@storm-software/config-tools 1.41.3 → 1.41.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/config-tools",
3
- "version": "1.41.3",
3
+ "version": "1.41.4",
4
4
  "private": false,
5
5
  "description": "⚡The Storm-Ops monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.",
6
6
  "repository": {
@@ -16,7 +16,7 @@
16
16
  "chalk": "5.3.0",
17
17
  "cosmiconfig": "9.0.0",
18
18
  "deepmerge": "4.3.1",
19
- "zod": "3.22.4"
19
+ "zod": "3.23.4"
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public"
@@ -1664,7 +1664,7 @@ var getChalk = () => {
1664
1664
  return _chalk;
1665
1665
  };
1666
1666
 
1667
- // node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
1667
+ // node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs
1668
1668
  var util;
1669
1669
  (function(util2) {
1670
1670
  util2.assertEqual = (val) => val;
@@ -1818,7 +1818,7 @@ var quotelessJson = (obj) => {
1818
1818
  const json = JSON.stringify(obj, null, 2);
1819
1819
  return json.replace(/"([^"]+)":/g, "$1:");
1820
1820
  };
1821
- var ZodError = class extends Error {
1821
+ var ZodError = class _ZodError extends Error {
1822
1822
  constructor(issues) {
1823
1823
  super();
1824
1824
  this.issues = [];
@@ -1876,6 +1876,11 @@ var ZodError = class extends Error {
1876
1876
  processError(this);
1877
1877
  return fieldErrors;
1878
1878
  }
1879
+ static assert(value) {
1880
+ if (!(value instanceof _ZodError)) {
1881
+ throw new Error(`Not a ZodError: ${value}`);
1882
+ }
1883
+ }
1879
1884
  toString() {
1880
1885
  return this.message;
1881
1886
  }
@@ -2018,6 +2023,13 @@ var makeIssue = (params) => {
2018
2023
  ...issueData,
2019
2024
  path: fullPath
2020
2025
  };
2026
+ if (issueData.message !== void 0) {
2027
+ return {
2028
+ ...issueData,
2029
+ path: fullPath,
2030
+ message: issueData.message
2031
+ };
2032
+ }
2021
2033
  let errorMessage = "";
2022
2034
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
2023
2035
  for (const map of maps) {
@@ -2026,11 +2038,12 @@ var makeIssue = (params) => {
2026
2038
  return {
2027
2039
  ...issueData,
2028
2040
  path: fullPath,
2029
- message: issueData.message || errorMessage
2041
+ message: errorMessage
2030
2042
  };
2031
2043
  };
2032
2044
  var EMPTY_PATH = [];
2033
2045
  function addIssueToContext(ctx, issueData) {
2046
+ const overrideMap = getErrorMap();
2034
2047
  const issue = makeIssue({
2035
2048
  issueData,
2036
2049
  data: ctx.data,
@@ -2038,8 +2051,8 @@ function addIssueToContext(ctx, issueData) {
2038
2051
  errorMaps: [
2039
2052
  ctx.common.contextualErrorMap,
2040
2053
  ctx.schemaErrorMap,
2041
- getErrorMap(),
2042
- errorMap
2054
+ overrideMap,
2055
+ overrideMap === errorMap ? void 0 : errorMap
2043
2056
  // then global default map
2044
2057
  ].filter((x) => !!x)
2045
2058
  });
@@ -2071,9 +2084,11 @@ var ParseStatus = class _ParseStatus {
2071
2084
  static async mergeObjectAsync(status, pairs) {
2072
2085
  const syncPairs = [];
2073
2086
  for (const pair of pairs) {
2087
+ const key = await pair.key;
2088
+ const value = await pair.value;
2074
2089
  syncPairs.push({
2075
- key: await pair.key,
2076
- value: await pair.value
2090
+ key,
2091
+ value
2077
2092
  });
2078
2093
  }
2079
2094
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -2106,11 +2121,29 @@ var isAborted = (x) => x.status === "aborted";
2106
2121
  var isDirty = (x) => x.status === "dirty";
2107
2122
  var isValid = (x) => x.status === "valid";
2108
2123
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
2124
+ function __classPrivateFieldGet(receiver, state, kind, f) {
2125
+ if (kind === "a" && !f)
2126
+ throw new TypeError("Private accessor was defined without a getter");
2127
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2128
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2129
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2130
+ }
2131
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
2132
+ if (kind === "m")
2133
+ throw new TypeError("Private method is not writable");
2134
+ if (kind === "a" && !f)
2135
+ throw new TypeError("Private accessor was defined without a setter");
2136
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2137
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
2138
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2139
+ }
2109
2140
  var errorUtil;
2110
2141
  (function(errorUtil2) {
2111
2142
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
2112
2143
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
2113
2144
  })(errorUtil || (errorUtil = {}));
2145
+ var _ZodEnum_cache;
2146
+ var _ZodNativeEnum_cache;
2114
2147
  var ParseInputLazyPath = class {
2115
2148
  constructor(parent, value, path, key) {
2116
2149
  this._cachedPath = [];
@@ -2159,12 +2192,17 @@ function processCreateParams(params) {
2159
2192
  if (errorMap2)
2160
2193
  return { errorMap: errorMap2, description };
2161
2194
  const customMap = (iss, ctx) => {
2162
- if (iss.code !== "invalid_type")
2163
- return { message: ctx.defaultError };
2195
+ var _a, _b;
2196
+ const { message } = params;
2197
+ if (iss.code === "invalid_enum_value") {
2198
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
2199
+ }
2164
2200
  if (typeof ctx.data === "undefined") {
2165
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
2201
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
2166
2202
  }
2167
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
2203
+ if (iss.code !== "invalid_type")
2204
+ return { message: ctx.defaultError };
2205
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
2168
2206
  };
2169
2207
  return { errorMap: customMap, description };
2170
2208
  }
@@ -2412,35 +2450,40 @@ var ZodType = class {
2412
2450
  }
2413
2451
  };
2414
2452
  var cuidRegex = /^c[^\s-]{8,}$/i;
2415
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
2453
+ var cuid2Regex = /^[0-9a-z]+$/;
2416
2454
  var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
2417
2455
  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;
2418
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2456
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
2457
+ 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)?)??$/;
2458
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2419
2459
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
2420
2460
  var emojiRegex;
2421
- 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}))$/;
2461
+ 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])$/;
2422
2462
  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})))$/;
