drizzle-kit 0.20.17-92ad3af → 0.20.17-940f46c

Sign up to get free protection for your applications and to get access to all the features.
package/utils.js CHANGED
@@ -33,10 +33,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
33
33
 
34
34
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
35
35
  var require_readline = __commonJS({
36
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports2) {
36
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
37
37
  "use strict";
38
- Object.defineProperty(exports2, "__esModule", { value: true });
39
- exports2.prepareReadLine = void 0;
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.prepareReadLine = void 0;
40
40
  var prepareReadLine = () => {
41
41
  const stdin = process.stdin;
42
42
  const stdout = process.stdout;
@@ -52,13 +52,13 @@ var require_readline = __commonJS({
52
52
  closable: rl
53
53
  };
54
54
  };
55
- exports2.prepareReadLine = prepareReadLine;
55
+ exports.prepareReadLine = prepareReadLine;
56
56
  }
57
57
  });
58
58
 
59
59
  // node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
60
60
  var require_src = __commonJS({
61
- "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) {
61
+ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module2) {
62
62
  "use strict";
63
63
  var ESC = "\x1B";
64
64
  var CSI = `${ESC}[`;
@@ -119,10 +119,10 @@ var require_src = __commonJS({
119
119
 
120
120
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
121
121
  var require_utils = __commonJS({
122
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports2) {
122
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports) {
123
123
  "use strict";
124
- Object.defineProperty(exports2, "__esModule", { value: true });
125
- exports2.clear = void 0;
124
+ Object.defineProperty(exports, "__esModule", { value: true });
125
+ exports.clear = void 0;
126
126
  var sisteransi_1 = require_src();
127
127
  var strip = (str) => {
128
128
  const pattern = [
@@ -143,13 +143,13 @@ var require_utils = __commonJS({
143
143
  }
144
144
  return sisteransi_1.erase.lines(rows);
145
145
  };
146
- exports2.clear = clear;
146
+ exports.clear = clear;
147
147
  }
148
148
  });
149
149
 
150
150
  // node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
151
151
  var require_lodash = __commonJS({
152
- "node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports2, module2) {
152
+ "node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module2) {
153
153
  var FUNC_ERROR_TEXT = "Expected a function";
154
154
  var NAN = 0 / 0;
155
155
  var symbolTag = "[object Symbol]";
@@ -297,9 +297,9 @@ var require_lodash = __commonJS({
297
297
 
298
298
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
299
299
  var require_hanji = __commonJS({
300
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports2) {
300
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports) {
301
301
  "use strict";
302
- var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
302
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
303
303
  function adopt(value) {
304
304
  return value instanceof P ? value : new P(function(resolve) {
305
305
  resolve(value);
@@ -326,11 +326,11 @@ var require_hanji = __commonJS({
326
326
  step((generator = generator.apply(thisArg, _arguments || [])).next());
327
327
  });
328
328
  };
329
- var __importDefault = exports2 && exports2.__importDefault || function(mod) {
329
+ var __importDefault = exports && exports.__importDefault || function(mod) {
330
330
  return mod && mod.__esModule ? mod : { "default": mod };
331
331
  };
332
- Object.defineProperty(exports2, "__esModule", { value: true });
333
- exports2.onTerminate = exports2.renderWithTask = exports2.render = exports2.TaskTerminal = exports2.TaskView = exports2.Terminal = exports2.deferred = exports2.SelectState = exports2.Prompt = void 0;
332
+ Object.defineProperty(exports, "__esModule", { value: true });
333
+ exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
334
334
  var readline_1 = require_readline();
335
335
  var sisteransi_1 = require_src();
336
336
  var utils_1 = require_utils();
@@ -365,7 +365,7 @@ var require_hanji = __commonJS({
365
365
  this.inputCallbacks.forEach((it) => it(str, key));
366
366
  }
367
367
  };
368
- exports2.Prompt = Prompt2;
368
+ exports.Prompt = Prompt2;
369
369
  var SelectState2 = class {
370
370
  constructor(items) {
371
371
  this.items = items;
@@ -393,7 +393,7 @@ var require_hanji = __commonJS({
393
393
  return false;
394
394
  }
395
395
  };
396
- exports2.SelectState = SelectState2;
396
+ exports.SelectState = SelectState2;
397
397
  var deferred = () => {
398
398
  let resolve;
399
399
  let reject;
@@ -407,7 +407,7 @@ var require_hanji = __commonJS({
407
407
  promise
408
408
  };
409
409
  };
410
- exports2.deferred = deferred;
410
+ exports.deferred = deferred;
411
411
  var Terminal = class {
412
412
  constructor(view, stdin, stdout, closable) {
413
413
  this.view = view;
@@ -452,7 +452,7 @@ var require_hanji = __commonJS({
452
452
  };
453
453
  this.stdin.on("keypress", keypress);
454
454
  this.view.attach(this);
455
- const { resolve, promise } = (0, exports2.deferred)();
455
+ const { resolve, promise } = (0, exports.deferred)();
456
456
  this.resolve = resolve;
457
457
  this.promise = promise;
458
458
  this.renderFunc = (0, lodash_throttle_1.default)((str) => {
@@ -483,7 +483,7 @@ var require_hanji = __commonJS({
483
483
  this.renderFunc(`${clearPrefix}${string}`);
484
484
  }
485
485
  };
486
- exports2.Terminal = Terminal;
486
+ exports.Terminal = Terminal;
487
487
  var TaskView2 = class {
488
488
  constructor() {
489
489
  this.attachCallbacks = [];
@@ -508,7 +508,7 @@ var require_hanji = __commonJS({
508
508
  }
509
509
  }
510
510
  };
511
- exports2.TaskView = TaskView2;
511
+ exports.TaskView = TaskView2;
512
512
  var TaskTerminal = class {
513
513
  constructor(view, stdout) {
514
514
  this.view = view;
@@ -529,7 +529,7 @@ var require_hanji = __commonJS({
529
529
  this.stdout.write(`${clearPrefix}${string}`);
530
530
  }
531
531
  };
532
- exports2.TaskTerminal = TaskTerminal;
532
+ exports.TaskTerminal = TaskTerminal;
533
533
  function render2(view) {
534
534
  const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
535
535
  if (view instanceof Prompt2) {
@@ -542,7 +542,7 @@ var require_hanji = __commonJS({
542
542
  closable.close();
543
543
  return;
544
544
  }
545
- exports2.render = render2;
545
+ exports.render = render2;
546
546
  function renderWithTask(view, task) {
547
547
  return __awaiter(this, void 0, void 0, function* () {
548
548
  const terminal = new TaskTerminal(view, process.stdout);
@@ -552,12 +552,12 @@ var require_hanji = __commonJS({
552
552
  return result;
553
553
  });
554
554
  }
555
- exports2.renderWithTask = renderWithTask;
555
+ exports.renderWithTask = renderWithTask;
556
556
  var terminateHandler;
557
557
  function onTerminate(callback) {
558
558
  terminateHandler = callback;
559
559
  }
560
- exports2.onTerminate = onTerminate;
560
+ exports.onTerminate = onTerminate;
561
561
  }
562
562
  });
563
563
 
@@ -580,7 +580,7 @@ __export(utils_exports, {
580
580
  module.exports = __toCommonJS(utils_exports);
581
581
  var import_fs = require("fs");
582
582
 
583
- // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
583
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
584
584
  var ANSI_BACKGROUND_OFFSET = 10;
585
585
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
586
586
  var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
@@ -766,7 +766,7 @@ function assembleStyles() {
766
766
  var ansiStyles = assembleStyles();
767
767
  var ansi_styles_default = ansiStyles;
768
768
 
769
- // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
769
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
770
770
  var import_node_process = __toESM(require("node:process"), 1);
771
771
  var import_node_os = __toESM(require("node:os"), 1);
772
772
  var import_node_tty = __toESM(require("node:tty"), 1);
@@ -840,7 +840,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
840
840
  return 1;
841
841
  }
842
842
  if ("CI" in env) {
843
- if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
843
+ if ("GITHUB_ACTIONS" in env) {
844
844
  return 3;
845
845
  }
846
846
  if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
@@ -892,7 +892,7 @@ var supportsColor = {
892
892
  };
893
893
  var supports_color_default = supportsColor;
894
894
 
895
- // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
895
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
896
896
  function stringReplaceAll(string, substring, replacer) {
897
897
  let index4 = string.indexOf(substring);
898
898
  if (index4 === -1) {
@@ -922,7 +922,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
922
922
  return returnValue;
923
923
  }
924
924
 
925
- // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
925
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
926
926
  var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
927
927
  var GENERATOR = Symbol("GENERATOR");
928
928
  var STYLER = Symbol("STYLER");
@@ -1079,7 +1079,7 @@ var info = (msg, greyMsg = "") => {
1079
1079
  var originUUID = "00000000-0000-0000-0000-000000000000";
1080
1080
  var snapshotVersion = "6";
1081
1081
 
1082
- // node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs
1082
+ // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
1083
1083
  var util;
1084
1084
  (function(util2) {
1085
1085
  util2.assertEqual = (val) => val;
@@ -1138,16 +1138,6 @@ var util;
1138
1138
  return value;
1139
1139
  };
1140
1140
  })(util || (util = {}));
1141
- var objectUtil;
1142
- (function(objectUtil2) {
1143
- objectUtil2.mergeShapes = (first, second) => {
1144
- return {
1145
- ...first,
1146
- ...second
1147
- // second overwrites first
1148
- };
1149
- };
1150
- })(objectUtil || (objectUtil = {}));
1151
1141
  var ZodParsedType = util.arrayToEnum([
1152
1142
  "string",
1153
1143
  "nan",
@@ -1229,7 +1219,7 @@ var ZodIssueCode = util.arrayToEnum([
1229
1219
  "not_multiple_of",
1230
1220
  "not_finite"
1231
1221
  ]);
1232
- var ZodError = class _ZodError extends Error {
1222
+ var ZodError = class extends Error {
1233
1223
  constructor(issues) {
1234
1224
  super();
1235
1225
  this.issues = [];
@@ -1287,11 +1277,6 @@ var ZodError = class _ZodError extends Error {
1287
1277
  processError(this);
1288
1278
  return fieldErrors;
1289
1279
  }
1290
- static assert(value) {
1291
- if (!(value instanceof _ZodError)) {
1292
- throw new Error(`Not a ZodError: ${value}`);
1293
- }
1294
- }
1295
1280
  toString() {
1296
1281
  return this.message;
1297
1282
  }
@@ -1358,12 +1343,7 @@ var errorMap = (issue, _ctx) => {
1358
1343
  break;
1359
1344
  case ZodIssueCode.invalid_string:
1360
1345
  if (typeof issue.validation === "object") {
1361
- if ("includes" in issue.validation) {
1362
- message = `Invalid input: must include "${issue.validation.includes}"`;
1363
- if (typeof issue.validation.position === "number") {
1364
- message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1365
- }
1366
- } else if ("startsWith" in issue.validation) {
1346
+ if ("startsWith" in issue.validation) {
1367
1347
  message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1368
1348
  } else if ("endsWith" in issue.validation) {
1369
1349
  message = `Invalid input: must end with "${issue.validation.endsWith}"`;
@@ -1384,7 +1364,7 @@ var errorMap = (issue, _ctx) => {
1384
1364
  else if (issue.type === "number")
1385
1365
  message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1386
1366
  else if (issue.type === "date")
1387
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1367
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
1388
1368
  else
1389
1369
  message = "Invalid input";
1390
1370
  break;
@@ -1395,10 +1375,8 @@ var errorMap = (issue, _ctx) => {
1395
1375
  message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1396
1376
  else if (issue.type === "number")
1397
1377
  message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1398
- else if (issue.type === "bigint")
1399
- message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1400
1378
  else if (issue.type === "date")
1401
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1379
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
1402
1380
  else
1403
1381
  message = "Invalid input";
1404
1382
  break;
@@ -1431,13 +1409,6 @@ var makeIssue = (params) => {
1431
1409
  ...issueData,
1432
1410
  path: fullPath
1433
1411
  };
1434
- if (issueData.message !== void 0) {
1435
- return {
1436
- ...issueData,
1437
- path: fullPath,
1438
- message: issueData.message
1439
- };
1440
- }
1441
1412
  let errorMessage = "";
1442
1413
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
1443
1414
  for (const map of maps) {
@@ -1446,11 +1417,10 @@ var makeIssue = (params) => {
1446
1417
  return {
1447
1418
  ...issueData,
1448
1419
  path: fullPath,
1449
- message: errorMessage
1420
+ message: issueData.message || errorMessage
1450
1421
  };
1451
1422
  };
1452
1423
  function addIssueToContext(ctx, issueData) {
1453
- const overrideMap = getErrorMap();
1454
1424
  const issue = makeIssue({
1455
1425
  issueData,
1456
1426
  data: ctx.data,
@@ -1458,8 +1428,8 @@ function addIssueToContext(ctx, issueData) {
1458
1428
  errorMaps: [
1459
1429
  ctx.common.contextualErrorMap,
1460
1430
  ctx.schemaErrorMap,
1461
- overrideMap,
1462
- overrideMap === errorMap ? void 0 : errorMap
1431
+ getErrorMap(),
1432
+ errorMap
1463
1433
  // then global default map
1464
1434
  ].filter((x) => !!x)
1465
1435
  });
@@ -1491,11 +1461,9 @@ var ParseStatus = class _ParseStatus {
1491
1461
  static async mergeObjectAsync(status, pairs) {
1492
1462
  const syncPairs = [];
1493
1463
  for (const pair of pairs) {
1494
- const key = await pair.key;
1495
- const value = await pair.value;
1496
1464
  syncPairs.push({
1497
- key,
1498
- value
1465
+ key: await pair.key,
1466
+ value: await pair.value
1499
1467
  });
1500
1468
  }
1501
1469
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -1512,7 +1480,7 @@ var ParseStatus = class _ParseStatus {
1512
1480
  status.dirty();
1513
1481
  if (value.status === "dirty")
1514
1482
  status.dirty();
1515
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1483
+ if (typeof value.value !== "undefined" || pair.alwaysSet) {
1516
1484
  finalObject[key.value] = value.value;
1517
1485
  }
1518
1486
  }
@@ -1527,47 +1495,21 @@ var OK = (value) => ({ status: "valid", value });
1527
1495
  var isAborted = (x) => x.status === "aborted";
1528
1496
  var isDirty = (x) => x.status === "dirty";
1529
1497
  var isValid = (x) => x.status === "valid";
1530
- var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1531
- function __classPrivateFieldGet(receiver, state, kind, f) {
1532
- if (kind === "a" && !f)
1533
- throw new TypeError("Private accessor was defined without a getter");
1534
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1535
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
1536
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1537
- }
1538
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
1539
- if (kind === "m")
1540
- throw new TypeError("Private method is not writable");
1541
- if (kind === "a" && !f)
1542
- throw new TypeError("Private accessor was defined without a setter");
1543
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1544
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
1545
- return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1546
- }
1498
+ var isAsync = (x) => typeof Promise !== void 0 && x instanceof Promise;
1547
1499
  var errorUtil;
1548
1500
  (function(errorUtil2) {
1549
1501
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1550
1502
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1551
1503
  })(errorUtil || (errorUtil = {}));
1552
- var _ZodEnum_cache;
1553
- var _ZodNativeEnum_cache;
1554
1504
  var ParseInputLazyPath = class {
1555
1505
  constructor(parent, value, path, key) {
1556
- this._cachedPath = [];
1557
1506
  this.parent = parent;
1558
1507
  this.data = value;
1559
1508
  this._path = path;
1560
1509
  this._key = key;
1561
1510
  }
1562
1511
  get path() {
1563
- if (!this._cachedPath.length) {
1564
- if (this._key instanceof Array) {
1565
- this._cachedPath.push(...this._path, ...this._key);
1566
- } else {
1567
- this._cachedPath.push(...this._path, this._key);
1568
- }
1569
- }
1570
- return this._cachedPath;
1512
+ return this._path.concat(this._key);
1571
1513
  }
1572
1514
  };
1573
1515
  var handleResult = (ctx, result) => {
@@ -1577,16 +1519,8 @@ var handleResult = (ctx, result) => {
1577
1519
  if (!ctx.common.issues.length) {
1578
1520
  throw new Error("Validation failed but no issues detected.");
1579
1521
  }
1580
- return {
1581
- success: false,
1582
- get error() {
1583
- if (this._error)
1584
- return this._error;
1585
- const error = new ZodError(ctx.common.issues);
1586
- this._error = error;
1587
- return this._error;
1588
- }
1589
- };
1522
+ const error = new ZodError(ctx.common.issues);
1523
+ return { success: false, error };
1590
1524
  }
1591
1525
  };
1592
1526
  function processCreateParams(params) {
@@ -1599,17 +1533,12 @@ function processCreateParams(params) {
1599
1533
  if (errorMap2)
1600
1534
  return { errorMap: errorMap2, description };
1601
1535
  const customMap = (iss, ctx) => {
1602
- var _a, _b;
1603
- const { message } = params;
1604
- if (iss.code === "invalid_enum_value") {
1605
- return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
1606
- }
1607
- if (typeof ctx.data === "undefined") {
1608
- return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
1609
- }
1610
1536
  if (iss.code !== "invalid_type")
1611
1537
  return { message: ctx.defaultError };
1612
- return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
1538
+ if (typeof ctx.data === "undefined") {
1539
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
1540
+ }
1541
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
1613
1542
  };
1614
1543
  return { errorMap: customMap, description };
1615
1544
  }
@@ -1638,7 +1567,6 @@ var ZodType = class {
1638
1567
  this.catch = this.catch.bind(this);
1639
1568
  this.describe = this.describe.bind(this);
1640
1569
  this.pipe = this.pipe.bind(this);
1641
- this.readonly = this.readonly.bind(this);
1642
1570
  this.isNullable = this.isNullable.bind(this);
1643
1571
  this.isOptional = this.isOptional.bind(this);
1644
1572
  }
@@ -1783,29 +1711,28 @@ var ZodType = class {
1783
1711
  return this._refinement(refinement);
1784
1712
  }
1785
1713
  optional() {
1786
- return ZodOptional.create(this, this._def);
1714
+ return ZodOptional.create(this);
1787
1715
  }
1788
1716
  nullable() {
1789
- return ZodNullable.create(this, this._def);
1717
+ return ZodNullable.create(this);
1790
1718
  }
1791
1719
  nullish() {
1792
- return this.nullable().optional();
1720
+ return this.optional().nullable();
1793
1721
  }
1794
1722
  array() {
1795
- return ZodArray.create(this, this._def);
1723
+ return ZodArray.create(this);
1796
1724
  }
1797
1725
  promise() {
1798
- return ZodPromise.create(this, this._def);
1726
+ return ZodPromise.create(this);
1799
1727
  }
1800
1728
  or(option) {
1801
- return ZodUnion.create([this, option], this._def);
1729
+ return ZodUnion.create([this, option]);
1802
1730
  }
1803
1731
  and(incoming) {
1804
- return ZodIntersection.create(this, incoming, this._def);
1732
+ return ZodIntersection.create(this, incoming);
1805
1733
  }
1806
1734
  transform(transform) {
1807
1735
  return new ZodEffects({
1808
- ...processCreateParams(this._def),
1809
1736
  schema: this,
1810
1737
  typeName: ZodFirstPartyTypeKind.ZodEffects,
1811
1738
  effect: { type: "transform", transform }
@@ -1814,7 +1741,6 @@ var ZodType = class {
1814
1741
  default(def) {
1815
1742
  const defaultValueFunc = typeof def === "function" ? def : () => def;
1816
1743
  return new ZodDefault({
1817
- ...processCreateParams(this._def),
1818
1744
  innerType: this,
1819
1745
  defaultValue: defaultValueFunc,
1820
1746
  typeName: ZodFirstPartyTypeKind.ZodDefault
@@ -1824,15 +1750,14 @@ var ZodType = class {
1824
1750
  return new ZodBranded({
1825
1751
  typeName: ZodFirstPartyTypeKind.ZodBranded,
1826
1752
  type: this,
1827
- ...processCreateParams(this._def)
1753
+ ...processCreateParams(void 0)
1828
1754
  });
1829
1755
  }
1830
1756
  catch(def) {
1831
- const catchValueFunc = typeof def === "function" ? def : () => def;
1757
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1832
1758
  return new ZodCatch({
1833
- ...processCreateParams(this._def),
1834
1759
  innerType: this,
1835
- catchValue: catchValueFunc,
1760
+ defaultValue: defaultValueFunc,
1836
1761
  typeName: ZodFirstPartyTypeKind.ZodCatch
1837
1762
  });
1838
1763
  }
@@ -1846,9 +1771,6 @@ var ZodType = class {
1846
1771
  pipe(target) {
1847
1772
  return ZodPipeline.create(this, target);
1848
1773
  }
1849
- readonly() {
1850
- return ZodReadonly.create(this);
1851
- }
1852
1774
  isOptional() {
1853
1775
  return this.safeParse(void 0).success;
1854
1776
  }
@@ -1857,50 +1779,43 @@ var ZodType = class {
1857
1779
  }
1858
1780
  };
1859
1781
  var cuidRegex = /^c[^\s-]{8,}$/i;
1860
- var cuid2Regex = /^[0-9a-z]+$/;
1861
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
1862
- var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
1863
- var nanoidRegex = /^[a-z0-9_-]{21}$/i;
1864
- var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
1865
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1866
- var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1867
- var emojiRegex;
1868
- var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1869
- var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
1870
- var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1871
- var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
1872
- var dateRegex = new RegExp(`^${dateRegexSource}$`);
1873
- function timeRegexSource(args) {
1874
- let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
1782
+ var 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;
1783
+ var emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1784
+ var datetimeRegex = (args) => {
1875
1785
  if (args.precision) {
1876
- regex = `${regex}\\.\\d{${args.precision}}`;
1877
- } else if (args.precision == null) {
1878
- regex = `${regex}(\\.\\d+)?`;
1879
- }
1880
- return regex;
1881
- }
1882
- function timeRegex(args) {
1883
- return new RegExp(`^${timeRegexSource(args)}$`);
1884
- }
1885
- function datetimeRegex(args) {
1886
- let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1887
- const opts = [];
1888
- opts.push(args.local ? `Z?` : `Z`);
1889
- if (args.offset)
1890
- opts.push(`([+-]\\d{2}:?\\d{2})`);
1891
- regex = `${regex}(${opts.join("|")})`;
1892
- return new RegExp(`^${regex}$`);
1893
- }
1894
- function isValidIP(ip, version) {
1895
- if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1896
- return true;
1897
- }
1898
- if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1899
- return true;
1786
+ if (args.offset) {
1787
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
1788
+ } else {
1789
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
1790
+ }
1791
+ } else if (args.precision === 0) {
1792
+ if (args.offset) {
1793
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
1794
+ } else {
1795
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
1796
+ }
1797
+ } else {
1798
+ if (args.offset) {
1799
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
1800
+ } else {
1801
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
1802
+ }
1900
1803
  }
1901
- return false;
1902
- }
1804
+ };
1903
1805
  var ZodString = class _ZodString extends ZodType {
1806
+ constructor() {
1807
+ super(...arguments);
1808
+ this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
1809
+ validation,
1810
+ code: ZodIssueCode.invalid_string,
1811
+ ...errorUtil.errToObj(message)
1812
+ });
1813
+ this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
1814
+ this.trim = () => new _ZodString({
1815
+ ...this._def,
1816
+ checks: [...this._def.checks, { kind: "trim" }]
1817
+ });
1818
+ }
1904
1819
  _parse(input) {
1905
1820
  if (this._def.coerce) {
1906
1821
  input.data = String(input.data);
@@ -1908,11 +1823,15 @@ var ZodString = class _ZodString extends ZodType {
1908
1823
  const parsedType = this._getType(input);
1909
1824
  if (parsedType !== ZodParsedType.string) {
1910
1825
  const ctx2 = this._getOrReturnCtx(input);
1911
- addIssueToContext(ctx2, {
1912
- code: ZodIssueCode.invalid_type,
1913
- expected: ZodParsedType.string,
1914
- received: ctx2.parsedType
1915
- });
1826
+ addIssueToContext(
1827
+ ctx2,
1828
+ {
1829
+ code: ZodIssueCode.invalid_type,
1830
+ expected: ZodParsedType.string,
1831
+ received: ctx2.parsedType
1832
+ }
1833
+ //
1834
+ );
1916
1835
  return INVALID;
1917
1836
  }
1918
1837
  const status = new ParseStatus();
@@ -1980,19 +1899,6 @@ var ZodString = class _ZodString extends ZodType {
1980
1899
  });
1981
1900
  status.dirty();
1982
1901
  }
1983
- } else if (check.kind === "emoji") {
1984
- if (!emojiRegex) {
1985
- emojiRegex = new RegExp(_emojiRegex, "u");
1986
- }
1987
- if (!emojiRegex.test(input.data)) {
1988
- ctx = this._getOrReturnCtx(input, ctx);
1989
- addIssueToContext(ctx, {
1990
- validation: "emoji",
1991
- code: ZodIssueCode.invalid_string,
1992
- message: check.message
1993
- });
1994
- status.dirty();
1995
- }
1996
1902
  } else if (check.kind === "uuid") {
1997
1903
  if (!uuidRegex.test(input.data)) {
1998
1904
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2003,16 +1909,6 @@ var ZodString = class _ZodString extends ZodType {
2003
1909
  });
2004
1910
  status.dirty();
2005
1911
  }
2006
- } else if (check.kind === "nanoid") {
2007
- if (!nanoidRegex.test(input.data)) {
2008
- ctx = this._getOrReturnCtx(input, ctx);
2009
- addIssueToContext(ctx, {
2010
- validation: "nanoid",
2011
- code: ZodIssueCode.invalid_string,
2012
- message: check.message
2013
- });
2014
- status.dirty();
2015
- }
2016
1912
  } else if (check.kind === "cuid") {
2017
1913
  if (!cuidRegex.test(input.data)) {
2018
1914
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2023,26 +1919,6 @@ var ZodString = class _ZodString extends ZodType {
2023
1919
  });
2024
1920
  status.dirty();
2025
1921
  }
2026
- } else if (check.kind === "cuid2") {
2027
- if (!cuid2Regex.test(input.data)) {
2028
- ctx = this._getOrReturnCtx(input, ctx);
2029
- addIssueToContext(ctx, {
2030
- validation: "cuid2",
2031
- code: ZodIssueCode.invalid_string,
2032
- message: check.message
2033
- });
2034
- status.dirty();
2035
- }
2036
- } else if (check.kind === "ulid") {
2037
- if (!ulidRegex.test(input.data)) {
2038
- ctx = this._getOrReturnCtx(input, ctx);
2039
- addIssueToContext(ctx, {
2040
- validation: "ulid",
2041
- code: ZodIssueCode.invalid_string,
2042
- message: check.message
2043
- });
2044
- status.dirty();
2045
- }
2046
1922
  } else if (check.kind === "url") {
2047
1923
  try {
2048
1924
  new URL(input.data);
@@ -2069,20 +1945,6 @@ var ZodString = class _ZodString extends ZodType {
2069
1945
  }
2070
1946
  } else if (check.kind === "trim") {
2071
1947
  input.data = input.data.trim();
2072
- } else if (check.kind === "includes") {
2073
- if (!input.data.includes(check.value, check.position)) {
2074
- ctx = this._getOrReturnCtx(input, ctx);
2075
- addIssueToContext(ctx, {
2076
- code: ZodIssueCode.invalid_string,
2077
- validation: { includes: check.value, position: check.position },
2078
- message: check.message
2079
- });
2080
- status.dirty();
2081
- }
2082
- } else if (check.kind === "toLowerCase") {
2083
- input.data = input.data.toLowerCase();
2084
- } else if (check.kind === "toUpperCase") {
2085
- input.data = input.data.toUpperCase();
2086
1948
  } else if (check.kind === "startsWith") {
2087
1949
  if (!input.data.startsWith(check.value)) {
2088
1950
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2114,71 +1976,12 @@ var ZodString = class _ZodString extends ZodType {
2114
1976
  });
2115
1977
  status.dirty();
2116
1978
  }
2117
- } else if (check.kind === "date") {
2118
- const regex = dateRegex;
2119
- if (!regex.test(input.data)) {
2120
- ctx = this._getOrReturnCtx(input, ctx);
2121
- addIssueToContext(ctx, {
2122
- code: ZodIssueCode.invalid_string,
2123
- validation: "date",
2124
- message: check.message
2125
- });
2126
- status.dirty();
2127
- }
2128
- } else if (check.kind === "time") {
2129
- const regex = timeRegex(check);
2130
- if (!regex.test(input.data)) {
2131
- ctx = this._getOrReturnCtx(input, ctx);
2132
- addIssueToContext(ctx, {
2133
- code: ZodIssueCode.invalid_string,
2134
- validation: "time",
2135
- message: check.message
2136
- });
2137
- status.dirty();
2138
- }
2139
- } else if (check.kind === "duration") {
2140
- if (!durationRegex.test(input.data)) {
2141
- ctx = this._getOrReturnCtx(input, ctx);
2142
- addIssueToContext(ctx, {
2143
- validation: "duration",
2144
- code: ZodIssueCode.invalid_string,
2145
- message: check.message
2146
- });
2147
- status.dirty();
2148
- }
2149
- } else if (check.kind === "ip") {
2150
- if (!isValidIP(input.data, check.version)) {
2151
- ctx = this._getOrReturnCtx(input, ctx);
2152
- addIssueToContext(ctx, {
2153
- validation: "ip",
2154
- code: ZodIssueCode.invalid_string,
2155
- message: check.message
2156
- });
2157
- status.dirty();
2158
- }
2159
- } else if (check.kind === "base64") {
2160
- if (!base64Regex.test(input.data)) {
2161
- ctx = this._getOrReturnCtx(input, ctx);
2162
- addIssueToContext(ctx, {
2163
- validation: "base64",
2164
- code: ZodIssueCode.invalid_string,
2165
- message: check.message
2166
- });
2167
- status.dirty();
2168
- }
2169
1979
  } else {
2170
1980
  util.assertNever(check);
2171
1981
  }
2172
1982
  }
2173
1983
  return { status: status.value, value: input.data };
2174
1984
  }
2175
- _regex(regex, validation, message) {
2176
- return this.refinement((data) => regex.test(data), {
2177
- validation,
2178
- code: ZodIssueCode.invalid_string,
2179
- ...errorUtil.errToObj(message)
2180
- });
2181
- }
2182
1985
  _addCheck(check) {
2183
1986
  return new _ZodString({
2184
1987
  ...this._def,
@@ -2191,38 +1994,19 @@ var ZodString = class _ZodString extends ZodType {
2191
1994
  url(message) {
2192
1995
  return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2193
1996
  }
2194
- emoji(message) {
2195
- return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
2196
- }
2197
1997
  uuid(message) {
2198
1998
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2199
1999
  }
2200
- nanoid(message) {
2201
- return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2202
- }
2203
2000
  cuid(message) {
2204
2001
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2205
2002
  }
2206
- cuid2(message) {
2207
- return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
2208
- }
2209
- ulid(message) {
2210
- return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2211
- }
2212
- base64(message) {
2213
- return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2214
- }
2215
- ip(options) {
2216
- return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2217
- }
2218
2003
  datetime(options) {
2219
- var _a, _b;
2004
+ var _a;
2220
2005
  if (typeof options === "string") {
2221
2006
  return this._addCheck({
2222
2007
  kind: "datetime",
2223
2008
  precision: null,
2224
2009
  offset: false,
2225
- local: false,
2226
2010
  message: options
2227
2011
  });
2228
2012
  }
@@ -2230,30 +2014,9 @@ var ZodString = class _ZodString extends ZodType {
2230
2014
  kind: "datetime",
2231
2015
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2232
2016
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2233
- local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2234
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2235
- });
2236
- }
2237
- date(message) {
2238
- return this._addCheck({ kind: "date", message });
2239
- }
2240
- time(options) {
2241
- if (typeof options === "string") {
2242
- return this._addCheck({
2243
- kind: "time",
2244
- precision: null,
2245
- message: options
2246
- });
2247
- }
2248
- return this._addCheck({
2249
- kind: "time",
2250
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2251
2017
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2252
2018
  });
2253
2019
  }
2254
- duration(message) {
2255
- return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2256
- }
2257
2020
  regex(regex, message) {
2258
2021
  return this._addCheck({
2259
2022
  kind: "regex",
@@ -2261,14 +2024,6 @@ var ZodString = class _ZodString extends ZodType {
2261
2024
  ...errorUtil.errToObj(message)
2262
2025
  });
2263
2026
  }
2264
- includes(value, options) {
2265
- return this._addCheck({
2266
- kind: "includes",
2267
- value,
2268
- position: options === null || options === void 0 ? void 0 : options.position,
2269
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2270
- });
2271
- }
2272
2027
  startsWith(value, message) {
2273
2028
  return this._addCheck({
2274
2029
  kind: "startsWith",
@@ -2304,73 +2059,21 @@ var ZodString = class _ZodString extends ZodType {
2304
2059
  ...errorUtil.errToObj(message)
2305
2060
  });
2306
2061
  }
2307
- /**
2308
- * @deprecated Use z.string().min(1) instead.
2309
- * @see {@link ZodString.min}
2310
- */
2311
- nonempty(message) {
2312
- return this.min(1, errorUtil.errToObj(message));
2313
- }
2314
- trim() {
2315
- return new _ZodString({
2316
- ...this._def,
2317
- checks: [...this._def.checks, { kind: "trim" }]
2318
- });
2319
- }
2320
- toLowerCase() {
2321
- return new _ZodString({
2322
- ...this._def,
2323
- checks: [...this._def.checks, { kind: "toLowerCase" }]
2324
- });
2325
- }
2326
- toUpperCase() {
2327
- return new _ZodString({
2328
- ...this._def,
2329
- checks: [...this._def.checks, { kind: "toUpperCase" }]
2330
- });
2331
- }
2332
2062
  get isDatetime() {
2333
2063
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
2334
2064
  }
2335
- get isDate() {
2336
- return !!this._def.checks.find((ch) => ch.kind === "date");
2337
- }
2338
- get isTime() {
2339
- return !!this._def.checks.find((ch) => ch.kind === "time");
2340
- }
2341
- get isDuration() {
2342
- return !!this._def.checks.find((ch) => ch.kind === "duration");
2343
- }
2344
2065
  get isEmail() {
2345
2066
  return !!this._def.checks.find((ch) => ch.kind === "email");
2346
2067
  }
2347
2068
  get isURL() {
2348
2069
  return !!this._def.checks.find((ch) => ch.kind === "url");
2349
2070
  }
2350
- get isEmoji() {
2351
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
2352
- }
2353
2071
  get isUUID() {
2354
2072
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
2355
2073
  }
2356
- get isNANOID() {
2357
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2358
- }
2359
2074
  get isCUID() {
2360
2075
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
2361
2076
  }
2362
- get isCUID2() {
2363
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
2364
- }
2365
- get isULID() {
2366
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
2367
- }
2368
- get isIP() {
2369
- return !!this._def.checks.find((ch) => ch.kind === "ip");
2370
- }
2371
- get isBase64() {
2372
- return !!this._def.checks.find((ch) => ch.kind === "base64");
2373
- }
2374
2077
  get minLength() {
2375
2078
  let min = null;
2376
2079
  for (const ch of this._def.checks) {
@@ -2580,19 +2283,6 @@ var ZodNumber = class _ZodNumber extends ZodType {
2580
2283
  message: errorUtil.toString(message)
2581
2284
  });
2582
2285
  }
2583
- safe(message) {
2584
- return this._addCheck({
2585
- kind: "min",
2586
- inclusive: true,
2587
- value: Number.MIN_SAFE_INTEGER,
2588
- message: errorUtil.toString(message)
2589
- })._addCheck({
2590
- kind: "max",
2591
- inclusive: true,
2592
- value: Number.MAX_SAFE_INTEGER,
2593
- message: errorUtil.toString(message)
2594
- });
2595
- }
2596
2286
  get minValue() {
2597
2287
  let min = null;
2598
2288
  for (const ch of this._def.checks) {
@@ -2614,22 +2304,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
2614
2304
  return max;
2615
2305
  }
2616
2306
  get isInt() {
2617
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2618
- }
2619
- get isFinite() {
2620
- let max = null, min = null;
2621
- for (const ch of this._def.checks) {
2622
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2623
- return true;
2624
- } else if (ch.kind === "min") {
2625
- if (min === null || ch.value > min)
2626
- min = ch.value;
2627
- } else if (ch.kind === "max") {
2628
- if (max === null || ch.value < max)
2629
- max = ch.value;
2630
- }
2631
- }
2632
- return Number.isFinite(min) && Number.isFinite(max);
2307
+ return !!this._def.checks.find((ch) => ch.kind === "int");
2633
2308
  }
2634
2309
  };
2635
2310
  ZodNumber.create = (params) => {
@@ -2640,167 +2315,27 @@ ZodNumber.create = (params) => {
2640
2315
  ...processCreateParams(params)
2641
2316
  });
2642
2317
  };
2643
- var ZodBigInt = class _ZodBigInt extends ZodType {
2644
- constructor() {
2645
- super(...arguments);
2646
- this.min = this.gte;
2647
- this.max = this.lte;
2648
- }
2318
+ var ZodBigInt = class extends ZodType {
2649
2319
  _parse(input) {
2650
2320
  if (this._def.coerce) {
2651
2321
  input.data = BigInt(input.data);
2652
2322
  }
2653
2323
  const parsedType = this._getType(input);
2654
2324
  if (parsedType !== ZodParsedType.bigint) {
2655
- const ctx2 = this._getOrReturnCtx(input);
2656
- addIssueToContext(ctx2, {
2325
+ const ctx = this._getOrReturnCtx(input);
2326
+ addIssueToContext(ctx, {
2657
2327
  code: ZodIssueCode.invalid_type,
2658
2328
  expected: ZodParsedType.bigint,
2659
- received: ctx2.parsedType
2329
+ received: ctx.parsedType
2660
2330
  });
2661
2331
  return INVALID;
2662
2332
  }
2663
- let ctx = void 0;
2664
- const status = new ParseStatus();
2665
- for (const check of this._def.checks) {
2666
- if (check.kind === "min") {
2667
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2668
- if (tooSmall) {
2669
- ctx = this._getOrReturnCtx(input, ctx);
2670
- addIssueToContext(ctx, {
2671
- code: ZodIssueCode.too_small,
2672
- type: "bigint",
2673
- minimum: check.value,
2674
- inclusive: check.inclusive,
2675
- message: check.message
2676
- });
2677
- status.dirty();
2678
- }
2679
- } else if (check.kind === "max") {
2680
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2681
- if (tooBig) {
2682
- ctx = this._getOrReturnCtx(input, ctx);
2683
- addIssueToContext(ctx, {
2684
- code: ZodIssueCode.too_big,
2685
- type: "bigint",
2686
- maximum: check.value,
2687
- inclusive: check.inclusive,
2688
- message: check.message
2689
- });
2690
- status.dirty();
2691
- }
2692
- } else if (check.kind === "multipleOf") {
2693
- if (input.data % check.value !== BigInt(0)) {
2694
- ctx = this._getOrReturnCtx(input, ctx);
2695
- addIssueToContext(ctx, {
2696
- code: ZodIssueCode.not_multiple_of,
2697
- multipleOf: check.value,
2698
- message: check.message
2699
- });
2700
- status.dirty();
2701
- }
2702
- } else {
2703
- util.assertNever(check);
2704
- }
2705
- }
2706
- return { status: status.value, value: input.data };
2707
- }
2708
- gte(value, message) {
2709
- return this.setLimit("min", value, true, errorUtil.toString(message));
2710
- }
2711
- gt(value, message) {
2712
- return this.setLimit("min", value, false, errorUtil.toString(message));
2713
- }
2714
- lte(value, message) {
2715
- return this.setLimit("max", value, true, errorUtil.toString(message));
2716
- }
2717
- lt(value, message) {
2718
- return this.setLimit("max", value, false, errorUtil.toString(message));
2719
- }
2720
- setLimit(kind, value, inclusive, message) {
2721
- return new _ZodBigInt({
2722
- ...this._def,
2723
- checks: [
2724
- ...this._def.checks,
2725
- {
2726
- kind,
2727
- value,
2728
- inclusive,
2729
- message: errorUtil.toString(message)
2730
- }
2731
- ]
2732
- });
2733
- }
2734
- _addCheck(check) {
2735
- return new _ZodBigInt({
2736
- ...this._def,
2737
- checks: [...this._def.checks, check]
2738
- });
2739
- }
2740
- positive(message) {
2741
- return this._addCheck({
2742
- kind: "min",
2743
- value: BigInt(0),
2744
- inclusive: false,
2745
- message: errorUtil.toString(message)
2746
- });
2747
- }
2748
- negative(message) {
2749
- return this._addCheck({
2750
- kind: "max",
2751
- value: BigInt(0),
2752
- inclusive: false,
2753
- message: errorUtil.toString(message)
2754
- });
2755
- }
2756
- nonpositive(message) {
2757
- return this._addCheck({
2758
- kind: "max",
2759
- value: BigInt(0),
2760
- inclusive: true,
2761
- message: errorUtil.toString(message)
2762
- });
2763
- }
2764
- nonnegative(message) {
2765
- return this._addCheck({
2766
- kind: "min",
2767
- value: BigInt(0),
2768
- inclusive: true,
2769
- message: errorUtil.toString(message)
2770
- });
2771
- }
2772
- multipleOf(value, message) {
2773
- return this._addCheck({
2774
- kind: "multipleOf",
2775
- value,
2776
- message: errorUtil.toString(message)
2777
- });
2778
- }
2779
- get minValue() {
2780
- let min = null;
2781
- for (const ch of this._def.checks) {
2782
- if (ch.kind === "min") {
2783
- if (min === null || ch.value > min)
2784
- min = ch.value;
2785
- }
2786
- }
2787
- return min;
2788
- }
2789
- get maxValue() {
2790
- let max = null;
2791
- for (const ch of this._def.checks) {
2792
- if (ch.kind === "max") {
2793
- if (max === null || ch.value < max)
2794
- max = ch.value;
2795
- }
2796
- }
2797
- return max;
2333
+ return OK(input.data);
2798
2334
  }
2799
2335
  };
2800
2336
  ZodBigInt.create = (params) => {
2801
2337
  var _a;
2802
2338
  return new ZodBigInt({
2803
- checks: [],
2804
2339
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
2805
2340
  coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2806
2341
  ...processCreateParams(params)
@@ -3126,13 +2661,13 @@ var ZodArray = class _ZodArray extends ZodType {
3126
2661
  }
3127
2662
  }
3128
2663
  if (ctx.common.async) {
3129
- return Promise.all([...ctx.data].map((item, i) => {
2664
+ return Promise.all(ctx.data.map((item, i) => {
3130
2665
  return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
3131
2666
  })).then((result2) => {
3132
2667
  return ParseStatus.mergeArray(status, result2);
3133
2668
  });
3134
2669
  }
3135
- const result = [...ctx.data].map((item, i) => {
2670
+ const result = ctx.data.map((item, i) => {
3136
2671
  return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
3137
2672
  });
3138
2673
  return ParseStatus.mergeArray(status, result);
@@ -3172,6 +2707,25 @@ ZodArray.create = (schema3, params) => {
3172
2707
  ...processCreateParams(params)
3173
2708
  });
3174
2709
  };
2710
+ var objectUtil;
2711
+ (function(objectUtil2) {
2712
+ objectUtil2.mergeShapes = (first, second) => {
2713
+ return {
2714
+ ...first,
2715
+ ...second
2716
+ // second overwrites first
2717
+ };
2718
+ };
2719
+ })(objectUtil || (objectUtil = {}));
2720
+ var AugmentFactory = (def) => (augmentation) => {
2721
+ return new ZodObject({
2722
+ ...def,
2723
+ shape: () => ({
2724
+ ...def.shape(),
2725
+ ...augmentation
2726
+ })
2727
+ });
2728
+ };
3175
2729
  function deepPartialify(schema3) {
3176
2730
  if (schema3 instanceof ZodObject) {
3177
2731
  const newShape = {};
@@ -3184,10 +2738,7 @@ function deepPartialify(schema3) {
3184
2738
  shape: () => newShape
3185
2739
  });
3186
2740
  } else if (schema3 instanceof ZodArray) {
3187
- return new ZodArray({
3188
- ...schema3._def,
3189
- type: deepPartialify(schema3.element)
3190
- });
2741
+ return ZodArray.create(deepPartialify(schema3.element));
3191
2742
  } else if (schema3 instanceof ZodOptional) {
3192
2743
  return ZodOptional.create(deepPartialify(schema3.unwrap()));
3193
2744
  } else if (schema3 instanceof ZodNullable) {
@@ -3203,7 +2754,8 @@ var ZodObject = class _ZodObject extends ZodType {
3203
2754
  super(...arguments);
3204
2755
  this._cached = null;
3205
2756
  this.nonstrict = this.passthrough;
3206
- this.augment = this.extend;
2757
+ this.augment = AugmentFactory(this._def);
2758
+ this.extend = AugmentFactory(this._def);
3207
2759
  }
3208
2760
  _getCached() {
3209
2761
  if (this._cached !== null)
@@ -3284,10 +2836,9 @@ var ZodObject = class _ZodObject extends ZodType {
3284
2836
  const syncPairs = [];
3285
2837
  for (const pair of pairs) {
3286
2838
  const key = await pair.key;
3287
- const value = await pair.value;
3288
2839
  syncPairs.push({
3289
2840
  key,
3290
- value,
2841
+ value: await pair.value,
3291
2842
  alwaysSet: pair.alwaysSet
3292
2843
  });
3293
2844
  }
@@ -3334,31 +2885,8 @@ var ZodObject = class _ZodObject extends ZodType {
3334
2885
  unknownKeys: "passthrough"
3335
2886
  });
3336
2887
  }
3337
- // const AugmentFactory =
3338
- // <Def extends ZodObjectDef>(def: Def) =>
3339
- // <Augmentation extends ZodRawShape>(
3340
- // augmentation: Augmentation
3341
- // ): ZodObject<
3342
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
3343
- // Def["unknownKeys"],
3344
- // Def["catchall"]
3345
- // > => {
3346
- // return new ZodObject({
3347
- // ...def,
3348
- // shape: () => ({
3349
- // ...def.shape(),
3350
- // ...augmentation,
3351
- // }),
3352
- // }) as any;
3353
- // };
3354
- extend(augmentation) {
3355
- return new _ZodObject({
3356
- ...this._def,
3357
- shape: () => ({
3358
- ...this._def.shape(),
3359
- ...augmentation
3360
- })
3361
- });
2888
+ setKey(key, schema3) {
2889
+ return this.augment({ [key]: schema3 });
3362
2890
  }
3363
2891
  /**
3364
2892
  * Prior to zod@1.0.12 there was a bug in the
@@ -3369,73 +2897,11 @@ var ZodObject = class _ZodObject extends ZodType {
3369
2897
  const merged = new _ZodObject({
3370
2898
  unknownKeys: merging._def.unknownKeys,
3371
2899
  catchall: merging._def.catchall,
3372
- shape: () => ({
3373
- ...this._def.shape(),
3374
- ...merging._def.shape()
3375
- }),
2900
+ shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3376
2901
  typeName: ZodFirstPartyTypeKind.ZodObject
3377
2902
  });
3378
2903
  return merged;
3379
2904
  }
3380
- // merge<
3381
- // Incoming extends AnyZodObject,
3382
- // Augmentation extends Incoming["shape"],
3383
- // NewOutput extends {
3384
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3385
- // ? Augmentation[k]["_output"]
3386
- // : k extends keyof Output
3387
- // ? Output[k]
3388
- // : never;
3389
- // },
3390
- // NewInput extends {
3391
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3392
- // ? Augmentation[k]["_input"]
3393
- // : k extends keyof Input
3394
- // ? Input[k]
3395
- // : never;
3396
- // }
3397
- // >(
3398
- // merging: Incoming
3399
- // ): ZodObject<
3400
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3401
- // Incoming["_def"]["unknownKeys"],
3402
- // Incoming["_def"]["catchall"],
3403
- // NewOutput,
3404
- // NewInput
3405
- // > {
3406
- // const merged: any = new ZodObject({
3407
- // unknownKeys: merging._def.unknownKeys,
3408
- // catchall: merging._def.catchall,
3409
- // shape: () =>
3410
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3411
- // typeName: ZodFirstPartyTypeKind.ZodObject,
3412
- // }) as any;
3413
- // return merged;
3414
- // }
3415
- setKey(key, schema3) {
3416
- return this.augment({ [key]: schema3 });
3417
- }
3418
- // merge<Incoming extends AnyZodObject>(
3419
- // merging: Incoming
3420
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3421
- // ZodObject<
3422
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3423
- // Incoming["_def"]["unknownKeys"],
3424
- // Incoming["_def"]["catchall"]
3425
- // > {
3426
- // // const mergedShape = objectUtil.mergeShapes(
3427
- // // this._def.shape(),
3428
- // // merging._def.shape()
3429
- // // );
3430
- // const merged: any = new ZodObject({
3431
- // unknownKeys: merging._def.unknownKeys,
3432
- // catchall: merging._def.catchall,
3433
- // shape: () =>
3434
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3435
- // typeName: ZodFirstPartyTypeKind.ZodObject,
3436
- // }) as any;
3437
- // return merged;
3438
- // }
3439
2905
  catchall(index4) {
3440
2906
  return new _ZodObject({
3441
2907
  ...this._def,
@@ -3444,10 +2910,9 @@ var ZodObject = class _ZodObject extends ZodType {
3444
2910
  }
3445
2911
  pick(mask) {
3446
2912
  const shape = {};
3447
- util.objectKeys(mask).forEach((key) => {
3448
- if (mask[key] && this.shape[key]) {
2913
+ util.objectKeys(mask).map((key) => {
2914
+ if (this.shape[key])
3449
2915
  shape[key] = this.shape[key];
3450
- }
3451
2916
  });
3452
2917
  return new _ZodObject({
3453
2918
  ...this._def,
@@ -3456,8 +2921,8 @@ var ZodObject = class _ZodObject extends ZodType {
3456
2921
  }
3457
2922
  omit(mask) {
3458
2923
  const shape = {};
3459
- util.objectKeys(this.shape).forEach((key) => {
3460
- if (!mask[key]) {
2924
+ util.objectKeys(this.shape).map((key) => {
2925
+ if (util.objectKeys(mask).indexOf(key) === -1) {
3461
2926
  shape[key] = this.shape[key];
3462
2927
  }
3463
2928
  });
@@ -3466,22 +2931,29 @@ var ZodObject = class _ZodObject extends ZodType {
3466
2931
  shape: () => shape
3467
2932
  });
3468
2933
  }
3469
- /**
3470
- * @deprecated
3471
- */
3472
2934
  deepPartial() {
3473
2935
  return deepPartialify(this);
3474
2936
  }
3475
2937
  partial(mask) {
3476
2938
  const newShape = {};
3477
- util.objectKeys(this.shape).forEach((key) => {
3478
- const fieldSchema = this.shape[key];
3479
- if (mask && !mask[key]) {
3480
- newShape[key] = fieldSchema;
3481
- } else {
2939
+ if (mask) {
2940
+ util.objectKeys(this.shape).map((key) => {
2941
+ if (util.objectKeys(mask).indexOf(key) === -1) {
2942
+ newShape[key] = this.shape[key];
2943
+ } else {
2944
+ newShape[key] = this.shape[key].optional();
2945
+ }
2946
+ });
2947
+ return new _ZodObject({
2948
+ ...this._def,
2949
+ shape: () => newShape
2950
+ });
2951
+ } else {
2952
+ for (const key in this.shape) {
2953
+ const fieldSchema = this.shape[key];
3482
2954
  newShape[key] = fieldSchema.optional();
3483
2955
  }
3484
- });
2956
+ }
3485
2957
  return new _ZodObject({
3486
2958
  ...this._def,
3487
2959
  shape: () => newShape
@@ -3489,10 +2961,21 @@ var ZodObject = class _ZodObject extends ZodType {
3489
2961
  }
3490
2962
  required(mask) {
3491
2963
  const newShape = {};
3492
- util.objectKeys(this.shape).forEach((key) => {
3493
- if (mask && !mask[key]) {
3494
- newShape[key] = this.shape[key];
3495
- } else {
2964
+ if (mask) {
2965
+ util.objectKeys(this.shape).map((key) => {
2966
+ if (util.objectKeys(mask).indexOf(key) === -1) {
2967
+ newShape[key] = this.shape[key];
2968
+ } else {
2969
+ const fieldSchema = this.shape[key];
2970
+ let newField = fieldSchema;
2971
+ while (newField instanceof ZodOptional) {
2972
+ newField = newField._def.innerType;
2973
+ }
2974
+ newShape[key] = newField;
2975
+ }
2976
+ });
2977
+ } else {
2978
+ for (const key in this.shape) {
3496
2979
  const fieldSchema = this.shape[key];
3497
2980
  let newField = fieldSchema;
3498
2981
  while (newField instanceof ZodOptional) {
@@ -3500,7 +2983,7 @@ var ZodObject = class _ZodObject extends ZodType {
3500
2983
  }
3501
2984
  newShape[key] = newField;
3502
2985
  }
3503
- });
2986
+ }
3504
2987
  return new _ZodObject({
3505
2988
  ...this._def,
3506
2989
  shape: () => newShape
@@ -3638,25 +3121,15 @@ var getDiscriminator = (type) => {
3638
3121
  } else if (type instanceof ZodEnum) {
3639
3122
  return type.options;
3640
3123
  } else if (type instanceof ZodNativeEnum) {
3641
- return util.objectValues(type.enum);
3124
+ return Object.keys(type.enum);
3642
3125
  } else if (type instanceof ZodDefault) {
3643
3126
  return getDiscriminator(type._def.innerType);
3644
3127
  } else if (type instanceof ZodUndefined) {
3645
3128
  return [void 0];
3646
3129
  } else if (type instanceof ZodNull) {
3647
3130
  return [null];
3648
- } else if (type instanceof ZodOptional) {
3649
- return [void 0, ...getDiscriminator(type.unwrap())];
3650
- } else if (type instanceof ZodNullable) {
3651
- return [null, ...getDiscriminator(type.unwrap())];
3652
- } else if (type instanceof ZodBranded) {
3653
- return getDiscriminator(type.unwrap());
3654
- } else if (type instanceof ZodReadonly) {
3655
- return getDiscriminator(type.unwrap());
3656
- } else if (type instanceof ZodCatch) {
3657
- return getDiscriminator(type._def.innerType);
3658
3131
  } else {
3659
- return [];
3132
+ return null;
3660
3133
  }
3661
3134
  };
3662
3135
  var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -3716,7 +3189,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
3716
3189
  const optionsMap = /* @__PURE__ */ new Map();
3717
3190
  for (const type of options) {
3718
3191
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3719
- if (!discriminatorValues.length) {
3192
+ if (!discriminatorValues) {
3720
3193
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3721
3194
  }
3722
3195
  for (const value of discriminatorValues) {
@@ -3858,7 +3331,7 @@ var ZodTuple = class _ZodTuple extends ZodType {
3858
3331
  });
3859
3332
  status.dirty();
3860
3333
  }
3861
- const items = [...ctx.data].map((item, itemIndex) => {
3334
+ const items = ctx.data.map((item, itemIndex) => {
3862
3335
  const schema3 = this._def.items[itemIndex] || this._def.rest;
3863
3336
  if (!schema3)
3864
3337
  return null;
@@ -3916,8 +3389,7 @@ var ZodRecord = class _ZodRecord extends ZodType {
3916
3389
  for (const key in ctx.data) {
3917
3390
  pairs.push({
3918
3391
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3919
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3920
- alwaysSet: key in ctx.data
3392
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3921
3393
  });
3922
3394
  }
3923
3395
  if (ctx.common.async) {
@@ -3947,12 +3419,6 @@ var ZodRecord = class _ZodRecord extends ZodType {
3947
3419
  }
3948
3420
  };
3949
3421
  var ZodMap = class extends ZodType {
3950
- get keySchema() {
3951
- return this._def.keyType;
3952
- }
3953
- get valueSchema() {
3954
- return this._def.valueType;
3955
- }
3956
3422
  _parse(input) {
3957
3423
  const { status, ctx } = this._processInputParams(input);
3958
3424
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -4147,29 +3613,27 @@ var ZodFunction = class _ZodFunction extends ZodType {
4147
3613
  const params = { errorMap: ctx.common.contextualErrorMap };
4148
3614
  const fn = ctx.data;
4149
3615
  if (this._def.returns instanceof ZodPromise) {
4150
- const me = this;
4151
- return OK(async function(...args) {
3616
+ return OK(async (...args) => {
4152
3617
  const error = new ZodError([]);
4153
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3618
+ const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
4154
3619
  error.addIssue(makeArgsIssue(args, e));
4155
3620
  throw error;
4156
3621
  });
4157
- const result = await Reflect.apply(fn, this, parsedArgs);
4158
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3622
+ const result = await fn(...parsedArgs);
3623
+ const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
4159
3624
  error.addIssue(makeReturnsIssue(result, e));
4160
3625
  throw error;
4161
3626
  });
4162
3627
  return parsedReturns;
4163
3628
  });
4164
3629
  } else {
4165
- const me = this;
4166
- return OK(function(...args) {
4167
- const parsedArgs = me._def.args.safeParse(args, params);
3630
+ return OK((...args) => {
3631
+ const parsedArgs = this._def.args.safeParse(args, params);
4168
3632
  if (!parsedArgs.success) {
4169
3633
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
4170
3634
  }
4171
- const result = Reflect.apply(fn, this, parsedArgs.data);
4172
- const parsedReturns = me._def.returns.safeParse(result, params);
3635
+ const result = fn(...parsedArgs.data);
3636
+ const parsedReturns = this._def.returns.safeParse(result, params);
4173
3637
  if (!parsedReturns.success) {
4174
3638
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
4175
3639
  }
@@ -4234,7 +3698,6 @@ var ZodLiteral = class extends ZodType {
4234
3698
  if (input.data !== this._def.value) {
4235
3699
  const ctx = this._getOrReturnCtx(input);
4236
3700
  addIssueToContext(ctx, {
4237
- received: ctx.data,
4238
3701
  code: ZodIssueCode.invalid_literal,
4239
3702
  expected: this._def.value
4240
3703
  });
@@ -4260,11 +3723,7 @@ function createZodEnum(values, params) {
4260
3723
  ...processCreateParams(params)
4261
3724
  });
4262
3725
  }
4263
- var ZodEnum = class _ZodEnum extends ZodType {
4264
- constructor() {
4265
- super(...arguments);
4266
- _ZodEnum_cache.set(this, void 0);
4267
- }
3726
+ var ZodEnum = class extends ZodType {
4268
3727
  _parse(input) {
4269
3728
  if (typeof input.data !== "string") {
4270
3729
  const ctx = this._getOrReturnCtx(input);
@@ -4276,10 +3735,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
4276
3735
  });
4277
3736
  return INVALID;
4278
3737
  }
4279
- if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
4280
- __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
4281
- }
4282
- if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3738
+ if (this._def.values.indexOf(input.data) === -1) {
4283
3739
  const ctx = this._getOrReturnCtx(input);
4284
3740
  const expectedValues = this._def.values;
4285
3741
  addIssueToContext(ctx, {
@@ -4315,26 +3771,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
4315
3771
  }
4316
3772
  return enumValues;
4317
3773
  }
4318
- extract(values, newDef = this._def) {
4319
- return _ZodEnum.create(values, {
4320
- ...this._def,
4321
- ...newDef
4322
- });
4323
- }
4324
- exclude(values, newDef = this._def) {
4325
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4326
- ...this._def,
4327
- ...newDef
4328
- });
4329
- }
4330
3774
  };
4331
- _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
4332
3775
  ZodEnum.create = createZodEnum;
4333
3776
  var ZodNativeEnum = class extends ZodType {
4334
- constructor() {
4335
- super(...arguments);
4336
- _ZodNativeEnum_cache.set(this, void 0);
4337
- }
4338
3777
  _parse(input) {
4339
3778
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
4340
3779
  const ctx = this._getOrReturnCtx(input);
@@ -4347,10 +3786,7 @@ var ZodNativeEnum = class extends ZodType {
4347
3786
  });
4348
3787
  return INVALID;
4349
3788
  }
4350
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
4351
- __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
4352
- }
4353
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3789
+ if (nativeEnumValues.indexOf(input.data) === -1) {
4354
3790
  const expectedValues = util.objectValues(nativeEnumValues);
4355
3791
  addIssueToContext(ctx, {
4356
3792
  received: ctx.data,
@@ -4365,7 +3801,6 @@ var ZodNativeEnum = class extends ZodType {
4365
3801
  return this._def.values;
4366
3802
  }
4367
3803
  };
4368
- _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
4369
3804
  ZodNativeEnum.create = (values, params) => {
4370
3805
  return new ZodNativeEnum({
4371
3806
  values,
@@ -4374,9 +3809,6 @@ ZodNativeEnum.create = (values, params) => {
4374
3809
  });
4375
3810
  };
4376
3811
  var ZodPromise = class extends ZodType {
4377
- unwrap() {
4378
- return this._def.type;
4379
- }
4380
3812
  _parse(input) {
4381
3813
  const { ctx } = this._processInputParams(input);
4382
3814
  if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
@@ -4413,56 +3845,38 @@ var ZodEffects = class extends ZodType {
4413
3845
  _parse(input) {
4414
3846
  const { status, ctx } = this._processInputParams(input);
4415
3847
  const effect = this._def.effect || null;
4416
- const checkCtx = {
4417
- addIssue: (arg) => {
4418
- addIssueToContext(ctx, arg);
4419
- if (arg.fatal) {
4420
- status.abort();
4421
- } else {
4422
- status.dirty();
4423
- }
4424
- },
4425
- get path() {
4426
- return ctx.path;
4427
- }
4428
- };
4429
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4430
3848
  if (effect.type === "preprocess") {
4431
- const processed = effect.transform(ctx.data, checkCtx);
3849
+ const processed = effect.transform(ctx.data);
4432
3850
  if (ctx.common.async) {
4433
- return Promise.resolve(processed).then(async (processed2) => {
4434
- if (status.value === "aborted")
4435
- return INVALID;
4436
- const result = await this._def.schema._parseAsync({
3851
+ return Promise.resolve(processed).then((processed2) => {
3852
+ return this._def.schema._parseAsync({
4437
3853
  data: processed2,
4438
3854
  path: ctx.path,
4439
3855
  parent: ctx
4440
3856
  });
4441
- if (result.status === "aborted")
4442
- return INVALID;
4443
- if (result.status === "dirty")
4444
- return DIRTY(result.value);
4445
- if (status.value === "dirty")
4446
- return DIRTY(result.value);
4447
- return result;
4448
3857
  });
4449
3858
  } else {
4450
- if (status.value === "aborted")
4451
- return INVALID;
4452
- const result = this._def.schema._parseSync({
3859
+ return this._def.schema._parseSync({
4453
3860
  data: processed,
4454
3861
  path: ctx.path,
4455
3862
  parent: ctx
4456
3863
  });
4457
- if (result.status === "aborted")
4458
- return INVALID;
4459
- if (result.status === "dirty")
4460
- return DIRTY(result.value);
4461
- if (status.value === "dirty")
4462
- return DIRTY(result.value);
4463
- return result;
4464
3864
  }
4465
3865
  }
3866
+ const checkCtx = {
3867
+ addIssue: (arg) => {
3868
+ addIssueToContext(ctx, arg);
3869
+ if (arg.fatal) {
3870
+ status.abort();
3871
+ } else {
3872
+ status.dirty();
3873
+ }
3874
+ },
3875
+ get path() {
3876
+ return ctx.path;
3877
+ }
3878
+ };
3879
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4466
3880
  if (effect.type === "refinement") {
4467
3881
  const executeRefinement = (acc) => {
4468
3882
  const result = effect.refinement(acc, checkCtx);
@@ -4605,45 +4019,26 @@ ZodDefault.create = (type, params) => {
4605
4019
  var ZodCatch = class extends ZodType {
4606
4020
  _parse(input) {
4607
4021
  const { ctx } = this._processInputParams(input);
4608
- const newCtx = {
4609
- ...ctx,
4610
- common: {
4611
- ...ctx.common,
4612
- issues: []
4613
- }
4614
- };
4615
4022
  const result = this._def.innerType._parse({
4616
- data: newCtx.data,
4617
- path: newCtx.path,
4618
- parent: {
4619
- ...newCtx
4620
- }
4023
+ data: ctx.data,
4024
+ path: ctx.path,
4025
+ parent: ctx
4621
4026
  });
4622
4027
  if (isAsync(result)) {
4623
4028
  return result.then((result2) => {
4624
4029
  return {
4625
4030
  status: "valid",
4626
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
4627
- get error() {
4628
- return new ZodError(newCtx.common.issues);
4629
- },
4630
- input: newCtx.data
4631
- })
4031
+ value: result2.status === "valid" ? result2.value : this._def.defaultValue()
4632
4032
  };
4633
4033
  });
4634
4034
  } else {
4635
4035
  return {
4636
4036
  status: "valid",
4637
- value: result.status === "valid" ? result.value : this._def.catchValue({
4638
- get error() {
4639
- return new ZodError(newCtx.common.issues);
4640
- },
4641
- input: newCtx.data
4642
- })
4037
+ value: result.status === "valid" ? result.value : this._def.defaultValue()
4643
4038
  };
4644
4039
  }
4645
4040
  }
4646
- removeCatch() {
4041
+ removeDefault() {
4647
4042
  return this._def.innerType;
4648
4043
  }
4649
4044
  };
@@ -4651,7 +4046,7 @@ ZodCatch.create = (type, params) => {
4651
4046
  return new ZodCatch({
4652
4047
  innerType: type,
4653
4048
  typeName: ZodFirstPartyTypeKind.ZodCatch,
4654
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4049
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4655
4050
  ...processCreateParams(params)
4656
4051
  });
4657
4052
  };
@@ -4746,25 +4141,6 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
4746
4141
  });
4747
4142
  }
4748
4143
  };
4749
- var ZodReadonly = class extends ZodType {
4750
- _parse(input) {
4751
- const result = this._def.innerType._parse(input);
4752
- if (isValid(result)) {
4753
- result.value = Object.freeze(result.value);
4754
- }
4755
- return result;
4756
- }
4757
- unwrap() {
4758
- return this._def.innerType;
4759
- }
4760
- };
4761
- ZodReadonly.create = (type, params) => {
4762
- return new ZodReadonly({
4763
- innerType: type,
4764
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
4765
- ...processCreateParams(params)
4766
- });
4767
- };
4768
4144
  var late = {
4769
4145
  object: ZodObject.lazycreate
4770
4146
  };
@@ -4805,7 +4181,6 @@ var ZodFirstPartyTypeKind;
4805
4181
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4806
4182
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4807
4183
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4808
- ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4809
4184
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4810
4185
  var stringType = ZodString.create;
4811
4186
  var numberType = ZodNumber.create;