146 lines
5.5 KiB
TypeScript
146 lines
5.5 KiB
TypeScript
/**
|
||
* Mobile app release lifecycle: admin CRUD, APK validation, public check/download, telemetry.
|
||
*/
|
||
import { HttpError } from '../utils/httpError';
|
||
import * as repo from '../repositories/mobileAppReleaseRepository';
|
||
import type { MobileAppRelease, MobileChannel, MobileReleaseEventType, MobileUpdatePolicy } from '../models/mobileAppRelease.model';
|
||
export declare class MobileReleaseError extends HttpError {
|
||
constructor(status: number, message: string, code?: string);
|
||
}
|
||
/** Deterministic rollout bucket 0–99 from device id. */
|
||
export declare function rolloutBucket(deviceId: string): number;
|
||
export declare function isRolloutEligible(deviceId: string, rolloutPercent: number): boolean;
|
||
export declare function hashDeviceId(deviceId: string): string;
|
||
export declare function createDownloadToken(releaseId: string): {
|
||
token: string;
|
||
expiresAt: number;
|
||
};
|
||
export declare function verifyDownloadToken(token: string, releaseId: string): boolean;
|
||
/** Latest published Android APK for the public website (ignores staged rollout). */
|
||
export declare function getLatestPublicAndroidApk(channel?: MobileChannel): Promise<{
|
||
available: boolean;
|
||
versionName: string | null;
|
||
versionCode: number | null;
|
||
fileSizeBytes: number | null;
|
||
sha256: string | null;
|
||
/** Absolute URL using APP_PUBLIC_URL (may differ from the browser origin). */
|
||
downloadUrl: string | null;
|
||
/** Same-origin path — prefer this on the landing page. */
|
||
downloadPath: string | null;
|
||
publishedAt: string | null;
|
||
packageName: string | null;
|
||
}>;
|
||
export declare function getSettings(): Promise<import("../models/mobileAppRelease.model").MobileAppUpdateSettings>;
|
||
export declare function updateSettings(input: {
|
||
minSupportedVersionCode?: number;
|
||
checkIntervalSeconds?: number;
|
||
expectedPackageName?: string;
|
||
}): Promise<import("../models/mobileAppRelease.model").MobileAppUpdateSettings>;
|
||
export declare function listReleases(filters: Parameters<typeof repo.listReleases>[0]): Promise<{
|
||
items: MobileAppRelease[];
|
||
total: number;
|
||
}>;
|
||
export declare function getRelease(id: string): Promise<MobileAppRelease>;
|
||
export declare function createRelease(input: {
|
||
platform?: 'android' | 'ios';
|
||
channel?: MobileChannel;
|
||
versionName: string;
|
||
versionCode: number;
|
||
previousVersionName?: string | null;
|
||
whatsNew?: string;
|
||
bugFixes?: string;
|
||
updatePolicy?: MobileUpdatePolicy;
|
||
rolloutPercent?: number;
|
||
createdBy?: string | null;
|
||
}): Promise<MobileAppRelease>;
|
||
export declare function updateReleaseMeta(id: string, patch: {
|
||
versionName?: string;
|
||
previousVersionName?: string | null;
|
||
whatsNew?: string;
|
||
bugFixes?: string;
|
||
updatePolicy?: MobileUpdatePolicy;
|
||
rolloutPercent?: number;
|
||
}): Promise<MobileAppRelease>;
|
||
export declare function attachApk(id: string, uploadedAbsolutePath: string): Promise<MobileAppRelease>;
|
||
export declare function submitForValidation(id: string): Promise<MobileAppRelease>;
|
||
export declare function publish(id: string): Promise<MobileAppRelease>;
|
||
export declare function suspend(id: string): Promise<MobileAppRelease>;
|
||
export declare function retire(id: string): Promise<MobileAppRelease>;
|
||
/**
|
||
* Permanently deletes a release: APK file on disk, FIM snapshot, events, DB row.
|
||
* Blocks deletion of the current highest published release for that platform/channel
|
||
* (would leave clients without an update target).
|
||
*/
|
||
export declare function hardDelete(id: string, actor?: {
|
||
userId: string;
|
||
ipAddress?: string;
|
||
userAgent?: string;
|
||
}): Promise<{
|
||
deleted: true;
|
||
versionCode: number;
|
||
versionName: string;
|
||
}>;
|
||
export type UpdateCheckResult = {
|
||
updateAvailable: boolean;
|
||
blocked: boolean;
|
||
policy: MobileUpdatePolicy | null;
|
||
versionName: string | null;
|
||
versionCode: number | null;
|
||
whatsNew: string | null;
|
||
bugFixes: string | null;
|
||
fileSizeBytes: number | null;
|
||
sha256: string | null;
|
||
downloadUrl: string | null;
|
||
/** Same-origin API path — prefer this on mobile so APP_PUBLIC_URL host mismatches do not apply. */
|
||
downloadPath: string | null;
|
||
minSupportedVersionCode: number;
|
||
checkIntervalSeconds: number;
|
||
publishedAt: string | null;
|
||
packageName: string | null;
|
||
};
|
||
export declare function checkAndroidUpdate(input: {
|
||
versionCode: number;
|
||
versionName?: string;
|
||
channel?: MobileChannel;
|
||
deviceId: string;
|
||
}): Promise<UpdateCheckResult>;
|
||
export declare function openDownloadStream(releaseId: string, token: string): Promise<{
|
||
release: MobileAppRelease;
|
||
absolutePath: string;
|
||
}>;
|
||
export declare function recordClientEvent(input: {
|
||
eventType: MobileReleaseEventType;
|
||
releaseId?: string;
|
||
versionCode?: number;
|
||
deviceId?: string;
|
||
userId?: string | null;
|
||
channel?: MobileChannel;
|
||
}): Promise<void>;
|
||
export declare function getStats(): Promise<{
|
||
byStatus: Array<{
|
||
status: string;
|
||
count: number;
|
||
}>;
|
||
byVersion: Array<{
|
||
id: string;
|
||
versionName: string;
|
||
versionCode: number;
|
||
status: string;
|
||
downloadCount: number;
|
||
downloadFailCount: number;
|
||
installConfirmCount: number;
|
||
}>;
|
||
eventCounts: Array<{
|
||
eventType: string;
|
||
count: number;
|
||
}>;
|
||
}>;
|
||
/**
|
||
* Returns whether a client versionCode is allowed to call sensitive APIs.
|
||
* When blocked, returns the update payload for a 426 response.
|
||
*/
|
||
export declare function evaluateClientVersionGate(versionCode: number | null): Promise<{
|
||
allowed: boolean;
|
||
update?: UpdateCheckResult;
|
||
}>;
|
||
//# sourceMappingURL=mobileAppReleaseService.d.ts.map
|