attaform 0.30.0 → 0.31.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 +15 -21
- package/dist/abstract.mjs +3 -3
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/devtools.mjs +4 -4
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +2 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +1 -1
- package/dist/dev/shared/{attaform-dev.DUZckyV8.mjs → attaform-dev.B1q-x9R9.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.BcYT6tFh.mjs → attaform-dev.CZz4GYZ6.mjs} +21 -9
- package/dist/dev/shared/{attaform-dev.BisFstxh.mjs → attaform-dev.Caibt7sb.mjs} +16 -15
- package/dist/dev/shared/{attaform-dev.DTrHonpc.mjs → attaform-dev.CtyqGia7.mjs} +176 -260
- package/dist/dev/shared/{attaform-dev.BK6Ge2qR.mjs → attaform-dev.DJ3nsWw6.mjs} +86 -122
- package/dist/dev/shared/{attaform-dev.BcNtyOmf.mjs → attaform-dev.DlaT4xGd.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.D6CLvaQT.mjs → attaform-dev.k5X47GMD.mjs} +520 -395
- package/dist/dev/shared/{attaform-dev.CQ2rJiAX.mjs → attaform-dev.y9x9Vp9F.mjs} +324 -234
- package/dist/dev/shared/{attaform-dev.BQc5QV3Y.mjs → attaform-dev.zlvDr0WB.mjs} +2 -2
- package/dist/dev/zod-v3.mjs +6 -6
- package/dist/dev/zod-v4.mjs +6 -6
- package/dist/dev/zod.mjs +5 -5
- package/dist/directive.d.mts +4 -4
- package/dist/directive.mjs +1 -1
- package/dist/esbuild.d.mts +11 -0
- package/dist/esbuild.mjs +1 -1
- package/dist/history.d.mts +3 -32
- package/dist/history.mjs +2 -2
- package/dist/index.d.mts +67 -70
- package/dist/index.mjs +4 -4
- package/dist/nuxt.d.mts +4 -3
- package/dist/nuxt.mjs +3 -6
- package/dist/rollup.d.mts +11 -0
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.d.mts +19 -11
- package/dist/rspack.mjs +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +15 -15
- package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
- package/dist/runtime/plugins/attaform.mjs +1 -1
- package/dist/shared/{attaform.BRDDQeHV.mjs → attaform.8mfKZCwH.mjs} +2 -2
- package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
- package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
- package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
- package/dist/shared/{attaform.BXneBxEj.mjs → attaform.BWUn8Kjy.mjs} +85 -121
- package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.C4shmwyJ.mjs} +2 -2
- package/dist/shared/{attaform.Rc9u4Vfw.d.mts → attaform.CRVe8s82.d.mts} +83 -95
- package/dist/shared/attaform.D9RqPgGu.d.mts +42 -0
- package/dist/shared/attaform.DAo0QBmS.d.mts +2173 -0
- package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.DBCbxlyk.mjs} +62 -4
- package/dist/shared/{attaform.CUfrMK7t.mjs → attaform.DL2nl_QR.mjs} +15 -14
- package/dist/shared/{attaform.DNJOWjQw.mjs → attaform.DNPJPOO7.mjs} +299 -218
- package/dist/shared/attaform.DZnrDrNb.d.mts +4657 -0
- package/dist/shared/{attaform.B3resMQ1.mjs → attaform.DxKQsqFZ.mjs} +496 -371
- package/dist/shared/{attaform.ByWP6kSx.mjs → attaform.L011tHgJ.mjs} +3 -3
- package/dist/shared/{attaform.CJ8DpRGj.mjs → attaform.LUPC-2Qg.mjs} +175 -257
- package/dist/transforms.d.mts +153 -26
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +29 -52
- package/dist/vite.mjs +3 -3
- package/dist/webpack.d.mts +20 -12
- package/dist/webpack.mjs +1 -1
- package/dist/zod-v3.d.mts +90 -96
- package/dist/zod-v3.mjs +5 -5
- package/dist/zod-v4.d.mts +120 -118
- package/dist/zod-v4.mjs +5 -5
- package/dist/zod.d.mts +5 -5
- package/dist/zod.mjs +4 -4
- package/package.json +7 -6
- package/skills/attaform/SKILL.md +1 -1
- package/skills/attaform/references/custom-components.md +4 -0
- package/dist/shared/attaform.Clz0ArIi.d.mts +0 -44
- package/dist/shared/attaform.UGyOK83T.d.mts +0 -2366
- package/dist/shared/attaform.bKLzMU0o.d.mts +0 -4761
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as InvalidUseFormConfigError } from './attaform.CdZIEf7_.mjs';
|
|
2
|
-
import { u as useForm$2 } from './attaform.
|
|
3
|
-
import { u as useForm$1 } from './attaform.
|
|
4
|
-
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform.
|
|
2
|
+
import { u as useForm$2 } from './attaform.LUPC-2Qg.mjs';
|
|
3
|
+
import { u as useForm$1 } from './attaform.BWUn8Kjy.mjs';
|
|
4
|
+
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform.DL2nl_QR.mjs';
|
|
5
5
|
|
|
6
6
|
function isZodV4SchemaShape(value) {
|
|
7
7
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, f as fixStructuralDefaults, m as mergeDeep, d as deriveDefaultWalk, e as getFieldMetaListForSchema } from './attaform.
|
|
2
|
-
import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform.
|
|
3
|
-
import { c as
|
|
1
|
+
import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, f as fixStructuralDefaults, m as mergeDeep, d as deriveDefaultWalk, e as getFieldMetaListForSchema } from './attaform.DL2nl_QR.mjs';
|
|
2
|
+
import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform.DNPJPOO7.mjs';
|
|
3
|
+
import { c as callConsumerFn } from './attaform.8mfKZCwH.mjs';
|
|
4
4
|
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.CdZIEf7_.mjs';
|
|
5
5
|
|
|
6
6
|
function isZodSchemaType(schema, expectedType) {
|
|
@@ -196,104 +196,6 @@ function isAsyncEffect(schema) {
|
|
|
196
196
|
if (typeof fn !== "function") return false;
|
|
197
197
|
return fn.constructor.name === "AsyncFunction";
|
|
198
198
|
}
|
|
199
|
-
function containsAsyncRefine(schema, seen) {
|
|
200
|
-
return walkForTarget(schema, "refinement", seen ?? /* @__PURE__ */ new WeakSet());
|
|
201
|
-
}
|
|
202
|
-
function containsMapOrSet(schema, seen) {
|
|
203
|
-
return walkForTarget(schema, "map-or-set", /* @__PURE__ */ new WeakSet());
|
|
204
|
-
}
|
|
205
|
-
function containsDiscriminatedUnion(schema, seen) {
|
|
206
|
-
return walkForTarget(schema, "discriminated-union", seen ?? /* @__PURE__ */ new WeakSet());
|
|
207
|
-
}
|
|
208
|
-
function containsAsyncTransform(schema, seen) {
|
|
209
|
-
return walkForTarget(schema, "transform-or-preprocess", seen ?? /* @__PURE__ */ new WeakSet());
|
|
210
|
-
}
|
|
211
|
-
function walkForTarget(schema, target, visited) {
|
|
212
|
-
const candidate = schema;
|
|
213
|
-
if (typeof candidate !== "object" || candidate === null) return false;
|
|
214
|
-
if (visited.has(candidate)) return false;
|
|
215
|
-
visited.add(candidate);
|
|
216
|
-
if (isZodSchemaType(schema, "ZodEffects")) {
|
|
217
|
-
const kind = getEffectsKind(schema);
|
|
218
|
-
if (target === "refinement" && kind === "refinement") return true;
|
|
219
|
-
if (target === "transform-or-preprocess" && (kind === "transform" || kind === "preprocess") && isAsyncEffect(schema)) {
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
const inner = unwrapEffectsSource(schema);
|
|
223
|
-
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
224
|
-
}
|
|
225
|
-
if (isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodCatch") || isZodSchemaType(schema, "ZodReadonly")) {
|
|
226
|
-
const inner = unwrapInner(schema);
|
|
227
|
-
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
228
|
-
}
|
|
229
|
-
if (isZodSchemaType(schema, "ZodBranded")) {
|
|
230
|
-
const inner = unwrapBranded(schema);
|
|
231
|
-
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
232
|
-
}
|
|
233
|
-
if (isZodSchemaType(schema, "ZodLazy")) {
|
|
234
|
-
const inner = unwrapLazy(schema);
|
|
235
|
-
return inner !== void 0 && walkForTarget(inner, target, visited);
|
|
236
|
-
}
|
|
237
|
-
if (isZodSchemaType(schema, "ZodPipeline")) {
|
|
238
|
-
const inSide = unwrapPipeIn(schema);
|
|
239
|
-
if (inSide !== void 0 && walkForTarget(inSide, target, visited)) return true;
|
|
240
|
-
const outSide = unwrapPipeOut(schema);
|
|
241
|
-
if (outSide !== void 0 && walkForTarget(outSide, target, visited)) return true;
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
if (isZodSchemaType(schema, "ZodObject")) {
|
|
245
|
-
for (const sub of Object.values(getObjectShape(schema))) {
|
|
246
|
-
if (walkForTarget(sub, target, visited)) return true;
|
|
247
|
-
}
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
if (isZodSchemaType(schema, "ZodArray")) {
|
|
251
|
-
const elem = getArrayElement(schema);
|
|
252
|
-
return elem !== void 0 && walkForTarget(elem, target, visited);
|
|
253
|
-
}
|
|
254
|
-
if (isZodSchemaType(schema, "ZodTuple")) {
|
|
255
|
-
for (const it of getTupleItems(schema)) {
|
|
256
|
-
if (walkForTarget(it, target, visited)) return true;
|
|
257
|
-
}
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
if (isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
|
|
261
|
-
if (target === "discriminated-union" && isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
for (const opt of getUnionOptions(schema)) {
|
|
265
|
-
if (walkForTarget(opt, target, visited)) return true;
|
|
266
|
-
}
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
if (isZodSchemaType(schema, "ZodIntersection")) {
|
|
270
|
-
const left = getIntersectionLeft(schema);
|
|
271
|
-
if (left !== void 0 && walkForTarget(left, target, visited)) return true;
|
|
272
|
-
const right = getIntersectionRight(schema);
|
|
273
|
-
if (right !== void 0 && walkForTarget(right, target, visited)) return true;
|
|
274
|
-
return false;
|
|
275
|
-
}
|
|
276
|
-
if (isZodSchemaType(schema, "ZodRecord")) {
|
|
277
|
-
const keyType = getRecordKeyType(schema);
|
|
278
|
-
if (keyType !== void 0 && walkForTarget(keyType, target, visited)) return true;
|
|
279
|
-
const valueType = getRecordValueType(schema);
|
|
280
|
-
if (valueType !== void 0 && walkForTarget(valueType, target, visited)) return true;
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
if (isZodSchemaType(schema, "ZodSet")) {
|
|
284
|
-
if (target === "map-or-set") return true;
|
|
285
|
-
const elem = getSetValueType(schema);
|
|
286
|
-
return elem !== void 0 && walkForTarget(elem, target, visited);
|
|
287
|
-
}
|
|
288
|
-
if (isZodSchemaType(schema, "ZodMap")) {
|
|
289
|
-
if (target === "map-or-set") return true;
|
|
290
|
-
const keyType = getMapKeyType(schema);
|
|
291
|
-
if (keyType !== void 0 && walkForTarget(keyType, target, visited)) return true;
|
|
292
|
-
const valueType = getMapValueType(schema);
|
|
293
|
-
return valueType !== void 0 && walkForTarget(valueType, target, visited);
|
|
294
|
-
}
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
199
|
function unwrapPipeIn(schema) {
|
|
298
200
|
const def = readDef(schema);
|
|
299
201
|
return def?.in;
|
|
@@ -306,7 +208,7 @@ function unwrapLazy(schema) {
|
|
|
306
208
|
const def = readDef(schema);
|
|
307
209
|
const getter = def?.getter;
|
|
308
210
|
if (typeof getter !== "function") return void 0;
|
|
309
|
-
return
|
|
211
|
+
return callConsumerFn(() => getter(), void 0);
|
|
310
212
|
}
|
|
311
213
|
function getLiteralValues(schema) {
|
|
312
214
|
const def = readDef(schema);
|
|
@@ -323,113 +225,148 @@ function getDefaultValue(schema) {
|
|
|
323
225
|
const def = readDef(schema);
|
|
324
226
|
const thunk = def?.defaultValue;
|
|
325
227
|
if (typeof thunk !== "function") return void 0;
|
|
326
|
-
return
|
|
228
|
+
return callConsumerFn(() => thunk(), void 0);
|
|
327
229
|
}
|
|
328
230
|
function getCatchDefault(schema) {
|
|
329
231
|
const def = readDef(schema);
|
|
330
232
|
const cv = def?.catchValue;
|
|
331
233
|
if (typeof cv !== "function") return void 0;
|
|
332
|
-
return
|
|
333
|
-
() => cv({ error: null, input: void 0 }),
|
|
334
|
-
void 0);
|
|
234
|
+
return callConsumerFn(() => cv({ error: null, input: void 0 }), void 0);
|
|
335
235
|
}
|
|
336
236
|
function hasCatchValue(schema) {
|
|
337
237
|
const def = readDef(schema);
|
|
338
238
|
return typeof def?.catchValue === "function";
|
|
339
239
|
}
|
|
340
|
-
|
|
341
|
-
|
|
240
|
+
const capabilityMemo = /* @__PURE__ */ new WeakMap();
|
|
241
|
+
function capabilitiesOf(schema) {
|
|
242
|
+
let capabilities = capabilityMemo.get(schema);
|
|
243
|
+
if (capabilities === void 0) {
|
|
244
|
+
capabilities = scanCapabilities(schema);
|
|
245
|
+
const key = schema;
|
|
246
|
+
if (typeof key === "object" && key !== null) capabilityMemo.set(key, capabilities);
|
|
247
|
+
}
|
|
248
|
+
return capabilities;
|
|
249
|
+
}
|
|
250
|
+
function scanCapabilities(schema) {
|
|
251
|
+
const capabilities = {
|
|
252
|
+
asyncRefine: false,
|
|
253
|
+
asyncTransform: false,
|
|
254
|
+
discriminatedUnion: false,
|
|
255
|
+
containerOrRootRefine: false,
|
|
256
|
+
preprocessOrCoerce: false,
|
|
257
|
+
mapOrSet: false
|
|
258
|
+
};
|
|
259
|
+
walkCapabilities(schema, capabilities, /* @__PURE__ */ new WeakSet());
|
|
260
|
+
return capabilities;
|
|
261
|
+
}
|
|
262
|
+
function walkCapabilities(schema, capabilities, visited) {
|
|
263
|
+
if (schema === void 0) return;
|
|
342
264
|
const candidate = schema;
|
|
343
|
-
if (typeof candidate !== "object" || candidate === null) return
|
|
344
|
-
if (visited.has(candidate)) return false;
|
|
265
|
+
if (typeof candidate !== "object" || candidate === null || visited.has(candidate)) return;
|
|
345
266
|
visited.add(candidate);
|
|
346
|
-
if (
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return inner !== void 0 && hasContainerOrRootRefine(inner, visited);
|
|
363
|
-
}
|
|
364
|
-
if (isZodSchemaType(schema, "ZodPipeline")) {
|
|
365
|
-
const inSide = unwrapPipeIn(schema);
|
|
366
|
-
if (inSide !== void 0 && hasContainerOrRootRefine(inSide, visited)) return true;
|
|
367
|
-
const outSide = unwrapPipeOut(schema);
|
|
368
|
-
if (outSide !== void 0 && hasContainerOrRootRefine(outSide, visited)) return true;
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
if (isZodSchemaType(schema, "ZodObject")) {
|
|
372
|
-
for (const sub of Object.values(getObjectShape(schema))) {
|
|
373
|
-
if (hasContainerOrRootRefine(sub, visited)) return true;
|
|
374
|
-
}
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
if (isZodSchemaType(schema, "ZodArray")) {
|
|
378
|
-
const elem = getArrayElement(schema);
|
|
379
|
-
return elem !== void 0 && hasContainerOrRootRefine(elem, visited);
|
|
380
|
-
}
|
|
381
|
-
if (isZodSchemaType(schema, "ZodTuple")) {
|
|
382
|
-
for (const it of getTupleItems(schema)) {
|
|
383
|
-
if (hasContainerOrRootRefine(it, visited)) return true;
|
|
384
|
-
}
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
if (isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
|
|
388
|
-
for (const opt of getUnionOptions(schema)) {
|
|
389
|
-
if (hasContainerOrRootRefine(opt, visited)) return true;
|
|
267
|
+
if (isCoercePrimitive(schema)) capabilities.preprocessOrCoerce = true;
|
|
268
|
+
const typeName = getTypeName(schema) ?? "";
|
|
269
|
+
switch (typeName) {
|
|
270
|
+
case "ZodEffects": {
|
|
271
|
+
const kind = getEffectsKind(schema);
|
|
272
|
+
if (kind === "refinement") capabilities.asyncRefine = true;
|
|
273
|
+
else if ((kind === "transform" || kind === "preprocess") && isAsyncEffect(schema)) {
|
|
274
|
+
capabilities.asyncTransform = true;
|
|
275
|
+
}
|
|
276
|
+
if (kind === "preprocess") capabilities.preprocessOrCoerce = true;
|
|
277
|
+
const inner = unwrapEffectsSource(schema);
|
|
278
|
+
if (!capabilities.containerOrRootRefine && inner !== void 0 && isContainerAfterWrapperPeel(inner)) {
|
|
279
|
+
capabilities.containerOrRootRefine = true;
|
|
280
|
+
}
|
|
281
|
+
walkCapabilities(inner, capabilities, visited);
|
|
282
|
+
return;
|
|
390
283
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
284
|
+
case "ZodOptional":
|
|
285
|
+
case "ZodNullable":
|
|
286
|
+
case "ZodDefault":
|
|
287
|
+
case "ZodCatch":
|
|
288
|
+
case "ZodReadonly":
|
|
289
|
+
walkCapabilities(unwrapInner(schema), capabilities, visited);
|
|
290
|
+
return;
|
|
291
|
+
case "ZodBranded":
|
|
292
|
+
walkCapabilities(unwrapBranded(schema), capabilities, visited);
|
|
293
|
+
return;
|
|
294
|
+
case "ZodLazy":
|
|
295
|
+
walkCapabilities(unwrapLazy(schema), capabilities, visited);
|
|
296
|
+
return;
|
|
297
|
+
case "ZodPipeline":
|
|
298
|
+
walkCapabilities(unwrapPipeIn(schema), capabilities, visited);
|
|
299
|
+
walkCapabilities(unwrapPipeOut(schema), capabilities, visited);
|
|
300
|
+
return;
|
|
301
|
+
case "ZodObject":
|
|
302
|
+
for (const sub of Object.values(getObjectShape(schema))) {
|
|
303
|
+
walkCapabilities(sub, capabilities, visited);
|
|
304
|
+
}
|
|
305
|
+
return;
|
|
306
|
+
case "ZodArray":
|
|
307
|
+
walkCapabilities(getArrayElement(schema), capabilities, visited);
|
|
308
|
+
return;
|
|
309
|
+
case "ZodTuple":
|
|
310
|
+
for (const item of getTupleItems(schema)) walkCapabilities(item, capabilities, visited);
|
|
311
|
+
return;
|
|
312
|
+
case "ZodUnion":
|
|
313
|
+
case "ZodDiscriminatedUnion":
|
|
314
|
+
if (typeName === "ZodDiscriminatedUnion") capabilities.discriminatedUnion = true;
|
|
315
|
+
for (const option of getUnionOptions(schema)) walkCapabilities(option, capabilities, visited);
|
|
316
|
+
return;
|
|
317
|
+
case "ZodIntersection":
|
|
318
|
+
walkCapabilities(getIntersectionLeft(schema), capabilities, visited);
|
|
319
|
+
walkCapabilities(getIntersectionRight(schema), capabilities, visited);
|
|
320
|
+
return;
|
|
321
|
+
case "ZodRecord":
|
|
322
|
+
walkCapabilities(getRecordKeyType(schema), capabilities, visited);
|
|
323
|
+
walkCapabilities(getRecordValueType(schema), capabilities, visited);
|
|
324
|
+
return;
|
|
325
|
+
case "ZodSet":
|
|
326
|
+
capabilities.mapOrSet = true;
|
|
327
|
+
walkCapabilities(getSetValueType(schema), capabilities, visited);
|
|
328
|
+
return;
|
|
329
|
+
case "ZodMap":
|
|
330
|
+
capabilities.mapOrSet = true;
|
|
331
|
+
walkCapabilities(getMapKeyType(schema), capabilities, visited);
|
|
332
|
+
walkCapabilities(getMapValueType(schema), capabilities, visited);
|
|
333
|
+
return;
|
|
410
334
|
}
|
|
411
|
-
return false;
|
|
412
335
|
}
|
|
336
|
+
const CONTAINER_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
337
|
+
"ZodObject",
|
|
338
|
+
"ZodArray",
|
|
339
|
+
"ZodTuple",
|
|
340
|
+
"ZodIntersection",
|
|
341
|
+
"ZodUnion",
|
|
342
|
+
"ZodDiscriminatedUnion",
|
|
343
|
+
"ZodRecord",
|
|
344
|
+
"ZodMap",
|
|
345
|
+
"ZodSet"
|
|
346
|
+
]);
|
|
413
347
|
function isContainerAfterWrapperPeel(schema) {
|
|
414
348
|
let cur = schema;
|
|
415
|
-
for (let i = 0; i < MAX_UNWRAP_STEPS$1; i++) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
349
|
+
for (let i = 0; i < MAX_UNWRAP_STEPS$1 && cur !== void 0; i++) {
|
|
350
|
+
const typeName = getTypeName(cur) ?? "";
|
|
351
|
+
switch (typeName) {
|
|
352
|
+
case "ZodOptional":
|
|
353
|
+
case "ZodNullable":
|
|
354
|
+
case "ZodDefault":
|
|
355
|
+
case "ZodCatch":
|
|
356
|
+
case "ZodReadonly":
|
|
357
|
+
cur = unwrapInner(cur);
|
|
358
|
+
break;
|
|
359
|
+
case "ZodBranded":
|
|
360
|
+
cur = unwrapBranded(cur);
|
|
361
|
+
break;
|
|
362
|
+
case "ZodLazy":
|
|
363
|
+
cur = unwrapLazy(cur);
|
|
364
|
+
break;
|
|
365
|
+
default:
|
|
366
|
+
return CONTAINER_TYPE_NAMES.has(typeName);
|
|
430
367
|
}
|
|
431
368
|
}
|
|
432
|
-
return
|
|
369
|
+
return false;
|
|
433
370
|
}
|
|
434
371
|
|
|
435
372
|
const V3_INTROSPECTOR = {
|
|
@@ -441,10 +378,7 @@ const V3_INTROSPECTOR = {
|
|
|
441
378
|
getLiteralValues,
|
|
442
379
|
isPreprocessNode,
|
|
443
380
|
isCoercePrimitive,
|
|
444
|
-
|
|
445
|
-
containsAsyncTransform,
|
|
446
|
-
containsDiscriminatedUnion,
|
|
447
|
-
hasContainerOrRootRefine,
|
|
381
|
+
capabilitiesOf,
|
|
448
382
|
// Walker accessors (D2 / D3 / D5).
|
|
449
383
|
getArrayElement,
|
|
450
384
|
getSetValueType,
|
|
@@ -469,6 +403,10 @@ const V3_INTROSPECTOR = {
|
|
|
469
403
|
getCatchDefault,
|
|
470
404
|
hasCatchValue
|
|
471
405
|
};
|
|
406
|
+
const V3_SUB_SCHEMA_INTROSPECTOR = {
|
|
407
|
+
...V3_INTROSPECTOR,
|
|
408
|
+
capabilitiesOf: scanCapabilities
|
|
409
|
+
};
|
|
472
410
|
|
|
473
411
|
function mapKeyAt(value, index) {
|
|
474
412
|
if (!(value instanceof Map)) return void 0;
|
|
@@ -536,7 +474,7 @@ function normalizeOne(path, rootSchema, data, maxRecursionDepth, peel) {
|
|
|
536
474
|
}
|
|
537
475
|
|
|
538
476
|
function slimPrimitivesV3(schema) {
|
|
539
|
-
return
|
|
477
|
+
return slimPrimitivesWalk(schema, V3_INTROSPECTOR, 64);
|
|
540
478
|
}
|
|
541
479
|
|
|
542
480
|
function rebuildWithDef(original, defPatch) {
|
|
@@ -605,6 +543,9 @@ function rebuildDiscriminatedUnion(original, options) {
|
|
|
605
543
|
}
|
|
606
544
|
return rebuildWithDef(original, { options, optionsMap });
|
|
607
545
|
}
|
|
546
|
+
function rebuildPipeline(original, inSide, outSide) {
|
|
547
|
+
return rebuildWithDef(original, { in: inSide, out: outSide });
|
|
548
|
+
}
|
|
608
549
|
function rebuildEffects(original, source, effect) {
|
|
609
550
|
return rebuildWithDef(original, { schema: source, effect });
|
|
610
551
|
}
|
|
@@ -680,7 +621,9 @@ function walkEffects(schema) {
|
|
|
680
621
|
}
|
|
681
622
|
if (isZodSchemaType(s, "ZodPipeline")) {
|
|
682
623
|
const inSide = unwrapPipeIn(s);
|
|
683
|
-
|
|
624
|
+
const outSide = unwrapPipeOut(s);
|
|
625
|
+
if (inSide === void 0 || outSide === void 0) return s;
|
|
626
|
+
return rebuildPipeline(s, recurse(inSide), recurse(outSide));
|
|
684
627
|
}
|
|
685
628
|
if (isZodSchemaType(s, "ZodObject")) {
|
|
686
629
|
const shape = getObjectShape(s);
|
|
@@ -818,29 +761,32 @@ function syncSafe(schema) {
|
|
|
818
761
|
return wrapped;
|
|
819
762
|
}
|
|
820
763
|
function buildV3Services(maxRecursionDepth) {
|
|
821
|
-
const mapOrSetBySchema = /* @__PURE__ */ new WeakMap();
|
|
822
764
|
const refileIssues = (schema, data, issues) => {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
hasMapOrSet = containsMapOrSet(schema);
|
|
826
|
-
mapOrSetBySchema.set(schema, hasMapOrSet);
|
|
765
|
+
if (!issues.some((issue) => issue.path.some((segment) => typeof segment === "number"))) {
|
|
766
|
+
return issues;
|
|
827
767
|
}
|
|
828
|
-
if (!
|
|
768
|
+
if (!capabilitiesOf(schema).mapOrSet) return issues;
|
|
829
769
|
return normalizeIssuePaths(issues, schema, data, maxRecursionDepth, peelAllV3Wrappers);
|
|
830
770
|
};
|
|
771
|
+
const validateSync = (schema, data) => {
|
|
772
|
+
if (capabilitiesOf(schema).asyncTransform) return [];
|
|
773
|
+
try {
|
|
774
|
+
const result = syncSafe(schema).safeParse(data);
|
|
775
|
+
return result.success ? [] : zodIssuesToValidationErrors(refileIssues(schema, data, result.error.issues));
|
|
776
|
+
} catch {
|
|
777
|
+
return [];
|
|
778
|
+
}
|
|
779
|
+
};
|
|
831
780
|
return {
|
|
832
781
|
getNestedSchemasAtPath: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
|
|
833
|
-
//
|
|
834
|
-
// slim
|
|
835
|
-
//
|
|
836
|
-
// candidates reflect the slim shape.
|
|
837
|
-
// The slim-root projection is gone (size-teardown P7): the shared
|
|
838
|
-
// path walker peels wrappers / effects inline, so the slim and
|
|
839
|
-
// unstripped walks coincide — same aliasing v4 always had.
|
|
782
|
+
// The shared path walker peels wrappers and effects inline, so the
|
|
783
|
+
// slim and unstripped walks coincide and the root needs no slim
|
|
784
|
+
// projection of its own. Same aliasing v4 has.
|
|
840
785
|
getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
|
|
841
786
|
slimPrimitivesOf: (schema, _maxRecursionDepth) => slimPrimitivesV3(schema),
|
|
842
787
|
deriveDefault: (schema, useDefault) => getDefaultValuesFromZodSchema(schema, useDefault),
|
|
843
788
|
runGetDefaults: (schema, config, maxRecursionDepth2) => runGetDefaultsV3(schema, config, maxRecursionDepth2),
|
|
789
|
+
validateSync,
|
|
844
790
|
unwrapStructuralWrappers: (schema) => unwrapStructuralLeafV3(schema),
|
|
845
791
|
unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
|
|
846
792
|
peelAllWrappers: (schema) => peelAllV3Wrappers(schema),
|
|
@@ -855,13 +801,13 @@ function buildV3Services(maxRecursionDepth) {
|
|
|
855
801
|
const result = await schema.safeParseAsync(data);
|
|
856
802
|
return result.success ? { success: true, data: result.data } : { success: false, issues: refileIssues(schema, data, result.error.issues) };
|
|
857
803
|
},
|
|
858
|
-
//
|
|
859
|
-
//
|
|
860
|
-
//
|
|
861
|
-
//
|
|
804
|
+
// A `getSchemasAtPath` consumer may probe any method on the result,
|
|
805
|
+
// so a sub-schema comes back as a full recursive AbstractSchema: the
|
|
806
|
+
// factory call rebuilds the whole surface against it, with its own
|
|
807
|
+
// per-form caches, and walks its capabilities without the memo.
|
|
862
808
|
makeSubSchema: (sub, maxRecursionDepth2) => createAbstractSchema(
|
|
863
809
|
sub,
|
|
864
|
-
|
|
810
|
+
V3_SUB_SCHEMA_INTROSPECTOR,
|
|
865
811
|
buildV3Services(maxRecursionDepth2),
|
|
866
812
|
{ maxRecursionDepth: maxRecursionDepth2 }
|
|
867
813
|
)
|
|
@@ -878,17 +824,16 @@ function zodIssuesToValidationErrors(issues) {
|
|
|
878
824
|
}
|
|
879
825
|
validationErrors.push({
|
|
880
826
|
message: issue.message,
|
|
881
|
-
// `ValidationError.path` is `(string | number)[]`
|
|
882
|
-
//
|
|
883
|
-
//
|
|
884
|
-
//
|
|
885
|
-
//
|
|
886
|
-
// Mirrors v4's behaviour at the same site.
|
|
827
|
+
// `ValidationError.path` is `(string | number)[]` publicly, and
|
|
828
|
+
// v3's `issue.path` matches in the standard case, but a custom
|
|
829
|
+
// check calling `ctx.addIssue({ path: [...] })` can smuggle a
|
|
830
|
+
// Symbol through. Coerce to keep the promise. v4 does the same
|
|
831
|
+
// here.
|
|
887
832
|
//
|
|
888
|
-
// Adapter-side paths stay schema-
|
|
889
|
-
//
|
|
890
|
-
//
|
|
891
|
-
//
|
|
833
|
+
// Adapter-side paths stay schema-RELATIVE: the validation pipeline
|
|
834
|
+
// in `core/create-form-store.ts` prepends the parent path to
|
|
835
|
+
// absolutise, then routes form-level entries, those whose absolute
|
|
836
|
+
// path is empty, to the empty-string bucket at storage time.
|
|
892
837
|
path: coercePathSegments(issue.path),
|
|
893
838
|
code
|
|
894
839
|
});
|
|
@@ -920,10 +865,10 @@ function unwrapStructuralLeafV3(schema) {
|
|
|
920
865
|
return current;
|
|
921
866
|
}
|
|
922
867
|
function isStructuralV3Kind(schema) {
|
|
923
|
-
return isZodSchemaType(schema, "ZodObject") || isZodSchemaType(schema, "ZodArray") || isZodSchemaType(schema, "ZodRecord") || isZodSchemaType(schema, "ZodTuple") || isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion") || // Wrappers that themselves resolve to a structural type
|
|
924
|
-
// peeling
|
|
925
|
-
isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodEffects") || // Newer transparent wrappers (v3.23+)
|
|
926
|
-
// schema with no structural impact
|
|
868
|
+
return isZodSchemaType(schema, "ZodObject") || isZodSchemaType(schema, "ZodArray") || isZodSchemaType(schema, "ZodRecord") || isZodSchemaType(schema, "ZodTuple") || isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion") || // Wrappers that themselves resolve to a structural type; keep
|
|
869
|
+
// peeling next iteration.
|
|
870
|
+
isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodEffects") || // Newer transparent wrappers (v3.23+), each wrapping one inner
|
|
871
|
+
// schema with no structural impact. `peelV3Wrappers` resolves them.
|
|
927
872
|
isZodSchemaType(schema, "ZodPipeline") || isZodSchemaType(schema, "ZodReadonly") || isZodSchemaType(schema, "ZodBranded");
|
|
928
873
|
}
|
|
929
874
|
function peelV3Wrappers(schema) {
|
|
@@ -1112,7 +1057,8 @@ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
|
|
|
1112
1057
|
rootSchema,
|
|
1113
1058
|
config.useDefaultSchemaValues
|
|
1114
1059
|
);
|
|
1115
|
-
|
|
1060
|
+
if (config.constraints === void 0) return defaultValuesWithoutConstraints;
|
|
1061
|
+
return fixStructuralDefaults(
|
|
1116
1062
|
rootSchema,
|
|
1117
1063
|
mergeDeep(defaultValuesWithoutConstraints, config.constraints),
|
|
1118
1064
|
config.useDefaultSchemaValues,
|
|
@@ -1124,34 +1070,6 @@ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
|
|
|
1124
1070
|
unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
|
|
1125
1071
|
}
|
|
1126
1072
|
).data;
|
|
1127
|
-
if (containsAsyncTransform(rootSchema)) {
|
|
1128
|
-
return {
|
|
1129
|
-
data: rawDefaultValues,
|
|
1130
|
-
errors: void 0,
|
|
1131
|
-
success: true
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
try {
|
|
1135
|
-
const parseResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
|
|
1136
|
-
if (parseResult.success) {
|
|
1137
|
-
return {
|
|
1138
|
-
data: rawDefaultValues,
|
|
1139
|
-
errors: void 0,
|
|
1140
|
-
success: true
|
|
1141
|
-
};
|
|
1142
|
-
}
|
|
1143
|
-
return {
|
|
1144
|
-
data: rawDefaultValues,
|
|
1145
|
-
errors: zodIssuesToValidationErrors(parseResult.error.issues),
|
|
1146
|
-
success: false
|
|
1147
|
-
};
|
|
1148
|
-
} catch {
|
|
1149
|
-
return {
|
|
1150
|
-
data: rawDefaultValues,
|
|
1151
|
-
errors: void 0,
|
|
1152
|
-
success: true
|
|
1153
|
-
};
|
|
1154
|
-
}
|
|
1155
1073
|
}
|
|
1156
1074
|
|
|
1157
1075
|
function useForm(configuration) {
|