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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { $ZodStringFormats } from "../core/checks.js";
|
|
2
|
+
import type * as errors from "../core/errors.js";
|
|
3
|
+
import * as util from "../core/util.js";
|
|
4
|
+
|
|
5
|
+
const error: () => errors.$ZodErrorMap = () => {
|
|
6
|
+
const Sizable: Record<string, { unit: string; verb: string }> = {
|
|
7
|
+
string: { unit: "caractere", verb: "să aibă" },
|
|
8
|
+
file: { unit: "octeți", verb: "să aibă" },
|
|
9
|
+
array: { unit: "elemente", verb: "să aibă" },
|
|
10
|
+
set: { unit: "elemente", verb: "să aibă" },
|
|
11
|
+
map: { unit: "intrări", verb: "să aibă" },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function getSizing(origin: string): { unit: string; verb: string } | null {
|
|
15
|
+
return Sizable[origin] ?? null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const FormatDictionary: {
|
|
19
|
+
[k in $ZodStringFormats | (string & {})]?: string;
|
|
20
|
+
} = {
|
|
21
|
+
regex: "intrare",
|
|
22
|
+
email: "adresă de email",
|
|
23
|
+
url: "URL",
|
|
24
|
+
emoji: "emoji",
|
|
25
|
+
uuid: "UUID",
|
|
26
|
+
uuidv4: "UUIDv4",
|
|
27
|
+
uuidv6: "UUIDv6",
|
|
28
|
+
nanoid: "nanoid",
|
|
29
|
+
guid: "GUID",
|
|
30
|
+
cuid: "cuid",
|
|
31
|
+
cuid2: "cuid2",
|
|
32
|
+
ulid: "ULID",
|
|
33
|
+
xid: "XID",
|
|
34
|
+
ksuid: "KSUID",
|
|
35
|
+
datetime: "dată și oră ISO",
|
|
36
|
+
date: "dată ISO",
|
|
37
|
+
time: "oră ISO",
|
|
38
|
+
duration: "durată ISO",
|
|
39
|
+
ipv4: "adresă IPv4",
|
|
40
|
+
ipv6: "adresă IPv6",
|
|
41
|
+
mac: "adresă MAC",
|
|
42
|
+
cidrv4: "interval IPv4",
|
|
43
|
+
cidrv6: "interval IPv6",
|
|
44
|
+
base64: "șir codat base64",
|
|
45
|
+
base64url: "șir codat base64url",
|
|
46
|
+
json_string: "șir JSON",
|
|
47
|
+
e164: "număr E.164",
|
|
48
|
+
jwt: "JWT",
|
|
49
|
+
template_literal: "intrare",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const TypeDictionary: {
|
|
53
|
+
[k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
|
|
54
|
+
} = {
|
|
55
|
+
nan: "NaN",
|
|
56
|
+
string: "șir",
|
|
57
|
+
number: "număr",
|
|
58
|
+
boolean: "boolean",
|
|
59
|
+
function: "funcție",
|
|
60
|
+
array: "matrice",
|
|
61
|
+
object: "obiect",
|
|
62
|
+
undefined: "nedefinit",
|
|
63
|
+
symbol: "simbol",
|
|
64
|
+
bigint: "număr mare",
|
|
65
|
+
void: "void",
|
|
66
|
+
never: "never",
|
|
67
|
+
map: "hartă",
|
|
68
|
+
set: "set",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (issue) => {
|
|
72
|
+
switch (issue.code) {
|
|
73
|
+
case "invalid_type": {
|
|
74
|
+
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
|
75
|
+
const receivedType = util.parsedType(issue.input);
|
|
76
|
+
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
77
|
+
return `Intrare invalidă: așteptat ${expected}, primit ${received}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
case "invalid_value":
|
|
81
|
+
if (issue.values.length === 1) return `Intrare invalidă: așteptat ${util.stringifyPrimitive(issue.values[0])}`;
|
|
82
|
+
return `Opțiune invalidă: așteptat una dintre ${util.joinValues(issue.values, "|")}`;
|
|
83
|
+
case "too_big": {
|
|
84
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
85
|
+
const sizing = getSizing(issue.origin);
|
|
86
|
+
if (sizing)
|
|
87
|
+
return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemente"}`;
|
|
88
|
+
return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} să fie ${adj}${issue.maximum.toString()}`;
|
|
89
|
+
}
|
|
90
|
+
case "too_small": {
|
|
91
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
92
|
+
const sizing = getSizing(issue.origin);
|
|
93
|
+
if (sizing) {
|
|
94
|
+
return `Prea mic: așteptat ca ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return `Prea mic: așteptat ca ${issue.origin} să fie ${adj}${issue.minimum.toString()}`;
|
|
98
|
+
}
|
|
99
|
+
case "invalid_format": {
|
|
100
|
+
const _issue = issue as errors.$ZodStringFormatIssues;
|
|
101
|
+
if (_issue.format === "starts_with") {
|
|
102
|
+
return `Șir invalid: trebuie să înceapă cu "${_issue.prefix}"`;
|
|
103
|
+
}
|
|
104
|
+
if (_issue.format === "ends_with") return `Șir invalid: trebuie să se termine cu "${_issue.suffix}"`;
|
|
105
|
+
if (_issue.format === "includes") return `Șir invalid: trebuie să includă "${_issue.includes}"`;
|
|
106
|
+
if (_issue.format === "regex") return `Șir invalid: trebuie să se potrivească cu modelul ${_issue.pattern}`;
|
|
107
|
+
return `Format invalid: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
108
|
+
}
|
|
109
|
+
case "not_multiple_of":
|
|
110
|
+
return `Număr invalid: trebuie să fie multiplu de ${issue.divisor}`;
|
|
111
|
+
case "unrecognized_keys":
|
|
112
|
+
return `Chei nerecunoscute: ${util.joinValues(issue.keys, ", ")}`;
|
|
113
|
+
case "invalid_key":
|
|
114
|
+
return `Cheie invalidă în ${issue.origin}`;
|
|
115
|
+
case "invalid_union":
|
|
116
|
+
return "Intrare invalidă";
|
|
117
|
+
case "invalid_element":
|
|
118
|
+
return `Valoare invalidă în ${issue.origin}`;
|
|
119
|
+
default:
|
|
120
|
+
return `Intrare invalidă`;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default function (): { localeError: errors.$ZodErrorMap } {
|
|
126
|
+
return {
|
|
127
|
+
localeError: error(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -8,6 +8,7 @@ const error: () => errors.$ZodErrorMap = () => {
|
|
|
8
8
|
file: { unit: "bayt", verb: "bo‘lishi kerak" },
|
|
9
9
|
array: { unit: "element", verb: "bo‘lishi kerak" },
|
|
10
10
|
set: { unit: "element", verb: "bo‘lishi kerak" },
|
|
11
|
+
map: { unit: "yozuv", verb: "bo‘lishi kerak" },
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
function getSizing(origin: string): { unit: string; verb: string } | null {
|
|
@@ -60,7 +60,11 @@ export const ZodMiniType: core.$constructor<ZodMiniType> = /*@__PURE__*/ core.$c
|
|
|
60
60
|
checks: [
|
|
61
61
|
...(def.checks ?? []),
|
|
62
62
|
...checks.map((ch) =>
|
|
63
|
-
typeof ch === "function"
|
|
63
|
+
typeof ch === "function"
|
|
64
|
+
? {
|
|
65
|
+
_zod: { check: ch, def: { check: "custom" }, onattach: [] },
|
|
66
|
+
}
|
|
67
|
+
: ch
|
|
64
68
|
),
|
|
65
69
|
],
|
|
66
70
|
},
|
|
@@ -200,7 +204,7 @@ export function url(params?: string | core.$ZodURLParams): ZodMiniURL {
|
|
|
200
204
|
// @__NO_SIDE_EFFECTS__
|
|
201
205
|
export function httpUrl(params?: string | Omit<core.$ZodURLParams, "protocol" | "hostname">): ZodMiniURL {
|
|
202
206
|
return core._url(ZodMiniURL, {
|
|
203
|
-
protocol:
|
|
207
|
+
protocol: core.regexes.httpProtocol,
|
|
204
208
|
hostname: core.regexes.domain,
|
|
205
209
|
...util.normalizeParams(params),
|
|
206
210
|
});
|
|
@@ -241,9 +245,19 @@ export function nanoid(params?: string | core.$ZodNanoIDParams): ZodMiniNanoID {
|
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
// ZodMiniCUID
|
|
248
|
+
/**
|
|
249
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
250
|
+
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
|
251
|
+
* See https://github.com/paralleldrive/cuid.
|
|
252
|
+
*/
|
|
244
253
|
export interface ZodMiniCUID extends _ZodMiniString<core.$ZodCUIDInternals> {
|
|
245
254
|
// _zod: core.$ZodCUIDInternals;
|
|
246
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
258
|
+
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
|
259
|
+
* See https://github.com/paralleldrive/cuid.
|
|
260
|
+
*/
|
|
247
261
|
export const ZodMiniCUID: core.$constructor<ZodMiniCUID> = /*@__PURE__*/ core.$constructor(
|
|
248
262
|
"ZodMiniCUID",
|
|
249
263
|
(inst, def) => {
|
|
@@ -252,6 +266,13 @@ export const ZodMiniCUID: core.$constructor<ZodMiniCUID> = /*@__PURE__*/ core.$c
|
|
|
252
266
|
}
|
|
253
267
|
);
|
|
254
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Validates a CUID v1 string.
|
|
271
|
+
*
|
|
272
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
273
|
+
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
|
274
|
+
* See https://github.com/paralleldrive/cuid.
|
|
275
|
+
*/
|
|
255
276
|
// @__NO_SIDE_EFFECTS__
|
|
256
277
|
export function cuid(params?: string | core.$ZodCUIDParams): ZodMiniCUID {
|
|
257
278
|
return core._cuid(ZodMiniCUID, params);
|
|
@@ -833,7 +854,7 @@ export const ZodMiniObject: core.$constructor<ZodMiniObject> = /*@__PURE__*/ cor
|
|
|
833
854
|
export function object<T extends core.$ZodLooseShape = Record<never, SomeType>>(
|
|
834
855
|
shape?: T,
|
|
835
856
|
params?: string | core.$ZodObjectParams
|
|
836
|
-
): ZodMiniObject<T
|
|
857
|
+
): ZodMiniObject<util.Writeable<T>, core.$strip> {
|
|
837
858
|
const def: core.$ZodObjectDef = {
|
|
838
859
|
type: "object",
|
|
839
860
|
shape: shape ?? {},
|
|
@@ -847,7 +868,7 @@ export function object<T extends core.$ZodLooseShape = Record<never, SomeType>>(
|
|
|
847
868
|
export function strictObject<T extends core.$ZodLooseShape>(
|
|
848
869
|
shape: T,
|
|
849
870
|
params?: string | core.$ZodObjectParams
|
|
850
|
-
): ZodMiniObject<T
|
|
871
|
+
): ZodMiniObject<util.Writeable<T>, core.$strict> {
|
|
851
872
|
return new ZodMiniObject({
|
|
852
873
|
type: "object",
|
|
853
874
|
shape,
|
|
@@ -861,7 +882,7 @@ export function strictObject<T extends core.$ZodLooseShape>(
|
|
|
861
882
|
export function looseObject<T extends core.$ZodLooseShape>(
|
|
862
883
|
shape: T,
|
|
863
884
|
params?: string | core.$ZodObjectParams
|
|
864
|
-
): ZodMiniObject<T
|
|
885
|
+
): ZodMiniObject<util.Writeable<T>, core.$loose> {
|
|
865
886
|
return new ZodMiniObject({
|
|
866
887
|
type: "object",
|
|
867
888
|
shape,
|
|
@@ -875,7 +896,7 @@ export function looseObject<T extends core.$ZodLooseShape>(
|
|
|
875
896
|
export function extend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(
|
|
876
897
|
schema: T,
|
|
877
898
|
shape: U
|
|
878
|
-
): ZodMiniObject<util.Extend<T["shape"], U
|
|
899
|
+
): ZodMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_zod"]["config"]> {
|
|
879
900
|
return util.extend(schema, shape);
|
|
880
901
|
}
|
|
881
902
|
|
|
@@ -893,7 +914,7 @@ export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLo
|
|
|
893
914
|
export function safeExtend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(
|
|
894
915
|
schema: T,
|
|
895
916
|
shape: SafeExtendShape<T["shape"], U>
|
|
896
|
-
): ZodMiniObject<util.Extend<T["shape"], U
|
|
917
|
+
): ZodMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_zod"]["config"]> {
|
|
897
918
|
return util.safeExtend(schema, shape as any);
|
|
898
919
|
}
|
|
899
920
|
|
|
@@ -930,7 +951,7 @@ export function partial<T extends ZodMiniObject>(
|
|
|
930
951
|
schema: T
|
|
931
952
|
): ZodMiniObject<
|
|
932
953
|
{
|
|
933
|
-
[k in keyof T["shape"]]: ZodMiniOptional<T["shape"][k]>;
|
|
954
|
+
-readonly [k in keyof T["shape"]]: ZodMiniOptional<T["shape"][k]>;
|
|
934
955
|
},
|
|
935
956
|
T["_zod"]["config"]
|
|
936
957
|
>;
|
|
@@ -940,7 +961,7 @@ export function partial<T extends ZodMiniObject, M extends util.Mask<keyof T["sh
|
|
|
940
961
|
mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>
|
|
941
962
|
): ZodMiniObject<
|
|
942
963
|
{
|
|
943
|
-
[k in keyof T["shape"]]: k extends keyof M ? ZodMiniOptional<T["shape"][k]> : T["shape"][k];
|
|
964
|
+
-readonly [k in keyof T["shape"]]: k extends keyof M ? ZodMiniOptional<T["shape"][k]> : T["shape"][k];
|
|
944
965
|
},
|
|
945
966
|
T["_zod"]["config"]
|
|
946
967
|
>;
|
|
@@ -965,7 +986,7 @@ export function required<T extends ZodMiniObject>(
|
|
|
965
986
|
schema: T
|
|
966
987
|
): ZodMiniObject<
|
|
967
988
|
{
|
|
968
|
-
[k in keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
|
989
|
+
-readonly [k in keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
|
969
990
|
},
|
|
970
991
|
T["_zod"]["config"]
|
|
971
992
|
>;
|
|
@@ -1162,6 +1183,15 @@ export function record<Key extends core.$ZodRecordKey, Value extends SomeType>(
|
|
|
1162
1183
|
valueType: Value,
|
|
1163
1184
|
params?: string | core.$ZodRecordParams
|
|
1164
1185
|
): ZodMiniRecord<Key, Value> {
|
|
1186
|
+
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
|
1187
|
+
if (!valueType || !(valueType as any)._zod) {
|
|
1188
|
+
return new ZodMiniRecord({
|
|
1189
|
+
type: "record",
|
|
1190
|
+
keyType: string() as any,
|
|
1191
|
+
valueType: keyType as any as core.$ZodType,
|
|
1192
|
+
...util.normalizeParams(valueType as string | core.$ZodRecordParams | undefined),
|
|
1193
|
+
}) as any;
|
|
1194
|
+
}
|
|
1165
1195
|
return new ZodMiniRecord({
|
|
1166
1196
|
type: "record",
|
|
1167
1197
|
keyType,
|
|
@@ -1625,14 +1655,17 @@ export function codec<const A extends SomeType, B extends core.SomeType = core.$
|
|
|
1625
1655
|
}) as any;
|
|
1626
1656
|
}
|
|
1627
1657
|
|
|
1628
|
-
//
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1658
|
+
// @__NO_SIDE_EFFECTS__
|
|
1659
|
+
export function invertCodec<A extends SomeType, B extends SomeType>(codec: ZodMiniCodec<A, B>): ZodMiniCodec<B, A> {
|
|
1660
|
+
const def = codec._zod.def;
|
|
1661
|
+
return new ZodMiniCodec({
|
|
1662
|
+
type: "pipe",
|
|
1663
|
+
in: def.out as any,
|
|
1664
|
+
out: def.in as any,
|
|
1665
|
+
transform: def.reverseTransform as any,
|
|
1666
|
+
reverseTransform: def.transform as any,
|
|
1667
|
+
}) as any;
|
|
1668
|
+
}
|
|
1636
1669
|
|
|
1637
1670
|
// ZodMiniReadonly
|
|
1638
1671
|
export interface ZodMiniReadonly<T extends SomeType = core.$ZodType>
|
|
@@ -1770,9 +1803,10 @@ export function refine<T>(
|
|
|
1770
1803
|
// superRefine
|
|
1771
1804
|
// @__NO_SIDE_EFFECTS__
|
|
1772
1805
|
export function superRefine<T>(
|
|
1773
|
-
fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void
|
|
1806
|
+
fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>,
|
|
1807
|
+
params?: core.$ZodSuperRefineParams
|
|
1774
1808
|
): core.$ZodCheck<T> {
|
|
1775
|
-
return core._superRefine(fn);
|
|
1809
|
+
return core._superRefine(fn, params);
|
|
1776
1810
|
}
|
|
1777
1811
|
|
|
1778
1812
|
// Re-export describe and meta from core
|
|
@@ -1897,10 +1931,7 @@ export function _function<const Out extends core.$ZodFunctionOut = core.$ZodFunc
|
|
|
1897
1931
|
export function _function<
|
|
1898
1932
|
In extends core.$ZodFunctionIn = core.$ZodFunctionIn,
|
|
1899
1933
|
Out extends core.$ZodFunctionOut = core.$ZodFunctionOut,
|
|
1900
|
-
>(params?: {
|
|
1901
|
-
input: In;
|
|
1902
|
-
output: Out;
|
|
1903
|
-
}): ZodMiniFunction<In, Out>;
|
|
1934
|
+
>(params?: { input: In; output: Out }): ZodMiniFunction<In, Out>;
|
|
1904
1935
|
// @__NO_SIDE_EFFECTS__
|
|
1905
1936
|
export function _function(params?: {
|
|
1906
1937
|
output?: core.$ZodFunctionOut;
|
|
@@ -527,3 +527,22 @@ test("codec type enforcement - complex types", () => {
|
|
|
527
527
|
}
|
|
528
528
|
);
|
|
529
529
|
});
|
|
530
|
+
|
|
531
|
+
test("invertCodec", () => {
|
|
532
|
+
const inverted = z.invertCodec(isoDateCodec);
|
|
533
|
+
|
|
534
|
+
type InvIn = z.input<typeof inverted>;
|
|
535
|
+
type InvOut = z.output<typeof inverted>;
|
|
536
|
+
expectTypeOf<InvIn>().toEqualTypeOf<Date>();
|
|
537
|
+
expectTypeOf<InvOut>().toEqualTypeOf<string>();
|
|
538
|
+
|
|
539
|
+
const testDate = new Date("2024-01-15T10:30:00.000Z");
|
|
540
|
+
expect(z.decode(inverted, testDate)).toBe("2024-01-15T10:30:00.000Z");
|
|
541
|
+
|
|
542
|
+
const encoded = z.encode(inverted, "2024-01-15T10:30:00.000Z");
|
|
543
|
+
expect(encoded).toBeInstanceOf(Date);
|
|
544
|
+
expect(encoded.toISOString()).toBe("2024-01-15T10:30:00.000Z");
|
|
545
|
+
|
|
546
|
+
const doubleInverted = z.invertCodec(z.invertCodec(isoDateCodec));
|
|
547
|
+
expect(z.decode(doubleInverted, "2024-01-15T10:30:00.000Z")).toBeInstanceOf(Date);
|
|
548
|
+
});
|
|
@@ -228,6 +228,25 @@ test("z.union", () => {
|
|
|
228
228
|
expect(() => z.parse(a, true)).toThrow();
|
|
229
229
|
});
|
|
230
230
|
|
|
231
|
+
test("z.union([]) / z.xor([]) / z.discriminatedUnion(_, []) construct and reject all input", () => {
|
|
232
|
+
for (const schema of [z.union([]), z.xor([])]) {
|
|
233
|
+
const r = schema.safeParse("anything");
|
|
234
|
+
expect(r.success).toEqual(false);
|
|
235
|
+
if (!r.success) {
|
|
236
|
+
expect(r.error.issues[0].code).toBe("invalid_union");
|
|
237
|
+
expect((r.error.issues[0] as any).errors).toEqual([]);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const disc = z.discriminatedUnion("type", [] as any);
|
|
241
|
+
const r = disc.safeParse({ type: "x" });
|
|
242
|
+
expect(r.success).toEqual(false);
|
|
243
|
+
if (!r.success) {
|
|
244
|
+
expect(r.error.issues[0].code).toBe("invalid_union");
|
|
245
|
+
expect((r.error.issues[0] as any).errors).toEqual([]);
|
|
246
|
+
expect((r.error.issues[0] as any).options).toEqual([]);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
231
250
|
test("z.intersection", () => {
|
|
232
251
|
const a = z.intersection(z.object({ a: z.string() }), z.object({ b: z.number() }));
|
|
233
252
|
expect(z.parse(a, { a: "hello", b: 123 })).toEqual({ a: "hello", b: 123 });
|
|
@@ -247,7 +266,7 @@ test("z.tuple", () => {
|
|
|
247
266
|
const b = z.tuple([z.string(), z.number(), z.optional(z.string())], z.boolean());
|
|
248
267
|
type b = z.output<typeof b>;
|
|
249
268
|
|
|
250
|
-
expectTypeOf<b>().toEqualTypeOf<[string, number, string?, ...boolean[]]>();
|
|
269
|
+
expectTypeOf<b>().toEqualTypeOf<[string, number, (string | undefined)?, ...boolean[]]>();
|
|
251
270
|
const datas = [
|
|
252
271
|
["hello", 123],
|
|
253
272
|
["hello", 123, "world"],
|
|
@@ -265,7 +284,7 @@ test("z.tuple", () => {
|
|
|
265
284
|
const cArgs = [z.string(), z.number(), z.optional(z.string())] as const;
|
|
266
285
|
const c = z.tuple(cArgs, z.boolean());
|
|
267
286
|
type c = z.output<typeof c>;
|
|
268
|
-
expectTypeOf<c>().toEqualTypeOf<[string, number, string?, ...boolean[]]>();
|
|
287
|
+
expectTypeOf<c>().toEqualTypeOf<[string, number, (string | undefined)?, ...boolean[]]>();
|
|
269
288
|
});
|
|
270
289
|
|
|
271
290
|
test("z.record", () => {
|
|
@@ -319,6 +338,12 @@ test("z.record", () => {
|
|
|
319
338
|
[Enum.A]: "hello",
|
|
320
339
|
[Enum.B]: "world",
|
|
321
340
|
});
|
|
341
|
+
|
|
342
|
+
// v3-compat single-arg form: z.record(valueType) defaults keyType to z.string()
|
|
343
|
+
const f = (z.record as any)(z.number());
|
|
344
|
+
expect(f._zod.def.keyType._zod.def.type).toEqual("string");
|
|
345
|
+
expect(f._zod.def.valueType._zod.def.type).toEqual("number");
|
|
346
|
+
expect(z.parse(f, { a: 1, b: 2 })).toEqual({ a: 1, b: 2 });
|
|
322
347
|
});
|
|
323
348
|
|
|
324
349
|
test("z.map", () => {
|
|
@@ -17,7 +17,7 @@ test("z.object", () => {
|
|
|
17
17
|
expectTypeOf<a>().toEqualTypeOf<{
|
|
18
18
|
name: string;
|
|
19
19
|
age: number;
|
|
20
|
-
points?: number;
|
|
20
|
+
points?: number | undefined;
|
|
21
21
|
"test?": boolean;
|
|
22
22
|
}>();
|
|
23
23
|
expect(z.parse(a, { name: "john", age: 30, "test?": true })).toEqual({
|
|
@@ -109,7 +109,7 @@ test("z.extend", () => {
|
|
|
109
109
|
expectTypeOf<ExtendedUser>().toEqualTypeOf<{
|
|
110
110
|
name: string;
|
|
111
111
|
age: number;
|
|
112
|
-
email?: string;
|
|
112
|
+
email?: string | undefined;
|
|
113
113
|
isAdmin: boolean;
|
|
114
114
|
}>();
|
|
115
115
|
expect(extendedSchema).toBeDefined();
|
|
@@ -120,7 +120,7 @@ test("z.safeExtend", () => {
|
|
|
120
120
|
const extended = z.safeExtend(userSchema, { name: z.string() });
|
|
121
121
|
expect(z.safeParse(extended, { name: "John", age: 30 }).success).toBe(true);
|
|
122
122
|
type Extended = z.infer<typeof extended>;
|
|
123
|
-
expectTypeOf<Extended>().toEqualTypeOf<{ name: string; age: number; email?: string }>();
|
|
123
|
+
expectTypeOf<Extended>().toEqualTypeOf<{ name: string; age: number; email?: string | undefined }>();
|
|
124
124
|
// @ts-expect-error
|
|
125
125
|
z.safeExtend(userSchema, { name: z.number() });
|
|
126
126
|
});
|
|
@@ -128,7 +128,7 @@ test("z.safeExtend", () => {
|
|
|
128
128
|
test("z.pick", () => {
|
|
129
129
|
const pickedSchema = z.pick(userSchema, { name: true, email: true });
|
|
130
130
|
type PickedUser = z.infer<typeof pickedSchema>;
|
|
131
|
-
expectTypeOf<PickedUser>().toEqualTypeOf<{ name: string; email?: string }>();
|
|
131
|
+
expectTypeOf<PickedUser>().toEqualTypeOf<{ name: string; email?: string | undefined }>();
|
|
132
132
|
expect(pickedSchema).toBeDefined();
|
|
133
133
|
expect(z.safeParse(pickedSchema, { name: "John", email: "john@example.com" }).success).toBe(true);
|
|
134
134
|
});
|
|
@@ -149,9 +149,9 @@ test("z.partial", () => {
|
|
|
149
149
|
const partialSchema = z.partial(userSchema);
|
|
150
150
|
type PartialUser = z.infer<typeof partialSchema>;
|
|
151
151
|
expectTypeOf<PartialUser>().toEqualTypeOf<{
|
|
152
|
-
name?: string;
|
|
153
|
-
age?: number;
|
|
154
|
-
email?: string;
|
|
152
|
+
name?: string | undefined;
|
|
153
|
+
age?: number | undefined;
|
|
154
|
+
email?: string | undefined;
|
|
155
155
|
}>();
|
|
156
156
|
expect(z.safeParse(partialSchema, { name: "John" }).success).toBe(true);
|
|
157
157
|
});
|
|
@@ -160,9 +160,9 @@ test("z.partial with mask", () => {
|
|
|
160
160
|
const partialSchemaWithMask = z.partial(userSchema, { name: true });
|
|
161
161
|
type PartialUserWithMask = z.infer<typeof partialSchemaWithMask>;
|
|
162
162
|
expectTypeOf<PartialUserWithMask>().toEqualTypeOf<{
|
|
163
|
-
name?: string;
|
|
163
|
+
name?: string | undefined;
|
|
164
164
|
age: number;
|
|
165
|
-
email?: string;
|
|
165
|
+
email?: string | undefined;
|
|
166
166
|
}>();
|
|
167
167
|
expect(z.safeParse(partialSchemaWithMask, { age: 30 }).success).toBe(true);
|
|
168
168
|
expect(z.safeParse(partialSchemaWithMask, { name: "John" }).success).toBe(false);
|
package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts
CHANGED
|
@@ -33,7 +33,7 @@ test("recursion with z.lazy", () => {
|
|
|
33
33
|
type Category = z.infer<typeof Category>;
|
|
34
34
|
interface _Category {
|
|
35
35
|
name: string;
|
|
36
|
-
subcategories?: _Category[];
|
|
36
|
+
subcategories?: _Category[] | undefined;
|
|
37
37
|
}
|
|
38
38
|
expectTypeOf<Category>().toEqualTypeOf<_Category>();
|
|
39
39
|
});
|
|
@@ -273,3 +273,53 @@ test("recursion compatibility", () => {
|
|
|
273
273
|
},
|
|
274
274
|
});
|
|
275
275
|
});
|
|
276
|
+
|
|
277
|
+
test("shape stays writeable through object/strictObject/looseObject/extend with getters", () => {
|
|
278
|
+
const Cat = z.object({
|
|
279
|
+
name: z.string(),
|
|
280
|
+
get sub(): z.ZodMiniArray<typeof Cat> {
|
|
281
|
+
return z.array(Cat);
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
type CatShape = (typeof Cat)["shape"];
|
|
285
|
+
expectTypeOf<CatShape>().toEqualTypeOf<{
|
|
286
|
+
name: z.ZodMiniString<string>;
|
|
287
|
+
sub: z.ZodMiniArray<typeof Cat>;
|
|
288
|
+
}>();
|
|
289
|
+
|
|
290
|
+
const StrictCat = z.strictObject({
|
|
291
|
+
name: z.string(),
|
|
292
|
+
get sub(): z.ZodMiniArray<typeof StrictCat> {
|
|
293
|
+
return z.array(StrictCat);
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
type StrictShape = (typeof StrictCat)["shape"];
|
|
297
|
+
expectTypeOf<StrictShape>().toEqualTypeOf<{
|
|
298
|
+
name: z.ZodMiniString<string>;
|
|
299
|
+
sub: z.ZodMiniArray<typeof StrictCat>;
|
|
300
|
+
}>();
|
|
301
|
+
|
|
302
|
+
const LooseCat = z.looseObject({
|
|
303
|
+
name: z.string(),
|
|
304
|
+
get sub(): z.ZodMiniArray<typeof LooseCat> {
|
|
305
|
+
return z.array(LooseCat);
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
type LooseShape = (typeof LooseCat)["shape"];
|
|
309
|
+
expectTypeOf<LooseShape>().toEqualTypeOf<{
|
|
310
|
+
name: z.ZodMiniString<string>;
|
|
311
|
+
sub: z.ZodMiniArray<typeof LooseCat>;
|
|
312
|
+
}>();
|
|
313
|
+
|
|
314
|
+
const Base = z.object({ name: z.string() });
|
|
315
|
+
const Extended = z.extend(Base, {
|
|
316
|
+
get sub(): z.ZodMiniArray<typeof Extended> {
|
|
317
|
+
return z.array(Extended);
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
type ExtendedShape = (typeof Extended)["shape"];
|
|
321
|
+
expectTypeOf<ExtendedShape>().toEqualTypeOf<{
|
|
322
|
+
name: z.ZodMiniString<string>;
|
|
323
|
+
sub: z.ZodMiniArray<typeof Extended>;
|
|
324
|
+
}>();
|
|
325
|
+
});
|
|
@@ -282,6 +282,11 @@ test("z.base64", () => {
|
|
|
282
282
|
expect(() => z.parse(a, "SGVsbG8gd29ybGQ")).toThrow();
|
|
283
283
|
expect(() => z.parse(a, "U29tZSBvdGhlciBzdHJpbmc")).toThrow();
|
|
284
284
|
expect(() => z.parse(a, "hello")).toThrow();
|
|
285
|
+
// whitespace is not allowed (atob would otherwise strip it)
|
|
286
|
+
expect(() => z.parse(a, "123 ")).toThrow();
|
|
287
|
+
expect(() => z.parse(a, "SGVsbG8gd29ybGQ= ")).toThrow();
|
|
288
|
+
expect(() => z.parse(a, "SGVsbG8gd29ybGQ=\n")).toThrow();
|
|
289
|
+
expect(() => z.parse(a, "SGVs bG8gd29ybGQ=")).toThrow();
|
|
285
290
|
// wrong type
|
|
286
291
|
expect(() => z.parse(a, 123)).toThrow();
|
|
287
292
|
});
|
|
@@ -40,8 +40,8 @@ const initializer = (inst, issues) => {
|
|
|
40
40
|
// },
|
|
41
41
|
// });
|
|
42
42
|
};
|
|
43
|
-
export const ZodError = core.$constructor("ZodError", initializer);
|
|
44
|
-
export const ZodRealError = core.$constructor("ZodError", initializer, {
|
|
43
|
+
export const ZodError = /*@__PURE__*/ core.$constructor("ZodError", initializer);
|
|
44
|
+
export const ZodRealError = /*@__PURE__*/ core.$constructor("ZodError", initializer, {
|
|
45
45
|
Parent: Error,
|
|
46
46
|
});
|
|
47
47
|
// /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
|
|
@@ -5,6 +5,7 @@ export * from "./errors.cjs";
|
|
|
5
5
|
export * from "./parse.cjs";
|
|
6
6
|
export * from "./compat.cjs";
|
|
7
7
|
export type { infer, output, input } from "../core/index.cjs";
|
|
8
|
+
export type { JSONType } from "../core/util.cjs";
|
|
8
9
|
export { globalRegistry, type GlobalMeta, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, TimePrecision, util, NEVER, } from "../core/index.cjs";
|
|
9
10
|
export { toJSONSchema } from "../core/json-schema-processors.cjs";
|
|
10
11
|
export { fromJSONSchema } from "./from-json-schema.cjs";
|
|
@@ -5,6 +5,7 @@ export * from "./errors.js";
|
|
|
5
5
|
export * from "./parse.js";
|
|
6
6
|
export * from "./compat.js";
|
|
7
7
|
export type { infer, output, input } from "../core/index.js";
|
|
8
|
+
export type { JSONType } from "../core/util.js";
|
|
8
9
|
export { globalRegistry, type GlobalMeta, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, TimePrecision, util, NEVER, } from "../core/index.js";
|
|
9
10
|
export { toJSONSchema } from "../core/json-schema-processors.js";
|
|
10
11
|
export { fromJSONSchema } from "./from-json-schema.js";
|