@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
|
@@ -23,8 +23,13 @@ export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> ex
|
|
|
23
23
|
export interface ParsePayload<T = unknown> {
|
|
24
24
|
value: T;
|
|
25
25
|
issues: errors.$ZodRawIssue[];
|
|
26
|
-
/** A
|
|
26
|
+
/** A way to mark a whole payload as aborted. Used in codecs/pipes. */
|
|
27
27
|
aborted?: boolean;
|
|
28
|
+
/** @internal Marks a value as a fallback that an outer wrapper (e.g.
|
|
29
|
+
* $ZodOptional) may override with its own interpretation when input was
|
|
30
|
+
* undefined. Set by $ZodCatch when catchValue substitutes and by every
|
|
31
|
+
* $ZodTransform invocation. */
|
|
32
|
+
fallback?: boolean | undefined;
|
|
28
33
|
}
|
|
29
34
|
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
|
30
35
|
export interface $ZodTypeDef {
|
|
@@ -182,13 +187,33 @@ export interface $ZodNanoID extends $ZodType {
|
|
|
182
187
|
_zod: $ZodNanoIDInternals;
|
|
183
188
|
}
|
|
184
189
|
export declare const $ZodNanoID: core.$constructor<$ZodNanoID>;
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
192
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
193
|
+
* See https://github.com/paralleldrive/cuid.
|
|
194
|
+
*/
|
|
185
195
|
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {
|
|
186
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
199
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
200
|
+
* See https://github.com/paralleldrive/cuid.
|
|
201
|
+
*/
|
|
187
202
|
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {
|
|
188
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
206
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
207
|
+
* See https://github.com/paralleldrive/cuid.
|
|
208
|
+
*/
|
|
189
209
|
export interface $ZodCUID extends $ZodType {
|
|
190
210
|
_zod: $ZodCUIDInternals;
|
|
191
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
214
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
215
|
+
* See https://github.com/paralleldrive/cuid.
|
|
216
|
+
*/
|
|
192
217
|
export declare const $ZodCUID: core.$constructor<$ZodCUID>;
|
|
193
218
|
export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {
|
|
194
219
|
}
|
|
@@ -1010,6 +1035,19 @@ export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $
|
|
|
1010
1035
|
_zod: $ZodCodecInternals<A, B>;
|
|
1011
1036
|
}
|
|
1012
1037
|
export declare const $ZodCodec: core.$constructor<$ZodCodec>;
|
|
1038
|
+
export interface $ZodPreprocessDef<B extends SomeType = $ZodType> extends $ZodPipeDef<$ZodTransform, B> {
|
|
1039
|
+
in: $ZodTransform;
|
|
1040
|
+
out: B;
|
|
1041
|
+
}
|
|
1042
|
+
export interface $ZodPreprocessInternals<B extends SomeType = $ZodType> extends $ZodPipeInternals<$ZodTransform, B> {
|
|
1043
|
+
def: $ZodPreprocessDef<B>;
|
|
1044
|
+
optin: B["_zod"]["optin"];
|
|
1045
|
+
optout: B["_zod"]["optout"];
|
|
1046
|
+
}
|
|
1047
|
+
export interface $ZodPreprocess<B extends SomeType = $ZodType> extends $ZodPipe<$ZodTransform, B> {
|
|
1048
|
+
_zod: $ZodPreprocessInternals<B>;
|
|
1049
|
+
}
|
|
1050
|
+
export declare const $ZodPreprocess: core.$constructor<$ZodPreprocess>;
|
|
1013
1051
|
export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
|
1014
1052
|
type: "readonly";
|
|
1015
1053
|
innerType: T;
|
|
@@ -35,6 +35,8 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
35
35
|
let asyncResult;
|
|
36
36
|
for (const ch of checks) {
|
|
37
37
|
if (ch._zod.def.when) {
|
|
38
|
+
if (util.explicitlyAborted(payload))
|
|
39
|
+
continue;
|
|
38
40
|
const shouldRun = ch._zod.def.when(payload);
|
|
39
41
|
if (!shouldRun)
|
|
40
42
|
continue;
|
|
@@ -188,6 +190,21 @@ export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) =>
|
|
|
188
190
|
try {
|
|
189
191
|
// Trim whitespace from input
|
|
190
192
|
const trimmed = payload.value.trim();
|
|
193
|
+
// When normalize is off, require :// for http/https URLs
|
|
194
|
+
// This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
195
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
|
|
196
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
197
|
+
payload.issues.push({
|
|
198
|
+
code: "invalid_format",
|
|
199
|
+
format: "url",
|
|
200
|
+
note: "Invalid URL format",
|
|
201
|
+
input: payload.value,
|
|
202
|
+
inst,
|
|
203
|
+
continue: !def.abort,
|
|
204
|
+
});
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
191
208
|
// @ts-ignore
|
|
192
209
|
const url = new URL(trimmed);
|
|
193
210
|
if (def.hostname) {
|
|
@@ -248,6 +265,11 @@ export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, d
|
|
|
248
265
|
def.pattern ?? (def.pattern = regexes.nanoid);
|
|
249
266
|
$ZodStringFormat.init(inst, def);
|
|
250
267
|
});
|
|
268
|
+
/**
|
|
269
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
270
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
271
|
+
* See https://github.com/paralleldrive/cuid.
|
|
272
|
+
*/
|
|
251
273
|
export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
|
|
252
274
|
def.pattern ?? (def.pattern = regexes.cuid);
|
|
253
275
|
$ZodStringFormat.init(inst, def);
|
|
@@ -353,6 +375,9 @@ export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, d
|
|
|
353
375
|
export function isValidBase64(data) {
|
|
354
376
|
if (data === "")
|
|
355
377
|
return true;
|
|
378
|
+
// atob ignores whitespace, so reject it up front.
|
|
379
|
+
if (/\s/.test(data))
|
|
380
|
+
return false;
|
|
356
381
|
if (data.length % 4 !== 0)
|
|
357
382
|
return false;
|
|
358
383
|
try {
|
|
@@ -557,8 +582,6 @@ export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (i
|
|
|
557
582
|
$ZodType.init(inst, def);
|
|
558
583
|
inst._zod.pattern = regexes.undefined;
|
|
559
584
|
inst._zod.values = new Set([undefined]);
|
|
560
|
-
inst._zod.optin = "optional";
|
|
561
|
-
inst._zod.optout = "optional";
|
|
562
585
|
inst._zod.parse = (payload, _ctx) => {
|
|
563
586
|
const input = payload.value;
|
|
564
587
|
if (typeof input === "undefined")
|
|
@@ -688,16 +711,28 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
688
711
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
689
712
|
};
|
|
690
713
|
});
|
|
691
|
-
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
714
|
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
|
715
|
+
const isPresent = key in input;
|
|
692
716
|
if (result.issues.length) {
|
|
693
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
694
|
-
if (isOptionalOut && !
|
|
717
|
+
// For optional-in/out schemas, ignore errors on absent keys.
|
|
718
|
+
if (isOptionalIn && isOptionalOut && !isPresent) {
|
|
695
719
|
return;
|
|
696
720
|
}
|
|
697
721
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
698
722
|
}
|
|
723
|
+
if (!isPresent && !isOptionalIn) {
|
|
724
|
+
if (!result.issues.length) {
|
|
725
|
+
final.issues.push({
|
|
726
|
+
code: "invalid_type",
|
|
727
|
+
expected: "nonoptional",
|
|
728
|
+
input: undefined,
|
|
729
|
+
path: [key],
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
699
734
|
if (result.value === undefined) {
|
|
700
|
-
if (
|
|
735
|
+
if (isPresent) {
|
|
701
736
|
final.value[key] = undefined;
|
|
702
737
|
}
|
|
703
738
|
}
|
|
@@ -723,12 +758,16 @@ function normalizeDef(def) {
|
|
|
723
758
|
}
|
|
724
759
|
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
725
760
|
const unrecognized = [];
|
|
726
|
-
// iterate over input keys
|
|
727
761
|
const keySet = def.keySet;
|
|
728
762
|
const _catchall = def.catchall._zod;
|
|
729
763
|
const t = _catchall.def.type;
|
|
764
|
+
const isOptionalIn = _catchall.optin === "optional";
|
|
730
765
|
const isOptionalOut = _catchall.optout === "optional";
|
|
731
766
|
for (const key in input) {
|
|
767
|
+
// skip __proto__ so it can't replace the result prototype via the
|
|
768
|
+
// assignment setter on the plain {} we build into
|
|
769
|
+
if (key === "__proto__")
|
|
770
|
+
continue;
|
|
732
771
|
if (keySet.has(key))
|
|
733
772
|
continue;
|
|
734
773
|
if (t === "never") {
|
|
@@ -737,10 +776,10 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
737
776
|
}
|
|
738
777
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
739
778
|
if (r instanceof Promise) {
|
|
740
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
779
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
741
780
|
}
|
|
742
781
|
else {
|
|
743
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
782
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
744
783
|
}
|
|
745
784
|
}
|
|
746
785
|
if (unrecognized.length) {
|
|
@@ -808,13 +847,14 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
808
847
|
const shape = value.shape;
|
|
809
848
|
for (const key of value.keys) {
|
|
810
849
|
const el = shape[key];
|
|
850
|
+
const isOptionalIn = el._zod.optin === "optional";
|
|
811
851
|
const isOptionalOut = el._zod.optout === "optional";
|
|
812
852
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
813
853
|
if (r instanceof Promise) {
|
|
814
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
854
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
815
855
|
}
|
|
816
856
|
else {
|
|
817
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
857
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
818
858
|
}
|
|
819
859
|
}
|
|
820
860
|
if (!catchall) {
|
|
@@ -847,10 +887,11 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
|
|
|
847
887
|
const id = ids[key];
|
|
848
888
|
const k = util.esc(key);
|
|
849
889
|
const schema = shape[key];
|
|
890
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
850
891
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
851
892
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
852
|
-
if (isOptionalOut) {
|
|
853
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
893
|
+
if (isOptionalIn && isOptionalOut) {
|
|
894
|
+
// For optional-in/out schemas, ignore errors on absent keys
|
|
854
895
|
doc.write(`
|
|
855
896
|
if (${id}.issues.length) {
|
|
856
897
|
if (${k} in input) {
|
|
@@ -869,6 +910,34 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
|
|
|
869
910
|
newResult[${k}] = ${id}.value;
|
|
870
911
|
}
|
|
871
912
|
|
|
913
|
+
`);
|
|
914
|
+
}
|
|
915
|
+
else if (!isOptionalIn) {
|
|
916
|
+
doc.write(`
|
|
917
|
+
const ${id}_present = ${k} in input;
|
|
918
|
+
if (${id}.issues.length) {
|
|
919
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
920
|
+
...iss,
|
|
921
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
922
|
+
})));
|
|
923
|
+
}
|
|
924
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
925
|
+
payload.issues.push({
|
|
926
|
+
code: "invalid_type",
|
|
927
|
+
expected: "nonoptional",
|
|
928
|
+
input: undefined,
|
|
929
|
+
path: [${k}]
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
if (${id}_present) {
|
|
934
|
+
if (${id}.value === undefined) {
|
|
935
|
+
newResult[${k}] = undefined;
|
|
936
|
+
} else {
|
|
937
|
+
newResult[${k}] = ${id}.value;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
872
941
|
`);
|
|
873
942
|
}
|
|
874
943
|
else {
|
|
@@ -964,10 +1033,9 @@ export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def
|
|
|
964
1033
|
}
|
|
965
1034
|
return undefined;
|
|
966
1035
|
});
|
|
967
|
-
const
|
|
968
|
-
const first = def.options[0]._zod.run;
|
|
1036
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
969
1037
|
inst._zod.parse = (payload, ctx) => {
|
|
970
|
-
if (
|
|
1038
|
+
if (first) {
|
|
971
1039
|
return first(payload, ctx);
|
|
972
1040
|
}
|
|
973
1041
|
let async = false;
|
|
@@ -1024,10 +1092,9 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
1024
1092
|
export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) => {
|
|
1025
1093
|
$ZodUnion.init(inst, def);
|
|
1026
1094
|
def.inclusive = false;
|
|
1027
|
-
const
|
|
1028
|
-
const first = def.options[0]._zod.run;
|
|
1095
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
1029
1096
|
inst._zod.parse = (payload, ctx) => {
|
|
1030
|
-
if (
|
|
1097
|
+
if (first) {
|
|
1031
1098
|
return first(payload, ctx);
|
|
1032
1099
|
}
|
|
1033
1100
|
let async = false;
|
|
@@ -1105,7 +1172,11 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1105
1172
|
if (opt) {
|
|
1106
1173
|
return opt._zod.run(payload, ctx);
|
|
1107
1174
|
}
|
|
1108
|
-
|
|
1175
|
+
// Fall back to union matching when the fast discriminator path fails:
|
|
1176
|
+
// - explicitly enabled via unionFallback, or
|
|
1177
|
+
// - during backward direction (encode), since codec-based discriminators
|
|
1178
|
+
// have different values in forward vs backward directions
|
|
1179
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
1109
1180
|
return _super(payload, ctx);
|
|
1110
1181
|
}
|
|
1111
1182
|
// no matching discriminator
|
|
@@ -1114,6 +1185,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1114
1185
|
errors: [],
|
|
1115
1186
|
note: "No matching discriminator",
|
|
1116
1187
|
discriminator: def.discriminator,
|
|
1188
|
+
options: Array.from(disc.value.keys()),
|
|
1117
1189
|
input,
|
|
1118
1190
|
path: [def.discriminator],
|
|
1119
1191
|
inst,
|
|
@@ -1241,67 +1313,112 @@ export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def
|
|
|
1241
1313
|
}
|
|
1242
1314
|
payload.value = [];
|
|
1243
1315
|
const proms = [];
|
|
1244
|
-
const
|
|
1245
|
-
const
|
|
1316
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
1317
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
1246
1318
|
if (!def.rest) {
|
|
1247
|
-
|
|
1248
|
-
const tooSmall = input.length < optStart - 1;
|
|
1249
|
-
if (tooBig || tooSmall) {
|
|
1319
|
+
if (input.length < optinStart) {
|
|
1250
1320
|
payload.issues.push({
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1321
|
+
code: "too_small",
|
|
1322
|
+
minimum: optinStart,
|
|
1323
|
+
inclusive: true,
|
|
1254
1324
|
input,
|
|
1255
1325
|
inst,
|
|
1256
1326
|
origin: "array",
|
|
1257
1327
|
});
|
|
1258
1328
|
return payload;
|
|
1259
1329
|
}
|
|
1330
|
+
if (input.length > items.length) {
|
|
1331
|
+
payload.issues.push({
|
|
1332
|
+
code: "too_big",
|
|
1333
|
+
maximum: items.length,
|
|
1334
|
+
inclusive: true,
|
|
1335
|
+
input,
|
|
1336
|
+
inst,
|
|
1337
|
+
origin: "array",
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1260
1340
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
1341
|
+
// Run every item in parallel, collecting results into an indexed
|
|
1342
|
+
// array. The post-processing in `handleTupleResults` walks them in
|
|
1343
|
+
// order so it can decide whether an absent optional-output error can
|
|
1344
|
+
// truncate the tail or must be reported to preserve required output.
|
|
1345
|
+
const itemResults = new Array(items.length);
|
|
1346
|
+
for (let i = 0; i < items.length; i++) {
|
|
1347
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
1348
|
+
if (r instanceof Promise) {
|
|
1349
|
+
proms.push(r.then((rr) => {
|
|
1350
|
+
itemResults[i] = rr;
|
|
1351
|
+
}));
|
|
1273
1352
|
}
|
|
1274
1353
|
else {
|
|
1275
|
-
|
|
1354
|
+
itemResults[i] = r;
|
|
1276
1355
|
}
|
|
1277
1356
|
}
|
|
1278
1357
|
if (def.rest) {
|
|
1358
|
+
let i = items.length - 1;
|
|
1279
1359
|
const rest = input.slice(items.length);
|
|
1280
1360
|
for (const el of rest) {
|
|
1281
1361
|
i++;
|
|
1282
|
-
const result = def.rest._zod.run({
|
|
1283
|
-
value: el,
|
|
1284
|
-
issues: [],
|
|
1285
|
-
}, ctx);
|
|
1362
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
1286
1363
|
if (result instanceof Promise) {
|
|
1287
|
-
proms.push(result.then((
|
|
1364
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
1288
1365
|
}
|
|
1289
1366
|
else {
|
|
1290
1367
|
handleTupleResult(result, payload, i);
|
|
1291
1368
|
}
|
|
1292
1369
|
}
|
|
1293
1370
|
}
|
|
1294
|
-
if (proms.length)
|
|
1295
|
-
return Promise.all(proms).then(() => payload);
|
|
1296
|
-
|
|
1371
|
+
if (proms.length) {
|
|
1372
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
1373
|
+
}
|
|
1374
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
1297
1375
|
};
|
|
1298
1376
|
});
|
|
1377
|
+
function getTupleOptStart(items, key) {
|
|
1378
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
1379
|
+
if (items[i]._zod[key] !== "optional")
|
|
1380
|
+
return i + 1;
|
|
1381
|
+
}
|
|
1382
|
+
return 0;
|
|
1383
|
+
}
|
|
1299
1384
|
function handleTupleResult(result, final, index) {
|
|
1300
1385
|
if (result.issues.length) {
|
|
1301
1386
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
1302
1387
|
}
|
|
1303
1388
|
final.value[index] = result.value;
|
|
1304
1389
|
}
|
|
1390
|
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
1391
|
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
|
|
1392
|
+
// rule, but only after `optoutStart`: the first index where the output
|
|
1393
|
+
// tuple tail can be absent.
|
|
1394
|
+
for (let i = 0; i < items.length; i++) {
|
|
1395
|
+
const r = itemResults[i];
|
|
1396
|
+
const isPresent = i < input.length;
|
|
1397
|
+
if (r.issues.length) {
|
|
1398
|
+
if (!isPresent && i >= optoutStart) {
|
|
1399
|
+
final.value.length = i;
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
1403
|
+
}
|
|
1404
|
+
final.value[i] = r.value;
|
|
1405
|
+
}
|
|
1406
|
+
// Drop trailing slots that produced `undefined` for absent input
|
|
1407
|
+
// (the array analog of an absent optional key on an object). The
|
|
1408
|
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
1409
|
+
// *inside* the input must be preserved even when the schema is
|
|
1410
|
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
1411
|
+
// explicit undefined value).
|
|
1412
|
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
1413
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
1414
|
+
final.value.length = i;
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
return final;
|
|
1421
|
+
}
|
|
1305
1422
|
export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
|
|
1306
1423
|
$ZodType.init(inst, def);
|
|
1307
1424
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1323,20 +1440,36 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1323
1440
|
for (const key of values) {
|
|
1324
1441
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1325
1442
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
1443
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1444
|
+
if (keyResult instanceof Promise) {
|
|
1445
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
1446
|
+
}
|
|
1447
|
+
if (keyResult.issues.length) {
|
|
1448
|
+
payload.issues.push({
|
|
1449
|
+
code: "invalid_key",
|
|
1450
|
+
origin: "record",
|
|
1451
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1452
|
+
input: key,
|
|
1453
|
+
path: [key],
|
|
1454
|
+
inst,
|
|
1455
|
+
});
|
|
1456
|
+
continue;
|
|
1457
|
+
}
|
|
1458
|
+
const outKey = keyResult.value;
|
|
1326
1459
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1327
1460
|
if (result instanceof Promise) {
|
|
1328
1461
|
proms.push(result.then((result) => {
|
|
1329
1462
|
if (result.issues.length) {
|
|
1330
1463
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1331
1464
|
}
|
|
1332
|
-
payload.value[
|
|
1465
|
+
payload.value[outKey] = result.value;
|
|
1333
1466
|
}));
|
|
1334
1467
|
}
|
|
1335
1468
|
else {
|
|
1336
1469
|
if (result.issues.length) {
|
|
1337
1470
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1338
1471
|
}
|
|
1339
|
-
payload.value[
|
|
1472
|
+
payload.value[outKey] = result.value;
|
|
1340
1473
|
}
|
|
1341
1474
|
}
|
|
1342
1475
|
}
|
|
@@ -1358,9 +1491,12 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1358
1491
|
}
|
|
1359
1492
|
else {
|
|
1360
1493
|
payload.value = {};
|
|
1494
|
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
1361
1495
|
for (const key of Reflect.ownKeys(input)) {
|
|
1362
1496
|
if (key === "__proto__")
|
|
1363
1497
|
continue;
|
|
1498
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
|
1499
|
+
continue;
|
|
1364
1500
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1365
1501
|
if (keyResult instanceof Promise) {
|
|
1366
1502
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -1581,6 +1717,7 @@ export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def)
|
|
|
1581
1717
|
});
|
|
1582
1718
|
export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
|
|
1583
1719
|
$ZodType.init(inst, def);
|
|
1720
|
+
inst._zod.optin = "optional";
|
|
1584
1721
|
inst._zod.parse = (payload, ctx) => {
|
|
1585
1722
|
if (ctx.direction === "backward") {
|
|
1586
1723
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -1590,6 +1727,7 @@ export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (i
|
|
|
1590
1727
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1591
1728
|
return output.then((output) => {
|
|
1592
1729
|
payload.value = output;
|
|
1730
|
+
payload.fallback = true;
|
|
1593
1731
|
return payload;
|
|
1594
1732
|
});
|
|
1595
1733
|
}
|
|
@@ -1597,11 +1735,12 @@ export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (i
|
|
|
1597
1735
|
throw new core.$ZodAsyncError();
|
|
1598
1736
|
}
|
|
1599
1737
|
payload.value = _out;
|
|
1738
|
+
payload.fallback = true;
|
|
1600
1739
|
return payload;
|
|
1601
1740
|
};
|
|
1602
1741
|
});
|
|
1603
1742
|
function handleOptionalResult(result, input) {
|
|
1604
|
-
if (result.issues.length
|
|
1743
|
+
if (input === undefined && (result.issues.length || result.fallback)) {
|
|
1605
1744
|
return { issues: [], value: undefined };
|
|
1606
1745
|
}
|
|
1607
1746
|
return result;
|
|
@@ -1619,10 +1758,11 @@ export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (ins
|
|
|
1619
1758
|
});
|
|
1620
1759
|
inst._zod.parse = (payload, ctx) => {
|
|
1621
1760
|
if (def.innerType._zod.optin === "optional") {
|
|
1761
|
+
const input = payload.value;
|
|
1622
1762
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1623
1763
|
if (result instanceof Promise)
|
|
1624
|
-
return result.then((r) => handleOptionalResult(r,
|
|
1625
|
-
return handleOptionalResult(result,
|
|
1764
|
+
return result.then((r) => handleOptionalResult(r, input));
|
|
1765
|
+
return handleOptionalResult(result, input);
|
|
1626
1766
|
}
|
|
1627
1767
|
if (payload.value === undefined) {
|
|
1628
1768
|
return payload;
|
|
@@ -1749,7 +1889,7 @@ export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst,
|
|
|
1749
1889
|
});
|
|
1750
1890
|
export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
|
1751
1891
|
$ZodType.init(inst, def);
|
|
1752
|
-
|
|
1892
|
+
inst._zod.optin = "optional";
|
|
1753
1893
|
util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1754
1894
|
util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1755
1895
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1770,6 +1910,7 @@ export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def
|
|
|
1770
1910
|
input: payload.value,
|
|
1771
1911
|
});
|
|
1772
1912
|
payload.issues = [];
|
|
1913
|
+
payload.fallback = true;
|
|
1773
1914
|
}
|
|
1774
1915
|
return payload;
|
|
1775
1916
|
});
|
|
@@ -1784,6 +1925,7 @@ export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def
|
|
|
1784
1925
|
input: payload.value,
|
|
1785
1926
|
});
|
|
1786
1927
|
payload.issues = [];
|
|
1928
|
+
payload.fallback = true;
|
|
1787
1929
|
}
|
|
1788
1930
|
return payload;
|
|
1789
1931
|
};
|
|
@@ -1830,7 +1972,7 @@ function handlePipeResult(left, next, ctx) {
|
|
|
1830
1972
|
left.aborted = true;
|
|
1831
1973
|
return left;
|
|
1832
1974
|
}
|
|
1833
|
-
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
1975
|
+
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
|
|
1834
1976
|
}
|
|
1835
1977
|
export const $ZodCodec = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
|
|
1836
1978
|
$ZodType.init(inst, def);
|
|
@@ -1886,6 +2028,9 @@ function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
|
1886
2028
|
}
|
|
1887
2029
|
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
1888
2030
|
}
|
|
2031
|
+
export const $ZodPreprocess = /*@__PURE__*/ core.$constructor("$ZodPreprocess", (inst, def) => {
|
|
2032
|
+
$ZodPipe.init(inst, def);
|
|
2033
|
+
});
|
|
1889
2034
|
export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
|
|
1890
2035
|
$ZodType.init(inst, def);
|
|
1891
2036
|
util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
@@ -2043,14 +2188,15 @@ export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst,
|
|
|
2043
2188
|
});
|
|
2044
2189
|
export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
2045
2190
|
$ZodType.init(inst, def);
|
|
2046
|
-
//
|
|
2047
|
-
//
|
|
2048
|
-
//
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2191
|
+
// Cache the resolved inner type on the shared `def` so all clones of this
|
|
2192
|
+
// lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
|
|
2193
|
+
// preserving identity for cycle detection on recursive schemas.
|
|
2194
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
2195
|
+
const d = def;
|
|
2196
|
+
if (!d._cachedInner)
|
|
2197
|
+
d._cachedInner = def.getter();
|
|
2198
|
+
return d._cachedInner;
|
|
2199
|
+
});
|
|
2054
2200
|
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
2055
2201
|
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
2056
2202
|
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|
|
@@ -93,7 +93,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
93
93
|
delete result.schema.default;
|
|
94
94
|
}
|
|
95
95
|
// set prefault as default
|
|
96
|
-
if (ctx.io === "input" && result.schema
|
|
96
|
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
97
97
|
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
98
98
|
delete result.schema._prefault;
|
|
99
99
|
// pulling fresh from ctx.seen in case it was overwritten
|
|
@@ -325,11 +325,20 @@ function finalize(ctx, schema) {
|
|
|
325
325
|
result.$id = ctx.external.uri(id);
|
|
326
326
|
}
|
|
327
327
|
Object.assign(result, root.def ?? root.schema);
|
|
328
|
+
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
|
329
|
+
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
|
330
|
+
// from the output body where it would otherwise leak. The id is preserved
|
|
331
|
+
// implicitly via the $defs key (and via $ref paths).
|
|
332
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
333
|
+
if (rootMetaId !== undefined && result.id === rootMetaId)
|
|
334
|
+
delete result.id;
|
|
328
335
|
// build defs object
|
|
329
336
|
const defs = ctx.external?.defs ?? {};
|
|
330
337
|
for (const entry of ctx.seen.entries()) {
|
|
331
338
|
const seen = entry[1];
|
|
332
339
|
if (seen.def && seen.defId) {
|
|
340
|
+
if (seen.def.id === seen.defId)
|
|
341
|
+
delete seen.def.id;
|
|
333
342
|
defs[seen.defId] = seen.def;
|
|
334
343
|
}
|
|
335
344
|
}
|
|
@@ -398,6 +407,8 @@ function isTransforming(_schema, _ctx) {
|
|
|
398
407
|
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
399
408
|
}
|
|
400
409
|
if (def.type === "pipe") {
|
|
410
|
+
if (_schema._zod.traits.has("$ZodCodec"))
|
|
411
|
+
return true;
|
|
401
412
|
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
402
413
|
}
|
|
403
414
|
if (def.type === "object") {
|