import type { JsonValue } from '../control-plane';
import type { QueueExecutionContext, QueueOperationHandler } from '../queue';
import type { BackupDestination, BackupJob, BackupPolicy, RecoveryPoint } from './model';
import type { MultipartCheckpoint, StoredBackup } from './s3-destination';
import { DurableOperationQueue } from '../queue';
import { BackupStore } from './store';
export type BackupSourceResult = {
    mode: 'object';
    key: string;
    body: Uint8Array;
    contentType?: string;
    manifest: Record<string, JsonValue>;
    toolVersion?: string;
    engineVersion?: string;
} | {
    mode: 'external';
    uri: string;
    checksum: string;
    sizeBytes: number;
    manifest: Record<string, JsonValue>;
    toolVersion?: string;
    engineVersion?: string;
};
export interface BackupSourceAdapter {
    create(policy: BackupPolicy, context: QueueExecutionContext): Promise<BackupSourceResult>;
    verifyExternal?(point: RecoveryPoint, context: QueueExecutionContext): Promise<Record<string, JsonValue>>;
    verify?(point: RecoveryPoint, body: Uint8Array, context: QueueExecutionContext): Promise<Record<string, JsonValue>>;
    restore(point: RecoveryPoint, body: Uint8Array | undefined, target: Record<string, JsonValue>, context: QueueExecutionContext): Promise<Record<string, JsonValue>>;
    validateHealth?(target: Record<string, JsonValue>, context: QueueExecutionContext): Promise<Record<string, JsonValue>>;
    cleanup?(target: Record<string, JsonValue>, context: QueueExecutionContext): Promise<void>;
    deleteExternal?(point: RecoveryPoint, context: QueueExecutionContext): Promise<void>;
}
export interface BackupDestinationAdapter {
    upload(destination: BackupDestination, input: {
        key: string;
        body: Uint8Array;
        contentType?: string;
        resume?: MultipartCheckpoint;
        checkpoint?: (value: MultipartCheckpoint) => void;
    }): Promise<StoredBackup>;
    download(destination: BackupDestination, stored: Pick<StoredBackup, 'key' | 'checksum' | 'manifest'>): Promise<Buffer>;
    delete(destination: BackupDestination, key: string): Promise<void>;
    abortPartial?(destination: BackupDestination, checkpoint: MultipartCheckpoint): Promise<void>;
}
export declare class BackupCoordinator {
    readonly store: BackupStore;
    readonly queue: DurableOperationQueue;
    private readonly now;
    constructor(store: BackupStore, queue: DurableOperationQueue, now?: () => Date);
    enqueueBackup(policy: BackupPolicy, scheduledFor?: string, actorId?: string): BackupJob;
    enqueueDue(at?: Date): BackupJob[];
    enqueueVerification(point: RecoveryPoint): BackupJob;
    planRestore(point: RecoveryPoint, input: {
        mode: 'isolated' | 'in_place';
        target: Record<string, JsonValue>;
        targetName: string;
        confirm?: string;
        recentAuth?: boolean;
        downtimeAcknowledged?: boolean;
        safetyBackupId?: string;
    }): {
        point: RecoveryPoint;
        mode: 'isolated' | 'in_place';
        target: Record<string, JsonValue>;
        warnings: string[];
    };
    enqueueRestore(point: RecoveryPoint, input: Parameters<BackupCoordinator['planRestore']>[1] & {
        drill?: boolean;
        actorId?: string;
    }): BackupJob;
    enqueueRetention(at?: Date): BackupJob[];
}
export declare function createBackupQueueHandlers(input: {
    store: BackupStore;
    queue: DurableOperationQueue;
    resolveSource: (policy: BackupPolicy) => BackupSourceAdapter | undefined;
    resolveDestination: (destination: BackupDestination) => BackupDestinationAdapter | undefined;
    validateHealth?: (policy: BackupPolicy, target: Record<string, JsonValue>) => Promise<Record<string, JsonValue>>;
    now?: () => Date;
}): Record<string, QueueOperationHandler>;
