@cadenza.io/service 2.20.0 → 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-D787NzXY.d.mts → Cadenza-Duj65Skt.d.mts} +134 -2
- package/dist/{Cadenza-D787NzXY.d.ts → Cadenza-Duj65Skt.d.ts} +134 -2
- package/dist/browser/index.js +985 -182
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +926 -123
- 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 +1184 -223
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1125 -164
- 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 +1 -1
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;
|
|
5101
5674
|
return sanitized;
|
|
5102
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
|
+
}
|
|
5694
|
+
return sanitized;
|
|
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,9 +9245,36 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8549
9245
|
}
|
|
8550
9246
|
}
|
|
8551
9247
|
}
|
|
8552
|
-
const
|
|
8553
|
-
|
|
8554
|
-
|
|
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);
|
|
8555
9278
|
const explodedManifest = explodeServiceManifestSnapshots(
|
|
8556
9279
|
latestManifestSnapshots
|
|
8557
9280
|
);
|
|
@@ -8634,7 +9357,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8634
9357
|
if (!hasExplicitSignalRoutingRows) {
|
|
8635
9358
|
pushUnique(
|
|
8636
9359
|
explodedManifest.signalToTaskMaps,
|
|
8637
|
-
|
|
9360
|
+
filteredSignalToTaskMaps,
|
|
8638
9361
|
seenSignalMaps,
|
|
8639
9362
|
(row) => `${String(row.signal_name ?? "").trim()}|${String(
|
|
8640
9363
|
row.service_name ?? ""
|
|
@@ -8646,7 +9369,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8646
9369
|
if (!hasExplicitIntentRoutingRows) {
|
|
8647
9370
|
pushUnique(
|
|
8648
9371
|
explodedManifest.intentToTaskMaps,
|
|
8649
|
-
|
|
9372
|
+
filteredIntentToTaskMaps,
|
|
8650
9373
|
seenIntentMaps,
|
|
8651
9374
|
(row) => `${String(row.intent_name ?? "").trim()}|${String(
|
|
8652
9375
|
row.service_name ?? ""
|
|
@@ -8656,8 +9379,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8656
9379
|
);
|
|
8657
9380
|
}
|
|
8658
9381
|
return {
|
|
8659
|
-
serviceInstances,
|
|
8660
|
-
serviceInstanceTransports,
|
|
9382
|
+
serviceInstances: filteredServiceInstances,
|
|
9383
|
+
serviceInstanceTransports: filteredServiceInstanceTransports,
|
|
8661
9384
|
serviceManifests,
|
|
8662
9385
|
tasks,
|
|
8663
9386
|
signals,
|
|
@@ -8667,8 +9390,8 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
8667
9390
|
directionalTaskMaps,
|
|
8668
9391
|
actorTaskMaps,
|
|
8669
9392
|
taskToRoutineMaps,
|
|
8670
|
-
signalToTaskMaps,
|
|
8671
|
-
intentToTaskMaps
|
|
9393
|
+
signalToTaskMaps: filteredSignalToTaskMaps,
|
|
9394
|
+
intentToTaskMaps: filteredIntentToTaskMaps
|
|
8672
9395
|
};
|
|
8673
9396
|
}
|
|
8674
9397
|
buildRemoteIntentDeputyKey(map) {
|
|
@@ -9097,10 +9820,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9097
9820
|
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
9098
9821
|
const timeoutId = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
9099
9822
|
try {
|
|
9823
|
+
const sanitizedContext = sanitizeAuthorityBootstrapDelegationContext(context);
|
|
9100
9824
|
const requestBody = stripDelegationRequestSnapshot(
|
|
9101
9825
|
ensureDelegationContextMetadata(
|
|
9102
9826
|
attachDelegationRequestSnapshot({
|
|
9103
|
-
...
|
|
9827
|
+
...sanitizedContext,
|
|
9104
9828
|
__remoteRoutineName: remoteRoutineName,
|
|
9105
9829
|
__serviceName: "CadenzaDB",
|
|
9106
9830
|
__localServiceName: this.serviceName,
|
|
@@ -9114,7 +9838,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9114
9838
|
__fetchId: target.fetchId,
|
|
9115
9839
|
fetchId: target.fetchId,
|
|
9116
9840
|
__metadata: {
|
|
9117
|
-
...
|
|
9841
|
+
...sanitizedContext.__metadata && typeof sanitizedContext.__metadata === "object" ? sanitizedContext.__metadata : {},
|
|
9118
9842
|
__timeout: timeoutMs,
|
|
9119
9843
|
__syncing: true,
|
|
9120
9844
|
__authorityBootstrapChannel: true
|
|
@@ -9132,22 +9856,22 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
9132
9856
|
});
|
|
9133
9857
|
if ("ok" in response && response.ok === false) {
|
|
9134
9858
|
return {
|
|
9135
|
-
...
|
|
9859
|
+
...sanitizedContext,
|
|
9136
9860
|
__error: `Bootstrap authority delegation failed with HTTP ${response.status}`,
|
|
9137
9861
|
errored: true
|
|
9138
9862
|
};
|
|
9139
9863
|
}
|
|
9140
9864
|
const payload = typeof response.json === "function" ? await response.json() : response;
|
|
9141
9865
|
return payload && typeof payload === "object" ? {
|
|
9142
|
-
...
|
|
9866
|
+
...sanitizedContext,
|
|
9143
9867
|
...payload
|
|
9144
9868
|
} : {
|
|
9145
|
-
...
|
|
9869
|
+
...sanitizedContext,
|
|
9146
9870
|
returnedValue: payload
|
|
9147
9871
|
};
|
|
9148
9872
|
} catch (error) {
|
|
9149
9873
|
return {
|
|
9150
|
-
...context,
|
|
9874
|
+
...sanitizeAuthorityBootstrapDelegationContext(context),
|
|
9151
9875
|
__error: error instanceof Error ? error.message : String(error),
|
|
9152
9876
|
errored: true
|
|
9153
9877
|
};
|
|
@@ -12384,6 +13108,41 @@ var TRACED_INQUIRY_METADATA_SIGNALS = /* @__PURE__ */ new Set([
|
|
|
12384
13108
|
"global.meta.graph_metadata.inquiry_updated"
|
|
12385
13109
|
]);
|
|
12386
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
|
+
}
|
|
12387
13146
|
var RestController = class _RestController {
|
|
12388
13147
|
/**
|
|
12389
13148
|
* Constructor for initializing the REST server and related configurations.
|
|
@@ -12417,16 +13176,17 @@ var RestController = class _RestController {
|
|
|
12417
13176
|
const parsedResponse = await this.parseFetchResponse(response);
|
|
12418
13177
|
return parsedResponse.data;
|
|
12419
13178
|
} catch (error) {
|
|
13179
|
+
const loggedRequestInit = summarizeRequestInitForLogging(requestInit);
|
|
12420
13180
|
if (error?.name === "AbortError") {
|
|
12421
13181
|
CadenzaService.log(
|
|
12422
13182
|
"Fetch request timed out.",
|
|
12423
|
-
{ error, URL: url, requestInit },
|
|
13183
|
+
{ error, URL: url, requestInit: loggedRequestInit },
|
|
12424
13184
|
"warning"
|
|
12425
13185
|
);
|
|
12426
13186
|
} else {
|
|
12427
13187
|
CadenzaService.log(
|
|
12428
13188
|
"Fetch request error.",
|
|
12429
|
-
{ error, URL: url, requestInit },
|
|
13189
|
+
{ error, URL: url, requestInit: loggedRequestInit },
|
|
12430
13190
|
"error"
|
|
12431
13191
|
);
|
|
12432
13192
|
}
|
|
@@ -12572,7 +13332,7 @@ var RestController = class _RestController {
|
|
|
12572
13332
|
return { ...ctx, __app: app };
|
|
12573
13333
|
},
|
|
12574
13334
|
"Sets up the Express server according to the security profile"
|
|
12575
|
-
).
|
|
13335
|
+
).then(
|
|
12576
13336
|
CadenzaService.createMetaTask(
|
|
12577
13337
|
"Define RestServer",
|
|
12578
13338
|
(ctx) => {
|
|
@@ -12969,32 +13729,40 @@ var RestController = class _RestController {
|
|
|
12969
13729
|
serviceName,
|
|
12970
13730
|
URL2
|
|
12971
13731
|
);
|
|
12972
|
-
fetchDiagnostics.destroyed = false;
|
|
12973
|
-
fetchDiagnostics.updatedAt = Date.now();
|
|
12974
13732
|
if (CadenzaService.get(`Send Handshake to ${clientTaskSuffix}`)) {
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
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
|
+
}
|
|
12993
13757
|
return true;
|
|
12994
13758
|
}
|
|
13759
|
+
fetchDiagnostics.destroyed = false;
|
|
13760
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13761
|
+
fetchDiagnostics.updatedAt = Date.now();
|
|
12995
13762
|
const handshakeTask = CadenzaService.createMetaTask(
|
|
12996
13763
|
`Send Handshake to ${clientTaskSuffix}`,
|
|
12997
13764
|
async (ctx2, emit2) => {
|
|
13765
|
+
fetchDiagnostics.handshakeInFlight = true;
|
|
12998
13766
|
try {
|
|
12999
13767
|
const response = await this.fetchDataWithTimeout(
|
|
13000
13768
|
`${URL2}/handshake`,
|
|
@@ -13010,6 +13778,7 @@ var RestController = class _RestController {
|
|
|
13010
13778
|
if (response.__status !== "success") {
|
|
13011
13779
|
const error = response.__error ?? `Failed to connect to service ${serviceName} ${ctx2.serviceInstanceId}`;
|
|
13012
13780
|
fetchDiagnostics.connected = false;
|
|
13781
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13013
13782
|
fetchDiagnostics.lastHandshakeError = error;
|
|
13014
13783
|
fetchDiagnostics.updatedAt = Date.now();
|
|
13015
13784
|
this.recordFetchClientError(fetchId, serviceName, URL2, error);
|
|
@@ -13029,6 +13798,7 @@ var RestController = class _RestController {
|
|
|
13029
13798
|
ctx2.serviceInstanceId = response.__serviceInstanceId;
|
|
13030
13799
|
fetchDiagnostics.connected = true;
|
|
13031
13800
|
fetchDiagnostics.destroyed = false;
|
|
13801
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13032
13802
|
fetchDiagnostics.lastHandshakeAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
13033
13803
|
fetchDiagnostics.lastHandshakeError = null;
|
|
13034
13804
|
fetchDiagnostics.updatedAt = Date.now();
|
|
@@ -13057,6 +13827,7 @@ var RestController = class _RestController {
|
|
|
13057
13827
|
}
|
|
13058
13828
|
} catch (e) {
|
|
13059
13829
|
fetchDiagnostics.connected = false;
|
|
13830
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13060
13831
|
fetchDiagnostics.lastHandshakeError = this.getErrorMessage(e);
|
|
13061
13832
|
fetchDiagnostics.updatedAt = Date.now();
|
|
13062
13833
|
this.recordFetchClientError(fetchId, serviceName, URL2, e);
|
|
@@ -13089,8 +13860,8 @@ var RestController = class _RestController {
|
|
|
13089
13860
|
}
|
|
13090
13861
|
const routedDelegateCtx = stripTransportSelectionRoutingContext(ctx2);
|
|
13091
13862
|
const delegateCtx = ensureDelegationContextMetadata(
|
|
13092
|
-
|
|
13093
|
-
|
|
13863
|
+
restoreDelegationRequestSnapshot(
|
|
13864
|
+
attachDelegationRequestSnapshot(routedDelegateCtx)
|
|
13094
13865
|
)
|
|
13095
13866
|
);
|
|
13096
13867
|
const deputyExecId = delegateCtx.__metadata.__deputyExecId;
|
|
@@ -13150,13 +13921,11 @@ var RestController = class _RestController {
|
|
|
13150
13921
|
fetchDiagnostics.delegationFailures++;
|
|
13151
13922
|
fetchDiagnostics.updatedAt = Date.now();
|
|
13152
13923
|
this.recordFetchClientError(fetchId, serviceName, URL2, e);
|
|
13153
|
-
resultContext =
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
...delegateCtx.__metadata
|
|
13159
|
-
};
|
|
13924
|
+
resultContext = buildDelegationFailureContext(
|
|
13925
|
+
"meta.fetch.delegate_failed",
|
|
13926
|
+
delegateCtx,
|
|
13927
|
+
e
|
|
13928
|
+
);
|
|
13160
13929
|
routeOutcome = "failure";
|
|
13161
13930
|
emit2("meta.fetch.delegate_failed", resultContext);
|
|
13162
13931
|
} finally {
|
|
@@ -13322,6 +14091,7 @@ var RestController = class _RestController {
|
|
|
13322
14091
|
return false;
|
|
13323
14092
|
}
|
|
13324
14093
|
fetchDiagnostics.connected = false;
|
|
14094
|
+
fetchDiagnostics.handshakeInFlight = false;
|
|
13325
14095
|
fetchDiagnostics.destroyed = true;
|
|
13326
14096
|
fetchDiagnostics.updatedAt = Date.now();
|
|
13327
14097
|
CadenzaService.log("Destroying fetch client", { URL: URL2, serviceName });
|
|
@@ -13361,7 +14131,15 @@ var RestController = class _RestController {
|
|
|
13361
14131
|
const fetchId = String(
|
|
13362
14132
|
ctx.fetchId ?? ctx.__fetchId ?? (routeKey ? buildTransportHandleKey(routeKey, "rest") : serviceTransportId ?? "")
|
|
13363
14133
|
);
|
|
13364
|
-
|
|
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}`, {
|
|
13365
14143
|
serviceInstanceId,
|
|
13366
14144
|
serviceName,
|
|
13367
14145
|
communicationTypes,
|
|
@@ -13377,7 +14155,7 @@ var RestController = class _RestController {
|
|
|
13377
14155
|
serviceName: CadenzaService.serviceRegistry.serviceName
|
|
13378
14156
|
// JWT token...
|
|
13379
14157
|
}
|
|
13380
|
-
},
|
|
14158
|
+
}, 50);
|
|
13381
14159
|
return true;
|
|
13382
14160
|
},
|
|
13383
14161
|
"Prepares handshake"
|
|
@@ -13431,6 +14209,7 @@ var RestController = class _RestController {
|
|
|
13431
14209
|
serviceName,
|
|
13432
14210
|
url,
|
|
13433
14211
|
connected: false,
|
|
14212
|
+
handshakeInFlight: false,
|
|
13434
14213
|
destroyed: false,
|
|
13435
14214
|
lastHandshakeAt: null,
|
|
13436
14215
|
lastHandshakeError: null,
|
|
@@ -14868,8 +15647,8 @@ var SocketController = class _SocketController {
|
|
|
14868
15647
|
}
|
|
14869
15648
|
const routedDelegateCtx = stripTransportSelectionRoutingContext(delegateCtx);
|
|
14870
15649
|
const normalizedDelegateCtx = ensureDelegationContextMetadata(
|
|
14871
|
-
|
|
14872
|
-
|
|
15650
|
+
restoreDelegationRequestSnapshot(
|
|
15651
|
+
attachDelegationRequestSnapshot(routedDelegateCtx)
|
|
14873
15652
|
)
|
|
14874
15653
|
);
|
|
14875
15654
|
delete normalizedDelegateCtx.__isSubMeta;
|
|
@@ -14942,13 +15721,11 @@ var SocketController = class _SocketController {
|
|
|
14942
15721
|
return resolvedResultContext;
|
|
14943
15722
|
} catch (error) {
|
|
14944
15723
|
const message = error instanceof Error ? error.message : String(error);
|
|
14945
|
-
const failedContext =
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
...normalizedDelegateCtx.__metadata
|
|
14951
|
-
};
|
|
15724
|
+
const failedContext = buildDelegationFailureContext(
|
|
15725
|
+
"meta.socket_client.delegate_failed",
|
|
15726
|
+
normalizedDelegateCtx,
|
|
15727
|
+
error
|
|
15728
|
+
);
|
|
14952
15729
|
if (deputyExecId) {
|
|
14953
15730
|
emitter(`meta.socket_client.delegated:${deputyExecId}`, {
|
|
14954
15731
|
...failedContext,
|
|
@@ -15957,6 +16734,51 @@ import { META_ACTOR_SESSION_STATE_PERSIST_INTENT } from "@cadenza.io/core";
|
|
|
15957
16734
|
var ACTOR_SESSION_STATE_PERSIST_CONCURRENCY = 20;
|
|
15958
16735
|
var META_ACTOR_SESSION_STATE_HYDRATE_INTENT = "meta-actor-session-state-hydrate";
|
|
15959
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
|
+
}
|
|
15960
16782
|
function shouldAssumeSuccessfulActorSessionRowCount(ctx) {
|
|
15961
16783
|
return ctx.__success === true && ctx.rowCount === void 0 && ctx.__status === "success" && ctx.__serviceName === "CadenzaDB" && ctx.__localTaskName === "Insert actor_session_state in CadenzaDB";
|
|
15962
16784
|
}
|
|
@@ -16029,7 +16851,7 @@ function registerActorSessionPersistenceTasks() {
|
|
|
16029
16851
|
)
|
|
16030
16852
|
);
|
|
16031
16853
|
}
|
|
16032
|
-
const row =
|
|
16854
|
+
const row = resolveActorSessionStateRow(ctx);
|
|
16033
16855
|
if (!row) {
|
|
16034
16856
|
return {
|
|
16035
16857
|
__success: true,
|
|
@@ -16436,16 +17258,20 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
16436
17258
|
ctx,
|
|
16437
17259
|
queryData
|
|
16438
17260
|
);
|
|
16439
|
-
|
|
16440
|
-
|
|
16441
|
-
|
|
16442
|
-
|
|
16443
|
-
|
|
16444
|
-
|
|
16445
|
-
|
|
16446
|
-
|
|
16447
|
-
|
|
16448
|
-
|
|
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
|
+
});
|
|
16449
17275
|
}
|
|
16450
17276
|
return buildSyncExecutionEnvelope(
|
|
16451
17277
|
ctx,
|
|
@@ -16536,7 +17362,7 @@ function isBootstrapLocalOnlyActorName(actorName) {
|
|
|
16536
17362
|
return BOOTSTRAP_LOCAL_ONLY_ACTOR_NAMES.has(actorName);
|
|
16537
17363
|
}
|
|
16538
17364
|
function isBootstrapLocalOnlySignal(signalName) {
|
|
16539
|
-
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);
|
|
16540
17366
|
}
|
|
16541
17367
|
function hasNonZeroPending(summary) {
|
|
16542
17368
|
return Object.values(summary).some((value) => Number(value) > 0);
|
|
@@ -16764,6 +17590,12 @@ function resolveLocalRoutineFromSyncContext(ctx) {
|
|
|
16764
17590
|
);
|
|
16765
17591
|
return routineName ? CadenzaService.getRoutine(routineName) : void 0;
|
|
16766
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
|
+
}
|
|
16767
17599
|
function resolveSignalNameFromSyncContext(ctx) {
|
|
16768
17600
|
const candidateSignalNames = [
|
|
16769
17601
|
ctx.signalName,
|
|
@@ -17840,7 +18672,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
17840
18672
|
return;
|
|
17841
18673
|
}
|
|
17842
18674
|
for (const t of task.nextTasks) {
|
|
17843
|
-
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)) {
|
|
17844
18676
|
continue;
|
|
17845
18677
|
}
|
|
17846
18678
|
const serviceName2 = resolveSyncServiceName(t);
|
|
@@ -17908,7 +18740,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
17908
18740
|
return false;
|
|
17909
18741
|
}
|
|
17910
18742
|
for (const nextTask of task.nextTasks) {
|
|
17911
|
-
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)) {
|
|
17912
18744
|
continue;
|
|
17913
18745
|
}
|
|
17914
18746
|
if (resolveSyncServiceName(nextTask)) {
|
|
@@ -20206,6 +21038,15 @@ var DEFAULT_DEPUTY_TASK_CONCURRENCY = 50;
|
|
|
20206
21038
|
var DEFAULT_DEPUTY_TASK_TIMEOUT_MS = 12e4;
|
|
20207
21039
|
var DEFAULT_DATABASE_PROXY_TASK_CONCURRENCY = 50;
|
|
20208
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
|
+
}
|
|
20209
21050
|
var CadenzaService = class {
|
|
20210
21051
|
static unregisterGracefulShutdownHandlers() {
|
|
20211
21052
|
for (const cleanup of this.shutdownHandlerCleanup) {
|
|
@@ -20332,7 +21173,15 @@ var CadenzaService = class {
|
|
|
20332
21173
|
this.replayRegisteredTaskSignalObservations();
|
|
20333
21174
|
this.replayRegisteredTaskIntentAssociations();
|
|
20334
21175
|
}
|
|
20335
|
-
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") {
|
|
20336
21185
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
20337
21186
|
return;
|
|
20338
21187
|
}
|
|
@@ -20340,7 +21189,8 @@ var CadenzaService = class {
|
|
|
20340
21189
|
const payload = {
|
|
20341
21190
|
__reason: reason,
|
|
20342
21191
|
__serviceName: this.serviceRegistry.serviceName,
|
|
20343
|
-
__serviceInstanceId: this.serviceRegistry.serviceInstanceId
|
|
21192
|
+
__serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
21193
|
+
__publicationLayer: targetLayer
|
|
20344
21194
|
};
|
|
20345
21195
|
if (immediate) {
|
|
20346
21196
|
this.emit(signalName, payload);
|
|
@@ -20348,32 +21198,53 @@ var CadenzaService = class {
|
|
|
20348
21198
|
}
|
|
20349
21199
|
this.debounce(signalName, payload, 100);
|
|
20350
21200
|
}
|
|
20351
|
-
static scheduleServiceManifestPublicationRetry(reason) {
|
|
21201
|
+
static scheduleServiceManifestPublicationRetry(reason, targetLayer = "business_structural") {
|
|
20352
21202
|
if (!this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
20353
21203
|
return;
|
|
20354
21204
|
}
|
|
20355
21205
|
setTimeout(() => {
|
|
20356
|
-
this.requestServiceManifestPublication(reason, false);
|
|
21206
|
+
this.requestServiceManifestPublication(reason, false, targetLayer);
|
|
20357
21207
|
}, 1e3);
|
|
20358
21208
|
}
|
|
20359
|
-
static async publishServiceManifestIfNeeded(reason) {
|
|
21209
|
+
static async publishServiceManifestIfNeeded(reason, targetLayer = "business_structural") {
|
|
20360
21210
|
if (!this.serviceRegistry.connectsToCadenzaDB || !this.serviceRegistry.serviceName || !this.serviceRegistry.serviceInstanceId) {
|
|
20361
21211
|
return false;
|
|
20362
21212
|
}
|
|
20363
21213
|
const publishReason = typeof reason === "string" && reason.trim().length > 0 ? reason.trim() : "service_manifest_publish";
|
|
21214
|
+
const publishTargetLayer = this.normalizeServiceManifestPublicationLayer(
|
|
21215
|
+
targetLayer
|
|
21216
|
+
);
|
|
20364
21217
|
if (this.serviceManifestPublicationInFlight) {
|
|
20365
|
-
this.
|
|
21218
|
+
this.mergeServiceManifestPublicationRequest(
|
|
21219
|
+
publishReason,
|
|
21220
|
+
publishTargetLayer
|
|
21221
|
+
);
|
|
20366
21222
|
return false;
|
|
20367
21223
|
}
|
|
20368
|
-
const
|
|
20369
|
-
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
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
|
+
};
|
|
20373
21239
|
});
|
|
20374
|
-
|
|
21240
|
+
const nextPublication = publicationPlan.find((entry) => entry.changed);
|
|
21241
|
+
if (!nextPublication) {
|
|
20375
21242
|
return false;
|
|
20376
21243
|
}
|
|
21244
|
+
const { layer: publicationLayer, snapshot } = nextPublication;
|
|
21245
|
+
const hasPendingFollowupLayer = publicationPlan.some(
|
|
21246
|
+
(entry) => entry.changed && getServiceManifestPublicationLayerRank(entry.layer) > getServiceManifestPublicationLayerRank(publicationLayer)
|
|
21247
|
+
);
|
|
20377
21248
|
this.serviceManifestPublicationInFlight = true;
|
|
20378
21249
|
try {
|
|
20379
21250
|
this.serviceRegistry.ensureBootstrapAuthorityControlPlaneForInquiry(
|
|
@@ -20381,7 +21252,10 @@ var CadenzaService = class {
|
|
|
20381
21252
|
snapshot
|
|
20382
21253
|
);
|
|
20383
21254
|
if (!this.serviceRegistry.hasAuthorityBootstrapHandshakeEstablished()) {
|
|
20384
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
21255
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
21256
|
+
publishReason,
|
|
21257
|
+
publishTargetLayer
|
|
21258
|
+
);
|
|
20385
21259
|
return false;
|
|
20386
21260
|
}
|
|
20387
21261
|
await this.inquire(AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT, snapshot, {
|
|
@@ -20389,32 +21263,48 @@ var CadenzaService = class {
|
|
|
20389
21263
|
requireComplete: true
|
|
20390
21264
|
});
|
|
20391
21265
|
this.serviceManifestRevision = snapshot.revision;
|
|
20392
|
-
this.
|
|
21266
|
+
this.lastPublishedServiceManifestHashes[publicationLayer] = snapshot.manifestHash;
|
|
21267
|
+
if (hasPendingFollowupLayer) {
|
|
21268
|
+
this.mergeServiceManifestPublicationRequest(
|
|
21269
|
+
publishReason,
|
|
21270
|
+
publishTargetLayer
|
|
21271
|
+
);
|
|
21272
|
+
}
|
|
20393
21273
|
return {
|
|
20394
21274
|
serviceManifest: snapshot,
|
|
20395
|
-
published: true
|
|
21275
|
+
published: true,
|
|
21276
|
+
publicationLayer
|
|
20396
21277
|
};
|
|
20397
21278
|
} catch (error) {
|
|
20398
21279
|
this.log("Service manifest publication failed. Scheduling retry.", {
|
|
20399
21280
|
serviceName: this.serviceRegistry.serviceName,
|
|
20400
21281
|
serviceInstanceId: this.serviceRegistry.serviceInstanceId,
|
|
20401
21282
|
reason: publishReason,
|
|
21283
|
+
publicationLayer,
|
|
20402
21284
|
error: resolveInquiryFailureError(
|
|
20403
21285
|
AUTHORITY_SERVICE_MANIFEST_REPORT_INTENT,
|
|
20404
21286
|
error
|
|
20405
21287
|
),
|
|
20406
21288
|
inquiryMeta: error && typeof error === "object" && "__inquiryMeta" in error ? error.__inquiryMeta : null
|
|
20407
21289
|
});
|
|
20408
|
-
this.scheduleServiceManifestPublicationRetry(
|
|
21290
|
+
this.scheduleServiceManifestPublicationRetry(
|
|
21291
|
+
publishReason,
|
|
21292
|
+
publishTargetLayer
|
|
21293
|
+
);
|
|
20409
21294
|
return false;
|
|
20410
21295
|
} finally {
|
|
20411
21296
|
this.serviceManifestPublicationInFlight = false;
|
|
20412
|
-
if (this.serviceManifestPublicationPendingReason) {
|
|
21297
|
+
if (this.serviceManifestPublicationPendingReason && this.serviceManifestPublicationPendingLayer) {
|
|
20413
21298
|
const pendingReason = this.serviceManifestPublicationPendingReason;
|
|
21299
|
+
const pendingLayer = this.serviceManifestPublicationPendingLayer;
|
|
20414
21300
|
this.serviceManifestPublicationPendingReason = null;
|
|
21301
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
20415
21302
|
this.debounce(
|
|
20416
21303
|
"meta.service_manifest.publish_requested",
|
|
20417
|
-
{
|
|
21304
|
+
{
|
|
21305
|
+
__reason: pendingReason,
|
|
21306
|
+
__publicationLayer: pendingLayer
|
|
21307
|
+
},
|
|
20418
21308
|
100
|
|
20419
21309
|
);
|
|
20420
21310
|
}
|
|
@@ -20427,9 +21317,13 @@ var CadenzaService = class {
|
|
|
20427
21317
|
this.createMetaTask(
|
|
20428
21318
|
"Publish service manifest",
|
|
20429
21319
|
async (ctx) => this.publishServiceManifestIfNeeded(
|
|
20430
|
-
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
|
+
)
|
|
20431
21325
|
),
|
|
20432
|
-
"Publishes
|
|
21326
|
+
"Publishes staged static manifest snapshots to authority when the manifest hash changes.",
|
|
20433
21327
|
{
|
|
20434
21328
|
register: false,
|
|
20435
21329
|
isHidden: true
|
|
@@ -20439,13 +21333,18 @@ var CadenzaService = class {
|
|
|
20439
21333
|
"Request manifest publication after structural change",
|
|
20440
21334
|
(ctx) => {
|
|
20441
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
|
+
);
|
|
20442
21340
|
this.requestServiceManifestPublication(
|
|
20443
21341
|
reason,
|
|
20444
|
-
reason === "meta.service_registry.instance_inserted"
|
|
21342
|
+
reason === "meta.service_registry.instance_inserted",
|
|
21343
|
+
targetLayer
|
|
20445
21344
|
);
|
|
20446
21345
|
return true;
|
|
20447
21346
|
},
|
|
20448
|
-
"Requests
|
|
21347
|
+
"Requests staged manifest publication when a static service primitive changes.",
|
|
20449
21348
|
{
|
|
20450
21349
|
register: false,
|
|
20451
21350
|
isHidden: true
|
|
@@ -21700,10 +22599,28 @@ var CadenzaService = class {
|
|
|
21700
22599
|
__isFrontend: isFrontend,
|
|
21701
22600
|
__declaredTransports: declaredTransports
|
|
21702
22601
|
};
|
|
22602
|
+
let bootstrapServiceCreationRequested = false;
|
|
21703
22603
|
if (options.cadenzaDB?.connect) {
|
|
21704
|
-
this.
|
|
21705
|
-
|
|
21706
|
-
|
|
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");
|
|
21707
22624
|
} else {
|
|
21708
22625
|
this.emit("meta.create_service_requested", initContext);
|
|
21709
22626
|
this.createMetaTask("Create signal transmission for sync", (ctx, emit2) => {
|
|
@@ -21716,10 +22633,33 @@ var CadenzaService = class {
|
|
|
21716
22633
|
);
|
|
21717
22634
|
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
21718
22635
|
}
|
|
22636
|
+
let serviceSetupCompletedHandled = false;
|
|
21719
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;
|
|
21720
22657
|
if (options.cadenzaDB?.connect) {
|
|
21721
22658
|
this.serviceRegistry.bootstrapFullSync(emit2, ctx, "service_setup_completed");
|
|
21722
|
-
void this.publishServiceManifestIfNeeded(
|
|
22659
|
+
void this.publishServiceManifestIfNeeded(
|
|
22660
|
+
"service_setup_completed",
|
|
22661
|
+
"business_structural"
|
|
22662
|
+
);
|
|
21723
22663
|
}
|
|
21724
22664
|
if (isFrontend) {
|
|
21725
22665
|
registerActorSessionPersistenceTasks();
|
|
@@ -21774,7 +22714,11 @@ var CadenzaService = class {
|
|
|
21774
22714
|
);
|
|
21775
22715
|
}
|
|
21776
22716
|
this.serviceCreated = true;
|
|
21777
|
-
this.requestServiceManifestPublication(
|
|
22717
|
+
this.requestServiceManifestPublication(
|
|
22718
|
+
"service_created",
|
|
22719
|
+
true,
|
|
22720
|
+
"routing_capability"
|
|
22721
|
+
);
|
|
21778
22722
|
}
|
|
21779
22723
|
/**
|
|
21780
22724
|
* Creates a Cadenza metadata service with the specified name, description, and options.
|
|
@@ -22530,6 +23474,11 @@ var CadenzaService = class {
|
|
|
22530
23474
|
this.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
22531
23475
|
this.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
22532
23476
|
this.frontendSyncScheduled = false;
|
|
23477
|
+
this.serviceManifestRevision = 0;
|
|
23478
|
+
this.lastPublishedServiceManifestHashes = {};
|
|
23479
|
+
this.serviceManifestPublicationInFlight = false;
|
|
23480
|
+
this.serviceManifestPublicationPendingReason = null;
|
|
23481
|
+
this.serviceManifestPublicationPendingLayer = null;
|
|
22533
23482
|
resetBrowserRuntimeActorHandles();
|
|
22534
23483
|
}
|
|
22535
23484
|
};
|
|
@@ -22543,9 +23492,10 @@ CadenzaService.warnedInvalidMetaIntentResponderKeys = /* @__PURE__ */ new Set();
|
|
|
22543
23492
|
CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
22544
23493
|
CadenzaService.frontendSyncScheduled = false;
|
|
22545
23494
|
CadenzaService.serviceManifestRevision = 0;
|
|
22546
|
-
CadenzaService.
|
|
23495
|
+
CadenzaService.lastPublishedServiceManifestHashes = {};
|
|
22547
23496
|
CadenzaService.serviceManifestPublicationInFlight = false;
|
|
22548
23497
|
CadenzaService.serviceManifestPublicationPendingReason = null;
|
|
23498
|
+
CadenzaService.serviceManifestPublicationPendingLayer = null;
|
|
22549
23499
|
CadenzaService.shutdownHandlersRegistered = false;
|
|
22550
23500
|
CadenzaService.shutdownInFlight = false;
|
|
22551
23501
|
CadenzaService.shutdownHandlerCleanup = [];
|
|
@@ -22579,6 +23529,17 @@ function normalizeArrayResponse(value, keys) {
|
|
|
22579
23529
|
if (Array.isArray(value?.data)) {
|
|
22580
23530
|
return value.data;
|
|
22581
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
|
+
}
|
|
22582
23543
|
return [];
|
|
22583
23544
|
}
|
|
22584
23545
|
function buildQueryResponseKeys(tableName) {
|