@atproto/lexicon 0.0.1

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.
Files changed (42) hide show
  1. package/README.md +31 -0
  2. package/build.js +22 -0
  3. package/dist/index.d.ts +126 -0
  4. package/dist/index.js +3897 -0
  5. package/dist/index.js.map +7 -0
  6. package/dist/src/index.d.ts +2 -0
  7. package/dist/src/lexicons.d.ts +15 -0
  8. package/dist/src/record/index.d.ts +4 -0
  9. package/dist/src/record/schema.d.ts +9 -0
  10. package/dist/src/record/schemas.d.ts +10 -0
  11. package/dist/src/record/util.d.ts +1 -0
  12. package/dist/src/record/validation.d.ts +24 -0
  13. package/dist/src/record/validator.d.ts +17 -0
  14. package/dist/src/record-validator.d.ts +17 -0
  15. package/dist/src/schema.d.ts +9 -0
  16. package/dist/src/schemas.d.ts +10 -0
  17. package/dist/src/types.d.ts +30268 -0
  18. package/dist/src/util.d.ts +6 -0
  19. package/dist/src/validation.d.ts +6 -0
  20. package/dist/src/validators/blob.d.ts +6 -0
  21. package/dist/src/validators/complex.d.ts +5 -0
  22. package/dist/src/validators/primitives.d.ts +9 -0
  23. package/dist/src/validators/xrpc.d.ts +3 -0
  24. package/dist/src/view-validator.d.ts +13 -0
  25. package/dist/tsconfig.build.tsbuildinfo +1 -0
  26. package/dist/types.d.ts +73 -0
  27. package/dist/types.js +35 -0
  28. package/jest.config.js +6 -0
  29. package/package.json +21 -0
  30. package/src/index.ts +2 -0
  31. package/src/lexicons.ts +203 -0
  32. package/src/types.ts +318 -0
  33. package/src/util.ts +107 -0
  34. package/src/validation.ts +48 -0
  35. package/src/validators/blob.ts +57 -0
  36. package/src/validators/complex.ts +152 -0
  37. package/src/validators/primitives.ts +300 -0
  38. package/src/validators/xrpc.ts +50 -0
  39. package/tests/_scaffolds/lexicons.ts +379 -0
  40. package/tests/general.test.ts +611 -0
  41. package/tsconfig.build.json +4 -0
  42. package/tsconfig.json +11 -0
