@igniter-js/jobs 0.1.0 → 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.
Files changed (44) hide show
  1. package/AGENTS.md +1006 -410
  2. package/CHANGELOG.md +13 -0
  3. package/README.md +2092 -277
  4. package/dist/adapter-CXZxomI9.d.mts +529 -0
  5. package/dist/adapter-CXZxomI9.d.ts +529 -0
  6. package/dist/adapters/bullmq.adapter.d.mts +56 -111
  7. package/dist/adapters/bullmq.adapter.d.ts +56 -111
  8. package/dist/adapters/bullmq.adapter.js +432 -530
  9. package/dist/adapters/bullmq.adapter.js.map +1 -1
  10. package/dist/adapters/bullmq.adapter.mjs +432 -530
  11. package/dist/adapters/bullmq.adapter.mjs.map +1 -1
  12. package/dist/adapters/index.d.mts +142 -4
  13. package/dist/adapters/index.d.ts +142 -4
  14. package/dist/adapters/index.js +1701 -939
  15. package/dist/adapters/index.js.map +1 -1
  16. package/dist/adapters/index.mjs +1699 -938
  17. package/dist/adapters/index.mjs.map +1 -1
  18. package/dist/adapters/memory.adapter.d.mts +53 -99
  19. package/dist/adapters/memory.adapter.d.ts +53 -99
  20. package/dist/adapters/memory.adapter.js +554 -464
  21. package/dist/adapters/memory.adapter.js.map +1 -1
  22. package/dist/adapters/memory.adapter.mjs +554 -464
  23. package/dist/adapters/memory.adapter.mjs.map +1 -1
  24. package/dist/index.d.mts +524 -887
  25. package/dist/index.d.ts +524 -887
  26. package/dist/index.js +2917 -860
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +2914 -860
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/shim.d.mts +36 -0
  31. package/dist/shim.d.ts +36 -0
  32. package/dist/shim.js +75 -0
  33. package/dist/shim.js.map +1 -0
  34. package/dist/shim.mjs +67 -0
  35. package/dist/shim.mjs.map +1 -0
  36. package/dist/telemetry/index.d.mts +281 -0
  37. package/dist/telemetry/index.d.ts +281 -0
  38. package/dist/telemetry/index.js +97 -0
  39. package/dist/telemetry/index.js.map +1 -0
  40. package/dist/telemetry/index.mjs +95 -0
  41. package/dist/telemetry/index.mjs.map +1 -0
  42. package/package.json +71 -20
  43. package/dist/adapter-CcQCatSa.d.mts +0 -1411
  44. package/dist/adapter-CcQCatSa.d.ts +0 -1411
@@ -1,131 +1,76 @@
1
- import { Redis } from 'ioredis';
2
- import { I as IgniterJobsAdapter, A as AdapterDispatchParams, a as AdapterScheduleParams, b as IgniterJobInfo, c as IgniterJobStatus, d as IgniterJobLog, e as IgniterQueueInfo, f as IgniterQueueCleanOptions, g as IgniterJobCounts, h as IgniterJobSearchResult, i as IgniterJobEventHandler, j as IgniterJobUnsubscribeFn, k as AdapterWorkerConfig, l as AdapterJobHandler, m as AdapterWorkerHandle } from '../adapter-CcQCatSa.mjs';
3
- import '@igniter-js/core';
1
+ import { I as IgniterJobsAdapter, a as IgniterJobsQueueManager, b as IgniterJobsBullMQAdapterOptions, c as IgniterJobDefinition, d as IgniterCronDefinition, e as IgniterJobsAdapterDispatchParams, f as IgniterJobsAdapterScheduleParams, g as IgniterJobSearchResult, h as IgniterJobStatus, i as IgniterJobsJobLog, j as IgniterJobsQueueInfo, k as IgniterJobsQueueCleanOptions, l as IgniterJobsWorkerHandle, m as IgniterJobsWorkerBuilderConfig, n as IgniterJobsEventHandler } from '../adapter-CXZxomI9.mjs';
2
+ import 'ioredis';
3
+ import '@igniter-js/common';
4
4
 
