@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.
Files changed (116) hide show
  1. package/CHANGELOG.md +5987 -0
  2. package/THIRD-PARTY-NOTICES.md +1125 -34
  3. package/dist/analyticsCatalog.js +47 -0
  4. package/dist/apiConnectivity.js +33 -0
  5. package/dist/apiRoleTransports.js +48 -0
  6. package/dist/apiRuntime.js +145 -0
  7. package/dist/apiSocketTracker.js +21 -0
  8. package/dist/apiSupervisor.js +136 -0
  9. package/dist/authRefresh.js +20 -0
  10. package/dist/awaitResolvedApi.js +23 -0
  11. package/dist/bootstrap.d.ts +1153 -0
  12. package/dist/bootstrap.js +8 -0
  13. package/dist/cellMerger.js +6 -0
  14. package/dist/clientDiagnostics.js +94 -0
  15. package/dist/clientErrorBus.js +16 -0
  16. package/dist/clientScheduler.js +31 -0
  17. package/dist/connectionPrerequisite.js +70 -0
  18. package/dist/connectionScope.js +47 -0
  19. package/dist/connectionSetupController.js +206 -0
  20. package/dist/createHooks.js +15 -0
  21. package/dist/deepLink.js +69 -0
  22. package/dist/filters.js +58 -0
  23. package/dist/form.d.ts +37 -4
  24. package/dist/form.js +7 -2
  25. package/dist/formBinding.js +325 -0
  26. package/dist/formData.js +127 -0
  27. package/dist/formFlashId.js +4 -0
  28. package/dist/formRejection.js +23 -0
  29. package/dist/formSource.js +13 -0
  30. package/dist/frameworkRuntimesContext.js +8 -0
  31. package/dist/globalContext.js +10 -0
  32. package/dist/index.d.ts +152 -27
  33. package/dist/index.js +87 -4121
  34. package/dist/liveRowSort.js +66 -0
  35. package/dist/mutationConnectionSetup.js +16 -0
  36. package/dist/mutationIdentity.js +10 -0
  37. package/dist/mutationSerialExecution.js +53 -0
  38. package/dist/mutationsBus.js +40 -0
  39. package/dist/onlineSource.js +13 -0
  40. package/dist/outbox.js +213 -0
  41. package/dist/outboxHttp.js +104 -0
  42. package/dist/outboxState.js +43 -0
  43. package/dist/permissions.js +20 -0
  44. package/dist/platform.js +121 -0
  45. package/dist/preloadSeed.js +47 -0
  46. package/dist/provider.js +22 -0
  47. package/dist/query.js +12 -2
  48. package/dist/recoveryCoordinator.js +195 -0
  49. package/dist/recoveryRetry.js +24 -0
  50. package/dist/richText.js +176 -0
  51. package/dist/rpcErrorBus.js +39 -0
  52. package/dist/rpcErrorKind.js +13 -0
  53. package/dist/runRpc.js +12 -0
  54. package/dist/runtime.d.ts +49 -3
  55. package/dist/runtime.js +16 -126
  56. package/dist/runtimeCapabilities.js +44 -0
  57. package/dist/runtimeContext.js +49 -0
  58. package/dist/schemaFields.js +219 -0
  59. package/dist/scopeMembership.js +12 -0
  60. package/dist/seedResolvers.js +7 -0
  61. package/dist/sequence.js +65 -0
  62. package/dist/serverRequest.js +28 -0
  63. package/dist/serviceClient.js +129 -0
  64. package/dist/squashRpcCause.js +8 -0
  65. package/dist/stableKey.js +21 -0
  66. package/dist/store.js +288 -0
  67. package/dist/storeStorage.js +28 -0
  68. package/dist/subscriptionCache.js +724 -0
  69. package/dist/tagWalk.js +23 -0
  70. package/dist/traceBus.js +10 -0
  71. package/dist/tracking.js +40 -0
  72. package/dist/uploadProgress.js +21 -0
  73. package/dist/useAction.js +101 -0
  74. package/dist/useAgent.js +53 -0
  75. package/dist/useAgentChat.js +43 -0
  76. package/dist/useAgentStream.js +64 -0
  77. package/dist/useApiOnline.js +14 -0
  78. package/dist/useCapabilityManifest.js +105 -0
  79. package/dist/useConnectionSetup.js +28 -0
  80. package/dist/useConnectionStatus.js +38 -0
  81. package/dist/useConnections.js +107 -0
  82. package/dist/useDataCopilot.js +24 -0
  83. package/dist/useDataTable.js +34 -0
  84. package/dist/useDerived.js +22 -0
  85. package/dist/useEvent.js +98 -0
  86. package/dist/useFormBinding.js +478 -0
  87. package/dist/useLocalQuery.js +59 -0
  88. package/dist/useMutation.js +214 -0
  89. package/dist/useOnRpcError.js +13 -0
  90. package/dist/usePreloadedSubscription.js +18 -0
  91. package/dist/usePreview.js +14 -0
  92. package/dist/useProvenance.js +51 -0
  93. package/dist/useQueryField.js +34 -0
  94. package/dist/useRecord.js +12 -0
  95. package/dist/useRefreshSubscriptions.js +22 -0
  96. package/dist/useResourceCan.js +18 -0
  97. package/dist/useResumableAgentStream.js +75 -0
  98. package/dist/useRpcCaller.js +17 -0
  99. package/dist/useSequence.js +25 -0
  100. package/dist/useSkeleton.js +13 -0
  101. package/dist/useSubscription.js +98 -0
  102. package/dist/useSubscriptionHealth.js +32 -0
  103. package/dist/useTranscription.js +51 -0
  104. package/dist/useUndo.js +33 -0
  105. package/dist/useUndoLog.js +44 -0
  106. package/dist/useUpload.js +296 -0
  107. package/dist/useWindowedSubscription.js +65 -0
  108. package/dist/useWorkflow.js +284 -0
  109. package/dist/useWorkflowRunState.js +93 -0
  110. package/dist/validation.js +39 -0
  111. package/dist/validationMessages.js +5 -0
  112. package/package.json +7 -2
  113. package/dist/authRefresh-DmfSoCca.js +0 -360
  114. package/dist/formData-BfpBt7BQ.js +0 -769
  115. package/dist/queryOnce-D5Y4V1SB.js +0 -55
  116. package/dist/runRpc-Zfz3w709.js +0 -1172