package/dist/index.js ADDED
@@ -0,0 +1,3897 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ InvalidLexiconError: () => InvalidLexiconError,
24
+ LexiconDefNotFoundError: () => LexiconDefNotFoundError,
25
+ LexiconDocMalformedError: () => LexiconDocMalformedError,
26
+ Lexicons: () => Lexicons,
27
+ ValidationError: () => ValidationError,
28
+ discriminatedObject: () => discriminatedObject,
29
+ hasProp: () => hasProp,
30
+ isDiscriminatedObject: () => isDiscriminatedObject,
31
+ isObj: () => isObj,
32
+ isValidLexiconDoc: () => isValidLexiconDoc,
33
+ lexArray: () => lexArray,
34
+ lexAudio: () => lexAudio,
35
+ lexBlob: () => lexBlob,
36
+ lexBlobVariant: () => lexBlobVariant,
37
+ lexBoolean: () => lexBoolean,
38
+ lexDatetime: () => lexDatetime,
39
+ lexImage: () => lexImage,
40
+ lexInteger: () => lexInteger,
41
+ lexNumber: () => lexNumber,
42
+ lexObject: () => lexObject,
43
+ lexPrimitive: () => lexPrimitive,
44
+ lexRecord: () => lexRecord,
45
+ lexRef: () => lexRef,
46
+ lexRefUnion: () => lexRefUnion,
47
+ lexRefVariant: () => lexRefVariant,
48
+ lexString: () => lexString,
49
+ lexToken: () => lexToken,
50
+ lexUnknown: () => lexUnknown,
51
+ lexUserType: () => lexUserType,
52
+ lexVideo: () => lexVideo,
53
+ lexXrpcBody: () => lexXrpcBody,
54
+ lexXrpcError: () => lexXrpcError,
55
+ lexXrpcParameters: () => lexXrpcParameters,
56
+ lexXrpcProcedure: () => lexXrpcProcedure,
57
+ lexXrpcQuery: () => lexXrpcQuery,
58
+ lexiconDoc: () => lexiconDoc
59
+ });
60
+ module.exports = __toCommonJS(src_exports);
61
+
62
+ // ../../node_modules/zod/lib/index.mjs
63
+ var util;
64
+ (function(util2) {
65
+ util2.assertEqual = (val) => val;
66
+ function assertIs(_arg) {
67
+ }
68
+ util2.assertIs = assertIs;
69
+ function assertNever(_x) {
70
+ throw new Error();
71
+ }
72
+ util2.assertNever = assertNever;
73
+ util2.arrayToEnum = (items) => {
74
+ const obj = {};
75
+ for (const item of items) {
76
+ obj[item] = item;
77
+ }
78
+ return obj;
79
+ };
80
+ util2.getValidEnumValues = (obj) => {
81
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
82
+ const filtered = {};
83
+ for (const k of validKeys) {
84
+ filtered[k] = obj[k];
85
+ }
86
+ return util2.objectValues(filtered);
87
+ };
88
+ util2.objectValues = (obj) => {
89
+ return util2.objectKeys(obj).map(function(e) {
90
+ return obj[e];
91
+ });
92
+ };
93
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
94
+ const keys = [];
95
+ for (const key in object2) {
96
+ if (Object.prototype.hasOwnProperty.call(object2, key)) {
97
+ keys.push(key);
98
+ }
99
+ }
100
+ return keys;
101
+ };
102
+ util2.find = (arr, checker) => {
103
+ for (const item of arr) {
104
+ if (checker(item))
105
+ return item;
106
+ }
107
+ return void 0;
108
+ };
109
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
110
+ function joinValues(array2, separator = " | ") {
111
+ return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
112
+ }
113
+ util2.joinValues = joinValues;
114
+ util2.jsonStringifyReplacer = (_, value) => {
115
+ if (typeof value === "bigint") {
116
+ return value.toString();
117
+ }
118
+ return value;
119
+ };
120
+ })(util || (util = {}));
121
+ var ZodParsedType = util.arrayToEnum([
122
+ "string",
123
+ "nan",
124
+ "number",
125
+ "integer",
126
+ "float",
127
+ "boolean",
128
+ "date",
129
+ "bigint",
130
+ "symbol",
131
+ "function",
132
+ "undefined",
133
+ "null",
134
+ "array",
135
+ "object",
136
+ "unknown",
137
+ "promise",
138
+ "void",
139
+ "never",
140
+ "map",
141
+ "set"
142
+ ]);
143
+ var getParsedType = (data) => {
144
+ const t = typeof data;
145
+ switch (t) {
146
+ case "undefined":
147
+ return ZodParsedType.undefined;
148
+ case "string":
149
+ return ZodParsedType.string;
150
+ case "number":
151
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
152
+ case "boolean":
153
+ return ZodParsedType.boolean;
154
+ case "function":
155
+ return ZodParsedType.function;
156
+ case "bigint":
157
+ return ZodParsedType.bigint;
158
+ case "object":
159
+ if (Array.isArray(data)) {
160
+ return ZodParsedType.array;
161
+ }
162
+ if (data === null) {
163
+ return ZodParsedType.null;
164
+ }
165
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
166
+ return ZodParsedType.promise;
167
+ }
168
+ if (typeof Map !== "undefined" && data instanceof Map) {
169
+ return ZodParsedType.map;
170
+ }
171
+ if (typeof Set !== "undefined" && data instanceof Set) {
172
+ return ZodParsedType.set;
173
+ }
174
+ if (typeof Date !== "undefined" && data instanceof Date) {
175
+ return ZodParsedType.date;
176
+ }
177
+ return ZodParsedType.object;
178
+ default:
179
+ return ZodParsedType.unknown;
180
+ }
181
+ };
182
+ var ZodIssueCode = util.arrayToEnum([
183
+ "invalid_type",
184
+ "invalid_literal",
185
+ "custom",
186
+ "invalid_union",
187
+ "invalid_union_discriminator",
188
+ "invalid_enum_value",
189
+ "unrecognized_keys",
190
+ "invalid_arguments",
191
+ "invalid_return_type",
192
+ "invalid_date",
193
+ "invalid_string",
194
+ "too_small",
195
+ "too_big",
196
+ "invalid_intersection_types",
197
+ "not_multiple_of"
198
+ ]);
199
+ var quotelessJson = (obj) => {
200
+ const json = JSON.stringify(obj, null, 2);
201
+ return json.replace(/"([^"]+)":/g, "$1:");
202
+ };
203
+ var ZodError = class extends Error {
204
+ constructor(issues) {
205
+ super();
206
+ this.issues = [];
207
+ this.addIssue = (sub) => {
208
+ this.issues = [...this.issues, sub];
209
+ };
210
+ this.addIssues = (subs = []) => {
211
+ this.issues = [...this.issues, ...subs];
212
+ };
213
+ const actualProto = new.target.prototype;
214
+ if (Object.setPrototypeOf) {
215
+ Object.setPrototypeOf(this, actualProto);
216
+ } else {
217
+ this.__proto__ = actualProto;
218
+ }
219
+ this.name = "ZodError";
220
+ this.issues = issues;
221
+ }
222
+ get errors() {
223
+ return this.issues;
224
+ }
225
+ format(_mapper) {
226
+ const mapper = _mapper || function(issue) {
227
+ return issue.message;
228
+ };
229
+ const fieldErrors = { _errors: [] };
230
+ const processError = (error) => {
231
+ for (const issue of error.issues) {
232
+ if (issue.code === "invalid_union") {
233
+ issue.unionErrors.map(processError);
234
+ } else if (issue.code === "invalid_return_type") {
235
+ processError(issue.returnTypeError);
236
+ } else if (issue.code === "invalid_arguments") {
237
+ processError(issue.argumentsError);
238
+ } else if (issue.path.length === 0) {
239
+ fieldErrors._errors.push(mapper(issue));
240
+ } else {
241
+ let curr = fieldErrors;
242
+ let i = 0;
243
+ while (i < issue.path.length) {
244
+ const el = issue.path[i];
245
+ const terminal = i === issue.path.length - 1;
246
+ if (!terminal) {
247
+ curr[el] = curr[el] || { _errors: [] };
248
+ } else {
249
+ curr[el] = curr[el] || { _errors: [] };
250
+ curr[el]._errors.push(mapper(issue));
251
+ }
252
+ curr = curr[el];
253
+ i++;
254
+ }
255
+ }
256
+ }
257
+ };
258
+ processError(this);
259
+ return fieldErrors;
260
+ }
261
+ toString() {
262
+ return this.message;
263
+ }
264
+ get message() {
265
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
266
+ }
267
+ get isEmpty() {
268
+ return this.issues.length === 0;
269
+ }
270
+ flatten(mapper = (issue) => issue.message) {
271
+ const fieldErrors = {};
272
+ const formErrors = [];
273
+ for (const sub of this.issues) {
274
+ if (sub.path.length > 0) {
275
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
276
+ fieldErrors[sub.path[0]].push(mapper(sub));
277
+ } else {
278
+ formErrors.push(mapper(sub));
279
+ }
280
+ }
281
+ return { formErrors, fieldErrors };
282
+ }
283
+ get formErrors() {
284
+ return this.flatten();
285
+ }
286
+ };
287
+ ZodError.create = (issues) => {
288
+ const error = new ZodError(issues);
289
+ return error;
290
+ };
291
+ var errorMap = (issue, _ctx) => {
292
+ let message;
293
+ switch (issue.code) {
294
+ case ZodIssueCode.invalid_type:
295
+ if (issue.received === ZodParsedType.undefined) {
296
+ message = "Required";
297
+ } else {
298
+ message = `Expected ${issue.expected}, received ${issue.received}`;
299
+ }
300
+ break;
301
+ case ZodIssueCode.invalid_literal:
302
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
303
+ break;
304
+ case ZodIssueCode.unrecognized_keys:
305
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
306
+ break;
307
+ case ZodIssueCode.invalid_union:
308
+ message = `Invalid input`;
309
+ break;
310
+ case ZodIssueCode.invalid_union_discriminator:
311
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
312
+ break;
313
+ case ZodIssueCode.invalid_enum_value:
314
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
315
+ break;
316
+ case ZodIssueCode.invalid_arguments:
317
+ message = `Invalid function arguments`;
318
+ break;
319
+ case ZodIssueCode.invalid_return_type:
320
+ message = `Invalid function return type`;
321
+ break;
322
+ case ZodIssueCode.invalid_date:
323
+ message = `Invalid date`;
324
+ break;
325
+ case ZodIssueCode.invalid_string:
326
+ if (typeof issue.validation === "object") {
327
+ if ("startsWith" in issue.validation) {
328
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
329
+ } else if ("endsWith" in issue.validation) {
330
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
331
+ } else {
332
+ util.assertNever(issue.validation);
333
+ }
334
+ } else if (issue.validation !== "regex") {
335
+ message = `Invalid ${issue.validation}`;
336
+ } else {
337
+ message = "Invalid";
338
+ }
339
+ break;
340
+ case ZodIssueCode.too_small:
341
+ if (issue.type === "array")
342
+ message = `Array must contain ${issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
343
+ else if (issue.type === "string")
344
+ message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
345
+ else if (issue.type === "number")
346
+ message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
347
+ else if (issue.type === "date")
348
+ message = `Date must be greater than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.minimum)}`;
349
+ else
350
+ message = "Invalid input";
351
+ break;
352
+ case ZodIssueCode.too_big:
353
+ if (issue.type === "array")
354
+ message = `Array must contain ${issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
355
+ else if (issue.type === "string")
356
+ message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
357
+ else if (issue.type === "number")
358
+ message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
359
+ else if (issue.type === "date")
360
+ message = `Date must be smaller than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.maximum)}`;
361
+ else
362
+ message = "Invalid input";
363
+ break;
364
+ case ZodIssueCode.custom:
365
+ message = `Invalid input`;
366
+ break;
367
+ case ZodIssueCode.invalid_intersection_types:
368
+ message = `Intersection results could not be merged`;
369
+ break;
370
+ case ZodIssueCode.not_multiple_of:
371
+ message = `Number must be a multiple of ${issue.multipleOf}`;
372
+ break;
373
+ default:
374
+ message = _ctx.defaultError;
375
+ util.assertNever(issue);
376
+ }
377
+ return { message };
378
+ };
379
+ var overrideErrorMap = errorMap;
380
+ function setErrorMap(map) {
381
+ overrideErrorMap = map;
382
+ }
383
+ function getErrorMap() {
384
+ return overrideErrorMap;
385
+ }
386
+ var makeIssue = (params2) => {
387
+ const { data, path, errorMaps, issueData } = params2;
388
+ const fullPath = [...path, ...issueData.path || []];
389
+ const fullIssue = {
390
+ ...issueData,
391
+ path: fullPath
392
+ };
393
+ let errorMessage = "";
394
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
395
+ for (const map of maps) {
396
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
397
+ }
398
+ return {
399
+ ...issueData,
400
+ path: fullPath,
401
+ message: issueData.message || errorMessage
402
+ };
403
+ };
404
+ var EMPTY_PATH = [];
405
+ function addIssueToContext(ctx, issueData) {
406
+ const issue = makeIssue({
407
+ issueData,
408
+ data: ctx.data,
409
+ path: ctx.path,
410
+ errorMaps: [
411
+ ctx.common.contextualErrorMap,
412
+ ctx.schemaErrorMap,
413
+ getErrorMap(),
414
+ errorMap
415
+ ].filter((x) => !!x)
416
+ });
417
+ ctx.common.issues.push(issue);
418
+ }
419
+ var ParseStatus = class {
420
+ constructor() {
421
+ this.value = "valid";
422
+ }
423
+ dirty() {
424
+ if (this.value === "valid")
425
+ this.value = "dirty";
426
+ }
427
+ abort() {
428
+ if (this.value !== "aborted")
429
+ this.value = "aborted";
430
+ }
431
+ static mergeArray(status, results) {
432
+ const arrayValue = [];
433
+ for (const s of results) {
434
+ if (s.status === "aborted")
435
+ return INVALID;
436
+ if (s.status === "dirty")
437
+ status.dirty();
438
+ arrayValue.push(s.value);
439
+ }
440
+ return { status: status.value, value: arrayValue };
441
+ }
442
+ static async mergeObjectAsync(status, pairs) {
443
+ const syncPairs = [];
444
+ for (const pair of pairs) {
445
+ syncPairs.push({
446
+ key: await pair.key,
447
+ value: await pair.value
448
+ });
449
+ }
450
+ return ParseStatus.mergeObjectSync(status, syncPairs);
451
+ }
452
+ static mergeObjectSync(status, pairs) {
453
+ const finalObject = {};
454
+ for (const pair of pairs) {
455
+ const { key, value } = pair;
456
+ if (key.status === "aborted")
457
+ return INVALID;
458
+ if (value.status === "aborted")
459
+ return INVALID;
460
+ if (key.status === "dirty")
461
+ status.dirty();
462
+ if (value.status === "dirty")
463
+ status.dirty();
464
+ if (typeof value.value !== "undefined" || pair.alwaysSet) {
465
+ finalObject[key.value] = value.value;
466
+ }
467
+ }
468
+ return { status: status.value, value: finalObject };
469
+ }
470
+ };
471
+ var INVALID = Object.freeze({
472
+ status: "aborted"
473
+ });
474
+ var DIRTY = (value) => ({ status: "dirty", value });
475
+ var OK = (value) => ({ status: "valid", value });
476
+ var isAborted = (x) => x.status === "aborted";
477
+ var isDirty = (x) => x.status === "dirty";
478
+ var isValid = (x) => x.status === "valid";
479
+ var isAsync = (x) => typeof Promise !== void 0 && x instanceof Promise;
480
+ var errorUtil;
481
+ (function(errorUtil2) {
482
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
483
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
484
+ })(errorUtil || (errorUtil = {}));
485
+ var ParseInputLazyPath = class {
486
+ constructor(parent, value, path, key) {
487
+ this.parent = parent;
488
+ this.data = value;
489
+ this._path = path;
490
+ this._key = key;
491
+ }
492
+ get path() {
493
+ return this._path.concat(this._key);
494
+ }
495
+ };
496
+ var handleResult = (ctx, result) => {
497
+ if (isValid(result)) {
498
+ return { success: true, data: result.value };
499
+ } else {
500
+ if (!ctx.common.issues.length) {
501
+ throw new Error("Validation failed but no issues detected.");
502
+ }
503
+ const error = new ZodError(ctx.common.issues);
504
+ return { success: false, error };
505
+ }
506
+ };
507
+ function processCreateParams(params2) {
508
+ if (!params2)
509
+ return {};
510
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params2;
511
+ if (errorMap2 && (invalid_type_error || required_error)) {
512
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
513
+ }
514
+ if (errorMap2)
515
+ return { errorMap: errorMap2, description };
516
+ const customMap = (iss, ctx) => {
517
+ if (iss.code !== "invalid_type")
518
+ return { message: ctx.defaultError };
519
+ if (typeof ctx.data === "undefined") {
520
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
521
+ }
522
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
523
+ };
524
+ return { errorMap: customMap, description };
525
+ }
526
+ var ZodType = class {
527
+ constructor(def) {
528
+ this.spa = this.safeParseAsync;
529
+ this.superRefine = this._refinement;
530
+ this._def = def;
531
+ this.parse = this.parse.bind(this);
532
+ this.safeParse = this.safeParse.bind(this);
533
+ this.parseAsync = this.parseAsync.bind(this);
534
+ this.safeParseAsync = this.safeParseAsync.bind(this);
535
+ this.spa = this.spa.bind(this);
536
+ this.refine = this.refine.bind(this);
537
+ this.refinement = this.refinement.bind(this);
538
+ this.superRefine = this.superRefine.bind(this);
539
+ this.optional = this.optional.bind(this);
540
+ this.nullable = this.nullable.bind(this);
541
+ this.nullish = this.nullish.bind(this);
542
+ this.array = this.array.bind(this);
543
+ this.promise = this.promise.bind(this);
544
+ this.or = this.or.bind(this);
545
+ this.and = this.and.bind(this);
546
+ this.transform = this.transform.bind(this);
547
+ this.default = this.default.bind(this);
548
+ this.describe = this.describe.bind(this);
549
+ this.isNullable = this.isNullable.bind(this);
550
+ this.isOptional = this.isOptional.bind(this);
551
+ }
552
+ get description() {
553
+ return this._def.description;
554
+ }
555
+ _getType(input) {
556
+ return getParsedType(input.data);
557
+ }
558
+ _getOrReturnCtx(input, ctx) {
559
+ return ctx || {
560
+ common: input.parent.common,
561
+ data: input.data,
562
+ parsedType: getParsedType(input.data),
563
+ schemaErrorMap: this._def.errorMap,
564
+ path: input.path,
565
+ parent: input.parent
566
+ };
567
+ }
568
+ _processInputParams(input) {
569
+ return {
570
+ status: new ParseStatus(),
571
+ ctx: {
572
+ common: input.parent.common,
573
+ data: input.data,
574
+ parsedType: getParsedType(input.data),
575
+ schemaErrorMap: this._def.errorMap,
576
+ path: input.path,
577
+ parent: input.parent
578
+ }
579
+ };
580
+ }
581
+ _parseSync(input) {
582
+ const result = this._parse(input);
583
+ if (isAsync(result)) {
584
+ throw new Error("Synchronous parse encountered promise.");
585
+ }
586
+ return result;
587
+ }
588
+ _parseAsync(input) {
589
+ const result = this._parse(input);
590
+ return Promise.resolve(result);
591
+ }
592
+ parse(data, params2) {
593
+ const result = this.safeParse(data, params2);
594
+ if (result.success)
595
+ return result.data;
596
+ throw result.error;
597
+ }
598
+ safeParse(data, params2) {
599
+ var _a;
600
+ const ctx = {
601
+ common: {
602
+ issues: [],
603
+ async: (_a = params2 === null || params2 === void 0 ? void 0 : params2.async) !== null && _a !== void 0 ? _a : false,
604
+ contextualErrorMap: params2 === null || params2 === void 0 ? void 0 : params2.errorMap
605
+ },
606
+ path: (params2 === null || params2 === void 0 ? void 0 : params2.path) || [],
607
+ schemaErrorMap: this._def.errorMap,
608
+ parent: null,
609
+ data,
610
+ parsedType: getParsedType(data)
611
+ };
612
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
613
+ return handleResult(ctx, result);
614
+ }
615
+ async parseAsync(data, params2) {
616
+ const result = await this.safeParseAsync(data, params2);
617
+ if (result.success)
618
+ return result.data;
619
+ throw result.error;
620
+ }
621
+ async safeParseAsync(data, params2) {
622
+ const ctx = {
623
+ common: {
624
+ issues: [],
625
+ contextualErrorMap: params2 === null || params2 === void 0 ? void 0 : params2.errorMap,
626
+ async: true
627
+ },
628
+ path: (params2 === null || params2 === void 0 ? void 0 : params2.path) || [],
629
+ schemaErrorMap: this._def.errorMap,
630
+ parent: null,
631
+ data,
632
+ parsedType: getParsedType(data)
633
+ };
634
+ const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
635
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
636
+ return handleResult(ctx, result);
637
+ }
638
+ refine(check, message) {
639
+ const getIssueProperties = (val) => {
640
+ if (typeof message === "string" || typeof message === "undefined") {
641
+ return { message };
642
+ } else if (typeof message === "function") {
643
+ return message(val);
644
+ } else {
645
+ return message;
646
+ }
647
+ };
648
+ return this._refinement((val, ctx) => {
649
+ const result = check(val);
650
+ const setError = () => ctx.addIssue({
651
+ code: ZodIssueCode.custom,
652
+ ...getIssueProperties(val)
653
+ });
654
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
655
+ return result.then((data) => {
656
+ if (!data) {
657
+ setError();
658
+ return false;
659
+ } else {
660
+ return true;
661
+ }
662
+ });
663
+ }
664
+ if (!result) {
665
+ setError();
666
+ return false;
667
+ } else {
668
+ return true;
669
+ }
670
+ });
671
+ }
672
+ refinement(check, refinementData) {
673
+ return this._refinement((val, ctx) => {
674
+ if (!check(val)) {
675
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
676
+ return false;
677
+ } else {
678
+ return true;
679
+ }
680
+ });
681
+ }
682
+ _refinement(refinement) {
683
+ return new ZodEffects({
684
+ schema: this,
685
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
686
+ effect: { type: "refinement", refinement }
687
+ });
688
+ }
689
+ optional() {
690
+ return ZodOptional.create(this);
691
+ }
692
+ nullable() {
693
+ return ZodNullable.create(this);
694
+ }
695
+ nullish() {
696
+ return this.optional().nullable();
697
+ }
698
+ array() {
699
+ return ZodArray.create(this);
700
+ }
701
+ promise() {
702
+ return ZodPromise.create(this);
703
+ }
704
+ or(option) {
705
+ return ZodUnion.create([this, option]);
706
+ }
707
+ and(incoming) {
708
+ return ZodIntersection.create(this, incoming);
709
+ }
710
+ transform(transform) {
711
+ return new ZodEffects({
712
+ schema: this,
713
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
714
+ effect: { type: "transform", transform }
715
+ });
716
+ }
717
+ default(def) {
718
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
719
+ return new ZodDefault({
720
+ innerType: this,
721
+ defaultValue: defaultValueFunc,
722
+ typeName: ZodFirstPartyTypeKind.ZodDefault
723
+ });
724
+ }
725
+ brand() {
726
+ return new ZodBranded({
727
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
728
+ type: this,
729
+ ...processCreateParams(void 0)
730
+ });
731
+ }
732
+ describe(description) {
733
+ const This = this.constructor;
734
+ return new This({
735
+ ...this._def,
736
+ description
737
+ });
738
+ }
739
+ isOptional() {
740
+ return this.safeParse(void 0).success;
741
+ }
742
+ isNullable() {
743
+ return this.safeParse(null).success;
744
+ }
745
+ };
746
+ var cuidRegex = /^c[^\s-]{8,}$/i;
747
+ var uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
748
+ var emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
749
+ var ZodString = class extends ZodType {
750
+ constructor() {
751
+ super(...arguments);
752
+ this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
753
+ validation,
754
+ code: ZodIssueCode.invalid_string,
755
+ ...errorUtil.errToObj(message)
756
+ });
757
+ this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
758
+ this.trim = () => new ZodString({
759
+ ...this._def,
760
+ checks: [...this._def.checks, { kind: "trim" }]
761
+ });
762
+ }
763
+ _parse(input) {
764
+ const parsedType = this._getType(input);
765
+ if (parsedType !== ZodParsedType.string) {
766
+ const ctx2 = this._getOrReturnCtx(input);
767
+ addIssueToContext(
768
+ ctx2,
769
+ {
770
+ code: ZodIssueCode.invalid_type,
771
+ expected: ZodParsedType.string,
772
+ received: ctx2.parsedType
773
+ }
774
+ );
775
+ return INVALID;
776
+ }
777
+ const status = new ParseStatus();
778
+ let ctx = void 0;
779
+ for (const check of this._def.checks) {
780
+ if (check.kind === "min") {
781
+ if (input.data.length < check.value) {
782
+ ctx = this._getOrReturnCtx(input, ctx);
783
+ addIssueToContext(ctx, {
784
+ code: ZodIssueCode.too_small,
785
+ minimum: check.value,
786
+ type: "string",
787
+ inclusive: true,
788
+ message: check.message
789
+ });
790
+ status.dirty();
791
+ }
792
+ } else if (check.kind === "max") {
793
+ if (input.data.length > check.value) {
794
+ ctx = this._getOrReturnCtx(input, ctx);
795
+ addIssueToContext(ctx, {
796
+ code: ZodIssueCode.too_big,
797
+ maximum: check.value,
798
+ type: "string",
799
+ inclusive: true,
800
+ message: check.message
801
+ });
802
+ status.dirty();
803
+ }
804
+ } else if (check.kind === "email") {
805
+ if (!emailRegex.test(input.data)) {
806
+ ctx = this._getOrReturnCtx(input, ctx);
807
+ addIssueToContext(ctx, {
808
+ validation: "email",
809
+ code: ZodIssueCode.invalid_string,
810
+ message: check.message
811
+ });
812
+ status.dirty();
813
+ }
814
+ } else if (check.kind === "uuid") {
815
+ if (!uuidRegex.test(input.data)) {
816
+ ctx = this._getOrReturnCtx(input, ctx);
817
+ addIssueToContext(ctx, {
818
+ validation: "uuid",
819
+ code: ZodIssueCode.invalid_string,
820
+ message: check.message
821
+ });
822
+ status.dirty();
823
+ }
824
+ } else if (check.kind === "cuid") {
825
+ if (!cuidRegex.test(input.data)) {
826
+ ctx = this._getOrReturnCtx(input, ctx);
827
+ addIssueToContext(ctx, {
828
+ validation: "cuid",
829
+ code: ZodIssueCode.invalid_string,
830
+ message: check.message
831
+ });
832
+ status.dirty();
833
+ }
834
+ } else if (check.kind === "url") {
835
+ try {
836
+ new URL(input.data);
837
+ } catch (_a) {
838
+ ctx = this._getOrReturnCtx(input, ctx);
839
+ addIssueToContext(ctx, {
840
+ validation: "url",
841
+ code: ZodIssueCode.invalid_string,
842
+ message: check.message
843
+ });
844
+ status.dirty();
845
+ }
846
+ } else if (check.kind === "regex") {
847
+ check.regex.lastIndex = 0;
848
+ const testResult = check.regex.test(input.data);
849
+ if (!testResult) {
850
+ ctx = this._getOrReturnCtx(input, ctx);
851
+ addIssueToContext(ctx, {
852
+ validation: "regex",
853
+ code: ZodIssueCode.invalid_string,
854
+ message: check.message
855
+ });
856
+ status.dirty();
857
+ }
858
+ } else if (check.kind === "trim") {
859
+ input.data = input.data.trim();
860
+ } else if (check.kind === "startsWith") {
861
+ if (!input.data.startsWith(check.value)) {
862
+ ctx = this._getOrReturnCtx(input, ctx);
863
+ addIssueToContext(ctx, {
864
+ code: ZodIssueCode.invalid_string,
865
+ validation: { startsWith: check.value },
866
+ message: check.message
867
+ });
868
+ status.dirty();
869
+ }
870
+ } else if (check.kind === "endsWith") {
871
+ if (!input.data.endsWith(check.value)) {
872
+ ctx = this._getOrReturnCtx(input, ctx);
873
+ addIssueToContext(ctx, {
874
+ code: ZodIssueCode.invalid_string,
875
+ validation: { endsWith: check.value },
876
+ message: check.message
877
+ });
878
+ status.dirty();
879
+ }
880
+ } else {
881
+ util.assertNever(check);
882
+ }
883
+ }
884
+ return { status: status.value, value: input.data };
885
+ }
886
+ _addCheck(check) {
887
+ return new ZodString({
888
+ ...this._def,
889
+ checks: [...this._def.checks, check]
890
+ });
891
+ }
892
+ email(message) {
893
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
894
+ }
895
+ url(message) {
896
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
897
+ }
898
+ uuid(message) {
899
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
900
+ }
901
+ cuid(message) {
902
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
903
+ }
904
+ regex(regex, message) {
905
+ return this._addCheck({
906
+ kind: "regex",
907
+ regex,
908
+ ...errorUtil.errToObj(message)
909
+ });
910
+ }
911
+ startsWith(value, message) {
912
+ return this._addCheck({
913
+ kind: "startsWith",
914
+ value,
915
+ ...errorUtil.errToObj(message)
916
+ });
917
+ }
918
+ endsWith(value, message) {
919
+ return this._addCheck({
920
+ kind: "endsWith",
921
+ value,
922
+ ...errorUtil.errToObj(message)
923
+ });
924
+ }
925
+ min(minLength, message) {
926
+ return this._addCheck({
927
+ kind: "min",
928
+ value: minLength,
929
+ ...errorUtil.errToObj(message)
930
+ });
931
+ }
932
+ max(maxLength, message) {
933
+ return this._addCheck({
934
+ kind: "max",
935
+ value: maxLength,
936
+ ...errorUtil.errToObj(message)
937
+ });
938
+ }
939
+ length(len, message) {
940
+ return this.min(len, message).max(len, message);
941
+ }
942
+ get isEmail() {
943
+ return !!this._def.checks.find((ch) => ch.kind === "email");
944
+ }
945
+ get isURL() {
946
+ return !!this._def.checks.find((ch) => ch.kind === "url");
947
+ }
948
+ get isUUID() {
949
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
950
+ }
951
+ get isCUID() {
952
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
953
+ }
954
+ get minLength() {
955
+ let min = null;
956
+ for (const ch of this._def.checks) {
957
+ if (ch.kind === "min") {
958
+ if (min === null || ch.value > min)
959
+ min = ch.value;
960
+ }
961
+ }
962
+ return min;
963
+ }
964
+ get maxLength() {
965
+ let max = null;
966
+ for (const ch of this._def.checks) {
967
+ if (ch.kind === "max") {
968
+ if (max === null || ch.value < max)
969
+ max = ch.value;
970
+ }
971
+ }
972
+ return max;
973
+ }
974
+ };
975
+ ZodString.create = (params2) => {
976
+ return new ZodString({
977
+ checks: [],
978
+ typeName: ZodFirstPartyTypeKind.ZodString,
979
+ ...processCreateParams(params2)
980
+ });
981
+ };
982
+ function floatSafeRemainder(val, step) {
983
+ const valDecCount = (val.toString().split(".")[1] || "").length;
984
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
985
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
986
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
987
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
988
+ return valInt % stepInt / Math.pow(10, decCount);
989
+ }
990
+ var ZodNumber = class extends ZodType {
991
+ constructor() {
992
+ super(...arguments);
993
+ this.min = this.gte;
994
+ this.max = this.lte;
995
+ this.step = this.multipleOf;
996
+ }
997
+ _parse(input) {
998
+ const parsedType = this._getType(input);
999
+ if (parsedType !== ZodParsedType.number) {
1000
+ const ctx2 = this._getOrReturnCtx(input);
1001
+ addIssueToContext(ctx2, {
1002
+ code: ZodIssueCode.invalid_type,
1003
+ expected: ZodParsedType.number,
1004
+ received: ctx2.parsedType
1005
+ });
1006
+ return INVALID;
1007
+ }
1008
+ let ctx = void 0;
1009
+ const status = new ParseStatus();
1010
+ for (const check of this._def.checks) {
1011
+ if (check.kind === "int") {
1012
+ if (!util.isInteger(input.data)) {
1013
+ ctx = this._getOrReturnCtx(input, ctx);
1014
+ addIssueToContext(ctx, {
1015
+ code: ZodIssueCode.invalid_type,
1016
+ expected: "integer",
1017
+ received: "float",
1018
+ message: check.message
1019
+ });
1020
+ status.dirty();
1021
+ }
1022
+ } else if (check.kind === "min") {
1023
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1024
+ if (tooSmall) {
1025
+ ctx = this._getOrReturnCtx(input, ctx);
1026
+ addIssueToContext(ctx, {
1027
+ code: ZodIssueCode.too_small,
1028
+ minimum: check.value,
1029
+ type: "number",
1030
+ inclusive: check.inclusive,
1031
+ message: check.message
1032
+ });
1033
+ status.dirty();
1034
+ }
1035
+ } else if (check.kind === "max") {
1036
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1037
+ if (tooBig) {
1038
+ ctx = this._getOrReturnCtx(input, ctx);
1039
+ addIssueToContext(ctx, {
1040
+ code: ZodIssueCode.too_big,
1041
+ maximum: check.value,
1042
+ type: "number",
1043
+ inclusive: check.inclusive,
1044
+ message: check.message
1045
+ });
1046
+ status.dirty();
1047
+ }
1048
+ } else if (check.kind === "multipleOf") {
1049
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1050
+ ctx = this._getOrReturnCtx(input, ctx);
1051
+ addIssueToContext(ctx, {
1052
+ code: ZodIssueCode.not_multiple_of,
1053
+ multipleOf: check.value,
1054
+ message: check.message
1055
+ });
1056
+ status.dirty();
1057
+ }
1058
+ } else {
1059
+ util.assertNever(check);
1060
+ }
1061
+ }
1062
+ return { status: status.value, value: input.data };
1063
+ }
1064
+ gte(value, message) {
1065
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1066
+ }
1067
+ gt(value, message) {
1068
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1069
+ }
1070
+ lte(value, message) {
1071
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1072
+ }
1073
+ lt(value, message) {
1074
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1075
+ }
1076
+ setLimit(kind, value, inclusive, message) {
1077
+ return new ZodNumber({
1078
+ ...this._def,
1079
+ checks: [
1080
+ ...this._def.checks,
1081
+ {
1082
+ kind,
1083
+ value,
1084
+ inclusive,
1085
+ message: errorUtil.toString(message)
1086
+ }
1087
+ ]
1088
+ });
1089
+ }
1090
+ _addCheck(check) {
1091
+ return new ZodNumber({
1092
+ ...this._def,
1093
+ checks: [...this._def.checks, check]
1094
+ });
1095
+ }
1096
+ int(message) {
1097
+ return this._addCheck({
1098
+ kind: "int",
1099
+ message: errorUtil.toString(message)
1100
+ });
1101
+ }
1102
+ positive(message) {
1103
+ return this._addCheck({
1104
+ kind: "min",
1105
+ value: 0,
1106
+ inclusive: false,
1107
+ message: errorUtil.toString(message)
1108
+ });
1109
+ }
1110
+ negative(message) {
1111
+ return this._addCheck({
1112
+ kind: "max",
1113
+ value: 0,
1114
+ inclusive: false,
1115
+ message: errorUtil.toString(message)
1116
+ });
1117
+ }
1118
+ nonpositive(message) {
1119
+ return this._addCheck({
1120
+ kind: "max",
1121
+ value: 0,
1122
+ inclusive: true,
1123
+ message: errorUtil.toString(message)
1124
+ });
1125
+ }
1126
+ nonnegative(message) {
1127
+ return this._addCheck({
1128
+ kind: "min",
1129
+ value: 0,
1130
+ inclusive: true,
1131
+ message: errorUtil.toString(message)
1132
+ });
1133
+ }
1134
+ multipleOf(value, message) {
1135
+ return this._addCheck({
1136
+ kind: "multipleOf",
1137
+ value,
1138
+ message: errorUtil.toString(message)
1139
+ });
1140
+ }
1141
+ get minValue() {
1142
+ let min = null;
1143
+ for (const ch of this._def.checks) {
1144
+ if (ch.kind === "min") {
1145
+ if (min === null || ch.value > min)
1146
+ min = ch.value;
1147
+ }
1148
+ }
1149
+ return min;
1150
+ }
1151
+ get maxValue() {
1152
+ let max = null;
1153
+ for (const ch of this._def.checks) {
1154
+ if (ch.kind === "max") {
1155
+ if (max === null || ch.value < max)
1156
+ max = ch.value;
1157
+ }
1158
+ }
1159
+ return max;
1160
+ }
1161
+ get isInt() {
1162
+ return !!this._def.checks.find((ch) => ch.kind === "int");
1163
+ }
1164
+ };
1165
+ ZodNumber.create = (params2) => {
1166
+ return new ZodNumber({
1167
+ checks: [],
1168
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1169
+ ...processCreateParams(params2)
1170
+ });
1171
+ };
1172
+ var ZodBigInt = class extends ZodType {
1173
+ _parse(input) {
1174
+ const parsedType = this._getType(input);
1175
+ if (parsedType !== ZodParsedType.bigint) {
1176
+ const ctx = this._getOrReturnCtx(input);
1177
+ addIssueToContext(ctx, {
1178
+ code: ZodIssueCode.invalid_type,
1179
+ expected: ZodParsedType.bigint,
1180
+ received: ctx.parsedType
1181
+ });
1182
+ return INVALID;
1183
+ }
1184
+ return OK(input.data);
1185
+ }
1186
+ };
1187
+ ZodBigInt.create = (params2) => {
1188
+ return new ZodBigInt({
1189
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1190
+ ...processCreateParams(params2)
1191
+ });
1192
+ };
1193
+ var ZodBoolean = class extends ZodType {
1194
+ _parse(input) {
1195
+ const parsedType = this._getType(input);
1196
+ if (parsedType !== ZodParsedType.boolean) {
1197
+ const ctx = this._getOrReturnCtx(input);
1198
+ addIssueToContext(ctx, {
1199
+ code: ZodIssueCode.invalid_type,
1200
+ expected: ZodParsedType.boolean,
1201
+ received: ctx.parsedType
1202
+ });
1203
+ return INVALID;
1204
+ }
1205
+ return OK(input.data);
1206
+ }
1207
+ };
1208
+ ZodBoolean.create = (params2) => {
1209
+ return new ZodBoolean({
1210
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1211
+ ...processCreateParams(params2)
1212
+ });
1213
+ };
1214
+ var ZodDate = class extends ZodType {
1215
+ _parse(input) {
1216
+ const parsedType = this._getType(input);
1217
+ if (parsedType !== ZodParsedType.date) {
1218
+ const ctx2 = this._getOrReturnCtx(input);
1219
+ addIssueToContext(ctx2, {
1220
+ code: ZodIssueCode.invalid_type,
1221
+ expected: ZodParsedType.date,
1222
+ received: ctx2.parsedType
1223
+ });
1224
+ return INVALID;
1225
+ }
1226
+ if (isNaN(input.data.getTime())) {
1227
+ const ctx2 = this._getOrReturnCtx(input);
1228
+ addIssueToContext(ctx2, {
1229
+ code: ZodIssueCode.invalid_date
1230
+ });
1231
+ return INVALID;
1232
+ }
1233
+ const status = new ParseStatus();
1234
+ let ctx = void 0;
1235
+ for (const check of this._def.checks) {
1236
+ if (check.kind === "min") {
1237
+ if (input.data.getTime() < check.value) {
1238
+ ctx = this._getOrReturnCtx(input, ctx);
1239
+ addIssueToContext(ctx, {
1240
+ code: ZodIssueCode.too_small,
1241
+ message: check.message,
1242
+ inclusive: true,
1243
+ minimum: check.value,
1244
+ type: "date"
1245
+ });
1246
+ status.dirty();
1247
+ }
1248
+ } else if (check.kind === "max") {
1249
+ if (input.data.getTime() > check.value) {
1250
+ ctx = this._getOrReturnCtx(input, ctx);
1251
+ addIssueToContext(ctx, {
1252
+ code: ZodIssueCode.too_big,
1253
+ message: check.message,
1254
+ inclusive: true,
1255
+ maximum: check.value,
1256
+ type: "date"
1257
+ });
1258
+ status.dirty();
1259
+ }
1260
+ } else {
1261
+ util.assertNever(check);
1262
+ }
1263
+ }
1264
+ return {
1265
+ status: status.value,
1266
+ value: new Date(input.data.getTime())
1267
+ };
1268
+ }
1269
+ _addCheck(check) {
1270
+ return new ZodDate({
1271
+ ...this._def,
1272
+ checks: [...this._def.checks, check]
1273
+ });
1274
+ }
1275
+ min(minDate, message) {
1276
+ return this._addCheck({
1277
+ kind: "min",
1278
+ value: minDate.getTime(),
1279
+ message: errorUtil.toString(message)
1280
+ });
1281
+ }
1282
+ max(maxDate, message) {
1283
+ return this._addCheck({
1284
+ kind: "max",
1285
+ value: maxDate.getTime(),
1286
+ message: errorUtil.toString(message)
1287
+ });
1288
+ }
1289
+ get minDate() {
1290
+ let min = null;
1291
+ for (const ch of this._def.checks) {
1292
+ if (ch.kind === "min") {
1293
+ if (min === null || ch.value > min)
1294
+ min = ch.value;
1295
+ }
1296
+ }
1297
+ return min != null ? new Date(min) : null;
1298
+ }
1299
+ get maxDate() {
1300
+ let max = null;
1301
+ for (const ch of this._def.checks) {
1302
+ if (ch.kind === "max") {
1303
+ if (max === null || ch.value < max)
1304
+ max = ch.value;
1305
+ }
1306
+ }
1307
+ return max != null ? new Date(max) : null;
1308
+ }
1309
+ };
1310
+ ZodDate.create = (params2) => {
1311
+ return new ZodDate({
1312
+ checks: [],
1313
+ typeName: ZodFirstPartyTypeKind.ZodDate,
1314
+ ...processCreateParams(params2)
1315
+ });
1316
+ };
1317
+ var ZodUndefined = class extends ZodType {
1318
+ _parse(input) {
1319
+ const parsedType = this._getType(input);
1320
+ if (parsedType !== ZodParsedType.undefined) {
1321
+ const ctx = this._getOrReturnCtx(input);
1322
+ addIssueToContext(ctx, {
1323
+ code: ZodIssueCode.invalid_type,
1324
+ expected: ZodParsedType.undefined,
1325
+ received: ctx.parsedType
1326
+ });
1327
+ return INVALID;
1328
+ }
1329
+ return OK(input.data);
1330
+ }
1331
+ };
1332
+ ZodUndefined.create = (params2) => {
1333
+ return new ZodUndefined({
1334
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
1335
+ ...processCreateParams(params2)
1336
+ });
1337
+ };
1338
+ var ZodNull = class extends ZodType {
1339
+ _parse(input) {
1340
+ const parsedType = this._getType(input);
1341
+ if (parsedType !== ZodParsedType.null) {
1342
+ const ctx = this._getOrReturnCtx(input);
1343
+ addIssueToContext(ctx, {
1344
+ code: ZodIssueCode.invalid_type,
1345
+ expected: ZodParsedType.null,
1346
+ received: ctx.parsedType
1347
+ });
1348
+ return INVALID;
1349
+ }
1350
+ return OK(input.data);
1351
+ }
1352
+ };
1353
+ ZodNull.create = (params2) => {
1354
+ return new ZodNull({
1355
+ typeName: ZodFirstPartyTypeKind.ZodNull,
1356
+ ...processCreateParams(params2)
1357
+ });
1358
+ };
1359
+ var ZodAny = class extends ZodType {
1360
+ constructor() {
1361
+ super(...arguments);
1362
+ this._any = true;
1363
+ }
1364
+ _parse(input) {
1365
+ return OK(input.data);
1366
+ }
1367
+ };
1368
+ ZodAny.create = (params2) => {
1369
+ return new ZodAny({
1370
+ typeName: ZodFirstPartyTypeKind.ZodAny,
1371
+ ...processCreateParams(params2)
1372
+ });
1373
+ };
1374
+ var ZodUnknown = class extends ZodType {
1375
+ constructor() {
1376
+ super(...arguments);
1377
+ this._unknown = true;
1378
+ }
1379
+ _parse(input) {
1380
+ return OK(input.data);
1381
+ }
1382
+ };
1383
+ ZodUnknown.create = (params2) => {
1384
+ return new ZodUnknown({
1385
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
1386
+ ...processCreateParams(params2)
1387
+ });
1388
+ };
1389
+ var ZodNever = class extends ZodType {
1390
+ _parse(input) {
1391
+ const ctx = this._getOrReturnCtx(input);
1392
+ addIssueToContext(ctx, {
1393
+ code: ZodIssueCode.invalid_type,
1394
+ expected: ZodParsedType.never,
1395
+ received: ctx.parsedType
1396
+ });
1397
+ return INVALID;
1398
+ }
1399
+ };
1400
+ ZodNever.create = (params2) => {
1401
+ return new ZodNever({
1402
+ typeName: ZodFirstPartyTypeKind.ZodNever,
1403
+ ...processCreateParams(params2)
1404
+ });
1405
+ };
1406
+ var ZodVoid = class extends ZodType {
1407
+ _parse(input) {
1408
+ const parsedType = this._getType(input);
1409
+ if (parsedType !== ZodParsedType.undefined) {
1410
+ const ctx = this._getOrReturnCtx(input);
1411
+ addIssueToContext(ctx, {
1412
+ code: ZodIssueCode.invalid_type,
1413
+ expected: ZodParsedType.void,
1414
+ received: ctx.parsedType
1415
+ });
1416
+ return INVALID;
1417
+ }
1418
+ return OK(input.data);
1419
+ }
1420
+ };
1421
+ ZodVoid.create = (params2) => {
1422
+ return new ZodVoid({
1423
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
1424
+ ...processCreateParams(params2)
1425
+ });
1426
+ };
1427
+ var ZodArray = class extends ZodType {
1428
+ _parse(input) {
1429
+ const { ctx, status } = this._processInputParams(input);
1430
+ const def = this._def;
1431
+ if (ctx.parsedType !== ZodParsedType.array) {
1432
+ addIssueToContext(ctx, {
1433
+ code: ZodIssueCode.invalid_type,
1434
+ expected: ZodParsedType.array,
1435
+ received: ctx.parsedType
1436
+ });
1437
+ return INVALID;
1438
+ }
1439
+ if (def.minLength !== null) {
1440
+ if (ctx.data.length < def.minLength.value) {
1441
+ addIssueToContext(ctx, {
1442
+ code: ZodIssueCode.too_small,
1443
+ minimum: def.minLength.value,
1444
+ type: "array",
1445
+ inclusive: true,
1446
+ message: def.minLength.message
1447
+ });
1448
+ status.dirty();
1449
+ }
1450
+ }
1451
+ if (def.maxLength !== null) {
1452
+ if (ctx.data.length > def.maxLength.value) {
1453
+ addIssueToContext(ctx, {
1454
+ code: ZodIssueCode.too_big,
1455
+ maximum: def.maxLength.value,
1456
+ type: "array",
1457
+ inclusive: true,
1458
+ message: def.maxLength.message
1459
+ });
1460
+ status.dirty();
1461
+ }
1462
+ }
1463
+ if (ctx.common.async) {
1464
+ return Promise.all(ctx.data.map((item, i) => {
1465
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1466
+ })).then((result2) => {
1467
+ return ParseStatus.mergeArray(status, result2);
1468
+ });
1469
+ }
1470
+ const result = ctx.data.map((item, i) => {
1471
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1472
+ });
1473
+ return ParseStatus.mergeArray(status, result);
1474
+ }
1475
+ get element() {
1476
+ return this._def.type;
1477
+ }
1478
+ min(minLength, message) {
1479
+ return new ZodArray({
1480
+ ...this._def,
1481
+ minLength: { value: minLength, message: errorUtil.toString(message) }
1482
+ });
1483
+ }
1484
+ max(maxLength, message) {
1485
+ return new ZodArray({
1486
+ ...this._def,
1487
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
1488
+ });
1489
+ }
1490
+ length(len, message) {
1491
+ return this.min(len, message).max(len, message);
1492
+ }
1493
+ nonempty(message) {
1494
+ return this.min(1, message);
1495
+ }
1496
+ };
1497
+ ZodArray.create = (schema, params2) => {
1498
+ return new ZodArray({
1499
+ type: schema,
1500
+ minLength: null,
1501
+ maxLength: null,
1502
+ typeName: ZodFirstPartyTypeKind.ZodArray,
1503
+ ...processCreateParams(params2)
1504
+ });
1505
+ };
1506
+ var objectUtil;
1507
+ (function(objectUtil2) {
1508
+ objectUtil2.mergeShapes = (first, second) => {
1509
+ return {
1510
+ ...first,
1511
+ ...second
1512
+ };
1513
+ };
1514
+ })(objectUtil || (objectUtil = {}));
1515
+ var AugmentFactory = (def) => (augmentation) => {
1516
+ return new ZodObject({
1517
+ ...def,
1518
+ shape: () => ({
1519
+ ...def.shape(),
1520
+ ...augmentation
1521
+ })
1522
+ });
1523
+ };
1524
+ function deepPartialify(schema) {
1525
+ if (schema instanceof ZodObject) {
1526
+ const newShape = {};
1527
+ for (const key in schema.shape) {
1528
+ const fieldSchema = schema.shape[key];
1529
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1530
+ }
1531
+ return new ZodObject({
1532
+ ...schema._def,
1533
+ shape: () => newShape
1534
+ });
1535
+ } else if (schema instanceof ZodArray) {
1536
+ return ZodArray.create(deepPartialify(schema.element));
1537
+ } else if (schema instanceof ZodOptional) {
1538
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
1539
+ } else if (schema instanceof ZodNullable) {
1540
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
1541
+ } else if (schema instanceof ZodTuple) {
1542
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
1543
+ } else {
1544
+ return schema;
1545
+ }
1546
+ }
1547
+ var ZodObject = class extends ZodType {
1548
+ constructor() {
1549
+ super(...arguments);
1550
+ this._cached = null;
1551
+ this.nonstrict = this.passthrough;
1552
+ this.augment = AugmentFactory(this._def);
1553
+ this.extend = AugmentFactory(this._def);
1554
+ }
1555
+ _getCached() {
1556
+ if (this._cached !== null)
1557
+ return this._cached;
1558
+ const shape = this._def.shape();
1559
+ const keys = util.objectKeys(shape);
1560
+ return this._cached = { shape, keys };
1561
+ }
1562
+ _parse(input) {
1563
+ const parsedType = this._getType(input);
1564
+ if (parsedType !== ZodParsedType.object) {
1565
+ const ctx2 = this._getOrReturnCtx(input);
1566
+ addIssueToContext(ctx2, {
1567
+ code: ZodIssueCode.invalid_type,
1568
+ expected: ZodParsedType.object,
1569
+ received: ctx2.parsedType
1570
+ });
1571
+ return INVALID;
1572
+ }
1573
+ const { status, ctx } = this._processInputParams(input);
1574
+ const { shape, keys: shapeKeys } = this._getCached();
1575
+ const extraKeys = [];
1576
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
1577
+ for (const key in ctx.data) {
1578
+ if (!shapeKeys.includes(key)) {
1579
+ extraKeys.push(key);
1580
+ }
1581
+ }
1582
+ }
1583
+ const pairs = [];
1584
+ for (const key of shapeKeys) {
1585
+ const keyValidator = shape[key];
1586
+ const value = ctx.data[key];
1587
+ pairs.push({
1588
+ key: { status: "valid", value: key },
1589
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
1590
+ alwaysSet: key in ctx.data
1591
+ });
1592
+ }
1593
+ if (this._def.catchall instanceof ZodNever) {
1594
+ const unknownKeys = this._def.unknownKeys;
1595
+ if (unknownKeys === "passthrough") {
1596
+ for (const key of extraKeys) {
1597
+ pairs.push({
1598
+ key: { status: "valid", value: key },
1599
+ value: { status: "valid", value: ctx.data[key] }
1600
+ });
1601
+ }
1602
+ } else if (unknownKeys === "strict") {
1603
+ if (extraKeys.length > 0) {
1604
+ addIssueToContext(ctx, {
1605
+ code: ZodIssueCode.unrecognized_keys,
1606
+ keys: extraKeys
1607
+ });
1608
+ status.dirty();
1609
+ }
1610
+ } else if (unknownKeys === "strip")
1611
+ ;
1612
+ else {
1613
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
1614
+ }
1615
+ } else {
1616
+ const catchall = this._def.catchall;
1617
+ for (const key of extraKeys) {
1618
+ const value = ctx.data[key];
1619
+ pairs.push({
1620
+ key: { status: "valid", value: key },
1621
+ value: catchall._parse(
1622
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
1623
+ ),
1624
+ alwaysSet: key in ctx.data
1625
+ });
1626
+ }
1627
+ }
1628
+ if (ctx.common.async) {
1629
+ return Promise.resolve().then(async () => {
1630
+ const syncPairs = [];
1631
+ for (const pair of pairs) {
1632
+ const key = await pair.key;
1633
+ syncPairs.push({
1634
+ key,
1635
+ value: await pair.value,
1636
+ alwaysSet: pair.alwaysSet
1637
+ });
1638
+ }
1639
+ return syncPairs;
1640
+ }).then((syncPairs) => {
1641
+ return ParseStatus.mergeObjectSync(status, syncPairs);
1642
+ });
1643
+ } else {
1644
+ return ParseStatus.mergeObjectSync(status, pairs);
1645
+ }
1646
+ }
1647
+ get shape() {
1648
+ return this._def.shape();
1649
+ }
1650
+ strict(message) {
1651
+ errorUtil.errToObj;
1652
+ return new ZodObject({
1653
+ ...this._def,
1654
+ unknownKeys: "strict",
1655
+ ...message !== void 0 ? {
1656
+ errorMap: (issue, ctx) => {
1657
+ var _a, _b, _c, _d;
1658
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
1659
+ if (issue.code === "unrecognized_keys")
1660
+ return {
1661
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
1662
+ };
1663
+ return {
1664
+ message: defaultError
1665
+ };
1666
+ }
1667
+ } : {}
1668
+ });
1669
+ }
1670
+ strip() {
1671
+ return new ZodObject({
1672
+ ...this._def,
1673
+ unknownKeys: "strip"
1674
+ });
1675
+ }
1676
+ passthrough() {
1677
+ return new ZodObject({
1678
+ ...this._def,
1679
+ unknownKeys: "passthrough"
1680
+ });
1681
+ }
1682
+ setKey(key, schema) {
1683
+ return this.augment({ [key]: schema });
1684
+ }
1685
+ merge(merging) {
1686
+ const merged = new ZodObject({
1687
+ unknownKeys: merging._def.unknownKeys,
1688
+ catchall: merging._def.catchall,
1689
+ shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1690
+ typeName: ZodFirstPartyTypeKind.ZodObject
1691
+ });
1692
+ return merged;
1693
+ }
1694
+ catchall(index) {
1695
+ return new ZodObject({
1696
+ ...this._def,
1697
+ catchall: index
1698
+ });
1699
+ }
1700
+ pick(mask) {
1701
+ const shape = {};
1702
+ util.objectKeys(mask).map((key) => {
1703
+ if (this.shape[key])
1704
+ shape[key] = this.shape[key];
1705
+ });
1706
+ return new ZodObject({
1707
+ ...this._def,
1708
+ shape: () => shape
1709
+ });
1710
+ }
1711
+ omit(mask) {
1712
+ const shape = {};
1713
+ util.objectKeys(this.shape).map((key) => {
1714
+ if (util.objectKeys(mask).indexOf(key) === -1) {
1715
+ shape[key] = this.shape[key];
1716
+ }
1717
+ });
1718
+ return new ZodObject({
1719
+ ...this._def,
1720
+ shape: () => shape
1721
+ });
1722
+ }
1723
+ deepPartial() {
1724
+ return deepPartialify(this);
1725
+ }
1726
+ partial(mask) {
1727
+ const newShape = {};
1728
+ if (mask) {
1729
+ util.objectKeys(this.shape).map((key) => {
1730
+ if (util.objectKeys(mask).indexOf(key) === -1) {
1731
+ newShape[key] = this.shape[key];
1732
+ } else {
1733
+ newShape[key] = this.shape[key].optional();
1734
+ }
1735
+ });
1736
+ return new ZodObject({
1737
+ ...this._def,
1738
+ shape: () => newShape
1739
+ });
1740
+ } else {
1741
+ for (const key in this.shape) {
1742
+ const fieldSchema = this.shape[key];
1743
+ newShape[key] = fieldSchema.optional();
1744
+ }
1745
+ }
1746
+ return new ZodObject({
1747
+ ...this._def,
1748
+ shape: () => newShape
1749
+ });
1750
+ }
1751
+ required() {
1752
+ const newShape = {};
1753
+ for (const key in this.shape) {
1754
+ const fieldSchema = this.shape[key];
1755
+ let newField = fieldSchema;
1756
+ while (newField instanceof ZodOptional) {
1757
+ newField = newField._def.innerType;
1758
+ }
1759
+ newShape[key] = newField;
1760
+ }
1761
+ return new ZodObject({
1762
+ ...this._def,
1763
+ shape: () => newShape
1764
+ });
1765
+ }
1766
+ keyof() {
1767
+ return createZodEnum(util.objectKeys(this.shape));
1768
+ }
1769
+ };
1770
+ ZodObject.create = (shape, params2) => {
1771
+ return new ZodObject({
1772
+ shape: () => shape,
1773
+ unknownKeys: "strip",
1774
+ catchall: ZodNever.create(),
1775
+ typeName: ZodFirstPartyTypeKind.ZodObject,
1776
+ ...processCreateParams(params2)
1777
+ });
1778
+ };
1779
+ ZodObject.strictCreate = (shape, params2) => {
1780
+ return new ZodObject({
1781
+ shape: () => shape,
1782
+ unknownKeys: "strict",
1783
+ catchall: ZodNever.create(),
1784
+ typeName: ZodFirstPartyTypeKind.ZodObject,
1785
+ ...processCreateParams(params2)
1786
+ });
1787
+ };
1788
+ ZodObject.lazycreate = (shape, params2) => {
1789
+ return new ZodObject({
1790
+ shape,
1791
+ unknownKeys: "strip",
1792
+ catchall: ZodNever.create(),
1793
+ typeName: ZodFirstPartyTypeKind.ZodObject,
1794
+ ...processCreateParams(params2)
1795
+ });
1796
+ };
1797
+ var ZodUnion = class extends ZodType {
1798
+ _parse(input) {
1799
+ const { ctx } = this._processInputParams(input);
1800
+ const options = this._def.options;
1801
+ function handleResults(results) {
1802
+ for (const result of results) {
1803
+ if (result.result.status === "valid") {
1804
+ return result.result;
1805
+ }
1806
+ }
1807
+ for (const result of results) {
1808
+ if (result.result.status === "dirty") {
1809
+ ctx.common.issues.push(...result.ctx.common.issues);
1810
+ return result.result;
1811
+ }
1812
+ }
1813
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
1814
+ addIssueToContext(ctx, {
1815
+ code: ZodIssueCode.invalid_union,
1816
+ unionErrors
1817
+ });
1818
+ return INVALID;
1819
+ }
1820
+ if (ctx.common.async) {
1821
+ return Promise.all(options.map(async (option) => {
1822
+ const childCtx = {
1823
+ ...ctx,
1824
+ common: {
1825
+ ...ctx.common,
1826
+ issues: []
1827
+ },
1828
+ parent: null
1829
+ };
1830
+ return {
1831
+ result: await option._parseAsync({
1832
+ data: ctx.data,
1833
+ path: ctx.path,
1834
+ parent: childCtx
1835
+ }),
1836
+ ctx: childCtx
1837
+ };
1838
+ })).then(handleResults);
1839
+ } else {
1840
+ let dirty = void 0;
1841
+ const issues = [];
1842
+ for (const option of options) {
1843
+ const childCtx = {
1844
+ ...ctx,
1845
+ common: {
1846
+ ...ctx.common,
1847
+ issues: []
1848
+ },
1849
+ parent: null
1850
+ };
1851
+ const result = option._parseSync({
1852
+ data: ctx.data,
1853
+ path: ctx.path,
1854
+ parent: childCtx
1855
+ });
1856
+ if (result.status === "valid") {
1857
+ return result;
1858
+ } else if (result.status === "dirty" && !dirty) {
1859
+ dirty = { result, ctx: childCtx };
1860
+ }
1861
+ if (childCtx.common.issues.length) {
1862
+ issues.push(childCtx.common.issues);
1863
+ }
1864
+ }
1865
+ if (dirty) {
1866
+ ctx.common.issues.push(...dirty.ctx.common.issues);
1867
+ return dirty.result;
1868
+ }
1869
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
1870
+ addIssueToContext(ctx, {
1871
+ code: ZodIssueCode.invalid_union,
1872
+ unionErrors
1873
+ });
1874
+ return INVALID;
1875
+ }
1876
+ }
1877
+ get options() {
1878
+ return this._def.options;
1879
+ }
1880
+ };
1881
+ ZodUnion.create = (types, params2) => {
1882
+ return new ZodUnion({
1883
+ options: types,
1884
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
1885
+ ...processCreateParams(params2)
1886
+ });
1887
+ };
1888
+ var ZodDiscriminatedUnion = class extends ZodType {
1889
+ _parse(input) {
1890
+ const { ctx } = this._processInputParams(input);
1891
+ if (ctx.parsedType !== ZodParsedType.object) {
1892
+ addIssueToContext(ctx, {
1893
+ code: ZodIssueCode.invalid_type,
1894
+ expected: ZodParsedType.object,
1895
+ received: ctx.parsedType
1896
+ });
1897
+ return INVALID;
1898
+ }
1899
+ const discriminator = this.discriminator;
1900
+ const discriminatorValue = ctx.data[discriminator];
1901
+ const option = this.options.get(discriminatorValue);
1902
+ if (!option) {
1903
+ addIssueToContext(ctx, {
1904
+ code: ZodIssueCode.invalid_union_discriminator,
1905
+ options: this.validDiscriminatorValues,
1906
+ path: [discriminator]
1907
+ });
1908
+ return INVALID;
1909
+ }
1910
+ if (ctx.common.async) {
1911
+ return option._parseAsync({
1912
+ data: ctx.data,
1913
+ path: ctx.path,
1914
+ parent: ctx
1915
+ });
1916
+ } else {
1917
+ return option._parseSync({
1918
+ data: ctx.data,
1919
+ path: ctx.path,
1920
+ parent: ctx
1921
+ });
1922
+ }
1923
+ }
1924
+ get discriminator() {
1925
+ return this._def.discriminator;
1926
+ }
1927
+ get validDiscriminatorValues() {
1928
+ return Array.from(this.options.keys());
1929
+ }
1930
+ get options() {
1931
+ return this._def.options;
1932
+ }
1933
+ static create(discriminator, types, params2) {
1934
+ const options = /* @__PURE__ */ new Map();
1935
+ try {
1936
+ types.forEach((type) => {
1937
+ const discriminatorValue = type.shape[discriminator].value;
1938
+ options.set(discriminatorValue, type);
1939
+ });
1940
+ } catch (e) {
1941
+ throw new Error("The discriminator value could not be extracted from all the provided schemas");
1942
+ }
1943
+ if (options.size !== types.length) {
1944
+ throw new Error("Some of the discriminator values are not unique");
1945
+ }
1946
+ return new ZodDiscriminatedUnion({
1947
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
1948
+ discriminator,
1949
+ options,
1950
+ ...processCreateParams(params2)
1951
+ });
1952
+ }
1953
+ };
1954
+ function mergeValues(a, b) {
1955
+ const aType = getParsedType(a);
1956
+ const bType = getParsedType(b);
1957
+ if (a === b) {
1958
+ return { valid: true, data: a };
1959
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
1960
+ const bKeys = util.objectKeys(b);
1961
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
1962
+ const newObj = { ...a, ...b };
1963
+ for (const key of sharedKeys) {
1964
+ const sharedValue = mergeValues(a[key], b[key]);
1965
+ if (!sharedValue.valid) {
1966
+ return { valid: false };
1967
+ }
1968
+ newObj[key] = sharedValue.data;
1969
+ }
1970
+ return { valid: true, data: newObj };
1971
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
1972
+ if (a.length !== b.length) {
1973
+ return { valid: false };
1974
+ }
1975
+ const newArray = [];
1976
+ for (let index = 0; index < a.length; index++) {
1977
+ const itemA = a[index];
1978
+ const itemB = b[index];
1979
+ const sharedValue = mergeValues(itemA, itemB);
1980
+ if (!sharedValue.valid) {
1981
+ return { valid: false };
1982
+ }
1983
+ newArray.push(sharedValue.data);
1984
+ }
1985
+ return { valid: true, data: newArray };
1986
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
1987
+ return { valid: true, data: a };
1988
+ } else {
1989
+ return { valid: false };
1990
+ }
1991
+ }
1992
+ var ZodIntersection = class extends ZodType {
1993
+ _parse(input) {
1994
+ const { status, ctx } = this._processInputParams(input);
1995
+ const handleParsed = (parsedLeft, parsedRight) => {
1996
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
1997
+ return INVALID;
1998
+ }
1999
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2000
+ if (!merged.valid) {
2001
+ addIssueToContext(ctx, {
2002
+ code: ZodIssueCode.invalid_intersection_types
2003
+ });
2004
+ return INVALID;
2005
+ }
2006
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2007
+ status.dirty();
2008
+ }
2009
+ return { status: status.value, value: merged.data };
2010
+ };
2011
+ if (ctx.common.async) {
2012
+ return Promise.all([
2013
+ this._def.left._parseAsync({
2014
+ data: ctx.data,
2015
+ path: ctx.path,
2016
+ parent: ctx
2017
+ }),
2018
+ this._def.right._parseAsync({
2019
+ data: ctx.data,
2020
+ path: ctx.path,
2021
+ parent: ctx
2022
+ })
2023
+ ]).then(([left, right]) => handleParsed(left, right));
2024
+ } else {
2025
+ return handleParsed(this._def.left._parseSync({
2026
+ data: ctx.data,
2027
+ path: ctx.path,
2028
+ parent: ctx
2029
+ }), this._def.right._parseSync({
2030
+ data: ctx.data,
2031
+ path: ctx.path,
2032
+ parent: ctx
2033
+ }));
2034
+ }
2035
+ }
2036
+ };
2037
+ ZodIntersection.create = (left, right, params2) => {
2038
+ return new ZodIntersection({
2039
+ left,
2040
+ right,
2041
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
2042
+ ...processCreateParams(params2)
2043
+ });
2044
+ };
2045
+ var ZodTuple = class extends ZodType {
2046
+ _parse(input) {
2047
+ const { status, ctx } = this._processInputParams(input);
2048
+ if (ctx.parsedType !== ZodParsedType.array) {
2049
+ addIssueToContext(ctx, {
2050
+ code: ZodIssueCode.invalid_type,
2051
+ expected: ZodParsedType.array,
2052
+ received: ctx.parsedType
2053
+ });
2054
+ return INVALID;
2055
+ }
2056
+ if (ctx.data.length < this._def.items.length) {
2057
+ addIssueToContext(ctx, {
2058
+ code: ZodIssueCode.too_small,
2059
+ minimum: this._def.items.length,
2060
+ inclusive: true,
2061
+ type: "array"
2062
+ });
2063
+ return INVALID;
2064
+ }
2065
+ const rest = this._def.rest;
2066
+ if (!rest && ctx.data.length > this._def.items.length) {
2067
+ addIssueToContext(ctx, {
2068
+ code: ZodIssueCode.too_big,
2069
+ maximum: this._def.items.length,
2070
+ inclusive: true,
2071
+ type: "array"
2072
+ });
2073
+ status.dirty();
2074
+ }
2075
+ const items = ctx.data.map((item, itemIndex) => {
2076
+ const schema = this._def.items[itemIndex] || this._def.rest;
2077
+ if (!schema)
2078
+ return null;
2079
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2080
+ }).filter((x) => !!x);
2081
+ if (ctx.common.async) {
2082
+ return Promise.all(items).then((results) => {
2083
+ return ParseStatus.mergeArray(status, results);
2084
+ });
2085
+ } else {
2086
+ return ParseStatus.mergeArray(status, items);
2087
+ }
2088
+ }
2089
+ get items() {
2090
+ return this._def.items;
2091
+ }
2092
+ rest(rest) {
2093
+ return new ZodTuple({
2094
+ ...this._def,
2095
+ rest
2096
+ });
2097
+ }
2098
+ };
2099
+ ZodTuple.create = (schemas, params2) => {
2100
+ if (!Array.isArray(schemas)) {
2101
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2102
+ }
2103
+ return new ZodTuple({
2104
+ items: schemas,
2105
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2106
+ rest: null,
2107
+ ...processCreateParams(params2)
2108
+ });
2109
+ };
2110
+ var ZodRecord = class extends ZodType {
2111
+ get keySchema() {
2112
+ return this._def.keyType;
2113
+ }
2114
+ get valueSchema() {
2115
+ return this._def.valueType;
2116
+ }
2117
+ _parse(input) {
2118
+ const { status, ctx } = this._processInputParams(input);
2119
+ if (ctx.parsedType !== ZodParsedType.object) {
2120
+ addIssueToContext(ctx, {
2121
+ code: ZodIssueCode.invalid_type,
2122
+ expected: ZodParsedType.object,
2123
+ received: ctx.parsedType
2124
+ });
2125
+ return INVALID;
2126
+ }
2127
+ const pairs = [];
2128
+ const keyType = this._def.keyType;
2129
+ const valueType = this._def.valueType;
2130
+ for (const key in ctx.data) {
2131
+ pairs.push({
2132
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2133
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
2134
+ });
2135
+ }
2136
+ if (ctx.common.async) {
2137
+ return ParseStatus.mergeObjectAsync(status, pairs);
2138
+ } else {
2139
+ return ParseStatus.mergeObjectSync(status, pairs);
2140
+ }
2141
+ }
2142
+ get element() {
2143
+ return this._def.valueType;
2144
+ }
2145
+ static create(first, second, third) {
2146
+ if (second instanceof ZodType) {
2147
+ return new ZodRecord({
2148
+ keyType: first,
2149
+ valueType: second,
2150
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2151
+ ...processCreateParams(third)
2152
+ });
2153
+ }
2154
+ return new ZodRecord({
2155
+ keyType: ZodString.create(),
2156
+ valueType: first,
2157
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2158
+ ...processCreateParams(second)
2159
+ });
2160
+ }
2161
+ };
2162
+ var ZodMap = class extends ZodType {
2163
+ _parse(input) {
2164
+ const { status, ctx } = this._processInputParams(input);
2165
+ if (ctx.parsedType !== ZodParsedType.map) {
2166
+ addIssueToContext(ctx, {
2167
+ code: ZodIssueCode.invalid_type,
2168
+ expected: ZodParsedType.map,
2169
+ received: ctx.parsedType
2170
+ });
2171
+ return INVALID;
2172
+ }
2173
+ const keyType = this._def.keyType;
2174
+ const valueType = this._def.valueType;
2175
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
2176
+ return {
2177
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2178
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
2179
+ };
2180
+ });
2181
+ if (ctx.common.async) {
2182
+ const finalMap = /* @__PURE__ */ new Map();
2183
+ return Promise.resolve().then(async () => {
2184
+ for (const pair of pairs) {
2185
+ const key = await pair.key;
2186
+ const value = await pair.value;
2187
+ if (key.status === "aborted" || value.status === "aborted") {
2188
+ return INVALID;
2189
+ }
2190
+ if (key.status === "dirty" || value.status === "dirty") {
2191
+ status.dirty();
2192
+ }
2193
+ finalMap.set(key.value, value.value);
2194
+ }
2195
+ return { status: status.value, value: finalMap };
2196
+ });
2197
+ } else {
2198
+ const finalMap = /* @__PURE__ */ new Map();
2199
+ for (const pair of pairs) {
2200
+ const key = pair.key;
2201
+ const value = pair.value;
2202
+ if (key.status === "aborted" || value.status === "aborted") {
2203
+ return INVALID;
2204
+ }
2205
+ if (key.status === "dirty" || value.status === "dirty") {
2206
+ status.dirty();
2207
+ }
2208
+ finalMap.set(key.value, value.value);
2209
+ }
2210
+ return { status: status.value, value: finalMap };
2211
+ }
2212
+ }
2213
+ };
2214
+ ZodMap.create = (keyType, valueType, params2) => {
2215
+ return new ZodMap({
2216
+ valueType,
2217
+ keyType,
2218
+ typeName: ZodFirstPartyTypeKind.ZodMap,
2219
+ ...processCreateParams(params2)
2220
+ });
2221
+ };
2222
+ var ZodSet = class extends ZodType {
2223
+ _parse(input) {
2224
+ const { status, ctx } = this._processInputParams(input);
2225
+ if (ctx.parsedType !== ZodParsedType.set) {
2226
+ addIssueToContext(ctx, {
2227
+ code: ZodIssueCode.invalid_type,
2228
+ expected: ZodParsedType.set,
2229
+ received: ctx.parsedType
2230
+ });
2231
+ return INVALID;
2232
+ }
2233
+ const def = this._def;
2234
+ if (def.minSize !== null) {
2235
+ if (ctx.data.size < def.minSize.value) {
2236
+ addIssueToContext(ctx, {
2237
+ code: ZodIssueCode.too_small,
2238
+ minimum: def.minSize.value,
2239
+ type: "set",
2240
+ inclusive: true,
2241
+ message: def.minSize.message
2242
+ });
2243
+ status.dirty();
2244
+ }
2245
+ }
2246
+ if (def.maxSize !== null) {
2247
+ if (ctx.data.size > def.maxSize.value) {
2248
+ addIssueToContext(ctx, {
2249
+ code: ZodIssueCode.too_big,
2250
+ maximum: def.maxSize.value,
2251
+ type: "set",
2252
+ inclusive: true,
2253
+ message: def.maxSize.message
2254
+ });
2255
+ status.dirty();
2256
+ }
2257
+ }
2258
+ const valueType = this._def.valueType;
2259
+ function finalizeSet(elements2) {
2260
+ const parsedSet = /* @__PURE__ */ new Set();
2261
+ for (const element of elements2) {
2262
+ if (element.status === "aborted")
2263
+ return INVALID;
2264
+ if (element.status === "dirty")
2265
+ status.dirty();
2266
+ parsedSet.add(element.value);
2267
+ }
2268
+ return { status: status.value, value: parsedSet };
2269
+ }
2270
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2271
+ if (ctx.common.async) {
2272
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
2273
+ } else {
2274
+ return finalizeSet(elements);
2275
+ }
2276
+ }
2277
+ min(minSize, message) {
2278
+ return new ZodSet({
2279
+ ...this._def,
2280
+ minSize: { value: minSize, message: errorUtil.toString(message) }
2281
+ });
2282
+ }
2283
+ max(maxSize, message) {
2284
+ return new ZodSet({
2285
+ ...this._def,
2286
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
2287
+ });
2288
+ }
2289
+ size(size, message) {
2290
+ return this.min(size, message).max(size, message);
2291
+ }
2292
+ nonempty(message) {
2293
+ return this.min(1, message);
2294
+ }
2295
+ };
2296
+ ZodSet.create = (valueType, params2) => {
2297
+ return new ZodSet({
2298
+ valueType,
2299
+ minSize: null,
2300
+ maxSize: null,
2301
+ typeName: ZodFirstPartyTypeKind.ZodSet,
2302
+ ...processCreateParams(params2)
2303
+ });
2304
+ };
2305
+ var ZodFunction = class extends ZodType {
2306
+ constructor() {
2307
+ super(...arguments);
2308
+ this.validate = this.implement;
2309
+ }
2310
+ _parse(input) {
2311
+ const { ctx } = this._processInputParams(input);
2312
+ if (ctx.parsedType !== ZodParsedType.function) {
2313
+ addIssueToContext(ctx, {
2314
+ code: ZodIssueCode.invalid_type,
2315
+ expected: ZodParsedType.function,
2316
+ received: ctx.parsedType
2317
+ });
2318
+ return INVALID;
2319
+ }
2320
+ function makeArgsIssue(args, error) {
2321
+ return makeIssue({
2322
+ data: args,
2323
+ path: ctx.path,
2324
+ errorMaps: [
2325
+ ctx.common.contextualErrorMap,
2326
+ ctx.schemaErrorMap,
2327
+ getErrorMap(),
2328
+ errorMap
2329
+ ].filter((x) => !!x),
2330
+ issueData: {
2331
+ code: ZodIssueCode.invalid_arguments,
2332
+ argumentsError: error
2333
+ }
2334
+ });
2335
+ }
2336
+ function makeReturnsIssue(returns, error) {
2337
+ return makeIssue({
2338
+ data: returns,
2339
+ path: ctx.path,
2340
+ errorMaps: [
2341
+ ctx.common.contextualErrorMap,
2342
+ ctx.schemaErrorMap,
2343
+ getErrorMap(),
2344
+ errorMap
2345
+ ].filter((x) => !!x),
2346
+ issueData: {
2347
+ code: ZodIssueCode.invalid_return_type,
2348
+ returnTypeError: error
2349
+ }
2350
+ });
2351
+ }
2352
+ const params2 = { errorMap: ctx.common.contextualErrorMap };
2353
+ const fn = ctx.data;
2354
+ if (this._def.returns instanceof ZodPromise) {
2355
+ return OK(async (...args) => {
2356
+ const error = new ZodError([]);
2357
+ const parsedArgs = await this._def.args.parseAsync(args, params2).catch((e) => {
2358
+ error.addIssue(makeArgsIssue(args, e));
2359
+ throw error;
2360
+ });
2361
+ const result = await fn(...parsedArgs);
2362
+ const parsedReturns = await this._def.returns._def.type.parseAsync(result, params2).catch((e) => {
2363
+ error.addIssue(makeReturnsIssue(result, e));
2364
+ throw error;
2365
+ });
2366
+ return parsedReturns;
2367
+ });
2368
+ } else {
2369
+ return OK((...args) => {
2370
+ const parsedArgs = this._def.args.safeParse(args, params2);
2371
+ if (!parsedArgs.success) {
2372
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2373
+ }
2374
+ const result = fn(...parsedArgs.data);
2375
+ const parsedReturns = this._def.returns.safeParse(result, params2);
2376
+ if (!parsedReturns.success) {
2377
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2378
+ }
2379
+ return parsedReturns.data;
2380
+ });
2381
+ }
2382
+ }
2383
+ parameters() {
2384
+ return this._def.args;
2385
+ }
2386
+ returnType() {
2387
+ return this._def.returns;
2388
+ }
2389
+ args(...items) {
2390
+ return new ZodFunction({
2391
+ ...this._def,
2392
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
2393
+ });
2394
+ }
2395
+ returns(returnType) {
2396
+ return new ZodFunction({
2397
+ ...this._def,
2398
+ returns: returnType
2399
+ });
2400
+ }
2401
+ implement(func) {
2402
+ const validatedFunc = this.parse(func);
2403
+ return validatedFunc;
2404
+ }
2405
+ strictImplement(func) {
2406
+ const validatedFunc = this.parse(func);
2407
+ return validatedFunc;
2408
+ }
2409
+ static create(args, returns, params2) {
2410
+ return new ZodFunction({
2411
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
2412
+ returns: returns || ZodUnknown.create(),
2413
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
2414
+ ...processCreateParams(params2)
2415
+ });
2416
+ }
2417
+ };
2418
+ var ZodLazy = class extends ZodType {
2419
+ get schema() {
2420
+ return this._def.getter();
2421
+ }
2422
+ _parse(input) {
2423
+ const { ctx } = this._processInputParams(input);
2424
+ const lazySchema = this._def.getter();
2425
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
2426
+ }
2427
+ };
2428
+ ZodLazy.create = (getter, params2) => {
2429
+ return new ZodLazy({
2430
+ getter,
2431
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
2432
+ ...processCreateParams(params2)
2433
+ });
2434
+ };
2435
+ var ZodLiteral = class extends ZodType {
2436
+ _parse(input) {
2437
+ if (input.data !== this._def.value) {
2438
+ const ctx = this._getOrReturnCtx(input);
2439
+ addIssueToContext(ctx, {
2440
+ code: ZodIssueCode.invalid_literal,
2441
+ expected: this._def.value
2442
+ });
2443
+ return INVALID;
2444
+ }
2445
+ return { status: "valid", value: input.data };
2446
+ }
2447
+ get value() {
2448
+ return this._def.value;
2449
+ }
2450
+ };
2451
+ ZodLiteral.create = (value, params2) => {
2452
+ return new ZodLiteral({
2453
+ value,
2454
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
2455
+ ...processCreateParams(params2)
2456
+ });
2457
+ };
2458
+ function createZodEnum(values, params2) {
2459
+ return new ZodEnum({
2460
+ values,
2461
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
2462
+ ...processCreateParams(params2)
2463
+ });
2464
+ }
2465
+ var ZodEnum = class extends ZodType {
2466
+ _parse(input) {
2467
+ if (typeof input.data !== "string") {
2468
+ const ctx = this._getOrReturnCtx(input);
2469
+ const expectedValues = this._def.values;
2470
+ addIssueToContext(ctx, {
2471
+ expected: util.joinValues(expectedValues),
2472
+ received: ctx.parsedType,
2473
+ code: ZodIssueCode.invalid_type
2474
+ });
2475
+ return INVALID;
2476
+ }
2477
+ if (this._def.values.indexOf(input.data) === -1) {
2478
+ const ctx = this._getOrReturnCtx(input);
2479
+ const expectedValues = this._def.values;
2480
+ addIssueToContext(ctx, {
2481
+ received: ctx.data,
2482
+ code: ZodIssueCode.invalid_enum_value,
2483
+ options: expectedValues
2484
+ });
2485
+ return INVALID;
2486
+ }
2487
+ return OK(input.data);
2488
+ }
2489
+ get options() {
2490
+ return this._def.values;
2491
+ }
2492
+ get enum() {
2493
+ const enumValues = {};
2494
+ for (const val of this._def.values) {
2495
+ enumValues[val] = val;
2496
+ }
2497
+ return enumValues;
2498
+ }
2499
+ get Values() {
2500
+ const enumValues = {};
2501
+ for (const val of this._def.values) {
2502
+ enumValues[val] = val;
2503
+ }
2504
+ return enumValues;
2505
+ }
2506
+ get Enum() {
2507
+ const enumValues = {};
2508
+ for (const val of this._def.values) {
2509
+ enumValues[val] = val;
2510
+ }
2511
+ return enumValues;
2512
+ }
2513
+ };
2514
+ ZodEnum.create = createZodEnum;
2515
+ var ZodNativeEnum = class extends ZodType {
2516
+ _parse(input) {
2517
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
2518
+ const ctx = this._getOrReturnCtx(input);
2519
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
2520
+ const expectedValues = util.objectValues(nativeEnumValues);
2521
+ addIssueToContext(ctx, {
2522
+ expected: util.joinValues(expectedValues),
2523
+ received: ctx.parsedType,
2524
+ code: ZodIssueCode.invalid_type
2525
+ });
2526
+ return INVALID;
2527
+ }
2528
+ if (nativeEnumValues.indexOf(input.data) === -1) {
2529
+ const expectedValues = util.objectValues(nativeEnumValues);
2530
+ addIssueToContext(ctx, {
2531
+ received: ctx.data,
2532
+ code: ZodIssueCode.invalid_enum_value,
2533
+ options: expectedValues
2534
+ });
2535
+ return INVALID;
2536
+ }
2537
+ return OK(input.data);
2538
+ }
2539
+ get enum() {
2540
+ return this._def.values;
2541
+ }
2542
+ };
2543
+ ZodNativeEnum.create = (values, params2) => {
2544
+ return new ZodNativeEnum({
2545
+ values,
2546
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
2547
+ ...processCreateParams(params2)
2548
+ });
2549
+ };
2550
+ var ZodPromise = class extends ZodType {
2551
+ _parse(input) {
2552
+ const { ctx } = this._processInputParams(input);
2553
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
2554
+ addIssueToContext(ctx, {
2555
+ code: ZodIssueCode.invalid_type,
2556
+ expected: ZodParsedType.promise,
2557
+ received: ctx.parsedType
2558
+ });
2559
+ return INVALID;
2560
+ }
2561
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
2562
+ return OK(promisified.then((data) => {
2563
+ return this._def.type.parseAsync(data, {
2564
+ path: ctx.path,
2565
+ errorMap: ctx.common.contextualErrorMap
2566
+ });
2567
+ }));
2568
+ }
2569
+ };
2570
+ ZodPromise.create = (schema, params2) => {
2571
+ return new ZodPromise({
2572
+ type: schema,
2573
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
2574
+ ...processCreateParams(params2)
2575
+ });
2576
+ };
2577
+ var ZodEffects = class extends ZodType {
2578
+ innerType() {
2579
+ return this._def.schema;
2580
+ }
2581
+ _parse(input) {
2582
+ const { status, ctx } = this._processInputParams(input);
2583
+ const effect = this._def.effect || null;
2584
+ if (effect.type === "preprocess") {
2585
+ const processed = effect.transform(ctx.data);
2586
+ if (ctx.common.async) {
2587
+ return Promise.resolve(processed).then((processed2) => {
2588
+ return this._def.schema._parseAsync({
2589
+ data: processed2,
2590
+ path: ctx.path,
2591
+ parent: ctx
2592
+ });
2593
+ });
2594
+ } else {
2595
+ return this._def.schema._parseSync({
2596
+ data: processed,
2597
+ path: ctx.path,
2598
+ parent: ctx
2599
+ });
2600
+ }
2601
+ }
2602
+ const checkCtx = {
2603
+ addIssue: (arg) => {
2604
+ addIssueToContext(ctx, arg);
2605
+ if (arg.fatal) {
2606
+ status.abort();
2607
+ } else {
2608
+ status.dirty();
2609
+ }
2610
+ },
2611
+ get path() {
2612
+ return ctx.path;
2613
+ }
2614
+ };
2615
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
2616
+ if (effect.type === "refinement") {
2617
+ const executeRefinement = (acc) => {
2618
+ const result = effect.refinement(acc, checkCtx);
2619
+ if (ctx.common.async) {
2620
+ return Promise.resolve(result);
2621
+ }
2622
+ if (result instanceof Promise) {
2623
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2624
+ }
2625
+ return acc;
2626
+ };
2627
+ if (ctx.common.async === false) {
2628
+ const inner = this._def.schema._parseSync({
2629
+ data: ctx.data,
2630
+ path: ctx.path,
2631
+ parent: ctx
2632
+ });
2633
+ if (inner.status === "aborted")
2634
+ return INVALID;
2635
+ if (inner.status === "dirty")
2636
+ status.dirty();
2637
+ executeRefinement(inner.value);
2638
+ return { status: status.value, value: inner.value };
2639
+ } else {
2640
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
2641
+ if (inner.status === "aborted")
2642
+ return INVALID;
2643
+ if (inner.status === "dirty")
2644
+ status.dirty();
2645
+ return executeRefinement(inner.value).then(() => {
2646
+ return { status: status.value, value: inner.value };
2647
+ });
2648
+ });
2649
+ }
2650
+ }
2651
+ if (effect.type === "transform") {
2652
+ if (ctx.common.async === false) {
2653
+ const base = this._def.schema._parseSync({
2654
+ data: ctx.data,
2655
+ path: ctx.path,
2656
+ parent: ctx
2657
+ });
2658
+ if (!isValid(base))
2659
+ return base;
2660
+ const result = effect.transform(base.value, checkCtx);
2661
+ if (result instanceof Promise) {
2662
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
2663
+ }
2664
+ return { status: status.value, value: result };
2665
+ } else {
2666
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
2667
+ if (!isValid(base))
2668
+ return base;
2669
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
2670
+ });
2671
+ }
2672
+ }
2673
+ util.assertNever(effect);
2674
+ }
2675
+ };
2676
+ ZodEffects.create = (schema, effect, params2) => {
2677
+ return new ZodEffects({
2678
+ schema,
2679
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2680
+ effect,
2681
+ ...processCreateParams(params2)
2682
+ });
2683
+ };
2684
+ ZodEffects.createWithPreprocess = (preprocess, schema, params2) => {
2685
+ return new ZodEffects({
2686
+ schema,
2687
+ effect: { type: "preprocess", transform: preprocess },
2688
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2689
+ ...processCreateParams(params2)
2690
+ });
2691
+ };
2692
+ var ZodOptional = class extends ZodType {
2693
+ _parse(input) {
2694
+ const parsedType = this._getType(input);
2695
+ if (parsedType === ZodParsedType.undefined) {
2696
+ return OK(void 0);
2697
+ }
2698
+ return this._def.innerType._parse(input);
2699
+ }
2700
+ unwrap() {
2701
+ return this._def.innerType;
2702
+ }
2703
+ };
2704
+ ZodOptional.create = (type, params2) => {
2705
+ return new ZodOptional({
2706
+ innerType: type,
2707
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
2708
+ ...processCreateParams(params2)
2709
+ });
2710
+ };
2711
+ var ZodNullable = class extends ZodType {
2712
+ _parse(input) {
2713
+ const parsedType = this._getType(input);
2714
+ if (parsedType === ZodParsedType.null) {
2715
+ return OK(null);
2716
+ }
2717
+ return this._def.innerType._parse(input);
2718
+ }
2719
+ unwrap() {
2720
+ return this._def.innerType;
2721
+ }
2722
+ };
2723
+ ZodNullable.create = (type, params2) => {
2724
+ return new ZodNullable({
2725
+ innerType: type,
2726
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
2727
+ ...processCreateParams(params2)
2728
+ });
2729
+ };
2730
+ var ZodDefault = class extends ZodType {
2731
+ _parse(input) {
2732
+ const { ctx } = this._processInputParams(input);
2733
+ let data = ctx.data;
2734
+ if (ctx.parsedType === ZodParsedType.undefined) {
2735
+ data = this._def.defaultValue();
2736
+ }
2737
+ return this._def.innerType._parse({
2738
+ data,
2739
+ path: ctx.path,
2740
+ parent: ctx
2741
+ });
2742
+ }
2743
+ removeDefault() {
2744
+ return this._def.innerType;
2745
+ }
2746
+ };
2747
+ ZodDefault.create = (type, params2) => {
2748
+ return new ZodOptional({
2749
+ innerType: type,
2750
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
2751
+ ...processCreateParams(params2)
2752
+ });
2753
+ };
2754
+ var ZodNaN = class extends ZodType {
2755
+ _parse(input) {
2756
+ const parsedType = this._getType(input);
2757
+ if (parsedType !== ZodParsedType.nan) {
2758
+ const ctx = this._getOrReturnCtx(input);
2759
+ addIssueToContext(ctx, {
2760
+ code: ZodIssueCode.invalid_type,
2761
+ expected: ZodParsedType.nan,
2762
+ received: ctx.parsedType
2763
+ });
2764
+ return INVALID;
2765
+ }
2766
+ return { status: "valid", value: input.data };
2767
+ }
2768
+ };
2769
+ ZodNaN.create = (params2) => {
2770
+ return new ZodNaN({
2771
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
2772
+ ...processCreateParams(params2)
2773
+ });
2774
+ };
2775
+ var BRAND = Symbol("zod_brand");
2776
+ var ZodBranded = class extends ZodType {
2777
+ _parse(input) {
2778
+ const { ctx } = this._processInputParams(input);
2779
+ const data = ctx.data;
2780
+ return this._def.type._parse({
2781
+ data,
2782
+ path: ctx.path,
2783
+ parent: ctx
2784
+ });
2785
+ }
2786
+ unwrap() {
2787
+ return this._def.type;
2788
+ }
2789
+ };
2790
+ var custom = (check, params2 = {}, fatal) => {
2791
+ if (check)
2792
+ return ZodAny.create().superRefine((data, ctx) => {
2793
+ if (!check(data)) {
2794
+ const p = typeof params2 === "function" ? params2(data) : params2;
2795
+ const p2 = typeof p === "string" ? { message: p } : p;
2796
+ ctx.addIssue({ code: "custom", ...p2, fatal });
2797
+ }
2798
+ });
2799
+ return ZodAny.create();
2800
+ };
2801
+ var late = {
2802
+ object: ZodObject.lazycreate
2803
+ };
2804
+ var ZodFirstPartyTypeKind;
2805
+ (function(ZodFirstPartyTypeKind2) {
2806
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
2807
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
2808
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
2809
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
2810
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
2811
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
2812
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
2813
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
2814
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
2815
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
2816
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
2817
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
2818
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
2819
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
2820
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
2821
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
2822
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
2823
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
2824
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
2825
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
2826
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
2827
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
2828
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
2829
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
2830
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
2831
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
2832
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
2833
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
2834
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
2835
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
2836
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
2837
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
2838
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2839
+ var instanceOfType = (cls, params2 = {
2840
+ message: `Input not instance of ${cls.name}`
2841
+ }) => custom((data) => data instanceof cls, params2, true);
2842
+ var stringType = ZodString.create;
2843
+ var numberType = ZodNumber.create;
2844
+ var nanType = ZodNaN.create;
2845
+ var bigIntType = ZodBigInt.create;
2846
+ var booleanType = ZodBoolean.create;
2847
+ var dateType = ZodDate.create;
2848
+ var undefinedType = ZodUndefined.create;
2849
+ var nullType = ZodNull.create;
2850
+ var anyType = ZodAny.create;
2851
+ var unknownType = ZodUnknown.create;
2852
+ var neverType = ZodNever.create;
2853
+ var voidType = ZodVoid.create;
2854
+ var arrayType = ZodArray.create;
2855
+ var objectType = ZodObject.create;
2856
+ var strictObjectType = ZodObject.strictCreate;
2857
+ var unionType = ZodUnion.create;
2858
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
2859
+ var intersectionType = ZodIntersection.create;
2860
+ var tupleType = ZodTuple.create;
2861
+ var recordType = ZodRecord.create;
2862
+ var mapType = ZodMap.create;
2863
+ var setType = ZodSet.create;
2864
+ var functionType = ZodFunction.create;
2865
+ var lazyType = ZodLazy.create;
2866
+ var literalType = ZodLiteral.create;
2867
+ var enumType = ZodEnum.create;
2868
+ var nativeEnumType = ZodNativeEnum.create;
2869
+ var promiseType = ZodPromise.create;
2870
+ var effectsType = ZodEffects.create;
2871
+ var optionalType = ZodOptional.create;
2872
+ var nullableType = ZodNullable.create;
2873
+ var preprocessType = ZodEffects.createWithPreprocess;
2874
+ var ostring = () => stringType().optional();
2875
+ var onumber = () => numberType().optional();
2876
+ var oboolean = () => booleanType().optional();
2877
+ var NEVER = INVALID;
2878
+ var mod = /* @__PURE__ */ Object.freeze({
2879
+ __proto__: null,
2880
+ getParsedType,
2881
+ ZodParsedType,
2882
+ defaultErrorMap: errorMap,
2883
+ setErrorMap,
2884
+ getErrorMap,
2885
+ makeIssue,
2886
+ EMPTY_PATH,
2887
+ addIssueToContext,
2888
+ ParseStatus,
2889
+ INVALID,
2890
+ DIRTY,
2891
+ OK,
2892
+ isAborted,
2893
+ isDirty,
2894
+ isValid,
2895
+ isAsync,
2896
+ ZodType,
2897
+ ZodString,
2898
+ ZodNumber,
2899
+ ZodBigInt,
2900
+ ZodBoolean,
2901
+ ZodDate,
2902
+ ZodUndefined,
2903
+ ZodNull,
2904
+ ZodAny,
2905
+ ZodUnknown,
2906
+ ZodNever,
2907
+ ZodVoid,
2908
+ ZodArray,
2909
+ get objectUtil() {
2910
+ return objectUtil;
2911
+ },
2912
+ ZodObject,
2913
+ ZodUnion,
2914
+ ZodDiscriminatedUnion,
2915
+ ZodIntersection,
2916
+ ZodTuple,
2917
+ ZodRecord,
2918
+ ZodMap,
2919
+ ZodSet,
2920
+ ZodFunction,
2921
+ ZodLazy,
2922
+ ZodLiteral,
2923
+ ZodEnum,
2924
+ ZodNativeEnum,
2925
+ ZodPromise,
2926
+ ZodEffects,
2927
+ ZodTransformer: ZodEffects,
2928
+ ZodOptional,
2929
+ ZodNullable,
2930
+ ZodDefault,
2931
+ ZodNaN,
2932
+ BRAND,
2933
+ ZodBranded,
2934
+ custom,
2935
+ Schema: ZodType,
2936
+ ZodSchema: ZodType,
2937
+ late,
2938
+ get ZodFirstPartyTypeKind() {
2939
+ return ZodFirstPartyTypeKind;
2940
+ },
2941
+ any: anyType,
2942
+ array: arrayType,
2943
+ bigint: bigIntType,
2944
+ boolean: booleanType,
2945
+ date: dateType,
2946
+ discriminatedUnion: discriminatedUnionType,
2947
+ effect: effectsType,
2948
+ "enum": enumType,
2949
+ "function": functionType,
2950
+ "instanceof": instanceOfType,
2951
+ intersection: intersectionType,
2952
+ lazy: lazyType,
2953
+ literal: literalType,
2954
+ map: mapType,
2955
+ nan: nanType,
2956
+ nativeEnum: nativeEnumType,
2957
+ never: neverType,
2958
+ "null": nullType,
2959
+ nullable: nullableType,
2960
+ number: numberType,
2961
+ object: objectType,
2962
+ oboolean,
2963
+ onumber,
2964
+ optional: optionalType,
2965
+ ostring,
2966
+ preprocess: preprocessType,
2967
+ promise: promiseType,
2968
+ record: recordType,
2969
+ set: setType,
2970
+ strictObject: strictObjectType,
2971
+ string: stringType,
2972
+ transformer: effectsType,
2973
+ tuple: tupleType,
2974
+ "undefined": undefinedType,
2975
+ union: unionType,
2976
+ unknown: unknownType,
2977
+ "void": voidType,
2978
+ NEVER,
2979
+ ZodIssueCode,
2980
+ quotelessJson,
2981
+ ZodError
2982
+ });
2983
+
2984
+ // ../nsid/src/index.ts
2985
+ var SEGMENT_RE = /^[a-zA-Z]([a-zA-Z0-9-])*$/;
2986
+ var NSID = class {
2987
+ constructor(nsid) {
2988
+ this.segments = [];
2989
+ const segments = nsid.split(".");
2990
+ if (segments.length <= 2) {
2991
+ throw new Error(`Invalid NSID: ${nsid}`);
2992
+ }
2993
+ for (let i = 0; i < segments.length; i++) {
2994
+ const segment = segments[i];
2995
+ if (SEGMENT_RE.test(segment)) {
2996
+ continue;
2997
+ }
2998
+ if (i === segments.length - 1 && segment === "*") {
2999
+ continue;
3000
+ }
3001
+ throw new Error(`Invalid NSID: invalid character in segment "${segment}"`);
3002
+ }
3003
+ this.segments = segments;
3004
+ }
3005
+ static parse(nsid) {
3006
+ return new NSID(nsid);
3007
+ }
3008
+ static create(authority, name) {
3009
+ const segments = [...authority.split(".").reverse(), name].join(".");
3010
+ return new NSID(segments);
3011
+ }
3012
+ static isValid(nsid) {
3013
+ try {
3014
+ NSID.parse(nsid);
3015
+ return true;
3016
+ } catch (e) {
3017
+ return false;
3018
+ }
3019
+ }
3020
+ get authority() {
3021
+ return this.segments.slice(0, this.segments.length - 1).reverse().join(".");
3022
+ }
3023
+ get name() {
3024
+ return this.segments.at(this.segments.length - 1);
3025
+ }
3026
+ toString() {
3027
+ return this.segments.join(".");
3028
+ }
3029
+ };
3030
+
3031
+ // src/types.ts
3032
+ var lexBoolean = mod.object({
3033
+ type: mod.literal("boolean"),
3034
+ description: mod.string().optional(),
3035
+ default: mod.boolean().optional(),
3036
+ const: mod.boolean().optional()
3037
+ });
3038
+ var lexNumber = mod.object({
3039
+ type: mod.literal("number"),
3040
+ description: mod.string().optional(),
3041
+ default: mod.number().optional(),
3042
+ minimum: mod.number().optional(),
3043
+ maximum: mod.number().optional(),
3044
+ enum: mod.number().array().optional(),
3045
+ const: mod.number().optional()
3046
+ });
3047
+ var lexInteger = mod.object({
3048
+ type: mod.literal("integer"),
3049
+ description: mod.string().optional(),
3050
+ default: mod.number().int().optional(),
3051
+ minimum: mod.number().int().optional(),
3052
+ maximum: mod.number().int().optional(),
3053
+ enum: mod.number().int().array().optional(),
3054
+ const: mod.number().int().optional()
3055
+ });
3056
+ var lexString = mod.object({
3057
+ type: mod.literal("string"),
3058
+ description: mod.string().optional(),
3059
+ default: mod.string().optional(),
3060
+ minLength: mod.number().int().optional(),
3061
+ maxLength: mod.number().int().optional(),
3062
+ enum: mod.string().array().optional(),
3063
+ const: mod.string().optional(),
3064
+ knownValues: mod.string().array().optional()
3065
+ });
3066
+ var lexDatetime = mod.object({
3067
+ type: mod.literal("datetime"),
3068
+ description: mod.string().optional()
3069
+ });
3070
+ var lexUnknown = mod.object({
3071
+ type: mod.literal("unknown"),
3072
+ description: mod.string().optional()
3073
+ });
3074
+ var lexPrimitive = mod.union([
3075
+ lexBoolean,
3076
+ lexNumber,
3077
+ lexInteger,
3078
+ lexString,
3079
+ lexDatetime,
3080
+ lexUnknown
3081
+ ]);
3082
+ var lexRef = mod.object({
3083
+ type: mod.literal("ref"),
3084
+ description: mod.string().optional(),
3085
+ ref: mod.string()
3086
+ });
3087
+ var lexRefUnion = mod.object({
3088
+ type: mod.literal("union"),
3089
+ description: mod.string().optional(),
3090
+ refs: mod.string().array(),
3091
+ closed: mod.boolean().optional()
3092
+ });
3093
+ var lexRefVariant = mod.union([lexRef, lexRefUnion]);
3094
+ var lexBlob = mod.object({
3095
+ type: mod.literal("blob"),
3096
+ description: mod.string().optional(),
3097
+ accept: mod.string().array().optional(),
3098
+ maxSize: mod.number().optional()
3099
+ });
3100
+ var lexImage = mod.object({
3101
+ type: mod.literal("image"),
3102
+ description: mod.string().optional(),
3103
+ accept: mod.string().array().optional(),
3104
+ maxSize: mod.number().optional(),
3105
+ maxWidth: mod.number().int().optional(),
3106
+ maxHeight: mod.number().int().optional()
3107
+ });
3108
+ var lexVideo = mod.object({
3109
+ type: mod.literal("video"),
3110
+ description: mod.string().optional(),
3111
+ accept: mod.string().array().optional(),
3112
+ maxSize: mod.number().optional(),
3113
+ maxWidth: mod.number().int().optional(),
3114
+ maxHeight: mod.number().int().optional(),
3115
+ maxLength: mod.number().int().optional()
3116
+ });
3117
+ var lexAudio = mod.object({
3118
+ type: mod.literal("audio"),
3119
+ description: mod.string().optional(),
3120
+ accept: mod.string().array().optional(),
3121
+ maxSize: mod.number().optional(),
3122
+ maxLength: mod.number().int().optional()
3123
+ });
3124
+ var lexBlobVariant = mod.union([lexBlob, lexImage, lexVideo, lexAudio]);
3125
+ var lexArray = mod.object({
3126
+ type: mod.literal("array"),
3127
+ description: mod.string().optional(),
3128
+ items: mod.union([lexPrimitive, lexBlobVariant, lexRefVariant]),
3129
+ minLength: mod.number().int().optional(),
3130
+ maxLength: mod.number().int().optional()
3131
+ });
3132
+ var lexToken = mod.object({
3133
+ type: mod.literal("token"),
3134
+ description: mod.string().optional()
3135
+ });
3136
+ var lexObject = mod.object({
3137
+ type: mod.literal("object"),
3138
+ description: mod.string().optional(),
3139
+ required: mod.string().array().optional(),
3140
+ properties: mod.record(mod.union([lexRefVariant, lexArray, lexBlobVariant, lexPrimitive])).optional()
3141
+ });
3142
+ var lexXrpcParameters = mod.object({
3143
+ type: mod.literal("params"),
3144
+ description: mod.string().optional(),
3145
+ required: mod.string().array().optional(),
3146
+ properties: mod.record(lexPrimitive)
3147
+ });
3148
+ var lexXrpcBody = mod.object({
3149
+ description: mod.string().optional(),
3150
+ encoding: mod.string(),
3151
+ schema: mod.union([lexRefVariant, lexObject]).optional()
3152
+ });
3153
+ var lexXrpcError = mod.object({
3154
+ name: mod.string(),
3155
+ description: mod.string().optional()
3156
+ });
3157
+ var lexXrpcQuery = mod.object({
3158
+ type: mod.literal("query"),
3159
+ description: mod.string().optional(),
3160
+ parameters: lexXrpcParameters.optional(),
3161
+ output: lexXrpcBody.optional(),
3162
+ errors: lexXrpcError.array().optional()
3163
+ });
3164
+ var lexXrpcProcedure = mod.object({
3165
+ type: mod.literal("procedure"),
3166
+ description: mod.string().optional(),
3167
+ parameters: lexXrpcParameters.optional(),
3168
+ input: lexXrpcBody.optional(),
3169
+ output: lexXrpcBody.optional(),
3170
+ errors: lexXrpcError.array().optional()
3171
+ });
3172
+ var lexRecord = mod.object({
3173
+ type: mod.literal("record"),
3174
+ description: mod.string().optional(),
3175
+ key: mod.string().optional(),
3176
+ record: lexObject
3177
+ });
3178
+ var lexUserType = mod.union([
3179
+ lexRecord,
3180
+ lexXrpcQuery,
3181
+ lexXrpcProcedure,
3182
+ lexBlob,
3183
+ lexImage,
3184
+ lexVideo,
3185
+ lexAudio,
3186
+ lexArray,
3187
+ lexToken,
3188
+ lexObject,
3189
+ lexBoolean,
3190
+ lexNumber,
3191
+ lexInteger,
3192
+ lexString,
3193
+ lexDatetime,
3194
+ lexUnknown
3195
+ ]);
3196
+ var lexiconDoc = mod.object({
3197
+ lexicon: mod.literal(1),
3198
+ id: mod.string().refine((v) => NSID.isValid(v), {
3199
+ message: "Must be a valid NSID"
3200
+ }),
3201
+ revision: mod.number().optional(),
3202
+ description: mod.string().optional(),
3203
+ defs: mod.record(lexUserType)
3204
+ }).superRefine((doc, ctx) => {
3205
+ for (const defId in doc.defs) {
3206
+ const def = doc.defs[defId];
3207
+ if (defId !== "main" && (def.type === "record" || def.type === "procedure" || def.type === "query")) {
3208
+ ctx.addIssue({
3209
+ code: mod.ZodIssueCode.custom,
3210
+ message: `Records, procedures, and queries must be the main definition.`
3211
+ });
3212
+ }
3213
+ }
3214
+ });
3215
+ function isValidLexiconDoc(v) {
3216
+ return lexiconDoc.safeParse(v).success;
3217
+ }
3218
+ function isObj(obj) {
3219
+ return !!obj && typeof obj === "object";
3220
+ }
3221
+ function hasProp(data, prop) {
3222
+ return prop in data;
3223
+ }
3224
+ var discriminatedObject = mod.object({ $type: mod.string() });
3225
+ function isDiscriminatedObject(value) {
3226
+ return discriminatedObject.safeParse(value).success;
3227
+ }
3228
+ var LexiconDocMalformedError = class extends Error {
3229
+ constructor(message, schemaDef, issues) {
3230
+ super(message);
3231
+ this.schemaDef = schemaDef;
3232
+ this.issues = issues;
3233
+ this.schemaDef = schemaDef;
3234
+ this.issues = issues;
3235
+ }
3236
+ };
3237
+ var ValidationError = class extends Error {
3238
+ };
3239
+ var InvalidLexiconError = class extends Error {
3240
+ };
3241
+ var LexiconDefNotFoundError = class extends Error {
3242
+ };
3243
+
3244
+ // src/validators/primitives.ts
3245
+ function validate(lexicons, path, def, value) {
3246
+ switch (def.type) {
3247
+ case "boolean":
3248
+ return boolean(lexicons, path, def, value);
3249
+ case "number":
3250
+ return number(lexicons, path, def, value);
3251
+ case "integer":
3252
+ return integer(lexicons, path, def, value);
3253
+ case "string":
3254
+ return string(lexicons, path, def, value);
3255
+ case "datetime":
3256
+ return datetime(lexicons, path, def, value);
3257
+ case "unknown":
3258
+ return unknown(lexicons, path, def, value);
3259
+ default:
3260
+ return {
3261
+ success: false,
3262
+ error: new ValidationError(`Unexpected lexicon type: ${def.type}`)
3263
+ };
3264
+ }
3265
+ }
3266
+ function boolean(lexicons, path, def, value) {
3267
+ def = def;
3268
+ const type = typeof value;
3269
+ if (type == "undefined") {
3270
+ if (typeof def.default === "boolean") {
3271
+ return { success: true };
3272
+ }
3273
+ return {
3274
+ success: false,
3275
+ error: new ValidationError(`${path} must be a boolean`)
3276
+ };
3277
+ } else if (type !== "boolean") {
3278
+ return {
3279
+ success: false,
3280
+ error: new ValidationError(`${path} must be a boolean`)
3281
+ };
3282
+ }
3283
+ if (typeof def.const === "boolean") {
3284
+ if (value !== def.const) {
3285
+ return {
3286
+ success: false,
3287
+ error: new ValidationError(`${path} must be ${def.const}`)
3288
+ };
3289
+ }
3290
+ }
3291
+ return { success: true };
3292
+ }
3293
+ function number(lexicons, path, def, value) {
3294
+ def = def;
3295
+ const type = typeof value;
3296
+ if (type == "undefined") {
3297
+ if (typeof def.default === "number") {
3298
+ return { success: true };
3299
+ }
3300
+ return {
3301
+ success: false,
3302
+ error: new ValidationError(`${path} must be a number`)
3303
+ };
3304
+ } else if (type !== "number") {
3305
+ return {
3306
+ success: false,
3307
+ error: new ValidationError(`${path} must be a number`)
3308
+ };
3309
+ }
3310
+ if (typeof def.const === "number") {
3311
+ if (value !== def.const) {
3312
+ return {
3313
+ success: false,
3314
+ error: new ValidationError(`${path} must be ${def.const}`)
3315
+ };
3316
+ }
3317
+ }
3318
+ if (Array.isArray(def.enum)) {
3319
+ if (!def.enum.includes(value)) {
3320
+ return {
3321
+ success: false,
3322
+ error: new ValidationError(
3323
+ `${path} must be one of (${def.enum.join("|")})`
3324
+ )
3325
+ };
3326
+ }
3327
+ }
3328
+ if (typeof def.maximum === "number") {
3329
+ if (value > def.maximum) {
3330
+ return {
3331
+ success: false,
3332
+ error: new ValidationError(
3333
+ `${path} can not be greater than ${def.maximum}`
3334
+ )
3335
+ };
3336
+ }
3337
+ }
3338
+ if (typeof def.minimum === "number") {
3339
+ if (value < def.minimum) {
3340
+ return {
3341
+ success: false,
3342
+ error: new ValidationError(
3343
+ `${path} can not be less than ${def.minimum}`
3344
+ )
3345
+ };
3346
+ }
3347
+ }
3348
+ return { success: true };
3349
+ }
3350
+ function integer(lexicons, path, def, value) {
3351
+ def = def;
3352
+ const numRes = number(lexicons, path, def, value);
3353
+ if (!numRes.success) {
3354
+ return numRes;
3355
+ }
3356
+ if (!Number.isInteger(value)) {
3357
+ return {
3358
+ success: false,
3359
+ error: new ValidationError(`${path} must be an integer`)
3360
+ };
3361
+ }
3362
+ return { success: true };
3363
+ }
3364
+ function string(lexicons, path, def, value) {
3365
+ def = def;
3366
+ const type = typeof value;
3367
+ if (type == "undefined") {
3368
+ if (typeof def.default === "string") {
3369
+ return { success: true };
3370
+ }
3371
+ return {
3372
+ success: false,
3373
+ error: new ValidationError(`${path} must be a string`)
3374
+ };
3375
+ } else if (type !== "string") {
3376
+ return {
3377
+ success: false,
3378
+ error: new ValidationError(`${path} must be a string`)
3379
+ };
3380
+ }
3381
+ if (typeof def.const === "string") {
3382
+ if (value !== def.const) {
3383
+ return {
3384
+ success: false,
3385
+ error: new ValidationError(`${path} must be ${def.const}`)
3386
+ };
3387
+ }
3388
+ }
3389
+ if (Array.isArray(def.enum)) {
3390
+ if (!def.enum.includes(value)) {
3391
+ return {
3392
+ success: false,
3393
+ error: new ValidationError(
3394
+ `${path} must be one of (${def.enum.join("|")})`
3395
+ )
3396
+ };
3397
+ }
3398
+ }
3399
+ if (typeof def.maxLength === "number") {
3400
+ if (value.length > def.maxLength) {
3401
+ return {
3402
+ success: false,
3403
+ error: new ValidationError(
3404
+ `${path} must not be longer than ${def.maxLength} characters`
3405
+ )
3406
+ };
3407
+ }
3408
+ }
3409
+ if (typeof def.minLength === "number") {
3410
+ if (value.length < def.minLength) {
3411
+ return {
3412
+ success: false,
3413
+ error: new ValidationError(
3414
+ `${path} must not be shorter than ${def.minLength} characters`
3415
+ )
3416
+ };
3417
+ }
3418
+ }
3419
+ return { success: true };
3420
+ }
3421
+ function datetime(lexicons, path, def, value) {
3422
+ def = def;
3423
+ const type = typeof value;
3424
+ if (type !== "string") {
3425
+ return {
3426
+ success: false,
3427
+ error: new ValidationError(`${path} must be a string`)
3428
+ };
3429
+ }
3430
+ {
3431
+ try {
3432
+ const date = new Date(Date.parse(value));
3433
+ if (value !== date.toISOString()) {
3434
+ throw new ValidationError(
3435
+ `${path} must be an iso8601 formatted datetime`
3436
+ );
3437
+ }
3438
+ } catch {
3439
+ throw new ValidationError(`${path} must be an iso8601 formatted datetime`);
3440
+ }
3441
+ }
3442
+ return { success: true };
3443
+ }
3444
+ function unknown(lexicons, path, def, value) {
3445
+ if (!value || typeof value !== "object") {
3446
+ return {
3447
+ success: false,
3448
+ error: new ValidationError(`${path} must be an object`)
3449
+ };
3450
+ }
3451
+ return { success: true };
3452
+ }
3453
+
3454
+ // src/validators/blob.ts
3455
+ function blob(lexicons, path, def, value) {
3456
+ if (!isObj(value)) {
3457
+ return {
3458
+ success: false,
3459
+ error: new ValidationError(`${path} should be an object`)
3460
+ };
3461
+ }
3462
+ if (!hasProp(value, "cid") || typeof value.cid !== "string") {
3463
+ return {
3464
+ success: false,
3465
+ error: new ValidationError(`${path}/cid should be a string`)
3466
+ };
3467
+ }
3468
+ if (!hasProp(value, "mimeType") || typeof value.mimeType !== "string") {
3469
+ return {
3470
+ success: false,
3471
+ error: new ValidationError(`${path}/mimeType should be a string`)
3472
+ };
3473
+ }
3474
+ return { success: true };
3475
+ }
3476
+ function image(lexicons, path, def, value) {
3477
+ return blob(lexicons, path, def, value);
3478
+ }
3479
+ function video(lexicons, path, def, value) {
3480
+ return blob(lexicons, path, def, value);
3481
+ }
3482
+ function audio(lexicons, path, def, value) {
3483
+ return blob(lexicons, path, def, value);
3484
+ }
3485
+
3486
+ // src/validators/complex.ts
3487
+ function validate2(lexicons, path, def, value) {
3488
+ switch (def.type) {
3489
+ case "boolean":
3490
+ return boolean(lexicons, path, def, value);
3491
+ case "number":
3492
+ return number(lexicons, path, def, value);
3493
+ case "integer":
3494
+ return integer(lexicons, path, def, value);
3495
+ case "string":
3496
+ return string(lexicons, path, def, value);
3497
+ case "datetime":
3498
+ return datetime(lexicons, path, def, value);
3499
+ case "unknown":
3500
+ return unknown(lexicons, path, def, value);
3501
+ case "object":
3502
+ return object(lexicons, path, def, value);
3503
+ case "array":
3504
+ return array(lexicons, path, def, value);
3505
+ case "blob":
3506
+ return blob(lexicons, path, def, value);
3507
+ case "image":
3508
+ return image(lexicons, path, def, value);
3509
+ case "video":
3510
+ return video(lexicons, path, def, value);
3511
+ case "audio":
3512
+ return audio(lexicons, path, def, value);
3513
+ default:
3514
+ return {
3515
+ success: false,
3516
+ error: new ValidationError(`Unexpected lexicon type: ${def.type}`)
3517
+ };
3518
+ }
3519
+ }
3520
+ function array(lexicons, path, def, value) {
3521
+ def = def;
3522
+ if (!Array.isArray(value)) {
3523
+ return {
3524
+ success: false,
3525
+ error: new ValidationError(`${path} must be an array`)
3526
+ };
3527
+ }
3528
+ if (typeof def.maxLength === "number") {
3529
+ if (value.length > def.maxLength) {
3530
+ return {
3531
+ success: false,
3532
+ error: new ValidationError(
3533
+ `${path} must not have more than ${def.maxLength} elements`
3534
+ )
3535
+ };
3536
+ }
3537
+ }
3538
+ if (typeof def.minLength === "number") {
3539
+ if (value.length < def.minLength) {
3540
+ return {
3541
+ success: false,
3542
+ error: new ValidationError(
3543
+ `${path} must not have fewer than ${def.minLength} elements`
3544
+ )
3545
+ };
3546
+ }
3547
+ }
3548
+ const itemsDef = def.items;
3549
+ for (let i = 0; i < value.length; i++) {
3550
+ const itemValue = value[i];
3551
+ const itemPath = `${path}/${i}`;
3552
+ const res = validateOneOf(lexicons, itemPath, itemsDef, itemValue);
3553
+ if (!res.success) {
3554
+ return res;
3555
+ }
3556
+ }
3557
+ return { success: true };
3558
+ }
3559
+ function object(lexicons, path, def, value) {
3560
+ def = def;
3561
+ if (!value || typeof value !== "object") {
3562
+ return {
3563
+ success: false,
3564
+ error: new ValidationError(`${path} must be an object`)
3565
+ };
3566
+ }
3567
+ if (Array.isArray(def.required)) {
3568
+ for (const key of def.required) {
3569
+ if (!(key in value)) {
3570
+ return {
3571
+ success: false,
3572
+ error: new ValidationError(`${path} must have the property "${key}"`)
3573
+ };
3574
+ }
3575
+ }
3576
+ }
3577
+ if (typeof def.properties === "object") {
3578
+ for (const key in def.properties) {
3579
+ const propValue = value[key];
3580
+ if (typeof propValue === "undefined") {
3581
+ continue;
3582
+ }
3583
+ const propDef = def.properties[key];
3584
+ const propPath = `${path}/${key}`;
3585
+ const res = validateOneOf(lexicons, propPath, propDef, propValue);
3586
+ if (!res.success) {
3587
+ return res;
3588
+ }
3589
+ }
3590
+ }
3591
+ return { success: true };
3592
+ }
3593
+
3594
+ // src/util.ts
3595
+ function toLexUri(str, baseUri) {
3596
+ if (str.startsWith("lex:")) {
3597
+ return str;
3598
+ }
3599
+ if (str.startsWith("#")) {
3600
+ if (!baseUri) {
3601
+ throw new Error(`Unable to resolve uri without anchor: ${str}`);
3602
+ }
3603
+ return `${baseUri}${str}`;
3604
+ }
3605
+ return `lex:${str}`;
3606
+ }
3607
+ function validateOneOf(lexicons, path, def, value, mustBeObj = false) {
3608
+ let error;
3609
+ let concreteDefs;
3610
+ if (def.type === "union") {
3611
+ if (!isDiscriminatedObject(value)) {
3612
+ return {
3613
+ success: false,
3614
+ error: new ValidationError(
3615
+ `${path} must be an object which includes the "$type" property`
3616
+ )
3617
+ };
3618
+ }
3619
+ if (!def.refs.includes(toLexUri(value.$type))) {
3620
+ if (def.closed) {
3621
+ return {
3622
+ success: false,
3623
+ error: new ValidationError(
3624
+ `${path} $type must be one of ${def.refs.join(", ")}`
3625
+ )
3626
+ };
3627
+ }
3628
+ return { success: true };
3629
+ } else {
3630
+ concreteDefs = toConcreteTypes(lexicons, {
3631
+ type: "ref",
3632
+ ref: value.$type
3633
+ });
3634
+ }
3635
+ } else {
3636
+ concreteDefs = toConcreteTypes(lexicons, def);
3637
+ }
3638
+ for (const concreteDef of concreteDefs) {
3639
+ const result = mustBeObj ? object(lexicons, path, concreteDef, value) : validate2(lexicons, path, concreteDef, value);
3640
+ if (result.success) {
3641
+ return result;
3642
+ }
3643
+ error ?? (error = result.error);
3644
+ }
3645
+ if (concreteDefs.length > 1) {
3646
+ return {
3647
+ success: false,
3648
+ error: new ValidationError(
3649
+ `${path} did not match any of the expected definitions`
3650
+ )
3651
+ };
3652
+ }
3653
+ return { success: false, error };
3654
+ }
3655
+ function assertValidOneOf(lexicons, path, def, value, mustBeObj = false) {
3656
+ const res = validateOneOf(lexicons, path, def, value, mustBeObj);
3657
+ if (!res.success) {
3658
+ throw res.error;
3659
+ }
3660
+ }
3661
+ function toConcreteTypes(lexicons, def) {
3662
+ if (def.type === "ref") {
3663
+ return [lexicons.getDefOrThrow(def.ref)];
3664
+ } else if (def.type === "union") {
3665
+ return def.refs.map((ref) => lexicons.getDefOrThrow(ref)).flat();
3666
+ } else {
3667
+ return [def];
3668
+ }
3669
+ }
3670
+
3671
+ // src/validators/xrpc.ts
3672
+ function params(lexicons, path, def, value) {
3673
+ def = def;
3674
+ if (!value || typeof value !== "object") {
3675
+ value = {};
3676
+ }
3677
+ if (Array.isArray(def.required)) {
3678
+ for (const key of def.required) {
3679
+ if (!(key in value)) {
3680
+ return {
3681
+ success: false,
3682
+ error: new ValidationError(`${path} must have the property "${key}"`)
3683
+ };
3684
+ }
3685
+ }
3686
+ }
3687
+ for (const key in def.properties) {
3688
+ if (typeof value[key] === "undefined") {
3689
+ continue;
3690
+ }
3691
+ const paramDef = def.properties[key];
3692
+ const res = validate(
3693
+ lexicons,
3694
+ key,
3695
+ paramDef,
3696
+ value[key]
3697
+ );
3698
+ if (!res.success) {
3699
+ return res;
3700
+ }
3701
+ }
3702
+ return { success: true };
3703
+ }
3704
+
3705
+ // src/validation.ts
3706
+ function assertValidRecord(lexicons, def, value) {
3707
+ const res = object(lexicons, "Record", def.record, value);
3708
+ if (!res.success)
3709
+ throw res.error;
3710
+ }
3711
+ function assertValidXrpcParams(lexicons, def, value) {
3712
+ if (def.parameters) {
3713
+ const res = params(lexicons, "Params", def.parameters, value);
3714
+ if (!res.success)
3715
+ throw res.error;
3716
+ }
3717
+ }
3718
+ function assertValidXrpcInput(lexicons, def, value) {
3719
+ if (def.input?.schema) {
3720
+ assertValidOneOf(lexicons, "Input", def.input.schema, value, true);
3721
+ }
3722
+ }
3723
+ function assertValidXrpcOutput(lexicons, def, value) {
3724
+ if (def.output?.schema) {
3725
+ assertValidOneOf(lexicons, "Output", def.output.schema, value, true);
3726
+ }
3727
+ }
3728
+
3729
+ // src/lexicons.ts
3730
+ var Lexicons = class {
3731
+ constructor(docs) {
3732
+ this.docs = /* @__PURE__ */ new Map();
3733
+ this.defs = /* @__PURE__ */ new Map();
3734
+ if (docs?.length) {
3735
+ for (const doc of docs) {
3736
+ this.add(doc);
3737
+ }
3738
+ }
3739
+ }
3740
+ add(doc) {
3741
+ try {
3742
+ lexiconDoc.parse(doc);
3743
+ } catch (e) {
3744
+ if (e instanceof ZodError) {
3745
+ throw new LexiconDocMalformedError(
3746
+ `Failed to parse schema definition ${doc.id}`,
3747
+ doc,
3748
+ e.issues
3749
+ );
3750
+ } else {
3751
+ throw e;
3752
+ }
3753
+ }
3754
+ const validatedDoc = doc;
3755
+ const uri = toLexUri(validatedDoc.id);
3756
+ if (this.docs.has(uri)) {
3757
+ throw new Error(`${uri} has already been registered`);
3758
+ }
3759
+ resolveRefUris(validatedDoc, uri);
3760
+ this.docs.set(uri, validatedDoc);
3761
+ for (const [defUri, def] of iterDefs(validatedDoc)) {
3762
+ this.defs.set(defUri, def);
3763
+ }
3764
+ }
3765
+ remove(uri) {
3766
+ uri = toLexUri(uri);
3767
+ const doc = this.docs.get(uri);
3768
+ if (!doc) {
3769
+ throw new Error(`Unable to remove "${uri}": does not exist`);
3770
+ }
3771
+ for (const [defUri, _def] of iterDefs(doc)) {
3772
+ this.defs.delete(defUri);
3773
+ }
3774
+ this.docs.delete(uri);
3775
+ }
3776
+ get(uri) {
3777
+ uri = toLexUri(uri);
3778
+ return this.docs.get(uri);
3779
+ }
3780
+ getDef(uri) {
3781
+ uri = toLexUri(uri);
3782
+ return this.defs.get(uri);
3783
+ }
3784
+ getDefOrThrow(uri, types) {
3785
+ const def = this.getDef(uri);
3786
+ if (!def) {
3787
+ throw new LexiconDefNotFoundError(`Lexicon not found: ${uri}`);
3788
+ }
3789
+ if (types && !types.includes(def.type)) {
3790
+ throw new InvalidLexiconError(
3791
+ `Not a ${types.join(" or ")} lexicon: ${uri}`
3792
+ );
3793
+ }
3794
+ return def;
3795
+ }
3796
+ assertValidRecord(lexUri, value) {
3797
+ lexUri = toLexUri(lexUri);
3798
+ const def = this.getDefOrThrow(lexUri, ["record"]);
3799
+ if (!isObj(value)) {
3800
+ throw new ValidationError(`Record must be an object`);
3801
+ }
3802
+ if (!hasProp(value, "$type") || typeof value.$type !== "string") {
3803
+ throw new ValidationError(`Record/$type must be a string`);
3804
+ }
3805
+ const $type = value.$type || "";
3806
+ if (toLexUri($type) !== lexUri) {
3807
+ throw new ValidationError(
3808
+ `Invalid $type: must be ${lexUri}, got ${$type}`
3809
+ );
3810
+ }
3811
+ assertValidRecord(this, def, value);
3812
+ }
3813
+ assertValidXrpcParams(lexUri, value) {
3814
+ lexUri = toLexUri(lexUri);
3815
+ const def = this.getDefOrThrow(lexUri, ["query", "procedure"]);
3816
+ assertValidXrpcParams(this, def, value);
3817
+ }
3818
+ assertValidXrpcInput(lexUri, value) {
3819
+ lexUri = toLexUri(lexUri);
3820
+ const def = this.getDefOrThrow(lexUri, ["procedure"]);
3821
+ assertValidXrpcInput(this, def, value);
3822
+ }
3823
+ assertValidXrpcOutput(lexUri, value) {
3824
+ lexUri = toLexUri(lexUri);
3825
+ const def = this.getDefOrThrow(lexUri, ["query", "procedure"]);
3826
+ assertValidXrpcOutput(this, def, value);
3827
+ }
3828
+ };
3829
+ function* iterDefs(doc) {
3830
+ for (const defId in doc.defs) {
3831
+ yield [`lex:${doc.id}#${defId}`, doc.defs[defId]];
3832
+ if (defId === "main") {
3833
+ yield [`lex:${doc.id}`, doc.defs[defId]];
3834
+ }
3835
+ }
3836
+ }
3837
+ function resolveRefUris(obj, baseUri) {
3838
+ for (const k in obj) {
3839
+ if (obj.type === "ref") {
3840
+ obj.ref = toLexUri(obj.ref, baseUri);
3841
+ } else if (obj.type === "union") {
3842
+ obj.refs = obj.refs.map((ref) => toLexUri(ref, baseUri));
3843
+ } else if (Array.isArray(obj[k])) {
3844
+ obj[k] = obj[k].map((item) => {
3845
+ if (typeof item === "string") {
3846
+ return item.startsWith("#") ? toLexUri(item, baseUri) : item;
3847
+ } else if (item && typeof item === "object") {
3848
+ return resolveRefUris(item, baseUri);
3849
+ }
3850
+ return item;
3851
+ });
3852
+ } else if (obj[k] && typeof obj[k] === "object") {
3853
+ obj[k] = resolveRefUris(obj[k], baseUri);
3854
+ }
3855
+ }
3856
+ return obj;
3857
+ }
3858
+ // Annotate the CommonJS export names for ESM import in node:
3859
+ 0 && (module.exports = {
3860
+ InvalidLexiconError,
3861
+ LexiconDefNotFoundError,
3862
+ LexiconDocMalformedError,
3863
+ Lexicons,
3864
+ ValidationError,
3865
+ discriminatedObject,
3866
+ hasProp,
3867
+ isDiscriminatedObject,
3868
+ isObj,
3869
+ isValidLexiconDoc,
3870
+ lexArray,
3871
+ lexAudio,
3872
+ lexBlob,
3873
+ lexBlobVariant,
3874
+ lexBoolean,
3875
+ lexDatetime,
3876
+ lexImage,
3877
+ lexInteger,
3878
+ lexNumber,
3879
+ lexObject,
3880
+ lexPrimitive,
3881
+ lexRecord,
3882
+ lexRef,
3883
+ lexRefUnion,
3884
+ lexRefVariant,
3885
+ lexString,
3886
+ lexToken,
3887
+ lexUnknown,
3888
+ lexUserType,
3889
+ lexVideo,
3890
+ lexXrpcBody,
3891
+ lexXrpcError,
3892
+ lexXrpcParameters,
3893
+ lexXrpcProcedure,
3894
+ lexXrpcQuery,
3895
+ lexiconDoc
3896
+ });
3897
+ //# sourceMappingURL=index.js.map