@voltro/client 0.52.0 → 0.54.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 +424 -0
- package/THIRD-PARTY-NOTICES.md +169 -1
- package/dist/form.d.ts +111 -10
- package/dist/form.js +2 -2
- package/dist/formData-BO7zkG_F.js +386 -0
- package/dist/index.d.ts +393 -16
- package/dist/index.js +1158 -810
- package/package.json +4 -2
- package/dist/formData-Bw07C0wr.js +0 -155
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Framework-agnostic client bindings — the typed RpcClient, subscription cache, and reactive data layer the web hooks build on.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
"node": ">=24.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@
|
|
41
|
+
"@tanstack/form-core": "^1.33.5",
|
|
42
|
+
"@tanstack/react-store": "^0.11.1",
|
|
43
|
+
"@voltro/protocol": "0.54.0"
|
|
42
44
|
},
|
|
43
45
|
"peerDependencies": {
|
|
44
46
|
"@effect/platform": "^0.97.0",
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { JSONSchema as e, Schema as t } from "effect";
|
|
2
|
-
import { ArrayFormatter as n } from "effect/ParseResult";
|
|
3
|
-
//#region src/schemaFields.ts
|
|
4
|
-
var r = "#/$defs/", i = (e) => e.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/^./, (e) => e.toUpperCase()), a = (e, t) => {
|
|
5
|
-
let n = e;
|
|
6
|
-
for (let e = 0; e < 8; e += 1) {
|
|
7
|
-
let e = n.$ref;
|
|
8
|
-
if (typeof e != "string" || !e.startsWith(r)) return n;
|
|
9
|
-
let i = t[e.slice(8)];
|
|
10
|
-
if (!i || typeof i != "object") return n;
|
|
11
|
-
n = i;
|
|
12
|
-
}
|
|
13
|
-
return n;
|
|
14
|
-
}, o = (e) => {
|
|
15
|
-
if (!e || typeof e != "object") return !1;
|
|
16
|
-
let t = e;
|
|
17
|
-
if (t.type === "null" || t.const === null) return !0;
|
|
18
|
-
let n = t.enum;
|
|
19
|
-
return Array.isArray(n) && n.length === 1 && n[0] === null;
|
|
20
|
-
}, s = (e, t) => {
|
|
21
|
-
let n = e.type;
|
|
22
|
-
if (Array.isArray(n) && n.includes("null")) {
|
|
23
|
-
let t = n.filter((e) => e !== "null");
|
|
24
|
-
return {
|
|
25
|
-
node: {
|
|
26
|
-
...e,
|
|
27
|
-
type: t.length === 1 ? t[0] : t
|
|
28
|
-
},
|
|
29
|
-
nullable: !0
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
for (let n of ["anyOf", "oneOf"]) {
|
|
33
|
-
let r = e[n];
|
|
34
|
-
if (!Array.isArray(r)) continue;
|
|
35
|
-
let i = r.filter((e) => !o(e));
|
|
36
|
-
if (i.length !== r.length) return i.length === 1 ? {
|
|
37
|
-
node: a(i[0], t),
|
|
38
|
-
nullable: !0
|
|
39
|
-
} : {
|
|
40
|
-
node: {
|
|
41
|
-
...e,
|
|
42
|
-
[n]: i
|
|
43
|
-
},
|
|
44
|
-
nullable: !0
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
node: e,
|
|
49
|
-
nullable: !1
|
|
50
|
-
};
|
|
51
|
-
}, c = (e) => e.map((e) => ({
|
|
52
|
-
value: String(e),
|
|
53
|
-
label: i(String(e))
|
|
54
|
-
})), l = (e) => {
|
|
55
|
-
let t = e.enum;
|
|
56
|
-
if (Array.isArray(t) && t.length > 0) return {
|
|
57
|
-
widget: "select",
|
|
58
|
-
options: c(t)
|
|
59
|
-
};
|
|
60
|
-
let n = e.type, r = Array.isArray(n) ? n.find((e) => e !== "null") : n, i = e.format;
|
|
61
|
-
switch (r) {
|
|
62
|
-
case "string": return i === "date" ? { widget: "date" } : i === "date-time" ? { widget: "datetime" } : { widget: "text" };
|
|
63
|
-
case "integer":
|
|
64
|
-
case "number": return { widget: "number" };
|
|
65
|
-
case "boolean": return { widget: "checkbox" };
|
|
66
|
-
case "array": return { widget: "multi-select" };
|
|
67
|
-
default: return { widget: "custom" };
|
|
68
|
-
}
|
|
69
|
-
}, u = (e, t, n) => Object.entries(e).map(([e, r]) => {
|
|
70
|
-
let { node: o, nullable: c } = s(a(r, n), n), u = a(o, n), { widget: d, options: f } = l(u);
|
|
71
|
-
return {
|
|
72
|
-
name: e,
|
|
73
|
-
label: i(e),
|
|
74
|
-
widget: d,
|
|
75
|
-
required: t.has(e),
|
|
76
|
-
nullable: c,
|
|
77
|
-
...f ? { options: f } : {},
|
|
78
|
-
jsonSchema: u
|
|
79
|
-
};
|
|
80
|
-
}), d = (t) => {
|
|
81
|
-
try {
|
|
82
|
-
return e.make(t);
|
|
83
|
-
} catch {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
}, f = (e) => {
|
|
87
|
-
let t = d(e);
|
|
88
|
-
if (t === void 0) return [];
|
|
89
|
-
let n = t.$defs ?? {}, r = a(t, n), i = r.properties;
|
|
90
|
-
return i ? u(i, new Set(Array.isArray(r.required) ? r.required : []), n) : [];
|
|
91
|
-
}, p = (e) => {
|
|
92
|
-
let t = d(e);
|
|
93
|
-
if (t === void 0) return [];
|
|
94
|
-
let n = t.$defs ?? {}, r = a(t, n);
|
|
95
|
-
if (r.type !== "array") return [];
|
|
96
|
-
let i = r.items;
|
|
97
|
-
if (!i || typeof i != "object") return [];
|
|
98
|
-
let o = a(i, n), s = o.properties;
|
|
99
|
-
return s ? u(s, new Set(Array.isArray(o.required) ? o.required : []), n) : [];
|
|
100
|
-
}, m = (e, r) => {
|
|
101
|
-
let i = t.decodeUnknownEither(e, { errors: "all" })(r);
|
|
102
|
-
if (i._tag === "Right") return {
|
|
103
|
-
valid: !0,
|
|
104
|
-
errors: {}
|
|
105
|
-
};
|
|
106
|
-
let a = {};
|
|
107
|
-
for (let e of n.formatErrorSync(i.left)) {
|
|
108
|
-
let t = e.path.length === 0 ? "" : String(e.path[0]);
|
|
109
|
-
t !== "" && !(t in a) && (a[t] = e.message);
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
valid: !1,
|
|
113
|
-
errors: a
|
|
114
|
-
};
|
|
115
|
-
}, h = "__voltro_form_flash__", g = "/form/", _ = (e) => `${g}${encodeURIComponent(e)}`, v = "__voltro_form", y = "__voltro_redirect", b = (e) => {
|
|
116
|
-
let t = Number(e);
|
|
117
|
-
return Number.isNaN(t) ? e : t;
|
|
118
|
-
}, x = (e) => {
|
|
119
|
-
let t = e.jsonSchema.items;
|
|
120
|
-
if (!t || typeof t != "object") return;
|
|
121
|
-
let n = t.type;
|
|
122
|
-
return typeof n == "string" ? n : void 0;
|
|
123
|
-
}, S = (e, t) => {
|
|
124
|
-
switch (e.widget) {
|
|
125
|
-
case "number": return t === "" ? void 0 : b(t);
|
|
126
|
-
case "date":
|
|
127
|
-
case "datetime": return t === "" ? void 0 : t;
|
|
128
|
-
default: return t;
|
|
129
|
-
}
|
|
130
|
-
}, C = (e, t) => {
|
|
131
|
-
let n = /* @__PURE__ */ new Map();
|
|
132
|
-
for (let [e, r] of t) {
|
|
133
|
-
let t = n.get(e);
|
|
134
|
-
t === void 0 ? n.set(e, [r]) : t.push(r);
|
|
135
|
-
}
|
|
136
|
-
let r = {};
|
|
137
|
-
for (let t of f(e)) {
|
|
138
|
-
let e = n.get(t.name);
|
|
139
|
-
if (t.widget === "checkbox" || t.widget === "switch") {
|
|
140
|
-
r[t.name] = e !== void 0;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (t.widget === "multi-select") {
|
|
144
|
-
let n = x(t), i = e ?? [];
|
|
145
|
-
r[t.name] = n === "number" || n === "integer" ? i.filter((e) => e !== "").map(b) : i.filter((e) => e !== "");
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (e === void 0) continue;
|
|
149
|
-
let i = S(t, e[0]);
|
|
150
|
-
i !== void 0 && (r[t.name] = i);
|
|
151
|
-
}
|
|
152
|
-
return r;
|
|
153
|
-
};
|
|
154
|
-
//#endregion
|
|
155
|
-
export { _ as a, p as c, y as i, f as l, v as n, C as o, g as r, m as s, h as t };
|