/**
 * Serverless application deploy orchestrator (Laravel-Vapor-equivalent).
 *
 * Drives the full pipeline for `environments.<env>.app`:
 *   build hooks → package → ensure artifact bucket → upload artifact →
 *   deploy/update CloudFormation stack → update function code + env →
 *   sync assets → run deploy hooks → health check.
 *
 * Plus the operational verbs: redeploy (no rebuild), rollback (previous
 * release), and maintenance mode (down/up).
 */
import type { CloudConfig, EnvironmentType, ServerlessAppConfig } from '@ts-cloud/core';
export interface DeployServerlessOptions {
    /** Project root for entry resolution + build hooks. @default process.cwd() */
    projectRoot?: string;
    /** Skip the local build hooks (already run). */
    skipBuild?: boolean;
    /** Skip running the post-deploy `deploy` hooks. */
    skipDeployHooks?: boolean;
    /** Skip the post-deploy HTTP health check. */
    skipHealthCheck?: boolean;
}
export interface ResolvedContext {
    app: ServerlessAppConfig;
    slug: string;
    region: string;
    stackName: string;
    artifactBucket: string;
    assetsBucket: string;
}
/**
 * Resolve the deployed function names, region, and slug for an environment —
 * shared by the logs/metrics/env/warming CLI commands. Throws if the env has no
 * serverless app configured.
 */
export declare function resolveServerlessFunctions(config: CloudConfig, environment: EnvironmentType): {
    region: string;
    slug: string;
    stackName: string;
    functions: {
        http: string;
        queue: string;
        cli: string;
    };
};
/** Resolve secrets from Secrets Manager into a flat env map. */
export declare function resolveSecrets(app: ServerlessAppConfig, region: string): Promise<Record<string, string>>;
/**
 * Derive framework env vars (DB/Redis hosts) from the deployed stack outputs so
 * a Laravel app connects to the Aurora/RDS-Proxy/ElastiCache resources the
 * composer created. Returns an empty map when nothing data-related is attached.
 */
export declare function infraEnvFromOutputs(app: ServerlessAppConfig, outputs: Record<string, string>): Record<string, string>;
/** Build the complete environment for one function. Exported for testing. */
export declare function buildFunctionEnv(app: ServerlessAppConfig, ctx: ResolvedContext, environment: EnvironmentType, mode: 'http' | 'queue' | 'cli', secrets: Record<string, string>, assetUrl: string | undefined, queueName: string | undefined, infraEnv?: Record<string, string>): Record<string, string>;
/** Code source for a function update: an S3 zip or an ECR image. */
export type CodeSource = {
    kind: 'zip';
    bucket: string;
    key: string;
} | {
    kind: 'image';
    imageUri: string;
};
/**
 * AWS caps the aggregate size of a function's environment variables at 4 KB.
 * Check before the API call so we fail with an actionable message (which vars,
 * how far over) instead of a cryptic `InvalidParameterValueException` mid-deploy.
 */
export declare function assertEnvWithinLimit(name: string, env: Record<string, string>): void;
export declare function deployServerlessApp(config: CloudConfig, environment: EnvironmentType, opts?: DeployServerlessOptions): Promise<void>;
export declare function redeployServerlessApp(config: CloudConfig, environment: EnvironmentType): Promise<void>;
export declare function rollbackServerlessApp(config: CloudConfig, environment: EnvironmentType): Promise<void>;
export declare function setMaintenance(config: CloudConfig, environment: EnvironmentType, enabled: boolean, bypassSecret?: string): Promise<void>;
/** Invoke the CLI function with an arbitrary command (e.g. `cloud command "migrate"`). */
export declare function runRemoteCommand(config: CloudConfig, environment: EnvironmentType, command: string): Promise<string>;
/** One recorded `cloud command` invocation. */
export interface CommandRecord {
    id: number;
    command: string;
    timestamp: string;
    status: 'ok' | 'error';
    output: string;
}
/** Run a command on the CLI function AND record it to the history log (best-effort). */
export declare function runAndRecordCommand(config: CloudConfig, environment: EnvironmentType, command: string): Promise<{
    id: number;
    status: 'ok' | 'error';
    output: string;
}>;
/** Return the recorded command history (most-recent last). */
export declare function listCommandHistory(config: CloudConfig, environment: EnvironmentType): Promise<CommandRecord[]>;
/** Look up one history record by id (or the most recent when id is omitted). */
export declare function getCommandRecord(config: CloudConfig, environment: EnvironmentType, id?: number): Promise<CommandRecord | undefined>;
/**
 * Run a SQL statement against a (private, in-VPC) serverless database via the CLI
 * function — no bastion needed. Requires the `tscloud/serverless` PHP bridge
 * (`tscloud:db-query`). The SQL is base64-encoded so it survives the runtime's
 * whitespace argument parsing.
 */
export declare function runDbQuery(config: CloudConfig, environment: EnvironmentType, sql: string): Promise<string>;
export interface ServerlessFunctionInfo {
    mode: 'http' | 'queue' | 'cli';
    name: string;
    /** `live` alias version when provisioned concurrency is on, else '$LATEST'. */
    version: string;
    provisioned?: {
        status: string;
        allocated: number;
        requested: number;
    };
}
export interface ServerlessInfo {
    slug: string;
    environment: string;
    region: string;
    stackStatus: string;
    endpoint?: string;
    assetUrl?: string;
    scheduler: 'on' | 'off' | 'sub-minute';
    queues: string[];
    provisionedConcurrency: number;
    functions: ServerlessFunctionInfo[];
    lastRelease?: {
        sha: string;
        timestamp: string;
    };
}
/** Gather an operational summary of a deployed serverless app. */
export declare function serverlessInfo(config: CloudConfig, environment: EnvironmentType): Promise<ServerlessInfo>;
/** Rescale the serverless Aurora cluster's min/max ACU capacity. */
export declare function scaleServerlessDatabase(config: CloudConfig, environment: EnvironmentType, minCapacity: number, maxCapacity: number): Promise<void>;
/**
 * Restore the serverless Aurora cluster to a point in time as a NEW cluster
 * (the source is untouched). Returns the new cluster identifier.
 */
export declare function restoreServerlessDatabase(config: CloudConfig, environment: EnvironmentType, opts: {
    toTime?: Date;
    latest?: boolean;
    target?: string;
}): Promise<string>;
