attaform 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -36
- package/dist/chunks/devtools.cjs +10 -37
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +10 -37
- package/dist/chunks/devtools.mjs.map +1 -1
- package/dist/chunks/indexeddb.cjs +4 -4
- package/dist/chunks/indexeddb.cjs.map +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +2 -2
- package/dist/chunks/local-storage.cjs.map +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +2 -2
- package/dist/chunks/session-storage.cjs.map +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +42 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -196
- package/dist/index.d.mts +159 -196
- package/dist/index.d.ts +159 -196
- package/dist/index.mjs +5 -7
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.cjs +31 -40
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.cts +8 -1
- package/dist/nuxt.d.mts +8 -1
- package/dist/nuxt.d.ts +8 -1
- package/dist/nuxt.mjs +32 -41
- package/dist/nuxt.mjs.map +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.d.vue.ts +7 -0
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +453 -0
- package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +7 -0
- package/dist/runtime/components/DevtoolsValueTree.d.vue.ts +37 -0
- package/dist/runtime/components/DevtoolsValueTree.vue +192 -0
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +37 -0
- package/dist/runtime/plugins/attaform.cjs +17 -6
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +15 -4
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/attaform.5UhpSVFI.cjs +63 -0
- package/dist/shared/attaform.5UhpSVFI.cjs.map +1 -0
- package/dist/shared/attaform.BDdFdjeX.mjs +57 -0
- package/dist/shared/attaform.BDdFdjeX.mjs.map +1 -0
- package/dist/shared/attaform.Bgu9l6OG.d.cts +1651 -0
- package/dist/shared/attaform.BmDBu4ql.d.ts +1651 -0
- package/dist/shared/{attaform.Dee2rU1P.cjs → attaform.BqK_L4gK.cjs} +310 -24
- package/dist/shared/attaform.BqK_L4gK.cjs.map +1 -0
- package/dist/shared/{attaform.C_5aB6EQ.d.mts → attaform.BsMdl-35.d.cts} +754 -146
- package/dist/shared/{attaform.C_5aB6EQ.d.ts → attaform.BsMdl-35.d.mts} +754 -146
- package/dist/shared/{attaform.C_5aB6EQ.d.cts → attaform.BsMdl-35.d.ts} +754 -146
- package/dist/shared/attaform.Bubm_slq.cjs.map +1 -1
- package/dist/shared/attaform.C3x1hKJC.d.mts +53 -0
- package/dist/shared/{attaform.CuE-bS1C.d.mts → attaform.CWs1Z3p7.d.ts} +57 -23
- package/dist/shared/attaform.CXpzmj38.mjs.map +1 -1
- package/dist/shared/attaform.CjmJpfLH.d.ts +53 -0
- package/dist/shared/{attaform.CVCmBKZX.mjs → attaform.CtNUB9nf.mjs} +74 -72
- package/dist/shared/attaform.CtNUB9nf.mjs.map +1 -0
- package/dist/shared/{attaform.C0iFnTN0.d.ts → attaform.D-hDvb98.d.cts} +57 -23
- package/dist/shared/attaform.DAH3kvav.d.mts +1651 -0
- package/dist/shared/{attaform.B5qiXQwN.cjs → attaform.DUHru0OF.cjs} +83 -81
- package/dist/shared/attaform.DUHru0OF.cjs.map +1 -0
- package/dist/shared/{attaform.BV40t5y2.cjs → attaform.Dlk1jMuv.cjs} +245 -108
- package/dist/shared/attaform.Dlk1jMuv.cjs.map +1 -0
- package/dist/shared/{attaform.B3ZaPIzS.mjs → attaform.DsC3rZHG.mjs} +1804 -219
- package/dist/shared/attaform.DsC3rZHG.mjs.map +1 -0
- package/dist/shared/attaform.Dzi89x8N.d.cts +53 -0
- package/dist/shared/{attaform.Cer8JO_P.cjs → attaform.II89Pcf4.cjs} +1860 -272
- package/dist/shared/attaform.II89Pcf4.cjs.map +1 -0
- package/dist/shared/{attaform.CIEQgJnM.mjs → attaform.Xhg0AYNa.mjs} +300 -26
- package/dist/shared/attaform.Xhg0AYNa.mjs.map +1 -0
- package/dist/shared/{attaform.CpERWz3u.mjs → attaform.Xt0A3QUd.mjs} +232 -95
- package/dist/shared/attaform.Xt0A3QUd.mjs.map +1 -0
- package/dist/shared/{attaform.CHorcsIU.d.cts → attaform.bH7WvNad.d.mts} +57 -23
- package/dist/vite.cjs +270 -2
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +266 -2
- package/dist/vite.mjs.map +1 -1
- package/dist/zod-v3.cjs +11 -8
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +36 -84
- package/dist/zod-v3.d.mts +36 -84
- package/dist/zod-v3.d.ts +36 -84
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +11 -8
- package/dist/zod-v4.cjs.map +1 -1
- package/dist/zod-v4.d.cts +5 -5
- package/dist/zod-v4.d.mts +5 -5
- package/dist/zod-v4.d.ts +5 -5
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +13 -10
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +127 -15
- package/dist/zod.d.mts +127 -15
- package/dist/zod.d.ts +127 -15
- package/dist/zod.mjs +5 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +19 -5
- package/dist/shared/attaform.B1jvxsOF.d.mts +0 -156
- package/dist/shared/attaform.B3ZaPIzS.mjs.map +0 -1
- package/dist/shared/attaform.B5qiXQwN.cjs.map +0 -1
- package/dist/shared/attaform.BBM2muQ9.cjs +0 -101
- package/dist/shared/attaform.BBM2muQ9.cjs.map +0 -1
- package/dist/shared/attaform.BV40t5y2.cjs.map +0 -1
- package/dist/shared/attaform.C6qzEdIM.d.cts +0 -156
- package/dist/shared/attaform.C8LVFVVe.cjs +0 -32
- package/dist/shared/attaform.C8LVFVVe.cjs.map +0 -1
- package/dist/shared/attaform.CIEQgJnM.mjs.map +0 -1
- package/dist/shared/attaform.CTwNcpLE.d.ts +0 -156
- package/dist/shared/attaform.CVCmBKZX.mjs.map +0 -1
- package/dist/shared/attaform.Cer8JO_P.cjs.map +0 -1
- package/dist/shared/attaform.CpERWz3u.mjs.map +0 -1
- package/dist/shared/attaform.Dee2rU1P.cjs.map +0 -1
- package/dist/shared/attaform.Vo-Kft0t.mjs +0 -29
- package/dist/shared/attaform.Vo-Kft0t.mjs.map +0 -1
- package/dist/shared/attaform.h1sq3BFu.mjs +0 -92
- package/dist/shared/attaform.h1sq3BFu.mjs.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const injectWizard = require('./attaform.II89Pcf4.cjs');
|
|
4
|
+
const paths = require('./attaform.BqK_L4gK.cjs');
|
|
5
5
|
const fieldMetaStore = require('./attaform.C8CyvYa_.cjs');
|
|
6
|
-
const paths = require('./attaform.BBM2muQ9.cjs');
|
|
7
6
|
const zod = require('zod');
|
|
8
7
|
|
|
9
8
|
const fieldMeta = fieldMetaStore.fieldMetaStore;
|
|
@@ -28,7 +27,7 @@ function zodIssuesToValidationErrors(issues, formKey) {
|
|
|
28
27
|
code = `zod:${issue.code}`;
|
|
29
28
|
} else {
|
|
30
29
|
code = "zod:unknown";
|
|
31
|
-
if (
|
|
30
|
+
if (paths.__DEV__ && !warnedZodCodeMissing) {
|
|
32
31
|
warnedZodCodeMissing = true;
|
|
33
32
|
console.warn(
|
|
34
33
|
"[attaform] zod-v4 adapter received an issue with no string `code`; stamping `'zod:unknown'`. This usually means a custom Zod plugin emitted an issue without the standard code field."
|
|
@@ -47,7 +46,7 @@ function zodIssuesToValidationErrors(issues, formKey) {
|
|
|
47
46
|
};
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
|
-
class UnsupportedSchemaError extends
|
|
49
|
+
class UnsupportedSchemaError extends paths.AttaformError {
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
function readDef(schema) {
|
|
@@ -126,6 +125,8 @@ function kindOf(schema) {
|
|
|
126
125
|
case "template_literal":
|
|
127
126
|
case "templateLiteral":
|
|
128
127
|
return "template-literal";
|
|
128
|
+
case "file":
|
|
129
|
+
return "file";
|
|
129
130
|
default:
|
|
130
131
|
return "unknown";
|
|
131
132
|
}
|
|
@@ -180,14 +181,13 @@ function unwrapPipeIn(schema) {
|
|
|
180
181
|
const def = readDef(schema);
|
|
181
182
|
return def?.in;
|
|
182
183
|
}
|
|
184
|
+
function isCoercePrimitive(schema) {
|
|
185
|
+
return readDef(schema)?.coerce === true;
|
|
186
|
+
}
|
|
183
187
|
function unwrapPipeOut(schema) {
|
|
184
188
|
const def = readDef(schema);
|
|
185
189
|
return def?.out;
|
|
186
190
|
}
|
|
187
|
-
function readTransformFn(schema) {
|
|
188
|
-
const def = readDef(schema);
|
|
189
|
-
return typeof def?.transform === "function" ? def.transform : void 0;
|
|
190
|
-
}
|
|
191
191
|
function unwrapLazy(schema) {
|
|
192
192
|
const def = readDef(schema);
|
|
193
193
|
const getter = def?.getter;
|
|
@@ -312,6 +312,70 @@ function containsAsyncRefine(schema, seen) {
|
|
|
312
312
|
}
|
|
313
313
|
return false;
|
|
314
314
|
}
|
|
315
|
+
function containsAsyncTransform(schema, seen) {
|
|
316
|
+
const visited = seen ?? /* @__PURE__ */ new WeakSet();
|
|
317
|
+
const candidate = schema;
|
|
318
|
+
if (typeof candidate !== "object" || candidate === null) return false;
|
|
319
|
+
if (visited.has(candidate)) return false;
|
|
320
|
+
visited.add(candidate);
|
|
321
|
+
const def = readDef(schema);
|
|
322
|
+
if (def === void 0) return false;
|
|
323
|
+
if (typeof def.transform === "function" && def.transform.constructor.name === "AsyncFunction") {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
if (def.innerType !== void 0 && containsAsyncTransform(def.innerType, visited)) {
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
if (def.element !== void 0 && containsAsyncTransform(def.element, visited)) {
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
if (def.in !== void 0 && containsAsyncTransform(def.in, visited)) {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
if (def.out !== void 0 && containsAsyncTransform(def.out, visited)) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
if (def.left !== void 0 && containsAsyncTransform(def.left, visited)) {
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
if (def.right !== void 0 && containsAsyncTransform(def.right, visited)) {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
if (def.keyType !== void 0 && containsAsyncTransform(def.keyType, visited)) {
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
if (def.valueType !== void 0 && containsAsyncTransform(def.valueType, visited)) {
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
if (def.shape !== void 0) {
|
|
351
|
+
for (const sub of Object.values(def.shape)) {
|
|
352
|
+
if (containsAsyncTransform(sub, visited)) return true;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (def.entries !== void 0) {
|
|
356
|
+
for (const sub of Object.values(def.entries)) {
|
|
357
|
+
if (containsAsyncTransform(sub, visited)) return true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (def.options !== void 0) {
|
|
361
|
+
for (const sub of def.options) {
|
|
362
|
+
if (containsAsyncTransform(sub, visited)) return true;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (def.items !== void 0) {
|
|
366
|
+
for (const sub of def.items) {
|
|
367
|
+
if (containsAsyncTransform(sub, visited)) return true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (typeof def.getter === "function") {
|
|
371
|
+
try {
|
|
372
|
+
const inner = def.getter();
|
|
373
|
+
if (containsAsyncTransform(inner, visited)) return true;
|
|
374
|
+
} catch {
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
315
379
|
function isAsyncCheck(check) {
|
|
316
380
|
if (typeof check !== "object" || check === null) return false;
|
|
317
381
|
const c = check;
|
|
@@ -416,6 +480,7 @@ function assertSupportedKinds(schema, path = [], lazyGetters = []) {
|
|
|
416
480
|
case "custom":
|
|
417
481
|
case "template-literal":
|
|
418
482
|
case "transform":
|
|
483
|
+
case "file":
|
|
419
484
|
return;
|
|
420
485
|
default: {
|
|
421
486
|
const _exhaustive = kind;
|
|
@@ -571,6 +636,7 @@ function computeFingerprint(schema, cache, inProgress) {
|
|
|
571
636
|
case "custom":
|
|
572
637
|
case "template-literal":
|
|
573
638
|
case "transform":
|
|
639
|
+
case "file":
|
|
574
640
|
return `${kind}:*`;
|
|
575
641
|
default: {
|
|
576
642
|
const _ = kind;
|
|
@@ -650,30 +716,45 @@ const PERMISSIVE = /* @__PURE__ */ new Set([
|
|
|
650
716
|
"symbol",
|
|
651
717
|
"function",
|
|
652
718
|
"map",
|
|
653
|
-
"set"
|
|
719
|
+
"set",
|
|
720
|
+
"file"
|
|
654
721
|
]);
|
|
722
|
+
const KIND_STRING = /* @__PURE__ */ new Set(["string"]);
|
|
723
|
+
const KIND_NUMBER = /* @__PURE__ */ new Set(["number"]);
|
|
724
|
+
const KIND_BOOLEAN = /* @__PURE__ */ new Set(["boolean"]);
|
|
725
|
+
const KIND_BIGINT = /* @__PURE__ */ new Set(["bigint"]);
|
|
726
|
+
const KIND_DATE = /* @__PURE__ */ new Set(["date"]);
|
|
727
|
+
const KIND_NULL = /* @__PURE__ */ new Set(["null"]);
|
|
728
|
+
const KIND_UNDEFINED = /* @__PURE__ */ new Set(["undefined"]);
|
|
729
|
+
const KIND_OBJECT = /* @__PURE__ */ new Set(["object"]);
|
|
730
|
+
const KIND_ARRAY = /* @__PURE__ */ new Set(["array"]);
|
|
731
|
+
const KIND_SET = /* @__PURE__ */ new Set(["set"]);
|
|
732
|
+
const KIND_FILE = /* @__PURE__ */ new Set(["file", "null"]);
|
|
733
|
+
const EMPTY_KINDS = /* @__PURE__ */ new Set();
|
|
655
734
|
function slimPrimitivesOf(schema, maxRecursionDepth) {
|
|
656
|
-
return walk(schema, 0, maxRecursionDepth);
|
|
735
|
+
return new Set(walk(schema, 0, maxRecursionDepth));
|
|
657
736
|
}
|
|
658
737
|
function walk(schema, lazyDepth, maxDepth) {
|
|
659
738
|
const kind = kindOf(schema);
|
|
660
739
|
switch (kind) {
|
|
661
740
|
case "string":
|
|
662
|
-
return
|
|
741
|
+
return KIND_STRING;
|
|
663
742
|
case "number":
|
|
664
743
|
case "nan":
|
|
665
|
-
return
|
|
744
|
+
return KIND_NUMBER;
|
|
666
745
|
case "boolean":
|
|
667
|
-
return
|
|
746
|
+
return KIND_BOOLEAN;
|
|
668
747
|
case "bigint":
|
|
669
|
-
return
|
|
748
|
+
return KIND_BIGINT;
|
|
670
749
|
case "date":
|
|
671
|
-
return
|
|
750
|
+
return KIND_DATE;
|
|
751
|
+
case "file":
|
|
752
|
+
return KIND_FILE;
|
|
672
753
|
case "null":
|
|
673
|
-
return
|
|
754
|
+
return KIND_NULL;
|
|
674
755
|
case "undefined":
|
|
675
756
|
case "void":
|
|
676
|
-
return
|
|
757
|
+
return KIND_UNDEFINED;
|
|
677
758
|
case "enum": {
|
|
678
759
|
const values = getEnumValues(schema);
|
|
679
760
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -681,48 +762,52 @@ function walk(schema, lazyDepth, maxDepth) {
|
|
|
681
762
|
if (typeof v === "string") out.add("string");
|
|
682
763
|
else if (typeof v === "number") out.add("number");
|
|
683
764
|
}
|
|
684
|
-
return out.size === 0 ?
|
|
765
|
+
return out.size === 0 ? KIND_STRING : out;
|
|
685
766
|
}
|
|
686
767
|
case "literal": {
|
|
687
768
|
const values = getLiteralValues(schema);
|
|
688
769
|
const out = /* @__PURE__ */ new Set();
|
|
689
770
|
for (const v of values) out.add(slimKindOfRaw(v));
|
|
690
|
-
return out.size === 0 ?
|
|
771
|
+
return out.size === 0 ? PERMISSIVE : out;
|
|
691
772
|
}
|
|
692
773
|
case "object":
|
|
693
774
|
case "record":
|
|
694
|
-
return
|
|
775
|
+
return KIND_OBJECT;
|
|
695
776
|
case "array":
|
|
696
777
|
case "tuple":
|
|
697
|
-
return
|
|
778
|
+
return KIND_ARRAY;
|
|
698
779
|
case "set":
|
|
699
|
-
return
|
|
780
|
+
return KIND_SET;
|
|
700
781
|
case "optional": {
|
|
701
782
|
const inner = unwrapInner(schema);
|
|
702
|
-
const innerSet = inner === void 0 ?
|
|
703
|
-
innerSet
|
|
704
|
-
|
|
783
|
+
const innerSet = inner === void 0 ? EMPTY_KINDS : walk(inner, lazyDepth, maxDepth);
|
|
784
|
+
const out = new Set(innerSet);
|
|
785
|
+
out.add("undefined");
|
|
786
|
+
return out;
|
|
705
787
|
}
|
|
706
788
|
case "nullable": {
|
|
707
789
|
const inner = unwrapInner(schema);
|
|
708
|
-
const innerSet = inner === void 0 ?
|
|
709
|
-
innerSet
|
|
710
|
-
|
|
790
|
+
const innerSet = inner === void 0 ? EMPTY_KINDS : walk(inner, lazyDepth, maxDepth);
|
|
791
|
+
const out = new Set(innerSet);
|
|
792
|
+
out.add("null");
|
|
793
|
+
return out;
|
|
711
794
|
}
|
|
712
795
|
case "default":
|
|
713
796
|
case "readonly":
|
|
714
797
|
case "catch": {
|
|
715
798
|
const inner = unwrapInner(schema);
|
|
716
|
-
return inner === void 0 ?
|
|
799
|
+
return inner === void 0 ? PERMISSIVE : walk(inner, lazyDepth, maxDepth);
|
|
717
800
|
}
|
|
718
801
|
case "pipe": {
|
|
719
|
-
const
|
|
720
|
-
|
|
802
|
+
const pipeIn = unwrapPipeIn(schema);
|
|
803
|
+
const pipeOut = unwrapPipeOut(schema);
|
|
804
|
+
const inner = pipeIn !== void 0 && kindOf(pipeIn) === "transform" ? pipeOut : pipeIn ?? pipeOut;
|
|
805
|
+
return inner === void 0 ? PERMISSIVE : walk(inner, lazyDepth, maxDepth);
|
|
721
806
|
}
|
|
722
807
|
case "lazy": {
|
|
723
|
-
if (lazyDepth >= maxDepth) return
|
|
808
|
+
if (lazyDepth >= maxDepth) return PERMISSIVE;
|
|
724
809
|
const inner = unwrapLazy(schema);
|
|
725
|
-
return inner === void 0 ?
|
|
810
|
+
return inner === void 0 ? PERMISSIVE : walk(inner, lazyDepth + 1, maxDepth);
|
|
726
811
|
}
|
|
727
812
|
case "union":
|
|
728
813
|
case "discriminated-union": {
|
|
@@ -731,22 +816,22 @@ function walk(schema, lazyDepth, maxDepth) {
|
|
|
731
816
|
for (const opt of options) {
|
|
732
817
|
for (const k of walk(opt, lazyDepth, maxDepth)) out.add(k);
|
|
733
818
|
}
|
|
734
|
-
return out.size === 0 ?
|
|
819
|
+
return out.size === 0 ? PERMISSIVE : out;
|
|
735
820
|
}
|
|
736
821
|
case "intersection": {
|
|
737
822
|
const left = getIntersectionLeft(schema);
|
|
738
823
|
const right = getIntersectionRight(schema);
|
|
739
|
-
const leftSet = left === void 0 ?
|
|
740
|
-
const rightSet = right === void 0 ?
|
|
824
|
+
const leftSet = left === void 0 ? PERMISSIVE : walk(left, lazyDepth, maxDepth);
|
|
825
|
+
const rightSet = right === void 0 ? PERMISSIVE : walk(right, lazyDepth, maxDepth);
|
|
741
826
|
const out = /* @__PURE__ */ new Set();
|
|
742
827
|
for (const k of leftSet) if (rightSet.has(k)) out.add(k);
|
|
743
828
|
return out;
|
|
744
829
|
}
|
|
745
830
|
case "never":
|
|
746
|
-
return
|
|
831
|
+
return EMPTY_KINDS;
|
|
747
832
|
case "any":
|
|
748
833
|
case "unknown":
|
|
749
|
-
return
|
|
834
|
+
return PERMISSIVE;
|
|
750
835
|
// Kinds we don't understand at the slim level: be permissive to
|
|
751
836
|
// avoid false-rejecting legitimate writes against schema shapes
|
|
752
837
|
// we haven't characterised.
|
|
@@ -754,9 +839,9 @@ function walk(schema, lazyDepth, maxDepth) {
|
|
|
754
839
|
case "custom":
|
|
755
840
|
case "template-literal":
|
|
756
841
|
case "transform":
|
|
757
|
-
return
|
|
842
|
+
return PERMISSIVE;
|
|
758
843
|
default:
|
|
759
|
-
return
|
|
844
|
+
return PERMISSIVE;
|
|
760
845
|
}
|
|
761
846
|
}
|
|
762
847
|
function slimKindOfRaw(value) {
|
|
@@ -875,6 +960,7 @@ function walkSegments(schema, segments, maxDepth, lazyDepth) {
|
|
|
875
960
|
case "custom":
|
|
876
961
|
case "template-literal":
|
|
877
962
|
case "transform":
|
|
963
|
+
case "file":
|
|
878
964
|
return [];
|
|
879
965
|
default: {
|
|
880
966
|
const _exhaustive = kind;
|
|
@@ -987,6 +1073,7 @@ function stripRefinements(schema) {
|
|
|
987
1073
|
case "custom":
|
|
988
1074
|
case "template-literal":
|
|
989
1075
|
case "transform":
|
|
1076
|
+
case "file":
|
|
990
1077
|
return schema;
|
|
991
1078
|
default: {
|
|
992
1079
|
const _exhaustive = kind;
|
|
@@ -1111,6 +1198,7 @@ function stripAsyncChecks(schema) {
|
|
|
1111
1198
|
case "custom":
|
|
1112
1199
|
case "template-literal":
|
|
1113
1200
|
case "transform":
|
|
1201
|
+
case "file":
|
|
1114
1202
|
return s;
|
|
1115
1203
|
default: {
|
|
1116
1204
|
const _exhaustive = kind;
|
|
@@ -1256,6 +1344,7 @@ function walkSlim(schema, stripConfig, maxDepth, lazyDepth) {
|
|
|
1256
1344
|
return slimmedInner.catch(getCatchDefault(schema));
|
|
1257
1345
|
}
|
|
1258
1346
|
case "transform":
|
|
1347
|
+
case "file":
|
|
1259
1348
|
return schema;
|
|
1260
1349
|
default: {
|
|
1261
1350
|
const _exhaustive = kind;
|
|
@@ -1264,10 +1353,25 @@ function walkSlim(schema, stripConfig, maxDepth, lazyDepth) {
|
|
|
1264
1353
|
}
|
|
1265
1354
|
}
|
|
1266
1355
|
|
|
1356
|
+
function hasDeclaredDefaultInChain(schema) {
|
|
1357
|
+
let current = schema;
|
|
1358
|
+
for (let i = 0; i < 32; i++) {
|
|
1359
|
+
if (current === void 0) return false;
|
|
1360
|
+
const k = kindOf(current);
|
|
1361
|
+
if (k === "default") return true;
|
|
1362
|
+
if (k === "optional" || k === "nullable" || k === "readonly" || k === "catch") {
|
|
1363
|
+
current = unwrapInner(current);
|
|
1364
|
+
continue;
|
|
1365
|
+
}
|
|
1366
|
+
return false;
|
|
1367
|
+
}
|
|
1368
|
+
return false;
|
|
1369
|
+
}
|
|
1267
1370
|
function deriveDefault(schema, useDefault, maxRecursionDepth) {
|
|
1268
1371
|
return defaultForKind(kindOf(schema), schema, useDefault, maxRecursionDepth, 0);
|
|
1269
1372
|
}
|
|
1270
1373
|
function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
|
|
1374
|
+
if (isCoercePrimitive(schema)) return void 0;
|
|
1271
1375
|
switch (kind) {
|
|
1272
1376
|
case "object": {
|
|
1273
1377
|
const shape = getObjectShape(schema);
|
|
@@ -1291,8 +1395,15 @@ function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
|
|
|
1291
1395
|
return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
|
|
1292
1396
|
}
|
|
1293
1397
|
case "pipe": {
|
|
1294
|
-
const out = unwrapPipeOut(schema);
|
|
1295
1398
|
const inn = unwrapPipeIn(schema);
|
|
1399
|
+
if (inn !== void 0 && kindOf(inn) === "transform") {
|
|
1400
|
+
const out2 = unwrapPipeOut(schema);
|
|
1401
|
+
if (out2 !== void 0 && hasDeclaredDefaultInChain(out2)) {
|
|
1402
|
+
return defaultForKind(kindOf(out2), out2, useDefault, maxDepth, lazyDepth);
|
|
1403
|
+
}
|
|
1404
|
+
return void 0;
|
|
1405
|
+
}
|
|
1406
|
+
const out = unwrapPipeOut(schema);
|
|
1296
1407
|
const real = inn !== void 0 && kindOf(inn) !== "transform" ? inn : out !== void 0 && kindOf(out) !== "transform" ? out : inn ?? out;
|
|
1297
1408
|
return real === void 0 ? void 0 : defaultForKind(kindOf(real), real, useDefault, maxDepth, lazyDepth);
|
|
1298
1409
|
}
|
|
@@ -1343,7 +1454,12 @@ function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
|
|
|
1343
1454
|
return NaN;
|
|
1344
1455
|
case "lazy": {
|
|
1345
1456
|
if (lazyDepth >= maxDepth) return void 0;
|
|
1346
|
-
|
|
1457
|
+
let inner;
|
|
1458
|
+
try {
|
|
1459
|
+
inner = unwrapLazy(schema);
|
|
1460
|
+
} catch {
|
|
1461
|
+
return void 0;
|
|
1462
|
+
}
|
|
1347
1463
|
return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth + 1);
|
|
1348
1464
|
}
|
|
1349
1465
|
case "intersection": {
|
|
@@ -1367,6 +1483,8 @@ function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
|
|
|
1367
1483
|
case "template-literal":
|
|
1368
1484
|
case "transform":
|
|
1369
1485
|
return void 0;
|
|
1486
|
+
case "file":
|
|
1487
|
+
return null;
|
|
1370
1488
|
default: {
|
|
1371
1489
|
const _exhaustive = kind;
|
|
1372
1490
|
throw new Error(`deriveDefault: unhandled ZodKind '${_exhaustive}'`);
|
|
@@ -1375,15 +1493,15 @@ function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
|
|
|
1375
1493
|
}
|
|
1376
1494
|
function mergeDeep(base, override) {
|
|
1377
1495
|
if (override === void 0) return base;
|
|
1378
|
-
if (!
|
|
1379
|
-
if (!
|
|
1496
|
+
if (!injectWizard.isPlainRecord(override)) return override;
|
|
1497
|
+
if (!injectWizard.isPlainRecord(base)) return override;
|
|
1380
1498
|
const result = { ...base };
|
|
1381
1499
|
for (const key of Object.keys(override)) {
|
|
1382
1500
|
const oVal = override[key];
|
|
1383
1501
|
const bVal = base[key];
|
|
1384
|
-
if (
|
|
1502
|
+
if (injectWizard.isPlainRecord(oVal) && injectWizard.isPlainRecord(bVal)) {
|
|
1385
1503
|
result[key] = mergeDeep(bVal, oVal);
|
|
1386
|
-
} else
|
|
1504
|
+
} else {
|
|
1387
1505
|
result[key] = oVal;
|
|
1388
1506
|
}
|
|
1389
1507
|
}
|
|
@@ -1409,18 +1527,26 @@ function getDefaultValuesFromZodSchema(opts) {
|
|
|
1409
1527
|
let fixedData = merged;
|
|
1410
1528
|
for (const issue of firstParse.error.issues) {
|
|
1411
1529
|
const pathSegments = issue.path.map((seg) => typeof seg === "number" ? seg : String(seg));
|
|
1530
|
+
const originalCandidate = getNestedZodSchemasAtPath(schema, pathSegments, maxRecursionDepth)[0];
|
|
1531
|
+
if (originalCandidate !== void 0) {
|
|
1532
|
+
if (isCoercePrimitive(originalCandidate)) continue;
|
|
1533
|
+
if (kindOf(originalCandidate) === "pipe") {
|
|
1534
|
+
const pipeIn = unwrapPipeIn(originalCandidate);
|
|
1535
|
+
if (pipeIn !== void 0 && kindOf(pipeIn) === "transform") continue;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1412
1538
|
const candidates = getNestedZodSchemasAtPath(slimSchema, pathSegments, maxRecursionDepth);
|
|
1413
1539
|
if (candidates.length === 0) continue;
|
|
1414
1540
|
const candidate = candidates[0];
|
|
1415
1541
|
if (candidate === void 0) continue;
|
|
1416
|
-
const valueAtPath =
|
|
1542
|
+
const valueAtPath = injectWizard.getAtPath(merged, pathSegments);
|
|
1417
1543
|
const slimKinds = slimPrimitivesOf(candidate, maxRecursionDepth);
|
|
1418
|
-
if (slimKinds.size > 0 && slimKinds.has(
|
|
1544
|
+
if (slimKinds.size > 0 && slimKinds.has(injectWizard.slimKindOf(valueAtPath))) {
|
|
1419
1545
|
continue;
|
|
1420
1546
|
}
|
|
1421
1547
|
const fixValue = defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursionDepth);
|
|
1422
1548
|
if (fixValue === SKIP) continue;
|
|
1423
|
-
fixedData = pathSegments.length === 0 ? fixValue :
|
|
1549
|
+
fixedData = pathSegments.length === 0 ? fixValue : injectWizard.setAtPath(fixedData, pathSegments, fixValue);
|
|
1424
1550
|
}
|
|
1425
1551
|
const secondParse = slimSchema.safeParse(fixedData);
|
|
1426
1552
|
if (secondParse.success) {
|
|
@@ -1537,11 +1663,12 @@ function zodV4Adapter(rootSchema) {
|
|
|
1537
1663
|
return (formKey, options) => {
|
|
1538
1664
|
const maxRecursionDepth = options.maxRecursionDepth;
|
|
1539
1665
|
const leafCache = /* @__PURE__ */ new Map();
|
|
1666
|
+
const preprocessOrCoerceCache = /* @__PURE__ */ new Map();
|
|
1540
1667
|
let asyncValidationFlag = null;
|
|
1541
1668
|
return {
|
|
1542
1669
|
fingerprint: () => fingerprintZodSchema(rootSchema),
|
|
1543
1670
|
needsAsyncValidation() {
|
|
1544
|
-
asyncValidationFlag ?? (asyncValidationFlag = containsAsyncRefine(rootSchema));
|
|
1671
|
+
asyncValidationFlag ?? (asyncValidationFlag = containsAsyncRefine(rootSchema) || containsAsyncTransform(rootSchema));
|
|
1545
1672
|
return asyncValidationFlag;
|
|
1546
1673
|
},
|
|
1547
1674
|
getDefaultValues(config) {
|
|
@@ -1552,8 +1679,12 @@ function zodV4Adapter(rootSchema) {
|
|
|
1552
1679
|
maxRecursionDepth
|
|
1553
1680
|
});
|
|
1554
1681
|
if (config.strict !== false) {
|
|
1682
|
+
if (containsAsyncTransform(rootSchema)) {
|
|
1683
|
+
return { data, errors: void 0, success: true, formKey };
|
|
1684
|
+
}
|
|
1685
|
+
const parseTarget = containsAsyncRefine(rootSchema) ? stripAsyncChecks(rootSchema) : rootSchema;
|
|
1555
1686
|
try {
|
|
1556
|
-
const strictResult =
|
|
1687
|
+
const strictResult = parseTarget.safeParse(
|
|
1557
1688
|
data
|
|
1558
1689
|
);
|
|
1559
1690
|
if (strictResult.success) {
|
|
@@ -1566,56 +1697,11 @@ function zodV4Adapter(rootSchema) {
|
|
|
1566
1697
|
formKey
|
|
1567
1698
|
};
|
|
1568
1699
|
} catch {
|
|
1569
|
-
|
|
1570
|
-
const syncOnly = stripAsyncChecks(rootSchema);
|
|
1571
|
-
const syncResult = syncOnly.safeParse(data);
|
|
1572
|
-
if (syncResult.success) {
|
|
1573
|
-
return { data, errors: void 0, success: true, formKey };
|
|
1574
|
-
}
|
|
1575
|
-
return {
|
|
1576
|
-
data,
|
|
1577
|
-
errors: zodIssuesToValidationErrors(syncResult.error.issues, formKey),
|
|
1578
|
-
success: false,
|
|
1579
|
-
formKey
|
|
1580
|
-
};
|
|
1581
|
-
} catch {
|
|
1582
|
-
return { data, errors: void 0, success: true, formKey };
|
|
1583
|
-
}
|
|
1700
|
+
return { data, errors: void 0, success: true, formKey };
|
|
1584
1701
|
}
|
|
1585
1702
|
}
|
|
1586
1703
|
return { data, errors: void 0, success: true, formKey };
|
|
1587
1704
|
},
|
|
1588
|
-
normalizeWriteValueAtPath(value, path) {
|
|
1589
|
-
const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
1590
|
-
const [first] = candidates;
|
|
1591
|
-
if (first === void 0) return value;
|
|
1592
|
-
let current = first;
|
|
1593
|
-
let result = value;
|
|
1594
|
-
for (let i = 0; i < 64; i++) {
|
|
1595
|
-
if (kindOf(current) !== "pipe") break;
|
|
1596
|
-
const pipeIn = unwrapPipeIn(current);
|
|
1597
|
-
if (pipeIn === void 0 || kindOf(pipeIn) !== "transform") break;
|
|
1598
|
-
const fn = readTransformFn(pipeIn);
|
|
1599
|
-
if (typeof fn !== "function") break;
|
|
1600
|
-
let next;
|
|
1601
|
-
try {
|
|
1602
|
-
next = fn(result);
|
|
1603
|
-
} catch (cause) {
|
|
1604
|
-
throw new Error(
|
|
1605
|
-
`[attaform] input normalization at path "${path.join(".")}" threw \u2014 write rejected.`,
|
|
1606
|
-
{ cause }
|
|
1607
|
-
);
|
|
1608
|
-
}
|
|
1609
|
-
if (next instanceof Promise) {
|
|
1610
|
-
return value;
|
|
1611
|
-
}
|
|
1612
|
-
result = next;
|
|
1613
|
-
const out = unwrapPipeOut(current);
|
|
1614
|
-
if (out === void 0) break;
|
|
1615
|
-
current = out;
|
|
1616
|
-
}
|
|
1617
|
-
return result;
|
|
1618
|
-
},
|
|
1619
1705
|
getDefaultAtPath(path) {
|
|
1620
1706
|
if (path.length === 0) return deriveDefault(rootSchema, true, maxRecursionDepth);
|
|
1621
1707
|
const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
@@ -1685,6 +1771,30 @@ function zodV4Adapter(rootSchema) {
|
|
|
1685
1771
|
leafCache.set(cacheKey, isLeaf);
|
|
1686
1772
|
return isLeaf;
|
|
1687
1773
|
},
|
|
1774
|
+
isPreprocessOrCoerceLeaf(path) {
|
|
1775
|
+
const cacheKey = paths.canonicalizePath(path).key;
|
|
1776
|
+
const cached = preprocessOrCoerceCache.get(cacheKey);
|
|
1777
|
+
if (cached !== void 0) return cached;
|
|
1778
|
+
let hit = false;
|
|
1779
|
+
for (let i = 0; i <= path.length && !hit; i++) {
|
|
1780
|
+
const prefix = path.slice(0, i);
|
|
1781
|
+
const candidates = prefix.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, prefix, maxRecursionDepth);
|
|
1782
|
+
for (const candidate of candidates) {
|
|
1783
|
+
if (isCoercePrimitive(candidate)) {
|
|
1784
|
+
hit = true;
|
|
1785
|
+
break;
|
|
1786
|
+
}
|
|
1787
|
+
if (kindOf(candidate) !== "pipe") continue;
|
|
1788
|
+
const pipeIn = unwrapPipeIn(candidate);
|
|
1789
|
+
if (pipeIn !== void 0 && kindOf(pipeIn) === "transform") {
|
|
1790
|
+
hit = true;
|
|
1791
|
+
break;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
preprocessOrCoerceCache.set(cacheKey, hit);
|
|
1796
|
+
return hit;
|
|
1797
|
+
},
|
|
1688
1798
|
isRequiredAtPath(path) {
|
|
1689
1799
|
if (path.length === 0) return true;
|
|
1690
1800
|
const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
@@ -1771,9 +1881,14 @@ function zodV4Adapter(rootSchema) {
|
|
|
1771
1881
|
}
|
|
1772
1882
|
async function runAsync() {
|
|
1773
1883
|
if (path === void 0) {
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1884
|
+
let result;
|
|
1885
|
+
try {
|
|
1886
|
+
result = await rootSchema.safeParseAsync(
|
|
1887
|
+
data
|
|
1888
|
+
);
|
|
1889
|
+
} catch (err) {
|
|
1890
|
+
return validatorThrewResponse(err, []);
|
|
1891
|
+
}
|
|
1777
1892
|
return result.success ? { data: result.data, errors: void 0, success: true, formKey } : {
|
|
1778
1893
|
data: void 0,
|
|
1779
1894
|
errors: zodIssuesToValidationErrors(result.error.issues, formKey),
|
|
@@ -1785,7 +1900,12 @@ function zodV4Adapter(rootSchema) {
|
|
|
1785
1900
|
if (resolved.length === 0) return pathNotFound(path);
|
|
1786
1901
|
const aggregated = [];
|
|
1787
1902
|
for (const candidate of resolved) {
|
|
1788
|
-
|
|
1903
|
+
let result;
|
|
1904
|
+
try {
|
|
1905
|
+
result = await candidate.safeParseAsync(data);
|
|
1906
|
+
} catch (err) {
|
|
1907
|
+
return validatorThrewResponse(err, path);
|
|
1908
|
+
}
|
|
1789
1909
|
if (result.success) {
|
|
1790
1910
|
return {
|
|
1791
1911
|
data: result.data,
|
|
@@ -1798,6 +1918,22 @@ function zodV4Adapter(rootSchema) {
|
|
|
1798
1918
|
}
|
|
1799
1919
|
return { data: void 0, errors: aggregated, success: false, formKey };
|
|
1800
1920
|
}
|
|
1921
|
+
function validatorThrewResponse(err, errPath) {
|
|
1922
|
+
const message = err instanceof Error ? err.message : typeof err === "string" ? err : "Validator threw";
|
|
1923
|
+
return {
|
|
1924
|
+
data: void 0,
|
|
1925
|
+
errors: [
|
|
1926
|
+
{
|
|
1927
|
+
message,
|
|
1928
|
+
path: [...errPath],
|
|
1929
|
+
formKey,
|
|
1930
|
+
code: injectWizard.AttaformErrorCode.ValidatorThrew
|
|
1931
|
+
}
|
|
1932
|
+
],
|
|
1933
|
+
success: false,
|
|
1934
|
+
formKey
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1801
1937
|
function pathNotFound(p) {
|
|
1802
1938
|
return {
|
|
1803
1939
|
data: void 0,
|
|
@@ -1806,7 +1942,7 @@ function zodV4Adapter(rootSchema) {
|
|
|
1806
1942
|
message: `Path '${p.join(PATH_SEPARATOR)}' did not resolve to any schema`,
|
|
1807
1943
|
path: [...p],
|
|
1808
1944
|
formKey,
|
|
1809
|
-
code:
|
|
1945
|
+
code: injectWizard.AttaformErrorCode.PathNotFound
|
|
1810
1946
|
}
|
|
1811
1947
|
],
|
|
1812
1948
|
success: false,
|
|
@@ -1971,6 +2107,7 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress)
|
|
|
1971
2107
|
case "custom":
|
|
1972
2108
|
case "template-literal":
|
|
1973
2109
|
case "transform":
|
|
2110
|
+
case "file":
|
|
1974
2111
|
return;
|
|
1975
2112
|
}
|
|
1976
2113
|
} finally {
|
|
@@ -1991,7 +2128,7 @@ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
|
|
|
1991
2128
|
const target = candidates[0];
|
|
1992
2129
|
if (target === void 0) {
|
|
1993
2130
|
return {
|
|
1994
|
-
label:
|
|
2131
|
+
label: injectWizard.humanize(lastSegment),
|
|
1995
2132
|
description: void 0,
|
|
1996
2133
|
placeholder: void 0,
|
|
1997
2134
|
meta: Object.freeze({})
|
|
@@ -2005,7 +2142,7 @@ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
|
|
|
2005
2142
|
const peeledDescription = peeled !== target ? readDescription(peeled) : void 0;
|
|
2006
2143
|
const schemaDescription = targetDescription ?? peeledDescription;
|
|
2007
2144
|
return {
|
|
2008
|
-
label: payload?.label ??
|
|
2145
|
+
label: payload?.label ?? injectWizard.humanize(lastSegment),
|
|
2009
2146
|
description: payload?.description ?? schemaDescription ?? void 0,
|
|
2010
2147
|
placeholder: payload?.placeholder ?? void 0,
|
|
2011
2148
|
meta: Object.freeze({ ...payload ?? {} })
|
|
@@ -2019,10 +2156,10 @@ function readDescription(schema) {
|
|
|
2019
2156
|
function useForm(configuration) {
|
|
2020
2157
|
const candidate = configuration;
|
|
2021
2158
|
if (candidate === void 0 || candidate === null || candidate.schema === void 0) {
|
|
2022
|
-
throw new
|
|
2159
|
+
throw new paths.InvalidUseFormConfigError();
|
|
2023
2160
|
}
|
|
2024
2161
|
const adapter = zodV4Adapter(configuration.schema);
|
|
2025
|
-
return
|
|
2162
|
+
return injectWizard.useAbstractForm({
|
|
2026
2163
|
...configuration,
|
|
2027
2164
|
schema: adapter
|
|
2028
2165
|
});
|
|
@@ -2035,4 +2172,4 @@ exports.kindOf = kindOf;
|
|
|
2035
2172
|
exports.useForm = useForm;
|
|
2036
2173
|
exports.withMeta = withMeta;
|
|
2037
2174
|
exports.zodV4Adapter = zodV4Adapter;
|
|
2038
|
-
//# sourceMappingURL=attaform.
|
|
2175
|
+
//# sourceMappingURL=attaform.Dlk1jMuv.cjs.map
|