@cadenza.io/service 2.17.32 → 2.17.34
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 +397 -136
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +354 -94
- package/dist/browser/index.mjs.map +1 -1
- 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/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 uuid9 = 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 (!uuid9 || !serviceInstanceId || !config) {
|
|
445
445
|
return null;
|
|
446
446
|
}
|
|
447
447
|
return {
|
|
448
|
-
uuid:
|
|
448
|
+
uuid: uuid9,
|
|
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 uuid9 = normalizeString2(raw.uuid);
|
|
511
511
|
const serviceName = normalizeString2(raw.serviceName ?? raw.service_name);
|
|
512
|
-
if (!
|
|
512
|
+
if (!uuid9 || !serviceName) {
|
|
513
513
|
return null;
|
|
514
514
|
}
|
|
515
|
-
const transports = normalizeTransportArray(raw.transports,
|
|
515
|
+
const transports = normalizeTransportArray(raw.transports, uuid9);
|
|
516
516
|
return {
|
|
517
|
-
uuid:
|
|
517
|
+
uuid: uuid9,
|
|
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) {
|
|
@@ -785,12 +787,18 @@ function normalizeServiceRegistryInsertResult(tableName, ctx, queryData, rawResu
|
|
|
785
787
|
result.queryData = normalizedQueryData;
|
|
786
788
|
if (tableName === "service") {
|
|
787
789
|
const resolvedServiceName = String(
|
|
788
|
-
result.__serviceName ?? resolvedData?.name ?? resolvedData?.service_name ??
|
|
790
|
+
ctx.__serviceName ?? result.__serviceName ?? resolvedData?.name ?? resolvedData?.service_name ?? ""
|
|
789
791
|
).trim();
|
|
790
792
|
if (resolvedServiceName) {
|
|
791
793
|
result.__serviceName = resolvedServiceName;
|
|
792
794
|
}
|
|
793
795
|
}
|
|
796
|
+
const resolvedLocalServiceInstanceId = String(
|
|
797
|
+
ctx.__serviceInstanceId ?? resolvedData?.uuid ?? resolvedData?.service_instance_id ?? ""
|
|
798
|
+
).trim();
|
|
799
|
+
if (resolvedLocalServiceInstanceId) {
|
|
800
|
+
result.__serviceInstanceId = resolvedLocalServiceInstanceId;
|
|
801
|
+
}
|
|
794
802
|
if (tableName === "service_instance" || tableName === "service_instance_transport") {
|
|
795
803
|
const resolvedUuid = String(
|
|
796
804
|
result.uuid ?? resolvedData?.uuid ?? ctx.__serviceInstanceId ?? ""
|
|
@@ -807,49 +815,105 @@ function resolveServiceRegistryInsertTask(tableName, queryData = {}, options = {
|
|
|
807
815
|
queryData,
|
|
808
816
|
options
|
|
809
817
|
);
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
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) => {
|
|
813
825
|
const nextQueryData = buildServiceRegistryInsertQueryData(ctx, queryData);
|
|
814
|
-
if (tableName === "service" && nextQueryData.data === void 0) {
|
|
815
|
-
CadenzaService.log(
|
|
816
|
-
"Service registry insert resolver missing service payload.",
|
|
817
|
-
{
|
|
818
|
-
ctxKeys: ctx && typeof ctx === "object" ? Object.keys(ctx).sort() : [],
|
|
819
|
-
hasData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "data") || ctx.data !== void 0),
|
|
820
|
-
hasRegistrationData: !!ctx && typeof ctx === "object" && (Object.prototype.hasOwnProperty.call(ctx, "__registrationData") || ctx.__registrationData !== void 0),
|
|
821
|
-
serviceName: ctx?.__serviceName ?? ctx?.data?.name ?? null
|
|
822
|
-
},
|
|
823
|
-
"warning"
|
|
824
|
-
);
|
|
825
|
-
}
|
|
826
|
-
const targetTask = CadenzaService.getLocalCadenzaDBInsertTask(tableName) ?? remoteInsertTask;
|
|
827
826
|
const delegationContext = ensureDelegationContextMetadata({
|
|
828
827
|
...ctx,
|
|
829
828
|
queryData: nextQueryData
|
|
830
829
|
});
|
|
831
830
|
delegationContext.__metadata.__skipRemoteExecution = delegationContext.__metadata.__skipRemoteExecution ?? delegationContext.__skipRemoteExecution ?? false;
|
|
832
831
|
delegationContext.__metadata.__blockRemoteExecution = delegationContext.__metadata.__blockRemoteExecution ?? delegationContext.__blockRemoteExecution ?? false;
|
|
833
|
-
return
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
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
|
|
851
863
|
);
|
|
864
|
+
if (!normalized || typeof normalized !== "object") {
|
|
865
|
+
return normalized;
|
|
866
|
+
}
|
|
867
|
+
emit(executionResolvedSignal, normalized);
|
|
868
|
+
return normalized;
|
|
852
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
|
+
}),
|
|
853
917
|
`Resolves ${tableName} inserts through the local CadenzaDB task when available.`,
|
|
854
918
|
options
|
|
855
919
|
);
|
|
@@ -1087,15 +1151,15 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1087
1151
|
if (!serviceInstance) {
|
|
1088
1152
|
return false;
|
|
1089
1153
|
}
|
|
1090
|
-
const
|
|
1154
|
+
const uuid9 = serviceInstance.uuid;
|
|
1091
1155
|
const serviceName = serviceInstance.serviceName;
|
|
1092
1156
|
const deleted = Boolean(
|
|
1093
1157
|
ctx.deleted ?? ctx.serviceInstance?.deleted ?? ctx.data?.deleted
|
|
1094
1158
|
);
|
|
1095
|
-
if (
|
|
1159
|
+
if (uuid9 === this.serviceInstanceId) return;
|
|
1096
1160
|
if (deleted) {
|
|
1097
|
-
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid ===
|
|
1098
|
-
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid ===
|
|
1161
|
+
const existingInstance = this.instances.get(serviceName)?.find((instance) => instance.uuid === uuid9);
|
|
1162
|
+
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid9) ?? -1;
|
|
1099
1163
|
if (indexToDelete >= 0 && existingInstance) {
|
|
1100
1164
|
this.instances.get(serviceName)?.splice(indexToDelete, 1);
|
|
1101
1165
|
for (const transport of existingInstance.transports) {
|
|
@@ -1107,13 +1171,13 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1107
1171
|
if (this.instances.get(serviceName)?.length === 0) {
|
|
1108
1172
|
this.instances.delete(serviceName);
|
|
1109
1173
|
}
|
|
1110
|
-
this.unregisterDependee(
|
|
1174
|
+
this.unregisterDependee(uuid9, serviceName);
|
|
1111
1175
|
return;
|
|
1112
1176
|
}
|
|
1113
1177
|
if (!this.instances.has(serviceName))
|
|
1114
1178
|
this.instances.set(serviceName, []);
|
|
1115
1179
|
const instances = this.instances.get(serviceName);
|
|
1116
|
-
const existing = instances.find((i) => i.uuid ===
|
|
1180
|
+
const existing = instances.find((i) => i.uuid === uuid9);
|
|
1117
1181
|
if (existing) {
|
|
1118
1182
|
Object.assign(existing, {
|
|
1119
1183
|
...serviceInstance,
|
|
@@ -1123,7 +1187,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1123
1187
|
} else {
|
|
1124
1188
|
instances.push(serviceInstance);
|
|
1125
1189
|
}
|
|
1126
|
-
const trackedInstance = existing ?? instances.find((instance) => instance.uuid ===
|
|
1190
|
+
const trackedInstance = existing ?? instances.find((instance) => instance.uuid === uuid9);
|
|
1127
1191
|
if (trackedInstance) {
|
|
1128
1192
|
const snapshot = this.resolveRuntimeStatusSnapshot(
|
|
1129
1193
|
trackedInstance.numberOfRunningGraphs ?? 0,
|
|
@@ -1136,16 +1200,19 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1136
1200
|
trackedInstance.reportedAt = trackedInstance.reportedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1137
1201
|
}
|
|
1138
1202
|
if (!serviceInstance.isBootstrapPlaceholder) {
|
|
1139
|
-
this.reconcileBootstrapPlaceholderInstance(serviceName,
|
|
1203
|
+
this.reconcileBootstrapPlaceholderInstance(serviceName, uuid9, emit);
|
|
1140
1204
|
}
|
|
1141
1205
|
if (this.serviceName === serviceName) {
|
|
1142
1206
|
return false;
|
|
1143
1207
|
}
|
|
1208
|
+
if (trackedInstance?.isFrontend) {
|
|
1209
|
+
return true;
|
|
1210
|
+
}
|
|
1144
1211
|
const trackedTransport = this.getRouteableTransport(
|
|
1145
1212
|
trackedInstance,
|
|
1146
1213
|
this.useSocket ? "socket" : "rest"
|
|
1147
1214
|
);
|
|
1148
|
-
if (
|
|
1215
|
+
if (this.deputies.has(serviceName) || this.remoteIntents.has(serviceName) || this.remoteSignals.has(serviceName)) {
|
|
1149
1216
|
const communicationTypes = Array.from(
|
|
1150
1217
|
new Set(
|
|
1151
1218
|
this.deputies.get(serviceName)?.map((d) => d.communicationType) ?? []
|
|
@@ -1162,7 +1229,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1162
1229
|
if (!clientCreated) {
|
|
1163
1230
|
emit("meta.service_registry.dependee_registered", {
|
|
1164
1231
|
serviceName,
|
|
1165
|
-
serviceInstanceId:
|
|
1232
|
+
serviceInstanceId: uuid9,
|
|
1166
1233
|
serviceTransportId: trackedTransport.uuid,
|
|
1167
1234
|
serviceOrigin: trackedTransport.origin,
|
|
1168
1235
|
transportProtocols: trackedTransport.protocols,
|
|
@@ -1176,7 +1243,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1176
1243
|
} else {
|
|
1177
1244
|
emit("meta.service_registry.routeable_transport_missing", {
|
|
1178
1245
|
serviceName,
|
|
1179
|
-
serviceInstanceId:
|
|
1246
|
+
serviceInstanceId: uuid9,
|
|
1180
1247
|
requiredRole: this.getRoutingTransportRole(),
|
|
1181
1248
|
isFrontend: this.isFrontend
|
|
1182
1249
|
});
|
|
@@ -1235,7 +1302,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1235
1302
|
if (ownerInstance.uuid === this.serviceInstanceId) {
|
|
1236
1303
|
return true;
|
|
1237
1304
|
}
|
|
1238
|
-
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();
|
|
1239
1306
|
if (!hasRemoteInterest) {
|
|
1240
1307
|
return true;
|
|
1241
1308
|
}
|
|
@@ -1650,6 +1717,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1650
1717
|
if (!instance.isActive || instance.isNonResponsive || instance.isBlocked) {
|
|
1651
1718
|
return false;
|
|
1652
1719
|
}
|
|
1720
|
+
if (instance.isFrontend) {
|
|
1721
|
+
return true;
|
|
1722
|
+
}
|
|
1653
1723
|
return Boolean(
|
|
1654
1724
|
this.selectTransportForInstance(instance, context, preferredRole)
|
|
1655
1725
|
);
|
|
@@ -1683,6 +1753,21 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1683
1753
|
}
|
|
1684
1754
|
if (__broadcast || instances[0].isFrontend) {
|
|
1685
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
|
+
}
|
|
1686
1771
|
const selectedTransport2 = this.selectTransportForInstance(
|
|
1687
1772
|
instance,
|
|
1688
1773
|
context,
|
|
@@ -1724,6 +1809,21 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
1724
1809
|
if (retries > 0) {
|
|
1725
1810
|
selected = instancesToTry[Math.floor(Math.random() * instancesToTry.length)];
|
|
1726
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
|
+
}
|
|
1727
1827
|
const selectedTransport = this.selectTransportForInstance(
|
|
1728
1828
|
selected,
|
|
1729
1829
|
context,
|
|
@@ -2380,7 +2480,7 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
2380
2480
|
)
|
|
2381
2481
|
);
|
|
2382
2482
|
for (const service of services) {
|
|
2383
|
-
const instances = this.instances.get(service).filter((i) => i.isActive);
|
|
2483
|
+
const instances = this.instances.get(service).filter((i) => i.isActive && !i.isFrontend);
|
|
2384
2484
|
for (const instance of instances) {
|
|
2385
2485
|
const transport = this.getRouteableTransport(
|
|
2386
2486
|
instance,
|
|
@@ -3432,9 +3532,9 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
3432
3532
|
};
|
|
3433
3533
|
|
|
3434
3534
|
// src/graph/definition/SignalTransmissionTask.ts
|
|
3435
|
-
var
|
|
3436
|
-
var
|
|
3437
|
-
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 {
|
|
3438
3538
|
/**
|
|
3439
3539
|
* Constructs a new instance of the class and initializes it with the provided parameters.
|
|
3440
3540
|
*
|
|
@@ -3462,7 +3562,7 @@ var SignalTransmissionTask = class extends import_core3.Task {
|
|
|
3462
3562
|
*/
|
|
3463
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) {
|
|
3464
3564
|
const taskFunction = (context) => {
|
|
3465
|
-
context.__routineExecId = (0,
|
|
3565
|
+
context.__routineExecId = (0, import_uuid4.v4)();
|
|
3466
3566
|
return context;
|
|
3467
3567
|
};
|
|
3468
3568
|
super(
|
|
@@ -3532,7 +3632,7 @@ var import_node_http = __toESM(require("http"));
|
|
|
3532
3632
|
var import_node_fs = __toESM(require("fs"));
|
|
3533
3633
|
var import_node_https = __toESM(require("https"));
|
|
3534
3634
|
var import_node_fetch = __toESM(require("node-fetch"));
|
|
3535
|
-
var
|
|
3635
|
+
var import_uuid5 = require("uuid");
|
|
3536
3636
|
var RestController = class _RestController {
|
|
3537
3637
|
/**
|
|
3538
3638
|
* Constructor for initializing the REST server and related configurations.
|
|
@@ -3902,7 +4002,7 @@ var RestController = class _RestController {
|
|
|
3902
4002
|
const internalOrigin = httpOrigin ?? httpsOrigin;
|
|
3903
4003
|
if (internalOrigin) {
|
|
3904
4004
|
transportData.unshift({
|
|
3905
|
-
uuid: (0,
|
|
4005
|
+
uuid: (0, import_uuid5.v4)(),
|
|
3906
4006
|
service_instance_id: ctx.__serviceInstanceId,
|
|
3907
4007
|
role: "internal",
|
|
3908
4008
|
origin: internalOrigin,
|
|
@@ -4559,6 +4659,35 @@ var SocketController = class _SocketController {
|
|
|
4559
4659
|
},
|
|
4560
4660
|
{ isMeta: true }
|
|
4561
4661
|
);
|
|
4662
|
+
CadenzaService.registry.getTaskByName.doOn("meta.socket.delegation_requested");
|
|
4663
|
+
CadenzaService.registry.getRoutineByName.doOn("meta.socket.delegation_requested");
|
|
4664
|
+
CadenzaService.createMetaTask(
|
|
4665
|
+
"Forward socket delegations to runner",
|
|
4666
|
+
(context, emit) => {
|
|
4667
|
+
if (!isBrowser && !CadenzaService.serviceRegistry.isFrontend) {
|
|
4668
|
+
return false;
|
|
4669
|
+
}
|
|
4670
|
+
if (context.task || context.routine) {
|
|
4671
|
+
const routine = context.task ?? context.routine;
|
|
4672
|
+
delete context.task;
|
|
4673
|
+
delete context.routine;
|
|
4674
|
+
context.__routineExecId = context.__metadata?.__deputyExecId ?? null;
|
|
4675
|
+
context.__isDeputy = true;
|
|
4676
|
+
CadenzaService.runner.run(routine, context);
|
|
4677
|
+
return true;
|
|
4678
|
+
}
|
|
4679
|
+
const deputyExecId = context.__metadata?.__deputyExecId ?? context.__deputyExecId;
|
|
4680
|
+
const remoteRoutineName = context.__remoteRoutineName ?? context.__name ?? "unknown";
|
|
4681
|
+
context.errored = true;
|
|
4682
|
+
context.__error = `No task or routine registered for delegation target ${remoteRoutineName}.`;
|
|
4683
|
+
if (deputyExecId) {
|
|
4684
|
+
emit(`meta.socket.delegation_target_not_found:${deputyExecId}`, context);
|
|
4685
|
+
}
|
|
4686
|
+
emit("meta.runner.failed", context);
|
|
4687
|
+
return false;
|
|
4688
|
+
},
|
|
4689
|
+
"Forwards socket delegated lookups to the local runner in frontend runtimes."
|
|
4690
|
+
).attachSignal("meta.runner.failed").doAfter(CadenzaService.registry.getTaskByName, CadenzaService.registry.getRoutineByName);
|
|
4562
4691
|
this.registerDiagnosticsTasks();
|
|
4563
4692
|
this.registerSocketServerTasks();
|
|
4564
4693
|
this.registerSocketClientTasks();
|
|
@@ -4802,8 +4931,56 @@ var SocketController = class _SocketController {
|
|
|
4802
4931
|
});
|
|
4803
4932
|
if (ctx.isFrontend) {
|
|
4804
4933
|
const fetchId = `browser:${ctx.serviceInstanceId}`;
|
|
4934
|
+
const frontendDelegateTaskName = `Delegate flow to frontend ${fetchId}`;
|
|
4935
|
+
const frontendTransmitTaskName = `Transmit signal to ${fetchId}`;
|
|
4936
|
+
CadenzaService.get(frontendDelegateTaskName)?.destroy();
|
|
4937
|
+
CadenzaService.get(frontendTransmitTaskName)?.destroy();
|
|
4805
4938
|
CadenzaService.createMetaTask(
|
|
4806
|
-
|
|
4939
|
+
frontendDelegateTaskName,
|
|
4940
|
+
async (delegateCtx, emitter) => {
|
|
4941
|
+
if (delegateCtx.__remoteRoutineName === void 0) {
|
|
4942
|
+
return;
|
|
4943
|
+
}
|
|
4944
|
+
const normalizedDelegateCtx = ensureDelegationContextMetadata(delegateCtx);
|
|
4945
|
+
delete normalizedDelegateCtx.__isSubMeta;
|
|
4946
|
+
delete normalizedDelegateCtx.__broadcast;
|
|
4947
|
+
const deputyExecId = normalizedDelegateCtx.__metadata?.__deputyExecId;
|
|
4948
|
+
const resultContext = await new Promise((resolve) => {
|
|
4949
|
+
ws.timeout(normalizedDelegateCtx.__timeout ?? 6e4).emit(
|
|
4950
|
+
"delegation",
|
|
4951
|
+
normalizedDelegateCtx,
|
|
4952
|
+
(err, response) => {
|
|
4953
|
+
if (err) {
|
|
4954
|
+
resolve({
|
|
4955
|
+
...normalizedDelegateCtx,
|
|
4956
|
+
errored: true,
|
|
4957
|
+
__error: `Frontend delegation timed out: ${err.message ?? err}`
|
|
4958
|
+
});
|
|
4959
|
+
return;
|
|
4960
|
+
}
|
|
4961
|
+
resolve(
|
|
4962
|
+
response ?? {
|
|
4963
|
+
errored: true,
|
|
4964
|
+
__error: "Frontend delegation returned no response"
|
|
4965
|
+
}
|
|
4966
|
+
);
|
|
4967
|
+
}
|
|
4968
|
+
);
|
|
4969
|
+
});
|
|
4970
|
+
if (deputyExecId) {
|
|
4971
|
+
const metadata = resultContext.__metadata;
|
|
4972
|
+
delete resultContext.__metadata;
|
|
4973
|
+
emitter(`meta.socket_client.delegated:${deputyExecId}`, {
|
|
4974
|
+
...resultContext,
|
|
4975
|
+
...metadata && typeof metadata === "object" ? metadata : {}
|
|
4976
|
+
});
|
|
4977
|
+
}
|
|
4978
|
+
return resultContext;
|
|
4979
|
+
},
|
|
4980
|
+
"Delegates work to a connected frontend runtime through its active websocket."
|
|
4981
|
+
).doOn(`meta.service_registry.selected_instance_for_socket:${fetchId}`).attachSignal("meta.socket_client.delegated");
|
|
4982
|
+
CadenzaService.createMetaTask(
|
|
4983
|
+
frontendTransmitTaskName,
|
|
4807
4984
|
(c, emitter) => {
|
|
4808
4985
|
if (c.__signalName === void 0) {
|
|
4809
4986
|
return;
|
|
@@ -5268,10 +5445,54 @@ var SocketController = class _SocketController {
|
|
|
5268
5445
|
delegationCtx
|
|
5269
5446
|
);
|
|
5270
5447
|
});
|
|
5271
|
-
socket.on("
|
|
5448
|
+
socket.on("delegation", (delegationCtx, callback) => {
|
|
5449
|
+
const normalizedDelegationCtx = ensureDelegationContextMetadata(delegationCtx);
|
|
5450
|
+
const deputyExecId = normalizedDelegationCtx.__metadata.__deputyExecId;
|
|
5451
|
+
const targetNotFoundSignal = `meta.socket.delegation_target_not_found:${deputyExecId}`;
|
|
5452
|
+
CadenzaService.createEphemeralMetaTask(
|
|
5453
|
+
`Resolve frontend socket delegation ${deputyExecId}`,
|
|
5454
|
+
(completedCtx) => {
|
|
5455
|
+
callback(completedCtx);
|
|
5456
|
+
return completedCtx;
|
|
5457
|
+
},
|
|
5458
|
+
"Resolves a server-routed delegation request through the frontend runtime.",
|
|
5459
|
+
{
|
|
5460
|
+
register: false
|
|
5461
|
+
}
|
|
5462
|
+
).doOn(`meta.node.graph_completed:${deputyExecId}`, targetNotFoundSignal);
|
|
5463
|
+
if (!CadenzaService.get(normalizedDelegationCtx.__remoteRoutineName) && !CadenzaService.registry.routines.get(
|
|
5464
|
+
normalizedDelegationCtx.__remoteRoutineName
|
|
5465
|
+
)) {
|
|
5466
|
+
CadenzaService.emit(targetNotFoundSignal, {
|
|
5467
|
+
...normalizedDelegationCtx,
|
|
5468
|
+
__error: `No task or routine registered for delegation target ${normalizedDelegationCtx.__remoteRoutineName}.`,
|
|
5469
|
+
errored: true
|
|
5470
|
+
});
|
|
5471
|
+
return;
|
|
5472
|
+
}
|
|
5473
|
+
CadenzaService.emit("meta.socket.delegation_requested", {
|
|
5474
|
+
...normalizedDelegationCtx,
|
|
5475
|
+
__name: normalizedDelegationCtx.__remoteRoutineName
|
|
5476
|
+
});
|
|
5477
|
+
});
|
|
5478
|
+
socket.on("signal", (signalCtx, callback) => {
|
|
5272
5479
|
if (CadenzaService.signalBroker.listObservedSignals().includes(signalCtx.__signalName)) {
|
|
5480
|
+
callback?.({
|
|
5481
|
+
__status: "success",
|
|
5482
|
+
__signalName: signalCtx.__signalName
|
|
5483
|
+
});
|
|
5273
5484
|
CadenzaService.emit(signalCtx.__signalName, signalCtx);
|
|
5485
|
+
return;
|
|
5274
5486
|
}
|
|
5487
|
+
callback?.({
|
|
5488
|
+
...signalCtx,
|
|
5489
|
+
__status: "error",
|
|
5490
|
+
__error: `No such signal: ${signalCtx.__signalName}`,
|
|
5491
|
+
errored: true
|
|
5492
|
+
});
|
|
5493
|
+
});
|
|
5494
|
+
socket.on("status_check", (statusCtx, callback) => {
|
|
5495
|
+
callback(CadenzaService.serviceRegistry.resolveLocalStatusCheck(statusCtx));
|
|
5275
5496
|
});
|
|
5276
5497
|
socket.on("status_update", (status) => {
|
|
5277
5498
|
CadenzaService.emit("meta.socket_client.status_received", status);
|
|
@@ -5941,7 +6162,7 @@ var SignalController = class _SignalController {
|
|
|
5941
6162
|
};
|
|
5942
6163
|
|
|
5943
6164
|
// src/graph/controllers/registerActorSessionPersistence.ts
|
|
5944
|
-
var
|
|
6165
|
+
var import_core3 = require("@cadenza.io/core");
|
|
5945
6166
|
function registerActorSessionPersistenceTasks() {
|
|
5946
6167
|
if (CadenzaService.get("Persist actor session state")) {
|
|
5947
6168
|
return;
|
|
@@ -6062,7 +6283,7 @@ function registerActorSessionPersistenceTasks() {
|
|
|
6062
6283
|
},
|
|
6063
6284
|
"Validates and prepares actor_session_state payload for strict write-through persistence.",
|
|
6064
6285
|
{ isSubMeta: true, concurrency: 100 }
|
|
6065
|
-
).then(insertAndValidateActorSessionStateTask).respondsTo(
|
|
6286
|
+
).then(insertAndValidateActorSessionStateTask).respondsTo(import_core3.META_ACTOR_SESSION_STATE_PERSIST_INTENT);
|
|
6066
6287
|
}
|
|
6067
6288
|
|
|
6068
6289
|
// src/graph/controllers/GraphMetadataController.ts
|
|
@@ -8344,10 +8565,11 @@ function tableFieldTypeToSchemaType(type) {
|
|
|
8344
8565
|
}
|
|
8345
8566
|
|
|
8346
8567
|
// src/Cadenza.ts
|
|
8347
|
-
var
|
|
8568
|
+
var import_uuid7 = require("uuid");
|
|
8348
8569
|
|
|
8349
8570
|
// src/graph/controllers/GraphSyncController.ts
|
|
8350
|
-
var
|
|
8571
|
+
var import_core4 = require("@cadenza.io/core");
|
|
8572
|
+
var import_uuid6 = require("uuid");
|
|
8351
8573
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
8352
8574
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
8353
8575
|
if (typeof taskFunction !== "function") {
|
|
@@ -8413,7 +8635,7 @@ function resolveSyncServiceName(task) {
|
|
|
8413
8635
|
return taskServiceName || registryServiceName || void 0;
|
|
8414
8636
|
}
|
|
8415
8637
|
function isLocalOnlySyncIntent(intentName) {
|
|
8416
|
-
return intentName ===
|
|
8638
|
+
return intentName === import_core4.META_ACTOR_SESSION_STATE_PERSIST_INTENT;
|
|
8417
8639
|
}
|
|
8418
8640
|
function buildIntentRegistryData(intent) {
|
|
8419
8641
|
const name = String(intent?.name ?? "").trim();
|
|
@@ -8481,30 +8703,69 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
8481
8703
|
if (!localInsertTask && !remoteInsertTask) {
|
|
8482
8704
|
return void 0;
|
|
8483
8705
|
}
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8706
|
+
const targetTask = localInsertTask ?? remoteInsertTask;
|
|
8707
|
+
const executionRequestedSignal = `meta.sync_controller.insert_execution_requested:${tableName}`;
|
|
8708
|
+
const executionResolvedSignal = `meta.sync_controller.insert_execution_resolved:${tableName}`;
|
|
8709
|
+
const executionFailedSignal = `meta.sync_controller.insert_execution_failed:${tableName}`;
|
|
8710
|
+
const prepareExecutionTask = CadenzaService.createMetaTask(
|
|
8711
|
+
`Prepare graph sync insert execution for ${tableName}`,
|
|
8712
|
+
(ctx) => ({
|
|
8713
|
+
...ctx,
|
|
8714
|
+
queryData: buildSyncInsertQueryData(
|
|
8715
|
+
ctx,
|
|
8716
|
+
queryData
|
|
8717
|
+
)
|
|
8718
|
+
}),
|
|
8719
|
+
`Prepares ${tableName} graph-sync insert payloads for runner execution.`,
|
|
8720
|
+
{
|
|
8721
|
+
register: false,
|
|
8722
|
+
isHidden: true
|
|
8723
|
+
}
|
|
8724
|
+
).doOn(executionRequestedSignal).emitsOnFail(executionFailedSignal);
|
|
8725
|
+
const finalizeExecutionTask = CadenzaService.createMetaTask(
|
|
8726
|
+
`Finalize graph sync insert execution for ${tableName}`,
|
|
8727
|
+
(ctx, emit) => {
|
|
8728
|
+
if (!ctx.__resolverRequestId) {
|
|
8489
8729
|
return false;
|
|
8490
8730
|
}
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8731
|
+
emit(executionResolvedSignal, ctx);
|
|
8732
|
+
return ctx;
|
|
8733
|
+
},
|
|
8734
|
+
`Resolves signal-driven ${tableName} graph-sync insert execution.`,
|
|
8735
|
+
{
|
|
8736
|
+
register: false,
|
|
8737
|
+
isHidden: true
|
|
8738
|
+
}
|
|
8739
|
+
);
|
|
8740
|
+
targetTask.then(finalizeExecutionTask).emitsOnFail(executionFailedSignal);
|
|
8741
|
+
prepareExecutionTask.then(targetTask);
|
|
8742
|
+
return CadenzaService.createUniqueMetaTask(
|
|
8743
|
+
`Resolve graph sync insert for ${tableName}`,
|
|
8744
|
+
(ctx, emit) => new Promise((resolve) => {
|
|
8745
|
+
const resolverRequestId = (0, import_uuid6.v4)();
|
|
8746
|
+
CadenzaService.createEphemeralMetaTask(
|
|
8747
|
+
`Resolve graph sync insert execution for ${tableName} (${resolverRequestId})`,
|
|
8748
|
+
(resultCtx) => {
|
|
8749
|
+
if (resultCtx.__resolverRequestId !== resolverRequestId) {
|
|
8750
|
+
return false;
|
|
8751
|
+
}
|
|
8752
|
+
const normalizedResult = {
|
|
8753
|
+
...resultCtx
|
|
8754
|
+
};
|
|
8755
|
+
delete normalizedResult.__resolverRequestId;
|
|
8756
|
+
resolve(normalizedResult);
|
|
8757
|
+
return normalizedResult;
|
|
8758
|
+
},
|
|
8759
|
+
`Waits for signal-driven ${tableName} graph-sync insert execution.`,
|
|
8502
8760
|
{
|
|
8503
|
-
|
|
8504
|
-
routineExecId: ctx.__routineExecId ?? ctx.__metadata?.__routineExecId ?? ctx.__metadata?.__localRoutineExecId ?? "graph-sync"
|
|
8761
|
+
register: false
|
|
8505
8762
|
}
|
|
8506
|
-
);
|
|
8507
|
-
|
|
8763
|
+
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
8764
|
+
emit(executionRequestedSignal, {
|
|
8765
|
+
...ctx,
|
|
8766
|
+
__resolverRequestId: resolverRequestId
|
|
8767
|
+
});
|
|
8768
|
+
}),
|
|
8508
8769
|
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
8509
8770
|
{
|
|
8510
8771
|
...options,
|
|
@@ -9809,12 +10070,12 @@ var CadenzaService = class {
|
|
|
9809
10070
|
static bootstrap() {
|
|
9810
10071
|
if (this.isBootstrapped) return;
|
|
9811
10072
|
this.isBootstrapped = true;
|
|
9812
|
-
|
|
9813
|
-
this.signalBroker =
|
|
9814
|
-
this.inquiryBroker =
|
|
9815
|
-
this.runner =
|
|
9816
|
-
this.metaRunner =
|
|
9817
|
-
this.registry =
|
|
10073
|
+
import_core5.default.bootstrap();
|
|
10074
|
+
this.signalBroker = import_core5.default.signalBroker;
|
|
10075
|
+
this.inquiryBroker = import_core5.default.inquiryBroker;
|
|
10076
|
+
this.runner = import_core5.default.runner;
|
|
10077
|
+
this.metaRunner = import_core5.default.metaRunner;
|
|
10078
|
+
this.registry = import_core5.default.registry;
|
|
9818
10079
|
this.serviceRegistry = ServiceRegistry.instance;
|
|
9819
10080
|
RestController.instance;
|
|
9820
10081
|
SocketController.instance;
|
|
@@ -9848,15 +10109,15 @@ var CadenzaService = class {
|
|
|
9848
10109
|
return;
|
|
9849
10110
|
}
|
|
9850
10111
|
this.frontendSyncScheduled = true;
|
|
9851
|
-
|
|
9852
|
-
|
|
10112
|
+
import_core5.default.interval("meta.sync_requested", { __syncing: false }, 18e4);
|
|
10113
|
+
import_core5.default.schedule("meta.sync_requested", { __syncing: false }, 250);
|
|
9853
10114
|
}
|
|
9854
10115
|
static normalizeDeclaredTransports(transports, serviceId) {
|
|
9855
10116
|
return (transports ?? []).map((transport) => normalizeServiceTransportConfig(transport)).filter(
|
|
9856
10117
|
(transport) => !!transport
|
|
9857
10118
|
).map((transport) => ({
|
|
9858
10119
|
...transport,
|
|
9859
|
-
uuid: (0,
|
|
10120
|
+
uuid: (0, import_uuid7.v4)()
|
|
9860
10121
|
}));
|
|
9861
10122
|
}
|
|
9862
10123
|
static createBootstrapTransport(serviceInstanceId, role, endpoint) {
|
|
@@ -9906,7 +10167,7 @@ var CadenzaService = class {
|
|
|
9906
10167
|
* @return {void} Does not return any value.
|
|
9907
10168
|
*/
|
|
9908
10169
|
static validateName(name) {
|
|
9909
|
-
|
|
10170
|
+
import_core5.default.validateName(name);
|
|
9910
10171
|
}
|
|
9911
10172
|
/**
|
|
9912
10173
|
* Gets the current run strategy from the Cadenza configuration.
|
|
@@ -9914,7 +10175,7 @@ var CadenzaService = class {
|
|
|
9914
10175
|
* @return {Function} The run strategy function defined in the Cadenza configuration.
|
|
9915
10176
|
*/
|
|
9916
10177
|
static get runStrategy() {
|
|
9917
|
-
return
|
|
10178
|
+
return import_core5.default.runStrategy;
|
|
9918
10179
|
}
|
|
9919
10180
|
/**
|
|
9920
10181
|
* Sets the mode for the Cadenza application.
|
|
@@ -9923,7 +10184,7 @@ var CadenzaService = class {
|
|
|
9923
10184
|
* @return {void} This method does not return a value.
|
|
9924
10185
|
*/
|
|
9925
10186
|
static setMode(mode) {
|
|
9926
|
-
|
|
10187
|
+
import_core5.default.setMode(mode);
|
|
9927
10188
|
}
|
|
9928
10189
|
/**
|
|
9929
10190
|
* Emits a signal with the specified data using the associated broker.
|
|
@@ -9941,16 +10202,16 @@ var CadenzaService = class {
|
|
|
9941
10202
|
* ```
|
|
9942
10203
|
*/
|
|
9943
10204
|
static emit(signal, data = {}, options = {}) {
|
|
9944
|
-
|
|
10205
|
+
import_core5.default.emit(signal, data, options);
|
|
9945
10206
|
}
|
|
9946
10207
|
static debounce(signal, context = {}, delayMs = 500) {
|
|
9947
|
-
|
|
10208
|
+
import_core5.default.debounce(signal, context, delayMs);
|
|
9948
10209
|
}
|
|
9949
10210
|
static schedule(signal, context, timeoutMs, exactDateTime) {
|
|
9950
|
-
|
|
10211
|
+
import_core5.default.schedule(signal, context, timeoutMs, exactDateTime);
|
|
9951
10212
|
}
|
|
9952
10213
|
static interval(signal, context, intervalMs, leading = false, startDateTime) {
|
|
9953
|
-
|
|
10214
|
+
import_core5.default.interval(signal, context, intervalMs, leading, startDateTime);
|
|
9954
10215
|
}
|
|
9955
10216
|
static defineIntent(intent) {
|
|
9956
10217
|
this.inquiryBroker?.addIntent(intent);
|
|
@@ -10108,7 +10369,7 @@ var CadenzaService = class {
|
|
|
10108
10369
|
}
|
|
10109
10370
|
for (const responder of responders) {
|
|
10110
10371
|
const { task, descriptor } = responder;
|
|
10111
|
-
const inquiryId = (0,
|
|
10372
|
+
const inquiryId = (0, import_uuid7.v4)();
|
|
10112
10373
|
startTimeByTask.set(task, Date.now());
|
|
10113
10374
|
const resolverTask = this.createEphemeralMetaTask(
|
|
10114
10375
|
`Resolve inquiry ${inquiry} for ${descriptor.localTaskName}`,
|
|
@@ -10212,7 +10473,7 @@ var CadenzaService = class {
|
|
|
10212
10473
|
});
|
|
10213
10474
|
}
|
|
10214
10475
|
static get(taskName) {
|
|
10215
|
-
return
|
|
10476
|
+
return import_core5.default.get(taskName);
|
|
10216
10477
|
}
|
|
10217
10478
|
static getLocalCadenzaDBTask(tableName, operation) {
|
|
10218
10479
|
const generatedTaskName = this.buildGeneratedLocalCadenzaDBTaskName(
|
|
@@ -10223,7 +10484,7 @@ var CadenzaService = class {
|
|
|
10223
10484
|
tableName,
|
|
10224
10485
|
operation
|
|
10225
10486
|
);
|
|
10226
|
-
return
|
|
10487
|
+
return import_core5.default.get(generatedTaskName) ?? import_core5.default.get(legacyTaskName);
|
|
10227
10488
|
}
|
|
10228
10489
|
static getLocalCadenzaDBInsertTask(tableName) {
|
|
10229
10490
|
return this.getLocalCadenzaDBTask(tableName, "insert");
|
|
@@ -10232,15 +10493,15 @@ var CadenzaService = class {
|
|
|
10232
10493
|
return this.getLocalCadenzaDBTask(tableName, "query");
|
|
10233
10494
|
}
|
|
10234
10495
|
static getActor(actorName) {
|
|
10235
|
-
const cadenzaWithActors =
|
|
10496
|
+
const cadenzaWithActors = import_core5.default;
|
|
10236
10497
|
return cadenzaWithActors.getActor?.(actorName);
|
|
10237
10498
|
}
|
|
10238
10499
|
static getAllActors() {
|
|
10239
|
-
const cadenzaWithActors =
|
|
10500
|
+
const cadenzaWithActors = import_core5.default;
|
|
10240
10501
|
return cadenzaWithActors.getAllActors?.() ?? [];
|
|
10241
10502
|
}
|
|
10242
10503
|
static getRoutine(routineName) {
|
|
10243
|
-
return
|
|
10504
|
+
return import_core5.default.getRoutine(routineName);
|
|
10244
10505
|
}
|
|
10245
10506
|
/**
|
|
10246
10507
|
* Creates a new DeputyTask instance based on the provided routine name, service name, and options.
|
|
@@ -10616,7 +10877,7 @@ var CadenzaService = class {
|
|
|
10616
10877
|
this.bootstrap();
|
|
10617
10878
|
this.validateName(serviceName);
|
|
10618
10879
|
this.validateServiceName(serviceName);
|
|
10619
|
-
const serviceId = options.customServiceId ?? (0,
|
|
10880
|
+
const serviceId = options.customServiceId ?? (0, import_uuid7.v4)();
|
|
10620
10881
|
this.serviceRegistry.serviceName = serviceName;
|
|
10621
10882
|
this.serviceRegistry.serviceInstanceId = serviceId;
|
|
10622
10883
|
this.setHydrationResults(options.hydration);
|
|
@@ -10753,7 +11014,7 @@ var CadenzaService = class {
|
|
|
10753
11014
|
"global.meta.cadenza_db.gathered_sync_data",
|
|
10754
11015
|
ctx.serviceName
|
|
10755
11016
|
);
|
|
10756
|
-
}).doOn("meta.rest.handshake");
|
|
11017
|
+
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
10757
11018
|
}
|
|
10758
11019
|
this.createMetaTask("Handle service setup completion", () => {
|
|
10759
11020
|
if (isFrontend) {
|
|
@@ -10768,7 +11029,7 @@ var CadenzaService = class {
|
|
|
10768
11029
|
return true;
|
|
10769
11030
|
}).doOn("meta.service_registry.instance_inserted");
|
|
10770
11031
|
if (!options.cadenzaDB?.connect && isFrontend) {
|
|
10771
|
-
|
|
11032
|
+
import_core5.default.schedule(
|
|
10772
11033
|
"meta.service_registry.instance_registration_requested",
|
|
10773
11034
|
{
|
|
10774
11035
|
data: {
|
|
@@ -11029,11 +11290,11 @@ var CadenzaService = class {
|
|
|
11029
11290
|
}
|
|
11030
11291
|
static createActor(spec, options = {}) {
|
|
11031
11292
|
this.bootstrap();
|
|
11032
|
-
return
|
|
11293
|
+
return import_core5.default.createActor(spec, options);
|
|
11033
11294
|
}
|
|
11034
11295
|
static createActorFromDefinition(definition, options = {}) {
|
|
11035
11296
|
this.bootstrap();
|
|
11036
|
-
return
|
|
11297
|
+
return import_core5.default.createActorFromDefinition(definition, options);
|
|
11037
11298
|
}
|
|
11038
11299
|
/**
|
|
11039
11300
|
* Creates and registers a new task with the provided name, function, and optional details.
|
|
@@ -11107,7 +11368,7 @@ var CadenzaService = class {
|
|
|
11107
11368
|
*/
|
|
11108
11369
|
static createTask(name, func, description, options = {}) {
|
|
11109
11370
|
this.bootstrap();
|
|
11110
|
-
return
|
|
11371
|
+
return import_core5.default.createTask(name, func, description, options);
|
|
11111
11372
|
}
|
|
11112
11373
|
/**
|
|
11113
11374
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
@@ -11123,7 +11384,7 @@ var CadenzaService = class {
|
|
|
11123
11384
|
*/
|
|
11124
11385
|
static createMetaTask(name, func, description, options = {}) {
|
|
11125
11386
|
this.bootstrap();
|
|
11126
|
-
return
|
|
11387
|
+
return import_core5.default.createMetaTask(name, func, description, options);
|
|
11127
11388
|
}
|
|
11128
11389
|
/**
|
|
11129
11390
|
* Creates a unique task by wrapping the provided task function with a uniqueness constraint.
|
|
@@ -11173,7 +11434,7 @@ var CadenzaService = class {
|
|
|
11173
11434
|
*/
|
|
11174
11435
|
static createUniqueTask(name, func, description, options = {}) {
|
|
11175
11436
|
this.bootstrap();
|
|
11176
|
-
return
|
|
11437
|
+
return import_core5.default.createUniqueTask(name, func, description, options);
|
|
11177
11438
|
}
|
|
11178
11439
|
/**
|
|
11179
11440
|
* Creates a unique meta task with the specified name, function, description, and options.
|
|
@@ -11187,7 +11448,7 @@ var CadenzaService = class {
|
|
|
11187
11448
|
*/
|
|
11188
11449
|
static createUniqueMetaTask(name, func, description, options = {}) {
|
|
11189
11450
|
this.bootstrap();
|
|
11190
|
-
return
|
|
11451
|
+
return import_core5.default.createUniqueMetaTask(name, func, description, options);
|
|
11191
11452
|
}
|
|
11192
11453
|
/**
|
|
11193
11454
|
* 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.
|
|
@@ -11220,7 +11481,7 @@ var CadenzaService = class {
|
|
|
11220
11481
|
*/
|
|
11221
11482
|
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
11222
11483
|
this.bootstrap();
|
|
11223
|
-
return
|
|
11484
|
+
return import_core5.default.createThrottledTask(
|
|
11224
11485
|
name,
|
|
11225
11486
|
func,
|
|
11226
11487
|
throttledIdGetter,
|
|
@@ -11241,7 +11502,7 @@ var CadenzaService = class {
|
|
|
11241
11502
|
*/
|
|
11242
11503
|
static createThrottledMetaTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
11243
11504
|
this.bootstrap();
|
|
11244
|
-
return
|
|
11505
|
+
return import_core5.default.createThrottledMetaTask(
|
|
11245
11506
|
name,
|
|
11246
11507
|
func,
|
|
11247
11508
|
throttledIdGetter,
|
|
@@ -11284,7 +11545,7 @@ var CadenzaService = class {
|
|
|
11284
11545
|
*/
|
|
11285
11546
|
static createDebounceTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
11286
11547
|
this.bootstrap();
|
|
11287
|
-
return
|
|
11548
|
+
return import_core5.default.createDebounceTask(
|
|
11288
11549
|
name,
|
|
11289
11550
|
func,
|
|
11290
11551
|
description,
|
|
@@ -11305,7 +11566,7 @@ var CadenzaService = class {
|
|
|
11305
11566
|
*/
|
|
11306
11567
|
static createDebounceMetaTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
11307
11568
|
this.bootstrap();
|
|
11308
|
-
return
|
|
11569
|
+
return import_core5.default.createDebounceMetaTask(
|
|
11309
11570
|
name,
|
|
11310
11571
|
func,
|
|
11311
11572
|
description,
|
|
@@ -11375,7 +11636,7 @@ var CadenzaService = class {
|
|
|
11375
11636
|
*/
|
|
11376
11637
|
static createEphemeralTask(name, func, description, options = {}) {
|
|
11377
11638
|
this.bootstrap();
|
|
11378
|
-
return
|
|
11639
|
+
return import_core5.default.createEphemeralTask(name, func, description, options);
|
|
11379
11640
|
}
|
|
11380
11641
|
/**
|
|
11381
11642
|
* Creates an ephemeral meta-task with the specified name, function, description, and options.
|
|
@@ -11389,7 +11650,7 @@ var CadenzaService = class {
|
|
|
11389
11650
|
*/
|
|
11390
11651
|
static createEphemeralMetaTask(name, func, description, options = {}) {
|
|
11391
11652
|
this.bootstrap();
|
|
11392
|
-
return
|
|
11653
|
+
return import_core5.default.createEphemeralMetaTask(name, func, description, options);
|
|
11393
11654
|
}
|
|
11394
11655
|
/**
|
|
11395
11656
|
* Creates a new routine with the specified name, tasks, and an optional description.
|
|
@@ -11421,7 +11682,7 @@ var CadenzaService = class {
|
|
|
11421
11682
|
*/
|
|
11422
11683
|
static createRoutine(name, tasks, description = "") {
|
|
11423
11684
|
this.bootstrap();
|
|
11424
|
-
return
|
|
11685
|
+
return import_core5.default.createRoutine(name, tasks, description);
|
|
11425
11686
|
}
|
|
11426
11687
|
/**
|
|
11427
11688
|
* Creates a meta routine with a given name, tasks, and optional description.
|
|
@@ -11436,10 +11697,10 @@ var CadenzaService = class {
|
|
|
11436
11697
|
*/
|
|
11437
11698
|
static createMetaRoutine(name, tasks, description = "") {
|
|
11438
11699
|
this.bootstrap();
|
|
11439
|
-
return
|
|
11700
|
+
return import_core5.default.createMetaRoutine(name, tasks, description);
|
|
11440
11701
|
}
|
|
11441
11702
|
static reset() {
|
|
11442
|
-
|
|
11703
|
+
import_core5.default.reset();
|
|
11443
11704
|
this.serviceRegistry?.reset();
|
|
11444
11705
|
this.isBootstrapped = false;
|
|
11445
11706
|
this.serviceCreated = false;
|
|
@@ -11457,10 +11718,10 @@ CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
|
11457
11718
|
CadenzaService.frontendSyncScheduled = false;
|
|
11458
11719
|
|
|
11459
11720
|
// src/index.ts
|
|
11460
|
-
var
|
|
11721
|
+
var import_core6 = require("@cadenza.io/core");
|
|
11461
11722
|
|
|
11462
11723
|
// src/ssr/createSSRInquiryBridge.ts
|
|
11463
|
-
var
|
|
11724
|
+
var import_uuid8 = require("uuid");
|
|
11464
11725
|
function ensureFetch() {
|
|
11465
11726
|
if (typeof globalThis.fetch !== "function") {
|
|
11466
11727
|
throw new Error("SSR inquiry bridge requires global fetch support.");
|
|
@@ -11549,7 +11810,7 @@ function createSSRInquiryBridge(options = {}) {
|
|
|
11549
11810
|
__remoteRoutineName: remoteRoutineName,
|
|
11550
11811
|
__metadata: {
|
|
11551
11812
|
...context.__metadata ?? {},
|
|
11552
|
-
__deputyExecId: (0,
|
|
11813
|
+
__deputyExecId: (0, import_uuid8.v4)()
|
|
11553
11814
|
}
|
|
11554
11815
|
}),
|
|
11555
11816
|
signal
|