@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/browser/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 uuid7 = 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 (!uuid7 || !serviceInstanceId || !config) {
|
|
445
445
|
return null;
|
|
446
446
|
}
|
|
447
447
|
return {
|
|
448
|
-
uuid:
|
|
448
|
+
uuid: uuid7,
|
|
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 uuid7 = normalizeString2(raw.uuid);
|
|
511
511
|
const serviceName = normalizeString2(raw.serviceName ?? raw.service_name);
|
|
512
|
-
if (!
|
|
512
|
+
if (!uuid7 || !serviceName) {
|
|
513
513
|
return null;
|
|
514
514
|
}
|
|
515
|
-
const transports = normalizeTransportArray(raw.transports,
|
|
515
|
+
const transports = normalizeTransportArray(raw.transports, uuid7);
|
|
516
516
|
return {
|
|
517
|
-
uuid:
|
|
517
|
+
uuid: uuid7,
|
|
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 uuid7 = 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 (uuid7 === 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 === uuid7);
|
|
1166
|
+
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid7) ?? -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(uuid7, 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 === uuid7);
|
|
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 === uuid7);
|
|
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, uuid7, 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: uuid7,
|
|
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: uuid7,
|
|
1251
1251
|
requiredRole: this.getRoutingTransportRole(),
|
|
1252
1252
|
isFrontend: this.isFrontend
|
|
1253
1253
|
});
|
|
@@ -6111,11 +6111,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
6111
6111
|
};
|
|
6112
6112
|
|
|
6113
6113
|
// src/Cadenza.ts
|
|
6114
|
-
var
|
|
6114
|
+
var import_uuid5 = require("uuid");
|
|
6115
6115
|
|
|
6116
6116
|
// src/graph/controllers/GraphSyncController.ts
|
|
6117
6117
|
var import_core4 = require("@cadenza.io/core");
|
|
6118
|
-
var import_uuid5 = require("uuid");
|
|
6119
6118
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
6120
6119
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
6121
6120
|
if (typeof taskFunction !== "function") {
|
|
@@ -6243,6 +6242,64 @@ function buildSyncInsertQueryData(ctx, queryData = {}) {
|
|
|
6243
6242
|
}
|
|
6244
6243
|
return nextQueryData;
|
|
6245
6244
|
}
|
|
6245
|
+
function wireSyncTaskGraph(predecessorTask, graph, ...completionTasks) {
|
|
6246
|
+
if (!graph) {
|
|
6247
|
+
return void 0;
|
|
6248
|
+
}
|
|
6249
|
+
predecessorTask.then(graph.entryTask);
|
|
6250
|
+
if (completionTasks.length > 0) {
|
|
6251
|
+
graph.completionTask.then(...completionTasks);
|
|
6252
|
+
}
|
|
6253
|
+
return graph.completionTask;
|
|
6254
|
+
}
|
|
6255
|
+
function resolveLocalDatabaseTaskIntent(task, operation, tableName) {
|
|
6256
|
+
if (!task) {
|
|
6257
|
+
return void 0;
|
|
6258
|
+
}
|
|
6259
|
+
const expectedPrefix = `${operation}-pg-`;
|
|
6260
|
+
const expectedSuffix = `-${tableName}`;
|
|
6261
|
+
const handledIntents = Array.from(task.handlesIntents ?? []);
|
|
6262
|
+
const directMatch = handledIntents.find(
|
|
6263
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix) && intent.endsWith(expectedSuffix)
|
|
6264
|
+
);
|
|
6265
|
+
if (directMatch) {
|
|
6266
|
+
return directMatch;
|
|
6267
|
+
}
|
|
6268
|
+
return handledIntents.find(
|
|
6269
|
+
(intent) => typeof intent === "string" && intent.startsWith(expectedPrefix)
|
|
6270
|
+
);
|
|
6271
|
+
}
|
|
6272
|
+
function createLocalDatabaseInquiryTask(localTask, operation, tableName, options = {}) {
|
|
6273
|
+
const intentName = resolveLocalDatabaseTaskIntent(localTask, operation, tableName);
|
|
6274
|
+
return CadenzaService.createMetaTask(
|
|
6275
|
+
`Execute local graph sync ${operation} for ${tableName}`,
|
|
6276
|
+
async (ctx, _emit, inquire) => {
|
|
6277
|
+
if (!intentName) {
|
|
6278
|
+
return {
|
|
6279
|
+
...ctx,
|
|
6280
|
+
errored: true,
|
|
6281
|
+
__success: false,
|
|
6282
|
+
__error: `No local ${operation} intent found for ${tableName}`
|
|
6283
|
+
};
|
|
6284
|
+
}
|
|
6285
|
+
const inquiryContext = {
|
|
6286
|
+
...ctx,
|
|
6287
|
+
queryData: ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {}
|
|
6288
|
+
};
|
|
6289
|
+
const result = await inquire(intentName, inquiryContext, {});
|
|
6290
|
+
return {
|
|
6291
|
+
...ctx,
|
|
6292
|
+
...result
|
|
6293
|
+
};
|
|
6294
|
+
},
|
|
6295
|
+
`Executes the local ${tableName} ${operation} operation through the generated database intent.`,
|
|
6296
|
+
{
|
|
6297
|
+
...options,
|
|
6298
|
+
register: false,
|
|
6299
|
+
isHidden: true
|
|
6300
|
+
}
|
|
6301
|
+
);
|
|
6302
|
+
}
|
|
6246
6303
|
function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, options = {}) {
|
|
6247
6304
|
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
6248
6305
|
const remoteInsertTask = isCadenzaDBReady ? CadenzaService.createCadenzaDBInsertTask(tableName, queryData, options) : void 0;
|
|
@@ -6250,7 +6307,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6250
6307
|
if (!localInsertTask && !remoteInsertTask) {
|
|
6251
6308
|
return void 0;
|
|
6252
6309
|
}
|
|
6253
|
-
const targetTask = localInsertTask
|
|
6310
|
+
const targetTask = localInsertTask ? createLocalDatabaseInquiryTask(localInsertTask, "insert", tableName, options) : remoteInsertTask;
|
|
6254
6311
|
if (debugTable) {
|
|
6255
6312
|
logSyncDebug("insert_task_resolved", {
|
|
6256
6313
|
tableName,
|
|
@@ -6261,21 +6318,14 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6261
6318
|
options
|
|
6262
6319
|
});
|
|
6263
6320
|
}
|
|
6264
|
-
const executionRequestedSignal = `meta.sync_controller.insert_execution_requested:${tableName}`;
|
|
6265
|
-
const executionResolvedSignal = `meta.sync_controller.insert_execution_resolved:${tableName}`;
|
|
6266
|
-
const executionFailedSignal = `meta.sync_controller.insert_execution_failed:${tableName}`;
|
|
6267
|
-
const pendingResolverContexts = /* @__PURE__ */ new Map();
|
|
6268
6321
|
const prepareExecutionTask = CadenzaService.createMetaTask(
|
|
6269
6322
|
`Prepare graph sync insert for ${tableName}`,
|
|
6270
6323
|
(ctx) => {
|
|
6271
6324
|
const originalContext = { ...ctx };
|
|
6272
|
-
const originalQueryData = buildSyncInsertQueryData(
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
originalQueryData
|
|
6277
|
-
});
|
|
6278
|
-
}
|
|
6325
|
+
const originalQueryData = buildSyncInsertQueryData(
|
|
6326
|
+
ctx,
|
|
6327
|
+
queryData
|
|
6328
|
+
);
|
|
6279
6329
|
return {
|
|
6280
6330
|
...ctx,
|
|
6281
6331
|
__resolverOriginalContext: originalContext,
|
|
@@ -6288,7 +6338,7 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6288
6338
|
register: false,
|
|
6289
6339
|
isHidden: true
|
|
6290
6340
|
}
|
|
6291
|
-
)
|
|
6341
|
+
);
|
|
6292
6342
|
if (debugTable) {
|
|
6293
6343
|
prepareExecutionTask.then(
|
|
6294
6344
|
CadenzaService.createMetaTask(
|
|
@@ -6322,15 +6372,9 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6322
6372
|
}
|
|
6323
6373
|
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
6324
6374
|
`Finalize graph sync insert for ${tableName}`,
|
|
6325
|
-
(ctx
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
}
|
|
6329
|
-
const pendingResolverContext = pendingResolverContexts.get(
|
|
6330
|
-
ctx.__resolverRequestId
|
|
6331
|
-
);
|
|
6332
|
-
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : pendingResolverContext?.originalContext ? { ...pendingResolverContext.originalContext } : {};
|
|
6333
|
-
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : pendingResolverContext?.originalQueryData;
|
|
6375
|
+
(ctx) => {
|
|
6376
|
+
const originalContext = ctx.__resolverOriginalContext && typeof ctx.__resolverOriginalContext === "object" ? ctx.__resolverOriginalContext : {};
|
|
6377
|
+
const originalQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : void 0;
|
|
6334
6378
|
const normalizedContext = {
|
|
6335
6379
|
...originalContext,
|
|
6336
6380
|
...ctx,
|
|
@@ -6355,8 +6399,6 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6355
6399
|
});
|
|
6356
6400
|
}
|
|
6357
6401
|
}
|
|
6358
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
6359
|
-
emit(executionResolvedSignal, normalizedContext);
|
|
6360
6402
|
return normalizedContext;
|
|
6361
6403
|
},
|
|
6362
6404
|
`Finalizes ${tableName} graph-sync insert execution after the authority task finishes.`,
|
|
@@ -6365,95 +6407,12 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6365
6407
|
isHidden: true
|
|
6366
6408
|
}
|
|
6367
6409
|
);
|
|
6368
|
-
targetTask.then(finalizeExecutionTask).emitsOnFail(executionFailedSignal);
|
|
6369
6410
|
prepareExecutionTask.then(targetTask);
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
if (shouldDebugTaskSyncPayload(ctx) || shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
6376
|
-
logSyncDebug("insert_failed", {
|
|
6377
|
-
tableName,
|
|
6378
|
-
targetTaskName: targetTask.name,
|
|
6379
|
-
payload: buildTaskSyncDebugPayload({
|
|
6380
|
-
...ctx,
|
|
6381
|
-
__taskName: ctx.__taskName
|
|
6382
|
-
})
|
|
6383
|
-
});
|
|
6384
|
-
}
|
|
6385
|
-
} else {
|
|
6386
|
-
logSyncDebug("insert_failed", {
|
|
6387
|
-
tableName,
|
|
6388
|
-
targetTaskName: targetTask.name,
|
|
6389
|
-
ctx
|
|
6390
|
-
});
|
|
6391
|
-
}
|
|
6392
|
-
if (typeof ctx.__resolverRequestId === "string") {
|
|
6393
|
-
pendingResolverContexts.delete(ctx.__resolverRequestId);
|
|
6394
|
-
}
|
|
6395
|
-
return false;
|
|
6396
|
-
},
|
|
6397
|
-
`Logs failed ${tableName} sync insert executions.`,
|
|
6398
|
-
{
|
|
6399
|
-
register: false,
|
|
6400
|
-
isHidden: true
|
|
6401
|
-
}
|
|
6402
|
-
).doOn(executionFailedSignal);
|
|
6403
|
-
}
|
|
6404
|
-
return CadenzaService.createMetaTask(
|
|
6405
|
-
`Resolve graph sync insert for ${tableName}`,
|
|
6406
|
-
(ctx, emit) => new Promise((resolve) => {
|
|
6407
|
-
const resolverRequestId = (0, import_uuid5.v4)();
|
|
6408
|
-
const resolvedContext = {
|
|
6409
|
-
...ctx,
|
|
6410
|
-
__resolverRequestId: resolverRequestId
|
|
6411
|
-
};
|
|
6412
|
-
if (debugTable) {
|
|
6413
|
-
if (tableName === "task") {
|
|
6414
|
-
if (shouldDebugTaskSyncPayload(resolvedContext)) {
|
|
6415
|
-
logSyncDebug("insert_resolver_request", {
|
|
6416
|
-
tableName,
|
|
6417
|
-
targetTaskName: targetTask.name,
|
|
6418
|
-
payload: buildTaskSyncDebugPayload(resolvedContext)
|
|
6419
|
-
});
|
|
6420
|
-
}
|
|
6421
|
-
} else {
|
|
6422
|
-
logSyncDebug("insert_resolver_request", {
|
|
6423
|
-
tableName,
|
|
6424
|
-
targetTaskName: targetTask.name,
|
|
6425
|
-
ctx: resolvedContext
|
|
6426
|
-
});
|
|
6427
|
-
}
|
|
6428
|
-
}
|
|
6429
|
-
CadenzaService.createEphemeralMetaTask(
|
|
6430
|
-
`Resolve graph sync insert execution for ${tableName} (${resolverRequestId})`,
|
|
6431
|
-
(resultCtx) => {
|
|
6432
|
-
if (resultCtx.__resolverRequestId !== resolverRequestId) {
|
|
6433
|
-
return false;
|
|
6434
|
-
}
|
|
6435
|
-
const normalizedResult = {
|
|
6436
|
-
...resultCtx
|
|
6437
|
-
};
|
|
6438
|
-
delete normalizedResult.__resolverRequestId;
|
|
6439
|
-
pendingResolverContexts.delete(resolverRequestId);
|
|
6440
|
-
resolve(normalizedResult);
|
|
6441
|
-
return normalizedResult;
|
|
6442
|
-
},
|
|
6443
|
-
`Waits for ${tableName} graph-sync insert execution.`,
|
|
6444
|
-
{
|
|
6445
|
-
register: false
|
|
6446
|
-
}
|
|
6447
|
-
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
6448
|
-
emit(executionRequestedSignal, resolvedContext);
|
|
6449
|
-
}),
|
|
6450
|
-
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
6451
|
-
{
|
|
6452
|
-
...options,
|
|
6453
|
-
register: false,
|
|
6454
|
-
isHidden: true
|
|
6455
|
-
}
|
|
6456
|
-
);
|
|
6411
|
+
targetTask.then(finalizeExecutionTask);
|
|
6412
|
+
return {
|
|
6413
|
+
entryTask: prepareExecutionTask,
|
|
6414
|
+
completionTask: finalizeExecutionTask
|
|
6415
|
+
};
|
|
6457
6416
|
}
|
|
6458
6417
|
var CADENZA_DB_REQUIRED_LOCAL_SYNC_INSERT_TABLES = [
|
|
6459
6418
|
"intent_registry",
|
|
@@ -6614,8 +6573,8 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
6614
6573
|
if (!localQueryTask && !remoteQueryTask) {
|
|
6615
6574
|
return void 0;
|
|
6616
6575
|
}
|
|
6617
|
-
const targetTask = localQueryTask
|
|
6618
|
-
|
|
6576
|
+
const targetTask = localQueryTask ? createLocalDatabaseInquiryTask(localQueryTask, "query", tableName, options) : remoteQueryTask;
|
|
6577
|
+
const prepareQueryTask = CadenzaService.createMetaTask(
|
|
6619
6578
|
`Prepare graph sync query for ${tableName}`,
|
|
6620
6579
|
(ctx) => ({
|
|
6621
6580
|
...ctx,
|
|
@@ -6629,7 +6588,22 @@ function resolveSyncQueryTask(isCadenzaDBReady, tableName, queryData = {}, optio
|
|
|
6629
6588
|
register: false,
|
|
6630
6589
|
isHidden: true
|
|
6631
6590
|
}
|
|
6632
|
-
)
|
|
6591
|
+
);
|
|
6592
|
+
const finalizeQueryTask = CadenzaService.createMetaTask(
|
|
6593
|
+
`Finalize graph sync query for ${tableName}`,
|
|
6594
|
+
(ctx) => ctx,
|
|
6595
|
+
`Finalizes ${tableName} graph-sync query payloads after authority lookup.`,
|
|
6596
|
+
{
|
|
6597
|
+
register: false,
|
|
6598
|
+
isHidden: true
|
|
6599
|
+
}
|
|
6600
|
+
);
|
|
6601
|
+
prepareQueryTask.then(targetTask);
|
|
6602
|
+
targetTask.then(finalizeQueryTask);
|
|
6603
|
+
return {
|
|
6604
|
+
entryTask: prepareQueryTask,
|
|
6605
|
+
completionTask: finalizeQueryTask
|
|
6606
|
+
};
|
|
6633
6607
|
}
|
|
6634
6608
|
function getRegistrableTasks() {
|
|
6635
6609
|
return Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
@@ -6756,25 +6730,25 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6756
6730
|
},
|
|
6757
6731
|
{ concurrency: 30 }
|
|
6758
6732
|
);
|
|
6759
|
-
const
|
|
6733
|
+
const authoritativeTaskQueryGraph = resolveSyncQueryTask(
|
|
6760
6734
|
this.isCadenzaDBReady,
|
|
6761
6735
|
"task",
|
|
6762
6736
|
{},
|
|
6763
6737
|
{ concurrency: 10 }
|
|
6764
6738
|
);
|
|
6765
|
-
const
|
|
6739
|
+
const authoritativeRoutineQueryGraph = resolveSyncQueryTask(
|
|
6766
6740
|
this.isCadenzaDBReady,
|
|
6767
6741
|
"routine",
|
|
6768
6742
|
{},
|
|
6769
6743
|
{ concurrency: 10 }
|
|
6770
6744
|
);
|
|
6771
|
-
const
|
|
6745
|
+
const authoritativeSignalQueryGraph = resolveSyncQueryTask(
|
|
6772
6746
|
this.isCadenzaDBReady,
|
|
6773
6747
|
"signal_registry",
|
|
6774
6748
|
{},
|
|
6775
6749
|
{ concurrency: 10 }
|
|
6776
6750
|
);
|
|
6777
|
-
const
|
|
6751
|
+
const authoritativeIntentQueryGraph = resolveSyncQueryTask(
|
|
6778
6752
|
this.isCadenzaDBReady,
|
|
6779
6753
|
"intent_registry",
|
|
6780
6754
|
{},
|
|
@@ -6945,32 +6919,30 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
6945
6919
|
}
|
|
6946
6920
|
}.bind(this)
|
|
6947
6921
|
);
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
{
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
do: "nothing"
|
|
6957
|
-
}
|
|
6958
|
-
}
|
|
6959
|
-
},
|
|
6960
|
-
{ concurrency: 30 }
|
|
6961
|
-
)?.then(
|
|
6962
|
-
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
6963
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
6964
|
-
return;
|
|
6922
|
+
const routineRegistrationGraph = resolveSyncInsertTask(
|
|
6923
|
+
this.isCadenzaDBReady,
|
|
6924
|
+
"routine",
|
|
6925
|
+
{
|
|
6926
|
+
onConflict: {
|
|
6927
|
+
target: ["name", "version", "service_name"],
|
|
6928
|
+
action: {
|
|
6929
|
+
do: "nothing"
|
|
6965
6930
|
}
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6970
|
-
return true;
|
|
6971
|
-
}).then(gatherRoutineRegistrationTask)
|
|
6972
|
-
)
|
|
6931
|
+
}
|
|
6932
|
+
},
|
|
6933
|
+
{ concurrency: 30 }
|
|
6973
6934
|
);
|
|
6935
|
+
const registerRoutineTask = CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
6936
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
6937
|
+
return;
|
|
6938
|
+
}
|
|
6939
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
6940
|
+
delayMs: 3e3
|
|
6941
|
+
});
|
|
6942
|
+
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
6943
|
+
return true;
|
|
6944
|
+
}).then(gatherRoutineRegistrationTask);
|
|
6945
|
+
wireSyncTaskGraph(this.splitRoutinesTask, routineRegistrationGraph, registerRoutineTask);
|
|
6974
6946
|
this.splitTasksInRoutines = CadenzaService.createMetaTask(
|
|
6975
6947
|
"Split tasks in routines",
|
|
6976
6948
|
function* (ctx) {
|
|
@@ -7023,7 +6995,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7023
6995
|
}
|
|
7024
6996
|
}
|
|
7025
6997
|
);
|
|
7026
|
-
const
|
|
6998
|
+
const registerTaskToRoutineMapGraph = resolveSyncInsertTask(
|
|
7027
6999
|
this.isCadenzaDBReady,
|
|
7028
7000
|
"task_to_routine_map",
|
|
7029
7001
|
{
|
|
@@ -7041,8 +7013,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7041
7013
|
}
|
|
7042
7014
|
},
|
|
7043
7015
|
{ concurrency: 30 }
|
|
7044
|
-
)
|
|
7045
|
-
|
|
7016
|
+
);
|
|
7017
|
+
const registerTaskToRoutineMapTask = CadenzaService.createMetaTask(
|
|
7018
|
+
"Register routine task",
|
|
7019
|
+
(ctx) => {
|
|
7046
7020
|
if (!didSyncInsertSucceed(ctx)) {
|
|
7047
7021
|
return;
|
|
7048
7022
|
}
|
|
@@ -7052,11 +7026,13 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7052
7026
|
CadenzaService.getRoutine(ctx.__routineName).registeredTasks.add(
|
|
7053
7027
|
ctx.__taskName
|
|
7054
7028
|
);
|
|
7055
|
-
}
|
|
7029
|
+
}
|
|
7030
|
+
);
|
|
7031
|
+
wireSyncTaskGraph(
|
|
7032
|
+
this.splitTasksInRoutines,
|
|
7033
|
+
registerTaskToRoutineMapGraph,
|
|
7034
|
+
registerTaskToRoutineMapTask
|
|
7056
7035
|
);
|
|
7057
|
-
if (registerTaskToRoutineMapTask) {
|
|
7058
|
-
this.splitTasksInRoutines.then(registerTaskToRoutineMapTask);
|
|
7059
|
-
}
|
|
7060
7036
|
this.splitSignalsTask = CadenzaService.createMetaTask(
|
|
7061
7037
|
"Split signals for registration",
|
|
7062
7038
|
function* (ctx) {
|
|
@@ -7085,30 +7061,35 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7085
7061
|
}
|
|
7086
7062
|
}.bind(this)
|
|
7087
7063
|
);
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
{
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
do: "nothing"
|
|
7097
|
-
}
|
|
7098
|
-
}
|
|
7099
|
-
},
|
|
7100
|
-
{ concurrency: 30 }
|
|
7101
|
-
)?.then(
|
|
7102
|
-
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
7103
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7104
|
-
return;
|
|
7064
|
+
const signalRegistrationGraph = resolveSyncInsertTask(
|
|
7065
|
+
this.isCadenzaDBReady,
|
|
7066
|
+
"signal_registry",
|
|
7067
|
+
{
|
|
7068
|
+
onConflict: {
|
|
7069
|
+
target: ["name"],
|
|
7070
|
+
action: {
|
|
7071
|
+
do: "nothing"
|
|
7105
7072
|
}
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7073
|
+
}
|
|
7074
|
+
},
|
|
7075
|
+
{ concurrency: 30 }
|
|
7076
|
+
);
|
|
7077
|
+
const processSignalRegistrationTask = CadenzaService.createMetaTask(
|
|
7078
|
+
"Process signal registration",
|
|
7079
|
+
(ctx) => {
|
|
7080
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7081
|
+
return;
|
|
7082
|
+
}
|
|
7083
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7084
|
+
delayMs: 3e3
|
|
7085
|
+
});
|
|
7086
|
+
return { signalName: ctx.__signal };
|
|
7087
|
+
}
|
|
7088
|
+
).then(CadenzaService.signalBroker.registerSignalTask).then(gatherSignalRegistrationTask);
|
|
7089
|
+
wireSyncTaskGraph(
|
|
7090
|
+
this.splitSignalsTask,
|
|
7091
|
+
signalRegistrationGraph,
|
|
7092
|
+
processSignalRegistrationTask
|
|
7112
7093
|
);
|
|
7113
7094
|
this.splitTasksForRegistration = CadenzaService.createMetaTask(
|
|
7114
7095
|
"Split tasks for registration",
|
|
@@ -7177,7 +7158,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7177
7158
|
}
|
|
7178
7159
|
}.bind(this)
|
|
7179
7160
|
);
|
|
7180
|
-
const
|
|
7161
|
+
const registerTaskGraph = resolveSyncInsertTask(
|
|
7181
7162
|
this.isCadenzaDBReady,
|
|
7182
7163
|
"task",
|
|
7183
7164
|
{
|
|
@@ -7189,8 +7170,10 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7189
7170
|
}
|
|
7190
7171
|
},
|
|
7191
7172
|
{ concurrency: 30 }
|
|
7192
|
-
)
|
|
7193
|
-
|
|
7173
|
+
);
|
|
7174
|
+
const registerTaskTask = CadenzaService.createMetaTask(
|
|
7175
|
+
"Record registration",
|
|
7176
|
+
(ctx, emit) => {
|
|
7194
7177
|
if (shouldDebugSyncTaskName(ctx.__taskName)) {
|
|
7195
7178
|
logSyncDebug("task_registration_result", {
|
|
7196
7179
|
taskName: ctx.__taskName,
|
|
@@ -7210,11 +7193,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7210
7193
|
task: CadenzaService.get(ctx.__taskName)
|
|
7211
7194
|
});
|
|
7212
7195
|
return true;
|
|
7213
|
-
}
|
|
7214
|
-
);
|
|
7215
|
-
|
|
7216
|
-
this.splitTasksForRegistration.then(registerTaskTask);
|
|
7217
|
-
}
|
|
7196
|
+
}
|
|
7197
|
+
).then(gatherTaskRegistrationTask);
|
|
7198
|
+
wireSyncTaskGraph(this.splitTasksForRegistration, registerTaskGraph, registerTaskTask);
|
|
7218
7199
|
CadenzaService.createMetaTask(
|
|
7219
7200
|
"Prepare created task for immediate sync",
|
|
7220
7201
|
(ctx) => {
|
|
@@ -7273,31 +7254,37 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7273
7254
|
};
|
|
7274
7255
|
}
|
|
7275
7256
|
}.bind(this)
|
|
7276
|
-
)
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
}
|
|
7286
|
-
}
|
|
7287
|
-
},
|
|
7288
|
-
{ concurrency: 30 }
|
|
7289
|
-
)?.then(
|
|
7290
|
-
CadenzaService.createMetaTask("Record actor registration", (ctx) => {
|
|
7291
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7292
|
-
return;
|
|
7257
|
+
);
|
|
7258
|
+
const actorRegistrationGraph = resolveSyncInsertTask(
|
|
7259
|
+
this.isCadenzaDBReady,
|
|
7260
|
+
"actor",
|
|
7261
|
+
{
|
|
7262
|
+
onConflict: {
|
|
7263
|
+
target: ["name", "service_name", "version"],
|
|
7264
|
+
action: {
|
|
7265
|
+
do: "nothing"
|
|
7293
7266
|
}
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
)
|
|
7267
|
+
}
|
|
7268
|
+
},
|
|
7269
|
+
{ concurrency: 30 }
|
|
7270
|
+
);
|
|
7271
|
+
const recordActorRegistrationTask = CadenzaService.createMetaTask(
|
|
7272
|
+
"Record actor registration",
|
|
7273
|
+
(ctx) => {
|
|
7274
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7275
|
+
return;
|
|
7276
|
+
}
|
|
7277
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7278
|
+
delayMs: 3e3
|
|
7279
|
+
});
|
|
7280
|
+
this.registeredActors.add(ctx.__actorRegistrationKey);
|
|
7281
|
+
return true;
|
|
7282
|
+
}
|
|
7283
|
+
).then(gatherActorRegistrationTask);
|
|
7284
|
+
wireSyncTaskGraph(
|
|
7285
|
+
this.splitActorsForRegistration,
|
|
7286
|
+
actorRegistrationGraph,
|
|
7287
|
+
recordActorRegistrationTask
|
|
7301
7288
|
);
|
|
7302
7289
|
this.registerActorTaskMapTask = CadenzaService.createMetaTask(
|
|
7303
7290
|
"Split actor task maps",
|
|
@@ -7335,36 +7322,42 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7335
7322
|
__actorTaskMapRegistrationKey: registrationKey
|
|
7336
7323
|
};
|
|
7337
7324
|
}.bind(this)
|
|
7338
|
-
)
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
}
|
|
7354
|
-
}
|
|
7355
|
-
},
|
|
7356
|
-
{ concurrency: 30 }
|
|
7357
|
-
)?.then(
|
|
7358
|
-
CadenzaService.createMetaTask("Record actor task map registration", (ctx) => {
|
|
7359
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7360
|
-
return;
|
|
7325
|
+
);
|
|
7326
|
+
const actorTaskMapRegistrationGraph = resolveSyncInsertTask(
|
|
7327
|
+
this.isCadenzaDBReady,
|
|
7328
|
+
"actor_task_map",
|
|
7329
|
+
{
|
|
7330
|
+
onConflict: {
|
|
7331
|
+
target: [
|
|
7332
|
+
"actor_name",
|
|
7333
|
+
"actor_version",
|
|
7334
|
+
"task_name",
|
|
7335
|
+
"task_version",
|
|
7336
|
+
"service_name"
|
|
7337
|
+
],
|
|
7338
|
+
action: {
|
|
7339
|
+
do: "nothing"
|
|
7361
7340
|
}
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7341
|
+
}
|
|
7342
|
+
},
|
|
7343
|
+
{ concurrency: 30 }
|
|
7344
|
+
);
|
|
7345
|
+
const recordActorTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
7346
|
+
"Record actor task map registration",
|
|
7347
|
+
(ctx) => {
|
|
7348
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7349
|
+
return;
|
|
7350
|
+
}
|
|
7351
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7352
|
+
delayMs: 3e3
|
|
7353
|
+
});
|
|
7354
|
+
this.registeredActorTaskMaps.add(ctx.__actorTaskMapRegistrationKey);
|
|
7355
|
+
}
|
|
7356
|
+
);
|
|
7357
|
+
wireSyncTaskGraph(
|
|
7358
|
+
this.registerActorTaskMapTask,
|
|
7359
|
+
actorTaskMapRegistrationGraph,
|
|
7360
|
+
recordActorTaskMapRegistrationTask
|
|
7368
7361
|
);
|
|
7369
7362
|
const registerSignalTask = CadenzaService.createMetaTask(
|
|
7370
7363
|
"Record signal registration",
|
|
@@ -7423,25 +7416,32 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7423
7416
|
return emittedCount > 0;
|
|
7424
7417
|
}
|
|
7425
7418
|
);
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7419
|
+
const processSplitSignalToTaskMapTask = CadenzaService.createMetaTask(
|
|
7420
|
+
"Process split signal-to-task map",
|
|
7421
|
+
(ctx) => ctx
|
|
7422
|
+
).doOn("meta.sync_controller.signal_task_map_split");
|
|
7423
|
+
const signalToTaskMapGraph = resolveSyncInsertTask(
|
|
7424
|
+
this.isCadenzaDBReady,
|
|
7425
|
+
"signal_to_task_map",
|
|
7426
|
+
{
|
|
7427
|
+
onConflict: {
|
|
7428
|
+
target: [
|
|
7429
|
+
"task_name",
|
|
7430
|
+
"task_version",
|
|
7431
|
+
"service_name",
|
|
7432
|
+
"signal_name"
|
|
7433
|
+
],
|
|
7434
|
+
action: {
|
|
7435
|
+
do: "nothing"
|
|
7441
7436
|
}
|
|
7442
|
-
}
|
|
7443
|
-
|
|
7444
|
-
|
|
7437
|
+
}
|
|
7438
|
+
},
|
|
7439
|
+
{ concurrency: 30 }
|
|
7440
|
+
);
|
|
7441
|
+
wireSyncTaskGraph(
|
|
7442
|
+
processSplitSignalToTaskMapTask,
|
|
7443
|
+
signalToTaskMapGraph,
|
|
7444
|
+
registerSignalTask
|
|
7445
7445
|
);
|
|
7446
7446
|
this.splitIntentsTask = CadenzaService.createMetaTask(
|
|
7447
7447
|
"Split intents for registration",
|
|
@@ -7467,19 +7467,23 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7467
7467
|
}
|
|
7468
7468
|
}.bind(this)
|
|
7469
7469
|
);
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7470
|
+
const recordIntentDefinitionRegistrationTask = CadenzaService.createMetaTask(
|
|
7471
|
+
"Record intent definition registration",
|
|
7472
|
+
(ctx) => {
|
|
7473
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7474
|
+
return;
|
|
7475
|
+
}
|
|
7476
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7477
|
+
delayMs: 3e3
|
|
7478
|
+
});
|
|
7479
|
+
this.registeredIntentDefinitions.add(ctx.__intentName);
|
|
7480
|
+
return true;
|
|
7481
|
+
}
|
|
7482
|
+
).then(gatherIntentRegistrationTask);
|
|
7483
|
+
wireSyncTaskGraph(
|
|
7484
|
+
this.splitIntentsTask,
|
|
7485
|
+
insertIntentRegistryTask,
|
|
7486
|
+
recordIntentDefinitionRegistrationTask
|
|
7483
7487
|
);
|
|
7484
7488
|
const registerIntentTask = CadenzaService.createMetaTask(
|
|
7485
7489
|
"Record intent registration",
|
|
@@ -7561,67 +7565,82 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7561
7565
|
return true;
|
|
7562
7566
|
}.bind(this)
|
|
7563
7567
|
);
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7568
|
+
const processSplitIntentToTaskMapTask = CadenzaService.createMetaTask(
|
|
7569
|
+
"Process split intent-to-task map",
|
|
7570
|
+
(ctx) => ctx
|
|
7571
|
+
).doOn("meta.sync_controller.intent_task_map_split");
|
|
7572
|
+
const prepareIntentDefinitionForIntentMapTask = CadenzaService.createMetaTask(
|
|
7573
|
+
"Prepare intent definition for intent-to-task map",
|
|
7574
|
+
(ctx) => {
|
|
7575
|
+
if (!ctx.__intentDefinition || !ctx.__intentMapData) {
|
|
7576
|
+
return false;
|
|
7577
|
+
}
|
|
7578
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
7579
|
+
logSyncDebug("intent_definition_prepare", {
|
|
7580
|
+
taskName: ctx.__taskName,
|
|
7581
|
+
intentName: ctx.__intent,
|
|
7582
|
+
intentDefinition: ctx.__intentDefinition
|
|
7583
|
+
});
|
|
7584
|
+
}
|
|
7585
|
+
return {
|
|
7586
|
+
...ctx,
|
|
7587
|
+
data: ctx.__intentDefinition
|
|
7588
|
+
};
|
|
7589
|
+
}
|
|
7590
|
+
);
|
|
7591
|
+
const restoreIntentToTaskMapPayloadTask = CadenzaService.createMetaTask(
|
|
7592
|
+
"Restore intent-to-task map payload",
|
|
7593
|
+
(ctx) => {
|
|
7594
|
+
if (!ctx.__intentMapData) {
|
|
7595
|
+
return false;
|
|
7596
|
+
}
|
|
7597
|
+
if (shouldDebugSyncTaskName(ctx.__taskName) || shouldDebugSyncIntentName(ctx.__intent)) {
|
|
7598
|
+
logSyncDebug("intent_map_payload_restore", {
|
|
7599
|
+
taskName: ctx.__taskName,
|
|
7600
|
+
intentName: ctx.__intent,
|
|
7601
|
+
intentMapData: ctx.__intentMapData
|
|
7602
|
+
});
|
|
7603
|
+
}
|
|
7604
|
+
return {
|
|
7605
|
+
...ctx,
|
|
7606
|
+
data: ctx.__intentMapData
|
|
7607
|
+
};
|
|
7608
|
+
}
|
|
7609
|
+
);
|
|
7610
|
+
const intentToTaskMapGraph = resolveSyncInsertTask(
|
|
7611
|
+
this.isCadenzaDBReady,
|
|
7612
|
+
"intent_to_task_map",
|
|
7613
|
+
{
|
|
7614
|
+
onConflict: {
|
|
7615
|
+
target: [
|
|
7616
|
+
"intent_name",
|
|
7617
|
+
"task_name",
|
|
7618
|
+
"task_version",
|
|
7619
|
+
"service_name"
|
|
7620
|
+
],
|
|
7621
|
+
action: {
|
|
7622
|
+
do: "nothing"
|
|
7577
7623
|
}
|
|
7578
|
-
return {
|
|
7579
|
-
...ctx,
|
|
7580
|
-
data: ctx.__intentDefinition
|
|
7581
|
-
};
|
|
7582
7624
|
}
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
}
|
|
7603
|
-
).then(
|
|
7604
|
-
resolveSyncInsertTask(
|
|
7605
|
-
this.isCadenzaDBReady,
|
|
7606
|
-
"intent_to_task_map",
|
|
7607
|
-
{
|
|
7608
|
-
onConflict: {
|
|
7609
|
-
target: [
|
|
7610
|
-
"intent_name",
|
|
7611
|
-
"task_name",
|
|
7612
|
-
"task_version",
|
|
7613
|
-
"service_name"
|
|
7614
|
-
],
|
|
7615
|
-
action: {
|
|
7616
|
-
do: "nothing"
|
|
7617
|
-
}
|
|
7618
|
-
}
|
|
7619
|
-
},
|
|
7620
|
-
{ concurrency: 30 }
|
|
7621
|
-
)?.then(registerIntentTask)
|
|
7622
|
-
)
|
|
7623
|
-
)
|
|
7624
|
-
)
|
|
7625
|
+
},
|
|
7626
|
+
{ concurrency: 30 }
|
|
7627
|
+
);
|
|
7628
|
+
processSplitIntentToTaskMapTask.then(prepareIntentDefinitionForIntentMapTask);
|
|
7629
|
+
if (ensureIntentRegistryBeforeIntentMapTask) {
|
|
7630
|
+
wireSyncTaskGraph(
|
|
7631
|
+
prepareIntentDefinitionForIntentMapTask,
|
|
7632
|
+
ensureIntentRegistryBeforeIntentMapTask,
|
|
7633
|
+
restoreIntentToTaskMapPayloadTask
|
|
7634
|
+
);
|
|
7635
|
+
} else {
|
|
7636
|
+
prepareIntentDefinitionForIntentMapTask.then(
|
|
7637
|
+
restoreIntentToTaskMapPayloadTask
|
|
7638
|
+
);
|
|
7639
|
+
}
|
|
7640
|
+
wireSyncTaskGraph(
|
|
7641
|
+
restoreIntentToTaskMapPayloadTask,
|
|
7642
|
+
intentToTaskMapGraph,
|
|
7643
|
+
registerIntentTask
|
|
7625
7644
|
);
|
|
7626
7645
|
this.registerTaskMapTask = CadenzaService.createMetaTask(
|
|
7627
7646
|
"Register task map to DB",
|
|
@@ -7657,39 +7676,45 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7657
7676
|
};
|
|
7658
7677
|
}
|
|
7659
7678
|
}
|
|
7660
|
-
)
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
}
|
|
7677
|
-
}
|
|
7678
|
-
},
|
|
7679
|
-
{ concurrency: 30 }
|
|
7680
|
-
)?.then(
|
|
7681
|
-
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
7682
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7683
|
-
return;
|
|
7679
|
+
);
|
|
7680
|
+
const taskMapRegistrationGraph = resolveSyncInsertTask(
|
|
7681
|
+
this.isCadenzaDBReady,
|
|
7682
|
+
"directional_task_graph_map",
|
|
7683
|
+
{
|
|
7684
|
+
onConflict: {
|
|
7685
|
+
target: [
|
|
7686
|
+
"task_name",
|
|
7687
|
+
"predecessor_task_name",
|
|
7688
|
+
"task_version",
|
|
7689
|
+
"predecessor_task_version",
|
|
7690
|
+
"service_name",
|
|
7691
|
+
"predecessor_service_name"
|
|
7692
|
+
],
|
|
7693
|
+
action: {
|
|
7694
|
+
do: "nothing"
|
|
7684
7695
|
}
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7696
|
+
}
|
|
7697
|
+
},
|
|
7698
|
+
{ concurrency: 30 }
|
|
7699
|
+
);
|
|
7700
|
+
const recordTaskMapRegistrationTask = CadenzaService.createMetaTask(
|
|
7701
|
+
"Record task map registration",
|
|
7702
|
+
(ctx) => {
|
|
7703
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7704
|
+
return;
|
|
7705
|
+
}
|
|
7706
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7707
|
+
delayMs: 3e3
|
|
7708
|
+
});
|
|
7709
|
+
CadenzaService.get(ctx.__taskName)?.taskMapRegistration.add(
|
|
7710
|
+
ctx.__nextTaskName
|
|
7711
|
+
);
|
|
7712
|
+
}
|
|
7713
|
+
);
|
|
7714
|
+
wireSyncTaskGraph(
|
|
7715
|
+
this.registerTaskMapTask,
|
|
7716
|
+
taskMapRegistrationGraph,
|
|
7717
|
+
recordTaskMapRegistrationTask
|
|
7693
7718
|
);
|
|
7694
7719
|
this.registerDeputyRelationshipTask = CadenzaService.createMetaTask(
|
|
7695
7720
|
"Register deputy relationship",
|
|
@@ -7716,40 +7741,43 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7716
7741
|
};
|
|
7717
7742
|
}
|
|
7718
7743
|
}
|
|
7719
|
-
)
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
}
|
|
7736
|
-
}
|
|
7737
|
-
},
|
|
7738
|
-
{ concurrency: 30 }
|
|
7739
|
-
)?.then(
|
|
7740
|
-
CadenzaService.createMetaTask(
|
|
7741
|
-
"Record deputy relationship registration",
|
|
7742
|
-
(ctx) => {
|
|
7743
|
-
if (!didSyncInsertSucceed(ctx)) {
|
|
7744
|
-
return;
|
|
7745
|
-
}
|
|
7746
|
-
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7747
|
-
delayMs: 3e3
|
|
7748
|
-
});
|
|
7749
|
-
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
7744
|
+
);
|
|
7745
|
+
const deputyRelationshipRegistrationGraph = resolveSyncInsertTask(
|
|
7746
|
+
this.isCadenzaDBReady,
|
|
7747
|
+
"directional_task_graph_map",
|
|
7748
|
+
{
|
|
7749
|
+
onConflict: {
|
|
7750
|
+
target: [
|
|
7751
|
+
"task_name",
|
|
7752
|
+
"predecessor_task_name",
|
|
7753
|
+
"task_version",
|
|
7754
|
+
"predecessor_task_version",
|
|
7755
|
+
"service_name",
|
|
7756
|
+
"predecessor_service_name"
|
|
7757
|
+
],
|
|
7758
|
+
action: {
|
|
7759
|
+
do: "nothing"
|
|
7750
7760
|
}
|
|
7751
|
-
|
|
7752
|
-
|
|
7761
|
+
}
|
|
7762
|
+
},
|
|
7763
|
+
{ concurrency: 30 }
|
|
7764
|
+
);
|
|
7765
|
+
const recordDeputyRelationshipRegistrationTask = CadenzaService.createMetaTask(
|
|
7766
|
+
"Record deputy relationship registration",
|
|
7767
|
+
(ctx) => {
|
|
7768
|
+
if (!didSyncInsertSucceed(ctx)) {
|
|
7769
|
+
return;
|
|
7770
|
+
}
|
|
7771
|
+
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
7772
|
+
delayMs: 3e3
|
|
7773
|
+
});
|
|
7774
|
+
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
7775
|
+
}
|
|
7776
|
+
);
|
|
7777
|
+
wireSyncTaskGraph(
|
|
7778
|
+
this.registerDeputyRelationshipTask,
|
|
7779
|
+
deputyRelationshipRegistrationGraph,
|
|
7780
|
+
recordDeputyRelationshipRegistrationTask
|
|
7753
7781
|
);
|
|
7754
7782
|
const reconcileTaskRegistrationFromAuthorityTask = CadenzaService.createMetaTask(
|
|
7755
7783
|
"Reconcile task registration from authority",
|
|
@@ -7881,7 +7909,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7881
7909
|
isHidden: true
|
|
7882
7910
|
}
|
|
7883
7911
|
);
|
|
7884
|
-
const
|
|
7912
|
+
const skipAuthoritativeTaskReconciliationTask = CadenzaService.createMetaTask(
|
|
7885
7913
|
"Skip authoritative task reconciliation",
|
|
7886
7914
|
() => false,
|
|
7887
7915
|
"Skips task reconciliation when no authority query task is available.",
|
|
@@ -7890,7 +7918,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7890
7918
|
isHidden: true
|
|
7891
7919
|
}
|
|
7892
7920
|
);
|
|
7893
|
-
const
|
|
7921
|
+
const skipAuthoritativeRoutineReconciliationTask = CadenzaService.createMetaTask(
|
|
7894
7922
|
"Skip authoritative routine reconciliation",
|
|
7895
7923
|
() => false,
|
|
7896
7924
|
"Skips routine reconciliation when no authority query task is available.",
|
|
@@ -7899,7 +7927,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7899
7927
|
isHidden: true
|
|
7900
7928
|
}
|
|
7901
7929
|
);
|
|
7902
|
-
const
|
|
7930
|
+
const skipAuthoritativeSignalReconciliationTask = CadenzaService.createMetaTask(
|
|
7903
7931
|
"Skip authoritative signal reconciliation",
|
|
7904
7932
|
() => false,
|
|
7905
7933
|
"Skips signal reconciliation when no authority query task is available.",
|
|
@@ -7908,7 +7936,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7908
7936
|
isHidden: true
|
|
7909
7937
|
}
|
|
7910
7938
|
);
|
|
7911
|
-
const
|
|
7939
|
+
const skipAuthoritativeIntentReconciliationTask = CadenzaService.createMetaTask(
|
|
7912
7940
|
"Skip authoritative intent reconciliation",
|
|
7913
7941
|
() => false,
|
|
7914
7942
|
"Skips intent reconciliation when no authority query task is available.",
|
|
@@ -7917,6 +7945,26 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7917
7945
|
isHidden: true
|
|
7918
7946
|
}
|
|
7919
7947
|
);
|
|
7948
|
+
if (authoritativeTaskQueryGraph) {
|
|
7949
|
+
authoritativeTaskQueryGraph.completionTask.then(
|
|
7950
|
+
reconcileTaskRegistrationFromAuthorityTask
|
|
7951
|
+
);
|
|
7952
|
+
}
|
|
7953
|
+
if (authoritativeRoutineQueryGraph) {
|
|
7954
|
+
authoritativeRoutineQueryGraph.completionTask.then(
|
|
7955
|
+
reconcileRoutineRegistrationFromAuthorityTask
|
|
7956
|
+
);
|
|
7957
|
+
}
|
|
7958
|
+
if (authoritativeSignalQueryGraph) {
|
|
7959
|
+
authoritativeSignalQueryGraph.completionTask.then(
|
|
7960
|
+
reconcileSignalRegistrationFromAuthorityTask
|
|
7961
|
+
);
|
|
7962
|
+
}
|
|
7963
|
+
if (authoritativeIntentQueryGraph) {
|
|
7964
|
+
authoritativeIntentQueryGraph.completionTask.then(
|
|
7965
|
+
reconcileIntentRegistrationFromAuthorityTask
|
|
7966
|
+
);
|
|
7967
|
+
}
|
|
7920
7968
|
const authoritativeRegistrationTriggers = [
|
|
7921
7969
|
"meta.service_registry.initial_sync_complete",
|
|
7922
7970
|
"meta.sync_requested",
|
|
@@ -7949,7 +7997,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7949
7997
|
register: false,
|
|
7950
7998
|
isHidden: true
|
|
7951
7999
|
}
|
|
7952
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8000
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8001
|
+
authoritativeTaskQueryGraph?.entryTask ?? skipAuthoritativeTaskReconciliationTask
|
|
8002
|
+
);
|
|
7953
8003
|
CadenzaService.createMetaTask(
|
|
7954
8004
|
"Prepare authoritative routine registration query",
|
|
7955
8005
|
(ctx) => {
|
|
@@ -7976,7 +8026,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7976
8026
|
register: false,
|
|
7977
8027
|
isHidden: true
|
|
7978
8028
|
}
|
|
7979
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8029
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8030
|
+
authoritativeRoutineQueryGraph?.entryTask ?? skipAuthoritativeRoutineReconciliationTask
|
|
8031
|
+
);
|
|
7980
8032
|
CadenzaService.createMetaTask(
|
|
7981
8033
|
"Prepare authoritative signal registration query",
|
|
7982
8034
|
(ctx) => {
|
|
@@ -7995,7 +8047,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7995
8047
|
register: false,
|
|
7996
8048
|
isHidden: true
|
|
7997
8049
|
}
|
|
7998
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8050
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8051
|
+
authoritativeSignalQueryGraph?.entryTask ?? skipAuthoritativeSignalReconciliationTask
|
|
8052
|
+
);
|
|
7999
8053
|
CadenzaService.createMetaTask(
|
|
8000
8054
|
"Prepare authoritative intent registration query",
|
|
8001
8055
|
(ctx) => {
|
|
@@ -8014,7 +8068,9 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
8014
8068
|
register: false,
|
|
8015
8069
|
isHidden: true
|
|
8016
8070
|
}
|
|
8017
|
-
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8071
|
+
).doOn(...authoritativeRegistrationTriggers).then(
|
|
8072
|
+
authoritativeIntentQueryGraph?.entryTask ?? skipAuthoritativeIntentReconciliationTask
|
|
8073
|
+
);
|
|
8018
8074
|
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
8019
8075
|
"meta.sync_controller.sync_tick",
|
|
8020
8076
|
"meta.service_registry.initial_sync_complete",
|
|
@@ -8449,7 +8505,7 @@ var CadenzaService = class {
|
|
|
8449
8505
|
).map((transport) => ({
|
|
8450
8506
|
...transport,
|
|
8451
8507
|
protocols: transport.protocols && transport.protocols.length > 0 ? transport.protocols : useSocket ? ["rest", "socket"] : ["rest"],
|
|
8452
|
-
uuid: (0,
|
|
8508
|
+
uuid: (0, import_uuid5.v4)()
|
|
8453
8509
|
}));
|
|
8454
8510
|
}
|
|
8455
8511
|
static createBootstrapTransport(serviceInstanceId, role, endpoint) {
|
|
@@ -8701,7 +8757,7 @@ var CadenzaService = class {
|
|
|
8701
8757
|
}
|
|
8702
8758
|
for (const responder of responders) {
|
|
8703
8759
|
const { task, descriptor } = responder;
|
|
8704
|
-
const inquiryId = (0,
|
|
8760
|
+
const inquiryId = (0, import_uuid5.v4)();
|
|
8705
8761
|
startTimeByTask.set(task, Date.now());
|
|
8706
8762
|
const resolverTask = this.createEphemeralMetaTask(
|
|
8707
8763
|
`Resolve inquiry ${inquiry} for ${descriptor.localTaskName}`,
|
|
@@ -9209,7 +9265,7 @@ var CadenzaService = class {
|
|
|
9209
9265
|
this.bootstrap();
|
|
9210
9266
|
this.validateName(serviceName);
|
|
9211
9267
|
this.validateServiceName(serviceName);
|
|
9212
|
-
const serviceId = options.customServiceId ?? (0,
|
|
9268
|
+
const serviceId = options.customServiceId ?? (0, import_uuid5.v4)();
|
|
9213
9269
|
this.serviceRegistry.serviceName = serviceName;
|
|
9214
9270
|
this.serviceRegistry.serviceInstanceId = serviceId;
|
|
9215
9271
|
this.setHydrationResults(options.hydration);
|
|
@@ -10054,7 +10110,7 @@ CadenzaService.frontendSyncScheduled = false;
|
|
|
10054
10110
|
var import_core6 = require("@cadenza.io/core");
|
|
10055
10111
|
|
|
10056
10112
|
// src/ssr/createSSRInquiryBridge.ts
|
|
10057
|
-
var
|
|
10113
|
+
var import_uuid6 = require("uuid");
|
|
10058
10114
|
function ensureFetch() {
|
|
10059
10115
|
if (typeof globalThis.fetch !== "function") {
|
|
10060
10116
|
throw new Error("SSR inquiry bridge requires global fetch support.");
|
|
@@ -10143,7 +10199,7 @@ function createSSRInquiryBridge(options = {}) {
|
|
|
10143
10199
|
__remoteRoutineName: remoteRoutineName,
|
|
10144
10200
|
__metadata: {
|
|
10145
10201
|
...context.__metadata ?? {},
|
|
10146
|
-
__deputyExecId: (0,
|
|
10202
|
+
__deputyExecId: (0, import_uuid6.v4)()
|
|
10147
10203
|
}
|
|
10148
10204
|
}),
|
|
10149
10205
|
signal
|