@voltro/client 0.84.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 (111) hide show
  1. package/CHANGELOG.md +1215 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -89
  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.d.ts +8 -11
  22. package/dist/form.js +5 -2
  23. package/dist/formBinding.js +325 -0
  24. package/dist/formData.js +65 -0
  25. package/dist/formFlashId.js +4 -0
  26. package/dist/frameworkRuntimesContext.js +8 -0
  27. package/dist/globalContext.js +10 -0
  28. package/dist/index.d.ts +285 -279
  29. package/dist/index.js +83 -3686
  30. package/dist/liveRowSort.js +66 -0
  31. package/dist/mutationConnectionSetup.js +16 -0
  32. package/dist/mutationIdentity.js +10 -0
  33. package/dist/mutationSerialExecution.js +53 -0
  34. package/dist/mutationsBus.js +40 -0
  35. package/dist/onlineSource.js +13 -0
  36. package/dist/outbox.js +213 -0
  37. package/dist/outboxHttp.js +104 -0
  38. package/dist/outboxState.js +43 -0
  39. package/dist/permissions.js +20 -0
  40. package/dist/platform.js +121 -0
  41. package/dist/preloadSeed.js +47 -0
  42. package/dist/provider.js +22 -0
  43. package/dist/query.js +12 -2
  44. package/dist/recoveryCoordinator.js +195 -0
  45. package/dist/recoveryRetry.js +24 -0
  46. package/dist/richText.js +176 -0
  47. package/dist/rpcErrorBus.js +39 -0
  48. package/dist/rpcErrorKind.js +13 -0
  49. package/dist/runRpc.js +12 -0
  50. package/dist/runtime.d.ts +79 -15
  51. package/dist/runtime.js +16 -129
  52. package/dist/runtimeCapabilities.js +44 -0
  53. package/dist/runtimeContext.js +49 -0
  54. package/dist/schemaFields.js +219 -0
  55. package/dist/scopeMembership.js +12 -0
  56. package/dist/seedResolvers.js +7 -0
  57. package/dist/sequence.js +65 -0
  58. package/dist/serverRequest.js +24 -0
  59. package/dist/serviceClient.js +128 -0
  60. package/dist/squashRpcCause.js +8 -0
  61. package/dist/stableKey.js +21 -0
  62. package/dist/store.js +288 -0
  63. package/dist/storeStorage.js +28 -0
  64. package/dist/subscriptionCache.js +724 -0
  65. package/dist/tagWalk.js +23 -0
  66. package/dist/traceBus.js +10 -0
  67. package/dist/tracking.js +40 -0
  68. package/dist/uploadProgress.js +21 -0
  69. package/dist/useAction.js +101 -0
  70. package/dist/useAgent.js +53 -0
  71. package/dist/useAgentChat.js +43 -0
  72. package/dist/useAgentStream.js +64 -0
  73. package/dist/useApiOnline.js +14 -0
  74. package/dist/useCapabilityManifest.js +101 -0
  75. package/dist/useConnectionSetup.js +28 -0
  76. package/dist/useConnectionStatus.js +38 -0
  77. package/dist/useConnections.js +107 -0
  78. package/dist/useDataCopilot.js +24 -0
  79. package/dist/useDataTable.js +34 -0
  80. package/dist/useDerived.js +22 -0
  81. package/dist/useEvent.js +88 -0
  82. package/dist/useFormBinding.js +476 -0
  83. package/dist/useLocalQuery.js +59 -0
  84. package/dist/useMutation.js +214 -0
  85. package/dist/useOnRpcError.js +13 -0
  86. package/dist/usePreloadedSubscription.js +18 -0
  87. package/dist/usePreview.js +14 -0
  88. package/dist/useProvenance.js +51 -0
  89. package/dist/useQueryField.js +34 -0
  90. package/dist/useRecord.js +12 -0
  91. package/dist/useRefreshSubscriptions.js +22 -0
  92. package/dist/useResourceCan.js +18 -0
  93. package/dist/useResumableAgentStream.js +75 -0
  94. package/dist/useSequence.js +25 -0
  95. package/dist/useSkeleton.js +13 -0
  96. package/dist/useSubscription.js +89 -0
  97. package/dist/useSubscriptionHealth.js +32 -0
  98. package/dist/useTranscription.js +51 -0
  99. package/dist/useUndo.js +33 -0
  100. package/dist/useUndoLog.js +44 -0
  101. package/dist/useUpload.js +296 -0
  102. package/dist/useWindowedSubscription.js +65 -0
  103. package/dist/useWorkflow.js +284 -0
  104. package/dist/useWorkflowRunState.js +93 -0
  105. package/dist/validation.js +39 -0
  106. package/dist/validationMessages.js +5 -0
  107. package/package.json +8 -5
  108. package/dist/authRefresh-C4Ow8HH7.js +0 -346
  109. package/dist/formData-dGz5aoUR.js +0 -649
  110. package/dist/queryOnce-CvdopzOj.js +0 -55
  111. package/dist/runRpc-DvHpFZAZ.js +0 -1034
