mlform 0.1.2 → 0.1.3

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 (30) hide show
  1. package/README.md +166 -85
  2. package/dist/FieldStrategy-CW2h8YyB.js +2427 -0
  3. package/dist/{ReportStrategy-DY3GC_mJ.js → ReportStrategy-CxPzs4b2.js} +1 -1
  4. package/dist/{boolean-field-Cd3uhIPj.js → boolean-field-Dwz0ejWl.js} +2 -2
  5. package/dist/{category-field-D_Ms1x9u.js → category-field-DIgX--Px.js} +2 -2
  6. package/dist/{classifier-prediction-C5QzorTo.js → classifier-prediction-DgiEREf_.js} +2 -2
  7. package/dist/{custom-element-ttkHUa8w.js → custom-element-DFxkZ1wU.js} +0 -5
  8. package/dist/{date-field-Cg_ja679.js → date-field-91U2Xe46.js} +2 -2
  9. package/dist/{error-card-BwjPChwf.js → error-card-DHdkE18B.js} +2 -2
  10. package/dist/{field-wrapper-DqIQl76d.js → field-wrapper-CBmpN5T_.js} +3 -3
  11. package/dist/{ml-layout-Dx63KKf7.js → ml-layout-BJax9HVW.js} +3 -3
  12. package/dist/mlform/extensions.mjs +4 -4
  13. package/dist/mlform/strategies.mjs +9 -9
  14. package/dist/mlform.mjs +210 -202
  15. package/dist/{number-field-CC2DrVEb.js → number-field-Bcp45dJb.js} +31 -32
  16. package/dist/{property-jKFNMQpR.js → property-B2UZ3Oii.js} +0 -25
  17. package/dist/{range-field-Cr7LEtsJ.js → range-field-CD0kkCt0.js} +2 -2
  18. package/dist/{regressor-prediction-C18dHlfK.js → regressor-prediction-CPzZXlmA.js} +2 -2
  19. package/dist/src/core/domain/index.d.ts +2 -1
  20. package/dist/state-Ba1Gr1cr.js +7 -0
  21. package/dist/test/integration/lifecycle.integration.test.d.ts +1 -0
  22. package/dist/test/integration/registration.integration.test.d.ts +1 -0
  23. package/dist/test/integration/state.integration.test.d.ts +1 -0
  24. package/dist/test/integration/validation.integration.test.d.ts +1 -0
  25. package/dist/test/unit/Strategies.extensions.test.d.ts +1 -0
  26. package/dist/test/unit/Strategies.test.d.ts +1 -0
  27. package/dist/{text-field-DwP-Fa1w.js → text-field-CSBBr4gN.js} +2 -2
  28. package/package.json +59 -15
  29. package/dist/FieldStrategy-pPekBtH-.js +0 -2318
  30. package/dist/state-CLlTRyl1.js +0 -12
