@voltro/client 0.85.0 → 0.86.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +666 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -33
  3. package/dist/analyticsCatalog.js +47 -0
  4. package/dist/apiConnectivity.js +33 -0
  5. package/dist/apiRuntime.js +135 -0
  6. package/dist/apiSupervisor.js +125 -0
  7. package/dist/authRefresh.js +20 -0
  8. package/dist/awaitResolvedApi.js +23 -0
  9. package/dist/bootstrap.d.ts +1144 -0
  10. package/dist/bootstrap.js +8 -0
  11. package/dist/cellMerger.js +6 -0
  12. package/dist/clientDiagnostics.js +94 -0
  13. package/dist/clientErrorBus.js +16 -0
  14. package/dist/clientScheduler.js +31 -0
  15. package/dist/connectionPrerequisite.js +70 -0
  16. package/dist/connectionScope.js +35 -0
  17. package/dist/connectionSetupController.js +206 -0
  18. package/dist/createHooks.js +15 -0
  19. package/dist/deepLink.js +69 -0
  20. package/dist/filters.js +58 -0
  21. package/dist/form.js +5 -2
  22. package/dist/formBinding.js +325 -0
  23. package/dist/formData.js +65 -0
  24. package/dist/formFlashId.js +4 -0
  25. package/dist/frameworkRuntimesContext.js +8 -0
  26. package/dist/globalContext.js +10 -0
  27. package/dist/index.d.ts +53 -7
  28. package/dist/index.js +83 -4121
  29. package/dist/liveRowSort.js +66 -0
  30. package/dist/mutationConnectionSetup.js +16 -0
  31. package/dist/mutationIdentity.js +10 -0
  32. package/dist/mutationSerialExecution.js +53 -0
  33. package/dist/mutationsBus.js +40 -0
  34. package/dist/onlineSource.js +13 -0
  35. package/dist/outbox.js +213 -0
  36. package/dist/outboxHttp.js +104 -0
  37. package/dist/outboxState.js +43 -0
  38. package/dist/permissions.js +20 -0
  39. package/dist/platform.js +121 -0
  40. package/dist/preloadSeed.js +47 -0
  41. package/dist/provider.js +22 -0
  42. package/dist/query.js +12 -2
  43. package/dist/recoveryCoordinator.js +195 -0
  44. package/dist/recoveryRetry.js +24 -0
  45. package/dist/richText.js +176 -0
  46. package/dist/rpcErrorBus.js +39 -0
  47. package/dist/rpcErrorKind.js +13 -0
  48. package/dist/runRpc.js +12 -0
  49. package/dist/runtime.d.ts +32 -1
  50. package/dist/runtime.js +16 -126
  51. package/dist/runtimeCapabilities.js +44 -0
  52. package/dist/runtimeContext.js +49 -0
  53. package/dist/schemaFields.js +219 -0
  54. package/dist/scopeMembership.js +12 -0
  55. package/dist/seedResolvers.js +7 -0
  56. package/dist/sequence.js +65 -0
  57. package/dist/serverRequest.js +24 -0
  58. package/dist/serviceClient.js +128 -0
  59. package/dist/squashRpcCause.js +8 -0
  60. package/dist/stableKey.js +21 -0
  61. package/dist/store.js +288 -0
  62. package/dist/storeStorage.js +28 -0
  63. package/dist/subscriptionCache.js +724 -0
  64. package/dist/tagWalk.js +23 -0
  65. package/dist/traceBus.js +10 -0
  66. package/dist/tracking.js +40 -0
  67. package/dist/uploadProgress.js +21 -0
  68. package/dist/useAction.js +101 -0
  69. package/dist/useAgent.js +53 -0
  70. package/dist/useAgentChat.js +43 -0
  71. package/dist/useAgentStream.js +64 -0
  72. package/dist/useApiOnline.js +14 -0
  73. package/dist/useCapabilityManifest.js +101 -0
  74. package/dist/useConnectionSetup.js +28 -0
  75. package/dist/useConnectionStatus.js +38 -0
  76. package/dist/useConnections.js +107 -0
  77. package/dist/useDataCopilot.js +24 -0
  78. package/dist/useDataTable.js +34 -0
  79. package/dist/useDerived.js +22 -0
  80. package/dist/useEvent.js +88 -0
  81. package/dist/useFormBinding.js +476 -0
  82. package/dist/useLocalQuery.js +59 -0
  83. package/dist/useMutation.js +214 -0
  84. package/dist/useOnRpcError.js +13 -0
  85. package/dist/usePreloadedSubscription.js +18 -0
  86. package/dist/usePreview.js +14 -0
  87. package/dist/useProvenance.js +51 -0
  88. package/dist/useQueryField.js +34 -0
  89. package/dist/useRecord.js +12 -0
  90. package/dist/useRefreshSubscriptions.js +22 -0
  91. package/dist/useResourceCan.js +18 -0
  92. package/dist/useResumableAgentStream.js +75 -0
  93. package/dist/useSequence.js +25 -0
  94. package/dist/useSkeleton.js +13 -0
  95. package/dist/useSubscription.js +89 -0
  96. package/dist/useSubscriptionHealth.js +32 -0
  97. package/dist/useTranscription.js +51 -0
  98. package/dist/useUndo.js +33 -0
  99. package/dist/useUndoLog.js +44 -0
  100. package/dist/useUpload.js +296 -0
  101. package/dist/useWindowedSubscription.js +65 -0
  102. package/dist/useWorkflow.js +284 -0
  103. package/dist/useWorkflowRunState.js +93 -0
  104. package/dist/validation.js +39 -0
  105. package/dist/validationMessages.js +5 -0
  106. package/package.json +7 -2
  107. package/dist/authRefresh-DmfSoCca.js +0 -360
  108. package/dist/formData-BfpBt7BQ.js +0 -769
  109. package/dist/queryOnce-D5Y4V1SB.js +0 -55
  110. package/dist/runRpc-Zfz3w709.js +0 -1172
