@cadenza.io/core 3.1.4 → 3.1.6

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/index.mjs CHANGED
@@ -950,9 +950,9 @@ var GraphNode = class _GraphNode extends SignalEmitter {
950
950
  }
951
951
  }
952
952
  emitWithMetadata(signal, ctx) {
953
- var _a, _b;
953
+ var _a, _b, _c;
954
954
  const data = { ...ctx };
955
- if (!this.task.isHidden) {
955
+ if (!((_a = this.task) == null ? void 0 : _a.isHidden)) {
956
956
  data.__signalEmission = {
957
957
  taskName: this.task.name,
958
958
  taskVersion: this.task.version,
@@ -962,15 +962,15 @@ var GraphNode = class _GraphNode extends SignalEmitter {
962
962
  data.__metadata = {
963
963
  ...data.__metadata,
964
964
  __routineExecId: this.routineExecId,
965
- __executionTraceId: (_b = (_a = context.__metadata) == null ? void 0 : _a.__executionTraceId) != null ? _b : context.__executionTraceId
965
+ __executionTraceId: (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId
966
966
  };
967
967
  }
968
968
  this.emit(signal, data);
969
969
  }
970
970
  emitMetricsWithMetadata(signal, ctx) {
971
- var _a, _b;
971
+ var _a, _b, _c;
972
972
  const data = { ...ctx };
973
- if (!this.task.isHidden) {
973
+ if (!((_a = this.task) == null ? void 0 : _a.isHidden)) {
974
974
  data.__signalEmission = {
975
975
  taskName: this.task.name,
976
976
  taskVersion: this.task.version,
@@ -981,7 +981,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
981
981
  data.__metadata = {
982
982
  ...data.__metadata,
983
983
  __routineExecId: this.routineExecId,
984
- __executionTraceId: (_b = (_a = context.__metadata) == null ? void 0 : _a.__executionTraceId) != null ? _b : context.__executionTraceId
984
+ __executionTraceId: (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId
985
985
  };
986
986
  }
987
987
  this.emitMetrics(signal, data);
@@ -2101,6 +2101,7 @@ var Task = class extends SignalEmitter {
2101
2101
  filter: { name: this.name, version: this.version }
2102
2102
  });
2103
2103
  }
2104
+ console.log("Task destroyed", this.name);
2104
2105
  }
2105
2106
  export() {
2106
2107
  return {
@@ -2227,8 +2228,8 @@ var GraphRegistry = class _GraphRegistry {
2227
2228
  this.deleteTask = Cadenza.createMetaTask(
2228
2229
  "Delete task",
2229
2230
  (context) => {
2230
- const { __name } = context;
2231
- this.tasks.delete(__name);
2231
+ const { filter } = context;
2232
+ this.tasks.delete(filter.name);
2232
2233
  return context;
2233
2234
  },
2234
2235
  "Deletes task."
@@ -2333,7 +2334,7 @@ var GraphRunner = class extends SignalEmitter {
2333
2334
  * @edge Empty tasks warns no-op.
2334
2335
  */
2335
2336
  addTasks(tasks, context = {}) {
2336
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2337
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
2337
2338
  let _tasks = Array.isArray(tasks) ? tasks : [tasks];
2338
2339
  if (_tasks.length === 0) {
2339
2340
  console.warn("No tasks/routines to add.");
@@ -2388,7 +2389,7 @@ var GraphRunner = class extends SignalEmitter {
2388
2389
  isMeta,
2389
2390
  executionTraceId,
2390
2391
  context: isNewTrace ? contextData.id : contextData,
2391
- previousRoutineExecution: (_m = (_l = context.__metadata) == null ? void 0 : _l.__routineExecId) != null ? _m : null,
2392
+ previousRoutineExecution: (_n = (_m = context.__localRoutineExecId) != null ? _m : (_l = context.__metadata) == null ? void 0 : _l.__routineExecId) != null ? _n : null,
2392
2393
  // TODO: There is a chance this is not added to the database yet...
2393
2394
  created: formatTimestamp(Date.now())
2394
2395
  },
@@ -2454,6 +2455,7 @@ var GraphRunner = class extends SignalEmitter {
2454
2455
  this.currentRun = new GraphRun(this.strategy);
2455
2456
  }
2456
2457
  }
2458
+ // TODO This should not live here. This is deputy related.
2457
2459
  startRun(context, emit) {
2458
2460
  var _a, _b, _c;
2459
2461
  if (context.__task || context.__routine) {
@@ -2626,8 +2628,8 @@ var EphemeralTask = class extends Task {
2626
2628
  const result = super.execute(context, emit, progressCallback);
2627
2629
  if (this.once || this.condition(result)) {
2628
2630
  this.destroy();
2629
- return result;
2630
2631
  }
2632
+ return result;
2631
2633
  }
2632
2634
  };
2633
2635