drizzle-kit 0.20.17-b08243d → 0.20.17-b4f119e

Sign up to get free protection for your applications and to get access to all the features.
package/payload.mjs CHANGED
@@ -40,7 +40,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
40
40
  ));
41
41
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
42
 
43
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
43
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
44
44
  function assembleStyles() {
45
45
  const codes = /* @__PURE__ */ new Map();
46
46
  for (const [groupName, group] of Object.entries(styles)) {
@@ -157,7 +157,7 @@ function assembleStyles() {
157
157
  }
158
158
  var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
159
159
  var init_ansi_styles = __esm({
160
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
160
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
161
161
  ANSI_BACKGROUND_OFFSET = 10;
162
162
  wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
163
163
  wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
@@ -231,7 +231,7 @@ var init_ansi_styles = __esm({
231
231
  }
232
232
  });
233
233
 
234
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
234
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
235
235
  import process2 from "node:process";
236
236
  import os from "node:os";
237
237
  import tty from "node:tty";
@@ -298,7 +298,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
298
298
  return 1;
299
299
  }
300
300
  if ("CI" in env) {
301
- if ("GITHUB_ACTIONS" in env) {
301
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
302
302
  return 3;
303
303
  }
304
304
  if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
@@ -346,7 +346,7 @@ function createSupportsColor(stream, options = {}) {
346
346
  }
347
347
  var env, flagForceColor, supportsColor, supports_color_default;
348
348
  var init_supports_color = __esm({
349
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
349
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
350
350
  ({ env } = process2);
351
351
  if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
352
352
  flagForceColor = 0;
@@ -361,7 +361,7 @@ var init_supports_color = __esm({
361
361
  }
362
362
  });
363
363
 
364
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
364
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
365
365
  function stringReplaceAll(string, substring, replacer) {
366
366
  let index4 = string.indexOf(substring);
367
367
  if (index4 === -1) {
@@ -391,21 +391,20 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
391
391
  return returnValue;
392
392
  }
393
393
  var init_utilities = __esm({
394
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
394
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js"() {
395
395
  }
396
396
  });
397
397
 
398
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
398
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
399
399
  function createChalk(options) {
400
400
  return chalkFactory(options);
401
401
  }
402
402
  var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
403
403
  var init_source = __esm({
404
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
404
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js"() {
405
405
  init_ansi_styles();
406
406
  init_supports_color();
407
407
  init_utilities();
408
- init_ansi_styles();
409
408
  ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
410
409
  GENERATOR = Symbol("GENERATOR");
411
410
  STYLER = Symbol("STYLER");
@@ -1116,11 +1115,12 @@ var init_global = __esm({
1116
1115
  }
1117
1116
  });
1118
1117
 
1119
- // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
1118
+ // node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs
1120
1119
  function getErrorMap() {
1121
1120
  return overrideErrorMap;
1122
1121
  }
1123
1122
  function addIssueToContext(ctx, issueData) {
1123
+ const overrideMap = getErrorMap();
1124
1124
  const issue = makeIssue({
1125
1125
  issueData,
1126
1126
  data: ctx.data,
@@ -1128,13 +1128,29 @@ function addIssueToContext(ctx, issueData) {
1128
1128
  errorMaps: [
1129
1129
  ctx.common.contextualErrorMap,
1130
1130
  ctx.schemaErrorMap,
1131
- getErrorMap(),
1132
- errorMap
1131
+ overrideMap,
1132
+ overrideMap === errorMap ? void 0 : errorMap
1133
1133
  // then global default map
1134
1134
  ].filter((x) => !!x)
1135
1135
  });
1136
1136
  ctx.common.issues.push(issue);
1137
1137
  }
1138
+ function __classPrivateFieldGet(receiver, state, kind, f) {
1139
+ if (kind === "a" && !f)
1140
+ throw new TypeError("Private accessor was defined without a getter");
1141
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1142
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
1143
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1144
+ }
1145
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
1146
+ if (kind === "m")
1147
+ throw new TypeError("Private method is not writable");
1148
+ if (kind === "a" && !f)
1149
+ throw new TypeError("Private accessor was defined without a setter");
1150
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1151
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
1152
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1153
+ }
1138
1154
  function processCreateParams(params) {
1139
1155
  if (!params)
1140
1156
  return {};
@@ -1145,15 +1161,50 @@ function processCreateParams(params) {
1145
1161
  if (errorMap2)
1146
1162
  return { errorMap: errorMap2, description };
1147
1163
  const customMap = (iss, ctx) => {
1148
- if (iss.code !== "invalid_type")
1149
- return { message: ctx.defaultError };
1164
+ var _a, _b;
1165
+ const { message } = params;
1166
+ if (iss.code === "invalid_enum_value") {
1167
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
1168
+ }
1150
1169
  if (typeof ctx.data === "undefined") {
1151
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
1170
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
1152
1171
  }
1153
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
1172
+ if (iss.code !== "invalid_type")
1173
+ return { message: ctx.defaultError };
1174
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
1154
1175
  };
1155
1176
  return { errorMap: customMap, description };
1156
1177
  }
1178
+ function timeRegexSource(args) {
1179
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
1180
+ if (args.precision) {
1181
+ regex = `${regex}\\.\\d{${args.precision}}`;
1182
+ } else if (args.precision == null) {
1183
+ regex = `${regex}(\\.\\d+)?`;
1184
+ }
1185
+ return regex;
1186
+ }
1187
+ function timeRegex(args) {
1188
+ return new RegExp(`^${timeRegexSource(args)}$`);
1189
+ }
1190
+ function datetimeRegex(args) {
1191
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1192
+ const opts = [];
1193
+ opts.push(args.local ? `Z?` : `Z`);
1194
+ if (args.offset)
1195
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1196
+ regex = `${regex}(${opts.join("|")})`;
1197
+ return new RegExp(`^${regex}$`);
1198
+ }
1199
+ function isValidIP(ip, version) {
1200
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1201
+ return true;
1202
+ }
1203
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1204
+ return true;
1205
+ }
1206
+ return false;
1207
+ }
1157
1208
  function floatSafeRemainder(val, step) {
1158
1209
  const valDecCount = (val.toString().split(".")[1] || "").length;
1159
1210
  const stepDecCount = (step.toString().split(".")[1] || "").length;
@@ -1174,7 +1225,10 @@ function deepPartialify(schema4) {
1174
1225
  shape: () => newShape
1175
1226
  });
1176
1227
  } else if (schema4 instanceof ZodArray) {
1177
- return ZodArray.create(deepPartialify(schema4.element));
1228
+ return new ZodArray({
1229
+ ...schema4._def,
1230
+ type: deepPartialify(schema4.element)
1231
+ });
1178
1232
  } else if (schema4 instanceof ZodOptional) {
1179
1233
  return ZodOptional.create(deepPartialify(schema4.unwrap()));
1180
1234
  } else if (schema4 instanceof ZodNullable) {
@@ -1230,9 +1284,9 @@ function createZodEnum(values, params) {
1230
1284
  ...processCreateParams(params)
1231
1285
  });
1232
1286
  }
1233
- var util, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, ParseInputLazyPath, handleResult, ZodType, cuidRegex, uuidRegex, emailRegex, datetimeRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, objectUtil, AugmentFactory, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType, coerce;
1287
+ var util, objectUtil, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, _ZodEnum_cache, _ZodNativeEnum_cache, ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv6Regex, base64Regex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType, coerce;
1234
1288
  var init_lib = __esm({
1235
- "node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs"() {
1289
+ "node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs"() {
1236
1290
  (function(util2) {
1237
1291
  util2.assertEqual = (val) => val;
1238
1292
  function assertIs(_arg) {
@@ -1290,6 +1344,15 @@ var init_lib = __esm({
1290
1344
  return value;
1291
1345
  };
1292
1346
  })(util || (util = {}));
1347
+ (function(objectUtil2) {
1348
+ objectUtil2.mergeShapes = (first, second) => {
1349
+ return {
1350
+ ...first,
1351
+ ...second
1352
+ // second overwrites first
1353
+ };
1354
+ };
1355
+ })(objectUtil || (objectUtil = {}));
1293
1356
  ZodParsedType = util.arrayToEnum([
1294
1357
  "string",
1295
1358
  "nan",
@@ -1371,7 +1434,7 @@ var init_lib = __esm({
1371
1434
  "not_multiple_of",
1372
1435
  "not_finite"
1373
1436
  ]);
1374
- ZodError = class extends Error {
1437
+ ZodError = class _ZodError extends Error {
1375
1438
  constructor(issues) {
1376
1439
  super();
1377
1440
  this.issues = [];
@@ -1429,6 +1492,11 @@ var init_lib = __esm({
1429
1492
  processError(this);
1430
1493
  return fieldErrors;
1431
1494
  }
1495
+ static assert(value) {
1496
+ if (!(value instanceof _ZodError)) {
1497
+ throw new Error(`Not a ZodError: ${value}`);
1498
+ }
1499
+ }
1432
1500
  toString() {
1433
1501
  return this.message;
1434
1502
  }
@@ -1495,7 +1563,12 @@ var init_lib = __esm({
1495
1563
  break;
1496
1564
  case ZodIssueCode.invalid_string:
1497
1565
  if (typeof issue.validation === "object") {
1498
- if ("startsWith" in issue.validation) {
1566
+ if ("includes" in issue.validation) {
1567
+ message = `Invalid input: must include "${issue.validation.includes}"`;
1568
+ if (typeof issue.validation.position === "number") {
1569
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1570
+ }
1571
+ } else if ("startsWith" in issue.validation) {
1499
1572
  message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1500
1573
  } else if ("endsWith" in issue.validation) {
1501
1574
  message = `Invalid input: must end with "${issue.validation.endsWith}"`;
@@ -1516,7 +1589,7 @@ var init_lib = __esm({
1516
1589
  else if (issue.type === "number")
1517
1590
  message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1518
1591
  else if (issue.type === "date")
1519
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
1592
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1520
1593
  else
1521
1594
  message = "Invalid input";
1522
1595
  break;
@@ -1527,8 +1600,10 @@ var init_lib = __esm({
1527
1600
  message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1528
1601
  else if (issue.type === "number")
1529
1602
  message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1603
+ else if (issue.type === "bigint")
1604
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1530
1605
  else if (issue.type === "date")
1531
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
1606
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1532
1607
  else
1533
1608
  message = "Invalid input";
1534
1609
  break;
@@ -1558,6 +1633,13 @@ var init_lib = __esm({
1558
1633
  ...issueData,
1559
1634
  path: fullPath
1560
1635
  };
1636
+ if (issueData.message !== void 0) {
1637
+ return {
1638
+ ...issueData,
1639
+ path: fullPath,
1640
+ message: issueData.message
1641
+ };
1642
+ }
1561
1643
  let errorMessage = "";
1562
1644
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
1563
1645
  for (const map of maps) {
@@ -1566,7 +1648,7 @@ var init_lib = __esm({
1566
1648
  return {
1567
1649
  ...issueData,
1568
1650
  path: fullPath,
1569
- message: issueData.message || errorMessage
1651
+ message: errorMessage
1570
1652
  };
1571
1653
  };
1572
1654
  ParseStatus = class _ParseStatus {
@@ -1595,9 +1677,11 @@ var init_lib = __esm({
1595
1677
  static async mergeObjectAsync(status, pairs) {
1596
1678
  const syncPairs = [];
1597
1679
  for (const pair of pairs) {
1680
+ const key = await pair.key;
1681
+ const value = await pair.value;
1598
1682
  syncPairs.push({
1599
- key: await pair.key,
1600
- value: await pair.value
1683
+ key,
1684
+ value
1601
1685
  });
1602
1686
  }
1603
1687
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -1614,7 +1698,7 @@ var init_lib = __esm({
1614
1698
  status.dirty();
1615
1699
  if (value.status === "dirty")
1616
1700
  status.dirty();
1617
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
1701
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1618
1702
  finalObject[key.value] = value.value;
1619
1703
  }
1620
1704
  }
@@ -1629,20 +1713,28 @@ var init_lib = __esm({
1629
1713
  isAborted = (x) => x.status === "aborted";
1630
1714
  isDirty = (x) => x.status === "dirty";
1631
1715
  isValid = (x) => x.status === "valid";
1632
- isAsync = (x) => typeof Promise !== void 0 && x instanceof Promise;
1716
+ isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1633
1717
  (function(errorUtil2) {
1634
1718
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1635
1719
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1636
1720
  })(errorUtil || (errorUtil = {}));
1637
1721
  ParseInputLazyPath = class {
1638
1722
  constructor(parent, value, path2, key) {
1723
+ this._cachedPath = [];
1639
1724
  this.parent = parent;
1640
1725
  this.data = value;
1641
1726
  this._path = path2;
1642
1727
  this._key = key;
1643
1728
  }
1644
1729
  get path() {
1645
- return this._path.concat(this._key);
1730
+ if (!this._cachedPath.length) {
1731
+ if (this._key instanceof Array) {
1732
+ this._cachedPath.push(...this._path, ...this._key);
1733
+ } else {
1734
+ this._cachedPath.push(...this._path, this._key);
1735
+ }
1736
+ }
1737
+ return this._cachedPath;
1646
1738
  }
1647
1739
  };
1648
1740
  handleResult = (ctx, result) => {
@@ -1652,8 +1744,16 @@ var init_lib = __esm({
1652
1744
  if (!ctx.common.issues.length) {
1653
1745
  throw new Error("Validation failed but no issues detected.");
1654
1746
  }
1655
- const error2 = new ZodError(ctx.common.issues);
1656
- return { success: false, error: error2 };
1747
+ return {
1748
+ success: false,
1749
+ get error() {
1750
+ if (this._error)
1751
+ return this._error;
1752
+ const error2 = new ZodError(ctx.common.issues);
1753
+ this._error = error2;
1754
+ return this._error;
1755
+ }
1756
+ };
1657
1757
  }
1658
1758
  };
1659
1759
  ZodType = class {
@@ -1681,6 +1781,7 @@ var init_lib = __esm({
1681
1781
  this.catch = this.catch.bind(this);
1682
1782
  this.describe = this.describe.bind(this);
1683
1783
  this.pipe = this.pipe.bind(this);
1784
+ this.readonly = this.readonly.bind(this);
1684
1785
  this.isNullable = this.isNullable.bind(this);
1685
1786
  this.isOptional = this.isOptional.bind(this);
1686
1787
  }
@@ -1825,28 +1926,29 @@ var init_lib = __esm({
1825
1926
  return this._refinement(refinement);
1826
1927
  }
1827
1928
  optional() {
1828
- return ZodOptional.create(this);
1929
+ return ZodOptional.create(this, this._def);
1829
1930
  }
1830
1931
  nullable() {
1831
- return ZodNullable.create(this);
1932
+ return ZodNullable.create(this, this._def);
1832
1933
  }
1833
1934
  nullish() {
1834
- return this.optional().nullable();
1935
+ return this.nullable().optional();
1835
1936
  }
1836
1937
  array() {
1837
- return ZodArray.create(this);
1938
+ return ZodArray.create(this, this._def);
1838
1939
  }
1839
1940
  promise() {
1840
- return ZodPromise.create(this);
1941
+ return ZodPromise.create(this, this._def);
1841
1942
  }
1842
1943
  or(option) {
1843
- return ZodUnion.create([this, option]);
1944
+ return ZodUnion.create([this, option], this._def);
1844
1945
  }
1845
1946
  and(incoming) {
1846
- return ZodIntersection.create(this, incoming);
1947
+ return ZodIntersection.create(this, incoming, this._def);
1847
1948
  }
1848
1949
  transform(transform) {
1849
1950
  return new ZodEffects({
1951
+ ...processCreateParams(this._def),
1850
1952
  schema: this,
1851
1953
  typeName: ZodFirstPartyTypeKind.ZodEffects,
1852
1954
  effect: { type: "transform", transform }
@@ -1855,6 +1957,7 @@ var init_lib = __esm({
1855
1957
  default(def) {
1856
1958
  const defaultValueFunc = typeof def === "function" ? def : () => def;
1857
1959
  return new ZodDefault({
1960
+ ...processCreateParams(this._def),
1858
1961
  innerType: this,
1859
1962
  defaultValue: defaultValueFunc,
1860
1963
  typeName: ZodFirstPartyTypeKind.ZodDefault
@@ -1864,14 +1967,15 @@ var init_lib = __esm({
1864
1967
  return new ZodBranded({
1865
1968
  typeName: ZodFirstPartyTypeKind.ZodBranded,
1866
1969
  type: this,
1867
- ...processCreateParams(void 0)
1970
+ ...processCreateParams(this._def)
1868
1971
  });
1869
1972
  }
1870
1973
  catch(def) {
1871
- const defaultValueFunc = typeof def === "function" ? def : () => def;
1974
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1872
1975
  return new ZodCatch({
1976
+ ...processCreateParams(this._def),
1873
1977
  innerType: this,
1874
- defaultValue: defaultValueFunc,
1978
+ catchValue: catchValueFunc,
1875
1979
  typeName: ZodFirstPartyTypeKind.ZodCatch
1876
1980
  });
1877
1981
  }
@@ -1885,6 +1989,9 @@ var init_lib = __esm({
1885
1989
  pipe(target) {
1886
1990
  return ZodPipeline.create(this, target);
1887
1991
  }
1992
+ readonly() {
1993
+ return ZodReadonly.create(this);
1994
+ }
1888
1995
  isOptional() {
1889
1996
  return this.safeParse(void 0).success;
1890
1997
  }
@@ -1893,43 +2000,19 @@ var init_lib = __esm({
1893
2000
  }
1894
2001
  };
1895
2002
  cuidRegex = /^c[^\s-]{8,}$/i;
1896
- uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
1897
- emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1898
- datetimeRegex = (args) => {
1899
- if (args.precision) {
1900
- if (args.offset) {
1901
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
1902
- } else {
1903
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
1904
- }
1905
- } else if (args.precision === 0) {
1906
- if (args.offset) {
1907
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
1908
- } else {
1909
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
1910
- }
1911
- } else {
1912
- if (args.offset) {
1913
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
1914
- } else {
1915
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
1916
- }
1917
- }
1918
- };
2003
+ cuid2Regex = /^[0-9a-z]+$/;
2004
+ ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
2005
+ 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;
2006
+ nanoidRegex = /^[a-z0-9_-]{21}$/i;
2007
+ 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)?)??$/;
2008
+ emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2009
+ _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
2010
+ 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])$/;
2011
+ 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})))$/;
2012
+ base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
2013
+ 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])))`;
2014
+ dateRegex = new RegExp(`^${dateRegexSource}$`);
1919
2015
  ZodString = class _ZodString extends ZodType {
1920
- constructor() {
1921
- super(...arguments);
1922
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
1923
- validation,
1924
- code: ZodIssueCode.invalid_string,
1925
- ...errorUtil.errToObj(message)
1926
- });
1927
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
1928
- this.trim = () => new _ZodString({
1929
- ...this._def,
1930
- checks: [...this._def.checks, { kind: "trim" }]
1931
- });
1932
- }
1933
2016
  _parse(input) {
1934
2017
  if (this._def.coerce) {
1935
2018
  input.data = String(input.data);
@@ -1937,15 +2020,11 @@ var init_lib = __esm({
1937
2020
  const parsedType = this._getType(input);
1938
2021
  if (parsedType !== ZodParsedType.string) {
1939
2022
  const ctx2 = this._getOrReturnCtx(input);
1940
- addIssueToContext(
1941
- ctx2,
1942
- {
1943
- code: ZodIssueCode.invalid_type,
1944
- expected: ZodParsedType.string,
1945
- received: ctx2.parsedType
1946
- }
1947
- //
1948
- );
2023
+ addIssueToContext(ctx2, {
2024
+ code: ZodIssueCode.invalid_type,
2025
+ expected: ZodParsedType.string,
2026
+ received: ctx2.parsedType
2027
+ });
1949
2028
  return INVALID;
1950
2029
  }
1951
2030
  const status = new ParseStatus();
@@ -2013,6 +2092,19 @@ var init_lib = __esm({
2013
2092
  });
2014
2093
  status.dirty();
2015
2094
  }
2095
+ } else if (check.kind === "emoji") {
2096
+ if (!emojiRegex) {
2097
+ emojiRegex = new RegExp(_emojiRegex, "u");
2098
+ }
2099
+ if (!emojiRegex.test(input.data)) {
2100
+ ctx = this._getOrReturnCtx(input, ctx);
2101
+ addIssueToContext(ctx, {
2102
+ validation: "emoji",
2103
+ code: ZodIssueCode.invalid_string,
2104
+ message: check.message
2105
+ });
2106
+ status.dirty();
2107
+ }
2016
2108
  } else if (check.kind === "uuid") {
2017
2109
  if (!uuidRegex.test(input.data)) {
2018
2110
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2023,6 +2115,16 @@ var init_lib = __esm({
2023
2115
  });
2024
2116
  status.dirty();
2025
2117
  }
2118
+ } else if (check.kind === "nanoid") {
2119
+ if (!nanoidRegex.test(input.data)) {
2120
+ ctx = this._getOrReturnCtx(input, ctx);
2121
+ addIssueToContext(ctx, {
2122
+ validation: "nanoid",
2123
+ code: ZodIssueCode.invalid_string,
2124
+ message: check.message
2125
+ });
2126
+ status.dirty();
2127
+ }
2026
2128
  } else if (check.kind === "cuid") {
2027
2129
  if (!cuidRegex.test(input.data)) {
2028
2130
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2033,6 +2135,26 @@ var init_lib = __esm({
2033
2135
  });
2034
2136
  status.dirty();
2035
2137
  }
2138
+ } else if (check.kind === "cuid2") {
2139
+ if (!cuid2Regex.test(input.data)) {
2140
+ ctx = this._getOrReturnCtx(input, ctx);
2141
+ addIssueToContext(ctx, {
2142
+ validation: "cuid2",
2143
+ code: ZodIssueCode.invalid_string,
2144
+ message: check.message
2145
+ });
2146
+ status.dirty();
2147
+ }
2148
+ } else if (check.kind === "ulid") {
2149
+ if (!ulidRegex.test(input.data)) {
2150
+ ctx = this._getOrReturnCtx(input, ctx);
2151
+ addIssueToContext(ctx, {
2152
+ validation: "ulid",
2153
+ code: ZodIssueCode.invalid_string,
2154
+ message: check.message
2155
+ });
2156
+ status.dirty();
2157
+ }
2036
2158
  } else if (check.kind === "url") {
2037
2159
  try {
2038
2160
  new URL(input.data);
@@ -2059,6 +2181,20 @@ var init_lib = __esm({
2059
2181
  }
2060
2182
  } else if (check.kind === "trim") {
2061
2183
  input.data = input.data.trim();
2184
+ } else if (check.kind === "includes") {
2185
+ if (!input.data.includes(check.value, check.position)) {
2186
+ ctx = this._getOrReturnCtx(input, ctx);
2187
+ addIssueToContext(ctx, {
2188
+ code: ZodIssueCode.invalid_string,
2189
+ validation: { includes: check.value, position: check.position },
2190
+ message: check.message
2191
+ });
2192
+ status.dirty();
2193
+ }
2194
+ } else if (check.kind === "toLowerCase") {
2195
+ input.data = input.data.toLowerCase();
2196
+ } else if (check.kind === "toUpperCase") {
2197
+ input.data = input.data.toUpperCase();
2062
2198
  } else if (check.kind === "startsWith") {
2063
2199
  if (!input.data.startsWith(check.value)) {
2064
2200
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2090,12 +2226,71 @@ var init_lib = __esm({
2090
2226
  });
2091
2227
  status.dirty();
2092
2228
  }
2229
+ } else if (check.kind === "date") {
2230
+ const regex = dateRegex;
2231
+ if (!regex.test(input.data)) {
2232
+ ctx = this._getOrReturnCtx(input, ctx);
2233
+ addIssueToContext(ctx, {
2234
+ code: ZodIssueCode.invalid_string,
2235
+ validation: "date",
2236
+ message: check.message
2237
+ });
2238
+ status.dirty();
2239
+ }
2240
+ } else if (check.kind === "time") {
2241
+ const regex = timeRegex(check);
2242
+ if (!regex.test(input.data)) {
2243
+ ctx = this._getOrReturnCtx(input, ctx);
2244
+ addIssueToContext(ctx, {
2245
+ code: ZodIssueCode.invalid_string,
2246
+ validation: "time",
2247
+ message: check.message
2248
+ });
2249
+ status.dirty();
2250
+ }
2251
+ } else if (check.kind === "duration") {
2252
+ if (!durationRegex.test(input.data)) {
2253
+ ctx = this._getOrReturnCtx(input, ctx);
2254
+ addIssueToContext(ctx, {
2255
+ validation: "duration",
2256
+ code: ZodIssueCode.invalid_string,
2257
+ message: check.message
2258
+ });
2259
+ status.dirty();
2260
+ }
2261
+ } else if (check.kind === "ip") {
2262
+ if (!isValidIP(input.data, check.version)) {
2263
+ ctx = this._getOrReturnCtx(input, ctx);
2264
+ addIssueToContext(ctx, {
2265
+ validation: "ip",
2266
+ code: ZodIssueCode.invalid_string,
2267
+ message: check.message
2268
+ });
2269
+ status.dirty();
2270
+ }
2271
+ } else if (check.kind === "base64") {
2272
+ if (!base64Regex.test(input.data)) {
2273
+ ctx = this._getOrReturnCtx(input, ctx);
2274
+ addIssueToContext(ctx, {
2275
+ validation: "base64",
2276
+ code: ZodIssueCode.invalid_string,
2277
+ message: check.message
2278
+ });
2279
+ status.dirty();
2280
+ }
2093
2281
  } else {
2094
2282
  util.assertNever(check);
2095
2283
  }
2096
2284
  }
2097
2285
  return { status: status.value, value: input.data };
2098
2286
  }
2287
+ _regex(regex, validation, message) {
2288
+ return this.refinement((data) => regex.test(data), {
2289
+ validation,
2290
+ code: ZodIssueCode.invalid_string,
2291
+ ...errorUtil.errToObj(message)
2292
+ });
2293
+ }
2099
2294
  _addCheck(check) {
2100
2295
  return new _ZodString({
2101
2296
  ...this._def,
@@ -2108,19 +2303,38 @@ var init_lib = __esm({
2108
2303
  url(message) {
2109
2304
  return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2110
2305
  }
2306
+ emoji(message) {
2307
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
2308
+ }
2111
2309
  uuid(message) {
2112
2310
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2113
2311
  }
2312
+ nanoid(message) {
2313
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2314
+ }
2114
2315
  cuid(message) {
2115
2316
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2116
2317
  }
2318
+ cuid2(message) {
2319
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
2320
+ }
2321
+ ulid(message) {
2322
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2323
+ }
2324
+ base64(message) {
2325
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2326
+ }
2327
+ ip(options) {
2328
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2329
+ }
2117
2330
  datetime(options) {
2118
- var _a;
2331
+ var _a, _b;
2119
2332
  if (typeof options === "string") {
2120
2333
  return this._addCheck({
2121
2334
  kind: "datetime",
2122
2335
  precision: null,
2123
2336
  offset: false,
2337
+ local: false,
2124
2338
  message: options
2125
2339
  });
2126
2340
  }
@@ -2128,9 +2342,30 @@ var init_lib = __esm({
2128
2342
  kind: "datetime",
2129
2343
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2130
2344
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2345
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2131
2346
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2132
2347
  });
2133
2348
  }
2349
+ date(message) {
2350
+ return this._addCheck({ kind: "date", message });
2351
+ }
2352
+ time(options) {
2353
+ if (typeof options === "string") {
2354
+ return this._addCheck({
2355
+ kind: "time",
2356
+ precision: null,
2357
+ message: options
2358
+ });
2359
+ }
2360
+ return this._addCheck({
2361
+ kind: "time",
2362
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2363
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2364
+ });
2365
+ }
2366
+ duration(message) {
2367
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2368
+ }
2134
2369
  regex(regex, message) {
2135
2370
  return this._addCheck({
2136
2371
  kind: "regex",
@@ -2138,6 +2373,14 @@ var init_lib = __esm({
2138
2373
  ...errorUtil.errToObj(message)
2139
2374
  });
2140
2375
  }
2376
+ includes(value, options) {
2377
+ return this._addCheck({
2378
+ kind: "includes",
2379
+ value,
2380
+ position: options === null || options === void 0 ? void 0 : options.position,
2381
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2382
+ });
2383
+ }
2141
2384
  startsWith(value, message) {
2142
2385
  return this._addCheck({
2143
2386
  kind: "startsWith",
@@ -2173,21 +2416,73 @@ var init_lib = __esm({
2173
2416
  ...errorUtil.errToObj(message)
2174
2417
  });
2175
2418
  }
2419
+ /**
2420
+ * @deprecated Use z.string().min(1) instead.
2421
+ * @see {@link ZodString.min}
2422
+ */
2423
+ nonempty(message) {
2424
+ return this.min(1, errorUtil.errToObj(message));
2425
+ }
2426
+ trim() {
2427
+ return new _ZodString({
2428
+ ...this._def,
2429
+ checks: [...this._def.checks, { kind: "trim" }]
2430
+ });
2431
+ }
2432
+ toLowerCase() {
2433
+ return new _ZodString({
2434
+ ...this._def,
2435
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
2436
+ });
2437
+ }
2438
+ toUpperCase() {
2439
+ return new _ZodString({
2440
+ ...this._def,
2441
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
2442
+ });
2443
+ }
2176
2444
  get isDatetime() {
2177
2445
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
2178
2446
  }
2447
+ get isDate() {
2448
+ return !!this._def.checks.find((ch) => ch.kind === "date");
2449
+ }
2450
+ get isTime() {
2451
+ return !!this._def.checks.find((ch) => ch.kind === "time");
2452
+ }
2453
+ get isDuration() {
2454
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
2455
+ }
2179
2456
  get isEmail() {
2180
2457
  return !!this._def.checks.find((ch) => ch.kind === "email");
2181
2458
  }
2182
2459
  get isURL() {
2183
2460
  return !!this._def.checks.find((ch) => ch.kind === "url");
2184
2461
  }
2462
+ get isEmoji() {
2463
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
2464
+ }
2185
2465
  get isUUID() {
2186
2466
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
2187
2467
  }
2468
+ get isNANOID() {
2469
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2470
+ }
2188
2471
  get isCUID() {
2189
2472
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
2190
2473
  }
2474
+ get isCUID2() {
2475
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
2476
+ }
2477
+ get isULID() {
2478
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
2479
+ }
2480
+ get isIP() {
2481
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
2482
+ }
2483
+ get isBase64() {
2484
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
2485
+ }
2191
2486
  get minLength() {
2192
2487
  let min = null;
2193
2488
  for (const ch of this._def.checks) {
@@ -2389,6 +2684,19 @@ var init_lib = __esm({
2389
2684
  message: errorUtil.toString(message)
2390
2685
  });
2391
2686
  }
2687
+ safe(message) {
2688
+ return this._addCheck({
2689
+ kind: "min",
2690
+ inclusive: true,
2691
+ value: Number.MIN_SAFE_INTEGER,
2692
+ message: errorUtil.toString(message)
2693
+ })._addCheck({
2694
+ kind: "max",
2695
+ inclusive: true,
2696
+ value: Number.MAX_SAFE_INTEGER,
2697
+ message: errorUtil.toString(message)
2698
+ });
2699
+ }
2392
2700
  get minValue() {
2393
2701
  let min = null;
2394
2702
  for (const ch of this._def.checks) {
@@ -2410,7 +2718,22 @@ var init_lib = __esm({
2410
2718
  return max;
2411
2719
  }
2412
2720
  get isInt() {
2413
- return !!this._def.checks.find((ch) => ch.kind === "int");
2721
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2722
+ }
2723
+ get isFinite() {
2724
+ let max = null, min = null;
2725
+ for (const ch of this._def.checks) {
2726
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2727
+ return true;
2728
+ } else if (ch.kind === "min") {
2729
+ if (min === null || ch.value > min)
2730
+ min = ch.value;
2731
+ } else if (ch.kind === "max") {
2732
+ if (max === null || ch.value < max)
2733
+ max = ch.value;
2734
+ }
2735
+ }
2736
+ return Number.isFinite(min) && Number.isFinite(max);
2414
2737
  }
2415
2738
  };
2416
2739
  ZodNumber.create = (params) => {
@@ -2421,27 +2744,167 @@ var init_lib = __esm({
2421
2744
  ...processCreateParams(params)
2422
2745
  });
2423
2746
  };
2424
- ZodBigInt = class extends ZodType {
2747
+ ZodBigInt = class _ZodBigInt extends ZodType {
2748
+ constructor() {
2749
+ super(...arguments);
2750
+ this.min = this.gte;
2751
+ this.max = this.lte;
2752
+ }
2425
2753
  _parse(input) {
2426
2754
  if (this._def.coerce) {
2427
2755
  input.data = BigInt(input.data);
2428
2756
  }
2429
2757
  const parsedType = this._getType(input);
2430
2758
  if (parsedType !== ZodParsedType.bigint) {
2431
- const ctx = this._getOrReturnCtx(input);
2432
- addIssueToContext(ctx, {
2759
+ const ctx2 = this._getOrReturnCtx(input);
2760
+ addIssueToContext(ctx2, {
2433
2761
  code: ZodIssueCode.invalid_type,
2434
2762
  expected: ZodParsedType.bigint,
2435
- received: ctx.parsedType
2763
+ received: ctx2.parsedType
2436
2764
  });
2437
2765
  return INVALID;
2438
2766
  }
2439
- return OK(input.data);
2767
+ let ctx = void 0;
2768
+ const status = new ParseStatus();
2769
+ for (const check of this._def.checks) {
2770
+ if (check.kind === "min") {
2771
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2772
+ if (tooSmall) {
2773
+ ctx = this._getOrReturnCtx(input, ctx);
2774
+ addIssueToContext(ctx, {
2775
+ code: ZodIssueCode.too_small,
2776
+ type: "bigint",
2777
+ minimum: check.value,
2778
+ inclusive: check.inclusive,
2779
+ message: check.message
2780
+ });
2781
+ status.dirty();
2782
+ }
2783
+ } else if (check.kind === "max") {
2784
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2785
+ if (tooBig) {
2786
+ ctx = this._getOrReturnCtx(input, ctx);
2787
+ addIssueToContext(ctx, {
2788
+ code: ZodIssueCode.too_big,
2789
+ type: "bigint",
2790
+ maximum: check.value,
2791
+ inclusive: check.inclusive,
2792
+ message: check.message
2793
+ });
2794
+ status.dirty();
2795
+ }
2796
+ } else if (check.kind === "multipleOf") {
2797
+ if (input.data % check.value !== BigInt(0)) {
2798
+ ctx = this._getOrReturnCtx(input, ctx);
2799
+ addIssueToContext(ctx, {
2800
+ code: ZodIssueCode.not_multiple_of,
2801
+ multipleOf: check.value,
2802
+ message: check.message
2803
+ });
2804
+ status.dirty();
2805
+ }
2806
+ } else {
2807
+ util.assertNever(check);
2808
+ }
2809
+ }
2810
+ return { status: status.value, value: input.data };
2811
+ }
2812
+ gte(value, message) {
2813
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2814
+ }
2815
+ gt(value, message) {
2816
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2817
+ }
2818
+ lte(value, message) {
2819
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2820
+ }
2821
+ lt(value, message) {
2822
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2823
+ }
2824
+ setLimit(kind, value, inclusive, message) {
2825
+ return new _ZodBigInt({
2826
+ ...this._def,
2827
+ checks: [
2828
+ ...this._def.checks,
2829
+ {
2830
+ kind,
2831
+ value,
2832
+ inclusive,
2833
+ message: errorUtil.toString(message)
2834
+ }
2835
+ ]
2836
+ });
2837
+ }
2838
+ _addCheck(check) {
2839
+ return new _ZodBigInt({
2840
+ ...this._def,
2841
+ checks: [...this._def.checks, check]
2842
+ });
2843
+ }
2844
+ positive(message) {
2845
+ return this._addCheck({
2846
+ kind: "min",
2847
+ value: BigInt(0),
2848
+ inclusive: false,
2849
+ message: errorUtil.toString(message)
2850
+ });
2851
+ }
2852
+ negative(message) {
2853
+ return this._addCheck({
2854
+ kind: "max",
2855
+ value: BigInt(0),
2856
+ inclusive: false,
2857
+ message: errorUtil.toString(message)
2858
+ });
2859
+ }
2860
+ nonpositive(message) {
2861
+ return this._addCheck({
2862
+ kind: "max",
2863
+ value: BigInt(0),
2864
+ inclusive: true,
2865
+ message: errorUtil.toString(message)
2866
+ });
2867
+ }
2868
+ nonnegative(message) {
2869
+ return this._addCheck({
2870
+ kind: "min",
2871
+ value: BigInt(0),
2872
+ inclusive: true,
2873
+ message: errorUtil.toString(message)
2874
+ });
2875
+ }
2876
+ multipleOf(value, message) {
2877
+ return this._addCheck({
2878
+ kind: "multipleOf",
2879
+ value,
2880
+ message: errorUtil.toString(message)
2881
+ });
2882
+ }
2883
+ get minValue() {
2884
+ let min = null;
2885
+ for (const ch of this._def.checks) {
2886
+ if (ch.kind === "min") {
2887
+ if (min === null || ch.value > min)
2888
+ min = ch.value;
2889
+ }
2890
+ }
2891
+ return min;
2892
+ }
2893
+ get maxValue() {
2894
+ let max = null;
2895
+ for (const ch of this._def.checks) {
2896
+ if (ch.kind === "max") {
2897
+ if (max === null || ch.value < max)
2898
+ max = ch.value;
2899
+ }
2900
+ }
2901
+ return max;
2440
2902
  }
2441
2903
  };
2442
2904
  ZodBigInt.create = (params) => {
2443
2905
  var _a;
2444
2906
  return new ZodBigInt({
2907
+ checks: [],
2445
2908
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
2446
2909
  coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2447
2910
  ...processCreateParams(params)
@@ -2767,13 +3230,13 @@ var init_lib = __esm({
2767
3230
  }
2768
3231
  }
2769
3232
  if (ctx.common.async) {
2770
- return Promise.all(ctx.data.map((item, i) => {
3233
+ return Promise.all([...ctx.data].map((item, i) => {
2771
3234
  return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2772
3235
  })).then((result2) => {
2773
3236
  return ParseStatus.mergeArray(status, result2);
2774
3237
  });
2775
3238
  }
2776
- const result = ctx.data.map((item, i) => {
3239
+ const result = [...ctx.data].map((item, i) => {
2777
3240
  return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2778
3241
  });
2779
3242
  return ParseStatus.mergeArray(status, result);
@@ -2813,31 +3276,12 @@ var init_lib = __esm({
2813
3276
  ...processCreateParams(params)
2814
3277
  });
2815
3278
  };
2816
- (function(objectUtil2) {
2817
- objectUtil2.mergeShapes = (first, second) => {
2818
- return {
2819
- ...first,
2820
- ...second
2821
- // second overwrites first
2822
- };
2823
- };
2824
- })(objectUtil || (objectUtil = {}));
2825
- AugmentFactory = (def) => (augmentation) => {
2826
- return new ZodObject({
2827
- ...def,
2828
- shape: () => ({
2829
- ...def.shape(),
2830
- ...augmentation
2831
- })
2832
- });
2833
- };
2834
3279
  ZodObject = class _ZodObject extends ZodType {
2835
3280
  constructor() {
2836
3281
  super(...arguments);
2837
3282
  this._cached = null;
2838
3283
  this.nonstrict = this.passthrough;
2839
- this.augment = AugmentFactory(this._def);
2840
- this.extend = AugmentFactory(this._def);
3284
+ this.augment = this.extend;
2841
3285
  }
2842
3286
  _getCached() {
2843
3287
  if (this._cached !== null)
@@ -2918,9 +3362,10 @@ var init_lib = __esm({
2918
3362
  const syncPairs = [];
2919
3363
  for (const pair of pairs) {
2920
3364
  const key = await pair.key;
3365
+ const value = await pair.value;
2921
3366
  syncPairs.push({
2922
3367
  key,
2923
- value: await pair.value,
3368
+ value,
2924
3369
  alwaysSet: pair.alwaysSet
2925
3370
  });
2926
3371
  }
@@ -2967,8 +3412,31 @@ var init_lib = __esm({
2967
3412
  unknownKeys: "passthrough"
2968
3413
  });
2969
3414
  }
2970
- setKey(key, schema4) {
2971
- return this.augment({ [key]: schema4 });
3415
+ // const AugmentFactory =
3416
+ // <Def extends ZodObjectDef>(def: Def) =>
3417
+ // <Augmentation extends ZodRawShape>(
3418
+ // augmentation: Augmentation
3419
+ // ): ZodObject<
3420
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
3421
+ // Def["unknownKeys"],
3422
+ // Def["catchall"]
3423
+ // > => {
3424
+ // return new ZodObject({
3425
+ // ...def,
3426
+ // shape: () => ({
3427
+ // ...def.shape(),
3428
+ // ...augmentation,
3429
+ // }),
3430
+ // }) as any;
3431
+ // };
3432
+ extend(augmentation) {
3433
+ return new _ZodObject({
3434
+ ...this._def,
3435
+ shape: () => ({
3436
+ ...this._def.shape(),
3437
+ ...augmentation
3438
+ })
3439
+ });
2972
3440
  }
2973
3441
  /**
2974
3442
  * Prior to zod@1.0.12 there was a bug in the
@@ -2979,11 +3447,73 @@ var init_lib = __esm({
2979
3447
  const merged = new _ZodObject({
2980
3448
  unknownKeys: merging._def.unknownKeys,
2981
3449
  catchall: merging._def.catchall,
2982
- shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3450
+ shape: () => ({
3451
+ ...this._def.shape(),
3452
+ ...merging._def.shape()
3453
+ }),
2983
3454
  typeName: ZodFirstPartyTypeKind.ZodObject
2984
3455
  });
2985
3456
  return merged;
2986
3457
  }
3458
+ // merge<
3459
+ // Incoming extends AnyZodObject,
3460
+ // Augmentation extends Incoming["shape"],
3461
+ // NewOutput extends {
3462
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3463
+ // ? Augmentation[k]["_output"]
3464
+ // : k extends keyof Output
3465
+ // ? Output[k]
3466
+ // : never;
3467
+ // },
3468
+ // NewInput extends {
3469
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3470
+ // ? Augmentation[k]["_input"]
3471
+ // : k extends keyof Input
3472
+ // ? Input[k]
3473
+ // : never;
3474
+ // }
3475
+ // >(
3476
+ // merging: Incoming
3477
+ // ): ZodObject<
3478
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3479
+ // Incoming["_def"]["unknownKeys"],
3480
+ // Incoming["_def"]["catchall"],
3481
+ // NewOutput,
3482
+ // NewInput
3483
+ // > {
3484
+ // const merged: any = new ZodObject({
3485
+ // unknownKeys: merging._def.unknownKeys,
3486
+ // catchall: merging._def.catchall,
3487
+ // shape: () =>
3488
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3489
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3490
+ // }) as any;
3491
+ // return merged;
3492
+ // }
3493
+ setKey(key, schema4) {
3494
+ return this.augment({ [key]: schema4 });
3495
+ }
3496
+ // merge<Incoming extends AnyZodObject>(
3497
+ // merging: Incoming
3498
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3499
+ // ZodObject<
3500
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3501
+ // Incoming["_def"]["unknownKeys"],
3502
+ // Incoming["_def"]["catchall"]
3503
+ // > {
3504
+ // // const mergedShape = objectUtil.mergeShapes(
3505
+ // // this._def.shape(),
3506
+ // // merging._def.shape()
3507
+ // // );
3508
+ // const merged: any = new ZodObject({
3509
+ // unknownKeys: merging._def.unknownKeys,
3510
+ // catchall: merging._def.catchall,
3511
+ // shape: () =>
3512
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3513
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3514
+ // }) as any;
3515
+ // return merged;
3516
+ // }
2987
3517
  catchall(index4) {
2988
3518
  return new _ZodObject({
2989
3519
  ...this._def,
@@ -2992,9 +3522,10 @@ var init_lib = __esm({
2992
3522
  }
2993
3523
  pick(mask) {
2994
3524
  const shape = {};
2995
- util.objectKeys(mask).map((key) => {
2996
- if (this.shape[key])
3525
+ util.objectKeys(mask).forEach((key) => {
3526
+ if (mask[key] && this.shape[key]) {
2997
3527
  shape[key] = this.shape[key];
3528
+ }
2998
3529
  });
2999
3530
  return new _ZodObject({
3000
3531
  ...this._def,
@@ -3003,8 +3534,8 @@ var init_lib = __esm({
3003
3534
  }
3004
3535
  omit(mask) {
3005
3536
  const shape = {};
3006
- util.objectKeys(this.shape).map((key) => {
3007
- if (util.objectKeys(mask).indexOf(key) === -1) {
3537
+ util.objectKeys(this.shape).forEach((key) => {
3538
+ if (!mask[key]) {
3008
3539
  shape[key] = this.shape[key];
3009
3540
  }
3010
3541
  });
@@ -3013,29 +3544,22 @@ var init_lib = __esm({
3013
3544
  shape: () => shape
3014
3545
  });
3015
3546
  }
3547
+ /**
3548
+ * @deprecated
3549
+ */
3016
3550
  deepPartial() {
3017
3551
  return deepPartialify(this);
3018
3552
  }
3019
3553
  partial(mask) {
3020
3554
  const newShape = {};
3021
- if (mask) {
3022
- util.objectKeys(this.shape).map((key) => {
3023
- if (util.objectKeys(mask).indexOf(key) === -1) {
3024
- newShape[key] = this.shape[key];
3025
- } else {
3026
- newShape[key] = this.shape[key].optional();
3027
- }
3028
- });
3029
- return new _ZodObject({
3030
- ...this._def,
3031
- shape: () => newShape
3032
- });
3033
- } else {
3034
- for (const key in this.shape) {
3035
- const fieldSchema = this.shape[key];
3555
+ util.objectKeys(this.shape).forEach((key) => {
3556
+ const fieldSchema = this.shape[key];
3557
+ if (mask && !mask[key]) {
3558
+ newShape[key] = fieldSchema;
3559
+ } else {
3036
3560
  newShape[key] = fieldSchema.optional();
3037
3561
  }
3038
- }
3562
+ });
3039
3563
  return new _ZodObject({
3040
3564
  ...this._def,
3041
3565
  shape: () => newShape
@@ -3043,21 +3567,10 @@ var init_lib = __esm({
3043
3567
  }
3044
3568
  required(mask) {
3045
3569
  const newShape = {};
3046
- if (mask) {
3047
- util.objectKeys(this.shape).map((key) => {
3048
- if (util.objectKeys(mask).indexOf(key) === -1) {
3049
- newShape[key] = this.shape[key];
3050
- } else {
3051
- const fieldSchema = this.shape[key];
3052
- let newField = fieldSchema;
3053
- while (newField instanceof ZodOptional) {
3054
- newField = newField._def.innerType;
3055
- }
3056
- newShape[key] = newField;
3057
- }
3058
- });
3059
- } else {
3060
- for (const key in this.shape) {
3570
+ util.objectKeys(this.shape).forEach((key) => {
3571
+ if (mask && !mask[key]) {
3572
+ newShape[key] = this.shape[key];
3573
+ } else {
3061
3574
  const fieldSchema = this.shape[key];
3062
3575
  let newField = fieldSchema;
3063
3576
  while (newField instanceof ZodOptional) {
@@ -3065,7 +3578,7 @@ var init_lib = __esm({
3065
3578
  }
3066
3579
  newShape[key] = newField;
3067
3580
  }
3068
- }
3581
+ });
3069
3582
  return new _ZodObject({
3070
3583
  ...this._def,
3071
3584
  shape: () => newShape
@@ -3203,15 +3716,25 @@ var init_lib = __esm({
3203
3716
  } else if (type instanceof ZodEnum) {
3204
3717
  return type.options;
3205
3718
  } else if (type instanceof ZodNativeEnum) {
3206
- return Object.keys(type.enum);
3719
+ return util.objectValues(type.enum);
3207
3720
  } else if (type instanceof ZodDefault) {
3208
3721
  return getDiscriminator(type._def.innerType);
3209
3722
  } else if (type instanceof ZodUndefined) {
3210
3723
  return [void 0];
3211
3724
  } else if (type instanceof ZodNull) {
3212
3725
  return [null];
3726
+ } else if (type instanceof ZodOptional) {
3727
+ return [void 0, ...getDiscriminator(type.unwrap())];
3728
+ } else if (type instanceof ZodNullable) {
3729
+ return [null, ...getDiscriminator(type.unwrap())];
3730
+ } else if (type instanceof ZodBranded) {
3731
+ return getDiscriminator(type.unwrap());
3732
+ } else if (type instanceof ZodReadonly) {
3733
+ return getDiscriminator(type.unwrap());
3734
+ } else if (type instanceof ZodCatch) {
3735
+ return getDiscriminator(type._def.innerType);
3213
3736
  } else {
3214
- return null;
3737
+ return [];
3215
3738
  }
3216
3739
  };
3217
3740
  ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -3271,7 +3794,7 @@ var init_lib = __esm({
3271
3794
  const optionsMap = /* @__PURE__ */ new Map();
3272
3795
  for (const type of options) {
3273
3796
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3274
- if (!discriminatorValues) {
3797
+ if (!discriminatorValues.length) {
3275
3798
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3276
3799
  }
3277
3800
  for (const value of discriminatorValues) {
@@ -3375,7 +3898,7 @@ var init_lib = __esm({
3375
3898
  });
3376
3899
  status.dirty();
3377
3900
  }
3378
- const items = ctx.data.map((item, itemIndex) => {
3901
+ const items = [...ctx.data].map((item, itemIndex) => {
3379
3902
  const schema4 = this._def.items[itemIndex] || this._def.rest;
3380
3903
  if (!schema4)
3381
3904
  return null;
@@ -3433,7 +3956,8 @@ var init_lib = __esm({
3433
3956
  for (const key in ctx.data) {
3434
3957
  pairs.push({
3435
3958
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3436
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3959
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3960
+ alwaysSet: key in ctx.data
3437
3961
  });
3438
3962
  }
3439
3963
  if (ctx.common.async) {
@@ -3463,6 +3987,12 @@ var init_lib = __esm({
3463
3987
  }
3464
3988
  };
3465
3989
  ZodMap = class extends ZodType {
3990
+ get keySchema() {
3991
+ return this._def.keyType;
3992
+ }
3993
+ get valueSchema() {
3994
+ return this._def.valueType;
3995
+ }
3466
3996
  _parse(input) {
3467
3997
  const { status, ctx } = this._processInputParams(input);
3468
3998
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -3657,27 +4187,29 @@ var init_lib = __esm({
3657
4187
  const params = { errorMap: ctx.common.contextualErrorMap };
3658
4188
  const fn = ctx.data;
3659
4189
  if (this._def.returns instanceof ZodPromise) {
3660
- return OK(async (...args) => {
4190
+ const me = this;
4191
+ return OK(async function(...args) {
3661
4192
  const error2 = new ZodError([]);
3662
- const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
4193
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3663
4194
  error2.addIssue(makeArgsIssue(args, e));
3664
4195
  throw error2;
3665
4196
  });
3666
- const result = await fn(...parsedArgs);
3667
- const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
4197
+ const result = await Reflect.apply(fn, this, parsedArgs);
4198
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3668
4199
  error2.addIssue(makeReturnsIssue(result, e));
3669
4200
  throw error2;
3670
4201
  });
3671
4202
  return parsedReturns;
3672
4203
  });
3673
4204
  } else {
3674
- return OK((...args) => {
3675
- const parsedArgs = this._def.args.safeParse(args, params);
4205
+ const me = this;
4206
+ return OK(function(...args) {
4207
+ const parsedArgs = me._def.args.safeParse(args, params);
3676
4208
  if (!parsedArgs.success) {
3677
4209
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3678
4210
  }
3679
- const result = fn(...parsedArgs.data);
3680
- const parsedReturns = this._def.returns.safeParse(result, params);
4211
+ const result = Reflect.apply(fn, this, parsedArgs.data);
4212
+ const parsedReturns = me._def.returns.safeParse(result, params);
3681
4213
  if (!parsedReturns.success) {
3682
4214
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3683
4215
  }
@@ -3742,6 +4274,7 @@ var init_lib = __esm({
3742
4274
  if (input.data !== this._def.value) {
3743
4275
  const ctx = this._getOrReturnCtx(input);
3744
4276
  addIssueToContext(ctx, {
4277
+ received: ctx.data,
3745
4278
  code: ZodIssueCode.invalid_literal,
3746
4279
  expected: this._def.value
3747
4280
  });
@@ -3760,7 +4293,11 @@ var init_lib = __esm({
3760
4293
  ...processCreateParams(params)
3761
4294
  });
3762
4295
  };
3763
- ZodEnum = class extends ZodType {
4296
+ ZodEnum = class _ZodEnum extends ZodType {
4297
+ constructor() {
4298
+ super(...arguments);
4299
+ _ZodEnum_cache.set(this, void 0);
4300
+ }
3764
4301
  _parse(input) {
3765
4302
  if (typeof input.data !== "string") {
3766
4303
  const ctx = this._getOrReturnCtx(input);
@@ -3772,7 +4309,10 @@ var init_lib = __esm({
3772
4309
  });
3773
4310
  return INVALID;
3774
4311
  }
3775
- if (this._def.values.indexOf(input.data) === -1) {
4312
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
4313
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
4314
+ }
4315
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3776
4316
  const ctx = this._getOrReturnCtx(input);
3777
4317
  const expectedValues = this._def.values;
3778
4318
  addIssueToContext(ctx, {
@@ -3808,9 +4348,26 @@ var init_lib = __esm({
3808
4348
  }
3809
4349
  return enumValues;
3810
4350
  }
4351
+ extract(values, newDef = this._def) {
4352
+ return _ZodEnum.create(values, {
4353
+ ...this._def,
4354
+ ...newDef
4355
+ });
4356
+ }
4357
+ exclude(values, newDef = this._def) {
4358
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4359
+ ...this._def,
4360
+ ...newDef
4361
+ });
4362
+ }
3811
4363
  };
4364
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3812
4365
  ZodEnum.create = createZodEnum;
3813
4366
  ZodNativeEnum = class extends ZodType {
4367
+ constructor() {
4368
+ super(...arguments);
4369
+ _ZodNativeEnum_cache.set(this, void 0);
4370
+ }
3814
4371
  _parse(input) {
3815
4372
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3816
4373
  const ctx = this._getOrReturnCtx(input);
@@ -3823,7 +4380,10 @@ var init_lib = __esm({
3823
4380
  });
3824
4381
  return INVALID;
3825
4382
  }
3826
- if (nativeEnumValues.indexOf(input.data) === -1) {
4383
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
4384
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
4385
+ }
4386
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3827
4387
  const expectedValues = util.objectValues(nativeEnumValues);
3828
4388
  addIssueToContext(ctx, {
3829
4389
  received: ctx.data,
@@ -3838,6 +4398,7 @@ var init_lib = __esm({
3838
4398
  return this._def.values;
3839
4399
  }
3840
4400
  };
4401
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3841
4402
  ZodNativeEnum.create = (values, params) => {
3842
4403
  return new ZodNativeEnum({
3843
4404
  values,
@@ -3846,6 +4407,9 @@ var init_lib = __esm({
3846
4407
  });
3847
4408
  };
3848
4409
  ZodPromise = class extends ZodType {
4410
+ unwrap() {
4411
+ return this._def.type;
4412
+ }
3849
4413
  _parse(input) {
3850
4414
  const { ctx } = this._processInputParams(input);
3851
4415
  if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
@@ -3882,24 +4446,6 @@ var init_lib = __esm({
3882
4446
  _parse(input) {
3883
4447
  const { status, ctx } = this._processInputParams(input);
3884
4448
  const effect = this._def.effect || null;
3885
- if (effect.type === "preprocess") {
3886
- const processed = effect.transform(ctx.data);
3887
- if (ctx.common.async) {
3888
- return Promise.resolve(processed).then((processed2) => {
3889
- return this._def.schema._parseAsync({
3890
- data: processed2,
3891
- path: ctx.path,
3892
- parent: ctx
3893
- });
3894
- });
3895
- } else {
3896
- return this._def.schema._parseSync({
3897
- data: processed,
3898
- path: ctx.path,
3899
- parent: ctx
3900
- });
3901
- }
3902
- }
3903
4449
  const checkCtx = {
3904
4450
  addIssue: (arg) => {
3905
4451
  addIssueToContext(ctx, arg);
@@ -3914,6 +4460,42 @@ var init_lib = __esm({
3914
4460
  }
3915
4461
  };
3916
4462
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4463
+ if (effect.type === "preprocess") {
4464
+ const processed = effect.transform(ctx.data, checkCtx);
4465
+ if (ctx.common.async) {
4466
+ return Promise.resolve(processed).then(async (processed2) => {
4467
+ if (status.value === "aborted")
4468
+ return INVALID;
4469
+ const result = await this._def.schema._parseAsync({
4470
+ data: processed2,
4471
+ path: ctx.path,
4472
+ parent: ctx
4473
+ });
4474
+ if (result.status === "aborted")
4475
+ return INVALID;
4476
+ if (result.status === "dirty")
4477
+ return DIRTY(result.value);
4478
+ if (status.value === "dirty")
4479
+ return DIRTY(result.value);
4480
+ return result;
4481
+ });
4482
+ } else {
4483
+ if (status.value === "aborted")
4484
+ return INVALID;
4485
+ const result = this._def.schema._parseSync({
4486
+ data: processed,
4487
+ path: ctx.path,
4488
+ parent: ctx
4489
+ });
4490
+ if (result.status === "aborted")
4491
+ return INVALID;
4492
+ if (result.status === "dirty")
4493
+ return DIRTY(result.value);
4494
+ if (status.value === "dirty")
4495
+ return DIRTY(result.value);
4496
+ return result;
4497
+ }
4498
+ }
3917
4499
  if (effect.type === "refinement") {
3918
4500
  const executeRefinement = (acc) => {
3919
4501
  const result = effect.refinement(acc, checkCtx);
@@ -4056,26 +4638,45 @@ var init_lib = __esm({
4056
4638
  ZodCatch = class extends ZodType {
4057
4639
  _parse(input) {
4058
4640
  const { ctx } = this._processInputParams(input);
4641
+ const newCtx = {
4642
+ ...ctx,
4643
+ common: {
4644
+ ...ctx.common,
4645
+ issues: []
4646
+ }
4647
+ };
4059
4648
  const result = this._def.innerType._parse({
4060
- data: ctx.data,
4061
- path: ctx.path,
4062
- parent: ctx
4649
+ data: newCtx.data,
4650
+ path: newCtx.path,
4651
+ parent: {
4652
+ ...newCtx
4653
+ }
4063
4654
  });
4064
4655
  if (isAsync(result)) {
4065
4656
  return result.then((result2) => {
4066
4657
  return {
4067
4658
  status: "valid",
4068
- value: result2.status === "valid" ? result2.value : this._def.defaultValue()
4659
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
4660
+ get error() {
4661
+ return new ZodError(newCtx.common.issues);
4662
+ },
4663
+ input: newCtx.data
4664
+ })
4069
4665
  };
4070
4666
  });
4071
4667
  } else {
4072
4668
  return {
4073
4669
  status: "valid",
4074
- value: result.status === "valid" ? result.value : this._def.defaultValue()
4670
+ value: result.status === "valid" ? result.value : this._def.catchValue({
4671
+ get error() {
4672
+ return new ZodError(newCtx.common.issues);
4673
+ },
4674
+ input: newCtx.data
4675
+ })
4075
4676
  };
4076
4677
  }
4077
4678
  }
4078
- removeDefault() {
4679
+ removeCatch() {
4079
4680
  return this._def.innerType;
4080
4681
  }
4081
4682
  };
@@ -4083,7 +4684,7 @@ var init_lib = __esm({
4083
4684
  return new ZodCatch({
4084
4685
  innerType: type,
4085
4686
  typeName: ZodFirstPartyTypeKind.ZodCatch,
4086
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4687
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4087
4688
  ...processCreateParams(params)
4088
4689
  });
4089
4690
  };
@@ -4178,6 +4779,25 @@ var init_lib = __esm({
4178
4779
  });
4179
4780
  }
4180
4781
  };
4782
+ ZodReadonly = class extends ZodType {
4783
+ _parse(input) {
4784
+ const result = this._def.innerType._parse(input);
4785
+ if (isValid(result)) {
4786
+ result.value = Object.freeze(result.value);
4787
+ }
4788
+ return result;
4789
+ }
4790
+ unwrap() {
4791
+ return this._def.innerType;
4792
+ }
4793
+ };
4794
+ ZodReadonly.create = (type, params) => {
4795
+ return new ZodReadonly({
4796
+ innerType: type,
4797
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4798
+ ...processCreateParams(params)
4799
+ });
4800
+ };
4181
4801
  late = {
4182
4802
  object: ZodObject.lazycreate
4183
4803
  };
@@ -4217,6 +4837,7 @@ var init_lib = __esm({
4217
4837
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4218
4838
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4219
4839
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4840
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4220
4841
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4221
4842
  stringType = ZodString.create;
4222
4843
  numberType = ZodNumber.create;
@@ -4255,7 +4876,10 @@ var init_lib = __esm({
4255
4876
  coerce = {
4256
4877
  string: (arg) => ZodString.create({ ...arg, coerce: true }),
4257
4878
  number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4258
- boolean: (arg) => ZodBoolean.create({ ...arg, coerce: true }),
4879
+ boolean: (arg) => ZodBoolean.create({
4880
+ ...arg,
4881
+ coerce: true
4882
+ }),
4259
4883
  bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4260
4884
  date: (arg) => ZodDate.create({ ...arg, coerce: true })
4261
4885
  };
@@ -5077,7 +5701,6 @@ var init_utils = __esm({
5077
5701
  init_mysqlSchema();
5078
5702
  init_pgSchema();
5079
5703
  init_sqliteSchema();
5080
- init_source();
5081
5704
  init_global();
5082
5705
  copy = (it) => {
5083
5706
  return JSON.parse(JSON.stringify(it));
@@ -5282,7 +5905,6 @@ var sqlToStr;
5282
5905
  var init_serializer = __esm({
5283
5906
  "src/serializer/index.ts"() {
5284
5907
  "use strict";
5285
- init_source();
5286
5908
  init_views();
5287
5909
  sqlToStr = (sql2) => {
5288
5910
  return sql2.toQuery({
@@ -5311,8 +5933,7 @@ var init_outputs = __esm({
5311
5933
  warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
5312
5934
  errorWarning: (str) => `${source_default.red(`${source_default.white.bgRed(" Warning ")} ${str}`)}`,
5313
5935
  fullWarning: (str) => `${source_default.black.bgYellow("[Warning]")} ${source_default.bold(str)}`,
5314
- suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}`,
5315
- info: (str) => `${source_default.grey(str)}`
5936
+ suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}`
5316
5937
  };
5317
5938
  }
5318
5939
  });
@@ -5517,7 +6138,7 @@ var init_cli = __esm({
5517
6138
  dialect: dialect3,
5518
6139
  schema: unionType([stringType(), stringType().array()]).optional(),
5519
6140
  tablesFilter: unionType([stringType(), stringType().array()]).optional(),
5520
- schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
6141
+ schemaFilters: unionType([stringType(), stringType().array()]).optional().default(["public"]),
5521
6142
  driver: stringType().optional(),
5522
6143
  // pg
5523
6144
  connectionString: stringType().optional(),
@@ -5556,7 +6177,7 @@ var init_cli = __esm({
5556
6177
  authToken: stringType().optional(),
5557
6178
  introspectCasing: casing,
5558
6179
  breakpoints: booleanType().optional().default(true)
5559
- }).passthrough();
6180
+ });
5560
6181
  configCheck = objectType({
5561
6182
  dialect: dialect3.optional(),
5562
6183
  out: stringType().optional()
@@ -6332,9 +6953,9 @@ var require_src2 = __commonJS({
6332
6953
  }
6333
6954
  });
6334
6955
 
6335
- // node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.7/node_modules/esbuild-register/dist/node.js
6956
+ // node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.12/node_modules/esbuild-register/dist/node.js
6336
6957
  var require_node2 = __commonJS({
6337
- "node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.7/node_modules/esbuild-register/dist/node.js"(exports) {
6958
+ "node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.12/node_modules/esbuild-register/dist/node.js"(exports) {
6338
6959
  "use strict";
6339
6960
  Object.defineProperty(exports, "__esModule", { value: true });
6340
6961
  function _interopRequireDefault2(obj) {
@@ -11195,7 +11816,6 @@ var init_utils2 = __esm({
11195
11816
  "src/cli/commands/utils.ts"() {
11196
11817
  "use strict";
11197
11818
  init_serializer();
11198
- init_source();
11199
11819
  init_views();
11200
11820
  import_hanji2 = __toESM(require_hanji());
11201
11821
  init_global();
@@ -12172,10 +12792,10 @@ var require_brace_expansion = __commonJS({
12172
12792
  }
12173
12793
  });
12174
12794
 
12175
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js
12795
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
12176
12796
  var posixClasses, braceEscape, regexpEscape, rangesToString, parseClass;
12177
12797
  var init_brace_expressions = __esm({
12178
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js"() {
12798
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js"() {
12179
12799
  posixClasses = {
12180
12800
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
12181
12801
  "[:alpha:]": ["\\p{L}\\p{Nl}", true],
@@ -12287,30 +12907,30 @@ var init_brace_expressions = __esm({
12287
12907
  }
12288
12908
  });
12289
12909
 
12290
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js
12910
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js
12291
12911
  var escape;
12292
12912
  var init_escape = __esm({
12293
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js"() {
12913
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js"() {
12294
12914
  escape = (s, { windowsPathsNoEscape = false } = {}) => {
12295
12915
  return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
12296
12916
  };
12297
12917
  }
12298
12918
  });
12299
12919
 
12300
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js
12920
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js
12301
12921
  var unescape;
12302
12922
  var init_unescape = __esm({
12303
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js"() {
12923
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js"() {
12304
12924
  unescape = (s, { windowsPathsNoEscape = false } = {}) => {
12305
12925
  return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
12306
12926
  };
12307
12927
  }
12308
12928
  });
12309
12929
 
12310
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
12930
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
12311
12931
  var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext, defaults, braceExpand, MAX_PATTERN_LENGTH, assertValidPattern, makeRe, match, globUnescape, globMagic, regExpEscape, Minimatch;
12312
12932
  var init_mjs = __esm({
12313
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js"() {
12933
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js"() {
12314
12934
  import_brace_expansion = __toESM(require_brace_expansion(), 1);
12315
12935
  init_brace_expressions();
12316
12936
  init_escape();
@@ -15102,7 +15722,7 @@ var init_snapshotsDiffer = __esm({
15102
15722
  const jsonTableAlternations = alteredTables.map((it) => {
15103
15723
  return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
15104
15724
  }).flat();
15105
- const jsonCreateIndexesFoAlteredTables = alteredTables.map((it) => {
15725
+ const jsonCreateIndexesForAllAlteredTables = alteredTables.map((it) => {
15106
15726
  return prepareCreateIndexesJson(
15107
15727
  it.name,
15108
15728
  it.schema,
@@ -15131,21 +15751,14 @@ var init_snapshotsDiffer = __esm({
15131
15751
  },
15132
15752
  {}
15133
15753
  );
15134
- jsonCreateIndexesFoAlteredTables.push(
15754
+ jsonCreateIndexesForAllAlteredTables.push(
15135
15755
  ...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
15136
15756
  );
15137
15757
  jsonDropIndexesForAllAlteredTables.push(
15138
15758
  ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
15139
15759
  );
15140
15760
  });
15141
- const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
15142
- return prepareCreateReferencesJson(
15143
- it.name,
15144
- it.schema,
15145
- it.foreignKeys
15146
- );
15147
- }).flat();
15148
- const jsonReferencesForAlteredTables = alteredTables.map((it) => {
15761
+ const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
15149
15762
  const forAdded = prepareCreateReferencesJson(
15150
15763
  it.name,
15151
15764
  it.schema,
@@ -15163,10 +15776,10 @@ var init_snapshotsDiffer = __esm({
15163
15776
  );
15164
15777
  return [...forAdded, ...forAltered, ...alteredFKs];
15165
15778
  }).flat();
15166
- const jsonCreatedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
15779
+ const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
15167
15780
  (t) => t.type === "create_reference"
15168
15781
  );
15169
- const jsonDroppedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
15782
+ const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
15170
15783
  (t) => t.type === "delete_reference"
15171
15784
  );
15172
15785
  const createEnums = createdEnums.map((it) => {
@@ -15193,7 +15806,7 @@ var init_snapshotsDiffer = __esm({
15193
15806
  const dropSchemas = prepareDeleteSchemasJson(
15194
15807
  deletedSchemas.map((it) => it.name)
15195
15808
  );
15196
- const createTables = createdTables.map((it) => {
15809
+ const jsonPgCreateTables = createdTables.map((it) => {
15197
15810
  return preparePgCreateTableJson(it, curFull);
15198
15811
  });
15199
15812
  jsonStatements.push(...createSchemas);
@@ -15202,7 +15815,7 @@ var init_snapshotsDiffer = __esm({
15202
15815
  jsonStatements.push(...moveEnums);
15203
15816
  jsonStatements.push(...renameEnums);
15204
15817
  jsonStatements.push(...jsonAlterEnumsWithAddedValues);
15205
- jsonStatements.push(...createTables);
15818
+ jsonStatements.push(...jsonPgCreateTables);
15206
15819
  jsonStatements.push(...jsonDropTables);
15207
15820
  jsonStatements.push(...jsonSetTableSchemas);
15208
15821
  jsonStatements.push(...jsonRenameTables);
@@ -15213,10 +15826,9 @@ var init_snapshotsDiffer = __esm({
15213
15826
  jsonStatements.push(...jsonTableAlternations);
15214
15827
  jsonStatements.push(...jsonAddedCompositePKs);
15215
15828
  jsonStatements.push(...jsonAddColumnsStatemets);
15216
- jsonStatements.push(...jsonCreateReferencesForCreatedTables);
15217
15829
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
15830
+ jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
15218
15831
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
15219
- jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
15220
15832
  jsonStatements.push(...jsonDropColumnsStatemets);
15221
15833
  jsonStatements.push(...jsonAlteredCompositePKs);
15222
15834
  jsonStatements.push(...jsonAlteredUniqueConstraints);
@@ -15475,13 +16087,6 @@ var init_snapshotsDiffer = __esm({
15475
16087
  ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
15476
16088
  );
15477
16089
  });
15478
- const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
15479
- return prepareCreateReferencesJson(
15480
- it.name,
15481
- it.schema,
15482
- it.foreignKeys
15483
- );
15484
- }).flat();
15485
16090
  const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
15486
16091
  const forAdded = prepareCreateReferencesJson(
15487
16092
  it.name,
@@ -15522,10 +16127,9 @@ var init_snapshotsDiffer = __esm({
15522
16127
  jsonStatements.push(...jsonAddedUniqueConstraints);
15523
16128
  jsonStatements.push(...jsonDeletedUniqueConstraints);
15524
16129
  jsonStatements.push(...jsonAddColumnsStatemets);
15525
- jsonStatements.push(...jsonCreateReferencesForCreatedTables);
15526
16130
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
15527
- jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
15528
16131
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16132
+ jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
15529
16133
  jsonStatements.push(...jsonDropColumnsStatemets);
15530
16134
  jsonStatements.push(...jsonAlteredCompositePKs);
15531
16135
  jsonStatements.push(...jsonAddedUniqueConstraints);