@riktajs/queue 0.10.2 → 0.10.3

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 (64) hide show
  1. package/dist/index.cjs +16251 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +946 -0
  4. package/dist/index.d.ts +945 -21
  5. package/dist/index.js +16177 -29
  6. package/dist/index.js.map +1 -1
  7. package/package.json +13 -6
  8. package/dist/config/queue.config.d.ts +0 -43
  9. package/dist/config/queue.config.d.ts.map +0 -1
  10. package/dist/config/queue.config.js +0 -82
  11. package/dist/config/queue.config.js.map +0 -1
  12. package/dist/constants.d.ts +0 -33
  13. package/dist/constants.d.ts.map +0 -1
  14. package/dist/constants.js +0 -37
  15. package/dist/constants.js.map +0 -1
  16. package/dist/decorators/events.decorator.d.ts +0 -85
  17. package/dist/decorators/events.decorator.d.ts.map +0 -1
  18. package/dist/decorators/events.decorator.js +0 -120
  19. package/dist/decorators/events.decorator.js.map +0 -1
  20. package/dist/decorators/index.d.ts +0 -8
  21. package/dist/decorators/index.d.ts.map +0 -1
  22. package/dist/decorators/index.js +0 -8
  23. package/dist/decorators/index.js.map +0 -1
  24. package/dist/decorators/process.decorator.d.ts +0 -41
  25. package/dist/decorators/process.decorator.d.ts.map +0 -1
  26. package/dist/decorators/process.decorator.js +0 -61
  27. package/dist/decorators/process.decorator.js.map +0 -1
  28. package/dist/decorators/processor.decorator.d.ts +0 -41
  29. package/dist/decorators/processor.decorator.d.ts.map +0 -1
  30. package/dist/decorators/processor.decorator.js +0 -59
  31. package/dist/decorators/processor.decorator.js.map +0 -1
  32. package/dist/decorators/queue.decorator.d.ts +0 -35
  33. package/dist/decorators/queue.decorator.d.ts.map +0 -1
  34. package/dist/decorators/queue.decorator.js +0 -49
  35. package/dist/decorators/queue.decorator.js.map +0 -1
  36. package/dist/events/queue-events.d.ts +0 -32
  37. package/dist/events/queue-events.d.ts.map +0 -1
  38. package/dist/events/queue-events.js +0 -103
  39. package/dist/events/queue-events.js.map +0 -1
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/monitoring/bull-board.d.ts +0 -77
  42. package/dist/monitoring/bull-board.d.ts.map +0 -1
  43. package/dist/monitoring/bull-board.js +0 -112
  44. package/dist/monitoring/bull-board.js.map +0 -1
  45. package/dist/providers/queue.provider.d.ts +0 -113
  46. package/dist/providers/queue.provider.d.ts.map +0 -1
  47. package/dist/providers/queue.provider.js +0 -383
  48. package/dist/providers/queue.provider.js.map +0 -1
  49. package/dist/services/queue.service.d.ts +0 -133
  50. package/dist/services/queue.service.d.ts.map +0 -1
  51. package/dist/services/queue.service.js +0 -192
  52. package/dist/services/queue.service.js.map +0 -1
  53. package/dist/types.d.ts +0 -133
  54. package/dist/types.d.ts.map +0 -1
  55. package/dist/types.js +0 -5
  56. package/dist/types.js.map +0 -1
  57. package/dist/utils/connection.d.ts +0 -47
  58. package/dist/utils/connection.d.ts.map +0 -1
  59. package/dist/utils/connection.js +0 -102
  60. package/dist/utils/connection.js.map +0 -1
  61. package/dist/utils/validation.d.ts +0 -137
  62. package/dist/utils/validation.d.ts.map +0 -1
  63. package/dist/utils/validation.js +0 -156
  64. package/dist/utils/validation.js.map +0 -1
