drizzle-kit 0.20.17-e041df8 → 0.20.17-e0821c1

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) {
@@ -2218,23 +2513,253 @@ var init_lib = __esm({
2218
2513
  ...processCreateParams(params)
2219
2514
  });
2220
2515
  };
2221
- ZodNumber = class _ZodNumber extends ZodType {
2516
+ ZodNumber = class _ZodNumber extends ZodType {
2517
+ constructor() {
2518
+ super(...arguments);
2519
+ this.min = this.gte;
2520
+ this.max = this.lte;
2521
+ this.step = this.multipleOf;
2522
+ }
2523
+ _parse(input) {
2524
+ if (this._def.coerce) {
2525
+ input.data = Number(input.data);
2526
+ }
2527
+ const parsedType = this._getType(input);
2528
+ if (parsedType !== ZodParsedType.number) {
2529
+ const ctx2 = this._getOrReturnCtx(input);
2530
+ addIssueToContext(ctx2, {
2531
+ code: ZodIssueCode.invalid_type,
2532
+ expected: ZodParsedType.number,
2533
+ received: ctx2.parsedType
2534
+ });
2535
+ return INVALID;
2536
+ }
2537
+ let ctx = void 0;
2538
+ const status = new ParseStatus();
2539
+ for (const check of this._def.checks) {
2540
+ if (check.kind === "int") {
2541
+ if (!util.isInteger(input.data)) {
2542
+ ctx = this._getOrReturnCtx(input, ctx);
2543
+ addIssueToContext(ctx, {
2544
+ code: ZodIssueCode.invalid_type,
2545
+ expected: "integer",
2546
+ received: "float",
2547
+ message: check.message
2548
+ });
2549
+ status.dirty();
2550
+ }
2551
+ } else if (check.kind === "min") {
2552
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2553
+ if (tooSmall) {
2554
+ ctx = this._getOrReturnCtx(input, ctx);
2555
+ addIssueToContext(ctx, {
2556
+ code: ZodIssueCode.too_small,
2557
+ minimum: check.value,
2558
+ type: "number",
2559
+ inclusive: check.inclusive,
2560
+ exact: false,
2561
+ message: check.message
2562
+ });
2563
+ status.dirty();
2564
+ }
2565
+ } else if (check.kind === "max") {
2566
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2567
+ if (tooBig) {
2568
+ ctx = this._getOrReturnCtx(input, ctx);
2569
+ addIssueToContext(ctx, {
2570
+ code: ZodIssueCode.too_big,
2571
+ maximum: check.value,
2572
+ type: "number",
2573
+ inclusive: check.inclusive,
2574
+ exact: false,
2575
+ message: check.message
2576
+ });
2577
+ status.dirty();
2578
+ }
2579
+ } else if (check.kind === "multipleOf") {
2580
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
2581
+ ctx = this._getOrReturnCtx(input, ctx);
2582
+ addIssueToContext(ctx, {
2583
+ code: ZodIssueCode.not_multiple_of,
2584
+ multipleOf: check.value,
2585
+ message: check.message
2586
+ });
2587
+ status.dirty();
2588
+ }
2589
+ } else if (check.kind === "finite") {
2590
+ if (!Number.isFinite(input.data)) {
2591
+ ctx = this._getOrReturnCtx(input, ctx);
2592
+ addIssueToContext(ctx, {
2593
+ code: ZodIssueCode.not_finite,
2594
+ message: check.message
2595
+ });
2596
+ status.dirty();
2597
+ }
2598
+ } else {
2599
+ util.assertNever(check);
2600
+ }
2601
+ }
2602
+ return { status: status.value, value: input.data };
2603
+ }
2604
+ gte(value, message) {
2605
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2606
+ }
2607
+ gt(value, message) {
2608
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2609
+ }
2610
+ lte(value, message) {
2611
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2612
+ }
2613
+ lt(value, message) {
2614
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2615
+ }
2616
+ setLimit(kind, value, inclusive, message) {
2617
+ return new _ZodNumber({
2618
+ ...this._def,
2619
+ checks: [
2620
+ ...this._def.checks,
2621
+ {
2622
+ kind,
2623
+ value,
2624
+ inclusive,
2625
+ message: errorUtil.toString(message)
2626
+ }
2627
+ ]
2628
+ });
2629
+ }
2630
+ _addCheck(check) {
2631
+ return new _ZodNumber({
2632
+ ...this._def,
2633
+ checks: [...this._def.checks, check]
2634
+ });
2635
+ }
2636
+ int(message) {
2637
+ return this._addCheck({
2638
+ kind: "int",
2639
+ message: errorUtil.toString(message)
2640
+ });
2641
+ }
2642
+ positive(message) {
2643
+ return this._addCheck({
2644
+ kind: "min",
2645
+ value: 0,
2646
+ inclusive: false,
2647
+ message: errorUtil.toString(message)
2648
+ });
2649
+ }
2650
+ negative(message) {
2651
+ return this._addCheck({
2652
+ kind: "max",
2653
+ value: 0,
2654
+ inclusive: false,
2655
+ message: errorUtil.toString(message)
2656
+ });
2657
+ }
2658
+ nonpositive(message) {
2659
+ return this._addCheck({
2660
+ kind: "max",
2661
+ value: 0,
2662
+ inclusive: true,
2663
+ message: errorUtil.toString(message)
2664
+ });
2665
+ }
2666
+ nonnegative(message) {
2667
+ return this._addCheck({
2668
+ kind: "min",
2669
+ value: 0,
2670
+ inclusive: true,
2671
+ message: errorUtil.toString(message)
2672
+ });
2673
+ }
2674
+ multipleOf(value, message) {
2675
+ return this._addCheck({
2676
+ kind: "multipleOf",
2677
+ value,
2678
+ message: errorUtil.toString(message)
2679
+ });
2680
+ }
2681
+ finite(message) {
2682
+ return this._addCheck({
2683
+ kind: "finite",
2684
+ message: errorUtil.toString(message)
2685
+ });
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
+ }
2700
+ get minValue() {
2701
+ let min = null;
2702
+ for (const ch of this._def.checks) {
2703
+ if (ch.kind === "min") {
2704
+ if (min === null || ch.value > min)
2705
+ min = ch.value;
2706
+ }
2707
+ }
2708
+ return min;
2709
+ }
2710
+ get maxValue() {
2711
+ let max = null;
2712
+ for (const ch of this._def.checks) {
2713
+ if (ch.kind === "max") {
2714
+ if (max === null || ch.value < max)
2715
+ max = ch.value;
2716
+ }
2717
+ }
2718
+ return max;
2719
+ }
2720
+ get isInt() {
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);
2737
+ }
2738
+ };
2739
+ ZodNumber.create = (params) => {
2740
+ return new ZodNumber({
2741
+ checks: [],
2742
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
2743
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2744
+ ...processCreateParams(params)
2745
+ });
2746
+ };
2747
+ ZodBigInt = class _ZodBigInt extends ZodType {
2222
2748
  constructor() {
2223
2749
  super(...arguments);
2224
2750
  this.min = this.gte;
2225
2751
  this.max = this.lte;
2226
- this.step = this.multipleOf;
2227
2752
  }
2228
2753
  _parse(input) {
2229
2754
  if (this._def.coerce) {
2230
- input.data = Number(input.data);
2755
+ input.data = BigInt(input.data);
2231
2756
  }
2232
2757
  const parsedType = this._getType(input);
2233
- if (parsedType !== ZodParsedType.number) {
2758
+ if (parsedType !== ZodParsedType.bigint) {
2234
2759
  const ctx2 = this._getOrReturnCtx(input);
2235
2760
  addIssueToContext(ctx2, {
2236
2761
  code: ZodIssueCode.invalid_type,
2237
- expected: ZodParsedType.number,
2762
+ expected: ZodParsedType.bigint,
2238
2763
  received: ctx2.parsedType
2239
2764
  });
2240
2765
  return INVALID;
@@ -2242,27 +2767,15 @@ var init_lib = __esm({
2242
2767
  let ctx = void 0;
2243
2768
  const status = new ParseStatus();
2244
2769
  for (const check of this._def.checks) {
2245
- if (check.kind === "int") {
2246
- if (!util.isInteger(input.data)) {
2247
- ctx = this._getOrReturnCtx(input, ctx);
2248
- addIssueToContext(ctx, {
2249
- code: ZodIssueCode.invalid_type,
2250
- expected: "integer",
2251
- received: "float",
2252
- message: check.message
2253
- });
2254
- status.dirty();
2255
- }
2256
- } else if (check.kind === "min") {
2770
+ if (check.kind === "min") {
2257
2771
  const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2258
2772
  if (tooSmall) {
2259
2773
  ctx = this._getOrReturnCtx(input, ctx);
2260
2774
  addIssueToContext(ctx, {
2261
2775
  code: ZodIssueCode.too_small,
2776
+ type: "bigint",
2262
2777
  minimum: check.value,
2263
- type: "number",
2264
2778
  inclusive: check.inclusive,
2265
- exact: false,
2266
2779
  message: check.message
2267
2780
  });
2268
2781
  status.dirty();
@@ -2273,16 +2786,15 @@ var init_lib = __esm({
2273
2786
  ctx = this._getOrReturnCtx(input, ctx);
2274
2787
  addIssueToContext(ctx, {
2275
2788
  code: ZodIssueCode.too_big,
2789
+ type: "bigint",
2276
2790
  maximum: check.value,
2277
- type: "number",
2278
2791
  inclusive: check.inclusive,
2279
- exact: false,
2280
2792
  message: check.message
2281
2793
  });
2282
2794
  status.dirty();
2283
2795
  }
2284
2796
  } else if (check.kind === "multipleOf") {
2285
- if (floatSafeRemainder(input.data, check.value) !== 0) {
2797
+ if (input.data % check.value !== BigInt(0)) {
2286
2798
  ctx = this._getOrReturnCtx(input, ctx);
2287
2799
  addIssueToContext(ctx, {
2288
2800
  code: ZodIssueCode.not_multiple_of,
@@ -2291,15 +2803,6 @@ var init_lib = __esm({
2291
2803
  });
2292
2804
  status.dirty();
2293
2805
  }
2294
- } else if (check.kind === "finite") {
2295
- if (!Number.isFinite(input.data)) {
2296
- ctx = this._getOrReturnCtx(input, ctx);
2297
- addIssueToContext(ctx, {
2298
- code: ZodIssueCode.not_finite,
2299
- message: check.message
2300
- });
2301
- status.dirty();
2302
- }
2303
2806
  } else {
2304
2807
  util.assertNever(check);
2305
2808
  }
@@ -2319,7 +2822,7 @@ var init_lib = __esm({
2319
2822
  return this.setLimit("max", value, false, errorUtil.toString(message));
2320
2823
  }
2321
2824
  setLimit(kind, value, inclusive, message) {
2322
- return new _ZodNumber({
2825
+ return new _ZodBigInt({
2323
2826
  ...this._def,
2324
2827
  checks: [
2325
2828
  ...this._def.checks,
@@ -2333,21 +2836,15 @@ var init_lib = __esm({
2333
2836
  });
2334
2837
  }
2335
2838
  _addCheck(check) {
2336
- return new _ZodNumber({
2839
+ return new _ZodBigInt({
2337
2840
  ...this._def,
2338
2841
  checks: [...this._def.checks, check]
2339
2842
  });
2340
2843
  }
2341
- int(message) {
2342
- return this._addCheck({
2343
- kind: "int",
2344
- message: errorUtil.toString(message)
2345
- });
2346
- }
2347
2844
  positive(message) {
2348
2845
  return this._addCheck({
2349
2846
  kind: "min",
2350
- value: 0,
2847
+ value: BigInt(0),
2351
2848
  inclusive: false,
2352
2849
  message: errorUtil.toString(message)
2353
2850
  });
@@ -2355,7 +2852,7 @@ var init_lib = __esm({
2355
2852
  negative(message) {
2356
2853
  return this._addCheck({
2357
2854
  kind: "max",
2358
- value: 0,
2855
+ value: BigInt(0),
2359
2856
  inclusive: false,
2360
2857
  message: errorUtil.toString(message)
2361
2858
  });
@@ -2363,7 +2860,7 @@ var init_lib = __esm({
2363
2860
  nonpositive(message) {
2364
2861
  return this._addCheck({
2365
2862
  kind: "max",
2366
- value: 0,
2863
+ value: BigInt(0),
2367
2864
  inclusive: true,
2368
2865
  message: errorUtil.toString(message)
2369
2866
  });
@@ -2371,7 +2868,7 @@ var init_lib = __esm({
2371
2868
  nonnegative(message) {
2372
2869
  return this._addCheck({
2373
2870
  kind: "min",
2374
- value: 0,
2871
+ value: BigInt(0),
2375
2872
  inclusive: true,
2376
2873
  message: errorUtil.toString(message)
2377
2874
  });
@@ -2383,12 +2880,6 @@ var init_lib = __esm({
2383
2880
  message: errorUtil.toString(message)
2384
2881
  });
2385
2882
  }
2386
- finite(message) {
2387
- return this._addCheck({
2388
- kind: "finite",
2389
- message: errorUtil.toString(message)
2390
- });
2391
- }
2392
2883
  get minValue() {
2393
2884
  let min = null;
2394
2885
  for (const ch of this._def.checks) {
@@ -2409,39 +2900,11 @@ var init_lib = __esm({
2409
2900
  }
2410
2901
  return max;
2411
2902
  }
2412
- get isInt() {
2413
- return !!this._def.checks.find((ch) => ch.kind === "int");
2414
- }
2415
- };
2416
- ZodNumber.create = (params) => {
2417
- return new ZodNumber({
2418
- checks: [],
2419
- typeName: ZodFirstPartyTypeKind.ZodNumber,
2420
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2421
- ...processCreateParams(params)
2422
- });
2423
- };
2424
- ZodBigInt = class extends ZodType {
2425
- _parse(input) {
2426
- if (this._def.coerce) {
2427
- input.data = BigInt(input.data);
2428
- }
2429
- const parsedType = this._getType(input);
2430
- if (parsedType !== ZodParsedType.bigint) {
2431
- const ctx = this._getOrReturnCtx(input);
2432
- addIssueToContext(ctx, {
2433
- code: ZodIssueCode.invalid_type,
2434
- expected: ZodParsedType.bigint,
2435
- received: ctx.parsedType
2436
- });
2437
- return INVALID;
2438
- }
2439
- return OK(input.data);
2440
- }
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
  };
@@ -4701,7 +5325,7 @@ var init_pgSchema = __esm({
4701
5325
  }).strict();
4702
5326
  pgSchemaInternal = objectType({
4703
5327
  version: literalType("6"),
4704
- dialect: literalType("pg"),
5328
+ dialect: literalType("postgresql"),
4705
5329
  tables: recordType(stringType(), table2),
4706
5330
  enums: recordType(stringType(), enumSchema),
4707
5331
  schemas: recordType(stringType(), stringType()),
@@ -4730,14 +5354,14 @@ var init_pgSchema = __esm({
4730
5354
  }).strict();
4731
5355
  pgSchemaSquashedV4 = objectType({
4732
5356
  version: literalType("4"),
4733
- dialect: enumType(["pg"]),
5357
+ dialect: literalType("pg"),
4734
5358
  tables: recordType(stringType(), tableSquashedV42),
4735
5359
  enums: recordType(stringType(), enumSchemaV1),
4736
5360
  schemas: recordType(stringType(), stringType())
4737
5361
  }).strict();
4738
5362
  pgSchemaSquashed = objectType({
4739
5363
  version: literalType("6"),
4740
- dialect: enumType(["pg"]),
5364
+ dialect: literalType("postgresql"),
4741
5365
  tables: recordType(stringType(), tableSquashed2),
4742
5366
  enums: recordType(stringType(), enumSchema),
4743
5367
  schemas: recordType(stringType(), stringType())
@@ -4848,7 +5472,7 @@ var init_pgSchema = __esm({
4848
5472
  };
4849
5473
  dryPg = pgSchema.parse({
4850
5474
  version: snapshotVersion,
4851
- dialect: "pg",
5475
+ dialect: "postgresql",
4852
5476
  id: originUUID,
4853
5477
  prevId: "",
4854
5478
  tables: {},
@@ -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,10 +5905,9 @@ 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
- sqlToStr = (sql2) => {
5288
- return sql2.toQuery({
5909
+ sqlToStr = (sql) => {
5910
+ return sql.toQuery({
5289
5911
  escapeName: () => {
5290
5912
  throw new Error("we don't support params for `sql` default values");
5291
5913
  },
@@ -5311,7 +5933,8 @@ 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}`
5936
+ suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}`,
5937
+ info: (str) => `${source_default.grey(str)}`
5315
5938
  };
5316
5939
  }
5317
5940
  });
@@ -5396,7 +6019,7 @@ var init_schemaValidator = __esm({
5396
6019
  init_mysqlSchema();
5397
6020
  init_pgSchema();
5398
6021
  init_sqliteSchema();
5399
- dialect3 = enumType(["pg", "mysql", "sqlite"]);
6022
+ dialect3 = enumType(["postgresql", "mysql", "sqlite"]);
5400
6023
  commonSquashedSchema = unionType([
5401
6024
  pgSchemaSquashed,
5402
6025
  mysqlSchemaSquashed,
@@ -5516,8 +6139,8 @@ var init_cli = __esm({
5516
6139
  dialect: dialect3,
5517
6140
  schema: unionType([stringType(), stringType().array()]).optional(),
5518
6141
  tablesFilter: unionType([stringType(), stringType().array()]).optional(),
5519
- schemaFilters: unionType([stringType(), stringType().array()]).optional().default(["public"]),
5520
- driver: stringType(),
6142
+ schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
6143
+ driver: stringType().optional(),
5521
6144
  // pg
5522
6145
  connectionString: stringType().optional(),
5523
6146
  // mysql
@@ -5555,7 +6178,7 @@ var init_cli = __esm({
5555
6178
  authToken: stringType().optional(),
5556
6179
  introspectCasing: casing,
5557
6180
  breakpoints: booleanType().optional().default(true)
5558
- });
6181
+ }).passthrough();
5559
6182
  configCheck = objectType({
5560
6183
  dialect: dialect3.optional(),
5561
6184
  out: stringType().optional()
@@ -5569,6 +6192,33 @@ var init_cli = __esm({
5569
6192
  }
5570
6193
  });
5571
6194
 
6195
+ // src/cli/validations/studio.ts
6196
+ var credentials, studioCliParams, studioConfig;
6197
+ var init_studio = __esm({
6198
+ "src/cli/validations/studio.ts"() {
6199
+ "use strict";
6200
+ init_lib();
6201
+ init_mysql();
6202
+ init_sqlite();
6203
+ init_schemaValidator();
6204
+ init_pg();
6205
+ credentials = intersectionType(
6206
+ postgresCredentials,
6207
+ mysqlCredentials,
6208
+ sqliteCredentials
6209
+ );
6210
+ studioCliParams = objectType({
6211
+ port: coerce.number().optional().default(4983),
6212
+ host: stringType().optional().default("127.0.0.1"),
6213
+ config: stringType().optional()
6214
+ });
6215
+ studioConfig = objectType({
6216
+ dialect: dialect3,
6217
+ schema: unionType([stringType(), stringType().array()])
6218
+ });
6219
+ }
6220
+ });
6221
+
5572
6222
  // src/cli/commands/_es5.ts
5573
6223
  var es5_exports = {};
5574
6224
  __export(es5_exports, {
@@ -6331,9 +6981,9 @@ var require_src2 = __commonJS({
6331
6981
  }
6332
6982
  });
6333
6983
 
6334
- // node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.7/node_modules/esbuild-register/dist/node.js
6984
+ // node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.12/node_modules/esbuild-register/dist/node.js
6335
6985
  var require_node2 = __commonJS({
6336
- "node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.7/node_modules/esbuild-register/dist/node.js"(exports) {
6986
+ "node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.19.12/node_modules/esbuild-register/dist/node.js"(exports) {
6337
6987
  "use strict";
6338
6988
  Object.defineProperty(exports, "__esModule", { value: true });
6339
6989
  function _interopRequireDefault2(obj) {
@@ -8598,13 +9248,13 @@ var require_node2 = __commonJS({
8598
9248
  }
8599
9249
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8600
9250
  try {
8601
- var info3 = gen[key](arg);
8602
- var value = info3.value;
9251
+ var info2 = gen[key](arg);
9252
+ var value = info2.value;
8603
9253
  } catch (error2) {
8604
9254
  reject(error2);
8605
9255
  return;
8606
9256
  }
8607
- if (info3.done) {
9257
+ if (info2.done) {
8608
9258
  resolve(value);
8609
9259
  } else {
8610
9260
  Promise.resolve(value).then(_next, _throw);
@@ -11189,12 +11839,11 @@ var require_node2 = __commonJS({
11189
11839
  });
11190
11840
 
11191
11841
  // src/cli/commands/utils.ts
11192
- var import_hanji2, assertES5, safeRegister;
11842
+ var import_hanji2, assertES5, safeRegister, migrateCliParams, migrateConfig;
11193
11843
  var init_utils2 = __esm({
11194
11844
  "src/cli/commands/utils.ts"() {
11195
11845
  "use strict";
11196
11846
  init_serializer();
11197
- init_source();
11198
11847
  init_views();
11199
11848
  import_hanji2 = __toESM(require_hanji());
11200
11849
  init_global();
@@ -11202,8 +11851,11 @@ var init_utils2 = __esm({
11202
11851
  init_pg();
11203
11852
  init_sqlite();
11204
11853
  init_common();
11854
+ init_schemaValidator();
11205
11855
  init_cli();
11206
11856
  init_outputs();
11857
+ init_studio();
11858
+ init_lib();
11207
11859
  assertES5 = async (unregister) => {
11208
11860
  try {
11209
11861
  init_es5();
@@ -11245,6 +11897,17 @@ var init_utils2 = __esm({
11245
11897
  await assertES5(res.unregister);
11246
11898
  return res;
11247
11899
  };
11900
+ migrateCliParams = objectType({
11901
+ config: stringType().optional()
11902
+ });
11903
+ migrateConfig = objectType({
11904
+ dialect: dialect3,
11905
+ out: stringType().optional().default("drizzle"),
11906
+ migrations: objectType({
11907
+ table: stringType().optional(),
11908
+ schema: stringType().optional()
11909
+ }).optional()
11910
+ });
11248
11911
  }
11249
11912
  });
11250
11913
 
@@ -11515,7 +12178,7 @@ ${withStyle.errorWarning(
11515
12178
  );
11516
12179
  return {
11517
12180
  version: "6",
11518
- dialect: "pg",
12181
+ dialect: "postgresql",
11519
12182
  tables: result,
11520
12183
  enums: enumsToReturn,
11521
12184
  schemas: schemasObject,
@@ -11722,7 +12385,7 @@ ${withStyle.errorWarning(
11722
12385
  const columnName = columnResponse.attname;
11723
12386
  const columnAdditionalDT = columnResponse.additional_dt;
11724
12387
  const columnDimensions = columnResponse.array_dimensions;
11725
- const enumType2 = columnResponse.enum_name;
12388
+ const enumType3 = columnResponse.enum_name;
11726
12389
  let columnType = columnResponse.data_type;
11727
12390
  const primaryKey = tableConstraints.filter(
11728
12391
  (mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "PRIMARY KEY"
@@ -11786,8 +12449,8 @@ ${withStyle.errorWarning(
11786
12449
  columnTypeMapped = trimChar(columnTypeMapped, '"');
11787
12450
  columnToReturn[columnName] = {
11788
12451
  name: columnName,
11789
- type: columnAdditionalDT === "USER-DEFINED" ? enumType2 : columnTypeMapped,
11790
- typeSchema: enumsToReturn[`${tableSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType2}`].schema : void 0,
12452
+ type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
12453
+ typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
11791
12454
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
11792
12455
  // default: isSerial ? undefined : defaultValue,
11793
12456
  notNull: columnResponse.is_nullable === "NO"
@@ -11870,7 +12533,7 @@ ${withStyle.errorWarning(
11870
12533
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
11871
12534
  return {
11872
12535
  version: "6",
11873
- dialect: "pg",
12536
+ dialect: "postgresql",
11874
12537
  tables: result,
11875
12538
  enums: enumsToReturn,
11876
12539
  schemas: schemasObject,
@@ -12171,10 +12834,10 @@ var require_brace_expansion = __commonJS({
12171
12834
  }
12172
12835
  });
12173
12836
 
12174
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js
12837
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
12175
12838
  var posixClasses, braceEscape, regexpEscape, rangesToString, parseClass;
12176
12839
  var init_brace_expressions = __esm({
12177
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js"() {
12840
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js"() {
12178
12841
  posixClasses = {
12179
12842
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
12180
12843
  "[:alpha:]": ["\\p{L}\\p{Nl}", true],
@@ -12286,30 +12949,30 @@ var init_brace_expressions = __esm({
12286
12949
  }
12287
12950
  });
12288
12951
 
12289
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js
12952
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js
12290
12953
  var escape;
12291
12954
  var init_escape = __esm({
12292
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js"() {
12955
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js"() {
12293
12956
  escape = (s, { windowsPathsNoEscape = false } = {}) => {
12294
12957
  return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
12295
12958
  };
12296
12959
  }
12297
12960
  });
12298
12961
 
12299
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js
12962
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js
12300
12963
  var unescape;
12301
12964
  var init_unescape = __esm({
12302
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js"() {
12965
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js"() {
12303
12966
  unescape = (s, { windowsPathsNoEscape = false } = {}) => {
12304
12967
  return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
12305
12968
  };
12306
12969
  }
12307
12970
  });
12308
12971
 
12309
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
12972
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
12310
12973
  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;
12311
12974
  var init_mjs = __esm({
12312
- "node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js"() {
12975
+ "node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js"() {
12313
12976
  import_brace_expansion = __toESM(require_brace_expansion(), 1);
12314
12977
  init_brace_expressions();
12315
12978
  init_escape();
@@ -15101,7 +15764,7 @@ var init_snapshotsDiffer = __esm({
15101
15764
  const jsonTableAlternations = alteredTables.map((it) => {
15102
15765
  return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
15103
15766
  }).flat();
15104
- const jsonCreateIndexesForAllAlteredTables = alteredTables.map((it) => {
15767
+ const jsonCreateIndexesFoAlteredTables = alteredTables.map((it) => {
15105
15768
  return prepareCreateIndexesJson(
15106
15769
  it.name,
15107
15770
  it.schema,
@@ -15130,14 +15793,21 @@ var init_snapshotsDiffer = __esm({
15130
15793
  },
15131
15794
  {}
15132
15795
  );
15133
- jsonCreateIndexesForAllAlteredTables.push(
15796
+ jsonCreateIndexesFoAlteredTables.push(
15134
15797
  ...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
15135
15798
  );
15136
15799
  jsonDropIndexesForAllAlteredTables.push(
15137
15800
  ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
15138
15801
  );
15139
15802
  });
15140
- const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
15803
+ const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
15804
+ return prepareCreateReferencesJson(
15805
+ it.name,
15806
+ it.schema,
15807
+ it.foreignKeys
15808
+ );
15809
+ }).flat();
15810
+ const jsonReferencesForAlteredTables = alteredTables.map((it) => {
15141
15811
  const forAdded = prepareCreateReferencesJson(
15142
15812
  it.name,
15143
15813
  it.schema,
@@ -15155,10 +15825,10 @@ var init_snapshotsDiffer = __esm({
15155
15825
  );
15156
15826
  return [...forAdded, ...forAltered, ...alteredFKs];
15157
15827
  }).flat();
15158
- const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
15828
+ const jsonCreatedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
15159
15829
  (t) => t.type === "create_reference"
15160
15830
  );
15161
- const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
15831
+ const jsonDroppedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
15162
15832
  (t) => t.type === "delete_reference"
15163
15833
  );
15164
15834
  const createEnums = createdEnums.map((it) => {
@@ -15185,7 +15855,7 @@ var init_snapshotsDiffer = __esm({
15185
15855
  const dropSchemas = prepareDeleteSchemasJson(
15186
15856
  deletedSchemas.map((it) => it.name)
15187
15857
  );
15188
- const jsonPgCreateTables = createdTables.map((it) => {
15858
+ const createTables = createdTables.map((it) => {
15189
15859
  return preparePgCreateTableJson(it, curFull);
15190
15860
  });
15191
15861
  jsonStatements.push(...createSchemas);
@@ -15194,7 +15864,7 @@ var init_snapshotsDiffer = __esm({
15194
15864
  jsonStatements.push(...moveEnums);
15195
15865
  jsonStatements.push(...renameEnums);
15196
15866
  jsonStatements.push(...jsonAlterEnumsWithAddedValues);
15197
- jsonStatements.push(...jsonPgCreateTables);
15867
+ jsonStatements.push(...createTables);
15198
15868
  jsonStatements.push(...jsonDropTables);
15199
15869
  jsonStatements.push(...jsonSetTableSchemas);
15200
15870
  jsonStatements.push(...jsonRenameTables);
@@ -15205,15 +15875,16 @@ var init_snapshotsDiffer = __esm({
15205
15875
  jsonStatements.push(...jsonTableAlternations);
15206
15876
  jsonStatements.push(...jsonAddedCompositePKs);
15207
15877
  jsonStatements.push(...jsonAddColumnsStatemets);
15878
+ jsonStatements.push(...jsonCreateReferencesForCreatedTables);
15208
15879
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
15209
- jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
15210
15880
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
15881
+ jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
15211
15882
  jsonStatements.push(...jsonDropColumnsStatemets);
15212
15883
  jsonStatements.push(...jsonAlteredCompositePKs);
15213
15884
  jsonStatements.push(...jsonAlteredUniqueConstraints);
15214
15885
  jsonStatements.push(...dropEnums);
15215
15886
  jsonStatements.push(...dropSchemas);
15216
- const sqlStatements = fromJson(jsonStatements, "pg");
15887
+ const sqlStatements = fromJson(jsonStatements, "postgresql");
15217
15888
  const uniqueSqlStatements = [];
15218
15889
  sqlStatements.forEach((ss) => {
15219
15890
  if (!uniqueSqlStatements.includes(ss)) {
@@ -15351,8 +16022,8 @@ var init_snapshotsDiffer = __esm({
15351
16022
  const jsonDeletedUniqueConstraints = [];
15352
16023
  const jsonAlteredUniqueConstraints = [];
15353
16024
  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
16025
+ const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
15354
16026
  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
15355
- const jsonAddColumnsStatemets = columnDeletes.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
15356
16027
  alteredTables.forEach((it) => {
15357
16028
  let addedColumns = [];
15358
16029
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -15466,6 +16137,13 @@ var init_snapshotsDiffer = __esm({
15466
16137
  ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
15467
16138
  );
15468
16139
  });
16140
+ const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
16141
+ return prepareCreateReferencesJson(
16142
+ it.name,
16143
+ it.schema,
16144
+ it.foreignKeys
16145
+ );
16146
+ }).flat();
15469
16147
  const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
15470
16148
  const forAdded = prepareCreateReferencesJson(
15471
16149
  it.name,
@@ -15506,9 +16184,10 @@ var init_snapshotsDiffer = __esm({
15506
16184
  jsonStatements.push(...jsonAddedUniqueConstraints);
15507
16185
  jsonStatements.push(...jsonDeletedUniqueConstraints);
15508
16186
  jsonStatements.push(...jsonAddColumnsStatemets);
16187
+ jsonStatements.push(...jsonCreateReferencesForCreatedTables);
15509
16188
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
15510
- jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
15511
16189
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16190
+ jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
15512
16191
  jsonStatements.push(...jsonDropColumnsStatemets);
15513
16192
  jsonStatements.push(...jsonAlteredCompositePKs);
15514
16193
  jsonStatements.push(...jsonAddedUniqueConstraints);
@@ -16093,7 +16772,7 @@ var init_sqlgenerator = __esm({
16093
16772
  };
16094
16773
  PgCreateTableConvertor = class extends Convertor {
16095
16774
  can(statement, dialect7) {
16096
- return statement.type === "create_table" && dialect7 === "pg";
16775
+ return statement.type === "create_table" && dialect7 === "postgresql";
16097
16776
  }
16098
16777
  convert(st) {
16099
16778
  const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
@@ -16235,7 +16914,7 @@ var init_sqlgenerator = __esm({
16235
16914
  };
16236
16915
  PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
16237
16916
  can(statement, dialect7) {
16238
- return statement.type === "create_unique_constraint" && dialect7 === "pg";
16917
+ return statement.type === "create_unique_constraint" && dialect7 === "postgresql";
16239
16918
  }
16240
16919
  convert(statement) {
16241
16920
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -16245,7 +16924,7 @@ var init_sqlgenerator = __esm({
16245
16924
  };
16246
16925
  PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
16247
16926
  can(statement, dialect7) {
16248
- return statement.type === "delete_unique_constraint" && dialect7 === "pg";
16927
+ return statement.type === "delete_unique_constraint" && dialect7 === "postgresql";
16249
16928
  }
16250
16929
  convert(statement) {
16251
16930
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -16334,7 +17013,7 @@ var init_sqlgenerator = __esm({
16334
17013
  };
16335
17014
  PgDropTableConvertor = class extends Convertor {
16336
17015
  can(statement, dialect7) {
16337
- return statement.type === "drop_table" && dialect7 === "pg";
17016
+ return statement.type === "drop_table" && dialect7 === "postgresql";
16338
17017
  }
16339
17018
  convert(statement) {
16340
17019
  const { tableName, schema: schema4 } = statement;
@@ -16362,7 +17041,7 @@ var init_sqlgenerator = __esm({
16362
17041
  };
16363
17042
  PgRenameTableConvertor = class extends Convertor {
16364
17043
  can(statement, dialect7) {
16365
- return statement.type === "rename_table" && dialect7 === "pg";
17044
+ return statement.type === "rename_table" && dialect7 === "postgresql";
16366
17045
  }
16367
17046
  convert(statement) {
16368
17047
  const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
@@ -16393,7 +17072,7 @@ var init_sqlgenerator = __esm({
16393
17072
  };
16394
17073
  PgAlterTableRenameColumnConvertor = class extends Convertor {
16395
17074
  can(statement, dialect7) {
16396
- return statement.type === "alter_table_rename_column" && dialect7 === "pg";
17075
+ return statement.type === "alter_table_rename_column" && dialect7 === "postgresql";
16397
17076
  }
16398
17077
  convert(statement) {
16399
17078
  const { tableName, oldColumnName, newColumnName, schema: schema4 } = statement;
@@ -16421,7 +17100,7 @@ var init_sqlgenerator = __esm({
16421
17100
  };
16422
17101
  PgAlterTableDropColumnConvertor = class extends Convertor {
16423
17102
  can(statement, dialect7) {
16424
- return statement.type === "alter_table_drop_column" && dialect7 === "pg";
17103
+ return statement.type === "alter_table_drop_column" && dialect7 === "postgresql";
16425
17104
  }
16426
17105
  convert(statement) {
16427
17106
  const { tableName, columnName, schema: schema4 } = statement;
@@ -16449,7 +17128,7 @@ var init_sqlgenerator = __esm({
16449
17128
  };
16450
17129
  PgAlterTableAddColumnConvertor = class extends Convertor {
16451
17130
  can(statement, dialect7) {
16452
- return statement.type === "alter_table_add_column" && dialect7 === "pg";
17131
+ return statement.type === "alter_table_add_column" && dialect7 === "postgresql";
16453
17132
  }
16454
17133
  convert(statement) {
16455
17134
  const { tableName, column: column4, schema: schema4 } = statement;
@@ -16494,7 +17173,7 @@ var init_sqlgenerator = __esm({
16494
17173
  };
16495
17174
  PgAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
16496
17175
  can(statement, dialect7) {
16497
- return statement.type === "alter_table_alter_column_set_type" && dialect7 === "pg";
17176
+ return statement.type === "alter_table_alter_column_set_type" && dialect7 === "postgresql";
16498
17177
  }
16499
17178
  convert(statement) {
16500
17179
  const { tableName, columnName, newDataType, schema: schema4 } = statement;
@@ -16519,7 +17198,7 @@ var init_sqlgenerator = __esm({
16519
17198
  };
16520
17199
  PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
16521
17200
  can(statement, dialect7) {
16522
- return statement.type === "alter_table_alter_column_set_default" && dialect7 === "pg";
17201
+ return statement.type === "alter_table_alter_column_set_default" && dialect7 === "postgresql";
16523
17202
  }
16524
17203
  convert(statement) {
16525
17204
  const { tableName, columnName, schema: schema4 } = statement;
@@ -16544,7 +17223,7 @@ var init_sqlgenerator = __esm({
16544
17223
  };
16545
17224
  PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
16546
17225
  can(statement, dialect7) {
16547
- return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "pg";
17226
+ return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "postgresql";
16548
17227
  }
16549
17228
  convert(statement) {
16550
17229
  const { tableName, columnName, schema: schema4 } = statement;
@@ -16656,7 +17335,7 @@ var init_sqlgenerator = __esm({
16656
17335
  };
16657
17336
  PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
16658
17337
  can(statement, dialect7) {
16659
- return statement.type === "create_composite_pk" && dialect7 === "pg";
17338
+ return statement.type === "create_composite_pk" && dialect7 === "postgresql";
16660
17339
  }
16661
17340
  convert(statement) {
16662
17341
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -16666,7 +17345,7 @@ var init_sqlgenerator = __esm({
16666
17345
  };
16667
17346
  PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
16668
17347
  can(statement, dialect7) {
16669
- return statement.type === "delete_composite_pk" && dialect7 === "pg";
17348
+ return statement.type === "delete_composite_pk" && dialect7 === "postgresql";
16670
17349
  }
16671
17350
  convert(statement) {
16672
17351
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -16676,7 +17355,7 @@ var init_sqlgenerator = __esm({
16676
17355
  };
16677
17356
  PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
16678
17357
  can(statement, dialect7) {
16679
- return statement.type === "alter_composite_pk" && dialect7 === "pg";
17358
+ return statement.type === "alter_composite_pk" && dialect7 === "postgresql";
16680
17359
  }
16681
17360
  convert(statement) {
16682
17361
  const { name, columns } = PgSquasher.unsquashPK(statement.old);
@@ -16799,7 +17478,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16799
17478
  };
16800
17479
  PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
16801
17480
  can(statement, dialect7) {
16802
- return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "pg";
17481
+ return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "postgresql";
16803
17482
  }
16804
17483
  convert(statement) {
16805
17484
  const { tableName, columnName } = statement;
@@ -16809,7 +17488,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16809
17488
  };
16810
17489
  PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
16811
17490
  can(statement, dialect7) {
16812
- return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "pg";
17491
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "postgresql";
16813
17492
  }
16814
17493
  convert(statement) {
16815
17494
  const { tableName, columnName, schema: schema4 } = statement;
@@ -16833,7 +17512,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16833
17512
  };
16834
17513
  PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
16835
17514
  can(statement, dialect7) {
16836
- return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "pg";
17515
+ return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "postgresql";
16837
17516
  }
16838
17517
  convert(statement) {
16839
17518
  const { tableName, columnName } = statement;
@@ -16888,7 +17567,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16888
17567
  };
16889
17568
  PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
16890
17569
  can(statement, dialect7) {
16891
- return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "pg";
17570
+ return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "postgresql";
16892
17571
  }
16893
17572
  convert(statement) {
16894
17573
  const { tableName, columnName } = statement;
@@ -16913,7 +17592,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16913
17592
  };
16914
17593
  PgCreateForeignKeyConvertor = class extends Convertor {
16915
17594
  can(statement, dialect7) {
16916
- return statement.type === "create_reference" && dialect7 === "pg";
17595
+ return statement.type === "create_reference" && dialect7 === "postgresql";
16917
17596
  }
16918
17597
  convert(statement) {
16919
17598
  const {
@@ -16933,12 +17612,12 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16933
17612
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
16934
17613
  const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
16935
17614
  const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
16936
- let sql2 = "DO $$ BEGIN\n";
16937
- sql2 += " " + alterStatement + ";\n";
16938
- sql2 += "EXCEPTION\n";
16939
- sql2 += " WHEN duplicate_object THEN null;\n";
16940
- sql2 += "END $$;\n";
16941
- return sql2;
17615
+ let sql = "DO $$ BEGIN\n";
17616
+ sql += " " + alterStatement + ";\n";
17617
+ sql += "EXCEPTION\n";
17618
+ sql += " WHEN duplicate_object THEN null;\n";
17619
+ sql += "END $$;\n";
17620
+ return sql;
16942
17621
  }
16943
17622
  };
16944
17623
  SqliteCreateForeignKeyConvertor = class extends Convertor {
@@ -16978,13 +17657,13 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16978
17657
  };
16979
17658
  PgAlterForeignKeyConvertor = class extends Convertor {
16980
17659
  can(statement, dialect7) {
16981
- return statement.type === "alter_reference" && dialect7 === "pg";
17660
+ return statement.type === "alter_reference" && dialect7 === "postgresql";
16982
17661
  }
16983
17662
  convert(statement) {
16984
17663
  const newFk = PgSquasher.unsquashFK(statement.data);
16985
17664
  const oldFk = PgSquasher.unsquashFK(statement.oldFkey);
16986
17665
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
16987
- let sql2 = `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${oldFk.name}";
17666
+ let sql = `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${oldFk.name}";
16988
17667
  `;
16989
17668
  const onDeleteStatement = newFk.onDelete ? ` ON DELETE ${newFk.onDelete}` : "";
16990
17669
  const onUpdateStatement = newFk.onUpdate ? ` ON UPDATE ${newFk.onUpdate}` : "";
@@ -16993,12 +17672,12 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
16993
17672
  const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
16994
17673
  const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
16995
17674
  const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
16996
- sql2 += "DO $$ BEGIN\n";
16997
- sql2 += " " + alterStatement + ";\n";
16998
- sql2 += "EXCEPTION\n";
16999
- sql2 += " WHEN duplicate_object THEN null;\n";
17000
- sql2 += "END $$;\n";
17001
- return sql2;
17675
+ sql += "DO $$ BEGIN\n";
17676
+ sql += " " + alterStatement + ";\n";
17677
+ sql += "EXCEPTION\n";
17678
+ sql += " WHEN duplicate_object THEN null;\n";
17679
+ sql += "END $$;\n";
17680
+ return sql;
17002
17681
  }
17003
17682
  };
17004
17683
  SqliteAlterForeignKeyConvertor = class extends Convertor {
@@ -17017,7 +17696,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17017
17696
  };
17018
17697
  PgDeleteForeignKeyConvertor = class extends Convertor {
17019
17698
  can(statement, dialect7) {
17020
- return statement.type === "delete_reference" && dialect7 === "pg";
17699
+ return statement.type === "delete_reference" && dialect7 === "postgresql";
17021
17700
  }
17022
17701
  convert(statement) {
17023
17702
  const tableFrom = statement.tableName;
@@ -17054,7 +17733,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17054
17733
  };
17055
17734
  CreatePgIndexConvertor = class extends Convertor {
17056
17735
  can(statement, dialect7) {
17057
- return statement.type === "create_index" && dialect7 === "pg";
17736
+ return statement.type === "create_index" && dialect7 === "postgresql";
17058
17737
  }
17059
17738
  convert(statement) {
17060
17739
  const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
@@ -17093,7 +17772,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17093
17772
  };
17094
17773
  PgDropIndexConvertor = class extends Convertor {
17095
17774
  can(statement, dialect7) {
17096
- return statement.type === "drop_index" && dialect7 === "pg";
17775
+ return statement.type === "drop_index" && dialect7 === "postgresql";
17097
17776
  }
17098
17777
  convert(statement) {
17099
17778
  const { name } = PgSquasher.unsquashIdx(statement.data);
@@ -17102,7 +17781,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17102
17781
  };
17103
17782
  PgCreateSchemaConvertor = class extends Convertor {
17104
17783
  can(statement, dialect7) {
17105
- return statement.type === "create_schema" && dialect7 === "pg";
17784
+ return statement.type === "create_schema" && dialect7 === "postgresql";
17106
17785
  }
17107
17786
  convert(statement) {
17108
17787
  const { name } = statement;
@@ -17112,7 +17791,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17112
17791
  };
17113
17792
  PgRenameSchemaConvertor = class extends Convertor {
17114
17793
  can(statement, dialect7) {
17115
- return statement.type === "rename_schema" && dialect7 === "pg";
17794
+ return statement.type === "rename_schema" && dialect7 === "postgresql";
17116
17795
  }
17117
17796
  convert(statement) {
17118
17797
  const { from, to } = statement;
@@ -17122,7 +17801,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17122
17801
  };
17123
17802
  PgDropSchemaConvertor = class extends Convertor {
17124
17803
  can(statement, dialect7) {
17125
- return statement.type === "drop_schema" && dialect7 === "pg";
17804
+ return statement.type === "drop_schema" && dialect7 === "postgresql";
17126
17805
  }
17127
17806
  convert(statement) {
17128
17807
  const { name } = statement;
@@ -17132,7 +17811,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17132
17811
  };
17133
17812
  PgAlterTableSetSchemaConvertor = class extends Convertor {
17134
17813
  can(statement, dialect7) {
17135
- return statement.type === "alter_table_set_schema" && dialect7 === "pg";
17814
+ return statement.type === "alter_table_set_schema" && dialect7 === "postgresql";
17136
17815
  }
17137
17816
  convert(statement) {
17138
17817
  const { tableName, schemaFrom, schemaTo } = statement;
@@ -17142,7 +17821,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17142
17821
  };
17143
17822
  PgAlterTableSetNewSchemaConvertor = class extends Convertor {
17144
17823
  can(statement, dialect7) {
17145
- return statement.type === "alter_table_set_new_schema" && dialect7 === "pg";
17824
+ return statement.type === "alter_table_set_new_schema" && dialect7 === "postgresql";
17146
17825
  }
17147
17826
  convert(statement) {
17148
17827
  const { tableName, to, from } = statement;
@@ -17153,7 +17832,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17153
17832
  };
17154
17833
  PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
17155
17834
  can(statement, dialect7) {
17156
- return statement.type === "alter_table_remove_from_schema" && dialect7 === "pg";
17835
+ return statement.type === "alter_table_remove_from_schema" && dialect7 === "postgresql";
17157
17836
  }
17158
17837
  convert(statement) {
17159
17838
  const { tableName, schema: schema4 } = statement;
@@ -17372,7 +18051,9 @@ function mapSqlToSqliteType(sqlType) {
17372
18051
  return "text";
17373
18052
  } else if (lowered.startsWith("blob")) {
17374
18053
  return "blob";
17375
- } else if (["real", "double", "double precision", "float"].some((it) => lowered.startsWith(it))) {
18054
+ } else if (["real", "double", "double precision", "float"].some(
18055
+ (it) => lowered.startsWith(it)
18056
+ )) {
17376
18057
  return "real";
17377
18058
  } else {
17378
18059
  return "numeric";
@@ -17557,7 +18238,7 @@ The unique constraint ${source_default.underline.blue(
17557
18238
  `SELECT
17558
18239
  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
17559
18240
  FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
17560
- 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';
18241
+ 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';
17561
18242
  `
17562
18243
  );
17563
18244
  const tablesWithSeq = [];
@@ -18928,7 +19609,7 @@ var pgSuggestions = async (db, statements) => {
18928
19609
  }
18929
19610
  }
18930
19611
  }
18931
- const stmnt = fromJson([statement], "pg")[0];
19612
+ const stmnt = fromJson([statement], "postgresql")[0];
18932
19613
  if (typeof stmnt !== "undefined") {
18933
19614
  if (statement.type === "drop_table") {
18934
19615
  statementsToExecute.push(
@@ -19056,6 +19737,9 @@ String.prototype.squashSpaces = function() {
19056
19737
  String.prototype.camelCase = function() {
19057
19738
  return camelCase(String(this));
19058
19739
  };
19740
+ String.prototype.capitalise = function() {
19741
+ return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
19742
+ };
19059
19743
  String.prototype.concatIf = function(it, condition) {
19060
19744
  return condition ? `${this}${it}` : String(this);
19061
19745
  };
@@ -19366,7 +20050,6 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
19366
20050
  init_mysqlSerializer();
19367
20051
  init_global();
19368
20052
  init_migrate();
19369
- import { sql } from "drizzle-orm";
19370
20053
  var generateDrizzleJson = (imports, prevId) => {
19371
20054
  const prepared = prepareFromExports(imports);
19372
20055
  const id = randomUUID();
@@ -19401,6 +20084,7 @@ var generateMigration = async (prev, cur) => {
19401
20084
  };
19402
20085
  var pushSchema = async (imports, drizzleInstance) => {
19403
20086
  const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
20087
+ const { sql } = await import("drizzle-orm");
19404
20088
  const db = {
19405
20089
  query: async (query, params) => {
19406
20090
  const res = await drizzleInstance.execute(sql.raw(query));
@@ -19462,6 +20146,7 @@ var generateSQLiteMigration = async (prev, cur) => {
19462
20146
  };
19463
20147
  var pushSQLiteSchema = async (imports, drizzleInstance) => {
19464
20148
  const { applySqliteSnapshotsDiff: applySqliteSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
20149
+ const { sql } = await import("drizzle-orm");
19465
20150
  const db = {
19466
20151
  query: async (query, params) => {
19467
20152
  const res = drizzleInstance.all(sql.raw(query));
@@ -19535,6 +20220,7 @@ var pushMySQLSchema = async (imports, drizzleInstance, databaseName) => {
19535
20220
  const { applyMysqlSnapshotsDiff: applyMysqlSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
19536
20221
  const { logSuggestionsAndReturn: logSuggestionsAndReturn3 } = await Promise.resolve().then(() => (init_mysqlPushUtils(), mysqlPushUtils_exports));
19537
20222
  const { mysqlPushIntrospect: mysqlPushIntrospect2 } = await Promise.resolve().then(() => (init_mysqlIntrospect(), mysqlIntrospect_exports));
20223
+ const { sql } = await import("drizzle-orm");
19538
20224
  const db = {
19539
20225
  query: async (query, params) => {
19540
20226
  const res = await drizzleInstance.execute(sql.raw(query));