@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.js
CHANGED
|
@@ -436,16 +436,16 @@ function normalizeServiceTransportConfig(value) {
|
|
|
436
436
|
}
|
|
437
437
|
function normalizeServiceTransportDescriptor(value) {
|
|
438
438
|
const raw = value ?? {};
|
|
439
|
-
const
|
|
439
|
+
const uuid8 = normalizeString(raw.uuid);
|
|
440
440
|
const serviceInstanceId = normalizeString(
|
|
441
441
|
raw.serviceInstanceId ?? raw.service_instance_id
|
|
442
442
|
);
|
|
443
443
|
const config = normalizeServiceTransportConfig(raw);
|
|
444
|
-
if (!
|
|
444
|
+
if (!uuid8 || !serviceInstanceId || !config) {
|
|
445
445
|
return null;
|
|
446
446
|
}
|
|
447
447
|
return {
|
|
448
|
-
uuid:
|
|
448
|
+
uuid: uuid8,
|
|
449
449
|
serviceInstanceId,
|
|
450
450
|
role: config.role,
|
|
451
451
|
origin: config.origin,
|
|
@@ -507,14 +507,14 @@ function normalizeTransportArray(value, serviceInstanceId) {
|
|
|
507
507
|
}
|
|
508
508
|
function normalizeServiceInstanceDescriptor(value) {
|
|
509
509
|
const raw = value ?? {};
|
|
510
|
-
const
|
|
510
|
+
const uuid8 = normalizeString2(raw.uuid);
|
|
511
511
|
const serviceName = normalizeString2(raw.serviceName ?? raw.service_name);
|
|
512
|
-
if (!
|
|
512
|
+
if (!uuid8 || !serviceName) {
|
|
513
513
|
return null;
|
|
514
514
|
}
|
|
515
|
-
const transports = normalizeTransportArray(raw.transports,
|
|
515
|
+
const transports = normalizeTransportArray(raw.transports, uuid8);
|
|
516
516
|
return {
|
|
517
|
-
uuid:
|
|
517
|
+
uuid: uuid8,
|
|
518
518
|
serviceName,
|
|
519
519
|
numberOfRunningGraphs: Math.max(
|
|
520
520
|
0,
|
|
@@ -1155,15 +1155,15 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1155
1155
|
if (!serviceInstance) {
|
|
1156
1156
|
return false;
|
|
1157
1157
|
}
|
|
1158
|
-
const
|
|
1158
|
+
const uuid8 = serviceInstance.uuid;
|
|
1159
1159
|
const serviceName = serviceInstance.serviceName;
|
|
1160
1160
|
const deleted = Boolean(
|
|
1161
1161
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
1162
1162
|
);
|
|
1163
|
-
if (
|
|
1163
|
+
if (uuid8 === this.serviceInstanceId) return;
|
|
1164
1164
|
if (deleted) {
|
|
1165
|
-
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid ===
|
|
1166
|
-
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid ===
|
|
1165
|
+
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid8);
|
|
1166
|
+
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid8) ?? -1;
|
|
1167
1167
|
if (indexToDelete >= 0 && existingInstance) {
|
|
1168
1168
|
this.instances.get(serviceName)?.splice(indexToDelete, 1);
|
|
1169
1169
|
for (const transport of existingInstance.transports) {
|
|
@@ -1175,13 +1175,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1175
1175
|
if (this.instances.get(serviceName)?.length === 0) {
|
|
1176
1176
|
this.instances.delete(serviceName);
|
|
1177
1177
|
}
|
|
1178
|
-
this.unregisterDependee(
|
|
1178
|
+
this.unregisterDependee(uuid8, serviceName);
|
|
1179
1179
|
return;
|
|
1180
1180
|
}
|
|
1181
1181
|
if (!this.instances.has(serviceName))
|
|
1182
1182
|
this.instances.set(serviceName, []);
|
|
1183
1183
|
const instances = this.instances.get(serviceName);
|
|
1184
|
-
const existing = instances.find((i) => i.uuid ===
|
|
1184
|
+
const existing = instances.find((i) => i.uuid === uuid8);
|
|
1185
1185
|
if (existing) {
|
|
1186
1186
|
Object.assign(existing, {
|
|
1187
1187
|
...serviceInstance,
|
|
@@ -1191,7 +1191,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1191
1191
|
} else {
|
|
1192
1192
|
instances.push(serviceInstance);
|
|
1193
1193
|
}
|
|
1194
|
-
const trackedInstance = existing ?? instances.find((instance) => instance.uuid ===
|
|
1194
|
+
const trackedInstance = existing ?? instances.find((instance) => instance.uuid === uuid8);
|
|
1195
1195
|
if (trackedInstance) {
|
|
1196
1196
|
const snapshot = this.resolveRuntimeStatusSnapshot(
|
|
1197
1197
|
trackedInstance.numberOfRunningGraphs ?? 0,
|
|
@@ -1204,7 +1204,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1204
1204
|
trackedInstance.reportedAt = trackedInstance.reportedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1205
1205
|
}
|
|
1206
1206
|
if (!serviceInstance.isBootstrapPlaceholder) {
|
|
1207
|
-
this.reconcileBootstrapPlaceholderInstance(serviceName,
|
|
1207
|
+
this.reconcileBootstrapPlaceholderInstance(serviceName, uuid8, emit);
|
|
1208
1208
|
}
|
|
1209
1209
|
if (this.serviceName === serviceName) {
|
|
1210
1210
|
return false;
|
|
@@ -1233,7 +1233,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1233
1233
|
if (!clientCreated) {
|
|
1234
1234
|
emit("meta.service_registry.dependee_registered", {
|
|
1235
1235
|
serviceName,
|
|
1236
|
-
serviceInstanceId:
|
|
1236
|
+
serviceInstanceId: uuid8,
|
|
1237
1237
|
serviceTransportId: trackedTransport.uuid,
|
|
1238
1238
|
serviceOrigin: trackedTransport.origin,
|
|
1239
1239
|
transportProtocols: trackedTransport.protocols,
|
|
@@ -1247,7 +1247,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1247
1247
|
} else {
|
|
1248
1248
|
emit("meta.service_registry.routeable_transport_missing", {
|
|
1249
1249
|
serviceName,
|
|
1250
|
-
serviceInstanceId:
|
|
1250
|
+
serviceInstanceId: uuid8,
|
|
1251
1251
|
requiredRole: this.getRoutingTransportRole(),
|
|
1252
1252
|
isFrontend: this.isFrontend
|
|
1253
1253
|
});
|
|
@@ -8667,11 +8667,10 @@ function tableFieldTypeToSchemaType(type) {
|
|
|
8667
8667
|
}
|
|
8668
8668
|
|
|
8669
8669
|
// src/Cadenza.ts
|
|
8670
|
-
var
|
|
8670
|
+
var import_uuid6 = require("uuid");
|
|
8671
8671
|
|
|
8672
8672
|
// src/graph/controllers/GraphSyncController.ts
|
|
8673
8673
|
var import_core4 = require("@cadenza.io/core");
|
|
8674
|
-
var import_uuid6 = require("uuid");
|
|
8675
8674
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
8676
8675
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
8677
8676
|
if (typeof taskFunction !== "function") {
|
|
@@ -8799,6 +8798,64 @@ function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
|
8799
8798
|
}
|
|
8800
8799
|
return nextQueryData;
|
|
8801
8800
|
}
|
|
8801
|
+
function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
8802
|
+
if (!graph) {
|
|
8803
|
+
return void 0;
|
|
8804
|
+
}
|
|
8805
|
+
predecessorTask.then(graph.entryTask);
|
|
8806
|
+
if (completionTasks.length > 0) {
|
|
8807
|
+
graph.completionTask.then(...completionTasks);
|
|
8808
|
+
}
|
|
8809
|
+
return graph.completionTask;
|
|
8810
|
+
}
|
|
8811
|
+
function resolveLocalDatabaseTaskIntent(task, operation, tableName) {
|
|
8812
|
+
if (!task) {
|
|
8813
|
+
return void 0;
|
|
8814
|
+
}
|
|
8815
|
+
const expectedPrefix = `${operation}-pg-`;
|
|
8816
|
+
const expectedSuffix = `-${tableName}`;
|
|
8817
|
+
const handledIntents = Array.from(task.handlesIntents ?? []);
|
|
8818
|
+
const directMatch = handledIntents.find(
|
|
8819
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix) && intent.endsWith(expectedSuffix)
|
|
8820
|
+
);
|
|
8821
|
+
if (directMatch) {
|
|
8822
|
+
return directMatch;
|
|
8823
|
+
}
|
|
8824
|
+
return handledIntents.find(
|
|
8825
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix)
|
|
8826
|
+
);
|
|
8827
|
+
}
|
|
8828
|
+
function createLocalDatabaseInquiryTask(localTask, operation, tableName, options = {}) {
|
|
8829
|
+
const intentName = resolveLocalDatabaseTaskIntent(localTask, operation, tableName);
|
|
8830
|
+
return CadenzaService.createMetaTask(
|
|
8831
|
+
`Execute local graph sync ${operation} for ${tableName}`,
|
|
8832
|
+
async (ctx, _emit, inquire) => {
|
|
8833
|
+
if (!intentName) {
|
|
8834
|
+
return {
|
|
8835
|
+
...ctx,
|
|
8836
|
+
errored: true,
|
|
8837
|
+
__success: false,
|
|
8838
|
+
__error: `No local ${operation} intent found for ${tableName}`
|
|
8839
|
+
};
|
|
8840
|
+
}
|
|
8841
|
+
const inquiryContext = {
|
|
8842
|
+
...ctx,
|
|
8843
|
+
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {}
|
|
8844
|
+
};
|
|
8845
|
+
const result = await inquire(intentName, inquiryContext, {});
|
|
8846
|
+
return {
|
|
8847
|
+
...ctx,
|
|
8848
|
+
...result
|
|
8849
|
+
};
|
|
8850
|
+
},
|
|
8851
|
+
`Executes the local ${tableName} ${operation} operation through the generated database intent.`,
|
|
8852
|
+
{
|
|
8853
|
+
...options,
|
|
8854
|
+
register: false,
|
|
8855
|
+
isHidden: true
|
|
8856
|
+
}
|
|
8857
|
+
);
|
|
8858
|
+
}
|
|
8802
8859
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
8803
8860
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
8804
8861
|
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
@@ -8806,7 +8863,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8806
8863
|
if (!localInsertTask && !remoteInsertTask) {
|
|
8807
8864
|
return void 0;
|
|
8808
8865
|
}
|
|
8809
|
-
const targetTask = localInsertTask
|
|
8866
|
+
const targetTask = localInsertTask ? createLocalDatabaseInquiryTask(localInsertTask, "insert", tableName, options) : remoteInsertTask;
|
|
8810
8867
|
if (debugTable) {
|
|
8811
8868
|
logSyncDebug("insert_task_resolved", {
|
|
8812
8869
|
tableName,
|
|
@@ -8817,21 +8874,14 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8817
8874
|
options
|
|
8818
8875
|
});
|
|
8819
8876
|
}
|
|
8820
|
-
const executionRequestedSignal = `meta.sync_controller.insert_execution_requested:${tableName}`;
|
|
8821
|
-
const executionResolvedSignal = `meta.sync_controller.insert_execution_resolved:${tableName}`;
|
|
8822
|
-
const executionFailedSignal = `meta.sync_controller.insert_execution_failed:${tableName}`;
|
|
8823
|
-
const pendingResolverContexts = /* @__PURE__ */ new Map();
|
|
8824
8877
|
const prepareExecutionTask = CadenzaService.createMetaTask(
|
|
8825
8878
|
`Prepare graph sync insert for ${tableName}`,
|
|
8826
8879
|
(ctx) => {
|
|
8827
8880
|
const originalContext = { ...ctx };
|
|
8828
|
-
const originalQueryData = buildSyncInsertQueryData(
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
originalQueryData
|
|
8833
|
-
});
|
|
8834
|
-
}
|
|
8881
|
+
const originalQueryData = buildSyncInsertQueryData(
|
|
8882
|
+
ctx,
|
|
8883
|
+
queryData
|
|
8884
|
+
);
|
|
8835
8885
|
return {
|
|
8836
8886
|
...ctx,
|
|
8837
8887
|
__resolverOriginalContext: originalContext,
|
|
@@ -8844,7 +8894,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8844
8894
|
register: false,
|
|
8845
8895
|
isHidden: true
|
|
8846
8896
|
}
|
|
8847
|
-
)
|
|
8897
|
+
);
|
|
8848
8898
|
if (debugTable) {
|
|
8849
8899
|
prepareExecutionTask.then(
|
|
8850
8900
|
CadenzaService.createMetaTask(
|
|
@@ -8878,15 +8928,9 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8878
8928
|
}
|
|
8879
8929
|
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
8880
8930
|
`Finalize graph sync insert for ${tableName}`,
|
|
8881
|
-
(ctx
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
}
|
|
8885
|
-
const pendingResolverContext = pendingResolverContexts.get(
|
|
8886
|
-
ctx.__resolverRequestId
|
|
8887
|
-
);
|
|
8888
|
-
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : pendingResolverContext?.originalContext ? { ...pendingResolverContext.originalContext } : {};
|
|
8889
|
-
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : pendingResolverContext?.originalQueryData;
|
|
8931
|
+
(ctx) => {
|
|
8932
|
+
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : {};
|
|
8933
|
+
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : void 0;
|
|
8890
8934
|
const normalizedContext = {
|
|
8891
8935
|
...originalContext,
|
|
8892
8936
|
...ctx,
|
|
@@ -8911,8 +8955,6 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8911
8955
|
});
|
|
8912
8956
|
}
|
|
8913
8957
|
}
|
|
8914
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
8915
|
-
emit(executionResolvedSignal, normalizedContext);
|
|
8916
8958
|
return normalizedContext;
|
|
8917
8959
|
},
|
|
8918
8960
|
`Finalizes ${tableName} graph-sync insert execution after the authority task finishes.`,
|
|
@@ -8921,95 +8963,12 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8921
8963
|
isHidden: true
|
|
8922
8964
|
}
|
|
8923
8965
|
);
|
|
8924
|
-
targetTask.then(finalizeExecutionTask).emitsOnFail(executionFailedSignal);
|
|
8925
8966
|
prepareExecutionTask.then(targetTask);
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
if (shouldDebugTaskSyncPayload(ctx) || shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
8932
|
-
logSyncDebug("insert_failed", {
|
|
8933
|
-
tableName,
|
|
8934
|
-
targetTaskName: targetTask.name,
|
|
8935
|
-
payload: buildTaskSyncDebugPayload({
|
|
8936
|
-
...ctx,
|
|
8937
|
-
__taskName: ctx.__taskName
|
|
8938
|
-
})
|
|
8939
|
-
});
|
|
8940
|
-
}
|
|
8941
|
-
} else {
|
|
8942
|
-
logSyncDebug("insert_failed", {
|
|
8943
|
-
tableName,
|
|
8944
|
-
targetTaskName: targetTask.name,
|
|
8945
|
-
ctx
|
|
8946
|
-
});
|
|
8947
|
-
}
|
|
8948
|
-
if (typeof ctx.__resolverRequestId === "string") {
|
|
8949
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
8950
|
-
}
|
|
8951
|
-
return false;
|
|
8952
|
-
},
|
|
8953
|
-
`Logs failed ${tableName} sync insert executions.`,
|
|
8954
|
-
{
|
|
8955
|
-
register: false,
|
|
8956
|
-
isHidden: true
|
|
8957
|
-
}
|
|
8958
|
-
).doOn(executionFailedSignal);
|
|
8959
|
-
}
|
|
8960
|
-
return CadenzaService.createMetaTask(
|
|
8961
|
-
`Resolve graph sync insert for ${tableName}`,
|
|
8962
|
-
(ctx, emit) => new Promise((resolve) => {
|
|
8963
|
-
const resolverRequestId = (0, import_uuid6.v4)();
|
|
8964
|
-
const resolvedContext = {
|
|
8965
|
-
...ctx,
|
|
8966
|
-
__resolverRequestId: resolverRequestId
|
|
8967
|
-
};
|
|
8968
|
-
if (debugTable) {
|
|
8969
|
-
if (tableName === "task") {
|
|
8970
|
-
if (shouldDebugTaskSyncPayload(resolvedContext)) {
|
|
8971
|
-
logSyncDebug("insert_resolver_request", {
|
|
8972
|
-
tableName,
|
|
8973
|
-
targetTaskName: targetTask.name,
|
|
8974
|
-
payload: buildTaskSyncDebugPayload(resolvedContext)
|
|
8975
|
-
});
|
|
8976
|
-
}
|
|
8977
|
-
} else {
|
|
8978
|
-
logSyncDebug("insert_resolver_request", {
|
|
8979
|
-
tableName,
|
|
8980
|
-
targetTaskName: targetTask.name,
|
|
8981
|
-
ctx: resolvedContext
|
|
8982
|
-
});
|
|
8983
|
-
}
|
|
8984
|
-
}
|
|
8985
|
-
CadenzaService.createEphemeralMetaTask(
|
|
8986
|
-
`Resolve graph sync insert execution for ${tableName} (${resolverRequestId})`,
|
|
8987
|
-
(resultCtx) => {
|
|
8988
|
-
if (resultCtx.__resolverRequestId !== resolverRequestId) {
|
|
8989
|
-
return false;
|
|
8990
|
-
}
|
|
8991
|
-
const normalizedResult = {
|
|
8992
|
-
...resultCtx
|
|
8993
|
-
};
|
|
8994
|
-
delete normalizedResult.__resolverRequestId;
|
|
8995
|
-
pendingResolverContexts.delete(resolverRequestId);
|
|
8996
|
-
resolve(normalizedResult);
|
|
8997
|
-
return normalizedResult;
|
|
8998
|
-
},
|
|
8999
|
-
`Waits for ${tableName} graph-sync insert execution.`,
|
|
9000
|
-
{
|
|
9001
|
-
register: false
|
|
9002
|
-
}
|
|
9003
|
-
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
9004
|
-
emit(executionRequestedSignal, resolvedContext);
|
|
9005
|
-
}),
|
|
9006
|
-
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
9007
|
-
{
|
|
9008
|
-
...options,
|
|
9009
|
-
register: false,
|
|
9010
|
-
isHidden: true
|
|
9011
|
-
}
|
|
9012
|
-
);
|
|
8967
|
+
targetTask.then(finalizeExecutionTask);
|
|
8968
|
+
return {
|
|
8969
|
+
entryTask: prepareExecutionTask,
|
|
8970
|
+
completionTask: finalizeExecutionTask
|
|
8971
|
+
};
|
|
9013
8972
|
}
|
|
9014
8973
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
9015
8974
|
"intent_registry",
|
|
@@ -9170,8 +9129,8 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
9170
9129
|
if (!localQueryTask && !remoteQueryTask) {
|
|
9171
9130
|
return void 0;
|
|
9172
9131
|
}
|
|
9173
|
-
const targetTask = localQueryTask
|
|
9174
|
-
|
|
9132
|
+
const targetTask = localQueryTask ? createLocalDatabaseInquiryTask(localQueryTask, "query", tableName, options) : remoteQueryTask;
|
|
9133
|
+
const prepareQueryTask = CadenzaService.createMetaTask(
|
|
9175
9134
|
`Prepare graph sync query for ${tableName}`,
|
|
9176
9135
|
(ctx) => ({
|
|
9177
9136
|
...ctx,
|
|
@@ -9185,7 +9144,22 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
9185
9144
|
register: false,
|
|
9186
9145
|
isHidden: true
|
|
9187
9146
|
}
|
|
9188
|
-
)
|
|
9147
|
+
);
|
|
9148
|
+
const finalizeQueryTask = CadenzaService.createMetaTask(
|
|
9149
|
+
`Finalize graph sync query for ${tableName}`,
|
|
9150
|
+
(ctx) => ctx,
|
|
9151
|
+
`Finalizes ${tableName} graph-sync query payloads after authority lookup.`,
|
|
9152
|
+
{
|
|
9153
|
+
register: false,
|
|
9154
|
+
isHidden: true
|
|
9155
|
+
}
|
|
9156
|
+
);
|
|
9157
|
+
prepareQueryTask.then(targetTask);
|
|
9158
|
+
targetTask.then(finalizeQueryTask);
|
|
9159
|
+
return {
|
|
9160
|
+
entryTask: prepareQueryTask,
|
|
9161
|
+
completionTask: finalizeQueryTask
|
|
9162
|
+
};
|
|
9189
9163
|
}
|
|
9190
9164
|
function getRegistrableTasks() {
|
|
9191
9165
|
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
@@ -9312,25 +9286,25 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9312
9286
|
},
|
|
9313
9287
|
{ concurrency: 30 }
|
|
9314
9288
|
);
|
|
9315
|
-
const
|
|
9289
|
+
const authoritativeTaskQueryGraph = resolveSyncQueryTask(
|
|
9316
9290
|
this.isCadenzaDBReady,
|
|
9317
9291
|
"task",
|
|
9318
9292
|
{},
|
|
9319
9293
|
{ concurrency: 10 }
|
|
9320
9294
|
);
|
|
9321
|
-
const
|
|
9295
|
+
const authoritativeRoutineQueryGraph = resolveSyncQueryTask(
|
|
9322
9296
|
this.isCadenzaDBReady,
|
|
9323
9297
|
"routine",
|
|
9324
9298
|
{},
|
|
9325
9299
|
{ concurrency: 10 }
|
|
9326
9300
|
);
|
|
9327
|
-
const
|
|
9301
|
+
const authoritativeSignalQueryGraph = resolveSyncQueryTask(
|
|
9328
9302
|
this.isCadenzaDBReady,
|
|
9329
9303
|
"signal_registry",
|
|
9330
9304
|
{},
|
|
9331
9305
|
{ concurrency: 10 }
|
|
9332
9306
|
);
|
|
9333
|
-
const
|
|
9307
|
+
const authoritativeIntentQueryGraph = resolveSyncQueryTask(
|
|
9334
9308
|
this.isCadenzaDBReady,
|
|
9335
9309
|
"intent_registry",
|
|
9336
9310
|
{},
|
|
@@ -9501,32 +9475,30 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9501
9475
|
}
|
|
9502
9476
|
}.bind(this)
|
|
9503
9477
|
);
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
{
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
do: "nothing"
|
|
9513
|
-
}
|
|
9514
|
-
}
|
|
9515
|
-
},
|
|
9516
|
-
{ concurrency: 30 }
|
|
9517
|
-
)?.then(
|
|
9518
|
-
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
9519
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9520
|
-
return;
|
|
9478
|
+
const routineRegistrationGraph = resolveSyncInsertTask(
|
|
9479
|
+
this.isCadenzaDBReady,
|
|
9480
|
+
"routine",
|
|
9481
|
+
{
|
|
9482
|
+
onConflict: {
|
|
9483
|
+
target: ["name", "version", "service_name"],
|
|
9484
|
+
action: {
|
|
9485
|
+
do: "nothing"
|
|
9521
9486
|
}
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
9526
|
-
return true;
|
|
9527
|
-
}).then(gatherRoutineRegistrationTask)
|
|
9528
|
-
)
|
|
9487
|
+
}
|
|
9488
|
+
},
|
|
9489
|
+
{ concurrency: 30 }
|
|
9529
9490
|
);
|
|
9491
|
+
const registerRoutineTask = CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
9492
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9493
|
+
return;
|
|
9494
|
+
}
|
|
9495
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9496
|
+
delayMs: 3e3
|
|
9497
|
+
});
|
|
9498
|
+
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
9499
|
+
return true;
|
|
9500
|
+
}).then(gatherRoutineRegistrationTask);
|
|
9501
|
+
wireSyncTaskGraph(this.splitRoutinesTask, routineRegistrationGraph, registerRoutineTask);
|
|
9530
9502
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
9531
9503
|
"Split tasks in routines",
|
|
9532
9504
|
function* (ctx) {
|
|
@@ -9579,7 +9551,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9579
9551
|
}
|
|
9580
9552
|
}
|
|
9581
9553
|
);
|
|
9582
|
-
const
|
|
9554
|
+
const registerTaskToRoutineMapGraph = resolveSyncInsertTask(
|
|
9583
9555
|
this.isCadenzaDBReady,
|
|
9584
9556
|
"task_to_routine_map",
|
|
9585
9557
|
{
|
|
@@ -9597,8 +9569,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9597
9569
|
}
|
|
9598
9570
|
},
|
|
9599
9571
|
{ concurrency: 30 }
|
|
9600
|
-
)
|
|
9601
|
-
|
|
9572
|
+
);
|
|
9573
|
+
const registerTaskToRoutineMapTask = CadenzaService.createMetaTask(
|
|
9574
|
+
"Register routine task",
|
|
9575
|
+
(ctx) => {
|
|
9602
9576
|
if (!didSyncInsertSucceed(ctx)) {
|
|
9603
9577
|
return;
|
|
9604
9578
|
}
|
|
@@ -9608,11 +9582,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9608
9582
|
CadenzaService.getRoutine(ctx.__routineName).registeredTasks.add(
|
|
9609
9583
|
ctx.__taskName
|
|
9610
9584
|
);
|
|
9611
|
-
}
|
|
9585
|
+
}
|
|
9586
|
+
);
|
|
9587
|
+
wireSyncTaskGraph(
|
|
9588
|
+
this.splitTasksInRoutines,
|
|
9589
|
+
registerTaskToRoutineMapGraph,
|
|
9590
|
+
registerTaskToRoutineMapTask
|
|
9612
9591
|
);
|
|
9613
|
-
if (registerTaskToRoutineMapTask) {
|
|
9614
|
-
this.splitTasksInRoutines.then(registerTaskToRoutineMapTask);
|
|
9615
|
-
}
|
|
9616
9592
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
9617
9593
|
"Split signals for registration",
|
|
9618
9594
|
function* (ctx) {
|
|
@@ -9641,30 +9617,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9641
9617
|
}
|
|
9642
9618
|
}.bind(this)
|
|
9643
9619
|
);
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
{
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
do: "nothing"
|
|
9653
|
-
}
|
|
9654
|
-
}
|
|
9655
|
-
},
|
|
9656
|
-
{ concurrency: 30 }
|
|
9657
|
-
)?.then(
|
|
9658
|
-
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
9659
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9660
|
-
return;
|
|
9620
|
+
const signalRegistrationGraph = resolveSyncInsertTask(
|
|
9621
|
+
this.isCadenzaDBReady,
|
|
9622
|
+
"signal_registry",
|
|
9623
|
+
{
|
|
9624
|
+
onConflict: {
|
|
9625
|
+
target: ["name"],
|
|
9626
|
+
action: {
|
|
9627
|
+
do: "nothing"
|
|
9661
9628
|
}
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9629
|
+
}
|
|
9630
|
+
},
|
|
9631
|
+
{ concurrency: 30 }
|
|
9632
|
+
);
|
|
9633
|
+
const processSignalRegistrationTask = CadenzaService.createMetaTask(
|
|
9634
|
+
"Process signal registration",
|
|
9635
|
+
(ctx) => {
|
|
9636
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9637
|
+
return;
|
|
9638
|
+
}
|
|
9639
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9640
|
+
delayMs: 3e3
|
|
9641
|
+
});
|
|
9642
|
+
return { signalName: ctx.__signal };
|
|
9643
|
+
}
|
|
9644
|
+
).then(CadenzaService.signalBroker.registerSignalTask).then(gatherSignalRegistrationTask);
|
|
9645
|
+
wireSyncTaskGraph(
|
|
9646
|
+
this.splitSignalsTask,
|
|
9647
|
+
signalRegistrationGraph,
|
|
9648
|
+
processSignalRegistrationTask
|
|
9668
9649
|
);
|
|
9669
9650
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
9670
9651
|
"Split tasks for registration",
|
|
@@ -9733,7 +9714,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9733
9714
|
}
|
|
9734
9715
|
}.bind(this)
|
|
9735
9716
|
);
|
|
9736
|
-
const
|
|
9717
|
+
const registerTaskGraph = resolveSyncInsertTask(
|
|
9737
9718
|
this.isCadenzaDBReady,
|
|
9738
9719
|
"task",
|
|
9739
9720
|
{
|
|
@@ -9745,8 +9726,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9745
9726
|
}
|
|
9746
9727
|
},
|
|
9747
9728
|
{ concurrency: 30 }
|
|
9748
|
-
)
|
|
9749
|
-
|
|
9729
|
+
);
|
|
9730
|
+
const registerTaskTask = CadenzaService.createMetaTask(
|
|
9731
|
+
"Record registration",
|
|
9732
|
+
(ctx, emit) => {
|
|
9750
9733
|
if (shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
9751
9734
|
logSyncDebug("task_registration_result", {
|
|
9752
9735
|
taskName: ctx.__taskName,
|
|
@@ -9766,11 +9749,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9766
9749
|
task: CadenzaService.get(ctx.__taskName)
|
|
9767
9750
|
});
|
|
9768
9751
|
return true;
|
|
9769
|
-
}
|
|
9770
|
-
);
|
|
9771
|
-
|
|
9772
|
-
this.splitTasksForRegistration.then(registerTaskTask);
|
|
9773
|
-
}
|
|
9752
|
+
}
|
|
9753
|
+
).then(gatherTaskRegistrationTask);
|
|
9754
|
+
wireSyncTaskGraph(this.splitTasksForRegistration, registerTaskGraph, registerTaskTask);
|
|
9774
9755
|
CadenzaService.createMetaTask(
|
|
9775
9756
|
"Prepare created task for immediate sync",
|
|
9776
9757
|
(ctx) => {
|
|
@@ -9829,31 +9810,37 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9829
9810
|
};
|
|
9830
9811
|
}
|
|
9831
9812
|
}.bind(this)
|
|
9832
|
-
)
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
}
|
|
9842
|
-
}
|
|
9843
|
-
},
|
|
9844
|
-
{ concurrency: 30 }
|
|
9845
|
-
)?.then(
|
|
9846
|
-
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
9847
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9848
|
-
return;
|
|
9813
|
+
);
|
|
9814
|
+
const actorRegistrationGraph = resolveSyncInsertTask(
|
|
9815
|
+
this.isCadenzaDBReady,
|
|
9816
|
+
"actor",
|
|
9817
|
+
{
|
|
9818
|
+
onConflict: {
|
|
9819
|
+
target: ["name", "service_name", "version"],
|
|
9820
|
+
action: {
|
|
9821
|
+
do: "nothing"
|
|
9849
9822
|
}
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
)
|
|
9823
|
+
}
|
|
9824
|
+
},
|
|
9825
|
+
{ concurrency: 30 }
|
|
9826
|
+
);
|
|
9827
|
+
const recordActorRegistrationTask = CadenzaService.createMetaTask(
|
|
9828
|
+
"Record actor registration",
|
|
9829
|
+
(ctx) => {
|
|
9830
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9831
|
+
return;
|
|
9832
|
+
}
|
|
9833
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9834
|
+
delayMs: 3e3
|
|
9835
|
+
});
|
|
9836
|
+
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
9837
|
+
return true;
|
|
9838
|
+
}
|
|
9839
|
+
).then(gatherActorRegistrationTask);
|
|
9840
|
+
wireSyncTaskGraph(
|
|
9841
|
+
this.splitActorsForRegistration,
|
|
9842
|
+
actorRegistrationGraph,
|
|
9843
|
+
recordActorRegistrationTask
|
|
9857
9844
|
);
|
|
9858
9845
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
9859
9846
|
"Split actor task maps",
|
|
@@ -9891,36 +9878,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9891
9878
|
__actorTaskMapRegistrationKey: registrationKey
|
|
9892
9879
|
};
|
|
9893
9880
|
}.bind(this)
|
|
9894
|
-
)
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
}
|
|
9910
|
-
}
|
|
9911
|
-
},
|
|
9912
|
-
{ concurrency: 30 }
|
|
9913
|
-
)?.then(
|
|
9914
|
-
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
9915
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
9916
|
-
return;
|
|
9881
|
+
);
|
|
9882
|
+
const actorTaskMapRegistrationGraph = resolveSyncInsertTask(
|
|
9883
|
+
this.isCadenzaDBReady,
|
|
9884
|
+
"actor_task_map",
|
|
9885
|
+
{
|
|
9886
|
+
onConflict: {
|
|
9887
|
+
target: [
|
|
9888
|
+
"actor_name",
|
|
9889
|
+
"actor_version",
|
|
9890
|
+
"task_name",
|
|
9891
|
+
"task_version",
|
|
9892
|
+
"service_name"
|
|
9893
|
+
],
|
|
9894
|
+
action: {
|
|
9895
|
+
do: "nothing"
|
|
9917
9896
|
}
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9897
|
+
}
|
|
9898
|
+
},
|
|
9899
|
+
{ concurrency: 30 }
|
|
9900
|
+
);
|
|
9901
|
+
const recordActorTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
9902
|
+
"Record actor task map registration",
|
|
9903
|
+
(ctx) => {
|
|
9904
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
9905
|
+
return;
|
|
9906
|
+
}
|
|
9907
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
9908
|
+
delayMs: 3e3
|
|
9909
|
+
});
|
|
9910
|
+
this.registeredActorTaskMaps.add(ctx.__actorTaskMapRegistrationKey);
|
|
9911
|
+
}
|
|
9912
|
+
);
|
|
9913
|
+
wireSyncTaskGraph(
|
|
9914
|
+
this.registerActorTaskMapTask,
|
|
9915
|
+
actorTaskMapRegistrationGraph,
|
|
9916
|
+
recordActorTaskMapRegistrationTask
|
|
9924
9917
|
);
|
|
9925
9918
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
9926
9919
|
"Record signal registration",
|
|
@@ -9979,25 +9972,32 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
9979
9972
|
return emittedCount > 0;
|
|
9980
9973
|
}
|
|
9981
9974
|
);
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9975
|
+
const processSplitSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
9976
|
+
"Process split signal-to-task map",
|
|
9977
|
+
(ctx) => ctx
|
|
9978
|
+
).doOn("meta.sync_controller.signal_task_map_split");
|
|
9979
|
+
const signalToTaskMapGraph = resolveSyncInsertTask(
|
|
9980
|
+
this.isCadenzaDBReady,
|
|
9981
|
+
"signal_to_task_map",
|
|
9982
|
+
{
|
|
9983
|
+
onConflict: {
|
|
9984
|
+
target: [
|
|
9985
|
+
"task_name",
|
|
9986
|
+
"task_version",
|
|
9987
|
+
"service_name",
|
|
9988
|
+
"signal_name"
|
|
9989
|
+
],
|
|
9990
|
+
action: {
|
|
9991
|
+
do: "nothing"
|
|
9997
9992
|
}
|
|
9998
|
-
}
|
|
9999
|
-
|
|
10000
|
-
|
|
9993
|
+
}
|
|
9994
|
+
},
|
|
9995
|
+
{ concurrency: 30 }
|
|
9996
|
+
);
|
|
9997
|
+
wireSyncTaskGraph(
|
|
9998
|
+
processSplitSignalToTaskMapTask,
|
|
9999
|
+
signalToTaskMapGraph,
|
|
10000
|
+
registerSignalTask
|
|
10001
10001
|
);
|
|
10002
10002
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
10003
10003
|
"Split intents for registration",
|
|
@@ -10023,19 +10023,23 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10023
10023
|
}
|
|
10024
10024
|
}.bind(this)
|
|
10025
10025
|
);
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10026
|
+
const recordIntentDefinitionRegistrationTask = CadenzaService.createMetaTask(
|
|
10027
|
+
"Record intent definition registration",
|
|
10028
|
+
(ctx) => {
|
|
10029
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
10030
|
+
return;
|
|
10031
|
+
}
|
|
10032
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
10033
|
+
delayMs: 3e3
|
|
10034
|
+
});
|
|
10035
|
+
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
10036
|
+
return true;
|
|
10037
|
+
}
|
|
10038
|
+
).then(gatherIntentRegistrationTask);
|
|
10039
|
+
wireSyncTaskGraph(
|
|
10040
|
+
this.splitIntentsTask,
|
|
10041
|
+
insertIntentRegistryTask,
|
|
10042
|
+
recordIntentDefinitionRegistrationTask
|
|
10039
10043
|
);
|
|
10040
10044
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
10041
10045
|
"Record intent registration",
|
|
@@ -10117,67 +10121,82 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10117
10121
|
return true;
|
|
10118
10122
|
}.bind(this)
|
|
10119
10123
|
);
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10124
|
+
const processSplitIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
10125
|
+
"Process split intent-to-task map",
|
|
10126
|
+
(ctx) => ctx
|
|
10127
|
+
).doOn("meta.sync_controller.intent_task_map_split");
|
|
10128
|
+
const prepareIntentDefinitionForIntentMapTask = CadenzaService.createMetaTask(
|
|
10129
|
+
"Prepare intent definition for intent-to-task map",
|
|
10130
|
+
(ctx) => {
|
|
10131
|
+
if (!ctx.__intentDefinition || !ctx.__intentMapData) {
|
|
10132
|
+
return false;
|
|
10133
|
+
}
|
|
10134
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
10135
|
+
logSyncDebug("intent_definition_prepare", {
|
|
10136
|
+
taskName: ctx.__taskName,
|
|
10137
|
+
intentName: ctx.__intent,
|
|
10138
|
+
intentDefinition: ctx.__intentDefinition
|
|
10139
|
+
});
|
|
10140
|
+
}
|
|
10141
|
+
return {
|
|
10142
|
+
...ctx,
|
|
10143
|
+
data: ctx.__intentDefinition
|
|
10144
|
+
};
|
|
10145
|
+
}
|
|
10146
|
+
);
|
|
10147
|
+
const restoreIntentToTaskMapPayloadTask = CadenzaService.createMetaTask(
|
|
10148
|
+
"Restore intent-to-task map payload",
|
|
10149
|
+
(ctx) => {
|
|
10150
|
+
if (!ctx.__intentMapData) {
|
|
10151
|
+
return false;
|
|
10152
|
+
}
|
|
10153
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
10154
|
+
logSyncDebug("intent_map_payload_restore", {
|
|
10155
|
+
taskName: ctx.__taskName,
|
|
10156
|
+
intentName: ctx.__intent,
|
|
10157
|
+
intentMapData: ctx.__intentMapData
|
|
10158
|
+
});
|
|
10159
|
+
}
|
|
10160
|
+
return {
|
|
10161
|
+
...ctx,
|
|
10162
|
+
data: ctx.__intentMapData
|
|
10163
|
+
};
|
|
10164
|
+
}
|
|
10165
|
+
);
|
|
10166
|
+
const intentToTaskMapGraph = resolveSyncInsertTask(
|
|
10167
|
+
this.isCadenzaDBReady,
|
|
10168
|
+
"intent_to_task_map",
|
|
10169
|
+
{
|
|
10170
|
+
onConflict: {
|
|
10171
|
+
target: [
|
|
10172
|
+
"intent_name",
|
|
10173
|
+
"task_name",
|
|
10174
|
+
"task_version",
|
|
10175
|
+
"service_name"
|
|
10176
|
+
],
|
|
10177
|
+
action: {
|
|
10178
|
+
do: "nothing"
|
|
10133
10179
|
}
|
|
10134
|
-
return {
|
|
10135
|
-
...ctx,
|
|
10136
|
-
data: ctx.__intentDefinition
|
|
10137
|
-
};
|
|
10138
10180
|
}
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
}
|
|
10159
|
-
).then(
|
|
10160
|
-
resolveSyncInsertTask(
|
|
10161
|
-
this.isCadenzaDBReady,
|
|
10162
|
-
"intent_to_task_map",
|
|
10163
|
-
{
|
|
10164
|
-
onConflict: {
|
|
10165
|
-
target: [
|
|
10166
|
-
"intent_name",
|
|
10167
|
-
"task_name",
|
|
10168
|
-
"task_version",
|
|
10169
|
-
"service_name"
|
|
10170
|
-
],
|
|
10171
|
-
action: {
|
|
10172
|
-
do: "nothing"
|
|
10173
|
-
}
|
|
10174
|
-
}
|
|
10175
|
-
},
|
|
10176
|
-
{ concurrency: 30 }
|
|
10177
|
-
)?.then(registerIntentTask)
|
|
10178
|
-
)
|
|
10179
|
-
)
|
|
10180
|
-
)
|
|
10181
|
+
},
|
|
10182
|
+
{ concurrency: 30 }
|
|
10183
|
+
);
|
|
10184
|
+
processSplitIntentToTaskMapTask.then(prepareIntentDefinitionForIntentMapTask);
|
|
10185
|
+
if (ensureIntentRegistryBeforeIntentMapTask) {
|
|
10186
|
+
wireSyncTaskGraph(
|
|
10187
|
+
prepareIntentDefinitionForIntentMapTask,
|
|
10188
|
+
ensureIntentRegistryBeforeIntentMapTask,
|
|
10189
|
+
restoreIntentToTaskMapPayloadTask
|
|
10190
|
+
);
|
|
10191
|
+
} else {
|
|
10192
|
+
prepareIntentDefinitionForIntentMapTask.then(
|
|
10193
|
+
restoreIntentToTaskMapPayloadTask
|
|
10194
|
+
);
|
|
10195
|
+
}
|
|
10196
|
+
wireSyncTaskGraph(
|
|
10197
|
+
restoreIntentToTaskMapPayloadTask,
|
|
10198
|
+
intentToTaskMapGraph,
|
|
10199
|
+
registerIntentTask
|
|
10181
10200
|
);
|
|
10182
10201
|
this.registerTaskMapTask = CadenzaService.createMetaTask(
|
|
10183
10202
|
"Register task map to DB",
|
|
@@ -10213,39 +10232,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10213
10232
|
};
|
|
10214
10233
|
}
|
|
10215
10234
|
}
|
|
10216
|
-
)
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
}
|
|
10233
|
-
}
|
|
10234
|
-
},
|
|
10235
|
-
{ concurrency: 30 }
|
|
10236
|
-
)?.then(
|
|
10237
|
-
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
10238
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
10239
|
-
return;
|
|
10235
|
+
);
|
|
10236
|
+
const taskMapRegistrationGraph = resolveSyncInsertTask(
|
|
10237
|
+
this.isCadenzaDBReady,
|
|
10238
|
+
"directional_task_graph_map",
|
|
10239
|
+
{
|
|
10240
|
+
onConflict: {
|
|
10241
|
+
target: [
|
|
10242
|
+
"task_name",
|
|
10243
|
+
"predecessor_task_name",
|
|
10244
|
+
"task_version",
|
|
10245
|
+
"predecessor_task_version",
|
|
10246
|
+
"service_name",
|
|
10247
|
+
"predecessor_service_name"
|
|
10248
|
+
],
|
|
10249
|
+
action: {
|
|
10250
|
+
do: "nothing"
|
|
10240
10251
|
}
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10252
|
+
}
|
|
10253
|
+
},
|
|
10254
|
+
{ concurrency: 30 }
|
|
10255
|
+
);
|
|
10256
|
+
const recordTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
10257
|
+
"Record task map registration",
|
|
10258
|
+
(ctx) => {
|
|
10259
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
10260
|
+
return;
|
|
10261
|
+
}
|
|
10262
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
10263
|
+
delayMs: 3e3
|
|
10264
|
+
});
|
|
10265
|
+
CadenzaService.get(ctx.__taskName)?.taskMapRegistration.add(
|
|
10266
|
+
ctx.__nextTaskName
|
|
10267
|
+
);
|
|
10268
|
+
}
|
|
10269
|
+
);
|
|
10270
|
+
wireSyncTaskGraph(
|
|
10271
|
+
this.registerTaskMapTask,
|
|
10272
|
+
taskMapRegistrationGraph,
|
|
10273
|
+
recordTaskMapRegistrationTask
|
|
10249
10274
|
);
|
|
10250
10275
|
this.registerDeputyRelationshipTask = CadenzaService.createMetaTask(
|
|
10251
10276
|
"Register deputy relationship",
|
|
@@ -10272,40 +10297,43 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10272
10297
|
};
|
|
10273
10298
|
}
|
|
10274
10299
|
}
|
|
10275
|
-
)
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
}
|
|
10292
|
-
}
|
|
10293
|
-
},
|
|
10294
|
-
{ concurrency: 30 }
|
|
10295
|
-
)?.then(
|
|
10296
|
-
CadenzaService.createMetaTask(
|
|
10297
|
-
"Record deputy relationship registration",
|
|
10298
|
-
(ctx) => {
|
|
10299
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
10300
|
-
return;
|
|
10301
|
-
}
|
|
10302
|
-
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
10303
|
-
delayMs: 3e3
|
|
10304
|
-
});
|
|
10305
|
-
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
10300
|
+
);
|
|
10301
|
+
const deputyRelationshipRegistrationGraph = resolveSyncInsertTask(
|
|
10302
|
+
this.isCadenzaDBReady,
|
|
10303
|
+
"directional_task_graph_map",
|
|
10304
|
+
{
|
|
10305
|
+
onConflict: {
|
|
10306
|
+
target: [
|
|
10307
|
+
"task_name",
|
|
10308
|
+
"predecessor_task_name",
|
|
10309
|
+
"task_version",
|
|
10310
|
+
"predecessor_task_version",
|
|
10311
|
+
"service_name",
|
|
10312
|
+
"predecessor_service_name"
|
|
10313
|
+
],
|
|
10314
|
+
action: {
|
|
10315
|
+
do: "nothing"
|
|
10306
10316
|
}
|
|
10307
|
-
|
|
10308
|
-
|
|
10317
|
+
}
|
|
10318
|
+
},
|
|
10319
|
+
{ concurrency: 30 }
|
|
10320
|
+
);
|
|
10321
|
+
const recordDeputyRelationshipRegistrationTask = CadenzaService.createMetaTask(
|
|
10322
|
+
"Record deputy relationship registration",
|
|
10323
|
+
(ctx) => {
|
|
10324
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
10325
|
+
return;
|
|
10326
|
+
}
|
|
10327
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
10328
|
+
delayMs: 3e3
|
|
10329
|
+
});
|
|
10330
|
+
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
10331
|
+
}
|
|
10332
|
+
);
|
|
10333
|
+
wireSyncTaskGraph(
|
|
10334
|
+
this.registerDeputyRelationshipTask,
|
|
10335
|
+
deputyRelationshipRegistrationGraph,
|
|
10336
|
+
recordDeputyRelationshipRegistrationTask
|
|
10309
10337
|
);
|
|
10310
10338
|
const reconcileTaskRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
10311
10339
|
"Reconcile task registration from authority",
|
|
@@ -10437,7 +10465,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10437
10465
|
isHidden: true
|
|
10438
10466
|
}
|
|
10439
10467
|
);
|
|
10440
|
-
const
|
|
10468
|
+
const skipAuthoritativeTaskReconciliationTask = CadenzaService.createMetaTask(
|
|
10441
10469
|
"Skip authoritative task reconciliation",
|
|
10442
10470
|
() => false,
|
|
10443
10471
|
"Skips task reconciliation when no authority query task is available.",
|
|
@@ -10446,7 +10474,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10446
10474
|
isHidden: true
|
|
10447
10475
|
}
|
|
10448
10476
|
);
|
|
10449
|
-
const
|
|
10477
|
+
const skipAuthoritativeRoutineReconciliationTask = CadenzaService.createMetaTask(
|
|
10450
10478
|
"Skip authoritative routine reconciliation",
|
|
10451
10479
|
() => false,
|
|
10452
10480
|
"Skips routine reconciliation when no authority query task is available.",
|
|
@@ -10455,7 +10483,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10455
10483
|
isHidden: true
|
|
10456
10484
|
}
|
|
10457
10485
|
);
|
|
10458
|
-
const
|
|
10486
|
+
const skipAuthoritativeSignalReconciliationTask = CadenzaService.createMetaTask(
|
|
10459
10487
|
"Skip authoritative signal reconciliation",
|
|
10460
10488
|
() => false,
|
|
10461
10489
|
"Skips signal reconciliation when no authority query task is available.",
|
|
@@ -10464,7 +10492,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10464
10492
|
isHidden: true
|
|
10465
10493
|
}
|
|
10466
10494
|
);
|
|
10467
|
-
const
|
|
10495
|
+
const skipAuthoritativeIntentReconciliationTask = CadenzaService.createMetaTask(
|
|
10468
10496
|
"Skip authoritative intent reconciliation",
|
|
10469
10497
|
() => false,
|
|
10470
10498
|
"Skips intent reconciliation when no authority query task is available.",
|
|
@@ -10473,6 +10501,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10473
10501
|
isHidden: true
|
|
10474
10502
|
}
|
|
10475
10503
|
);
|
|
10504
|
+
if (authoritativeTaskQueryGraph) {
|
|
10505
|
+
authoritativeTaskQueryGraph.completionTask.then(
|
|
10506
|
+
reconcileTaskRegistrationFromAuthorityTask
|
|
10507
|
+
);
|
|
10508
|
+
}
|
|
10509
|
+
if (authoritativeRoutineQueryGraph) {
|
|
10510
|
+
authoritativeRoutineQueryGraph.completionTask.then(
|
|
10511
|
+
reconcileRoutineRegistrationFromAuthorityTask
|
|
10512
|
+
);
|
|
10513
|
+
}
|
|
10514
|
+
if (authoritativeSignalQueryGraph) {
|
|
10515
|
+
authoritativeSignalQueryGraph.completionTask.then(
|
|
10516
|
+
reconcileSignalRegistrationFromAuthorityTask
|
|
10517
|
+
);
|
|
10518
|
+
}
|
|
10519
|
+
if (authoritativeIntentQueryGraph) {
|
|
10520
|
+
authoritativeIntentQueryGraph.completionTask.then(
|
|
10521
|
+
reconcileIntentRegistrationFromAuthorityTask
|
|
10522
|
+
);
|
|
10523
|
+
}
|
|
10476
10524
|
const authoritativeRegistrationTriggers = [
|
|
10477
10525
|
"meta.service_registry.initial_sync_complete",
|
|
10478
10526
|
"meta.sync_requested",
|
|
@@ -10505,7 +10553,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10505
10553
|
register: false,
|
|
10506
10554
|
isHidden: true
|
|
10507
10555
|
}
|
|
10508
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10556
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10557
|
+
authoritativeTaskQueryGraph?.entryTask ?? skipAuthoritativeTaskReconciliationTask
|
|
10558
|
+
);
|
|
10509
10559
|
CadenzaService.createMetaTask(
|
|
10510
10560
|
"Prepare authoritative routine registration query",
|
|
10511
10561
|
(ctx) => {
|
|
@@ -10532,7 +10582,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10532
10582
|
register: false,
|
|
10533
10583
|
isHidden: true
|
|
10534
10584
|
}
|
|
10535
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10585
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10586
|
+
authoritativeRoutineQueryGraph?.entryTask ?? skipAuthoritativeRoutineReconciliationTask
|
|
10587
|
+
);
|
|
10536
10588
|
CadenzaService.createMetaTask(
|
|
10537
10589
|
"Prepare authoritative signal registration query",
|
|
10538
10590
|
(ctx) => {
|
|
@@ -10551,7 +10603,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10551
10603
|
register: false,
|
|
10552
10604
|
isHidden: true
|
|
10553
10605
|
}
|
|
10554
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10606
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10607
|
+
authoritativeSignalQueryGraph?.entryTask ?? skipAuthoritativeSignalReconciliationTask
|
|
10608
|
+
);
|
|
10555
10609
|
CadenzaService.createMetaTask(
|
|
10556
10610
|
"Prepare authoritative intent registration query",
|
|
10557
10611
|
(ctx) => {
|
|
@@ -10570,7 +10624,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
10570
10624
|
register: false,
|
|
10571
10625
|
isHidden: true
|
|
10572
10626
|
}
|
|
10573
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10627
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
10628
|
+
authoritativeIntentQueryGraph?.entryTask ?? skipAuthoritativeIntentReconciliationTask
|
|
10629
|
+
);
|
|
10574
10630
|
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
10575
10631
|
"meta.sync_controller.sync_tick",
|
|
10576
10632
|
"meta.service_registry.initial_sync_complete",
|
|
@@ -11005,7 +11061,7 @@ var CadenzaService = class {
|
|
|
11005
11061
|
).map((transport) => ({
|
|
11006
11062
|
...transport,
|
|
11007
11063
|
protocols: transport.protocols && transport.protocols.length > 0 ? transport.protocols : useSocket ? ["rest", "socket"] : ["rest"],
|
|
11008
|
-
uuid: (0,
|
|
11064
|
+
uuid: (0, import_uuid6.v4)()
|
|
11009
11065
|
}));
|
|
11010
11066
|
}
|
|
11011
11067
|
static createBootstrapTransport(serviceInstanceId, role, endpoint) {
|
|
@@ -11257,7 +11313,7 @@ var CadenzaService = class {
|
|
|
11257
11313
|
}
|
|
11258
11314
|
for (const responder of responders) {
|
|
11259
11315
|
const { task, descriptor } = responder;
|
|
11260
|
-
const inquiryId = (0,
|
|
11316
|
+
const inquiryId = (0, import_uuid6.v4)();
|
|
11261
11317
|
startTimeByTask.set(task, Date.now());
|
|
11262
11318
|
const resolverTask = this.createEphemeralMetaTask(
|
|
11263
11319
|
`Resolve inquiry ${inquiry} for ${descriptor.localTaskName}`,
|
|
@@ -11765,7 +11821,7 @@ var CadenzaService = class {
|
|
|
11765
11821
|
this.bootstrap();
|
|
11766
11822
|
this.validateName(serviceName);
|
|
11767
11823
|
this.validateServiceName(serviceName);
|
|
11768
|
-
const serviceId = options.customServiceId ?? (0,
|
|
11824
|
+
const serviceId = options.customServiceId ?? (0, import_uuid6.v4)();
|
|
11769
11825
|
this.serviceRegistry.serviceName = serviceName;
|
|
11770
11826
|
this.serviceRegistry.serviceInstanceId = serviceId;
|
|
11771
11827
|
this.setHydrationResults(options.hydration);
|
|
@@ -12610,7 +12666,7 @@ CadenzaService.frontendSyncScheduled = false;
|
|
|
12610
12666
|
var import_core6 = require("@cadenza.io/core");
|
|
12611
12667
|
|
|
12612
12668
|
// src/ssr/createSSRInquiryBridge.ts
|
|
12613
|
-
var
|
|
12669
|
+
var import_uuid7 = require("uuid");
|
|
12614
12670
|
function ensureFetch() {
|
|
12615
12671
|
if (typeof globalThis.fetch !== "function") {
|
|
12616
12672
|
throw new Error("SSR inquiry bridge requires global fetch support.");
|
|
@@ -12699,7 +12755,7 @@ function createSSRInquiryBridge(options = {}) {
|
|
|
12699
12755
|
__remoteRoutineName: remoteRoutineName,
|
|
12700
12756
|
__metadata: {
|
|
12701
12757
|
...context.__metadata ?? {},
|
|
12702
|
-
__deputyExecId: (0,
|
|
12758
|
+
__deputyExecId: (0, import_uuid7.v4)()
|
|
12703
12759
|
}
|
|
12704
12760
|
}),
|
|
12705
12761
|
signal
|