@igniter-js/jobs 0.1.12 → 0.1.14

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.
Files changed (40) hide show
  1. package/AGENTS.md +117 -243
  2. package/README.md +311 -153
  3. package/dist/{adapter-CXZxomI9.d.mts → adapter-Cax_40HW.d.mts} +27 -6
  4. package/dist/{adapter-CXZxomI9.d.ts → adapter-Cax_40HW.d.ts} +27 -6
  5. package/dist/adapters/bun.d.mts +93 -0
  6. package/dist/adapters/bun.d.ts +93 -0
  7. package/dist/adapters/bun.js +914 -0
  8. package/dist/adapters/bun.js.map +1 -0
  9. package/dist/adapters/bun.mjs +912 -0
  10. package/dist/adapters/bun.mjs.map +1 -0
  11. package/dist/adapters/{memory.adapter.d.ts → mock.d.mts} +1 -3
  12. package/dist/adapters/{memory.adapter.d.mts → mock.d.ts} +1 -3
  13. package/dist/adapters/{memory.adapter.js → mock.js} +58 -25
  14. package/dist/adapters/mock.js.map +1 -0
  15. package/dist/adapters/{memory.adapter.mjs → mock.mjs} +58 -25
  16. package/dist/adapters/mock.mjs.map +1 -0
  17. package/dist/adapters/{bullmq.adapter.d.ts → node.d.mts} +1 -3
  18. package/dist/adapters/{bullmq.adapter.d.mts → node.d.ts} +1 -3
  19. package/dist/adapters/{bullmq.adapter.js → node.js} +117 -40
  20. package/dist/adapters/node.js.map +1 -0
  21. package/dist/adapters/{bullmq.adapter.mjs → node.mjs} +117 -40
  22. package/dist/adapters/node.mjs.map +1 -0
  23. package/dist/index.d.mts +17 -21
  24. package/dist/index.d.ts +17 -21
  25. package/dist/index.js +20 -1854
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +21 -1852
  28. package/dist/index.mjs.map +1 -1
  29. package/package.json +28 -40
  30. package/CHANGELOG.md +0 -13
  31. package/dist/adapters/bullmq.adapter.js.map +0 -1
  32. package/dist/adapters/bullmq.adapter.mjs.map +0 -1
  33. package/dist/adapters/index.d.mts +0 -143
  34. package/dist/adapters/index.d.ts +0 -143
  35. package/dist/adapters/index.js +0 -1891
  36. package/dist/adapters/index.js.map +0 -1
  37. package/dist/adapters/index.mjs +0 -1887
  38. package/dist/adapters/index.mjs.map +0 -1
  39. package/dist/adapters/memory.adapter.js.map +0 -1
  40. package/dist/adapters/memory.adapter.mjs.map +0 -1
@@ -169,37 +169,68 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
169
169
  });
170
170
  }
171
171
  async getJob(jobId, queue) {
172
- const result = await this.core().job.get(jobId, queue ? this.toCoreQueueName(queue) : void 0);
172
+ const result = await this.core().job.get(
173
+ jobId,
174
+ queue ? this.toCoreQueueName(queue) : void 0
175
+ );
173
176
  return result ? this.mapJob(result, queue) : null;
174
177
  }
175
178
  async getJobState(jobId, queue) {
176
- const state = await this.core().job.getState(jobId, queue ? this.toCoreQueueName(queue) : void 0);
179
+ const state = await this.core().job.getState(
180
+ jobId,
181
+ queue ? this.toCoreQueueName(queue) : void 0
182
+ );
177
183
  return state;
178
184
  }
179
185
  async getJobLogs(jobId, queue) {
180
- const logs = await this.core().job.getLogs(jobId, queue ? this.toCoreQueueName(queue) : void 0);
186
+ const logs = await this.core().job.getLogs(
187
+ jobId,
188
+ queue ? this.toCoreQueueName(queue) : void 0
189
+ );
181
190
  return logs;
182
191
  }
183
192
  async getJobProgress(jobId, queue) {
184
- return this.core().job.getProgress(jobId, queue ? this.toCoreQueueName(queue) : void 0);
193
+ return this.core().job.getProgress(
194
+ jobId,
195
+ queue ? this.toCoreQueueName(queue) : void 0
196
+ );
185
197
  }
186
198
  async retryJob(jobId, queue) {
187
- await this.core().job.retry(jobId, queue ? this.toCoreQueueName(queue) : void 0);
199
+ await this.core().job.retry(
200
+ jobId,
201
+ queue ? this.toCoreQueueName(queue) : void 0
202
+ );
188
203
  }
189
204
  async removeJob(jobId, queue) {
190
- await this.core().job.remove(jobId, queue ? this.toCoreQueueName(queue) : void 0);
205
+ await this.core().job.remove(
206
+ jobId,
207
+ queue ? this.toCoreQueueName(queue) : void 0
208
+ );
191
209
  }
192
210
  async promoteJob(jobId, queue) {
193
- await this.core().job.promote(jobId, queue ? this.toCoreQueueName(queue) : void 0);
211
+ await this.core().job.promote(
212
+ jobId,
213
+ queue ? this.toCoreQueueName(queue) : void 0
214
+ );
194
215
  }
195
216
  async moveJobToFailed(jobId, reason, queue) {
196
- await this.core().job.moveToFailed(jobId, reason, queue ? this.toCoreQueueName(queue) : void 0);
217
+ await this.core().job.moveToFailed(
218
+ jobId,
219
+ reason,
220
+ queue ? this.toCoreQueueName(queue) : void 0
221
+ );
197
222
  }
198
223
  async retryManyJobs(jobIds, queue) {
199
- await this.core().job.retryMany(jobIds, queue ? this.toCoreQueueName(queue) : void 0);
224
+ await this.core().job.retryMany(
225
+ jobIds,
226
+ queue ? this.toCoreQueueName(queue) : void 0
227
+ );
200
228
  }
201
229
  async removeManyJobs(jobIds, queue) {
202
- await this.core().job.removeMany(jobIds, queue ? this.toCoreQueueName(queue) : void 0);
230
+ await this.core().job.removeMany(
231
+ jobIds,
232
+ queue ? this.toCoreQueueName(queue) : void 0
233
+ );
203
234
  }
204
235
  async getQueueInfo(queue) {
205
236
  const info = await this.core().queues.get(this.toCoreQueueName(queue));
@@ -207,7 +238,9 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
207
238
  return this.mapQueueInfo(info);
208
239
  }
209
240
  async getQueueJobCounts(queue) {
210
- const counts = await this.core().queues.getJobCounts(this.toCoreQueueName(queue));
241
+ const counts = await this.core().queues.getJobCounts(
242
+ this.toCoreQueueName(queue)
243
+ );
211
244
  return counts;
212
245
  }
213
246
  async listQueues() {
@@ -224,27 +257,23 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
224
257
  return this.core().queues.drain(this.toCoreQueueName(queue));
225
258
  }
226
259
  async cleanQueue(queue, options) {
227
- return this.core().queues.clean(this.toCoreQueueName(queue), options);
260
+ return this.core().queues.clean(
261
+ this.toCoreQueueName(queue),
262
+ options
263
+ );
228
264
  }
229
265
  async obliterateQueue(queue, options) {
230
266
  await this.core().queues.obliterate(this.toCoreQueueName(queue), options);
231
267
  }
