@midwayjs/bullmq 3.20.11 → 4.0.0-beta.2

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.
@@ -30,6 +30,7 @@ let BullConfiguration = class BullConfiguration {
30
30
  this.framework.loadConfig();
31
31
  }
32
32
  };
33
+ exports.BullConfiguration = BullConfiguration;
33
34
  __decorate([
34
35
  (0, core_1.Inject)(),
35
36
  __metadata("design:type", framework_1.BullMQFramework)
@@ -44,7 +45,7 @@ __decorate([
44
45
  __metadata("design:paramtypes", []),
45
46
  __metadata("design:returntype", Promise)
46
47
  ], BullConfiguration.prototype, "init", null);
47
- BullConfiguration = __decorate([
48
+ exports.BullConfiguration = BullConfiguration = __decorate([
48
49
  (0, core_1.Configuration)({
49
50
  namespace: 'bullmq',
50
51
  importConfigs: [
@@ -54,5 +55,4 @@ BullConfiguration = __decorate([
54
55
  ],
55
56
  })
56
57
  ], BullConfiguration);
57
- exports.BullConfiguration = BullConfiguration;
58
58
  //# sourceMappingURL=configuration.js.map
package/dist/decorator.js CHANGED
@@ -5,8 +5,8 @@ const core_1 = require("@midwayjs/core");
5
5
  const constants_1 = require("./constants");
6
6
  function Processor(queueName, jobOptions, workerOptions, queueOptions) {
7
7
  return function (target) {
8
- (0, core_1.saveModule)(constants_1.BULLMQ_PROCESSOR_KEY, target);
9
- (0, core_1.saveClassMetadata)(constants_1.BULLMQ_PROCESSOR_KEY, {
8
+ core_1.DecoratorManager.saveModule(constants_1.BULLMQ_PROCESSOR_KEY, target);
9
+ core_1.MetadataManager.defineMetadata(constants_1.BULLMQ_PROCESSOR_KEY, {
10
10
  queueName,
11
11
  jobOptions,
12
12
  workerOptions,
@@ -18,19 +18,19 @@ function Processor(queueName, jobOptions, workerOptions, queueOptions) {
18
18
  }
19
19
  exports.Processor = Processor;
20
20
  function InjectQueue(queueName) {
21
- return (0, core_1.createCustomPropertyDecorator)(constants_1.BULLMQ_QUEUE_KEY, {
21
+ return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.BULLMQ_QUEUE_KEY, {
22
22
  queueName,
23
23
  });
24
24
  }
25
25
  exports.InjectQueue = InjectQueue;
26
26
  function InjectWorker(queueName) {
27
- return (0, core_1.createCustomPropertyDecorator)(constants_1.BULLMQ_WORKER_KEY, {
27
+ return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.BULLMQ_WORKER_KEY, {
28
28
  queueName,
29
29
  });
30
30
  }
31
31
  exports.InjectWorker = InjectWorker;
32
32
  function InjectFlowProducer(producerName) {
33
- return (0, core_1.createCustomPropertyDecorator)(constants_1.BULLMQ_FLOW_PRODUCER_KEY, {
33
+ return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.BULLMQ_FLOW_PRODUCER_KEY, {
34
34
  producerName,
35
35
  });
36
36
  }
package/dist/framework.js CHANGED
@@ -22,7 +22,7 @@ class BullMQQueue extends bullmq_1.Queue {
22
22
  this.queueEventsProducerList = [];
23
23
  }
24
24
  async addJobToQueue(data, options) {
25
- const { repeat, ...OtherOptions } = options !== null && options !== void 0 ? options : {};
25
+ const { repeat, ...OtherOptions } = options ?? {};
26
26
  if (repeat) {
27
27
  return this.upsertJobScheduler(this.name, repeat, {
28
28
  name: 'jobName',
@@ -102,12 +102,11 @@ let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
102
102
  return 'bullmq';
103
103
  }
104
104
  async run() {
105
- var _a, _b, _c;
106
- const processorModules = (0, core_1.listModule)(constants_1.BULLMQ_PROCESSOR_KEY);
105
+ const processorModules = core_1.DecoratorManager.listModule(constants_1.BULLMQ_PROCESSOR_KEY);
107
106
  for (const mod of processorModules) {
108
- const options = (0, core_1.getClassMetadata)(constants_1.BULLMQ_PROCESSOR_KEY, mod);
109
- const { repeat, ...otherOptions } = (_a = options.jobOptions) !== null && _a !== void 0 ? _a : {};
110
- const queueOptions = (_b = options.queueOptions) !== null && _b !== void 0 ? _b : {};
107
+ const options = core_1.MetadataManager.getMetadata(constants_1.BULLMQ_PROCESSOR_KEY, mod);
108
+ const { repeat, ...otherOptions } = options.jobOptions ?? {};
109
+ const queueOptions = options.queueOptions ?? {};
111
110
  const currentQueue = this.ensureQueue(options.queueName, {
112
111
  ...queueOptions,
113
112
  defaultJobOptions: otherOptions,
@@ -130,7 +129,7 @@ let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
130
129
  await this.addProcessor(mod, options.queueName, options.workerOptions);
131
130
  if (repeat) {
132
131
  // add repeatable job
133
- await ((_c = this.getQueue(options.queueName)) === null || _c === void 0 ? void 0 : _c.addJobToQueue({}, options.jobOptions));
132
+ await this.getQueue(options.queueName)?.addJobToQueue({}, options.jobOptions);
134
133
  }
135
134
  }
136
135
  }
@@ -174,8 +173,7 @@ let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
174
173
  * Get the first worker by queueName
175
174
  */
176
175
  getWorker(queueName) {
177
- var _a;
178
- return (_a = this.workerMap.get(queueName)) === null || _a === void 0 ? void 0 : _a[0];
176
+ return this.workerMap.get(queueName)?.[0];
179
177
  }
180
178
  /**
181
179
  * Get all workers by queueName
@@ -270,12 +268,12 @@ let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
270
268
  return this.flowProducerMap.get(producerName);
271
269
  }
272
270
  };
271
+ exports.BullMQFramework = BullMQFramework;
273
272
  __decorate([
274
273
  (0, core_1.Logger)('bullMQLogger'),
275
274
  __metadata("design:type", Object)
276
275
  ], BullMQFramework.prototype, "bullMQLogger", void 0);
277
- BullMQFramework = __decorate([
276
+ exports.BullMQFramework = BullMQFramework = __decorate([
278
277
  (0, core_1.Framework)()
279
278
  ], BullMQFramework);
280
- exports.BullMQFramework = BullMQFramework;
281
279
  //# sourceMappingURL=framework.js.map
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/bullmq",
3
- "version": "3.20.11",
3
+ "version": "4.0.0-beta.2",
4
4
  "description": "midway component for BullMQ",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
10
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit"
9
+ "test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
10
+ "cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit"
11
11
  },
12
12
  "keywords": [
13
13
  "midway",
@@ -24,15 +24,15 @@
24
24
  ],
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@midwayjs/core": "^3.20.11",
28
- "@midwayjs/mock": "^3.20.11"
27
+ "@midwayjs/core": "^4.0.0-beta.2",
28
+ "@midwayjs/mock": "^4.0.0-beta.2"
29
29
  },
30
30
  "dependencies": {
31
31
  "bullmq": "5.51.1"
32
32
  },
33
33
  "engines": {
34
- "node": ">=12"
34
+ "node": ">=20"
35
35
  },
36
36
  "repository": "https://github.com/midwayjs/midway.git",
37
- "gitHead": "741e5e2cd200d44182bf893f348f58fb5c4e5404"
37
+ "gitHead": "53bfef4c5279da5f09025e4610bdbf64f94f60bd"
38
38
  }