@openfn/ws-worker 1.5.1 → 1.6.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,19 @@
1
1
  # ws-worker
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - eaa3859: Include timestamps in key events
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [870a836]
12
+ - Updated dependencies [44f7f57]
13
+ - @openfn/engine-multi@1.2.2
14
+ - @openfn/lexicon@1.1.0
15
+ - @openfn/runtime@1.4.1
16
+
3
17
  ## 1.5.1
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ var name, version, description, main, type, scripts, bin, author, license, depen
29
29
  var init_package = __esm({
30
30
  "package.json"() {
31
31
  name = "@openfn/ws-worker";
32
- version = "1.5.1";
32
+ version = "1.6.0";
33
33
  description = "A Websocket Worker to connect Lightning to a Runtime Engine";
34
34
  main = "dist/index.js";
35
35
  type = "module";
@@ -508,6 +508,9 @@ var createThrottler = () => {
508
508
  };
509
509
  var throttle_default = createThrottler;
510
510
 
511
+ // src/util/timestamp.ts
512
+ var timeInMicroseconds = (time) => time && (BigInt(time) / BigInt(1e3)).toString();
513
+
511
514
  // src/events/run-start.ts
512
515
  import { timestamp } from "@openfn/logger";
513
516
 
@@ -549,7 +552,10 @@ async function onRunStart(context, event) {
549
552
  worker: package_default.version,
550
553
  ...event.versions
551
554
  };
552
- await sendEvent(channel, RUN_START, { versions });
555
+ await sendEvent(channel, RUN_START, {
556
+ versions,
557
+ timestamp: timeInMicroseconds(event.time)
558
+ });
553
559
  if ("payloadLimitMb" in options) {
554
560
  await onJobLog(versionLogContext, {
555
561
  time,
@@ -642,7 +648,8 @@ async function onStepComplete(context, event, error) {
642
648
  job_id,
643
649
  mem: event.mem,
644
650
  duration: event.duration,
645
- thread_id: event.threadId
651
+ thread_id: event.threadId,
652
+ timestamp: timeInMicroseconds(event.time)
646
653
  };
647
654
  try {
648
655
  if (!options || options.outputDataclips !== false) {
@@ -679,7 +686,8 @@ async function onStepStart(context, event) {
679
686
  await sendEvent(channel, STEP_START, {
680
687
  step_id: state.activeStep,
681
688
  job_id: state.activeJob,
682
- input_dataclip_id
689
+ input_dataclip_id,
690
+ timestamp: timeInMicroseconds(event.time)
683
691
  });
684
692
  }
685
693
 
@@ -701,7 +709,7 @@ ${reason.error_type}: ${reason.error_message || "unknown"}`;
701
709
  };
702
710
 
703
711
  // src/events/run-complete.ts
704
- async function onWorkflowComplete(context, _event) {
712
+ async function onWorkflowComplete(context, event) {
705
713
  const { state, channel, onFinish, logger } = context;
706
714
  const result = state.dataclips[state.lastDataclipId];
707
715
  const reason = calculateRunExitReason(state);
@@ -709,6 +717,7 @@ async function onWorkflowComplete(context, _event) {
709
717
  try {
710
718
  await sendEvent(channel, RUN_COMPLETE, {
711
719
  final_dataclip_id: state.lastDataclipId,
720
+ timestamp: timeInMicroseconds(event.time),
712
721
  ...reason
713
722
  });
714
723
  } catch (e) {
@@ -837,7 +846,6 @@ function onJobError(context, event) {
837
846
  }
838
847
  }
839
848
  function onJobLog({ channel, state, options }, event) {
840
- const timeInMicroseconds = BigInt(event.time) / BigInt(1e3);
841
849
  let message = event.message;
842
850
  try {
843
851
  if (typeof event.message === "string") {
@@ -857,7 +865,7 @@ function onJobLog({ channel, state, options }, event) {
857
865
  message,
858
866
  source: event.name,
859
867
  level: event.level,
860
- timestamp: timeInMicroseconds.toString()
868
+ timestamp: timeInMicroseconds(event.time)
861
869
  };
862
870
  if (state.activeStep) {
863
871
  log.step_id = state.activeStep;
package/dist/start.js CHANGED
@@ -37,7 +37,7 @@ var name, version, description, main, type, scripts, bin, author, license, depen
37
37
  var init_package = __esm({
38
38
  "package.json"() {
39
39
  name = "@openfn/ws-worker";
40
- version = "1.5.1";
40
+ version = "1.6.0";
41
41
  description = "A Websocket Worker to connect Lightning to a Runtime Engine";
42
42
  main = "dist/index.js";
43
43
  type = "module";
@@ -647,6 +647,9 @@ var createThrottler = () => {
647
647
  };
648
648
  var throttle_default = createThrottler;
649
649
 
650
+ // src/util/timestamp.ts
651
+ var timeInMicroseconds = (time) => time && (BigInt(time) / BigInt(1e3)).toString();
652
+
650
653
  // src/events/run-start.ts
651
654
  import { timestamp } from "@openfn/logger";
652
655
 
@@ -688,7 +691,10 @@ async function onRunStart(context, event) {
688
691
  worker: package_default.version,
689
692
  ...event.versions
690
693
  };
691
- await sendEvent(channel, RUN_START, { versions });
694
+ await sendEvent(channel, RUN_START, {
695
+ versions,
696
+ timestamp: timeInMicroseconds(event.time)
697
+ });
692
698
  if ("payloadLimitMb" in options) {
693
699
  await onJobLog(versionLogContext, {
694
700
  time,
@@ -781,7 +787,8 @@ async function onStepComplete(context, event, error) {
781
787
  job_id,
782
788
  mem: event.mem,
783
789
  duration: event.duration,
784
- thread_id: event.threadId
790
+ thread_id: event.threadId,
791
+ timestamp: timeInMicroseconds(event.time)
785
792
  };
786
793
  try {
787
794
  if (!options || options.outputDataclips !== false) {
@@ -818,7 +825,8 @@ async function onStepStart(context, event) {
818
825
  await sendEvent(channel, STEP_START, {
819
826
  step_id: state.activeStep,
820
827
  job_id: state.activeJob,
821
- input_dataclip_id
828
+ input_dataclip_id,
829
+ timestamp: timeInMicroseconds(event.time)
822
830
  });
823
831
  }
824
832
 
@@ -840,7 +848,7 @@ ${reason.error_type}: ${reason.error_message || "unknown"}`;
840
848
  };
841
849
 
842
850
  // src/events/run-complete.ts
843
- async function onWorkflowComplete(context, _event) {
851
+ async function onWorkflowComplete(context, event) {
844
852
  const { state, channel, onFinish, logger: logger2 } = context;
845
853
  const result = state.dataclips[state.lastDataclipId];
846
854
  const reason = calculateRunExitReason(state);
@@ -848,6 +856,7 @@ async function onWorkflowComplete(context, _event) {
848
856
  try {
849
857
  await sendEvent(channel, RUN_COMPLETE, {
850
858
  final_dataclip_id: state.lastDataclipId,
859
+ timestamp: timeInMicroseconds(event.time),
851
860
  ...reason
852
861
  });
853
862
  } catch (e) {
@@ -976,7 +985,6 @@ function onJobError(context, event) {
976
985
  }
977
986
  }
978
987
  function onJobLog({ channel, state, options }, event) {
979
- const timeInMicroseconds = BigInt(event.time) / BigInt(1e3);
980
988
  let message = event.message;
981
989
  try {
982
990
  if (typeof event.message === "string") {
@@ -996,7 +1004,7 @@ function onJobLog({ channel, state, options }, event) {
996
1004
  message,
997
1005
  source: event.name,
998
1006
  level: event.level,
999
- timestamp: timeInMicroseconds.toString()
1007
+ timestamp: timeInMicroseconds(event.time)
1000
1008
  };
1001
1009
  if (state.activeStep) {
1002
1010
  log.step_id = state.activeStep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/ws-worker",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "A Websocket Worker to connect Lightning to a Runtime Engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -22,10 +22,10 @@
22
22
  "koa-logger": "^3.2.1",
23
23
  "phoenix": "1.7.10",
24
24
  "ws": "^8.14.1",
25
- "@openfn/engine-multi": "1.2.1",
26
- "@openfn/lexicon": "^1.0.2",
27
- "@openfn/logger": "1.0.1",
28
- "@openfn/runtime": "1.4.1"
25
+ "@openfn/engine-multi": "1.2.2",
26
+ "@openfn/lexicon": "^1.1.0",
27
+ "@openfn/runtime": "1.4.1",
28
+ "@openfn/logger": "1.0.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/koa": "^2.13.5",
@@ -42,7 +42,7 @@
42
42
  "tsup": "^6.2.3",
43
43
  "typescript": "^4.6.4",
44
44
  "yargs": "^17.6.2",
45
- "@openfn/lightning-mock": "2.0.15"
45
+ "@openfn/lightning-mock": "2.0.16"
46
46
  },
47
47
  "files": [
48
48
  "dist",