/**
 * Schedule Executor
 *
 * Executes queued updates within scheduled time windows.
 * Coordinates between ScheduleService and UpdateQueue.
 *
 * @since v1.51.0
 * @since v1.51.2 - Added auto-backup before updates
 */
import type { ScheduleService } from './schedule-service.js';
import type { QueueProcessResult, QueuedUpdate, UpdateQueue } from './update-queue.js';
/**
 * Execution mode
 */
export type ExecutionMode = 'immediate' | 'scheduled';
/**
 * Time window configuration
 */
export interface TimeWindow {
    /** Start time in 24h format (e.g., "02:00") */
    start: string;
    /** End time in 24h format (e.g., "04:00") */
    end: string;
}
/**
 * Auto-backup configuration
 */
export interface AutoBackupConfig {
    /** Whether to create a backup before executing updates */
    enabled: boolean;
    /** Directory to store backups */
    backupDir: string;
    /** Directory containing plugins to backup */
    pluginsDir: string;
    /** Number of days to keep pre-update backups (0 = keep forever) */
    retentionDays: number;
    /** Maximum number of pre-update backups to keep */
    maxBackups: number;
}
/**
 * Schedule executor configuration
 */
export interface ScheduleExecutorConfig {
    /** Whether scheduled execution is enabled */
    enabled: boolean;
    /** Time window for scheduled updates */
    window: TimeWindow;
    /** Timezone for window calculations (IANA format, e.g., "America/New_York") */
    timezone: string;
    /** Days of week to run (0 = Sunday, 6 = Saturday) */
    daysOfWeek: number[];
    /** Skip major version updates in scheduled mode */
    skipMajorUpdates: boolean;
    /** Maximum updates per execution */
    maxUpdatesPerRun: number;
    /** Auto-backup configuration */
    autoBackup?: AutoBackupConfig;
}
/**
 * Execution result
 */
export interface ExecutionResult {
    /** Whether execution was successful */
    success: boolean;
    /** Execution mode used */
    mode: ExecutionMode;
    /** Queue processing result */
    result?: QueueProcessResult;
    /** Reason if execution was skipped */
    skipReason?: string;
    /** Start timestamp */
    startedAt: string;
    /** End timestamp */
    completedAt: string;
    /** Path to backup created before update (if auto-backup enabled) */
    backupPath?: string;
}
/**
 * Default executor configuration
 */
export declare const DEFAULT_EXECUTOR_CONFIG: ScheduleExecutorConfig;
/**
 * Schedule Executor
 *
 * Executes queued updates based on schedule configuration.
 */
export declare class ScheduleExecutor {
    private config;
    private queue;
    private scheduleService;
    private updateHandler;
    constructor(queue: UpdateQueue, scheduleService: ScheduleService, updateHandler: (update: QueuedUpdate) => Promise<{
        success: boolean;
        error?: string;
    }>, config?: Partial<ScheduleExecutorConfig>);
    /**
     * Update configuration
     */
    updateConfig(config: Partial<ScheduleExecutorConfig>): void;
    /**
     * Get current configuration
     */
    getConfig(): ScheduleExecutorConfig;
    /**
     * Check if current time is within the execution window
     */
    isWithinWindow(): boolean;
    /**
     * Check if today is a valid execution day
     */
    shouldProcessToday(): boolean;
    /**
     * Check if execution can proceed in scheduled mode
     */
    canExecuteScheduled(): boolean;
    /**
     * Get the next execution window start time
     */
    getNextWindowStart(): Date;
    /**
     * Execute queued updates
     *
     * @param mode - 'immediate' bypasses time window checks, 'scheduled' respects them
     */
    execute(mode?: ExecutionMode): Promise<ExecutionResult>;
    /**
     * Execute immediately (bypasses time window checks)
     */
    executeImmediate(): Promise<ExecutionResult>;
    /**
     * Execute if within scheduled window
     */
    executeScheduled(): Promise<ExecutionResult>;
    /**
     * Get execution status summary
     */
    getStatus(): {
        enabled: boolean;
        withinWindow: boolean;
        validDay: boolean;
        pendingUpdates: number;
        nextWindow: Date;
        config: ScheduleExecutorConfig;
    };
    /**
     * Create a pre-update backup
     *
     * @returns Path to the created backup, or null if backup is disabled or failed
     */
    createPreUpdateBackup(): Promise<string | null>;
    /**
     * Clean up old pre-update backups based on retention policy
     */
    cleanupOldBackups(): Promise<string[]>;
    /**
     * List pre-update backups
     */
    listPreUpdateBackups(): Promise<Array<{
        filename: string;
        path: string;
        created: Date;
        size: number;
    }>>;
}
/**
 * Get the singleton schedule executor
 */
export declare function getScheduleExecutor(): ScheduleExecutor | null;
/**
 * Initialize the schedule executor
 */
export declare function initScheduleExecutor(queue: UpdateQueue, scheduleService: ScheduleService, updateHandler: (update: QueuedUpdate) => Promise<{
    success: boolean;
    error?: string;
}>, config?: Partial<ScheduleExecutorConfig>): ScheduleExecutor;
/**
 * Reset the singleton (for testing)
 */
export declare function resetScheduleExecutor(): void;
//# sourceMappingURL=schedule-executor.d.ts.map