import type { InstallCommand, PackageManagerRunner, PackageManagerType } from '@capgo/find-package-manager'; import type { SemVer } from '@std/semver'; import type { SupabaseClient } from '@supabase/supabase-js'; import type { Buffer } from 'node:buffer'; import type { CapacitorConfig, ExtConfigPairs } from './config'; import type { Compatibility, CompatibilityDetails, NativePackage } from './schemas/common'; import type { Database } from './types/supabase.types'; import { spinner as spinnerC } from '@clack/prompts'; export declare const baseKey = ".capgo_key"; export declare const baseKeyV2 = ".capgo_key_v2"; export declare const baseKeyPub = ".capgo_key.pub"; export declare const baseKeyPubV2 = ".capgo_key_v2.pub"; export declare const defaultHost = "https://capgo.app"; export declare const defaultFileHost = "https://files.capgo.app"; export declare const defaultApiHost = "https://api.capgo.app"; export declare const defaultHostWeb = "https://console.capgo.app"; /** Build a console web-app URL (settings, builds, connect, etc.). */ export declare function consoleWebUrl(path?: string): string; export declare const UPLOAD_TIMEOUT = 120000; export declare const ALERT_UPLOAD_SIZE_BYTES: number; export declare const MAX_UPLOAD_LENGTH_BYTES: number; export declare const MAX_CHUNK_SIZE_BYTES: number; export declare const TUS_UPLOAD_RETRY_DELAYS: number[]; export declare const PACKNAME = "package.json"; export type ArrayElement = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; export type Organization = ArrayElement; export declare const regexSemver: RegExp; /** * Format an error for display. If it's a security policy error, * returns a human-readable message with actionable steps. */ export declare function formatError(error: any): string; export declare function check2FAAccessForOrg(supabase: SupabaseClient, orgId: string, silent?: boolean): Promise; type TagKey = Lowercase; /** Tag Type */ type Tags = Record; type Parser = 'markdown' | 'text'; /** * Options for publishing LogSnag events */ interface TrackOptions { /** * Channel name * example: "waitlist" */ channel: string; /** * Event name * example: "User Joined" */ event: string; /** * Event description * example: "joe@example.com joined waitlist" */ description?: string; /** * User ID * example: "user-123" */ user_id?: string; /** * Organization ID for actor-scoped tracking. */ org_id?: string; /** * Tracking payload contract version. */ tracking_version?: number; /** * Event icon (emoji) * must be a single emoji * example: "🎉" */ icon?: string; /** * Event tags * example: { username: "mattie" } */ tags?: Tags; /** * Send push notification */ notify?: boolean; /** * Parser for description */ parser?: Parser; /** * Event timestamp */ timestamp?: number | Date; } export type { OptionsBase } from './schemas/base'; export declare function wait(ms: number): Promise; interface PromptInteractivityOptions { silent?: boolean; stdinIsTTY?: boolean; stdoutIsTTY?: boolean; ci?: boolean; } export declare function canPromptInteractively({ silent, stdinIsTTY, stdoutIsTTY, ci, }?: PromptInteractivityOptions): boolean; export declare function projectIsMonorepo(dir: string): boolean; export declare function findRoot(dir: string): string; export declare function getPackageScripts(f?: string, file?: string | undefined): Record; export declare function getBundleVersion(f?: string, file?: string | undefined): string; /** * Get the actual installed version of a package from node_modules (not from package.json) * Uses multiple resolution strategies to find the installed version: * 1. require.resolve - Works with all package managers * 2. Walk up node_modules - Handles hoisted dependencies in monorepos * 3. Native config files (iOS/Android) - For @capgo/capacitor-updater only * 4. Fallback to declared version in package.json * * @param packageName - The package name to check * @param rootDir - The root directory of the project * @param packageJsonPath - Optional custom package.json path provided by user (takes priority if provided) */ export declare function getInstalledVersion(packageName: string, rootDir?: string, packageJsonPath?: string): Promise; export declare function getAllPackagesDependencies(f?: string, file?: string | undefined): Promise>; export declare function getDeclaredPackageVersionMap(f?: string, file?: string | undefined): Promise>; export declare function getConfig(silent?: boolean): Promise<{ config: { [x: string]: unknown; appId: string; appName: string; webDir: string; plugins?: Record | undefined; android?: Record | undefined; }; path: string; }>; export declare function updateConfigbyKey(key: string, newConfig: any): Promise; export declare function updateConfigUpdater(newConfig: any): Promise; export declare function getLocalConfig(silent?: boolean): Promise; interface CapgoConfig { supaHost?: string; supaKey?: string; host: string; hostWeb: string; hostFilesApi: string; hostApi: string; } export declare function getRemoteConfig(silent?: boolean, signal?: AbortSignal): Promise; interface CapgoFilesConfig { partialUpload: boolean; partialUploadForced: boolean; TUSUpload: boolean; TUSUploadForced: boolean; maxUploadLength: number; maxChunkSize: number; alertUploadSize: number; } export declare function getRemoteFileConfig(): Promise; export declare function createSupabaseClient(apikey: string, supaHost?: string, supaKey?: string, silent?: boolean, instrument?: boolean, signal?: AbortSignal): Promise>; export declare function isPayingOrg(supabase: SupabaseClient, orgId: string): Promise; export declare function isTrialOrg(supabase: SupabaseClient, orgId: string): Promise; export declare function isAllowedActionOrg(supabase: SupabaseClient, orgId: string): Promise; export declare function isAllowedActionAppIdApiKey(supabase: SupabaseClient, appId: string, apikey: string): Promise; export declare enum OrganizationPerm { none = 0, read = 1, upload = 2, write = 3, admin = 4, super_admin = 5 } export declare const hasOrganizationPerm: (perm: OrganizationPerm, required: OrganizationPerm) => boolean; export declare function isAllowedAppOrg(supabase: SupabaseClient, apikey: string, appId: string): Promise<{ okay: true; data: OrganizationPerm; } | { okay: false; error: 'INVALID_APIKEY' | 'NO_APP' | 'NO_ORG'; }>; export declare function checkRemoteCliMessages(supabase: SupabaseClient, orgId: string, cliVersion: string): Promise; export declare function checkPlanValid(supabase: SupabaseClient, orgId: string, apikey: string, appId?: string, warning?: boolean): Promise; export declare function checkPlanValidUpload(supabase: SupabaseClient, orgId: string, apikey: string, appId?: string, warning?: boolean): Promise; export declare function findSavedKeySilent(): string | undefined; export declare function findSavedKey(quiet?: boolean): string; export declare function getContentType(filename: string): string; export declare function findProjectType(options?: { quiet?: boolean; packageJsonPath?: string; }): Promise; export declare function findMainFileForProjectType(projectType: string, isTypeScript: boolean, rootDir?: string): string | null; export declare function findBuildCommandForProjectType(projectType: string): Promise<"build" | "generate">; export declare function findMainFile(silent?: boolean, rootDir?: string): Promise; export declare function updateOrCreateVersion(supabase: SupabaseClient, update: Database['public']['Tables']['app_versions']['Insert']): Promise>; export declare function uploadUrl(supabase: SupabaseClient, appId: string, name: string): Promise; export declare const BROTLI_MIN_UPDATER_VERSION_V5 = "5.10.0"; export declare const BROTLI_MIN_UPDATER_VERSION_V6 = "6.25.0"; export declare const BROTLI_MIN_UPDATER_VERSION_V7 = "7.0.30"; export declare function isDeprecatedPluginVersion(parsedPluginVersion: SemVer, minFive?: string, minSix?: string, minSeven?: string): boolean; export declare function generateManifest(path: string): Promise<{ file: string; hash: string; }[]>; export type manifestType = Awaited>; export declare function zipFile(filePath: string): Promise; export declare function zipFileUnix(filePath: string): Buffer; export declare function zipFileWindows(filePath: string): Promise; export declare function uploadTUS(apikey: string, data: Buffer, orgId: string, appId: string, name: string, spinner: ReturnType, localConfig: CapgoConfig, chunkSize: number): Promise; export declare function deletedFailedVersion(supabase: SupabaseClient, appId: string, name: string): Promise; export declare function updateOrCreateChannel(supabase: SupabaseClient, update: Database['public']['Tables']['channels']['Insert']): Promise>; export declare function sendEvent(capgkey: string, payload: TrackOptions & { notifyConsole?: boolean; nonPersonTags?: Record; }, verbose?: boolean, signal?: AbortSignal): Promise; export declare function show2FADeniedError(organizationName?: string): never; export declare function filterOrgsByPermission(supabase: SupabaseClient, apikey: string, orgs: Organization[], permissionKey: string): Promise; export declare function getOrganizationListWithPermission(supabase: SupabaseClient, apikey: string, permissionKey: string): Promise<{ allOrganizations: Organization[]; allowedOrganizations: Organization[]; }>; export declare function getOrganizationWithPermission(supabase: SupabaseClient, apikey: string, permissionKey: string): Promise; export declare function resolveUserIdFromApiKey(supabase: SupabaseClient, apikey: string, silent?: boolean): Promise; interface CliPermissionScope { orgId?: string | null; appId?: string | null; channelId?: number | null; } export declare function hasCliPermission(supabase: SupabaseClient, apikey: string, permissionKey: string, scope?: CliPermissionScope): Promise; export declare function assertCliPermission(supabase: SupabaseClient, apikey: string, permissionKey: string, scope?: CliPermissionScope, options?: { message?: string; silent?: boolean; }): Promise; export declare function assertOrgPermission(supabase: SupabaseClient, apikey: string, permissionKey: string, orgId: string, message: string, silent: boolean): Promise; export declare function getOrganizationId(supabase: SupabaseClient, appId: string): Promise; export declare function getHumanDate(createdA: string | null): string; export declare function getPMAndCommand(): { pm: PackageManagerType; command: InstallCommand; installCommand: string; runner: PackageManagerRunner; }; export declare function getNativeProjectResetAdvice(platformRunner: string, nativePlatform: 'ios' | 'android'): { summary: string; command: string; }; export declare function getLocalDependencies(packageJsonPath: string | undefined, nodeModulesString: string | undefined): Promise<{ name: string; version: string; requested_version?: string; native: boolean; ios_checksum?: string; android_checksum?: string; }[]>; export declare function getRemoteChecksums(supabase: SupabaseClient, appId: string, channel: string): Promise; export type { NativePackage } from './schemas/common'; export declare function convertNativePackages(nativePackages: NativePackage[]): Map; export declare function getRemoteDependencies(supabase: SupabaseClient, appId: string, channel: string): Promise>; export type { Compatibility, CompatibilityDetails, IncompatibilityReason } from './schemas/common'; export declare function getAppId(appId: string | undefined, config: CapacitorConfig | undefined): any; /** * Check if a package is compatible and return detailed reasons if not */ export declare function getCompatibilityDetails(pkg: Compatibility): CompatibilityDetails; /** * Simple compatibility check (backward compatible) */ export declare function isCompatible(pkg: Compatibility): boolean; export declare function checkCompatibilityCloud(supabase: SupabaseClient, appId: string, channel: string, packageJsonPath: string | undefined, nodeModules: string | undefined): Promise<{ finalCompatibility: { name: string; localVersion?: string | undefined; remoteVersion?: string | undefined; localRequestedVersion?: string | undefined; remoteRequestedVersion?: string | undefined; localIosChecksum?: string | undefined; remoteIosChecksum?: string | undefined; localAndroidChecksum?: string | undefined; remoteAndroidChecksum?: string | undefined; }[]; localDependencies: { name: string; version: string; requested_version?: string; native: boolean; ios_checksum?: string; android_checksum?: string; }[]; }>; export declare function checkCompatibilityNativePackages(supabase: SupabaseClient, appId: string, channel: string, nativePackages: NativePackage[]): Promise<{ finalCompatibility: { name: string; localVersion?: string | undefined; remoteVersion?: string | undefined; localRequestedVersion?: string | undefined; remoteRequestedVersion?: string | undefined; localIosChecksum?: string | undefined; remoteIosChecksum?: string | undefined; localAndroidChecksum?: string | undefined; remoteAndroidChecksum?: string | undefined; }[]; localDependencies: { name: string; version: string; requested_version?: string | undefined; ios_checksum?: string | undefined; android_checksum?: string | undefined; }[]; }>; export interface IosUpdaterSyncValidationResult { shouldCheck: boolean; valid: boolean; details: string[]; } /** * Validate whether the iOS native project is correctly synced for capacitor-updater. * * `shouldCheck` is `false` when no iOS project is present or no updater signals are detected * (no dependency declaration, installed package, or native references). `shouldCheck` is `true` * as soon as any signal indicates updater should be wired, then both dependency definitions * (`Podfile` or SPM `Package.swift`) and generated native outputs (`Podfile.lock`, * `capacitor.plugins.json`, or `ios/App/App/capacitor.config.json`) must include * updater markers for `valid` to be `true`. */ export declare function validateIosUpdaterSync(rootDir?: string, packageJsonPath?: string): IosUpdaterSyncValidationResult; interface PromptAndSyncOptions { validateIosUpdater?: boolean; packageJsonPath?: string; } export declare function promptAndSyncCapacitor(isInit?: boolean, orgId?: string, apikey?: string, options?: PromptAndSyncOptions): Promise;