Skip to content
MANUAL OTAReferência

API do SDK TypeScript ​

Importe o singleton updates (ou crie uma instância configurada com createOtaUpdates) a partir de @getcortexlabs/ota-nativescript.

ts
import { updates, OtaError, OTA_ERROR_CODES } from '@getcortexlabs/ota-nativescript';

Métodos principais ​

  • updates.markReady(): boolean — confirma o boot atual de forma síncrona e offline, promovendo pendingLaunch para confirmedReleaseId.
  • updates.getBootInfo(): NativeBootInfo | null — retorna source, releaseId, bundlePath, binaryVersion, targetBuild, runtimeContract, pendingConfirmation, launchAttempts e lastRecovery.
  • updates.getCurrentRelease(): string | null — retorna o releaseId OTA ativo ou null no bundle embarcado.
  • updates.check(options?): Promise<CheckResult> — consulta POST /check, valida Ed25519, compatibilidade e directiveSeq.
  • updates.downloadAndStage(directive, options?): Promise<StageResult> — baixa manifesto e arquivos em staging/, valida SHA-256/tamanhos/paths, promove atomicamente para releases/ e executa GC.
  • updates.checkAndStage(options?): Promise<CheckAndStageResult> — executa check() + downloadAndStage() com proteção single-flight.
  • updates.collectGarbage(): Promise<string[]> — remove releases não referenciadas em disco.
  • updates.onEvent(listener): () => void — assina eventos estruturados de telemetria (check_started, download_progress, staged, boot_confirmed, recovery_triggered, error).