package/dist/runtime.d.ts CHANGED
@@ -480,6 +480,22 @@ export declare interface FrameworkRuntimes {
480
480
  * keeps working; absent means "already connected", which is the safe reading.
481
481
  */
482
482
  readonly demand?: (apiName: string) => void;
483
+ /**
484
+ * One read through an api's client — the browser half of a loader's
485
+ * `ctx.query`. Supplied by the host that builds the rpc runtime
486
+ * (`VoltroRuntimeProvider`), not by this context: the read reaches the rpc
487
+ * client and with it the Effect runtime, and an app that mounts no api must
488
+ * not load either just because its router can ask. Absent → `ctx.query` is
489
+ * `undefined` in the browser, as it is for an app without apis.
490
+ */
491
+ readonly queryOnce?: QueryOnce;
492
+ /**
493
+ * Resolves once the rpc runtime behind these apis is loaded. A host that
494
+ * loads it on demand (the web boot keeps it out of an app's first load and
495
+ * fetches it with the first route that reads data) supplies it; absent means
496
+ * the runtime is already there.
497
+ */
498
+ readonly ready?: () => Promise<void>;
483
499
  }
484
500
 
485
501
  /**
@@ -582,6 +598,14 @@ export declare const publishClientError: (event: ClientErrorEvent) => void;
582
598
  /** Publish a started client trace. Cheap + sync; safe on the hot path. */
583
599
  export declare const publishClientTrace: (event: ClientTraceEvent) => void;
584
600
 
601
+ /** `queryOnce`'s shape, declared here so this module stays free of it. */
602
+ declare type QueryOnce = (handleRef: {
603
+ readonly current: {
604
+ readonly runtime: unknown;
605
+ readonly client: unknown;
606
+ };
607
+ }, apiName: string, tag: string, input: Record<string, unknown> | undefined, signal?: AbortSignal) => Promise<unknown>;
608
+
585
609
  export declare type RawTransportStatus = 'connected' | 'disconnected';
586
610
 
587
611
  /** Record one payload-free transition. Safe to call on every production path. */
