@cadenza.io/service 2.17.42 → 2.17.44
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 +339 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +339 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +339 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +339 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -6297,6 +6297,40 @@ var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
|
6297
6297
|
"intent_to_task_map",
|
|
6298
6298
|
"directional_task_graph_map"
|
|
6299
6299
|
];
|
|
6300
|
+
var AUTHORITY_QUERY_RESULT_KEYS = {
|
|
6301
|
+
task: "tasks",
|
|
6302
|
+
routine: "routines",
|
|
6303
|
+
signal_registry: "signalRegistrys",
|
|
6304
|
+
intent_registry: "intentRegistrys"
|
|
6305
|
+
};
|
|
6306
|
+
function resolveSyncQueryRows(ctx, tableName) {
|
|
6307
|
+
const resultKey = AUTHORITY_QUERY_RESULT_KEYS[tableName];
|
|
6308
|
+
const rows = ctx?.[resultKey];
|
|
6309
|
+
return Array.isArray(rows) ? rows : [];
|
|
6310
|
+
}
|
|
6311
|
+
function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
6312
|
+
const localQueryTask = CadenzaService.getLocalCadenzaDBQueryTask(tableName);
|
|
6313
|
+
const remoteQueryTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBQueryTask(tableName, queryData, options) : void 0;
|
|
6314
|
+
if (!localQueryTask && !remoteQueryTask) {
|
|
6315
|
+
return void 0;
|
|
6316
|
+
}
|
|
6317
|
+
const targetTask = localQueryTask ?? remoteQueryTask;
|
|
6318
|
+
return CadenzaService.createMetaTask(
|
|
6319
|
+
`Prepare graph sync query for ${tableName}`,
|
|
6320
|
+
(ctx) => ({
|
|
6321
|
+
...ctx,
|
|
6322
|
+
queryData: {
|
|
6323
|
+
...ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {},
|
|
6324
|
+
...queryData
|
|
6325
|
+
}
|
|
6326
|
+
}),
|
|
6327
|
+
`Prepares ${tableName} graph-sync query payloads.`,
|
|
6328
|
+
{
|
|
6329
|
+
register: false,
|
|
6330
|
+
isHidden: true
|
|
6331
|
+
}
|
|
6332
|
+
).then(targetTask);
|
|
6333
|
+
}
|
|
6300
6334
|
var GraphSyncController = class _GraphSyncController {
|
|
6301
6335
|
constructor() {
|
|
6302
6336
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
@@ -6397,6 +6431,30 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6397
6431
|
},
|
|
6398
6432
|
{ concurrency: 30 }
|
|
6399
6433
|
);
|
|
6434
|
+
const authoritativeTaskQueryTask = resolveSyncQueryTask(
|
|
6435
|
+
this.isCadenzaDBReady,
|
|
6436
|
+
"task",
|
|
6437
|
+
{},
|
|
6438
|
+
{ concurrency: 10 }
|
|
6439
|
+
);
|
|
6440
|
+
const authoritativeRoutineQueryTask = resolveSyncQueryTask(
|
|
6441
|
+
this.isCadenzaDBReady,
|
|
6442
|
+
"routine",
|
|
6443
|
+
{},
|
|
6444
|
+
{ concurrency: 10 }
|
|
6445
|
+
);
|
|
6446
|
+
const authoritativeSignalQueryTask = resolveSyncQueryTask(
|
|
6447
|
+
this.isCadenzaDBReady,
|
|
6448
|
+
"signal_registry",
|
|
6449
|
+
{},
|
|
6450
|
+
{ concurrency: 10 }
|
|
6451
|
+
);
|
|
6452
|
+
const authoritativeIntentQueryTask = resolveSyncQueryTask(
|
|
6453
|
+
this.isCadenzaDBReady,
|
|
6454
|
+
"intent_registry",
|
|
6455
|
+
{},
|
|
6456
|
+
{ concurrency: 10 }
|
|
6457
|
+
);
|
|
6400
6458
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
6401
6459
|
"Split routines for registration",
|
|
6402
6460
|
(ctx, emit) => {
|
|
@@ -7205,6 +7263,286 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7205
7263
|
)
|
|
7206
7264
|
)
|
|
7207
7265
|
);
|
|
7266
|
+
const reconcileTaskRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7267
|
+
"Reconcile task registration from authority",
|
|
7268
|
+
(ctx, emit) => {
|
|
7269
|
+
const authoritativeTasks = resolveSyncQueryRows(ctx, "task");
|
|
7270
|
+
let changed = false;
|
|
7271
|
+
for (const row of authoritativeTasks) {
|
|
7272
|
+
const taskName = typeof row.name === "string" ? row.name : "";
|
|
7273
|
+
if (!taskName) {
|
|
7274
|
+
continue;
|
|
7275
|
+
}
|
|
7276
|
+
const task = CadenzaService.get(taskName);
|
|
7277
|
+
if (!task || task.registered) {
|
|
7278
|
+
continue;
|
|
7279
|
+
}
|
|
7280
|
+
task.registered = true;
|
|
7281
|
+
changed = true;
|
|
7282
|
+
emit("meta.sync_controller.task_registered", {
|
|
7283
|
+
...ctx,
|
|
7284
|
+
__taskName: task.name,
|
|
7285
|
+
task,
|
|
7286
|
+
__authoritativeReconciliation: true
|
|
7287
|
+
});
|
|
7288
|
+
}
|
|
7289
|
+
if (authoritativeTasks.length > 0) {
|
|
7290
|
+
CadenzaService.debounce(
|
|
7291
|
+
"meta.sync_controller.task_registration_settled",
|
|
7292
|
+
{
|
|
7293
|
+
__syncing: true,
|
|
7294
|
+
__authoritativeReconciliation: true
|
|
7295
|
+
},
|
|
7296
|
+
300
|
|
7297
|
+
);
|
|
7298
|
+
}
|
|
7299
|
+
return changed;
|
|
7300
|
+
},
|
|
7301
|
+
"Marks local tasks as registered when authority rows already exist.",
|
|
7302
|
+
{
|
|
7303
|
+
register: false,
|
|
7304
|
+
isHidden: true
|
|
7305
|
+
}
|
|
7306
|
+
);
|
|
7307
|
+
const reconcileRoutineRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7308
|
+
"Reconcile routine registration from authority",
|
|
7309
|
+
(ctx) => {
|
|
7310
|
+
const authoritativeRoutines = resolveSyncQueryRows(ctx, "routine");
|
|
7311
|
+
let changed = false;
|
|
7312
|
+
for (const row of authoritativeRoutines) {
|
|
7313
|
+
const routineName = typeof row.name === "string" ? row.name : "";
|
|
7314
|
+
if (!routineName) {
|
|
7315
|
+
continue;
|
|
7316
|
+
}
|
|
7317
|
+
const routine = CadenzaService.getRoutine(routineName);
|
|
7318
|
+
if (!routine || routine.registered) {
|
|
7319
|
+
continue;
|
|
7320
|
+
}
|
|
7321
|
+
routine.registered = true;
|
|
7322
|
+
changed = true;
|
|
7323
|
+
}
|
|
7324
|
+
if (authoritativeRoutines.length > 0) {
|
|
7325
|
+
CadenzaService.debounce(
|
|
7326
|
+
"meta.sync_controller.routine_registration_settled",
|
|
7327
|
+
{
|
|
7328
|
+
__syncing: true,
|
|
7329
|
+
__authoritativeReconciliation: true
|
|
7330
|
+
},
|
|
7331
|
+
300
|
|
7332
|
+
);
|
|
7333
|
+
}
|
|
7334
|
+
return changed;
|
|
7335
|
+
},
|
|
7336
|
+
"Marks local routines as registered when authority rows already exist.",
|
|
7337
|
+
{
|
|
7338
|
+
register: false,
|
|
7339
|
+
isHidden: true
|
|
7340
|
+
}
|
|
7341
|
+
);
|
|
7342
|
+
const reconcileSignalRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7343
|
+
"Reconcile signal registration from authority",
|
|
7344
|
+
(ctx) => {
|
|
7345
|
+
const authoritativeSignals = resolveSyncQueryRows(ctx, "signal_registry");
|
|
7346
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
7347
|
+
let changed = false;
|
|
7348
|
+
for (const row of authoritativeSignals) {
|
|
7349
|
+
const signalName = typeof row.name === "string" ? row.name : "";
|
|
7350
|
+
if (!signalName) {
|
|
7351
|
+
continue;
|
|
7352
|
+
}
|
|
7353
|
+
const observer = signalObservers?.get(signalName);
|
|
7354
|
+
if (!observer || observer.registered) {
|
|
7355
|
+
continue;
|
|
7356
|
+
}
|
|
7357
|
+
observer.registered = true;
|
|
7358
|
+
changed = true;
|
|
7359
|
+
}
|
|
7360
|
+
if (authoritativeSignals.length > 0) {
|
|
7361
|
+
CadenzaService.debounce(
|
|
7362
|
+
"meta.sync_controller.signal_registration_settled",
|
|
7363
|
+
{
|
|
7364
|
+
__syncing: true,
|
|
7365
|
+
__authoritativeReconciliation: true
|
|
7366
|
+
},
|
|
7367
|
+
300
|
|
7368
|
+
);
|
|
7369
|
+
}
|
|
7370
|
+
return changed;
|
|
7371
|
+
},
|
|
7372
|
+
"Marks local signals as registered when authority rows already exist.",
|
|
7373
|
+
{
|
|
7374
|
+
register: false,
|
|
7375
|
+
isHidden: true
|
|
7376
|
+
}
|
|
7377
|
+
);
|
|
7378
|
+
const reconcileIntentRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7379
|
+
"Reconcile intent registration from authority",
|
|
7380
|
+
(ctx) => {
|
|
7381
|
+
const authoritativeIntents = resolveSyncQueryRows(ctx, "intent_registry");
|
|
7382
|
+
let changed = false;
|
|
7383
|
+
for (const row of authoritativeIntents) {
|
|
7384
|
+
const intentName = typeof row.name === "string" ? row.name : "";
|
|
7385
|
+
if (!intentName || !CadenzaService.inquiryBroker.intents.has(intentName)) {
|
|
7386
|
+
continue;
|
|
7387
|
+
}
|
|
7388
|
+
if (this.registeredIntentDefinitions.has(intentName)) {
|
|
7389
|
+
continue;
|
|
7390
|
+
}
|
|
7391
|
+
this.registeredIntentDefinitions.add(intentName);
|
|
7392
|
+
changed = true;
|
|
7393
|
+
}
|
|
7394
|
+
if (authoritativeIntents.length > 0) {
|
|
7395
|
+
CadenzaService.debounce(
|
|
7396
|
+
"meta.sync_controller.intent_registration_settled",
|
|
7397
|
+
{
|
|
7398
|
+
__syncing: true,
|
|
7399
|
+
__authoritativeReconciliation: true
|
|
7400
|
+
},
|
|
7401
|
+
300
|
|
7402
|
+
);
|
|
7403
|
+
}
|
|
7404
|
+
return changed;
|
|
7405
|
+
},
|
|
7406
|
+
"Marks local intents as registered when authority rows already exist.",
|
|
7407
|
+
{
|
|
7408
|
+
register: false,
|
|
7409
|
+
isHidden: true
|
|
7410
|
+
}
|
|
7411
|
+
);
|
|
7412
|
+
const authoritativeTaskReconciliationGraph = authoritativeTaskQueryTask?.then(reconcileTaskRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7413
|
+
"Skip authoritative task reconciliation",
|
|
7414
|
+
() => false,
|
|
7415
|
+
"Skips task reconciliation when no authority query task is available.",
|
|
7416
|
+
{
|
|
7417
|
+
register: false,
|
|
7418
|
+
isHidden: true
|
|
7419
|
+
}
|
|
7420
|
+
);
|
|
7421
|
+
const authoritativeRoutineReconciliationGraph = authoritativeRoutineQueryTask?.then(reconcileRoutineRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7422
|
+
"Skip authoritative routine reconciliation",
|
|
7423
|
+
() => false,
|
|
7424
|
+
"Skips routine reconciliation when no authority query task is available.",
|
|
7425
|
+
{
|
|
7426
|
+
register: false,
|
|
7427
|
+
isHidden: true
|
|
7428
|
+
}
|
|
7429
|
+
);
|
|
7430
|
+
const authoritativeSignalReconciliationGraph = authoritativeSignalQueryTask?.then(reconcileSignalRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7431
|
+
"Skip authoritative signal reconciliation",
|
|
7432
|
+
() => false,
|
|
7433
|
+
"Skips signal reconciliation when no authority query task is available.",
|
|
7434
|
+
{
|
|
7435
|
+
register: false,
|
|
7436
|
+
isHidden: true
|
|
7437
|
+
}
|
|
7438
|
+
);
|
|
7439
|
+
const authoritativeIntentReconciliationGraph = authoritativeIntentQueryTask?.then(reconcileIntentRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7440
|
+
"Skip authoritative intent reconciliation",
|
|
7441
|
+
() => false,
|
|
7442
|
+
"Skips intent reconciliation when no authority query task is available.",
|
|
7443
|
+
{
|
|
7444
|
+
register: false,
|
|
7445
|
+
isHidden: true
|
|
7446
|
+
}
|
|
7447
|
+
);
|
|
7448
|
+
const authoritativeRegistrationTriggers = [
|
|
7449
|
+
"meta.service_registry.initial_sync_complete",
|
|
7450
|
+
"meta.sync_requested",
|
|
7451
|
+
"meta.sync_controller.synced_resource",
|
|
7452
|
+
"meta.sync_controller.authority_registration_reconciliation_requested"
|
|
7453
|
+
];
|
|
7454
|
+
CadenzaService.createMetaTask(
|
|
7455
|
+
"Prepare authoritative task registration query",
|
|
7456
|
+
(ctx) => {
|
|
7457
|
+
if (!this.isCadenzaDBReady) {
|
|
7458
|
+
return false;
|
|
7459
|
+
}
|
|
7460
|
+
const serviceName2 = resolveSyncServiceName();
|
|
7461
|
+
if (!serviceName2) {
|
|
7462
|
+
return false;
|
|
7463
|
+
}
|
|
7464
|
+
return {
|
|
7465
|
+
...ctx,
|
|
7466
|
+
__syncServiceName: serviceName2,
|
|
7467
|
+
queryData: {
|
|
7468
|
+
filter: {
|
|
7469
|
+
service_name: serviceName2
|
|
7470
|
+
},
|
|
7471
|
+
fields: ["name", "version", "service_name"]
|
|
7472
|
+
}
|
|
7473
|
+
};
|
|
7474
|
+
},
|
|
7475
|
+
"Builds the authority task query payload for the current service.",
|
|
7476
|
+
{
|
|
7477
|
+
register: false,
|
|
7478
|
+
isHidden: true
|
|
7479
|
+
}
|
|
7480
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeTaskReconciliationGraph);
|
|
7481
|
+
CadenzaService.createMetaTask(
|
|
7482
|
+
"Prepare authoritative routine registration query",
|
|
7483
|
+
(ctx) => {
|
|
7484
|
+
if (!this.isCadenzaDBReady) {
|
|
7485
|
+
return false;
|
|
7486
|
+
}
|
|
7487
|
+
const serviceName2 = resolveSyncServiceName();
|
|
7488
|
+
if (!serviceName2) {
|
|
7489
|
+
return false;
|
|
7490
|
+
}
|
|
7491
|
+
return {
|
|
7492
|
+
...ctx,
|
|
7493
|
+
__syncServiceName: serviceName2,
|
|
7494
|
+
queryData: {
|
|
7495
|
+
filter: {
|
|
7496
|
+
service_name: serviceName2
|
|
7497
|
+
},
|
|
7498
|
+
fields: ["name", "version", "service_name"]
|
|
7499
|
+
}
|
|
7500
|
+
};
|
|
7501
|
+
},
|
|
7502
|
+
"Builds the authority routine query payload for the current service.",
|
|
7503
|
+
{
|
|
7504
|
+
register: false,
|
|
7505
|
+
isHidden: true
|
|
7506
|
+
}
|
|
7507
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeRoutineReconciliationGraph);
|
|
7508
|
+
CadenzaService.createMetaTask(
|
|
7509
|
+
"Prepare authoritative signal registration query",
|
|
7510
|
+
(ctx) => {
|
|
7511
|
+
if (!this.isCadenzaDBReady) {
|
|
7512
|
+
return false;
|
|
7513
|
+
}
|
|
7514
|
+
return {
|
|
7515
|
+
...ctx,
|
|
7516
|
+
queryData: {
|
|
7517
|
+
fields: ["name"]
|
|
7518
|
+
}
|
|
7519
|
+
};
|
|
7520
|
+
},
|
|
7521
|
+
"Builds the authority signal query payload for local reconciliation.",
|
|
7522
|
+
{
|
|
7523
|
+
register: false,
|
|
7524
|
+
isHidden: true
|
|
7525
|
+
}
|
|
7526
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeSignalReconciliationGraph);
|
|
7527
|
+
CadenzaService.createMetaTask(
|
|
7528
|
+
"Prepare authoritative intent registration query",
|
|
7529
|
+
(ctx) => {
|
|
7530
|
+
if (!this.isCadenzaDBReady) {
|
|
7531
|
+
return false;
|
|
7532
|
+
}
|
|
7533
|
+
return {
|
|
7534
|
+
...ctx,
|
|
7535
|
+
queryData: {
|
|
7536
|
+
fields: ["name"]
|
|
7537
|
+
}
|
|
7538
|
+
};
|
|
7539
|
+
},
|
|
7540
|
+
"Builds the authority intent query payload for local reconciliation.",
|
|
7541
|
+
{
|
|
7542
|
+
register: false,
|
|
7543
|
+
isHidden: true
|
|
7544
|
+
}
|
|
7545
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeIntentReconciliationGraph);
|
|
7208
7546
|
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
7209
7547
|
"meta.sync_controller.sync_tick",
|
|
7210
7548
|
"meta.service_registry.initial_sync_complete"
|
|
@@ -8535,7 +8873,7 @@ var CadenzaService = class {
|
|
|
8535
8873
|
this.ensureFrontendSyncLoop();
|
|
8536
8874
|
} else {
|
|
8537
8875
|
GraphMetadataController.instance;
|
|
8538
|
-
GraphSyncController.instance.isCadenzaDBReady = !!options.cadenzaDB?.connect;
|
|
8876
|
+
GraphSyncController.instance.isCadenzaDBReady = serviceName === "CadenzaDB" || !!options.cadenzaDB?.connect;
|
|
8539
8877
|
GraphSyncController.instance.init();
|
|
8540
8878
|
}
|
|
8541
8879
|
this.log("Service created.");
|