5
5
  /**
6
- * @fileoverview BullMQ adapter for @igniter-js/jobs
6
+ * @fileoverview BullMQ adapter for @igniter-js/jobs (wraps @igniter-js/adapter-bullmq)
7
7
  * @module @igniter-js/jobs/adapters/bullmq
8
- *
9
- * @description
10
- * Provides BullMQ-based implementation of the IgniterJobsAdapter interface.
11
- * Requires Redis connection via ioredis.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { BullMQAdapter } from '@igniter-js/jobs/adapters'
16
- * import Redis from 'ioredis'
17
- *
18
- * const redis = new Redis()
19
- * const adapter = BullMQAdapter.create({ redis })
20
- *
21
- * const jobs = IgniterJobs.create<AppContext>()
22
- * .withAdapter(adapter)
23
- * .build()
24
- * ```
25
8
  */
26
9
 
27
10
  /**
28
- * BullMQ adapter options.
29
- */
30
- interface BullMQAdapterOptions {
31
- /**
32
- * Redis connection (ioredis instance).
33
- */
34
- redis: Redis;
35
- }
36
- /**
37
- * BullMQ implementation of IgniterJobsAdapter.
11
+ * BullMQ adapter facade.
12
+ *
13
+ * It reuses the mature BullMQ integration from `@igniter-js/adapter-bullmq` to keep
14
+ * feature parity (workers, queue/job management, advanced scheduling, hooks).
38
15
  */
