@velajs/vela 1.2.0 → 1.4.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/CHANGELOG.md +67 -0
- package/dist/__tests__/workers/entry.d.ts +9 -0
- package/dist/container/container.d.ts +17 -5
- package/dist/container/container.js +151 -34
- package/dist/container/index.d.ts +2 -2
- package/dist/container/index.js +1 -1
- package/dist/container/types.d.ts +16 -0
- package/dist/container/types.js +14 -0
- package/dist/event-emitter/event-emitter.subscriber.js +6 -1
- package/dist/factory/bootstrap.d.ts +23 -0
- package/dist/factory/bootstrap.js +76 -0
- package/dist/factory.d.ts +2 -2
- package/dist/factory.js +2 -33
- package/dist/http/request-context.d.ts +13 -0
- package/dist/http/request-context.js +22 -0
- package/dist/http/route.manager.js +2 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +6 -1
- package/dist/internal.d.ts +6 -0
- package/dist/internal.js +6 -0
- package/dist/module/module-loader.d.ts +4 -0
- package/dist/module/module-loader.js +80 -23
- package/dist/plugin/plugin.d.ts +31 -0
- package/dist/plugin/plugin.js +111 -0
- package/dist/registry/metadata.registry.js +0 -1
- package/dist/schedule/schedule.registry.js +6 -1
- package/dist/schedule-node/schedule.executor.d.ts +3 -1
- package/dist/schedule-node/schedule.executor.js +21 -5
- package/package.json +6 -2
|
@@ -7,18 +7,26 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
7
7
|
function _ts_metadata(k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
function _ts_param(paramIndex, decorator) {
|
|
11
|
+
return function(target, key) {
|
|
12
|
+
decorator(target, key, paramIndex);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
import { Inject, Injectable } from "../container/index.js";
|
|
16
|
+
import { Container } from "../container/container.js";
|
|
11
17
|
import { parseCron } from "../schedule/cron-matcher.js";
|
|
12
18
|
import { ScheduleRegistry } from "../schedule/schedule.registry.js";
|
|
13
19
|
export class ScheduleExecutor {
|
|
14
20
|
registry;
|
|
21
|
+
container;
|
|
15
22
|
intervalTimers = [];
|
|
16
23
|
cronTimers = [];
|
|
17
24
|
cronMatcherCache = new Map();
|
|
18
25
|
lastCronMinute = new Map();
|
|
19
26
|
running = true;
|
|
20
|
-
constructor(registry){
|
|
27
|
+
constructor(registry, container){
|
|
21
28
|
this.registry = registry;
|
|
29
|
+
this.container = container;
|
|
22
30
|
}
|
|
23
31
|
onApplicationBootstrap() {
|
|
24
32
|
if (typeof setInterval !== 'function') {
|
|
@@ -61,8 +69,14 @@ export class ScheduleExecutor {
|
|
|
61
69
|
if (typeof method === 'function') {
|
|
62
70
|
await method.call(instance);
|
|
63
71
|
}
|
|
64
|
-
} catch
|
|
65
|
-
|
|
72
|
+
} catch (err) {
|
|
73
|
+
// Runtime job error — keep the scheduler running by default. Users
|
|
74
|
+
// can opt into rethrowing by setting diagnostics: 'throw'.
|
|
75
|
+
const mode = this.container.getDiagnostics();
|
|
76
|
+
if (mode === 'throw') throw err;
|
|
77
|
+
if (mode === 'log') {
|
|
78
|
+
console.warn(`[vela] scheduled job ${methodName} failed:`, err);
|
|
79
|
+
}
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
getMatcher(expression) {
|
|
@@ -84,8 +98,10 @@ export class ScheduleExecutor {
|
|
|
84
98
|
}
|
|
85
99
|
ScheduleExecutor = _ts_decorate([
|
|
86
100
|
Injectable(),
|
|
101
|
+
_ts_param(1, Inject(Container)),
|
|
87
102
|
_ts_metadata("design:type", Function),
|
|
88
103
|
_ts_metadata("design:paramtypes", [
|
|
89
|
-
typeof ScheduleRegistry === "undefined" ? Object : ScheduleRegistry
|
|
104
|
+
typeof ScheduleRegistry === "undefined" ? Object : ScheduleRegistry,
|
|
105
|
+
typeof Container === "undefined" ? Object : Container
|
|
90
106
|
])
|
|
91
107
|
], ScheduleExecutor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velajs/vela",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "NestJS-compatible framework for edge runtimes, powered by Hono",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -61,17 +61,21 @@
|
|
|
61
61
|
"hono": "^4"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
+
"@cloudflare/vitest-pool-workers": "^0.15.2",
|
|
64
65
|
"@swc/cli": "^0.8.0",
|
|
65
66
|
"@swc/core": "^1.15.11",
|
|
66
67
|
"@types/bun": "latest",
|
|
68
|
+
"@vitest/runner": "^4.1.5",
|
|
69
|
+
"@vitest/snapshot": "^4.1.5",
|
|
67
70
|
"typescript": "^5",
|
|
68
71
|
"unplugin-swc": "^1.5.9",
|
|
69
|
-
"vitest": "^4.
|
|
72
|
+
"vitest": "^4.1.5",
|
|
70
73
|
"zod": "^4.3.6"
|
|
71
74
|
},
|
|
72
75
|
"scripts": {
|
|
73
76
|
"build": "rm -rf dist && swc src -d dist --strip-leading-paths && tsc --emitDeclarationOnly",
|
|
74
77
|
"test": "vitest run",
|
|
78
|
+
"test:workers": "vitest run --config vitest.config.workers.ts",
|
|
75
79
|
"typecheck": "tsc --noEmit"
|
|
76
80
|
}
|
|
77
81
|
}
|