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