import type { OccurrencePlan } from './plan'; import type { ScheduledJob } from '../types'; export interface PlannedJob { job: ScheduledJob; plan: OccurrencePlan; } export interface NewOccurrence { jobId: number; taskType: string; payload: Record; scheduledFor: Date; runAt: Date; maxAttempts: number; missedAfter: Date; } export interface SupersededOccurrences { jobId: number; before: Date; } export interface RecordedOccurrence { id: string; jobId: number; taskType: string; } export interface RecordOccurrencesResult { recorded: number; created: RecordedOccurrence[]; } export interface DueJobs { now: Date; jobs: ScheduledJob[]; } export interface MaterializerTransaction { claimDueJobs(limit: number, lookaheadMs: number): Promise; recordOccurrences(occurrences: NewOccurrence[]): Promise; retireSuperseded(superseded: SupersededOccurrences[]): Promise; advanceJobs(planned: PlannedJob[]): Promise; } export type RunInTransaction = (work: (tx: MaterializerTransaction) => Promise) => Promise;