232
268
  async retryAllInQueue(queue) {
233
- const jobs = await this.core().queues.getJobs(this.toCoreQueueName(queue), { status: ["failed"], limit: 1e3 });
234
- await Promise.all(jobs.map((j) => this.core().job.retry(j.id, this.toCoreQueueName(queue))));
235
- return jobs.length;
236
- }
237
- async pauseJobType(queue, jobName) {
238
- throw new IgniterJobsError({
239
- code: "JOBS_QUEUE_OPERATION_FAILED",
240
- message: "BullMQ backend does not support pausing a single job type; pause the queue or adjust worker filters."
241
- });
242
- }
243
- async resumeJobType(queue, jobName) {
244
- throw new IgniterJobsError({
245
- code: "JOBS_QUEUE_OPERATION_FAILED",
246
- message: "BullMQ backend does not support resuming a single job type; resume the queue or adjust worker filters."
269
+ const jobs = await this.core().queues.getJobs(this.toCoreQueueName(queue), {
270
+ status: ["failed"],
271
+ limit: 1e3
247
272
  });
273
+ await Promise.all(
274
+ jobs.map((j) => this.core().job.retry(j.id, this.toCoreQueueName(queue)))
275
+ );
276
+ return jobs.length;
248
277
  }
249
278
  async searchJobs(filter) {
250
279
  const queue = filter?.queue;
@@ -252,13 +281,19 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
252
281
  const limit = filter?.limit ?? 100;
253
282
  const offset = filter?.offset ?? 0;
254
283
  if (queue) {
255
- const jobs = await this.core().queues.getJobs(this.toCoreQueueName(queue), { status, limit, offset });
284
+ const jobs = await this.core().queues.getJobs(
285
+ this.toCoreQueueName(queue),
286
+ { status, limit, offset }
287
+ );
256
288
  return jobs.map((j) => this.mapJob(j, queue));
257
289
  }
258
290
  const queues = await this.listQueues();
259
291
  const results = [];
260
292
  for (const q of queues) {
261
- const jobs = await this.core().queues.getJobs(this.toCoreQueueName(q.name), { status, limit, offset });
293
+ const jobs = await this.core().queues.getJobs(
294
+ this.toCoreQueueName(q.name),
295
+ { status, limit, offset }
296
+ );
262
297
  results.push(...jobs.map((j) => this.mapJob(j, q.name)));
263
298
  if (results.length >= limit) break;
264
299
  }
@@ -268,7 +303,9 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
268
303
  const all = await this.listQueues();
269
304
  const name = filter?.name;
270
305
  const isPaused = filter?.isPaused;
271
- return all.filter((q) => name ? q.name.includes(name) : true).filter((q) => typeof isPaused === "boolean" ? q.isPaused === isPaused : true);
306
+ return all.filter((q) => name ? q.name.includes(name) : true).filter(
307
+ (q) => typeof isPaused === "boolean" ? q.isPaused === isPaused : true
308
+ );
272
309
  }
273
310
  async searchWorkers(filter) {
274
311
  const queue = filter?.queue;
@@ -279,11 +316,15 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
279
316
  const coreQueue = this.toCoreQueueName(queue);
280
317
  const queues = w.config?.queues ?? [w.queueName];
281
318
  return Array.isArray(queues) ? queues.includes(coreQueue) : false;
282
- }).filter((w) => typeof isRunning === "boolean" ? isRunning ? w.isRunning() : !w.isRunning() : true).map((w) => this.mapWorker(w));
319
+ }).filter(
320
+ (w) => typeof isRunning === "boolean" ? isRunning ? w.isRunning() : !w.isRunning() : true
321
+ ).map((w) => this.mapWorker(w));
283
322
  }
284
323
  async createWorker(config) {
285
324
  await this.executor();
286
- const queuesSource = config.queues?.length ? config.queues : Array.from(/* @__PURE__ */ new Set([...this.jobsByQueue.keys(), ...this.cronsByQueue.keys()]));
325
+ const queuesSource = config.queues?.length ? config.queues : Array.from(
326
+ /* @__PURE__ */ new Set([...this.jobsByQueue.keys(), ...this.cronsByQueue.keys()])
327
+ );
287
328
  const queues = queuesSource.map((q) => this.toCoreQueueName(q));
288
329
  const coreConfig = {
289
330
  queues,
@@ -299,7 +340,8 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
299
340
  }
300
341
  getWorkers() {
301
342
  const out = /* @__PURE__ */ new Map();
302
- for (const [id, handle] of this.core().getWorkers()) out.set(id, this.mapWorker(handle));
343
+ for (const [id, handle] of this.core().getWorkers())
344
+ out.set(id, this.mapWorker(handle));
303
345
  return out;
304
346
  }
305
347
  async publishEvent(channel, payload) {
@@ -338,7 +380,10 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
338
380
  if (!this.executorDirty && this.coreExecutor) return this.coreExecutor;
339
381
  const routers = {};
340
382
  const flattened = {};
341
- const allQueues = /* @__PURE__ */ new Set([...this.jobsByQueue.keys(), ...this.cronsByQueue.keys()]);
383
+ const allQueues = /* @__PURE__ */ new Set([
384
+ ...this.jobsByQueue.keys(),
385
+ ...this.cronsByQueue.keys()
386
+ ]);
342
387
  for (const queueName of allQueues) {
343
388
  const coreJobs = {};
344
389
  const jobs = this.jobsByQueue.get(queueName);
@@ -346,14 +391,24 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
346
391
  for (const [jobName, def] of jobs.entries()) {
347
392
  const queue = def.queue ? `${queueName}.${def.queue}` : queueName;
348
393
  const fullQueue = IgniterJobsPrefix.buildQueueName(queue);
349
- coreJobs[jobName] = this.toCoreJobDefinition(queueName, jobName, def, fullQueue);
394
+ coreJobs[jobName] = this.toCoreJobDefinition(
395
+ queueName,
396
+ jobName,
397
+ def,
398
+ fullQueue
399
+ );
350
400
  }
351
401
  }
352
402
  const crons = this.cronsByQueue.get(queueName);
353
403
  if (crons) {
354
404
  for (const [cronName, def] of crons.entries()) {
355
405
  const fullQueue = IgniterJobsPrefix.buildQueueName(queueName);
356
- coreJobs[cronName] = this.toCoreCronJobDefinition(queueName, cronName, def, fullQueue);
406
+ coreJobs[cronName] = this.toCoreCronJobDefinition(
407
+ queueName,
408
+ cronName,
409
+ def,
410
+ fullQueue
411
+ );
357
412
  }
358
413
  }
359
414
  if (Object.keys(coreJobs).length === 0) continue;
@@ -395,7 +450,7 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
395
450
  input: job.payload,
396
451
  result: job.result,
397
452
  error: job.error,
398
- progress: 0,
453
+ progress: typeof job.progress === "number" ? job.progress : 0,
399
454
  attemptsMade: job.attemptsMade ?? 0,
400
455
  priority: job.priority ?? 0,
401
456
  createdAt: job.createdAt,
@@ -406,7 +461,9 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
406
461
  };
407
462
  }
