agent-relay 6.0.2 → 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/README.md +10 -3
- package/dist/index.cjs +2024 -962
- package/dist/src/cli/commands/cloud.d.ts.map +1 -1
- package/dist/src/cli/commands/cloud.js +17 -144
- package/dist/src/cli/commands/cloud.js.map +1 -1
- package/dist/src/cli/commands/setup.d.ts +2 -39
- package/dist/src/cli/commands/setup.d.ts.map +1 -1
- package/dist/src/cli/commands/setup.js +4 -333
- package/dist/src/cli/commands/setup.js.map +1 -1
- package/dist/src/cli/lib/auth-ssh.d.ts +2 -33
- package/dist/src/cli/lib/auth-ssh.d.ts.map +1 -1
- package/dist/src/cli/lib/auth-ssh.js +3 -39
- package/dist/src/cli/lib/auth-ssh.js.map +1 -1
- package/dist/src/cli/lib/ssh-interactive.d.ts +4 -66
- package/dist/src/cli/lib/ssh-interactive.d.ts.map +1 -1
- package/dist/src/cli/lib/ssh-interactive.js +4 -436
- package/dist/src/cli/lib/ssh-interactive.js.map +1 -1
- 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 +10 -10
|
@@ -34,7 +34,7 @@ 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
39
|
}
|
|
40
40
|
|
|
@@ -220,6 +220,7 @@ export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constru
|
|
|
220
220
|
let asyncResult!: Promise<unknown> | undefined;
|
|
221
221
|
for (const ch of checks) {
|
|
222
222
|
if (ch._zod.def.when) {
|
|
223
|
+
if (util.explicitlyAborted(payload)) continue;
|
|
223
224
|
const shouldRun = ch._zod.def.when(payload);
|
|
224
225
|
if (!shouldRun) continue;
|
|
225
226
|
} else if (isAborted) {
|
|
@@ -477,6 +478,23 @@ export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$construct
|
|
|
477
478
|
try {
|
|
478
479
|
// Trim whitespace from input
|
|
479
480
|
const trimmed = payload.value.trim();
|
|
481
|
+
|
|
482
|
+
// When normalize is off, require :// for http/https URLs
|
|
483
|
+
// This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
484
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
|
|
485
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
486
|
+
payload.issues.push({
|
|
487
|
+
code: "invalid_format",
|
|
488
|
+
format: "url",
|
|
489
|
+
note: "Invalid URL format",
|
|
490
|
+
input: payload.value,
|
|
491
|
+
inst,
|
|
492
|
+
continue: !def.abort,
|
|
493
|
+
});
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
480
498
|
// @ts-ignore
|
|
481
499
|
const url = new URL(trimmed);
|
|
482
500
|
|
|
@@ -568,13 +586,33 @@ export const $ZodNanoID: core.$constructor<$ZodNanoID> = /*@__PURE__*/ core.$con
|
|
|
568
586
|
|
|
569
587
|
////////////////////////////// ZodCUID //////////////////////////////
|
|
570
588
|
|
|
589
|
+
/**
|
|
590
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
591
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
592
|
+
* See https://github.com/paralleldrive/cuid.
|
|
593
|
+
*/
|
|
571
594
|
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {}
|
|
595
|
+
/**
|
|
596
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
597
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
598
|
+
* See https://github.com/paralleldrive/cuid.
|
|
599
|
+
*/
|
|
572
600
|
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {}
|
|
573
601
|
|
|
602
|
+
/**
|
|
603
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
604
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
605
|
+
* See https://github.com/paralleldrive/cuid.
|
|
606
|
+
*/
|
|
574
607
|
export interface $ZodCUID extends $ZodType {
|
|
575
608
|
_zod: $ZodCUIDInternals;
|
|
576
609
|
}
|
|
577
610
|
|
|
611
|
+
/**
|
|
612
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
613
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
614
|
+
* See https://github.com/paralleldrive/cuid.
|
|
615
|
+
*/
|
|
578
616
|
export const $ZodCUID: core.$constructor<$ZodCUID> = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def): void => {
|
|
579
617
|
def.pattern ??= regexes.cuid;
|
|
580
618
|
$ZodStringFormat.init(inst, def);
|
|
@@ -869,6 +907,8 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
|
|
|
869
907
|
////////////////////////////// ZodBase64 //////////////////////////////
|
|
870
908
|
export function isValidBase64(data: string): boolean {
|
|
871
909
|
if (data === "") return true;
|
|
910
|
+
// atob ignores whitespace, so reject it up front.
|
|
911
|
+
if (/\s/.test(data)) return false;
|
|
872
912
|
if (data.length % 4 !== 0) return false;
|
|
873
913
|
try {
|
|
874
914
|
// @ts-ignore
|
|
@@ -1318,8 +1358,6 @@ export const $ZodUndefined: core.$constructor<$ZodUndefined> = /*@__PURE__*/ cor
|
|
|
1318
1358
|
$ZodType.init(inst, def);
|
|
1319
1359
|
inst._zod.pattern = regexes.undefined;
|
|
1320
1360
|
inst._zod.values = new Set([undefined]);
|
|
1321
|
-
inst._zod.optin = "optional";
|
|
1322
|
-
inst._zod.optout = "optional";
|
|
1323
1361
|
|
|
1324
1362
|
inst._zod.parse = (payload, _ctx) => {
|
|
1325
1363
|
const input = payload.value;
|
|
@@ -1709,18 +1747,32 @@ function handlePropertyResult(
|
|
|
1709
1747
|
final: ParsePayload,
|
|
1710
1748
|
key: PropertyKey,
|
|
1711
1749
|
input: any,
|
|
1750
|
+
isOptionalIn: boolean,
|
|
1712
1751
|
isOptionalOut: boolean
|
|
1713
1752
|
) {
|
|
1753
|
+
const isPresent = key in input;
|
|
1714
1754
|
if (result.issues.length) {
|
|
1715
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
1716
|
-
if (isOptionalOut && !
|
|
1755
|
+
// For optional-in/out schemas, ignore errors on absent keys.
|
|
1756
|
+
if (isOptionalIn && isOptionalOut && !isPresent) {
|
|
1717
1757
|
return;
|
|
1718
1758
|
}
|
|
1719
1759
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
1720
1760
|
}
|
|
1721
1761
|
|
|
1762
|
+
if (!isPresent && !isOptionalIn) {
|
|
1763
|
+
if (!result.issues.length) {
|
|
1764
|
+
final.issues.push({
|
|
1765
|
+
code: "invalid_type",
|
|
1766
|
+
expected: "nonoptional",
|
|
1767
|
+
input: undefined,
|
|
1768
|
+
path: [key],
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
return;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1722
1774
|
if (result.value === undefined) {
|
|
1723
|
-
if (
|
|
1775
|
+
if (isPresent) {
|
|
1724
1776
|
(final.value as any)[key] = undefined;
|
|
1725
1777
|
}
|
|
1726
1778
|
} else {
|
|
@@ -1805,12 +1857,15 @@ function handleCatchall(
|
|
|
1805
1857
|
inst: $ZodObject
|
|
1806
1858
|
) {
|
|
1807
1859
|
const unrecognized: string[] = [];
|
|
1808
|
-
// iterate over input keys
|
|
1809
1860
|
const keySet = def.keySet;
|
|
1810
1861
|
const _catchall = def.catchall!._zod;
|
|
1811
1862
|
const t = _catchall.def.type;
|
|
1863
|
+
const isOptionalIn = _catchall.optin === "optional";
|
|
1812
1864
|
const isOptionalOut = _catchall.optout === "optional";
|
|
1813
1865
|
for (const key in input) {
|
|
1866
|
+
// skip __proto__ so it can't replace the result prototype via the
|
|
1867
|
+
// assignment setter on the plain {} we build into
|
|
1868
|
+
if (key === "__proto__") continue;
|
|
1814
1869
|
if (keySet.has(key)) continue;
|
|
1815
1870
|
if (t === "never") {
|
|
1816
1871
|
unrecognized.push(key);
|
|
@@ -1819,9 +1874,9 @@ function handleCatchall(
|
|
|
1819
1874
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1820
1875
|
|
|
1821
1876
|
if (r instanceof Promise) {
|
|
1822
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
1877
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1823
1878
|
} else {
|
|
1824
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1879
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
1825
1880
|
}
|
|
1826
1881
|
}
|
|
1827
1882
|
|
|
@@ -1899,13 +1954,14 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
|
|
|
1899
1954
|
|
|
1900
1955
|
for (const key of value.keys) {
|
|
1901
1956
|
const el = shape[key]!;
|
|
1957
|
+
const isOptionalIn = el._zod.optin === "optional";
|
|
1902
1958
|
const isOptionalOut = el._zod.optout === "optional";
|
|
1903
1959
|
|
|
1904
1960
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1905
1961
|
if (r instanceof Promise) {
|
|
1906
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
1962
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1907
1963
|
} else {
|
|
1908
|
-
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1964
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
1909
1965
|
}
|
|
1910
1966
|
}
|
|
1911
1967
|
|
|
@@ -1949,12 +2005,13 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
1949
2005
|
const id = ids[key];
|
|
1950
2006
|
const k = util.esc(key);
|
|
1951
2007
|
const schema = shape[key];
|
|
2008
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
1952
2009
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1953
2010
|
|
|
1954
2011
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1955
2012
|
|
|
1956
|
-
if (isOptionalOut) {
|
|
1957
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
2013
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2014
|
+
// For optional-in/out schemas, ignore errors on absent keys
|
|
1958
2015
|
doc.write(`
|
|
1959
2016
|
if (${id}.issues.length) {
|
|
1960
2017
|
if (${k} in input) {
|
|
@@ -1973,6 +2030,33 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
1973
2030
|
newResult[${k}] = ${id}.value;
|
|
1974
2031
|
}
|
|
1975
2032
|
|
|
2033
|
+
`);
|
|
2034
|
+
} else if (!isOptionalIn) {
|
|
2035
|
+
doc.write(`
|
|
2036
|
+
const ${id}_present = ${k} in input;
|
|
2037
|
+
if (${id}.issues.length) {
|
|
2038
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2039
|
+
...iss,
|
|
2040
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2041
|
+
})));
|
|
2042
|
+
}
|
|
2043
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
2044
|
+
payload.issues.push({
|
|
2045
|
+
code: "invalid_type",
|
|
2046
|
+
expected: "nonoptional",
|
|
2047
|
+
input: undefined,
|
|
2048
|
+
path: [${k}]
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
if (${id}_present) {
|
|
2053
|
+
if (${id}.value === undefined) {
|
|
2054
|
+
newResult[${k}] = undefined;
|
|
2055
|
+
} else {
|
|
2056
|
+
newResult[${k}] = ${id}.value;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
|
|
1976
2060
|
`);
|
|
1977
2061
|
} else {
|
|
1978
2062
|
doc.write(`
|
|
@@ -2126,11 +2210,10 @@ export const $ZodUnion: core.$constructor<$ZodUnion> = /*@__PURE__*/ core.$const
|
|
|
2126
2210
|
return undefined;
|
|
2127
2211
|
});
|
|
2128
2212
|
|
|
2129
|
-
const
|
|
2130
|
-
const first = def.options[0]._zod.run;
|
|
2213
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2131
2214
|
|
|
2132
2215
|
inst._zod.parse = (payload, ctx) => {
|
|
2133
|
-
if (
|
|
2216
|
+
if (first) {
|
|
2134
2217
|
return first(payload, ctx);
|
|
2135
2218
|
}
|
|
2136
2219
|
let async = false;
|
|
@@ -2206,11 +2289,10 @@ export const $ZodXor: core.$constructor<$ZodXor> = /*@__PURE__*/ core.$construct
|
|
|
2206
2289
|
$ZodUnion.init(inst, def);
|
|
2207
2290
|
def.inclusive = false;
|
|
2208
2291
|
|
|
2209
|
-
const
|
|
2210
|
-
const first = def.options[0]._zod.run;
|
|
2292
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2211
2293
|
|
|
2212
2294
|
inst._zod.parse = (payload, ctx) => {
|
|
2213
|
-
if (
|
|
2295
|
+
if (first) {
|
|
2214
2296
|
return first(payload, ctx);
|
|
2215
2297
|
}
|
|
2216
2298
|
let async = false;
|
|
@@ -2329,17 +2411,21 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2329
2411
|
return opt._zod.run(payload, ctx) as any;
|
|
2330
2412
|
}
|
|
2331
2413
|
|
|
2332
|
-
|
|
2414
|
+
// Fall back to union matching when the fast discriminator path fails:
|
|
2415
|
+
// - explicitly enabled via unionFallback, or
|
|
2416
|
+
// - during backward direction (encode), since codec-based discriminators
|
|
2417
|
+
// have different values in forward vs backward directions
|
|
2418
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
2333
2419
|
return _super(payload, ctx);
|
|
2334
2420
|
}
|
|
2335
2421
|
|
|
2336
2422
|
// no matching discriminator
|
|
2337
2423
|
payload.issues.push({
|
|
2338
2424
|
code: "invalid_union",
|
|
2339
|
-
|
|
2340
2425
|
errors: [],
|
|
2341
2426
|
note: "No matching discriminator",
|
|
2342
2427
|
discriminator: def.discriminator,
|
|
2428
|
+
options: Array.from(disc.value.keys()),
|
|
2343
2429
|
input,
|
|
2344
2430
|
path: [def.discriminator],
|
|
2345
2431
|
inst,
|
|
@@ -2591,70 +2677,79 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
|
|
|
2591
2677
|
payload.value = [];
|
|
2592
2678
|
const proms: Promise<any>[] = [];
|
|
2593
2679
|
|
|
2594
|
-
const
|
|
2595
|
-
const
|
|
2680
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
2681
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
2596
2682
|
|
|
2597
2683
|
if (!def.rest) {
|
|
2598
|
-
|
|
2599
|
-
const tooSmall = input.length < optStart - 1;
|
|
2600
|
-
if (tooBig || tooSmall) {
|
|
2684
|
+
if (input.length < optinStart) {
|
|
2601
2685
|
payload.issues.push({
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2686
|
+
code: "too_small",
|
|
2687
|
+
minimum: optinStart,
|
|
2688
|
+
inclusive: true,
|
|
2606
2689
|
input,
|
|
2607
2690
|
inst,
|
|
2608
2691
|
origin: "array" as const,
|
|
2609
2692
|
});
|
|
2610
2693
|
return payload;
|
|
2611
2694
|
}
|
|
2695
|
+
if (input.length > items.length) {
|
|
2696
|
+
payload.issues.push({
|
|
2697
|
+
code: "too_big",
|
|
2698
|
+
maximum: items.length,
|
|
2699
|
+
inclusive: true,
|
|
2700
|
+
input,
|
|
2701
|
+
inst,
|
|
2702
|
+
origin: "array" as const,
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2612
2705
|
}
|
|
2613
2706
|
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
2707
|
+
// Run every item in parallel, collecting results into an indexed
|
|
2708
|
+
// array. The post-processing in `handleTupleResults` walks them in
|
|
2709
|
+
// order so it can decide whether an absent optional-output error can
|
|
2710
|
+
// truncate the tail or must be reported to preserve required output.
|
|
2711
|
+
const itemResults: ParsePayload[] = new Array(items.length);
|
|
2712
|
+
for (let i = 0; i < items.length; i++) {
|
|
2713
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
2714
|
+
if (r instanceof Promise) {
|
|
2715
|
+
proms.push(
|
|
2716
|
+
r.then((rr) => {
|
|
2717
|
+
itemResults[i] = rr;
|
|
2718
|
+
})
|
|
2719
|
+
);
|
|
2628
2720
|
} else {
|
|
2629
|
-
|
|
2721
|
+
itemResults[i] = r;
|
|
2630
2722
|
}
|
|
2631
2723
|
}
|
|
2632
2724
|
|
|
2633
2725
|
if (def.rest) {
|
|
2726
|
+
let i = items.length - 1;
|
|
2634
2727
|
const rest = input.slice(items.length);
|
|
2635
2728
|
for (const el of rest) {
|
|
2636
2729
|
i++;
|
|
2637
|
-
const result = def.rest._zod.run(
|
|
2638
|
-
{
|
|
2639
|
-
value: el,
|
|
2640
|
-
issues: [],
|
|
2641
|
-
},
|
|
2642
|
-
ctx
|
|
2643
|
-
);
|
|
2644
|
-
|
|
2730
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
2645
2731
|
if (result instanceof Promise) {
|
|
2646
|
-
proms.push(result.then((
|
|
2732
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
2647
2733
|
} else {
|
|
2648
2734
|
handleTupleResult(result, payload, i);
|
|
2649
2735
|
}
|
|
2650
2736
|
}
|
|
2651
2737
|
}
|
|
2652
2738
|
|
|
2653
|
-
if (proms.length)
|
|
2654
|
-
|
|
2739
|
+
if (proms.length) {
|
|
2740
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
2741
|
+
}
|
|
2742
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
2655
2743
|
};
|
|
2656
2744
|
});
|
|
2657
2745
|
|
|
2746
|
+
function getTupleOptStart(items: readonly $ZodType[], key: "optin" | "optout") {
|
|
2747
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
2748
|
+
if (items[i]._zod[key] !== "optional") return i + 1;
|
|
2749
|
+
}
|
|
2750
|
+
return 0;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2658
2753
|
function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, index: number) {
|
|
2659
2754
|
if (result.issues.length) {
|
|
2660
2755
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -2662,6 +2757,45 @@ function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, ind
|
|
|
2662
2757
|
final.value[index] = result.value;
|
|
2663
2758
|
}
|
|
2664
2759
|
|
|
2760
|
+
function handleTupleResults(
|
|
2761
|
+
itemResults: ParsePayload[],
|
|
2762
|
+
final: ParsePayload<any[]>,
|
|
2763
|
+
items: readonly $ZodType[],
|
|
2764
|
+
input: unknown[],
|
|
2765
|
+
optoutStart: number
|
|
2766
|
+
) {
|
|
2767
|
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
|
|
2768
|
+
// rule, but only after `optoutStart`: the first index where the output
|
|
2769
|
+
// tuple tail can be absent.
|
|
2770
|
+
for (let i = 0; i < items.length; i++) {
|
|
2771
|
+
const r = itemResults[i];
|
|
2772
|
+
const isPresent = i < input.length;
|
|
2773
|
+
if (r.issues.length) {
|
|
2774
|
+
if (!isPresent && i >= optoutStart) {
|
|
2775
|
+
final.value.length = i;
|
|
2776
|
+
break;
|
|
2777
|
+
}
|
|
2778
|
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
2779
|
+
}
|
|
2780
|
+
final.value[i] = r.value;
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
// Drop trailing slots that produced `undefined` for absent input
|
|
2784
|
+
// (the array analog of an absent optional key on an object). The
|
|
2785
|
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
2786
|
+
// *inside* the input must be preserved even when the schema is
|
|
2787
|
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
2788
|
+
// explicit undefined value).
|
|
2789
|
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
2790
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
2791
|
+
final.value.length = i;
|
|
2792
|
+
} else {
|
|
2793
|
+
break;
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
return final;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2665
2799
|
//////////////////////////////////////////
|
|
2666
2800
|
//////////////////////////////////////////
|
|
2667
2801
|
////////// //////////
|
|
@@ -2759,6 +2893,22 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2759
2893
|
for (const key of values) {
|
|
2760
2894
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
2761
2895
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2896
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2897
|
+
if (keyResult instanceof Promise) {
|
|
2898
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
2899
|
+
}
|
|
2900
|
+
if (keyResult.issues.length) {
|
|
2901
|
+
payload.issues.push({
|
|
2902
|
+
code: "invalid_key",
|
|
2903
|
+
origin: "record",
|
|
2904
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
2905
|
+
input: key,
|
|
2906
|
+
path: [key],
|
|
2907
|
+
inst,
|
|
2908
|
+
});
|
|
2909
|
+
continue;
|
|
2910
|
+
}
|
|
2911
|
+
const outKey = keyResult.value as PropertyKey;
|
|
2762
2912
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2763
2913
|
|
|
2764
2914
|
if (result instanceof Promise) {
|
|
@@ -2767,14 +2917,14 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2767
2917
|
if (result.issues.length) {
|
|
2768
2918
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2769
2919
|
}
|
|
2770
|
-
payload.value[
|
|
2920
|
+
payload.value[outKey] = result.value;
|
|
2771
2921
|
})
|
|
2772
2922
|
);
|
|
2773
2923
|
} else {
|
|
2774
2924
|
if (result.issues.length) {
|
|
2775
2925
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2776
2926
|
}
|
|
2777
|
-
payload.value[
|
|
2927
|
+
payload.value[outKey] = result.value;
|
|
2778
2928
|
}
|
|
2779
2929
|
}
|
|
2780
2930
|
}
|
|
@@ -2797,8 +2947,10 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2797
2947
|
}
|
|
2798
2948
|
} else {
|
|
2799
2949
|
payload.value = {};
|
|
2950
|
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
2800
2951
|
for (const key of Reflect.ownKeys(input)) {
|
|
2801
2952
|
if (key === "__proto__") continue;
|
|
2953
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
|
|
2802
2954
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2803
2955
|
if (keyResult instanceof Promise) {
|
|
2804
2956
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -4384,14 +4536,14 @@ export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
4384
4536
|
export const $ZodLazy: core.$constructor<$ZodLazy> = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
4385
4537
|
$ZodType.init(inst, def);
|
|
4386
4538
|
|
|
4387
|
-
//
|
|
4388
|
-
//
|
|
4389
|
-
//
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4539
|
+
// Cache the resolved inner type on the shared `def` so all clones of this
|
|
4540
|
+
// lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
|
|
4541
|
+
// preserving identity for cycle detection on recursive schemas.
|
|
4542
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
4543
|
+
const d = def as $ZodLazyDef & { _cachedInner?: $ZodType };
|
|
4544
|
+
if (!d._cachedInner) d._cachedInner = def.getter() as $ZodType;
|
|
4545
|
+
return d._cachedInner;
|
|
4546
|
+
});
|
|
4395
4547
|
util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
|
|
4396
4548
|
util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
4397
4549
|
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|