@openfn/ws-worker 0.2.2 → 0.2.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 +6 -0
- package/dist/index.js +27 -21
- package/dist/start.js +27 -21
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -216,7 +216,7 @@ var stringify_default = (obj) => stringify(obj, (_key, value) => {
|
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
// src/api/reasons.ts
|
|
219
|
-
var calculateJobExitReason = (jobId, state, error) => {
|
|
219
|
+
var calculateJobExitReason = (jobId, state = { data: {} }, error) => {
|
|
220
220
|
let reason = "success";
|
|
221
221
|
let error_type = null;
|
|
222
222
|
let error_message = null;
|
|
@@ -231,12 +231,14 @@ var calculateJobExitReason = (jobId, state, error) => {
|
|
|
231
231
|
return { reason, error_type, error_message };
|
|
232
232
|
};
|
|
233
233
|
var calculateAttemptExitReason = (state) => {
|
|
234
|
-
if (state.reasons) {
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
)
|
|
238
|
-
|
|
234
|
+
if (state.plan && state.reasons) {
|
|
235
|
+
const leafJobReasons = state.plan.jobs.filter(({ next }) => !next || Object.keys(next).length == 0).map(({ id }) => state.reasons[id]);
|
|
236
|
+
const fail = leafJobReasons.find((r) => r && r.reason === "fail");
|
|
237
|
+
if (fail) {
|
|
238
|
+
return fail;
|
|
239
|
+
}
|
|
239
240
|
}
|
|
241
|
+
return { reason: "success", error_type: null, error_message: null };
|
|
240
242
|
};
|
|
241
243
|
|
|
242
244
|
// src/api/execute.ts
|
|
@@ -339,21 +341,25 @@ function onJobComplete({ channel, state }, event, error) {
|
|
|
339
341
|
state.lastDataclipId = dataclipId;
|
|
340
342
|
delete state.activeRun;
|
|
341
343
|
delete state.activeJob;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
344
|
+
try {
|
|
345
|
+
const { reason, error_message, error_type } = calculateJobExitReason(
|
|
346
|
+
job_id,
|
|
347
|
+
event.state,
|
|
348
|
+
error
|
|
349
|
+
);
|
|
350
|
+
state.reasons[job_id] = { reason, error_message, error_type };
|
|
351
|
+
return sendEvent(channel, RUN_COMPLETE, {
|
|
352
|
+
run_id,
|
|
353
|
+
job_id,
|
|
354
|
+
output_dataclip_id: dataclipId,
|
|
355
|
+
output_dataclip: stringify_default(event.state),
|
|
356
|
+
reason,
|
|
357
|
+
error_message,
|
|
358
|
+
error_type
|
|
359
|
+
});
|
|
360
|
+
} catch (e) {
|
|
361
|
+
console.log(e);
|
|
362
|
+
}
|
|
357
363
|
}
|
|
358
364
|
function onWorkflowStart({ channel }, _event) {
|
|
359
365
|
return sendEvent(channel, ATTEMPT_START);
|
package/dist/start.js
CHANGED
|
@@ -5198,7 +5198,7 @@ var stringify_default = (obj) => stringify(obj, (_key, value) => {
|
|
|
5198
5198
|
});
|
|
5199
5199
|
|
|
5200
5200
|
// src/api/reasons.ts
|
|
5201
|
-
var calculateJobExitReason = (jobId, state, error) => {
|
|
5201
|
+
var calculateJobExitReason = (jobId, state = { data: {} }, error) => {
|
|
5202
5202
|
let reason = "success";
|
|
5203
5203
|
let error_type = null;
|
|
5204
5204
|
let error_message = null;
|
|
@@ -5213,12 +5213,14 @@ var calculateJobExitReason = (jobId, state, error) => {
|
|
|
5213
5213
|
return { reason, error_type, error_message };
|
|
5214
5214
|
};
|
|
5215
5215
|
var calculateAttemptExitReason = (state) => {
|
|
5216
|
-
if (state.reasons) {
|
|
5217
|
-
const
|
|
5218
|
-
|
|
5219
|
-
)
|
|
5220
|
-
|
|
5216
|
+
if (state.plan && state.reasons) {
|
|
5217
|
+
const leafJobReasons = state.plan.jobs.filter(({ next }) => !next || Object.keys(next).length == 0).map(({ id }) => state.reasons[id]);
|
|
5218
|
+
const fail = leafJobReasons.find((r) => r && r.reason === "fail");
|
|
5219
|
+
if (fail) {
|
|
5220
|
+
return fail;
|
|
5221
|
+
}
|
|
5221
5222
|
}
|
|
5223
|
+
return { reason: "success", error_type: null, error_message: null };
|
|
5222
5224
|
};
|
|
5223
5225
|
|
|
5224
5226
|
// src/api/execute.ts
|
|
@@ -5321,21 +5323,25 @@ function onJobComplete({ channel, state }, event, error) {
|
|
|
5321
5323
|
state.lastDataclipId = dataclipId;
|
|
5322
5324
|
delete state.activeRun;
|
|
5323
5325
|
delete state.activeJob;
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5326
|
+
try {
|
|
5327
|
+
const { reason, error_message, error_type } = calculateJobExitReason(
|
|
5328
|
+
job_id,
|
|
5329
|
+
event.state,
|
|
5330
|
+
error
|
|
5331
|
+
);
|
|
5332
|
+
state.reasons[job_id] = { reason, error_message, error_type };
|
|
5333
|
+
return sendEvent(channel, RUN_COMPLETE, {
|
|
5334
|
+
run_id,
|
|
5335
|
+
job_id,
|
|
5336
|
+
output_dataclip_id: dataclipId,
|
|
5337
|
+
output_dataclip: stringify_default(event.state),
|
|
5338
|
+
reason,
|
|
5339
|
+
error_message,
|
|
5340
|
+
error_type
|
|
5341
|
+
});
|
|
5342
|
+
} catch (e) {
|
|
5343
|
+
console.log(e);
|
|
5344
|
+
}
|
|
5339
5345
|
}
|
|
5340
5346
|
function onWorkflowStart({ channel }, _event) {
|
|
5341
5347
|
return sendEvent(channel, ATTEMPT_START);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/ws-worker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"phoenix": "^1.7.7",
|
|
23
23
|
"ws": "^8.14.1",
|
|
24
24
|
"@openfn/engine-multi": "0.1.8",
|
|
25
|
-
"@openfn/
|
|
26
|
-
"@openfn/
|
|
25
|
+
"@openfn/runtime": "0.1.1",
|
|
26
|
+
"@openfn/logger": "0.0.19"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/koa": "^2.13.5",
|