@ldsg/schedules 0.3.36 → 0.3.38
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/resource.d.ts.map +1 -1
- package/dist/resource.js +30 -2
- package/package.json +9 -9
package/dist/resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEhG,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,UAAU,sBAAsB;IAC9B,gBAAgB,EAAE,YAAY,EAAE,CAAC;CAClC;AAED,KAAK,mBAAmB,GAAG,MAAM,sBAAsB,CAAC;AAIxD,qBAAa,iBAAkB,SAAQ,QAAQ,CAAC,iCAAiC,CAAC;IAChF,MAAM,EAAG,MAAM,CAAC;IAEhB,mBAAmB,EAAE,mBAAmB,CAsBtC;IAEF,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEhG,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,UAAU,sBAAsB;IAC9B,gBAAgB,EAAE,YAAY,EAAE,CAAC;CAClC;AAED,KAAK,mBAAmB,GAAG,MAAM,sBAAsB,CAAC;AAIxD,qBAAa,iBAAkB,SAAQ,QAAQ,CAAC,iCAAiC,CAAC;IAChF,MAAM,EAAG,MAAM,CAAC;IAEhB,mBAAmB,EAAE,mBAAmB,CAsBtC;IAEF,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAsBjD;IAEF,IAAI,sBAuEF;IAEF,WAAW,GAAU,QAAQ,iBAAiB,KAAG,OAAO,CAAC,GAAG,CAAC,CAiD3D;IAEF,SAAS,GAAU,QAAQ,eAAe,mBAOxC;IAEF,aAAa,sBAEX;CACH"}
|
package/dist/resource.js
CHANGED
|
@@ -30,11 +30,15 @@ class SchedulesResource extends resource_1.Resource {
|
|
|
30
30
|
};
|
|
31
31
|
this.executeWorkflow = async (params) => {
|
|
32
32
|
const { workflowResourceId, workflowVariables } = params;
|
|
33
|
+
console.log("[Schedules] executeWorkflow start", { workflowResourceId });
|
|
33
34
|
const { resource: workflowResource } = this.getFilteredResource({
|
|
34
35
|
id: workflowResourceId,
|
|
35
36
|
});
|
|
36
37
|
const wr = workflowResource;
|
|
37
38
|
if (!(wr === null || wr === void 0 ? void 0 : wr.execute)) {
|
|
39
|
+
console.error("[Schedules] executeWorkflow workflow not found or invalid", {
|
|
40
|
+
workflowResourceId,
|
|
41
|
+
});
|
|
38
42
|
throw new Error(`workflow not found or invalid: ${workflowResourceId}`);
|
|
39
43
|
}
|
|
40
44
|
await wr.execute({
|
|
@@ -45,6 +49,7 @@ class SchedulesResource extends resource_1.Resource {
|
|
|
45
49
|
this.init = async () => {
|
|
46
50
|
var _a;
|
|
47
51
|
const { getFilteredResource, getResourcesFromSettings, settings: { processEvery }, } = this;
|
|
52
|
+
console.log("[Schedules] init start", { processEvery });
|
|
48
53
|
const databaseResourceFromSettings = getResourcesFromSettings()
|
|
49
54
|
.databaseResource;
|
|
50
55
|
const databaseResource = databaseResourceFromSettings !== null && databaseResourceFromSettings !== void 0 ? databaseResourceFromSettings : getFilteredResource({
|
|
@@ -62,9 +67,23 @@ class SchedulesResource extends resource_1.Resource {
|
|
|
62
67
|
console.error("Agenda error:", error);
|
|
63
68
|
});
|
|
64
69
|
this.agenda.define(JOB_NAME, async (job) => {
|
|
65
|
-
|
|
70
|
+
console.log("[Schedules] agenda job fired", {
|
|
71
|
+
jobId: job.attrs._id,
|
|
72
|
+
data: job.attrs.data,
|
|
73
|
+
});
|
|
74
|
+
try {
|
|
75
|
+
await this.executeWorkflow(job.attrs.data);
|
|
76
|
+
console.log("[Schedules] agenda job executeWorkflow done", { jobId: job.attrs._id });
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error("[Schedules] agenda job executeWorkflow error", {
|
|
80
|
+
jobId: job.attrs._id,
|
|
81
|
+
error,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
66
84
|
});
|
|
67
85
|
await this.agenda.start();
|
|
86
|
+
console.log("[Schedules] agenda started", { processEvery });
|
|
68
87
|
const { scheduleInfoList } = this.getScheduleInfoList();
|
|
69
88
|
const hasEvery = scheduleInfoList.some((info) => info.triggerType === "every");
|
|
70
89
|
if (hasEvery) {
|
|
@@ -109,7 +128,16 @@ class SchedulesResource extends resource_1.Resource {
|
|
|
109
128
|
else {
|
|
110
129
|
throw new Error("invalid scheduling parameters");
|
|
111
130
|
}
|
|
112
|
-
|
|
131
|
+
const savedJob = await job.save();
|
|
132
|
+
console.log("[Schedules] scheduleJob saved", {
|
|
133
|
+
jobId: savedJob.attrs._id,
|
|
134
|
+
triggerType,
|
|
135
|
+
delay,
|
|
136
|
+
scheduledAt,
|
|
137
|
+
workflowResourceId,
|
|
138
|
+
nextRunAt: savedJob.attrs.nextRunAt,
|
|
139
|
+
});
|
|
140
|
+
return savedJob;
|
|
113
141
|
};
|
|
114
142
|
this.cancelJob = async (params) => {
|
|
115
143
|
if (!this.agenda) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/schedules",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,11 +18,13 @@
|
|
|
18
18
|
"agenda": "^6.2.5",
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
20
|
"zod": "^4.1.11",
|
|
21
|
-
"@ldsg/
|
|
22
|
-
"@ldsg/
|
|
23
|
-
"@ldsg/
|
|
24
|
-
"@ldsg/
|
|
25
|
-
"@ldsg/resource-definition": "0.3.
|
|
21
|
+
"@ldsg/application": "0.3.38",
|
|
22
|
+
"@ldsg/handler": "0.3.38",
|
|
23
|
+
"@ldsg/database": "0.3.38",
|
|
24
|
+
"@ldsg/resource": "0.3.38",
|
|
25
|
+
"@ldsg/resource-definition": "0.3.38",
|
|
26
|
+
"@ldsg/types": "0.3.38",
|
|
27
|
+
"@ldsg/schedule": "0.3.38"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@types/jest": "^29.5.2",
|
|
@@ -33,9 +35,7 @@
|
|
|
33
35
|
"oxlint": "latest",
|
|
34
36
|
"ts-jest": "^29.1.5",
|
|
35
37
|
"ts-node": "^10.9.2",
|
|
36
|
-
"typescript": "^5.8.3"
|
|
37
|
-
"@ldsg/application": "0.3.36",
|
|
38
|
-
"@ldsg/types": "0.3.36"
|
|
38
|
+
"typescript": "^5.8.3"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc --project tsconfig.build.json",
|