@@ -1,346 +0,0 @@
1
- import { S as e, a as t, c as n, h as r, i, n as a, s as o, u as s } from "./runRpc-DvHpFZAZ.js";
2
- import { Context as c, Effect as l, Either as u, Layer as d, ManagedRuntime as f, Scheduler as p, Schema as m, Stream as h } from "effect";
3
- import * as g from "@effect/platform/Headers";
4
- import { RpcClient as _, RpcSerialization as v } from "@effect/rpc";
5
- import { compareSurfaces as y, groupShapeDigests as b } from "@voltro/protocol";
6
- import * as x from "@effect/platform/Socket";
7
- //#region src/clientScheduler.ts
8
- var S = {
9
- channel: "timer",
10
- yield: (e) => {
11
- setTimeout(e, 0);
12
- }
13
- }, C = (e) => {
14
- let t = [];
15
- return e.port1.onmessage = () => {
16
- t.shift()?.();
17
- }, e.port1.unref?.(), {
18
- channel: "message-channel",
19
- yield: (n) => {
20
- t.push(n), e.port2.postMessage(null);
21
- }
22
- };
23
- }, w = () => globalThis.window !== void 0 && typeof MessageChannel == "function" ? C(new MessageChannel()) : S, T = 2048, E = (e = w(), t = T) => {
24
- let n = p.SchedulerRunner.cached((n, r) => {
25
- n >= t ? e.yield(() => r(0)) : Promise.resolve().then(() => r(n + 1));
26
- });
27
- return {
28
- yieldChannel: e.channel,
29
- shouldYield: p.defaultShouldYield,
30
- scheduleTask: (e, t, r) => {
31
- n(r).scheduleTask(e, t);
32
- }
33
- };
34
- }, D = (e, t, n) => {
35
- try {
36
- let r = globalThis.location, i = typeof r == "object" && r ? r.href : void 0, a = new URL(e, i);
37
- if (a.protocol === "wss:" ? a.protocol = "https:" : a.protocol === "ws:" && (a.protocol = "http:"), n !== void 0) return new URL(n, a).toString();
38
- let o = `/ws/${t}`;
39
- if (a.pathname === o) a.pathname = `/_voltro/api/${encodeURIComponent(t)}/_voltro/runtime-capabilities`;
40
- else {
41
- let e = a.pathname.lastIndexOf("/");
42
- a.pathname = `${e <= 0 ? "" : a.pathname.slice(0, e)}/_voltro/runtime-capabilities`;
43
- }
44
- return a.search = "", a.hash = "", a.toString();
45
- } catch {
46
- return;
47
- }
48
- }, O = async (e, t, n = fetch, r = 1500, i) => {
49
- let a = D(e, t, i);
50
- if (a === void 0) return;
51
- let o = new AbortController(), s = setTimeout(() => o.abort(), r);
52
- try {
53
- let e = await n(a, {
54
- method: "GET",
55
- headers: { accept: "application/json" },
56
- cache: "no-store",
57
- signal: o.signal
58
- });
59
- if (!e.ok) return;
60
- let t = await e.json();
61
- if (t.protocol !== 1 || typeof t.mutationReplay != "boolean") return;
62
- let r = (e) => typeof e == "object" && e && !Array.isArray(e) && Object.values(e).every((e) => typeof e == "string") ? e : void 0, i = r(t.surface), s = r(t.serviceSurface);
63
- return {
64
- protocol: 1,
65
- mutationReplay: t.mutationReplay,
66
- ...i === void 0 ? {} : { surface: i },
67
- ...s === void 0 ? {} : { serviceSurface: s }
68
- };
69
- } catch {
70
- return;
71
- } finally {
72
- clearTimeout(s);
73
- }
74
- }, k = class {
75
- #e;
76
- #t;
77
- #n;
78
- #r = /* @__PURE__ */ new Set();
79
- getSnapshot = () => this.#n;
80
- subscribe = (e) => (this.#r.add(e), () => {
81
- this.#r.delete(e);
82
- });
83
- begin() {
84
- let e = {};
85
- return this.#e = e, this.#i(), {
86
- open: () => {
87
- if (this.#e === e) return this.#n === void 0 && (this.#t = new AbortController(), this.#n = Object.freeze({ signal: this.#t.signal }), this.#a()), this.#e === e ? this.#n : void 0;
88
- },
89
- close: () => {
90
- this.#e === e && (this.#e = void 0, this.#i());
91
- }
92
- };
93
- }
94
- #i() {
95
- let e = this.#t, t = this.#n !== void 0;
96
- this.#t = void 0, this.#n = void 0, e?.abort(), t && this.#a();
97
- }
98
- #a() {
99
- for (let e of this.#r) try {
100
- e();
101
- } catch {}
102
- }
103
- }, A = /* @__PURE__ */ new WeakMap(), j = (e, t) => {
104
- A.set(e, t);
105
- }, M = (e) => A.get(e), N = async (t, n, r, i) => {
106
- if (r !== void 0) try {
107
- let a = await r({
108
- apiName: t,
109
- descriptors: i
110
- });
111
- return e(t, "runtime.mirror", {
112
- generation: n,
113
- mirrored: a !== void 0
114
- }), a;
115
- } catch (r) {
116
- e(t, "runtime.mirror", {
117
- generation: n,
118
- mirrored: !1,
119
- errorName: r instanceof Error ? r.name : typeof r
120
- });
121
- return;
122
- }
123
- }, P = (e, t, n = new k()) => x.Socket.of({
124
- ...e,
125
- runRaw: (r, i) => l.acquireUseRelease(l.sync(() => n.begin()), (n) => e.runRaw(r, {
126
- ...i,
127
- onOpen: l.zipRight(i?.onOpen ?? l.void, l.sync(() => {
128
- n.open() !== void 0 && t();
129
- }))
130
- }), (e) => l.sync(e.close))
131
- }), F = 3, I = (t, n, r) => {
132
- let i;
133
- try {
134
- i = y(b(n), r);
135
- } catch {
136
- return;
137
- }
138
- let { differing: a, missingHere: o } = i;
139
- if (a.length === 0 && o.length === 0) return;
140
- e(t, "runtime.surface-mismatch", {
141
- differing: a.length,
142
- missingHere: o.length,
143
- first: a[0] ?? o[0] ?? null
144
- });
145
- let s = [...a, ...o].slice(0, F), c = a.length + o.length - s.length;
146
- console.warn(`[voltro] the api client this page loaded does not match what the '${t}' server binds: ${s.join(", ")}${c > 0 ? ` and ${c} more` : ""}. Responses for those procedures may decode against the wrong schema — a field the server sends and this client does not know is dropped silently. Reload; if it persists, stop the dev server, delete \`.framework/.vite\`, and start it again.`);
147
- }, L = async (n) => {
148
- let { name: i, wsUrl: p, group: y, headers: b, webSocketConstructor: S } = n, C = n.generation ?? 0;
149
- e(i, "runtime.build-started", { generation: C });
150
- let w = n.errorBus ?? new s(), T = n.recovery ?? t(w, i), D = o(T.options.retry, (t, n) => {
151
- e(i, "socket.retry-scheduled", {
152
- generation: C,
153
- attempt: t,
154
- delayMs: n,
155
- owner: "socket"
156
- });
157
- });
158
- O(p, i, fetch, 1500, T.options.capabilitiesUrl).then((t) => {
159
- T.setMutationReplaySupported(t?.mutationReplay === !0, C), e(i, "runtime.capabilities", {
160
- mutationReplay: t?.mutationReplay === !0,
161
- discovered: t !== void 0
162
- });
163
- let r = n.surfaceAudience === "service" ? t?.serviceSurface : t?.surface;
164
- r !== void 0 && I(i, y, r);
165
- });
166
- let A = n.descriptors ?? {}, M = await N(i, C, n.mirror, A), F = new r({
167
- errorBus: w,
168
- apiName: i,
169
- ...M === void 0 ? {} : { mirror: M }
170
- }), L = new k(), R;
171
- class z extends c.Tag(`@voltro/client/AppClient/${i}`)() {}
172
- let B = d.succeed(x.WebSocketConstructor, S), V = x.layerWebSocket(p).pipe(d.provide(B)), H = d.effect(x.Socket, l.map(x.Socket, (t) => P(t, () => {
173
- D.reset();
174
- let t = 0;
175
- R !== void 0 && (t = F.resumeTransportFailures(R)), e(i, "protocol.ready", {
176
- generation: C,
177
- resumed: t
178
- }), T.protocolReady();
179
- }, L))).pipe(d.provide(V)), U = _.layerProtocolSocket({ retrySchedule: D.schedule }).pipe(d.provide(v.layerJson), d.provide(H)), W = typeof b == "function" ? await b() : b, G = d.scoped(z, _.make(y)).pipe(d.provide(U)), K = W ? d.locallyScoped(_.currentHeaders, g.fromInput(W)) : d.empty, q = E(), J = f.make(d.merge(G, K).pipe(d.provide(d.setScheduler(q))));
180
- R = J, j(R, L);
181
- try {
182
- let t = await J.runPromise(z);
183
- e(i, "runtime.resolved", {
184
- generation: C,
185
- scheduler: q.yieldChannel
186
- });
187
- let n = (M?.warmTags ?? []).filter((e) => {
188
- let t = A[e]?.input;
189
- return t !== void 0 && u.isRight(m.decodeUnknownEither(t)({}));
190
- }).map((e) => [e, {}]);
191
- for (let [e, r] of [...M?.warm ?? [], ...n]) {
192
- let n = A[e]?.source;
193
- F.subscribe([e, r], () => h.suspend(() => a(t, e)(r)), J, () => {}, n === void 0 ? {} : { source: n });
194
- }
195
- return {
196
- runtime: J,
197
- client: t,
198
- cache: F,
199
- errorBus: w,
200
- recovery: T
201
- };
202
- } catch (t) {
203
- throw e(i, "runtime.failed", {
204
- generation: C,
205
- errorName: t instanceof Error ? t.name : typeof t
206
- }), J.dispose(), t;
207
- }
208
- }, R = (e, t, n) => ({
209
- resolved: null,
210
- retryToken: 0,
211
- failureCount: 0,
212
- generation: 0,
213
- reconnectStatusDispose: null,
214
- everOpened: !1,
215
- wedgeStop: null,
216
- subjectMayHaveChanged: !1,
217
- errorBus: e,
218
- recovery: t,
219
- stopRecoveryError: e.on((e) => t.observeError(e)),
220
- stopRecoverySuccess: e.onSuccess((e) => t.observeSuccess(e)),
221
- ownsRecovery: n
222
- }), z = (e) => {
223
- e.wedgeStop !== null && (e.wedgeStop(), e.wedgeStop = null);
224
- }, B = (e) => {
225
- e.cache.destroy(e.runtime), e.runtime.dispose();
226
- }, V = (t) => {
227
- let r = t.apis, a = t.buildClient, o = t.onChange, c = t.stableWindowMs ?? 5e3, l = t.scheduler?.setTimeout ?? ((e, t) => setTimeout(e, t)), u = t.scheduler?.clearTimeout ?? ((e) => {
228
- clearTimeout(e);
229
- }), d = t.scheduler?.queueMicrotask ?? queueMicrotask, f = t.onReconnecting, p = t.wedgeBackstop, m = /* @__PURE__ */ new Map();
230
- for (let e of r) {
231
- let n = t.errorBusFor?.(e.name) ?? new s(), r = t.recoveryFor?.(e.name, e.recovery), a = r ?? new i(e.name, e.recovery);
232
- m.set(e.name, R(n, a, r === void 0));
233
- }
234
- let h = !1, g = /* @__PURE__ */ new Set(), _ = (e, t) => {
235
- let n = l(() => {
236
- g.delete(n), e();
237
- }, t);
238
- return g.add(n), n;
239
- }, v = () => {
240
- if (h) return;
241
- let e = /* @__PURE__ */ new Map();
242
- for (let [t, n] of m) n.resolved && e.set(t, n.resolved);
243
- o(e, r.every((t) => e.has(t.name)));
244
- }, y = (e, t) => {
245
- t.failureCount += 1, !t.reconnectStatusDispose && f && (t.reconnectStatusDispose = f(e.name)), p && t.everOpened && t.failureCount >= p.afterFailures && t.wedgeStop === null && (t.wedgeStop = p.arm(e.name));
246
- }, b = (r) => {
247
- if (h) return;
248
- let i = m.get(r.name);
249
- if (!i) return;
250
- y(r, i);
251
- let a = t.retryDelayMs?.(i.failureCount) ?? n(i.recovery.options.retry, i.failureCount);
252
- e(r.name, "socket.retry-scheduled", {
253
- generation: i.generation,
254
- attempt: i.failureCount,
255
- delayMs: a,
256
- owner: "runtime-build"
257
- });
258
- let o = ++i.retryToken;
259
- _(() => {
260
- h || i.retryToken === o && (i.generation += 1, x(r));
261
- }, a);
262
- }, x = async (t) => {
263
- if (h) return;
264
- let n = m.get(t.name);
265
- if (!n) return;
266
- let r = n.generation, i = () => {
267
- if (h || n.generation !== r) return;
268
- n.everOpened = !0, z(n), n.reconnectStatusDispose &&= (n.reconnectStatusDispose(), null), n.retryToken++;
269
- let e = n.failureCount;
270
- _(() => {
271
- h || n.failureCount === e && (n.failureCount = 0);
272
- }, c);
273
- }, o = (e) => {
274
- h || n.generation !== r || (n.recovery.transportIssue(), y(t, n));
275
- };
276
- try {
277
- let s = await a(t, r, i, o, n.errorBus, n.recovery);
278
- if (h || n.generation !== r) {
279
- B(s);
280
- return;
281
- }
282
- let c = n.resolved, l = n.subjectMayHaveChanged, u = c && !l ? s.cache.seedStaleFrom(c.cache) : 0;
283
- n.subjectMayHaveChanged = !1, n.resolved = s, e(t.name, "runtime.swapped", {
284
- generation: r,
285
- replaced: c !== null,
286
- seeded: u,
287
- subjectMayHaveChanged: l
288
- }), v(), c && B(c);
289
- } catch {
290
- if (h || n.generation !== r) return;
291
- b(t);
292
- }
293
- }, S = (e) => {
294
- if (!h) for (let t of r) {
295
- let n = m.get(t.name);
296
- n && (e && (n.subjectMayHaveChanged = !0), n.retryToken += 1, n.generation += 1, e && n.recovery.resetForSubjectChange(n.generation), n.failureCount = 0, z(n), x(t));
297
- }
298
- };
299
- return r.length === 0 ? (o(/* @__PURE__ */ new Map(), !0), {
300
- dispose: () => {
301
- h = !0;
302
- },
303
- reconnect: () => {},
304
- refreshAuth: () => {}
305
- }) : (d(() => {
306
- if (!h) for (let e of r) x(e);
307
- }), {
308
- dispose: () => {
309
- if (!h) {
310
- h = !0;
311
- for (let e of g) u(e);
312
- g.clear();
313
- for (let [, e] of m) e.resolved && B(e.resolved), e.reconnectStatusDispose && e.reconnectStatusDispose(), z(e), e.stopRecoveryError(), e.stopRecoverySuccess(), e.ownsRecovery && e.recovery.dispose();
314
- for (let t of r) e(t.name, "runtime.disposed");
315
- m.clear();
316
- }
317
- },
318
- reconnect: () => {
319
- S(!0);
320
- },
321
- refreshAuth: () => {
322
- S(!1);
323
- }
324
- });
325
- }, H = 0, U = () => {
326
- let e = typeof crypto < "u" ? crypto : void 0;
327
- return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${H += 1}`;
328
- }, W = (e, t) => e.pipe(l.locallyWith(_.currentHeaders, (e) => g.set(e, "idempotency-key", t))), G = (e) => e?._tag === "Unauthenticated", K = (e, t, n = {}) => {
329
- let r = n.cooldownMs ?? 15e3, i = n.maxConsecutive ?? 3, a = n.now ?? (() => Date.now()), o = -Infinity, s = 0, c = e.on((e) => {
330
- if (!G(e.error) || s >= i) return;
331
- let n = a();
332
- n - o < r || (o = n, s += 1, t());
333
- }), l = e.onSuccess(() => {
334
- s = 0;
335
- });
336
- return {
337
- dispose: () => {
338
- c(), l();
339
- },
340
- noteSuccess: () => {
341
- s = 0;
342
- }
343
- };
344
- };
345
- //#endregion
346
- export { V as a, M as c, W as i, K as n, L as o, U as r, P as s, G as t };