attaform 0.18.2 → 0.20.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.
Files changed (111) hide show
  1. package/README.md +3 -0
  2. package/dist/chunks/devtools.cjs +1 -1
  3. package/dist/chunks/devtools.mjs +1 -1
  4. package/dist/chunks/indexeddb.cjs +1 -1
  5. package/dist/chunks/indexeddb.mjs +1 -1
  6. package/dist/chunks/local-storage.cjs +1 -1
  7. package/dist/chunks/local-storage.mjs +1 -1
  8. package/dist/chunks/session-storage.cjs +1 -1
  9. package/dist/chunks/session-storage.mjs +1 -1
  10. package/dist/index.cjs +4 -7
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +77 -110
  13. package/dist/index.d.mts +77 -110
  14. package/dist/index.d.ts +77 -110
  15. package/dist/index.mjs +5 -5
  16. package/dist/nuxt.d.cts +1 -1
  17. package/dist/nuxt.d.mts +1 -1
  18. package/dist/nuxt.d.ts +1 -1
  19. package/dist/runtime/components/AttaformDevtoolsPanel.vue +2 -2
  20. package/dist/runtime/components/DevtoolsValueTree.d.vue.ts +1 -3
  21. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +1 -3
  22. package/dist/runtime/plugins/attaform.cjs +2 -2
  23. package/dist/runtime/plugins/attaform.mjs +2 -2
  24. package/dist/shared/{attaform.CDmaxrt2.mjs → attaform.BKozEdTr.mjs} +305 -178
  25. package/dist/shared/attaform.BKozEdTr.mjs.map +1 -0
  26. package/dist/shared/{attaform.Bubm_slq.cjs → attaform.BM6YD9kZ.cjs} +212 -269
  27. package/dist/shared/attaform.BM6YD9kZ.cjs.map +1 -0
  28. package/dist/shared/{attaform.5UhpSVFI.cjs → attaform.BPxsYtTe.cjs} +2 -26
  29. package/dist/shared/attaform.BPxsYtTe.cjs.map +1 -0
  30. package/dist/shared/{attaform.BqK_L4gK.cjs → attaform.BPy-4qRx.cjs} +305 -180
  31. package/dist/shared/attaform.BPy-4qRx.cjs.map +1 -0
  32. package/dist/shared/attaform.BWgAFnsj.mjs +770 -0
  33. package/dist/shared/attaform.BWgAFnsj.mjs.map +1 -0
  34. package/dist/shared/{attaform.CGX1CNpz.d.ts → attaform.Bh3ACtts.d.ts} +152 -111
  35. package/dist/shared/{attaform.CXpzmj38.mjs → attaform.BupwXkj_.mjs} +213 -270
  36. package/dist/shared/attaform.BupwXkj_.mjs.map +1 -0
  37. package/dist/shared/{attaform.Dlk1jMuv.cjs → attaform.CIn4bMsD.cjs} +263 -799
  38. package/dist/shared/attaform.CIn4bMsD.cjs.map +1 -0
  39. package/dist/shared/{attaform.CZ-XtZt_.mjs → attaform.CKFbKFb6.mjs} +2265 -1509
  40. package/dist/shared/attaform.CKFbKFb6.mjs.map +1 -0
  41. package/dist/shared/{attaform.CuN7ZhBy.d.cts → attaform.D5-1XGQU.d.cts} +152 -111
  42. package/dist/shared/{attaform.-1GQTX2T.mjs → attaform.DEBvCjeH.mjs} +257 -793
  43. package/dist/shared/attaform.DEBvCjeH.mjs.map +1 -0
  44. package/dist/shared/{attaform.II89Pcf4.cjs → attaform.DL4CQ-oW.cjs} +2270 -1514
  45. package/dist/shared/attaform.DL4CQ-oW.cjs.map +1 -0
  46. package/dist/shared/{attaform.FnEwjhvX.d.ts → attaform.DSD85fHb.d.cts} +1 -19
  47. package/dist/shared/{attaform.CRmmNAYp.d.cts → attaform.DSD85fHb.d.mts} +1 -19
  48. package/dist/shared/{attaform.D9wuTGu9.d.mts → attaform.DSD85fHb.d.ts} +1 -19
  49. package/dist/shared/{attaform.B7rzpK1U.d.cts → attaform.DkA5J8NW.d.cts} +1 -17
  50. package/dist/shared/{attaform.B7rzpK1U.d.mts → attaform.DkA5J8NW.d.mts} +1 -17
  51. package/dist/shared/{attaform.B7rzpK1U.d.ts → attaform.DkA5J8NW.d.ts} +1 -17
  52. package/dist/shared/{attaform.B957T6NU.d.ts → attaform.Dl5kDY-A.d.ts} +1 -1
  53. package/dist/shared/attaform.Dmb6itxC.cjs +781 -0
  54. package/dist/shared/attaform.Dmb6itxC.cjs.map +1 -0
  55. package/dist/shared/{attaform.M-RanbyV.d.mts → attaform.DoKXru-a.d.mts} +1 -1
  56. package/dist/shared/attaform.DvA-CJJW.mjs +1876 -0
  57. package/dist/shared/attaform.DvA-CJJW.mjs.map +1 -0
  58. package/dist/shared/{attaform.D1gzu2GL.d.mts → attaform.EMzJcQci.d.mts} +152 -111
  59. package/dist/shared/attaform.EZG6fOFb.mjs +35 -0
  60. package/dist/shared/attaform.EZG6fOFb.mjs.map +1 -0
  61. package/dist/shared/{attaform.XDjA7sRz.d.cts → attaform.GbDo_lJi.d.cts} +1 -1
  62. package/dist/shared/{attaform.Ca5_6Ky-.d.mts → attaform.SfhU0OEY.d.cts} +499 -116
  63. package/dist/shared/{attaform.Ca5_6Ky-.d.cts → attaform.SfhU0OEY.d.mts} +499 -116
  64. package/dist/shared/{attaform.Ca5_6Ky-.d.ts → attaform.SfhU0OEY.d.ts} +499 -116
  65. package/dist/shared/attaform.jgzuNZVC.cjs +1882 -0
  66. package/dist/shared/attaform.jgzuNZVC.cjs.map +1 -0
  67. package/dist/transforms.cjs +2 -2
  68. package/dist/transforms.d.cts +22 -13
  69. package/dist/transforms.d.mts +22 -13
  70. package/dist/transforms.d.ts +22 -13
  71. package/dist/transforms.mjs +1 -1
  72. package/dist/vite.cjs +8 -7
  73. package/dist/vite.cjs.map +1 -1
  74. package/dist/vite.mjs +8 -7
  75. package/dist/vite.mjs.map +1 -1
  76. package/dist/zod-v3.cjs +3 -3
  77. package/dist/zod-v3.d.cts +32 -6
  78. package/dist/zod-v3.d.mts +32 -6
  79. package/dist/zod-v3.d.ts +32 -6
  80. package/dist/zod-v3.mjs +3 -3
  81. package/dist/zod-v4.cjs +3 -3
  82. package/dist/zod-v4.d.cts +12 -8
  83. package/dist/zod-v4.d.mts +12 -8
  84. package/dist/zod-v4.d.ts +12 -8
  85. package/dist/zod-v4.mjs +3 -3
  86. package/dist/zod.cjs +8 -8
  87. package/dist/zod.cjs.map +1 -1
  88. package/dist/zod.d.cts +6 -6
  89. package/dist/zod.d.mts +6 -6
  90. package/dist/zod.d.ts +6 -6
  91. package/dist/zod.mjs +6 -6
  92. package/package.json +2 -2
  93. package/dist/shared/attaform.-1GQTX2T.mjs.map +0 -1
  94. package/dist/shared/attaform.5UhpSVFI.cjs.map +0 -1
  95. package/dist/shared/attaform.BqK_L4gK.cjs.map +0 -1
  96. package/dist/shared/attaform.Bubm_slq.cjs.map +0 -1
  97. package/dist/shared/attaform.C8CyvYa_.cjs +0 -36
  98. package/dist/shared/attaform.C8CyvYa_.cjs.map +0 -1
  99. package/dist/shared/attaform.CDmaxrt2.mjs.map +0 -1
  100. package/dist/shared/attaform.CXpzmj38.mjs.map +0 -1
  101. package/dist/shared/attaform.CZ-XtZt_.mjs.map +0 -1
  102. package/dist/shared/attaform.D13GMFgK.mjs +0 -32
  103. package/dist/shared/attaform.D13GMFgK.mjs.map +0 -1
  104. package/dist/shared/attaform.DUHru0OF.cjs +0 -1600
  105. package/dist/shared/attaform.DUHru0OF.cjs.map +0 -1
  106. package/dist/shared/attaform.Df0tU0Ut.mjs +0 -1594
  107. package/dist/shared/attaform.Df0tU0Ut.mjs.map +0 -1
  108. package/dist/shared/attaform.Dl161U6E.mjs +0 -57
  109. package/dist/shared/attaform.Dl161U6E.mjs.map +0 -1
  110. package/dist/shared/attaform.Dlk1jMuv.cjs.map +0 -1
  111. package/dist/shared/attaform.II89Pcf4.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { g as getAtPath, j as slimKindOf, s as setAtPath, e as isPlainRecord, A as AttaformErrorCode, h as humanize, k as useAbstractForm } from './attaform.CZ-XtZt_.mjs';
