/**
 * Job Scheduler
 *
 * Core scheduler that manages recurring jobs with configurable intervals.
 * Supports pause/resume, retry with backoff, and job state tracking.
 *
 * @module core/scheduler/job-scheduler
 */
import { ScheduledJob, ScheduledJobConfig, JobType } from './scheduled-job.js';
import { Logger } from '../../utils/logger.js';
/**
 * Job scheduler configuration
 */
export interface JobSchedulerOptions {
    /**
     * Logger instance
     */
    logger?: Logger;
}
/**
 * Job scheduler events
 */
export type JobSchedulerEvent = 'job-registered' | 'job-unregistered' | 'job-started' | 'job-completed' | 'job-failed' | 'job-paused' | 'job-resumed';
/**
 * Event listener callback
 */
export type JobSchedulerEventListener = (event: JobSchedulerEvent, job: ScheduledJob, data?: Record<string, unknown>) => void;
/**
 * JobScheduler - Manages recurring background jobs
 *
 * Key features:
 * - Register/unregister jobs dynamically
 * - Check for due jobs (for execution by caller)
 * - Track job state (idle, running, failed, disabled)
 * - Exponential backoff for failed jobs
 * - Event notifications for state changes
 */
export declare class JobScheduler {
    private jobs;
    private listeners;
    private readonly logger;
    constructor(options?: JobSchedulerOptions);
    /**
     * Register a new job with the scheduler
     *
     * @param config - Job configuration
     * @throws Error if job with same ID already exists
     */
    registerJob(config: ScheduledJobConfig): void;
    /**
     * Unregister a job from the scheduler
     *
     * @param jobId - Job ID to remove
     * @returns true if job was removed, false if not found
     */
    unregisterJob(jobId: string): boolean;
    /**
     * Get a job by ID
     *
     * @param jobId - Job ID
     * @returns Job or undefined if not found
     */
    getJob(jobId: string): ScheduledJob | undefined;
    /**
     * Get all registered jobs
     *
     * @returns Array of all jobs
     */
    getAllJobs(): ScheduledJob[];
    /**
     * Get jobs by type
     *
     * @param type - Job type to filter by
     * @returns Array of matching jobs
     */
    getJobsByType(type: JobType): ScheduledJob[];
    /**
     * Get all jobs that are due for execution
     *
     * @returns Array of due jobs (sorted by next run time)
     */
    getNextDueJobs(): ScheduledJob[];
    /**
     * Mark a job as started (running)
     *
     * @param jobId - Job ID
     * @throws Error if job not found or not in idle state
     */
    markJobStarted(jobId: string): void;
    /**
     * Mark a job as completed successfully
     *
     * @param jobId - Job ID
     * @param data - Optional result data
     * @throws Error if job not found
     */
    markJobComplete(jobId: string, data?: Record<string, unknown>): void;
    /**
     * Mark a job as failed
     *
     * @param jobId - Job ID
     * @param error - Error message
     * @throws Error if job not found
     */
    markJobFailed(jobId: string, error: string): void;
    /**
     * Pause a job (stops scheduling but preserves state)
     *
     * @param jobId - Job ID
     * @throws Error if job not found
     */
    pauseJob(jobId: string): void;
    /**
     * Resume a paused job
     *
     * @param jobId - Job ID
     * @throws Error if job not found
     */
    resumeJob(jobId: string): void;
    /**
     * Reset a failed job for retry
     *
     * @param jobId - Job ID
     * @throws Error if job not found
     */
    resetJob(jobId: string): void;
    /**
     * Update job interval
     *
     * @param jobId - Job ID
     * @param intervalMs - New interval in milliseconds
     * @throws Error if job not found
     */
    updateJobInterval(jobId: string, intervalMs: number): void;
    /**
     * Load jobs from persisted state
     *
     * @param jobs - Array of persisted jobs
     */
    loadJobs(jobs: ScheduledJob[]): void;
    /**
     * Get all jobs for persistence
     *
     * @returns Array of all jobs
     */
    getJobsForPersistence(): ScheduledJob[];
    /**
     * Add an event listener
     *
     * @param listener - Callback function
     */
    addEventListener(listener: JobSchedulerEventListener): void;
    /**
     * Remove an event listener
     *
     * @param listener - Callback function
     */
    removeEventListener(listener: JobSchedulerEventListener): void;
    /**
     * Get scheduler statistics
     *
     * @returns Scheduler stats
     */
    getStats(): {
        totalJobs: number;
        byStatus: Record<string, number>;
        byType: Record<string, number>;
        dueCount: number;
    };
    /**
     * Emit an event to all listeners
     */
    private emit;
    /**
     * Get a job or throw if not found
     */
    private getJobOrThrow;
}
//# sourceMappingURL=job-scheduler.d.ts.map