UNPKG

balena-sdk

Version:
93 lines (92 loc) 4.51 kB
import { type ExtendedPineTypedResult } from '../util'; import type { BalenaRequestStreamResult } from 'balena-request'; import type { Dictionary } from '../../typings/utils'; import type { Release } from '../types/models'; import type { InjectedDependenciesParam, InjectedOptionsParam, PineOptions, PineTypedResult } from '..'; export declare enum OsTypes { DEFAULT = "default", ESR = "esr" } export declare enum OsVariant { production = "prod", development = "dev" } export type OsLines = 'next' | 'current' | 'sunset' | 'outdated' | undefined; declare const baseReleasePineOptions: { $select: ("variant" | "id" | "phase" | "known_issue_list" | "raw_version")[]; $expand: { release_tag: { $select: ("value" | "tag_key")[]; }; }; }; export interface OsVersion extends PineTypedResult<Release, typeof baseReleasePineOptions> { strippedVersion: string; basedOnVersion?: string; osType: string; line?: OsLines; } export interface ImgConfigOptions { network?: 'ethernet' | 'wifi'; appUpdatePollInterval?: number; provisioningKeyName?: string; provisioningKeyExpiryDate?: string; provisioningKeyDescription?: string; wifiKey?: string; wifiSsid?: string; ip?: string; gateway?: string; netmask?: string; deviceType?: string; version: string; developmentMode?: boolean; } export interface OsUpdateVersions { versions: string[]; recommended: string | undefined; current: string | undefined; } export interface OsDownloadOptions extends Pick<ImgConfigOptions, 'developmentMode' | 'appUpdatePollInterval' | 'network' | 'wifiKey' | 'wifiSsid'> { deviceType: string; version?: string; appId?: number; fileType?: '.img' | '.zip' | '.gz'; imageType?: 'raw' | 'flasher'; } declare const getOsModel: (deps: InjectedDependenciesParam, opts: InjectedOptionsParam) => { _getNormalizedDeviceTypeSlug: (deviceTypeSlug: string) => Promise<string>; _getDownloadSize: (deviceType: string, version: string) => Promise<number>; _clearDeviceTypesAndOsVersionCaches: () => void; _getMaxSatisfyingVersion: (versionOrRange: string, osVersions: Array<Pick<OsVersion, "raw_version">>) => string | null; OsTypes: typeof OsTypes; getAllOsVersions: { <TP extends PineOptions<Release> | undefined>(deviceType: string, options?: TP): Promise<Array<ExtendedPineTypedResult<Release, OsVersion, TP>>>; <TP extends PineOptions<Release> | undefined>(deviceTypes: string[], options?: TP): Promise<Dictionary<Array<ExtendedPineTypedResult<Release, OsVersion, TP>>>>; }; getAvailableOsVersions: { (deviceType: string, options?: { includeDraft?: boolean; }): Promise<OsVersion[]>; (deviceTypes: string[], options?: { includeDraft?: boolean; }): Promise<Dictionary<OsVersion[]>>; <TP extends PineOptions<Release>>(deviceType: string, options: TP & { includeDraft?: boolean; }): Promise<Array<ExtendedPineTypedResult<Release, OsVersion, TP>>>; <TP extends PineOptions<Release>>(deviceTypes: string[], options: TP & { includeDraft?: boolean; }): Promise<Dictionary<Array<ExtendedPineTypedResult<Release, OsVersion, TP>>>>; }; getMaxSatisfyingVersion: (deviceType: string, versionOrRange?: string, osType?: "default" | "esr") => Promise<string | null>; getDownloadSize: (deviceType: string, version?: string) => Promise<number>; download: (() => never) | (({ deviceType, version, ...restOptions }: OsDownloadOptions) => Promise<BalenaRequestStreamResult>); getConfig: (slugOrUuidOrId: string | number, options: ImgConfigOptions) => Promise<object>; isSupportedOsUpdate: (deviceType: string, currentVersion: string, targetVersion: string) => Promise<boolean>; getOsUpdateType: (deviceType: string, currentVersion: string, targetVersion: string) => Promise<string>; getSupportedOsUpdateVersions: (deviceType: string, currentVersion: string, options?: { includeDraft?: boolean; }) => Promise<OsUpdateVersions>; isArchitectureCompatibleWith: (osArchitecture: string, applicationArchitecture: string) => boolean; getSupervisorReleasesForCpuArchitecture: <TP extends PineOptions<Release> | undefined>(cpuArchitectureSlugOrId: string | number, options?: TP) => Promise<Array<ExtendedPineTypedResult<Release, Pick<Release, "id" | "raw_version" | "known_issue_list">, TP>>>; }; export default getOsModel;