@nest-boot/bullmq 7.2.0 → 8.0.0-beta.0
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/bullmq-module-options.interface.js +1 -2
- package/dist/bullmq.module-definition.d.ts +1 -1
- package/dist/bullmq.module-definition.js +7 -11
- package/dist/bullmq.module-definition.js.map +1 -1
- package/dist/bullmq.module.d.ts +1 -1
- package/dist/bullmq.module.js +17 -20
- package/dist/bullmq.module.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -25
- package/dist/index.js.map +1 -1
- package/dist/processor.decorator.d.ts +2 -2
- package/dist/processor.decorator.js +7 -10
- package/dist/processor.decorator.js.map +1 -1
- package/dist/utils/load-config-from-env.util.js +1 -4
- package/dist/utils/load-config-from-env.util.js.map +1 -1
- package/package.json +21 -24
- package/dist/bullmq.module.spec.d.ts +0 -1
- package/dist/bullmq.module.spec.js +0 -117
- package/dist/bullmq.module.spec.js.map +0 -1
- package/dist/index.spec.d.ts +0 -1
- package/dist/index.spec.js +0 -47
- package/dist/index.spec.js.map +0 -1
- package/dist/processor.decorator.spec.d.ts +0 -1
- package/dist/processor.decorator.spec.js +0 -57
- package/dist/processor.decorator.spec.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/utils/load-config-from-env.util.spec.d.ts +0 -1
- package/dist/utils/load-config-from-env.util.spec.js +0 -57
- package/dist/utils/load-config-from-env.util.spec.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BullModuleOptions } from "./bullmq-module-options.interface";
|
|
1
|
+
import { BullModuleOptions } from "./bullmq-module-options.interface.js";
|
|
2
2
|
export declare const SCHEDULE_QUEUE_NAME = "schedule";
|
|
3
3
|
export declare const SCHEDULE_METADATA_KEY: `${string}-${string}-${string}-${string}-${string}`;
|
|
4
4
|
export declare const MODULE_OPTIONS_TOKEN: unique symbol;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
exports.SCHEDULE_QUEUE_NAME = "schedule";
|
|
8
|
-
exports.SCHEDULE_METADATA_KEY = (0, crypto_1.randomUUID)();
|
|
9
|
-
exports.MODULE_OPTIONS_TOKEN = Symbol("BullModuleOptions");
|
|
10
|
-
_a = new common_1.ConfigurableModuleBuilder()
|
|
1
|
+
import { ConfigurableModuleBuilder } from "@nestjs/common";
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
3
|
+
export const SCHEDULE_QUEUE_NAME = "schedule";
|
|
4
|
+
export const SCHEDULE_METADATA_KEY = randomUUID();
|
|
5
|
+
export const MODULE_OPTIONS_TOKEN = Symbol("BullModuleOptions");
|
|
6
|
+
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN: BASE_MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE, } = new ConfigurableModuleBuilder()
|
|
11
7
|
.setClassMethodName("forRoot")
|
|
12
|
-
.build()
|
|
8
|
+
.build();
|
|
13
9
|
//# sourceMappingURL=bullmq.module-definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullmq.module-definition.js","sourceRoot":"","sources":["../src/bullmq.module-definition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bullmq.module-definition.js","sourceRoot":"","sources":["../src/bullmq.module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAIpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,EAAE,CAAC;AAElD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,EACX,uBAAuB,EACvB,oBAAoB,EAAE,yBAAyB,EAC/C,YAAY,EACZ,kBAAkB,GACnB,GAAG,IAAI,yBAAyB,EAAqB;KACnD,kBAAkB,CAAC,SAAS,CAAC;KAC7B,KAAK,EAAE,CAAC"}
|
package/dist/bullmq.module.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BullModule as BaseBullModule } from "@nestjs/bullmq";
|
|
2
2
|
import { type DynamicModule } from "@nestjs/common";
|
|
3
|
-
import { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, OPTIONS_TYPE } from "./bullmq.module-definition";
|
|
3
|
+
import { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, OPTIONS_TYPE } from "./bullmq.module-definition.js";
|
|
4
4
|
/**
|
|
5
5
|
* BullMQ integration module for job queue processing.
|
|
6
6
|
*
|
package/dist/bullmq.module.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const bullmq_module_definition_1 = require("./bullmq.module-definition");
|
|
13
|
-
const load_config_from_env_util_1 = require("./utils/load-config-from-env.util");
|
|
7
|
+
import { BullModule as BaseBullModule } from "@nestjs/bullmq";
|
|
8
|
+
import { Global, Module } from "@nestjs/common";
|
|
9
|
+
import { BASE_MODULE_OPTIONS_TOKEN, ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, } from "./bullmq.module-definition.js";
|
|
10
|
+
import { loadConfigFromEnv } from "./utils/load-config-from-env.util.js";
|
|
14
11
|
/**
|
|
15
12
|
* BullMQ integration module for job queue processing.
|
|
16
13
|
*
|
|
@@ -18,7 +15,7 @@ const load_config_from_env_util_1 = require("./utils/load-config-from-env.util")
|
|
|
18
15
|
* Wraps `@nestjs/bullmq` with automatic Redis connection configuration
|
|
19
16
|
* from environment variables. Supports registering queues and flow producers.
|
|
20
17
|
*/
|
|
21
|
-
let BullModule = class BullModule extends
|
|
18
|
+
let BullModule = class BullModule extends ConfigurableModuleClass {
|
|
22
19
|
/**
|
|
23
20
|
* Registers the BullModule with the given options.
|
|
24
21
|
* @param options - Configuration options including Redis connection
|
|
@@ -41,7 +38,7 @@ let BullModule = class BullModule extends bullmq_module_definition_1.Configurabl
|
|
|
41
38
|
* @returns Dynamic module configuration
|
|
42
39
|
*/
|
|
43
40
|
static registerQueue(...args) {
|
|
44
|
-
return
|
|
41
|
+
return BaseBullModule.registerQueue(...args);
|
|
45
42
|
}
|
|
46
43
|
/**
|
|
47
44
|
* Registers a BullMQ queue asynchronously.
|
|
@@ -49,32 +46,32 @@ let BullModule = class BullModule extends bullmq_module_definition_1.Configurabl
|
|
|
49
46
|
* @returns Dynamic module configuration
|
|
50
47
|
*/
|
|
51
48
|
static registerQueueAsync(...args) {
|
|
52
|
-
return
|
|
49
|
+
return BaseBullModule.registerQueueAsync(...args);
|
|
53
50
|
}
|
|
54
51
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(
|
|
58
|
-
(0, common_1.Module)({
|
|
52
|
+
BullModule = __decorate([
|
|
53
|
+
Global(),
|
|
54
|
+
Module({
|
|
59
55
|
imports: [
|
|
60
|
-
|
|
61
|
-
inject: [
|
|
56
|
+
BaseBullModule.forRootAsync({
|
|
57
|
+
inject: [MODULE_OPTIONS_TOKEN],
|
|
62
58
|
useFactory: (options) => {
|
|
63
59
|
return {
|
|
64
60
|
...options,
|
|
65
|
-
connection: options.connection ??
|
|
61
|
+
connection: options.connection ?? loadConfigFromEnv(),
|
|
66
62
|
};
|
|
67
63
|
},
|
|
68
64
|
}),
|
|
69
65
|
],
|
|
70
66
|
providers: [
|
|
71
67
|
{
|
|
72
|
-
provide:
|
|
73
|
-
inject: [{ token:
|
|
68
|
+
provide: MODULE_OPTIONS_TOKEN,
|
|
69
|
+
inject: [{ token: BASE_MODULE_OPTIONS_TOKEN, optional: true }],
|
|
74
70
|
useFactory: (options) => options ?? {},
|
|
75
71
|
},
|
|
76
72
|
],
|
|
77
|
-
exports: [
|
|
73
|
+
exports: [MODULE_OPTIONS_TOKEN],
|
|
78
74
|
})
|
|
79
75
|
], BullModule);
|
|
76
|
+
export { BullModule };
|
|
80
77
|
//# sourceMappingURL=bullmq.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullmq.module.js","sourceRoot":"","sources":["../src/bullmq.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bullmq.module.js","sourceRoot":"","sources":["../src/bullmq.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAsB,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAEL,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,GAErB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE;;;;;;GAMG;AAuBI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,uBAAuB;IACrD;;;;OAIG;IACH,MAAM,CAAU,OAAO,CAAC,OAA4B;QAClD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAU,YAAY,CAC1B,OAAkC;QAElC,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAClB,GAAG,IAAqD;QAExD,OAAO,cAAc,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CACvB,GAAG,IAA0D;QAE7D,OAAO,cAAc,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,CAAC;IACpD,CAAC;CACF,CAAA;AA1CY,UAAU;IAtBtB,MAAM,EAAE;IACR,MAAM,CAAC;QACN,OAAO,EAAE;YACP,cAAc,CAAC,YAAY,CAAC;gBAC1B,MAAM,EAAE,CAAC,oBAAoB,CAAC;gBAC9B,UAAU,EAAE,CAAC,OAA0B,EAAE,EAAE;oBACzC,OAAO;wBACL,GAAG,OAAO;wBACV,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,iBAAiB,EAAE;qBACtD,CAAC;gBACJ,CAAC;aACF,CAAC;SACH;QACD,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,oBAAoB;gBAC7B,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBAC9D,UAAU,EAAE,CAAC,OAA2B,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE;aAC3D;SACF;QACD,OAAO,EAAE,CAAC,oBAAoB,CAAC;KAChC,CAAC;GACW,UAAU,CA0CtB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { BullModule } from "./bullmq.module";
|
|
2
|
-
export * from "./bullmq-module-options.interface";
|
|
3
|
-
export { Processor } from "./processor.decorator";
|
|
1
|
+
export { BullModule } from "./bullmq.module.js";
|
|
2
|
+
export * from "./bullmq-module-options.interface.js";
|
|
3
|
+
export { Processor } from "./processor.decorator.js";
|
|
4
4
|
export * from "@nestjs/bullmq";
|
|
5
5
|
export { QueueEventsListener } from "@nestjs/bullmq";
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.QueueEventsListener = exports.Processor = exports.BullModule = void 0;
|
|
18
|
-
var bullmq_module_1 = require("./bullmq.module");
|
|
19
|
-
Object.defineProperty(exports, "BullModule", { enumerable: true, get: function () { return bullmq_module_1.BullModule; } });
|
|
20
|
-
__exportStar(require("./bullmq-module-options.interface"), exports);
|
|
21
|
-
var processor_decorator_1 = require("./processor.decorator");
|
|
22
|
-
Object.defineProperty(exports, "Processor", { enumerable: true, get: function () { return processor_decorator_1.Processor; } });
|
|
23
|
-
__exportStar(require("@nestjs/bullmq"), exports);
|
|
24
|
-
var bullmq_1 = require("@nestjs/bullmq");
|
|
25
|
-
Object.defineProperty(exports, "QueueEventsListener", { enumerable: true, get: function () { return bullmq_1.QueueEventsListener; } });
|
|
1
|
+
export { BullModule } from "./bullmq.module.js";
|
|
2
|
+
export * from "./bullmq-module-options.interface.js";
|
|
3
|
+
export { Processor } from "./processor.decorator.js";
|
|
4
|
+
export * from "@nestjs/bullmq";
|
|
5
|
+
export { QueueEventsListener } from "@nestjs/bullmq";
|
|
26
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ProcessorOptions } from "@nestjs/bullmq";
|
|
2
|
-
import { NestWorkerOptions } from "@nestjs/bullmq/dist/interfaces/worker-options.interface";
|
|
1
|
+
import { type ProcessorOptions } from "@nestjs/bullmq";
|
|
2
|
+
import { type NestWorkerOptions } from "@nestjs/bullmq/dist/interfaces/worker-options.interface.js";
|
|
3
3
|
/**
|
|
4
4
|
* Decorator that marks a class as a BullMQ queue processor.
|
|
5
5
|
*
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const bullmq_1 = require("@nestjs/bullmq");
|
|
7
|
-
function Processor(queueNameOrOptions, maybeWorkerOptions) {
|
|
2
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
3
|
+
import { JOB_REF, Processor as BaseProcessor, } from "@nestjs/bullmq";
|
|
4
|
+
export function Processor(queueNameOrOptions, maybeWorkerOptions) {
|
|
8
5
|
return (target) => {
|
|
9
6
|
const originalProcess = target.prototype.process;
|
|
10
7
|
if (originalProcess) {
|
|
11
8
|
target.prototype.process = async function (job) {
|
|
12
|
-
const ctx = new
|
|
9
|
+
const ctx = new RequestContext({
|
|
13
10
|
id: job.id,
|
|
14
11
|
type: "queue",
|
|
15
12
|
});
|
|
16
|
-
ctx.set(
|
|
17
|
-
return await
|
|
13
|
+
ctx.set(JOB_REF, job);
|
|
14
|
+
return await RequestContext.run(ctx, () => originalProcess.call(this, job));
|
|
18
15
|
};
|
|
19
16
|
}
|
|
20
|
-
(
|
|
17
|
+
BaseProcessor(queueNameOrOptions, maybeWorkerOptions)(target);
|
|
21
18
|
};
|
|
22
19
|
}
|
|
23
20
|
//# sourceMappingURL=processor.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor.decorator.js","sourceRoot":"","sources":["../src/processor.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processor.decorator.js","sourceRoot":"","sources":["../src/processor.decorator.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,OAAO,EACP,SAAS,IAAI,aAAa,GAG3B,MAAM,gBAAgB,CAAC;AA6CxB,MAAM,UAAU,SAAS,CACvB,kBAA8C,EAC9C,kBAAsC;IAEtC,OAAO,CAAC,MAA2B,EAAE,EAAE;QACrC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;QACjD,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,WAAW,GAAQ;gBACjD,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC;oBAC7B,EAAE,EAAE,GAAG,CAAC,EAAE;oBACV,IAAI,EAAE,OAAO;iBACd,CAAC,CAAC;gBAEH,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAEtB,OAAO,MAAM,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CACxC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAChC,CAAC;YACJ,CAAC,CAAC;QACJ,CAAC;QAED,aAAa,CAAC,kBAAyB,EAAE,kBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadConfigFromEnv = loadConfigFromEnv;
|
|
4
|
-
function loadConfigFromEnv() {
|
|
1
|
+
export function loadConfigFromEnv() {
|
|
5
2
|
if (process.env.REDIS_URL) {
|
|
6
3
|
const url = new URL(process.env.REDIS_URL);
|
|
7
4
|
const port = url.port;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config-from-env.util.js","sourceRoot":"","sources":["../../src/utils/load-config-from-env.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-config-from-env.util.js","sourceRoot":"","sources":["../../src/utils/load-config-from-env.util.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5C,OAAO;YACL,IAAI,EAAE,GAAG,CAAC,QAAQ;YAClB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YAC9B,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACpC,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,GAAG,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IACpC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IACtE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IACtE,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAEpC,OAAO;QACL,IAAI;QACJ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtC,QAAQ;QACR,QAAQ;QACR,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5B,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-boot/bullmq",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nest-boot/nest-boot.git",
|
|
@@ -25,32 +25,31 @@
|
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@nestjs/bullmq": "^11.0.4",
|
|
28
|
-
"@nestjs/common": "
|
|
29
|
-
"@nestjs/core": "
|
|
30
|
-
"@nestjs/testing": "
|
|
31
|
-
"@types/
|
|
32
|
-
"@
|
|
28
|
+
"@nestjs/common": "next",
|
|
29
|
+
"@nestjs/core": "next",
|
|
30
|
+
"@nestjs/testing": "next",
|
|
31
|
+
"@types/node": "^26.0.0",
|
|
32
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
33
33
|
"bullmq": "^5.61.0",
|
|
34
34
|
"dotenv": "^17.2.3",
|
|
35
35
|
"eslint": "^9.39.3",
|
|
36
|
-
"jest": "^29.7.0",
|
|
37
36
|
"reflect-metadata": "^0.2.2",
|
|
38
37
|
"rxjs": "^7.8.2",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"@nest-boot/eslint-
|
|
42
|
-
"@nest-boot/
|
|
43
|
-
"@nest-boot/
|
|
44
|
-
"@nest-boot/tsconfig": "^
|
|
38
|
+
"typescript": "^6.0.3",
|
|
39
|
+
"vitest": "^4.1.2",
|
|
40
|
+
"@nest-boot/eslint-plugin": "^8.0.0-beta.0",
|
|
41
|
+
"@nest-boot/request-context": "^8.0.0-beta.0",
|
|
42
|
+
"@nest-boot/eslint-config": "^8.0.0-beta.0",
|
|
43
|
+
"@nest-boot/tsconfig": "^8.0.0-beta.0"
|
|
45
44
|
},
|
|
46
45
|
"peerDependencies": {
|
|
47
|
-
"@nest-boot/request-context": "^7.4.3",
|
|
48
46
|
"@nestjs/bullmq": "^11.0.0",
|
|
49
|
-
"@nestjs/common": "^
|
|
50
|
-
"@nestjs/core": "^
|
|
47
|
+
"@nestjs/common": "^12.0.0-alpha.5",
|
|
48
|
+
"@nestjs/core": "^12.0.0-alpha.5",
|
|
51
49
|
"bullmq": "^5.0.0",
|
|
52
50
|
"reflect-metadata": "^0.2.2",
|
|
53
|
-
"rxjs": "^7.0.0"
|
|
51
|
+
"rxjs": "^7.0.0",
|
|
52
|
+
"@nest-boot/request-context": "^8.0.0-beta.0"
|
|
54
53
|
},
|
|
55
54
|
"publishConfig": {
|
|
56
55
|
"access": "public"
|
|
@@ -61,18 +60,16 @@
|
|
|
61
60
|
"eslint --fix"
|
|
62
61
|
]
|
|
63
62
|
},
|
|
64
|
-
"
|
|
65
|
-
"extends": "../../package.json"
|
|
66
|
-
},
|
|
63
|
+
"type": "module",
|
|
67
64
|
"scripts": {
|
|
68
65
|
"build": "tsc -p tsconfig.build.json",
|
|
69
66
|
"clean": "rm -rf .nx && rm -rf node_modules && rm -rf dist",
|
|
70
67
|
"dev": "tsc -w -p tsconfig.build.json",
|
|
71
68
|
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
72
69
|
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
73
|
-
"test": "
|
|
74
|
-
"test:cov": "
|
|
75
|
-
"test:watch": "
|
|
76
|
-
"test:debug": "
|
|
70
|
+
"test": "vitest run",
|
|
71
|
+
"test:cov": "vitest run --coverage",
|
|
72
|
+
"test:watch": "vitest",
|
|
73
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism"
|
|
77
74
|
}
|
|
78
75
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constants_1 = require("@nestjs/common/constants");
|
|
4
|
-
let mockForRootAsyncOptions;
|
|
5
|
-
const mockBaseBullModule = {
|
|
6
|
-
forRootAsync: jest.fn((options) => {
|
|
7
|
-
mockForRootAsyncOptions = options;
|
|
8
|
-
return {
|
|
9
|
-
module: class BaseRootModule {
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
}),
|
|
13
|
-
registerQueue: jest.fn(),
|
|
14
|
-
registerQueueAsync: jest.fn(),
|
|
15
|
-
};
|
|
16
|
-
jest.mock("@nestjs/bullmq", () => ({
|
|
17
|
-
BullModule: mockBaseBullModule,
|
|
18
|
-
QueueEventsListener: class QueueEventsListener {
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
const bullmq_module_1 = require("./bullmq.module");
|
|
22
|
-
const bullmq_module_definition_1 = require("./bullmq.module-definition");
|
|
23
|
-
const load_config_from_env_util_1 = require("./utils/load-config-from-env.util");
|
|
24
|
-
jest.mock("./utils/load-config-from-env.util", () => ({
|
|
25
|
-
loadConfigFromEnv: jest.fn(() => ({
|
|
26
|
-
host: "redis.local",
|
|
27
|
-
})),
|
|
28
|
-
}));
|
|
29
|
-
describe("BullModule", () => {
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
jest.clearAllMocks();
|
|
32
|
-
});
|
|
33
|
-
it("should register synchronous and asynchronous options", () => {
|
|
34
|
-
const options = {
|
|
35
|
-
connection: {
|
|
36
|
-
host: "redis.local",
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
const dynamicModule = bullmq_module_1.BullModule.forRoot(options);
|
|
40
|
-
const useFactory = () => options;
|
|
41
|
-
const asyncModule = bullmq_module_1.BullModule.forRootAsync({
|
|
42
|
-
useFactory,
|
|
43
|
-
});
|
|
44
|
-
expect(dynamicModule.module).toBe(bullmq_module_1.BullModule);
|
|
45
|
-
expect(dynamicModule.providers).toEqual(expect.arrayContaining([
|
|
46
|
-
{
|
|
47
|
-
provide: bullmq_module_definition_1.BASE_MODULE_OPTIONS_TOKEN,
|
|
48
|
-
useValue: options,
|
|
49
|
-
},
|
|
50
|
-
]));
|
|
51
|
-
expect(asyncModule.providers).toEqual(expect.arrayContaining([
|
|
52
|
-
{
|
|
53
|
-
inject: [],
|
|
54
|
-
provide: bullmq_module_definition_1.BASE_MODULE_OPTIONS_TOKEN,
|
|
55
|
-
useFactory,
|
|
56
|
-
},
|
|
57
|
-
]));
|
|
58
|
-
});
|
|
59
|
-
it("should provide empty options when base options are missing", () => {
|
|
60
|
-
const providers = Reflect.getMetadata(constants_1.MODULE_METADATA.PROVIDERS, bullmq_module_1.BullModule);
|
|
61
|
-
const optionsProvider = providers.find((provider) => provider.provide === bullmq_module_definition_1.MODULE_OPTIONS_TOKEN);
|
|
62
|
-
expect(optionsProvider).toBeDefined();
|
|
63
|
-
expect(optionsProvider?.useFactory(undefined)).toEqual({});
|
|
64
|
-
expect(optionsProvider?.useFactory({
|
|
65
|
-
prefix: "jobs",
|
|
66
|
-
})).toEqual({
|
|
67
|
-
prefix: "jobs",
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
it("should merge module options with environment Redis config", () => {
|
|
71
|
-
const imports = Reflect.getMetadata(constants_1.MODULE_METADATA.IMPORTS, bullmq_module_1.BullModule);
|
|
72
|
-
expect(mockForRootAsyncOptions).toEqual(expect.objectContaining({
|
|
73
|
-
inject: [bullmq_module_definition_1.MODULE_OPTIONS_TOKEN],
|
|
74
|
-
}));
|
|
75
|
-
expect(mockForRootAsyncOptions.useFactory({
|
|
76
|
-
prefix: "jobs",
|
|
77
|
-
})).toEqual({
|
|
78
|
-
connection: {
|
|
79
|
-
host: "redis.local",
|
|
80
|
-
},
|
|
81
|
-
prefix: "jobs",
|
|
82
|
-
});
|
|
83
|
-
expect(mockForRootAsyncOptions.useFactory({
|
|
84
|
-
connection: {
|
|
85
|
-
host: "custom.redis",
|
|
86
|
-
},
|
|
87
|
-
})).toEqual({
|
|
88
|
-
connection: {
|
|
89
|
-
host: "custom.redis",
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
expect(load_config_from_env_util_1.loadConfigFromEnv).toHaveBeenCalledTimes(1);
|
|
93
|
-
expect(imports).toEqual([
|
|
94
|
-
{
|
|
95
|
-
module: expect.any(Function),
|
|
96
|
-
},
|
|
97
|
-
]);
|
|
98
|
-
});
|
|
99
|
-
it("should delegate queue registration to the base Bull module", () => {
|
|
100
|
-
const queueModule = {
|
|
101
|
-
module: class QueueModule {
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
const asyncQueueModule = {
|
|
105
|
-
module: class AsyncQueueModule {
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
mockBaseBullModule.registerQueue.mockReturnValue(queueModule);
|
|
109
|
-
mockBaseBullModule.registerQueueAsync.mockReturnValue(asyncQueueModule);
|
|
110
|
-
expect(bullmq_module_1.BullModule.registerQueue({ name: "email" })).toBe(queueModule);
|
|
111
|
-
expect(bullmq_module_1.BullModule.registerQueueAsync({
|
|
112
|
-
name: "email",
|
|
113
|
-
useFactory: () => ({}),
|
|
114
|
-
})).toBe(asyncQueueModule);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
//# sourceMappingURL=bullmq.module.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bullmq.module.spec.js","sourceRoot":"","sources":["../src/bullmq.module.spec.ts"],"names":[],"mappings":";;AAAA,wDAA2D;AAE3D,IAAI,uBAA4B,CAAC;AACjC,MAAM,kBAAkB,GAAG;IACzB,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;QAChC,uBAAuB,GAAG,OAAO,CAAC;QAClC,OAAO;YACL,MAAM,EAAE,MAAM,cAAc;aAAG;SAChC,CAAC;IACJ,CAAC,CAAC;IACF,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;IACxB,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC9B,CAAC;AAEF,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC;IACjC,UAAU,EAAE,kBAAkB;IAC9B,mBAAmB,EAAE,MAAM,mBAAmB;KAAG;CAClD,CAAC,CAAC,CAAC;AAEJ,mDAA6C;AAC7C,yEAGoC;AACpC,iFAAsE;AAEtE,IAAI,CAAC,IAAI,CAAC,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC;IACpD,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,aAAa;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ACpE,MAAM,WAAW,GAAG;YAClB,MAAM,EAAE,MAAM,WAAW;aAAG;SAC7B,CAAC;QACF,MAAM,gBAAgB,GAAG;YACvB,MAAM,EAAE,MAAM,gBAAgB;aAAG;SAClC,CAAC;QACF,kBAAkB,CAAC,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QAC9D,kBAAkB,CAAC,kBAAkB,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAExE,MAAM,CAAC,0BAAU,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtE,MAAM,CACJ,0BAAU,CAAC,kBAAkB,CAAC;YAC5B,IAAI,EAAE,OAAO;YACb,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;SACvB,CAAC,CACH,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/index.spec.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const publicApi = __importStar(require("."));
|
|
37
|
-
const bullmq_module_1 = require("./bullmq.module");
|
|
38
|
-
const processor_decorator_1 = require("./processor.decorator");
|
|
39
|
-
describe("public API", () => {
|
|
40
|
-
it("should export Bull module and upstream BullMQ helpers", () => {
|
|
41
|
-
expect(publicApi.BullModule).toBe(bullmq_module_1.BullModule);
|
|
42
|
-
expect(publicApi.Processor).toBe(processor_decorator_1.Processor);
|
|
43
|
-
expect(publicApi.WorkerHost).toBeDefined();
|
|
44
|
-
expect(publicApi.QueueEventsListener).toBeDefined();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=index.spec.js.map
|
package/dist/index.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,mDAA6C;AAC7C,+DAAkD;AAElD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,0BAAU,CAAC,CAAC;QAC9C,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,+BAAS,CAAC,CAAC;QAC5C,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mockJobRef = Symbol("JOB_REF");
|
|
4
|
-
const mockBaseProcessorDecorator = jest.fn();
|
|
5
|
-
const mockBaseProcessor = jest.fn(() => mockBaseProcessorDecorator);
|
|
6
|
-
jest.mock("@nestjs/bullmq", () => ({
|
|
7
|
-
JOB_REF: mockJobRef,
|
|
8
|
-
Processor: mockBaseProcessor,
|
|
9
|
-
WorkerHost: class WorkerHost {
|
|
10
|
-
},
|
|
11
|
-
}));
|
|
12
|
-
const request_context_1 = require("@nest-boot/request-context");
|
|
13
|
-
const processor_decorator_1 = require("./processor.decorator");
|
|
14
|
-
describe("Processor", () => {
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
jest.restoreAllMocks();
|
|
17
|
-
jest.clearAllMocks();
|
|
18
|
-
});
|
|
19
|
-
it("should wrap process in a queue request context and apply the base decorator", async () => {
|
|
20
|
-
const set = jest.spyOn(request_context_1.RequestContext.prototype, "set");
|
|
21
|
-
const run = jest
|
|
22
|
-
.spyOn(request_context_1.RequestContext, "run")
|
|
23
|
-
.mockImplementation(async (ctx, callback) => await callback(ctx));
|
|
24
|
-
const job = {
|
|
25
|
-
id: "job-1",
|
|
26
|
-
};
|
|
27
|
-
class EmailProcessor {
|
|
28
|
-
async process(input) {
|
|
29
|
-
await Promise.resolve();
|
|
30
|
-
return `processed:${input.id}`;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
(0, processor_decorator_1.Processor)("email")(EmailProcessor);
|
|
34
|
-
await expect(new EmailProcessor().process(job)).resolves.toBe("processed:job-1");
|
|
35
|
-
expect(set).toHaveBeenCalledWith(mockJobRef, job);
|
|
36
|
-
expect(run).toHaveBeenCalledWith(expect.objectContaining({
|
|
37
|
-
id: "job-1",
|
|
38
|
-
type: "queue",
|
|
39
|
-
}), expect.any(Function));
|
|
40
|
-
expect(mockBaseProcessor).toHaveBeenCalledWith("email", undefined);
|
|
41
|
-
expect(mockBaseProcessorDecorator).toHaveBeenCalledWith(EmailProcessor);
|
|
42
|
-
});
|
|
43
|
-
it("should apply the base decorator when no process method exists", () => {
|
|
44
|
-
class EmptyProcessor {
|
|
45
|
-
}
|
|
46
|
-
const processorOptions = {
|
|
47
|
-
name: "email",
|
|
48
|
-
};
|
|
49
|
-
const workerOptions = {
|
|
50
|
-
concurrency: 2,
|
|
51
|
-
};
|
|
52
|
-
(0, processor_decorator_1.Processor)(processorOptions, workerOptions)(EmptyProcessor);
|
|
53
|
-
expect(mockBaseProcessor).toHaveBeenCalledWith(processorOptions, workerOptions);
|
|
54
|
-
expect(mockBaseProcessorDecorator).toHaveBeenCalledWith(EmptyProcessor);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
//# sourceMappingURL=processor.decorator.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processor.decorator.spec.js","sourceRoot":"","sources":["../src/processor.decorator.spec.ts"],"names":[],"mappings":";;AAAA,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AACrC,MAAM,0BA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