@wallarm-org/mcp 2.0.0-rc-feature-AS-882-status-code-ds-ownership.3 → 2.0.0
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.js +905 -3359
- package/package.json +4 -4
- package/dist/rslib-runtime.js +0 -38
package/dist/index.js
CHANGED
|
@@ -1,287 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
2
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
4
|
import fs from "fs";
|
|
6
5
|
import path_0 from "path";
|
|
7
|
-
var
|
|
8
|
-
__webpack_require__.r(classic_checks_namespaceObject);
|
|
9
|
-
__webpack_require__.d(classic_checks_namespaceObject, {
|
|
10
|
-
endsWith: ()=>_endsWith,
|
|
11
|
-
gt: ()=>_gt,
|
|
12
|
-
gte: ()=>_gte,
|
|
13
|
-
includes: ()=>_includes,
|
|
14
|
-
length: ()=>_length,
|
|
15
|
-
lowercase: ()=>_lowercase,
|
|
16
|
-
lt: ()=>_lt,
|
|
17
|
-
lte: ()=>_lte,
|
|
18
|
-
maxLength: ()=>_maxLength,
|
|
19
|
-
maxSize: ()=>_maxSize,
|
|
20
|
-
mime: ()=>_mime,
|
|
21
|
-
minLength: ()=>_minLength,
|
|
22
|
-
minSize: ()=>_minSize,
|
|
23
|
-
multipleOf: ()=>_multipleOf,
|
|
24
|
-
negative: ()=>_negative,
|
|
25
|
-
nonnegative: ()=>_nonnegative,
|
|
26
|
-
nonpositive: ()=>_nonpositive,
|
|
27
|
-
normalize: ()=>_normalize,
|
|
28
|
-
overwrite: ()=>_overwrite,
|
|
29
|
-
positive: ()=>_positive,
|
|
30
|
-
property: ()=>_property,
|
|
31
|
-
regex: ()=>_regex,
|
|
32
|
-
size: ()=>_size,
|
|
33
|
-
slugify: ()=>_slugify,
|
|
34
|
-
startsWith: ()=>_startsWith,
|
|
35
|
-
toLowerCase: ()=>_toLowerCase,
|
|
36
|
-
toUpperCase: ()=>_toUpperCase,
|
|
37
|
-
trim: ()=>_trim,
|
|
38
|
-
uppercase: ()=>_uppercase
|
|
39
|
-
});
|
|
40
|
-
var iso_namespaceObject = {};
|
|
41
|
-
__webpack_require__.r(iso_namespaceObject);
|
|
42
|
-
__webpack_require__.d(iso_namespaceObject, {
|
|
43
|
-
ZodISODate: ()=>ZodISODate,
|
|
44
|
-
ZodISODateTime: ()=>ZodISODateTime,
|
|
45
|
-
ZodISODuration: ()=>ZodISODuration,
|
|
46
|
-
ZodISOTime: ()=>ZodISOTime,
|
|
47
|
-
date: ()=>iso_date,
|
|
48
|
-
datetime: ()=>iso_datetime,
|
|
49
|
-
duration: ()=>iso_duration,
|
|
50
|
-
time: ()=>iso_time
|
|
51
|
-
});
|
|
52
|
-
var classic_schemas_namespaceObject = {};
|
|
53
|
-
__webpack_require__.r(classic_schemas_namespaceObject);
|
|
54
|
-
__webpack_require__.d(classic_schemas_namespaceObject, {
|
|
55
|
-
ZodAny: ()=>ZodAny,
|
|
56
|
-
ZodArray: ()=>ZodArray,
|
|
57
|
-
ZodBase64: ()=>ZodBase64,
|
|
58
|
-
ZodBase64URL: ()=>ZodBase64URL,
|
|
59
|
-
ZodBigInt: ()=>ZodBigInt,
|
|
60
|
-
ZodBigIntFormat: ()=>ZodBigIntFormat,
|
|
61
|
-
ZodBoolean: ()=>ZodBoolean,
|
|
62
|
-
ZodCIDRv4: ()=>ZodCIDRv4,
|
|
63
|
-
ZodCIDRv6: ()=>ZodCIDRv6,
|
|
64
|
-
ZodCUID: ()=>ZodCUID,
|
|
65
|
-
ZodCUID2: ()=>ZodCUID2,
|
|
66
|
-
ZodCatch: ()=>ZodCatch,
|
|
67
|
-
ZodCodec: ()=>ZodCodec,
|
|
68
|
-
ZodCustom: ()=>ZodCustom,
|
|
69
|
-
ZodCustomStringFormat: ()=>ZodCustomStringFormat,
|
|
70
|
-
ZodDate: ()=>ZodDate,
|
|
71
|
-
ZodDefault: ()=>ZodDefault,
|
|
72
|
-
ZodDiscriminatedUnion: ()=>ZodDiscriminatedUnion,
|
|
73
|
-
ZodE164: ()=>ZodE164,
|
|
74
|
-
ZodEmail: ()=>ZodEmail,
|
|
75
|
-
ZodEmoji: ()=>ZodEmoji,
|
|
76
|
-
ZodEnum: ()=>ZodEnum,
|
|
77
|
-
ZodExactOptional: ()=>ZodExactOptional,
|
|
78
|
-
ZodFile: ()=>ZodFile,
|
|
79
|
-
ZodFunction: ()=>ZodFunction,
|
|
80
|
-
ZodGUID: ()=>ZodGUID,
|
|
81
|
-
ZodIPv4: ()=>ZodIPv4,
|
|
82
|
-
ZodIPv6: ()=>ZodIPv6,
|
|
83
|
-
ZodIntersection: ()=>ZodIntersection,
|
|
84
|
-
ZodJWT: ()=>ZodJWT,
|
|
85
|
-
ZodKSUID: ()=>ZodKSUID,
|
|
86
|
-
ZodLazy: ()=>ZodLazy,
|
|
87
|
-
ZodLiteral: ()=>ZodLiteral,
|
|
88
|
-
ZodMAC: ()=>ZodMAC,
|
|
89
|
-
ZodMap: ()=>ZodMap,
|
|
90
|
-
ZodNaN: ()=>ZodNaN,
|
|
91
|
-
ZodNanoID: ()=>ZodNanoID,
|
|
92
|
-
ZodNever: ()=>ZodNever,
|
|
93
|
-
ZodNonOptional: ()=>ZodNonOptional,
|
|
94
|
-
ZodNull: ()=>ZodNull,
|
|
95
|
-
ZodNullable: ()=>ZodNullable,
|
|
96
|
-
ZodNumber: ()=>ZodNumber,
|
|
97
|
-
ZodNumberFormat: ()=>ZodNumberFormat,
|
|
98
|
-
ZodObject: ()=>ZodObject,
|
|
99
|
-
ZodOptional: ()=>ZodOptional,
|
|
100
|
-
ZodPipe: ()=>ZodPipe,
|
|
101
|
-
ZodPrefault: ()=>ZodPrefault,
|
|
102
|
-
ZodPromise: ()=>ZodPromise,
|
|
103
|
-
ZodReadonly: ()=>ZodReadonly,
|
|
104
|
-
ZodRecord: ()=>ZodRecord,
|
|
105
|
-
ZodSet: ()=>ZodSet,
|
|
106
|
-
ZodString: ()=>ZodString,
|
|
107
|
-
ZodStringFormat: ()=>ZodStringFormat,
|
|
108
|
-
ZodSuccess: ()=>ZodSuccess,
|
|
109
|
-
ZodSymbol: ()=>ZodSymbol,
|
|
110
|
-
ZodTemplateLiteral: ()=>ZodTemplateLiteral,
|
|
111
|
-
ZodTransform: ()=>ZodTransform,
|
|
112
|
-
ZodTuple: ()=>ZodTuple,
|
|
113
|
-
ZodType: ()=>ZodType,
|
|
114
|
-
ZodULID: ()=>ZodULID,
|
|
115
|
-
ZodURL: ()=>ZodURL,
|
|
116
|
-
ZodUUID: ()=>ZodUUID,
|
|
117
|
-
ZodUndefined: ()=>ZodUndefined,
|
|
118
|
-
ZodUnion: ()=>ZodUnion,
|
|
119
|
-
ZodUnknown: ()=>ZodUnknown,
|
|
120
|
-
ZodVoid: ()=>ZodVoid,
|
|
121
|
-
ZodXID: ()=>ZodXID,
|
|
122
|
-
ZodXor: ()=>ZodXor,
|
|
123
|
-
_ZodString: ()=>_ZodString,
|
|
124
|
-
_default: ()=>schemas_default,
|
|
125
|
-
_function: ()=>_function,
|
|
126
|
-
any: ()=>any,
|
|
127
|
-
array: ()=>schemas_array,
|
|
128
|
-
base64: ()=>schemas_base64,
|
|
129
|
-
base64url: ()=>schemas_base64url,
|
|
130
|
-
bigint: ()=>schemas_bigint,
|
|
131
|
-
boolean: ()=>schemas_boolean,
|
|
132
|
-
catch: ()=>schemas_catch,
|
|
133
|
-
check: ()=>schemas_check,
|
|
134
|
-
cidrv4: ()=>schemas_cidrv4,
|
|
135
|
-
cidrv6: ()=>schemas_cidrv6,
|
|
136
|
-
codec: ()=>schemas_codec,
|
|
137
|
-
cuid: ()=>schemas_cuid,
|
|
138
|
-
cuid2: ()=>schemas_cuid2,
|
|
139
|
-
custom: ()=>custom,
|
|
140
|
-
date: ()=>schemas_date,
|
|
141
|
-
describe: ()=>schemas_describe,
|
|
142
|
-
discriminatedUnion: ()=>discriminatedUnion,
|
|
143
|
-
e164: ()=>schemas_e164,
|
|
144
|
-
email: ()=>schemas_email,
|
|
145
|
-
emoji: ()=>schemas_emoji,
|
|
146
|
-
enum: ()=>schemas_enum,
|
|
147
|
-
exactOptional: ()=>exactOptional,
|
|
148
|
-
file: ()=>schemas_file,
|
|
149
|
-
float32: ()=>float32,
|
|
150
|
-
float64: ()=>float64,
|
|
151
|
-
function: ()=>_function,
|
|
152
|
-
guid: ()=>schemas_guid,
|
|
153
|
-
hash: ()=>hash,
|
|
154
|
-
hex: ()=>schemas_hex,
|
|
155
|
-
hostname: ()=>schemas_hostname,
|
|
156
|
-
httpUrl: ()=>httpUrl,
|
|
157
|
-
instanceof: ()=>_instanceof,
|
|
158
|
-
int: ()=>schemas_int,
|
|
159
|
-
int32: ()=>int32,
|
|
160
|
-
int64: ()=>int64,
|
|
161
|
-
intersection: ()=>intersection,
|
|
162
|
-
ipv4: ()=>schemas_ipv4,
|
|
163
|
-
ipv6: ()=>schemas_ipv6,
|
|
164
|
-
json: ()=>schemas_json,
|
|
165
|
-
jwt: ()=>jwt,
|
|
166
|
-
keyof: ()=>keyof,
|
|
167
|
-
ksuid: ()=>schemas_ksuid,
|
|
168
|
-
lazy: ()=>lazy,
|
|
169
|
-
literal: ()=>literal,
|
|
170
|
-
looseObject: ()=>looseObject,
|
|
171
|
-
looseRecord: ()=>looseRecord,
|
|
172
|
-
mac: ()=>schemas_mac,
|
|
173
|
-
map: ()=>schemas_map,
|
|
174
|
-
meta: ()=>schemas_meta,
|
|
175
|
-
nan: ()=>nan,
|
|
176
|
-
nanoid: ()=>schemas_nanoid,
|
|
177
|
-
nativeEnum: ()=>nativeEnum,
|
|
178
|
-
never: ()=>never,
|
|
179
|
-
nonoptional: ()=>nonoptional,
|
|
180
|
-
null: ()=>schemas_null,
|
|
181
|
-
nullable: ()=>nullable,
|
|
182
|
-
nullish: ()=>schemas_nullish,
|
|
183
|
-
number: ()=>schemas_number,
|
|
184
|
-
object: ()=>schemas_object,
|
|
185
|
-
optional: ()=>optional,
|
|
186
|
-
partialRecord: ()=>partialRecord,
|
|
187
|
-
pipe: ()=>pipe,
|
|
188
|
-
prefault: ()=>prefault,
|
|
189
|
-
preprocess: ()=>preprocess,
|
|
190
|
-
promise: ()=>promise,
|
|
191
|
-
readonly: ()=>readonly,
|
|
192
|
-
record: ()=>record,
|
|
193
|
-
refine: ()=>refine,
|
|
194
|
-
set: ()=>schemas_set,
|
|
195
|
-
strictObject: ()=>strictObject,
|
|
196
|
-
string: ()=>schemas_string,
|
|
197
|
-
stringFormat: ()=>stringFormat,
|
|
198
|
-
stringbool: ()=>stringbool,
|
|
199
|
-
success: ()=>success,
|
|
200
|
-
superRefine: ()=>superRefine,
|
|
201
|
-
symbol: ()=>symbol,
|
|
202
|
-
templateLiteral: ()=>templateLiteral,
|
|
203
|
-
transform: ()=>transform,
|
|
204
|
-
tuple: ()=>tuple,
|
|
205
|
-
uint32: ()=>uint32,
|
|
206
|
-
uint64: ()=>uint64,
|
|
207
|
-
ulid: ()=>schemas_ulid,
|
|
208
|
-
undefined: ()=>schemas_undefined,
|
|
209
|
-
union: ()=>union,
|
|
210
|
-
unknown: ()=>unknown,
|
|
211
|
-
url: ()=>schemas_url,
|
|
212
|
-
uuid: ()=>schemas_uuid,
|
|
213
|
-
uuidv4: ()=>uuidv4,
|
|
214
|
-
uuidv6: ()=>uuidv6,
|
|
215
|
-
uuidv7: ()=>uuidv7,
|
|
216
|
-
void: ()=>schemas_void,
|
|
217
|
-
xid: ()=>schemas_xid,
|
|
218
|
-
xor: ()=>xor
|
|
219
|
-
});
|
|
220
|
-
var regexes_namespaceObject = {};
|
|
221
|
-
__webpack_require__.r(regexes_namespaceObject);
|
|
222
|
-
__webpack_require__.d(regexes_namespaceObject, {
|
|
223
|
-
base64: ()=>regexes_base64,
|
|
224
|
-
base64url: ()=>regexes_base64url,
|
|
225
|
-
bigint: ()=>bigint,
|
|
226
|
-
boolean: ()=>regexes_boolean,
|
|
227
|
-
browserEmail: ()=>browserEmail,
|
|
228
|
-
cidrv4: ()=>cidrv4,
|
|
229
|
-
cidrv6: ()=>cidrv6,
|
|
230
|
-
cuid: ()=>cuid,
|
|
231
|
-
cuid2: ()=>cuid2,
|
|
232
|
-
date: ()=>date,
|
|
233
|
-
datetime: ()=>datetime,
|
|
234
|
-
domain: ()=>domain,
|
|
235
|
-
duration: ()=>duration,
|
|
236
|
-
e164: ()=>e164,
|
|
237
|
-
email: ()=>email,
|
|
238
|
-
emoji: ()=>emoji,
|
|
239
|
-
extendedDuration: ()=>extendedDuration,
|
|
240
|
-
guid: ()=>guid,
|
|
241
|
-
hex: ()=>regexes_hex,
|
|
242
|
-
hostname: ()=>hostname,
|
|
243
|
-
html5Email: ()=>html5Email,
|
|
244
|
-
idnEmail: ()=>idnEmail,
|
|
245
|
-
integer: ()=>integer,
|
|
246
|
-
ipv4: ()=>ipv4,
|
|
247
|
-
ipv6: ()=>ipv6,
|
|
248
|
-
ksuid: ()=>ksuid,
|
|
249
|
-
lowercase: ()=>lowercase,
|
|
250
|
-
mac: ()=>mac,
|
|
251
|
-
md5_base64: ()=>md5_base64,
|
|
252
|
-
md5_base64url: ()=>md5_base64url,
|
|
253
|
-
md5_hex: ()=>md5_hex,
|
|
254
|
-
nanoid: ()=>nanoid,
|
|
255
|
-
null: ()=>_null,
|
|
256
|
-
number: ()=>regexes_number,
|
|
257
|
-
rfc5322Email: ()=>rfc5322Email,
|
|
258
|
-
sha1_base64: ()=>sha1_base64,
|
|
259
|
-
sha1_base64url: ()=>sha1_base64url,
|
|
260
|
-
sha1_hex: ()=>sha1_hex,
|
|
261
|
-
sha256_base64: ()=>sha256_base64,
|
|
262
|
-
sha256_base64url: ()=>sha256_base64url,
|
|
263
|
-
sha256_hex: ()=>sha256_hex,
|
|
264
|
-
sha384_base64: ()=>sha384_base64,
|
|
265
|
-
sha384_base64url: ()=>sha384_base64url,
|
|
266
|
-
sha384_hex: ()=>sha384_hex,
|
|
267
|
-
sha512_base64: ()=>sha512_base64,
|
|
268
|
-
sha512_base64url: ()=>sha512_base64url,
|
|
269
|
-
sha512_hex: ()=>sha512_hex,
|
|
270
|
-
string: ()=>string,
|
|
271
|
-
time: ()=>regexes_time,
|
|
272
|
-
ulid: ()=>ulid,
|
|
273
|
-
undefined: ()=>_undefined,
|
|
274
|
-
unicodeEmail: ()=>unicodeEmail,
|
|
275
|
-
uppercase: ()=>uppercase,
|
|
276
|
-
uuid: ()=>uuid,
|
|
277
|
-
uuid4: ()=>uuid4,
|
|
278
|
-
uuid6: ()=>uuid6,
|
|
279
|
-
uuid7: ()=>uuid7,
|
|
280
|
-
xid: ()=>xid
|
|
281
|
-
});
|
|
282
|
-
Object.freeze({
|
|
283
|
-
status: "aborted"
|
|
284
|
-
});
|
|
6
|
+
var core_a;
|
|
285
7
|
function $constructor(name, initializer, params) {
|
|
286
8
|
function init(inst, def) {
|
|
287
9
|
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
@@ -342,19 +64,71 @@ class $ZodEncodeError extends Error {
|
|
|
342
64
|
this.name = "ZodEncodeError";
|
|
343
65
|
}
|
|
344
66
|
}
|
|
345
|
-
|
|
67
|
+
(core_a = globalThis).__zod_globalConfig ?? (core_a.__zod_globalConfig = {});
|
|
68
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
346
69
|
function core_config(newConfig) {
|
|
347
70
|
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
348
71
|
return globalConfig;
|
|
349
72
|
}
|
|
73
|
+
const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
74
|
+
const cuid2 = /^[0-9a-z]+$/;
|
|
75
|
+
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
76
|
+
const xid = /^[0-9a-vA-V]{20}$/;
|
|
77
|
+
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
78
|
+
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
79
|
+
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
80
|
+
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
81
|
+
const uuid = (version)=>{
|
|
82
|
+
if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
83
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
84
|
+
};
|
|
85
|
+
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
86
|
+
const _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
87
|
+
function emoji() {
|
|
88
|
+
return new RegExp(_emoji, "u");
|
|
89
|
+
}
|
|
90
|
+
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
91
|
+
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
92
|
+
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
93
|
+
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
94
|
+
const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
95
|
+
const regexes_base64url = /^[A-Za-z0-9_-]*$/;
|
|
96
|
+
const httpProtocol = /^https?$/;
|
|
97
|
+
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
98
|
+
const dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";
|
|
99
|
+
const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
|
100
|
+
function timeSource(args) {
|
|
101
|
+
const hhmm = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
102
|
+
const regex = "number" == typeof args.precision ? -1 === args.precision ? `${hhmm}` : 0 === args.precision ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
103
|
+
return regex;
|
|
104
|
+
}
|
|
105
|
+
function regexes_time(args) {
|
|
106
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
107
|
+
}
|
|
108
|
+
function datetime(args) {
|
|
109
|
+
const time = timeSource({
|
|
110
|
+
precision: args.precision
|
|
111
|
+
});
|
|
112
|
+
const opts = [
|
|
113
|
+
"Z"
|
|
114
|
+
];
|
|
115
|
+
if (args.local) opts.push("");
|
|
116
|
+
if (args.offset) opts.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
|
117
|
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
118
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
119
|
+
}
|
|
120
|
+
const string = (params)=>{
|
|
121
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
122
|
+
return new RegExp(`^${regex}$`);
|
|
123
|
+
};
|
|
124
|
+
const regexes_boolean = /^(?:true|false)$/i;
|
|
125
|
+
const lowercase = /^[^A-Z]*$/;
|
|
126
|
+
const uppercase = /^[^a-z]*$/;
|
|
350
127
|
function getEnumValues(entries) {
|
|
351
128
|
const numericValues = Object.values(entries).filter((v)=>"number" == typeof v);
|
|
352
129
|
const values = Object.entries(entries).filter(([k, _])=>-1 === numericValues.indexOf(+k)).map(([_, v])=>v);
|
|
353
130
|
return values;
|
|
354
131
|
}
|
|
355
|
-
function joinValues(array, separator = "|") {
|
|
356
|
-
return array.map((val)=>stringifyPrimitive(val)).join(separator);
|
|
357
|
-
}
|
|
358
132
|
function jsonStringifyReplacer(_, value) {
|
|
359
133
|
if ("bigint" == typeof value) return value.toString();
|
|
360
134
|
return value;
|
|
@@ -382,20 +156,7 @@ function cleanRegex(source) {
|
|
|
382
156
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
383
157
|
return source.slice(start, end);
|
|
384
158
|
}
|
|
385
|
-
|
|
386
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
387
|
-
const stepString = step.toString();
|
|
388
|
-
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
389
|
-
if (0 === stepDecCount && /\d?e-\d?/.test(stepString)) {
|
|
390
|
-
const match = stepString.match(/\d?e-(\d?)/);
|
|
391
|
-
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
392
|
-
}
|
|
393
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
394
|
-
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
395
|
-
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
396
|
-
return valInt % stepInt / 10 ** decCount;
|
|
397
|
-
}
|
|
398
|
-
const EVALUATING = Symbol("evaluating");
|
|
159
|
+
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
399
160
|
function defineLazy(object, key, getter) {
|
|
400
161
|
let value;
|
|
401
162
|
Object.defineProperty(object, key, {
|
|
@@ -441,7 +202,8 @@ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace
|
|
|
441
202
|
function util_isObject(data) {
|
|
442
203
|
return "object" == typeof data && null !== data && !Array.isArray(data);
|
|
443
204
|
}
|
|
444
|
-
const util_allowsEval = cached(()=>{
|
|
205
|
+
const util_allowsEval = /* @__PURE__*/ cached(()=>{
|
|
206
|
+
if (globalConfig.jitless) return false;
|
|
445
207
|
if ("u" > typeof navigator && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
446
208
|
try {
|
|
447
209
|
const F = Function;
|
|
@@ -468,21 +230,15 @@ function shallowClone(o) {
|
|
|
468
230
|
if (Array.isArray(o)) return [
|
|
469
231
|
...o
|
|
470
232
|
];
|
|
233
|
+
if (o instanceof Map) return new Map(o);
|
|
234
|
+
if (o instanceof Set) return new Set(o);
|
|
471
235
|
return o;
|
|
472
236
|
}
|
|
473
|
-
const propertyKeyTypes = new Set([
|
|
237
|
+
const propertyKeyTypes = /* @__PURE__*/ new Set([
|
|
474
238
|
"string",
|
|
475
239
|
"number",
|
|
476
240
|
"symbol"
|
|
477
241
|
]);
|
|
478
|
-
const primitiveTypes = new Set([
|
|
479
|
-
"string",
|
|
480
|
-
"number",
|
|
481
|
-
"bigint",
|
|
482
|
-
"boolean",
|
|
483
|
-
"symbol",
|
|
484
|
-
"undefined"
|
|
485
|
-
]);
|
|
486
242
|
function escapeRegex(str) {
|
|
487
243
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
488
244
|
}
|
|
@@ -508,46 +264,9 @@ function normalizeParams(_params) {
|
|
|
508
264
|
};
|
|
509
265
|
return params;
|
|
510
266
|
}
|
|
511
|
-
function stringifyPrimitive(value) {
|
|
512
|
-
if ("bigint" == typeof value) return value.toString() + "n";
|
|
513
|
-
if ("string" == typeof value) return `"${value}"`;
|
|
514
|
-
return `${value}`;
|
|
515
|
-
}
|
|
516
267
|
function optionalKeys(shape) {
|
|
517
268
|
return Object.keys(shape).filter((k)=>"optional" === shape[k]._zod.optin && "optional" === shape[k]._zod.optout);
|
|
518
269
|
}
|
|
519
|
-
const NUMBER_FORMAT_RANGES = {
|
|
520
|
-
safeint: [
|
|
521
|
-
Number.MIN_SAFE_INTEGER,
|
|
522
|
-
Number.MAX_SAFE_INTEGER
|
|
523
|
-
],
|
|
524
|
-
int32: [
|
|
525
|
-
-2147483648,
|
|
526
|
-
2147483647
|
|
527
|
-
],
|
|
528
|
-
uint32: [
|
|
529
|
-
0,
|
|
530
|
-
4294967295
|
|
531
|
-
],
|
|
532
|
-
float32: [
|
|
533
|
-
-3.4028234663852886e+38,
|
|
534
|
-
3.4028234663852886e38
|
|
535
|
-
],
|
|
536
|
-
float64: [
|
|
537
|
-
-Number.MAX_VALUE,
|
|
538
|
-
Number.MAX_VALUE
|
|
539
|
-
]
|
|
540
|
-
};
|
|
541
|
-
const BIGINT_FORMAT_RANGES = {
|
|
542
|
-
int64: [
|
|
543
|
-
/* @__PURE__*/ BigInt("-9223372036854775808"),
|
|
544
|
-
/* @__PURE__*/ BigInt("9223372036854775807")
|
|
545
|
-
],
|
|
546
|
-
uint64: [
|
|
547
|
-
/* @__PURE__*/ BigInt(0),
|
|
548
|
-
/* @__PURE__*/ BigInt("18446744073709551615")
|
|
549
|
-
]
|
|
550
|
-
};
|
|
551
270
|
function pick(schema, mask) {
|
|
552
271
|
const currDef = schema._zod.def;
|
|
553
272
|
const checks = currDef.checks;
|
|
@@ -623,6 +342,7 @@ function safeExtend(schema, shape) {
|
|
|
623
342
|
return clone(schema, def);
|
|
624
343
|
}
|
|
625
344
|
function merge(a, b) {
|
|
345
|
+
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
626
346
|
const def = mergeDefs(a._zod.def, {
|
|
627
347
|
get shape () {
|
|
628
348
|
const _shape = {
|
|
@@ -635,7 +355,7 @@ function merge(a, b) {
|
|
|
635
355
|
get catchall () {
|
|
636
356
|
return b._zod.def.catchall;
|
|
637
357
|
},
|
|
638
|
-
checks: []
|
|
358
|
+
checks: b._zod.def.checks ?? []
|
|
639
359
|
});
|
|
640
360
|
return clone(a, def);
|
|
641
361
|
}
|
|
@@ -697,6 +417,11 @@ function aborted(x, startIndex = 0) {
|
|
|
697
417
|
for(let i = startIndex; i < x.issues.length; i++)if (x.issues[i]?.continue !== true) return true;
|
|
698
418
|
return false;
|
|
699
419
|
}
|
|
420
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
421
|
+
if (true === x.aborted) return true;
|
|
422
|
+
for(let i = startIndex; i < x.issues.length; i++)if (x.issues[i]?.continue === false) return true;
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
700
425
|
function prefixIssues(path, issues) {
|
|
701
426
|
return issues.map((iss)=>{
|
|
702
427
|
var _a;
|
|
@@ -709,45 +434,18 @@ function unwrapMessage(message) {
|
|
|
709
434
|
return "string" == typeof message ? message : message?.message;
|
|
710
435
|
}
|
|
711
436
|
function finalizeIssue(iss, ctx, config) {
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
if (
|
|
717
|
-
|
|
718
|
-
full.message = message;
|
|
719
|
-
}
|
|
720
|
-
delete full.inst;
|
|
721
|
-
delete full.continue;
|
|
722
|
-
if (!ctx?.reportInput) delete full.input;
|
|
723
|
-
return full;
|
|
724
|
-
}
|
|
725
|
-
function getSizableOrigin(input) {
|
|
726
|
-
if (input instanceof Set) return "set";
|
|
727
|
-
if (input instanceof Map) return "map";
|
|
728
|
-
if (input instanceof File) return "file";
|
|
729
|
-
return "unknown";
|
|
437
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
438
|
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
439
|
+
rest.path ?? (rest.path = []);
|
|
440
|
+
rest.message = message;
|
|
441
|
+
if (ctx?.reportInput) rest.input = _input;
|
|
442
|
+
return rest;
|
|
730
443
|
}
|
|
731
444
|
function getLengthableOrigin(input) {
|
|
732
445
|
if (Array.isArray(input)) return "array";
|
|
733
446
|
if ("string" == typeof input) return "string";
|
|
734
447
|
return "unknown";
|
|
735
448
|
}
|
|
736
|
-
function parsedType(data) {
|
|
737
|
-
const t = typeof data;
|
|
738
|
-
switch(t){
|
|
739
|
-
case "number":
|
|
740
|
-
return Number.isNaN(data) ? "nan" : "number";
|
|
741
|
-
case "object":
|
|
742
|
-
{
|
|
743
|
-
if (null === data) return "null";
|
|
744
|
-
if (Array.isArray(data)) return "array";
|
|
745
|
-
const obj = data;
|
|
746
|
-
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
return t;
|
|
750
|
-
}
|
|
751
449
|
function util_issue(...args) {
|
|
752
450
|
const [iss, input, inst] = args;
|
|
753
451
|
if ("string" == typeof iss) return {
|
|
@@ -760,677 +458,143 @@ function util_issue(...args) {
|
|
|
760
458
|
...iss
|
|
761
459
|
};
|
|
762
460
|
}
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
461
|
+
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def)=>{
|
|
462
|
+
var _a;
|
|
463
|
+
inst._zod ?? (inst._zod = {});
|
|
464
|
+
inst._zod.def = def;
|
|
465
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
466
|
+
});
|
|
467
|
+
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def)=>{
|
|
468
|
+
var _a;
|
|
469
|
+
$ZodCheck.init(inst, def);
|
|
470
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
471
|
+
const val = payload.value;
|
|
472
|
+
return !nullish(val) && void 0 !== val.length;
|
|
772
473
|
});
|
|
773
|
-
inst.
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
enumerable: false
|
|
474
|
+
inst._zod.onattach.push((inst)=>{
|
|
475
|
+
const curr = inst._zod.bag.maximum ?? 1 / 0;
|
|
476
|
+
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
777
477
|
});
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
const
|
|
781
|
-
|
|
478
|
+
inst._zod.check = (payload)=>{
|
|
479
|
+
const input = payload.value;
|
|
480
|
+
const length = input.length;
|
|
481
|
+
if (length <= def.maximum) return;
|
|
482
|
+
const origin = getLengthableOrigin(input);
|
|
483
|
+
payload.issues.push({
|
|
484
|
+
origin,
|
|
485
|
+
code: "too_big",
|
|
486
|
+
maximum: def.maximum,
|
|
487
|
+
inclusive: true,
|
|
488
|
+
input,
|
|
489
|
+
inst,
|
|
490
|
+
continue: !def.abort
|
|
491
|
+
});
|
|
492
|
+
};
|
|
782
493
|
});
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
494
|
+
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def)=>{
|
|
495
|
+
var _a;
|
|
496
|
+
$ZodCheck.init(inst, def);
|
|
497
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
498
|
+
const val = payload.value;
|
|
499
|
+
return !nullish(val) && void 0 !== val.length;
|
|
500
|
+
});
|
|
501
|
+
inst._zod.onattach.push((inst)=>{
|
|
502
|
+
const curr = inst._zod.bag.minimum ?? -1 / 0;
|
|
503
|
+
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
504
|
+
});
|
|
505
|
+
inst._zod.check = (payload)=>{
|
|
506
|
+
const input = payload.value;
|
|
507
|
+
const length = input.length;
|
|
508
|
+
if (length >= def.minimum) return;
|
|
509
|
+
const origin = getLengthableOrigin(input);
|
|
510
|
+
payload.issues.push({
|
|
511
|
+
origin,
|
|
512
|
+
code: "too_small",
|
|
513
|
+
minimum: def.minimum,
|
|
514
|
+
inclusive: true,
|
|
515
|
+
input,
|
|
516
|
+
inst,
|
|
517
|
+
continue: !def.abort
|
|
518
|
+
});
|
|
793
519
|
};
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
520
|
+
});
|
|
521
|
+
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def)=>{
|
|
522
|
+
var _a;
|
|
523
|
+
$ZodCheck.init(inst, def);
|
|
524
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
525
|
+
const val = payload.value;
|
|
526
|
+
return !nullish(val) && void 0 !== val.length;
|
|
527
|
+
});
|
|
528
|
+
inst._zod.onattach.push((inst)=>{
|
|
529
|
+
const bag = inst._zod.bag;
|
|
530
|
+
bag.minimum = def.length;
|
|
531
|
+
bag.maximum = def.length;
|
|
532
|
+
bag.length = def.length;
|
|
533
|
+
});
|
|
534
|
+
inst._zod.check = (payload)=>{
|
|
535
|
+
const input = payload.value;
|
|
536
|
+
const length = input.length;
|
|
537
|
+
if (length === def.length) return;
|
|
538
|
+
const origin = getLengthableOrigin(input);
|
|
539
|
+
const tooBig = length > def.length;
|
|
540
|
+
payload.issues.push({
|
|
541
|
+
origin,
|
|
542
|
+
...tooBig ? {
|
|
543
|
+
code: "too_big",
|
|
544
|
+
maximum: def.length
|
|
545
|
+
} : {
|
|
546
|
+
code: "too_small",
|
|
547
|
+
minimum: def.length
|
|
548
|
+
},
|
|
549
|
+
inclusive: true,
|
|
550
|
+
exact: true,
|
|
551
|
+
input: payload.value,
|
|
552
|
+
inst,
|
|
553
|
+
continue: !def.abort
|
|
554
|
+
});
|
|
798
555
|
};
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
556
|
+
});
|
|
557
|
+
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def)=>{
|
|
558
|
+
var _a, _b;
|
|
559
|
+
$ZodCheck.init(inst, def);
|
|
560
|
+
inst._zod.onattach.push((inst)=>{
|
|
561
|
+
const bag = inst._zod.bag;
|
|
562
|
+
bag.format = def.format;
|
|
563
|
+
if (def.pattern) {
|
|
564
|
+
bag.patterns ?? (bag.patterns = new Set());
|
|
565
|
+
bag.patterns.add(def.pattern);
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload)=>{
|
|
569
|
+
def.pattern.lastIndex = 0;
|
|
570
|
+
if (def.pattern.test(payload.value)) return;
|
|
571
|
+
payload.issues.push({
|
|
572
|
+
origin: "string",
|
|
573
|
+
code: "invalid_format",
|
|
574
|
+
format: def.format,
|
|
575
|
+
input: payload.value,
|
|
576
|
+
...def.pattern ? {
|
|
577
|
+
pattern: def.pattern.toString()
|
|
578
|
+
} : {},
|
|
579
|
+
inst,
|
|
580
|
+
continue: !def.abort
|
|
805
581
|
});
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
_errors: []
|
|
823
|
-
};
|
|
824
|
-
curr = curr[el];
|
|
825
|
-
i++;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
};
|
|
829
|
-
processError(error);
|
|
830
|
-
return fieldErrors;
|
|
831
|
-
}
|
|
832
|
-
const _parse = (_Err)=>(schema, value, _ctx, _params)=>{
|
|
833
|
-
const ctx = _ctx ? Object.assign(_ctx, {
|
|
834
|
-
async: false
|
|
835
|
-
}) : {
|
|
836
|
-
async: false
|
|
837
|
-
};
|
|
838
|
-
const result = schema._zod.run({
|
|
839
|
-
value,
|
|
840
|
-
issues: []
|
|
841
|
-
}, ctx);
|
|
842
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
843
|
-
if (result.issues.length) {
|
|
844
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())));
|
|
845
|
-
captureStackTrace(e, _params?.callee);
|
|
846
|
-
throw e;
|
|
847
|
-
}
|
|
848
|
-
return result.value;
|
|
849
|
-
};
|
|
850
|
-
const parse = /* @__PURE__*/ _parse($ZodRealError);
|
|
851
|
-
const _parseAsync = (_Err)=>async (schema, value, _ctx, params)=>{
|
|
852
|
-
const ctx = _ctx ? Object.assign(_ctx, {
|
|
853
|
-
async: true
|
|
854
|
-
}) : {
|
|
855
|
-
async: true
|
|
856
|
-
};
|
|
857
|
-
let result = schema._zod.run({
|
|
858
|
-
value,
|
|
859
|
-
issues: []
|
|
860
|
-
}, ctx);
|
|
861
|
-
if (result instanceof Promise) result = await result;
|
|
862
|
-
if (result.issues.length) {
|
|
863
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())));
|
|
864
|
-
captureStackTrace(e, params?.callee);
|
|
865
|
-
throw e;
|
|
866
|
-
}
|
|
867
|
-
return result.value;
|
|
868
|
-
};
|
|
869
|
-
const parseAsync = /* @__PURE__*/ _parseAsync($ZodRealError);
|
|
870
|
-
const _safeParse = (_Err)=>(schema, value, _ctx)=>{
|
|
871
|
-
const ctx = _ctx ? {
|
|
872
|
-
..._ctx,
|
|
873
|
-
async: false
|
|
874
|
-
} : {
|
|
875
|
-
async: false
|
|
876
|
-
};
|
|
877
|
-
const result = schema._zod.run({
|
|
878
|
-
value,
|
|
879
|
-
issues: []
|
|
880
|
-
}, ctx);
|
|
881
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
882
|
-
return result.issues.length ? {
|
|
883
|
-
success: false,
|
|
884
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
|
885
|
-
} : {
|
|
886
|
-
success: true,
|
|
887
|
-
data: result.value
|
|
888
|
-
};
|
|
889
|
-
};
|
|
890
|
-
const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
891
|
-
const _safeParseAsync = (_Err)=>async (schema, value, _ctx)=>{
|
|
892
|
-
const ctx = _ctx ? Object.assign(_ctx, {
|
|
893
|
-
async: true
|
|
894
|
-
}) : {
|
|
895
|
-
async: true
|
|
896
|
-
};
|
|
897
|
-
let result = schema._zod.run({
|
|
898
|
-
value,
|
|
899
|
-
issues: []
|
|
900
|
-
}, ctx);
|
|
901
|
-
if (result instanceof Promise) result = await result;
|
|
902
|
-
return result.issues.length ? {
|
|
903
|
-
success: false,
|
|
904
|
-
error: new _Err(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
|
905
|
-
} : {
|
|
906
|
-
success: true,
|
|
907
|
-
data: result.value
|
|
908
|
-
};
|
|
909
|
-
};
|
|
910
|
-
const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
|
911
|
-
const _encode = (_Err)=>(schema, value, _ctx)=>{
|
|
912
|
-
const ctx = _ctx ? Object.assign(_ctx, {
|
|
913
|
-
direction: "backward"
|
|
914
|
-
}) : {
|
|
915
|
-
direction: "backward"
|
|
916
|
-
};
|
|
917
|
-
return _parse(_Err)(schema, value, ctx);
|
|
918
|
-
};
|
|
919
|
-
const _decode = (_Err)=>(schema, value, _ctx)=>_parse(_Err)(schema, value, _ctx);
|
|
920
|
-
const _encodeAsync = (_Err)=>async (schema, value, _ctx)=>{
|
|
921
|
-
const ctx = _ctx ? Object.assign(_ctx, {
|
|
922
|
-
direction: "backward"
|
|
923
|
-
}) : {
|
|
924
|
-
direction: "backward"
|
|
925
|
-
};
|
|
926
|
-
return _parseAsync(_Err)(schema, value, ctx);
|
|
927
|
-
};
|
|
928
|
-
const _decodeAsync = (_Err)=>async (schema, value, _ctx)=>_parseAsync(_Err)(schema, value, _ctx);
|
|
929
|
-
const _safeEncode = (_Err)=>(schema, value, _ctx)=>{
|
|
930
|
-
const ctx = _ctx ? Object.assign(_ctx, {
|
|
931
|
-
direction: "backward"
|
|
932
|
-
}) : {
|
|
933
|
-
direction: "backward"
|
|
934
|
-
};
|
|
935
|
-
return _safeParse(_Err)(schema, value, ctx);
|
|
936
|
-
};
|
|
937
|
-
const _safeDecode = (_Err)=>(schema, value, _ctx)=>_safeParse(_Err)(schema, value, _ctx);
|
|
938
|
-
const _safeEncodeAsync = (_Err)=>async (schema, value, _ctx)=>{
|
|
939
|
-
const ctx = _ctx ? Object.assign(_ctx, {
|
|
940
|
-
direction: "backward"
|
|
941
|
-
}) : {
|
|
942
|
-
direction: "backward"
|
|
943
|
-
};
|
|
944
|
-
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
945
|
-
};
|
|
946
|
-
const _safeDecodeAsync = (_Err)=>async (schema, value, _ctx)=>_safeParseAsync(_Err)(schema, value, _ctx);
|
|
947
|
-
const cuid = /^[cC][^\s-]{8,}$/;
|
|
948
|
-
const cuid2 = /^[0-9a-z]+$/;
|
|
949
|
-
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
950
|
-
const xid = /^[0-9a-vA-V]{20}$/;
|
|
951
|
-
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
952
|
-
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
953
|
-
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
954
|
-
const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
955
|
-
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
956
|
-
const uuid = (version)=>{
|
|
957
|
-
if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
958
|
-
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
959
|
-
};
|
|
960
|
-
const uuid4 = /*@__PURE__*/ uuid(4);
|
|
961
|
-
const uuid6 = /*@__PURE__*/ uuid(6);
|
|
962
|
-
const uuid7 = /*@__PURE__*/ uuid(7);
|
|
963
|
-
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
964
|
-
const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
965
|
-
const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
966
|
-
const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
967
|
-
const idnEmail = unicodeEmail;
|
|
968
|
-
const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
969
|
-
const _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
970
|
-
function emoji() {
|
|
971
|
-
return new RegExp(_emoji, "u");
|
|
972
|
-
}
|
|
973
|
-
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
974
|
-
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
975
|
-
const mac = (delimiter)=>{
|
|
976
|
-
const escapedDelim = escapeRegex(delimiter ?? ":");
|
|
977
|
-
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
978
|
-
};
|
|
979
|
-
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
980
|
-
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
981
|
-
const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
982
|
-
const regexes_base64url = /^[A-Za-z0-9_-]*$/;
|
|
983
|
-
const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
984
|
-
const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
985
|
-
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
986
|
-
const dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";
|
|
987
|
-
const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
|
988
|
-
function timeSource(args) {
|
|
989
|
-
const hhmm = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
990
|
-
const regex = "number" == typeof args.precision ? -1 === args.precision ? `${hhmm}` : 0 === args.precision ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
991
|
-
return regex;
|
|
992
|
-
}
|
|
993
|
-
function regexes_time(args) {
|
|
994
|
-
return new RegExp(`^${timeSource(args)}$`);
|
|
995
|
-
}
|
|
996
|
-
function datetime(args) {
|
|
997
|
-
const time = timeSource({
|
|
998
|
-
precision: args.precision
|
|
999
|
-
});
|
|
1000
|
-
const opts = [
|
|
1001
|
-
"Z"
|
|
1002
|
-
];
|
|
1003
|
-
if (args.local) opts.push("");
|
|
1004
|
-
if (args.offset) opts.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
|
1005
|
-
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
1006
|
-
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
1007
|
-
}
|
|
1008
|
-
const string = (params)=>{
|
|
1009
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
1010
|
-
return new RegExp(`^${regex}$`);
|
|
1011
|
-
};
|
|
1012
|
-
const bigint = /^-?\d+n?$/;
|
|
1013
|
-
const integer = /^-?\d+$/;
|
|
1014
|
-
const regexes_number = /^-?\d+(?:\.\d+)?$/;
|
|
1015
|
-
const regexes_boolean = /^(?:true|false)$/i;
|
|
1016
|
-
const _null = /^null$/i;
|
|
1017
|
-
const _undefined = /^undefined$/i;
|
|
1018
|
-
const lowercase = /^[^A-Z]*$/;
|
|
1019
|
-
const uppercase = /^[^a-z]*$/;
|
|
1020
|
-
const regexes_hex = /^[0-9a-fA-F]*$/;
|
|
1021
|
-
function fixedBase64(bodyLength, padding) {
|
|
1022
|
-
return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
|
|
1023
|
-
}
|
|
1024
|
-
function fixedBase64url(length) {
|
|
1025
|
-
return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
|
|
1026
|
-
}
|
|
1027
|
-
const md5_hex = /^[0-9a-fA-F]{32}$/;
|
|
1028
|
-
const md5_base64 = /*@__PURE__*/ fixedBase64(22, "==");
|
|
1029
|
-
const md5_base64url = /*@__PURE__*/ fixedBase64url(22);
|
|
1030
|
-
const sha1_hex = /^[0-9a-fA-F]{40}$/;
|
|
1031
|
-
const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "=");
|
|
1032
|
-
const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);
|
|
1033
|
-
const sha256_hex = /^[0-9a-fA-F]{64}$/;
|
|
1034
|
-
const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "=");
|
|
1035
|
-
const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);
|
|
1036
|
-
const sha384_hex = /^[0-9a-fA-F]{96}$/;
|
|
1037
|
-
const sha384_base64 = /*@__PURE__*/ fixedBase64(64, "");
|
|
1038
|
-
const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);
|
|
1039
|
-
const sha512_hex = /^[0-9a-fA-F]{128}$/;
|
|
1040
|
-
const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
|
|
1041
|
-
const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
|
|
1042
|
-
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def)=>{
|
|
1043
|
-
var _a;
|
|
1044
|
-
inst._zod ?? (inst._zod = {});
|
|
1045
|
-
inst._zod.def = def;
|
|
1046
|
-
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
1047
|
-
});
|
|
1048
|
-
const numericOriginMap = {
|
|
1049
|
-
number: "number",
|
|
1050
|
-
bigint: "bigint",
|
|
1051
|
-
object: "date"
|
|
1052
|
-
};
|
|
1053
|
-
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def)=>{
|
|
1054
|
-
$ZodCheck.init(inst, def);
|
|
1055
|
-
const origin = numericOriginMap[typeof def.value];
|
|
1056
|
-
inst._zod.onattach.push((inst)=>{
|
|
1057
|
-
const bag = inst._zod.bag;
|
|
1058
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? 1 / 0;
|
|
1059
|
-
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
|
1060
|
-
else bag.exclusiveMaximum = def.value;
|
|
1061
|
-
});
|
|
1062
|
-
inst._zod.check = (payload)=>{
|
|
1063
|
-
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
1064
|
-
payload.issues.push({
|
|
1065
|
-
origin,
|
|
1066
|
-
code: "too_big",
|
|
1067
|
-
maximum: "object" == typeof def.value ? def.value.getTime() : def.value,
|
|
1068
|
-
input: payload.value,
|
|
1069
|
-
inclusive: def.inclusive,
|
|
1070
|
-
inst,
|
|
1071
|
-
continue: !def.abort
|
|
1072
|
-
});
|
|
1073
|
-
};
|
|
1074
|
-
});
|
|
1075
|
-
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def)=>{
|
|
1076
|
-
$ZodCheck.init(inst, def);
|
|
1077
|
-
const origin = numericOriginMap[typeof def.value];
|
|
1078
|
-
inst._zod.onattach.push((inst)=>{
|
|
1079
|
-
const bag = inst._zod.bag;
|
|
1080
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? -1 / 0;
|
|
1081
|
-
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
|
1082
|
-
else bag.exclusiveMinimum = def.value;
|
|
1083
|
-
});
|
|
1084
|
-
inst._zod.check = (payload)=>{
|
|
1085
|
-
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
1086
|
-
payload.issues.push({
|
|
1087
|
-
origin,
|
|
1088
|
-
code: "too_small",
|
|
1089
|
-
minimum: "object" == typeof def.value ? def.value.getTime() : def.value,
|
|
1090
|
-
input: payload.value,
|
|
1091
|
-
inclusive: def.inclusive,
|
|
1092
|
-
inst,
|
|
1093
|
-
continue: !def.abort
|
|
1094
|
-
});
|
|
1095
|
-
};
|
|
1096
|
-
});
|
|
1097
|
-
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def)=>{
|
|
1098
|
-
$ZodCheck.init(inst, def);
|
|
1099
|
-
inst._zod.onattach.push((inst)=>{
|
|
1100
|
-
var _a;
|
|
1101
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
1102
|
-
});
|
|
1103
|
-
inst._zod.check = (payload)=>{
|
|
1104
|
-
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
1105
|
-
const isMultiple = "bigint" == typeof payload.value ? payload.value % def.value === BigInt(0) : 0 === floatSafeRemainder(payload.value, def.value);
|
|
1106
|
-
if (isMultiple) return;
|
|
1107
|
-
payload.issues.push({
|
|
1108
|
-
origin: typeof payload.value,
|
|
1109
|
-
code: "not_multiple_of",
|
|
1110
|
-
divisor: def.value,
|
|
1111
|
-
input: payload.value,
|
|
1112
|
-
inst,
|
|
1113
|
-
continue: !def.abort
|
|
1114
|
-
});
|
|
1115
|
-
};
|
|
1116
|
-
});
|
|
1117
|
-
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def)=>{
|
|
1118
|
-
$ZodCheck.init(inst, def);
|
|
1119
|
-
def.format = def.format || "float64";
|
|
1120
|
-
const isInt = def.format?.includes("int");
|
|
1121
|
-
const origin = isInt ? "int" : "number";
|
|
1122
|
-
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
1123
|
-
inst._zod.onattach.push((inst)=>{
|
|
1124
|
-
const bag = inst._zod.bag;
|
|
1125
|
-
bag.format = def.format;
|
|
1126
|
-
bag.minimum = minimum;
|
|
1127
|
-
bag.maximum = maximum;
|
|
1128
|
-
if (isInt) bag.pattern = integer;
|
|
1129
|
-
});
|
|
1130
|
-
inst._zod.check = (payload)=>{
|
|
1131
|
-
const input = payload.value;
|
|
1132
|
-
if (isInt) {
|
|
1133
|
-
if (!Number.isInteger(input)) return void payload.issues.push({
|
|
1134
|
-
expected: origin,
|
|
1135
|
-
format: def.format,
|
|
1136
|
-
code: "invalid_type",
|
|
1137
|
-
continue: false,
|
|
1138
|
-
input,
|
|
1139
|
-
inst
|
|
1140
|
-
});
|
|
1141
|
-
if (!Number.isSafeInteger(input)) {
|
|
1142
|
-
if (input > 0) payload.issues.push({
|
|
1143
|
-
input,
|
|
1144
|
-
code: "too_big",
|
|
1145
|
-
maximum: Number.MAX_SAFE_INTEGER,
|
|
1146
|
-
note: "Integers must be within the safe integer range.",
|
|
1147
|
-
inst,
|
|
1148
|
-
origin,
|
|
1149
|
-
inclusive: true,
|
|
1150
|
-
continue: !def.abort
|
|
1151
|
-
});
|
|
1152
|
-
else payload.issues.push({
|
|
1153
|
-
input,
|
|
1154
|
-
code: "too_small",
|
|
1155
|
-
minimum: Number.MIN_SAFE_INTEGER,
|
|
1156
|
-
note: "Integers must be within the safe integer range.",
|
|
1157
|
-
inst,
|
|
1158
|
-
origin,
|
|
1159
|
-
inclusive: true,
|
|
1160
|
-
continue: !def.abort
|
|
1161
|
-
});
|
|
1162
|
-
return;
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
if (input < minimum) payload.issues.push({
|
|
1166
|
-
origin: "number",
|
|
1167
|
-
input,
|
|
1168
|
-
code: "too_small",
|
|
1169
|
-
minimum,
|
|
1170
|
-
inclusive: true,
|
|
1171
|
-
inst,
|
|
1172
|
-
continue: !def.abort
|
|
1173
|
-
});
|
|
1174
|
-
if (input > maximum) payload.issues.push({
|
|
1175
|
-
origin: "number",
|
|
1176
|
-
input,
|
|
1177
|
-
code: "too_big",
|
|
1178
|
-
maximum,
|
|
1179
|
-
inclusive: true,
|
|
1180
|
-
inst,
|
|
1181
|
-
continue: !def.abort
|
|
1182
|
-
});
|
|
1183
|
-
};
|
|
1184
|
-
});
|
|
1185
|
-
const $ZodCheckBigIntFormat = /*@__PURE__*/ $constructor("$ZodCheckBigIntFormat", (inst, def)=>{
|
|
1186
|
-
$ZodCheck.init(inst, def);
|
|
1187
|
-
const [minimum, maximum] = BIGINT_FORMAT_RANGES[def.format];
|
|
1188
|
-
inst._zod.onattach.push((inst)=>{
|
|
1189
|
-
const bag = inst._zod.bag;
|
|
1190
|
-
bag.format = def.format;
|
|
1191
|
-
bag.minimum = minimum;
|
|
1192
|
-
bag.maximum = maximum;
|
|
1193
|
-
});
|
|
1194
|
-
inst._zod.check = (payload)=>{
|
|
1195
|
-
const input = payload.value;
|
|
1196
|
-
if (input < minimum) payload.issues.push({
|
|
1197
|
-
origin: "bigint",
|
|
1198
|
-
input,
|
|
1199
|
-
code: "too_small",
|
|
1200
|
-
minimum: minimum,
|
|
1201
|
-
inclusive: true,
|
|
1202
|
-
inst,
|
|
1203
|
-
continue: !def.abort
|
|
1204
|
-
});
|
|
1205
|
-
if (input > maximum) payload.issues.push({
|
|
1206
|
-
origin: "bigint",
|
|
1207
|
-
input,
|
|
1208
|
-
code: "too_big",
|
|
1209
|
-
maximum,
|
|
1210
|
-
inclusive: true,
|
|
1211
|
-
inst,
|
|
1212
|
-
continue: !def.abort
|
|
1213
|
-
});
|
|
1214
|
-
};
|
|
1215
|
-
});
|
|
1216
|
-
const $ZodCheckMaxSize = /*@__PURE__*/ $constructor("$ZodCheckMaxSize", (inst, def)=>{
|
|
1217
|
-
var _a;
|
|
1218
|
-
$ZodCheck.init(inst, def);
|
|
1219
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
1220
|
-
const val = payload.value;
|
|
1221
|
-
return !nullish(val) && void 0 !== val.size;
|
|
1222
|
-
});
|
|
1223
|
-
inst._zod.onattach.push((inst)=>{
|
|
1224
|
-
const curr = inst._zod.bag.maximum ?? 1 / 0;
|
|
1225
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
1226
|
-
});
|
|
1227
|
-
inst._zod.check = (payload)=>{
|
|
1228
|
-
const input = payload.value;
|
|
1229
|
-
const size = input.size;
|
|
1230
|
-
if (size <= def.maximum) return;
|
|
1231
|
-
payload.issues.push({
|
|
1232
|
-
origin: getSizableOrigin(input),
|
|
1233
|
-
code: "too_big",
|
|
1234
|
-
maximum: def.maximum,
|
|
1235
|
-
inclusive: true,
|
|
1236
|
-
input,
|
|
1237
|
-
inst,
|
|
1238
|
-
continue: !def.abort
|
|
1239
|
-
});
|
|
1240
|
-
};
|
|
1241
|
-
});
|
|
1242
|
-
const $ZodCheckMinSize = /*@__PURE__*/ $constructor("$ZodCheckMinSize", (inst, def)=>{
|
|
1243
|
-
var _a;
|
|
1244
|
-
$ZodCheck.init(inst, def);
|
|
1245
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
1246
|
-
const val = payload.value;
|
|
1247
|
-
return !nullish(val) && void 0 !== val.size;
|
|
1248
|
-
});
|
|
1249
|
-
inst._zod.onattach.push((inst)=>{
|
|
1250
|
-
const curr = inst._zod.bag.minimum ?? -1 / 0;
|
|
1251
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
1252
|
-
});
|
|
1253
|
-
inst._zod.check = (payload)=>{
|
|
1254
|
-
const input = payload.value;
|
|
1255
|
-
const size = input.size;
|
|
1256
|
-
if (size >= def.minimum) return;
|
|
1257
|
-
payload.issues.push({
|
|
1258
|
-
origin: getSizableOrigin(input),
|
|
1259
|
-
code: "too_small",
|
|
1260
|
-
minimum: def.minimum,
|
|
1261
|
-
inclusive: true,
|
|
1262
|
-
input,
|
|
1263
|
-
inst,
|
|
1264
|
-
continue: !def.abort
|
|
1265
|
-
});
|
|
1266
|
-
};
|
|
1267
|
-
});
|
|
1268
|
-
const $ZodCheckSizeEquals = /*@__PURE__*/ $constructor("$ZodCheckSizeEquals", (inst, def)=>{
|
|
1269
|
-
var _a;
|
|
1270
|
-
$ZodCheck.init(inst, def);
|
|
1271
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
1272
|
-
const val = payload.value;
|
|
1273
|
-
return !nullish(val) && void 0 !== val.size;
|
|
1274
|
-
});
|
|
1275
|
-
inst._zod.onattach.push((inst)=>{
|
|
1276
|
-
const bag = inst._zod.bag;
|
|
1277
|
-
bag.minimum = def.size;
|
|
1278
|
-
bag.maximum = def.size;
|
|
1279
|
-
bag.size = def.size;
|
|
1280
|
-
});
|
|
1281
|
-
inst._zod.check = (payload)=>{
|
|
1282
|
-
const input = payload.value;
|
|
1283
|
-
const size = input.size;
|
|
1284
|
-
if (size === def.size) return;
|
|
1285
|
-
const tooBig = size > def.size;
|
|
1286
|
-
payload.issues.push({
|
|
1287
|
-
origin: getSizableOrigin(input),
|
|
1288
|
-
...tooBig ? {
|
|
1289
|
-
code: "too_big",
|
|
1290
|
-
maximum: def.size
|
|
1291
|
-
} : {
|
|
1292
|
-
code: "too_small",
|
|
1293
|
-
minimum: def.size
|
|
1294
|
-
},
|
|
1295
|
-
inclusive: true,
|
|
1296
|
-
exact: true,
|
|
1297
|
-
input: payload.value,
|
|
1298
|
-
inst,
|
|
1299
|
-
continue: !def.abort
|
|
1300
|
-
});
|
|
1301
|
-
};
|
|
1302
|
-
});
|
|
1303
|
-
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def)=>{
|
|
1304
|
-
var _a;
|
|
1305
|
-
$ZodCheck.init(inst, def);
|
|
1306
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
1307
|
-
const val = payload.value;
|
|
1308
|
-
return !nullish(val) && void 0 !== val.length;
|
|
1309
|
-
});
|
|
1310
|
-
inst._zod.onattach.push((inst)=>{
|
|
1311
|
-
const curr = inst._zod.bag.maximum ?? 1 / 0;
|
|
1312
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
1313
|
-
});
|
|
1314
|
-
inst._zod.check = (payload)=>{
|
|
1315
|
-
const input = payload.value;
|
|
1316
|
-
const length = input.length;
|
|
1317
|
-
if (length <= def.maximum) return;
|
|
1318
|
-
const origin = getLengthableOrigin(input);
|
|
1319
|
-
payload.issues.push({
|
|
1320
|
-
origin,
|
|
1321
|
-
code: "too_big",
|
|
1322
|
-
maximum: def.maximum,
|
|
1323
|
-
inclusive: true,
|
|
1324
|
-
input,
|
|
1325
|
-
inst,
|
|
1326
|
-
continue: !def.abort
|
|
1327
|
-
});
|
|
1328
|
-
};
|
|
1329
|
-
});
|
|
1330
|
-
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def)=>{
|
|
1331
|
-
var _a;
|
|
1332
|
-
$ZodCheck.init(inst, def);
|
|
1333
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
1334
|
-
const val = payload.value;
|
|
1335
|
-
return !nullish(val) && void 0 !== val.length;
|
|
1336
|
-
});
|
|
1337
|
-
inst._zod.onattach.push((inst)=>{
|
|
1338
|
-
const curr = inst._zod.bag.minimum ?? -1 / 0;
|
|
1339
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
1340
|
-
});
|
|
1341
|
-
inst._zod.check = (payload)=>{
|
|
1342
|
-
const input = payload.value;
|
|
1343
|
-
const length = input.length;
|
|
1344
|
-
if (length >= def.minimum) return;
|
|
1345
|
-
const origin = getLengthableOrigin(input);
|
|
1346
|
-
payload.issues.push({
|
|
1347
|
-
origin,
|
|
1348
|
-
code: "too_small",
|
|
1349
|
-
minimum: def.minimum,
|
|
1350
|
-
inclusive: true,
|
|
1351
|
-
input,
|
|
1352
|
-
inst,
|
|
1353
|
-
continue: !def.abort
|
|
1354
|
-
});
|
|
1355
|
-
};
|
|
1356
|
-
});
|
|
1357
|
-
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def)=>{
|
|
1358
|
-
var _a;
|
|
1359
|
-
$ZodCheck.init(inst, def);
|
|
1360
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
|
1361
|
-
const val = payload.value;
|
|
1362
|
-
return !nullish(val) && void 0 !== val.length;
|
|
1363
|
-
});
|
|
1364
|
-
inst._zod.onattach.push((inst)=>{
|
|
1365
|
-
const bag = inst._zod.bag;
|
|
1366
|
-
bag.minimum = def.length;
|
|
1367
|
-
bag.maximum = def.length;
|
|
1368
|
-
bag.length = def.length;
|
|
1369
|
-
});
|
|
1370
|
-
inst._zod.check = (payload)=>{
|
|
1371
|
-
const input = payload.value;
|
|
1372
|
-
const length = input.length;
|
|
1373
|
-
if (length === def.length) return;
|
|
1374
|
-
const origin = getLengthableOrigin(input);
|
|
1375
|
-
const tooBig = length > def.length;
|
|
1376
|
-
payload.issues.push({
|
|
1377
|
-
origin,
|
|
1378
|
-
...tooBig ? {
|
|
1379
|
-
code: "too_big",
|
|
1380
|
-
maximum: def.length
|
|
1381
|
-
} : {
|
|
1382
|
-
code: "too_small",
|
|
1383
|
-
minimum: def.length
|
|
1384
|
-
},
|
|
1385
|
-
inclusive: true,
|
|
1386
|
-
exact: true,
|
|
1387
|
-
input: payload.value,
|
|
1388
|
-
inst,
|
|
1389
|
-
continue: !def.abort
|
|
1390
|
-
});
|
|
1391
|
-
};
|
|
1392
|
-
});
|
|
1393
|
-
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def)=>{
|
|
1394
|
-
var _a, _b;
|
|
1395
|
-
$ZodCheck.init(inst, def);
|
|
1396
|
-
inst._zod.onattach.push((inst)=>{
|
|
1397
|
-
const bag = inst._zod.bag;
|
|
1398
|
-
bag.format = def.format;
|
|
1399
|
-
if (def.pattern) {
|
|
1400
|
-
bag.patterns ?? (bag.patterns = new Set());
|
|
1401
|
-
bag.patterns.add(def.pattern);
|
|
1402
|
-
}
|
|
1403
|
-
});
|
|
1404
|
-
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload)=>{
|
|
1405
|
-
def.pattern.lastIndex = 0;
|
|
1406
|
-
if (def.pattern.test(payload.value)) return;
|
|
1407
|
-
payload.issues.push({
|
|
1408
|
-
origin: "string",
|
|
1409
|
-
code: "invalid_format",
|
|
1410
|
-
format: def.format,
|
|
1411
|
-
input: payload.value,
|
|
1412
|
-
...def.pattern ? {
|
|
1413
|
-
pattern: def.pattern.toString()
|
|
1414
|
-
} : {},
|
|
1415
|
-
inst,
|
|
1416
|
-
continue: !def.abort
|
|
1417
|
-
});
|
|
1418
|
-
});
|
|
1419
|
-
else (_b = inst._zod).check ?? (_b.check = ()=>{});
|
|
1420
|
-
});
|
|
1421
|
-
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def)=>{
|
|
1422
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1423
|
-
inst._zod.check = (payload)=>{
|
|
1424
|
-
def.pattern.lastIndex = 0;
|
|
1425
|
-
if (def.pattern.test(payload.value)) return;
|
|
1426
|
-
payload.issues.push({
|
|
1427
|
-
origin: "string",
|
|
1428
|
-
code: "invalid_format",
|
|
1429
|
-
format: "regex",
|
|
1430
|
-
input: payload.value,
|
|
1431
|
-
pattern: def.pattern.toString(),
|
|
1432
|
-
inst,
|
|
1433
|
-
continue: !def.abort
|
|
582
|
+
});
|
|
583
|
+
else (_b = inst._zod).check ?? (_b.check = ()=>{});
|
|
584
|
+
});
|
|
585
|
+
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def)=>{
|
|
586
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
587
|
+
inst._zod.check = (payload)=>{
|
|
588
|
+
def.pattern.lastIndex = 0;
|
|
589
|
+
if (def.pattern.test(payload.value)) return;
|
|
590
|
+
payload.issues.push({
|
|
591
|
+
origin: "string",
|
|
592
|
+
code: "invalid_format",
|
|
593
|
+
format: "regex",
|
|
594
|
+
input: payload.value,
|
|
595
|
+
pattern: def.pattern.toString(),
|
|
596
|
+
inst,
|
|
597
|
+
continue: !def.abort
|
|
1434
598
|
});
|
|
1435
599
|
};
|
|
1436
600
|
});
|
|
@@ -1508,87 +672,260 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
|
|
|
1508
672
|
continue: !def.abort
|
|
1509
673
|
});
|
|
1510
674
|
};
|
|
1511
|
-
});
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
675
|
+
});
|
|
676
|
+
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def)=>{
|
|
677
|
+
$ZodCheck.init(inst, def);
|
|
678
|
+
inst._zod.check = (payload)=>{
|
|
679
|
+
payload.value = def.tx(payload.value);
|
|
680
|
+
};
|
|
681
|
+
});
|
|
682
|
+
class Doc {
|
|
683
|
+
constructor(args = []){
|
|
684
|
+
this.content = [];
|
|
685
|
+
this.indent = 0;
|
|
686
|
+
if (this) this.args = args;
|
|
687
|
+
}
|
|
688
|
+
indented(fn) {
|
|
689
|
+
this.indent += 1;
|
|
690
|
+
fn(this);
|
|
691
|
+
this.indent -= 1;
|
|
692
|
+
}
|
|
693
|
+
write(arg) {
|
|
694
|
+
if ("function" == typeof arg) {
|
|
695
|
+
arg(this, {
|
|
696
|
+
execution: "sync"
|
|
697
|
+
});
|
|
698
|
+
arg(this, {
|
|
699
|
+
execution: "async"
|
|
700
|
+
});
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
const content = arg;
|
|
704
|
+
const lines = content.split("\n").filter((x)=>x);
|
|
705
|
+
const minIndent = Math.min(...lines.map((x)=>x.length - x.trimStart().length));
|
|
706
|
+
const dedented = lines.map((x)=>x.slice(minIndent)).map((x)=>" ".repeat(2 * this.indent) + x);
|
|
707
|
+
for (const line of dedented)this.content.push(line);
|
|
708
|
+
}
|
|
709
|
+
compile() {
|
|
710
|
+
const F = Function;
|
|
711
|
+
const args = this?.args;
|
|
712
|
+
const content = this?.content ?? [
|
|
713
|
+
""
|
|
714
|
+
];
|
|
715
|
+
const lines = [
|
|
716
|
+
...content.map((x)=>` ${x}`)
|
|
717
|
+
];
|
|
718
|
+
return new F(...args, lines.join("\n"));
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
const errors_initializer = (inst, def)=>{
|
|
722
|
+
inst.name = "$ZodError";
|
|
723
|
+
Object.defineProperty(inst, "_zod", {
|
|
724
|
+
value: inst._zod,
|
|
725
|
+
enumerable: false
|
|
726
|
+
});
|
|
727
|
+
Object.defineProperty(inst, "issues", {
|
|
728
|
+
value: def,
|
|
729
|
+
enumerable: false
|
|
730
|
+
});
|
|
731
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
732
|
+
Object.defineProperty(inst, "toString", {
|
|
733
|
+
value: ()=>inst.message,
|
|
734
|
+
enumerable: false
|
|
735
|
+
});
|
|
736
|
+
};
|
|
737
|
+
const $ZodError = $constructor("$ZodError", errors_initializer);
|
|
738
|
+
const $ZodRealError = $constructor("$ZodError", errors_initializer, {
|
|
739
|
+
Parent: Error
|
|
740
|
+
});
|
|
741
|
+
function flattenError(error, mapper = (issue)=>issue.message) {
|
|
742
|
+
const fieldErrors = {};
|
|
743
|
+
const formErrors = [];
|
|
744
|
+
for (const sub of error.issues)if (sub.path.length > 0) {
|
|
745
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
746
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
747
|
+
} else formErrors.push(mapper(sub));
|
|
748
|
+
return {
|
|
749
|
+
formErrors,
|
|
750
|
+
fieldErrors
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function formatError(error, mapper = (issue)=>issue.message) {
|
|
754
|
+
const fieldErrors = {
|
|
755
|
+
_errors: []
|
|
756
|
+
};
|
|
757
|
+
const processError = (error, path = [])=>{
|
|
758
|
+
for (const issue of error.issues)if ("invalid_union" === issue.code && issue.errors.length) issue.errors.map((issues)=>processError({
|
|
759
|
+
issues
|
|
760
|
+
}, [
|
|
761
|
+
...path,
|
|
762
|
+
...issue.path
|
|
763
|
+
]));
|
|
764
|
+
else if ("invalid_key" === issue.code) processError({
|
|
765
|
+
issues: issue.issues
|
|
766
|
+
}, [
|
|
767
|
+
...path,
|
|
768
|
+
...issue.path
|
|
769
|
+
]);
|
|
770
|
+
else if ("invalid_element" === issue.code) processError({
|
|
771
|
+
issues: issue.issues
|
|
772
|
+
}, [
|
|
773
|
+
...path,
|
|
774
|
+
...issue.path
|
|
775
|
+
]);
|
|
776
|
+
else {
|
|
777
|
+
const fullpath = [
|
|
778
|
+
...path,
|
|
779
|
+
...issue.path
|
|
780
|
+
];
|
|
781
|
+
if (0 === fullpath.length) fieldErrors._errors.push(mapper(issue));
|
|
782
|
+
else {
|
|
783
|
+
let curr = fieldErrors;
|
|
784
|
+
let i = 0;
|
|
785
|
+
while(i < fullpath.length){
|
|
786
|
+
const el = fullpath[i];
|
|
787
|
+
const terminal = i === fullpath.length - 1;
|
|
788
|
+
if (terminal) {
|
|
789
|
+
curr[el] = curr[el] || {
|
|
790
|
+
_errors: []
|
|
791
|
+
};
|
|
792
|
+
curr[el]._errors.push(mapper(issue));
|
|
793
|
+
} else curr[el] = curr[el] || {
|
|
794
|
+
_errors: []
|
|
795
|
+
};
|
|
796
|
+
curr = curr[el];
|
|
797
|
+
i++;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
processError(error);
|
|
803
|
+
return fieldErrors;
|
|
804
|
+
}
|
|
805
|
+
const _parse = (_Err)=>(schema, value, _ctx, _params)=>{
|
|
806
|
+
const ctx = _ctx ? {
|
|
807
|
+
..._ctx,
|
|
808
|
+
async: false
|
|
809
|
+
} : {
|
|
810
|
+
async: false
|
|
811
|
+
};
|
|
812
|
+
const result = schema._zod.run({
|
|
813
|
+
value,
|
|
814
|
+
issues: []
|
|
815
|
+
}, ctx);
|
|
816
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
817
|
+
if (result.issues.length) {
|
|
818
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())));
|
|
819
|
+
captureStackTrace(e, _params?.callee);
|
|
820
|
+
throw e;
|
|
821
|
+
}
|
|
822
|
+
return result.value;
|
|
823
|
+
};
|
|
824
|
+
const _parseAsync = (_Err)=>async (schema, value, _ctx, params)=>{
|
|
825
|
+
const ctx = _ctx ? {
|
|
826
|
+
..._ctx,
|
|
827
|
+
async: true
|
|
828
|
+
} : {
|
|
829
|
+
async: true
|
|
830
|
+
};
|
|
831
|
+
let result = schema._zod.run({
|
|
832
|
+
value,
|
|
833
|
+
issues: []
|
|
834
|
+
}, ctx);
|
|
835
|
+
if (result instanceof Promise) result = await result;
|
|
836
|
+
if (result.issues.length) {
|
|
837
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())));
|
|
838
|
+
captureStackTrace(e, params?.callee);
|
|
839
|
+
throw e;
|
|
840
|
+
}
|
|
841
|
+
return result.value;
|
|
842
|
+
};
|
|
843
|
+
const _safeParse = (_Err)=>(schema, value, _ctx)=>{
|
|
844
|
+
const ctx = _ctx ? {
|
|
845
|
+
..._ctx,
|
|
846
|
+
async: false
|
|
847
|
+
} : {
|
|
848
|
+
async: false
|
|
849
|
+
};
|
|
850
|
+
const result = schema._zod.run({
|
|
851
|
+
value,
|
|
1520
852
|
issues: []
|
|
1521
|
-
},
|
|
1522
|
-
if (result instanceof Promise)
|
|
1523
|
-
|
|
853
|
+
}, ctx);
|
|
854
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
855
|
+
return result.issues.length ? {
|
|
856
|
+
success: false,
|
|
857
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
|
858
|
+
} : {
|
|
859
|
+
success: true,
|
|
860
|
+
data: result.value
|
|
861
|
+
};
|
|
1524
862
|
};
|
|
1525
|
-
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
863
|
+
const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
864
|
+
const _safeParseAsync = (_Err)=>async (schema, value, _ctx)=>{
|
|
865
|
+
const ctx = _ctx ? {
|
|
866
|
+
..._ctx,
|
|
867
|
+
async: true
|
|
868
|
+
} : {
|
|
869
|
+
async: true
|
|
870
|
+
};
|
|
871
|
+
let result = schema._zod.run({
|
|
872
|
+
value,
|
|
873
|
+
issues: []
|
|
874
|
+
}, ctx);
|
|
875
|
+
if (result instanceof Promise) result = await result;
|
|
876
|
+
return result.issues.length ? {
|
|
877
|
+
success: false,
|
|
878
|
+
error: new _Err(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
|
879
|
+
} : {
|
|
880
|
+
success: true,
|
|
881
|
+
data: result.value
|
|
882
|
+
};
|
|
1541
883
|
};
|
|
1542
|
-
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
884
|
+
const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
|
885
|
+
const _encode = (_Err)=>(schema, value, _ctx)=>{
|
|
886
|
+
const ctx = _ctx ? {
|
|
887
|
+
..._ctx,
|
|
888
|
+
direction: "backward"
|
|
889
|
+
} : {
|
|
890
|
+
direction: "backward"
|
|
891
|
+
};
|
|
892
|
+
return _parse(_Err)(schema, value, ctx);
|
|
1547
893
|
};
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
const content = this?.content ?? [
|
|
1580
|
-
""
|
|
1581
|
-
];
|
|
1582
|
-
const lines = [
|
|
1583
|
-
...content.map((x)=>` ${x}`)
|
|
1584
|
-
];
|
|
1585
|
-
return new F(...args, lines.join("\n"));
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
894
|
+
const _decode = (_Err)=>(schema, value, _ctx)=>_parse(_Err)(schema, value, _ctx);
|
|
895
|
+
const _encodeAsync = (_Err)=>async (schema, value, _ctx)=>{
|
|
896
|
+
const ctx = _ctx ? {
|
|
897
|
+
..._ctx,
|
|
898
|
+
direction: "backward"
|
|
899
|
+
} : {
|
|
900
|
+
direction: "backward"
|
|
901
|
+
};
|
|
902
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
903
|
+
};
|
|
904
|
+
const _decodeAsync = (_Err)=>async (schema, value, _ctx)=>_parseAsync(_Err)(schema, value, _ctx);
|
|
905
|
+
const _safeEncode = (_Err)=>(schema, value, _ctx)=>{
|
|
906
|
+
const ctx = _ctx ? {
|
|
907
|
+
..._ctx,
|
|
908
|
+
direction: "backward"
|
|
909
|
+
} : {
|
|
910
|
+
direction: "backward"
|
|
911
|
+
};
|
|
912
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
913
|
+
};
|
|
914
|
+
const _safeDecode = (_Err)=>(schema, value, _ctx)=>_safeParse(_Err)(schema, value, _ctx);
|
|
915
|
+
const _safeEncodeAsync = (_Err)=>async (schema, value, _ctx)=>{
|
|
916
|
+
const ctx = _ctx ? {
|
|
917
|
+
..._ctx,
|
|
918
|
+
direction: "backward"
|
|
919
|
+
} : {
|
|
920
|
+
direction: "backward"
|
|
921
|
+
};
|
|
922
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
923
|
+
};
|
|
924
|
+
const _safeDecodeAsync = (_Err)=>async (schema, value, _ctx)=>_safeParseAsync(_Err)(schema, value, _ctx);
|
|
1588
925
|
const versions_version = {
|
|
1589
926
|
major: 4,
|
|
1590
|
-
minor:
|
|
1591
|
-
patch:
|
|
927
|
+
minor: 4,
|
|
928
|
+
patch: 3
|
|
1592
929
|
};
|
|
1593
930
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def)=>{
|
|
1594
931
|
var _a;
|
|
@@ -1612,6 +949,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def)=>{
|
|
|
1612
949
|
let asyncResult;
|
|
1613
950
|
for (const ch of checks){
|
|
1614
951
|
if (ch._zod.def.when) {
|
|
952
|
+
if (explicitlyAborted(payload)) continue;
|
|
1615
953
|
const shouldRun = ch._zod.def.when(payload);
|
|
1616
954
|
if (!shouldRun) continue;
|
|
1617
955
|
} else if (isAborted) continue;
|
|
@@ -1741,6 +1079,16 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def)=>{
|
|
|
1741
1079
|
inst._zod.check = (payload)=>{
|
|
1742
1080
|
try {
|
|
1743
1081
|
const trimmed = payload.value.trim();
|
|
1082
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
1083
|
+
if (!/^https?:\/\//i.test(trimmed)) return void payload.issues.push({
|
|
1084
|
+
code: "invalid_format",
|
|
1085
|
+
format: "url",
|
|
1086
|
+
note: "Invalid URL format",
|
|
1087
|
+
input: payload.value,
|
|
1088
|
+
inst,
|
|
1089
|
+
continue: !def.abort
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1744
1092
|
const url = new URL(trimmed);
|
|
1745
1093
|
if (def.hostname) {
|
|
1746
1094
|
def.hostname.lastIndex = 0;
|
|
@@ -1847,11 +1195,6 @@ const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def)=>{
|
|
|
1847
1195
|
}
|
|
1848
1196
|
};
|
|
1849
1197
|
});
|
|
1850
|
-
const $ZodMAC = /*@__PURE__*/ $constructor("$ZodMAC", (inst, def)=>{
|
|
1851
|
-
def.pattern ?? (def.pattern = mac(def.delimiter));
|
|
1852
|
-
$ZodStringFormat.init(inst, def);
|
|
1853
|
-
inst._zod.bag.format = "mac";
|
|
1854
|
-
});
|
|
1855
1198
|
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def)=>{
|
|
1856
1199
|
def.pattern ?? (def.pattern = cidrv4);
|
|
1857
1200
|
$ZodStringFormat.init(inst, def);
|
|
@@ -1882,6 +1225,7 @@ const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def)=>{
|
|
|
1882
1225
|
});
|
|
1883
1226
|
function isValidBase64(data) {
|
|
1884
1227
|
if ("" === data) return true;
|
|
1228
|
+
if (/\s/.test(data)) return false;
|
|
1885
1229
|
if (data.length % 4 !== 0) return false;
|
|
1886
1230
|
try {
|
|
1887
1231
|
atob(data);
|
|
@@ -1931,156 +1275,44 @@ const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def)=>{
|
|
|
1931
1275
|
$ZodStringFormat.init(inst, def);
|
|
1932
1276
|
});
|
|
1933
1277
|
function isValidJWT(token, algorithm = null) {
|
|
1934
|
-
try {
|
|
1935
|
-
const tokensParts = token.split(".");
|
|
1936
|
-
if (3 !== tokensParts.length) return false;
|
|
1937
|
-
const [header] = tokensParts;
|
|
1938
|
-
if (!header) return false;
|
|
1939
|
-
const parsedHeader = JSON.parse(atob(header));
|
|
1940
|
-
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
1941
|
-
if (!parsedHeader.alg) return false;
|
|
1942
|
-
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
1943
|
-
return true;
|
|
1944
|
-
} catch {
|
|
1945
|
-
return false;
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def)=>{
|
|
1949
|
-
$ZodStringFormat.init(inst, def);
|
|
1950
|
-
inst._zod.check = (payload)=>{
|
|
1951
|
-
if (isValidJWT(payload.value, def.alg)) return;
|
|
1952
|
-
payload.issues.push({
|
|
1953
|
-
code: "invalid_format",
|
|
1954
|
-
format: "jwt",
|
|
1955
|
-
input: payload.value,
|
|
1956
|
-
inst,
|
|
1957
|
-
continue: !def.abort
|
|
1958
|
-
});
|
|
1959
|
-
};
|
|
1960
|
-
});
|
|
1961
|
-
const $ZodCustomStringFormat = /*@__PURE__*/ $constructor("$ZodCustomStringFormat", (inst, def)=>{
|
|
1962
|
-
$ZodStringFormat.init(inst, def);
|
|
1963
|
-
inst._zod.check = (payload)=>{
|
|
1964
|
-
if (def.fn(payload.value)) return;
|
|
1965
|
-
payload.issues.push({
|
|
1966
|
-
code: "invalid_format",
|
|
1967
|
-
format: def.format,
|
|
1968
|
-
input: payload.value,
|
|
1969
|
-
inst,
|
|
1970
|
-
continue: !def.abort
|
|
1971
|
-
});
|
|
1972
|
-
};
|
|
1973
|
-
});
|
|
1974
|
-
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def)=>{
|
|
1975
|
-
$ZodType.init(inst, def);
|
|
1976
|
-
inst._zod.pattern = inst._zod.bag.pattern ?? regexes_number;
|
|
1977
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
1978
|
-
if (def.coerce) try {
|
|
1979
|
-
payload.value = Number(payload.value);
|
|
1980
|
-
} catch (_) {}
|
|
1981
|
-
const input = payload.value;
|
|
1982
|
-
if ("number" == typeof input && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1983
|
-
const received = "number" == typeof input ? Number.isNaN(input) ? "NaN" : Number.isFinite(input) ? void 0 : "Infinity" : void 0;
|
|
1984
|
-
payload.issues.push({
|
|
1985
|
-
expected: "number",
|
|
1986
|
-
code: "invalid_type",
|
|
1987
|
-
input,
|
|
1988
|
-
inst,
|
|
1989
|
-
...received ? {
|
|
1990
|
-
received
|
|
1991
|
-
} : {}
|
|
1992
|
-
});
|
|
1993
|
-
return payload;
|
|
1994
|
-
};
|
|
1995
|
-
});
|
|
1996
|
-
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def)=>{
|
|
1997
|
-
$ZodCheckNumberFormat.init(inst, def);
|
|
1998
|
-
$ZodNumber.init(inst, def);
|
|
1999
|
-
});
|
|
2000
|
-
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def)=>{
|
|
2001
|
-
$ZodType.init(inst, def);
|
|
2002
|
-
inst._zod.pattern = regexes_boolean;
|
|
2003
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2004
|
-
if (def.coerce) try {
|
|
2005
|
-
payload.value = Boolean(payload.value);
|
|
2006
|
-
} catch (_) {}
|
|
2007
|
-
const input = payload.value;
|
|
2008
|
-
if ("boolean" == typeof input) return payload;
|
|
2009
|
-
payload.issues.push({
|
|
2010
|
-
expected: "boolean",
|
|
2011
|
-
code: "invalid_type",
|
|
2012
|
-
input,
|
|
2013
|
-
inst
|
|
2014
|
-
});
|
|
2015
|
-
return payload;
|
|
2016
|
-
};
|
|
2017
|
-
});
|
|
2018
|
-
const $ZodBigInt = /*@__PURE__*/ $constructor("$ZodBigInt", (inst, def)=>{
|
|
2019
|
-
$ZodType.init(inst, def);
|
|
2020
|
-
inst._zod.pattern = bigint;
|
|
2021
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2022
|
-
if (def.coerce) try {
|
|
2023
|
-
payload.value = BigInt(payload.value);
|
|
2024
|
-
} catch (_) {}
|
|
2025
|
-
if ("bigint" == typeof payload.value) return payload;
|
|
2026
|
-
payload.issues.push({
|
|
2027
|
-
expected: "bigint",
|
|
2028
|
-
code: "invalid_type",
|
|
2029
|
-
input: payload.value,
|
|
2030
|
-
inst
|
|
2031
|
-
});
|
|
2032
|
-
return payload;
|
|
2033
|
-
};
|
|
2034
|
-
});
|
|
2035
|
-
const $ZodBigIntFormat = /*@__PURE__*/ $constructor("$ZodBigIntFormat", (inst, def)=>{
|
|
2036
|
-
$ZodCheckBigIntFormat.init(inst, def);
|
|
2037
|
-
$ZodBigInt.init(inst, def);
|
|
2038
|
-
});
|
|
2039
|
-
const $ZodSymbol = /*@__PURE__*/ $constructor("$ZodSymbol", (inst, def)=>{
|
|
2040
|
-
$ZodType.init(inst, def);
|
|
2041
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2042
|
-
const input = payload.value;
|
|
2043
|
-
if ("symbol" == typeof input) return payload;
|
|
2044
|
-
payload.issues.push({
|
|
2045
|
-
expected: "symbol",
|
|
2046
|
-
code: "invalid_type",
|
|
2047
|
-
input,
|
|
2048
|
-
inst
|
|
2049
|
-
});
|
|
2050
|
-
return payload;
|
|
2051
|
-
};
|
|
2052
|
-
});
|
|
2053
|
-
const $ZodUndefined = /*@__PURE__*/ $constructor("$ZodUndefined", (inst, def)=>{
|
|
2054
|
-
$ZodType.init(inst, def);
|
|
2055
|
-
inst._zod.pattern = _undefined;
|
|
2056
|
-
inst._zod.values = new Set([
|
|
2057
|
-
void 0
|
|
2058
|
-
]);
|
|
2059
|
-
inst._zod.optin = "optional";
|
|
2060
|
-
inst._zod.optout = "optional";
|
|
2061
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2062
|
-
const input = payload.value;
|
|
2063
|
-
if (void 0 === input) return payload;
|
|
1278
|
+
try {
|
|
1279
|
+
const tokensParts = token.split(".");
|
|
1280
|
+
if (3 !== tokensParts.length) return false;
|
|
1281
|
+
const [header] = tokensParts;
|
|
1282
|
+
if (!header) return false;
|
|
1283
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
1284
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
1285
|
+
if (!parsedHeader.alg) return false;
|
|
1286
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
1287
|
+
return true;
|
|
1288
|
+
} catch {
|
|
1289
|
+
return false;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def)=>{
|
|
1293
|
+
$ZodStringFormat.init(inst, def);
|
|
1294
|
+
inst._zod.check = (payload)=>{
|
|
1295
|
+
if (isValidJWT(payload.value, def.alg)) return;
|
|
2064
1296
|
payload.issues.push({
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
input,
|
|
2068
|
-
inst
|
|
1297
|
+
code: "invalid_format",
|
|
1298
|
+
format: "jwt",
|
|
1299
|
+
input: payload.value,
|
|
1300
|
+
inst,
|
|
1301
|
+
continue: !def.abort
|
|
2069
1302
|
});
|
|
2070
|
-
return payload;
|
|
2071
1303
|
};
|
|
2072
1304
|
});
|
|
2073
|
-
const $
|
|
1305
|
+
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def)=>{
|
|
2074
1306
|
$ZodType.init(inst, def);
|
|
2075
|
-
inst._zod.pattern =
|
|
2076
|
-
inst._zod.values = new Set([
|
|
2077
|
-
null
|
|
2078
|
-
]);
|
|
1307
|
+
inst._zod.pattern = regexes_boolean;
|
|
2079
1308
|
inst._zod.parse = (payload, _ctx)=>{
|
|
1309
|
+
if (def.coerce) try {
|
|
1310
|
+
payload.value = Boolean(payload.value);
|
|
1311
|
+
} catch (_) {}
|
|
2080
1312
|
const input = payload.value;
|
|
2081
|
-
if (
|
|
1313
|
+
if ("boolean" == typeof input) return payload;
|
|
2082
1314
|
payload.issues.push({
|
|
2083
|
-
expected: "
|
|
1315
|
+
expected: "boolean",
|
|
2084
1316
|
code: "invalid_type",
|
|
2085
1317
|
input,
|
|
2086
1318
|
inst
|
|
@@ -2088,10 +1320,6 @@ const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def)=>{
|
|
|
2088
1320
|
return payload;
|
|
2089
1321
|
};
|
|
2090
1322
|
});
|
|
2091
|
-
const $ZodAny = /*@__PURE__*/ $constructor("$ZodAny", (inst, def)=>{
|
|
2092
|
-
$ZodType.init(inst, def);
|
|
2093
|
-
inst._zod.parse = (payload)=>payload;
|
|
2094
|
-
});
|
|
2095
1323
|
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def)=>{
|
|
2096
1324
|
$ZodType.init(inst, def);
|
|
2097
1325
|
inst._zod.parse = (payload)=>payload;
|
|
@@ -2108,42 +1336,6 @@ const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def)=>{
|
|
|
2108
1336
|
return payload;
|
|
2109
1337
|
};
|
|
2110
1338
|
});
|
|
2111
|
-
const $ZodVoid = /*@__PURE__*/ $constructor("$ZodVoid", (inst, def)=>{
|
|
2112
|
-
$ZodType.init(inst, def);
|
|
2113
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2114
|
-
const input = payload.value;
|
|
2115
|
-
if (void 0 === input) return payload;
|
|
2116
|
-
payload.issues.push({
|
|
2117
|
-
expected: "void",
|
|
2118
|
-
code: "invalid_type",
|
|
2119
|
-
input,
|
|
2120
|
-
inst
|
|
2121
|
-
});
|
|
2122
|
-
return payload;
|
|
2123
|
-
};
|
|
2124
|
-
});
|
|
2125
|
-
const $ZodDate = /*@__PURE__*/ $constructor("$ZodDate", (inst, def)=>{
|
|
2126
|
-
$ZodType.init(inst, def);
|
|
2127
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2128
|
-
if (def.coerce) try {
|
|
2129
|
-
payload.value = new Date(payload.value);
|
|
2130
|
-
} catch (_err) {}
|
|
2131
|
-
const input = payload.value;
|
|
2132
|
-
const isDate = input instanceof Date;
|
|
2133
|
-
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
|
2134
|
-
if (isValidDate) return payload;
|
|
2135
|
-
payload.issues.push({
|
|
2136
|
-
expected: "date",
|
|
2137
|
-
code: "invalid_type",
|
|
2138
|
-
input,
|
|
2139
|
-
...isDate ? {
|
|
2140
|
-
received: "Invalid Date"
|
|
2141
|
-
} : {},
|
|
2142
|
-
inst
|
|
2143
|
-
});
|
|
2144
|
-
return payload;
|
|
2145
|
-
};
|
|
2146
|
-
});
|
|
2147
1339
|
function handleArrayResult(result, final, index) {
|
|
2148
1340
|
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
2149
1341
|
final.value[index] = result.value;
|
|
@@ -2176,13 +1368,25 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def)=>{
|
|
|
2176
1368
|
return payload;
|
|
2177
1369
|
};
|
|
2178
1370
|
});
|
|
2179
|
-
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
1371
|
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
|
1372
|
+
const isPresent = key in input;
|
|
2180
1373
|
if (result.issues.length) {
|
|
2181
|
-
if (isOptionalOut && !
|
|
1374
|
+
if (isOptionalIn && isOptionalOut && !isPresent) return;
|
|
2182
1375
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
2183
1376
|
}
|
|
1377
|
+
if (!isPresent && !isOptionalIn) {
|
|
1378
|
+
if (!result.issues.length) final.issues.push({
|
|
1379
|
+
code: "invalid_type",
|
|
1380
|
+
expected: "nonoptional",
|
|
1381
|
+
input: void 0,
|
|
1382
|
+
path: [
|
|
1383
|
+
key
|
|
1384
|
+
]
|
|
1385
|
+
});
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
2184
1388
|
if (void 0 === result.value) {
|
|
2185
|
-
if (
|
|
1389
|
+
if (isPresent) final.value[key] = void 0;
|
|
2186
1390
|
} else final.value[key] = result.value;
|
|
2187
1391
|
}
|
|
2188
1392
|
function normalizeDef(def) {
|
|
@@ -2202,8 +1406,10 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2202
1406
|
const keySet = def.keySet;
|
|
2203
1407
|
const _catchall = def.catchall._zod;
|
|
2204
1408
|
const t = _catchall.def.type;
|
|
1409
|
+
const isOptionalIn = "optional" === _catchall.optin;
|
|
2205
1410
|
const isOptionalOut = "optional" === _catchall.optout;
|
|
2206
1411
|
for(const key in input){
|
|
1412
|
+
if ("__proto__" === key) continue;
|
|
2207
1413
|
if (keySet.has(key)) continue;
|
|
2208
1414
|
if ("never" === t) {
|
|
2209
1415
|
unrecognized.push(key);
|
|
@@ -2213,8 +1419,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2213
1419
|
value: input[key],
|
|
2214
1420
|
issues: []
|
|
2215
1421
|
}, ctx);
|
|
2216
|
-
if (r instanceof Promise) proms.push(r.then((r)=>handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
2217
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1422
|
+
if (r instanceof Promise) proms.push(r.then((r)=>handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1423
|
+
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
2218
1424
|
}
|
|
2219
1425
|
if (unrecognized.length) payload.issues.push({
|
|
2220
1426
|
code: "unrecognized_keys",
|
|
@@ -2275,13 +1481,14 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def)=>{
|
|
|
2275
1481
|
const shape = value.shape;
|
|
2276
1482
|
for (const key of value.keys){
|
|
2277
1483
|
const el = shape[key];
|
|
1484
|
+
const isOptionalIn = "optional" === el._zod.optin;
|
|
2278
1485
|
const isOptionalOut = "optional" === el._zod.optout;
|
|
2279
1486
|
const r = el._zod.run({
|
|
2280
1487
|
value: input[key],
|
|
2281
1488
|
issues: []
|
|
2282
1489
|
}, ctx);
|
|
2283
|
-
if (r instanceof Promise) proms.push(r.then((r)=>handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
2284
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
1490
|
+
if (r instanceof Promise) proms.push(r.then((r)=>handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1491
|
+
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
2285
1492
|
}
|
|
2286
1493
|
if (!catchall) return proms.length ? Promise.all(proms).then(()=>payload) : payload;
|
|
2287
1494
|
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
@@ -2311,9 +1518,10 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def)=>{
|
|
|
2311
1518
|
const id = ids[key];
|
|
2312
1519
|
const k = esc(key);
|
|
2313
1520
|
const schema = shape[key];
|
|
1521
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
2314
1522
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
2315
1523
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
2316
|
-
if (isOptionalOut) doc.write(`
|
|
1524
|
+
if (isOptionalIn && isOptionalOut) doc.write(`
|
|
2317
1525
|
if (${id}.issues.length) {
|
|
2318
1526
|
if (${k} in input) {
|
|
2319
1527
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
@@ -2332,7 +1540,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def)=>{
|
|
|
2332
1540
|
}
|
|
2333
1541
|
|
|
2334
1542
|
`);
|
|
2335
|
-
else doc.write(`
|
|
1543
|
+
else if (isOptionalIn) doc.write(`
|
|
2336
1544
|
if (${id}.issues.length) {
|
|
2337
1545
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2338
1546
|
...iss,
|
|
@@ -2348,6 +1556,32 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def)=>{
|
|
|
2348
1556
|
newResult[${k}] = ${id}.value;
|
|
2349
1557
|
}
|
|
2350
1558
|
|
|
1559
|
+
`);
|
|
1560
|
+
else doc.write(`
|
|
1561
|
+
const ${id}_present = ${k} in input;
|
|
1562
|
+
if (${id}.issues.length) {
|
|
1563
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1564
|
+
...iss,
|
|
1565
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1566
|
+
})));
|
|
1567
|
+
}
|
|
1568
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
1569
|
+
payload.issues.push({
|
|
1570
|
+
code: "invalid_type",
|
|
1571
|
+
expected: "nonoptional",
|
|
1572
|
+
input: undefined,
|
|
1573
|
+
path: [${k}]
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
if (${id}_present) {
|
|
1578
|
+
if (${id}.value === undefined) {
|
|
1579
|
+
newResult[${k}] = undefined;
|
|
1580
|
+
} else {
|
|
1581
|
+
newResult[${k}] = ${id}.value;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
2351
1585
|
`);
|
|
2352
1586
|
}
|
|
2353
1587
|
doc.write("payload.value = newResult;");
|
|
@@ -2414,10 +1648,9 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def)=>{
|
|
|
2414
1648
|
return new RegExp(`^(${patterns.map((p)=>cleanRegex(p.source)).join("|")})$`);
|
|
2415
1649
|
}
|
|
2416
1650
|
});
|
|
2417
|
-
const
|
|
2418
|
-
const first = def.options[0]._zod.run;
|
|
1651
|
+
const first = 1 === def.options.length ? def.options[0]._zod.run : null;
|
|
2419
1652
|
inst._zod.parse = (payload, ctx)=>{
|
|
2420
|
-
if (
|
|
1653
|
+
if (first) return first(payload, ctx);
|
|
2421
1654
|
let async = false;
|
|
2422
1655
|
const results = [];
|
|
2423
1656
|
for (const option of def.options){
|
|
@@ -2437,107 +1670,6 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def)=>{
|
|
|
2437
1670
|
return Promise.all(results).then((results)=>handleUnionResults(results, payload, inst, ctx));
|
|
2438
1671
|
};
|
|
2439
1672
|
});
|
|
2440
|
-
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
2441
|
-
const successes = results.filter((r)=>0 === r.issues.length);
|
|
2442
|
-
if (1 === successes.length) {
|
|
2443
|
-
final.value = successes[0].value;
|
|
2444
|
-
return final;
|
|
2445
|
-
}
|
|
2446
|
-
if (0 === successes.length) final.issues.push({
|
|
2447
|
-
code: "invalid_union",
|
|
2448
|
-
input: final.value,
|
|
2449
|
-
inst,
|
|
2450
|
-
errors: results.map((result)=>result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
|
2451
|
-
});
|
|
2452
|
-
else final.issues.push({
|
|
2453
|
-
code: "invalid_union",
|
|
2454
|
-
input: final.value,
|
|
2455
|
-
inst,
|
|
2456
|
-
errors: [],
|
|
2457
|
-
inclusive: false
|
|
2458
|
-
});
|
|
2459
|
-
return final;
|
|
2460
|
-
}
|
|
2461
|
-
const $ZodXor = /*@__PURE__*/ $constructor("$ZodXor", (inst, def)=>{
|
|
2462
|
-
$ZodUnion.init(inst, def);
|
|
2463
|
-
def.inclusive = false;
|
|
2464
|
-
const single = 1 === def.options.length;
|
|
2465
|
-
const first = def.options[0]._zod.run;
|
|
2466
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
2467
|
-
if (single) return first(payload, ctx);
|
|
2468
|
-
let async = false;
|
|
2469
|
-
const results = [];
|
|
2470
|
-
for (const option of def.options){
|
|
2471
|
-
const result = option._zod.run({
|
|
2472
|
-
value: payload.value,
|
|
2473
|
-
issues: []
|
|
2474
|
-
}, ctx);
|
|
2475
|
-
if (result instanceof Promise) {
|
|
2476
|
-
results.push(result);
|
|
2477
|
-
async = true;
|
|
2478
|
-
} else results.push(result);
|
|
2479
|
-
}
|
|
2480
|
-
if (!async) return handleExclusiveUnionResults(results, payload, inst, ctx);
|
|
2481
|
-
return Promise.all(results).then((results)=>handleExclusiveUnionResults(results, payload, inst, ctx));
|
|
2482
|
-
};
|
|
2483
|
-
});
|
|
2484
|
-
const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def)=>{
|
|
2485
|
-
def.inclusive = false;
|
|
2486
|
-
$ZodUnion.init(inst, def);
|
|
2487
|
-
const _super = inst._zod.parse;
|
|
2488
|
-
defineLazy(inst._zod, "propValues", ()=>{
|
|
2489
|
-
const propValues = {};
|
|
2490
|
-
for (const option of def.options){
|
|
2491
|
-
const pv = option._zod.propValues;
|
|
2492
|
-
if (!pv || 0 === Object.keys(pv).length) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2493
|
-
for (const [k, v] of Object.entries(pv)){
|
|
2494
|
-
if (!propValues[k]) propValues[k] = new Set();
|
|
2495
|
-
for (const val of v)propValues[k].add(val);
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
return propValues;
|
|
2499
|
-
});
|
|
2500
|
-
const disc = cached(()=>{
|
|
2501
|
-
const opts = def.options;
|
|
2502
|
-
const map = new Map();
|
|
2503
|
-
for (const o of opts){
|
|
2504
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
2505
|
-
if (!values || 0 === values.size) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
2506
|
-
for (const v of values){
|
|
2507
|
-
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
2508
|
-
map.set(v, o);
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
return map;
|
|
2512
|
-
});
|
|
2513
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
2514
|
-
const input = payload.value;
|
|
2515
|
-
if (!util_isObject(input)) {
|
|
2516
|
-
payload.issues.push({
|
|
2517
|
-
code: "invalid_type",
|
|
2518
|
-
expected: "object",
|
|
2519
|
-
input,
|
|
2520
|
-
inst
|
|
2521
|
-
});
|
|
2522
|
-
return payload;
|
|
2523
|
-
}
|
|
2524
|
-
const opt = disc.value.get(input?.[def.discriminator]);
|
|
2525
|
-
if (opt) return opt._zod.run(payload, ctx);
|
|
2526
|
-
if (def.unionFallback) return _super(payload, ctx);
|
|
2527
|
-
payload.issues.push({
|
|
2528
|
-
code: "invalid_union",
|
|
2529
|
-
errors: [],
|
|
2530
|
-
note: "No matching discriminator",
|
|
2531
|
-
discriminator: def.discriminator,
|
|
2532
|
-
input,
|
|
2533
|
-
path: [
|
|
2534
|
-
def.discriminator
|
|
2535
|
-
],
|
|
2536
|
-
inst
|
|
2537
|
-
});
|
|
2538
|
-
return payload;
|
|
2539
|
-
};
|
|
2540
|
-
});
|
|
2541
1673
|
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def)=>{
|
|
2542
1674
|
$ZodType.init(inst, def);
|
|
2543
1675
|
inst._zod.parse = (payload, ctx)=>{
|
|
@@ -2638,268 +1770,14 @@ function handleIntersectionResults(result, left, right) {
|
|
|
2638
1770
|
...unrecKeys
|
|
2639
1771
|
].filter(([, f])=>f.l && f.r).map(([k])=>k);
|
|
2640
1772
|
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
2641
|
-
...unrecIssue,
|
|
2642
|
-
keys: bothKeys
|
|
2643
|
-
});
|
|
2644
|
-
if (aborted(result)) return result;
|
|
2645
|
-
const merged = mergeValues(left.value, right.value);
|
|
2646
|
-
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2647
|
-
result.value = merged.data;
|
|
2648
|
-
return result;
|
|
2649
|
-
}
|
|
2650
|
-
const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def)=>{
|
|
2651
|
-
$ZodType.init(inst, def);
|
|
2652
|
-
const items = def.items;
|
|
2653
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
2654
|
-
const input = payload.value;
|
|
2655
|
-
if (!Array.isArray(input)) {
|
|
2656
|
-
payload.issues.push({
|
|
2657
|
-
input,
|
|
2658
|
-
inst,
|
|
2659
|
-
expected: "tuple",
|
|
2660
|
-
code: "invalid_type"
|
|
2661
|
-
});
|
|
2662
|
-
return payload;
|
|
2663
|
-
}
|
|
2664
|
-
payload.value = [];
|
|
2665
|
-
const proms = [];
|
|
2666
|
-
const reversedIndex = [
|
|
2667
|
-
...items
|
|
2668
|
-
].reverse().findIndex((item)=>"optional" !== item._zod.optin);
|
|
2669
|
-
const optStart = -1 === reversedIndex ? 0 : items.length - reversedIndex;
|
|
2670
|
-
if (!def.rest) {
|
|
2671
|
-
const tooBig = input.length > items.length;
|
|
2672
|
-
const tooSmall = input.length < optStart - 1;
|
|
2673
|
-
if (tooBig || tooSmall) {
|
|
2674
|
-
payload.issues.push({
|
|
2675
|
-
...tooBig ? {
|
|
2676
|
-
code: "too_big",
|
|
2677
|
-
maximum: items.length,
|
|
2678
|
-
inclusive: true
|
|
2679
|
-
} : {
|
|
2680
|
-
code: "too_small",
|
|
2681
|
-
minimum: items.length
|
|
2682
|
-
},
|
|
2683
|
-
input,
|
|
2684
|
-
inst,
|
|
2685
|
-
origin: "array"
|
|
2686
|
-
});
|
|
2687
|
-
return payload;
|
|
2688
|
-
}
|
|
2689
|
-
}
|
|
2690
|
-
let i = -1;
|
|
2691
|
-
for (const item of items){
|
|
2692
|
-
i++;
|
|
2693
|
-
if (i >= input.length) {
|
|
2694
|
-
if (i >= optStart) continue;
|
|
2695
|
-
}
|
|
2696
|
-
const result = item._zod.run({
|
|
2697
|
-
value: input[i],
|
|
2698
|
-
issues: []
|
|
2699
|
-
}, ctx);
|
|
2700
|
-
if (result instanceof Promise) proms.push(result.then((result)=>handleTupleResult(result, payload, i)));
|
|
2701
|
-
else handleTupleResult(result, payload, i);
|
|
2702
|
-
}
|
|
2703
|
-
if (def.rest) {
|
|
2704
|
-
const rest = input.slice(items.length);
|
|
2705
|
-
for (const el of rest){
|
|
2706
|
-
i++;
|
|
2707
|
-
const result = def.rest._zod.run({
|
|
2708
|
-
value: el,
|
|
2709
|
-
issues: []
|
|
2710
|
-
}, ctx);
|
|
2711
|
-
if (result instanceof Promise) proms.push(result.then((result)=>handleTupleResult(result, payload, i)));
|
|
2712
|
-
else handleTupleResult(result, payload, i);
|
|
2713
|
-
}
|
|
2714
|
-
}
|
|
2715
|
-
if (proms.length) return Promise.all(proms).then(()=>payload);
|
|
2716
|
-
return payload;
|
|
2717
|
-
};
|
|
2718
|
-
});
|
|
2719
|
-
function handleTupleResult(result, final, index) {
|
|
2720
|
-
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
2721
|
-
final.value[index] = result.value;
|
|
2722
|
-
}
|
|
2723
|
-
const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def)=>{
|
|
2724
|
-
$ZodType.init(inst, def);
|
|
2725
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
2726
|
-
const input = payload.value;
|
|
2727
|
-
if (!isPlainObject(input)) {
|
|
2728
|
-
payload.issues.push({
|
|
2729
|
-
expected: "record",
|
|
2730
|
-
code: "invalid_type",
|
|
2731
|
-
input,
|
|
2732
|
-
inst
|
|
2733
|
-
});
|
|
2734
|
-
return payload;
|
|
2735
|
-
}
|
|
2736
|
-
const proms = [];
|
|
2737
|
-
const values = def.keyType._zod.values;
|
|
2738
|
-
if (values) {
|
|
2739
|
-
payload.value = {};
|
|
2740
|
-
const recordKeys = new Set();
|
|
2741
|
-
for (const key of values)if ("string" == typeof key || "number" == typeof key || "symbol" == typeof key) {
|
|
2742
|
-
recordKeys.add("number" == typeof key ? key.toString() : key);
|
|
2743
|
-
const result = def.valueType._zod.run({
|
|
2744
|
-
value: input[key],
|
|
2745
|
-
issues: []
|
|
2746
|
-
}, ctx);
|
|
2747
|
-
if (result instanceof Promise) proms.push(result.then((result)=>{
|
|
2748
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
2749
|
-
payload.value[key] = result.value;
|
|
2750
|
-
}));
|
|
2751
|
-
else {
|
|
2752
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
2753
|
-
payload.value[key] = result.value;
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
let unrecognized;
|
|
2757
|
-
for(const key in input)if (!recordKeys.has(key)) {
|
|
2758
|
-
unrecognized = unrecognized ?? [];
|
|
2759
|
-
unrecognized.push(key);
|
|
2760
|
-
}
|
|
2761
|
-
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
|
2762
|
-
code: "unrecognized_keys",
|
|
2763
|
-
input,
|
|
2764
|
-
inst,
|
|
2765
|
-
keys: unrecognized
|
|
2766
|
-
});
|
|
2767
|
-
} else {
|
|
2768
|
-
payload.value = {};
|
|
2769
|
-
for (const key of Reflect.ownKeys(input)){
|
|
2770
|
-
if ("__proto__" === key) continue;
|
|
2771
|
-
let keyResult = def.keyType._zod.run({
|
|
2772
|
-
value: key,
|
|
2773
|
-
issues: []
|
|
2774
|
-
}, ctx);
|
|
2775
|
-
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
2776
|
-
const checkNumericKey = "string" == typeof key && regexes_number.test(key) && keyResult.issues.length;
|
|
2777
|
-
if (checkNumericKey) {
|
|
2778
|
-
const retryResult = def.keyType._zod.run({
|
|
2779
|
-
value: Number(key),
|
|
2780
|
-
issues: []
|
|
2781
|
-
}, ctx);
|
|
2782
|
-
if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
2783
|
-
if (0 === retryResult.issues.length) keyResult = retryResult;
|
|
2784
|
-
}
|
|
2785
|
-
if (keyResult.issues.length) {
|
|
2786
|
-
if ("loose" === def.mode) payload.value[key] = input[key];
|
|
2787
|
-
else payload.issues.push({
|
|
2788
|
-
code: "invalid_key",
|
|
2789
|
-
origin: "record",
|
|
2790
|
-
issues: keyResult.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())),
|
|
2791
|
-
input: key,
|
|
2792
|
-
path: [
|
|
2793
|
-
key
|
|
2794
|
-
],
|
|
2795
|
-
inst
|
|
2796
|
-
});
|
|
2797
|
-
continue;
|
|
2798
|
-
}
|
|
2799
|
-
const result = def.valueType._zod.run({
|
|
2800
|
-
value: input[key],
|
|
2801
|
-
issues: []
|
|
2802
|
-
}, ctx);
|
|
2803
|
-
if (result instanceof Promise) proms.push(result.then((result)=>{
|
|
2804
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
2805
|
-
payload.value[keyResult.value] = result.value;
|
|
2806
|
-
}));
|
|
2807
|
-
else {
|
|
2808
|
-
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
2809
|
-
payload.value[keyResult.value] = result.value;
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
if (proms.length) return Promise.all(proms).then(()=>payload);
|
|
2814
|
-
return payload;
|
|
2815
|
-
};
|
|
2816
|
-
});
|
|
2817
|
-
const $ZodMap = /*@__PURE__*/ $constructor("$ZodMap", (inst, def)=>{
|
|
2818
|
-
$ZodType.init(inst, def);
|
|
2819
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
2820
|
-
const input = payload.value;
|
|
2821
|
-
if (!(input instanceof Map)) {
|
|
2822
|
-
payload.issues.push({
|
|
2823
|
-
expected: "map",
|
|
2824
|
-
code: "invalid_type",
|
|
2825
|
-
input,
|
|
2826
|
-
inst
|
|
2827
|
-
});
|
|
2828
|
-
return payload;
|
|
2829
|
-
}
|
|
2830
|
-
const proms = [];
|
|
2831
|
-
payload.value = new Map();
|
|
2832
|
-
for (const [key, value] of input){
|
|
2833
|
-
const keyResult = def.keyType._zod.run({
|
|
2834
|
-
value: key,
|
|
2835
|
-
issues: []
|
|
2836
|
-
}, ctx);
|
|
2837
|
-
const valueResult = def.valueType._zod.run({
|
|
2838
|
-
value: value,
|
|
2839
|
-
issues: []
|
|
2840
|
-
}, ctx);
|
|
2841
|
-
if (keyResult instanceof Promise || valueResult instanceof Promise) proms.push(Promise.all([
|
|
2842
|
-
keyResult,
|
|
2843
|
-
valueResult
|
|
2844
|
-
]).then(([keyResult, valueResult])=>{
|
|
2845
|
-
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
|
2846
|
-
}));
|
|
2847
|
-
else handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
|
2848
|
-
}
|
|
2849
|
-
if (proms.length) return Promise.all(proms).then(()=>payload);
|
|
2850
|
-
return payload;
|
|
2851
|
-
};
|
|
2852
|
-
});
|
|
2853
|
-
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
2854
|
-
if (keyResult.issues.length) if (propertyKeyTypes.has(typeof key)) final.issues.push(...prefixIssues(key, keyResult.issues));
|
|
2855
|
-
else final.issues.push({
|
|
2856
|
-
code: "invalid_key",
|
|
2857
|
-
origin: "map",
|
|
2858
|
-
input,
|
|
2859
|
-
inst,
|
|
2860
|
-
issues: keyResult.issues.map((iss)=>finalizeIssue(iss, ctx, core_config()))
|
|
2861
|
-
});
|
|
2862
|
-
if (valueResult.issues.length) if (propertyKeyTypes.has(typeof key)) final.issues.push(...prefixIssues(key, valueResult.issues));
|
|
2863
|
-
else final.issues.push({
|
|
2864
|
-
origin: "map",
|
|
2865
|
-
code: "invalid_element",
|
|
2866
|
-
input,
|
|
2867
|
-
inst,
|
|
2868
|
-
key: key,
|
|
2869
|
-
issues: valueResult.issues.map((iss)=>finalizeIssue(iss, ctx, core_config()))
|
|
2870
|
-
});
|
|
2871
|
-
final.value.set(keyResult.value, valueResult.value);
|
|
2872
|
-
}
|
|
2873
|
-
const $ZodSet = /*@__PURE__*/ $constructor("$ZodSet", (inst, def)=>{
|
|
2874
|
-
$ZodType.init(inst, def);
|
|
2875
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
2876
|
-
const input = payload.value;
|
|
2877
|
-
if (!(input instanceof Set)) {
|
|
2878
|
-
payload.issues.push({
|
|
2879
|
-
input,
|
|
2880
|
-
inst,
|
|
2881
|
-
expected: "set",
|
|
2882
|
-
code: "invalid_type"
|
|
2883
|
-
});
|
|
2884
|
-
return payload;
|
|
2885
|
-
}
|
|
2886
|
-
const proms = [];
|
|
2887
|
-
payload.value = new Set();
|
|
2888
|
-
for (const item of input){
|
|
2889
|
-
const result = def.valueType._zod.run({
|
|
2890
|
-
value: item,
|
|
2891
|
-
issues: []
|
|
2892
|
-
}, ctx);
|
|
2893
|
-
if (result instanceof Promise) proms.push(result.then((result)=>handleSetResult(result, payload)));
|
|
2894
|
-
else handleSetResult(result, payload);
|
|
2895
|
-
}
|
|
2896
|
-
if (proms.length) return Promise.all(proms).then(()=>payload);
|
|
2897
|
-
return payload;
|
|
2898
|
-
};
|
|
2899
|
-
});
|
|
2900
|
-
function handleSetResult(result, final) {
|
|
2901
|
-
if (result.issues.length) final.issues.push(...result.issues);
|
|
2902
|
-
final.value.add(result.value);
|
|
1773
|
+
...unrecIssue,
|
|
1774
|
+
keys: bothKeys
|
|
1775
|
+
});
|
|
1776
|
+
if (aborted(result)) return result;
|
|
1777
|
+
const merged = mergeValues(left.value, right.value);
|
|
1778
|
+
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1779
|
+
result.value = merged.data;
|
|
1780
|
+
return result;
|
|
2903
1781
|
}
|
|
2904
1782
|
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def)=>{
|
|
2905
1783
|
$ZodType.init(inst, def);
|
|
@@ -2919,40 +1797,9 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def)=>{
|
|
|
2919
1797
|
return payload;
|
|
2920
1798
|
};
|
|
2921
1799
|
});
|
|
2922
|
-
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def)=>{
|
|
2923
|
-
$ZodType.init(inst, def);
|
|
2924
|
-
if (0 === def.values.length) throw new Error("Cannot create literal schema with no valid values");
|
|
2925
|
-
const values = new Set(def.values);
|
|
2926
|
-
inst._zod.values = values;
|
|
2927
|
-
inst._zod.pattern = new RegExp(`^(${def.values.map((o)=>"string" == typeof o ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
2928
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2929
|
-
const input = payload.value;
|
|
2930
|
-
if (values.has(input)) return payload;
|
|
2931
|
-
payload.issues.push({
|
|
2932
|
-
code: "invalid_value",
|
|
2933
|
-
values: def.values,
|
|
2934
|
-
input,
|
|
2935
|
-
inst
|
|
2936
|
-
});
|
|
2937
|
-
return payload;
|
|
2938
|
-
};
|
|
2939
|
-
});
|
|
2940
|
-
const $ZodFile = /*@__PURE__*/ $constructor("$ZodFile", (inst, def)=>{
|
|
2941
|
-
$ZodType.init(inst, def);
|
|
2942
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
2943
|
-
const input = payload.value;
|
|
2944
|
-
if (input instanceof File) return payload;
|
|
2945
|
-
payload.issues.push({
|
|
2946
|
-
expected: "file",
|
|
2947
|
-
code: "invalid_type",
|
|
2948
|
-
input,
|
|
2949
|
-
inst
|
|
2950
|
-
});
|
|
2951
|
-
return payload;
|
|
2952
|
-
};
|
|
2953
|
-
});
|
|
2954
1800
|
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def)=>{
|
|
2955
1801
|
$ZodType.init(inst, def);
|
|
1802
|
+
inst._zod.optin = "optional";
|
|
2956
1803
|
inst._zod.parse = (payload, ctx)=>{
|
|
2957
1804
|
if ("backward" === ctx.direction) throw new $ZodEncodeError(inst.constructor.name);
|
|
2958
1805
|
const _out = def.transform(payload.value, payload);
|
|
@@ -2960,16 +1807,18 @@ const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def)=>{
|
|
|
2960
1807
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
2961
1808
|
return output.then((output)=>{
|
|
2962
1809
|
payload.value = output;
|
|
1810
|
+
payload.fallback = true;
|
|
2963
1811
|
return payload;
|
|
2964
1812
|
});
|
|
2965
1813
|
}
|
|
2966
1814
|
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
2967
1815
|
payload.value = _out;
|
|
1816
|
+
payload.fallback = true;
|
|
2968
1817
|
return payload;
|
|
2969
1818
|
};
|
|
2970
1819
|
});
|
|
2971
1820
|
function handleOptionalResult(result, input) {
|
|
2972
|
-
if (result.issues.length
|
|
1821
|
+
if (void 0 === input && (result.issues.length || result.fallback)) return {
|
|
2973
1822
|
issues: [],
|
|
2974
1823
|
value: void 0
|
|
2975
1824
|
};
|
|
@@ -2989,9 +1838,10 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def)=>{
|
|
|
2989
1838
|
});
|
|
2990
1839
|
inst._zod.parse = (payload, ctx)=>{
|
|
2991
1840
|
if ("optional" === def.innerType._zod.optin) {
|
|
1841
|
+
const input = payload.value;
|
|
2992
1842
|
const result = def.innerType._zod.run(payload, ctx);
|
|
2993
|
-
if (result instanceof Promise) return result.then((r)=>handleOptionalResult(r,
|
|
2994
|
-
return handleOptionalResult(result,
|
|
1843
|
+
if (result instanceof Promise) return result.then((r)=>handleOptionalResult(r, input));
|
|
1844
|
+
return handleOptionalResult(result, input);
|
|
2995
1845
|
}
|
|
2996
1846
|
if (void 0 === payload.value) return payload;
|
|
2997
1847
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -3072,22 +1922,9 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
3072
1922
|
});
|
|
3073
1923
|
return payload;
|
|
3074
1924
|
}
|
|
3075
|
-
const $ZodSuccess = /*@__PURE__*/ $constructor("$ZodSuccess", (inst, def)=>{
|
|
3076
|
-
$ZodType.init(inst, def);
|
|
3077
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
3078
|
-
if ("backward" === ctx.direction) throw new $ZodEncodeError("ZodSuccess");
|
|
3079
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
3080
|
-
if (result instanceof Promise) return result.then((result)=>{
|
|
3081
|
-
payload.value = 0 === result.issues.length;
|
|
3082
|
-
return payload;
|
|
3083
|
-
});
|
|
3084
|
-
payload.value = 0 === result.issues.length;
|
|
3085
|
-
return payload;
|
|
3086
|
-
};
|
|
3087
|
-
});
|
|
3088
1925
|
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def)=>{
|
|
3089
1926
|
$ZodType.init(inst, def);
|
|
3090
|
-
|
|
1927
|
+
inst._zod.optin = "optional";
|
|
3091
1928
|
defineLazy(inst._zod, "optout", ()=>def.innerType._zod.optout);
|
|
3092
1929
|
defineLazy(inst._zod, "values", ()=>def.innerType._zod.values);
|
|
3093
1930
|
inst._zod.parse = (payload, ctx)=>{
|
|
@@ -3104,6 +1941,7 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def)=>{
|
|
|
3104
1941
|
input: payload.value
|
|
3105
1942
|
});
|
|
3106
1943
|
payload.issues = [];
|
|
1944
|
+
payload.fallback = true;
|
|
3107
1945
|
}
|
|
3108
1946
|
return payload;
|
|
3109
1947
|
});
|
|
@@ -3117,22 +1955,11 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def)=>{
|
|
|
3117
1955
|
input: payload.value
|
|
3118
1956
|
});
|
|
3119
1957
|
payload.issues = [];
|
|
1958
|
+
payload.fallback = true;
|
|
3120
1959
|
}
|
|
3121
1960
|
return payload;
|
|
3122
1961
|
};
|
|
3123
1962
|
});
|
|
3124
|
-
const $ZodNaN = /*@__PURE__*/ $constructor("$ZodNaN", (inst, def)=>{
|
|
3125
|
-
$ZodType.init(inst, def);
|
|
3126
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
3127
|
-
if ("number" != typeof payload.value || !Number.isNaN(payload.value)) payload.issues.push({
|
|
3128
|
-
input: payload.value,
|
|
3129
|
-
inst,
|
|
3130
|
-
expected: "nan",
|
|
3131
|
-
code: "invalid_type"
|
|
3132
|
-
});
|
|
3133
|
-
return payload;
|
|
3134
|
-
};
|
|
3135
|
-
});
|
|
3136
1963
|
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def)=>{
|
|
3137
1964
|
$ZodType.init(inst, def);
|
|
3138
1965
|
defineLazy(inst._zod, "values", ()=>def.in._zod.values);
|
|
@@ -3157,54 +1984,8 @@ function handlePipeResult(left, next, ctx) {
|
|
|
3157
1984
|
}
|
|
3158
1985
|
return next._zod.run({
|
|
3159
1986
|
value: left.value,
|
|
3160
|
-
issues: left.issues
|
|
3161
|
-
|
|
3162
|
-
}
|
|
3163
|
-
const $ZodCodec = /*@__PURE__*/ $constructor("$ZodCodec", (inst, def)=>{
|
|
3164
|
-
$ZodType.init(inst, def);
|
|
3165
|
-
defineLazy(inst._zod, "values", ()=>def.in._zod.values);
|
|
3166
|
-
defineLazy(inst._zod, "optin", ()=>def.in._zod.optin);
|
|
3167
|
-
defineLazy(inst._zod, "optout", ()=>def.out._zod.optout);
|
|
3168
|
-
defineLazy(inst._zod, "propValues", ()=>def.in._zod.propValues);
|
|
3169
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
3170
|
-
const direction = ctx.direction || "forward";
|
|
3171
|
-
if ("forward" === direction) {
|
|
3172
|
-
const left = def.in._zod.run(payload, ctx);
|
|
3173
|
-
if (left instanceof Promise) return left.then((left)=>handleCodecAResult(left, def, ctx));
|
|
3174
|
-
return handleCodecAResult(left, def, ctx);
|
|
3175
|
-
}
|
|
3176
|
-
{
|
|
3177
|
-
const right = def.out._zod.run(payload, ctx);
|
|
3178
|
-
if (right instanceof Promise) return right.then((right)=>handleCodecAResult(right, def, ctx));
|
|
3179
|
-
return handleCodecAResult(right, def, ctx);
|
|
3180
|
-
}
|
|
3181
|
-
};
|
|
3182
|
-
});
|
|
3183
|
-
function handleCodecAResult(result, def, ctx) {
|
|
3184
|
-
if (result.issues.length) {
|
|
3185
|
-
result.aborted = true;
|
|
3186
|
-
return result;
|
|
3187
|
-
}
|
|
3188
|
-
const direction = ctx.direction || "forward";
|
|
3189
|
-
if ("forward" === direction) {
|
|
3190
|
-
const transformed = def.transform(result.value, result);
|
|
3191
|
-
if (transformed instanceof Promise) return transformed.then((value)=>handleCodecTxResult(result, value, def.out, ctx));
|
|
3192
|
-
return handleCodecTxResult(result, transformed, def.out, ctx);
|
|
3193
|
-
}
|
|
3194
|
-
{
|
|
3195
|
-
const transformed = def.reverseTransform(result.value, result);
|
|
3196
|
-
if (transformed instanceof Promise) return transformed.then((value)=>handleCodecTxResult(result, value, def.in, ctx));
|
|
3197
|
-
return handleCodecTxResult(result, transformed, def.in, ctx);
|
|
3198
|
-
}
|
|
3199
|
-
}
|
|
3200
|
-
function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
3201
|
-
if (left.issues.length) {
|
|
3202
|
-
left.aborted = true;
|
|
3203
|
-
return left;
|
|
3204
|
-
}
|
|
3205
|
-
return nextSchema._zod.run({
|
|
3206
|
-
value,
|
|
3207
|
-
issues: left.issues
|
|
1987
|
+
issues: left.issues,
|
|
1988
|
+
fallback: left.fallback
|
|
3208
1989
|
}, ctx);
|
|
3209
1990
|
}
|
|
3210
1991
|
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def)=>{
|
|
@@ -3224,125 +2005,6 @@ function handleReadonlyResult(payload) {
|
|
|
3224
2005
|
payload.value = Object.freeze(payload.value);
|
|
3225
2006
|
return payload;
|
|
3226
2007
|
}
|
|
3227
|
-
const $ZodTemplateLiteral = /*@__PURE__*/ $constructor("$ZodTemplateLiteral", (inst, def)=>{
|
|
3228
|
-
$ZodType.init(inst, def);
|
|
3229
|
-
const regexParts = [];
|
|
3230
|
-
for (const part of def.parts)if ("object" == typeof part && null !== part) {
|
|
3231
|
-
if (!part._zod.pattern) throw new Error(`Invalid template literal part, no pattern found: ${[
|
|
3232
|
-
...part._zod.traits
|
|
3233
|
-
].shift()}`);
|
|
3234
|
-
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
|
3235
|
-
if (!source) throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
3236
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
3237
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
3238
|
-
regexParts.push(source.slice(start, end));
|
|
3239
|
-
} else if (null === part || primitiveTypes.has(typeof part)) regexParts.push(escapeRegex(`${part}`));
|
|
3240
|
-
else throw new Error(`Invalid template literal part: ${part}`);
|
|
3241
|
-
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
|
|
3242
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
3243
|
-
if ("string" != typeof payload.value) {
|
|
3244
|
-
payload.issues.push({
|
|
3245
|
-
input: payload.value,
|
|
3246
|
-
inst,
|
|
3247
|
-
expected: "string",
|
|
3248
|
-
code: "invalid_type"
|
|
3249
|
-
});
|
|
3250
|
-
return payload;
|
|
3251
|
-
}
|
|
3252
|
-
inst._zod.pattern.lastIndex = 0;
|
|
3253
|
-
if (!inst._zod.pattern.test(payload.value)) payload.issues.push({
|
|
3254
|
-
input: payload.value,
|
|
3255
|
-
inst,
|
|
3256
|
-
code: "invalid_format",
|
|
3257
|
-
format: def.format ?? "template_literal",
|
|
3258
|
-
pattern: inst._zod.pattern.source
|
|
3259
|
-
});
|
|
3260
|
-
return payload;
|
|
3261
|
-
};
|
|
3262
|
-
});
|
|
3263
|
-
const $ZodFunction = /*@__PURE__*/ $constructor("$ZodFunction", (inst, def)=>{
|
|
3264
|
-
$ZodType.init(inst, def);
|
|
3265
|
-
inst._def = def;
|
|
3266
|
-
inst._zod.def = def;
|
|
3267
|
-
inst.implement = (func)=>{
|
|
3268
|
-
if ("function" != typeof func) throw new Error("implement() must be called with a function");
|
|
3269
|
-
return function(...args) {
|
|
3270
|
-
const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
|
|
3271
|
-
const result = Reflect.apply(func, this, parsedArgs);
|
|
3272
|
-
if (inst._def.output) return parse(inst._def.output, result);
|
|
3273
|
-
return result;
|
|
3274
|
-
};
|
|
3275
|
-
};
|
|
3276
|
-
inst.implementAsync = (func)=>{
|
|
3277
|
-
if ("function" != typeof func) throw new Error("implementAsync() must be called with a function");
|
|
3278
|
-
return async function(...args) {
|
|
3279
|
-
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
|
|
3280
|
-
const result = await Reflect.apply(func, this, parsedArgs);
|
|
3281
|
-
if (inst._def.output) return await parseAsync(inst._def.output, result);
|
|
3282
|
-
return result;
|
|
3283
|
-
};
|
|
3284
|
-
};
|
|
3285
|
-
inst._zod.parse = (payload, _ctx)=>{
|
|
3286
|
-
if ("function" != typeof payload.value) {
|
|
3287
|
-
payload.issues.push({
|
|
3288
|
-
code: "invalid_type",
|
|
3289
|
-
expected: "function",
|
|
3290
|
-
input: payload.value,
|
|
3291
|
-
inst
|
|
3292
|
-
});
|
|
3293
|
-
return payload;
|
|
3294
|
-
}
|
|
3295
|
-
const hasPromiseOutput = inst._def.output && "promise" === inst._def.output._zod.def.type;
|
|
3296
|
-
if (hasPromiseOutput) payload.value = inst.implementAsync(payload.value);
|
|
3297
|
-
else payload.value = inst.implement(payload.value);
|
|
3298
|
-
return payload;
|
|
3299
|
-
};
|
|
3300
|
-
inst.input = (...args)=>{
|
|
3301
|
-
const F = inst.constructor;
|
|
3302
|
-
if (Array.isArray(args[0])) return new F({
|
|
3303
|
-
type: "function",
|
|
3304
|
-
input: new $ZodTuple({
|
|
3305
|
-
type: "tuple",
|
|
3306
|
-
items: args[0],
|
|
3307
|
-
rest: args[1]
|
|
3308
|
-
}),
|
|
3309
|
-
output: inst._def.output
|
|
3310
|
-
});
|
|
3311
|
-
return new F({
|
|
3312
|
-
type: "function",
|
|
3313
|
-
input: args[0],
|
|
3314
|
-
output: inst._def.output
|
|
3315
|
-
});
|
|
3316
|
-
};
|
|
3317
|
-
inst.output = (output)=>{
|
|
3318
|
-
const F = inst.constructor;
|
|
3319
|
-
return new F({
|
|
3320
|
-
type: "function",
|
|
3321
|
-
input: inst._def.input,
|
|
3322
|
-
output
|
|
3323
|
-
});
|
|
3324
|
-
};
|
|
3325
|
-
return inst;
|
|
3326
|
-
});
|
|
3327
|
-
const $ZodPromise = /*@__PURE__*/ $constructor("$ZodPromise", (inst, def)=>{
|
|
3328
|
-
$ZodType.init(inst, def);
|
|
3329
|
-
inst._zod.parse = (payload, ctx)=>Promise.resolve(payload.value).then((inner)=>def.innerType._zod.run({
|
|
3330
|
-
value: inner,
|
|
3331
|
-
issues: []
|
|
3332
|
-
}, ctx));
|
|
3333
|
-
});
|
|
3334
|
-
const $ZodLazy = /*@__PURE__*/ $constructor("$ZodLazy", (inst, def)=>{
|
|
3335
|
-
$ZodType.init(inst, def);
|
|
3336
|
-
defineLazy(inst._zod, "innerType", ()=>def.getter());
|
|
3337
|
-
defineLazy(inst._zod, "pattern", ()=>inst._zod.innerType?._zod?.pattern);
|
|
3338
|
-
defineLazy(inst._zod, "propValues", ()=>inst._zod.innerType?._zod?.propValues);
|
|
3339
|
-
defineLazy(inst._zod, "optin", ()=>inst._zod.innerType?._zod?.optin ?? void 0);
|
|
3340
|
-
defineLazy(inst._zod, "optout", ()=>inst._zod.innerType?._zod?.optout ?? void 0);
|
|
3341
|
-
inst._zod.parse = (payload, ctx)=>{
|
|
3342
|
-
const inner = inst._zod.innerType;
|
|
3343
|
-
return inner._zod.run(payload, ctx);
|
|
3344
|
-
};
|
|
3345
|
-
});
|
|
3346
2008
|
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def)=>{
|
|
3347
2009
|
$ZodCheck.init(inst, def);
|
|
3348
2010
|
$ZodType.init(inst, def);
|
|
@@ -3369,121 +2031,6 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
3369
2031
|
payload.issues.push(util_issue(_iss));
|
|
3370
2032
|
}
|
|
3371
2033
|
}
|
|
3372
|
-
const en_error = ()=>{
|
|
3373
|
-
const Sizable = {
|
|
3374
|
-
string: {
|
|
3375
|
-
unit: "characters",
|
|
3376
|
-
verb: "to have"
|
|
3377
|
-
},
|
|
3378
|
-
file: {
|
|
3379
|
-
unit: "bytes",
|
|
3380
|
-
verb: "to have"
|
|
3381
|
-
},
|
|
3382
|
-
array: {
|
|
3383
|
-
unit: "items",
|
|
3384
|
-
verb: "to have"
|
|
3385
|
-
},
|
|
3386
|
-
set: {
|
|
3387
|
-
unit: "items",
|
|
3388
|
-
verb: "to have"
|
|
3389
|
-
},
|
|
3390
|
-
map: {
|
|
3391
|
-
unit: "entries",
|
|
3392
|
-
verb: "to have"
|
|
3393
|
-
}
|
|
3394
|
-
};
|
|
3395
|
-
function getSizing(origin) {
|
|
3396
|
-
return Sizable[origin] ?? null;
|
|
3397
|
-
}
|
|
3398
|
-
const FormatDictionary = {
|
|
3399
|
-
regex: "input",
|
|
3400
|
-
email: "email address",
|
|
3401
|
-
url: "URL",
|
|
3402
|
-
emoji: "emoji",
|
|
3403
|
-
uuid: "UUID",
|
|
3404
|
-
uuidv4: "UUIDv4",
|
|
3405
|
-
uuidv6: "UUIDv6",
|
|
3406
|
-
nanoid: "nanoid",
|
|
3407
|
-
guid: "GUID",
|
|
3408
|
-
cuid: "cuid",
|
|
3409
|
-
cuid2: "cuid2",
|
|
3410
|
-
ulid: "ULID",
|
|
3411
|
-
xid: "XID",
|
|
3412
|
-
ksuid: "KSUID",
|
|
3413
|
-
datetime: "ISO datetime",
|
|
3414
|
-
date: "ISO date",
|
|
3415
|
-
time: "ISO time",
|
|
3416
|
-
duration: "ISO duration",
|
|
3417
|
-
ipv4: "IPv4 address",
|
|
3418
|
-
ipv6: "IPv6 address",
|
|
3419
|
-
mac: "MAC address",
|
|
3420
|
-
cidrv4: "IPv4 range",
|
|
3421
|
-
cidrv6: "IPv6 range",
|
|
3422
|
-
base64: "base64-encoded string",
|
|
3423
|
-
base64url: "base64url-encoded string",
|
|
3424
|
-
json_string: "JSON string",
|
|
3425
|
-
e164: "E.164 number",
|
|
3426
|
-
jwt: "JWT",
|
|
3427
|
-
template_literal: "input"
|
|
3428
|
-
};
|
|
3429
|
-
const TypeDictionary = {
|
|
3430
|
-
nan: "NaN"
|
|
3431
|
-
};
|
|
3432
|
-
return (issue)=>{
|
|
3433
|
-
switch(issue.code){
|
|
3434
|
-
case "invalid_type":
|
|
3435
|
-
{
|
|
3436
|
-
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
|
3437
|
-
const receivedType = parsedType(issue.input);
|
|
3438
|
-
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
3439
|
-
return `Invalid input: expected ${expected}, received ${received}`;
|
|
3440
|
-
}
|
|
3441
|
-
case "invalid_value":
|
|
3442
|
-
if (1 === issue.values.length) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
3443
|
-
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
3444
|
-
case "too_big":
|
|
3445
|
-
{
|
|
3446
|
-
const adj = issue.inclusive ? "<=" : "<";
|
|
3447
|
-
const sizing = getSizing(issue.origin);
|
|
3448
|
-
if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
3449
|
-
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
3450
|
-
}
|
|
3451
|
-
case "too_small":
|
|
3452
|
-
{
|
|
3453
|
-
const adj = issue.inclusive ? ">=" : ">";
|
|
3454
|
-
const sizing = getSizing(issue.origin);
|
|
3455
|
-
if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
3456
|
-
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
3457
|
-
}
|
|
3458
|
-
case "invalid_format":
|
|
3459
|
-
{
|
|
3460
|
-
const _issue = issue;
|
|
3461
|
-
if ("starts_with" === _issue.format) return `Invalid string: must start with "${_issue.prefix}"`;
|
|
3462
|
-
if ("ends_with" === _issue.format) return `Invalid string: must end with "${_issue.suffix}"`;
|
|
3463
|
-
if ("includes" === _issue.format) return `Invalid string: must include "${_issue.includes}"`;
|
|
3464
|
-
if ("regex" === _issue.format) return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
3465
|
-
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
3466
|
-
}
|
|
3467
|
-
case "not_multiple_of":
|
|
3468
|
-
return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
3469
|
-
case "unrecognized_keys":
|
|
3470
|
-
return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
3471
|
-
case "invalid_key":
|
|
3472
|
-
return `Invalid key in ${issue.origin}`;
|
|
3473
|
-
case "invalid_union":
|
|
3474
|
-
return "Invalid input";
|
|
3475
|
-
case "invalid_element":
|
|
3476
|
-
return `Invalid value in ${issue.origin}`;
|
|
3477
|
-
default:
|
|
3478
|
-
return "Invalid input";
|
|
3479
|
-
}
|
|
3480
|
-
};
|
|
3481
|
-
};
|
|
3482
|
-
function en() {
|
|
3483
|
-
return {
|
|
3484
|
-
localeError: en_error()
|
|
3485
|
-
};
|
|
3486
|
-
}
|
|
3487
2034
|
var registries_a;
|
|
3488
2035
|
Symbol("ZodOutput");
|
|
3489
2036
|
Symbol("ZodInput");
|
|
@@ -3532,7 +2079,7 @@ function registries_registry() {
|
|
|
3532
2079
|
return new $ZodRegistry();
|
|
3533
2080
|
}
|
|
3534
2081
|
(registries_a = globalThis).__zod_globalRegistry ?? (registries_a.__zod_globalRegistry = registries_registry());
|
|
3535
|
-
const
|
|
2082
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
3536
2083
|
function _string(Class, params) {
|
|
3537
2084
|
return new Class({
|
|
3538
2085
|
type: "string",
|
|
@@ -3686,15 +2233,6 @@ function _ipv6(Class, params) {
|
|
|
3686
2233
|
...normalizeParams(params)
|
|
3687
2234
|
});
|
|
3688
2235
|
}
|
|
3689
|
-
function _mac(Class, params) {
|
|
3690
|
-
return new Class({
|
|
3691
|
-
type: "string",
|
|
3692
|
-
format: "mac",
|
|
3693
|
-
check: "string_format",
|
|
3694
|
-
abort: false,
|
|
3695
|
-
...normalizeParams(params)
|
|
3696
|
-
});
|
|
3697
|
-
}
|
|
3698
2236
|
function _cidrv4(Class, params) {
|
|
3699
2237
|
return new Class({
|
|
3700
2238
|
type: "string",
|
|
@@ -3722,275 +2260,86 @@ function _base64(Class, params) {
|
|
|
3722
2260
|
...normalizeParams(params)
|
|
3723
2261
|
});
|
|
3724
2262
|
}
|
|
3725
|
-
function _base64url(Class, params) {
|
|
3726
|
-
return new Class({
|
|
3727
|
-
type: "string",
|
|
3728
|
-
format: "base64url",
|
|
3729
|
-
check: "string_format",
|
|
3730
|
-
abort: false,
|
|
3731
|
-
...normalizeParams(params)
|
|
3732
|
-
});
|
|
3733
|
-
}
|
|
3734
|
-
function _e164(Class, params) {
|
|
3735
|
-
return new Class({
|
|
3736
|
-
type: "string",
|
|
3737
|
-
format: "e164",
|
|
3738
|
-
check: "string_format",
|
|
3739
|
-
abort: false,
|
|
3740
|
-
...normalizeParams(params)
|
|
3741
|
-
});
|
|
3742
|
-
}
|
|
3743
|
-
function _jwt(Class, params) {
|
|
3744
|
-
return new Class({
|
|
3745
|
-
type: "string",
|
|
3746
|
-
format: "jwt",
|
|
3747
|
-
check: "string_format",
|
|
3748
|
-
abort: false,
|
|
3749
|
-
...normalizeParams(params)
|
|
3750
|
-
});
|
|
3751
|
-
}
|
|
3752
|
-
function _isoDateTime(Class, params) {
|
|
3753
|
-
return new Class({
|
|
3754
|
-
type: "string",
|
|
3755
|
-
format: "datetime",
|
|
3756
|
-
check: "string_format",
|
|
3757
|
-
offset: false,
|
|
3758
|
-
local: false,
|
|
3759
|
-
precision: null,
|
|
3760
|
-
...normalizeParams(params)
|
|
3761
|
-
});
|
|
3762
|
-
}
|
|
3763
|
-
function _isoDate(Class, params) {
|
|
3764
|
-
return new Class({
|
|
3765
|
-
type: "string",
|
|
3766
|
-
format: "date",
|
|
3767
|
-
check: "string_format",
|
|
3768
|
-
...normalizeParams(params)
|
|
3769
|
-
});
|
|
3770
|
-
}
|
|
3771
|
-
function _isoTime(Class, params) {
|
|
3772
|
-
return new Class({
|
|
3773
|
-
type: "string",
|
|
3774
|
-
format: "time",
|
|
3775
|
-
check: "string_format",
|
|
3776
|
-
precision: null,
|
|
3777
|
-
...normalizeParams(params)
|
|
3778
|
-
});
|
|
3779
|
-
}
|
|
3780
|
-
function _isoDuration(Class, params) {
|
|
3781
|
-
return new Class({
|
|
3782
|
-
type: "string",
|
|
3783
|
-
format: "duration",
|
|
3784
|
-
check: "string_format",
|
|
3785
|
-
...normalizeParams(params)
|
|
3786
|
-
});
|
|
3787
|
-
}
|
|
3788
|
-
function _number(Class, params) {
|
|
3789
|
-
return new Class({
|
|
3790
|
-
type: "number",
|
|
3791
|
-
checks: [],
|
|
3792
|
-
...normalizeParams(params)
|
|
3793
|
-
});
|
|
3794
|
-
}
|
|
3795
|
-
function _int(Class, params) {
|
|
3796
|
-
return new Class({
|
|
3797
|
-
type: "number",
|
|
3798
|
-
check: "number_format",
|
|
3799
|
-
abort: false,
|
|
3800
|
-
format: "safeint",
|
|
3801
|
-
...normalizeParams(params)
|
|
3802
|
-
});
|
|
3803
|
-
}
|
|
3804
|
-
function _float32(Class, params) {
|
|
3805
|
-
return new Class({
|
|
3806
|
-
type: "number",
|
|
3807
|
-
check: "number_format",
|
|
3808
|
-
abort: false,
|
|
3809
|
-
format: "float32",
|
|
3810
|
-
...normalizeParams(params)
|
|
3811
|
-
});
|
|
3812
|
-
}
|
|
3813
|
-
function _float64(Class, params) {
|
|
3814
|
-
return new Class({
|
|
3815
|
-
type: "number",
|
|
3816
|
-
check: "number_format",
|
|
3817
|
-
abort: false,
|
|
3818
|
-
format: "float64",
|
|
3819
|
-
...normalizeParams(params)
|
|
3820
|
-
});
|
|
3821
|
-
}
|
|
3822
|
-
function _int32(Class, params) {
|
|
3823
|
-
return new Class({
|
|
3824
|
-
type: "number",
|
|
3825
|
-
check: "number_format",
|
|
3826
|
-
abort: false,
|
|
3827
|
-
format: "int32",
|
|
3828
|
-
...normalizeParams(params)
|
|
3829
|
-
});
|
|
3830
|
-
}
|
|
3831
|
-
function _uint32(Class, params) {
|
|
3832
|
-
return new Class({
|
|
3833
|
-
type: "number",
|
|
3834
|
-
check: "number_format",
|
|
3835
|
-
abort: false,
|
|
3836
|
-
format: "uint32",
|
|
3837
|
-
...normalizeParams(params)
|
|
3838
|
-
});
|
|
3839
|
-
}
|
|
3840
|
-
function _boolean(Class, params) {
|
|
3841
|
-
return new Class({
|
|
3842
|
-
type: "boolean",
|
|
3843
|
-
...normalizeParams(params)
|
|
3844
|
-
});
|
|
3845
|
-
}
|
|
3846
|
-
function _bigint(Class, params) {
|
|
3847
|
-
return new Class({
|
|
3848
|
-
type: "bigint",
|
|
3849
|
-
...normalizeParams(params)
|
|
3850
|
-
});
|
|
3851
|
-
}
|
|
3852
|
-
function _int64(Class, params) {
|
|
3853
|
-
return new Class({
|
|
3854
|
-
type: "bigint",
|
|
3855
|
-
check: "bigint_format",
|
|
3856
|
-
abort: false,
|
|
3857
|
-
format: "int64",
|
|
3858
|
-
...normalizeParams(params)
|
|
3859
|
-
});
|
|
3860
|
-
}
|
|
3861
|
-
function _uint64(Class, params) {
|
|
2263
|
+
function _base64url(Class, params) {
|
|
3862
2264
|
return new Class({
|
|
3863
|
-
type: "
|
|
3864
|
-
|
|
2265
|
+
type: "string",
|
|
2266
|
+
format: "base64url",
|
|
2267
|
+
check: "string_format",
|
|
3865
2268
|
abort: false,
|
|
3866
|
-
format: "uint64",
|
|
3867
2269
|
...normalizeParams(params)
|
|
3868
2270
|
});
|
|
3869
2271
|
}
|
|
3870
|
-
function
|
|
2272
|
+
function _e164(Class, params) {
|
|
3871
2273
|
return new Class({
|
|
3872
|
-
type: "
|
|
2274
|
+
type: "string",
|
|
2275
|
+
format: "e164",
|
|
2276
|
+
check: "string_format",
|
|
2277
|
+
abort: false,
|
|
3873
2278
|
...normalizeParams(params)
|
|
3874
2279
|
});
|
|
3875
2280
|
}
|
|
3876
|
-
function
|
|
2281
|
+
function _jwt(Class, params) {
|
|
3877
2282
|
return new Class({
|
|
3878
|
-
type: "
|
|
2283
|
+
type: "string",
|
|
2284
|
+
format: "jwt",
|
|
2285
|
+
check: "string_format",
|
|
2286
|
+
abort: false,
|
|
3879
2287
|
...normalizeParams(params)
|
|
3880
2288
|
});
|
|
3881
2289
|
}
|
|
3882
|
-
function
|
|
2290
|
+
function _isoDateTime(Class, params) {
|
|
3883
2291
|
return new Class({
|
|
3884
|
-
type: "
|
|
2292
|
+
type: "string",
|
|
2293
|
+
format: "datetime",
|
|
2294
|
+
check: "string_format",
|
|
2295
|
+
offset: false,
|
|
2296
|
+
local: false,
|
|
2297
|
+
precision: null,
|
|
3885
2298
|
...normalizeParams(params)
|
|
3886
2299
|
});
|
|
3887
2300
|
}
|
|
3888
|
-
function
|
|
2301
|
+
function _isoDate(Class, params) {
|
|
3889
2302
|
return new Class({
|
|
3890
|
-
type: "
|
|
2303
|
+
type: "string",
|
|
2304
|
+
format: "date",
|
|
2305
|
+
check: "string_format",
|
|
2306
|
+
...normalizeParams(params)
|
|
3891
2307
|
});
|
|
3892
2308
|
}
|
|
3893
|
-
function
|
|
2309
|
+
function _isoTime(Class, params) {
|
|
3894
2310
|
return new Class({
|
|
3895
|
-
type: "
|
|
2311
|
+
type: "string",
|
|
2312
|
+
format: "time",
|
|
2313
|
+
check: "string_format",
|
|
2314
|
+
precision: null,
|
|
2315
|
+
...normalizeParams(params)
|
|
3896
2316
|
});
|
|
3897
2317
|
}
|
|
3898
|
-
function
|
|
2318
|
+
function _isoDuration(Class, params) {
|
|
3899
2319
|
return new Class({
|
|
3900
|
-
type: "
|
|
2320
|
+
type: "string",
|
|
2321
|
+
format: "duration",
|
|
2322
|
+
check: "string_format",
|
|
3901
2323
|
...normalizeParams(params)
|
|
3902
2324
|
});
|
|
3903
2325
|
}
|
|
3904
|
-
function
|
|
2326
|
+
function _boolean(Class, params) {
|
|
3905
2327
|
return new Class({
|
|
3906
|
-
type: "
|
|
2328
|
+
type: "boolean",
|
|
3907
2329
|
...normalizeParams(params)
|
|
3908
2330
|
});
|
|
3909
2331
|
}
|
|
3910
|
-
function
|
|
2332
|
+
function _unknown(Class) {
|
|
3911
2333
|
return new Class({
|
|
3912
|
-
type: "
|
|
3913
|
-
...normalizeParams(params)
|
|
2334
|
+
type: "unknown"
|
|
3914
2335
|
});
|
|
3915
2336
|
}
|
|
3916
|
-
function
|
|
2337
|
+
function _never(Class, params) {
|
|
3917
2338
|
return new Class({
|
|
3918
|
-
type: "
|
|
2339
|
+
type: "never",
|
|
3919
2340
|
...normalizeParams(params)
|
|
3920
2341
|
});
|
|
3921
2342
|
}
|
|
3922
|
-
function _lt(value, params) {
|
|
3923
|
-
return new $ZodCheckLessThan({
|
|
3924
|
-
check: "less_than",
|
|
3925
|
-
...normalizeParams(params),
|
|
3926
|
-
value,
|
|
3927
|
-
inclusive: false
|
|
3928
|
-
});
|
|
3929
|
-
}
|
|
3930
|
-
function _lte(value, params) {
|
|
3931
|
-
return new $ZodCheckLessThan({
|
|
3932
|
-
check: "less_than",
|
|
3933
|
-
...normalizeParams(params),
|
|
3934
|
-
value,
|
|
3935
|
-
inclusive: true
|
|
3936
|
-
});
|
|
3937
|
-
}
|
|
3938
|
-
function _gt(value, params) {
|
|
3939
|
-
return new $ZodCheckGreaterThan({
|
|
3940
|
-
check: "greater_than",
|
|
3941
|
-
...normalizeParams(params),
|
|
3942
|
-
value,
|
|
3943
|
-
inclusive: false
|
|
3944
|
-
});
|
|
3945
|
-
}
|
|
3946
|
-
function _gte(value, params) {
|
|
3947
|
-
return new $ZodCheckGreaterThan({
|
|
3948
|
-
check: "greater_than",
|
|
3949
|
-
...normalizeParams(params),
|
|
3950
|
-
value,
|
|
3951
|
-
inclusive: true
|
|
3952
|
-
});
|
|
3953
|
-
}
|
|
3954
|
-
function _positive(params) {
|
|
3955
|
-
return _gt(0, params);
|
|
3956
|
-
}
|
|
3957
|
-
function _negative(params) {
|
|
3958
|
-
return _lt(0, params);
|
|
3959
|
-
}
|
|
3960
|
-
function _nonpositive(params) {
|
|
3961
|
-
return _lte(0, params);
|
|
3962
|
-
}
|
|
3963
|
-
function _nonnegative(params) {
|
|
3964
|
-
return _gte(0, params);
|
|
3965
|
-
}
|
|
3966
|
-
function _multipleOf(value, params) {
|
|
3967
|
-
return new $ZodCheckMultipleOf({
|
|
3968
|
-
check: "multiple_of",
|
|
3969
|
-
...normalizeParams(params),
|
|
3970
|
-
value
|
|
3971
|
-
});
|
|
3972
|
-
}
|
|
3973
|
-
function _maxSize(maximum, params) {
|
|
3974
|
-
return new $ZodCheckMaxSize({
|
|
3975
|
-
check: "max_size",
|
|
3976
|
-
...normalizeParams(params),
|
|
3977
|
-
maximum
|
|
3978
|
-
});
|
|
3979
|
-
}
|
|
3980
|
-
function _minSize(minimum, params) {
|
|
3981
|
-
return new $ZodCheckMinSize({
|
|
3982
|
-
check: "min_size",
|
|
3983
|
-
...normalizeParams(params),
|
|
3984
|
-
minimum
|
|
3985
|
-
});
|
|
3986
|
-
}
|
|
3987
|
-
function _size(size, params) {
|
|
3988
|
-
return new $ZodCheckSizeEquals({
|
|
3989
|
-
check: "size_equals",
|
|
3990
|
-
...normalizeParams(params),
|
|
3991
|
-
size
|
|
3992
|
-
});
|
|
3993
|
-
}
|
|
3994
2343
|
function _maxLength(maximum, params) {
|
|
3995
2344
|
const ch = new $ZodCheckMaxLength({
|
|
3996
2345
|
check: "max_length",
|
|
@@ -4059,21 +2408,6 @@ function _endsWith(suffix, params) {
|
|
|
4059
2408
|
suffix
|
|
4060
2409
|
});
|
|
4061
2410
|
}
|
|
4062
|
-
function _property(property, schema, params) {
|
|
4063
|
-
return new $ZodCheckProperty({
|
|
4064
|
-
check: "property",
|
|
4065
|
-
property,
|
|
4066
|
-
schema,
|
|
4067
|
-
...normalizeParams(params)
|
|
4068
|
-
});
|
|
4069
|
-
}
|
|
4070
|
-
function _mime(types, params) {
|
|
4071
|
-
return new $ZodCheckMimeType({
|
|
4072
|
-
check: "mime_type",
|
|
4073
|
-
mime: types,
|
|
4074
|
-
...normalizeParams(params)
|
|
4075
|
-
});
|
|
4076
|
-
}
|
|
4077
2411
|
function _overwrite(tx) {
|
|
4078
2412
|
return new $ZodCheckOverwrite({
|
|
4079
2413
|
check: "overwrite",
|
|
@@ -4102,23 +2436,6 @@ function _array(Class, element, params) {
|
|
|
4102
2436
|
...normalizeParams(params)
|
|
4103
2437
|
});
|
|
4104
2438
|
}
|
|
4105
|
-
function _file(Class, params) {
|
|
4106
|
-
return new Class({
|
|
4107
|
-
type: "file",
|
|
4108
|
-
...normalizeParams(params)
|
|
4109
|
-
});
|
|
4110
|
-
}
|
|
4111
|
-
function _custom(Class, fn, _params) {
|
|
4112
|
-
const norm = normalizeParams(_params);
|
|
4113
|
-
norm.abort ?? (norm.abort = true);
|
|
4114
|
-
const schema = new Class({
|
|
4115
|
-
type: "custom",
|
|
4116
|
-
check: "custom",
|
|
4117
|
-
fn: fn,
|
|
4118
|
-
...norm
|
|
4119
|
-
});
|
|
4120
|
-
return schema;
|
|
4121
|
-
}
|
|
4122
2439
|
function _refine(Class, fn, _params) {
|
|
4123
2440
|
const schema = new Class({
|
|
4124
2441
|
type: "custom",
|
|
@@ -4128,7 +2445,7 @@ function _refine(Class, fn, _params) {
|
|
|
4128
2445
|
});
|
|
4129
2446
|
return schema;
|
|
4130
2447
|
}
|
|
4131
|
-
function _superRefine(fn) {
|
|
2448
|
+
function _superRefine(fn, params) {
|
|
4132
2449
|
const ch = _check((payload)=>{
|
|
4133
2450
|
payload.addIssue = (issue)=>{
|
|
4134
2451
|
if ("string" == typeof issue) payload.issues.push(util_issue(issue, payload.value, ch._zod.def));
|
|
@@ -4143,7 +2460,7 @@ function _superRefine(fn) {
|
|
|
4143
2460
|
}
|
|
4144
2461
|
};
|
|
4145
2462
|
return fn(payload.value, payload);
|
|
4146
|
-
});
|
|
2463
|
+
}, params);
|
|
4147
2464
|
return ch;
|
|
4148
2465
|
}
|
|
4149
2466
|
function _check(fn, params) {
|
|
@@ -4154,124 +2471,13 @@ function _check(fn, params) {
|
|
|
4154
2471
|
ch._zod.check = fn;
|
|
4155
2472
|
return ch;
|
|
4156
2473
|
}
|
|
4157
|
-
function describe(description) {
|
|
4158
|
-
const ch = new $ZodCheck({
|
|
4159
|
-
check: "describe"
|
|
4160
|
-
});
|
|
4161
|
-
ch._zod.onattach = [
|
|
4162
|
-
(inst)=>{
|
|
4163
|
-
const existing = registries_globalRegistry.get(inst) ?? {};
|
|
4164
|
-
registries_globalRegistry.add(inst, {
|
|
4165
|
-
...existing,
|
|
4166
|
-
description
|
|
4167
|
-
});
|
|
4168
|
-
}
|
|
4169
|
-
];
|
|
4170
|
-
ch._zod.check = ()=>{};
|
|
4171
|
-
return ch;
|
|
4172
|
-
}
|
|
4173
|
-
function api_meta(metadata) {
|
|
4174
|
-
const ch = new $ZodCheck({
|
|
4175
|
-
check: "meta"
|
|
4176
|
-
});
|
|
4177
|
-
ch._zod.onattach = [
|
|
4178
|
-
(inst)=>{
|
|
4179
|
-
const existing = registries_globalRegistry.get(inst) ?? {};
|
|
4180
|
-
registries_globalRegistry.add(inst, {
|
|
4181
|
-
...existing,
|
|
4182
|
-
...metadata
|
|
4183
|
-
});
|
|
4184
|
-
}
|
|
4185
|
-
];
|
|
4186
|
-
ch._zod.check = ()=>{};
|
|
4187
|
-
return ch;
|
|
4188
|
-
}
|
|
4189
|
-
function _stringbool(Classes, _params) {
|
|
4190
|
-
const params = normalizeParams(_params);
|
|
4191
|
-
let truthyArray = params.truthy ?? [
|
|
4192
|
-
"true",
|
|
4193
|
-
"1",
|
|
4194
|
-
"yes",
|
|
4195
|
-
"on",
|
|
4196
|
-
"y",
|
|
4197
|
-
"enabled"
|
|
4198
|
-
];
|
|
4199
|
-
let falsyArray = params.falsy ?? [
|
|
4200
|
-
"false",
|
|
4201
|
-
"0",
|
|
4202
|
-
"no",
|
|
4203
|
-
"off",
|
|
4204
|
-
"n",
|
|
4205
|
-
"disabled"
|
|
4206
|
-
];
|
|
4207
|
-
if ("sensitive" !== params.case) {
|
|
4208
|
-
truthyArray = truthyArray.map((v)=>"string" == typeof v ? v.toLowerCase() : v);
|
|
4209
|
-
falsyArray = falsyArray.map((v)=>"string" == typeof v ? v.toLowerCase() : v);
|
|
4210
|
-
}
|
|
4211
|
-
const truthySet = new Set(truthyArray);
|
|
4212
|
-
const falsySet = new Set(falsyArray);
|
|
4213
|
-
const _Codec = Classes.Codec ?? $ZodCodec;
|
|
4214
|
-
const _Boolean = Classes.Boolean ?? $ZodBoolean;
|
|
4215
|
-
const _String = Classes.String ?? $ZodString;
|
|
4216
|
-
const stringSchema = new _String({
|
|
4217
|
-
type: "string",
|
|
4218
|
-
error: params.error
|
|
4219
|
-
});
|
|
4220
|
-
const booleanSchema = new _Boolean({
|
|
4221
|
-
type: "boolean",
|
|
4222
|
-
error: params.error
|
|
4223
|
-
});
|
|
4224
|
-
const codec = new _Codec({
|
|
4225
|
-
type: "pipe",
|
|
4226
|
-
in: stringSchema,
|
|
4227
|
-
out: booleanSchema,
|
|
4228
|
-
transform: (input, payload)=>{
|
|
4229
|
-
let data = input;
|
|
4230
|
-
if ("sensitive" !== params.case) data = data.toLowerCase();
|
|
4231
|
-
if (truthySet.has(data)) return true;
|
|
4232
|
-
if (falsySet.has(data)) return false;
|
|
4233
|
-
payload.issues.push({
|
|
4234
|
-
code: "invalid_value",
|
|
4235
|
-
expected: "stringbool",
|
|
4236
|
-
values: [
|
|
4237
|
-
...truthySet,
|
|
4238
|
-
...falsySet
|
|
4239
|
-
],
|
|
4240
|
-
input: payload.value,
|
|
4241
|
-
inst: codec,
|
|
4242
|
-
continue: false
|
|
4243
|
-
});
|
|
4244
|
-
return {};
|
|
4245
|
-
},
|
|
4246
|
-
reverseTransform: (input, _payload)=>{
|
|
4247
|
-
if (true === input) return truthyArray[0] || "true";
|
|
4248
|
-
return falsyArray[0] || "false";
|
|
4249
|
-
},
|
|
4250
|
-
error: params.error
|
|
4251
|
-
});
|
|
4252
|
-
return codec;
|
|
4253
|
-
}
|
|
4254
|
-
function _stringFormat(Class, format, fnOrRegex, _params = {}) {
|
|
4255
|
-
const params = normalizeParams(_params);
|
|
4256
|
-
const def = {
|
|
4257
|
-
...normalizeParams(_params),
|
|
4258
|
-
check: "string_format",
|
|
4259
|
-
type: "string",
|
|
4260
|
-
format,
|
|
4261
|
-
fn: "function" == typeof fnOrRegex ? fnOrRegex : (val)=>fnOrRegex.test(val),
|
|
4262
|
-
...params
|
|
4263
|
-
};
|
|
4264
|
-
if (fnOrRegex instanceof RegExp) def.pattern = fnOrRegex;
|
|
4265
|
-
const inst = new Class(def);
|
|
4266
|
-
return inst;
|
|
4267
|
-
}
|
|
4268
2474
|
function to_json_schema_initializeContext(params) {
|
|
4269
2475
|
let target = params?.target ?? "draft-2020-12";
|
|
4270
2476
|
if ("draft-4" === target) target = "draft-04";
|
|
4271
2477
|
if ("draft-7" === target) target = "draft-07";
|
|
4272
2478
|
return {
|
|
4273
2479
|
processors: params.processors ?? {},
|
|
4274
|
-
metadataRegistry: params?.metadata ??
|
|
2480
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
4275
2481
|
target,
|
|
4276
2482
|
unrepresentable: params?.unrepresentable ?? "throw",
|
|
4277
2483
|
override: params?.override ?? (()=>{}),
|
|
@@ -4334,7 +2540,7 @@ function to_json_schema_process(schema, ctx, _params = {
|
|
|
4334
2540
|
delete result.schema.examples;
|
|
4335
2541
|
delete result.schema.default;
|
|
4336
2542
|
}
|
|
4337
|
-
if ("input" === ctx.io && result.schema
|
|
2543
|
+
if ("input" === ctx.io && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
4338
2544
|
delete result.schema._prefault;
|
|
4339
2545
|
const _result = ctx.seen.get(schema);
|
|
4340
2546
|
return _result.schema;
|
|
@@ -4489,10 +2695,15 @@ function to_json_schema_finalize(ctx, schema) {
|
|
|
4489
2695
|
result.$id = ctx.external.uri(id);
|
|
4490
2696
|
}
|
|
4491
2697
|
Object.assign(result, root.def ?? root.schema);
|
|
2698
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
2699
|
+
if (void 0 !== rootMetaId && result.id === rootMetaId) delete result.id;
|
|
4492
2700
|
const defs = ctx.external?.defs ?? {};
|
|
4493
2701
|
for (const entry of ctx.seen.entries()){
|
|
4494
2702
|
const seen = entry[1];
|
|
4495
|
-
if (seen.def && seen.defId)
|
|
2703
|
+
if (seen.def && seen.defId) {
|
|
2704
|
+
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
2705
|
+
defs[seen.defId] = seen.def;
|
|
2706
|
+
}
|
|
4496
2707
|
}
|
|
4497
2708
|
if (ctx.external) ;
|
|
4498
2709
|
else if (Object.keys(defs).length > 0) if ("draft-2020-12" === ctx.target) result.$defs = defs;
|
|
@@ -4529,7 +2740,10 @@ function isTransforming(_schema, _ctx) {
|
|
|
4529
2740
|
if ("promise" === def.type || "optional" === def.type || "nonoptional" === def.type || "nullable" === def.type || "readonly" === def.type || "default" === def.type || "prefault" === def.type) return isTransforming(def.innerType, ctx);
|
|
4530
2741
|
if ("intersection" === def.type) return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
4531
2742
|
if ("record" === def.type || "map" === def.type) return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
4532
|
-
if ("pipe" === def.type)
|
|
2743
|
+
if ("pipe" === def.type) {
|
|
2744
|
+
if (_schema._zod.traits.has("$ZodCodec")) return true;
|
|
2745
|
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
2746
|
+
}
|
|
4533
2747
|
if ("object" === def.type) {
|
|
4534
2748
|
for(const key in def.shape)if (isTransforming(def.shape[key], ctx)) return true;
|
|
4535
2749
|
return false;
|
|
@@ -4599,63 +2813,13 @@ const stringProcessor = (schema, ctx, _json, _params)=>{
|
|
|
4599
2813
|
];
|
|
4600
2814
|
}
|
|
4601
2815
|
};
|
|
4602
|
-
const numberProcessor = (schema, ctx, _json, _params)=>{
|
|
4603
|
-
const json = _json;
|
|
4604
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
4605
|
-
if ("string" == typeof format && format.includes("int")) json.type = "integer";
|
|
4606
|
-
else json.type = "number";
|
|
4607
|
-
if ("number" == typeof exclusiveMinimum) if ("draft-04" === ctx.target || "openapi-3.0" === ctx.target) {
|
|
4608
|
-
json.minimum = exclusiveMinimum;
|
|
4609
|
-
json.exclusiveMinimum = true;
|
|
4610
|
-
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
4611
|
-
if ("number" == typeof minimum) {
|
|
4612
|
-
json.minimum = minimum;
|
|
4613
|
-
if ("number" == typeof exclusiveMinimum && "draft-04" !== ctx.target) if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
4614
|
-
else delete json.exclusiveMinimum;
|
|
4615
|
-
}
|
|
4616
|
-
if ("number" == typeof exclusiveMaximum) if ("draft-04" === ctx.target || "openapi-3.0" === ctx.target) {
|
|
4617
|
-
json.maximum = exclusiveMaximum;
|
|
4618
|
-
json.exclusiveMaximum = true;
|
|
4619
|
-
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
4620
|
-
if ("number" == typeof maximum) {
|
|
4621
|
-
json.maximum = maximum;
|
|
4622
|
-
if ("number" == typeof exclusiveMaximum && "draft-04" !== ctx.target) if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
4623
|
-
else delete json.exclusiveMaximum;
|
|
4624
|
-
}
|
|
4625
|
-
if ("number" == typeof multipleOf) json.multipleOf = multipleOf;
|
|
4626
|
-
};
|
|
4627
2816
|
const booleanProcessor = (_schema, _ctx, json, _params)=>{
|
|
4628
2817
|
json.type = "boolean";
|
|
4629
2818
|
};
|
|
4630
|
-
const bigintProcessor = (_schema, ctx, _json, _params)=>{
|
|
4631
|
-
if ("throw" === ctx.unrepresentable) throw new Error("BigInt cannot be represented in JSON Schema");
|
|
4632
|
-
};
|
|
4633
|
-
const symbolProcessor = (_schema, ctx, _json, _params)=>{
|
|
4634
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Symbols cannot be represented in JSON Schema");
|
|
4635
|
-
};
|
|
4636
|
-
const nullProcessor = (_schema, ctx, json, _params)=>{
|
|
4637
|
-
if ("openapi-3.0" === ctx.target) {
|
|
4638
|
-
json.type = "string";
|
|
4639
|
-
json.nullable = true;
|
|
4640
|
-
json.enum = [
|
|
4641
|
-
null
|
|
4642
|
-
];
|
|
4643
|
-
} else json.type = "null";
|
|
4644
|
-
};
|
|
4645
|
-
const undefinedProcessor = (_schema, ctx, _json, _params)=>{
|
|
4646
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Undefined cannot be represented in JSON Schema");
|
|
4647
|
-
};
|
|
4648
|
-
const voidProcessor = (_schema, ctx, _json, _params)=>{
|
|
4649
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Void cannot be represented in JSON Schema");
|
|
4650
|
-
};
|
|
4651
2819
|
const neverProcessor = (_schema, _ctx, json, _params)=>{
|
|
4652
2820
|
json.not = {};
|
|
4653
2821
|
};
|
|
4654
|
-
const anyProcessor = (_schema, _ctx, _json, _params)=>{};
|
|
4655
2822
|
const unknownProcessor = (_schema, _ctx, _json, _params)=>{};
|
|
4656
|
-
const dateProcessor = (_schema, ctx, _json, _params)=>{
|
|
4657
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Date cannot be represented in JSON Schema");
|
|
4658
|
-
};
|
|
4659
2823
|
const enumProcessor = (schema, _ctx, json, _params)=>{
|
|
4660
2824
|
const def = schema._zod.def;
|
|
4661
2825
|
const values = getEnumValues(def.entries);
|
|
@@ -4663,79 +2827,12 @@ const enumProcessor = (schema, _ctx, json, _params)=>{
|
|
|
4663
2827
|
if (values.every((v)=>"string" == typeof v)) json.type = "string";
|
|
4664
2828
|
json.enum = values;
|
|
4665
2829
|
};
|
|
4666
|
-
const literalProcessor = (schema, ctx, json, _params)=>{
|
|
4667
|
-
const def = schema._zod.def;
|
|
4668
|
-
const vals = [];
|
|
4669
|
-
for (const val of def.values)if (void 0 === val) {
|
|
4670
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
4671
|
-
} else if ("bigint" == typeof val) if ("throw" === ctx.unrepresentable) throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
4672
|
-
else vals.push(Number(val));
|
|
4673
|
-
else vals.push(val);
|
|
4674
|
-
if (0 === vals.length) ;
|
|
4675
|
-
else if (1 === vals.length) {
|
|
4676
|
-
const val = vals[0];
|
|
4677
|
-
json.type = null === val ? "null" : typeof val;
|
|
4678
|
-
if ("draft-04" === ctx.target || "openapi-3.0" === ctx.target) json.enum = [
|
|
4679
|
-
val
|
|
4680
|
-
];
|
|
4681
|
-
else json.const = val;
|
|
4682
|
-
} else {
|
|
4683
|
-
if (vals.every((v)=>"number" == typeof v)) json.type = "number";
|
|
4684
|
-
if (vals.every((v)=>"string" == typeof v)) json.type = "string";
|
|
4685
|
-
if (vals.every((v)=>"boolean" == typeof v)) json.type = "boolean";
|
|
4686
|
-
if (vals.every((v)=>null === v)) json.type = "null";
|
|
4687
|
-
json.enum = vals;
|
|
4688
|
-
}
|
|
4689
|
-
};
|
|
4690
|
-
const nanProcessor = (_schema, ctx, _json, _params)=>{
|
|
4691
|
-
if ("throw" === ctx.unrepresentable) throw new Error("NaN cannot be represented in JSON Schema");
|
|
4692
|
-
};
|
|
4693
|
-
const templateLiteralProcessor = (schema, _ctx, json, _params)=>{
|
|
4694
|
-
const _json = json;
|
|
4695
|
-
const pattern = schema._zod.pattern;
|
|
4696
|
-
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
4697
|
-
_json.type = "string";
|
|
4698
|
-
_json.pattern = pattern.source;
|
|
4699
|
-
};
|
|
4700
|
-
const fileProcessor = (schema, _ctx, json, _params)=>{
|
|
4701
|
-
const _json = json;
|
|
4702
|
-
const file = {
|
|
4703
|
-
type: "string",
|
|
4704
|
-
format: "binary",
|
|
4705
|
-
contentEncoding: "binary"
|
|
4706
|
-
};
|
|
4707
|
-
const { minimum, maximum, mime } = schema._zod.bag;
|
|
4708
|
-
if (void 0 !== minimum) file.minLength = minimum;
|
|
4709
|
-
if (void 0 !== maximum) file.maxLength = maximum;
|
|
4710
|
-
if (mime) if (1 === mime.length) {
|
|
4711
|
-
file.contentMediaType = mime[0];
|
|
4712
|
-
Object.assign(_json, file);
|
|
4713
|
-
} else {
|
|
4714
|
-
Object.assign(_json, file);
|
|
4715
|
-
_json.anyOf = mime.map((m)=>({
|
|
4716
|
-
contentMediaType: m
|
|
4717
|
-
}));
|
|
4718
|
-
}
|
|
4719
|
-
else Object.assign(_json, file);
|
|
4720
|
-
};
|
|
4721
|
-
const successProcessor = (_schema, _ctx, json, _params)=>{
|
|
4722
|
-
json.type = "boolean";
|
|
4723
|
-
};
|
|
4724
2830
|
const customProcessor = (_schema, ctx, _json, _params)=>{
|
|
4725
2831
|
if ("throw" === ctx.unrepresentable) throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4726
2832
|
};
|
|
4727
|
-
const functionProcessor = (_schema, ctx, _json, _params)=>{
|
|
4728
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Function types cannot be represented in JSON Schema");
|
|
4729
|
-
};
|
|
4730
2833
|
const transformProcessor = (_schema, ctx, _json, _params)=>{
|
|
4731
2834
|
if ("throw" === ctx.unrepresentable) throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4732
2835
|
};
|
|
4733
|
-
const mapProcessor = (_schema, ctx, _json, _params)=>{
|
|
4734
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Map cannot be represented in JSON Schema");
|
|
4735
|
-
};
|
|
4736
|
-
const setProcessor = (_schema, ctx, _json, _params)=>{
|
|
4737
|
-
if ("throw" === ctx.unrepresentable) throw new Error("Set cannot be represented in JSON Schema");
|
|
4738
|
-
};
|
|
4739
2836
|
const arrayProcessor = (schema, ctx, _json, params)=>{
|
|
4740
2837
|
const json = _json;
|
|
4741
2838
|
const def = schema._zod.def;
|
|
@@ -4828,90 +2925,6 @@ const intersectionProcessor = (schema, ctx, json, params)=>{
|
|
|
4828
2925
|
];
|
|
4829
2926
|
json.allOf = allOf;
|
|
4830
2927
|
};
|
|
4831
|
-
const tupleProcessor = (schema, ctx, _json, params)=>{
|
|
4832
|
-
const json = _json;
|
|
4833
|
-
const def = schema._zod.def;
|
|
4834
|
-
json.type = "array";
|
|
4835
|
-
const prefixPath = "draft-2020-12" === ctx.target ? "prefixItems" : "items";
|
|
4836
|
-
const restPath = "draft-2020-12" === ctx.target ? "items" : "openapi-3.0" === ctx.target ? "items" : "additionalItems";
|
|
4837
|
-
const prefixItems = def.items.map((x, i)=>to_json_schema_process(x, ctx, {
|
|
4838
|
-
...params,
|
|
4839
|
-
path: [
|
|
4840
|
-
...params.path,
|
|
4841
|
-
prefixPath,
|
|
4842
|
-
i
|
|
4843
|
-
]
|
|
4844
|
-
}));
|
|
4845
|
-
const rest = def.rest ? to_json_schema_process(def.rest, ctx, {
|
|
4846
|
-
...params,
|
|
4847
|
-
path: [
|
|
4848
|
-
...params.path,
|
|
4849
|
-
restPath,
|
|
4850
|
-
..."openapi-3.0" === ctx.target ? [
|
|
4851
|
-
def.items.length
|
|
4852
|
-
] : []
|
|
4853
|
-
]
|
|
4854
|
-
}) : null;
|
|
4855
|
-
if ("draft-2020-12" === ctx.target) {
|
|
4856
|
-
json.prefixItems = prefixItems;
|
|
4857
|
-
if (rest) json.items = rest;
|
|
4858
|
-
} else if ("openapi-3.0" === ctx.target) {
|
|
4859
|
-
json.items = {
|
|
4860
|
-
anyOf: prefixItems
|
|
4861
|
-
};
|
|
4862
|
-
if (rest) json.items.anyOf.push(rest);
|
|
4863
|
-
json.minItems = prefixItems.length;
|
|
4864
|
-
if (!rest) json.maxItems = prefixItems.length;
|
|
4865
|
-
} else {
|
|
4866
|
-
json.items = prefixItems;
|
|
4867
|
-
if (rest) json.additionalItems = rest;
|
|
4868
|
-
}
|
|
4869
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
4870
|
-
if ("number" == typeof minimum) json.minItems = minimum;
|
|
4871
|
-
if ("number" == typeof maximum) json.maxItems = maximum;
|
|
4872
|
-
};
|
|
4873
|
-
const recordProcessor = (schema, ctx, _json, params)=>{
|
|
4874
|
-
const json = _json;
|
|
4875
|
-
const def = schema._zod.def;
|
|
4876
|
-
json.type = "object";
|
|
4877
|
-
const keyType = def.keyType;
|
|
4878
|
-
const keyBag = keyType._zod.bag;
|
|
4879
|
-
const patterns = keyBag?.patterns;
|
|
4880
|
-
if ("loose" === def.mode && patterns && patterns.size > 0) {
|
|
4881
|
-
const valueSchema = to_json_schema_process(def.valueType, ctx, {
|
|
4882
|
-
...params,
|
|
4883
|
-
path: [
|
|
4884
|
-
...params.path,
|
|
4885
|
-
"patternProperties",
|
|
4886
|
-
"*"
|
|
4887
|
-
]
|
|
4888
|
-
});
|
|
4889
|
-
json.patternProperties = {};
|
|
4890
|
-
for (const pattern of patterns)json.patternProperties[pattern.source] = valueSchema;
|
|
4891
|
-
} else {
|
|
4892
|
-
if ("draft-07" === ctx.target || "draft-2020-12" === ctx.target) json.propertyNames = to_json_schema_process(def.keyType, ctx, {
|
|
4893
|
-
...params,
|
|
4894
|
-
path: [
|
|
4895
|
-
...params.path,
|
|
4896
|
-
"propertyNames"
|
|
4897
|
-
]
|
|
4898
|
-
});
|
|
4899
|
-
json.additionalProperties = to_json_schema_process(def.valueType, ctx, {
|
|
4900
|
-
...params,
|
|
4901
|
-
path: [
|
|
4902
|
-
...params.path,
|
|
4903
|
-
"additionalProperties"
|
|
4904
|
-
]
|
|
4905
|
-
});
|
|
4906
|
-
}
|
|
4907
|
-
const keyValues = keyType._zod.values;
|
|
4908
|
-
if (keyValues) {
|
|
4909
|
-
const validKeyValues = [
|
|
4910
|
-
...keyValues
|
|
4911
|
-
].filter((v)=>"string" == typeof v || "number" == typeof v);
|
|
4912
|
-
if (validKeyValues.length > 0) json.required = validKeyValues;
|
|
4913
|
-
}
|
|
4914
|
-
};
|
|
4915
2928
|
const nullableProcessor = (schema, ctx, json, params)=>{
|
|
4916
2929
|
const def = schema._zod.def;
|
|
4917
2930
|
const inner = to_json_schema_process(def.innerType, ctx, params);
|
|
@@ -4961,7 +2974,8 @@ const catchProcessor = (schema, ctx, json, params)=>{
|
|
|
4961
2974
|
};
|
|
4962
2975
|
const pipeProcessor = (schema, ctx, _json, params)=>{
|
|
4963
2976
|
const def = schema._zod.def;
|
|
4964
|
-
const
|
|
2977
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
2978
|
+
const innerType = "input" === ctx.io ? inIsTransform ? def.out : def.in : def.out;
|
|
4965
2979
|
to_json_schema_process(innerType, ctx, params);
|
|
4966
2980
|
const seen = ctx.seen.get(schema);
|
|
4967
2981
|
seen.ref = innerType;
|
|
@@ -4973,24 +2987,12 @@ const readonlyProcessor = (schema, ctx, json, params)=>{
|
|
|
4973
2987
|
seen.ref = def.innerType;
|
|
4974
2988
|
json.readOnly = true;
|
|
4975
2989
|
};
|
|
4976
|
-
const promiseProcessor = (schema, ctx, _json, params)=>{
|
|
4977
|
-
const def = schema._zod.def;
|
|
4978
|
-
to_json_schema_process(def.innerType, ctx, params);
|
|
4979
|
-
const seen = ctx.seen.get(schema);
|
|
4980
|
-
seen.ref = def.innerType;
|
|
4981
|
-
};
|
|
4982
2990
|
const optionalProcessor = (schema, ctx, _json, params)=>{
|
|
4983
2991
|
const def = schema._zod.def;
|
|
4984
2992
|
to_json_schema_process(def.innerType, ctx, params);
|
|
4985
2993
|
const seen = ctx.seen.get(schema);
|
|
4986
2994
|
seen.ref = def.innerType;
|
|
4987
2995
|
};
|
|
4988
|
-
const lazyProcessor = (schema, ctx, _json, params)=>{
|
|
4989
|
-
const innerType = schema._zod.innerType;
|
|
4990
|
-
to_json_schema_process(innerType, ctx, params);
|
|
4991
|
-
const seen = ctx.seen.get(schema);
|
|
4992
|
-
seen.ref = innerType;
|
|
4993
|
-
};
|
|
4994
2996
|
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def)=>{
|
|
4995
2997
|
$ZodISODateTime.init(inst, def);
|
|
4996
2998
|
ZodStringFormat.init(inst, def);
|
|
@@ -5048,12 +3050,11 @@ const classic_errors_initializer = (inst, issues)=>{
|
|
|
5048
3050
|
}
|
|
5049
3051
|
});
|
|
5050
3052
|
};
|
|
5051
|
-
$constructor("ZodError", classic_errors_initializer
|
|
5052
|
-
const ZodRealError = $constructor("ZodError", classic_errors_initializer, {
|
|
3053
|
+
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", classic_errors_initializer, {
|
|
5053
3054
|
Parent: Error
|
|
5054
3055
|
});
|
|
5055
|
-
const
|
|
5056
|
-
const
|
|
3056
|
+
const classic_parse_parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
3057
|
+
const classic_parse_parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
5057
3058
|
const parse_safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
5058
3059
|
const parse_safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
5059
3060
|
const parse_encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
@@ -5064,6 +3065,42 @@ const parse_safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
|
5064
3065
|
const parse_safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
5065
3066
|
const parse_safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
5066
3067
|
const parse_safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3068
|
+
const _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
3069
|
+
function _installLazyMethods(inst, group, methods) {
|
|
3070
|
+
const proto = Object.getPrototypeOf(inst);
|
|
3071
|
+
let installed = _installedGroups.get(proto);
|
|
3072
|
+
if (!installed) {
|
|
3073
|
+
installed = new Set();
|
|
3074
|
+
_installedGroups.set(proto, installed);
|
|
3075
|
+
}
|
|
3076
|
+
if (installed.has(group)) return;
|
|
3077
|
+
installed.add(group);
|
|
3078
|
+
for(const key in methods){
|
|
3079
|
+
const fn = methods[key];
|
|
3080
|
+
Object.defineProperty(proto, key, {
|
|
3081
|
+
configurable: true,
|
|
3082
|
+
enumerable: false,
|
|
3083
|
+
get () {
|
|
3084
|
+
const bound = fn.bind(this);
|
|
3085
|
+
Object.defineProperty(this, key, {
|
|
3086
|
+
configurable: true,
|
|
3087
|
+
writable: true,
|
|
3088
|
+
enumerable: true,
|
|
3089
|
+
value: bound
|
|
3090
|
+
});
|
|
3091
|
+
return bound;
|
|
3092
|
+
},
|
|
3093
|
+
set (v) {
|
|
3094
|
+
Object.defineProperty(this, key, {
|
|
3095
|
+
configurable: true,
|
|
3096
|
+
writable: true,
|
|
3097
|
+
enumerable: true,
|
|
3098
|
+
value: v
|
|
3099
|
+
});
|
|
3100
|
+
}
|
|
3101
|
+
});
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
5067
3104
|
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def)=>{
|
|
5068
3105
|
$ZodType.init(inst, def);
|
|
5069
3106
|
Object.assign(inst["~standard"], {
|
|
@@ -5078,34 +3115,11 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def)=>{
|
|
|
5078
3115
|
Object.defineProperty(inst, "_def", {
|
|
5079
3116
|
value: def
|
|
5080
3117
|
});
|
|
5081
|
-
inst.
|
|
5082
|
-
checks: [
|
|
5083
|
-
...def.checks ?? [],
|
|
5084
|
-
...checks.map((ch)=>"function" == typeof ch ? {
|
|
5085
|
-
_zod: {
|
|
5086
|
-
check: ch,
|
|
5087
|
-
def: {
|
|
5088
|
-
check: "custom"
|
|
5089
|
-
},
|
|
5090
|
-
onattach: []
|
|
5091
|
-
}
|
|
5092
|
-
} : ch)
|
|
5093
|
-
]
|
|
5094
|
-
}), {
|
|
5095
|
-
parent: true
|
|
5096
|
-
});
|
|
5097
|
-
inst.with = inst.check;
|
|
5098
|
-
inst.clone = (def, params)=>clone(inst, def, params);
|
|
5099
|
-
inst.brand = ()=>inst;
|
|
5100
|
-
inst.register = (reg, meta)=>{
|
|
5101
|
-
reg.add(inst, meta);
|
|
5102
|
-
return inst;
|
|
5103
|
-
};
|
|
5104
|
-
inst.parse = (data, params)=>parse_parse(inst, data, params, {
|
|
3118
|
+
inst.parse = (data, params)=>classic_parse_parse(inst, data, params, {
|
|
5105
3119
|
callee: inst.parse
|
|
5106
3120
|
});
|
|
5107
3121
|
inst.safeParse = (data, params)=>parse_safeParse(inst, data, params);
|
|
5108
|
-
inst.parseAsync = async (data, params)=>
|
|
3122
|
+
inst.parseAsync = async (data, params)=>classic_parse_parseAsync(inst, data, params, {
|
|
5109
3123
|
callee: inst.parseAsync
|
|
5110
3124
|
});
|
|
5111
3125
|
inst.safeParseAsync = async (data, params)=>parse_safeParseAsync(inst, data, params);
|
|
@@ -5118,48 +3132,122 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def)=>{
|
|
|
5118
3132
|
inst.safeDecode = (data, params)=>parse_safeDecode(inst, data, params);
|
|
5119
3133
|
inst.safeEncodeAsync = async (data, params)=>parse_safeEncodeAsync(inst, data, params);
|
|
5120
3134
|
inst.safeDecodeAsync = async (data, params)=>parse_safeDecodeAsync(inst, data, params);
|
|
5121
|
-
inst
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
3135
|
+
_installLazyMethods(inst, "ZodType", {
|
|
3136
|
+
check (...chks) {
|
|
3137
|
+
const def = this.def;
|
|
3138
|
+
return this.clone(mergeDefs(def, {
|
|
3139
|
+
checks: [
|
|
3140
|
+
...def.checks ?? [],
|
|
3141
|
+
...chks.map((ch)=>"function" == typeof ch ? {
|
|
3142
|
+
_zod: {
|
|
3143
|
+
check: ch,
|
|
3144
|
+
def: {
|
|
3145
|
+
check: "custom"
|
|
3146
|
+
},
|
|
3147
|
+
onattach: []
|
|
3148
|
+
}
|
|
3149
|
+
} : ch)
|
|
3150
|
+
]
|
|
3151
|
+
}), {
|
|
3152
|
+
parent: true
|
|
3153
|
+
});
|
|
3154
|
+
},
|
|
3155
|
+
with (...chks) {
|
|
3156
|
+
return this.check(...chks);
|
|
3157
|
+
},
|
|
3158
|
+
clone (def, params) {
|
|
3159
|
+
return clone(this, def, params);
|
|
3160
|
+
},
|
|
3161
|
+
brand () {
|
|
3162
|
+
return this;
|
|
3163
|
+
},
|
|
3164
|
+
register (reg, meta) {
|
|
3165
|
+
reg.add(this, meta);
|
|
3166
|
+
return this;
|
|
3167
|
+
},
|
|
3168
|
+
refine (check, params) {
|
|
3169
|
+
return this.check(refine(check, params));
|
|
3170
|
+
},
|
|
3171
|
+
superRefine (refinement, params) {
|
|
3172
|
+
return this.check(superRefine(refinement, params));
|
|
3173
|
+
},
|
|
3174
|
+
overwrite (fn) {
|
|
3175
|
+
return this.check(_overwrite(fn));
|
|
3176
|
+
},
|
|
3177
|
+
optional () {
|
|
3178
|
+
return optional(this);
|
|
3179
|
+
},
|
|
3180
|
+
exactOptional () {
|
|
3181
|
+
return exactOptional(this);
|
|
3182
|
+
},
|
|
3183
|
+
nullable () {
|
|
3184
|
+
return nullable(this);
|
|
3185
|
+
},
|
|
3186
|
+
nullish () {
|
|
3187
|
+
return optional(nullable(this));
|
|
3188
|
+
},
|
|
3189
|
+
nonoptional (params) {
|
|
3190
|
+
return nonoptional(this, params);
|
|
3191
|
+
},
|
|
3192
|
+
array () {
|
|
3193
|
+
return schemas_array(this);
|
|
3194
|
+
},
|
|
3195
|
+
or (arg) {
|
|
3196
|
+
return union([
|
|
3197
|
+
this,
|
|
3198
|
+
arg
|
|
3199
|
+
]);
|
|
3200
|
+
},
|
|
3201
|
+
and (arg) {
|
|
3202
|
+
return intersection(this, arg);
|
|
3203
|
+
},
|
|
3204
|
+
transform (tx) {
|
|
3205
|
+
return pipe(this, transform(tx));
|
|
3206
|
+
},
|
|
3207
|
+
default (d) {
|
|
3208
|
+
return schemas_default(this, d);
|
|
3209
|
+
},
|
|
3210
|
+
prefault (d) {
|
|
3211
|
+
return prefault(this, d);
|
|
3212
|
+
},
|
|
3213
|
+
catch (params) {
|
|
3214
|
+
return schemas_catch(this, params);
|
|
3215
|
+
},
|
|
3216
|
+
pipe (target) {
|
|
3217
|
+
return pipe(this, target);
|
|
3218
|
+
},
|
|
3219
|
+
readonly () {
|
|
3220
|
+
return readonly(this);
|
|
3221
|
+
},
|
|
3222
|
+
describe (description) {
|
|
3223
|
+
const cl = this.clone();
|
|
3224
|
+
globalRegistry.add(cl, {
|
|
3225
|
+
description
|
|
3226
|
+
});
|
|
3227
|
+
return cl;
|
|
3228
|
+
},
|
|
3229
|
+
meta (...args) {
|
|
3230
|
+
if (0 === args.length) return globalRegistry.get(this);
|
|
3231
|
+
const cl = this.clone();
|
|
3232
|
+
globalRegistry.add(cl, args[0]);
|
|
3233
|
+
return cl;
|
|
3234
|
+
},
|
|
3235
|
+
isOptional () {
|
|
3236
|
+
return this.safeParse(void 0).success;
|
|
3237
|
+
},
|
|
3238
|
+
isNullable () {
|
|
3239
|
+
return this.safeParse(null).success;
|
|
3240
|
+
},
|
|
3241
|
+
apply (fn) {
|
|
3242
|
+
return fn(this);
|
|
3243
|
+
}
|
|
3244
|
+
});
|
|
5148
3245
|
Object.defineProperty(inst, "description", {
|
|
5149
3246
|
get () {
|
|
5150
|
-
return
|
|
3247
|
+
return globalRegistry.get(inst)?.description;
|
|
5151
3248
|
},
|
|
5152
3249
|
configurable: true
|
|
5153
3250
|
});
|
|
5154
|
-
inst.meta = (...args)=>{
|
|
5155
|
-
if (0 === args.length) return registries_globalRegistry.get(inst);
|
|
5156
|
-
const cl = inst.clone();
|
|
5157
|
-
registries_globalRegistry.add(cl, args[0]);
|
|
5158
|
-
return cl;
|
|
5159
|
-
};
|
|
5160
|
-
inst.isOptional = ()=>inst.safeParse(void 0).success;
|
|
5161
|
-
inst.isNullable = ()=>inst.safeParse(null).success;
|
|
5162
|
-
inst.apply = (fn)=>fn(inst);
|
|
5163
3251
|
return inst;
|
|
5164
3252
|
});
|
|
5165
3253
|
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def)=>{
|
|
@@ -5170,21 +3258,53 @@ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def)=>{
|
|
|
5170
3258
|
inst.format = bag.format ?? null;
|
|
5171
3259
|
inst.minLength = bag.minimum ?? null;
|
|
5172
3260
|
inst.maxLength = bag.maximum ?? null;
|
|
5173
|
-
inst
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
3261
|
+
_installLazyMethods(inst, "_ZodString", {
|
|
3262
|
+
regex (...args) {
|
|
3263
|
+
return this.check(_regex(...args));
|
|
3264
|
+
},
|
|
3265
|
+
includes (...args) {
|
|
3266
|
+
return this.check(_includes(...args));
|
|
3267
|
+
},
|
|
3268
|
+
startsWith (...args) {
|
|
3269
|
+
return this.check(_startsWith(...args));
|
|
3270
|
+
},
|
|
3271
|
+
endsWith (...args) {
|
|
3272
|
+
return this.check(_endsWith(...args));
|
|
3273
|
+
},
|
|
3274
|
+
min (...args) {
|
|
3275
|
+
return this.check(_minLength(...args));
|
|
3276
|
+
},
|
|
3277
|
+
max (...args) {
|
|
3278
|
+
return this.check(_maxLength(...args));
|
|
3279
|
+
},
|
|
3280
|
+
length (...args) {
|
|
3281
|
+
return this.check(_length(...args));
|
|
3282
|
+
},
|
|
3283
|
+
nonempty (...args) {
|
|
3284
|
+
return this.check(_minLength(1, ...args));
|
|
3285
|
+
},
|
|
3286
|
+
lowercase (params) {
|
|
3287
|
+
return this.check(_lowercase(params));
|
|
3288
|
+
},
|
|
3289
|
+
uppercase (params) {
|
|
3290
|
+
return this.check(_uppercase(params));
|
|
3291
|
+
},
|
|
3292
|
+
trim () {
|
|
3293
|
+
return this.check(_trim());
|
|
3294
|
+
},
|
|
3295
|
+
normalize (...args) {
|
|
3296
|
+
return this.check(_normalize(...args));
|
|
3297
|
+
},
|
|
3298
|
+
toLowerCase () {
|
|
3299
|
+
return this.check(_toLowerCase());
|
|
3300
|
+
},
|
|
3301
|
+
toUpperCase () {
|
|
3302
|
+
return this.check(_toUpperCase());
|
|
3303
|
+
},
|
|
3304
|
+
slugify () {
|
|
3305
|
+
return this.check(_slugify());
|
|
3306
|
+
}
|
|
3307
|
+
});
|
|
5188
3308
|
});
|
|
5189
3309
|
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def)=>{
|
|
5190
3310
|
$ZodString.init(inst, def);
|
|
@@ -5228,226 +3348,78 @@ const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def)=>{
|
|
|
5228
3348
|
$ZodEmail.init(inst, def);
|
|
5229
3349
|
ZodStringFormat.init(inst, def);
|
|
5230
3350
|
});
|
|
5231
|
-
function schemas_email(params) {
|
|
5232
|
-
return _email(ZodEmail, params);
|
|
5233
|
-
}
|
|
5234
3351
|
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def)=>{
|
|
5235
3352
|
$ZodGUID.init(inst, def);
|
|
5236
3353
|
ZodStringFormat.init(inst, def);
|
|
5237
3354
|
});
|
|
5238
|
-
function schemas_guid(params) {
|
|
5239
|
-
return _guid(ZodGUID, params);
|
|
5240
|
-
}
|
|
5241
3355
|
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def)=>{
|
|
5242
3356
|
$ZodUUID.init(inst, def);
|
|
5243
3357
|
ZodStringFormat.init(inst, def);
|
|
5244
3358
|
});
|
|
5245
|
-
function schemas_uuid(params) {
|
|
5246
|
-
return _uuid(ZodUUID, params);
|
|
5247
|
-
}
|
|
5248
|
-
function uuidv4(params) {
|
|
5249
|
-
return _uuidv4(ZodUUID, params);
|
|
5250
|
-
}
|
|
5251
|
-
function uuidv6(params) {
|
|
5252
|
-
return _uuidv6(ZodUUID, params);
|
|
5253
|
-
}
|
|
5254
|
-
function uuidv7(params) {
|
|
5255
|
-
return _uuidv7(ZodUUID, params);
|
|
5256
|
-
}
|
|
5257
3359
|
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def)=>{
|
|
5258
3360
|
$ZodURL.init(inst, def);
|
|
5259
3361
|
ZodStringFormat.init(inst, def);
|
|
5260
3362
|
});
|
|
5261
|
-
function schemas_url(params) {
|
|
5262
|
-
return _url(ZodURL, params);
|
|
5263
|
-
}
|
|
5264
|
-
function httpUrl(params) {
|
|
5265
|
-
return _url(ZodURL, {
|
|
5266
|
-
protocol: /^https?$/,
|
|
5267
|
-
hostname: domain,
|
|
5268
|
-
...normalizeParams(params)
|
|
5269
|
-
});
|
|
5270
|
-
}
|
|
5271
3363
|
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def)=>{
|
|
5272
3364
|
$ZodEmoji.init(inst, def);
|
|
5273
3365
|
ZodStringFormat.init(inst, def);
|
|
5274
3366
|
});
|
|
5275
|
-
function schemas_emoji(params) {
|
|
5276
|
-
return api_emoji(ZodEmoji, params);
|
|
5277
|
-
}
|
|
5278
3367
|
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def)=>{
|
|
5279
3368
|
$ZodNanoID.init(inst, def);
|
|
5280
3369
|
ZodStringFormat.init(inst, def);
|
|
5281
3370
|
});
|
|
5282
|
-
function schemas_nanoid(params) {
|
|
5283
|
-
return _nanoid(ZodNanoID, params);
|
|
5284
|
-
}
|
|
5285
3371
|
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def)=>{
|
|
5286
3372
|
$ZodCUID.init(inst, def);
|
|
5287
3373
|
ZodStringFormat.init(inst, def);
|
|
5288
3374
|
});
|
|
5289
|
-
function schemas_cuid(params) {
|
|
5290
|
-
return _cuid(ZodCUID, params);
|
|
5291
|
-
}
|
|
5292
3375
|
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def)=>{
|
|
5293
3376
|
$ZodCUID2.init(inst, def);
|
|
5294
3377
|
ZodStringFormat.init(inst, def);
|
|
5295
3378
|
});
|
|
5296
|
-
function schemas_cuid2(params) {
|
|
5297
|
-
return _cuid2(ZodCUID2, params);
|
|
5298
|
-
}
|
|
5299
3379
|
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def)=>{
|
|
5300
3380
|
$ZodULID.init(inst, def);
|
|
5301
3381
|
ZodStringFormat.init(inst, def);
|
|
5302
3382
|
});
|
|
5303
|
-
function schemas_ulid(params) {
|
|
5304
|
-
return _ulid(ZodULID, params);
|
|
5305
|
-
}
|
|
5306
3383
|
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def)=>{
|
|
5307
3384
|
$ZodXID.init(inst, def);
|
|
5308
3385
|
ZodStringFormat.init(inst, def);
|
|
5309
3386
|
});
|
|
5310
|
-
function schemas_xid(params) {
|
|
5311
|
-
return _xid(ZodXID, params);
|
|
5312
|
-
}
|
|
5313
3387
|
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def)=>{
|
|
5314
3388
|
$ZodKSUID.init(inst, def);
|
|
5315
3389
|
ZodStringFormat.init(inst, def);
|
|
5316
3390
|
});
|
|
5317
|
-
function schemas_ksuid(params) {
|
|
5318
|
-
return _ksuid(ZodKSUID, params);
|
|
5319
|
-
}
|
|
5320
3391
|
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def)=>{
|
|
5321
3392
|
$ZodIPv4.init(inst, def);
|
|
5322
3393
|
ZodStringFormat.init(inst, def);
|
|
5323
3394
|
});
|
|
5324
|
-
function schemas_ipv4(params) {
|
|
5325
|
-
return _ipv4(ZodIPv4, params);
|
|
5326
|
-
}
|
|
5327
|
-
const ZodMAC = /*@__PURE__*/ $constructor("ZodMAC", (inst, def)=>{
|
|
5328
|
-
$ZodMAC.init(inst, def);
|
|
5329
|
-
ZodStringFormat.init(inst, def);
|
|
5330
|
-
});
|
|
5331
|
-
function schemas_mac(params) {
|
|
5332
|
-
return _mac(ZodMAC, params);
|
|
5333
|
-
}
|
|
5334
3395
|
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def)=>{
|
|
5335
3396
|
$ZodIPv6.init(inst, def);
|
|
5336
3397
|
ZodStringFormat.init(inst, def);
|
|
5337
3398
|
});
|
|
5338
|
-
function schemas_ipv6(params) {
|
|
5339
|
-
return _ipv6(ZodIPv6, params);
|
|
5340
|
-
}
|
|
5341
3399
|
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def)=>{
|
|
5342
3400
|
$ZodCIDRv4.init(inst, def);
|
|
5343
3401
|
ZodStringFormat.init(inst, def);
|
|
5344
3402
|
});
|
|
5345
|
-
function schemas_cidrv4(params) {
|
|
5346
|
-
return _cidrv4(ZodCIDRv4, params);
|
|
5347
|
-
}
|
|
5348
3403
|
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def)=>{
|
|
5349
3404
|
$ZodCIDRv6.init(inst, def);
|
|
5350
3405
|
ZodStringFormat.init(inst, def);
|
|
5351
3406
|
});
|
|
5352
|
-
function schemas_cidrv6(params) {
|
|
5353
|
-
return _cidrv6(ZodCIDRv6, params);
|
|
5354
|
-
}
|
|
5355
3407
|
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def)=>{
|
|
5356
3408
|
$ZodBase64.init(inst, def);
|
|
5357
3409
|
ZodStringFormat.init(inst, def);
|
|
5358
3410
|
});
|
|
5359
|
-
function schemas_base64(params) {
|
|
5360
|
-
return _base64(ZodBase64, params);
|
|
5361
|
-
}
|
|
5362
3411
|
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def)=>{
|
|
5363
3412
|
$ZodBase64URL.init(inst, def);
|
|
5364
3413
|
ZodStringFormat.init(inst, def);
|
|
5365
3414
|
});
|
|
5366
|
-
function schemas_base64url(params) {
|
|
5367
|
-
return _base64url(ZodBase64URL, params);
|
|
5368
|
-
}
|
|
5369
3415
|
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def)=>{
|
|
5370
3416
|
$ZodE164.init(inst, def);
|
|
5371
3417
|
ZodStringFormat.init(inst, def);
|
|
5372
3418
|
});
|
|
5373
|
-
function schemas_e164(params) {
|
|
5374
|
-
return _e164(ZodE164, params);
|
|
5375
|
-
}
|
|
5376
3419
|
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def)=>{
|
|
5377
3420
|
$ZodJWT.init(inst, def);
|
|
5378
3421
|
ZodStringFormat.init(inst, def);
|
|
5379
3422
|
});
|
|
5380
|
-
function jwt(params) {
|
|
5381
|
-
return _jwt(ZodJWT, params);
|
|
5382
|
-
}
|
|
5383
|
-
const ZodCustomStringFormat = /*@__PURE__*/ $constructor("ZodCustomStringFormat", (inst, def)=>{
|
|
5384
|
-
$ZodCustomStringFormat.init(inst, def);
|
|
5385
|
-
ZodStringFormat.init(inst, def);
|
|
5386
|
-
});
|
|
5387
|
-
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
5388
|
-
return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
5389
|
-
}
|
|
5390
|
-
function schemas_hostname(_params) {
|
|
5391
|
-
return _stringFormat(ZodCustomStringFormat, "hostname", hostname, _params);
|
|
5392
|
-
}
|
|
5393
|
-
function schemas_hex(_params) {
|
|
5394
|
-
return _stringFormat(ZodCustomStringFormat, "hex", regexes_hex, _params);
|
|
5395
|
-
}
|
|
5396
|
-
function hash(alg, params) {
|
|
5397
|
-
const enc = params?.enc ?? "hex";
|
|
5398
|
-
const format = `${alg}_${enc}`;
|
|
5399
|
-
const regex = regexes_namespaceObject[format];
|
|
5400
|
-
if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
|
|
5401
|
-
return _stringFormat(ZodCustomStringFormat, format, regex, params);
|
|
5402
|
-
}
|
|
5403
|
-
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def)=>{
|
|
5404
|
-
$ZodNumber.init(inst, def);
|
|
5405
|
-
ZodType.init(inst, def);
|
|
5406
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>numberProcessor(inst, ctx, json, params);
|
|
5407
|
-
inst.gt = (value, params)=>inst.check(_gt(value, params));
|
|
5408
|
-
inst.gte = (value, params)=>inst.check(_gte(value, params));
|
|
5409
|
-
inst.min = (value, params)=>inst.check(_gte(value, params));
|
|
5410
|
-
inst.lt = (value, params)=>inst.check(_lt(value, params));
|
|
5411
|
-
inst.lte = (value, params)=>inst.check(_lte(value, params));
|
|
5412
|
-
inst.max = (value, params)=>inst.check(_lte(value, params));
|
|
5413
|
-
inst.int = (params)=>inst.check(schemas_int(params));
|
|
5414
|
-
inst.safe = (params)=>inst.check(schemas_int(params));
|
|
5415
|
-
inst.positive = (params)=>inst.check(_gt(0, params));
|
|
5416
|
-
inst.nonnegative = (params)=>inst.check(_gte(0, params));
|
|
5417
|
-
inst.negative = (params)=>inst.check(_lt(0, params));
|
|
5418
|
-
inst.nonpositive = (params)=>inst.check(_lte(0, params));
|
|
5419
|
-
inst.multipleOf = (value, params)=>inst.check(_multipleOf(value, params));
|
|
5420
|
-
inst.step = (value, params)=>inst.check(_multipleOf(value, params));
|
|
5421
|
-
inst.finite = ()=>inst;
|
|
5422
|
-
const bag = inst._zod.bag;
|
|
5423
|
-
inst.minValue = Math.max(bag.minimum ?? -1 / 0, bag.exclusiveMinimum ?? -1 / 0) ?? null;
|
|
5424
|
-
inst.maxValue = Math.min(bag.maximum ?? 1 / 0, bag.exclusiveMaximum ?? 1 / 0) ?? null;
|
|
5425
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
5426
|
-
inst.isFinite = true;
|
|
5427
|
-
inst.format = bag.format ?? null;
|
|
5428
|
-
});
|
|
5429
|
-
function schemas_number(params) {
|
|
5430
|
-
return _number(ZodNumber, params);
|
|
5431
|
-
}
|
|
5432
|
-
const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def)=>{
|
|
5433
|
-
$ZodNumberFormat.init(inst, def);
|
|
5434
|
-
ZodNumber.init(inst, def);
|
|
5435
|
-
});
|
|
5436
|
-
function schemas_int(params) {
|
|
5437
|
-
return _int(ZodNumberFormat, params);
|
|
5438
|
-
}
|
|
5439
|
-
function float32(params) {
|
|
5440
|
-
return _float32(ZodNumberFormat, params);
|
|
5441
|
-
}
|
|
5442
|
-
function float64(params) {
|
|
5443
|
-
return _float64(ZodNumberFormat, params);
|
|
5444
|
-
}
|
|
5445
|
-
function int32(params) {
|
|
5446
|
-
return _int32(ZodNumberFormat, params);
|
|
5447
|
-
}
|
|
5448
|
-
function uint32(params) {
|
|
5449
|
-
return _uint32(ZodNumberFormat, params);
|
|
5450
|
-
}
|
|
5451
3423
|
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def)=>{
|
|
5452
3424
|
$ZodBoolean.init(inst, def);
|
|
5453
3425
|
ZodType.init(inst, def);
|
|
@@ -5456,73 +3428,6 @@ const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def)=>{
|
|
|
5456
3428
|
function schemas_boolean(params) {
|
|
5457
3429
|
return _boolean(ZodBoolean, params);
|
|
5458
3430
|
}
|
|
5459
|
-
const ZodBigInt = /*@__PURE__*/ $constructor("ZodBigInt", (inst, def)=>{
|
|
5460
|
-
$ZodBigInt.init(inst, def);
|
|
5461
|
-
ZodType.init(inst, def);
|
|
5462
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>bigintProcessor(inst, ctx, json, params);
|
|
5463
|
-
inst.gte = (value, params)=>inst.check(_gte(value, params));
|
|
5464
|
-
inst.min = (value, params)=>inst.check(_gte(value, params));
|
|
5465
|
-
inst.gt = (value, params)=>inst.check(_gt(value, params));
|
|
5466
|
-
inst.gte = (value, params)=>inst.check(_gte(value, params));
|
|
5467
|
-
inst.min = (value, params)=>inst.check(_gte(value, params));
|
|
5468
|
-
inst.lt = (value, params)=>inst.check(_lt(value, params));
|
|
5469
|
-
inst.lte = (value, params)=>inst.check(_lte(value, params));
|
|
5470
|
-
inst.max = (value, params)=>inst.check(_lte(value, params));
|
|
5471
|
-
inst.positive = (params)=>inst.check(_gt(BigInt(0), params));
|
|
5472
|
-
inst.negative = (params)=>inst.check(_lt(BigInt(0), params));
|
|
5473
|
-
inst.nonpositive = (params)=>inst.check(_lte(BigInt(0), params));
|
|
5474
|
-
inst.nonnegative = (params)=>inst.check(_gte(BigInt(0), params));
|
|
5475
|
-
inst.multipleOf = (value, params)=>inst.check(_multipleOf(value, params));
|
|
5476
|
-
const bag = inst._zod.bag;
|
|
5477
|
-
inst.minValue = bag.minimum ?? null;
|
|
5478
|
-
inst.maxValue = bag.maximum ?? null;
|
|
5479
|
-
inst.format = bag.format ?? null;
|
|
5480
|
-
});
|
|
5481
|
-
function schemas_bigint(params) {
|
|
5482
|
-
return _bigint(ZodBigInt, params);
|
|
5483
|
-
}
|
|
5484
|
-
const ZodBigIntFormat = /*@__PURE__*/ $constructor("ZodBigIntFormat", (inst, def)=>{
|
|
5485
|
-
$ZodBigIntFormat.init(inst, def);
|
|
5486
|
-
ZodBigInt.init(inst, def);
|
|
5487
|
-
});
|
|
5488
|
-
function int64(params) {
|
|
5489
|
-
return _int64(ZodBigIntFormat, params);
|
|
5490
|
-
}
|
|
5491
|
-
function uint64(params) {
|
|
5492
|
-
return _uint64(ZodBigIntFormat, params);
|
|
5493
|
-
}
|
|
5494
|
-
const ZodSymbol = /*@__PURE__*/ $constructor("ZodSymbol", (inst, def)=>{
|
|
5495
|
-
$ZodSymbol.init(inst, def);
|
|
5496
|
-
ZodType.init(inst, def);
|
|
5497
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>symbolProcessor(inst, ctx, json, params);
|
|
5498
|
-
});
|
|
5499
|
-
function symbol(params) {
|
|
5500
|
-
return _symbol(ZodSymbol, params);
|
|
5501
|
-
}
|
|
5502
|
-
const ZodUndefined = /*@__PURE__*/ $constructor("ZodUndefined", (inst, def)=>{
|
|
5503
|
-
$ZodUndefined.init(inst, def);
|
|
5504
|
-
ZodType.init(inst, def);
|
|
5505
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>undefinedProcessor(inst, ctx, json, params);
|
|
5506
|
-
});
|
|
5507
|
-
function schemas_undefined(params) {
|
|
5508
|
-
return api_undefined(ZodUndefined, params);
|
|
5509
|
-
}
|
|
5510
|
-
const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def)=>{
|
|
5511
|
-
$ZodNull.init(inst, def);
|
|
5512
|
-
ZodType.init(inst, def);
|
|
5513
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>nullProcessor(inst, ctx, json, params);
|
|
5514
|
-
});
|
|
5515
|
-
function schemas_null(params) {
|
|
5516
|
-
return api_null(ZodNull, params);
|
|
5517
|
-
}
|
|
5518
|
-
const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def)=>{
|
|
5519
|
-
$ZodAny.init(inst, def);
|
|
5520
|
-
ZodType.init(inst, def);
|
|
5521
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>anyProcessor(inst, ctx, json, params);
|
|
5522
|
-
});
|
|
5523
|
-
function any() {
|
|
5524
|
-
return _any(ZodAny);
|
|
5525
|
-
}
|
|
5526
3431
|
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def)=>{
|
|
5527
3432
|
$ZodUnknown.init(inst, def);
|
|
5528
3433
|
ZodType.init(inst, def);
|
|
@@ -5539,78 +3444,93 @@ const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def)=>{
|
|
|
5539
3444
|
function never(params) {
|
|
5540
3445
|
return _never(ZodNever, params);
|
|
5541
3446
|
}
|
|
5542
|
-
const ZodVoid = /*@__PURE__*/ $constructor("ZodVoid", (inst, def)=>{
|
|
5543
|
-
$ZodVoid.init(inst, def);
|
|
5544
|
-
ZodType.init(inst, def);
|
|
5545
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>voidProcessor(inst, ctx, json, params);
|
|
5546
|
-
});
|
|
5547
|
-
function schemas_void(params) {
|
|
5548
|
-
return _void(ZodVoid, params);
|
|
5549
|
-
}
|
|
5550
|
-
const ZodDate = /*@__PURE__*/ $constructor("ZodDate", (inst, def)=>{
|
|
5551
|
-
$ZodDate.init(inst, def);
|
|
5552
|
-
ZodType.init(inst, def);
|
|
5553
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>dateProcessor(inst, ctx, json, params);
|
|
5554
|
-
inst.min = (value, params)=>inst.check(_gte(value, params));
|
|
5555
|
-
inst.max = (value, params)=>inst.check(_lte(value, params));
|
|
5556
|
-
const c = inst._zod.bag;
|
|
5557
|
-
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
5558
|
-
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
5559
|
-
});
|
|
5560
|
-
function schemas_date(params) {
|
|
5561
|
-
return _date(ZodDate, params);
|
|
5562
|
-
}
|
|
5563
3447
|
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def)=>{
|
|
5564
3448
|
$ZodArray.init(inst, def);
|
|
5565
3449
|
ZodType.init(inst, def);
|
|
5566
3450
|
inst._zod.processJSONSchema = (ctx, json, params)=>arrayProcessor(inst, ctx, json, params);
|
|
5567
3451
|
inst.element = def.element;
|
|
5568
|
-
inst
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
3452
|
+
_installLazyMethods(inst, "ZodArray", {
|
|
3453
|
+
min (n, params) {
|
|
3454
|
+
return this.check(_minLength(n, params));
|
|
3455
|
+
},
|
|
3456
|
+
nonempty (params) {
|
|
3457
|
+
return this.check(_minLength(1, params));
|
|
3458
|
+
},
|
|
3459
|
+
max (n, params) {
|
|
3460
|
+
return this.check(_maxLength(n, params));
|
|
3461
|
+
},
|
|
3462
|
+
length (n, params) {
|
|
3463
|
+
return this.check(_length(n, params));
|
|
3464
|
+
},
|
|
3465
|
+
unwrap () {
|
|
3466
|
+
return this.element;
|
|
3467
|
+
}
|
|
3468
|
+
});
|
|
5573
3469
|
});
|
|
5574
3470
|
function schemas_array(element, params) {
|
|
5575
3471
|
return _array(ZodArray, element, params);
|
|
5576
3472
|
}
|
|
5577
|
-
function keyof(schema) {
|
|
5578
|
-
const shape = schema._zod.def.shape;
|
|
5579
|
-
return schemas_enum(Object.keys(shape));
|
|
5580
|
-
}
|
|
5581
3473
|
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def)=>{
|
|
5582
3474
|
$ZodObjectJIT.init(inst, def);
|
|
5583
3475
|
ZodType.init(inst, def);
|
|
5584
3476
|
inst._zod.processJSONSchema = (ctx, json, params)=>objectProcessor(inst, ctx, json, params);
|
|
5585
3477
|
defineLazy(inst, "shape", ()=>def.shape);
|
|
5586
|
-
inst
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
3478
|
+
_installLazyMethods(inst, "ZodObject", {
|
|
3479
|
+
keyof () {
|
|
3480
|
+
return schemas_enum(Object.keys(this._zod.def.shape));
|
|
3481
|
+
},
|
|
3482
|
+
catchall (catchall) {
|
|
3483
|
+
return this.clone({
|
|
3484
|
+
...this._zod.def,
|
|
3485
|
+
catchall: catchall
|
|
3486
|
+
});
|
|
3487
|
+
},
|
|
3488
|
+
passthrough () {
|
|
3489
|
+
return this.clone({
|
|
3490
|
+
...this._zod.def,
|
|
3491
|
+
catchall: unknown()
|
|
3492
|
+
});
|
|
3493
|
+
},
|
|
3494
|
+
loose () {
|
|
3495
|
+
return this.clone({
|
|
3496
|
+
...this._zod.def,
|
|
3497
|
+
catchall: unknown()
|
|
3498
|
+
});
|
|
3499
|
+
},
|
|
3500
|
+
strict () {
|
|
3501
|
+
return this.clone({
|
|
3502
|
+
...this._zod.def,
|
|
3503
|
+
catchall: never()
|
|
3504
|
+
});
|
|
3505
|
+
},
|
|
3506
|
+
strip () {
|
|
3507
|
+
return this.clone({
|
|
3508
|
+
...this._zod.def,
|
|
3509
|
+
catchall: void 0
|
|
3510
|
+
});
|
|
3511
|
+
},
|
|
3512
|
+
extend (incoming) {
|
|
3513
|
+
return extend(this, incoming);
|
|
3514
|
+
},
|
|
3515
|
+
safeExtend (incoming) {
|
|
3516
|
+
return safeExtend(this, incoming);
|
|
3517
|
+
},
|
|
3518
|
+
merge (other) {
|
|
3519
|
+
return merge(this, other);
|
|
3520
|
+
},
|
|
3521
|
+
pick (mask) {
|
|
3522
|
+
return pick(this, mask);
|
|
3523
|
+
},
|
|
3524
|
+
omit (mask) {
|
|
3525
|
+
return omit(this, mask);
|
|
3526
|
+
},
|
|
3527
|
+
partial (...args) {
|
|
3528
|
+
return partial(ZodOptional, this, args[0]);
|
|
3529
|
+
},
|
|
3530
|
+
required (...args) {
|
|
3531
|
+
return required(ZodNonOptional, this, args[0]);
|
|
3532
|
+
}
|
|
3533
|
+
});
|
|
5614
3534
|
});
|
|
5615
3535
|
function schemas_object(shape, params) {
|
|
5616
3536
|
const def = {
|
|
@@ -5620,22 +3540,6 @@ function schemas_object(shape, params) {
|
|
|
5620
3540
|
};
|
|
5621
3541
|
return new ZodObject(def);
|
|
5622
3542
|
}
|
|
5623
|
-
function strictObject(shape, params) {
|
|
5624
|
-
return new ZodObject({
|
|
5625
|
-
type: "object",
|
|
5626
|
-
shape,
|
|
5627
|
-
catchall: never(),
|
|
5628
|
-
...normalizeParams(params)
|
|
5629
|
-
});
|
|
5630
|
-
}
|
|
5631
|
-
function looseObject(shape, params) {
|
|
5632
|
-
return new ZodObject({
|
|
5633
|
-
type: "object",
|
|
5634
|
-
shape,
|
|
5635
|
-
catchall: unknown(),
|
|
5636
|
-
...normalizeParams(params)
|
|
5637
|
-
});
|
|
5638
|
-
}
|
|
5639
3543
|
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def)=>{
|
|
5640
3544
|
$ZodUnion.init(inst, def);
|
|
5641
3545
|
ZodType.init(inst, def);
|
|
@@ -5649,32 +3553,6 @@ function union(options, params) {
|
|
|
5649
3553
|
...normalizeParams(params)
|
|
5650
3554
|
});
|
|
5651
3555
|
}
|
|
5652
|
-
const ZodXor = /*@__PURE__*/ $constructor("ZodXor", (inst, def)=>{
|
|
5653
|
-
ZodUnion.init(inst, def);
|
|
5654
|
-
$ZodXor.init(inst, def);
|
|
5655
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>unionProcessor(inst, ctx, json, params);
|
|
5656
|
-
inst.options = def.options;
|
|
5657
|
-
});
|
|
5658
|
-
function xor(options, params) {
|
|
5659
|
-
return new ZodXor({
|
|
5660
|
-
type: "union",
|
|
5661
|
-
options: options,
|
|
5662
|
-
inclusive: false,
|
|
5663
|
-
...normalizeParams(params)
|
|
5664
|
-
});
|
|
5665
|
-
}
|
|
5666
|
-
const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def)=>{
|
|
5667
|
-
ZodUnion.init(inst, def);
|
|
5668
|
-
$ZodDiscriminatedUnion.init(inst, def);
|
|
5669
|
-
});
|
|
5670
|
-
function discriminatedUnion(discriminator, options, params) {
|
|
5671
|
-
return new ZodDiscriminatedUnion({
|
|
5672
|
-
type: "union",
|
|
5673
|
-
options,
|
|
5674
|
-
discriminator,
|
|
5675
|
-
...normalizeParams(params)
|
|
5676
|
-
});
|
|
5677
|
-
}
|
|
5678
3556
|
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def)=>{
|
|
5679
3557
|
$ZodIntersection.init(inst, def);
|
|
5680
3558
|
ZodType.init(inst, def);
|
|
@@ -5687,95 +3565,6 @@ function intersection(left, right) {
|
|
|
5687
3565
|
right: right
|
|
5688
3566
|
});
|
|
5689
3567
|
}
|
|
5690
|
-
const ZodTuple = /*@__PURE__*/ $constructor("ZodTuple", (inst, def)=>{
|
|
5691
|
-
$ZodTuple.init(inst, def);
|
|
5692
|
-
ZodType.init(inst, def);
|
|
5693
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>tupleProcessor(inst, ctx, json, params);
|
|
5694
|
-
inst.rest = (rest)=>inst.clone({
|
|
5695
|
-
...inst._zod.def,
|
|
5696
|
-
rest: rest
|
|
5697
|
-
});
|
|
5698
|
-
});
|
|
5699
|
-
function tuple(items, _paramsOrRest, _params) {
|
|
5700
|
-
const hasRest = _paramsOrRest instanceof $ZodType;
|
|
5701
|
-
const params = hasRest ? _params : _paramsOrRest;
|
|
5702
|
-
const rest = hasRest ? _paramsOrRest : null;
|
|
5703
|
-
return new ZodTuple({
|
|
5704
|
-
type: "tuple",
|
|
5705
|
-
items: items,
|
|
5706
|
-
rest,
|
|
5707
|
-
...normalizeParams(params)
|
|
5708
|
-
});
|
|
5709
|
-
}
|
|
5710
|
-
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def)=>{
|
|
5711
|
-
$ZodRecord.init(inst, def);
|
|
5712
|
-
ZodType.init(inst, def);
|
|
5713
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>recordProcessor(inst, ctx, json, params);
|
|
5714
|
-
inst.keyType = def.keyType;
|
|
5715
|
-
inst.valueType = def.valueType;
|
|
5716
|
-
});
|
|
5717
|
-
function record(keyType, valueType, params) {
|
|
5718
|
-
return new ZodRecord({
|
|
5719
|
-
type: "record",
|
|
5720
|
-
keyType,
|
|
5721
|
-
valueType: valueType,
|
|
5722
|
-
...normalizeParams(params)
|
|
5723
|
-
});
|
|
5724
|
-
}
|
|
5725
|
-
function partialRecord(keyType, valueType, params) {
|
|
5726
|
-
const k = clone(keyType);
|
|
5727
|
-
k._zod.values = void 0;
|
|
5728
|
-
return new ZodRecord({
|
|
5729
|
-
type: "record",
|
|
5730
|
-
keyType: k,
|
|
5731
|
-
valueType: valueType,
|
|
5732
|
-
...normalizeParams(params)
|
|
5733
|
-
});
|
|
5734
|
-
}
|
|
5735
|
-
function looseRecord(keyType, valueType, params) {
|
|
5736
|
-
return new ZodRecord({
|
|
5737
|
-
type: "record",
|
|
5738
|
-
keyType,
|
|
5739
|
-
valueType: valueType,
|
|
5740
|
-
mode: "loose",
|
|
5741
|
-
...normalizeParams(params)
|
|
5742
|
-
});
|
|
5743
|
-
}
|
|
5744
|
-
const ZodMap = /*@__PURE__*/ $constructor("ZodMap", (inst, def)=>{
|
|
5745
|
-
$ZodMap.init(inst, def);
|
|
5746
|
-
ZodType.init(inst, def);
|
|
5747
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>mapProcessor(inst, ctx, json, params);
|
|
5748
|
-
inst.keyType = def.keyType;
|
|
5749
|
-
inst.valueType = def.valueType;
|
|
5750
|
-
inst.min = (...args)=>inst.check(_minSize(...args));
|
|
5751
|
-
inst.nonempty = (params)=>inst.check(_minSize(1, params));
|
|
5752
|
-
inst.max = (...args)=>inst.check(_maxSize(...args));
|
|
5753
|
-
inst.size = (...args)=>inst.check(_size(...args));
|
|
5754
|
-
});
|
|
5755
|
-
function schemas_map(keyType, valueType, params) {
|
|
5756
|
-
return new ZodMap({
|
|
5757
|
-
type: "map",
|
|
5758
|
-
keyType: keyType,
|
|
5759
|
-
valueType: valueType,
|
|
5760
|
-
...normalizeParams(params)
|
|
5761
|
-
});
|
|
5762
|
-
}
|
|
5763
|
-
const ZodSet = /*@__PURE__*/ $constructor("ZodSet", (inst, def)=>{
|
|
5764
|
-
$ZodSet.init(inst, def);
|
|
5765
|
-
ZodType.init(inst, def);
|
|
5766
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>setProcessor(inst, ctx, json, params);
|
|
5767
|
-
inst.min = (...args)=>inst.check(_minSize(...args));
|
|
5768
|
-
inst.nonempty = (params)=>inst.check(_minSize(1, params));
|
|
5769
|
-
inst.max = (...args)=>inst.check(_maxSize(...args));
|
|
5770
|
-
inst.size = (...args)=>inst.check(_size(...args));
|
|
5771
|
-
});
|
|
5772
|
-
function schemas_set(valueType, params) {
|
|
5773
|
-
return new ZodSet({
|
|
5774
|
-
type: "set",
|
|
5775
|
-
valueType: valueType,
|
|
5776
|
-
...normalizeParams(params)
|
|
5777
|
-
});
|
|
5778
|
-
}
|
|
5779
3568
|
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def)=>{
|
|
5780
3569
|
$ZodEnum.init(inst, def);
|
|
5781
3570
|
ZodType.init(inst, def);
|
|
@@ -5819,47 +3608,6 @@ function schemas_enum(values, params) {
|
|
|
5819
3608
|
...normalizeParams(params)
|
|
5820
3609
|
});
|
|
5821
3610
|
}
|
|
5822
|
-
function nativeEnum(entries, params) {
|
|
5823
|
-
return new ZodEnum({
|
|
5824
|
-
type: "enum",
|
|
5825
|
-
entries,
|
|
5826
|
-
...normalizeParams(params)
|
|
5827
|
-
});
|
|
5828
|
-
}
|
|
5829
|
-
const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def)=>{
|
|
5830
|
-
$ZodLiteral.init(inst, def);
|
|
5831
|
-
ZodType.init(inst, def);
|
|
5832
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>literalProcessor(inst, ctx, json, params);
|
|
5833
|
-
inst.values = new Set(def.values);
|
|
5834
|
-
Object.defineProperty(inst, "value", {
|
|
5835
|
-
get () {
|
|
5836
|
-
if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
5837
|
-
return def.values[0];
|
|
5838
|
-
}
|
|
5839
|
-
});
|
|
5840
|
-
});
|
|
5841
|
-
function literal(value, params) {
|
|
5842
|
-
return new ZodLiteral({
|
|
5843
|
-
type: "literal",
|
|
5844
|
-
values: Array.isArray(value) ? value : [
|
|
5845
|
-
value
|
|
5846
|
-
],
|
|
5847
|
-
...normalizeParams(params)
|
|
5848
|
-
});
|
|
5849
|
-
}
|
|
5850
|
-
const ZodFile = /*@__PURE__*/ $constructor("ZodFile", (inst, def)=>{
|
|
5851
|
-
$ZodFile.init(inst, def);
|
|
5852
|
-
ZodType.init(inst, def);
|
|
5853
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>fileProcessor(inst, ctx, json, params);
|
|
5854
|
-
inst.min = (size, params)=>inst.check(_minSize(size, params));
|
|
5855
|
-
inst.max = (size, params)=>inst.check(_maxSize(size, params));
|
|
5856
|
-
inst.mime = (types, params)=>inst.check(_mime(Array.isArray(types) ? types : [
|
|
5857
|
-
types
|
|
5858
|
-
], params));
|
|
5859
|
-
});
|
|
5860
|
-
function schemas_file(params) {
|
|
5861
|
-
return _file(ZodFile, params);
|
|
5862
|
-
}
|
|
5863
3611
|
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def)=>{
|
|
5864
3612
|
$ZodTransform.init(inst, def);
|
|
5865
3613
|
ZodType.init(inst, def);
|
|
@@ -5880,9 +3628,11 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def)=>{
|
|
|
5880
3628
|
const output = def.transform(payload.value, payload);
|
|
5881
3629
|
if (output instanceof Promise) return output.then((output)=>{
|
|
5882
3630
|
payload.value = output;
|
|
3631
|
+
payload.fallback = true;
|
|
5883
3632
|
return payload;
|
|
5884
3633
|
});
|
|
5885
3634
|
payload.value = output;
|
|
3635
|
+
payload.fallback = true;
|
|
5886
3636
|
return payload;
|
|
5887
3637
|
};
|
|
5888
3638
|
});
|
|
@@ -5928,9 +3678,6 @@ function nullable(innerType) {
|
|
|
5928
3678
|
innerType: innerType
|
|
5929
3679
|
});
|
|
5930
3680
|
}
|
|
5931
|
-
function schemas_nullish(innerType) {
|
|
5932
|
-
return optional(nullable(innerType));
|
|
5933
|
-
}
|
|
5934
3681
|
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def)=>{
|
|
5935
3682
|
$ZodDefault.init(inst, def);
|
|
5936
3683
|
ZodType.init(inst, def);
|
|
@@ -5975,18 +3722,6 @@ function nonoptional(innerType, params) {
|
|
|
5975
3722
|
...normalizeParams(params)
|
|
5976
3723
|
});
|
|
5977
3724
|
}
|
|
5978
|
-
const ZodSuccess = /*@__PURE__*/ $constructor("ZodSuccess", (inst, def)=>{
|
|
5979
|
-
$ZodSuccess.init(inst, def);
|
|
5980
|
-
ZodType.init(inst, def);
|
|
5981
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>successProcessor(inst, ctx, json, params);
|
|
5982
|
-
inst.unwrap = ()=>inst._zod.def.innerType;
|
|
5983
|
-
});
|
|
5984
|
-
function success(innerType) {
|
|
5985
|
-
return new ZodSuccess({
|
|
5986
|
-
type: "success",
|
|
5987
|
-
innerType: innerType
|
|
5988
|
-
});
|
|
5989
|
-
}
|
|
5990
3725
|
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def)=>{
|
|
5991
3726
|
$ZodCatch.init(inst, def);
|
|
5992
3727
|
ZodType.init(inst, def);
|
|
@@ -6001,14 +3736,6 @@ function schemas_catch(innerType, catchValue) {
|
|
|
6001
3736
|
catchValue: "function" == typeof catchValue ? catchValue : ()=>catchValue
|
|
6002
3737
|
});
|
|
6003
3738
|
}
|
|
6004
|
-
const ZodNaN = /*@__PURE__*/ $constructor("ZodNaN", (inst, def)=>{
|
|
6005
|
-
$ZodNaN.init(inst, def);
|
|
6006
|
-
ZodType.init(inst, def);
|
|
6007
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>nanProcessor(inst, ctx, json, params);
|
|
6008
|
-
});
|
|
6009
|
-
function nan(params) {
|
|
6010
|
-
return _nan(ZodNaN, params);
|
|
6011
|
-
}
|
|
6012
3739
|
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def)=>{
|
|
6013
3740
|
$ZodPipe.init(inst, def);
|
|
6014
3741
|
ZodType.init(inst, def);
|
|
@@ -6023,19 +3750,6 @@ function pipe(in_, out) {
|
|
|
6023
3750
|
out: out
|
|
6024
3751
|
});
|
|
6025
3752
|
}
|
|
6026
|
-
const ZodCodec = /*@__PURE__*/ $constructor("ZodCodec", (inst, def)=>{
|
|
6027
|
-
ZodPipe.init(inst, def);
|
|
6028
|
-
$ZodCodec.init(inst, def);
|
|
6029
|
-
});
|
|
6030
|
-
function schemas_codec(in_, out, params) {
|
|
6031
|
-
return new ZodCodec({
|
|
6032
|
-
type: "pipe",
|
|
6033
|
-
in: in_,
|
|
6034
|
-
out: out,
|
|
6035
|
-
transform: params.decode,
|
|
6036
|
-
reverseTransform: params.encode
|
|
6037
|
-
});
|
|
6038
|
-
}
|
|
6039
3753
|
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def)=>{
|
|
6040
3754
|
$ZodReadonly.init(inst, def);
|
|
6041
3755
|
ZodType.init(inst, def);
|
|
@@ -6048,185 +3762,17 @@ function readonly(innerType) {
|
|
|
6048
3762
|
innerType: innerType
|
|
6049
3763
|
});
|
|
6050
3764
|
}
|
|
6051
|
-
const ZodTemplateLiteral = /*@__PURE__*/ $constructor("ZodTemplateLiteral", (inst, def)=>{
|
|
6052
|
-
$ZodTemplateLiteral.init(inst, def);
|
|
6053
|
-
ZodType.init(inst, def);
|
|
6054
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>templateLiteralProcessor(inst, ctx, json, params);
|
|
6055
|
-
});
|
|
6056
|
-
function templateLiteral(parts, params) {
|
|
6057
|
-
return new ZodTemplateLiteral({
|
|
6058
|
-
type: "template_literal",
|
|
6059
|
-
parts,
|
|
6060
|
-
...normalizeParams(params)
|
|
6061
|
-
});
|
|
6062
|
-
}
|
|
6063
|
-
const ZodLazy = /*@__PURE__*/ $constructor("ZodLazy", (inst, def)=>{
|
|
6064
|
-
$ZodLazy.init(inst, def);
|
|
6065
|
-
ZodType.init(inst, def);
|
|
6066
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>lazyProcessor(inst, ctx, json, params);
|
|
6067
|
-
inst.unwrap = ()=>inst._zod.def.getter();
|
|
6068
|
-
});
|
|
6069
|
-
function lazy(getter) {
|
|
6070
|
-
return new ZodLazy({
|
|
6071
|
-
type: "lazy",
|
|
6072
|
-
getter: getter
|
|
6073
|
-
});
|
|
6074
|
-
}
|
|
6075
|
-
const ZodPromise = /*@__PURE__*/ $constructor("ZodPromise", (inst, def)=>{
|
|
6076
|
-
$ZodPromise.init(inst, def);
|
|
6077
|
-
ZodType.init(inst, def);
|
|
6078
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>promiseProcessor(inst, ctx, json, params);
|
|
6079
|
-
inst.unwrap = ()=>inst._zod.def.innerType;
|
|
6080
|
-
});
|
|
6081
|
-
function promise(innerType) {
|
|
6082
|
-
return new ZodPromise({
|
|
6083
|
-
type: "promise",
|
|
6084
|
-
innerType: innerType
|
|
6085
|
-
});
|
|
6086
|
-
}
|
|
6087
|
-
const ZodFunction = /*@__PURE__*/ $constructor("ZodFunction", (inst, def)=>{
|
|
6088
|
-
$ZodFunction.init(inst, def);
|
|
6089
|
-
ZodType.init(inst, def);
|
|
6090
|
-
inst._zod.processJSONSchema = (ctx, json, params)=>functionProcessor(inst, ctx, json, params);
|
|
6091
|
-
});
|
|
6092
|
-
function _function(params) {
|
|
6093
|
-
return new ZodFunction({
|
|
6094
|
-
type: "function",
|
|
6095
|
-
input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? schemas_array(unknown()),
|
|
6096
|
-
output: params?.output ?? unknown()
|
|
6097
|
-
});
|
|
6098
|
-
}
|
|
6099
3765
|
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def)=>{
|
|
6100
3766
|
$ZodCustom.init(inst, def);
|
|
6101
3767
|
ZodType.init(inst, def);
|
|
6102
3768
|
inst._zod.processJSONSchema = (ctx, json, params)=>customProcessor(inst, ctx, json, params);
|
|
6103
3769
|
});
|
|
6104
|
-
function schemas_check(fn) {
|
|
6105
|
-
const ch = new $ZodCheck({
|
|
6106
|
-
check: "custom"
|
|
6107
|
-
});
|
|
6108
|
-
ch._zod.check = fn;
|
|
6109
|
-
return ch;
|
|
6110
|
-
}
|
|
6111
|
-
function custom(fn, _params) {
|
|
6112
|
-
return _custom(ZodCustom, fn ?? (()=>true), _params);
|
|
6113
|
-
}
|
|
6114
3770
|
function refine(fn, _params = {}) {
|
|
6115
3771
|
return _refine(ZodCustom, fn, _params);
|
|
6116
3772
|
}
|
|
6117
|
-
function superRefine(fn) {
|
|
6118
|
-
return _superRefine(fn);
|
|
6119
|
-
}
|
|
6120
|
-
const schemas_describe = describe;
|
|
6121
|
-
const schemas_meta = api_meta;
|
|
6122
|
-
function _instanceof(cls, params = {}) {
|
|
6123
|
-
const inst = new ZodCustom({
|
|
6124
|
-
type: "custom",
|
|
6125
|
-
check: "custom",
|
|
6126
|
-
fn: (data)=>data instanceof cls,
|
|
6127
|
-
abort: true,
|
|
6128
|
-
...normalizeParams(params)
|
|
6129
|
-
});
|
|
6130
|
-
inst._zod.bag.Class = cls;
|
|
6131
|
-
inst._zod.check = (payload)=>{
|
|
6132
|
-
if (!(payload.value instanceof cls)) payload.issues.push({
|
|
6133
|
-
code: "invalid_type",
|
|
6134
|
-
expected: cls.name,
|
|
6135
|
-
input: payload.value,
|
|
6136
|
-
inst,
|
|
6137
|
-
path: [
|
|
6138
|
-
...inst._zod.def.path ?? []
|
|
6139
|
-
]
|
|
6140
|
-
});
|
|
6141
|
-
};
|
|
6142
|
-
return inst;
|
|
3773
|
+
function superRefine(fn, params) {
|
|
3774
|
+
return _superRefine(fn, params);
|
|
6143
3775
|
}
|
|
6144
|
-
const stringbool = (...args)=>_stringbool({
|
|
6145
|
-
Codec: ZodCodec,
|
|
6146
|
-
Boolean: ZodBoolean,
|
|
6147
|
-
String: ZodString
|
|
6148
|
-
}, ...args);
|
|
6149
|
-
function schemas_json(params) {
|
|
6150
|
-
const jsonSchema = lazy(()=>union([
|
|
6151
|
-
schemas_string(params),
|
|
6152
|
-
schemas_number(),
|
|
6153
|
-
schemas_boolean(),
|
|
6154
|
-
schemas_null(),
|
|
6155
|
-
schemas_array(jsonSchema),
|
|
6156
|
-
record(schemas_string(), jsonSchema)
|
|
6157
|
-
]));
|
|
6158
|
-
return jsonSchema;
|
|
6159
|
-
}
|
|
6160
|
-
function preprocess(fn, schema) {
|
|
6161
|
-
return pipe(transform(fn), schema);
|
|
6162
|
-
}
|
|
6163
|
-
var compat_ZodFirstPartyTypeKind;
|
|
6164
|
-
compat_ZodFirstPartyTypeKind || (compat_ZodFirstPartyTypeKind = {});
|
|
6165
|
-
({
|
|
6166
|
-
...classic_schemas_namespaceObject,
|
|
6167
|
-
...classic_checks_namespaceObject,
|
|
6168
|
-
iso: iso_namespaceObject
|
|
6169
|
-
});
|
|
6170
|
-
new Set([
|
|
6171
|
-
"$schema",
|
|
6172
|
-
"$ref",
|
|
6173
|
-
"$defs",
|
|
6174
|
-
"definitions",
|
|
6175
|
-
"$id",
|
|
6176
|
-
"id",
|
|
6177
|
-
"$comment",
|
|
6178
|
-
"$anchor",
|
|
6179
|
-
"$vocabulary",
|
|
6180
|
-
"$dynamicRef",
|
|
6181
|
-
"$dynamicAnchor",
|
|
6182
|
-
"type",
|
|
6183
|
-
"enum",
|
|
6184
|
-
"const",
|
|
6185
|
-
"anyOf",
|
|
6186
|
-
"oneOf",
|
|
6187
|
-
"allOf",
|
|
6188
|
-
"not",
|
|
6189
|
-
"properties",
|
|
6190
|
-
"required",
|
|
6191
|
-
"additionalProperties",
|
|
6192
|
-
"patternProperties",
|
|
6193
|
-
"propertyNames",
|
|
6194
|
-
"minProperties",
|
|
6195
|
-
"maxProperties",
|
|
6196
|
-
"items",
|
|
6197
|
-
"prefixItems",
|
|
6198
|
-
"additionalItems",
|
|
6199
|
-
"minItems",
|
|
6200
|
-
"maxItems",
|
|
6201
|
-
"uniqueItems",
|
|
6202
|
-
"contains",
|
|
6203
|
-
"minContains",
|
|
6204
|
-
"maxContains",
|
|
6205
|
-
"minLength",
|
|
6206
|
-
"maxLength",
|
|
6207
|
-
"pattern",
|
|
6208
|
-
"format",
|
|
6209
|
-
"minimum",
|
|
6210
|
-
"maximum",
|
|
6211
|
-
"exclusiveMinimum",
|
|
6212
|
-
"exclusiveMaximum",
|
|
6213
|
-
"multipleOf",
|
|
6214
|
-
"description",
|
|
6215
|
-
"default",
|
|
6216
|
-
"contentEncoding",
|
|
6217
|
-
"contentMediaType",
|
|
6218
|
-
"contentSchema",
|
|
6219
|
-
"unevaluatedItems",
|
|
6220
|
-
"unevaluatedProperties",
|
|
6221
|
-
"if",
|
|
6222
|
-
"then",
|
|
6223
|
-
"else",
|
|
6224
|
-
"dependentSchemas",
|
|
6225
|
-
"dependentRequired",
|
|
6226
|
-
"nullable",
|
|
6227
|
-
"readOnly"
|
|
6228
|
-
]);
|
|
6229
|
-
core_config(en());
|
|
6230
3776
|
const propMetadataSchema = schemas_object({
|
|
6231
3777
|
name: schemas_string(),
|
|
6232
3778
|
type: schemas_string(),
|