drizzle-kit 0.21.2 → 0.21.4-b5744a6

Sign up to get free protection for your applications and to get access to all the features.
package/utils-studio.mjs CHANGED
@@ -34,7 +34,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
 
37
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
37
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
38
38
  function assembleStyles() {
39
39
  const codes = /* @__PURE__ */ new Map();
40
40
  for (const [groupName, group] of Object.entries(styles)) {
@@ -151,7 +151,7 @@ function assembleStyles() {
151
151
  }
152
152
  var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
153
153
  var init_ansi_styles = __esm({
154
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
154
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
155
155
  ANSI_BACKGROUND_OFFSET = 10;
156
156
  wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
157
157
  wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
@@ -225,7 +225,7 @@ var init_ansi_styles = __esm({
225
225
  }
226
226
  });
227
227
 
228
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
228
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
229
229
  import process2 from "node:process";
230
230
  import os from "node:os";
231
231
  import tty from "node:tty";
@@ -292,7 +292,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
292
292
  return 1;
293
293
  }
294
294
  if ("CI" in env) {
295
- if ("GITHUB_ACTIONS" in env) {
295
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
296
296
  return 3;
297
297
  }
298
298
  if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
@@ -340,7 +340,7 @@ function createSupportsColor(stream, options = {}) {
340
340
  }
341
341
  var env, flagForceColor, supportsColor, supports_color_default;
342
342
  var init_supports_color = __esm({
343
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
343
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
344
344
  ({ env } = process2);
345
345
  if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
346
346
  flagForceColor = 0;
@@ -355,7 +355,7 @@ var init_supports_color = __esm({
355
355
  }
356
356
  });
357
357
 
358
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
358
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
359
359
  function stringReplaceAll(string, substring, replacer) {
360
360
  let index4 = string.indexOf(substring);
361
361
  if (index4 === -1) {
@@ -385,21 +385,20 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
385
385
  return returnValue;
386
386
  }
387
387
  var init_utilities = __esm({
388
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
388
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js"() {
389
389
  }
390
390
  });
391
391
 
392
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
392
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
393
393
  function createChalk(options) {
394
394
  return chalkFactory(options);
395
395
  }
396
- var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr;
396
+ var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
397
397
  var init_source = __esm({
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
  init_ansi_styles();
400
400
  init_supports_color();
401
401
  init_utilities();
402
- init_ansi_styles();
403
402
  ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
404
403
  GENERATOR = Symbol("GENERATOR");
405
404
  STYLER = Symbol("STYLER");
@@ -541,6 +540,7 @@ var init_source = __esm({
541
540
  Object.defineProperties(createChalk.prototype, styles2);
542
541
  chalk = createChalk();
543
542
  chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
543
+ source_default = chalk;
544
544
  }
545
545
  });
546
546
 
@@ -1056,7 +1056,7 @@ var require_hanji = __commonJS({
1056
1056
  return;
1057
1057
  }
1058
1058
  exports.render = render2;
1059
- function renderWithTask2(view, task) {
1059
+ function renderWithTask3(view, task) {
1060
1060
  return __awaiter(this, void 0, void 0, function* () {
1061
1061
  const terminal = new TaskTerminal(view, process.stdout);
1062
1062
  terminal.requestLayout();
@@ -1065,7 +1065,7 @@ var require_hanji = __commonJS({
1065
1065
  return result;
1066
1066
  });
1067
1067
  }
1068
- exports.renderWithTask = renderWithTask2;
1068
+ exports.renderWithTask = renderWithTask3;
1069
1069
  var terminateHandler;
1070
1070
  function onTerminate(callback) {
1071
1071
  terminateHandler = callback;
@@ -1084,11 +1084,12 @@ var init_global = __esm({
1084
1084
  }
1085
1085
  });
1086
1086
 
1087
- // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
1087
+ // node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
1088
1088
  function getErrorMap() {
1089
1089
  return overrideErrorMap;
1090
1090
  }
1091
1091
  function addIssueToContext(ctx, issueData) {
1092
+ const overrideMap = getErrorMap();
1092
1093
  const issue = makeIssue({
1093
1094
  issueData,
1094
1095
  data: ctx.data,
@@ -1096,13 +1097,29 @@ function addIssueToContext(ctx, issueData) {
1096
1097
  errorMaps: [
1097
1098
  ctx.common.contextualErrorMap,
1098
1099
  ctx.schemaErrorMap,
1099
- getErrorMap(),
1100
- errorMap
1100
+ overrideMap,
1101
+ overrideMap === errorMap ? void 0 : errorMap
1101
1102
  // then global default map
1102
1103
  ].filter((x) => !!x)
1103
1104
  });
1104
1105
  ctx.common.issues.push(issue);
1105
1106
  }
1107
+ function __classPrivateFieldGet(receiver, state, kind, f) {
1108
+ if (kind === "a" && !f)
1109
+ throw new TypeError("Private accessor was defined without a getter");
1110
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1111
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
1112
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1113
+ }
1114
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
1115
+ if (kind === "m")
1116
+ throw new TypeError("Private method is not writable");
1117
+ if (kind === "a" && !f)
1118
+ throw new TypeError("Private accessor was defined without a setter");
1119
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1120
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
1121
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1122
+ }
1106
1123
  function processCreateParams(params) {
1107
1124
  if (!params)
1108
1125
  return {};
@@ -1113,15 +1130,50 @@ function processCreateParams(params) {
1113
1130
  if (errorMap2)
1114
1131
  return { errorMap: errorMap2, description };
1115
1132
  const customMap = (iss, ctx) => {
1116
- if (iss.code !== "invalid_type")
1117
- return { message: ctx.defaultError };
1133
+ var _a, _b;
1134
+ const { message } = params;
1135
+ if (iss.code === "invalid_enum_value") {
1136
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
1137
+ }
1118
1138
  if (typeof ctx.data === "undefined") {
1119
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
1139
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
1120
1140
  }
1121
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
1141
+ if (iss.code !== "invalid_type")
1142
+ return { message: ctx.defaultError };
1143
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
1122
1144
  };
1123
1145
  return { errorMap: customMap, description };
1124
1146
  }
1147
+ function timeRegexSource(args) {
1148
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
1149
+ if (args.precision) {
1150
+ regex = `${regex}\\.\\d{${args.precision}}`;
1151
+ } else if (args.precision == null) {
1152
+ regex = `${regex}(\\.\\d+)?`;
1153
+ }
1154
+ return regex;
1155
+ }
1156
+ function timeRegex(args) {
1157
+ return new RegExp(`^${timeRegexSource(args)}$`);
1158
+ }
1159
+ function datetimeRegex(args) {
1160
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1161
+ const opts = [];
1162
+ opts.push(args.local ? `Z?` : `Z`);
1163
+ if (args.offset)
1164
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1165
+ regex = `${regex}(${opts.join("|")})`;
1166
+ return new RegExp(`^${regex}$`);
1167
+ }
1168
+ function isValidIP(ip, version) {
1169
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1170
+ return true;
1171
+ }
1172
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1173
+ return true;
1174
+ }
1175
+ return false;
1176
+ }
1125
1177
  function floatSafeRemainder(val, step) {
1126
1178
  const valDecCount = (val.toString().split(".")[1] || "").length;
1127
1179
  const stepDecCount = (step.toString().split(".")[1] || "").length;
@@ -1142,7 +1194,10 @@ function deepPartialify(schema3) {
1142
1194
  shape: () => newShape
1143
1195
  });
1144
1196
  } else if (schema3 instanceof ZodArray) {
1145
- return ZodArray.create(deepPartialify(schema3.element));
1197
+ return new ZodArray({
1198
+ ...schema3._def,
1199
+ type: deepPartialify(schema3.element)
1200
+ });
1146
1201
  } else if (schema3 instanceof ZodOptional) {
1147
1202
  return ZodOptional.create(deepPartialify(schema3.unwrap()));
1148
1203
  } else if (schema3 instanceof ZodNullable) {
@@ -1198,9 +1253,9 @@ function createZodEnum(values, params) {
1198
1253
  ...processCreateParams(params)
1199
1254
  });
1200
1255
  }
1201
- 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;
1256
+ 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;
1202
1257
  var init_lib = __esm({
1203
- "node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs"() {
1258
+ "node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs"() {
1204
1259
  (function(util2) {
1205
1260
  util2.assertEqual = (val) => val;
1206
1261
  function assertIs(_arg) {
@@ -1258,6 +1313,15 @@ var init_lib = __esm({
1258
1313
  return value;
1259
1314
  };
1260
1315
  })(util || (util = {}));
1316
+ (function(objectUtil2) {
1317
+ objectUtil2.mergeShapes = (first, second) => {
1318
+ return {
1319
+ ...first,
1320
+ ...second
1321
+ // second overwrites first
1322
+ };
1323
+ };
1324
+ })(objectUtil || (objectUtil = {}));
1261
1325
  ZodParsedType = util.arrayToEnum([
1262
1326
  "string",
1263
1327
  "nan",
@@ -1339,7 +1403,7 @@ var init_lib = __esm({
1339
1403
  "not_multiple_of",
1340
1404
  "not_finite"
1341
1405
  ]);
1342
- ZodError = class extends Error {
1406
+ ZodError = class _ZodError extends Error {
1343
1407
  constructor(issues) {
1344
1408
  super();
1345
1409
  this.issues = [];
@@ -1397,6 +1461,11 @@ var init_lib = __esm({
1397
1461
  processError(this);
1398
1462
  return fieldErrors;
1399
1463
  }
1464
+ static assert(value) {
1465
+ if (!(value instanceof _ZodError)) {
1466
+ throw new Error(`Not a ZodError: ${value}`);
1467
+ }
1468
+ }
1400
1469
  toString() {
1401
1470
  return this.message;
1402
1471
  }
@@ -1463,7 +1532,12 @@ var init_lib = __esm({
1463
1532
  break;
1464
1533
  case ZodIssueCode.invalid_string:
1465
1534
  if (typeof issue.validation === "object") {
1466
- if ("startsWith" in issue.validation) {
1535
+ if ("includes" in issue.validation) {
1536
+ message = `Invalid input: must include "${issue.validation.includes}"`;
1537
+ if (typeof issue.validation.position === "number") {
1538
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1539
+ }
1540
+ } else if ("startsWith" in issue.validation) {
1467
1541
  message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1468
1542
  } else if ("endsWith" in issue.validation) {
1469
1543
  message = `Invalid input: must end with "${issue.validation.endsWith}"`;
@@ -1484,7 +1558,7 @@ var init_lib = __esm({
1484
1558
  else if (issue.type === "number")
1485
1559
  message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1486
1560
  else if (issue.type === "date")
1487
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
1561
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1488
1562
  else
1489
1563
  message = "Invalid input";
1490
1564
  break;
@@ -1495,8 +1569,10 @@ var init_lib = __esm({
1495
1569
  message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1496
1570
  else if (issue.type === "number")
1497
1571
  message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1572
+ else if (issue.type === "bigint")
1573
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1498
1574
  else if (issue.type === "date")
1499
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
1575
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1500
1576
  else
1501
1577
  message = "Invalid input";
1502
1578
  break;
@@ -1526,6 +1602,13 @@ var init_lib = __esm({
1526
1602
  ...issueData,
1527
1603
  path: fullPath
1528
1604
  };
1605
+ if (issueData.message !== void 0) {
1606
+ return {
1607
+ ...issueData,
1608
+ path: fullPath,
1609
+ message: issueData.message
1610
+ };
1611
+ }
1529
1612
  let errorMessage = "";
1530
1613
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
1531
1614
  for (const map of maps) {
@@ -1534,7 +1617,7 @@ var init_lib = __esm({
1534
1617
  return {
1535
1618
  ...issueData,
1536
1619
  path: fullPath,
1537
- message: issueData.message || errorMessage
1620
+ message: errorMessage
1538
1621
  };
1539
1622
  };
1540
1623
  ParseStatus = class _ParseStatus {
@@ -1563,9 +1646,11 @@ var init_lib = __esm({
1563
1646
  static async mergeObjectAsync(status, pairs) {
1564
1647
  const syncPairs = [];
1565
1648
  for (const pair of pairs) {
1649
+ const key = await pair.key;
1650
+ const value = await pair.value;
1566
1651
  syncPairs.push({
1567
- key: await pair.key,
1568
- value: await pair.value
1652
+ key,
1653
+ value
1569
1654
  });
1570
1655
  }
1571
1656
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -1582,7 +1667,7 @@ var init_lib = __esm({
1582
1667
  status.dirty();
1583
1668
  if (value.status === "dirty")
1584
1669
  status.dirty();
1585
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
1670
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1586
1671
  finalObject[key.value] = value.value;
1587
1672
  }
1588
1673
  }
@@ -1597,20 +1682,28 @@ var init_lib = __esm({
1597
1682
  isAborted = (x) => x.status === "aborted";
1598
1683
  isDirty = (x) => x.status === "dirty";
1599
1684
  isValid = (x) => x.status === "valid";
1600
- isAsync = (x) => typeof Promise !== void 0 && x instanceof Promise;
1685
+ isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1601
1686
  (function(errorUtil2) {
1602
1687
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1603
1688
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1604
1689
  })(errorUtil || (errorUtil = {}));
1605
1690
  ParseInputLazyPath = class {
1606
1691
  constructor(parent, value, path2, key) {
1692
+ this._cachedPath = [];
1607
1693
  this.parent = parent;
1608
1694
  this.data = value;
1609
1695
  this._path = path2;
1610
1696
  this._key = key;
1611
1697
  }
1612
1698
  get path() {
1613
- return this._path.concat(this._key);
1699
+ if (!this._cachedPath.length) {
1700
+ if (this._key instanceof Array) {
1701
+ this._cachedPath.push(...this._path, ...this._key);
1702
+ } else {
1703
+ this._cachedPath.push(...this._path, this._key);
1704
+ }
1705
+ }
1706
+ return this._cachedPath;
1614
1707
  }
1615
1708
  };
1616
1709
  handleResult = (ctx, result) => {
@@ -1620,8 +1713,16 @@ var init_lib = __esm({
1620
1713
  if (!ctx.common.issues.length) {
1621
1714
  throw new Error("Validation failed but no issues detected.");
1622
1715
  }
1623
- const error2 = new ZodError(ctx.common.issues);
1624
- return { success: false, error: error2 };
1716
+ return {
1717
+ success: false,
1718
+ get error() {
1719
+ if (this._error)
1720
+ return this._error;
1721
+ const error2 = new ZodError(ctx.common.issues);
1722
+ this._error = error2;
1723
+ return this._error;
1724
+ }
1725
+ };
1625
1726
  }
1626
1727
  };
1627
1728
  ZodType = class {
@@ -1649,6 +1750,7 @@ var init_lib = __esm({
1649
1750
  this.catch = this.catch.bind(this);
1650
1751
  this.describe = this.describe.bind(this);
1651
1752
  this.pipe = this.pipe.bind(this);
1753
+ this.readonly = this.readonly.bind(this);
1652
1754
  this.isNullable = this.isNullable.bind(this);
1653
1755
  this.isOptional = this.isOptional.bind(this);
1654
1756
  }
@@ -1793,28 +1895,29 @@ var init_lib = __esm({
1793
1895
  return this._refinement(refinement);
1794
1896
  }
1795
1897
  optional() {
1796
- return ZodOptional.create(this);
1898
+ return ZodOptional.create(this, this._def);
1797
1899
  }
1798
1900
  nullable() {
1799
- return ZodNullable.create(this);
1901
+ return ZodNullable.create(this, this._def);
1800
1902
  }
1801
1903
  nullish() {
1802
- return this.optional().nullable();
1904
+ return this.nullable().optional();
1803
1905
  }
1804
1906
  array() {
1805
- return ZodArray.create(this);
1907
+ return ZodArray.create(this, this._def);
1806
1908
  }
1807
1909
  promise() {
1808
- return ZodPromise.create(this);
1910
+ return ZodPromise.create(this, this._def);
1809
1911
  }
1810
1912
  or(option) {
1811
- return ZodUnion.create([this, option]);
1913
+ return ZodUnion.create([this, option], this._def);
1812
1914
  }
1813
1915
  and(incoming) {
1814
- return ZodIntersection.create(this, incoming);
1916
+ return ZodIntersection.create(this, incoming, this._def);
1815
1917
  }
1816
1918
  transform(transform) {
1817
1919
  return new ZodEffects({
1920
+ ...processCreateParams(this._def),
1818
1921
  schema: this,
1819
1922
  typeName: ZodFirstPartyTypeKind.ZodEffects,
1820
1923
  effect: { type: "transform", transform }
@@ -1823,6 +1926,7 @@ var init_lib = __esm({
1823
1926
  default(def) {
1824
1927
  const defaultValueFunc = typeof def === "function" ? def : () => def;
1825
1928
  return new ZodDefault({
1929
+ ...processCreateParams(this._def),
1826
1930
  innerType: this,
1827
1931
  defaultValue: defaultValueFunc,
1828
1932
  typeName: ZodFirstPartyTypeKind.ZodDefault
@@ -1832,14 +1936,15 @@ var init_lib = __esm({
1832
1936
  return new ZodBranded({
1833
1937
  typeName: ZodFirstPartyTypeKind.ZodBranded,
1834
1938
  type: this,
1835
- ...processCreateParams(void 0)
1939
+ ...processCreateParams(this._def)
1836
1940
  });
1837
1941
  }
1838
1942
  catch(def) {
1839
- const defaultValueFunc = typeof def === "function" ? def : () => def;
1943
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1840
1944
  return new ZodCatch({
1945
+ ...processCreateParams(this._def),
1841
1946
  innerType: this,
1842
- defaultValue: defaultValueFunc,
1947
+ catchValue: catchValueFunc,
1843
1948
  typeName: ZodFirstPartyTypeKind.ZodCatch
1844
1949
  });
1845
1950
  }
@@ -1853,6 +1958,9 @@ var init_lib = __esm({
1853
1958
  pipe(target) {
1854
1959
  return ZodPipeline.create(this, target);
1855
1960
  }
1961
+ readonly() {
1962
+ return ZodReadonly.create(this);
1963
+ }
1856
1964
  isOptional() {
1857
1965
  return this.safeParse(void 0).success;
1858
1966
  }
@@ -1861,43 +1969,19 @@ var init_lib = __esm({
1861
1969
  }
1862
1970
  };
1863
1971
  cuidRegex = /^c[^\s-]{8,}$/i;
1864
- 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;
1865
- emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1866
- datetimeRegex = (args) => {
1867
- if (args.precision) {
1868
- if (args.offset) {
1869
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
1870
- } else {
1871
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
1872
- }
1873
- } else if (args.precision === 0) {
1874
- if (args.offset) {
1875
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
1876
- } else {
1877
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
1878
- }
1879
- } else {
1880
- if (args.offset) {
1881
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
1882
- } else {
1883
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
1884
- }
1885
- }
1886
- };
1972
+ cuid2Regex = /^[0-9a-z]+$/;
1973
+ ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
1974
+ 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;
1975
+ nanoidRegex = /^[a-z0-9_-]{21}$/i;
1976
+ 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)?)??$/;
1977
+ emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1978
+ _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1979
+ 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])$/;
1980
+ 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})))$/;
1981
+ base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1982
+ 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])))`;
1983
+ dateRegex = new RegExp(`^${dateRegexSource}$`);
1887
1984
  ZodString = class _ZodString extends ZodType {
1888
- constructor() {
1889
- super(...arguments);
1890
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
1891
- validation,
1892
- code: ZodIssueCode.invalid_string,
1893
- ...errorUtil.errToObj(message)
1894
- });
1895
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
1896
- this.trim = () => new _ZodString({
1897
- ...this._def,
1898
- checks: [...this._def.checks, { kind: "trim" }]
1899
- });
1900
- }
1901
1985
  _parse(input) {
1902
1986
  if (this._def.coerce) {
1903
1987
  input.data = String(input.data);
@@ -1905,15 +1989,11 @@ var init_lib = __esm({
1905
1989
  const parsedType = this._getType(input);
1906
1990
  if (parsedType !== ZodParsedType.string) {
1907
1991
  const ctx2 = this._getOrReturnCtx(input);
1908
- addIssueToContext(
1909
- ctx2,
1910
- {
1911
- code: ZodIssueCode.invalid_type,
1912
- expected: ZodParsedType.string,
1913
- received: ctx2.parsedType
1914
- }
1915
- //
1916
- );
1992
+ addIssueToContext(ctx2, {
1993
+ code: ZodIssueCode.invalid_type,
1994
+ expected: ZodParsedType.string,
1995
+ received: ctx2.parsedType
1996
+ });
1917
1997
  return INVALID;
1918
1998
  }
1919
1999
  const status = new ParseStatus();
@@ -1981,6 +2061,19 @@ var init_lib = __esm({
1981
2061
  });
1982
2062
  status.dirty();
1983
2063
  }
2064
+ } else if (check.kind === "emoji") {
2065
+ if (!emojiRegex) {
2066
+ emojiRegex = new RegExp(_emojiRegex, "u");
2067
+ }
2068
+ if (!emojiRegex.test(input.data)) {
2069
+ ctx = this._getOrReturnCtx(input, ctx);
2070
+ addIssueToContext(ctx, {
2071
+ validation: "emoji",
2072
+ code: ZodIssueCode.invalid_string,
2073
+ message: check.message
2074
+ });
2075
+ status.dirty();
2076
+ }
1984
2077
  } else if (check.kind === "uuid") {
1985
2078
  if (!uuidRegex.test(input.data)) {
1986
2079
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1991,6 +2084,16 @@ var init_lib = __esm({
1991
2084
  });
1992
2085
  status.dirty();
1993
2086
  }
2087
+ } else if (check.kind === "nanoid") {
2088
+ if (!nanoidRegex.test(input.data)) {
2089
+ ctx = this._getOrReturnCtx(input, ctx);
2090
+ addIssueToContext(ctx, {
2091
+ validation: "nanoid",
2092
+ code: ZodIssueCode.invalid_string,
2093
+ message: check.message
2094
+ });
2095
+ status.dirty();
2096
+ }
1994
2097
  } else if (check.kind === "cuid") {
1995
2098
  if (!cuidRegex.test(input.data)) {
1996
2099
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2001,6 +2104,26 @@ var init_lib = __esm({
2001
2104
  });
2002
2105
  status.dirty();
2003
2106
  }
2107
+ } else if (check.kind === "cuid2") {
2108
+ if (!cuid2Regex.test(input.data)) {
2109
+ ctx = this._getOrReturnCtx(input, ctx);
2110
+ addIssueToContext(ctx, {
2111
+ validation: "cuid2",
2112
+ code: ZodIssueCode.invalid_string,
2113
+ message: check.message
2114
+ });
2115
+ status.dirty();
2116
+ }
2117
+ } else if (check.kind === "ulid") {
2118
+ if (!ulidRegex.test(input.data)) {
2119
+ ctx = this._getOrReturnCtx(input, ctx);
2120
+ addIssueToContext(ctx, {
2121
+ validation: "ulid",
2122
+ code: ZodIssueCode.invalid_string,
2123
+ message: check.message
2124
+ });
2125
+ status.dirty();
2126
+ }
2004
2127
  } else if (check.kind === "url") {
2005
2128
  try {
2006
2129
  new URL(input.data);
@@ -2027,6 +2150,20 @@ var init_lib = __esm({
2027
2150
  }
2028
2151
  } else if (check.kind === "trim") {
2029
2152
  input.data = input.data.trim();
2153
+ } else if (check.kind === "includes") {
2154
+ if (!input.data.includes(check.value, check.position)) {
2155
+ ctx = this._getOrReturnCtx(input, ctx);
2156
+ addIssueToContext(ctx, {
2157
+ code: ZodIssueCode.invalid_string,
2158
+ validation: { includes: check.value, position: check.position },
2159
+ message: check.message
2160
+ });
2161
+ status.dirty();
2162
+ }
2163
+ } else if (check.kind === "toLowerCase") {
2164
+ input.data = input.data.toLowerCase();
2165
+ } else if (check.kind === "toUpperCase") {
2166
+ input.data = input.data.toUpperCase();
2030
2167
  } else if (check.kind === "startsWith") {
2031
2168
  if (!input.data.startsWith(check.value)) {
2032
2169
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2058,12 +2195,71 @@ var init_lib = __esm({
2058
2195
  });
2059
2196
  status.dirty();
2060
2197
  }
2198
+ } else if (check.kind === "date") {
2199
+ const regex = dateRegex;
2200
+ if (!regex.test(input.data)) {
2201
+ ctx = this._getOrReturnCtx(input, ctx);
2202
+ addIssueToContext(ctx, {
2203
+ code: ZodIssueCode.invalid_string,
2204
+ validation: "date",
2205
+ message: check.message
2206
+ });
2207
+ status.dirty();
2208
+ }
2209
+ } else if (check.kind === "time") {
2210
+ const regex = timeRegex(check);
2211
+ if (!regex.test(input.data)) {
2212
+ ctx = this._getOrReturnCtx(input, ctx);
2213
+ addIssueToContext(ctx, {
2214
+ code: ZodIssueCode.invalid_string,
2215
+ validation: "time",
2216
+ message: check.message
2217
+ });
2218
+ status.dirty();
2219
+ }
2220
+ } else if (check.kind === "duration") {
2221
+ if (!durationRegex.test(input.data)) {
2222
+ ctx = this._getOrReturnCtx(input, ctx);
2223
+ addIssueToContext(ctx, {
2224
+ validation: "duration",
2225
+ code: ZodIssueCode.invalid_string,
2226
+ message: check.message
2227
+ });
2228
+ status.dirty();
2229
+ }
2230
+ } else if (check.kind === "ip") {
2231
+ if (!isValidIP(input.data, check.version)) {
2232
+ ctx = this._getOrReturnCtx(input, ctx);
2233
+ addIssueToContext(ctx, {
2234
+ validation: "ip",
2235
+ code: ZodIssueCode.invalid_string,
2236
+ message: check.message
2237
+ });
2238
+ status.dirty();
2239
+ }
2240
+ } else if (check.kind === "base64") {
2241
+ if (!base64Regex.test(input.data)) {
2242
+ ctx = this._getOrReturnCtx(input, ctx);
2243
+ addIssueToContext(ctx, {
2244
+ validation: "base64",
2245
+ code: ZodIssueCode.invalid_string,
2246
+ message: check.message
2247
+ });
2248
+ status.dirty();
2249
+ }
2061
2250
  } else {
2062
2251
  util.assertNever(check);
2063
2252
  }
2064
2253
  }
2065
2254
  return { status: status.value, value: input.data };
2066
2255
  }
2256
+ _regex(regex, validation, message) {
2257
+ return this.refinement((data) => regex.test(data), {
2258
+ validation,
2259
+ code: ZodIssueCode.invalid_string,
2260
+ ...errorUtil.errToObj(message)
2261
+ });
2262
+ }
2067
2263
  _addCheck(check) {
2068
2264
  return new _ZodString({
2069
2265
  ...this._def,
@@ -2076,19 +2272,38 @@ var init_lib = __esm({
2076
2272
  url(message) {
2077
2273
  return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2078
2274
  }
2275
+ emoji(message) {
2276
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
2277
+ }
2079
2278
  uuid(message) {
2080
2279
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2081
2280
  }
2281
+ nanoid(message) {
2282
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2283
+ }
2082
2284
  cuid(message) {
2083
2285
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2084
2286
  }
2287
+ cuid2(message) {
2288
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
2289
+ }
2290
+ ulid(message) {
2291
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2292
+ }
2293
+ base64(message) {
2294
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2295
+ }
2296
+ ip(options) {
2297
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2298
+ }
2085
2299
  datetime(options) {
2086
- var _a;
2300
+ var _a, _b;
2087
2301
  if (typeof options === "string") {
2088
2302
  return this._addCheck({
2089
2303
  kind: "datetime",
2090
2304
  precision: null,
2091
2305
  offset: false,
2306
+ local: false,
2092
2307
  message: options
2093
2308
  });
2094
2309
  }
@@ -2096,9 +2311,30 @@ var init_lib = __esm({
2096
2311
  kind: "datetime",
2097
2312
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2098
2313
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2314
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2315
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2316
+ });
2317
+ }
2318
+ date(message) {
2319
+ return this._addCheck({ kind: "date", message });
2320
+ }
2321
+ time(options) {
2322
+ if (typeof options === "string") {
2323
+ return this._addCheck({
2324
+ kind: "time",
2325
+ precision: null,
2326
+ message: options
2327
+ });
2328
+ }
2329
+ return this._addCheck({
2330
+ kind: "time",
2331
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2099
2332
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2100
2333
  });
2101
2334
  }
2335
+ duration(message) {
2336
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2337
+ }
2102
2338
  regex(regex, message) {
2103
2339
  return this._addCheck({
2104
2340
  kind: "regex",
@@ -2106,6 +2342,14 @@ var init_lib = __esm({
2106
2342
  ...errorUtil.errToObj(message)
2107
2343
  });
2108
2344
  }
2345
+ includes(value, options) {
2346
+ return this._addCheck({
2347
+ kind: "includes",
2348
+ value,
2349
+ position: options === null || options === void 0 ? void 0 : options.position,
2350
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2351
+ });
2352
+ }
2109
2353
  startsWith(value, message) {
2110
2354
  return this._addCheck({
2111
2355
  kind: "startsWith",
@@ -2141,21 +2385,73 @@ var init_lib = __esm({
2141
2385
  ...errorUtil.errToObj(message)
2142
2386
  });
2143
2387
  }
2388
+ /**
2389
+ * @deprecated Use z.string().min(1) instead.
2390
+ * @see {@link ZodString.min}
2391
+ */
2392
+ nonempty(message) {
2393
+ return this.min(1, errorUtil.errToObj(message));
2394
+ }
2395
+ trim() {
2396
+ return new _ZodString({
2397
+ ...this._def,
2398
+ checks: [...this._def.checks, { kind: "trim" }]
2399
+ });
2400
+ }
2401
+ toLowerCase() {
2402
+ return new _ZodString({
2403
+ ...this._def,
2404
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
2405
+ });
2406
+ }
2407
+ toUpperCase() {
2408
+ return new _ZodString({
2409
+ ...this._def,
2410
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
2411
+ });
2412
+ }
2144
2413
  get isDatetime() {
2145
2414
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
2146
2415
  }
2416
+ get isDate() {
2417
+ return !!this._def.checks.find((ch) => ch.kind === "date");
2418
+ }
2419
+ get isTime() {
2420
+ return !!this._def.checks.find((ch) => ch.kind === "time");
2421
+ }
2422
+ get isDuration() {
2423
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
2424
+ }
2147
2425
  get isEmail() {
2148
2426
  return !!this._def.checks.find((ch) => ch.kind === "email");
2149
2427
  }
2150
2428
  get isURL() {
2151
2429
  return !!this._def.checks.find((ch) => ch.kind === "url");
2152
2430
  }
2431
+ get isEmoji() {
2432
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
2433
+ }
2153
2434
  get isUUID() {
2154
2435
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
2155
2436
  }
2437
+ get isNANOID() {
2438
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2439
+ }
2156
2440
  get isCUID() {
2157
2441
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
2158
2442
  }
2443
+ get isCUID2() {
2444
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
2445
+ }
2446
+ get isULID() {
2447
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
2448
+ }
2449
+ get isIP() {
2450
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
2451
+ }
2452
+ get isBase64() {
2453
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
2454
+ }
2159
2455
  get minLength() {
2160
2456
  let min = null;
2161
2457
  for (const ch of this._def.checks) {
@@ -2357,6 +2653,19 @@ var init_lib = __esm({
2357
2653
  message: errorUtil.toString(message)
2358
2654
  });
2359
2655
  }
2656
+ safe(message) {
2657
+ return this._addCheck({
2658
+ kind: "min",
2659
+ inclusive: true,
2660
+ value: Number.MIN_SAFE_INTEGER,
2661
+ message: errorUtil.toString(message)
2662
+ })._addCheck({
2663
+ kind: "max",
2664
+ inclusive: true,
2665
+ value: Number.MAX_SAFE_INTEGER,
2666
+ message: errorUtil.toString(message)
2667
+ });
2668
+ }
2360
2669
  get minValue() {
2361
2670
  let min = null;
2362
2671
  for (const ch of this._def.checks) {
@@ -2378,7 +2687,22 @@ var init_lib = __esm({
2378
2687
  return max;
2379
2688
  }
2380
2689
  get isInt() {
2381
- return !!this._def.checks.find((ch) => ch.kind === "int");
2690
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2691
+ }
2692
+ get isFinite() {
2693
+ let max = null, min = null;
2694
+ for (const ch of this._def.checks) {
2695
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2696
+ return true;
2697
+ } else if (ch.kind === "min") {
2698
+ if (min === null || ch.value > min)
2699
+ min = ch.value;
2700
+ } else if (ch.kind === "max") {
2701
+ if (max === null || ch.value < max)
2702
+ max = ch.value;
2703
+ }
2704
+ }
2705
+ return Number.isFinite(min) && Number.isFinite(max);
2382
2706
  }
2383
2707
  };
2384
2708
  ZodNumber.create = (params) => {
@@ -2389,27 +2713,167 @@ var init_lib = __esm({
2389
2713
  ...processCreateParams(params)
2390
2714
  });
2391
2715
  };
2392
- ZodBigInt = class extends ZodType {
2716
+ ZodBigInt = class _ZodBigInt extends ZodType {
2717
+ constructor() {
2718
+ super(...arguments);
2719
+ this.min = this.gte;
2720
+ this.max = this.lte;
2721
+ }
2393
2722
  _parse(input) {
2394
2723
  if (this._def.coerce) {
2395
2724
  input.data = BigInt(input.data);
2396
2725
  }
2397
2726
  const parsedType = this._getType(input);
2398
2727
  if (parsedType !== ZodParsedType.bigint) {
2399
- const ctx = this._getOrReturnCtx(input);
2400
- addIssueToContext(ctx, {
2728
+ const ctx2 = this._getOrReturnCtx(input);
2729
+ addIssueToContext(ctx2, {
2401
2730
  code: ZodIssueCode.invalid_type,
2402
2731
  expected: ZodParsedType.bigint,
2403
- received: ctx.parsedType
2732
+ received: ctx2.parsedType
2404
2733
  });
2405
2734
  return INVALID;
2406
2735
  }
2407
- return OK(input.data);
2736
+ let ctx = void 0;
2737
+ const status = new ParseStatus();
2738
+ for (const check of this._def.checks) {
2739
+ if (check.kind === "min") {
2740
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2741
+ if (tooSmall) {
2742
+ ctx = this._getOrReturnCtx(input, ctx);
2743
+ addIssueToContext(ctx, {
2744
+ code: ZodIssueCode.too_small,
2745
+ type: "bigint",
2746
+ minimum: check.value,
2747
+ inclusive: check.inclusive,
2748
+ message: check.message
2749
+ });
2750
+ status.dirty();
2751
+ }
2752
+ } else if (check.kind === "max") {
2753
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2754
+ if (tooBig) {
2755
+ ctx = this._getOrReturnCtx(input, ctx);
2756
+ addIssueToContext(ctx, {
2757
+ code: ZodIssueCode.too_big,
2758
+ type: "bigint",
2759
+ maximum: check.value,
2760
+ inclusive: check.inclusive,
2761
+ message: check.message
2762
+ });
2763
+ status.dirty();
2764
+ }
2765
+ } else if (check.kind === "multipleOf") {
2766
+ if (input.data % check.value !== BigInt(0)) {
2767
+ ctx = this._getOrReturnCtx(input, ctx);
2768
+ addIssueToContext(ctx, {
2769
+ code: ZodIssueCode.not_multiple_of,
2770
+ multipleOf: check.value,
2771
+ message: check.message
2772
+ });
2773
+ status.dirty();
2774
+ }
2775
+ } else {
2776
+ util.assertNever(check);
2777
+ }
2778
+ }
2779
+ return { status: status.value, value: input.data };
2780
+ }
2781
+ gte(value, message) {
2782
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2783
+ }
2784
+ gt(value, message) {
2785
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2786
+ }
2787
+ lte(value, message) {
2788
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2789
+ }
2790
+ lt(value, message) {
2791
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2792
+ }
2793
+ setLimit(kind, value, inclusive, message) {
2794
+ return new _ZodBigInt({
2795
+ ...this._def,
2796
+ checks: [
2797
+ ...this._def.checks,
2798
+ {
2799
+ kind,
2800
+ value,
2801
+ inclusive,
2802
+ message: errorUtil.toString(message)
2803
+ }
2804
+ ]
2805
+ });
2806
+ }
2807
+ _addCheck(check) {
2808
+ return new _ZodBigInt({
2809
+ ...this._def,
2810
+ checks: [...this._def.checks, check]
2811
+ });
2812
+ }
2813
+ positive(message) {
2814
+ return this._addCheck({
2815
+ kind: "min",
2816
+ value: BigInt(0),
2817
+ inclusive: false,
2818
+ message: errorUtil.toString(message)
2819
+ });
2820
+ }
2821
+ negative(message) {
2822
+ return this._addCheck({
2823
+ kind: "max",
2824
+ value: BigInt(0),
2825
+ inclusive: false,
2826
+ message: errorUtil.toString(message)
2827
+ });
2828
+ }
2829
+ nonpositive(message) {
2830
+ return this._addCheck({
2831
+ kind: "max",
2832
+ value: BigInt(0),
2833
+ inclusive: true,
2834
+ message: errorUtil.toString(message)
2835
+ });
2836
+ }
2837
+ nonnegative(message) {
2838
+ return this._addCheck({
2839
+ kind: "min",
2840
+ value: BigInt(0),
2841
+ inclusive: true,
2842
+ message: errorUtil.toString(message)
2843
+ });
2844
+ }
2845
+ multipleOf(value, message) {
2846
+ return this._addCheck({
2847
+ kind: "multipleOf",
2848
+ value,
2849
+ message: errorUtil.toString(message)
2850
+ });
2851
+ }
2852
+ get minValue() {
2853
+ let min = null;
2854
+ for (const ch of this._def.checks) {
2855
+ if (ch.kind === "min") {
2856
+ if (min === null || ch.value > min)
2857
+ min = ch.value;
2858
+ }
2859
+ }
2860
+ return min;
2861
+ }
2862
+ get maxValue() {
2863
+ let max = null;
2864
+ for (const ch of this._def.checks) {
2865
+ if (ch.kind === "max") {
2866
+ if (max === null || ch.value < max)
2867
+ max = ch.value;
2868
+ }
2869
+ }
2870
+ return max;
2408
2871
  }
2409
2872
  };
2410
2873
  ZodBigInt.create = (params) => {
2411
2874
  var _a;
2412
2875
  return new ZodBigInt({
2876
+ checks: [],
2413
2877
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
2414
2878
  coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2415
2879
  ...processCreateParams(params)
@@ -2735,13 +3199,13 @@ var init_lib = __esm({
2735
3199
  }
2736
3200
  }
2737
3201
  if (ctx.common.async) {
2738
- return Promise.all(ctx.data.map((item, i) => {
3202
+ return Promise.all([...ctx.data].map((item, i) => {
2739
3203
  return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2740
3204
  })).then((result2) => {
2741
3205
  return ParseStatus.mergeArray(status, result2);
2742
3206
  });
2743
3207
  }
2744
- const result = ctx.data.map((item, i) => {
3208
+ const result = [...ctx.data].map((item, i) => {
2745
3209
  return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2746
3210
  });
2747
3211
  return ParseStatus.mergeArray(status, result);
@@ -2781,31 +3245,12 @@ var init_lib = __esm({
2781
3245
  ...processCreateParams(params)
2782
3246
  });
2783
3247
  };
2784
- (function(objectUtil2) {
2785
- objectUtil2.mergeShapes = (first, second) => {
2786
- return {
2787
- ...first,
2788
- ...second
2789
- // second overwrites first
2790
- };
2791
- };
2792
- })(objectUtil || (objectUtil = {}));
2793
- AugmentFactory = (def) => (augmentation) => {
2794
- return new ZodObject({
2795
- ...def,
2796
- shape: () => ({
2797
- ...def.shape(),
2798
- ...augmentation
2799
- })
2800
- });
2801
- };
2802
3248
  ZodObject = class _ZodObject extends ZodType {
2803
3249
  constructor() {
2804
3250
  super(...arguments);
2805
3251
  this._cached = null;
2806
3252
  this.nonstrict = this.passthrough;
2807
- this.augment = AugmentFactory(this._def);
2808
- this.extend = AugmentFactory(this._def);
3253
+ this.augment = this.extend;
2809
3254
  }
2810
3255
  _getCached() {
2811
3256
  if (this._cached !== null)
@@ -2886,9 +3331,10 @@ var init_lib = __esm({
2886
3331
  const syncPairs = [];
2887
3332
  for (const pair of pairs) {
2888
3333
  const key = await pair.key;
3334
+ const value = await pair.value;
2889
3335
  syncPairs.push({
2890
3336
  key,
2891
- value: await pair.value,
3337
+ value,
2892
3338
  alwaysSet: pair.alwaysSet
2893
3339
  });
2894
3340
  }
@@ -2935,8 +3381,31 @@ var init_lib = __esm({
2935
3381
  unknownKeys: "passthrough"
2936
3382
  });
2937
3383
  }
2938
- setKey(key, schema3) {
2939
- return this.augment({ [key]: schema3 });
3384
+ // const AugmentFactory =
3385
+ // <Def extends ZodObjectDef>(def: Def) =>
3386
+ // <Augmentation extends ZodRawShape>(
3387
+ // augmentation: Augmentation
3388
+ // ): ZodObject<
3389
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
3390
+ // Def["unknownKeys"],
3391
+ // Def["catchall"]
3392
+ // > => {
3393
+ // return new ZodObject({
3394
+ // ...def,
3395
+ // shape: () => ({
3396
+ // ...def.shape(),
3397
+ // ...augmentation,
3398
+ // }),
3399
+ // }) as any;
3400
+ // };
3401
+ extend(augmentation) {
3402
+ return new _ZodObject({
3403
+ ...this._def,
3404
+ shape: () => ({
3405
+ ...this._def.shape(),
3406
+ ...augmentation
3407
+ })
3408
+ });
2940
3409
  }
2941
3410
  /**
2942
3411
  * Prior to zod@1.0.12 there was a bug in the
@@ -2947,11 +3416,73 @@ var init_lib = __esm({
2947
3416
  const merged = new _ZodObject({
2948
3417
  unknownKeys: merging._def.unknownKeys,
2949
3418
  catchall: merging._def.catchall,
2950
- shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3419
+ shape: () => ({
3420
+ ...this._def.shape(),
3421
+ ...merging._def.shape()
3422
+ }),
2951
3423
  typeName: ZodFirstPartyTypeKind.ZodObject
2952
3424
  });
2953
3425
  return merged;
2954
3426
  }
3427
+ // merge<
3428
+ // Incoming extends AnyZodObject,
3429
+ // Augmentation extends Incoming["shape"],
3430
+ // NewOutput extends {
3431
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3432
+ // ? Augmentation[k]["_output"]
3433
+ // : k extends keyof Output
3434
+ // ? Output[k]
3435
+ // : never;
3436
+ // },
3437
+ // NewInput extends {
3438
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3439
+ // ? Augmentation[k]["_input"]
3440
+ // : k extends keyof Input
3441
+ // ? Input[k]
3442
+ // : never;
3443
+ // }
3444
+ // >(
3445
+ // merging: Incoming
3446
+ // ): ZodObject<
3447
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3448
+ // Incoming["_def"]["unknownKeys"],
3449
+ // Incoming["_def"]["catchall"],
3450
+ // NewOutput,
3451
+ // NewInput
3452
+ // > {
3453
+ // const merged: any = new ZodObject({
3454
+ // unknownKeys: merging._def.unknownKeys,
3455
+ // catchall: merging._def.catchall,
3456
+ // shape: () =>
3457
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3458
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3459
+ // }) as any;
3460
+ // return merged;
3461
+ // }
3462
+ setKey(key, schema3) {
3463
+ return this.augment({ [key]: schema3 });
3464
+ }
3465
+ // merge<Incoming extends AnyZodObject>(
3466
+ // merging: Incoming
3467
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3468
+ // ZodObject<
3469
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3470
+ // Incoming["_def"]["unknownKeys"],
3471
+ // Incoming["_def"]["catchall"]
3472
+ // > {
3473
+ // // const mergedShape = objectUtil.mergeShapes(
3474
+ // // this._def.shape(),
3475
+ // // merging._def.shape()
3476
+ // // );
3477
+ // const merged: any = new ZodObject({
3478
+ // unknownKeys: merging._def.unknownKeys,
3479
+ // catchall: merging._def.catchall,
3480
+ // shape: () =>
3481
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3482
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3483
+ // }) as any;
3484
+ // return merged;
3485
+ // }
2955
3486
  catchall(index4) {
2956
3487
  return new _ZodObject({
2957
3488
  ...this._def,
@@ -2960,9 +3491,10 @@ var init_lib = __esm({
2960
3491
  }
2961
3492
  pick(mask) {
2962
3493
  const shape = {};
2963
- util.objectKeys(mask).map((key) => {
2964
- if (this.shape[key])
3494
+ util.objectKeys(mask).forEach((key) => {
3495
+ if (mask[key] && this.shape[key]) {
2965
3496
  shape[key] = this.shape[key];
3497
+ }
2966
3498
  });
2967
3499
  return new _ZodObject({
2968
3500
  ...this._def,
@@ -2971,8 +3503,8 @@ var init_lib = __esm({
2971
3503
  }
2972
3504
  omit(mask) {
2973
3505
  const shape = {};
2974
- util.objectKeys(this.shape).map((key) => {
2975
- if (util.objectKeys(mask).indexOf(key) === -1) {
3506
+ util.objectKeys(this.shape).forEach((key) => {
3507
+ if (!mask[key]) {
2976
3508
  shape[key] = this.shape[key];
2977
3509
  }
2978
3510
  });
@@ -2981,29 +3513,22 @@ var init_lib = __esm({
2981
3513
  shape: () => shape
2982
3514
  });
2983
3515
  }
3516
+ /**
3517
+ * @deprecated
3518
+ */
2984
3519
  deepPartial() {
2985
3520
  return deepPartialify(this);
2986
3521
  }
2987
3522
  partial(mask) {
2988
3523
  const newShape = {};
2989
- if (mask) {
2990
- util.objectKeys(this.shape).map((key) => {
2991
- if (util.objectKeys(mask).indexOf(key) === -1) {
2992
- newShape[key] = this.shape[key];
2993
- } else {
2994
- newShape[key] = this.shape[key].optional();
2995
- }
2996
- });
2997
- return new _ZodObject({
2998
- ...this._def,
2999
- shape: () => newShape
3000
- });
3001
- } else {
3002
- for (const key in this.shape) {
3003
- const fieldSchema = this.shape[key];
3524
+ util.objectKeys(this.shape).forEach((key) => {
3525
+ const fieldSchema = this.shape[key];
3526
+ if (mask && !mask[key]) {
3527
+ newShape[key] = fieldSchema;
3528
+ } else {
3004
3529
  newShape[key] = fieldSchema.optional();
3005
3530
  }
3006
- }
3531
+ });
3007
3532
  return new _ZodObject({
3008
3533
  ...this._def,
3009
3534
  shape: () => newShape
@@ -3011,21 +3536,10 @@ var init_lib = __esm({
3011
3536
  }
3012
3537
  required(mask) {
3013
3538
  const newShape = {};
3014
- if (mask) {
3015
- util.objectKeys(this.shape).map((key) => {
3016
- if (util.objectKeys(mask).indexOf(key) === -1) {
3017
- newShape[key] = this.shape[key];
3018
- } else {
3019
- const fieldSchema = this.shape[key];
3020
- let newField = fieldSchema;
3021
- while (newField instanceof ZodOptional) {
3022
- newField = newField._def.innerType;
3023
- }
3024
- newShape[key] = newField;
3025
- }
3026
- });
3027
- } else {
3028
- for (const key in this.shape) {
3539
+ util.objectKeys(this.shape).forEach((key) => {
3540
+ if (mask && !mask[key]) {
3541
+ newShape[key] = this.shape[key];
3542
+ } else {
3029
3543
  const fieldSchema = this.shape[key];
3030
3544
  let newField = fieldSchema;
3031
3545
  while (newField instanceof ZodOptional) {
@@ -3033,7 +3547,7 @@ var init_lib = __esm({
3033
3547
  }
3034
3548
  newShape[key] = newField;
3035
3549
  }
3036
- }
3550
+ });
3037
3551
  return new _ZodObject({
3038
3552
  ...this._def,
3039
3553
  shape: () => newShape
@@ -3171,15 +3685,25 @@ var init_lib = __esm({
3171
3685
  } else if (type instanceof ZodEnum) {
3172
3686
  return type.options;
3173
3687
  } else if (type instanceof ZodNativeEnum) {
3174
- return Object.keys(type.enum);
3688
+ return util.objectValues(type.enum);
3175
3689
  } else if (type instanceof ZodDefault) {
3176
3690
  return getDiscriminator(type._def.innerType);
3177
3691
  } else if (type instanceof ZodUndefined) {
3178
3692
  return [void 0];
3179
3693
  } else if (type instanceof ZodNull) {
3180
3694
  return [null];
3695
+ } else if (type instanceof ZodOptional) {
3696
+ return [void 0, ...getDiscriminator(type.unwrap())];
3697
+ } else if (type instanceof ZodNullable) {
3698
+ return [null, ...getDiscriminator(type.unwrap())];
3699
+ } else if (type instanceof ZodBranded) {
3700
+ return getDiscriminator(type.unwrap());
3701
+ } else if (type instanceof ZodReadonly) {
3702
+ return getDiscriminator(type.unwrap());
3703
+ } else if (type instanceof ZodCatch) {
3704
+ return getDiscriminator(type._def.innerType);
3181
3705
  } else {
3182
- return null;
3706
+ return [];
3183
3707
  }
3184
3708
  };
3185
3709
  ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -3239,7 +3763,7 @@ var init_lib = __esm({
3239
3763
  const optionsMap = /* @__PURE__ */ new Map();
3240
3764
  for (const type of options) {
3241
3765
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3242
- if (!discriminatorValues) {
3766
+ if (!discriminatorValues.length) {
3243
3767
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3244
3768
  }
3245
3769
  for (const value of discriminatorValues) {
@@ -3343,7 +3867,7 @@ var init_lib = __esm({
3343
3867
  });
3344
3868
  status.dirty();
3345
3869
  }
3346
- const items = ctx.data.map((item, itemIndex) => {
3870
+ const items = [...ctx.data].map((item, itemIndex) => {
3347
3871
  const schema3 = this._def.items[itemIndex] || this._def.rest;
3348
3872
  if (!schema3)
3349
3873
  return null;
@@ -3401,7 +3925,8 @@ var init_lib = __esm({
3401
3925
  for (const key in ctx.data) {
3402
3926
  pairs.push({
3403
3927
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3404
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3928
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3929
+ alwaysSet: key in ctx.data
3405
3930
  });
3406
3931
  }
3407
3932
  if (ctx.common.async) {
@@ -3431,6 +3956,12 @@ var init_lib = __esm({
3431
3956
  }
3432
3957
  };
3433
3958
  ZodMap = class extends ZodType {
3959
+ get keySchema() {
3960
+ return this._def.keyType;
3961
+ }
3962
+ get valueSchema() {
3963
+ return this._def.valueType;
3964
+ }
3434
3965
  _parse(input) {
3435
3966
  const { status, ctx } = this._processInputParams(input);
3436
3967
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -3625,27 +4156,29 @@ var init_lib = __esm({
3625
4156
  const params = { errorMap: ctx.common.contextualErrorMap };
3626
4157
  const fn = ctx.data;
3627
4158
  if (this._def.returns instanceof ZodPromise) {
3628
- return OK(async (...args) => {
4159
+ const me = this;
4160
+ return OK(async function(...args) {
3629
4161
  const error2 = new ZodError([]);
3630
- const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
4162
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3631
4163
  error2.addIssue(makeArgsIssue(args, e));
3632
4164
  throw error2;
3633
4165
  });
3634
- const result = await fn(...parsedArgs);
3635
- const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
4166
+ const result = await Reflect.apply(fn, this, parsedArgs);
4167
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3636
4168
  error2.addIssue(makeReturnsIssue(result, e));
3637
4169
  throw error2;
3638
4170
  });
3639
4171
  return parsedReturns;
3640
4172
  });
3641
4173
  } else {
3642
- return OK((...args) => {
3643
- const parsedArgs = this._def.args.safeParse(args, params);
4174
+ const me = this;
4175
+ return OK(function(...args) {
4176
+ const parsedArgs = me._def.args.safeParse(args, params);
3644
4177
  if (!parsedArgs.success) {
3645
4178
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3646
4179
  }
3647
- const result = fn(...parsedArgs.data);
3648
- const parsedReturns = this._def.returns.safeParse(result, params);
4180
+ const result = Reflect.apply(fn, this, parsedArgs.data);
4181
+ const parsedReturns = me._def.returns.safeParse(result, params);
3649
4182
  if (!parsedReturns.success) {
3650
4183
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3651
4184
  }
@@ -3710,6 +4243,7 @@ var init_lib = __esm({
3710
4243
  if (input.data !== this._def.value) {
3711
4244
  const ctx = this._getOrReturnCtx(input);
3712
4245
  addIssueToContext(ctx, {
4246
+ received: ctx.data,
3713
4247
  code: ZodIssueCode.invalid_literal,
3714
4248
  expected: this._def.value
3715
4249
  });
@@ -3728,7 +4262,11 @@ var init_lib = __esm({
3728
4262
  ...processCreateParams(params)
3729
4263
  });
3730
4264
  };
3731
- ZodEnum = class extends ZodType {
4265
+ ZodEnum = class _ZodEnum extends ZodType {
4266
+ constructor() {
4267
+ super(...arguments);
4268
+ _ZodEnum_cache.set(this, void 0);
4269
+ }
3732
4270
  _parse(input) {
3733
4271
  if (typeof input.data !== "string") {
3734
4272
  const ctx = this._getOrReturnCtx(input);
@@ -3740,7 +4278,10 @@ var init_lib = __esm({
3740
4278
  });
3741
4279
  return INVALID;
3742
4280
  }
3743
- if (this._def.values.indexOf(input.data) === -1) {
4281
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
4282
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
4283
+ }
4284
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3744
4285
  const ctx = this._getOrReturnCtx(input);
3745
4286
  const expectedValues = this._def.values;
3746
4287
  addIssueToContext(ctx, {
@@ -3776,9 +4317,26 @@ var init_lib = __esm({
3776
4317
  }
3777
4318
  return enumValues;
3778
4319
  }
4320
+ extract(values, newDef = this._def) {
4321
+ return _ZodEnum.create(values, {
4322
+ ...this._def,
4323
+ ...newDef
4324
+ });
4325
+ }
4326
+ exclude(values, newDef = this._def) {
4327
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4328
+ ...this._def,
4329
+ ...newDef
4330
+ });
4331
+ }
3779
4332
  };
4333
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3780
4334
  ZodEnum.create = createZodEnum;
3781
4335
  ZodNativeEnum = class extends ZodType {
4336
+ constructor() {
4337
+ super(...arguments);
4338
+ _ZodNativeEnum_cache.set(this, void 0);
4339
+ }
3782
4340
  _parse(input) {
3783
4341
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3784
4342
  const ctx = this._getOrReturnCtx(input);
@@ -3791,7 +4349,10 @@ var init_lib = __esm({
3791
4349
  });
3792
4350
  return INVALID;
3793
4351
  }
3794
- if (nativeEnumValues.indexOf(input.data) === -1) {
4352
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
4353
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
4354
+ }
4355
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3795
4356
  const expectedValues = util.objectValues(nativeEnumValues);
3796
4357
  addIssueToContext(ctx, {
3797
4358
  received: ctx.data,
@@ -3806,6 +4367,7 @@ var init_lib = __esm({
3806
4367
  return this._def.values;
3807
4368
  }
3808
4369
  };
4370
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3809
4371
  ZodNativeEnum.create = (values, params) => {
3810
4372
  return new ZodNativeEnum({
3811
4373
  values,
@@ -3814,6 +4376,9 @@ var init_lib = __esm({
3814
4376
  });
3815
4377
  };
3816
4378
  ZodPromise = class extends ZodType {
4379
+ unwrap() {
4380
+ return this._def.type;
4381
+ }
3817
4382
  _parse(input) {
3818
4383
  const { ctx } = this._processInputParams(input);
3819
4384
  if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
@@ -3850,24 +4415,6 @@ var init_lib = __esm({
3850
4415
  _parse(input) {
3851
4416
  const { status, ctx } = this._processInputParams(input);
3852
4417
  const effect = this._def.effect || null;
3853
- if (effect.type === "preprocess") {
3854
- const processed = effect.transform(ctx.data);
3855
- if (ctx.common.async) {
3856
- return Promise.resolve(processed).then((processed2) => {
3857
- return this._def.schema._parseAsync({
3858
- data: processed2,
3859
- path: ctx.path,
3860
- parent: ctx
3861
- });
3862
- });
3863
- } else {
3864
- return this._def.schema._parseSync({
3865
- data: processed,
3866
- path: ctx.path,
3867
- parent: ctx
3868
- });
3869
- }
3870
- }
3871
4418
  const checkCtx = {
3872
4419
  addIssue: (arg) => {
3873
4420
  addIssueToContext(ctx, arg);
@@ -3882,6 +4429,42 @@ var init_lib = __esm({
3882
4429
  }
3883
4430
  };
3884
4431
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4432
+ if (effect.type === "preprocess") {
4433
+ const processed = effect.transform(ctx.data, checkCtx);
4434
+ if (ctx.common.async) {
4435
+ return Promise.resolve(processed).then(async (processed2) => {
4436
+ if (status.value === "aborted")
4437
+ return INVALID;
4438
+ const result = await this._def.schema._parseAsync({
4439
+ data: processed2,
4440
+ path: ctx.path,
4441
+ parent: ctx
4442
+ });
4443
+ if (result.status === "aborted")
4444
+ return INVALID;
4445
+ if (result.status === "dirty")
4446
+ return DIRTY(result.value);
4447
+ if (status.value === "dirty")
4448
+ return DIRTY(result.value);
4449
+ return result;
4450
+ });
4451
+ } else {
4452
+ if (status.value === "aborted")
4453
+ return INVALID;
4454
+ const result = this._def.schema._parseSync({
4455
+ data: processed,
4456
+ path: ctx.path,
4457
+ parent: ctx
4458
+ });
4459
+ if (result.status === "aborted")
4460
+ return INVALID;
4461
+ if (result.status === "dirty")
4462
+ return DIRTY(result.value);
4463
+ if (status.value === "dirty")
4464
+ return DIRTY(result.value);
4465
+ return result;
4466
+ }
4467
+ }
3885
4468
  if (effect.type === "refinement") {
3886
4469
  const executeRefinement = (acc) => {
3887
4470
  const result = effect.refinement(acc, checkCtx);
@@ -4024,26 +4607,45 @@ var init_lib = __esm({
4024
4607
  ZodCatch = class extends ZodType {
4025
4608
  _parse(input) {
4026
4609
  const { ctx } = this._processInputParams(input);
4610
+ const newCtx = {
4611
+ ...ctx,
4612
+ common: {
4613
+ ...ctx.common,
4614
+ issues: []
4615
+ }
4616
+ };
4027
4617
  const result = this._def.innerType._parse({
4028
- data: ctx.data,
4029
- path: ctx.path,
4030
- parent: ctx
4618
+ data: newCtx.data,
4619
+ path: newCtx.path,
4620
+ parent: {
4621
+ ...newCtx
4622
+ }
4031
4623
  });
4032
4624
  if (isAsync(result)) {
4033
4625
  return result.then((result2) => {
4034
4626
  return {
4035
4627
  status: "valid",
4036
- value: result2.status === "valid" ? result2.value : this._def.defaultValue()
4628
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
4629
+ get error() {
4630
+ return new ZodError(newCtx.common.issues);
4631
+ },
4632
+ input: newCtx.data
4633
+ })
4037
4634
  };
4038
4635
  });
4039
4636
  } else {
4040
4637
  return {
4041
4638
  status: "valid",
4042
- value: result.status === "valid" ? result.value : this._def.defaultValue()
4639
+ value: result.status === "valid" ? result.value : this._def.catchValue({
4640
+ get error() {
4641
+ return new ZodError(newCtx.common.issues);
4642
+ },
4643
+ input: newCtx.data
4644
+ })
4043
4645
  };
4044
4646
  }
4045
4647
  }
4046
- removeDefault() {
4648
+ removeCatch() {
4047
4649
  return this._def.innerType;
4048
4650
  }
4049
4651
  };
@@ -4051,7 +4653,7 @@ var init_lib = __esm({
4051
4653
  return new ZodCatch({
4052
4654
  innerType: type,
4053
4655
  typeName: ZodFirstPartyTypeKind.ZodCatch,
4054
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4656
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4055
4657
  ...processCreateParams(params)
4056
4658
  });
4057
4659
  };
@@ -4146,6 +4748,28 @@ var init_lib = __esm({
4146
4748
  });
4147
4749
  }
4148
4750
  };
4751
+ ZodReadonly = class extends ZodType {
4752
+ _parse(input) {
4753
+ const result = this._def.innerType._parse(input);
4754
+ const freeze = (data) => {
4755
+ if (isValid(data)) {
4756
+ data.value = Object.freeze(data.value);
4757
+ }
4758
+ return data;
4759
+ };
4760
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
4761
+ }
4762
+ unwrap() {
4763
+ return this._def.innerType;
4764
+ }
4765
+ };
4766
+ ZodReadonly.create = (type, params) => {
4767
+ return new ZodReadonly({
4768
+ innerType: type,
4769
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4770
+ ...processCreateParams(params)
4771
+ });
4772
+ };
4149
4773
  late = {
4150
4774
  object: ZodObject.lazycreate
4151
4775
  };
@@ -4185,6 +4809,7 @@ var init_lib = __esm({
4185
4809
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4186
4810
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4187
4811
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4812
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4188
4813
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4189
4814
  stringType = ZodString.create;
4190
4815
  numberType = ZodNumber.create;
@@ -4764,19 +5389,54 @@ var init_utils = __esm({
4764
5389
  init_mysqlSchema();
4765
5390
  init_pgSchema();
4766
5391
  init_sqliteSchema();
4767
- init_source();
4768
5392
  init_global();
4769
5393
  }
4770
5394
  });
4771
5395
 
4772
5396
  // src/cli/views.ts
4773
- var import_hanji;
5397
+ var import_hanji, Spinner, ProgressView;
4774
5398
  var init_views = __esm({
4775
5399
  "src/cli/views.ts"() {
4776
5400
  "use strict";
4777
5401
  init_source();
4778
5402
  import_hanji = __toESM(require_hanji());
4779
5403
  init_utils();
5404
+ Spinner = class {
5405
+ constructor(frames) {
5406
+ this.frames = frames;
5407
+ this.offset = 0;
5408
+ this.tick = () => {
5409
+ this.iterator();
5410
+ };
5411
+ this.value = () => {
5412
+ return this.frames[this.offset];
5413
+ };
5414
+ this.iterator = () => {
5415
+ this.offset += 1;
5416
+ this.offset %= frames.length - 1;
5417
+ };
5418
+ }
5419
+ };
5420
+ ProgressView = class extends import_hanji.TaskView {
5421
+ constructor(progressText, successText) {
5422
+ super();
5423
+ this.progressText = progressText;
5424
+ this.successText = successText;
5425
+ this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
5426
+ this.timeout = setInterval(() => {
5427
+ this.spinner.tick();
5428
+ this.requestLayout();
5429
+ }, 128);
5430
+ this.on("detach", () => clearInterval(this.timeout));
5431
+ }
5432
+ render(status) {
5433
+ if (status === "pending") {
5434
+ const spin = this.spinner.value();
5435
+ return `[${spin}] ${this.progressText}`;
5436
+ }
5437
+ return `[${source_default.green("\u2713")}] ${this.successText}`;
5438
+ }
5439
+ };
4780
5440
  }
4781
5441
  });
4782
5442
 
@@ -4785,7 +5445,6 @@ import * as glob from "glob";
4785
5445
  var init_serializer = __esm({
4786
5446
  "src/serializer/index.ts"() {
4787
5447
  "use strict";
4788
- init_source();
4789
5448
  init_views();
4790
5449
  }
4791
5450
  });
@@ -4794,7 +5453,6 @@ var init_serializer = __esm({
4794
5453
  var init_outputs = __esm({
4795
5454
  "src/cli/validations/outputs.ts"() {
4796
5455
  "use strict";
4797
- init_source();
4798
5456
  }
4799
5457
  });
4800
5458
 
@@ -4853,7 +5511,6 @@ var init_sqliteSerializer = __esm({
4853
5511
  "use strict";
4854
5512
  init_serializer();
4855
5513
  init_outputs();
4856
- init_source();
4857
5514
  dialect3 = new SQLiteSyncDialect();
4858
5515
  fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
4859
5516
  const result = {};
@@ -4861,12 +5518,24 @@ var init_sqliteSerializer = __esm({
4861
5518
  `SELECT
4862
5519
  m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
4863
5520
  FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
4864
- WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table' and m.tbl_name != '__drizzle_migrations';
5521
+ WHERE m.type = 'table'
5522
+ and m.tbl_name != 'sqlite_sequence'
5523
+ and m.tbl_name != 'sqlite_stat1'
5524
+ and m.tbl_name != '_litestream_seq'
5525
+ and m.tbl_name != '_litestream_lock'
5526
+ and m.tbl_name != 'libsql_wasm_func_table'
5527
+ and m.tbl_name != '__drizzle_migrations'
5528
+ and m.tbl_name != '_cf_KV';
4865
5529
  `
4866
5530
  );
4867
5531
  const tablesWithSeq = [];
4868
5532
  const seq = await db.query(
4869
- `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence' and name != 'sqlite_stat1' and name != '_litestream_seq' and name != '_litestream_lock' and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
5533
+ `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
5534
+ and name != 'sqlite_stat1'
5535
+ and name != '_litestream_seq'
5536
+ and name != '_litestream_lock'
5537
+ and tbl_name != '_cf_KV'
5538
+ and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
4870
5539
  );
4871
5540
  for (const s of seq) {
4872
5541
  tablesWithSeq.push(s.name);
@@ -4951,7 +5620,8 @@ var init_sqliteSerializer = __esm({
4951
5620
  try {
4952
5621
  const fks = await db.query(
4953
5622
  `SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
4954
- FROM sqlite_master m, pragma_foreign_key_list(m.name) as f;`
5623
+ FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
5624
+ where m.tbl_name != '_cf_KV';`
4955
5625
  );
4956
5626
  const fkByTableName = {};
4957
5627
  for (const fkRow of fks) {
@@ -5010,7 +5680,9 @@ FROM sqlite_master AS m,
5010
5680
  pragma_index_list(m.name) AS il,
5011
5681
  pragma_index_info(il.name) AS ii
5012
5682
  WHERE
5013
- m.type = 'table' and il.name NOT LIKE 'sqlite_autoindex_%';`
5683
+ m.type = 'table'
5684
+ and il.name NOT LIKE 'sqlite_autoindex_%'
5685
+ and m.tbl_name != '_cf_KV';`
5014
5686
  );
5015
5687
  for (const idxRow of idxs) {
5016
5688
  const tableName = idxRow.tableName;
@@ -5276,7 +5948,6 @@ var init_pgSerializer = __esm({
5276
5948
  "src/serializer/pgSerializer.ts"() {
5277
5949
  "use strict";
5278
5950
  init_serializer();
5279
- init_source();
5280
5951
  init_outputs();
5281
5952
  dialect4 = new PgDialect();
5282
5953
  trimChar = (str, char) => {
@@ -5644,6 +6315,7 @@ var init_pgSerializer = __esm({
5644
6315
  "time without time zone": "::time without time zone",
5645
6316
  // "timestamp with time zone": "::timestamp with time zone",
5646
6317
  "timestamp without time zone": "::timestamp without time zone",
6318
+ "timestamp(": "::timestamp without time zone",
5647
6319
  // date: "::date",
5648
6320
  // interval: "::interval",
5649
6321
  // character: "::bpchar",
@@ -5656,15 +6328,15 @@ var init_pgSerializer = __esm({
5656
6328
  "character(": "::bpchar"
5657
6329
  };
5658
6330
  defaultForColumn = (column4) => {
6331
+ if (column4.column_default === null) {
6332
+ return void 0;
6333
+ }
5659
6334
  if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
5660
6335
  return void 0;
5661
6336
  }
5662
6337
  const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
5663
6338
  (it) => column4.data_type.startsWith(it)
5664
6339
  );
5665
- if (column4.column_default === null) {
5666
- return void 0;
5667
- }
5668
6340
  const columnDefaultAsString = column4.column_default.toString();
5669
6341
  if (columnDefaultAsString.endsWith(
5670
6342
  hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
@@ -5994,10 +6666,10 @@ Array.prototype.random = function() {
5994
6666
  return this[~~(Math.random() * this.length)];
5995
6667
  };
5996
6668
 
5997
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
6669
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
5998
6670
  var import_brace_expansion = __toESM(require_brace_expansion(), 1);
5999
6671
 
6000
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js
6672
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
6001
6673
  var posixClasses = {
6002
6674
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
6003
6675
  "[:alpha:]": ["\\p{L}\\p{Nl}", true],
@@ -6107,17 +6779,17 @@ var parseClass = (glob2, position) => {
6107
6779
  return [comb, uflag, endPos - pos, true];
6108
6780
  };
6109
6781
 
6110
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js
6782
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js
6111
6783
  var escape = (s, { windowsPathsNoEscape = false } = {}) => {
6112
6784
  return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
6113
6785
  };
6114
6786
 
6115
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js
6787
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js
6116
6788
  var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
6117
6789
  return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
6118
6790
  };
6119
6791
 
6120
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
6792
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
6121
6793
  var minimatch = (p, pattern, options = {}) => {
6122
6794
  assertValidPattern(pattern);
6123
6795
  if (!options.nocomment && pattern.charAt(0) === "#") {
@@ -7056,7 +7728,14 @@ var sqlitePushIntrospect = async (db, filters) => {
7056
7728
  }
7057
7729
  return false;
7058
7730
  };
7059
- const res = await fromDatabase(db, filter2);
7731
+ const progress = new ProgressView(
7732
+ "Pulling schema from database...",
7733
+ "Pulling schema from database..."
7734
+ );
7735
+ const res = await (0, import_hanji2.renderWithTask)(
7736
+ progress,
7737
+ fromDatabase(db, filter2)
7738
+ );
7060
7739
  const schema3 = { id: originUUID, prevId: "", ...res };
7061
7740
  return { schema: schema3 };
7062
7741
  };
@@ -7064,6 +7743,8 @@ var sqlitePushIntrospect = async (db, filters) => {
7064
7743
  // src/cli/commands/pgIntrospect.ts
7065
7744
  init_pgSerializer();
7066
7745
  init_global();
7746
+ init_views();
7747
+ var import_hanji3 = __toESM(require_hanji());
7067
7748
  var pgPushIntrospect = async (db, filters, schemaFilters) => {
7068
7749
  const matchers = filters.map((it) => {
7069
7750
  return new Minimatch(it);
@@ -7078,7 +7759,14 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
7078
7759
  }
7079
7760
  return false;
7080
7761
  };
7081
- const res = await fromDatabase2(db, filter2, schemaFilters);
7762
+ const progress = new ProgressView(
7763
+ "Pulling schema from database...",
7764
+ "Pulling schema from database..."
7765
+ );
7766
+ const res = await (0, import_hanji3.renderWithTask)(
7767
+ progress,
7768
+ fromDatabase2(db, filter2, schemaFilters)
7769
+ );
7082
7770
  const schema3 = { id: originUUID, prevId: "", ...res };
7083
7771
  const { internal, ...schemaWithoutInternals } = schema3;
7084
7772
  return { schema: schemaWithoutInternals };