@midwayjs/cron 3.20.4 → 4.0.0-beta.1

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.
@@ -23,6 +23,7 @@ let CronConfiguration = class CronConfiguration {
23
23
  this.framework.loadConfig();
24
24
  }
25
25
  };
26
+ exports.CronConfiguration = CronConfiguration;
26
27
  __decorate([
27
28
  (0, core_1.Inject)(),
28
29
  __metadata("design:type", framework_1.CronFramework)
@@ -37,7 +38,7 @@ __decorate([
37
38
  __metadata("design:paramtypes", []),
38
39
  __metadata("design:returntype", Promise)
39
40
  ], CronConfiguration.prototype, "init", null);
40
- CronConfiguration = __decorate([
41
+ exports.CronConfiguration = CronConfiguration = __decorate([
41
42
  (0, core_1.Configuration)({
42
43
  namespace: 'cron',
43
44
  importConfigs: [
@@ -45,7 +46,6 @@ CronConfiguration = __decorate([
45
46
  default: {
46
47
  cron: {
47
48
  defaultCronJobOptions: {},
48
- contextLoggerApplyLogger: 'cronLogger',
49
49
  },
50
50
  midwayLogger: {
51
51
  clients: {
@@ -63,5 +63,4 @@ CronConfiguration = __decorate([
63
63
  ],
64
64
  })
65
65
  ], CronConfiguration);
66
- exports.CronConfiguration = CronConfiguration;
67
66
  //# sourceMappingURL=configuration.js.map
package/dist/decorator.js CHANGED
@@ -9,8 +9,8 @@ function Job(jobName, jobOptions) {
9
9
  jobOptions = jobName;
10
10
  jobName = undefined;
11
11
  }
12
- (0, core_1.saveModule)(constants_1.CRON_JOB_KEY, target);
13
- (0, core_1.saveClassMetadata)(constants_1.CRON_JOB_KEY, {
12
+ core_1.DecoratorManager.saveModule(constants_1.CRON_JOB_KEY, target);
13
+ core_1.MetadataManager.defineMetadata(constants_1.CRON_JOB_KEY, {
14
14
  jobOptions,
15
15
  jobName,
16
16
  }, target);
@@ -20,7 +20,7 @@ function Job(jobName, jobOptions) {
20
20
  }
21
21
  exports.Job = Job;
22
22
  function InjectJob(jobName) {
23
- return (0, core_1.createCustomPropertyDecorator)(constants_1.CRON_JOB_KEY, {
23
+ return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.CRON_JOB_KEY, {
24
24
  jobName,
25
25
  });
26
26
  }
@@ -4,6 +4,7 @@ import { CronJob, CronJobParameters } from 'cron';
4
4
  export declare class CronFramework extends BaseFramework<Application, Context, any> {
5
5
  private defaultCronJobConfig;
6
6
  private jobs;
7
+ protected frameworkLoggerName: string;
7
8
  applicationInitialize(options: IMidwayBootstrapOptions): Promise<void>;
8
9
  loadConfig(): void;
9
10
  configure(): any;
package/dist/framework.js CHANGED
@@ -14,6 +14,7 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
14
14
  constructor() {
15
15
  super(...arguments);
16
16
  this.jobs = new Map();
17
+ this.frameworkLoggerName = 'cronLogger';
17
18
  }
18
19
  async applicationInitialize(options) {
19
20
  this.app = {};
@@ -28,7 +29,7 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
28
29
  return 'cron';
29
30
  }
30
31
  async run() {
31
- const jobModules = (0, core_1.listModule)(constants_1.CRON_JOB_KEY);
32
+ const jobModules = core_1.DecoratorManager.listModule(constants_1.CRON_JOB_KEY);
32
33
  for (const mod of jobModules) {
33
34
  this.addJob(mod);
34
35
  }
@@ -45,14 +46,13 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
45
46
  jobName = name;
46
47
  }
47
48
  else {
48
- const options = (0, core_1.getClassMetadata)(constants_1.CRON_JOB_KEY, name);
49
- jobName = options.jobName || (0, core_1.getProviderUUId)(name);
49
+ const options = core_1.MetadataManager.getOwnMetadata(constants_1.CRON_JOB_KEY, name);
50
+ jobName = options.jobName || core_1.DecoratorManager.getProviderUUId(name);
50
51
  jobOptions = (0, core_1.extend)(true, {}, this.defaultCronJobConfig, options.jobOptions, jobOptions);
51
52
  // eslint-disable-next-line @typescript-eslint/no-this-alias
52
53
  const self = this;
53
54
  jobOptions.onTick = function () {
54
55
  (async () => {
55
- var _a;
56
56
  const ctx = self.app.createAnonymousContext({
57
57
  job: this,
58
58
  from: name,
@@ -71,7 +71,7 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
71
71
  try {
72
72
  const result = await Promise.resolve(await fn(ctx));
73
73
  ctx.logger.info(`complete job ${name.name}`);
74
- await ((_a = service.onComplete) === null || _a === void 0 ? void 0 : _a.call(service, result));
74
+ await service.onComplete?.(result);
75
75
  return result;
76
76
  }
77
77
  catch (err) {
@@ -104,13 +104,13 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
104
104
  return name;
105
105
  }
106
106
  else {
107
- const options = (0, core_1.getClassMetadata)(constants_1.CRON_JOB_KEY, name);
108
- return options.jobName || (0, core_1.getProviderUUId)(name);
107
+ const options = core_1.MetadataManager.getOwnMetadata(constants_1.CRON_JOB_KEY, name);
108
+ return options.jobName || core_1.DecoratorManager.getProviderUUId(name);
109
109
  }
110
110
  }
111
111
  };
112
- CronFramework = __decorate([
112
+ exports.CronFramework = CronFramework;
113
+ exports.CronFramework = CronFramework = __decorate([
113
114
  (0, core_1.Framework)()
114
115
  ], CronFramework);
115
- exports.CronFramework = CronFramework;
116
116
  //# sourceMappingURL=framework.js.map
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/cron",
3
- "version": "3.20.4",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "Midway Component for Cron",
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
  "ci": "npm run test"
12
12
  },
13
13
  "keywords": [
@@ -29,8 +29,8 @@
29
29
  "cron": "2.4.4"
30
30
  },
31
31
  "devDependencies": {
32
- "@midwayjs/core": "^3.20.4",
33
- "@midwayjs/mock": "^3.20.4"
32
+ "@midwayjs/core": "^4.0.0-beta.1",
33
+ "@midwayjs/mock": "^4.0.0-beta.1"
34
34
  },
35
- "gitHead": "c3fb65a7ada8829635f3c6af5ef83c65c3a43d79"
35
+ "gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
36
36
  }