@midwayjs/cron 3.19.2 → 4.0.0-alpha.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.
- package/dist/configuration.js +2 -2
- package/dist/decorator.js +3 -3
- package/dist/framework.js +8 -9
- package/package.json +6 -6
package/dist/configuration.js
CHANGED
|
@@ -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: [
|
|
@@ -63,5 +64,4 @@ CronConfiguration = __decorate([
|
|
|
63
64
|
],
|
|
64
65
|
})
|
|
65
66
|
], CronConfiguration);
|
|
66
|
-
exports.CronConfiguration = CronConfiguration;
|
|
67
67
|
//# 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
|
-
|
|
13
|
-
|
|
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
|
|
23
|
+
return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.CRON_JOB_KEY, {
|
|
24
24
|
jobName,
|
|
25
25
|
});
|
|
26
26
|
}
|
package/dist/framework.js
CHANGED
|
@@ -28,7 +28,7 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
|
|
|
28
28
|
return 'cron';
|
|
29
29
|
}
|
|
30
30
|
async run() {
|
|
31
|
-
const jobModules =
|
|
31
|
+
const jobModules = core_1.DecoratorManager.listModule(constants_1.CRON_JOB_KEY);
|
|
32
32
|
for (const mod of jobModules) {
|
|
33
33
|
this.addJob(mod);
|
|
34
34
|
}
|
|
@@ -45,14 +45,13 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
|
|
|
45
45
|
jobName = name;
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
const options =
|
|
49
|
-
jobName = options.name ||
|
|
48
|
+
const options = core_1.MetadataManager.getOwnMetadata(constants_1.CRON_JOB_KEY, name);
|
|
49
|
+
jobName = options.name || core_1.DecoratorManager.getProviderUUId(name);
|
|
50
50
|
jobOptions = (0, core_1.extend)(true, {}, this.defaultCronJobConfig, options.jobOptions, jobOptions);
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
52
52
|
const self = this;
|
|
53
53
|
jobOptions.onTick = function () {
|
|
54
54
|
(async () => {
|
|
55
|
-
var _a;
|
|
56
55
|
const ctx = self.app.createAnonymousContext({
|
|
57
56
|
job: this,
|
|
58
57
|
from: name,
|
|
@@ -71,7 +70,7 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
|
|
|
71
70
|
try {
|
|
72
71
|
const result = await Promise.resolve(await fn(ctx));
|
|
73
72
|
ctx.logger.info(`complete job ${name.name}`);
|
|
74
|
-
await
|
|
73
|
+
await service.onComplete?.(result);
|
|
75
74
|
return result;
|
|
76
75
|
}
|
|
77
76
|
catch (err) {
|
|
@@ -104,13 +103,13 @@ let CronFramework = class CronFramework extends core_1.BaseFramework {
|
|
|
104
103
|
return name;
|
|
105
104
|
}
|
|
106
105
|
else {
|
|
107
|
-
const options =
|
|
108
|
-
return options.name ||
|
|
106
|
+
const options = core_1.MetadataManager.getOwnMetadata(constants_1.CRON_JOB_KEY, name);
|
|
107
|
+
return options.name || core_1.DecoratorManager.getProviderUUId(name);
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
};
|
|
112
|
-
CronFramework =
|
|
111
|
+
exports.CronFramework = CronFramework;
|
|
112
|
+
exports.CronFramework = CronFramework = __decorate([
|
|
113
113
|
(0, core_1.Framework)()
|
|
114
114
|
], CronFramework);
|
|
115
|
-
exports.CronFramework = CronFramework;
|
|
116
115
|
//# sourceMappingURL=framework.js.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/cron",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.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
|
|
10
|
-
"cov": "node
|
|
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": "^
|
|
33
|
-
"@midwayjs/mock": "^
|
|
32
|
+
"@midwayjs/core": "^4.0.0-alpha.1",
|
|
33
|
+
"@midwayjs/mock": "^4.0.0-alpha.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
|
|
36
36
|
}
|