@@ -602,6 +626,13 @@ export declare class RecoveryCoordinator {
602
626
  get options(): ResolvedRecoveryOptions;
603
627
  /** Ends on login/logout, tenant change or API disposal, not ordinary reconnect. */
604
628
  get subjectSignal(): AbortSignal;
629
+ /** Hydration values belong to the initial subject only. Once identity may
630
+ * have changed, a later generation/remount must obtain its own snapshot.
631
+ * Ordinary transport recovery does not cross this boundary. */
632
+ getPreloadSeedPermission: () => boolean;
633
+ /** A whole-cache resnapshot can follow same-socket re-authentication. Its
634
+ * replacement reads must not reuse the original server-rendered values. */
635
+ invalidatePreloadSeeds(): void;
605
636
  getSnapshot: () => RecoverySnapshot;
606
637
  /** The SSR / hydration snapshot — see INITIAL_RECOVERY_SNAPSHOT. Stable by
607
638
  * reference, so both renders agree and React swaps to the live one after. */
@@ -633,7 +664,7 @@ export declare class RecoveryCoordinator {
633
664
  * Disabled is final for the current generation and refuses immediately.
634
665
  */
635
666
  reserveMutationReplay(startedAt: number): MutationReplayReservation | undefined;
636
- waitForProtocolReady(startedAt: number): Promise<boolean>;
667
+ waitForProtocolReady(startedAt: number, signal?: AbortSignal): Promise<boolean>;
637
668
  dispose(): void;
638
669
  }
639
670
 
package/dist/runtime.js CHANGED
@@ -1,126 +1,16 @@
1
- import { C as e, D as t, E as n, O as r, S as i, T as a, _ as o, a as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as v, t as y, u as b, v as x, w as S, y as C } from "./runRpc-Zfz3w709.js";
2
- import { a as w, i as T, n as E, o as D, r as O, s as k, t as A } from "./authRefresh-DmfSoCca.js";
3
- import { Duration as j, Effect as M, Exit as N, Option as P, Schedule as F, Stream as I } from "effect";
4
- import * as L from "effect/http/Headers";
5
- import { RpcClient as R } from "effect/rpc";
6
- import { ApiUnavailable as z, MUTATION_IN_FLIGHT_RETRY_AFTER_MS as B } from "@voltro/protocol";
7
- //#region src/serviceClient.ts
8
- var V = (e) => e?._tag === "MutationInFlight", H = 1e4, U = (e, t) => {
9
- let n = e.descriptors[t]?.kind;
10
- return n === "query" || n === "mutation" || n === "action" ? n : void 0;
11
- }, W = (e) => {
12
- let t = e.defaultTimeoutMs ?? 1e4, n, i, a = !1, o = () => {
13
- if (a) return Promise.reject(new z({
14
- api: e.name,
15
- tag: "",
16
- reason: "closed",
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 };
@@ -0,0 +1,7 @@
1
+ //#region src/seedResolvers.ts
2
+ var e = Symbol.for("@voltro/client/seedResolvers"), t = globalThis, n = t[e] ??= {
3
+ store: null,
4
+ preload: null
5
+ };
6
+ //#endregion
7
+ export { n as seedResolvers };
@@ -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 };
@@ -0,0 +1,24 @@
1
+ import { globalContext as e } from "./globalContext.js";
2
+ import { FORM_FLASH_SCRIPT_ID as t } from "./formFlashId.js";
3
+ import { useContext as n, useMemo as r } from "react";
4
+ import { jsx as i } from "react/jsx-runtime";
5
+ //#region src/serverRequest.tsx
6
+ var a = e("serverRequest", null), o = () => n(a), s = ({ value: e, children: t }) => /* @__PURE__ */ i(a.Provider, {
7
+ value: e,
8
+ children: t
9
+ }), c = (e) => {
10
+ let n = o();
11
+ return r(() => {
12
+ if (n !== null) return n.formFlash?.formKey === e ? n.formFlash : void 0;
13
+ if (typeof document > "u") return;
14
+ let r = document.getElementById(t);
15
+ if (r !== null && r.textContent !== null && r.textContent !== "") try {
16
+ let t = JSON.parse(r.textContent);
17
+ return t.formKey === e ? t : void 0;
18
+ } catch {
19
+ return;
20
+ }
21
+ }, [n, e]);
22
+ };
23
+ //#endregion
24
+ export { a as ServerRequestContext, s as ServerRequestProvider, c as useFormFlash, o as useServerRequest };