408
463
  mapWorker(handle) {
409
- const queues = handle.config?.queues ?? [handle.queueName];
464
+ const queues = handle.config?.queues ?? [
465
+ handle.queueName
466
+ ];
410
467
  return {
411
468
  id: handle.id,
412
469
  queues: queues.map((q) => this.fromCoreQueueName(q)),
@@ -421,6 +478,25 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
421
478
  }
422
479
  toCoreJobDefinition(queueName, jobName, def, fullQueueName) {
423
480
  const handler = async (ctx) => {
481
+ const updateProgress = typeof ctx.job?.updateProgress === "function" ? async (progress, message) => {
482
+ await ctx.job.updateProgress(progress);
483
+ await def.onProgress?.({
484
+ input: ctx.input,
485
+ context: ctx.context,
486
+ job: {
487
+ id: ctx.job.id,
488
+ name: jobName,
489
+ queue: queueName,
490
+ attemptsMade: ctx.job.attemptsMade,
491
+ createdAt: ctx.job.createdAt,
492
+ metadata: ctx.job.metadata,
493
+ updateProgress
494
+ },
495
+ scope: ctx.job.metadata?.__igniter_jobs_scope,
496
+ progress,
497
+ message
498
+ });
499
+ } : void 0;
424
500
  return def.handler({
425
501
  input: ctx.input,
426
502
  context: ctx.context,
@@ -430,7 +506,8 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
430
506
  queue: queueName,
431
507
  attemptsMade: ctx.job.attemptsMade,
432
508
  createdAt: ctx.job.createdAt,
433
- metadata: ctx.job.metadata
509
+ metadata: ctx.job.metadata,
510
+ updateProgress
434
511
  },
435
512
  scope: ctx.job.metadata?.__igniter_jobs_scope
436
513
  });
@@ -494,5 +571,5 @@ var IgniterJobsBullMQAdapter = class _IgniterJobsBullMQAdapter {
494
571
  };
495
572
 
496
573
  export { IgniterJobsBullMQAdapter };
497
- //# sourceMappingURL=bullmq.adapter.mjs.map
498
- //# sourceMappingURL=bullmq.adapter.mjs.map
574
+ //# sourceMappingURL=node.mjs.map
575
+ //# sourceMappingURL=node.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/prefix.ts","../../src/errors/jobs.error.ts","../../src/adapters/bullmq.adapter.ts"],"names":["options"],"mappings":";;;;;;AAGO,IAAM,kBAAA,GAAN,MAAM,kBAAA,CAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAY7B,OAAc,eAAe,KAAA,EAAuB;AAClD,IAAA,OAAO,CAAA,EAAG,kBAAA,CAAkB,WAAW,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAc,mBAAmB,MAAA,EAItB;AACT,IAAA,MAAM,IAAA,GAAO,GAAG,kBAAA,CAAkB,WAAW,WAAW,MAAA,CAAO,WAAW,CAAA,CAAA,EAAI,MAAA,CAAO,OAAO,CAAA,CAAA;AAC5F,IAAA,IAAI,CAAC,MAAA,CAAO,KAAA,EAAO,OAAO,IAAA;AAC1B,IAAA,OAAO,CAAA,EAAG,IAAI,CAAA,OAAA,EAAU,MAAA,CAAO,MAAM,IAAI,CAAA,CAAA,EAAI,MAAA,CAAO,KAAA,CAAM,EAAE,CAAA,CAAA;AAAA,EAC9D;AACF,CAAA;AA/Ba,kBAAA,CACY,WAAA,GAAc,cAAA;AADhC,IAAM,iBAAA,GAAN,kBAAA;AC6DA,IAAM,gBAAA,GAAN,cAA+B,YAAA,CAAa;AAAA,EACjD,YAAY,OAAA,EAAkC;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AAAA,EACf;AACF,CAAA;;;AC7BA,SAAS,YAAY,MAAA,EAAmD;AACtE,EAAA,IAAI,CAAC,QAAQ,OAAO,MAAA;AACpB,EAAA,OAAO,MAAA,CAAO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W,GAAA,CAAI,SAAA;AAAA,QACf,SAAS,GAAA,CAAI;AAAA,OACf;AAAA,MACA,QAAA,EACE,GAAA,CAAI,iBAAA,IACJ,GAAA,CAAI,gBACJ,GAAA,CAAI,aAAA,IACJ,GAAA,CAAI,YAAA,IACJ,GAAA,CAAI,SAAA,IACH,GAAA,CAAI,SAAA,IAAa,IAAI,OAAA,GAClB;AAAA,QACE,kBAAA,EAAoB;AAAA,UAClB,mBAAmB,GAAA,CAAI,iBAAA;AAAA,UACvB,cAAc,GAAA,CAAI,YAAA;AAAA,UAClB,eAAe,GAAA,CAAI,aAAA;AAAA,UACnB,SAAA,EAAW,WAAA,CAAY,GAAA,CAAI,SAAS,CAAA;AAAA,UACpC,cAAc,GAAA,CAAI,YAAA;AAAA,UAClB,OAAA,EACE,GAAA,CAAI,SAAA,IAAa,GAAA,CAAI,OAAA,GACjB,CAAC,GAAA,CAAI,SAAA,EAAW,GAAA,CAAI,OAAO,CAAA,GAC3B;AAAA;AACR,OACF,GACA;AAAA,KACR;AAAA,EACF;AACF","file":"node.mjs","sourcesContent":["/**\n * Helpers for building consistent key/queue prefixes.\n */\nexport class IgniterJobsPrefix {\n public static readonly BASE_PREFIX = 'igniter:jobs'\n\n /**\n * Builds a normalized queue name using the global prefix and queue id.\n *\n * @example\n * ```typescript\n * const name = IgniterJobsPrefix.buildQueueName('email')\n * // -> igniter:jobs:email\n * ```\n */\n public static buildQueueName(queue: string): string {\n return `${IgniterJobsPrefix.BASE_PREFIX}:${queue}`\n }\n\n /**\n * Builds the event channel used for pub/sub.\n *\n * Unscoped events are published to a global channel per service/environment.\n * Scoped events are also published to an additional channel for that scope.\n */\n public static buildEventsChannel(params: {\n service: string\n environment: string\n scope?: { type: string; id: string | number }\n }): string {\n const base = `${IgniterJobsPrefix.BASE_PREFIX}:events:${params.environment}:${params.service}`\n if (!params.scope) return base\n return `${base}:scope:${params.scope.type}:${params.scope.id}`\n }\n}\n","import { IgniterError } from \"@igniter-js/common\";\n\n/**\n * Canonical error codes for `@igniter-js/jobs`.\n */\nexport const IGNITER_JOBS_ERROR_CODES = {\n JOBS_ADAPTER_REQUIRED: 'JOBS_ADAPTER_REQUIRED',\n JOBS_SERVICE_REQUIRED: 'JOBS_SERVICE_REQUIRED',\n JOBS_CONTEXT_REQUIRED: 'JOBS_CONTEXT_REQUIRED',\n JOBS_CONFIGURATION_INVALID: 'JOBS_CONFIGURATION_INVALID',\n JOBS_QUEUE_NOT_FOUND: 'JOBS_QUEUE_NOT_FOUND',\n JOBS_QUEUE_DUPLICATE: 'JOBS_QUEUE_DUPLICATE',\n JOBS_QUEUE_OPERATION_FAILED: 'JOBS_QUEUE_OPERATION_FAILED',\n JOBS_INVALID_DEFINITION: 'JOBS_INVALID_DEFINITION',\n JOBS_HANDLER_REQUIRED: 'JOBS_HANDLER_REQUIRED',\n JOBS_DUPLICATE_JOB: 'JOBS_DUPLICATE_JOB',\n JOBS_NOT_FOUND: 'JOBS_NOT_FOUND',\n JOBS_NOT_REGISTERED: 'JOBS_NOT_REGISTERED',\n JOBS_EXECUTION_FAILED: 'JOBS_EXECUTION_FAILED',\n JOBS_TIMEOUT: 'JOBS_TIMEOUT',\n JOBS_CONTEXT_FACTORY_FAILED: 'JOBS_CONTEXT_FACTORY_FAILED',\n JOBS_VALIDATION_FAILED: 'JOBS_VALIDATION_FAILED',\n JOBS_INVALID_INPUT: 'JOBS_INVALID_INPUT',\n JOBS_INVALID_CRON: 'JOBS_INVALID_CRON',\n JOBS_INVALID_SCHEDULE: 'JOBS_INVALID_SCHEDULE',\n JOBS_SCOPE_ALREADY_DEFINED: 'JOBS_SCOPE_ALREADY_DEFINED',\n JOBS_WORKER_FAILED: 'JOBS_WORKER_FAILED',\n JOBS_ADAPTER_ERROR: 'JOBS_ADAPTER_ERROR',\n JOBS_ADAPTER_CONNECTION_FAILED: 'JOBS_ADAPTER_CONNECTION_FAILED',\n JOBS_SUBSCRIBE_FAILED: 'JOBS_SUBSCRIBE_FAILED',\n} as const\n\nexport type IgniterJobsErrorCode = keyof typeof IGNITER_JOBS_ERROR_CODES\n\nexport interface IgniterJobsErrorOptions {\n /** Error code scoped to Igniter Jobs. */\n code: IgniterJobsErrorCode\n /** Human-readable message. */\n message: string\n /** HTTP-like status code hint (default: 500). */\n statusCode?: number\n /** Optional structured details for debugging and clients. */\n details?: unknown\n /** Optional metadata for logs and tracing. */\n metadata?: Record<string, unknown>\n /** Optional causer tag used by some Igniter tooling. */\n causer?: string\n /** Underlying cause for debugging (optional). */\n cause?: Error\n /** Optional logger passthrough to align with other Igniter errors. */\n logger?: any\n}\n\n/**\n * Typed error class for the Jobs package.\n *\n * @example\n * ```typescript\n * throw new IgniterJobsError({\n * code: 'JOBS_INVALID_INPUT',\n * message: 'Input payload failed validation',\n * })\n * ```\n */\nexport class IgniterJobsError extends IgniterError {\n constructor(options: IgniterJobsErrorOptions) {\n super(options)\n }\n}\n","/**\n * @fileoverview BullMQ adapter for @igniter-js/jobs (wraps @igniter-js/adapter-bullmq)\n * @module @igniter-js/jobs/adapters/bullmq\n */\n\nimport type { Redis } from \"ioredis\";\nimport type {\n AdvancedScheduleOptions,\n IgniterJobQueueAdapter,\n JobsRouter,\n JobDefinition as CoreJobDefinition,\n JobExecutionContext as CoreJobExecutionContext,\n JobWorkerConfig,\n} from \"@igniter-js/core\";\nimport { createBullMQAdapter } from \"@igniter-js/adapter-bullmq\";\nimport type {\n IgniterCronDefinition,\n IgniterJobDefinition,\n IgniterJobSearchResult,\n IgniterJobStatus,\n IgniterJobsAdapter,\n IgniterJobsAdapterDispatchParams,\n IgniterJobsAdapterScheduleParams,\n IgniterJobsBullMQAdapterOptions,\n IgniterJobsEventHandler,\n IgniterJobsJobLog,\n IgniterJobsQueueCleanOptions,\n IgniterJobsQueueInfo,\n IgniterJobsQueueManager,\n IgniterJobsWorkerBuilderConfig,\n IgniterJobsWorkerHandle,\n IgniterJobsWorkerMetrics,\n} from \"../types\";\nimport { IgniterJobsPrefix } from \"../utils/prefix\";\nimport { IgniterJobsError } from \"../errors\";\n\ntype CoreAdapter = IgniterJobQueueAdapter<any>;\ntype CoreMergedExecutor = ReturnType<CoreAdapter[\"merge\"]>;\n\nfunction toDateArray(values?: Array<string | Date>): Date[] | undefined {\n if (!values) return undefined;\n return values.map((v) => (v instanceof Date ? v : new Date(v)));\n}\n\n/**\n * BullMQ adapter facade.\n *\n * It reuses the mature BullMQ integration from `@igniter-js/adapter-bullmq` to keep\n * feature parity (workers, queue/job management, advanced scheduling, hooks).\n */\nexport class IgniterJobsBullMQAdapter implements IgniterJobsAdapter {\n public readonly client: unknown;\n\n private readonly redis: Redis;\n private readonly publisher: Redis;\n private readonly subscriber: Redis;\n private readonly subscribers = new Map<string, Set<(payload: any) => void>>();\n\n private coreAdapter: CoreAdapter | null = null;\n private coreExecutor: CoreMergedExecutor | null = null;\n private executorDirty = true;\n\n private readonly jobsByQueue = new Map<\n string,\n Map<string, IgniterJobDefinition<any, any, any>>\n >();\n private readonly cronsByQueue = new Map<\n string,\n Map<string, IgniterCronDefinition<any, any>>\n >();\n\n public readonly queues: IgniterJobsQueueManager;\n\n private constructor(options: IgniterJobsBullMQAdapterOptions) {\n this.redis = options.redis;\n this.publisher = this.redis;\n this.subscriber = this.redis.duplicate();\n this.client = { redis: this.redis };\n\n this.subscriber.on(\"message\", (channel: string, message: string) => {\n const set = this.subscribers.get(channel);\n if (!set || set.size === 0) return;\n let payload: any = message;\n try {\n payload = JSON.parse(message);\n } catch {\n // ignore, treat as raw\n }\n for (const handler of set) handler(payload);\n });\n\n this.queues = {\n list: async () => this.listQueues(),\n get: async (name) => this.getQueueInfo(name),\n getJobCounts: async (name) => this.getQueueJobCounts(name),\n getJobs: async (name, filter) => {\n const full = this.toCoreQueueName(name);\n return this.core().queues.getJobs(full, filter as any) as any;\n },\n pause: async (name) => this.pauseQueue(name),\n resume: async (name) => this.resumeQueue(name),\n isPaused: async (name) => {\n const full = this.toCoreQueueName(name);\n return this.core().queues.isPaused(full);\n },\n drain: async (name) => this.drainQueue(name),\n clean: async (name, options) => this.cleanQueue(name, options),\n obliterate: async (name, options) => this.obliterateQueue(name, options),\n };\n }\n\n public static create(\n options: IgniterJobsBullMQAdapterOptions,\n ): IgniterJobsAdapter {\n return new IgniterJobsBullMQAdapter(options);\n }\n\n public registerJob(\n queueName: string,\n jobName: string,\n definition: IgniterJobDefinition<any, any, any>,\n ): void {\n const map = this.jobsByQueue.get(queueName) ?? new Map();\n if (map.has(jobName)) {\n throw new IgniterJobsError({\n code: \"JOBS_DUPLICATE_JOB\",\n message: `Job \"${jobName}\" is already registered in queue \"${queueName}\".`,\n });\n }\n map.set(jobName, definition);\n this.jobsByQueue.set(queueName, map);\n this.executorDirty = true;\n }\n\n public registerCron(\n queueName: string,\n cronName: string,\n definition: IgniterCronDefinition<any, any>,\n ): void {\n const map = this.cronsByQueue.get(queueName) ?? new Map();\n if (map.has(cronName)) {\n throw new IgniterJobsError({\n code: \"JOBS_INVALID_CRON\",\n message: `Cron \"${cronName}\" is already registered in queue \"${queueName}\".`,\n });\n }\n map.set(cronName, definition);\n this.cronsByQueue.set(queueName, map);\n this.executorDirty = true;\n }\n\n public async dispatch(\n params: IgniterJobsAdapterDispatchParams,\n ): Promise<string> {\n const executor = await this.executor();\n const namespace = (executor as any)[params.queue];\n if (!namespace) {\n throw new IgniterJobsError({\n code: \"JOBS_QUEUE_NOT_FOUND\",\n message: `Queue \"${params.queue}\" is not registered in the adapter.`,\n });\n }\n return namespace.enqueue({\n task: params.jobName,\n input: params.input,\n jobId: params.jobId,\n delay: params.delay,\n priority: params.priority,\n attempts: params.attempts,\n metadata: params.metadata as any,\n removeOnComplete: params.removeOnComplete as any,\n removeOnFail: params.removeOnFail as any,\n limiter: params.limiter as any,\n });\n }\n\n public async schedule(\n params: IgniterJobsAdapterScheduleParams,\n ): Promise<string> {\n const executor = await this.executor();\n const namespace = (executor as any)[params.queue];\n if (!namespace) {\n throw new IgniterJobsError({\n code: \"JOBS_QUEUE_NOT_FOUND\",\n message: `Queue \"${params.queue}\" is not registered in the adapter.`,\n });\n }\n\n const schedule: AdvancedScheduleOptions = {\n jobId: params.jobId,\n delay: params.delay,\n priority: params.priority,\n attempts: params.attempts,\n metadata: params.metadata as any,\n removeOnComplete: params.removeOnComplete as any,\n removeOnFail: params.removeOnFail as any,\n limiter: params.limiter as any,\n at: params.at,\n repeat:\n params.cron ||\n params.every ||\n params.maxExecutions ||\n params.skipWeekends ||\n params.onlyBusinessHours ||\n params.businessHours ||\n params.onlyWeekdays ||\n params.skipDates\n ? {\n cron: params.cron,\n every: params.every,\n times: params.maxExecutions,\n skipWeekends: params.skipWeekends,\n onlyBusinessHours: params.onlyBusinessHours,\n businessHours: params.businessHours,\n onlyWeekdays: params.onlyWeekdays,\n skipDates: toDateArray(params.skipDates),\n }\n : undefined,\n };\n\n return namespace.schedule({\n task: params.jobName,\n input: params.input,\n ...schedule,\n });\n }\n\n public async getJob(\n jobId: string,\n queue?: string,\n ): Promise<IgniterJobSearchResult | null> {\n const result = await this.core().job.get(\n jobId,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n return result ? this.mapJob(result, queue) : null;\n }\n\n public async getJobState(\n jobId: string,\n queue?: string,\n ): Promise<IgniterJobStatus | null> {\n const state = await this.core().job.getState(\n jobId,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n return state as any;\n }\n\n public async getJobLogs(\n jobId: string,\n queue?: string,\n ): Promise<IgniterJobsJobLog[]> {\n const logs = await this.core().job.getLogs(\n jobId,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n return logs as any;\n }\n\n public async getJobProgress(jobId: string, queue?: string): Promise<number> {\n return this.core().job.getProgress(\n jobId,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n }\n\n public async retryJob(jobId: string, queue?: string): Promise<void> {\n await this.core().job.retry(\n jobId,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n }\n\n public async removeJob(jobId: string, queue?: string): Promise<void> {\n await this.core().job.remove(\n jobId,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n }\n\n public async promoteJob(jobId: string, queue?: string): Promise<void> {\n await this.core().job.promote(\n jobId,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n }\n\n public async moveJobToFailed(\n jobId: string,\n reason: string,\n queue?: string,\n ): Promise<void> {\n await this.core().job.moveToFailed(\n jobId,\n reason,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n }\n\n public async retryManyJobs(jobIds: string[], queue?: string): Promise<void> {\n await this.core().job.retryMany(\n jobIds,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n }\n\n public async removeManyJobs(jobIds: string[], queue?: string): Promise<void> {\n await this.core().job.removeMany(\n jobIds,\n queue ? this.toCoreQueueName(queue) : undefined,\n );\n }\n\n public async getQueueInfo(\n queue: string,\n ): Promise<IgniterJobsQueueInfo | null> {\n const info = await this.core().queues.get(this.toCoreQueueName(queue));\n if (!info) return null;\n return this.mapQueueInfo(info);\n }\n\n public async getQueueJobCounts(queue: string): Promise<any> {\n const counts = await this.core().queues.getJobCounts(\n this.toCoreQueueName(queue),\n );\n return counts as any;\n }\n\n public async listQueues(): Promise<IgniterJobsQueueInfo[]> {\n const list = await this.core().queues.list();\n return list.map((q) => this.mapQueueInfo(q));\n }\n\n public async pauseQueue(queue: string): Promise<void> {\n await this.core().queues.pause(this.toCoreQueueName(queue));\n }\n\n public async resumeQueue(queue: string): Promise<void> {\n await this.core().queues.resume(this.toCoreQueueName(queue));\n }\n\n public async drainQueue(queue: string): Promise<number> {\n return this.core().queues.drain(this.toCoreQueueName(queue));\n }\n\n public async cleanQueue(\n queue: string,\n options: IgniterJobsQueueCleanOptions,\n ): Promise<number> {\n return this.core().queues.clean(\n this.toCoreQueueName(queue),\n options as any,\n );\n }\n\n public async obliterateQueue(\n queue: string,\n options?: { force?: boolean },\n ): Promise<void> {\n await this.core().queues.obliterate(this.toCoreQueueName(queue), options);\n }\n\n public async retryAllInQueue(queue: string): Promise<number> {\n const jobs = await this.core().queues.getJobs(this.toCoreQueueName(queue), {\n status: [\"failed\"],\n limit: 1000,\n } as any);\n await Promise.all(\n jobs.map((j) => this.core().job.retry(j.id, this.toCoreQueueName(queue))),\n );\n return jobs.length;\n }\n\n public async searchJobs(filter: any): Promise<IgniterJobSearchResult[]> {\n // Minimal implementation: list jobs from a specific queue when provided, otherwise aggregate known queues.\n const queue = filter?.queue as string | undefined;\n const status = filter?.status as IgniterJobStatus[] | undefined;\n const limit = filter?.limit ?? 100;\n const offset = filter?.offset ?? 0;\n\n if (queue) {\n const jobs = await this.core().queues.getJobs(\n this.toCoreQueueName(queue),\n { status, limit, offset } as any,\n );\n return jobs.map((j) => this.mapJob(j as any, queue));\n }\n\n const queues = await this.listQueues();\n const results: IgniterJobSearchResult[] = [];\n for (const q of queues) {\n const jobs = await this.core().queues.getJobs(\n this.toCoreQueueName(q.name),\n { status, limit, offset } as any,\n );\n results.push(...jobs.map((j) => this.mapJob(j as any, q.name)));\n if (results.length >= limit) break;\n }\n return results.slice(0, limit);\n }\n\n public async searchQueues(filter: any): Promise<IgniterJobsQueueInfo[]> {\n const all = await this.listQueues();\n const name = filter?.name as string | undefined;\n const isPaused = filter?.isPaused as boolean | undefined;\n return all\n .filter((q) => (name ? q.name.includes(name) : true))\n .filter((q) =>\n typeof isPaused === \"boolean\" ? q.isPaused === isPaused : true,\n );\n }\n\n public async searchWorkers(filter: any): Promise<IgniterJobsWorkerHandle[]> {\n const queue = filter?.queue as string | undefined;\n const isRunning = filter?.isRunning as boolean | undefined;\n\n const all = Array.from(this.core().getWorkers().values());\n return all\n .filter((w) => {\n if (!queue) return true;\n const coreQueue = this.toCoreQueueName(queue);\n const queues = (w as any).config?.queues ?? [(w as any).queueName];\n return Array.isArray(queues) ? queues.includes(coreQueue) : false;\n })\n .filter((w) =>\n typeof isRunning === \"boolean\"\n ? isRunning\n ? w.isRunning()\n : !w.isRunning()\n : true,\n )\n .map((w) => this.mapWorker(w));\n }\n\n public async createWorker(\n config: IgniterJobsWorkerBuilderConfig,\n ): Promise<IgniterJobsWorkerHandle> {\n // Ensure jobs/crons are registered in the underlying BullMQ adapter before starting workers.\n await this.executor();\n\n const queuesSource = config.queues?.length\n ? config.queues\n : Array.from(\n new Set([...this.jobsByQueue.keys(), ...this.cronsByQueue.keys()]),\n );\n const queues = queuesSource.map((q) => this.toCoreQueueName(q));\n const coreConfig: JobWorkerConfig = {\n queues,\n concurrency: config.concurrency ?? 1,\n limiter: config.limiter as any,\n onActive: config.handlers?.onActive as any,\n onSuccess: config.handlers?.onSuccess as any,\n onFailure: config.handlers?.onFailure as any,\n onIdle: config.handlers?.onIdle as any,\n };\n const handle = await (this.core() as any).worker(coreConfig);\n return this.mapWorker(handle);\n }\n\n public getWorkers(): Map<string, IgniterJobsWorkerHandle> {\n const out = new Map<string, IgniterJobsWorkerHandle>();\n for (const [id, handle] of this.core().getWorkers())\n out.set(id, this.mapWorker(handle));\n return out;\n }\n\n public async publishEvent(channel: string, payload: unknown): Promise<void> {\n await this.publisher.publish(channel, JSON.stringify(payload));\n }\n\n public async subscribeEvent(\n channel: string,\n handler: IgniterJobsEventHandler,\n ): Promise<() => Promise<void>> {\n const set =\n this.subscribers.get(channel) ?? new Set<(payload: any) => void>();\n const wrapped = (payload: any) => void handler(payload as any);\n set.add(wrapped);\n this.subscribers.set(channel, set);\n\n if (set.size === 1) {\n await this.subscriber.subscribe(channel);\n }\n\n return async () => {\n const current = this.subscribers.get(channel);\n if (!current) return;\n current.delete(wrapped);\n if (current.size === 0) {\n this.subscribers.delete(channel);\n await this.subscriber.unsubscribe(channel);\n }\n };\n }\n\n public async shutdown(): Promise<void> {\n await this.subscriber.quit();\n // BullMQ adapter does not expose global shutdown on the core adapter in a single method;\n // queue/worker cleanup is handled by worker close and queue obliterate.\n }\n\n private core(): CoreAdapter {\n if (!this.coreAdapter) {\n // We only need the Redis connection. The wrapped job handlers can create real context.\n this.coreAdapter = createBullMQAdapter({\n store: { client: this.redis } as any,\n }) as unknown as CoreAdapter;\n }\n return this.coreAdapter;\n }\n\n private async executor(): Promise<CoreMergedExecutor> {\n if (!this.executorDirty && this.coreExecutor) return this.coreExecutor;\n\n const routers: Record<string, JobsRouter<any>> = {};\n const flattened: Record<string, CoreJobDefinition<any, any, any>> = {};\n\n const allQueues = new Set<string>([\n ...this.jobsByQueue.keys(),\n ...this.cronsByQueue.keys(),\n ]);\n\n for (const queueName of allQueues) {\n const coreJobs: Record<string, CoreJobDefinition<any, any, any>> = {};\n\n const jobs = this.jobsByQueue.get(queueName);\n if (jobs) {\n for (const [jobName, def] of jobs.entries()) {\n const queue = def.queue ? `${queueName}.${def.queue}` : queueName;\n const fullQueue = IgniterJobsPrefix.buildQueueName(queue);\n coreJobs[jobName] = this.toCoreJobDefinition(\n queueName,\n jobName,\n def,\n fullQueue,\n );\n }\n }\n\n const crons = this.cronsByQueue.get(queueName);\n if (crons) {\n for (const [cronName, def] of crons.entries()) {\n const fullQueue = IgniterJobsPrefix.buildQueueName(queueName);\n coreJobs[cronName] = this.toCoreCronJobDefinition(\n queueName,\n cronName,\n def,\n fullQueue,\n );\n }\n }\n\n if (Object.keys(coreJobs).length === 0) continue;\n\n routers[queueName] = this.core().router({\n jobs: coreJobs as any,\n namespace: queueName,\n });\n\n for (const [jobName, def] of Object.entries(coreJobs)) {\n flattened[`${queueName}.${jobName}`] = def;\n }\n }\n\n // Register jobs in bulk so management APIs and workers can resolve handlers.\n await this.core().bulkRegister(flattened as any);\n\n this.coreExecutor = this.core().merge(routers as any) as any;\n this.executorDirty = false;\n return this.coreExecutor as CoreMergedExecutor;\n }\n\n private toCoreQueueName(queueName: string): string {\n return IgniterJobsPrefix.buildQueueName(queueName);\n }\n\n private mapQueueInfo(info: any): IgniterJobsQueueInfo {\n return {\n name: this.fromCoreQueueName(info.name),\n isPaused: info.isPaused,\n jobCounts: info.jobCounts,\n };\n }\n\n private fromCoreQueueName(full: string): string {\n const prefix = `${IgniterJobsPrefix.BASE_PREFIX}:`;\n return full.startsWith(prefix) ? full.slice(prefix.length) : full;\n }\n\n private mapJob(job: any, queue?: string): IgniterJobSearchResult {\n const q =\n queue ??\n this.fromCoreQueueName(job.metadata?.queue ?? job.queueName ?? \"\");\n const scope = (job.metadata as any)?.__igniter_jobs_scope;\n return {\n id: job.id,\n name: job.name,\n queue: q,\n status: job.status,\n input: job.payload,\n result: job.result,\n error: job.error,\n progress: typeof job.progress === \"number\" ? job.progress : 0,\n attemptsMade: job.attemptsMade ?? 0,\n priority: job.priority ?? 0,\n createdAt: job.createdAt,\n startedAt: job.processedAt,\n completedAt: job.completedAt,\n metadata: job.metadata,\n scope,\n };\n }\n\n private mapWorker(handle: any): IgniterJobsWorkerHandle {\n const queues = (handle as any).config?.queues ?? [\n (handle as any).queueName,\n ];\n return {\n id: handle.id,\n queues: (queues as string[]).map((q) => this.fromCoreQueueName(q)),\n pause: () => handle.pause(),\n resume: () => handle.resume(),\n close: () => handle.close(),\n isRunning: () => handle.isRunning(),\n isPaused: () => handle.isPaused(),\n isClosed: () => handle.isClosed(),\n getMetrics: async () => handle.getMetrics() as IgniterJobsWorkerMetrics,\n };\n }\n\n private toCoreJobDefinition(\n queueName: string,\n jobName: string,\n def: IgniterJobDefinition<any, any, any>,\n fullQueueName: string,\n ): CoreJobDefinition<any, any, any> {\n const handler = async (ctx: CoreJobExecutionContext<any, any>) => {\n const updateProgress =\n typeof (ctx.job as any)?.updateProgress === \"function\"\n ? async (progress: number, message?: string) => {\n await (ctx.job as any).updateProgress(progress);\n await def.onProgress?.({\n input: ctx.input as any,\n context: ctx.context as any,\n job: {\n id: ctx.job.id,\n name: jobName,\n queue: queueName,\n attemptsMade: ctx.job.attemptsMade,\n createdAt: (ctx.job as any).createdAt,\n metadata: ctx.job.metadata,\n updateProgress,\n },\n scope: (ctx.job.metadata as any)?.__igniter_jobs_scope,\n progress,\n message,\n } as any);\n }\n : undefined;\n\n return def.handler({\n input: ctx.input as any,\n context: ctx.context as any,\n job: {\n id: ctx.job.id,\n name: jobName,\n queue: queueName,\n attemptsMade: ctx.job.attemptsMade,\n createdAt: (ctx.job as any).createdAt,\n metadata: ctx.job.metadata,\n updateProgress,\n },\n scope: (ctx.job.metadata as any)?.__igniter_jobs_scope,\n } as any);\n };\n\n return {\n name: jobName,\n input: def.input as any,\n handler,\n queue: { name: fullQueueName },\n attempts: def.attempts,\n priority: def.priority,\n delay: def.delay,\n removeOnComplete: def.removeOnComplete as any,\n removeOnFail: def.removeOnFail as any,\n metadata: def.metadata as any,\n limiter: def.limiter as any,\n onStart: def.onStart as any,\n onSuccess: def.onSuccess as any,\n onFailure: def.onFailure as any,\n onProgress: def.onProgress as any,\n } as any;\n }\n\n private toCoreCronJobDefinition(\n queueName: string,\n cronName: string,\n def: IgniterCronDefinition<any, any>,\n fullQueueName: string,\n ): CoreJobDefinition<any, any, any> {\n const handler = async (ctx: CoreJobExecutionContext<any, any>) => {\n return def.handler({\n context: ctx.context as any,\n job: {\n id: ctx.job.id,\n name: cronName,\n queue: queueName,\n attemptsMade: ctx.job.attemptsMade,\n createdAt: (ctx.job as any).createdAt,\n metadata: ctx.job.metadata,\n },\n scope: (ctx.job.metadata as any)?.__igniter_jobs_scope,\n } as any);\n };\n\n return {\n name: cronName,\n handler,\n queue: { name: fullQueueName },\n repeat: {\n cron: def.cron,\n tz: def.tz,\n limit: def.maxExecutions,\n startDate: def.startDate,\n endDate: def.endDate,\n },\n metadata:\n def.onlyBusinessHours ||\n def.skipWeekends ||\n def.businessHours ||\n def.onlyWeekdays ||\n def.skipDates ||\n (def.startDate && def.endDate)\n ? {\n advancedScheduling: {\n onlyBusinessHours: def.onlyBusinessHours,\n skipWeekends: def.skipWeekends,\n businessHours: def.businessHours,\n skipDates: toDateArray(def.skipDates),\n onlyWeekdays: def.onlyWeekdays,\n between:\n def.startDate && def.endDate\n ? [def.startDate, def.endDate]\n : undefined,\n },\n }\n : undefined,\n } as any;\n }\n}\n"]}
package/dist/index.d.mts CHANGED
@@ -1,9 +1,6 @@
1
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.mjs';
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.mjs';
4
- export { IgniterJobsBullMQAdapter } from './adapters/bullmq.adapter.mjs';
5
- export { IgniterJobsMemoryAdapter } from './adapters/memory.adapter.mjs';
6
- export { IgniterJobsSQLiteAdapter, IgniterJobsSQLiteAdapterOptions } from './adapters/index.mjs';
2
+ import { I as IgniterJobsQueue, a as IgniterJobsAdapter, b as IgniterJobsScopeDefinition, c as IgniterJobDefinition, d as IgniterJobsWorkerBuilderConfig, e as IgniterJobsTelemetry, f as IgniterJobsEventHandler, g as IgniterJobSearchResult, h as IgniterJobsQueueInfo, i as IgniterJobsWorkerHandle, j as IgniterJobsLimiter, k as IgniterJobsWorkerHandlers, l as IgniterJobsQueueCleanOptions, m as IgniterJobStatus, n as IgniterJobsDispatchParams, o as IgniterJobsScheduleParams, p as IgniterJobsInferSchemaInput, q as IgniterCronDefinition, r as IgniterJobsScopeEntry, s as IgniterJobsSchema, t as IgniterJobsScopeOptions } from './adapter-Cax_40HW.mjs';
3
+ export { u as IgniterJobCounts, v as IgniterJobsAdapterDispatchParams, w as IgniterJobsAdapterScheduleParams, x as IgniterJobsBullMQAdapterOptions, y as IgniterJobsBunSQLiteAdapterOptions, z as IgniterJobsEvent, A as IgniterJobsExecutionContext, B as IgniterJobsFailureHook, C as IgniterJobsHookContext, D as IgniterJobsInferSchemaOutput, E as IgniterJobsInvokeOptions, F as IgniterJobsJobLog, G as IgniterJobsProgressHook, H as IgniterJobsQueueManager, J as IgniterJobsScheduleOptions, K as IgniterJobsStartHook, L as IgniterJobsSuccessHook, M as IgniterJobsWorkerMetrics } from './adapter-Cax_40HW.mjs';
7
4
  import 'ioredis';
8
5
 
9
6
  /**
@@ -58,13 +55,13 @@ interface IgniterJobsJobInstanceAccessor {
58
55
  retry(): Promise<void>;
59
56
  remove(): Promise<void>;
60
57
  promote(): Promise<void>;
61
- move(state: 'failed', reason: string): Promise<void>;
58
+ move(state: "failed", reason: string): Promise<void>;
62
59
  state(): Promise<IgniterJobStatus | null>;
63
60
  progress(): Promise<number>;
64
61
  logs(): Promise<{
65
62
  timestamp: Date;
66
63
  message: string;
67
- level: 'info' | 'warn' | 'error';
64
+ level: "info" | "warn" | "error";
68
65
  }[]>;
69
66
  }
70
67
  interface IgniterJobsJobManyAccessor {
@@ -76,8 +73,6 @@ interface IgniterJobsJobAccessor<TInput = unknown, TResult = unknown> {
76
73
  schedule(params: IgniterJobsScheduleParams<TInput>): Promise<string>;
77
74
  get(id: string): IgniterJobsJobInstanceAccessor;
78
75
  many(ids: string[]): IgniterJobsJobManyAccessor;
79
- pause(): Promise<void>;
80
- resume(): Promise<void>;
81
76
  subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
82
77
  }
83
78
  interface IgniterJobsQueueManagerAccessor {
@@ -112,24 +107,24 @@ interface IgniterJobsWorkerFluentBuilder<TQueueNames extends string> {
112
107
  addQueue(queue: TQueueNames): IgniterJobsWorkerFluentBuilder<TQueueNames>;
113
108
  withConcurrency(concurrency: number): IgniterJobsWorkerFluentBuilder<TQueueNames>;
114
109
  withLimiter(limiter: IgniterJobsLimiter): IgniterJobsWorkerFluentBuilder<TQueueNames>;
115
- onActive(handler: NonNullable<IgniterJobsWorkerHandlers['onActive']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
116
- onSuccess(handler: NonNullable<IgniterJobsWorkerHandlers['onSuccess']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
117
- onFailure(handler: NonNullable<IgniterJobsWorkerHandlers['onFailure']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
118
- onIdle(handler: NonNullable<IgniterJobsWorkerHandlers['onIdle']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
110
+ onActive(handler: NonNullable<IgniterJobsWorkerHandlers["onActive"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
111
+ onSuccess(handler: NonNullable<IgniterJobsWorkerHandlers["onSuccess"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
112
+ onFailure(handler: NonNullable<IgniterJobsWorkerHandlers["onFailure"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
113
+ onIdle(handler: NonNullable<IgniterJobsWorkerHandlers["onIdle"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
119
114
  start(): Promise<IgniterJobsWorkerHandle>;
120
115
  }
121
116
  interface IgniterJobsBaseRuntime<TConfig extends IgniterJobsConfig<any, any, any> = IgniterJobsConfig<any, any, any>> {
122
117
  readonly config: TConfig;
123
118
  subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
124
- search(target: 'jobs', filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
125
- search(target: 'queues', filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
126
- search(target: 'workers', filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
119
+ search(target: "jobs", filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
120
+ search(target: "queues", filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
121
+ search(target: "workers", filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
127
122
  shutdown(): Promise<void>;
128
- readonly worker: IgniterJobsWorkerBuilderAccessor<keyof TConfig['queues'] & string>;
129
- scope: TConfig extends IgniterJobsConfig<any, any, infer TScope> ? (TScope extends string ? (type: TScope, id: string | number, tags?: Record<string, unknown>) => IgniterJobsRuntime<TConfig> : never) : never;
123
+ readonly worker: IgniterJobsWorkerBuilderAccessor<keyof TConfig["queues"] & string>;
124
+ scope: TConfig extends IgniterJobsConfig<any, any, infer TScope> ? TScope extends string ? (type: TScope, id: string | number, tags?: Record<string, unknown>) => IgniterJobsRuntime<TConfig> : never : never;
130
125
  }
131
126
  type IgniterJobsRuntime<TConfig extends IgniterJobsConfig<any, any, any> = IgniterJobsConfig<any, any, any>> = IgniterJobsBaseRuntime<TConfig> & {
132
- [Q in keyof TConfig['queues']]: TConfig['queues'][Q] extends {
127
+ [Q in keyof TConfig["queues"]]: TConfig["queues"][Q] extends {
133
128
  jobs: infer TJobs extends Record<string, IgniterJobDefinition<any, any, any>>;
134
129
  } ? IgniterJobsQueueAccessor<TJobs> : IgniterJobsQueueAccessor;
135
130
  };
@@ -387,6 +382,7 @@ declare class IgniterJobsManager<TConfig extends IgniterJobsConfig<any, any, any
387
382
  * @internal
388
383
  */
389
384
  private getJobDefinition;
385
+ private getEffectiveJobDefinition;
390
386
  /**
391
387
  * Resolves the effective scope for a job operation.
392
388
  * @internal
@@ -504,7 +500,7 @@ declare class IgniterQueue {
504
500
  * @example
505
501
  * ```typescript
506
502
  * import { IgniterJobs, IgniterQueue } from '@igniter-js/jobs'
507
- * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters'
503
+ * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters/mock'
508
504
  * import { z } from 'zod'
509
505
  *
510
506
  * const emailQueue = IgniterQueue.create('email')
@@ -644,7 +640,7 @@ declare class IgniterJobsBuilder<TContext, TQueues extends Record<string, Ignite
644
640
  * @example
645
641
  * ```typescript
646
642
  * import { IgniterJobs, IgniterQueue } from '@igniter-js/jobs'
647
- * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters'
643
+ * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters/mock'
648
644
  * import { z } from 'zod'
649
645
  *
650
646
  * const emailQueue = IgniterQueue.create('email')
package/dist/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
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
- export { IgniterJobsBullMQAdapter } from './adapters/bullmq.adapter.js';
5
- export { IgniterJobsMemoryAdapter } from './adapters/memory.adapter.js';
6
- export { IgniterJobsSQLiteAdapter, IgniterJobsSQLiteAdapterOptions } from './adapters/index.js';
2
+ import { I as IgniterJobsQueue, a as IgniterJobsAdapter, b as IgniterJobsScopeDefinition, c as IgniterJobDefinition, d as IgniterJobsWorkerBuilderConfig, e as IgniterJobsTelemetry, f as IgniterJobsEventHandler, g as IgniterJobSearchResult, h as IgniterJobsQueueInfo, i as IgniterJobsWorkerHandle, j as IgniterJobsLimiter, k as IgniterJobsWorkerHandlers, l as IgniterJobsQueueCleanOptions, m as IgniterJobStatus, n as IgniterJobsDispatchParams, o as IgniterJobsScheduleParams, p as IgniterJobsInferSchemaInput, q as IgniterCronDefinition, r as IgniterJobsScopeEntry, s as IgniterJobsSchema, t as IgniterJobsScopeOptions } from './adapter-Cax_40HW.js';
3
+ export { u as IgniterJobCounts, v as IgniterJobsAdapterDispatchParams, w as IgniterJobsAdapterScheduleParams, x as IgniterJobsBullMQAdapterOptions, y as IgniterJobsBunSQLiteAdapterOptions, z as IgniterJobsEvent, A as IgniterJobsExecutionContext, B as IgniterJobsFailureHook, C as IgniterJobsHookContext, D as IgniterJobsInferSchemaOutput, E as IgniterJobsInvokeOptions, F as IgniterJobsJobLog, G as IgniterJobsProgressHook, H as IgniterJobsQueueManager, J as IgniterJobsScheduleOptions, K as IgniterJobsStartHook, L as IgniterJobsSuccessHook, M as IgniterJobsWorkerMetrics } from './adapter-Cax_40HW.js';
7
4
  import 'ioredis';
8
5
 
9
6
  /**
@@ -58,13 +55,13 @@ interface IgniterJobsJobInstanceAccessor {
58
55
  retry(): Promise<void>;
59
56
  remove(): Promise<void>;
60
57
  promote(): Promise<void>;
61
- move(state: 'failed', reason: string): Promise<void>;
58
+ move(state: "failed", reason: string): Promise<void>;
62
59
  state(): Promise<IgniterJobStatus | null>;
63
60
  progress(): Promise<number>;
64
61
  logs(): Promise<{
65
62
  timestamp: Date;
66
63
  message: string;
67
- level: 'info' | 'warn' | 'error';
64
+ level: "info" | "warn" | "error";
68
65
  }[]>;
69
66
  }
70
67
  interface IgniterJobsJobManyAccessor {
@@ -76,8 +73,6 @@ interface IgniterJobsJobAccessor<TInput = unknown, TResult = unknown> {
76
73
  schedule(params: IgniterJobsScheduleParams<TInput>): Promise<string>;
77
74
  get(id: string): IgniterJobsJobInstanceAccessor;
78
75
  many(ids: string[]): IgniterJobsJobManyAccessor;
79
- pause(): Promise<void>;
80
- resume(): Promise<void>;
81
76
  subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
82
77
  }
83
78
  interface IgniterJobsQueueManagerAccessor {
@@ -112,24 +107,24 @@ interface IgniterJobsWorkerFluentBuilder<TQueueNames extends string> {
112
107
  addQueue(queue: TQueueNames): IgniterJobsWorkerFluentBuilder<TQueueNames>;
113
108
  withConcurrency(concurrency: number): IgniterJobsWorkerFluentBuilder<TQueueNames>;
114
109
  withLimiter(limiter: IgniterJobsLimiter): IgniterJobsWorkerFluentBuilder<TQueueNames>;
115
- onActive(handler: NonNullable<IgniterJobsWorkerHandlers['onActive']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
116
- onSuccess(handler: NonNullable<IgniterJobsWorkerHandlers['onSuccess']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
117
- onFailure(handler: NonNullable<IgniterJobsWorkerHandlers['onFailure']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
118
- onIdle(handler: NonNullable<IgniterJobsWorkerHandlers['onIdle']>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
110
+ onActive(handler: NonNullable<IgniterJobsWorkerHandlers["onActive"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
111
+ onSuccess(handler: NonNullable<IgniterJobsWorkerHandlers["onSuccess"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
112
+ onFailure(handler: NonNullable<IgniterJobsWorkerHandlers["onFailure"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
113
+ onIdle(handler: NonNullable<IgniterJobsWorkerHandlers["onIdle"]>): IgniterJobsWorkerFluentBuilder<TQueueNames>;
119
114
  start(): Promise<IgniterJobsWorkerHandle>;
120
115
  }
121
116
  interface IgniterJobsBaseRuntime<TConfig extends IgniterJobsConfig<any, any, any> = IgniterJobsConfig<any, any, any>> {
122
117
  readonly config: TConfig;
123
118
  subscribe(handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
124
- search(target: 'jobs', filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
125
- search(target: 'queues', filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
126
- search(target: 'workers', filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
119
+ search(target: "jobs", filter: Record<string, unknown>): Promise<IgniterJobSearchResult[]>;
120
+ search(target: "queues", filter: Record<string, unknown>): Promise<IgniterJobsQueueInfo[]>;
121
+ search(target: "workers", filter: Record<string, unknown>): Promise<IgniterJobsWorkerHandle[]>;
127
122
  shutdown(): Promise<void>;
128
- readonly worker: IgniterJobsWorkerBuilderAccessor<keyof TConfig['queues'] & string>;
129
- scope: TConfig extends IgniterJobsConfig<any, any, infer TScope> ? (TScope extends string ? (type: TScope, id: string | number, tags?: Record<string, unknown>) => IgniterJobsRuntime<TConfig> : never) : never;
123
+ readonly worker: IgniterJobsWorkerBuilderAccessor<keyof TConfig["queues"] & string>;
124
+ scope: TConfig extends IgniterJobsConfig<any, any, infer TScope> ? TScope extends string ? (type: TScope, id: string | number, tags?: Record<string, unknown>) => IgniterJobsRuntime<TConfig> : never : never;
130
125
  }
131
126
  type IgniterJobsRuntime<TConfig extends IgniterJobsConfig<any, any, any> = IgniterJobsConfig<any, any, any>> = IgniterJobsBaseRuntime<TConfig> & {
132
- [Q in keyof TConfig['queues']]: TConfig['queues'][Q] extends {
127
+ [Q in keyof TConfig["queues"]]: TConfig["queues"][Q] extends {
133
128
  jobs: infer TJobs extends Record<string, IgniterJobDefinition<any, any, any>>;
134
129
  } ? IgniterJobsQueueAccessor<TJobs> : IgniterJobsQueueAccessor;
135
130
  };
@@ -387,6 +382,7 @@ declare class IgniterJobsManager<TConfig extends IgniterJobsConfig<any, any, any
387
382
  * @internal
388
383
  */
389
384
  private getJobDefinition;
385
+ private getEffectiveJobDefinition;
390
386
  /**
391
387
  * Resolves the effective scope for a job operation.
392
388
  * @internal
@@ -504,7 +500,7 @@ declare class IgniterQueue {
504
500
  * @example
505
501
  * ```typescript
506
502
  * import { IgniterJobs, IgniterQueue } from '@igniter-js/jobs'
507
- * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters'
503
+ * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters/mock'
508
504
  * import { z } from 'zod'
509
505
  *
510
506
  * const emailQueue = IgniterQueue.create('email')
@@ -644,7 +640,7 @@ declare class IgniterJobsBuilder<TContext, TQueues extends Record<string, Ignite
644
640
  * @example
645
641
  * ```typescript
646
642
  * import { IgniterJobs, IgniterQueue } from '@igniter-js/jobs'
647
- * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters'
643
+ * import { IgniterJobsMemoryAdapter } from '@igniter-js/jobs/adapters/mock'
648
644
  * import { z } from 'zod'
649
645
  *
650
646
  * const emailQueue = IgniterQueue.create('email')