package/dist/mlform.mjs CHANGED
@@ -1,61 +1,61 @@
1
- import { $ as P, g as D, c as z, u as k, d as $, l as I, e as N, s as R, F as O, o as M } from "./FieldStrategy-pPekBtH-.js";
2
- import { F as U, M as L } from "./ModelTypes-B9_veCKB.js";
3
- class T {
1
+ import { $ as R, g as M, c as D, d as z, e as $, u as T, l as I, f as N, s as P, F as k, o as U } from "./FieldStrategy-CW2h8YyB.js";
2
+ import { F as L, M as H } from "./ModelTypes-B9_veCKB.js";
3
+ class x {
4
4
  constructor(e) {
5
- this.counter = 0, this.metadataRegistry = e?.metadata ?? D, this.target = e?.target ?? "draft-2020-12", this.unrepresentable = e?.unrepresentable ?? "throw", this.override = e?.override ?? (() => {
5
+ this.counter = 0, this.metadataRegistry = e?.metadata ?? M, this.target = e?.target ?? "draft-2020-12", this.unrepresentable = e?.unrepresentable ?? "throw", this.override = e?.override ?? (() => {
6
6
  }), this.io = e?.io ?? "output", this.seen = /* @__PURE__ */ new Map();
7
7
  }
8
8
  process(e, r = { path: [], schemaPath: [] }) {
9
9
  var o;
10
- const t = e._zod.def, u = {
10
+ const s = e._zod.def, u = {
11
11
  guid: "uuid",
12
12
  url: "uri",
13
13
  datetime: "date-time",
14
14
  json_string: "json-string",
15
15
  regex: ""
16
16
  // do not set
17
- }, y = this.seen.get(e);
18
- if (y)
19
- return y.count++, r.schemaPath.includes(e) && (y.cycle = r.path), y.schema;
17
+ }, g = this.seen.get(e);
18
+ if (g)
19
+ return g.count++, r.schemaPath.includes(e) && (g.cycle = r.path), g.schema;
20
20
  const p = { schema: {}, count: 1, cycle: void 0, path: r.path };
21
21
  this.seen.set(e, p);
22
- const S = e._zod.toJSONSchema?.();
23
- if (S)
24
- p.schema = S;
22
+ const b = e._zod.toJSONSchema?.();
23
+ if (b)
24
+ p.schema = b;
25
25
  else {
26
26
  const n = {
27
27
  ...r,
28
28
  schemaPath: [...r.schemaPath, e],
29
29
  path: r.path
30
- }, b = e._zod.parent;
31
- if (b)
32
- p.ref = b, this.process(b, n), this.seen.get(b).isParent = !0;
30
+ }, S = e._zod.parent;
31
+ if (S)
32
+ p.ref = S, this.process(S, n), this.seen.get(S).isParent = !0;
33
33
  else {
34
34
  const c = p.schema;
35
- switch (t.type) {
35
+ switch (s.type) {
36
36
  case "string": {
37
- const s = c;
38
- s.type = "string";
39
- const { minimum: i, maximum: a, format: h, patterns: f, contentEncoding: g } = e._zod.bag;
40
- if (typeof i == "number" && (s.minLength = i), typeof a == "number" && (s.maxLength = a), h && (s.format = u[h] ?? h, s.format === "" && delete s.format), g && (s.contentEncoding = g), f && f.size > 0) {
41
- const v = [...f];
42
- v.length === 1 ? s.pattern = v[0].source : v.length > 1 && (p.schema.allOf = [
43
- ...v.map((J) => ({
44
- ...this.target === "draft-7" ? { type: "string" } : {},
45
- pattern: J.source
37
+ const t = c;
38
+ t.type = "string";
39
+ const { minimum: i, maximum: a, format: h, patterns: f, contentEncoding: d } = e._zod.bag;
40
+ if (typeof i == "number" && (t.minLength = i), typeof a == "number" && (t.maxLength = a), h && (t.format = u[h] ?? h, t.format === "" && delete t.format), d && (t.contentEncoding = d), f && f.size > 0) {
41
+ const w = [...f];
42
+ w.length === 1 ? t.pattern = w[0].source : w.length > 1 && (p.schema.allOf = [
43
+ ...w.map((O) => ({
44
+ ...this.target === "draft-7" || this.target === "draft-4" || this.target === "openapi-3.0" ? { type: "string" } : {},
45
+ pattern: O.source
46
46
  }))
47
47
  ]);
48
48
  }
49
49
  break;
50
50
  }
51
51
  case "number": {
52
- const s = c, { minimum: i, maximum: a, format: h, multipleOf: f, exclusiveMaximum: g, exclusiveMinimum: v } = e._zod.bag;
53
- typeof h == "string" && h.includes("int") ? s.type = "integer" : s.type = "number", typeof v == "number" && (s.exclusiveMinimum = v), typeof i == "number" && (s.minimum = i, typeof v == "number" && (v >= i ? delete s.minimum : delete s.exclusiveMinimum)), typeof g == "number" && (s.exclusiveMaximum = g), typeof a == "number" && (s.maximum = a, typeof g == "number" && (g <= a ? delete s.maximum : delete s.exclusiveMaximum)), typeof f == "number" && (s.multipleOf = f);
52
+ const t = c, { minimum: i, maximum: a, format: h, multipleOf: f, exclusiveMaximum: d, exclusiveMinimum: w } = e._zod.bag;
53
+ typeof h == "string" && h.includes("int") ? t.type = "integer" : t.type = "number", typeof w == "number" && (this.target === "draft-4" || this.target === "openapi-3.0" ? (t.minimum = w, t.exclusiveMinimum = !0) : t.exclusiveMinimum = w), typeof i == "number" && (t.minimum = i, typeof w == "number" && this.target !== "draft-4" && (w >= i ? delete t.minimum : delete t.exclusiveMinimum)), typeof d == "number" && (this.target === "draft-4" || this.target === "openapi-3.0" ? (t.maximum = d, t.exclusiveMaximum = !0) : t.exclusiveMaximum = d), typeof a == "number" && (t.maximum = a, typeof d == "number" && this.target !== "draft-4" && (d <= a ? delete t.maximum : delete t.exclusiveMaximum)), typeof f == "number" && (t.multipleOf = f);
54
54
  break;
55
55
  }
56
56
  case "boolean": {
57
- const s = c;
58
- s.type = "boolean";
57
+ const t = c;
58
+ t.type = "boolean";
59
59
  break;
60
60
  }
61
61
  case "bigint": {
@@ -69,7 +69,7 @@ class T {
69
69
  break;
70
70
  }
71
71
  case "null": {
72
- c.type = "null";
72
+ this.target === "openapi-3.0" ? (c.type = "string", c.nullable = !0, c.enum = [null]) : c.type = "null";
73
73
  break;
74
74
  }
75
75
  case "any":
@@ -96,73 +96,74 @@ class T {
96
96
  break;
97
97
  }
98
98
  case "array": {
99
- const s = c, { minimum: i, maximum: a } = e._zod.bag;
100
- typeof i == "number" && (s.minItems = i), typeof a == "number" && (s.maxItems = a), s.type = "array", s.items = this.process(t.element, { ...n, path: [...n.path, "items"] });
99
+ const t = c, { minimum: i, maximum: a } = e._zod.bag;
100
+ typeof i == "number" && (t.minItems = i), typeof a == "number" && (t.maxItems = a), t.type = "array", t.items = this.process(s.element, { ...n, path: [...n.path, "items"] });
101
101
  break;
102
102
  }
103
103
  case "object": {
104
- const s = c;
105
- s.type = "object", s.properties = {};
106
- const i = t.shape;
104
+ const t = c;
105
+ t.type = "object", t.properties = {};
106
+ const i = s.shape;
107
107
  for (const f in i)
108
- s.properties[f] = this.process(i[f], {
108
+ t.properties[f] = this.process(i[f], {
109
109
  ...n,
110
110
  path: [...n.path, "properties", f]
111
111
  });
112
112
  const a = new Set(Object.keys(i)), h = new Set([...a].filter((f) => {
113
- const g = t.shape[f]._zod;
114
- return this.io === "input" ? g.optin === void 0 : g.optout === void 0;
113
+ const d = s.shape[f]._zod;
114
+ return this.io === "input" ? d.optin === void 0 : d.optout === void 0;
115
115
  }));
116
- h.size > 0 && (s.required = Array.from(h)), t.catchall?._zod.def.type === "never" ? s.additionalProperties = !1 : t.catchall ? t.catchall && (s.additionalProperties = this.process(t.catchall, {
116
+ h.size > 0 && (t.required = Array.from(h)), s.catchall?._zod.def.type === "never" ? t.additionalProperties = !1 : s.catchall ? s.catchall && (t.additionalProperties = this.process(s.catchall, {
117
117
  ...n,
118
118
  path: [...n.path, "additionalProperties"]
119
- })) : this.io === "output" && (s.additionalProperties = !1);
119
+ })) : this.io === "output" && (t.additionalProperties = !1);
120
120
  break;
121
121
  }
122
122
  case "union": {
123
- const s = c;
124
- s.anyOf = t.options.map((i, a) => this.process(i, {
123
+ const t = c, i = s.options.map((a, h) => this.process(a, {
125
124
  ...n,
126
- path: [...n.path, "anyOf", a]
125
+ path: [...n.path, "anyOf", h]
127
126
  }));
127
+ t.anyOf = i;
128
128
  break;
129
129
  }
130
130
  case "intersection": {
131
- const s = c, i = this.process(t.left, {
131
+ const t = c, i = this.process(s.left, {
132
132
  ...n,
133
133
  path: [...n.path, "allOf", 0]
134
- }), a = this.process(t.right, {
134
+ }), a = this.process(s.right, {
135
135
  ...n,
136
136
  path: [...n.path, "allOf", 1]
137
- }), h = (g) => "allOf" in g && Object.keys(g).length === 1, f = [
137
+ }), h = (d) => "allOf" in d && Object.keys(d).length === 1, f = [
138
138
  ...h(i) ? i.allOf : [i],
139
139
  ...h(a) ? a.allOf : [a]
140
140
  ];
141
- s.allOf = f;
141
+ t.allOf = f;
142
142
  break;
143
143
  }
144
144
  case "tuple": {
145
- const s = c;
146
- s.type = "array";
147
- const i = t.items.map((f, g) => this.process(f, { ...n, path: [...n.path, "prefixItems", g] }));
148
- if (this.target === "draft-2020-12" ? s.prefixItems = i : s.items = i, t.rest) {
149
- const f = this.process(t.rest, {
150
- ...n,
151
- path: [...n.path, "items"]
152
- });
153
- this.target === "draft-2020-12" ? s.items = f : s.additionalItems = f;
154
- }
155
- t.rest && (s.items = this.process(t.rest, {
145
+ const t = c;
146
+ t.type = "array";
147
+ const i = this.target === "draft-2020-12" ? "prefixItems" : "items", a = this.target === "draft-2020-12" || this.target === "openapi-3.0" ? "items" : "additionalItems", h = s.items.map((O, J) => this.process(O, {
156
148
  ...n,
157
- path: [...n.path, "items"]
158
- }));
159
- const { minimum: a, maximum: h } = e._zod.bag;
160
- typeof a == "number" && (s.minItems = a), typeof h == "number" && (s.maxItems = h);
149
+ path: [...n.path, i, J]
150
+ })), f = s.rest ? this.process(s.rest, {
151
+ ...n,
152
+ path: [...n.path, a, ...this.target === "openapi-3.0" ? [s.items.length] : []]
153
+ }) : null;
154
+ this.target === "draft-2020-12" ? (t.prefixItems = h, f && (t.items = f)) : this.target === "openapi-3.0" ? (t.items = {
155
+ anyOf: h
156
+ }, f && t.items.anyOf.push(f), t.minItems = h.length, f || (t.maxItems = h.length)) : (t.items = h, f && (t.additionalItems = f));
157
+ const { minimum: d, maximum: w } = e._zod.bag;
158
+ typeof d == "number" && (t.minItems = d), typeof w == "number" && (t.maxItems = w);
161
159
  break;
162
160
  }
163
161
  case "record": {
164
- const s = c;
165
- s.type = "object", s.propertyNames = this.process(t.keyType, { ...n, path: [...n.path, "propertyNames"] }), s.additionalProperties = this.process(t.valueType, {
162
+ const t = c;
163
+ t.type = "object", (this.target === "draft-7" || this.target === "draft-2020-12") && (t.propertyNames = this.process(s.keyType, {
164
+ ...n,
165
+ path: [...n.path, "propertyNames"]
166
+ })), t.additionalProperties = this.process(s.valueType, {
166
167
  ...n,
167
168
  path: [...n.path, "additionalProperties"]
168
169
  });
@@ -179,13 +180,13 @@ class T {
179
180
  break;
180
181
  }
181
182
  case "enum": {
182
- const s = c, i = z(t.entries);
183
- i.every((a) => typeof a == "number") && (s.type = "number"), i.every((a) => typeof a == "string") && (s.type = "string"), s.enum = i;
183
+ const t = c, i = D(s.entries);
184
+ i.every((a) => typeof a == "number") && (t.type = "number"), i.every((a) => typeof a == "string") && (t.type = "string"), t.enum = i;
184
185
  break;
185
186
  }
186
187
  case "literal": {
187
- const s = c, i = [];
188
- for (const a of t.values)
188
+ const t = c, i = [];
189
+ for (const a of s.values)
189
190
  if (a === void 0) {
190
191
  if (this.unrepresentable === "throw")
191
192
  throw new Error("Literal `undefined` cannot be represented in JSON Schema");
@@ -197,18 +198,18 @@ class T {
197
198
  i.push(a);
198
199
  if (i.length !== 0) if (i.length === 1) {
199
200
  const a = i[0];
200
- s.type = a === null ? "null" : typeof a, s.const = a;
201
+ t.type = a === null ? "null" : typeof a, this.target === "draft-4" || this.target === "openapi-3.0" ? t.enum = [a] : t.const = a;
201
202
  } else
202
- i.every((a) => typeof a == "number") && (s.type = "number"), i.every((a) => typeof a == "string") && (s.type = "string"), i.every((a) => typeof a == "boolean") && (s.type = "string"), i.every((a) => a === null) && (s.type = "null"), s.enum = i;
203
+ i.every((a) => typeof a == "number") && (t.type = "number"), i.every((a) => typeof a == "string") && (t.type = "string"), i.every((a) => typeof a == "boolean") && (t.type = "string"), i.every((a) => a === null) && (t.type = "null"), t.enum = i;
203
204
  break;
204
205
  }
205
206
  case "file": {
206
- const s = c, i = {
207
+ const t = c, i = {
207
208
  type: "string",
208
209
  format: "binary",
209
210
  contentEncoding: "binary"
210
211
  }, { minimum: a, maximum: h, mime: f } = e._zod.bag;
211
- a !== void 0 && (i.minLength = a), h !== void 0 && (i.maxLength = h), f ? f.length === 1 ? (i.contentMediaType = f[0], Object.assign(s, i)) : s.anyOf = f.map((g) => ({ ...i, contentMediaType: g })) : Object.assign(s, i);
212
+ a !== void 0 && (i.minLength = a), h !== void 0 && (i.maxLength = h), f ? f.length === 1 ? (i.contentMediaType = f[0], Object.assign(t, i)) : t.anyOf = f.map((d) => ({ ...i, contentMediaType: d })) : Object.assign(t, i);
212
213
  break;
213
214
  }
214
215
  case "transform": {
@@ -217,36 +218,36 @@ class T {
217
218
  break;
218
219
  }
219
220
  case "nullable": {
220
- const s = this.process(t.innerType, n);
221
- c.anyOf = [s, { type: "null" }];
221
+ const t = this.process(s.innerType, n);
222
+ this.target === "openapi-3.0" ? (p.ref = s.innerType, c.nullable = !0) : c.anyOf = [t, { type: "null" }];
222
223
  break;
223
224
  }
224
225
  case "nonoptional": {
225
- this.process(t.innerType, n), p.ref = t.innerType;
226
+ this.process(s.innerType, n), p.ref = s.innerType;
226
227
  break;
227
228
  }
228
229
  case "success": {
229
- const s = c;
230
- s.type = "boolean";
230
+ const t = c;
231
+ t.type = "boolean";
231
232
  break;
232
233
  }
233
234
  case "default": {
234
- this.process(t.innerType, n), p.ref = t.innerType, c.default = JSON.parse(JSON.stringify(t.defaultValue));
235
+ this.process(s.innerType, n), p.ref = s.innerType, c.default = JSON.parse(JSON.stringify(s.defaultValue));
235
236
  break;
236
237
  }
237
238
  case "prefault": {
238
- this.process(t.innerType, n), p.ref = t.innerType, this.io === "input" && (c._prefault = JSON.parse(JSON.stringify(t.defaultValue)));
239
+ this.process(s.innerType, n), p.ref = s.innerType, this.io === "input" && (c._prefault = JSON.parse(JSON.stringify(s.defaultValue)));
239
240
  break;
240
241
  }
241
242
  case "catch": {
242
- this.process(t.innerType, n), p.ref = t.innerType;
243
- let s;
243
+ this.process(s.innerType, n), p.ref = s.innerType;
244
+ let t;
244
245
  try {
245
- s = t.catchValue(void 0);
246
+ t = s.catchValue(void 0);
246
247
  } catch {
247
248
  throw new Error("Dynamic catch values are not supported in JSON Schema");
248
249
  }
249
- c.default = s;
250
+ c.default = t;
250
251
  break;
251
252
  }
252
253
  case "nan": {
@@ -255,33 +256,33 @@ class T {
255
256
  break;
256
257
  }
257
258
  case "template_literal": {
258
- const s = c, i = e._zod.pattern;
259
+ const t = c, i = e._zod.pattern;
259
260
  if (!i)
260
261
  throw new Error("Pattern not found in template literal");
261
- s.type = "string", s.pattern = i.source;
262
+ t.type = "string", t.pattern = i.source;
262
263
  break;
263
264
  }
264
265
  case "pipe": {
265
- const s = this.io === "input" ? t.in._zod.def.type === "transform" ? t.out : t.in : t.out;
266
- this.process(s, n), p.ref = s;
266
+ const t = this.io === "input" ? s.in._zod.def.type === "transform" ? s.out : s.in : s.out;
267
+ this.process(t, n), p.ref = t;
267
268
  break;
268
269
  }
269
270
  case "readonly": {
270
- this.process(t.innerType, n), p.ref = t.innerType, c.readOnly = !0;
271
+ this.process(s.innerType, n), p.ref = s.innerType, c.readOnly = !0;
271
272
  break;
272
273
  }
273
274
  // passthrough types
274
275
  case "promise": {
275
- this.process(t.innerType, n), p.ref = t.innerType;
276
+ this.process(s.innerType, n), p.ref = s.innerType;
276
277
  break;
277
278
  }
278
279
  case "optional": {
279
- this.process(t.innerType, n), p.ref = t.innerType;
280
+ this.process(s.innerType, n), p.ref = s.innerType;
280
281
  break;
281
282
  }
282
283
  case "lazy": {
283
- const s = e._zod.innerType;
284
- this.process(s, n), p.ref = s;
284
+ const t = e._zod.innerType;
285
+ this.process(t, n), p.ref = t;
285
286
  break;
286
287
  }
287
288
  case "custom": {
@@ -289,11 +290,16 @@ class T {
289
290
  throw new Error("Custom types cannot be represented in JSON Schema");
290
291
  break;
291
292
  }
293
+ case "function": {
294
+ if (this.unrepresentable === "throw")
295
+ throw new Error("Function types cannot be represented in JSON Schema");
296
+ break;
297
+ }
292
298
  }
293
299
  }
294
300
  }
295
- const w = this.metadataRegistry.get(e);
296
- return w && Object.assign(p.schema, w), this.io === "input" && d(e) && (delete p.schema.examples, delete p.schema.default), this.io === "input" && p.schema._prefault && ((o = p.schema).default ?? (o.default = p.schema._prefault)), delete p.schema._prefault, this.seen.get(e).schema;
301
+ const v = this.metadataRegistry.get(e);
302
+ return v && Object.assign(p.schema, v), this.io === "input" && m(e) && (delete p.schema.examples, delete p.schema.default), this.io === "input" && p.schema._prefault && ((o = p.schema).default ?? (o.default = p.schema._prefault)), delete p.schema._prefault, this.seen.get(e).schema;
297
303
  }
298
304
  emit(e, r) {
299
305
  const o = {
@@ -302,8 +308,8 @@ class T {
302
308
  // unrepresentable: _params?.unrepresentable ?? "throw",
303
309
  // uri: _params?.uri ?? ((id) => `${id}`),
304
310
  external: r?.external ?? void 0
305
- }, t = this.seen.get(e);
306
- if (!t)
311
+ }, s = this.seen.get(e);
312
+ if (!s)
307
313
  throw new Error("Unprocessed schema. This is a bug in Zod.");
308
314
  const u = (l) => {
309
315
  const n = this.target === "draft-2020-12" ? "$defs" : "definitions";
@@ -314,19 +320,19 @@ class T {
314
320
  const h = l[1].defId ?? l[1].schema.id ?? `schema${this.counter++}`;
315
321
  return l[1].defId = h, { defId: h, ref: `${a("__shared")}#/${n}/${h}` };
316
322
  }
317
- if (l[1] === t)
323
+ if (l[1] === s)
318
324
  return { ref: "#" };
319
- const c = `#/${n}/`, s = l[1].schema.id ?? `__schema${this.counter++}`;
320
- return { defId: s, ref: c + s };
321
- }, y = (l) => {
325
+ const c = `#/${n}/`, t = l[1].schema.id ?? `__schema${this.counter++}`;
326
+ return { defId: t, ref: c + t };
327
+ }, g = (l) => {
322
328
  if (l[1].schema.$ref)
323
329
  return;
324
- const n = l[1], { ref: b, defId: c } = u(l);
330
+ const n = l[1], { ref: S, defId: c } = u(l);
325
331
  n.def = { ...n.schema }, c && (n.defId = c);
326
- const s = n.schema;
327
- for (const i in s)
328
- delete s[i];
329
- s.$ref = b;
332
+ const t = n.schema;
333
+ for (const i in t)
334
+ delete t[i];
335
+ t.$ref = S;
330
336
  };
331
337
  if (o.cycles === "throw")
332
338
  for (const l of this.seen.entries()) {
@@ -339,105 +345,105 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
339
345
  for (const l of this.seen.entries()) {
340
346
  const n = l[1];
341
347
  if (e === l[0]) {
342
- y(l);
348
+ g(l);
343
349
  continue;
344
350
  }
345
351
  if (o.external) {
346
352
  const c = o.external.registry.get(l[0])?.id;
347
353
  if (e !== l[0] && c) {
348
- y(l);
354
+ g(l);
349
355
  continue;
350
356
  }
351
357
  }
352
358
  if (this.metadataRegistry.get(l[0])?.id) {
353
- y(l);
359
+ g(l);
354
360
  continue;
355
361
  }
356
362
  if (n.cycle) {
357
- y(l);
363
+ g(l);
358
364
  continue;
359
365
  }
360
366
  if (n.count > 1 && o.reused === "ref") {
361
- y(l);
367
+ g(l);
362
368
  continue;
363
369
  }
364
370
  }
365
371
  const p = (l, n) => {
366
- const b = this.seen.get(l), c = b.def ?? b.schema, s = { ...c };
367
- if (b.ref === null)
372
+ const S = this.seen.get(l), c = S.def ?? S.schema, t = { ...c };
373
+ if (S.ref === null)
368
374
  return;
369
- const i = b.ref;
370
- if (b.ref = null, i) {
375
+ const i = S.ref;
376
+ if (S.ref = null, i) {
371
377
  p(i, n);
372
378
  const a = this.seen.get(i).schema;
373
- a.$ref && n.target === "draft-7" ? (c.allOf = c.allOf ?? [], c.allOf.push(a)) : (Object.assign(c, a), Object.assign(c, s));
379
+ a.$ref && (n.target === "draft-7" || n.target === "draft-4" || n.target === "openapi-3.0") ? (c.allOf = c.allOf ?? [], c.allOf.push(a)) : (Object.assign(c, a), Object.assign(c, t));
374
380
  }
375
- b.isParent || this.override({
381
+ S.isParent || this.override({
376
382
  zodSchema: l,
377
383
  jsonSchema: c,
378
- path: b.path ?? []
384
+ path: S.path ?? []
379
385
  });
380
386
  };
381
387
  for (const l of [...this.seen.entries()].reverse())
382
388
  p(l[0], { target: this.target });
383
- const S = {};
384
- if (this.target === "draft-2020-12" ? S.$schema = "https://json-schema.org/draft/2020-12/schema" : this.target === "draft-7" ? S.$schema = "http://json-schema.org/draft-07/schema#" : console.warn(`Invalid target: ${this.target}`), o.external?.uri) {
389
+ const b = {};
390
+ if (this.target === "draft-2020-12" ? b.$schema = "https://json-schema.org/draft/2020-12/schema" : this.target === "draft-7" ? b.$schema = "http://json-schema.org/draft-07/schema#" : this.target === "draft-4" ? b.$schema = "http://json-schema.org/draft-04/schema#" : this.target === "openapi-3.0" || console.warn(`Invalid target: ${this.target}`), o.external?.uri) {
385
391
  const l = o.external.registry.get(e)?.id;
386
392
  if (!l)
387
393
  throw new Error("Schema is missing an `id` property");
388
- S.$id = o.external.uri(l);
394
+ b.$id = o.external.uri(l);
389
395
  }
390
- Object.assign(S, t.def);
391
- const w = o.external?.defs ?? {};
396
+ Object.assign(b, s.def);
397
+ const v = o.external?.defs ?? {};
392
398
  for (const l of this.seen.entries()) {
393
399
  const n = l[1];
394
- n.def && n.defId && (w[n.defId] = n.def);
400
+ n.def && n.defId && (v[n.defId] = n.def);
395
401
  }
396
- o.external || Object.keys(w).length > 0 && (this.target === "draft-2020-12" ? S.$defs = w : S.definitions = w);
402
+ o.external || Object.keys(v).length > 0 && (this.target === "draft-2020-12" ? b.$defs = v : b.definitions = v);
397
403
  try {
398
- return JSON.parse(JSON.stringify(S));
404
+ return JSON.parse(JSON.stringify(b));
399
405
  } catch {
400
406
  throw new Error("Error converting schema to JSON.");
401
407
  }
402
408
  }
403
409
  }
404
- function H(m, e) {
405
- if (m instanceof P) {
406
- const o = new T(e), t = {};
407
- for (const p of m._idmap.entries()) {
408
- const [S, w] = p;
409
- o.process(w);
410
+ function C(y, e) {
411
+ if (y instanceof R) {
412
+ const o = new x(e), s = {};
413
+ for (const p of y._idmap.entries()) {
414
+ const [b, v] = p;
415
+ o.process(v);
410
416
  }
411
- const u = {}, y = {
412
- registry: m,
417
+ const u = {}, g = {
418
+ registry: y,
413
419
  uri: e?.uri,
414
- defs: t
420
+ defs: s
415
421
  };
416
- for (const p of m._idmap.entries()) {
417
- const [S, w] = p;
418
- u[S] = o.emit(w, {
422
+ for (const p of y._idmap.entries()) {
423
+ const [b, v] = p;
424
+ u[b] = o.emit(v, {
419
425
  ...e,
420
- external: y
426
+ external: g
421
427
  });
422
428
  }
423
- if (Object.keys(t).length > 0) {
429
+ if (Object.keys(s).length > 0) {
424
430
  const p = o.target === "draft-2020-12" ? "$defs" : "definitions";
425
431
  u.__shared = {
426
- [p]: t
432
+ [p]: s
427
433
  };
428
434
  }
429
435
  return { schemas: u };
430
436
  }
431
- const r = new T(e);
432
- return r.process(m), r.emit(m, e);
437
+ const r = new x(e);
438
+ return r.process(y), r.emit(y, e);
433
439
  }
434
- function d(m, e) {
440
+ function m(y, e) {
435
441
  const r = e ?? { seen: /* @__PURE__ */ new Set() };
436
- if (r.seen.has(m))
442
+ if (r.seen.has(y))
437
443
  return !1;
438
- r.seen.add(m);
439
- const t = m._zod.def;
440
- switch (t.type) {
444
+ r.seen.add(y);
445
+ const s = y._zod.def;
446
+ switch (s.type) {
441
447
  case "string":
442
448
  case "number":
443
449
  case "bigint":
@@ -457,77 +463,79 @@ function d(m, e) {
457
463
  case "template_literal":
458
464
  return !1;
459
465
  case "array":
460
- return d(t.element, r);
466
+ return m(s.element, r);
461
467
  case "object": {
462
- for (const u in t.shape)
463
- if (d(t.shape[u], r))
468
+ for (const u in s.shape)
469
+ if (m(s.shape[u], r))
464
470
  return !0;
465
471
  return !1;
466
472
  }
467
473
  case "union": {
468
- for (const u of t.options)
469
- if (d(u, r))
474
+ for (const u of s.options)
475
+ if (m(u, r))
470
476
  return !0;
471
477
  return !1;
472
478
  }
473
479
  case "intersection":
474
- return d(t.left, r) || d(t.right, r);
480
+ return m(s.left, r) || m(s.right, r);
475
481
  case "tuple": {
476
- for (const u of t.items)
477
- if (d(u, r))
482
+ for (const u of s.items)
483
+ if (m(u, r))
478
484
  return !0;
479
- return !!(t.rest && d(t.rest, r));
485
+ return !!(s.rest && m(s.rest, r));
480
486
  }
481
487
  case "record":
482
- return d(t.keyType, r) || d(t.valueType, r);
488
+ return m(s.keyType, r) || m(s.valueType, r);
483
489
  case "map":
484
- return d(t.keyType, r) || d(t.valueType, r);
490
+ return m(s.keyType, r) || m(s.valueType, r);
485
491
  case "set":
486
- return d(t.valueType, r);
492
+ return m(s.valueType, r);
487
493
  // inner types
488
494
  case "promise":
489
495
  case "optional":
490
496
  case "nonoptional":
491
497
  case "nullable":
492
498
  case "readonly":
493
- return d(t.innerType, r);
499
+ return m(s.innerType, r);
494
500
  case "lazy":
495
- return d(t.getter(), r);
501
+ return m(s.getter(), r);
496
502
  case "default":
497
- return d(t.innerType, r);
503
+ return m(s.innerType, r);
498
504
  case "prefault":
499
- return d(t.innerType, r);
505
+ return m(s.innerType, r);
500
506
  case "custom":
501
507
  return !1;
502
508
  case "transform":
503
509
  return !0;
504
510
  case "pipe":
505
- return d(t.in, r) || d(t.out, r);
511
+ return m(s.in, r) || m(s.out, r);
506
512
  case "success":
507
513
  return !1;
508
514
  case "catch":
509
515
  return !1;
516
+ case "function":
517
+ return !1;
510
518
  }
511
- throw new Error(`Unknown schema type: ${t.type}`);
519
+ throw new Error(`Unknown schema type: ${s.type}`);
512
520
  }
513
- const C = $, x = k, _ = $(
521
+ const F = $, A = T, V = z, _ = $(
514
522
  I({
515
- type: k(Object.values(U).map((m) => N(m)))
523
+ type: T(Object.values(L).map((y) => N(y)))
516
524
  })
517
525
  );
518
526
  I({
519
- type: k(Object.values(L).map((m) => N(m)))
527
+ type: T(Object.values(H).map((y) => N(y)))
520
528
  });
521
- R({
529
+ P({
522
530
  inputs: _,
523
531
  outputs: _
524
532
  });
525
- const A = "[Registry] The type «{type}» already exists.", E = "[Registry] The type «{type}» does not exist.";
526
- class F {
533
+ const Y = "[Registry] The type «{type}» already exists.", E = "[Registry] The type «{type}» does not exist.";
534
+ class q {
527
535
  catalog = /* @__PURE__ */ new Map();
528
- combinedSchema = x([]);
536
+ combinedSchema = V();
529
537
  get schema() {
530
- return C(this.combinedSchema);
538
+ return F(this.combinedSchema);
531
539
  }
532
540
  get(e) {
533
541
  return this.catalog.get(e);
@@ -537,7 +545,7 @@ class F {
537
545
  }
538
546
  register(e) {
539
547
  if (this.catalog.has(e.type))
540
- throw new Error(A.replace("{type}", e.type));
548
+ throw new Error(Y.replace("{type}", e.type));
541
549
  this.catalog.set(e.type, e), this.rebuildSchema();
542
550
  }
543
551
  unregister(e) {
@@ -552,12 +560,12 @@ class F {
552
560
  }
553
561
  rebuildSchema() {
554
562
  const e = Array.from(this.catalog.values()).map((r) => r.schema);
555
- this.combinedSchema = x(e);
563
+ this.combinedSchema = A(e);
556
564
  }
557
565
  }
558
- const V = "[DescriptorService] Unsupported <<type>>";
566
+ const B = "[DescriptorService] Unsupported <<type>>";
559
567
  class j {
560
- registry = new F();
568
+ registry = new q();
561
569
  loadedTypes = /* @__PURE__ */ new Set();
562
570
  temporalOutputs = null;
563
571
  constructor(e = "") {
@@ -576,15 +584,15 @@ class j {
576
584
  }
577
585
  async ensureComponents(e) {
578
586
  const r = [
579
- import("./error-card-BwjPChwf.js"),
580
- import("./ml-layout-Dx63KKf7.js"),
581
- import("./field-wrapper-DqIQl76d.js")
587
+ import("./error-card-DHdkE18B.js"),
588
+ import("./ml-layout-BJax9HVW.js"),
589
+ import("./field-wrapper-CBmpN5T_.js")
582
590
  ];
583
591
  for (const o of e) {
584
- const t = o.type, u = this.reg.get(t);
592
+ const s = o.type, u = this.reg.get(s);
585
593
  if (!u)
586
- throw new Error(V.replace("type", t));
587
- this.loadedTypes.has(t) || (this.loadedTypes.add(t), r.push(u.loader()));
594
+ throw new Error(B.replace("type", s));
595
+ this.loadedTypes.has(s) || (this.loadedTypes.add(s), r.push(u.loader()));
588
596
  }
589
597
  await Promise.all(r);
590
598
  }
@@ -592,9 +600,9 @@ class j {
592
600
  this.reg.schema.parse(e);
593
601
  const r = [];
594
602
  for (const o of e) {
595
- const t = o.type, u = this.reg.get(t), y = u.parse(o);
603
+ const s = o.type, u = this.reg.get(s), g = u.parse(o);
596
604
  r.push(
597
- u.buildDescriptor(y)
605
+ u.buildDescriptor(g)
598
606
  );
599
607
  }
600
608
  return r;
@@ -612,8 +620,8 @@ class j {
612
620
  async render(e) {
613
621
  const r = this.reg.schema.parse(e);
614
622
  await this.ensureComponents(r);
615
- const o = this.renderDescriptors(r), t = document.querySelector('div[slot="report"]');
616
- t && (t.innerHTML = this.reportDescriptorsToInnerHtml(o));
623
+ const o = this.renderDescriptors(r), s = document.querySelector('div[slot="report"]');
624
+ s && (s.innerHTML = this.reportDescriptorsToInnerHtml(o));
617
625
  }
618
626
  async submit(e) {
619
627
  let r;
@@ -628,9 +636,9 @@ class j {
628
636
  });
629
637
  if (!o.ok) throw new Error(await o.text());
630
638
  r = await o.json();
631
- const t = this.reg.schema.parse(this.temporalOutputs);
632
- t[0].execution_time = r.outputs[0].execution_time, t[0].type === "regressor" ? t[0].values = r.outputs[0].values : t[0].type === "classifier" && (t[0].probabilities = r.outputs[0].probabilities);
633
- const u = this.reg.schema.parse(t);
639
+ const s = this.reg.schema.parse(this.temporalOutputs);
640
+ s[0].execution_time = r.outputs[0].execution_time, s[0].type === "regressor" ? s[0].values = r.outputs[0].values : s[0].type === "classifier" && (s[0].probabilities = r.outputs[0].probabilities);
641
+ const u = this.reg.schema.parse(s);
634
642
  this.render(u), r = u;
635
643
  } catch (o) {
636
644
  throw new Error(
@@ -650,7 +658,7 @@ class j {
650
658
  ).join(" ");
651
659
  }
652
660
  }
653
- class B {
661
+ class X {
654
662
  backendUrl;
655
663
  fieldService;
656
664
  modelService;
@@ -661,13 +669,13 @@ class B {
661
669
  this.backendUrl = e, this.fieldService = new j(), this.modelService = new j(this.backendUrl);
662
670
  }
663
671
  register(e) {
664
- e instanceof O ? this.fieldService.reg.register(e) : this.modelService.reg.register(e);
672
+ e instanceof k ? this.fieldService.reg.register(e) : this.modelService.reg.register(e);
665
673
  }
666
674
  update(e) {
667
- e instanceof O ? this.fieldService.reg.update(e) : this.modelService.reg.update(e);
675
+ e instanceof k ? this.fieldService.reg.update(e) : this.modelService.reg.update(e);
668
676
  }
669
677
  unregister(e) {
670
- e instanceof O ? this.fieldService.reg.unregister(e.type) : this.modelService.reg.unregister(e.type);
678
+ e instanceof k ? this.fieldService.reg.unregister(e.type) : this.modelService.reg.unregister(e.type);
671
679
  }
672
680
  /** Lectura sincrónica del último envío */
673
681
  get lastInputs() {
@@ -683,11 +691,11 @@ class B {
683
691
  async toHTMLElement(e, r) {
684
692
  const o = this.fieldService.reg.schema.parse(e.inputs);
685
693
  this.modelService.tmpOutputs = e.outputs, await this.fieldService.mount(o, r);
686
- const t = r.firstChild;
687
- return t.modelService = this.modelService, t.__mlSubmitHandler && t.removeEventListener("ml-submit", t.__mlSubmitHandler), t.__mlSubmitHandler = (u) => {
688
- const { inputs: y, response: p } = u.detail;
689
- this._lastInputs = y, this._lastResponse = p, this._listeners.forEach((S) => S(y, p));
690
- }, t.addEventListener("ml-submit", t.__mlSubmitHandler, {
694
+ const s = r.firstChild;
695
+ return s.modelService = this.modelService, s.__mlSubmitHandler && s.removeEventListener("ml-submit", s.__mlSubmitHandler), s.__mlSubmitHandler = (u) => {
696
+ const { inputs: g, response: p } = u.detail;
697
+ this._lastInputs = g, this._lastResponse = p, this._listeners.forEach((b) => b(g, p));
698
+ }, s.addEventListener("ml-submit", s.__mlSubmitHandler, {
691
699
  passive: !0
692
700
  }), r;
693
701
  }
@@ -695,15 +703,15 @@ class B {
695
703
  return this.fieldService.reg.schema.safeParseAsync(e.inputs);
696
704
  }
697
705
  schema() {
698
- return H(
699
- R({
706
+ return C(
707
+ P({
700
708
  inputs: this.fieldService.reg.schema,
701
- outputs: M(this.modelService.reg.schema)
709
+ outputs: U(this.modelService.reg.schema)
702
710
  }),
703
711
  { target: "draft-2020-12" }
704
712
  );
705
713
  }
706
714
  }
707
715
  export {
708
- B as MLForm
716
+ X as MLForm
709
717
  };