UNPKG

balena-sdk

Version:
227 lines (226 loc) • 11.6 kB
import type { BalenaRequestStreamResult } from 'balena-request'; import type { Dictionary } from '../../typings/utils'; import type { Release, ReleaseTag } from '../types/models'; import type { InjectedDependenciesParam, InjectedOptionsParam } from '..'; import type { ODataOptionsWithoutCount, OptionsToResponse } from 'pinejs-client-core'; 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: { readonly $select: readonly ["id", "known_issue_list", "raw_version", "variant", "phase"]; readonly $expand: { readonly release_tag: { readonly $select: readonly ["tag_key", "value"]; }; }; }; type PickExpandedRelease = OptionsToResponse<Release['Read'], typeof baseReleasePineOptions, undefined>[number]; type OsVersionProps = { strippedVersion: string; basedOnVersion?: string; osType: string; line?: OsLines; }; export type OsVersion = PickExpandedRelease & OsVersionProps; type OsVersionResponse<TP extends ODataOptionsWithoutCount<Release['Read']>> = Array<OptionsToResponse<Release['Read'], NonNullable<TP>, undefined>[number] & OsVersionProps>; 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: { (deviceType: string, options?: undefined): Promise<OsVersion[]>; (deviceType: string[], options?: undefined): Promise<Dictionary<OsVersion[]>>; <TP extends ODataOptionsWithoutCount<Release["Read"]>>(deviceType: string, options?: TP): Promise<OsVersionResponse<NonNullable<TP>>>; <TP extends ODataOptionsWithoutCount<Release["Read"]>>(deviceTypes: string[], options?: TP): Promise<Dictionary<OsVersionResponse<NonNullable<TP>>>>; }; getAvailableOsVersions: { (deviceType: string, options?: { includeDraft?: boolean; }): Promise<OsVersion[]>; (deviceTypes: string[], options?: { includeDraft?: boolean; }): Promise<Dictionary<OsVersion[]>>; <TP extends ODataOptionsWithoutCount<Release["Read"]>>(deviceType: string, options: TP & { includeDraft?: boolean; }): Promise<OsVersionResponse<TP>>; <TP extends ODataOptionsWithoutCount<Release["Read"]>>(deviceTypes: string[], options: TP & { includeDraft?: boolean; }): Promise<Dictionary<OsVersionResponse<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, { osType, ...options }?: { osType?: "default" | "esr" | null; includeDraft?: boolean; }) => Promise<OsUpdateVersions>; isArchitectureCompatibleWith: (osArchitecture: string, applicationArchitecture: string) => boolean; getSupervisorReleasesForCpuArchitecture: <T extends ODataOptionsWithoutCount<Release["Read"]>>(cpuArchitectureSlugOrId: string | number, options?: T) => Promise<OptionsToResponse<{ created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"]; id: import("@balena/sbvr-types").Types["Integer"]["Read"]; belongs_to__application: { __id: import("..").Application["Read"]["id"]; } | [import("..").Application["Read"]]; commit: import("@balena/sbvr-types").Types["Short Text"]["Read"]; composition: import("@balena/sbvr-types").Types["JSON"]["Read"]; status: import("@balena/sbvr-types").Types["Short Text"]["Read"]; source: import("@balena/sbvr-types").Types["Short Text"]["Read"]; build_log: import("@balena/sbvr-types").Types["Text"]["Read"] | null; is_invalidated: import("@balena/sbvr-types").Types["Boolean"]["Read"]; start_timestamp: import("@balena/sbvr-types").Types["Date Time"]["Read"]; end_timestamp: import("@balena/sbvr-types").Types["Date Time"]["Read"] | null; update_timestamp: import("@balena/sbvr-types").Types["Date Time"]["Read"]; release_version: import("@balena/sbvr-types").Types["Short Text"]["Read"] | null; contract: import("@balena/sbvr-types").Types["JSON"]["Read"] | null; is_passing_tests: import("@balena/sbvr-types").Types["Boolean"]["Read"]; is_finalized_at__date: import("@balena/sbvr-types").Types["Date Time"]["Read"] | null; phase: "next" | "current" | "sunset" | "end-of-life" | null; is_final: import("@balena/sbvr-types").Types["Boolean"]["Read"]; semver: import("@balena/sbvr-types").Types["Short Text"]["Read"]; semver_major: import("@balena/sbvr-types").Types["Integer"]["Read"]; semver_minor: import("@balena/sbvr-types").Types["Integer"]["Read"]; semver_patch: import("@balena/sbvr-types").Types["Integer"]["Read"]; semver_prerelease: import("@balena/sbvr-types").Types["Short Text"]["Read"]; semver_build: import("@balena/sbvr-types").Types["Short Text"]["Read"]; variant: import("@balena/sbvr-types").Types["Short Text"]["Read"]; revision: import("@balena/sbvr-types").Types["Integer"]["Read"] | null; raw_version: import("@balena/sbvr-types").Types["Short Text"]["Read"]; version: import("@balena/sbvr-types").Types["JSON"]["Read"]; known_issue_list: import("@balena/sbvr-types").Types["Text"]["Read"] | null; note: import("@balena/sbvr-types").Types["Text"]["Read"] | null; invalidation_reason: import("@balena/sbvr-types").Types["Text"]["Read"] | null; is_created_by__user: { __id: import("..").User["Read"]["id"]; } | [import("..").User["Read"]] | [] | null; release__has__tag_key?: Array<ReleaseTag["Read"]>; release_tag?: Array<ReleaseTag["Read"]>; release__has__asset_key?: Array<import("..").ReleaseAsset["Read"]>; release_asset?: Array<import("..").ReleaseAsset["Read"]>; image__is_part_of__release?: Array<import("..").ImageIsPartOfRelease["Read"]>; release_image?: Array<import("..").ImageIsPartOfRelease["Read"]>; contains__image?: Array<import("..").ImageIsPartOfRelease["Read"]>; should_be_running_on__application?: Array<import("..").Application["Read"]>; should_be_running_on__device?: Array<import("..").Device["Read"]>; is_running_on__device?: Array<import("..").Device["Read"]>; is_pinned_to__device?: Array<import("..").Device["Read"]>; should_operate__device?: Array<import("..").Device["Read"]>; should_manage__device?: Array<import("..").Device["Read"]>; provides__device__installs__image?: Array<import("..").ImageInstall["Read"]>; provides__image_install?: Array<import("..").ImageInstall["Read"]>; }, import("../util").MergePineOptions<import("../util").AliasResourceRead, { $select: ("id" | "raw_version" | "known_issue_list")[]; $filter: { status: "success"; is_final: true; is_invalidated: false; semver_major: { $gt: number; }; belongs_to__application: { $any: { $alias: string; $expr: { $and: ({ a: { slug: { $startswith: string; $endswith?: undefined; }; }; } | { a: { slug: { $endswith: string; readonly $startswith?: undefined; }; }; })[]; a: { is_public: true; is_host: false; is_for__device_type: { $any: { $alias: string; $expr: { dt: { is_of__cpu_architecture: number | { $any: { $alias: string; $expr: { c: { slug: string; }; }; }; }; }; }; }; }; }; }; }; }; }; $orderby: ({ semver_major: "desc"; semver_minor?: undefined; semver_patch?: undefined; revision?: undefined; } | { semver_minor: "desc"; semver_major?: undefined; semver_patch?: undefined; revision?: undefined; } | { semver_patch: "desc"; semver_major?: undefined; semver_minor?: undefined; revision?: undefined; } | { revision: "desc"; semver_major?: undefined; semver_minor?: undefined; semver_patch?: undefined; })[]; }, T>, undefined>>; }; export default getOsModel;