@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.
@@ -6200,24 +6200,65 @@ function buildMinimalSyncSignalContext(ctx, extra = {}) {
6200
6200
  return nextContext;
6201
6201
  }
6202
6202
  function buildSyncInsertQueryData(ctx, queryData = {}) {
6203
+ const pickQueryData = (source, allowedKeys) => {
6204
+ const next = {};
6205
+ for (const key of allowedKeys) {
6206
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
6207
+ next[key] = source[key];
6208
+ }
6209
+ }
6210
+ return next;
6211
+ };
6203
6212
  const joinedQueryData = getJoinedContextValue(ctx, "queryData");
6204
6213
  const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
6205
6214
  const nextQueryData = {
6206
- ...existingQueryData,
6215
+ ...pickQueryData(existingQueryData, ["transaction"]),
6207
6216
  ...queryData
6208
6217
  };
6209
6218
  const resolvedData = Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedContextValue(ctx, "data");
6210
6219
  const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedContextValue(ctx, "batch");
6211
6220
  if (resolvedData !== void 0) {
6212
6221
  nextQueryData.data = resolvedData && typeof resolvedData === "object" && !Array.isArray(resolvedData) ? { ...resolvedData } : resolvedData;
6222
+ } else {
6223
+ delete nextQueryData.data;
6213
6224
  }
6214
6225
  if (resolvedBatch !== void 0) {
6215
6226
  nextQueryData.batch = Array.isArray(resolvedBatch) ? resolvedBatch.map(
6216
6227
  (row) => row && typeof row === "object" ? { ...row } : row
6217
6228
  ) : resolvedBatch;
6229
+ } else {
6230
+ delete nextQueryData.batch;
6218
6231
  }
6219
6232
  return nextQueryData;
6220
6233
  }
6234
+ function buildSyncQueryQueryData(ctx, queryData = {}) {
6235
+ const joinedQueryData = getJoinedContextValue(ctx, "queryData");
6236
+ const existingQueryData = ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : joinedQueryData && typeof joinedQueryData === "object" ? joinedQueryData : {};
6237
+ const nextQueryData = {};
6238
+ const allowedKeys = [
6239
+ "transaction",
6240
+ "filter",
6241
+ "fields",
6242
+ "joins",
6243
+ "sort",
6244
+ "limit",
6245
+ "offset",
6246
+ "queryMode",
6247
+ "aggregates",
6248
+ "groupBy"
6249
+ ];
6250
+ for (const key of allowedKeys) {
6251
+ if (Object.prototype.hasOwnProperty.call(existingQueryData, key)) {
6252
+ nextQueryData[key] = existingQueryData[key];
6253
+ }
6254
+ }
6255
+ return {
6256
+ ...nextQueryData,
6257
+ ...queryData
6258
+ };
6259
+ }
6260
+ var REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY = 5;
6261
+ var REMOTE_AUTHORITY_SYNC_QUERY_CONCURRENCY = 3;
6221
6262
  function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
6222
6263
  if (!graph) {
6223
6264
  return void 0;
@@ -6228,6 +6269,20 @@ function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
6228
6269
  }
6229
6270
  return graph.completionTask;
6230
6271
  }
6272
+ function buildSyncExecutionEnvelope(ctx, queryData) {
6273
+ const originalContext = { ...ctx };
6274
+ const nextContext = {
6275
+ __syncing: ctx.__syncing === true || ctx.__metadata?.__syncing === true || false,
6276
+ __preferredTransportProtocol: "rest",
6277
+ __resolverOriginalContext: originalContext,
6278
+ __resolverQueryData: queryData,
6279
+ queryData
6280
+ };
6281
+ if (typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0) {
6282
+ nextContext.__reason = ctx.__reason;
6283
+ }
6284
+ return nextContext;
6285
+ }
6231
6286
  function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
6232
6287
  const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
6233
6288
  const debugTable = shouldDebugSyncTable(tableName);
@@ -6236,6 +6291,10 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
6236
6291
  }
6237
6292
  const targetTask = localInsertTask ?? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, {
6238
6293
  ...options,
6294
+ concurrency: Number(options.concurrency) > 0 ? Math.min(
6295
+ Number(options.concurrency),
6296
+ REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY
6297
+ ) : REMOTE_AUTHORITY_SYNC_INSERT_CONCURRENCY,
6239
6298
  register: false,
6240
6299
  isHidden: true
6241
6300
  });
@@ -6252,18 +6311,14 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
6252
6311
  const prepareExecutionTask = CadenzaService.createMetaTask(
6253
6312
  `Prepare graph sync insert for ${tableName}`,
6254
6313
  (ctx) => {
6255
- const originalContext = { ...ctx };
6256
6314
  const originalQueryData = buildSyncInsertQueryData(
6257
6315
  ctx,
6258
6316
  queryData
6259
6317
  );
6260
- return {
6261
- ...ctx,
6262
- __preferredTransportProtocol: "rest",
6263
- __resolverOriginalContext: originalContext,
6264
- __resolverQueryData: originalQueryData,
6265
- queryData: originalQueryData
6266
- };
6318
+ return buildSyncExecutionEnvelope(
6319
+ ctx,
6320
+ originalQueryData
6321
+ );
6267
6322
  },
6268
6323
  `Prepares ${tableName} graph-sync insert payloads for runner execution.`,
6269
6324
  {
@@ -6510,19 +6565,19 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
6510
6565
  }
6511
6566
  const targetTask = localQueryTask ?? CadenzaService.createCadenzaDBQueryTask(tableName, queryData, {
6512
6567
  ...options,
6568
+ concurrency: Number(options.concurrency) > 0 ? Math.min(
6569
+ Number(options.concurrency),
6570
+ REMOTE_AUTHORITY_SYNC_QUERY_CONCURRENCY
6571
+ ) : REMOTE_AUTHORITY_SYNC_QUERY_CONCURRENCY,
6513
6572
  register: false,
6514
6573
  isHidden: true
6515
6574
  });
6516
6575
  const prepareQueryTask = CadenzaService.createMetaTask(
6517
6576
  `Prepare graph sync query for ${tableName}`,
6518
- (ctx) => ({
6519
- ...ctx,
6520
- __preferredTransportProtocol: "rest",
6521
- queryData: {
6522
- ...ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {},
6523
- ...queryData
6524
- }
6525
- }),
6577
+ (ctx) => buildSyncExecutionEnvelope(
6578
+ ctx,
6579
+ buildSyncQueryQueryData(ctx, queryData)
6580
+ ),
6526
6581
  `Prepares ${tableName} graph-sync query payloads.`,
6527
6582
  {
6528
6583
  register: false,