@@ -19,6 +19,20 @@ export type { Logger }
1919 */
2020export type Duration = number | string
2121
22+ /**
23+ * Retention policy for completed/failed jobs.
24+ *
25+ * - `true` (default): Remove job immediately
26+ * - `false`: Keep job in history indefinitely
27+ * - `{ age?, count? }`: Keep with pruning by age and/or count
28+ */
29+ export type JobRetention = boolean | { age ?: Duration ; count ?: number }
30+
31+ /**
32+ * Possible statuses for a job in the queue.
33+ */
34+ export type JobStatus = 'pending' | 'active' | 'delayed' | 'completed' | 'failed'
35+
2236/**
2337 * Result returned when dispatching a job.
2438 *
@@ -78,6 +92,20 @@ export interface JobData {
7892 stalledCount ?: number
7993}
8094
95+ /**
96+ * Record of a job's current state, including history for completed/failed jobs.
97+ */
98+ export interface JobRecord {
99+ /** Current status of the job */
100+ status : JobStatus
101+ /** Original job data */
102+ data : JobData
103+ /** Timestamp when the job finished (for completed/failed jobs) */
104+ finishedAt ?: number
105+ /** Error message (for failed jobs) */
106+ error ?: string
107+ }
108+
81109/**
82110 * Static options for a Job class.
83111 *
@@ -150,6 +178,8 @@ export interface JobOptions {
150178 * @default true
151179 */
152180 failOnTimeout ?: boolean
181+ removeOnComplete ?: JobRetention
182+ removeOnFail ?: JobRetention
153183}
154184
155185/**
@@ -244,6 +274,7 @@ export interface BackoffConfig {
244274export interface QueueConfig {
245275 adapter ?: string
246276 retry ?: any
277+ defaultJobOptions ?: JobOptions
247278}
248279
249280export interface WorkerConfig {
@@ -416,6 +447,7 @@ export interface QueueManagerConfig {
416447 default : string
417448 adapters : Record < string , AdapterFactory >
418449 retry ?: RetryConfig
450+ defaultJobOptions ?: JobOptions
419451 queues ?: Record < string , QueueConfig >
420452 worker ?: WorkerConfig
421453 locations ?: string [ ]
0 commit comments