@wise/dynamic-flow-types 2.15.1 → 2.15.2

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/build/main.js CHANGED
@@ -43,7 +43,7 @@ __export(src_exports, {
43
43
  });
44
44
  module.exports = __toCommonJS(src_exports);
45
45
 
46
- // ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
46
+ // ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
47
47
  var util;
48
48
  (function(util2) {
49
49
  util2.assertEqual = (val) => val;
@@ -193,7 +193,7 @@ var quotelessJson = (obj) => {
193
193
  const json = JSON.stringify(obj, null, 2);
194
194
  return json.replace(/"([^"]+)":/g, "$1:");
195
195
  };
196
- var ZodError = class extends Error {
196
+ var ZodError = class _ZodError extends Error {
197
197
  constructor(issues) {
198
198
  super();
199
199
  this.issues = [];
@@ -251,6 +251,11 @@ var ZodError = class extends Error {
251
251
  processError(this);
252
252
  return fieldErrors;
253
253
  }
254
+ static assert(value) {
255
+ if (!(value instanceof _ZodError)) {
256
+ throw new Error(`Not a ZodError: ${value}`);
257
+ }
258
+ }
254
259
  toString() {
255
260
  return this.message;
256
261
  }
@@ -392,6 +397,12 @@ var makeIssue = (params) => {
392
397
  const fullIssue = __spreadProps(__spreadValues({}, issueData), {
393
398
  path: fullPath
394
399
  });
400
+ if (issueData.message !== void 0) {
401
+ return __spreadProps(__spreadValues({}, issueData), {
402
+ path: fullPath,
403
+ message: issueData.message
404
+ });
405
+ }
395
406
  let errorMessage = "";
396
407
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
397
408
  for (const map of maps) {
@@ -399,11 +410,12 @@ var makeIssue = (params) => {
399
410
  }
400
411
  return __spreadProps(__spreadValues({}, issueData), {
401
412
  path: fullPath,
402
- message: issueData.message || errorMessage
413
+ message: errorMessage
403
414
  });
404
415
  };
405
416
  var EMPTY_PATH = [];
406
417
  function addIssueToContext(ctx, issueData) {
418
+ const overrideMap = getErrorMap();
407
419
  const issue = makeIssue({
408
420
  issueData,
409
421
  data: ctx.data,
@@ -411,8 +423,8 @@ function addIssueToContext(ctx, issueData) {
411
423
  errorMaps: [
412
424
  ctx.common.contextualErrorMap,
413
425
  ctx.schemaErrorMap,
414
- getErrorMap(),
415
- errorMap
426
+ overrideMap,
427
+ overrideMap === errorMap ? void 0 : errorMap
416
428
  // then global default map
417
429
  ].filter((x) => !!x)
418
430
  });
@@ -444,9 +456,11 @@ var ParseStatus = class _ParseStatus {
444
456
  static async mergeObjectAsync(status, pairs) {
445
457
  const syncPairs = [];
446
458
  for (const pair of pairs) {
459
+ const key = await pair.key;
460
+ const value = await pair.value;
447
461
  syncPairs.push({
448
- key: await pair.key,
449
- value: await pair.value
462
+ key,
463
+ value
450
464
  });
451
465
  }
452
466
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -479,11 +493,29 @@ var isAborted = (x) => x.status === "aborted";
479
493
  var isDirty = (x) => x.status === "dirty";
480
494
  var isValid = (x) => x.status === "valid";
481
495
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
496
+ function __classPrivateFieldGet(receiver, state, kind, f) {
497
+ if (kind === "a" && !f)
498
+ throw new TypeError("Private accessor was defined without a getter");
499
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
500
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
501
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
502
+ }
503
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
504
+ if (kind === "m")
505
+ throw new TypeError("Private method is not writable");
506
+ if (kind === "a" && !f)
507
+ throw new TypeError("Private accessor was defined without a setter");
508
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
509
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
510
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
511
+ }
482
512
  var errorUtil;
483
513
  (function(errorUtil2) {
484
514
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
485
515
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
486
516
  })(errorUtil || (errorUtil = {}));
517
+ var _ZodEnum_cache;
518
+ var _ZodNativeEnum_cache;
487
519
  var ParseInputLazyPath = class {
488
520
  constructor(parent, value, path, key) {
489
521
  this._cachedPath = [];
@@ -532,12 +564,17 @@ function processCreateParams(params) {
532
564
  if (errorMap2)
533
565
  return { errorMap: errorMap2, description };
534
566
  const customMap = (iss, ctx) => {
535
- if (iss.code !== "invalid_type")
536
- return { message: ctx.defaultError };
567
+ var _a, _b;
568
+ const { message } = params;
569
+ if (iss.code === "invalid_enum_value") {
570
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
571
+ }
537
572
  if (typeof ctx.data === "undefined") {
538
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
573
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
539
574
  }
540
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
575
+ if (iss.code !== "invalid_type")
576
+ return { message: ctx.defaultError };
577
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
541
578
  };
542
579
  return { errorMap: customMap, description };
543
580
  }
@@ -779,35 +816,40 @@ var ZodType = class {
779
816
  }
780
817
  };
781
818
  var cuidRegex = /^c[^\s-]{8,}$/i;
782
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
819
+ var cuid2Regex = /^[0-9a-z]+$/;
783
820
  var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
784
821
  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;
785
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
822
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
823
+ 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)?)??$/;
824
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
786
825
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
787
826
  var emojiRegex;
788
- 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}))$/;
827
+ 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])$/;
789
828
  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})))$/;
