import type { InstallCommand, PackageManagerRunner, PackageManagerType } from '@capgo/find-package-manager';
import type { SupabaseClient } from '@supabase/supabase-js';
import type { Buffer } from 'node:buffer';
import type { CapacitorConfig, ExtConfigPairs } from './config';
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";
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 PACKNAME = "package.json";
export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
export type Organization = ArrayElement<Database['public']['Functions']['get_orgs_v6']['Returns']>;
export declare const regexSemver: RegExp;
export declare const formatError: (error: any) => string;
type TagKey = Lowercase<string>;
/** Tag Type */
type Tags = Record<TagKey, string | number | boolean>;
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;
    /**
     * 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 interface OptionsBase {
    apikey: string;
    supaHost?: string;
    supaAnon?: string;
}
export declare function wait(ms: number): Promise<unknown>;
export declare function projectIsMonorepo(dir: string): boolean;
export declare function findRoot(dir: string): string;
export declare function getPackageScripts(f?: string, file?: string | undefined): Record<string, string>;
export declare function getBundleVersion(f?: string, file?: string | undefined): string;
export declare function getAllPackagesDependencies(f?: string, file?: string | undefined): Promise<Map<string, string>>;
export declare function getConfig(): Promise<ExtConfigPairs>;
export declare function updateConfigbyKey(key: string, newConfig: any): Promise<ExtConfigPairs>;
export declare function updateConfigUpdater(newConfig: any): Promise<ExtConfigPairs>;
export declare function getLocalConfig(): Promise<CapgoConfig>;
interface CapgoConfig {
    supaHost?: string;
    supaKey?: string;
    host: string;
    hostWeb: string;
    hostFilesApi: string;
    hostApi: string;
}
export declare function getRemoteConfig(): Promise<CapgoConfig>;
interface CapgoFilesConfig {
    partialUpload: boolean;
    partialUploadForced: boolean;
    TUSUpload: boolean;
    TUSUploadForced: boolean;
    maxUploadLength: number;
    maxChunkSize: number;
    alertUploadSize: number;
}
export declare function getRemoteFileConfig(): Promise<CapgoFilesConfig | {
    partialUpload: boolean;
    TUSUpload: boolean;
    partialUploadForced: boolean;
    TUSUploadForced: boolean;
    maxUploadLength: number;
    maxChunkSize: number;
    alertUploadSize: number;
}>;
export declare function createSupabaseClient(apikey: string, supaHost?: string, supaKey?: string): Promise<SupabaseClient<Database, "public", "public", {
    Tables: {
        apikeys: {
            Row: {
                created_at: string | null;
                id: number;
                key: string;
                limited_to_apps: string[] | null;
                limited_to_orgs: string[] | null;
                mode: Database["public"]["Enums"]["key_mode"];
                name: string;
                updated_at: string | null;
                user_id: string;
            };
            Insert: {
                created_at?: string | null;
                id?: number;
                key: string;
                limited_to_apps?: string[] | null;
                limited_to_orgs?: string[] | null;
                mode: Database["public"]["Enums"]["key_mode"];
                name: string;
                updated_at?: string | null;
                user_id: string;
            };
            Update: {
                created_at?: string | null;
                id?: number;
                key?: string;
                limited_to_apps?: string[] | null;
                limited_to_orgs?: string[] | null;
                mode?: Database["public"]["Enums"]["key_mode"];
                name?: string;
                updated_at?: string | null;
                user_id?: string;
            };
            Relationships: [{
                foreignKeyName: "apikeys_user_id_fkey";
                columns: ["user_id"];
                isOneToOne: false;
                referencedRelation: "users";
                referencedColumns: ["id"];
            }];
        };
        app_versions: {
            Row: {
                app_id: string;
                checksum: string | null;
                comment: string | null;
                created_at: string | null;
                deleted: boolean;
                external_url: string | null;
                id: number;
                link: string | null;
                manifest: Database["public"]["CompositeTypes"]["manifest_entry"][] | null;
                min_update_version: string | null;
                name: string;
                native_packages: import("./types/supabase.types").Json[] | null;
                owner_org: string;
                r2_path: string | null;
                session_key: string | null;
                storage_provider: string;
                updated_at: string | null;
                user_id: string | null;
            };
            Insert: {
                app_id: string;
                checksum?: string | null;
                comment?: string | null;
                created_at?: string | null;
                deleted?: boolean;
                external_url?: string | null;
                id?: number;
                link?: string | null;
                manifest
                /**
                 * Options for publishing LogSnag events
                 */
                ? /**
                 * Options for publishing LogSnag events
                 */: Database["public"]["CompositeTypes"]["manifest_entry"][] | null;
                min_update_version?: string | null;
                name: string;
                native_packages?: import("./types/supabase.types").Json[] | null;
                owner_org: string;
                r2_path?: string | null;
                session_key?: string | null;
                storage_provider?: string;
                updated_at?: string | null;
                user_id?: string | null;
            };
            Update: {
                app_id?: string;
                checksum?: string | null;
                comment?: string | null;
                created_at?: string | null;
                deleted?: boolean;
                external_url?: string | null;
                id?: number;
                link?: string | null;
                manifest?: Database["public"]["CompositeTypes"]["manifest_entry"][] | null;
                min_update_version?: string | null;
                name?: string;
                native_packages?: import("./types/supabase.types").Json[] | null;
                owner_org?: string;
                r2_path?: string | null;
                session_key?: string | null;
                storage_provider?: string;
                updated_at?: string | null;
                user_id?: string | null;
            };
            Relationships: [{
                foreignKeyName: "app_versions_app_id_fkey";
                columns: ["app_id"];
                isOneToOne: false;
                referencedRelation: "apps";
                referencedColumns: ["app_id"];
            }, {
                foreignKeyName: "owner_org_id_fkey";
                columns: ["owner_org"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }];
        };
        app_versions_meta: {
            Row: {
                app_id: string;
                checksum: string;
                created_at: string | null;
                id: number;
                owner_org: string;
                size: number;
                updated_at: string | null;
            };
            Insert: {
                app_id: string;
                checksum: string;
                created_at?: string | null;
                id?: number;
                owner_org: string;
                size: number;
                updated_at?: string | null;
            };
            Update: {
                app_id?: string;
                checksum?: string;
                created_at?: string | null;
                id?: number;
                owner_org?: string;
                size?: number;
                updated_at?: string | null;
            };
            Relationships: [{
                foreignKeyName: "app_versions_meta_app_id_fkey";
                columns: ["app_id"];
                isOneToOne: false;
                referencedRelation: "apps";
                referencedColumns: ["app_id"];
            }, {
                foreignKeyName: "app_versions_meta_id_fkey";
                columns: ["id"];
                isOneToOne: true;
                referencedRelation: "app_versions";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "owner_org_id_fkey";
                columns: ["owner_org"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }];
        };
        apps: {
            Row: {
                app_id: string;
                created_at: string | null;
                default_upload_channel: string;
                icon_url: string;
                id: string | null;
                last_version: string | null;
                name: string | null;
                owner_org: string;
                retention: number;
                transfer_history: import("./types/supabase.types").Json[] | null;
                updated_at: string | null;
                user_id: string | null;
            };
            Insert: {
                app_id: string;
                created_at?: string | null;
                default_upload_channel?: string;
                icon_url: string;
                id?: string | null;
                last_version?: string | null;
                name?: string | null;
                owner_org: string;
                retention?: number;
                transfer_history?: import("./types/supabase.types").Json[] | null;
                updated_at?: string | null;
                user_id?: string | null;
            };
            Update: {
                app_id?: string;
                created_at?: string | null;
                default_upload_channel?: string;
                icon_url?: string;
                id?: string | null;
                last_version?: string | null;
                name?: string | null;
                owner_org?: string;
                retention?: number;
                transfer_history?: import("./types/supabase.types").Json[] | null;
                updated_at?: string | null;
                user_id?: string | null;
            };
            Relationships: [{
                foreignKeyName: "apps_user_id_fkey";
                columns: ["user_id"];
                isOneToOne: false;
                referencedRelation: "users";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "owner_org_id_fkey";
                columns: ["owner_org"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }];
        };
        bandwidth_usage: {
            Row: {
                app_id: string;
                device_id: string;
                file_size: number;
                id: number;
                timestamp: string;
            };
            Insert: {
                app_id: string;
                device_id: string;
                file_size: number;
                id?: number;
                timestamp?: string;
            };
            Update: {
                app_id?: string;
                device_id?: string;
                file_size?: number;
                id?: number;
                timestamp?: string;
            };
            Relationships: [];
        };
        capgo_credits_steps: {
            Row: {
                created_at: string;
                id: number;
                price_per_unit: number;
                step_max: number;
                step_min: number;
                stripe_id: string | null;
                type: string;
                unit_factor: number;
                updated_at: string;
            };
            Insert: {
                created_at?: string;
                id?: number;
                price_per_unit: number;
                step_max: number;
                step_min: number;
                stripe_id?: string | null;
                type: string;
                unit_factor?: number;
                updated_at?: string;
            };
            Update: {
                created_at?: string;
                id?: number;
                price_per_unit?: number;
                step_max?: number;
                step_min?: number;
                stripe_id?: string | null;
                type?: string;
                unit_factor?: number;
                updated_at?: string;
            };
            Relationships: [];
        };
        channel_devices: {
            Row: {
                app_id: string;
                channel_id: number;
                created_at: string | null;
                device_id: string;
                id: number;
                owner_org: string;
                updated_at: string;
            };
            Insert: {
                app_id: string;
                channel_id: number;
                created_at?: string | null;
                device_id: string;
                id?: number;
                owner_org: string;
                updated_at?: string;
            };
            Update: {
                app_id?: string;
                channel_id?: number;
                created_at?: string | null;
                device_id?: string;
                id?: number;
                owner_org?: string;
                updated_at?: string;
            };
            Relationships: [{
                foreignKeyName: "channel_devices_app_id_fkey";
                columns: ["app_id"];
                isOneToOne: false;
                referencedRelation: "apps";
                referencedColumns: ["app_id"];
            }, {
                foreignKeyName: "channel_devices_channel_id_fkey";
                columns: ["channel_id"];
                isOneToOne: false;
                referencedRelation: "channels";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "owner_org_id_fkey";
                columns: ["owner_org"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }];
        };
        channels: {
            Row: {
                allow_dev: boolean;
                allow_device_self_set: boolean;
                allow_emulator: boolean;
                android: boolean;
                app_id: string;
                created_at: string;
                created_by: string;
                disable_auto_update: Database["public"]["Enums"]["disable_update"];
                disable_auto_update_under_native: boolean;
                id: number;
                ios: boolean;
                name: string;
                owner_org: string;
                public: boolean;
                updated_at: string;
                version: number;
            };
            Insert: {
                allow_dev?: boolean;
                allow_device_self_set?: boolean;
                allow_emulator?: boolean;
                android?: boolean;
                app_id: string;
                created_at?: string;
                created_by: string;
                disable_auto_update?: Database["public"]["Enums"]["disable_update"];
                disable_auto_update_under_native?: boolean;
                id?: number;
                ios?: boolean;
                name: string;
                owner_org: string;
                public?: boolean;
                updated_at?: string;
                version: number;
            };
            Update: {
                allow_dev?: boolean;
                allow_device_self_set?: boolean;
                allow_emulator?: boolean;
                android?: boolean;
                app_id?: string;
                created_at?: string;
                created_by?: string;
                disable_auto_update?: Database["public"]["Enums"]["disable_update"];
                disable_auto_update_under_native?: boolean;
                id?: number;
                ios?: boolean;
                name?: string;
                owner_org?: string;
                public?: boolean;
                updated_at?: string;
                version?: number;
            };
            Relationships: [{
                foreignKeyName: "channels_app_id_fkey";
                columns: ["app_id"];
                isOneToOne: false;
                referencedRelation: "apps";
                referencedColumns: ["app_id"];
            }, {
                foreignKeyName: "channels_version_fkey";
                columns: ["version"];
                isOneToOne: false;
                referencedRelation: "app_versions";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "owner_org_id_fkey";
                columns: ["owner_org"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }];
        };
        daily_bandwidth: {
            Row: {
                app_id: string;
                bandwidth: number;
                date: string;
                id: number;
            };
            Insert: {
                app_id: string;
                bandwidth: number;
                date: string;
                id?: number;
            };
            Update: {
                app_id?: string;
                bandwidth?: number;
                date?: string;
                id?: number;
            };
            Relationships: [];
        };
        daily_mau: {
            Row: {
                app_id: string;
                date: string;
                id: number;
                mau: number;
            };
            Insert: {
                app_id: string;
                date: string;
                id?: number;
                mau: number;
            };
            Update: {
                app_id?: string;
                date?: string;
                id?: number;
                mau?: number;
            };
            Relationships: [];
        };
        daily_storage: {
            Row: {
                app_id: string;
                date: string;
                id: number;
                storage: number;
            };
            Insert: {
                app_id: string;
                date: string;
                id?: number;
                storage: number;
            };
            Update: {
                app_id?: string;
                date?: string;
                id?: number;
                storage?: number;
            };
            Relationships: [];
        };
        daily_version: {
            Row: {
                app_id: string;
                date: string;
                fail: number | null;
                get: number | null;
                install: number | null;
                uninstall: number | null;
                version_id: number;
            };
            Insert: {
                app_id: string;
                date: string;
                fail?: number | null;
                get?: number | null;
                install?: number | null;
                uninstall?: number | null;
                version_id: number;
            };
            Update: {
                app_id?: string;
                date?: string;
                fail?: number | null;
                get?: number | null;
                install?: number | null;
                uninstall?: number | null;
                version_id?: number;
            };
            Relationships: [];
        };
        deleted_account: {
            Row: {
                created_at: string | null;
                email: string;
                id: string;
            };
            Insert: {
                created_at?: string | null;
                email?: string;
                id?: string;
            };
            Update: {
                created_at?: string | null;
                email?: string;
                id?: string;
            };
            Relationships: [];
        };
        deleted_apps: {
            Row: {
                app_id: string;
                created_at: string | null;
                deleted_at: string | null;
                id: number;
                owner_org: string;
            };
            Insert: {
                app_id: string;
                created_at?: string | null;
                deleted_at?: string | null;
                id?: number;
                owner_org: string;
            };
            Update: {
                app_id?: string;
                created_at?: string | null;
                deleted_at?: string | null;
                id?: number;
                owner_org?: string;
            };
            Relationships: [];
        };
        deploy_history: {
            Row: {
                app_id: string;
                channel_id: number;
                created_at: string | null;
                created_by: string;
                deployed_at: string | null;
                id: number;
                owner_org: string;
                updated_at: string | null;
                version_id: number;
            };
            Insert: {
                app_id: string;
                channel_id: number;
                created_at?: string | null;
                created_by: string;
                deployed_at?: string | null;
                id?: number;
                owner_org: string;
                updated_at?: string | null;
                version_id: number;
            };
            Update: {
                app_id?: string;
                channel_id?: number;
                created_at?: string | null;
                created_by?: string;
                deployed_at?: string | null;
                id?: number;
                owner_org?: string;
                updated_at?: string | null;
                version_id?: number;
            };
            Relationships: [{
                foreignKeyName: "deploy_history_app_id_fkey";
                columns: ["app_id"];
                isOneToOne: false;
                referencedRelation: "apps";
                referencedColumns: ["app_id"];
            }, {
                foreignKeyName: "deploy_history_channel_id_fkey";
                columns: ["channel_id"];
                isOneToOne: false;
                referencedRelation: "channels";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "deploy_history_created_by_fkey";
                columns: ["created_by"];
                isOneToOne: false;
                referencedRelation: "users";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "deploy_history_version_id_fkey";
                columns: ["version_id"];
                isOneToOne: false;
                referencedRelation: "app_versions";
                referencedColumns: ["id"];
            }];
        };
        device_usage: {
            Row: {
                app_id: string;
                device_id: string;
                id: number;
                timestamp: string;
            };
            Insert: {
                app_id: string;
                device_id: string;
                id?: number;
                timestamp?: string;
            };
            Update: {
                app_id?: string;
                device_id?: string;
                id?: number;
                timestamp?: string;
            };
            Relationships: [];
        };
        devices: {
            Row: {
                app_id: string;
                custom_id: string;
                device_id: string;
                id: number;
                is_emulator: boolean | null;
                is_prod: boolean | null;
                os_version: string | null;
                platform: Database["public"]["Enums"]["platform_os"];
                plugin_version: string;
                updated_at: string;
                version: number;
                version_build: string | null;
            };
            Insert: {
                app_id: string;
                custom_id?: string;
                device_id: string;
                id?: never;
                is_emulator?: boolean | null;
                is_prod?: boolean | null;
                os_version?: string | null;
                platform: Database["public"]["Enums"]["platform_os"];
                plugin_version?: string;
                updated_at: string;
                version: number;
                version_build?: string | null;
            };
            Update: {
                app_id?: string;
                custom_id?: string;
                device_id?: string;
                id?: never;
                is_emulator?: boolean | null;
                is_prod?: boolean | null;
                os_version?: string | null;
                platform?: Database["public"]["Enums"]["platform_os"];
                plugin_version?: string;
                updated_at?: string;
                version?: number;
                version_build?: string | null;
            };
            Relationships: [];
        };
        global_stats: {
            Row: {
                apps: number;
                apps_active: number | null;
                created_at: string | null;
                date_id: string;
                devices_last_month: number | null;
                need_upgrade: number | null;
                not_paying: number | null;
                onboarded: number | null;
                paying: number | null;
                paying_monthly: number | null;
                paying_yearly: number | null;
                plan_maker: number | null;
                plan_payg: number | null;
                plan_solo: number | null;
                plan_team: number | null;
                stars: number;
                success_rate: number | null;
                trial: number | null;
                updates: number;
                updates_external: number | null;
                updates_last_month: number | null;
                users: number | null;
                users_active: number | null;
            };
            Insert: {
                apps: number;
                apps_active?: number | null;
                created_at?: string | null;
                date_id: string;
                devices_last_month?: number | null;
                need_upgrade?: number | null;
                not_paying?: number | null;
                onboarded?: number | null;
                paying?: number | null;
                paying_monthly?: number | null;
                paying_yearly?: number | null;
                plan_maker?: number | null;
                plan_payg?: number | null;
                plan_solo?: number | null;
                plan_team?: number | null;
                stars: number;
                success_rate?: number | null;
                trial?: number | null;
                updates: number;
                updates_external?: number | null;
                updates_last_month?: number | null;
                users?: number | null;
                users_active?: number | null;
            };
            Update: {
                apps?: number;
                apps_active?: number | null;
                created_at?: string | null;
                date_id?: string;
                devices_last_month?: number | null;
                need_upgrade?: number | null;
                not_paying?: number | null;
                onboarded?: number | null;
                paying?: number | null;
                paying_monthly?: number | null;
                paying_yearly?: number | null;
                plan_maker?: number | null;
                plan_payg?: number | null;
                plan_solo?: number | null;
                plan_team?: number | null;
                stars?: number;
                success_rate?: number | null;
                trial?: number | null;
                updates?: number;
                updates_external?: number | null;
                updates_last_month?: number | null;
                users?: number | null;
                users_active?: number | null;
            };
            Relationships: [];
        };
        manifest: {
            Row: {
                app_version_id: number;
                file_hash: string;
                file_name: string;
                file_size: number | null;
                id: number;
                s3_path: string;
            };
            Insert: {
                app_version_id: number;
                file_hash: string;
                file_name: string;
                file_size?: number | null;
                id?: number;
                s3_path: string;
            };
            Update: {
                app_version_id?: number;
                file_hash?: string;
                file_name?: string;
                file_size?: number | null;
                id?: number;
                s3_path?: string;
            };
            Relationships: [{
                foreignKeyName: "manifest_app_version_id_fkey";
                columns: ["app_version_id"];
                isOneToOne: false;
                referencedRelation: "app_versions";
                referencedColumns: ["id"];
            }];
        };
        notifications: {
            Row: {
                created_at: string | null;
                event: string;
                last_send_at: string;
                owner_org: string;
                total_send: number;
                uniq_id: string;
                updated_at: string | null;
            };
            Insert: {
                created_at?: string | null;
                event: string;
                last_send_at?: string;
                owner_org: string;
                total_send?: number;
                uniq_id: string;
                updated_at?: string | null;
            };
            Update: {
                created_at?: string | null;
                event?: string;
                last_send_at?: string;
                owner_org?: string;
                total_send?: number;
                uniq_id?: string;
                updated_at?: string | null;
            };
            Relationships: [{
                foreignKeyName: "owner_org_id_fkey";
                columns: ["owner_org"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }];
        };
        org_users: {
            Row: {
                app_id: string | null;
                channel_id: number | null;
                created_at: string | null;
                id: number;
                org_id: string;
                updated_at: string | null;
                user_id: string;
                user_right: Database["public"]["Enums"]["user_min_right"] | null;
            };
            Insert: {
                app_id?: string | null;
                channel_id?: number | null;
                created_at?: string | null;
                id?: number;
                org_id: string;
                updated_at?: string | null;
                user_id: string;
                user_right?: Database["public"]["Enums"]["user_min_right"] | null;
            };
            Update: {
                app_id?: string | null;
                channel_id?: number | null;
                created_at?: string | null;
                id?: number;
                org_id?: string;
                updated_at?: string | null;
                user_id?: string;
                user_right?: Database["public"]["Enums"]["user_min_right"] | null;
            };
            Relationships: [{
                foreignKeyName: "org_users_app_id_fkey";
                columns: ["app_id"];
                isOneToOne: false;
                referencedRelation: "apps";
                referencedColumns: ["app_id"];
            }, {
                foreignKeyName: "org_users_channel_id_fkey";
                columns: ["channel_id"];
                isOneToOne: false;
                referencedRelation: "channels";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "org_users_org_id_fkey";
                columns: ["org_id"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "org_users_user_id_fkey";
                columns: ["user_id"];
                isOneToOne: false;
                referencedRelation: "users";
                referencedColumns: ["id"];
            }];
        };
        orgs: {
            Row: {
                created_at: string | null;
                created_by: string;
                customer_id: string | null;
                id: string;
                logo: string | null;
                management_email: string;
                name: string;
                updated_at: string | null;
            };
            Insert: {
                created_at?: string | null;
                created_by: string;
                customer_id?: string | null;
                id?: string;
                logo?: string | null;
                management_email: string;
                name: string;
                updated_at?: string | null;
            };
            Update: {
                created_at?: string | null;
                created_by?: string;
                customer_id?: string | null;
                id?: string;
                logo?: string | null;
                management_email?: string;
                name?: string;
                updated_at?: string | null;
            };
            Relationships: [{
                foreignKeyName: "orgs_created_by_fkey";
                columns: ["created_by"];
                isOneToOne: false;
                referencedRelation: "users";
                referencedColumns: ["id"];
            }, {
                foreignKeyName: "orgs_customer_id_fkey";
                columns: ["customer_id"];
                isOneToOne: true;
                referencedRelation: "stripe_info";
                referencedColumns: ["customer_id"];
            }];
        };
        plans: {
            Row: {
                bandwidth: number;
                bandwidth_unit: number | null;
                created_at: string;
                description: string;
                id: string;
                market_desc: string | null;
                mau: number;
                mau_unit: number | null;
                name: string;
                price_m: number;
                price_m_bandwidth_id: string | null;
                price_m_id: string;
                price_m_mau_id: string | null;
                price_m_storage_id: string | null;
                price_y: number;
                price_y_id: string;
                storage: number;
                storage_unit: number | null;
                stripe_id: string;
                updated_at: string;
            };
            Insert: {
                bandwidth: number;
                bandwidth_unit?: number | null;
                created_at?: string;
                description?: string;
                id?: string;
                market_desc?: string | null;
                mau?: number;
                mau_unit?: number | null;
                name?: string;
                price_m?: number;
                price_m_bandwidth_id?: string | null;
                price_m_id: string;
                price_m_mau_id?: string | null;
                price_m_storage_id?: string | null;
                price_y?: number;
                price_y_id: string;
                storage: number;
                storage_unit?: number | null;
                stripe_id?: string;
                updated_at?: string;
            };
            Update: {
                bandwidth?: number;
                bandwidth_unit?: number | null;
                created_at?: string;
                description?: string;
                id?: string;
                market_desc?: string | null;
                mau?: number;
                mau_unit?: number | null;
                name?: string;
                price_m?: number;
                price_m_bandwidth_id?: string | null;
                price_m_id?: string;
                price_m_mau_id?: string | null;
                price_m_storage_id?: string | null;
                price_y?: number;
                price_y_id?: string;
                storage?: number;
                storage_unit?: number | null;
                stripe_id?: string;
                updated_at?: string;
            };
            Relationships: [];
        };
        stats: {
            Row: {
                action: Database["public"]["Enums"]["stats_action"];
                app_id: string;
                created_at: string;
                device_id: string;
                id: number;
                version: number;
            };
            Insert: {
                action: Database["public"]["Enums"]["stats_action"];
                app_id: string;
                created_at: string;
                device_id: string;
                id?: never;
                version: number;
            };
            Update: {
                action?: Database["public"]["Enums"]["stats_action"];
                app_id?: string;
                created_at?: string;
                device_id?: string;
                id?: never;
                version?: number;
            };
            Relationships: [];
        };
        storage_usage: {
            Row: {
                app_id: string;
                device_id: string;
                file_size: number;
                id: number;
                timestamp: string;
            };
            Insert: {
                app_id: string;
                device_id: string;
                file_size: number;
                id?: number;
                timestamp?: string;
            };
            Update: {
                app_id?: string;
                device_id?: string;
                file_size?: number;
                id?: number;
                timestamp?: string;
            };
            Relationships: [];
        };
        stripe_info: {
            Row: {
                bandwidth_exceeded: boolean | null;
                canceled_at: string | null;
                created_at: string;
                customer_id: string;
                id: number;
                is_good_plan: boolean | null;
                mau_exceeded: boolean | null;
                plan_usage: number | null;
                price_id: string | null;
                product_id: string;
                status: Database["public"]["Enums"]["stripe_status"] | null;
                storage_exceeded: boolean | null;
                subscription_anchor_end: string;
                subscription_anchor_start: string;
                subscription_id: string | null;
                subscription_metered: import("./types/supabase.types").Json;
                trial_at: string;
                updated_at: string;
            };
            Insert: {
                bandwidth_exceeded?: boolean | null;
                canceled_at?: string | null;
                created_at?: string;
                customer_id: string;
                id?: number;
                is_good_plan?: boolean | null;
                mau_exceeded?: boolean | null;
                plan_usage?: number | null;
                price_id?: string | null;
                product_id: string;
                status?: Database["public"]["Enums"]["stripe_status"] | null;
                storage_exceeded?: boolean | null;
                subscription_anchor_end?: string;
                subscription_anchor_start?: string;
                subscription_id?: string | null;
                subscription_metered?: import("./types/supabase.types").Json;
                trial_at?: string;
                updated_at?: string;
            };
            Update: {
                bandwidth_exceeded?: boolean | null;
                canceled_at?: string | null;
                created_at?: string;
                customer_id?: string;
                id?: number;
                is_good_plan?: boolean | null;
                mau_exceeded?: boolean | null;
                plan_usage?: number | null;
                price_id?: string | null;
                product_id?: string;
                status?: Database["public"]["Enums"]["stripe_status"] | null;
                storage_exceeded?: boolean | null;
                subscription_anchor_end?: string;
                subscription_anchor_start?: string;
                subscription_id?: string | null;
                subscription_metered?: import("./types/supabase.types").Json;
                trial_at?: string;
                updated_at?: string;
            };
            Relationships: [{
                foreignKeyName: "stripe_info_product_id_fkey";
                columns: ["product_id"];
                isOneToOne: false;
                referencedRelation: "plans";
                referencedColumns: ["stripe_id"];
            }];
        };
        tmp_users: {
            Row: {
                cancelled_at: string | null;
                created_at: string;
                email: string;
                first_name: string;
                future_uuid: string;
                id: number;
                invite_magic_string: string;
                last_name: string;
                org_id: string;
                role: Database["public"]["Enums"]["user_min_right"];
                updated_at: string;
            };
            Insert: {
                cancelled_at?: string | null;
                created_at?: string;
                email: string;
                first_name: string;
                future_uuid?: string;
                id?: number;
                invite_magic_string?: string;
                last_name: string;
                org_id: string;
                role: Database["public"]["Enums"]["user_min_right"];
                updated_at?: string;
            };
            Update: {
                cancelled_at?: string | null;
                created_at?: string;
                email?: string;
                first_name?: string;
                future_uuid?: string;
                id?: number;
                invite_magic_string?: string;
                last_name?: string;
                org_id?: string;
                role?: Database["public"]["Enums"]["user_min_right"];
                updated_at?: string;
            };
            Relationships: [{
                foreignKeyName: "tmp_users_org_id_fkey";
                columns: ["org_id"];
                isOneToOne: false;
                referencedRelation: "orgs";
                referencedColumns: ["id"];
            }];
        };
        to_delete_accounts: {
            Row: {
                account_id: string;
                created_at: string;
                id: number;
                removal_date: string;
                removed_data: import("./types/supabase.types").Json | null;
            };
            Insert: {
                account_id: string;
                created_at?: string;
                id?: number;
                removal_date: string;
                removed_data?: import("./types/supabase.types").Json | null;
            };
            Update: {
                account_id?: string;
                created_at?: string;
                id?: number;
                removal_date?: string;
                removed_data?: import("./types/supabase.types").Json | null;
            };
            Relationships: [{
                foreignKeyName: "to_delete_accounts_account_id_fkey";
                columns: ["account_id"];
                isOneToOne: false;
                referencedRelation: "users";
                referencedColumns: ["id"];
            }];
        };
        users: {
            Row: {
                ban_time: string | null;
                country: string | null;
                created_at: string | null;
                email: string;
                enable_notifications: boolean;
                first_name: string | null;
                id: string;
                image_url: string | null;
                last_name: string | null;
                opt_for_newsletters: boolean;
                updated_at: string | null;
            };
            Insert: {
                ban_time?: string | null;
                country?: string | null;
                created_at?: string | null;
                email: string;
                enable_notifications?: boolean;
                first_name?: string | null;
                id: string;
                image_url?: string | null;
                last_name?: string | null;
                opt_for_newsletters?: boolean;
                updated_at?: string | null;
            };
            Update: {
                ban_time?: string | null;
                country?: string | null;
                created_at?: string | null;
                email?: string;
                enable_notifications?: boolean;
                first_name?: string | null;
                id?: string;
                image_url?: string | null;
                last_name?: string | null;
                opt_for_newsletters?: boolean;
                updated_at?: string | null;
            };
            Relationships: [];
        };
        version_meta: {
            Row: {
                app_id: string;
                size: number;
                timestamp: string;
                version_id: number;
            };
            Insert: {
                app_id: string;
                size: number;
                timestamp?: string;
                version_id: number;
            };
            Update: {
                app_id?: string;
                size?: number;
                timestamp?: string;
                version_id?: number;
            };
            Relationships: [];
        };
        version_usage: {
            Row: {
                action: Database["public"]["Enums"]["version_action"];
                app_id: string;
                timestamp: string;
                version_id: number;
            };
            Insert: {
                action: Database["public"]["Enums"]["version_action"];
                app_id: string;
                timestamp?: string;
                version_id: number;
            };
            Update: {
                action?: Database["public"]["Enums"]["version_action"];
                app_id?: string;
                timestamp?: string;
                version_id?: number;
            };
            Relationships: [];
        };
    };
    Views: { [_ in never]: never; };
    Functions: {
        accept_invitation_to_org: {
            Args: {
                org_id: string;
            };
            Returns: string;
        };
        check_min_rights: {
            Args: {
                app_id: string;
                channel_id: number;
                min_right: Database["public"]["Enums"]["user_min_right"];
                org_id: string;
            } | {
                app_id: string;
                channel_id: number;
                min_right: Database["public"]["Enums"]["user_min_right"];
                org_id: string;
                user_id: string;
            };
            Returns: boolean;
        };
        check_revert_to_builtin_version: {
            Args: {
                appid: string;
            };
            Returns: number;
        };
        cleanup_frequent_job_details: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        cleanup_queue_messages: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        convert_bytes_to_gb: {
            Args: {
                byt: number;
            };
            Returns: number;
        };
        convert_bytes_to_mb: {
            Args: {
                byt: number;
            };
            Returns: number;
        };
        convert_gb_to_bytes: {
            Args: {
                gb: number;
            };
            Returns: number;
        };
        convert_mb_to_bytes: {
            Args: {
                gb: number;
            };
            Returns: number;
        };
        convert_number_to_percent: {
            Args: {
                max_val: number;
                val: number;
            };
            Returns: number;
        };
        count_active_users: {
            Args: {
                app_ids: string[];
            };
            Returns: number;
        };
        count_all_need_upgrade: {
            Args: Record<PropertyKey, never>;
            Returns: number;
        };
        count_all_onboarded: {
            Args: Record<PropertyKey, never>;
            Returns: number;
        };
        count_all_plans_v2: {
            Args: Record<PropertyKey, never>;
            Returns: {
                count: number;
                plan_name: string;
            }[];
        };
        delete_accounts_marked_for_deletion: {
            Args: Record<PropertyKey, never>;
            Returns: {
                deleted_count: number;
                deleted_user_ids: string[];
            }[];
        };
        delete_http_response: {
            Args: {
                request_id: number;
            };
            Returns: undefined;
        };
        delete_old_deleted_apps: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        delete_user: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        exist_app_v2: {
            Args: {
                appid: string;
            };
            Returns: boolean;
        };
        exist_app_versions: {
            Args: {
                apikey: string;
                appid: string;
                name_version: string;
            } | {
                appid: string;
                name_version: string;
            };
            Returns: boolean;
        };
        find_best_plan_v3: {
            Args: {
                bandwidth: number;
                mau: number;
                storage: number;
            };
            Returns: string;
        };
        find_fit_plan_v3: {
            Args: {
                bandwidth: number;
                mau: number;
                storage: number;
            };
            Returns: {
                name: string;
            }[];
        };
        get_account_removal_date: {
            Args: {
                user_id: string;
            };
            Returns: string;
        };
        get_apikey: {
            Args: Record<PropertyKey, never>;
            Returns: string;
        };
        get_apikey_header: {
            Args: Record<PropertyKey, never>;
            Returns: string;
        };
        get_app_metrics: {
            Args: {
                end_date: string;
                org_id: string;
                start_date: string;
            } | {
                org_id: string;
            };
            Returns: {
                app_id: string;
                bandwidth: number;
                date: string;
                fail: number;
                get: number;
                install: number;
                mau: number;
                storage: number;
                uninstall: number;
            }[];
        };
        get_app_versions: {
            Args: {
                apikey: string;
                appid: string;
                name_version: string;
            };
            Returns: number;
        };
        get_current_plan_max_org: {
            Args: {
                orgid: string;
            };
            Returns: {
                bandwidth: number;
                mau: number;
                storage: number;
            }[];
        };
        get_current_plan_name_org: {
            Args: {
                orgid: string;
            };
            Returns: string;
        };
        get_customer_counts: {
            Args: Record<PropertyKey, never>;
            Returns: {
                monthly: number;
                total: number;
                yearly: number;
            }[];
        };
        get_cycle_info_org: {
            Args: {
                orgid: string;
            };
            Returns: {
                subscription_anchor_end: string;
                subscription_anchor_start: string;
            }[];
        };
        get_d1_webhook_signature: {
            Args: Record<PropertyKey, never>;
            Returns: string;
        };
        get_db_url: {
            Args: Record<PropertyKey, never>;
            Returns: string;
        };
        get_global_metrics: {
            Args: {
                end_date: string;
                org_id: string;
                start_date: string;
            } | {
                org_id: string;
            };
            Returns: {
                bandwidth: number;
                date: string;
                fail: number;
                get: number;
                install: number;
                mau: number;
                storage: number;
                uninstall: number;
            }[];
        };
        get_identity: {
            Args: Record<PropertyKey, never> | {
                keymode: Database["public"]["Enums"]["key_mode"][];
            };
            Returns: string;
        };
        get_identity_apikey_only: {
            Args: {
                keymode: Database["public"]["Enums"]["key_mode"][];
            };
            Returns: string;
        };
        get_identity_org_allowed: {
            Args: {
                keymode: Database["public"]["Enums"]["key_mode"][];
                org_id: string;
            };
            Returns: string;
        };
        get_identity_org_appid: {
            Args: {
                app_id: string;
                keymode: Database["public"]["Enums"]["key_mode"][];
                org_id: string;
            };
            Returns: string;
        };
        get_invite_by_magic_lookup: {
            Args: {
                lookup: string;
            };
            Returns: {
                org_logo: string;
                org_name: string;
                role: Database["public"]["Enums"]["user_min_right"];
            }[];
        };
        get_metered_usage: {
            Args: Record<PropertyKey, never> | {
                orgid: string;
            };
            Returns: Database["public"]["CompositeTypes"]["stats_table"];
        };
        get_next_cron_time: {
            Args: {
                p_schedule: string;
                p_timestamp: string;
            };
            Returns: string;
        };
        get_next_cron_value: {
            Args: {
                current_val: number;
                max_val: number;
                pattern: string;
            };
            Returns: number;
        };
        get_org_members: {
            Args: {
                guild_id: string;
            } | {
                guild_id: string;
                user_id: string;
            };
            Returns: {
                aid: number;
                email: string;
                image_url: string;
                is_tmp: boolean;
                role: Database["public"]["Enums"]["user_min_right"];
                uid: string;
            }[];
        };
        get_org_owner_id: {
            Args: {
                apikey: string;
                app_id: string;
            };
            Returns: string;
        };
        get_org_perm_for_apikey: {
            Args: {
                apikey: string;
                app_id: string;
            };
            Returns: string;
        };
        get_organization_cli_warnings: {
            Args: {
                cli_version: string;
                orgid: string;
            };
            Returns: import("./types/supabase.types").Json[];
        };
        get_orgs_v6: {
            Args: Record<PropertyKey, never> | {
                userid: string;
            };
            Returns: {
                app_count: number;
                can_use_more: boolean;
                created_by: string;
                gid: string;
                is_canceled: boolean;
                is_yearly: boolean;
                logo: string;
                management_email: string;
                name: string;
                paying: boolean;
                role: string;
                subscription_end: string;
                subscription_start: string;
                trial_left: number;
            }[];
        };
        get_plan_usage_percent_detailed: {
            Args: {
                cycle_end: string;
                cycle_start: string;
                orgid: string;
            } | {
                orgid: string;
            };
            Returns: {
                bandwidth_percent: number;
                mau_percent: number;
                storage_percent: number;
                total_percent: number;
            }[];
        };
        get_process_cron_stats_job_info: {
            Args: Record<PropertyKey, never>;
            Returns: {
                last_run: string;
                next_run: string;
            }[];
        };
        get_total_app_storage_size_orgs: {
            Args: {
                app_id: string;
                org_id: string;
            };
            Returns: number;
        };
        get_total_metrics: {
            Args: {
                end_date: string;
                org_id: string;
                start_date: string;
            } | {
                org_id: string;
            };
            Returns: {
                bandwidth: number;
                fail: number;
                get: number;
                install: number;
                mau: number;
                storage: number;
                uninstall: number;
            }[];
        };
        get_total_storage_size_org: {
            Args: {
                org_id: string;
            };
            Returns: number;
        };
        get_update_stats: {
            Args: Record<PropertyKey, never>;
            Returns: {
                app_id: string;
                failed: number;
                get: number;
                healthy: boolean;
                install: number;
                success_rate: number;
            }[];
        };
        get_user_id: {
            Args: {
                apikey: string;
            } | {
                apikey: string;
                app_id: string;
            };
            Returns: string;
        };
        get_user_main_org_id: {
            Args: {
                user_id: string;
            };
            Returns: string;
        };
        get_user_main_org_id_by_app_id: {
            Args: {
                app_id: string;
            };
            Returns: string;
        };
        get_versions_with_no_metadata: {
            Args: Record<PropertyKey, never>;
            Returns: {
                app_id: string;
                checksum: string | null;
                comment: string | null;
                created_at: string | null;
                deleted: boolean;
                external_url: string | null;
                id: number;
                link: string | null;
                manifest: Database["public"]["CompositeTypes"]["manifest_entry"][] | null;
                min_update_version: string | null;
                name: string;
                native_packages: import("./types/supabase.types").Json[] | null;
                owner_org: string;
                r2_path: string | null;
                session_key: string | null;
                storage_provider: string;
                updated_at: string | null;
                user_id: string | null;
            }[];
        };
        get_weekly_stats: {
            Args: {
                app_id: string;
            };
            Returns: {
                all_updates: number;
                failed_updates: number;
                open_app: number;
            }[];
        };
        has_app_right: {
            Args: {
                appid: string;
                right: Database["public"]["Enums"]["user_min_right"];
            };
            Returns: boolean;
        };
        has_app_right_apikey: {
            Args: {
                apikey: string;
                appid: string;
                right: Database["public"]["Enums"]["user_min_right"];
                userid: string;
            };
            Returns: boolean;
        };
        has_app_right_userid: {
            Args: {
                appid: string;
                right: Database["public"]["Enums"]["user_min_right"];
                userid: string;
            };
            Returns: boolean;
        };
        invite_user_to_org: {
            Args: {
                email: string;
                invite_type: Database["public"]["Enums"]["user_min_right"];
                org_id: string;
            };
            Returns: string;
        };
        is_account_disabled: {
            Args: {
                user_id: string;
            };
            Returns: boolean;
        };
        is_admin: {
            Args: Record<PropertyKey, never> | {
                userid: string;
            };
            Returns: boolean;
        };
        is_allowed_action: {
            Args: {
                apikey: string;
                appid: string;
            };
            Returns: boolean;
        };
        is_allowed_action_org: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_allowed_action_org_action: {
            Args: {
                actions: Database["public"]["Enums"]["action_type"][];
                orgid: string;
            };
            Returns: boolean;
        };
        is_allowed_capgkey: {
            Args: {
                apikey: string;
                app_id: string;
                keymode: Database["public"]["Enums"]["key_mode"][];
            } | {
                apikey: string;
                keymode: Database["public"]["Enums"]["key_mode"][];
            };
            Returns: boolean;
        };
        is_app_owner: {
            Args: {
                apikey: string;
                appid: string;
            } | {
                appid: string;
            } | {
                appid: string;
                userid: string;
            };
            Returns: boolean;
        };
        is_bandwidth_exceeded_by_org: {
            Args: {
                org_id: string;
            };
            Returns: boolean;
        };
        is_canceled_org: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_good_plan_v5_org: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_mau_exceeded_by_org: {
            Args: {
                org_id: string;
            };
            Returns: boolean;
        };
        is_member_of_org: {
            Args: {
                org_id: string;
                user_id: string;
            };
            Returns: boolean;
        };
        is_not_deleted: {
            Args: {
                email_check: string;
            };
            Returns: boolean;
        };
        is_numeric: {
            Args: {
                "": string;
            };
            Returns: boolean;
        };
        is_onboarded_org: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_onboarding_needed_org: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_org_yearly: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_owner_of_org: {
            Args: {
                org_id: string;
                user_id: string;
            };
            Returns: boolean;
        };
        is_paying_and_good_plan_org: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_paying_and_good_plan_org_action: {
            Args: {
                actions: Database["public"]["Enums"]["action_type"][];
                orgid: string;
            };
            Returns: boolean;
        };
        is_paying_org: {
            Args: {
                orgid: string;
            };
            Returns: boolean;
        };
        is_storage_exceeded_by_org: {
            Args: {
                org_id: string;
            };
            Returns: boolean;
        };
        is_trial_org: {
            Args: {
                orgid: string;
            };
            Returns: number;
        };
        mass_edit_queue_messages_cf_ids: {
            Args: {
                updates: Database["public"]["CompositeTypes"]["message_update"][];
            };
            Returns: undefined;
        };
        modify_permissions_tmp: {
            Args: {
                email: string;
                new_role: Database["public"]["Enums"]["user_min_right"];
                org_id: string;
            };
            Returns: string;
        };
        one_month_ahead: {
            Args: Record<PropertyKey, never>;
            Returns: string;
        };
        parse_cron_field: {
            Args: {
                current_val: number;
                field: string;
                max_val: number;
            };
            Returns: number;
        };
        parse_step_pattern: {
            Args: {
                pattern: string;
            };
            Returns: number;
        };
        pg_log: {
            Args: {
                decision: string;
                input?: import("./types/supabase.types").Json;
            };
            Returns: undefined;
        };
        process_admin_stats: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        process_cron_stats_jobs: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        process_d1_replication_batch: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        process_failed_uploads: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        process_free_trial_expired: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        process_function_queue: {
            Args: {
                queue_name: string;
            };
            Returns: number;
        };
        process_stats_email_monthly: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        process_stats_email_weekly: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        process_subscribed_orgs: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        read_bandwidth_usage: {
            Args: {
                p_app_id: string;
                p_period_end: string;
                p_period_start: string;
            };
            Returns: {
                app_id: string;
                bandwidth: number;
                date: string;
            }[];
        };
        read_device_usage: {
            Args: {
                p_app_id: string;
                p_period_end: string;
                p_period_start: string;
            };
            Returns: {
                app_id: string;
                date: string;
                mau: number;
            }[];
        };
        read_storage_usage: {
            Args: {
                p_app_id: string;
                p_period_end: string;
                p_period_start: string;
            };
            Returns: {
                app_id: string;
                date: string;
                storage: number;
            }[];
        };
        read_version_usage: {
            Args: {
                p_app_id: string;
                p_period_end: string;
                p_period_start: string;
            };
            Returns: {
                app_id: string;
                date: string;
                fail: number;
                get: number;
                install: number;
                uninstall: number;
                version_id: number;
            }[];
        };
        remove_old_jobs: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        rescind_invitation: {
            Args: {
                email: string;
                org_id: string;
            };
            Returns: string;
        };
        set_bandwidth_exceeded_by_org: {
            Args: {
                disabled: boolean;
                org_id: string;
            };
            Returns: undefined;
        };
        set_mau_exceeded_by_org: {
            Args: {
                disabled: boolean;
                org_id: string;
            };
            Returns: undefined;
        };
        set_storage_exceeded_by_org: {
            Args: {
                disabled: boolean;
                org_id: string;
            };
            Returns: undefined;
        };
        transfer_app: {
            Args: {
                p_app_id: string;
                p_new_org_id: string;
            };
            Returns: undefined;
        };
        transform_role_to_invite: {
            Args: {
                role_input: Database["public"]["Enums"]["user_min_right"];
            };
            Returns: Database["public"]["Enums"]["user_min_right"];
        };
        transform_role_to_non_invite: {
            Args: {
                role_input: Database["public"]["Enums"]["user_min_right"];
            };
            Returns: Database["public"]["Enums"]["user_min_right"];
        };
        update_app_versions_retention: {
            Args: Record<PropertyKey, never>;
            Returns: undefined;
        };
        upsert_version_meta: {
            Args: {
                p_app_id: string;
                p_size: number;
                p_version_id: number;
            };
            Returns: boolean;
        };
        verify_mfa: {
            Args: Record<PropertyKey, never>;
            Returns: boolean;
        };
    };
    Enums: {
        action_type: "mau" | "storage" | "bandwidth";
        app_mode: "prod" | "dev" | "livereload";
        disable_update: "major" | "minor" | "patch" | "version_number" | "none";
        key_mode: "read" | "write" | "all" | "upload";
        pay_as_you_go_type: "base" | "units";
        platform_os: "ios" | "android";
        stats_action: "delete" | "reset" | "set" | "get" | "set_fail" | "update_fail" | "download_fail" | "windows_path_fail" | "canonical_path_fail" | "directory_path_fail" | "unzip_fail" | "low_mem_fail" | "download_10" | "download_20" | "download_30" | "download_40" | "download_50" | "download_60" | "download_70" | "download_80" | "download_90" | "download_complete" | "decrypt_fail" | "app_moved_to_foreground" | "app_moved_to_background" | "uninstall" | "needPlanUpgrade" | "missingBundle" | "noNew" | "disablePlatformIos" | "disablePlatformAndroid" | "disableAutoUpdateToMajor" | "cannotUpdateViaPrivateChannel" | "disableAutoUpdateToMinor" | "disableAutoUpdateToPatch" | "channelMisconfigured" | "disableAutoUpdateMetadata" | "disableAutoUpdateUnderNative" | "disableDevBuild" | "disableEmulator" | "cannotGetBundle" | "checksum_fail" | "NoChannelOrOverride" | "setChannel" | "getChannel" | "rateLimited" | "disableAutoUpdate" | "InvalidIp";
        stripe_status: "created" | "succeeded" | "updated" | "failed" | "deleted" | "canceled";
        usage_mode: "5min" | "day" | "month" | "cycle" | "last_saved";
        user_min_right: "invite_read" | "invite_upload" | "invite_write" | "invite_admin" | "invite_super_admin" | "read" | "upload" | "write" | "admin" | "super_admin";
        user_role: "read" | "upload" | "write" | "admin";
        version_action: "get" | "fail" | "install" | "uninstall";
    };
    CompositeTypes: {
        manifest_entry: {
            file_name: string | null;
            s3_path: string | null;
            file_hash: string | null;
        };
        match_plan: {
            name: string | null;
        };
        message_update: {
            msg_id: number | null;
            cf_id: string | null;
            queue: string | null;
        };
        orgs_table: {
            id: string | null;
            created_by: string | null;
            created_at: string | null;
            updated_at: string | null;
            logo: string | null;
            name: string | null;
        };
        owned_orgs: {
            id: string | null;
            created_by: string | null;
            logo: string | null;
            name: string | null;
            role: string | null;
        };
        stats_table: {
            mau: number | null;
            bandwidth: number | null;
            storage: number | null;
        };
    };
}, {
    PostgrestVersion: "13.0.5";
}>>;
export declare function checkKey(supabase: SupabaseClient<Database>, apikey: string, keymode: Database['public']['Enums']['key_mode'][]): Promise<void>;
export declare function isPayingOrg(supabase: SupabaseClient<Database>, orgId: string): Promise<boolean>;
export declare function isTrialOrg(supabase: SupabaseClient<Database>, orgId: string): Promise<number>;
export declare function isAllowedActionOrg(supabase: SupabaseClient<Database>, orgId: string): Promise<boolean>;
export declare function isAllowedActionAppIdApiKey(supabase: SupabaseClient<Database>, appId: string, apikey: string): Promise<boolean>;
export declare function isAllowedApp(supabase: SupabaseClient<Database>, apikey: string, appId: string): Promise<boolean>;
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<Database>, apikey: string, appId: string): Promise<{
    okay: true;
    data: OrganizationPerm;
} | {
    okay: false;
    error: 'INVALID_APIKEY' | 'NO_APP' | 'NO_ORG';
}>;
export declare function checkRemoteCliMessages(supabase: SupabaseClient<Database>, orgId: string, cliVersion: string): Promise<void>;
export declare function checkPlanValid(supabase: SupabaseClient<Database>, orgId: string, apikey: string, appId?: string, warning?: boolean): Promise<void>;
export declare function checkPlanValidUpload(supabase: SupabaseClient<Database>, orgId: string, apikey: string, appId?: string, warning?: boolean): Promise<void>;
export declare function findSavedKey(quiet?: boolean): string;
export declare function getContentType(filename: string): string | null;
export declare function findProjectType(): Promise<"unknown" | "angular-ts" | "angular-js" | "nuxtjs-ts" | "nuxtjs-js" | "nextjs-ts" | "nextjs-js" | "sveltekit-ts" | "sveltekit-js" | "svelte-ts" | "svelte-js" | "vue-ts" | "vue-js" | "react-ts" | "react-js">;
export declare function findMainFileForProjectType(projectType: string, isTypeScript: boolean): string | null;
export declare function findBuildCommandForProjectType(projectType: string): Promise<"build" | "generate">;
export declare function findMainFile(): Promise<string>;
export declare function updateOrCreateVersion(supabase: SupabaseClient<Database>, update: Database['public']['Tables']['app_versions']['Insert']): Promise<import("@supabase/postgrest-js").PostgrestSingleResponse<null>>;
export declare function uploadUrl(supabase: SupabaseClient<Database>, appId: string, name: string): Promise<string>;
export declare function generateManifest(path: string): Promise<{
    file: string;
    hash: string;
}[]>;
export type manifestType = Awaited<ReturnType<typeof generateManifest>>;
export interface uploadUrlsType {
    path: string;
    hash: string;
    uploadLink: string;
    finalPath: string;
}
export declare function zipFile(filePath: string): Promise<Buffer>;
export declare function zipFileUnix(filePath: string): Buffer<ArrayBufferLike>;
export declare function zipFileWindows(filePath: string): Promise<Buffer>;
export declare function uploadTUS(apikey: string, data: Buffer, orgId: string, appId: string, name: string, spinner: ReturnType<typeof spinnerC>, localConfig: CapgoConfig, chunkSize: number): Promise<boolean>;
export declare function deletedFailedVersion(supabase: SupabaseClient<Database>, appId: string, name: string): Promise<void>;
export declare function updateOrCreateChannel(supabase: SupabaseClient<Database>, update: Database['public']['Tables']['channels']['Insert']): Promise<import("@supabase/postgrest-js").PostgrestSingleResponse<{
    allow_dev: boolean;
    allow_device_self_set: boolean;
    allow_emulator: boolean;
    android: boolean;
    app_id: string;
    created_at: string;
    created_by: string;
    disable_auto_update: Database["public"]["Enums"]["disable_update"];
    disable_auto_update_under_native: boolean;
    id: number;
    ios: boolean;
    name: string;
    owner_org: string;
    public: boolean;
    updated_at: string;
    version: number;
}>>;
export declare function sendEvent(capgkey: string, payload: TrackOptions, verbose?: boolean): Promise<void>;
export declare function getOrganization(supabase: SupabaseClient<Database>, roles: string[]): Promise<Organization>;
export declare function verifyUser(supabase: SupabaseClient<Database>, apikey: string, keymod?: Database['public']['Enums']['key_mode'][]): Promise<string>;
export declare function getOrganizationId(supabase: SupabaseClient<Database>, appId: string): Promise<string>;
export declare function requireUpdateMetadata(supabase: SupabaseClient<Database>, channel: string, appId: string): Promise<boolean>;
export declare function getHumanDate(createdA: string | null): string;
export declare function getPMAndCommand(): {
    pm: PackageManagerType;
    command: InstallCommand;
    installCommand: string;
    runner: PackageManagerRunner;
};
export declare function getLocalDepenencies(packageJsonPath: string | undefined, nodeModulesString: string | undefined): Promise<{
    name: string;
    version: string;
    native: boolean;
}[]>;
export declare function getRemoteChecksums(supabase: SupabaseClient<Database>, appId: string, channel: string): Promise<string | null>;
export declare function convertNativePackages(nativePackages: {
    name: string;
    version: string;
}[]): Map<string, {
    name: string;
    version: string;
}>;
export declare function getRemoteDepenencies(supabase: SupabaseClient<Database>, appId: string, channel: string): Promise<Map<string, {
    name: string;
    version: string;
}>>;
export declare function checkChecksum(supabase: SupabaseClient<Database>, appId: string, channel: string, currentChecksum: string): Promise<void>;
interface Compatibility {
    name: string;
    localVersion: string | undefined;
    remoteVersion: string | undefined;
}
export declare function getAppId(appId: string | undefined, config: CapacitorConfig | undefined): any;
export declare function isCompatible(pkg: Compatibility): boolean;
export declare function checkCompatibility(supabase: SupabaseClient<Database>, appId: string, channel: string, packageJsonPath: string | undefined, nodeModules: string | undefined): Promise<{
    finalCompatibility: Compatibility[];
    localDependencies: {
        name: string;
        version: string;
        native: boolean;
    }[];
}>;
export declare function checkCompatibilityNativePackages(supabase: SupabaseClient<Database>, appId: string, channel: string, nativePackages: {
    name: string;
    version: string;
}[]): Promise<{
    finalCompatibility: Compatibility[];
    localDependencies: {
        name: string;
        version: string;
    }[];
}>;
export {};
//# sourceMappingURL=utils.d.ts.map