mlform 0.1.19 → 0.1.22
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/README.md +2 -2
- package/dist/{builtins-6Cv46IXP.js → builtins-B2U_ViF6.js} +12 -14
- package/dist/mlform/builtins.mjs +1 -1
- package/dist/mlform/kit.mjs +6 -8
- package/dist/mlform/primitives.mjs +1 -1
- package/dist/mlform/runtime.mjs +3 -3
- package/dist/mlform/schema.mjs +2 -2
- package/dist/mlform/transport.mjs +2 -2
- package/dist/{primitives-BNBNG2Aa.js → primitives-ljp3c5R8.js} +11 -54
- package/dist/{runtime-Eo_q4pgg.js → runtime-C9ZioNpI.js} +405 -683
- package/dist/schema-CiCjXECD.js +350 -0
- package/dist/transport-KUB3zfW9.js +65 -0
- package/dist/types/src/kit/constants.d.ts +0 -1
- package/dist/types/src/kit/kinds/define-report-kind.d.ts +1 -3
- package/dist/types/src/primitives/components/form-root-state.d.ts +0 -4
- package/dist/types/src/primitives/components/submit-button.d.ts +0 -4
- package/dist/types/src/primitives/controller-types.d.ts +9 -23
- package/dist/types/src/runtime/errors.d.ts +0 -1
- package/dist/types/src/runtime/index.d.ts +1 -2
- package/dist/types/src/runtime/reports/controller.d.ts +1 -2
- package/dist/types/src/runtime/state/engine.d.ts +1 -5
- package/dist/types/src/runtime/submission/create-submitter.d.ts +1 -1
- package/dist/types/src/runtime/submission/index.d.ts +1 -0
- package/dist/types/src/runtime/submission/reports.d.ts +1 -2
- package/dist/types/src/runtime/submission/request.d.ts +2 -18
- package/dist/types/src/runtime/submission/transport-response.d.ts +2 -0
- package/dist/types/src/runtime/submission/types.d.ts +2 -23
- package/dist/types/src/runtime/types/behavior.d.ts +1 -7
- package/dist/types/src/runtime/types/form.d.ts +1 -14
- package/dist/types/src/runtime/types/report.d.ts +1 -1
- package/dist/types/src/runtime/types/transport.d.ts +5 -16
- package/dist/types/src/schema/index.d.ts +1 -0
- package/dist/types/src/schema/mapped-to.d.ts +13 -1
- package/dist/types/src/schema/normalize.d.ts +5 -0
- package/dist/types/src/schema/report-context.d.ts +2 -2
- package/dist/types/src/schema/types/report.d.ts +5 -11
- package/dist/types/src/schema/types/submit.d.ts +28 -11
- package/dist/types/src/schema/validation.d.ts +25 -0
- package/dist/types/src/transport/errors.d.ts +1 -28
- package/dist/types/src/transport/fanout.d.ts +17 -0
- package/dist/types/src/transport/index.d.ts +4 -10
- package/dist/types/src/transport/request-runner.d.ts +3 -2
- package/dist/types/src/transport/types.d.ts +18 -0
- package/package.json +1 -1
- package/dist/schema-CNKKJZRx.js +0 -173
- package/dist/transport-Cloa_erk.js +0 -2154
- package/dist/types/src/runtime/submission/field-updates.d.ts +0 -14
- package/dist/types/src/runtime/submission/pending-patches.d.ts +0 -2
- package/dist/types/src/runtime/submission/report-updates.d.ts +0 -16
- package/dist/types/src/runtime/submission/stream-events.d.ts +0 -13
- package/dist/types/src/runtime/submission/stream-progress.d.ts +0 -4
- package/dist/types/src/transport/capabilities.d.ts +0 -7
- package/dist/types/src/transport/clone.d.ts +0 -6
- package/dist/types/src/transport/composition/fallback.d.ts +0 -2
- package/dist/types/src/transport/composition/fanout-helpers.d.ts +0 -2
- package/dist/types/src/transport/composition/fanout-options.d.ts +0 -9
- package/dist/types/src/transport/composition/fanout.d.ts +0 -2
- package/dist/types/src/transport/composition/hedged.d.ts +0 -2
- package/dist/types/src/transport/composition/index.d.ts +0 -8
- package/dist/types/src/transport/composition/load-balancing.d.ts +0 -2
- package/dist/types/src/transport/composition/pipeline.d.ts +0 -2
- package/dist/types/src/transport/composition/quorum-fanout.d.ts +0 -2
- package/dist/types/src/transport/composition/racing.d.ts +0 -2
- package/dist/types/src/transport/composition/routing.d.ts +0 -3
- package/dist/types/src/transport/constants.d.ts +0 -34
- package/dist/types/src/transport/internal-core.d.ts +0 -21
- package/dist/types/src/transport/internal-errors.d.ts +0 -21
- package/dist/types/src/transport/internal-request.d.ts +0 -21
- package/dist/types/src/transport/internal-routing.d.ts +0 -25
- package/dist/types/src/transport/internal-sse.d.ts +0 -14
- package/dist/types/src/transport/internal-stream.d.ts +0 -13
- package/dist/types/src/transport/internal.d.ts +0 -6
- package/dist/types/src/transport/middleware/auth.d.ts +0 -2
- package/dist/types/src/transport/middleware/cache.d.ts +0 -2
- package/dist/types/src/transport/middleware/circuit-breaker.d.ts +0 -2
- package/dist/types/src/transport/middleware/dedup.d.ts +0 -2
- package/dist/types/src/transport/middleware/index.d.ts +0 -12
- package/dist/types/src/transport/middleware/logging.d.ts +0 -2
- package/dist/types/src/transport/middleware/metrics.d.ts +0 -2
- package/dist/types/src/transport/middleware/pipe.d.ts +0 -2
- package/dist/types/src/transport/middleware/rate-limit.d.ts +0 -2
- package/dist/types/src/transport/middleware/retry.d.ts +0 -2
- package/dist/types/src/transport/middleware/timeout.d.ts +0 -2
- package/dist/types/src/transport/middleware/tracing.d.ts +0 -2
- package/dist/types/src/transport/middleware/transform.d.ts +0 -3
- package/dist/types/src/transport/policy-context.d.ts +0 -3
- package/dist/types/src/transport/protocols/graphql.d.ts +0 -2
- package/dist/types/src/transport/protocols/grpc.d.ts +0 -5
- package/dist/types/src/transport/protocols/index.d.ts +0 -5
- package/dist/types/src/transport/protocols/json.d.ts +0 -2
- package/dist/types/src/transport/protocols/sse.d.ts +0 -2
- package/dist/types/src/transport/protocols/websocket.d.ts +0 -2
- package/dist/types/src/transport/runtime.d.ts +0 -4
- package/dist/types/src/transport/state/cache-store.d.ts +0 -2
- package/dist/types/src/transport/state/circuit-breaker.d.ts +0 -2
- package/dist/types/src/transport/state/health.d.ts +0 -2
- package/dist/types/src/transport/state/index.d.ts +0 -5
- package/dist/types/src/transport/state/rate-limiter.d.ts +0 -2
- package/dist/types/src/transport/state/session.d.ts +0 -2
- package/dist/types/src/transport/types/capabilities.d.ts +0 -35
- package/dist/types/src/transport/types/core.d.ts +0 -74
- package/dist/types/src/transport/types/events.d.ts +0 -50
- package/dist/types/src/transport/types/index.d.ts +0 -7
- package/dist/types/src/transport/types/middleware.d.ts +0 -3
- package/dist/types/src/transport/types/options-http.d.ts +0 -85
- package/dist/types/src/transport/types/options-middleware.d.ts +0 -96
- package/dist/types/src/transport/types/options-routing.d.ts +0 -82
- package/dist/types/src/transport/types/options.d.ts +0 -3
- package/dist/types/src/transport/types/session.d.ts +0 -48
- package/dist/types/src/transport/types/state.d.ts +0 -46
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { toJSONSchema as e } from "zod";
|
|
2
|
+
//#region src/schema/ids.ts
|
|
3
|
+
var t = (e) => e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item", n = (e, t) => {
|
|
4
|
+
if (typeof e == "string" || typeof e == "number") return e;
|
|
5
|
+
if (e) return (t ? e[t] : void 0) ?? e.default ?? void 0;
|
|
6
|
+
}, r = (e) => String(e), i = (e, t) => {
|
|
7
|
+
let i = n(e, t);
|
|
8
|
+
if (t !== void 0 || typeof e != "object" || !e) return i === void 0 ? [] : [i];
|
|
9
|
+
let a = /* @__PURE__ */ new Set();
|
|
10
|
+
return Object.values(e).filter((e) => {
|
|
11
|
+
if (typeof e != "string" && typeof e != "number") return !1;
|
|
12
|
+
let t = r(e);
|
|
13
|
+
return a.has(t) ? !1 : (a.add(t), !0);
|
|
14
|
+
});
|
|
15
|
+
}, a = (e, t) => {
|
|
16
|
+
if (typeof e == "string" || typeof e == "number") return [{
|
|
17
|
+
backend: t ?? "default",
|
|
18
|
+
mappedTo: e
|
|
19
|
+
}];
|
|
20
|
+
if (!e) return [];
|
|
21
|
+
if (t) {
|
|
22
|
+
let r = n(e, t);
|
|
23
|
+
return r === void 0 ? [] : [{
|
|
24
|
+
backend: t,
|
|
25
|
+
mappedTo: r
|
|
26
|
+
}];
|
|
27
|
+
}
|
|
28
|
+
return Object.entries(e).flatMap(([e, t]) => typeof t == "string" || typeof t == "number" ? [{
|
|
29
|
+
backend: e,
|
|
30
|
+
mappedTo: t
|
|
31
|
+
}] : []);
|
|
32
|
+
}, o = (e, t) => {
|
|
33
|
+
let n = a(e.mappedTo, t.backend), i = t.reports.filter((e) => n.some((t) => t.backend === e.backend && r(t.mappedTo) === r(e.mappedTo)));
|
|
34
|
+
if (i.length > 1) {
|
|
35
|
+
let e = i[0];
|
|
36
|
+
throw Error(`Duplicate report result for backend "${e?.backend}" and mappedTo "${String(e?.mappedTo)}".`);
|
|
37
|
+
}
|
|
38
|
+
return i[0];
|
|
39
|
+
}, s = (e, t) => {
|
|
40
|
+
let n = o(e, t);
|
|
41
|
+
return n?.status === "ready" ? n.payload : void 0;
|
|
42
|
+
}, c = class extends Error {
|
|
43
|
+
constructor(e) {
|
|
44
|
+
super(e), this.name = "RegistryError";
|
|
45
|
+
}
|
|
46
|
+
}, l = class {
|
|
47
|
+
fieldDefinitions = /* @__PURE__ */ new Map();
|
|
48
|
+
reportDefinitions = /* @__PURE__ */ new Map();
|
|
49
|
+
registerField(e) {
|
|
50
|
+
if (this.fieldDefinitions.has(e.kind)) throw new c(`Field kind "${e.kind}" is already registered.`);
|
|
51
|
+
return this.fieldDefinitions.set(e.kind, e), this;
|
|
52
|
+
}
|
|
53
|
+
unregisterField(e) {
|
|
54
|
+
return this.fieldDefinitions.delete(e), this;
|
|
55
|
+
}
|
|
56
|
+
registerReport(e) {
|
|
57
|
+
if (this.reportDefinitions.has(e.kind)) throw new c(`Report kind "${e.kind}" is already registered.`);
|
|
58
|
+
return this.reportDefinitions.set(e.kind, e), this;
|
|
59
|
+
}
|
|
60
|
+
unregisterReport(e) {
|
|
61
|
+
return this.reportDefinitions.delete(e), this;
|
|
62
|
+
}
|
|
63
|
+
getField(e) {
|
|
64
|
+
return this.fieldDefinitions.get(e);
|
|
65
|
+
}
|
|
66
|
+
getReport(e) {
|
|
67
|
+
return this.reportDefinitions.get(e);
|
|
68
|
+
}
|
|
69
|
+
listFields() {
|
|
70
|
+
return Array.from(this.fieldDefinitions.values());
|
|
71
|
+
}
|
|
72
|
+
listReports() {
|
|
73
|
+
return Array.from(this.reportDefinitions.values());
|
|
74
|
+
}
|
|
75
|
+
}, u = () => new l(), d = (e) => e, f = (e) => e, p = class extends Error {
|
|
76
|
+
path;
|
|
77
|
+
code;
|
|
78
|
+
constructor(e, t, n = "invalid-config") {
|
|
79
|
+
super(e), this.path = t, this.code = n, this.name = "SchemaNormalizationError";
|
|
80
|
+
}
|
|
81
|
+
}, m = (e, t, n, r, i) => {
|
|
82
|
+
if (typeof n != "object" || !n) throw new p(`Series field "${e}" requires "${t}" configuration.`, [
|
|
83
|
+
"fields",
|
|
84
|
+
i,
|
|
85
|
+
t
|
|
86
|
+
]);
|
|
87
|
+
let a = "kind" in n && typeof n.kind == "string" ? n.kind : "";
|
|
88
|
+
if (a.length === 0) throw new p(`Series field "${e}" requires "${t}.kind".`, [
|
|
89
|
+
"fields",
|
|
90
|
+
i,
|
|
91
|
+
t,
|
|
92
|
+
"kind"
|
|
93
|
+
]);
|
|
94
|
+
if (a === "series") throw new p(`Series field "${e}" cannot nest series in "${t}".`, [
|
|
95
|
+
"fields",
|
|
96
|
+
i,
|
|
97
|
+
t,
|
|
98
|
+
"kind"
|
|
99
|
+
]);
|
|
100
|
+
if (!r.getField(a)) throw new p(`Series field "${e}" uses unknown sub-field kind "${a}" in "${t}".`, [
|
|
101
|
+
"fields",
|
|
102
|
+
i,
|
|
103
|
+
t,
|
|
104
|
+
"kind"
|
|
105
|
+
], "unknown-kind");
|
|
106
|
+
}, h = (e, t, n) => {
|
|
107
|
+
if (e.kind === "series" && (m(e.label, "field1", e.field1, t, n), m(e.label, "field2", e.field2, t, n), typeof e.minPoints == "number" && typeof e.maxPoints == "number" && e.minPoints > e.maxPoints)) throw new p(`Series field "${e.label}" requires minPoints to be less than or equal to maxPoints.`, [
|
|
108
|
+
"fields",
|
|
109
|
+
n,
|
|
110
|
+
"minPoints"
|
|
111
|
+
]);
|
|
112
|
+
}, g = (e, n, r, i, a) => {
|
|
113
|
+
let o = t((e ?? n) || i);
|
|
114
|
+
if (e) {
|
|
115
|
+
if (r.has(o)) throw new p(`Duplicate explicit id "${o}" in schema.`, a);
|
|
116
|
+
return r.add(o), o;
|
|
117
|
+
}
|
|
118
|
+
let s = o, c = 2;
|
|
119
|
+
for (; r.has(s);) s = `${o}-${c}`, c += 1;
|
|
120
|
+
return r.add(s), s;
|
|
121
|
+
}, _ = (e, t, n, r) => {
|
|
122
|
+
let i = n.getField(e.kind);
|
|
123
|
+
if (!i) throw new c(`Unknown field kind "${e.kind}".`);
|
|
124
|
+
let a = i.schema.parse(e);
|
|
125
|
+
return h(a, n, t), {
|
|
126
|
+
...a,
|
|
127
|
+
id: g(a.id, a.label, r, `field-${t + 1}`, [
|
|
128
|
+
"fields",
|
|
129
|
+
t,
|
|
130
|
+
"id"
|
|
131
|
+
])
|
|
132
|
+
};
|
|
133
|
+
}, v = (e, t, n, r) => {
|
|
134
|
+
let i = n.getReport(e.kind);
|
|
135
|
+
if (!i) throw new c(`Unknown report kind "${e.kind}".`);
|
|
136
|
+
let a = i.schema.parse(e), o = g(e.id ?? a.id, e.label ?? a.label ?? a.kind, r, `report-${t + 1}`, [
|
|
137
|
+
"reports",
|
|
138
|
+
t,
|
|
139
|
+
"id"
|
|
140
|
+
]);
|
|
141
|
+
return {
|
|
142
|
+
...a,
|
|
143
|
+
...e.label === void 0 ? {} : { label: e.label },
|
|
144
|
+
...e.description === void 0 ? {} : { description: e.description },
|
|
145
|
+
...e.mappedTo === void 0 ? {} : { mappedTo: e.mappedTo },
|
|
146
|
+
...e.ui === void 0 ? {} : { ui: e.ui },
|
|
147
|
+
id: o
|
|
148
|
+
};
|
|
149
|
+
}, y = (e, t) => {
|
|
150
|
+
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = (e.reports ?? []).map((e, n) => v(e, n, t, r));
|
|
151
|
+
return {
|
|
152
|
+
fields: e.fields.map((e, r) => _(e, r, t, n)),
|
|
153
|
+
reports: i
|
|
154
|
+
};
|
|
155
|
+
}, b = (e) => e === 1 || e === "1" || e === !0, x = (e, t, i = {}) => {
|
|
156
|
+
if (e.kind !== "onehot-category" || !Array.isArray(e.options)) return;
|
|
157
|
+
let a = /* @__PURE__ */ new Set(), o;
|
|
158
|
+
for (let s of e.options) {
|
|
159
|
+
let c = n(s.mappedTo, i.backend);
|
|
160
|
+
if (c === void 0) throw Error(`onehot-category "${e.id ?? e.kind}": option "${s.value}" has no mappedTo.`);
|
|
161
|
+
let l = r(c);
|
|
162
|
+
if (a.has(l)) throw Error(`onehot-category "${e.id ?? e.kind}": duplicate mappedTo "${l}".`);
|
|
163
|
+
if (a.add(l), b(t[l])) {
|
|
164
|
+
if (o !== void 0) throw Error(`onehot-category "${e.id ?? e.kind}": multiple selected mapped values.`);
|
|
165
|
+
o = s.value;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return o;
|
|
169
|
+
}, S = (e) => {
|
|
170
|
+
if (typeof e == "string") return e;
|
|
171
|
+
if (typeof e != "number") return e.id ?? e.config?.id;
|
|
172
|
+
}, C = (e, t) => {
|
|
173
|
+
if (typeof e == "string" || typeof e == "number") return String(e);
|
|
174
|
+
let i = n(e.mappedTo ?? e.config?.mappedTo, t);
|
|
175
|
+
return i === void 0 ? void 0 : r(i);
|
|
176
|
+
}, w = (e, t) => Object.fromEntries(e.map((e) => {
|
|
177
|
+
let i = o(e, t), a = i?.context, s = i?.mappedTo ?? n(e.mappedTo, t.backend);
|
|
178
|
+
return [e.id, {
|
|
179
|
+
reportId: e.id,
|
|
180
|
+
kind: e.kind,
|
|
181
|
+
label: e.label,
|
|
182
|
+
mappedTo: e.mappedTo,
|
|
183
|
+
target: s,
|
|
184
|
+
targetKey: s === void 0 ? void 0 : r(s),
|
|
185
|
+
backend: i?.backend ?? t.backend,
|
|
186
|
+
displayValues: a?.displayValues ?? t.displayValues,
|
|
187
|
+
modelValues: a?.modelValues ?? t.modelValues,
|
|
188
|
+
reports: t.reports,
|
|
189
|
+
meta: a?.meta ?? t.meta,
|
|
190
|
+
raw: a && "raw" in a ? a.raw : t.raw
|
|
191
|
+
}];
|
|
192
|
+
})), T = (e, t) => {
|
|
193
|
+
let n = e.reportContexts, r = S(t);
|
|
194
|
+
if (r && n[r]) return n[r];
|
|
195
|
+
let i = C(t, e.backend);
|
|
196
|
+
if (i === void 0) return;
|
|
197
|
+
let a = Object.values(n).filter((t) => t.targetKey === i && (e.backend === void 0 || t.backend === e.backend));
|
|
198
|
+
return a.length === 1 ? a[0] : void 0;
|
|
199
|
+
}, E = (e) => typeof e == "object" && !!e && !Array.isArray(e), D = (e, t) => {
|
|
200
|
+
if (!E(e)) return [];
|
|
201
|
+
let n = [], r = (r) => {
|
|
202
|
+
let i = e[r];
|
|
203
|
+
Array.isArray(i) && i.forEach((e, i) => {
|
|
204
|
+
if (!(!E(e) || typeof e.kind != "string") && ((r === "fields" ? t.getField(e.kind) : t.getReport(e.kind)) || n.push({
|
|
205
|
+
section: r,
|
|
206
|
+
index: i,
|
|
207
|
+
kind: e.kind,
|
|
208
|
+
path: [
|
|
209
|
+
r,
|
|
210
|
+
i,
|
|
211
|
+
"kind"
|
|
212
|
+
]
|
|
213
|
+
}), r === "fields" && e.kind === "series")) for (let a of ["field1", "field2"]) {
|
|
214
|
+
let o = e[a];
|
|
215
|
+
!E(o) || typeof o.kind != "string" || t.getField(o.kind) || n.push({
|
|
216
|
+
section: r,
|
|
217
|
+
index: i,
|
|
218
|
+
kind: o.kind,
|
|
219
|
+
path: [
|
|
220
|
+
r,
|
|
221
|
+
i,
|
|
222
|
+
a,
|
|
223
|
+
"kind"
|
|
224
|
+
]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
return r("fields"), r("reports"), n;
|
|
230
|
+
}, O = (e, t, n, r) => {
|
|
231
|
+
if (!Array.isArray(t)) {
|
|
232
|
+
r.push({
|
|
233
|
+
path: [e],
|
|
234
|
+
message: `${e} must be an array.`,
|
|
235
|
+
code: "invalid-schema"
|
|
236
|
+
});
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
t.forEach((t, i) => {
|
|
240
|
+
if (!E(t)) {
|
|
241
|
+
r.push({
|
|
242
|
+
path: [e, i],
|
|
243
|
+
message: `${e === "fields" ? "Field" : "Report"} must be an object.`,
|
|
244
|
+
code: "invalid-config"
|
|
245
|
+
});
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (typeof t.kind != "string" || t.kind.length === 0) {
|
|
249
|
+
r.push({
|
|
250
|
+
path: [
|
|
251
|
+
e,
|
|
252
|
+
i,
|
|
253
|
+
"kind"
|
|
254
|
+
],
|
|
255
|
+
message: "kind must be a non-empty string.",
|
|
256
|
+
code: "invalid-config"
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
let a = e === "fields" ? n.getField(t.kind) : n.getReport(t.kind);
|
|
261
|
+
if (!a) return;
|
|
262
|
+
let o = a.schema.safeParse(t);
|
|
263
|
+
if (!o.success) for (let t of o.error.issues) r.push({
|
|
264
|
+
path: [
|
|
265
|
+
e,
|
|
266
|
+
i,
|
|
267
|
+
...t.path.map((e) => typeof e == "symbol" ? String(e) : e)
|
|
268
|
+
],
|
|
269
|
+
message: t.message,
|
|
270
|
+
code: "invalid-config"
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}, k = (e, t) => {
|
|
274
|
+
if (!E(e)) return {
|
|
275
|
+
success: !1,
|
|
276
|
+
issues: [{
|
|
277
|
+
path: [],
|
|
278
|
+
message: "Schema must be an object.",
|
|
279
|
+
code: "invalid-schema"
|
|
280
|
+
}]
|
|
281
|
+
};
|
|
282
|
+
let n = [], r = new Set(["fields", "reports"]);
|
|
283
|
+
for (let t of Object.keys(e)) r.has(t) || n.push({
|
|
284
|
+
path: [t],
|
|
285
|
+
message: `Unsupported schema property "${t}".`,
|
|
286
|
+
code: "invalid-schema"
|
|
287
|
+
});
|
|
288
|
+
O("fields", e.fields, t, n), O("reports", e.reports ?? [], t, n);
|
|
289
|
+
for (let r of D(e, t)) n.push({
|
|
290
|
+
path: r.path,
|
|
291
|
+
message: `Unknown ${r.section === "fields" ? "field" : "report"} kind "${r.kind}".`,
|
|
292
|
+
code: "unknown-kind"
|
|
293
|
+
});
|
|
294
|
+
if (n.length > 0) return {
|
|
295
|
+
success: !1,
|
|
296
|
+
issues: n
|
|
297
|
+
};
|
|
298
|
+
try {
|
|
299
|
+
return {
|
|
300
|
+
success: !0,
|
|
301
|
+
data: y(e, t),
|
|
302
|
+
issues: []
|
|
303
|
+
};
|
|
304
|
+
} catch (e) {
|
|
305
|
+
let t = e instanceof p ? e : void 0;
|
|
306
|
+
return {
|
|
307
|
+
success: !1,
|
|
308
|
+
issues: [{
|
|
309
|
+
path: t?.path ?? [],
|
|
310
|
+
message: e instanceof Error ? e.message : "Schema normalization failed.",
|
|
311
|
+
code: t?.code ?? "invalid-schema"
|
|
312
|
+
}]
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}, A = (t) => t.map((t) => e(t.schema, {
|
|
316
|
+
io: "input",
|
|
317
|
+
unrepresentable: "any"
|
|
318
|
+
})), j = (e) => {
|
|
319
|
+
let t = A(e);
|
|
320
|
+
return t.length > 0 ? { oneOf: t } : !1;
|
|
321
|
+
}, M = (e) => ({
|
|
322
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
323
|
+
type: "object",
|
|
324
|
+
additionalProperties: !1,
|
|
325
|
+
required: ["fields"],
|
|
326
|
+
properties: {
|
|
327
|
+
fields: {
|
|
328
|
+
type: "array",
|
|
329
|
+
items: j(e.listFields())
|
|
330
|
+
},
|
|
331
|
+
reports: {
|
|
332
|
+
type: "array",
|
|
333
|
+
items: j(e.listReports())
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}), N = (e, t = {}) => ({
|
|
337
|
+
reportId: t.reportId ?? "",
|
|
338
|
+
backend: e.backend,
|
|
339
|
+
inputs: e.inputs,
|
|
340
|
+
displayValues: e.displayValues,
|
|
341
|
+
modelValues: e.modelValues,
|
|
342
|
+
reports: e.reports,
|
|
343
|
+
reportContext: t.reportId === void 0 ? void 0 : T(e, t.reportId),
|
|
344
|
+
reportContexts: e.reportContexts,
|
|
345
|
+
meta: e.meta,
|
|
346
|
+
raw: e.raw,
|
|
347
|
+
signal: t.signal
|
|
348
|
+
});
|
|
349
|
+
//#endregion
|
|
350
|
+
export { a as _, w as a, t as b, p as c, u as d, d as f, o as g, s as h, k as i, y as l, r as m, D as n, T as o, f as p, M as r, x as s, N as t, c as u, i as v, n as y };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/transport/errors.ts
|
|
2
|
+
var e = { ABORTED: "ABORTED" }, t = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
super(e), this.name = "TransportError", this.code = t;
|
|
6
|
+
}
|
|
7
|
+
}, n = (e) => e instanceof Error ? e.message : typeof e == "string" && e.trim().length > 0 ? e : String(e), r = (e) => e instanceof Error && e.name === "AbortError", i = (e) => {
|
|
8
|
+
let t = e.filter((e) => e !== void 0);
|
|
9
|
+
return t.length === 0 ? void 0 : AbortSignal.any(t);
|
|
10
|
+
}, a = () => {
|
|
11
|
+
let e = null;
|
|
12
|
+
return {
|
|
13
|
+
async run(t, a = []) {
|
|
14
|
+
e?.abort("request-restarted");
|
|
15
|
+
let o = new AbortController();
|
|
16
|
+
e = o;
|
|
17
|
+
let s = i([...a, o.signal]);
|
|
18
|
+
try {
|
|
19
|
+
let e = await t(s);
|
|
20
|
+
return o.signal.aborted || s?.aborted ? { status: "aborted" } : {
|
|
21
|
+
status: "completed",
|
|
22
|
+
value: e
|
|
23
|
+
};
|
|
24
|
+
} catch (e) {
|
|
25
|
+
return o.signal.aborted || s?.aborted || r(e) ? { status: "aborted" } : {
|
|
26
|
+
status: "failed",
|
|
27
|
+
error: e,
|
|
28
|
+
message: n(e)
|
|
29
|
+
};
|
|
30
|
+
} finally {
|
|
31
|
+
e === o && (e = null);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
abort(t) {
|
|
35
|
+
e?.abort(t), e = null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}, o = (e) => ({ async submit(t) {
|
|
39
|
+
if (e.failurePolicy === "fail-fast") {
|
|
40
|
+
let n = await Promise.all(e.targets.map((n) => e.submit(n, t)));
|
|
41
|
+
return e.merge(n.map((t, n) => ({
|
|
42
|
+
target: e.targets[n],
|
|
43
|
+
status: "fulfilled",
|
|
44
|
+
value: t
|
|
45
|
+
})), t);
|
|
46
|
+
}
|
|
47
|
+
let n = await Promise.all(e.targets.map(async (n) => {
|
|
48
|
+
try {
|
|
49
|
+
return {
|
|
50
|
+
target: n,
|
|
51
|
+
status: "fulfilled",
|
|
52
|
+
value: await e.submit(n, t)
|
|
53
|
+
};
|
|
54
|
+
} catch (e) {
|
|
55
|
+
return {
|
|
56
|
+
target: n,
|
|
57
|
+
status: "rejected",
|
|
58
|
+
reason: e
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
return e.merge(n, t);
|
|
63
|
+
} });
|
|
64
|
+
//#endregion
|
|
65
|
+
export { e as a, t as i, a as n, n as r, o as t };
|
|
@@ -24,10 +24,9 @@ export interface DeclarativeReportKind<TConfig extends ReportConfig = ReportConf
|
|
|
24
24
|
schema: ZodType<TConfig>;
|
|
25
25
|
payloadSchema?: ZodType<unknown>;
|
|
26
26
|
payloadValidationPolicy?: "report-error" | "fail-submit";
|
|
27
|
-
partialUpdatePolicy?: "trust" | "validate" | "defer";
|
|
28
27
|
clonePayload?: (payload: TPayload, config: TConfig) => TPayload;
|
|
29
28
|
fetch?: ReportFetchFactory<TConfig>;
|
|
30
|
-
resolve
|
|
29
|
+
resolve?: (context: ReportResolveContext<TConfig>) => unknown;
|
|
31
30
|
render: ReportRenderSpec<TConfig, TPayload>;
|
|
32
31
|
}
|
|
33
32
|
export type DefinedReportKind<TConfig extends ReportConfig, _TPayload> = {
|
|
@@ -35,7 +34,6 @@ export type DefinedReportKind<TConfig extends ReportConfig, _TPayload> = {
|
|
|
35
34
|
schema: import('zod').ZodType<TConfig>;
|
|
36
35
|
payloadSchema?: ReportDefinition<TConfig>["payloadSchema"];
|
|
37
36
|
payloadValidationPolicy?: ReportDefinition<TConfig>["payloadValidationPolicy"];
|
|
38
|
-
partialUpdatePolicy?: ReportDefinition<TConfig>["partialUpdatePolicy"];
|
|
39
37
|
clonePayload?: ReportDefinition<TConfig>["clonePayload"];
|
|
40
38
|
fetch?: ReportDefinition<TConfig>["fetch"];
|
|
41
39
|
resolvePayload?: ReportDefinition<TConfig>["resolvePayload"];
|
|
@@ -4,10 +4,6 @@ export type FormRenderState = {
|
|
|
4
4
|
submitCount: number;
|
|
5
5
|
hasFormErrors: boolean;
|
|
6
6
|
hasLastResult: boolean;
|
|
7
|
-
submissionLoaded?: number;
|
|
8
|
-
submissionTotal?: number;
|
|
9
|
-
submissionMessage?: string;
|
|
10
|
-
submissionSessionMessageCount?: number;
|
|
11
7
|
visibleFieldIds: string[];
|
|
12
8
|
visibleReportIds: string[];
|
|
13
9
|
reportStateKeys: string[];
|
|
@@ -8,10 +8,6 @@ export declare class PrimitiveSubmitButtonElement extends LitElement {
|
|
|
8
8
|
accessor idleLabel: string;
|
|
9
9
|
accessor validatingLabel: string;
|
|
10
10
|
accessor submittingLabel: string;
|
|
11
|
-
accessor loaded: number | undefined;
|
|
12
|
-
accessor total: number | undefined;
|
|
13
|
-
accessor progressMessage: string | undefined;
|
|
14
|
-
accessor sessionMessageCount: number | undefined;
|
|
15
11
|
render(): import('lit').TemplateResult<1>;
|
|
16
12
|
}
|
|
17
13
|
declare global {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type PrimitiveFormStatus = "idle" | "editing" | "validating" | "submitting" | "success" | "error";
|
|
2
|
-
export type PrimitiveReportStatus = "idle" | "loading" | "ready" | "error";
|
|
2
|
+
export type PrimitiveReportStatus = "idle" | "loading" | "ready" | "skipped" | "error";
|
|
3
3
|
export interface PrimitiveFieldStateSnapshot {
|
|
4
4
|
value: unknown;
|
|
5
5
|
errors: readonly string[];
|
|
@@ -18,15 +18,11 @@ export interface PrimitiveReportStateSnapshot {
|
|
|
18
18
|
}
|
|
19
19
|
export interface PrimitiveSubmitResult {
|
|
20
20
|
backend?: string;
|
|
21
|
-
inputs
|
|
22
|
-
displayValues
|
|
23
|
-
modelValues
|
|
24
|
-
values: Record<string, unknown>;
|
|
25
|
-
fieldValues: Record<string, unknown>;
|
|
26
|
-
serializedValues: Record<string, unknown>;
|
|
27
|
-
serializedFieldValues: Record<string, unknown>;
|
|
21
|
+
inputs: PrimitiveSubmissionInputRecord[];
|
|
22
|
+
displayValues: Record<string, unknown>;
|
|
23
|
+
modelValues: Record<string, unknown>;
|
|
28
24
|
reports: readonly unknown[];
|
|
29
|
-
reportContexts
|
|
25
|
+
reportContexts: Record<string, PrimitiveReportContext>;
|
|
30
26
|
reportStates: Record<string, unknown>;
|
|
31
27
|
meta: Record<string, unknown>;
|
|
32
28
|
raw: unknown;
|
|
@@ -69,12 +65,6 @@ export interface PrimitiveFormState {
|
|
|
69
65
|
form: readonly string[];
|
|
70
66
|
};
|
|
71
67
|
lastResult: PrimitiveSubmitResult | null;
|
|
72
|
-
submissionProgress?: {
|
|
73
|
-
loaded?: number;
|
|
74
|
-
total?: number;
|
|
75
|
-
message?: string;
|
|
76
|
-
sessionMessageCount?: number;
|
|
77
|
-
} | null;
|
|
78
68
|
}
|
|
79
69
|
export interface PrimitiveFieldController {
|
|
80
70
|
id: string;
|
|
@@ -120,16 +110,12 @@ export interface PrimitiveSubmitExecutionResult {
|
|
|
120
110
|
export interface PrimitiveReportRequest {
|
|
121
111
|
reportId: string;
|
|
122
112
|
backend?: string;
|
|
123
|
-
inputs
|
|
124
|
-
displayValues
|
|
125
|
-
modelValues
|
|
126
|
-
values: Record<string, unknown>;
|
|
127
|
-
fieldValues: Record<string, unknown>;
|
|
128
|
-
serializedValues: Record<string, unknown>;
|
|
129
|
-
serializedFieldValues: Record<string, unknown>;
|
|
113
|
+
inputs: PrimitiveSubmissionInputRecord[];
|
|
114
|
+
displayValues: Record<string, unknown>;
|
|
115
|
+
modelValues: Record<string, unknown>;
|
|
130
116
|
reports: readonly unknown[];
|
|
131
117
|
reportContext?: PrimitiveReportContext;
|
|
132
|
-
reportContexts
|
|
118
|
+
reportContexts: Record<string, PrimitiveReportContext>;
|
|
133
119
|
meta: Record<string, unknown>;
|
|
134
120
|
raw: unknown;
|
|
135
121
|
signal?: AbortSignal;
|
|
@@ -24,4 +24,3 @@ export declare class SubmissionAbortedError extends SubmitError {
|
|
|
24
24
|
export declare const createAbortError: (reason?: string) => SubmissionAbortedError;
|
|
25
25
|
export declare const isAbortLikeError: (error: unknown) => boolean;
|
|
26
26
|
export { TransportError, transportErrorCodes } from '../../transport';
|
|
27
|
-
export type { TransportErrorCode } from '../../transport';
|
|
@@ -2,11 +2,10 @@ export { createSubmissionSnapshot, executeFormPipeline, executeReportFetches } f
|
|
|
2
2
|
export { createMultiBackendSubmissionSnapshot, executeMultiBackendPipeline } from './submission';
|
|
3
3
|
export type { CreateMultiBackendSubmissionSnapshotOptions, CreateSubmissionSnapshotOptions, ExecuteMultiBackendPipelineOptions, MultiBackendPipelineResult, MultiBackendRunResult, MultiBackendSubmit, SubmissionSnapshot, } from './submission';
|
|
4
4
|
export { EngineError, ReportPayloadError, RegistryError, SubmissionAbortedError, SubmitError, TransportError, transportErrorCodes, ValidationError, } from './errors';
|
|
5
|
-
export type { TransportErrorCode } from './errors';
|
|
6
5
|
export { createForm, createForm as createFormRuntime } from './form';
|
|
7
6
|
export { defaultEquality, shallowArrayEquality, shallowEquality, shallowObjectEquality, } from './equality';
|
|
8
7
|
export { identity, isPromiseLike } from './utils';
|
|
9
|
-
export type { AllConditions, AfterSubmitContext, AfterValidateContext, AnyConditions, BaseFieldConfig, BaseReportConfig, BeforeSubmitContext, BeforeValidateContext, CreateFormConfig, DeclarativeFieldCondition, AfterReportFetchContext, FieldValidationFnContext, FieldValueAdapter, FieldConfig, FieldComparisonCondition, FieldCondition, FieldConditionContext, FieldController, FieldDefinition, FieldStateSnapshot, FieldStatus, FieldValueCondition, FieldValidationContext, FieldValidationResult, FormController, FormHooks, FormSchema, FormState, FormStatusCondition, FormStatus, FormValidator, FormValidationContext, FormValidationIssue, FormValidationResult, InactiveFieldPolicy, MaybePromise, NormalizedFieldConfig, NormalizedReportConfig, Registry, ReportConfig, ReportController, ReportDefinition, ReportFetchContext, ReportFetchErrorContext, ReportFetchExecutionContext, ReportFetchExecutionResult, ReportFetchFactory, ReportFetchRequest, ReportFetchStatus, ReportFetchTransport, ReportResolveContext, ReportStateSnapshot, ReportStatus, PipelineArtifactAdapter, PipelineArtifactContext, PipelineResult, ExecuteFormPipelineOptions, SelectorSubscriptionOptions, SubmitCountCondition, SubmitErrorContext, SubmitOptions, SubmitRequest,
|
|
8
|
+
export type { AllConditions, AfterSubmitContext, AfterValidateContext, AnyConditions, BaseFieldConfig, BaseReportConfig, BeforeSubmitContext, BeforeValidateContext, CreateFormConfig, DeclarativeFieldCondition, AfterReportFetchContext, FieldValidationFnContext, FieldValueAdapter, FieldConfig, FieldComparisonCondition, FieldCondition, FieldConditionContext, FieldController, FieldDefinition, FieldStateSnapshot, FieldStatus, FieldValueCondition, FieldValidationContext, FieldValidationResult, FormController, FormHooks, FormSchema, FormState, FormStatusCondition, FormStatus, FormValidator, FormValidationContext, FormValidationIssue, FormValidationResult, InactiveFieldPolicy, MaybePromise, NormalizedFieldConfig, NormalizedReportConfig, Registry, ReportConfig, ReportController, ReportDefinition, ReportFetchContext, ReportFetchErrorContext, ReportFetchExecutionContext, ReportFetchExecutionResult, ReportFetchFactory, ReportFetchRequest, ReportFetchStatus, ReportFetchTransport, ReportContext, ReportResult, ReportResultContext, ReportResolveContext, ReportStateSnapshot, ReportStatus, PipelineArtifactAdapter, PipelineArtifactContext, PipelineResult, ExecuteFormPipelineOptions, SelectorSubscriptionOptions, SubmitCountCondition, SubmitErrorContext, SubmitOptions, SubmitRequest, SubmitResult, SubmissionInputRecord, Transport, TransportResponse, NotCondition, RuntimeBehavior, RuntimeBehaviorContext, RuntimeBehaviorSubmissionRecords, RuntimeBehaviorValueChangeEvent, } from './types';
|
|
10
9
|
export type FieldHandle = import('./types').FieldController;
|
|
11
10
|
export type ReportHandle = import('./types').ReportController;
|
|
12
11
|
export type FormRuntime = import('./types').FormController;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EngineStore } from '../state';
|
|
2
|
-
import { FormHooks, NormalizedReportConfig,
|
|
2
|
+
import { FormHooks, NormalizedReportConfig, ReportController, ReportDefinition, ReportStateSnapshot, SubmitResult } from '../types';
|
|
3
3
|
type CreateReportControllerOptions = {
|
|
4
4
|
config: NormalizedReportConfig;
|
|
5
5
|
definition: ReportDefinition;
|
|
@@ -14,7 +14,6 @@ export type InternalReportController = ReportController & {
|
|
|
14
14
|
update(result: SubmitResult): Promise<void>;
|
|
15
15
|
markLoading(): void;
|
|
16
16
|
reset(): void;
|
|
17
|
-
readonly partialUpdatePolicy: PartialReportUpdatePolicy;
|
|
18
17
|
};
|
|
19
18
|
export declare const createReportController: ({ config, definition, store, hooks, }: CreateReportControllerOptions) => InternalReportController;
|
|
20
19
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldStateSnapshot, FormStatus, ReportStateSnapshot,
|
|
1
|
+
import { FieldStateSnapshot, FormStatus, ReportStateSnapshot, SubmitResult } from '../types';
|
|
2
2
|
import { Store } from './store';
|
|
3
3
|
export interface InternalFieldState extends FieldStateSnapshot {
|
|
4
4
|
syncErrors: string[];
|
|
@@ -13,7 +13,6 @@ export interface EngineState {
|
|
|
13
13
|
formErrors: string[];
|
|
14
14
|
fieldStates: Record<string, InternalFieldState>;
|
|
15
15
|
reportStates: Record<string, ReportStateSnapshot>;
|
|
16
|
-
submissionProgress: SubmissionProgressState | null;
|
|
17
16
|
lifecycleVersion: number;
|
|
18
17
|
activeValidationVersion: number;
|
|
19
18
|
activeSubmissionVersion: number | null;
|
|
@@ -37,9 +36,6 @@ export type EngineTransition = {
|
|
|
37
36
|
} | {
|
|
38
37
|
type: "start-submission";
|
|
39
38
|
submissionVersion: number;
|
|
40
|
-
} | {
|
|
41
|
-
type: "submission-stream-update";
|
|
42
|
-
progress: SubmissionProgressState;
|
|
43
39
|
} | {
|
|
44
40
|
type: "submission-success";
|
|
45
41
|
result: SubmitResult;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CreateFormSubmitterOptions, FormSubmitter } from './types';
|
|
2
|
-
export declare const createFormSubmitter: ({ store, transport, hooks, hookFailurePolicy, normalizedSchema, fields, reports, validate, getSubmitCount, markReportsLoading, resetReports, syncDerivedFieldState, shouldResetInactiveFields, resolveInactiveFieldPolicy, inactiveFieldPolicy,
|
|
2
|
+
export declare const createFormSubmitter: ({ store, transport, hooks, hookFailurePolicy, normalizedSchema, fields, reports, validate, getSubmitCount, markReportsLoading, resetReports, syncDerivedFieldState, shouldResetInactiveFields, resolveInactiveFieldPolicy, inactiveFieldPolicy, beforeSubmitRecords, }: CreateFormSubmitterOptions) => FormSubmitter;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { NormalizedReportConfig,
|
|
1
|
+
import { NormalizedReportConfig, ReportStateSnapshot, SubmitResult } from '../types';
|
|
2
2
|
export type SubmissionReport = {
|
|
3
3
|
readonly id: string;
|
|
4
4
|
readonly config: NormalizedReportConfig;
|
|
5
|
-
readonly partialUpdatePolicy: PartialReportUpdatePolicy;
|
|
6
5
|
cloneState(state: ReportStateSnapshot): ReportStateSnapshot;
|
|
7
6
|
prepareState(result: SubmitResult): Promise<ReportStateSnapshot>;
|
|
8
7
|
commitState(state: ReportStateSnapshot): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SubmissionInputRecord } from '../../../schema';
|
|
2
|
+
import { NormalizedFieldConfig } from '../types';
|
|
2
3
|
type SubmissionField = {
|
|
3
4
|
readonly id: string;
|
|
4
5
|
readonly config: NormalizedFieldConfig;
|
|
@@ -9,29 +10,12 @@ type SubmissionField = {
|
|
|
9
10
|
};
|
|
10
11
|
serialize(): unknown;
|
|
11
12
|
};
|
|
12
|
-
export type SubmissionInputRecord = {
|
|
13
|
-
fieldId: string;
|
|
14
|
-
displayKey?: string;
|
|
15
|
-
label: string;
|
|
16
|
-
value: unknown;
|
|
17
|
-
serializedValue: unknown;
|
|
18
|
-
mappedTo?: string | number;
|
|
19
|
-
modelValues: Record<string, unknown>;
|
|
20
|
-
visible: boolean;
|
|
21
|
-
disabled: boolean;
|
|
22
|
-
};
|
|
23
13
|
export type SubmissionValueRecords = {
|
|
24
14
|
inputs: SubmissionInputRecord[];
|
|
25
15
|
displayValues: Record<string, unknown>;
|
|
26
16
|
modelValues: Record<string, unknown>;
|
|
27
|
-
values: Record<string, unknown>;
|
|
28
|
-
fieldValues: Record<string, unknown>;
|
|
29
|
-
serializedValues: Record<string, unknown>;
|
|
30
|
-
serializedFieldValues: Record<string, unknown>;
|
|
31
17
|
};
|
|
32
|
-
export declare const estimatePayloadBytes: (value: unknown) => number | undefined;
|
|
33
18
|
export declare const cloneSubmissionValueRecords: (records: SubmissionValueRecords) => SubmissionValueRecords;
|
|
34
19
|
export declare const shouldIncludeFieldInSubmission: (field: SubmissionField, resolveInactiveFieldPolicy: (field: SubmissionField) => "include" | "omit" | "reset-on-hide") => boolean;
|
|
35
20
|
export declare const buildSubmissionValueRecords: (fields: readonly SubmissionField[], backend: string | undefined, resolveInactiveFieldPolicy: (field: SubmissionField) => "include" | "omit" | "reset-on-hide") => SubmissionValueRecords;
|
|
36
|
-
export declare const normalizeTransportResponse: (response: unknown) => TransportResponse;
|
|
37
21
|
export {};
|