import type { InjectionToken } from '@omnitron-dev/titan/nexus'; export type CronExpressionType = string | Date; export declare enum SchedulerJobType { CRON = "cron", INTERVAL = "interval", TIMEOUT = "timeout", DELAYED = "delayed", RECURRING = "recurring" } export declare enum JobPriority { CRITICAL = 0, HIGH = 1, NORMAL = 2, LOW = 3, IDLE = 4 } export declare enum JobStatus { PENDING = "pending", RUNNING = "running", COMPLETED = "completed", FAILED = "failed", CANCELLED = "cancelled", PAUSED = "paused", RETRYING = "retrying" } export interface IBaseJobOptions { name?: string; priority?: JobPriority; retry?: IRetryOptions; onError?: (error: Error) => void | Promise; onSuccess?: (result: any) => void | Promise; disabled?: boolean; timeout?: number; persist?: boolean; metadata?: Record; preventOverlap?: boolean; } export interface ICronOptions extends IBaseJobOptions { timezone?: string; utcOffset?: number; startTime?: Date | string; endTime?: Date | string; immediate?: boolean; } export interface IIntervalOptions extends IBaseJobOptions { immediate?: boolean; } export interface ITimeoutOptions extends IBaseJobOptions { } export interface IRetryOptions { maxAttempts?: number; delay?: number; backoff?: number; maxDelay?: number; retryIf?: (error: Error) => boolean; } export interface IScheduledJob { id: string; name: string; type: SchedulerJobType; status: JobStatus; target: any; method: string; options: ICronOptions | IIntervalOptions | ITimeoutOptions; pattern?: string | number; nextExecution?: Date; lastExecution?: Date; executionCount: number; failureCount: number; createdAt: Date; updatedAt: Date; instance?: any; lastError?: Error; lastResult?: any; avgExecutionTime?: number; isRunning: boolean; dependencies?: string[]; } export interface IJobExecutionContext { jobId: string; jobName: string; executionId: string; timestamp: Date; attempt: number; metadata?: Record; previousResult?: any; signal?: AbortSignal; } export interface IJobExecutionResult { jobId: string; executionId: string; status: 'success' | 'failure' | 'cancelled'; result?: any; error?: Error; duration: number; timestamp: Date; attempt?: number; } export interface ISchedulerConfig { enabled?: boolean; timezone?: string; persistence?: { enabled: boolean; provider?: any; options?: Record; }; metrics?: { enabled: boolean; interval?: number; includeDetails?: boolean; }; distributed?: { enabled: boolean; lockProvider?: 'redis' | 'database'; lockTTL?: number; nodeId?: string; }; retry?: IRetryOptions; maxConcurrent?: number; queueSize?: number; queueTimeout?: number; debug?: boolean; shutdownTimeout?: number; healthCheck?: { enabled: boolean; path?: string; }; } export interface ISchedulerMetrics { totalJobs: number; activeJobs: number; jobsByStatus: Record; jobsByType: Record; totalExecutions: number; successfulExecutions: number; failedExecutions: number; avgExecutionTime: number; queueSize: number; uptime: number; memoryUsage?: { rss: number; heapTotal: number; heapUsed: number; }; timestamp: Date; } export interface IJobFilterOptions { status?: JobStatus | JobStatus[]; type?: SchedulerJobType | SchedulerJobType[]; namePattern?: string | RegExp; priority?: JobPriority | JobPriority[]; includeDisabled?: boolean; sortBy?: 'name' | 'nextExecution' | 'lastExecution' | 'priority' | 'createdAt'; sortDirection?: 'asc' | 'desc'; limit?: number; offset?: number; } export interface IJobListener { onJobStart?(job: IScheduledJob, context: IJobExecutionContext): void | Promise; onJobComplete?(job: IScheduledJob, result: IJobExecutionResult): void | Promise; onJobError?(job: IScheduledJob, error: Error, context: IJobExecutionContext): void | Promise; onJobRetry?(job: IScheduledJob, attempt: number, error: Error): void | Promise; onJobCancelled?(job: IScheduledJob, reason?: string): void | Promise; } export interface ISchedulerModuleOptions extends ISchedulerConfig { listeners?: IJobListener[]; executor?: InjectionToken; persistenceProvider?: InjectionToken; metricsProvider?: InjectionToken; } export interface ISchedulerModuleAsyncOptions { imports?: any[]; useFactory?: (...args: any[]) => Promise | ISchedulerModuleOptions; inject?: InjectionToken[]; useExisting?: InjectionToken; } export interface IJobMetadata { type: SchedulerJobType; pattern?: string | number; options?: ICronOptions | IIntervalOptions | ITimeoutOptions; target: any; propertyKey: string; } export declare enum CronExpression { EVERY_SECOND = "* * * * * *", EVERY_5_SECONDS = "*/5 * * * * *", EVERY_10_SECONDS = "*/10 * * * * *", EVERY_30_SECONDS = "*/30 * * * * *", EVERY_MINUTE = "*/1 * * * *", EVERY_5_MINUTES = "*/5 * * * *", EVERY_10_MINUTES = "*/10 * * * *", EVERY_30_MINUTES = "*/30 * * * *", EVERY_HOUR = "0 * * * *", EVERY_DAY_AT_1AM = "0 1 * * *", EVERY_DAY_AT_2AM = "0 2 * * *", EVERY_DAY_AT_3AM = "0 3 * * *", EVERY_DAY_AT_4AM = "0 4 * * *", EVERY_DAY_AT_5AM = "0 5 * * *", EVERY_DAY_AT_6AM = "0 6 * * *", EVERY_DAY_AT_MIDNIGHT = "0 0 * * *", EVERY_DAY_AT_NOON = "0 12 * * *", EVERY_WEEK = "0 0 * * 0", EVERY_WEEKDAY = "0 0 * * 1-5", EVERY_WEEKEND = "0 0 * * 0,6", EVERY_1ST_DAY_OF_MONTH = "0 0 1 * *", EVERY_LAST_DAY_OF_MONTH = "0 0 L * *", EVERY_QUARTER = "0 0 1 */3 *", EVERY_YEAR = "0 0 1 1 *" } //# sourceMappingURL=scheduler.interfaces.d.ts.map