@learncard/types 5.2.9 → 5.3.0

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