@igniter-js/jobs 0.1.1 → 0.1.12
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/AGENTS.md +1118 -96
- package/CHANGELOG.md +8 -0
- package/README.md +2146 -93
- package/dist/{adapter-PiDCQWQd.d.mts → adapter-CXZxomI9.d.mts} +2 -2
- package/dist/{adapter-PiDCQWQd.d.ts → adapter-CXZxomI9.d.ts} +2 -2
- package/dist/adapters/bullmq.adapter.d.mts +2 -2
- package/dist/adapters/bullmq.adapter.d.ts +2 -2
- package/dist/adapters/bullmq.adapter.js +2 -2
- package/dist/adapters/bullmq.adapter.js.map +1 -1
- package/dist/adapters/bullmq.adapter.mjs +1 -1
- package/dist/adapters/bullmq.adapter.mjs.map +1 -1
- package/dist/adapters/index.d.mts +140 -2
- package/dist/adapters/index.d.ts +140 -2
- package/dist/adapters/index.js +864 -31
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +863 -31
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/adapters/memory.adapter.d.mts +2 -2
- package/dist/adapters/memory.adapter.d.ts +2 -2
- package/dist/adapters/memory.adapter.js +122 -30
- package/dist/adapters/memory.adapter.js.map +1 -1
- package/dist/adapters/memory.adapter.mjs +121 -29
- package/dist/adapters/memory.adapter.mjs.map +1 -1
- package/dist/index.d.mts +452 -342
- package/dist/index.d.ts +452 -342
- package/dist/index.js +1923 -1002
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1921 -1001
- package/dist/index.mjs.map +1 -1
- package/dist/shim.d.mts +36 -0
- package/dist/shim.d.ts +36 -0
- package/dist/shim.js +75 -0
- package/dist/shim.js.map +1 -0
- package/dist/shim.mjs +67 -0
- package/dist/shim.mjs.map +1 -0
- package/dist/telemetry/index.d.mts +281 -0
- package/dist/telemetry/index.d.ts +281 -0
- package/dist/telemetry/index.js +97 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/index.mjs +95 -0
- package/dist/telemetry/index.mjs.map +1 -0
- package/package.json +44 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { IgniterLogger, IgniterError } from '@igniter-js/common';
|
|
2
|
+
import { p as IgniterJobsQueue, I as IgniterJobsAdapter, q as IgniterJobsScopeDefinition, c as IgniterJobDefinition, m as IgniterJobsWorkerBuilderConfig, r as IgniterJobsTelemetry, n as IgniterJobsEventHandler, g as IgniterJobSearchResult, j as IgniterJobsQueueInfo, l as IgniterJobsWorkerHandle, s as IgniterJobsLimiter, t as IgniterJobsWorkerHandlers, k as IgniterJobsQueueCleanOptions, h as IgniterJobStatus, u as IgniterJobsDispatchParams, v as IgniterJobsScheduleParams, w as IgniterJobsInferSchemaInput, d as IgniterCronDefinition, x as IgniterJobsScopeEntry, y as IgniterJobsSchema, z as IgniterJobsScopeOptions } from './adapter-CXZxomI9.js';
|
|
3
|
+
export { o as IgniterJobCounts, e as IgniterJobsAdapterDispatchParams, f as IgniterJobsAdapterScheduleParams, b as IgniterJobsBullMQAdapterOptions, A as IgniterJobsEvent, B as IgniterJobsExecutionContext, C as IgniterJobsFailureHook, D as IgniterJobsHookContext, E as IgniterJobsInferSchemaOutput, F as IgniterJobsInvokeOptions, i as IgniterJobsJobLog, G as IgniterJobsProgressHook, a as IgniterJobsQueueManager, H as IgniterJobsScheduleOptions, J as IgniterJobsStartHook, K as IgniterJobsSuccessHook, L as IgniterJobsWorkerMetrics } from './adapter-CXZxomI9.js';
|
|
4
4
|
export { IgniterJobsBullMQAdapter } from './adapters/bullmq.adapter.js';
|
|
5
5
|
export { IgniterJobsMemoryAdapter } from './adapters/memory.adapter.js';
|
|
6
|
+
export { IgniterJobsSQLiteAdapter, IgniterJobsSQLiteAdapterOptions } from './adapters/index.js';
|
|
6
7
|
import 'ioredis';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -134,144 +135,278 @@ type IgniterJobsRuntime<TConfig extends IgniterJobsConfig<any, any, any> = Ignit
|
|
|
134
135
|
};
|
|
135
136
|
|
|
136
137
|
/**
|
|
137
|
-
*
|
|
138
|
+
* @fileoverview Worker builder for @igniter-js/jobs
|
|
139
|
+
* @module @igniter-js/jobs/builders/igniter-worker
|
|
138
140
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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";
|
|
141
|
+
|
|
142
|
+
type IgniterJobsWorkerBuilderState<TAllowedQueues extends string> = {
|
|
143
|
+
queues: TAllowedQueues[];
|
|
144
|
+
concurrency?: number;
|
|
145
|
+
limiter?: IgniterJobsLimiter;
|
|
146
|
+
handlers: IgniterJobsWorkerHandlers;
|
|
164
147
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Fluent builder for creating workers tied to registered queues.
|
|
150
|
+
*
|
|
151
|
+
* Instances of this builder are created by `jobs.worker.create()` so it can be
|
|
152
|
+
* automatically scoped to registered queue names.
|
|
153
|
+
*/
|
|
154
|
+
declare class IgniterWorkerBuilder<TAllowedQueues extends string> {
|
|
155
|
+
private readonly adapter;
|
|
156
|
+
private readonly allowedQueues;
|
|
157
|
+
private readonly state;
|
|
158
|
+
constructor(params: {
|
|
159
|
+
adapter: IgniterJobsAdapter;
|
|
160
|
+
allowedQueues: readonly TAllowedQueues[];
|
|
161
|
+
state?: Partial<IgniterJobsWorkerBuilderState<TAllowedQueues>>;
|
|
162
|
+
});
|
|
163
|
+
private clone;
|
|
164
|
+
/**
|
|
165
|
+
* Adds a queue to the worker.
|
|
166
|
+
*
|
|
167
|
+
* @param queue - Queue name registered on the jobs instance.
|
|
168
|
+
*/
|
|
169
|
+
addQueue(queue: TAllowedQueues): IgniterWorkerBuilder<TAllowedQueues>;
|
|
170
|
+
/**
|
|
171
|
+
* Sets the worker concurrency.
|
|
172
|
+
*/
|
|
173
|
+
withConcurrency(concurrency: number): IgniterWorkerBuilder<TAllowedQueues>;
|
|
174
|
+
/**
|
|
175
|
+
* Sets a worker-level rate limiter.
|
|
176
|
+
*/
|
|
177
|
+
withLimiter(limiter: IgniterJobsLimiter): IgniterWorkerBuilder<TAllowedQueues>;
|
|
178
|
+
onActive(handler: NonNullable<IgniterJobsWorkerHandlers['onActive']>): IgniterWorkerBuilder<TAllowedQueues>;
|
|
179
|
+
onSuccess(handler: NonNullable<IgniterJobsWorkerHandlers['onSuccess']>): IgniterWorkerBuilder<TAllowedQueues>;
|
|
180
|
+
onFailure(handler: NonNullable<IgniterJobsWorkerHandlers['onFailure']>): IgniterWorkerBuilder<TAllowedQueues>;
|
|
181
|
+
onIdle(handler: NonNullable<IgniterJobsWorkerHandlers['onIdle']>): IgniterWorkerBuilder<TAllowedQueues>;
|
|
182
|
+
/**
|
|
183
|
+
* Builds and starts the worker.
|
|
184
|
+
*
|
|
185
|
+
* If no queues are added explicitly, the adapter should interpret it as "all queues".
|
|
186
|
+
*/
|
|
187
|
+
start(): Promise<IgniterJobsWorkerHandle>;
|
|
183
188
|
}
|
|
189
|
+
|
|
184
190
|
/**
|
|
185
|
-
*
|
|
191
|
+
* @fileoverview Core IgniterJobsManager class with all job operations
|
|
192
|
+
* @module @igniter-js/jobs/core
|
|
193
|
+
*
|
|
194
|
+
* @description
|
|
195
|
+
* The main IgniterJobsManager class provides a type-safe, scoped API for background job processing.
|
|
196
|
+
* It supports job dispatching, scheduling, worker management, queue operations, and scoped instances
|
|
197
|
+
* for multi-tenant applications.
|
|
186
198
|
*
|
|
187
199
|
* @example
|
|
188
200
|
* ```typescript
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
201
|
+
* import { IgniterJobs, IgniterJobsMemoryAdapter } from '@igniter-js/jobs'
|
|
202
|
+
* import { z } from 'zod'
|
|
203
|
+
*
|
|
204
|
+
* const emailQueue = IgniterQueue.create('email')
|
|
205
|
+
* .addJob('sendWelcome', {
|
|
206
|
+
* input: z.object({ to: z.string(), name: z.string() }),
|
|
207
|
+
* handler: async (ctx) => {
|
|
208
|
+
* await sendEmail(ctx.input.to, `Welcome ${ctx.input.name}!`)
|
|
209
|
+
* },
|
|
210
|
+
* })
|
|
211
|
+
* .build()
|
|
212
|
+
*
|
|
213
|
+
* const jobs = IgniterJobs.create()
|
|
214
|
+
* .withAdapter(IgniterJobsMemoryAdapter.create())
|
|
215
|
+
* .withService('my-api')
|
|
216
|
+
* .withEnvironment('production')
|
|
217
|
+
* .withContext(async () => ({ db }))
|
|
218
|
+
* .addQueue(emailQueue)
|
|
219
|
+
* .build()
|
|
220
|
+
*
|
|
221
|
+
* // Dispatch a job
|
|
222
|
+
* await jobs.email.sendWelcome.dispatch({ input: { to: 'user@example.com', name: 'Alice' } })
|
|
223
|
+
*
|
|
224
|
+
* // Scoped operations
|
|
225
|
+
* const orgJobs = jobs.scope('organization', 'org_123')
|
|
226
|
+
* await orgJobs.email.sendWelcome.dispatch({ input: { to: 'user@example.com', name: 'Bob' } })
|
|
193
227
|
* ```
|
|
194
228
|
*/
|
|
195
|
-
declare class IgniterJobsError extends IgniterError {
|
|
196
|
-
constructor(options: IgniterJobsErrorOptions);
|
|
197
|
-
}
|
|
198
229
|
|
|
199
230
|
/**
|
|
200
|
-
*
|
|
231
|
+
* Main IgniterJobsManager class providing background job processing operations.
|
|
201
232
|
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
233
|
+
* Features:
|
|
234
|
+
* - **Job Dispatching**: Enqueue jobs for immediate or delayed processing
|
|
235
|
+
* - **Job Scheduling**: Schedule jobs with cron expressions or specific times
|
|
236
|
+
* - **Worker Management**: Create and manage workers with configurable concurrency
|
|
237
|
+
* - **Queue Operations**: Pause, resume, drain, clean queues
|
|
238
|
+
* - **Scopes**: Multi-tenant isolation with scoped job instances
|
|
239
|
+
* - **Telemetry**: Built-in observability with typed telemetry events
|
|
240
|
+
*
|
|
241
|
+
* @typeParam TConfig - The jobs configuration type
|
|
205
242
|
*/
|
|
206
|
-
declare class
|
|
207
|
-
|
|
208
|
-
private
|
|
243
|
+
declare class IgniterJobsManager<TConfig extends IgniterJobsConfig<any, any, any> = IgniterJobsConfig<any, any, any>> {
|
|
244
|
+
/** @internal */
|
|
245
|
+
private readonly config;
|
|
246
|
+
/** @internal */
|
|
247
|
+
private readonly adapter;
|
|
248
|
+
/** @internal */
|
|
249
|
+
private readonly telemetry?;
|
|
250
|
+
/** @internal */
|
|
251
|
+
private readonly scopeEntry?;
|
|
209
252
|
/**
|
|
210
|
-
*
|
|
253
|
+
* @internal
|
|
254
|
+
* Constructor is internal. Use `IgniterJobs.create()` instead.
|
|
211
255
|
*/
|
|
212
|
-
|
|
256
|
+
constructor(config: TConfig, scopeEntry?: IgniterJobsScopeEntry);
|
|
213
257
|
/**
|
|
214
|
-
*
|
|
258
|
+
* Creates a scoped jobs instance.
|
|
259
|
+
*
|
|
260
|
+
* Scopes provide multi-tenant isolation by adding scope metadata to all jobs.
|
|
261
|
+
* Jobs dispatched from a scoped instance will include scope information in their metadata.
|
|
262
|
+
*
|
|
263
|
+
* @param type - The scope type (e.g., 'organization', 'workspace')
|
|
264
|
+
* @param id - The scope identifier (e.g., 'org_123')
|
|
265
|
+
* @param tags - Optional additional tags for the scope
|
|
266
|
+
* @returns A new scoped IgniterJobsManager instance
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* const orgJobs = jobs.scope('organization', 'org_123')
|
|
271
|
+
* await orgJobs.email.sendWelcome.dispatch({ input: { to: 'user@example.com' } })
|
|
272
|
+
* ```
|
|
215
273
|
*/
|
|
216
|
-
|
|
274
|
+
scope(type: string, id: string | number, tags?: Record<string, unknown>): IgniterJobsManager<TConfig>;
|
|
217
275
|
/**
|
|
218
|
-
*
|
|
276
|
+
* Subscribes to all job events from this jobs instance.
|
|
219
277
|
*
|
|
220
|
-
* @param
|
|
278
|
+
* @param handler - The event handler function
|
|
279
|
+
* @returns A function to unsubscribe
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```typescript
|
|
283
|
+
* const unsubscribe = await jobs.subscribe((event) => {
|
|
284
|
+
* console.log('Job event:', event.type, event.data)
|
|
285
|
+
* })
|
|
286
|
+
* // Later: await unsubscribe()
|
|
287
|
+
* ```
|
|
221
288
|
*/
|
|
222
|
-
|
|
289
|
+
subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
|
|
223
290
|
/**
|
|
224
|
-
*
|
|
291
|
+
* Searches for jobs, queues, or workers based on filters.
|
|
225
292
|
*
|
|
226
|
-
* @param
|
|
293
|
+
* @param target - The target to search ('jobs', 'queues', or 'workers')
|
|
294
|
+
* @param filter - The filter criteria
|
|
295
|
+
* @returns The search results
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const failedJobs = await jobs.search('jobs', { status: 'failed', queue: 'email' })
|
|
300
|
+
* const queues = await jobs.search('queues', {})
|
|
301
|
+
* ```
|
|
227
302
|
*/
|
|
228
|
-
|
|
303
|
+
search(target: "jobs" | "queues" | "workers", filter: Record<string, unknown>): Promise<unknown[]>;
|
|
229
304
|
/**
|
|
230
|
-
*
|
|
305
|
+
* Gracefully shuts down the jobs instance.
|
|
306
|
+
*
|
|
307
|
+
* This will close all connections and stop all workers.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* await jobs.shutdown()
|
|
312
|
+
* ```
|
|
231
313
|
*/
|
|
232
|
-
|
|
314
|
+
shutdown(): Promise<void>;
|
|
233
315
|
/**
|
|
234
|
-
*
|
|
316
|
+
* Creates a new worker builder for processing jobs.
|
|
317
|
+
*
|
|
318
|
+
* @returns A new IgniterWorkerBuilder instance
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* const worker = await jobs.worker
|
|
323
|
+
* .create()
|
|
324
|
+
* .addQueue('email')
|
|
325
|
+
* .withConcurrency(5)
|
|
326
|
+
* .start()
|
|
327
|
+
* ```
|
|
235
328
|
*/
|
|
236
|
-
|
|
329
|
+
get worker(): {
|
|
330
|
+
create: () => IgniterWorkerBuilder<string>;
|
|
331
|
+
};
|
|
237
332
|
/**
|
|
238
|
-
*
|
|
333
|
+
* Converts the manager to a runtime proxy with typed queue accessors.
|
|
334
|
+
*
|
|
335
|
+
* @internal
|
|
336
|
+
* @returns The runtime proxy
|
|
239
337
|
*/
|
|
240
|
-
|
|
338
|
+
toRuntime(): IgniterJobsRuntime<TConfig>;
|
|
241
339
|
/**
|
|
242
|
-
*
|
|
340
|
+
* Ensures all jobs and crons are registered with the adapter.
|
|
341
|
+
* Uses a shared WeakSet to prevent duplicate registration across scoped instances.
|
|
342
|
+
* @internal
|
|
243
343
|
*/
|
|
244
|
-
|
|
245
|
-
name: TName;
|
|
246
|
-
}): IgniterJobsBuilder<TContext, TQueues & Record<TName, TQueue>, TScope>;
|
|
344
|
+
private ensureRegistered;
|
|
247
345
|
/**
|
|
248
|
-
*
|
|
346
|
+
* Creates a queue accessor with job accessors and management methods.
|
|
347
|
+
* @internal
|
|
249
348
|
*/
|
|
250
|
-
|
|
349
|
+
private createQueueAccessor;
|
|
251
350
|
/**
|
|
252
|
-
*
|
|
351
|
+
* Creates a job accessor with dispatch, schedule, and management methods.
|
|
352
|
+
* @internal
|
|
253
353
|
*/
|
|
254
|
-
|
|
354
|
+
private createJobAccessor;
|
|
255
355
|
/**
|
|
256
|
-
*
|
|
356
|
+
* Dispatches a job for immediate or delayed processing.
|
|
357
|
+
* @internal
|
|
257
358
|
*/
|
|
258
|
-
|
|
259
|
-
queues: (keyof TQueues)[];
|
|
260
|
-
concurrency?: number;
|
|
261
|
-
limiter?: IgniterJobsLimiter;
|
|
262
|
-
}): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
359
|
+
private dispatchJob;
|
|
263
360
|
/**
|
|
264
|
-
*
|
|
361
|
+
* Schedules a job for future processing.
|
|
362
|
+
* @internal
|
|
265
363
|
*/
|
|
266
|
-
|
|
364
|
+
private scheduleJob;
|
|
267
365
|
/**
|
|
268
|
-
*
|
|
366
|
+
* Wraps a job definition with context building, validation, and telemetry.
|
|
367
|
+
* @internal
|
|
269
368
|
*/
|
|
270
|
-
|
|
369
|
+
private wrapJobDefinition;
|
|
271
370
|
/**
|
|
272
|
-
*
|
|
371
|
+
* Wraps a cron definition with context building and lifecycle events.
|
|
372
|
+
* @internal
|
|
273
373
|
*/
|
|
274
|
-
|
|
374
|
+
private wrapCronDefinition;
|
|
375
|
+
/**
|
|
376
|
+
* Builds the execution context for a job.
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
private buildExecutionContext;
|
|
380
|
+
/**
|
|
381
|
+
* Builds the execution context for a cron job.
|
|
382
|
+
* @internal
|
|
383
|
+
*/
|
|
384
|
+
private buildCronExecutionContext;
|
|
385
|
+
/**
|
|
386
|
+
* Gets a job definition by queue and job name.
|
|
387
|
+
* @internal
|
|
388
|
+
*/
|
|
389
|
+
private getJobDefinition;
|
|
390
|
+
/**
|
|
391
|
+
* Resolves the effective scope for a job operation.
|
|
392
|
+
* @internal
|
|
393
|
+
*/
|
|
394
|
+
private resolveScope;
|
|
395
|
+
/**
|
|
396
|
+
* Builds the events channel string for subscriptions.
|
|
397
|
+
* @internal
|
|
398
|
+
*/
|
|
399
|
+
private buildEventsChannel;
|
|
400
|
+
/**
|
|
401
|
+
* Publishes a job lifecycle event.
|
|
402
|
+
* @internal
|
|
403
|
+
*/
|
|
404
|
+
private publishJobEvent;
|
|
405
|
+
/**
|
|
406
|
+
* Emits a telemetry event if telemetry is configured.
|
|
407
|
+
* @internal
|
|
408
|
+
*/
|
|
409
|
+
private emitTelemetry;
|
|
275
410
|
}
|
|
276
411
|
|
|
277
412
|
/**
|
|
@@ -311,19 +446,6 @@ declare class IgniterQueueBuilder<TContext, TJobs extends Record<string, Igniter
|
|
|
311
446
|
* Creates a new queue builder for the given queue name.
|
|
312
447
|
*/
|
|
313
448
|
static create<const TName extends string>(name: TName): IgniterQueueBuilder<unknown, {}, {}, TName>;
|
|
314
|
-
/**
|
|
315
|
-
* Re-types this builder with the application context type.
|
|
316
|
-
*
|
|
317
|
-
* This is a type-level helper; it does not mutate runtime state.
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* ```typescript
|
|
321
|
-
* const queue = IgniterQueue.create('email')
|
|
322
|
-
* .withContext<AppContext>()
|
|
323
|
-
* .addJob('send', { handler: async ({ context }) => context.mailer.send() })
|
|
324
|
-
* ```
|
|
325
|
-
*/
|
|
326
|
-
withContext<TNewContext>(this: IgniterQueueBuilder<unknown, {}, {}, TName>): IgniterQueueBuilder<TNewContext, {}, {}, TName>;
|
|
327
449
|
private clone;
|
|
328
450
|
/**
|
|
329
451
|
* Registers a job on the queue.
|
|
@@ -347,92 +469,6 @@ declare class IgniterQueueBuilder<TContext, TJobs extends Record<string, Igniter
|
|
|
347
469
|
};
|
|
348
470
|
}
|
|
349
471
|
|
|
350
|
-
/**
|
|
351
|
-
* @fileoverview Worker builder for @igniter-js/jobs
|
|
352
|
-
* @module @igniter-js/jobs/builders/igniter-worker
|
|
353
|
-
*/
|
|
354
|
-
|
|
355
|
-
type IgniterJobsWorkerBuilderState<TAllowedQueues extends string> = {
|
|
356
|
-
queues: TAllowedQueues[];
|
|
357
|
-
concurrency?: number;
|
|
358
|
-
limiter?: IgniterJobsLimiter;
|
|
359
|
-
handlers: IgniterJobsWorkerHandlers;
|
|
360
|
-
};
|
|
361
|
-
/**
|
|
362
|
-
* Fluent builder for creating workers tied to registered queues.
|
|
363
|
-
*
|
|
364
|
-
* Instances of this builder are created by `jobs.worker.create()` so it can be
|
|
365
|
-
* automatically scoped to registered queue names.
|
|
366
|
-
*/
|
|
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;
|
|
377
|
-
/**
|
|
378
|
-
* Adds a queue to the worker.
|
|
379
|
-
*
|
|
380
|
-
* @param queue - Queue name registered on the jobs instance.
|
|
381
|
-
*/
|
|
382
|
-
addQueue(queue: TAllowedQueues): IgniterWorkerBuilder<TAllowedQueues>;
|
|
383
|
-
/**
|
|
384
|
-
* Sets the worker concurrency.
|
|
385
|
-
*/
|
|
386
|
-
withConcurrency(concurrency: number): IgniterWorkerBuilder<TAllowedQueues>;
|
|
387
|
-
/**
|
|
388
|
-
* Sets a worker-level rate limiter.
|
|
389
|
-
*/
|
|
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>;
|
|
395
|
-
/**
|
|
396
|
-
* Builds and starts the worker.
|
|
397
|
-
*
|
|
398
|
-
* If no queues are added explicitly, the adapter should interpret it as "all queues".
|
|
399
|
-
*/
|
|
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 {
|
|
415
|
-
/**
|
|
416
|
-
* Starts the fluent builder API for jobs.
|
|
417
|
-
*
|
|
418
|
-
* @example
|
|
419
|
-
* ```typescript
|
|
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()
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
static create<TContext>(): IgniterJobsBuilder<TContext, {}, never>;
|
|
430
|
-
/**
|
|
431
|
-
* Creates a runtime instance from a validated configuration.
|
|
432
|
-
*/
|
|
433
|
-
static fromConfig<TConfig extends IgniterJobsConfig<any, any, any>>(config: TConfig): IgniterJobsRuntime<TConfig>;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
472
|
/**
|
|
437
473
|
* @fileoverview Public queue entry point for @igniter-js/jobs
|
|
438
474
|
* @module @igniter-js/jobs/core/igniter-queue
|
|
@@ -457,178 +493,252 @@ declare class IgniterQueue {
|
|
|
457
493
|
}
|
|
458
494
|
|
|
459
495
|
/**
|
|
460
|
-
* @fileoverview
|
|
461
|
-
* @module @igniter-js/jobs/
|
|
496
|
+
* @fileoverview Builder for creating IgniterJobs instances
|
|
497
|
+
* @module @igniter-js/jobs/builders/main
|
|
462
498
|
*
|
|
463
499
|
* @description
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
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)
|
|
500
|
+
* Provides a fluent builder API for configuring and creating IgniterJobs instances.
|
|
501
|
+
* Supports adapter configuration, service naming, environment settings, queues,
|
|
502
|
+
* scopes, telemetry, and more.
|
|
474
503
|
*
|
|
475
504
|
* @example
|
|
476
505
|
* ```typescript
|
|
477
|
-
* import {
|
|
478
|
-
* import {
|
|
506
|
+
* import { IgniterJobs, IgniterQueue } from '@igniter-js/jobs'
|
|
507
|
+
* import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters'
|
|
508
|
+
* import { z } from 'zod'
|
|
509
|
+
*
|
|
510
|
+
* const emailQueue = IgniterQueue.create('email')
|
|
511
|
+
* .addJob('sendWelcome', {
|
|
512
|
+
* input: z.object({ to: z.string(), name: z.string() }),
|
|
513
|
+
* handler: async (ctx) => {
|
|
514
|
+
* await sendEmail(ctx.input.to, `Welcome ${ctx.input.name}!`)
|
|
515
|
+
* },
|
|
516
|
+
* })
|
|
517
|
+
* .build()
|
|
479
518
|
*
|
|
480
|
-
* const
|
|
519
|
+
* const jobs = IgniterJobs.create()
|
|
520
|
+
* .withAdapter(IgniterJobsMemoryAdapter.create())
|
|
481
521
|
* .withService('my-api')
|
|
482
|
-
* .
|
|
522
|
+
* .withEnvironment('production')
|
|
523
|
+
* .withContext(async () => ({ db }))
|
|
524
|
+
* .addQueue(emailQueue)
|
|
483
525
|
* .build()
|
|
484
526
|
* ```
|
|
485
527
|
*/
|
|
528
|
+
|
|
486
529
|
/**
|
|
487
|
-
*
|
|
530
|
+
* Fluent builder responsible for configuring and constructing an `IgniterJobs` instance.
|
|
488
531
|
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
532
|
+
* The builder follows the immutable pattern used across Igniter packages: each
|
|
533
|
+
* method returns a new builder with refined types. Only a single scope is
|
|
534
|
+
* supported per the current specification (no actor support).
|
|
535
|
+
*/
|
|
536
|
+
declare class IgniterJobsBuilder<TContext, TQueues extends Record<string, IgniterJobsQueue<TContext, any, any>> = {}, TScope extends string = never> {
|
|
537
|
+
private readonly state;
|
|
538
|
+
private constructor();
|
|
539
|
+
/**
|
|
540
|
+
* Creates the initial builder with no configuration.
|
|
541
|
+
*
|
|
542
|
+
* Context type is inferred from `withContext()` - no explicit generic needed.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* // Context is inferred from the factory return type
|
|
547
|
+
* const jobs = IgniterJobs.create()
|
|
548
|
+
* .withContext(async () => ({ db: prisma, cache: redis }))
|
|
549
|
+
* // TContext is now { db: PrismaClient, cache: Redis }
|
|
550
|
+
* .build()
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
static create(): IgniterJobsBuilder<unknown>;
|
|
554
|
+
/**
|
|
555
|
+
* Returns a new builder with updated state while preserving generics.
|
|
556
|
+
*/
|
|
557
|
+
private clone;
|
|
558
|
+
/**
|
|
559
|
+
* Attaches the jobs adapter.
|
|
560
|
+
*
|
|
561
|
+
* @param adapter - Backend adapter implementation (BullMQ, memory, etc.).
|
|
562
|
+
*/
|
|
563
|
+
withAdapter(adapter: IgniterJobsAdapter): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
564
|
+
/**
|
|
565
|
+
* Sets the service identifier for telemetry and metrics.
|
|
566
|
+
*
|
|
567
|
+
* @param service - Service name (e.g., "my-api").
|
|
568
|
+
*/
|
|
569
|
+
withService(service: string): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
570
|
+
/**
|
|
571
|
+
* Sets the environment name (e.g., development, staging, production).
|
|
572
|
+
*/
|
|
573
|
+
withEnvironment(environment: string): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
574
|
+
/**
|
|
575
|
+
* Provides a context factory used when executing jobs.
|
|
576
|
+
*
|
|
577
|
+
* The context type is inferred from the factory return type, eliminating
|
|
578
|
+
* the need for explicit generics on `IgniterJobs.create()`.
|
|
579
|
+
*
|
|
580
|
+
* **Note:** This must be called before adding any queues, as the context
|
|
581
|
+
* type affects queue type compatibility.
|
|
582
|
+
*
|
|
583
|
+
* @param factory - Function that returns the context (sync or async)
|
|
584
|
+
* @returns A new builder with the inferred context type
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* // Context type is inferred as { db: PrismaClient, cache: Redis }
|
|
589
|
+
* const jobs = IgniterJobs.create()
|
|
590
|
+
* .withContext(async () => ({
|
|
591
|
+
* db: new PrismaClient(),
|
|
592
|
+
* cache: new Redis(),
|
|
593
|
+
* }))
|
|
594
|
+
* .addQueue(emailQueue)
|
|
595
|
+
* .build()
|
|
596
|
+
* ```
|
|
597
|
+
*/
|
|
598
|
+
withContext<TNewContext>(this: IgniterJobsBuilder<unknown, {}, TScope>, factory: () => TNewContext | Promise<TNewContext>): IgniterJobsBuilder<TNewContext, {}, TScope>;
|
|
599
|
+
/**
|
|
600
|
+
* Adds a scope definition (single scope supported).
|
|
601
|
+
*/
|
|
602
|
+
addScope<TNewScope extends string>(name: TNewScope, options?: IgniterJobsScopeOptions): IgniterJobsBuilder<TContext, TQueues, TScope | TNewScope>;
|
|
603
|
+
/**
|
|
604
|
+
* Registers a queue definition on the builder.
|
|
605
|
+
*/
|
|
606
|
+
addQueue<TName extends string, TQueue extends IgniterJobsQueue<TContext, any, any>>(queue: TQueue & {
|
|
607
|
+
name: TName;
|
|
608
|
+
}): IgniterJobsBuilder<TContext, TQueues & Record<TName, TQueue>, TScope>;
|
|
609
|
+
/**
|
|
610
|
+
* Applies default job options to all queues.
|
|
611
|
+
*/
|
|
612
|
+
withQueueDefaults(defaults: Partial<IgniterJobDefinition<TContext, any, any>>): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
613
|
+
/**
|
|
614
|
+
* Applies default worker options.
|
|
615
|
+
*/
|
|
616
|
+
withWorkerDefaults(defaults: Partial<IgniterJobsWorkerBuilderConfig>): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
617
|
+
/**
|
|
618
|
+
* Configures automatic worker startup.
|
|
619
|
+
*/
|
|
620
|
+
withAutoStartWorker(config: {
|
|
621
|
+
queues: (keyof TQueues)[];
|
|
622
|
+
concurrency?: number;
|
|
623
|
+
limiter?: IgniterJobsLimiter;
|
|
624
|
+
}): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
625
|
+
/**
|
|
626
|
+
* Attaches telemetry support.
|
|
627
|
+
*/
|
|
628
|
+
withTelemetry(telemetry: IgniterJobsTelemetry): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
629
|
+
/**
|
|
630
|
+
* Attaches a custom logger.
|
|
631
|
+
*/
|
|
632
|
+
withLogger(logger: IgniterLogger): IgniterJobsBuilder<TContext, TQueues, TScope>;
|
|
633
|
+
/**
|
|
634
|
+
* Finalizes the configuration and returns the runtime instance.
|
|
635
|
+
*/
|
|
636
|
+
build(): IgniterJobsRuntime<IgniterJobsConfig<TContext, TQueues, TScope>>;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Factory for creating and configuring IgniterJobs instances.
|
|
491
640
|
*
|
|
492
|
-
*
|
|
641
|
+
* This is the main entry point for creating a jobs runtime with a fluent builder API.
|
|
642
|
+
* It provides type-safe configuration for adapters, queues, scopes, context, and telemetry.
|
|
493
643
|
*
|
|
494
644
|
* @example
|
|
495
645
|
* ```typescript
|
|
496
|
-
* import {
|
|
497
|
-
* import {
|
|
646
|
+
* import { IgniterJobs, IgniterQueue } from '@igniter-js/jobs'
|
|
647
|
+
* import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters'
|
|
648
|
+
* import { z } from 'zod'
|
|
649
|
+
*
|
|
650
|
+
* const emailQueue = IgniterQueue.create('email')
|
|
651
|
+
* .addJob('sendWelcome', {
|
|
652
|
+
* input: z.object({ to: z.string(), name: z.string() }),
|
|
653
|
+
* handler: async (ctx) => {
|
|
654
|
+
* await sendEmail(ctx.input.to, `Welcome ${ctx.input.name}!`)
|
|
655
|
+
* },
|
|
656
|
+
* })
|
|
657
|
+
* .build()
|
|
498
658
|
*
|
|
499
|
-
* const
|
|
659
|
+
* const jobs = IgniterJobs.create()
|
|
660
|
+
* .withAdapter(IgniterJobsMemoryAdapter.create())
|
|
500
661
|
* .withService('my-api')
|
|
501
|
-
* .
|
|
662
|
+
* .withEnvironment('production')
|
|
663
|
+
* .withContext(async () => ({ db }))
|
|
664
|
+
* .addQueue(emailQueue)
|
|
502
665
|
* .build()
|
|
503
666
|
*
|
|
504
|
-
* //
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
* 'ctx.job.duration': 1500,
|
|
511
|
-
* },
|
|
512
|
-
* })
|
|
667
|
+
* // Dispatch jobs
|
|
668
|
+
* await jobs.email.sendWelcome.dispatch({ input: { to: 'user@example.com', name: 'Alice' } })
|
|
669
|
+
*
|
|
670
|
+
* // Use scopes for multi-tenancy
|
|
671
|
+
* const orgJobs = jobs.scope('organization', 'org_123')
|
|
672
|
+
* await orgJobs.email.sendWelcome.dispatch({ input: { to: 'user@example.com', name: 'Bob' } })
|
|
513
673
|
* ```
|
|
674
|
+
*
|
|
675
|
+
* @see {@link IgniterJobsBuilder} for detailed method documentation
|
|
514
676
|
*/
|
|
515
|
-
declare const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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
|
-
};
|
|
677
|
+
declare const IgniterJobs: {
|
|
678
|
+
create: typeof IgniterJobsBuilder.create;
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Canonical error codes for `@igniter-js/jobs`.
|
|
683
|
+
*/
|
|
684
|
+
declare const IGNITER_JOBS_ERROR_CODES: {
|
|
685
|
+
readonly JOBS_ADAPTER_REQUIRED: "JOBS_ADAPTER_REQUIRED";
|
|
686
|
+
readonly JOBS_SERVICE_REQUIRED: "JOBS_SERVICE_REQUIRED";
|
|
687
|
+
readonly JOBS_CONTEXT_REQUIRED: "JOBS_CONTEXT_REQUIRED";
|
|
688
|
+
readonly JOBS_CONFIGURATION_INVALID: "JOBS_CONFIGURATION_INVALID";
|
|
689
|
+
readonly JOBS_QUEUE_NOT_FOUND: "JOBS_QUEUE_NOT_FOUND";
|
|
690
|
+
readonly JOBS_QUEUE_DUPLICATE: "JOBS_QUEUE_DUPLICATE";
|
|
691
|
+
readonly JOBS_QUEUE_OPERATION_FAILED: "JOBS_QUEUE_OPERATION_FAILED";
|
|
692
|
+
readonly JOBS_INVALID_DEFINITION: "JOBS_INVALID_DEFINITION";
|
|
693
|
+
readonly JOBS_HANDLER_REQUIRED: "JOBS_HANDLER_REQUIRED";
|
|
694
|
+
readonly JOBS_DUPLICATE_JOB: "JOBS_DUPLICATE_JOB";
|
|
695
|
+
readonly JOBS_NOT_FOUND: "JOBS_NOT_FOUND";
|
|
696
|
+
readonly JOBS_NOT_REGISTERED: "JOBS_NOT_REGISTERED";
|
|
697
|
+
readonly JOBS_EXECUTION_FAILED: "JOBS_EXECUTION_FAILED";
|
|
698
|
+
readonly JOBS_TIMEOUT: "JOBS_TIMEOUT";
|
|
699
|
+
readonly JOBS_CONTEXT_FACTORY_FAILED: "JOBS_CONTEXT_FACTORY_FAILED";
|
|
700
|
+
readonly JOBS_VALIDATION_FAILED: "JOBS_VALIDATION_FAILED";
|
|
701
|
+
readonly JOBS_INVALID_INPUT: "JOBS_INVALID_INPUT";
|
|
702
|
+
readonly JOBS_INVALID_CRON: "JOBS_INVALID_CRON";
|
|
703
|
+
readonly JOBS_INVALID_SCHEDULE: "JOBS_INVALID_SCHEDULE";
|
|
704
|
+
readonly JOBS_SCOPE_ALREADY_DEFINED: "JOBS_SCOPE_ALREADY_DEFINED";
|
|
705
|
+
readonly JOBS_WORKER_FAILED: "JOBS_WORKER_FAILED";
|
|
706
|
+
readonly JOBS_ADAPTER_ERROR: "JOBS_ADAPTER_ERROR";
|
|
707
|
+
readonly JOBS_ADAPTER_CONNECTION_FAILED: "JOBS_ADAPTER_CONNECTION_FAILED";
|
|
708
|
+
readonly JOBS_SUBSCRIBE_FAILED: "JOBS_SUBSCRIBE_FAILED";
|
|
619
709
|
};
|
|
710
|
+
type IgniterJobsErrorCode = keyof typeof IGNITER_JOBS_ERROR_CODES;
|
|
711
|
+
interface IgniterJobsErrorOptions {
|
|
712
|
+
/** Error code scoped to Igniter Jobs. */
|
|
713
|
+
code: IgniterJobsErrorCode;
|
|
714
|
+
/** Human-readable message. */
|
|
715
|
+
message: string;
|
|
716
|
+
/** HTTP-like status code hint (default: 500). */
|
|
717
|
+
statusCode?: number;
|
|
718
|
+
/** Optional structured details for debugging and clients. */
|
|
719
|
+
details?: unknown;
|
|
720
|
+
/** Optional metadata for logs and tracing. */
|
|
721
|
+
metadata?: Record<string, unknown>;
|
|
722
|
+
/** Optional causer tag used by some Igniter tooling. */
|
|
723
|
+
causer?: string;
|
|
724
|
+
/** Underlying cause for debugging (optional). */
|
|
725
|
+
cause?: Error;
|
|
726
|
+
/** Optional logger passthrough to align with other Igniter errors. */
|
|
727
|
+
logger?: any;
|
|
728
|
+
}
|
|
620
729
|
/**
|
|
621
|
-
*
|
|
730
|
+
* Typed error class for the Jobs package.
|
|
622
731
|
*
|
|
623
732
|
* @example
|
|
624
733
|
* ```typescript
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
* }
|
|
734
|
+
* throw new IgniterJobsError({
|
|
735
|
+
* code: 'JOBS_INVALID_INPUT',
|
|
736
|
+
* message: 'Input payload failed validation',
|
|
737
|
+
* })
|
|
630
738
|
* ```
|
|
631
739
|
*/
|
|
632
|
-
|
|
740
|
+
declare class IgniterJobsError extends IgniterError {
|
|
741
|
+
constructor(options: IgniterJobsErrorOptions);
|
|
742
|
+
}
|
|
633
743
|
|
|
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
|
|
744
|
+
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, IgniterJobsManager, IgniterJobsQueue, type IgniterJobsQueueAccessor, IgniterJobsQueueCleanOptions, IgniterJobsQueueInfo, type IgniterJobsQueueManagerAccessor, type IgniterJobsRuntime, IgniterJobsScheduleParams, IgniterJobsSchema, IgniterJobsScopeDefinition, IgniterJobsScopeEntry, IgniterJobsScopeOptions, IgniterJobsTelemetry, type IgniterJobsWorkerBuilderAccessor, IgniterJobsWorkerBuilderConfig, type IgniterJobsWorkerFluentBuilder, IgniterJobsWorkerHandle, IgniterJobsWorkerHandlers, IgniterQueue, IgniterQueueBuilder, IgniterWorkerBuilder };
|