790
- var datetimeRegex = (args) => {
829
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
830
+ 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])))`;
831
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
832
+ function timeRegexSource(args) {
833
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
791
834
  if (args.precision) {
792
- if (args.offset) {
793
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
794
- } else {
795
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
796
- }
797
- } else if (args.precision === 0) {
798
- if (args.offset) {
799
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
800
- } else {
801
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
802
- }
803
- } else {
804
- if (args.offset) {
805
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
806
- } else {
807
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
808
- }
835
+ regex = `${regex}\\.\\d{${args.precision}}`;
836
+ } else if (args.precision == null) {
837
+ regex = `${regex}(\\.\\d+)?`;
809
838
  }
810
- };
839
+ return regex;
840
+ }
841
+ function timeRegex(args) {
842
+ return new RegExp(`^${timeRegexSource(args)}$`);
843
+ }
844
+ function datetimeRegex(args) {
845
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
846
+ const opts = [];
847
+ opts.push(args.local ? `Z?` : `Z`);
848
+ if (args.offset)
849
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
850
+ regex = `${regex}(${opts.join("|")})`;
851
+ return new RegExp(`^${regex}$`);
852
+ }
811
853
  function isValidIP(ip, version) {
812
854
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
813
855
  return true;
@@ -825,15 +867,11 @@ var ZodString = class _ZodString extends ZodType {
825
867
  const parsedType = this._getType(input);
826
868
  if (parsedType !== ZodParsedType.string) {
827
869
  const ctx2 = this._getOrReturnCtx(input);
828
- addIssueToContext(
829
- ctx2,
830
- {
831
- code: ZodIssueCode.invalid_type,
832
- expected: ZodParsedType.string,
833
- received: ctx2.parsedType
834
- }
835
- //
836
- );
870
+ addIssueToContext(ctx2, {
871
+ code: ZodIssueCode.invalid_type,
872
+ expected: ZodParsedType.string,
873
+ received: ctx2.parsedType
874
+ });
837
875
  return INVALID;
838
876
  }
839
877
  const status = new ParseStatus();
@@ -924,6 +962,16 @@ var ZodString = class _ZodString extends ZodType {
924
962
  });
925
963
  status.dirty();
926
964
  }
965
+ } else if (check.kind === "nanoid") {
966
+ if (!nanoidRegex.test(input.data)) {
967
+ ctx = this._getOrReturnCtx(input, ctx);
968
+ addIssueToContext(ctx, {
969
+ validation: "nanoid",
970
+ code: ZodIssueCode.invalid_string,
971
+ message: check.message
972
+ });
973
+ status.dirty();
974
+ }
927
975
  } else if (check.kind === "cuid") {
928
976
  if (!cuidRegex.test(input.data)) {
929
977
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1025,6 +1073,38 @@ var ZodString = class _ZodString extends ZodType {
1025
1073
  });
1026
1074
  status.dirty();
1027
1075
  }
1076
+ } else if (check.kind === "date") {
1077
+ const regex = dateRegex;
1078
+ if (!regex.test(input.data)) {
1079
+ ctx = this._getOrReturnCtx(input, ctx);
1080
+ addIssueToContext(ctx, {
1081
+ code: ZodIssueCode.invalid_string,
1082
+ validation: "date",
1083
+ message: check.message
1084
+ });
1085
+ status.dirty();
1086
+ }
1087
+ } else if (check.kind === "time") {
1088
+ const regex = timeRegex(check);
1089
+ if (!regex.test(input.data)) {
1090
+ ctx = this._getOrReturnCtx(input, ctx);
1091
+ addIssueToContext(ctx, {
1092
+ code: ZodIssueCode.invalid_string,
1093
+ validation: "time",
1094
+ message: check.message
1095
+ });
1096
+ status.dirty();
1097
+ }
1098
+ } else if (check.kind === "duration") {
1099
+ if (!durationRegex.test(input.data)) {
1100
+ ctx = this._getOrReturnCtx(input, ctx);
1101
+ addIssueToContext(ctx, {
1102
+ validation: "duration",
1103
+ code: ZodIssueCode.invalid_string,
1104
+ message: check.message
1105
+ });
1106
+ status.dirty();
1107
+ }
1028
1108
  } else if (check.kind === "ip") {
1029
1109
  if (!isValidIP(input.data, check.version)) {
1030
1110
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1035,6 +1115,16 @@ var ZodString = class _ZodString extends ZodType {
1035
1115
  });
1036
1116
  status.dirty();
1037
1117
  }
1118
+ } else if (check.kind === "base64") {
1119
+ if (!base64Regex.test(input.data)) {
1120
+ ctx = this._getOrReturnCtx(input, ctx);
1121
+ addIssueToContext(ctx, {
1122
+ validation: "base64",
1123
+ code: ZodIssueCode.invalid_string,
1124
+ message: check.message
1125
+ });
1126
+ status.dirty();
1127
+ }
1038
1128
  } else {
1039
1129
  util.assertNever(check);
1040
1130
  }
@@ -1064,6 +1154,9 @@ var ZodString = class _ZodString extends ZodType {
1064
1154
  uuid(message) {
1065
1155
  return this._addCheck(__spreadValues({ kind: "uuid" }, errorUtil.errToObj(message)));
1066
1156
  }
1157
+ nanoid(message) {
1158
+ return this._addCheck(__spreadValues({ kind: "nanoid" }, errorUtil.errToObj(message)));
1159
+ }
1067
1160
  cuid(message) {
1068
1161
  return this._addCheck(__spreadValues({ kind: "cuid" }, errorUtil.errToObj(message)));
1069
1162
  }
@@ -1073,25 +1166,49 @@ var ZodString = class _ZodString extends ZodType {
1073
1166
  ulid(message) {
1074
1167
  return this._addCheck(__spreadValues({ kind: "ulid" }, errorUtil.errToObj(message)));
1075
1168
  }
1169
+ base64(message) {
1170
+ return this._addCheck(__spreadValues({ kind: "base64" }, errorUtil.errToObj(message)));
1171
+ }
1076
1172
  ip(options) {
1077
1173
  return this._addCheck(__spreadValues({ kind: "ip" }, errorUtil.errToObj(options)));
1078
1174
  }
1079
1175
  datetime(options) {
1080
- var _a;
1176
+ var _a, _b;
1081
1177
  if (typeof options === "string") {
1082
1178
  return this._addCheck({
1083
1179
  kind: "datetime",
1084
1180
  precision: null,
1085
1181
  offset: false,
1182
+ local: false,
1086
1183
  message: options
1087
1184
  });
1088
1185
  }
1089
1186
  return this._addCheck(__spreadValues({
1090
1187
  kind: "datetime",
1091
1188
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1092
- offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false
1189
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1190
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false
1191
+ }, errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)));
1192
+ }
1193
+ date(message) {
1194
+ return this._addCheck({ kind: "date", message });
1195
+ }
1196
+ time(options) {
1197
+ if (typeof options === "string") {
1198
+ return this._addCheck({
1199
+ kind: "time",
1200
+ precision: null,
1201
+ message: options
1202
+ });
1203
+ }
1204
+ return this._addCheck(__spreadValues({
1205
+ kind: "time",
1206
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision
1093
1207
  }, errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)));
1094
1208
  }
1209
+ duration(message) {
1210
+ return this._addCheck(__spreadValues({ kind: "duration" }, errorUtil.errToObj(message)));
1211
+ }
1095
1212
  regex(regex, message) {
1096
1213
  return this._addCheck(__spreadValues({
1097
1214
  kind: "regex",
@@ -1160,6 +1277,15 @@ var ZodString = class _ZodString extends ZodType {
1160
1277
  get isDatetime() {
1161
1278
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
1162
1279
  }
1280
+ get isDate() {
1281
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1282
+ }
1283
+ get isTime() {
1284
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1285
+ }
1286
+ get isDuration() {
1287
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1288
+ }
1163
1289
  get isEmail() {
1164
1290
  return !!this._def.checks.find((ch) => ch.kind === "email");
1165
1291
  }
@@ -1172,6 +1298,9 @@ var ZodString = class _ZodString extends ZodType {
1172
1298
  get isUUID() {
1173
1299
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
1174
1300
  }
1301
+ get isNANOID() {
1302
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1303
+ }
1175
1304
  get isCUID() {
1176
1305
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1177
1306
  }
@@ -1184,6 +1313,9 @@ var ZodString = class _ZodString extends ZodType {
1184
1313
  get isIP() {
1185
1314
  return !!this._def.checks.find((ch) => ch.kind === "ip");
1186
1315
  }
1316
+ get isBase64() {
1317
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1318
+ }
1187
1319
  get minLength() {
1188
1320
  let min = null;
1189
1321
  for (const ch of this._def.checks) {
@@ -2074,9 +2206,10 @@ var ZodObject = class _ZodObject extends ZodType {
2074
2206
  const syncPairs = [];
2075
2207
  for (const pair of pairs) {
2076
2208
  const key = await pair.key;
2209
+ const value = await pair.value;
2077
2210
  syncPairs.push({
2078
2211
  key,
2079
- value: await pair.value,
2212
+ value,
2080
2213
  alwaysSet: pair.alwaysSet
2081
2214
  });
2082
2215
  }
@@ -2403,15 +2536,25 @@ var getDiscriminator = (type) => {
2403
2536
  } else if (type instanceof ZodEnum) {
2404
2537
  return type.options;
2405
2538
  } else if (type instanceof ZodNativeEnum) {
2406
- return Object.keys(type.enum);
2539
+ return util.objectValues(type.enum);
2407
2540
  } else if (type instanceof ZodDefault) {
2408
2541
  return getDiscriminator(type._def.innerType);
2409
2542
  } else if (type instanceof ZodUndefined) {
2410
2543
  return [void 0];
2411
2544
  } else if (type instanceof ZodNull) {
2412
2545
  return [null];
2546
+ } else if (type instanceof ZodOptional) {
2547
+ return [void 0, ...getDiscriminator(type.unwrap())];
2548
+ } else if (type instanceof ZodNullable) {
2549
+ return [null, ...getDiscriminator(type.unwrap())];
2550
+ } else if (type instanceof ZodBranded) {
2551
+ return getDiscriminator(type.unwrap());
2552
+ } else if (type instanceof ZodReadonly) {
2553
+ return getDiscriminator(type.unwrap());
2554
+ } else if (type instanceof ZodCatch) {
2555
+ return getDiscriminator(type._def.innerType);
2413
2556
  } else {
2414
- return null;
2557
+ return [];
2415
2558
  }
2416
2559
  };
2417
2560
  var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -2471,7 +2614,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2471
2614
  const optionsMap = /* @__PURE__ */ new Map();
2472
2615
  for (const type of options) {
2473
2616
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2474
- if (!discriminatorValues) {
2617
+ if (!discriminatorValues.length) {
2475
2618
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2476
2619
  }
2477
2620
  for (const value of discriminatorValues) {
@@ -2667,7 +2810,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
2667
2810
  for (const key in ctx.data) {
2668
2811
  pairs.push({
2669
2812
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2670
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
2813
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2814
+ alwaysSet: key in ctx.data
2671
2815
  });
2672
2816
  }
2673
2817
  if (ctx.common.async) {
@@ -2999,6 +3143,10 @@ function createZodEnum(values, params) {
2999
3143
  }, processCreateParams(params)));
3000
3144
  }
3001
3145
  var ZodEnum = class _ZodEnum extends ZodType {
3146
+ constructor() {
3147
+ super(...arguments);
3148
+ _ZodEnum_cache.set(this, void 0);
3149
+ }
3002
3150
  _parse(input) {
3003
3151
  if (typeof input.data !== "string") {
3004
3152
  const ctx = this._getOrReturnCtx(input);
@@ -3010,7 +3158,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
3010
3158
  });
3011
3159
  return INVALID;
3012
3160
  }
3013
- if (this._def.values.indexOf(input.data) === -1) {
3161
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3162
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3163
+ }
3164
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3014
3165
  const ctx = this._getOrReturnCtx(input);
3015
3166
  const expectedValues = this._def.values;
3016
3167
  addIssueToContext(ctx, {
@@ -3046,15 +3197,20 @@ var ZodEnum = class _ZodEnum extends ZodType {
3046
3197
  }
3047
3198
  return enumValues;
3048
3199
  }
3049
- extract(values) {
3050
- return _ZodEnum.create(values);
3200
+ extract(values, newDef = this._def) {
3201
+ return _ZodEnum.create(values, __spreadValues(__spreadValues({}, this._def), newDef));
3051
3202
  }
3052
- exclude(values) {
3053
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3203
+ exclude(values, newDef = this._def) {
3204
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), __spreadValues(__spreadValues({}, this._def), newDef));
3054
3205
  }
3055
3206
  };
3207
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3056
3208
  ZodEnum.create = createZodEnum;
3057
3209
  var ZodNativeEnum = class extends ZodType {
3210
+ constructor() {
3211
+ super(...arguments);
3212
+ _ZodNativeEnum_cache.set(this, void 0);
3213
+ }
3058
3214
  _parse(input) {
3059
3215
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3060
3216
  const ctx = this._getOrReturnCtx(input);
@@ -3067,7 +3223,10 @@ var ZodNativeEnum = class extends ZodType {
3067
3223
  });
3068
3224
  return INVALID;
3069
3225
  }
3070
- if (nativeEnumValues.indexOf(input.data) === -1) {
3226
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3227
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3228
+ }
3229
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3071
3230
  const expectedValues = util.objectValues(nativeEnumValues);
3072
3231
  addIssueToContext(ctx, {
3073
3232
  received: ctx.data,
@@ -3082,6 +3241,7 @@ var ZodNativeEnum = class extends ZodType {
3082
3241
  return this._def.values;
3083
3242
  }
3084
3243
  };
3244
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3085
3245
  ZodNativeEnum.create = (values, params) => {
3086
3246
  return new ZodNativeEnum(__spreadValues({
3087
3247
  values,
@@ -3143,26 +3303,38 @@ var ZodEffects = class extends ZodType {
3143
3303
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3144
3304
  if (effect.type === "preprocess") {
3145
3305
  const processed = effect.transform(ctx.data, checkCtx);
3146
- if (ctx.common.issues.length) {
3147
- return {
3148
- status: "dirty",
3149
- value: ctx.data
3150
- };
3151
- }
3152
3306
  if (ctx.common.async) {
3153
- return Promise.resolve(processed).then((processed2) => {
3154
- return this._def.schema._parseAsync({
3307
+ return Promise.resolve(processed).then(async (processed2) => {
3308
+ if (status.value === "aborted")
3309
+ return INVALID;
3310
+ const result = await this._def.schema._parseAsync({
3155
3311
  data: processed2,
3156
3312
  path: ctx.path,
3157
3313
  parent: ctx
3158
3314
  });
3315
+ if (result.status === "aborted")
3316
+ return INVALID;
3317
+ if (result.status === "dirty")
3318
+ return DIRTY(result.value);
3319
+ if (status.value === "dirty")
3320
+ return DIRTY(result.value);
3321
+ return result;
3159
3322
  });
3160
3323
  } else {
3161
- return this._def.schema._parseSync({
3324
+ if (status.value === "aborted")
3325
+ return INVALID;
3326
+ const result = this._def.schema._parseSync({
3162
3327
  data: processed,
3163
3328
  path: ctx.path,
3164
3329
  parent: ctx
3165
3330
  });
3331
+ if (result.status === "aborted")
3332
+ return INVALID;
3333
+ if (result.status === "dirty")
3334
+ return DIRTY(result.value);
3335
+ if (status.value === "dirty")
3336
+ return DIRTY(result.value);
3337
+ return result;
3166
3338
  }
3167
3339
  }
3168
3340
  if (effect.type === "refinement") {
@@ -3440,10 +3612,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
3440
3612
  var ZodReadonly = class extends ZodType {
3441
3613
  _parse(input) {
3442
3614
  const result = this._def.innerType._parse(input);
3443
- if (isValid(result)) {
3444
- result.value = Object.freeze(result.value);
3445
- }
3446
- return result;
3615
+ const freeze = (data) => {
3616
+ if (isValid(data)) {
3617
+ data.value = Object.freeze(data.value);
3618
+ }
3619
+ return data;
3620
+ };
3621
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3622
+ }
3623
+ unwrap() {
3624
+ return this._def.innerType;
3447
3625
  }
3448
3626
  };
3449
3627
  ZodReadonly.create = (type, params) => {
@@ -3452,7 +3630,7 @@ ZodReadonly.create = (type, params) => {
3452
3630
  typeName: ZodFirstPartyTypeKind.ZodReadonly
3453
3631
  }, processCreateParams(params)));
3454
3632
  };
3455
- var custom = (check, params = {}, fatal) => {
3633
+ function custom(check, params = {}, fatal) {
3456
3634
  if (check)
3457
3635
  return ZodAny.create().superRefine((data, ctx) => {
3458
3636
  var _a, _b;
@@ -3464,7 +3642,7 @@ var custom = (check, params = {}, fatal) => {
3464
3642
  }
3465
3643
  });
3466
3644
  return ZodAny.create();
3467
- };
3645
+ }
3468
3646
  var late = {
3469
3647
  object: ZodObject.lazycreate
3470
3648
  };
@@ -3582,6 +3760,7 @@ var z = /* @__PURE__ */ Object.freeze({
3582
3760
  ZodParsedType,
3583
3761
  getParsedType,
3584
3762
  ZodType,
3763
+ datetimeRegex,
3585
3764
  ZodString,
3586
3765
  ZodNumber,
3587
3766
  ZodBigInt,