attaform 0.27.5 → 0.28.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/dist/abstract.d.mts +5 -4
- package/dist/abstract.mjs +4 -3
- package/dist/chunks/fingerprint.mjs +0 -1
- package/dist/chunks/fingerprint2.mjs +1 -2
- package/dist/dev/abstract.mjs +4 -0
- package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
- package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
- package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
- package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
- package/dist/dev/directive.mjs +1 -0
- package/dist/dev/history.mjs +89 -0
- package/dist/dev/index.mjs +5 -0
- package/dist/dev/runtime/plugins/attaform.mjs +40 -0
- package/dist/{shared/attaform.f2zyNh5d.cjs → dev/shared/attaform-dev.6qxD-Yqo.mjs} +187 -43
- package/dist/{shared/attaform.CQN9R62B.cjs → dev/shared/attaform-dev.BJGA_UOS.mjs} +1 -4
- package/dist/{shared/attaform.Dc1mx48r.mjs → dev/shared/attaform-dev.BR8u0YOZ.mjs} +6 -7
- package/dist/dev/shared/attaform-dev.BXE2cr0L.mjs +220 -0
- package/dist/dev/shared/attaform-dev.By4PRjt0.mjs +248 -0
- package/dist/{shared/attaform.Cg_8gFQ7.mjs → dev/shared/attaform-dev.D2I8e_Mm.mjs} +132 -568
- package/dist/dev/shared/attaform-dev.Dr2YzS5B.mjs +197 -0
- package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.P7cseiEG.mjs} +178 -397
- package/dist/{shared/attaform.BypWgXRB.mjs → dev/shared/attaform-dev.WmuhD_CZ.mjs} +3955 -5029
- package/dist/{shared/attaform.Dkjh_F30.mjs → dev/shared/attaform-dev.oYrkP9dj.mjs} +160 -508
- package/dist/dev/zod-v3.mjs +17 -0
- package/dist/dev/zod-v4.mjs +16 -0
- package/dist/dev/zod.mjs +5 -0
- package/dist/directive.d.mts +20 -0
- package/dist/directive.mjs +1 -0
- package/dist/esbuild.mjs +0 -1
- package/dist/history.d.mts +59 -0
- package/dist/history.mjs +89 -0
- package/dist/index.d.mts +11 -5
- package/dist/index.mjs +5 -4
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.mjs +5 -2
- package/dist/rollup.mjs +0 -1
- package/dist/rspack.d.mts +6 -1
- package/dist/rspack.mjs +0 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
- package/dist/runtime/plugins/attaform.mjs +1 -2
- package/dist/shared/{attaform.CIBMfxg9.d.ts → attaform.B4VkS43-.d.mts} +2 -2
- package/dist/shared/{attaform.Cg1rUfcF.cjs → attaform.B8k8JrmK.mjs} +3778 -5297
- package/dist/shared/attaform.BJGA_UOS.mjs +0 -1
- package/dist/shared/{attaform.CTiZ9Rrv.mjs → attaform.C09fpdLS.mjs} +172 -16
- package/dist/shared/{attaform.Bh8A6YAc.cjs → attaform.CJP3RkGa.mjs} +141 -590
- package/dist/shared/{attaform.CzL2CZ8U.d.ts → attaform.Cgu-hdSb.d.mts} +328 -78
- package/dist/shared/attaform.Cs2Rbdlo.mjs +0 -1
- package/dist/shared/{attaform.DcFDQVpa.d.ts → attaform.D5V4tZWq.d.mts} +79 -179
- package/dist/shared/{attaform.CF-EnyJn.cjs → attaform.D6DCnnQu.mjs} +11 -16
- package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
- package/dist/shared/attaform.Dq4vWxuG.mjs +197 -0
- package/dist/shared/attaform.JfSWdEcb.d.mts +44 -0
- package/dist/shared/attaform.KvlEedlF.mjs +0 -1
- package/dist/shared/{attaform.Crv0RNiz.cjs → attaform.NLmerepI.mjs} +175 -557
- package/dist/shared/attaform.h0i6LijT.mjs +242 -0
- package/dist/shared/{attaform.Biytrv0-.cjs → attaform.uLbun31C.mjs} +204 -544
- package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
- package/dist/shared/attaform.wfY8XFvm.mjs +197 -0
- package/dist/transforms.mjs +0 -1
- package/dist/vite.d.mts +17 -5
- package/dist/vite.mjs +24 -2
- package/dist/webpack.d.mts +6 -1
- package/dist/webpack.mjs +0 -1
- package/dist/zod-v3.d.mts +11 -6
- package/dist/zod-v3.mjs +17 -4
- package/dist/zod-v4.d.mts +12 -6
- package/dist/zod-v4.mjs +16 -4
- package/dist/zod.d.mts +4 -3
- package/dist/zod.mjs +5 -4
- package/package.json +23 -8
- package/skills/attaform/SKILL.md +2 -1
- package/dist/abstract.cjs +0 -48
- package/dist/abstract.cjs.map +0 -1
- package/dist/abstract.d.cts +0 -42
- package/dist/abstract.d.ts +0 -42
- package/dist/abstract.mjs.map +0 -1
- package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
- package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
- package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
- package/dist/chunks/devtools.cjs +0 -157
- package/dist/chunks/devtools.cjs.map +0 -1
- package/dist/chunks/devtools.mjs.map +0 -1
- package/dist/chunks/fingerprint.cjs.map +0 -1
- package/dist/chunks/fingerprint.mjs.map +0 -1
- package/dist/chunks/fingerprint2.cjs.map +0 -1
- package/dist/chunks/fingerprint2.mjs.map +0 -1
- package/dist/esbuild.cjs +0 -28
- package/dist/esbuild.cjs.map +0 -1
- package/dist/esbuild.d.cts +0 -56
- package/dist/esbuild.d.ts +0 -56
- package/dist/esbuild.mjs.map +0 -1
- package/dist/index.cjs +0 -51
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -249
- package/dist/index.d.ts +0 -249
- package/dist/index.mjs.map +0 -1
- package/dist/nuxt.cjs +0 -84
- package/dist/nuxt.cjs.map +0 -1
- package/dist/nuxt.d.cts +0 -66
- package/dist/nuxt.d.ts +0 -66
- package/dist/nuxt.mjs.map +0 -1
- package/dist/rollup.cjs +0 -24
- package/dist/rollup.cjs.map +0 -1
- package/dist/rollup.d.cts +0 -35
- package/dist/rollup.d.ts +0 -35
- package/dist/rollup.mjs.map +0 -1
- package/dist/rspack.cjs +0 -10
- package/dist/rspack.cjs.map +0 -1
- package/dist/rspack.d.cts +0 -40
- package/dist/rspack.d.ts +0 -40
- package/dist/rspack.mjs.map +0 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
- package/dist/runtime/plugins/attaform.cjs +0 -43
- package/dist/runtime/plugins/attaform.cjs.map +0 -1
- package/dist/runtime/plugins/attaform.d.cts +0 -5
- package/dist/runtime/plugins/attaform.d.ts +0 -5
- package/dist/runtime/plugins/attaform.mjs.map +0 -1
- package/dist/shared/attaform.B3abZaCV.d.cts +0 -2484
- package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
- package/dist/shared/attaform.Bh8A6YAc.cjs.map +0 -1
- package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
- package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
- package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
- package/dist/shared/attaform.BypWgXRB.mjs.map +0 -1
- package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
- package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
- package/dist/shared/attaform.CF-EnyJn.cjs.map +0 -1
- package/dist/shared/attaform.CJ1Z9Mz4.d.mts +0 -2484
- package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
- package/dist/shared/attaform.CTiZ9Rrv.mjs.map +0 -1
- package/dist/shared/attaform.Cg1rUfcF.cjs.map +0 -1
- package/dist/shared/attaform.Cg_8gFQ7.mjs.map +0 -1
- package/dist/shared/attaform.Crv0RNiz.cjs.map +0 -1
- package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
- package/dist/shared/attaform.CzL2CZ8U.d.cts +0 -4713
- package/dist/shared/attaform.CzL2CZ8U.d.mts +0 -4713
- package/dist/shared/attaform.DRUT703x.d.cts +0 -56
- package/dist/shared/attaform.DRUT703x.d.ts +0 -56
- package/dist/shared/attaform.DYwyM5Cp.d.cts +0 -232
- package/dist/shared/attaform.Dc1mx48r.mjs.map +0 -1
- package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
- package/dist/shared/attaform.Dkjh_F30.mjs.map +0 -1
- package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
- package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
- package/dist/shared/attaform.DrHOqB-d.d.mts +0 -232
- package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
- package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
- package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
- package/dist/shared/attaform.f2zyNh5d.cjs.map +0 -1
- package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
- package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
- package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
- package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
- package/dist/transforms.cjs +0 -12
- package/dist/transforms.cjs.map +0 -1
- package/dist/transforms.d.cts +0 -73
- package/dist/transforms.d.ts +0 -73
- package/dist/transforms.mjs.map +0 -1
- package/dist/vite.cjs +0 -363
- package/dist/vite.cjs.map +0 -1
- package/dist/vite.d.cts +0 -133
- package/dist/vite.d.ts +0 -133
- package/dist/vite.mjs.map +0 -1
- package/dist/webpack.cjs +0 -10
- package/dist/webpack.cjs.map +0 -1
- package/dist/webpack.d.cts +0 -37
- package/dist/webpack.d.ts +0 -37
- package/dist/webpack.mjs.map +0 -1
- package/dist/zod-v3.cjs +0 -53
- package/dist/zod-v3.cjs.map +0 -1
- package/dist/zod-v3.d.cts +0 -246
- package/dist/zod-v3.d.ts +0 -246
- package/dist/zod-v3.mjs.map +0 -1
- package/dist/zod-v4.cjs +0 -55
- package/dist/zod-v4.cjs.map +0 -1
- package/dist/zod-v4.d.cts +0 -172
- package/dist/zod-v4.d.ts +0 -172
- package/dist/zod-v4.mjs.map +0 -1
- package/dist/zod.cjs +0 -51
- package/dist/zod.cjs.map +0 -1
- package/dist/zod.d.cts +0 -7
- package/dist/zod.d.ts +0 -7
- package/dist/zod.mjs.map +0 -1
|
@@ -1,58 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { s as slimPrimitivesWalk, c as createAbstractSchema, w as walkPathSegments, d as deriveDefaultWalk, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, m as mergeDeep, f as fixStructuralDefaults, a as getFieldMetaListForSchema } from './attaform.C09fpdLS.mjs';
|
|
2
|
+
import { o as humanize, h as useAbstractForm } from './attaform.B8k8JrmK.mjs';
|
|
3
|
+
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.wfY8XFvm.mjs';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const serializeScript = require('./attaform.Cg1rUfcF.cjs');
|
|
5
|
-
const devtoolsShared = require('./attaform.Biytrv0-.cjs');
|
|
6
|
-
|
|
7
|
-
const fieldMeta = walkFieldMeta.fieldMetaStore;
|
|
8
|
-
function withMeta(schema, payload) {
|
|
9
|
-
const existing = walkFieldMeta.getFieldMetaForSchema(schema) ?? {};
|
|
10
|
-
const Ctor = schema.constructor;
|
|
11
|
-
const cloned = new Ctor(schema._def);
|
|
12
|
-
walkFieldMeta.fieldMetaStore.add(cloned, { ...existing, ...payload });
|
|
13
|
-
return cloned;
|
|
14
|
-
}
|
|
15
|
-
function getFieldMeta(schema) {
|
|
16
|
-
return walkFieldMeta.getFieldMetaForSchema(schema);
|
|
17
|
-
}
|
|
18
|
-
function getFieldMetaList(schema) {
|
|
19
|
-
return walkFieldMeta.getFieldMetaListForSchema(schema);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function cloneSchemaDeep(value) {
|
|
23
|
-
return clone(value, /* @__PURE__ */ new WeakMap());
|
|
24
|
-
}
|
|
25
|
-
function clone(value, seen) {
|
|
26
|
-
if (value === null || typeof value !== "object") return value;
|
|
27
|
-
if (seen.has(value)) return seen.get(value);
|
|
28
|
-
if (value instanceof RegExp) {
|
|
29
|
-
const copy2 = new RegExp(value.source, value.flags);
|
|
30
|
-
copy2.lastIndex = value.lastIndex;
|
|
31
|
-
seen.set(value, copy2);
|
|
32
|
-
return copy2;
|
|
33
|
-
}
|
|
34
|
-
if (value instanceof Date) {
|
|
35
|
-
const copy2 = new Date(value.getTime());
|
|
36
|
-
seen.set(value, copy2);
|
|
37
|
-
return copy2;
|
|
38
|
-
}
|
|
39
|
-
if (Array.isArray(value)) {
|
|
40
|
-
const copy2 = [];
|
|
41
|
-
seen.set(value, copy2);
|
|
42
|
-
for (let i = 0; i < value.length; i++) {
|
|
43
|
-
copy2[i] = clone(value[i], seen);
|
|
44
|
-
}
|
|
45
|
-
return copy2;
|
|
46
|
-
}
|
|
47
|
-
const copy = Object.create(Object.getPrototypeOf(value));
|
|
48
|
-
seen.set(value, copy);
|
|
49
|
-
const source = value;
|
|
50
|
-
for (const key of Reflect.ownKeys(value)) {
|
|
51
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
52
|
-
if (descriptor?.enumerable !== true) continue;
|
|
53
|
-
copy[key] = clone(source[key], seen);
|
|
54
|
-
}
|
|
55
|
-
return copy;
|
|
5
|
+
class UnsupportedSchemaError extends AttaformError {
|
|
56
6
|
}
|
|
57
7
|
|
|
58
8
|
function isZodSchemaType(schema, expectedType) {
|
|
@@ -236,12 +186,15 @@ function isAsyncEffect(schema) {
|
|
|
236
186
|
return fn.constructor.name === "AsyncFunction";
|
|
237
187
|
}
|
|
238
188
|
function containsAsyncRefine(schema, seen) {
|
|
239
|
-
return
|
|
189
|
+
return walkForTarget(schema, "refinement", seen ?? /* @__PURE__ */ new WeakSet());
|
|
190
|
+
}
|
|
191
|
+
function containsDiscriminatedUnion(schema, seen) {
|
|
192
|
+
return walkForTarget(schema, "discriminated-union", seen ?? /* @__PURE__ */ new WeakSet());
|
|
240
193
|
}
|
|
241
194
|
function containsAsyncTransform(schema, seen) {
|
|
242
|
-
return
|
|
195
|
+
return walkForTarget(schema, "transform-or-preprocess", seen ?? /* @__PURE__ */ new WeakSet());
|
|
243
196
|
}
|
|
244
|
-
function
|
|
197
|
+
function walkForTarget(schema, target, visited) {
|
|
245
198
|
const candidate = schema;
|
|
246
199
|
if (typeof candidate !== "object" || candidate === null) return false;
|
|
247
200
|
if (visited.has(candidate)) return false;
|
|
@@ -253,66 +206,69 @@ function walkForAsync(schema, target, visited) {
|
|
|
253
206
|
return true;
|
|
254
207
|
}
|
|
255
208
|
const inner = unwrapEffectsSource(schema);
|
|
256
|
-
return inner !== void 0 &&
|
|
209
|
+
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
257
210
|
}
|
|
258
211
|
if (isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodCatch") || isZodSchemaType(schema, "ZodReadonly")) {
|
|
259
212
|
const inner = unwrapInner(schema);
|
|
260
|
-
return inner !== void 0 &&
|
|
213
|
+
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
261
214
|
}
|
|
262
215
|
if (isZodSchemaType(schema, "ZodBranded")) {
|
|
263
216
|
const inner = unwrapBranded(schema);
|
|
264
|
-
return inner !== void 0 &&
|
|
217
|
+
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
265
218
|
}
|
|
266
219
|
if (isZodSchemaType(schema, "ZodLazy")) {
|
|
267
220
|
const inner = unwrapLazy(schema);
|
|
268
|
-
return inner !== void 0 &&
|
|
221
|
+
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
269
222
|
}
|
|
270
223
|
if (isZodSchemaType(schema, "ZodPipeline")) {
|
|
271
224
|
const inSide = unwrapPipeIn(schema);
|
|
272
|
-
if (inSide !== void 0 &&
|
|
225
|
+
if (inSide !== void 0 && walkForTarget(inSide, target, visited)) return true;
|
|
273
226
|
const outSide = unwrapPipeOut(schema);
|
|
274
|
-
if (outSide !== void 0 &&
|
|
227
|
+
if (outSide !== void 0 && walkForTarget(outSide, target, visited)) return true;
|
|
275
228
|
return false;
|
|
276
229
|
}
|
|
277
230
|
if (isZodSchemaType(schema, "ZodObject")) {
|
|
278
231
|
for (const sub of Object.values(getObjectShape(schema))) {
|
|
279
|
-
if (
|
|
232
|
+
if (walkForTarget(sub, target, visited)) return true;
|
|
280
233
|
}
|
|
281
234
|
return false;
|
|
282
235
|
}
|
|
283
236
|
if (isZodSchemaType(schema, "ZodArray")) {
|
|
284
237
|
const elem = getArrayElement(schema);
|
|
285
|
-
return elem !== void 0 &&
|
|
238
|
+
return elem !== void 0 && walkForTarget(elem, target, visited);
|
|
286
239
|
}
|
|
287
240
|
if (isZodSchemaType(schema, "ZodTuple")) {
|
|
288
241
|
for (const it of getTupleItems(schema)) {
|
|
289
|
-
if (
|
|
242
|
+
if (walkForTarget(it, target, visited)) return true;
|
|
290
243
|
}
|
|
291
244
|
return false;
|
|
292
245
|
}
|
|
293
246
|
if (isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
|
|
247
|
+
if (target === "discriminated-union" && isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
294
250
|
for (const opt of getUnionOptions(schema)) {
|
|
295
|
-
if (
|
|
251
|
+
if (walkForTarget(opt, target, visited)) return true;
|
|
296
252
|
}
|
|
297
253
|
return false;
|
|
298
254
|
}
|
|
299
255
|
if (isZodSchemaType(schema, "ZodIntersection")) {
|
|
300
256
|
const left = getIntersectionLeft(schema);
|
|
301
|
-
if (left !== void 0 &&
|
|
257
|
+
if (left !== void 0 && walkForTarget(left, target, visited)) return true;
|
|
302
258
|
const right = getIntersectionRight(schema);
|
|
303
|
-
if (right !== void 0 &&
|
|
259
|
+
if (right !== void 0 && walkForTarget(right, target, visited)) return true;
|
|
304
260
|
return false;
|
|
305
261
|
}
|
|
306
262
|
if (isZodSchemaType(schema, "ZodRecord")) {
|
|
307
263
|
const keyType = getRecordKeyType(schema);
|
|
308
|
-
if (keyType !== void 0 &&
|
|
264
|
+
if (keyType !== void 0 && walkForTarget(keyType, target, visited)) return true;
|
|
309
265
|
const valueType = getRecordValueType(schema);
|
|
310
|
-
if (valueType !== void 0 &&
|
|
266
|
+
if (valueType !== void 0 && walkForTarget(valueType, target, visited)) return true;
|
|
311
267
|
return false;
|
|
312
268
|
}
|
|
313
269
|
if (isZodSchemaType(schema, "ZodSet")) {
|
|
314
270
|
const elem = getSetValueType(schema);
|
|
315
|
-
return elem !== void 0 &&
|
|
271
|
+
return elem !== void 0 && walkForTarget(elem, target, visited);
|
|
316
272
|
}
|
|
317
273
|
return false;
|
|
318
274
|
}
|
|
@@ -349,7 +305,7 @@ function getNativeEnumValues(schema) {
|
|
|
349
305
|
const def = readDef(schema);
|
|
350
306
|
return def?.values;
|
|
351
307
|
}
|
|
352
|
-
function getDefaultValue
|
|
308
|
+
function getDefaultValue(schema) {
|
|
353
309
|
const def = readDef(schema);
|
|
354
310
|
const thunk = def?.defaultValue;
|
|
355
311
|
if (typeof thunk !== "function") return void 0;
|
|
@@ -373,11 +329,6 @@ function hasCatchValue(schema) {
|
|
|
373
329
|
const def = readDef(schema);
|
|
374
330
|
return typeof def?.catchValue === "function";
|
|
375
331
|
}
|
|
376
|
-
function hasChecks(schema) {
|
|
377
|
-
const def = readDef(schema);
|
|
378
|
-
const checks = def?.checks;
|
|
379
|
-
return Array.isArray(checks) && checks.length > 0;
|
|
380
|
-
}
|
|
381
332
|
function hasContainerOrRootRefine(schema, seen) {
|
|
382
333
|
const visited = seen ?? /* @__PURE__ */ new WeakSet();
|
|
383
334
|
const candidate = schema;
|
|
@@ -473,71 +424,6 @@ function isContainerAfterWrapperPeel(schema) {
|
|
|
473
424
|
return isZodSchemaType(cur, "ZodObject") || isZodSchemaType(cur, "ZodArray") || isZodSchemaType(cur, "ZodTuple") || isZodSchemaType(cur, "ZodIntersection") || isZodSchemaType(cur, "ZodUnion") || isZodSchemaType(cur, "ZodDiscriminatedUnion") || isZodSchemaType(cur, "ZodRecord") || isZodSchemaType(cur, "ZodSet");
|
|
474
425
|
}
|
|
475
426
|
|
|
476
|
-
function rebuildWithDef(original, defPatch) {
|
|
477
|
-
const node = Object.create(Object.getPrototypeOf(original));
|
|
478
|
-
node._def = { ...original._def, ...defPatch };
|
|
479
|
-
return node;
|
|
480
|
-
}
|
|
481
|
-
function rebuildObject(original, shape) {
|
|
482
|
-
const node = rebuildWithDef(original, { shape: () => shape, unknownKeys: "strip" });
|
|
483
|
-
node._cached = null;
|
|
484
|
-
return node;
|
|
485
|
-
}
|
|
486
|
-
function rebuildArray(original, element) {
|
|
487
|
-
return rebuildWithDef(original, {
|
|
488
|
-
type: element,
|
|
489
|
-
minLength: null,
|
|
490
|
-
maxLength: null,
|
|
491
|
-
exactLength: null
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
function rebuildSet(original, valueType) {
|
|
495
|
-
return rebuildWithDef(original, {
|
|
496
|
-
valueType,
|
|
497
|
-
minSize: null,
|
|
498
|
-
maxSize: null
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
function rebuildRecord(original, valueType, keyType) {
|
|
502
|
-
const patch = { valueType };
|
|
503
|
-
if (keyType !== void 0) patch["keyType"] = keyType;
|
|
504
|
-
return rebuildWithDef(original, patch);
|
|
505
|
-
}
|
|
506
|
-
function rebuildTuple(original, items) {
|
|
507
|
-
return rebuildWithDef(original, { items, rest: null });
|
|
508
|
-
}
|
|
509
|
-
function rebuildUnion(original, options) {
|
|
510
|
-
return rebuildWithDef(original, { options });
|
|
511
|
-
}
|
|
512
|
-
function rebuildIntersection(original, left, right) {
|
|
513
|
-
return rebuildWithDef(original, { left, right });
|
|
514
|
-
}
|
|
515
|
-
function rebuildWrapperInner(original, inner) {
|
|
516
|
-
return rebuildWithDef(original, { innerType: inner });
|
|
517
|
-
}
|
|
518
|
-
function rebuildLazy(original, target) {
|
|
519
|
-
return rebuildWithDef(original, { getter: () => target });
|
|
520
|
-
}
|
|
521
|
-
function stripLeafChecks(original) {
|
|
522
|
-
return rebuildWithDef(original, { checks: [] });
|
|
523
|
-
}
|
|
524
|
-
function rebuildDiscriminatedUnion(original, options) {
|
|
525
|
-
const originalOptions = getDiscriminatedOptions(original);
|
|
526
|
-
const originalMap = getDiscriminatedOptionsMap(original);
|
|
527
|
-
const optionsMap = /* @__PURE__ */ new Map();
|
|
528
|
-
if (originalMap !== void 0) {
|
|
529
|
-
for (const [value, originalOption] of originalMap) {
|
|
530
|
-
const index = originalOptions.indexOf(originalOption);
|
|
531
|
-
const replacement = index >= 0 ? options[index] : void 0;
|
|
532
|
-
if (replacement !== void 0) optionsMap.set(value, replacement);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
return rebuildWithDef(original, { options, optionsMap });
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
class UnsupportedSchemaError extends devtoolsShared.AttaformError {
|
|
539
|
-
}
|
|
540
|
-
|
|
541
427
|
const UNSUPPORTED_TYPE_NAMES = /* @__PURE__ */ new Set(["ZodPromise", "ZodFunction", "ZodMap", "ZodSymbol"]);
|
|
542
428
|
function labelPath(path) {
|
|
543
429
|
return path.length === 0 ? "<root>" : path.join(".");
|
|
@@ -546,7 +432,7 @@ function assertSupportedKinds(schema, path = [], lazyGetters = []) {
|
|
|
546
432
|
const typeName = getTypeName(schema);
|
|
547
433
|
if (typeName !== void 0 && UNSUPPORTED_TYPE_NAMES.has(typeName)) {
|
|
548
434
|
throw new UnsupportedSchemaError(
|
|
549
|
-
`[attaform
|
|
435
|
+
`[attaform] AF02 attaform.dev/e/af02 '${typeName}' at '${labelPath(path)}'`
|
|
550
436
|
);
|
|
551
437
|
}
|
|
552
438
|
if (isZodSchemaType(schema, "ZodObject")) {
|
|
@@ -638,6 +524,7 @@ const V3_INTROSPECTOR = {
|
|
|
638
524
|
isCoercePrimitive,
|
|
639
525
|
containsAsyncRefine,
|
|
640
526
|
containsAsyncTransform,
|
|
527
|
+
containsDiscriminatedUnion,
|
|
641
528
|
hasContainerOrRootRefine,
|
|
642
529
|
// Walker accessors (D2 / D3 / D5).
|
|
643
530
|
getArrayElement,
|
|
@@ -659,13 +546,72 @@ const V3_INTROSPECTOR = {
|
|
|
659
546
|
unwrapPipeOut,
|
|
660
547
|
unwrapLazy,
|
|
661
548
|
getLazyGetter,
|
|
662
|
-
getDefaultValue
|
|
549
|
+
getDefaultValue,
|
|
663
550
|
getCatchDefault,
|
|
664
551
|
hasCatchValue
|
|
665
552
|
};
|
|
666
553
|
|
|
667
554
|
function slimPrimitivesV3(schema) {
|
|
668
|
-
return new Set(
|
|
555
|
+
return new Set(slimPrimitivesWalk(schema, V3_INTROSPECTOR, 64));
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function rebuildWithDef(original, defPatch) {
|
|
559
|
+
const node = Object.create(Object.getPrototypeOf(original));
|
|
560
|
+
node._def = { ...original._def, ...defPatch };
|
|
561
|
+
return node;
|
|
562
|
+
}
|
|
563
|
+
function rebuildObject(original, shape) {
|
|
564
|
+
const node = rebuildWithDef(original, { shape: () => shape, unknownKeys: "strip" });
|
|
565
|
+
node._cached = null;
|
|
566
|
+
return node;
|
|
567
|
+
}
|
|
568
|
+
function rebuildArray(original, element) {
|
|
569
|
+
return rebuildWithDef(original, {
|
|
570
|
+
type: element,
|
|
571
|
+
minLength: null,
|
|
572
|
+
maxLength: null,
|
|
573
|
+
exactLength: null
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
function rebuildSet(original, valueType) {
|
|
577
|
+
return rebuildWithDef(original, {
|
|
578
|
+
valueType,
|
|
579
|
+
minSize: null,
|
|
580
|
+
maxSize: null
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
function rebuildRecord(original, valueType, keyType) {
|
|
584
|
+
const patch = { valueType };
|
|
585
|
+
if (keyType !== void 0) patch["keyType"] = keyType;
|
|
586
|
+
return rebuildWithDef(original, patch);
|
|
587
|
+
}
|
|
588
|
+
function rebuildTuple(original, items) {
|
|
589
|
+
return rebuildWithDef(original, { items, rest: null });
|
|
590
|
+
}
|
|
591
|
+
function rebuildUnion(original, options) {
|
|
592
|
+
return rebuildWithDef(original, { options });
|
|
593
|
+
}
|
|
594
|
+
function rebuildIntersection(original, left, right) {
|
|
595
|
+
return rebuildWithDef(original, { left, right });
|
|
596
|
+
}
|
|
597
|
+
function rebuildWrapperInner(original, inner) {
|
|
598
|
+
return rebuildWithDef(original, { innerType: inner });
|
|
599
|
+
}
|
|
600
|
+
function rebuildLazy(original, target) {
|
|
601
|
+
return rebuildWithDef(original, { getter: () => target });
|
|
602
|
+
}
|
|
603
|
+
function rebuildDiscriminatedUnion(original, options) {
|
|
604
|
+
const originalOptions = getDiscriminatedOptions(original);
|
|
605
|
+
const originalMap = getDiscriminatedOptionsMap(original);
|
|
606
|
+
const optionsMap = /* @__PURE__ */ new Map();
|
|
607
|
+
if (originalMap !== void 0) {
|
|
608
|
+
for (const [value, originalOption] of originalMap) {
|
|
609
|
+
const index = originalOptions.indexOf(originalOption);
|
|
610
|
+
const replacement = index >= 0 ? options[index] : void 0;
|
|
611
|
+
if (replacement !== void 0) optionsMap.set(value, replacement);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return rebuildWithDef(original, { options, optionsMap });
|
|
669
615
|
}
|
|
670
616
|
|
|
671
617
|
function stripAsyncChecks(schema) {
|
|
@@ -690,7 +636,7 @@ function stripAsyncChecks(schema) {
|
|
|
690
636
|
if (isZodSchemaType(s, "ZodDefault")) {
|
|
691
637
|
const inner = unwrapInner(s);
|
|
692
638
|
if (inner === void 0) return s;
|
|
693
|
-
const def = getDefaultValue
|
|
639
|
+
const def = getDefaultValue(s);
|
|
694
640
|
return recurse(inner).default(def);
|
|
695
641
|
}
|
|
696
642
|
if (isZodSchemaType(s, "ZodCatch")) {
|
|
@@ -823,38 +769,17 @@ function carryObjectChecks(rebuilt, original) {
|
|
|
823
769
|
return next;
|
|
824
770
|
}
|
|
825
771
|
|
|
826
|
-
const PATH_SEPARATOR = ".";
|
|
827
772
|
const MAX_UNWRAP_STEPS = 64;
|
|
828
|
-
function isPrimitive(input) {
|
|
829
|
-
const type = typeof input;
|
|
830
|
-
if (type === "string" || type === "number" || type === "boolean" || type === "bigint" || type === "undefined")
|
|
831
|
-
return true;
|
|
832
|
-
return input === null;
|
|
833
|
-
}
|
|
834
|
-
function constraintsAreSlimValid(slimSchema, constraints) {
|
|
835
|
-
try {
|
|
836
|
-
return slimSchema.safeParse(constraints).success;
|
|
837
|
-
} catch {
|
|
838
|
-
return false;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
let warnedZodCodeMissing = false;
|
|
842
773
|
function zodAdapter(zodSchema) {
|
|
843
774
|
assertSupportedKinds(zodSchema);
|
|
844
|
-
const
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
stripOptional: true,
|
|
848
|
-
stripZodEffects: true,
|
|
849
|
-
stripZodRefinements: true
|
|
850
|
-
});
|
|
851
|
-
if (!isZodSchemaType(_strippedRoot, "ZodObject") && !isZodSchemaType(_strippedRoot, "ZodRecord") && !isZodSchemaType(_strippedRoot, "ZodDiscriminatedUnion")) {
|
|
852
|
-
const name = getTypeName(_strippedRoot);
|
|
775
|
+
const peeledRoot = peelAllV3Wrappers(zodSchema);
|
|
776
|
+
if (!isZodSchemaType(peeledRoot, "ZodObject") && !isZodSchemaType(peeledRoot, "ZodRecord") && !isZodSchemaType(peeledRoot, "ZodDiscriminatedUnion")) {
|
|
777
|
+
const name = getTypeName(peeledRoot);
|
|
853
778
|
throw new Error(
|
|
854
779
|
`Attaform: useForm schema root must be a ZodObject, ZodRecord, or ZodDiscriminatedUnion (got ${name}). Wrap other shapes under a key.`
|
|
855
780
|
);
|
|
856
781
|
}
|
|
857
|
-
return (formKey, options) =>
|
|
782
|
+
return (formKey, options) => createAbstractSchema(
|
|
858
783
|
zodSchema,
|
|
859
784
|
V3_INTROSPECTOR,
|
|
860
785
|
buildV3Services(),
|
|
@@ -863,7 +788,7 @@ function zodAdapter(zodSchema) {
|
|
|
863
788
|
);
|
|
864
789
|
}
|
|
865
790
|
async function lazyFingerprint(schema) {
|
|
866
|
-
const { fingerprintZodSchema } = await import('../chunks/fingerprint.
|
|
791
|
+
const { fingerprintZodSchema } = await import('../chunks/fingerprint.mjs');
|
|
867
792
|
return fingerprintZodSchema(schema);
|
|
868
793
|
}
|
|
869
794
|
function buildV3Services() {
|
|
@@ -874,7 +799,10 @@ function buildV3Services() {
|
|
|
874
799
|
// slim-mode walks — `getSlimPrimitiveTypesAtPath` and
|
|
875
800
|
// `getSchemasAtPath` both consume this variant so the yielded
|
|
876
801
|
// candidates reflect the slim shape.
|
|
877
|
-
|
|
802
|
+
// The slim-root projection is gone (size-teardown P7): the shared
|
|
803
|
+
// path walker peels wrappers / effects inline, so the slim and
|
|
804
|
+
// unstripped walks coincide — same aliasing v4 always had.
|
|
805
|
+
getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
|
|
878
806
|
slimPrimitivesOf: (schema, _maxRecursionDepth) => slimPrimitivesV3(schema),
|
|
879
807
|
deriveDefault: (schema, useDefault, _maxRecursionDepth, formKey) => getDefaultValuesFromZodSchema(schema, useDefault, formKey),
|
|
880
808
|
runStrictGetDefaults: (schema, config, formKey, maxRecursionDepth) => runStrictGetDefaultsV3(schema, config, formKey, maxRecursionDepth),
|
|
@@ -883,7 +811,7 @@ function buildV3Services() {
|
|
|
883
811
|
peelAllWrappers: (schema) => peelAllV3Wrappers(schema),
|
|
884
812
|
isLeafRequired: (schema) => isLeafRequiredV3(schema),
|
|
885
813
|
resolveFieldMetaAtPath: (schema, path, maxRecursionDepth) => resolveFieldMetaAtPathV3(schema, path, maxRecursionDepth),
|
|
886
|
-
issuesToValidationErrors: (issues
|
|
814
|
+
issuesToValidationErrors: (issues) => zodIssuesToValidationErrors(issues),
|
|
887
815
|
safeParseSync: (schema, data) => {
|
|
888
816
|
const result = schema.safeParse(data);
|
|
889
817
|
return result.success ? { success: true, data: result.data } : { success: false, issues: result.error.issues };
|
|
@@ -896,7 +824,7 @@ function buildV3Services() {
|
|
|
896
824
|
// historical shape) — `getSchemasAtPath` consumers may probe any
|
|
897
825
|
// method on the result. The factory call rebuilds the full surface
|
|
898
826
|
// against the sub-schema with its own per-form caches.
|
|
899
|
-
makeSubSchema: (sub, formKey, maxRecursionDepth) =>
|
|
827
|
+
makeSubSchema: (sub, formKey, maxRecursionDepth) => createAbstractSchema(
|
|
900
828
|
sub,
|
|
901
829
|
V3_INTROSPECTOR,
|
|
902
830
|
buildV3Services(),
|
|
@@ -905,7 +833,7 @@ function buildV3Services() {
|
|
|
905
833
|
)
|
|
906
834
|
};
|
|
907
835
|
}
|
|
908
|
-
function zodIssuesToValidationErrors(issues
|
|
836
|
+
function zodIssuesToValidationErrors(issues) {
|
|
909
837
|
const validationErrors = [];
|
|
910
838
|
for (const issue of issues) {
|
|
911
839
|
let code;
|
|
@@ -913,12 +841,6 @@ function zodIssuesToValidationErrors(issues, formKey) {
|
|
|
913
841
|
code = `zod:${issue.code}`;
|
|
914
842
|
} else {
|
|
915
843
|
code = "zod:unknown";
|
|
916
|
-
if (devtoolsShared.__DEV__ && !warnedZodCodeMissing) {
|
|
917
|
-
warnedZodCodeMissing = true;
|
|
918
|
-
console.warn(
|
|
919
|
-
"[attaform] zod-v3 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."
|
|
920
|
-
);
|
|
921
|
-
}
|
|
922
844
|
}
|
|
923
845
|
validationErrors.push({
|
|
924
846
|
message: issue.message,
|
|
@@ -934,7 +856,6 @@ function zodIssuesToValidationErrors(issues, formKey) {
|
|
|
934
856
|
// to absolutise, then routes form-level (absolute path length 0)
|
|
935
857
|
// entries to the empty-string bucket at storage time.
|
|
936
858
|
path: coercePathSegments(issue.path),
|
|
937
|
-
formKey,
|
|
938
859
|
code
|
|
939
860
|
});
|
|
940
861
|
}
|
|
@@ -949,7 +870,7 @@ function coercePathSegments(path) {
|
|
|
949
870
|
}
|
|
950
871
|
function getNestedZodSchemasAtPath(schema, segments, maxRecursionDepth) {
|
|
951
872
|
if (segments.length === 0) return [schema];
|
|
952
|
-
return
|
|
873
|
+
return walkPathSegments(schema, segments.map(String), V3_INTROSPECTOR, maxRecursionDepth, 0);
|
|
953
874
|
}
|
|
954
875
|
function unwrapStructuralLeafV3(schema) {
|
|
955
876
|
let current = schema;
|
|
@@ -1094,271 +1015,6 @@ function unwrapToDiscriminatedUnion(schema, depth = 0) {
|
|
|
1094
1015
|
}
|
|
1095
1016
|
return void 0;
|
|
1096
1017
|
}
|
|
1097
|
-
function getDefaultValue(expected, context) {
|
|
1098
|
-
const discriminatorContext = context.discriminator;
|
|
1099
|
-
if (discriminatorContext.isDiscriminatorKey) {
|
|
1100
|
-
if (!discriminatorContext.schema) {
|
|
1101
|
-
throw new Error("discriminatorContext.schema unspecified");
|
|
1102
|
-
}
|
|
1103
|
-
if (!isZodSchemaType(discriminatorContext.schema, "ZodDiscriminatedUnion")) {
|
|
1104
|
-
throw new TypeError(
|
|
1105
|
-
"Programming error: discriminatorContext.schema is not a ZodDiscriminatedUnion schema."
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
const optionDiscriminator = getSchemaByDiscriminatorKey(
|
|
1109
|
-
discriminatorContext.schema);
|
|
1110
|
-
if (!optionDiscriminator) {
|
|
1111
|
-
throw new Error("ZodDiscriminatedUnion: default option not found");
|
|
1112
|
-
}
|
|
1113
|
-
return getDefaultValuesFromZodSchema(
|
|
1114
|
-
optionDiscriminator,
|
|
1115
|
-
discriminatorContext.useDefaultSchemaValues,
|
|
1116
|
-
context.formKey
|
|
1117
|
-
);
|
|
1118
|
-
}
|
|
1119
|
-
if (expected === "string") return "";
|
|
1120
|
-
if (expected === "number") return 0;
|
|
1121
|
-
if (expected === "array") return [];
|
|
1122
|
-
if (expected === "boolean") return false;
|
|
1123
|
-
if (expected === "bigint") return 0n;
|
|
1124
|
-
if (expected === "float") return 0;
|
|
1125
|
-
if (expected === "integer") return 0;
|
|
1126
|
-
if (expected === "null") return null;
|
|
1127
|
-
if (expected === "object") return {};
|
|
1128
|
-
if (expected === "set") return /* @__PURE__ */ new Set();
|
|
1129
|
-
if (expected === "date") return /* @__PURE__ */ new Date();
|
|
1130
|
-
if (expected === "undefined") return void 0;
|
|
1131
|
-
if (expected === "unknown") return void 0;
|
|
1132
|
-
if (expected === "nan") return Number("nan");
|
|
1133
|
-
return void 0;
|
|
1134
|
-
}
|
|
1135
|
-
function getDefaultValuesFromZodSchema(formSchema, useDefaultSchemaValues, formKey) {
|
|
1136
|
-
return walkFieldMeta.deriveDefaultWalk(formSchema, useDefaultSchemaValues, V3_INTROSPECTOR, 64, {
|
|
1137
|
-
unsupportedKindFallback: (schema) => {
|
|
1138
|
-
console.warn(
|
|
1139
|
-
`[attaform] zod-v3 adapter: unsupported schema kind '${schema.constructor?.name ?? "unknown"}' on form '${formKey}'. Defaulting the field to null. Use a supported zod kind (object/array/record/string/number/etc.) at this path.`
|
|
1140
|
-
);
|
|
1141
|
-
return null;
|
|
1142
|
-
},
|
|
1143
|
-
// v3 historically surfaces the `.catch(v)` fallback even when
|
|
1144
|
-
// `useDefaultSchemaValues=false`. Pinned by
|
|
1145
|
-
// `test/adapters/zod-v3/wrappers.test.ts` ('surfaces the catch
|
|
1146
|
-
// fallback even when useDefaultSchemaValues is false').
|
|
1147
|
-
catchOnUseDefaultFalse: "preserveCatch"
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
function getSchemaByDiscriminatorKey(unionSchema, key) {
|
|
1151
|
-
if (!isZodSchemaType(unionSchema, "ZodDiscriminatedUnion")) {
|
|
1152
|
-
throw new TypeError("Provided schema is not a discriminated union.");
|
|
1153
|
-
}
|
|
1154
|
-
{
|
|
1155
|
-
const options = getDiscriminatedOptions(unionSchema);
|
|
1156
|
-
if (!options.length) {
|
|
1157
|
-
throw new TypeError("Provided ZodDiscriminatedUnion does not have any options");
|
|
1158
|
-
}
|
|
1159
|
-
return options[0];
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
function stripRefinements(schema) {
|
|
1163
|
-
function _stripRefinements(_schema, depth) {
|
|
1164
|
-
if (depth >= MAX_UNWRAP_STEPS) return _schema;
|
|
1165
|
-
if (isZodSchemaType(_schema, "ZodString") && hasChecks(_schema)) {
|
|
1166
|
-
return stripLeafChecks(_schema);
|
|
1167
|
-
}
|
|
1168
|
-
if (isZodSchemaType(_schema, "ZodNumber") && hasChecks(_schema)) {
|
|
1169
|
-
return stripLeafChecks(_schema);
|
|
1170
|
-
}
|
|
1171
|
-
if (isZodSchemaType(_schema, "ZodArray")) {
|
|
1172
|
-
const inner = getArrayElement(_schema);
|
|
1173
|
-
if (!inner) return _schema;
|
|
1174
|
-
return rebuildArray(_schema, _stripRefinements(inner, depth + 1));
|
|
1175
|
-
}
|
|
1176
|
-
if (isZodSchemaType(_schema, "ZodObject")) {
|
|
1177
|
-
const strippedShape = Object.fromEntries(
|
|
1178
|
-
Object.entries(getObjectShape(_schema)).map(([key, value]) => [
|
|
1179
|
-
key,
|
|
1180
|
-
_stripRefinements(value, depth + 1)
|
|
1181
|
-
])
|
|
1182
|
-
);
|
|
1183
|
-
return rebuildObject(_schema, strippedShape);
|
|
1184
|
-
}
|
|
1185
|
-
if (isZodSchemaType(_schema, "ZodEffects")) {
|
|
1186
|
-
const inner = unwrapEffectsSource(_schema);
|
|
1187
|
-
if (!inner) return _schema;
|
|
1188
|
-
return _stripRefinements(inner, depth + 1);
|
|
1189
|
-
}
|
|
1190
|
-
if (isZodSchemaType(_schema, "ZodOptional")) {
|
|
1191
|
-
const inner = unwrapInner(_schema);
|
|
1192
|
-
if (!inner) return _schema;
|
|
1193
|
-
return rebuildWrapperInner(_schema, _stripRefinements(inner, depth + 1));
|
|
1194
|
-
}
|
|
1195
|
-
if (isZodSchemaType(_schema, "ZodNullable")) {
|
|
1196
|
-
const inner = unwrapInner(_schema);
|
|
1197
|
-
if (!inner) return _schema;
|
|
1198
|
-
return rebuildWrapperInner(_schema, _stripRefinements(inner, depth + 1));
|
|
1199
|
-
}
|
|
1200
|
-
if (isZodSchemaType(_schema, "ZodReadonly")) {
|
|
1201
|
-
const inner = unwrapInner(_schema);
|
|
1202
|
-
if (!inner) return _schema;
|
|
1203
|
-
return _stripRefinements(inner, depth + 1);
|
|
1204
|
-
}
|
|
1205
|
-
if (isZodSchemaType(_schema, "ZodBranded")) {
|
|
1206
|
-
const inner = unwrapBranded(_schema);
|
|
1207
|
-
if (!inner) return _schema;
|
|
1208
|
-
return _stripRefinements(inner, depth + 1);
|
|
1209
|
-
}
|
|
1210
|
-
if (isZodSchemaType(_schema, "ZodPipeline")) {
|
|
1211
|
-
const inner = unwrapPipeIn(_schema);
|
|
1212
|
-
if (!inner) return _schema;
|
|
1213
|
-
return _stripRefinements(inner, depth + 1);
|
|
1214
|
-
}
|
|
1215
|
-
if (isZodSchemaType(_schema, "ZodSet")) {
|
|
1216
|
-
const valueType = getSetValueType(_schema);
|
|
1217
|
-
if (!valueType) return _schema;
|
|
1218
|
-
return rebuildSet(_schema, _stripRefinements(valueType, depth + 1));
|
|
1219
|
-
}
|
|
1220
|
-
if (isZodSchemaType(_schema, "ZodTuple")) {
|
|
1221
|
-
const items = getTupleItems(_schema);
|
|
1222
|
-
if (items.length === 0) return _schema;
|
|
1223
|
-
const stripped = items.map((it) => _stripRefinements(it, depth + 1));
|
|
1224
|
-
return rebuildTuple(_schema, stripped);
|
|
1225
|
-
}
|
|
1226
|
-
if (isZodSchemaType(_schema, "ZodRecord")) {
|
|
1227
|
-
const valueType = getRecordValueType(_schema);
|
|
1228
|
-
if (!valueType) return _schema;
|
|
1229
|
-
const value = _stripRefinements(valueType, depth + 1);
|
|
1230
|
-
const keyType = getRecordKeyType(_schema);
|
|
1231
|
-
if (keyType) {
|
|
1232
|
-
return rebuildRecord(_schema, value, keyType);
|
|
1233
|
-
}
|
|
1234
|
-
return rebuildRecord(_schema, value);
|
|
1235
|
-
}
|
|
1236
|
-
if (isZodSchemaType(_schema, "ZodUnion")) {
|
|
1237
|
-
const options = getUnionOptions(_schema);
|
|
1238
|
-
if (options.length === 0) return _schema;
|
|
1239
|
-
const stripped = options.map((o) => _stripRefinements(o, depth + 1));
|
|
1240
|
-
return rebuildUnion(_schema, stripped);
|
|
1241
|
-
}
|
|
1242
|
-
if (isZodSchemaType(_schema, "ZodDiscriminatedUnion")) {
|
|
1243
|
-
const discKey = getDiscriminator(_schema);
|
|
1244
|
-
const options = getDiscriminatedOptions(_schema);
|
|
1245
|
-
if (discKey === void 0 || options.length === 0) return _schema;
|
|
1246
|
-
const stripped = options.map(
|
|
1247
|
-
(o) => _stripRefinements(o, depth + 1)
|
|
1248
|
-
);
|
|
1249
|
-
return rebuildDiscriminatedUnion(_schema, stripped);
|
|
1250
|
-
}
|
|
1251
|
-
if (isZodSchemaType(_schema, "ZodIntersection")) {
|
|
1252
|
-
const left = getIntersectionLeft(_schema);
|
|
1253
|
-
const right = getIntersectionRight(_schema);
|
|
1254
|
-
if (!left || !right) return _schema;
|
|
1255
|
-
return rebuildIntersection(
|
|
1256
|
-
_schema,
|
|
1257
|
-
_stripRefinements(left, depth + 1),
|
|
1258
|
-
_stripRefinements(right, depth + 1)
|
|
1259
|
-
);
|
|
1260
|
-
}
|
|
1261
|
-
if (isZodSchemaType(_schema, "ZodLazy")) {
|
|
1262
|
-
const inner = unwrapLazy(_schema);
|
|
1263
|
-
if (!inner) return _schema;
|
|
1264
|
-
const stripped = _stripRefinements(inner, depth + 1);
|
|
1265
|
-
return rebuildLazy(_schema, stripped);
|
|
1266
|
-
}
|
|
1267
|
-
return _schema;
|
|
1268
|
-
}
|
|
1269
|
-
return _stripRefinements(schema, 0);
|
|
1270
|
-
}
|
|
1271
|
-
function stripRootSchema(schema, stripConfig) {
|
|
1272
|
-
function recursion(_schema, _stripped = false) {
|
|
1273
|
-
if (getStripInstruction(stripConfig.stripNullable, _schema) && isZodSchemaType(_schema, "ZodNullable")) {
|
|
1274
|
-
return recursion(_schema.unwrap(), true);
|
|
1275
|
-
}
|
|
1276
|
-
if (getStripInstruction(stripConfig.stripOptional, _schema) && isZodSchemaType(_schema, "ZodOptional")) {
|
|
1277
|
-
return recursion(_schema.unwrap(), true);
|
|
1278
|
-
}
|
|
1279
|
-
if (getStripInstruction(stripConfig.stripZodEffects, _schema) && isZodSchemaType(_schema, "ZodEffects")) {
|
|
1280
|
-
const inner = unwrapEffectsSource(_schema);
|
|
1281
|
-
if (inner) return recursion(inner, true);
|
|
1282
|
-
}
|
|
1283
|
-
if (getStripInstruction(stripConfig.stripDefaultValues, _schema) && isZodSchemaType(_schema, "ZodDefault")) {
|
|
1284
|
-
const inner = unwrapInner(_schema);
|
|
1285
|
-
if (inner) return recursion(inner, true);
|
|
1286
|
-
}
|
|
1287
|
-
if (getStripInstruction(stripConfig.stripZodRefinements, _schema) && hasChecks(_schema)) {
|
|
1288
|
-
return recursion(stripRefinements(_schema));
|
|
1289
|
-
}
|
|
1290
|
-
return [_schema, _stripped];
|
|
1291
|
-
}
|
|
1292
|
-
return recursion(schema, false);
|
|
1293
|
-
}
|
|
1294
|
-
const getStripInstruction = (stripValueOrCallback, schema) => {
|
|
1295
|
-
if (stripValueOrCallback === void 0 || stripValueOrCallback === false) return false;
|
|
1296
|
-
return typeof stripValueOrCallback === "function" ? stripValueOrCallback(schema) : stripValueOrCallback;
|
|
1297
|
-
};
|
|
1298
|
-
function getSlimSchema(config) {
|
|
1299
|
-
function _getSlimSchema(_schema) {
|
|
1300
|
-
if (isZodSchemaType(_schema, "ZodObject")) {
|
|
1301
|
-
const newShape = {};
|
|
1302
|
-
for (const [key, value] of Object.entries(getObjectShape(_schema))) {
|
|
1303
|
-
newShape[key] = _getSlimSchema(value);
|
|
1304
|
-
}
|
|
1305
|
-
return rebuildObject(_schema, newShape);
|
|
1306
|
-
}
|
|
1307
|
-
if (isZodSchemaType(_schema, "ZodArray")) {
|
|
1308
|
-
const inner = getArrayElement(_schema);
|
|
1309
|
-
if (!inner) return _schema;
|
|
1310
|
-
return rebuildArray(_schema, _getSlimSchema(inner));
|
|
1311
|
-
}
|
|
1312
|
-
if (isZodSchemaType(_schema, "ZodRecord")) {
|
|
1313
|
-
const keyType = getRecordKeyType(_schema);
|
|
1314
|
-
const valueType = getRecordValueType(_schema);
|
|
1315
|
-
if (!keyType || !valueType) return _schema;
|
|
1316
|
-
const key = _getSlimSchema(keyType);
|
|
1317
|
-
const value = _getSlimSchema(valueType);
|
|
1318
|
-
return rebuildRecord(_schema, value, key);
|
|
1319
|
-
}
|
|
1320
|
-
if (isZodSchemaType(_schema, "ZodDiscriminatedUnion")) {
|
|
1321
|
-
const slimmedSchemas = [];
|
|
1322
|
-
const discKey = getDiscriminator(_schema);
|
|
1323
|
-
if (discKey === void 0) return _schema;
|
|
1324
|
-
for (const option of getDiscriminatedOptions(_schema)) {
|
|
1325
|
-
const slimmedSchema = _getSlimSchema(option);
|
|
1326
|
-
const deepCloneSlimmedSchema = cloneSchemaDeep(slimmedSchema);
|
|
1327
|
-
slimmedSchemas.push(deepCloneSlimmedSchema);
|
|
1328
|
-
}
|
|
1329
|
-
return rebuildDiscriminatedUnion(
|
|
1330
|
-
_schema,
|
|
1331
|
-
slimmedSchemas
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
|
-
if (getStripInstruction(config.stripConfig.stripZodEffects, _schema) && isZodSchemaType(_schema, "ZodEffects")) {
|
|
1335
|
-
const inner = unwrapEffectsSource(_schema);
|
|
1336
|
-
if (inner) return _getSlimSchema(inner);
|
|
1337
|
-
}
|
|
1338
|
-
if (getStripInstruction(config.stripConfig.stripNullable, _schema) && isZodSchemaType(_schema, "ZodNullable")) {
|
|
1339
|
-
const inner = unwrapInner(_schema);
|
|
1340
|
-
if (inner) return _getSlimSchema(inner);
|
|
1341
|
-
}
|
|
1342
|
-
if (getStripInstruction(config.stripConfig.stripOptional, _schema) && isZodSchemaType(_schema, "ZodOptional")) {
|
|
1343
|
-
const inner = unwrapInner(_schema);
|
|
1344
|
-
if (inner) return _getSlimSchema(inner);
|
|
1345
|
-
}
|
|
1346
|
-
if (getStripInstruction(config.stripConfig.stripZodRefinements, _schema) && hasChecks(_schema)) {
|
|
1347
|
-
return stripRefinements(_schema);
|
|
1348
|
-
}
|
|
1349
|
-
if (getStripInstruction(config.stripConfig.stripDefaultValues, _schema) && isZodSchemaType(_schema, "ZodDefault")) {
|
|
1350
|
-
const inner = unwrapInner(_schema);
|
|
1351
|
-
if (inner) return _getSlimSchema(inner);
|
|
1352
|
-
}
|
|
1353
|
-
const unionSchema = unwrapToDiscriminatedUnion(_schema);
|
|
1354
|
-
if (unionSchema && getStripInstruction(config.stripConfig.stripDefaultValues, unionSchema)) {
|
|
1355
|
-
return _getSlimSchema(unionSchema);
|
|
1356
|
-
}
|
|
1357
|
-
return _schema;
|
|
1358
|
-
}
|
|
1359
|
-
const processedRootSchema = stripRootSchema(config.schema, config.stripConfig)[0];
|
|
1360
|
-
return _getSlimSchema(processedRootSchema);
|
|
1361
|
-
}
|
|
1362
1018
|
function peelAllV3Wrappers(schema) {
|
|
1363
1019
|
let current = schema;
|
|
1364
1020
|
for (let i = 0; i < MAX_UNWRAP_STEPS; i++) {
|
|
@@ -1385,30 +1041,41 @@ function peelAllV3Wrappers(schema) {
|
|
|
1385
1041
|
}
|
|
1386
1042
|
return current;
|
|
1387
1043
|
}
|
|
1044
|
+
function getDefaultValuesFromZodSchema(formSchema, useDefaultSchemaValues, formKey) {
|
|
1045
|
+
return deriveDefaultWalk(formSchema, useDefaultSchemaValues, V3_INTROSPECTOR, 64, {
|
|
1046
|
+
unsupportedKindFallback: (schema) => {
|
|
1047
|
+
const kindName = schema.constructor?.name ?? "unknown";
|
|
1048
|
+
console.warn(
|
|
1049
|
+
`[attaform] AF13 attaform.dev/e/af13 '${kindName}' on '${formKey}'`
|
|
1050
|
+
);
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1388
1055
|
function resolveFieldMetaAtPathV3(rootSchema, path, maxRecursionDepth) {
|
|
1389
1056
|
const lastSegment = path.length === 0 ? "" : path[path.length - 1];
|
|
1390
1057
|
const target = path.length === 0 ? rootSchema : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth)[0];
|
|
1391
1058
|
if (target === void 0) {
|
|
1392
1059
|
return {
|
|
1393
|
-
label:
|
|
1060
|
+
label: humanize(lastSegment),
|
|
1394
1061
|
description: void 0,
|
|
1395
1062
|
placeholder: void 0,
|
|
1396
1063
|
meta: Object.freeze({})
|
|
1397
1064
|
};
|
|
1398
1065
|
}
|
|
1399
|
-
const pathMap =
|
|
1066
|
+
const pathMap = buildFieldMetaPathMap(rootSchema, {
|
|
1400
1067
|
intro: V3_INTROSPECTOR,
|
|
1401
1068
|
peelAllWrappers: peelAllV3Wrappers,
|
|
1402
|
-
getFieldMetaList
|
|
1069
|
+
getFieldMetaList: getFieldMetaListForSchema
|
|
1403
1070
|
});
|
|
1404
|
-
const pathKey =
|
|
1071
|
+
const pathKey = canonicalizePath(path).key;
|
|
1405
1072
|
const peeled = peelV3Wrappers(target);
|
|
1406
|
-
const payload = pathMap
|
|
1073
|
+
const payload = pathMap?.get(pathKey) ?? getFieldMetaForSchema(target) ?? (peeled !== target ? getFieldMetaForSchema(peeled) : void 0);
|
|
1407
1074
|
const targetDescription = typeof target.description === "string" ? target.description : void 0;
|
|
1408
1075
|
const peeledDescription = peeled !== target && typeof peeled.description === "string" ? peeled.description : void 0;
|
|
1409
1076
|
const schemaDescription = targetDescription ?? peeledDescription;
|
|
1410
1077
|
return {
|
|
1411
|
-
label: payload?.label ??
|
|
1078
|
+
label: payload?.label ?? humanize(lastSegment),
|
|
1412
1079
|
description: payload?.description ?? schemaDescription ?? void 0,
|
|
1413
1080
|
placeholder: payload?.placeholder ?? void 0,
|
|
1414
1081
|
meta: Object.freeze({ ...payload ?? {} })
|
|
@@ -1420,24 +1087,7 @@ function runStrictGetDefaultsV3(rootSchema, config, formKey, maxRecursionDepth)
|
|
|
1420
1087
|
config.useDefaultSchemaValues,
|
|
1421
1088
|
formKey
|
|
1422
1089
|
);
|
|
1423
|
-
const
|
|
1424
|
-
schema: rootSchema,
|
|
1425
|
-
stripConfig: {
|
|
1426
|
-
stripZodEffects: true,
|
|
1427
|
-
stripDefaultValues: true,
|
|
1428
|
-
// `strict: false` strips refinements (so empty defaults pass);
|
|
1429
|
-
// strict keeps them so the slim parse below surfaces refinement
|
|
1430
|
-
// errors. Async refines are guarded by the try/catch — they
|
|
1431
|
-
// can't be surfaced synchronously regardless.
|
|
1432
|
-
stripZodRefinements: (config.strict ?? true) === false
|
|
1433
|
-
}
|
|
1434
|
-
});
|
|
1435
|
-
let rawDefaultValues = defaultValuesWithoutConstraints;
|
|
1436
|
-
if (!isPrimitive(rawDefaultValues)) {
|
|
1437
|
-
rawDefaultValues = walkFieldMeta.mergeDeep(defaultValuesWithoutConstraints, config.constraints);
|
|
1438
|
-
} else if (constraintsAreSlimValid(slimSchema, config.constraints)) {
|
|
1439
|
-
rawDefaultValues = config.constraints;
|
|
1440
|
-
}
|
|
1090
|
+
const rawDefaultValues = mergeDeep(defaultValuesWithoutConstraints, config.constraints);
|
|
1441
1091
|
if ((config.strict ?? true) !== false) {
|
|
1442
1092
|
if (containsAsyncTransform(rootSchema)) {
|
|
1443
1093
|
return {
|
|
@@ -1459,7 +1109,7 @@ function runStrictGetDefaultsV3(rootSchema, config, formKey, maxRecursionDepth)
|
|
|
1459
1109
|
}
|
|
1460
1110
|
return {
|
|
1461
1111
|
data: rawDefaultValues,
|
|
1462
|
-
errors: zodIssuesToValidationErrors(strictResult.error.issues
|
|
1112
|
+
errors: zodIssuesToValidationErrors(strictResult.error.issues),
|
|
1463
1113
|
success: false,
|
|
1464
1114
|
formKey
|
|
1465
1115
|
};
|
|
@@ -1478,7 +1128,7 @@ function runStrictGetDefaultsV3(rootSchema, config, formKey, maxRecursionDepth)
|
|
|
1478
1128
|
}
|
|
1479
1129
|
return {
|
|
1480
1130
|
data: rawDefaultValues,
|
|
1481
|
-
errors: zodIssuesToValidationErrors(strippedResult.error.issues
|
|
1131
|
+
errors: zodIssuesToValidationErrors(strippedResult.error.issues),
|
|
1482
1132
|
success: false,
|
|
1483
1133
|
formKey
|
|
1484
1134
|
};
|
|
@@ -1499,139 +1149,40 @@ function runStrictGetDefaultsV3(rootSchema, config, formKey, maxRecursionDepth)
|
|
|
1499
1149
|
};
|
|
1500
1150
|
}
|
|
1501
1151
|
}
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
formKey
|
|
1511
|
-
|
|
1512
|
-
}
|
|
1513
|
-
const { data, success, error } = parseResult;
|
|
1514
|
-
if (success) {
|
|
1515
|
-
return {
|
|
1516
|
-
data,
|
|
1517
|
-
errors: void 0,
|
|
1518
|
-
success,
|
|
1519
|
-
formKey
|
|
1520
|
-
};
|
|
1521
|
-
}
|
|
1522
|
-
let fixedData = {};
|
|
1523
|
-
for (const issue of error.issues) {
|
|
1524
|
-
const schemasAtPath = getNestedZodSchemasAtPath(slimSchema, issue.path, maxRecursionDepth);
|
|
1525
|
-
const path = coercePathSegments(issue.path);
|
|
1526
|
-
if (!schemasAtPath.length) {
|
|
1527
|
-
console.error(
|
|
1528
|
-
`[attaform] zod-v3 adapter: no schema at path '${path.join(PATH_SEPARATOR)}' for key '${formKey}'. Skipping the issue. (This is a library-internal invariant \u2014 please file a bug.)`
|
|
1529
|
-
);
|
|
1530
|
-
continue;
|
|
1531
|
-
}
|
|
1532
|
-
const candidate = schemasAtPath[0];
|
|
1533
|
-
if (candidate !== void 0) {
|
|
1534
|
-
const valueAtPath = serializeScript.getAtPath(rawDefaultValues, path);
|
|
1535
|
-
const slimKinds = slimPrimitivesV3(candidate);
|
|
1536
|
-
if (slimKinds.size > 0 && slimKinds.has(serializeScript.slimKindOf(valueAtPath))) {
|
|
1537
|
-
continue;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
for (const schemaAtPath of schemasAtPath) {
|
|
1541
|
-
if (issue.code === "invalid_type") {
|
|
1542
|
-
const isDiscriminatedUnion = isZodSchemaType(schemaAtPath, "ZodDiscriminatedUnion");
|
|
1543
|
-
const defaultValueContext = isDiscriminatedUnion ? {
|
|
1544
|
-
formKey,
|
|
1545
|
-
discriminator: {
|
|
1546
|
-
isDiscriminatorKey: true,
|
|
1547
|
-
schema: schemaAtPath,
|
|
1548
|
-
useDefaultSchemaValues: false
|
|
1549
|
-
}
|
|
1550
|
-
} : {
|
|
1551
|
-
formKey,
|
|
1552
|
-
discriminator: {
|
|
1553
|
-
isDiscriminatorKey: false,
|
|
1554
|
-
schema: void 0,
|
|
1555
|
-
useDefaultSchemaValues: false
|
|
1556
|
-
}
|
|
1557
|
-
};
|
|
1558
|
-
const defaultValue = getDefaultValue(issue.expected, defaultValueContext);
|
|
1559
|
-
fixedData = serializeScript.setAtPath(fixedData, path, defaultValue);
|
|
1560
|
-
continue;
|
|
1561
|
-
}
|
|
1562
|
-
const peeled = walkFieldMeta.peelEmbeddedDefault(schemaAtPath, V3_INTROSPECTOR);
|
|
1563
|
-
if (peeled !== walkFieldMeta.NO_EMBEDDED_DEFAULT) {
|
|
1564
|
-
fixedData = serializeScript.setAtPath(fixedData, path, peeled);
|
|
1565
|
-
continue;
|
|
1566
|
-
}
|
|
1567
|
-
const ctx = {
|
|
1568
|
-
formKey,
|
|
1569
|
-
discriminator: {
|
|
1570
|
-
isDiscriminatorKey: false,
|
|
1571
|
-
schema: void 0,
|
|
1572
|
-
useDefaultSchemaValues: false
|
|
1573
|
-
}
|
|
1574
|
-
};
|
|
1575
|
-
const slimKinds = slimPrimitivesV3(schemaAtPath);
|
|
1576
|
-
const firstKind = [...slimKinds][0];
|
|
1577
|
-
if (firstKind !== void 0) {
|
|
1578
|
-
const expected = firstKind === "string" ? "string" : firstKind === "number" ? "number" : firstKind === "boolean" ? "boolean" : firstKind === "bigint" ? "bigint" : firstKind === "date" ? "date" : firstKind === "array" ? "array" : firstKind === "object" ? "object" : null;
|
|
1579
|
-
if (expected !== null) {
|
|
1580
|
-
fixedData = serializeScript.setAtPath(fixedData, path, getDefaultValue(expected, ctx));
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1152
|
+
const fixed = fixStructuralDefaults(
|
|
1153
|
+
rootSchema,
|
|
1154
|
+
rawDefaultValues,
|
|
1155
|
+
config.useDefaultSchemaValues,
|
|
1156
|
+
maxRecursionDepth,
|
|
1157
|
+
{
|
|
1158
|
+
intro: V3_INTROSPECTOR,
|
|
1159
|
+
slimPrimitivesOf: (s) => slimPrimitivesV3(s),
|
|
1160
|
+
deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault, formKey),
|
|
1161
|
+
unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
|
|
1583
1162
|
}
|
|
1584
|
-
|
|
1585
|
-
fixedData = walkFieldMeta.mergeDeep(rawDefaultValues, fixedData);
|
|
1586
|
-
const secondParse = slimSchema.safeParse(fixedData);
|
|
1587
|
-
const finalData = secondParse.success ? secondParse.data : fixedData;
|
|
1163
|
+
);
|
|
1588
1164
|
return {
|
|
1589
|
-
data:
|
|
1165
|
+
data: fixed.data,
|
|
1590
1166
|
errors: void 0,
|
|
1591
1167
|
success: true,
|
|
1592
1168
|
formKey
|
|
1593
1169
|
};
|
|
1594
1170
|
}
|
|
1595
|
-
const slimRootCacheV3 = /* @__PURE__ */ new WeakMap();
|
|
1596
|
-
function getSlimRootV3(rootSchema) {
|
|
1597
|
-
const cached = slimRootCacheV3.get(rootSchema);
|
|
1598
|
-
if (cached !== void 0) return cached;
|
|
1599
|
-
const [strippedSchema] = stripRootSchema(rootSchema, {
|
|
1600
|
-
stripDefaultValues: true,
|
|
1601
|
-
stripNullable: true,
|
|
1602
|
-
stripOptional: true,
|
|
1603
|
-
stripZodEffects: true
|
|
1604
|
-
});
|
|
1605
|
-
const slimSchema = getSlimSchema({
|
|
1606
|
-
schema: strippedSchema,
|
|
1607
|
-
stripConfig: { stripDefaultValues: true, stripZodEffects: true }
|
|
1608
|
-
});
|
|
1609
|
-
slimRootCacheV3.set(rootSchema, slimSchema);
|
|
1610
|
-
return slimSchema;
|
|
1611
|
-
}
|
|
1612
|
-
function getNestedSchemasInSlimModeV3(rootSchema, path, maxRecursionDepth) {
|
|
1613
|
-
return getNestedZodSchemasAtPath(getSlimRootV3(rootSchema), path, maxRecursionDepth);
|
|
1614
|
-
}
|
|
1615
1171
|
|
|
1616
1172
|
function useForm(configuration) {
|
|
1617
1173
|
if (configuration === void 0 || configuration === null || configuration.schema === void 0) {
|
|
1618
|
-
throw new
|
|
1174
|
+
throw new InvalidUseFormConfigError();
|
|
1619
1175
|
}
|
|
1620
1176
|
function isZodType(value) {
|
|
1621
1177
|
return typeof value === "object" && value !== null && "_def" in value;
|
|
1622
1178
|
}
|
|
1623
1179
|
const { schema } = configuration;
|
|
1624
1180
|
const abstractSchema = isZodType(schema) ? zodAdapter(schema) : schema;
|
|
1625
|
-
return
|
|
1181
|
+
return useAbstractForm({
|
|
1626
1182
|
...configuration,
|
|
1627
1183
|
schema: abstractSchema,
|
|
1628
1184
|
defaultValues: configuration.defaultValues
|
|
1629
1185
|
});
|
|
1630
1186
|
}
|
|
1631
1187
|
|
|
1632
|
-
|
|
1633
|
-
exports.isZodSchemaType = isZodSchemaType;
|
|
1634
|
-
exports.useForm = useForm;
|
|
1635
|
-
exports.withMeta = withMeta;
|
|
1636
|
-
exports.zodAdapter = zodAdapter;
|
|
1637
|
-
//# sourceMappingURL=attaform.Bh8A6YAc.cjs.map
|
|
1188
|
+
export { isZodSchemaType as i, useForm as u, zodAdapter as z };
|