@@ -1,769 +0,0 @@
1
- import { Schema as e, SchemaIssue as t } from "effect";
2
- import { finiteNumberView as n } from "@voltro/protocol";
3
- import * as r from "effect/SchemaAST";
4
- //#region src/schemaFields.ts
5
- var i = (e) => ({ voltroField: e }), a = "x-voltro", o = (t) => e.makeFilter(() => !0, { toJsonSchema: () => ({ [a]: t }) }), s = {
6
- "effect/schema/Date": "date",
7
- "effect/schema/DateTimeUtc": "date-time"
8
- }, c = (e) => {
9
- let t = e.annotations?.representation;
10
- return typeof t?.id == "string" ? t.id : void 0;
11
- }, l = (e, t = /* @__PURE__ */ new Map()) => {
12
- let n = t.get(e);
13
- if (n !== void 0) return n;
14
- let r = u(e, t);
15
- return t.set(e, r), r;
16
- }, u = (t, n) => {
17
- 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;
18
- if (r.isDeclaration(t)) {
19
- let e = s[c(t) ?? ""];
20
- if (e === void 0) return a(t);
21
- let { title: n, description: i } = t.annotations ?? {};
22
- return a(new r.String({
23
- format: e,
24
- ...typeof n == "string" ? { title: n } : {},
25
- ...typeof i == "string" ? { description: i } : {}
26
- }, void 0, void 0, t.context));
27
- }
28
- return t.encoding === void 0 ? r.isObjects(t) ? a(new r.Objects(t.propertySignatures.map((e) => new r.PropertySignature(e.name, l(e.type, n))), t.indexSignatures.map((e) => new r.IndexSignature(e.parameter, l(e.type, n))), t.annotations, t.checks, void 0, t.context)) : r.isArrays(t) ? a(new r.Arrays(t.isMutable, t.elements.map((e) => l(e, n)), t.rest.map((e) => l(e, n)), t.annotations, t.checks, void 0, t.context)) : r.isUnion(t) ? a(new r.Union(t.types.map((e) => l(e, n)), t.options, t.annotations, t.checks, void 0, t.context)) : r.isSuspend(t) ? a(new r.Suspend(() => l(t.thunk(), n), t.annotations, t.checks, void 0, t.context)) : a(t) : a(t);
29
- }, 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) => {
30
- let t = e.title;
31
- if (typeof t != "string") return;
32
- let n = t.trim();
33
- return n === "" ? void 0 : n;
34
- }, m = (e, t) => {
35
- let n = e;
36
- for (let e = 0; e < 8; e += 1) {
37
- let e = n.$ref;
38
- if (typeof e != "string" || !e.startsWith(d)) return g(n);
39
- let r = t[e.slice(8)];
40
- if (!r || typeof r != "object") return g(n);
41
- n = r;
42
- }
43
- return g(n);
44
- }, h = [
45
- "Infinity",
46
- "-Infinity",
47
- "NaN"
48
- ], g = (e) => {
49
- let t = e.anyOf;
50
- if (!Array.isArray(t) || t.length !== 2) return e;
51
- 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));
52
- if (i(n) && a(r) || i(r) && a(n)) {
53
- let { anyOf: t, ...n } = e;
54
- return {
55
- ...n,
56
- type: "number"
57
- };
58
- }
59
- return e;
60
- }, _ = (e) => {
61
- if (!e || typeof e != "object") return !1;
62
- let t = e;
63
- if (t.type === "null" || t.const === null) return !0;
64
- let n = t.enum;
65
- return Array.isArray(n) && n.length === 1 && n[0] === null;
66
- }, v = (e, t) => {
67
- let n = e.type;
68
- if (Array.isArray(n) && n.includes("null")) {
69
- let t = n.filter((e) => e !== "null");
70
- return {
71
- node: {
72
- ...e,
73
- type: t.length === 1 ? t[0] : t
74
- },
75
- nullable: !0
76
- };
77
- }
78
- for (let n of ["anyOf", "oneOf"]) {
79
- let r = e[n];
80
- if (!Array.isArray(r)) continue;
81
- let i, a = 0, o, s = r.length;
82
- for (let e = 0; e < s; e++) {
83
- if (!(e in r)) continue;
84
- let t = r[e];
85
- _(t) || (a += 1, a === 1 ? i = t : a === 2 ? o = [i, t] : o.push(t));
86
- }
87
- if (a !== r.length) return a === 1 ? {
88
- ...v(m(i, t), t),
89
- nullable: !0
90
- } : {
91
- node: {
92
- ...e,
93
- [n]: o ?? []
94
- },
95
- nullable: !0
96
- };
97
- }
98
- return {
99
- node: e,
100
- nullable: !1
101
- };
102
- }, y = (e) => e.map((e) => ({
103
- value: String(e),
104
- label: f(String(e))
105
- })), ee = (e) => {
106
- let t = e.enum;
107
- if (Array.isArray(t) && t.length > 0) return {
108
- widget: "select",
109
- options: y(t)
110
- };
111
- let n = e.type, r = Array.isArray(n) ? n.find((e) => e !== "null") : n, i = e.format;
112
- switch (r) {
113
- case "string": return i === "date" ? { widget: "date" } : i === "date-time" ? { widget: "datetime" } : { widget: "text" };
114
- case "integer":
115
- case "number": return { widget: "number" };
116
- case "boolean": return { widget: "checkbox" };
117
- case "array": return { widget: "multi-select" };
118
- default: return { widget: "custom" };
119
- }
120
- }, b = (...e) => {
121
- for (let t of e) {
122
- let e = [t, ...Array.isArray(t.allOf) ? t.allOf : []].find((e) => typeof e[a] == "object" && e[a] !== null);
123
- if (e !== void 0) return e[a];
124
- }
125
- return {};
126
- }, x = 4, S = (e, t, n, r = "", i, a = 0, o = []) => {
127
- let s = Object.entries(e);
128
- for (let e = 0; e < s.length; e += 1) {
129
- let [c, l] = s[e], u = m(l, n), { node: d, nullable: h } = v(u, n), g = m(d, n), _ = b(g, u), y = r === "" ? c : `${r}.${c}`, C = g.properties;
130
- if (g.type === "object" && C !== void 0 && a < x && _.widget === void 0) {
131
- S(C, new Set(Array.isArray(g.required) ? g.required : []), n, y, {
132
- path: _.section ?? y,
133
- label: _.label ?? p(g) ?? f(c)
134
- }, a + 1, o);
135
- continue;
136
- }
137
- let { widget: w, options: T } = ee(g), E, D = g;
138
- if (g.type === "array") {
139
- let e = g.items;
140
- if (typeof e == "object" && e && !Array.isArray(e)) {
141
- let t = m(e, n);
142
- D = {
143
- ...g,
144
- items: t
145
- };
146
- let r = t.properties;
147
- t.type === "object" && r !== void 0 && (w = "array", E = S(r, new Set(Array.isArray(t.required) ? t.required : []), n));
148
- }
149
- }
150
- _.widget !== void 0 && (w = _.widget), _.reference !== void 0 && _.widget === void 0 && (w = "reference");
151
- let O = typeof g.description == "string" ? g.description : void 0, k = _.section ?? i?.path;
152
- o.push({
153
- name: y,
154
- label: _.label ?? p(g) ?? f(c),
155
- widget: w,
156
- required: t.has(c),
157
- nullable: h,
158
- ...T ? { options: T } : {},
159
- jsonSchema: D,
160
- ...k === void 0 ? {} : {
161
- section: k,
162
- sectionLabel: i?.label ?? f(k)
163
- },
164
- ...O === void 0 ? {} : { description: O },
165
- ..._.order === void 0 ? {} : { order: _.order },
166
- ...E === void 0 ? {} : { item: E },
167
- ..._.reference === void 0 ? {} : { reference: _.reference }
168
- });
169
- }
170
- return o;
171
- }, C = (e) => {
172
- let t = !1;
173
- for (let n = 0; n < e.length; n += 1) if (e[n].order !== void 0) {
174
- t = !0;
175
- break;
176
- }
177
- if (!t) return e;
178
- 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]);
179
- for (let t = 0; t < n.length; t += 1) e[t] = n[t][0];
180
- return e;
181
- }, w = (t) => {
182
- try {
183
- let r = e.toJsonSchemaDocument(e.make(n(l(t.ast))));
184
- return {
185
- root: r.schema,
186
- defs: r.definitions
187
- };
188
- } catch {
189
- return;
190
- }
191
- }, T = (e) => {
192
- let t = w(e);
193
- if (t === void 0) return [];
194
- let { root: n, defs: r } = t, i = m(n, r), a = i.properties;
195
- return a ? C(S(a, new Set(Array.isArray(i.required) ? i.required : []), r)) : [];
196
- }, E = (e) => {
197
- let t = w(e);
198
- if (t === void 0) return [];
199
- let { root: n, defs: r } = t, i = m(n, r);
200
- if (i.type !== "array") return [];
201
- let a = i.items;
202
- if (!a || typeof a != "object") return [];
203
- let o = m(a, r), s = o.properties;
204
- return s ? S(s, new Set(Array.isArray(o.required) ? o.required : []), r) : [];
205
- }, D = (e) => {
206
- let t = [];
207
- for (let n of e) {
208
- let e = t[t.length - 1];
209
- if (e !== void 0 && e.name === n.section) {
210
- e.fields.push(n);
211
- continue;
212
- }
213
- t.push({
214
- name: n.section,
215
- label: n.sectionLabel,
216
- fields: [n]
217
- });
218
- }
219
- return t;
220
- }, O = {
221
- en: {
222
- "validation.required": "Required",
223
- "validation.invalid": "Invalid value",
224
- "validation.minLength": "Must be at least {min} characters",
225
- "validation.maxLength": "Must be at most {max} characters",
226
- "validation.pattern": "Invalid format",
227
- "validation.minValue": "Must be at least {min}",
228
- "validation.maxValue": "Must be at most {max}",
229
- "validation.minItems": "Add at least {min}",
230
- "validation.maxItems": "No more than {max}",
231
- "validation.integer": "Must be a whole number",
232
- "validation.checking": "Still checking…",
233
- "validation.invalidEmail": "Enter a valid email address",
234
- "validation.invalidUrl": "Enter a valid URL",
235
- "validation.invalidUuid": "Enter a valid identifier",
236
- "validation.betweenLength": "Must be between {min} and {max} characters",
237
- "validation.exactLength": "Must be exactly {amount} characters",
238
- "validation.minDate": "Must not be earlier than {min}",
239
- "validation.maxDate": "Must not be later than {max}",
240
- "validation.invalidFileType": "This file type is not allowed",
241
- "validation.fileTooLarge": "File is too large"
242
- },
243
- de: {
244
- "validation.required": "Pflichtfeld",
245
- "validation.invalid": "Ungültiger Wert",
246
- "validation.minLength": "Mindestens {min} Zeichen",
247
- "validation.maxLength": "Höchstens {max} Zeichen",
248
- "validation.pattern": "Ungültiges Format",
249
- "validation.minValue": "Mindestens {min}",
250
- "validation.maxValue": "Höchstens {max}",
251
- "validation.minItems": "Mindestens {min}",
252
- "validation.maxItems": "Höchstens {max}",
253
- "validation.integer": "Ganze Zahl erforderlich",
254
- "validation.checking": "Prüfung läuft…",
255
- "validation.invalidEmail": "Bitte eine gültige E-Mail-Adresse eingeben",
256
- "validation.invalidUrl": "Bitte eine gültige URL eingeben",
257
- "validation.invalidUuid": "Bitte eine gültige Kennung eingeben",
258
- "validation.betweenLength": "Muss zwischen {min} und {max} Zeichen haben",
259
- "validation.exactLength": "Muss genau {amount} Zeichen haben",
260
- "validation.minDate": "Darf nicht früher sein als {min}",
261
- "validation.maxDate": "Darf nicht später sein als {max}",
262
- "validation.invalidFileType": "Dieser Dateityp ist nicht erlaubt",
263
- "validation.fileTooLarge": "Die Datei ist zu groß"
264
- }
265
- }, k = (e, t) => {
266
- let n = !1, r = e.replace(/\{(\w+)\}/g, (e, r) => {
267
- let i = t?.[r];
268
- return i === void 0 ? (n = !0, e) : String(i);
269
- });
270
- return n ? void 0 : r;
271
- }, A = () => {
272
- let e = globalThis.document?.documentElement?.lang ?? "";
273
- return e === "" ? "en" : e;
274
- }, j = (e, t) => {
275
- let n = t?.messages?.(e.id, e.params, e.fallback);
276
- if (n !== void 0) return n;
277
- let r = O[(t?.locale ?? A()).toLowerCase().split("-")[0] ?? "en"]?.[e.id] ?? O.en?.[e.id];
278
- return (r === void 0 ? void 0 : k(r, e.params)) ?? e.fallback;
279
- }, te = (e) => {
280
- let t = /^([a-z][\w-]*(?:\.[\w-]+)+)\|(\{.*\})$/.exec(e);
281
- if (t !== null && t[1] !== void 0 && t[2] !== void 0) try {
282
- return {
283
- id: t[1],
284
- params: JSON.parse(t[2]),
285
- fallback: e
286
- };
287
- } catch {}
288
- return /^[a-z][\w-]*(?:\.[\w-]+)+$/.test(e) ? {
289
- id: e,
290
- fallback: e
291
- } : {
292
- id: "validation.custom",
293
- fallback: e
294
- };
295
- }, ne = {
296
- email: "validation.invalidEmail",
297
- "idn-email": "validation.invalidEmail",
298
- uri: "validation.invalidUrl",
299
- url: "validation.invalidUrl",
300
- uuid: "validation.invalidUuid"
301
- }, M = (e, t, n) => {
302
- let i = e.ast;
303
- for (let e of t.split(".")) {
304
- if (i === void 0) return {};
305
- if (/^\d+$/.test(e)) {
306
- i = r.isArrays(i) ? i.rest[0] ?? i.elements[0] : void 0;
307
- continue;
308
- }
309
- let t = n?.get(i);
310
- if (t !== void 0) {
311
- i = t.get(e);
312
- continue;
313
- }
314
- let a;
315
- if (!r.isObjects(i)) return {};
316
- if (a = i.propertySignatures, n !== void 0 && a.length >= 32) {
317
- let t = /* @__PURE__ */ new Map();
318
- for (let e of a) {
319
- let n = String(e.name);
320
- t.has(n) || t.set(n, e.type);
321
- }
322
- n.set(i, t), i = t.get(e);
323
- } else i = a.find((t) => String(t.name) === e)?.type;
324
- }
325
- let a = {};
326
- for (let e of i?.checks ?? []) {
327
- let t = N(e.annotations);
328
- if (t === void 0) continue;
329
- let n = t.payload ?? {};
330
- a.min === void 0 && t.id === "effect/schema/isMinLength" && typeof n.minLength == "number" && (a.min = n.minLength), a.max === void 0 && t.id === "effect/schema/isMaxLength" && typeof n.maxLength == "number" && (a.max = n.maxLength);
331
- }
332
- return a;
333
- }, N = (e) => {
334
- let t = e?.representation;
335
- return t !== void 0 && typeof t.id == "string" ? {
336
- id: t.id,
337
- payload: t.payload
338
- } : void 0;
339
- }, P = (e, t) => {
340
- let n = N(e), r = n?.payload ?? {};
341
- switch (n?.id) {
342
- case "effect/schema/isMinLength": return t ? {
343
- id: "validation.minItems",
344
- params: {
345
- count: r.minLength,
346
- min: r.minLength
347
- }
348
- } : {
349
- id: "validation.minLength",
350
- params: { min: r.minLength }
351
- };
352
- case "effect/schema/isMaxLength": return t ? {
353
- id: "validation.maxItems",
354
- params: {
355
- count: r.maxLength,
356
- max: r.maxLength
357
- }
358
- } : {
359
- id: "validation.maxLength",
360
- params: { max: r.maxLength }
361
- };
362
- case "effect/schema/isBetweenLength": {
363
- let e = r.minimum, t = r.maximum;
364
- return e === t ? {
365
- id: "validation.exactLength",
366
- params: { amount: e }
367
- } : {
368
- id: "validation.betweenLength",
369
- params: {
370
- min: e,
371
- max: t
372
- }
373
- };
374
- }
375
- case "effect/schema/isPattern": {
376
- let t = typeof e?.format == "string" ? ne[e.format] : void 0;
377
- return t === void 0 ? {
378
- id: "validation.pattern",
379
- params: { pattern: r.source }
380
- } : { id: t };
381
- }
382
- case "effect/schema/isGreaterThanOrEqualTo": return {
383
- id: "validation.minValue",
384
- params: { min: r.minimum }
385
- };
386
- case "effect/schema/isLessThanOrEqualTo": return {
387
- id: "validation.maxValue",
388
- params: { max: r.maximum }
389
- };
390
- case "effect/schema/isGreaterThan": return {
391
- id: "validation.minValue",
392
- params: {
393
- min: r.exclusiveMinimum,
394
- exclusive: !0
395
- }
396
- };
397
- case "effect/schema/isLessThan": return {
398
- id: "validation.maxValue",
399
- params: {
400
- max: r.exclusiveMaximum,
401
- exclusive: !0
402
- }
403
- };
404
- case "effect/schema/isInt": return { id: "validation.integer" };
405
- case "effect/schema/isBetween": return {
406
- id: "validation.minValue",
407
- params: {
408
- min: r.minimum,
409
- max: r.maximum
410
- }
411
- };
412
- default: {
413
- let e = n?.id ?? "";
414
- return /isGreaterThanOrEqualToDate|isGreaterThanDate/.test(e) ? { id: "validation.minDate" } : /isLessThanOrEqualToDate|isLessThanDate/.test(e) ? { id: "validation.maxDate" } : { id: "validation.invalid" };
415
- }
416
- }
417
- }, F = (e) => {
418
- let t = e?.message;
419
- return typeof t == "string" && t.length > 0 ? t : void 0;
420
- }, re = (e) => e.map((e) => String(e)), ie = t.makeFormatterDefault(), I = (e) => {
421
- let t = [], n = (e, n, r, i) => {
422
- t.push({
423
- path: e.join("."),
424
- id: n,
425
- ...r === void 0 ? {} : { params: r },
426
- fallback: i
427
- });
428
- }, r = (e, t) => {
429
- let r = te(t);
430
- n(e, r.id, r.params, r.fallback);
431
- }, i = (e, t, a = !1) => {
432
- switch (e._tag) {
433
- case "Composite":
434
- for (let n of e.issues) i(n, t, e.ast._tag === "Arrays");
435
- return;
436
- case "AnyOf":
437
- for (let n of e.issues) i(n, t, a);
438
- return;
439
- case "Pointer":
440
- i(e.issue, [...t, ...re(e.path)]);
441
- return;
442
- case "Encoding":
443
- i(e.issue, t, a);
444
- return;
445
- case "Filter": {
446
- let o = e.filter.annotations, s = F(o);
447
- if (s !== void 0) return r(t, s);
448
- let c = P(o, a);
449
- if (c.id !== "validation.invalid") {
450
- n(t, c.id, c.params, L(e));
451
- return;
452
- }
453
- if (e.issue._tag === "Pointer" || e.issue._tag === "Composite" || e.issue._tag === "InvalidValue") {
454
- i(e.issue, t);
455
- return;
456
- }
457
- n(t, "validation.invalid", void 0, L(e));
458
- return;
459
- }
460
- case "MissingKey":
461
- n(t, "validation.required", void 0, "Required");
462
- return;
463
- case "InvalidValue": {
464
- let i = F(e.annotations);
465
- if (i !== void 0) return r(t, i);
466
- n(t, "validation.invalid", void 0, L(e));
467
- return;
468
- }
469
- default:
470
- n(t, "validation.invalid", void 0, L(e));
471
- return;
472
- }
473
- };
474
- return i(e.issue, []), t;
475
- }, L = (e) => {
476
- let t = ie(e).split("\n")[0] ?? "";
477
- return t.length > 0 ? t : "Invalid value";
478
- }, ae = (e, t) => {
479
- if (typeof t != "object" || !t || Array.isArray(t)) return {
480
- input: t,
481
- dropped: []
482
- };
483
- let n;
484
- try {
485
- let t = e.ast;
486
- if (!r.isObjects(t)) throw Error("not an object schema");
487
- n = t.propertySignatures.map((e) => String(e.name));
488
- } catch {
489
- return {
490
- input: t,
491
- dropped: []
492
- };
493
- }
494
- if (n.length === 0) return {
495
- input: t,
496
- dropped: []
497
- };
498
- let i = new Set(n), a = Object.entries(t), o = [], s = 0;
499
- for (let e = 0; e < a.length; e += 1) {
500
- let t = a[e];
501
- i.has(t[0]) ? a[s++] = t : o.push(t[0]);
502
- }
503
- return o.length === 0 ? {
504
- input: t,
505
- dropped: []
506
- } : (a.length = s, {
507
- input: Object.fromEntries(a),
508
- dropped: o
509
- });
510
- }, oe = (t, n, r) => {
511
- let i = e.decodeUnknownResult(t, { errors: "all" })(n);
512
- if (i._tag === "Success") return {
513
- valid: !0,
514
- errors: {},
515
- issues: []
516
- };
517
- let a = I(i.failure), o = a.length >= 32 ? /* @__PURE__ */ new WeakMap() : void 0, s = a.map((e) => {
518
- if (e.id !== "validation.minLength" && e.id !== "validation.maxLength") return e;
519
- let n = M(t, e.path, o);
520
- return n.min === void 0 || n.max === void 0 ? e : n.min === n.max ? {
521
- ...e,
522
- id: "validation.exactLength",
523
- params: { amount: n.min }
524
- } : {
525
- ...e,
526
- id: "validation.betweenLength",
527
- params: {
528
- min: n.min,
529
- max: n.max
530
- }
531
- };
532
- }), c = {};
533
- for (let e of s) e.path !== "" && !(e.path in c) && (c[e.path] = j(e, r));
534
- return {
535
- valid: !1,
536
- errors: c,
537
- issues: s
538
- };
539
- }, R = [
540
- "bold",
541
- "italic",
542
- "code",
543
- "strike"
544
- ], se = 5e3, ce = (e) => {
545
- let t = "";
546
- for (let n of e) {
547
- let e = n.codePointAt(0) ?? 0;
548
- if (e > 32 && e !== 127 && (t += n, t.length >= 8 || t === "#" || t.startsWith("/") && t.length >= 2)) break;
549
- }
550
- return t.toLowerCase();
551
- }, z = (e) => {
552
- let t = ce(e);
553
- return t.length === 0 ? !1 : t.startsWith("#") || t.startsWith("/") ? !t.startsWith("//") : t.startsWith("https://") || t.startsWith("http://") || t.startsWith("mailto:");
554
- }, B = e.String.pipe(e.check(e.makeFilter((e) => z(e) || "href must be http(s), mailto:, a #fragment or a /path"))), V = e.Struct({
555
- type: e.Literal("text"),
556
- text: e.String,
557
- marks: e.optional(e.Array(e.Literals(R)))
558
- }), H = e.Struct({
559
- type: e.Literal("link"),
560
- href: B,
561
- content: e.Array(V)
562
- }), U = e.Union([V, H]), W = e.Struct({
563
- type: e.Literal("listItem"),
564
- content: e.Array(U)
565
- }), le = e.Union([
566
- e.Struct({
567
- type: e.Literal("paragraph"),
568
- content: e.Array(U)
569
- }),
570
- e.Struct({
571
- type: e.Literal("heading"),
572
- level: e.Literals([
573
- 1,
574
- 2,
575
- 3
576
- ]),
577
- content: e.Array(U)
578
- }),
579
- e.Struct({
580
- type: e.Literal("blockquote"),
581
- content: e.Array(U)
582
- }),
583
- e.Struct({
584
- type: e.Literal("bulletList"),
585
- content: e.Array(W)
586
- }),
587
- e.Struct({
588
- type: e.Literal("orderedList"),
589
- content: e.Array(W)
590
- }),
591
- e.Struct({
592
- type: e.Literal("codeBlock"),
593
- text: e.String
594
- })
595
- ]), ue = (e) => {
596
- let t = 1, n = (e) => {
597
- for (let r of e) {
598
- if (t += 1, t > 5e3) return;
599
- let e = r.content;
600
- if (Array.isArray(e) && n(e), t > 5e3) return;
601
- }
602
- };
603
- return n(e.content), t;
604
- }, de = e.Struct({
605
- type: e.Literal("doc"),
606
- content: e.Array(le)
607
- }).pipe(e.check(e.makeFilter((e) => ue(e) <= 5e3 || "rich text document exceeds 5000 nodes")), e.annotate(i({ widget: "rich-text" }))), fe = {
608
- type: "doc",
609
- content: []
610
- }, G = (e) => typeof e == "object" && !!e && e.type === "doc" && Array.isArray(e.content), pe = /(\*\*([^*]+)\*\*)|(~~([^~]+)~~)|(\*([^*]+)\*)|(`([^`]+)`)|(\[([^\]]*)\]\(([^)\s]+)\))/, K = (e, t) => t && t.length > 0 ? {
611
- type: "text",
612
- text: e,
613
- marks: t
614
- } : {
615
- type: "text",
616
- text: e
617
- }, q = (e) => {
618
- let t = [], n = e;
619
- for (;;) {
620
- let e = pe.exec(n);
621
- if (e === null || e.index === void 0) break;
622
- e.index > 0 && t.push(K(n.slice(0, e.index))), e[2] === void 0 ? e[4] === void 0 ? e[6] === void 0 ? e[8] === void 0 ? e[11] !== void 0 && (z(e[11]) ? t.push({
623
- type: "link",
624
- href: e[11],
625
- content: [{
626
- type: "text",
627
- text: e[10] ?? ""
628
- }]
629
- }) : t.push(K(e[0]))) : t.push(K(e[8], ["code"])) : t.push(K(e[6], ["italic"])) : t.push(K(e[4], ["strike"])) : t.push(K(e[2], ["bold"])), n = n.slice(e.index + e[0].length);
630
- }
631
- return n.length > 0 && t.push(K(n)), t;
632
- }, J = (e, t) => e.map((e) => ({
633
- type: "listItem",
634
- content: q(e.replace(t, ""))
635
- })), me = (e) => {
636
- if (e.length === 0) return null;
637
- let t = e[0];
638
- if (t.startsWith("```")) {
639
- let t = "", n = !1;
640
- for (let r of e) r.startsWith("```") || (n && (t += "\n"), t += r, n = !0);
641
- return {
642
- type: "codeBlock",
643
- text: t
644
- };
645
- }
646
- let n = /^(#{1,3})\s+(.*)$/.exec(t);
647
- if (n !== null) return {
648
- type: "heading",
649
- level: n[1].length,
650
- content: q(n[2])
651
- };
652
- if (e.every((e) => /^[-*]\s+/.test(e))) return {
653
- type: "bulletList",
654
- content: J(e, /^[-*]\s+/)
655
- };
656
- if (e.every((e) => /^\d+\.\s+/.test(e))) return {
657
- type: "orderedList",
658
- content: J(e, /^\d+\.\s+/)
659
- };
660
- if (e.every((e) => e.startsWith(">"))) {
661
- for (let t = 0; t < e.length; t++) e[t] = e[t].replace(/^>\s?/, "");
662
- return {
663
- type: "blockquote",
664
- content: q(e.join(" "))
665
- };
666
- }
667
- return {
668
- type: "paragraph",
669
- content: q(e.join(" "))
670
- };
671
- }, Y = (e) => {
672
- let t = [], n = [], r = () => {
673
- let e = me(n);
674
- e !== null && t.push(e), n = [];
675
- };
676
- for (let t of e.replace(/\r\n/g, "\n").split("\n")) t.trim() === "" ? r() : n.push(t);
677
- return r(), {
678
- type: "doc",
679
- content: t
680
- };
681
- }, X = (e) => e.map((e) => {
682
- if (e.type === "link") return `[${e.content.map((e) => e.text).join("")}](${e.href})`;
683
- let t = e.marks ?? [];
684
- return t.includes("bold") ? `**${e.text}**` : t.includes("strike") ? `~~${e.text}~~` : t.includes("italic") ? `*${e.text}*` : t.includes("code") ? `\`${e.text}\`` : e.text;
685
- }).join(""), he = (e) => G(e) ? e.content.map((e) => {
686
- switch (e.type) {
687
- case "heading": return `${"#".repeat(e.level)} ${X(e.content)}`;
688
- case "bulletList": return e.content.map((e) => `- ${X(e.content)}`).join("\n");
689
- case "orderedList": return e.content.map((e, t) => `${t + 1}. ${X(e.content)}`).join("\n");
690
- case "blockquote": return `> ${X(e.content)}`;
691
- case "codeBlock": return [
692
- "```",
693
- e.text,
694
- "```"
695
- ].join("\n");
696
- default: return X(e.content);
697
- }
698
- }).join("\n\n") : "", Z = (e) => {
699
- if (!G(e)) return "";
700
- let t = (e) => e.map((e) => e.type === "link" ? e.content.map((e) => e.text).join("") : e.text).join("");
701
- return e.content.map((e) => {
702
- switch (e.type) {
703
- case "bulletList":
704
- case "orderedList": return e.content.map((e) => t(e.content)).join("\n");
705
- case "codeBlock": return e.text;
706
- default: return t(e.content);
707
- }
708
- }).join("\n\n");
709
- }, ge = "__voltro_form_flash__", Q = "/form/", _e = (e) => `${Q}${encodeURIComponent(e)}`, ve = "__voltro_form", ye = "__voltro_redirect", $ = (e) => {
710
- let t = Number(e);
711
- return Number.isNaN(t) ? e : t;
712
- }, be = (e) => {
713
- let t = e.jsonSchema.items;
714
- if (!t || typeof t != "object") return;
715
- let n = t.type;
716
- return typeof n == "string" ? n : void 0;
717
- }, xe = (e, t) => {
718
- switch (e.widget) {
719
- case "rich-text": return t === "" ? {
720
- type: "doc",
721
- content: []
722
- } : Y(t);
723
- case "number": return t === "" ? void 0 : $(t);
724
- case "date":
725
- case "datetime": return t === "" ? void 0 : t;
726
- default: return t;
727
- }
728
- }, Se = (e, t) => {
729
- let n = /* @__PURE__ */ new Map();
730
- for (let [e, r] of t) {
731
- let t = n.get(e);
732
- t === void 0 ? n.set(e, [r]) : t.push(r);
733
- }
734
- let r = {}, i = (e, t) => {
735
- if (!e.includes(".")) {
736
- r[e] = t;
737
- return;
738
- }
739
- let n = e.split("."), i = r;
740
- for (let e = 0; e < n.length - 1; e += 1) {
741
- let t = n[e], r = i[t];
742
- if (typeof r != "object" || !r) {
743
- let e = {};
744
- i[t] = e, i = e;
745
- } else i = r;
746
- }
747
- i[n[n.length - 1]] = t;
748
- };
749
- for (let t of T(e)) {
750
- if (t.widget === "array") continue;
751
- let e = n.get(t.name);
752
- if (t.widget === "checkbox" || t.widget === "switch") {
753
- i(t.name, e !== void 0);
754
- continue;
755
- }
756
- if (t.widget === "multi-select") {
757
- let n = be(t), r = e ?? [], a = n === "number" || n === "integer", o = r.filter((e) => e !== "");
758
- if (a) for (let e = 0; e < o.length; e += 1) o[e] = $(o[e]);
759
- i(t.name, o);
760
- continue;
761
- }
762
- if (e === void 0) continue;
763
- let r = xe(t, e[0]);
764
- r !== void 0 && i(t.name, r);
765
- }
766
- return r;
767
- };
768
- //#endregion
769
- export { E as C, D as S, A as _, _e as a, oe as b, se as c, G as d, z as f, I as g, he as h, ye as i, de as l, Z as m, ve as n, Se as o, Y as p, Q as r, R as s, ge as t, fe as u, j as v, T as w, i as x, ae as y };