@tonyclaw/llm-inspector 1.9.6 → 1.9.7
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/.output/nitro.json +1 -1
- package/.output/public/assets/index-Cc1oV0hF.css +1 -0
- package/.output/public/assets/index-DTjsqi6U.js +11 -0
- package/.output/public/assets/index-DrYcBTSK.js +122 -0
- package/.output/server/_chunks/ssr-renderer.mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +1 -1
- package/.output/server/_libs/ajv-formats.mjs +18 -18
- package/.output/server/_libs/ajv.mjs +196 -196
- package/.output/server/_libs/cookie-es.mjs +7 -21
- package/.output/server/_libs/h3-v2.mjs +18 -7
- package/.output/server/_libs/h3.mjs +24 -16
- package/.output/server/_libs/jszip.mjs +28 -28
- package/.output/server/_libs/pako.mjs +13 -13
- package/.output/server/_libs/radix-ui__react-collection.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-id.mjs +1 -1
- package/.output/server/_libs/react-dom.mjs +5 -5
- package/.output/server/_libs/react.mjs +43 -43
- package/.output/server/_libs/readable-stream.mjs +15 -15
- package/.output/server/_libs/safe-buffer.mjs +3 -3
- package/.output/server/_libs/semver.mjs +10 -10
- package/.output/server/_libs/seroval-plugins.mjs +5 -5
- package/.output/server/_libs/seroval.mjs +606 -596
- package/.output/server/_libs/srvx.mjs +110 -46
- package/.output/server/_libs/swr.mjs +1 -1
- package/.output/server/_libs/tanstack__history.mjs +31 -44
- package/.output/server/_libs/tanstack__react-router.mjs +781 -1090
- package/.output/server/_libs/tanstack__router-core.mjs +2223 -2328
- package/.output/server/_libs/tslib.mjs +5 -5
- package/.output/server/_libs/use-sync-external-store.mjs +1 -1
- package/.output/server/_libs/zod.mjs +503 -205
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +6 -0
- package/.output/server/_ssr/{index--OdB29Fv.mjs → index-Lxfn0bBE.mjs} +31 -13
- package/.output/server/_ssr/index.mjs +1100 -777
- package/.output/server/_ssr/{router-CY_hgLPo.mjs → router-CXva8nm-.mjs} +26 -7
- package/.output/server/_tanstack-start-manifest_v-Cb2CDJtB.mjs +4 -0
- package/.output/server/index.mjs +26 -25
- package/README.md +50 -11
- package/package.json +1 -1
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +35 -2
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +25 -11
- package/src/proxy/formats/openai/schemas.ts +6 -0
- package/src/proxy/formats/openai/stream.ts +8 -0
- package/src/proxy/handler.ts +6 -2
- package/.output/public/assets/index-Bjuk3Pry.css +0 -1
- package/.output/public/assets/index-DtK6Ymig.js +0 -97
- package/.output/public/assets/main-ClWp6y0D.js +0 -17
- package/.output/server/_libs/tiny-invariant.mjs +0 -12
- package/.output/server/_libs/tiny-warning.mjs +0 -5
- package/.output/server/_tanstack-start-manifest_v-bpFJzmyh.mjs +0 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a$1;
|
|
1
2
|
function $constructor(name, initializer2, params) {
|
|
2
3
|
function init(inst, def) {
|
|
3
4
|
if (!inst._zod) {
|
|
@@ -60,7 +61,8 @@ class $ZodEncodeError extends Error {
|
|
|
60
61
|
this.name = "ZodEncodeError";
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
65
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
64
66
|
function config(newConfig) {
|
|
65
67
|
return globalConfig;
|
|
66
68
|
}
|
|
@@ -94,19 +96,12 @@ function cleanRegex(source) {
|
|
|
94
96
|
return source.slice(start, end);
|
|
95
97
|
}
|
|
96
98
|
function floatSafeRemainder(val, step) {
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
stepDecCount = Number.parseInt(match[1]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
107
|
-
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
108
|
-
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
109
|
-
return valInt % stepInt / 10 ** decCount;
|
|
99
|
+
const ratio = val / step;
|
|
100
|
+
const roundedRatio = Math.round(ratio);
|
|
101
|
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
102
|
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
103
|
+
return 0;
|
|
104
|
+
return ratio - roundedRatio;
|
|
110
105
|
}
|
|
111
106
|
const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
112
107
|
function defineLazy(object2, key, getter) {
|
|
@@ -158,7 +153,10 @@ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace
|
|
|
158
153
|
function isObject(data) {
|
|
159
154
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
160
155
|
}
|
|
161
|
-
const allowsEval = cached(() => {
|
|
156
|
+
const allowsEval = /* @__PURE__ */ cached(() => {
|
|
157
|
+
if (globalConfig.jitless) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
162
160
|
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
163
161
|
return false;
|
|
164
162
|
}
|
|
@@ -191,6 +189,10 @@ function shallowClone(o) {
|
|
|
191
189
|
return { ...o };
|
|
192
190
|
if (Array.isArray(o))
|
|
193
191
|
return [...o];
|
|
192
|
+
if (o instanceof Map)
|
|
193
|
+
return new Map(o);
|
|
194
|
+
if (o instanceof Set)
|
|
195
|
+
return new Set(o);
|
|
194
196
|
return o;
|
|
195
197
|
}
|
|
196
198
|
const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
@@ -318,6 +320,9 @@ function safeExtend(schema, shape) {
|
|
|
318
320
|
return clone(schema, def);
|
|
319
321
|
}
|
|
320
322
|
function merge(a, b) {
|
|
323
|
+
if (a._zod.def.checks?.length) {
|
|
324
|
+
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
325
|
+
}
|
|
321
326
|
const def = mergeDefs(a._zod.def, {
|
|
322
327
|
get shape() {
|
|
323
328
|
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
@@ -327,8 +332,7 @@ function merge(a, b) {
|
|
|
327
332
|
get catchall() {
|
|
328
333
|
return b._zod.def.catchall;
|
|
329
334
|
},
|
|
330
|
-
checks: []
|
|
331
|
-
// delete existing checks
|
|
335
|
+
checks: b._zod.def.checks ?? []
|
|
332
336
|
});
|
|
333
337
|
return clone(a, def);
|
|
334
338
|
}
|
|
@@ -411,6 +415,16 @@ function aborted(x, startIndex = 0) {
|
|
|
411
415
|
}
|
|
412
416
|
return false;
|
|
413
417
|
}
|
|
418
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
419
|
+
if (x.aborted === true)
|
|
420
|
+
return true;
|
|
421
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
422
|
+
if (x.issues[i]?.continue === false) {
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
414
428
|
function prefixIssues(path, issues) {
|
|
415
429
|
return issues.map((iss) => {
|
|
416
430
|
var _a2;
|
|
@@ -423,17 +437,14 @@ function unwrapMessage(message) {
|
|
|
423
437
|
return typeof message === "string" ? message : message?.message;
|
|
424
438
|
}
|
|
425
439
|
function finalizeIssue(iss, ctx, config2) {
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
delete full.continue;
|
|
433
|
-
if (!ctx?.reportInput) {
|
|
434
|
-
delete full.input;
|
|
440
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
|
|
441
|
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
442
|
+
rest.path ?? (rest.path = []);
|
|
443
|
+
rest.message = message;
|
|
444
|
+
if (ctx?.reportInput) {
|
|
445
|
+
rest.input = _input;
|
|
435
446
|
}
|
|
436
|
-
return
|
|
447
|
+
return rest;
|
|
437
448
|
}
|
|
438
449
|
function getLengthableOrigin(input) {
|
|
439
450
|
if (Array.isArray(input))
|
|
@@ -487,30 +498,33 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
487
498
|
}
|
|
488
499
|
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
489
500
|
const fieldErrors = { _errors: [] };
|
|
490
|
-
const processError = (error2) => {
|
|
501
|
+
const processError = (error2, path = []) => {
|
|
491
502
|
for (const issue2 of error2.issues) {
|
|
492
503
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
493
|
-
issue2.errors.map((issues) => processError({ issues }));
|
|
504
|
+
issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
|
|
494
505
|
} else if (issue2.code === "invalid_key") {
|
|
495
|
-
processError({ issues: issue2.issues });
|
|
506
|
+
processError({ issues: issue2.issues }, [...path, ...issue2.path]);
|
|
496
507
|
} else if (issue2.code === "invalid_element") {
|
|
497
|
-
processError({ issues: issue2.issues });
|
|
498
|
-
} else if (issue2.path.length === 0) {
|
|
499
|
-
fieldErrors._errors.push(mapper(issue2));
|
|
508
|
+
processError({ issues: issue2.issues }, [...path, ...issue2.path]);
|
|
500
509
|
} else {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
510
|
+
const fullpath = [...path, ...issue2.path];
|
|
511
|
+
if (fullpath.length === 0) {
|
|
512
|
+
fieldErrors._errors.push(mapper(issue2));
|
|
513
|
+
} else {
|
|
514
|
+
let curr = fieldErrors;
|
|
515
|
+
let i = 0;
|
|
516
|
+
while (i < fullpath.length) {
|
|
517
|
+
const el = fullpath[i];
|
|
518
|
+
const terminal = i === fullpath.length - 1;
|
|
519
|
+
if (!terminal) {
|
|
520
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
521
|
+
} else {
|
|
522
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
523
|
+
curr[el]._errors.push(mapper(issue2));
|
|
524
|
+
}
|
|
525
|
+
curr = curr[el];
|
|
526
|
+
i++;
|
|
511
527
|
}
|
|
512
|
-
curr = curr[el];
|
|
513
|
-
i++;
|
|
514
528
|
}
|
|
515
529
|
}
|
|
516
530
|
}
|
|
@@ -519,7 +533,7 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
519
533
|
return fieldErrors;
|
|
520
534
|
}
|
|
521
535
|
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
522
|
-
const ctx = _ctx ?
|
|
536
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
523
537
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
524
538
|
if (result instanceof Promise) {
|
|
525
539
|
throw new $ZodAsyncError();
|
|
@@ -532,7 +546,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
532
546
|
return result.value;
|
|
533
547
|
};
|
|
534
548
|
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
535
|
-
const ctx = _ctx ?
|
|
549
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
536
550
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
537
551
|
if (result instanceof Promise)
|
|
538
552
|
result = await result;
|
|
@@ -556,7 +570,7 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
556
570
|
};
|
|
557
571
|
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
558
572
|
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
559
|
-
const ctx = _ctx ?
|
|
573
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
560
574
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
561
575
|
if (result instanceof Promise)
|
|
562
576
|
result = await result;
|
|
@@ -567,34 +581,34 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
567
581
|
};
|
|
568
582
|
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
569
583
|
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
570
|
-
const ctx = _ctx ?
|
|
584
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
571
585
|
return _parse(_Err)(schema, value, ctx);
|
|
572
586
|
};
|
|
573
587
|
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
574
588
|
return _parse(_Err)(schema, value, _ctx);
|
|
575
589
|
};
|
|
576
590
|
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
577
|
-
const ctx = _ctx ?
|
|
591
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
578
592
|
return _parseAsync(_Err)(schema, value, ctx);
|
|
579
593
|
};
|
|
580
594
|
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
581
595
|
return _parseAsync(_Err)(schema, value, _ctx);
|
|
582
596
|
};
|
|
583
597
|
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
584
|
-
const ctx = _ctx ?
|
|
598
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
585
599
|
return _safeParse(_Err)(schema, value, ctx);
|
|
586
600
|
};
|
|
587
601
|
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
588
602
|
return _safeParse(_Err)(schema, value, _ctx);
|
|
589
603
|
};
|
|
590
604
|
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
591
|
-
const ctx = _ctx ?
|
|
605
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
592
606
|
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
593
607
|
};
|
|
594
608
|
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
595
609
|
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
596
610
|
};
|
|
597
|
-
const cuid = /^[cC][
|
|
611
|
+
const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
598
612
|
const cuid2 = /^[0-9a-z]+$/;
|
|
599
613
|
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
600
614
|
const xid = /^[0-9a-vA-V]{20}$/;
|
|
@@ -618,6 +632,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
|
|
|
618
632
|
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
619
633
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
620
634
|
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
635
|
+
const httpProtocol = /^https?$/;
|
|
621
636
|
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
622
637
|
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
623
638
|
const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
@@ -1073,8 +1088,8 @@ class Doc {
|
|
|
1073
1088
|
}
|
|
1074
1089
|
const version = {
|
|
1075
1090
|
major: 4,
|
|
1076
|
-
minor:
|
|
1077
|
-
patch:
|
|
1091
|
+
minor: 4,
|
|
1092
|
+
patch: 3
|
|
1078
1093
|
};
|
|
1079
1094
|
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1080
1095
|
var _a2;
|
|
@@ -1102,6 +1117,8 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1102
1117
|
let asyncResult;
|
|
1103
1118
|
for (const ch of checks2) {
|
|
1104
1119
|
if (ch._zod.def.when) {
|
|
1120
|
+
if (explicitlyAborted(payload))
|
|
1121
|
+
continue;
|
|
1105
1122
|
const shouldRun = ch._zod.def.when(payload);
|
|
1106
1123
|
if (!shouldRun)
|
|
1107
1124
|
continue;
|
|
@@ -1242,6 +1259,19 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
1242
1259
|
inst._zod.check = (payload) => {
|
|
1243
1260
|
try {
|
|
1244
1261
|
const trimmed = payload.value.trim();
|
|
1262
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
1263
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
1264
|
+
payload.issues.push({
|
|
1265
|
+
code: "invalid_format",
|
|
1266
|
+
format: "url",
|
|
1267
|
+
note: "Invalid URL format",
|
|
1268
|
+
input: payload.value,
|
|
1269
|
+
inst,
|
|
1270
|
+
continue: !def.abort
|
|
1271
|
+
});
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1245
1275
|
const url = new URL(trimmed);
|
|
1246
1276
|
if (def.hostname) {
|
|
1247
1277
|
def.hostname.lastIndex = 0;
|
|
@@ -1390,6 +1420,8 @@ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
1390
1420
|
function isValidBase64(data) {
|
|
1391
1421
|
if (data === "")
|
|
1392
1422
|
return true;
|
|
1423
|
+
if (/\s/.test(data))
|
|
1424
|
+
return false;
|
|
1393
1425
|
if (data.length % 4 !== 0)
|
|
1394
1426
|
return false;
|
|
1395
1427
|
try {
|
|
@@ -1597,15 +1629,27 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1597
1629
|
return payload;
|
|
1598
1630
|
};
|
|
1599
1631
|
});
|
|
1600
|
-
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
1632
|
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
|
1633
|
+
const isPresent = key in input;
|
|
1601
1634
|
if (result.issues.length) {
|
|
1602
|
-
if (isOptionalOut && !
|
|
1635
|
+
if (isOptionalIn && isOptionalOut && !isPresent) {
|
|
1603
1636
|
return;
|
|
1604
1637
|
}
|
|
1605
1638
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1606
1639
|
}
|
|
1640
|
+
if (!isPresent && !isOptionalIn) {
|
|
1641
|
+
if (!result.issues.length) {
|
|
1642
|
+
final.issues.push({
|
|
1643
|
+
code: "invalid_type",
|
|
1644
|
+
expected: "nonoptional",
|
|
1645
|
+
input: void 0,
|
|
1646
|
+
path: [key]
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1607
1651
|
if (result.value === void 0) {
|
|
1608
|
-
if (
|
|
1652
|
+
if (isPresent) {
|
|
1609
1653
|
final.value[key] = void 0;
|
|
1610
1654
|
}
|
|
1611
1655
|
} else {
|
|
@@ -1633,8 +1677,11 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1633
1677
|
const keySet = def.keySet;
|
|
1634
1678
|
const _catchall = def.catchall._zod;
|
|
1635
1679
|
const t = _catchall.def.type;
|
|
1680
|
+
const isOptionalIn = _catchall.optin === "optional";
|
|
1636
1681
|
const isOptionalOut = _catchall.optout === "optional";
|
|
1637
1682
|
for (const key in input) {
|
|
1683
|
+
if (key === "__proto__")
|
|
1684
|
+
continue;
|
|
1638
1685
|
if (keySet.has(key))
|
|
1639
1686
|
continue;
|
|
1640
1687
|
if (t === "never") {
|
|
@@ -1643,9 +1690,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1643
1690
|
}
|
|
1644
1691
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1645
1692
|
if (r instanceof Promise) {
|
|
1646
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
1693
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1647
1694
|
} else {
|
|
1648
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1695
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
1649
1696
|
}
|
|
1650
1697
|
}
|
|
1651
1698
|
if (unrecognized.length) {
|
|
@@ -1711,12 +1758,13 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
1711
1758
|
const shape = value.shape;
|
|
1712
1759
|
for (const key of value.keys) {
|
|
1713
1760
|
const el = shape[key];
|
|
1761
|
+
const isOptionalIn = el._zod.optin === "optional";
|
|
1714
1762
|
const isOptionalOut = el._zod.optout === "optional";
|
|
1715
1763
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1716
1764
|
if (r instanceof Promise) {
|
|
1717
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
1765
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1718
1766
|
} else {
|
|
1719
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1767
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
1720
1768
|
}
|
|
1721
1769
|
}
|
|
1722
1770
|
if (!catchall) {
|
|
@@ -1747,9 +1795,10 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
1747
1795
|
const id = ids[key];
|
|
1748
1796
|
const k = esc(key);
|
|
1749
1797
|
const schema = shape[key];
|
|
1798
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
1750
1799
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1751
1800
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1752
|
-
if (isOptionalOut) {
|
|
1801
|
+
if (isOptionalIn && isOptionalOut) {
|
|
1753
1802
|
doc.write(`
|
|
1754
1803
|
if (${id}.issues.length) {
|
|
1755
1804
|
if (${k} in input) {
|
|
@@ -1768,6 +1817,33 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
1768
1817
|
newResult[${k}] = ${id}.value;
|
|
1769
1818
|
}
|
|
1770
1819
|
|
|
1820
|
+
`);
|
|
1821
|
+
} else if (!isOptionalIn) {
|
|
1822
|
+
doc.write(`
|
|
1823
|
+
const ${id}_present = ${k} in input;
|
|
1824
|
+
if (${id}.issues.length) {
|
|
1825
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1826
|
+
...iss,
|
|
1827
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1828
|
+
})));
|
|
1829
|
+
}
|
|
1830
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
1831
|
+
payload.issues.push({
|
|
1832
|
+
code: "invalid_type",
|
|
1833
|
+
expected: "nonoptional",
|
|
1834
|
+
input: undefined,
|
|
1835
|
+
path: [${k}]
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
if (${id}_present) {
|
|
1840
|
+
if (${id}.value === undefined) {
|
|
1841
|
+
newResult[${k}] = undefined;
|
|
1842
|
+
} else {
|
|
1843
|
+
newResult[${k}] = ${id}.value;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1771
1847
|
`);
|
|
1772
1848
|
} else {
|
|
1773
1849
|
doc.write(`
|
|
@@ -1861,10 +1937,9 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
1861
1937
|
}
|
|
1862
1938
|
return void 0;
|
|
1863
1939
|
});
|
|
1864
|
-
const
|
|
1865
|
-
const first = def.options[0]._zod.run;
|
|
1940
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
1866
1941
|
inst._zod.parse = (payload, ctx) => {
|
|
1867
|
-
if (
|
|
1942
|
+
if (first) {
|
|
1868
1943
|
return first(payload, ctx);
|
|
1869
1944
|
}
|
|
1870
1945
|
let async = false;
|
|
@@ -1941,7 +2016,7 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
|
|
|
1941
2016
|
if (opt) {
|
|
1942
2017
|
return opt._zod.run(payload, ctx);
|
|
1943
2018
|
}
|
|
1944
|
-
if (def.unionFallback) {
|
|
2019
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
1945
2020
|
return _super(payload, ctx);
|
|
1946
2021
|
}
|
|
1947
2022
|
payload.issues.push({
|
|
@@ -1949,6 +2024,7 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
|
|
|
1949
2024
|
errors: [],
|
|
1950
2025
|
note: "No matching discriminator",
|
|
1951
2026
|
discriminator: def.discriminator,
|
|
2027
|
+
options: Array.from(disc.value.keys()),
|
|
1952
2028
|
input,
|
|
1953
2029
|
path: [def.discriminator],
|
|
1954
2030
|
inst
|
|
@@ -2075,19 +2151,35 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2075
2151
|
for (const key of values) {
|
|
2076
2152
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
2077
2153
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2154
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2155
|
+
if (keyResult instanceof Promise) {
|
|
2156
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
2157
|
+
}
|
|
2158
|
+
if (keyResult.issues.length) {
|
|
2159
|
+
payload.issues.push({
|
|
2160
|
+
code: "invalid_key",
|
|
2161
|
+
origin: "record",
|
|
2162
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
2163
|
+
input: key,
|
|
2164
|
+
path: [key],
|
|
2165
|
+
inst
|
|
2166
|
+
});
|
|
2167
|
+
continue;
|
|
2168
|
+
}
|
|
2169
|
+
const outKey = keyResult.value;
|
|
2078
2170
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2079
2171
|
if (result instanceof Promise) {
|
|
2080
2172
|
proms.push(result.then((result2) => {
|
|
2081
2173
|
if (result2.issues.length) {
|
|
2082
2174
|
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
2083
2175
|
}
|
|
2084
|
-
payload.value[
|
|
2176
|
+
payload.value[outKey] = result2.value;
|
|
2085
2177
|
}));
|
|
2086
2178
|
} else {
|
|
2087
2179
|
if (result.issues.length) {
|
|
2088
2180
|
payload.issues.push(...prefixIssues(key, result.issues));
|
|
2089
2181
|
}
|
|
2090
|
-
payload.value[
|
|
2182
|
+
payload.value[outKey] = result.value;
|
|
2091
2183
|
}
|
|
2092
2184
|
}
|
|
2093
2185
|
}
|
|
@@ -2111,6 +2203,8 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
2111
2203
|
for (const key of Reflect.ownKeys(input)) {
|
|
2112
2204
|
if (key === "__proto__")
|
|
2113
2205
|
continue;
|
|
2206
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
|
2207
|
+
continue;
|
|
2114
2208
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2115
2209
|
if (keyResult instanceof Promise) {
|
|
2116
2210
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -2206,6 +2300,7 @@ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
2206
2300
|
});
|
|
2207
2301
|
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
2208
2302
|
$ZodType.init(inst, def);
|
|
2303
|
+
inst._zod.optin = "optional";
|
|
2209
2304
|
inst._zod.parse = (payload, ctx) => {
|
|
2210
2305
|
if (ctx.direction === "backward") {
|
|
2211
2306
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -2215,6 +2310,7 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
|
|
|
2215
2310
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
2216
2311
|
return output.then((output2) => {
|
|
2217
2312
|
payload.value = output2;
|
|
2313
|
+
payload.fallback = true;
|
|
2218
2314
|
return payload;
|
|
2219
2315
|
});
|
|
2220
2316
|
}
|
|
@@ -2222,11 +2318,12 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
|
|
|
2222
2318
|
throw new $ZodAsyncError();
|
|
2223
2319
|
}
|
|
2224
2320
|
payload.value = _out;
|
|
2321
|
+
payload.fallback = true;
|
|
2225
2322
|
return payload;
|
|
2226
2323
|
};
|
|
2227
2324
|
});
|
|
2228
2325
|
function handleOptionalResult(result, input) {
|
|
2229
|
-
if (result.issues.length
|
|
2326
|
+
if (input === void 0 && (result.issues.length || result.fallback)) {
|
|
2230
2327
|
return { issues: [], value: void 0 };
|
|
2231
2328
|
}
|
|
2232
2329
|
return result;
|
|
@@ -2244,10 +2341,11 @@ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) =>
|
|
|
2244
2341
|
});
|
|
2245
2342
|
inst._zod.parse = (payload, ctx) => {
|
|
2246
2343
|
if (def.innerType._zod.optin === "optional") {
|
|
2344
|
+
const input = payload.value;
|
|
2247
2345
|
const result = def.innerType._zod.run(payload, ctx);
|
|
2248
2346
|
if (result instanceof Promise)
|
|
2249
|
-
return result.then((r) => handleOptionalResult(r,
|
|
2250
|
-
return handleOptionalResult(result,
|
|
2347
|
+
return result.then((r) => handleOptionalResult(r, input));
|
|
2348
|
+
return handleOptionalResult(result, input);
|
|
2251
2349
|
}
|
|
2252
2350
|
if (payload.value === void 0) {
|
|
2253
2351
|
return payload;
|
|
@@ -2346,7 +2444,7 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
2346
2444
|
}
|
|
2347
2445
|
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
2348
2446
|
$ZodType.init(inst, def);
|
|
2349
|
-
|
|
2447
|
+
inst._zod.optin = "optional";
|
|
2350
2448
|
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2351
2449
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2352
2450
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2366,6 +2464,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
2366
2464
|
input: payload.value
|
|
2367
2465
|
});
|
|
2368
2466
|
payload.issues = [];
|
|
2467
|
+
payload.fallback = true;
|
|
2369
2468
|
}
|
|
2370
2469
|
return payload;
|
|
2371
2470
|
});
|
|
@@ -2380,6 +2479,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
2380
2479
|
input: payload.value
|
|
2381
2480
|
});
|
|
2382
2481
|
payload.issues = [];
|
|
2482
|
+
payload.fallback = true;
|
|
2383
2483
|
}
|
|
2384
2484
|
return payload;
|
|
2385
2485
|
};
|
|
@@ -2410,7 +2510,7 @@ function handlePipeResult(left, next, ctx) {
|
|
|
2410
2510
|
left.aborted = true;
|
|
2411
2511
|
return left;
|
|
2412
2512
|
}
|
|
2413
|
-
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
2513
|
+
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
|
|
2414
2514
|
}
|
|
2415
2515
|
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2416
2516
|
$ZodType.init(inst, def);
|
|
@@ -2435,7 +2535,12 @@ function handleReadonlyResult(payload) {
|
|
|
2435
2535
|
}
|
|
2436
2536
|
const $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
|
|
2437
2537
|
$ZodType.init(inst, def);
|
|
2438
|
-
defineLazy(inst._zod, "innerType", () =>
|
|
2538
|
+
defineLazy(inst._zod, "innerType", () => {
|
|
2539
|
+
const d = def;
|
|
2540
|
+
if (!d._cachedInner)
|
|
2541
|
+
d._cachedInner = def.getter();
|
|
2542
|
+
return d._cachedInner;
|
|
2543
|
+
});
|
|
2439
2544
|
defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
2440
2545
|
defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
2441
2546
|
defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
|
|
@@ -3009,7 +3114,7 @@ function _refine(Class, fn, _params) {
|
|
|
3009
3114
|
return schema;
|
|
3010
3115
|
}
|
|
3011
3116
|
// @__NO_SIDE_EFFECTS__
|
|
3012
|
-
function _superRefine(fn) {
|
|
3117
|
+
function _superRefine(fn, params) {
|
|
3013
3118
|
const ch = /* @__PURE__ */ _check((payload) => {
|
|
3014
3119
|
payload.addIssue = (issue$1) => {
|
|
3015
3120
|
if (typeof issue$1 === "string") {
|
|
@@ -3026,7 +3131,7 @@ function _superRefine(fn) {
|
|
|
3026
3131
|
}
|
|
3027
3132
|
};
|
|
3028
3133
|
return fn(payload.value, payload);
|
|
3029
|
-
});
|
|
3134
|
+
}, params);
|
|
3030
3135
|
return ch;
|
|
3031
3136
|
}
|
|
3032
3137
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -3107,7 +3212,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
3107
3212
|
delete result.schema.examples;
|
|
3108
3213
|
delete result.schema.default;
|
|
3109
3214
|
}
|
|
3110
|
-
if (ctx.io === "input" && result.schema
|
|
3215
|
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
3111
3216
|
(_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
|
|
3112
3217
|
delete result.schema._prefault;
|
|
3113
3218
|
const _result = ctx.seen.get(schema);
|
|
@@ -3288,10 +3393,15 @@ function finalize(ctx, schema) {
|
|
|
3288
3393
|
result.$id = ctx.external.uri(id);
|
|
3289
3394
|
}
|
|
3290
3395
|
Object.assign(result, root.def ?? root.schema);
|
|
3396
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
3397
|
+
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
3398
|
+
delete result.id;
|
|
3291
3399
|
const defs = ctx.external?.defs ?? {};
|
|
3292
3400
|
for (const entry of ctx.seen.entries()) {
|
|
3293
3401
|
const seen = entry[1];
|
|
3294
3402
|
if (seen.def && seen.defId) {
|
|
3403
|
+
if (seen.def.id === seen.defId)
|
|
3404
|
+
delete seen.def.id;
|
|
3295
3405
|
defs[seen.defId] = seen.def;
|
|
3296
3406
|
}
|
|
3297
3407
|
}
|
|
@@ -3347,6 +3457,8 @@ function isTransforming(_schema, _ctx) {
|
|
|
3347
3457
|
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
3348
3458
|
}
|
|
3349
3459
|
if (def.type === "pipe") {
|
|
3460
|
+
if (_schema._zod.traits.has("$ZodCodec"))
|
|
3461
|
+
return true;
|
|
3350
3462
|
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
3351
3463
|
}
|
|
3352
3464
|
if (def.type === "object") {
|
|
@@ -3434,39 +3546,28 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
3434
3546
|
json.type = "integer";
|
|
3435
3547
|
else
|
|
3436
3548
|
json.type = "number";
|
|
3437
|
-
|
|
3438
|
-
|
|
3549
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3550
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3551
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
3552
|
+
if (exMin) {
|
|
3553
|
+
if (legacy) {
|
|
3439
3554
|
json.minimum = exclusiveMinimum;
|
|
3440
3555
|
json.exclusiveMinimum = true;
|
|
3441
3556
|
} else {
|
|
3442
3557
|
json.exclusiveMinimum = exclusiveMinimum;
|
|
3443
3558
|
}
|
|
3444
|
-
}
|
|
3445
|
-
if (typeof minimum === "number") {
|
|
3559
|
+
} else if (typeof minimum === "number") {
|
|
3446
3560
|
json.minimum = minimum;
|
|
3447
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
3448
|
-
if (exclusiveMinimum >= minimum)
|
|
3449
|
-
delete json.minimum;
|
|
3450
|
-
else
|
|
3451
|
-
delete json.exclusiveMinimum;
|
|
3452
|
-
}
|
|
3453
3561
|
}
|
|
3454
|
-
if (
|
|
3455
|
-
if (
|
|
3562
|
+
if (exMax) {
|
|
3563
|
+
if (legacy) {
|
|
3456
3564
|
json.maximum = exclusiveMaximum;
|
|
3457
3565
|
json.exclusiveMaximum = true;
|
|
3458
3566
|
} else {
|
|
3459
3567
|
json.exclusiveMaximum = exclusiveMaximum;
|
|
3460
3568
|
}
|
|
3461
|
-
}
|
|
3462
|
-
if (typeof maximum === "number") {
|
|
3569
|
+
} else if (typeof maximum === "number") {
|
|
3463
3570
|
json.maximum = maximum;
|
|
3464
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
3465
|
-
if (exclusiveMaximum <= maximum)
|
|
3466
|
-
delete json.maximum;
|
|
3467
|
-
else
|
|
3468
|
-
delete json.exclusiveMaximum;
|
|
3469
|
-
}
|
|
3470
3571
|
}
|
|
3471
3572
|
if (typeof multipleOf === "number")
|
|
3472
3573
|
json.multipleOf = multipleOf;
|
|
@@ -3555,7 +3656,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
3555
3656
|
if (typeof maximum === "number")
|
|
3556
3657
|
json.maxItems = maximum;
|
|
3557
3658
|
json.type = "array";
|
|
3558
|
-
json.items = process(def.element, ctx, {
|
|
3659
|
+
json.items = process(def.element, ctx, {
|
|
3660
|
+
...params,
|
|
3661
|
+
path: [...params.path, "items"]
|
|
3662
|
+
});
|
|
3559
3663
|
};
|
|
3560
3664
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
3561
3665
|
const json = _json;
|
|
@@ -3706,7 +3810,8 @@ const catchProcessor = (schema, ctx, json, params) => {
|
|
|
3706
3810
|
};
|
|
3707
3811
|
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
3708
3812
|
const def = schema._zod.def;
|
|
3709
|
-
const
|
|
3813
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
3814
|
+
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
3710
3815
|
process(innerType, ctx, params);
|
|
3711
3816
|
const seen = ctx.seen.get(schema);
|
|
3712
3817
|
seen.ref = innerType;
|
|
@@ -3792,7 +3897,7 @@ const initializer = (inst, issues) => {
|
|
|
3792
3897
|
}
|
|
3793
3898
|
});
|
|
3794
3899
|
};
|
|
3795
|
-
const ZodRealError = $constructor("ZodError", initializer, {
|
|
3900
|
+
const ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer, {
|
|
3796
3901
|
Parent: Error
|
|
3797
3902
|
});
|
|
3798
3903
|
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
@@ -3807,6 +3912,43 @@ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
|
3807
3912
|
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
3808
3913
|
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
3809
3914
|
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3915
|
+
const _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
3916
|
+
function _installLazyMethods(inst, group, methods) {
|
|
3917
|
+
const proto = Object.getPrototypeOf(inst);
|
|
3918
|
+
let installed = _installedGroups.get(proto);
|
|
3919
|
+
if (!installed) {
|
|
3920
|
+
installed = /* @__PURE__ */ new Set();
|
|
3921
|
+
_installedGroups.set(proto, installed);
|
|
3922
|
+
}
|
|
3923
|
+
if (installed.has(group))
|
|
3924
|
+
return;
|
|
3925
|
+
installed.add(group);
|
|
3926
|
+
for (const key in methods) {
|
|
3927
|
+
const fn = methods[key];
|
|
3928
|
+
Object.defineProperty(proto, key, {
|
|
3929
|
+
configurable: true,
|
|
3930
|
+
enumerable: false,
|
|
3931
|
+
get() {
|
|
3932
|
+
const bound = fn.bind(this);
|
|
3933
|
+
Object.defineProperty(this, key, {
|
|
3934
|
+
configurable: true,
|
|
3935
|
+
writable: true,
|
|
3936
|
+
enumerable: true,
|
|
3937
|
+
value: bound
|
|
3938
|
+
});
|
|
3939
|
+
return bound;
|
|
3940
|
+
},
|
|
3941
|
+
set(v) {
|
|
3942
|
+
Object.defineProperty(this, key, {
|
|
3943
|
+
configurable: true,
|
|
3944
|
+
writable: true,
|
|
3945
|
+
enumerable: true,
|
|
3946
|
+
value: v
|
|
3947
|
+
});
|
|
3948
|
+
}
|
|
3949
|
+
});
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3810
3952
|
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
3811
3953
|
$ZodType.init(inst, def);
|
|
3812
3954
|
Object.assign(inst["~standard"], {
|
|
@@ -3819,23 +3961,6 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
3819
3961
|
inst.def = def;
|
|
3820
3962
|
inst.type = def.type;
|
|
3821
3963
|
Object.defineProperty(inst, "_def", { value: def });
|
|
3822
|
-
inst.check = (...checks) => {
|
|
3823
|
-
return inst.clone(mergeDefs(def, {
|
|
3824
|
-
checks: [
|
|
3825
|
-
...def.checks ?? [],
|
|
3826
|
-
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
3827
|
-
]
|
|
3828
|
-
}), {
|
|
3829
|
-
parent: true
|
|
3830
|
-
});
|
|
3831
|
-
};
|
|
3832
|
-
inst.with = inst.check;
|
|
3833
|
-
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
3834
|
-
inst.brand = () => inst;
|
|
3835
|
-
inst.register = ((reg, meta) => {
|
|
3836
|
-
reg.add(inst, meta);
|
|
3837
|
-
return inst;
|
|
3838
|
-
});
|
|
3839
3964
|
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
3840
3965
|
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
3841
3966
|
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
@@ -3849,45 +3974,108 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
3849
3974
|
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
3850
3975
|
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
3851
3976
|
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
3852
|
-
inst
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3977
|
+
_installLazyMethods(inst, "ZodType", {
|
|
3978
|
+
check(...chks) {
|
|
3979
|
+
const def2 = this.def;
|
|
3980
|
+
return this.clone(mergeDefs(def2, {
|
|
3981
|
+
checks: [
|
|
3982
|
+
...def2.checks ?? [],
|
|
3983
|
+
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
3984
|
+
]
|
|
3985
|
+
}), { parent: true });
|
|
3986
|
+
},
|
|
3987
|
+
with(...chks) {
|
|
3988
|
+
return this.check(...chks);
|
|
3989
|
+
},
|
|
3990
|
+
clone(def2, params) {
|
|
3991
|
+
return clone(this, def2, params);
|
|
3992
|
+
},
|
|
3993
|
+
brand() {
|
|
3994
|
+
return this;
|
|
3995
|
+
},
|
|
3996
|
+
register(reg, meta) {
|
|
3997
|
+
reg.add(this, meta);
|
|
3998
|
+
return this;
|
|
3999
|
+
},
|
|
4000
|
+
refine(check, params) {
|
|
4001
|
+
return this.check(refine(check, params));
|
|
4002
|
+
},
|
|
4003
|
+
superRefine(refinement, params) {
|
|
4004
|
+
return this.check(superRefine(refinement, params));
|
|
4005
|
+
},
|
|
4006
|
+
overwrite(fn) {
|
|
4007
|
+
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
4008
|
+
},
|
|
4009
|
+
optional() {
|
|
4010
|
+
return optional(this);
|
|
4011
|
+
},
|
|
4012
|
+
exactOptional() {
|
|
4013
|
+
return exactOptional(this);
|
|
4014
|
+
},
|
|
4015
|
+
nullable() {
|
|
4016
|
+
return nullable(this);
|
|
4017
|
+
},
|
|
4018
|
+
nullish() {
|
|
4019
|
+
return optional(nullable(this));
|
|
4020
|
+
},
|
|
4021
|
+
nonoptional(params) {
|
|
4022
|
+
return nonoptional(this, params);
|
|
4023
|
+
},
|
|
4024
|
+
array() {
|
|
4025
|
+
return array(this);
|
|
4026
|
+
},
|
|
4027
|
+
or(arg) {
|
|
4028
|
+
return union([this, arg]);
|
|
4029
|
+
},
|
|
4030
|
+
and(arg) {
|
|
4031
|
+
return intersection(this, arg);
|
|
4032
|
+
},
|
|
4033
|
+
transform(tx) {
|
|
4034
|
+
return pipe(this, transform(tx));
|
|
4035
|
+
},
|
|
4036
|
+
default(d) {
|
|
4037
|
+
return _default(this, d);
|
|
4038
|
+
},
|
|
4039
|
+
prefault(d) {
|
|
4040
|
+
return prefault(this, d);
|
|
4041
|
+
},
|
|
4042
|
+
catch(params) {
|
|
4043
|
+
return _catch(this, params);
|
|
4044
|
+
},
|
|
4045
|
+
pipe(target) {
|
|
4046
|
+
return pipe(this, target);
|
|
4047
|
+
},
|
|
4048
|
+
readonly() {
|
|
4049
|
+
return readonly(this);
|
|
4050
|
+
},
|
|
4051
|
+
describe(description) {
|
|
4052
|
+
const cl = this.clone();
|
|
4053
|
+
globalRegistry.add(cl, { description });
|
|
4054
|
+
return cl;
|
|
4055
|
+
},
|
|
4056
|
+
meta(...args) {
|
|
4057
|
+
if (args.length === 0)
|
|
4058
|
+
return globalRegistry.get(this);
|
|
4059
|
+
const cl = this.clone();
|
|
4060
|
+
globalRegistry.add(cl, args[0]);
|
|
4061
|
+
return cl;
|
|
4062
|
+
},
|
|
4063
|
+
isOptional() {
|
|
4064
|
+
return this.safeParse(void 0).success;
|
|
4065
|
+
},
|
|
4066
|
+
isNullable() {
|
|
4067
|
+
return this.safeParse(null).success;
|
|
4068
|
+
},
|
|
4069
|
+
apply(fn) {
|
|
4070
|
+
return fn(this);
|
|
4071
|
+
}
|
|
4072
|
+
});
|
|
3874
4073
|
Object.defineProperty(inst, "description", {
|
|
3875
4074
|
get() {
|
|
3876
4075
|
return globalRegistry.get(inst)?.description;
|
|
3877
4076
|
},
|
|
3878
4077
|
configurable: true
|
|
3879
4078
|
});
|
|
3880
|
-
inst.meta = (...args) => {
|
|
3881
|
-
if (args.length === 0) {
|
|
3882
|
-
return globalRegistry.get(inst);
|
|
3883
|
-
}
|
|
3884
|
-
const cl = inst.clone();
|
|
3885
|
-
globalRegistry.add(cl, args[0]);
|
|
3886
|
-
return cl;
|
|
3887
|
-
};
|
|
3888
|
-
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
3889
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
3890
|
-
inst.apply = (fn) => fn(inst);
|
|
3891
4079
|
return inst;
|
|
3892
4080
|
});
|
|
3893
4081
|
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
@@ -3898,21 +4086,53 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
3898
4086
|
inst.format = bag.format ?? null;
|
|
3899
4087
|
inst.minLength = bag.minimum ?? null;
|
|
3900
4088
|
inst.maxLength = bag.maximum ?? null;
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
4089
|
+
_installLazyMethods(inst, "_ZodString", {
|
|
4090
|
+
regex(...args) {
|
|
4091
|
+
return this.check(/* @__PURE__ */ _regex(...args));
|
|
4092
|
+
},
|
|
4093
|
+
includes(...args) {
|
|
4094
|
+
return this.check(/* @__PURE__ */ _includes(...args));
|
|
4095
|
+
},
|
|
4096
|
+
startsWith(...args) {
|
|
4097
|
+
return this.check(/* @__PURE__ */ _startsWith(...args));
|
|
4098
|
+
},
|
|
4099
|
+
endsWith(...args) {
|
|
4100
|
+
return this.check(/* @__PURE__ */ _endsWith(...args));
|
|
4101
|
+
},
|
|
4102
|
+
min(...args) {
|
|
4103
|
+
return this.check(/* @__PURE__ */ _minLength(...args));
|
|
4104
|
+
},
|
|
4105
|
+
max(...args) {
|
|
4106
|
+
return this.check(/* @__PURE__ */ _maxLength(...args));
|
|
4107
|
+
},
|
|
4108
|
+
length(...args) {
|
|
4109
|
+
return this.check(/* @__PURE__ */ _length(...args));
|
|
4110
|
+
},
|
|
4111
|
+
nonempty(...args) {
|
|
4112
|
+
return this.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
4113
|
+
},
|
|
4114
|
+
lowercase(params) {
|
|
4115
|
+
return this.check(/* @__PURE__ */ _lowercase(params));
|
|
4116
|
+
},
|
|
4117
|
+
uppercase(params) {
|
|
4118
|
+
return this.check(/* @__PURE__ */ _uppercase(params));
|
|
4119
|
+
},
|
|
4120
|
+
trim() {
|
|
4121
|
+
return this.check(/* @__PURE__ */ _trim());
|
|
4122
|
+
},
|
|
4123
|
+
normalize(...args) {
|
|
4124
|
+
return this.check(/* @__PURE__ */ _normalize(...args));
|
|
4125
|
+
},
|
|
4126
|
+
toLowerCase() {
|
|
4127
|
+
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
4128
|
+
},
|
|
4129
|
+
toUpperCase() {
|
|
4130
|
+
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
4131
|
+
},
|
|
4132
|
+
slugify() {
|
|
4133
|
+
return this.check(/* @__PURE__ */ _slugify());
|
|
4134
|
+
}
|
|
4135
|
+
});
|
|
3916
4136
|
});
|
|
3917
4137
|
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
3918
4138
|
$ZodString.init(inst, def);
|
|
@@ -4032,21 +4252,53 @@ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
4032
4252
|
$ZodNumber.init(inst, def);
|
|
4033
4253
|
ZodType.init(inst, def);
|
|
4034
4254
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json);
|
|
4035
|
-
inst
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4255
|
+
_installLazyMethods(inst, "ZodNumber", {
|
|
4256
|
+
gt(value, params) {
|
|
4257
|
+
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
4258
|
+
},
|
|
4259
|
+
gte(value, params) {
|
|
4260
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
4261
|
+
},
|
|
4262
|
+
min(value, params) {
|
|
4263
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
4264
|
+
},
|
|
4265
|
+
lt(value, params) {
|
|
4266
|
+
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
4267
|
+
},
|
|
4268
|
+
lte(value, params) {
|
|
4269
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
4270
|
+
},
|
|
4271
|
+
max(value, params) {
|
|
4272
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
4273
|
+
},
|
|
4274
|
+
int(params) {
|
|
4275
|
+
return this.check(int(params));
|
|
4276
|
+
},
|
|
4277
|
+
safe(params) {
|
|
4278
|
+
return this.check(int(params));
|
|
4279
|
+
},
|
|
4280
|
+
positive(params) {
|
|
4281
|
+
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
4282
|
+
},
|
|
4283
|
+
nonnegative(params) {
|
|
4284
|
+
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
4285
|
+
},
|
|
4286
|
+
negative(params) {
|
|
4287
|
+
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
4288
|
+
},
|
|
4289
|
+
nonpositive(params) {
|
|
4290
|
+
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
4291
|
+
},
|
|
4292
|
+
multipleOf(value, params) {
|
|
4293
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
4294
|
+
},
|
|
4295
|
+
step(value, params) {
|
|
4296
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
4297
|
+
},
|
|
4298
|
+
finite() {
|
|
4299
|
+
return this;
|
|
4300
|
+
}
|
|
4301
|
+
});
|
|
4050
4302
|
const bag = inst._zod.bag;
|
|
4051
4303
|
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
4052
4304
|
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
@@ -4101,11 +4353,23 @@ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
4101
4353
|
ZodType.init(inst, def);
|
|
4102
4354
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
4103
4355
|
inst.element = def.element;
|
|
4104
|
-
inst
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4356
|
+
_installLazyMethods(inst, "ZodArray", {
|
|
4357
|
+
min(n, params) {
|
|
4358
|
+
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
4359
|
+
},
|
|
4360
|
+
nonempty(params) {
|
|
4361
|
+
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
4362
|
+
},
|
|
4363
|
+
max(n, params) {
|
|
4364
|
+
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
4365
|
+
},
|
|
4366
|
+
length(n, params) {
|
|
4367
|
+
return this.check(/* @__PURE__ */ _length(n, params));
|
|
4368
|
+
},
|
|
4369
|
+
unwrap() {
|
|
4370
|
+
return this.element;
|
|
4371
|
+
}
|
|
4372
|
+
});
|
|
4109
4373
|
});
|
|
4110
4374
|
function array(element, params) {
|
|
4111
4375
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
@@ -4117,23 +4381,47 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
4117
4381
|
defineLazy(inst, "shape", () => {
|
|
4118
4382
|
return def.shape;
|
|
4119
4383
|
});
|
|
4120
|
-
inst
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4384
|
+
_installLazyMethods(inst, "ZodObject", {
|
|
4385
|
+
keyof() {
|
|
4386
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
4387
|
+
},
|
|
4388
|
+
catchall(catchall) {
|
|
4389
|
+
return this.clone({ ...this._zod.def, catchall });
|
|
4390
|
+
},
|
|
4391
|
+
passthrough() {
|
|
4392
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
4393
|
+
},
|
|
4394
|
+
loose() {
|
|
4395
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
4396
|
+
},
|
|
4397
|
+
strict() {
|
|
4398
|
+
return this.clone({ ...this._zod.def, catchall: never() });
|
|
4399
|
+
},
|
|
4400
|
+
strip() {
|
|
4401
|
+
return this.clone({ ...this._zod.def, catchall: void 0 });
|
|
4402
|
+
},
|
|
4403
|
+
extend(incoming) {
|
|
4404
|
+
return extend(this, incoming);
|
|
4405
|
+
},
|
|
4406
|
+
safeExtend(incoming) {
|
|
4407
|
+
return safeExtend(this, incoming);
|
|
4408
|
+
},
|
|
4409
|
+
merge(other) {
|
|
4410
|
+
return merge(this, other);
|
|
4411
|
+
},
|
|
4412
|
+
pick(mask) {
|
|
4413
|
+
return pick(this, mask);
|
|
4414
|
+
},
|
|
4415
|
+
omit(mask) {
|
|
4416
|
+
return omit(this, mask);
|
|
4417
|
+
},
|
|
4418
|
+
partial(...args) {
|
|
4419
|
+
return partial(ZodOptional, this, args[0]);
|
|
4420
|
+
},
|
|
4421
|
+
required(...args) {
|
|
4422
|
+
return required(ZodNonOptional, this, args[0]);
|
|
4423
|
+
}
|
|
4424
|
+
});
|
|
4137
4425
|
});
|
|
4138
4426
|
function object(shape, params) {
|
|
4139
4427
|
const def = {
|
|
@@ -4188,6 +4476,14 @@ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
4188
4476
|
inst.valueType = def.valueType;
|
|
4189
4477
|
});
|
|
4190
4478
|
function record(keyType, valueType, params) {
|
|
4479
|
+
if (!valueType || !valueType._zod) {
|
|
4480
|
+
return new ZodRecord({
|
|
4481
|
+
type: "record",
|
|
4482
|
+
keyType: string(),
|
|
4483
|
+
valueType: keyType,
|
|
4484
|
+
...normalizeParams(valueType)
|
|
4485
|
+
});
|
|
4486
|
+
}
|
|
4191
4487
|
return new ZodRecord({
|
|
4192
4488
|
type: "record",
|
|
4193
4489
|
keyType,
|
|
@@ -4287,10 +4583,12 @@ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) =>
|
|
|
4287
4583
|
if (output instanceof Promise) {
|
|
4288
4584
|
return output.then((output2) => {
|
|
4289
4585
|
payload.value = output2;
|
|
4586
|
+
payload.fallback = true;
|
|
4290
4587
|
return payload;
|
|
4291
4588
|
});
|
|
4292
4589
|
}
|
|
4293
4590
|
payload.value = output;
|
|
4591
|
+
payload.fallback = true;
|
|
4294
4592
|
return payload;
|
|
4295
4593
|
};
|
|
4296
4594
|
});
|
|
@@ -4441,8 +4739,8 @@ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
|
4441
4739
|
function refine(fn, _params = {}) {
|
|
4442
4740
|
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
4443
4741
|
}
|
|
4444
|
-
function superRefine(fn) {
|
|
4445
|
-
return /* @__PURE__ */ _superRefine(fn);
|
|
4742
|
+
function superRefine(fn, params) {
|
|
4743
|
+
return /* @__PURE__ */ _superRefine(fn, params);
|
|
4446
4744
|
}
|
|
4447
4745
|
export {
|
|
4448
4746
|
_enum as _,
|