@cadenza.io/service 2.17.63 → 2.17.65

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
@@ -6536,6 +6536,7 @@ var SCHEMA_TYPES = [
6536
6536
  import { Pool } from "pg";
6537
6537
  import { camelCase, kebabCase, snakeCase } from "lodash-es";
6538
6538
  var AUTHORITY_SYNC_DEBUG_PREFIX = "[CADENZA_DB_TASK_DEBUG]";
6539
+ var AUTHORITY_SYNC_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env === "object" && process.env.CADENZA_DB_TASK_DEBUG === "true";
6539
6540
  var AUTHORITY_SYNC_DEBUG_TASK_NAMES = /* @__PURE__ */ new Set([
6540
6541
  "Query service_instance",
6541
6542
  "Query service_instance_transport",
@@ -6550,6 +6551,9 @@ var AUTHORITY_SYNC_DEBUG_TASK_NAMES = /* @__PURE__ */ new Set([
6550
6551
  ]);
6551
6552
  var AUTHORITY_SYNC_DEBUG_ROUTINE_NAMES = /* @__PURE__ */ new Set(["Sync services"]);
6552
6553
  function logAuthoritySyncDebug(event, payload) {
6554
+ if (!AUTHORITY_SYNC_DEBUG_ENABLED) {
6555
+ return;
6556
+ }
6553
6557
  console.log(`${AUTHORITY_SYNC_DEBUG_PREFIX} ${event}`, payload);
6554
6558
  }
6555
6559
  function resolveAuthoritySyncPayloadName(payload, tableName) {
@@ -6568,6 +6572,9 @@ function resolveAuthoritySyncPayloadName(payload, tableName) {
6568
6572
  return null;
6569
6573
  }
6570
6574
  function shouldDebugAuthoritySyncPayload(tableName, payload) {
6575
+ if (!AUTHORITY_SYNC_DEBUG_ENABLED) {
6576
+ return false;
6577
+ }
6571
6578
  if (tableName !== "task" && tableName !== "task_to_routine_map") {
6572
6579
  return false;
6573
6580
  }
@@ -8741,6 +8748,16 @@ function didSyncInsertSucceed(ctx) {
8741
8748
  }
8742
8749
  return true;
8743
8750
  }
8751
+ function buildMinimalSyncSignalContext(ctx, extra = {}) {
8752
+ const nextContext = {
8753
+ __syncing: ctx.__syncing === true,
8754
+ ...extra
8755
+ };
8756
+ if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
8757
+ nextContext.__reason = ctx.__reason;
8758
+ }
8759
+ return nextContext;
8760
+ }
8744
8761
  function buildSyncInsertQueryData(ctx, queryData = {}) {
8745
8762
  const joinedQueryData = getJoinedContextValue(ctx, "queryData");
8746
8763
  const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
@@ -9245,10 +9262,10 @@ var GraphSyncController = class _GraphSyncController {
9245
9262
  const shouldEmit = !this.tasksSynced;
9246
9263
  this.tasksSynced = true;
9247
9264
  if (shouldEmit) {
9248
- emit("meta.sync_controller.synced_tasks", {
9249
- __syncing: true,
9250
- ...ctx
9251
- });
9265
+ emit(
9266
+ "meta.sync_controller.synced_tasks",
9267
+ buildMinimalSyncSignalContext(ctx)
9268
+ );
9252
9269
  }
9253
9270
  return true;
9254
9271
  };
@@ -9263,10 +9280,10 @@ var GraphSyncController = class _GraphSyncController {
9263
9280
  const shouldEmit = !this.routinesSynced;
9264
9281
  this.routinesSynced = true;
9265
9282
  if (shouldEmit) {
9266
- emit("meta.sync_controller.synced_routines", {
9267
- __syncing: true,
9268
- ...ctx
9269
- });
9283
+ emit(
9284
+ "meta.sync_controller.synced_routines",
9285
+ buildMinimalSyncSignalContext(ctx)
9286
+ );
9270
9287
  }
9271
9288
  return true;
9272
9289
  };
@@ -9281,10 +9298,10 @@ var GraphSyncController = class _GraphSyncController {
9281
9298
  const shouldEmit = !this.signalsSynced;
9282
9299
  this.signalsSynced = true;
9283
9300
  if (shouldEmit) {
9284
- emit("meta.sync_controller.synced_signals", {
9285
- __syncing: true,
9286
- ...ctx
9287
- });
9301
+ emit(
9302
+ "meta.sync_controller.synced_signals",
9303
+ buildMinimalSyncSignalContext(ctx)
9304
+ );
9288
9305
  }
9289
9306
  return true;
9290
9307
  };
@@ -9299,10 +9316,10 @@ var GraphSyncController = class _GraphSyncController {
9299
9316
  const shouldEmit = !this.intentsSynced;
9300
9317
  this.intentsSynced = true;
9301
9318
  if (shouldEmit) {
9302
- emit("meta.sync_controller.synced_intents", {
9303
- __syncing: true,
9304
- ...ctx
9305
- });
9319
+ emit(
9320
+ "meta.sync_controller.synced_intents",
9321
+ buildMinimalSyncSignalContext(ctx)
9322
+ );
9306
9323
  }
9307
9324
  return true;
9308
9325
  };
@@ -9320,10 +9337,10 @@ var GraphSyncController = class _GraphSyncController {
9320
9337
  const shouldEmit = !this.actorsSynced;
9321
9338
  this.actorsSynced = true;
9322
9339
  if (shouldEmit) {
9323
- emit("meta.sync_controller.synced_actors", {
9324
- __syncing: true,
9325
- ...ctx
9326
- });
9340
+ emit(
9341
+ "meta.sync_controller.synced_actors",
9342
+ buildMinimalSyncSignalContext(ctx)
9343
+ );
9327
9344
  }
9328
9345
  return true;
9329
9346
  };
@@ -9670,10 +9687,12 @@ var GraphSyncController = class _GraphSyncController {
9670
9687
  delayMs: 3e3
9671
9688
  });
9672
9689
  CadenzaService.get(ctx.__taskName).registered = true;
9673
- emit("meta.sync_controller.task_registered", {
9674
- ...ctx,
9675
- task: CadenzaService.get(ctx.__taskName)
9676
- });
9690
+ emit(
9691
+ "meta.sync_controller.task_registered",
9692
+ buildMinimalSyncSignalContext(ctx, {
9693
+ __taskName: ctx.__taskName
9694
+ })
9695
+ );
9677
9696
  return true;
9678
9697
  }
9679
9698
  ).then(gatherTaskRegistrationTask);