@riktajs/queue 0.5.0 → 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.
- package/dist/index.cjs +16251 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +946 -0
- package/dist/index.d.ts +945 -21
- package/dist/index.js +16177 -29
- package/dist/index.js.map +1 -1
- package/package.json +82 -75
- package/dist/config/queue.config.d.ts +0 -43
- package/dist/config/queue.config.d.ts.map +0 -1
- package/dist/config/queue.config.js +0 -82
- package/dist/config/queue.config.js.map +0 -1
- package/dist/constants.d.ts +0 -33
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -37
- package/dist/constants.js.map +0 -1
- package/dist/decorators/events.decorator.d.ts +0 -85
- package/dist/decorators/events.decorator.d.ts.map +0 -1
- package/dist/decorators/events.decorator.js +0 -120
- package/dist/decorators/events.decorator.js.map +0 -1
- package/dist/decorators/index.d.ts +0 -8
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/decorators/index.js +0 -8
- package/dist/decorators/index.js.map +0 -1
- package/dist/decorators/process.decorator.d.ts +0 -41
- package/dist/decorators/process.decorator.d.ts.map +0 -1
- package/dist/decorators/process.decorator.js +0 -61
- package/dist/decorators/process.decorator.js.map +0 -1
- package/dist/decorators/processor.decorator.d.ts +0 -41
- package/dist/decorators/processor.decorator.d.ts.map +0 -1
- package/dist/decorators/processor.decorator.js +0 -59
- package/dist/decorators/processor.decorator.js.map +0 -1
- package/dist/decorators/queue.decorator.d.ts +0 -35
- package/dist/decorators/queue.decorator.d.ts.map +0 -1
- package/dist/decorators/queue.decorator.js +0 -49
- package/dist/decorators/queue.decorator.js.map +0 -1
- package/dist/events/queue-events.d.ts +0 -32
- package/dist/events/queue-events.d.ts.map +0 -1
- package/dist/events/queue-events.js +0 -103
- package/dist/events/queue-events.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/monitoring/bull-board.d.ts +0 -77
- package/dist/monitoring/bull-board.d.ts.map +0 -1
- package/dist/monitoring/bull-board.js +0 -112
- package/dist/monitoring/bull-board.js.map +0 -1
- package/dist/providers/queue.provider.d.ts +0 -113
- package/dist/providers/queue.provider.d.ts.map +0 -1
- package/dist/providers/queue.provider.js +0 -383
- package/dist/providers/queue.provider.js.map +0 -1
- package/dist/services/queue.service.d.ts +0 -133
- package/dist/services/queue.service.d.ts.map +0 -1
- package/dist/services/queue.service.js +0 -192
- package/dist/services/queue.service.js.map +0 -1
- package/dist/types.d.ts +0 -133
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/utils/connection.d.ts +0 -47
- package/dist/utils/connection.d.ts.map +0 -1
- package/dist/utils/connection.js +0 -102
- package/dist/utils/connection.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -137
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -156
- package/dist/utils/validation.js.map +0 -1
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Process decorator - marks a method as a job handler
|
|
3
|
-
*/
|
|
4
|
-
import 'reflect-metadata';
|
|
5
|
-
import { METADATA_KEY } from '../constants.js';
|
|
6
|
-
/**
|
|
7
|
-
* Decorator to define a job handler method
|
|
8
|
-
*
|
|
9
|
-
* @param jobName - The name of the job to handle (default: method name)
|
|
10
|
-
* @returns MethodDecorator
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* @Processor('email-queue')
|
|
15
|
-
* class EmailProcessor {
|
|
16
|
-
* @Process('send')
|
|
17
|
-
* async handleSendEmail(job: Job<EmailData>) {
|
|
18
|
-
* await sendEmail(job.data);
|
|
19
|
-
* return { sent: true };
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* @Process() // Uses method name as job name
|
|
23
|
-
* async welcome(job: Job<WelcomeData>) {
|
|
24
|
-
* // ...
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export function Process(jobName) {
|
|
30
|
-
return (target, propertyKey, _descriptor) => {
|
|
31
|
-
const methodName = String(propertyKey);
|
|
32
|
-
const name = jobName || methodName;
|
|
33
|
-
// Get existing handlers or create new array
|
|
34
|
-
const existingHandlers = Reflect.getMetadata(METADATA_KEY.JOB_HANDLERS, target.constructor) || [];
|
|
35
|
-
// Add this handler
|
|
36
|
-
const handler = {
|
|
37
|
-
name,
|
|
38
|
-
methodName,
|
|
39
|
-
};
|
|
40
|
-
existingHandlers.push(handler);
|
|
41
|
-
// Store updated handlers
|
|
42
|
-
Reflect.defineMetadata(METADATA_KEY.JOB_HANDLERS, existingHandlers, target.constructor);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get all job handlers from a processor class
|
|
47
|
-
* @param target - The processor class
|
|
48
|
-
*/
|
|
49
|
-
export function getJobHandlers(target) {
|
|
50
|
-
return Reflect.getMetadata(METADATA_KEY.JOB_HANDLERS, target) || [];
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Check if a method is decorated with @Process
|
|
54
|
-
* @param target - The class
|
|
55
|
-
* @param methodName - The method name
|
|
56
|
-
*/
|
|
57
|
-
export function isJobHandler(target, methodName) {
|
|
58
|
-
const handlers = getJobHandlers(target);
|
|
59
|
-
return handlers.some(h => h.methodName === methodName);
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=process.decorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process.decorator.js","sourceRoot":"","sources":["../../src/decorators/process.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,OAAO,CAAC,OAAgB;IACtC,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,WAA+B,EAC/B,EAAE;QACF,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,OAAO,IAAI,UAAU,CAAC;QAEnC,4CAA4C;QAC5C,MAAM,gBAAgB,GACpB,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAE3E,mBAAmB;QACnB,MAAM,OAAO,GAAmB;YAC9B,IAAI;YACJ,UAAU;SACX,CAAC;QAEF,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/B,yBAAyB;QACzB,OAAO,CAAC,cAAc,CACpB,YAAY,CAAC,YAAY,EACzB,gBAAgB,EAChB,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAgB;IAC7C,OAAO,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAgB,EAAE,UAAkB;IAC/D,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Processor decorator - marks a class as a job processor
|
|
3
|
-
*/
|
|
4
|
-
import 'reflect-metadata';
|
|
5
|
-
import type { ProcessorOptions } from '../types.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 declare function Processor(queueName: string, options?: Omit<ProcessorOptions, 'queueName'>): ClassDecorator;
|
|
25
|
-
/**
|
|
26
|
-
* Get processor options from a decorated class
|
|
27
|
-
* @param target - The decorated class
|
|
28
|
-
*/
|
|
29
|
-
export declare function getProcessorOptions(target: Function): ProcessorOptions | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Check if a class is decorated with @Processor
|
|
32
|
-
* @param target - The class to check
|
|
33
|
-
*/
|
|
34
|
-
export declare function isProcessor(target: Function): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Error thrown when @Processor decorator is used incorrectly
|
|
37
|
-
*/
|
|
38
|
-
export declare class ProcessorDecoratorError extends Error {
|
|
39
|
-
constructor(message: string);
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=processor.decorator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processor.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/processor.decorator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAC5C,cAAc,CAahB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAElF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -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,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,CAAC,CAAC,CAAC,YAAY,KAAK;gBACnC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO;gBACjB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACpB,MAAM;IACV,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,gBAAgB,CAAC;AAG/B,cAAc,YAAY,CAAC;AAG3B,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,KAAK,EACL,eAAe,EACf,OAAO,EACP,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,uBAAuB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,OAAO,EACP,cAAc,EACd,YAAY,GACb,MAAM,mCAAmC,CAAC;AAC3C,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","sourceRoot":"","sources":["../../src/monitoring/bull-board.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AA2BH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KA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