@voltro/client 0.85.0 → 0.87.0
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/CHANGELOG.md +5987 -0
- package/THIRD-PARTY-NOTICES.md +1125 -34
- package/dist/analyticsCatalog.js +47 -0
- package/dist/apiConnectivity.js +33 -0
- package/dist/apiRoleTransports.js +48 -0
- package/dist/apiRuntime.js +145 -0
- package/dist/apiSocketTracker.js +21 -0
- package/dist/apiSupervisor.js +136 -0
- package/dist/authRefresh.js +20 -0
- package/dist/awaitResolvedApi.js +23 -0
- package/dist/bootstrap.d.ts +1153 -0
- package/dist/bootstrap.js +8 -0
- package/dist/cellMerger.js +6 -0
- package/dist/clientDiagnostics.js +94 -0
- package/dist/clientErrorBus.js +16 -0
- package/dist/clientScheduler.js +31 -0
- package/dist/connectionPrerequisite.js +70 -0
- package/dist/connectionScope.js +47 -0
- package/dist/connectionSetupController.js +206 -0
- package/dist/createHooks.js +15 -0
- package/dist/deepLink.js +69 -0
- package/dist/filters.js +58 -0
- package/dist/form.d.ts +37 -4
- package/dist/form.js +7 -2
- package/dist/formBinding.js +325 -0
- package/dist/formData.js +127 -0
- package/dist/formFlashId.js +4 -0
- package/dist/formRejection.js +23 -0
- package/dist/formSource.js +13 -0
- package/dist/frameworkRuntimesContext.js +8 -0
- package/dist/globalContext.js +10 -0
- package/dist/index.d.ts +152 -27
- package/dist/index.js +87 -4121
- package/dist/liveRowSort.js +66 -0
- package/dist/mutationConnectionSetup.js +16 -0
- package/dist/mutationIdentity.js +10 -0
- package/dist/mutationSerialExecution.js +53 -0
- package/dist/mutationsBus.js +40 -0
- package/dist/onlineSource.js +13 -0
- package/dist/outbox.js +213 -0
- package/dist/outboxHttp.js +104 -0
- package/dist/outboxState.js +43 -0
- package/dist/permissions.js +20 -0
- package/dist/platform.js +121 -0
- package/dist/preloadSeed.js +47 -0
- package/dist/provider.js +22 -0
- package/dist/query.js +12 -2
- package/dist/recoveryCoordinator.js +195 -0
- package/dist/recoveryRetry.js +24 -0
- package/dist/richText.js +176 -0
- package/dist/rpcErrorBus.js +39 -0
- package/dist/rpcErrorKind.js +13 -0
- package/dist/runRpc.js +12 -0
- package/dist/runtime.d.ts +49 -3
- package/dist/runtime.js +16 -126
- package/dist/runtimeCapabilities.js +44 -0
- package/dist/runtimeContext.js +49 -0
- package/dist/schemaFields.js +219 -0
- package/dist/scopeMembership.js +12 -0
- package/dist/seedResolvers.js +7 -0
- package/dist/sequence.js +65 -0
- package/dist/serverRequest.js +28 -0
- package/dist/serviceClient.js +129 -0
- package/dist/squashRpcCause.js +8 -0
- package/dist/stableKey.js +21 -0
- package/dist/store.js +288 -0
- package/dist/storeStorage.js +28 -0
- package/dist/subscriptionCache.js +724 -0
- package/dist/tagWalk.js +23 -0
- package/dist/traceBus.js +10 -0
- package/dist/tracking.js +40 -0
- package/dist/uploadProgress.js +21 -0
- package/dist/useAction.js +101 -0
- package/dist/useAgent.js +53 -0
- package/dist/useAgentChat.js +43 -0
- package/dist/useAgentStream.js +64 -0
- package/dist/useApiOnline.js +14 -0
- package/dist/useCapabilityManifest.js +105 -0
- package/dist/useConnectionSetup.js +28 -0
- package/dist/useConnectionStatus.js +38 -0
- package/dist/useConnections.js +107 -0
- package/dist/useDataCopilot.js +24 -0
- package/dist/useDataTable.js +34 -0
- package/dist/useDerived.js +22 -0
- package/dist/useEvent.js +98 -0
- package/dist/useFormBinding.js +478 -0
- package/dist/useLocalQuery.js +59 -0
- package/dist/useMutation.js +214 -0
- package/dist/useOnRpcError.js +13 -0
- package/dist/usePreloadedSubscription.js +18 -0
- package/dist/usePreview.js +14 -0
- package/dist/useProvenance.js +51 -0
- package/dist/useQueryField.js +34 -0
- package/dist/useRecord.js +12 -0
- package/dist/useRefreshSubscriptions.js +22 -0
- package/dist/useResourceCan.js +18 -0
- package/dist/useResumableAgentStream.js +75 -0
- package/dist/useRpcCaller.js +17 -0
- package/dist/useSequence.js +25 -0
- package/dist/useSkeleton.js +13 -0
- package/dist/useSubscription.js +98 -0
- package/dist/useSubscriptionHealth.js +32 -0
- package/dist/useTranscription.js +51 -0
- package/dist/useUndo.js +33 -0
- package/dist/useUndoLog.js +44 -0
- package/dist/useUpload.js +296 -0
- package/dist/useWindowedSubscription.js +65 -0
- package/dist/useWorkflow.js +284 -0
- package/dist/useWorkflowRunState.js +93 -0
- package/dist/validation.js +39 -0
- package/dist/validationMessages.js +5 -0
- package/package.json +7 -2
- package/dist/authRefresh-DmfSoCca.js +0 -360
- package/dist/formData-BfpBt7BQ.js +0 -769
- package/dist/queryOnce-D5Y4V1SB.js +0 -55
- package/dist/runRpc-Zfz3w709.js +0 -1172
package/dist/runtime.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export declare interface ApiHandle {
|
|
|
60
60
|
readonly errorBus: RpcErrorBus;
|
|
61
61
|
/** Stable UI/raw transport recovery state for this logical api. */
|
|
62
62
|
readonly recovery?: RecoveryCoordinator;
|
|
63
|
+
/** Identity lifetime captured when this transport was built. */
|
|
64
|
+
readonly subjectSignal?: AbortSignal;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
export declare interface AuthRefreshHandle {
|
|
@@ -150,6 +152,8 @@ export declare interface BuildApiRuntimeOptions {
|
|
|
150
152
|
readonly generation?: number;
|
|
151
153
|
/** WebSocket URL of the api (`ws(s)://host:port/ws`). */
|
|
152
154
|
readonly wsUrl: string;
|
|
155
|
+
/** Captured deployment role endpoint manifest; partition this group's transports by tag/workload. */
|
|
156
|
+
readonly roleEndpoints?: unknown;
|
|
153
157
|
/**
|
|
154
158
|
* The api's rpc group, as the ERASED `RpcGroup.Any`.
|
|
155
159
|
*
|
|
@@ -208,6 +212,8 @@ export declare interface BuiltApiRuntime {
|
|
|
208
212
|
readonly client: RpcClient.RpcClient<Rpc.Any, RpcClientError.RpcClientError>;
|
|
209
213
|
readonly errorBus: RpcErrorBus;
|
|
210
214
|
readonly recovery: RecoveryCoordinator;
|
|
215
|
+
/** Identity lifetime captured when this transport was built. */
|
|
216
|
+
readonly subjectSignal?: AbortSignal;
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
declare interface CacheEntry {
|
|
@@ -480,6 +486,22 @@ export declare interface FrameworkRuntimes {
|
|
|
480
486
|
* keeps working; absent means "already connected", which is the safe reading.
|
|
481
487
|
*/
|
|
482
488
|
readonly demand?: (apiName: string) => void;
|
|
489
|
+
/**
|
|
490
|
+
* One read through an api's client — the browser half of a loader's
|
|
491
|
+
* `ctx.query`. Supplied by the host that builds the rpc runtime
|
|
492
|
+
* (`VoltroRuntimeProvider`), not by this context: the read reaches the rpc
|
|
493
|
+
* client and with it the Effect runtime, and an app that mounts no api must
|
|
494
|
+
* not load either just because its router can ask. Absent → `ctx.query` is
|
|
495
|
+
* `undefined` in the browser, as it is for an app without apis.
|
|
496
|
+
*/
|
|
497
|
+
readonly queryOnce?: QueryOnce;
|
|
498
|
+
/**
|
|
499
|
+
* Resolves once the rpc runtime behind these apis is loaded. A host that
|
|
500
|
+
* loads it on demand (the web boot keeps it out of an app's first load and
|
|
501
|
+
* fetches it with the first route that reads data) supplies it; absent means
|
|
502
|
+
* the runtime is already there.
|
|
503
|
+
*/
|
|
504
|
+
readonly ready?: () => Promise<void>;
|
|
483
505
|
}
|
|
484
506
|
|
|
485
507
|
/**
|
|
@@ -551,6 +573,7 @@ export declare interface MountedApi {
|
|
|
551
573
|
readonly group: RpcGroup.Any;
|
|
552
574
|
readonly descriptors: ClientDescriptorMap;
|
|
553
575
|
readonly wsUrl: string;
|
|
576
|
+
readonly roleEndpoints?: unknown;
|
|
554
577
|
readonly headers?: ResolvableHeaders | undefined;
|
|
555
578
|
readonly recovery?: RecoveryOptions | undefined;
|
|
556
579
|
/** Durable local mirror, resolved per transport generation — see
|
|
@@ -582,6 +605,14 @@ export declare const publishClientError: (event: ClientErrorEvent) => void;
|
|
|
582
605
|
/** Publish a started client trace. Cheap + sync; safe on the hot path. */
|
|
583
606
|
export declare const publishClientTrace: (event: ClientTraceEvent) => void;
|
|
584
607
|
|
|
608
|
+
/** `queryOnce`'s shape, declared here so this module stays free of it. */
|
|
609
|
+
declare type QueryOnce = (handleRef: {
|
|
610
|
+
readonly current: {
|
|
611
|
+
readonly runtime: unknown;
|
|
612
|
+
readonly client: unknown;
|
|
613
|
+
};
|
|
614
|
+
}, apiName: string, tag: string, input: Record<string, unknown> | undefined, signal?: AbortSignal) => Promise<unknown>;
|
|
615
|
+
|
|
585
616
|
export declare type RawTransportStatus = 'connected' | 'disconnected';
|
|
586
617
|
|
|
587
618
|
/** Record one payload-free transition. Safe to call on every production path. */
|
|
@@ -602,6 +633,13 @@ export declare class RecoveryCoordinator {
|
|
|
602
633
|
get options(): ResolvedRecoveryOptions;
|
|
603
634
|
/** Ends on login/logout, tenant change or API disposal, not ordinary reconnect. */
|
|
604
635
|
get subjectSignal(): AbortSignal;
|
|
636
|
+
/** Hydration values belong to the initial subject only. Once identity may
|
|
637
|
+
* have changed, a later generation/remount must obtain its own snapshot.
|
|
638
|
+
* Ordinary transport recovery does not cross this boundary. */
|
|
639
|
+
getPreloadSeedPermission: () => boolean;
|
|
640
|
+
/** A whole-cache resnapshot can follow same-socket re-authentication. Its
|
|
641
|
+
* replacement reads must not reuse the original server-rendered values. */
|
|
642
|
+
invalidatePreloadSeeds(): void;
|
|
605
643
|
getSnapshot: () => RecoverySnapshot;
|
|
606
644
|
/** The SSR / hydration snapshot — see INITIAL_RECOVERY_SNAPSHOT. Stable by
|
|
607
645
|
* reference, so both renders agree and React swaps to the live one after. */
|
|
@@ -633,7 +671,7 @@ export declare class RecoveryCoordinator {
|
|
|
633
671
|
* Disabled is final for the current generation and refuses immediately.
|
|
634
672
|
*/
|
|
635
673
|
reserveMutationReplay(startedAt: number): MutationReplayReservation | undefined;
|
|
636
|
-
waitForProtocolReady(startedAt: number): Promise<boolean>;
|
|
674
|
+
waitForProtocolReady(startedAt: number, signal?: AbortSignal): Promise<boolean>;
|
|
637
675
|
dispose(): void;
|
|
638
676
|
}
|
|
639
677
|
|
|
@@ -711,6 +749,8 @@ export declare interface ResolvedClient {
|
|
|
711
749
|
readonly client: RpcClient.RpcClient<Rpc.Any, RpcClientError.RpcClientError>;
|
|
712
750
|
readonly errorBus?: RpcErrorBus;
|
|
713
751
|
readonly recovery?: RecoveryCoordinator;
|
|
752
|
+
/** Identity lifetime captured when this transport was built. */
|
|
753
|
+
readonly subjectSignal?: AbortSignal;
|
|
714
754
|
}
|
|
715
755
|
|
|
716
756
|
export declare interface ResolvedRecoveryOptions {
|
|
@@ -874,6 +914,8 @@ export declare interface ServiceClientOptions {
|
|
|
874
914
|
/** The callee's WebSocket endpoint. A function so a late-resolved URL (dev
|
|
875
915
|
* port discovery) is read at connect time, not at construction. */
|
|
876
916
|
readonly wsUrl: string | (() => string);
|
|
917
|
+
/** Parsed deployment role endpoint manifest; captured before the lazy connect. */
|
|
918
|
+
readonly roleEndpoints?: unknown;
|
|
877
919
|
/** The service credential, read at each (re)connect. */
|
|
878
920
|
readonly token: () => string;
|
|
879
921
|
/** The callee's `serviceGroup` (erased — see `BuildApiRuntimeOptions.group`). */
|
|
@@ -1324,8 +1366,12 @@ export declare interface SupervisorHandle {
|
|
|
1324
1366
|
readonly dispose: () => void;
|
|
1325
1367
|
/** Force a fresh ws connect for every api (carrying the browser's current
|
|
1326
1368
|
* cookies) so a cookie-based login re-resolves the authenticated Subject
|
|
1327
|
-
* in place, without a page reload.
|
|
1328
|
-
|
|
1369
|
+
* in place, without a page reload. Resolves once every api runs on a
|
|
1370
|
+
* runtime built after this call (or the supervisor is gone): a call made
|
|
1371
|
+
* after that goes out as the next Subject. Never rejects; a failing build
|
|
1372
|
+
* keeps retrying and the promise waits for the one that lands. Resolves
|
|
1373
|
+
* at once for UI-only (no-api) apps. */
|
|
1374
|
+
readonly reconnect: () => Promise<void>;
|
|
1329
1375
|
/** Re-resolve `authHeaders` and rebuild the transport, SAME subject — for a
|
|
1330
1376
|
* rotated token on a long-lived tab. Unlike `reconnect()` this seeds the new
|
|
1331
1377
|
* cache from the old one, because nobody's entitlement changed. */
|
package/dist/runtime.js
CHANGED
|
@@ -1,126 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
message: "client closed"
|
|
18
|
-
}));
|
|
19
|
-
if (n !== void 0) return n;
|
|
20
|
-
let t = typeof e.wsUrl == "function" ? e.wsUrl() : e.wsUrl, r = e.webSocketConstructor ?? ((e, t) => new globalThis.WebSocket(e, typeof t == "object" && !Array.isArray(t) ? void 0 : t));
|
|
21
|
-
return n = D({
|
|
22
|
-
name: `service:${e.name}`,
|
|
23
|
-
wsUrl: t,
|
|
24
|
-
group: e.group,
|
|
25
|
-
headers: async () => ({ authorization: `Bearer ${e.token()}` }),
|
|
26
|
-
webSocketConstructor: r,
|
|
27
|
-
surfaceAudience: "service"
|
|
28
|
-
}).then((e) => (i = e, e), (e) => {
|
|
29
|
-
throw n = void 0, e;
|
|
30
|
-
}), n;
|
|
31
|
-
}, s = (t, n, r) => new z({
|
|
32
|
-
api: e.name,
|
|
33
|
-
tag: t,
|
|
34
|
-
reason: n,
|
|
35
|
-
message: r
|
|
36
|
-
}), c = (t) => {
|
|
37
|
-
let n = e.callHeaders?.() ?? {};
|
|
38
|
-
return t.pipe(M.updateService(R.CurrentHeaders, (t) => {
|
|
39
|
-
let r = L.set(t, "authorization", `Bearer ${e.token()}`);
|
|
40
|
-
for (let [e, t] of Object.entries(n)) r = L.set(r, e, t);
|
|
41
|
-
return r;
|
|
42
|
-
}));
|
|
43
|
-
}, l = (e) => e.pipe(I.filter((e) => e._tag === "snapshot" || e._tag === "error"), I.runHead, M.flatMap((e) => {
|
|
44
|
-
if (P.isNone(e)) return M.fail(/* @__PURE__ */ Error("the query stream ended before its first snapshot"));
|
|
45
|
-
let t = e.value;
|
|
46
|
-
return t._tag === "error" ? M.fail(t.error) : M.succeed(t.data);
|
|
47
|
-
})), u = (n, r, i) => {
|
|
48
|
-
let u = U(e, n), d = i?.timeoutMs ?? t, f = Date.now(), p = (t) => {
|
|
49
|
-
e.onCall?.({
|
|
50
|
-
api: e.name,
|
|
51
|
-
tag: n,
|
|
52
|
-
durationMs: Date.now() - f,
|
|
53
|
-
outcome: t
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
if (u === void 0) return M.die(/* @__PURE__ */ Error(`apis.${e.name}: '${n}' is not a service procedure of this api — is the caller built against an older contract?`));
|
|
57
|
-
let m = M.gen(function* () {
|
|
58
|
-
let t = yield* M.tryPromise({
|
|
59
|
-
try: () => o(),
|
|
60
|
-
catch: (e) => s(n, a ? "closed" : "transport", `could not build the connection: ${String(e)}`)
|
|
61
|
-
}), d = h(t.client, n);
|
|
62
|
-
if (u === "query") {
|
|
63
|
-
let e = d(r);
|
|
64
|
-
return yield* c(l(e));
|
|
65
|
-
}
|
|
66
|
-
let f = i?.idempotencyKey === void 0 && e.ambientIdempotencyKey !== void 0 ? yield* e.ambientIdempotencyKey(n, r) : void 0, p = i?.idempotencyKey ?? f ?? O();
|
|
67
|
-
return yield* c(T(d(r), p)).pipe(M.tapError((e) => M.sync(() => {
|
|
68
|
-
V(e) && (g = !0);
|
|
69
|
-
})), M.retry({
|
|
70
|
-
while: V,
|
|
71
|
-
schedule: F.spaced(j.millis(B))
|
|
72
|
-
}));
|
|
73
|
-
}), g = !1;
|
|
74
|
-
return m.pipe(M.timeoutOrElse({
|
|
75
|
-
duration: j.millis(d),
|
|
76
|
-
orElse: () => M.fail(s(n, "timeout", g ? `no answer within ${d} ms — an earlier send with this idempotency key is still in flight on the callee` : `no answer within ${d} ms`))
|
|
77
|
-
}), M.mapError((e) => e?._tag === "RpcClientError" ? s(n, "transport", String(e.message ?? e)) : e), M.tapError((e) => M.sync(() => p(e?._tag === "ApiUnavailable" ? "unavailable" : "error"))), M.tap(() => M.sync(() => p("ok"))));
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
name: e.name,
|
|
81
|
-
call: async (e, t, n) => {
|
|
82
|
-
let i = await M.runPromiseExit(u(e, t, n), n?.signal === void 0 ? void 0 : { signal: n.signal });
|
|
83
|
-
if (N.isSuccess(i)) return i.value;
|
|
84
|
-
throw r(i.cause);
|
|
85
|
-
},
|
|
86
|
-
callEffect: u,
|
|
87
|
-
subscribe: (t, n, r) => {
|
|
88
|
-
if (U(e, t) !== "query") throw Error(`apis.${e.name}: '${t}' is not a query — only a query can be subscribed to`);
|
|
89
|
-
let i, a = !1, c = -2, l;
|
|
90
|
-
return o().then((e) => {
|
|
91
|
-
if (a) return;
|
|
92
|
-
let o = [t, n], s = e.cache.subscribe(o, () => h(e.client, t)(n), e.runtime, () => {
|
|
93
|
-
let e = s.getSnapshot();
|
|
94
|
-
e.error !== void 0 && e.error !== l && (l = e.error, r.onError?.(e.error)), e.revision >= 0 && e.revision !== c && e.data !== void 0 && (c = e.revision, r.onValue(e.data));
|
|
95
|
-
});
|
|
96
|
-
i = s.unsubscribe;
|
|
97
|
-
}, (e) => {
|
|
98
|
-
r.onError?.(s(t, "transport", `could not build the connection: ${String(e)}`));
|
|
99
|
-
}), { unsubscribe: () => {
|
|
100
|
-
a = !0, i?.();
|
|
101
|
-
} };
|
|
102
|
-
},
|
|
103
|
-
connected: () => i !== void 0,
|
|
104
|
-
close: async () => {
|
|
105
|
-
a = !0;
|
|
106
|
-
let e = i;
|
|
107
|
-
i = void 0, n = void 0, e !== void 0 && (e.cache.destroy(e.runtime), await e.runtime.dispose());
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}, G = (e) => {
|
|
111
|
-
let t = (n) => {
|
|
112
|
-
let r = n.join("."), i = Object.assign((t, n) => e.call(r, t, n), {
|
|
113
|
-
effect: (t, n) => e.callEffect(r, t, n),
|
|
114
|
-
subscribe: (t, n) => e.subscribe(r, t, n)
|
|
115
|
-
});
|
|
116
|
-
return new Proxy(i, { get: (e, r) => {
|
|
117
|
-
if (typeof r == "string") {
|
|
118
|
-
if (r === "effect" || r === "subscribe") return e[r];
|
|
119
|
-
if (r !== "then") return t([...n, r]);
|
|
120
|
-
}
|
|
121
|
-
} });
|
|
122
|
-
};
|
|
123
|
-
return new Proxy({}, { get: (e, n) => typeof n == "string" && n !== "then" ? t([n]) : void 0 });
|
|
124
|
-
};
|
|
125
|
-
//#endregion
|
|
126
|
-
export { H as DEFAULT_SERVICE_CALL_TIMEOUT_MS, v as INITIAL_RECOVERY_SNAPSHOT, m as LoadingSubscriptionCache, f as RecoveryCoordinator, b as RpcErrorBus, d as SubscriptionCache, p as apiConnectivity, D as buildApiRuntime, x as clearClientDiagnostics, C as clientDiagnosticsSnapshot, A as isUnauthenticated, k as makeProtocolOpenRecovery, W as makeServiceClient, c as publishClientError, n as publishClientTrace, i as recordClientDiagnostic, s as recoveryCoordinatorFor, S as rememberRpcErrorKind, l as reportClientError, h as resolveByTag, g as resolveRecoveryOptions, a as rpcErrorKind, y as runRpcPromise, G as serviceApi, u as stableKey, w as startApiSupervisor, e as subscribeClientDiagnostics, _ as subscribeClientErrors, t as subscribeClientTraces, o as supersedesConfirmedPatches, E as wireAuthRefresh };
|
|
1
|
+
import { publishClientTrace as e, subscribeClientTraces as t } from "./traceBus.js";
|
|
2
|
+
import { rememberRpcErrorKind as n, rpcErrorKind as r } from "./rpcErrorKind.js";
|
|
3
|
+
import { clearClientDiagnostics as i, clientDiagnosticsSnapshot as a, recordClientDiagnostic as o, subscribeClientDiagnostics as s } from "./clientDiagnostics.js";
|
|
4
|
+
import { stableKey as c } from "./stableKey.js";
|
|
5
|
+
import { LoadingSubscriptionCache as l, SubscriptionCache as u, supersedesConfirmedPatches as d } from "./subscriptionCache.js";
|
|
6
|
+
import { publishClientError as f, reportClientError as p, subscribeClientErrors as m } from "./clientErrorBus.js";
|
|
7
|
+
import { RpcErrorBus as h } from "./rpcErrorBus.js";
|
|
8
|
+
import { apiConnectivity as g } from "./apiConnectivity.js";
|
|
9
|
+
import { INITIAL_RECOVERY_SNAPSHOT as _, RecoveryCoordinator as v, recoveryCoordinatorFor as y, resolveRecoveryOptions as b } from "./recoveryCoordinator.js";
|
|
10
|
+
import { resolveByTag as x } from "./tagWalk.js";
|
|
11
|
+
import { buildApiRuntime as S, makeProtocolOpenRecovery as C } from "./apiRuntime.js";
|
|
12
|
+
import { startApiSupervisor as w } from "./apiSupervisor.js";
|
|
13
|
+
import { runRpcPromise as T } from "./runRpc.js";
|
|
14
|
+
import { isUnauthenticated as E, wireAuthRefresh as D } from "./authRefresh.js";
|
|
15
|
+
import { DEFAULT_SERVICE_CALL_TIMEOUT_MS as O, makeServiceClient as k, serviceApi as A } from "./serviceClient.js";
|
|
16
|
+
export { O as DEFAULT_SERVICE_CALL_TIMEOUT_MS, _ as INITIAL_RECOVERY_SNAPSHOT, l as LoadingSubscriptionCache, v as RecoveryCoordinator, h as RpcErrorBus, u as SubscriptionCache, g as apiConnectivity, S as buildApiRuntime, i as clearClientDiagnostics, a as clientDiagnosticsSnapshot, E as isUnauthenticated, C as makeProtocolOpenRecovery, k as makeServiceClient, f as publishClientError, e as publishClientTrace, o as recordClientDiagnostic, y as recoveryCoordinatorFor, n as rememberRpcErrorKind, p as reportClientError, x as resolveByTag, b as resolveRecoveryOptions, r as rpcErrorKind, T as runRpcPromise, A as serviceApi, c as stableKey, w as startApiSupervisor, s as subscribeClientDiagnostics, m as subscribeClientErrors, t as subscribeClientTraces, d as supersedesConfirmedPatches, D as wireAuthRefresh };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/runtimeCapabilities.ts
|
|
2
|
+
var e = (e, t, n) => {
|
|
3
|
+
try {
|
|
4
|
+
let r = globalThis.location, i = typeof r == "object" && r ? r.href : void 0, a = new URL(e, i);
|
|
5
|
+
if (a.protocol === "wss:" ? a.protocol = "https:" : a.protocol === "ws:" && (a.protocol = "http:"), n !== void 0) return new URL(n, a).toString();
|
|
6
|
+
let o = `/ws/${t}`;
|
|
7
|
+
if (a.pathname === o) a.pathname = `/_voltro/api/${encodeURIComponent(t)}/_voltro/runtime-capabilities`;
|
|
8
|
+
else {
|
|
9
|
+
let e = a.pathname.lastIndexOf("/");
|
|
10
|
+
a.pathname = `${e <= 0 ? "" : a.pathname.slice(0, e)}/_voltro/runtime-capabilities`;
|
|
11
|
+
}
|
|
12
|
+
return a.search = "", a.hash = "", a.toString();
|
|
13
|
+
} catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}, t = async (t, n, r = fetch, i = 1500, a) => {
|
|
17
|
+
let o = e(t, n, a);
|
|
18
|
+
if (o === void 0) return;
|
|
19
|
+
let s = new AbortController(), c = setTimeout(() => s.abort(), i);
|
|
20
|
+
try {
|
|
21
|
+
let e = await r(o, {
|
|
22
|
+
method: "GET",
|
|
23
|
+
headers: { accept: "application/json" },
|
|
24
|
+
cache: "no-store",
|
|
25
|
+
signal: s.signal
|
|
26
|
+
});
|
|
27
|
+
if (!e.ok) return;
|
|
28
|
+
let t = await e.json();
|
|
29
|
+
if (t.protocol !== 1 || typeof t.mutationReplay != "boolean") return;
|
|
30
|
+
let n = (e) => typeof e == "object" && e && !Array.isArray(e) && Object.values(e).every((e) => typeof e == "string") ? e : void 0, i = n(t.surface), a = n(t.serviceSurface);
|
|
31
|
+
return {
|
|
32
|
+
protocol: 1,
|
|
33
|
+
mutationReplay: t.mutationReplay,
|
|
34
|
+
...i === void 0 ? {} : { surface: i },
|
|
35
|
+
...a === void 0 ? {} : { serviceSurface: a }
|
|
36
|
+
};
|
|
37
|
+
} catch {
|
|
38
|
+
return;
|
|
39
|
+
} finally {
|
|
40
|
+
clearTimeout(c), s.abort();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { t as readRuntimeCapabilities, e as runtimeCapabilitiesUrl };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LoadingSubscriptionCache as e } from "./subscriptionCache.js";
|
|
2
|
+
import { RpcErrorBus as t } from "./rpcErrorBus.js";
|
|
3
|
+
import { RecoveryCoordinator as n } from "./recoveryCoordinator.js";
|
|
4
|
+
import { FrameworkRuntimesContext as r, isUnresolvedApi as i, unknownApiError as a } from "./frameworkRuntimesContext.js";
|
|
5
|
+
import { useContext as o, useEffect as s } from "react";
|
|
6
|
+
import { Exit as c } from "effect";
|
|
7
|
+
//#region src/runtimeContext.ts
|
|
8
|
+
var l = () => {
|
|
9
|
+
throw Error("Voltro: rpc / cache calls are not invokable on a not-yet-resolved api — either during SSR, or in the client boot window before the api client resolves");
|
|
10
|
+
}, u = /* @__PURE__ */ new Proxy(() => l(), {
|
|
11
|
+
get: (e, t) => u,
|
|
12
|
+
has: () => !0,
|
|
13
|
+
apply: () => l()
|
|
14
|
+
}), d = Symbol.for("@voltro/client/ssrDescriptors"), f = globalThis, p = f[d] ?? (f[d] = { byApi: /* @__PURE__ */ new Map() }), m = (e, t) => {
|
|
15
|
+
p.byApi.set(e, t);
|
|
16
|
+
}, h = (e) => p.byApi.get(e), g = () => {
|
|
17
|
+
p.byApi.clear();
|
|
18
|
+
}, _ = {
|
|
19
|
+
runtime: { runPromiseExit: () => Promise.resolve(c.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
|
|
20
|
+
cache: /* @__PURE__ */ new e(),
|
|
21
|
+
client: u,
|
|
22
|
+
descriptors: {},
|
|
23
|
+
inspectBaseUrl: "",
|
|
24
|
+
errorBus: /* @__PURE__ */ new t(),
|
|
25
|
+
recovery: /* @__PURE__ */ new n("ssr")
|
|
26
|
+
}, v = {
|
|
27
|
+
get: (e) => {
|
|
28
|
+
let t = h(e);
|
|
29
|
+
return t === void 0 ? _ : {
|
|
30
|
+
..._,
|
|
31
|
+
descriptors: t
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
names: []
|
|
35
|
+
}, y = !1, b = !1, x = null, S = () => {
|
|
36
|
+
y = !1, b = !1, x !== null && (clearTimeout(x), x = null);
|
|
37
|
+
}, C = () => {
|
|
38
|
+
let e = o(r);
|
|
39
|
+
return e ? (b || (b = !0, x !== null && (clearTimeout(x), x = null)), e) : (globalThis.window !== void 0 && !y && !b && x === null && process.env.NODE_ENV !== "production" && (x = setTimeout(() => {
|
|
40
|
+
x = null, !(y || b) && (y = !0, console.warn("useFrameworkRuntimes: no <FrameworkRuntimesProvider> in the tree — returning a loading baseline (subscriptions read `undefined`, mutations are no-ops). If this is not an intentional lazy/conditional mount, mount your app via @voltro/web mount() or wrap the subtree in <VoltroRuntimeProvider>."));
|
|
41
|
+
}, 0)), v);
|
|
42
|
+
}, w = (e) => {
|
|
43
|
+
let t = C(), n = t.demand;
|
|
44
|
+
return s(() => {
|
|
45
|
+
n?.(e);
|
|
46
|
+
}, [n, e]), t.get(e);
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { r as FrameworkRuntimesContext, S as _resetFrameworkRuntimesWarning, g as _resetSsrDescriptors, i as isUnresolvedApi, m as registerSsrDescriptors, u as ssrClientProxy, h as ssrDescriptorsFor, _ as ssrStubHandle, a as unknownApiError, w as useFrameworkApi, C as useFrameworkRuntimes };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
import { finiteNumberView as t } from "@voltro/protocol";
|
|
3
|
+
import * as n from "effect/SchemaAST";
|
|
4
|
+
import * as r from "effect/SchemaRepresentation";
|
|
5
|
+
//#region src/schemaFields.ts
|
|
6
|
+
var i = (e) => ({ voltroField: e }), a = "x-voltro", o = (t) => e.makeFilter(() => !0, { toJsonSchema: () => ({ [a]: t }) }), s = {
|
|
7
|
+
"effect/schema/Date": "date",
|
|
8
|
+
"effect/schema/DateTimeUtc": "date-time"
|
|
9
|
+
}, c = (e) => {
|
|
10
|
+
let t = e.annotations?.representation;
|
|
11
|
+
return typeof t?.id == "string" ? t.id : void 0;
|
|
12
|
+
}, l = (e, t = /* @__PURE__ */ new Map()) => {
|
|
13
|
+
let n = t.get(e);
|
|
14
|
+
if (n !== void 0) return n;
|
|
15
|
+
let r = u(e, t);
|
|
16
|
+
return t.set(e, r), r;
|
|
17
|
+
}, u = (t, r) => {
|
|
18
|
+
let i = [t.annotations, ...(t.checks ?? []).map((e) => e.annotations)].map((e) => e?.voltroField).find((e) => e !== void 0), a = (t) => i === void 0 ? t : e.make(t).check(o(i)).ast;
|
|
19
|
+
if (n.isDeclaration(t)) {
|
|
20
|
+
let e = s[c(t) ?? ""];
|
|
21
|
+
if (e === void 0) return a(t);
|
|
22
|
+
let { title: r, description: i } = t.annotations ?? {};
|
|
23
|
+
return a(new n.String({
|
|
24
|
+
format: e,
|
|
25
|
+
...typeof r == "string" ? { title: r } : {},
|
|
26
|
+
...typeof i == "string" ? { description: i } : {}
|
|
27
|
+
}, void 0, void 0, t.context));
|
|
28
|
+
}
|
|
29
|
+
return t.encoding === void 0 ? n.isObjects(t) ? a(new n.Objects(t.propertySignatures.map((e) => new n.PropertySignature(e.name, l(e.type, r))), t.indexSignatures.map((e) => new n.IndexSignature(e.parameter, l(e.type, r))), t.annotations, t.checks, void 0, t.context)) : n.isArrays(t) ? a(new n.Arrays(t.isMutable, t.elements.map((e) => l(e, r)), t.rest.map((e) => l(e, r)), t.annotations, t.checks, void 0, t.context)) : n.isUnion(t) ? a(new n.Union(t.types.map((e) => l(e, r)), t.options, t.annotations, t.checks, void 0, t.context)) : n.isSuspend(t) ? a(new n.Suspend(() => l(t.thunk(), r), t.annotations, t.checks, void 0, t.context)) : a(t) : a(t);
|
|
30
|
+
}, d = "#/$defs/", f = (e) => e.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/^./, (e) => e.toUpperCase()), p = (e) => {
|
|
31
|
+
let t = e.title;
|
|
32
|
+
if (typeof t != "string") return;
|
|
33
|
+
let n = t.trim();
|
|
34
|
+
return n === "" ? void 0 : n;
|
|
35
|
+
}, m = (e, t) => {
|
|
36
|
+
let n = e;
|
|
37
|
+
for (let e = 0; e < 8; e += 1) {
|
|
38
|
+
let e = n.$ref;
|
|
39
|
+
if (typeof e != "string" || !e.startsWith(d)) return g(n);
|
|
40
|
+
let r = t[e.slice(8)];
|
|
41
|
+
if (!r || typeof r != "object") return g(n);
|
|
42
|
+
n = r;
|
|
43
|
+
}
|
|
44
|
+
return g(n);
|
|
45
|
+
}, h = [
|
|
46
|
+
"Infinity",
|
|
47
|
+
"-Infinity",
|
|
48
|
+
"NaN"
|
|
49
|
+
], g = (e) => {
|
|
50
|
+
let t = e.anyOf;
|
|
51
|
+
if (!Array.isArray(t) || t.length !== 2) return e;
|
|
52
|
+
let [n, r] = t, i = (e) => e.type === "number" && e.enum === void 0, a = (e) => e.type === "string" && Array.isArray(e.enum) && e.enum.every((e) => h.includes(e));
|
|
53
|
+
if (i(n) && a(r) || i(r) && a(n)) {
|
|
54
|
+
let { anyOf: t, ...n } = e;
|
|
55
|
+
return {
|
|
56
|
+
...n,
|
|
57
|
+
type: "number"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return e;
|
|
61
|
+
}, _ = (e) => {
|
|
62
|
+
if (!e || typeof e != "object") return !1;
|
|
63
|
+
let t = e;
|
|
64
|
+
if (t.type === "null" || t.const === null) return !0;
|
|
65
|
+
let n = t.enum;
|
|
66
|
+
return Array.isArray(n) && n.length === 1 && n[0] === null;
|
|
67
|
+
}, v = (e, t) => {
|
|
68
|
+
let n = e.type;
|
|
69
|
+
if (Array.isArray(n) && n.includes("null")) {
|
|
70
|
+
let t = n.filter((e) => e !== "null");
|
|
71
|
+
return {
|
|
72
|
+
node: {
|
|
73
|
+
...e,
|
|
74
|
+
type: t.length === 1 ? t[0] : t
|
|
75
|
+
},
|
|
76
|
+
nullable: !0
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
for (let n of ["anyOf", "oneOf"]) {
|
|
80
|
+
let r = e[n];
|
|
81
|
+
if (!Array.isArray(r)) continue;
|
|
82
|
+
let i, a = 0, o, s = r.length;
|
|
83
|
+
for (let e = 0; e < s; e++) {
|
|
84
|
+
if (!(e in r)) continue;
|
|
85
|
+
let t = r[e];
|
|
86
|
+
_(t) || (a += 1, a === 1 ? i = t : a === 2 ? o = [i, t] : o.push(t));
|
|
87
|
+
}
|
|
88
|
+
if (a !== r.length) return a === 1 ? {
|
|
89
|
+
...v(m(i, t), t),
|
|
90
|
+
nullable: !0
|
|
91
|
+
} : {
|
|
92
|
+
node: {
|
|
93
|
+
...e,
|
|
94
|
+
[n]: o ?? []
|
|
95
|
+
},
|
|
96
|
+
nullable: !0
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
node: e,
|
|
101
|
+
nullable: !1
|
|
102
|
+
};
|
|
103
|
+
}, y = (e) => e.map((e) => ({
|
|
104
|
+
value: String(e),
|
|
105
|
+
label: f(String(e))
|
|
106
|
+
})), b = (e) => {
|
|
107
|
+
let t = e.enum;
|
|
108
|
+
if (Array.isArray(t) && t.length > 0) return {
|
|
109
|
+
widget: "select",
|
|
110
|
+
options: y(t)
|
|
111
|
+
};
|
|
112
|
+
let n = e.type, r = Array.isArray(n) ? n.find((e) => e !== "null") : n, i = e.format;
|
|
113
|
+
switch (r) {
|
|
114
|
+
case "string": return i === "date" ? { widget: "date" } : i === "date-time" ? { widget: "datetime" } : { widget: "text" };
|
|
115
|
+
case "integer":
|
|
116
|
+
case "number": return { widget: "number" };
|
|
117
|
+
case "boolean": return { widget: "checkbox" };
|
|
118
|
+
case "array": return { widget: "multi-select" };
|
|
119
|
+
default: return { widget: "custom" };
|
|
120
|
+
}
|
|
121
|
+
}, x = (...e) => {
|
|
122
|
+
for (let t of e) {
|
|
123
|
+
let e = [t, ...Array.isArray(t.allOf) ? t.allOf : []].find((e) => typeof e[a] == "object" && e[a] !== null);
|
|
124
|
+
if (e !== void 0) return e[a];
|
|
125
|
+
}
|
|
126
|
+
return {};
|
|
127
|
+
}, S = 4, C = (e, t, n, r = "", i, a = 0, o = []) => {
|
|
128
|
+
let s = Object.entries(e);
|
|
129
|
+
for (let e = 0; e < s.length; e += 1) {
|
|
130
|
+
let [c, l] = s[e], u = m(l, n), { node: d, nullable: h } = v(u, n), g = m(d, n), _ = x(g, u), y = r === "" ? c : `${r}.${c}`, w = g.properties;
|
|
131
|
+
if (g.type === "object" && w !== void 0 && a < S && _.widget === void 0) {
|
|
132
|
+
C(w, new Set(Array.isArray(g.required) ? g.required : []), n, y, {
|
|
133
|
+
path: _.section ?? y,
|
|
134
|
+
label: _.label ?? p(g) ?? f(c)
|
|
135
|
+
}, a + 1, o);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
let { widget: T, options: E } = b(g), D, O = g;
|
|
139
|
+
if (g.type === "array") {
|
|
140
|
+
let e = g.items;
|
|
141
|
+
if (typeof e == "object" && e && !Array.isArray(e)) {
|
|
142
|
+
let t = m(e, n);
|
|
143
|
+
O = {
|
|
144
|
+
...g,
|
|
145
|
+
items: t
|
|
146
|
+
};
|
|
147
|
+
let r = t.properties;
|
|
148
|
+
t.type === "object" && r !== void 0 && (T = "array", D = C(r, new Set(Array.isArray(t.required) ? t.required : []), n));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
_.widget !== void 0 && (T = _.widget), _.reference !== void 0 && _.widget === void 0 && (T = "reference");
|
|
152
|
+
let k = typeof g.description == "string" ? g.description : void 0, A = _.section ?? i?.path;
|
|
153
|
+
o.push({
|
|
154
|
+
name: y,
|
|
155
|
+
label: _.label ?? p(g) ?? f(c),
|
|
156
|
+
widget: T,
|
|
157
|
+
required: t.has(c),
|
|
158
|
+
nullable: h,
|
|
159
|
+
...E ? { options: E } : {},
|
|
160
|
+
jsonSchema: O,
|
|
161
|
+
...A === void 0 ? {} : {
|
|
162
|
+
section: A,
|
|
163
|
+
sectionLabel: i?.label ?? f(A)
|
|
164
|
+
},
|
|
165
|
+
...k === void 0 ? {} : { description: k },
|
|
166
|
+
..._.order === void 0 ? {} : { order: _.order },
|
|
167
|
+
...D === void 0 ? {} : { item: D },
|
|
168
|
+
..._.reference === void 0 ? {} : { reference: _.reference }
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return o;
|
|
172
|
+
}, w = (e) => {
|
|
173
|
+
let t = !1;
|
|
174
|
+
for (let n = 0; n < e.length; n += 1) if (e[n].order !== void 0) {
|
|
175
|
+
t = !0;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
if (!t) return e;
|
|
179
|
+
let n = e.map((e, t) => [e, t]).sort((e, t) => (e[0].order ?? e[1]) - (t[0].order ?? t[1]) || e[1] - t[1]);
|
|
180
|
+
for (let t = 0; t < n.length; t += 1) e[t] = n[t][0];
|
|
181
|
+
return e;
|
|
182
|
+
}, T = (n) => {
|
|
183
|
+
try {
|
|
184
|
+
let i = e.make(t(l(n.ast))), a = r.toJsonSchemaDocument(r.toRepresentation(e.toCodecJson(i).ast));
|
|
185
|
+
return {
|
|
186
|
+
root: a.schema,
|
|
187
|
+
defs: a.definitions
|
|
188
|
+
};
|
|
189
|
+
} catch {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
}, E = (e) => {
|
|
193
|
+
let t = T(e);
|
|
194
|
+
if (t === void 0) return [];
|
|
195
|
+
let { root: n, defs: r } = t, i = m(n, r), a = i.properties;
|
|
196
|
+
return a ? w(C(a, new Set(Array.isArray(i.required) ? i.required : []), r)) : [];
|
|
197
|
+
}, D = (e) => {
|
|
198
|
+
let t = T(e);
|
|
199
|
+
if (t === void 0) return [];
|
|
200
|
+
let { root: n, defs: r } = t, i = m(n, r);
|
|
201
|
+
if (i.type !== "array") return [];
|
|
202
|
+
let a = i.items;
|
|
203
|
+
if (!a || typeof a != "object") return [];
|
|
204
|
+
let o = m(a, r), s = o.properties;
|
|
205
|
+
return s ? C(s, new Set(Array.isArray(o.required) ? o.required : []), r) : [];
|
|
206
|
+
}, O = (e) => {
|
|
207
|
+
let t = [];
|
|
208
|
+
for (let n of e) {
|
|
209
|
+
let e = t[t.length - 1];
|
|
210
|
+
e !== void 0 && e.name === n.section ? e.fields.push(n) : t.push({
|
|
211
|
+
name: n.section,
|
|
212
|
+
label: n.sectionLabel,
|
|
213
|
+
fields: [n]
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return t;
|
|
217
|
+
};
|
|
218
|
+
//#endregion
|
|
219
|
+
export { i as formField, O as formSections, D as schemaToColumns, E as schemaToFields };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/scopeMembership.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
if (!(e.length < 32 || Object.getPrototypeOf(e) !== Array.prototype || e.includes !== Array.prototype.includes || e[Symbol.iterator] !== Array.prototype[Symbol.iterator])) {
|
|
4
|
+
for (let t = 0; t < e.length; t++) {
|
|
5
|
+
let n = Object.getOwnPropertyDescriptor(e, String(t));
|
|
6
|
+
if (n === void 0 || !("value" in n) || typeof n.value != "string") return;
|
|
7
|
+
}
|
|
8
|
+
return new Set(e);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { e as scopeMembership };
|
package/dist/sequence.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/sequence.ts
|
|
2
|
+
var e = () => {
|
|
3
|
+
let e = (t) => ({
|
|
4
|
+
steps: t,
|
|
5
|
+
step: ((n, r, i) => e([...t, {
|
|
6
|
+
name: n,
|
|
7
|
+
run: r,
|
|
8
|
+
undo: i?.undo,
|
|
9
|
+
covers: i?.covers ?? [],
|
|
10
|
+
when: i?.when
|
|
11
|
+
}]))
|
|
12
|
+
});
|
|
13
|
+
return e([]);
|
|
14
|
+
}, t = async (e, t = {}) => {
|
|
15
|
+
let n = {}, r = [];
|
|
16
|
+
for (let i of e.steps) if (i.when !== void 0 && !i.when(n)) n[i.name] = void 0;
|
|
17
|
+
else try {
|
|
18
|
+
let e = await i.run(n);
|
|
19
|
+
n[i.name] = e, r.push({
|
|
20
|
+
step: i,
|
|
21
|
+
result: e
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {
|
|
24
|
+
let a = [], o = [], s = [], c = [];
|
|
25
|
+
if (t.compensate !== !1) {
|
|
26
|
+
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
27
|
+
for (let i = r.length - 1; i >= 0; i--) {
|
|
28
|
+
let l = r[i], u = l.step.name;
|
|
29
|
+
if (t.has(u)) c.push({
|
|
30
|
+
step: u,
|
|
31
|
+
coveredBy: t.get(u)
|
|
32
|
+
});
|
|
33
|
+
else if (e.has(u)) s.push(u);
|
|
34
|
+
else if (l.step.undo !== void 0) try {
|
|
35
|
+
await l.step.undo(l.result, n), a.push(u);
|
|
36
|
+
for (let t of l.step.covers) e.set(t, u);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
o.push({
|
|
39
|
+
step: u,
|
|
40
|
+
error: e
|
|
41
|
+
});
|
|
42
|
+
for (let e of l.step.covers) t.set(e, u);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
let l = {
|
|
47
|
+
failedStep: i.name,
|
|
48
|
+
compensated: a,
|
|
49
|
+
compensationFailures: o,
|
|
50
|
+
compensationCovered: s,
|
|
51
|
+
compensationUncertain: c
|
|
52
|
+
};
|
|
53
|
+
return t.onError?.(e, l), {
|
|
54
|
+
ok: !1,
|
|
55
|
+
error: e,
|
|
56
|
+
...l
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
ok: !0,
|
|
61
|
+
data: n
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { t as runSequence, e as sequence };
|