@cadenza.io/service 2.17.33 → 2.17.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +390 -135
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +347 -93
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +399 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +356 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -30,27 +30,27 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
Actor: () =>
|
|
33
|
+
Actor: () => import_core6.Actor,
|
|
34
34
|
DatabaseController: () => DatabaseController,
|
|
35
35
|
DatabaseTask: () => DatabaseTask,
|
|
36
|
-
DebounceTask: () =>
|
|
36
|
+
DebounceTask: () => import_core6.DebounceTask,
|
|
37
37
|
DeputyTask: () => DeputyTask,
|
|
38
|
-
EphemeralTask: () =>
|
|
38
|
+
EphemeralTask: () => import_core6.EphemeralTask,
|
|
39
39
|
GraphMetadataController: () => GraphMetadataController,
|
|
40
|
-
GraphRoutine: () =>
|
|
40
|
+
GraphRoutine: () => import_core6.GraphRoutine,
|
|
41
41
|
RestController: () => RestController,
|
|
42
42
|
ServiceRegistry: () => ServiceRegistry,
|
|
43
43
|
SignalController: () => SignalController,
|
|
44
44
|
SignalTransmissionTask: () => SignalTransmissionTask,
|
|
45
45
|
SocketController: () => SocketController,
|
|
46
|
-
Task: () =>
|
|
46
|
+
Task: () => import_core6.Task,
|
|
47
47
|
createSSRInquiryBridge: () => createSSRInquiryBridge,
|
|
48
48
|
default: () => index_default
|
|
49
49
|
});
|
|
50
50
|
module.exports = __toCommonJS(index_exports);
|
|
51
51
|
|
|
52
52
|
// src/Cadenza.ts
|
|
53
|
-
var
|
|
53
|
+
var import_core5 = __toESM(require("@cadenza.io/core"));
|
|
54
54
|
|
|
55
55
|
// src/graph/definition/DeputyTask.ts
|
|
56
56
|
var import_uuid = require("uuid");
|
|
@@ -300,7 +300,7 @@ var DatabaseTask = class extends DeputyTask {
|
|
|
300
300
|
};
|
|
301
301
|
|
|
302
302
|
// src/registry/ServiceRegistry.ts
|
|
303
|
-
var
|
|
303
|
+
var import_uuid3 = require("uuid");
|
|
304
304
|
|
|
305
305
|
// src/utils/environment.ts
|
|
306
306
|
var isNode = typeof process !== "undefined" && process.versions?.node != null;
|
|
@@ -436,16 +436,16 @@ function normalizeServiceTransportConfig(value) {
|
|
|
436
436
|
}
|
|
437
437
|
function normalizeServiceTransportDescriptor(value) {
|
|
438
438
|
const raw = value ?? {};
|
|
439
|
-
const
|
|
439
|
+
const uuid8 = normalizeString(raw.uuid);
|
|
440
440
|
const serviceInstanceId = normalizeString(
|
|
441
441
|
raw.serviceInstanceId ?? raw.service_instance_id
|
|
442
442
|
);
|
|
443
443
|
const config = normalizeServiceTransportConfig(raw);
|
|
444
|
-
if (!
|
|
444
|
+
if (!uuid8 || !serviceInstanceId || !config) {
|
|
445
445
|
return null;
|
|
446
446
|
}
|
|
447
447
|
return {
|
|
448
|
-
uuid:
|
|
448
|
+
uuid: uuid8,
|
|
449
449
|
serviceInstanceId,
|
|
450
450
|
role: config.role,
|
|
451
451
|
origin: config.origin,
|
|
@@ -507,14 +507,14 @@ function normalizeTransportArray(value, serviceInstanceId) {
|
|
|
507
507
|
}
|
|
508
508
|
function normalizeServiceInstanceDescriptor(value) {
|
|
509
509
|
const raw = value ?? {};
|
|
510
|
-
const
|
|
510
|
+
const uuid8 = normalizeString2(raw.uuid);
|
|
511
511
|
const serviceName = normalizeString2(raw.serviceName ?? raw.service_name);
|
|
512
|
-
if (!
|
|
512
|
+
if (!uuid8 || !serviceName) {
|
|
513
513
|
return null;
|
|
514
514
|
}
|
|
515
|
-
const transports = normalizeTransportArray(raw.transports,
|
|
515
|
+
const transports = normalizeTransportArray(raw.transports, uuid8);
|
|
516
516
|
return {
|
|
517
|
-
uuid:
|
|
517
|
+
uuid: uuid8,
|
|
518
518
|
serviceName,
|
|
519
519
|
numberOfRunningGraphs: Math.max(
|
|
520
520
|
0,
|
|
@@ -774,6 +774,8 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
774
774
|
return rawResult;
|
|
775
775
|
}
|
|
776
776
|
const result = { ...rawResult };
|
|
777
|
+
delete result.__resolverOriginalContext;
|
|
778
|
+
delete result.__resolverQueryData;
|
|
777
779
|
const normalizedQueryData = result.queryData && typeof result.queryData === "object" ? { ...result.queryData } : { ...queryData };
|
|
778
780
|
const resolvedData = result.data ?? normalizedQueryData.data ?? queryData.data ?? ctx.data ?? ctx.__registrationData;
|
|
779
781
|
if (resolvedData !== void 0 && result.data === void 0) {
|
|
@@ -813,49 +815,105 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
813
815
|
queryData,
|
|
814
816
|
options
|
|
815
817
|
);
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
818
|
+
const localExecutionRequestedSignal = `meta.service_registry.insert_execution_requested:${tableName}:local`;
|
|
819
|
+
const remoteExecutionRequestedSignal = `meta.service_registry.insert_execution_requested:${tableName}:remote`;
|
|
820
|
+
const executionResolvedSignal = `meta.service_registry.insert_execution_resolved:${tableName}`;
|
|
821
|
+
const executionFailedSignal = `meta.service_registry.insert_execution_failed:${tableName}`;
|
|
822
|
+
const createPrepareExecutionTask = (signalName) => CadenzaService.createMetaTask(
|
|
823
|
+
`Prepare service registry insert execution for ${tableName} (${signalName})`,
|
|
824
|
+
(ctx) => {
|
|
819
825
|
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
820
|
-
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
821
|
-
CadenzaService.log(
|
|
822
|
-
"Service registry insert resolver missing service payload.",
|
|
823
|
-
{
|
|
824
|
-
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
825
|
-
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
826
|
-
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
827
|
-
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
828
|
-
},
|
|
829
|
-
"warning"
|
|
830
|
-
);
|
|
831
|
-
}
|
|
832
|
-
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
833
826
|
const delegationContext = ensureDelegationContextMetadata({
|
|
834
827
|
...ctx,
|
|
835
828
|
queryData: nextQueryData
|
|
836
829
|
});
|
|
837
830
|
delegationContext.__metadata.__skipRemoteExecution = delegationContext.__metadata.__skipRemoteExecution ?? delegationContext.__skipRemoteExecution ?? false;
|
|
838
831
|
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
839
|
-
return
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
832
|
+
return {
|
|
833
|
+
...delegationContext,
|
|
834
|
+
__resolverOriginalContext: {
|
|
835
|
+
...ctx
|
|
836
|
+
},
|
|
837
|
+
__resolverQueryData: nextQueryData
|
|
838
|
+
};
|
|
839
|
+
},
|
|
840
|
+
`Prepares ${tableName} service-registry insert payloads for runner execution.`,
|
|
841
|
+
{
|
|
842
|
+
register: false,
|
|
843
|
+
isHidden: true
|
|
844
|
+
}
|
|
845
|
+
).doOn(signalName).emitsOnFail(executionFailedSignal);
|
|
846
|
+
const prepareLocalExecutionTask = createPrepareExecutionTask(
|
|
847
|
+
localExecutionRequestedSignal
|
|
848
|
+
);
|
|
849
|
+
const prepareRemoteExecutionTask = createPrepareExecutionTask(
|
|
850
|
+
remoteExecutionRequestedSignal
|
|
851
|
+
);
|
|
852
|
+
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
853
|
+
`Finalize service registry insert execution for ${tableName}`,
|
|
854
|
+
(ctx, emit) => {
|
|
855
|
+
if (!ctx.__resolverRequestId) {
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
858
|
+
const normalized = normalizeServiceRegistryInsertResult(
|
|
859
|
+
tableName,
|
|
860
|
+
ctx.__resolverOriginalContext ?? ctx,
|
|
861
|
+
ctx.__resolverQueryData ?? ctx.queryData ?? {},
|
|
862
|
+
ctx
|
|
857
863
|
);
|
|
864
|
+
if (!normalized || typeof normalized !== "object") {
|
|
865
|
+
return normalized;
|
|
866
|
+
}
|
|
867
|
+
emit(executionResolvedSignal, normalized);
|
|
868
|
+
return normalized;
|
|
858
869
|
},
|
|
870
|
+
`Normalizes ${tableName} service-registry insert results for resolver callers.`,
|
|
871
|
+
{
|
|
872
|
+
register: false,
|
|
873
|
+
isHidden: true
|
|
874
|
+
}
|
|
875
|
+
);
|
|
876
|
+
const wiredLocalTaskNames = /* @__PURE__ */ new Set();
|
|
877
|
+
const wireExecutionTarget = (targetTask, prepareTask) => {
|
|
878
|
+
targetTask.then(finalizeExecutionTask).emitsOnFail(executionFailedSignal);
|
|
879
|
+
prepareTask.then(targetTask);
|
|
880
|
+
};
|
|
881
|
+
wireExecutionTarget(remoteInsertTask, prepareRemoteExecutionTask);
|
|
882
|
+
return CadenzaService.createUniqueMetaTask(
|
|
883
|
+
`Resolve service registry insert for ${tableName}`,
|
|
884
|
+
(ctx, emit) => new Promise((resolve) => {
|
|
885
|
+
const resolverRequestId = (0, import_uuid3.v4)();
|
|
886
|
+
CadenzaService.createEphemeralMetaTask(
|
|
887
|
+
`Resolve service registry insert execution for ${tableName} (${resolverRequestId})`,
|
|
888
|
+
(resultCtx) => {
|
|
889
|
+
if (resultCtx.__resolverRequestId !== resolverRequestId) {
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
const normalizedResult = {
|
|
893
|
+
...resultCtx
|
|
894
|
+
};
|
|
895
|
+
delete normalizedResult.__resolverRequestId;
|
|
896
|
+
delete normalizedResult.__resolverOriginalContext;
|
|
897
|
+
delete normalizedResult.__resolverQueryData;
|
|
898
|
+
resolve(normalizedResult);
|
|
899
|
+
return normalizedResult;
|
|
900
|
+
},
|
|
901
|
+
`Resolves signal-driven ${tableName} service-registry insert execution.`,
|
|
902
|
+
{
|
|
903
|
+
register: false
|
|
904
|
+
}
|
|
905
|
+
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
906
|
+
const localInsertTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName);
|
|
907
|
+
const executionSignal = localInsertTask ? localExecutionRequestedSignal : remoteExecutionRequestedSignal;
|
|
908
|
+
if (localInsertTask && !wiredLocalTaskNames.has(localInsertTask.name)) {
|
|
909
|
+
wireExecutionTarget(localInsertTask, prepareLocalExecutionTask);
|
|
910
|
+
wiredLocalTaskNames.add(localInsertTask.name);
|
|
911
|
+
}
|
|
912
|
+
emit(executionSignal, {
|
|
913
|
+
...ctx,
|
|
914
|
+
__resolverRequestId: resolverRequestId
|
|
915
|
+
});
|
|
916
|
+
}),
|
|
859
917
|
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
860
918
|
options
|
|
861
919
|
);
|
|
@@ -1093,15 +1151,15 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1093
1151
|
if (!serviceInstance) {
|
|
1094
1152
|
return false;
|
|
1095
1153
|
}
|
|
1096
|
-
const
|
|
1154
|
+
const uuid8 = serviceInstance.uuid;
|
|
1097
1155
|
const serviceName = serviceInstance.serviceName;
|
|
1098
1156
|
const deleted = Boolean(
|
|
1099
1157
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
1100
1158
|
);
|
|
1101
|
-
if (
|
|
1159
|
+
if (uuid8 === this.serviceInstanceId) return;
|
|
1102
1160
|
if (deleted) {
|
|
1103
|
-
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid ===
|
|
1104
|
-
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid ===
|
|
1161
|
+
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid8);
|
|
1162
|
+
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid8) ?? -1;
|
|
1105
1163
|
if (indexToDelete >= 0 && existingInstance) {
|
|
1106
1164
|
this.instances.get(serviceName)?.splice(indexToDelete, 1);
|
|
1107
1165
|
for (const transport of existingInstance.transports) {
|
|
@@ -1113,13 +1171,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1113
1171
|
if (this.instances.get(serviceName)?.length === 0) {
|
|
1114
1172
|
this.instances.delete(serviceName);
|
|
1115
1173
|
}
|
|
1116
|
-
this.unregisterDependee(
|
|
1174
|
+
this.unregisterDependee(uuid8, serviceName);
|
|
1117
1175
|
return;
|
|
1118
1176
|
}
|
|
1119
1177
|
if (!this.instances.has(serviceName))
|
|
1120
1178
|
this.instances.set(serviceName, []);
|
|
1121
1179
|
const instances = this.instances.get(serviceName);
|
|
1122
|
-
const existing = instances.find((i) => i.uuid ===
|
|
1180
|
+
const existing = instances.find((i) => i.uuid === uuid8);
|
|
1123
1181
|
if (existing) {
|
|
1124
1182
|
Object.assign(existing, {
|
|
1125
1183
|
...serviceInstance,
|
|
@@ -1129,7 +1187,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1129
1187
|
} else {
|
|
1130
1188
|
instances.push(serviceInstance);
|
|
1131
1189
|
}
|
|
1132
|
-
const trackedInstance = existing ?? instances.find((instance) => instance.uuid ===
|
|
1190
|
+
const trackedInstance = existing ?? instances.find((instance) => instance.uuid === uuid8);
|
|
1133
1191
|
if (trackedInstance) {
|
|
1134
1192
|
const snapshot = this.resolveRuntimeStatusSnapshot(
|
|
1135
1193
|
trackedInstance.numberOfRunningGraphs ?? 0,
|
|
@@ -1142,16 +1200,19 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1142
1200
|
trackedInstance.reportedAt = trackedInstance.reportedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1143
1201
|
}
|
|
1144
1202
|
if (!serviceInstance.isBootstrapPlaceholder) {
|
|
1145
|
-
this.reconcileBootstrapPlaceholderInstance(serviceName,
|
|
1203
|
+
this.reconcileBootstrapPlaceholderInstance(serviceName, uuid8, emit);
|
|
1146
1204
|
}
|
|
1147
1205
|
if (this.serviceName === serviceName) {
|
|
1148
1206
|
return false;
|
|
1149
1207
|
}
|
|
1208
|
+
if (trackedInstance?.isFrontend) {
|
|
1209
|
+
return true;
|
|
1210
|
+
}
|
|
1150
1211
|
const trackedTransport = this.getRouteableTransport(
|
|
1151
1212
|
trackedInstance,
|
|
1152
1213
|
this.useSocket ? "socket" : "rest"
|
|
1153
1214
|
);
|
|
1154
|
-
if (
|
|
1215
|
+
if (this.deputies.has(serviceName) || this.remoteIntents.has(serviceName) || this.remoteSignals.has(serviceName)) {
|
|
1155
1216
|
const communicationTypes = Array.from(
|
|
1156
1217
|
new Set(
|
|
1157
1218
|
this.deputies.get(serviceName)?.map((d) => d.communicationType) ?? []
|
|
@@ -1168,7 +1229,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1168
1229
|
if (!clientCreated) {
|
|
1169
1230
|
emit("meta.service_registry.dependee_registered", {
|
|
1170
1231
|
serviceName,
|
|
1171
|
-
serviceInstanceId:
|
|
1232
|
+
serviceInstanceId: uuid8,
|
|
1172
1233
|
serviceTransportId: trackedTransport.uuid,
|
|
1173
1234
|
serviceOrigin: trackedTransport.origin,
|
|
1174
1235
|
transportProtocols: trackedTransport.protocols,
|
|
@@ -1182,7 +1243,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1182
1243
|
} else {
|
|
1183
1244
|
emit("meta.service_registry.routeable_transport_missing", {
|
|
1184
1245
|
serviceName,
|
|
1185
|
-
serviceInstanceId:
|
|
1246
|
+
serviceInstanceId: uuid8,
|
|
1186
1247
|
requiredRole: this.getRoutingTransportRole(),
|
|
1187
1248
|
isFrontend: this.isFrontend
|
|
1188
1249
|
});
|
|
@@ -1241,7 +1302,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1241
1302
|
if (ownerInstance.uuid === this.serviceInstanceId) {
|
|
1242
1303
|
return true;
|
|
1243
1304
|
}
|
|
1244
|
-
const hasRemoteInterest =
|
|
1305
|
+
const hasRemoteInterest = !ownerInstance.isFrontend && (this.deputies.has(ownerInstance.serviceName) || this.remoteIntents.has(ownerInstance.serviceName) || this.remoteSignals.has(ownerInstance.serviceName)) && transport.role === this.getRoutingTransportRole();
|
|
1245
1306
|
if (!hasRemoteInterest) {
|
|
1246
1307
|
return true;
|
|
1247
1308
|
}
|
|
@@ -1656,6 +1717,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1656
1717
|
if (!instance.isActive || instance.isNonResponsive || instance.isBlocked) {
|
|
1657
1718
|
return false;
|
|
1658
1719
|
}
|
|
1720
|
+
if (instance.isFrontend) {
|
|
1721
|
+
return true;
|
|
1722
|
+
}
|
|
1659
1723
|
return Boolean(
|
|
1660
1724
|
this.selectTransportForInstance(instance, context, preferredRole)
|
|
1661
1725
|
);
|
|
@@ -1689,6 +1753,21 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1689
1753
|
}
|
|
1690
1754
|
if (__broadcast || instances[0].isFrontend) {
|
|
1691
1755
|
for (const instance of instances) {
|
|
1756
|
+
if (instance.isFrontend) {
|
|
1757
|
+
const fetchId = `browser:${instance.uuid}`;
|
|
1758
|
+
emit(
|
|
1759
|
+
`meta.service_registry.selected_instance_for_socket:${fetchId}`,
|
|
1760
|
+
{
|
|
1761
|
+
...context,
|
|
1762
|
+
__instance: instance.uuid,
|
|
1763
|
+
__transportId: void 0,
|
|
1764
|
+
__transportOrigin: void 0,
|
|
1765
|
+
__transportProtocols: ["socket"],
|
|
1766
|
+
__fetchId: fetchId
|
|
1767
|
+
}
|
|
1768
|
+
);
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1692
1771
|
const selectedTransport2 = this.selectTransportForInstance(
|
|
1693
1772
|
instance,
|
|
1694
1773
|
context,
|
|
@@ -1730,6 +1809,21 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1730
1809
|
if (retries > 0) {
|
|
1731
1810
|
selected = instancesToTry[Math.floor(Math.random() * instancesToTry.length)];
|
|
1732
1811
|
}
|
|
1812
|
+
if (selected.isFrontend) {
|
|
1813
|
+
context.__instance = selected.uuid;
|
|
1814
|
+
context.__transportId = void 0;
|
|
1815
|
+
context.__transportOrigin = void 0;
|
|
1816
|
+
context.__transportProtocols = ["socket"];
|
|
1817
|
+
context.__fetchId = `browser:${selected.uuid}`;
|
|
1818
|
+
context.__triedInstances = triedInstances;
|
|
1819
|
+
context.__triedInstances.push(selected.uuid);
|
|
1820
|
+
context.__retries = retries;
|
|
1821
|
+
emit(
|
|
1822
|
+
`meta.service_registry.selected_instance_for_socket:${context.__fetchId}`,
|
|
1823
|
+
context
|
|
1824
|
+
);
|
|
1825
|
+
return context;
|
|
1826
|
+
}
|
|
1733
1827
|
const selectedTransport = this.selectTransportForInstance(
|
|
1734
1828
|
selected,
|
|
1735
1829
|
context,
|
|
@@ -2386,7 +2480,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2386
2480
|
)
|
|
2387
2481
|
);
|
|
2388
2482
|
for (const service of services) {
|
|
2389
|
-
const instances = this.instances.get(service).filter((i) => i.isActive);
|
|
2483
|
+
const instances = this.instances.get(service).filter((i) => i.isActive && !i.isFrontend);
|
|
2390
2484
|
for (const instance of instances) {
|
|
2391
2485
|
const transport = this.getRouteableTransport(
|
|
2392
2486
|
instance,
|
|
@@ -3438,9 +3532,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3438
3532
|
};
|
|
3439
3533
|
|
|
3440
3534
|
// src/graph/definition/SignalTransmissionTask.ts
|
|
3441
|
-
var
|
|
3442
|
-
var
|
|
3443
|
-
var SignalTransmissionTask = class extends
|
|
3535
|
+
var import_core2 = require("@cadenza.io/core");
|
|
3536
|
+
var import_uuid4 = require("uuid");
|
|
3537
|
+
var SignalTransmissionTask = class extends import_core2.Task {
|
|
3444
3538
|
/**
|
|
3445
3539
|
* Constructs a new instance of the class and initializes it with the provided parameters.
|
|
3446
3540
|
*
|
|
@@ -3468,7 +3562,7 @@ var SignalTransmissionTask = class extends import_core3.Task {
|
|
|
3468
3562
|
*/
|
|
3469
3563
|
constructor(name, signalName, serviceName, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = true, isSubMeta = false, isHidden = false, getTagCallback = void 0, inputSchema = void 0, validateInputContext = false, outputSchema = void 0, validateOutputContext = false, retryCount = 0, retryDelay = 0, retryDelayMax = 0, retryDelayFactor = 1) {
|
|
3470
3564
|
const taskFunction = (context) => {
|
|
3471
|
-
context.__routineExecId = (0,
|
|
3565
|
+
context.__routineExecId = (0, import_uuid4.v4)();
|
|
3472
3566
|
return context;
|
|
3473
3567
|
};
|
|
3474
3568
|
super(
|
|
@@ -4105,6 +4199,35 @@ var SocketController = class _SocketController {
|
|
|
4105
4199
|
},
|
|
4106
4200
|
{ isMeta: true }
|
|
4107
4201
|
);
|
|
4202
|
+
CadenzaService.registry.getTaskByName.doOn("meta.socket.delegation_requested");
|
|
4203
|
+
CadenzaService.registry.getRoutineByName.doOn("meta.socket.delegation_requested");
|
|
4204
|
+
CadenzaService.createMetaTask(
|
|
4205
|
+
"Forward socket delegations to runner",
|
|
4206
|
+
(context, emit) => {
|
|
4207
|
+
if (!isBrowser && !CadenzaService.serviceRegistry.isFrontend) {
|
|
4208
|
+
return false;
|
|
4209
|
+
}
|
|
4210
|
+
if (context.task || context.routine) {
|
|
4211
|
+
const routine = context.task ?? context.routine;
|
|
4212
|
+
delete context.task;
|
|
4213
|
+
delete context.routine;
|
|
4214
|
+
context.__routineExecId = context.__metadata?.__deputyExecId ?? null;
|
|
4215
|
+
context.__isDeputy = true;
|
|
4216
|
+
CadenzaService.runner.run(routine, context);
|
|
4217
|
+
return true;
|
|
4218
|
+
}
|
|
4219
|
+
const deputyExecId = context.__metadata?.__deputyExecId ?? context.__deputyExecId;
|
|
4220
|
+
const remoteRoutineName = context.__remoteRoutineName ?? context.__name ?? "unknown";
|
|
4221
|
+
context.errored = true;
|
|
4222
|
+
context.__error = `No task or routine registered for delegation target ${remoteRoutineName}.`;
|
|
4223
|
+
if (deputyExecId) {
|
|
4224
|
+
emit(`meta.socket.delegation_target_not_found:${deputyExecId}`, context);
|
|
4225
|
+
}
|
|
4226
|
+
emit("meta.runner.failed", context);
|
|
4227
|
+
return false;
|
|
4228
|
+
},
|
|
4229
|
+
"Forwards socket delegated lookups to the local runner in frontend runtimes."
|
|
4230
|
+
).attachSignal("meta.runner.failed").doAfter(CadenzaService.registry.getTaskByName, CadenzaService.registry.getRoutineByName);
|
|
4108
4231
|
this.registerDiagnosticsTasks();
|
|
4109
4232
|
this.registerSocketServerTasks();
|
|
4110
4233
|
this.registerSocketClientTasks();
|
|
@@ -4348,8 +4471,56 @@ var SocketController = class _SocketController {
|
|
|
4348
4471
|
});
|
|
4349
4472
|
if (ctx.isFrontend) {
|
|
4350
4473
|
const fetchId = `browser:${ctx.serviceInstanceId}`;
|
|
4474
|
+
const frontendDelegateTaskName = `Delegate flow to frontend ${fetchId}`;
|
|
4475
|
+
const frontendTransmitTaskName = `Transmit signal to ${fetchId}`;
|
|
4476
|
+
CadenzaService.get(frontendDelegateTaskName)?.destroy();
|
|
4477
|
+
CadenzaService.get(frontendTransmitTaskName)?.destroy();
|
|
4351
4478
|
CadenzaService.createMetaTask(
|
|
4352
|
-
|
|
4479
|
+
frontendDelegateTaskName,
|
|
4480
|
+
async (delegateCtx, emitter) => {
|
|
4481
|
+
if (delegateCtx.__remoteRoutineName === void 0) {
|
|
4482
|
+
return;
|
|
4483
|
+
}
|
|
4484
|
+
const normalizedDelegateCtx = ensureDelegationContextMetadata(delegateCtx);
|
|
4485
|
+
delete normalizedDelegateCtx.__isSubMeta;
|
|
4486
|
+
delete normalizedDelegateCtx.__broadcast;
|
|
4487
|
+
const deputyExecId = normalizedDelegateCtx.__metadata?.__deputyExecId;
|
|
4488
|
+
const resultContext = await new Promise((resolve) => {
|
|
4489
|
+
ws.timeout(normalizedDelegateCtx.__timeout ?? 6e4).emit(
|
|
4490
|
+
"delegation",
|
|
4491
|
+
normalizedDelegateCtx,
|
|
4492
|
+
(err, response) => {
|
|
4493
|
+
if (err) {
|
|
4494
|
+
resolve({
|
|
4495
|
+
...normalizedDelegateCtx,
|
|
4496
|
+
errored: true,
|
|
4497
|
+
__error: `Frontend delegation timed out: ${err.message ?? err}`
|
|
4498
|
+
});
|
|
4499
|
+
return;
|
|
4500
|
+
}
|
|
4501
|
+
resolve(
|
|
4502
|
+
response ?? {
|
|
4503
|
+
errored: true,
|
|
4504
|
+
__error: "Frontend delegation returned no response"
|
|
4505
|
+
}
|
|
4506
|
+
);
|
|
4507
|
+
}
|
|
4508
|
+
);
|
|
4509
|
+
});
|
|
4510
|
+
if (deputyExecId) {
|
|
4511
|
+
const metadata = resultContext.__metadata;
|
|
4512
|
+
delete resultContext.__metadata;
|
|
4513
|
+
emitter(`meta.socket_client.delegated:${deputyExecId}`, {
|
|
4514
|
+
...resultContext,
|
|
4515
|
+
...metadata && typeof metadata === "object" ? metadata : {}
|
|
4516
|
+
});
|
|
4517
|
+
}
|
|
4518
|
+
return resultContext;
|
|
4519
|
+
},
|
|
4520
|
+
"Delegates work to a connected frontend runtime through its active websocket."
|
|
4521
|
+
).doOn(`meta.service_registry.selected_instance_for_socket:${fetchId}`).attachSignal("meta.socket_client.delegated");
|
|
4522
|
+
CadenzaService.createMetaTask(
|
|
4523
|
+
frontendTransmitTaskName,
|
|
4353
4524
|
(c, emitter) => {
|
|
4354
4525
|
if (c.__signalName === void 0) {
|
|
4355
4526
|
return;
|
|
@@ -4814,10 +4985,54 @@ var SocketController = class _SocketController {
|
|
|
4814
4985
|
delegationCtx
|
|
4815
4986
|
);
|
|
4816
4987
|
});
|
|
4817
|
-
socket.on("
|
|
4988
|
+
socket.on("delegation", (delegationCtx, callback) => {
|
|
4989
|
+
const normalizedDelegationCtx = ensureDelegationContextMetadata(delegationCtx);
|
|
4990
|
+
const deputyExecId = normalizedDelegationCtx.__metadata.__deputyExecId;
|
|
4991
|
+
const targetNotFoundSignal = `meta.socket.delegation_target_not_found:${deputyExecId}`;
|
|
4992
|
+
CadenzaService.createEphemeralMetaTask(
|
|
4993
|
+
`Resolve frontend socket delegation ${deputyExecId}`,
|
|
4994
|
+
(completedCtx) => {
|
|
4995
|
+
callback(completedCtx);
|
|
4996
|
+
return completedCtx;
|
|
4997
|
+
},
|
|
4998
|
+
"Resolves a server-routed delegation request through the frontend runtime.",
|
|
4999
|
+
{
|
|
5000
|
+
register: false
|
|
5001
|
+
}
|
|
5002
|
+
).doOn(`meta.node.graph_completed:${deputyExecId}`, targetNotFoundSignal);
|
|
5003
|
+
if (!CadenzaService.get(normalizedDelegationCtx.__remoteRoutineName) && !CadenzaService.registry.routines.get(
|
|
5004
|
+
normalizedDelegationCtx.__remoteRoutineName
|
|
5005
|
+
)) {
|
|
5006
|
+
CadenzaService.emit(targetNotFoundSignal, {
|
|
5007
|
+
...normalizedDelegationCtx,
|
|
5008
|
+
__error: `No task or routine registered for delegation target ${normalizedDelegationCtx.__remoteRoutineName}.`,
|
|
5009
|
+
errored: true
|
|
5010
|
+
});
|
|
5011
|
+
return;
|
|
5012
|
+
}
|
|
5013
|
+
CadenzaService.emit("meta.socket.delegation_requested", {
|
|
5014
|
+
...normalizedDelegationCtx,
|
|
5015
|
+
__name: normalizedDelegationCtx.__remoteRoutineName
|
|
5016
|
+
});
|
|
5017
|
+
});
|
|
5018
|
+
socket.on("signal", (signalCtx, callback) => {
|
|
4818
5019
|
if (CadenzaService.signalBroker.listObservedSignals().includes(signalCtx.__signalName)) {
|
|
5020
|
+
callback?.({
|
|
5021
|
+
__status: "success",
|
|
5022
|
+
__signalName: signalCtx.__signalName
|
|
5023
|
+
});
|
|
4819
5024
|
CadenzaService.emit(signalCtx.__signalName, signalCtx);
|
|
5025
|
+
return;
|
|
4820
5026
|
}
|
|
5027
|
+
callback?.({
|
|
5028
|
+
...signalCtx,
|
|
5029
|
+
__status: "error",
|
|
5030
|
+
__error: `No such signal: ${signalCtx.__signalName}`,
|
|
5031
|
+
errored: true
|
|
5032
|
+
});
|
|
5033
|
+
});
|
|
5034
|
+
socket.on("status_check", (statusCtx, callback) => {
|
|
5035
|
+
callback(CadenzaService.serviceRegistry.resolveLocalStatusCheck(statusCtx));
|
|
4821
5036
|
});
|
|
4822
5037
|
socket.on("status_update", (status) => {
|
|
4823
5038
|
CadenzaService.emit("meta.socket_client.status_received", status);
|
|
@@ -5487,7 +5702,7 @@ var SignalController = class _SignalController {
|
|
|
5487
5702
|
};
|
|
5488
5703
|
|
|
5489
5704
|
// src/graph/controllers/registerActorSessionPersistence.ts
|
|
5490
|
-
var
|
|
5705
|
+
var import_core3 = require("@cadenza.io/core");
|
|
5491
5706
|
function registerActorSessionPersistenceTasks() {
|
|
5492
5707
|
if (CadenzaService.get("Persist actor session state")) {
|
|
5493
5708
|
return;
|
|
@@ -5608,7 +5823,7 @@ function registerActorSessionPersistenceTasks() {
|
|
|
5608
5823
|
},
|
|
5609
5824
|
"Validates and prepares actor_session_state payload for strict write-through persistence.",
|
|
5610
5825
|
{ isSubMeta: true, concurrency: 100 }
|
|
5611
|
-
).then(insertAndValidateActorSessionStateTask).respondsTo(
|
|
5826
|
+
).then(insertAndValidateActorSessionStateTask).respondsTo(import_core3.META_ACTOR_SESSION_STATE_PERSIST_INTENT);
|
|
5612
5827
|
}
|
|
5613
5828
|
|
|
5614
5829
|
// src/graph/controllers/GraphMetadataController.ts
|
|
@@ -5892,10 +6107,11 @@ var DatabaseController = class _DatabaseController {
|
|
|
5892
6107
|
};
|
|
5893
6108
|
|
|
5894
6109
|
// src/Cadenza.ts
|
|
5895
|
-
var
|
|
6110
|
+
var import_uuid6 = require("uuid");
|
|
5896
6111
|
|
|
5897
6112
|
// src/graph/controllers/GraphSyncController.ts
|
|
5898
|
-
var
|
|
6113
|
+
var import_core4 = require("@cadenza.io/core");
|
|
6114
|
+
var import_uuid5 = require("uuid");
|
|
5899
6115
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
5900
6116
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
5901
6117
|
if (typeof taskFunction !== "function") {
|
|
@@ -5961,7 +6177,7 @@ function resolveSyncServiceName(task) {
|
|
|
5961
6177
|
return taskServiceName || registryServiceName || void 0;
|
|
5962
6178
|
}
|
|
5963
6179
|
function isLocalOnlySyncIntent(intentName) {
|
|
5964
|
-
return intentName ===
|
|
6180
|
+
return intentName === import_core4.META_ACTOR_SESSION_STATE_PERSIST_INTENT;
|
|
5965
6181
|
}
|
|
5966
6182
|
function buildIntentRegistryData(intent) {
|
|
5967
6183
|
const name = String(intent?.name ?? "").trim();
|
|
@@ -6029,30 +6245,69 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6029
6245
|
if (!localInsertTask && !remoteInsertTask) {
|
|
6030
6246
|
return void 0;
|
|
6031
6247
|
}
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6248
|
+
const targetTask = localInsertTask ?? remoteInsertTask;
|
|
6249
|
+
const executionRequestedSignal = `meta.sync_controller.insert_execution_requested:${tableName}`;
|
|
6250
|
+
const executionResolvedSignal = `meta.sync_controller.insert_execution_resolved:${tableName}`;
|
|
6251
|
+
const executionFailedSignal = `meta.sync_controller.insert_execution_failed:${tableName}`;
|
|
6252
|
+
const prepareExecutionTask = CadenzaService.createMetaTask(
|
|
6253
|
+
`Prepare graph sync insert execution for ${tableName}`,
|
|
6254
|
+
(ctx) => ({
|
|
6255
|
+
...ctx,
|
|
6256
|
+
queryData: buildSyncInsertQueryData(
|
|
6257
|
+
ctx,
|
|
6258
|
+
queryData
|
|
6259
|
+
)
|
|
6260
|
+
}),
|
|
6261
|
+
`Prepares ${tableName} graph-sync insert payloads for runner execution.`,
|
|
6262
|
+
{
|
|
6263
|
+
register: false,
|
|
6264
|
+
isHidden: true
|
|
6265
|
+
}
|
|
6266
|
+
).doOn(executionRequestedSignal).emitsOnFail(executionFailedSignal);
|
|
6267
|
+
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
6268
|
+
`Finalize graph sync insert execution for ${tableName}`,
|
|
6269
|
+
(ctx, emit) => {
|
|
6270
|
+
if (!ctx.__resolverRequestId) {
|
|
6037
6271
|
return false;
|
|
6038
6272
|
}
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6273
|
+
emit(executionResolvedSignal, ctx);
|
|
6274
|
+
return ctx;
|
|
6275
|
+
},
|
|
6276
|
+
`Resolves signal-driven ${tableName} graph-sync insert execution.`,
|
|
6277
|
+
{
|
|
6278
|
+
register: false,
|
|
6279
|
+
isHidden: true
|
|
6280
|
+
}
|
|
6281
|
+
);
|
|
6282
|
+
targetTask.then(finalizeExecutionTask).emitsOnFail(executionFailedSignal);
|
|
6283
|
+
prepareExecutionTask.then(targetTask);
|
|
6284
|
+
return CadenzaService.createUniqueMetaTask(
|
|
6285
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
6286
|
+
(ctx, emit) => new Promise((resolve) => {
|
|
6287
|
+
const resolverRequestId = (0, import_uuid5.v4)();
|
|
6288
|
+
CadenzaService.createEphemeralMetaTask(
|
|
6289
|
+
`Resolve graph sync insert execution for ${tableName} (${resolverRequestId})`,
|
|
6290
|
+
(resultCtx) => {
|
|
6291
|
+
if (resultCtx.__resolverRequestId !== resolverRequestId) {
|
|
6292
|
+
return false;
|
|
6293
|
+
}
|
|
6294
|
+
const normalizedResult = {
|
|
6295
|
+
...resultCtx
|
|
6296
|
+
};
|
|
6297
|
+
delete normalizedResult.__resolverRequestId;
|
|
6298
|
+
resolve(normalizedResult);
|
|
6299
|
+
return normalizedResult;
|
|
6300
|
+
},
|
|
6301
|
+
`Waits for signal-driven ${tableName} graph-sync insert execution.`,
|
|
6050
6302
|
{
|
|
6051
|
-
|
|
6052
|
-
routineExecId: ctx.__routineExecId ?? ctx.__metadata?.__routineExecId ?? ctx.__metadata?.__localRoutineExecId ?? "graph-sync"
|
|
6303
|
+
register: false
|
|
6053
6304
|
}
|
|
6054
|
-
);
|
|
6055
|
-
|
|
6305
|
+
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
6306
|
+
emit(executionRequestedSignal, {
|
|
6307
|
+
...ctx,
|
|
6308
|
+
__resolverRequestId: resolverRequestId
|
|
6309
|
+
});
|
|
6310
|
+
}),
|
|
6056
6311
|
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
6057
6312
|
{
|
|
6058
6313
|
...options,
|
|
@@ -7357,12 +7612,12 @@ var CadenzaService = class {
|
|
|
7357
7612
|
static bootstrap() {
|
|
7358
7613
|
if (this.isBootstrapped) return;
|
|
7359
7614
|
this.isBootstrapped = true;
|
|
7360
|
-
|
|
7361
|
-
this.signalBroker =
|
|
7362
|
-
this.inquiryBroker =
|
|
7363
|
-
this.runner =
|
|
7364
|
-
this.metaRunner =
|
|
7365
|
-
this.registry =
|
|
7615
|
+
import_core5.default.bootstrap();
|
|
7616
|
+
this.signalBroker = import_core5.default.signalBroker;
|
|
7617
|
+
this.inquiryBroker = import_core5.default.inquiryBroker;
|
|
7618
|
+
this.runner = import_core5.default.runner;
|
|
7619
|
+
this.metaRunner = import_core5.default.metaRunner;
|
|
7620
|
+
this.registry = import_core5.default.registry;
|
|
7366
7621
|
this.serviceRegistry = ServiceRegistry.instance;
|
|
7367
7622
|
RestController.instance;
|
|
7368
7623
|
SocketController.instance;
|
|
@@ -7396,15 +7651,15 @@ var CadenzaService = class {
|
|
|
7396
7651
|
return;
|
|
7397
7652
|
}
|
|
7398
7653
|
this.frontendSyncScheduled = true;
|
|
7399
|
-
|
|
7400
|
-
|
|
7654
|
+
import_core5.default.interval("meta.sync_requested", { __syncing: false }, 18e4);
|
|
7655
|
+
import_core5.default.schedule("meta.sync_requested", { __syncing: false }, 250);
|
|
7401
7656
|
}
|
|
7402
7657
|
static normalizeDeclaredTransports(transports, serviceId) {
|
|
7403
7658
|
return (transports ?? []).map((transport) => normalizeServiceTransportConfig(transport)).filter(
|
|
7404
7659
|
(transport) => !!transport
|
|
7405
7660
|
).map((transport) => ({
|
|
7406
7661
|
...transport,
|
|
7407
|
-
uuid: (0,
|
|
7662
|
+
uuid: (0, import_uuid6.v4)()
|
|
7408
7663
|
}));
|
|
7409
7664
|
}
|
|
7410
7665
|
static createBootstrapTransport(serviceInstanceId, role, endpoint) {
|
|
@@ -7454,7 +7709,7 @@ var CadenzaService = class {
|
|
|
7454
7709
|
* @return {void} Does not return any value.
|
|
7455
7710
|
*/
|
|
7456
7711
|
static validateName(name) {
|
|
7457
|
-
|
|
7712
|
+
import_core5.default.validateName(name);
|
|
7458
7713
|
}
|
|
7459
7714
|
/**
|
|
7460
7715
|
* Gets the current run strategy from the Cadenza configuration.
|
|
@@ -7462,7 +7717,7 @@ var CadenzaService = class {
|
|
|
7462
7717
|
* @return {Function} The run strategy function defined in the Cadenza configuration.
|
|
7463
7718
|
*/
|
|
7464
7719
|
static get runStrategy() {
|
|
7465
|
-
return
|
|
7720
|
+
return import_core5.default.runStrategy;
|
|
7466
7721
|
}
|
|
7467
7722
|
/**
|
|
7468
7723
|
* Sets the mode for the Cadenza application.
|
|
@@ -7471,7 +7726,7 @@ var CadenzaService = class {
|
|
|
7471
7726
|
* @return {void} This method does not return a value.
|
|
7472
7727
|
*/
|
|
7473
7728
|
static setMode(mode) {
|
|
7474
|
-
|
|
7729
|
+
import_core5.default.setMode(mode);
|
|
7475
7730
|
}
|
|
7476
7731
|
/**
|
|
7477
7732
|
* Emits a signal with the specified data using the associated broker.
|
|
@@ -7489,16 +7744,16 @@ var CadenzaService = class {
|
|
|
7489
7744
|
* ```
|
|
7490
7745
|
*/
|
|
7491
7746
|
static emit(signal, data = {}, options = {}) {
|
|
7492
|
-
|
|
7747
|
+
import_core5.default.emit(signal, data, options);
|
|
7493
7748
|
}
|
|
7494
7749
|
static debounce(signal, context = {}, delayMs = 500) {
|
|
7495
|
-
|
|
7750
|
+
import_core5.default.debounce(signal, context, delayMs);
|
|
7496
7751
|
}
|
|
7497
7752
|
static schedule(signal, context, timeoutMs, exactDateTime) {
|
|
7498
|
-
|
|
7753
|
+
import_core5.default.schedule(signal, context, timeoutMs, exactDateTime);
|
|
7499
7754
|
}
|
|
7500
7755
|
static interval(signal, context, intervalMs, leading = false, startDateTime) {
|
|
7501
|
-
|
|
7756
|
+
import_core5.default.interval(signal, context, intervalMs, leading, startDateTime);
|
|
7502
7757
|
}
|
|
7503
7758
|
static defineIntent(intent) {
|
|
7504
7759
|
this.inquiryBroker?.addIntent(intent);
|
|
@@ -7656,7 +7911,7 @@ var CadenzaService = class {
|
|
|
7656
7911
|
}
|
|
7657
7912
|
for (const responder of responders) {
|
|
7658
7913
|
const { task, descriptor } = responder;
|
|
7659
|
-
const inquiryId = (0,
|
|
7914
|
+
const inquiryId = (0, import_uuid6.v4)();
|
|
7660
7915
|
startTimeByTask.set(task, Date.now());
|
|
7661
7916
|
const resolverTask = this.createEphemeralMetaTask(
|
|
7662
7917
|
`Resolve inquiry ${inquiry} for ${descriptor.localTaskName}`,
|
|
@@ -7760,7 +8015,7 @@ var CadenzaService = class {
|
|
|
7760
8015
|
});
|
|
7761
8016
|
}
|
|
7762
8017
|
static get(taskName) {
|
|
7763
|
-
return
|
|
8018
|
+
return import_core5.default.get(taskName);
|
|
7764
8019
|
}
|
|
7765
8020
|
static getLocalCadenzaDBTask(tableName, operation) {
|
|
7766
8021
|
const generatedTaskName = this.buildGeneratedLocalCadenzaDBTaskName(
|
|
@@ -7771,7 +8026,7 @@ var CadenzaService = class {
|
|
|
7771
8026
|
tableName,
|
|
7772
8027
|
operation
|
|
7773
8028
|
);
|
|
7774
|
-
return
|
|
8029
|
+
return import_core5.default.get(generatedTaskName) ?? import_core5.default.get(legacyTaskName);
|
|
7775
8030
|
}
|
|
7776
8031
|
static getLocalCadenzaDBInsertTask(tableName) {
|
|
7777
8032
|
return this.getLocalCadenzaDBTask(tableName, "insert");
|
|
@@ -7780,15 +8035,15 @@ var CadenzaService = class {
|
|
|
7780
8035
|
return this.getLocalCadenzaDBTask(tableName, "query");
|
|
7781
8036
|
}
|
|
7782
8037
|
static getActor(actorName) {
|
|
7783
|
-
const cadenzaWithActors =
|
|
8038
|
+
const cadenzaWithActors = import_core5.default;
|
|
7784
8039
|
return cadenzaWithActors.getActor?.(actorName);
|
|
7785
8040
|
}
|
|
7786
8041
|
static getAllActors() {
|
|
7787
|
-
const cadenzaWithActors =
|
|
8042
|
+
const cadenzaWithActors = import_core5.default;
|
|
7788
8043
|
return cadenzaWithActors.getAllActors?.() ?? [];
|
|
7789
8044
|
}
|
|
7790
8045
|
static getRoutine(routineName) {
|
|
7791
|
-
return
|
|
8046
|
+
return import_core5.default.getRoutine(routineName);
|
|
7792
8047
|
}
|
|
7793
8048
|
/**
|
|
7794
8049
|
* Creates a new DeputyTask instance based on the provided routine name, service name, and options.
|
|
@@ -8164,7 +8419,7 @@ var CadenzaService = class {
|
|
|
8164
8419
|
this.bootstrap();
|
|
8165
8420
|
this.validateName(serviceName);
|
|
8166
8421
|
this.validateServiceName(serviceName);
|
|
8167
|
-
const serviceId = options.customServiceId ?? (0,
|
|
8422
|
+
const serviceId = options.customServiceId ?? (0, import_uuid6.v4)();
|
|
8168
8423
|
this.serviceRegistry.serviceName = serviceName;
|
|
8169
8424
|
this.serviceRegistry.serviceInstanceId = serviceId;
|
|
8170
8425
|
this.setHydrationResults(options.hydration);
|
|
@@ -8301,7 +8556,7 @@ var CadenzaService = class {
|
|
|
8301
8556
|
"global.meta.cadenza_db.gathered_sync_data",
|
|
8302
8557
|
ctx.serviceName
|
|
8303
8558
|
);
|
|
8304
|
-
}).doOn("meta.rest.handshake");
|
|
8559
|
+
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
8305
8560
|
}
|
|
8306
8561
|
this.createMetaTask("Handle service setup completion", () => {
|
|
8307
8562
|
if (isFrontend) {
|
|
@@ -8316,7 +8571,7 @@ var CadenzaService = class {
|
|
|
8316
8571
|
return true;
|
|
8317
8572
|
}).doOn("meta.service_registry.instance_inserted");
|
|
8318
8573
|
if (!options.cadenzaDB?.connect && isFrontend) {
|
|
8319
|
-
|
|
8574
|
+
import_core5.default.schedule(
|
|
8320
8575
|
"meta.service_registry.instance_registration_requested",
|
|
8321
8576
|
{
|
|
8322
8577
|
data: {
|
|
@@ -8577,11 +8832,11 @@ var CadenzaService = class {
|
|
|
8577
8832
|
}
|
|
8578
8833
|
static createActor(spec, options = {}) {
|
|
8579
8834
|
this.bootstrap();
|
|
8580
|
-
return
|
|
8835
|
+
return import_core5.default.createActor(spec, options);
|
|
8581
8836
|
}
|
|
8582
8837
|
static createActorFromDefinition(definition, options = {}) {
|
|
8583
8838
|
this.bootstrap();
|
|
8584
|
-
return
|
|
8839
|
+
return import_core5.default.createActorFromDefinition(definition, options);
|
|
8585
8840
|
}
|
|
8586
8841
|
/**
|
|
8587
8842
|
* Creates and registers a new task with the provided name, function, and optional details.
|
|
@@ -8655,7 +8910,7 @@ var CadenzaService = class {
|
|
|
8655
8910
|
*/
|
|
8656
8911
|
static createTask(name, func, description, options = {}) {
|
|
8657
8912
|
this.bootstrap();
|
|
8658
|
-
return
|
|
8913
|
+
return import_core5.default.createTask(name, func, description, options);
|
|
8659
8914
|
}
|
|
8660
8915
|
/**
|
|
8661
8916
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
@@ -8671,7 +8926,7 @@ var CadenzaService = class {
|
|
|
8671
8926
|
*/
|
|
8672
8927
|
static createMetaTask(name, func, description, options = {}) {
|
|
8673
8928
|
this.bootstrap();
|
|
8674
|
-
return
|
|
8929
|
+
return import_core5.default.createMetaTask(name, func, description, options);
|
|
8675
8930
|
}
|
|
8676
8931
|
/**
|
|
8677
8932
|
* Creates a unique task by wrapping the provided task function with a uniqueness constraint.
|
|
@@ -8721,7 +8976,7 @@ var CadenzaService = class {
|
|
|
8721
8976
|
*/
|
|
8722
8977
|
static createUniqueTask(name, func, description, options = {}) {
|
|
8723
8978
|
this.bootstrap();
|
|
8724
|
-
return
|
|
8979
|
+
return import_core5.default.createUniqueTask(name, func, description, options);
|
|
8725
8980
|
}
|
|
8726
8981
|
/**
|
|
8727
8982
|
* Creates a unique meta task with the specified name, function, description, and options.
|
|
@@ -8735,7 +8990,7 @@ var CadenzaService = class {
|
|
|
8735
8990
|
*/
|
|
8736
8991
|
static createUniqueMetaTask(name, func, description, options = {}) {
|
|
8737
8992
|
this.bootstrap();
|
|
8738
|
-
return
|
|
8993
|
+
return import_core5.default.createUniqueMetaTask(name, func, description, options);
|
|
8739
8994
|
}
|
|
8740
8995
|
/**
|
|
8741
8996
|
* Creates a throttled task with a concurrency limit of 1, ensuring that only one instance of the task can run at a time for a specific throttle tag.
|
|
@@ -8768,7 +9023,7 @@ var CadenzaService = class {
|
|
|
8768
9023
|
*/
|
|
8769
9024
|
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
8770
9025
|
this.bootstrap();
|
|
8771
|
-
return
|
|
9026
|
+
return import_core5.default.createThrottledTask(
|
|
8772
9027
|
name,
|
|
8773
9028
|
func,
|
|
8774
9029
|
throttledIdGetter,
|
|
@@ -8789,7 +9044,7 @@ var CadenzaService = class {
|
|
|
8789
9044
|
*/
|
|
8790
9045
|
static createThrottledMetaTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
8791
9046
|
this.bootstrap();
|
|
8792
|
-
return
|
|
9047
|
+
return import_core5.default.createThrottledMetaTask(
|
|
8793
9048
|
name,
|
|
8794
9049
|
func,
|
|
8795
9050
|
throttledIdGetter,
|
|
@@ -8832,7 +9087,7 @@ var CadenzaService = class {
|
|
|
8832
9087
|
*/
|
|
8833
9088
|
static createDebounceTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
8834
9089
|
this.bootstrap();
|
|
8835
|
-
return
|
|
9090
|
+
return import_core5.default.createDebounceTask(
|
|
8836
9091
|
name,
|
|
8837
9092
|
func,
|
|
8838
9093
|
description,
|
|
@@ -8853,7 +9108,7 @@ var CadenzaService = class {
|
|
|
8853
9108
|
*/
|
|
8854
9109
|
static createDebounceMetaTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
8855
9110
|
this.bootstrap();
|
|
8856
|
-
return
|
|
9111
|
+
return import_core5.default.createDebounceMetaTask(
|
|
8857
9112
|
name,
|
|
8858
9113
|
func,
|
|
8859
9114
|
description,
|
|
@@ -8923,7 +9178,7 @@ var CadenzaService = class {
|
|
|
8923
9178
|
*/
|
|
8924
9179
|
static createEphemeralTask(name, func, description, options = {}) {
|
|
8925
9180
|
this.bootstrap();
|
|
8926
|
-
return
|
|
9181
|
+
return import_core5.default.createEphemeralTask(name, func, description, options);
|
|
8927
9182
|
}
|
|
8928
9183
|
/**
|
|
8929
9184
|
* Creates an ephemeral meta-task with the specified name, function, description, and options.
|
|
@@ -8937,7 +9192,7 @@ var CadenzaService = class {
|
|
|
8937
9192
|
*/
|
|
8938
9193
|
static createEphemeralMetaTask(name, func, description, options = {}) {
|
|
8939
9194
|
this.bootstrap();
|
|
8940
|
-
return
|
|
9195
|
+
return import_core5.default.createEphemeralMetaTask(name, func, description, options);
|
|
8941
9196
|
}
|
|
8942
9197
|
/**
|
|
8943
9198
|
* Creates a new routine with the specified name, tasks, and an optional description.
|
|
@@ -8969,7 +9224,7 @@ var CadenzaService = class {
|
|
|
8969
9224
|
*/
|
|
8970
9225
|
static createRoutine(name, tasks, description = "") {
|
|
8971
9226
|
this.bootstrap();
|
|
8972
|
-
return
|
|
9227
|
+
return import_core5.default.createRoutine(name, tasks, description);
|
|
8973
9228
|
}
|
|
8974
9229
|
/**
|
|
8975
9230
|
* Creates a meta routine with a given name, tasks, and optional description.
|
|
@@ -8984,10 +9239,10 @@ var CadenzaService = class {
|
|
|
8984
9239
|
*/
|
|
8985
9240
|
static createMetaRoutine(name, tasks, description = "") {
|
|
8986
9241
|
this.bootstrap();
|
|
8987
|
-
return
|
|
9242
|
+
return import_core5.default.createMetaRoutine(name, tasks, description);
|
|
8988
9243
|
}
|
|
8989
9244
|
static reset() {
|
|
8990
|
-
|
|
9245
|
+
import_core5.default.reset();
|
|
8991
9246
|
this.serviceRegistry?.reset();
|
|
8992
9247
|
this.isBootstrapped = false;
|
|
8993
9248
|
this.serviceCreated = false;
|
|
@@ -9005,10 +9260,10 @@ CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
|
9005
9260
|
CadenzaService.frontendSyncScheduled = false;
|
|
9006
9261
|
|
|
9007
9262
|
// src/index.ts
|
|
9008
|
-
var
|
|
9263
|
+
var import_core6 = require("@cadenza.io/core");
|
|
9009
9264
|
|
|
9010
9265
|
// src/ssr/createSSRInquiryBridge.ts
|
|
9011
|
-
var
|
|
9266
|
+
var import_uuid7 = require("uuid");
|
|
9012
9267
|
function ensureFetch() {
|
|
9013
9268
|
if (typeof globalThis.fetch !== "function") {
|
|
9014
9269
|
throw new Error("SSR inquiry bridge requires global fetch support.");
|
|
@@ -9097,7 +9352,7 @@ function createSSRInquiryBridge(options = {}) {
|
|
|
9097
9352
|
__remoteRoutineName: remoteRoutineName,
|
|
9098
9353
|
__metadata: {
|
|
9099
9354
|
...context.__metadata ?? {},
|
|
9100
|
-
__deputyExecId: (0,
|
|
9355
|
+
__deputyExecId: (0, import_uuid7.v4)()
|
|
9101
9356
|
}
|
|
9102
9357
|
}),
|
|
9103
9358
|
signal
|