39
- declare class BullMQAdapter implements IgniterJobsAdapter {
16
+ declare class IgniterJobsBullMQAdapter implements IgniterJobsAdapter {
17
+ readonly client: unknown;
40
18
  private readonly redis;
41
- private readonly queues;
42
- private readonly workers;
43
- private readonly queueEvents;
44
- private BullMQ;
19
+ private readonly publisher;
20
+ private readonly subscriber;
21
+ private readonly subscribers;
22
+ private coreAdapter;
23
+ private coreExecutor;
24
+ private executorDirty;
25
+ private readonly jobsByQueue;
26
+ private readonly cronsByQueue;
27
+ readonly queues: IgniterJobsQueueManager;
45
28
  private constructor();
46
- /**
47
- * Create a new BullMQ adapter.
48
- *
49
- * @param options - Adapter options with Redis connection
50
- * @returns A new BullMQAdapter instance
51
- */
52
- static create(options: BullMQAdapterOptions): BullMQAdapter;
53
- /**
54
- * Get the underlying Redis client.
55
- */
56
- get client(): Redis;
57
- /**
58
- * Lazily load BullMQ module.
59
- */
60
- private getBullMQ;
61
- /**
62
- * Get or create a queue instance.
63
- */
64
- private getOrCreateQueue;
65
- /**
66
- * Get or create queue events instance.
67
- */
68
- private getQueueEvents;
69
- /**
70
- * Convert BullMQ job state to IgniterJobStatus.
71
- */
72
- private mapJobState;
73
- /**
74
- * Convert BullMQ job to IgniterJobInfo.
75
- */
76
- private mapJobToInfo;
77
- dispatch(params: AdapterDispatchParams): Promise<string>;
78
- schedule(params: AdapterScheduleParams): Promise<string>;
79
- getJob(queue: string, jobId: string): Promise<IgniterJobInfo | null>;
80
- getJobState(queue: string, jobId: string): Promise<IgniterJobStatus | null>;
81
- getJobProgress(queue: string, jobId: string): Promise<number>;
82
- getJobLogs(queue: string, jobId: string): Promise<IgniterJobLog[]>;
83
- retryJob(queue: string, jobId: string): Promise<void>;
84
- removeJob(queue: string, jobId: string): Promise<void>;
85
- promoteJob(queue: string, jobId: string): Promise<void>;
86
- moveJob(queue: string, jobId: string, state: 'failed' | 'completed', reason?: string): Promise<void>;
87
- retryJobs(queue: string, jobIds: string[]): Promise<void>;
88
- removeJobs(queue: string, jobIds: string[]): Promise<void>;
89
- getQueue(queue: string): Promise<IgniterQueueInfo>;
29
+ static create(options: IgniterJobsBullMQAdapterOptions): IgniterJobsAdapter;
30
+ registerJob(queueName: string, jobName: string, definition: IgniterJobDefinition<any, any, any>): void;
31
+ registerCron(queueName: string, cronName: string, definition: IgniterCronDefinition<any, any>): void;
32
+ dispatch(params: IgniterJobsAdapterDispatchParams): Promise<string>;
33
+ schedule(params: IgniterJobsAdapterScheduleParams): Promise<string>;
34
+ getJob(jobId: string, queue?: string): Promise<IgniterJobSearchResult | null>;
35
+ getJobState(jobId: string, queue?: string): Promise<IgniterJobStatus | null>;
36
+ getJobLogs(jobId: string, queue?: string): Promise<IgniterJobsJobLog[]>;
37
+ getJobProgress(jobId: string, queue?: string): Promise<number>;
38
+ retryJob(jobId: string, queue?: string): Promise<void>;
39
+ removeJob(jobId: string, queue?: string): Promise<void>;
40
+ promoteJob(jobId: string, queue?: string): Promise<void>;
41
+ moveJobToFailed(jobId: string, reason: string, queue?: string): Promise<void>;
42
+ retryManyJobs(jobIds: string[], queue?: string): Promise<void>;
43
+ removeManyJobs(jobIds: string[], queue?: string): Promise<void>;
44
+ getQueueInfo(queue: string): Promise<IgniterJobsQueueInfo | null>;
45
+ getQueueJobCounts(queue: string): Promise<any>;
46
+ listQueues(): Promise<IgniterJobsQueueInfo[]>;
90
47
  pauseQueue(queue: string): Promise<void>;
91
48
  resumeQueue(queue: string): Promise<void>;
92
49
  drainQueue(queue: string): Promise<number>;
93
- cleanQueue(queue: string, options: IgniterQueueCleanOptions): Promise<number>;
50
+ cleanQueue(queue: string, options: IgniterJobsQueueCleanOptions): Promise<number>;
94
51
  obliterateQueue(queue: string, options?: {
95
52
  force?: boolean;
96
53
  }): Promise<void>;
97
- retryAllFailed(queue: string): Promise<number>;
98
- getJobCounts(queue: string): Promise<IgniterJobCounts>;
99
- listJobs(queue: string, options?: {
100
- status?: IgniterJobStatus[];
101
- start?: number;
102
- end?: number;
103
- }): Promise<IgniterJobSearchResult[]>;
54
+ retryAllInQueue(queue: string): Promise<number>;
104
55
  pauseJobType(queue: string, jobName: string): Promise<void>;
105
56
  resumeJobType(queue: string, jobName: string): Promise<void>;
106
- private config?;
107
- subscribe(pattern: string, handler: IgniterJobEventHandler): Promise<IgniterJobUnsubscribeFn>;
108
- private matchesPattern;
109
- createWorker(config: AdapterWorkerConfig, handler: AdapterJobHandler): Promise<AdapterWorkerHandle>;
110
- searchJobs(filter: {
111
- status?: IgniterJobStatus[];
112
- queue?: string;
113
- jobName?: string;
114
- scopeId?: string;
115
- actorId?: string;
116
- dateRange?: {
117
- from?: Date;
118
- to?: Date;
119
- };
120
- orderBy?: string;
121
- limit?: number;
122
- offset?: number;
123
- }): Promise<IgniterJobSearchResult[]>;
124
- searchQueues(filter: {
125
- name?: string;
126
- isPaused?: boolean;
127
- }): Promise<IgniterQueueInfo[]>;
57
+ searchJobs(filter: any): Promise<IgniterJobSearchResult[]>;
58
+ searchQueues(filter: any): Promise<IgniterJobsQueueInfo[]>;
59
+ searchWorkers(filter: any): Promise<IgniterJobsWorkerHandle[]>;
60
+ createWorker(config: IgniterJobsWorkerBuilderConfig): Promise<IgniterJobsWorkerHandle>;
61
+ getWorkers(): Map<string, IgniterJobsWorkerHandle>;
62
+ publishEvent(channel: string, payload: unknown): Promise<void>;
63
+ subscribeEvent(channel: string, handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
128
64
  shutdown(): Promise<void>;
65
+ private core;
66
+ private executor;
67
+ private toCoreQueueName;
68
+ private mapQueueInfo;
69
+ private fromCoreQueueName;
70
+ private mapJob;
71
+ private mapWorker;
72
+ private toCoreJobDefinition;
73
+ private toCoreCronJobDefinition;
129
74
  }
130
75
 
131
- export { BullMQAdapter, type BullMQAdapterOptions };
76
+ export { IgniterJobsBullMQAdapter };
@@ -1,131 +1,76 @@
1
- import { Redis } from 'ioredis';
2
- import { I as IgniterJobsAdapter, A as AdapterDispatchParams, a as AdapterScheduleParams, b as IgniterJobInfo, c as IgniterJobStatus, d as IgniterJobLog, e as IgniterQueueInfo, f as IgniterQueueCleanOptions, g as IgniterJobCounts, h as IgniterJobSearchResult, i as IgniterJobEventHandler, j as IgniterJobUnsubscribeFn, k as AdapterWorkerConfig, l as AdapterJobHandler, m as AdapterWorkerHandle } from '../adapter-CcQCatSa.js';
3
- import '@igniter-js/core';
1
+ import { I as IgniterJobsAdapter, a as IgniterJobsQueueManager, b as IgniterJobsBullMQAdapterOptions, c as IgniterJobDefinition, d as IgniterCronDefinition, e as IgniterJobsAdapterDispatchParams, f as IgniterJobsAdapterScheduleParams, g as IgniterJobSearchResult, h as IgniterJobStatus, i as IgniterJobsJobLog, j as IgniterJobsQueueInfo, k as IgniterJobsQueueCleanOptions, l as IgniterJobsWorkerHandle, m as IgniterJobsWorkerBuilderConfig, n as IgniterJobsEventHandler } from '../adapter-CXZxomI9.js';
2
+ import 'ioredis';
3
+ import '@igniter-js/common';
4
4
 
5
5
  /**
6
- * @fileoverview BullMQ adapter for @igniter-js/jobs
6
+ * @fileoverview BullMQ adapter for @igniter-js/jobs (wraps @igniter-js/adapter-bullmq)
7
7
  * @module @igniter-js/jobs/adapters/bullmq
8
- *
9
- * @description
10
- * Provides BullMQ-based implementation of the IgniterJobsAdapter interface.
11
- * Requires Redis connection via ioredis.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { BullMQAdapter } from '@igniter-js/jobs/adapters'
16
- * import Redis from 'ioredis'
17
- *
18
- * const redis = new Redis()
19
- * const adapter = BullMQAdapter.create({ redis })
20
- *
21
- * const jobs = IgniterJobs.create<AppContext>()
22
- * .withAdapter(adapter)
23
- * .build()
24
- * ```
25
8
  */
26
9
 
27
10
  /**
28
- * BullMQ adapter options.
29
- */
30
- interface BullMQAdapterOptions {
31
- /**
32
- * Redis connection (ioredis instance).
33
- */
34
- redis: Redis;
35
- }
36
- /**
37
- * BullMQ implementation of IgniterJobsAdapter.
11
+ * BullMQ adapter facade.
12
+ *
13
+ * It reuses the mature BullMQ integration from `@igniter-js/adapter-bullmq` to keep
14
+ * feature parity (workers, queue/job management, advanced scheduling, hooks).
38
15
  */
39
- declare class BullMQAdapter implements IgniterJobsAdapter {
16
+ declare class IgniterJobsBullMQAdapter implements IgniterJobsAdapter {
17
+ readonly client: unknown;
40
18
  private readonly redis;
41
- private readonly queues;
42
- private readonly workers;
43
- private readonly queueEvents;
44
- private BullMQ;
19
+ private readonly publisher;
20
+ private readonly subscriber;
21
+ private readonly subscribers;
22
+ private coreAdapter;
23
+ private coreExecutor;
24
+ private executorDirty;
25
+ private readonly jobsByQueue;
26
+ private readonly cronsByQueue;
27
+ readonly queues: IgniterJobsQueueManager;
45
28
  private constructor();
46
- /**
47
- * Create a new BullMQ adapter.
48
- *
49
- * @param options - Adapter options with Redis connection
50
- * @returns A new BullMQAdapter instance
51
- */
52
- static create(options: BullMQAdapterOptions): BullMQAdapter;
53
- /**
54
- * Get the underlying Redis client.
55
- */
56
- get client(): Redis;
57
- /**
58
- * Lazily load BullMQ module.
59
- */
60
- private getBullMQ;
61
- /**
62
- * Get or create a queue instance.
63
- */
64
- private getOrCreateQueue;
65
- /**
66
- * Get or create queue events instance.
67
- */
68
- private getQueueEvents;
69
- /**
70
- * Convert BullMQ job state to IgniterJobStatus.
71
- */
72
- private mapJobState;
73
- /**
74
- * Convert BullMQ job to IgniterJobInfo.
75
- */
76
- private mapJobToInfo;
77
- dispatch(params: AdapterDispatchParams): Promise<string>;
78
- schedule(params: AdapterScheduleParams): Promise<string>;
79
- getJob(queue: string, jobId: string): Promise<IgniterJobInfo | null>;
80
- getJobState(queue: string, jobId: string): Promise<IgniterJobStatus | null>;
81
- getJobProgress(queue: string, jobId: string): Promise<number>;
82
- getJobLogs(queue: string, jobId: string): Promise<IgniterJobLog[]>;
83
- retryJob(queue: string, jobId: string): Promise<void>;
84
- removeJob(queue: string, jobId: string): Promise<void>;
85
- promoteJob(queue: string, jobId: string): Promise<void>;
86
- moveJob(queue: string, jobId: string, state: 'failed' | 'completed', reason?: string): Promise<void>;
87
- retryJobs(queue: string, jobIds: string[]): Promise<void>;
88
- removeJobs(queue: string, jobIds: string[]): Promise<void>;
89
- getQueue(queue: string): Promise<IgniterQueueInfo>;
29
+ static create(options: IgniterJobsBullMQAdapterOptions): IgniterJobsAdapter;
30
+ registerJob(queueName: string, jobName: string, definition: IgniterJobDefinition<any, any, any>): void;
31
+ registerCron(queueName: string, cronName: string, definition: IgniterCronDefinition<any, any>): void;
32
+ dispatch(params: IgniterJobsAdapterDispatchParams): Promise<string>;
33
+ schedule(params: IgniterJobsAdapterScheduleParams): Promise<string>;
34
+ getJob(jobId: string, queue?: string): Promise<IgniterJobSearchResult | null>;
35
+ getJobState(jobId: string, queue?: string): Promise<IgniterJobStatus | null>;
36
+ getJobLogs(jobId: string, queue?: string): Promise<IgniterJobsJobLog[]>;
37
+ getJobProgress(jobId: string, queue?: string): Promise<number>;
38
+ retryJob(jobId: string, queue?: string): Promise<void>;
39
+ removeJob(jobId: string, queue?: string): Promise<void>;
40
+ promoteJob(jobId: string, queue?: string): Promise<void>;
41
+ moveJobToFailed(jobId: string, reason: string, queue?: string): Promise<void>;
42
+ retryManyJobs(jobIds: string[], queue?: string): Promise<void>;
43
+ removeManyJobs(jobIds: string[], queue?: string): Promise<void>;
44
+ getQueueInfo(queue: string): Promise<IgniterJobsQueueInfo | null>;
45
+ getQueueJobCounts(queue: string): Promise<any>;
46
+ listQueues(): Promise<IgniterJobsQueueInfo[]>;
90
47
  pauseQueue(queue: string): Promise<void>;
91
48
  resumeQueue(queue: string): Promise<void>;
92
49
  drainQueue(queue: string): Promise<number>;
93
- cleanQueue(queue: string, options: IgniterQueueCleanOptions): Promise<number>;
50
+ cleanQueue(queue: string, options: IgniterJobsQueueCleanOptions): Promise<number>;
94
51
  obliterateQueue(queue: string, options?: {
95
52
  force?: boolean;
96
53
  }): Promise<void>;
97
- retryAllFailed(queue: string): Promise<number>;
98
- getJobCounts(queue: string): Promise<IgniterJobCounts>;
99
- listJobs(queue: string, options?: {
100
- status?: IgniterJobStatus[];
101
- start?: number;
102
- end?: number;
103
- }): Promise<IgniterJobSearchResult[]>;
54
+ retryAllInQueue(queue: string): Promise<number>;
104
55
  pauseJobType(queue: string, jobName: string): Promise<void>;
105
56
  resumeJobType(queue: string, jobName: string): Promise<void>;
106
- private config?;
107
- subscribe(pattern: string, handler: IgniterJobEventHandler): Promise<IgniterJobUnsubscribeFn>;
108
- private matchesPattern;
109
- createWorker(config: AdapterWorkerConfig, handler: AdapterJobHandler): Promise<AdapterWorkerHandle>;
110
- searchJobs(filter: {
111
- status?: IgniterJobStatus[];
112
- queue?: string;
113
- jobName?: string;
114
- scopeId?: string;
115
- actorId?: string;
116
- dateRange?: {
117
- from?: Date;
118
- to?: Date;
119
- };
120
- orderBy?: string;
121
- limit?: number;
122
- offset?: number;
123
- }): Promise<IgniterJobSearchResult[]>;
124
- searchQueues(filter: {
125
- name?: string;
126
- isPaused?: boolean;
127
- }): Promise<IgniterQueueInfo[]>;
57
+ searchJobs(filter: any): Promise<IgniterJobSearchResult[]>;
58
+ searchQueues(filter: any): Promise<IgniterJobsQueueInfo[]>;
59
+ searchWorkers(filter: any): Promise<IgniterJobsWorkerHandle[]>;
60
+ createWorker(config: IgniterJobsWorkerBuilderConfig): Promise<IgniterJobsWorkerHandle>;
61
+ getWorkers(): Map<string, IgniterJobsWorkerHandle>;
62
+ publishEvent(channel: string, payload: unknown): Promise<void>;
63
+ subscribeEvent(channel: string, handler: IgniterJobsEventHandler): Promise<() => Promise<void>>;
128
64
  shutdown(): Promise<void>;
65
+ private core;
66
+ private executor;
67
+ private toCoreQueueName;
68
+ private mapQueueInfo;
69
+ private fromCoreQueueName;
70
+ private mapJob;
71
+ private mapWorker;
72
+ private toCoreJobDefinition;
73
+ private toCoreCronJobDefinition;
129
74
  }
130
75
 
131
- export { BullMQAdapter, type BullMQAdapterOptions };
76
+ export { IgniterJobsBullMQAdapter };