@openfn/ws-worker 0.1.1 → 0.1.3
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 +18 -0
- package/dist/index.js +17 -5
- package/dist/start.js +18 -6
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
# ws-worker
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix log event mapping
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @openfn/engine-multi@0.1.3
|
|
10
|
+
|
|
11
|
+
## 0.1.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- f241348: Make destroy async
|
|
16
|
+
- Updated dependencies [d255f32]
|
|
17
|
+
- Updated dependencies [f241348]
|
|
18
|
+
- @openfn/engine-multi@0.1.2
|
|
19
|
+
|
|
3
20
|
## 0.1.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
6
23
|
|
|
24
|
+
- Added docker image and bin stub
|
|
7
25
|
- Destroy workers on close
|
|
8
26
|
- Updated dependencies
|
|
9
27
|
- @openfn/engine-multi@0.1.1
|
package/dist/index.js
CHANGED
|
@@ -122,6 +122,17 @@ import crypto2 from "node:crypto";
|
|
|
122
122
|
|
|
123
123
|
// src/util/convert-attempt.ts
|
|
124
124
|
import crypto from "node:crypto";
|
|
125
|
+
var conditions = {
|
|
126
|
+
on_job_success: "!state.errors",
|
|
127
|
+
on_job_failure: "state.errors",
|
|
128
|
+
always: null
|
|
129
|
+
};
|
|
130
|
+
var mapEdgeCondition = (condition) => {
|
|
131
|
+
if (condition && condition in conditions) {
|
|
132
|
+
return conditions[condition];
|
|
133
|
+
}
|
|
134
|
+
return condition;
|
|
135
|
+
};
|
|
125
136
|
var convert_attempt_default = (attempt) => {
|
|
126
137
|
const options = attempt.options || {};
|
|
127
138
|
const plan = {
|
|
@@ -167,8 +178,9 @@ var convert_attempt_default = (attempt) => {
|
|
|
167
178
|
}
|
|
168
179
|
const next = edges.filter((e) => e.source_job_id === id).reduce((obj, edge) => {
|
|
169
180
|
const newEdge = {};
|
|
170
|
-
|
|
171
|
-
|
|
181
|
+
const condition = mapEdgeCondition(edge.condition);
|
|
182
|
+
if (condition) {
|
|
183
|
+
newEdge.condition = condition;
|
|
172
184
|
}
|
|
173
185
|
if (edge.enabled === false) {
|
|
174
186
|
newEdge.disabled = true;
|
|
@@ -245,7 +257,7 @@ function execute(channel, engine, logger, plan, options = {}) {
|
|
|
245
257
|
addEvent("workflow-start", onWorkflowStart),
|
|
246
258
|
addEvent("job-start", onJobStart),
|
|
247
259
|
addEvent("job-complete", onJobComplete),
|
|
248
|
-
addEvent("log", onJobLog),
|
|
260
|
+
addEvent("workflow-log", onJobLog),
|
|
249
261
|
addEvent("workflow-complete", onWorkflowComplete),
|
|
250
262
|
addEvent("workflow-error", onWorkflowError)
|
|
251
263
|
);
|
|
@@ -498,10 +510,10 @@ function createServer(engine, options = {}) {
|
|
|
498
510
|
ctx.status = 204;
|
|
499
511
|
});
|
|
500
512
|
});
|
|
501
|
-
app.destroy = () => {
|
|
513
|
+
app.destroy = async () => {
|
|
502
514
|
logger.info("Closing server...");
|
|
503
515
|
server.close();
|
|
504
|
-
engine.destroy();
|
|
516
|
+
await engine.destroy();
|
|
505
517
|
app.killWorkloop?.();
|
|
506
518
|
logger.success("Server closed");
|
|
507
519
|
};
|
package/dist/start.js
CHANGED
|
@@ -4913,7 +4913,7 @@ async function createMock() {
|
|
|
4913
4913
|
await resolvers.credential?.(configuration);
|
|
4914
4914
|
}
|
|
4915
4915
|
const info = (...message) => {
|
|
4916
|
-
dispatch("log", {
|
|
4916
|
+
dispatch("workflow-log", {
|
|
4917
4917
|
workflowId,
|
|
4918
4918
|
message,
|
|
4919
4919
|
level: "info",
|
|
@@ -5096,6 +5096,17 @@ import crypto3 from "node:crypto";
|
|
|
5096
5096
|
|
|
5097
5097
|
// src/util/convert-attempt.ts
|
|
5098
5098
|
import crypto2 from "node:crypto";
|
|
5099
|
+
var conditions = {
|
|
5100
|
+
on_job_success: "!state.errors",
|
|
5101
|
+
on_job_failure: "state.errors",
|
|
5102
|
+
always: null
|
|
5103
|
+
};
|
|
5104
|
+
var mapEdgeCondition = (condition) => {
|
|
5105
|
+
if (condition && condition in conditions) {
|
|
5106
|
+
return conditions[condition];
|
|
5107
|
+
}
|
|
5108
|
+
return condition;
|
|
5109
|
+
};
|
|
5099
5110
|
var convert_attempt_default = (attempt) => {
|
|
5100
5111
|
const options = attempt.options || {};
|
|
5101
5112
|
const plan = {
|
|
@@ -5141,8 +5152,9 @@ var convert_attempt_default = (attempt) => {
|
|
|
5141
5152
|
}
|
|
5142
5153
|
const next = edges.filter((e) => e.source_job_id === id).reduce((obj, edge) => {
|
|
5143
5154
|
const newEdge = {};
|
|
5144
|
-
|
|
5145
|
-
|
|
5155
|
+
const condition = mapEdgeCondition(edge.condition);
|
|
5156
|
+
if (condition) {
|
|
5157
|
+
newEdge.condition = condition;
|
|
5146
5158
|
}
|
|
5147
5159
|
if (edge.enabled === false) {
|
|
5148
5160
|
newEdge.disabled = true;
|
|
@@ -5219,7 +5231,7 @@ function execute(channel, engine, logger2, plan, options = {}) {
|
|
|
5219
5231
|
addEvent("workflow-start", onWorkflowStart),
|
|
5220
5232
|
addEvent("job-start", onJobStart),
|
|
5221
5233
|
addEvent("job-complete", onJobComplete),
|
|
5222
|
-
addEvent("log", onJobLog),
|
|
5234
|
+
addEvent("workflow-log", onJobLog),
|
|
5223
5235
|
addEvent("workflow-complete", onWorkflowComplete),
|
|
5224
5236
|
addEvent("workflow-error", onWorkflowError)
|
|
5225
5237
|
);
|
|
@@ -5472,10 +5484,10 @@ function createServer(engine, options = {}) {
|
|
|
5472
5484
|
ctx.status = 204;
|
|
5473
5485
|
});
|
|
5474
5486
|
});
|
|
5475
|
-
app.destroy = () => {
|
|
5487
|
+
app.destroy = async () => {
|
|
5476
5488
|
logger2.info("Closing server...");
|
|
5477
5489
|
server.close();
|
|
5478
|
-
engine.destroy();
|
|
5490
|
+
await engine.destroy();
|
|
5479
5491
|
app.killWorkloop?.();
|
|
5480
5492
|
logger2.success("Server closed");
|
|
5481
5493
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/ws-worker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"koa-logger": "^3.2.1",
|
|
22
22
|
"phoenix": "^1.7.7",
|
|
23
23
|
"ws": "^8.14.1",
|
|
24
|
-
"@openfn/engine-multi": "0.1.
|
|
25
|
-
"@openfn/
|
|
26
|
-
"@openfn/
|
|
24
|
+
"@openfn/engine-multi": "0.1.3",
|
|
25
|
+
"@openfn/logger": "0.0.18",
|
|
26
|
+
"@openfn/runtime": "0.0.32"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/koa": "^2.13.5",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsup": "^6.2.3",
|
|
41
41
|
"typescript": "^4.6.4",
|
|
42
42
|
"yargs": "^17.6.2",
|
|
43
|
-
"@openfn/lightning-mock": "1.0.
|
|
43
|
+
"@openfn/lightning-mock": "1.0.4"
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
46
46
|
"dist",
|