@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/index.mjs
CHANGED
|
@@ -79,14 +79,55 @@ var ROOT_METADATA_PASSTHROUGH_KEYS = [
|
|
|
79
79
|
"__inquirySourceRoutineExecutionId"
|
|
80
80
|
];
|
|
81
81
|
var DELEGATION_REQUEST_SNAPSHOT_KEY = "__delegationRequestContext";
|
|
82
|
+
var DELEGATION_FAILURE_CONTEXT_KEYS = [
|
|
83
|
+
"__remoteRoutineName",
|
|
84
|
+
"__serviceName",
|
|
85
|
+
"__timeout",
|
|
86
|
+
"__localTaskName",
|
|
87
|
+
"__localTaskVersion",
|
|
88
|
+
"__localServiceName",
|
|
89
|
+
"__localRoutineExecId",
|
|
90
|
+
"__previousTaskExecutionId",
|
|
91
|
+
"__fetchId",
|
|
92
|
+
"fetchId",
|
|
93
|
+
"__routeKey",
|
|
94
|
+
"routeKey",
|
|
95
|
+
"__instance",
|
|
96
|
+
"__transportId",
|
|
97
|
+
"__transportOrigin",
|
|
98
|
+
"__transportProtocols",
|
|
99
|
+
"__transportProtocol",
|
|
100
|
+
"__retries",
|
|
101
|
+
"__triedInstances",
|
|
102
|
+
"__delegationRequestContext",
|
|
103
|
+
"__metadata",
|
|
104
|
+
"serviceName",
|
|
105
|
+
"serviceInstanceId",
|
|
106
|
+
"serviceTransportId",
|
|
107
|
+
"serviceOrigin",
|
|
108
|
+
"transportProtocols",
|
|
109
|
+
"transportProtocol"
|
|
110
|
+
];
|
|
111
|
+
function isPlainObject(value) {
|
|
112
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
const prototype = Object.getPrototypeOf(value);
|
|
116
|
+
return prototype === Object.prototype || prototype === null;
|
|
117
|
+
}
|
|
82
118
|
function cloneDelegationValue(value) {
|
|
119
|
+
if (value instanceof Date) {
|
|
120
|
+
return new Date(value.getTime());
|
|
121
|
+
}
|
|
83
122
|
if (Array.isArray(value)) {
|
|
84
|
-
return value.map(
|
|
85
|
-
(item) => item && typeof item === "object" ? { ...item } : item
|
|
86
|
-
);
|
|
123
|
+
return value.map((item) => cloneDelegationValue(item));
|
|
87
124
|
}
|
|
88
|
-
if (value
|
|
89
|
-
|
|
125
|
+
if (isPlainObject(value)) {
|
|
126
|
+
const clone = {};
|
|
127
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
128
|
+
clone[key] = cloneDelegationValue(nestedValue);
|
|
129
|
+
}
|
|
130
|
+
return clone;
|
|
90
131
|
}
|
|
91
132
|
return value;
|
|
92
133
|
}
|
|
@@ -122,9 +163,9 @@ function attachDelegationRequestSnapshot(input) {
|
|
|
122
163
|
function restoreDelegationRequestSnapshot(input) {
|
|
123
164
|
const context = input && typeof input === "object" ? { ...input } : {};
|
|
124
165
|
const mutableContext = context;
|
|
125
|
-
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
166
|
+
const snapshotCandidate = mutableContext[DELEGATION_REQUEST_SNAPSHOT_KEY] ?? (mutableContext.__metadata && typeof mutableContext.__metadata === "object" ? mutableContext.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] : void 0);
|
|
126
167
|
const snapshot = snapshotCandidate && typeof snapshotCandidate === "object" ? snapshotCandidate : null;
|
|
127
|
-
const looksLikeDelegationResult = mutableContext.__status !== void 0 || mutableContext.__success !== void 0 || mutableContext.rowCount !== void 0 || mutableContext.__nextNodes !== void 0 || mutableContext.__isDeputy === true;
|
|
168
|
+
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;
|
|
128
169
|
if (!snapshot || !looksLikeDelegationResult) {
|
|
129
170
|
return context;
|
|
130
171
|
}
|
|
@@ -145,6 +186,26 @@ function stripDelegationRequestSnapshot(input) {
|
|
|
145
186
|
delete context[DELEGATION_REQUEST_SNAPSHOT_KEY];
|
|
146
187
|
return context;
|
|
147
188
|
}
|
|
189
|
+
function buildDelegationFailureContext(signalName, input, error) {
|
|
190
|
+
const source = input && typeof input === "object" ? { ...input } : {};
|
|
191
|
+
const slimContext = {};
|
|
192
|
+
for (const key of DELEGATION_FAILURE_CONTEXT_KEYS) {
|
|
193
|
+
if (source[key] !== void 0) {
|
|
194
|
+
slimContext[key] = cloneDelegationValue(source[key]);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] === void 0 && source.__metadata && typeof source.__metadata === "object" && source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY] !== void 0) {
|
|
198
|
+
slimContext[DELEGATION_REQUEST_SNAPSHOT_KEY] = cloneDelegationValue(
|
|
199
|
+
source.__metadata[DELEGATION_REQUEST_SNAPSHOT_KEY]
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
__signalName: signalName,
|
|
204
|
+
__error: error instanceof Error ? error.message : String(error ?? "Unknown error"),
|
|
205
|
+
errored: true,
|
|
206
|
+
...slimContext
|
|
207
|
+
};
|
|
208
|
+
}
|
|
148
209
|
function stripTransportSelectionRoutingContext(input) {
|
|
149
210
|
const context = stripLocalRoutinePersistenceHints(
|
|
150
211
|
input && typeof input === "object" ? { ...input } : {}
|
|
@@ -364,6 +425,8 @@ var DeputyTask = class extends Task {
|
|
|
364
425
|
|
|
365
426
|
// src/graph/definition/DatabaseTask.ts
|
|
366
427
|
var ACTOR_SESSION_TRACE_ENABLED = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
428
|
+
var actorSessionEmptyDelegationLogCount = 0;
|
|
429
|
+
var ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT = 40;
|
|
367
430
|
var INSTANCE_TRACE_ENABLED = process.env.CADENZA_INSTANCE_DEBUG === "1" || process.env.CADENZA_INSTANCE_DEBUG === "true";
|
|
368
431
|
var EXECUTION_OBSERVABILITY_INSERT_ROUTINES = /* @__PURE__ */ new Set([
|
|
369
432
|
"Insert execution_trace",
|
|
@@ -465,15 +528,16 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
465
528
|
}
|
|
466
529
|
delete ctx.__metadata;
|
|
467
530
|
const isResolverExecution = typeof ctx.__resolverRequestId === "string" && ctx.__resolverRequestId.length > 0;
|
|
468
|
-
const
|
|
531
|
+
const resolverQueryData = ctx.__resolverQueryData && typeof ctx.__resolverQueryData === "object" ? ctx.__resolverQueryData : null;
|
|
532
|
+
const dynamicQueryData = resolverQueryData ?? (ctx.queryData && typeof ctx.queryData === "object" ? ctx.queryData : {});
|
|
469
533
|
delete ctx.queryData;
|
|
470
534
|
const nextQueryData = {
|
|
471
535
|
...this.queryData,
|
|
472
|
-
data: {
|
|
473
|
-
...ctx.data
|
|
474
|
-
},
|
|
475
536
|
...dynamicQueryData
|
|
476
537
|
};
|
|
538
|
+
if (dynamicQueryData.data === void 0 && ctx.data !== void 0) {
|
|
539
|
+
nextQueryData.data = ctx.data && typeof ctx.data === "object" && !Array.isArray(ctx.data) ? { ...ctx.data } : ctx.data;
|
|
540
|
+
}
|
|
477
541
|
const deputyContext = attachDelegationRequestSnapshot(
|
|
478
542
|
stripDelegationRequestSnapshot(
|
|
479
543
|
hoistDelegationMetadataFields({
|
|
@@ -533,6 +597,22 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
533
597
|
rootKeys: Object.keys(rawContext)
|
|
534
598
|
});
|
|
535
599
|
}
|
|
600
|
+
if (this.remoteRoutineName === "Insert actor_session_state" && deputyContext.data === void 0 && deputyContext.queryData === void 0 && actorSessionEmptyDelegationLogCount < ACTOR_SESSION_EMPTY_DELEGATION_LOG_LIMIT) {
|
|
601
|
+
actorSessionEmptyDelegationLogCount += 1;
|
|
602
|
+
console.warn("[CADENZA_ACTOR_SESSION_EMPTY_DELEGATION]", {
|
|
603
|
+
localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
604
|
+
localTaskName: this.name,
|
|
605
|
+
remoteRoutineName: this.remoteRoutineName,
|
|
606
|
+
hadSnapshotBeforeRestore: initialFullContext.__delegationRequestContext !== void 0 || initialFullContext.__metadata?.__delegationRequestContext !== void 0,
|
|
607
|
+
restoredRootKeys: Object.keys(rawContext),
|
|
608
|
+
deputyRootKeys: Object.keys(deputyContext),
|
|
609
|
+
signalName: rawContext.__signalName ?? rawContext.__metadata?.__signalName ?? null,
|
|
610
|
+
inquiryName: rawContext.__inquiryName ?? rawContext.__metadata?.__inquiryName ?? null,
|
|
611
|
+
sourceServiceName: rawContext.__localServiceName ?? rawContext.__metadata?.__localServiceName ?? null,
|
|
612
|
+
sourceRoutineName: rawContext.__routineName ?? rawContext.__metadata?.__routineName ?? null,
|
|
613
|
+
sourceTaskName: rawContext.__localTaskName ?? rawContext.__metadata?.__localTaskName ?? null
|
|
614
|
+
});
|
|
615
|
+
}
|
|
536
616
|
return this.taskFunction(deputyContext, emit2, inquire, progressCallback);
|
|
537
617
|
}
|
|
538
618
|
};
|
|
@@ -578,6 +658,26 @@ var AUTHORITY_SYNC_DEBUG_TASK_NAMES = /* @__PURE__ */ new Set([
|
|
|
578
658
|
]);
|
|
579
659
|
var AUTHORITY_SYNC_DEBUG_ROUTINE_NAMES = /* @__PURE__ */ new Set(["Sync services"]);
|
|
580
660
|
var INTENT_MAP_DEBUG_ENABLED = process.env.CADENZA_INTENT_MAP_DEBUG === "1" || process.env.CADENZA_INTENT_MAP_DEBUG === "true";
|
|
661
|
+
function normalizeQueryResultValue(value) {
|
|
662
|
+
if (value instanceof Date) {
|
|
663
|
+
return value.toISOString();
|
|
664
|
+
}
|
|
665
|
+
if (Array.isArray(value)) {
|
|
666
|
+
return value.map((entry) => normalizeQueryResultValue(entry));
|
|
667
|
+
}
|
|
668
|
+
if (value && typeof value === "object") {
|
|
669
|
+
const prototype = Object.getPrototypeOf(value);
|
|
670
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
671
|
+
return Object.fromEntries(
|
|
672
|
+
Object.entries(value).map(([key, nestedValue]) => [
|
|
673
|
+
key,
|
|
674
|
+
normalizeQueryResultValue(nestedValue)
|
|
675
|
+
])
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
return value;
|
|
680
|
+
}
|
|
581
681
|
var POSTGRES_SETUP_DEBUG_ENABLED = process.env.CADENZA_POSTGRES_SETUP_DEBUG === "1" || process.env.CADENZA_POSTGRES_SETUP_DEBUG === "true";
|
|
582
682
|
var ACTOR_SESSION_TRACE_ENABLED2 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
583
683
|
var ACTOR_SESSION_TRACE_LIMIT = 20;
|
|
@@ -875,14 +975,14 @@ function errorMessage(error) {
|
|
|
875
975
|
}
|
|
876
976
|
return String(error);
|
|
877
977
|
}
|
|
878
|
-
function
|
|
978
|
+
function isPlainObject2(value) {
|
|
879
979
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
880
980
|
}
|
|
881
981
|
function stableStringify(value) {
|
|
882
982
|
if (Array.isArray(value)) {
|
|
883
983
|
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
884
984
|
}
|
|
885
|
-
if (
|
|
985
|
+
if (isPlainObject2(value)) {
|
|
886
986
|
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
|
|
887
987
|
}
|
|
888
988
|
return JSON.stringify(value);
|
|
@@ -998,7 +1098,23 @@ function resolveGeneratedTaskTag(tableName, actorToken, context, operation) {
|
|
|
998
1098
|
if (operation === "insert") {
|
|
999
1099
|
return `insert:${actorToken}:${tableName}`;
|
|
1000
1100
|
}
|
|
1001
|
-
|
|
1101
|
+
const traceScopedTag = context?.__metadata?.__executionTraceId ?? context?.__executionTraceId ?? context?.__metadata?.__deputyExecId ?? context?.__deputyExecId ?? context?.__metadata?.__inquiryId ?? context?.__inquiryId ?? context?.__metadata?.__routineExecId ?? context?.__routineExecId ?? context?.__metadata?.__localRoutineExecId ?? context?.__localRoutineExecId;
|
|
1102
|
+
if (typeof traceScopedTag === "string" && traceScopedTag.length > 0) {
|
|
1103
|
+
return traceScopedTag;
|
|
1104
|
+
}
|
|
1105
|
+
const queryScope = {
|
|
1106
|
+
queryData: context?.queryData,
|
|
1107
|
+
filter: context?.filter,
|
|
1108
|
+
fields: context?.fields,
|
|
1109
|
+
joins: context?.joins,
|
|
1110
|
+
sort: context?.sort,
|
|
1111
|
+
limit: context?.limit,
|
|
1112
|
+
offset: context?.offset,
|
|
1113
|
+
queryMode: context?.queryMode,
|
|
1114
|
+
aggregates: context?.aggregates,
|
|
1115
|
+
groupBy: context?.groupBy
|
|
1116
|
+
};
|
|
1117
|
+
return `read:${actorToken}:${tableName}:${stableStringify(queryScope)}`;
|
|
1002
1118
|
}
|
|
1003
1119
|
function resolveExecutionObservabilitySafetyPolicyForTable(basePolicy, tableName) {
|
|
1004
1120
|
if (!EXECUTION_OBSERVABILITY_TABLES.has(tableName)) {
|
|
@@ -1080,6 +1196,44 @@ function mergeTriggerQueryData(context, triggerQueryData) {
|
|
|
1080
1196
|
...triggerQueryData
|
|
1081
1197
|
};
|
|
1082
1198
|
}
|
|
1199
|
+
function isNonEmptyPlainObject(value) {
|
|
1200
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0;
|
|
1201
|
+
}
|
|
1202
|
+
function isMissingInsertData(data) {
|
|
1203
|
+
return !data || Array.isArray(data) && data.length === 0 || typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0;
|
|
1204
|
+
}
|
|
1205
|
+
function resolveActorSessionDelegationSnapshot(context) {
|
|
1206
|
+
const direct = context.__delegationRequestContext && typeof context.__delegationRequestContext === "object" ? context.__delegationRequestContext : null;
|
|
1207
|
+
if (direct) {
|
|
1208
|
+
return direct;
|
|
1209
|
+
}
|
|
1210
|
+
const metadata = context.__metadata && typeof context.__metadata === "object" ? context.__metadata : null;
|
|
1211
|
+
const nested = metadata?.__delegationRequestContext && typeof metadata.__delegationRequestContext === "object" ? metadata.__delegationRequestContext : null;
|
|
1212
|
+
return nested;
|
|
1213
|
+
}
|
|
1214
|
+
function recoverActorSessionInsertPayload(context, payload) {
|
|
1215
|
+
if (!isMissingInsertData(payload.data)) {
|
|
1216
|
+
return payload;
|
|
1217
|
+
}
|
|
1218
|
+
const snapshot = resolveActorSessionDelegationSnapshot(context);
|
|
1219
|
+
if (!snapshot) {
|
|
1220
|
+
return payload;
|
|
1221
|
+
}
|
|
1222
|
+
const snapshotQueryData = snapshot.queryData && typeof snapshot.queryData === "object" ? { ...snapshot.queryData } : {};
|
|
1223
|
+
const snapshotData = isNonEmptyPlainObject(snapshotQueryData.data) ? snapshotQueryData.data : isNonEmptyPlainObject(snapshot.data) ? snapshot.data : null;
|
|
1224
|
+
if (!snapshotData) {
|
|
1225
|
+
return payload;
|
|
1226
|
+
}
|
|
1227
|
+
const recoveredPayload = {
|
|
1228
|
+
...snapshotQueryData,
|
|
1229
|
+
...payload,
|
|
1230
|
+
data: snapshotData
|
|
1231
|
+
};
|
|
1232
|
+
if (recoveredPayload.onConflict === void 0 && snapshotQueryData.onConflict) {
|
|
1233
|
+
recoveredPayload.onConflict = snapshotQueryData.onConflict;
|
|
1234
|
+
}
|
|
1235
|
+
return recoveredPayload;
|
|
1236
|
+
}
|
|
1083
1237
|
function resolveOperationPayload(context) {
|
|
1084
1238
|
const queryData = typeof context.queryData === "object" && context.queryData ? context.queryData : {};
|
|
1085
1239
|
return mergeTriggerQueryData(context, queryData);
|
|
@@ -1807,6 +1961,23 @@ var DatabaseController = class _DatabaseController {
|
|
|
1807
1961
|
async insertFunction(registration, tableName, context) {
|
|
1808
1962
|
const { data, transaction = true, fields = [], onConflict } = context;
|
|
1809
1963
|
if (!data || Array.isArray(data) && data.length === 0) {
|
|
1964
|
+
if (tableName === "actor_session_state") {
|
|
1965
|
+
const rawContext = context;
|
|
1966
|
+
const rawMetadata = rawContext.__metadata && typeof rawContext.__metadata === "object" ? rawContext.__metadata : void 0;
|
|
1967
|
+
console.warn("[CADENZA_ACTOR_SESSION_EMPTY_INSERT]", {
|
|
1968
|
+
tableName,
|
|
1969
|
+
contextKeys: Object.keys(context ?? {}),
|
|
1970
|
+
queryDataKeys: [],
|
|
1971
|
+
hasDelegationSnapshot: rawContext.__delegationRequestContext !== void 0 || rawMetadata?.__delegationRequestContext !== void 0,
|
|
1972
|
+
localTaskName: typeof rawContext.__localTaskName === "string" ? rawContext.__localTaskName : void 0,
|
|
1973
|
+
remoteRoutineName: typeof rawContext.__remoteRoutineName === "string" ? rawContext.__remoteRoutineName : void 0,
|
|
1974
|
+
serviceName: typeof rawContext.__serviceName === "string" ? rawContext.__serviceName : void 0,
|
|
1975
|
+
actorName: typeof rawContext.actor_name === "string" ? rawContext.actor_name : void 0,
|
|
1976
|
+
actorKey: typeof rawContext.actor_key === "string" ? rawContext.actor_key : void 0,
|
|
1977
|
+
durableVersion: rawContext.durable_version,
|
|
1978
|
+
metadata: rawMetadata
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1810
1981
|
return {
|
|
1811
1982
|
rowCount: 0,
|
|
1812
1983
|
errored: true,
|
|
@@ -2876,9 +3047,18 @@ var DatabaseController = class _DatabaseController {
|
|
|
2876
3047
|
}
|
|
2877
3048
|
}
|
|
2878
3049
|
}
|
|
2879
|
-
const
|
|
3050
|
+
const initialOperationPayload = resolveOperationPayload(context);
|
|
3051
|
+
let operationPayload = initialOperationPayload;
|
|
3052
|
+
if (tableName === "actor_session_state" && op === "insert") {
|
|
3053
|
+
operationPayload = recoverActorSessionInsertPayload(
|
|
3054
|
+
context,
|
|
3055
|
+
operationPayload
|
|
3056
|
+
);
|
|
3057
|
+
}
|
|
2880
3058
|
const actorSessionInsertData = operationPayload.data;
|
|
2881
|
-
const actorSessionInsertMissingData =
|
|
3059
|
+
const actorSessionInsertMissingData = isMissingInsertData(
|
|
3060
|
+
actorSessionInsertData
|
|
3061
|
+
);
|
|
2882
3062
|
if (tableName === "actor_session_state" && op === "insert" && actorSessionInsertMissingData) {
|
|
2883
3063
|
logActorSessionTrace("empty_insert_payload", {
|
|
2884
3064
|
taskName,
|
|
@@ -2894,7 +3074,10 @@ var DatabaseController = class _DatabaseController {
|
|
|
2894
3074
|
payloadDataType: actorSessionInsertData === null ? "null" : Array.isArray(actorSessionInsertData) ? "array" : typeof actorSessionInsertData,
|
|
2895
3075
|
payloadDataKeys: actorSessionInsertData && typeof actorSessionInsertData === "object" && !Array.isArray(actorSessionInsertData) ? Object.keys(actorSessionInsertData) : [],
|
|
2896
3076
|
queryDataKeys: context.queryData && typeof context.queryData === "object" && !Array.isArray(context.queryData) ? Object.keys(context.queryData) : [],
|
|
2897
|
-
rootKeys: Object.keys(context ?? {}).slice(0, 24)
|
|
3077
|
+
rootKeys: Object.keys(context ?? {}).slice(0, 24),
|
|
3078
|
+
initialPayloadMissingData: isMissingInsertData(
|
|
3079
|
+
initialOperationPayload.data
|
|
3080
|
+
)
|
|
2898
3081
|
});
|
|
2899
3082
|
}
|
|
2900
3083
|
const shouldDebugAuthoritySync = shouldDebugAuthoritySyncPayload(
|
|
@@ -3189,7 +3372,7 @@ var DatabaseController = class _DatabaseController {
|
|
|
3189
3372
|
return rows.map((row) => {
|
|
3190
3373
|
const camelCasedRow = {};
|
|
3191
3374
|
for (const [key, value] of Object.entries(row)) {
|
|
3192
|
-
camelCasedRow[camelCase(key)] = value;
|
|
3375
|
+
camelCasedRow[camelCase(key)] = normalizeQueryResultValue(value);
|
|
3193
3376
|
}
|
|
3194
3377
|
return camelCasedRow;
|
|
3195
3378
|
});
|
|
@@ -3624,14 +3807,14 @@ var META_INTENT_PREFIX = "meta-";
|
|
|
3624
3807
|
var META_RUNTIME_TRANSPORT_DIAGNOSTICS_INTENT = "meta-runtime-transport-diagnostics";
|
|
3625
3808
|
var META_RUNTIME_STATUS_INTENT = "meta-runtime-status";
|
|
3626
3809
|
var META_READINESS_INTENT = "meta-readiness";
|
|
3627
|
-
function
|
|
3810
|
+
function isPlainObject3(value) {
|
|
3628
3811
|
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
3629
3812
|
}
|
|
3630
3813
|
function deepMergeDeterministic(left, right) {
|
|
3631
3814
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
3632
3815
|
return [...left, ...right];
|
|
3633
3816
|
}
|
|
3634
|
-
if (
|
|
3817
|
+
if (isPlainObject3(left) && isPlainObject3(right)) {
|
|
3635
3818
|
const merged = { ...left };
|
|
3636
3819
|
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])).sort();
|
|
3637
3820
|
for (const key of keys) {
|
|
@@ -4453,6 +4636,7 @@ function normalizeServiceManifestSnapshot(input) {
|
|
|
4453
4636
|
revision,
|
|
4454
4637
|
manifestHash,
|
|
4455
4638
|
publishedAt,
|
|
4639
|
+
publicationLayer: record.publicationLayer === "routing_capability" || record.publicationLayer === "business_structural" || record.publicationLayer === "local_meta_structural" ? record.publicationLayer : "business_structural",
|
|
4456
4640
|
tasks: normalizeArray(record.tasks),
|
|
4457
4641
|
signals: normalizeArray(record.signals),
|
|
4458
4642
|
intents: normalizeArray(record.intents),
|
|
@@ -4582,6 +4766,7 @@ function decomposeSignalName(signalName) {
|
|
|
4582
4766
|
}
|
|
4583
4767
|
|
|
4584
4768
|
// src/registry/serviceManifest.ts
|
|
4769
|
+
import CoreCadenza from "@cadenza.io/core";
|
|
4585
4770
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
4586
4771
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
4587
4772
|
if (typeof taskFunction !== "function") {
|
|
@@ -4726,14 +4911,48 @@ function buildRoutineDefinition(routine, serviceName) {
|
|
|
4726
4911
|
};
|
|
4727
4912
|
}
|
|
4728
4913
|
function shouldExportTask(task) {
|
|
4729
|
-
return !task.isDeputy && !task.isEphemeral;
|
|
4914
|
+
return task.register !== false && task.isHidden !== true && !task.isDeputy && !task.isEphemeral;
|
|
4730
4915
|
}
|
|
4731
4916
|
function shouldExportRoutine(routine) {
|
|
4732
4917
|
return Boolean(String(routine?.name ?? "").trim());
|
|
4733
4918
|
}
|
|
4919
|
+
function buildTaskKey(task) {
|
|
4920
|
+
return `${task.service_name}|${task.name}|${task.version}`;
|
|
4921
|
+
}
|
|
4922
|
+
function buildActorKey(actor) {
|
|
4923
|
+
return `${actor.service_name}|${actor.name}|${actor.version}`;
|
|
4924
|
+
}
|
|
4925
|
+
function buildRoutineKey(routine) {
|
|
4926
|
+
return `${routine.service_name}|${routine.name}|${routine.version}`;
|
|
4927
|
+
}
|
|
4928
|
+
function listManifestTasks() {
|
|
4929
|
+
const registryTasks = Array.from(CadenzaService.registry.tasks.values()).filter(
|
|
4930
|
+
(task) => Boolean(task)
|
|
4931
|
+
);
|
|
4932
|
+
const cachedTasks = Array.from(
|
|
4933
|
+
CoreCadenza.taskCache?.values?.() ?? []
|
|
4934
|
+
).filter((task) => Boolean(task));
|
|
4935
|
+
return Array.from(
|
|
4936
|
+
new Map(
|
|
4937
|
+
[...registryTasks, ...cachedTasks].map((task) => [task.name, task])
|
|
4938
|
+
).values()
|
|
4939
|
+
);
|
|
4940
|
+
}
|
|
4941
|
+
function isRoutingCriticalMetaSignal(_signal) {
|
|
4942
|
+
return false;
|
|
4943
|
+
}
|
|
4944
|
+
function isRoutingCriticalMetaIntent(_intent) {
|
|
4945
|
+
return false;
|
|
4946
|
+
}
|
|
4734
4947
|
function buildServiceManifestSnapshot(params) {
|
|
4735
|
-
const {
|
|
4736
|
-
|
|
4948
|
+
const {
|
|
4949
|
+
serviceName,
|
|
4950
|
+
serviceInstanceId,
|
|
4951
|
+
revision,
|
|
4952
|
+
publishedAt,
|
|
4953
|
+
publicationLayer = "business_structural"
|
|
4954
|
+
} = params;
|
|
4955
|
+
const tasks = listManifestTasks().filter(shouldExportTask);
|
|
4737
4956
|
const routines = Array.from(CadenzaService.registry.routines.values()).filter((routine) => Boolean(routine)).filter(shouldExportRoutine);
|
|
4738
4957
|
const actors = CadenzaService.getAllActors();
|
|
4739
4958
|
const taskDefinitions = tasks.map((task) => buildTaskDefinition(task, serviceName)).sort(
|
|
@@ -4881,41 +5100,385 @@ function buildServiceManifestSnapshot(params) {
|
|
|
4881
5100
|
}
|
|
4882
5101
|
}
|
|
4883
5102
|
}
|
|
4884
|
-
const
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
)
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
5103
|
+
const taskDefinitionsByKey = new Map(
|
|
5104
|
+
taskDefinitions.map((task) => [buildTaskKey(task), task])
|
|
5105
|
+
);
|
|
5106
|
+
const signalDefinitionsByName = new Map(
|
|
5107
|
+
Array.from(signalDefinitions.values()).map((signal) => [signal.name, signal])
|
|
5108
|
+
);
|
|
5109
|
+
const intentDefinitionsByName = new Map(
|
|
5110
|
+
intentDefinitions.map((intent) => [intent.name, intent])
|
|
5111
|
+
);
|
|
5112
|
+
const actorDefinitionsByKey = new Map(
|
|
5113
|
+
actorDefinitions.map((actor) => [buildActorKey(actor), actor])
|
|
5114
|
+
);
|
|
5115
|
+
const routineDefinitionsByKey = new Map(
|
|
5116
|
+
routineDefinitions.map((routine) => [buildRoutineKey(routine), routine])
|
|
5117
|
+
);
|
|
5118
|
+
const routingTaskKeys = /* @__PURE__ */ new Set();
|
|
5119
|
+
const routingSignalNames = /* @__PURE__ */ new Set();
|
|
5120
|
+
const routingIntentNames = /* @__PURE__ */ new Set();
|
|
5121
|
+
const publishedSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => {
|
|
5122
|
+
const signal = signalDefinitionsByName.get(map.signal_name);
|
|
5123
|
+
return signal?.is_meta !== true || (signal ? isRoutingCriticalMetaSignal(signal) : false);
|
|
5124
|
+
}).sort(
|
|
5125
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
5126
|
+
`${right.signal_name}:${right.task_name}`
|
|
5127
|
+
)
|
|
5128
|
+
);
|
|
5129
|
+
const publishedIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => {
|
|
5130
|
+
const intent = intentDefinitionsByName.get(map.intent_name);
|
|
5131
|
+
return intent?.is_meta !== true || (intent ? isRoutingCriticalMetaIntent(intent) : false);
|
|
5132
|
+
}).sort(
|
|
5133
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
5134
|
+
`${right.intent_name}:${right.task_name}`
|
|
5135
|
+
)
|
|
5136
|
+
);
|
|
5137
|
+
const localMetaSignalTaskMaps = Array.from(signalTaskMaps.values()).filter((map) => !publishedSignalTaskMaps.includes(map)).sort(
|
|
5138
|
+
(left, right) => `${left.signal_name}:${left.task_name}`.localeCompare(
|
|
5139
|
+
`${right.signal_name}:${right.task_name}`
|
|
5140
|
+
)
|
|
5141
|
+
);
|
|
5142
|
+
const localMetaIntentTaskMaps = Array.from(intentTaskMaps.values()).filter((map) => !publishedIntentTaskMaps.includes(map)).sort(
|
|
5143
|
+
(left, right) => `${left.intent_name}:${left.task_name}`.localeCompare(
|
|
5144
|
+
`${right.intent_name}:${right.task_name}`
|
|
5145
|
+
)
|
|
5146
|
+
);
|
|
5147
|
+
for (const map of publishedSignalTaskMaps) {
|
|
5148
|
+
routingTaskKeys.add(
|
|
5149
|
+
buildTaskKey({
|
|
5150
|
+
service_name: map.service_name,
|
|
5151
|
+
name: map.task_name,
|
|
5152
|
+
version: map.task_version
|
|
5153
|
+
})
|
|
5154
|
+
);
|
|
5155
|
+
routingSignalNames.add(map.signal_name);
|
|
5156
|
+
}
|
|
5157
|
+
for (const map of publishedIntentTaskMaps) {
|
|
5158
|
+
routingTaskKeys.add(
|
|
5159
|
+
buildTaskKey({
|
|
5160
|
+
service_name: map.service_name,
|
|
5161
|
+
name: map.task_name,
|
|
5162
|
+
version: map.task_version
|
|
5163
|
+
})
|
|
5164
|
+
);
|
|
5165
|
+
routingIntentNames.add(map.intent_name);
|
|
5166
|
+
}
|
|
5167
|
+
const routingTasks = Array.from(routingTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter((task) => task !== null).sort(
|
|
5168
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5169
|
+
);
|
|
5170
|
+
const routingSignals = Array.from(routingSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter((signal) => signal !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
5171
|
+
const routingIntents = Array.from(routingIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter((intent) => intent !== null).sort((left, right) => left.name.localeCompare(right.name));
|
|
5172
|
+
const businessTasks = taskDefinitions.filter((task) => task.is_meta !== true && task.is_sub_meta !== true).sort(
|
|
5173
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5174
|
+
);
|
|
5175
|
+
const businessSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
5176
|
+
const businessIntents = intentDefinitions.filter((intent) => intent.is_meta !== true).sort((left, right) => left.name.localeCompare(right.name));
|
|
5177
|
+
const businessActors = actorDefinitions.filter((actor) => actor.is_meta !== true).sort(
|
|
5178
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5179
|
+
);
|
|
5180
|
+
const businessRoutines = routineDefinitions.filter((routine) => routine.is_meta !== true).sort(
|
|
5181
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5182
|
+
);
|
|
5183
|
+
const businessDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => {
|
|
5184
|
+
const predecessor = taskDefinitionsByKey.get(
|
|
5185
|
+
buildTaskKey({
|
|
5186
|
+
service_name: map.predecessor_service_name,
|
|
5187
|
+
name: map.predecessor_task_name,
|
|
5188
|
+
version: map.predecessor_task_version
|
|
5189
|
+
})
|
|
5190
|
+
);
|
|
5191
|
+
const task = taskDefinitionsByKey.get(
|
|
5192
|
+
buildTaskKey({
|
|
5193
|
+
service_name: map.service_name,
|
|
5194
|
+
name: map.task_name,
|
|
5195
|
+
version: map.task_version
|
|
5196
|
+
})
|
|
5197
|
+
);
|
|
5198
|
+
return predecessor?.is_meta !== true && predecessor?.is_sub_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
5199
|
+
}).sort(
|
|
5200
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
5201
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
5202
|
+
)
|
|
5203
|
+
);
|
|
5204
|
+
const businessActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => {
|
|
5205
|
+
const actor = actorDefinitionsByKey.get(
|
|
5206
|
+
buildActorKey({
|
|
5207
|
+
service_name: map.service_name,
|
|
5208
|
+
name: map.actor_name,
|
|
5209
|
+
version: map.actor_version
|
|
5210
|
+
})
|
|
5211
|
+
);
|
|
5212
|
+
const task = taskDefinitionsByKey.get(
|
|
5213
|
+
buildTaskKey({
|
|
5214
|
+
service_name: map.service_name,
|
|
5215
|
+
name: map.task_name,
|
|
5216
|
+
version: map.task_version
|
|
5217
|
+
})
|
|
5218
|
+
);
|
|
5219
|
+
return actor?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
5220
|
+
}).sort(
|
|
5221
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
5222
|
+
`${right.actor_name}:${right.task_name}`
|
|
5223
|
+
)
|
|
5224
|
+
);
|
|
5225
|
+
const businessTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => {
|
|
5226
|
+
const routine = routineDefinitionsByKey.get(
|
|
5227
|
+
buildRoutineKey({
|
|
5228
|
+
service_name: map.service_name,
|
|
5229
|
+
name: map.routine_name,
|
|
5230
|
+
version: map.routine_version
|
|
5231
|
+
})
|
|
5232
|
+
);
|
|
5233
|
+
const task = taskDefinitionsByKey.get(
|
|
5234
|
+
buildTaskKey({
|
|
5235
|
+
service_name: map.service_name,
|
|
5236
|
+
name: map.task_name,
|
|
5237
|
+
version: map.task_version
|
|
5238
|
+
})
|
|
5239
|
+
);
|
|
5240
|
+
return routine?.is_meta !== true && task?.is_meta !== true && task?.is_sub_meta !== true;
|
|
5241
|
+
}).sort(
|
|
5242
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
5243
|
+
`${right.routine_name}:${right.task_name}`
|
|
5244
|
+
)
|
|
5245
|
+
);
|
|
5246
|
+
const localMetaTasks = taskDefinitions.filter((task) => task.is_meta === true || task.is_sub_meta === true).sort(
|
|
5247
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5248
|
+
);
|
|
5249
|
+
const localMetaSignals = Array.from(signalDefinitions.values()).filter((signal) => signal.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
5250
|
+
const localMetaIntents = intentDefinitions.filter((intent) => intent.is_meta === true).sort((left, right) => left.name.localeCompare(right.name));
|
|
5251
|
+
const localMetaActors = actorDefinitions.filter((actor) => actor.is_meta === true).sort(
|
|
5252
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5253
|
+
);
|
|
5254
|
+
const localMetaRoutines = routineDefinitions.filter((routine) => routine.is_meta === true).sort(
|
|
5255
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5256
|
+
);
|
|
5257
|
+
const localMetaDirectionalTaskMaps = Array.from(directionalTaskMaps.values()).filter((map) => !businessDirectionalTaskMaps.includes(map)).sort(
|
|
5258
|
+
(left, right) => `${left.predecessor_task_name}:${left.task_name}`.localeCompare(
|
|
5259
|
+
`${right.predecessor_task_name}:${right.task_name}`
|
|
5260
|
+
)
|
|
5261
|
+
);
|
|
5262
|
+
const localMetaActorTaskMaps = Array.from(actorTaskMaps.values()).filter((map) => !businessActorTaskMaps.includes(map)).sort(
|
|
5263
|
+
(left, right) => `${left.actor_name}:${left.task_name}`.localeCompare(
|
|
5264
|
+
`${right.actor_name}:${right.task_name}`
|
|
5265
|
+
)
|
|
5266
|
+
);
|
|
5267
|
+
const localMetaTaskToRoutineMaps = Array.from(taskToRoutineMaps.values()).filter((map) => !businessTaskToRoutineMaps.includes(map)).sort(
|
|
5268
|
+
(left, right) => `${left.routine_name}:${left.task_name}`.localeCompare(
|
|
5269
|
+
`${right.routine_name}:${right.task_name}`
|
|
5270
|
+
)
|
|
5271
|
+
);
|
|
5272
|
+
const businessLocalMetaTaskKeys = /* @__PURE__ */ new Set();
|
|
5273
|
+
const businessLocalMetaSignalNames = /* @__PURE__ */ new Set();
|
|
5274
|
+
const businessLocalMetaIntentNames = /* @__PURE__ */ new Set();
|
|
5275
|
+
const businessLocalMetaActorKeys = /* @__PURE__ */ new Set();
|
|
5276
|
+
const businessLocalMetaRoutineKeys = /* @__PURE__ */ new Set();
|
|
5277
|
+
for (const map of localMetaSignalTaskMaps) {
|
|
5278
|
+
businessLocalMetaSignalNames.add(map.signal_name);
|
|
5279
|
+
businessLocalMetaTaskKeys.add(
|
|
5280
|
+
buildTaskKey({
|
|
5281
|
+
service_name: map.service_name,
|
|
5282
|
+
name: map.task_name,
|
|
5283
|
+
version: map.task_version
|
|
5284
|
+
})
|
|
5285
|
+
);
|
|
5286
|
+
}
|
|
5287
|
+
for (const map of localMetaIntentTaskMaps) {
|
|
5288
|
+
businessLocalMetaIntentNames.add(map.intent_name);
|
|
5289
|
+
businessLocalMetaTaskKeys.add(
|
|
5290
|
+
buildTaskKey({
|
|
5291
|
+
service_name: map.service_name,
|
|
5292
|
+
name: map.task_name,
|
|
5293
|
+
version: map.task_version
|
|
5294
|
+
})
|
|
5295
|
+
);
|
|
5296
|
+
}
|
|
5297
|
+
for (const map of localMetaActorTaskMaps) {
|
|
5298
|
+
businessLocalMetaActorKeys.add(
|
|
5299
|
+
buildActorKey({
|
|
5300
|
+
service_name: map.service_name,
|
|
5301
|
+
name: map.actor_name,
|
|
5302
|
+
version: map.actor_version
|
|
5303
|
+
})
|
|
5304
|
+
);
|
|
5305
|
+
businessLocalMetaTaskKeys.add(
|
|
5306
|
+
buildTaskKey({
|
|
5307
|
+
service_name: map.service_name,
|
|
5308
|
+
name: map.task_name,
|
|
5309
|
+
version: map.task_version
|
|
5310
|
+
})
|
|
5311
|
+
);
|
|
5312
|
+
}
|
|
5313
|
+
for (const map of localMetaTaskToRoutineMaps) {
|
|
5314
|
+
businessLocalMetaRoutineKeys.add(
|
|
5315
|
+
buildRoutineKey({
|
|
5316
|
+
service_name: map.service_name,
|
|
5317
|
+
name: map.routine_name,
|
|
5318
|
+
version: map.routine_version
|
|
5319
|
+
})
|
|
5320
|
+
);
|
|
5321
|
+
businessLocalMetaTaskKeys.add(
|
|
5322
|
+
buildTaskKey({
|
|
5323
|
+
service_name: map.service_name,
|
|
5324
|
+
name: map.task_name,
|
|
5325
|
+
version: map.task_version
|
|
5326
|
+
})
|
|
5327
|
+
);
|
|
5328
|
+
}
|
|
5329
|
+
const businessLocalMetaTasks = Array.from(businessLocalMetaTaskKeys).map((key) => taskDefinitionsByKey.get(key) ?? null).filter(
|
|
5330
|
+
(task) => task !== null && (task.is_meta === true || task.is_sub_meta === true)
|
|
5331
|
+
).sort(
|
|
5332
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5333
|
+
);
|
|
5334
|
+
const businessLocalMetaSignals = Array.from(businessLocalMetaSignalNames).map((name) => signalDefinitionsByName.get(name) ?? null).filter(
|
|
5335
|
+
(signal) => signal !== null && signal.is_meta === true
|
|
5336
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5337
|
+
const businessLocalMetaIntents = Array.from(businessLocalMetaIntentNames).map((name) => intentDefinitionsByName.get(name) ?? null).filter(
|
|
5338
|
+
(intent) => intent !== null && intent.is_meta === true
|
|
5339
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5340
|
+
const businessLocalMetaActors = Array.from(businessLocalMetaActorKeys).map((key) => actorDefinitionsByKey.get(key) ?? null).filter(
|
|
5341
|
+
(actor) => actor !== null && actor.is_meta === true
|
|
5342
|
+
).sort(
|
|
5343
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5344
|
+
);
|
|
5345
|
+
const businessLocalMetaRoutines = Array.from(businessLocalMetaRoutineKeys).map((key) => routineDefinitionsByKey.get(key) ?? null).filter(
|
|
5346
|
+
(routine) => routine !== null && routine.is_meta === true
|
|
5347
|
+
).sort(
|
|
5348
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5349
|
+
);
|
|
5350
|
+
const cumulativeTasks = publicationLayer === "routing_capability" ? routingTasks : publicationLayer === "business_structural" ? Array.from(
|
|
5351
|
+
new Map(
|
|
5352
|
+
[...routingTasks, ...businessTasks, ...businessLocalMetaTasks].map((task) => [
|
|
5353
|
+
buildTaskKey(task),
|
|
5354
|
+
task
|
|
5355
|
+
])
|
|
5356
|
+
).values()
|
|
5357
|
+
).sort(
|
|
5358
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5359
|
+
) : Array.from(
|
|
5360
|
+
new Map(
|
|
5361
|
+
[...routingTasks, ...businessTasks, ...localMetaTasks].map((task) => [
|
|
5362
|
+
buildTaskKey(task),
|
|
5363
|
+
task
|
|
5364
|
+
])
|
|
5365
|
+
).values()
|
|
5366
|
+
).sort(
|
|
5367
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5368
|
+
);
|
|
5369
|
+
const cumulativeSignals = publicationLayer === "routing_capability" ? routingSignals : publicationLayer === "business_structural" ? Array.from(
|
|
5370
|
+
new Map(
|
|
5371
|
+
[...routingSignals, ...businessSignals, ...businessLocalMetaSignals].map(
|
|
5372
|
+
(signal) => [signal.name, signal]
|
|
4907
5373
|
)
|
|
4908
|
-
)
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
5374
|
+
).values()
|
|
5375
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
5376
|
+
new Map(
|
|
5377
|
+
[...routingSignals, ...businessSignals, ...localMetaSignals].map((signal) => [
|
|
5378
|
+
signal.name,
|
|
5379
|
+
signal
|
|
5380
|
+
])
|
|
5381
|
+
).values()
|
|
5382
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5383
|
+
const cumulativeIntents = publicationLayer === "routing_capability" ? routingIntents : publicationLayer === "business_structural" ? Array.from(
|
|
5384
|
+
new Map(
|
|
5385
|
+
[...routingIntents, ...businessIntents, ...businessLocalMetaIntents].map(
|
|
5386
|
+
(intent) => [intent.name, intent]
|
|
4912
5387
|
)
|
|
4913
|
-
)
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
5388
|
+
).values()
|
|
5389
|
+
).sort((left, right) => left.name.localeCompare(right.name)) : Array.from(
|
|
5390
|
+
new Map(
|
|
5391
|
+
[...routingIntents, ...businessIntents, ...localMetaIntents].map((intent) => [
|
|
5392
|
+
intent.name,
|
|
5393
|
+
intent
|
|
5394
|
+
])
|
|
5395
|
+
).values()
|
|
5396
|
+
).sort((left, right) => left.name.localeCompare(right.name));
|
|
5397
|
+
const cumulativeActors = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5398
|
+
new Map(
|
|
5399
|
+
[...businessActors, ...businessLocalMetaActors].map((actor) => [
|
|
5400
|
+
buildActorKey(actor),
|
|
5401
|
+
actor
|
|
5402
|
+
])
|
|
5403
|
+
).values()
|
|
5404
|
+
).sort(
|
|
5405
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5406
|
+
) : Array.from(
|
|
5407
|
+
new Map(
|
|
5408
|
+
[...businessActors, ...localMetaActors].map((actor) => [
|
|
5409
|
+
buildActorKey(actor),
|
|
5410
|
+
actor
|
|
5411
|
+
])
|
|
5412
|
+
).values()
|
|
5413
|
+
).sort(
|
|
5414
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5415
|
+
);
|
|
5416
|
+
const cumulativeRoutines = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5417
|
+
new Map(
|
|
5418
|
+
[...businessRoutines, ...businessLocalMetaRoutines].map((routine) => [
|
|
5419
|
+
buildRoutineKey(routine),
|
|
5420
|
+
routine
|
|
5421
|
+
])
|
|
5422
|
+
).values()
|
|
5423
|
+
).sort(
|
|
5424
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5425
|
+
) : Array.from(
|
|
5426
|
+
new Map(
|
|
5427
|
+
[...businessRoutines, ...localMetaRoutines].map((routine) => [
|
|
5428
|
+
buildRoutineKey(routine),
|
|
5429
|
+
routine
|
|
5430
|
+
])
|
|
5431
|
+
).values()
|
|
5432
|
+
).sort(
|
|
5433
|
+
(left, right) => `${left.name}:${left.version}`.localeCompare(`${right.name}:${right.version}`)
|
|
5434
|
+
);
|
|
5435
|
+
const cumulativeDirectionalTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessDirectionalTaskMaps : Array.from(
|
|
5436
|
+
new Map(
|
|
5437
|
+
[...businessDirectionalTaskMaps, ...localMetaDirectionalTaskMaps].map(
|
|
5438
|
+
(map) => [
|
|
5439
|
+
`${map.predecessor_service_name}|${map.predecessor_task_name}|${map.predecessor_task_version}|${map.service_name}|${map.task_name}|${map.task_version}`,
|
|
5440
|
+
map
|
|
5441
|
+
]
|
|
4917
5442
|
)
|
|
4918
|
-
)
|
|
5443
|
+
).values()
|
|
5444
|
+
);
|
|
5445
|
+
const cumulativeActorTaskMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? Array.from(
|
|
5446
|
+
new Map(
|
|
5447
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
5448
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
5449
|
+
map
|
|
5450
|
+
])
|
|
5451
|
+
).values()
|
|
5452
|
+
) : Array.from(
|
|
5453
|
+
new Map(
|
|
5454
|
+
[...businessActorTaskMaps, ...localMetaActorTaskMaps].map((map) => [
|
|
5455
|
+
`${map.service_name}|${map.actor_name}|${map.actor_version}|${map.task_name}|${map.task_version}|${map.mode}`,
|
|
5456
|
+
map
|
|
5457
|
+
])
|
|
5458
|
+
).values()
|
|
5459
|
+
);
|
|
5460
|
+
const cumulativeTaskToRoutineMaps = publicationLayer === "routing_capability" ? [] : publicationLayer === "business_structural" ? businessTaskToRoutineMaps : Array.from(
|
|
5461
|
+
new Map(
|
|
5462
|
+
[...businessTaskToRoutineMaps, ...localMetaTaskToRoutineMaps].map((map) => [
|
|
5463
|
+
`${map.service_name}|${map.task_name}|${map.task_version}|${map.routine_name}|${map.routine_version}`,
|
|
5464
|
+
map
|
|
5465
|
+
])
|
|
5466
|
+
).values()
|
|
5467
|
+
);
|
|
5468
|
+
const manifestBody = {
|
|
5469
|
+
serviceName,
|
|
5470
|
+
serviceInstanceId,
|
|
5471
|
+
publicationLayer,
|
|
5472
|
+
tasks: cumulativeTasks,
|
|
5473
|
+
signals: cumulativeSignals,
|
|
5474
|
+
intents: cumulativeIntents,
|
|
5475
|
+
actors: cumulativeActors,
|
|
5476
|
+
routines: cumulativeRoutines,
|
|
5477
|
+
directionalTaskMaps: cumulativeDirectionalTaskMaps,
|
|
5478
|
+
signalToTaskMaps: publicationLayer === "routing_capability" ? publishedSignalTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps] : [...publishedSignalTaskMaps, ...localMetaSignalTaskMaps],
|
|
5479
|
+
intentToTaskMaps: publicationLayer === "routing_capability" ? publishedIntentTaskMaps : publicationLayer === "local_meta_structural" ? [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps] : [...publishedIntentTaskMaps, ...localMetaIntentTaskMaps],
|
|
5480
|
+
actorTaskMaps: cumulativeActorTaskMaps,
|
|
5481
|
+
taskToRoutineMaps: cumulativeTaskToRoutineMaps
|
|
4919
5482
|
};
|
|
4920
5483
|
return {
|
|
4921
5484
|
...manifestBody,
|
|
@@ -5053,7 +5616,7 @@ var SERVICE_REGISTRY_TRACE_SERVICE2 = (process.env.CADENZA_SERVICE_REGISTRY_TRAC
|
|
|
5053
5616
|
function shouldTraceServiceRegistry(serviceName) {
|
|
5054
5617
|
return SERVICE_REGISTRY_TRACE_SERVICE2.length > 0 && serviceName === SERVICE_REGISTRY_TRACE_SERVICE2;
|
|
5055
5618
|
}
|
|
5056
|
-
function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
5619
|
+
function buildServiceRegistryInsertQueryData(tableName, ctx, queryData) {
|
|
5057
5620
|
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
5058
5621
|
const getJoinedValue = (key) => {
|
|
5059
5622
|
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
@@ -5071,7 +5634,8 @@ function buildServiceRegistryInsertQueryData(ctx, queryData) {
|
|
|
5071
5634
|
if (!Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
5072
5635
|
delete nextQueryData.onConflict;
|
|
5073
5636
|
}
|
|
5074
|
-
const
|
|
5637
|
+
const preferRegistrationData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
5638
|
+
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");
|
|
5075
5639
|
const resolvedBatch = Object.prototype.hasOwnProperty.call(ctx, "batch") || ctx.batch !== void 0 ? ctx.batch : getJoinedValue("batch");
|
|
5076
5640
|
const nextData = resolvedData !== void 0 ? resolvedData && typeof resolvedData === "object" ? { ...resolvedData } : resolvedData : registrationData && typeof registrationData === "object" && !Array.isArray(registrationData) ? { ...registrationData } : registrationData;
|
|
5077
5641
|
if (nextData !== void 0) {
|
|
@@ -5098,8 +5662,114 @@ function sanitizeServiceRegistryInsertExecutionContext(ctx) {
|
|
|
5098
5662
|
delete sanitized.returnedValue;
|
|
5099
5663
|
delete sanitized.queryData;
|
|
5100
5664
|
delete sanitized.onConflict;
|
|
5665
|
+
delete sanitized.task;
|
|
5666
|
+
delete sanitized.routine;
|
|
5667
|
+
delete sanitized.httpServer;
|
|
5668
|
+
delete sanitized.service;
|
|
5669
|
+
delete sanitized.serviceInstance;
|
|
5670
|
+
delete sanitized.joinedContexts;
|
|
5671
|
+
delete sanitized.__declaredTransports;
|
|
5672
|
+
delete sanitized.__resolverOriginalContext;
|
|
5673
|
+
delete sanitized.__resolverQueryData;
|
|
5674
|
+
return sanitized;
|
|
5675
|
+
}
|
|
5676
|
+
function sanitizeAuthorityBootstrapDelegationContext(ctx) {
|
|
5677
|
+
const sanitized = stripDelegationRequestSnapshot({
|
|
5678
|
+
...ctx
|
|
5679
|
+
});
|
|
5680
|
+
delete sanitized.__resolverOriginalContext;
|
|
5681
|
+
delete sanitized.__resolverQueryData;
|
|
5682
|
+
delete sanitized.joinedContexts;
|
|
5683
|
+
delete sanitized.httpServer;
|
|
5684
|
+
delete sanitized.service;
|
|
5685
|
+
delete sanitized.serviceInstance;
|
|
5686
|
+
delete sanitized.task;
|
|
5687
|
+
delete sanitized.routine;
|
|
5688
|
+
delete sanitized.__declaredTransports;
|
|
5689
|
+
const queryData = sanitized.queryData && typeof sanitized.queryData === "object" ? { ...sanitized.queryData } : null;
|
|
5690
|
+
if (queryData) {
|
|
5691
|
+
delete queryData.joinedContexts;
|
|
5692
|
+
sanitized.queryData = queryData;
|
|
5693
|
+
}
|
|
5101
5694
|
return sanitized;
|
|
5102
5695
|
}
|
|
5696
|
+
function cloneServiceRegistryContextValue(value) {
|
|
5697
|
+
if (value instanceof Date) {
|
|
5698
|
+
return new Date(value.getTime());
|
|
5699
|
+
}
|
|
5700
|
+
if (Array.isArray(value)) {
|
|
5701
|
+
return value.map(
|
|
5702
|
+
(entry) => cloneServiceRegistryContextValue(entry)
|
|
5703
|
+
);
|
|
5704
|
+
}
|
|
5705
|
+
if (value && typeof value === "object") {
|
|
5706
|
+
const clone = {};
|
|
5707
|
+
for (const [key, nestedValue] of Object.entries(value)) {
|
|
5708
|
+
clone[key] = cloneServiceRegistryContextValue(nestedValue);
|
|
5709
|
+
}
|
|
5710
|
+
return clone;
|
|
5711
|
+
}
|
|
5712
|
+
return value;
|
|
5713
|
+
}
|
|
5714
|
+
function buildServiceRegistryResolverOriginalContext(tableName, ctx, queryData) {
|
|
5715
|
+
const originalContext = {};
|
|
5716
|
+
for (const key of [
|
|
5717
|
+
"__serviceName",
|
|
5718
|
+
"serviceName",
|
|
5719
|
+
"__serviceInstanceId",
|
|
5720
|
+
"serviceInstanceId",
|
|
5721
|
+
"__registrationData",
|
|
5722
|
+
"__reason",
|
|
5723
|
+
"__syncing",
|
|
5724
|
+
"__syncSourceServiceName",
|
|
5725
|
+
"__preferredTransportProtocol",
|
|
5726
|
+
"__networkMode",
|
|
5727
|
+
"__securityProfile",
|
|
5728
|
+
"__loadBalance",
|
|
5729
|
+
"__cadenzaDBConnect",
|
|
5730
|
+
"__isFrontend",
|
|
5731
|
+
"__isDatabase",
|
|
5732
|
+
"__retryCount",
|
|
5733
|
+
"__retries",
|
|
5734
|
+
"__triedInstances"
|
|
5735
|
+
]) {
|
|
5736
|
+
if (ctx[key] !== void 0) {
|
|
5737
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5740
|
+
if (queryData.data !== void 0) {
|
|
5741
|
+
originalContext.data = cloneServiceRegistryContextValue(queryData.data);
|
|
5742
|
+
}
|
|
5743
|
+
if (queryData.batch !== void 0) {
|
|
5744
|
+
originalContext.batch = cloneServiceRegistryContextValue(queryData.batch);
|
|
5745
|
+
}
|
|
5746
|
+
if (Object.prototype.hasOwnProperty.call(queryData, "onConflict")) {
|
|
5747
|
+
originalContext.queryData = {
|
|
5748
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
5749
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0,
|
|
5750
|
+
onConflict: cloneServiceRegistryContextValue(queryData.onConflict)
|
|
5751
|
+
};
|
|
5752
|
+
} else if (queryData.data !== void 0 || queryData.batch !== void 0) {
|
|
5753
|
+
originalContext.queryData = {
|
|
5754
|
+
data: queryData.data !== void 0 ? cloneServiceRegistryContextValue(queryData.data) : void 0,
|
|
5755
|
+
batch: queryData.batch !== void 0 ? cloneServiceRegistryContextValue(queryData.batch) : void 0
|
|
5756
|
+
};
|
|
5757
|
+
}
|
|
5758
|
+
if (tableName === "service_instance") {
|
|
5759
|
+
for (const key of [
|
|
5760
|
+
"__transportData",
|
|
5761
|
+
"transportData",
|
|
5762
|
+
"__useSocket",
|
|
5763
|
+
"__retryCount",
|
|
5764
|
+
"__isFrontend"
|
|
5765
|
+
]) {
|
|
5766
|
+
if (ctx[key] !== void 0) {
|
|
5767
|
+
originalContext[key] = cloneServiceRegistryContextValue(ctx[key]);
|
|
5768
|
+
}
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
return originalContext;
|
|
5772
|
+
}
|
|
5103
5773
|
function clearTransientRoutingErrorState(context) {
|
|
5104
5774
|
delete context.errored;
|
|
5105
5775
|
delete context.failed;
|
|
@@ -5155,7 +5825,8 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
5155
5825
|
delete result.__resolverOriginalContext;
|
|
5156
5826
|
delete result.__resolverQueryData;
|
|
5157
5827
|
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
5158
|
-
const
|
|
5828
|
+
const preferRequestedData = tableName === "service" || tableName === "service_instance" || tableName === "service_instance_transport";
|
|
5829
|
+
const resolvedData = preferRequestedData ? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData ?? result.data : result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
5159
5830
|
if (resolvedData !== void 0 && result.data === void 0) {
|
|
5160
5831
|
result.data = resolvedData;
|
|
5161
5832
|
}
|
|
@@ -5185,6 +5856,7 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
5185
5856
|
).trim();
|
|
5186
5857
|
if (resolvedServiceName) {
|
|
5187
5858
|
result.__serviceName = resolvedServiceName;
|
|
5859
|
+
result.serviceName = resolvedServiceName;
|
|
5188
5860
|
}
|
|
5189
5861
|
}
|
|
5190
5862
|
const resolvedLocalServiceInstanceId = String(
|
|
@@ -5193,6 +5865,18 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
5193
5865
|
if (resolvedLocalServiceInstanceId) {
|
|
5194
5866
|
result.__serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
5195
5867
|
}
|
|
5868
|
+
if (tableName === "service_instance") {
|
|
5869
|
+
const resolvedServiceName = String(
|
|
5870
|
+
ctx.__serviceName ?? resolveServiceNameFromContext(ctx) ?? resolvedData?.service_name ?? resolvedData?.serviceName ?? ""
|
|
5871
|
+
).trim();
|
|
5872
|
+
if (resolvedServiceName) {
|
|
5873
|
+
result.__serviceName = resolvedServiceName;
|
|
5874
|
+
result.serviceName = resolvedServiceName;
|
|
5875
|
+
}
|
|
5876
|
+
if (resolvedLocalServiceInstanceId) {
|
|
5877
|
+
result.serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5196
5880
|
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
5197
5881
|
const resolvedUuid = String(
|
|
5198
5882
|
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
@@ -5292,9 +5976,15 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
5292
5976
|
ctx
|
|
5293
5977
|
);
|
|
5294
5978
|
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
5979
|
+
tableName,
|
|
5295
5980
|
sanitizedContext,
|
|
5296
5981
|
queryData
|
|
5297
5982
|
);
|
|
5983
|
+
const resolverOriginalContext = buildServiceRegistryResolverOriginalContext(
|
|
5984
|
+
tableName,
|
|
5985
|
+
sanitizedContext,
|
|
5986
|
+
nextQueryData
|
|
5987
|
+
);
|
|
5298
5988
|
const delegationContext = ensureDelegationContextMetadata({
|
|
5299
5989
|
...sanitizedContext,
|
|
5300
5990
|
data: nextQueryData.data !== void 0 ? nextQueryData.data : sanitizedContext.data,
|
|
@@ -5307,9 +5997,7 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
5307
5997
|
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
5308
5998
|
const nextContext = {
|
|
5309
5999
|
...delegationContext,
|
|
5310
|
-
__resolverOriginalContext:
|
|
5311
|
-
...sanitizedContext
|
|
5312
|
-
},
|
|
6000
|
+
__resolverOriginalContext: resolverOriginalContext,
|
|
5313
6001
|
__resolverQueryData: nextQueryData
|
|
5314
6002
|
};
|
|
5315
6003
|
if (tableName === "service_instance_transport" && shouldTraceServiceRegistry(
|
|
@@ -5481,6 +6169,7 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
5481
6169
|
if (bootstrapAuthorityInsertSpec) {
|
|
5482
6170
|
const sanitizedContext = sanitizeServiceRegistryInsertExecutionContext(ctx);
|
|
5483
6171
|
const nextQueryData = buildServiceRegistryInsertQueryData(
|
|
6172
|
+
tableName,
|
|
5484
6173
|
sanitizedContext,
|
|
5485
6174
|
queryData
|
|
5486
6175
|
);
|
|
@@ -5915,6 +6604,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
5915
6604
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
5916
6605
|
);
|
|
5917
6606
|
if (uuid10 === this.serviceInstanceId) return;
|
|
6607
|
+
if (serviceName === this.serviceName) {
|
|
6608
|
+
return false;
|
|
6609
|
+
}
|
|
5918
6610
|
if (deleted) {
|
|
5919
6611
|
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid10);
|
|
5920
6612
|
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid10) ?? -1;
|
|
@@ -6001,9 +6693,6 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6001
6693
|
emit2
|
|
6002
6694
|
);
|
|
6003
6695
|
}
|
|
6004
|
-
if (this.serviceName === serviceName) {
|
|
6005
|
-
return false;
|
|
6006
|
-
}
|
|
6007
6696
|
if (trackedInstance?.isFrontend) {
|
|
6008
6697
|
return true;
|
|
6009
6698
|
}
|
|
@@ -6057,6 +6746,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
6057
6746
|
if (!ownerInstance) {
|
|
6058
6747
|
return false;
|
|
6059
6748
|
}
|
|
6749
|
+
if (ownerInstance.serviceName === this.serviceName && ownerInstance.uuid !== this.serviceInstanceId) {
|
|
6750
|
+
return false;
|
|
6751
|
+
}
|
|
6060
6752
|
if (transport.deleted) {
|
|
6061
6753
|
this.clearTransportFailureState(ownerInstance.uuid, transport.uuid);
|
|
6062
6754
|
const transportKey = this.buildTransportRouteKey(
|
|
@@ -8483,6 +9175,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8483
9175
|
seenSignalMaps,
|
|
8484
9176
|
(row) => `${String(row.service_name ?? row.serviceName ?? "").trim()}|${String(
|
|
8485
9177
|
row.signal_name ?? row.signalName ?? ""
|
|
9178
|
+
).trim()}|${String(row.task_name ?? row.taskName ?? "").trim()}|${String(
|
|
9179
|
+
row.task_version ?? row.taskVersion ?? 1
|
|
8486
9180
|
).trim()}`
|
|
8487
9181
|
);
|
|
8488
9182
|
pushUnique(
|
|
@@ -8517,6 +9211,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8517
9211
|
seenSignalMaps,
|
|
8518
9212
|
(entry) => `${String(entry.service_name ?? entry.serviceName ?? "").trim()}|${String(
|
|
8519
9213
|
entry.signal_name ?? entry.signalName ?? ""
|
|
9214
|
+
).trim()}|${String(entry.task_name ?? entry.taskName ?? "").trim()}|${String(
|
|
9215
|
+
entry.task_version ?? entry.taskVersion ?? 1
|
|
8520
9216
|
).trim()}`
|
|
8521
9217
|
);
|
|
8522
9218
|
continue;
|
|
@@ -8549,7 +9245,36 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8549
9245
|
}
|
|
8550
9246
|
}
|
|
8551
9247
|
}
|
|
8552
|
-
const
|
|
9248
|
+
const activeServiceInstanceIds = new Set(
|
|
9249
|
+
serviceInstances.filter((row) => row.is_active === true || row.isActive === true).map((row) => String(row.uuid ?? "").trim()).filter((uuid10) => uuid10.length > 0)
|
|
9250
|
+
);
|
|
9251
|
+
const filteredServiceInstances = activeServiceInstanceIds.size > 0 ? serviceInstances.filter(
|
|
9252
|
+
(row) => activeServiceInstanceIds.has(String(row.uuid ?? "").trim())
|
|
9253
|
+
) : serviceInstances;
|
|
9254
|
+
const filteredServiceInstanceTransports = activeServiceInstanceIds.size > 0 ? serviceInstanceTransports.filter(
|
|
9255
|
+
(row) => activeServiceInstanceIds.has(
|
|
9256
|
+
String(row.service_instance_id ?? row.serviceInstanceId ?? "").trim()
|
|
9257
|
+
)
|
|
9258
|
+
) : serviceInstanceTransports;
|
|
9259
|
+
const filteredManifestSnapshots = activeServiceInstanceIds.size > 0 ? manifestSnapshots.filter(
|
|
9260
|
+
(snapshot) => activeServiceInstanceIds.has(snapshot.serviceInstanceId)
|
|
9261
|
+
) : manifestSnapshots;
|
|
9262
|
+
const activeServiceNames = new Set(
|
|
9263
|
+
filteredServiceInstances.map((row) => String(row.service_name ?? row.serviceName ?? "").trim()).filter((serviceName) => serviceName.length > 0)
|
|
9264
|
+
);
|
|
9265
|
+
const filteredSignalToTaskMaps = activeServiceNames.size > 0 ? signalToTaskMaps.filter(
|
|
9266
|
+
(row) => activeServiceNames.has(
|
|
9267
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
9268
|
+
)
|
|
9269
|
+
) : signalToTaskMaps;
|
|
9270
|
+
const filteredIntentToTaskMaps = activeServiceNames.size > 0 ? intentToTaskMaps.filter(
|
|
9271
|
+
(row) => activeServiceNames.has(
|
|
9272
|
+
String(row.service_name ?? row.serviceName ?? "").trim()
|
|
9273
|
+
)
|
|
9274
|
+
) : intentToTaskMaps;
|
|
9275
|
+
const hasExplicitSignalRoutingRows = filteredSignalToTaskMaps.length > 0;
|
|
9276
|
+
const hasExplicitIntentRoutingRows = filteredIntentToTaskMaps.length > 0;
|
|
9277
|
+
const latestManifestSnapshots = selectLatestServiceManifestSnapshots(filteredManifestSnapshots);
|
|
8553
9278
|
const explodedManifest = explodeServiceManifestSnapshots(
|
|
8554
9279
|
latestManifestSnapshots
|
|
8555
9280
|
);
|
|
@@ -8611,47 +9336,51 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8611
9336
|
);
|
|
8612
9337
|
pushUnique(
|
|
8613
9338
|
explodedManifest.actorTaskMaps,
|
|
8614
|
-
actorTaskMaps,
|
|
8615
|
-
seenActorTaskMaps,
|
|
8616
|
-
(row) => `${String(row.actor_name ?? "").trim()}|${String(row.actor_version ?? 1).trim()}|${String(
|
|
8617
|
-
row.service_name ?? ""
|
|
8618
|
-
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
8619
|
-
row.task_version ?? 1
|
|
8620
|
-
).trim()}`
|
|
8621
|
-
);
|
|
8622
|
-
pushUnique(
|
|
8623
|
-
explodedManifest.taskToRoutineMaps,
|
|
8624
|
-
taskToRoutineMaps,
|
|
8625
|
-
seenTaskToRoutineMaps,
|
|
8626
|
-
(row) => `${String(row.routine_name ?? "").trim()}|${String(row.routine_version ?? 1).trim()}|${String(
|
|
8627
|
-
row.service_name ?? ""
|
|
8628
|
-
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
8629
|
-
row.task_version ?? 1
|
|
8630
|
-
).trim()}`
|
|
8631
|
-
);
|
|
8632
|
-
pushUnique(
|
|
8633
|
-
explodedManifest.signalToTaskMaps,
|
|
8634
|
-
signalToTaskMaps,
|
|
8635
|
-
seenSignalMaps,
|
|
8636
|
-
(row) => `${String(row.signal_name ?? "").trim()}|${String(
|
|
9339
|
+
actorTaskMaps,
|
|
9340
|
+
seenActorTaskMaps,
|
|
9341
|
+
(row) => `${String(row.actor_name ?? "").trim()}|${String(row.actor_version ?? 1).trim()}|${String(
|
|
8637
9342
|
row.service_name ?? ""
|
|
8638
9343
|
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
8639
9344
|
row.task_version ?? 1
|
|
8640
9345
|
).trim()}`
|
|
8641
9346
|
);
|
|
8642
9347
|
pushUnique(
|
|
8643
|
-
explodedManifest.
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
(row) => `${String(row.
|
|
9348
|
+
explodedManifest.taskToRoutineMaps,
|
|
9349
|
+
taskToRoutineMaps,
|
|
9350
|
+
seenTaskToRoutineMaps,
|
|
9351
|
+
(row) => `${String(row.routine_name ?? "").trim()}|${String(row.routine_version ?? 1).trim()}|${String(
|
|
8647
9352
|
row.service_name ?? ""
|
|
8648
9353
|
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
8649
9354
|
row.task_version ?? 1
|
|
8650
9355
|
).trim()}`
|
|
8651
9356
|
);
|
|
9357
|
+
if (!hasExplicitSignalRoutingRows) {
|
|
9358
|
+
pushUnique(
|
|
9359
|
+
explodedManifest.signalToTaskMaps,
|
|
9360
|
+
filteredSignalToTaskMaps,
|
|
9361
|
+
seenSignalMaps,
|
|
9362
|
+
(row) => `${String(row.signal_name ?? "").trim()}|${String(
|
|
9363
|
+
row.service_name ?? ""
|
|
9364
|
+
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
9365
|
+
row.task_version ?? 1
|
|
9366
|
+
).trim()}`
|
|
9367
|
+
);
|
|
9368
|
+
}
|
|
9369
|
+
if (!hasExplicitIntentRoutingRows) {
|
|
9370
|
+
pushUnique(
|
|
9371
|
+
explodedManifest.intentToTaskMaps,
|
|
9372
|
+
filteredIntentToTaskMaps,
|
|
9373
|
+
seenIntentMaps,
|
|
9374
|
+
(row) => `${String(row.intent_name ?? "").trim()}|${String(
|
|
9375
|
+
row.service_name ?? ""
|
|
9376
|
+
).trim()}|${String(row.task_name ?? "").trim()}|${String(
|
|
9377
|
+
row.task_version ?? 1
|
|
9378
|
+
).trim()}`
|
|
9379
|
+
);
|
|
9380
|
+
}
|
|
8652
9381
|
return {
|
|
8653
|
-
serviceInstances,
|
|
8654
|
-
serviceInstanceTransports,
|
|
9382
|
+
serviceInstances: filteredServiceInstances,
|
|
9383
|
+
serviceInstanceTransports: filteredServiceInstanceTransports,
|
|
8655
9384
|
serviceManifests,
|
|
8656
9385
|
tasks,
|
|
8657
9386
|
signals,
|
|
@@ -8661,8 +9390,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8661
9390
|
directionalTaskMaps,
|
|
8662
9391
|
actorTaskMaps,
|
|
8663
9392
|
taskToRoutineMaps,
|
|
8664
|
-
signalToTaskMaps,
|
|
8665
|
-
intentToTaskMaps
|
|
9393
|
+
signalToTaskMaps: filteredSignalToTaskMaps,
|
|
9394
|
+
intentToTaskMaps: filteredIntentToTaskMaps
|
|
8666
9395
|
};
|
|
8667
9396
|
}
|
|
8668
9397
|
buildRemoteIntentDeputyKey(map) {
|
|
@@ -9091,10 +9820,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9091
9820
|
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
9092
9821
|
const timeoutId = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
9093
9822
|
try {
|
|
9823
|
+
const sanitizedContext = sanitizeAuthorityBootstrapDelegationContext(context);
|
|
9094
9824
|
const requestBody = stripDelegationRequestSnapshot(
|
|
9095
9825
|
ensureDelegationContextMetadata(
|
|
9096
9826
|
attachDelegationRequestSnapshot({
|
|
9097
|
-
...
|
|
9827
|
+
...sanitizedContext,
|
|
9098
9828
|
__remoteRoutineName: remoteRoutineName,
|
|
9099
9829
|
__serviceName: "CadenzaDB",
|
|
9100
9830
|
__localServiceName: this.serviceName,
|
|
@@ -9108,7 +9838,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9108
9838
|
__fetchId: target.fetchId,
|
|
9109
9839
|
fetchId: target.fetchId,
|
|
9110
9840
|
__metadata: {
|
|
9111
|
-
...
|
|
9841
|
+
...sanitizedContext.__metadata && typeof sanitizedContext.__metadata === "object" ? sanitizedContext.__metadata : {},
|
|
9112
9842
|
__timeout: timeoutMs,
|
|
9113
9843
|
__syncing: true,
|
|
9114
9844
|
__authorityBootstrapChannel: true
|
|
@@ -9126,22 +9856,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9126
9856
|
});
|
|
9127
9857
|
if ("ok" in response && response.ok === false) {
|
|
9128
9858
|
return {
|
|
9129
|
-
...
|
|
9859
|
+
...sanitizedContext,
|
|
9130
9860
|
__error: `Bootstrap authority delegation failed with HTTP ${response.status}`,
|
|
9131
9861
|
errored: true
|
|
9132
9862
|
};
|
|
9133
9863
|
}
|
|
9134
9864
|
const payload = typeof response.json === "function" ? await response.json() : response;
|
|
9135
9865
|
return payload && typeof payload === "object" ? {
|
|
9136
|
-
...
|
|
9866
|
+
...sanitizedContext,
|
|
9137
9867
|
...payload
|
|
9138
9868
|
} : {
|
|
9139
|
-
...
|
|
9869
|
+
...sanitizedContext,
|
|
9140
9870
|
returnedValue: payload
|
|
9141
9871
|
};
|
|
9142
9872
|
} catch (error) {
|
|
9143
9873
|
return {
|
|
9144
|
-
...context,
|
|
9874
|
+
...sanitizeAuthorityBootstrapDelegationContext(context),
|
|
9145
9875
|
__error: error instanceof Error ? error.message : String(error),
|
|
9146
9876
|
errored: true
|
|
9147
9877
|
};
|
|
@@ -9251,16 +9981,35 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9251
9981
|
const authorityFullSyncResponderTask = CadenzaService.createMetaTask(
|
|
9252
9982
|
BOOTSTRAP_FULL_SYNC_RESPONDER_TASK_NAME,
|
|
9253
9983
|
async (ctx) => {
|
|
9984
|
+
const queryOptionalAuthorityRoutingRows = async (tableName) => {
|
|
9985
|
+
try {
|
|
9986
|
+
return await DatabaseController.instance.queryAuthorityTableRows(
|
|
9987
|
+
tableName
|
|
9988
|
+
);
|
|
9989
|
+
} catch (error) {
|
|
9990
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9991
|
+
if (message.includes(
|
|
9992
|
+
`Table '${tableName}' is not registered on the CadenzaDB PostgresActor`
|
|
9993
|
+
)) {
|
|
9994
|
+
return [];
|
|
9995
|
+
}
|
|
9996
|
+
throw error;
|
|
9997
|
+
}
|
|
9998
|
+
};
|
|
9254
9999
|
const [
|
|
9255
10000
|
serviceInstances,
|
|
9256
10001
|
serviceInstanceTransports,
|
|
9257
|
-
serviceManifests
|
|
10002
|
+
serviceManifests,
|
|
10003
|
+
signalToTaskMaps,
|
|
10004
|
+
intentToTaskMaps
|
|
9258
10005
|
] = await Promise.all([
|
|
9259
10006
|
DatabaseController.instance.queryAuthorityTableRows("service_instance"),
|
|
9260
10007
|
DatabaseController.instance.queryAuthorityTableRows(
|
|
9261
10008
|
"service_instance_transport"
|
|
9262
10009
|
),
|
|
9263
|
-
DatabaseController.instance.queryAuthorityTableRows("service_manifest")
|
|
10010
|
+
DatabaseController.instance.queryAuthorityTableRows("service_manifest"),
|
|
10011
|
+
queryOptionalAuthorityRoutingRows("signal_to_task_map"),
|
|
10012
|
+
queryOptionalAuthorityRoutingRows("intent_to_task_map")
|
|
9264
10013
|
]);
|
|
9265
10014
|
return {
|
|
9266
10015
|
...ctx,
|
|
@@ -9268,7 +10017,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9268
10017
|
...this.collectBootstrapFullSyncPayload({
|
|
9269
10018
|
serviceInstances,
|
|
9270
10019
|
serviceInstanceTransports,
|
|
9271
|
-
serviceManifests
|
|
10020
|
+
serviceManifests,
|
|
10021
|
+
signalToTaskMaps,
|
|
10022
|
+
intentToTaskMaps
|
|
9272
10023
|
})
|
|
9273
10024
|
};
|
|
9274
10025
|
},
|
|
@@ -12357,6 +13108,41 @@ var TRACED_INQUIRY_METADATA_SIGNALS = /* @__PURE__ */ new Set([
|
|
|
12357
13108
|
"global.meta.graph_metadata.inquiry_updated"
|
|
12358
13109
|
]);
|
|
12359
13110
|
var ACTOR_SESSION_TRACE_ENABLED3 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
13111
|
+
function summarizeRequestBodyForLogging(body) {
|
|
13112
|
+
if (typeof body !== "string") {
|
|
13113
|
+
return body;
|
|
13114
|
+
}
|
|
13115
|
+
const summary = {
|
|
13116
|
+
bodyLength: body.length
|
|
13117
|
+
};
|
|
13118
|
+
try {
|
|
13119
|
+
const parsed = JSON.parse(body);
|
|
13120
|
+
const queryData = parsed.queryData && typeof parsed.queryData === "object" ? parsed.queryData : null;
|
|
13121
|
+
const queryDataData = queryData?.data && typeof queryData.data === "object" ? queryData.data : null;
|
|
13122
|
+
const data = parsed.data && typeof parsed.data === "object" ? parsed.data : null;
|
|
13123
|
+
summary.rootKeys = Object.keys(parsed).slice(0, 24);
|
|
13124
|
+
summary.remoteRoutineName = typeof parsed.__remoteRoutineName === "string" ? parsed.__remoteRoutineName : null;
|
|
13125
|
+
summary.serviceName = typeof parsed.__serviceName === "string" ? parsed.__serviceName : null;
|
|
13126
|
+
summary.authorityBootstrapChannel = parsed.__authorityBootstrapChannel === true || parsed.__metadata?.__authorityBootstrapChannel === true;
|
|
13127
|
+
summary.hasData = data !== null;
|
|
13128
|
+
summary.dataKeys = data ? Object.keys(data).slice(0, 24) : [];
|
|
13129
|
+
summary.hasQueryData = queryData !== null;
|
|
13130
|
+
summary.queryDataKeys = queryData ? Object.keys(queryData).slice(0, 24) : [];
|
|
13131
|
+
summary.queryDataDataKeys = queryDataData ? Object.keys(queryDataData).slice(0, 24) : [];
|
|
13132
|
+
} catch {
|
|
13133
|
+
summary.preview = body.slice(0, 240);
|
|
13134
|
+
}
|
|
13135
|
+
return summary;
|
|
13136
|
+
}
|
|
13137
|
+
function summarizeRequestInitForLogging(requestInit) {
|
|
13138
|
+
if (!requestInit || typeof requestInit !== "object") {
|
|
13139
|
+
return requestInit;
|
|
13140
|
+
}
|
|
13141
|
+
return {
|
|
13142
|
+
...requestInit,
|
|
13143
|
+
body: summarizeRequestBodyForLogging(requestInit.body)
|
|
13144
|
+
};
|
|
13145
|
+
}
|
|
12360
13146
|
var RestController = class _RestController {
|
|
12361
13147
|
/**
|
|
12362
13148
|
* Constructor for initializing the REST server and related configurations.
|
|
@@ -12390,16 +13176,17 @@ var RestController = class _RestController {
|
|
|
12390
13176
|
const parsedResponse = await this.parseFetchResponse(response);
|
|
12391
13177
|
return parsedResponse.data;
|
|
12392
13178
|
} catch (error) {
|
|
13179
|
+
const loggedRequestInit = summarizeRequestInitForLogging(requestInit);
|
|
12393
13180
|
if (error?.name === "AbortError") {
|
|
12394
13181
|
CadenzaService.log(
|
|
12395
13182
|
"Fetch request timed out.",
|
|
12396
|
-
{ error, URL: url, requestInit },
|
|
13183
|
+
{ error, URL: url, requestInit: loggedRequestInit },
|
|
12397
13184
|
"warning"
|
|
12398
13185
|
);
|
|
12399
13186
|
} else {
|
|
12400
13187
|
CadenzaService.log(
|
|
12401
13188
|
"Fetch request error.",
|
|
12402
|
-
{ error, URL: url, requestInit },
|
|
13189
|
+
{ error, URL: url, requestInit: loggedRequestInit },
|
|
12403
13190
|
"error"
|
|
12404
13191
|
);
|
|
12405
13192
|
}
|
|
@@ -12545,7 +13332,7 @@ var RestController = class _RestController {
|
|
|
12545
13332
|
return { ...ctx, __app: app };
|
|
12546
13333
|
},
|
|
12547
13334
|
"Sets up the Express server according to the security profile"
|
|
12548
|
-
).
|
|
13335
|
+
).then(
|
|
12549
13336
|
CadenzaService.createMetaTask(
|
|
12550
13337
|
"Define RestServer",
|
|
12551
13338
|
(ctx) => {
|
|
@@ -12942,32 +13729,40 @@ var RestController = class _RestController {
|
|
|
12942
13729
|
serviceName,
|
|
12943
13730
|
URL2
|
|
12944
13731
|
);
|
|
12945
|
-
fetchDiagnostics.destroyed = false;
|
|
12946
|
-
fetchDiagnostics.updatedAt = Date.now();
|
|
12947
13732
|
if (CadenzaService.get(`Send Handshake to ${clientTaskSuffix}`)) {
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
13733
|
+
const shouldRetryHandshake = ctx.__forceHandshakeRecovery === true || fetchDiagnostics.destroyed === true || (fetchDiagnostics.connected !== true || typeof fetchDiagnostics.lastHandshakeError === "string") && fetchDiagnostics.handshakeInFlight !== true;
|
|
13734
|
+
if (shouldRetryHandshake) {
|
|
13735
|
+
fetchDiagnostics.destroyed = false;
|
|
13736
|
+
fetchDiagnostics.handshakeInFlight = true;
|
|
13737
|
+
fetchDiagnostics.updatedAt = Date.now();
|
|
13738
|
+
console.error("Fetch client already exists", { URL: URL2, fetchId });
|
|
13739
|
+
CadenzaService.debounce(
|
|
13740
|
+
`meta.fetch.handshake_requested:${fetchId}`,
|
|
13741
|
+
{
|
|
13742
|
+
serviceInstanceId: ctx.serviceInstanceId,
|
|
13743
|
+
serviceName,
|
|
13744
|
+
communicationTypes: ctx.communicationTypes,
|
|
13745
|
+
serviceTransportId: ctx.serviceTransportId,
|
|
13746
|
+
serviceOrigin: URL2,
|
|
13747
|
+
fetchId,
|
|
13748
|
+
routeKey,
|
|
13749
|
+
socketClientId: ctx.socketClientId ?? (routeKey ? buildTransportHandleKey(routeKey, "socket") : void 0),
|
|
13750
|
+
transportProtocols: ctx.transportProtocols,
|
|
13751
|
+
transportProtocol: "rest",
|
|
13752
|
+
handshakeData: ctx.handshakeData
|
|
13753
|
+
},
|
|
13754
|
+
50
|
|
13755
|
+
);
|
|
13756
|
+
}
|
|
12966
13757
|
return true;
|
|
12967
13758
|
}
|
|
13759
|
+
fetchDiagnostics.destroyed = false;
|
|
13760
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13761
|
+
fetchDiagnostics.updatedAt = Date.now();
|
|
12968
13762
|
const handshakeTask = CadenzaService.createMetaTask(
|
|
12969
13763
|
`Send Handshake to ${clientTaskSuffix}`,
|
|
12970
13764
|
async (ctx2, emit2) => {
|
|
13765
|
+
fetchDiagnostics.handshakeInFlight = true;
|
|
12971
13766
|
try {
|
|
12972
13767
|
const response = await this.fetchDataWithTimeout(
|
|
12973
13768
|
`${URL2}/handshake`,
|
|
@@ -12983,6 +13778,7 @@ var RestController = class _RestController {
|
|
|
12983
13778
|
if (response.__status !== "success") {
|
|
12984
13779
|
const error = response.__error ?? `Failed to connect to service ${serviceName} ${ctx2.serviceInstanceId}`;
|
|
12985
13780
|
fetchDiagnostics.connected = false;
|
|
13781
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
12986
13782
|
fetchDiagnostics.lastHandshakeError = error;
|
|
12987
13783
|
fetchDiagnostics.updatedAt = Date.now();
|
|
12988
13784
|
this.recordFetchClientError(fetchId, serviceName, URL2, error);
|
|
@@ -13002,6 +13798,7 @@ var RestController = class _RestController {
|
|
|
13002
13798
|
ctx2.serviceInstanceId = response.__serviceInstanceId;
|
|
13003
13799
|
fetchDiagnostics.connected = true;
|
|
13004
13800
|
fetchDiagnostics.destroyed = false;
|
|
13801
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13005
13802
|
fetchDiagnostics.lastHandshakeAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
13006
13803
|
fetchDiagnostics.lastHandshakeError = null;
|
|
13007
13804
|
fetchDiagnostics.updatedAt = Date.now();
|
|
@@ -13030,6 +13827,7 @@ var RestController = class _RestController {
|
|
|
13030
13827
|
}
|
|
13031
13828
|
} catch (e) {
|
|
13032
13829
|
fetchDiagnostics.connected = false;
|
|
13830
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13033
13831
|
fetchDiagnostics.lastHandshakeError = this.getErrorMessage(e);
|
|
13034
13832
|
fetchDiagnostics.updatedAt = Date.now();
|
|
13035
13833
|
this.recordFetchClientError(fetchId, serviceName, URL2, e);
|
|
@@ -13062,8 +13860,8 @@ var RestController = class _RestController {
|
|
|
13062
13860
|
}
|
|
13063
13861
|
const routedDelegateCtx = stripTransportSelectionRoutingContext(ctx2);
|
|
13064
13862
|
const delegateCtx = ensureDelegationContextMetadata(
|
|
13065
|
-
|
|
13066
|
-
|
|
13863
|
+
restoreDelegationRequestSnapshot(
|
|
13864
|
+
attachDelegationRequestSnapshot(routedDelegateCtx)
|
|
13067
13865
|
)
|
|
13068
13866
|
);
|
|
13069
13867
|
const deputyExecId = delegateCtx.__metadata.__deputyExecId;
|
|
@@ -13123,13 +13921,11 @@ var RestController = class _RestController {
|
|
|
13123
13921
|
fetchDiagnostics.delegationFailures++;
|
|
13124
13922
|
fetchDiagnostics.updatedAt = Date.now();
|
|
13125
13923
|
this.recordFetchClientError(fetchId, serviceName, URL2, e);
|
|
13126
|
-
resultContext =
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
...delegateCtx.__metadata
|
|
13132
|
-
};
|
|
13924
|
+
resultContext = buildDelegationFailureContext(
|
|
13925
|
+
"meta.fetch.delegate_failed",
|
|
13926
|
+
delegateCtx,
|
|
13927
|
+
e
|
|
13928
|
+
);
|
|
13133
13929
|
routeOutcome = "failure";
|
|
13134
13930
|
emit2("meta.fetch.delegate_failed", resultContext);
|
|
13135
13931
|
} finally {
|
|
@@ -13295,6 +14091,7 @@ var RestController = class _RestController {
|
|
|
13295
14091
|
return false;
|
|
13296
14092
|
}
|
|
13297
14093
|
fetchDiagnostics.connected = false;
|
|
14094
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13298
14095
|
fetchDiagnostics.destroyed = true;
|
|
13299
14096
|
fetchDiagnostics.updatedAt = Date.now();
|
|
13300
14097
|
CadenzaService.log("Destroying fetch client", { URL: URL2, serviceName });
|
|
@@ -13334,7 +14131,15 @@ var RestController = class _RestController {
|
|
|
13334
14131
|
const fetchId = String(
|
|
13335
14132
|
ctx.fetchId ?? ctx.__fetchId ?? (routeKey ? buildTransportHandleKey(routeKey, "rest") : serviceTransportId ?? "")
|
|
13336
14133
|
);
|
|
13337
|
-
|
|
14134
|
+
const fetchDiagnostics = this.ensureFetchClientDiagnostics(
|
|
14135
|
+
fetchId,
|
|
14136
|
+
String(serviceName ?? ""),
|
|
14137
|
+
String(serviceOrigin ?? "")
|
|
14138
|
+
);
|
|
14139
|
+
if (fetchDiagnostics.handshakeInFlight !== true) {
|
|
14140
|
+
fetchDiagnostics.handshakeInFlight = true;
|
|
14141
|
+
}
|
|
14142
|
+
CadenzaService.debounce(`meta.fetch.handshake_requested:${fetchId}`, {
|
|
13338
14143
|
serviceInstanceId,
|
|
13339
14144
|
serviceName,
|
|
13340
14145
|
communicationTypes,
|
|
@@ -13350,7 +14155,7 @@ var RestController = class _RestController {
|
|
|
13350
14155
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
13351
14156
|
// JWT token...
|
|
13352
14157
|
}
|
|
13353
|
-
},
|
|
14158
|
+
}, 50);
|
|
13354
14159
|
return true;
|
|
13355
14160
|
},
|
|
13356
14161
|
"Prepares handshake"
|
|
@@ -13404,6 +14209,7 @@ var RestController = class _RestController {
|
|
|
13404
14209
|
serviceName,
|
|
13405
14210
|
url,
|
|
13406
14211
|
connected: false,
|
|
14212
|
+
handshakeInFlight: false,
|
|
13407
14213
|
destroyed: false,
|
|
13408
14214
|
lastHandshakeAt: null,
|
|
13409
14215
|
lastHandshakeError: null,
|
|
@@ -14841,8 +15647,8 @@ var SocketController = class _SocketController {
|
|
|
14841
15647
|
}
|
|
14842
15648
|
const routedDelegateCtx = stripTransportSelectionRoutingContext(delegateCtx);
|
|
14843
15649
|
const normalizedDelegateCtx = ensureDelegationContextMetadata(
|
|
14844
|
-
|
|
14845
|
-
|
|
15650
|
+
restoreDelegationRequestSnapshot(
|
|
15651
|
+
attachDelegationRequestSnapshot(routedDelegateCtx)
|
|
14846
15652
|
)
|
|
14847
15653
|
);
|
|
14848
15654
|
delete normalizedDelegateCtx.__isSubMeta;
|
|
@@ -14915,13 +15721,11 @@ var SocketController = class _SocketController {
|
|
|
14915
15721
|
return resolvedResultContext;
|
|
14916
15722
|
} catch (error) {
|
|
14917
15723
|
const message = error instanceof Error ? error.message : String(error);
|
|
14918
|
-
const failedContext =
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
...normalizedDelegateCtx.__metadata
|
|
14924
|
-
};
|
|
15724
|
+
const failedContext = buildDelegationFailureContext(
|
|
15725
|
+
"meta.socket_client.delegate_failed",
|
|
15726
|
+
normalizedDelegateCtx,
|
|
15727
|
+
error
|
|
15728
|
+
);
|
|
14925
15729
|
if (deputyExecId) {
|
|
14926
15730
|
emitter(`meta.socket_client.delegated:${deputyExecId}`, {
|
|
14927
15731
|
...failedContext,
|
|
@@ -15928,12 +16732,58 @@ var RuntimeValidationController = class _RuntimeValidationController {
|
|
|
15928
16732
|
// src/graph/controllers/registerActorSessionPersistence.ts
|
|
15929
16733
|
import { META_ACTOR_SESSION_STATE_PERSIST_INTENT } from "@cadenza.io/core";
|
|
15930
16734
|
var ACTOR_SESSION_STATE_PERSIST_CONCURRENCY = 20;
|
|
16735
|
+
var META_ACTOR_SESSION_STATE_HYDRATE_INTENT = "meta-actor-session-state-hydrate";
|
|
15931
16736
|
var ACTOR_SESSION_TRACE_ENABLED4 = process.env.CADENZA_ACTOR_SESSION_TRACE === "1" || process.env.CADENZA_ACTOR_SESSION_TRACE === "true";
|
|
16737
|
+
function findNestedContextValue(ctx, key) {
|
|
16738
|
+
if (!ctx || typeof ctx !== "object") {
|
|
16739
|
+
return void 0;
|
|
16740
|
+
}
|
|
16741
|
+
if (Object.prototype.hasOwnProperty.call(ctx, key) || ctx[key] !== void 0) {
|
|
16742
|
+
return ctx[key];
|
|
16743
|
+
}
|
|
16744
|
+
const joinedContexts = Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : [];
|
|
16745
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
16746
|
+
const nested = joinedContexts[index];
|
|
16747
|
+
if (!nested || typeof nested !== "object") {
|
|
16748
|
+
continue;
|
|
16749
|
+
}
|
|
16750
|
+
const nestedValue = findNestedContextValue(nested, key);
|
|
16751
|
+
if (nestedValue !== void 0) {
|
|
16752
|
+
return nestedValue;
|
|
16753
|
+
}
|
|
16754
|
+
}
|
|
16755
|
+
return void 0;
|
|
16756
|
+
}
|
|
16757
|
+
function resolveActorSessionStateRow(ctx) {
|
|
16758
|
+
const singular = findNestedContextValue(ctx, "actorSessionState");
|
|
16759
|
+
if (singular && typeof singular === "object" && !Array.isArray(singular)) {
|
|
16760
|
+
return singular;
|
|
16761
|
+
}
|
|
16762
|
+
const plural = findNestedContextValue(ctx, "actorSessionStates");
|
|
16763
|
+
if (Array.isArray(plural)) {
|
|
16764
|
+
const first = plural.find(
|
|
16765
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
16766
|
+
);
|
|
16767
|
+
if (first) {
|
|
16768
|
+
return first;
|
|
16769
|
+
}
|
|
16770
|
+
}
|
|
16771
|
+
const rows = findNestedContextValue(ctx, "rows");
|
|
16772
|
+
if (Array.isArray(rows)) {
|
|
16773
|
+
const first = rows.find(
|
|
16774
|
+
(entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
16775
|
+
);
|
|
16776
|
+
if (first) {
|
|
16777
|
+
return first;
|
|
16778
|
+
}
|
|
16779
|
+
}
|
|
16780
|
+
return null;
|
|
16781
|
+
}
|
|
15932
16782
|
function shouldAssumeSuccessfulActorSessionRowCount(ctx) {
|
|
15933
16783
|
return ctx.__success === true && ctx.rowCount === void 0 && ctx.__status === "success" && ctx.__serviceName === "CadenzaDB" && ctx.__localTaskName === "Insert actor_session_state in CadenzaDB";
|
|
15934
16784
|
}
|
|
15935
16785
|
function registerActorSessionPersistenceTasks() {
|
|
15936
|
-
if (CadenzaService.get("Persist actor session state")) {
|
|
16786
|
+
if (CadenzaService.get("Persist actor session state") && CadenzaService.get("Hydrate actor session state")) {
|
|
15937
16787
|
return;
|
|
15938
16788
|
}
|
|
15939
16789
|
const localActorSessionTaskOptions = {
|
|
@@ -15950,6 +16800,14 @@ function registerActorSessionPersistenceTasks() {
|
|
|
15950
16800
|
isSubMeta: true
|
|
15951
16801
|
}
|
|
15952
16802
|
);
|
|
16803
|
+
const actorSessionStateQueryTask = CadenzaService.getLocalCadenzaDBQueryTask("actor_session_state") ?? CadenzaService.get("dbQueryActorSessionState") ?? CadenzaService.get("Query actor_session_state in CadenzaDB") ?? CadenzaService.createCadenzaDBQueryTask(
|
|
16804
|
+
"actor_session_state",
|
|
16805
|
+
{},
|
|
16806
|
+
{
|
|
16807
|
+
concurrency: ACTOR_SESSION_STATE_PERSIST_CONCURRENCY,
|
|
16808
|
+
isSubMeta: true
|
|
16809
|
+
}
|
|
16810
|
+
);
|
|
15953
16811
|
const validateActorSessionStatePersistenceTask = CadenzaService.createMetaTask(
|
|
15954
16812
|
"Validate actor session state persistence",
|
|
15955
16813
|
(ctx) => {
|
|
@@ -15983,6 +16841,103 @@ function registerActorSessionPersistenceTasks() {
|
|
|
15983
16841
|
const insertAndValidateActorSessionStateTask = actorSessionStateInsertTask.then(
|
|
15984
16842
|
validateActorSessionStatePersistenceTask
|
|
15985
16843
|
);
|
|
16844
|
+
const validateActorSessionStateHydrationTask = CadenzaService.createMetaTask(
|
|
16845
|
+
"Validate actor session state hydration",
|
|
16846
|
+
(ctx) => {
|
|
16847
|
+
if (ctx.errored || ctx.failed || ctx.__success !== true) {
|
|
16848
|
+
throw new Error(
|
|
16849
|
+
String(
|
|
16850
|
+
ctx.__error ?? ctx.error ?? "actor_session_state hydration query failed"
|
|
16851
|
+
)
|
|
16852
|
+
);
|
|
16853
|
+
}
|
|
16854
|
+
const row = resolveActorSessionStateRow(ctx);
|
|
16855
|
+
if (!row) {
|
|
16856
|
+
return {
|
|
16857
|
+
__success: true,
|
|
16858
|
+
hydrated: false
|
|
16859
|
+
};
|
|
16860
|
+
}
|
|
16861
|
+
const expiresAt = typeof row.expiresAt === "string" ? row.expiresAt : typeof row.expires_at === "string" ? row.expires_at : null;
|
|
16862
|
+
const expiresAtMs = expiresAt ? Date.parse(expiresAt) : Number.NaN;
|
|
16863
|
+
if (Number.isFinite(expiresAtMs) && expiresAtMs <= Date.now()) {
|
|
16864
|
+
return {
|
|
16865
|
+
__success: true,
|
|
16866
|
+
hydrated: false
|
|
16867
|
+
};
|
|
16868
|
+
}
|
|
16869
|
+
const durableState = row.durableState ?? row.durable_state ?? null;
|
|
16870
|
+
const durableVersion = Number(
|
|
16871
|
+
row.durableVersion ?? row.durable_version ?? Number.NaN
|
|
16872
|
+
);
|
|
16873
|
+
if (typeof durableState !== "object" || durableState === null || Array.isArray(durableState)) {
|
|
16874
|
+
throw new Error("actor_session_state durable_state must be a non-null object");
|
|
16875
|
+
}
|
|
16876
|
+
if (!Number.isInteger(durableVersion) || durableVersion < 0) {
|
|
16877
|
+
throw new Error(
|
|
16878
|
+
"actor_session_state durable_version must be a non-negative integer"
|
|
16879
|
+
);
|
|
16880
|
+
}
|
|
16881
|
+
return {
|
|
16882
|
+
__success: true,
|
|
16883
|
+
hydrated: true,
|
|
16884
|
+
actor_name: row.actorName ?? row.actor_name,
|
|
16885
|
+
actor_version: row.actorVersion ?? row.actor_version,
|
|
16886
|
+
actor_key: row.actorKey ?? row.actor_key,
|
|
16887
|
+
service_name: row.serviceName ?? row.service_name,
|
|
16888
|
+
durable_state: durableState,
|
|
16889
|
+
durable_version: durableVersion
|
|
16890
|
+
};
|
|
16891
|
+
},
|
|
16892
|
+
"Validates and normalizes hydrated actor_session_state rows.",
|
|
16893
|
+
localActorSessionTaskOptions
|
|
16894
|
+
);
|
|
16895
|
+
const queryAndValidateActorSessionStateTask = actorSessionStateQueryTask.then(
|
|
16896
|
+
validateActorSessionStateHydrationTask
|
|
16897
|
+
);
|
|
16898
|
+
CadenzaService.createMetaTask(
|
|
16899
|
+
"Hydrate actor session state",
|
|
16900
|
+
(ctx) => {
|
|
16901
|
+
const actorName = typeof ctx.actor_name === "string" ? ctx.actor_name.trim() : "";
|
|
16902
|
+
const actorKey = typeof ctx.actor_key === "string" ? ctx.actor_key.trim() : "";
|
|
16903
|
+
const actorVersion = Number(ctx.actor_version ?? 1);
|
|
16904
|
+
const serviceName = CadenzaService.serviceRegistry.serviceName;
|
|
16905
|
+
if (!actorName) {
|
|
16906
|
+
throw new Error("actor_name is required for actor session hydration");
|
|
16907
|
+
}
|
|
16908
|
+
if (!actorKey) {
|
|
16909
|
+
throw new Error("actor_key is required for actor session hydration");
|
|
16910
|
+
}
|
|
16911
|
+
if (!Number.isInteger(actorVersion) || actorVersion < 1) {
|
|
16912
|
+
throw new Error("actor_version must be a positive integer");
|
|
16913
|
+
}
|
|
16914
|
+
if (!serviceName) {
|
|
16915
|
+
throw new Error("service_name is not available for actor session hydration");
|
|
16916
|
+
}
|
|
16917
|
+
return {
|
|
16918
|
+
...ctx,
|
|
16919
|
+
actor_name: actorName,
|
|
16920
|
+
actor_key: actorKey,
|
|
16921
|
+
actor_version: actorVersion,
|
|
16922
|
+
service_name: serviceName,
|
|
16923
|
+
queryData: {
|
|
16924
|
+
filter: {
|
|
16925
|
+
actor_name: actorName,
|
|
16926
|
+
actor_version: actorVersion,
|
|
16927
|
+
actor_key: actorKey,
|
|
16928
|
+
service_name: serviceName,
|
|
16929
|
+
deleted: false
|
|
16930
|
+
},
|
|
16931
|
+
queryMode: "one",
|
|
16932
|
+
sort: {
|
|
16933
|
+
updated: "desc"
|
|
16934
|
+
}
|
|
16935
|
+
}
|
|
16936
|
+
};
|
|
16937
|
+
},
|
|
16938
|
+
"Builds a one-row actor_session_state lookup for lazy actor hydration.",
|
|
16939
|
+
localActorSessionTaskOptions
|
|
16940
|
+
).then(queryAndValidateActorSessionStateTask).respondsTo(META_ACTOR_SESSION_STATE_HYDRATE_INTENT);
|
|
15986
16941
|
CadenzaService.createMetaTask(
|
|
15987
16942
|
"Persist actor session state",
|
|
15988
16943
|
(ctx) => {
|
|
@@ -16303,16 +17258,20 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
16303
17258
|
ctx,
|
|
16304
17259
|
queryData
|
|
16305
17260
|
);
|
|
16306
|
-
|
|
16307
|
-
|
|
16308
|
-
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
17261
|
+
const hasEmptyObjectData = originalQueryData.data && typeof originalQueryData.data === "object" && !Array.isArray(originalQueryData.data) && Object.keys(originalQueryData.data).length === 0;
|
|
17262
|
+
const hasMissingData = originalQueryData.data === void 0;
|
|
17263
|
+
if ((tableName === "task" || tableName === "signal_registry" || tableName === "directional_task_graph_map") && (hasEmptyObjectData || hasMissingData)) {
|
|
17264
|
+
console.warn("[CADENZA_SYNC_EMPTY_INSERT]", {
|
|
17265
|
+
tableName,
|
|
17266
|
+
hasMissingData,
|
|
17267
|
+
hasEmptyObjectData,
|
|
17268
|
+
taskName: typeof ctx.__taskName === "string" ? ctx.__taskName : void 0,
|
|
17269
|
+
reason: typeof ctx.__reason === "string" ? ctx.__reason : void 0,
|
|
17270
|
+
syncSourceServiceName: typeof ctx.__syncSourceServiceName === "string" ? ctx.__syncSourceServiceName : void 0,
|
|
17271
|
+
queryData: originalQueryData,
|
|
17272
|
+
ctx,
|
|
17273
|
+
joinedContexts: Array.isArray(ctx.joinedContexts) ? ctx.joinedContexts : []
|
|
17274
|
+
});
|
|
16316
17275
|
}
|
|
16317
17276
|
return buildSyncExecutionEnvelope(
|
|
16318
17277
|
ctx,
|
|
@@ -16403,7 +17362,7 @@ function isBootstrapLocalOnlyActorName(actorName) {
|
|
|
16403
17362
|
return BOOTSTRAP_LOCAL_ONLY_ACTOR_NAMES.has(actorName);
|
|
16404
17363
|
}
|
|
16405
17364
|
function isBootstrapLocalOnlySignal(signalName) {
|
|
16406
|
-
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);
|
|
17365
|
+
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);
|
|
16407
17366
|
}
|
|
16408
17367
|
function hasNonZeroPending(summary) {
|
|
16409
17368
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
@@ -16631,6 +17590,12 @@ function resolveLocalRoutineFromSyncContext(ctx) {
|
|
|
16631
17590
|
);
|
|
16632
17591
|
return routineName ? CadenzaService.getRoutine(routineName) : void 0;
|
|
16633
17592
|
}
|
|
17593
|
+
function shouldTrackDirectionalTaskMapForBootstrap(predecessorTask, nextTask) {
|
|
17594
|
+
if (!predecessorTask || !nextTask) {
|
|
17595
|
+
return false;
|
|
17596
|
+
}
|
|
17597
|
+
return predecessorTask.isMeta !== true && predecessorTask.isSubMeta !== true && nextTask.isMeta !== true && nextTask.isSubMeta !== true;
|
|
17598
|
+
}
|
|
16634
17599
|
function resolveSignalNameFromSyncContext(ctx) {
|
|
16635
17600
|
const candidateSignalNames = [
|
|
16636
17601
|
ctx.signalName,
|
|
@@ -17707,7 +18672,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
17707
18672
|
return;
|
|
17708
18673
|
}
|
|
17709
18674
|
for (const t of task.nextTasks) {
|
|
17710
|
-
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered) {
|
|
18675
|
+
if (task.taskMapRegistration.has(t.name) || t.hidden || !t.register || !t.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, t)) {
|
|
17711
18676
|
continue;
|
|
17712
18677
|
}
|
|
17713
18678
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -17775,7 +18740,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
17775
18740
|
return false;
|
|
17776
18741
|
}
|
|
17777
18742
|
for (const nextTask of task.nextTasks) {
|
|
17778
|
-
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered) {
|
|
18743
|
+
if (task.taskMapRegistration.has(nextTask.name) || nextTask.isHidden || !nextTask.register || !nextTask.registered || !shouldTrackDirectionalTaskMapForBootstrap(task, nextTask)) {
|
|
17779
18744
|
continue;
|
|
17780
18745
|
}
|
|
17781
18746
|
if (resolveSyncServiceName(nextTask)) {
|
|
@@ -20065,10 +21030,23 @@ function resolveInquiryFailureError(inquiry, value, depth = 3, seen = /* @__PURE
|
|
|
20065
21030
|
}
|
|
20066
21031
|
return `Inquiry '${inquiry}' did not complete successfully`;
|
|
20067
21032
|
}
|
|
21033
|
+
function normalizePositiveInteger2(value, fallback) {
|
|
21034
|
+
const normalized = Number(value);
|
|
21035
|
+
return Number.isInteger(normalized) && normalized > 0 ? normalized : fallback;
|
|
21036
|
+
}
|
|
20068
21037
|
var DEFAULT_DEPUTY_TASK_CONCURRENCY = 50;
|
|
20069
21038
|
var DEFAULT_DEPUTY_TASK_TIMEOUT_MS = 12e4;
|
|
20070
21039
|
var DEFAULT_DATABASE_PROXY_TASK_CONCURRENCY = 50;
|
|
20071
21040
|
var DEFAULT_DATABASE_PROXY_TASK_TIMEOUT_MS = 12e4;
|
|
21041
|
+
var SERVICE_MANIFEST_PUBLICATION_ORDER = [
|
|
21042
|
+
"routing_capability",
|
|
21043
|
+
"business_structural",
|
|
21044
|
+
"local_meta_structural"
|
|
21045
|
+
];
|
|
21046
|
+
function getServiceManifestPublicationLayerRank(layer) {
|
|
21047
|
+
const index = SERVICE_MANIFEST_PUBLICATION_ORDER.indexOf(layer);
|
|
21048
|
+
return index >= 0 ? index : SERVICE_MANIFEST_PUBLICATION_ORDER.length - 1;
|
|
21049
|
+
}
|
|
20072
21050
|
var CadenzaService = class {
|
|
20073
21051
|
static unregisterGracefulShutdownHandlers() {
|
|
20074
21052
|
for (const cleanup of this.shutdownHandlerCleanup) {
|
|
@@ -20195,7 +21173,15 @@ var CadenzaService = class {
|
|
|
20195
21173
|
this.replayRegisteredTaskSignalObservations();
|
|
20196
21174
|
this.replayRegisteredTaskIntentAssociations();
|
|
20197
21175
|
}
|
|
20198
|
-
static
|
|
21176
|
+
static normalizeServiceManifestPublicationLayer(value, fallback = "business_structural") {
|
|
21177
|
+
return value === "routing_capability" || value === "business_structural" || value === "local_meta_structural" ? value : fallback;
|
|
21178
|
+
}
|
|
21179
|
+
static mergeServiceManifestPublicationRequest(reason, targetLayer) {
|
|
21180
|
+
this.serviceManifestPublicationPendingReason = reason;
|
|
21181
|
+
const currentTargetLayer = this.serviceManifestPublicationPendingLayer ?? "routing_capability";
|
|
21182
|
+
this.serviceManifestPublicationPendingLayer = getServiceManifestPublicationLayerRank(targetLayer) >= getServiceManifestPublicationLayerRank(currentTargetLayer) ? targetLayer : currentTargetLayer;
|
|
21183
|
+
}
|
|
21184
|
+
static requestServiceManifestPublication(reason, immediate = false, targetLayer = "business_structural") {
|
|
20199
21185
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
20200
21186
|
return;
|
|
20201
21187
|
}
|
|
@@ -20203,7 +21189,8 @@ var CadenzaService = class {
|
|
|
20203
21189
|
const payload = {
|
|
20204
21190
|
__reason: reason,
|
|
20205
21191
|
__serviceName: this.serviceRegistry.serviceName,
|
|
20206
|
-
__serviceInstanceId: this.serviceRegistry.serviceInstanceId
|
|
21192
|
+
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
21193
|
+
__publicationLayer: targetLayer
|
|
20207
21194
|
};
|
|
20208
21195
|
if (immediate) {
|
|
20209
21196
|
this.emit(signalName, payload);
|
|
@@ -20211,32 +21198,53 @@ var CadenzaService = class {
|
|
|
20211
21198
|
}
|
|
20212
21199
|
this.debounce(signalName, payload, 100);
|
|
20213
21200
|
}
|
|
20214
|
-
static scheduleServiceManifestPublicationRetry(reason) {
|
|
21201
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
20215
21202
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
20216
21203
|
return;
|
|
20217
21204
|
}
|
|
20218
21205
|
setTimeout(() => {
|
|
20219
|
-
this.requestServiceManifestPublication(reason, false);
|
|
21206
|
+
this.requestServiceManifestPublication(reason, false, targetLayer);
|
|
20220
21207
|
}, 1e3);
|
|
20221
21208
|
}
|
|
20222
|
-
static async publishServiceManifestIfNeeded(reason) {
|
|
21209
|
+
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
20223
21210
|
if (!this.serviceRegistry.connectsToCadenzaDB || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
20224
21211
|
return false;
|
|
20225
21212
|
}
|
|
20226
21213
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
21214
|
+
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
21215
|
+
targetLayer
|
|
21216
|
+
);
|
|
20227
21217
|
if (this.serviceManifestPublicationInFlight) {
|
|
20228
|
-
this.
|
|
21218
|
+
this.mergeServiceManifestPublicationRequest(
|
|
21219
|
+
publishReason,
|
|
21220
|
+
publishTargetLayer
|
|
21221
|
+
);
|
|
20229
21222
|
return false;
|
|
20230
21223
|
}
|
|
20231
|
-
const
|
|
20232
|
-
|
|
20233
|
-
|
|
20234
|
-
|
|
20235
|
-
|
|
21224
|
+
const publicationPlan = SERVICE_MANIFEST_PUBLICATION_ORDER.filter(
|
|
21225
|
+
(layer) => getServiceManifestPublicationLayerRank(layer) <= getServiceManifestPublicationLayerRank(publishTargetLayer)
|
|
21226
|
+
).map((layer) => {
|
|
21227
|
+
const snapshot2 = buildServiceManifestSnapshot({
|
|
21228
|
+
serviceName: this.serviceRegistry.serviceName,
|
|
21229
|
+
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
21230
|
+
revision: this.serviceManifestRevision + 1,
|
|
21231
|
+
publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21232
|
+
publicationLayer: layer
|
|
21233
|
+
});
|
|
21234
|
+
return {
|
|
21235
|
+
layer,
|
|
21236
|
+
snapshot: snapshot2,
|
|
21237
|
+
changed: this.lastPublishedServiceManifestHashes[layer] !== snapshot2.manifestHash
|
|
21238
|
+
};
|
|
20236
21239
|
});
|
|
20237
|
-
|
|
21240
|
+
const nextPublication = publicationPlan.find((entry) => entry.changed);
|
|
21241
|
+
if (!nextPublication) {
|
|
20238
21242
|
return false;
|
|
20239
21243
|
}
|
|
21244
|
+
const { layer: publicationLayer, snapshot } = nextPublication;
|
|
21245
|
+
const hasPendingFollowupLayer = publicationPlan.some(
|
|
21246
|
+
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
21247
|
+
);
|
|
20240
21248
|
this.serviceManifestPublicationInFlight = true;
|
|
20241
21249
|
try {
|
|
20242
21250
|
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
@@ -20244,7 +21252,10 @@ var CadenzaService = class {
|
|
|
20244
21252
|
snapshot
|
|
20245
21253
|
);
|
|
20246
21254
|
if (!this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
20247
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
21255
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
21256
|
+
publishReason,
|
|
21257
|
+
publishTargetLayer
|
|
21258
|
+
);
|
|
20248
21259
|
return false;
|
|
20249
21260
|
}
|
|
20250
21261
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
@@ -20252,32 +21263,48 @@ var CadenzaService = class {
|
|
|
20252
21263
|
requireComplete: true
|
|
20253
21264
|
});
|
|
20254
21265
|
this.serviceManifestRevision = snapshot.revision;
|
|
20255
|
-
this.
|
|
21266
|
+
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
21267
|
+
if (hasPendingFollowupLayer) {
|
|
21268
|
+
this.mergeServiceManifestPublicationRequest(
|
|
21269
|
+
publishReason,
|
|
21270
|
+
publishTargetLayer
|
|
21271
|
+
);
|
|
21272
|
+
}
|
|
20256
21273
|
return {
|
|
20257
21274
|
serviceManifest: snapshot,
|
|
20258
|
-
published: true
|
|
21275
|
+
published: true,
|
|
21276
|
+
publicationLayer
|
|
20259
21277
|
};
|
|
20260
21278
|
} catch (error) {
|
|
20261
21279
|
this.log("Service manifest publication failed. Scheduling retry.", {
|
|
20262
21280
|
serviceName: this.serviceRegistry.serviceName,
|
|
20263
21281
|
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
20264
21282
|
reason: publishReason,
|
|
21283
|
+
publicationLayer,
|
|
20265
21284
|
error: resolveInquiryFailureError(
|
|
20266
21285
|
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
20267
21286
|
error
|
|
20268
21287
|
),
|
|
20269
21288
|
inquiryMeta: error && typeof error === "object" && "__inquiryMeta" in error ? error.__inquiryMeta : null
|
|
20270
21289
|
});
|
|
20271
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
21290
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
21291
|
+
publishReason,
|
|
21292
|
+
publishTargetLayer
|
|
21293
|
+
);
|
|
20272
21294
|
return false;
|
|
20273
21295
|
} finally {
|
|
20274
21296
|
this.serviceManifestPublicationInFlight = false;
|
|
20275
|
-
if (this.serviceManifestPublicationPendingReason) {
|
|
21297
|
+
if (this.serviceManifestPublicationPendingReason && this.serviceManifestPublicationPendingLayer) {
|
|
20276
21298
|
const pendingReason = this.serviceManifestPublicationPendingReason;
|
|
21299
|
+
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
20277
21300
|
this.serviceManifestPublicationPendingReason = null;
|
|
21301
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
20278
21302
|
this.debounce(
|
|
20279
21303
|
"meta.service_manifest.publish_requested",
|
|
20280
|
-
{
|
|
21304
|
+
{
|
|
21305
|
+
__reason: pendingReason,
|
|
21306
|
+
__publicationLayer: pendingLayer
|
|
21307
|
+
},
|
|
20281
21308
|
100
|
|
20282
21309
|
);
|
|
20283
21310
|
}
|
|
@@ -20290,9 +21317,13 @@ var CadenzaService = class {
|
|
|
20290
21317
|
this.createMetaTask(
|
|
20291
21318
|
"Publish service manifest",
|
|
20292
21319
|
async (ctx) => this.publishServiceManifestIfNeeded(
|
|
20293
|
-
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish"
|
|
21320
|
+
typeof ctx.__reason === "string" && ctx.__reason.trim().length > 0 ? ctx.__reason.trim() : "service_manifest_publish",
|
|
21321
|
+
this.normalizeServiceManifestPublicationLayer(
|
|
21322
|
+
ctx.__publicationLayer,
|
|
21323
|
+
"business_structural"
|
|
21324
|
+
)
|
|
20294
21325
|
),
|
|
20295
|
-
"Publishes
|
|
21326
|
+
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
20296
21327
|
{
|
|
20297
21328
|
register: false,
|
|
20298
21329
|
isHidden: true
|
|
@@ -20302,13 +21333,18 @@ var CadenzaService = class {
|
|
|
20302
21333
|
"Request manifest publication after structural change",
|
|
20303
21334
|
(ctx) => {
|
|
20304
21335
|
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";
|
|
21336
|
+
const targetLayer = reason === "meta.service_registry.instance_inserted" ? "business_structural" : this.normalizeServiceManifestPublicationLayer(
|
|
21337
|
+
ctx.__publicationLayer,
|
|
21338
|
+
"business_structural"
|
|
21339
|
+
);
|
|
20305
21340
|
this.requestServiceManifestPublication(
|
|
20306
21341
|
reason,
|
|
20307
|
-
reason === "meta.service_registry.instance_inserted"
|
|
21342
|
+
reason === "meta.service_registry.instance_inserted",
|
|
21343
|
+
targetLayer
|
|
20308
21344
|
);
|
|
20309
21345
|
return true;
|
|
20310
21346
|
},
|
|
20311
|
-
"Requests
|
|
21347
|
+
"Requests staged manifest publication when a static service primitive changes.",
|
|
20312
21348
|
{
|
|
20313
21349
|
register: false,
|
|
20314
21350
|
isHidden: true
|
|
@@ -21563,10 +22599,28 @@ var CadenzaService = class {
|
|
|
21563
22599
|
__isFrontend: isFrontend,
|
|
21564
22600
|
__declaredTransports: declaredTransports
|
|
21565
22601
|
};
|
|
22602
|
+
let bootstrapServiceCreationRequested = false;
|
|
21566
22603
|
if (options.cadenzaDB?.connect) {
|
|
21567
|
-
this.
|
|
21568
|
-
|
|
21569
|
-
|
|
22604
|
+
this.createMetaTask(
|
|
22605
|
+
"Create service",
|
|
22606
|
+
async (context, emit2) => {
|
|
22607
|
+
const handshakeServiceName = String(context?.serviceName ?? "").trim();
|
|
22608
|
+
if (handshakeServiceName !== "CadenzaDB") {
|
|
22609
|
+
return false;
|
|
22610
|
+
}
|
|
22611
|
+
if (bootstrapServiceCreationRequested) {
|
|
22612
|
+
return false;
|
|
22613
|
+
}
|
|
22614
|
+
bootstrapServiceCreationRequested = true;
|
|
22615
|
+
emit2("meta.create_service_requested", initContext);
|
|
22616
|
+
return true;
|
|
22617
|
+
},
|
|
22618
|
+
"Requests local service creation only once after the initial authority bootstrap handshake completes.",
|
|
22619
|
+
{
|
|
22620
|
+
register: false,
|
|
22621
|
+
isHidden: true
|
|
22622
|
+
}
|
|
22623
|
+
).doOn("meta.fetch.handshake_complete");
|
|
21570
22624
|
} else {
|
|
21571
22625
|
this.emit("meta.create_service_requested", initContext);
|
|
21572
22626
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
@@ -21579,10 +22633,33 @@ var CadenzaService = class {
|
|
|
21579
22633
|
);
|
|
21580
22634
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
21581
22635
|
}
|
|
22636
|
+
let serviceSetupCompletedHandled = false;
|
|
21582
22637
|
this.createMetaTask("Handle service setup completion", (ctx, emit2) => {
|
|
22638
|
+
if (serviceSetupCompletedHandled) {
|
|
22639
|
+
return false;
|
|
22640
|
+
}
|
|
22641
|
+
const insertedServiceInstanceId = String(
|
|
22642
|
+
ctx?.serviceInstanceId ?? ctx?.service_instance_id ?? ctx?.serviceInstance?.uuid ?? ctx?.serviceInstance?.serviceInstanceId ?? ""
|
|
22643
|
+
).trim();
|
|
22644
|
+
const insertedServiceName = String(
|
|
22645
|
+
ctx?.serviceName ?? ctx?.service_name ?? ctx?.serviceInstance?.serviceName ?? ctx?.serviceInstance?.service_name ?? ""
|
|
22646
|
+
).trim();
|
|
22647
|
+
if (!insertedServiceInstanceId && !insertedServiceName) {
|
|
22648
|
+
return false;
|
|
22649
|
+
}
|
|
22650
|
+
if (insertedServiceInstanceId && insertedServiceInstanceId !== serviceId) {
|
|
22651
|
+
return false;
|
|
22652
|
+
}
|
|
22653
|
+
if (!insertedServiceInstanceId && insertedServiceName && insertedServiceName !== serviceName) {
|
|
22654
|
+
return false;
|
|
22655
|
+
}
|
|
22656
|
+
serviceSetupCompletedHandled = true;
|
|
21583
22657
|
if (options.cadenzaDB?.connect) {
|
|
21584
22658
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
21585
|
-
void this.publishServiceManifestIfNeeded(
|
|
22659
|
+
void this.publishServiceManifestIfNeeded(
|
|
22660
|
+
"service_setup_completed",
|
|
22661
|
+
"business_structural"
|
|
22662
|
+
);
|
|
21586
22663
|
}
|
|
21587
22664
|
if (isFrontend) {
|
|
21588
22665
|
registerActorSessionPersistenceTasks();
|
|
@@ -21637,7 +22714,11 @@ var CadenzaService = class {
|
|
|
21637
22714
|
);
|
|
21638
22715
|
}
|
|
21639
22716
|
this.serviceCreated = true;
|
|
21640
|
-
this.requestServiceManifestPublication(
|
|
22717
|
+
this.requestServiceManifestPublication(
|
|
22718
|
+
"service_created",
|
|
22719
|
+
true,
|
|
22720
|
+
"routing_capability"
|
|
22721
|
+
);
|
|
21641
22722
|
}
|
|
21642
22723
|
/**
|
|
21643
22724
|
* Creates a Cadenza metadata service with the specified name, description, and options.
|
|
@@ -21898,11 +22979,84 @@ var CadenzaService = class {
|
|
|
21898
22979
|
}
|
|
21899
22980
|
static createActor(spec, options = {}) {
|
|
21900
22981
|
this.bootstrap();
|
|
21901
|
-
return Cadenza.createActor(
|
|
22982
|
+
return Cadenza.createActor(
|
|
22983
|
+
spec,
|
|
22984
|
+
this.withActorSessionHydration(
|
|
22985
|
+
spec,
|
|
22986
|
+
options
|
|
22987
|
+
)
|
|
22988
|
+
);
|
|
21902
22989
|
}
|
|
21903
22990
|
static createActorFromDefinition(definition, options = {}) {
|
|
21904
22991
|
this.bootstrap();
|
|
21905
|
-
return Cadenza.createActorFromDefinition(
|
|
22992
|
+
return Cadenza.createActorFromDefinition(
|
|
22993
|
+
definition,
|
|
22994
|
+
this.withActorSessionHydration(
|
|
22995
|
+
{
|
|
22996
|
+
name: definition.name,
|
|
22997
|
+
description: definition.description,
|
|
22998
|
+
defaultKey: definition.defaultKey,
|
|
22999
|
+
kind: definition.kind,
|
|
23000
|
+
loadPolicy: definition.loadPolicy,
|
|
23001
|
+
writeContract: definition.writeContract,
|
|
23002
|
+
consistencyProfile: definition.consistencyProfile,
|
|
23003
|
+
retry: definition.retry,
|
|
23004
|
+
idempotency: definition.idempotency,
|
|
23005
|
+
session: definition.session,
|
|
23006
|
+
runtimeReadGuard: definition.runtimeReadGuard,
|
|
23007
|
+
key: definition.key,
|
|
23008
|
+
state: definition.state,
|
|
23009
|
+
taskBindings: definition.tasks,
|
|
23010
|
+
initState: definition.state?.durable?.initState ?? definition.state?.durable?.initialState
|
|
23011
|
+
},
|
|
23012
|
+
options
|
|
23013
|
+
)
|
|
23014
|
+
);
|
|
23015
|
+
}
|
|
23016
|
+
static withActorSessionHydration(spec, options) {
|
|
23017
|
+
if (options.hydrateDurableState || spec.session?.persistDurableState !== true) {
|
|
23018
|
+
return options;
|
|
23019
|
+
}
|
|
23020
|
+
const actorName = String(spec.name ?? "").trim();
|
|
23021
|
+
const actorVersion = 1;
|
|
23022
|
+
const timeoutMs = normalizePositiveInteger2(
|
|
23023
|
+
spec.session?.persistenceTimeoutMs,
|
|
23024
|
+
5e3
|
|
23025
|
+
);
|
|
23026
|
+
return {
|
|
23027
|
+
...options,
|
|
23028
|
+
hydrateDurableState: async (actorKey) => {
|
|
23029
|
+
registerActorSessionPersistenceTasks();
|
|
23030
|
+
const response = await Cadenza.inquire(
|
|
23031
|
+
META_ACTOR_SESSION_STATE_HYDRATE_INTENT,
|
|
23032
|
+
{
|
|
23033
|
+
actor_name: actorName,
|
|
23034
|
+
actor_version: actorVersion,
|
|
23035
|
+
actor_key: actorKey
|
|
23036
|
+
},
|
|
23037
|
+
{
|
|
23038
|
+
timeout: timeoutMs,
|
|
23039
|
+
requireComplete: true,
|
|
23040
|
+
rejectOnTimeout: true
|
|
23041
|
+
}
|
|
23042
|
+
);
|
|
23043
|
+
if (!response || typeof response !== "object" || response.__success !== true) {
|
|
23044
|
+
throw new Error(
|
|
23045
|
+
resolveInquiryFailureError(
|
|
23046
|
+
META_ACTOR_SESSION_STATE_HYDRATE_INTENT,
|
|
23047
|
+
response
|
|
23048
|
+
)
|
|
23049
|
+
);
|
|
23050
|
+
}
|
|
23051
|
+
if (response.hydrated !== true) {
|
|
23052
|
+
return null;
|
|
23053
|
+
}
|
|
23054
|
+
return {
|
|
23055
|
+
durableState: response.durable_state,
|
|
23056
|
+
durableVersion: Number(response.durable_version)
|
|
23057
|
+
};
|
|
23058
|
+
}
|
|
23059
|
+
};
|
|
21906
23060
|
}
|
|
21907
23061
|
/**
|
|
21908
23062
|
* Creates and registers a new task with the provided name, function, and optional details.
|
|
@@ -22320,6 +23474,11 @@ var CadenzaService = class {
|
|
|
22320
23474
|
this.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
22321
23475
|
this.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
22322
23476
|
this.frontendSyncScheduled = false;
|
|
23477
|
+
this.serviceManifestRevision = 0;
|
|
23478
|
+
this.lastPublishedServiceManifestHashes = {};
|
|
23479
|
+
this.serviceManifestPublicationInFlight = false;
|
|
23480
|
+
this.serviceManifestPublicationPendingReason = null;
|
|
23481
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
22323
23482
|
resetBrowserRuntimeActorHandles();
|
|
22324
23483
|
}
|
|
22325
23484
|
};
|
|
@@ -22333,9 +23492,10 @@ CadenzaService.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
|
22333
23492
|
CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
22334
23493
|
CadenzaService.frontendSyncScheduled = false;
|
|
22335
23494
|
CadenzaService.serviceManifestRevision = 0;
|
|
22336
|
-
CadenzaService.
|
|
23495
|
+
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
22337
23496
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
22338
23497
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
23498
|
+
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
22339
23499
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
22340
23500
|
CadenzaService.shutdownInFlight = false;
|
|
22341
23501
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
@@ -22369,6 +23529,17 @@ function normalizeArrayResponse(value, keys) {
|
|
|
22369
23529
|
if (Array.isArray(value?.data)) {
|
|
22370
23530
|
return value.data;
|
|
22371
23531
|
}
|
|
23532
|
+
const joinedContexts = Array.isArray(value?.joinedContexts) ? value.joinedContexts : [];
|
|
23533
|
+
for (let index = joinedContexts.length - 1; index >= 0; index -= 1) {
|
|
23534
|
+
const nested = joinedContexts[index];
|
|
23535
|
+
if (!nested || typeof nested !== "object") {
|
|
23536
|
+
continue;
|
|
23537
|
+
}
|
|
23538
|
+
const rows = normalizeArrayResponse(nested, keys);
|
|
23539
|
+
if (rows.length > 0) {
|
|
23540
|
+
return rows;
|
|
23541
|
+
}
|
|
23542
|
+
}
|
|
22372
23543
|
return [];
|
|
22373
23544
|
}
|
|
22374
23545
|
function buildQueryResponseKeys(tableName) {
|