@cadenza.io/service 2.17.59 → 2.17.60

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
@@ -8819,93 +8819,23 @@ function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
8819
8819
  }
8820
8820
  return graph.completionTask;
8821
8821
  }
8822
- function resolveLocalDatabaseTaskIntent(task, operation, tableName) {
8823
- if (!task) {
8824
- return void 0;
8825
- }
8826
- const expectedPrefix = `${operation}-pg-`;
8827
- const expectedSuffix = `-${tableName}`;
8828
- const handledIntents = Array.from(task.handlesIntents ?? []);
8829
- const directMatch = handledIntents.find(
8830
- (intent) => typeof intent === "string" && intent.startsWith(expectedPrefix) && intent.endsWith(expectedSuffix)
8831
- );
8832
- if (directMatch) {
8833
- return directMatch;
8834
- }
8835
- return handledIntents.find(
8836
- (intent) => typeof intent === "string" && intent.startsWith(expectedPrefix)
8837
- );
8838
- }
8839
- function buildAuthoritySyncIntentName(operation, tableName) {
8840
- return `${operation}-pg-cadenza-db-postgres-actor-${tableName}`;
8841
- }
8842
- function createDatabaseInquiryTask(intentName, operation, tableName, options = {}) {
8843
- return CadenzaService.createMetaTask(
8844
- `Execute graph sync ${operation} for ${tableName}`,
8845
- async (ctx, _emit, inquire) => {
8846
- if (!intentName) {
8847
- return {
8848
- ...ctx,
8849
- errored: true,
8850
- __success: false,
8851
- __error: `No ${operation} intent found for ${tableName}`
8852
- };
8853
- }
8854
- const inquiryContext = {
8855
- ...ctx,
8856
- queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {}
8857
- };
8858
- const result = await inquire(intentName, inquiryContext, {});
8859
- const normalizedResult = result && typeof result === "object" ? result : {};
8860
- if (Object.keys(normalizedResult).length === 0 && normalizedResult.errored !== true && normalizedResult.__success !== true && normalizedResult.__inquiryMeta === void 0) {
8861
- return {
8862
- ...ctx,
8863
- errored: true,
8864
- __success: false,
8865
- __error: `No responders available for ${intentName}`,
8866
- __inquiryMeta: {
8867
- inquiry: intentName,
8868
- eligibleResponders: 0,
8869
- responded: 0,
8870
- failed: 0,
8871
- timedOut: 0,
8872
- pending: 0
8873
- }
8874
- };
8875
- }
8876
- return {
8877
- ...ctx,
8878
- ...normalizedResult
8879
- };
8880
- },
8881
- `Executes the ${tableName} ${operation} operation through the generated database intent.`,
8882
- {
8883
- ...options,
8884
- register: false,
8885
- isHidden: true
8886
- }
8887
- );
8888
- }
8889
8822
  function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
8890
8823
  const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
8891
8824
  const debugTable = shouldDebugSyncTable(tableName);
8892
8825
  if (!localInsertTask && !isCadenzaDBReady) {
8893
8826
  return void 0;
8894
8827
  }
8895
- const targetIntentName = resolveLocalDatabaseTaskIntent(localInsertTask, "insert", tableName) ?? buildAuthoritySyncIntentName("insert", tableName);
8896
- const targetTask = createDatabaseInquiryTask(
8897
- targetIntentName,
8898
- "insert",
8899
- tableName,
8900
- options
8901
- );
8828
+ const targetTask = localInsertTask ?? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, {
8829
+ ...options,
8830
+ register: false,
8831
+ isHidden: true
8832
+ });
8902
8833
  if (debugTable) {
8903
8834
  logSyncDebug("insert_task_resolved", {
8904
8835
  tableName,
8905
8836
  localInsertTaskName: localInsertTask?.name ?? null,
8906
- remoteInsertTaskName: isCadenzaDBReady ? targetIntentName : null,
8837
+ remoteInsertTaskName: isCadenzaDBReady ? targetTask.name : null,
8907
8838
  targetTaskName: targetTask.name,
8908
- targetIntentName,
8909
8839
  queryData,
8910
8840
  options
8911
8841
  });
@@ -9176,13 +9106,11 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
9176
9106
  if (!localQueryTask && !isCadenzaDBReady) {
9177
9107
  return void 0;
9178
9108
  }
9179
- const targetIntentName = resolveLocalDatabaseTaskIntent(localQueryTask, "query", tableName) ?? buildAuthoritySyncIntentName("query", tableName);
9180
- const targetTask = createDatabaseInquiryTask(
9181
- targetIntentName,
9182
- "query",
9183
- tableName,
9184
- options
9185
- );
9109
+ const targetTask = localQueryTask ?? CadenzaService.createCadenzaDBQueryTask(tableName, queryData, {
9110
+ ...options,
9111
+ register: false,
9112
+ isHidden: true
9113
+ });
9186
9114
  const prepareQueryTask = CadenzaService.createMetaTask(
9187
9115
  `Prepare graph sync query for ${tableName}`,
9188
9116
  (ctx) => ({