@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.js CHANGED
@@ -987,9 +987,9 @@ var GraphNode = class _GraphNode extends SignalEmitter {
987
987
  }
988
988
  }
989
989
  emitWithMetadata(signal, ctx) {
990
- var _a, _b;
990
+ var _a, _b, _c;
991
991
  const data = { ...ctx };
992
- if (!this.task.isHidden) {
992
+ if (!((_a = this.task) == null ? void 0 : _a.isHidden)) {
993
993
  data.__signalEmission = {
994
994
  taskName: this.task.name,
995
995
  taskVersion: this.task.version,
@@ -999,15 +999,15 @@ var GraphNode = class _GraphNode extends SignalEmitter {
999
999
  data.__metadata = {
1000
1000
  ...data.__metadata,
1001
1001
  __routineExecId: this.routineExecId,
1002
- __executionTraceId: (_b = (_a = context.__metadata) == null ? void 0 : _a.__executionTraceId) != null ? _b : context.__executionTraceId
1002
+ __executionTraceId: (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId
1003
1003
  };
1004
1004
  }
1005
1005
  this.emit(signal, data);
1006
1006
  }
1007
1007
  emitMetricsWithMetadata(signal, ctx) {
1008
- var _a, _b;
1008
+ var _a, _b, _c;
1009
1009
  const data = { ...ctx };
1010
- if (!this.task.isHidden) {
1010
+ if (!((_a = this.task) == null ? void 0 : _a.isHidden)) {
1011
1011
  data.__signalEmission = {
1012
1012
  taskName: this.task.name,
1013
1013
  taskVersion: this.task.version,
@@ -1018,7 +1018,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
1018
1018
  data.__metadata = {
1019
1019
  ...data.__metadata,
1020
1020
  __routineExecId: this.routineExecId,
1021
- __executionTraceId: (_b = (_a = context.__metadata) == null ? void 0 : _a.__executionTraceId) != null ? _b : context.__executionTraceId
1021
+ __executionTraceId: (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId
1022
1022
  };
1023
1023
  }
1024
1024
  this.emitMetrics(signal, data);
@@ -2138,6 +2138,7 @@ var Task = class extends SignalEmitter {
2138
2138
  filter: { name: this.name, version: this.version }
2139
2139
  });
2140
2140
  }
2141
+ console.log("Task destroyed", this.name);
2141
2142
  }
2142
2143
  export() {
2143
2144
  return {
@@ -2264,8 +2265,8 @@ var GraphRegistry = class _GraphRegistry {
2264
2265
  this.deleteTask = Cadenza.createMetaTask(
2265
2266
  "Delete task",
2266
2267
  (context) => {
2267
- const { __name } = context;
2268
- this.tasks.delete(__name);
2268
+ const { filter } = context;
2269
+ this.tasks.delete(filter.name);
2269
2270
  return context;
2270
2271
  },
2271
2272
  "Deletes task."
@@ -2370,7 +2371,7 @@ var GraphRunner = class extends SignalEmitter {
2370
2371
  * @edge Empty tasks warns no-op.
2371
2372
  */
2372
2373
  addTasks(tasks, context = {}) {
2373
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2374
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
2374
2375
  let _tasks = Array.isArray(tasks) ? tasks : [tasks];
2375
2376
  if (_tasks.length === 0) {
2376
2377
  console.warn("No tasks/routines to add.");
@@ -2425,7 +2426,7 @@ var GraphRunner = class extends SignalEmitter {
2425
2426
  isMeta,
2426
2427
  executionTraceId,
2427
2428
  context: isNewTrace ? contextData.id : contextData,
2428
- previousRoutineExecution: (_m = (_l = context.__metadata) == null ? void 0 : _l.__routineExecId) != null ? _m : null,
2429
+ previousRoutineExecution: (_n = (_m = context.__localRoutineExecId) != null ? _m : (_l = context.__metadata) == null ? void 0 : _l.__routineExecId) != null ? _n : null,
2429
2430
  // TODO: There is a chance this is not added to the database yet...
2430
2431
  created: formatTimestamp(Date.now())
2431
2432
  },
@@ -2491,6 +2492,7 @@ var GraphRunner = class extends SignalEmitter {
2491
2492
  this.currentRun = new GraphRun(this.strategy);
2492
2493
  }
2493
2494
  }
2495
+ // TODO This should not live here. This is deputy related.
2494
2496
  startRun(context, emit) {
2495
2497
  var _a, _b, _c;
2496
2498
  if (context.__task || context.__routine) {
@@ -2663,8 +2665,8 @@ var EphemeralTask = class extends Task {
2663
2665
  const result = super.execute(context, emit, progressCallback);
2664
2666
  if (this.once || this.condition(result)) {
2665
2667
  this.destroy();
2666
- return result;
2667
2668
  }
2669
+ return result;
2668
2670
  }
2669
2671
  };
2670
2672