@myxtra/microservice 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -24,45 +24,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  mod
25
25
  ));
26
26
 
27
- // ../../node_modules/zod-to-json-schema/dist/cjs/errorMessages.js
28
- var require_errorMessages = __commonJS({
29
- "../../node_modules/zod-to-json-schema/dist/cjs/errorMessages.js"(exports) {
30
- "use strict";
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.setResponseValueAndErrors = exports.addErrorMessage = void 0;
33
- function addErrorMessage(res, key, errorMessage, refs) {
34
- if (!refs?.errorMessages)
35
- return;
36
- if (errorMessage) {
37
- res.errorMessage = {
38
- ...res.errorMessage,
39
- [key]: errorMessage
40
- };
41
- }
42
- }
43
- exports.addErrorMessage = addErrorMessage;
44
- function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
45
- res[key] = value;
46
- addErrorMessage(res, key, errorMessage, refs);
47
- }
48
- exports.setResponseValueAndErrors = setResponseValueAndErrors;
49
- }
50
- });
51
-
52
27
  // ../../node_modules/zod-to-json-schema/dist/cjs/Options.js
53
28
  var require_Options = __commonJS({
54
29
  "../../node_modules/zod-to-json-schema/dist/cjs/Options.js"(exports) {
55
30
  "use strict";
56
31
  Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.getDefaultOptions = exports.defaultOptions = void 0;
32
+ exports.getDefaultOptions = exports.defaultOptions = exports.ignoreOverride = void 0;
33
+ exports.ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
58
34
  exports.defaultOptions = {
59
35
  name: void 0,
60
36
  $refStrategy: "root",
61
37
  basePath: ["#"],
62
38
  effectStrategy: "input",
63
39
  pipeStrategy: "all",
64
- dateStrategy: "string",
40
+ dateStrategy: "format:date-time",
65
41
  mapStrategy: "entries",
42
+ removeAdditionalStrategy: "passthrough",
66
43
  definitionPath: "definitions",
67
44
  target: "jsonSchema7",
68
45
  strictUnions: false,
@@ -70,7 +47,8 @@ var require_Options = __commonJS({
70
47
  errorMessages: false,
71
48
  markdownDescription: false,
72
49
  patternStrategy: "escape",
73
- emailStrategy: "format:email"
50
+ emailStrategy: "format:email",
51
+ base64Strategy: "contentEncoding:base64"
74
52
  };
75
53
  var getDefaultOptions = (options) => typeof options === "string" ? {
76
54
  ...exports.defaultOptions,
@@ -83,6 +61,60 @@ var require_Options = __commonJS({
83
61
  }
84
62
  });
85
63
 
64
+ // ../../node_modules/zod-to-json-schema/dist/cjs/Refs.js
65
+ var require_Refs = __commonJS({
66
+ "../../node_modules/zod-to-json-schema/dist/cjs/Refs.js"(exports) {
67
+ "use strict";
68
+ Object.defineProperty(exports, "__esModule", { value: true });
69
+ exports.getRefs = void 0;
70
+ var Options_js_1 = require_Options();
71
+ var getRefs = (options) => {
72
+ const _options = (0, Options_js_1.getDefaultOptions)(options);
73
+ const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
74
+ return {
75
+ ..._options,
76
+ currentPath,
77
+ propertyPath: void 0,
78
+ seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
79
+ def._def,
80
+ {
81
+ def: def._def,
82
+ path: [..._options.basePath, _options.definitionPath, name],
83
+ // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
84
+ jsonSchema: void 0
85
+ }
86
+ ]))
87
+ };
88
+ };
89
+ exports.getRefs = getRefs;
90
+ }
91
+ });
92
+
93
+ // ../../node_modules/zod-to-json-schema/dist/cjs/errorMessages.js
94
+ var require_errorMessages = __commonJS({
95
+ "../../node_modules/zod-to-json-schema/dist/cjs/errorMessages.js"(exports) {
96
+ "use strict";
97
+ Object.defineProperty(exports, "__esModule", { value: true });
98
+ exports.setResponseValueAndErrors = exports.addErrorMessage = void 0;
99
+ function addErrorMessage(res, key, errorMessage, refs) {
100
+ if (!refs?.errorMessages)
101
+ return;
102
+ if (errorMessage) {
103
+ res.errorMessage = {
104
+ ...res.errorMessage,
105
+ [key]: errorMessage
106
+ };
107
+ }
108
+ }
109
+ exports.addErrorMessage = addErrorMessage;
110
+ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
111
+ res[key] = value;
112
+ addErrorMessage(res, key, errorMessage, refs);
113
+ }
114
+ exports.setResponseValueAndErrors = setResponseValueAndErrors;
115
+ }
116
+ });
117
+
86
118
  // ../../node_modules/zod/lib/helpers/util.js
87
119
  var require_util = __commonJS({
88
120
  "../../node_modules/zod/lib/helpers/util.js"(exports) {
@@ -254,7 +286,7 @@ var require_ZodError = __commonJS({
254
286
  return json.replace(/"([^"]+)":/g, "$1:");
255
287
  };
256
288
  exports.quotelessJson = quotelessJson2;
257
- var ZodError2 = class extends Error {
289
+ var ZodError2 = class _ZodError extends Error {
258
290
  constructor(issues) {
259
291
  super();
260
292
  this.issues = [];
@@ -312,6 +344,11 @@ var require_ZodError = __commonJS({
312
344
  processError(this);
313
345
  return fieldErrors;
314
346
  }
347
+ static assert(value) {
348
+ if (!(value instanceof _ZodError)) {
349
+ throw new Error(`Not a ZodError: ${value}`);
350
+ }
351
+ }
315
352
  toString() {
316
353
  return this.message;
317
354
  }
@@ -496,6 +533,13 @@ var require_parseUtil = __commonJS({
496
533
  ...issueData,
497
534
  path: fullPath
498
535
  };
536
+ if (issueData.message !== void 0) {
537
+ return {
538
+ ...issueData,
539
+ path: fullPath,
540
+ message: issueData.message
541
+ };
542
+ }
499
543
  let errorMessage = "";
500
544
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
501
545
  for (const map of maps) {
@@ -504,12 +548,13 @@ var require_parseUtil = __commonJS({
504
548
  return {
505
549
  ...issueData,
506
550
  path: fullPath,
507
- message: issueData.message || errorMessage
551
+ message: errorMessage
508
552
  };
509
553
  };
510
554
  exports.makeIssue = makeIssue2;
511
555
  exports.EMPTY_PATH = [];
512
556
  function addIssueToContext2(ctx, issueData) {
557
+ const overrideMap = (0, errors_1.getErrorMap)();
513
558
  const issue = (0, exports.makeIssue)({
514
559
  issueData,
515
560
  data: ctx.data,
@@ -517,8 +562,8 @@ var require_parseUtil = __commonJS({
517
562
  errorMaps: [
518
563
  ctx.common.contextualErrorMap,
519
564
  ctx.schemaErrorMap,
520
- (0, errors_1.getErrorMap)(),
521
- en_1.default
565
+ overrideMap,
566
+ overrideMap === en_1.default ? void 0 : en_1.default
522
567
  // then global default map
523
568
  ].filter((x) => !!x)
524
569
  });
@@ -551,9 +596,11 @@ var require_parseUtil = __commonJS({
551
596
  static async mergeObjectAsync(status, pairs) {
552
597
  const syncPairs = [];
553
598
  for (const pair of pairs) {
599
+ const key = await pair.key;
600
+ const value = await pair.value;
554
601
  syncPairs.push({
555
- key: await pair.key,
556
- value: await pair.value
602
+ key,
603
+ value
557
604
  });
558
605
  }
559
606
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -622,9 +669,27 @@ var require_errorUtil = __commonJS({
622
669
  var require_types = __commonJS({
623
670
  "../../node_modules/zod/lib/types.js"(exports) {
624
671
  "use strict";
672
+ var __classPrivateFieldGet2 = exports && exports.__classPrivateFieldGet || function(receiver, state, kind, f) {
673
+ if (kind === "a" && !f)
674
+ throw new TypeError("Private accessor was defined without a getter");
675
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
676
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
677
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
678
+ };
679
+ var __classPrivateFieldSet2 = exports && exports.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
680
+ if (kind === "m")
681
+ throw new TypeError("Private method is not writable");
682
+ if (kind === "a" && !f)
683
+ throw new TypeError("Private accessor was defined without a setter");
684
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
685
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
686
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
687
+ };
688
+ var _ZodEnum_cache2;
689
+ var _ZodNativeEnum_cache2;
625
690
  Object.defineProperty(exports, "__esModule", { value: true });
626
- exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
627
- exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = void 0;
691
+ exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.datetimeRegex = exports.ZodType = void 0;
692
+ exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = exports.date = void 0;
628
693
  var errors_1 = require_errors();
629
694
  var errorUtil_1 = require_errorUtil();
630
695
  var parseUtil_1 = require_parseUtil();
@@ -678,12 +743,17 @@ var require_types = __commonJS({
678
743
  if (errorMap2)
679
744
  return { errorMap: errorMap2, description };
680
745
  const customMap = (iss, ctx) => {
681
- if (iss.code !== "invalid_type")
682
- return { message: ctx.defaultError };
746
+ var _a, _b;
747
+ const { message } = params;
748
+ if (iss.code === "invalid_enum_value") {
749
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
750
+ }
683
751
  if (typeof ctx.data === "undefined") {
684
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
752
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
685
753
  }
686
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
754
+ if (iss.code !== "invalid_type")
755
+ return { message: ctx.defaultError };
756
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
687
757
  };
688
758
  return { errorMap: customMap, description };
689
759
  }
@@ -934,35 +1004,41 @@ var require_types = __commonJS({
934
1004
  exports.Schema = ZodType2;
935
1005
  exports.ZodSchema = ZodType2;
936
1006
  var cuidRegex2 = /^c[^\s-]{8,}$/i;
937
- var cuid2Regex2 = /^[a-z][a-z0-9]*$/;
1007
+ var cuid2Regex2 = /^[0-9a-z]+$/;
938
1008
  var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/;
939
1009
  var uuidRegex2 = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
940
- var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1010
+ var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
1011
+ var durationRegex2 = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
1012
+ var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
941
1013
  var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
942
1014
  var emojiRegex2;
943
- var ipv4Regex2 = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
1015
+ var ipv4Regex2 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
944
1016
  var ipv6Regex2 = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
945
- var datetimeRegex2 = (args) => {
1017
+ var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1018
+ var dateRegexSource2 = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
1019
+ var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
1020
+ function timeRegexSource2(args) {
1021
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
946
1022
  if (args.precision) {
947
- if (args.offset) {
948
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
949
- } else {
950
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
951
- }
952
- } else if (args.precision === 0) {
953
- if (args.offset) {
954
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
955
- } else {
956
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
957
- }
958
- } else {
959
- if (args.offset) {
960
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
961
- } else {
962
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
963
- }
1023
+ regex = `${regex}\\.\\d{${args.precision}}`;
1024
+ } else if (args.precision == null) {
1025
+ regex = `${regex}(\\.\\d+)?`;
964
1026
  }
965
- };
1027
+ return regex;
1028
+ }
1029
+ function timeRegex2(args) {
1030
+ return new RegExp(`^${timeRegexSource2(args)}$`);
1031
+ }
1032
+ function datetimeRegex2(args) {
1033
+ let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
1034
+ const opts = [];
1035
+ opts.push(args.local ? `Z?` : `Z`);
1036
+ if (args.offset)
1037
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1038
+ regex = `${regex}(${opts.join("|")})`;
1039
+ return new RegExp(`^${regex}$`);
1040
+ }
1041
+ exports.datetimeRegex = datetimeRegex2;
966
1042
  function isValidIP2(ip, version) {
967
1043
  if ((version === "v4" || !version) && ipv4Regex2.test(ip)) {
968
1044
  return true;
@@ -980,15 +1056,11 @@ var require_types = __commonJS({
980
1056
  const parsedType = this._getType(input);
981
1057
  if (parsedType !== util_1.ZodParsedType.string) {
982
1058
  const ctx2 = this._getOrReturnCtx(input);
983
- (0, parseUtil_1.addIssueToContext)(
984
- ctx2,
985
- {
986
- code: ZodError_1.ZodIssueCode.invalid_type,
987
- expected: util_1.ZodParsedType.string,
988
- received: ctx2.parsedType
989
- }
990
- //
991
- );
1059
+ (0, parseUtil_1.addIssueToContext)(ctx2, {
1060
+ code: ZodError_1.ZodIssueCode.invalid_type,
1061
+ expected: util_1.ZodParsedType.string,
1062
+ received: ctx2.parsedType
1063
+ });
992
1064
  return parseUtil_1.INVALID;
993
1065
  }
994
1066
  const status = new parseUtil_1.ParseStatus();
@@ -1079,6 +1151,16 @@ var require_types = __commonJS({
1079
1151
  });
1080
1152
  status.dirty();
1081
1153
  }
1154
+ } else if (check.kind === "nanoid") {
1155
+ if (!nanoidRegex2.test(input.data)) {
1156
+ ctx = this._getOrReturnCtx(input, ctx);
1157
+ (0, parseUtil_1.addIssueToContext)(ctx, {
1158
+ validation: "nanoid",
1159
+ code: ZodError_1.ZodIssueCode.invalid_string,
1160
+ message: check.message
1161
+ });
1162
+ status.dirty();
1163
+ }
1082
1164
  } else if (check.kind === "cuid") {
1083
1165
  if (!cuidRegex2.test(input.data)) {
1084
1166
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1180,6 +1262,38 @@ var require_types = __commonJS({
1180
1262
  });
1181
1263
  status.dirty();
1182
1264
  }
1265
+ } else if (check.kind === "date") {
1266
+ const regex = dateRegex2;
1267
+ if (!regex.test(input.data)) {
1268
+ ctx = this._getOrReturnCtx(input, ctx);
1269
+ (0, parseUtil_1.addIssueToContext)(ctx, {
1270
+ code: ZodError_1.ZodIssueCode.invalid_string,
1271
+ validation: "date",
1272
+ message: check.message
1273
+ });
1274
+ status.dirty();
1275
+ }
1276
+ } else if (check.kind === "time") {
1277
+ const regex = timeRegex2(check);
1278
+ if (!regex.test(input.data)) {
1279
+ ctx = this._getOrReturnCtx(input, ctx);
1280
+ (0, parseUtil_1.addIssueToContext)(ctx, {
1281
+ code: ZodError_1.ZodIssueCode.invalid_string,
1282
+ validation: "time",
1283
+ message: check.message
1284
+ });
1285
+ status.dirty();
1286
+ }
1287
+ } else if (check.kind === "duration") {
1288
+ if (!durationRegex2.test(input.data)) {
1289
+ ctx = this._getOrReturnCtx(input, ctx);
1290
+ (0, parseUtil_1.addIssueToContext)(ctx, {
1291
+ validation: "duration",
1292
+ code: ZodError_1.ZodIssueCode.invalid_string,
1293
+ message: check.message
1294
+ });
1295
+ status.dirty();
1296
+ }
1183
1297
  } else if (check.kind === "ip") {
1184
1298
  if (!isValidIP2(input.data, check.version)) {
1185
1299
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1190,6 +1304,16 @@ var require_types = __commonJS({
1190
1304
  });
1191
1305
  status.dirty();
1192
1306
  }
1307
+ } else if (check.kind === "base64") {
1308
+ if (!base64Regex2.test(input.data)) {
1309
+ ctx = this._getOrReturnCtx(input, ctx);
1310
+ (0, parseUtil_1.addIssueToContext)(ctx, {
1311
+ validation: "base64",
1312
+ code: ZodError_1.ZodIssueCode.invalid_string,
1313
+ message: check.message
1314
+ });
1315
+ status.dirty();
1316
+ }
1193
1317
  } else {
1194
1318
  util_1.util.assertNever(check);
1195
1319
  }
@@ -1221,6 +1345,9 @@ var require_types = __commonJS({
1221
1345
  uuid(message) {
1222
1346
  return this._addCheck({ kind: "uuid", ...errorUtil_1.errorUtil.errToObj(message) });
1223
1347
  }
1348
+ nanoid(message) {
1349
+ return this._addCheck({ kind: "nanoid", ...errorUtil_1.errorUtil.errToObj(message) });
1350
+ }
1224
1351
  cuid(message) {
1225
1352
  return this._addCheck({ kind: "cuid", ...errorUtil_1.errorUtil.errToObj(message) });
1226
1353
  }
@@ -1230,16 +1357,20 @@ var require_types = __commonJS({
1230
1357
  ulid(message) {
1231
1358
  return this._addCheck({ kind: "ulid", ...errorUtil_1.errorUtil.errToObj(message) });
1232
1359
  }
1360
+ base64(message) {
1361
+ return this._addCheck({ kind: "base64", ...errorUtil_1.errorUtil.errToObj(message) });
1362
+ }
1233
1363
  ip(options) {
1234
1364
  return this._addCheck({ kind: "ip", ...errorUtil_1.errorUtil.errToObj(options) });
1235
1365
  }
1236
1366
  datetime(options) {
1237
- var _a;
1367
+ var _a, _b;
1238
1368
  if (typeof options === "string") {
1239
1369
  return this._addCheck({
1240
1370
  kind: "datetime",
1241
1371
  precision: null,
1242
1372
  offset: false,
1373
+ local: false,
1243
1374
  message: options
1244
1375
  });
1245
1376
  }
@@ -1247,9 +1378,30 @@ var require_types = __commonJS({
1247
1378
  kind: "datetime",
1248
1379
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1249
1380
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1381
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1250
1382
  ...errorUtil_1.errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1251
1383
  });
1252
1384
  }
1385
+ date(message) {
1386
+ return this._addCheck({ kind: "date", message });
1387
+ }
1388
+ time(options) {
1389
+ if (typeof options === "string") {
1390
+ return this._addCheck({
1391
+ kind: "time",
1392
+ precision: null,
1393
+ message: options
1394
+ });
1395
+ }
1396
+ return this._addCheck({
1397
+ kind: "time",
1398
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1399
+ ...errorUtil_1.errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1400
+ });
1401
+ }
1402
+ duration(message) {
1403
+ return this._addCheck({ kind: "duration", ...errorUtil_1.errorUtil.errToObj(message) });
1404
+ }
1253
1405
  regex(regex, message) {
1254
1406
  return this._addCheck({
1255
1407
  kind: "regex",
@@ -1328,6 +1480,15 @@ var require_types = __commonJS({
1328
1480
  get isDatetime() {
1329
1481
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1330
1482
  }
1483
+ get isDate() {
1484
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1485
+ }
1486
+ get isTime() {
1487
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1488
+ }
1489
+ get isDuration() {
1490
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1491
+ }
1331
1492
  get isEmail() {
1332
1493
  return !!this._def.checks.find((ch) => ch.kind === "email");
1333
1494
  }
@@ -1340,6 +1501,9 @@ var require_types = __commonJS({
1340
1501
  get isUUID() {
1341
1502
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1342
1503
  }
1504
+ get isNANOID() {
1505
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1506
+ }
1343
1507
  get isCUID() {
1344
1508
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1345
1509
  }
@@ -1352,6 +1516,9 @@ var require_types = __commonJS({
1352
1516
  get isIP() {
1353
1517
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1354
1518
  }
1519
+ get isBase64() {
1520
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1521
+ }
1355
1522
  get minLength() {
1356
1523
  let min = null;
1357
1524
  for (const ch of this._def.checks) {
@@ -2277,9 +2444,10 @@ var require_types = __commonJS({
2277
2444
  const syncPairs = [];
2278
2445
  for (const pair of pairs) {
2279
2446
  const key = await pair.key;
2447
+ const value = await pair.value;
2280
2448
  syncPairs.push({
2281
2449
  key,
2282
- value: await pair.value,
2450
+ value,
2283
2451
  alwaysSet: pair.alwaysSet
2284
2452
  });
2285
2453
  }
@@ -2632,15 +2800,25 @@ var require_types = __commonJS({
2632
2800
  } else if (type instanceof ZodEnum2) {
2633
2801
  return type.options;
2634
2802
  } else if (type instanceof ZodNativeEnum2) {
2635
- return Object.keys(type.enum);
2803
+ return util_1.util.objectValues(type.enum);
2636
2804
  } else if (type instanceof ZodDefault2) {
2637
2805
  return getDiscriminator2(type._def.innerType);
2638
2806
  } else if (type instanceof ZodUndefined2) {
2639
2807
  return [void 0];
2640
2808
  } else if (type instanceof ZodNull2) {
2641
2809
  return [null];
2810
+ } else if (type instanceof ZodOptional2) {
2811
+ return [void 0, ...getDiscriminator2(type.unwrap())];
2812
+ } else if (type instanceof ZodNullable2) {
2813
+ return [null, ...getDiscriminator2(type.unwrap())];
2814
+ } else if (type instanceof ZodBranded2) {
2815
+ return getDiscriminator2(type.unwrap());
2816
+ } else if (type instanceof ZodReadonly2) {
2817
+ return getDiscriminator2(type.unwrap());
2818
+ } else if (type instanceof ZodCatch2) {
2819
+ return getDiscriminator2(type._def.innerType);
2642
2820
  } else {
2643
- return null;
2821
+ return [];
2644
2822
  }
2645
2823
  };
2646
2824
  var ZodDiscriminatedUnion2 = class _ZodDiscriminatedUnion extends ZodType2 {
@@ -2700,7 +2878,7 @@ var require_types = __commonJS({
2700
2878
  const optionsMap = /* @__PURE__ */ new Map();
2701
2879
  for (const type of options) {
2702
2880
  const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
2703
- if (!discriminatorValues) {
2881
+ if (!discriminatorValues.length) {
2704
2882
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2705
2883
  }
2706
2884
  for (const value of discriminatorValues) {
@@ -2903,7 +3081,8 @@ var require_types = __commonJS({
2903
3081
  for (const key in ctx.data) {
2904
3082
  pairs.push({
2905
3083
  key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
2906
- value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key))
3084
+ value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
3085
+ alwaysSet: key in ctx.data
2907
3086
  });
2908
3087
  }
2909
3088
  if (ctx.common.async) {
@@ -3253,6 +3432,10 @@ var require_types = __commonJS({
3253
3432
  });
3254
3433
  }
3255
3434
  var ZodEnum2 = class _ZodEnum extends ZodType2 {
3435
+ constructor() {
3436
+ super(...arguments);
3437
+ _ZodEnum_cache2.set(this, void 0);
3438
+ }
3256
3439
  _parse(input) {
3257
3440
  if (typeof input.data !== "string") {
3258
3441
  const ctx = this._getOrReturnCtx(input);
@@ -3264,7 +3447,10 @@ var require_types = __commonJS({
3264
3447
  });
3265
3448
  return parseUtil_1.INVALID;
3266
3449
  }
3267
- if (this._def.values.indexOf(input.data) === -1) {
3450
+ if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f")) {
3451
+ __classPrivateFieldSet2(this, _ZodEnum_cache2, new Set(this._def.values), "f");
3452
+ }
3453
+ if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f").has(input.data)) {
3268
3454
  const ctx = this._getOrReturnCtx(input);
3269
3455
  const expectedValues = this._def.values;
3270
3456
  (0, parseUtil_1.addIssueToContext)(ctx, {
@@ -3300,16 +3486,27 @@ var require_types = __commonJS({
3300
3486
  }
3301
3487
  return enumValues;
3302
3488
  }
3303
- extract(values) {
3304
- return _ZodEnum.create(values);
3489
+ extract(values, newDef = this._def) {
3490
+ return _ZodEnum.create(values, {
3491
+ ...this._def,
3492
+ ...newDef
3493
+ });
3305
3494
  }
3306
- exclude(values) {
3307
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3495
+ exclude(values, newDef = this._def) {
3496
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3497
+ ...this._def,
3498
+ ...newDef
3499
+ });
3308
3500
  }
3309
3501
  };
3310
3502
  exports.ZodEnum = ZodEnum2;
3503
+ _ZodEnum_cache2 = /* @__PURE__ */ new WeakMap();
3311
3504
  ZodEnum2.create = createZodEnum2;
3312
3505
  var ZodNativeEnum2 = class extends ZodType2 {
3506
+ constructor() {
3507
+ super(...arguments);
3508
+ _ZodNativeEnum_cache2.set(this, void 0);
3509
+ }
3313
3510
  _parse(input) {
3314
3511
  const nativeEnumValues = util_1.util.getValidEnumValues(this._def.values);
3315
3512
  const ctx = this._getOrReturnCtx(input);
@@ -3322,7 +3519,10 @@ var require_types = __commonJS({
3322
3519
  });
3323
3520
  return parseUtil_1.INVALID;
3324
3521
  }
3325
- if (nativeEnumValues.indexOf(input.data) === -1) {
3522
+ if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f")) {
3523
+ __classPrivateFieldSet2(this, _ZodNativeEnum_cache2, new Set(util_1.util.getValidEnumValues(this._def.values)), "f");
3524
+ }
3525
+ if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
3326
3526
  const expectedValues = util_1.util.objectValues(nativeEnumValues);
3327
3527
  (0, parseUtil_1.addIssueToContext)(ctx, {
3328
3528
  received: ctx.data,
@@ -3338,6 +3538,7 @@ var require_types = __commonJS({
3338
3538
  }
3339
3539
  };
3340
3540
  exports.ZodNativeEnum = ZodNativeEnum2;
3541
+ _ZodNativeEnum_cache2 = /* @__PURE__ */ new WeakMap();
3341
3542
  ZodNativeEnum2.create = (values, params) => {
3342
3543
  return new ZodNativeEnum2({
3343
3544
  values,
@@ -3402,26 +3603,38 @@ var require_types = __commonJS({
3402
3603
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3403
3604
  if (effect.type === "preprocess") {
3404
3605
  const processed = effect.transform(ctx.data, checkCtx);
3405
- if (ctx.common.issues.length) {
3406
- return {
3407
- status: "dirty",
3408
- value: ctx.data
3409
- };
3410
- }
3411
3606
  if (ctx.common.async) {
3412
- return Promise.resolve(processed).then((processed2) => {
3413
- return this._def.schema._parseAsync({
3607
+ return Promise.resolve(processed).then(async (processed2) => {
3608
+ if (status.value === "aborted")
3609
+ return parseUtil_1.INVALID;
3610
+ const result = await this._def.schema._parseAsync({
3414
3611
  data: processed2,
3415
3612
  path: ctx.path,
3416
3613
  parent: ctx
3417
3614
  });
3615
+ if (result.status === "aborted")
3616
+ return parseUtil_1.INVALID;
3617
+ if (result.status === "dirty")
3618
+ return (0, parseUtil_1.DIRTY)(result.value);
3619
+ if (status.value === "dirty")
3620
+ return (0, parseUtil_1.DIRTY)(result.value);
3621
+ return result;
3418
3622
  });
3419
3623
  } else {
3420
- return this._def.schema._parseSync({
3624
+ if (status.value === "aborted")
3625
+ return parseUtil_1.INVALID;
3626
+ const result = this._def.schema._parseSync({
3421
3627
  data: processed,
3422
3628
  path: ctx.path,
3423
3629
  parent: ctx
3424
3630
  });
3631
+ if (result.status === "aborted")
3632
+ return parseUtil_1.INVALID;
3633
+ if (result.status === "dirty")
3634
+ return (0, parseUtil_1.DIRTY)(result.value);
3635
+ if (status.value === "dirty")
3636
+ return (0, parseUtil_1.DIRTY)(result.value);
3637
+ return result;
3425
3638
  }
3426
3639
  }
3427
3640
  if (effect.type === "refinement") {
@@ -3719,10 +3932,16 @@ var require_types = __commonJS({
3719
3932
  var ZodReadonly2 = class extends ZodType2 {
3720
3933
  _parse(input) {
3721
3934
  const result = this._def.innerType._parse(input);
3722
- if ((0, parseUtil_1.isValid)(result)) {
3723
- result.value = Object.freeze(result.value);
3724
- }
3725
- return result;
3935
+ const freeze = (data) => {
3936
+ if ((0, parseUtil_1.isValid)(data)) {
3937
+ data.value = Object.freeze(data.value);
3938
+ }
3939
+ return data;
3940
+ };
3941
+ return (0, parseUtil_1.isAsync)(result) ? result.then((data) => freeze(data)) : freeze(result);
3942
+ }
3943
+ unwrap() {
3944
+ return this._def.innerType;
3726
3945
  }
3727
3946
  };
3728
3947
  exports.ZodReadonly = ZodReadonly2;
@@ -3733,7 +3952,7 @@ var require_types = __commonJS({
3733
3952
  ...processCreateParams2(params)
3734
3953
  });
3735
3954
  };
3736
- var custom2 = (check, params = {}, fatal) => {
3955
+ function custom2(check, params = {}, fatal) {
3737
3956
  if (check)
3738
3957
  return ZodAny2.create().superRefine((data, ctx) => {
3739
3958
  var _a, _b;
@@ -3745,7 +3964,7 @@ var require_types = __commonJS({
3745
3964
  }
3746
3965
  });
3747
3966
  return ZodAny2.create();
3748
- };
3967
+ }
3749
3968
  exports.custom = custom2;
3750
3969
  exports.late = {
3751
3970
  object: ZodObject2.lazycreate
@@ -3791,7 +4010,7 @@ var require_types = __commonJS({
3791
4010
  })(ZodFirstPartyTypeKind2 = exports.ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = {}));
3792
4011
  var instanceOfType2 = (cls, params = {
3793
4012
  message: `Input not instance of ${cls.name}`
3794
- }) => (0, exports.custom)((data) => data instanceof cls, params);
4013
+ }) => custom2((data) => data instanceof cls, params);
3795
4014
  exports.instanceof = instanceOfType2;
3796
4015
  var stringType2 = ZodString2.create;
3797
4016
  exports.string = stringType2;
@@ -4111,15 +4330,28 @@ var require_date = __commonJS({
4111
4330
  Object.defineProperty(exports, "__esModule", { value: true });
4112
4331
  exports.parseDateDef = void 0;
4113
4332
  var errorMessages_js_1 = require_errorMessages();
4114
- function parseDateDef(def, refs) {
4115
- if (refs.dateStrategy == "integer") {
4116
- return integerDateParser(def, refs);
4117
- } else {
4333
+ function parseDateDef(def, refs, overrideDateStrategy) {
4334
+ const strategy = overrideDateStrategy ?? refs.dateStrategy;
4335
+ if (Array.isArray(strategy)) {
4118
4336
  return {
4119
- type: "string",
4120
- format: "date-time"
4337
+ anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
4121
4338
  };
4122
4339
  }
4340
+ switch (strategy) {
4341
+ case "string":
4342
+ case "format:date-time":
4343
+ return {
4344
+ type: "string",
4345
+ format: "date-time"
4346
+ };
4347
+ case "format:date":
4348
+ return {
4349
+ type: "string",
4350
+ format: "date"
4351
+ };
4352
+ case "integer":
4353
+ return integerDateParser(def, refs);
4354
+ }
4123
4355
  }
4124
4356
  exports.parseDateDef = parseDateDef;
4125
4357
  var integerDateParser = (def, refs) => {
@@ -4127,31 +4359,30 @@ var require_date = __commonJS({
4127
4359
  type: "integer",
4128
4360
  format: "unix-time"
4129
4361
  };
4362
+ if (refs.target === "openApi3") {
4363
+ return res;
4364
+ }
4130
4365
  for (const check of def.checks) {
4131
4366
  switch (check.kind) {
4132
4367
  case "min":
4133
- if (refs.target === "jsonSchema7") {
4134
- (0, errorMessages_js_1.setResponseValueAndErrors)(
4135
- res,
4136
- "minimum",
4137
- check.value,
4138
- // This is in milliseconds
4139
- check.message,
4140
- refs
4141
- );
4142
- }
4368
+ (0, errorMessages_js_1.setResponseValueAndErrors)(
4369
+ res,
4370
+ "minimum",
4371
+ check.value,
4372
+ // This is in milliseconds
4373
+ check.message,
4374
+ refs
4375
+ );
4143
4376
  break;
4144
4377
  case "max":
4145
- if (refs.target === "jsonSchema7") {
4146
- (0, errorMessages_js_1.setResponseValueAndErrors)(
4147
- res,
4148
- "maximum",
4149
- check.value,
4150
- // This is in milliseconds
4151
- check.message,
4152
- refs
4153
- );
4154
- }
4378
+ (0, errorMessages_js_1.setResponseValueAndErrors)(
4379
+ res,
4380
+ "maximum",
4381
+ check.value,
4382
+ // This is in milliseconds
4383
+ check.message,
4384
+ refs
4385
+ );
4155
4386
  break;
4156
4387
  }
4157
4388
  }
@@ -4316,7 +4547,9 @@ var require_string = __commonJS({
4316
4547
  /**
4317
4548
  * Unused
4318
4549
  */
4319
- ipv6: "^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"
4550
+ ipv6: "^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$",
4551
+ base64: "^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$",
4552
+ nanoid: "^[a-zA-Z0-9_-]{21}$"
4320
4553
  };
4321
4554
  function parseStringDef(def, refs) {
4322
4555
  const res = {
@@ -4371,6 +4604,15 @@ var require_string = __commonJS({
4371
4604
  case "datetime":
4372
4605
  addFormat(res, "date-time", check.message, refs);
4373
4606
  break;
4607
+ case "date":
4608
+ addFormat(res, "date", check.message, refs);
4609
+ break;
4610
+ case "time":
4611
+ addFormat(res, "time", check.message, refs);
4612
+ break;
4613
+ case "duration":
4614
+ addFormat(res, "duration", check.message, refs);
4615
+ break;
4374
4616
  case "length":
4375
4617
  (0, errorMessages_js_1.setResponseValueAndErrors)(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
4376
4618
  (0, errorMessages_js_1.setResponseValueAndErrors)(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
@@ -4395,6 +4637,26 @@ var require_string = __commonJS({
4395
4637
  addPattern(res, exports.zodPatterns.ulid, check.message, refs);
4396
4638
  break;
4397
4639
  }
4640
+ case "base64": {
4641
+ switch (refs.base64Strategy) {
4642
+ case "format:binary": {
4643
+ addFormat(res, "binary", check.message, refs);
4644
+ break;
4645
+ }
4646
+ case "contentEncoding:base64": {
4647
+ (0, errorMessages_js_1.setResponseValueAndErrors)(res, "contentEncoding", "base64", check.message, refs);
4648
+ break;
4649
+ }
4650
+ case "pattern:zod": {
4651
+ addPattern(res, exports.zodPatterns.base64, check.message, refs);
4652
+ break;
4653
+ }
4654
+ }
4655
+ break;
4656
+ }
4657
+ case "nanoid": {
4658
+ addPattern(res, exports.zodPatterns.nanoid, check.message, refs);
4659
+ }
4398
4660
  case "toLowerCase":
4399
4661
  case "toUpperCase":
4400
4662
  case "trim":
@@ -4717,6 +4979,8 @@ var require_nullable = __commonJS({
4717
4979
  ...refs,
4718
4980
  currentPath: [...refs.currentPath]
4719
4981
  });
4982
+ if (base2 && "$ref" in base2)
4983
+ return { allOf: [base2], nullable: true };
4720
4984
  return base2 && { ...base2, nullable: true };
4721
4985
  }
4722
4986
  const base = (0, parseDef_js_1.parseDef)(def.innerType._def, {
@@ -4794,6 +5058,19 @@ var require_object = __commonJS({
4794
5058
  Object.defineProperty(exports, "__esModule", { value: true });
4795
5059
  exports.parseObjectDef = exports.parseObjectDefX = void 0;
4796
5060
  var parseDef_js_1 = require_parseDef();
5061
+ function decideAdditionalProperties(def, refs) {
5062
+ if (refs.removeAdditionalStrategy === "strict") {
5063
+ return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys !== "strict" : (0, parseDef_js_1.parseDef)(def.catchall._def, {
5064
+ ...refs,
5065
+ currentPath: [...refs.currentPath, "additionalProperties"]
5066
+ }) ?? true;
5067
+ } else {
5068
+ return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : (0, parseDef_js_1.parseDef)(def.catchall._def, {
5069
+ ...refs,
5070
+ currentPath: [...refs.currentPath, "additionalProperties"]
5071
+ }) ?? true;
5072
+ }
5073
+ }
4797
5074
  function parseObjectDefX(def, refs) {
4798
5075
  Object.keys(def.shape()).reduce((schema, key) => {
4799
5076
  let prop = def.shape()[key];
@@ -4819,10 +5096,7 @@ var require_object = __commonJS({
4819
5096
  }, {
4820
5097
  type: "object",
4821
5098
  properties: {},
4822
- additionalProperties: def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : (0, parseDef_js_1.parseDef)(def.catchall._def, {
4823
- ...refs,
4824
- currentPath: [...refs.currentPath, "additionalProperties"]
4825
- }) ?? true
5099
+ additionalProperties: decideAdditionalProperties(def, refs)
4826
5100
  });
4827
5101
  const result = {
4828
5102
  type: "object",
@@ -4841,10 +5115,7 @@ var require_object = __commonJS({
4841
5115
  required: propDef.isOptional() ? acc.required : [...acc.required, propName]
4842
5116
  };
4843
5117
  }, { properties: {}, required: [] }),
4844
- additionalProperties: def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : (0, parseDef_js_1.parseDef)(def.catchall._def, {
4845
- ...refs,
4846
- currentPath: [...refs.currentPath, "additionalProperties"]
4847
- }) ?? true
5118
+ additionalProperties: decideAdditionalProperties(def, refs)
4848
5119
  };
4849
5120
  if (!result.required.length)
4850
5121
  delete result.required;
@@ -4869,10 +5140,7 @@ var require_object = __commonJS({
4869
5140
  required: propDef.isOptional() ? acc.required : [...acc.required, propName]
4870
5141
  };
4871
5142
  }, { properties: {}, required: [] }),
4872
- additionalProperties: def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : (0, parseDef_js_1.parseDef)(def.catchall._def, {
4873
- ...refs,
4874
- currentPath: [...refs.currentPath, "additionalProperties"]
4875
- }) ?? true
5143
+ additionalProperties: decideAdditionalProperties(def, refs)
4876
5144
  };
4877
5145
  if (!result.required.length)
4878
5146
  delete result.required;
@@ -5099,8 +5367,15 @@ var require_parseDef = __commonJS({
5099
5367
  var union_js_1 = require_union();
5100
5368
  var unknown_js_1 = require_unknown();
5101
5369
  var readonly_js_1 = require_readonly();
5370
+ var Options_js_1 = require_Options();
5102
5371
  function parseDef(def, refs, forceResolution = false) {
5103
5372
  const seenItem = refs.seen.get(def);
5373
+ if (refs.override) {
5374
+ const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
5375
+ if (overrideResult !== Options_js_1.ignoreOverride) {
5376
+ return overrideResult;
5377
+ }
5378
+ }
5104
5379
  if (seenItem && !forceResolution) {
5105
5380
  const seenSchema = get$ref(seenItem, refs);
5106
5381
  if (seenSchema !== void 0) {
@@ -5227,35 +5502,6 @@ var require_parseDef = __commonJS({
5227
5502
  }
5228
5503
  });
5229
5504
 
5230
- // ../../node_modules/zod-to-json-schema/dist/cjs/Refs.js
5231
- var require_Refs = __commonJS({
5232
- "../../node_modules/zod-to-json-schema/dist/cjs/Refs.js"(exports) {
5233
- "use strict";
5234
- Object.defineProperty(exports, "__esModule", { value: true });
5235
- exports.getRefs = void 0;
5236
- var Options_js_1 = require_Options();
5237
- var getRefs = (options) => {
5238
- const _options = (0, Options_js_1.getDefaultOptions)(options);
5239
- const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
5240
- return {
5241
- ..._options,
5242
- currentPath,
5243
- propertyPath: void 0,
5244
- seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
5245
- def._def,
5246
- {
5247
- def: def._def,
5248
- path: [..._options.basePath, _options.definitionPath, name],
5249
- // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
5250
- jsonSchema: void 0
5251
- }
5252
- ]))
5253
- };
5254
- };
5255
- exports.getRefs = getRefs;
5256
- }
5257
- });
5258
-
5259
5505
  // ../../node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js
5260
5506
  var require_zodToJsonSchema = __commonJS({
5261
5507
  "../../node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js"(exports) {
@@ -5328,8 +5574,9 @@ var require_cjs = __commonJS({
5328
5574
  __createBinding(exports2, m, p);
5329
5575
  };
5330
5576
  Object.defineProperty(exports, "__esModule", { value: true });
5331
- __exportStar(require_errorMessages(), exports);
5332
5577
  __exportStar(require_Options(), exports);
5578
+ __exportStar(require_Refs(), exports);
5579
+ __exportStar(require_errorMessages(), exports);
5333
5580
  __exportStar(require_parseDef(), exports);
5334
5581
  __exportStar(require_any(), exports);
5335
5582
  __exportStar(require_array(), exports);
@@ -5361,7 +5608,6 @@ var require_cjs = __commonJS({
5361
5608
  __exportStar(require_undefined(), exports);
5362
5609
  __exportStar(require_union(), exports);
5363
5610
  __exportStar(require_unknown(), exports);
5364
- __exportStar(require_Refs(), exports);
5365
5611
  __exportStar(require_zodToJsonSchema(), exports);
5366
5612
  var zodToJsonSchema_js_1 = require_zodToJsonSchema();
5367
5613
  exports.default = zodToJsonSchema_js_1.zodToJsonSchema;
@@ -5715,7 +5961,7 @@ var quotelessJson = (obj) => {
5715
5961
  const json = JSON.stringify(obj, null, 2);
5716
5962
  return json.replace(/"([^"]+)":/g, "$1:");
5717
5963
  };
5718
- var ZodError = class extends Error {
5964
+ var ZodError = class _ZodError extends Error {
5719
5965
  constructor(issues) {
5720
5966
  super();
5721
5967
  this.issues = [];
@@ -5773,6 +6019,11 @@ var ZodError = class extends Error {
5773
6019
  processError(this);
5774
6020
  return fieldErrors;
5775
6021
  }
6022
+ static assert(value) {
6023
+ if (!(value instanceof _ZodError)) {
6024
+ throw new Error(`Not a ZodError: ${value}`);
6025
+ }
6026
+ }
5776
6027
  toString() {
5777
6028
  return this.message;
5778
6029
  }
@@ -5915,6 +6166,13 @@ var makeIssue = (params) => {
5915
6166
  ...issueData,
5916
6167
  path: fullPath
5917
6168
  };
6169
+ if (issueData.message !== void 0) {
6170
+ return {
6171
+ ...issueData,
6172
+ path: fullPath,
6173
+ message: issueData.message
6174
+ };
6175
+ }
5918
6176
  let errorMessage = "";
5919
6177
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
5920
6178
  for (const map of maps) {
@@ -5923,11 +6181,12 @@ var makeIssue = (params) => {
5923
6181
  return {
5924
6182
  ...issueData,
5925
6183
  path: fullPath,
5926
- message: issueData.message || errorMessage
6184
+ message: errorMessage
5927
6185
  };
5928
6186
  };
5929
6187
  var EMPTY_PATH = [];
5930
6188
  function addIssueToContext(ctx, issueData) {
6189
+ const overrideMap = getErrorMap();
5931
6190
  const issue = makeIssue({
5932
6191
  issueData,
5933
6192
  data: ctx.data,
@@ -5935,8 +6194,8 @@ function addIssueToContext(ctx, issueData) {
5935
6194
  errorMaps: [
5936
6195
  ctx.common.contextualErrorMap,
5937
6196
  ctx.schemaErrorMap,
5938
- getErrorMap(),
5939
- errorMap
6197
+ overrideMap,
6198
+ overrideMap === errorMap ? void 0 : errorMap
5940
6199
  // then global default map
5941
6200
  ].filter((x) => !!x)
5942
6201
  });
@@ -5968,9 +6227,11 @@ var ParseStatus = class _ParseStatus {
5968
6227
  static async mergeObjectAsync(status, pairs) {
5969
6228
  const syncPairs = [];
5970
6229
  for (const pair of pairs) {
6230
+ const key = await pair.key;
6231
+ const value = await pair.value;
5971
6232
  syncPairs.push({
5972
- key: await pair.key,
5973
- value: await pair.value
6233
+ key,
6234
+ value
5974
6235
  });
5975
6236
  }
5976
6237
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -6003,11 +6264,29 @@ var isAborted = (x) => x.status === "aborted";
6003
6264
  var isDirty = (x) => x.status === "dirty";
6004
6265
  var isValid = (x) => x.status === "valid";
6005
6266
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
6267
+ function __classPrivateFieldGet(receiver, state, kind, f) {
6268
+ if (kind === "a" && !f)
6269
+ throw new TypeError("Private accessor was defined without a getter");
6270
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
6271
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
6272
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6273
+ }
6274
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
6275
+ if (kind === "m")
6276
+ throw new TypeError("Private method is not writable");
6277
+ if (kind === "a" && !f)
6278
+ throw new TypeError("Private accessor was defined without a setter");
6279
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
6280
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
6281
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
6282
+ }
6006
6283
  var errorUtil;
6007
6284
  (function(errorUtil2) {
6008
6285
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
6009
6286
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
6010
6287
  })(errorUtil || (errorUtil = {}));
6288
+ var _ZodEnum_cache;
6289
+ var _ZodNativeEnum_cache;
6011
6290
  var ParseInputLazyPath = class {
6012
6291
  constructor(parent, value, path, key) {
6013
6292
  this._cachedPath = [];
@@ -6056,12 +6335,17 @@ function processCreateParams(params) {
6056
6335
  if (errorMap2)
6057
6336
  return { errorMap: errorMap2, description };
6058
6337
  const customMap = (iss, ctx) => {
6059
- if (iss.code !== "invalid_type")
6060
- return { message: ctx.defaultError };
6338
+ var _a, _b;
6339
+ const { message } = params;
6340
+ if (iss.code === "invalid_enum_value") {
6341
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
6342
+ }
6061
6343
  if (typeof ctx.data === "undefined") {
6062
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
6344
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
6063
6345
  }
6064
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
6346
+ if (iss.code !== "invalid_type")
6347
+ return { message: ctx.defaultError };
6348
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
6065
6349
  };
6066
6350
  return { errorMap: customMap, description };
6067
6351
  }
@@ -6309,35 +6593,40 @@ var ZodType = class {
6309
6593
  }
6310
6594
  };
6311
6595
  var cuidRegex = /^c[^\s-]{8,}$/i;
6312
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
6596
+ var cuid2Regex = /^[0-9a-z]+$/;
6313
6597
  var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
6314
6598
  var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
6315
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
6599
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
6600
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
6601
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
6316
6602
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
6317
6603
  var emojiRegex;
6318
- var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
6604
+ var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
6319
6605
  var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
6320
- var datetimeRegex = (args) => {
6606
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
6607
+ var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
6608
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
6609
+ function timeRegexSource(args) {
6610
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
6321
6611
  if (args.precision) {
6322
- if (args.offset) {
6323
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
6324
- } else {
6325
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
6326
- }
6327
- } else if (args.precision === 0) {
6328
- if (args.offset) {
6329
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
6330
- } else {
6331
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
6332
- }
6333
- } else {
6334
- if (args.offset) {
6335
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
6336
- } else {
6337
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
6338
- }
6612
+ regex = `${regex}\\.\\d{${args.precision}}`;
6613
+ } else if (args.precision == null) {
6614
+ regex = `${regex}(\\.\\d+)?`;
6339
6615
  }
6340
- };
6616
+ return regex;
6617
+ }
6618
+ function timeRegex(args) {
6619
+ return new RegExp(`^${timeRegexSource(args)}$`);
6620
+ }
6621
+ function datetimeRegex(args) {
6622
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
6623
+ const opts = [];
6624
+ opts.push(args.local ? `Z?` : `Z`);
6625
+ if (args.offset)
6626
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
6627
+ regex = `${regex}(${opts.join("|")})`;
6628
+ return new RegExp(`^${regex}$`);
6629
+ }
6341
6630
  function isValidIP(ip, version) {
6342
6631
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
6343
6632
  return true;
@@ -6355,15 +6644,11 @@ var ZodString = class _ZodString extends ZodType {
6355
6644
  const parsedType = this._getType(input);
6356
6645
  if (parsedType !== ZodParsedType.string) {
6357
6646
  const ctx2 = this._getOrReturnCtx(input);
6358
- addIssueToContext(
6359
- ctx2,
6360
- {
6361
- code: ZodIssueCode.invalid_type,
6362
- expected: ZodParsedType.string,
6363
- received: ctx2.parsedType
6364
- }
6365
- //
6366
- );
6647
+ addIssueToContext(ctx2, {
6648
+ code: ZodIssueCode.invalid_type,
6649
+ expected: ZodParsedType.string,
6650
+ received: ctx2.parsedType
6651
+ });
6367
6652
  return INVALID;
6368
6653
  }
6369
6654
  const status = new ParseStatus();
@@ -6454,6 +6739,16 @@ var ZodString = class _ZodString extends ZodType {
6454
6739
  });
6455
6740
  status.dirty();
6456
6741
  }
6742
+ } else if (check.kind === "nanoid") {
6743
+ if (!nanoidRegex.test(input.data)) {
6744
+ ctx = this._getOrReturnCtx(input, ctx);
6745
+ addIssueToContext(ctx, {
6746
+ validation: "nanoid",
6747
+ code: ZodIssueCode.invalid_string,
6748
+ message: check.message
6749
+ });
6750
+ status.dirty();
6751
+ }
6457
6752
  } else if (check.kind === "cuid") {
6458
6753
  if (!cuidRegex.test(input.data)) {
6459
6754
  ctx = this._getOrReturnCtx(input, ctx);
@@ -6555,6 +6850,38 @@ var ZodString = class _ZodString extends ZodType {
6555
6850
  });
6556
6851
  status.dirty();
6557
6852
  }
6853
+ } else if (check.kind === "date") {
6854
+ const regex = dateRegex;
6855
+ if (!regex.test(input.data)) {
6856
+ ctx = this._getOrReturnCtx(input, ctx);
6857
+ addIssueToContext(ctx, {
6858
+ code: ZodIssueCode.invalid_string,
6859
+ validation: "date",
6860
+ message: check.message
6861
+ });
6862
+ status.dirty();
6863
+ }
6864
+ } else if (check.kind === "time") {
6865
+ const regex = timeRegex(check);
6866
+ if (!regex.test(input.data)) {
6867
+ ctx = this._getOrReturnCtx(input, ctx);
6868
+ addIssueToContext(ctx, {
6869
+ code: ZodIssueCode.invalid_string,
6870
+ validation: "time",
6871
+ message: check.message
6872
+ });
6873
+ status.dirty();
6874
+ }
6875
+ } else if (check.kind === "duration") {
6876
+ if (!durationRegex.test(input.data)) {
6877
+ ctx = this._getOrReturnCtx(input, ctx);
6878
+ addIssueToContext(ctx, {
6879
+ validation: "duration",
6880
+ code: ZodIssueCode.invalid_string,
6881
+ message: check.message
6882
+ });
6883
+ status.dirty();
6884
+ }
6558
6885
  } else if (check.kind === "ip") {
6559
6886
  if (!isValidIP(input.data, check.version)) {
6560
6887
  ctx = this._getOrReturnCtx(input, ctx);
@@ -6565,6 +6892,16 @@ var ZodString = class _ZodString extends ZodType {
6565
6892
  });
6566
6893
  status.dirty();
6567
6894
  }
6895
+ } else if (check.kind === "base64") {
6896
+ if (!base64Regex.test(input.data)) {
6897
+ ctx = this._getOrReturnCtx(input, ctx);
6898
+ addIssueToContext(ctx, {
6899
+ validation: "base64",
6900
+ code: ZodIssueCode.invalid_string,
6901
+ message: check.message
6902
+ });
6903
+ status.dirty();
6904
+ }
6568
6905
  } else {
6569
6906
  util.assertNever(check);
6570
6907
  }
@@ -6596,6 +6933,9 @@ var ZodString = class _ZodString extends ZodType {
6596
6933
  uuid(message) {
6597
6934
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
6598
6935
  }
6936
+ nanoid(message) {
6937
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
6938
+ }
6599
6939
  cuid(message) {
6600
6940
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
6601
6941
  }
@@ -6605,16 +6945,20 @@ var ZodString = class _ZodString extends ZodType {
6605
6945
  ulid(message) {
6606
6946
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
6607
6947
  }
6948
+ base64(message) {
6949
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
6950
+ }
6608
6951
  ip(options) {
6609
6952
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
6610
6953
  }
6611
6954
  datetime(options) {
6612
- var _a;
6955
+ var _a, _b;
6613
6956
  if (typeof options === "string") {
6614
6957
  return this._addCheck({
6615
6958
  kind: "datetime",
6616
6959
  precision: null,
6617
6960
  offset: false,
6961
+ local: false,
6618
6962
  message: options
6619
6963
  });
6620
6964
  }
@@ -6622,9 +6966,30 @@ var ZodString = class _ZodString extends ZodType {
6622
6966
  kind: "datetime",
6623
6967
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
6624
6968
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
6969
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
6970
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
6971
+ });
6972
+ }
6973
+ date(message) {
6974
+ return this._addCheck({ kind: "date", message });
6975
+ }
6976
+ time(options) {
6977
+ if (typeof options === "string") {
6978
+ return this._addCheck({
6979
+ kind: "time",
6980
+ precision: null,
6981
+ message: options
6982
+ });
6983
+ }
6984
+ return this._addCheck({
6985
+ kind: "time",
6986
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
6625
6987
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
6626
6988
  });
6627
6989
  }
6990
+ duration(message) {
6991
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
6992
+ }
6628
6993
  regex(regex, message) {
6629
6994
  return this._addCheck({
6630
6995
  kind: "regex",
@@ -6703,6 +7068,15 @@ var ZodString = class _ZodString extends ZodType {
6703
7068
  get isDatetime() {
6704
7069
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
6705
7070
  }
7071
+ get isDate() {
7072
+ return !!this._def.checks.find((ch) => ch.kind === "date");
7073
+ }
7074
+ get isTime() {
7075
+ return !!this._def.checks.find((ch) => ch.kind === "time");
7076
+ }
7077
+ get isDuration() {
7078
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
7079
+ }
6706
7080
  get isEmail() {
6707
7081
  return !!this._def.checks.find((ch) => ch.kind === "email");
6708
7082
  }
@@ -6715,6 +7089,9 @@ var ZodString = class _ZodString extends ZodType {
6715
7089
  get isUUID() {
6716
7090
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
6717
7091
  }
7092
+ get isNANOID() {
7093
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
7094
+ }
6718
7095
  get isCUID() {
6719
7096
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
6720
7097
  }
@@ -6727,6 +7104,9 @@ var ZodString = class _ZodString extends ZodType {
6727
7104
  get isIP() {
6728
7105
  return !!this._def.checks.find((ch) => ch.kind === "ip");
6729
7106
  }
7107
+ get isBase64() {
7108
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
7109
+ }
6730
7110
  get minLength() {
6731
7111
  let min = null;
6732
7112
  for (const ch of this._def.checks) {
@@ -7640,9 +8020,10 @@ var ZodObject = class _ZodObject extends ZodType {
7640
8020
  const syncPairs = [];
7641
8021
  for (const pair of pairs) {
7642
8022
  const key = await pair.key;
8023
+ const value = await pair.value;
7643
8024
  syncPairs.push({
7644
8025
  key,
7645
- value: await pair.value,
8026
+ value,
7646
8027
  alwaysSet: pair.alwaysSet
7647
8028
  });
7648
8029
  }
@@ -7993,15 +8374,25 @@ var getDiscriminator = (type) => {
7993
8374
  } else if (type instanceof ZodEnum) {
7994
8375
  return type.options;
7995
8376
  } else if (type instanceof ZodNativeEnum) {
7996
- return Object.keys(type.enum);
8377
+ return util.objectValues(type.enum);
7997
8378
  } else if (type instanceof ZodDefault) {
7998
8379
  return getDiscriminator(type._def.innerType);
7999
8380
  } else if (type instanceof ZodUndefined) {
8000
8381
  return [void 0];
8001
8382
  } else if (type instanceof ZodNull) {
8002
8383
  return [null];
8384
+ } else if (type instanceof ZodOptional) {
8385
+ return [void 0, ...getDiscriminator(type.unwrap())];
8386
+ } else if (type instanceof ZodNullable) {
8387
+ return [null, ...getDiscriminator(type.unwrap())];
8388
+ } else if (type instanceof ZodBranded) {
8389
+ return getDiscriminator(type.unwrap());
8390
+ } else if (type instanceof ZodReadonly) {
8391
+ return getDiscriminator(type.unwrap());
8392
+ } else if (type instanceof ZodCatch) {
8393
+ return getDiscriminator(type._def.innerType);
8003
8394
  } else {
8004
- return null;
8395
+ return [];
8005
8396
  }
8006
8397
  };
8007
8398
  var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -8061,7 +8452,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
8061
8452
  const optionsMap = /* @__PURE__ */ new Map();
8062
8453
  for (const type of options) {
8063
8454
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
8064
- if (!discriminatorValues) {
8455
+ if (!discriminatorValues.length) {
8065
8456
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
8066
8457
  }
8067
8458
  for (const value of discriminatorValues) {
@@ -8261,7 +8652,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
8261
8652
  for (const key in ctx.data) {
8262
8653
  pairs.push({
8263
8654
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
8264
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
8655
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
8656
+ alwaysSet: key in ctx.data
8265
8657
  });
8266
8658
  }
8267
8659
  if (ctx.common.async) {
@@ -8605,6 +8997,10 @@ function createZodEnum(values, params) {
8605
8997
  });
8606
8998
  }
8607
8999
  var ZodEnum = class _ZodEnum extends ZodType {
9000
+ constructor() {
9001
+ super(...arguments);
9002
+ _ZodEnum_cache.set(this, void 0);
9003
+ }
8608
9004
  _parse(input) {
8609
9005
  if (typeof input.data !== "string") {
8610
9006
  const ctx = this._getOrReturnCtx(input);
@@ -8616,7 +9012,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
8616
9012
  });
8617
9013
  return INVALID;
8618
9014
  }
8619
- if (this._def.values.indexOf(input.data) === -1) {
9015
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
9016
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
9017
+ }
9018
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
8620
9019
  const ctx = this._getOrReturnCtx(input);
8621
9020
  const expectedValues = this._def.values;
8622
9021
  addIssueToContext(ctx, {
@@ -8652,15 +9051,26 @@ var ZodEnum = class _ZodEnum extends ZodType {
8652
9051
  }
8653
9052
  return enumValues;
8654
9053
  }
8655
- extract(values) {
8656
- return _ZodEnum.create(values);
9054
+ extract(values, newDef = this._def) {
9055
+ return _ZodEnum.create(values, {
9056
+ ...this._def,
9057
+ ...newDef
9058
+ });
8657
9059
  }
8658
- exclude(values) {
8659
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
9060
+ exclude(values, newDef = this._def) {
9061
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
9062
+ ...this._def,
9063
+ ...newDef
9064
+ });
8660
9065
  }
8661
9066
  };
9067
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
8662
9068
  ZodEnum.create = createZodEnum;
8663
9069
  var ZodNativeEnum = class extends ZodType {
9070
+ constructor() {
9071
+ super(...arguments);
9072
+ _ZodNativeEnum_cache.set(this, void 0);
9073
+ }
8664
9074
  _parse(input) {
8665
9075
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
8666
9076
  const ctx = this._getOrReturnCtx(input);
@@ -8673,7 +9083,10 @@ var ZodNativeEnum = class extends ZodType {
8673
9083
  });
8674
9084
  return INVALID;
8675
9085
  }
8676
- if (nativeEnumValues.indexOf(input.data) === -1) {
9086
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
9087
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
9088
+ }
9089
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
8677
9090
  const expectedValues = util.objectValues(nativeEnumValues);
8678
9091
  addIssueToContext(ctx, {
8679
9092
  received: ctx.data,
@@ -8688,6 +9101,7 @@ var ZodNativeEnum = class extends ZodType {
8688
9101
  return this._def.values;
8689
9102
  }
8690
9103
  };
9104
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
8691
9105
  ZodNativeEnum.create = (values, params) => {
8692
9106
  return new ZodNativeEnum({
8693
9107
  values,
@@ -8751,26 +9165,38 @@ var ZodEffects = class extends ZodType {
8751
9165
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
8752
9166
  if (effect.type === "preprocess") {
8753
9167
  const processed = effect.transform(ctx.data, checkCtx);
8754
- if (ctx.common.issues.length) {
8755
- return {
8756
- status: "dirty",
8757
- value: ctx.data
8758
- };
8759
- }
8760
9168
  if (ctx.common.async) {
8761
- return Promise.resolve(processed).then((processed2) => {
8762
- return this._def.schema._parseAsync({
9169
+ return Promise.resolve(processed).then(async (processed2) => {
9170
+ if (status.value === "aborted")
9171
+ return INVALID;
9172
+ const result = await this._def.schema._parseAsync({
8763
9173
  data: processed2,
8764
9174
  path: ctx.path,
8765
9175
  parent: ctx
8766
9176
  });
9177
+ if (result.status === "aborted")
9178
+ return INVALID;
9179
+ if (result.status === "dirty")
9180
+ return DIRTY(result.value);
9181
+ if (status.value === "dirty")
9182
+ return DIRTY(result.value);
9183
+ return result;
8767
9184
  });
8768
9185
  } else {
8769
- return this._def.schema._parseSync({
9186
+ if (status.value === "aborted")
9187
+ return INVALID;
9188
+ const result = this._def.schema._parseSync({
8770
9189
  data: processed,
8771
9190
  path: ctx.path,
8772
9191
  parent: ctx
8773
9192
  });
9193
+ if (result.status === "aborted")
9194
+ return INVALID;
9195
+ if (result.status === "dirty")
9196
+ return DIRTY(result.value);
9197
+ if (status.value === "dirty")
9198
+ return DIRTY(result.value);
9199
+ return result;
8774
9200
  }
8775
9201
  }
8776
9202
  if (effect.type === "refinement") {
@@ -9059,10 +9485,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
9059
9485
  var ZodReadonly = class extends ZodType {
9060
9486
  _parse(input) {
9061
9487
  const result = this._def.innerType._parse(input);
9062
- if (isValid(result)) {
9063
- result.value = Object.freeze(result.value);
9064
- }
9065
- return result;
9488
+ const freeze = (data) => {
9489
+ if (isValid(data)) {
9490
+ data.value = Object.freeze(data.value);
9491
+ }
9492
+ return data;
9493
+ };
9494
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
9495
+ }
9496
+ unwrap() {
9497
+ return this._def.innerType;
9066
9498
  }
9067
9499
  };
9068
9500
  ZodReadonly.create = (type, params) => {
@@ -9072,7 +9504,7 @@ ZodReadonly.create = (type, params) => {
9072
9504
  ...processCreateParams(params)
9073
9505
  });
9074
9506
  };
9075
- var custom = (check, params = {}, fatal) => {
9507
+ function custom(check, params = {}, fatal) {
9076
9508
  if (check)
9077
9509
  return ZodAny.create().superRefine((data, ctx) => {
9078
9510
  var _a, _b;
@@ -9084,7 +9516,7 @@ var custom = (check, params = {}, fatal) => {
9084
9516
  }
9085
9517
  });
9086
9518
  return ZodAny.create();
9087
- };
9519
+ }
9088
9520
  var late = {
9089
9521
  object: ZodObject.lazycreate
9090
9522
  };
@@ -9203,6 +9635,7 @@ var z = /* @__PURE__ */ Object.freeze({
9203
9635
  ZodParsedType,
9204
9636
  getParsedType,
9205
9637
  ZodType,
9638
+ datetimeRegex,
9206
9639
  ZodString,
9207
9640
  ZodNumber,
9208
9641
  ZodBigInt,