@cadenza.io/service 2.19.1 → 2.20.1
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/{Cadenza-DCMs7q97.d.mts → Cadenza-Duj65Skt.d.mts} +135 -2
- package/dist/{Cadenza-DCMs7q97.d.ts → Cadenza-Duj65Skt.d.ts} +135 -2
- package/dist/browser/index.js +1213 -200
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1157 -144
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.d.mts +4 -130
- package/dist/index.d.ts +4 -130
- package/dist/index.js +1415 -244
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1363 -192
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt/index.d.mts +2 -2
- package/dist/nuxt/index.d.ts +2 -2
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/vue/index.d.mts +2 -2
- package/dist/vue/index.d.ts +2 -2
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -39,15 +39,15 @@ __export(src_exports, {
|
|
|
39
39
|
AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_TASK_NAME: () => AUTHORITY_SERVICE_INSTANCE_TRANSPORT_REGISTER_TASK_NAME,
|
|
40
40
|
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT: () => AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
41
41
|
AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL: () => AUTHORITY_SERVICE_MANIFEST_UPDATED_SIGNAL,
|
|
42
|
-
Actor: () =>
|
|
42
|
+
Actor: () => import_core7.Actor,
|
|
43
43
|
DatabaseController: () => DatabaseController,
|
|
44
44
|
DatabaseTask: () => DatabaseTask,
|
|
45
|
-
DebounceTask: () =>
|
|
45
|
+
DebounceTask: () => import_core7.DebounceTask,
|
|
46
46
|
DeputyTask: () => DeputyTask,
|
|
47
47
|
EXECUTION_PERSISTENCE_BUNDLE_SIGNAL: () => EXECUTION_PERSISTENCE_BUNDLE_SIGNAL,
|
|
48
|
-
EphemeralTask: () =>
|
|
48
|
+
EphemeralTask: () => import_core7.EphemeralTask,
|
|
49
49
|
GraphMetadataController: () => GraphMetadataController,
|
|
50
|
-
GraphRoutine: () =>
|
|
50
|
+
GraphRoutine: () => import_core7.GraphRoutine,
|
|
51
51
|
RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL: () => RUNTIME_STATUS_AUTHORITY_SYNC_REQUESTED_SIGNAL,
|
|
52
52
|
RUNTIME_VALIDATION_INTENTS: () => RUNTIME_VALIDATION_INTENTS,
|
|
53
53
|
RUNTIME_VALIDATION_SIGNALS: () => RUNTIME_VALIDATION_SIGNALS,
|
|
@@ -56,7 +56,7 @@ __export(src_exports, {
|
|
|
56
56
|
SignalController: () => SignalController,
|
|
57
57
|
SignalTransmissionTask: () => SignalTransmissionTask,
|
|
58
58
|
SocketController: () => SocketController,
|
|
59
|
-
Task: () =>
|
|
59
|
+
Task: () => import_core7.Task,
|
|
60
60
|
buildAuthorityRuntimeStatusSignature: () => buildAuthorityRuntimeStatusSignature,
|
|
61
61
|
buildExecutionPersistenceDependency: () => buildExecutionPersistenceDependency,
|
|
62
62
|
buildExecutionPersistenceEnsureEvent: () => buildExecutionPersistenceEnsureEvent,
|
|
@@ -87,7 +87,7 @@ __export(src_exports, {
|
|
|
87
87
|
module.exports = __toCommonJS(src_exports);
|
|
88
88
|
|
|
89
89
|
// src/Cadenza.ts
|
|
90
|
-
var
|
|
90
|
+
var import_core6 = __toESM(require("@cadenza.io/core"));
|
|
91
91
|
|
|
92
92
|
// src/graph/definition/DeputyTask.ts
|
|
93
93
|
var import_uuid2 = require("uuid");
|
|
@@ -163,14 +163,55 @@ var ROOT_METADATA_PASSTHROUGH_KEYS = [
|
|
|
163
163
|
"__inquirySourceRoutineExecutionId"
|
|
164
164
|
];
|
|
165
165
|
var DELEGATION_REQUEST_SNAPSHOT_KEY = "__delegationRequestContext";
|
|
166
|
+
var DELEGATION_FAILURE_CONTEXT_KEYS = [
|
|
167
|
+
"__remoteRoutineName",
|
|
168
|
+
"__serviceName",
|
|
169
|
+
"__timeout",
|
|
170
|
+
"__localTaskName",
|
|
171
|
+
"__localTaskVersion",
|
|
172
|
+
"__localServiceName",
|
|
173
|
+
"__localRoutineExecId",
|
|
174
|
+
"__previousTaskExecutionId",
|
|
175
|
+
"__fetchId",
|
|
176
|
+
"fetchId",
|
|
177
|
+
"__routeKey",
|
|
178
|
+
"routeKey",
|
|
179
|
+
"__instance",
|
|
180
|
+
"__transportId",
|
|
181
|
+
"__transportOrigin",
|
|
182
|
+
"__transportProtocols",
|
|
183
|
+
"__transportProtocol",
|
|
184
|
+
"__retries",
|
|
185
|
+
"__triedInstances",
|
|
186
|
+
"__delegationRequestContext",
|
|
187
|
+
"__metadata",
|
|
188
|
+
"serviceName",
|
|
189
|
+
"serviceInstanceId",
|
|
190
|
+
"serviceTransportId",
|
|
191
|
+
"serviceOrigin",
|
|
192
|
+
"transportProtocols",
|
|
193
|
+
"transportProtocol"
|
|
194
|
+
];
|
|
195
|
+
function isPlainObject(value) {
|
|
196
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
const prototype = Object.getPrototypeOf(value);
|
|
200
|
+
return prototype === Object.prototype || prototype === null;
|
|
201
|
+
}
|
|
166
202
|
function cloneDelegationValue(value) {
|
|
203
|
+
if (value instanceof Date) {
|
|
204
|
+
return new Date(value.getTime());
|
|
205
|
+
}
|
|
167
206
|
if (Array.isArray(value)) {
|
|
168
|
-
return value.map(
|
|
169
|
-
(item) => item && typeof item === "object" ? { ...item } : item
|
|
170
|
-
);
|
|
207
|
+
return value.map((item) => cloneDelegationValue(item));
|
|
171
208
|
}
|
|
172
|
-
if (value
|
|
173
|
-
|
|
209
|
+
if (isPlainObject(value)) {
|
|
210
|
+
const clone = {};
|
|
211
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
212
|
+
clone[key] = cloneDelegationValue(nestedValue);
|
|
213
|
+
}
|
|
214
|
+
return clone;
|
|
174
215
|
}
|
|
175
216
|
return value;
|
|
176
217
|
}
|
|
@@ -206,9 +247,9 @@ function attachDelegationRequestSnapshot(input) {
|
|
|
206
247
|
function restoreDelegationRequestSnapshot(input) {
|
|
207
248
|
const context = input && typeof input === "object" ? { ...input } : {};
|
|
208
249
|
const mutableContext = context;
|
|
209
|
-
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
250
|
+
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY] ?? (mutableContext.__metadata && typeof mutableContext.__metadata === "object" ? mutableContext.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] : void 0);
|
|
210
251
|
const snapshot = snapshotCandidate && typeof snapshotCandidate === "object" ? snapshotCandidate : null;
|
|
211
|
-
const looksLikeDelegationResult = mutableContext.__status !== void 0 || mutableContext.__success !== void 0 || mutableContext.rowCount !== void 0 || mutableContext.__nextNodes !== void 0 || mutableContext.__isDeputy === true;
|
|
252
|
+
const looksLikeDelegationResult = mutableContext.__status !== void 0 || mutableContext.__success !== void 0 || mutableContext.rowCount !== void 0 || mutableContext.__nextNodes !== void 0 || mutableContext.__isDeputy === true || mutableContext.errored === true || mutableContext.failed === true || mutableContext.timedOut === true || mutableContext.__error !== void 0 || mutableContext.error !== void 0 || mutableContext.__inquiryMeta !== void 0;
|
|
212
253
|
if (!snapshot || !looksLikeDelegationResult) {
|
|
213
254
|
return context;
|
|
214
255
|
}
|
|
@@ -229,6 +270,26 @@ function stripDelegationRequestSnapshot(input) {
|
|
|
229
270
|
delete context[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
230
271
|
return context;
|
|
231
272
|
}
|
|
273
|
+
function buildDelegationFailureContext(signalName, input, error) {
|
|
274
|
+
const source = input && typeof input === "object" ? { ...input } : {};
|
|
275
|
+
const slimContext = {};
|
|
276
|
+
for (const key of DELEGATION_FAILURE_CONTEXT_KEYS) {
|
|
277
|
+
if (source[key] !== void 0) {
|
|
278
|
+
slimContext[key] = cloneDelegationValue(source[key]);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] === void 0 && source.__metadata && typeof source.__metadata === "object" && source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] !== void 0) {
|
|
282
|
+
slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] = cloneDelegationValue(
|
|
283
|
+
source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY]
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
__signalName: signalName,
|
|
288
|
+
__error: error instanceof Error ? error.message : String(error ?? "Unknown error"),
|
|
289
|
+
errored: true,
|
|
290
|
+
...slimContext
|
|
291
|
+
};
|
|
292
|
+
}
|
|
232
293
|
function stripTransportSelectionRoutingContext(input) {
|
|
233
294
|
const context = stripLocalRoutinePersistenceHints(
|
|
234
295
|
input && typeof input === "object" ? { ...input } : {}
|
|
@@ -448,6 +509,8 @@ var DeputyTask = class extends import_core.Task {
|
|
|
448
509
|
|
|
449
510
|
// src/graph/definition/DatabaseTask.ts
|
|
450
511
|
var ACTOR_SESSION_TRACE_ENABLED = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
512
|
+
var actorSessionEmptyDelegationLogCount = 0;
|
|
513
|
+
var ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT = 40;
|
|
451
514
|
var INSTANCE_TRACE_ENABLED = process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true";
|
|
452
515
|
var EXECUTION_OBSERVABILITY_INSERT_ROUTINES = /* @__PURE__ */ new Set([
|
|
453
516
|
"Insert execution_trace",
|
|
@@ -549,15 +612,16 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
549
612
|
}
|
|
550
613
|
delete ctx.__metadata;
|
|
551
614
|
const isResolverExecution = typeof ctx.__resolverRequestId === "string" && ctx.__resolverRequestId.length > 0;
|
|
552
|
-
const
|
|
615
|
+
const resolverQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : null;
|
|
616
|
+
const dynamicQueryData = resolverQueryData ?? (ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {});
|
|
553
617
|
delete ctx.queryData;
|
|
554
618
|
const nextQueryData = {
|
|
555
619
|
...this.queryData,
|
|
556
|
-
data: {
|
|
557
|
-
...ctx.data
|
|
558
|
-
},
|
|
559
620
|
...dynamicQueryData
|
|
560
621
|
};
|
|
622
|
+
if (dynamicQueryData.data === void 0 && ctx.data !== void 0) {
|
|
623
|
+
nextQueryData.data = ctx.data && typeof ctx.data === "object" && !Array.isArray(ctx.data) ? { ...ctx.data } : ctx.data;
|
|
624
|
+
}
|
|
561
625
|
const deputyContext = attachDelegationRequestSnapshot(
|
|
562
626
|
stripDelegationRequestSnapshot(
|
|
563
627
|
hoistDelegationMetadataFields({
|
|
@@ -617,6 +681,22 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
617
681
|
rootKeys: Object.keys(rawContext)
|
|
618
682
|
});
|
|
619
683
|
}
|
|
684
|
+
if (this.remoteRoutineName === "Insert actor_session_state" && deputyContext.data === void 0 && deputyContext.queryData === void 0 && actorSessionEmptyDelegationLogCount < ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT) {
|
|
685
|
+
actorSessionEmptyDelegationLogCount += 1;
|
|
686
|
+
console.warn("[CADENZA_ACTOR_SESSION_EMPTY_DELEGATION]", {
|
|
687
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
688
|
+
localTaskName: this.name,
|
|
689
|
+
remoteRoutineName: this.remoteRoutineName,
|
|
690
|
+
hadSnapshotBeforeRestore: initialFullContext.__delegationRequestContext !== void 0 || initialFullContext.__metadata?.__delegationRequestContext !== void 0,
|
|
691
|
+
restoredRootKeys: Object.keys(rawContext),
|
|
692
|
+
deputyRootKeys: Object.keys(deputyContext),
|
|
693
|
+
signalName: rawContext.__signalName ?? rawContext.__metadata?.__signalName ?? null,
|
|
694
|
+
inquiryName: rawContext.__inquiryName ?? rawContext.__metadata?.__inquiryName ?? null,
|
|
695
|
+
sourceServiceName: rawContext.__localServiceName ?? rawContext.__metadata?.__localServiceName ?? null,
|
|
696
|
+
sourceRoutineName: rawContext.__routineName ?? rawContext.__metadata?.__routineName ?? null,
|
|
697
|
+
sourceTaskName: rawContext.__localTaskName ?? rawContext.__metadata?.__localTaskName ?? null
|
|
698
|
+
});
|
|
699
|
+
}
|
|
620
700
|
return this.taskFunction(deputyContext, emit2, inquire, progressCallback);
|
|
621
701
|
}
|
|
622
702
|
};
|
|
@@ -656,14 +736,14 @@ var META_INTENT_PREFIX = "meta-";
|
|
|
656
736
|
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
657
737
|
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
658
738
|
var META_READINESS_INTENT = "meta-readiness";
|
|
659
|
-
function
|
|
739
|
+
function isPlainObject2(value) {
|
|
660
740
|
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
661
741
|
}
|
|
662
742
|
function deepMergeDeterministic(left, right) {
|
|
663
743
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
664
744
|
return [...left, ...right];
|
|
665
745
|
}
|
|
666
|
-
if (
|
|
746
|
+
if (isPlainObject2(left) && isPlainObject2(right)) {
|
|
667
747
|
const merged = { ...left };
|
|
668
748
|
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
669
749
|
for (const key of keys) {
|
|
@@ -1485,6 +1565,7 @@ function normalizeServiceManifestSnapshot(input) {
|
|
|
1485
1565
|
revision,
|
|
1486
1566
|
manifestHash,
|
|
1487
1567
|
publishedAt,
|
|
1568
|
+
publicationLayer: record.publicationLayer === "routing_capability" || record.publicationLayer === "business_structural" || record.publicationLayer === "local_meta_structural" ? record.publicationLayer : "business_structural",
|
|
1488
1569
|
tasks: normalizeArray(record.tasks),
|
|
1489
1570
|
signals: normalizeArray(record.signals),
|
|
1490
1571
|
intents: normalizeArray(record.intents),
|
|
@@ -1614,6 +1695,7 @@ function decomposeSignalName(signalName) {
|
|
|
1614
1695
|
}
|
|
1615
1696
|
|
|
1616
1697
|
// src/registry/serviceManifest.ts
|
|
1698
|
+
var import_core2 = __toESM(require("@cadenza.io/core"));
|
|
1617
1699
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
1618
1700
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
1619
1701
|
if (typeof taskFunction !== "function") {
|
|
@@ -1758,14 +1840,48 @@ function buildRoutineDefinition(routine, serviceName) {
|
|
|
1758
1840
|
};
|
|
1759
1841
|
}
|
|
1760
1842
|
function shouldExportTask(task) {
|
|
1761
|
-
return !task.isDeputy && !task.isEphemeral;
|
|
1843
|
+
return task.register !== false && task.isHidden !== true && !task.isDeputy && !task.isEphemeral;
|
|
1762
1844
|
}
|
|
1763
1845
|
function shouldExportRoutine(routine) {
|
|
1764
1846
|
return Boolean(String(routine?.name ?? "").trim());
|
|
1765
1847
|
}
|
|
1848
|
+
function buildTaskKey(task) {
|
|
1849
|
+
return `${task.service_name}|${task.name}|${task.version}`;
|
|
1850
|
+
}
|
|
1851
|
+
function buildActorKey(actor) {
|
|
1852
|
+
return `${actor.service_name}|${actor.name}|${actor.version}`;
|
|
1853
|
+
}
|
|
1854
|
+
function buildRoutineKey(routine) {
|
|
1855
|
+
return `${routine.service_name}|${routine.name}|${routine.version}`;
|
|
1856
|
+
}
|
|
1857
|
+
function listManifestTasks() {
|
|
1858
|
+
const registryTasks = Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
1859
|
+
(task) => Boolean(task)
|
|
1860
|
+
);
|
|
1861
|
+
const cachedTasks = Array.from(
|
|
1862
|
+
import_core2.default.taskCache?.values?.() ?? []
|
|
1863
|
+
).filter((task) => Boolean(task));
|
|
1864
|
+
return Array.from(
|
|
1865
|
+
new Map(
|
|
1866
|
+
[...registryTasks, ...cachedTasks].map((task) => [task.name, task])
|
|
1867
|
+
).values()
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
function isRoutingCriticalMetaSignal(_signal) {
|
|
1871
|
+
return false;
|
|
1872
|
+
}
|
|
1873
|
+
function isRoutingCriticalMetaIntent(_intent) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1766
1876
|
function buildServiceManifestSnapshot(params) {
|
|
1767
|
-
const {
|
|
1768
|
-
|
|
1877
|
+
const {
|
|
1878
|
+
serviceName,
|
|
1879
|
+
serviceInstanceId,
|
|
1880
|
+
revision,
|
|
1881
|
+
publishedAt,
|
|
1882
|
+
publicationLayer = "business_structural"
|
|
1883
|
+
} = params;
|
|
1884
|
+
const tasks = listManifestTasks().filter(shouldExportTask);
|
|
1769
1885
|
const routines = Array.from(CadenzaService.registry.routines.values()).filter((routine) => Boolean(routine)).filter(shouldExportRoutine);
|
|
1770
1886
|
const actors = CadenzaService.getAllActors();
|
|
1771
1887
|
const taskDefinitions = tasks.map((task) => buildTaskDefinition(task, serviceName)).sort(
|
|
@@ -1913,41 +2029,385 @@ function buildServiceManifestSnapshot(params) {
|
|
|
1913
2029
|
}
|
|
1914
2030
|
}
|
|
1915
2031
|
}
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
)
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2032
|
+
const taskDefinitionsByKey = new Map(
|
|
2033
|
+
taskDefinitions.map((task) => [buildTaskKey(task), task])
|
|
2034
|
+
);
|
|
2035
|
+
const signalDefinitionsByName = new Map(
|
|
2036
|
+
Array.from(signalDefinitions.values()).map((signal) => [signal.name, signal])
|
|
2037
|
+
);
|
|
2038
|
+
const intentDefinitionsByName = new Map(
|
|
2039
|
+
intentDefinitions.map((intent) => [intent.name, intent])
|
|
2040
|
+
);
|
|
2041
|
+
const actorDefinitionsByKey = new Map(
|
|
2042
|
+
actorDefinitions.map((actor) => [buildActorKey(actor), actor])
|
|
2043
|
+
);
|
|
2044
|
+
const routineDefinitionsByKey = new Map(
|
|
2045
|
+
routineDefinitions.map((routine) => [buildRoutineKey(routine), routine])
|
|
2046
|
+
);
|
|
2047
|
+
const routingTaskKeys = /* @__PURE__ */ new Set();
|
|
2048
|
+
const routingSignalNames = /* @__PURE__ */ new Set();
|
|
2049
|
+
const routingIntentNames = /* @__PURE__ */ new Set();
|
|
2050
|
+
const publishedSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => {
|
|
2051
|
+
const signal = signalDefinitionsByName.get(map.signal_name);
|
|
2052
|
+
return signal?.is_meta !== true || (signal ? isRoutingCriticalMetaSignal(signal) : false);
|
|
2053
|
+
}).sort(
|
|
2054
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
2055
|
+
`${right.signal_name}:${right.task_name}`
|
|
2056
|
+
)
|
|
2057
|
+
);
|
|
2058
|
+
const publishedIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => {
|
|
2059
|
+
const intent = intentDefinitionsByName.get(map.intent_name);
|
|
2060
|
+
return intent?.is_meta !== true || (intent ? isRoutingCriticalMetaIntent(intent) : false);
|
|
2061
|
+
}).sort(
|
|
2062
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
2063
|
+
`${right.intent_name}:${right.task_name}`
|
|
2064
|
+
)
|
|
2065
|
+
);
|
|
2066
|
+
const localMetaSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => !publishedSignalTaskMaps.includes(map)).sort(
|
|
2067
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
2068
|
+
`${right.signal_name}:${right.task_name}`
|
|
2069
|
+
)
|
|
2070
|
+
);
|
|
2071
|
+
const localMetaIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => !publishedIntentTaskMaps.includes(map)).sort(
|
|
2072
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
2073
|
+
`${right.intent_name}:${right.task_name}`
|
|
2074
|
+
)
|
|
2075
|
+
);
|
|
2076
|
+
for (const map of publishedSignalTaskMaps) {
|
|
2077
|
+
routingTaskKeys.add(
|
|
2078
|
+
buildTaskKey({
|
|
2079
|
+
service_name: map.service_name,
|
|
2080
|
+
name: map.task_name,
|
|
2081
|
+
version: map.task_version
|
|
2082
|
+
})
|
|
2083
|
+
);
|
|
2084
|
+
routingSignalNames.add(map.signal_name);
|
|
2085
|
+
}
|
|
2086
|
+
for (const map of publishedIntentTaskMaps) {
|
|
2087
|
+
routingTaskKeys.add(
|
|
2088
|
+
buildTaskKey({
|
|
2089
|
+
service_name: map.service_name,
|
|
2090
|
+
name: map.task_name,
|
|
2091
|
+
version: map.task_version
|
|
2092
|
+
})
|
|
2093
|
+
);
|
|
2094
|
+
routingIntentNames.add(map.intent_name);
|
|
2095
|
+
}
|
|
2096
|
+
const routingTasks = Array.from(routingTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter((task) => task !== null).sort(
|
|
2097
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2098
|
+
);
|
|
2099
|
+
const routingSignals = Array.from(routingSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter((signal) => signal !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
2100
|
+
const routingIntents = Array.from(routingIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter((intent) => intent !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
2101
|
+
const businessTasks = taskDefinitions.filter((task) => task.is_meta !== true && task.is_sub_meta !== true).sort(
|
|
2102
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2103
|
+
);
|
|
2104
|
+
const businessSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2105
|
+
const businessIntents = intentDefinitions.filter((intent) => intent.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2106
|
+
const businessActors = actorDefinitions.filter((actor) => actor.is_meta !== true).sort(
|
|
2107
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2108
|
+
);
|
|
2109
|
+
const businessRoutines = routineDefinitions.filter((routine) => routine.is_meta !== true).sort(
|
|
2110
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2111
|
+
);
|
|
2112
|
+
const businessDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => {
|
|
2113
|
+
const predecessor = taskDefinitionsByKey.get(
|
|
2114
|
+
buildTaskKey({
|
|
2115
|
+
service_name: map.predecessor_service_name,
|
|
2116
|
+
name: map.predecessor_task_name,
|
|
2117
|
+
version: map.predecessor_task_version
|
|
2118
|
+
})
|
|
2119
|
+
);
|
|
2120
|
+
const task = taskDefinitionsByKey.get(
|
|
2121
|
+
buildTaskKey({
|
|
2122
|
+
service_name: map.service_name,
|
|
2123
|
+
name: map.task_name,
|
|
2124
|
+
version: map.task_version
|
|
2125
|
+
})
|
|
2126
|
+
);
|
|
2127
|
+
return predecessor?.is_meta !== true && predecessor?.is_sub_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2128
|
+
}).sort(
|
|
2129
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
2130
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
2131
|
+
)
|
|
2132
|
+
);
|
|
2133
|
+
const businessActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => {
|
|
2134
|
+
const actor = actorDefinitionsByKey.get(
|
|
2135
|
+
buildActorKey({
|
|
2136
|
+
service_name: map.service_name,
|
|
2137
|
+
name: map.actor_name,
|
|
2138
|
+
version: map.actor_version
|
|
2139
|
+
})
|
|
2140
|
+
);
|
|
2141
|
+
const task = taskDefinitionsByKey.get(
|
|
2142
|
+
buildTaskKey({
|
|
2143
|
+
service_name: map.service_name,
|
|
2144
|
+
name: map.task_name,
|
|
2145
|
+
version: map.task_version
|
|
2146
|
+
})
|
|
2147
|
+
);
|
|
2148
|
+
return actor?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2149
|
+
}).sort(
|
|
2150
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
2151
|
+
`${right.actor_name}:${right.task_name}`
|
|
2152
|
+
)
|
|
2153
|
+
);
|
|
2154
|
+
const businessTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => {
|
|
2155
|
+
const routine = routineDefinitionsByKey.get(
|
|
2156
|
+
buildRoutineKey({
|
|
2157
|
+
service_name: map.service_name,
|
|
2158
|
+
name: map.routine_name,
|
|
2159
|
+
version: map.routine_version
|
|
2160
|
+
})
|
|
2161
|
+
);
|
|
2162
|
+
const task = taskDefinitionsByKey.get(
|
|
2163
|
+
buildTaskKey({
|
|
2164
|
+
service_name: map.service_name,
|
|
2165
|
+
name: map.task_name,
|
|
2166
|
+
version: map.task_version
|
|
2167
|
+
})
|
|
2168
|
+
);
|
|
2169
|
+
return routine?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
2170
|
+
}).sort(
|
|
2171
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
2172
|
+
`${right.routine_name}:${right.task_name}`
|
|
2173
|
+
)
|
|
2174
|
+
);
|
|
2175
|
+
const localMetaTasks = taskDefinitions.filter((task) => task.is_meta === true || task.is_sub_meta === true).sort(
|
|
2176
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2177
|
+
);
|
|
2178
|
+
const localMetaSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2179
|
+
const localMetaIntents = intentDefinitions.filter((intent) => intent.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
2180
|
+
const localMetaActors = actorDefinitions.filter((actor) => actor.is_meta === true).sort(
|
|
2181
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2182
|
+
);
|
|
2183
|
+
const localMetaRoutines = routineDefinitions.filter((routine) => routine.is_meta === true).sort(
|
|
2184
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2185
|
+
);
|
|
2186
|
+
const localMetaDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => !businessDirectionalTaskMaps.includes(map)).sort(
|
|
2187
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
2188
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
2189
|
+
)
|
|
2190
|
+
);
|
|
2191
|
+
const localMetaActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => !businessActorTaskMaps.includes(map)).sort(
|
|
2192
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
2193
|
+
`${right.actor_name}:${right.task_name}`
|
|
2194
|
+
)
|
|
2195
|
+
);
|
|
2196
|
+
const localMetaTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => !businessTaskToRoutineMaps.includes(map)).sort(
|
|
2197
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
2198
|
+
`${right.routine_name}:${right.task_name}`
|
|
2199
|
+
)
|
|
2200
|
+
);
|
|
2201
|
+
const businessLocalMetaTaskKeys = /* @__PURE__ */ new Set();
|
|
2202
|
+
const businessLocalMetaSignalNames = /* @__PURE__ */ new Set();
|
|
2203
|
+
const businessLocalMetaIntentNames = /* @__PURE__ */ new Set();
|
|
2204
|
+
const businessLocalMetaActorKeys = /* @__PURE__ */ new Set();
|
|
2205
|
+
const businessLocalMetaRoutineKeys = /* @__PURE__ */ new Set();
|
|
2206
|
+
for (const map of localMetaSignalTaskMaps) {
|
|
2207
|
+
businessLocalMetaSignalNames.add(map.signal_name);
|
|
2208
|
+
businessLocalMetaTaskKeys.add(
|
|
2209
|
+
buildTaskKey({
|
|
2210
|
+
service_name: map.service_name,
|
|
2211
|
+
name: map.task_name,
|
|
2212
|
+
version: map.task_version
|
|
2213
|
+
})
|
|
2214
|
+
);
|
|
2215
|
+
}
|
|
2216
|
+
for (const map of localMetaIntentTaskMaps) {
|
|
2217
|
+
businessLocalMetaIntentNames.add(map.intent_name);
|
|
2218
|
+
businessLocalMetaTaskKeys.add(
|
|
2219
|
+
buildTaskKey({
|
|
2220
|
+
service_name: map.service_name,
|
|
2221
|
+
name: map.task_name,
|
|
2222
|
+
version: map.task_version
|
|
2223
|
+
})
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
for (const map of localMetaActorTaskMaps) {
|
|
2227
|
+
businessLocalMetaActorKeys.add(
|
|
2228
|
+
buildActorKey({
|
|
2229
|
+
service_name: map.service_name,
|
|
2230
|
+
name: map.actor_name,
|
|
2231
|
+
version: map.actor_version
|
|
2232
|
+
})
|
|
2233
|
+
);
|
|
2234
|
+
businessLocalMetaTaskKeys.add(
|
|
2235
|
+
buildTaskKey({
|
|
2236
|
+
service_name: map.service_name,
|
|
2237
|
+
name: map.task_name,
|
|
2238
|
+
version: map.task_version
|
|
2239
|
+
})
|
|
2240
|
+
);
|
|
2241
|
+
}
|
|
2242
|
+
for (const map of localMetaTaskToRoutineMaps) {
|
|
2243
|
+
businessLocalMetaRoutineKeys.add(
|
|
2244
|
+
buildRoutineKey({
|
|
2245
|
+
service_name: map.service_name,
|
|
2246
|
+
name: map.routine_name,
|
|
2247
|
+
version: map.routine_version
|
|
2248
|
+
})
|
|
2249
|
+
);
|
|
2250
|
+
businessLocalMetaTaskKeys.add(
|
|
2251
|
+
buildTaskKey({
|
|
2252
|
+
service_name: map.service_name,
|
|
2253
|
+
name: map.task_name,
|
|
2254
|
+
version: map.task_version
|
|
2255
|
+
})
|
|
2256
|
+
);
|
|
2257
|
+
}
|
|
2258
|
+
const businessLocalMetaTasks = Array.from(businessLocalMetaTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter(
|
|
2259
|
+
(task) => task !== null && (task.is_meta === true || task.is_sub_meta === true)
|
|
2260
|
+
).sort(
|
|
2261
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2262
|
+
);
|
|
2263
|
+
const businessLocalMetaSignals = Array.from(businessLocalMetaSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter(
|
|
2264
|
+
(signal) => signal !== null && signal.is_meta === true
|
|
2265
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2266
|
+
const businessLocalMetaIntents = Array.from(businessLocalMetaIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter(
|
|
2267
|
+
(intent) => intent !== null && intent.is_meta === true
|
|
2268
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2269
|
+
const businessLocalMetaActors = Array.from(businessLocalMetaActorKeys).map((key) => actorDefinitionsByKey.get(key) ?? null).filter(
|
|
2270
|
+
(actor) => actor !== null && actor.is_meta === true
|
|
2271
|
+
).sort(
|
|
2272
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2273
|
+
);
|
|
2274
|
+
const businessLocalMetaRoutines = Array.from(businessLocalMetaRoutineKeys).map((key) => routineDefinitionsByKey.get(key) ?? null).filter(
|
|
2275
|
+
(routine) => routine !== null && routine.is_meta === true
|
|
2276
|
+
).sort(
|
|
2277
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2278
|
+
);
|
|
2279
|
+
const cumulativeTasks = publicationLayer === "routing_capability" ? routingTasks : publicationLayer === "business_structural" ? Array.from(
|
|
2280
|
+
new Map(
|
|
2281
|
+
[...routingTasks, ...businessTasks, ...businessLocalMetaTasks].map((task) => [
|
|
2282
|
+
buildTaskKey(task),
|
|
2283
|
+
task
|
|
2284
|
+
])
|
|
2285
|
+
).values()
|
|
2286
|
+
).sort(
|
|
2287
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2288
|
+
) : Array.from(
|
|
2289
|
+
new Map(
|
|
2290
|
+
[...routingTasks, ...businessTasks, ...localMetaTasks].map((task) => [
|
|
2291
|
+
buildTaskKey(task),
|
|
2292
|
+
task
|
|
2293
|
+
])
|
|
2294
|
+
).values()
|
|
2295
|
+
).sort(
|
|
2296
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2297
|
+
);
|
|
2298
|
+
const cumulativeSignals = publicationLayer === "routing_capability" ? routingSignals : publicationLayer === "business_structural" ? Array.from(
|
|
2299
|
+
new Map(
|
|
2300
|
+
[...routingSignals, ...businessSignals, ...businessLocalMetaSignals].map(
|
|
2301
|
+
(signal) => [signal.name, signal]
|
|
1939
2302
|
)
|
|
1940
|
-
)
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
2303
|
+
).values()
|
|
2304
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
2305
|
+
new Map(
|
|
2306
|
+
[...routingSignals, ...businessSignals, ...localMetaSignals].map((signal) => [
|
|
2307
|
+
signal.name,
|
|
2308
|
+
signal
|
|
2309
|
+
])
|
|
2310
|
+
).values()
|
|
2311
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2312
|
+
const cumulativeIntents = publicationLayer === "routing_capability" ? routingIntents : publicationLayer === "business_structural" ? Array.from(
|
|
2313
|
+
new Map(
|
|
2314
|
+
[...routingIntents, ...businessIntents, ...businessLocalMetaIntents].map(
|
|
2315
|
+
(intent) => [intent.name, intent]
|
|
1944
2316
|
)
|
|
1945
|
-
)
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2317
|
+
).values()
|
|
2318
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
2319
|
+
new Map(
|
|
2320
|
+
[...routingIntents, ...businessIntents, ...localMetaIntents].map((intent) => [
|
|
2321
|
+
intent.name,
|
|
2322
|
+
intent
|
|
2323
|
+
])
|
|
2324
|
+
).values()
|
|
2325
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
2326
|
+
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2327
|
+
new Map(
|
|
2328
|
+
[...businessActors, ...businessLocalMetaActors].map((actor) => [
|
|
2329
|
+
buildActorKey(actor),
|
|
2330
|
+
actor
|
|
2331
|
+
])
|
|
2332
|
+
).values()
|
|
2333
|
+
).sort(
|
|
2334
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2335
|
+
) : Array.from(
|
|
2336
|
+
new Map(
|
|
2337
|
+
[...businessActors, ...localMetaActors].map((actor) => [
|
|
2338
|
+
buildActorKey(actor),
|
|
2339
|
+
actor
|
|
2340
|
+
])
|
|
2341
|
+
).values()
|
|
2342
|
+
).sort(
|
|
2343
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2344
|
+
);
|
|
2345
|
+
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2346
|
+
new Map(
|
|
2347
|
+
[...businessRoutines, ...businessLocalMetaRoutines].map((routine) => [
|
|
2348
|
+
buildRoutineKey(routine),
|
|
2349
|
+
routine
|
|
2350
|
+
])
|
|
2351
|
+
).values()
|
|
2352
|
+
).sort(
|
|
2353
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2354
|
+
) : Array.from(
|
|
2355
|
+
new Map(
|
|
2356
|
+
[...businessRoutines, ...localMetaRoutines].map((routine) => [
|
|
2357
|
+
buildRoutineKey(routine),
|
|
2358
|
+
routine
|
|
2359
|
+
])
|
|
2360
|
+
).values()
|
|
2361
|
+
).sort(
|
|
2362
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
2363
|
+
);
|
|
2364
|
+
const cumulativeDirectionalTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessDirectionalTaskMaps : Array.from(
|
|
2365
|
+
new Map(
|
|
2366
|
+
[...businessDirectionalTaskMaps, ...localMetaDirectionalTaskMaps].map(
|
|
2367
|
+
(map) => [
|
|
2368
|
+
`${map.predecessor_service_name}|${map.predecessor_task_name}|${map.predecessor_task_version}|${map.service_name}|${map.task_name}|${map.task_version}`,
|
|
2369
|
+
map
|
|
2370
|
+
]
|
|
1949
2371
|
)
|
|
1950
|
-
)
|
|
2372
|
+
).values()
|
|
2373
|
+
);
|
|
2374
|
+
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
2375
|
+
new Map(
|
|
2376
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2377
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
2378
|
+
map
|
|
2379
|
+
])
|
|
2380
|
+
).values()
|
|
2381
|
+
) : Array.from(
|
|
2382
|
+
new Map(
|
|
2383
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
2384
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
2385
|
+
map
|
|
2386
|
+
])
|
|
2387
|
+
).values()
|
|
2388
|
+
);
|
|
2389
|
+
const cumulativeTaskToRoutineMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToRoutineMaps : Array.from(
|
|
2390
|
+
new Map(
|
|
2391
|
+
[...businessTaskToRoutineMaps, ...localMetaTaskToRoutineMaps].map((map) => [
|
|
2392
|
+
`${map.service_name}|${map.task_name}|${map.task_version}|${map.routine_name}|${map.routine_version}`,
|
|
2393
|
+
map
|
|
2394
|
+
])
|
|
2395
|
+
).values()
|
|
2396
|
+
);
|
|
2397
|
+
const manifestBody = {
|
|
2398
|
+
serviceName,
|
|
2399
|
+
serviceInstanceId,
|
|
2400
|
+
publicationLayer,
|
|
2401
|
+
tasks: cumulativeTasks,
|
|
2402
|
+
signals: cumulativeSignals,
|
|
2403
|
+
intents: cumulativeIntents,
|
|
2404
|
+
actors: cumulativeActors,
|
|
2405
|
+
routines: cumulativeRoutines,
|
|
2406
|
+
directionalTaskMaps: cumulativeDirectionalTaskMaps,
|
|
2407
|
+
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] : [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps],
|
|
2408
|
+
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] : [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps],
|
|
2409
|
+
actorTaskMaps: cumulativeActorTaskMaps,
|
|
2410
|
+
taskToRoutineMaps: cumulativeTaskToRoutineMaps
|
|
1951
2411
|
};
|
|
1952
2412
|
return {
|
|
1953
2413
|
...manifestBody,
|
|
@@ -2085,7 +2545,7 @@ var SERVICE_REGISTRY_TRACE_SERVICE2 = (process.env.CADENZA_SERVICE_REGISTRY_TRAC
|
|
|
2085
2545
|
function shouldTraceServiceRegistry(serviceName) {
|
|
2086
2546
|
return SERVICE_REGISTRY_TRACE_SERVICE2.length > 0 && serviceName === SERVICE_REGISTRY_TRACE_SERVICE2;
|
|
2087
2547
|
}
|
|
2088
|
-
function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
2548
|
+
function buildServiceRegistryInsertQueryData(tableName, ctx, queryData) {
|
|
2089
2549
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
2090
2550
|
const getJoinedValue = (key) => {
|
|
2091
2551
|
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
@@ -2103,7 +2563,8 @@ function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
|
2103
2563
|
if (!Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
2104
2564
|
delete nextQueryData.onConflict;
|
|
2105
2565
|
}
|
|
2106
|
-
const
|
|
2566
|
+
const preferRegistrationData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
2567
|
+
const resolvedData = preferRegistrationData ? registrationData ?? (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data")) : Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0 ? ctx.data : getJoinedValue("data");
|
|
2107
2568
|
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
2108
2569
|
const nextData = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
2109
2570
|
if (nextData !== void 0) {
|
|
@@ -2130,8 +2591,114 @@ function sanitizeServiceRegistryInsertExecutionContext(ctx) {
|
|
|
2130
2591
|
delete sanitized.returnedValue;
|
|
2131
2592
|
delete sanitized.queryData;
|
|
2132
2593
|
delete sanitized.onConflict;
|
|
2594
|
+
delete sanitized.task;
|
|
2595
|
+
delete sanitized.routine;
|
|
2596
|
+
delete sanitized.httpServer;
|
|
2597
|
+
delete sanitized.service;
|
|
2598
|
+
delete sanitized.serviceInstance;
|
|
2599
|
+
delete sanitized.joinedContexts;
|
|
2600
|
+
delete sanitized.__declaredTransports;
|
|
2601
|
+
delete sanitized.__resolverOriginalContext;
|
|
2602
|
+
delete sanitized.__resolverQueryData;
|
|
2133
2603
|
return sanitized;
|
|
2134
2604
|
}
|
|
2605
|
+
function sanitizeAuthorityBootstrapDelegationContext(ctx) {
|
|
2606
|
+
const sanitized = stripDelegationRequestSnapshot({
|
|
2607
|
+
...ctx
|
|
2608
|
+
});
|
|
2609
|
+
delete sanitized.__resolverOriginalContext;
|
|
2610
|
+
delete sanitized.__resolverQueryData;
|
|
2611
|
+
delete sanitized.joinedContexts;
|
|
2612
|
+
delete sanitized.httpServer;
|
|
2613
|
+
delete sanitized.service;
|
|
2614
|
+
delete sanitized.serviceInstance;
|
|
2615
|
+
delete sanitized.task;
|
|
2616
|
+
delete sanitized.routine;
|
|
2617
|
+
delete sanitized.__declaredTransports;
|
|
2618
|
+
const queryData = sanitized.queryData && typeof sanitized.queryData === "object" ? { ...sanitized.queryData } : null;
|
|
2619
|
+
if (queryData) {
|
|
2620
|
+
delete queryData.joinedContexts;
|
|
2621
|
+
sanitized.queryData = queryData;
|
|
2622
|
+
}
|
|
2623
|
+
return sanitized;
|
|
2624
|
+
}
|
|
2625
|
+
function cloneServiceRegistryContextValue(value) {
|
|
2626
|
+
if (value instanceof Date) {
|
|
2627
|
+
return new Date(value.getTime());
|
|
2628
|
+
}
|
|
2629
|
+
if (Array.isArray(value)) {
|
|
2630
|
+
return value.map(
|
|
2631
|
+
(entry) => cloneServiceRegistryContextValue(entry)
|
|
2632
|
+
);
|
|
2633
|
+
}
|
|
2634
|
+
if (value && typeof value === "object") {
|
|
2635
|
+
const clone = {};
|
|
2636
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
2637
|
+
clone[key] = cloneServiceRegistryContextValue(nestedValue);
|
|
2638
|
+
}
|
|
2639
|
+
return clone;
|
|
2640
|
+
}
|
|
2641
|
+
return value;
|
|
2642
|
+
}
|
|
2643
|
+
function buildServiceRegistryResolverOriginalContext(tableName, ctx, queryData) {
|
|
2644
|
+
const originalContext = {};
|
|
2645
|
+
for (const key of [
|
|
2646
|
+
"__serviceName",
|
|
2647
|
+
"serviceName",
|
|
2648
|
+
"__serviceInstanceId",
|
|
2649
|
+
"serviceInstanceId",
|
|
2650
|
+
"__registrationData",
|
|
2651
|
+
"__reason",
|
|
2652
|
+
"__syncing",
|
|
2653
|
+
"__syncSourceServiceName",
|
|
2654
|
+
"__preferredTransportProtocol",
|
|
2655
|
+
"__networkMode",
|
|
2656
|
+
"__securityProfile",
|
|
2657
|
+
"__loadBalance",
|
|
2658
|
+
"__cadenzaDBConnect",
|
|
2659
|
+
"__isFrontend",
|
|
2660
|
+
"__isDatabase",
|
|
2661
|
+
"__retryCount",
|
|
2662
|
+
"__retries",
|
|
2663
|
+
"__triedInstances"
|
|
2664
|
+
]) {
|
|
2665
|
+
if (ctx[key] !== void 0) {
|
|
2666
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
if (queryData.data !== void 0) {
|
|
2670
|
+
originalContext.data = cloneServiceRegistryContextValue(queryData.data);
|
|
2671
|
+
}
|
|
2672
|
+
if (queryData.batch !== void 0) {
|
|
2673
|
+
originalContext.batch = cloneServiceRegistryContextValue(queryData.batch);
|
|
2674
|
+
}
|
|
2675
|
+
if (Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
2676
|
+
originalContext.queryData = {
|
|
2677
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
2678
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0,
|
|
2679
|
+
onConflict: cloneServiceRegistryContextValue(queryData.onConflict)
|
|
2680
|
+
};
|
|
2681
|
+
} else if (queryData.data !== void 0 || queryData.batch !== void 0) {
|
|
2682
|
+
originalContext.queryData = {
|
|
2683
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
2684
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0
|
|
2685
|
+
};
|
|
2686
|
+
}
|
|
2687
|
+
if (tableName === "service_instance") {
|
|
2688
|
+
for (const key of [
|
|
2689
|
+
"__transportData",
|
|
2690
|
+
"transportData",
|
|
2691
|
+
"__useSocket",
|
|
2692
|
+
"__retryCount",
|
|
2693
|
+
"__isFrontend"
|
|
2694
|
+
]) {
|
|
2695
|
+
if (ctx[key] !== void 0) {
|
|
2696
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
return originalContext;
|
|
2701
|
+
}
|
|
2135
2702
|
function clearTransientRoutingErrorState(context) {
|
|
2136
2703
|
delete context.errored;
|
|
2137
2704
|
delete context.failed;
|
|
@@ -2187,7 +2754,8 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2187
2754
|
delete result.__resolverOriginalContext;
|
|
2188
2755
|
delete result.__resolverQueryData;
|
|
2189
2756
|
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
2190
|
-
const
|
|
2757
|
+
const preferRequestedData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
2758
|
+
const resolvedData = preferRequestedData ? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData ?? result.data : result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
2191
2759
|
if (resolvedData !== void 0 && result.data === void 0) {
|
|
2192
2760
|
result.data = resolvedData;
|
|
2193
2761
|
}
|
|
@@ -2217,6 +2785,7 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2217
2785
|
).trim();
|
|
2218
2786
|
if (resolvedServiceName) {
|
|
2219
2787
|
result.__serviceName = resolvedServiceName;
|
|
2788
|
+
result.serviceName = resolvedServiceName;
|
|
2220
2789
|
}
|
|
2221
2790
|
}
|
|
2222
2791
|
const resolvedLocalServiceInstanceId = String(
|
|
@@ -2225,6 +2794,18 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
2225
2794
|
if (resolvedLocalServiceInstanceId) {
|
|
2226
2795
|
result.__serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
2227
2796
|
}
|
|
2797
|
+
if (tableName === "service_instance") {
|
|
2798
|
+
const resolvedServiceName = String(
|
|
2799
|
+
ctx.__serviceName ?? resolveServiceNameFromContext(ctx) ?? resolvedData?.service_name ?? resolvedData?.serviceName ?? ""
|
|
2800
|
+
).trim();
|
|
2801
|
+
if (resolvedServiceName) {
|
|
2802
|
+
result.__serviceName = resolvedServiceName;
|
|
2803
|
+
result.serviceName = resolvedServiceName;
|
|
2804
|
+
}
|
|
2805
|
+
if (resolvedLocalServiceInstanceId) {
|
|
2806
|
+
result.serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2228
2809
|
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
2229
2810
|
const resolvedUuid = String(
|
|
2230
2811
|
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
@@ -2324,9 +2905,15 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2324
2905
|
ctx
|
|
2325
2906
|
);
|
|
2326
2907
|
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
2908
|
+
tableName,
|
|
2327
2909
|
sanitizedContext,
|
|
2328
2910
|
queryData
|
|
2329
2911
|
);
|
|
2912
|
+
const resolverOriginalContext = buildServiceRegistryResolverOriginalContext(
|
|
2913
|
+
tableName,
|
|
2914
|
+
sanitizedContext,
|
|
2915
|
+
nextQueryData
|
|
2916
|
+
);
|
|
2330
2917
|
const delegationContext = ensureDelegationContextMetadata({
|
|
2331
2918
|
...sanitizedContext,
|
|
2332
2919
|
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
@@ -2339,9 +2926,7 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2339
2926
|
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
2340
2927
|
const nextContext = {
|
|
2341
2928
|
...delegationContext,
|
|
2342
|
-
__resolverOriginalContext:
|
|
2343
|
-
...sanitizedContext
|
|
2344
|
-
},
|
|
2929
|
+
__resolverOriginalContext: resolverOriginalContext,
|
|
2345
2930
|
__resolverQueryData: nextQueryData
|
|
2346
2931
|
};
|
|
2347
2932
|
if (tableName === "service_instance_transport" && shouldTraceServiceRegistry(
|
|
@@ -2513,6 +3098,7 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
2513
3098
|
if (bootstrapAuthorityInsertSpec) {
|
|
2514
3099
|
const sanitizedContext = sanitizeServiceRegistryInsertExecutionContext(ctx);
|
|
2515
3100
|
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
3101
|
+
tableName,
|
|
2516
3102
|
sanitizedContext,
|
|
2517
3103
|
queryData
|
|
2518
3104
|
);
|
|
@@ -2947,6 +3533,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2947
3533
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
2948
3534
|
);
|
|
2949
3535
|
if (uuid9 === this.serviceInstanceId) return;
|
|
3536
|
+
if (serviceName === this.serviceName) {
|
|
3537
|
+
return false;
|
|
3538
|
+
}
|
|
2950
3539
|
if (deleted) {
|
|
2951
3540
|
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid9);
|
|
2952
3541
|
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid9) ?? -1;
|
|
@@ -3033,9 +3622,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3033
3622
|
emit2
|
|
3034
3623
|
);
|
|
3035
3624
|
}
|
|
3036
|
-
if (this.serviceName === serviceName) {
|
|
3037
|
-
return false;
|
|
3038
|
-
}
|
|
3039
3625
|
if (trackedInstance?.isFrontend) {
|
|
3040
3626
|
return true;
|
|
3041
3627
|
}
|
|
@@ -3089,6 +3675,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3089
3675
|
if (!ownerInstance) {
|
|
3090
3676
|
return false;
|
|
3091
3677
|
}
|
|
3678
|
+
if (ownerInstance.serviceName === this.serviceName && ownerInstance.uuid !== this.serviceInstanceId) {
|
|
3679
|
+
return false;
|
|
3680
|
+
}
|
|
3092
3681
|
if (transport.deleted) {
|
|
3093
3682
|
this.clearTransportFailureState(ownerInstance.uuid, transport.uuid);
|
|
3094
3683
|
const transportKey = this.buildTransportRouteKey(
|
|
@@ -5515,6 +6104,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5515
6104
|
seenSignalMaps,
|
|
5516
6105
|
(row) => `${String(row.service_name ?? row.serviceName ?? "").trim()}|${String(
|
|
5517
6106
|
row.signal_name ?? row.signalName ?? ""
|
|
6107
|
+
).trim()}|${String(row.task_name ?? row.taskName ?? "").trim()}|${String(
|
|
6108
|
+
row.task_version ?? row.taskVersion ?? 1
|
|
5518
6109
|
).trim()}`
|
|
5519
6110
|
);
|
|
5520
6111
|
pushUnique(
|
|
@@ -5549,6 +6140,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5549
6140
|
seenSignalMaps,
|
|
5550
6141
|
(entry) => `${String(entry.service_name ?? entry.serviceName ?? "").trim()}|${String(
|
|
5551
6142
|
entry.signal_name ?? entry.signalName ?? ""
|
|
6143
|
+
).trim()}|${String(entry.task_name ?? entry.taskName ?? "").trim()}|${String(
|
|
6144
|
+
entry.task_version ?? entry.taskVersion ?? 1
|
|
5552
6145
|
).trim()}`
|
|
5553
6146
|
);
|
|
5554
6147
|
continue;
|
|
@@ -5581,7 +6174,36 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5581
6174
|
}
|
|
5582
6175
|
}
|
|
5583
6176
|
}
|
|
5584
|
-
const
|
|
6177
|
+
const activeServiceInstanceIds = new Set(
|
|
6178
|
+
serviceInstances.filter((row) => row.is_active === true || row.isActive === true).map((row) => String(row.uuid ?? "").trim()).filter((uuid9) => uuid9.length > 0)
|
|
6179
|
+
);
|
|
6180
|
+
const filteredServiceInstances = activeServiceInstanceIds.size > 0 ? serviceInstances.filter(
|
|
6181
|
+
(row) => activeServiceInstanceIds.has(String(row.uuid ?? "").trim())
|
|
6182
|
+
) : serviceInstances;
|
|
6183
|
+
const filteredServiceInstanceTransports = activeServiceInstanceIds.size > 0 ? serviceInstanceTransports.filter(
|
|
6184
|
+
(row) => activeServiceInstanceIds.has(
|
|
6185
|
+
String(row.service_instance_id ?? row.serviceInstanceId ?? "").trim()
|
|
6186
|
+
)
|
|
6187
|
+
) : serviceInstanceTransports;
|
|
6188
|
+
const filteredManifestSnapshots = activeServiceInstanceIds.size > 0 ? manifestSnapshots.filter(
|
|
6189
|
+
(snapshot) => activeServiceInstanceIds.has(snapshot.serviceInstanceId)
|
|
6190
|
+
) : manifestSnapshots;
|
|
6191
|
+
const activeServiceNames = new Set(
|
|
6192
|
+
filteredServiceInstances.map((row) => String(row.service_name ?? row.serviceName ?? "").trim()).filter((serviceName) => serviceName.length > 0)
|
|
6193
|
+
);
|
|
6194
|
+
const filteredSignalToTaskMaps = activeServiceNames.size > 0 ? signalToTaskMaps.filter(
|
|
6195
|
+
(row) => activeServiceNames.has(
|
|
6196
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
6197
|
+
)
|
|
6198
|
+
) : signalToTaskMaps;
|
|
6199
|
+
const filteredIntentToTaskMaps = activeServiceNames.size > 0 ? intentToTaskMaps.filter(
|
|
6200
|
+
(row) => activeServiceNames.has(
|
|
6201
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
6202
|
+
)
|
|
6203
|
+
) : intentToTaskMaps;
|
|
6204
|
+
const hasExplicitSignalRoutingRows = filteredSignalToTaskMaps.length > 0;
|
|
6205
|
+
const hasExplicitIntentRoutingRows = filteredIntentToTaskMaps.length > 0;
|
|
6206
|
+
const latestManifestSnapshots = selectLatestServiceManifestSnapshots(filteredManifestSnapshots);
|
|
5585
6207
|
const explodedManifest = explodeServiceManifestSnapshots(
|
|
5586
6208
|
latestManifestSnapshots
|
|
5587
6209
|
);
|
|
@@ -5661,29 +6283,33 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5661
6283
|
row.task_version ?? 1
|
|
5662
6284
|
).trim()}`
|
|
5663
6285
|
);
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
row.
|
|
5670
|
-
|
|
5671
|
-
row.
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
row.
|
|
5682
|
-
|
|
5683
|
-
|
|
6286
|
+
if (!hasExplicitSignalRoutingRows) {
|
|
6287
|
+
pushUnique(
|
|
6288
|
+
explodedManifest.signalToTaskMaps,
|
|
6289
|
+
filteredSignalToTaskMaps,
|
|
6290
|
+
seenSignalMaps,
|
|
6291
|
+
(row) => `${String(row.signal_name ?? "").trim()}|${String(
|
|
6292
|
+
row.service_name ?? ""
|
|
6293
|
+
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
6294
|
+
row.task_version ?? 1
|
|
6295
|
+
).trim()}`
|
|
6296
|
+
);
|
|
6297
|
+
}
|
|
6298
|
+
if (!hasExplicitIntentRoutingRows) {
|
|
6299
|
+
pushUnique(
|
|
6300
|
+
explodedManifest.intentToTaskMaps,
|
|
6301
|
+
filteredIntentToTaskMaps,
|
|
6302
|
+
seenIntentMaps,
|
|
6303
|
+
(row) => `${String(row.intent_name ?? "").trim()}|${String(
|
|
6304
|
+
row.service_name ?? ""
|
|
6305
|
+
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
6306
|
+
row.task_version ?? 1
|
|
6307
|
+
).trim()}`
|
|
6308
|
+
);
|
|
6309
|
+
}
|
|
5684
6310
|
return {
|
|
5685
|
-
serviceInstances,
|
|
5686
|
-
serviceInstanceTransports,
|
|
6311
|
+
serviceInstances: filteredServiceInstances,
|
|
6312
|
+
serviceInstanceTransports: filteredServiceInstanceTransports,
|
|
5687
6313
|
serviceManifests,
|
|
5688
6314
|
tasks,
|
|
5689
6315
|
signals,
|
|
@@ -5693,8 +6319,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5693
6319
|
directionalTaskMaps,
|
|
5694
6320
|
actorTaskMaps,
|
|
5695
6321
|
taskToRoutineMaps,
|
|
5696
|
-
signalToTaskMaps,
|
|
5697
|
-
intentToTaskMaps
|
|
6322
|
+
signalToTaskMaps: filteredSignalToTaskMaps,
|
|
6323
|
+
intentToTaskMaps: filteredIntentToTaskMaps
|
|
5698
6324
|
};
|
|
5699
6325
|
}
|
|
5700
6326
|
buildRemoteIntentDeputyKey(map) {
|
|
@@ -6123,10 +6749,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6123
6749
|
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
6124
6750
|
const timeoutId = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
6125
6751
|
try {
|
|
6752
|
+
const sanitizedContext = sanitizeAuthorityBootstrapDelegationContext(context);
|
|
6126
6753
|
const requestBody = stripDelegationRequestSnapshot(
|
|
6127
6754
|
ensureDelegationContextMetadata(
|
|
6128
6755
|
attachDelegationRequestSnapshot({
|
|
6129
|
-
...
|
|
6756
|
+
...sanitizedContext,
|
|
6130
6757
|
__remoteRoutineName: remoteRoutineName,
|
|
6131
6758
|
__serviceName: "CadenzaDB",
|
|
6132
6759
|
__localServiceName: this.serviceName,
|
|
@@ -6140,7 +6767,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6140
6767
|
__fetchId: target.fetchId,
|
|
6141
6768
|
fetchId: target.fetchId,
|
|
6142
6769
|
__metadata: {
|
|
6143
|
-
...
|
|
6770
|
+
...sanitizedContext.__metadata && typeof sanitizedContext.__metadata === "object" ? sanitizedContext.__metadata : {},
|
|
6144
6771
|
__timeout: timeoutMs,
|
|
6145
6772
|
__syncing: true,
|
|
6146
6773
|
__authorityBootstrapChannel: true
|
|
@@ -6158,22 +6785,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6158
6785
|
});
|
|
6159
6786
|
if ("ok" in response && response.ok === false) {
|
|
6160
6787
|
return {
|
|
6161
|
-
...
|
|
6788
|
+
...sanitizedContext,
|
|
6162
6789
|
__error: `Bootstrap authority delegation failed with HTTP ${response.status}`,
|
|
6163
6790
|
errored: true
|
|
6164
6791
|
};
|
|
6165
6792
|
}
|
|
6166
6793
|
const payload = typeof response.json === "function" ? await response.json() : response;
|
|
6167
6794
|
return payload && typeof payload === "object" ? {
|
|
6168
|
-
...
|
|
6795
|
+
...sanitizedContext,
|
|
6169
6796
|
...payload
|
|
6170
6797
|
} : {
|
|
6171
|
-
...
|
|
6798
|
+
...sanitizedContext,
|
|
6172
6799
|
returnedValue: payload
|
|
6173
6800
|
};
|
|
6174
6801
|
} catch (error) {
|
|
6175
6802
|
return {
|
|
6176
|
-
...context,
|
|
6803
|
+
...sanitizeAuthorityBootstrapDelegationContext(context),
|
|
6177
6804
|
__error: error instanceof Error ? error.message : String(error),
|
|
6178
6805
|
errored: true
|
|
6179
6806
|
};
|
|
@@ -6283,16 +6910,35 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6283
6910
|
const authorityFullSyncResponderTask = CadenzaService.createMetaTask(
|
|
6284
6911
|
BOOTSTRAP_FULL_SYNC_RESPONDER_TASK_NAME,
|
|
6285
6912
|
async (ctx) => {
|
|
6913
|
+
const queryOptionalAuthorityRoutingRows = async (tableName) => {
|
|
6914
|
+
try {
|
|
6915
|
+
return await DatabaseController.instance.queryAuthorityTableRows(
|
|
6916
|
+
tableName
|
|
6917
|
+
);
|
|
6918
|
+
} catch (error) {
|
|
6919
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6920
|
+
if (message.includes(
|
|
6921
|
+
`Table '${tableName}' is not registered on the CadenzaDB PostgresActor`
|
|
6922
|
+
)) {
|
|
6923
|
+
return [];
|
|
6924
|
+
}
|
|
6925
|
+
throw error;
|
|
6926
|
+
}
|
|
6927
|
+
};
|
|
6286
6928
|
const [
|
|
6287
6929
|
serviceInstances,
|
|
6288
6930
|
serviceInstanceTransports,
|
|
6289
|
-
serviceManifests
|
|
6931
|
+
serviceManifests,
|
|
6932
|
+
signalToTaskMaps,
|
|
6933
|
+
intentToTaskMaps
|
|
6290
6934
|
] = await Promise.all([
|
|
6291
6935
|
DatabaseController.instance.queryAuthorityTableRows("service_instance"),
|
|
6292
6936
|
DatabaseController.instance.queryAuthorityTableRows(
|
|
6293
6937
|
"service_instance_transport"
|
|
6294
6938
|
),
|
|
6295
|
-
DatabaseController.instance.queryAuthorityTableRows("service_manifest")
|
|
6939
|
+
DatabaseController.instance.queryAuthorityTableRows("service_manifest"),
|
|
6940
|
+
queryOptionalAuthorityRoutingRows("signal_to_task_map"),
|
|
6941
|
+
queryOptionalAuthorityRoutingRows("intent_to_task_map")
|
|
6296
6942
|
]);
|
|
6297
6943
|
return {
|
|
6298
6944
|
...ctx,
|
|
@@ -6300,7 +6946,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6300
6946
|
...this.collectBootstrapFullSyncPayload({
|
|
6301
6947
|
serviceInstances,
|
|
6302
6948
|
serviceInstanceTransports,
|
|
6303
|
-
serviceManifests
|
|
6949
|
+
serviceManifests,
|
|
6950
|
+
signalToTaskMaps,
|
|
6951
|
+
intentToTaskMaps
|
|
6304
6952
|
})
|
|
6305
6953
|
};
|
|
6306
6954
|
},
|
|
@@ -9260,9 +9908,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9260
9908
|
};
|
|
9261
9909
|
|
|
9262
9910
|
// src/graph/definition/SignalTransmissionTask.ts
|
|
9263
|
-
var
|
|
9911
|
+
var import_core3 = require("@cadenza.io/core");
|
|
9264
9912
|
var import_uuid4 = require("uuid");
|
|
9265
|
-
var SignalTransmissionTask = class extends
|
|
9913
|
+
var SignalTransmissionTask = class extends import_core3.Task {
|
|
9266
9914
|
/**
|
|
9267
9915
|
* Constructs a new instance of the class and initializes it with the provided parameters.
|
|
9268
9916
|
*
|
|
@@ -11170,8 +11818,8 @@ var SocketController = class _SocketController {
|
|
|
11170
11818
|
}
|
|
11171
11819
|
const routedDelegateCtx = stripTransportSelectionRoutingContext(delegateCtx);
|
|
11172
11820
|
const normalizedDelegateCtx = ensureDelegationContextMetadata(
|
|
11173
|
-
|
|
11174
|
-
|
|
11821
|
+
restoreDelegationRequestSnapshot(
|
|
11822
|
+
attachDelegationRequestSnapshot(routedDelegateCtx)
|
|
11175
11823
|
)
|
|
11176
11824
|
);
|
|
11177
11825
|
delete normalizedDelegateCtx.__isSubMeta;
|
|
@@ -11244,13 +11892,11 @@ var SocketController = class _SocketController {
|
|
|
11244
11892
|
return resolvedResultContext;
|
|
11245
11893
|
} catch (error) {
|
|
11246
11894
|
const message = error instanceof Error ? error.message : String(error);
|
|
11247
|
-
const failedContext =
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
...normalizedDelegateCtx.__metadata
|
|
11253
|
-
};
|
|
11895
|
+
const failedContext = buildDelegationFailureContext(
|
|
11896
|
+
"meta.socket_client.delegate_failed",
|
|
11897
|
+
normalizedDelegateCtx,
|
|
11898
|
+
error
|
|
11899
|
+
);
|
|
11254
11900
|
if (deputyExecId) {
|
|
11255
11901
|
emitter(`meta.socket_client.delegated:${deputyExecId}`, {
|
|
11256
11902
|
...failedContext,
|
|
@@ -12255,14 +12901,60 @@ var RuntimeValidationController = class _RuntimeValidationController {
|
|
|
12255
12901
|
};
|
|
12256
12902
|
|
|
12257
12903
|
// src/graph/controllers/registerActorSessionPersistence.ts
|
|
12258
|
-
var
|
|
12904
|
+
var import_core4 = require("@cadenza.io/core");
|
|
12259
12905
|
var ACTOR_SESSION_STATE_PERSIST_CONCURRENCY = 20;
|
|
12906
|
+
var META_ACTOR_SESSION_STATE_HYDRATE_INTENT = "meta-actor-session-state-hydrate";
|
|
12260
12907
|
var ACTOR_SESSION_TRACE_ENABLED2 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
12908
|
+
function findNestedContextValue(ctx, key) {
|
|
12909
|
+
if (!ctx || typeof ctx !== "object") {
|
|
12910
|
+
return void 0;
|
|
12911
|
+
}
|
|
12912
|
+
if (Object.prototype.hasOwnProperty.call(ctx, key) || ctx[key] !== void 0) {
|
|
12913
|
+
return ctx[key];
|
|
12914
|
+
}
|
|
12915
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
12916
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
12917
|
+
const nested = joinedContexts[index];
|
|
12918
|
+
if (!nested || typeof nested !== "object") {
|
|
12919
|
+
continue;
|
|
12920
|
+
}
|
|
12921
|
+
const nestedValue = findNestedContextValue(nested, key);
|
|
12922
|
+
if (nestedValue !== void 0) {
|
|
12923
|
+
return nestedValue;
|
|
12924
|
+
}
|
|
12925
|
+
}
|
|
12926
|
+
return void 0;
|
|
12927
|
+
}
|
|
12928
|
+
function resolveActorSessionStateRow(ctx) {
|
|
12929
|
+
const singular = findNestedContextValue(ctx, "actorSessionState");
|
|
12930
|
+
if (singular && typeof singular === "object" && !Array.isArray(singular)) {
|
|
12931
|
+
return singular;
|
|
12932
|
+
}
|
|
12933
|
+
const plural = findNestedContextValue(ctx, "actorSessionStates");
|
|
12934
|
+
if (Array.isArray(plural)) {
|
|
12935
|
+
const first = plural.find(
|
|
12936
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
12937
|
+
);
|
|
12938
|
+
if (first) {
|
|
12939
|
+
return first;
|
|
12940
|
+
}
|
|
12941
|
+
}
|
|
12942
|
+
const rows = findNestedContextValue(ctx, "rows");
|
|
12943
|
+
if (Array.isArray(rows)) {
|
|
12944
|
+
const first = rows.find(
|
|
12945
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
12946
|
+
);
|
|
12947
|
+
if (first) {
|
|
12948
|
+
return first;
|
|
12949
|
+
}
|
|
12950
|
+
}
|
|
12951
|
+
return null;
|
|
12952
|
+
}
|
|
12261
12953
|
function shouldAssumeSuccessfulActorSessionRowCount(ctx) {
|
|
12262
12954
|
return ctx.__success === true && ctx.rowCount === void 0 && ctx.__status === "success" && ctx.__serviceName === "CadenzaDB" && ctx.__localTaskName === "Insert actor_session_state in CadenzaDB";
|
|
12263
12955
|
}
|
|
12264
12956
|
function registerActorSessionPersistenceTasks() {
|
|
12265
|
-
if (CadenzaService.get("Persist actor session state")) {
|
|
12957
|
+
if (CadenzaService.get("Persist actor session state") && CadenzaService.get("Hydrate actor session state")) {
|
|
12266
12958
|
return;
|
|
12267
12959
|
}
|
|
12268
12960
|
const localActorSessionTaskOptions = {
|
|
@@ -12279,6 +12971,14 @@ function registerActorSessionPersistenceTasks() {
|
|
|
12279
12971
|
isSubMeta: true
|
|
12280
12972
|
}
|
|
12281
12973
|
);
|
|
12974
|
+
const actorSessionStateQueryTask = CadenzaService.getLocalCadenzaDBQueryTask("actor_session_state") ?? CadenzaService.get("dbQueryActorSessionState") ?? CadenzaService.get("Query actor_session_state in CadenzaDB") ?? CadenzaService.createCadenzaDBQueryTask(
|
|
12975
|
+
"actor_session_state",
|
|
12976
|
+
{},
|
|
12977
|
+
{
|
|
12978
|
+
concurrency: ACTOR_SESSION_STATE_PERSIST_CONCURRENCY,
|
|
12979
|
+
isSubMeta: true
|
|
12980
|
+
}
|
|
12981
|
+
);
|
|
12282
12982
|
const validateActorSessionStatePersistenceTask = CadenzaService.createMetaTask(
|
|
12283
12983
|
"Validate actor session state persistence",
|
|
12284
12984
|
(ctx) => {
|
|
@@ -12312,6 +13012,103 @@ function registerActorSessionPersistenceTasks() {
|
|
|
12312
13012
|
const insertAndValidateActorSessionStateTask = actorSessionStateInsertTask.then(
|
|
12313
13013
|
validateActorSessionStatePersistenceTask
|
|
12314
13014
|
);
|
|
13015
|
+
const validateActorSessionStateHydrationTask = CadenzaService.createMetaTask(
|
|
13016
|
+
"Validate actor session state hydration",
|
|
13017
|
+
(ctx) => {
|
|
13018
|
+
if (ctx.errored || ctx.failed || ctx.__success !== true) {
|
|
13019
|
+
throw new Error(
|
|
13020
|
+
String(
|
|
13021
|
+
ctx.__error ?? ctx.error ?? "actor_session_state hydration query failed"
|
|
13022
|
+
)
|
|
13023
|
+
);
|
|
13024
|
+
}
|
|
13025
|
+
const row = resolveActorSessionStateRow(ctx);
|
|
13026
|
+
if (!row) {
|
|
13027
|
+
return {
|
|
13028
|
+
__success: true,
|
|
13029
|
+
hydrated: false
|
|
13030
|
+
};
|
|
13031
|
+
}
|
|
13032
|
+
const expiresAt = typeof row.expiresAt === "string" ? row.expiresAt : typeof row.expires_at === "string" ? row.expires_at : null;
|
|
13033
|
+
const expiresAtMs = expiresAt ? Date.parse(expiresAt) : Number.NaN;
|
|
13034
|
+
if (Number.isFinite(expiresAtMs) && expiresAtMs <= Date.now()) {
|
|
13035
|
+
return {
|
|
13036
|
+
__success: true,
|
|
13037
|
+
hydrated: false
|
|
13038
|
+
};
|
|
13039
|
+
}
|
|
13040
|
+
const durableState = row.durableState ?? row.durable_state ?? null;
|
|
13041
|
+
const durableVersion = Number(
|
|
13042
|
+
row.durableVersion ?? row.durable_version ?? Number.NaN
|
|
13043
|
+
);
|
|
13044
|
+
if (typeof durableState !== "object" || durableState === null || Array.isArray(durableState)) {
|
|
13045
|
+
throw new Error("actor_session_state durable_state must be a non-null object");
|
|
13046
|
+
}
|
|
13047
|
+
if (!Number.isInteger(durableVersion) || durableVersion < 0) {
|
|
13048
|
+
throw new Error(
|
|
13049
|
+
"actor_session_state durable_version must be a non-negative integer"
|
|
13050
|
+
);
|
|
13051
|
+
}
|
|
13052
|
+
return {
|
|
13053
|
+
__success: true,
|
|
13054
|
+
hydrated: true,
|
|
13055
|
+
actor_name: row.actorName ?? row.actor_name,
|
|
13056
|
+
actor_version: row.actorVersion ?? row.actor_version,
|
|
13057
|
+
actor_key: row.actorKey ?? row.actor_key,
|
|
13058
|
+
service_name: row.serviceName ?? row.service_name,
|
|
13059
|
+
durable_state: durableState,
|
|
13060
|
+
durable_version: durableVersion
|
|
13061
|
+
};
|
|
13062
|
+
},
|
|
13063
|
+
"Validates and normalizes hydrated actor_session_state rows.",
|
|
13064
|
+
localActorSessionTaskOptions
|
|
13065
|
+
);
|
|
13066
|
+
const queryAndValidateActorSessionStateTask = actorSessionStateQueryTask.then(
|
|
13067
|
+
validateActorSessionStateHydrationTask
|
|
13068
|
+
);
|
|
13069
|
+
CadenzaService.createMetaTask(
|
|
13070
|
+
"Hydrate actor session state",
|
|
13071
|
+
(ctx) => {
|
|
13072
|
+
const actorName = typeof ctx.actor_name === "string" ? ctx.actor_name.trim() : "";
|
|
13073
|
+
const actorKey = typeof ctx.actor_key === "string" ? ctx.actor_key.trim() : "";
|
|
13074
|
+
const actorVersion = Number(ctx.actor_version ?? 1);
|
|
13075
|
+
const serviceName = CadenzaService.serviceRegistry.serviceName;
|
|
13076
|
+
if (!actorName) {
|
|
13077
|
+
throw new Error("actor_name is required for actor session hydration");
|
|
13078
|
+
}
|
|
13079
|
+
if (!actorKey) {
|
|
13080
|
+
throw new Error("actor_key is required for actor session hydration");
|
|
13081
|
+
}
|
|
13082
|
+
if (!Number.isInteger(actorVersion) || actorVersion < 1) {
|
|
13083
|
+
throw new Error("actor_version must be a positive integer");
|
|
13084
|
+
}
|
|
13085
|
+
if (!serviceName) {
|
|
13086
|
+
throw new Error("service_name is not available for actor session hydration");
|
|
13087
|
+
}
|
|
13088
|
+
return {
|
|
13089
|
+
...ctx,
|
|
13090
|
+
actor_name: actorName,
|
|
13091
|
+
actor_key: actorKey,
|
|
13092
|
+
actor_version: actorVersion,
|
|
13093
|
+
service_name: serviceName,
|
|
13094
|
+
queryData: {
|
|
13095
|
+
filter: {
|
|
13096
|
+
actor_name: actorName,
|
|
13097
|
+
actor_version: actorVersion,
|
|
13098
|
+
actor_key: actorKey,
|
|
13099
|
+
service_name: serviceName,
|
|
13100
|
+
deleted: false
|
|
13101
|
+
},
|
|
13102
|
+
queryMode: "one",
|
|
13103
|
+
sort: {
|
|
13104
|
+
updated: "desc"
|
|
13105
|
+
}
|
|
13106
|
+
}
|
|
13107
|
+
};
|
|
13108
|
+
},
|
|
13109
|
+
"Builds a one-row actor_session_state lookup for lazy actor hydration.",
|
|
13110
|
+
localActorSessionTaskOptions
|
|
13111
|
+
).then(queryAndValidateActorSessionStateTask).respondsTo(META_ACTOR_SESSION_STATE_HYDRATE_INTENT);
|
|
12315
13112
|
CadenzaService.createMetaTask(
|
|
12316
13113
|
"Persist actor session state",
|
|
12317
13114
|
(ctx) => {
|
|
@@ -12403,11 +13200,11 @@ function registerActorSessionPersistenceTasks() {
|
|
|
12403
13200
|
},
|
|
12404
13201
|
"Validates and prepares actor_session_state payload for strict write-through persistence.",
|
|
12405
13202
|
localActorSessionTaskOptions
|
|
12406
|
-
).then(insertAndValidateActorSessionStateTask).respondsTo(
|
|
13203
|
+
).then(insertAndValidateActorSessionStateTask).respondsTo(import_core4.META_ACTOR_SESSION_STATE_PERSIST_INTENT);
|
|
12407
13204
|
}
|
|
12408
13205
|
|
|
12409
13206
|
// src/graph/controllers/GraphSyncController.ts
|
|
12410
|
-
var
|
|
13207
|
+
var import_core5 = require("@cadenza.io/core");
|
|
12411
13208
|
var import_uuid6 = require("uuid");
|
|
12412
13209
|
var ACTOR_TASK_METADATA2 = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
12413
13210
|
function getActorTaskRuntimeMetadata2(taskFunction) {
|
|
@@ -12491,7 +13288,7 @@ function buildIntentRegistryData(intent) {
|
|
|
12491
13288
|
};
|
|
12492
13289
|
}
|
|
12493
13290
|
function isLocalOnlySyncIntent(intentName) {
|
|
12494
|
-
return intentName ===
|
|
13291
|
+
return intentName === import_core5.META_ACTOR_SESSION_STATE_PERSIST_INTENT;
|
|
12495
13292
|
}
|
|
12496
13293
|
function getJoinedContextValue(ctx, key) {
|
|
12497
13294
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
@@ -12630,16 +13427,20 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
12630
13427
|
ctx,
|
|
12631
13428
|
queryData
|
|
12632
13429
|
);
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
|
|
12642
|
-
|
|
13430
|
+
const hasEmptyObjectData = originalQueryData.data && typeof originalQueryData.data === "object" && !Array.isArray(originalQueryData.data) && Object.keys(originalQueryData.data).length === 0;
|
|
13431
|
+
const hasMissingData = originalQueryData.data === void 0;
|
|
13432
|
+
if ((tableName === "task" || tableName === "signal_registry" || tableName === "directional_task_graph_map") && (hasEmptyObjectData || hasMissingData)) {
|
|
13433
|
+
console.warn("[CADENZA_SYNC_EMPTY_INSERT]", {
|
|
13434
|
+
tableName,
|
|
13435
|
+
hasMissingData,
|
|
13436
|
+
hasEmptyObjectData,
|
|
13437
|
+
taskName: typeof ctx.__taskName === "string" ? ctx.__taskName : void 0,
|
|
13438
|
+
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0,
|
|
13439
|
+
syncSourceServiceName: typeof ctx.__syncSourceServiceName === "string" ? ctx.__syncSourceServiceName : void 0,
|
|
13440
|
+
queryData: originalQueryData,
|
|
13441
|
+
ctx,
|
|
13442
|
+
joinedContexts: Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : []
|
|
13443
|
+
});
|
|
12643
13444
|
}
|
|
12644
13445
|
return buildSyncExecutionEnvelope(
|
|
12645
13446
|
ctx,
|
|
@@ -12730,7 +13531,7 @@ function isBootstrapLocalOnlyActorName(actorName) {
|
|
|
12730
13531
|
return BOOTSTRAP_LOCAL_ONLY_ACTOR_NAMES.has(actorName);
|
|
12731
13532
|
}
|
|
12732
13533
|
function isBootstrapLocalOnlySignal(signalName) {
|
|
12733
|
-
return signalName.startsWith("meta.") || signalName === "meta.service_registry.insert_execution_requested" || signalName === "meta.service_registry.routeable_transport_missing" || signalName === "meta.signal_broker.added" || signalName === "meta.rest.handshake" || signalName === "meta.rest.delegation_target_not_found" || signalName === "meta.socket.handshake" || signalName === "meta.socket.delegation_target_not_found" || signalName === "meta.fetch.handshake_complete" || signalName === "sub_meta.signal_broker.new_trace" || signalName.startsWith("meta.task.") || signalName.startsWith("meta.sync_controller.") || isLocalServiceReadySignal(signalName);
|
|
13534
|
+
return signalName.startsWith("meta.") || signalName.startsWith("global.meta.") || signalName === "meta.service_registry.insert_execution_requested" || signalName === "meta.service_registry.routeable_transport_missing" || signalName === "meta.signal_broker.added" || signalName === "meta.rest.handshake" || signalName === "meta.rest.delegation_target_not_found" || signalName === "meta.socket.handshake" || signalName === "meta.socket.delegation_target_not_found" || signalName === "meta.fetch.handshake_complete" || signalName === "sub_meta.signal_broker.new_trace" || signalName.startsWith("meta.task.") || signalName.startsWith("meta.sync_controller.") || isLocalServiceReadySignal(signalName);
|
|
12734
13535
|
}
|
|
12735
13536
|
function hasNonZeroPending(summary) {
|
|
12736
13537
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
@@ -12958,6 +13759,12 @@ function resolveLocalRoutineFromSyncContext(ctx) {
|
|
|
12958
13759
|
);
|
|
12959
13760
|
return routineName ? CadenzaService.getRoutine(routineName) : void 0;
|
|
12960
13761
|
}
|
|
13762
|
+
function shouldTrackDirectionalTaskMapForBootstrap(predecessorTask, nextTask) {
|
|
13763
|
+
if (!predecessorTask || !nextTask) {
|
|
13764
|
+
return false;
|
|
13765
|
+
}
|
|
13766
|
+
return predecessorTask.isMeta !== true && predecessorTask.isSubMeta !== true && nextTask.isMeta !== true && nextTask.isSubMeta !== true;
|
|
13767
|
+
}
|
|
12961
13768
|
function resolveSignalNameFromSyncContext(ctx) {
|
|
12962
13769
|
const candidateSignalNames = [
|
|
12963
13770
|
ctx.signalName,
|
|
@@ -14034,7 +14841,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14034
14841
|
return;
|
|
14035
14842
|
}
|
|
14036
14843
|
for (const t of task.nextTasks) {
|
|
14037
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
14844
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, t)) {
|
|
14038
14845
|
continue;
|
|
14039
14846
|
}
|
|
14040
14847
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -14102,7 +14909,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
14102
14909
|
return false;
|
|
14103
14910
|
}
|
|
14104
14911
|
for (const nextTask of task.nextTasks) {
|
|
14105
|
-
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered) {
|
|
14912
|
+
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, nextTask)) {
|
|
14106
14913
|
continue;
|
|
14107
14914
|
}
|
|
14108
14915
|
if (resolveSyncServiceName(nextTask)) {
|
|
@@ -16412,10 +17219,23 @@ function resolveInquiryFailureError(inquiry, value, depth = 3, seen = /* @__PURE
|
|
|
16412
17219
|
}
|
|
16413
17220
|
return `Inquiry '${inquiry}' did not complete successfully`;
|
|
16414
17221
|
}
|
|
17222
|
+
function normalizePositiveInteger(value, fallback) {
|
|
17223
|
+
const normalized = Number(value);
|
|
17224
|
+
return Number.isInteger(normalized) && normalized > 0 ? normalized : fallback;
|
|
17225
|
+
}
|
|
16415
17226
|
var DEFAULT_DEPUTY_TASK_CONCURRENCY = 50;
|
|
16416
17227
|
var DEFAULT_DEPUTY_TASK_TIMEOUT_MS = 12e4;
|
|
16417
17228
|
var DEFAULT_DATABASE_PROXY_TASK_CONCURRENCY = 50;
|
|
16418
17229
|
var DEFAULT_DATABASE_PROXY_TASK_TIMEOUT_MS = 12e4;
|
|
17230
|
+
var SERVICE_MANIFEST_PUBLICATION_ORDER = [
|
|
17231
|
+
"routing_capability",
|
|
17232
|
+
"business_structural",
|
|
17233
|
+
"local_meta_structural"
|
|
17234
|
+
];
|
|
17235
|
+
function getServiceManifestPublicationLayerRank(layer) {
|
|
17236
|
+
const index = SERVICE_MANIFEST_PUBLICATION_ORDER.indexOf(layer);
|
|
17237
|
+
return index >= 0 ? index : SERVICE_MANIFEST_PUBLICATION_ORDER.length - 1;
|
|
17238
|
+
}
|
|
16419
17239
|
var CadenzaService = class {
|
|
16420
17240
|
static unregisterGracefulShutdownHandlers() {
|
|
16421
17241
|
for (const cleanup of this.shutdownHandlerCleanup) {
|
|
@@ -16542,7 +17362,15 @@ var CadenzaService = class {
|
|
|
16542
17362
|
this.replayRegisteredTaskSignalObservations();
|
|
16543
17363
|
this.replayRegisteredTaskIntentAssociations();
|
|
16544
17364
|
}
|
|
16545
|
-
static
|
|
17365
|
+
static normalizeServiceManifestPublicationLayer(value, fallback = "business_structural") {
|
|
17366
|
+
return value === "routing_capability" || value === "business_structural" || value === "local_meta_structural" ? value : fallback;
|
|
17367
|
+
}
|
|
17368
|
+
static mergeServiceManifestPublicationRequest(reason, targetLayer) {
|
|
17369
|
+
this.serviceManifestPublicationPendingReason = reason;
|
|
17370
|
+
const currentTargetLayer = this.serviceManifestPublicationPendingLayer ?? "routing_capability";
|
|
17371
|
+
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(targetLayer) >= getServiceManifestPublicationLayerRank(currentTargetLayer) ? targetLayer : currentTargetLayer;
|
|
17372
|
+
}
|
|
17373
|
+
static requestServiceManifestPublication(reason, immediate = false, targetLayer = "business_structural") {
|
|
16546
17374
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16547
17375
|
return;
|
|
16548
17376
|
}
|
|
@@ -16550,7 +17378,8 @@ var CadenzaService = class {
|
|
|
16550
17378
|
const payload = {
|
|
16551
17379
|
__reason: reason,
|
|
16552
17380
|
__serviceName: this.serviceRegistry.serviceName,
|
|
16553
|
-
__serviceInstanceId: this.serviceRegistry.serviceInstanceId
|
|
17381
|
+
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
17382
|
+
__publicationLayer: targetLayer
|
|
16554
17383
|
};
|
|
16555
17384
|
if (immediate) {
|
|
16556
17385
|
this.emit(signalName, payload);
|
|
@@ -16558,32 +17387,53 @@ var CadenzaService = class {
|
|
|
16558
17387
|
}
|
|
16559
17388
|
this.debounce(signalName, payload, 100);
|
|
16560
17389
|
}
|
|
16561
|
-
static scheduleServiceManifestPublicationRetry(reason) {
|
|
17390
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
16562
17391
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16563
17392
|
return;
|
|
16564
17393
|
}
|
|
16565
17394
|
setTimeout(() => {
|
|
16566
|
-
this.requestServiceManifestPublication(reason, false);
|
|
17395
|
+
this.requestServiceManifestPublication(reason, false, targetLayer);
|
|
16567
17396
|
}, 1e3);
|
|
16568
17397
|
}
|
|
16569
|
-
static async publishServiceManifestIfNeeded(reason) {
|
|
17398
|
+
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
16570
17399
|
if (!this.serviceRegistry.connectsToCadenzaDB || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
16571
17400
|
return false;
|
|
16572
17401
|
}
|
|
16573
17402
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
17403
|
+
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
17404
|
+
targetLayer
|
|
17405
|
+
);
|
|
16574
17406
|
if (this.serviceManifestPublicationInFlight) {
|
|
16575
|
-
this.
|
|
17407
|
+
this.mergeServiceManifestPublicationRequest(
|
|
17408
|
+
publishReason,
|
|
17409
|
+
publishTargetLayer
|
|
17410
|
+
);
|
|
16576
17411
|
return false;
|
|
16577
17412
|
}
|
|
16578
|
-
const
|
|
16579
|
-
|
|
16580
|
-
|
|
16581
|
-
|
|
16582
|
-
|
|
17413
|
+
const publicationPlan = SERVICE_MANIFEST_PUBLICATION_ORDER.filter(
|
|
17414
|
+
(layer) => getServiceManifestPublicationLayerRank(layer) <= getServiceManifestPublicationLayerRank(publishTargetLayer)
|
|
17415
|
+
).map((layer) => {
|
|
17416
|
+
const snapshot2 = buildServiceManifestSnapshot({
|
|
17417
|
+
serviceName: this.serviceRegistry.serviceName,
|
|
17418
|
+
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
17419
|
+
revision: this.serviceManifestRevision + 1,
|
|
17420
|
+
publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17421
|
+
publicationLayer: layer
|
|
17422
|
+
});
|
|
17423
|
+
return {
|
|
17424
|
+
layer,
|
|
17425
|
+
snapshot: snapshot2,
|
|
17426
|
+
changed: this.lastPublishedServiceManifestHashes[layer] !== snapshot2.manifestHash
|
|
17427
|
+
};
|
|
16583
17428
|
});
|
|
16584
|
-
|
|
17429
|
+
const nextPublication = publicationPlan.find((entry) => entry.changed);
|
|
17430
|
+
if (!nextPublication) {
|
|
16585
17431
|
return false;
|
|
16586
17432
|
}
|
|
17433
|
+
const { layer: publicationLayer, snapshot } = nextPublication;
|
|
17434
|
+
const hasPendingFollowupLayer = publicationPlan.some(
|
|
17435
|
+
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
17436
|
+
);
|
|
16587
17437
|
this.serviceManifestPublicationInFlight = true;
|
|
16588
17438
|
try {
|
|
16589
17439
|
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
@@ -16591,7 +17441,10 @@ var CadenzaService = class {
|
|
|
16591
17441
|
snapshot
|
|
16592
17442
|
);
|
|
16593
17443
|
if (!this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
16594
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
17444
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
17445
|
+
publishReason,
|
|
17446
|
+
publishTargetLayer
|
|
17447
|
+
);
|
|
16595
17448
|
return false;
|
|
16596
17449
|
}
|
|
16597
17450
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
@@ -16599,32 +17452,48 @@ var CadenzaService = class {
|
|
|
16599
17452
|
requireComplete: true
|
|
16600
17453
|
});
|
|
16601
17454
|
this.serviceManifestRevision = snapshot.revision;
|
|
16602
|
-
this.
|
|
17455
|
+
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
17456
|
+
if (hasPendingFollowupLayer) {
|
|
17457
|
+
this.mergeServiceManifestPublicationRequest(
|
|
17458
|
+
publishReason,
|
|
17459
|
+
publishTargetLayer
|
|
17460
|
+
);
|
|
17461
|
+
}
|
|
16603
17462
|
return {
|
|
16604
17463
|
serviceManifest: snapshot,
|
|
16605
|
-
published: true
|
|
17464
|
+
published: true,
|
|
17465
|
+
publicationLayer
|
|
16606
17466
|
};
|
|
16607
17467
|
} catch (error) {
|
|
16608
17468
|
this.log("Service manifest publication failed. Scheduling retry.", {
|
|
16609
17469
|
serviceName: this.serviceRegistry.serviceName,
|
|
16610
17470
|
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
16611
17471
|
reason: publishReason,
|
|
17472
|
+
publicationLayer,
|
|
16612
17473
|
error: resolveInquiryFailureError(
|
|
16613
17474
|
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
16614
17475
|
error
|
|
16615
17476
|
),
|
|
16616
17477
|
inquiryMeta: error && typeof error === "object" && "__inquiryMeta" in error ? error.__inquiryMeta : null
|
|
16617
17478
|
});
|
|
16618
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
17479
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
17480
|
+
publishReason,
|
|
17481
|
+
publishTargetLayer
|
|
17482
|
+
);
|
|
16619
17483
|
return false;
|
|
16620
17484
|
} finally {
|
|
16621
17485
|
this.serviceManifestPublicationInFlight = false;
|
|
16622
|
-
if (this.serviceManifestPublicationPendingReason) {
|
|
17486
|
+
if (this.serviceManifestPublicationPendingReason && this.serviceManifestPublicationPendingLayer) {
|
|
16623
17487
|
const pendingReason = this.serviceManifestPublicationPendingReason;
|
|
17488
|
+
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
16624
17489
|
this.serviceManifestPublicationPendingReason = null;
|
|
17490
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
16625
17491
|
this.debounce(
|
|
16626
17492
|
"meta.service_manifest.publish_requested",
|
|
16627
|
-
{
|
|
17493
|
+
{
|
|
17494
|
+
__reason: pendingReason,
|
|
17495
|
+
__publicationLayer: pendingLayer
|
|
17496
|
+
},
|
|
16628
17497
|
100
|
|
16629
17498
|
);
|
|
16630
17499
|
}
|
|
@@ -16637,9 +17506,13 @@ var CadenzaService = class {
|
|
|
16637
17506
|
this.createMetaTask(
|
|
16638
17507
|
"Publish service manifest",
|
|
16639
17508
|
async (ctx) => this.publishServiceManifestIfNeeded(
|
|
16640
|
-
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish"
|
|
17509
|
+
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish",
|
|
17510
|
+
this.normalizeServiceManifestPublicationLayer(
|
|
17511
|
+
ctx.__publicationLayer,
|
|
17512
|
+
"business_structural"
|
|
17513
|
+
)
|
|
16641
17514
|
),
|
|
16642
|
-
"Publishes
|
|
17515
|
+
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
16643
17516
|
{
|
|
16644
17517
|
register: false,
|
|
16645
17518
|
isHidden: true
|
|
@@ -16649,13 +17522,18 @@ var CadenzaService = class {
|
|
|
16649
17522
|
"Request manifest publication after structural change",
|
|
16650
17523
|
(ctx) => {
|
|
16651
17524
|
const reason = typeof ctx.signal === "string" && ctx.signal.trim().length > 0 ? ctx.signal : typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason : "manifest_structural_update";
|
|
17525
|
+
const targetLayer = reason === "meta.service_registry.instance_inserted" ? "business_structural" : this.normalizeServiceManifestPublicationLayer(
|
|
17526
|
+
ctx.__publicationLayer,
|
|
17527
|
+
"business_structural"
|
|
17528
|
+
);
|
|
16652
17529
|
this.requestServiceManifestPublication(
|
|
16653
17530
|
reason,
|
|
16654
|
-
reason === "meta.service_registry.instance_inserted"
|
|
17531
|
+
reason === "meta.service_registry.instance_inserted",
|
|
17532
|
+
targetLayer
|
|
16655
17533
|
);
|
|
16656
17534
|
return true;
|
|
16657
17535
|
},
|
|
16658
|
-
"Requests
|
|
17536
|
+
"Requests staged manifest publication when a static service primitive changes.",
|
|
16659
17537
|
{
|
|
16660
17538
|
register: false,
|
|
16661
17539
|
isHidden: true
|
|
@@ -16698,19 +17576,19 @@ var CadenzaService = class {
|
|
|
16698
17576
|
static bootstrap() {
|
|
16699
17577
|
if (this.isBootstrapped) return;
|
|
16700
17578
|
this.isBootstrapped = true;
|
|
16701
|
-
|
|
16702
|
-
|
|
17579
|
+
import_core6.default.bootstrap();
|
|
17580
|
+
import_core6.default.setRuntimeInquiryDelegate(
|
|
16703
17581
|
(inquiry, context, options) => this.inquire(
|
|
16704
17582
|
inquiry,
|
|
16705
17583
|
context,
|
|
16706
17584
|
options ?? {}
|
|
16707
17585
|
)
|
|
16708
17586
|
);
|
|
16709
|
-
this.signalBroker =
|
|
16710
|
-
this.inquiryBroker =
|
|
16711
|
-
this.runner =
|
|
16712
|
-
this.metaRunner =
|
|
16713
|
-
this.registry =
|
|
17587
|
+
this.signalBroker = import_core6.default.signalBroker;
|
|
17588
|
+
this.inquiryBroker = import_core6.default.inquiryBroker;
|
|
17589
|
+
this.runner = import_core6.default.runner;
|
|
17590
|
+
this.metaRunner = import_core6.default.metaRunner;
|
|
17591
|
+
this.registry = import_core6.default.registry;
|
|
16714
17592
|
this.serviceRegistry = ServiceRegistry.instance;
|
|
16715
17593
|
RestController.instance;
|
|
16716
17594
|
SocketController.instance;
|
|
@@ -16744,8 +17622,8 @@ var CadenzaService = class {
|
|
|
16744
17622
|
return;
|
|
16745
17623
|
}
|
|
16746
17624
|
this.frontendSyncScheduled = true;
|
|
16747
|
-
|
|
16748
|
-
|
|
17625
|
+
import_core6.default.interval("meta.sync_requested", { __syncing: false }, 18e4);
|
|
17626
|
+
import_core6.default.schedule("meta.sync_requested", { __syncing: false }, 250);
|
|
16749
17627
|
}
|
|
16750
17628
|
static normalizeDeclaredTransports(transports, serviceId, useSocket) {
|
|
16751
17629
|
return (transports ?? []).map((transport) => normalizeServiceTransportConfig(transport)).filter(
|
|
@@ -16803,7 +17681,7 @@ var CadenzaService = class {
|
|
|
16803
17681
|
* @return {void} Does not return any value.
|
|
16804
17682
|
*/
|
|
16805
17683
|
static validateName(name) {
|
|
16806
|
-
|
|
17684
|
+
import_core6.default.validateName(name);
|
|
16807
17685
|
}
|
|
16808
17686
|
/**
|
|
16809
17687
|
* Gets the current run strategy from the Cadenza configuration.
|
|
@@ -16811,7 +17689,7 @@ var CadenzaService = class {
|
|
|
16811
17689
|
* @return {Function} The run strategy function defined in the Cadenza configuration.
|
|
16812
17690
|
*/
|
|
16813
17691
|
static get runStrategy() {
|
|
16814
|
-
return
|
|
17692
|
+
return import_core6.default.runStrategy;
|
|
16815
17693
|
}
|
|
16816
17694
|
/**
|
|
16817
17695
|
* Sets the mode for the Cadenza application.
|
|
@@ -16820,7 +17698,7 @@ var CadenzaService = class {
|
|
|
16820
17698
|
* @return {void} This method does not return a value.
|
|
16821
17699
|
*/
|
|
16822
17700
|
static setMode(mode) {
|
|
16823
|
-
|
|
17701
|
+
import_core6.default.setMode(mode);
|
|
16824
17702
|
}
|
|
16825
17703
|
static hasCompletedBootstrapSync() {
|
|
16826
17704
|
return !this.serviceCreated || this.bootstrapSyncCompleted;
|
|
@@ -16863,16 +17741,16 @@ var CadenzaService = class {
|
|
|
16863
17741
|
* ```
|
|
16864
17742
|
*/
|
|
16865
17743
|
static emit(signal, data = {}, options = {}) {
|
|
16866
|
-
|
|
17744
|
+
import_core6.default.emit(signal, data, options);
|
|
16867
17745
|
}
|
|
16868
17746
|
static debounce(signal, context = {}, delayMs = 500) {
|
|
16869
|
-
|
|
17747
|
+
import_core6.default.debounce(signal, context, delayMs);
|
|
16870
17748
|
}
|
|
16871
17749
|
static schedule(signal, context, timeoutMs, exactDateTime) {
|
|
16872
|
-
|
|
17750
|
+
import_core6.default.schedule(signal, context, timeoutMs, exactDateTime);
|
|
16873
17751
|
}
|
|
16874
17752
|
static interval(signal, context, intervalMs, leading = false, startDateTime) {
|
|
16875
|
-
|
|
17753
|
+
import_core6.default.interval(signal, context, intervalMs, leading, startDateTime);
|
|
16876
17754
|
}
|
|
16877
17755
|
static defineIntent(intent) {
|
|
16878
17756
|
this.inquiryBroker?.addIntent(intent);
|
|
@@ -16880,35 +17758,35 @@ var CadenzaService = class {
|
|
|
16880
17758
|
}
|
|
16881
17759
|
static getRuntimeValidationPolicy() {
|
|
16882
17760
|
this.bootstrap();
|
|
16883
|
-
return
|
|
17761
|
+
return import_core6.default.getRuntimeValidationPolicy();
|
|
16884
17762
|
}
|
|
16885
17763
|
static setRuntimeValidationPolicy(policy = {}) {
|
|
16886
17764
|
this.bootstrap();
|
|
16887
|
-
return
|
|
17765
|
+
return import_core6.default.setRuntimeValidationPolicy(policy);
|
|
16888
17766
|
}
|
|
16889
17767
|
static replaceRuntimeValidationPolicy(policy = {}) {
|
|
16890
17768
|
this.bootstrap();
|
|
16891
|
-
return
|
|
17769
|
+
return import_core6.default.replaceRuntimeValidationPolicy(policy);
|
|
16892
17770
|
}
|
|
16893
17771
|
static clearRuntimeValidationPolicy() {
|
|
16894
17772
|
this.bootstrap();
|
|
16895
|
-
|
|
17773
|
+
import_core6.default.clearRuntimeValidationPolicy();
|
|
16896
17774
|
}
|
|
16897
17775
|
static getRuntimeValidationScopes() {
|
|
16898
17776
|
this.bootstrap();
|
|
16899
|
-
return
|
|
17777
|
+
return import_core6.default.getRuntimeValidationScopes();
|
|
16900
17778
|
}
|
|
16901
17779
|
static upsertRuntimeValidationScope(scope) {
|
|
16902
17780
|
this.bootstrap();
|
|
16903
|
-
return
|
|
17781
|
+
return import_core6.default.upsertRuntimeValidationScope(scope);
|
|
16904
17782
|
}
|
|
16905
17783
|
static removeRuntimeValidationScope(id) {
|
|
16906
17784
|
this.bootstrap();
|
|
16907
|
-
|
|
17785
|
+
import_core6.default.removeRuntimeValidationScope(id);
|
|
16908
17786
|
}
|
|
16909
17787
|
static clearRuntimeValidationScopes() {
|
|
16910
17788
|
this.bootstrap();
|
|
16911
|
-
|
|
17789
|
+
import_core6.default.clearRuntimeValidationScopes();
|
|
16912
17790
|
}
|
|
16913
17791
|
static getInquiryResponderDescriptor(task) {
|
|
16914
17792
|
return this.serviceRegistry.getInquiryResponderDescriptor(task);
|
|
@@ -17270,7 +18148,7 @@ var CadenzaService = class {
|
|
|
17270
18148
|
});
|
|
17271
18149
|
}
|
|
17272
18150
|
static get(taskName) {
|
|
17273
|
-
return
|
|
18151
|
+
return import_core6.default.get(taskName);
|
|
17274
18152
|
}
|
|
17275
18153
|
static getLocalCadenzaDBTask(tableName, operation) {
|
|
17276
18154
|
const generatedTaskName = this.buildGeneratedLocalCadenzaDBTaskName(
|
|
@@ -17281,7 +18159,7 @@ var CadenzaService = class {
|
|
|
17281
18159
|
tableName,
|
|
17282
18160
|
operation
|
|
17283
18161
|
);
|
|
17284
|
-
return
|
|
18162
|
+
return import_core6.default.get(generatedTaskName) ?? import_core6.default.get(legacyTaskName);
|
|
17285
18163
|
}
|
|
17286
18164
|
static getLocalCadenzaDBInsertTask(tableName) {
|
|
17287
18165
|
return this.getLocalCadenzaDBTask(tableName, "insert");
|
|
@@ -17290,15 +18168,15 @@ var CadenzaService = class {
|
|
|
17290
18168
|
return this.getLocalCadenzaDBTask(tableName, "query");
|
|
17291
18169
|
}
|
|
17292
18170
|
static getActor(actorName) {
|
|
17293
|
-
const cadenzaWithActors =
|
|
18171
|
+
const cadenzaWithActors = import_core6.default;
|
|
17294
18172
|
return cadenzaWithActors.getActor?.(actorName);
|
|
17295
18173
|
}
|
|
17296
18174
|
static getAllActors() {
|
|
17297
|
-
const cadenzaWithActors =
|
|
18175
|
+
const cadenzaWithActors = import_core6.default;
|
|
17298
18176
|
return cadenzaWithActors.getAllActors?.() ?? [];
|
|
17299
18177
|
}
|
|
17300
18178
|
static getRoutine(routineName) {
|
|
17301
|
-
return
|
|
18179
|
+
return import_core6.default.getRoutine(routineName);
|
|
17302
18180
|
}
|
|
17303
18181
|
/**
|
|
17304
18182
|
* Creates a new DeputyTask instance based on the provided routine name, service name, and options.
|
|
@@ -17910,10 +18788,28 @@ var CadenzaService = class {
|
|
|
17910
18788
|
__isFrontend: isFrontend,
|
|
17911
18789
|
__declaredTransports: declaredTransports
|
|
17912
18790
|
};
|
|
18791
|
+
let bootstrapServiceCreationRequested = false;
|
|
17913
18792
|
if (options.cadenzaDB?.connect) {
|
|
17914
|
-
this.
|
|
17915
|
-
|
|
17916
|
-
|
|
18793
|
+
this.createMetaTask(
|
|
18794
|
+
"Create service",
|
|
18795
|
+
async (context, emit2) => {
|
|
18796
|
+
const handshakeServiceName = String(context?.serviceName ?? "").trim();
|
|
18797
|
+
if (handshakeServiceName !== "CadenzaDB") {
|
|
18798
|
+
return false;
|
|
18799
|
+
}
|
|
18800
|
+
if (bootstrapServiceCreationRequested) {
|
|
18801
|
+
return false;
|
|
18802
|
+
}
|
|
18803
|
+
bootstrapServiceCreationRequested = true;
|
|
18804
|
+
emit2("meta.create_service_requested", initContext);
|
|
18805
|
+
return true;
|
|
18806
|
+
},
|
|
18807
|
+
"Requests local service creation only once after the initial authority bootstrap handshake completes.",
|
|
18808
|
+
{
|
|
18809
|
+
register: false,
|
|
18810
|
+
isHidden: true
|
|
18811
|
+
}
|
|
18812
|
+
).doOn("meta.fetch.handshake_complete");
|
|
17917
18813
|
} else {
|
|
17918
18814
|
this.emit("meta.create_service_requested", initContext);
|
|
17919
18815
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
@@ -17926,10 +18822,33 @@ var CadenzaService = class {
|
|
|
17926
18822
|
);
|
|
17927
18823
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
17928
18824
|
}
|
|
18825
|
+
let serviceSetupCompletedHandled = false;
|
|
17929
18826
|
this.createMetaTask("Handle service setup completion", (ctx, emit2) => {
|
|
18827
|
+
if (serviceSetupCompletedHandled) {
|
|
18828
|
+
return false;
|
|
18829
|
+
}
|
|
18830
|
+
const insertedServiceInstanceId = String(
|
|
18831
|
+
ctx?.serviceInstanceId ?? ctx?.service_instance_id ?? ctx?.serviceInstance?.uuid ?? ctx?.serviceInstance?.serviceInstanceId ?? ""
|
|
18832
|
+
).trim();
|
|
18833
|
+
const insertedServiceName = String(
|
|
18834
|
+
ctx?.serviceName ?? ctx?.service_name ?? ctx?.serviceInstance?.serviceName ?? ctx?.serviceInstance?.service_name ?? ""
|
|
18835
|
+
).trim();
|
|
18836
|
+
if (!insertedServiceInstanceId && !insertedServiceName) {
|
|
18837
|
+
return false;
|
|
18838
|
+
}
|
|
18839
|
+
if (insertedServiceInstanceId && insertedServiceInstanceId !== serviceId) {
|
|
18840
|
+
return false;
|
|
18841
|
+
}
|
|
18842
|
+
if (!insertedServiceInstanceId && insertedServiceName && insertedServiceName !== serviceName) {
|
|
18843
|
+
return false;
|
|
18844
|
+
}
|
|
18845
|
+
serviceSetupCompletedHandled = true;
|
|
17930
18846
|
if (options.cadenzaDB?.connect) {
|
|
17931
18847
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
17932
|
-
void this.publishServiceManifestIfNeeded(
|
|
18848
|
+
void this.publishServiceManifestIfNeeded(
|
|
18849
|
+
"service_setup_completed",
|
|
18850
|
+
"business_structural"
|
|
18851
|
+
);
|
|
17933
18852
|
}
|
|
17934
18853
|
if (isFrontend) {
|
|
17935
18854
|
registerActorSessionPersistenceTasks();
|
|
@@ -17939,7 +18858,7 @@ var CadenzaService = class {
|
|
|
17939
18858
|
return true;
|
|
17940
18859
|
}).doOn("meta.service_registry.instance_inserted");
|
|
17941
18860
|
if (!options.cadenzaDB?.connect) {
|
|
17942
|
-
|
|
18861
|
+
import_core6.default.schedule(
|
|
17943
18862
|
"meta.service_registry.instance_registration_requested",
|
|
17944
18863
|
{
|
|
17945
18864
|
data: {
|
|
@@ -17984,7 +18903,11 @@ var CadenzaService = class {
|
|
|
17984
18903
|
);
|
|
17985
18904
|
}
|
|
17986
18905
|
this.serviceCreated = true;
|
|
17987
|
-
this.requestServiceManifestPublication(
|
|
18906
|
+
this.requestServiceManifestPublication(
|
|
18907
|
+
"service_created",
|
|
18908
|
+
true,
|
|
18909
|
+
"routing_capability"
|
|
18910
|
+
);
|
|
17988
18911
|
}
|
|
17989
18912
|
/**
|
|
17990
18913
|
* Creates a Cadenza metadata service with the specified name, description, and options.
|
|
@@ -18245,11 +19168,84 @@ var CadenzaService = class {
|
|
|
18245
19168
|
}
|
|
18246
19169
|
static createActor(spec, options = {}) {
|
|
18247
19170
|
this.bootstrap();
|
|
18248
|
-
return
|
|
19171
|
+
return import_core6.default.createActor(
|
|
19172
|
+
spec,
|
|
19173
|
+
this.withActorSessionHydration(
|
|
19174
|
+
spec,
|
|
19175
|
+
options
|
|
19176
|
+
)
|
|
19177
|
+
);
|
|
18249
19178
|
}
|
|
18250
19179
|
static createActorFromDefinition(definition, options = {}) {
|
|
18251
19180
|
this.bootstrap();
|
|
18252
|
-
return
|
|
19181
|
+
return import_core6.default.createActorFromDefinition(
|
|
19182
|
+
definition,
|
|
19183
|
+
this.withActorSessionHydration(
|
|
19184
|
+
{
|
|
19185
|
+
name: definition.name,
|
|
19186
|
+
description: definition.description,
|
|
19187
|
+
defaultKey: definition.defaultKey,
|
|
19188
|
+
kind: definition.kind,
|
|
19189
|
+
loadPolicy: definition.loadPolicy,
|
|
19190
|
+
writeContract: definition.writeContract,
|
|
19191
|
+
consistencyProfile: definition.consistencyProfile,
|
|
19192
|
+
retry: definition.retry,
|
|
19193
|
+
idempotency: definition.idempotency,
|
|
19194
|
+
session: definition.session,
|
|
19195
|
+
runtimeReadGuard: definition.runtimeReadGuard,
|
|
19196
|
+
key: definition.key,
|
|
19197
|
+
state: definition.state,
|
|
19198
|
+
taskBindings: definition.tasks,
|
|
19199
|
+
initState: definition.state?.durable?.initState ?? definition.state?.durable?.initialState
|
|
19200
|
+
},
|
|
19201
|
+
options
|
|
19202
|
+
)
|
|
19203
|
+
);
|
|
19204
|
+
}
|
|
19205
|
+
static withActorSessionHydration(spec, options) {
|
|
19206
|
+
if (options.hydrateDurableState || spec.session?.persistDurableState !== true) {
|
|
19207
|
+
return options;
|
|
19208
|
+
}
|
|
19209
|
+
const actorName = String(spec.name ?? "").trim();
|
|
19210
|
+
const actorVersion = 1;
|
|
19211
|
+
const timeoutMs = normalizePositiveInteger(
|
|
19212
|
+
spec.session?.persistenceTimeoutMs,
|
|
19213
|
+
5e3
|
|
19214
|
+
);
|
|
19215
|
+
return {
|
|
19216
|
+
...options,
|
|
19217
|
+
hydrateDurableState: async (actorKey) => {
|
|
19218
|
+
registerActorSessionPersistenceTasks();
|
|
19219
|
+
const response = await import_core6.default.inquire(
|
|
19220
|
+
META_ACTOR_SESSION_STATE_HYDRATE_INTENT,
|
|
19221
|
+
{
|
|
19222
|
+
actor_name: actorName,
|
|
19223
|
+
actor_version: actorVersion,
|
|
19224
|
+
actor_key: actorKey
|
|
19225
|
+
},
|
|
19226
|
+
{
|
|
19227
|
+
timeout: timeoutMs,
|
|
19228
|
+
requireComplete: true,
|
|
19229
|
+
rejectOnTimeout: true
|
|
19230
|
+
}
|
|
19231
|
+
);
|
|
19232
|
+
if (!response || typeof response !== "object" || response.__success !== true) {
|
|
19233
|
+
throw new Error(
|
|
19234
|
+
resolveInquiryFailureError(
|
|
19235
|
+
META_ACTOR_SESSION_STATE_HYDRATE_INTENT,
|
|
19236
|
+
response
|
|
19237
|
+
)
|
|
19238
|
+
);
|
|
19239
|
+
}
|
|
19240
|
+
if (response.hydrated !== true) {
|
|
19241
|
+
return null;
|
|
19242
|
+
}
|
|
19243
|
+
return {
|
|
19244
|
+
durableState: response.durable_state,
|
|
19245
|
+
durableVersion: Number(response.durable_version)
|
|
19246
|
+
};
|
|
19247
|
+
}
|
|
19248
|
+
};
|
|
18253
19249
|
}
|
|
18254
19250
|
/**
|
|
18255
19251
|
* Creates and registers a new task with the provided name, function, and optional details.
|
|
@@ -18323,7 +19319,7 @@ var CadenzaService = class {
|
|
|
18323
19319
|
*/
|
|
18324
19320
|
static createTask(name, func, description, options = {}) {
|
|
18325
19321
|
this.bootstrap();
|
|
18326
|
-
return
|
|
19322
|
+
return import_core6.default.createTask(name, func, description, options);
|
|
18327
19323
|
}
|
|
18328
19324
|
/**
|
|
18329
19325
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
@@ -18339,7 +19335,7 @@ var CadenzaService = class {
|
|
|
18339
19335
|
*/
|
|
18340
19336
|
static createMetaTask(name, func, description, options = {}) {
|
|
18341
19337
|
this.bootstrap();
|
|
18342
|
-
return
|
|
19338
|
+
return import_core6.default.createMetaTask(name, func, description, options);
|
|
18343
19339
|
}
|
|
18344
19340
|
/**
|
|
18345
19341
|
* Creates a unique task by wrapping the provided task function with a uniqueness constraint.
|
|
@@ -18389,7 +19385,7 @@ var CadenzaService = class {
|
|
|
18389
19385
|
*/
|
|
18390
19386
|
static createUniqueTask(name, func, description, options = {}) {
|
|
18391
19387
|
this.bootstrap();
|
|
18392
|
-
return
|
|
19388
|
+
return import_core6.default.createUniqueTask(name, func, description, options);
|
|
18393
19389
|
}
|
|
18394
19390
|
/**
|
|
18395
19391
|
* Creates a unique meta task with the specified name, function, description, and options.
|
|
@@ -18403,7 +19399,7 @@ var CadenzaService = class {
|
|
|
18403
19399
|
*/
|
|
18404
19400
|
static createUniqueMetaTask(name, func, description, options = {}) {
|
|
18405
19401
|
this.bootstrap();
|
|
18406
|
-
return
|
|
19402
|
+
return import_core6.default.createUniqueMetaTask(name, func, description, options);
|
|
18407
19403
|
}
|
|
18408
19404
|
/**
|
|
18409
19405
|
* Creates a throttled task with a concurrency limit of 1, ensuring that only one instance of the task can run at a time for a specific throttle tag.
|
|
@@ -18436,7 +19432,7 @@ var CadenzaService = class {
|
|
|
18436
19432
|
*/
|
|
18437
19433
|
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
18438
19434
|
this.bootstrap();
|
|
18439
|
-
return
|
|
19435
|
+
return import_core6.default.createThrottledTask(
|
|
18440
19436
|
name,
|
|
18441
19437
|
func,
|
|
18442
19438
|
throttledIdGetter,
|
|
@@ -18457,7 +19453,7 @@ var CadenzaService = class {
|
|
|
18457
19453
|
*/
|
|
18458
19454
|
static createThrottledMetaTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
18459
19455
|
this.bootstrap();
|
|
18460
|
-
return
|
|
19456
|
+
return import_core6.default.createThrottledMetaTask(
|
|
18461
19457
|
name,
|
|
18462
19458
|
func,
|
|
18463
19459
|
throttledIdGetter,
|
|
@@ -18500,7 +19496,7 @@ var CadenzaService = class {
|
|
|
18500
19496
|
*/
|
|
18501
19497
|
static createDebounceTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
18502
19498
|
this.bootstrap();
|
|
18503
|
-
return
|
|
19499
|
+
return import_core6.default.createDebounceTask(
|
|
18504
19500
|
name,
|
|
18505
19501
|
func,
|
|
18506
19502
|
description,
|
|
@@ -18521,7 +19517,7 @@ var CadenzaService = class {
|
|
|
18521
19517
|
*/
|
|
18522
19518
|
static createDebounceMetaTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
18523
19519
|
this.bootstrap();
|
|
18524
|
-
return
|
|
19520
|
+
return import_core6.default.createDebounceMetaTask(
|
|
18525
19521
|
name,
|
|
18526
19522
|
func,
|
|
18527
19523
|
description,
|
|
@@ -18591,7 +19587,7 @@ var CadenzaService = class {
|
|
|
18591
19587
|
*/
|
|
18592
19588
|
static createEphemeralTask(name, func, description, options = {}) {
|
|
18593
19589
|
this.bootstrap();
|
|
18594
|
-
return
|
|
19590
|
+
return import_core6.default.createEphemeralTask(name, func, description, options);
|
|
18595
19591
|
}
|
|
18596
19592
|
/**
|
|
18597
19593
|
* Creates an ephemeral meta-task with the specified name, function, description, and options.
|
|
@@ -18605,7 +19601,7 @@ var CadenzaService = class {
|
|
|
18605
19601
|
*/
|
|
18606
19602
|
static createEphemeralMetaTask(name, func, description, options = {}) {
|
|
18607
19603
|
this.bootstrap();
|
|
18608
|
-
return
|
|
19604
|
+
return import_core6.default.createEphemeralMetaTask(name, func, description, options);
|
|
18609
19605
|
}
|
|
18610
19606
|
/**
|
|
18611
19607
|
* Creates a new routine with the specified name, tasks, and an optional description.
|
|
@@ -18637,7 +19633,7 @@ var CadenzaService = class {
|
|
|
18637
19633
|
*/
|
|
18638
19634
|
static createRoutine(name, tasks, description = "") {
|
|
18639
19635
|
this.bootstrap();
|
|
18640
|
-
return
|
|
19636
|
+
return import_core6.default.createRoutine(name, tasks, description);
|
|
18641
19637
|
}
|
|
18642
19638
|
/**
|
|
18643
19639
|
* Creates a meta routine with a given name, tasks, and optional description.
|
|
@@ -18652,10 +19648,10 @@ var CadenzaService = class {
|
|
|
18652
19648
|
*/
|
|
18653
19649
|
static createMetaRoutine(name, tasks, description = "") {
|
|
18654
19650
|
this.bootstrap();
|
|
18655
|
-
return
|
|
19651
|
+
return import_core6.default.createMetaRoutine(name, tasks, description);
|
|
18656
19652
|
}
|
|
18657
19653
|
static reset() {
|
|
18658
|
-
|
|
19654
|
+
import_core6.default.reset();
|
|
18659
19655
|
this.serviceRegistry?.reset();
|
|
18660
19656
|
this.unregisterGracefulShutdownHandlers();
|
|
18661
19657
|
this.isBootstrapped = false;
|
|
@@ -18667,6 +19663,11 @@ var CadenzaService = class {
|
|
|
18667
19663
|
this.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
18668
19664
|
this.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
18669
19665
|
this.frontendSyncScheduled = false;
|
|
19666
|
+
this.serviceManifestRevision = 0;
|
|
19667
|
+
this.lastPublishedServiceManifestHashes = {};
|
|
19668
|
+
this.serviceManifestPublicationInFlight = false;
|
|
19669
|
+
this.serviceManifestPublicationPendingReason = null;
|
|
19670
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
18670
19671
|
resetBrowserRuntimeActorHandles();
|
|
18671
19672
|
}
|
|
18672
19673
|
};
|
|
@@ -18680,15 +19681,16 @@ CadenzaService.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
|
18680
19681
|
CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
18681
19682
|
CadenzaService.frontendSyncScheduled = false;
|
|
18682
19683
|
CadenzaService.serviceManifestRevision = 0;
|
|
18683
|
-
CadenzaService.
|
|
19684
|
+
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
18684
19685
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
18685
19686
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
19687
|
+
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
18686
19688
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
18687
19689
|
CadenzaService.shutdownInFlight = false;
|
|
18688
19690
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
18689
19691
|
|
|
18690
19692
|
// src/index.ts
|
|
18691
|
-
var
|
|
19693
|
+
var import_core7 = require("@cadenza.io/core");
|
|
18692
19694
|
|
|
18693
19695
|
// src/ssr/createSSRInquiryBridge.ts
|
|
18694
19696
|
var import_uuid8 = require("uuid");
|
|
@@ -18710,6 +19712,17 @@ function normalizeArrayResponse(value, keys) {
|
|
|
18710
19712
|
if (Array.isArray(value?.data)) {
|
|
18711
19713
|
return value.data;
|
|
18712
19714
|
}
|
|
19715
|
+
const joinedContexts = Array.isArray(value?.joinedContexts) ? value.joinedContexts : [];
|
|
19716
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
19717
|
+
const nested = joinedContexts[index];
|
|
19718
|
+
if (!nested || typeof nested !== "object") {
|
|
19719
|
+
continue;
|
|
19720
|
+
}
|
|
19721
|
+
const rows = normalizeArrayResponse(nested, keys);
|
|
19722
|
+
if (rows.length > 0) {
|
|
19723
|
+
return rows;
|
|
19724
|
+
}
|
|
19725
|
+
}
|
|
18713
19726
|
return [];
|
|
18714
19727
|
}
|
|
18715
19728
|
function buildQueryResponseKeys(tableName) {
|