@igniter-js/jobs 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,1107 +1,634 @@
1
+ import { p as IgniterJobsQueue, I as IgniterJobsAdapter, q as IgniterJobsScopeDefinition, c as IgniterJobDefinition, m as IgniterJobsWorkerBuilderConfig, r as IgniterJobsTelemetry, s as IgniterJobsInferSchemaInput, d as IgniterCronDefinition, g as IgniterJobSearchResult, h as IgniterJobStatus, t as IgniterJobsDispatchParams, u as IgniterJobsScheduleParams, n as IgniterJobsEventHandler, j as IgniterJobsQueueInfo, k as IgniterJobsQueueCleanOptions, v as IgniterJobsLimiter, w as IgniterJobsWorkerHandlers, l as IgniterJobsWorkerHandle, x as IgniterJobsScopeOptions, y as IgniterJobsSchema } from './adapter-PiDCQWQd.mjs';
2
+ export { o as IgniterJobCounts, e as IgniterJobsAdapterDispatchParams, f as IgniterJobsAdapterScheduleParams, b as IgniterJobsBullMQAdapterOptions, z as IgniterJobsEvent, B as IgniterJobsExecutionContext, F as IgniterJobsFailureHook, C as IgniterJobsHookContext, L as IgniterJobsInferSchemaOutput, A as IgniterJobsInvokeOptions, i as IgniterJobsJobLog, G as IgniterJobsProgressHook, a as IgniterJobsQueueManager, J as IgniterJobsScheduleOptions, H as IgniterJobsScopeEntry, D as IgniterJobsStartHook, E as IgniterJobsSuccessHook, K as IgniterJobsWorkerMetrics } from './adapter-PiDCQWQd.mjs';
1
3
  import { IgniterLogger, IgniterError } from '@igniter-js/core';
2
- import { IgniterTelemetry } from '@igniter-js/telemetry';
3
- import { n as IgniterJobDefinition, o as IgniterCronDefinition, p as IgniterQueueConfig, I as IgniterJobsAdapter, q as IgniterJobScopeOptions, r as IgniterJobActorOptions, l as AdapterJobHandler } from './adapter-CcQCatSa.mjs';
4
- export { A as AdapterDispatchParams, a as AdapterScheduleParams, k as AdapterWorkerConfig, m as AdapterWorkerHandle, y as IgniterCronFailureHook, u as IgniterCronHandler, v as IgniterCronHandlerContext, Q as IgniterJobActorEntry, z as IgniterJobBackoff, x as IgniterJobCompleteHook, M as IgniterJobCompletedPayload, g as IgniterJobCounts, J as IgniterJobEnqueuedPayload, G as IgniterJobEventContext, i as IgniterJobEventHandler, H as IgniterJobEventPayload, F as IgniterJobEventType, N as IgniterJobFailedPayload, w as IgniterJobFailureHook, s as IgniterJobHandler, t as IgniterJobHandlerContext, b as IgniterJobInfo, B as IgniterJobLimiter, d as IgniterJobLog, L as IgniterJobProgressPayload, O as IgniterJobRetryingPayload, P as IgniterJobScopeEntry, h as IgniterJobSearchResult, K as IgniterJobStartedPayload, c as IgniterJobStatus, j as IgniterJobUnsubscribeFn, D as IgniterJobsSearchFilter, f as IgniterQueueCleanOptions, e as IgniterQueueInfo, C as IgniterQueuesSearchFilter, E as IgniterWorkersSearchFilter } from './adapter-CcQCatSa.mjs';
4
+ export { IgniterJobsBullMQAdapter } from './adapters/bullmq.adapter.mjs';
5
+ export { IgniterJobsMemoryAdapter } from './adapters/memory.adapter.mjs';
6
+ import 'ioredis';
5
7
 
6
8
  /**
7
- * @fileoverview Configuration types for @igniter-js/jobs
8
- * @module @igniter-js/jobs/types/config
9
+ * Configuration used to build the jobs runtime.
9
10
  */
