mlform 0.1.20 → 0.1.23
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-CUN_bP93.js → builtins-rkxD-h7K.js} +7 -7
- package/dist/mlform/builtins.mjs +1 -1
- package/dist/mlform/kit.mjs +8 -8
- package/dist/mlform/primitives.mjs +1 -1
- package/dist/mlform/runtime.mjs +1 -1
- package/dist/mlform/schema.mjs +2 -2
- package/dist/{primitives-CgFaSmAm.js → primitives-ljp3c5R8.js} +4 -8
- package/dist/{runtime-zS0p2589.js → runtime-BQsOz8iz.js} +294 -304
- package/dist/schema-BI-Ia-h9.js +339 -0
- package/dist/types/src/primitives/controller-types.d.ts +8 -16
- package/dist/types/src/runtime/submission/request.d.ts +0 -4
- package/dist/types/src/runtime/types/behavior.d.ts +0 -4
- package/dist/types/src/runtime/types/transport.d.ts +0 -12
- package/dist/types/src/schema/mapped-to.d.ts +5 -0
- 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 +4 -8
- package/dist/types/src/schema/types/submit.d.ts +4 -8
- package/dist/types/src/schema/validation.d.ts +1 -0
- package/dist/types/src/transport/types.d.ts +3 -7
- package/package.json +1 -1
- package/dist/schema-CYsf2AFP.js +0 -303
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { array as e, never as t, strictObject as n, toJSONSchema as r, xor as i } from "zod";
|
|
2
|
+
//#region src/schema/ids.ts
|
|
3
|
+
var a = (e) => e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item", o = (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
|
+
}, s = (e) => String(e), c = (e, t) => {
|
|
7
|
+
let n = o(e, t);
|
|
8
|
+
if (t !== void 0 || typeof e != "object" || !e) return n === void 0 ? [] : [n];
|
|
9
|
+
let r = /* @__PURE__ */ new Set();
|
|
10
|
+
return Object.values(e).filter((e) => {
|
|
11
|
+
if (typeof e != "string" && typeof e != "number") return !1;
|
|
12
|
+
let t = s(e);
|
|
13
|
+
return r.has(t) ? !1 : (r.add(t), !0);
|
|
14
|
+
});
|
|
15
|
+
}, l = (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 n = o(e, t);
|
|
23
|
+
return n === void 0 ? [] : [{
|
|
24
|
+
backend: t,
|
|
25
|
+
mappedTo: n
|
|
26
|
+
}];
|
|
27
|
+
}
|
|
28
|
+
return Object.entries(e).flatMap(([e, t]) => typeof t == "string" || typeof t == "number" ? [{
|
|
29
|
+
backend: e,
|
|
30
|
+
mappedTo: t
|
|
31
|
+
}] : []);
|
|
32
|
+
}, u = (e, t) => {
|
|
33
|
+
let n = l(e.mappedTo, t.backend), r = t.reports.filter((e) => n.some((t) => t.backend === e.backend && s(t.mappedTo) === s(e.mappedTo)));
|
|
34
|
+
if (r.length > 1) {
|
|
35
|
+
let e = r[0];
|
|
36
|
+
throw Error(`Duplicate report result for backend "${e?.backend}" and mappedTo "${String(e?.mappedTo)}".`);
|
|
37
|
+
}
|
|
38
|
+
return r[0];
|
|
39
|
+
}, d = (e, t) => {
|
|
40
|
+
let n = u(e, t);
|
|
41
|
+
return n?.status === "ready" ? n.payload : void 0;
|
|
42
|
+
}, f = class extends Error {
|
|
43
|
+
constructor(e) {
|
|
44
|
+
super(e), this.name = "RegistryError";
|
|
45
|
+
}
|
|
46
|
+
}, p = class {
|
|
47
|
+
fieldDefinitions = /* @__PURE__ */ new Map();
|
|
48
|
+
reportDefinitions = /* @__PURE__ */ new Map();
|
|
49
|
+
registerField(e) {
|
|
50
|
+
if (this.fieldDefinitions.has(e.kind)) throw new f(`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 f(`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
|
+
}, m = () => new p(), h = (e) => e, g = (e) => e, _ = 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
|
+
}, v = (e, t, n, r, i) => {
|
|
82
|
+
if (typeof n != "object" || !n) throw new _(`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 _(`Series field "${e}" requires "${t}.kind".`, [
|
|
89
|
+
"fields",
|
|
90
|
+
i,
|
|
91
|
+
t,
|
|
92
|
+
"kind"
|
|
93
|
+
]);
|
|
94
|
+
if (a === "series") throw new _(`Series field "${e}" cannot nest series in "${t}".`, [
|
|
95
|
+
"fields",
|
|
96
|
+
i,
|
|
97
|
+
t,
|
|
98
|
+
"kind"
|
|
99
|
+
]);
|
|
100
|
+
if (!r.getField(a)) throw new _(`Series field "${e}" uses unknown sub-field kind "${a}" in "${t}".`, [
|
|
101
|
+
"fields",
|
|
102
|
+
i,
|
|
103
|
+
t,
|
|
104
|
+
"kind"
|
|
105
|
+
], "unknown-kind");
|
|
106
|
+
}, y = (e, t, n) => {
|
|
107
|
+
if (e.kind === "series" && (v(e.label, "field1", e.field1, t, n), v(e.label, "field2", e.field2, t, n), typeof e.minPoints == "number" && typeof e.maxPoints == "number" && e.minPoints > e.maxPoints)) throw new _(`Series field "${e.label}" requires minPoints to be less than or equal to maxPoints.`, [
|
|
108
|
+
"fields",
|
|
109
|
+
n,
|
|
110
|
+
"minPoints"
|
|
111
|
+
]);
|
|
112
|
+
}, b = (e, t, n, r, i) => {
|
|
113
|
+
let o = a((e ?? t) || r);
|
|
114
|
+
if (e) {
|
|
115
|
+
if (n.has(o)) throw new _(`Duplicate explicit id "${o}" in schema.`, i);
|
|
116
|
+
return n.add(o), o;
|
|
117
|
+
}
|
|
118
|
+
let s = o, c = 2;
|
|
119
|
+
for (; n.has(s);) s = `${o}-${c}`, c += 1;
|
|
120
|
+
return n.add(s), s;
|
|
121
|
+
}, x = (e, t, n, r) => {
|
|
122
|
+
let i = n.getField(e.kind);
|
|
123
|
+
if (!i) throw new f(`Unknown field kind "${e.kind}".`);
|
|
124
|
+
let a = i.schema.parse(e);
|
|
125
|
+
return y(a, n, t), {
|
|
126
|
+
...a,
|
|
127
|
+
id: b(a.id, a.label, r, `field-${t + 1}`, [
|
|
128
|
+
"fields",
|
|
129
|
+
t,
|
|
130
|
+
"id"
|
|
131
|
+
])
|
|
132
|
+
};
|
|
133
|
+
}, S = (e, t, n, r) => {
|
|
134
|
+
let i = n.getReport(e.kind);
|
|
135
|
+
if (!i) throw new f(`Unknown report kind "${e.kind}".`);
|
|
136
|
+
let a = i.schema.parse(e), o = b(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
|
+
}, C = (e, t) => {
|
|
150
|
+
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = (e.reports ?? []).map((e, n) => S(e, n, t, r));
|
|
151
|
+
return {
|
|
152
|
+
fields: e.fields.map((e, r) => x(e, r, t, n)),
|
|
153
|
+
reports: i
|
|
154
|
+
};
|
|
155
|
+
}, w = (e) => e === 1 || e === "1" || e === !0, T = (e, t, n = {}) => {
|
|
156
|
+
if (e.kind !== "onehot-category" || !Array.isArray(e.options)) return;
|
|
157
|
+
let r = /* @__PURE__ */ new Set(), i;
|
|
158
|
+
for (let a of e.options) {
|
|
159
|
+
let c = o(a.mappedTo, n.backend);
|
|
160
|
+
if (c === void 0) throw Error(`onehot-category "${e.id ?? e.kind}": option "${a.value}" has no mappedTo.`);
|
|
161
|
+
let l = s(c);
|
|
162
|
+
if (r.has(l)) throw Error(`onehot-category "${e.id ?? e.kind}": duplicate mappedTo "${l}".`);
|
|
163
|
+
if (r.add(l), w(t[l])) {
|
|
164
|
+
if (i !== void 0) throw Error(`onehot-category "${e.id ?? e.kind}": multiple selected mapped values.`);
|
|
165
|
+
i = a.value;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return i;
|
|
169
|
+
}, E = (e) => {
|
|
170
|
+
if (typeof e == "string") return e;
|
|
171
|
+
if (typeof e != "number") return e.id ?? e.config?.id;
|
|
172
|
+
}, D = (e, t) => {
|
|
173
|
+
if (typeof e == "string" || typeof e == "number") return String(e);
|
|
174
|
+
let n = o(e.mappedTo ?? e.config?.mappedTo, t);
|
|
175
|
+
return n === void 0 ? void 0 : s(n);
|
|
176
|
+
}, O = (e, t) => Object.fromEntries(e.map((e) => {
|
|
177
|
+
let n = u(e, t), r = n?.context, i = n?.mappedTo ?? o(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: i,
|
|
184
|
+
targetKey: i === void 0 ? void 0 : s(i),
|
|
185
|
+
backend: n?.backend ?? t.backend,
|
|
186
|
+
displayValues: r?.displayValues ?? t.displayValues,
|
|
187
|
+
modelValues: r?.modelValues ?? t.modelValues,
|
|
188
|
+
reports: t.reports,
|
|
189
|
+
meta: r?.meta ?? t.meta,
|
|
190
|
+
raw: r && "raw" in r ? r.raw : t.raw
|
|
191
|
+
}];
|
|
192
|
+
})), k = (e, t) => {
|
|
193
|
+
let n = e.reportContexts, r = E(t);
|
|
194
|
+
if (r && n[r]) return n[r];
|
|
195
|
+
let i = D(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
|
+
}, A = (e) => typeof e == "object" && !!e && !Array.isArray(e), j = (e, t) => {
|
|
200
|
+
if (!A(e)) return [];
|
|
201
|
+
let n = [], r = (r) => {
|
|
202
|
+
let i = e[r];
|
|
203
|
+
Array.isArray(i) && i.forEach((e, i) => {
|
|
204
|
+
if (!(!A(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
|
+
!A(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
|
+
}, M = (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 (!A(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
|
+
}, N = (e, t) => {
|
|
274
|
+
if (!A(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
|
+
M("fields", e.fields, t, n), M("reports", e.reports ?? [], t, n);
|
|
289
|
+
for (let r of j(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: C(e, t),
|
|
302
|
+
issues: []
|
|
303
|
+
};
|
|
304
|
+
} catch (e) {
|
|
305
|
+
let t = e instanceof _ ? 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
|
+
}, P = (e) => {
|
|
316
|
+
let n = e.map((e) => e.schema);
|
|
317
|
+
return n.length > 0 ? i(n) : t();
|
|
318
|
+
}, F = (t) => r(n({
|
|
319
|
+
fields: e(P(t.listFields())),
|
|
320
|
+
reports: e(P(t.listReports())).optional()
|
|
321
|
+
}), {
|
|
322
|
+
target: "draft-2020-12",
|
|
323
|
+
io: "input",
|
|
324
|
+
unrepresentable: "any"
|
|
325
|
+
}), I = (e, t = {}) => ({
|
|
326
|
+
reportId: t.reportId ?? "",
|
|
327
|
+
backend: e.backend,
|
|
328
|
+
inputs: e.inputs,
|
|
329
|
+
displayValues: e.displayValues,
|
|
330
|
+
modelValues: e.modelValues,
|
|
331
|
+
reports: e.reports,
|
|
332
|
+
reportContext: t.reportId === void 0 ? void 0 : k(e, t.reportId),
|
|
333
|
+
reportContexts: e.reportContexts,
|
|
334
|
+
meta: e.meta,
|
|
335
|
+
raw: e.raw,
|
|
336
|
+
signal: t.signal
|
|
337
|
+
});
|
|
338
|
+
//#endregion
|
|
339
|
+
export { l as _, O as a, a as b, _ as c, m as d, h as f, u as g, d as h, N as i, C as l, s as m, j as n, k as o, g as p, F as r, T as s, I as t, f as u, c as v, o as y };
|
|
@@ -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;
|
|
@@ -114,16 +110,12 @@ export interface PrimitiveSubmitExecutionResult {
|
|
|
114
110
|
export interface PrimitiveReportRequest {
|
|
115
111
|
reportId: string;
|
|
116
112
|
backend?: string;
|
|
117
|
-
inputs
|
|
118
|
-
displayValues
|
|
119
|
-
modelValues
|
|
120
|
-
values: Record<string, unknown>;
|
|
121
|
-
fieldValues: Record<string, unknown>;
|
|
122
|
-
serializedValues: Record<string, unknown>;
|
|
123
|
-
serializedFieldValues: Record<string, unknown>;
|
|
113
|
+
inputs: PrimitiveSubmissionInputRecord[];
|
|
114
|
+
displayValues: Record<string, unknown>;
|
|
115
|
+
modelValues: Record<string, unknown>;
|
|
124
116
|
reports: readonly unknown[];
|
|
125
117
|
reportContext?: PrimitiveReportContext;
|
|
126
|
-
reportContexts
|
|
118
|
+
reportContexts: Record<string, PrimitiveReportContext>;
|
|
127
119
|
meta: Record<string, unknown>;
|
|
128
120
|
raw: unknown;
|
|
129
121
|
signal?: AbortSignal;
|
|
@@ -14,10 +14,6 @@ export type SubmissionValueRecords = {
|
|
|
14
14
|
inputs: SubmissionInputRecord[];
|
|
15
15
|
displayValues: Record<string, unknown>;
|
|
16
16
|
modelValues: Record<string, unknown>;
|
|
17
|
-
values: Record<string, unknown>;
|
|
18
|
-
fieldValues: Record<string, unknown>;
|
|
19
|
-
serializedValues: Record<string, unknown>;
|
|
20
|
-
serializedFieldValues: Record<string, unknown>;
|
|
21
17
|
};
|
|
22
18
|
export declare const cloneSubmissionValueRecords: (records: SubmissionValueRecords) => SubmissionValueRecords;
|
|
23
19
|
export declare const shouldIncludeFieldInSubmission: (field: SubmissionField, resolveInactiveFieldPolicy: (field: SubmissionField) => "include" | "omit" | "reset-on-hide") => boolean;
|
|
@@ -10,10 +10,6 @@ export interface RuntimeBehaviorSubmissionRecords {
|
|
|
10
10
|
inputs: SubmissionInputRecord[];
|
|
11
11
|
displayValues: Record<string, unknown>;
|
|
12
12
|
modelValues: Record<string, unknown>;
|
|
13
|
-
values: Record<string, unknown>;
|
|
14
|
-
fieldValues: Record<string, unknown>;
|
|
15
|
-
serializedValues: Record<string, unknown>;
|
|
16
|
-
serializedFieldValues: Record<string, unknown>;
|
|
17
13
|
}
|
|
18
14
|
export interface RuntimeBehaviorContext {
|
|
19
15
|
readonly registry: Registry;
|
|
@@ -17,10 +17,6 @@ export interface BeforeSubmitContext {
|
|
|
17
17
|
inputs: SubmissionInputRecord[];
|
|
18
18
|
displayValues: Record<string, unknown>;
|
|
19
19
|
modelValues: Record<string, unknown>;
|
|
20
|
-
values: Record<string, unknown>;
|
|
21
|
-
fieldValues: Record<string, unknown>;
|
|
22
|
-
serializedValues: Record<string, unknown>;
|
|
23
|
-
serializedFieldValues: Record<string, unknown>;
|
|
24
20
|
submitCount: number;
|
|
25
21
|
signal: AbortSignal;
|
|
26
22
|
}
|
|
@@ -29,10 +25,6 @@ export interface AfterSubmitContext {
|
|
|
29
25
|
inputs: SubmissionInputRecord[];
|
|
30
26
|
displayValues: Record<string, unknown>;
|
|
31
27
|
modelValues: Record<string, unknown>;
|
|
32
|
-
values: Record<string, unknown>;
|
|
33
|
-
fieldValues: Record<string, unknown>;
|
|
34
|
-
serializedValues: Record<string, unknown>;
|
|
35
|
-
serializedFieldValues: Record<string, unknown>;
|
|
36
28
|
submitCount: number;
|
|
37
29
|
result: SubmitResult;
|
|
38
30
|
}
|
|
@@ -41,10 +33,6 @@ export interface SubmitErrorContext {
|
|
|
41
33
|
inputs: SubmissionInputRecord[];
|
|
42
34
|
displayValues: Record<string, unknown>;
|
|
43
35
|
modelValues: Record<string, unknown>;
|
|
44
|
-
values: Record<string, unknown>;
|
|
45
|
-
fieldValues: Record<string, unknown>;
|
|
46
|
-
serializedValues: Record<string, unknown>;
|
|
47
|
-
serializedFieldValues: Record<string, unknown>;
|
|
48
36
|
submitCount: number;
|
|
49
37
|
error: unknown;
|
|
50
38
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { ReportResult } from './types/submit';
|
|
2
2
|
export type MappedToTarget = string | number;
|
|
3
3
|
export type MappedTo = MappedToTarget | Record<string, MappedToTarget | null | undefined>;
|
|
4
|
+
export type MappedToRoute = {
|
|
5
|
+
backend: string;
|
|
6
|
+
mappedTo: MappedToTarget;
|
|
7
|
+
};
|
|
4
8
|
export declare const resolveMappedTo: (mappedTo: MappedTo | undefined, backend: string | undefined) => MappedToTarget | undefined;
|
|
5
9
|
export declare const mappedToKey: (target: MappedToTarget) => string;
|
|
6
10
|
export declare const resolveMappedTargets: (mappedTo: MappedTo | undefined, backend: string | undefined) => MappedToTarget[];
|
|
11
|
+
export declare const resolveMappedRoutes: (mappedTo: MappedTo | undefined, backend: string | undefined) => MappedToRoute[];
|
|
7
12
|
export declare const resolveMappedReportResult: (report: {
|
|
8
13
|
mappedTo?: MappedTo;
|
|
9
14
|
}, result: {
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { FormSchema, NormalizedFormSchema, Registry } from './index';
|
|
2
|
+
export declare class SchemaNormalizationError extends Error {
|
|
3
|
+
readonly path: readonly (string | number)[];
|
|
4
|
+
readonly code: "invalid-config" | "unknown-kind";
|
|
5
|
+
constructor(message: string, path: readonly (string | number)[], code?: "invalid-config" | "unknown-kind");
|
|
6
|
+
}
|
|
2
7
|
export declare const normalizeSchema: (schema: FormSchema, registry: Registry) => NormalizedFormSchema;
|
|
@@ -2,7 +2,7 @@ import { MappedTo } from './mapped-to';
|
|
|
2
2
|
import { NormalizedReportConfig } from './types/report';
|
|
3
3
|
import { ReportContext, SubmitResult } from './types/submit';
|
|
4
4
|
type ReportContextSource = Pick<SubmitResult, "backend"> & {
|
|
5
|
-
reportContexts
|
|
5
|
+
reportContexts: Record<string, ReportContext>;
|
|
6
6
|
};
|
|
7
7
|
type ReportContextLookup = string | number | {
|
|
8
8
|
id?: string;
|
|
@@ -12,6 +12,6 @@ type ReportContextLookup = string | number | {
|
|
|
12
12
|
mappedTo?: MappedTo;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export declare const createReportContexts: (reports: readonly NormalizedReportConfig[], result: Pick<SubmitResult, "backend" | "displayValues" | "modelValues" | "
|
|
15
|
+
export declare const createReportContexts: (reports: readonly NormalizedReportConfig[], result: Pick<SubmitResult, "backend" | "displayValues" | "modelValues" | "reports" | "meta" | "raw">) => Record<string, ReportContext>;
|
|
16
16
|
export declare const getReportContext: (source: ReportContextSource, lookup: ReportContextLookup) => ReportContext | undefined;
|
|
17
17
|
export {};
|
|
@@ -35,16 +35,12 @@ export interface ReportResolveContext<TConfig extends ReportConfig = ReportConfi
|
|
|
35
35
|
export interface ReportFetchRequest {
|
|
36
36
|
reportId: string;
|
|
37
37
|
backend?: string;
|
|
38
|
-
inputs
|
|
39
|
-
displayValues
|
|
40
|
-
modelValues
|
|
41
|
-
values: Record<string, unknown>;
|
|
42
|
-
fieldValues: Record<string, unknown>;
|
|
43
|
-
serializedValues: Record<string, unknown>;
|
|
44
|
-
serializedFieldValues: Record<string, unknown>;
|
|
38
|
+
inputs: SubmissionInputRecord[];
|
|
39
|
+
displayValues: Record<string, unknown>;
|
|
40
|
+
modelValues: Record<string, unknown>;
|
|
45
41
|
reports: readonly unknown[];
|
|
46
42
|
reportContext?: ReportContext;
|
|
47
|
-
reportContexts
|
|
43
|
+
reportContexts: Record<string, ReportContext>;
|
|
48
44
|
meta: Record<string, unknown>;
|
|
49
45
|
raw: unknown;
|
|
50
46
|
signal?: AbortSignal;
|
|
@@ -46,15 +46,11 @@ export type ReportResult = (BaseReportResult & {
|
|
|
46
46
|
});
|
|
47
47
|
export interface SubmitResult<TReportState = unknown> {
|
|
48
48
|
backend?: string;
|
|
49
|
-
inputs
|
|
50
|
-
displayValues
|
|
51
|
-
modelValues
|
|
52
|
-
values: Record<string, unknown>;
|
|
53
|
-
fieldValues: Record<string, unknown>;
|
|
54
|
-
serializedValues: Record<string, unknown>;
|
|
55
|
-
serializedFieldValues: Record<string, unknown>;
|
|
49
|
+
inputs: SubmissionInputRecord[];
|
|
50
|
+
displayValues: Record<string, unknown>;
|
|
51
|
+
modelValues: Record<string, unknown>;
|
|
56
52
|
reports: readonly ReportResult[];
|
|
57
|
-
reportContexts
|
|
53
|
+
reportContexts: Record<string, ReportContext>;
|
|
58
54
|
reportStates: Record<string, TReportState>;
|
|
59
55
|
meta: Record<string, unknown>;
|
|
60
56
|
raw: unknown;
|
|
@@ -22,4 +22,5 @@ export type SchemaValidationResult = {
|
|
|
22
22
|
export type SchemaJsonSchema = Record<string, unknown>;
|
|
23
23
|
export declare const findUnknownKinds: (schema: unknown, registry: Registry) => UnknownSchemaKind[];
|
|
24
24
|
export declare const validateSchema: (schema: unknown, registry: Registry) => SchemaValidationResult;
|
|
25
|
+
/** Registered schemas that set metadata ids must use globally unique ids. */
|
|
25
26
|
export declare const toSchemaJsonSchema: (registry: Registry) => SchemaJsonSchema;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { ReportResult, SubmissionInputRecord } from '../../schema';
|
|
2
2
|
export interface SubmitRequest<TField extends Record<string, unknown> = Record<string, unknown>, TReport extends Record<string, unknown> = Record<string, unknown>> {
|
|
3
3
|
backend?: string;
|
|
4
|
-
inputs
|
|
5
|
-
displayValues
|
|
6
|
-
modelValues
|
|
7
|
-
values: Record<string, unknown>;
|
|
8
|
-
fieldValues: Record<string, unknown>;
|
|
9
|
-
serializedValues: Record<string, unknown>;
|
|
10
|
-
serializedFieldValues: Record<string, unknown>;
|
|
4
|
+
inputs: SubmissionInputRecord[];
|
|
5
|
+
displayValues: Record<string, unknown>;
|
|
6
|
+
modelValues: Record<string, unknown>;
|
|
11
7
|
fields: readonly TField[];
|
|
12
8
|
reports: readonly TReport[];
|
|
13
9
|
signal?: AbortSignal;
|