@@ -1,59 +0,0 @@
1
- /**
2
- * @Processor decorator - marks a class as a job processor
3
- */
4
- import 'reflect-metadata';
5
- import { METADATA_KEY } from '../constants.js';
6
- /**
7
- * Decorator to define a job processor for a queue
8
- *
9
- * @param queueName - The name of the queue to process
10
- * @param options - Optional processor configuration
11
- * @returns ClassDecorator
12
- *
13
- * @example
14
- * ```typescript
15
- * @Processor('email-queue', { concurrency: 5 })
16
- * class EmailProcessor {
17
- * @Process('send')
18
- * async handleSendEmail(job: Job) {
19
- * // process job
20
- * }
21
- * }
22
- * ```
23
- */
24
- export function Processor(queueName, options) {
25
- if (!queueName) {
26
- throw new ProcessorDecoratorError('Queue name is required for @Processor');
27
- }
28
- const processorOptions = {
29
- queueName,
30
- ...options,
31
- };
32
- return (target) => {
33
- Reflect.defineMetadata(METADATA_KEY.PROCESSOR_OPTIONS, processorOptions, target);
34
- };
35
- }
36
- /**
37
- * Get processor options from a decorated class
38
- * @param target - The decorated class
39
- */
40
- export function getProcessorOptions(target) {
41
- return Reflect.getMetadata(METADATA_KEY.PROCESSOR_OPTIONS, target);
42
- }
43
- /**
44
- * Check if a class is decorated with @Processor
45
- * @param target - The class to check
46
- */
47
- export function isProcessor(target) {
48
- return Reflect.hasMetadata(METADATA_KEY.PROCESSOR_OPTIONS, target);
49
- }
50
- /**
51
- * Error thrown when @Processor decorator is used incorrectly
52
- */
53
- export class ProcessorDecoratorError extends Error {
54
- constructor(message) {
55
- super(message);
56
- this.name = 'ProcessorDecoratorError';
57
- }
58
- }
59
- //# sourceMappingURL=processor.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processor.decorator.js","sourceRoot":"","sources":["../../src/decorators/processor.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,SAAS,CACvB,SAAiB,EACjB,OAA6C;IAE7C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,uBAAuB,CAAC,uCAAuC,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,gBAAgB,GAAqB;QACzC,SAAS;QACT,GAAG,OAAO;KACX,CAAC;IAEF,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAgB;IAClD,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAgB;IAC1C,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
@@ -1,35 +0,0 @@
1
- /**
2
- * @Queue decorator - marks a class as a queue definition
3
- */
4
- import 'reflect-metadata';
5
- import type { QueueDecoratorOptions } from '../types.js';
6
- /**
7
- * Decorator to define a queue
8
- *
9
- * @param options - Queue configuration options
10
- * @returns ClassDecorator
11
- *
12
- * @example
13
- * ```typescript
14
- * @Queue({ name: 'email-queue' })
15
- * class EmailQueue {}
16
- * ```
17
- */
18
- export declare function Queue(options: QueueDecoratorOptions): ClassDecorator;
19
- /**
20
- * Get queue options from a decorated class
21
- * @param target - The decorated class
22
- */
23
- export declare function getQueueOptions(target: Function): QueueDecoratorOptions | undefined;
24
- /**
25
- * Check if a class is decorated with @Queue
26
- * @param target - The class to check
27
- */
28
- export declare function isQueue(target: Function): boolean;
29
- /**
30
- * Error thrown when @Queue decorator is used incorrectly
31
- */
32
- export declare class QueueDecoratorError extends Error {
33
- constructor(message: string);
34
- }
35
- //# sourceMappingURL=queue.decorator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/queue.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAQpE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,GAAG,qBAAqB,GAAG,SAAS,CAEnF;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAEjD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B"}
@@ -1,49 +0,0 @@
1
- /**
2
- * @Queue decorator - marks a class as a queue definition
3
- */
4
- import 'reflect-metadata';
5
- import { METADATA_KEY } from '../constants.js';
6
- /**
7
- * Decorator to define a queue
8
- *
9
- * @param options - Queue configuration options
10
- * @returns ClassDecorator
11
- *
12
- * @example
13
- * ```typescript
14
- * @Queue({ name: 'email-queue' })
15
- * class EmailQueue {}
16
- * ```
17
- */
18
- export function Queue(options) {
19
- if (!options.name) {
20
- throw new QueueDecoratorError('Queue name is required');
21
- }
22
- return (target) => {
23
- Reflect.defineMetadata(METADATA_KEY.QUEUE_OPTIONS, options, target);
24
- };
25
- }
26
- /**
27
- * Get queue options from a decorated class
28
- * @param target - The decorated class
29
- */
30
- export function getQueueOptions(target) {
31
- return Reflect.getMetadata(METADATA_KEY.QUEUE_OPTIONS, target);
32
- }
33
- /**
34
- * Check if a class is decorated with @Queue
35
- * @param target - The class to check
36
- */
37
- export function isQueue(target) {
38
- return Reflect.hasMetadata(METADATA_KEY.QUEUE_OPTIONS, target);
39
- }
40
- /**
41
- * Error thrown when @Queue decorator is used incorrectly
42
- */
43
- export class QueueDecoratorError extends Error {
44
- constructor(message) {
45
- super(message);
46
- this.name = 'QueueDecoratorError';
47
- }
48
- }
49
- //# sourceMappingURL=queue.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.decorator.js","sourceRoot":"","sources":["../../src/decorators/queue.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,KAAK,CAAC,OAA8B;IAClD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAgB;IAC9C,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,MAAgB;IACtC,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
@@ -1,32 +0,0 @@
1
- /**
2
- * Queue events integration with Rikta's EventBus
3
- */
4
- /** Event names for queue events */
5
- export type QueueEventName = 'job:added' | 'job:completed' | 'job:failed' | 'job:progress' | 'job:stalled' | 'job:delayed' | 'job:removed' | 'worker:ready' | 'worker:closed' | 'worker:error';
6
- /** Event bus event names with prefix */
7
- export declare const QUEUE_EVENTS: {
8
- readonly JOB_ADDED: "queue:job:added";
9
- readonly JOB_COMPLETED: "queue:job:completed";
10
- readonly JOB_FAILED: "queue:job:failed";
11
- readonly JOB_PROGRESS: "queue:job:progress";
12
- readonly JOB_STALLED: "queue:job:stalled";
13
- readonly JOB_DELAYED: "queue:job:delayed";
14
- readonly JOB_REMOVED: "queue:job:removed";
15
- readonly WORKER_READY: "queue:worker:ready";
16
- readonly WORKER_CLOSED: "queue:worker:closed";
17
- readonly WORKER_ERROR: "queue:worker:error";
18
- };
19
- /**
20
- * Map internal event names to EventBus event names
21
- */
22
- export declare function getEventBusEventName(event: QueueEventName): string;
23
- /**
24
- * Publish a queue event to the EventBus
25
- *
26
- * @param eventBus - Rikta's EventBus instance
27
- * @param event - The event name
28
- * @param queueName - The queue name
29
- * @param args - Event arguments (job, result, error, etc.)
30
- */
31
- export declare function publishQueueEvent(eventBus: unknown, event: QueueEventName, queueName: string, ...args: unknown[]): Promise<void>;
32
- //# sourceMappingURL=queue-events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue-events.d.ts","sourceRoot":"","sources":["../../src/events/queue-events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,mCAAmC;AACnC,MAAM,MAAM,cAAc,GACtB,WAAW,GACX,eAAe,GACf,YAAY,GACZ,cAAc,GACd,aAAa,GACb,aAAa,GACb,aAAa,GACb,cAAc,GACd,eAAe,GACf,cAAc,CAAC;AAEnB,wCAAwC;AACxC,eAAO,MAAM,YAAY;;;;;;;;;;;CAWf,CAAC;AAEX;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAyBlE;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,MAAM,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,IAAI,CAAC,CASf"}
@@ -1,103 +0,0 @@
1
- /**
2
- * Queue events integration with Rikta's EventBus
3
- */
4
- /** Event bus event names with prefix */
5
- export const QUEUE_EVENTS = {
6
- JOB_ADDED: 'queue:job:added',
7
- JOB_COMPLETED: 'queue:job:completed',
8
- JOB_FAILED: 'queue:job:failed',
9
- JOB_PROGRESS: 'queue:job:progress',
10
- JOB_STALLED: 'queue:job:stalled',
11
- JOB_DELAYED: 'queue:job:delayed',
12
- JOB_REMOVED: 'queue:job:removed',
13
- WORKER_READY: 'queue:worker:ready',
14
- WORKER_CLOSED: 'queue:worker:closed',
15
- WORKER_ERROR: 'queue:worker:error',
16
- };
17
- /**
18
- * Map internal event names to EventBus event names
19
- */
20
- export function getEventBusEventName(event) {
21
- switch (event) {
22
- case 'job:added':
23
- return QUEUE_EVENTS.JOB_ADDED;
24
- case 'job:completed':
25
- return QUEUE_EVENTS.JOB_COMPLETED;
26
- case 'job:failed':
27
- return QUEUE_EVENTS.JOB_FAILED;
28
- case 'job:progress':
29
- return QUEUE_EVENTS.JOB_PROGRESS;
30
- case 'job:stalled':
31
- return QUEUE_EVENTS.JOB_STALLED;
32
- case 'job:delayed':
33
- return QUEUE_EVENTS.JOB_DELAYED;
34
- case 'job:removed':
35
- return QUEUE_EVENTS.JOB_REMOVED;
36
- case 'worker:ready':
37
- return QUEUE_EVENTS.WORKER_READY;
38
- case 'worker:closed':
39
- return QUEUE_EVENTS.WORKER_CLOSED;
40
- case 'worker:error':
41
- return QUEUE_EVENTS.WORKER_ERROR;
42
- default:
43
- return `queue:${event}`;
44
- }
45
- }
46
- /**
47
- * Publish a queue event to the EventBus
48
- *
49
- * @param eventBus - Rikta's EventBus instance
50
- * @param event - The event name
51
- * @param queueName - The queue name
52
- * @param args - Event arguments (job, result, error, etc.)
53
- */
54
- export async function publishQueueEvent(eventBus, event, queueName, ...args) {
55
- if (!eventBus || typeof eventBus.emit !== 'function') {
56
- return;
57
- }
58
- const eventName = getEventBusEventName(event);
59
- const payload = createEventPayload(event, queueName, args);
60
- await eventBus.emit(eventName, payload);
61
- }
62
- /**
63
- * Create an event payload from event arguments
64
- */
65
- function createEventPayload(event, queueName, args) {
66
- const base = {
67
- queueName,
68
- jobId: '',
69
- jobName: '',
70
- data: null,
71
- timestamp: Date.now(),
72
- };
73
- const job = args[0];
74
- if (typeof job === 'object' && job !== null) {
75
- base.jobId = job.id || '';
76
- base.jobName = job.name || '';
77
- base.data = job.data;
78
- }
79
- else if (typeof job === 'string') {
80
- // For stalled events, first arg is jobId
81
- base.jobId = job;
82
- }
83
- switch (event) {
84
- case 'job:completed':
85
- base.returnValue = args[1];
86
- break;
87
- case 'job:failed':
88
- base.error = args[1] instanceof Error
89
- ? args[1].message
90
- : String(args[1]);
91
- break;
92
- case 'job:progress':
93
- base.progress = args[1];
94
- break;
95
- case 'worker:error':
96
- base.error = args[0] instanceof Error
97
- ? args[0].message
98
- : String(args[0]);
99
- break;
100
- }
101
- return base;
102
- }
103
- //# sourceMappingURL=queue-events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue-events.js","sourceRoot":"","sources":["../../src/events/queue-events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiBH,wCAAwC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,iBAAiB;IAC5B,aAAa,EAAE,qBAAqB;IACpC,UAAU,EAAE,kBAAkB;IAC9B,YAAY,EAAE,oBAAoB;IAClC,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,mBAAmB;IAChC,YAAY,EAAE,oBAAoB;IAClC,aAAa,EAAE,qBAAqB;IACpC,YAAY,EAAE,oBAAoB;CAC1B,CAAC;AAEX;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAqB;IACxD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,WAAW;YACd,OAAO,YAAY,CAAC,SAAS,CAAC;QAChC,KAAK,eAAe;YAClB,OAAO,YAAY,CAAC,aAAa,CAAC;QACpC,KAAK,YAAY;YACf,OAAO,YAAY,CAAC,UAAU,CAAC;QACjC,KAAK,cAAc;YACjB,OAAO,YAAY,CAAC,YAAY,CAAC;QACnC,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC,WAAW,CAAC;QAClC,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC,WAAW,CAAC;QAClC,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC,WAAW,CAA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AC3C,OAAO,EACL,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAG1C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,6BAA6B,CAAC;AAG5C,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,cAAc,4BAA4B,CAAC;AAG3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
@@ -1,77 +0,0 @@
1
- /**
2
- * Bull Board integration for queue monitoring
3
- *
4
- * This module provides optional Bull Board dashboard integration.
5
- * Bull Board packages are NOT included as dependencies - install them separately:
6
- *
7
- * npm install @bull-board/api @bull-board/fastify
8
- *
9
- * @example
10
- * ```typescript
11
- * import { registerBullBoard } from '@riktajs/queue';
12
- *
13
- * // In your Rikta bootstrap:
14
- * const app = await Rikta.create();
15
- *
16
- * // After queue provider is initialized:
17
- * await registerBullBoard(app.server, {
18
- * queues: queueProvider.getAllQueues(),
19
- * path: '/admin/queues',
20
- * auth: async (req) => {
21
- * // Your auth logic here
22
- * return req.headers.authorization === 'Bearer secret';
23
- * },
24
- * });
25
- * ```
26
- */
27
- import type { FastifyInstance, FastifyRequest } from 'fastify';
28
- import type { Queue } from 'bullmq';
29
- /** Options for Bull Board registration */
30
- export interface BullBoardOptions {
31
- /** Queues to display in the dashboard */
32
- queues: Queue[];
33
- /** Base path for the dashboard (default: '/admin/queues') */
34
- path?: string;
35
- /** Authentication function - return true to allow access */
36
- auth?: (request: FastifyRequest) => boolean | Promise<boolean>;
37
- /** Whether to use read-only mode */
38
- readOnly?: boolean;
39
- }
40
- /** Result of Bull Board registration */
41
- export interface BullBoardResult {
42
- /** The path where the dashboard is mounted */
43
- path: string;
44
- /** Function to add more queues dynamically */
45
- addQueue: (queue: Queue) => void;
46
- /** Function to remove a queue from the dashboard */
47
- removeQueue: (queueName: string) => void;
48
- }
49
- /**
50
- * Register Bull Board dashboard with Fastify
51
- *
52
- * @param app - Fastify instance
53
- * @param options - Dashboard configuration
54
- * @returns Bull Board control object
55
- *
56
- * @throws BullBoardNotInstalledError if @bull-board packages are not installed
57
- *
58
- * @example
59
- * ```typescript
60
- * const board = await registerBullBoard(app.server, {
61
- * queues: queueProvider.getAllQueues(),
62
- * path: '/admin/queues',
63
- * auth: (req) => checkAdminAuth(req),
64
- * });
65
- *
66
- * // Add more queues later
67
- * board.addQueue(newQueue);
68
- * ```
69
- */
70
- export declare function registerBullBoard(app: FastifyInstance, options: BullBoardOptions): Promise<BullBoardResult>;
71
- /**
72
- * Error thrown when Bull Board packages are not installed
73
- */
74
- export declare class BullBoardNotInstalledError extends Error {
75
- constructor();
76
- }
77
- //# sourceMappingURL=bull-board.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bull-board.d.ts","sourceRoot":"","sources":["../../src/monitoring/bull-board.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,oDAAoD;IACpD,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CA+D1B;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;;CAQpD"}
@@ -1,112 +0,0 @@
1
- /**
2
- * Bull Board integration for queue monitoring
3
- *
4
- * This module provides optional Bull Board dashboard integration.
5
- * Bull Board packages are NOT included as dependencies - install them separately:
6
- *
7
- * npm install @bull-board/api @bull-board/fastify
8
- *
9
- * @example
10
- * ```typescript
11
- * import { registerBullBoard } from '@riktajs/queue';
12
- *
13
- * // In your Rikta bootstrap:
14
- * const app = await Rikta.create();
15
- *
16
- * // After queue provider is initialized:
17
- * await registerBullBoard(app.server, {
18
- * queues: queueProvider.getAllQueues(),
19
- * path: '/admin/queues',
20
- * auth: async (req) => {
21
- * // Your auth logic here
22
- * return req.headers.authorization === 'Bearer secret';
23
- * },
24
- * });
25
- * ```
26
- */
27
- /**
28
- * Register Bull Board dashboard with Fastify
29
- *
30
- * @param app - Fastify instance
31
- * @param options - Dashboard configuration
32
- * @returns Bull Board control object
33
- *
34
- * @throws BullBoardNotInstalledError if @bull-board packages are not installed
35
- *
36
- * @example
37
- * ```typescript
38
- * const board = await registerBullBoard(app.server, {
39
- * queues: queueProvider.getAllQueues(),
40
- * path: '/admin/queues',
41
- * auth: (req) => checkAdminAuth(req),
42
- * });
43
- *
44
- * // Add more queues later
45
- * board.addQueue(newQueue);
46
- * ```
47
- */
48
- export async function registerBullBoard(app, options) {
49
- const { queues, path = '/admin/queues', auth, readOnly = false } = options;
50
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- let createBullBoard;
52
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
- let BullMQAdapter;
54
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- let FastifyAdapter;
56
- try {
57
- // Dynamic imports - these will fail if packages not installed
58
- // Use require for better compatibility
59
- createBullBoard = require('@bull-board/api').createBullBoard;
60
- FastifyAdapter = require('@bull-board/fastify').FastifyAdapter;
61
- BullMQAdapter = require('@bull-board/api/bullMQAdapter').BullMQAdapter;
62
- }
63
- catch {
64
- throw new BullBoardNotInstalledError();
65
- }
66
- // Create adapters for all queues
67
- const queueAdapters = queues.map(queue => new BullMQAdapter(queue, { readOnlyMode: readOnly }));
68
- // Create the server adapter
69
- const serverAdapter = new FastifyAdapter();
70
- serverAdapter.setBasePath(path);
71
- // Create Bull Board
72
- const board = createBullBoard({
73
- queues: queueAdapters,
74
- serverAdapter,
75
- });
76
- // Add auth hook if provided
77
- if (auth) {
78
- app.addHook('preHandler', async (request, reply) => {
79
- const url = request.url;
80
- if (url.startsWith(path)) {
81
- const isAuthorized = await auth(request);
82
- if (!isAuthorized) {
83
- reply.code(403).send({ error: 'Forbidden' });
84
- }
85
- }
86
- });
87
- }
88
- // Register the plugin
89
- await app.register(serverAdapter.registerPlugin(), { basePath: path, prefix: path });
90
- console.log(`📊 Bull Board: Dashboard available at ${path}`);
91
- return {
92
- path,
93
- addQueue: (queue) => {
94
- const adapter = new BullMQAdapter(queue, { readOnlyMode: readOnly });
95
- board.addQueue(adapter);
96
- },
97
- removeQueue: (queueName) => {
98
- board.removeQueue(queueName);
99
- },
100
- };
101
- }
102
- /**
103
- * Error thrown when Bull Board packages are not installed
104
- */
105
- export class BullBoardNotInstalledError extends Error {
106
- constructor() {
107
- super('Bull Board packages are not installed. ' +
108
- 'Install them with: npm install @bull-board/api @bull-board/fastify');
109
- this.name = 'BullBoardNotInstalledError';
110
- }
111
- }
112
- //# sourceMappingURL=bull-board.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bull-board.js","source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ecycle integration.
5
- * Not @Injectable - use createQueueProvider() factory function.
6
- */
7
- import type { OnProviderInit, OnProviderDestroy } from '@riktajs/core';
8
- import { Queue } from 'bullmq';
9
- import type { QueueProviderOptions, QueueConfig } from '../types.js';
10
- /**
11
- * QueueProvider manages the lifecycle of all queues and workers.
12
- *
13
- * @example
14
- * ```typescript
15
- * const provider = createQueueProvider({
16
- * config: { redis: { host: 'localhost', port: 6379 } }
17
- * });
18
- *
19
- * // In Rikta bootstrap:
20
- * await app.register(provider);
21
- * ```
22
- */
23
- export declare class QueueProvider implements OnProviderInit, OnProviderDestroy {
24
- private connectionManager;
25
- private config;
26
- private queues;
27
- private workers;
28
- private processorClasses;
29
- private initialized;
30
- private eventBus;
31
- private options;
32
- /**
33
- * Configure the provider with options
34
- */
35
- configure(options: QueueProviderOptions): this;
36
- /**
37
- * Register processor classes for auto-discovery
38
- */
39
- registerProcessors(...processors: Function[]): this;
40
- /**
41
- * Set EventBus for event emission (optional)
42
- */
43
- setEventBus(eventBus: unknown): this;
44
- /**
45
- * Initialize all queues and workers (called by Rikta lifecycle)
46
- */
47
- onProviderInit(): Promise<void>;
48
- /**
49
- * Gracefully shutdown all workers and close connections
50
- */
51
- onProviderDestroy(): Promise<void>;
52
- /**
53
- * Get a queue by name
54
- */
55
- getQueue(name: string): Queue | undefined;
56
- /**
57
- * Get all registered queues
58
- */
59
- getAllQueues(): Queue[];
60
- /**
61
- * Check if the provider is initialized
62
- */
63
- isInitialized(): boolean;
64
- /**
65
- * Get configuration
66
- */
67
- getConfig(): QueueConfig;
68
- private testConnection;
69
- private discoverAndRegisterProcessors;
70
- private registerProcessor;
71
- private createQueue;
72
- private attachWorkerEvents;
73
- private handleEvent;
74
- /**
75
- * Create a processor instance using the DI Container to support @Autowired
76
- */
77
- private createProcessorInstance;
78
- /**
79
- * Register QueueProvider and QueueService in the DI container.
80
- * Called early so processors can inject QueueService via @Autowired.
81
- * Individual queues and workers are registered as they are created.
82
- */
83
- private registerInContainer;
84
- /**
85
- * Register a queue and its worker in the DI container.
86
- * Called when a queue is created during processor registration.
87
- */
88
- private registerQueueInContainer;
89
- /**
90
- * Register a worker in the DI container.
91
- * Called when a worker is created during processor registration.
92
- */
93
- private registerWorkerInContainer;
94
- private delay;
95
- }
96
- /**
97
- * Factory function to create a QueueProvider
98
- */
99
- export declare function createQueueProvider(options?: QueueProviderOptions): QueueProvider;
100
- /**
101
- * Error thrown when queue initialization fails
102
- */
103
- export declare class QueueInitializationError extends Error {
104
- readonly cause?: Error | undefined;
105
- constructor(message: string, cause?: Error | undefined);
106
- }
107
- /**
108
- * Error thrown when a duplicate queue is detected
109
- */
110
- export declare class DuplicateQueueError extends Error {
111
- constructor(queueName: string);
112
- }
113
- //# sourceMappingURL=queue.provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.provider.d.ts","sourceRoot":"","sources":["../../src/providers/queue.provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,KAAK,EAAuB,MAAM,QAAQ,CAAC;AAOpD,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EAGZ,MAAM,aAAa,CAAC;AAwBrB;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,YAAW,cAAc,EAAE,iBAAiB;IACrE,OAAO,CAAC,iBAAiB,CAAgC;IACzD,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IAEjC,OAAO,CAAC,OAAO,CAIb;IAEF;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAK9C;;OAEG;IACH,kBAAkB,CAAC,GAAG,UAAU,EAAE,QAAQ,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