@cadenza.io/service 2.17.56 → 2.17.58
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/browser/index.js +53 -29
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +53 -29
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +53 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -6280,17 +6280,19 @@ function resolveLocalDatabaseTaskIntent(task, operation, tableName) {
|
|
|
6280
6280
|
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix)
|
|
6281
6281
|
);
|
|
6282
6282
|
}
|
|
6283
|
-
function
|
|
6284
|
-
|
|
6283
|
+
function buildAuthoritySyncIntentName(operation, tableName) {
|
|
6284
|
+
return `${operation}-pg-CadenzaDBPostgresActor-${tableName}`;
|
|
6285
|
+
}
|
|
6286
|
+
function createDatabaseInquiryTask(intentName, operation, tableName, options = {}) {
|
|
6285
6287
|
return CadenzaService.createMetaTask(
|
|
6286
|
-
`Execute
|
|
6288
|
+
`Execute graph sync ${operation} for ${tableName}`,
|
|
6287
6289
|
async (ctx, _emit, inquire) => {
|
|
6288
6290
|
if (!intentName) {
|
|
6289
6291
|
return {
|
|
6290
6292
|
...ctx,
|
|
6291
6293
|
errored: true,
|
|
6292
6294
|
__success: false,
|
|
6293
|
-
__error: `No
|
|
6295
|
+
__error: `No ${operation} intent found for ${tableName}`
|
|
6294
6296
|
};
|
|
6295
6297
|
}
|
|
6296
6298
|
const inquiryContext = {
|
|
@@ -6298,12 +6300,29 @@ function createLocalDatabaseInquiryTask(localTask, operation, tableName, options
|
|
|
6298
6300
|
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {}
|
|
6299
6301
|
};
|
|
6300
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
|
+
}
|
|
6301
6320
|
return {
|
|
6302
6321
|
...ctx,
|
|
6303
|
-
...
|
|
6322
|
+
...normalizedResult
|
|
6304
6323
|
};
|
|
6305
6324
|
},
|
|
6306
|
-
`Executes the
|
|
6325
|
+
`Executes the ${tableName} ${operation} operation through the generated database intent.`,
|
|
6307
6326
|
{
|
|
6308
6327
|
...options,
|
|
6309
6328
|
register: false,
|
|
@@ -6313,18 +6332,24 @@ function createLocalDatabaseInquiryTask(localTask, operation, tableName, options
|
|
|
6313
6332
|
}
|
|
6314
6333
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
6315
6334
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
6316
|
-
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
6317
6335
|
const debugTable = shouldDebugSyncTable(tableName);
|
|
6318
|
-
if (!localInsertTask && !
|
|
6336
|
+
if (!localInsertTask && !isCadenzaDBReady) {
|
|
6319
6337
|
return void 0;
|
|
6320
6338
|
}
|
|
6321
|
-
const
|
|
6339
|
+
const targetIntentName = resolveLocalDatabaseTaskIntent(localInsertTask, "insert", tableName) ?? buildAuthoritySyncIntentName("insert", tableName);
|
|
6340
|
+
const targetTask = createDatabaseInquiryTask(
|
|
6341
|
+
targetIntentName,
|
|
6342
|
+
"insert",
|
|
6343
|
+
tableName,
|
|
6344
|
+
options
|
|
6345
|
+
);
|
|
6322
6346
|
if (debugTable) {
|
|
6323
6347
|
logSyncDebug("insert_task_resolved", {
|
|
6324
6348
|
tableName,
|
|
6325
6349
|
localInsertTaskName: localInsertTask?.name ?? null,
|
|
6326
|
-
remoteInsertTaskName:
|
|
6350
|
+
remoteInsertTaskName: isCadenzaDBReady ? targetIntentName : null,
|
|
6327
6351
|
targetTaskName: targetTask.name,
|
|
6352
|
+
targetIntentName,
|
|
6328
6353
|
queryData,
|
|
6329
6354
|
options
|
|
6330
6355
|
});
|
|
@@ -6339,6 +6364,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6339
6364
|
);
|
|
6340
6365
|
return {
|
|
6341
6366
|
...ctx,
|
|
6367
|
+
__preferredTransportProtocol: "rest",
|
|
6342
6368
|
__resolverOriginalContext: originalContext,
|
|
6343
6369
|
__resolverQueryData: originalQueryData,
|
|
6344
6370
|
queryData: originalQueryData
|
|
@@ -6591,15 +6617,21 @@ function resolveSyncQueryRows(ctx, tableName) {
|
|
|
6591
6617
|
}
|
|
6592
6618
|
function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
6593
6619
|
const localQueryTask = CadenzaService.getLocalCadenzaDBQueryTask(tableName);
|
|
6594
|
-
|
|
6595
|
-
if (!localQueryTask && !remoteQueryTask) {
|
|
6620
|
+
if (!localQueryTask && !isCadenzaDBReady) {
|
|
6596
6621
|
return void 0;
|
|
6597
6622
|
}
|
|
6598
|
-
const
|
|
6623
|
+
const targetIntentName = resolveLocalDatabaseTaskIntent(localQueryTask, "query", tableName) ?? buildAuthoritySyncIntentName("query", tableName);
|
|
6624
|
+
const targetTask = createDatabaseInquiryTask(
|
|
6625
|
+
targetIntentName,
|
|
6626
|
+
"query",
|
|
6627
|
+
tableName,
|
|
6628
|
+
options
|
|
6629
|
+
);
|
|
6599
6630
|
const prepareQueryTask = CadenzaService.createMetaTask(
|
|
6600
6631
|
`Prepare graph sync query for ${tableName}`,
|
|
6601
6632
|
(ctx) => ({
|
|
6602
6633
|
...ctx,
|
|
6634
|
+
__preferredTransportProtocol: "rest",
|
|
6603
6635
|
queryData: {
|
|
6604
6636
|
...ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {},
|
|
6605
6637
|
...queryData
|
|
@@ -7395,7 +7427,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7395
7427
|
);
|
|
7396
7428
|
this.registerSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
7397
7429
|
"Split observed signals of task",
|
|
7398
|
-
(ctx
|
|
7430
|
+
function* (ctx) {
|
|
7399
7431
|
const task = ctx.task;
|
|
7400
7432
|
if (task.hidden || !task.register || !task.registered) return false;
|
|
7401
7433
|
const serviceName2 = resolveSyncServiceName(task);
|
|
@@ -7421,7 +7453,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7421
7453
|
)?.registered
|
|
7422
7454
|
});
|
|
7423
7455
|
}
|
|
7424
|
-
|
|
7456
|
+
yield {
|
|
7425
7457
|
__syncing: ctx.__syncing,
|
|
7426
7458
|
data: {
|
|
7427
7459
|
signalName: _signal,
|
|
@@ -7432,16 +7464,12 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7432
7464
|
},
|
|
7433
7465
|
__taskName: task.name,
|
|
7434
7466
|
__signal: signal
|
|
7435
|
-
}
|
|
7467
|
+
};
|
|
7436
7468
|
emittedCount += 1;
|
|
7437
7469
|
}
|
|
7438
7470
|
return emittedCount > 0;
|
|
7439
7471
|
}
|
|
7440
7472
|
);
|
|
7441
|
-
const processSplitSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
7442
|
-
"Process split signal-to-task map",
|
|
7443
|
-
(ctx) => ctx
|
|
7444
|
-
).doOn("meta.sync_controller.signal_task_map_split");
|
|
7445
7473
|
const signalToTaskMapGraph = resolveSyncInsertTask(
|
|
7446
7474
|
this.isCadenzaDBReady,
|
|
7447
7475
|
"signal_to_task_map",
|
|
@@ -7461,7 +7489,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7461
7489
|
{ concurrency: 30 }
|
|
7462
7490
|
);
|
|
7463
7491
|
wireSyncTaskGraph(
|
|
7464
|
-
|
|
7492
|
+
this.registerSignalToTaskMapTask,
|
|
7465
7493
|
signalToTaskMapGraph,
|
|
7466
7494
|
registerSignalTask
|
|
7467
7495
|
);
|
|
@@ -7523,7 +7551,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7523
7551
|
);
|
|
7524
7552
|
this.registerIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
7525
7553
|
"Split intents of task",
|
|
7526
|
-
function(ctx
|
|
7554
|
+
function* (ctx) {
|
|
7527
7555
|
const task = ctx.task;
|
|
7528
7556
|
if (task.hidden || !task.register || !task.registered) return false;
|
|
7529
7557
|
const serviceName2 = resolveSyncServiceName(task);
|
|
@@ -7581,7 +7609,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7581
7609
|
intentDefinition
|
|
7582
7610
|
});
|
|
7583
7611
|
}
|
|
7584
|
-
|
|
7612
|
+
yield {
|
|
7585
7613
|
__syncing: ctx.__syncing,
|
|
7586
7614
|
data: {
|
|
7587
7615
|
intentName: intent,
|
|
@@ -7598,7 +7626,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7598
7626
|
taskVersion: task.version,
|
|
7599
7627
|
serviceName: serviceName2
|
|
7600
7628
|
}
|
|
7601
|
-
}
|
|
7629
|
+
};
|
|
7602
7630
|
emittedCount += 1;
|
|
7603
7631
|
}
|
|
7604
7632
|
if (shouldDebugTask && emittedCount === 0) {
|
|
@@ -7613,10 +7641,6 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7613
7641
|
return emittedCount > 0;
|
|
7614
7642
|
}.bind(this)
|
|
7615
7643
|
);
|
|
7616
|
-
const processSplitIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
7617
|
-
"Process split intent-to-task map",
|
|
7618
|
-
(ctx) => ctx
|
|
7619
|
-
).doOn("meta.sync_controller.intent_task_map_split");
|
|
7620
7644
|
const prepareIntentDefinitionForIntentMapTask = CadenzaService.createMetaTask(
|
|
7621
7645
|
"Prepare intent definition for intent-to-task map",
|
|
7622
7646
|
(ctx) => {
|
|
@@ -7673,7 +7697,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7673
7697
|
},
|
|
7674
7698
|
{ concurrency: 30 }
|
|
7675
7699
|
);
|
|
7676
|
-
|
|
7700
|
+
this.registerIntentToTaskMapTask.then(prepareIntentDefinitionForIntentMapTask);
|
|
7677
7701
|
if (ensureIntentRegistryBeforeIntentMapTask) {
|
|
7678
7702
|
wireSyncTaskGraph(
|
|
7679
7703
|
prepareIntentDefinitionForIntentMapTask,
|