@cadenza.io/core 3.0.6 → 3.0.7

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
@@ -2299,7 +2299,7 @@ var GraphRunner = class extends SignalEmitter {
2299
2299
  * @edge Empty tasks warns no-op.
2300
2300
  */
2301
2301
  addTasks(tasks, context = {}) {
2302
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2302
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2303
2303
  let _tasks = Array.isArray(tasks) ? tasks : [tasks];
2304
2304
  if (_tasks.length === 0) {
2305
2305
  console.warn("No tasks/routines to add.");
@@ -2321,12 +2321,13 @@ var GraphRunner = class extends SignalEmitter {
2321
2321
  });
2322
2322
  const isSubMeta = allTasks.some((t) => t.isSubMeta) || !!context.__isSubMeta;
2323
2323
  context.__isSubMeta = isSubMeta;
2324
- const ctx = new GraphContext(context || {});
2325
- const isNewTrace = !!context.__routineExecId;
2326
- const routineExecId = (_a = context.__routineExecId) != null ? _a : uuid4();
2324
+ const isNewTrace = !context.__routineExecId && !((_a = context.__metadata) == null ? void 0 : _a.__executionTraceId) && !context.__executionTraceId;
2325
+ const executionTraceId = (_d = (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId) != null ? _d : uuid4();
2326
+ context.__executionTraceId = executionTraceId;
2327
+ const routineExecId = (_e = context.__routineExecId) != null ? _e : uuid4();
2327
2328
  context.__routineExecId = routineExecId;
2329
+ const ctx = new GraphContext(context || {});
2328
2330
  if (!isSubMeta) {
2329
- const executionTraceId = (_d = (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId) != null ? _d : uuid4();
2330
2331
  const contextData = ctx.export();
2331
2332
  if (isNewTrace) {
2332
2333
  this.emitMetrics("meta.runner.new_trace", {
@@ -2334,9 +2335,9 @@ var GraphRunner = class extends SignalEmitter {
2334
2335
  uuid: executionTraceId,
2335
2336
  issuer_type: "service",
2336
2337
  // TODO: Add issuer type
2337
- issuer_id: (_g = (_f = (_e = context.__metadata) == null ? void 0 : _e.__issuerId) != null ? _f : context.__issuerId) != null ? _g : null,
2338
+ issuer_id: (_h = (_g = (_f = context.__metadata) == null ? void 0 : _f.__issuerId) != null ? _g : context.__issuerId) != null ? _h : null,
2338
2339
  issued_at: formatTimestamp(Date.now()),
2339
- intent: (_j = (_i = (_h = context.__metadata) == null ? void 0 : _h.__intent) != null ? _i : context.__intent) != null ? _j : null,
2340
+ intent: (_k = (_j = (_i = context.__metadata) == null ? void 0 : _i.__intent) != null ? _j : context.__intent) != null ? _k : null,
2340
2341
  context: contextData,
2341
2342
  is_meta: isMeta
2342
2343
  },
@@ -2353,7 +2354,7 @@ var GraphRunner = class extends SignalEmitter {
2353
2354
  isMeta,
2354
2355
  executionTraceId,
2355
2356
  context: isNewTrace ? contextData.id : contextData,
2356
- previousRoutineExecution: (_l = (_k = context.__metadata) == null ? void 0 : _k.__routineExecId) != null ? _l : null,
2357
+ previousRoutineExecution: (_m = (_l = context.__metadata) == null ? void 0 : _l.__routineExecId) != null ? _m : null,
2357
2358
  // TODO: There is a chance this is not added to the database yet...
2358
2359
  created: formatTimestamp(Date.now())
2359
2360
  },