@midwayjs/cron 4.0.0-beta.1 → 4.0.0-beta.10

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/README.md CHANGED
@@ -9,4 +9,4 @@ Document: [https://midwayjs.org](https://midwayjs.org)
9
9
 
10
10
  ## License
11
11
 
12
- [MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
12
+ [MIT](https://github.com/midwayjs/midway/blob/master/LICENSE)
@@ -14,6 +14,8 @@ const core_1 = require("@midwayjs/core");
14
14
  const framework_1 = require("./framework");
15
15
  const constants_1 = require("./constants");
16
16
  let CronConfiguration = class CronConfiguration {
17
+ framework;
18
+ decoratorService;
17
19
  async init() {
18
20
  this.decoratorService.registerPropertyHandler(constants_1.CRON_JOB_KEY, (propertyName, meta) => {
19
21
  return this.framework.getJob(meta.jobName);
package/dist/decorator.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectJob = exports.Job = void 0;
3
+ exports.Job = Job;
4
+ exports.InjectJob = InjectJob;
4
5
  const core_1 = require("@midwayjs/core");
5
6
  const constants_1 = require("./constants");
6
7
  function Job(jobName, jobOptions) {
@@ -18,11 +19,9 @@ function Job(jobName, jobOptions) {
18
19
  (0, core_1.Scope)(core_1.ScopeEnum.Request)(target);
19
20
  };
20
21
  }
21
- exports.Job = Job;
22
22
  function InjectJob(jobName) {
23
23
  return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.CRON_JOB_KEY, {
24
24
  jobName,
25
25
  });
26
26
  }
27
- exports.InjectJob = InjectJob;
28
27
  //# sourceMappingURL=decorator.js.map
@@ -1,6 +1,6 @@
1
1
  import { BaseFramework, IMidwayBootstrapOptions } from '@midwayjs/core';
2
2
  import { Application, Context, JobNameOrClz } from './interface';
3
- import { CronJob, CronJobParameters } from 'cron';
3
+ import { CronJob, CronJobParams } from 'cron';
4
4
  export declare class CronFramework extends BaseFramework<Application, Context, any> {
5
5
  private defaultCronJobConfig;
6
6
  private jobs;
@@ -11,8 +11,8 @@ export declare class CronFramework extends BaseFramework<Application, Context, a
11
11
  getFrameworkName(): string;
12
12
  run(): Promise<void>;
13
13
  protected beforeStop(): Promise<void>;
14
- addJob(name: JobNameOrClz, jobOptions?: Partial<CronJobParameters>): CronJob;
15
- getJob(name: JobNameOrClz): CronJob;
14
+ addJob(name: JobNameOrClz, jobOptions?: Partial<CronJobParams>): CronJob;
15
+ getJob(name: JobNameOrClz): CronJob<null, null>;
16
16
  deleteJob(name: JobNameOrClz): Promise<void>;
17
17
  private getJobName;
18
18
  }
package/dist/framework.js CHANGED
@@ -11,11 +11,9 @@ const core_1 = require("@midwayjs/core");
11
11
  const cron_1 = require("cron");
12
12
  const constants_1 = require("./constants");
13
13
  let CronFramework = class CronFramework extends core_1.BaseFramework {
14
- constructor() {
15
- super(...arguments);
16
- this.jobs = new Map();
17
- this.frameworkLoggerName = 'cronLogger';
18
- }
14
+ defaultCronJobConfig;
15
+ jobs = new Map();
16
+ frameworkLoggerName = 'cronLogger';
19
17
  async applicationInitialize(options) {
20
18
  this.app = {};
21
19
  }
@@ -82,7 +80,7 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
82
80
  });
83
81
  };
84
82
  }
85
- const job = new cron_1.CronJob(jobOptions);
83
+ const job = cron_1.CronJob.from(jobOptions);
86
84
  this.jobs.set(jobName, job);
87
85
  return job;
88
86
  }
@@ -1,7 +1,7 @@
1
1
  import { IMidwayApplication, IMidwayContext, NextFunction as BaseNextFunction } from '@midwayjs/core';
2
- import { CronJob, CronJobParameters } from 'cron';
2
+ import { CronJob, CronJobParams } from 'cron';
3
3
  export { CronJob } from 'cron';
4
- export type CronJobOptions = Omit<CronJobParameters, 'onTick' | 'onComplete'>;
4
+ export type CronJobOptions = Omit<CronJobParams, 'onTick' | 'onComplete'>;
5
5
  export interface CronOptions {
6
6
  defaultCronJobOptions?: CronJobOptions;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/cron",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.10",
4
4
  "description": "Midway Component for Cron",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -22,15 +22,15 @@
22
22
  "index.d.ts"
23
23
  ],
24
24
  "engines": {
25
- "node": ">=12"
25
+ "node": ">=20"
26
26
  },
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "cron": "2.4.4"
29
+ "cron": "3.5.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@midwayjs/core": "^4.0.0-beta.1",
33
- "@midwayjs/mock": "^4.0.0-beta.1"
32
+ "@midwayjs/core": "^4.0.0-beta.10",
33
+ "@midwayjs/mock": "^4.0.0-beta.10"
34
34
  },
35
- "gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
35
+ "gitHead": "1b1856629913703f67304155aaf611ec936a81ac"
36
36
  }