@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/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) {
|
|
@@ -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 uuid8 = 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 (uuid8 === 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 === uuid8);
|
|
1162
|
+
const indexToDelete = this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid8) ?? -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(uuid8, 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 === uuid8);
|
|
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 === uuid8);
|
|
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, uuid8, 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: uuid8,
|
|
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: uuid8,
|
|
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(
|
|
@@ -4099,6 +4199,35 @@ var SocketController = class _SocketController {
|
|
|
4099
4199
|
},
|
|
4100
4200
|
{ isMeta: true }
|
|
4101
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);
|
|
4102
4231
|
this.registerDiagnosticsTasks();
|
|
4103
4232
|
this.registerSocketServerTasks();
|
|
4104
4233
|
this.registerSocketClientTasks();
|
|
@@ -4342,8 +4471,56 @@ var SocketController = class _SocketController {
|
|
|
4342
4471
|
});
|
|
4343
4472
|
if (ctx.isFrontend) {
|
|
4344
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();
|
|
4345
4478
|
CadenzaService.createMetaTask(
|
|
4346
|
-
|
|
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,
|
|
4347
4524
|
(c, emitter) => {
|
|
4348
4525
|
if (c.__signalName === void 0) {
|
|
4349
4526
|
return;
|
|
@@ -4808,10 +4985,54 @@ var SocketController = class _SocketController {
|
|
|
4808
4985
|
delegationCtx
|
|
4809
4986
|
);
|
|
4810
4987
|
});
|
|
4811
|
-
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) => {
|
|
4812
5019
|
if (CadenzaService.signalBroker.listObservedSignals().includes(signalCtx.__signalName)) {
|
|
5020
|
+
callback?.({
|
|
5021
|
+
__status: "success",
|
|
5022
|
+
__signalName: signalCtx.__signalName
|
|
5023
|
+
});
|
|
4813
5024
|
CadenzaService.emit(signalCtx.__signalName, signalCtx);
|
|
5025
|
+
return;
|
|
4814
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));
|
|
4815
5036
|
});
|
|
4816
5037
|
socket.on("status_update", (status) => {
|
|
4817
5038
|
CadenzaService.emit("meta.socket_client.status_received", status);
|
|
@@ -5481,7 +5702,7 @@ var SignalController = class _SignalController {
|
|
|
5481
5702
|
};
|
|
5482
5703
|
|
|
5483
5704
|
// src/graph/controllers/registerActorSessionPersistence.ts
|
|
5484
|
-
var
|
|
5705
|
+
var import_core3 = require("@cadenza.io/core");
|
|
5485
5706
|
function registerActorSessionPersistenceTasks() {
|
|
5486
5707
|
if (CadenzaService.get("Persist actor session state")) {
|
|
5487
5708
|
return;
|
|
@@ -5602,7 +5823,7 @@ function registerActorSessionPersistenceTasks() {
|
|
|
5602
5823
|
},
|
|
5603
5824
|
"Validates and prepares actor_session_state payload for strict write-through persistence.",
|
|
5604
5825
|
{ isSubMeta: true, concurrency: 100 }
|
|
5605
|
-
).then(insertAndValidateActorSessionStateTask).respondsTo(
|
|
5826
|
+
).then(insertAndValidateActorSessionStateTask).respondsTo(import_core3.META_ACTOR_SESSION_STATE_PERSIST_INTENT);
|
|
5606
5827
|
}
|
|
5607
5828
|
|
|
5608
5829
|
// src/graph/controllers/GraphMetadataController.ts
|
|
@@ -5886,10 +6107,11 @@ var DatabaseController = class _DatabaseController {
|
|
|
5886
6107
|
};
|
|
5887
6108
|
|
|
5888
6109
|
// src/Cadenza.ts
|
|
5889
|
-
var
|
|
6110
|
+
var import_uuid6 = require("uuid");
|
|
5890
6111
|
|
|
5891
6112
|
// src/graph/controllers/GraphSyncController.ts
|
|
5892
|
-
var
|
|
6113
|
+
var import_core4 = require("@cadenza.io/core");
|
|
6114
|
+
var import_uuid5 = require("uuid");
|
|
5893
6115
|
var ACTOR_TASK_METADATA = /* @__PURE__ */ Symbol.for("@cadenza.io/core/actor-task-meta");
|
|
5894
6116
|
function getActorTaskRuntimeMetadata(taskFunction) {
|
|
5895
6117
|
if (typeof taskFunction !== "function") {
|
|
@@ -5955,7 +6177,7 @@ function resolveSyncServiceName(task) {
|
|
|
5955
6177
|
return taskServiceName || registryServiceName || void 0;
|
|
5956
6178
|
}
|
|
5957
6179
|
function isLocalOnlySyncIntent(intentName) {
|
|
5958
|
-
return intentName ===
|
|
6180
|
+
return intentName === import_core4.META_ACTOR_SESSION_STATE_PERSIST_INTENT;
|
|
5959
6181
|
}
|
|
5960
6182
|
function buildIntentRegistryData(intent) {
|
|
5961
6183
|
const name = String(intent?.name ?? "").trim();
|
|
@@ -6023,30 +6245,69 @@ function resolveSyncInsertTask(isCadenzaDBReady, tableName, queryData = {}, opti
|
|
|
6023
6245
|
if (!localInsertTask && !remoteInsertTask) {
|
|
6024
6246
|
return void 0;
|
|
6025
6247
|
}
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
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) {
|
|
6031
6271
|
return false;
|
|
6032
6272
|
}
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
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.`,
|
|
6044
6302
|
{
|
|
6045
|
-
|
|
6046
|
-
routineExecId: ctx.__routineExecId ?? ctx.__metadata?.__routineExecId ?? ctx.__metadata?.__localRoutineExecId ?? "graph-sync"
|
|
6303
|
+
register: false
|
|
6047
6304
|
}
|
|
6048
|
-
);
|
|
6049
|
-
|
|
6305
|
+
).doOn(executionResolvedSignal, executionFailedSignal);
|
|
6306
|
+
emit(executionRequestedSignal, {
|
|
6307
|
+
...ctx,
|
|
6308
|
+
__resolverRequestId: resolverRequestId
|
|
6309
|
+
});
|
|
6310
|
+
}),
|
|
6050
6311
|
`Routes graph sync inserts for ${tableName} through the local authority task when available.`,
|
|
6051
6312
|
{
|
|
6052
6313
|
...options,
|
|
@@ -7351,12 +7612,12 @@ var CadenzaService = class {
|
|
|
7351
7612
|
static bootstrap() {
|
|
7352
7613
|
if (this.isBootstrapped) return;
|
|
7353
7614
|
this.isBootstrapped = true;
|
|
7354
|
-
|
|
7355
|
-
this.signalBroker =
|
|
7356
|
-
this.inquiryBroker =
|
|
7357
|
-
this.runner =
|
|
7358
|
-
this.metaRunner =
|
|
7359
|
-
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;
|
|
7360
7621
|
this.serviceRegistry = ServiceRegistry.instance;
|
|
7361
7622
|
RestController.instance;
|
|
7362
7623
|
SocketController.instance;
|
|
@@ -7390,15 +7651,15 @@ var CadenzaService = class {
|
|
|
7390
7651
|
return;
|
|
7391
7652
|
}
|
|
7392
7653
|
this.frontendSyncScheduled = true;
|
|
7393
|
-
|
|
7394
|
-
|
|
7654
|
+
import_core5.default.interval("meta.sync_requested", { __syncing: false }, 18e4);
|
|
7655
|
+
import_core5.default.schedule("meta.sync_requested", { __syncing: false }, 250);
|
|
7395
7656
|
}
|
|
7396
7657
|
static normalizeDeclaredTransports(transports, serviceId) {
|
|
7397
7658
|
return (transports ?? []).map((transport) => normalizeServiceTransportConfig(transport)).filter(
|
|
7398
7659
|
(transport) => !!transport
|
|
7399
7660
|
).map((transport) => ({
|
|
7400
7661
|
...transport,
|
|
7401
|
-
uuid: (0,
|
|
7662
|
+
uuid: (0, import_uuid6.v4)()
|
|
7402
7663
|
}));
|
|
7403
7664
|
}
|
|
7404
7665
|
static createBootstrapTransport(serviceInstanceId, role, endpoint) {
|
|
@@ -7448,7 +7709,7 @@ var CadenzaService = class {
|
|
|
7448
7709
|
* @return {void} Does not return any value.
|
|
7449
7710
|
*/
|
|
7450
7711
|
static validateName(name) {
|
|
7451
|
-
|
|
7712
|
+
import_core5.default.validateName(name);
|
|
7452
7713
|
}
|
|
7453
7714
|
/**
|
|
7454
7715
|
* Gets the current run strategy from the Cadenza configuration.
|
|
@@ -7456,7 +7717,7 @@ var CadenzaService = class {
|
|
|
7456
7717
|
* @return {Function} The run strategy function defined in the Cadenza configuration.
|
|
7457
7718
|
*/
|
|
7458
7719
|
static get runStrategy() {
|
|
7459
|
-
return
|
|
7720
|
+
return import_core5.default.runStrategy;
|
|
7460
7721
|
}
|
|
7461
7722
|
/**
|
|
7462
7723
|
* Sets the mode for the Cadenza application.
|
|
@@ -7465,7 +7726,7 @@ var CadenzaService = class {
|
|
|
7465
7726
|
* @return {void} This method does not return a value.
|
|
7466
7727
|
*/
|
|
7467
7728
|
static setMode(mode) {
|
|
7468
|
-
|
|
7729
|
+
import_core5.default.setMode(mode);
|
|
7469
7730
|
}
|
|
7470
7731
|
/**
|
|
7471
7732
|
* Emits a signal with the specified data using the associated broker.
|
|
@@ -7483,16 +7744,16 @@ var CadenzaService = class {
|
|
|
7483
7744
|
* ```
|
|
7484
7745
|
*/
|
|
7485
7746
|
static emit(signal, data = {}, options = {}) {
|
|
7486
|
-
|
|
7747
|
+
import_core5.default.emit(signal, data, options);
|
|
7487
7748
|
}
|
|
7488
7749
|
static debounce(signal, context = {}, delayMs = 500) {
|
|
7489
|
-
|
|
7750
|
+
import_core5.default.debounce(signal, context, delayMs);
|
|
7490
7751
|
}
|
|
7491
7752
|
static schedule(signal, context, timeoutMs, exactDateTime) {
|
|
7492
|
-
|
|
7753
|
+
import_core5.default.schedule(signal, context, timeoutMs, exactDateTime);
|
|
7493
7754
|
}
|
|
7494
7755
|
static interval(signal, context, intervalMs, leading = false, startDateTime) {
|
|
7495
|
-
|
|
7756
|
+
import_core5.default.interval(signal, context, intervalMs, leading, startDateTime);
|
|
7496
7757
|
}
|
|
7497
7758
|
static defineIntent(intent) {
|
|
7498
7759
|
this.inquiryBroker?.addIntent(intent);
|
|
@@ -7650,7 +7911,7 @@ var CadenzaService = class {
|
|
|
7650
7911
|
}
|
|
7651
7912
|
for (const responder of responders) {
|
|
7652
7913
|
const { task, descriptor } = responder;
|
|
7653
|
-
const inquiryId = (0,
|
|
7914
|
+
const inquiryId = (0, import_uuid6.v4)();
|
|
7654
7915
|
startTimeByTask.set(task, Date.now());
|
|
7655
7916
|
const resolverTask = this.createEphemeralMetaTask(
|
|
7656
7917
|
`Resolve inquiry ${inquiry} for ${descriptor.localTaskName}`,
|
|
@@ -7754,7 +8015,7 @@ var CadenzaService = class {
|
|
|
7754
8015
|
});
|
|
7755
8016
|
}
|
|
7756
8017
|
static get(taskName) {
|
|
7757
|
-
return
|
|
8018
|
+
return import_core5.default.get(taskName);
|
|
7758
8019
|
}
|
|
7759
8020
|
static getLocalCadenzaDBTask(tableName, operation) {
|
|
7760
8021
|
const generatedTaskName = this.buildGeneratedLocalCadenzaDBTaskName(
|
|
@@ -7765,7 +8026,7 @@ var CadenzaService = class {
|
|
|
7765
8026
|
tableName,
|
|
7766
8027
|
operation
|
|
7767
8028
|
);
|
|
7768
|
-
return
|
|
8029
|
+
return import_core5.default.get(generatedTaskName) ?? import_core5.default.get(legacyTaskName);
|
|
7769
8030
|
}
|
|
7770
8031
|
static getLocalCadenzaDBInsertTask(tableName) {
|
|
7771
8032
|
return this.getLocalCadenzaDBTask(tableName, "insert");
|
|
@@ -7774,15 +8035,15 @@ var CadenzaService = class {
|
|
|
7774
8035
|
return this.getLocalCadenzaDBTask(tableName, "query");
|
|
7775
8036
|
}
|
|
7776
8037
|
static getActor(actorName) {
|
|
7777
|
-
const cadenzaWithActors =
|
|
8038
|
+
const cadenzaWithActors = import_core5.default;
|
|
7778
8039
|
return cadenzaWithActors.getActor?.(actorName);
|
|
7779
8040
|
}
|
|
7780
8041
|
static getAllActors() {
|
|
7781
|
-
const cadenzaWithActors =
|
|
8042
|
+
const cadenzaWithActors = import_core5.default;
|
|
7782
8043
|
return cadenzaWithActors.getAllActors?.() ?? [];
|
|
7783
8044
|
}
|
|
7784
8045
|
static getRoutine(routineName) {
|
|
7785
|
-
return
|
|
8046
|
+
return import_core5.default.getRoutine(routineName);
|
|
7786
8047
|
}
|
|
7787
8048
|
/**
|
|
7788
8049
|
* Creates a new DeputyTask instance based on the provided routine name, service name, and options.
|
|
@@ -8158,7 +8419,7 @@ var CadenzaService = class {
|
|
|
8158
8419
|
this.bootstrap();
|
|
8159
8420
|
this.validateName(serviceName);
|
|
8160
8421
|
this.validateServiceName(serviceName);
|
|
8161
|
-
const serviceId = options.customServiceId ?? (0,
|
|
8422
|
+
const serviceId = options.customServiceId ?? (0, import_uuid6.v4)();
|
|
8162
8423
|
this.serviceRegistry.serviceName = serviceName;
|
|
8163
8424
|
this.serviceRegistry.serviceInstanceId = serviceId;
|
|
8164
8425
|
this.setHydrationResults(options.hydration);
|
|
@@ -8295,7 +8556,7 @@ var CadenzaService = class {
|
|
|
8295
8556
|
"global.meta.cadenza_db.gathered_sync_data",
|
|
8296
8557
|
ctx.serviceName
|
|
8297
8558
|
);
|
|
8298
|
-
}).doOn("meta.rest.handshake");
|
|
8559
|
+
}).doOn("meta.rest.handshake", "meta.socket.handshake");
|
|
8299
8560
|
}
|
|
8300
8561
|
this.createMetaTask("Handle service setup completion", () => {
|
|
8301
8562
|
if (isFrontend) {
|
|
@@ -8310,7 +8571,7 @@ var CadenzaService = class {
|
|
|
8310
8571
|
return true;
|
|
8311
8572
|
}).doOn("meta.service_registry.instance_inserted");
|
|
8312
8573
|
if (!options.cadenzaDB?.connect && isFrontend) {
|
|
8313
|
-
|
|
8574
|
+
import_core5.default.schedule(
|
|
8314
8575
|
"meta.service_registry.instance_registration_requested",
|
|
8315
8576
|
{
|
|
8316
8577
|
data: {
|
|
@@ -8571,11 +8832,11 @@ var CadenzaService = class {
|
|
|
8571
8832
|
}
|
|
8572
8833
|
static createActor(spec, options = {}) {
|
|
8573
8834
|
this.bootstrap();
|
|
8574
|
-
return
|
|
8835
|
+
return import_core5.default.createActor(spec, options);
|
|
8575
8836
|
}
|
|
8576
8837
|
static createActorFromDefinition(definition, options = {}) {
|
|
8577
8838
|
this.bootstrap();
|
|
8578
|
-
return
|
|
8839
|
+
return import_core5.default.createActorFromDefinition(definition, options);
|
|
8579
8840
|
}
|
|
8580
8841
|
/**
|
|
8581
8842
|
* Creates and registers a new task with the provided name, function, and optional details.
|
|
@@ -8649,7 +8910,7 @@ var CadenzaService = class {
|
|
|
8649
8910
|
*/
|
|
8650
8911
|
static createTask(name, func, description, options = {}) {
|
|
8651
8912
|
this.bootstrap();
|
|
8652
|
-
return
|
|
8913
|
+
return import_core5.default.createTask(name, func, description, options);
|
|
8653
8914
|
}
|
|
8654
8915
|
/**
|
|
8655
8916
|
* Creates a meta task with the specified name, functionality, description, and options.
|
|
@@ -8665,7 +8926,7 @@ var CadenzaService = class {
|
|
|
8665
8926
|
*/
|
|
8666
8927
|
static createMetaTask(name, func, description, options = {}) {
|
|
8667
8928
|
this.bootstrap();
|
|
8668
|
-
return
|
|
8929
|
+
return import_core5.default.createMetaTask(name, func, description, options);
|
|
8669
8930
|
}
|
|
8670
8931
|
/**
|
|
8671
8932
|
* Creates a unique task by wrapping the provided task function with a uniqueness constraint.
|
|
@@ -8715,7 +8976,7 @@ var CadenzaService = class {
|
|
|
8715
8976
|
*/
|
|
8716
8977
|
static createUniqueTask(name, func, description, options = {}) {
|
|
8717
8978
|
this.bootstrap();
|
|
8718
|
-
return
|
|
8979
|
+
return import_core5.default.createUniqueTask(name, func, description, options);
|
|
8719
8980
|
}
|
|
8720
8981
|
/**
|
|
8721
8982
|
* Creates a unique meta task with the specified name, function, description, and options.
|
|
@@ -8729,7 +8990,7 @@ var CadenzaService = class {
|
|
|
8729
8990
|
*/
|
|
8730
8991
|
static createUniqueMetaTask(name, func, description, options = {}) {
|
|
8731
8992
|
this.bootstrap();
|
|
8732
|
-
return
|
|
8993
|
+
return import_core5.default.createUniqueMetaTask(name, func, description, options);
|
|
8733
8994
|
}
|
|
8734
8995
|
/**
|
|
8735
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.
|
|
@@ -8762,7 +9023,7 @@ var CadenzaService = class {
|
|
|
8762
9023
|
*/
|
|
8763
9024
|
static createThrottledTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
8764
9025
|
this.bootstrap();
|
|
8765
|
-
return
|
|
9026
|
+
return import_core5.default.createThrottledTask(
|
|
8766
9027
|
name,
|
|
8767
9028
|
func,
|
|
8768
9029
|
throttledIdGetter,
|
|
@@ -8783,7 +9044,7 @@ var CadenzaService = class {
|
|
|
8783
9044
|
*/
|
|
8784
9045
|
static createThrottledMetaTask(name, func, throttledIdGetter = () => "default", description, options = {}) {
|
|
8785
9046
|
this.bootstrap();
|
|
8786
|
-
return
|
|
9047
|
+
return import_core5.default.createThrottledMetaTask(
|
|
8787
9048
|
name,
|
|
8788
9049
|
func,
|
|
8789
9050
|
throttledIdGetter,
|
|
@@ -8826,7 +9087,7 @@ var CadenzaService = class {
|
|
|
8826
9087
|
*/
|
|
8827
9088
|
static createDebounceTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
8828
9089
|
this.bootstrap();
|
|
8829
|
-
return
|
|
9090
|
+
return import_core5.default.createDebounceTask(
|
|
8830
9091
|
name,
|
|
8831
9092
|
func,
|
|
8832
9093
|
description,
|
|
@@ -8847,7 +9108,7 @@ var CadenzaService = class {
|
|
|
8847
9108
|
*/
|
|
8848
9109
|
static createDebounceMetaTask(name, func, description, debounceTime = 1e3, options = {}) {
|
|
8849
9110
|
this.bootstrap();
|
|
8850
|
-
return
|
|
9111
|
+
return import_core5.default.createDebounceMetaTask(
|
|
8851
9112
|
name,
|
|
8852
9113
|
func,
|
|
8853
9114
|
description,
|
|
@@ -8917,7 +9178,7 @@ var CadenzaService = class {
|
|
|
8917
9178
|
*/
|
|
8918
9179
|
static createEphemeralTask(name, func, description, options = {}) {
|
|
8919
9180
|
this.bootstrap();
|
|
8920
|
-
return
|
|
9181
|
+
return import_core5.default.createEphemeralTask(name, func, description, options);
|
|
8921
9182
|
}
|
|
8922
9183
|
/**
|
|
8923
9184
|
* Creates an ephemeral meta-task with the specified name, function, description, and options.
|
|
@@ -8931,7 +9192,7 @@ var CadenzaService = class {
|
|
|
8931
9192
|
*/
|
|
8932
9193
|
static createEphemeralMetaTask(name, func, description, options = {}) {
|
|
8933
9194
|
this.bootstrap();
|
|
8934
|
-
return
|
|
9195
|
+
return import_core5.default.createEphemeralMetaTask(name, func, description, options);
|
|
8935
9196
|
}
|
|
8936
9197
|
/**
|
|
8937
9198
|
* Creates a new routine with the specified name, tasks, and an optional description.
|
|
@@ -8963,7 +9224,7 @@ var CadenzaService = class {
|
|
|
8963
9224
|
*/
|
|
8964
9225
|
static createRoutine(name, tasks, description = "") {
|
|
8965
9226
|
this.bootstrap();
|
|
8966
|
-
return
|
|
9227
|
+
return import_core5.default.createRoutine(name, tasks, description);
|
|
8967
9228
|
}
|
|
8968
9229
|
/**
|
|
8969
9230
|
* Creates a meta routine with a given name, tasks, and optional description.
|
|
@@ -8978,10 +9239,10 @@ var CadenzaService = class {
|
|
|
8978
9239
|
*/
|
|
8979
9240
|
static createMetaRoutine(name, tasks, description = "") {
|
|
8980
9241
|
this.bootstrap();
|
|
8981
|
-
return
|
|
9242
|
+
return import_core5.default.createMetaRoutine(name, tasks, description);
|
|
8982
9243
|
}
|
|
8983
9244
|
static reset() {
|
|
8984
|
-
|
|
9245
|
+
import_core5.default.reset();
|
|
8985
9246
|
this.serviceRegistry?.reset();
|
|
8986
9247
|
this.isBootstrapped = false;
|
|
8987
9248
|
this.serviceCreated = false;
|
|
@@ -8999,10 +9260,10 @@ CadenzaService.hydratedInquiryResults = /* @__PURE__ */ new Map();
|
|
|
8999
9260
|
CadenzaService.frontendSyncScheduled = false;
|
|
9000
9261
|
|
|
9001
9262
|
// src/index.ts
|
|
9002
|
-
var
|
|
9263
|
+
var import_core6 = require("@cadenza.io/core");
|
|
9003
9264
|
|
|
9004
9265
|
// src/ssr/createSSRInquiryBridge.ts
|
|
9005
|
-
var
|
|
9266
|
+
var import_uuid7 = require("uuid");
|
|
9006
9267
|
function ensureFetch() {
|
|
9007
9268
|
if (typeof globalThis.fetch !== "function") {
|
|
9008
9269
|
throw new Error("SSR inquiry bridge requires global fetch support.");
|
|
@@ -9091,7 +9352,7 @@ function createSSRInquiryBridge(options = {}) {
|
|
|
9091
9352
|
__remoteRoutineName: remoteRoutineName,
|
|
9092
9353
|
__metadata: {
|
|
9093
9354
|
...context.__metadata ?? {},
|
|
9094
|
-
__deputyExecId: (0,
|
|
9355
|
+
__deputyExecId: (0, import_uuid7.v4)()
|
|
9095
9356
|
}
|
|
9096
9357
|
}),
|
|
9097
9358
|
signal
|