@cadenza.io/service 2.17.59 → 2.17.61

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.
@@ -6263,93 +6263,23 @@ function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
6263
6263
  }
6264
6264
  return graph.completionTask;
6265
6265
  }
6266
- function resolveLocalDatabaseTaskIntent(task, operation, tableName) {
6267
- if (!task) {
6268
- return void 0;
6269
- }
6270
- const expectedPrefix = `${operation}-pg-`;
6271
- const expectedSuffix = `-${tableName}`;
6272
- const handledIntents = Array.from(task.handlesIntents ?? []);
6273
- const directMatch = handledIntents.find(
6274
- (intent) => typeof intent === "string" && intent.startsWith(expectedPrefix) && intent.endsWith(expectedSuffix)
6275
- );
6276
- if (directMatch) {
6277
- return directMatch;
6278
- }
6279
- return handledIntents.find(
6280
- (intent) => typeof intent === "string" && intent.startsWith(expectedPrefix)
6281
- );
6282
- }
6283
- function buildAuthoritySyncIntentName(operation, tableName) {
6284
- return `${operation}-pg-cadenza-db-postgres-actor-${tableName}`;
6285
- }
6286
- function createDatabaseInquiryTask(intentName, operation, tableName, options = {}) {
6287
- return CadenzaService.createMetaTask(
6288
- `Execute graph sync ${operation} for ${tableName}`,
6289
- async (ctx, _emit, inquire) => {
6290
- if (!intentName) {
6291
- return {
6292
- ...ctx,
6293
- errored: true,
6294
- __success: false,
6295
- __error: `No ${operation} intent found for ${tableName}`
6296
- };
6297
- }
6298
- const inquiryContext = {
6299
- ...ctx,
6300
- queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {}
6301
- };
6302
- const result = await inquire(intentName, inquiryContext, {});
6303
- const normalizedResult = result && typeof result === "object" ? result : {};
6304
- if (Object.keys(normalizedResult).length === 0 && normalizedResult.errored !== true && normalizedResult.__success !== true && normalizedResult.__inquiryMeta === void 0) {
6305
- return {
6306
- ...ctx,
6307
- errored: true,
6308
- __success: false,
6309
- __error: `No responders available for ${intentName}`,
6310
- __inquiryMeta: {
6311
- inquiry: intentName,
6312
- eligibleResponders: 0,
6313
- responded: 0,
6314
- failed: 0,
6315
- timedOut: 0,
6316
- pending: 0
6317
- }
6318
- };
6319
- }
6320
- return {
6321
- ...ctx,
6322
- ...normalizedResult
6323
- };
6324
- },
6325
- `Executes the ${tableName} ${operation} operation through the generated database intent.`,
6326
- {
6327
- ...options,
6328
- register: false,
6329
- isHidden: true
6330
- }
6331
- );
6332
- }
6333
6266
  function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
6334
6267
  const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
6335
6268
  const debugTable = shouldDebugSyncTable(tableName);
6336
6269
  if (!localInsertTask && !isCadenzaDBReady) {
6337
6270
  return void 0;
6338
6271
  }
6339
- const targetIntentName = resolveLocalDatabaseTaskIntent(localInsertTask, "insert", tableName) ?? buildAuthoritySyncIntentName("insert", tableName);
6340
- const targetTask = createDatabaseInquiryTask(
6341
- targetIntentName,
6342
- "insert",
6343
- tableName,
6344
- options
6345
- );
6272
+ const targetTask = localInsertTask ?? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, {
6273
+ ...options,
6274
+ register: false,
6275
+ isHidden: true
6276
+ });
6346
6277
  if (debugTable) {
6347
6278
  logSyncDebug("insert_task_resolved", {
6348
6279
  tableName,
6349
6280
  localInsertTaskName: localInsertTask?.name ?? null,
6350
- remoteInsertTaskName: isCadenzaDBReady ? targetIntentName : null,
6281
+ remoteInsertTaskName: isCadenzaDBReady ? targetTask.name : null,
6351
6282
  targetTaskName: targetTask.name,
6352
- targetIntentName,
6353
6283
  queryData,
6354
6284
  options
6355
6285
  });
@@ -6472,11 +6402,7 @@ var AUTHORITY_QUERY_RESULT_KEYS = {
6472
6402
  var EARLY_SYNC_REQUEST_DELAYS_MS = [2e3, 1e4, 3e4];
6473
6403
  var SYNC_DEBUG_PREFIX = "[CADENZA_SYNC_DEBUG]";
6474
6404
  var SYNC_DEBUG_TABLES = /* @__PURE__ */ new Set([
6475
- "task",
6476
- "routine",
6477
6405
  "task_to_routine_map",
6478
- "signal_registry",
6479
- "intent_registry",
6480
6406
  "signal_to_task_map",
6481
6407
  "intent_to_task_map"
6482
6408
  ]);
@@ -6620,13 +6546,11 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
6620
6546
  if (!localQueryTask && !isCadenzaDBReady) {
6621
6547
  return void 0;
6622
6548
  }
6623
- const targetIntentName = resolveLocalDatabaseTaskIntent(localQueryTask, "query", tableName) ?? buildAuthoritySyncIntentName("query", tableName);
6624
- const targetTask = createDatabaseInquiryTask(
6625
- targetIntentName,
6626
- "query",
6627
- tableName,
6628
- options
6629
- );
6549
+ const targetTask = localQueryTask ?? CadenzaService.createCadenzaDBQueryTask(tableName, queryData, {
6550
+ ...options,
6551
+ register: false,
6552
+ isHidden: true
6553
+ });
6630
6554
  const prepareQueryTask = CadenzaService.createMetaTask(
6631
6555
  `Prepare graph sync query for ${tableName}`,
6632
6556
  (ctx) => ({