@wecode-ai/weibo-openclaw-plugin 2.2.3 → 2.2.4
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/node_modules/tar/dist/commonjs/index.min.js +3 -3
- package/node_modules/tar/dist/commonjs/index.min.js.map +3 -3
- package/node_modules/tar/dist/commonjs/pack.d.ts +3 -1
- package/node_modules/tar/dist/commonjs/pack.d.ts.map +1 -1
- package/node_modules/tar/dist/commonjs/pack.js +33 -7
- package/node_modules/tar/dist/commonjs/pack.js.map +1 -1
- package/node_modules/tar/dist/esm/index.min.js +3 -3
- package/node_modules/tar/dist/esm/index.min.js.map +3 -3
- package/node_modules/tar/dist/esm/pack.d.ts +3 -1
- package/node_modules/tar/dist/esm/pack.d.ts.map +1 -1
- package/node_modules/tar/dist/esm/pack.js +33 -7
- package/node_modules/tar/dist/esm/pack.js.map +1 -1
- package/node_modules/tar/package.json +4 -4
- package/node_modules/zod/README.md +1 -18
- package/node_modules/zod/locales/package.json +2 -1
- package/node_modules/zod/mini/package.json +2 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/object.test.ts +5 -5
- package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/zod/src/v4/classic/errors.ts +2 -2
- package/node_modules/zod/src/v4/classic/external.ts +1 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +39 -23
- package/node_modules/zod/src/v4/classic/parse.ts +6 -6
- package/node_modules/zod/src/v4/classic/schemas.ts +414 -151
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +6 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +50 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +142 -1
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +44 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +34 -1
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +214 -2
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +161 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +6 -6
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +55 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +83 -6
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +114 -4
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +24 -1
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +69 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +85 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +49 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +63 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +50 -1
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +4 -4
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +150 -15
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +315 -2
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +54 -0
- package/node_modules/zod/src/v4/core/api.ts +31 -6
- package/node_modules/zod/src/v4/core/checks.ts +1 -1
- package/node_modules/zod/src/v4/core/core.ts +17 -2
- package/node_modules/zod/src/v4/core/errors.ts +31 -24
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +17 -18
- package/node_modules/zod/src/v4/core/parse.ts +7 -7
- package/node_modules/zod/src/v4/core/regexes.ts +8 -1
- package/node_modules/zod/src/v4/core/schemas.ts +263 -71
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +10 -1
- package/node_modules/zod/src/v4/core/util.ts +52 -35
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/zod/src/v4/locales/en.ts +4 -0
- package/node_modules/zod/src/v4/locales/fr.ts +24 -8
- package/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/zod/src/v4/locales/index.ts +3 -0
- package/node_modules/zod/src/v4/locales/it.ts +1 -1
- package/node_modules/zod/src/v4/locales/ka.ts +8 -8
- package/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/zod/src/v4/locales/uz.ts +1 -0
- package/node_modules/zod/src/v4/mini/external.ts +1 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +56 -25
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +19 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +32 -2
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +9 -9
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +51 -1
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +5 -0
- package/node_modules/zod/v3/package.json +2 -1
- package/node_modules/zod/v4/classic/errors.js +2 -2
- package/node_modules/zod/v4/classic/external.d.cts +1 -0
- package/node_modules/zod/v4/classic/external.d.ts +1 -0
- package/node_modules/zod/v4/classic/from-json-schema.cjs +31 -16
- package/node_modules/zod/v4/classic/from-json-schema.js +31 -16
- package/node_modules/zod/v4/classic/package.json +2 -1
- package/node_modules/zod/v4/classic/schemas.cjs +358 -119
- package/node_modules/zod/v4/classic/schemas.d.cts +42 -14
- package/node_modules/zod/v4/classic/schemas.d.ts +42 -14
- package/node_modules/zod/v4/classic/schemas.js +356 -118
- package/node_modules/zod/v4/core/api.cjs +7 -2
- package/node_modules/zod/v4/core/api.d.cts +26 -5
- package/node_modules/zod/v4/core/api.d.ts +26 -5
- package/node_modules/zod/v4/core/api.js +7 -2
- package/node_modules/zod/v4/core/checks.d.cts +1 -1
- package/node_modules/zod/v4/core/checks.d.ts +1 -1
- package/node_modules/zod/v4/core/core.cjs +3 -1
- package/node_modules/zod/v4/core/core.js +4 -2
- package/node_modules/zod/v4/core/errors.cjs +26 -23
- package/node_modules/zod/v4/core/errors.d.cts +1 -0
- package/node_modules/zod/v4/core/errors.d.ts +1 -0
- package/node_modules/zod/v4/core/errors.js +26 -23
- package/node_modules/zod/v4/core/json-schema-processors.cjs +16 -20
- package/node_modules/zod/v4/core/json-schema-processors.js +16 -20
- package/node_modules/zod/v4/core/package.json +2 -1
- package/node_modules/zod/v4/core/parse.cjs +7 -7
- package/node_modules/zod/v4/core/parse.js +7 -7
- package/node_modules/zod/v4/core/regexes.cjs +9 -3
- package/node_modules/zod/v4/core/regexes.d.cts +6 -0
- package/node_modules/zod/v4/core/regexes.d.ts +6 -0
- package/node_modules/zod/v4/core/regexes.js +7 -1
- package/node_modules/zod/v4/core/schemas.cjs +211 -65
- package/node_modules/zod/v4/core/schemas.d.cts +39 -1
- package/node_modules/zod/v4/core/schemas.d.ts +39 -1
- package/node_modules/zod/v4/core/schemas.js +210 -64
- package/node_modules/zod/v4/core/to-json-schema.cjs +12 -1
- package/node_modules/zod/v4/core/to-json-schema.js +12 -1
- package/node_modules/zod/v4/core/util.cjs +54 -30
- package/node_modules/zod/v4/core/util.d.cts +1 -0
- package/node_modules/zod/v4/core/util.d.ts +1 -0
- package/node_modules/zod/v4/core/util.js +55 -32
- package/node_modules/zod/v4/core/versions.cjs +2 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/zod/v4/locales/en.cjs +4 -0
- package/node_modules/zod/v4/locales/en.js +4 -0
- package/node_modules/zod/v4/locales/fr.cjs +24 -7
- package/node_modules/zod/v4/locales/fr.js +24 -7
- package/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/zod/v4/locales/index.cjs +8 -1
- package/node_modules/zod/v4/locales/index.d.cts +3 -0
- package/node_modules/zod/v4/locales/index.d.ts +3 -0
- package/node_modules/zod/v4/locales/index.js +3 -0
- package/node_modules/zod/v4/locales/it.cjs +1 -1
- package/node_modules/zod/v4/locales/it.js +1 -1
- package/node_modules/zod/v4/locales/ka.cjs +8 -8
- package/node_modules/zod/v4/locales/ka.js +8 -8
- package/node_modules/zod/v4/locales/package.json +2 -1
- package/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/zod/v4/locales/uz.cjs +1 -0
- package/node_modules/zod/v4/locales/uz.js +1 -0
- package/node_modules/zod/v4/mini/external.d.cts +1 -0
- package/node_modules/zod/v4/mini/external.d.ts +1 -0
- package/node_modules/zod/v4/mini/package.json +2 -1
- package/node_modules/zod/v4/mini/schemas.cjs +41 -4
- package/node_modules/zod/v4/mini/schemas.d.cts +28 -10
- package/node_modules/zod/v4/mini/schemas.d.ts +28 -10
- package/node_modules/zod/v4/mini/schemas.js +40 -4
- package/node_modules/zod/v4/package.json +2 -1
- package/node_modules/zod/v4-mini/package.json +2 -1
- package/package.json +2 -1
- package/src/accounts.js +1 -1
- package/src/accounts.js.map +1 -1
- package/src/channel.js +1 -1
- package/src/channel.js.map +1 -1
- package/src/outbound.d.ts.map +1 -1
- package/src/outbound.js +82 -4
- package/src/outbound.js.map +1 -1
- package/src/send.d.ts +23 -0
- package/src/send.d.ts.map +1 -1
- package/src/send.js +54 -2
- package/src/send.js.map +1 -1
- package/src/token.d.ts +8 -0
- package/src/token.d.ts.map +1 -1
- package/src/token.js +16 -1
- package/src/token.js.map +1 -1
|
@@ -34,8 +34,13 @@ export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> ex
|
|
|
34
34
|
export interface ParsePayload<T = unknown> {
|
|
35
35
|
value: T;
|
|
36
36
|
issues: errors.$ZodRawIssue[];
|
|
37
|
-
/** A
|
|
37
|
+
/** A way to mark a whole payload as aborted. Used in codecs/pipes. */
|
|
38
38
|
aborted?: boolean;
|
|
39
|
+
/** @internal Marks a value as a fallback that an outer wrapper (e.g.
|
|
40
|
+
* $ZodOptional) may override with its own interpretation when input was
|
|
41
|
+
* undefined. Set by $ZodCatch when catchValue substitutes and by every
|
|
42
|
+
* $ZodTransform invocation. */
|
|
43
|
+
fallback?: boolean | undefined;
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
|
@@ -220,6 +225,7 @@ export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constru
|
|
|
220
225
|
let asyncResult!: Promise<unknown> | undefined;
|
|
221
226
|
for (const ch of checks) {
|
|
222
227
|
if (ch._zod.def.when) {
|
|
228
|
+
if (util.explicitlyAborted(payload)) continue;
|
|
223
229
|
const shouldRun = ch._zod.def.when(payload);
|
|
224
230
|
if (!shouldRun) continue;
|
|
225
231
|
} else if (isAborted) {
|
|
@@ -477,6 +483,23 @@ export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$construct
|
|
|
477
483
|
try {
|
|
478
484
|
// Trim whitespace from input
|
|
479
485
|
const trimmed = payload.value.trim();
|
|
486
|
+
|
|
487
|
+
// When normalize is off, require :// for http/https URLs
|
|
488
|
+
// This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
489
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
|
|
490
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
491
|
+
payload.issues.push({
|
|
492
|
+
code: "invalid_format",
|
|
493
|
+
format: "url",
|
|
494
|
+
note: "Invalid URL format",
|
|
495
|
+
input: payload.value,
|
|
496
|
+
inst,
|
|
497
|
+
continue: !def.abort,
|
|
498
|
+
});
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
480
503
|
// @ts-ignore
|
|
481
504
|
const url = new URL(trimmed);
|
|
482
505
|
|
|
@@ -568,13 +591,33 @@ export const $ZodNanoID: core.$constructor<$ZodNanoID> = /*@__PURE__*/ core.$con
|
|
|
568
591
|
|
|
569
592
|
////////////////////////////// ZodCUID //////////////////////////////
|
|
570
593
|
|
|
594
|
+
/**
|
|
595
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
596
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
597
|
+
* See https://github.com/paralleldrive/cuid.
|
|
598
|
+
*/
|
|
571
599
|
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {}
|
|
600
|
+
/**
|
|
601
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
602
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
603
|
+
* See https://github.com/paralleldrive/cuid.
|
|
604
|
+
*/
|
|
572
605
|
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {}
|
|
573
606
|
|
|
607
|
+
/**
|
|
608
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
609
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
610
|
+
* See https://github.com/paralleldrive/cuid.
|
|
611
|
+
*/
|
|
574
612
|
export interface $ZodCUID extends $ZodType {
|
|
575
613
|
_zod: $ZodCUIDInternals;
|
|
576
614
|
}
|
|
577
615
|
|
|
616
|
+
/**
|
|
617
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
618
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
619
|
+
* See https://github.com/paralleldrive/cuid.
|
|
620
|
+
*/
|
|
578
621
|
export const $ZodCUID: core.$constructor<$ZodCUID> = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def): void => {
|
|
579
622
|
def.pattern ??= regexes.cuid;
|
|
580
623
|
$ZodStringFormat.init(inst, def);
|
|
@@ -869,6 +912,8 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
|
|
|
869
912
|
////////////////////////////// ZodBase64 //////////////////////////////
|
|
870
913
|
export function isValidBase64(data: string): boolean {
|
|
871
914
|
if (data === "") return true;
|
|
915
|
+
// atob ignores whitespace, so reject it up front.
|
|
916
|
+
if (/\s/.test(data)) return false;
|
|
872
917
|
if (data.length % 4 !== 0) return false;
|
|
873
918
|
try {
|
|
874
919
|
// @ts-ignore
|
|
@@ -1318,8 +1363,6 @@ export const $ZodUndefined: core.$constructor<$ZodUndefined> = /*@__PURE__*/ cor
|
|
|
1318
1363
|
$ZodType.init(inst, def);
|
|
1319
1364
|
inst._zod.pattern = regexes.undefined;
|
|
1320
1365
|
inst._zod.values = new Set([undefined]);
|
|
1321
|
-
inst._zod.optin = "optional";
|
|
1322
|
-
inst._zod.optout = "optional";
|
|
1323
1366
|
|
|
1324
1367
|
inst._zod.parse = (payload, _ctx) => {
|
|
1325
1368
|
const input = payload.value;
|
|
@@ -1709,18 +1752,32 @@ function handlePropertyResult(
|
|
|
1709
1752
|
final: ParsePayload,
|
|
1710
1753
|
key: PropertyKey,
|
|
1711
1754
|
input: any,
|
|
1755
|
+
isOptionalIn: boolean,
|
|
1712
1756
|
isOptionalOut: boolean
|
|
1713
1757
|
) {
|
|
1758
|
+
const isPresent = key in input;
|
|
1714
1759
|
if (result.issues.length) {
|
|
1715
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
1716
|
-
if (isOptionalOut && !
|
|
1760
|
+
// For optional-in/out schemas, ignore errors on absent keys.
|
|
1761
|
+
if (isOptionalIn && isOptionalOut && !isPresent) {
|
|
1717
1762
|
return;
|
|
1718
1763
|
}
|
|
1719
1764
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
1720
1765
|
}
|
|
1721
1766
|
|
|
1767
|
+
if (!isPresent && !isOptionalIn) {
|
|
1768
|
+
if (!result.issues.length) {
|
|
1769
|
+
final.issues.push({
|
|
1770
|
+
code: "invalid_type",
|
|
1771
|
+
expected: "nonoptional",
|
|
1772
|
+
input: undefined,
|
|
1773
|
+
path: [key],
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1722
1779
|
if (result.value === undefined) {
|
|
1723
|
-
if (
|
|
1780
|
+
if (isPresent) {
|
|
1724
1781
|
(final.value as any)[key] = undefined;
|
|
1725
1782
|
}
|
|
1726
1783
|
} else {
|
|
@@ -1805,12 +1862,15 @@ function handleCatchall(
|
|
|
1805
1862
|
inst: $ZodObject
|
|
1806
1863
|
) {
|
|
1807
1864
|
const unrecognized: string[] = [];
|
|
1808
|
-
// iterate over input keys
|
|
1809
1865
|
const keySet = def.keySet;
|
|
1810
1866
|
const _catchall = def.catchall!._zod;
|
|
1811
1867
|
const t = _catchall.def.type;
|
|
1868
|
+
const isOptionalIn = _catchall.optin === "optional";
|
|
1812
1869
|
const isOptionalOut = _catchall.optout === "optional";
|
|
1813
1870
|
for (const key in input) {
|
|
1871
|
+
// skip __proto__ so it can't replace the result prototype via the
|
|
1872
|
+
// assignment setter on the plain {} we build into
|
|
1873
|
+
if (key === "__proto__") continue;
|
|
1814
1874
|
if (keySet.has(key)) continue;
|
|
1815
1875
|
if (t === "never") {
|
|
1816
1876
|
unrecognized.push(key);
|
|
@@ -1819,9 +1879,9 @@ function handleCatchall(
|
|
|
1819
1879
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1820
1880
|
|
|
1821
1881
|
if (r instanceof Promise) {
|
|
1822
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
1882
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1823
1883
|
} else {
|
|
1824
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1884
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
1825
1885
|
}
|
|
1826
1886
|
}
|
|
1827
1887
|
|
|
@@ -1899,13 +1959,14 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
|
|
|
1899
1959
|
|
|
1900
1960
|
for (const key of value.keys) {
|
|
1901
1961
|
const el = shape[key]!;
|
|
1962
|
+
const isOptionalIn = el._zod.optin === "optional";
|
|
1902
1963
|
const isOptionalOut = el._zod.optout === "optional";
|
|
1903
1964
|
|
|
1904
1965
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1905
1966
|
if (r instanceof Promise) {
|
|
1906
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
1967
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1907
1968
|
} else {
|
|
1908
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1969
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
1909
1970
|
}
|
|
1910
1971
|
}
|
|
1911
1972
|
|
|
@@ -1949,12 +2010,13 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
1949
2010
|
const id = ids[key];
|
|
1950
2011
|
const k = util.esc(key);
|
|
1951
2012
|
const schema = shape[key];
|
|
2013
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
1952
2014
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1953
2015
|
|
|
1954
2016
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1955
2017
|
|
|
1956
|
-
if (isOptionalOut) {
|
|
1957
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
2018
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2019
|
+
// For optional-in/out schemas, ignore errors on absent keys
|
|
1958
2020
|
doc.write(`
|
|
1959
2021
|
if (${id}.issues.length) {
|
|
1960
2022
|
if (${k} in input) {
|
|
@@ -1973,6 +2035,33 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
1973
2035
|
newResult[${k}] = ${id}.value;
|
|
1974
2036
|
}
|
|
1975
2037
|
|
|
2038
|
+
`);
|
|
2039
|
+
} else if (!isOptionalIn) {
|
|
2040
|
+
doc.write(`
|
|
2041
|
+
const ${id}_present = ${k} in input;
|
|
2042
|
+
if (${id}.issues.length) {
|
|
2043
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2044
|
+
...iss,
|
|
2045
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2046
|
+
})));
|
|
2047
|
+
}
|
|
2048
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
2049
|
+
payload.issues.push({
|
|
2050
|
+
code: "invalid_type",
|
|
2051
|
+
expected: "nonoptional",
|
|
2052
|
+
input: undefined,
|
|
2053
|
+
path: [${k}]
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
if (${id}_present) {
|
|
2058
|
+
if (${id}.value === undefined) {
|
|
2059
|
+
newResult[${k}] = undefined;
|
|
2060
|
+
} else {
|
|
2061
|
+
newResult[${k}] = ${id}.value;
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
|
|
1976
2065
|
`);
|
|
1977
2066
|
} else {
|
|
1978
2067
|
doc.write(`
|
|
@@ -2126,11 +2215,10 @@ export const $ZodUnion: core.$constructor<$ZodUnion> = /*@__PURE__*/ core.$const
|
|
|
2126
2215
|
return undefined;
|
|
2127
2216
|
});
|
|
2128
2217
|
|
|
2129
|
-
const
|
|
2130
|
-
const first = def.options[0]._zod.run;
|
|
2218
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2131
2219
|
|
|
2132
2220
|
inst._zod.parse = (payload, ctx) => {
|
|
2133
|
-
if (
|
|
2221
|
+
if (first) {
|
|
2134
2222
|
return first(payload, ctx);
|
|
2135
2223
|
}
|
|
2136
2224
|
let async = false;
|
|
@@ -2206,11 +2294,10 @@ export const $ZodXor: core.$constructor<$ZodXor> = /*@__PURE__*/ core.$construct
|
|
|
2206
2294
|
$ZodUnion.init(inst, def);
|
|
2207
2295
|
def.inclusive = false;
|
|
2208
2296
|
|
|
2209
|
-
const
|
|
2210
|
-
const first = def.options[0]._zod.run;
|
|
2297
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2211
2298
|
|
|
2212
2299
|
inst._zod.parse = (payload, ctx) => {
|
|
2213
|
-
if (
|
|
2300
|
+
if (first) {
|
|
2214
2301
|
return first(payload, ctx);
|
|
2215
2302
|
}
|
|
2216
2303
|
let async = false;
|
|
@@ -2329,17 +2416,21 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2329
2416
|
return opt._zod.run(payload, ctx) as any;
|
|
2330
2417
|
}
|
|
2331
2418
|
|
|
2332
|
-
|
|
2419
|
+
// Fall back to union matching when the fast discriminator path fails:
|
|
2420
|
+
// - explicitly enabled via unionFallback, or
|
|
2421
|
+
// - during backward direction (encode), since codec-based discriminators
|
|
2422
|
+
// have different values in forward vs backward directions
|
|
2423
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
2333
2424
|
return _super(payload, ctx);
|
|
2334
2425
|
}
|
|
2335
2426
|
|
|
2336
2427
|
// no matching discriminator
|
|
2337
2428
|
payload.issues.push({
|
|
2338
2429
|
code: "invalid_union",
|
|
2339
|
-
|
|
2340
2430
|
errors: [],
|
|
2341
2431
|
note: "No matching discriminator",
|
|
2342
2432
|
discriminator: def.discriminator,
|
|
2433
|
+
options: Array.from(disc.value.keys()),
|
|
2343
2434
|
input,
|
|
2344
2435
|
path: [def.discriminator],
|
|
2345
2436
|
inst,
|
|
@@ -2591,70 +2682,79 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
|
|
|
2591
2682
|
payload.value = [];
|
|
2592
2683
|
const proms: Promise<any>[] = [];
|
|
2593
2684
|
|
|
2594
|
-
const
|
|
2595
|
-
const
|
|
2685
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
2686
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
2596
2687
|
|
|
2597
2688
|
if (!def.rest) {
|
|
2598
|
-
|
|
2599
|
-
const tooSmall = input.length < optStart - 1;
|
|
2600
|
-
if (tooBig || tooSmall) {
|
|
2689
|
+
if (input.length < optinStart) {
|
|
2601
2690
|
payload.issues.push({
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2691
|
+
code: "too_small",
|
|
2692
|
+
minimum: optinStart,
|
|
2693
|
+
inclusive: true,
|
|
2606
2694
|
input,
|
|
2607
2695
|
inst,
|
|
2608
2696
|
origin: "array" as const,
|
|
2609
2697
|
});
|
|
2610
2698
|
return payload;
|
|
2611
2699
|
}
|
|
2700
|
+
if (input.length > items.length) {
|
|
2701
|
+
payload.issues.push({
|
|
2702
|
+
code: "too_big",
|
|
2703
|
+
maximum: items.length,
|
|
2704
|
+
inclusive: true,
|
|
2705
|
+
input,
|
|
2706
|
+
inst,
|
|
2707
|
+
origin: "array" as const,
|
|
2708
|
+
});
|
|
2709
|
+
}
|
|
2612
2710
|
}
|
|
2613
2711
|
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
2712
|
+
// Run every item in parallel, collecting results into an indexed
|
|
2713
|
+
// array. The post-processing in `handleTupleResults` walks them in
|
|
2714
|
+
// order so it can decide whether an absent optional-output error can
|
|
2715
|
+
// truncate the tail or must be reported to preserve required output.
|
|
2716
|
+
const itemResults: ParsePayload[] = new Array(items.length);
|
|
2717
|
+
for (let i = 0; i < items.length; i++) {
|
|
2718
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
2719
|
+
if (r instanceof Promise) {
|
|
2720
|
+
proms.push(
|
|
2721
|
+
r.then((rr) => {
|
|
2722
|
+
itemResults[i] = rr;
|
|
2723
|
+
})
|
|
2724
|
+
);
|
|
2628
2725
|
} else {
|
|
2629
|
-
|
|
2726
|
+
itemResults[i] = r;
|
|
2630
2727
|
}
|
|
2631
2728
|
}
|
|
2632
2729
|
|
|
2633
2730
|
if (def.rest) {
|
|
2731
|
+
let i = items.length - 1;
|
|
2634
2732
|
const rest = input.slice(items.length);
|
|
2635
2733
|
for (const el of rest) {
|
|
2636
2734
|
i++;
|
|
2637
|
-
const result = def.rest._zod.run(
|
|
2638
|
-
{
|
|
2639
|
-
value: el,
|
|
2640
|
-
issues: [],
|
|
2641
|
-
},
|
|
2642
|
-
ctx
|
|
2643
|
-
);
|
|
2644
|
-
|
|
2735
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
2645
2736
|
if (result instanceof Promise) {
|
|
2646
|
-
proms.push(result.then((
|
|
2737
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
2647
2738
|
} else {
|
|
2648
2739
|
handleTupleResult(result, payload, i);
|
|
2649
2740
|
}
|
|
2650
2741
|
}
|
|
2651
2742
|
}
|
|
2652
2743
|
|
|
2653
|
-
if (proms.length)
|
|
2654
|
-
|
|
2744
|
+
if (proms.length) {
|
|
2745
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
2746
|
+
}
|
|
2747
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
2655
2748
|
};
|
|
2656
2749
|
});
|
|
2657
2750
|
|
|
2751
|
+
function getTupleOptStart(items: readonly $ZodType[], key: "optin" | "optout") {
|
|
2752
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
2753
|
+
if (items[i]._zod[key] !== "optional") return i + 1;
|
|
2754
|
+
}
|
|
2755
|
+
return 0;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2658
2758
|
function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, index: number) {
|
|
2659
2759
|
if (result.issues.length) {
|
|
2660
2760
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -2662,6 +2762,45 @@ function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, ind
|
|
|
2662
2762
|
final.value[index] = result.value;
|
|
2663
2763
|
}
|
|
2664
2764
|
|
|
2765
|
+
function handleTupleResults(
|
|
2766
|
+
itemResults: ParsePayload[],
|
|
2767
|
+
final: ParsePayload<any[]>,
|
|
2768
|
+
items: readonly $ZodType[],
|
|
2769
|
+
input: unknown[],
|
|
2770
|
+
optoutStart: number
|
|
2771
|
+
) {
|
|
2772
|
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
|
|
2773
|
+
// rule, but only after `optoutStart`: the first index where the output
|
|
2774
|
+
// tuple tail can be absent.
|
|
2775
|
+
for (let i = 0; i < items.length; i++) {
|
|
2776
|
+
const r = itemResults[i];
|
|
2777
|
+
const isPresent = i < input.length;
|
|
2778
|
+
if (r.issues.length) {
|
|
2779
|
+
if (!isPresent && i >= optoutStart) {
|
|
2780
|
+
final.value.length = i;
|
|
2781
|
+
break;
|
|
2782
|
+
}
|
|
2783
|
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
2784
|
+
}
|
|
2785
|
+
final.value[i] = r.value;
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
// Drop trailing slots that produced `undefined` for absent input
|
|
2789
|
+
// (the array analog of an absent optional key on an object). The
|
|
2790
|
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
2791
|
+
// *inside* the input must be preserved even when the schema is
|
|
2792
|
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
2793
|
+
// explicit undefined value).
|
|
2794
|
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
2795
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
2796
|
+
final.value.length = i;
|
|
2797
|
+
} else {
|
|
2798
|
+
break;
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
return final;
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2665
2804
|
//////////////////////////////////////////
|
|
2666
2805
|
//////////////////////////////////////////
|
|
2667
2806
|
////////// //////////
|
|
@@ -2759,6 +2898,22 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2759
2898
|
for (const key of values) {
|
|
2760
2899
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
2761
2900
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2901
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2902
|
+
if (keyResult instanceof Promise) {
|
|
2903
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
2904
|
+
}
|
|
2905
|
+
if (keyResult.issues.length) {
|
|
2906
|
+
payload.issues.push({
|
|
2907
|
+
code: "invalid_key",
|
|
2908
|
+
origin: "record",
|
|
2909
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
2910
|
+
input: key,
|
|
2911
|
+
path: [key],
|
|
2912
|
+
inst,
|
|
2913
|
+
});
|
|
2914
|
+
continue;
|
|
2915
|
+
}
|
|
2916
|
+
const outKey = keyResult.value as PropertyKey;
|
|
2762
2917
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2763
2918
|
|
|
2764
2919
|
if (result instanceof Promise) {
|
|
@@ -2767,14 +2922,14 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2767
2922
|
if (result.issues.length) {
|
|
2768
2923
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2769
2924
|
}
|
|
2770
|
-
payload.value[
|
|
2925
|
+
payload.value[outKey] = result.value;
|
|
2771
2926
|
})
|
|
2772
2927
|
);
|
|
2773
2928
|
} else {
|
|
2774
2929
|
if (result.issues.length) {
|
|
2775
2930
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2776
2931
|
}
|
|
2777
|
-
payload.value[
|
|
2932
|
+
payload.value[outKey] = result.value;
|
|
2778
2933
|
}
|
|
2779
2934
|
}
|
|
2780
2935
|
}
|
|
@@ -2797,8 +2952,10 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2797
2952
|
}
|
|
2798
2953
|
} else {
|
|
2799
2954
|
payload.value = {};
|
|
2955
|
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
2800
2956
|
for (const key of Reflect.ownKeys(input)) {
|
|
2801
2957
|
if (key === "__proto__") continue;
|
|
2958
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
|
|
2802
2959
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2803
2960
|
if (keyResult instanceof Promise) {
|
|
2804
2961
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -3265,6 +3422,7 @@ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ cor
|
|
|
3265
3422
|
"$ZodTransform",
|
|
3266
3423
|
(inst, def) => {
|
|
3267
3424
|
$ZodType.init(inst, def);
|
|
3425
|
+
inst._zod.optin = "optional";
|
|
3268
3426
|
inst._zod.parse = (payload, ctx) => {
|
|
3269
3427
|
if (ctx.direction === "backward") {
|
|
3270
3428
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -3275,6 +3433,7 @@ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ cor
|
|
|
3275
3433
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
3276
3434
|
return output.then((output) => {
|
|
3277
3435
|
payload.value = output;
|
|
3436
|
+
payload.fallback = true;
|
|
3278
3437
|
return payload;
|
|
3279
3438
|
});
|
|
3280
3439
|
}
|
|
@@ -3284,6 +3443,7 @@ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ cor
|
|
|
3284
3443
|
}
|
|
3285
3444
|
|
|
3286
3445
|
payload.value = _out;
|
|
3446
|
+
payload.fallback = true;
|
|
3287
3447
|
return payload;
|
|
3288
3448
|
};
|
|
3289
3449
|
}
|
|
@@ -3316,7 +3476,7 @@ export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
3316
3476
|
}
|
|
3317
3477
|
|
|
3318
3478
|
function handleOptionalResult(result: ParsePayload, input: unknown) {
|
|
3319
|
-
if (result.issues.length
|
|
3479
|
+
if (input === undefined && (result.issues.length || result.fallback)) {
|
|
3320
3480
|
return { issues: [], value: undefined };
|
|
3321
3481
|
}
|
|
3322
3482
|
return result;
|
|
@@ -3339,9 +3499,10 @@ export const $ZodOptional: core.$constructor<$ZodOptional> = /*@__PURE__*/ core.
|
|
|
3339
3499
|
|
|
3340
3500
|
inst._zod.parse = (payload, ctx) => {
|
|
3341
3501
|
if (def.innerType._zod.optin === "optional") {
|
|
3502
|
+
const input = payload.value;
|
|
3342
3503
|
const result = def.innerType._zod.run(payload, ctx);
|
|
3343
|
-
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r,
|
|
3344
|
-
return handleOptionalResult(result,
|
|
3504
|
+
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
|
|
3505
|
+
return handleOptionalResult(result, input);
|
|
3345
3506
|
}
|
|
3346
3507
|
if (payload.value === undefined) {
|
|
3347
3508
|
return payload;
|
|
@@ -3734,7 +3895,7 @@ export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
3734
3895
|
|
|
3735
3896
|
export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
|
3736
3897
|
$ZodType.init(inst, def);
|
|
3737
|
-
|
|
3898
|
+
inst._zod.optin = "optional";
|
|
3738
3899
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
3739
3900
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3740
3901
|
|
|
@@ -3757,6 +3918,7 @@ export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$const
|
|
|
3757
3918
|
input: payload.value,
|
|
3758
3919
|
});
|
|
3759
3920
|
payload.issues = [];
|
|
3921
|
+
payload.fallback = true;
|
|
3760
3922
|
}
|
|
3761
3923
|
|
|
3762
3924
|
return payload;
|
|
@@ -3774,6 +3936,7 @@ export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$const
|
|
|
3774
3936
|
});
|
|
3775
3937
|
|
|
3776
3938
|
payload.issues = [];
|
|
3939
|
+
payload.fallback = true;
|
|
3777
3940
|
}
|
|
3778
3941
|
|
|
3779
3942
|
return payload;
|
|
@@ -3878,7 +4041,7 @@ function handlePipeResult(left: ParsePayload, next: $ZodType, ctx: ParseContextI
|
|
|
3878
4041
|
left.aborted = true;
|
|
3879
4042
|
return left;
|
|
3880
4043
|
}
|
|
3881
|
-
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
4044
|
+
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
|
|
3882
4045
|
}
|
|
3883
4046
|
|
|
3884
4047
|
////////////////////////////////////////////
|
|
@@ -3966,6 +4129,35 @@ function handleCodecTxResult(left: ParsePayload, value: any, nextSchema: SomeTyp
|
|
|
3966
4129
|
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
3967
4130
|
}
|
|
3968
4131
|
|
|
4132
|
+
/////////////////////////////////////////////////
|
|
4133
|
+
/////////////////////////////////////////////////
|
|
4134
|
+
////////// //////////
|
|
4135
|
+
////////// $ZodPreprocess //////////
|
|
4136
|
+
////////// //////////
|
|
4137
|
+
/////////////////////////////////////////////////
|
|
4138
|
+
/////////////////////////////////////////////////
|
|
4139
|
+
export interface $ZodPreprocessDef<B extends SomeType = $ZodType> extends $ZodPipeDef<$ZodTransform, B> {
|
|
4140
|
+
in: $ZodTransform;
|
|
4141
|
+
out: B;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
export interface $ZodPreprocessInternals<B extends SomeType = $ZodType> extends $ZodPipeInternals<$ZodTransform, B> {
|
|
4145
|
+
def: $ZodPreprocessDef<B>;
|
|
4146
|
+
optin: B["_zod"]["optin"];
|
|
4147
|
+
optout: B["_zod"]["optout"];
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
export interface $ZodPreprocess<B extends SomeType = $ZodType> extends $ZodPipe<$ZodTransform, B> {
|
|
4151
|
+
_zod: $ZodPreprocessInternals<B>;
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
export const $ZodPreprocess: core.$constructor<$ZodPreprocess> = /*@__PURE__*/ core.$constructor(
|
|
4155
|
+
"$ZodPreprocess",
|
|
4156
|
+
(inst, def) => {
|
|
4157
|
+
$ZodPipe.init(inst, def);
|
|
4158
|
+
}
|
|
4159
|
+
);
|
|
4160
|
+
|
|
3969
4161
|
////////////////////////////////////////////
|
|
3970
4162
|
////////////////////////////////////////////
|
|
3971
4163
|
////////// //////////
|
|
@@ -4384,14 +4576,14 @@ export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
4384
4576
|
export const $ZodLazy: core.$constructor<$ZodLazy> = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
4385
4577
|
$ZodType.init(inst, def);
|
|
4386
4578
|
|
|
4387
|
-
//
|
|
4388
|
-
//
|
|
4389
|
-
//
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4579
|
+
// Cache the resolved inner type on the shared `def` so all clones of this
|
|
4580
|
+
// lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
|
|
4581
|
+
// preserving identity for cycle detection on recursive schemas.
|
|
4582
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
4583
|
+
const d = def as $ZodLazyDef & { _cachedInner?: $ZodType };
|
|
4584
|
+
if (!d._cachedInner) d._cachedInner = def.getter() as $ZodType;
|
|
4585
|
+
return d._cachedInner;
|
|
4586
|
+
});
|
|
4395
4587
|
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
4396
4588
|
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
4397
4589
|
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|