2423
- var datetimeRegex = (args) => {
2463
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
2464
+ 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])))`;
2465
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
2466
+ function timeRegexSource(args) {
2467
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
2424
2468
  if (args.precision) {
2425
- if (args.offset) {
2426
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
2427
- } else {
2428
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
2429
- }
2430
- } else if (args.precision === 0) {
2431
- if (args.offset) {
2432
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
2433
- } else {
2434
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
2435
- }
2436
- } else {
2437
- if (args.offset) {
2438
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
2439
- } else {
2440
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
2441
- }
2469
+ regex = `${regex}\\.\\d{${args.precision}}`;
2470
+ } else if (args.precision == null) {
2471
+ regex = `${regex}(\\.\\d+)?`;
2442
2472
  }
2443
- };
2473
+ return regex;
2474
+ }
2475
+ function timeRegex(args) {
2476
+ return new RegExp(`^${timeRegexSource(args)}$`);
2477
+ }
2478
+ function datetimeRegex(args) {
2479
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
2480
+ const opts = [];
2481
+ opts.push(args.local ? `Z?` : `Z`);
2482
+ if (args.offset)
2483
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
2484
+ regex = `${regex}(${opts.join("|")})`;
2485
+ return new RegExp(`^${regex}$`);
2486
+ }
2444
2487
  function isValidIP(ip, version) {
2445
2488
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
2446
2489
  return true;
@@ -2458,15 +2501,11 @@ var ZodString = class _ZodString extends ZodType {
2458
2501
  const parsedType = this._getType(input);
2459
2502
  if (parsedType !== ZodParsedType.string) {
2460
2503
  const ctx2 = this._getOrReturnCtx(input);
2461
- addIssueToContext(
2462
- ctx2,
2463
- {
2464
- code: ZodIssueCode.invalid_type,
2465
- expected: ZodParsedType.string,
2466
- received: ctx2.parsedType
2467
- }
2468
- //
2469
- );
2504
+ addIssueToContext(ctx2, {
2505
+ code: ZodIssueCode.invalid_type,
2506
+ expected: ZodParsedType.string,
2507
+ received: ctx2.parsedType
2508
+ });
2470
2509
  return INVALID;
2471
2510
  }
2472
2511
  const status = new ParseStatus();
@@ -2557,6 +2596,16 @@ var ZodString = class _ZodString extends ZodType {
2557
2596
  });
2558
2597
  status.dirty();
2559
2598
  }
2599
+ } else if (check.kind === "nanoid") {
2600
+ if (!nanoidRegex.test(input.data)) {
2601
+ ctx = this._getOrReturnCtx(input, ctx);
2602
+ addIssueToContext(ctx, {
2603
+ validation: "nanoid",
2604
+ code: ZodIssueCode.invalid_string,
2605
+ message: check.message
2606
+ });
2607
+ status.dirty();
2608
+ }
2560
2609
  } else if (check.kind === "cuid") {
2561
2610
  if (!cuidRegex.test(input.data)) {
2562
2611
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2658,6 +2707,38 @@ var ZodString = class _ZodString extends ZodType {
2658
2707
  });
2659
2708
  status.dirty();
2660
2709
  }
2710
+ } else if (check.kind === "date") {
2711
+ const regex = dateRegex;
2712
+ if (!regex.test(input.data)) {
2713
+ ctx = this._getOrReturnCtx(input, ctx);
2714
+ addIssueToContext(ctx, {
2715
+ code: ZodIssueCode.invalid_string,
2716
+ validation: "date",
2717
+ message: check.message
2718
+ });
2719
+ status.dirty();
2720
+ }
2721
+ } else if (check.kind === "time") {
2722
+ const regex = timeRegex(check);
2723
+ if (!regex.test(input.data)) {
2724
+ ctx = this._getOrReturnCtx(input, ctx);
2725
+ addIssueToContext(ctx, {
2726
+ code: ZodIssueCode.invalid_string,
2727
+ validation: "time",
2728
+ message: check.message
2729
+ });
2730
+ status.dirty();
2731
+ }
2732
+ } else if (check.kind === "duration") {
2733
+ if (!durationRegex.test(input.data)) {
2734
+ ctx = this._getOrReturnCtx(input, ctx);
2735
+ addIssueToContext(ctx, {
2736
+ validation: "duration",
2737
+ code: ZodIssueCode.invalid_string,
2738
+ message: check.message
2739
+ });
2740
+ status.dirty();
2741
+ }
2661
2742
  } else if (check.kind === "ip") {
2662
2743
  if (!isValidIP(input.data, check.version)) {
2663
2744
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2668,6 +2749,16 @@ var ZodString = class _ZodString extends ZodType {
2668
2749
  });
2669
2750
  status.dirty();
2670
2751
  }
2752
+ } else if (check.kind === "base64") {
2753
+ if (!base64Regex.test(input.data)) {
2754
+ ctx = this._getOrReturnCtx(input, ctx);
2755
+ addIssueToContext(ctx, {
2756
+ validation: "base64",
2757
+ code: ZodIssueCode.invalid_string,
2758
+ message: check.message
2759
+ });
2760
+ status.dirty();
2761
+ }
2671
2762
  } else {
2672
2763
  util.assertNever(check);
2673
2764
  }
@@ -2699,6 +2790,9 @@ var ZodString = class _ZodString extends ZodType {
2699
2790
  uuid(message) {
2700
2791
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2701
2792
  }
2793
+ nanoid(message) {
2794
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2795
+ }
2702
2796
  cuid(message) {
2703
2797
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2704
2798
  }
@@ -2708,16 +2802,20 @@ var ZodString = class _ZodString extends ZodType {
2708
2802
  ulid(message) {
2709
2803
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2710
2804
  }
2805
+ base64(message) {
2806
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2807
+ }
2711
2808
  ip(options) {
2712
2809
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2713
2810
  }
2714
2811
  datetime(options) {
2715
- var _a;
2812
+ var _a, _b;
2716
2813
  if (typeof options === "string") {
2717
2814
  return this._addCheck({
2718
2815
  kind: "datetime",
2719
2816
  precision: null,
2720
2817
  offset: false,
2818
+ local: false,
2721
2819
  message: options
2722
2820
  });
2723
2821
  }
@@ -2725,9 +2823,30 @@ var ZodString = class _ZodString extends ZodType {
2725
2823
  kind: "datetime",
2726
2824
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2727
2825
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2826
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2827
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2828
+ });
2829
+ }
2830
+ date(message) {
2831
+ return this._addCheck({ kind: "date", message });
2832
+ }
2833
+ time(options) {
2834
+ if (typeof options === "string") {
2835
+ return this._addCheck({
2836
+ kind: "time",
2837
+ precision: null,
2838
+ message: options
2839
+ });
2840
+ }
2841
+ return this._addCheck({
2842
+ kind: "time",
2843
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2728
2844
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2729
2845
  });
2730
2846
  }
2847
+ duration(message) {
2848
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2849
+ }
2731
2850
  regex(regex, message) {
2732
2851
  return this._addCheck({
2733
2852
  kind: "regex",
@@ -2806,6 +2925,15 @@ var ZodString = class _ZodString extends ZodType {
2806
2925
  get isDatetime() {
2807
2926
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
2808
2927
  }
2928
+ get isDate() {
2929
+ return !!this._def.checks.find((ch) => ch.kind === "date");
2930
+ }
2931
+ get isTime() {
2932
+ return !!this._def.checks.find((ch) => ch.kind === "time");
2933
+ }
2934
+ get isDuration() {
2935
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
2936
+ }
2809
2937
  get isEmail() {
2810
2938
  return !!this._def.checks.find((ch) => ch.kind === "email");
2811
2939
  }
@@ -2818,6 +2946,9 @@ var ZodString = class _ZodString extends ZodType {
2818
2946
  get isUUID() {
2819
2947
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
2820
2948
  }
2949
+ get isNANOID() {
2950
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2951
+ }
2821
2952
  get isCUID() {
2822
2953
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
2823
2954
  }
@@ -2830,6 +2961,9 @@ var ZodString = class _ZodString extends ZodType {
2830
2961
  get isIP() {
2831
2962
  return !!this._def.checks.find((ch) => ch.kind === "ip");
2832
2963
  }
2964
+ get isBase64() {
2965
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
2966
+ }
2833
2967
  get minLength() {
2834
2968
  let min = null;
2835
2969
  for (const ch of this._def.checks) {
@@ -3743,9 +3877,10 @@ var ZodObject = class _ZodObject extends ZodType {
3743
3877
  const syncPairs = [];
3744
3878
  for (const pair of pairs) {
3745
3879
  const key = await pair.key;
3880
+ const value = await pair.value;
3746
3881
  syncPairs.push({
3747
3882
  key,
3748
- value: await pair.value,
3883
+ value,
3749
3884
  alwaysSet: pair.alwaysSet
3750
3885
  });
3751
3886
  }
@@ -4096,15 +4231,25 @@ var getDiscriminator = (type) => {
4096
4231
  } else if (type instanceof ZodEnum) {
4097
4232
  return type.options;
4098
4233
  } else if (type instanceof ZodNativeEnum) {
4099
- return Object.keys(type.enum);
4234
+ return util.objectValues(type.enum);
4100
4235
  } else if (type instanceof ZodDefault) {
4101
4236
  return getDiscriminator(type._def.innerType);
4102
4237
  } else if (type instanceof ZodUndefined) {
4103
4238
  return [void 0];
4104
4239
  } else if (type instanceof ZodNull) {
4105
4240
  return [null];
4241
+ } else if (type instanceof ZodOptional) {
4242
+ return [void 0, ...getDiscriminator(type.unwrap())];
4243
+ } else if (type instanceof ZodNullable) {
4244
+ return [null, ...getDiscriminator(type.unwrap())];
4245
+ } else if (type instanceof ZodBranded) {
4246
+ return getDiscriminator(type.unwrap());
4247
+ } else if (type instanceof ZodReadonly) {
4248
+ return getDiscriminator(type.unwrap());
4249
+ } else if (type instanceof ZodCatch) {
4250
+ return getDiscriminator(type._def.innerType);
4106
4251
  } else {
4107
- return null;
4252
+ return [];
4108
4253
  }
4109
4254
  };
4110
4255
  var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -4164,7 +4309,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
4164
4309
  const optionsMap = /* @__PURE__ */ new Map();
4165
4310
  for (const type of options) {
4166
4311
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
4167
- if (!discriminatorValues) {
4312
+ if (!discriminatorValues.length) {
4168
4313
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
4169
4314
  }
4170
4315
  for (const value of discriminatorValues) {
@@ -4364,7 +4509,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
4364
4509
  for (const key in ctx.data) {
4365
4510
  pairs.push({
4366
4511
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
4367
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
4512
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
4513
+ alwaysSet: key in ctx.data
4368
4514
  });
4369
4515
  }
4370
4516
  if (ctx.common.async) {
@@ -4708,6 +4854,10 @@ function createZodEnum(values, params) {
4708
4854
  });
4709
4855
  }
4710
4856
  var ZodEnum = class _ZodEnum extends ZodType {
4857
+ constructor() {
4858
+ super(...arguments);
4859
+ _ZodEnum_cache.set(this, void 0);
4860
+ }
4711
4861
  _parse(input) {
4712
4862
  if (typeof input.data !== "string") {
4713
4863
  const ctx = this._getOrReturnCtx(input);
@@ -4719,7 +4869,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
4719
4869
  });
4720
4870
  return INVALID;
4721
4871
  }
4722
- if (this._def.values.indexOf(input.data) === -1) {
4872
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
4873
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
4874
+ }
4875
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
4723
4876
  const ctx = this._getOrReturnCtx(input);
4724
4877
  const expectedValues = this._def.values;
4725
4878
  addIssueToContext(ctx, {
@@ -4755,15 +4908,26 @@ var ZodEnum = class _ZodEnum extends ZodType {
4755
4908
  }
4756
4909
  return enumValues;
4757
4910
  }
4758
- extract(values) {
4759
- return _ZodEnum.create(values);
4911
+ extract(values, newDef = this._def) {
4912
+ return _ZodEnum.create(values, {
4913
+ ...this._def,
4914
+ ...newDef
4915
+ });
4760
4916
  }
4761
- exclude(values) {
4762
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
4917
+ exclude(values, newDef = this._def) {
4918
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4919
+ ...this._def,
4920
+ ...newDef
4921
+ });
4763
4922
  }
4764
4923
  };
4924
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
4765
4925
  ZodEnum.create = createZodEnum;
4766
4926
  var ZodNativeEnum = class extends ZodType {
4927
+ constructor() {
4928
+ super(...arguments);
4929
+ _ZodNativeEnum_cache.set(this, void 0);
4930
+ }
4767
4931
  _parse(input) {
4768
4932
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
4769
4933
  const ctx = this._getOrReturnCtx(input);
@@ -4776,7 +4940,10 @@ var ZodNativeEnum = class extends ZodType {
4776
4940
  });
4777
4941
  return INVALID;
4778
4942
  }
4779
- if (nativeEnumValues.indexOf(input.data) === -1) {
4943
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
4944
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
4945
+ }
4946
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
4780
4947
  const expectedValues = util.objectValues(nativeEnumValues);
4781
4948
  addIssueToContext(ctx, {
4782
4949
  received: ctx.data,
@@ -4791,6 +4958,7 @@ var ZodNativeEnum = class extends ZodType {
4791
4958
  return this._def.values;
4792
4959
  }
4793
4960
  };
4961
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
4794
4962
  ZodNativeEnum.create = (values, params) => {
4795
4963
  return new ZodNativeEnum({
4796
4964
  values,
@@ -4854,26 +5022,38 @@ var ZodEffects = class extends ZodType {
4854
5022
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4855
5023
  if (effect.type === "preprocess") {
4856
5024
  const processed = effect.transform(ctx.data, checkCtx);
4857
- if (ctx.common.issues.length) {
4858
- return {
4859
- status: "dirty",
4860
- value: ctx.data
4861
- };
4862
- }
4863
5025
  if (ctx.common.async) {
4864
- return Promise.resolve(processed).then((processed2) => {
4865
- return this._def.schema._parseAsync({
5026
+ return Promise.resolve(processed).then(async (processed2) => {
5027
+ if (status.value === "aborted")
5028
+ return INVALID;
5029
+ const result = await this._def.schema._parseAsync({
4866
5030
  data: processed2,
4867
5031
  path: ctx.path,
4868
5032
  parent: ctx
4869
5033
  });
5034
+ if (result.status === "aborted")
5035
+ return INVALID;
5036
+ if (result.status === "dirty")
5037
+ return DIRTY(result.value);
5038
+ if (status.value === "dirty")
5039
+ return DIRTY(result.value);
5040
+ return result;
4870
5041
  });
4871
5042
  } else {
4872
- return this._def.schema._parseSync({
5043
+ if (status.value === "aborted")
5044
+ return INVALID;
5045
+ const result = this._def.schema._parseSync({
4873
5046
  data: processed,
4874
5047
  path: ctx.path,
4875
5048
  parent: ctx
4876
5049
  });
5050
+ if (result.status === "aborted")
5051
+ return INVALID;
5052
+ if (result.status === "dirty")
5053
+ return DIRTY(result.value);
5054
+ if (status.value === "dirty")
5055
+ return DIRTY(result.value);
5056
+ return result;
4877
5057
  }
4878
5058
  }
4879
5059
  if (effect.type === "refinement") {
@@ -5167,6 +5347,9 @@ var ZodReadonly = class extends ZodType {
5167
5347
  }
5168
5348
  return result;
5169
5349
  }
5350
+ unwrap() {
5351
+ return this._def.innerType;
5352
+ }
5170
5353
  };
5171
5354
  ZodReadonly.create = (type, params) => {
5172
5355
  return new ZodReadonly({
@@ -5175,7 +5358,7 @@ ZodReadonly.create = (type, params) => {
5175
5358
  ...processCreateParams(params)
5176
5359
  });
5177
5360
  };
5178
- var custom = (check, params = {}, fatal) => {
5361
+ function custom(check, params = {}, fatal) {
5179
5362
  if (check)
5180
5363
  return ZodAny.create().superRefine((data, ctx) => {
5181
5364
  var _a, _b;
@@ -5187,7 +5370,7 @@ var custom = (check, params = {}, fatal) => {
5187
5370
  }
5188
5371
  });
5189
5372
  return ZodAny.create();
5190
- };
5373
+ }
5191
5374
  var late = {
5192
5375
  object: ZodObject.lazycreate
5193
5376
  };
@@ -5306,6 +5489,7 @@ var z = /* @__PURE__ */ Object.freeze({
5306
5489
  ZodParsedType,
5307
5490
  getParsedType,
5308
5491
  ZodType,
5492
+ datetimeRegex,
5309
5493
  ZodString,
5310
5494
  ZodNumber,
5311
5495
  ZodBigInt,
@@ -5570,7 +5754,6 @@ var getLogFn = (logLevel = LogLevel.INFO, config = {}) => {
5570
5754
  ${_chalk.bold.hex(colors.error ?? "#f85149")(">")} ${_chalk.bold.bgHex(colors.fatal ?? "#b62324").whiteBright(
5571
5755
  " \u{1F480} Fatal "
5572
5756
  )} ${_chalk.hex(colors.error ?? "#f85149")(formatLogMessage(message))}
5573
-
5574
5757
  `
5575
5758
  );
5576
5759
  };
@@ -5663,10 +5846,10 @@ var getStopwatch = (name) => {
5663
5846
  };
5664
5847
  };
5665
5848
  var formatLogMessage = (message, prefix = "-") => {
5666
- return `
5667
- ${typeof message === "string" ? message : typeof message === "object" ? Object.keys(message).map(
5849
+ return typeof message === "string" ? message : typeof message === "object" ? `
5850
+ ${Object.keys(message).map(
5668
5851
  (key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(message[key], `${prefix}-`) : message[key]}`
5669
- ).join("\n") : message}`;
5852
+ ).join("\n")}` : message;
5670
5853
  };
5671
5854
  var _isFunction = (value) => {
5672
5855
  try {