@cadenza.io/service 2.17.42 → 2.17.43
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 +338 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +338 -0
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +338 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +338 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -6346,6 +6346,40 @@ var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
|
6346
6346
|
"intent_to_task_map",
|
|
6347
6347
|
"directional_task_graph_map"
|
|
6348
6348
|
];
|
|
6349
|
+
var AUTHORITY_QUERY_RESULT_KEYS = {
|
|
6350
|
+
task: "tasks",
|
|
6351
|
+
routine: "routines",
|
|
6352
|
+
signal_registry: "signalRegistrys",
|
|
6353
|
+
intent_registry: "intentRegistrys"
|
|
6354
|
+
};
|
|
6355
|
+
function resolveSyncQueryRows(ctx, tableName) {
|
|
6356
|
+
const resultKey = AUTHORITY_QUERY_RESULT_KEYS[tableName];
|
|
6357
|
+
const rows = ctx?.[resultKey];
|
|
6358
|
+
return Array.isArray(rows) ? rows : [];
|
|
6359
|
+
}
|
|
6360
|
+
function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
6361
|
+
const localQueryTask = CadenzaService.getLocalCadenzaDBQueryTask(tableName);
|
|
6362
|
+
const remoteQueryTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBQueryTask(tableName, queryData, options) : void 0;
|
|
6363
|
+
if (!localQueryTask && !remoteQueryTask) {
|
|
6364
|
+
return void 0;
|
|
6365
|
+
}
|
|
6366
|
+
const targetTask = localQueryTask ?? remoteQueryTask;
|
|
6367
|
+
return CadenzaService.createMetaTask(
|
|
6368
|
+
`Prepare graph sync query for ${tableName}`,
|
|
6369
|
+
(ctx) => ({
|
|
6370
|
+
...ctx,
|
|
6371
|
+
queryData: {
|
|
6372
|
+
...ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {},
|
|
6373
|
+
...queryData
|
|
6374
|
+
}
|
|
6375
|
+
}),
|
|
6376
|
+
`Prepares ${tableName} graph-sync query payloads.`,
|
|
6377
|
+
{
|
|
6378
|
+
register: false,
|
|
6379
|
+
isHidden: true
|
|
6380
|
+
}
|
|
6381
|
+
).then(targetTask);
|
|
6382
|
+
}
|
|
6349
6383
|
var GraphSyncController = class _GraphSyncController {
|
|
6350
6384
|
constructor() {
|
|
6351
6385
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
@@ -6446,6 +6480,30 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6446
6480
|
},
|
|
6447
6481
|
{ concurrency: 30 }
|
|
6448
6482
|
);
|
|
6483
|
+
const authoritativeTaskQueryTask = resolveSyncQueryTask(
|
|
6484
|
+
this.isCadenzaDBReady,
|
|
6485
|
+
"task",
|
|
6486
|
+
{},
|
|
6487
|
+
{ concurrency: 10 }
|
|
6488
|
+
);
|
|
6489
|
+
const authoritativeRoutineQueryTask = resolveSyncQueryTask(
|
|
6490
|
+
this.isCadenzaDBReady,
|
|
6491
|
+
"routine",
|
|
6492
|
+
{},
|
|
6493
|
+
{ concurrency: 10 }
|
|
6494
|
+
);
|
|
6495
|
+
const authoritativeSignalQueryTask = resolveSyncQueryTask(
|
|
6496
|
+
this.isCadenzaDBReady,
|
|
6497
|
+
"signal_registry",
|
|
6498
|
+
{},
|
|
6499
|
+
{ concurrency: 10 }
|
|
6500
|
+
);
|
|
6501
|
+
const authoritativeIntentQueryTask = resolveSyncQueryTask(
|
|
6502
|
+
this.isCadenzaDBReady,
|
|
6503
|
+
"intent_registry",
|
|
6504
|
+
{},
|
|
6505
|
+
{ concurrency: 10 }
|
|
6506
|
+
);
|
|
6449
6507
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
6450
6508
|
"Split routines for registration",
|
|
6451
6509
|
(ctx, emit) => {
|
|
@@ -7254,6 +7312,286 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7254
7312
|
)
|
|
7255
7313
|
)
|
|
7256
7314
|
);
|
|
7315
|
+
const reconcileTaskRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7316
|
+
"Reconcile task registration from authority",
|
|
7317
|
+
(ctx, emit) => {
|
|
7318
|
+
const authoritativeTasks = resolveSyncQueryRows(ctx, "task");
|
|
7319
|
+
let changed = false;
|
|
7320
|
+
for (const row of authoritativeTasks) {
|
|
7321
|
+
const taskName = typeof row.name === "string" ? row.name : "";
|
|
7322
|
+
if (!taskName) {
|
|
7323
|
+
continue;
|
|
7324
|
+
}
|
|
7325
|
+
const task = CadenzaService.get(taskName);
|
|
7326
|
+
if (!task || task.registered) {
|
|
7327
|
+
continue;
|
|
7328
|
+
}
|
|
7329
|
+
task.registered = true;
|
|
7330
|
+
changed = true;
|
|
7331
|
+
emit("meta.sync_controller.task_registered", {
|
|
7332
|
+
...ctx,
|
|
7333
|
+
__taskName: task.name,
|
|
7334
|
+
task,
|
|
7335
|
+
__authoritativeReconciliation: true
|
|
7336
|
+
});
|
|
7337
|
+
}
|
|
7338
|
+
if (authoritativeTasks.length > 0) {
|
|
7339
|
+
CadenzaService.debounce(
|
|
7340
|
+
"meta.sync_controller.task_registration_settled",
|
|
7341
|
+
{
|
|
7342
|
+
__syncing: true,
|
|
7343
|
+
__authoritativeReconciliation: true
|
|
7344
|
+
},
|
|
7345
|
+
300
|
|
7346
|
+
);
|
|
7347
|
+
}
|
|
7348
|
+
return changed;
|
|
7349
|
+
},
|
|
7350
|
+
"Marks local tasks as registered when authority rows already exist.",
|
|
7351
|
+
{
|
|
7352
|
+
register: false,
|
|
7353
|
+
isHidden: true
|
|
7354
|
+
}
|
|
7355
|
+
);
|
|
7356
|
+
const reconcileRoutineRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7357
|
+
"Reconcile routine registration from authority",
|
|
7358
|
+
(ctx) => {
|
|
7359
|
+
const authoritativeRoutines = resolveSyncQueryRows(ctx, "routine");
|
|
7360
|
+
let changed = false;
|
|
7361
|
+
for (const row of authoritativeRoutines) {
|
|
7362
|
+
const routineName = typeof row.name === "string" ? row.name : "";
|
|
7363
|
+
if (!routineName) {
|
|
7364
|
+
continue;
|
|
7365
|
+
}
|
|
7366
|
+
const routine = CadenzaService.getRoutine(routineName);
|
|
7367
|
+
if (!routine || routine.registered) {
|
|
7368
|
+
continue;
|
|
7369
|
+
}
|
|
7370
|
+
routine.registered = true;
|
|
7371
|
+
changed = true;
|
|
7372
|
+
}
|
|
7373
|
+
if (authoritativeRoutines.length > 0) {
|
|
7374
|
+
CadenzaService.debounce(
|
|
7375
|
+
"meta.sync_controller.routine_registration_settled",
|
|
7376
|
+
{
|
|
7377
|
+
__syncing: true,
|
|
7378
|
+
__authoritativeReconciliation: true
|
|
7379
|
+
},
|
|
7380
|
+
300
|
|
7381
|
+
);
|
|
7382
|
+
}
|
|
7383
|
+
return changed;
|
|
7384
|
+
},
|
|
7385
|
+
"Marks local routines as registered when authority rows already exist.",
|
|
7386
|
+
{
|
|
7387
|
+
register: false,
|
|
7388
|
+
isHidden: true
|
|
7389
|
+
}
|
|
7390
|
+
);
|
|
7391
|
+
const reconcileSignalRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7392
|
+
"Reconcile signal registration from authority",
|
|
7393
|
+
(ctx) => {
|
|
7394
|
+
const authoritativeSignals = resolveSyncQueryRows(ctx, "signal_registry");
|
|
7395
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
7396
|
+
let changed = false;
|
|
7397
|
+
for (const row of authoritativeSignals) {
|
|
7398
|
+
const signalName = typeof row.name === "string" ? row.name : "";
|
|
7399
|
+
if (!signalName) {
|
|
7400
|
+
continue;
|
|
7401
|
+
}
|
|
7402
|
+
const observer = signalObservers?.get(signalName);
|
|
7403
|
+
if (!observer || observer.registered) {
|
|
7404
|
+
continue;
|
|
7405
|
+
}
|
|
7406
|
+
observer.registered = true;
|
|
7407
|
+
changed = true;
|
|
7408
|
+
}
|
|
7409
|
+
if (authoritativeSignals.length > 0) {
|
|
7410
|
+
CadenzaService.debounce(
|
|
7411
|
+
"meta.sync_controller.signal_registration_settled",
|
|
7412
|
+
{
|
|
7413
|
+
__syncing: true,
|
|
7414
|
+
__authoritativeReconciliation: true
|
|
7415
|
+
},
|
|
7416
|
+
300
|
|
7417
|
+
);
|
|
7418
|
+
}
|
|
7419
|
+
return changed;
|
|
7420
|
+
},
|
|
7421
|
+
"Marks local signals as registered when authority rows already exist.",
|
|
7422
|
+
{
|
|
7423
|
+
register: false,
|
|
7424
|
+
isHidden: true
|
|
7425
|
+
}
|
|
7426
|
+
);
|
|
7427
|
+
const reconcileIntentRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7428
|
+
"Reconcile intent registration from authority",
|
|
7429
|
+
(ctx) => {
|
|
7430
|
+
const authoritativeIntents = resolveSyncQueryRows(ctx, "intent_registry");
|
|
7431
|
+
let changed = false;
|
|
7432
|
+
for (const row of authoritativeIntents) {
|
|
7433
|
+
const intentName = typeof row.name === "string" ? row.name : "";
|
|
7434
|
+
if (!intentName || !CadenzaService.inquiryBroker.intents.has(intentName)) {
|
|
7435
|
+
continue;
|
|
7436
|
+
}
|
|
7437
|
+
if (this.registeredIntentDefinitions.has(intentName)) {
|
|
7438
|
+
continue;
|
|
7439
|
+
}
|
|
7440
|
+
this.registeredIntentDefinitions.add(intentName);
|
|
7441
|
+
changed = true;
|
|
7442
|
+
}
|
|
7443
|
+
if (authoritativeIntents.length > 0) {
|
|
7444
|
+
CadenzaService.debounce(
|
|
7445
|
+
"meta.sync_controller.intent_registration_settled",
|
|
7446
|
+
{
|
|
7447
|
+
__syncing: true,
|
|
7448
|
+
__authoritativeReconciliation: true
|
|
7449
|
+
},
|
|
7450
|
+
300
|
|
7451
|
+
);
|
|
7452
|
+
}
|
|
7453
|
+
return changed;
|
|
7454
|
+
},
|
|
7455
|
+
"Marks local intents as registered when authority rows already exist.",
|
|
7456
|
+
{
|
|
7457
|
+
register: false,
|
|
7458
|
+
isHidden: true
|
|
7459
|
+
}
|
|
7460
|
+
);
|
|
7461
|
+
const authoritativeTaskReconciliationGraph = authoritativeTaskQueryTask?.then(reconcileTaskRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7462
|
+
"Skip authoritative task reconciliation",
|
|
7463
|
+
() => false,
|
|
7464
|
+
"Skips task reconciliation when no authority query task is available.",
|
|
7465
|
+
{
|
|
7466
|
+
register: false,
|
|
7467
|
+
isHidden: true
|
|
7468
|
+
}
|
|
7469
|
+
);
|
|
7470
|
+
const authoritativeRoutineReconciliationGraph = authoritativeRoutineQueryTask?.then(reconcileRoutineRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7471
|
+
"Skip authoritative routine reconciliation",
|
|
7472
|
+
() => false,
|
|
7473
|
+
"Skips routine reconciliation when no authority query task is available.",
|
|
7474
|
+
{
|
|
7475
|
+
register: false,
|
|
7476
|
+
isHidden: true
|
|
7477
|
+
}
|
|
7478
|
+
);
|
|
7479
|
+
const authoritativeSignalReconciliationGraph = authoritativeSignalQueryTask?.then(reconcileSignalRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7480
|
+
"Skip authoritative signal reconciliation",
|
|
7481
|
+
() => false,
|
|
7482
|
+
"Skips signal reconciliation when no authority query task is available.",
|
|
7483
|
+
{
|
|
7484
|
+
register: false,
|
|
7485
|
+
isHidden: true
|
|
7486
|
+
}
|
|
7487
|
+
);
|
|
7488
|
+
const authoritativeIntentReconciliationGraph = authoritativeIntentQueryTask?.then(reconcileIntentRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
7489
|
+
"Skip authoritative intent reconciliation",
|
|
7490
|
+
() => false,
|
|
7491
|
+
"Skips intent reconciliation when no authority query task is available.",
|
|
7492
|
+
{
|
|
7493
|
+
register: false,
|
|
7494
|
+
isHidden: true
|
|
7495
|
+
}
|
|
7496
|
+
);
|
|
7497
|
+
const authoritativeRegistrationTriggers = [
|
|
7498
|
+
"meta.service_registry.initial_sync_complete",
|
|
7499
|
+
"meta.sync_requested",
|
|
7500
|
+
"meta.sync_controller.synced_resource",
|
|
7501
|
+
"meta.sync_controller.authority_registration_reconciliation_requested"
|
|
7502
|
+
];
|
|
7503
|
+
CadenzaService.createMetaTask(
|
|
7504
|
+
"Prepare authoritative task registration query",
|
|
7505
|
+
(ctx) => {
|
|
7506
|
+
if (!this.isCadenzaDBReady) {
|
|
7507
|
+
return false;
|
|
7508
|
+
}
|
|
7509
|
+
const serviceName2 = resolveSyncServiceName();
|
|
7510
|
+
if (!serviceName2) {
|
|
7511
|
+
return false;
|
|
7512
|
+
}
|
|
7513
|
+
return {
|
|
7514
|
+
...ctx,
|
|
7515
|
+
__syncServiceName: serviceName2,
|
|
7516
|
+
queryData: {
|
|
7517
|
+
filter: {
|
|
7518
|
+
service_name: serviceName2
|
|
7519
|
+
},
|
|
7520
|
+
fields: ["name", "version", "service_name"]
|
|
7521
|
+
}
|
|
7522
|
+
};
|
|
7523
|
+
},
|
|
7524
|
+
"Builds the authority task query payload for the current service.",
|
|
7525
|
+
{
|
|
7526
|
+
register: false,
|
|
7527
|
+
isHidden: true
|
|
7528
|
+
}
|
|
7529
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeTaskReconciliationGraph);
|
|
7530
|
+
CadenzaService.createMetaTask(
|
|
7531
|
+
"Prepare authoritative routine registration query",
|
|
7532
|
+
(ctx) => {
|
|
7533
|
+
if (!this.isCadenzaDBReady) {
|
|
7534
|
+
return false;
|
|
7535
|
+
}
|
|
7536
|
+
const serviceName2 = resolveSyncServiceName();
|
|
7537
|
+
if (!serviceName2) {
|
|
7538
|
+
return false;
|
|
7539
|
+
}
|
|
7540
|
+
return {
|
|
7541
|
+
...ctx,
|
|
7542
|
+
__syncServiceName: serviceName2,
|
|
7543
|
+
queryData: {
|
|
7544
|
+
filter: {
|
|
7545
|
+
service_name: serviceName2
|
|
7546
|
+
},
|
|
7547
|
+
fields: ["name", "version", "service_name"]
|
|
7548
|
+
}
|
|
7549
|
+
};
|
|
7550
|
+
},
|
|
7551
|
+
"Builds the authority routine query payload for the current service.",
|
|
7552
|
+
{
|
|
7553
|
+
register: false,
|
|
7554
|
+
isHidden: true
|
|
7555
|
+
}
|
|
7556
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeRoutineReconciliationGraph);
|
|
7557
|
+
CadenzaService.createMetaTask(
|
|
7558
|
+
"Prepare authoritative signal registration query",
|
|
7559
|
+
(ctx) => {
|
|
7560
|
+
if (!this.isCadenzaDBReady) {
|
|
7561
|
+
return false;
|
|
7562
|
+
}
|
|
7563
|
+
return {
|
|
7564
|
+
...ctx,
|
|
7565
|
+
queryData: {
|
|
7566
|
+
fields: ["name"]
|
|
7567
|
+
}
|
|
7568
|
+
};
|
|
7569
|
+
},
|
|
7570
|
+
"Builds the authority signal query payload for local reconciliation.",
|
|
7571
|
+
{
|
|
7572
|
+
register: false,
|
|
7573
|
+
isHidden: true
|
|
7574
|
+
}
|
|
7575
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeSignalReconciliationGraph);
|
|
7576
|
+
CadenzaService.createMetaTask(
|
|
7577
|
+
"Prepare authoritative intent registration query",
|
|
7578
|
+
(ctx) => {
|
|
7579
|
+
if (!this.isCadenzaDBReady) {
|
|
7580
|
+
return false;
|
|
7581
|
+
}
|
|
7582
|
+
return {
|
|
7583
|
+
...ctx,
|
|
7584
|
+
queryData: {
|
|
7585
|
+
fields: ["name"]
|
|
7586
|
+
}
|
|
7587
|
+
};
|
|
7588
|
+
},
|
|
7589
|
+
"Builds the authority intent query payload for local reconciliation.",
|
|
7590
|
+
{
|
|
7591
|
+
register: false,
|
|
7592
|
+
isHidden: true
|
|
7593
|
+
}
|
|
7594
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeIntentReconciliationGraph);
|
|
7257
7595
|
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
7258
7596
|
"meta.sync_controller.sync_tick",
|
|
7259
7597
|
"meta.service_registry.initial_sync_complete"
|