@capgo/cli
Version:
A CLI to upload to capgo servers
69 lines (68 loc) • 3.63 kB
TypeScript
import type { AppVersionInsert, AppVersionRow } from '../types/api';
import type { CapgoClient } from '../utils';
import { invokeCapgoCliApi } from '../utils';
interface VersionOptions {
silent?: boolean;
apikey?: string;
apiHost?: string;
/** Injectable for unit tests; defaults to invokeCapgoCliApi. */
invoke?: typeof invokeCapgoCliApi;
}
interface DeleteSpecificVersionOptions extends VersionOptions {
autoUnlink?: boolean;
}
interface CapgoHttpOptions {
apikey: string;
silent?: boolean;
apiHost?: string;
}
export type BundleVersionLookupRow = Pick<AppVersionRow, 'id' | 'name' | 'checksum' | 'deleted' | 'created_at'>;
export declare function fetchBundleVersionRow(apikey: string, appId: string, version: string, options?: VersionOptions & {
includeDeleted?: boolean;
}): Promise<BundleVersionLookupRow | null>;
/** A bundle row without the heavy per-file `manifest` and `native_packages` arrays. */
export type BundleSummaryRow = Omit<AppVersionRow, 'manifest' | 'native_packages'>;
export type UpsertAppVersionInput = Pick<AppVersionInsert, 'app_id' | 'name'> & Partial<Omit<AppVersionInsert, 'app_id' | 'name'>>;
export declare function upsertAppVersion(apikey: string, versionData: UpsertAppVersionInput, options?: VersionOptions): Promise<number>;
export declare function deleteAppVersion(client: CapgoClient | null, appid: string, bundle: string, options?: VersionOptions): Promise<void>;
/**
* Deletes one bundle with a single DELETE /bundle on the 2026-10-22 contract: the API resolves
* the name, reports a missing bundle (`bundle_not_found`) and refuses a linked one
* (`bundle_linked`, with the bundle id). Only that linked case does extra work: offer to unlink,
* then retry.
*/
export declare function deleteSpecificVersion(client: CapgoClient, appid: string, bundle: string, options?: DeleteSpecificVersionOptions): Promise<void>;
export interface CleanupBundleRow {
id: number;
name: string;
created_at: string | null;
linked: boolean;
}
export interface CleanupBundlesResult {
/** Active bundles of the app (placeholders excluded), before the `bundle` range filter. */
active: number;
/** Bundles inside the cleanup scope. */
total: number;
kept: CleanupBundleRow[];
removed: CleanupBundleRow[];
dry_run: boolean;
}
/** Server-side cleanup: the API selects and soft-deletes old bundles in one request. */
export declare function cleanupAppVersions(appid: string, body: {
keep: number;
bundle?: string;
ignoreChannel?: boolean;
dryRun: boolean;
ids?: number[];
}, options: CapgoHttpOptions & Pick<VersionOptions, 'invoke'>): Promise<CleanupBundlesResult>;
export declare function displayBundles(data: (Pick<AppVersionRow, 'name' | 'created_at'> & {
keep?: string;
})[], silent?: boolean): void;
export declare function getActiveAppVersions(apikeyOrClient: string | CapgoClient, appid: string, options?: VersionOptions): Promise<BundleSummaryRow[]>;
/** Looks up one active bundle by name with a single filtered request. */
export declare function getVersionData(apikeyOrClient: string | CapgoClient, appid: string, bundle: string, options?: VersionOptions): Promise<AppVersionRow>;
/** Looks up one active bundle by id with a single filtered request. */
export declare function getVersionDataById(apikey: string, appid: string, id: number, options?: VersionOptions): Promise<AppVersionRow | null>;
/** Newest active bundle: a one-row list page. */
export declare function getLatestAppVersion(apikey: string, appid: string, options?: VersionOptions): Promise<AppVersionRow | null>;
export {};