2
- import { a as AttaformError, _ as __DEV__, i as canonicalizePath, c as InvalidUseFormConfigError } from './attaform.CDmaxrt2.mjs';
3
- import { f as fieldMetaStore, g as getFieldMetaForSchema, a as getFieldMetaListForSchema } from './attaform.D13GMFgK.mjs';
1
+ import { g as getAtPath, j as slimKindOf, s as setAtPath, h as humanize, k as useAbstractForm } from './attaform.CKFbKFb6.mjs';
2
+ import { a as AttaformError, _ as __DEV__, j as canonicalizePath, d as InvalidUseFormConfigError } from './attaform.BKozEdTr.mjs';
3
+ import { f as fieldMetaStore, g as getFieldMetaForSchema, a as getFieldMetaListForSchema, s as slimPrimitivesWalk, w as walkPathSegments, d as deriveDefaultWalk, m as mergeDeep, c as createAbstractSchema } from './attaform.BWgAFnsj.mjs';
4
4
  import { z } from 'zod';
5
5
 
6
6
  const fieldMeta = fieldMetaStore;
@@ -125,6 +125,12 @@ function kindOf(schema) {
125
125
  return "template-literal";
126
126
  case "file":
127
127
  return "file";
128
+ case "map":
129
+ return "map";
130
+ case "symbol":
131
+ return "symbol";
132
+ case "function":
133
+ return "function";
128
134
  default:
129
135
  return "unknown";
130
136
  }
@@ -182,6 +188,11 @@ function unwrapPipeIn(schema) {
182
188
  function isCoercePrimitive(schema) {
183
189
  return readDef(schema)?.coerce === true;
184
190
  }
191
+ function isPreprocessNode(schema) {
192
+ if (kindOf(schema) !== "pipe") return false;
193
+ const pipeIn = unwrapPipeIn(schema);
194
+ return pipeIn !== void 0 && kindOf(pipeIn) === "transform";
195
+ }
185
196
  function unwrapPipeOut(schema) {
186
197
  const def = readDef(schema);
187
198
  return def?.out;
@@ -214,10 +225,23 @@ function getCatchDefault(schema) {
214
225
  return void 0;
215
226
  }
216
227
  }
228
+ function hasCatchValue(schema) {
229
+ const def = readDef(schema);
230
+ return typeof def?.catchValue === "function";
231
+ }
217
232
  function getDefaultValue(schema) {
218
233
  const def = readDef(schema);
219
234
  return def?.defaultValue;
220
235
  }
236
+ function getNativeEnumValues(_schema) {
237
+ return void 0;
238
+ }
239
+ function unwrapEffectsSource(_schema) {
240
+ return void 0;
241
+ }
242
+ function unwrapBranded(_schema) {
243
+ return void 0;
244
+ }
221
245
  function hasChecks(schema) {
222
246
  const def = readDef(schema);
223
247
  const checks = def?.checks;
@@ -245,134 +269,97 @@ function assertZodVersion(schema) {
245
269
  );
246
270
  }
247
271
  }
