@openfn/ws-worker 1.16.0 → 1.17.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # ws-worker
2
2
 
3
+ ## 1.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 09dd4b2: - Add `final_state` object to `workflow:complete` event
8
+ - Remove unused `final_dataclip_id` from `workflow:complete` payload
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [09dd4b2]
13
+ - @openfn/lexicon@1.2.4
14
+
15
+ ## 1.16.1
16
+
17
+ ### Patch Changes
18
+
19
+ - cb97744: Improve compiler performance for large files
20
+ - @openfn/engine-multi@1.6.14
21
+
3
22
  ## 1.16.0
4
23
 
5
24
  ### Minor Changes
package/dist/index.js CHANGED
@@ -348,10 +348,6 @@ var convert_lightning_plan_default = (run, options = {}) => {
348
348
  engineOpts.jobLogLevel = run.options.job_log_level;
349
349
  }
350
350
  }
351
- const plan = {
352
- id: run.id,
353
- options: runtimeOpts
354
- };
355
351
  let initialState;
356
352
  if (run.dataclip_id) {
357
353
  initialState = run.dataclip_id;
@@ -415,8 +411,14 @@ var convert_lightning_plan_default = (run, options = {}) => {
415
411
  nodes[id] = job;
416
412
  });
417
413
  }
418
- plan.workflow = {
419
- steps: Object.values(nodes)
414
+ const plan = {
415
+ id: run.id,
416
+ options: runtimeOpts,
417
+ workflow: {
418
+ // id: run.workflowId, // TODO: lightning does not send this
419
+ // name: run.name, // TODO: lightning does not send this
420
+ steps: Object.values(nodes)
421
+ }
420
422
  };
421
423
  if (run.globals && typeof run.globals === "string")
422
424
  plan.workflow.globals = run.globals;
@@ -806,12 +808,12 @@ var log_final_reason_default = async (context, reason) => {
806
808
  // src/events/run-complete.ts
807
809
  async function onWorkflowComplete(context, event) {
808
810
  const { state, onFinish, logger } = context;
809
- const result = state.dataclips[state.lastDataclipId];
811
+ const result = event.state;
810
812
  const reason = calculateRunExitReason(state);
811
813
  await log_final_reason_default(context, reason);
812
814
  try {
813
815
  await sendEvent(context, RUN_COMPLETE, {
814
- final_dataclip_id: state.lastDataclipId,
816
+ final_state: result,
815
817
  timestamp: timeInMicroseconds(event.time),
816
818
  ...reason
817
819
  });
@@ -834,7 +836,6 @@ async function onRunError(context, event) {
834
836
  }
835
837
  await log_final_reason_default(context, reason);
836
838
  await sendEvent(context, RUN_COMPLETE, {
837
- final_dataclip_id: state.lastDataclipId,
838
839
  ...reason
839
840
  });
840
841
  onFinish({ reason });
package/dist/start.js CHANGED
@@ -105,10 +105,19 @@ async function createMock() {
105
105
  }
106
106
  };
107
107
  setTimeout(async () => {
108
+ const startTime = Date.now();
108
109
  dispatch("workflow-start", { workflowId: id, threadId });
109
110
  try {
110
- await run(xplan, input, opts);
111
- dispatch("workflow-complete", { workflowId: id, threadId });
111
+ const result = await run(xplan, input, opts);
112
+ const duration = Date.now() - startTime;
113
+ dispatch("workflow-complete", {
114
+ workflowId: id,
115
+ threadId,
116
+ state: result,
117
+ duration,
118
+ time: BigInt(Date.now()) * BigInt(1e6)
119
+ // Convert to nanoseconds
120
+ });
112
121
  } catch (e) {
113
122
  dispatch("workflow-error", {
114
123
  threadId,
@@ -488,10 +497,6 @@ var convert_lightning_plan_default = (run2, options = {}) => {
488
497
  engineOpts.jobLogLevel = run2.options.job_log_level;
489
498
  }
490
499
  }
491
- const plan = {
492
- id: run2.id,
493
- options: runtimeOpts
494
- };
495
500
  let initialState;
496
501
  if (run2.dataclip_id) {
497
502
  initialState = run2.dataclip_id;
@@ -555,8 +560,14 @@ var convert_lightning_plan_default = (run2, options = {}) => {
555
560
  nodes[id] = job;
556
561
  });
557
562
  }
558
- plan.workflow = {
559
- steps: Object.values(nodes)
563
+ const plan = {
564
+ id: run2.id,
565
+ options: runtimeOpts,
566
+ workflow: {
567
+ // id: run.workflowId, // TODO: lightning does not send this
568
+ // name: run.name, // TODO: lightning does not send this
569
+ steps: Object.values(nodes)
570
+ }
560
571
  };
561
572
  if (run2.globals && typeof run2.globals === "string")
562
573
  plan.workflow.globals = run2.globals;
@@ -946,12 +957,12 @@ var log_final_reason_default = async (context, reason) => {
946
957
  // src/events/run-complete.ts
947
958
  async function onWorkflowComplete(context, event) {
948
959
  const { state, onFinish, logger: logger2 } = context;
949
- const result = state.dataclips[state.lastDataclipId];
960
+ const result = event.state;
950
961
  const reason = calculateRunExitReason(state);
951
962
  await log_final_reason_default(context, reason);
952
963
  try {
953
964
  await sendEvent(context, RUN_COMPLETE, {
954
- final_dataclip_id: state.lastDataclipId,
965
+ final_state: result,
955
966
  timestamp: timeInMicroseconds(event.time),
956
967
  ...reason
957
968
  });
@@ -974,7 +985,6 @@ async function onRunError(context, event) {
974
985
  }
975
986
  await log_final_reason_default(context, reason);
976
987
  await sendEvent(context, RUN_COMPLETE, {
977
- final_dataclip_id: state.lastDataclipId,
978
988
  ...reason
979
989
  });
980
990
  onFinish({ reason });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/ws-worker",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "A Websocket Worker to connect Lightning to a Runtime Engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -23,10 +23,10 @@
23
23
  "koa-logger": "^3.2.1",
24
24
  "phoenix": "1.7.10",
25
25
  "ws": "^8.18.3",
26
- "@openfn/engine-multi": "1.6.13",
26
+ "@openfn/lexicon": "^1.2.5",
27
27
  "@openfn/logger": "1.0.6",
28
28
  "@openfn/runtime": "1.7.3",
29
- "@openfn/lexicon": "^1.2.3"
29
+ "@openfn/engine-multi": "1.6.14"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/koa": "^2.15.0",
@@ -43,7 +43,7 @@
43
43
  "tsup": "^6.7.0",
44
44
  "typescript": "^4.9.5",
45
45
  "yargs": "^17.7.2",
46
- "@openfn/lightning-mock": "2.2.8"
46
+ "@openfn/lightning-mock": "2.3.0"
47
47
  },
48
48
  "files": [
49
49
  "dist",