@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/index.mjs
CHANGED
|
@@ -8761,6 +8761,40 @@ var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
|
8761
8761
|
"intent_to_task_map",
|
|
8762
8762
|
"directional_task_graph_map"
|
|
8763
8763
|
];
|
|
8764
|
+
var AUTHORITY_QUERY_RESULT_KEYS = {
|
|
8765
|
+
task: "tasks",
|
|
8766
|
+
routine: "routines",
|
|
8767
|
+
signal_registry: "signalRegistrys",
|
|
8768
|
+
intent_registry: "intentRegistrys"
|
|
8769
|
+
};
|
|
8770
|
+
function resolveSyncQueryRows(ctx, tableName) {
|
|
8771
|
+
const resultKey = AUTHORITY_QUERY_RESULT_KEYS[tableName];
|
|
8772
|
+
const rows = ctx?.[resultKey];
|
|
8773
|
+
return Array.isArray(rows) ? rows : [];
|
|
8774
|
+
}
|
|
8775
|
+
function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
8776
|
+
const localQueryTask = CadenzaService.getLocalCadenzaDBQueryTask(tableName);
|
|
8777
|
+
const remoteQueryTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBQueryTask(tableName, queryData, options) : void 0;
|
|
8778
|
+
if (!localQueryTask && !remoteQueryTask) {
|
|
8779
|
+
return void 0;
|
|
8780
|
+
}
|
|
8781
|
+
const targetTask = localQueryTask ?? remoteQueryTask;
|
|
8782
|
+
return CadenzaService.createMetaTask(
|
|
8783
|
+
`Prepare graph sync query for ${tableName}`,
|
|
8784
|
+
(ctx) => ({
|
|
8785
|
+
...ctx,
|
|
8786
|
+
queryData: {
|
|
8787
|
+
...ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {},
|
|
8788
|
+
...queryData
|
|
8789
|
+
}
|
|
8790
|
+
}),
|
|
8791
|
+
`Prepares ${tableName} graph-sync query payloads.`,
|
|
8792
|
+
{
|
|
8793
|
+
register: false,
|
|
8794
|
+
isHidden: true
|
|
8795
|
+
}
|
|
8796
|
+
).then(targetTask);
|
|
8797
|
+
}
|
|
8764
8798
|
var GraphSyncController = class _GraphSyncController {
|
|
8765
8799
|
constructor() {
|
|
8766
8800
|
this.registeredActors = /* @__PURE__ */ new Set();
|
|
@@ -8861,6 +8895,30 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8861
8895
|
},
|
|
8862
8896
|
{ concurrency: 30 }
|
|
8863
8897
|
);
|
|
8898
|
+
const authoritativeTaskQueryTask = resolveSyncQueryTask(
|
|
8899
|
+
this.isCadenzaDBReady,
|
|
8900
|
+
"task",
|
|
8901
|
+
{},
|
|
8902
|
+
{ concurrency: 10 }
|
|
8903
|
+
);
|
|
8904
|
+
const authoritativeRoutineQueryTask = resolveSyncQueryTask(
|
|
8905
|
+
this.isCadenzaDBReady,
|
|
8906
|
+
"routine",
|
|
8907
|
+
{},
|
|
8908
|
+
{ concurrency: 10 }
|
|
8909
|
+
);
|
|
8910
|
+
const authoritativeSignalQueryTask = resolveSyncQueryTask(
|
|
8911
|
+
this.isCadenzaDBReady,
|
|
8912
|
+
"signal_registry",
|
|
8913
|
+
{},
|
|
8914
|
+
{ concurrency: 10 }
|
|
8915
|
+
);
|
|
8916
|
+
const authoritativeIntentQueryTask = resolveSyncQueryTask(
|
|
8917
|
+
this.isCadenzaDBReady,
|
|
8918
|
+
"intent_registry",
|
|
8919
|
+
{},
|
|
8920
|
+
{ concurrency: 10 }
|
|
8921
|
+
);
|
|
8864
8922
|
this.splitRoutinesTask = CadenzaService.createMetaTask(
|
|
8865
8923
|
"Split routines for registration",
|
|
8866
8924
|
(ctx, emit) => {
|
|
@@ -9669,6 +9727,286 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9669
9727
|
)
|
|
9670
9728
|
)
|
|
9671
9729
|
);
|
|
9730
|
+
const reconcileTaskRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
9731
|
+
"Reconcile task registration from authority",
|
|
9732
|
+
(ctx, emit) => {
|
|
9733
|
+
const authoritativeTasks = resolveSyncQueryRows(ctx, "task");
|
|
9734
|
+
let changed = false;
|
|
9735
|
+
for (const row of authoritativeTasks) {
|
|
9736
|
+
const taskName = typeof row.name === "string" ? row.name : "";
|
|
9737
|
+
if (!taskName) {
|
|
9738
|
+
continue;
|
|
9739
|
+
}
|
|
9740
|
+
const task = CadenzaService.get(taskName);
|
|
9741
|
+
if (!task || task.registered) {
|
|
9742
|
+
continue;
|
|
9743
|
+
}
|
|
9744
|
+
task.registered = true;
|
|
9745
|
+
changed = true;
|
|
9746
|
+
emit("meta.sync_controller.task_registered", {
|
|
9747
|
+
...ctx,
|
|
9748
|
+
__taskName: task.name,
|
|
9749
|
+
task,
|
|
9750
|
+
__authoritativeReconciliation: true
|
|
9751
|
+
});
|
|
9752
|
+
}
|
|
9753
|
+
if (authoritativeTasks.length > 0) {
|
|
9754
|
+
CadenzaService.debounce(
|
|
9755
|
+
"meta.sync_controller.task_registration_settled",
|
|
9756
|
+
{
|
|
9757
|
+
__syncing: true,
|
|
9758
|
+
__authoritativeReconciliation: true
|
|
9759
|
+
},
|
|
9760
|
+
300
|
|
9761
|
+
);
|
|
9762
|
+
}
|
|
9763
|
+
return changed;
|
|
9764
|
+
},
|
|
9765
|
+
"Marks local tasks as registered when authority rows already exist.",
|
|
9766
|
+
{
|
|
9767
|
+
register: false,
|
|
9768
|
+
isHidden: true
|
|
9769
|
+
}
|
|
9770
|
+
);
|
|
9771
|
+
const reconcileRoutineRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
9772
|
+
"Reconcile routine registration from authority",
|
|
9773
|
+
(ctx) => {
|
|
9774
|
+
const authoritativeRoutines = resolveSyncQueryRows(ctx, "routine");
|
|
9775
|
+
let changed = false;
|
|
9776
|
+
for (const row of authoritativeRoutines) {
|
|
9777
|
+
const routineName = typeof row.name === "string" ? row.name : "";
|
|
9778
|
+
if (!routineName) {
|
|
9779
|
+
continue;
|
|
9780
|
+
}
|
|
9781
|
+
const routine = CadenzaService.getRoutine(routineName);
|
|
9782
|
+
if (!routine || routine.registered) {
|
|
9783
|
+
continue;
|
|
9784
|
+
}
|
|
9785
|
+
routine.registered = true;
|
|
9786
|
+
changed = true;
|
|
9787
|
+
}
|
|
9788
|
+
if (authoritativeRoutines.length > 0) {
|
|
9789
|
+
CadenzaService.debounce(
|
|
9790
|
+
"meta.sync_controller.routine_registration_settled",
|
|
9791
|
+
{
|
|
9792
|
+
__syncing: true,
|
|
9793
|
+
__authoritativeReconciliation: true
|
|
9794
|
+
},
|
|
9795
|
+
300
|
|
9796
|
+
);
|
|
9797
|
+
}
|
|
9798
|
+
return changed;
|
|
9799
|
+
},
|
|
9800
|
+
"Marks local routines as registered when authority rows already exist.",
|
|
9801
|
+
{
|
|
9802
|
+
register: false,
|
|
9803
|
+
isHidden: true
|
|
9804
|
+
}
|
|
9805
|
+
);
|
|
9806
|
+
const reconcileSignalRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
9807
|
+
"Reconcile signal registration from authority",
|
|
9808
|
+
(ctx) => {
|
|
9809
|
+
const authoritativeSignals = resolveSyncQueryRows(ctx, "signal_registry");
|
|
9810
|
+
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
9811
|
+
let changed = false;
|
|
9812
|
+
for (const row of authoritativeSignals) {
|
|
9813
|
+
const signalName = typeof row.name === "string" ? row.name : "";
|
|
9814
|
+
if (!signalName) {
|
|
9815
|
+
continue;
|
|
9816
|
+
}
|
|
9817
|
+
const observer = signalObservers?.get(signalName);
|
|
9818
|
+
if (!observer || observer.registered) {
|
|
9819
|
+
continue;
|
|
9820
|
+
}
|
|
9821
|
+
observer.registered = true;
|
|
9822
|
+
changed = true;
|
|
9823
|
+
}
|
|
9824
|
+
if (authoritativeSignals.length > 0) {
|
|
9825
|
+
CadenzaService.debounce(
|
|
9826
|
+
"meta.sync_controller.signal_registration_settled",
|
|
9827
|
+
{
|
|
9828
|
+
__syncing: true,
|
|
9829
|
+
__authoritativeReconciliation: true
|
|
9830
|
+
},
|
|
9831
|
+
300
|
|
9832
|
+
);
|
|
9833
|
+
}
|
|
9834
|
+
return changed;
|
|
9835
|
+
},
|
|
9836
|
+
"Marks local signals as registered when authority rows already exist.",
|
|
9837
|
+
{
|
|
9838
|
+
register: false,
|
|
9839
|
+
isHidden: true
|
|
9840
|
+
}
|
|
9841
|
+
);
|
|
9842
|
+
const reconcileIntentRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
9843
|
+
"Reconcile intent registration from authority",
|
|
9844
|
+
(ctx) => {
|
|
9845
|
+
const authoritativeIntents = resolveSyncQueryRows(ctx, "intent_registry");
|
|
9846
|
+
let changed = false;
|
|
9847
|
+
for (const row of authoritativeIntents) {
|
|
9848
|
+
const intentName = typeof row.name === "string" ? row.name : "";
|
|
9849
|
+
if (!intentName || !CadenzaService.inquiryBroker.intents.has(intentName)) {
|
|
9850
|
+
continue;
|
|
9851
|
+
}
|
|
9852
|
+
if (this.registeredIntentDefinitions.has(intentName)) {
|
|
9853
|
+
continue;
|
|
9854
|
+
}
|
|
9855
|
+
this.registeredIntentDefinitions.add(intentName);
|
|
9856
|
+
changed = true;
|
|
9857
|
+
}
|
|
9858
|
+
if (authoritativeIntents.length > 0) {
|
|
9859
|
+
CadenzaService.debounce(
|
|
9860
|
+
"meta.sync_controller.intent_registration_settled",
|
|
9861
|
+
{
|
|
9862
|
+
__syncing: true,
|
|
9863
|
+
__authoritativeReconciliation: true
|
|
9864
|
+
},
|
|
9865
|
+
300
|
|
9866
|
+
);
|
|
9867
|
+
}
|
|
9868
|
+
return changed;
|
|
9869
|
+
},
|
|
9870
|
+
"Marks local intents as registered when authority rows already exist.",
|
|
9871
|
+
{
|
|
9872
|
+
register: false,
|
|
9873
|
+
isHidden: true
|
|
9874
|
+
}
|
|
9875
|
+
);
|
|
9876
|
+
const authoritativeTaskReconciliationGraph = authoritativeTaskQueryTask?.then(reconcileTaskRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
9877
|
+
"Skip authoritative task reconciliation",
|
|
9878
|
+
() => false,
|
|
9879
|
+
"Skips task reconciliation when no authority query task is available.",
|
|
9880
|
+
{
|
|
9881
|
+
register: false,
|
|
9882
|
+
isHidden: true
|
|
9883
|
+
}
|
|
9884
|
+
);
|
|
9885
|
+
const authoritativeRoutineReconciliationGraph = authoritativeRoutineQueryTask?.then(reconcileRoutineRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
9886
|
+
"Skip authoritative routine reconciliation",
|
|
9887
|
+
() => false,
|
|
9888
|
+
"Skips routine reconciliation when no authority query task is available.",
|
|
9889
|
+
{
|
|
9890
|
+
register: false,
|
|
9891
|
+
isHidden: true
|
|
9892
|
+
}
|
|
9893
|
+
);
|
|
9894
|
+
const authoritativeSignalReconciliationGraph = authoritativeSignalQueryTask?.then(reconcileSignalRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
9895
|
+
"Skip authoritative signal reconciliation",
|
|
9896
|
+
() => false,
|
|
9897
|
+
"Skips signal reconciliation when no authority query task is available.",
|
|
9898
|
+
{
|
|
9899
|
+
register: false,
|
|
9900
|
+
isHidden: true
|
|
9901
|
+
}
|
|
9902
|
+
);
|
|
9903
|
+
const authoritativeIntentReconciliationGraph = authoritativeIntentQueryTask?.then(reconcileIntentRegistrationFromAuthorityTask) ?? CadenzaService.createMetaTask(
|
|
9904
|
+
"Skip authoritative intent reconciliation",
|
|
9905
|
+
() => false,
|
|
9906
|
+
"Skips intent reconciliation when no authority query task is available.",
|
|
9907
|
+
{
|
|
9908
|
+
register: false,
|
|
9909
|
+
isHidden: true
|
|
9910
|
+
}
|
|
9911
|
+
);
|
|
9912
|
+
const authoritativeRegistrationTriggers = [
|
|
9913
|
+
"meta.service_registry.initial_sync_complete",
|
|
9914
|
+
"meta.sync_requested",
|
|
9915
|
+
"meta.sync_controller.synced_resource",
|
|
9916
|
+
"meta.sync_controller.authority_registration_reconciliation_requested"
|
|
9917
|
+
];
|
|
9918
|
+
CadenzaService.createMetaTask(
|
|
9919
|
+
"Prepare authoritative task registration query",
|
|
9920
|
+
(ctx) => {
|
|
9921
|
+
if (!this.isCadenzaDBReady) {
|
|
9922
|
+
return false;
|
|
9923
|
+
}
|
|
9924
|
+
const serviceName2 = resolveSyncServiceName();
|
|
9925
|
+
if (!serviceName2) {
|
|
9926
|
+
return false;
|
|
9927
|
+
}
|
|
9928
|
+
return {
|
|
9929
|
+
...ctx,
|
|
9930
|
+
__syncServiceName: serviceName2,
|
|
9931
|
+
queryData: {
|
|
9932
|
+
filter: {
|
|
9933
|
+
service_name: serviceName2
|
|
9934
|
+
},
|
|
9935
|
+
fields: ["name", "version", "service_name"]
|
|
9936
|
+
}
|
|
9937
|
+
};
|
|
9938
|
+
},
|
|
9939
|
+
"Builds the authority task query payload for the current service.",
|
|
9940
|
+
{
|
|
9941
|
+
register: false,
|
|
9942
|
+
isHidden: true
|
|
9943
|
+
}
|
|
9944
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeTaskReconciliationGraph);
|
|
9945
|
+
CadenzaService.createMetaTask(
|
|
9946
|
+
"Prepare authoritative routine registration query",
|
|
9947
|
+
(ctx) => {
|
|
9948
|
+
if (!this.isCadenzaDBReady) {
|
|
9949
|
+
return false;
|
|
9950
|
+
}
|
|
9951
|
+
const serviceName2 = resolveSyncServiceName();
|
|
9952
|
+
if (!serviceName2) {
|
|
9953
|
+
return false;
|
|
9954
|
+
}
|
|
9955
|
+
return {
|
|
9956
|
+
...ctx,
|
|
9957
|
+
__syncServiceName: serviceName2,
|
|
9958
|
+
queryData: {
|
|
9959
|
+
filter: {
|
|
9960
|
+
service_name: serviceName2
|
|
9961
|
+
},
|
|
9962
|
+
fields: ["name", "version", "service_name"]
|
|
9963
|
+
}
|
|
9964
|
+
};
|
|
9965
|
+
},
|
|
9966
|
+
"Builds the authority routine query payload for the current service.",
|
|
9967
|
+
{
|
|
9968
|
+
register: false,
|
|
9969
|
+
isHidden: true
|
|
9970
|
+
}
|
|
9971
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeRoutineReconciliationGraph);
|
|
9972
|
+
CadenzaService.createMetaTask(
|
|
9973
|
+
"Prepare authoritative signal registration query",
|
|
9974
|
+
(ctx) => {
|
|
9975
|
+
if (!this.isCadenzaDBReady) {
|
|
9976
|
+
return false;
|
|
9977
|
+
}
|
|
9978
|
+
return {
|
|
9979
|
+
...ctx,
|
|
9980
|
+
queryData: {
|
|
9981
|
+
fields: ["name"]
|
|
9982
|
+
}
|
|
9983
|
+
};
|
|
9984
|
+
},
|
|
9985
|
+
"Builds the authority signal query payload for local reconciliation.",
|
|
9986
|
+
{
|
|
9987
|
+
register: false,
|
|
9988
|
+
isHidden: true
|
|
9989
|
+
}
|
|
9990
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeSignalReconciliationGraph);
|
|
9991
|
+
CadenzaService.createMetaTask(
|
|
9992
|
+
"Prepare authoritative intent registration query",
|
|
9993
|
+
(ctx) => {
|
|
9994
|
+
if (!this.isCadenzaDBReady) {
|
|
9995
|
+
return false;
|
|
9996
|
+
}
|
|
9997
|
+
return {
|
|
9998
|
+
...ctx,
|
|
9999
|
+
queryData: {
|
|
10000
|
+
fields: ["name"]
|
|
10001
|
+
}
|
|
10002
|
+
};
|
|
10003
|
+
},
|
|
10004
|
+
"Builds the authority intent query payload for local reconciliation.",
|
|
10005
|
+
{
|
|
10006
|
+
register: false,
|
|
10007
|
+
isHidden: true
|
|
10008
|
+
}
|
|
10009
|
+
).doOn(...authoritativeRegistrationTriggers).then(authoritativeIntentReconciliationGraph);
|
|
9672
10010
|
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
9673
10011
|
"meta.sync_controller.sync_tick",
|
|
9674
10012
|
"meta.service_registry.initial_sync_complete"
|
|
@@ -10999,7 +11337,7 @@ var CadenzaService = class {
|
|
|
10999
11337
|
this.ensureFrontendSyncLoop();
|
|
11000
11338
|
} else {
|
|
11001
11339
|
GraphMetadataController.instance;
|
|
11002
|
-
GraphSyncController.instance.isCadenzaDBReady = !!options.cadenzaDB?.connect;
|
|
11340
|
+
GraphSyncController.instance.isCadenzaDBReady = serviceName === "CadenzaDB" || !!options.cadenzaDB?.connect;
|
|
11003
11341
|
GraphSyncController.instance.init();
|
|
11004
11342
|
}
|
|
11005
11343
|
this.log("Service created.");
|