UNPKG

@hot-updater/core

Version:

React Native OTA solution for self-hosted

102 lines (101 loc) 2.9 kB
export type Platform = "ios" | "android"; export interface Bundle { /** * The unique identifier for the bundle. uuidv7 */ id: string; /** * The platform the bundle is for. */ platform: Platform; /** * The target app version of the bundle. */ targetAppVersion: string; /** * Whether the bundle should force an update. */ shouldForceUpdate: boolean; /** * Whether the bundle is enabled. */ enabled: boolean; /** * The hash of the bundle. */ fileHash: string; /** * The git commit hash of the bundle. */ gitCommitHash: string | null; /** * The message of the bundle. */ message: string | null; /** * The name of the channel where the bundle is deployed. * * Examples: * - production: Production channel for end users * - development: Development channel for testing * - staging: Staging channel for quality assurance before production * - app-name: Channel for specific app instances (e.g., my-app, app-test) * * Different channel values can be used based on each app's requirements. */ channel: string; } type SnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? "_" : ""}${Lowercase<T>}${SnakeCase<U>}` : S; type SnakeKeyObject<T> = T extends Record<string, any> ? { [K in keyof T as SnakeCase<Extract<K, string>>]: T[K] extends object ? SnakeKeyObject<T[K]> : T[K]; } : T; export type SnakeCaseBundle = SnakeKeyObject<Bundle>; export type UpdateStatus = "ROLLBACK" | "UPDATE"; /** * The update info for the database layer. * This is the update info that is used by the database. */ export interface UpdateInfo { id: string; shouldForceUpdate: boolean; message: string | null; status: UpdateStatus; } /** * The update info for the app layer. * This is the update info that is used by the app. */ export interface AppUpdateInfo extends UpdateInfo { fileUrl: string | null; } export interface GetBundlesArgs { platform: Platform; /** * The current bundle id of the app. */ bundleId: string; /** * The current app version. */ appVersion: string; /** * Minimum bundle id that should be used. * This value is generated at build time via getMinBundleId(). * * @default "00000000-0000-0000-0000-000000000000" */ minBundleId?: string; /** * The name of the channel where the bundle is deployed. * * @default "production" * * Examples: * - production: Production channel for end users * - development: Development channel for testing * - staging: Staging channel for quality assurance before production * - app-name: Channel for specific app instances (e.g., my-app, app-test) */ channel?: string; } export {};