248
- function containsAsyncRefine(schema, seen) {
272
+ function walkSchemaTree(schema, visit, seen) {
249
273
  const visited = seen ?? /* @__PURE__ */ new WeakSet();
250
274
  const candidate = schema;
251
275
  if (typeof candidate !== "object" || candidate === null) return false;
252
276
  if (visited.has(candidate)) return false;
253
277
  visited.add(candidate);
254
- const checks = getChecks(schema);
255
- for (const check of checks) {
256
- if (isAsyncCheck(check)) return true;
257
- }
278
+ if (visit(schema)) return true;
258
279
  const def = readDef(schema);
259
280
  if (def === void 0) return false;
260
- if (def.innerType !== void 0 && containsAsyncRefine(def.innerType, visited)) {
261
- return true;
262
- }
263
- if (def.element !== void 0 && containsAsyncRefine(def.element, visited)) {
281
+ if (def.innerType !== void 0 && walkSchemaTree(def.innerType, visit, visited)) {
264
282
  return true;
265
283
  }
266
- if (def.in !== void 0 && containsAsyncRefine(def.in, visited)) {
284
+ if (def.element !== void 0 && walkSchemaTree(def.element, visit, visited)) {
267
285
  return true;
268
286
  }
269
- if (def.out !== void 0 && containsAsyncRefine(def.out, visited)) {
287
+ if (def.in !== void 0 && walkSchemaTree(def.in, visit, visited)) return true;
288
+ if (def.out !== void 0 && walkSchemaTree(def.out, visit, visited)) return true;
289
+ if (def.left !== void 0 && walkSchemaTree(def.left, visit, visited)) return true;
290
+ if (def.right !== void 0 && walkSchemaTree(def.right, visit, visited)) return true;
291
+ if (def.keyType !== void 0 && walkSchemaTree(def.keyType, visit, visited)) {
270
292
  return true;
271
293
  }
272
- if (def.left !== void 0 && containsAsyncRefine(def.left, visited)) {
273
- return true;
274
- }
275
- if (def.right !== void 0 && containsAsyncRefine(def.right, visited)) {
276
- return true;
277
- }
278
- if (def.keyType !== void 0 && containsAsyncRefine(def.keyType, visited)) {
279
- return true;
280
- }
281
- if (def.valueType !== void 0 && containsAsyncRefine(def.valueType, visited)) {
294
+ if (def.valueType !== void 0 && walkSchemaTree(def.valueType, visit, visited)) {
282
295
  return true;
283
296
  }
284
297
  if (def.shape !== void 0) {
285
298
  for (const sub of Object.values(def.shape)) {
286
- if (containsAsyncRefine(sub, visited)) return true;
299
+ if (walkSchemaTree(sub, visit, visited)) return true;
287
300
  }
288
301
  }
289
302
  if (def.entries !== void 0) {
290
303
  for (const sub of Object.values(def.entries)) {
291
- if (containsAsyncRefine(sub, visited)) return true;
304
+ if (walkSchemaTree(sub, visit, visited)) return true;
292
305
  }
293
306
  }
294
307
  if (def.options !== void 0) {
295
308
  for (const sub of def.options) {
296
- if (containsAsyncRefine(sub, visited)) return true;
309
+ if (walkSchemaTree(sub, visit, visited)) return true;
297
310
  }
298
311
  }
299
312
  if (def.items !== void 0) {
300
313
  for (const sub of def.items) {
301
- if (containsAsyncRefine(sub, visited)) return true;
314
+ if (walkSchemaTree(sub, visit, visited)) return true;
302
315
  }
303
316
  }
304
317
  if (typeof def.getter === "function") {
305
318
  try {
306
319
  const inner = def.getter();
307
- if (containsAsyncRefine(inner, visited)) return true;
320
+ if (walkSchemaTree(inner, visit, visited)) return true;
308
321
  } catch {
309
322
  }
310
323
  }
311
324
  return false;
312
325
  }
326
+ function containsAsyncRefine(schema, seen) {
327
+ return walkSchemaTree(
328
+ schema,
329
+ (node) => {
330
+ for (const check of getChecks(node)) {
331
+ if (isAsyncCheck(check)) return true;
332
+ }
333
+ return false;
334
+ },
335
+ seen
336
+ );
337
+ }
338
+ function hasContainerOrRootRefine(schema, seen) {
339
+ return walkSchemaTree(
340
+ schema,
341
+ (node) => {
342
+ const def = readDef(node);
343
+ if (def === void 0) return false;
344
+ const isContainer = def.shape !== void 0 || def.entries !== void 0 || def.element !== void 0 || def.options !== void 0 || def.items !== void 0 || def.keyType !== void 0 || def.valueType !== void 0 || def.left !== void 0 || def.right !== void 0;
345
+ if (!isContainer) return false;
346
+ return getChecks(node).length > 0;
347
+ },
348
+ seen
349
+ );
350
+ }
313
351
  function containsAsyncTransform(schema, seen) {
314
- const visited = seen ?? /* @__PURE__ */ new WeakSet();
315
- const candidate = schema;
316
- if (typeof candidate !== "object" || candidate === null) return false;
317
- if (visited.has(candidate)) return false;
318
- visited.add(candidate);
319
- const def = readDef(schema);
320
- if (def === void 0) return false;
321
- if (typeof def.transform === "function" && def.transform.constructor.name === "AsyncFunction") {
322
- return true;
323
- }
324
- if (def.innerType !== void 0 && containsAsyncTransform(def.innerType, visited)) {
325
- return true;
326
- }
327
- if (def.element !== void 0 && containsAsyncTransform(def.element, visited)) {
328
- return true;
329
- }
330
- if (def.in !== void 0 && containsAsyncTransform(def.in, visited)) {
331
- return true;
332
- }
333
- if (def.out !== void 0 && containsAsyncTransform(def.out, visited)) {
334
- return true;
335
- }
336
- if (def.left !== void 0 && containsAsyncTransform(def.left, visited)) {
337
- return true;
338
- }
339
- if (def.right !== void 0 && containsAsyncTransform(def.right, visited)) {
340
- return true;
341
- }
342
- if (def.keyType !== void 0 && containsAsyncTransform(def.keyType, visited)) {
343
- return true;
344
- }
345
- if (def.valueType !== void 0 && containsAsyncTransform(def.valueType, visited)) {
346
- return true;
347
- }
348
- if (def.shape !== void 0) {
349
- for (const sub of Object.values(def.shape)) {
350
- if (containsAsyncTransform(sub, visited)) return true;
351
- }
352
- }
353
- if (def.entries !== void 0) {
354
- for (const sub of Object.values(def.entries)) {
355
- if (containsAsyncTransform(sub, visited)) return true;
356
- }
357
- }
358
- if (def.options !== void 0) {
359
- for (const sub of def.options) {
360
- if (containsAsyncTransform(sub, visited)) return true;
361
- }
362
- }
363
- if (def.items !== void 0) {
364
- for (const sub of def.items) {
365
- if (containsAsyncTransform(sub, visited)) return true;
366
- }
367
- }
368
- if (typeof def.getter === "function") {
369
- try {
370
- const inner = def.getter();
371
- if (containsAsyncTransform(inner, visited)) return true;
372
- } catch {
373
- }
374
- }
375
- return false;
352
+ return walkSchemaTree(
353
+ schema,
354
+ (node) => {
355
+ const def = readDef(node);
356
+ if (def === void 0) return false;
357
+ const fn = def.transform;
358
+ if (typeof fn !== "function") return false;
359
+ return fn.constructor.name === "AsyncFunction";
360
+ },
361
+ seen
362
+ );
376
363
  }
377
364
  function isAsyncCheck(check) {
378
365
  if (typeof check !== "object" || check === null) return false;
@@ -382,7 +369,14 @@ function isAsyncCheck(check) {
382
369
  return fn.constructor.name === "AsyncFunction";
383
370
  }
384
371
 
385
- const UNSUPPORTED = ["promise", "custom", "template-literal"];
372
+ const UNSUPPORTED = [
373
+ "promise",
374
+ "custom",
375
+ "template-literal",
376
+ "map",
377
+ "symbol",
378
+ "function"
379
+ ];
386
380
  function labelPath(path) {
387
381
  return path.length === 0 ? "<root>" : path.join(".");
388
382
  }
@@ -479,6 +473,9 @@ function assertSupportedKinds(schema, path = [], lazyGetters = []) {
479
473
  case "template-literal":
480
474
  case "transform":
481
475
  case "file":
476
+ case "map":
477
+ case "symbol":
478
+ case "function":
482
479
  return;
483
480
  default: {
484
481
  const _exhaustive = kind;
@@ -493,7 +490,7 @@ function unwrapToDiscriminatedUnion(schema) {
493
490
  const kind = kindOf(current);
494
491
  if (kind === "discriminated-union") return current;
495
492
  let next;
496
- if (kind === "optional" || kind === "nullable" || kind === "default" || kind === "readonly") {
493
+ if (kind === "optional" || kind === "nullable" || kind === "default" || kind === "readonly" || kind === "catch") {
497
494
  next = unwrapInner(current);
498
495
  } else if (kind === "pipe") {
499
496
  next = unwrapPipe(current);
@@ -629,12 +626,17 @@ function computeFingerprint(schema, cache, inProgress) {
629
626
  // Structural shape isn't observable for these. Bucket them into
630
627
  // kind-only fingerprints — a schema-mismatch warning can't do
631
628
  // better than "both are `custom`" here, but that still catches
632
- // `object` vs `custom` mismatches.
629
+ // `object` vs `custom` mismatches. `map` / `symbol` / `function`
630
+ // are rejected at adapter construction; kept here for exhaustive
631
+ // switch safety when `fingerprintSchema` is called from tooling.
633
632
  case "promise":
634
633
  case "custom":
635
634
  case "template-literal":
636
635
  case "transform":
637
636
  case "file":
637
+ case "map":
638
+ case "symbol":
639
+ case "function":
638
640
  return `${kind}:*`;
639
641
  default: {
640
642
  const _ = kind;
@@ -701,270 +703,61 @@ function compare(a, b) {
701
703
  return as < bs ? -1 : as > bs ? 1 : 0;
702
704
  }
703
705
 
704
- const PERMISSIVE = /* @__PURE__ */ new Set([
705
- "string",
706
- "number",
707
- "boolean",
708
- "bigint",
709
- "date",
710
- "null",
711
- "undefined",
712
- "object",
713
- "array",
714
- "symbol",
715
- "function",
716
- "map",
717
- "set",
718
- "file"
719
- ]);
720
- const KIND_STRING = /* @__PURE__ */ new Set(["string"]);
721
- const KIND_NUMBER = /* @__PURE__ */ new Set(["number"]);
722
- const KIND_BOOLEAN = /* @__PURE__ */ new Set(["boolean"]);
723
- const KIND_BIGINT = /* @__PURE__ */ new Set(["bigint"]);
724
- const KIND_DATE = /* @__PURE__ */ new Set(["date"]);
725
- const KIND_NULL = /* @__PURE__ */ new Set(["null"]);
726
- const KIND_UNDEFINED = /* @__PURE__ */ new Set(["undefined"]);
727
- const KIND_OBJECT = /* @__PURE__ */ new Set(["object"]);
728
- const KIND_ARRAY = /* @__PURE__ */ new Set(["array"]);
729
- const KIND_SET = /* @__PURE__ */ new Set(["set"]);
730
- const KIND_FILE = /* @__PURE__ */ new Set(["file", "null"]);
731
- const EMPTY_KINDS = /* @__PURE__ */ new Set();
706
+ const V4_INTROSPECTOR = {
707
+ kindOf: (schema) => kindOf(schema),
708
+ getObjectShape: (schema) => getObjectShape(schema),
709
+ getTupleItems: (schema) => getTupleItems(schema),
710
+ getDiscriminatedOptions: (schema) => getDiscriminatedOptions(schema),
711
+ getDiscriminator: (schema) => getDiscriminator(schema),
712
+ getLiteralValues: (schema) => getLiteralValues(schema),
713
+ isPreprocessNode: (schema) => isPreprocessNode(schema),
714
+ isCoercePrimitive: (schema) => isCoercePrimitive(schema),
715
+ containsAsyncRefine: (schema) => containsAsyncRefine(schema),
716
+ containsAsyncTransform: (schema) => containsAsyncTransform(schema),
717
+ hasContainerOrRootRefine: (schema) => hasContainerOrRootRefine(schema),
718
+ // Walker accessors (D2 / D3 / D5).
719
+ getArrayElement: (schema) => {
720
+ if (kindOf(schema) !== "array") return void 0;
721
+ return getArrayElement(schema);
722
+ },
723
+ getSetValueType: (schema) => kindOf(schema) === "set" ? getSetValueType(schema) : void 0,
724
+ getRecordKeyType: (schema) => kindOf(schema) === "record" ? getRecordKeyType(schema) : void 0,
725
+ getRecordValueType: (schema) => kindOf(schema) === "record" ? getRecordValueType(schema) : void 0,
726
+ getUnionOptions: (schema) => getUnionOptions(schema),
727
+ getIntersectionLeft: (schema) => getIntersectionLeft(schema),
728
+ getIntersectionRight: (schema) => getIntersectionRight(schema),
729
+ getEnumValues: (schema) => getEnumValues(schema),
730
+ getNativeEnumValues: (schema) => getNativeEnumValues(),
731
+ unwrapInner: (schema) => unwrapInner(schema),
732
+ unwrapBranded: (schema) => unwrapBranded(),
733
+ unwrapEffectsSource: (schema) => unwrapEffectsSource(),
734
+ unwrapPipeIn: (schema) => unwrapPipeIn(schema),
735
+ unwrapPipeOut: (schema) => unwrapPipeOut(schema),
736
+ unwrapLazy: (schema) => unwrapLazy(schema),
737
+ getLazyGetter: (schema) => getLazyGetter(schema),
738
+ getDefaultValue: (schema) => getDefaultValue(schema),
739
+ getCatchDefault: (schema) => getCatchDefault(schema),
740
+ hasCatchValue: (schema) => hasCatchValue(schema)
741
+ };
742
+
732
743
  function slimPrimitivesOf(schema, maxRecursionDepth) {
733
- return new Set(walk(schema, 0, maxRecursionDepth));
734
- }
735
- function walk(schema, lazyDepth, maxDepth) {
736
- const kind = kindOf(schema);
737
- switch (kind) {
738
- case "string":
739
- return KIND_STRING;
740
- case "number":
741
- case "nan":
742
- return KIND_NUMBER;
743
- case "boolean":
744
- return KIND_BOOLEAN;
745
- case "bigint":
746
- return KIND_BIGINT;
747
- case "date":
748
- return KIND_DATE;
749
- case "file":
750
- return KIND_FILE;
751
- case "null":
752
- return KIND_NULL;
753
- case "undefined":
754
- case "void":
755
- return KIND_UNDEFINED;
756
- case "enum": {
757
- const values = getEnumValues(schema);
758
- const out = /* @__PURE__ */ new Set();
759
- for (const v of values) {
760
- if (typeof v === "string") out.add("string");
761
- else if (typeof v === "number") out.add("number");
762
- }
763
- return out.size === 0 ? KIND_STRING : out;
764
- }
765
- case "literal": {
766
- const values = getLiteralValues(schema);
767
- const out = /* @__PURE__ */ new Set();
768
- for (const v of values) out.add(slimKindOfRaw(v));
769
- return out.size === 0 ? PERMISSIVE : out;
770
- }
771
- case "object":
772
- case "record":
773
- return KIND_OBJECT;
774
- case "array":
775
- case "tuple":
776
- return KIND_ARRAY;
777
- case "set":
778
- return KIND_SET;
779
- case "optional": {
780
- const inner = unwrapInner(schema);
781
- const innerSet = inner === void 0 ? EMPTY_KINDS : walk(inner, lazyDepth, maxDepth);
782
- const out = new Set(innerSet);
783
- out.add("undefined");
784
- return out;
785
- }
786
- case "nullable": {
787
- const inner = unwrapInner(schema);
788
- const innerSet = inner === void 0 ? EMPTY_KINDS : walk(inner, lazyDepth, maxDepth);
789
- const out = new Set(innerSet);
790
- out.add("null");
791
- return out;
792
- }
793
- case "default":
794
- case "readonly":
795
- case "catch": {
796
- const inner = unwrapInner(schema);
797
- return inner === void 0 ? PERMISSIVE : walk(inner, lazyDepth, maxDepth);
798
- }
799
- case "pipe": {
800
- const pipeIn = unwrapPipeIn(schema);
801
- const pipeOut = unwrapPipeOut(schema);
802
- const inner = pipeIn !== void 0 && kindOf(pipeIn) === "transform" ? pipeOut : pipeIn ?? pipeOut;
803
- return inner === void 0 ? PERMISSIVE : walk(inner, lazyDepth, maxDepth);
804
- }
805
- case "lazy": {
806
- if (lazyDepth >= maxDepth) return PERMISSIVE;
807
- const inner = unwrapLazy(schema);
808
- return inner === void 0 ? PERMISSIVE : walk(inner, lazyDepth + 1, maxDepth);
809
- }
810
- case "union":
811
- case "discriminated-union": {
812
- const options = getUnionOptions(schema);
813
- const out = /* @__PURE__ */ new Set();
814
- for (const opt of options) {
815
- for (const k of walk(opt, lazyDepth, maxDepth)) out.add(k);
816
- }
817
- return out.size === 0 ? PERMISSIVE : out;
818
- }
819
- case "intersection": {
820
- const left = getIntersectionLeft(schema);
821
- const right = getIntersectionRight(schema);
822
- const leftSet = left === void 0 ? PERMISSIVE : walk(left, lazyDepth, maxDepth);
823
- const rightSet = right === void 0 ? PERMISSIVE : walk(right, lazyDepth, maxDepth);
824
- const out = /* @__PURE__ */ new Set();
825
- for (const k of leftSet) if (rightSet.has(k)) out.add(k);
826
- return out;
827
- }
828
- case "never":
829
- return EMPTY_KINDS;
830
- case "any":
831
- case "unknown":
832
- return PERMISSIVE;
833
- // Kinds we don't understand at the slim level: be permissive to
834
- // avoid false-rejecting legitimate writes against schema shapes
835
- // we haven't characterised.
836
- case "promise":
837
- case "custom":
838
- case "template-literal":
839
- case "transform":
840
- return PERMISSIVE;
841
- default:
842
- return PERMISSIVE;
843
- }
844
- }
845
- function slimKindOfRaw(value) {
846
- if (value === null) return "null";
847
- if (value === void 0) return "undefined";
848
- if (Array.isArray(value)) return "array";
849
- if (value instanceof Date) return "date";
850
- const t = typeof value;
851
- switch (t) {
852
- case "string":
853
- return "string";
854
- case "number":
855
- return "number";
856
- case "boolean":
857
- return "boolean";
858
- case "bigint":
859
- return "bigint";
860
- case "symbol":
861
- return "symbol";
862
- case "undefined":
863
- return "undefined";
864
- case "object":
865
- return "object";
866
- case "function":
867
- return "function";
868
- default:
869
- return "object";
870
- }
744
+ return new Set(slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth));
871
745
  }
872
746
 
873
- const PATH_SEPARATOR$1 = ".";
747
+ const PATH_SEPARATOR = ".";
874
748
  function getNestedZodSchemasAtPath(schema, path, maxRecursionDepth) {
875
- if (Array.isArray(path)) return walkSegments(schema, path.map(String), maxRecursionDepth, 0);
749
+ if (Array.isArray(path)) {
750
+ return walkPathSegments(schema, path.map(String), V4_INTROSPECTOR, maxRecursionDepth, 0);
751
+ }
876
752
  const pathString = path;
877
753
  if (pathString.length === 0) return [schema];
878
- return walkSegments(schema, pathString.split(PATH_SEPARATOR$1), maxRecursionDepth, 0);
879
- }
880
- function walkSegments(schema, segments, maxDepth, lazyDepth) {
881
- if (segments.length === 0) return [schema];
882
- const [head, ...rest] = segments;
883
- if (head === void 0) return [schema];
884
- const kind = kindOf(schema);
885
- switch (kind) {
886
- case "object": {
887
- const shape = getObjectShape(schema);
888
- if (!Object.hasOwn(shape, head)) return [];
889
- const next = shape[head];
890
- return next === void 0 ? [] : walkSegments(next, rest, maxDepth, lazyDepth);
891
- }
892
- case "array":
893
- return walkSegments(getArrayElement(schema), rest, maxDepth, lazyDepth);
894
- case "set":
895
- return walkSegments(getSetValueType(schema), rest, maxDepth, lazyDepth);
896
- case "record":
897
- return walkSegments(getRecordValueType(schema), rest, maxDepth, lazyDepth);
898
- case "tuple": {
899
- const index = Number(head);
900
- if (!Number.isInteger(index)) return [];
901
- const items = getTupleItems(schema);
902
- const item = items[index];
903
- return item === void 0 ? [] : walkSegments(item, rest, maxDepth, lazyDepth);
904
- }
905
- case "union":
906
- return getUnionOptions(schema).flatMap(
907
- (opt) => walkSegments(opt, segments, maxDepth, lazyDepth)
908
- );
909
- case "discriminated-union": {
910
- const options = getDiscriminatedOptions(schema);
911
- const matching = options.filter((opt) => {
912
- const shape = getObjectShape(opt);
913
- return Object.hasOwn(shape, head);
914
- });
915
- const candidates = matching.length > 0 ? matching : options;
916
- return candidates.flatMap((opt) => walkSegments(opt, segments, maxDepth, lazyDepth));
917
- }
918
- case "optional":
919
- case "nullable":
920
- case "default":
921
- case "readonly":
922
- case "catch": {
923
- const inner = unwrapInner(schema);
924
- return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth);
925
- }
926
- case "pipe": {
927
- const inner = unwrapPipe(schema);
928
- return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth);
929
- }
930
- case "lazy": {
931
- if (lazyDepth >= maxDepth) return [];
932
- const inner = unwrapLazy(schema);
933
- return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth + 1);
934
- }
935
- case "intersection": {
936
- const left = getIntersectionLeft(schema);
937
- const right = getIntersectionRight(schema);
938
- const leftResults = left === void 0 ? [] : walkSegments(left, segments, maxDepth, lazyDepth);
939
- const rightResults = right === void 0 ? [] : walkSegments(right, segments, maxDepth, lazyDepth);
940
- return [...leftResults, ...rightResults];
941
- }
942
- // Leaf types — can't descend further.
943
- case "string":
944
- case "number":
945
- case "bigint":
946
- case "boolean":
947
- case "undefined":
948
- case "null":
949
- case "void":
950
- case "never":
951
- case "any":
952
- case "unknown":
953
- case "date":
954
- case "enum":
955
- case "literal":
956
- case "nan":
957
- case "promise":
958
- case "custom":
959
- case "template-literal":
960
- case "transform":
961
- case "file":
962
- return [];
963
- default: {
964
- const _exhaustive = kind;
965
- throw new Error(`walkSegments: unhandled ZodKind '${_exhaustive}'`);
966
- }
967
- }
754
+ return walkPathSegments(
755
+ schema,
756
+ pathString.split(PATH_SEPARATOR),
757
+ V4_INTROSPECTOR,
758
+ maxRecursionDepth,
759
+ 0
760
+ );
968
761
  }
969
762
 
970
763
  function carryChecks(rebuilt, original, stripConfig) {
@@ -1072,6 +865,9 @@ function stripRefinements(schema) {
1072
865
  case "template-literal":
1073
866
  case "transform":
1074
867
  case "file":
868
+ case "map":
869
+ case "symbol":
870
+ case "function":
1075
871
  return schema;
1076
872
  default: {
1077
873
  const _exhaustive = kind;
@@ -1197,6 +993,9 @@ function stripAsyncChecks(schema) {
1197
993
  case "template-literal":
1198
994
  case "transform":
1199
995
  case "file":
996
+ case "map":
997
+ case "symbol":
998
+ case "function":
1200
999
  return s;
1201
1000
  default: {
1202
1001
  const _exhaustive = kind;
@@ -1318,6 +1117,9 @@ function walkSlim(schema, stripConfig, maxDepth, lazyDepth) {
1318
1117
  case "promise":
1319
1118
  case "custom":
1320
1119
  case "template-literal":
1120
+ case "map":
1121
+ case "symbol":
1122
+ case "function":
1321
1123
  return schema;
1322
1124
  case "lazy": {
1323
1125
  if (lazyDepth >= maxDepth) return schema;
@@ -1351,159 +1153,17 @@ function walkSlim(schema, stripConfig, maxDepth, lazyDepth) {
1351
1153
  }
1352
1154
  }
1353
1155
 
1354
- function hasDeclaredDefaultInChain(schema) {
1355
- let current = schema;
1356
- for (let i = 0; i < 32; i++) {
1357
- if (current === void 0) return false;
1358
- const k = kindOf(current);
1359
- if (k === "default") return true;
1360
- if (k === "optional" || k === "nullable" || k === "readonly" || k === "catch") {
1361
- current = unwrapInner(current);
1362
- continue;
1363
- }
1364
- return false;
1365
- }
1366
- return false;
1367
- }
1368
1156
  function deriveDefault(schema, useDefault, maxRecursionDepth) {
1369
- return defaultForKind(kindOf(schema), schema, useDefault, maxRecursionDepth, 0);
1370
- }
1371
- function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
1372
- if (isCoercePrimitive(schema)) return void 0;
1373
- switch (kind) {
1374
- case "object": {
1375
- const shape = getObjectShape(schema);
1376
- const out = {};
1377
- for (const [key, subSchema] of Object.entries(shape)) {
1378
- out[key] = defaultForKind(kindOf(subSchema), subSchema, useDefault, maxDepth, lazyDepth);
1379
- }
1380
- return out;
1381
- }
1382
- case "default": {
1383
- if (useDefault) return getDefaultValue(schema);
1384
- const inner = unwrapInner(schema);
1385
- return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1386
- }
1387
- case "optional":
1388
- return void 0;
1389
- case "nullable":
1390
- return null;
1391
- case "readonly": {
1392
- const inner = unwrapInner(schema);
1393
- return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1394
- }
1395
- case "pipe": {
1396
- const inn = unwrapPipeIn(schema);
1397
- if (inn !== void 0 && kindOf(inn) === "transform") {
1398
- const out2 = unwrapPipeOut(schema);
1399
- if (out2 !== void 0 && hasDeclaredDefaultInChain(out2)) {
1400
- return defaultForKind(kindOf(out2), out2, useDefault, maxDepth, lazyDepth);
1401
- }
1402
- return void 0;
1403
- }
1404
- const out = unwrapPipeOut(schema);
1405
- const real = inn !== void 0 && kindOf(inn) !== "transform" ? inn : out !== void 0 && kindOf(out) !== "transform" ? out : inn ?? out;
1406
- return real === void 0 ? void 0 : defaultForKind(kindOf(real), real, useDefault, maxDepth, lazyDepth);
1407
- }
1408
- case "array":
1409
- return [];
1410
- case "set":
1411
- return /* @__PURE__ */ new Set();
1412
- case "record":
1413
- return {};
1414
- case "tuple": {
1415
- const items = getTupleItems(schema);
1416
- return items.map(
1417
- (item) => defaultForKind(kindOf(item), item, useDefault, maxDepth, lazyDepth)
1418
- );
1419
- }
1420
- case "union": {
1421
- const options = getUnionOptions(schema);
1422
- const first = options[0];
1423
- return first === void 0 ? void 0 : defaultForKind(kindOf(first), first, useDefault, maxDepth, lazyDepth);
1424
- }
1425
- case "discriminated-union": {
1426
- const first = getDiscriminatedUnionFirstOption(schema);
1427
- return first === void 0 ? void 0 : defaultForKind(kindOf(first), first, useDefault, maxDepth, lazyDepth);
1428
- }
1429
- case "string":
1430
- return "";
1431
- case "number":
1432
- return 0;
1433
- case "bigint":
1434
- return 0n;
1435
- case "boolean":
1436
- return false;
1437
- case "date":
1438
- return /* @__PURE__ */ new Date(0);
1439
- case "null":
1440
- return null;
1441
- case "undefined":
1442
- return void 0;
1443
- case "enum": {
1444
- const values = getEnumValues(schema);
1445
- return values[0];
1446
- }
1447
- case "literal": {
1448
- const values = getLiteralValues(schema);
1449
- return values[0];
1450
- }
1451
- case "nan":
1452
- return NaN;
1453
- case "lazy": {
1454
- if (lazyDepth >= maxDepth) return void 0;
1455
- let inner;
1456
- try {
1457
- inner = unwrapLazy(schema);
1458
- } catch {
1459
- return void 0;
1460
- }
1461
- return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth + 1);
1462
- }
1463
- case "intersection": {
1464
- const left = getIntersectionLeft(schema);
1465
- const right = getIntersectionRight(schema);
1466
- const l = left === void 0 ? void 0 : defaultForKind(kindOf(left), left, useDefault, maxDepth, lazyDepth);
1467
- const r = right === void 0 ? void 0 : defaultForKind(kindOf(right), right, useDefault, maxDepth, lazyDepth);
1468
- return mergeDeep(l, r);
1469
- }
1470
- case "catch": {
1471
- if (useDefault) return getCatchDefault(schema);
1472
- const inner = unwrapInner(schema);
1473
- return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1474
- }
1475
- case "any":
1476
- case "unknown":
1477
- case "void":
1478
- case "never":
1479
- case "promise":
1480
- case "custom":
1481
- case "template-literal":
1482
- case "transform":
1483
- return void 0;
1484
- case "file":
1485
- return null;
1486
- default: {
1487
- const _exhaustive = kind;
1488
- throw new Error(`deriveDefault: unhandled ZodKind '${_exhaustive}'`);
1489
- }
1490
- }
1491
- }
1492
- function mergeDeep(base, override) {
1493
- if (override === void 0) return base;
1494
- if (!isPlainRecord(override)) return override;
1495
- if (!isPlainRecord(base)) return override;
1496
- const result = { ...base };
1497
- for (const key of Object.keys(override)) {
1498
- const oVal = override[key];
1499
- const bVal = base[key];
1500
- if (isPlainRecord(oVal) && isPlainRecord(bVal)) {
1501
- result[key] = mergeDeep(bVal, oVal);
1502
- } else {
1503
- result[key] = oVal;
1504
- }
1505
- }
1506
- return result;
1157
+ return deriveDefaultWalk(schema, useDefault, V4_INTROSPECTOR, maxRecursionDepth, {
1158
+ // v4 has an exhaustive switch against `SchemaIntrospector.kindOf`;
1159
+ // unknown kinds genuinely shouldn't appear, so return undefined.
1160
+ unsupportedKindFallback: () => void 0,
1161
+ // v4 historically recurses into the inner on `useDefault=false`
1162
+ // so a `.catch(v)` slot returns the leaf empty rather than the
1163
+ // fallback. Pinned by `test/adapters/zod-v4/unsupported-kinds.test.ts`
1164
+ // (`z.catch falls through to inner leaf default when useDefault=false`).
1165
+ catchOnUseDefaultFalse: "recurseInner"
1166
+ });
1507
1167
  }
1508
1168
  function getDefaultValuesFromZodSchema(opts) {
1509
1169
  const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts;
@@ -1571,7 +1231,6 @@ function defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursion
1571
1231
  return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth);
1572
1232
  }
1573
1233
 
1574
- const PATH_SEPARATOR = ".";
1575
1234
  function unwrapStructuralWrappers(schema) {
1576
1235
  let current = schema;
1577
1236
  for (let i = 0; i < 64; i++) {
@@ -1658,297 +1317,99 @@ function isLeafRequired(schema, depth = 0) {
1658
1317
  function zodV4Adapter(rootSchema) {
1659
1318
  assertZodVersion(rootSchema);
1660
1319
  assertSupportedKinds(rootSchema);
1661
- return (formKey, options) => {
1662
- const maxRecursionDepth = options.maxRecursionDepth;
1663
- const leafCache = /* @__PURE__ */ new Map();
1664
- const preprocessOrCoerceCache = /* @__PURE__ */ new Map();
1665
- let asyncValidationFlag = null;
1320
+ return (formKey, options) => createAbstractSchema(
1321
+ rootSchema,
1322
+ V4_INTROSPECTOR,
1323
+ buildV4Services(),
1324
+ formKey,
1325
+ options
1326
+ );
1327
+ }
1328
+ function buildV4Services() {
1329
+ return {
1330
+ fingerprint: (schema) => fingerprintZodSchema(schema),
1331
+ getNestedSchemasAtPath: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
1332
+ // v4 doesn't pre-strip for the slim-mode walk — its path walker
1333
+ // already peels every transparent wrapper inline, so the slim and
1334
+ // unstripped walks coincide.
1335
+ getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
1336
+ slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),
1337
+ deriveDefault: (schema, useDefault, maxRecursionDepth) => deriveDefault(schema, useDefault, maxRecursionDepth),
1338
+ runStrictGetDefaults: (schema, config, fk, maxRecursionDepth) => runStrictGetDefaultsV4(schema, config, fk, maxRecursionDepth),
1339
+ unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),
1340
+ unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
1341
+ peelAllWrappers: (schema) => peelAllWrappers(schema),
1342
+ isLeafRequired: (schema) => isLeafRequired(schema),
1343
+ resolveFieldMetaAtPath: (schema, path, maxRecursionDepth) => resolveFieldMetaAtPath(schema, path, maxRecursionDepth),
1344
+ issuesToValidationErrors: (issues, fk) => zodIssuesToValidationErrors(issues, fk),
1345
+ safeParseSync: (schema, data) => {
1346
+ const result = schema.safeParse(data);
1347
+ return result.success ? { success: true, data: result.data } : { success: false, issues: result.error.issues };
1348
+ },
1349
+ safeParseAsync: async (schema, data) => {
1350
+ const result = await schema.safeParseAsync(data);
1351
+ return result.success ? { success: true, data: result.data } : { success: false, issues: result.error.issues };
1352
+ },
1353
+ makeSubSchema: (schema, fk, maxRecursionDepth) => buildSubSchemaStubV4(schema, fk, maxRecursionDepth)
1354
+ };
1355
+ }
1356
+ function runStrictGetDefaultsV4(rootSchema, config, formKey, maxRecursionDepth) {
1357
+ const { data } = getDefaultValuesFromZodSchema({
1358
+ schema: rootSchema,
1359
+ useDefaultSchemaValues: config.useDefaultSchemaValues,
1360
+ constraints: config.constraints,
1361
+ maxRecursionDepth
1362
+ });
1363
+ if (config.strict === false) {
1364
+ return { data, errors: void 0, success: true, formKey };
1365
+ }
1366
+ if (containsAsyncTransform(rootSchema)) {
1367
+ return { data, errors: void 0, success: true, formKey };
1368
+ }
1369
+ const parseTarget = containsAsyncRefine(rootSchema) ? stripAsyncChecks(rootSchema) : rootSchema;
1370
+ try {
1371
+ const strictResult = parseTarget.safeParse(data);
1372
+ if (strictResult.success) {
1373
+ return { data, errors: void 0, success: true, formKey };
1374
+ }
1666
1375
  return {
1667
- fingerprint: () => fingerprintZodSchema(rootSchema),
1668
- needsAsyncValidation() {
1669
- asyncValidationFlag ?? (asyncValidationFlag = containsAsyncRefine(rootSchema) || containsAsyncTransform(rootSchema));
1670
- return asyncValidationFlag;
1671
- },
1672
- getDefaultValues(config) {
1673
- const { data } = getDefaultValuesFromZodSchema({
1674
- schema: rootSchema,
1675
- useDefaultSchemaValues: config.useDefaultSchemaValues,
1676
- constraints: config.constraints,
1677
- maxRecursionDepth
1678
- });
1679
- if (config.strict !== false) {
1680
- if (containsAsyncTransform(rootSchema)) {
1681
- return { data, errors: void 0, success: true, formKey };
1682
- }
1683
- const parseTarget = containsAsyncRefine(rootSchema) ? stripAsyncChecks(rootSchema) : rootSchema;
1684
- try {
1685
- const strictResult = parseTarget.safeParse(
1686
- data
1687
- );
1688
- if (strictResult.success) {
1689
- return { data, errors: void 0, success: true, formKey };
1690
- }
1691
- return {
1692
- data,
1693
- errors: zodIssuesToValidationErrors(strictResult.error.issues, formKey),
1694
- success: false,
1695
- formKey
1696
- };
1697
- } catch {
1698
- return { data, errors: void 0, success: true, formKey };
1699
- }
1700
- }
1701
- return { data, errors: void 0, success: true, formKey };
1702
- },
1703
- getDefaultAtPath(path) {
1704
- if (path.length === 0) return deriveDefault(rootSchema, true, maxRecursionDepth);
1705
- const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1706
- if (first === void 0) return void 0;
1707
- return deriveDefault(unwrapStructuralWrappers(first), true, maxRecursionDepth);
1708
- },
1709
- getEmptyValueAtPath(path) {
1710
- if (path.length === 0) return deriveDefault(rootSchema, false, maxRecursionDepth);
1711
- const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1712
- if (first === void 0) return void 0;
1713
- return deriveDefault(first, false, maxRecursionDepth);
1714
- },
1715
- arrayShapeAtPath(path) {
1716
- if (path.length === 0) return void 0;
1717
- const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1718
- if (first === void 0) return void 0;
1719
- const peeled = peelAllWrappers(first);
1720
- const kind = kindOf(peeled);
1721
- if (kind === "tuple") return getTupleItems(peeled).length;
1722
- if (kind === "array") return null;
1723
- return void 0;
1724
- },
1725
- getSchemasAtPath(path) {
1726
- const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1727
- return resolved.map(
1728
- (schema) => ({
1729
- fingerprint: () => fingerprintZodSchema(schema),
1730
- needsAsyncValidation: () => containsAsyncRefine(schema),
1731
- getDefaultValues: () => ({
1732
- data: deriveDefault(schema, true, maxRecursionDepth),
1733
- errors: void 0,
1734
- success: true,
1735
- formKey
1736
- }),
1737
- getSchemasAtPath: () => [],
1738
- validateAtPath: async (data) => {
1739
- const result = await schema.safeParseAsync(data);
1740
- if (result.success) {
1741
- return { data: result.data, errors: void 0, success: true, formKey };
1742
- }
1743
- return {
1744
- data: void 0,
1745
- errors: zodIssuesToValidationErrors(result.error.issues, formKey),
1746
- success: false,
1747
- formKey
1748
- };
1749
- }
1750
- })
1751
- );
1752
- },
1753
- getSlimPrimitiveTypesAtPath(path) {
1754
- if (path.length === 0) return /* @__PURE__ */ new Set(["object"]);
1755
- const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1756
- if (resolved.length === 0) return /* @__PURE__ */ new Set();
1757
- const out = /* @__PURE__ */ new Set();
1758
- for (const candidate of resolved) {
1759
- for (const k of slimPrimitivesOf(candidate, maxRecursionDepth)) out.add(k);
1760
- }
1761
- return out;
1762
- },
1763
- isLeafAtPath(path) {
1764
- const cacheKey = canonicalizePath(path).key;
1765
- const cached = leafCache.get(cacheKey);
1766
- if (cached !== void 0) return cached;
1767
- const prim = this.getSlimPrimitiveTypesAtPath(path);
1768
- const isLeaf = prim.size > 0 && !prim.has("object") && !prim.has("array") && !prim.has("map") && !prim.has("set");
1769
- leafCache.set(cacheKey, isLeaf);
1770
- return isLeaf;
1771
- },
1772
- isPreprocessOrCoerceLeaf(path) {
1773
- const cacheKey = canonicalizePath(path).key;
1774
- const cached = preprocessOrCoerceCache.get(cacheKey);
1775
- if (cached !== void 0) return cached;
1776
- let hit = false;
1777
- for (let i = 0; i <= path.length && !hit; i++) {
1778
- const prefix = path.slice(0, i);
1779
- const candidates = prefix.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, prefix, maxRecursionDepth);
1780
- for (const candidate of candidates) {
1781
- if (isCoercePrimitive(candidate)) {
1782
- hit = true;
1783
- break;
1784
- }
1785
- if (kindOf(candidate) !== "pipe") continue;
1786
- const pipeIn = unwrapPipeIn(candidate);
1787
- if (pipeIn !== void 0 && kindOf(pipeIn) === "transform") {
1788
- hit = true;
1789
- break;
1790
- }
1791
- }
1792
- }
1793
- preprocessOrCoerceCache.set(cacheKey, hit);
1794
- return hit;
1795
- },
1796
- isRequiredAtPath(path) {
1797
- if (path.length === 0) return true;
1798
- const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1799
- if (resolved.length === 0) return false;
1800
- return resolved.every((candidate) => isLeafRequired(candidate));
1801
- },
1802
- getFieldMetaAtPath(path) {
1803
- return resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth);
1804
- },
1805
- getUnionDiscriminatorAtPath(path) {
1806
- const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1807
- let matchedUnion;
1808
- for (const candidate of candidates) {
1809
- const du = unwrapToDiscriminatedUnion(candidate);
1810
- if (du === void 0) continue;
1811
- if (matchedUnion !== void 0 && matchedUnion !== du) return void 0;
1812
- matchedUnion = du;
1813
- }
1814
- if (matchedUnion === void 0) return void 0;
1815
- const discKey = getDiscriminator(matchedUnion);
1816
- if (discKey === void 0) return void 0;
1817
- const options2 = getDiscriminatedOptions(matchedUnion);
1818
- const literalSet = /* @__PURE__ */ new Set();
1819
- for (const opt of options2) {
1820
- const shape = getObjectShape(opt);
1821
- const litSchema = shape[discKey];
1822
- if (litSchema === void 0) continue;
1823
- if (kindOf(litSchema) !== "literal") continue;
1824
- for (const v of getLiteralValues(litSchema)) literalSet.add(v);
1825
- }
1376
+ data,
1377
+ errors: zodIssuesToValidationErrors(strictResult.error.issues, formKey),
1378
+ success: false,
1379
+ formKey
1380
+ };
1381
+ } catch {
1382
+ return { data, errors: void 0, success: true, formKey };
1383
+ }
1384
+ }
1385
+ function buildSubSchemaStubV4(schema, formKey, maxRecursionDepth) {
1386
+ return {
1387
+ fingerprint: () => fingerprintZodSchema(schema),
1388
+ needsAsyncValidation: () => containsAsyncRefine(schema),
1389
+ getDefaultValues: () => ({
1390
+ data: deriveDefault(schema, true, maxRecursionDepth),
1391
+ errors: void 0,
1392
+ success: true,
1393
+ formKey
1394
+ }),
1395
+ getSchemasAtPath: () => [],
1396
+ validateAtPath: async (data) => {
1397
+ const result = await schema.safeParseAsync(data);
1398
+ if (result.success) {
1826
1399
  return {
1827
- discriminatorKey: discKey,
1828
- getVariantDefault(value) {
1829
- for (const opt of options2) {
1830
- const shape = getObjectShape(opt);
1831
- const litSchema = shape[discKey];
1832
- if (litSchema === void 0) continue;
1833
- if (kindOf(litSchema) !== "literal") continue;
1834
- const literalValues = getLiteralValues(litSchema);
1835
- if (literalValues.includes(value)) return deriveDefault(opt, true, maxRecursionDepth);
1836
- }
1837
- return void 0;
1838
- },
1839
- isVariantSelected(value) {
1840
- return literalSet.has(value);
1841
- }
1400
+ data: result.data,
1401
+ errors: void 0,
1402
+ success: true,
1403
+ formKey
1842
1404
  };
1843
- },
1844
- validateAtPath(data, path, options2) {
1845
- const trySync = options2?.sync === true;
1846
- if (trySync) {
1847
- try {
1848
- return runSync();
1849
- } catch {
1850
- }
1851
- }
1852
- return runAsync();
1853
- function runSync() {
1854
- if (path === void 0) {
1855
- const result = rootSchema.safeParse(data);
1856
- return result.success ? { data: result.data, errors: void 0, success: true, formKey } : {
1857
- data: void 0,
1858
- errors: zodIssuesToValidationErrors(result.error.issues, formKey),
1859
- success: false,
1860
- formKey
1861
- };
1862
- }
1863
- const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1864
- if (resolved.length === 0) return pathNotFound(path);
1865
- const aggregated = [];
1866
- for (const candidate of resolved) {
1867
- const result = candidate.safeParse(data);
1868
- if (result.success) {
1869
- return {
1870
- data: result.data,
1871
- errors: void 0,
1872
- success: true,
1873
- formKey
1874
- };
1875
- }
1876
- aggregated.push(...zodIssuesToValidationErrors(result.error.issues, formKey));
1877
- }
1878
- return { data: void 0, errors: aggregated, success: false, formKey };
1879
- }
1880
- async function runAsync() {
1881
- if (path === void 0) {
1882
- let result;
1883
- try {
1884
- result = await rootSchema.safeParseAsync(
1885
- data
1886
- );
1887
- } catch (err) {
1888
- return validatorThrewResponse(err, []);
1889
- }
1890
- return result.success ? { data: result.data, errors: void 0, success: true, formKey } : {
1891
- data: void 0,
1892
- errors: zodIssuesToValidationErrors(result.error.issues, formKey),
1893
- success: false,
1894
- formKey
1895
- };
1896
- }
1897
- const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1898
- if (resolved.length === 0) return pathNotFound(path);
1899
- const aggregated = [];
1900
- for (const candidate of resolved) {
1901
- let result;
1902
- try {
1903
- result = await candidate.safeParseAsync(data);
1904
- } catch (err) {
1905
- return validatorThrewResponse(err, path);
1906
- }
1907
- if (result.success) {
1908
- return {
1909
- data: result.data,
1910
- errors: void 0,
1911
- success: true,
1912
- formKey
1913
- };
1914
- }
1915
- aggregated.push(...zodIssuesToValidationErrors(result.error.issues, formKey));
1916
- }
1917
- return { data: void 0, errors: aggregated, success: false, formKey };
1918
- }
1919
- function validatorThrewResponse(err, errPath) {
1920
- const message = err instanceof Error ? err.message : typeof err === "string" ? err : "Validator threw";
1921
- return {
1922
- data: void 0,
1923
- errors: [
1924
- {
1925
- message,
1926
- path: [...errPath],
1927
- formKey,
1928
- code: AttaformErrorCode.ValidatorThrew
1929
- }
1930
- ],
1931
- success: false,
1932
- formKey
1933
- };
1934
- }
1935
- function pathNotFound(p) {
1936
- return {
1937
- data: void 0,
1938
- errors: [
1939
- {
1940
- message: `Path '${p.join(PATH_SEPARATOR)}' did not resolve to any schema`,
1941
- path: [...p],
1942
- formKey,
1943
- code: AttaformErrorCode.PathNotFound
1944
- }
1945
- ],
1946
- success: false,
1947
- formKey
1948
- };
1949
- }
1950
1405
  }
1951
- };
1406
+ return {
1407
+ data: void 0,
1408
+ errors: zodIssuesToValidationErrors(result.error.issues, formKey),
1409
+ success: false,
1410
+ formKey
1411
+ };
1412
+ }
1952
1413
  };
1953
1414
  }
1954
1415
  const pathMetaCache = /* @__PURE__ */ new WeakMap();
@@ -2106,6 +1567,9 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress)
2106
1567
  case "template-literal":
2107
1568
  case "transform":
2108
1569
  case "file":
1570
+ case "map":
1571
+ case "symbol":
1572
+ case "function":
2109
1573
  return;
2110
1574
  }
2111
1575
  } finally {
@@ -2164,4 +1628,4 @@ function useForm(configuration) {
2164
1628
  }
2165
1629
 
2166
1630
  export { UnsupportedSchemaError as U, assertZodVersion as a, fieldMeta as f, kindOf as k, useForm as u, withMeta as w, zodV4Adapter as z };
2167
- //# sourceMappingURL=attaform.-1GQTX2T.mjs.map
1631
+ //# sourceMappingURL=attaform.DEBvCjeH.mjs.map