@cadenza.io/service 2.17.52 → 2.17.53
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 +477 -421
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +477 -421
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.js +477 -421
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +477 -421
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -385,16 +385,16 @@ function normalizeServiceTransportConfig(value) {
|
|
|
385
385
|
}
|
|
386
386
|
function normalizeServiceTransportDescriptor(value) {
|
|
387
387
|
const raw = value ?? {};
|
|
388
|
-
const
|
|
388
|
+
const uuid8 = normalizeString(raw.uuid);
|
|
389
389
|
const serviceInstanceId = normalizeString(
|
|
390
390
|
raw.serviceInstanceId ?? raw.service_instance_id
|
|
391
391
|
);
|
|
392
392
|
const config = normalizeServiceTransportConfig(raw);
|
|
393
|
-
if (!
|
|
393
|
+
if (!uuid8 || !serviceInstanceId || !config) {
|
|
394
394
|
return null;
|
|
395
395
|
}
|
|
396
396
|
return {
|
|
397
|
-
uuid:
|
|
397
|
+
uuid: uuid8,
|
|
398
398
|
serviceInstanceId,
|
|
399
399
|
role: config.role,
|
|
400
400
|
origin: config.origin,
|
|
@@ -456,14 +456,14 @@ function normalizeTransportArray(value, serviceInstanceId) {
|
|
|
456
456
|
}
|
|
457
457
|
function normalizeServiceInstanceDescriptor(value) {
|
|
458
458
|
const raw = value ?? {};
|
|
459
|
-
const
|
|
459
|
+
const uuid8 = normalizeString2(raw.uuid);
|
|
460
460
|
const serviceName = normalizeString2(raw.serviceName ?? raw.service_name);
|
|
461
|
-
if (!
|
|
461
|
+
if (!uuid8 || !serviceName) {
|
|
462
462
|
return null;
|
|
463
463
|
}
|
|
464
|
-
const transports = normalizeTransportArray(raw.transports,
|
|
464
|
+
const transports = normalizeTransportArray(raw.transports, uuid8);
|
|
465
465
|
return {
|
|
466
|
-
uuid:
|
|
466
|
+
uuid: uuid8,
|
|
467
467
|
serviceName,
|
|
468
468
|
numberOfRunningGraphs: Math.max(
|
|
469
469
|
0,
|
|
@@ -1104,15 +1104,15 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1104
1104
|
if (!serviceInstance) {
|
|
1105
1105
|
return false;
|
|
1106
1106
|
}
|
|
1107
|
-
const
|
|
1107
|
+
const uuid8 = serviceInstance.uuid;
|
|
1108
1108
|
const serviceName = serviceInstance.serviceName;
|
|
1109
1109
|
const deleted = Boolean(
|
|
1110
1110
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
1111
1111
|
);
|
|
1112
|
-
if (
|
|
1112
|
+
if (uuid8 === this.serviceInstanceId) return;
|
|
1113
1113
|
if (deleted) {
|
|
1114
|
-
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid ===
|
|
1115
|
-
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid ===
|
|
1114
|
+
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid8);
|
|
1115
|
+
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid8) ?? -1;
|
|
1116
1116
|
if (indexToDelete >= 0 && existingInstance) {
|
|
1117
1117
|
this.instances.get(serviceName)?.splice(indexToDelete, 1);
|
|
1118
1118
|
for (const transport of existingInstance.transports) {
|
|
@@ -1124,13 +1124,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1124
1124
|
if (this.instances.get(serviceName)?.length === 0) {
|
|
1125
1125
|
this.instances.delete(serviceName);
|
|
1126
1126
|
}
|
|
1127
|
-
this.unregisterDependee(
|
|
1127
|
+
this.unregisterDependee(uuid8, serviceName);
|
|
1128
1128
|
return;
|
|
1129
1129
|
}
|
|
1130
1130
|
if (!this.instances.has(serviceName))
|
|
1131
1131
|
this.instances.set(serviceName, []);
|
|
1132
1132
|
const instances = this.instances.get(serviceName);
|
|
1133
|
-
const existing = instances.find((i) => i.uuid ===
|
|
1133
|
+
const existing = instances.find((i) => i.uuid === uuid8);
|
|
1134
1134
|
if (existing) {
|
|
1135
1135
|
Object.assign(existing, {
|
|
1136
1136
|
...serviceInstance,
|
|
@@ -1140,7 +1140,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1140
1140
|
} else {
|
|
1141
1141
|
instances.push(serviceInstance);
|
|
1142
1142
|
}
|
|
1143
|
-
const trackedInstance = existing ?? instances.find((instance) => instance.uuid ===
|
|
1143
|
+
const trackedInstance = existing ?? instances.find((instance) => instance.uuid === uuid8);
|
|
1144
1144
|
if (trackedInstance) {
|
|
1145
1145
|
const snapshot = this.resolveRuntimeStatusSnapshot(
|
|
1146
1146
|
trackedInstance.numberOfRunningGraphs ?? 0,
|
|
@@ -1153,7 +1153,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1153
1153
|
trackedInstance.reportedAt = trackedInstance.reportedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1154
1154
|
}
|
|
1155
1155
|
if (!serviceInstance.isBootstrapPlaceholder) {
|
|
1156
|
-
this.reconcileBootstrapPlaceholderInstance(serviceName,
|
|
1156
|
+
this.reconcileBootstrapPlaceholderInstance(serviceName, uuid8, emit);
|
|
1157
1157
|
}
|
|
1158
1158
|
if (this.serviceName === serviceName) {
|
|
1159
1159
|
return false;
|
|
@@ -1182,7 +1182,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1182
1182
|
if (!clientCreated) {
|
|
1183
1183
|
emit("meta.service_registry.dependee_registered", {
|
|
1184
1184
|
serviceName,
|
|
1185
|
-
serviceInstanceId:
|
|
1185
|
+
serviceInstanceId: uuid8,
|
|
1186
1186
|
serviceTransportId: trackedTransport.uuid,
|
|
1187
1187
|
serviceOrigin: trackedTransport.origin,
|
|
1188
1188
|
transportProtocols: trackedTransport.protocols,
|
|
@@ -1196,7 +1196,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1196
1196
|
} else {
|
|
1197
1197
|
emit("meta.service_registry.routeable_transport_missing", {
|
|
1198
1198
|
serviceName,
|
|
1199
|
-
serviceInstanceId:
|
|
1199
|
+
serviceInstanceId: uuid8,
|
|
1200
1200
|
requiredRole: this.getRoutingTransportRole(),
|
|
1201
1201
|
isFrontend: this.isFrontend
|
|
1202
1202
|
});
|
|
@@ -8616,13 +8616,12 @@ function tableFieldTypeToSchemaType(type) {
|
|
|
8616
8616
|
}
|
|
8617
8617
|
|
|
8618
8618
|
// src/Cadenza.ts
|
|
8619
|
-
import { v4 as
|
|
8619
|
+
import { v4 as uuid6 } from "uuid";
|
|
8620
8620
|
|
|
8621
8621
|
// src/graph/controllers/GraphSyncController.ts
|
|
8622
8622
|
import {
|
|
8623
8623
|
META_ACTOR_SESSION_STATE_PERSIST_INTENT as META_ACTOR_SESSION_STATE_PERSIST_INTENT2
|
|
8624
8624
|
} from "@cadenza.io/core";
|
|
8625
|
-
import { v4 as uuid6 } from "uuid";
|
|
8626
8625
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
8627
8626
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
8628
8627
|
if (typeof taskFunction !== "function") {
|
|
@@ -8750,6 +8749,64 @@ function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
|
8750
8749
|
}
|
|
8751
8750
|
return nextQueryData;
|
|
8752
8751
|
}
|
|
8752
|
+
function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
8753
|
+
if (!graph) {
|
|
8754
|
+
return void 0;
|
|
8755
|
+
}
|
|
8756
|
+
predecessorTask.then(graph.entryTask);
|
|
8757
|
+
if (completionTasks.length > 0) {
|
|
8758
|
+
graph.completionTask.then(...completionTasks);
|
|
8759
|
+
}
|
|
8760
|
+
return graph.completionTask;
|
|
8761
|
+
}
|
|
8762
|
+
function resolveLocalDatabaseTaskIntent(task, operation, tableName) {
|
|
8763
|
+
if (!task) {
|
|
8764
|
+
return void 0;
|
|
8765
|
+
}
|
|
8766
|
+
const expectedPrefix = `${operation}-pg-`;
|
|
8767
|
+
const expectedSuffix = `-${tableName}`;
|
|
8768
|
+
const handledIntents = Array.from(task.handlesIntents ?? []);
|
|
8769
|
+
const directMatch = handledIntents.find(
|
|
8770
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix) && intent.endsWith(expectedSuffix)
|
|
8771
|
+
);
|
|
8772
|
+
if (directMatch) {
|
|
8773
|
+
return directMatch;
|
|
8774
|
+
}
|
|
8775
|
+
return handledIntents.find(
|
|
8776
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix)
|
|
8777
|
+
);
|
|
8778
|
+
}
|
|
8779
|
+
function createLocalDatabaseInquiryTask(localTask, operation, tableName, options = {}) {
|
|
8780
|
+
const intentName = resolveLocalDatabaseTaskIntent(localTask, operation, tableName);
|
|
8781
|
+
return CadenzaService.createMetaTask(
|
|
8782
|
+
`Execute local graph sync ${operation} for ${tableName}`,
|
|
8783
|
+
async (ctx, _emit, inquire) => {
|
|
8784
|
+
if (!intentName) {
|
|
8785
|
+
return {
|
|
8786
|
+
...ctx,
|
|
8787
|
+
errored: true,
|
|
8788
|
+
__success: false,
|
|
8789
|
+
__error: `No local ${operation} intent found for ${tableName}`
|
|
8790
|
+
};
|
|
8791
|
+
}
|
|
8792
|
+
const inquiryContext = {
|
|
8793
|
+
...ctx,
|
|
8794
|
+
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {}
|
|
8795
|
+
};
|
|
8796
|
+
const result = await inquire(intentName, inquiryContext, {});
|
|
8797
|
+
return {
|
|
8798
|
+
...ctx,
|
|
8799
|
+
...result
|
|
8800
|
+
};
|
|
8801
|
+
},
|
|
8802
|
+
`Executes the local ${tableName} ${operation} operation through the generated database intent.`,
|
|
8803
|
+
{
|
|
8804
|
+
...options,
|
|
8805
|
+
register: false,
|
|
8806
|
+
isHidden: true
|
|
8807
|
+
}
|
|
8808
|
+
);
|
|
8809
|
+
}
|
|
8753
8810
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
8754
8811
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
8755
8812
|
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
@@ -8757,7 +8814,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8757
8814
|
if (!localInsertTask && !remoteInsertTask) {
|
|
8758
8815
|
return void 0;
|
|
8759
8816
|
}
|
|
8760
|
-
const targetTask = localInsertTask
|
|
8817
|
+
const targetTask = localInsertTask ? createLocalDatabaseInquiryTask(localInsertTask, "insert", tableName, options) : remoteInsertTask;
|
|
8761
8818
|
if (debugTable) {
|
|
8762
8819
|
logSyncDebug("insert_task_resolved", {
|
|
8763
8820
|
tableName,
|
|
@@ -8768,21 +8825,14 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8768
8825
|
options
|
|
8769
8826
|
});
|
|
8770
8827
|
}
|
|
8771
|
-
const executionRequestedSignal = `meta.sync_controller.insert_execution_requested:${tableName}`;
|
|
8772
|
-
const executionResolvedSignal = `meta.sync_controller.insert_execution_resolved:${tableName}`;
|
|
8773
|
-
const executionFailedSignal = `meta.sync_controller.insert_execution_failed:${tableName}`;
|
|
8774
|
-
const pendingResolverContexts = /* @__PURE__ */ new Map();
|
|
8775
8828
|
const prepareExecutionTask = CadenzaService.createMetaTask(
|
|
8776
8829
|
`Prepare graph sync insert for ${tableName}`,
|
|
8777
8830
|
(ctx) => {
|
|
8778
8831
|
const originalContext = { ...ctx };
|
|
8779
|
-
const originalQueryData = buildSyncInsertQueryData(
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
originalQueryData
|
|
8784
|
-
});
|
|
8785
|
-
}
|
|
8832
|
+
const originalQueryData = buildSyncInsertQueryData(
|
|
8833
|
+
ctx,
|
|
8834
|
+
queryData
|
|
8835
|
+
);
|
|
8786
8836
|
return {
|
|
8787
8837
|
...ctx,
|
|
8788
8838
|
__resolverOriginalContext: originalContext,
|
|
@@ -8795,7 +8845,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8795
8845
|
register: false,
|
|
8796
8846
|
isHidden: true
|
|
8797
8847
|
}
|
|
8798
|
-
)
|
|
8848
|
+
);
|
|
8799
8849
|
if (debugTable) {
|
|
8800
8850
|
prepareExecutionTask.then(
|
|
8801
8851
|
CadenzaService.createMetaTask(
|
|
@@ -8829,15 +8879,9 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8829
8879
|
}
|
|
8830
8880
|
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
8831
8881
|
`Finalize graph sync insert for ${tableName}`,
|
|
8832
|
-
(ctx
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
}
|
|
8836
|
-
const pendingResolverContext = pendingResolverContexts.get(
|
|
8837
|
-
ctx.__resolverRequestId
|
|
8838
|
-
);
|
|
8839
|
-
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : pendingResolverContext?.originalContext ? { ...pendingResolverContext.originalContext } : {};
|
|
8840
|
-
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : pendingResolverContext?.originalQueryData;
|
|
8882
|
+
(ctx) => {
|
|
8883
|
+
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : {};
|
|
8884
|
+
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : void 0;
|
|
8841
8885
|
const normalizedContext = {
|
|
8842
8886
|
...originalContext,
|
|
8843
8887
|
...ctx,
|
|
@@ -8862,8 +8906,6 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8862
8906
|
});
|
|
8863
8907
|
}
|
|
8864
8908
|
}
|
|
8865
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
8866
|
-
emit(executionResolvedSignal, normalizedContext);
|
|
8867
8909
|
return normalizedContext;
|
|
8868
8910
|
},
|
|
8869
8911
|
`Finalizes ${tableName} graph-sync insert execution after the authority task finishes.`,
|
|
@@ -8872,95 +8914,12 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8872
8914
|
isHidden: true
|
|
8873
8915
|
}
|
|
8874
8916
|
);
|
|
8875
|
-
targetTask.then(finalizeExecutionTask).emitsOnFail(executionFailedSignal);
|
|
8876
8917
|
prepareExecutionTask.then(targetTask);
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
if (shouldDebugTaskSyncPayload(ctx) || shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
8883
|
-
logSyncDebug("insert_failed", {
|
|
8884
|
-
tableName,
|
|
8885
|
-
targetTaskName: targetTask.name,
|
|
8886
|
-
payload: buildTaskSyncDebugPayload({
|
|
8887
|
-
...ctx,
|
|
8888
|
-
__taskName: ctx.__taskName
|
|
8889
|
-
})
|
|
8890
|
-
});
|
|
8891
|
-
}
|
|
8892
|
-
} else {
|
|
8893
|
-
logSyncDebug("insert_failed", {
|
|
8894
|
-
tableName,
|
|
8895
|
-
targetTaskName: targetTask.name,
|
|
8896
|
-
ctx
|
|
8897
|
-
});
|
|
8898
|
-
}
|
|
8899
|
-
if (typeof ctx.__resolverRequestId === "string") {
|
|
8900
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
8901
|
-
}
|
|
8902
|
-
return false;
|
|
8903
|
-
},
|
|
8904
|
-
`Logs failed ${tableName} sync insert executions.`,
|
|
8905
|
-
{
|
|
8906
|
-
register: false,
|
|
8907
|
-
isHidden: true
|
|
8908
|
-
}
|
|
8909
|
-
).doOn(executionFailedSignal);
|
|
8910
|
-
}
|
|
8911
|
-
return CadenzaService.createMetaTask(
|
|
8912
|
-
`Resolve graph sync insert for ${tableName}`,
|
|
8913
|
-
(ctx, emit) => new Promise((resolve) => {
|
|
8914
|
-
const resolverRequestId = uuid6();
|
|
8915
|
-
const resolvedContext = {
|
|
8916
|
-
...ctx,
|
|
8917
|
-
__resolverRequestId: resolverRequestId
|
|
8918
|
-
};
|
|
8919
|
-
if (debugTable) {
|
|
8920
|
-
if (tableName === "task") {
|
|
8921
|
-
if (shouldDebugTaskSyncPayload(resolvedContext)) {
|
|
8922
|
-
logSyncDebug("insert_resolver_request", {
|
|
8923
|
-
tableName,
|
|
8924
|
-
targetTaskName: targetTask.name,
|
|
8925
|
-
payload: buildTaskSyncDebugPayload(resolvedContext)
|
|
8926
|
-
});
|
|
8927
|
-
}
|
|
8928
|
-
} else {
|
|
8929
|
-
logSyncDebug("insert_resolver_request", {
|
|
8930
|
-
tableName,
|
|
8931
|
-
targetTaskName: targetTask.name,
|
|
8932
|
-
ctx: resolvedContext
|
|
8933
|
-
});
|
|
8934
|
-
}
|
|
8935
|
-
}
|
|
8936
|
-
CadenzaService.createEphemeralMetaTask(
|
|
8937
|
-
`Resolve graph sync insert execution for ${tableName} (${resolverRequestId})`,
|
|
8938
|
-
(resultCtx) => {
|
|
8939
|
-
if (resultCtx.__resolverRequestId !== resolverRequestId) {
|
|
8940
|
-
return false;
|
|
8941
|
-
}
|
|
8942
|
-
const normalizedResult = {
|
|
8943
|
-
...resultCtx
|
|
8944
|
-
};
|
|
8945
|
-
delete normalizedResult.__resolverRequestId;
|
|
8946
|
-
pendingResolverContexts.delete(resolverRequestId);
|
|
8947
|
-
resolve(normalizedResult);
|
|
8948
|
-
return normalizedResult;
|
|
8949
|
-
},
|
|
8950
|
-
`Waits for ${tableName} graph-sync insert execution.`,
|
|
8951
|
-
{
|
|
8952
|
-
register: false
|
|
8953
|
-
}
|
|
8954
|
-
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
8955
|
-
emit(executionRequestedSignal, resolvedContext);
|
|
8956
|
-
}),
|
|
8957
|
-
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
8958
|
-
{
|
|
8959
|
-
...options,
|
|
8960
|
-
register: false,
|
|
8961
|
-
isHidden: true
|
|
8962
|
-
}
|
|
8963
|
-
);
|
|
8918
|
+
targetTask.then(finalizeExecutionTask);
|
|
8919
|
+
return {
|
|
8920
|
+
entryTask: prepareExecutionTask,
|
|
8921
|
+
completionTask: finalizeExecutionTask
|
|
8922
|
+
};
|
|
8964
8923
|
}
|
|
8965
8924
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
8966
8925
|
"intent_registry",
|
|
@@ -9121,8 +9080,8 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
9121
9080
|
if (!localQueryTask && !remoteQueryTask) {
|
|
9122
9081
|
return void 0;
|
|
9123
9082
|
}
|
|
9124
|
-
const targetTask = localQueryTask
|
|
9125
|
-
|
|
9083
|
+
const targetTask = localQueryTask ? createLocalDatabaseInquiryTask(localQueryTask, "query", tableName, options) : remoteQueryTask;
|
|
9084
|
+
const prepareQueryTask = CadenzaService.createMetaTask(
|
|
9126
9085
|
`Prepare graph sync query for ${tableName}`,
|
|
9127
9086
|
(ctx) => ({
|
|
9128
9087
|
...ctx,
|
|
@@ -9136,7 +9095,22 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
9136
9095
|
register: false,
|
|
9137
9096
|
isHidden: true
|
|
9138
9097
|
}
|
|
9139
|
-
)
|
|
9098
|
+
);
|
|
9099
|
+
const finalizeQueryTask = CadenzaService.createMetaTask(
|
|
9100
|
+
`Finalize graph sync query for ${tableName}`,
|
|
9101
|
+
(ctx) => ctx,
|
|
9102
|
+
`Finalizes ${tableName} graph-sync query payloads after authority lookup.`,
|
|
9103
|
+
{
|
|
9104
|
+
register: false,
|
|
9105
|
+
isHidden: true
|
|
9106
|
+
}
|
|
9107
|
+
);
|
|
9108
|
+
prepareQueryTask.then(targetTask);
|
|
9109
|
+
targetTask.then(finalizeQueryTask);
|
|
9110
|
+
return {
|
|
9111
|
+
entryTask: prepareQueryTask,
|
|
9112
|
+
completionTask: finalizeQueryTask
|
|
9113
|
+
};
|
|
9140
9114
|
}
|
|
9141
9115
|
function getRegistrableTasks() {
|
|
9142
9116
|
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
@@ -9263,25 +9237,25 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9263
9237
|
},
|
|
9264
9238
|
{ concurrency: 30 }
|
|
9265
9239
|
);
|
|
9266
|
-
const
|
|
9240
|
+
const authoritativeTaskQueryGraph = resolveSyncQueryTask(
|
|
9267
9241
|
this.isCadenzaDBReady,
|
|
9268
9242
|
"task",
|
|
9269
9243
|
{},
|
|
9270
9244
|
{ concurrency: 10 }
|
|
9271
9245
|
);
|
|
9272
|
-
const
|
|
9246
|
+
const authoritativeRoutineQueryGraph = resolveSyncQueryTask(
|
|
9273
9247
|
this.isCadenzaDBReady,
|
|
9274
9248
|
"routine",
|
|
9275
9249
|
{},
|
|
9276
9250
|
{ concurrency: 10 }
|
|
9277
9251
|
);
|
|
9278
|
-
const
|
|
9252
|
+
const authoritativeSignalQueryGraph = resolveSyncQueryTask(
|
|
9279
9253
|
this.isCadenzaDBReady,
|
|
9280
9254
|
"signal_registry",
|
|
9281
9255
|
{},
|
|
9282
9256
|
{ concurrency: 10 }
|
|
9283
9257
|
);
|
|
9284
|
-
const
|
|
9258
|
+
const authoritativeIntentQueryGraph = resolveSyncQueryTask(
|
|
9285
9259
|
this.isCadenzaDBReady,
|
|
9286
9260
|
"intent_registry",
|
|
9287
9261
|
{},
|
|
@@ -9452,32 +9426,30 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9452
9426
|
}
|
|
9453
9427
|
}.bind(this)
|
|
9454
9428
|
);
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
{
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
do: "nothing"
|
|
9464
|
-
}
|
|
9465
|
-
}
|
|
9466
|
-
},
|
|
9467
|
-
{ concurrency: 30 }
|
|
9468
|
-
)?.then(
|
|
9469
|
-
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
9470
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9471
|
-
return;
|
|
9429
|
+
const routineRegistrationGraph = resolveSyncInsertTask(
|
|
9430
|
+
this.isCadenzaDBReady,
|
|
9431
|
+
"routine",
|
|
9432
|
+
{
|
|
9433
|
+
onConflict: {
|
|
9434
|
+
target: ["name", "version", "service_name"],
|
|
9435
|
+
action: {
|
|
9436
|
+
do: "nothing"
|
|
9472
9437
|
}
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
9477
|
-
return true;
|
|
9478
|
-
}).then(gatherRoutineRegistrationTask)
|
|
9479
|
-
)
|
|
9438
|
+
}
|
|
9439
|
+
},
|
|
9440
|
+
{ concurrency: 30 }
|
|
9480
9441
|
);
|
|
9442
|
+
const registerRoutineTask = CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
9443
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9444
|
+
return;
|
|
9445
|
+
}
|
|
9446
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9447
|
+
delayMs: 3e3
|
|
9448
|
+
});
|
|
9449
|
+
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
9450
|
+
return true;
|
|
9451
|
+
}).then(gatherRoutineRegistrationTask);
|
|
9452
|
+
wireSyncTaskGraph(this.splitRoutinesTask, routineRegistrationGraph, registerRoutineTask);
|
|
9481
9453
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
9482
9454
|
"Split tasks in routines",
|
|
9483
9455
|
function* (ctx) {
|
|
@@ -9530,7 +9502,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9530
9502
|
}
|
|
9531
9503
|
}
|
|
9532
9504
|
);
|
|
9533
|
-
const
|
|
9505
|
+
const registerTaskToRoutineMapGraph = resolveSyncInsertTask(
|
|
9534
9506
|
this.isCadenzaDBReady,
|
|
9535
9507
|
"task_to_routine_map",
|
|
9536
9508
|
{
|
|
@@ -9548,8 +9520,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9548
9520
|
}
|
|
9549
9521
|
},
|
|
9550
9522
|
{ concurrency: 30 }
|
|
9551
|
-
)
|
|
9552
|
-
|
|
9523
|
+
);
|
|
9524
|
+
const registerTaskToRoutineMapTask = CadenzaService.createMetaTask(
|
|
9525
|
+
"Register routine task",
|
|
9526
|
+
(ctx) => {
|
|
9553
9527
|
if (!didSyncInsertSucceed(ctx)) {
|
|
9554
9528
|
return;
|
|
9555
9529
|
}
|
|
@@ -9559,11 +9533,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9559
9533
|
CadenzaService.getRoutine(ctx.__routineName).registeredTasks.add(
|
|
9560
9534
|
ctx.__taskName
|
|
9561
9535
|
);
|
|
9562
|
-
}
|
|
9536
|
+
}
|
|
9537
|
+
);
|
|
9538
|
+
wireSyncTaskGraph(
|
|
9539
|
+
this.splitTasksInRoutines,
|
|
9540
|
+
registerTaskToRoutineMapGraph,
|
|
9541
|
+
registerTaskToRoutineMapTask
|
|
9563
9542
|
);
|
|
9564
|
-
if (registerTaskToRoutineMapTask) {
|
|
9565
|
-
this.splitTasksInRoutines.then(registerTaskToRoutineMapTask);
|
|
9566
|
-
}
|
|
9567
9543
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
9568
9544
|
"Split signals for registration",
|
|
9569
9545
|
function* (ctx) {
|
|
@@ -9592,30 +9568,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9592
9568
|
}
|
|
9593
9569
|
}.bind(this)
|
|
9594
9570
|
);
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
{
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
do: "nothing"
|
|
9604
|
-
}
|
|
9605
|
-
}
|
|
9606
|
-
},
|
|
9607
|
-
{ concurrency: 30 }
|
|
9608
|
-
)?.then(
|
|
9609
|
-
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
9610
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9611
|
-
return;
|
|
9571
|
+
const signalRegistrationGraph = resolveSyncInsertTask(
|
|
9572
|
+
this.isCadenzaDBReady,
|
|
9573
|
+
"signal_registry",
|
|
9574
|
+
{
|
|
9575
|
+
onConflict: {
|
|
9576
|
+
target: ["name"],
|
|
9577
|
+
action: {
|
|
9578
|
+
do: "nothing"
|
|
9612
9579
|
}
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9580
|
+
}
|
|
9581
|
+
},
|
|
9582
|
+
{ concurrency: 30 }
|
|
9583
|
+
);
|
|
9584
|
+
const processSignalRegistrationTask = CadenzaService.createMetaTask(
|
|
9585
|
+
"Process signal registration",
|
|
9586
|
+
(ctx) => {
|
|
9587
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9588
|
+
return;
|
|
9589
|
+
}
|
|
9590
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9591
|
+
delayMs: 3e3
|
|
9592
|
+
});
|
|
9593
|
+
return { signalName: ctx.__signal };
|
|
9594
|
+
}
|
|
9595
|
+
).then(CadenzaService.signalBroker.registerSignalTask).then(gatherSignalRegistrationTask);
|
|
9596
|
+
wireSyncTaskGraph(
|
|
9597
|
+
this.splitSignalsTask,
|
|
9598
|
+
signalRegistrationGraph,
|
|
9599
|
+
processSignalRegistrationTask
|
|
9619
9600
|
);
|
|
9620
9601
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
9621
9602
|
"Split tasks for registration",
|
|
@@ -9684,7 +9665,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9684
9665
|
}
|
|
9685
9666
|
}.bind(this)
|
|
9686
9667
|
);
|
|
9687
|
-
const
|
|
9668
|
+
const registerTaskGraph = resolveSyncInsertTask(
|
|
9688
9669
|
this.isCadenzaDBReady,
|
|
9689
9670
|
"task",
|
|
9690
9671
|
{
|
|
@@ -9696,8 +9677,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9696
9677
|
}
|
|
9697
9678
|
},
|
|
9698
9679
|
{ concurrency: 30 }
|
|
9699
|
-
)
|
|
9700
|
-
|
|
9680
|
+
);
|
|
9681
|
+
const registerTaskTask = CadenzaService.createMetaTask(
|
|
9682
|
+
"Record registration",
|
|
9683
|
+
(ctx, emit) => {
|
|
9701
9684
|
if (shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
9702
9685
|
logSyncDebug("task_registration_result", {
|
|
9703
9686
|
taskName: ctx.__taskName,
|
|
@@ -9717,11 +9700,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9717
9700
|
task: CadenzaService.get(ctx.__taskName)
|
|
9718
9701
|
});
|
|
9719
9702
|
return true;
|
|
9720
|
-
}
|
|
9721
|
-
);
|
|
9722
|
-
|
|
9723
|
-
this.splitTasksForRegistration.then(registerTaskTask);
|
|
9724
|
-
}
|
|
9703
|
+
}
|
|
9704
|
+
).then(gatherTaskRegistrationTask);
|
|
9705
|
+
wireSyncTaskGraph(this.splitTasksForRegistration, registerTaskGraph, registerTaskTask);
|
|
9725
9706
|
CadenzaService.createMetaTask(
|
|
9726
9707
|
"Prepare created task for immediate sync",
|
|
9727
9708
|
(ctx) => {
|
|
@@ -9780,31 +9761,37 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9780
9761
|
};
|
|
9781
9762
|
}
|
|
9782
9763
|
}.bind(this)
|
|
9783
|
-
)
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
}
|
|
9793
|
-
}
|
|
9794
|
-
},
|
|
9795
|
-
{ concurrency: 30 }
|
|
9796
|
-
)?.then(
|
|
9797
|
-
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
9798
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9799
|
-
return;
|
|
9764
|
+
);
|
|
9765
|
+
const actorRegistrationGraph = resolveSyncInsertTask(
|
|
9766
|
+
this.isCadenzaDBReady,
|
|
9767
|
+
"actor",
|
|
9768
|
+
{
|
|
9769
|
+
onConflict: {
|
|
9770
|
+
target: ["name", "service_name", "version"],
|
|
9771
|
+
action: {
|
|
9772
|
+
do: "nothing"
|
|
9800
9773
|
}
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
)
|
|
9774
|
+
}
|
|
9775
|
+
},
|
|
9776
|
+
{ concurrency: 30 }
|
|
9777
|
+
);
|
|
9778
|
+
const recordActorRegistrationTask = CadenzaService.createMetaTask(
|
|
9779
|
+
"Record actor registration",
|
|
9780
|
+
(ctx) => {
|
|
9781
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9782
|
+
return;
|
|
9783
|
+
}
|
|
9784
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9785
|
+
delayMs: 3e3
|
|
9786
|
+
});
|
|
9787
|
+
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
9788
|
+
return true;
|
|
9789
|
+
}
|
|
9790
|
+
).then(gatherActorRegistrationTask);
|
|
9791
|
+
wireSyncTaskGraph(
|
|
9792
|
+
this.splitActorsForRegistration,
|
|
9793
|
+
actorRegistrationGraph,
|
|
9794
|
+
recordActorRegistrationTask
|
|
9808
9795
|
);
|
|
9809
9796
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
9810
9797
|
"Split actor task maps",
|
|
@@ -9842,36 +9829,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9842
9829
|
__actorTaskMapRegistrationKey: registrationKey
|
|
9843
9830
|
};
|
|
9844
9831
|
}.bind(this)
|
|
9845
|
-
)
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
}
|
|
9861
|
-
}
|
|
9862
|
-
},
|
|
9863
|
-
{ concurrency: 30 }
|
|
9864
|
-
)?.then(
|
|
9865
|
-
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
9866
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9867
|
-
return;
|
|
9832
|
+
);
|
|
9833
|
+
const actorTaskMapRegistrationGraph = resolveSyncInsertTask(
|
|
9834
|
+
this.isCadenzaDBReady,
|
|
9835
|
+
"actor_task_map",
|
|
9836
|
+
{
|
|
9837
|
+
onConflict: {
|
|
9838
|
+
target: [
|
|
9839
|
+
"actor_name",
|
|
9840
|
+
"actor_version",
|
|
9841
|
+
"task_name",
|
|
9842
|
+
"task_version",
|
|
9843
|
+
"service_name"
|
|
9844
|
+
],
|
|
9845
|
+
action: {
|
|
9846
|
+
do: "nothing"
|
|
9868
9847
|
}
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9848
|
+
}
|
|
9849
|
+
},
|
|
9850
|
+
{ concurrency: 30 }
|
|
9851
|
+
);
|
|
9852
|
+
const recordActorTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
9853
|
+
"Record actor task map registration",
|
|
9854
|
+
(ctx) => {
|
|
9855
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9856
|
+
return;
|
|
9857
|
+
}
|
|
9858
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9859
|
+
delayMs: 3e3
|
|
9860
|
+
});
|
|
9861
|
+
this.registeredActorTaskMaps.add(ctx.__actorTaskMapRegistrationKey);
|
|
9862
|
+
}
|
|
9863
|
+
);
|
|
9864
|
+
wireSyncTaskGraph(
|
|
9865
|
+
this.registerActorTaskMapTask,
|
|
9866
|
+
actorTaskMapRegistrationGraph,
|
|
9867
|
+
recordActorTaskMapRegistrationTask
|
|
9875
9868
|
);
|
|
9876
9869
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
9877
9870
|
"Record signal registration",
|
|
@@ -9930,25 +9923,32 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9930
9923
|
return emittedCount > 0;
|
|
9931
9924
|
}
|
|
9932
9925
|
);
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9926
|
+
const processSplitSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
9927
|
+
"Process split signal-to-task map",
|
|
9928
|
+
(ctx) => ctx
|
|
9929
|
+
).doOn("meta.sync_controller.signal_task_map_split");
|
|
9930
|
+
const signalToTaskMapGraph = resolveSyncInsertTask(
|
|
9931
|
+
this.isCadenzaDBReady,
|
|
9932
|
+
"signal_to_task_map",
|
|
9933
|
+
{
|
|
9934
|
+
onConflict: {
|
|
9935
|
+
target: [
|
|
9936
|
+
"task_name",
|
|
9937
|
+
"task_version",
|
|
9938
|
+
"service_name",
|
|
9939
|
+
"signal_name"
|
|
9940
|
+
],
|
|
9941
|
+
action: {
|
|
9942
|
+
do: "nothing"
|
|
9948
9943
|
}
|
|
9949
|
-
}
|
|
9950
|
-
|
|
9951
|
-
|
|
9944
|
+
}
|
|
9945
|
+
},
|
|
9946
|
+
{ concurrency: 30 }
|
|
9947
|
+
);
|
|
9948
|
+
wireSyncTaskGraph(
|
|
9949
|
+
processSplitSignalToTaskMapTask,
|
|
9950
|
+
signalToTaskMapGraph,
|
|
9951
|
+
registerSignalTask
|
|
9952
9952
|
);
|
|
9953
9953
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
9954
9954
|
"Split intents for registration",
|
|
@@ -9974,19 +9974,23 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9974
9974
|
}
|
|
9975
9975
|
}.bind(this)
|
|
9976
9976
|
);
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9977
|
+
const recordIntentDefinitionRegistrationTask = CadenzaService.createMetaTask(
|
|
9978
|
+
"Record intent definition registration",
|
|
9979
|
+
(ctx) => {
|
|
9980
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9981
|
+
return;
|
|
9982
|
+
}
|
|
9983
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9984
|
+
delayMs: 3e3
|
|
9985
|
+
});
|
|
9986
|
+
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
9987
|
+
return true;
|
|
9988
|
+
}
|
|
9989
|
+
).then(gatherIntentRegistrationTask);
|
|
9990
|
+
wireSyncTaskGraph(
|
|
9991
|
+
this.splitIntentsTask,
|
|
9992
|
+
insertIntentRegistryTask,
|
|
9993
|
+
recordIntentDefinitionRegistrationTask
|
|
9990
9994
|
);
|
|
9991
9995
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
9992
9996
|
"Record intent registration",
|
|
@@ -10068,67 +10072,82 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10068
10072
|
return true;
|
|
10069
10073
|
}.bind(this)
|
|
10070
10074
|
);
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10075
|
+
const processSplitIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
10076
|
+
"Process split intent-to-task map",
|
|
10077
|
+
(ctx) => ctx
|
|
10078
|
+
).doOn("meta.sync_controller.intent_task_map_split");
|
|
10079
|
+
const prepareIntentDefinitionForIntentMapTask = CadenzaService.createMetaTask(
|
|
10080
|
+
"Prepare intent definition for intent-to-task map",
|
|
10081
|
+
(ctx) => {
|
|
10082
|
+
if (!ctx.__intentDefinition || !ctx.__intentMapData) {
|
|
10083
|
+
return false;
|
|
10084
|
+
}
|
|
10085
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
10086
|
+
logSyncDebug("intent_definition_prepare", {
|
|
10087
|
+
taskName: ctx.__taskName,
|
|
10088
|
+
intentName: ctx.__intent,
|
|
10089
|
+
intentDefinition: ctx.__intentDefinition
|
|
10090
|
+
});
|
|
10091
|
+
}
|
|
10092
|
+
return {
|
|
10093
|
+
...ctx,
|
|
10094
|
+
data: ctx.__intentDefinition
|
|
10095
|
+
};
|
|
10096
|
+
}
|
|
10097
|
+
);
|
|
10098
|
+
const restoreIntentToTaskMapPayloadTask = CadenzaService.createMetaTask(
|
|
10099
|
+
"Restore intent-to-task map payload",
|
|
10100
|
+
(ctx) => {
|
|
10101
|
+
if (!ctx.__intentMapData) {
|
|
10102
|
+
return false;
|
|
10103
|
+
}
|
|
10104
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
10105
|
+
logSyncDebug("intent_map_payload_restore", {
|
|
10106
|
+
taskName: ctx.__taskName,
|
|
10107
|
+
intentName: ctx.__intent,
|
|
10108
|
+
intentMapData: ctx.__intentMapData
|
|
10109
|
+
});
|
|
10110
|
+
}
|
|
10111
|
+
return {
|
|
10112
|
+
...ctx,
|
|
10113
|
+
data: ctx.__intentMapData
|
|
10114
|
+
};
|
|
10115
|
+
}
|
|
10116
|
+
);
|
|
10117
|
+
const intentToTaskMapGraph = resolveSyncInsertTask(
|
|
10118
|
+
this.isCadenzaDBReady,
|
|
10119
|
+
"intent_to_task_map",
|
|
10120
|
+
{
|
|
10121
|
+
onConflict: {
|
|
10122
|
+
target: [
|
|
10123
|
+
"intent_name",
|
|
10124
|
+
"task_name",
|
|
10125
|
+
"task_version",
|
|
10126
|
+
"service_name"
|
|
10127
|
+
],
|
|
10128
|
+
action: {
|
|
10129
|
+
do: "nothing"
|
|
10084
10130
|
}
|
|
10085
|
-
return {
|
|
10086
|
-
...ctx,
|
|
10087
|
-
data: ctx.__intentDefinition
|
|
10088
|
-
};
|
|
10089
10131
|
}
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
}
|
|
10110
|
-
).then(
|
|
10111
|
-
resolveSyncInsertTask(
|
|
10112
|
-
this.isCadenzaDBReady,
|
|
10113
|
-
"intent_to_task_map",
|
|
10114
|
-
{
|
|
10115
|
-
onConflict: {
|
|
10116
|
-
target: [
|
|
10117
|
-
"intent_name",
|
|
10118
|
-
"task_name",
|
|
10119
|
-
"task_version",
|
|
10120
|
-
"service_name"
|
|
10121
|
-
],
|
|
10122
|
-
action: {
|
|
10123
|
-
do: "nothing"
|
|
10124
|
-
}
|
|
10125
|
-
}
|
|
10126
|
-
},
|
|
10127
|
-
{ concurrency: 30 }
|
|
10128
|
-
)?.then(registerIntentTask)
|
|
10129
|
-
)
|
|
10130
|
-
)
|
|
10131
|
-
)
|
|
10132
|
+
},
|
|
10133
|
+
{ concurrency: 30 }
|
|
10134
|
+
);
|
|
10135
|
+
processSplitIntentToTaskMapTask.then(prepareIntentDefinitionForIntentMapTask);
|
|
10136
|
+
if (ensureIntentRegistryBeforeIntentMapTask) {
|
|
10137
|
+
wireSyncTaskGraph(
|
|
10138
|
+
prepareIntentDefinitionForIntentMapTask,
|
|
10139
|
+
ensureIntentRegistryBeforeIntentMapTask,
|
|
10140
|
+
restoreIntentToTaskMapPayloadTask
|
|
10141
|
+
);
|
|
10142
|
+
} else {
|
|
10143
|
+
prepareIntentDefinitionForIntentMapTask.then(
|
|
10144
|
+
restoreIntentToTaskMapPayloadTask
|
|
10145
|
+
);
|
|
10146
|
+
}
|
|
10147
|
+
wireSyncTaskGraph(
|
|
10148
|
+
restoreIntentToTaskMapPayloadTask,
|
|
10149
|
+
intentToTaskMapGraph,
|
|
10150
|
+
registerIntentTask
|
|
10132
10151
|
);
|
|
10133
10152
|
this.registerTaskMapTask = CadenzaService.createMetaTask(
|
|
10134
10153
|
"Register task map to DB",
|
|
@@ -10164,39 +10183,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10164
10183
|
};
|
|
10165
10184
|
}
|
|
10166
10185
|
}
|
|
10167
|
-
)
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
}
|
|
10184
|
-
}
|
|
10185
|
-
},
|
|
10186
|
-
{ concurrency: 30 }
|
|
10187
|
-
)?.then(
|
|
10188
|
-
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
10189
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
10190
|
-
return;
|
|
10186
|
+
);
|
|
10187
|
+
const taskMapRegistrationGraph = resolveSyncInsertTask(
|
|
10188
|
+
this.isCadenzaDBReady,
|
|
10189
|
+
"directional_task_graph_map",
|
|
10190
|
+
{
|
|
10191
|
+
onConflict: {
|
|
10192
|
+
target: [
|
|
10193
|
+
"task_name",
|
|
10194
|
+
"predecessor_task_name",
|
|
10195
|
+
"task_version",
|
|
10196
|
+
"predecessor_task_version",
|
|
10197
|
+
"service_name",
|
|
10198
|
+
"predecessor_service_name"
|
|
10199
|
+
],
|
|
10200
|
+
action: {
|
|
10201
|
+
do: "nothing"
|
|
10191
10202
|
}
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10203
|
+
}
|
|
10204
|
+
},
|
|
10205
|
+
{ concurrency: 30 }
|
|
10206
|
+
);
|
|
10207
|
+
const recordTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
10208
|
+
"Record task map registration",
|
|
10209
|
+
(ctx) => {
|
|
10210
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
10211
|
+
return;
|
|
10212
|
+
}
|
|
10213
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
10214
|
+
delayMs: 3e3
|
|
10215
|
+
});
|
|
10216
|
+
CadenzaService.get(ctx.__taskName)?.taskMapRegistration.add(
|
|
10217
|
+
ctx.__nextTaskName
|
|
10218
|
+
);
|
|
10219
|
+
}
|
|
10220
|
+
);
|
|
10221
|
+
wireSyncTaskGraph(
|
|
10222
|
+
this.registerTaskMapTask,
|
|
10223
|
+
taskMapRegistrationGraph,
|
|
10224
|
+
recordTaskMapRegistrationTask
|
|
10200
10225
|
);
|
|
10201
10226
|
this.registerDeputyRelationshipTask = CadenzaService.createMetaTask(
|
|
10202
10227
|
"Register deputy relationship",
|
|
@@ -10223,40 +10248,43 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10223
10248
|
};
|
|
10224
10249
|
}
|
|
10225
10250
|
}
|
|
10226
|
-
)
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
}
|
|
10243
|
-
}
|
|
10244
|
-
},
|
|
10245
|
-
{ concurrency: 30 }
|
|
10246
|
-
)?.then(
|
|
10247
|
-
CadenzaService.createMetaTask(
|
|
10248
|
-
"Record deputy relationship registration",
|
|
10249
|
-
(ctx) => {
|
|
10250
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
10251
|
-
return;
|
|
10252
|
-
}
|
|
10253
|
-
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
10254
|
-
delayMs: 3e3
|
|
10255
|
-
});
|
|
10256
|
-
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
10251
|
+
);
|
|
10252
|
+
const deputyRelationshipRegistrationGraph = resolveSyncInsertTask(
|
|
10253
|
+
this.isCadenzaDBReady,
|
|
10254
|
+
"directional_task_graph_map",
|
|
10255
|
+
{
|
|
10256
|
+
onConflict: {
|
|
10257
|
+
target: [
|
|
10258
|
+
"task_name",
|
|
10259
|
+
"predecessor_task_name",
|
|
10260
|
+
"task_version",
|
|
10261
|
+
"predecessor_task_version",
|
|
10262
|
+
"service_name",
|
|
10263
|
+
"predecessor_service_name"
|
|
10264
|
+
],
|
|
10265
|
+
action: {
|
|
10266
|
+
do: "nothing"
|
|
10257
10267
|
}
|
|
10258
|
-
|
|
10259
|
-
|
|
10268
|
+
}
|
|
10269
|
+
},
|
|
10270
|
+
{ concurrency: 30 }
|
|
10271
|
+
);
|
|
10272
|
+
const recordDeputyRelationshipRegistrationTask = CadenzaService.createMetaTask(
|
|
10273
|
+
"Record deputy relationship registration",
|
|
10274
|
+
(ctx) => {
|
|
10275
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
10276
|
+
return;
|
|
10277
|
+
}
|
|
10278
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
10279
|
+
delayMs: 3e3
|
|
10280
|
+
});
|
|
10281
|
+
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
10282
|
+
}
|
|
10283
|
+
);
|
|
10284
|
+
wireSyncTaskGraph(
|
|
10285
|
+
this.registerDeputyRelationshipTask,
|
|
10286
|
+
deputyRelationshipRegistrationGraph,
|
|
10287
|
+
recordDeputyRelationshipRegistrationTask
|
|
10260
10288
|
);
|
|
10261
10289
|
const reconcileTaskRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
10262
10290
|
"Reconcile task registration from authority",
|
|
@@ -10388,7 +10416,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10388
10416
|
isHidden: true
|
|
10389
10417
|
}
|
|
10390
10418
|
);
|
|
10391
|
-
const
|
|
10419
|
+
const skipAuthoritativeTaskReconciliationTask = CadenzaService.createMetaTask(
|
|
10392
10420
|
"Skip authoritative task reconciliation",
|
|
10393
10421
|
() => false,
|
|
10394
10422
|
"Skips task reconciliation when no authority query task is available.",
|
|
@@ -10397,7 +10425,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10397
10425
|
isHidden: true
|
|
10398
10426
|
}
|
|
10399
10427
|
);
|
|
10400
|
-
const
|
|
10428
|
+
const skipAuthoritativeRoutineReconciliationTask = CadenzaService.createMetaTask(
|
|
10401
10429
|
"Skip authoritative routine reconciliation",
|
|
10402
10430
|
() => false,
|
|
10403
10431
|
"Skips routine reconciliation when no authority query task is available.",
|
|
@@ -10406,7 +10434,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10406
10434
|
isHidden: true
|
|
10407
10435
|
}
|
|
10408
10436
|
);
|
|
10409
|
-
const
|
|
10437
|
+
const skipAuthoritativeSignalReconciliationTask = CadenzaService.createMetaTask(
|
|
10410
10438
|
"Skip authoritative signal reconciliation",
|
|
10411
10439
|
() => false,
|
|
10412
10440
|
"Skips signal reconciliation when no authority query task is available.",
|
|
@@ -10415,7 +10443,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10415
10443
|
isHidden: true
|
|
10416
10444
|
}
|
|
10417
10445
|
);
|
|
10418
|
-
const
|
|
10446
|
+
const skipAuthoritativeIntentReconciliationTask = CadenzaService.createMetaTask(
|
|
10419
10447
|
"Skip authoritative intent reconciliation",
|
|
10420
10448
|
() => false,
|
|
10421
10449
|
"Skips intent reconciliation when no authority query task is available.",
|
|
@@ -10424,6 +10452,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10424
10452
|
isHidden: true
|
|
10425
10453
|
}
|
|
10426
10454
|
);
|
|
10455
|
+
if (authoritativeTaskQueryGraph) {
|
|
10456
|
+
authoritativeTaskQueryGraph.completionTask.then(
|
|
10457
|
+
reconcileTaskRegistrationFromAuthorityTask
|
|
10458
|
+
);
|
|
10459
|
+
}
|
|
10460
|
+
if (authoritativeRoutineQueryGraph) {
|
|
10461
|
+
authoritativeRoutineQueryGraph.completionTask.then(
|
|
10462
|
+
reconcileRoutineRegistrationFromAuthorityTask
|
|
10463
|
+
);
|
|
10464
|
+
}
|
|
10465
|
+
if (authoritativeSignalQueryGraph) {
|
|
10466
|
+
authoritativeSignalQueryGraph.completionTask.then(
|
|
10467
|
+
reconcileSignalRegistrationFromAuthorityTask
|
|
10468
|
+
);
|
|
10469
|
+
}
|
|
10470
|
+
if (authoritativeIntentQueryGraph) {
|
|
10471
|
+
authoritativeIntentQueryGraph.completionTask.then(
|
|
10472
|
+
reconcileIntentRegistrationFromAuthorityTask
|
|
10473
|
+
);
|
|
10474
|
+
}
|
|
10427
10475
|
const authoritativeRegistrationTriggers = [
|
|
10428
10476
|
"meta.service_registry.initial_sync_complete",
|
|
10429
10477
|
"meta.sync_requested",
|
|
@@ -10456,7 +10504,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10456
10504
|
register: false,
|
|
10457
10505
|
isHidden: true
|
|
10458
10506
|
}
|
|
10459
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10507
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10508
|
+
authoritativeTaskQueryGraph?.entryTask ?? skipAuthoritativeTaskReconciliationTask
|
|
10509
|
+
);
|
|
10460
10510
|
CadenzaService.createMetaTask(
|
|
10461
10511
|
"Prepare authoritative routine registration query",
|
|
10462
10512
|
(ctx) => {
|
|
@@ -10483,7 +10533,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10483
10533
|
register: false,
|
|
10484
10534
|
isHidden: true
|
|
10485
10535
|
}
|
|
10486
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10536
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10537
|
+
authoritativeRoutineQueryGraph?.entryTask ?? skipAuthoritativeRoutineReconciliationTask
|
|
10538
|
+
);
|
|
10487
10539
|
CadenzaService.createMetaTask(
|
|
10488
10540
|
"Prepare authoritative signal registration query",
|
|
10489
10541
|
(ctx) => {
|
|
@@ -10502,7 +10554,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10502
10554
|
register: false,
|
|
10503
10555
|
isHidden: true
|
|
10504
10556
|
}
|
|
10505
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10557
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10558
|
+
authoritativeSignalQueryGraph?.entryTask ?? skipAuthoritativeSignalReconciliationTask
|
|
10559
|
+
);
|
|
10506
10560
|
CadenzaService.createMetaTask(
|
|
10507
10561
|
"Prepare authoritative intent registration query",
|
|
10508
10562
|
(ctx) => {
|
|
@@ -10521,7 +10575,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10521
10575
|
register: false,
|
|
10522
10576
|
isHidden: true
|
|
10523
10577
|
}
|
|
10524
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10578
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10579
|
+
authoritativeIntentQueryGraph?.entryTask ?? skipAuthoritativeIntentReconciliationTask
|
|
10580
|
+
);
|
|
10525
10581
|
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
10526
10582
|
"meta.sync_controller.sync_tick",
|
|
10527
10583
|
"meta.service_registry.initial_sync_complete",
|
|
@@ -10956,7 +11012,7 @@ var CadenzaService = class {
|
|
|
10956
11012
|
).map((transport) => ({
|
|
10957
11013
|
...transport,
|
|
10958
11014
|
protocols: transport.protocols && transport.protocols.length > 0 ? transport.protocols : useSocket ? ["rest", "socket"] : ["rest"],
|
|
10959
|
-
uuid:
|
|
11015
|
+
uuid: uuid6()
|
|
10960
11016
|
}));
|
|
10961
11017
|
}
|
|
10962
11018
|
static createBootstrapTransport(serviceInstanceId, role, endpoint) {
|
|
@@ -11208,7 +11264,7 @@ var CadenzaService = class {
|
|
|
11208
11264
|
}
|
|
11209
11265
|
for (const responder of responders) {
|
|
11210
11266
|
const { task, descriptor } = responder;
|
|
11211
|
-
const inquiryId =
|
|
11267
|
+
const inquiryId = uuid6();
|
|
11212
11268
|
startTimeByTask.set(task, Date.now());
|
|
11213
11269
|
const resolverTask = this.createEphemeralMetaTask(
|
|
11214
11270
|
`Resolve inquiry ${inquiry} for ${descriptor.localTaskName}`,
|
|
@@ -11716,7 +11772,7 @@ var CadenzaService = class {
|
|
|
11716
11772
|
this.bootstrap();
|
|
11717
11773
|
this.validateName(serviceName);
|
|
11718
11774
|
this.validateServiceName(serviceName);
|
|
11719
|
-
const serviceId = options.customServiceId ??
|
|
11775
|
+
const serviceId = options.customServiceId ?? uuid6();
|
|
11720
11776
|
this.serviceRegistry.serviceName = serviceName;
|
|
11721
11777
|
this.serviceRegistry.serviceInstanceId = serviceId;
|
|
11722
11778
|
this.setHydrationResults(options.hydration);
|
|
@@ -12567,7 +12623,7 @@ import {
|
|
|
12567
12623
|
} from "@cadenza.io/core";
|
|
12568
12624
|
|
|
12569
12625
|
// src/ssr/createSSRInquiryBridge.ts
|
|
12570
|
-
import { v4 as
|
|
12626
|
+
import { v4 as uuid7 } from "uuid";
|
|
12571
12627
|
function ensureFetch() {
|
|
12572
12628
|
if (typeof globalThis.fetch !== "function") {
|
|
12573
12629
|
throw new Error("SSR inquiry bridge requires global fetch support.");
|
|
@@ -12656,7 +12712,7 @@ function createSSRInquiryBridge(options = {}) {
|
|
|
12656
12712
|
__remoteRoutineName: remoteRoutineName,
|
|
12657
12713
|
__metadata: {
|
|
12658
12714
|
...context.__metadata ?? {},
|
|
12659
|
-
__deputyExecId:
|
|
12715
|
+
__deputyExecId: uuid7()
|
|
12660
12716
|
}
|
|
12661
12717
|
}),
|
|
12662
12718
|
signal
|