drizzle-kit 0.31.1-581277d → 0.31.1-8bf5193
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 +24 -24
- package/api.d.ts +24 -24
- package/api.js +525 -326
- package/api.mjs +528 -329
- package/bin.cjs +20836 -20322
- package/package.json +1 -1
- package/utils.js +266 -152
- package/utils.mjs +266 -152
package/utils.js
CHANGED
@@ -580,7 +580,7 @@ __export(utils_exports, {
|
|
580
580
|
});
|
581
581
|
module.exports = __toCommonJS(utils_exports);
|
582
582
|
|
583
|
-
// ../node_modules/.pnpm/chalk@5.
|
583
|
+
// ../node_modules/.pnpm/chalk@5.4.1/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.
|
769
|
+
// ../node_modules/.pnpm/chalk@5.4.1/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,10 +840,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
840
840
|
return 1;
|
841
841
|
}
|
842
842
|
if ("CI" in env) {
|
843
|
-
if ("GITHUB_ACTIONS"
|
843
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
844
844
|
return 3;
|
845
845
|
}
|
846
|
-
if (["TRAVIS", "
|
846
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
847
847
|
return 1;
|
848
848
|
}
|
849
849
|
return min;
|
@@ -892,7 +892,7 @@ var supportsColor = {
|
|
892
892
|
};
|
893
893
|
var supports_color_default = supportsColor;
|
894
894
|
|
895
|
-
// ../node_modules/.pnpm/chalk@5.
|
895
|
+
// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js
|
896
896
|
function stringReplaceAll(string, substring, replacer) {
|
897
897
|
let index6 = string.indexOf(substring);
|
898
898
|
if (index6 === -1) {
|
@@ -922,7 +922,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index6) {
|
|
922
922
|
return returnValue;
|
923
923
|
}
|
924
924
|
|
925
|
-
// ../node_modules/.pnpm/chalk@5.
|
925
|
+
// ../node_modules/.pnpm/chalk@5.4.1/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");
|
@@ -1087,10 +1087,11 @@ function assertUnreachable(x) {
|
|
1087
1087
|
throw new Error("Didn't expect to get here");
|
1088
1088
|
}
|
1089
1089
|
|
1090
|
-
// ../node_modules/.pnpm/zod@3.
|
1090
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/util.js
|
1091
1091
|
var util;
|
1092
1092
|
(function(util2) {
|
1093
|
-
util2.assertEqual = (
|
1093
|
+
util2.assertEqual = (_) => {
|
1094
|
+
};
|
1094
1095
|
function assertIs(_arg) {
|
1095
1096
|
}
|
1096
1097
|
util2.assertIs = assertIs;
|
@@ -1134,7 +1135,7 @@ var util;
|
|
1134
1135
|
}
|
1135
1136
|
return void 0;
|
1136
1137
|
};
|
1137
|
-
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
1138
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
1138
1139
|
function joinValues(array, separator = " | ") {
|
1139
1140
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
1140
1141
|
}
|
@@ -1186,7 +1187,7 @@ var getParsedType = (data) => {
|
|
1186
1187
|
case "string":
|
1187
1188
|
return ZodParsedType.string;
|
1188
1189
|
case "number":
|
1189
|
-
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
1190
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
1190
1191
|
case "boolean":
|
1191
1192
|
return ZodParsedType.boolean;
|
1192
1193
|
case "function":
|
@@ -1219,6 +1220,8 @@ var getParsedType = (data) => {
|
|
1219
1220
|
return ZodParsedType.unknown;
|
1220
1221
|
}
|
1221
1222
|
};
|
1223
|
+
|
1224
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/ZodError.js
|
1222
1225
|
var ZodIssueCode = util.arrayToEnum([
|
1223
1226
|
"invalid_type",
|
1224
1227
|
"invalid_literal",
|
@@ -1238,6 +1241,9 @@ var ZodIssueCode = util.arrayToEnum([
|
|
1238
1241
|
"not_finite"
|
1239
1242
|
]);
|
1240
1243
|
var ZodError = class _ZodError extends Error {
|
1244
|
+
get errors() {
|
1245
|
+
return this.issues;
|
1246
|
+
}
|
1241
1247
|
constructor(issues) {
|
1242
1248
|
super();
|
1243
1249
|
this.issues = [];
|
@@ -1256,9 +1262,6 @@ var ZodError = class _ZodError extends Error {
|
|
1256
1262
|
this.name = "ZodError";
|
1257
1263
|
this.issues = issues;
|
1258
1264
|
}
|
1259
|
-
get errors() {
|
1260
|
-
return this.issues;
|
1261
|
-
}
|
1262
1265
|
format(_mapper) {
|
1263
1266
|
const mapper = _mapper || function(issue) {
|
1264
1267
|
return issue.message;
|
@@ -1330,6 +1333,8 @@ ZodError.create = (issues) => {
|
|
1330
1333
|
const error = new ZodError(issues);
|
1331
1334
|
return error;
|
1332
1335
|
};
|
1336
|
+
|
1337
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/locales/en.js
|
1333
1338
|
var errorMap = (issue, _ctx) => {
|
1334
1339
|
let message;
|
1335
1340
|
switch (issue.code) {
|
@@ -1428,10 +1433,15 @@ var errorMap = (issue, _ctx) => {
|
|
1428
1433
|
}
|
1429
1434
|
return { message };
|
1430
1435
|
};
|
1431
|
-
var
|
1436
|
+
var en_default = errorMap;
|
1437
|
+
|
1438
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/errors.js
|
1439
|
+
var overrideErrorMap = en_default;
|
1432
1440
|
function getErrorMap() {
|
1433
1441
|
return overrideErrorMap;
|
1434
1442
|
}
|
1443
|
+
|
1444
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/parseUtil.js
|
1435
1445
|
var makeIssue = (params) => {
|
1436
1446
|
const { data, path, errorMaps, issueData } = params;
|
1437
1447
|
const fullPath = [...path, ...issueData.path || []];
|
@@ -1465,9 +1475,12 @@ function addIssueToContext(ctx, issueData) {
|
|
1465
1475
|
path: ctx.path,
|
1466
1476
|
errorMaps: [
|
1467
1477
|
ctx.common.contextualErrorMap,
|
1478
|
+
// contextual error map is first priority
|
1468
1479
|
ctx.schemaErrorMap,
|
1480
|
+
// then schema-bound map if available
|
1469
1481
|
overrideMap,
|
1470
|
-
|
1482
|
+
// then global override map
|
1483
|
+
overrideMap === en_default ? void 0 : en_default
|
1471
1484
|
// then global default map
|
1472
1485
|
].filter((x) => !!x)
|
1473
1486
|
});
|
@@ -1536,24 +1549,15 @@ var isAborted = (x) => x.status === "aborted";
|
|
1536
1549
|
var isDirty = (x) => x.status === "dirty";
|
1537
1550
|
var isValid = (x) => x.status === "valid";
|
1538
1551
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
1539
|
-
|
1540
|
-
|
1541
|
-
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");
|
1542
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
1543
|
-
}
|
1544
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
1545
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
1546
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
1547
|
-
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");
|
1548
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
1549
|
-
}
|
1552
|
+
|
1553
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/errorUtil.js
|
1550
1554
|
var errorUtil;
|
1551
1555
|
(function(errorUtil2) {
|
1552
1556
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
1553
|
-
errorUtil2.toString = (message) => typeof message === "string" ? message : message
|
1557
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
|
1554
1558
|
})(errorUtil || (errorUtil = {}));
|
1555
|
-
|
1556
|
-
|
1559
|
+
|
1560
|
+
// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/types.js
|
1557
1561
|
var ParseInputLazyPath = class {
|
1558
1562
|
constructor(parent, value, path, key) {
|
1559
1563
|
this._cachedPath = [];
|
@@ -1564,7 +1568,7 @@ var ParseInputLazyPath = class {
|
|
1564
1568
|
}
|
1565
1569
|
get path() {
|
1566
1570
|
if (!this._cachedPath.length) {
|
1567
|
-
if (this._key
|
1571
|
+
if (Array.isArray(this._key)) {
|
1568
1572
|
this._cachedPath.push(...this._path, ...this._key);
|
1569
1573
|
} else {
|
1570
1574
|
this._cachedPath.push(...this._path, this._key);
|
@@ -1602,49 +1606,20 @@ function processCreateParams(params) {
|
|
1602
1606
|
if (errorMap2)
|
1603
1607
|
return { errorMap: errorMap2, description };
|
1604
1608
|
const customMap = (iss, ctx) => {
|
1605
|
-
var _a, _b;
|
1606
1609
|
const { message } = params;
|
1607
1610
|
if (iss.code === "invalid_enum_value") {
|
1608
|
-
return { message: message
|
1611
|
+
return { message: message ?? ctx.defaultError };
|
1609
1612
|
}
|
1610
1613
|
if (typeof ctx.data === "undefined") {
|
1611
|
-
return { message:
|
1614
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
1612
1615
|
}
|
1613
1616
|
if (iss.code !== "invalid_type")
|
1614
1617
|
return { message: ctx.defaultError };
|
1615
|
-
return { message:
|
1618
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
1616
1619
|
};
|
1617
1620
|
return { errorMap: customMap, description };
|
1618
1621
|
}
|
1619
1622
|
var ZodType = class {
|
1620
|
-
constructor(def) {
|
1621
|
-
this.spa = this.safeParseAsync;
|
1622
|
-
this._def = def;
|
1623
|
-
this.parse = this.parse.bind(this);
|
1624
|
-
this.safeParse = this.safeParse.bind(this);
|
1625
|
-
this.parseAsync = this.parseAsync.bind(this);
|
1626
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
1627
|
-
this.spa = this.spa.bind(this);
|
1628
|
-
this.refine = this.refine.bind(this);
|
1629
|
-
this.refinement = this.refinement.bind(this);
|
1630
|
-
this.superRefine = this.superRefine.bind(this);
|
1631
|
-
this.optional = this.optional.bind(this);
|
1632
|
-
this.nullable = this.nullable.bind(this);
|
1633
|
-
this.nullish = this.nullish.bind(this);
|
1634
|
-
this.array = this.array.bind(this);
|
1635
|
-
this.promise = this.promise.bind(this);
|
1636
|
-
this.or = this.or.bind(this);
|
1637
|
-
this.and = this.and.bind(this);
|
1638
|
-
this.transform = this.transform.bind(this);
|
1639
|
-
this.brand = this.brand.bind(this);
|
1640
|
-
this.default = this.default.bind(this);
|
1641
|
-
this.catch = this.catch.bind(this);
|
1642
|
-
this.describe = this.describe.bind(this);
|
1643
|
-
this.pipe = this.pipe.bind(this);
|
1644
|
-
this.readonly = this.readonly.bind(this);
|
1645
|
-
this.isNullable = this.isNullable.bind(this);
|
1646
|
-
this.isOptional = this.isOptional.bind(this);
|
1647
|
-
}
|
1648
1623
|
get description() {
|
1649
1624
|
return this._def.description;
|
1650
1625
|
}
|
@@ -1692,14 +1667,13 @@ var ZodType = class {
|
|
1692
1667
|
throw result.error;
|
1693
1668
|
}
|
1694
1669
|
safeParse(data, params) {
|
1695
|
-
var _a;
|
1696
1670
|
const ctx = {
|
1697
1671
|
common: {
|
1698
1672
|
issues: [],
|
1699
|
-
async: (
|
1700
|
-
contextualErrorMap: params
|
1673
|
+
async: (params == null ? void 0 : params.async) ?? false,
|
1674
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap
|
1701
1675
|
},
|
1702
|
-
path: (params
|
1676
|
+
path: (params == null ? void 0 : params.path) || [],
|
1703
1677
|
schemaErrorMap: this._def.errorMap,
|
1704
1678
|
parent: null,
|
1705
1679
|
data,
|
@@ -1708,6 +1682,43 @@ var ZodType = class {
|
|
1708
1682
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
1709
1683
|
return handleResult(ctx, result);
|
1710
1684
|
}
|
1685
|
+
"~validate"(data) {
|
1686
|
+
var _a, _b;
|
1687
|
+
const ctx = {
|
1688
|
+
common: {
|
1689
|
+
issues: [],
|
1690
|
+
async: !!this["~standard"].async
|
1691
|
+
},
|
1692
|
+
path: [],
|
1693
|
+
schemaErrorMap: this._def.errorMap,
|
1694
|
+
parent: null,
|
1695
|
+
data,
|
1696
|
+
parsedType: getParsedType(data)
|
1697
|
+
};
|
1698
|
+
if (!this["~standard"].async) {
|
1699
|
+
try {
|
1700
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
1701
|
+
return isValid(result) ? {
|
1702
|
+
value: result.value
|
1703
|
+
} : {
|
1704
|
+
issues: ctx.common.issues
|
1705
|
+
};
|
1706
|
+
} catch (err) {
|
1707
|
+
if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {
|
1708
|
+
this["~standard"].async = true;
|
1709
|
+
}
|
1710
|
+
ctx.common = {
|
1711
|
+
issues: [],
|
1712
|
+
async: true
|
1713
|
+
};
|
1714
|
+
}
|
1715
|
+
}
|
1716
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
1717
|
+
value: result.value
|
1718
|
+
} : {
|
1719
|
+
issues: ctx.common.issues
|
1720
|
+
});
|
1721
|
+
}
|
1711
1722
|
async parseAsync(data, params) {
|
1712
1723
|
const result = await this.safeParseAsync(data, params);
|
1713
1724
|
if (result.success)
|
@@ -1718,10 +1729,10 @@ var ZodType = class {
|
|
1718
1729
|
const ctx = {
|
1719
1730
|
common: {
|
1720
1731
|
issues: [],
|
1721
|
-
contextualErrorMap: params
|
1732
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap,
|
1722
1733
|
async: true
|
1723
1734
|
},
|
1724
|
-
path: (params
|
1735
|
+
path: (params == null ? void 0 : params.path) || [],
|
1725
1736
|
schemaErrorMap: this._def.errorMap,
|
1726
1737
|
parent: null,
|
1727
1738
|
data,
|
@@ -1785,6 +1796,39 @@ var ZodType = class {
|
|
1785
1796
|
superRefine(refinement) {
|
1786
1797
|
return this._refinement(refinement);
|
1787
1798
|
}
|
1799
|
+
constructor(def) {
|
1800
|
+
this.spa = this.safeParseAsync;
|
1801
|
+
this._def = def;
|
1802
|
+
this.parse = this.parse.bind(this);
|
1803
|
+
this.safeParse = this.safeParse.bind(this);
|
1804
|
+
this.parseAsync = this.parseAsync.bind(this);
|
1805
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
1806
|
+
this.spa = this.spa.bind(this);
|
1807
|
+
this.refine = this.refine.bind(this);
|
1808
|
+
this.refinement = this.refinement.bind(this);
|
1809
|
+
this.superRefine = this.superRefine.bind(this);
|
1810
|
+
this.optional = this.optional.bind(this);
|
1811
|
+
this.nullable = this.nullable.bind(this);
|
1812
|
+
this.nullish = this.nullish.bind(this);
|
1813
|
+
this.array = this.array.bind(this);
|
1814
|
+
this.promise = this.promise.bind(this);
|
1815
|
+
this.or = this.or.bind(this);
|
1816
|
+
this.and = this.and.bind(this);
|
1817
|
+
this.transform = this.transform.bind(this);
|
1818
|
+
this.brand = this.brand.bind(this);
|
1819
|
+
this.default = this.default.bind(this);
|
1820
|
+
this.catch = this.catch.bind(this);
|
1821
|
+
this.describe = this.describe.bind(this);
|
1822
|
+
this.pipe = this.pipe.bind(this);
|
1823
|
+
this.readonly = this.readonly.bind(this);
|
1824
|
+
this.isNullable = this.isNullable.bind(this);
|
1825
|
+
this.isOptional = this.isOptional.bind(this);
|
1826
|
+
this["~standard"] = {
|
1827
|
+
version: 1,
|
1828
|
+
vendor: "zod",
|
1829
|
+
validate: (data) => this["~validate"](data)
|
1830
|
+
};
|
1831
|
+
}
|
1788
1832
|
optional() {
|
1789
1833
|
return ZodOptional.create(this, this._def);
|
1790
1834
|
}
|
@@ -1795,7 +1839,7 @@ var ZodType = class {
|
|
1795
1839
|
return this.nullable().optional();
|
1796
1840
|
}
|
1797
1841
|
array() {
|
1798
|
-
return ZodArray.create(this
|
1842
|
+
return ZodArray.create(this);
|
1799
1843
|
}
|
1800
1844
|
promise() {
|
1801
1845
|
return ZodPromise.create(this, this._def);
|
@@ -1861,26 +1905,31 @@ var ZodType = class {
|
|
1861
1905
|
};
|
1862
1906
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
1863
1907
|
var cuid2Regex = /^[0-9a-z]+$/;
|
1864
|
-
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
1908
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
1865
1909
|
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;
|
1866
1910
|
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
1911
|
+
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
1867
1912
|
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)?)??$/;
|
1868
1913
|
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
1869
1914
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
1870
1915
|
var emojiRegex;
|
1871
1916
|
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])$/;
|
1872
|
-
var
|
1917
|
+
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])$/;
|
1918
|
+
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]))$/;
|
1919
|
+
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])$/;
|
1873
1920
|
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
1921
|
+
var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
1874
1922
|
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])))`;
|
1875
1923
|
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
1876
1924
|
function timeRegexSource(args) {
|
1877
|
-
let
|
1925
|
+
let secondsRegexSource = `[0-5]\\d`;
|
1878
1926
|
if (args.precision) {
|
1879
|
-
|
1927
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
1880
1928
|
} else if (args.precision == null) {
|
1881
|
-
|
1929
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
1882
1930
|
}
|
1883
|
-
|
1931
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
1932
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
1884
1933
|
}
|
1885
1934
|
function timeRegex(args) {
|
1886
1935
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
@@ -1903,6 +1952,35 @@ function isValidIP(ip, version) {
|
|
1903
1952
|
}
|
1904
1953
|
return false;
|
1905
1954
|
}
|
1955
|
+
function isValidJWT(jwt, alg) {
|
1956
|
+
if (!jwtRegex.test(jwt))
|
1957
|
+
return false;
|
1958
|
+
try {
|
1959
|
+
const [header] = jwt.split(".");
|
1960
|
+
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
1961
|
+
const decoded = JSON.parse(atob(base64));
|
1962
|
+
if (typeof decoded !== "object" || decoded === null)
|
1963
|
+
return false;
|
1964
|
+
if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")
|
1965
|
+
return false;
|
1966
|
+
if (!decoded.alg)
|
1967
|
+
return false;
|
1968
|
+
if (alg && decoded.alg !== alg)
|
1969
|
+
return false;
|
1970
|
+
return true;
|
1971
|
+
} catch {
|
1972
|
+
return false;
|
1973
|
+
}
|
1974
|
+
}
|
1975
|
+
function isValidCidr(ip, version) {
|
1976
|
+
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
|
1977
|
+
return true;
|
1978
|
+
}
|
1979
|
+
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
|
1980
|
+
return true;
|
1981
|
+
}
|
1982
|
+
return false;
|
1983
|
+
}
|
1906
1984
|
var ZodString = class _ZodString extends ZodType {
|
1907
1985
|
_parse(input) {
|
1908
1986
|
if (this._def.coerce) {
|
@@ -2049,7 +2127,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
2049
2127
|
} else if (check.kind === "url") {
|
2050
2128
|
try {
|
2051
2129
|
new URL(input.data);
|
2052
|
-
} catch
|
2130
|
+
} catch {
|
2053
2131
|
ctx = this._getOrReturnCtx(input, ctx);
|
2054
2132
|
addIssueToContext(ctx, {
|
2055
2133
|
validation: "url",
|
@@ -2159,6 +2237,26 @@ var ZodString = class _ZodString extends ZodType {
|
|
2159
2237
|
});
|
2160
2238
|
status.dirty();
|
2161
2239
|
}
|
2240
|
+
} else if (check.kind === "jwt") {
|
2241
|
+
if (!isValidJWT(input.data, check.alg)) {
|
2242
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2243
|
+
addIssueToContext(ctx, {
|
2244
|
+
validation: "jwt",
|
2245
|
+
code: ZodIssueCode.invalid_string,
|
2246
|
+
message: check.message
|
2247
|
+
});
|
2248
|
+
status.dirty();
|
2249
|
+
}
|
2250
|
+
} else if (check.kind === "cidr") {
|
2251
|
+
if (!isValidCidr(input.data, check.version)) {
|
2252
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2253
|
+
addIssueToContext(ctx, {
|
2254
|
+
validation: "cidr",
|
2255
|
+
code: ZodIssueCode.invalid_string,
|
2256
|
+
message: check.message
|
2257
|
+
});
|
2258
|
+
status.dirty();
|
2259
|
+
}
|
2162
2260
|
} else if (check.kind === "base64") {
|
2163
2261
|
if (!base64Regex.test(input.data)) {
|
2164
2262
|
ctx = this._getOrReturnCtx(input, ctx);
|
@@ -2169,6 +2267,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
2169
2267
|
});
|
2170
2268
|
status.dirty();
|
2171
2269
|
}
|
2270
|
+
} else if (check.kind === "base64url") {
|
2271
|
+
if (!base64urlRegex.test(input.data)) {
|
2272
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
2273
|
+
addIssueToContext(ctx, {
|
2274
|
+
validation: "base64url",
|
2275
|
+
code: ZodIssueCode.invalid_string,
|
2276
|
+
message: check.message
|
2277
|
+
});
|
2278
|
+
status.dirty();
|
2279
|
+
}
|
2172
2280
|
} else {
|
2173
2281
|
util.assertNever(check);
|
2174
2282
|
}
|
@@ -2215,11 +2323,22 @@ var ZodString = class _ZodString extends ZodType {
|
|
2215
2323
|
base64(message) {
|
2216
2324
|
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
2217
2325
|
}
|
2326
|
+
base64url(message) {
|
2327
|
+
return this._addCheck({
|
2328
|
+
kind: "base64url",
|
2329
|
+
...errorUtil.errToObj(message)
|
2330
|
+
});
|
2331
|
+
}
|
2332
|
+
jwt(options) {
|
2333
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
2334
|
+
}
|
2218
2335
|
ip(options) {
|
2219
2336
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
2220
2337
|
}
|
2338
|
+
cidr(options) {
|
2339
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
2340
|
+
}
|
2221
2341
|
datetime(options) {
|
2222
|
-
var _a, _b;
|
2223
2342
|
if (typeof options === "string") {
|
2224
2343
|
return this._addCheck({
|
2225
2344
|
kind: "datetime",
|
@@ -2231,10 +2350,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
2231
2350
|
}
|
2232
2351
|
return this._addCheck({
|
2233
2352
|
kind: "datetime",
|
2234
|
-
precision: typeof (options
|
2235
|
-
offset: (
|
2236
|
-
local: (
|
2237
|
-
...errorUtil.errToObj(options
|
2353
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
2354
|
+
offset: (options == null ? void 0 : options.offset) ?? false,
|
2355
|
+
local: (options == null ? void 0 : options.local) ?? false,
|
2356
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
2238
2357
|
});
|
2239
2358
|
}
|
2240
2359
|
date(message) {
|
@@ -2250,8 +2369,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
2250
2369
|
}
|
2251
2370
|
return this._addCheck({
|
2252
2371
|
kind: "time",
|
2253
|
-
precision: typeof (options
|
2254
|
-
...errorUtil.errToObj(options
|
2372
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
2373
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
2255
2374
|
});
|
2256
2375
|
}
|
2257
2376
|
duration(message) {
|
@@ -2268,8 +2387,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
2268
2387
|
return this._addCheck({
|
2269
2388
|
kind: "includes",
|
2270
2389
|
value,
|
2271
|
-
position: options
|
2272
|
-
...errorUtil.errToObj(options
|
2390
|
+
position: options == null ? void 0 : options.position,
|
2391
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
2273
2392
|
});
|
2274
2393
|
}
|
2275
2394
|
startsWith(value, message) {
|
@@ -2308,8 +2427,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
2308
2427
|
});
|
2309
2428
|
}
|
2310
2429
|
/**
|
2311
|
-
*
|
2312
|
-
* @see {@link ZodString.min}
|
2430
|
+
* Equivalent to `.min(1)`
|
2313
2431
|
*/
|
2314
2432
|
nonempty(message) {
|
2315
2433
|
return this.min(1, errorUtil.errToObj(message));
|
@@ -2371,9 +2489,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
2371
2489
|
get isIP() {
|
2372
2490
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
2373
2491
|
}
|
2492
|
+
get isCIDR() {
|
2493
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
2494
|
+
}
|
2374
2495
|
get isBase64() {
|
2375
2496
|
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
2376
2497
|
}
|
2498
|
+
get isBase64url() {
|
2499
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
2500
|
+
}
|
2377
2501
|
get minLength() {
|
2378
2502
|
let min = null;
|
2379
2503
|
for (const ch of this._def.checks) {
|
@@ -2396,11 +2520,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
2396
2520
|
}
|
2397
2521
|
};
|
2398
2522
|
ZodString.create = (params) => {
|
2399
|
-
var _a;
|
2400
2523
|
return new ZodString({
|
2401
2524
|
checks: [],
|
2402
2525
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
2403
|
-
coerce: (
|
2526
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
2404
2527
|
...processCreateParams(params)
|
2405
2528
|
});
|
2406
2529
|
};
|
@@ -2408,9 +2531,9 @@ function floatSafeRemainder(val, step) {
|
|
2408
2531
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
2409
2532
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
2410
2533
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
2411
|
-
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
2412
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
2413
|
-
return valInt % stepInt /
|
2534
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
2535
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
2536
|
+
return valInt % stepInt / 10 ** decCount;
|
2414
2537
|
}
|
2415
2538
|
var ZodNumber = class _ZodNumber extends ZodType {
|
2416
2539
|
constructor() {
|
@@ -2620,7 +2743,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
2620
2743
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
2621
2744
|
}
|
2622
2745
|
get isFinite() {
|
2623
|
-
let max = null
|
2746
|
+
let max = null;
|
2747
|
+
let min = null;
|
2624
2748
|
for (const ch of this._def.checks) {
|
2625
2749
|
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
2626
2750
|
return true;
|
@@ -2639,7 +2763,7 @@ ZodNumber.create = (params) => {
|
|
2639
2763
|
return new ZodNumber({
|
2640
2764
|
checks: [],
|
2641
2765
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
2642
|
-
coerce: (params
|
2766
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
2643
2767
|
...processCreateParams(params)
|
2644
2768
|
});
|
2645
2769
|
};
|
@@ -2651,17 +2775,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
2651
2775
|
}
|
2652
2776
|
_parse(input) {
|
2653
2777
|
if (this._def.coerce) {
|
2654
|
-
|
2778
|
+
try {
|
2779
|
+
input.data = BigInt(input.data);
|
2780
|
+
} catch {
|
2781
|
+
return this._getInvalidInput(input);
|
2782
|
+
}
|
2655
2783
|
}
|
2656
2784
|
const parsedType = this._getType(input);
|
2657
2785
|
if (parsedType !== ZodParsedType.bigint) {
|
2658
|
-
|
2659
|
-
addIssueToContext(ctx2, {
|
2660
|
-
code: ZodIssueCode.invalid_type,
|
2661
|
-
expected: ZodParsedType.bigint,
|
2662
|
-
received: ctx2.parsedType
|
2663
|
-
});
|
2664
|
-
return INVALID;
|
2786
|
+
return this._getInvalidInput(input);
|
2665
2787
|
}
|
2666
2788
|
let ctx = void 0;
|
2667
2789
|
const status = new ParseStatus();
|
@@ -2708,6 +2830,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
2708
2830
|
}
|
2709
2831
|
return { status: status.value, value: input.data };
|
2710
2832
|
}
|
2833
|
+
_getInvalidInput(input) {
|
2834
|
+
const ctx = this._getOrReturnCtx(input);
|
2835
|
+
addIssueToContext(ctx, {
|
2836
|
+
code: ZodIssueCode.invalid_type,
|
2837
|
+
expected: ZodParsedType.bigint,
|
2838
|
+
received: ctx.parsedType
|
2839
|
+
});
|
2840
|
+
return INVALID;
|
2841
|
+
}
|
2711
2842
|
gte(value, message) {
|
2712
2843
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
2713
2844
|
}
|
@@ -2801,11 +2932,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
2801
2932
|
}
|
2802
2933
|
};
|
2803
2934
|
ZodBigInt.create = (params) => {
|
2804
|
-
var _a;
|
2805
2935
|
return new ZodBigInt({
|
2806
2936
|
checks: [],
|
2807
2937
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
2808
|
-
coerce: (
|
2938
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
2809
2939
|
...processCreateParams(params)
|
2810
2940
|
});
|
2811
2941
|
};
|
@@ -2830,7 +2960,7 @@ var ZodBoolean = class extends ZodType {
|
|
2830
2960
|
ZodBoolean.create = (params) => {
|
2831
2961
|
return new ZodBoolean({
|
2832
2962
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
2833
|
-
coerce: (params
|
2963
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
2834
2964
|
...processCreateParams(params)
|
2835
2965
|
});
|
2836
2966
|
};
|
@@ -2849,7 +2979,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
2849
2979
|
});
|
2850
2980
|
return INVALID;
|
2851
2981
|
}
|
2852
|
-
if (isNaN(input.data.getTime())) {
|
2982
|
+
if (Number.isNaN(input.data.getTime())) {
|
2853
2983
|
const ctx2 = this._getOrReturnCtx(input);
|
2854
2984
|
addIssueToContext(ctx2, {
|
2855
2985
|
code: ZodIssueCode.invalid_date
|
@@ -2938,7 +3068,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
2938
3068
|
ZodDate.create = (params) => {
|
2939
3069
|
return new ZodDate({
|
2940
3070
|
checks: [],
|
2941
|
-
coerce: (params
|
3071
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
2942
3072
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
2943
3073
|
...processCreateParams(params)
|
2944
3074
|
});
|
@@ -3213,7 +3343,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3213
3343
|
return this._cached;
|
3214
3344
|
const shape = this._def.shape();
|
3215
3345
|
const keys = util.objectKeys(shape);
|
3216
|
-
|
3346
|
+
this._cached = { shape, keys };
|
3347
|
+
return this._cached;
|
3217
3348
|
}
|
3218
3349
|
_parse(input) {
|
3219
3350
|
const parsedType = this._getType(input);
|
@@ -3263,8 +3394,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3263
3394
|
});
|
3264
3395
|
status.dirty();
|
3265
3396
|
}
|
3266
|
-
} else if (unknownKeys === "strip")
|
3267
|
-
else {
|
3397
|
+
} else if (unknownKeys === "strip") {
|
3398
|
+
} else {
|
3268
3399
|
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
3269
3400
|
}
|
3270
3401
|
} else {
|
@@ -3311,11 +3442,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3311
3442
|
unknownKeys: "strict",
|
3312
3443
|
...message !== void 0 ? {
|
3313
3444
|
errorMap: (issue, ctx) => {
|
3314
|
-
var _a, _b
|
3315
|
-
const defaultError = (
|
3445
|
+
var _a, _b;
|
3446
|
+
const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;
|
3316
3447
|
if (issue.code === "unrecognized_keys")
|
3317
3448
|
return {
|
3318
|
-
message:
|
3449
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
3319
3450
|
};
|
3320
3451
|
return {
|
3321
3452
|
message: defaultError
|
@@ -3446,11 +3577,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3446
3577
|
}
|
3447
3578
|
pick(mask) {
|
3448
3579
|
const shape = {};
|
3449
|
-
util.objectKeys(mask)
|
3580
|
+
for (const key of util.objectKeys(mask)) {
|
3450
3581
|
if (mask[key] && this.shape[key]) {
|
3451
3582
|
shape[key] = this.shape[key];
|
3452
3583
|
}
|
3453
|
-
}
|
3584
|
+
}
|
3454
3585
|
return new _ZodObject({
|
3455
3586
|
...this._def,
|
3456
3587
|
shape: () => shape
|
@@ -3458,11 +3589,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3458
3589
|
}
|
3459
3590
|
omit(mask) {
|
3460
3591
|
const shape = {};
|
3461
|
-
util.objectKeys(this.shape)
|
3592
|
+
for (const key of util.objectKeys(this.shape)) {
|
3462
3593
|
if (!mask[key]) {
|
3463
3594
|
shape[key] = this.shape[key];
|
3464
3595
|
}
|
3465
|
-
}
|
3596
|
+
}
|
3466
3597
|
return new _ZodObject({
|
3467
3598
|
...this._def,
|
3468
3599
|
shape: () => shape
|
@@ -3476,14 +3607,14 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3476
3607
|
}
|
3477
3608
|
partial(mask) {
|
3478
3609
|
const newShape = {};
|
3479
|
-
util.objectKeys(this.shape)
|
3610
|
+
for (const key of util.objectKeys(this.shape)) {
|
3480
3611
|
const fieldSchema = this.shape[key];
|
3481
3612
|
if (mask && !mask[key]) {
|
3482
3613
|
newShape[key] = fieldSchema;
|
3483
3614
|
} else {
|
3484
3615
|
newShape[key] = fieldSchema.optional();
|
3485
3616
|
}
|
3486
|
-
}
|
3617
|
+
}
|
3487
3618
|
return new _ZodObject({
|
3488
3619
|
...this._def,
|
3489
3620
|
shape: () => newShape
|
@@ -3491,7 +3622,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3491
3622
|
}
|
3492
3623
|
required(mask) {
|
3493
3624
|
const newShape = {};
|
3494
|
-
util.objectKeys(this.shape)
|
3625
|
+
for (const key of util.objectKeys(this.shape)) {
|
3495
3626
|
if (mask && !mask[key]) {
|
3496
3627
|
newShape[key] = this.shape[key];
|
3497
3628
|
} else {
|
@@ -3502,7 +3633,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
3502
3633
|
}
|
3503
3634
|
newShape[key] = newField;
|
3504
3635
|
}
|
3505
|
-
}
|
3636
|
+
}
|
3506
3637
|
return new _ZodObject({
|
3507
3638
|
...this._def,
|
3508
3639
|
shape: () => newShape
|
@@ -4118,12 +4249,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
4118
4249
|
return makeIssue({
|
4119
4250
|
data: args,
|
4120
4251
|
path: ctx.path,
|
4121
|
-
errorMaps: [
|
4122
|
-
ctx.common.contextualErrorMap,
|
4123
|
-
ctx.schemaErrorMap,
|
4124
|
-
getErrorMap(),
|
4125
|
-
errorMap
|
4126
|
-
].filter((x) => !!x),
|
4252
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
4127
4253
|
issueData: {
|
4128
4254
|
code: ZodIssueCode.invalid_arguments,
|
4129
4255
|
argumentsError: error
|
@@ -4134,12 +4260,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
4134
4260
|
return makeIssue({
|
4135
4261
|
data: returns,
|
4136
4262
|
path: ctx.path,
|
4137
|
-
errorMaps: [
|
4138
|
-
ctx.common.contextualErrorMap,
|
4139
|
-
ctx.schemaErrorMap,
|
4140
|
-
getErrorMap(),
|
4141
|
-
errorMap
|
4142
|
-
].filter((x) => !!x),
|
4263
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
4143
4264
|
issueData: {
|
4144
4265
|
code: ZodIssueCode.invalid_return_type,
|
4145
4266
|
returnTypeError: error
|
@@ -4263,10 +4384,6 @@ function createZodEnum(values, params) {
|
|
4263
4384
|
});
|
4264
4385
|
}
|
4265
4386
|
var ZodEnum = class _ZodEnum extends ZodType {
|
4266
|
-
constructor() {
|
4267
|
-
super(...arguments);
|
4268
|
-
_ZodEnum_cache.set(this, void 0);
|
4269
|
-
}
|
4270
4387
|
_parse(input) {
|
4271
4388
|
if (typeof input.data !== "string") {
|
4272
4389
|
const ctx = this._getOrReturnCtx(input);
|
@@ -4278,10 +4395,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
4278
4395
|
});
|
4279
4396
|
return INVALID;
|
4280
4397
|
}
|
4281
|
-
if (!
|
4282
|
-
|
4398
|
+
if (!this._cache) {
|
4399
|
+
this._cache = new Set(this._def.values);
|
4283
4400
|
}
|
4284
|
-
if (!
|
4401
|
+
if (!this._cache.has(input.data)) {
|
4285
4402
|
const ctx = this._getOrReturnCtx(input);
|
4286
4403
|
const expectedValues = this._def.values;
|
4287
4404
|
addIssueToContext(ctx, {
|
@@ -4330,13 +4447,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
4330
4447
|
});
|
4331
4448
|
}
|
4332
4449
|
};
|
4333
|
-
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
4334
4450
|
ZodEnum.create = createZodEnum;
|
4335
4451
|
var ZodNativeEnum = class extends ZodType {
|
4336
|
-
constructor() {
|
4337
|
-
super(...arguments);
|
4338
|
-
_ZodNativeEnum_cache.set(this, void 0);
|
4339
|
-
}
|
4340
4452
|
_parse(input) {
|
4341
4453
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
4342
4454
|
const ctx = this._getOrReturnCtx(input);
|
@@ -4349,10 +4461,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
4349
4461
|
});
|
4350
4462
|
return INVALID;
|
4351
4463
|
}
|
4352
|
-
if (!
|
4353
|
-
|
4464
|
+
if (!this._cache) {
|
4465
|
+
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
4354
4466
|
}
|
4355
|
-
if (!
|
4467
|
+
if (!this._cache.has(input.data)) {
|
4356
4468
|
const expectedValues = util.objectValues(nativeEnumValues);
|
4357
4469
|
addIssueToContext(ctx, {
|
4358
4470
|
received: ctx.data,
|
@@ -4367,7 +4479,6 @@ var ZodNativeEnum = class extends ZodType {
|
|
4367
4479
|
return this._def.values;
|
4368
4480
|
}
|
4369
4481
|
};
|
4370
|
-
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
4371
4482
|
ZodNativeEnum.create = (values, params) => {
|
4372
4483
|
return new ZodNativeEnum({
|
4373
4484
|
values,
|
@@ -4508,7 +4619,7 @@ var ZodEffects = class extends ZodType {
|
|
4508
4619
|
parent: ctx
|
4509
4620
|
});
|
4510
4621
|
if (!isValid(base))
|
4511
|
-
return
|
4622
|
+
return INVALID;
|
4512
4623
|
const result = effect.transform(base.value, checkCtx);
|
4513
4624
|
if (result instanceof Promise) {
|
4514
4625
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
@@ -4517,8 +4628,11 @@ var ZodEffects = class extends ZodType {
|
|
4517
4628
|
} else {
|
4518
4629
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
4519
4630
|
if (!isValid(base))
|
4520
|
-
return
|
4521
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
4631
|
+
return INVALID;
|
4632
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
4633
|
+
status: status.value,
|
4634
|
+
value: result
|
4635
|
+
}));
|
4522
4636
|
});
|
4523
4637
|
}
|
4524
4638
|
}
|