drizzle-kit 0.31.1-a42461b → 0.31.1-ab4d983
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.d.mts +466 -466
- package/api.d.ts +466 -466
- package/api.js +531 -329
- package/api.mjs +534 -332
- package/bin.cjs +20842 -20325
- package/package.json +1 -1
- package/utils.js +266 -152
- package/utils.mjs +266 -152
package/utils.mjs
CHANGED
@@ -556,7 +556,7 @@ var require_hanji = __commonJS({
|
|
556
556
|
}
|
557
557
|
});
|
558
558
|
|
559
|
-
// ../node_modules/.pnpm/chalk@5.
|
559
|
+
// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/ansi-styles/index.js
|
560
560
|
var ANSI_BACKGROUND_OFFSET = 10;
|
561
561
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
562
562
|
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
@@ -742,7 +742,7 @@ function assembleStyles() {
|
|
742
742
|
var ansiStyles = assembleStyles();
|
743
743
|
var ansi_styles_default = ansiStyles;
|
744
744
|
|
745
|
-
// ../node_modules/.pnpm/chalk@5.
|
745
|
+
// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/supports-color/index.js
|
746
746
|
import process2 from "node:process";
|
747
747
|
import os from "node:os";
|
748
748
|
import tty from "node:tty";
|
@@ -816,10 +816,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
816
816
|
return 1;
|
817
817
|
}
|
818
818
|
if ("CI" in env) {
|
819
|
-
if ("GITHUB_ACTIONS"
|
819
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
820
820
|
return 3;
|
821
821
|
}
|
822
|
-
if (["TRAVIS", "
|
822
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
823
823
|
return 1;
|
824
824
|
}
|
825
825
|
return min;
|
@@ -868,7 +868,7 @@ var supportsColor = {
|
|
868
868
|
};
|
869
869
|
var supports_color_default = supportsColor;
|
870
870
|
|
871
|
-
// ../node_modules/.pnpm/chalk@5.
|
871
|
+
// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js
|
872
872
|
function stringReplaceAll(string, substring, replacer) {
|
873
873
|
let index6 = string.indexOf(substring);
|
874
874
|
if (index6 === -1) {
|
@@ -898,7 +898,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index6) {
|
|
898
898
|
return returnValue;
|
899
899
|
}
|
900
900
|
|
901
|
-
// ../node_modules/.pnpm/chalk@5.
|
901
|
+
// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/index.js
|
902
902
|
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
903
903
|
var GENERATOR = Symbol("GENERATOR");
|
904
904
|
var STYLER = Symbol("STYLER");
|
@@ -1063,10 +1063,11 @@ function assertUnreachable(x) {
|
|
1063
1063
|
throw new Error("Didn't expect to get here");
|
1064
1064
|
}
|
1065
1065
|
|
1066
|
-
// ../node_modules/.pnpm/zod@3.
|
1066
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/util.js
|
1067
1067
|
var util;
|
1068
1068
|
(function(util2) {
|
1069
|
-
util2.assertEqual = (
|
1069
|
+
util2.assertEqual = (_) => {
|
1070
|
+
};
|
1070
1071
|
function assertIs(_arg) {
|
1071
1072
|
}
|
1072
1073
|
util2.assertIs = assertIs;
|
@@ -1110,7 +1111,7 @@ var util;
|
|
1110
1111
|
}
|
1111
1112
|
return void 0;
|
1112
1113
|
};
|
1113
|
-
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
1114
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
1114
1115
|
function joinValues(array, separator = " | ") {
|
1115
1116
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
1116
1117
|
}
|
@@ -1162,7 +1163,7 @@ var getParsedType = (data) => {
|
|
1162
1163
|
case "string":
|
1163
1164
|
return ZodParsedType.string;
|
1164
1165
|
case "number":
|
1165
|
-
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
1166
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
1166
1167
|
case "boolean":
|
1167
1168
|
return ZodParsedType.boolean;
|
1168
1169
|
case "function":
|
@@ -1195,6 +1196,8 @@ var getParsedType = (data) => {
|
|
1195
1196
|
return ZodParsedType.unknown;
|
1196
1197
|
}
|
1197
1198
|
};
|
1199
|
+
|
1200
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/ZodError.js
|
1198
1201
|
var ZodIssueCode = util.arrayToEnum([
|
1199
1202
|
"invalid_type",
|
1200
1203
|
"invalid_literal",
|
@@ -1214,6 +1217,9 @@ var ZodIssueCode = util.arrayToEnum([
|
|
1214
1217
|
"not_finite"
|
1215
1218
|
]);
|
1216
1219
|
var ZodError = class _ZodError extends Error {
|
1220
|
+
get errors() {
|
1221
|
+
return this.issues;
|
1222
|
+
}
|
1217
1223
|
constructor(issues) {
|
1218
1224
|
super();
|
1219
1225
|
this.issues = [];
|
@@ -1232,9 +1238,6 @@ var ZodError = class _ZodError extends Error {
|
|
1232
1238
|
this.name = "ZodError";
|
1233
1239
|
this.issues = issues;
|
1234
1240
|
}
|
1235
|
-
get errors() {
|
1236
|
-
return this.issues;
|
1237
|
-
}
|
1238
1241
|
format(_mapper) {
|
1239
1242
|
const mapper = _mapper || function(issue) {
|
1240
1243
|
return issue.message;
|
@@ -1306,6 +1309,8 @@ ZodError.create = (issues) => {
|
|
1306
1309
|
const error = new ZodError(issues);
|
1307
1310
|
return error;
|
1308
1311
|
};
|
1312
|
+
|
1313
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/locales/en.js
|
1309
1314
|
var errorMap = (issue, _ctx) => {
|
1310
1315
|
let message;
|
1311
1316
|
switch (issue.code) {
|
@@ -1404,10 +1409,15 @@ var errorMap = (issue, _ctx) => {
|
|
1404
1409
|
}
|
1405
1410
|
return { message };
|
1406
1411
|
};
|
1407
|
-
var
|
1412
|
+
var en_default = errorMap;
|
1413
|
+
|
1414
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/errors.js
|
1415
|
+
var overrideErrorMap = en_default;
|
1408
1416
|
function getErrorMap() {
|
1409
1417
|
return overrideErrorMap;
|
1410
1418
|
}
|
1419
|
+
|
1420
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/parseUtil.js
|
1411
1421
|
var makeIssue = (params) => {
|
1412
1422
|
const { data, path, errorMaps, issueData } = params;
|
1413
1423
|
const fullPath = [...path, ...issueData.path || []];
|
@@ -1441,9 +1451,12 @@ function addIssueToContext(ctx, issueData) {
|
|
1441
1451
|
path: ctx.path,
|
1442
1452
|
errorMaps: [
|
1443
1453
|
ctx.common.contextualErrorMap,
|
1454
|
+
// contextual error map is first priority
|
1444
1455
|
ctx.schemaErrorMap,
|
1456
|
+
// then schema-bound map if available
|
1445
1457
|
overrideMap,
|
1446
|
-
|
1458
|
+
// then global override map
|
1459
|
+
overrideMap === en_default ? void 0 : en_default
|
1447
1460
|
// then global default map
|
1448
1461
|
].filter((x) => !!x)
|
1449
1462
|
});
|
@@ -1512,24 +1525,15 @@ var isAborted = (x) => x.status === "aborted";
|
|
1512
1525
|
var isDirty = (x) => x.status === "dirty";
|
1513
1526
|
var isValid = (x) => x.status === "valid";
|
1514
1527
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
1515
|
-
|
1516
|
-
|
1517
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
1518
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
1519
|
-
}
|
1520
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
1521
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
1522
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
1523
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
1524
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
1525
|
-
}
|
1528
|
+
|
1529
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/errorUtil.js
|
1526
1530
|
var errorUtil;
|
1527
1531
|
(function(errorUtil2) {
|
1528
1532
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
1529
|
-
errorUtil2.toString = (message) => typeof message === "string" ? message : message
|
1533
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
|
1530
1534
|
})(errorUtil || (errorUtil = {}));
|
1531
|
-
|
1532
|
-
|
1535
|
+
|
1536
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/types.js
|
1533
1537
|
var ParseInputLazyPath = class {
|
1534
1538
|
constructor(parent, value, path, key) {
|
1535
1539
|
this._cachedPath = [];
|
@@ -1540,7 +1544,7 @@ var ParseInputLazyPath = class {
|
|
1540
1544
|
}
|
1541
1545
|
get path() {
|
1542
1546
|
if (!this._cachedPath.length) {
|
1543
|
-
if (this._key
|
1547
|
+
if (Array.isArray(this._key)) {
|
1544
1548
|
this._cachedPath.push(...this._path, ...this._key);
|
1545
1549
|
} else {
|
1546
1550
|
this._cachedPath.push(...this._path, this._key);
|
@@ -1578,49 +1582,20 @@ function processCreateParams(params) {
|
|
1578
1582
|
if (errorMap2)
|
1579
1583
|
return { errorMap: errorMap2, description };
|
1580
1584
|
const customMap = (iss, ctx) => {
|
1581
|
-
var _a, _b;
|
1582
1585
|
const { message } = params;
|
1583
1586
|
if (iss.code === "invalid_enum_value") {
|
1584
|
-
return { message: message
|
1587
|
+
return { message: message ?? ctx.defaultError };
|
1585
1588
|
}
|
1586
1589
|
if (typeof ctx.data === "undefined") {
|
1587
|
-
return { message:
|
1590
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
1588
1591
|
}
|
1589
1592
|
if (iss.code !== "invalid_type")
|
1590
1593
|
return { message: ctx.defaultError };
|
1591
|
-
return { message:
|
1594
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
1592
1595
|
};
|
1593
1596
|
return { errorMap: customMap, description };
|
1594
1597
|
}
|
1595
1598
|
var ZodType = class {
|
1596
|
-
constructor(def) {
|
1597
|
-
this.spa = this.safeParseAsync;
|
1598
|
-
this._def = def;
|
1599
|
-
this.parse = this.parse.bind(this);
|
1600
|
-
this.safeParse = this.safeParse.bind(this);
|
1601
|
-
this.parseAsync = this.parseAsync.bind(this);
|
1602
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
1603
|
-
this.spa = this.spa.bind(this);
|
1604
|
-
this.refine = this.refine.bind(this);
|
1605
|
-
this.refinement = this.refinement.bind(this);
|
1606
|
-
this.superRefine = this.superRefine.bind(this);
|
1607
|
-
this.optional = this.optional.bind(this);
|
1608
|
-
this.nullable = this.nullable.bind(this);
|
1609
|
-
this.nullish = this.nullish.bind(this);
|
1610
|
-
this.array = this.array.bind(this);
|
1611
|
-
this.promise = this.promise.bind(this);
|
1612
|
-
this.or = this.or.bind(this);
|
1613
|
-
this.and = this.and.bind(this);
|
1614
|
-
this.transform = this.transform.bind(this);
|
1615
|
-
this.brand = this.brand.bind(this);
|
1616
|
-
this.default = this.default.bind(this);
|
1617
|
-
this.catch = this.catch.bind(this);
|
1618
|
-
this.describe = this.describe.bind(this);
|
1619
|
-
this.pipe = this.pipe.bind(this);
|
1620
|
-
this.readonly = this.readonly.bind(this);
|
1621
|
-
this.isNullable = this.isNullable.bind(this);
|
1622
|
-
this.isOptional = this.isOptional.bind(this);
|
1623
|
-
}
|
1624
1599
|
get description() {
|
1625
1600
|
return this._def.description;
|
1626
1601
|
}
|
@@ -1668,14 +1643,13 @@ var ZodType = class {
|
|
1668
1643
|
throw result.error;
|
1669
1644
|
}
|
1670
1645
|
safeParse(data, params) {
|
1671
|
-
var _a;
|
1672
1646
|
const ctx = {
|
1673
1647
|
common: {
|
1674
1648
|
issues: [],
|
1675
|
-
async: (
|
1676
|
-
contextualErrorMap: params
|
1649
|
+
async: (params == null ? void 0 : params.async) ?? false,
|
1650
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap
|
1677
1651
|
},
|
1678
|
-
path: (params
|
1652
|
+
path: (params == null ? void 0 : params.path) || [],
|
1679
1653
|
schemaErrorMap: this._def.errorMap,
|
1680
1654
|
parent: null,
|
1681
1655
|
data,
|
@@ -1684,6 +1658,43 @@ var ZodType = class {
|
|
1684
1658
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
1685
1659
|
return handleResult(ctx, result);
|
1686
1660
|
}
|
1661
|
+
"~validate"(data) {
|
1662
|
+
var _a, _b;
|
1663
|
+
const ctx = {
|
1664
|
+
common: {
|
1665
|
+
issues: [],
|
1666
|
+
async: !!this["~standard"].async
|
1667
|
+
},
|
1668
|
+
path: [],
|
1669
|
+
schemaErrorMap: this._def.errorMap,
|
1670
|
+
parent: null,
|
1671
|
+
data,
|
1672
|
+
parsedType: getParsedType(data)
|
1673
|
+
};
|
1674
|
+
if (!this["~standard"].async) {
|
1675
|
+
try {
|
1676
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
1677
|
+
return isValid(result) ? {
|
1678
|
+
value: result.value
|
1679
|
+
} : {
|
1680
|
+
issues: ctx.common.issues
|
1681
|
+
};
|
1682
|
+
} catch (err) {
|
1683
|
+
if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {
|
1684
|
+
this["~standard"].async = true;
|
1685
|
+
}
|
1686
|
+
ctx.common = {
|
1687
|
+
issues: [],
|
1688
|
+
async: true
|
1689
|
+
};
|
1690
|
+
}
|
1691
|
+
}
|
1692
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
1693
|
+
value: result.value
|
1694
|
+
} : {
|
1695
|
+
issues: ctx.common.issues
|
1696
|
+
});
|
1697
|
+
}
|
1687
1698
|
async parseAsync(data, params) {
|
1688
1699
|
const result = await this.safeParseAsync(data, params);
|
1689
1700
|
if (result.success)
|
@@ -1694,10 +1705,10 @@ var ZodType = class {
|
|
1694
1705
|
const ctx = {
|
1695
1706
|
common: {
|
1696
1707
|
issues: [],
|
1697
|
-
contextualErrorMap: params
|
1708
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap,
|
1698
1709
|
async: true
|
1699
1710
|
},
|
1700
|
-
path: (params
|
1711
|
+
path: (params == null ? void 0 : params.path) || [],
|
1701
1712
|
schemaErrorMap: this._def.errorMap,
|
1702
1713
|
parent: null,
|
1703
1714
|
data,
|
@@ -1761,6 +1772,39 @@ var ZodType = class {
|
|
1761
1772
|
superRefine(refinement) {
|
1762
1773
|
return this._refinement(refinement);
|
1763
1774
|
}
|
1775
|
+
constructor(def) {
|
1776
|
+
this.spa = this.safeParseAsync;
|
1777
|
+
this._def = def;
|
1778
|
+
this.parse = this.parse.bind(this);
|
1779
|
+
this.safeParse = this.safeParse.bind(this);
|
1780
|
+
this.parseAsync = this.parseAsync.bind(this);
|
1781
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
1782
|
+
this.spa = this.spa.bind(this);
|
1783
|
+
this.refine = this.refine.bind(this);
|
1784
|
+
this.refinement = this.refinement.bind(this);
|
1785
|
+
this.superRefine = this.superRefine.bind(this);
|
1786
|
+
this.optional = this.optional.bind(this);
|
1787
|
+
this.nullable = this.nullable.bind(this);
|
1788
|
+
this.nullish = this.nullish.bind(this);
|
1789
|
+
this.array = this.array.bind(this);
|
1790
|
+
this.promise = this.promise.bind(this);
|
1791
|
+
this.or = this.or.bind(this);
|
1792
|
+
this.and = this.and.bind(this);
|
1793
|
+
this.transform = this.transform.bind(this);
|
1794
|
+
this.brand = this.brand.bind(this);
|
1795
|
+
this.default = this.default.bind(this);
|
1796
|
+
this.catch = this.catch.bind(this);
|
1797
|
+
this.describe = this.describe.bind(this);
|
1798
|
+
this.pipe = this.pipe.bind(this);
|
1799
|
+
this.readonly = this.readonly.bind(this);
|
1800
|
+
this.isNullable = this.isNullable.bind(this);
|
1801
|
+
this.isOptional = this.isOptional.bind(this);
|
1802
|
+
this["~standard"] = {
|
1803
|
+
version: 1,
|
1804
|
+
vendor: "zod",
|
1805
|
+
validate: (data) => this["~validate"](data)
|
1806
|
+
};
|
1807
|
+
}
|
1764
1808
|
optional() {
|
1765
1809
|
return ZodOptional.create(this, this._def);
|
1766
1810
|
}
|
@@ -1771,7 +1815,7 @@ var ZodType = class {
|
|
1771
1815
|
return this.nullable().optional();
|
1772
1816
|
}
|
1773
1817
|
array() {
|
1774
|
-
return ZodArray.create(this
|
1818
|
+
return ZodArray.create(this);
|
1775
1819
|
}
|
1776
1820
|
promise() {
|
1777
1821
|
return ZodPromise.create(this, this._def);
|
@@ -1837,26 +1881,31 @@ var ZodType = class {
|
|
1837
1881
|
};
|
1838
1882
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
1839
1883
|
var cuid2Regex = /^[0-9a-z]+$/;
|
1840
|
-
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
1884
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
1841
1885
|
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;
|
1842
1886
|
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
1887
|
+
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
1843
1888
|
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)?)??$/;
|
1844
1889
|
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
1845
1890
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
1846
1891
|
var emojiRegex;
|
1847
1892
|
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])$/;
|
1848
|
-
var
|
1893
|
+
var ipv4CidrRegex = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/;
|
1894
|
+
var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
1895
|
+
var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
1849
1896
|
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
1897
|
+
var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
1850
1898
|
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])))`;
|
1851
1899
|
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
1852
1900
|
function timeRegexSource(args) {
|
1853
|
-
let
|
1901
|
+
let secondsRegexSource = `[0-5]\\d`;
|
1854
1902
|
if (args.precision) {
|
1855
|
-
|
1903
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
1856
1904
|
} else if (args.precision == null) {
|
1857
|
-
|
1905
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
1858
1906
|
}
|
1859
|
-
|
1907
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
1908
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
1860
1909
|
}
|
1861
1910
|
function timeRegex(args) {
|
1862
1911
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
@@ -1879,6 +1928,35 @@ function isValidIP(ip, version) {
|
|
1879
1928
|
}
|
1880
1929
|
return false;
|
1881
1930
|
}
|
1931
|
+
function isValidJWT(jwt, alg) {
|
1932
|
+
if (!jwtRegex.test(jwt))
|
1933
|
+
return false;
|
1934
|
+
try {
|
1935
|
+
const [header] = jwt.split(".");
|
1936
|
+
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
1937
|
+
const decoded = JSON.parse(atob(base64));
|
1938
|
+
if (typeof decoded !== "object" || decoded === null)
|
1939
|
+
return false;
|
1940
|
+
if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")
|
1941
|
+
return false;
|
1942
|
+
if (!decoded.alg)
|
1943
|
+
return false;
|
1944
|
+
if (alg && decoded.alg !== alg)
|
1945
|
+
return false;
|
1946
|
+
return true;
|
1947
|
+
} catch {
|
1948
|
+
return false;
|
1949
|
+
}
|
1950
|
+
}
|
1951
|
+
function isValidCidr(ip, version) {
|
1952
|
+
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
|
1953
|
+
return true;
|
1954
|
+
}
|
1955
|
+
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
|
1956
|
+
return true;
|
1957
|
+
}
|
1958
|
+
return false;
|
1959
|
+
}
|
1882
1960
|
var ZodString = class _ZodString extends ZodType {
|
1883
1961
|
_parse(input) {
|
1884
1962
|
if (this._def.coerce) {
|
@@ -2025,7 +2103,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
2025
2103
|
} else if (check.kind === "url") {
|
2026
2104
|
try {
|
2027
2105
|
new URL(input.data);
|
2028
|
-
} catch
|
2106
|
+
} catch {
|
2029
2107
|
ctx = this._getOrReturnCtx(input, ctx);
|
2030
2108
|
addIssueToContext(ctx, {
|
2031
2109
|
validation: "url",
|
@@ -2135,6 +2213,26 @@ var ZodString = class _ZodString extends ZodType {
|
|
2135
2213
|
});
|
2136
2214
|
status.dirty();
|
2137
2215
|
}
|
2216
|
+
} else if (check.kind === "jwt") {
|
2217
|
+
if (!isValidJWT(input.data, check.alg)) {
|
2218
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2219
|
+
addIssueToContext(ctx, {
|
2220
|
+
validation: "jwt",
|
2221
|
+
code: ZodIssueCode.invalid_string,
|
2222
|
+
message: check.message
|
2223
|
+
});
|
2224
|
+
status.dirty();
|
2225
|
+
}
|
2226
|
+
} else if (check.kind === "cidr") {
|
2227
|
+
if (!isValidCidr(input.data, check.version)) {
|
2228
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2229
|
+
addIssueToContext(ctx, {
|
2230
|
+
validation: "cidr",
|
2231
|
+
code: ZodIssueCode.invalid_string,
|
2232
|
+
message: check.message
|
2233
|
+
});
|
2234
|
+
status.dirty();
|
2235
|
+
}
|
2138
2236
|
} else if (check.kind === "base64") {
|
2139
2237
|
if (!base64Regex.test(input.data)) {
|
2140
2238
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -2145,6 +2243,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
2145
2243
|
});
|
2146
2244
|
status.dirty();
|
2147
2245
|
}
|
2246
|
+
} else if (check.kind === "base64url") {
|
2247
|
+
if (!base64urlRegex.test(input.data)) {
|
2248
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2249
|
+
addIssueToContext(ctx, {
|
2250
|
+
validation: "base64url",
|
2251
|
+
code: ZodIssueCode.invalid_string,
|
2252
|
+
message: check.message
|
2253
|
+
});
|
2254
|
+
status.dirty();
|
2255
|
+
}
|
2148
2256
|
} else {
|
2149
2257
|
util.assertNever(check);
|
2150
2258
|
}
|
@@ -2191,11 +2299,22 @@ var ZodString = class _ZodString extends ZodType {
|
|
2191
2299
|
base64(message) {
|
2192
2300
|
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
2193
2301
|
}
|
2302
|
+
base64url(message) {
|
2303
|
+
return this._addCheck({
|
2304
|
+
kind: "base64url",
|
2305
|
+
...errorUtil.errToObj(message)
|
2306
|
+
});
|
2307
|
+
}
|
2308
|
+
jwt(options) {
|
2309
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
2310
|
+
}
|
2194
2311
|
ip(options) {
|
2195
2312
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
2196
2313
|
}
|
2314
|
+
cidr(options) {
|
2315
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
2316
|
+
}
|
2197
2317
|
datetime(options) {
|
2198
|
-
var _a, _b;
|
2199
2318
|
if (typeof options === "string") {
|
2200
2319
|
return this._addCheck({
|
2201
2320
|
kind: "datetime",
|
@@ -2207,10 +2326,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
2207
2326
|
}
|
2208
2327
|
return this._addCheck({
|
2209
2328
|
kind: "datetime",
|
2210
|
-
precision: typeof (options
|
2211
|
-
offset: (
|
2212
|
-
local: (
|
2213
|
-
...errorUtil.errToObj(options
|
2329
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
2330
|
+
offset: (options == null ? void 0 : options.offset) ?? false,
|
2331
|
+
local: (options == null ? void 0 : options.local) ?? false,
|
2332
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
2214
2333
|
});
|
2215
2334
|
}
|
2216
2335
|
date(message) {
|
@@ -2226,8 +2345,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
2226
2345
|
}
|
2227
2346
|
return this._addCheck({
|
2228
2347
|
kind: "time",
|
2229
|
-
precision: typeof (options
|
2230
|
-
...errorUtil.errToObj(options
|
2348
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
2349
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
2231
2350
|
});
|
2232
2351
|
}
|
2233
2352
|
duration(message) {
|
@@ -2244,8 +2363,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
2244
2363
|
return this._addCheck({
|
2245
2364
|
kind: "includes",
|
2246
2365
|
value,
|
2247
|
-
position: options
|
2248
|
-
...errorUtil.errToObj(options
|
2366
|
+
position: options == null ? void 0 : options.position,
|
2367
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
2249
2368
|
});
|
2250
2369
|
}
|
2251
2370
|
startsWith(value, message) {
|
@@ -2284,8 +2403,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
2284
2403
|
});
|
2285
2404
|
}
|
2286
2405
|
/**
|
2287
|
-
*
|
2288
|
-
* @see {@link ZodString.min}
|
2406
|
+
* Equivalent to `.min(1)`
|
2289
2407
|
*/
|
2290
2408
|
nonempty(message) {
|
2291
2409
|
return this.min(1, errorUtil.errToObj(message));
|
@@ -2347,9 +2465,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
2347
2465
|
get isIP() {
|
2348
2466
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
2349
2467
|
}
|
2468
|
+
get isCIDR() {
|
2469
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
2470
|
+
}
|
2350
2471
|
get isBase64() {
|
2351
2472
|
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
2352
2473
|
}
|
2474
|
+
get isBase64url() {
|
2475
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
2476
|
+
}
|
2353
2477
|
get minLength() {
|
2354
2478
|
let min = null;
|
2355
2479
|
for (const ch of this._def.checks) {
|
@@ -2372,11 +2496,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
2372
2496
|
}
|
2373
2497
|
};
|
2374
2498
|
ZodString.create = (params) => {
|
2375
|
-
var _a;
|
2376
2499
|
return new ZodString({
|
2377
2500
|
checks: [],
|
2378
2501
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
2379
|
-
coerce: (
|
2502
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
2380
2503
|
...processCreateParams(params)
|
2381
2504
|
});
|
2382
2505
|
};
|
@@ -2384,9 +2507,9 @@ function floatSafeRemainder(val, step) {
|
|
2384
2507
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
2385
2508
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
2386
2509
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
2387
|
-
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
2388
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
2389
|
-
return valInt % stepInt /
|
2510
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
2511
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
2512
|
+
return valInt % stepInt / 10 ** decCount;
|
2390
2513
|
}
|
2391
2514
|
var ZodNumber = class _ZodNumber extends ZodType {
|
2392
2515
|
constructor() {
|
@@ -2596,7 +2719,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
2596
2719
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
2597
2720
|
}
|
2598
2721
|
get isFinite() {
|
2599
|
-
let max = null
|
2722
|
+
let max = null;
|
2723
|
+
let min = null;
|
2600
2724
|
for (const ch of this._def.checks) {
|
2601
2725
|
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
2602
2726
|
return true;
|
@@ -2615,7 +2739,7 @@ ZodNumber.create = (params) => {
|
|
2615
2739
|
return new ZodNumber({
|
2616
2740
|
checks: [],
|
2617
2741
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
2618
|
-
coerce: (params
|
2742
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
2619
2743
|
...processCreateParams(params)
|
2620
2744
|
});
|
2621
2745
|
};
|
@@ -2627,17 +2751,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
2627
2751
|
}
|
2628
2752
|
_parse(input) {
|
2629
2753
|
if (this._def.coerce) {
|
2630
|
-
|
2754
|
+
try {
|
2755
|
+
input.data = BigInt(input.data);
|
2756
|
+
} catch {
|
2757
|
+
return this._getInvalidInput(input);
|
2758
|
+
}
|
2631
2759
|
}
|
2632
2760
|
const parsedType = this._getType(input);
|
2633
2761
|
if (parsedType !== ZodParsedType.bigint) {
|
2634
|
-
|
2635
|
-
addIssueToContext(ctx2, {
|
2636
|
-
code: ZodIssueCode.invalid_type,
|
2637
|
-
expected: ZodParsedType.bigint,
|
2638
|
-
received: ctx2.parsedType
|
2639
|
-
});
|
2640
|
-
return INVALID;
|
2762
|
+
return this._getInvalidInput(input);
|
2641
2763
|
}
|
2642
2764
|
let ctx = void 0;
|
2643
2765
|
const status = new ParseStatus();
|
@@ -2684,6 +2806,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
2684
2806
|
}
|
2685
2807
|
return { status: status.value, value: input.data };
|
2686
2808
|
}
|
2809
|
+
_getInvalidInput(input) {
|
2810
|
+
const ctx = this._getOrReturnCtx(input);
|
2811
|
+
addIssueToContext(ctx, {
|
2812
|
+
code: ZodIssueCode.invalid_type,
|
2813
|
+
expected: ZodParsedType.bigint,
|
2814
|
+
received: ctx.parsedType
|
2815
|
+
});
|
2816
|
+
return INVALID;
|
2817
|
+
}
|
2687
2818
|
gte(value, message) {
|
2688
2819
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
2689
2820
|
}
|
@@ -2777,11 +2908,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
2777
2908
|
}
|
2778
2909
|
};
|
2779
2910
|
ZodBigInt.create = (params) => {
|
2780
|
-
var _a;
|
2781
2911
|
return new ZodBigInt({
|
2782
2912
|
checks: [],
|
2783
2913
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
2784
|
-
coerce: (
|
2914
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
2785
2915
|
...processCreateParams(params)
|
2786
2916
|
});
|
2787
2917
|
};
|
@@ -2806,7 +2936,7 @@ var ZodBoolean = class extends ZodType {
|
|
2806
2936
|
ZodBoolean.create = (params) => {
|
2807
2937
|
return new ZodBoolean({
|
2808
2938
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
2809
|
-
coerce: (params
|
2939
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
2810
2940
|
...processCreateParams(params)
|
2811
2941
|
});
|
2812
2942
|
};
|
@@ -2825,7 +2955,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
2825
2955
|
});
|
2826
2956
|
return INVALID;
|
2827
2957
|
}
|
2828
|
-
if (isNaN(input.data.getTime())) {
|
2958
|
+
if (Number.isNaN(input.data.getTime())) {
|
2829
2959
|
const ctx2 = this._getOrReturnCtx(input);
|
2830
2960
|
addIssueToContext(ctx2, {
|
2831
2961
|
code: ZodIssueCode.invalid_date
|
@@ -2914,7 +3044,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
2914
3044
|
ZodDate.create = (params) => {
|
2915
3045
|
return new ZodDate({
|
2916
3046
|
checks: [],
|
2917
|
-
coerce: (params
|
3047
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
2918
3048
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
2919
3049
|
...processCreateParams(params)
|
2920
3050
|
});
|
@@ -3189,7 +3319,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3189
3319
|
return this._cached;
|
3190
3320
|
const shape = this._def.shape();
|
3191
3321
|
const keys = util.objectKeys(shape);
|
3192
|
-
|
3322
|
+
this._cached = { shape, keys };
|
3323
|
+
return this._cached;
|
3193
3324
|
}
|
3194
3325
|
_parse(input) {
|
3195
3326
|
const parsedType = this._getType(input);
|
@@ -3239,8 +3370,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3239
3370
|
});
|
3240
3371
|
status.dirty();
|
3241
3372
|
}
|
3242
|
-
} else if (unknownKeys === "strip")
|
3243
|
-
else {
|
3373
|
+
} else if (unknownKeys === "strip") {
|
3374
|
+
} else {
|
3244
3375
|
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
3245
3376
|
}
|
3246
3377
|
} else {
|
@@ -3287,11 +3418,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3287
3418
|
unknownKeys: "strict",
|
3288
3419
|
...message !== void 0 ? {
|
3289
3420
|
errorMap: (issue, ctx) => {
|
3290
|
-
var _a, _b
|
3291
|
-
const defaultError = (
|
3421
|
+
var _a, _b;
|
3422
|
+
const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;
|
3292
3423
|
if (issue.code === "unrecognized_keys")
|
3293
3424
|
return {
|
3294
|
-
message:
|
3425
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
3295
3426
|
};
|
3296
3427
|
return {
|
3297
3428
|
message: defaultError
|
@@ -3422,11 +3553,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3422
3553
|
}
|
3423
3554
|
pick(mask) {
|
3424
3555
|
const shape = {};
|
3425
|
-
util.objectKeys(mask)
|
3556
|
+
for (const key of util.objectKeys(mask)) {
|
3426
3557
|
if (mask[key] && this.shape[key]) {
|
3427
3558
|
shape[key] = this.shape[key];
|
3428
3559
|
}
|
3429
|
-
}
|
3560
|
+
}
|
3430
3561
|
return new _ZodObject({
|
3431
3562
|
...this._def,
|
3432
3563
|
shape: () => shape
|
@@ -3434,11 +3565,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3434
3565
|
}
|
3435
3566
|
omit(mask) {
|
3436
3567
|
const shape = {};
|
3437
|
-
util.objectKeys(this.shape)
|
3568
|
+
for (const key of util.objectKeys(this.shape)) {
|
3438
3569
|
if (!mask[key]) {
|
3439
3570
|
shape[key] = this.shape[key];
|
3440
3571
|
}
|
3441
|
-
}
|
3572
|
+
}
|
3442
3573
|
return new _ZodObject({
|
3443
3574
|
...this._def,
|
3444
3575
|
shape: () => shape
|
@@ -3452,14 +3583,14 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3452
3583
|
}
|
3453
3584
|
partial(mask) {
|
3454
3585
|
const newShape = {};
|
3455
|
-
util.objectKeys(this.shape)
|
3586
|
+
for (const key of util.objectKeys(this.shape)) {
|
3456
3587
|
const fieldSchema = this.shape[key];
|
3457
3588
|
if (mask && !mask[key]) {
|
3458
3589
|
newShape[key] = fieldSchema;
|
3459
3590
|
} else {
|
3460
3591
|
newShape[key] = fieldSchema.optional();
|
3461
3592
|
}
|
3462
|
-
}
|
3593
|
+
}
|
3463
3594
|
return new _ZodObject({
|
3464
3595
|
...this._def,
|
3465
3596
|
shape: () => newShape
|
@@ -3467,7 +3598,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3467
3598
|
}
|
3468
3599
|
required(mask) {
|
3469
3600
|
const newShape = {};
|
3470
|
-
util.objectKeys(this.shape)
|
3601
|
+
for (const key of util.objectKeys(this.shape)) {
|
3471
3602
|
if (mask && !mask[key]) {
|
3472
3603
|
newShape[key] = this.shape[key];
|
3473
3604
|
} else {
|
@@ -3478,7 +3609,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3478
3609
|
}
|
3479
3610
|
newShape[key] = newField;
|
3480
3611
|
}
|
3481
|
-
}
|
3612
|
+
}
|
3482
3613
|
return new _ZodObject({
|
3483
3614
|
...this._def,
|
3484
3615
|
shape: () => newShape
|
@@ -4094,12 +4225,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
4094
4225
|
return makeIssue({
|
4095
4226
|
data: args,
|
4096
4227
|
path: ctx.path,
|
4097
|
-
errorMaps: [
|
4098
|
-
ctx.common.contextualErrorMap,
|
4099
|
-
ctx.schemaErrorMap,
|
4100
|
-
getErrorMap(),
|
4101
|
-
errorMap
|
4102
|
-
].filter((x) => !!x),
|
4228
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
4103
4229
|
issueData: {
|
4104
4230
|
code: ZodIssueCode.invalid_arguments,
|
4105
4231
|
argumentsError: error
|
@@ -4110,12 +4236,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
4110
4236
|
return makeIssue({
|
4111
4237
|
data: returns,
|
4112
4238
|
path: ctx.path,
|
4113
|
-
errorMaps: [
|
4114
|
-
ctx.common.contextualErrorMap,
|
4115
|
-
ctx.schemaErrorMap,
|
4116
|
-
getErrorMap(),
|
4117
|
-
errorMap
|
4118
|
-
].filter((x) => !!x),
|
4239
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
4119
4240
|
issueData: {
|
4120
4241
|
code: ZodIssueCode.invalid_return_type,
|
4121
4242
|
returnTypeError: error
|
@@ -4239,10 +4360,6 @@ function createZodEnum(values, params) {
|
|
4239
4360
|
});
|
4240
4361
|
}
|
4241
4362
|
var ZodEnum = class _ZodEnum extends ZodType {
|
4242
|
-
constructor() {
|
4243
|
-
super(...arguments);
|
4244
|
-
_ZodEnum_cache.set(this, void 0);
|
4245
|
-
}
|
4246
4363
|
_parse(input) {
|
4247
4364
|
if (typeof input.data !== "string") {
|
4248
4365
|
const ctx = this._getOrReturnCtx(input);
|
@@ -4254,10 +4371,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
4254
4371
|
});
|
4255
4372
|
return INVALID;
|
4256
4373
|
}
|
4257
|
-
if (!
|
4258
|
-
|
4374
|
+
if (!this._cache) {
|
4375
|
+
this._cache = new Set(this._def.values);
|
4259
4376
|
}
|
4260
|
-
if (!
|
4377
|
+
if (!this._cache.has(input.data)) {
|
4261
4378
|
const ctx = this._getOrReturnCtx(input);
|
4262
4379
|
const expectedValues = this._def.values;
|
4263
4380
|
addIssueToContext(ctx, {
|
@@ -4306,13 +4423,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
4306
4423
|
});
|
4307
4424
|
}
|
4308
4425
|
};
|
4309
|
-
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
4310
4426
|
ZodEnum.create = createZodEnum;
|
4311
4427
|
var ZodNativeEnum = class extends ZodType {
|
4312
|
-
constructor() {
|
4313
|
-
super(...arguments);
|
4314
|
-
_ZodNativeEnum_cache.set(this, void 0);
|
4315
|
-
}
|
4316
4428
|
_parse(input) {
|
4317
4429
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
4318
4430
|
const ctx = this._getOrReturnCtx(input);
|
@@ -4325,10 +4437,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
4325
4437
|
});
|
4326
4438
|
return INVALID;
|
4327
4439
|
}
|
4328
|
-
if (!
|
4329
|
-
|
4440
|
+
if (!this._cache) {
|
4441
|
+
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
4330
4442
|
}
|
4331
|
-
if (!
|
4443
|
+
if (!this._cache.has(input.data)) {
|
4332
4444
|
const expectedValues = util.objectValues(nativeEnumValues);
|
4333
4445
|
addIssueToContext(ctx, {
|
4334
4446
|
received: ctx.data,
|
@@ -4343,7 +4455,6 @@ var ZodNativeEnum = class extends ZodType {
|
|
4343
4455
|
return this._def.values;
|
4344
4456
|
}
|
4345
4457
|
};
|
4346
|
-
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
4347
4458
|
ZodNativeEnum.create = (values, params) => {
|
4348
4459
|
return new ZodNativeEnum({
|
4349
4460
|
values,
|
@@ -4484,7 +4595,7 @@ var ZodEffects = class extends ZodType {
|
|
4484
4595
|
parent: ctx
|
4485
4596
|
});
|
4486
4597
|
if (!isValid(base))
|
4487
|
-
return
|
4598
|
+
return INVALID;
|
4488
4599
|
const result = effect.transform(base.value, checkCtx);
|
4489
4600
|
if (result instanceof Promise) {
|
4490
4601
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
@@ -4493,8 +4604,11 @@ var ZodEffects = class extends ZodType {
|
|
4493
4604
|
} else {
|
4494
4605
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
4495
4606
|
if (!isValid(base))
|
4496
|
-
return
|
4497
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
4607
|
+
return INVALID;
|
4608
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
4609
|
+
status: status.value,
|
4610
|
+
value: result
|
4611
|
+
}));
|
4498
4612
|
});
|
4499
4613
|
}
|
4500
4614
|
}
|