export type TaskContext = { date: Date; dateLocalIso: string; task?: ScheduledTask; execution?: Execution; triggeredAt: Date; }; export type TaskEvent = 'task:started' | 'task:stopped' | 'task:destroyed' | 'execution:started' | 'execution:finished' | 'execution:failed' | 'execution:missed' | 'execution:overlap' | 'execution:maxReached'; export type TaskOptions = { timezone?: string; name?: string; noOverlap?: boolean; maxExecutions?: number; }; export type Execution = { id: string; reason: 'invoked' | 'scheduled'; startedAt?: Date; finishedAt?: Date; error?: Error; result?: any; }; export type TaskFn = (context: TaskContext) => any | Promise; export interface ScheduledTask { id: string; name?: string; start(): void | Promise; stop(): void | Promise; getStatus(): string | Promise; destroy(): void | Promise; execute(): Promise; getNextRun(): Date | null; on(event: TaskEvent, fun: (context: TaskContext) => Promise | void): void; off(event: TaskEvent, fun: (context: TaskContext) => Promise | void): void; once(event: TaskEvent, fun: (context: TaskContext) => Promise | void): void; }