@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.js CHANGED
@@ -6587,6 +6587,7 @@ var SCHEMA_TYPES = [
6587
6587
  var import_pg = require("pg");
6588
6588
  var import_lodash_es = require("lodash-es");
6589
6589
  var AUTHORITY_SYNC_DEBUG_PREFIX = "[CADENZA_DB_TASK_DEBUG]";
6590
+ var AUTHORITY_SYNC_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env === "object" && process.env.CADENZA_DB_TASK_DEBUG === "true";
6590
6591
  var AUTHORITY_SYNC_DEBUG_TASK_NAMES = /* @__PURE__ */ new Set([
6591
6592
  "Query service_instance",
6592
6593
  "Query service_instance_transport",
@@ -6601,6 +6602,9 @@ var AUTHORITY_SYNC_DEBUG_TASK_NAMES = /* @__PURE__ */ new Set([
6601
6602
  ]);
6602
6603
  var AUTHORITY_SYNC_DEBUG_ROUTINE_NAMES = /* @__PURE__ */ new Set(["Sync services"]);
6603
6604
  function logAuthoritySyncDebug(event, payload) {
6605
+ if (!AUTHORITY_SYNC_DEBUG_ENABLED) {
6606
+ return;
6607
+ }
6604
6608
  console.log(`${AUTHORITY_SYNC_DEBUG_PREFIX} ${event}`, payload);
6605
6609
  }
6606
6610
  function resolveAuthoritySyncPayloadName(payload, tableName) {
@@ -6619,6 +6623,9 @@ function resolveAuthoritySyncPayloadName(payload, tableName) {
6619
6623
  return null;
6620
6624
  }
6621
6625
  function shouldDebugAuthoritySyncPayload(tableName, payload) {
6626
+ if (!AUTHORITY_SYNC_DEBUG_ENABLED) {
6627
+ return false;
6628
+ }
6622
6629
  if (tableName !== "task" && tableName !== "task_to_routine_map") {
6623
6630
  return false;
6624
6631
  }
@@ -8790,6 +8797,16 @@ function didSyncInsertSucceed(ctx) {
8790
8797
  }
8791
8798
  return true;
8792
8799
  }
8800
+ function buildMinimalSyncSignalContext(ctx, extra = {}) {
8801
+ const nextContext = {
8802
+ __syncing: ctx.__syncing === true,
8803
+ ...extra
8804
+ };
8805
+ if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
8806
+ nextContext.__reason = ctx.__reason;
8807
+ }
8808
+ return nextContext;
8809
+ }
8793
8810
  function buildSyncInsertQueryData(ctx, queryData = {}) {
8794
8811
  const joinedQueryData = getJoinedContextValue(ctx, "queryData");
8795
8812
  const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
@@ -9294,10 +9311,10 @@ var GraphSyncController = class _GraphSyncController {
9294
9311
  const shouldEmit = !this.tasksSynced;
9295
9312
  this.tasksSynced = true;
9296
9313
  if (shouldEmit) {
9297
- emit("meta.sync_controller.synced_tasks", {
9298
- __syncing: true,
9299
- ...ctx
9300
- });
9314
+ emit(
9315
+ "meta.sync_controller.synced_tasks",
9316
+ buildMinimalSyncSignalContext(ctx)
9317
+ );
9301
9318
  }
9302
9319
  return true;
9303
9320
  };
@@ -9312,10 +9329,10 @@ var GraphSyncController = class _GraphSyncController {
9312
9329
  const shouldEmit = !this.routinesSynced;
9313
9330
  this.routinesSynced = true;
9314
9331
  if (shouldEmit) {
9315
- emit("meta.sync_controller.synced_routines", {
9316
- __syncing: true,
9317
- ...ctx
9318
- });
9332
+ emit(
9333
+ "meta.sync_controller.synced_routines",
9334
+ buildMinimalSyncSignalContext(ctx)
9335
+ );
9319
9336
  }
9320
9337
  return true;
9321
9338
  };
@@ -9330,10 +9347,10 @@ var GraphSyncController = class _GraphSyncController {
9330
9347
  const shouldEmit = !this.signalsSynced;
9331
9348
  this.signalsSynced = true;
9332
9349
  if (shouldEmit) {
9333
- emit("meta.sync_controller.synced_signals", {
9334
- __syncing: true,
9335
- ...ctx
9336
- });
9350
+ emit(
9351
+ "meta.sync_controller.synced_signals",
9352
+ buildMinimalSyncSignalContext(ctx)
9353
+ );
9337
9354
  }
9338
9355
  return true;
9339
9356
  };
@@ -9348,10 +9365,10 @@ var GraphSyncController = class _GraphSyncController {
9348
9365
  const shouldEmit = !this.intentsSynced;
9349
9366
  this.intentsSynced = true;
9350
9367
  if (shouldEmit) {
9351
- emit("meta.sync_controller.synced_intents", {
9352
- __syncing: true,
9353
- ...ctx
9354
- });
9368
+ emit(
9369
+ "meta.sync_controller.synced_intents",
9370
+ buildMinimalSyncSignalContext(ctx)
9371
+ );
9355
9372
  }
9356
9373
  return true;
9357
9374
  };
@@ -9369,10 +9386,10 @@ var GraphSyncController = class _GraphSyncController {
9369
9386
  const shouldEmit = !this.actorsSynced;
9370
9387
  this.actorsSynced = true;
9371
9388
  if (shouldEmit) {
9372
- emit("meta.sync_controller.synced_actors", {
9373
- __syncing: true,
9374
- ...ctx
9375
- });
9389
+ emit(
9390
+ "meta.sync_controller.synced_actors",
9391
+ buildMinimalSyncSignalContext(ctx)
9392
+ );
9376
9393
  }
9377
9394
  return true;
9378
9395
  };
@@ -9719,10 +9736,12 @@ var GraphSyncController = class _GraphSyncController {
9719
9736
  delayMs: 3e3
9720
9737
  });
9721
9738
  CadenzaService.get(ctx.__taskName).registered = true;
9722
- emit("meta.sync_controller.task_registered", {
9723
- ...ctx,
9724
- task: CadenzaService.get(ctx.__taskName)
9725
- });
9739
+ emit(
9740
+ "meta.sync_controller.task_registered",
9741
+ buildMinimalSyncSignalContext(ctx, {
9742
+ __taskName: ctx.__taskName
9743
+ })
9744
+ );
9726
9745
  return true;
9727
9746
  }
9728
9747
  ).then(gatherTaskRegistrationTask);