@cadenza.io/service 2.17.69 → 2.17.71

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.
@@ -6249,24 +6249,65 @@ function buildMinimalSyncSignalContext(ctx, extra = {}) {
6249
6249
  return nextContext;
6250
6250
  }
6251
6251
  function buildSyncInsertQueryData(ctx, queryData = {}) {
6252
+ const pickQueryData = (source, allowedKeys) => {
6253
+ const next = {};
6254
+ for (const key of allowedKeys) {
6255
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
6256
+ next[key] = source[key];
6257
+ }
6258
+ }
6259
+ return next;
6260
+ };
6252
6261
  const joinedQueryData = getJoinedContextValue(ctx, "queryData");
6253
6262
  const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
6254
6263
  const nextQueryData = {
6255
- ...existingQueryData,
6264
+ ...pickQueryData(existingQueryData, ["transaction"]),
6256
6265
  ...queryData
6257
6266
  };
6258
6267
  const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
6259
6268
  const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
6260
6269
  if (resolvedData !== void 0) {
6261
6270
  nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
6271
+ } else {
6272
+ delete nextQueryData.data;
6262
6273
  }
6263
6274
  if (resolvedBatch !== void 0) {
6264
6275
  nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
6265
6276
  (row) => row && typeof row === "object" ? { ...row } : row
6266
6277
  ) : resolvedBatch;
6278
+ } else {
6279
+ delete nextQueryData.batch;
6267
6280
  }
6268
6281
  return nextQueryData;
6269
6282
  }
6283
+ function buildSyncQueryQueryData(ctx, queryData = {}) {
6284
+ const joinedQueryData = getJoinedContextValue(ctx, "queryData");
6285
+ const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
6286
+ const nextQueryData = {};
6287
+ const allowedKeys = [
6288
+ "transaction",
6289
+ "filter",
6290
+ "fields",
6291
+ "joins",
6292
+ "sort",
6293
+ "limit",
6294
+ "offset",
6295
+ "queryMode",
6296
+ "aggregates",
6297
+ "groupBy"
6298
+ ];
6299
+ for (const key of allowedKeys) {
6300
+ if (Object.prototype.hasOwnProperty.call(existingQueryData, key)) {
6301
+ nextQueryData[key] = existingQueryData[key];
6302
+ }
6303
+ }
6304
+ return {
6305
+ ...nextQueryData,
6306
+ ...queryData
6307
+ };
6308
+ }
6309
+ var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY = 5;
6310
+ var REMOTE_AUTHORITY_SYNC_QUERY_CONCURRENCY = 3;
6270
6311
  function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
6271
6312
  if (!graph) {
6272
6313
  return void 0;
@@ -6277,6 +6318,20 @@ function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
6277
6318
  }
6278
6319
  return graph.completionTask;
6279
6320
  }
6321
+ function buildSyncExecutionEnvelope(ctx, queryData) {
6322
+ const originalContext = { ...ctx };
6323
+ const nextContext = {
6324
+ __syncing: ctx.__syncing === true || ctx.__metadata?.__syncing === true || false,
6325
+ __preferredTransportProtocol: "rest",
6326
+ __resolverOriginalContext: originalContext,
6327
+ __resolverQueryData: queryData,
6328
+ queryData
6329
+ };
6330
+ if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
6331
+ nextContext.__reason = ctx.__reason;
6332
+ }
6333
+ return nextContext;
6334
+ }
6280
6335
  function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
6281
6336
  const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
6282
6337
  const debugTable = shouldDebugSyncTable(tableName);
@@ -6285,6 +6340,10 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
6285
6340
  }
6286
6341
  const targetTask = localInsertTask ?? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, {
6287
6342
  ...options,
6343
+ concurrency: Number(options.concurrency) > 0 ? Math.min(
6344
+ Number(options.concurrency),
6345
+ REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY
6346
+ ) : REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY,
6288
6347
  register: false,
6289
6348
  isHidden: true
6290
6349
  });
@@ -6301,18 +6360,14 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
6301
6360
  const prepareExecutionTask = CadenzaService.createMetaTask(
6302
6361
  `Prepare graph sync insert for ${tableName}`,
6303
6362
  (ctx) => {
6304
- const originalContext = { ...ctx };
6305
6363
  const originalQueryData = buildSyncInsertQueryData(
6306
6364
  ctx,
6307
6365
  queryData
6308
6366
  );
6309
- return {
6310
- ...ctx,
6311
- __preferredTransportProtocol: "rest",
6312
- __resolverOriginalContext: originalContext,
6313
- __resolverQueryData: originalQueryData,
6314
- queryData: originalQueryData
6315
- };
6367
+ return buildSyncExecutionEnvelope(
6368
+ ctx,
6369
+ originalQueryData
6370
+ );
6316
6371
  },
6317
6372
  `Prepares ${tableName} graph-sync insert payloads for runner execution.`,
6318
6373
  {
@@ -6559,19 +6614,19 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
6559
6614
  }
6560
6615
  const targetTask = localQueryTask ?? CadenzaService.createCadenzaDBQueryTask(tableName, queryData, {
6561
6616
  ...options,
6617
+ concurrency: Number(options.concurrency) > 0 ? Math.min(
6618
+ Number(options.concurrency),
6619
+ REMOTE_AUTHORITY_SYNC_QUERY_CONCURRENCY
6620
+ ) : REMOTE_AUTHORITY_SYNC_QUERY_CONCURRENCY,
6562
6621
  register: false,
6563
6622
  isHidden: true
6564
6623
  });
6565
6624
  const prepareQueryTask = CadenzaService.createMetaTask(
6566
6625
  `Prepare graph sync query for ${tableName}`,
6567
- (ctx) => ({
6568
- ...ctx,
6569
- __preferredTransportProtocol: "rest",
6570
- queryData: {
6571
- ...ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {},
6572
- ...queryData
6573
- }
6574
- }),
6626
+ (ctx) => buildSyncExecutionEnvelope(
6627
+ ctx,
6628
+ buildSyncQueryQueryData(ctx, queryData)
6629
+ ),
6575
6630
  `Prepares ${tableName} graph-sync query payloads.`,
6576
6631
  {
6577
6632
  register: false,