@lodashventure/medusa-campaign 0.0.6 → 1.0.0
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/.medusa/server/src/admin/index.js +543 -241
- package/.medusa/server/src/admin/index.mjs +543 -241
- package/.medusa/server/src/api/middlewares.js +1 -1
- package/package.json +16 -13
|
@@ -1259,7 +1259,8 @@ const config$1 = adminSdk.defineRouteConfig({
|
|
|
1259
1259
|
});
|
|
1260
1260
|
var util;
|
|
1261
1261
|
(function(util2) {
|
|
1262
|
-
util2.assertEqual = (
|
|
1262
|
+
util2.assertEqual = (_) => {
|
|
1263
|
+
};
|
|
1263
1264
|
function assertIs(_arg) {
|
|
1264
1265
|
}
|
|
1265
1266
|
util2.assertIs = assertIs;
|
|
@@ -1303,7 +1304,7 @@ var util;
|
|
|
1303
1304
|
}
|
|
1304
1305
|
return void 0;
|
|
1305
1306
|
};
|
|
1306
|
-
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
1307
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
1307
1308
|
function joinValues(array, separator = " | ") {
|
|
1308
1309
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
1309
1310
|
}
|
|
@@ -1355,7 +1356,7 @@ const getParsedType = (data) => {
|
|
|
1355
1356
|
case "string":
|
|
1356
1357
|
return ZodParsedType.string;
|
|
1357
1358
|
case "number":
|
|
1358
|
-
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
1359
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
1359
1360
|
case "boolean":
|
|
1360
1361
|
return ZodParsedType.boolean;
|
|
1361
1362
|
case "function":
|
|
@@ -1411,6 +1412,9 @@ const quotelessJson = (obj) => {
|
|
|
1411
1412
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
1412
1413
|
};
|
|
1413
1414
|
class ZodError extends Error {
|
|
1415
|
+
get errors() {
|
|
1416
|
+
return this.issues;
|
|
1417
|
+
}
|
|
1414
1418
|
constructor(issues) {
|
|
1415
1419
|
super();
|
|
1416
1420
|
this.issues = [];
|
|
@@ -1429,9 +1433,6 @@ class ZodError extends Error {
|
|
|
1429
1433
|
this.name = "ZodError";
|
|
1430
1434
|
this.issues = issues;
|
|
1431
1435
|
}
|
|
1432
|
-
get errors() {
|
|
1433
|
-
return this.issues;
|
|
1434
|
-
}
|
|
1435
1436
|
format(_mapper) {
|
|
1436
1437
|
const mapper = _mapper || function(issue) {
|
|
1437
1438
|
return issue.message;
|
|
@@ -1468,6 +1469,11 @@ class ZodError extends Error {
|
|
|
1468
1469
|
processError(this);
|
|
1469
1470
|
return fieldErrors;
|
|
1470
1471
|
}
|
|
1472
|
+
static assert(value) {
|
|
1473
|
+
if (!(value instanceof ZodError)) {
|
|
1474
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1471
1477
|
toString() {
|
|
1472
1478
|
return this.message;
|
|
1473
1479
|
}
|
|
@@ -1482,8 +1488,9 @@ class ZodError extends Error {
|
|
|
1482
1488
|
const formErrors = [];
|
|
1483
1489
|
for (const sub of this.issues) {
|
|
1484
1490
|
if (sub.path.length > 0) {
|
|
1485
|
-
|
|
1486
|
-
fieldErrors[
|
|
1491
|
+
const firstEl = sub.path[0];
|
|
1492
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
1493
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
1487
1494
|
} else {
|
|
1488
1495
|
formErrors.push(mapper(sub));
|
|
1489
1496
|
}
|
|
@@ -1559,6 +1566,8 @@ const errorMap = (issue, _ctx) => {
|
|
|
1559
1566
|
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
1560
1567
|
else if (issue.type === "number")
|
|
1561
1568
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
1569
|
+
else if (issue.type === "bigint")
|
|
1570
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
1562
1571
|
else if (issue.type === "date")
|
|
1563
1572
|
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
1564
1573
|
else
|
|
@@ -1610,6 +1619,13 @@ const makeIssue = (params) => {
|
|
|
1610
1619
|
...issueData,
|
|
1611
1620
|
path: fullPath
|
|
1612
1621
|
};
|
|
1622
|
+
if (issueData.message !== void 0) {
|
|
1623
|
+
return {
|
|
1624
|
+
...issueData,
|
|
1625
|
+
path: fullPath,
|
|
1626
|
+
message: issueData.message
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1613
1629
|
let errorMessage = "";
|
|
1614
1630
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
1615
1631
|
for (const map of maps) {
|
|
@@ -1618,20 +1634,24 @@ const makeIssue = (params) => {
|
|
|
1618
1634
|
return {
|
|
1619
1635
|
...issueData,
|
|
1620
1636
|
path: fullPath,
|
|
1621
|
-
message:
|
|
1637
|
+
message: errorMessage
|
|
1622
1638
|
};
|
|
1623
1639
|
};
|
|
1624
1640
|
const EMPTY_PATH = [];
|
|
1625
1641
|
function addIssueToContext(ctx, issueData) {
|
|
1642
|
+
const overrideMap = getErrorMap();
|
|
1626
1643
|
const issue = makeIssue({
|
|
1627
1644
|
issueData,
|
|
1628
1645
|
data: ctx.data,
|
|
1629
1646
|
path: ctx.path,
|
|
1630
1647
|
errorMaps: [
|
|
1631
1648
|
ctx.common.contextualErrorMap,
|
|
1649
|
+
// contextual error map is first priority
|
|
1632
1650
|
ctx.schemaErrorMap,
|
|
1633
|
-
|
|
1634
|
-
|
|
1651
|
+
// then schema-bound map if available
|
|
1652
|
+
overrideMap,
|
|
1653
|
+
// then global override map
|
|
1654
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
1635
1655
|
// then global default map
|
|
1636
1656
|
].filter((x) => !!x)
|
|
1637
1657
|
});
|
|
@@ -1663,9 +1683,11 @@ class ParseStatus {
|
|
|
1663
1683
|
static async mergeObjectAsync(status, pairs) {
|
|
1664
1684
|
const syncPairs = [];
|
|
1665
1685
|
for (const pair of pairs) {
|
|
1686
|
+
const key = await pair.key;
|
|
1687
|
+
const value = await pair.value;
|
|
1666
1688
|
syncPairs.push({
|
|
1667
|
-
key
|
|
1668
|
-
value
|
|
1689
|
+
key,
|
|
1690
|
+
value
|
|
1669
1691
|
});
|
|
1670
1692
|
}
|
|
1671
1693
|
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -1701,7 +1723,7 @@ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
|
1701
1723
|
var errorUtil;
|
|
1702
1724
|
(function(errorUtil2) {
|
|
1703
1725
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
1704
|
-
errorUtil2.toString = (message) => typeof message === "string" ? message : message
|
|
1726
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
|
|
1705
1727
|
})(errorUtil || (errorUtil = {}));
|
|
1706
1728
|
class ParseInputLazyPath {
|
|
1707
1729
|
constructor(parent, value, path, key) {
|
|
@@ -1713,7 +1735,7 @@ class ParseInputLazyPath {
|
|
|
1713
1735
|
}
|
|
1714
1736
|
get path() {
|
|
1715
1737
|
if (!this._cachedPath.length) {
|
|
1716
|
-
if (this._key
|
|
1738
|
+
if (Array.isArray(this._key)) {
|
|
1717
1739
|
this._cachedPath.push(...this._path, ...this._key);
|
|
1718
1740
|
} else {
|
|
1719
1741
|
this._cachedPath.push(...this._path, this._key);
|
|
@@ -1751,44 +1773,20 @@ function processCreateParams(params) {
|
|
|
1751
1773
|
if (errorMap2)
|
|
1752
1774
|
return { errorMap: errorMap2, description };
|
|
1753
1775
|
const customMap = (iss, ctx) => {
|
|
1754
|
-
|
|
1755
|
-
|
|
1776
|
+
const { message } = params;
|
|
1777
|
+
if (iss.code === "invalid_enum_value") {
|
|
1778
|
+
return { message: message ?? ctx.defaultError };
|
|
1779
|
+
}
|
|
1756
1780
|
if (typeof ctx.data === "undefined") {
|
|
1757
|
-
return { message:
|
|
1781
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
1758
1782
|
}
|
|
1759
|
-
|
|
1783
|
+
if (iss.code !== "invalid_type")
|
|
1784
|
+
return { message: ctx.defaultError };
|
|
1785
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
1760
1786
|
};
|
|
1761
1787
|
return { errorMap: customMap, description };
|
|
1762
1788
|
}
|
|
1763
1789
|
class ZodType {
|
|
1764
|
-
constructor(def) {
|
|
1765
|
-
this.spa = this.safeParseAsync;
|
|
1766
|
-
this._def = def;
|
|
1767
|
-
this.parse = this.parse.bind(this);
|
|
1768
|
-
this.safeParse = this.safeParse.bind(this);
|
|
1769
|
-
this.parseAsync = this.parseAsync.bind(this);
|
|
1770
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
1771
|
-
this.spa = this.spa.bind(this);
|
|
1772
|
-
this.refine = this.refine.bind(this);
|
|
1773
|
-
this.refinement = this.refinement.bind(this);
|
|
1774
|
-
this.superRefine = this.superRefine.bind(this);
|
|
1775
|
-
this.optional = this.optional.bind(this);
|
|
1776
|
-
this.nullable = this.nullable.bind(this);
|
|
1777
|
-
this.nullish = this.nullish.bind(this);
|
|
1778
|
-
this.array = this.array.bind(this);
|
|
1779
|
-
this.promise = this.promise.bind(this);
|
|
1780
|
-
this.or = this.or.bind(this);
|
|
1781
|
-
this.and = this.and.bind(this);
|
|
1782
|
-
this.transform = this.transform.bind(this);
|
|
1783
|
-
this.brand = this.brand.bind(this);
|
|
1784
|
-
this.default = this.default.bind(this);
|
|
1785
|
-
this.catch = this.catch.bind(this);
|
|
1786
|
-
this.describe = this.describe.bind(this);
|
|
1787
|
-
this.pipe = this.pipe.bind(this);
|
|
1788
|
-
this.readonly = this.readonly.bind(this);
|
|
1789
|
-
this.isNullable = this.isNullable.bind(this);
|
|
1790
|
-
this.isOptional = this.isOptional.bind(this);
|
|
1791
|
-
}
|
|
1792
1790
|
get description() {
|
|
1793
1791
|
return this._def.description;
|
|
1794
1792
|
}
|
|
@@ -1836,14 +1834,13 @@ class ZodType {
|
|
|
1836
1834
|
throw result.error;
|
|
1837
1835
|
}
|
|
1838
1836
|
safeParse(data, params) {
|
|
1839
|
-
var _a;
|
|
1840
1837
|
const ctx = {
|
|
1841
1838
|
common: {
|
|
1842
1839
|
issues: [],
|
|
1843
|
-
async: (
|
|
1844
|
-
contextualErrorMap: params
|
|
1840
|
+
async: (params == null ? void 0 : params.async) ?? false,
|
|
1841
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap
|
|
1845
1842
|
},
|
|
1846
|
-
path: (params
|
|
1843
|
+
path: (params == null ? void 0 : params.path) || [],
|
|
1847
1844
|
schemaErrorMap: this._def.errorMap,
|
|
1848
1845
|
parent: null,
|
|
1849
1846
|
data,
|
|
@@ -1852,6 +1849,43 @@ class ZodType {
|
|
|
1852
1849
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
1853
1850
|
return handleResult(ctx, result);
|
|
1854
1851
|
}
|
|
1852
|
+
"~validate"(data) {
|
|
1853
|
+
var _a, _b;
|
|
1854
|
+
const ctx = {
|
|
1855
|
+
common: {
|
|
1856
|
+
issues: [],
|
|
1857
|
+
async: !!this["~standard"].async
|
|
1858
|
+
},
|
|
1859
|
+
path: [],
|
|
1860
|
+
schemaErrorMap: this._def.errorMap,
|
|
1861
|
+
parent: null,
|
|
1862
|
+
data,
|
|
1863
|
+
parsedType: getParsedType(data)
|
|
1864
|
+
};
|
|
1865
|
+
if (!this["~standard"].async) {
|
|
1866
|
+
try {
|
|
1867
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
1868
|
+
return isValid(result) ? {
|
|
1869
|
+
value: result.value
|
|
1870
|
+
} : {
|
|
1871
|
+
issues: ctx.common.issues
|
|
1872
|
+
};
|
|
1873
|
+
} catch (err) {
|
|
1874
|
+
if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {
|
|
1875
|
+
this["~standard"].async = true;
|
|
1876
|
+
}
|
|
1877
|
+
ctx.common = {
|
|
1878
|
+
issues: [],
|
|
1879
|
+
async: true
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
1884
|
+
value: result.value
|
|
1885
|
+
} : {
|
|
1886
|
+
issues: ctx.common.issues
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1855
1889
|
async parseAsync(data, params) {
|
|
1856
1890
|
const result = await this.safeParseAsync(data, params);
|
|
1857
1891
|
if (result.success)
|
|
@@ -1862,10 +1896,10 @@ class ZodType {
|
|
|
1862
1896
|
const ctx = {
|
|
1863
1897
|
common: {
|
|
1864
1898
|
issues: [],
|
|
1865
|
-
contextualErrorMap: params
|
|
1899
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap,
|
|
1866
1900
|
async: true
|
|
1867
1901
|
},
|
|
1868
|
-
path: (params
|
|
1902
|
+
path: (params == null ? void 0 : params.path) || [],
|
|
1869
1903
|
schemaErrorMap: this._def.errorMap,
|
|
1870
1904
|
parent: null,
|
|
1871
1905
|
data,
|
|
@@ -1929,6 +1963,39 @@ class ZodType {
|
|
|
1929
1963
|
superRefine(refinement) {
|
|
1930
1964
|
return this._refinement(refinement);
|
|
1931
1965
|
}
|
|
1966
|
+
constructor(def) {
|
|
1967
|
+
this.spa = this.safeParseAsync;
|
|
1968
|
+
this._def = def;
|
|
1969
|
+
this.parse = this.parse.bind(this);
|
|
1970
|
+
this.safeParse = this.safeParse.bind(this);
|
|
1971
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
1972
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
1973
|
+
this.spa = this.spa.bind(this);
|
|
1974
|
+
this.refine = this.refine.bind(this);
|
|
1975
|
+
this.refinement = this.refinement.bind(this);
|
|
1976
|
+
this.superRefine = this.superRefine.bind(this);
|
|
1977
|
+
this.optional = this.optional.bind(this);
|
|
1978
|
+
this.nullable = this.nullable.bind(this);
|
|
1979
|
+
this.nullish = this.nullish.bind(this);
|
|
1980
|
+
this.array = this.array.bind(this);
|
|
1981
|
+
this.promise = this.promise.bind(this);
|
|
1982
|
+
this.or = this.or.bind(this);
|
|
1983
|
+
this.and = this.and.bind(this);
|
|
1984
|
+
this.transform = this.transform.bind(this);
|
|
1985
|
+
this.brand = this.brand.bind(this);
|
|
1986
|
+
this.default = this.default.bind(this);
|
|
1987
|
+
this.catch = this.catch.bind(this);
|
|
1988
|
+
this.describe = this.describe.bind(this);
|
|
1989
|
+
this.pipe = this.pipe.bind(this);
|
|
1990
|
+
this.readonly = this.readonly.bind(this);
|
|
1991
|
+
this.isNullable = this.isNullable.bind(this);
|
|
1992
|
+
this.isOptional = this.isOptional.bind(this);
|
|
1993
|
+
this["~standard"] = {
|
|
1994
|
+
version: 1,
|
|
1995
|
+
vendor: "zod",
|
|
1996
|
+
validate: (data) => this["~validate"](data)
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1932
1999
|
optional() {
|
|
1933
2000
|
return ZodOptional.create(this, this._def);
|
|
1934
2001
|
}
|
|
@@ -1939,7 +2006,7 @@ class ZodType {
|
|
|
1939
2006
|
return this.nullable().optional();
|
|
1940
2007
|
}
|
|
1941
2008
|
array() {
|
|
1942
|
-
return ZodArray.create(this
|
|
2009
|
+
return ZodArray.create(this);
|
|
1943
2010
|
}
|
|
1944
2011
|
promise() {
|
|
1945
2012
|
return ZodPromise.create(this, this._def);
|
|
@@ -2004,35 +2071,45 @@ class ZodType {
|
|
|
2004
2071
|
}
|
|
2005
2072
|
}
|
|
2006
2073
|
const cuidRegex = /^c[^\s-]{8,}$/i;
|
|
2007
|
-
const cuid2Regex = /^[
|
|
2008
|
-
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
|
2074
|
+
const cuid2Regex = /^[0-9a-z]+$/;
|
|
2075
|
+
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
2009
2076
|
const 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;
|
|
2010
|
-
const
|
|
2077
|
+
const nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
2078
|
+
const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
2079
|
+
const 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)?)??$/;
|
|
2080
|
+
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
2011
2081
|
const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
2012
2082
|
let emojiRegex;
|
|
2013
|
-
const ipv4Regex = /^((
|
|
2014
|
-
const
|
|
2015
|
-
const
|
|
2083
|
+
const 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])$/;
|
|
2084
|
+
const 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])$/;
|
|
2085
|
+
const 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]))$/;
|
|
2086
|
+
const 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])$/;
|
|
2087
|
+
const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
2088
|
+
const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
2089
|
+
const 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])))`;
|
|
2090
|
+
const dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
2091
|
+
function timeRegexSource(args) {
|
|
2092
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
2016
2093
|
if (args.precision) {
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
2021
|
-
}
|
|
2022
|
-
} else if (args.precision === 0) {
|
|
2023
|
-
if (args.offset) {
|
|
2024
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
2025
|
-
} else {
|
|
2026
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
2027
|
-
}
|
|
2028
|
-
} else {
|
|
2029
|
-
if (args.offset) {
|
|
2030
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
2031
|
-
} else {
|
|
2032
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
2033
|
-
}
|
|
2094
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
2095
|
+
} else if (args.precision == null) {
|
|
2096
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
2034
2097
|
}
|
|
2035
|
-
|
|
2098
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
2099
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
2100
|
+
}
|
|
2101
|
+
function timeRegex(args) {
|
|
2102
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
2103
|
+
}
|
|
2104
|
+
function datetimeRegex(args) {
|
|
2105
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
2106
|
+
const opts = [];
|
|
2107
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
2108
|
+
if (args.offset)
|
|
2109
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
2110
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
2111
|
+
return new RegExp(`^${regex}$`);
|
|
2112
|
+
}
|
|
2036
2113
|
function isValidIP(ip, version2) {
|
|
2037
2114
|
if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
|
|
2038
2115
|
return true;
|
|
@@ -2042,6 +2119,37 @@ function isValidIP(ip, version2) {
|
|
|
2042
2119
|
}
|
|
2043
2120
|
return false;
|
|
2044
2121
|
}
|
|
2122
|
+
function isValidJWT(jwt, alg) {
|
|
2123
|
+
if (!jwtRegex.test(jwt))
|
|
2124
|
+
return false;
|
|
2125
|
+
try {
|
|
2126
|
+
const [header] = jwt.split(".");
|
|
2127
|
+
if (!header)
|
|
2128
|
+
return false;
|
|
2129
|
+
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
2130
|
+
const decoded = JSON.parse(atob(base64));
|
|
2131
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
2132
|
+
return false;
|
|
2133
|
+
if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")
|
|
2134
|
+
return false;
|
|
2135
|
+
if (!decoded.alg)
|
|
2136
|
+
return false;
|
|
2137
|
+
if (alg && decoded.alg !== alg)
|
|
2138
|
+
return false;
|
|
2139
|
+
return true;
|
|
2140
|
+
} catch {
|
|
2141
|
+
return false;
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
function isValidCidr(ip, version2) {
|
|
2145
|
+
if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
|
|
2146
|
+
return true;
|
|
2147
|
+
}
|
|
2148
|
+
if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
|
|
2149
|
+
return true;
|
|
2150
|
+
}
|
|
2151
|
+
return false;
|
|
2152
|
+
}
|
|
2045
2153
|
class ZodString extends ZodType {
|
|
2046
2154
|
_parse(input) {
|
|
2047
2155
|
if (this._def.coerce) {
|
|
@@ -2050,15 +2158,11 @@ class ZodString extends ZodType {
|
|
|
2050
2158
|
const parsedType = this._getType(input);
|
|
2051
2159
|
if (parsedType !== ZodParsedType.string) {
|
|
2052
2160
|
const ctx2 = this._getOrReturnCtx(input);
|
|
2053
|
-
addIssueToContext(
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
received: ctx2.parsedType
|
|
2059
|
-
}
|
|
2060
|
-
//
|
|
2061
|
-
);
|
|
2161
|
+
addIssueToContext(ctx2, {
|
|
2162
|
+
code: ZodIssueCode.invalid_type,
|
|
2163
|
+
expected: ZodParsedType.string,
|
|
2164
|
+
received: ctx2.parsedType
|
|
2165
|
+
});
|
|
2062
2166
|
return INVALID;
|
|
2063
2167
|
}
|
|
2064
2168
|
const status = new ParseStatus();
|
|
@@ -2149,6 +2253,16 @@ class ZodString extends ZodType {
|
|
|
2149
2253
|
});
|
|
2150
2254
|
status.dirty();
|
|
2151
2255
|
}
|
|
2256
|
+
} else if (check.kind === "nanoid") {
|
|
2257
|
+
if (!nanoidRegex.test(input.data)) {
|
|
2258
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2259
|
+
addIssueToContext(ctx, {
|
|
2260
|
+
validation: "nanoid",
|
|
2261
|
+
code: ZodIssueCode.invalid_string,
|
|
2262
|
+
message: check.message
|
|
2263
|
+
});
|
|
2264
|
+
status.dirty();
|
|
2265
|
+
}
|
|
2152
2266
|
} else if (check.kind === "cuid") {
|
|
2153
2267
|
if (!cuidRegex.test(input.data)) {
|
|
2154
2268
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2182,7 +2296,7 @@ class ZodString extends ZodType {
|
|
|
2182
2296
|
} else if (check.kind === "url") {
|
|
2183
2297
|
try {
|
|
2184
2298
|
new URL(input.data);
|
|
2185
|
-
} catch
|
|
2299
|
+
} catch {
|
|
2186
2300
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
2187
2301
|
addIssueToContext(ctx, {
|
|
2188
2302
|
validation: "url",
|
|
@@ -2250,6 +2364,38 @@ class ZodString extends ZodType {
|
|
|
2250
2364
|
});
|
|
2251
2365
|
status.dirty();
|
|
2252
2366
|
}
|
|
2367
|
+
} else if (check.kind === "date") {
|
|
2368
|
+
const regex = dateRegex;
|
|
2369
|
+
if (!regex.test(input.data)) {
|
|
2370
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2371
|
+
addIssueToContext(ctx, {
|
|
2372
|
+
code: ZodIssueCode.invalid_string,
|
|
2373
|
+
validation: "date",
|
|
2374
|
+
message: check.message
|
|
2375
|
+
});
|
|
2376
|
+
status.dirty();
|
|
2377
|
+
}
|
|
2378
|
+
} else if (check.kind === "time") {
|
|
2379
|
+
const regex = timeRegex(check);
|
|
2380
|
+
if (!regex.test(input.data)) {
|
|
2381
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2382
|
+
addIssueToContext(ctx, {
|
|
2383
|
+
code: ZodIssueCode.invalid_string,
|
|
2384
|
+
validation: "time",
|
|
2385
|
+
message: check.message
|
|
2386
|
+
});
|
|
2387
|
+
status.dirty();
|
|
2388
|
+
}
|
|
2389
|
+
} else if (check.kind === "duration") {
|
|
2390
|
+
if (!durationRegex.test(input.data)) {
|
|
2391
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2392
|
+
addIssueToContext(ctx, {
|
|
2393
|
+
validation: "duration",
|
|
2394
|
+
code: ZodIssueCode.invalid_string,
|
|
2395
|
+
message: check.message
|
|
2396
|
+
});
|
|
2397
|
+
status.dirty();
|
|
2398
|
+
}
|
|
2253
2399
|
} else if (check.kind === "ip") {
|
|
2254
2400
|
if (!isValidIP(input.data, check.version)) {
|
|
2255
2401
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -2260,6 +2406,46 @@ class ZodString extends ZodType {
|
|
|
2260
2406
|
});
|
|
2261
2407
|
status.dirty();
|
|
2262
2408
|
}
|
|
2409
|
+
} else if (check.kind === "jwt") {
|
|
2410
|
+
if (!isValidJWT(input.data, check.alg)) {
|
|
2411
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2412
|
+
addIssueToContext(ctx, {
|
|
2413
|
+
validation: "jwt",
|
|
2414
|
+
code: ZodIssueCode.invalid_string,
|
|
2415
|
+
message: check.message
|
|
2416
|
+
});
|
|
2417
|
+
status.dirty();
|
|
2418
|
+
}
|
|
2419
|
+
} else if (check.kind === "cidr") {
|
|
2420
|
+
if (!isValidCidr(input.data, check.version)) {
|
|
2421
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2422
|
+
addIssueToContext(ctx, {
|
|
2423
|
+
validation: "cidr",
|
|
2424
|
+
code: ZodIssueCode.invalid_string,
|
|
2425
|
+
message: check.message
|
|
2426
|
+
});
|
|
2427
|
+
status.dirty();
|
|
2428
|
+
}
|
|
2429
|
+
} else if (check.kind === "base64") {
|
|
2430
|
+
if (!base64Regex.test(input.data)) {
|
|
2431
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2432
|
+
addIssueToContext(ctx, {
|
|
2433
|
+
validation: "base64",
|
|
2434
|
+
code: ZodIssueCode.invalid_string,
|
|
2435
|
+
message: check.message
|
|
2436
|
+
});
|
|
2437
|
+
status.dirty();
|
|
2438
|
+
}
|
|
2439
|
+
} else if (check.kind === "base64url") {
|
|
2440
|
+
if (!base64urlRegex.test(input.data)) {
|
|
2441
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
2442
|
+
addIssueToContext(ctx, {
|
|
2443
|
+
validation: "base64url",
|
|
2444
|
+
code: ZodIssueCode.invalid_string,
|
|
2445
|
+
message: check.message
|
|
2446
|
+
});
|
|
2447
|
+
status.dirty();
|
|
2448
|
+
}
|
|
2263
2449
|
} else {
|
|
2264
2450
|
util.assertNever(check);
|
|
2265
2451
|
}
|
|
@@ -2291,6 +2477,9 @@ class ZodString extends ZodType {
|
|
|
2291
2477
|
uuid(message) {
|
|
2292
2478
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
2293
2479
|
}
|
|
2480
|
+
nanoid(message) {
|
|
2481
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
2482
|
+
}
|
|
2294
2483
|
cuid(message) {
|
|
2295
2484
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
2296
2485
|
}
|
|
@@ -2300,26 +2489,62 @@ class ZodString extends ZodType {
|
|
|
2300
2489
|
ulid(message) {
|
|
2301
2490
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
2302
2491
|
}
|
|
2492
|
+
base64(message) {
|
|
2493
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
2494
|
+
}
|
|
2495
|
+
base64url(message) {
|
|
2496
|
+
return this._addCheck({
|
|
2497
|
+
kind: "base64url",
|
|
2498
|
+
...errorUtil.errToObj(message)
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
jwt(options) {
|
|
2502
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
2503
|
+
}
|
|
2303
2504
|
ip(options) {
|
|
2304
2505
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
2305
2506
|
}
|
|
2507
|
+
cidr(options) {
|
|
2508
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
2509
|
+
}
|
|
2306
2510
|
datetime(options) {
|
|
2307
|
-
var _a;
|
|
2308
2511
|
if (typeof options === "string") {
|
|
2309
2512
|
return this._addCheck({
|
|
2310
2513
|
kind: "datetime",
|
|
2311
2514
|
precision: null,
|
|
2312
2515
|
offset: false,
|
|
2516
|
+
local: false,
|
|
2313
2517
|
message: options
|
|
2314
2518
|
});
|
|
2315
2519
|
}
|
|
2316
2520
|
return this._addCheck({
|
|
2317
2521
|
kind: "datetime",
|
|
2318
|
-
precision: typeof (options
|
|
2319
|
-
offset: (
|
|
2320
|
-
|
|
2522
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
|
2523
|
+
offset: (options == null ? void 0 : options.offset) ?? false,
|
|
2524
|
+
local: (options == null ? void 0 : options.local) ?? false,
|
|
2525
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
|
2321
2526
|
});
|
|
2322
2527
|
}
|
|
2528
|
+
date(message) {
|
|
2529
|
+
return this._addCheck({ kind: "date", message });
|
|
2530
|
+
}
|
|
2531
|
+
time(options) {
|
|
2532
|
+
if (typeof options === "string") {
|
|
2533
|
+
return this._addCheck({
|
|
2534
|
+
kind: "time",
|
|
2535
|
+
precision: null,
|
|
2536
|
+
message: options
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
return this._addCheck({
|
|
2540
|
+
kind: "time",
|
|
2541
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
|
2542
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
duration(message) {
|
|
2546
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
2547
|
+
}
|
|
2323
2548
|
regex(regex, message) {
|
|
2324
2549
|
return this._addCheck({
|
|
2325
2550
|
kind: "regex",
|
|
@@ -2331,8 +2556,8 @@ class ZodString extends ZodType {
|
|
|
2331
2556
|
return this._addCheck({
|
|
2332
2557
|
kind: "includes",
|
|
2333
2558
|
value,
|
|
2334
|
-
position: options
|
|
2335
|
-
...errorUtil.errToObj(options
|
|
2559
|
+
position: options == null ? void 0 : options.position,
|
|
2560
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
|
2336
2561
|
});
|
|
2337
2562
|
}
|
|
2338
2563
|
startsWith(value, message) {
|
|
@@ -2371,8 +2596,7 @@ class ZodString extends ZodType {
|
|
|
2371
2596
|
});
|
|
2372
2597
|
}
|
|
2373
2598
|
/**
|
|
2374
|
-
*
|
|
2375
|
-
* @see {@link ZodString.min}
|
|
2599
|
+
* Equivalent to `.min(1)`
|
|
2376
2600
|
*/
|
|
2377
2601
|
nonempty(message) {
|
|
2378
2602
|
return this.min(1, errorUtil.errToObj(message));
|
|
@@ -2398,6 +2622,15 @@ class ZodString extends ZodType {
|
|
|
2398
2622
|
get isDatetime() {
|
|
2399
2623
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
2400
2624
|
}
|
|
2625
|
+
get isDate() {
|
|
2626
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
2627
|
+
}
|
|
2628
|
+
get isTime() {
|
|
2629
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
2630
|
+
}
|
|
2631
|
+
get isDuration() {
|
|
2632
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
2633
|
+
}
|
|
2401
2634
|
get isEmail() {
|
|
2402
2635
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
2403
2636
|
}
|
|
@@ -2410,6 +2643,9 @@ class ZodString extends ZodType {
|
|
|
2410
2643
|
get isUUID() {
|
|
2411
2644
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
2412
2645
|
}
|
|
2646
|
+
get isNANOID() {
|
|
2647
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
2648
|
+
}
|
|
2413
2649
|
get isCUID() {
|
|
2414
2650
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
2415
2651
|
}
|
|
@@ -2422,6 +2658,15 @@ class ZodString extends ZodType {
|
|
|
2422
2658
|
get isIP() {
|
|
2423
2659
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
2424
2660
|
}
|
|
2661
|
+
get isCIDR() {
|
|
2662
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
2663
|
+
}
|
|
2664
|
+
get isBase64() {
|
|
2665
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
2666
|
+
}
|
|
2667
|
+
get isBase64url() {
|
|
2668
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
2669
|
+
}
|
|
2425
2670
|
get minLength() {
|
|
2426
2671
|
let min = null;
|
|
2427
2672
|
for (const ch of this._def.checks) {
|
|
@@ -2444,11 +2689,10 @@ class ZodString extends ZodType {
|
|
|
2444
2689
|
}
|
|
2445
2690
|
}
|
|
2446
2691
|
ZodString.create = (params) => {
|
|
2447
|
-
var _a;
|
|
2448
2692
|
return new ZodString({
|
|
2449
2693
|
checks: [],
|
|
2450
2694
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
2451
|
-
coerce: (
|
|
2695
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
|
2452
2696
|
...processCreateParams(params)
|
|
2453
2697
|
});
|
|
2454
2698
|
};
|
|
@@ -2456,9 +2700,9 @@ function floatSafeRemainder(val, step) {
|
|
|
2456
2700
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
2457
2701
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
2458
2702
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
2459
|
-
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
|
2460
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
2461
|
-
return valInt % stepInt /
|
|
2703
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
2704
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
2705
|
+
return valInt % stepInt / 10 ** decCount;
|
|
2462
2706
|
}
|
|
2463
2707
|
class ZodNumber extends ZodType {
|
|
2464
2708
|
constructor() {
|
|
@@ -2668,7 +2912,8 @@ class ZodNumber extends ZodType {
|
|
|
2668
2912
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
2669
2913
|
}
|
|
2670
2914
|
get isFinite() {
|
|
2671
|
-
let max = null
|
|
2915
|
+
let max = null;
|
|
2916
|
+
let min = null;
|
|
2672
2917
|
for (const ch of this._def.checks) {
|
|
2673
2918
|
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
2674
2919
|
return true;
|
|
@@ -2687,7 +2932,7 @@ ZodNumber.create = (params) => {
|
|
|
2687
2932
|
return new ZodNumber({
|
|
2688
2933
|
checks: [],
|
|
2689
2934
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
2690
|
-
coerce: (params
|
|
2935
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
|
2691
2936
|
...processCreateParams(params)
|
|
2692
2937
|
});
|
|
2693
2938
|
};
|
|
@@ -2699,17 +2944,15 @@ class ZodBigInt extends ZodType {
|
|
|
2699
2944
|
}
|
|
2700
2945
|
_parse(input) {
|
|
2701
2946
|
if (this._def.coerce) {
|
|
2702
|
-
|
|
2947
|
+
try {
|
|
2948
|
+
input.data = BigInt(input.data);
|
|
2949
|
+
} catch {
|
|
2950
|
+
return this._getInvalidInput(input);
|
|
2951
|
+
}
|
|
2703
2952
|
}
|
|
2704
2953
|
const parsedType = this._getType(input);
|
|
2705
2954
|
if (parsedType !== ZodParsedType.bigint) {
|
|
2706
|
-
|
|
2707
|
-
addIssueToContext(ctx2, {
|
|
2708
|
-
code: ZodIssueCode.invalid_type,
|
|
2709
|
-
expected: ZodParsedType.bigint,
|
|
2710
|
-
received: ctx2.parsedType
|
|
2711
|
-
});
|
|
2712
|
-
return INVALID;
|
|
2955
|
+
return this._getInvalidInput(input);
|
|
2713
2956
|
}
|
|
2714
2957
|
let ctx = void 0;
|
|
2715
2958
|
const status = new ParseStatus();
|
|
@@ -2756,6 +2999,15 @@ class ZodBigInt extends ZodType {
|
|
|
2756
2999
|
}
|
|
2757
3000
|
return { status: status.value, value: input.data };
|
|
2758
3001
|
}
|
|
3002
|
+
_getInvalidInput(input) {
|
|
3003
|
+
const ctx = this._getOrReturnCtx(input);
|
|
3004
|
+
addIssueToContext(ctx, {
|
|
3005
|
+
code: ZodIssueCode.invalid_type,
|
|
3006
|
+
expected: ZodParsedType.bigint,
|
|
3007
|
+
received: ctx.parsedType
|
|
3008
|
+
});
|
|
3009
|
+
return INVALID;
|
|
3010
|
+
}
|
|
2759
3011
|
gte(value, message) {
|
|
2760
3012
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
2761
3013
|
}
|
|
@@ -2849,11 +3101,10 @@ class ZodBigInt extends ZodType {
|
|
|
2849
3101
|
}
|
|
2850
3102
|
}
|
|
2851
3103
|
ZodBigInt.create = (params) => {
|
|
2852
|
-
var _a;
|
|
2853
3104
|
return new ZodBigInt({
|
|
2854
3105
|
checks: [],
|
|
2855
3106
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
2856
|
-
coerce: (
|
|
3107
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
|
2857
3108
|
...processCreateParams(params)
|
|
2858
3109
|
});
|
|
2859
3110
|
};
|
|
@@ -2878,7 +3129,7 @@ class ZodBoolean extends ZodType {
|
|
|
2878
3129
|
ZodBoolean.create = (params) => {
|
|
2879
3130
|
return new ZodBoolean({
|
|
2880
3131
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
2881
|
-
coerce: (params
|
|
3132
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
|
2882
3133
|
...processCreateParams(params)
|
|
2883
3134
|
});
|
|
2884
3135
|
};
|
|
@@ -2897,7 +3148,7 @@ class ZodDate extends ZodType {
|
|
|
2897
3148
|
});
|
|
2898
3149
|
return INVALID;
|
|
2899
3150
|
}
|
|
2900
|
-
if (isNaN(input.data.getTime())) {
|
|
3151
|
+
if (Number.isNaN(input.data.getTime())) {
|
|
2901
3152
|
const ctx2 = this._getOrReturnCtx(input);
|
|
2902
3153
|
addIssueToContext(ctx2, {
|
|
2903
3154
|
code: ZodIssueCode.invalid_date
|
|
@@ -2986,7 +3237,7 @@ class ZodDate extends ZodType {
|
|
|
2986
3237
|
ZodDate.create = (params) => {
|
|
2987
3238
|
return new ZodDate({
|
|
2988
3239
|
checks: [],
|
|
2989
|
-
coerce: (params
|
|
3240
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
|
2990
3241
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
2991
3242
|
...processCreateParams(params)
|
|
2992
3243
|
});
|
|
@@ -3261,7 +3512,8 @@ class ZodObject extends ZodType {
|
|
|
3261
3512
|
return this._cached;
|
|
3262
3513
|
const shape = this._def.shape();
|
|
3263
3514
|
const keys = util.objectKeys(shape);
|
|
3264
|
-
|
|
3515
|
+
this._cached = { shape, keys };
|
|
3516
|
+
return this._cached;
|
|
3265
3517
|
}
|
|
3266
3518
|
_parse(input) {
|
|
3267
3519
|
const parsedType = this._getType(input);
|
|
@@ -3334,9 +3586,10 @@ class ZodObject extends ZodType {
|
|
|
3334
3586
|
const syncPairs = [];
|
|
3335
3587
|
for (const pair of pairs) {
|
|
3336
3588
|
const key = await pair.key;
|
|
3589
|
+
const value = await pair.value;
|
|
3337
3590
|
syncPairs.push({
|
|
3338
3591
|
key,
|
|
3339
|
-
value
|
|
3592
|
+
value,
|
|
3340
3593
|
alwaysSet: pair.alwaysSet
|
|
3341
3594
|
});
|
|
3342
3595
|
}
|
|
@@ -3358,11 +3611,11 @@ class ZodObject extends ZodType {
|
|
|
3358
3611
|
unknownKeys: "strict",
|
|
3359
3612
|
...message !== void 0 ? {
|
|
3360
3613
|
errorMap: (issue, ctx) => {
|
|
3361
|
-
var _a, _b
|
|
3362
|
-
const defaultError = (
|
|
3614
|
+
var _a, _b;
|
|
3615
|
+
const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;
|
|
3363
3616
|
if (issue.code === "unrecognized_keys")
|
|
3364
3617
|
return {
|
|
3365
|
-
message:
|
|
3618
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
3366
3619
|
};
|
|
3367
3620
|
return {
|
|
3368
3621
|
message: defaultError
|
|
@@ -3493,11 +3746,11 @@ class ZodObject extends ZodType {
|
|
|
3493
3746
|
}
|
|
3494
3747
|
pick(mask) {
|
|
3495
3748
|
const shape = {};
|
|
3496
|
-
util.objectKeys(mask)
|
|
3749
|
+
for (const key of util.objectKeys(mask)) {
|
|
3497
3750
|
if (mask[key] && this.shape[key]) {
|
|
3498
3751
|
shape[key] = this.shape[key];
|
|
3499
3752
|
}
|
|
3500
|
-
}
|
|
3753
|
+
}
|
|
3501
3754
|
return new ZodObject({
|
|
3502
3755
|
...this._def,
|
|
3503
3756
|
shape: () => shape
|
|
@@ -3505,11 +3758,11 @@ class ZodObject extends ZodType {
|
|
|
3505
3758
|
}
|
|
3506
3759
|
omit(mask) {
|
|
3507
3760
|
const shape = {};
|
|
3508
|
-
util.objectKeys(this.shape)
|
|
3761
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
3509
3762
|
if (!mask[key]) {
|
|
3510
3763
|
shape[key] = this.shape[key];
|
|
3511
3764
|
}
|
|
3512
|
-
}
|
|
3765
|
+
}
|
|
3513
3766
|
return new ZodObject({
|
|
3514
3767
|
...this._def,
|
|
3515
3768
|
shape: () => shape
|
|
@@ -3523,14 +3776,14 @@ class ZodObject extends ZodType {
|
|
|
3523
3776
|
}
|
|
3524
3777
|
partial(mask) {
|
|
3525
3778
|
const newShape = {};
|
|
3526
|
-
util.objectKeys(this.shape)
|
|
3779
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
3527
3780
|
const fieldSchema = this.shape[key];
|
|
3528
3781
|
if (mask && !mask[key]) {
|
|
3529
3782
|
newShape[key] = fieldSchema;
|
|
3530
3783
|
} else {
|
|
3531
3784
|
newShape[key] = fieldSchema.optional();
|
|
3532
3785
|
}
|
|
3533
|
-
}
|
|
3786
|
+
}
|
|
3534
3787
|
return new ZodObject({
|
|
3535
3788
|
...this._def,
|
|
3536
3789
|
shape: () => newShape
|
|
@@ -3538,7 +3791,7 @@ class ZodObject extends ZodType {
|
|
|
3538
3791
|
}
|
|
3539
3792
|
required(mask) {
|
|
3540
3793
|
const newShape = {};
|
|
3541
|
-
util.objectKeys(this.shape)
|
|
3794
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
3542
3795
|
if (mask && !mask[key]) {
|
|
3543
3796
|
newShape[key] = this.shape[key];
|
|
3544
3797
|
} else {
|
|
@@ -3549,7 +3802,7 @@ class ZodObject extends ZodType {
|
|
|
3549
3802
|
}
|
|
3550
3803
|
newShape[key] = newField;
|
|
3551
3804
|
}
|
|
3552
|
-
}
|
|
3805
|
+
}
|
|
3553
3806
|
return new ZodObject({
|
|
3554
3807
|
...this._def,
|
|
3555
3808
|
shape: () => newShape
|
|
@@ -3687,15 +3940,25 @@ const getDiscriminator = (type) => {
|
|
|
3687
3940
|
} else if (type instanceof ZodEnum) {
|
|
3688
3941
|
return type.options;
|
|
3689
3942
|
} else if (type instanceof ZodNativeEnum) {
|
|
3690
|
-
return
|
|
3943
|
+
return util.objectValues(type.enum);
|
|
3691
3944
|
} else if (type instanceof ZodDefault) {
|
|
3692
3945
|
return getDiscriminator(type._def.innerType);
|
|
3693
3946
|
} else if (type instanceof ZodUndefined) {
|
|
3694
3947
|
return [void 0];
|
|
3695
3948
|
} else if (type instanceof ZodNull) {
|
|
3696
3949
|
return [null];
|
|
3950
|
+
} else if (type instanceof ZodOptional) {
|
|
3951
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
3952
|
+
} else if (type instanceof ZodNullable) {
|
|
3953
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
3954
|
+
} else if (type instanceof ZodBranded) {
|
|
3955
|
+
return getDiscriminator(type.unwrap());
|
|
3956
|
+
} else if (type instanceof ZodReadonly) {
|
|
3957
|
+
return getDiscriminator(type.unwrap());
|
|
3958
|
+
} else if (type instanceof ZodCatch) {
|
|
3959
|
+
return getDiscriminator(type._def.innerType);
|
|
3697
3960
|
} else {
|
|
3698
|
-
return
|
|
3961
|
+
return [];
|
|
3699
3962
|
}
|
|
3700
3963
|
};
|
|
3701
3964
|
class ZodDiscriminatedUnion extends ZodType {
|
|
@@ -3755,7 +4018,7 @@ class ZodDiscriminatedUnion extends ZodType {
|
|
|
3755
4018
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
3756
4019
|
for (const type of options) {
|
|
3757
4020
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
3758
|
-
if (!discriminatorValues) {
|
|
4021
|
+
if (!discriminatorValues.length) {
|
|
3759
4022
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
3760
4023
|
}
|
|
3761
4024
|
for (const value of discriminatorValues) {
|
|
@@ -3955,7 +4218,8 @@ class ZodRecord extends ZodType {
|
|
|
3955
4218
|
for (const key in ctx.data) {
|
|
3956
4219
|
pairs.push({
|
|
3957
4220
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
3958
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
4221
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
4222
|
+
alwaysSet: key in ctx.data
|
|
3959
4223
|
});
|
|
3960
4224
|
}
|
|
3961
4225
|
if (ctx.common.async) {
|
|
@@ -4154,12 +4418,7 @@ class ZodFunction extends ZodType {
|
|
|
4154
4418
|
return makeIssue({
|
|
4155
4419
|
data: args,
|
|
4156
4420
|
path: ctx.path,
|
|
4157
|
-
errorMaps: [
|
|
4158
|
-
ctx.common.contextualErrorMap,
|
|
4159
|
-
ctx.schemaErrorMap,
|
|
4160
|
-
getErrorMap(),
|
|
4161
|
-
errorMap
|
|
4162
|
-
].filter((x) => !!x),
|
|
4421
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), errorMap].filter((x) => !!x),
|
|
4163
4422
|
issueData: {
|
|
4164
4423
|
code: ZodIssueCode.invalid_arguments,
|
|
4165
4424
|
argumentsError: error
|
|
@@ -4170,12 +4429,7 @@ class ZodFunction extends ZodType {
|
|
|
4170
4429
|
return makeIssue({
|
|
4171
4430
|
data: returns,
|
|
4172
4431
|
path: ctx.path,
|
|
4173
|
-
errorMaps: [
|
|
4174
|
-
ctx.common.contextualErrorMap,
|
|
4175
|
-
ctx.schemaErrorMap,
|
|
4176
|
-
getErrorMap(),
|
|
4177
|
-
errorMap
|
|
4178
|
-
].filter((x) => !!x),
|
|
4432
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), errorMap].filter((x) => !!x),
|
|
4179
4433
|
issueData: {
|
|
4180
4434
|
code: ZodIssueCode.invalid_return_type,
|
|
4181
4435
|
returnTypeError: error
|
|
@@ -4310,7 +4564,10 @@ class ZodEnum extends ZodType {
|
|
|
4310
4564
|
});
|
|
4311
4565
|
return INVALID;
|
|
4312
4566
|
}
|
|
4313
|
-
if (this.
|
|
4567
|
+
if (!this._cache) {
|
|
4568
|
+
this._cache = new Set(this._def.values);
|
|
4569
|
+
}
|
|
4570
|
+
if (!this._cache.has(input.data)) {
|
|
4314
4571
|
const ctx = this._getOrReturnCtx(input);
|
|
4315
4572
|
const expectedValues = this._def.values;
|
|
4316
4573
|
addIssueToContext(ctx, {
|
|
@@ -4346,11 +4603,17 @@ class ZodEnum extends ZodType {
|
|
|
4346
4603
|
}
|
|
4347
4604
|
return enumValues;
|
|
4348
4605
|
}
|
|
4349
|
-
extract(values) {
|
|
4350
|
-
return ZodEnum.create(values
|
|
4606
|
+
extract(values, newDef = this._def) {
|
|
4607
|
+
return ZodEnum.create(values, {
|
|
4608
|
+
...this._def,
|
|
4609
|
+
...newDef
|
|
4610
|
+
});
|
|
4351
4611
|
}
|
|
4352
|
-
exclude(values) {
|
|
4353
|
-
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt))
|
|
4612
|
+
exclude(values, newDef = this._def) {
|
|
4613
|
+
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
4614
|
+
...this._def,
|
|
4615
|
+
...newDef
|
|
4616
|
+
});
|
|
4354
4617
|
}
|
|
4355
4618
|
}
|
|
4356
4619
|
ZodEnum.create = createZodEnum;
|
|
@@ -4367,7 +4630,10 @@ class ZodNativeEnum extends ZodType {
|
|
|
4367
4630
|
});
|
|
4368
4631
|
return INVALID;
|
|
4369
4632
|
}
|
|
4370
|
-
if (
|
|
4633
|
+
if (!this._cache) {
|
|
4634
|
+
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
4635
|
+
}
|
|
4636
|
+
if (!this._cache.has(input.data)) {
|
|
4371
4637
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
4372
4638
|
addIssueToContext(ctx, {
|
|
4373
4639
|
received: ctx.data,
|
|
@@ -4445,26 +4711,38 @@ class ZodEffects extends ZodType {
|
|
|
4445
4711
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
4446
4712
|
if (effect.type === "preprocess") {
|
|
4447
4713
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
4448
|
-
if (ctx.common.issues.length) {
|
|
4449
|
-
return {
|
|
4450
|
-
status: "dirty",
|
|
4451
|
-
value: ctx.data
|
|
4452
|
-
};
|
|
4453
|
-
}
|
|
4454
4714
|
if (ctx.common.async) {
|
|
4455
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
4456
|
-
|
|
4715
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
4716
|
+
if (status.value === "aborted")
|
|
4717
|
+
return INVALID;
|
|
4718
|
+
const result = await this._def.schema._parseAsync({
|
|
4457
4719
|
data: processed2,
|
|
4458
4720
|
path: ctx.path,
|
|
4459
4721
|
parent: ctx
|
|
4460
4722
|
});
|
|
4723
|
+
if (result.status === "aborted")
|
|
4724
|
+
return INVALID;
|
|
4725
|
+
if (result.status === "dirty")
|
|
4726
|
+
return DIRTY(result.value);
|
|
4727
|
+
if (status.value === "dirty")
|
|
4728
|
+
return DIRTY(result.value);
|
|
4729
|
+
return result;
|
|
4461
4730
|
});
|
|
4462
4731
|
} else {
|
|
4463
|
-
|
|
4732
|
+
if (status.value === "aborted")
|
|
4733
|
+
return INVALID;
|
|
4734
|
+
const result = this._def.schema._parseSync({
|
|
4464
4735
|
data: processed,
|
|
4465
4736
|
path: ctx.path,
|
|
4466
4737
|
parent: ctx
|
|
4467
4738
|
});
|
|
4739
|
+
if (result.status === "aborted")
|
|
4740
|
+
return INVALID;
|
|
4741
|
+
if (result.status === "dirty")
|
|
4742
|
+
return DIRTY(result.value);
|
|
4743
|
+
if (status.value === "dirty")
|
|
4744
|
+
return DIRTY(result.value);
|
|
4745
|
+
return result;
|
|
4468
4746
|
}
|
|
4469
4747
|
}
|
|
4470
4748
|
if (effect.type === "refinement") {
|
|
@@ -4510,7 +4788,7 @@ class ZodEffects extends ZodType {
|
|
|
4510
4788
|
parent: ctx
|
|
4511
4789
|
});
|
|
4512
4790
|
if (!isValid(base))
|
|
4513
|
-
return
|
|
4791
|
+
return INVALID;
|
|
4514
4792
|
const result = effect.transform(base.value, checkCtx);
|
|
4515
4793
|
if (result instanceof Promise) {
|
|
4516
4794
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
@@ -4519,8 +4797,11 @@ class ZodEffects extends ZodType {
|
|
|
4519
4797
|
} else {
|
|
4520
4798
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
4521
4799
|
if (!isValid(base))
|
|
4522
|
-
return
|
|
4523
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
4800
|
+
return INVALID;
|
|
4801
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
4802
|
+
status: status.value,
|
|
4803
|
+
value: result
|
|
4804
|
+
}));
|
|
4524
4805
|
});
|
|
4525
4806
|
}
|
|
4526
4807
|
}
|
|
@@ -4753,10 +5034,16 @@ class ZodPipeline extends ZodType {
|
|
|
4753
5034
|
class ZodReadonly extends ZodType {
|
|
4754
5035
|
_parse(input) {
|
|
4755
5036
|
const result = this._def.innerType._parse(input);
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
5037
|
+
const freeze = (data) => {
|
|
5038
|
+
if (isValid(data)) {
|
|
5039
|
+
data.value = Object.freeze(data.value);
|
|
5040
|
+
}
|
|
5041
|
+
return data;
|
|
5042
|
+
};
|
|
5043
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
5044
|
+
}
|
|
5045
|
+
unwrap() {
|
|
5046
|
+
return this._def.innerType;
|
|
4760
5047
|
}
|
|
4761
5048
|
}
|
|
4762
5049
|
ZodReadonly.create = (type, params) => {
|
|
@@ -4766,19 +5053,33 @@ ZodReadonly.create = (type, params) => {
|
|
|
4766
5053
|
...processCreateParams(params)
|
|
4767
5054
|
});
|
|
4768
5055
|
};
|
|
4769
|
-
|
|
5056
|
+
function cleanParams(params, data) {
|
|
5057
|
+
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
5058
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
5059
|
+
return p2;
|
|
5060
|
+
}
|
|
5061
|
+
function custom(check, _params = {}, fatal) {
|
|
4770
5062
|
if (check)
|
|
4771
5063
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
4772
|
-
|
|
4773
|
-
if (
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
5064
|
+
const r = check(data);
|
|
5065
|
+
if (r instanceof Promise) {
|
|
5066
|
+
return r.then((r2) => {
|
|
5067
|
+
if (!r2) {
|
|
5068
|
+
const params = cleanParams(_params, data);
|
|
5069
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
5070
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
5071
|
+
}
|
|
5072
|
+
});
|
|
5073
|
+
}
|
|
5074
|
+
if (!r) {
|
|
5075
|
+
const params = cleanParams(_params, data);
|
|
5076
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
5077
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
4778
5078
|
}
|
|
5079
|
+
return;
|
|
4779
5080
|
});
|
|
4780
5081
|
return ZodAny.create();
|
|
4781
|
-
}
|
|
5082
|
+
}
|
|
4782
5083
|
const late = {
|
|
4783
5084
|
object: ZodObject.lazycreate
|
|
4784
5085
|
};
|
|
@@ -4872,98 +5173,98 @@ const coerce = {
|
|
|
4872
5173
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
4873
5174
|
};
|
|
4874
5175
|
const NEVER = INVALID;
|
|
4875
|
-
|
|
5176
|
+
const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4876
5177
|
__proto__: null,
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
getErrorMap,
|
|
4880
|
-
makeIssue,
|
|
5178
|
+
BRAND,
|
|
5179
|
+
DIRTY,
|
|
4881
5180
|
EMPTY_PATH,
|
|
4882
|
-
addIssueToContext,
|
|
4883
|
-
ParseStatus,
|
|
4884
5181
|
INVALID,
|
|
4885
|
-
|
|
5182
|
+
NEVER,
|
|
4886
5183
|
OK,
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
get util() {
|
|
4892
|
-
return util;
|
|
4893
|
-
},
|
|
4894
|
-
get objectUtil() {
|
|
4895
|
-
return objectUtil;
|
|
4896
|
-
},
|
|
4897
|
-
ZodParsedType,
|
|
4898
|
-
getParsedType,
|
|
4899
|
-
ZodType,
|
|
4900
|
-
ZodString,
|
|
4901
|
-
ZodNumber,
|
|
5184
|
+
ParseStatus,
|
|
5185
|
+
Schema: ZodType,
|
|
5186
|
+
ZodAny,
|
|
5187
|
+
ZodArray,
|
|
4902
5188
|
ZodBigInt,
|
|
4903
5189
|
ZodBoolean,
|
|
5190
|
+
ZodBranded,
|
|
5191
|
+
ZodCatch,
|
|
4904
5192
|
ZodDate,
|
|
4905
|
-
|
|
4906
|
-
ZodUndefined,
|
|
4907
|
-
ZodNull,
|
|
4908
|
-
ZodAny,
|
|
4909
|
-
ZodUnknown,
|
|
4910
|
-
ZodNever,
|
|
4911
|
-
ZodVoid,
|
|
4912
|
-
ZodArray,
|
|
4913
|
-
ZodObject,
|
|
4914
|
-
ZodUnion,
|
|
5193
|
+
ZodDefault,
|
|
4915
5194
|
ZodDiscriminatedUnion,
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
5195
|
+
ZodEffects,
|
|
5196
|
+
ZodEnum,
|
|
5197
|
+
ZodError,
|
|
5198
|
+
get ZodFirstPartyTypeKind() {
|
|
5199
|
+
return ZodFirstPartyTypeKind;
|
|
5200
|
+
},
|
|
4921
5201
|
ZodFunction,
|
|
5202
|
+
ZodIntersection,
|
|
5203
|
+
ZodIssueCode,
|
|
4922
5204
|
ZodLazy,
|
|
4923
5205
|
ZodLiteral,
|
|
4924
|
-
|
|
5206
|
+
ZodMap,
|
|
5207
|
+
ZodNaN,
|
|
4925
5208
|
ZodNativeEnum,
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
ZodTransformer: ZodEffects,
|
|
4929
|
-
ZodOptional,
|
|
5209
|
+
ZodNever,
|
|
5210
|
+
ZodNull,
|
|
4930
5211
|
ZodNullable,
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
ZodBranded,
|
|
5212
|
+
ZodNumber,
|
|
5213
|
+
ZodObject,
|
|
5214
|
+
ZodOptional,
|
|
5215
|
+
ZodParsedType,
|
|
4936
5216
|
ZodPipeline,
|
|
5217
|
+
ZodPromise,
|
|
4937
5218
|
ZodReadonly,
|
|
4938
|
-
|
|
4939
|
-
Schema: ZodType,
|
|
5219
|
+
ZodRecord,
|
|
4940
5220
|
ZodSchema: ZodType,
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
5221
|
+
ZodSet,
|
|
5222
|
+
ZodString,
|
|
5223
|
+
ZodSymbol,
|
|
5224
|
+
ZodTransformer: ZodEffects,
|
|
5225
|
+
ZodTuple,
|
|
5226
|
+
ZodType,
|
|
5227
|
+
ZodUndefined,
|
|
5228
|
+
ZodUnion,
|
|
5229
|
+
ZodUnknown,
|
|
5230
|
+
ZodVoid,
|
|
5231
|
+
addIssueToContext,
|
|
4946
5232
|
any: anyType,
|
|
4947
5233
|
array: arrayType,
|
|
4948
5234
|
bigint: bigIntType,
|
|
4949
5235
|
boolean: booleanType,
|
|
5236
|
+
coerce,
|
|
5237
|
+
custom,
|
|
4950
5238
|
date: dateType,
|
|
5239
|
+
datetimeRegex,
|
|
5240
|
+
defaultErrorMap: errorMap,
|
|
4951
5241
|
discriminatedUnion: discriminatedUnionType,
|
|
4952
5242
|
effect: effectsType,
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
5243
|
+
enum: enumType,
|
|
5244
|
+
function: functionType,
|
|
5245
|
+
getErrorMap,
|
|
5246
|
+
getParsedType,
|
|
5247
|
+
instanceof: instanceOfType,
|
|
4956
5248
|
intersection: intersectionType,
|
|
5249
|
+
isAborted,
|
|
5250
|
+
isAsync,
|
|
5251
|
+
isDirty,
|
|
5252
|
+
isValid,
|
|
5253
|
+
late,
|
|
4957
5254
|
lazy: lazyType,
|
|
4958
5255
|
literal: literalType,
|
|
5256
|
+
makeIssue,
|
|
4959
5257
|
map: mapType,
|
|
4960
5258
|
nan: nanType,
|
|
4961
5259
|
nativeEnum: nativeEnumType,
|
|
4962
5260
|
never: neverType,
|
|
4963
|
-
|
|
5261
|
+
null: nullType,
|
|
4964
5262
|
nullable: nullableType,
|
|
4965
5263
|
number: numberType,
|
|
4966
5264
|
object: objectType,
|
|
5265
|
+
get objectUtil() {
|
|
5266
|
+
return objectUtil;
|
|
5267
|
+
},
|
|
4967
5268
|
oboolean,
|
|
4968
5269
|
onumber,
|
|
4969
5270
|
optional: optionalType,
|
|
@@ -4971,22 +5272,23 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4971
5272
|
pipeline: pipelineType,
|
|
4972
5273
|
preprocess: preprocessType,
|
|
4973
5274
|
promise: promiseType,
|
|
5275
|
+
quotelessJson,
|
|
4974
5276
|
record: recordType,
|
|
4975
5277
|
set: setType,
|
|
5278
|
+
setErrorMap,
|
|
4976
5279
|
strictObject: strictObjectType,
|
|
4977
5280
|
string: stringType,
|
|
4978
5281
|
symbol: symbolType,
|
|
4979
5282
|
transformer: effectsType,
|
|
4980
5283
|
tuple: tupleType,
|
|
4981
|
-
|
|
5284
|
+
undefined: undefinedType,
|
|
4982
5285
|
union: unionType,
|
|
4983
5286
|
unknown: unknownType,
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
});
|
|
5287
|
+
get util() {
|
|
5288
|
+
return util;
|
|
5289
|
+
},
|
|
5290
|
+
void: voidType
|
|
5291
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
4990
5292
|
const sdk = new Medusa__default.default({
|
|
4991
5293
|
baseUrl: "/",
|
|
4992
5294
|
debug: false,
|