agent-relay 6.0.3 → 6.0.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/dist/index.cjs +1395 -674
- package/node_modules/@relaycast/sdk/node_modules/zod/README.md +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/locales/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/mini/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/package.json +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/object.test.ts +5 -5
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/errors.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/external.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/from-json-schema.ts +39 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/parse.ts +6 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/schemas.ts +389 -148
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/catch.test.ts +4 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/codec.test.ts +142 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/continuability.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/datetime.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/default.test.ts +44 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +31 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +214 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +161 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/function.test.ts +6 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/index.test.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/number.test.ts +55 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/object.test.ts +83 -6
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/optional.test.ts +114 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/partial.test.ts +28 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/prefault.test.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/record.test.ts +85 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +49 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/refine.test.ts +63 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/string.test.ts +50 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +4 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +128 -14
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/tuple.test.ts +315 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/union.test.ts +54 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/api.ts +25 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/checks.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/core.ts +17 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/errors.ts +31 -24
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/json-schema-processors.ts +15 -17
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/parse.ts +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/regexes.ts +8 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/schemas.ts +218 -66
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/to-json-schema.ts +9 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/util.ts +52 -35
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/en.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/fr.ts +24 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/index.ts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/it.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ka.ts +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/uz.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/external.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/schemas.ts +55 -24
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/codec.test.ts +19 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/index.test.ts +27 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/object.test.ts +9 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +51 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/string.test.ts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v3/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/errors.js +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.cjs +31 -16
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.js +31 -16
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.cjs +346 -117
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.cts +34 -12
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.ts +34 -12
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.js +345 -117
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.cjs +7 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.cts +20 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.ts +20 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.js +7 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.cts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.cjs +3 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.js +4 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.cjs +26 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.js +26 -23
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.cjs +14 -19
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.js +14 -19
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.cjs +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.js +7 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.cjs +9 -3
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.cts +6 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.ts +6 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.js +7 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.cjs +196 -59
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.cts +21 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.ts +21 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.js +196 -59
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.cjs +10 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.js +10 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.cjs +54 -30
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.js +55 -32
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.cjs +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.cjs +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.js +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.cjs +24 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.js +24 -7
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.cjs +8 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.cts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.ts +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.js +3 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.cjs +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.js +1 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.cjs +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.js +8 -8
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.cjs +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.js +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.cts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.ts +1 -0
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.cjs +41 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.cts +27 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.ts +27 -9
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.js +40 -4
- package/node_modules/@relaycast/sdk/node_modules/zod/v4/package.json +2 -1
- package/node_modules/@relaycast/sdk/node_modules/zod/v4-mini/package.json +2 -1
- package/package.json +9 -9
|
@@ -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");
|
|
@@ -2043,14 +2179,15 @@ export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst,
|
|
|
2043
2179
|
});
|
|
2044
2180
|
export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
2045
2181
|
$ZodType.init(inst, def);
|
|
2046
|
-
//
|
|
2047
|
-
//
|
|
2048
|
-
//
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2182
|
+
// Cache the resolved inner type on the shared `def` so all clones of this
|
|
2183
|
+
// lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
|
|
2184
|
+
// preserving identity for cycle detection on recursive schemas.
|
|
2185
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
2186
|
+
const d = def;
|
|
2187
|
+
if (!d._cachedInner)
|
|
2188
|
+
d._cachedInner = def.getter();
|
|
2189
|
+
return d._cachedInner;
|
|
2190
|
+
});
|
|
2054
2191
|
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
2055
2192
|
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
2056
2193
|
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
|
}
|
|
@@ -86,7 +86,7 @@ export function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
86
86
|
delete result.schema.default;
|
|
87
87
|
}
|
|
88
88
|
// set prefault as default
|
|
89
|
-
if (ctx.io === "input" && result.schema
|
|
89
|
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
90
90
|
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
91
91
|
delete result.schema._prefault;
|
|
92
92
|
// pulling fresh from ctx.seen in case it was overwritten
|
|
@@ -318,11 +318,20 @@ export function finalize(ctx, schema) {
|
|
|
318
318
|
result.$id = ctx.external.uri(id);
|
|
319
319
|
}
|
|
320
320
|
Object.assign(result, root.def ?? root.schema);
|
|
321
|
+
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
|
322
|
+
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
|
323
|
+
// from the output body where it would otherwise leak. The id is preserved
|
|
324
|
+
// implicitly via the $defs key (and via $ref paths).
|
|
325
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
326
|
+
if (rootMetaId !== undefined && result.id === rootMetaId)
|
|
327
|
+
delete result.id;
|
|
321
328
|
// build defs object
|
|
322
329
|
const defs = ctx.external?.defs ?? {};
|
|
323
330
|
for (const entry of ctx.seen.entries()) {
|
|
324
331
|
const seen = entry[1];
|
|
325
332
|
if (seen.def && seen.defId) {
|
|
333
|
+
if (seen.def.id === seen.defId)
|
|
334
|
+
delete seen.def.id;
|
|
326
335
|
defs[seen.defId] = seen.def;
|
|
327
336
|
}
|
|
328
337
|
}
|
|
@@ -41,6 +41,7 @@ exports.merge = merge;
|
|
|
41
41
|
exports.partial = partial;
|
|
42
42
|
exports.required = required;
|
|
43
43
|
exports.aborted = aborted;
|
|
44
|
+
exports.explicitlyAborted = explicitlyAborted;
|
|
44
45
|
exports.prefixIssues = prefixIssues;
|
|
45
46
|
exports.unwrapMessage = unwrapMessage;
|
|
46
47
|
exports.finalizeIssue = finalizeIssue;
|
|
@@ -55,6 +56,7 @@ exports.base64urlToUint8Array = base64urlToUint8Array;
|
|
|
55
56
|
exports.uint8ArrayToBase64url = uint8ArrayToBase64url;
|
|
56
57
|
exports.hexToUint8Array = hexToUint8Array;
|
|
57
58
|
exports.uint8ArrayToHex = uint8ArrayToHex;
|
|
59
|
+
const core_js_1 = require("./core.cjs");
|
|
58
60
|
// functions
|
|
59
61
|
function assertEqual(val) {
|
|
60
62
|
return val;
|
|
@@ -104,21 +106,15 @@ function cleanRegex(source) {
|
|
|
104
106
|
return source.slice(start, end);
|
|
105
107
|
}
|
|
106
108
|
function floatSafeRemainder(val, step) {
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
117
|
-
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
118
|
-
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
119
|
-
return (valInt % stepInt) / 10 ** decCount;
|
|
120
|
-
}
|
|
121
|
-
const EVALUATING = Symbol("evaluating");
|
|
109
|
+
const ratio = val / step;
|
|
110
|
+
const roundedRatio = Math.round(ratio);
|
|
111
|
+
// Use a relative epsilon scaled to the magnitude of the result
|
|
112
|
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
113
|
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
114
|
+
return 0;
|
|
115
|
+
return ratio - roundedRatio;
|
|
116
|
+
}
|
|
117
|
+
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
122
118
|
function defineLazy(object, key, getter) {
|
|
123
119
|
let value = undefined;
|
|
124
120
|
Object.defineProperty(object, key, {
|
|
@@ -205,6 +201,11 @@ function isObject(data) {
|
|
|
205
201
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
206
202
|
}
|
|
207
203
|
exports.allowsEval = cached(() => {
|
|
204
|
+
// Skip the probe under `jitless`: strict CSPs report the caught `new Function`
|
|
205
|
+
// as a `securitypolicyviolation` even though the throw is swallowed.
|
|
206
|
+
if (core_js_1.globalConfig.jitless) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
208
209
|
// @ts-ignore
|
|
209
210
|
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
210
211
|
return false;
|
|
@@ -242,6 +243,10 @@ function shallowClone(o) {
|
|
|
242
243
|
return { ...o };
|
|
243
244
|
if (Array.isArray(o))
|
|
244
245
|
return [...o];
|
|
246
|
+
if (o instanceof Map)
|
|
247
|
+
return new Map(o);
|
|
248
|
+
if (o instanceof Set)
|
|
249
|
+
return new Set(o);
|
|
245
250
|
return o;
|
|
246
251
|
}
|
|
247
252
|
function numKeys(data) {
|
|
@@ -300,7 +305,14 @@ const getParsedType = (data) => {
|
|
|
300
305
|
};
|
|
301
306
|
exports.getParsedType = getParsedType;
|
|
302
307
|
exports.propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
303
|
-
exports.primitiveTypes = new Set([
|
|
308
|
+
exports.primitiveTypes = new Set([
|
|
309
|
+
"string",
|
|
310
|
+
"number",
|
|
311
|
+
"bigint",
|
|
312
|
+
"boolean",
|
|
313
|
+
"symbol",
|
|
314
|
+
"undefined",
|
|
315
|
+
]);
|
|
304
316
|
function escapeRegex(str) {
|
|
305
317
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
306
318
|
}
|
|
@@ -472,6 +484,9 @@ function safeExtend(schema, shape) {
|
|
|
472
484
|
return clone(schema, def);
|
|
473
485
|
}
|
|
474
486
|
function merge(a, b) {
|
|
487
|
+
if (a._zod.def.checks?.length) {
|
|
488
|
+
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
489
|
+
}
|
|
475
490
|
const def = mergeDefs(a._zod.def, {
|
|
476
491
|
get shape() {
|
|
477
492
|
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
@@ -481,7 +496,7 @@ function merge(a, b) {
|
|
|
481
496
|
get catchall() {
|
|
482
497
|
return b._zod.def.catchall;
|
|
483
498
|
},
|
|
484
|
-
checks: [],
|
|
499
|
+
checks: b._zod.def.checks ?? [],
|
|
485
500
|
});
|
|
486
501
|
return clone(a, def);
|
|
487
502
|
}
|
|
@@ -575,6 +590,18 @@ function aborted(x, startIndex = 0) {
|
|
|
575
590
|
}
|
|
576
591
|
return false;
|
|
577
592
|
}
|
|
593
|
+
// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).
|
|
594
|
+
// Used to respect `abort: true` in .refine() even for checks that have a `when` function.
|
|
595
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
596
|
+
if (x.aborted === true)
|
|
597
|
+
return true;
|
|
598
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
599
|
+
if (x.issues[i]?.continue === false) {
|
|
600
|
+
return true;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
578
605
|
function prefixIssues(path, issues) {
|
|
579
606
|
return issues.map((iss) => {
|
|
580
607
|
var _a;
|
|
@@ -587,23 +614,20 @@ function unwrapMessage(message) {
|
|
|
587
614
|
return typeof message === "string" ? message : message?.message;
|
|
588
615
|
}
|
|
589
616
|
function finalizeIssue(iss, ctx, config) {
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
|
617
|
+
const message = iss.message
|
|
618
|
+
? iss.message
|
|
619
|
+
: (unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
|
594
620
|
unwrapMessage(ctx?.error?.(iss)) ??
|
|
595
621
|
unwrapMessage(config.customError?.(iss)) ??
|
|
596
622
|
unwrapMessage(config.localeError?.(iss)) ??
|
|
597
|
-
"Invalid input";
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
if (!ctx?.reportInput) {
|
|
604
|
-
delete full.input;
|
|
623
|
+
"Invalid input");
|
|
624
|
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
625
|
+
rest.path ?? (rest.path = []);
|
|
626
|
+
rest.message = message;
|
|
627
|
+
if (ctx?.reportInput) {
|
|
628
|
+
rest.input = _input;
|
|
605
629
|
}
|
|
606
|
-
return
|
|
630
|
+
return rest;
|
|
607
631
|
}
|
|
608
632
|
function getSizableOrigin(input) {
|
|
609
633
|
if (input instanceof Set)
|