10
-
11
- /**
12
- * Full configuration for IgniterJobs.
13
- *
14
- * @typeParam TContext - Application context type
15
- * @typeParam TQueues - Map of queue names to queue configs
16
- * @typeParam TScope - Scope key (only one allowed)
17
- * @typeParam TActor - Actor key (only one allowed)
18
- */
19
- interface IgniterJobsConfig<TContext = unknown, TQueues extends Record<string, IgniterQueueConfig<TContext, any, any>> = Record<string, never>, TScope extends string = never, TActor extends string = never> {
20
- /**
21
- * Queue adapter (required).
22
- */
11
+ interface IgniterJobsConfig<TContext = unknown, TQueues extends Record<string, IgniterJobsQueue<TContext, any, any>> = {}, TScope extends string = never> {
23
12
  adapter: IgniterJobsAdapter;
24
- /**
25
- * Application context provider (required).
26
- * Called for each job to get the context.
27
- */
28
- context: () => TContext | Promise<TContext>;
29
- /**
30
- * Queue configurations.
31
- */
13
+ service: string;
14
+ environment: string;
15
+ contextFactory: () => TContext | Promise<TContext>;
32
16
  queues: TQueues;
33
- /**
34
- * Scope definition (only one allowed).
35
- * Used for multi-tenancy.
36
- */
37
- scope?: TScope extends never ? never : {
38
- key: TScope;
39
- options?: IgniterJobScopeOptions;
40
- };
41
- /**
42
- * Actor definition (only one allowed).
43
- * Used for auditing.
44
- */
45
- actor?: TActor extends never ? never : {
46
- key: TActor;
47
- options?: IgniterJobActorOptions;
17
+ scopeDefinition?: IgniterJobsScopeDefinition<TScope>;
18
+ queueDefaults?: Partial<IgniterJobDefinition<TContext, any, any>>;
19
+ workerDefaults?: Partial<IgniterJobsWorkerBuilderConfig>;
20
+ autoStartWorker?: {
21
+ queues: (keyof TQueues)[];
22
+ concurrency?: number;
23
+ limiter?: IgniterJobsWorkerBuilderConfig['limiter'];
48
24
  };
49
- /**
50
- * Telemetry instance for observability.
51
- */
52
- telemetry?: IgniterTelemetry;
53
- /**
54
- * Custom logger.
55
- */
56
25
  logger?: IgniterLogger;
57
- /**
58
- * Default job options applied to all jobs.
59
- */
60
- defaults?: {
61
- /**
62
- * Default retry configuration.
63
- */
64
- retry?: {
65
- attempts?: number;
66
- backoff?: {
67
- type: 'exponential' | 'fixed' | 'linear';
68
- delay: number;
69
- maxDelay?: number;
70
- };
71
- };
72
- /**
73
- * Default timeout in milliseconds.
74
- */
75
- timeout?: number;
76
- /**
77
- * Default remove on complete config.
78
- */
79
- removeOnComplete?: boolean | {
80
- count?: number;
81
- age?: number;
82
- };
83
- /**
84
- * Default remove on fail config.
85
- */
86
- removeOnFail?: boolean | {
87
- count?: number;
88
- age?: number;
89
- };
90
- };
26
+ telemetry?: IgniterJobsTelemetry;
91
27
  }
92
28
  /**
93
- * Builder state for IgniterJobs configuration.
94
- *
95
- * @typeParam TContext - Application context type
96
- * @typeParam TQueues - Map of queue names to queue configs
97
- * @typeParam TScope - Scope key
98
- * @typeParam TActor - Actor key
29
+ * Builder interface placeholder to help fluent APIs type-infer.
99
30
  */
100
- interface IgniterJobsBuilderState<TContext = unknown, TQueues extends Record<string, IgniterQueueConfig<TContext, any, any>> = Record<string, never>, TScope extends string = never, TActor extends string = never> {
31
+ interface IgniterJobsBuilderState<TContext, TQueues extends Record<string, IgniterJobsQueue<TContext, any, any>>, TScope extends string> {
101
32
  adapter?: IgniterJobsAdapter;
102
- context?: () => TContext | Promise<TContext>;
33
+ service?: string;
34
+ environment?: string;
35
+ contextFactory?: () => TContext | Promise<TContext>;
103
36
  queues: TQueues;
104
- scope?: {
105
- key: TScope;
106
- options?: IgniterJobScopeOptions;
107
- };
108
- actor?: {
109
- key: TActor;
110
- options?: IgniterJobActorOptions;
37
+ scopeDefinition?: IgniterJobsScopeDefinition<TScope>;
38
+ queueDefaults?: Partial<IgniterJobDefinition<TContext, any, any>>;
39
+ workerDefaults?: Partial<IgniterJobsWorkerBuilderConfig>;
40
+ autoStartWorker?: {
41
+ queues: (keyof TQueues)[];
42
+ concurrency?: number;
43
+ limiter?: IgniterJobsWorkerBuilderConfig['limiter'];
111
44
  };
112
- telemetry?: IgniterTelemetry;
113
- logger?: IgniterLogger;
114
- defaults?: IgniterJobsConfig<TContext>['defaults'];
115
- }
116
- /**
117
- * Builder state for IgniterQueue configuration.
118
- *
119
- * @typeParam TContext - Application context type
120
- * @typeParam TJobs - Map of job names to definitions
121
- * @typeParam TCrons - Map of cron names to definitions
122
- */
123
- interface IgniterQueueBuilderState<TContext = unknown, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any>> = Record<string, never>, TCrons extends Record<string, IgniterCronDefinition<TContext, any>> = Record<string, never>> {
124
- name: string;
125
- jobs: TJobs;
126
- crons: TCrons;
127
45
  }
128
46
 
129
47
  /**
130
- * @fileoverview Worker types for @igniter-js/jobs
131
- * @module @igniter-js/jobs/types/worker
48
+ * @fileoverview Runtime surface types for @igniter-js/jobs
49
+ * @module @igniter-js/jobs/types/runtime
132
50
  */
133
- /**
134
- * Worker handle returned from worker.start().
135
- */
136
- interface IgniterWorkerHandle {
137
- /**
138
- * Unique worker ID.
139
- */
140
- readonly id: string;
141
- /**
142
- * Pause the worker (stops processing new jobs).
143
- */
51
+
52
+ type IgniterJobsInferInput<TInput> = IgniterJobsInferSchemaInput<TInput>;
53
+ type IgniterJobsInferJobInput<TDef> = TDef extends IgniterJobDefinition<any, infer TInput, any> ? IgniterJobsInferInput<TInput> : unknown;
54
+ type IgniterJobsInferCronResult<TDef> = TDef extends IgniterCronDefinition<any, infer TResult> ? TResult : unknown;
55
+ interface IgniterJobsJobInstanceAccessor {
56
+ retrieve(): Promise<IgniterJobSearchResult | null>;
57
+ retry(): Promise<void>;
58
+ remove(): Promise<void>;
59
+ promote(): Promise<void>;
60
+ move(state: 'failed', reason: string): Promise<void>;
61
+ state(): Promise<IgniterJobStatus | null>;
62
+ progress(): Promise<number>;
63
+ logs(): Promise<{
64
+ timestamp: Date;
65
+ message: string;
66
+ level: 'info' | 'warn' | 'error';
67
+ }[]>;
68
+ }
69
+ interface IgniterJobsJobManyAccessor {
70
+ retry(): Promise<void>;
71
+ remove(): Promise<void>;
72
+ }
73
+ interface IgniterJobsJobAccessor<TInput = unknown, TResult = unknown> {
74
+ dispatch(params: IgniterJobsDispatchParams<TInput>): Promise<string>;
75
+ schedule(params: IgniterJobsScheduleParams<TInput>): Promise<string>;
76
+ get(id: string): IgniterJobsJobInstanceAccessor;
77
+ many(ids: string[]): IgniterJobsJobManyAccessor;
144
78
  pause(): Promise<void>;
145
- /**
146
- * Resume the worker.
147
- */
148
79
  resume(): Promise<void>;
149
- /**
150
- * Close the worker gracefully.
151
- */
152
- close(): Promise<void>;
153
- /**
154
- * Check if worker is currently running.
155
- */
156
- isRunning(): boolean;
157
- /**
158
- * Check if worker is paused.
159
- */
160
- isPaused(): boolean;
161
- /**
162
- * Get worker metrics.
163
- */
164
- getMetrics(): Promise<IgniterWorkerMetrics>;
80
+ subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
165
81
  }
166
- /**
167
- * Worker metrics.
168
- */
169
- interface IgniterWorkerMetrics {
170
- /**
171
- * Total jobs processed.
172
- */
173
- processed: number;
174
- /**
175
- * Total jobs failed.
176
- */
177
- failed: number;
178
- /**
179
- * Total jobs completed successfully.
180
- */
181
- completed: number;
182
- /**
183
- * Currently active jobs.
184
- */
185
- active: number;
186
- /**
187
- * Worker uptime in milliseconds.
188
- */
189
- uptime: number;
82
+ interface IgniterJobsQueueManagerAccessor {
83
+ retrieve(): Promise<IgniterJobsQueueInfo | null>;
84
+ pause(): Promise<void>;
85
+ resume(): Promise<void>;
86
+ drain(): Promise<number>;
87
+ clean(options: IgniterJobsQueueCleanOptions): Promise<number>;
88
+ obliterate(options?: {
89
+ force?: boolean;
90
+ }): Promise<void>;
91
+ retryAll(): Promise<number>;
190
92
  }
191
- /**
192
- * Worker builder state.
193
- */
194
- interface IgniterWorkerBuilderState {
195
- /**
196
- * Queue names to process.
197
- */
198
- queues: string[];
199
- /**
200
- * Concurrency per queue.
201
- */
202
- concurrency: number;
203
- /**
204
- * Lock duration in milliseconds.
205
- */
206
- lockDuration?: number;
207
- /**
208
- * Rate limiter configuration.
209
- */
210
- limiter?: {
211
- max: number;
212
- duration: number;
93
+ type IgniterJobsQueueAccessor<TJobs extends Record<string, IgniterJobDefinition<any, any, any>> = {}> = {
94
+ get(): IgniterJobsQueueManagerAccessor;
95
+ list(filter?: {
96
+ status?: IgniterJobStatus[];
97
+ limit?: number;
98
+ offset?: number;
99
+ }): Promise<IgniterJobSearchResult[]>;
100
+ subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
101
+ readonly jobs: {
102
+ [K in keyof TJobs]: IgniterJobsJobAccessor<IgniterJobsInferJobInput<TJobs[K]>, any>;
213
103
  };
214
- /**
215
- * Callback when worker becomes idle.
216
- */
217
- onIdle?: () => void;
104
+ } & {
105
+ [K in keyof TJobs]: IgniterJobsJobAccessor<IgniterJobsInferJobInput<TJobs[K]>, any>;
106
+ };
107
+ interface IgniterJobsWorkerBuilderAccessor<TQueueNames extends string> {
108
+ create(): IgniterJobsWorkerFluentBuilder<TQueueNames>;
218
109
  }
110
+ interface IgniterJobsWorkerFluentBuilder<TQueueNames extends string> {
111
+ addQueue(queue: TQueueNames): IgniterJobsWorkerFluentBuilder<TQueueNames>;
112
+ withConcurrency(concurrency: number): IgniterJobsWorkerFluentBuilder<TQueueNames>;
113
+ withLimiter(limiter: IgniterJobsLimiter): IgniterJobsWorkerFluentBuilder<TQueueNames>;
114
+ onActive(handler: NonNullable<IgniterJobsWorkerHandlers['onActive']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
115
+ onSuccess(handler: NonNullable<IgniterJobsWorkerHandlers['onSuccess']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
116
+ onFailure(handler: NonNullable<IgniterJobsWorkerHandlers['onFailure']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
117
+ onIdle(handler: NonNullable<IgniterJobsWorkerHandlers['onIdle']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
118
+ start(): Promise<IgniterJobsWorkerHandle>;
119
+ }
120
+ interface IgniterJobsBaseRuntime<TConfig extends IgniterJobsConfig<any, any, any> = IgniterJobsConfig<any, any, any>> {
121
+ readonly config: TConfig;
122
+ subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
123
+ search(target: 'jobs', filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
124
+ search(target: 'queues', filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
125
+ search(target: 'workers', filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
126
+ shutdown(): Promise<void>;
127
+ readonly worker: IgniterJobsWorkerBuilderAccessor<keyof TConfig['queues'] & string>;
128
+ scope: TConfig extends IgniterJobsConfig<any, any, infer TScope> ? (TScope extends string ? (type: TScope, id: string | number, tags?: Record<string, unknown>) => IgniterJobsRuntime<TConfig> : never) : never;
129
+ }
130
+ type IgniterJobsRuntime<TConfig extends IgniterJobsConfig<any, any, any> = IgniterJobsConfig<any, any, any>> = IgniterJobsBaseRuntime<TConfig> & {
131
+ [Q in keyof TConfig['queues']]: TConfig['queues'][Q] extends {
132
+ jobs: infer TJobs extends Record<string, IgniterJobDefinition<any, any, any>>;
133
+ } ? IgniterJobsQueueAccessor<TJobs> : IgniterJobsQueueAccessor;
134
+ };
219
135
 
220
136
  /**
221
- * @fileoverview Builder for creating IgniterJobs instances
222
- * @module @igniter-js/jobs/builders/igniter-jobs
223
- *
224
- * @description
225
- * Provides a fluent builder API for configuring and creating IgniterJobs instances.
226
- * Supports adapter configuration, context provider, queues, scopes, actors, and telemetry.
137
+ * Canonical error codes for `@igniter-js/jobs`.
138
+ */
139
+ declare const IGNITER_JOBS_ERROR_CODES: {
140
+ readonly JOBS_ADAPTER_REQUIRED: "JOBS_ADAPTER_REQUIRED";
141
+ readonly JOBS_SERVICE_REQUIRED: "JOBS_SERVICE_REQUIRED";
142
+ readonly JOBS_CONTEXT_REQUIRED: "JOBS_CONTEXT_REQUIRED";
143
+ readonly JOBS_CONFIGURATION_INVALID: "JOBS_CONFIGURATION_INVALID";
144
+ readonly JOBS_QUEUE_NOT_FOUND: "JOBS_QUEUE_NOT_FOUND";
145
+ readonly JOBS_QUEUE_DUPLICATE: "JOBS_QUEUE_DUPLICATE";
146
+ readonly JOBS_QUEUE_OPERATION_FAILED: "JOBS_QUEUE_OPERATION_FAILED";
147
+ readonly JOBS_INVALID_DEFINITION: "JOBS_INVALID_DEFINITION";
148
+ readonly JOBS_HANDLER_REQUIRED: "JOBS_HANDLER_REQUIRED";
149
+ readonly JOBS_DUPLICATE_JOB: "JOBS_DUPLICATE_JOB";
150
+ readonly JOBS_NOT_FOUND: "JOBS_NOT_FOUND";
151
+ readonly JOBS_NOT_REGISTERED: "JOBS_NOT_REGISTERED";
152
+ readonly JOBS_EXECUTION_FAILED: "JOBS_EXECUTION_FAILED";
153
+ readonly JOBS_TIMEOUT: "JOBS_TIMEOUT";
154
+ readonly JOBS_CONTEXT_FACTORY_FAILED: "JOBS_CONTEXT_FACTORY_FAILED";
155
+ readonly JOBS_VALIDATION_FAILED: "JOBS_VALIDATION_FAILED";
156
+ readonly JOBS_INVALID_INPUT: "JOBS_INVALID_INPUT";
157
+ readonly JOBS_INVALID_CRON: "JOBS_INVALID_CRON";
158
+ readonly JOBS_INVALID_SCHEDULE: "JOBS_INVALID_SCHEDULE";
159
+ readonly JOBS_SCOPE_ALREADY_DEFINED: "JOBS_SCOPE_ALREADY_DEFINED";
160
+ readonly JOBS_WORKER_FAILED: "JOBS_WORKER_FAILED";
161
+ readonly JOBS_ADAPTER_ERROR: "JOBS_ADAPTER_ERROR";
162
+ readonly JOBS_ADAPTER_CONNECTION_FAILED: "JOBS_ADAPTER_CONNECTION_FAILED";
163
+ readonly JOBS_SUBSCRIBE_FAILED: "JOBS_SUBSCRIBE_FAILED";
164
+ };
165
+ type IgniterJobsErrorCode = keyof typeof IGNITER_JOBS_ERROR_CODES;
166
+ interface IgniterJobsErrorOptions {
167
+ /** Error code scoped to Igniter Jobs. */
168
+ code: IgniterJobsErrorCode;
169
+ /** Human-readable message. */
170
+ message: string;
171
+ /** HTTP-like status code hint (default: 500). */
172
+ statusCode?: number;
173
+ /** Optional structured details for debugging and clients. */
174
+ details?: unknown;
175
+ /** Optional metadata for logs and tracing. */
176
+ metadata?: Record<string, unknown>;
177
+ /** Optional causer tag used by some Igniter tooling. */
178
+ causer?: string;
179
+ /** Underlying cause for debugging (optional). */
180
+ cause?: Error;
181
+ /** Optional logger passthrough to align with other Igniter errors. */
182
+ logger?: any;
183
+ }
184
+ /**
185
+ * Typed error class for the Jobs package.
227
186
  *
228
187
  * @example
229
188
  * ```typescript
230
- * import { IgniterJobs, IgniterQueue } from '@igniter-js/jobs'
231
- * import { BullMQAdapter } from '@igniter-js/jobs/adapters'
232
- * import Redis from 'ioredis'
233
- *
234
- * const redis = new Redis()
235
- *
236
- * const emailQueue = IgniterQueue.create<AppContext>('email')
237
- * .addJob('sendWelcome', { ... })
238
- * .build()
239
- *
240
- * const jobs = IgniterJobs.create<AppContext>()
241
- * .withAdapter(BullMQAdapter.create({ redis }))
242
- * .withContext(() => ({ db, mailer }))
243
- * .addQueue(emailQueue)
244
- * .addScope('organization')
245
- * .addActor('user')
246
- * .build()
189
+ * throw new IgniterJobsError({
190
+ * code: 'JOBS_INVALID_INPUT',
191
+ * message: 'Input payload failed validation',
192
+ * })
247
193
  * ```
248
194
  */
195
+ declare class IgniterJobsError extends IgniterError {
196
+ constructor(options: IgniterJobsErrorOptions);
197
+ }
249
198
 
250
199
  /**
251
- * Builder for creating IgniterJobs instances.
200
+ * Fluent builder responsible for configuring and constructing an `IgniterJobs` instance.
252
201
  *
253
- * @typeParam TContext - Application context type
254
- * @typeParam TQueues - Map of queue names to queue configs
255
- * @typeParam TScope - Scope key (only one allowed)
256
- * @typeParam TActor - Actor key (only one allowed)
202
+ * The builder follows the immutable pattern used across Igniter packages: each
203
+ * method returns a new builder with refined types. Only a single scope is
204
+ * supported per the current specification (no actor support).
257
205
  */
258
- declare class IgniterJobsBuilder<TContext = unknown, TQueues extends Record<string, IgniterQueueBuilderState<TContext, any, any>> = Record<string, never>, TScope extends string = never, TActor extends string = never> {
206
+ declare class IgniterJobsBuilder<TContext, TQueues extends Record<string, IgniterJobsQueue<TContext, any, any>> = {}, TScope extends string = never> {
259
207
  private readonly state;
260
208
  private constructor();
261
209
  /**
262
- * Create a new IgniterJobs builder.
263
- *
264
- * @returns A new IgniterJobsBuilder instance
265
- *
266
- * @example
267
- * ```typescript
268
- * const jobs = IgniterJobs.create<AppContext>()
269
- * .withAdapter(...)
270
- * .build()
271
- * ```
210
+ * Creates the initial builder with no configuration.
272
211
  */
273
- static create<TContext = unknown>(): IgniterJobsBuilder<TContext>;
212
+ static create<TContext>(): IgniterJobsBuilder<TContext>;
274
213
  /**
275
- * Configure the queue adapter (required).
276
- *
277
- * @param adapter - The queue adapter (e.g., BullMQAdapter)
278
- * @returns The builder with adapter configured
279
- *
280
- * @example
281
- * ```typescript
282
- * .withAdapter(BullMQAdapter.create({ redis }))
283
- * ```
214
+ * Returns a new builder with updated state while preserving generics.
284
215
  */
285
- withAdapter(adapter: IgniterJobsAdapter): IgniterJobsBuilder<TContext, TQueues, TScope, TActor>;
216
+ private clone;
286
217
  /**
287
- * Configure the application context provider (required).
288
- * This function is called for each job to provide the application context.
289
- *
290
- * @param contextFn - Function that returns the application context
291
- * @returns The builder with context configured
218
+ * Attaches the jobs adapter.
292
219
  *
293
- * @example
294
- * ```typescript
295
- * .withContext(() => ({
296
- * db: prisma,
297
- * mailer: mailerService,
298
- * cache: redis,
299
- * }))
300
- * ```
220
+ * @param adapter - Backend adapter implementation (BullMQ, memory, etc.).
301
221
  */
302
- withContext(contextFn: () => TContext | Promise<TContext>): IgniterJobsBuilder<TContext, TQueues, TScope, TActor>;
222
+ withAdapter(adapter: IgniterJobsAdapter): IgniterJobsBuilder<TContext, TQueues, TScope>;
303
223
  /**
304
- * Add a queue to the jobs instance.
305
- *
306
- * @param queue - Queue configuration from IgniterQueue.create().build()
307
- * @returns The builder with the queue added
308
- *
309
- * @example
310
- * ```typescript
311
- * const emailQueue = IgniterQueue.create<AppContext>('email')
312
- * .addJob('sendWelcome', { ... })
313
- * .build()
224
+ * Sets the service identifier for telemetry and metrics.
314
225
  *
315
- * const jobs = IgniterJobs.create<AppContext>()
316
- * .addQueue(emailQueue)
317
- * .build()
318
- * ```
226
+ * @param service - Service name (e.g., "my-api").
319
227
  */
320
- addQueue<TQueueState extends IgniterQueueBuilderState<TContext, any, any>>(queue: TQueueState): IgniterJobsBuilder<TContext, TQueues & {
321
- [K in TQueueState['name']]: TQueueState;
322
- }, TScope, TActor>;
228
+ withService(service: string): IgniterJobsBuilder<TContext, TQueues, TScope>;
323
229
  /**
324
- * Add a scope for multi-tenancy (only one scope allowed).
325
- * Scopes are used to isolate jobs by organization, tenant, etc.
326
- *
327
- * @param key - Scope key (e.g., 'organization', 'tenant')
328
- * @param options - Optional scope configuration
329
- * @returns The builder with scope configured
330
- *
331
- * @example
332
- * ```typescript
333
- * .addScope('organization', { required: true })
334
- * ```
230
+ * Sets the environment name (e.g., development, staging, production).
335
231
  */
336
- addScope<TScopeKey extends string>(key: TScope extends never ? TScopeKey : never, options?: IgniterJobScopeOptions): IgniterJobsBuilder<TContext, TQueues, TScopeKey, TActor>;
232
+ withEnvironment(environment: string): IgniterJobsBuilder<TContext, TQueues, TScope>;
337
233
  /**
338
- * Add an actor for auditing (only one actor type allowed).
339
- * Actors are used to track who initiated jobs.
340
- *
341
- * @param key - Actor key (e.g., 'user', 'system')
342
- * @param options - Optional actor configuration
343
- * @returns The builder with actor configured
344
- *
345
- * @example
346
- * ```typescript
347
- * .addActor('user', { description: 'The user who initiated the job' })
348
- * ```
234
+ * Provides a context factory used when executing jobs.
349
235
  */
350
- addActor<TActorKey extends string>(key: TActor extends never ? TActorKey : never, options?: IgniterJobActorOptions): IgniterJobsBuilder<TContext, TQueues, TScope, TActorKey>;
236
+ withContext(factory: () => TContext | Promise<TContext>): IgniterJobsBuilder<TContext, TQueues, TScope>;
351
237
  /**
352
- * Configure telemetry for observability (optional).
353
- *
354
- * @param telemetry - IgniterTelemetry instance
355
- * @returns The builder with telemetry configured
356
- *
357
- * @example
358
- * ```typescript
359
- * .withTelemetry(telemetry)
360
- * ```
238
+ * Adds a scope definition (single scope supported).
361
239
  */
362
- withTelemetry(telemetry: IgniterTelemetry): IgniterJobsBuilder<TContext, TQueues, TScope, TActor>;
240
+ addScope<TNewScope extends string>(name: TNewScope, options?: IgniterJobsScopeOptions): IgniterJobsBuilder<TContext, TQueues, TScope | TNewScope>;
363
241
  /**
364
- * Configure a custom logger (optional).
365
- *
366
- * @param logger - Logger instance
367
- * @returns The builder with logger configured
368
- *
369
- * @example
370
- * ```typescript
371
- * .withLogger(customLogger)
372
- * ```
242
+ * Registers a queue definition on the builder.
373
243
  */
374
- withLogger(logger: IgniterLogger): IgniterJobsBuilder<TContext, TQueues, TScope, TActor>;
244
+ addQueue<TName extends string, TQueue extends IgniterJobsQueue<TContext, any, any>>(queue: TQueue & {
245
+ name: TName;
246
+ }): IgniterJobsBuilder<TContext, TQueues & Record<TName, TQueue>, TScope>;
375
247
  /**
376
- * Configure default job options applied to all jobs.
377
- *
378
- * @param defaults - Default job configuration
379
- * @returns The builder with defaults configured
380
- *
381
- * @example
382
- * ```typescript
383
- * .withDefaults({
384
- * retry: { attempts: 3, backoff: { type: 'exponential', delay: 1000 } },
385
- * timeout: 30000,
386
- * removeOnComplete: { count: 1000 },
387
- * })
388
- * ```
248
+ * Applies default job options to all queues.
389
249
  */
390
- withDefaults(defaults: {
391
- retry?: {
392
- attempts?: number;
393
- backoff?: {
394
- type: 'exponential' | 'fixed' | 'linear';
395
- delay: number;
396
- maxDelay?: number;
397
- };
398
- };
399
- timeout?: number;
400
- removeOnComplete?: boolean | {
401
- count?: number;
402
- age?: number;
403
- };
404
- removeOnFail?: boolean | {
405
- count?: number;
406
- age?: number;
407
- };
408
- }): IgniterJobsBuilder<TContext, TQueues, TScope, TActor>;
250
+ withQueueDefaults(defaults: Partial<IgniterJobDefinition<TContext, any, any>>): IgniterJobsBuilder<TContext, TQueues, TScope>;
409
251
  /**
410
- * Build the IgniterJobs instance.
411
- * Validates configuration and returns a fully typed jobs instance.
412
- *
413
- * @returns The IgniterJobs instance with proxy for typed access
414
- *
415
- * @throws {IgniterJobsError} If adapter is not configured
416
- * @throws {IgniterJobsError} If context is not configured
417
- * @throws {IgniterJobsError} If no queues are defined
418
- *
419
- * @example
420
- * ```typescript
421
- * const jobs = IgniterJobs.create<AppContext>()
422
- * .withAdapter(adapter)
423
- * .withContext(() => context)
424
- * .addQueue(emailQueue)
425
- * .build()
426
- *
427
- * // Now use with full type safety
428
- * await jobs.email.sendWelcome.dispatch({ userId: '123' })
429
- * ```
252
+ * Applies default worker options.
430
253
  */
431
- build(): IgniterJobsInstance<TContext, TQueues, TScope, TActor>;
432
- }
433
- /**
434
- * Type for the built IgniterJobs instance.
435
- * Provides typed access to queues, jobs, and management APIs.
436
- */
437
- type IgniterJobsInstance<TContext, TQueues extends Record<string, IgniterQueueBuilderState<TContext, any, any>>, TScope extends string, TActor extends string> = {
438
- [QueueName in keyof TQueues]: IgniterQueueProxy<TContext, TQueues[QueueName]['jobs'], TQueues[QueueName]['crons'], TScope, TActor>;
439
- } & {
440
- subscribe: IgniterJobsGlobalSubscribe;
441
- search: IgniterJobsSearch;
442
- worker: IgniterJobsWorkerBuilder<TQueues>;
443
- shutdown: () => Promise<void>;
444
- };
445
- /**
446
- * Queue proxy type providing access to jobs and queue management.
447
- */
448
- type IgniterQueueProxy<TContext, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any>>, TCrons extends Record<string, IgniterCronDefinition<TContext, any>>, TScope extends string, TActor extends string> = {
449
- [JobName in keyof TJobs]: IgniterJobProxy<TContext, TJobs[JobName] extends IgniterJobDefinition<TContext, infer TInput, infer TOutput> ? TInput : unknown, TJobs[JobName] extends IgniterJobDefinition<TContext, infer TInput, infer TOutput> ? TOutput : unknown, TScope, TActor>;
450
- } & {
451
- subscribe: (handler: (event: any) => void | Promise<void>) => Promise<() => Promise<void>>;
452
- list: (options?: {
453
- status?: string[];
454
- limit?: number;
455
- }) => Promise<any[]>;
456
- get: () => IgniterQueueManagement;
457
- };
458
- /**
459
- * Job proxy type providing dispatch, schedule, and job management.
460
- */
461
- interface IgniterJobProxy<TContext, TInput, TOutput, TScope extends string, TActor extends string> {
462
- dispatch: IgniterJobDispatch<TInput, TScope, TActor>;
463
- schedule: IgniterJobSchedule<TInput, TScope, TActor>;
464
- get: (jobId: string) => IgniterJobManagement;
465
- many: (jobIds: string[]) => IgniterJobBatchManagement;
466
- pause: () => Promise<void>;
467
- resume: () => Promise<void>;
468
- subscribe: (handler: (event: any) => void | Promise<void>) => Promise<() => Promise<void>>;
469
- }
470
- /**
471
- * Job dispatch function type.
472
- */
473
- type IgniterJobDispatch<TInput, TScope extends string, TActor extends string> = (input: TInput, options?: IgniterJobDispatchOptions<TScope, TActor>) => Promise<string>;
474
- /**
475
- * Job dispatch options.
476
- */
477
- interface IgniterJobDispatchOptions<TScope extends string, TActor extends string> {
478
- jobId?: string;
479
- delay?: number;
480
- priority?: number;
481
- scope?: TScope extends never ? never : {
482
- id: string;
483
- tags?: Record<string, string | number | boolean>;
484
- };
485
- actor?: TActor extends never ? never : {
486
- id?: string;
487
- tags?: Record<string, string | number | boolean>;
488
- };
489
- }
490
- /**
491
- * Job schedule function type.
492
- */
493
- type IgniterJobSchedule<TInput, TScope extends string, TActor extends string> = (params: {
494
- input: TInput;
495
- at?: Date;
496
- cron?: string;
497
- every?: number;
498
- timezone?: string;
499
- jobId?: string;
500
- scope?: TScope extends never ? never : {
501
- id: string;
502
- tags?: Record<string, string | number | boolean>;
503
- };
504
- actor?: TActor extends never ? never : {
505
- id?: string;
506
- tags?: Record<string, string | number | boolean>;
507
- };
508
- }) => Promise<string>;
509
- /**
510
- * Single job management operations.
511
- */
512
- interface IgniterJobManagement {
513
- retrieve: () => Promise<any>;
514
- retry: () => Promise<void>;
515
- remove: () => Promise<void>;
516
- state: () => Promise<string | null>;
517
- progress: () => Promise<number>;
518
- logs: () => Promise<any[]>;
519
- promote: () => Promise<void>;
520
- move: (state: 'failed' | 'completed', reason?: string) => Promise<void>;
521
- }
522
- /**
523
- * Batch job management operations.
524
- */
525
- interface IgniterJobBatchManagement {
526
- retry: () => Promise<void>;
527
- remove: () => Promise<void>;
528
- }
529
- /**
530
- * Queue management operations.
531
- */
532
- interface IgniterQueueManagement {
533
- retrieve: () => Promise<any>;
534
- pause: () => Promise<void>;
535
- resume: () => Promise<void>;
536
- drain: () => Promise<number>;
537
- clean: (options: {
538
- status: string | string[];
539
- olderThan?: number;
540
- limit?: number;
541
- }) => Promise<number>;
542
- obliterate: (options?: {
543
- force?: boolean;
544
- }) => Promise<void>;
545
- retryAll: () => Promise<number>;
546
- }
547
- /**
548
- * Global subscribe function.
549
- */
550
- type IgniterJobsGlobalSubscribe = (handler: (event: any) => void | Promise<void>) => Promise<() => Promise<void>>;
551
- /**
552
- * Search function.
553
- */
554
- interface IgniterJobsSearch {
555
- (target: 'queues', filter?: any): Promise<any[]>;
556
- (target: 'jobs', filter?: any): Promise<any[]>;
557
- (target: 'workers', filter?: any): Promise<any[]>;
558
- }
559
- /**
560
- * Worker builder interface.
561
- */
562
- interface IgniterJobsWorkerBuilder<TQueues> {
563
- create: () => IgniterJobsWorkerConfig<TQueues>;
564
- }
565
- /**
566
- * Worker configuration builder.
567
- */
568
- interface IgniterJobsWorkerConfig<TQueues> {
569
- forQueues: (...queues: (keyof TQueues)[]) => IgniterJobsWorkerConfig<TQueues>;
570
- withConcurrency: (concurrency: number) => IgniterJobsWorkerConfig<TQueues>;
571
- withLockDuration: (duration: number) => IgniterJobsWorkerConfig<TQueues>;
572
- withLimiter: (config: {
573
- max: number;
574
- duration: number;
575
- }) => IgniterJobsWorkerConfig<TQueues>;
576
- onIdle: (callback: () => void) => IgniterJobsWorkerConfig<TQueues>;
577
- start: () => Promise<any>;
254
+ withWorkerDefaults(defaults: Partial<IgniterJobsWorkerBuilderConfig>): IgniterJobsBuilder<TContext, TQueues, TScope>;
255
+ /**
256
+ * Configures automatic worker startup.
257
+ */
258
+ withAutoStartWorker(config: {
259
+ queues: (keyof TQueues)[];
260
+ concurrency?: number;
261
+ limiter?: IgniterJobsLimiter;
262
+ }): IgniterJobsBuilder<TContext, TQueues, TScope>;
263
+ /**
264
+ * Attaches telemetry support.
265
+ */
266
+ withTelemetry(telemetry: IgniterJobsTelemetry): IgniterJobsBuilder<TContext, TQueues, TScope>;
267
+ /**
268
+ * Attaches a custom logger.
269
+ */
270
+ withLogger(logger: IgniterLogger): IgniterJobsBuilder<TContext, TQueues, TScope>;
271
+ /**
272
+ * Finalizes the configuration and returns the runtime instance.
273
+ */
274
+ build(): IgniterJobsRuntime<IgniterJobsConfig<TContext, TQueues, TScope>>;
578
275
  }
276
+
579
277
  /**
580
- * Convenience alias for IgniterJobsBuilder.create().
581
- *
582
- * @example
583
- * ```typescript
584
- * import { IgniterJobs } from '@igniter-js/jobs'
585
- *
586
- * const jobs = IgniterJobs.create<AppContext>()
587
- * .withAdapter(adapter)
588
- * .withContext(() => context)
589
- * .addQueue(emailQueue)
590
- * .build()
591
- * ```
278
+ * @fileoverview Queue builder for @igniter-js/jobs
279
+ * @module @igniter-js/jobs/builders/igniter-queue
592
280
  */
593
- declare const IgniterJobs: {
594
- create: typeof IgniterJobsBuilder.create;
595
- };
596
281
 
597
282
  /**
598
- * @fileoverview Builder for creating IgniterQueue instances
599
- * @module @igniter-js/jobs/builders/igniter-queue
600
- *
601
- * @description
602
- * Provides a fluent builder API for defining queues with jobs and cron jobs.
603
- * Queues group related jobs together and provide type-safe job definitions.
283
+ * Builder for defining queues, jobs, and cron tasks.
604
284
  *
605
285
  * @example
606
286
  * ```typescript
607
287
  * import { IgniterQueue } from '@igniter-js/jobs'
608
288
  * import { z } from 'zod'
609
289
  *
610
- * const emailQueue = IgniterQueue.create<AppContext>('email')
290
+ * const emailQueue = IgniterQueue.create('email')
291
+ * .withContext<{ mailer: Mailer }>()
611
292
  * .addJob('sendWelcome', {
612
- * input: z.object({
613
- * userId: z.string(),
614
- * email: z.string().email(),
615
- * }),
616
- * retry: { attempts: 3 },
617
- * handler: async (ctx) => {
618
- * await ctx.context.mailer.send({
619
- * to: ctx.input.email,
620
- * template: 'welcome',
621
- * })
293
+ * input: z.object({ email: z.string().email() }),
294
+ * handler: async ({ input, context }) => {
295
+ * await context.mailer.send(input)
622
296
  * },
623
297
  * })
624
- * .addCron('cleanupExpired', {
625
- * expression: '0 0 * * *',
626
- * handler: async (ctx) => {
627
- * await ctx.context.db.cleanup.expiredSessions()
298
+ * .addCron('cleanup', {
299
+ * cron: '0 2 * * *',
300
+ * handler: async ({ context }) => {
301
+ * await context.mailer.cleanup()
628
302
  * },
629
303
  * })
630
304
  * .build()
631
305
  * ```
632
306
  */
633
-
634
- /**
635
- * Builder for creating queue configurations.
636
- *
637
- * @typeParam TContext - Application context type
638
- * @typeParam TJobs - Map of job names to definitions
639
- * @typeParam TCrons - Map of cron names to definitions
640
- */
641
- declare class IgniterQueueBuilder<TContext = unknown, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any>> = Record<string, never>, TCrons extends Record<string, IgniterCronDefinition<TContext, any>> = Record<string, never>> {
307
+ declare class IgniterQueueBuilder<TContext, TJobs extends Record<string, IgniterJobDefinition<TContext, any, any>> = {}, TCron extends Record<string, IgniterCronDefinition<TContext, any>> = {}, TName extends string = string> {
642
308
  private readonly state;
643
309
  private constructor();
644
310
  /**
645
- * Create a new queue builder.
646
- *
647
- * @param name - Queue name (kebab-case, e.g., 'email', 'payment-processing')
648
- * @returns A new IgniterQueueBuilder instance
649
- *
650
- * @example
651
- * ```typescript
652
- * const emailQueue = IgniterQueue.create<AppContext>('email')
653
- * ```
311
+ * Creates a new queue builder for the given queue name.
654
312
  */
655
- static create<TContext = unknown>(name: string): IgniterQueueBuilder<TContext>;
313
+ static create<const TName extends string>(name: TName): IgniterQueueBuilder<unknown, {}, {}, TName>;
656
314
  /**
657
- * Add a job definition to the queue.
315
+ * Re-types this builder with the application context type.
658
316
  *
659
- * @param name - Job name (camelCase, e.g., 'sendWelcome', 'processPayment')
660
- * @param definition - Job definition with input schema, handler, retry config, etc.
661
- * @returns The builder with the new job added
317
+ * This is a type-level helper; it does not mutate runtime state.
662
318
  *
663
319
  * @example
664
320
  * ```typescript
665
- * .addJob('sendWelcome', {
666
- * input: z.object({
667
- * userId: z.string(),
668
- * email: z.string().email(),
669
- * }),
670
- * retry: { attempts: 3, backoff: { type: 'exponential', delay: 1000 } },
671
- * handler: async (ctx) => {
672
- * await ctx.context.mailer.send({
673
- * to: ctx.input.email,
674
- * template: 'welcome',
675
- * })
676
- * },
677
- * })
321
+ * const queue = IgniterQueue.create('email')
322
+ * .withContext<AppContext>()
323
+ * .addJob('send', { handler: async ({ context }) => context.mailer.send() })
678
324
  * ```
679
325
  */
680
- addJob<TName extends string, TInput, TOutput = void>(name: TName extends keyof TJobs ? never : TName, definition: IgniterJobDefinition<TContext, TInput, TOutput>): IgniterQueueBuilder<TContext, TJobs & {
681
- [K in TName]: IgniterJobDefinition<TContext, TInput, TOutput>;
682
- }, TCrons>;
326
+ withContext<TNewContext>(this: IgniterQueueBuilder<unknown, {}, {}, TName>): IgniterQueueBuilder<TNewContext, {}, {}, TName>;
327
+ private clone;
683
328
  /**
684
- * Add a cron job definition to the queue.
329
+ * Registers a job on the queue.
685
330
  *
686
- * @param name - Cron job name (camelCase)
687
- * @param definition - Cron definition with expression, handler, etc.
688
- * @returns The builder with the new cron added
689
- *
690
- * @example
691
- * ```typescript
692
- * .addCron('cleanupExpired', {
693
- * expression: '0 0 * * *', // Every day at midnight
694
- * timezone: 'America/New_York',
695
- * handler: async (ctx) => {
696
- * await ctx.context.db.cleanup.expiredSessions()
697
- * },
698
- * })
699
- * ```
331
+ * @param jobName - Unique name of the job inside the queue.
332
+ * @param definition - Job definition (handler, schemas, options, hooks).
700
333
  */
701
- addCron<TName extends string, TOutput = void>(name: TName extends keyof TCrons ? never : TName, definition: IgniterCronDefinition<TContext, TOutput>): IgniterQueueBuilder<TContext, TJobs, TCrons & {
702
- [K in TName]: IgniterCronDefinition<TContext, TOutput>;
703
- }>;
334
+ addJob<TJobName extends string, TInput extends IgniterJobsSchema | unknown, TResult = unknown>(jobName: TJobName, definition: IgniterJobDefinition<TContext, TInput, TResult>): IgniterQueueBuilder<TContext, TJobs & Record<TJobName, IgniterJobDefinition<TContext, TInput, TResult>>, TCron, TName>;
704
335
  /**
705
- * Build the queue configuration.
706
- *
707
- * @returns The queue configuration ready to be registered with IgniterJobs
336
+ * Registers a cron task on the queue.
708
337
  *
709
- * @example
710
- * ```typescript
711
- * const emailQueue = IgniterQueue.create<AppContext>('email')
712
- * .addJob('sendWelcome', { ... })
713
- * .build()
714
- * ```
338
+ * @param cronName - Unique name of the cron task inside the queue.
339
+ * @param definition - Cron definition (cron string, tz, handler, options).
340
+ */
341
+ addCron<TCronName extends string, TResult = unknown>(cronName: TCronName, definition: IgniterCronDefinition<TContext, TResult>): IgniterQueueBuilder<TContext, TJobs, TCron & Record<TCronName, IgniterCronDefinition<TContext, TResult>>, TName>;
342
+ /**
343
+ * Finalizes the queue definition.
715
344
  */
716
- build(): IgniterQueueBuilderState<TContext, TJobs, TCrons>;
345
+ build(): IgniterJobsQueue<TContext, TJobs, TCron> & {
346
+ name: TName;
347
+ };
717
348
  }
718
- /**
719
- * Convenience alias for IgniterQueueBuilder.create().
720
- * Use this to create queue configurations with a fluent API.
721
- *
722
- * @example
723
- * ```typescript
724
- * import { IgniterQueue } from '@igniter-js/jobs'
725
- *
726
- * const emailQueue = IgniterQueue.create<AppContext>('email')
727
- * .addJob('sendWelcome', { ... })
728
- * .build()
729
- * ```
730
- */
731
- declare const IgniterQueue: {
732
- create: typeof IgniterQueueBuilder.create;
733
- };
734
349
 
735
350
  /**
736
- * @fileoverview Builder for creating workers
351
+ * @fileoverview Worker builder for @igniter-js/jobs
737
352
  * @module @igniter-js/jobs/builders/igniter-worker
738
353
  */
739
354
 
355
+ type IgniterJobsWorkerBuilderState<TAllowedQueues extends string> = {
356
+ queues: TAllowedQueues[];
357
+ concurrency?: number;
358
+ limiter?: IgniterJobsLimiter;
359
+ handlers: IgniterJobsWorkerHandlers;
360
+ };
740
361
  /**
741
- * Builder for configuring and starting workers.
362
+ * Fluent builder for creating workers tied to registered queues.
742
363
  *
743
- * @example
744
- * ```typescript
745
- * const worker = await jobs.worker
746
- * .create()
747
- * .forQueues('email', 'payment')
748
- * .withConcurrency(10)
749
- * .withLimiter({ max: 100, duration: 60000 })
750
- * .start()
751
- * ```
364
+ * Instances of this builder are created by `jobs.worker.create()` so it can be
365
+ * automatically scoped to registered queue names.
752
366
  */
753
- declare class IgniterWorkerBuilder {
754
- private state;
755
- private adapter;
756
- private jobHandler;
757
- private availableQueues;
758
- constructor(adapter: IgniterJobsAdapter, jobHandler: AdapterJobHandler, availableQueues: string[]);
367
+ declare class IgniterWorkerBuilder<TAllowedQueues extends string> {
368
+ private readonly adapter;
369
+ private readonly allowedQueues;
370
+ private readonly state;
371
+ constructor(params: {
372
+ adapter: IgniterJobsAdapter;
373
+ allowedQueues: readonly TAllowedQueues[];
374
+ state?: Partial<IgniterJobsWorkerBuilderState<TAllowedQueues>>;
375
+ });
376
+ private clone;
759
377
  /**
760
- * Specify which queues this worker should process.
761
- * If not called, worker processes all queues.
762
- *
763
- * @param queues - Queue names to process
764
- * @returns The builder for chaining
378
+ * Adds a queue to the worker.
765
379
  *
766
- * @example
767
- * ```typescript
768
- * .forQueues('email', 'payment')
769
- * ```
380
+ * @param queue - Queue name registered on the jobs instance.
770
381
  */
771
- forQueues(...queues: string[]): this;
382
+ addQueue(queue: TAllowedQueues): IgniterWorkerBuilder<TAllowedQueues>;
772
383
  /**
773
- * Set the concurrency level (jobs processed in parallel per queue).
774
- *
775
- * @param concurrency - Number of parallel jobs
776
- * @returns The builder for chaining
777
- *
778
- * @example
779
- * ```typescript
780
- * .withConcurrency(10)
781
- * ```
384
+ * Sets the worker concurrency.
782
385
  */
783
- withConcurrency(concurrency: number): this;
386
+ withConcurrency(concurrency: number): IgniterWorkerBuilder<TAllowedQueues>;
784
387
  /**
785
- * Set the lock duration in milliseconds.
786
- * Jobs are locked for this duration while being processed.
787
- *
788
- * @param duration - Lock duration in milliseconds
789
- * @returns The builder for chaining
790
- *
791
- * @example
792
- * ```typescript
793
- * .withLockDuration(30000) // 30 seconds
794
- * ```
388
+ * Sets a worker-level rate limiter.
795
389
  */
796
- withLockDuration(duration: number): this;
390
+ withLimiter(limiter: IgniterJobsLimiter): IgniterWorkerBuilder<TAllowedQueues>;
391
+ onActive(handler: NonNullable<IgniterJobsWorkerHandlers['onActive']>): IgniterWorkerBuilder<TAllowedQueues>;
392
+ onSuccess(handler: NonNullable<IgniterJobsWorkerHandlers['onSuccess']>): IgniterWorkerBuilder<TAllowedQueues>;
393
+ onFailure(handler: NonNullable<IgniterJobsWorkerHandlers['onFailure']>): IgniterWorkerBuilder<TAllowedQueues>;
394
+ onIdle(handler: NonNullable<IgniterJobsWorkerHandlers['onIdle']>): IgniterWorkerBuilder<TAllowedQueues>;
797
395
  /**
798
- * Configure rate limiting for the worker.
799
- *
800
- * @param config - Rate limiter configuration
801
- * @returns The builder for chaining
396
+ * Builds and starts the worker.
802
397
  *
803
- * @example
804
- * ```typescript
805
- * .withLimiter({ max: 100, duration: 60000 }) // 100 jobs per minute
806
- * ```
398
+ * If no queues are added explicitly, the adapter should interpret it as "all queues".
807
399
  */
808
- withLimiter(config: {
809
- max: number;
810
- duration: number;
811
- }): this;
400
+ start(): Promise<IgniterJobsWorkerHandle>;
401
+ }
402
+
403
+ /**
404
+ * @fileoverview Core runtime factory for @igniter-js/jobs
405
+ * @module @igniter-js/jobs/core/igniter-jobs
406
+ */
407
+
408
+ /**
409
+ * Runtime wrapper produced by `IgniterJobsBuilder`.
410
+ *
411
+ * The concrete implementation will expose queue/job proxies, management APIs,
412
+ * worker builder access, and shutdown handling.
413
+ */
414
+ declare class IgniterJobs {
812
415
  /**
813
- * Set a callback to be called when the worker becomes idle.
814
- *
815
- * @param callback - Idle callback
816
- * @returns The builder for chaining
416
+ * Starts the fluent builder API for jobs.
817
417
  *
818
418
  * @example
819
419
  * ```typescript
820
- * .onIdle(() => console.log('Worker is idle'))
420
+ * const jobs = IgniterJobs.create<AppContext>()
421
+ * .withAdapter(IgniterJobsMemoryAdapter.create())
422
+ * .withService('my-api')
423
+ * .withEnvironment('test')
424
+ * .withContext(async () => ({ db }))
425
+ * .addQueue(emailQueue)
426
+ * .build()
821
427
  * ```
822
428
  */
823
- onIdle(callback: () => void): this;
429
+ static create<TContext>(): IgniterJobsBuilder<TContext, {}, never>;
824
430
  /**
825
- * Start the worker.
826
- *
827
- * @returns Worker handle for management
828
- *
829
- * @example
830
- * ```typescript
831
- * const worker = await jobs.worker
832
- * .create()
833
- * .forQueues('email')
834
- * .start()
835
- *
836
- * // Later
837
- * await worker.pause()
838
- * await worker.close()
839
- * ```
431
+ * Creates a runtime instance from a validated configuration.
840
432
  */
841
- start(): Promise<IgniterWorkerHandle>;
433
+ static fromConfig<TConfig extends IgniterJobsConfig<any, any, any>>(config: TConfig): IgniterJobsRuntime<TConfig>;
842
434
  }
843
435
 
844
436
  /**
845
- * @fileoverview IgniterJobs runtime class with proxy-based API
846
- * @module @igniter-js/jobs/core/igniter-jobs
437
+ * @fileoverview Public queue entry point for @igniter-js/jobs
438
+ * @module @igniter-js/jobs/core/igniter-queue
847
439
  */
848
440
 
849
441
  /**
850
- * Configuration passed to IgniterJobsRuntime.
851
- */
852
- interface IgniterJobsRuntimeConfig<TContext, TQueues extends Record<string, IgniterQueueBuilderState<TContext, any, any>>, TScope extends string, TActor extends string> {
853
- adapter: IgniterJobsAdapter;
854
- context: () => TContext | Promise<TContext>;
855
- queues: TQueues;
856
- scope?: {
857
- key: TScope;
858
- options?: IgniterJobScopeOptions;
859
- };
860
- actor?: {
861
- key: TActor;
862
- options?: IgniterJobActorOptions;
863
- };
864
- telemetry?: IgniterTelemetry;
865
- logger?: IgniterLogger;
866
- defaults?: {
867
- retry?: {
868
- attempts?: number;
869
- backoff?: any;
870
- };
871
- timeout?: number;
872
- removeOnComplete?: boolean | {
873
- count?: number;
874
- age?: number;
875
- };
876
- removeOnFail?: boolean | {
877
- count?: number;
878
- age?: number;
879
- };
880
- };
881
- }
882
- /**
883
- * Main runtime class for IgniterJobs.
884
- * Creates proxy-based API for type-safe job access.
442
+ * Queue facade that exposes the fluent queue builder API.
885
443
  */
886
- declare class IgniterJobsRuntime<TContext, TQueues extends Record<string, IgniterQueueBuilderState<TContext, any, any>>, TScope extends string, TActor extends string> {
887
- private readonly config;
888
- private readonly queueNames;
889
- constructor(config: IgniterJobsRuntimeConfig<TContext, TQueues, TScope, TActor>);
890
- /**
891
- * Create the main proxy that provides queue access and global methods.
892
- */
893
- private createProxy;
894
- /**
895
- * Create a proxy for a specific queue.
896
- */
897
- private createQueueProxy;
898
- /**
899
- * Create a proxy for a specific job.
900
- */
901
- private createJobProxy;
902
- /**
903
- * Dispatch a job.
904
- */
905
- private dispatchJob;
906
- /**
907
- * Schedule a job for future execution.
908
- */
909
- private scheduleJob;
444
+ declare class IgniterQueue {
910
445
  /**
911
- * Create job management methods.
912
- */
913
- private createJobManagement;
914
- /**
915
- * Create batch job management methods.
916
- */
917
- private createJobBatchManagement;
918
- /**
919
- * Create queue management methods.
920
- */
921
- private createQueueManagement;
922
- /**
923
- * Pause a specific job type.
924
- */
925
- private pauseJobType;
926
- /**
927
- * Resume a specific job type.
928
- */
929
- private resumeJobType;
930
- /**
931
- * Subscribe to events for a specific job.
932
- */
933
- private subscribeToJob;
934
- /**
935
- * Create queue-level subscribe.
936
- */
937
- private createQueueSubscribe;
938
- /**
939
- * List jobs in a queue.
940
- */
941
- private listQueueJobs;
942
- /**
943
- * Create global subscribe.
944
- */
945
- private createGlobalSubscribe;
946
- /**
947
- * Create search function.
948
- */
949
- private createSearch;
950
- /**
951
- * Create worker builder.
952
- */
953
- private createWorkerBuilder;
954
- /**
955
- * Create the job handler function for workers.
956
- */
957
- private createJobHandler;
958
- /**
959
- * Shutdown the jobs instance.
446
+ * Creates a new queue builder for the given name.
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * const queue = IgniterQueue.create('email')
451
+ * .withContext<AppContext>()
452
+ * .addJob('sendWelcome', { handler: async () => {} })
453
+ * .build()
454
+ * ```
960
455
  */
961
- private shutdown;
456
+ static create<const TName extends string>(name: TName): IgniterQueueBuilder<unknown, {}, {}, TName>;
962
457
  }
963
458
 
964
459
  /**
965
- * @fileoverview Error class and error codes for @igniter-js/jobs
966
- * @module @igniter-js/jobs/errors
460
+ * @fileoverview Telemetry event definitions for @igniter-js/jobs
461
+ * @module @igniter-js/jobs/telemetry/jobs.telemetry
462
+ *
463
+ * @description
464
+ * Defines all telemetry events emitted by the jobs package during job
465
+ * lifecycle operations. These events can be consumed by any transport
466
+ * adapter configured on the telemetry instance.
467
+ *
468
+ * Events follow the pattern: igniter.jobs.<group>.<event>
469
+ *
470
+ * Groups:
471
+ * - job: Job lifecycle events (enqueued, started, completed, failed, progress, retrying)
472
+ * - worker: Worker lifecycle events (started, stopped, idle)
473
+ * - queue: Queue management events (paused, resumed, drained, cleaned)
474
+ *
475
+ * @example
476
+ * ```typescript
477
+ * import { IgniterTelemetry } from '@igniter-js/telemetry'
478
+ * import { IgniterJobsTelemetryEvents } from '@igniter-js/jobs'
479
+ *
480
+ * const telemetry = IgniterTelemetry.create()
481
+ * .withService('my-api')
482
+ * .addEvents(IgniterJobsTelemetryEvents)
483
+ * .build()
484
+ * ```
967
485
  */
968
-
969
486
  /**
970
- * All possible error codes for IgniterJobs.
971
- * Use these codes for programmatic error handling.
487
+ * Telemetry event definitions for @igniter-js/jobs.
488
+ *
489
+ * This descriptor can be passed to `IgniterTelemetry.addEvents()` to register
490
+ * all job-related telemetry events with proper type inference.
491
+ *
492
+ * Event names follow the pattern: `igniter.jobs.<group>.<event>`
972
493
  *
973
494
  * @example
974
495
  * ```typescript
975
- * try {
976
- * await jobs.email.sendWelcome.dispatch(input)
977
- * } catch (error) {
978
- * if (error instanceof IgniterJobsError) {
979
- * switch (error.code) {
980
- * case 'JOBS_ADAPTER_REQUIRED':
981
- * // Handle missing adapter
982
- * break
983
- * case 'JOBS_DISPATCH_FAILED':
984
- * // Handle dispatch failure
985
- * break
986
- * }
987
- * }
988
- * }
496
+ * import { IgniterTelemetry } from '@igniter-js/telemetry'
497
+ * import { IgniterJobsTelemetryEvents } from '@igniter-js/jobs'
498
+ *
499
+ * const telemetry = IgniterTelemetry.create()
500
+ * .withService('my-api')
501
+ * .addEvents(IgniterJobsTelemetryEvents)
502
+ * .build()
503
+ *
504
+ * // Type-safe emit
505
+ * telemetry.emit('igniter.jobs.job.completed', {
506
+ * attributes: {
507
+ * 'ctx.job.id': 'job_123',
508
+ * 'ctx.job.name': 'sendWelcome',
509
+ * 'ctx.job.queue': 'email',
510
+ * 'ctx.job.duration': 1500,
511
+ * },
512
+ * })
989
513
  * ```
990
514
  */
991
- declare const IGNITER_JOBS_ERROR_CODES: {
992
- readonly JOBS_ADAPTER_REQUIRED: "JOBS_ADAPTER_REQUIRED";
993
- readonly JOBS_CONTEXT_REQUIRED: "JOBS_CONTEXT_REQUIRED";
994
- readonly JOBS_QUEUE_REQUIRED: "JOBS_QUEUE_REQUIRED";
995
- readonly JOBS_CONFIGURATION_INVALID: "JOBS_CONFIGURATION_INVALID";
996
- readonly JOBS_QUEUE_NOT_FOUND: "JOBS_QUEUE_NOT_FOUND";
997
- readonly JOBS_QUEUE_ALREADY_EXISTS: "JOBS_QUEUE_ALREADY_EXISTS";
998
- readonly JOBS_QUEUE_NAME_INVALID: "JOBS_QUEUE_NAME_INVALID";
999
- readonly JOBS_QUEUE_PAUSE_FAILED: "JOBS_QUEUE_PAUSE_FAILED";
1000
- readonly JOBS_QUEUE_RESUME_FAILED: "JOBS_QUEUE_RESUME_FAILED";
1001
- readonly JOBS_QUEUE_DRAIN_FAILED: "JOBS_QUEUE_DRAIN_FAILED";
1002
- readonly JOBS_QUEUE_CLEAN_FAILED: "JOBS_QUEUE_CLEAN_FAILED";
1003
- readonly JOBS_QUEUE_OBLITERATE_FAILED: "JOBS_QUEUE_OBLITERATE_FAILED";
1004
- readonly JOBS_JOB_NOT_FOUND: "JOBS_JOB_NOT_FOUND";
1005
- readonly JOBS_JOB_ALREADY_EXISTS: "JOBS_JOB_ALREADY_EXISTS";
1006
- readonly JOBS_JOB_NAME_INVALID: "JOBS_JOB_NAME_INVALID";
1007
- readonly JOBS_JOB_HANDLER_REQUIRED: "JOBS_JOB_HANDLER_REQUIRED";
1008
- readonly JOBS_CRON_NOT_FOUND: "JOBS_CRON_NOT_FOUND";
1009
- readonly JOBS_CRON_ALREADY_EXISTS: "JOBS_CRON_ALREADY_EXISTS";
1010
- readonly JOBS_CRON_EXPRESSION_INVALID: "JOBS_CRON_EXPRESSION_INVALID";
1011
- readonly JOBS_CRON_HANDLER_REQUIRED: "JOBS_CRON_HANDLER_REQUIRED";
1012
- readonly JOBS_DISPATCH_FAILED: "JOBS_DISPATCH_FAILED";
1013
- readonly JOBS_SCHEDULE_FAILED: "JOBS_SCHEDULE_FAILED";
1014
- readonly JOBS_INPUT_REQUIRED: "JOBS_INPUT_REQUIRED";
1015
- readonly JOBS_INPUT_VALIDATION_FAILED: "JOBS_INPUT_VALIDATION_FAILED";
1016
- readonly JOBS_SCOPE_REQUIRED: "JOBS_SCOPE_REQUIRED";
1017
- readonly JOBS_SCOPE_ALREADY_DEFINED: "JOBS_SCOPE_ALREADY_DEFINED";
1018
- readonly JOBS_SCOPE_INVALID: "JOBS_SCOPE_INVALID";
1019
- readonly JOBS_ACTOR_ALREADY_DEFINED: "JOBS_ACTOR_ALREADY_DEFINED";
1020
- readonly JOBS_ACTOR_INVALID: "JOBS_ACTOR_INVALID";
1021
- readonly JOBS_GET_FAILED: "JOBS_GET_FAILED";
1022
- readonly JOBS_RETRY_FAILED: "JOBS_RETRY_FAILED";
1023
- readonly JOBS_REMOVE_FAILED: "JOBS_REMOVE_FAILED";
1024
- readonly JOBS_PROMOTE_FAILED: "JOBS_PROMOTE_FAILED";
1025
- readonly JOBS_MOVE_FAILED: "JOBS_MOVE_FAILED";
1026
- readonly JOBS_STATE_FAILED: "JOBS_STATE_FAILED";
1027
- readonly JOBS_PROGRESS_FAILED: "JOBS_PROGRESS_FAILED";
1028
- readonly JOBS_LOGS_FAILED: "JOBS_LOGS_FAILED";
1029
- readonly JOBS_WORKER_CREATE_FAILED: "JOBS_WORKER_CREATE_FAILED";
1030
- readonly JOBS_WORKER_START_FAILED: "JOBS_WORKER_START_FAILED";
1031
- readonly JOBS_WORKER_STOP_FAILED: "JOBS_WORKER_STOP_FAILED";
1032
- readonly JOBS_WORKER_NOT_FOUND: "JOBS_WORKER_NOT_FOUND";
1033
- readonly JOBS_WORKER_ALREADY_RUNNING: "JOBS_WORKER_ALREADY_RUNNING";
1034
- readonly JOBS_SUBSCRIBE_FAILED: "JOBS_SUBSCRIBE_FAILED";
1035
- readonly JOBS_UNSUBSCRIBE_FAILED: "JOBS_UNSUBSCRIBE_FAILED";
1036
- readonly JOBS_EVENT_EMIT_FAILED: "JOBS_EVENT_EMIT_FAILED";
1037
- readonly JOBS_SEARCH_FAILED: "JOBS_SEARCH_FAILED";
1038
- readonly JOBS_SEARCH_INVALID_TARGET: "JOBS_SEARCH_INVALID_TARGET";
1039
- readonly JOBS_SHUTDOWN_FAILED: "JOBS_SHUTDOWN_FAILED";
1040
- readonly JOBS_HANDLER_FAILED: "JOBS_HANDLER_FAILED";
1041
- readonly JOBS_HANDLER_TIMEOUT: "JOBS_HANDLER_TIMEOUT";
515
+ declare const IgniterJobsTelemetryEvents: {
516
+ readonly namespace: "igniter.jobs";
517
+ readonly events: {
518
+ readonly job: {
519
+ readonly enqueued: {
520
+ "ctx.job.id": string;
521
+ "ctx.job.name": string;
522
+ "ctx.job.queue": string;
523
+ "ctx.job.priority"?: number;
524
+ "ctx.job.delay"?: number;
525
+ };
526
+ readonly started: {
527
+ "ctx.job.id": string;
528
+ "ctx.job.name": string;
529
+ "ctx.job.queue": string;
530
+ "ctx.job.attempt": number;
531
+ "ctx.job.maxAttempts": number;
532
+ };
533
+ readonly completed: {
534
+ "ctx.job.id": string;
535
+ "ctx.job.name": string;
536
+ "ctx.job.queue": string;
537
+ "ctx.job.duration": number;
538
+ };
539
+ readonly failed: {
540
+ "ctx.job.id": string;
541
+ "ctx.job.name": string;
542
+ "ctx.job.queue": string;
543
+ "ctx.job.error.message": string;
544
+ "ctx.job.error.code"?: string;
545
+ "ctx.job.attempt": number;
546
+ "ctx.job.maxAttempts": number;
547
+ "ctx.job.isFinalAttempt": boolean;
548
+ };
549
+ readonly progress: {
550
+ "ctx.job.id": string;
551
+ "ctx.job.name": string;
552
+ "ctx.job.queue": string;
553
+ "ctx.job.progress": number;
554
+ "ctx.job.progress.message"?: string;
555
+ };
556
+ readonly retrying: {
557
+ "ctx.job.id": string;
558
+ "ctx.job.name": string;
559
+ "ctx.job.queue": string;
560
+ "ctx.job.attempt": number;
561
+ "ctx.job.maxAttempts": number;
562
+ "ctx.job.nextRetryDelay": number;
563
+ };
564
+ readonly scheduled: {
565
+ "ctx.job.id": string;
566
+ "ctx.job.name": string;
567
+ "ctx.job.queue": string;
568
+ "ctx.job.scheduledAt"?: string;
569
+ "ctx.job.cron"?: string;
570
+ };
571
+ };
572
+ readonly worker: {
573
+ readonly started: {
574
+ "ctx.worker.id": string;
575
+ "ctx.worker.queues": string;
576
+ "ctx.worker.concurrency": number;
577
+ };
578
+ readonly stopped: {
579
+ "ctx.worker.id": string;
580
+ "ctx.worker.processed": number;
581
+ "ctx.worker.failed": number;
582
+ "ctx.worker.uptime": number;
583
+ };
584
+ readonly idle: {
585
+ "ctx.worker.id": string;
586
+ "ctx.worker.queues": string;
587
+ };
588
+ readonly paused: {
589
+ "ctx.worker.id": string;
590
+ "ctx.worker.queues": string;
591
+ };
592
+ readonly resumed: {
593
+ "ctx.worker.id": string;
594
+ "ctx.worker.queues": string;
595
+ };
596
+ };
597
+ readonly queue: {
598
+ readonly paused: {
599
+ "ctx.queue.name": string;
600
+ };
601
+ readonly resumed: {
602
+ "ctx.queue.name": string;
603
+ };
604
+ readonly drained: {
605
+ "ctx.queue.name": string;
606
+ "ctx.queue.drained.count": number;
607
+ };
608
+ readonly cleaned: {
609
+ "ctx.queue.name": string;
610
+ "ctx.queue.cleaned.count": number;
611
+ "ctx.queue.cleaned.status": string;
612
+ };
613
+ readonly obliterated: {
614
+ "ctx.queue.name": string;
615
+ "ctx.queue.obliterated.force": boolean;
616
+ };
617
+ };
618
+ };
1042
619
  };
1043
620
  /**
1044
- * Type for all possible error codes.
1045
- */
1046
- type IgniterJobsErrorCode = keyof typeof IGNITER_JOBS_ERROR_CODES;
1047
- /**
1048
- * Options for creating an IgniterJobsError.
1049
- */
1050
- interface IgniterJobsErrorOptions {
1051
- /**
1052
- * Error code from IGNITER_JOBS_ERROR_CODES.
1053
- */
1054
- code: IgniterJobsErrorCode;
1055
- /**
1056
- * Human-readable error message.
1057
- */
1058
- message: string;
1059
- /**
1060
- * HTTP status code (for REST API responses).
1061
- * @default 500
1062
- */
1063
- statusCode?: number;
1064
- /**
1065
- * Original error that caused this error.
1066
- */
1067
- cause?: Error;
1068
- /**
1069
- * Additional details for debugging.
1070
- */
1071
- details?: Record<string, unknown>;
1072
- /**
1073
- * Logger instance for logging the error.
1074
- */
1075
- logger?: IgniterLogger;
1076
- }
1077
- /**
1078
- * Custom error class for @igniter-js/jobs.
1079
- * Extends IgniterError for consistent error handling across the Igniter ecosystem.
621
+ * Union type of all job telemetry event names.
1080
622
  *
1081
623
  * @example
1082
624
  * ```typescript
1083
- * throw new IgniterJobsError({
1084
- * code: 'JOBS_DISPATCH_FAILED',
1085
- * message: 'Failed to dispatch job to queue',
1086
- * statusCode: 500,
1087
- * details: { queue: 'email', job: 'sendWelcome' },
1088
- * })
625
+ * import type { IgniterJobsTelemetryEventNames } from '@igniter-js/jobs'
626
+ *
627
+ * function handleEvent(name: IgniterJobsTelemetryEventNames) {
628
+ * // name is type-safe
629
+ * }
1089
630
  * ```
1090
631
  */
1091
- declare class IgniterJobsError extends IgniterError {
1092
- /**
1093
- * Error code for programmatic handling.
1094
- */
1095
- readonly code: IgniterJobsErrorCode;
1096
- /**
1097
- * Additional error details.
1098
- */
1099
- readonly details?: Record<string, unknown>;
1100
- constructor(options: IgniterJobsErrorOptions);
1101
- /**
1102
- * Convert error to a plain object for serialization.
1103
- */
1104
- toJSON(): Record<string, unknown>;
1105
- }
632
+ type IgniterJobsTelemetryEventNames = "igniter.jobs.job.enqueued" | "igniter.jobs.job.started" | "igniter.jobs.job.completed" | "igniter.jobs.job.failed" | "igniter.jobs.job.progress" | "igniter.jobs.job.retrying" | "igniter.jobs.job.scheduled" | "igniter.jobs.worker.started" | "igniter.jobs.worker.stopped" | "igniter.jobs.worker.idle" | "igniter.jobs.worker.paused" | "igniter.jobs.worker.resumed" | "igniter.jobs.queue.paused" | "igniter.jobs.queue.resumed" | "igniter.jobs.queue.drained" | "igniter.jobs.queue.cleaned" | "igniter.jobs.queue.obliterated";
1106
633
 
1107
- export { AdapterJobHandler, IGNITER_JOBS_ERROR_CODES, IgniterCronDefinition, IgniterJobActorOptions, IgniterJobDefinition, IgniterJobScopeOptions, IgniterJobs, IgniterJobsAdapter, IgniterJobsBuilder, type IgniterJobsBuilderState, type IgniterJobsConfig, IgniterJobsError, type IgniterJobsErrorCode, IgniterJobsRuntime, IgniterQueue, IgniterQueueBuilder, type IgniterQueueBuilderState, IgniterQueueConfig, IgniterWorkerBuilder, type IgniterWorkerBuilderState, type IgniterWorkerHandle, type IgniterWorkerMetrics };
634
+ export { IGNITER_JOBS_ERROR_CODES, IgniterCronDefinition, IgniterJobDefinition, IgniterJobSearchResult, IgniterJobStatus, IgniterJobs, IgniterJobsAdapter, type IgniterJobsBaseRuntime, IgniterJobsBuilder, type IgniterJobsBuilderState, type IgniterJobsConfig, IgniterJobsDispatchParams, IgniterJobsError, type IgniterJobsErrorCode, type IgniterJobsErrorOptions, IgniterJobsEventHandler, type IgniterJobsInferCronResult, type IgniterJobsInferInput, type IgniterJobsInferJobInput, IgniterJobsInferSchemaInput, type IgniterJobsJobAccessor, type IgniterJobsJobInstanceAccessor, type IgniterJobsJobManyAccessor, IgniterJobsLimiter, IgniterJobsQueue, type IgniterJobsQueueAccessor, IgniterJobsQueueCleanOptions, IgniterJobsQueueInfo, type IgniterJobsQueueManagerAccessor, type IgniterJobsRuntime, IgniterJobsScheduleParams, IgniterJobsSchema, IgniterJobsScopeDefinition, IgniterJobsScopeOptions, IgniterJobsTelemetry, type IgniterJobsTelemetryEventNames, IgniterJobsTelemetryEvents, type IgniterJobsWorkerBuilderAccessor, IgniterJobsWorkerBuilderConfig, type IgniterJobsWorkerFluentBuilder, IgniterJobsWorkerHandle, IgniterJobsWorkerHandlers, IgniterQueue, IgniterQueueBuilder, IgniterWorkerBuilder };