attaform 0.28.0 → 0.30.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 -5
- package/dist/abstract.mjs +4 -4
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
- package/dist/dev/chunks/devtools.mjs +1 -1
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +3 -3
- package/dist/dev/shared/{attaform-dev.oYrkP9dj.mjs → attaform-dev.BK6Ge2qR.mjs} +80 -341
- package/dist/dev/shared/{attaform-dev.Dr2YzS5B.mjs → attaform-dev.BQc5QV3Y.mjs} +11 -19
- package/dist/dev/shared/{attaform-dev.BR8u0YOZ.mjs → attaform-dev.BcNtyOmf.mjs} +4 -4
- package/dist/{shared/attaform.h0i6LijT.mjs → dev/shared/attaform-dev.BcYT6tFh.mjs} +152 -20
- package/dist/dev/shared/{attaform-dev.6qxD-Yqo.mjs → attaform-dev.BisFstxh.mjs} +227 -88
- package/dist/dev/shared/{attaform-dev.WmuhD_CZ.mjs → attaform-dev.CQ2rJiAX.mjs} +833 -656
- package/dist/dev/shared/{attaform-dev.P7cseiEG.mjs → attaform-dev.D6CLvaQT.mjs} +20 -11
- package/dist/dev/shared/{attaform-dev.D2I8e_Mm.mjs → attaform-dev.DTrHonpc.mjs} +225 -238
- package/dist/dev/shared/{attaform-dev.BXE2cr0L.mjs → attaform-dev.DUZckyV8.mjs} +1 -3
- 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 +2 -2
- package/dist/directive.mjs +1 -1
- package/dist/history.d.mts +1 -1
- package/dist/history.mjs +1 -2
- package/dist/index.d.mts +9 -7
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.mts +11 -20
- package/dist/nuxt.mjs +0 -1
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/shared/{attaform.uLbun31C.mjs → attaform.B3resMQ1.mjs} +19 -11
- package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -139
- package/dist/{dev/shared/attaform-dev.By4PRjt0.mjs → shared/attaform.BRDDQeHV.mjs} +136 -26
- package/dist/shared/{attaform.NLmerepI.mjs → attaform.BXneBxEj.mjs} +71 -334
- package/dist/shared/{attaform.D6DCnnQu.mjs → attaform.ByWP6kSx.mjs} +4 -4
- package/dist/shared/{attaform.CJP3RkGa.mjs → attaform.CJ8DpRGj.mjs} +223 -238
- package/dist/shared/{attaform.C09fpdLS.mjs → attaform.CUfrMK7t.mjs} +227 -88
- package/dist/shared/{attaform.wfY8XFvm.mjs → attaform.CdZIEf7_.mjs} +11 -19
- package/dist/shared/{attaform.JfSWdEcb.d.mts → attaform.Clz0ArIi.d.mts} +1 -1
- package/dist/shared/{attaform.B8k8JrmK.mjs → attaform.DNJOWjQw.mjs} +826 -612
- package/dist/shared/{attaform.B4VkS43-.d.mts → attaform.Rc9u4Vfw.d.mts} +1 -1
- package/dist/shared/{attaform.D5V4tZWq.d.mts → attaform.UGyOK83T.d.mts} +200 -218
- package/dist/shared/{attaform.Dq4vWxuG.mjs → attaform.WiGdIqgx.mjs} +1 -3
- package/dist/shared/{attaform.Cgu-hdSb.d.mts → attaform.bKLzMU0o.d.mts} +321 -523
- package/dist/transforms.d.mts +0 -22
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +13 -4
- package/dist/vite.mjs +8 -2
- package/dist/zod-v3.d.mts +6 -4
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +18 -31
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +5 -5
- package/package.json +19 -15
- package/skills/attaform/SKILL.md +6 -3
- package/skills/attaform/references/custom-components.md +8 -3
- package/skills/attaform/references/errors.md +8 -3
- package/skills/attaform/references/saving.md +77 -0
- package/skills/attaform/references/wizards.md +10 -8
- package/dist/chunks/fingerprint.mjs +0 -183
- package/dist/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/chunks/fingerprint.mjs +0 -183
- package/dist/dev/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/shared/attaform-dev.BJGA_UOS.mjs +0 -36
- package/dist/shared/attaform.BJGA_UOS.mjs +0 -36
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.
|
|
3
|
-
import { s as slimPrimitivesWalk, d as deriveDefaultWalk, m as mergeDeep, f as fixStructuralDefaults, w as walkPathSegments, c as createAbstractSchema, b as buildFieldMetaPathMap,
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
let warnedZodCodeMissing = false;
|
|
7
|
-
function zodIssuesToValidationErrors(issues) {
|
|
8
|
-
return issues.map((issue) => {
|
|
9
|
-
let code;
|
|
10
|
-
if (typeof issue.code === "string" && issue.code.length > 0) {
|
|
11
|
-
code = `zod:${issue.code}`;
|
|
12
|
-
} else {
|
|
13
|
-
code = "zod:unknown";
|
|
14
|
-
if (!warnedZodCodeMissing) {
|
|
15
|
-
warnedZodCodeMissing = true;
|
|
16
|
-
console.warn(
|
|
17
|
-
"[attaform] zod-v4 adapter received an issue with no string `code`; stamping `'zod:unknown'`. This usually means a custom Zod plugin emitted an issue without the standard code field."
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
message: issue.message,
|
|
23
|
-
// Adapter-side paths stay schema-relative — the validation
|
|
24
|
-
// pipeline in `create-form-store.ts` prepends the parent path
|
|
25
|
-
// to absolutise, then routes form-level (absolute path length 0)
|
|
26
|
-
// entries to the empty-string bucket at storage time.
|
|
27
|
-
path: issue.path.map((seg) => typeof seg === "number" ? seg : String(seg)),
|
|
28
|
-
code
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
class UnsupportedSchemaError extends AttaformError {
|
|
33
|
-
}
|
|
1
|
+
import { j as humanize, c as useAbstractForm } from './attaform-dev.CQ2rJiAX.mjs';
|
|
2
|
+
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.BQc5QV3Y.mjs';
|
|
3
|
+
import { s as slimPrimitivesWalk, d as deriveDefaultWalk, m as mergeDeep, f as fixStructuralDefaults, w as walkPathSegments, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, e as getFieldMetaListForSchema, g as getFieldMetaForSchema } from './attaform-dev.BisFstxh.mjs';
|
|
4
|
+
import { c as callConsumerSchemaFn } from './attaform-dev.BcYT6tFh.mjs';
|
|
34
5
|
|
|
35
6
|
function readDef(schema) {
|
|
36
7
|
if (schema === null || typeof schema !== "object") return void 0;
|
|
@@ -77,7 +48,9 @@ const IDENTITY_KINDS = /* @__PURE__ */ new Set([
|
|
|
77
48
|
"file",
|
|
78
49
|
"map",
|
|
79
50
|
"symbol",
|
|
80
|
-
"function"
|
|
51
|
+
"function",
|
|
52
|
+
"nonoptional",
|
|
53
|
+
"success"
|
|
81
54
|
]);
|
|
82
55
|
function kindOf(schema) {
|
|
83
56
|
const def = readDef(schema);
|
|
@@ -110,6 +83,8 @@ function getRecordValueType(schema) {
|
|
|
110
83
|
const def = readDef(schema);
|
|
111
84
|
return def?.valueType;
|
|
112
85
|
}
|
|
86
|
+
const getMapKeyType = getRecordKeyType;
|
|
87
|
+
const getMapValueType = getRecordValueType;
|
|
113
88
|
function getTupleItems(schema) {
|
|
114
89
|
const def = readDef(schema);
|
|
115
90
|
return def?.items ?? [];
|
|
@@ -156,11 +131,7 @@ function unwrapLazy(schema) {
|
|
|
156
131
|
const def = readDef(schema);
|
|
157
132
|
const getter = def?.getter;
|
|
158
133
|
if (typeof getter !== "function") return void 0;
|
|
159
|
-
return getter();
|
|
160
|
-
}
|
|
161
|
-
function getLazyGetter(schema) {
|
|
162
|
-
const def = readDef(schema);
|
|
163
|
-
return typeof def?.getter === "function" ? def.getter : void 0;
|
|
134
|
+
return callConsumerSchemaFn(() => getter(), void 0, "lazy-getter");
|
|
164
135
|
}
|
|
165
136
|
function getIntersectionLeft(schema) {
|
|
166
137
|
const def = readDef(schema);
|
|
@@ -174,11 +145,11 @@ function getCatchDefault(schema) {
|
|
|
174
145
|
const def = readDef(schema);
|
|
175
146
|
const cv = def?.catchValue;
|
|
176
147
|
if (typeof cv !== "function") return void 0;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
148
|
+
return callConsumerSchemaFn(
|
|
149
|
+
() => cv({ error: new Error("atta:default-values"), input: void 0 }),
|
|
150
|
+
void 0,
|
|
151
|
+
"catch-factory"
|
|
152
|
+
);
|
|
182
153
|
}
|
|
183
154
|
function hasCatchValue(schema) {
|
|
184
155
|
const def = readDef(schema);
|
|
@@ -186,7 +157,7 @@ function hasCatchValue(schema) {
|
|
|
186
157
|
}
|
|
187
158
|
function getDefaultValue(schema) {
|
|
188
159
|
const def = readDef(schema);
|
|
189
|
-
return def?.defaultValue;
|
|
160
|
+
return callConsumerSchemaFn(() => def?.defaultValue, void 0, "default-factory");
|
|
190
161
|
}
|
|
191
162
|
function getNativeEnumValues(_schema) {
|
|
192
163
|
return void 0;
|
|
@@ -197,11 +168,6 @@ function unwrapEffectsSource(_schema) {
|
|
|
197
168
|
function unwrapBranded(_schema) {
|
|
198
169
|
return void 0;
|
|
199
170
|
}
|
|
200
|
-
function hasChecks(schema) {
|
|
201
|
-
const def = readDef(schema);
|
|
202
|
-
const checks = def?.checks;
|
|
203
|
-
return Array.isArray(checks) && checks.length > 0;
|
|
204
|
-
}
|
|
205
171
|
function getChecks(schema) {
|
|
206
172
|
const def = readDef(schema);
|
|
207
173
|
const checks = def?.checks;
|
|
@@ -335,123 +301,6 @@ function isAsyncCheck(check) {
|
|
|
335
301
|
return fn.constructor.name === "AsyncFunction";
|
|
336
302
|
}
|
|
337
303
|
|
|
338
|
-
const UNSUPPORTED = [
|
|
339
|
-
"promise",
|
|
340
|
-
"custom",
|
|
341
|
-
"template-literal",
|
|
342
|
-
"map",
|
|
343
|
-
"symbol",
|
|
344
|
-
"function"
|
|
345
|
-
];
|
|
346
|
-
function labelPath(path) {
|
|
347
|
-
return path.length === 0 ? "<root>" : path.join(".");
|
|
348
|
-
}
|
|
349
|
-
function assertSupportedKinds(schema, path = [], lazyGetters = []) {
|
|
350
|
-
const kind = kindOf(schema);
|
|
351
|
-
if (UNSUPPORTED.includes(kind)) {
|
|
352
|
-
throw new UnsupportedSchemaError(
|
|
353
|
-
`[attaform/zod] unsupported kind '${kind}' at '${labelPath(path)}'`
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
switch (kind) {
|
|
357
|
-
case "object": {
|
|
358
|
-
const shape = getObjectShape(schema);
|
|
359
|
-
for (const [key, sub] of Object.entries(shape)) {
|
|
360
|
-
assertSupportedKinds(sub, [...path, key], lazyGetters);
|
|
361
|
-
}
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
case "array":
|
|
365
|
-
assertSupportedKinds(getArrayElement(schema), [...path, "*"], lazyGetters);
|
|
366
|
-
return;
|
|
367
|
-
case "set":
|
|
368
|
-
assertSupportedKinds(getSetValueType(schema), [...path, "*"], lazyGetters);
|
|
369
|
-
return;
|
|
370
|
-
case "record":
|
|
371
|
-
assertSupportedKinds(getRecordValueType(schema), [...path, "*"], lazyGetters);
|
|
372
|
-
return;
|
|
373
|
-
case "tuple": {
|
|
374
|
-
const items = getTupleItems(schema);
|
|
375
|
-
items.forEach((item, i) => assertSupportedKinds(item, [...path, String(i)], lazyGetters));
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
case "union": {
|
|
379
|
-
const options = getUnionOptions(schema);
|
|
380
|
-
options.forEach((opt, i) => assertSupportedKinds(opt, [...path, `|${i}`], lazyGetters));
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
case "discriminated-union": {
|
|
384
|
-
const options = getDiscriminatedOptions(schema);
|
|
385
|
-
options.forEach((opt, i) => assertSupportedKinds(opt, [...path, `|${i}`], lazyGetters));
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
case "optional":
|
|
389
|
-
case "nullable":
|
|
390
|
-
case "default":
|
|
391
|
-
case "readonly":
|
|
392
|
-
case "catch": {
|
|
393
|
-
const inner = unwrapInner(schema);
|
|
394
|
-
if (inner !== void 0) assertSupportedKinds(inner, path, lazyGetters);
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
case "pipe": {
|
|
398
|
-
const inner = unwrapPipe(schema);
|
|
399
|
-
if (inner !== void 0) assertSupportedKinds(inner, path, lazyGetters);
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
case "lazy": {
|
|
403
|
-
const getter = getLazyGetter(schema);
|
|
404
|
-
if (getter !== void 0 && lazyGetters.includes(getter)) return;
|
|
405
|
-
const inner = unwrapLazy(schema);
|
|
406
|
-
if (inner !== void 0) {
|
|
407
|
-
assertSupportedKinds(
|
|
408
|
-
inner,
|
|
409
|
-
path,
|
|
410
|
-
getter === void 0 ? lazyGetters : [...lazyGetters, getter]
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
case "intersection": {
|
|
416
|
-
const left = getIntersectionLeft(schema);
|
|
417
|
-
const right = getIntersectionRight(schema);
|
|
418
|
-
if (left !== void 0) assertSupportedKinds(left, [...path, "left"], lazyGetters);
|
|
419
|
-
if (right !== void 0) assertSupportedKinds(right, [...path, "right"], lazyGetters);
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
// Leaves: nothing to descend into.
|
|
423
|
-
case "string":
|
|
424
|
-
case "number":
|
|
425
|
-
case "boolean":
|
|
426
|
-
case "bigint":
|
|
427
|
-
case "date":
|
|
428
|
-
case "enum":
|
|
429
|
-
case "literal":
|
|
430
|
-
case "null":
|
|
431
|
-
case "undefined":
|
|
432
|
-
case "nan":
|
|
433
|
-
case "any":
|
|
434
|
-
case "unknown":
|
|
435
|
-
case "void":
|
|
436
|
-
case "never":
|
|
437
|
-
case "promise":
|
|
438
|
-
case "custom":
|
|
439
|
-
case "template-literal":
|
|
440
|
-
case "transform":
|
|
441
|
-
case "file":
|
|
442
|
-
case "map":
|
|
443
|
-
case "symbol":
|
|
444
|
-
case "function":
|
|
445
|
-
return;
|
|
446
|
-
default: {
|
|
447
|
-
const _exhaustive = kind;
|
|
448
|
-
throw new Error(
|
|
449
|
-
`assertSupportedKinds: unhandled ZodKind '${_exhaustive}'`
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
304
|
function unwrapToDiscriminatedUnion(schema) {
|
|
456
305
|
let current = schema;
|
|
457
306
|
for (let i = 0; i < 64; i++) {
|
|
@@ -478,6 +327,33 @@ function unwrapToDiscriminatedUnion(schema) {
|
|
|
478
327
|
return void 0;
|
|
479
328
|
}
|
|
480
329
|
|
|
330
|
+
let warnedZodCodeMissing = false;
|
|
331
|
+
function zodIssuesToValidationErrors(issues) {
|
|
332
|
+
return issues.map((issue) => {
|
|
333
|
+
let code;
|
|
334
|
+
if (typeof issue.code === "string" && issue.code.length > 0) {
|
|
335
|
+
code = `zod:${issue.code}`;
|
|
336
|
+
} else {
|
|
337
|
+
code = "zod:unknown";
|
|
338
|
+
if (!warnedZodCodeMissing) {
|
|
339
|
+
warnedZodCodeMissing = true;
|
|
340
|
+
console.warn(
|
|
341
|
+
"[attaform] zod-v4 adapter received an issue with no string `code`; stamping `'zod:unknown'`. This usually means a custom Zod plugin emitted an issue without the standard code field."
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
message: issue.message,
|
|
347
|
+
// Adapter-side paths stay schema-relative — the validation
|
|
348
|
+
// pipeline in `create-form-store.ts` prepends the parent path
|
|
349
|
+
// to absolutise, then routes form-level (absolute path length 0)
|
|
350
|
+
// entries to the empty-string bucket at storage time.
|
|
351
|
+
path: issue.path.map((seg) => typeof seg === "number" ? seg : String(seg)),
|
|
352
|
+
code
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
481
357
|
const V4_INTROSPECTOR = {
|
|
482
358
|
kindOf: (schema) => kindOf(schema),
|
|
483
359
|
getObjectShape: (schema) => getObjectShape(schema),
|
|
@@ -497,8 +373,9 @@ const V4_INTROSPECTOR = {
|
|
|
497
373
|
return getArrayElement(schema);
|
|
498
374
|
},
|
|
499
375
|
getSetValueType: (schema) => kindOf(schema) === "set" ? getSetValueType(schema) : void 0,
|
|
500
|
-
getRecordKeyType: (schema) => kindOf(schema) === "record" ? getRecordKeyType(schema) : void 0,
|
|
501
376
|
getRecordValueType: (schema) => kindOf(schema) === "record" ? getRecordValueType(schema) : void 0,
|
|
377
|
+
getMapKeyType: (schema) => kindOf(schema) === "map" ? getMapKeyType(schema) : void 0,
|
|
378
|
+
getMapValueType: (schema) => kindOf(schema) === "map" ? getMapValueType(schema) : void 0,
|
|
502
379
|
getUnionOptions,
|
|
503
380
|
getIntersectionLeft,
|
|
504
381
|
getIntersectionRight,
|
|
@@ -510,7 +387,6 @@ const V4_INTROSPECTOR = {
|
|
|
510
387
|
unwrapPipeIn,
|
|
511
388
|
unwrapPipeOut,
|
|
512
389
|
unwrapLazy,
|
|
513
|
-
getLazyGetter,
|
|
514
390
|
getDefaultValue,
|
|
515
391
|
getCatchDefault,
|
|
516
392
|
hasCatchValue
|
|
@@ -521,15 +397,12 @@ function slimPrimitivesOf(schema, maxRecursionDepth) {
|
|
|
521
397
|
}
|
|
522
398
|
|
|
523
399
|
function deriveDefault(schema, useDefault, maxRecursionDepth) {
|
|
524
|
-
return deriveDefaultWalk(schema, useDefault, V4_INTROSPECTOR, maxRecursionDepth
|
|
525
|
-
// v4 has an exhaustive switch against `SchemaIntrospector.kindOf`;
|
|
526
|
-
// unknown kinds genuinely shouldn't appear, so return undefined.
|
|
527
|
-
unsupportedKindFallback: () => void 0
|
|
528
|
-
});
|
|
400
|
+
return deriveDefaultWalk(schema, useDefault, V4_INTROSPECTOR, maxRecursionDepth);
|
|
529
401
|
}
|
|
530
402
|
function getDefaultValuesFromZodSchema(opts) {
|
|
531
403
|
const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts;
|
|
532
404
|
const initial = deriveDefault(schema, useDefaultSchemaValues, maxRecursionDepth);
|
|
405
|
+
if (constraints === void 0) return { data: initial, success: true };
|
|
533
406
|
const merged = mergeDeep(initial, constraints);
|
|
534
407
|
return fixStructuralDefaults(
|
|
535
408
|
schema,
|
|
@@ -561,137 +434,6 @@ function getNestedZodSchemasAtPath(schema, path, maxRecursionDepth) {
|
|
|
561
434
|
);
|
|
562
435
|
}
|
|
563
436
|
|
|
564
|
-
function carrySyncChecks(rebuilt, original) {
|
|
565
|
-
if (!hasChecks(original)) return rebuilt;
|
|
566
|
-
const checks = getChecks(original).filter((c) => !isAsyncCheck(c));
|
|
567
|
-
if (checks.length === 0) return rebuilt;
|
|
568
|
-
return rebuilt.check(
|
|
569
|
-
...checks
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
function stripAsyncChecks(schema) {
|
|
573
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
574
|
-
function recurse(s) {
|
|
575
|
-
if (seen.has(s)) return s;
|
|
576
|
-
seen.add(s);
|
|
577
|
-
const kind = kindOf(s);
|
|
578
|
-
switch (kind) {
|
|
579
|
-
case "string":
|
|
580
|
-
return hasChecks(s) ? carrySyncChecks(z.string(), s) : s;
|
|
581
|
-
case "number":
|
|
582
|
-
return hasChecks(s) ? carrySyncChecks(z.number(), s) : s;
|
|
583
|
-
case "bigint":
|
|
584
|
-
return hasChecks(s) ? carrySyncChecks(z.bigint(), s) : s;
|
|
585
|
-
case "array": {
|
|
586
|
-
const element = getArrayElement(s);
|
|
587
|
-
return carrySyncChecks(z.array(recurse(element)), s);
|
|
588
|
-
}
|
|
589
|
-
case "set": {
|
|
590
|
-
return carrySyncChecks(z.set(recurse(getSetValueType(s))), s);
|
|
591
|
-
}
|
|
592
|
-
case "tuple": {
|
|
593
|
-
const items = getTupleItems(s).map(recurse);
|
|
594
|
-
const rebuilt = z.tuple(
|
|
595
|
-
items
|
|
596
|
-
);
|
|
597
|
-
return carrySyncChecks(rebuilt, s);
|
|
598
|
-
}
|
|
599
|
-
case "object": {
|
|
600
|
-
const shape = getObjectShape(s);
|
|
601
|
-
const next = {};
|
|
602
|
-
for (const [k, v] of Object.entries(shape)) {
|
|
603
|
-
next[k] = recurse(v);
|
|
604
|
-
}
|
|
605
|
-
return carrySyncChecks(z.object(next), s);
|
|
606
|
-
}
|
|
607
|
-
case "record": {
|
|
608
|
-
const keyType = getRecordKeyType(s);
|
|
609
|
-
const valueType = recurse(getRecordValueType(s));
|
|
610
|
-
return carrySyncChecks(
|
|
611
|
-
z.record(keyType, valueType),
|
|
612
|
-
s
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
case "union": {
|
|
616
|
-
const options = getUnionOptions(s).map(recurse);
|
|
617
|
-
return carrySyncChecks(
|
|
618
|
-
z.union(options),
|
|
619
|
-
s
|
|
620
|
-
);
|
|
621
|
-
}
|
|
622
|
-
case "discriminated-union": {
|
|
623
|
-
const options = getDiscriminatedOptions(s).map((opt) => recurse(opt));
|
|
624
|
-
const discriminator = getDiscriminator(s);
|
|
625
|
-
if (discriminator === void 0) return s;
|
|
626
|
-
return z.discriminatedUnion(
|
|
627
|
-
discriminator,
|
|
628
|
-
options
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
case "optional": {
|
|
632
|
-
const inner = unwrapInner(s);
|
|
633
|
-
return inner === void 0 ? s : recurse(inner).optional();
|
|
634
|
-
}
|
|
635
|
-
case "nullable": {
|
|
636
|
-
const inner = unwrapInner(s);
|
|
637
|
-
return inner === void 0 ? s : recurse(inner).nullable();
|
|
638
|
-
}
|
|
639
|
-
case "default": {
|
|
640
|
-
const inner = unwrapInner(s);
|
|
641
|
-
if (inner === void 0) return s;
|
|
642
|
-
return recurse(inner).default(getDefaultValue(s));
|
|
643
|
-
}
|
|
644
|
-
case "readonly": {
|
|
645
|
-
const inner = unwrapInner(s);
|
|
646
|
-
return inner === void 0 ? s : recurse(inner).readonly();
|
|
647
|
-
}
|
|
648
|
-
case "lazy": {
|
|
649
|
-
const inner = unwrapLazy(s);
|
|
650
|
-
if (inner === void 0) return s;
|
|
651
|
-
const stripped = recurse(inner);
|
|
652
|
-
return z.lazy(() => stripped);
|
|
653
|
-
}
|
|
654
|
-
case "intersection": {
|
|
655
|
-
const left = getIntersectionLeft(s);
|
|
656
|
-
const right = getIntersectionRight(s);
|
|
657
|
-
if (left === void 0 || right === void 0) return s;
|
|
658
|
-
return z.intersection(recurse(left), recurse(right));
|
|
659
|
-
}
|
|
660
|
-
case "catch": {
|
|
661
|
-
const inner = unwrapInner(s);
|
|
662
|
-
if (inner === void 0) return s;
|
|
663
|
-
return recurse(inner).catch(getCatchDefault(s));
|
|
664
|
-
}
|
|
665
|
-
// Pipes pass through (see the docblock); the rest are leaves
|
|
666
|
-
// whose checks the strip walker deliberately leaves in place —
|
|
667
|
-
// an async check on one of these still poisons the sync parse
|
|
668
|
-
// and the callers' defensive catch owns that case.
|
|
669
|
-
case "pipe":
|
|
670
|
-
case "boolean":
|
|
671
|
-
case "date":
|
|
672
|
-
case "enum":
|
|
673
|
-
case "literal":
|
|
674
|
-
case "null":
|
|
675
|
-
case "undefined":
|
|
676
|
-
case "any":
|
|
677
|
-
case "unknown":
|
|
678
|
-
case "nan":
|
|
679
|
-
case "void":
|
|
680
|
-
case "never":
|
|
681
|
-
case "promise":
|
|
682
|
-
case "custom":
|
|
683
|
-
case "template-literal":
|
|
684
|
-
case "transform":
|
|
685
|
-
case "file":
|
|
686
|
-
case "map":
|
|
687
|
-
case "symbol":
|
|
688
|
-
case "function":
|
|
689
|
-
return s;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
return recurse(schema);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
437
|
function unwrapStructuralWrappers(schema) {
|
|
696
438
|
let current = schema;
|
|
697
439
|
for (let i = 0; i < 64; i++) {
|
|
@@ -704,6 +446,13 @@ function unwrapStructuralWrappers(schema) {
|
|
|
704
446
|
}
|
|
705
447
|
return current;
|
|
706
448
|
}
|
|
449
|
+
function assertKeyedRoot(rootSchema) {
|
|
450
|
+
const kind = kindOf(peelAllWrappers(rootSchema));
|
|
451
|
+
if (kind === "object" || kind === "record" || kind === "discriminated-union") return;
|
|
452
|
+
throw new AttaformError(
|
|
453
|
+
`[attaform/zod] useForm schema root must be a ZodObject, ZodRecord, or ZodDiscriminatedUnion (got '${kind}'). Wrap other shapes under a key.`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
707
456
|
function peelAllWrappers(schema) {
|
|
708
457
|
let current = schema;
|
|
709
458
|
for (let i = 0; i < 64; i++) {
|
|
@@ -777,22 +526,21 @@ function isLeafRequired(schema, depth = 0) {
|
|
|
777
526
|
}
|
|
778
527
|
function zodV4Adapter(rootSchema) {
|
|
779
528
|
assertZodVersion(rootSchema);
|
|
780
|
-
|
|
781
|
-
return (
|
|
529
|
+
assertKeyedRoot(rootSchema);
|
|
530
|
+
return (_formKey, options) => sharedV4Schemas(
|
|
782
531
|
rootSchema,
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
532
|
+
options.maxRecursionDepth,
|
|
533
|
+
() => createAbstractSchema(
|
|
534
|
+
rootSchema,
|
|
535
|
+
V4_INTROSPECTOR,
|
|
536
|
+
buildV4Services(),
|
|
537
|
+
options
|
|
538
|
+
)
|
|
787
539
|
);
|
|
788
540
|
}
|
|
789
|
-
|
|
790
|
-
const { fingerprintZodSchema } = await import('../chunks/fingerprint2.mjs');
|
|
791
|
-
return fingerprintZodSchema(schema);
|
|
792
|
-
}
|
|
541
|
+
const sharedV4Schemas = createSharedSchemaStore();
|
|
793
542
|
function buildV4Services() {
|
|
794
543
|
return {
|
|
795
|
-
fingerprint: (schema) => lazyFingerprint(schema),
|
|
796
544
|
getNestedSchemasAtPath: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
|
|
797
545
|
// v4 doesn't pre-strip for the slim-mode walk — its path walker
|
|
798
546
|
// already peels every transparent wrapper inline, so the slim and
|
|
@@ -800,7 +548,7 @@ function buildV4Services() {
|
|
|
800
548
|
getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
|
|
801
549
|
slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),
|
|
802
550
|
deriveDefault: (schema, useDefault, maxRecursionDepth) => deriveDefault(schema, useDefault, maxRecursionDepth),
|
|
803
|
-
|
|
551
|
+
runGetDefaults: (schema, config, maxRecursionDepth) => runGetDefaultsV4(schema, config, maxRecursionDepth),
|
|
804
552
|
unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),
|
|
805
553
|
unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
|
|
806
554
|
peelAllWrappers: (schema) => peelAllWrappers(schema),
|
|
@@ -815,47 +563,40 @@ function buildV4Services() {
|
|
|
815
563
|
const result = await schema.safeParseAsync(data);
|
|
816
564
|
return result.success ? { success: true, data: result.data } : { success: false, issues: result.error.issues };
|
|
817
565
|
},
|
|
818
|
-
makeSubSchema: (schema,
|
|
566
|
+
makeSubSchema: (schema, maxRecursionDepth) => buildSubSchemaStubV4(schema, maxRecursionDepth)
|
|
819
567
|
};
|
|
820
568
|
}
|
|
821
|
-
function
|
|
569
|
+
function runGetDefaultsV4(rootSchema, config, maxRecursionDepth) {
|
|
822
570
|
const { data } = getDefaultValuesFromZodSchema({
|
|
823
571
|
schema: rootSchema,
|
|
824
572
|
useDefaultSchemaValues: config.useDefaultSchemaValues,
|
|
825
573
|
constraints: config.constraints,
|
|
826
574
|
maxRecursionDepth
|
|
827
575
|
});
|
|
828
|
-
if (
|
|
829
|
-
return { data, errors: void 0, success: true
|
|
830
|
-
}
|
|
831
|
-
if (containsAsyncTransform(rootSchema)) {
|
|
832
|
-
return { data, errors: void 0, success: true, formKey };
|
|
576
|
+
if (containsAsyncTransform(rootSchema) || containsAsyncRefine(rootSchema)) {
|
|
577
|
+
return { data, errors: void 0, success: true };
|
|
833
578
|
}
|
|
834
|
-
const parseTarget = containsAsyncRefine(rootSchema) ? stripAsyncChecks(rootSchema) : rootSchema;
|
|
835
579
|
try {
|
|
836
|
-
const
|
|
837
|
-
if (
|
|
838
|
-
return { data, errors: void 0, success: true
|
|
580
|
+
const parseResult = rootSchema.safeParse(data);
|
|
581
|
+
if (parseResult.success) {
|
|
582
|
+
return { data, errors: void 0, success: true };
|
|
839
583
|
}
|
|
840
584
|
return {
|
|
841
585
|
data,
|
|
842
|
-
errors: zodIssuesToValidationErrors(
|
|
843
|
-
success: false
|
|
844
|
-
formKey
|
|
586
|
+
errors: zodIssuesToValidationErrors(parseResult.error.issues),
|
|
587
|
+
success: false
|
|
845
588
|
};
|
|
846
589
|
} catch {
|
|
847
|
-
return { data, errors: void 0, success: true
|
|
590
|
+
return { data, errors: void 0, success: true };
|
|
848
591
|
}
|
|
849
592
|
}
|
|
850
|
-
function buildSubSchemaStubV4(schema,
|
|
593
|
+
function buildSubSchemaStubV4(schema, maxRecursionDepth) {
|
|
851
594
|
return {
|
|
852
|
-
fingerprint: () => lazyFingerprint(schema),
|
|
853
595
|
needsAsyncValidation: () => containsAsyncRefine(schema),
|
|
854
596
|
getDefaultValues: () => ({
|
|
855
597
|
data: deriveDefault(schema, true, maxRecursionDepth),
|
|
856
598
|
errors: void 0,
|
|
857
|
-
success: true
|
|
858
|
-
formKey
|
|
599
|
+
success: true
|
|
859
600
|
}),
|
|
860
601
|
getSchemasAtPath: () => [],
|
|
861
602
|
validateAtPath: async (data) => {
|
|
@@ -864,15 +605,13 @@ function buildSubSchemaStubV4(schema, formKey, maxRecursionDepth) {
|
|
|
864
605
|
return {
|
|
865
606
|
data: result.data,
|
|
866
607
|
errors: void 0,
|
|
867
|
-
success: true
|
|
868
|
-
formKey
|
|
608
|
+
success: true
|
|
869
609
|
};
|
|
870
610
|
}
|
|
871
611
|
return {
|
|
872
612
|
data: void 0,
|
|
873
613
|
errors: zodIssuesToValidationErrors(result.error.issues),
|
|
874
|
-
success: false
|
|
875
|
-
formKey
|
|
614
|
+
success: false
|
|
876
615
|
};
|
|
877
616
|
}
|
|
878
617
|
};
|
|
@@ -924,4 +663,4 @@ function useForm(configuration) {
|
|
|
924
663
|
});
|
|
925
664
|
}
|
|
926
665
|
|
|
927
|
-
export {
|
|
666
|
+
export { assertZodVersion as a, kindOf as k, useForm as u, zodV4Adapter as z };
|
|
@@ -40,12 +40,6 @@ function normalizeErrorInputs(input, scope, defaultCode) {
|
|
|
40
40
|
const items = Array.isArray(input) ? input : [input];
|
|
41
41
|
return items.map((item) => normalizeErrorInput(item, scope, defaultCode));
|
|
42
42
|
}
|
|
43
|
-
function* cellEntriesFor(cells, side) {
|
|
44
|
-
for (const [key, cell] of cells) {
|
|
45
|
-
const list = cell[side];
|
|
46
|
-
if (list.length > 0) yield [key, list];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
43
|
class RegistryNotInstalledError extends AttaformError {
|
|
50
44
|
constructor() {
|
|
51
45
|
super(
|
|
@@ -79,6 +73,16 @@ function groupErrorsByKey(entries) {
|
|
|
79
73
|
}
|
|
80
74
|
|
|
81
75
|
const INTEGER_SEGMENT = /^(?:0|[1-9]\d*)$/;
|
|
76
|
+
const SET_MEMBER_SEGMENT = "__atta:member";
|
|
77
|
+
function mapSegmentKeys(value) {
|
|
78
|
+
const keys = [];
|
|
79
|
+
for (const key of value.keys()) {
|
|
80
|
+
if (typeof key === "string") keys.push(key);
|
|
81
|
+
else if (typeof key === "number" && Number.isInteger(key) && key >= 0) keys.push(key);
|
|
82
|
+
else return null;
|
|
83
|
+
}
|
|
84
|
+
return keys;
|
|
85
|
+
}
|
|
82
86
|
function normalizeSegment(raw) {
|
|
83
87
|
if (typeof raw === "number") {
|
|
84
88
|
if (!Number.isInteger(raw) || raw < 0) {
|
|
@@ -165,18 +169,6 @@ function pathKeyToDotted(key) {
|
|
|
165
169
|
if (segments === null) return null;
|
|
166
170
|
return segmentsToDotted(segments);
|
|
167
171
|
}
|
|
168
|
-
function coerceToPathKey(input) {
|
|
169
|
-
if (input.length > 0 && input.charCodeAt(0) === 91) {
|
|
170
|
-
try {
|
|
171
|
-
const parsed = JSON.parse(input);
|
|
172
|
-
if (Array.isArray(parsed) && parsed.every((s) => typeof s === "string" || typeof s === "number")) {
|
|
173
|
-
return input;
|
|
174
|
-
}
|
|
175
|
-
} catch {
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return canonicalizePath(input).key;
|
|
179
|
-
}
|
|
180
172
|
const ROOT_PATH = Object.freeze([]);
|
|
181
173
|
const ROOT_PATH_KEY = "[]";
|
|
182
174
|
function isPathPrefix(prefix, path) {
|
|
@@ -194,4 +186,4 @@ function pathsEqual(a, b) {
|
|
|
194
186
|
return true;
|
|
195
187
|
}
|
|
196
188
|
|
|
197
|
-
export { AttaformError as A, InvalidPathError as I, OutsideSetupError as O, ROOT_PATH as R, SubmitErrorHandlerError as S, InvalidUseFormConfigError as a, ROOT_PATH_KEY as b, RegistryNotInstalledError as c, ReservedFormKeyError as d, canonicalizePath as e, pathsEqual as f, pathKeyToDotted as g,
|
|
189
|
+
export { AttaformError as A, InvalidPathError as I, OutsideSetupError as O, ROOT_PATH as R, SubmitErrorHandlerError as S, InvalidUseFormConfigError as a, ROOT_PATH_KEY as b, RegistryNotInstalledError as c, ReservedFormKeyError as d, canonicalizePath as e, pathsEqual as f, pathKeyToDotted as g, SET_MEMBER_SEGMENT as h, isPathPrefix as i, groupErrorsByKey as j, keyForSegments as k, normalizeErrorInputs as l, mapSegmentKeys as m, normalizeErrorInput as n, parseDottedPath as p, segmentsForPathKey as s, toError as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as InvalidUseFormConfigError } from './attaform-dev.
|
|
2
|
-
import { u as useForm$2 } from './attaform-dev.
|
|
3
|
-
import { u as useForm$1 } from './attaform-dev.
|
|
4
|
-
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.
|
|
1
|
+
import { a as InvalidUseFormConfigError } from './attaform-dev.BQc5QV3Y.mjs';
|
|
2
|
+
import { u as useForm$2 } from './attaform-dev.DTrHonpc.mjs';
|
|
3
|
+
import { u as useForm$1 } from './attaform-dev.BK6Ge2qR.mjs';
|
|
4
|
+
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.BisFstxh.mjs';
|
|
5
5
|
|
|
6
6
|
function isZodV4SchemaShape(value) {
|
|
7
7
|
if (typeof value !== "object" || value === null) return false;
|