@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.js CHANGED
@@ -2336,7 +2336,7 @@ var GraphRunner = class extends SignalEmitter {
2336
2336
  * @edge Empty tasks warns no-op.
2337
2337
  */
2338
2338
  addTasks(tasks, context = {}) {
2339
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2339
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2340
2340
  let _tasks = Array.isArray(tasks) ? tasks : [tasks];
2341
2341
  if (_tasks.length === 0) {
2342
2342
  console.warn("No tasks/routines to add.");
@@ -2358,12 +2358,13 @@ var GraphRunner = class extends SignalEmitter {
2358
2358
  });
2359
2359
  const isSubMeta = allTasks.some((t) => t.isSubMeta) || !!context.__isSubMeta;
2360
2360
  context.__isSubMeta = isSubMeta;
2361
- const ctx = new GraphContext(context || {});
2362
- const isNewTrace = !!context.__routineExecId;
2363
- const routineExecId = (_a = context.__routineExecId) != null ? _a : (0, import_uuid4.v4)();
2361
+ const isNewTrace = !context.__routineExecId && !((_a = context.__metadata) == null ? void 0 : _a.__executionTraceId) && !context.__executionTraceId;
2362
+ const executionTraceId = (_d = (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId) != null ? _d : (0, import_uuid4.v4)();
2363
+ context.__executionTraceId = executionTraceId;
2364
+ const routineExecId = (_e = context.__routineExecId) != null ? _e : (0, import_uuid4.v4)();
2364
2365
  context.__routineExecId = routineExecId;
2366
+ const ctx = new GraphContext(context || {});
2365
2367
  if (!isSubMeta) {
2366
- const executionTraceId = (_d = (_c = (_b = context.__metadata) == null ? void 0 : _b.__executionTraceId) != null ? _c : context.__executionTraceId) != null ? _d : (0, import_uuid4.v4)();
2367
2368
  const contextData = ctx.export();
2368
2369
  if (isNewTrace) {
2369
2370
  this.emitMetrics("meta.runner.new_trace", {
@@ -2371,9 +2372,9 @@ var GraphRunner = class extends SignalEmitter {
2371
2372
  uuid: executionTraceId,
2372
2373
  issuer_type: "service",
2373
2374
  // TODO: Add issuer type
2374
- issuer_id: (_g = (_f = (_e = context.__metadata) == null ? void 0 : _e.__issuerId) != null ? _f : context.__issuerId) != null ? _g : null,
2375
+ issuer_id: (_h = (_g = (_f = context.__metadata) == null ? void 0 : _f.__issuerId) != null ? _g : context.__issuerId) != null ? _h : null,
2375
2376
  issued_at: formatTimestamp(Date.now()),
2376
- intent: (_j = (_i = (_h = context.__metadata) == null ? void 0 : _h.__intent) != null ? _i : context.__intent) != null ? _j : null,
2377
+ intent: (_k = (_j = (_i = context.__metadata) == null ? void 0 : _i.__intent) != null ? _j : context.__intent) != null ? _k : null,
2377
2378
  context: contextData,
2378
2379
  is_meta: isMeta
2379
2380
  },
@@ -2390,7 +2391,7 @@ var GraphRunner = class extends SignalEmitter {
2390
2391
  isMeta,
2391
2392
  executionTraceId,
2392
2393
  context: isNewTrace ? contextData.id : contextData,
2393
- previousRoutineExecution: (_l = (_k = context.__metadata) == null ? void 0 : _k.__routineExecId) != null ? _l : null,
2394
+ previousRoutineExecution: (_m = (_l = context.__metadata) == null ? void 0 : _l.__routineExecId) != null ? _m : null,
2394
2395
  // TODO: There is a chance this is not added to the database yet...
2395
2396
  created: formatTimestamp(Date.now())
2396
2397
  },