@shopify/cli 3.70.0 → 3.71.1
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/dist/{chunk-DVTWERMH.js → chunk-24P2IYB3.js} +5 -5
- package/dist/{lib-CPSRXLFM.js → chunk-2HGYYNE5.js} +5 -2
- package/dist/{chunk-5OP2SA7G.js → chunk-2S2TOSUR.js} +214 -56
- package/dist/{chunk-I3IIDOBX.js → chunk-2ULUZCOJ.js} +3 -3
- package/dist/{chunk-PNN7RS7Y.js → chunk-3NSN5Z4N.js} +100 -11
- package/dist/{chunk-AT4IG4GJ.js → chunk-4BWP64T3.js} +9 -11
- package/dist/{chunk-SYRHCENA.js → chunk-4FXGYSQK.js} +2 -2
- package/dist/{chunk-PKE54TAY.js → chunk-5EH323MO.js} +7 -7
- package/dist/{chunk-JLK5OMFF.js → chunk-5RITYBXF.js} +2 -2
- package/dist/{chunk-47OJGAFT.js → chunk-6XIQQAII.js} +3 -3
- package/dist/{chunk-VFQMUAHB.js → chunk-DGICBICS.js} +4 -4
- package/dist/{chunk-335KXO4I.js → chunk-DN4PETPW.js} +7 -7
- package/dist/{chunk-MRDDDATQ.js → chunk-EIYEVKVE.js} +3 -3
- package/dist/{chunk-N2DEYZD6.js → chunk-EKRPU77H.js} +3 -3
- package/dist/{chunk-ZGHNMRBX.js → chunk-HSTSRNLJ.js} +121 -66
- package/dist/{chunk-MMQOVZDR.js → chunk-JJUWGFVJ.js} +5 -5
- package/dist/{chunk-MX4RJDBM.js → chunk-KYB6A4PE.js} +1 -2
- package/dist/{chunk-X6F3DHKX.js → chunk-L2JRQYNX.js} +2 -2
- package/dist/{chunk-GDYKHT64.js → chunk-L5QY66M5.js} +2805 -33
- package/dist/{chunk-XSMWYZDC.js → chunk-LFQTQLLB.js} +10 -10
- package/dist/{chunk-NH4U4X67.js → chunk-LVCMJDAE.js} +4 -4
- package/dist/{chunk-5QQTRGJ7.js → chunk-MU52LLEY.js} +4 -4
- package/dist/{chunk-43YGIE7Y.js → chunk-NGHX3OJ3.js} +2 -2
- package/dist/{chunk-NYFXBTWK.js → chunk-NZRMJMX6.js} +4 -4
- package/dist/{chunk-TCTXUAZT.js → chunk-O53RG2PS.js} +3 -3
- package/dist/{chunk-CBD6UXLA.js → chunk-OJOHMVV7.js} +5 -5
- package/dist/chunk-OSIMKPXN.js +104 -0
- package/dist/{chunk-N4X7XQWN.js → chunk-PGVLZNNX.js} +7 -3
- package/dist/{chunk-VHAXHYTL.js → chunk-PPETSPYI.js} +3 -3
- package/dist/{chunk-UOZCMFCN.js → chunk-RJ26EKJZ.js} +18 -13
- package/dist/{chunk-WN3FKMKB.js → chunk-RWUKHJPN.js} +14 -19
- package/dist/{chunk-ND6AGPC6.js → chunk-RYLVSBYA.js} +3 -3
- package/dist/{chunk-MH5JSAVK.js → chunk-SBXDGZUV.js} +3 -3
- package/dist/{chunk-BMNDAI5O.js → chunk-SQN45NED.js} +4 -4
- package/dist/{chunk-WI6MEN7U.js → chunk-TFYGB36T.js} +2 -2
- package/dist/{chunk-PJKCWDDX.js → chunk-TM56R4RM.js} +548 -550
- package/dist/{chunk-KYBCPKPL.js → chunk-V2IQ2QWA.js} +3 -3
- package/dist/{chunk-NEOIQ6PN.js → chunk-WNDN5FAY.js} +2 -2
- package/dist/{chunk-FDJVVEGH.js → chunk-WQY4NQRT.js} +4 -6
- package/dist/{chunk-LN444KRM.js → chunk-ZINX4YDI.js} +2 -2
- package/dist/{chunk-MQXHFQM3.js → chunk-ZPWQCUYD.js} +4 -4
- package/dist/cli/commands/auth/logout.js +18 -20
- package/dist/cli/commands/auth/logout.test.js +24 -26
- package/dist/cli/commands/cache/clear.js +17 -19
- package/dist/cli/commands/debug/command-flags.js +17 -19
- package/dist/cli/commands/docs/generate.js +17 -19
- package/dist/cli/commands/docs/generate.test.js +18 -20
- package/dist/cli/commands/help.js +17 -19
- package/dist/cli/commands/kitchen-sink/async.js +18 -20
- package/dist/cli/commands/kitchen-sink/async.test.js +19 -21
- package/dist/cli/commands/kitchen-sink/index.js +20 -22
- package/dist/cli/commands/kitchen-sink/index.test.js +23 -25
- package/dist/cli/commands/kitchen-sink/prompts.js +18 -20
- package/dist/cli/commands/kitchen-sink/prompts.test.js +19 -21
- package/dist/cli/commands/kitchen-sink/static.js +18 -20
- package/dist/cli/commands/kitchen-sink/static.test.js +19 -21
- package/dist/cli/commands/notifications/generate.js +18 -20
- package/dist/cli/commands/notifications/list.js +18 -20
- package/dist/cli/commands/search.js +18 -20
- package/dist/cli/commands/upgrade.js +18 -20
- package/dist/cli/commands/upgrade.test.js +1 -2
- package/dist/cli/commands/version.js +18 -20
- package/dist/cli/commands/version.test.js +19 -21
- package/dist/cli/services/commands/notifications.js +12 -14
- package/dist/cli/services/commands/search.js +8 -9
- package/dist/cli/services/commands/search.test.js +9 -10
- package/dist/cli/services/commands/version.js +9 -10
- package/dist/cli/services/commands/version.test.js +11 -12
- package/dist/cli/services/kitchen-sink/async.js +8 -9
- package/dist/cli/services/kitchen-sink/prompts.js +8 -9
- package/dist/cli/services/kitchen-sink/static.js +8 -9
- package/dist/cli/services/upgrade.js +9 -10
- package/dist/cli/services/upgrade.test.js +12 -13
- package/dist/configs/all.yml +15 -0
- package/dist/configs/recommended.yml +9 -0
- package/dist/{custom-oclif-loader-IZLFCRGJ.js → custom-oclif-loader-4ILBNUIN.js} +8 -9
- package/dist/data/filters.json +98 -3
- package/dist/data/latest.json +1 -1
- package/dist/data/manifest_theme.json +1 -0
- package/dist/data/objects.json +39 -1619
- package/dist/data/preset_blocks.json +78 -0
- package/dist/data/section.json +1 -42
- package/dist/data/shopify_system_translations.json +34 -7
- package/dist/data/tags.json +10 -0
- package/dist/data/theme_block.json +1 -19
- package/dist/{del-FEQWOMIX.js → del-K5ZJEWTD.js} +3 -3
- package/dist/{error-handler-DAI5HMQW.js → error-handler-VW3Z4CSO.js} +15 -17
- package/dist/hooks/postrun.js +13 -15
- package/dist/hooks/prerun.js +15 -19
- package/dist/index.js +19504 -17453
- package/dist/lib-PPXZBVZX.js +6 -0
- package/dist/{lib-JJXX7GH6.js → lib-XYCLX35G.js} +5 -5
- package/dist/{local-QD6GDUUE.js → local-42CRL4YR.js} +10 -9
- package/dist/{morph-FN23MJ2S.js → morph-SEECJQ2W.js} +2 -2
- package/dist/{node-4XKDIIJ7.js → node-RJUK5KNM.js} +19 -21
- package/dist/{node-package-manager-IEZ6F5VN.js → node-package-manager-6PHP23VI.js} +9 -10
- package/dist/{out-ZDSLKX4N.js → out-MHEKZJWS.js} +2 -2
- package/dist/{path-T2RCZTRE.js → path-5SZGULBR.js} +2 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{ui-BUB4OWO7.js → ui-OIACULNZ.js} +8 -9
- package/dist/{workerd-DIIGDIHZ.js → workerd-MTYSNN63.js} +19 -21
- package/oclif.manifest.json +334 -131
- package/package.json +7 -8
- package/assets/demo-catalog.json +0 -655
- package/dist/assets/demo-catalog.json +0 -655
- package/dist/chunk-2PUMVRDO.js +0 -131
- package/dist/chunk-7GNQ7YY4.js +0 -116
- package/dist/chunk-E2SYFYJU.js +0 -58
- package/dist/chunk-NLUGD7PZ.js +0 -2731
- package/dist/chunk-P6ABWRKD.js +0 -59
- package/dist/chunk-QSUS3GJF.js +0 -3838
- package/dist/chunk-RUK73IAH.js +0 -312
- package/dist/chunk-T2GATXSP.js +0 -112
- package/dist/chunk-VT3VJHZ7.js +0 -45
- package/dist/chunk-XEDHKQZA.js +0 -116
- package/dist/cli/commands/demo/catalog.d.ts +0 -6
- package/dist/cli/commands/demo/catalog.js +0 -36
- package/dist/cli/commands/demo/generate-file.d.ts +0 -11
- package/dist/cli/commands/demo/generate-file.js +0 -37
- package/dist/cli/commands/demo/index.d.ts +0 -10
- package/dist/cli/commands/demo/index.js +0 -36
- package/dist/cli/commands/demo/print-ai-prompt.d.ts +0 -6
- package/dist/cli/commands/demo/print-ai-prompt.js +0 -37
- package/dist/cli/services/demo.d.ts +0 -26440
- package/dist/cli/services/demo.js +0 -25
- package/dist/cli/services/demo.test.js +0 -42
- package/dist/constants-QFFDI47A.js +0 -26
- package/dist/system-KSIGUX64.js +0 -29
package/dist/chunk-QSUS3GJF.js
DELETED
|
@@ -1,3838 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS,
|
|
3
|
-
init_cjs_shims
|
|
4
|
-
} from "./chunk-POZ5MGPT.js";
|
|
5
|
-
|
|
6
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/util.js
|
|
7
|
-
var require_util = __commonJS({
|
|
8
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/util.js"(exports) {
|
|
9
|
-
"use strict";
|
|
10
|
-
init_cjs_shims();
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
12
|
-
exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0;
|
|
13
|
-
var util;
|
|
14
|
-
(function(util2) {
|
|
15
|
-
util2.assertEqual = (val) => val;
|
|
16
|
-
function assertIs(_arg) {
|
|
17
|
-
}
|
|
18
|
-
util2.assertIs = assertIs;
|
|
19
|
-
function assertNever(_x) {
|
|
20
|
-
throw new Error();
|
|
21
|
-
}
|
|
22
|
-
util2.assertNever = assertNever, util2.arrayToEnum = (items) => {
|
|
23
|
-
let obj = {};
|
|
24
|
-
for (let item of items)
|
|
25
|
-
obj[item] = item;
|
|
26
|
-
return obj;
|
|
27
|
-
}, util2.getValidEnumValues = (obj) => {
|
|
28
|
-
let validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] != "number"), filtered = {};
|
|
29
|
-
for (let k of validKeys)
|
|
30
|
-
filtered[k] = obj[k];
|
|
31
|
-
return util2.objectValues(filtered);
|
|
32
|
-
}, util2.objectValues = (obj) => util2.objectKeys(obj).map(function(e) {
|
|
33
|
-
return obj[e];
|
|
34
|
-
}), util2.objectKeys = typeof Object.keys == "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
35
|
-
let keys = [];
|
|
36
|
-
for (let key in object)
|
|
37
|
-
Object.prototype.hasOwnProperty.call(object, key) && keys.push(key);
|
|
38
|
-
return keys;
|
|
39
|
-
}, util2.find = (arr, checker) => {
|
|
40
|
-
for (let item of arr)
|
|
41
|
-
if (checker(item))
|
|
42
|
-
return item;
|
|
43
|
-
}, util2.isInteger = typeof Number.isInteger == "function" ? (val) => Number.isInteger(val) : (val) => typeof val == "number" && isFinite(val) && Math.floor(val) === val;
|
|
44
|
-
function joinValues(array, separator = " | ") {
|
|
45
|
-
return array.map((val) => typeof val == "string" ? `'${val}'` : val).join(separator);
|
|
46
|
-
}
|
|
47
|
-
util2.joinValues = joinValues, util2.jsonStringifyReplacer = (_, value) => typeof value == "bigint" ? value.toString() : value;
|
|
48
|
-
})(util = exports.util || (exports.util = {}));
|
|
49
|
-
var objectUtil;
|
|
50
|
-
(function(objectUtil2) {
|
|
51
|
-
objectUtil2.mergeShapes = (first, second) => ({
|
|
52
|
-
...first,
|
|
53
|
-
...second
|
|
54
|
-
});
|
|
55
|
-
})(objectUtil = exports.objectUtil || (exports.objectUtil = {}));
|
|
56
|
-
exports.ZodParsedType = util.arrayToEnum([
|
|
57
|
-
"string",
|
|
58
|
-
"nan",
|
|
59
|
-
"number",
|
|
60
|
-
"integer",
|
|
61
|
-
"float",
|
|
62
|
-
"boolean",
|
|
63
|
-
"date",
|
|
64
|
-
"bigint",
|
|
65
|
-
"symbol",
|
|
66
|
-
"function",
|
|
67
|
-
"undefined",
|
|
68
|
-
"null",
|
|
69
|
-
"array",
|
|
70
|
-
"object",
|
|
71
|
-
"unknown",
|
|
72
|
-
"promise",
|
|
73
|
-
"void",
|
|
74
|
-
"never",
|
|
75
|
-
"map",
|
|
76
|
-
"set"
|
|
77
|
-
]);
|
|
78
|
-
var getParsedType = (data) => {
|
|
79
|
-
switch (typeof data) {
|
|
80
|
-
case "undefined":
|
|
81
|
-
return exports.ZodParsedType.undefined;
|
|
82
|
-
case "string":
|
|
83
|
-
return exports.ZodParsedType.string;
|
|
84
|
-
case "number":
|
|
85
|
-
return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
|
|
86
|
-
case "boolean":
|
|
87
|
-
return exports.ZodParsedType.boolean;
|
|
88
|
-
case "function":
|
|
89
|
-
return exports.ZodParsedType.function;
|
|
90
|
-
case "bigint":
|
|
91
|
-
return exports.ZodParsedType.bigint;
|
|
92
|
-
case "symbol":
|
|
93
|
-
return exports.ZodParsedType.symbol;
|
|
94
|
-
case "object":
|
|
95
|
-
return Array.isArray(data) ? exports.ZodParsedType.array : data === null ? exports.ZodParsedType.null : data.then && typeof data.then == "function" && data.catch && typeof data.catch == "function" ? exports.ZodParsedType.promise : typeof Map < "u" && data instanceof Map ? exports.ZodParsedType.map : typeof Set < "u" && data instanceof Set ? exports.ZodParsedType.set : typeof Date < "u" && data instanceof Date ? exports.ZodParsedType.date : exports.ZodParsedType.object;
|
|
96
|
-
default:
|
|
97
|
-
return exports.ZodParsedType.unknown;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
exports.getParsedType = getParsedType;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/ZodError.js
|
|
105
|
-
var require_ZodError = __commonJS({
|
|
106
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/ZodError.js"(exports) {
|
|
107
|
-
"use strict";
|
|
108
|
-
init_cjs_shims();
|
|
109
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
110
|
-
exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
|
|
111
|
-
var util_1 = require_util();
|
|
112
|
-
exports.ZodIssueCode = util_1.util.arrayToEnum([
|
|
113
|
-
"invalid_type",
|
|
114
|
-
"invalid_literal",
|
|
115
|
-
"custom",
|
|
116
|
-
"invalid_union",
|
|
117
|
-
"invalid_union_discriminator",
|
|
118
|
-
"invalid_enum_value",
|
|
119
|
-
"unrecognized_keys",
|
|
120
|
-
"invalid_arguments",
|
|
121
|
-
"invalid_return_type",
|
|
122
|
-
"invalid_date",
|
|
123
|
-
"invalid_string",
|
|
124
|
-
"too_small",
|
|
125
|
-
"too_big",
|
|
126
|
-
"invalid_intersection_types",
|
|
127
|
-
"not_multiple_of",
|
|
128
|
-
"not_finite"
|
|
129
|
-
]);
|
|
130
|
-
var quotelessJson = (obj) => JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
131
|
-
exports.quotelessJson = quotelessJson;
|
|
132
|
-
var ZodError = class extends Error {
|
|
133
|
-
constructor(issues) {
|
|
134
|
-
super(), this.issues = [], this.addIssue = (sub) => {
|
|
135
|
-
this.issues = [...this.issues, sub];
|
|
136
|
-
}, this.addIssues = (subs = []) => {
|
|
137
|
-
this.issues = [...this.issues, ...subs];
|
|
138
|
-
};
|
|
139
|
-
let actualProto = new.target.prototype;
|
|
140
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this, actualProto) : this.__proto__ = actualProto, this.name = "ZodError", this.issues = issues;
|
|
141
|
-
}
|
|
142
|
-
get errors() {
|
|
143
|
-
return this.issues;
|
|
144
|
-
}
|
|
145
|
-
format(_mapper) {
|
|
146
|
-
let mapper = _mapper || function(issue) {
|
|
147
|
-
return issue.message;
|
|
148
|
-
}, fieldErrors = { _errors: [] }, processError = (error) => {
|
|
149
|
-
for (let issue of error.issues)
|
|
150
|
-
if (issue.code === "invalid_union")
|
|
151
|
-
issue.unionErrors.map(processError);
|
|
152
|
-
else if (issue.code === "invalid_return_type")
|
|
153
|
-
processError(issue.returnTypeError);
|
|
154
|
-
else if (issue.code === "invalid_arguments")
|
|
155
|
-
processError(issue.argumentsError);
|
|
156
|
-
else if (issue.path.length === 0)
|
|
157
|
-
fieldErrors._errors.push(mapper(issue));
|
|
158
|
-
else {
|
|
159
|
-
let curr = fieldErrors, i = 0;
|
|
160
|
-
for (; i < issue.path.length; ) {
|
|
161
|
-
let el = issue.path[i];
|
|
162
|
-
i === issue.path.length - 1 ? (curr[el] = curr[el] || { _errors: [] }, curr[el]._errors.push(mapper(issue))) : curr[el] = curr[el] || { _errors: [] }, curr = curr[el], i++;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
return processError(this), fieldErrors;
|
|
167
|
-
}
|
|
168
|
-
toString() {
|
|
169
|
-
return this.message;
|
|
170
|
-
}
|
|
171
|
-
get message() {
|
|
172
|
-
return JSON.stringify(this.issues, util_1.util.jsonStringifyReplacer, 2);
|
|
173
|
-
}
|
|
174
|
-
get isEmpty() {
|
|
175
|
-
return this.issues.length === 0;
|
|
176
|
-
}
|
|
177
|
-
flatten(mapper = (issue) => issue.message) {
|
|
178
|
-
let fieldErrors = {}, formErrors = [];
|
|
179
|
-
for (let sub of this.issues)
|
|
180
|
-
sub.path.length > 0 ? (fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [], fieldErrors[sub.path[0]].push(mapper(sub))) : formErrors.push(mapper(sub));
|
|
181
|
-
return { formErrors, fieldErrors };
|
|
182
|
-
}
|
|
183
|
-
get formErrors() {
|
|
184
|
-
return this.flatten();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
exports.ZodError = ZodError;
|
|
188
|
-
ZodError.create = (issues) => new ZodError(issues);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/locales/en.js
|
|
193
|
-
var require_en = __commonJS({
|
|
194
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/locales/en.js"(exports) {
|
|
195
|
-
"use strict";
|
|
196
|
-
init_cjs_shims();
|
|
197
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
198
|
-
var util_1 = require_util(), ZodError_1 = require_ZodError(), errorMap = (issue, _ctx) => {
|
|
199
|
-
let message;
|
|
200
|
-
switch (issue.code) {
|
|
201
|
-
case ZodError_1.ZodIssueCode.invalid_type:
|
|
202
|
-
issue.received === util_1.ZodParsedType.undefined ? message = "Required" : message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
203
|
-
break;
|
|
204
|
-
case ZodError_1.ZodIssueCode.invalid_literal:
|
|
205
|
-
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_1.util.jsonStringifyReplacer)}`;
|
|
206
|
-
break;
|
|
207
|
-
case ZodError_1.ZodIssueCode.unrecognized_keys:
|
|
208
|
-
message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`;
|
|
209
|
-
break;
|
|
210
|
-
case ZodError_1.ZodIssueCode.invalid_union:
|
|
211
|
-
message = "Invalid input";
|
|
212
|
-
break;
|
|
213
|
-
case ZodError_1.ZodIssueCode.invalid_union_discriminator:
|
|
214
|
-
message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`;
|
|
215
|
-
break;
|
|
216
|
-
case ZodError_1.ZodIssueCode.invalid_enum_value:
|
|
217
|
-
message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
218
|
-
break;
|
|
219
|
-
case ZodError_1.ZodIssueCode.invalid_arguments:
|
|
220
|
-
message = "Invalid function arguments";
|
|
221
|
-
break;
|
|
222
|
-
case ZodError_1.ZodIssueCode.invalid_return_type:
|
|
223
|
-
message = "Invalid function return type";
|
|
224
|
-
break;
|
|
225
|
-
case ZodError_1.ZodIssueCode.invalid_date:
|
|
226
|
-
message = "Invalid date";
|
|
227
|
-
break;
|
|
228
|
-
case ZodError_1.ZodIssueCode.invalid_string:
|
|
229
|
-
typeof issue.validation == "object" ? "includes" in issue.validation ? (message = `Invalid input: must include "${issue.validation.includes}"`, typeof issue.validation.position == "number" && (message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`)) : "startsWith" in issue.validation ? message = `Invalid input: must start with "${issue.validation.startsWith}"` : "endsWith" in issue.validation ? message = `Invalid input: must end with "${issue.validation.endsWith}"` : util_1.util.assertNever(issue.validation) : issue.validation !== "regex" ? message = `Invalid ${issue.validation}` : message = "Invalid";
|
|
230
|
-
break;
|
|
231
|
-
case ZodError_1.ZodIssueCode.too_small:
|
|
232
|
-
issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "more than"} ${issue.minimum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "over"} ${issue.minimum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${issue.minimum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(issue.minimum))}` : message = "Invalid input";
|
|
233
|
-
break;
|
|
234
|
-
case ZodError_1.ZodIssueCode.too_big:
|
|
235
|
-
issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "less than"} ${issue.maximum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "under"} ${issue.maximum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "bigint" ? message = `BigInt must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly" : issue.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(issue.maximum))}` : message = "Invalid input";
|
|
236
|
-
break;
|
|
237
|
-
case ZodError_1.ZodIssueCode.custom:
|
|
238
|
-
message = "Invalid input";
|
|
239
|
-
break;
|
|
240
|
-
case ZodError_1.ZodIssueCode.invalid_intersection_types:
|
|
241
|
-
message = "Intersection results could not be merged";
|
|
242
|
-
break;
|
|
243
|
-
case ZodError_1.ZodIssueCode.not_multiple_of:
|
|
244
|
-
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
245
|
-
break;
|
|
246
|
-
case ZodError_1.ZodIssueCode.not_finite:
|
|
247
|
-
message = "Number must be finite";
|
|
248
|
-
break;
|
|
249
|
-
default:
|
|
250
|
-
message = _ctx.defaultError, util_1.util.assertNever(issue);
|
|
251
|
-
}
|
|
252
|
-
return { message };
|
|
253
|
-
};
|
|
254
|
-
exports.default = errorMap;
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/errors.js
|
|
259
|
-
var require_errors = __commonJS({
|
|
260
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/errors.js"(exports) {
|
|
261
|
-
"use strict";
|
|
262
|
-
init_cjs_shims();
|
|
263
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
264
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
265
|
-
};
|
|
266
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
267
|
-
exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0;
|
|
268
|
-
var en_1 = __importDefault(require_en());
|
|
269
|
-
exports.defaultErrorMap = en_1.default;
|
|
270
|
-
var overrideErrorMap = en_1.default;
|
|
271
|
-
function setErrorMap(map) {
|
|
272
|
-
overrideErrorMap = map;
|
|
273
|
-
}
|
|
274
|
-
exports.setErrorMap = setErrorMap;
|
|
275
|
-
function getErrorMap() {
|
|
276
|
-
return overrideErrorMap;
|
|
277
|
-
}
|
|
278
|
-
exports.getErrorMap = getErrorMap;
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/parseUtil.js
|
|
283
|
-
var require_parseUtil = __commonJS({
|
|
284
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/parseUtil.js"(exports) {
|
|
285
|
-
"use strict";
|
|
286
|
-
init_cjs_shims();
|
|
287
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
288
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
289
|
-
};
|
|
290
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
291
|
-
exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
|
|
292
|
-
var errors_1 = require_errors(), en_1 = __importDefault(require_en()), makeIssue = (params) => {
|
|
293
|
-
let { data, path, errorMaps, issueData } = params, fullPath = [...path, ...issueData.path || []], fullIssue = {
|
|
294
|
-
...issueData,
|
|
295
|
-
path: fullPath
|
|
296
|
-
}, errorMessage = "", maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
297
|
-
for (let map of maps)
|
|
298
|
-
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
299
|
-
return {
|
|
300
|
-
...issueData,
|
|
301
|
-
path: fullPath,
|
|
302
|
-
message: issueData.message || errorMessage
|
|
303
|
-
};
|
|
304
|
-
};
|
|
305
|
-
exports.makeIssue = makeIssue;
|
|
306
|
-
exports.EMPTY_PATH = [];
|
|
307
|
-
function addIssueToContext(ctx, issueData) {
|
|
308
|
-
let issue = (0, exports.makeIssue)({
|
|
309
|
-
issueData,
|
|
310
|
-
data: ctx.data,
|
|
311
|
-
path: ctx.path,
|
|
312
|
-
errorMaps: [
|
|
313
|
-
ctx.common.contextualErrorMap,
|
|
314
|
-
ctx.schemaErrorMap,
|
|
315
|
-
(0, errors_1.getErrorMap)(),
|
|
316
|
-
en_1.default
|
|
317
|
-
].filter((x) => !!x)
|
|
318
|
-
});
|
|
319
|
-
ctx.common.issues.push(issue);
|
|
320
|
-
}
|
|
321
|
-
exports.addIssueToContext = addIssueToContext;
|
|
322
|
-
var ParseStatus = class _ParseStatus {
|
|
323
|
-
constructor() {
|
|
324
|
-
this.value = "valid";
|
|
325
|
-
}
|
|
326
|
-
dirty() {
|
|
327
|
-
this.value === "valid" && (this.value = "dirty");
|
|
328
|
-
}
|
|
329
|
-
abort() {
|
|
330
|
-
this.value !== "aborted" && (this.value = "aborted");
|
|
331
|
-
}
|
|
332
|
-
static mergeArray(status, results) {
|
|
333
|
-
let arrayValue = [];
|
|
334
|
-
for (let s of results) {
|
|
335
|
-
if (s.status === "aborted")
|
|
336
|
-
return exports.INVALID;
|
|
337
|
-
s.status === "dirty" && status.dirty(), arrayValue.push(s.value);
|
|
338
|
-
}
|
|
339
|
-
return { status: status.value, value: arrayValue };
|
|
340
|
-
}
|
|
341
|
-
static async mergeObjectAsync(status, pairs) {
|
|
342
|
-
let syncPairs = [];
|
|
343
|
-
for (let pair of pairs)
|
|
344
|
-
syncPairs.push({
|
|
345
|
-
key: await pair.key,
|
|
346
|
-
value: await pair.value
|
|
347
|
-
});
|
|
348
|
-
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
349
|
-
}
|
|
350
|
-
static mergeObjectSync(status, pairs) {
|
|
351
|
-
let finalObject = {};
|
|
352
|
-
for (let pair of pairs) {
|
|
353
|
-
let { key, value } = pair;
|
|
354
|
-
if (key.status === "aborted" || value.status === "aborted")
|
|
355
|
-
return exports.INVALID;
|
|
356
|
-
key.status === "dirty" && status.dirty(), value.status === "dirty" && status.dirty(), key.value !== "__proto__" && (typeof value.value < "u" || pair.alwaysSet) && (finalObject[key.value] = value.value);
|
|
357
|
-
}
|
|
358
|
-
return { status: status.value, value: finalObject };
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
exports.ParseStatus = ParseStatus;
|
|
362
|
-
exports.INVALID = Object.freeze({
|
|
363
|
-
status: "aborted"
|
|
364
|
-
});
|
|
365
|
-
var DIRTY = (value) => ({ status: "dirty", value });
|
|
366
|
-
exports.DIRTY = DIRTY;
|
|
367
|
-
var OK = (value) => ({ status: "valid", value });
|
|
368
|
-
exports.OK = OK;
|
|
369
|
-
var isAborted = (x) => x.status === "aborted";
|
|
370
|
-
exports.isAborted = isAborted;
|
|
371
|
-
var isDirty = (x) => x.status === "dirty";
|
|
372
|
-
exports.isDirty = isDirty;
|
|
373
|
-
var isValid = (x) => x.status === "valid";
|
|
374
|
-
exports.isValid = isValid;
|
|
375
|
-
var isAsync = (x) => typeof Promise < "u" && x instanceof Promise;
|
|
376
|
-
exports.isAsync = isAsync;
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/typeAliases.js
|
|
381
|
-
var require_typeAliases = __commonJS({
|
|
382
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/typeAliases.js"(exports) {
|
|
383
|
-
"use strict";
|
|
384
|
-
init_cjs_shims();
|
|
385
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/errorUtil.js
|
|
390
|
-
var require_errorUtil = __commonJS({
|
|
391
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/helpers/errorUtil.js"(exports) {
|
|
392
|
-
"use strict";
|
|
393
|
-
init_cjs_shims();
|
|
394
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
395
|
-
exports.errorUtil = void 0;
|
|
396
|
-
var errorUtil;
|
|
397
|
-
(function(errorUtil2) {
|
|
398
|
-
errorUtil2.errToObj = (message) => typeof message == "string" ? { message } : message || {}, errorUtil2.toString = (message) => typeof message == "string" ? message : message?.message;
|
|
399
|
-
})(errorUtil = exports.errorUtil || (exports.errorUtil = {}));
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/types.js
|
|
404
|
-
var require_types = __commonJS({
|
|
405
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/types.js"(exports) {
|
|
406
|
-
"use strict";
|
|
407
|
-
init_cjs_shims();
|
|
408
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
409
|
-
exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
|
|
410
|
-
exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = void 0;
|
|
411
|
-
var errors_1 = require_errors(), errorUtil_1 = require_errorUtil(), parseUtil_1 = require_parseUtil(), util_1 = require_util(), ZodError_1 = require_ZodError(), ParseInputLazyPath = class {
|
|
412
|
-
constructor(parent, value, path, key) {
|
|
413
|
-
this._cachedPath = [], this.parent = parent, this.data = value, this._path = path, this._key = key;
|
|
414
|
-
}
|
|
415
|
-
get path() {
|
|
416
|
-
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
417
|
-
}
|
|
418
|
-
}, handleResult = (ctx, result) => {
|
|
419
|
-
if ((0, parseUtil_1.isValid)(result))
|
|
420
|
-
return { success: !0, data: result.value };
|
|
421
|
-
if (!ctx.common.issues.length)
|
|
422
|
-
throw new Error("Validation failed but no issues detected.");
|
|
423
|
-
return {
|
|
424
|
-
success: !1,
|
|
425
|
-
get error() {
|
|
426
|
-
if (this._error)
|
|
427
|
-
return this._error;
|
|
428
|
-
let error = new ZodError_1.ZodError(ctx.common.issues);
|
|
429
|
-
return this._error = error, this._error;
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
};
|
|
433
|
-
function processCreateParams(params) {
|
|
434
|
-
if (!params)
|
|
435
|
-
return {};
|
|
436
|
-
let { errorMap, invalid_type_error, required_error, description } = params;
|
|
437
|
-
if (errorMap && (invalid_type_error || required_error))
|
|
438
|
-
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
439
|
-
return errorMap ? { errorMap, description } : { errorMap: (iss, ctx) => iss.code !== "invalid_type" ? { message: ctx.defaultError } : typeof ctx.data > "u" ? { message: required_error ?? ctx.defaultError } : { message: invalid_type_error ?? ctx.defaultError }, description };
|
|
440
|
-
}
|
|
441
|
-
var ZodType = class {
|
|
442
|
-
constructor(def) {
|
|
443
|
-
this.spa = this.safeParseAsync, this._def = def, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
|
|
444
|
-
}
|
|
445
|
-
get description() {
|
|
446
|
-
return this._def.description;
|
|
447
|
-
}
|
|
448
|
-
_getType(input) {
|
|
449
|
-
return (0, util_1.getParsedType)(input.data);
|
|
450
|
-
}
|
|
451
|
-
_getOrReturnCtx(input, ctx) {
|
|
452
|
-
return ctx || {
|
|
453
|
-
common: input.parent.common,
|
|
454
|
-
data: input.data,
|
|
455
|
-
parsedType: (0, util_1.getParsedType)(input.data),
|
|
456
|
-
schemaErrorMap: this._def.errorMap,
|
|
457
|
-
path: input.path,
|
|
458
|
-
parent: input.parent
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
_processInputParams(input) {
|
|
462
|
-
return {
|
|
463
|
-
status: new parseUtil_1.ParseStatus(),
|
|
464
|
-
ctx: {
|
|
465
|
-
common: input.parent.common,
|
|
466
|
-
data: input.data,
|
|
467
|
-
parsedType: (0, util_1.getParsedType)(input.data),
|
|
468
|
-
schemaErrorMap: this._def.errorMap,
|
|
469
|
-
path: input.path,
|
|
470
|
-
parent: input.parent
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
_parseSync(input) {
|
|
475
|
-
let result = this._parse(input);
|
|
476
|
-
if ((0, parseUtil_1.isAsync)(result))
|
|
477
|
-
throw new Error("Synchronous parse encountered promise.");
|
|
478
|
-
return result;
|
|
479
|
-
}
|
|
480
|
-
_parseAsync(input) {
|
|
481
|
-
let result = this._parse(input);
|
|
482
|
-
return Promise.resolve(result);
|
|
483
|
-
}
|
|
484
|
-
parse(data, params) {
|
|
485
|
-
let result = this.safeParse(data, params);
|
|
486
|
-
if (result.success)
|
|
487
|
-
return result.data;
|
|
488
|
-
throw result.error;
|
|
489
|
-
}
|
|
490
|
-
safeParse(data, params) {
|
|
491
|
-
var _a;
|
|
492
|
-
let ctx = {
|
|
493
|
-
common: {
|
|
494
|
-
issues: [],
|
|
495
|
-
async: (_a = params?.async) !== null && _a !== void 0 ? _a : !1,
|
|
496
|
-
contextualErrorMap: params?.errorMap
|
|
497
|
-
},
|
|
498
|
-
path: params?.path || [],
|
|
499
|
-
schemaErrorMap: this._def.errorMap,
|
|
500
|
-
parent: null,
|
|
501
|
-
data,
|
|
502
|
-
parsedType: (0, util_1.getParsedType)(data)
|
|
503
|
-
}, result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
504
|
-
return handleResult(ctx, result);
|
|
505
|
-
}
|
|
506
|
-
async parseAsync(data, params) {
|
|
507
|
-
let result = await this.safeParseAsync(data, params);
|
|
508
|
-
if (result.success)
|
|
509
|
-
return result.data;
|
|
510
|
-
throw result.error;
|
|
511
|
-
}
|
|
512
|
-
async safeParseAsync(data, params) {
|
|
513
|
-
let ctx = {
|
|
514
|
-
common: {
|
|
515
|
-
issues: [],
|
|
516
|
-
contextualErrorMap: params?.errorMap,
|
|
517
|
-
async: !0
|
|
518
|
-
},
|
|
519
|
-
path: params?.path || [],
|
|
520
|
-
schemaErrorMap: this._def.errorMap,
|
|
521
|
-
parent: null,
|
|
522
|
-
data,
|
|
523
|
-
parsedType: (0, util_1.getParsedType)(data)
|
|
524
|
-
}, maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }), result = await ((0, parseUtil_1.isAsync)(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
525
|
-
return handleResult(ctx, result);
|
|
526
|
-
}
|
|
527
|
-
refine(check, message) {
|
|
528
|
-
let getIssueProperties = (val) => typeof message == "string" || typeof message > "u" ? { message } : typeof message == "function" ? message(val) : message;
|
|
529
|
-
return this._refinement((val, ctx) => {
|
|
530
|
-
let result = check(val), setError = () => ctx.addIssue({
|
|
531
|
-
code: ZodError_1.ZodIssueCode.custom,
|
|
532
|
-
...getIssueProperties(val)
|
|
533
|
-
});
|
|
534
|
-
return typeof Promise < "u" && result instanceof Promise ? result.then((data) => data ? !0 : (setError(), !1)) : result ? !0 : (setError(), !1);
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
refinement(check, refinementData) {
|
|
538
|
-
return this._refinement((val, ctx) => check(val) ? !0 : (ctx.addIssue(typeof refinementData == "function" ? refinementData(val, ctx) : refinementData), !1));
|
|
539
|
-
}
|
|
540
|
-
_refinement(refinement) {
|
|
541
|
-
return new ZodEffects({
|
|
542
|
-
schema: this,
|
|
543
|
-
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
544
|
-
effect: { type: "refinement", refinement }
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
superRefine(refinement) {
|
|
548
|
-
return this._refinement(refinement);
|
|
549
|
-
}
|
|
550
|
-
optional() {
|
|
551
|
-
return ZodOptional.create(this, this._def);
|
|
552
|
-
}
|
|
553
|
-
nullable() {
|
|
554
|
-
return ZodNullable.create(this, this._def);
|
|
555
|
-
}
|
|
556
|
-
nullish() {
|
|
557
|
-
return this.nullable().optional();
|
|
558
|
-
}
|
|
559
|
-
array() {
|
|
560
|
-
return ZodArray.create(this, this._def);
|
|
561
|
-
}
|
|
562
|
-
promise() {
|
|
563
|
-
return ZodPromise.create(this, this._def);
|
|
564
|
-
}
|
|
565
|
-
or(option) {
|
|
566
|
-
return ZodUnion.create([this, option], this._def);
|
|
567
|
-
}
|
|
568
|
-
and(incoming) {
|
|
569
|
-
return ZodIntersection.create(this, incoming, this._def);
|
|
570
|
-
}
|
|
571
|
-
transform(transform) {
|
|
572
|
-
return new ZodEffects({
|
|
573
|
-
...processCreateParams(this._def),
|
|
574
|
-
schema: this,
|
|
575
|
-
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
576
|
-
effect: { type: "transform", transform }
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
default(def) {
|
|
580
|
-
let defaultValueFunc = typeof def == "function" ? def : () => def;
|
|
581
|
-
return new ZodDefault({
|
|
582
|
-
...processCreateParams(this._def),
|
|
583
|
-
innerType: this,
|
|
584
|
-
defaultValue: defaultValueFunc,
|
|
585
|
-
typeName: ZodFirstPartyTypeKind.ZodDefault
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
brand() {
|
|
589
|
-
return new ZodBranded({
|
|
590
|
-
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
591
|
-
type: this,
|
|
592
|
-
...processCreateParams(this._def)
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
catch(def) {
|
|
596
|
-
let catchValueFunc = typeof def == "function" ? def : () => def;
|
|
597
|
-
return new ZodCatch({
|
|
598
|
-
...processCreateParams(this._def),
|
|
599
|
-
innerType: this,
|
|
600
|
-
catchValue: catchValueFunc,
|
|
601
|
-
typeName: ZodFirstPartyTypeKind.ZodCatch
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
describe(description) {
|
|
605
|
-
let This = this.constructor;
|
|
606
|
-
return new This({
|
|
607
|
-
...this._def,
|
|
608
|
-
description
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
pipe(target) {
|
|
612
|
-
return ZodPipeline.create(this, target);
|
|
613
|
-
}
|
|
614
|
-
readonly() {
|
|
615
|
-
return ZodReadonly.create(this);
|
|
616
|
-
}
|
|
617
|
-
isOptional() {
|
|
618
|
-
return this.safeParse(void 0).success;
|
|
619
|
-
}
|
|
620
|
-
isNullable() {
|
|
621
|
-
return this.safeParse(null).success;
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
exports.ZodType = ZodType;
|
|
625
|
-
exports.Schema = ZodType;
|
|
626
|
-
exports.ZodSchema = ZodType;
|
|
627
|
-
var cuidRegex = /^c[^\s-]{8,}$/i, cuid2Regex = /^[a-z][a-z0-9]*$/, ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/, 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, emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u, ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/, ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, datetimeRegex = (args) => args.precision ? args.offset ? new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`) : new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`) : args.precision === 0 ? args.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$") : args.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");
|
|
628
|
-
function isValidIP(ip, version) {
|
|
629
|
-
return !!((version === "v4" || !version) && ipv4Regex.test(ip) || (version === "v6" || !version) && ipv6Regex.test(ip));
|
|
630
|
-
}
|
|
631
|
-
var ZodString = class _ZodString extends ZodType {
|
|
632
|
-
constructor() {
|
|
633
|
-
super(...arguments), this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
|
634
|
-
validation,
|
|
635
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
636
|
-
...errorUtil_1.errorUtil.errToObj(message)
|
|
637
|
-
}), this.nonempty = (message) => this.min(1, errorUtil_1.errorUtil.errToObj(message)), this.trim = () => new _ZodString({
|
|
638
|
-
...this._def,
|
|
639
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
640
|
-
}), this.toLowerCase = () => new _ZodString({
|
|
641
|
-
...this._def,
|
|
642
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
643
|
-
}), this.toUpperCase = () => new _ZodString({
|
|
644
|
-
...this._def,
|
|
645
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
_parse(input) {
|
|
649
|
-
if (this._def.coerce && (input.data = String(input.data)), this._getType(input) !== util_1.ZodParsedType.string) {
|
|
650
|
-
let ctx2 = this._getOrReturnCtx(input);
|
|
651
|
-
return (0, parseUtil_1.addIssueToContext)(ctx2, {
|
|
652
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
653
|
-
expected: util_1.ZodParsedType.string,
|
|
654
|
-
received: ctx2.parsedType
|
|
655
|
-
}), parseUtil_1.INVALID;
|
|
656
|
-
}
|
|
657
|
-
let status = new parseUtil_1.ParseStatus(), ctx;
|
|
658
|
-
for (let check of this._def.checks)
|
|
659
|
-
if (check.kind === "min")
|
|
660
|
-
input.data.length < check.value && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
661
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
662
|
-
minimum: check.value,
|
|
663
|
-
type: "string",
|
|
664
|
-
inclusive: !0,
|
|
665
|
-
exact: !1,
|
|
666
|
-
message: check.message
|
|
667
|
-
}), status.dirty());
|
|
668
|
-
else if (check.kind === "max")
|
|
669
|
-
input.data.length > check.value && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
670
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
671
|
-
maximum: check.value,
|
|
672
|
-
type: "string",
|
|
673
|
-
inclusive: !0,
|
|
674
|
-
exact: !1,
|
|
675
|
-
message: check.message
|
|
676
|
-
}), status.dirty());
|
|
677
|
-
else if (check.kind === "length") {
|
|
678
|
-
let tooBig = input.data.length > check.value, tooSmall = input.data.length < check.value;
|
|
679
|
-
(tooBig || tooSmall) && (ctx = this._getOrReturnCtx(input, ctx), tooBig ? (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
680
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
681
|
-
maximum: check.value,
|
|
682
|
-
type: "string",
|
|
683
|
-
inclusive: !0,
|
|
684
|
-
exact: !0,
|
|
685
|
-
message: check.message
|
|
686
|
-
}) : tooSmall && (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
687
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
688
|
-
minimum: check.value,
|
|
689
|
-
type: "string",
|
|
690
|
-
inclusive: !0,
|
|
691
|
-
exact: !0,
|
|
692
|
-
message: check.message
|
|
693
|
-
}), status.dirty());
|
|
694
|
-
} else if (check.kind === "email")
|
|
695
|
-
emailRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
696
|
-
validation: "email",
|
|
697
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
698
|
-
message: check.message
|
|
699
|
-
}), status.dirty());
|
|
700
|
-
else if (check.kind === "emoji")
|
|
701
|
-
emojiRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
702
|
-
validation: "emoji",
|
|
703
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
704
|
-
message: check.message
|
|
705
|
-
}), status.dirty());
|
|
706
|
-
else if (check.kind === "uuid")
|
|
707
|
-
uuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
708
|
-
validation: "uuid",
|
|
709
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
710
|
-
message: check.message
|
|
711
|
-
}), status.dirty());
|
|
712
|
-
else if (check.kind === "cuid")
|
|
713
|
-
cuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
714
|
-
validation: "cuid",
|
|
715
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
716
|
-
message: check.message
|
|
717
|
-
}), status.dirty());
|
|
718
|
-
else if (check.kind === "cuid2")
|
|
719
|
-
cuid2Regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
720
|
-
validation: "cuid2",
|
|
721
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
722
|
-
message: check.message
|
|
723
|
-
}), status.dirty());
|
|
724
|
-
else if (check.kind === "ulid")
|
|
725
|
-
ulidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
726
|
-
validation: "ulid",
|
|
727
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
728
|
-
message: check.message
|
|
729
|
-
}), status.dirty());
|
|
730
|
-
else if (check.kind === "url")
|
|
731
|
-
try {
|
|
732
|
-
new URL(input.data);
|
|
733
|
-
} catch {
|
|
734
|
-
ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
735
|
-
validation: "url",
|
|
736
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
737
|
-
message: check.message
|
|
738
|
-
}), status.dirty();
|
|
739
|
-
}
|
|
740
|
-
else
|
|
741
|
-
check.kind === "regex" ? (check.regex.lastIndex = 0, check.regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
742
|
-
validation: "regex",
|
|
743
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
744
|
-
message: check.message
|
|
745
|
-
}), status.dirty())) : check.kind === "trim" ? input.data = input.data.trim() : check.kind === "includes" ? input.data.includes(check.value, check.position) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
746
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
747
|
-
validation: { includes: check.value, position: check.position },
|
|
748
|
-
message: check.message
|
|
749
|
-
}), status.dirty()) : check.kind === "toLowerCase" ? input.data = input.data.toLowerCase() : check.kind === "toUpperCase" ? input.data = input.data.toUpperCase() : check.kind === "startsWith" ? input.data.startsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
750
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
751
|
-
validation: { startsWith: check.value },
|
|
752
|
-
message: check.message
|
|
753
|
-
}), status.dirty()) : check.kind === "endsWith" ? input.data.endsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
754
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
755
|
-
validation: { endsWith: check.value },
|
|
756
|
-
message: check.message
|
|
757
|
-
}), status.dirty()) : check.kind === "datetime" ? datetimeRegex(check).test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
758
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
759
|
-
validation: "datetime",
|
|
760
|
-
message: check.message
|
|
761
|
-
}), status.dirty()) : check.kind === "ip" ? isValidIP(input.data, check.version) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
762
|
-
validation: "ip",
|
|
763
|
-
code: ZodError_1.ZodIssueCode.invalid_string,
|
|
764
|
-
message: check.message
|
|
765
|
-
}), status.dirty()) : util_1.util.assertNever(check);
|
|
766
|
-
return { status: status.value, value: input.data };
|
|
767
|
-
}
|
|
768
|
-
_addCheck(check) {
|
|
769
|
-
return new _ZodString({
|
|
770
|
-
...this._def,
|
|
771
|
-
checks: [...this._def.checks, check]
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
email(message) {
|
|
775
|
-
return this._addCheck({ kind: "email", ...errorUtil_1.errorUtil.errToObj(message) });
|
|
776
|
-
}
|
|
777
|
-
url(message) {
|
|
778
|
-
return this._addCheck({ kind: "url", ...errorUtil_1.errorUtil.errToObj(message) });
|
|
779
|
-
}
|
|
780
|
-
emoji(message) {
|
|
781
|
-
return this._addCheck({ kind: "emoji", ...errorUtil_1.errorUtil.errToObj(message) });
|
|
782
|
-
}
|
|
783
|
-
uuid(message) {
|
|
784
|
-
return this._addCheck({ kind: "uuid", ...errorUtil_1.errorUtil.errToObj(message) });
|
|
785
|
-
}
|
|
786
|
-
cuid(message) {
|
|
787
|
-
return this._addCheck({ kind: "cuid", ...errorUtil_1.errorUtil.errToObj(message) });
|
|
788
|
-
}
|
|
789
|
-
cuid2(message) {
|
|
790
|
-
return this._addCheck({ kind: "cuid2", ...errorUtil_1.errorUtil.errToObj(message) });
|
|
791
|
-
}
|
|
792
|
-
ulid(message) {
|
|
793
|
-
return this._addCheck({ kind: "ulid", ...errorUtil_1.errorUtil.errToObj(message) });
|
|
794
|
-
}
|
|
795
|
-
ip(options) {
|
|
796
|
-
return this._addCheck({ kind: "ip", ...errorUtil_1.errorUtil.errToObj(options) });
|
|
797
|
-
}
|
|
798
|
-
datetime(options) {
|
|
799
|
-
var _a;
|
|
800
|
-
return typeof options == "string" ? this._addCheck({
|
|
801
|
-
kind: "datetime",
|
|
802
|
-
precision: null,
|
|
803
|
-
offset: !1,
|
|
804
|
-
message: options
|
|
805
|
-
}) : this._addCheck({
|
|
806
|
-
kind: "datetime",
|
|
807
|
-
precision: typeof options?.precision > "u" ? null : options?.precision,
|
|
808
|
-
offset: (_a = options?.offset) !== null && _a !== void 0 ? _a : !1,
|
|
809
|
-
...errorUtil_1.errorUtil.errToObj(options?.message)
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
regex(regex, message) {
|
|
813
|
-
return this._addCheck({
|
|
814
|
-
kind: "regex",
|
|
815
|
-
regex,
|
|
816
|
-
...errorUtil_1.errorUtil.errToObj(message)
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
includes(value, options) {
|
|
820
|
-
return this._addCheck({
|
|
821
|
-
kind: "includes",
|
|
822
|
-
value,
|
|
823
|
-
position: options?.position,
|
|
824
|
-
...errorUtil_1.errorUtil.errToObj(options?.message)
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
|
-
startsWith(value, message) {
|
|
828
|
-
return this._addCheck({
|
|
829
|
-
kind: "startsWith",
|
|
830
|
-
value,
|
|
831
|
-
...errorUtil_1.errorUtil.errToObj(message)
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
endsWith(value, message) {
|
|
835
|
-
return this._addCheck({
|
|
836
|
-
kind: "endsWith",
|
|
837
|
-
value,
|
|
838
|
-
...errorUtil_1.errorUtil.errToObj(message)
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
min(minLength, message) {
|
|
842
|
-
return this._addCheck({
|
|
843
|
-
kind: "min",
|
|
844
|
-
value: minLength,
|
|
845
|
-
...errorUtil_1.errorUtil.errToObj(message)
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
max(maxLength, message) {
|
|
849
|
-
return this._addCheck({
|
|
850
|
-
kind: "max",
|
|
851
|
-
value: maxLength,
|
|
852
|
-
...errorUtil_1.errorUtil.errToObj(message)
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
length(len, message) {
|
|
856
|
-
return this._addCheck({
|
|
857
|
-
kind: "length",
|
|
858
|
-
value: len,
|
|
859
|
-
...errorUtil_1.errorUtil.errToObj(message)
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
get isDatetime() {
|
|
863
|
-
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
864
|
-
}
|
|
865
|
-
get isEmail() {
|
|
866
|
-
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
867
|
-
}
|
|
868
|
-
get isURL() {
|
|
869
|
-
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
870
|
-
}
|
|
871
|
-
get isEmoji() {
|
|
872
|
-
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
873
|
-
}
|
|
874
|
-
get isUUID() {
|
|
875
|
-
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
876
|
-
}
|
|
877
|
-
get isCUID() {
|
|
878
|
-
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
879
|
-
}
|
|
880
|
-
get isCUID2() {
|
|
881
|
-
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
882
|
-
}
|
|
883
|
-
get isULID() {
|
|
884
|
-
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
885
|
-
}
|
|
886
|
-
get isIP() {
|
|
887
|
-
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
888
|
-
}
|
|
889
|
-
get minLength() {
|
|
890
|
-
let min = null;
|
|
891
|
-
for (let ch of this._def.checks)
|
|
892
|
-
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
893
|
-
return min;
|
|
894
|
-
}
|
|
895
|
-
get maxLength() {
|
|
896
|
-
let max = null;
|
|
897
|
-
for (let ch of this._def.checks)
|
|
898
|
-
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
899
|
-
return max;
|
|
900
|
-
}
|
|
901
|
-
};
|
|
902
|
-
exports.ZodString = ZodString;
|
|
903
|
-
ZodString.create = (params) => {
|
|
904
|
-
var _a;
|
|
905
|
-
return new ZodString({
|
|
906
|
-
checks: [],
|
|
907
|
-
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
908
|
-
coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1,
|
|
909
|
-
...processCreateParams(params)
|
|
910
|
-
});
|
|
911
|
-
};
|
|
912
|
-
function floatSafeRemainder(val, step) {
|
|
913
|
-
let valDecCount = (val.toString().split(".")[1] || "").length, stepDecCount = (step.toString().split(".")[1] || "").length, decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount, valInt = parseInt(val.toFixed(decCount).replace(".", "")), stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
914
|
-
return valInt % stepInt / Math.pow(10, decCount);
|
|
915
|
-
}
|
|
916
|
-
var ZodNumber = class _ZodNumber extends ZodType {
|
|
917
|
-
constructor() {
|
|
918
|
-
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
919
|
-
}
|
|
920
|
-
_parse(input) {
|
|
921
|
-
if (this._def.coerce && (input.data = Number(input.data)), this._getType(input) !== util_1.ZodParsedType.number) {
|
|
922
|
-
let ctx2 = this._getOrReturnCtx(input);
|
|
923
|
-
return (0, parseUtil_1.addIssueToContext)(ctx2, {
|
|
924
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
925
|
-
expected: util_1.ZodParsedType.number,
|
|
926
|
-
received: ctx2.parsedType
|
|
927
|
-
}), parseUtil_1.INVALID;
|
|
928
|
-
}
|
|
929
|
-
let ctx, status = new parseUtil_1.ParseStatus();
|
|
930
|
-
for (let check of this._def.checks)
|
|
931
|
-
check.kind === "int" ? util_1.util.isInteger(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
932
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
933
|
-
expected: "integer",
|
|
934
|
-
received: "float",
|
|
935
|
-
message: check.message
|
|
936
|
-
}), status.dirty()) : check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
937
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
938
|
-
minimum: check.value,
|
|
939
|
-
type: "number",
|
|
940
|
-
inclusive: check.inclusive,
|
|
941
|
-
exact: !1,
|
|
942
|
-
message: check.message
|
|
943
|
-
}), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
944
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
945
|
-
maximum: check.value,
|
|
946
|
-
type: "number",
|
|
947
|
-
inclusive: check.inclusive,
|
|
948
|
-
exact: !1,
|
|
949
|
-
message: check.message
|
|
950
|
-
}), status.dirty()) : check.kind === "multipleOf" ? floatSafeRemainder(input.data, check.value) !== 0 && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
951
|
-
code: ZodError_1.ZodIssueCode.not_multiple_of,
|
|
952
|
-
multipleOf: check.value,
|
|
953
|
-
message: check.message
|
|
954
|
-
}), status.dirty()) : check.kind === "finite" ? Number.isFinite(input.data) || (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
955
|
-
code: ZodError_1.ZodIssueCode.not_finite,
|
|
956
|
-
message: check.message
|
|
957
|
-
}), status.dirty()) : util_1.util.assertNever(check);
|
|
958
|
-
return { status: status.value, value: input.data };
|
|
959
|
-
}
|
|
960
|
-
gte(value, message) {
|
|
961
|
-
return this.setLimit("min", value, !0, errorUtil_1.errorUtil.toString(message));
|
|
962
|
-
}
|
|
963
|
-
gt(value, message) {
|
|
964
|
-
return this.setLimit("min", value, !1, errorUtil_1.errorUtil.toString(message));
|
|
965
|
-
}
|
|
966
|
-
lte(value, message) {
|
|
967
|
-
return this.setLimit("max", value, !0, errorUtil_1.errorUtil.toString(message));
|
|
968
|
-
}
|
|
969
|
-
lt(value, message) {
|
|
970
|
-
return this.setLimit("max", value, !1, errorUtil_1.errorUtil.toString(message));
|
|
971
|
-
}
|
|
972
|
-
setLimit(kind, value, inclusive, message) {
|
|
973
|
-
return new _ZodNumber({
|
|
974
|
-
...this._def,
|
|
975
|
-
checks: [
|
|
976
|
-
...this._def.checks,
|
|
977
|
-
{
|
|
978
|
-
kind,
|
|
979
|
-
value,
|
|
980
|
-
inclusive,
|
|
981
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
982
|
-
}
|
|
983
|
-
]
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
_addCheck(check) {
|
|
987
|
-
return new _ZodNumber({
|
|
988
|
-
...this._def,
|
|
989
|
-
checks: [...this._def.checks, check]
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
int(message) {
|
|
993
|
-
return this._addCheck({
|
|
994
|
-
kind: "int",
|
|
995
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
positive(message) {
|
|
999
|
-
return this._addCheck({
|
|
1000
|
-
kind: "min",
|
|
1001
|
-
value: 0,
|
|
1002
|
-
inclusive: !1,
|
|
1003
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
negative(message) {
|
|
1007
|
-
return this._addCheck({
|
|
1008
|
-
kind: "max",
|
|
1009
|
-
value: 0,
|
|
1010
|
-
inclusive: !1,
|
|
1011
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
nonpositive(message) {
|
|
1015
|
-
return this._addCheck({
|
|
1016
|
-
kind: "max",
|
|
1017
|
-
value: 0,
|
|
1018
|
-
inclusive: !0,
|
|
1019
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
nonnegative(message) {
|
|
1023
|
-
return this._addCheck({
|
|
1024
|
-
kind: "min",
|
|
1025
|
-
value: 0,
|
|
1026
|
-
inclusive: !0,
|
|
1027
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
multipleOf(value, message) {
|
|
1031
|
-
return this._addCheck({
|
|
1032
|
-
kind: "multipleOf",
|
|
1033
|
-
value,
|
|
1034
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
finite(message) {
|
|
1038
|
-
return this._addCheck({
|
|
1039
|
-
kind: "finite",
|
|
1040
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1041
|
-
});
|
|
1042
|
-
}
|
|
1043
|
-
safe(message) {
|
|
1044
|
-
return this._addCheck({
|
|
1045
|
-
kind: "min",
|
|
1046
|
-
inclusive: !0,
|
|
1047
|
-
value: Number.MIN_SAFE_INTEGER,
|
|
1048
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1049
|
-
})._addCheck({
|
|
1050
|
-
kind: "max",
|
|
1051
|
-
inclusive: !0,
|
|
1052
|
-
value: Number.MAX_SAFE_INTEGER,
|
|
1053
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
get minValue() {
|
|
1057
|
-
let min = null;
|
|
1058
|
-
for (let ch of this._def.checks)
|
|
1059
|
-
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
1060
|
-
return min;
|
|
1061
|
-
}
|
|
1062
|
-
get maxValue() {
|
|
1063
|
-
let max = null;
|
|
1064
|
-
for (let ch of this._def.checks)
|
|
1065
|
-
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
1066
|
-
return max;
|
|
1067
|
-
}
|
|
1068
|
-
get isInt() {
|
|
1069
|
-
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util_1.util.isInteger(ch.value));
|
|
1070
|
-
}
|
|
1071
|
-
get isFinite() {
|
|
1072
|
-
let max = null, min = null;
|
|
1073
|
-
for (let ch of this._def.checks) {
|
|
1074
|
-
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf")
|
|
1075
|
-
return !0;
|
|
1076
|
-
ch.kind === "min" ? (min === null || ch.value > min) && (min = ch.value) : ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
1077
|
-
}
|
|
1078
|
-
return Number.isFinite(min) && Number.isFinite(max);
|
|
1079
|
-
}
|
|
1080
|
-
};
|
|
1081
|
-
exports.ZodNumber = ZodNumber;
|
|
1082
|
-
ZodNumber.create = (params) => new ZodNumber({
|
|
1083
|
-
checks: [],
|
|
1084
|
-
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1085
|
-
coerce: params?.coerce || !1,
|
|
1086
|
-
...processCreateParams(params)
|
|
1087
|
-
});
|
|
1088
|
-
var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
1089
|
-
constructor() {
|
|
1090
|
-
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1091
|
-
}
|
|
1092
|
-
_parse(input) {
|
|
1093
|
-
if (this._def.coerce && (input.data = BigInt(input.data)), this._getType(input) !== util_1.ZodParsedType.bigint) {
|
|
1094
|
-
let ctx2 = this._getOrReturnCtx(input);
|
|
1095
|
-
return (0, parseUtil_1.addIssueToContext)(ctx2, {
|
|
1096
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1097
|
-
expected: util_1.ZodParsedType.bigint,
|
|
1098
|
-
received: ctx2.parsedType
|
|
1099
|
-
}), parseUtil_1.INVALID;
|
|
1100
|
-
}
|
|
1101
|
-
let ctx, status = new parseUtil_1.ParseStatus();
|
|
1102
|
-
for (let check of this._def.checks)
|
|
1103
|
-
check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1104
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
1105
|
-
type: "bigint",
|
|
1106
|
-
minimum: check.value,
|
|
1107
|
-
inclusive: check.inclusive,
|
|
1108
|
-
message: check.message
|
|
1109
|
-
}), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1110
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
1111
|
-
type: "bigint",
|
|
1112
|
-
maximum: check.value,
|
|
1113
|
-
inclusive: check.inclusive,
|
|
1114
|
-
message: check.message
|
|
1115
|
-
}), status.dirty()) : check.kind === "multipleOf" ? input.data % check.value !== BigInt(0) && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1116
|
-
code: ZodError_1.ZodIssueCode.not_multiple_of,
|
|
1117
|
-
multipleOf: check.value,
|
|
1118
|
-
message: check.message
|
|
1119
|
-
}), status.dirty()) : util_1.util.assertNever(check);
|
|
1120
|
-
return { status: status.value, value: input.data };
|
|
1121
|
-
}
|
|
1122
|
-
gte(value, message) {
|
|
1123
|
-
return this.setLimit("min", value, !0, errorUtil_1.errorUtil.toString(message));
|
|
1124
|
-
}
|
|
1125
|
-
gt(value, message) {
|
|
1126
|
-
return this.setLimit("min", value, !1, errorUtil_1.errorUtil.toString(message));
|
|
1127
|
-
}
|
|
1128
|
-
lte(value, message) {
|
|
1129
|
-
return this.setLimit("max", value, !0, errorUtil_1.errorUtil.toString(message));
|
|
1130
|
-
}
|
|
1131
|
-
lt(value, message) {
|
|
1132
|
-
return this.setLimit("max", value, !1, errorUtil_1.errorUtil.toString(message));
|
|
1133
|
-
}
|
|
1134
|
-
setLimit(kind, value, inclusive, message) {
|
|
1135
|
-
return new _ZodBigInt({
|
|
1136
|
-
...this._def,
|
|
1137
|
-
checks: [
|
|
1138
|
-
...this._def.checks,
|
|
1139
|
-
{
|
|
1140
|
-
kind,
|
|
1141
|
-
value,
|
|
1142
|
-
inclusive,
|
|
1143
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1144
|
-
}
|
|
1145
|
-
]
|
|
1146
|
-
});
|
|
1147
|
-
}
|
|
1148
|
-
_addCheck(check) {
|
|
1149
|
-
return new _ZodBigInt({
|
|
1150
|
-
...this._def,
|
|
1151
|
-
checks: [...this._def.checks, check]
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
positive(message) {
|
|
1155
|
-
return this._addCheck({
|
|
1156
|
-
kind: "min",
|
|
1157
|
-
value: BigInt(0),
|
|
1158
|
-
inclusive: !1,
|
|
1159
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
negative(message) {
|
|
1163
|
-
return this._addCheck({
|
|
1164
|
-
kind: "max",
|
|
1165
|
-
value: BigInt(0),
|
|
1166
|
-
inclusive: !1,
|
|
1167
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
nonpositive(message) {
|
|
1171
|
-
return this._addCheck({
|
|
1172
|
-
kind: "max",
|
|
1173
|
-
value: BigInt(0),
|
|
1174
|
-
inclusive: !0,
|
|
1175
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1176
|
-
});
|
|
1177
|
-
}
|
|
1178
|
-
nonnegative(message) {
|
|
1179
|
-
return this._addCheck({
|
|
1180
|
-
kind: "min",
|
|
1181
|
-
value: BigInt(0),
|
|
1182
|
-
inclusive: !0,
|
|
1183
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1184
|
-
});
|
|
1185
|
-
}
|
|
1186
|
-
multipleOf(value, message) {
|
|
1187
|
-
return this._addCheck({
|
|
1188
|
-
kind: "multipleOf",
|
|
1189
|
-
value,
|
|
1190
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
|
-
get minValue() {
|
|
1194
|
-
let min = null;
|
|
1195
|
-
for (let ch of this._def.checks)
|
|
1196
|
-
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
1197
|
-
return min;
|
|
1198
|
-
}
|
|
1199
|
-
get maxValue() {
|
|
1200
|
-
let max = null;
|
|
1201
|
-
for (let ch of this._def.checks)
|
|
1202
|
-
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
1203
|
-
return max;
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
exports.ZodBigInt = ZodBigInt;
|
|
1207
|
-
ZodBigInt.create = (params) => {
|
|
1208
|
-
var _a;
|
|
1209
|
-
return new ZodBigInt({
|
|
1210
|
-
checks: [],
|
|
1211
|
-
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
1212
|
-
coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1,
|
|
1213
|
-
...processCreateParams(params)
|
|
1214
|
-
});
|
|
1215
|
-
};
|
|
1216
|
-
var ZodBoolean = class extends ZodType {
|
|
1217
|
-
_parse(input) {
|
|
1218
|
-
if (this._def.coerce && (input.data = !!input.data), this._getType(input) !== util_1.ZodParsedType.boolean) {
|
|
1219
|
-
let ctx = this._getOrReturnCtx(input);
|
|
1220
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1221
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1222
|
-
expected: util_1.ZodParsedType.boolean,
|
|
1223
|
-
received: ctx.parsedType
|
|
1224
|
-
}), parseUtil_1.INVALID;
|
|
1225
|
-
}
|
|
1226
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
exports.ZodBoolean = ZodBoolean;
|
|
1230
|
-
ZodBoolean.create = (params) => new ZodBoolean({
|
|
1231
|
-
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
1232
|
-
coerce: params?.coerce || !1,
|
|
1233
|
-
...processCreateParams(params)
|
|
1234
|
-
});
|
|
1235
|
-
var ZodDate = class _ZodDate extends ZodType {
|
|
1236
|
-
_parse(input) {
|
|
1237
|
-
if (this._def.coerce && (input.data = new Date(input.data)), this._getType(input) !== util_1.ZodParsedType.date) {
|
|
1238
|
-
let ctx2 = this._getOrReturnCtx(input);
|
|
1239
|
-
return (0, parseUtil_1.addIssueToContext)(ctx2, {
|
|
1240
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1241
|
-
expected: util_1.ZodParsedType.date,
|
|
1242
|
-
received: ctx2.parsedType
|
|
1243
|
-
}), parseUtil_1.INVALID;
|
|
1244
|
-
}
|
|
1245
|
-
if (isNaN(input.data.getTime())) {
|
|
1246
|
-
let ctx2 = this._getOrReturnCtx(input);
|
|
1247
|
-
return (0, parseUtil_1.addIssueToContext)(ctx2, {
|
|
1248
|
-
code: ZodError_1.ZodIssueCode.invalid_date
|
|
1249
|
-
}), parseUtil_1.INVALID;
|
|
1250
|
-
}
|
|
1251
|
-
let status = new parseUtil_1.ParseStatus(), ctx;
|
|
1252
|
-
for (let check of this._def.checks)
|
|
1253
|
-
check.kind === "min" ? input.data.getTime() < check.value && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1254
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
1255
|
-
message: check.message,
|
|
1256
|
-
inclusive: !0,
|
|
1257
|
-
exact: !1,
|
|
1258
|
-
minimum: check.value,
|
|
1259
|
-
type: "date"
|
|
1260
|
-
}), status.dirty()) : check.kind === "max" ? input.data.getTime() > check.value && (ctx = this._getOrReturnCtx(input, ctx), (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1261
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
1262
|
-
message: check.message,
|
|
1263
|
-
inclusive: !0,
|
|
1264
|
-
exact: !1,
|
|
1265
|
-
maximum: check.value,
|
|
1266
|
-
type: "date"
|
|
1267
|
-
}), status.dirty()) : util_1.util.assertNever(check);
|
|
1268
|
-
return {
|
|
1269
|
-
status: status.value,
|
|
1270
|
-
value: new Date(input.data.getTime())
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
_addCheck(check) {
|
|
1274
|
-
return new _ZodDate({
|
|
1275
|
-
...this._def,
|
|
1276
|
-
checks: [...this._def.checks, check]
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
min(minDate, message) {
|
|
1280
|
-
return this._addCheck({
|
|
1281
|
-
kind: "min",
|
|
1282
|
-
value: minDate.getTime(),
|
|
1283
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
max(maxDate, message) {
|
|
1287
|
-
return this._addCheck({
|
|
1288
|
-
kind: "max",
|
|
1289
|
-
value: maxDate.getTime(),
|
|
1290
|
-
message: errorUtil_1.errorUtil.toString(message)
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
get minDate() {
|
|
1294
|
-
let min = null;
|
|
1295
|
-
for (let ch of this._def.checks)
|
|
1296
|
-
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
1297
|
-
return min != null ? new Date(min) : null;
|
|
1298
|
-
}
|
|
1299
|
-
get maxDate() {
|
|
1300
|
-
let max = null;
|
|
1301
|
-
for (let ch of this._def.checks)
|
|
1302
|
-
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
1303
|
-
return max != null ? new Date(max) : null;
|
|
1304
|
-
}
|
|
1305
|
-
};
|
|
1306
|
-
exports.ZodDate = ZodDate;
|
|
1307
|
-
ZodDate.create = (params) => new ZodDate({
|
|
1308
|
-
checks: [],
|
|
1309
|
-
coerce: params?.coerce || !1,
|
|
1310
|
-
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
1311
|
-
...processCreateParams(params)
|
|
1312
|
-
});
|
|
1313
|
-
var ZodSymbol = class extends ZodType {
|
|
1314
|
-
_parse(input) {
|
|
1315
|
-
if (this._getType(input) !== util_1.ZodParsedType.symbol) {
|
|
1316
|
-
let ctx = this._getOrReturnCtx(input);
|
|
1317
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1318
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1319
|
-
expected: util_1.ZodParsedType.symbol,
|
|
1320
|
-
received: ctx.parsedType
|
|
1321
|
-
}), parseUtil_1.INVALID;
|
|
1322
|
-
}
|
|
1323
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
1324
|
-
}
|
|
1325
|
-
};
|
|
1326
|
-
exports.ZodSymbol = ZodSymbol;
|
|
1327
|
-
ZodSymbol.create = (params) => new ZodSymbol({
|
|
1328
|
-
typeName: ZodFirstPartyTypeKind.ZodSymbol,
|
|
1329
|
-
...processCreateParams(params)
|
|
1330
|
-
});
|
|
1331
|
-
var ZodUndefined = class extends ZodType {
|
|
1332
|
-
_parse(input) {
|
|
1333
|
-
if (this._getType(input) !== util_1.ZodParsedType.undefined) {
|
|
1334
|
-
let ctx = this._getOrReturnCtx(input);
|
|
1335
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1336
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1337
|
-
expected: util_1.ZodParsedType.undefined,
|
|
1338
|
-
received: ctx.parsedType
|
|
1339
|
-
}), parseUtil_1.INVALID;
|
|
1340
|
-
}
|
|
1341
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
1342
|
-
}
|
|
1343
|
-
};
|
|
1344
|
-
exports.ZodUndefined = ZodUndefined;
|
|
1345
|
-
ZodUndefined.create = (params) => new ZodUndefined({
|
|
1346
|
-
typeName: ZodFirstPartyTypeKind.ZodUndefined,
|
|
1347
|
-
...processCreateParams(params)
|
|
1348
|
-
});
|
|
1349
|
-
var ZodNull = class extends ZodType {
|
|
1350
|
-
_parse(input) {
|
|
1351
|
-
if (this._getType(input) !== util_1.ZodParsedType.null) {
|
|
1352
|
-
let ctx = this._getOrReturnCtx(input);
|
|
1353
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1354
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1355
|
-
expected: util_1.ZodParsedType.null,
|
|
1356
|
-
received: ctx.parsedType
|
|
1357
|
-
}), parseUtil_1.INVALID;
|
|
1358
|
-
}
|
|
1359
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
exports.ZodNull = ZodNull;
|
|
1363
|
-
ZodNull.create = (params) => new ZodNull({
|
|
1364
|
-
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
1365
|
-
...processCreateParams(params)
|
|
1366
|
-
});
|
|
1367
|
-
var ZodAny = class extends ZodType {
|
|
1368
|
-
constructor() {
|
|
1369
|
-
super(...arguments), this._any = !0;
|
|
1370
|
-
}
|
|
1371
|
-
_parse(input) {
|
|
1372
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
1373
|
-
}
|
|
1374
|
-
};
|
|
1375
|
-
exports.ZodAny = ZodAny;
|
|
1376
|
-
ZodAny.create = (params) => new ZodAny({
|
|
1377
|
-
typeName: ZodFirstPartyTypeKind.ZodAny,
|
|
1378
|
-
...processCreateParams(params)
|
|
1379
|
-
});
|
|
1380
|
-
var ZodUnknown = class extends ZodType {
|
|
1381
|
-
constructor() {
|
|
1382
|
-
super(...arguments), this._unknown = !0;
|
|
1383
|
-
}
|
|
1384
|
-
_parse(input) {
|
|
1385
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
1386
|
-
}
|
|
1387
|
-
};
|
|
1388
|
-
exports.ZodUnknown = ZodUnknown;
|
|
1389
|
-
ZodUnknown.create = (params) => new ZodUnknown({
|
|
1390
|
-
typeName: ZodFirstPartyTypeKind.ZodUnknown,
|
|
1391
|
-
...processCreateParams(params)
|
|
1392
|
-
});
|
|
1393
|
-
var ZodNever = class extends ZodType {
|
|
1394
|
-
_parse(input) {
|
|
1395
|
-
let ctx = this._getOrReturnCtx(input);
|
|
1396
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1397
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1398
|
-
expected: util_1.ZodParsedType.never,
|
|
1399
|
-
received: ctx.parsedType
|
|
1400
|
-
}), parseUtil_1.INVALID;
|
|
1401
|
-
}
|
|
1402
|
-
};
|
|
1403
|
-
exports.ZodNever = ZodNever;
|
|
1404
|
-
ZodNever.create = (params) => new ZodNever({
|
|
1405
|
-
typeName: ZodFirstPartyTypeKind.ZodNever,
|
|
1406
|
-
...processCreateParams(params)
|
|
1407
|
-
});
|
|
1408
|
-
var ZodVoid = class extends ZodType {
|
|
1409
|
-
_parse(input) {
|
|
1410
|
-
if (this._getType(input) !== util_1.ZodParsedType.undefined) {
|
|
1411
|
-
let ctx = this._getOrReturnCtx(input);
|
|
1412
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1413
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1414
|
-
expected: util_1.ZodParsedType.void,
|
|
1415
|
-
received: ctx.parsedType
|
|
1416
|
-
}), parseUtil_1.INVALID;
|
|
1417
|
-
}
|
|
1418
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
1419
|
-
}
|
|
1420
|
-
};
|
|
1421
|
-
exports.ZodVoid = ZodVoid;
|
|
1422
|
-
ZodVoid.create = (params) => new ZodVoid({
|
|
1423
|
-
typeName: ZodFirstPartyTypeKind.ZodVoid,
|
|
1424
|
-
...processCreateParams(params)
|
|
1425
|
-
});
|
|
1426
|
-
var ZodArray = class _ZodArray extends ZodType {
|
|
1427
|
-
_parse(input) {
|
|
1428
|
-
let { ctx, status } = this._processInputParams(input), def = this._def;
|
|
1429
|
-
if (ctx.parsedType !== util_1.ZodParsedType.array)
|
|
1430
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1431
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1432
|
-
expected: util_1.ZodParsedType.array,
|
|
1433
|
-
received: ctx.parsedType
|
|
1434
|
-
}), parseUtil_1.INVALID;
|
|
1435
|
-
if (def.exactLength !== null) {
|
|
1436
|
-
let tooBig = ctx.data.length > def.exactLength.value, tooSmall = ctx.data.length < def.exactLength.value;
|
|
1437
|
-
(tooBig || tooSmall) && ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1438
|
-
code: tooBig ? ZodError_1.ZodIssueCode.too_big : ZodError_1.ZodIssueCode.too_small,
|
|
1439
|
-
minimum: tooSmall ? def.exactLength.value : void 0,
|
|
1440
|
-
maximum: tooBig ? def.exactLength.value : void 0,
|
|
1441
|
-
type: "array",
|
|
1442
|
-
inclusive: !0,
|
|
1443
|
-
exact: !0,
|
|
1444
|
-
message: def.exactLength.message
|
|
1445
|
-
}), status.dirty());
|
|
1446
|
-
}
|
|
1447
|
-
if (def.minLength !== null && ctx.data.length < def.minLength.value && ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1448
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
1449
|
-
minimum: def.minLength.value,
|
|
1450
|
-
type: "array",
|
|
1451
|
-
inclusive: !0,
|
|
1452
|
-
exact: !1,
|
|
1453
|
-
message: def.minLength.message
|
|
1454
|
-
}), status.dirty()), def.maxLength !== null && ctx.data.length > def.maxLength.value && ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1455
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
1456
|
-
maximum: def.maxLength.value,
|
|
1457
|
-
type: "array",
|
|
1458
|
-
inclusive: !0,
|
|
1459
|
-
exact: !1,
|
|
1460
|
-
message: def.maxLength.message
|
|
1461
|
-
}), status.dirty()), ctx.common.async)
|
|
1462
|
-
return Promise.all([...ctx.data].map((item, i) => def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i)))).then((result2) => parseUtil_1.ParseStatus.mergeArray(status, result2));
|
|
1463
|
-
let result = [...ctx.data].map((item, i) => def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
1464
|
-
return parseUtil_1.ParseStatus.mergeArray(status, result);
|
|
1465
|
-
}
|
|
1466
|
-
get element() {
|
|
1467
|
-
return this._def.type;
|
|
1468
|
-
}
|
|
1469
|
-
min(minLength, message) {
|
|
1470
|
-
return new _ZodArray({
|
|
1471
|
-
...this._def,
|
|
1472
|
-
minLength: { value: minLength, message: errorUtil_1.errorUtil.toString(message) }
|
|
1473
|
-
});
|
|
1474
|
-
}
|
|
1475
|
-
max(maxLength, message) {
|
|
1476
|
-
return new _ZodArray({
|
|
1477
|
-
...this._def,
|
|
1478
|
-
maxLength: { value: maxLength, message: errorUtil_1.errorUtil.toString(message) }
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
length(len, message) {
|
|
1482
|
-
return new _ZodArray({
|
|
1483
|
-
...this._def,
|
|
1484
|
-
exactLength: { value: len, message: errorUtil_1.errorUtil.toString(message) }
|
|
1485
|
-
});
|
|
1486
|
-
}
|
|
1487
|
-
nonempty(message) {
|
|
1488
|
-
return this.min(1, message);
|
|
1489
|
-
}
|
|
1490
|
-
};
|
|
1491
|
-
exports.ZodArray = ZodArray;
|
|
1492
|
-
ZodArray.create = (schema, params) => new ZodArray({
|
|
1493
|
-
type: schema,
|
|
1494
|
-
minLength: null,
|
|
1495
|
-
maxLength: null,
|
|
1496
|
-
exactLength: null,
|
|
1497
|
-
typeName: ZodFirstPartyTypeKind.ZodArray,
|
|
1498
|
-
...processCreateParams(params)
|
|
1499
|
-
});
|
|
1500
|
-
function deepPartialify(schema) {
|
|
1501
|
-
if (schema instanceof ZodObject) {
|
|
1502
|
-
let newShape = {};
|
|
1503
|
-
for (let key in schema.shape) {
|
|
1504
|
-
let fieldSchema = schema.shape[key];
|
|
1505
|
-
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
1506
|
-
}
|
|
1507
|
-
return new ZodObject({
|
|
1508
|
-
...schema._def,
|
|
1509
|
-
shape: () => newShape
|
|
1510
|
-
});
|
|
1511
|
-
} else
|
|
1512
|
-
return schema instanceof ZodArray ? new ZodArray({
|
|
1513
|
-
...schema._def,
|
|
1514
|
-
type: deepPartialify(schema.element)
|
|
1515
|
-
}) : schema instanceof ZodOptional ? ZodOptional.create(deepPartialify(schema.unwrap())) : schema instanceof ZodNullable ? ZodNullable.create(deepPartialify(schema.unwrap())) : schema instanceof ZodTuple ? ZodTuple.create(schema.items.map((item) => deepPartialify(item))) : schema;
|
|
1516
|
-
}
|
|
1517
|
-
var ZodObject = class _ZodObject extends ZodType {
|
|
1518
|
-
constructor() {
|
|
1519
|
-
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1520
|
-
}
|
|
1521
|
-
_getCached() {
|
|
1522
|
-
if (this._cached !== null)
|
|
1523
|
-
return this._cached;
|
|
1524
|
-
let shape = this._def.shape(), keys = util_1.util.objectKeys(shape);
|
|
1525
|
-
return this._cached = { shape, keys };
|
|
1526
|
-
}
|
|
1527
|
-
_parse(input) {
|
|
1528
|
-
if (this._getType(input) !== util_1.ZodParsedType.object) {
|
|
1529
|
-
let ctx2 = this._getOrReturnCtx(input);
|
|
1530
|
-
return (0, parseUtil_1.addIssueToContext)(ctx2, {
|
|
1531
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1532
|
-
expected: util_1.ZodParsedType.object,
|
|
1533
|
-
received: ctx2.parsedType
|
|
1534
|
-
}), parseUtil_1.INVALID;
|
|
1535
|
-
}
|
|
1536
|
-
let { status, ctx } = this._processInputParams(input), { shape, keys: shapeKeys } = this._getCached(), extraKeys = [];
|
|
1537
|
-
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip"))
|
|
1538
|
-
for (let key in ctx.data)
|
|
1539
|
-
shapeKeys.includes(key) || extraKeys.push(key);
|
|
1540
|
-
let pairs = [];
|
|
1541
|
-
for (let key of shapeKeys) {
|
|
1542
|
-
let keyValidator = shape[key], value = ctx.data[key];
|
|
1543
|
-
pairs.push({
|
|
1544
|
-
key: { status: "valid", value: key },
|
|
1545
|
-
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
1546
|
-
alwaysSet: key in ctx.data
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
|
-
if (this._def.catchall instanceof ZodNever) {
|
|
1550
|
-
let unknownKeys = this._def.unknownKeys;
|
|
1551
|
-
if (unknownKeys === "passthrough")
|
|
1552
|
-
for (let key of extraKeys)
|
|
1553
|
-
pairs.push({
|
|
1554
|
-
key: { status: "valid", value: key },
|
|
1555
|
-
value: { status: "valid", value: ctx.data[key] }
|
|
1556
|
-
});
|
|
1557
|
-
else if (unknownKeys === "strict")
|
|
1558
|
-
extraKeys.length > 0 && ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1559
|
-
code: ZodError_1.ZodIssueCode.unrecognized_keys,
|
|
1560
|
-
keys: extraKeys
|
|
1561
|
-
}), status.dirty());
|
|
1562
|
-
else if (unknownKeys !== "strip")
|
|
1563
|
-
throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1564
|
-
} else {
|
|
1565
|
-
let catchall = this._def.catchall;
|
|
1566
|
-
for (let key of extraKeys) {
|
|
1567
|
-
let value = ctx.data[key];
|
|
1568
|
-
pairs.push({
|
|
1569
|
-
key: { status: "valid", value: key },
|
|
1570
|
-
value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
1571
|
-
alwaysSet: key in ctx.data
|
|
1572
|
-
});
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
return ctx.common.async ? Promise.resolve().then(async () => {
|
|
1576
|
-
let syncPairs = [];
|
|
1577
|
-
for (let pair of pairs) {
|
|
1578
|
-
let key = await pair.key;
|
|
1579
|
-
syncPairs.push({
|
|
1580
|
-
key,
|
|
1581
|
-
value: await pair.value,
|
|
1582
|
-
alwaysSet: pair.alwaysSet
|
|
1583
|
-
});
|
|
1584
|
-
}
|
|
1585
|
-
return syncPairs;
|
|
1586
|
-
}).then((syncPairs) => parseUtil_1.ParseStatus.mergeObjectSync(status, syncPairs)) : parseUtil_1.ParseStatus.mergeObjectSync(status, pairs);
|
|
1587
|
-
}
|
|
1588
|
-
get shape() {
|
|
1589
|
-
return this._def.shape();
|
|
1590
|
-
}
|
|
1591
|
-
strict(message) {
|
|
1592
|
-
return errorUtil_1.errorUtil.errToObj, new _ZodObject({
|
|
1593
|
-
...this._def,
|
|
1594
|
-
unknownKeys: "strict",
|
|
1595
|
-
...message !== void 0 ? {
|
|
1596
|
-
errorMap: (issue, ctx) => {
|
|
1597
|
-
var _a, _b, _c, _d;
|
|
1598
|
-
let defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
|
|
1599
|
-
return issue.code === "unrecognized_keys" ? {
|
|
1600
|
-
message: (_d = errorUtil_1.errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
|
|
1601
|
-
} : {
|
|
1602
|
-
message: defaultError
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
} : {}
|
|
1606
|
-
});
|
|
1607
|
-
}
|
|
1608
|
-
strip() {
|
|
1609
|
-
return new _ZodObject({
|
|
1610
|
-
...this._def,
|
|
1611
|
-
unknownKeys: "strip"
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
passthrough() {
|
|
1615
|
-
return new _ZodObject({
|
|
1616
|
-
...this._def,
|
|
1617
|
-
unknownKeys: "passthrough"
|
|
1618
|
-
});
|
|
1619
|
-
}
|
|
1620
|
-
extend(augmentation) {
|
|
1621
|
-
return new _ZodObject({
|
|
1622
|
-
...this._def,
|
|
1623
|
-
shape: () => ({
|
|
1624
|
-
...this._def.shape(),
|
|
1625
|
-
...augmentation
|
|
1626
|
-
})
|
|
1627
|
-
});
|
|
1628
|
-
}
|
|
1629
|
-
merge(merging) {
|
|
1630
|
-
return new _ZodObject({
|
|
1631
|
-
unknownKeys: merging._def.unknownKeys,
|
|
1632
|
-
catchall: merging._def.catchall,
|
|
1633
|
-
shape: () => ({
|
|
1634
|
-
...this._def.shape(),
|
|
1635
|
-
...merging._def.shape()
|
|
1636
|
-
}),
|
|
1637
|
-
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1640
|
-
setKey(key, schema) {
|
|
1641
|
-
return this.augment({ [key]: schema });
|
|
1642
|
-
}
|
|
1643
|
-
catchall(index) {
|
|
1644
|
-
return new _ZodObject({
|
|
1645
|
-
...this._def,
|
|
1646
|
-
catchall: index
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
pick(mask) {
|
|
1650
|
-
let shape = {};
|
|
1651
|
-
return util_1.util.objectKeys(mask).forEach((key) => {
|
|
1652
|
-
mask[key] && this.shape[key] && (shape[key] = this.shape[key]);
|
|
1653
|
-
}), new _ZodObject({
|
|
1654
|
-
...this._def,
|
|
1655
|
-
shape: () => shape
|
|
1656
|
-
});
|
|
1657
|
-
}
|
|
1658
|
-
omit(mask) {
|
|
1659
|
-
let shape = {};
|
|
1660
|
-
return util_1.util.objectKeys(this.shape).forEach((key) => {
|
|
1661
|
-
mask[key] || (shape[key] = this.shape[key]);
|
|
1662
|
-
}), new _ZodObject({
|
|
1663
|
-
...this._def,
|
|
1664
|
-
shape: () => shape
|
|
1665
|
-
});
|
|
1666
|
-
}
|
|
1667
|
-
deepPartial() {
|
|
1668
|
-
return deepPartialify(this);
|
|
1669
|
-
}
|
|
1670
|
-
partial(mask) {
|
|
1671
|
-
let newShape = {};
|
|
1672
|
-
return util_1.util.objectKeys(this.shape).forEach((key) => {
|
|
1673
|
-
let fieldSchema = this.shape[key];
|
|
1674
|
-
mask && !mask[key] ? newShape[key] = fieldSchema : newShape[key] = fieldSchema.optional();
|
|
1675
|
-
}), new _ZodObject({
|
|
1676
|
-
...this._def,
|
|
1677
|
-
shape: () => newShape
|
|
1678
|
-
});
|
|
1679
|
-
}
|
|
1680
|
-
required(mask) {
|
|
1681
|
-
let newShape = {};
|
|
1682
|
-
return util_1.util.objectKeys(this.shape).forEach((key) => {
|
|
1683
|
-
if (mask && !mask[key])
|
|
1684
|
-
newShape[key] = this.shape[key];
|
|
1685
|
-
else {
|
|
1686
|
-
let newField = this.shape[key];
|
|
1687
|
-
for (; newField instanceof ZodOptional; )
|
|
1688
|
-
newField = newField._def.innerType;
|
|
1689
|
-
newShape[key] = newField;
|
|
1690
|
-
}
|
|
1691
|
-
}), new _ZodObject({
|
|
1692
|
-
...this._def,
|
|
1693
|
-
shape: () => newShape
|
|
1694
|
-
});
|
|
1695
|
-
}
|
|
1696
|
-
keyof() {
|
|
1697
|
-
return createZodEnum(util_1.util.objectKeys(this.shape));
|
|
1698
|
-
}
|
|
1699
|
-
};
|
|
1700
|
-
exports.ZodObject = ZodObject;
|
|
1701
|
-
ZodObject.create = (shape, params) => new ZodObject({
|
|
1702
|
-
shape: () => shape,
|
|
1703
|
-
unknownKeys: "strip",
|
|
1704
|
-
catchall: ZodNever.create(),
|
|
1705
|
-
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1706
|
-
...processCreateParams(params)
|
|
1707
|
-
});
|
|
1708
|
-
ZodObject.strictCreate = (shape, params) => new ZodObject({
|
|
1709
|
-
shape: () => shape,
|
|
1710
|
-
unknownKeys: "strict",
|
|
1711
|
-
catchall: ZodNever.create(),
|
|
1712
|
-
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1713
|
-
...processCreateParams(params)
|
|
1714
|
-
});
|
|
1715
|
-
ZodObject.lazycreate = (shape, params) => new ZodObject({
|
|
1716
|
-
shape,
|
|
1717
|
-
unknownKeys: "strip",
|
|
1718
|
-
catchall: ZodNever.create(),
|
|
1719
|
-
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1720
|
-
...processCreateParams(params)
|
|
1721
|
-
});
|
|
1722
|
-
var ZodUnion = class extends ZodType {
|
|
1723
|
-
_parse(input) {
|
|
1724
|
-
let { ctx } = this._processInputParams(input), options = this._def.options;
|
|
1725
|
-
function handleResults(results) {
|
|
1726
|
-
for (let result of results)
|
|
1727
|
-
if (result.result.status === "valid")
|
|
1728
|
-
return result.result;
|
|
1729
|
-
for (let result of results)
|
|
1730
|
-
if (result.result.status === "dirty")
|
|
1731
|
-
return ctx.common.issues.push(...result.ctx.common.issues), result.result;
|
|
1732
|
-
let unionErrors = results.map((result) => new ZodError_1.ZodError(result.ctx.common.issues));
|
|
1733
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1734
|
-
code: ZodError_1.ZodIssueCode.invalid_union,
|
|
1735
|
-
unionErrors
|
|
1736
|
-
}), parseUtil_1.INVALID;
|
|
1737
|
-
}
|
|
1738
|
-
if (ctx.common.async)
|
|
1739
|
-
return Promise.all(options.map(async (option) => {
|
|
1740
|
-
let childCtx = {
|
|
1741
|
-
...ctx,
|
|
1742
|
-
common: {
|
|
1743
|
-
...ctx.common,
|
|
1744
|
-
issues: []
|
|
1745
|
-
},
|
|
1746
|
-
parent: null
|
|
1747
|
-
};
|
|
1748
|
-
return {
|
|
1749
|
-
result: await option._parseAsync({
|
|
1750
|
-
data: ctx.data,
|
|
1751
|
-
path: ctx.path,
|
|
1752
|
-
parent: childCtx
|
|
1753
|
-
}),
|
|
1754
|
-
ctx: childCtx
|
|
1755
|
-
};
|
|
1756
|
-
})).then(handleResults);
|
|
1757
|
-
{
|
|
1758
|
-
let dirty, issues = [];
|
|
1759
|
-
for (let option of options) {
|
|
1760
|
-
let childCtx = {
|
|
1761
|
-
...ctx,
|
|
1762
|
-
common: {
|
|
1763
|
-
...ctx.common,
|
|
1764
|
-
issues: []
|
|
1765
|
-
},
|
|
1766
|
-
parent: null
|
|
1767
|
-
}, result = option._parseSync({
|
|
1768
|
-
data: ctx.data,
|
|
1769
|
-
path: ctx.path,
|
|
1770
|
-
parent: childCtx
|
|
1771
|
-
});
|
|
1772
|
-
if (result.status === "valid")
|
|
1773
|
-
return result;
|
|
1774
|
-
result.status === "dirty" && !dirty && (dirty = { result, ctx: childCtx }), childCtx.common.issues.length && issues.push(childCtx.common.issues);
|
|
1775
|
-
}
|
|
1776
|
-
if (dirty)
|
|
1777
|
-
return ctx.common.issues.push(...dirty.ctx.common.issues), dirty.result;
|
|
1778
|
-
let unionErrors = issues.map((issues2) => new ZodError_1.ZodError(issues2));
|
|
1779
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1780
|
-
code: ZodError_1.ZodIssueCode.invalid_union,
|
|
1781
|
-
unionErrors
|
|
1782
|
-
}), parseUtil_1.INVALID;
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
get options() {
|
|
1786
|
-
return this._def.options;
|
|
1787
|
-
}
|
|
1788
|
-
};
|
|
1789
|
-
exports.ZodUnion = ZodUnion;
|
|
1790
|
-
ZodUnion.create = (types, params) => new ZodUnion({
|
|
1791
|
-
options: types,
|
|
1792
|
-
typeName: ZodFirstPartyTypeKind.ZodUnion,
|
|
1793
|
-
...processCreateParams(params)
|
|
1794
|
-
});
|
|
1795
|
-
var getDiscriminator = (type) => type instanceof ZodLazy ? getDiscriminator(type.schema) : type instanceof ZodEffects ? getDiscriminator(type.innerType()) : type instanceof ZodLiteral ? [type.value] : type instanceof ZodEnum ? type.options : type instanceof ZodNativeEnum ? Object.keys(type.enum) : type instanceof ZodDefault ? getDiscriminator(type._def.innerType) : type instanceof ZodUndefined ? [void 0] : type instanceof ZodNull ? [null] : null, ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
1796
|
-
_parse(input) {
|
|
1797
|
-
let { ctx } = this._processInputParams(input);
|
|
1798
|
-
if (ctx.parsedType !== util_1.ZodParsedType.object)
|
|
1799
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1800
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1801
|
-
expected: util_1.ZodParsedType.object,
|
|
1802
|
-
received: ctx.parsedType
|
|
1803
|
-
}), parseUtil_1.INVALID;
|
|
1804
|
-
let discriminator = this.discriminator, discriminatorValue = ctx.data[discriminator], option = this.optionsMap.get(discriminatorValue);
|
|
1805
|
-
return option ? ctx.common.async ? option._parseAsync({
|
|
1806
|
-
data: ctx.data,
|
|
1807
|
-
path: ctx.path,
|
|
1808
|
-
parent: ctx
|
|
1809
|
-
}) : option._parseSync({
|
|
1810
|
-
data: ctx.data,
|
|
1811
|
-
path: ctx.path,
|
|
1812
|
-
parent: ctx
|
|
1813
|
-
}) : ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1814
|
-
code: ZodError_1.ZodIssueCode.invalid_union_discriminator,
|
|
1815
|
-
options: Array.from(this.optionsMap.keys()),
|
|
1816
|
-
path: [discriminator]
|
|
1817
|
-
}), parseUtil_1.INVALID);
|
|
1818
|
-
}
|
|
1819
|
-
get discriminator() {
|
|
1820
|
-
return this._def.discriminator;
|
|
1821
|
-
}
|
|
1822
|
-
get options() {
|
|
1823
|
-
return this._def.options;
|
|
1824
|
-
}
|
|
1825
|
-
get optionsMap() {
|
|
1826
|
-
return this._def.optionsMap;
|
|
1827
|
-
}
|
|
1828
|
-
static create(discriminator, options, params) {
|
|
1829
|
-
let optionsMap = /* @__PURE__ */ new Map();
|
|
1830
|
-
for (let type of options) {
|
|
1831
|
-
let discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
1832
|
-
if (!discriminatorValues)
|
|
1833
|
-
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
1834
|
-
for (let value of discriminatorValues) {
|
|
1835
|
-
if (optionsMap.has(value))
|
|
1836
|
-
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
|
|
1837
|
-
optionsMap.set(value, type);
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
return new _ZodDiscriminatedUnion({
|
|
1841
|
-
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
|
|
1842
|
-
discriminator,
|
|
1843
|
-
options,
|
|
1844
|
-
optionsMap,
|
|
1845
|
-
...processCreateParams(params)
|
|
1846
|
-
});
|
|
1847
|
-
}
|
|
1848
|
-
};
|
|
1849
|
-
exports.ZodDiscriminatedUnion = ZodDiscriminatedUnion;
|
|
1850
|
-
function mergeValues(a, b) {
|
|
1851
|
-
let aType = (0, util_1.getParsedType)(a), bType = (0, util_1.getParsedType)(b);
|
|
1852
|
-
if (a === b)
|
|
1853
|
-
return { valid: !0, data: a };
|
|
1854
|
-
if (aType === util_1.ZodParsedType.object && bType === util_1.ZodParsedType.object) {
|
|
1855
|
-
let bKeys = util_1.util.objectKeys(b), sharedKeys = util_1.util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1), newObj = { ...a, ...b };
|
|
1856
|
-
for (let key of sharedKeys) {
|
|
1857
|
-
let sharedValue = mergeValues(a[key], b[key]);
|
|
1858
|
-
if (!sharedValue.valid)
|
|
1859
|
-
return { valid: !1 };
|
|
1860
|
-
newObj[key] = sharedValue.data;
|
|
1861
|
-
}
|
|
1862
|
-
return { valid: !0, data: newObj };
|
|
1863
|
-
} else if (aType === util_1.ZodParsedType.array && bType === util_1.ZodParsedType.array) {
|
|
1864
|
-
if (a.length !== b.length)
|
|
1865
|
-
return { valid: !1 };
|
|
1866
|
-
let newArray = [];
|
|
1867
|
-
for (let index = 0; index < a.length; index++) {
|
|
1868
|
-
let itemA = a[index], itemB = b[index], sharedValue = mergeValues(itemA, itemB);
|
|
1869
|
-
if (!sharedValue.valid)
|
|
1870
|
-
return { valid: !1 };
|
|
1871
|
-
newArray.push(sharedValue.data);
|
|
1872
|
-
}
|
|
1873
|
-
return { valid: !0, data: newArray };
|
|
1874
|
-
} else
|
|
1875
|
-
return aType === util_1.ZodParsedType.date && bType === util_1.ZodParsedType.date && +a == +b ? { valid: !0, data: a } : { valid: !1 };
|
|
1876
|
-
}
|
|
1877
|
-
var ZodIntersection = class extends ZodType {
|
|
1878
|
-
_parse(input) {
|
|
1879
|
-
let { status, ctx } = this._processInputParams(input), handleParsed = (parsedLeft, parsedRight) => {
|
|
1880
|
-
if ((0, parseUtil_1.isAborted)(parsedLeft) || (0, parseUtil_1.isAborted)(parsedRight))
|
|
1881
|
-
return parseUtil_1.INVALID;
|
|
1882
|
-
let merged = mergeValues(parsedLeft.value, parsedRight.value);
|
|
1883
|
-
return merged.valid ? (((0, parseUtil_1.isDirty)(parsedLeft) || (0, parseUtil_1.isDirty)(parsedRight)) && status.dirty(), { status: status.value, value: merged.data }) : ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1884
|
-
code: ZodError_1.ZodIssueCode.invalid_intersection_types
|
|
1885
|
-
}), parseUtil_1.INVALID);
|
|
1886
|
-
};
|
|
1887
|
-
return ctx.common.async ? Promise.all([
|
|
1888
|
-
this._def.left._parseAsync({
|
|
1889
|
-
data: ctx.data,
|
|
1890
|
-
path: ctx.path,
|
|
1891
|
-
parent: ctx
|
|
1892
|
-
}),
|
|
1893
|
-
this._def.right._parseAsync({
|
|
1894
|
-
data: ctx.data,
|
|
1895
|
-
path: ctx.path,
|
|
1896
|
-
parent: ctx
|
|
1897
|
-
})
|
|
1898
|
-
]).then(([left, right]) => handleParsed(left, right)) : handleParsed(this._def.left._parseSync({
|
|
1899
|
-
data: ctx.data,
|
|
1900
|
-
path: ctx.path,
|
|
1901
|
-
parent: ctx
|
|
1902
|
-
}), this._def.right._parseSync({
|
|
1903
|
-
data: ctx.data,
|
|
1904
|
-
path: ctx.path,
|
|
1905
|
-
parent: ctx
|
|
1906
|
-
}));
|
|
1907
|
-
}
|
|
1908
|
-
};
|
|
1909
|
-
exports.ZodIntersection = ZodIntersection;
|
|
1910
|
-
ZodIntersection.create = (left, right, params) => new ZodIntersection({
|
|
1911
|
-
left,
|
|
1912
|
-
right,
|
|
1913
|
-
typeName: ZodFirstPartyTypeKind.ZodIntersection,
|
|
1914
|
-
...processCreateParams(params)
|
|
1915
|
-
});
|
|
1916
|
-
var ZodTuple = class _ZodTuple extends ZodType {
|
|
1917
|
-
_parse(input) {
|
|
1918
|
-
let { status, ctx } = this._processInputParams(input);
|
|
1919
|
-
if (ctx.parsedType !== util_1.ZodParsedType.array)
|
|
1920
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1921
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1922
|
-
expected: util_1.ZodParsedType.array,
|
|
1923
|
-
received: ctx.parsedType
|
|
1924
|
-
}), parseUtil_1.INVALID;
|
|
1925
|
-
if (ctx.data.length < this._def.items.length)
|
|
1926
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1927
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
1928
|
-
minimum: this._def.items.length,
|
|
1929
|
-
inclusive: !0,
|
|
1930
|
-
exact: !1,
|
|
1931
|
-
type: "array"
|
|
1932
|
-
}), parseUtil_1.INVALID;
|
|
1933
|
-
!this._def.rest && ctx.data.length > this._def.items.length && ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1934
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
1935
|
-
maximum: this._def.items.length,
|
|
1936
|
-
inclusive: !0,
|
|
1937
|
-
exact: !1,
|
|
1938
|
-
type: "array"
|
|
1939
|
-
}), status.dirty());
|
|
1940
|
-
let items = [...ctx.data].map((item, itemIndex) => {
|
|
1941
|
-
let schema = this._def.items[itemIndex] || this._def.rest;
|
|
1942
|
-
return schema ? schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)) : null;
|
|
1943
|
-
}).filter((x) => !!x);
|
|
1944
|
-
return ctx.common.async ? Promise.all(items).then((results) => parseUtil_1.ParseStatus.mergeArray(status, results)) : parseUtil_1.ParseStatus.mergeArray(status, items);
|
|
1945
|
-
}
|
|
1946
|
-
get items() {
|
|
1947
|
-
return this._def.items;
|
|
1948
|
-
}
|
|
1949
|
-
rest(rest) {
|
|
1950
|
-
return new _ZodTuple({
|
|
1951
|
-
...this._def,
|
|
1952
|
-
rest
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
};
|
|
1956
|
-
exports.ZodTuple = ZodTuple;
|
|
1957
|
-
ZodTuple.create = (schemas, params) => {
|
|
1958
|
-
if (!Array.isArray(schemas))
|
|
1959
|
-
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
1960
|
-
return new ZodTuple({
|
|
1961
|
-
items: schemas,
|
|
1962
|
-
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
|
1963
|
-
rest: null,
|
|
1964
|
-
...processCreateParams(params)
|
|
1965
|
-
});
|
|
1966
|
-
};
|
|
1967
|
-
var ZodRecord = class _ZodRecord extends ZodType {
|
|
1968
|
-
get keySchema() {
|
|
1969
|
-
return this._def.keyType;
|
|
1970
|
-
}
|
|
1971
|
-
get valueSchema() {
|
|
1972
|
-
return this._def.valueType;
|
|
1973
|
-
}
|
|
1974
|
-
_parse(input) {
|
|
1975
|
-
let { status, ctx } = this._processInputParams(input);
|
|
1976
|
-
if (ctx.parsedType !== util_1.ZodParsedType.object)
|
|
1977
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
1978
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
1979
|
-
expected: util_1.ZodParsedType.object,
|
|
1980
|
-
received: ctx.parsedType
|
|
1981
|
-
}), parseUtil_1.INVALID;
|
|
1982
|
-
let pairs = [], keyType = this._def.keyType, valueType = this._def.valueType;
|
|
1983
|
-
for (let key in ctx.data)
|
|
1984
|
-
pairs.push({
|
|
1985
|
-
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
1986
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
1987
|
-
});
|
|
1988
|
-
return ctx.common.async ? parseUtil_1.ParseStatus.mergeObjectAsync(status, pairs) : parseUtil_1.ParseStatus.mergeObjectSync(status, pairs);
|
|
1989
|
-
}
|
|
1990
|
-
get element() {
|
|
1991
|
-
return this._def.valueType;
|
|
1992
|
-
}
|
|
1993
|
-
static create(first, second, third) {
|
|
1994
|
-
return second instanceof ZodType ? new _ZodRecord({
|
|
1995
|
-
keyType: first,
|
|
1996
|
-
valueType: second,
|
|
1997
|
-
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
1998
|
-
...processCreateParams(third)
|
|
1999
|
-
}) : new _ZodRecord({
|
|
2000
|
-
keyType: ZodString.create(),
|
|
2001
|
-
valueType: first,
|
|
2002
|
-
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
2003
|
-
...processCreateParams(second)
|
|
2004
|
-
});
|
|
2005
|
-
}
|
|
2006
|
-
};
|
|
2007
|
-
exports.ZodRecord = ZodRecord;
|
|
2008
|
-
var ZodMap = class extends ZodType {
|
|
2009
|
-
get keySchema() {
|
|
2010
|
-
return this._def.keyType;
|
|
2011
|
-
}
|
|
2012
|
-
get valueSchema() {
|
|
2013
|
-
return this._def.valueType;
|
|
2014
|
-
}
|
|
2015
|
-
_parse(input) {
|
|
2016
|
-
let { status, ctx } = this._processInputParams(input);
|
|
2017
|
-
if (ctx.parsedType !== util_1.ZodParsedType.map)
|
|
2018
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2019
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
2020
|
-
expected: util_1.ZodParsedType.map,
|
|
2021
|
-
received: ctx.parsedType
|
|
2022
|
-
}), parseUtil_1.INVALID;
|
|
2023
|
-
let keyType = this._def.keyType, valueType = this._def.valueType, pairs = [...ctx.data.entries()].map(([key, value], index) => ({
|
|
2024
|
-
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
|
|
2025
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
|
|
2026
|
-
}));
|
|
2027
|
-
if (ctx.common.async) {
|
|
2028
|
-
let finalMap = /* @__PURE__ */ new Map();
|
|
2029
|
-
return Promise.resolve().then(async () => {
|
|
2030
|
-
for (let pair of pairs) {
|
|
2031
|
-
let key = await pair.key, value = await pair.value;
|
|
2032
|
-
if (key.status === "aborted" || value.status === "aborted")
|
|
2033
|
-
return parseUtil_1.INVALID;
|
|
2034
|
-
(key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
|
|
2035
|
-
}
|
|
2036
|
-
return { status: status.value, value: finalMap };
|
|
2037
|
-
});
|
|
2038
|
-
} else {
|
|
2039
|
-
let finalMap = /* @__PURE__ */ new Map();
|
|
2040
|
-
for (let pair of pairs) {
|
|
2041
|
-
let key = pair.key, value = pair.value;
|
|
2042
|
-
if (key.status === "aborted" || value.status === "aborted")
|
|
2043
|
-
return parseUtil_1.INVALID;
|
|
2044
|
-
(key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
|
|
2045
|
-
}
|
|
2046
|
-
return { status: status.value, value: finalMap };
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
};
|
|
2050
|
-
exports.ZodMap = ZodMap;
|
|
2051
|
-
ZodMap.create = (keyType, valueType, params) => new ZodMap({
|
|
2052
|
-
valueType,
|
|
2053
|
-
keyType,
|
|
2054
|
-
typeName: ZodFirstPartyTypeKind.ZodMap,
|
|
2055
|
-
...processCreateParams(params)
|
|
2056
|
-
});
|
|
2057
|
-
var ZodSet = class _ZodSet extends ZodType {
|
|
2058
|
-
_parse(input) {
|
|
2059
|
-
let { status, ctx } = this._processInputParams(input);
|
|
2060
|
-
if (ctx.parsedType !== util_1.ZodParsedType.set)
|
|
2061
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2062
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
2063
|
-
expected: util_1.ZodParsedType.set,
|
|
2064
|
-
received: ctx.parsedType
|
|
2065
|
-
}), parseUtil_1.INVALID;
|
|
2066
|
-
let def = this._def;
|
|
2067
|
-
def.minSize !== null && ctx.data.size < def.minSize.value && ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2068
|
-
code: ZodError_1.ZodIssueCode.too_small,
|
|
2069
|
-
minimum: def.minSize.value,
|
|
2070
|
-
type: "set",
|
|
2071
|
-
inclusive: !0,
|
|
2072
|
-
exact: !1,
|
|
2073
|
-
message: def.minSize.message
|
|
2074
|
-
}), status.dirty()), def.maxSize !== null && ctx.data.size > def.maxSize.value && ((0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2075
|
-
code: ZodError_1.ZodIssueCode.too_big,
|
|
2076
|
-
maximum: def.maxSize.value,
|
|
2077
|
-
type: "set",
|
|
2078
|
-
inclusive: !0,
|
|
2079
|
-
exact: !1,
|
|
2080
|
-
message: def.maxSize.message
|
|
2081
|
-
}), status.dirty());
|
|
2082
|
-
let valueType = this._def.valueType;
|
|
2083
|
-
function finalizeSet(elements2) {
|
|
2084
|
-
let parsedSet = /* @__PURE__ */ new Set();
|
|
2085
|
-
for (let element of elements2) {
|
|
2086
|
-
if (element.status === "aborted")
|
|
2087
|
-
return parseUtil_1.INVALID;
|
|
2088
|
-
element.status === "dirty" && status.dirty(), parsedSet.add(element.value);
|
|
2089
|
-
}
|
|
2090
|
-
return { status: status.value, value: parsedSet };
|
|
2091
|
-
}
|
|
2092
|
-
let elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
2093
|
-
return ctx.common.async ? Promise.all(elements).then((elements2) => finalizeSet(elements2)) : finalizeSet(elements);
|
|
2094
|
-
}
|
|
2095
|
-
min(minSize, message) {
|
|
2096
|
-
return new _ZodSet({
|
|
2097
|
-
...this._def,
|
|
2098
|
-
minSize: { value: minSize, message: errorUtil_1.errorUtil.toString(message) }
|
|
2099
|
-
});
|
|
2100
|
-
}
|
|
2101
|
-
max(maxSize, message) {
|
|
2102
|
-
return new _ZodSet({
|
|
2103
|
-
...this._def,
|
|
2104
|
-
maxSize: { value: maxSize, message: errorUtil_1.errorUtil.toString(message) }
|
|
2105
|
-
});
|
|
2106
|
-
}
|
|
2107
|
-
size(size, message) {
|
|
2108
|
-
return this.min(size, message).max(size, message);
|
|
2109
|
-
}
|
|
2110
|
-
nonempty(message) {
|
|
2111
|
-
return this.min(1, message);
|
|
2112
|
-
}
|
|
2113
|
-
};
|
|
2114
|
-
exports.ZodSet = ZodSet;
|
|
2115
|
-
ZodSet.create = (valueType, params) => new ZodSet({
|
|
2116
|
-
valueType,
|
|
2117
|
-
minSize: null,
|
|
2118
|
-
maxSize: null,
|
|
2119
|
-
typeName: ZodFirstPartyTypeKind.ZodSet,
|
|
2120
|
-
...processCreateParams(params)
|
|
2121
|
-
});
|
|
2122
|
-
var ZodFunction = class _ZodFunction extends ZodType {
|
|
2123
|
-
constructor() {
|
|
2124
|
-
super(...arguments), this.validate = this.implement;
|
|
2125
|
-
}
|
|
2126
|
-
_parse(input) {
|
|
2127
|
-
let { ctx } = this._processInputParams(input);
|
|
2128
|
-
if (ctx.parsedType !== util_1.ZodParsedType.function)
|
|
2129
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2130
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
2131
|
-
expected: util_1.ZodParsedType.function,
|
|
2132
|
-
received: ctx.parsedType
|
|
2133
|
-
}), parseUtil_1.INVALID;
|
|
2134
|
-
function makeArgsIssue(args, error) {
|
|
2135
|
-
return (0, parseUtil_1.makeIssue)({
|
|
2136
|
-
data: args,
|
|
2137
|
-
path: ctx.path,
|
|
2138
|
-
errorMaps: [
|
|
2139
|
-
ctx.common.contextualErrorMap,
|
|
2140
|
-
ctx.schemaErrorMap,
|
|
2141
|
-
(0, errors_1.getErrorMap)(),
|
|
2142
|
-
errors_1.defaultErrorMap
|
|
2143
|
-
].filter((x) => !!x),
|
|
2144
|
-
issueData: {
|
|
2145
|
-
code: ZodError_1.ZodIssueCode.invalid_arguments,
|
|
2146
|
-
argumentsError: error
|
|
2147
|
-
}
|
|
2148
|
-
});
|
|
2149
|
-
}
|
|
2150
|
-
function makeReturnsIssue(returns, error) {
|
|
2151
|
-
return (0, parseUtil_1.makeIssue)({
|
|
2152
|
-
data: returns,
|
|
2153
|
-
path: ctx.path,
|
|
2154
|
-
errorMaps: [
|
|
2155
|
-
ctx.common.contextualErrorMap,
|
|
2156
|
-
ctx.schemaErrorMap,
|
|
2157
|
-
(0, errors_1.getErrorMap)(),
|
|
2158
|
-
errors_1.defaultErrorMap
|
|
2159
|
-
].filter((x) => !!x),
|
|
2160
|
-
issueData: {
|
|
2161
|
-
code: ZodError_1.ZodIssueCode.invalid_return_type,
|
|
2162
|
-
returnTypeError: error
|
|
2163
|
-
}
|
|
2164
|
-
});
|
|
2165
|
-
}
|
|
2166
|
-
let params = { errorMap: ctx.common.contextualErrorMap }, fn = ctx.data;
|
|
2167
|
-
if (this._def.returns instanceof ZodPromise) {
|
|
2168
|
-
let me = this;
|
|
2169
|
-
return (0, parseUtil_1.OK)(async function(...args) {
|
|
2170
|
-
let error = new ZodError_1.ZodError([]), parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
2171
|
-
throw error.addIssue(makeArgsIssue(args, e)), error;
|
|
2172
|
-
}), result = await Reflect.apply(fn, this, parsedArgs);
|
|
2173
|
-
return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
2174
|
-
throw error.addIssue(makeReturnsIssue(result, e)), error;
|
|
2175
|
-
});
|
|
2176
|
-
});
|
|
2177
|
-
} else {
|
|
2178
|
-
let me = this;
|
|
2179
|
-
return (0, parseUtil_1.OK)(function(...args) {
|
|
2180
|
-
let parsedArgs = me._def.args.safeParse(args, params);
|
|
2181
|
-
if (!parsedArgs.success)
|
|
2182
|
-
throw new ZodError_1.ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
2183
|
-
let result = Reflect.apply(fn, this, parsedArgs.data), parsedReturns = me._def.returns.safeParse(result, params);
|
|
2184
|
-
if (!parsedReturns.success)
|
|
2185
|
-
throw new ZodError_1.ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
2186
|
-
return parsedReturns.data;
|
|
2187
|
-
});
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
parameters() {
|
|
2191
|
-
return this._def.args;
|
|
2192
|
-
}
|
|
2193
|
-
returnType() {
|
|
2194
|
-
return this._def.returns;
|
|
2195
|
-
}
|
|
2196
|
-
args(...items) {
|
|
2197
|
-
return new _ZodFunction({
|
|
2198
|
-
...this._def,
|
|
2199
|
-
args: ZodTuple.create(items).rest(ZodUnknown.create())
|
|
2200
|
-
});
|
|
2201
|
-
}
|
|
2202
|
-
returns(returnType) {
|
|
2203
|
-
return new _ZodFunction({
|
|
2204
|
-
...this._def,
|
|
2205
|
-
returns: returnType
|
|
2206
|
-
});
|
|
2207
|
-
}
|
|
2208
|
-
implement(func) {
|
|
2209
|
-
return this.parse(func);
|
|
2210
|
-
}
|
|
2211
|
-
strictImplement(func) {
|
|
2212
|
-
return this.parse(func);
|
|
2213
|
-
}
|
|
2214
|
-
static create(args, returns, params) {
|
|
2215
|
-
return new _ZodFunction({
|
|
2216
|
-
args: args || ZodTuple.create([]).rest(ZodUnknown.create()),
|
|
2217
|
-
returns: returns || ZodUnknown.create(),
|
|
2218
|
-
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
2219
|
-
...processCreateParams(params)
|
|
2220
|
-
});
|
|
2221
|
-
}
|
|
2222
|
-
};
|
|
2223
|
-
exports.ZodFunction = ZodFunction;
|
|
2224
|
-
var ZodLazy = class extends ZodType {
|
|
2225
|
-
get schema() {
|
|
2226
|
-
return this._def.getter();
|
|
2227
|
-
}
|
|
2228
|
-
_parse(input) {
|
|
2229
|
-
let { ctx } = this._processInputParams(input);
|
|
2230
|
-
return this._def.getter()._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
2231
|
-
}
|
|
2232
|
-
};
|
|
2233
|
-
exports.ZodLazy = ZodLazy;
|
|
2234
|
-
ZodLazy.create = (getter, params) => new ZodLazy({
|
|
2235
|
-
getter,
|
|
2236
|
-
typeName: ZodFirstPartyTypeKind.ZodLazy,
|
|
2237
|
-
...processCreateParams(params)
|
|
2238
|
-
});
|
|
2239
|
-
var ZodLiteral = class extends ZodType {
|
|
2240
|
-
_parse(input) {
|
|
2241
|
-
if (input.data !== this._def.value) {
|
|
2242
|
-
let ctx = this._getOrReturnCtx(input);
|
|
2243
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2244
|
-
received: ctx.data,
|
|
2245
|
-
code: ZodError_1.ZodIssueCode.invalid_literal,
|
|
2246
|
-
expected: this._def.value
|
|
2247
|
-
}), parseUtil_1.INVALID;
|
|
2248
|
-
}
|
|
2249
|
-
return { status: "valid", value: input.data };
|
|
2250
|
-
}
|
|
2251
|
-
get value() {
|
|
2252
|
-
return this._def.value;
|
|
2253
|
-
}
|
|
2254
|
-
};
|
|
2255
|
-
exports.ZodLiteral = ZodLiteral;
|
|
2256
|
-
ZodLiteral.create = (value, params) => new ZodLiteral({
|
|
2257
|
-
value,
|
|
2258
|
-
typeName: ZodFirstPartyTypeKind.ZodLiteral,
|
|
2259
|
-
...processCreateParams(params)
|
|
2260
|
-
});
|
|
2261
|
-
function createZodEnum(values, params) {
|
|
2262
|
-
return new ZodEnum({
|
|
2263
|
-
values,
|
|
2264
|
-
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
2265
|
-
...processCreateParams(params)
|
|
2266
|
-
});
|
|
2267
|
-
}
|
|
2268
|
-
var ZodEnum = class _ZodEnum extends ZodType {
|
|
2269
|
-
_parse(input) {
|
|
2270
|
-
if (typeof input.data != "string") {
|
|
2271
|
-
let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
|
|
2272
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2273
|
-
expected: util_1.util.joinValues(expectedValues),
|
|
2274
|
-
received: ctx.parsedType,
|
|
2275
|
-
code: ZodError_1.ZodIssueCode.invalid_type
|
|
2276
|
-
}), parseUtil_1.INVALID;
|
|
2277
|
-
}
|
|
2278
|
-
if (this._def.values.indexOf(input.data) === -1) {
|
|
2279
|
-
let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
|
|
2280
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2281
|
-
received: ctx.data,
|
|
2282
|
-
code: ZodError_1.ZodIssueCode.invalid_enum_value,
|
|
2283
|
-
options: expectedValues
|
|
2284
|
-
}), parseUtil_1.INVALID;
|
|
2285
|
-
}
|
|
2286
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
2287
|
-
}
|
|
2288
|
-
get options() {
|
|
2289
|
-
return this._def.values;
|
|
2290
|
-
}
|
|
2291
|
-
get enum() {
|
|
2292
|
-
let enumValues = {};
|
|
2293
|
-
for (let val of this._def.values)
|
|
2294
|
-
enumValues[val] = val;
|
|
2295
|
-
return enumValues;
|
|
2296
|
-
}
|
|
2297
|
-
get Values() {
|
|
2298
|
-
let enumValues = {};
|
|
2299
|
-
for (let val of this._def.values)
|
|
2300
|
-
enumValues[val] = val;
|
|
2301
|
-
return enumValues;
|
|
2302
|
-
}
|
|
2303
|
-
get Enum() {
|
|
2304
|
-
let enumValues = {};
|
|
2305
|
-
for (let val of this._def.values)
|
|
2306
|
-
enumValues[val] = val;
|
|
2307
|
-
return enumValues;
|
|
2308
|
-
}
|
|
2309
|
-
extract(values) {
|
|
2310
|
-
return _ZodEnum.create(values);
|
|
2311
|
-
}
|
|
2312
|
-
exclude(values) {
|
|
2313
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
|
|
2314
|
-
}
|
|
2315
|
-
};
|
|
2316
|
-
exports.ZodEnum = ZodEnum;
|
|
2317
|
-
ZodEnum.create = createZodEnum;
|
|
2318
|
-
var ZodNativeEnum = class extends ZodType {
|
|
2319
|
-
_parse(input) {
|
|
2320
|
-
let nativeEnumValues = util_1.util.getValidEnumValues(this._def.values), ctx = this._getOrReturnCtx(input);
|
|
2321
|
-
if (ctx.parsedType !== util_1.ZodParsedType.string && ctx.parsedType !== util_1.ZodParsedType.number) {
|
|
2322
|
-
let expectedValues = util_1.util.objectValues(nativeEnumValues);
|
|
2323
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2324
|
-
expected: util_1.util.joinValues(expectedValues),
|
|
2325
|
-
received: ctx.parsedType,
|
|
2326
|
-
code: ZodError_1.ZodIssueCode.invalid_type
|
|
2327
|
-
}), parseUtil_1.INVALID;
|
|
2328
|
-
}
|
|
2329
|
-
if (nativeEnumValues.indexOf(input.data) === -1) {
|
|
2330
|
-
let expectedValues = util_1.util.objectValues(nativeEnumValues);
|
|
2331
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2332
|
-
received: ctx.data,
|
|
2333
|
-
code: ZodError_1.ZodIssueCode.invalid_enum_value,
|
|
2334
|
-
options: expectedValues
|
|
2335
|
-
}), parseUtil_1.INVALID;
|
|
2336
|
-
}
|
|
2337
|
-
return (0, parseUtil_1.OK)(input.data);
|
|
2338
|
-
}
|
|
2339
|
-
get enum() {
|
|
2340
|
-
return this._def.values;
|
|
2341
|
-
}
|
|
2342
|
-
};
|
|
2343
|
-
exports.ZodNativeEnum = ZodNativeEnum;
|
|
2344
|
-
ZodNativeEnum.create = (values, params) => new ZodNativeEnum({
|
|
2345
|
-
values,
|
|
2346
|
-
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
|
|
2347
|
-
...processCreateParams(params)
|
|
2348
|
-
});
|
|
2349
|
-
var ZodPromise = class extends ZodType {
|
|
2350
|
-
unwrap() {
|
|
2351
|
-
return this._def.type;
|
|
2352
|
-
}
|
|
2353
|
-
_parse(input) {
|
|
2354
|
-
let { ctx } = this._processInputParams(input);
|
|
2355
|
-
if (ctx.parsedType !== util_1.ZodParsedType.promise && ctx.common.async === !1)
|
|
2356
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2357
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
2358
|
-
expected: util_1.ZodParsedType.promise,
|
|
2359
|
-
received: ctx.parsedType
|
|
2360
|
-
}), parseUtil_1.INVALID;
|
|
2361
|
-
let promisified = ctx.parsedType === util_1.ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
2362
|
-
return (0, parseUtil_1.OK)(promisified.then((data) => this._def.type.parseAsync(data, {
|
|
2363
|
-
path: ctx.path,
|
|
2364
|
-
errorMap: ctx.common.contextualErrorMap
|
|
2365
|
-
})));
|
|
2366
|
-
}
|
|
2367
|
-
};
|
|
2368
|
-
exports.ZodPromise = ZodPromise;
|
|
2369
|
-
ZodPromise.create = (schema, params) => new ZodPromise({
|
|
2370
|
-
type: schema,
|
|
2371
|
-
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
2372
|
-
...processCreateParams(params)
|
|
2373
|
-
});
|
|
2374
|
-
var ZodEffects = class extends ZodType {
|
|
2375
|
-
innerType() {
|
|
2376
|
-
return this._def.schema;
|
|
2377
|
-
}
|
|
2378
|
-
sourceType() {
|
|
2379
|
-
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2380
|
-
}
|
|
2381
|
-
_parse(input) {
|
|
2382
|
-
let { status, ctx } = this._processInputParams(input), effect = this._def.effect || null, checkCtx = {
|
|
2383
|
-
addIssue: (arg) => {
|
|
2384
|
-
(0, parseUtil_1.addIssueToContext)(ctx, arg), arg.fatal ? status.abort() : status.dirty();
|
|
2385
|
-
},
|
|
2386
|
-
get path() {
|
|
2387
|
-
return ctx.path;
|
|
2388
|
-
}
|
|
2389
|
-
};
|
|
2390
|
-
if (checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx), effect.type === "preprocess") {
|
|
2391
|
-
let processed = effect.transform(ctx.data, checkCtx);
|
|
2392
|
-
return ctx.common.issues.length ? {
|
|
2393
|
-
status: "dirty",
|
|
2394
|
-
value: ctx.data
|
|
2395
|
-
} : ctx.common.async ? Promise.resolve(processed).then((processed2) => this._def.schema._parseAsync({
|
|
2396
|
-
data: processed2,
|
|
2397
|
-
path: ctx.path,
|
|
2398
|
-
parent: ctx
|
|
2399
|
-
})) : this._def.schema._parseSync({
|
|
2400
|
-
data: processed,
|
|
2401
|
-
path: ctx.path,
|
|
2402
|
-
parent: ctx
|
|
2403
|
-
});
|
|
2404
|
-
}
|
|
2405
|
-
if (effect.type === "refinement") {
|
|
2406
|
-
let executeRefinement = (acc) => {
|
|
2407
|
-
let result = effect.refinement(acc, checkCtx);
|
|
2408
|
-
if (ctx.common.async)
|
|
2409
|
-
return Promise.resolve(result);
|
|
2410
|
-
if (result instanceof Promise)
|
|
2411
|
-
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2412
|
-
return acc;
|
|
2413
|
-
};
|
|
2414
|
-
if (ctx.common.async === !1) {
|
|
2415
|
-
let inner = this._def.schema._parseSync({
|
|
2416
|
-
data: ctx.data,
|
|
2417
|
-
path: ctx.path,
|
|
2418
|
-
parent: ctx
|
|
2419
|
-
});
|
|
2420
|
-
return inner.status === "aborted" ? parseUtil_1.INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value), { status: status.value, value: inner.value });
|
|
2421
|
-
} else
|
|
2422
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => inner.status === "aborted" ? parseUtil_1.INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value).then(() => ({ status: status.value, value: inner.value }))));
|
|
2423
|
-
}
|
|
2424
|
-
if (effect.type === "transform")
|
|
2425
|
-
if (ctx.common.async === !1) {
|
|
2426
|
-
let base = this._def.schema._parseSync({
|
|
2427
|
-
data: ctx.data,
|
|
2428
|
-
path: ctx.path,
|
|
2429
|
-
parent: ctx
|
|
2430
|
-
});
|
|
2431
|
-
if (!(0, parseUtil_1.isValid)(base))
|
|
2432
|
-
return base;
|
|
2433
|
-
let result = effect.transform(base.value, checkCtx);
|
|
2434
|
-
if (result instanceof Promise)
|
|
2435
|
-
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2436
|
-
return { status: status.value, value: result };
|
|
2437
|
-
} else
|
|
2438
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => (0, parseUtil_1.isValid)(base) ? Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result })) : base);
|
|
2439
|
-
util_1.util.assertNever(effect);
|
|
2440
|
-
}
|
|
2441
|
-
};
|
|
2442
|
-
exports.ZodEffects = ZodEffects;
|
|
2443
|
-
exports.ZodTransformer = ZodEffects;
|
|
2444
|
-
ZodEffects.create = (schema, effect, params) => new ZodEffects({
|
|
2445
|
-
schema,
|
|
2446
|
-
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
2447
|
-
effect,
|
|
2448
|
-
...processCreateParams(params)
|
|
2449
|
-
});
|
|
2450
|
-
ZodEffects.createWithPreprocess = (preprocess, schema, params) => new ZodEffects({
|
|
2451
|
-
schema,
|
|
2452
|
-
effect: { type: "preprocess", transform: preprocess },
|
|
2453
|
-
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
2454
|
-
...processCreateParams(params)
|
|
2455
|
-
});
|
|
2456
|
-
var ZodOptional = class extends ZodType {
|
|
2457
|
-
_parse(input) {
|
|
2458
|
-
return this._getType(input) === util_1.ZodParsedType.undefined ? (0, parseUtil_1.OK)(void 0) : this._def.innerType._parse(input);
|
|
2459
|
-
}
|
|
2460
|
-
unwrap() {
|
|
2461
|
-
return this._def.innerType;
|
|
2462
|
-
}
|
|
2463
|
-
};
|
|
2464
|
-
exports.ZodOptional = ZodOptional;
|
|
2465
|
-
ZodOptional.create = (type, params) => new ZodOptional({
|
|
2466
|
-
innerType: type,
|
|
2467
|
-
typeName: ZodFirstPartyTypeKind.ZodOptional,
|
|
2468
|
-
...processCreateParams(params)
|
|
2469
|
-
});
|
|
2470
|
-
var ZodNullable = class extends ZodType {
|
|
2471
|
-
_parse(input) {
|
|
2472
|
-
return this._getType(input) === util_1.ZodParsedType.null ? (0, parseUtil_1.OK)(null) : this._def.innerType._parse(input);
|
|
2473
|
-
}
|
|
2474
|
-
unwrap() {
|
|
2475
|
-
return this._def.innerType;
|
|
2476
|
-
}
|
|
2477
|
-
};
|
|
2478
|
-
exports.ZodNullable = ZodNullable;
|
|
2479
|
-
ZodNullable.create = (type, params) => new ZodNullable({
|
|
2480
|
-
innerType: type,
|
|
2481
|
-
typeName: ZodFirstPartyTypeKind.ZodNullable,
|
|
2482
|
-
...processCreateParams(params)
|
|
2483
|
-
});
|
|
2484
|
-
var ZodDefault = class extends ZodType {
|
|
2485
|
-
_parse(input) {
|
|
2486
|
-
let { ctx } = this._processInputParams(input), data = ctx.data;
|
|
2487
|
-
return ctx.parsedType === util_1.ZodParsedType.undefined && (data = this._def.defaultValue()), this._def.innerType._parse({
|
|
2488
|
-
data,
|
|
2489
|
-
path: ctx.path,
|
|
2490
|
-
parent: ctx
|
|
2491
|
-
});
|
|
2492
|
-
}
|
|
2493
|
-
removeDefault() {
|
|
2494
|
-
return this._def.innerType;
|
|
2495
|
-
}
|
|
2496
|
-
};
|
|
2497
|
-
exports.ZodDefault = ZodDefault;
|
|
2498
|
-
ZodDefault.create = (type, params) => new ZodDefault({
|
|
2499
|
-
innerType: type,
|
|
2500
|
-
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
2501
|
-
defaultValue: typeof params.default == "function" ? params.default : () => params.default,
|
|
2502
|
-
...processCreateParams(params)
|
|
2503
|
-
});
|
|
2504
|
-
var ZodCatch = class extends ZodType {
|
|
2505
|
-
_parse(input) {
|
|
2506
|
-
let { ctx } = this._processInputParams(input), newCtx = {
|
|
2507
|
-
...ctx,
|
|
2508
|
-
common: {
|
|
2509
|
-
...ctx.common,
|
|
2510
|
-
issues: []
|
|
2511
|
-
}
|
|
2512
|
-
}, result = this._def.innerType._parse({
|
|
2513
|
-
data: newCtx.data,
|
|
2514
|
-
path: newCtx.path,
|
|
2515
|
-
parent: {
|
|
2516
|
-
...newCtx
|
|
2517
|
-
}
|
|
2518
|
-
});
|
|
2519
|
-
return (0, parseUtil_1.isAsync)(result) ? result.then((result2) => ({
|
|
2520
|
-
status: "valid",
|
|
2521
|
-
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
2522
|
-
get error() {
|
|
2523
|
-
return new ZodError_1.ZodError(newCtx.common.issues);
|
|
2524
|
-
},
|
|
2525
|
-
input: newCtx.data
|
|
2526
|
-
})
|
|
2527
|
-
})) : {
|
|
2528
|
-
status: "valid",
|
|
2529
|
-
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
2530
|
-
get error() {
|
|
2531
|
-
return new ZodError_1.ZodError(newCtx.common.issues);
|
|
2532
|
-
},
|
|
2533
|
-
input: newCtx.data
|
|
2534
|
-
})
|
|
2535
|
-
};
|
|
2536
|
-
}
|
|
2537
|
-
removeCatch() {
|
|
2538
|
-
return this._def.innerType;
|
|
2539
|
-
}
|
|
2540
|
-
};
|
|
2541
|
-
exports.ZodCatch = ZodCatch;
|
|
2542
|
-
ZodCatch.create = (type, params) => new ZodCatch({
|
|
2543
|
-
innerType: type,
|
|
2544
|
-
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
2545
|
-
catchValue: typeof params.catch == "function" ? params.catch : () => params.catch,
|
|
2546
|
-
...processCreateParams(params)
|
|
2547
|
-
});
|
|
2548
|
-
var ZodNaN = class extends ZodType {
|
|
2549
|
-
_parse(input) {
|
|
2550
|
-
if (this._getType(input) !== util_1.ZodParsedType.nan) {
|
|
2551
|
-
let ctx = this._getOrReturnCtx(input);
|
|
2552
|
-
return (0, parseUtil_1.addIssueToContext)(ctx, {
|
|
2553
|
-
code: ZodError_1.ZodIssueCode.invalid_type,
|
|
2554
|
-
expected: util_1.ZodParsedType.nan,
|
|
2555
|
-
received: ctx.parsedType
|
|
2556
|
-
}), parseUtil_1.INVALID;
|
|
2557
|
-
}
|
|
2558
|
-
return { status: "valid", value: input.data };
|
|
2559
|
-
}
|
|
2560
|
-
};
|
|
2561
|
-
exports.ZodNaN = ZodNaN;
|
|
2562
|
-
ZodNaN.create = (params) => new ZodNaN({
|
|
2563
|
-
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
2564
|
-
...processCreateParams(params)
|
|
2565
|
-
});
|
|
2566
|
-
exports.BRAND = Symbol("zod_brand");
|
|
2567
|
-
var ZodBranded = class extends ZodType {
|
|
2568
|
-
_parse(input) {
|
|
2569
|
-
let { ctx } = this._processInputParams(input), data = ctx.data;
|
|
2570
|
-
return this._def.type._parse({
|
|
2571
|
-
data,
|
|
2572
|
-
path: ctx.path,
|
|
2573
|
-
parent: ctx
|
|
2574
|
-
});
|
|
2575
|
-
}
|
|
2576
|
-
unwrap() {
|
|
2577
|
-
return this._def.type;
|
|
2578
|
-
}
|
|
2579
|
-
};
|
|
2580
|
-
exports.ZodBranded = ZodBranded;
|
|
2581
|
-
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
2582
|
-
_parse(input) {
|
|
2583
|
-
let { status, ctx } = this._processInputParams(input);
|
|
2584
|
-
if (ctx.common.async)
|
|
2585
|
-
return (async () => {
|
|
2586
|
-
let inResult = await this._def.in._parseAsync({
|
|
2587
|
-
data: ctx.data,
|
|
2588
|
-
path: ctx.path,
|
|
2589
|
-
parent: ctx
|
|
2590
|
-
});
|
|
2591
|
-
return inResult.status === "aborted" ? parseUtil_1.INVALID : inResult.status === "dirty" ? (status.dirty(), (0, parseUtil_1.DIRTY)(inResult.value)) : this._def.out._parseAsync({
|
|
2592
|
-
data: inResult.value,
|
|
2593
|
-
path: ctx.path,
|
|
2594
|
-
parent: ctx
|
|
2595
|
-
});
|
|
2596
|
-
})();
|
|
2597
|
-
{
|
|
2598
|
-
let inResult = this._def.in._parseSync({
|
|
2599
|
-
data: ctx.data,
|
|
2600
|
-
path: ctx.path,
|
|
2601
|
-
parent: ctx
|
|
2602
|
-
});
|
|
2603
|
-
return inResult.status === "aborted" ? parseUtil_1.INVALID : inResult.status === "dirty" ? (status.dirty(), {
|
|
2604
|
-
status: "dirty",
|
|
2605
|
-
value: inResult.value
|
|
2606
|
-
}) : this._def.out._parseSync({
|
|
2607
|
-
data: inResult.value,
|
|
2608
|
-
path: ctx.path,
|
|
2609
|
-
parent: ctx
|
|
2610
|
-
});
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
static create(a, b) {
|
|
2614
|
-
return new _ZodPipeline({
|
|
2615
|
-
in: a,
|
|
2616
|
-
out: b,
|
|
2617
|
-
typeName: ZodFirstPartyTypeKind.ZodPipeline
|
|
2618
|
-
});
|
|
2619
|
-
}
|
|
2620
|
-
};
|
|
2621
|
-
exports.ZodPipeline = ZodPipeline;
|
|
2622
|
-
var ZodReadonly = class extends ZodType {
|
|
2623
|
-
_parse(input) {
|
|
2624
|
-
let result = this._def.innerType._parse(input);
|
|
2625
|
-
return (0, parseUtil_1.isValid)(result) && (result.value = Object.freeze(result.value)), result;
|
|
2626
|
-
}
|
|
2627
|
-
};
|
|
2628
|
-
exports.ZodReadonly = ZodReadonly;
|
|
2629
|
-
ZodReadonly.create = (type, params) => new ZodReadonly({
|
|
2630
|
-
innerType: type,
|
|
2631
|
-
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
2632
|
-
...processCreateParams(params)
|
|
2633
|
-
});
|
|
2634
|
-
var custom = (check, params = {}, fatal) => check ? ZodAny.create().superRefine((data, ctx) => {
|
|
2635
|
-
var _a, _b;
|
|
2636
|
-
if (!check(data)) {
|
|
2637
|
-
let p = typeof params == "function" ? params(data) : typeof params == "string" ? { message: params } : params, _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : !0, p2 = typeof p == "string" ? { message: p } : p;
|
|
2638
|
-
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
|
|
2639
|
-
}
|
|
2640
|
-
}) : ZodAny.create();
|
|
2641
|
-
exports.custom = custom;
|
|
2642
|
-
exports.late = {
|
|
2643
|
-
object: ZodObject.lazycreate
|
|
2644
|
-
};
|
|
2645
|
-
var ZodFirstPartyTypeKind;
|
|
2646
|
-
(function(ZodFirstPartyTypeKind2) {
|
|
2647
|
-
ZodFirstPartyTypeKind2.ZodString = "ZodString", ZodFirstPartyTypeKind2.ZodNumber = "ZodNumber", ZodFirstPartyTypeKind2.ZodNaN = "ZodNaN", ZodFirstPartyTypeKind2.ZodBigInt = "ZodBigInt", ZodFirstPartyTypeKind2.ZodBoolean = "ZodBoolean", ZodFirstPartyTypeKind2.ZodDate = "ZodDate", ZodFirstPartyTypeKind2.ZodSymbol = "ZodSymbol", ZodFirstPartyTypeKind2.ZodUndefined = "ZodUndefined", ZodFirstPartyTypeKind2.ZodNull = "ZodNull", ZodFirstPartyTypeKind2.ZodAny = "ZodAny", ZodFirstPartyTypeKind2.ZodUnknown = "ZodUnknown", ZodFirstPartyTypeKind2.ZodNever = "ZodNever", ZodFirstPartyTypeKind2.ZodVoid = "ZodVoid", ZodFirstPartyTypeKind2.ZodArray = "ZodArray", ZodFirstPartyTypeKind2.ZodObject = "ZodObject", ZodFirstPartyTypeKind2.ZodUnion = "ZodUnion", ZodFirstPartyTypeKind2.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", ZodFirstPartyTypeKind2.ZodIntersection = "ZodIntersection", ZodFirstPartyTypeKind2.ZodTuple = "ZodTuple", ZodFirstPartyTypeKind2.ZodRecord = "ZodRecord", ZodFirstPartyTypeKind2.ZodMap = "ZodMap", ZodFirstPartyTypeKind2.ZodSet = "ZodSet", ZodFirstPartyTypeKind2.ZodFunction = "ZodFunction", ZodFirstPartyTypeKind2.ZodLazy = "ZodLazy", ZodFirstPartyTypeKind2.ZodLiteral = "ZodLiteral", ZodFirstPartyTypeKind2.ZodEnum = "ZodEnum", ZodFirstPartyTypeKind2.ZodEffects = "ZodEffects", ZodFirstPartyTypeKind2.ZodNativeEnum = "ZodNativeEnum", ZodFirstPartyTypeKind2.ZodOptional = "ZodOptional", ZodFirstPartyTypeKind2.ZodNullable = "ZodNullable", ZodFirstPartyTypeKind2.ZodDefault = "ZodDefault", ZodFirstPartyTypeKind2.ZodCatch = "ZodCatch", ZodFirstPartyTypeKind2.ZodPromise = "ZodPromise", ZodFirstPartyTypeKind2.ZodBranded = "ZodBranded", ZodFirstPartyTypeKind2.ZodPipeline = "ZodPipeline", ZodFirstPartyTypeKind2.ZodReadonly = "ZodReadonly";
|
|
2648
|
-
})(ZodFirstPartyTypeKind = exports.ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = {}));
|
|
2649
|
-
var instanceOfType = (cls, params = {
|
|
2650
|
-
message: `Input not instance of ${cls.name}`
|
|
2651
|
-
}) => (0, exports.custom)((data) => data instanceof cls, params);
|
|
2652
|
-
exports.instanceof = instanceOfType;
|
|
2653
|
-
var stringType = ZodString.create;
|
|
2654
|
-
exports.string = stringType;
|
|
2655
|
-
var numberType = ZodNumber.create;
|
|
2656
|
-
exports.number = numberType;
|
|
2657
|
-
var nanType = ZodNaN.create;
|
|
2658
|
-
exports.nan = nanType;
|
|
2659
|
-
var bigIntType = ZodBigInt.create;
|
|
2660
|
-
exports.bigint = bigIntType;
|
|
2661
|
-
var booleanType = ZodBoolean.create;
|
|
2662
|
-
exports.boolean = booleanType;
|
|
2663
|
-
var dateType = ZodDate.create;
|
|
2664
|
-
exports.date = dateType;
|
|
2665
|
-
var symbolType = ZodSymbol.create;
|
|
2666
|
-
exports.symbol = symbolType;
|
|
2667
|
-
var undefinedType = ZodUndefined.create;
|
|
2668
|
-
exports.undefined = undefinedType;
|
|
2669
|
-
var nullType = ZodNull.create;
|
|
2670
|
-
exports.null = nullType;
|
|
2671
|
-
var anyType = ZodAny.create;
|
|
2672
|
-
exports.any = anyType;
|
|
2673
|
-
var unknownType = ZodUnknown.create;
|
|
2674
|
-
exports.unknown = unknownType;
|
|
2675
|
-
var neverType = ZodNever.create;
|
|
2676
|
-
exports.never = neverType;
|
|
2677
|
-
var voidType = ZodVoid.create;
|
|
2678
|
-
exports.void = voidType;
|
|
2679
|
-
var arrayType = ZodArray.create;
|
|
2680
|
-
exports.array = arrayType;
|
|
2681
|
-
var objectType = ZodObject.create;
|
|
2682
|
-
exports.object = objectType;
|
|
2683
|
-
var strictObjectType = ZodObject.strictCreate;
|
|
2684
|
-
exports.strictObject = strictObjectType;
|
|
2685
|
-
var unionType = ZodUnion.create;
|
|
2686
|
-
exports.union = unionType;
|
|
2687
|
-
var discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
2688
|
-
exports.discriminatedUnion = discriminatedUnionType;
|
|
2689
|
-
var intersectionType = ZodIntersection.create;
|
|
2690
|
-
exports.intersection = intersectionType;
|
|
2691
|
-
var tupleType = ZodTuple.create;
|
|
2692
|
-
exports.tuple = tupleType;
|
|
2693
|
-
var recordType = ZodRecord.create;
|
|
2694
|
-
exports.record = recordType;
|
|
2695
|
-
var mapType = ZodMap.create;
|
|
2696
|
-
exports.map = mapType;
|
|
2697
|
-
var setType = ZodSet.create;
|
|
2698
|
-
exports.set = setType;
|
|
2699
|
-
var functionType = ZodFunction.create;
|
|
2700
|
-
exports.function = functionType;
|
|
2701
|
-
var lazyType = ZodLazy.create;
|
|
2702
|
-
exports.lazy = lazyType;
|
|
2703
|
-
var literalType = ZodLiteral.create;
|
|
2704
|
-
exports.literal = literalType;
|
|
2705
|
-
var enumType = ZodEnum.create;
|
|
2706
|
-
exports.enum = enumType;
|
|
2707
|
-
var nativeEnumType = ZodNativeEnum.create;
|
|
2708
|
-
exports.nativeEnum = nativeEnumType;
|
|
2709
|
-
var promiseType = ZodPromise.create;
|
|
2710
|
-
exports.promise = promiseType;
|
|
2711
|
-
var effectsType = ZodEffects.create;
|
|
2712
|
-
exports.effect = effectsType;
|
|
2713
|
-
exports.transformer = effectsType;
|
|
2714
|
-
var optionalType = ZodOptional.create;
|
|
2715
|
-
exports.optional = optionalType;
|
|
2716
|
-
var nullableType = ZodNullable.create;
|
|
2717
|
-
exports.nullable = nullableType;
|
|
2718
|
-
var preprocessType = ZodEffects.createWithPreprocess;
|
|
2719
|
-
exports.preprocess = preprocessType;
|
|
2720
|
-
var pipelineType = ZodPipeline.create;
|
|
2721
|
-
exports.pipeline = pipelineType;
|
|
2722
|
-
var ostring = () => stringType().optional();
|
|
2723
|
-
exports.ostring = ostring;
|
|
2724
|
-
var onumber = () => numberType().optional();
|
|
2725
|
-
exports.onumber = onumber;
|
|
2726
|
-
var oboolean = () => booleanType().optional();
|
|
2727
|
-
exports.oboolean = oboolean;
|
|
2728
|
-
exports.coerce = {
|
|
2729
|
-
string: (arg) => ZodString.create({ ...arg, coerce: !0 }),
|
|
2730
|
-
number: (arg) => ZodNumber.create({ ...arg, coerce: !0 }),
|
|
2731
|
-
boolean: (arg) => ZodBoolean.create({
|
|
2732
|
-
...arg,
|
|
2733
|
-
coerce: !0
|
|
2734
|
-
}),
|
|
2735
|
-
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: !0 }),
|
|
2736
|
-
date: (arg) => ZodDate.create({ ...arg, coerce: !0 })
|
|
2737
|
-
};
|
|
2738
|
-
exports.NEVER = parseUtil_1.INVALID;
|
|
2739
|
-
}
|
|
2740
|
-
});
|
|
2741
|
-
|
|
2742
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/external.js
|
|
2743
|
-
var require_external = __commonJS({
|
|
2744
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/external.js"(exports) {
|
|
2745
|
-
"use strict";
|
|
2746
|
-
init_cjs_shims();
|
|
2747
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2748
|
-
k2 === void 0 && (k2 = k), Object.defineProperty(o, k2, { enumerable: !0, get: function() {
|
|
2749
|
-
return m[k];
|
|
2750
|
-
} });
|
|
2751
|
-
} : function(o, m, k, k2) {
|
|
2752
|
-
k2 === void 0 && (k2 = k), o[k2] = m[k];
|
|
2753
|
-
}), __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
2754
|
-
for (var p in m)
|
|
2755
|
-
p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p) && __createBinding(exports2, m, p);
|
|
2756
|
-
};
|
|
2757
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2758
|
-
__exportStar(require_errors(), exports);
|
|
2759
|
-
__exportStar(require_parseUtil(), exports);
|
|
2760
|
-
__exportStar(require_typeAliases(), exports);
|
|
2761
|
-
__exportStar(require_util(), exports);
|
|
2762
|
-
__exportStar(require_types(), exports);
|
|
2763
|
-
__exportStar(require_ZodError(), exports);
|
|
2764
|
-
}
|
|
2765
|
-
});
|
|
2766
|
-
|
|
2767
|
-
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.js
|
|
2768
|
-
var require_lib = __commonJS({
|
|
2769
|
-
"../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.js"(exports) {
|
|
2770
|
-
"use strict";
|
|
2771
|
-
init_cjs_shims();
|
|
2772
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2773
|
-
k2 === void 0 && (k2 = k), Object.defineProperty(o, k2, { enumerable: !0, get: function() {
|
|
2774
|
-
return m[k];
|
|
2775
|
-
} });
|
|
2776
|
-
} : function(o, m, k, k2) {
|
|
2777
|
-
k2 === void 0 && (k2 = k), o[k2] = m[k];
|
|
2778
|
-
}), __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
2779
|
-
Object.defineProperty(o, "default", { enumerable: !0, value: v });
|
|
2780
|
-
} : function(o, v) {
|
|
2781
|
-
o.default = v;
|
|
2782
|
-
}), __importStar = exports && exports.__importStar || function(mod) {
|
|
2783
|
-
if (mod && mod.__esModule)
|
|
2784
|
-
return mod;
|
|
2785
|
-
var result = {};
|
|
2786
|
-
if (mod != null)
|
|
2787
|
-
for (var k in mod)
|
|
2788
|
-
k !== "default" && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
|
|
2789
|
-
return __setModuleDefault(result, mod), result;
|
|
2790
|
-
}, __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
2791
|
-
for (var p in m)
|
|
2792
|
-
p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p) && __createBinding(exports2, m, p);
|
|
2793
|
-
};
|
|
2794
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2795
|
-
exports.z = void 0;
|
|
2796
|
-
var z = __importStar(require_external());
|
|
2797
|
-
exports.z = z;
|
|
2798
|
-
__exportStar(require_external(), exports);
|
|
2799
|
-
exports.default = z;
|
|
2800
|
-
}
|
|
2801
|
-
});
|
|
2802
|
-
|
|
2803
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/any.js
|
|
2804
|
-
var require_any = __commonJS({
|
|
2805
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/any.js"(exports) {
|
|
2806
|
-
"use strict";
|
|
2807
|
-
init_cjs_shims();
|
|
2808
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2809
|
-
exports.parseAnyDef = void 0;
|
|
2810
|
-
function parseAnyDef() {
|
|
2811
|
-
return {};
|
|
2812
|
-
}
|
|
2813
|
-
exports.parseAnyDef = parseAnyDef;
|
|
2814
|
-
}
|
|
2815
|
-
});
|
|
2816
|
-
|
|
2817
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/errorMessages.js
|
|
2818
|
-
var require_errorMessages = __commonJS({
|
|
2819
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/errorMessages.js"(exports) {
|
|
2820
|
-
"use strict";
|
|
2821
|
-
init_cjs_shims();
|
|
2822
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2823
|
-
exports.setResponseValueAndErrors = exports.addErrorMessage = void 0;
|
|
2824
|
-
function addErrorMessage(res, key, errorMessage, refs) {
|
|
2825
|
-
refs?.errorMessages && errorMessage && (res.errorMessage = Object.assign(Object.assign({}, res.errorMessage), { [key]: errorMessage }));
|
|
2826
|
-
}
|
|
2827
|
-
exports.addErrorMessage = addErrorMessage;
|
|
2828
|
-
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
2829
|
-
res[key] = value, addErrorMessage(res, key, errorMessage, refs);
|
|
2830
|
-
}
|
|
2831
|
-
exports.setResponseValueAndErrors = setResponseValueAndErrors;
|
|
2832
|
-
}
|
|
2833
|
-
});
|
|
2834
|
-
|
|
2835
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/array.js
|
|
2836
|
-
var require_array = __commonJS({
|
|
2837
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/array.js"(exports) {
|
|
2838
|
-
"use strict";
|
|
2839
|
-
init_cjs_shims();
|
|
2840
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2841
|
-
exports.parseArrayDef = void 0;
|
|
2842
|
-
var zod_1 = require_lib(), errorMessages_1 = require_errorMessages(), parseDef_1 = require_parseDef();
|
|
2843
|
-
function parseArrayDef(def, refs) {
|
|
2844
|
-
var _a, _b;
|
|
2845
|
-
let res = {
|
|
2846
|
-
type: "array"
|
|
2847
|
-
};
|
|
2848
|
-
return ((_b = (_a = def.type) === null || _a === void 0 ? void 0 : _a._def) === null || _b === void 0 ? void 0 : _b.typeName) !== zod_1.ZodFirstPartyTypeKind.ZodAny && (res.items = (0, parseDef_1.parseDef)(def.type._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "items"] }))), def.minLength && (0, errorMessages_1.setResponseValueAndErrors)(res, "minItems", def.minLength.value, def.minLength.message, refs), def.maxLength && (0, errorMessages_1.setResponseValueAndErrors)(res, "maxItems", def.maxLength.value, def.maxLength.message, refs), def.exactLength && ((0, errorMessages_1.setResponseValueAndErrors)(res, "minItems", def.exactLength.value, def.exactLength.message, refs), (0, errorMessages_1.setResponseValueAndErrors)(res, "maxItems", def.exactLength.value, def.exactLength.message, refs)), res;
|
|
2849
|
-
}
|
|
2850
|
-
exports.parseArrayDef = parseArrayDef;
|
|
2851
|
-
}
|
|
2852
|
-
});
|
|
2853
|
-
|
|
2854
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/bigint.js
|
|
2855
|
-
var require_bigint = __commonJS({
|
|
2856
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/bigint.js"(exports) {
|
|
2857
|
-
"use strict";
|
|
2858
|
-
init_cjs_shims();
|
|
2859
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2860
|
-
exports.parseBigintDef = void 0;
|
|
2861
|
-
var errorMessages_1 = require_errorMessages();
|
|
2862
|
-
function parseBigintDef(def, refs) {
|
|
2863
|
-
let res = {
|
|
2864
|
-
type: "integer",
|
|
2865
|
-
format: "int64"
|
|
2866
|
-
};
|
|
2867
|
-
if (!def.checks)
|
|
2868
|
-
return res;
|
|
2869
|
-
for (let check of def.checks)
|
|
2870
|
-
switch (check.kind) {
|
|
2871
|
-
case "min":
|
|
2872
|
-
refs.target === "jsonSchema7" ? check.inclusive ? (0, errorMessages_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs) : (0, errorMessages_1.setResponseValueAndErrors)(res, "exclusiveMinimum", check.value, check.message, refs) : (check.inclusive || (res.exclusiveMinimum = !0), (0, errorMessages_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs));
|
|
2873
|
-
break;
|
|
2874
|
-
case "max":
|
|
2875
|
-
refs.target === "jsonSchema7" ? check.inclusive ? (0, errorMessages_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs) : (0, errorMessages_1.setResponseValueAndErrors)(res, "exclusiveMaximum", check.value, check.message, refs) : (check.inclusive || (res.exclusiveMaximum = !0), (0, errorMessages_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs));
|
|
2876
|
-
break;
|
|
2877
|
-
case "multipleOf":
|
|
2878
|
-
(0, errorMessages_1.setResponseValueAndErrors)(res, "multipleOf", check.value, check.message, refs);
|
|
2879
|
-
break;
|
|
2880
|
-
}
|
|
2881
|
-
return res;
|
|
2882
|
-
}
|
|
2883
|
-
exports.parseBigintDef = parseBigintDef;
|
|
2884
|
-
}
|
|
2885
|
-
});
|
|
2886
|
-
|
|
2887
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/boolean.js
|
|
2888
|
-
var require_boolean = __commonJS({
|
|
2889
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/boolean.js"(exports) {
|
|
2890
|
-
"use strict";
|
|
2891
|
-
init_cjs_shims();
|
|
2892
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2893
|
-
exports.parseBooleanDef = void 0;
|
|
2894
|
-
function parseBooleanDef() {
|
|
2895
|
-
return {
|
|
2896
|
-
type: "boolean"
|
|
2897
|
-
};
|
|
2898
|
-
}
|
|
2899
|
-
exports.parseBooleanDef = parseBooleanDef;
|
|
2900
|
-
}
|
|
2901
|
-
});
|
|
2902
|
-
|
|
2903
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/branded.js
|
|
2904
|
-
var require_branded = __commonJS({
|
|
2905
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/branded.js"(exports) {
|
|
2906
|
-
"use strict";
|
|
2907
|
-
init_cjs_shims();
|
|
2908
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2909
|
-
exports.parseBrandedDef = void 0;
|
|
2910
|
-
var parseDef_1 = require_parseDef();
|
|
2911
|
-
function parseBrandedDef(_def, refs) {
|
|
2912
|
-
return (0, parseDef_1.parseDef)(_def.type._def, refs);
|
|
2913
|
-
}
|
|
2914
|
-
exports.parseBrandedDef = parseBrandedDef;
|
|
2915
|
-
}
|
|
2916
|
-
});
|
|
2917
|
-
|
|
2918
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/catch.js
|
|
2919
|
-
var require_catch = __commonJS({
|
|
2920
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/catch.js"(exports) {
|
|
2921
|
-
"use strict";
|
|
2922
|
-
init_cjs_shims();
|
|
2923
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2924
|
-
exports.parseCatchDef = void 0;
|
|
2925
|
-
var parseDef_1 = require_parseDef(), parseCatchDef = (def, refs) => (0, parseDef_1.parseDef)(def.innerType._def, refs);
|
|
2926
|
-
exports.parseCatchDef = parseCatchDef;
|
|
2927
|
-
}
|
|
2928
|
-
});
|
|
2929
|
-
|
|
2930
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/date.js
|
|
2931
|
-
var require_date = __commonJS({
|
|
2932
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/date.js"(exports) {
|
|
2933
|
-
"use strict";
|
|
2934
|
-
init_cjs_shims();
|
|
2935
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2936
|
-
exports.parseDateDef = void 0;
|
|
2937
|
-
var errorMessages_1 = require_errorMessages();
|
|
2938
|
-
function parseDateDef(def, refs) {
|
|
2939
|
-
return refs.dateStrategy == "integer" ? integerDateParser(def, refs) : {
|
|
2940
|
-
type: "string",
|
|
2941
|
-
format: "date-time"
|
|
2942
|
-
};
|
|
2943
|
-
}
|
|
2944
|
-
exports.parseDateDef = parseDateDef;
|
|
2945
|
-
var integerDateParser = (def, refs) => {
|
|
2946
|
-
let res = {
|
|
2947
|
-
type: "integer",
|
|
2948
|
-
format: "unix-time"
|
|
2949
|
-
};
|
|
2950
|
-
for (let check of def.checks)
|
|
2951
|
-
switch (check.kind) {
|
|
2952
|
-
case "min":
|
|
2953
|
-
refs.target === "jsonSchema7" && (0, errorMessages_1.setResponseValueAndErrors)(
|
|
2954
|
-
res,
|
|
2955
|
-
"minimum",
|
|
2956
|
-
check.value,
|
|
2957
|
-
// This is in milliseconds
|
|
2958
|
-
check.message,
|
|
2959
|
-
refs
|
|
2960
|
-
);
|
|
2961
|
-
break;
|
|
2962
|
-
case "max":
|
|
2963
|
-
refs.target === "jsonSchema7" && (0, errorMessages_1.setResponseValueAndErrors)(
|
|
2964
|
-
res,
|
|
2965
|
-
"maximum",
|
|
2966
|
-
check.value,
|
|
2967
|
-
// This is in milliseconds
|
|
2968
|
-
check.message,
|
|
2969
|
-
refs
|
|
2970
|
-
);
|
|
2971
|
-
break;
|
|
2972
|
-
}
|
|
2973
|
-
return res;
|
|
2974
|
-
};
|
|
2975
|
-
}
|
|
2976
|
-
});
|
|
2977
|
-
|
|
2978
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/default.js
|
|
2979
|
-
var require_default = __commonJS({
|
|
2980
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/default.js"(exports) {
|
|
2981
|
-
"use strict";
|
|
2982
|
-
init_cjs_shims();
|
|
2983
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2984
|
-
exports.parseDefaultDef = void 0;
|
|
2985
|
-
var parseDef_1 = require_parseDef();
|
|
2986
|
-
function parseDefaultDef(_def, refs) {
|
|
2987
|
-
return Object.assign(Object.assign({}, (0, parseDef_1.parseDef)(_def.innerType._def, refs)), { default: _def.defaultValue() });
|
|
2988
|
-
}
|
|
2989
|
-
exports.parseDefaultDef = parseDefaultDef;
|
|
2990
|
-
}
|
|
2991
|
-
});
|
|
2992
|
-
|
|
2993
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/effects.js
|
|
2994
|
-
var require_effects = __commonJS({
|
|
2995
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/effects.js"(exports) {
|
|
2996
|
-
"use strict";
|
|
2997
|
-
init_cjs_shims();
|
|
2998
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2999
|
-
exports.parseEffectsDef = void 0;
|
|
3000
|
-
var parseDef_1 = require_parseDef();
|
|
3001
|
-
function parseEffectsDef(_def, refs) {
|
|
3002
|
-
return refs.effectStrategy === "input" ? (0, parseDef_1.parseDef)(_def.schema._def, refs) : {};
|
|
3003
|
-
}
|
|
3004
|
-
exports.parseEffectsDef = parseEffectsDef;
|
|
3005
|
-
}
|
|
3006
|
-
});
|
|
3007
|
-
|
|
3008
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/enum.js
|
|
3009
|
-
var require_enum = __commonJS({
|
|
3010
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/enum.js"(exports) {
|
|
3011
|
-
"use strict";
|
|
3012
|
-
init_cjs_shims();
|
|
3013
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3014
|
-
exports.parseEnumDef = void 0;
|
|
3015
|
-
function parseEnumDef(def) {
|
|
3016
|
-
return {
|
|
3017
|
-
type: "string",
|
|
3018
|
-
enum: def.values
|
|
3019
|
-
};
|
|
3020
|
-
}
|
|
3021
|
-
exports.parseEnumDef = parseEnumDef;
|
|
3022
|
-
}
|
|
3023
|
-
});
|
|
3024
|
-
|
|
3025
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/intersection.js
|
|
3026
|
-
var require_intersection = __commonJS({
|
|
3027
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/intersection.js"(exports) {
|
|
3028
|
-
"use strict";
|
|
3029
|
-
init_cjs_shims();
|
|
3030
|
-
var __rest = exports && exports.__rest || function(s, e) {
|
|
3031
|
-
var t = {};
|
|
3032
|
-
for (var p in s)
|
|
3033
|
-
Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
3034
|
-
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
3035
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
3036
|
-
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
3037
|
-
return t;
|
|
3038
|
-
};
|
|
3039
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3040
|
-
exports.parseIntersectionDef = void 0;
|
|
3041
|
-
var parseDef_1 = require_parseDef(), isJsonSchema7AllOfType = (type) => "type" in type && type.type === "string" ? !1 : "allOf" in type;
|
|
3042
|
-
function parseIntersectionDef(def, refs) {
|
|
3043
|
-
let allOf = [
|
|
3044
|
-
(0, parseDef_1.parseDef)(def.left._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "allOf", "0"] })),
|
|
3045
|
-
(0, parseDef_1.parseDef)(def.right._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "allOf", "1"] }))
|
|
3046
|
-
].filter((x) => !!x), unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: !1 } : void 0, mergedAllOf = [];
|
|
3047
|
-
return allOf.forEach((schema) => {
|
|
3048
|
-
if (isJsonSchema7AllOfType(schema))
|
|
3049
|
-
mergedAllOf.push(...schema.allOf), schema.unevaluatedProperties === void 0 && (unevaluatedProperties = void 0);
|
|
3050
|
-
else {
|
|
3051
|
-
let nestedSchema = schema;
|
|
3052
|
-
if ("additionalProperties" in schema && schema.additionalProperties === !1) {
|
|
3053
|
-
let { additionalProperties } = schema;
|
|
3054
|
-
nestedSchema = __rest(schema, ["additionalProperties"]);
|
|
3055
|
-
} else
|
|
3056
|
-
unevaluatedProperties = void 0;
|
|
3057
|
-
mergedAllOf.push(nestedSchema);
|
|
3058
|
-
}
|
|
3059
|
-
}), mergedAllOf.length ? Object.assign({ allOf: mergedAllOf }, unevaluatedProperties) : void 0;
|
|
3060
|
-
}
|
|
3061
|
-
exports.parseIntersectionDef = parseIntersectionDef;
|
|
3062
|
-
}
|
|
3063
|
-
});
|
|
3064
|
-
|
|
3065
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/literal.js
|
|
3066
|
-
var require_literal = __commonJS({
|
|
3067
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/literal.js"(exports) {
|
|
3068
|
-
"use strict";
|
|
3069
|
-
init_cjs_shims();
|
|
3070
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3071
|
-
exports.parseLiteralDef = void 0;
|
|
3072
|
-
function parseLiteralDef(def, refs) {
|
|
3073
|
-
let parsedType = typeof def.value;
|
|
3074
|
-
return parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string" ? {
|
|
3075
|
-
type: Array.isArray(def.value) ? "array" : "object"
|
|
3076
|
-
} : refs.target === "openApi3" ? {
|
|
3077
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
3078
|
-
enum: [def.value]
|
|
3079
|
-
} : {
|
|
3080
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
3081
|
-
const: def.value
|
|
3082
|
-
};
|
|
3083
|
-
}
|
|
3084
|
-
exports.parseLiteralDef = parseLiteralDef;
|
|
3085
|
-
}
|
|
3086
|
-
});
|
|
3087
|
-
|
|
3088
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/map.js
|
|
3089
|
-
var require_map = __commonJS({
|
|
3090
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/map.js"(exports) {
|
|
3091
|
-
"use strict";
|
|
3092
|
-
init_cjs_shims();
|
|
3093
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3094
|
-
exports.parseMapDef = void 0;
|
|
3095
|
-
var parseDef_1 = require_parseDef();
|
|
3096
|
-
function parseMapDef(def, refs) {
|
|
3097
|
-
let keys = (0, parseDef_1.parseDef)(def.keyType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "items", "items", "0"] })) || {}, values = (0, parseDef_1.parseDef)(def.valueType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "items", "items", "1"] })) || {};
|
|
3098
|
-
return {
|
|
3099
|
-
type: "array",
|
|
3100
|
-
maxItems: 125,
|
|
3101
|
-
items: {
|
|
3102
|
-
type: "array",
|
|
3103
|
-
items: [keys, values],
|
|
3104
|
-
minItems: 2,
|
|
3105
|
-
maxItems: 2
|
|
3106
|
-
}
|
|
3107
|
-
};
|
|
3108
|
-
}
|
|
3109
|
-
exports.parseMapDef = parseMapDef;
|
|
3110
|
-
}
|
|
3111
|
-
});
|
|
3112
|
-
|
|
3113
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/nativeEnum.js
|
|
3114
|
-
var require_nativeEnum = __commonJS({
|
|
3115
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/nativeEnum.js"(exports) {
|
|
3116
|
-
"use strict";
|
|
3117
|
-
init_cjs_shims();
|
|
3118
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3119
|
-
exports.parseNativeEnumDef = void 0;
|
|
3120
|
-
function parseNativeEnumDef(def) {
|
|
3121
|
-
let object = def.values, actualValues = Object.keys(def.values).filter((key) => typeof object[object[key]] != "number").map((key) => object[key]), parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
3122
|
-
return {
|
|
3123
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
3124
|
-
enum: actualValues
|
|
3125
|
-
};
|
|
3126
|
-
}
|
|
3127
|
-
exports.parseNativeEnumDef = parseNativeEnumDef;
|
|
3128
|
-
}
|
|
3129
|
-
});
|
|
3130
|
-
|
|
3131
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/never.js
|
|
3132
|
-
var require_never = __commonJS({
|
|
3133
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/never.js"(exports) {
|
|
3134
|
-
"use strict";
|
|
3135
|
-
init_cjs_shims();
|
|
3136
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3137
|
-
exports.parseNeverDef = void 0;
|
|
3138
|
-
function parseNeverDef() {
|
|
3139
|
-
return {
|
|
3140
|
-
not: {}
|
|
3141
|
-
};
|
|
3142
|
-
}
|
|
3143
|
-
exports.parseNeverDef = parseNeverDef;
|
|
3144
|
-
}
|
|
3145
|
-
});
|
|
3146
|
-
|
|
3147
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/null.js
|
|
3148
|
-
var require_null = __commonJS({
|
|
3149
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/null.js"(exports) {
|
|
3150
|
-
"use strict";
|
|
3151
|
-
init_cjs_shims();
|
|
3152
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3153
|
-
exports.parseNullDef = void 0;
|
|
3154
|
-
function parseNullDef(refs) {
|
|
3155
|
-
return refs.target === "openApi3" ? {
|
|
3156
|
-
enum: ["null"],
|
|
3157
|
-
nullable: !0
|
|
3158
|
-
} : {
|
|
3159
|
-
type: "null"
|
|
3160
|
-
};
|
|
3161
|
-
}
|
|
3162
|
-
exports.parseNullDef = parseNullDef;
|
|
3163
|
-
}
|
|
3164
|
-
});
|
|
3165
|
-
|
|
3166
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/union.js
|
|
3167
|
-
var require_union = __commonJS({
|
|
3168
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/union.js"(exports) {
|
|
3169
|
-
"use strict";
|
|
3170
|
-
init_cjs_shims();
|
|
3171
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3172
|
-
exports.parseUnionDef = exports.primitiveMappings = void 0;
|
|
3173
|
-
var parseDef_1 = require_parseDef();
|
|
3174
|
-
exports.primitiveMappings = {
|
|
3175
|
-
ZodString: "string",
|
|
3176
|
-
ZodNumber: "number",
|
|
3177
|
-
ZodBigInt: "integer",
|
|
3178
|
-
ZodBoolean: "boolean",
|
|
3179
|
-
ZodNull: "null"
|
|
3180
|
-
};
|
|
3181
|
-
function parseUnionDef(def, refs) {
|
|
3182
|
-
if (refs.target === "openApi3")
|
|
3183
|
-
return asAnyOf(def, refs);
|
|
3184
|
-
let options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
3185
|
-
if (options.every((x) => x._def.typeName in exports.primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
3186
|
-
let types = options.reduce((types2, x) => {
|
|
3187
|
-
let type = exports.primitiveMappings[x._def.typeName];
|
|
3188
|
-
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
3189
|
-
}, []);
|
|
3190
|
-
return {
|
|
3191
|
-
type: types.length > 1 ? types : types[0]
|
|
3192
|
-
};
|
|
3193
|
-
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
3194
|
-
let types = options.reduce((acc, x) => {
|
|
3195
|
-
let type = typeof x._def.value;
|
|
3196
|
-
switch (type) {
|
|
3197
|
-
case "string":
|
|
3198
|
-
case "number":
|
|
3199
|
-
case "boolean":
|
|
3200
|
-
return [...acc, type];
|
|
3201
|
-
case "bigint":
|
|
3202
|
-
return [...acc, "integer"];
|
|
3203
|
-
case "object":
|
|
3204
|
-
if (x._def.value === null)
|
|
3205
|
-
return [...acc, "null"];
|
|
3206
|
-
case "symbol":
|
|
3207
|
-
case "undefined":
|
|
3208
|
-
case "function":
|
|
3209
|
-
default:
|
|
3210
|
-
return acc;
|
|
3211
|
-
}
|
|
3212
|
-
}, []);
|
|
3213
|
-
if (types.length === options.length) {
|
|
3214
|
-
let uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
3215
|
-
return {
|
|
3216
|
-
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
3217
|
-
enum: options.reduce((acc, x) => acc.includes(x._def.value) ? acc : [...acc, x._def.value], [])
|
|
3218
|
-
};
|
|
3219
|
-
}
|
|
3220
|
-
} else if (options.every((x) => x._def.typeName === "ZodEnum"))
|
|
3221
|
-
return {
|
|
3222
|
-
type: "string",
|
|
3223
|
-
enum: options.reduce((acc, x) => [
|
|
3224
|
-
...acc,
|
|
3225
|
-
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
3226
|
-
], [])
|
|
3227
|
-
};
|
|
3228
|
-
return asAnyOf(def, refs);
|
|
3229
|
-
}
|
|
3230
|
-
exports.parseUnionDef = parseUnionDef;
|
|
3231
|
-
var asAnyOf = (def, refs) => {
|
|
3232
|
-
let anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => (0, parseDef_1.parseDef)(x._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "anyOf", `${i}`] }))).filter((x) => !!x && (!refs.strictUnions || typeof x == "object" && Object.keys(x).length > 0));
|
|
3233
|
-
return anyOf.length ? { anyOf } : void 0;
|
|
3234
|
-
};
|
|
3235
|
-
}
|
|
3236
|
-
});
|
|
3237
|
-
|
|
3238
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/nullable.js
|
|
3239
|
-
var require_nullable = __commonJS({
|
|
3240
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/nullable.js"(exports) {
|
|
3241
|
-
"use strict";
|
|
3242
|
-
init_cjs_shims();
|
|
3243
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3244
|
-
exports.parseNullableDef = void 0;
|
|
3245
|
-
var parseDef_1 = require_parseDef(), union_1 = require_union();
|
|
3246
|
-
function parseNullableDef(def, refs) {
|
|
3247
|
-
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length))
|
|
3248
|
-
return refs.target === "openApi3" ? {
|
|
3249
|
-
type: union_1.primitiveMappings[def.innerType._def.typeName],
|
|
3250
|
-
nullable: !0
|
|
3251
|
-
} : {
|
|
3252
|
-
type: [
|
|
3253
|
-
union_1.primitiveMappings[def.innerType._def.typeName],
|
|
3254
|
-
"null"
|
|
3255
|
-
]
|
|
3256
|
-
};
|
|
3257
|
-
if (refs.target === "openApi3") {
|
|
3258
|
-
let base2 = (0, parseDef_1.parseDef)(def.innerType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath] }));
|
|
3259
|
-
return base2 && Object.assign(Object.assign({}, base2), { nullable: !0 });
|
|
3260
|
-
}
|
|
3261
|
-
let base = (0, parseDef_1.parseDef)(def.innerType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "anyOf", "0"] }));
|
|
3262
|
-
return base && { anyOf: [base, { type: "null" }] };
|
|
3263
|
-
}
|
|
3264
|
-
exports.parseNullableDef = parseNullableDef;
|
|
3265
|
-
}
|
|
3266
|
-
});
|
|
3267
|
-
|
|
3268
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/number.js
|
|
3269
|
-
var require_number = __commonJS({
|
|
3270
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/number.js"(exports) {
|
|
3271
|
-
"use strict";
|
|
3272
|
-
init_cjs_shims();
|
|
3273
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3274
|
-
exports.parseNumberDef = void 0;
|
|
3275
|
-
var errorMessages_1 = require_errorMessages();
|
|
3276
|
-
function parseNumberDef(def, refs) {
|
|
3277
|
-
let res = {
|
|
3278
|
-
type: "number"
|
|
3279
|
-
};
|
|
3280
|
-
if (!def.checks)
|
|
3281
|
-
return res;
|
|
3282
|
-
for (let check of def.checks)
|
|
3283
|
-
switch (check.kind) {
|
|
3284
|
-
case "int":
|
|
3285
|
-
res.type = "integer", (0, errorMessages_1.addErrorMessage)(res, "type", check.message, refs);
|
|
3286
|
-
break;
|
|
3287
|
-
case "min":
|
|
3288
|
-
refs.target === "jsonSchema7" ? check.inclusive ? (0, errorMessages_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs) : (0, errorMessages_1.setResponseValueAndErrors)(res, "exclusiveMinimum", check.value, check.message, refs) : (check.inclusive || (res.exclusiveMinimum = !0), (0, errorMessages_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs));
|
|
3289
|
-
break;
|
|
3290
|
-
case "max":
|
|
3291
|
-
refs.target === "jsonSchema7" ? check.inclusive ? (0, errorMessages_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs) : (0, errorMessages_1.setResponseValueAndErrors)(res, "exclusiveMaximum", check.value, check.message, refs) : (check.inclusive || (res.exclusiveMaximum = !0), (0, errorMessages_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs));
|
|
3292
|
-
break;
|
|
3293
|
-
case "multipleOf":
|
|
3294
|
-
(0, errorMessages_1.setResponseValueAndErrors)(res, "multipleOf", check.value, check.message, refs);
|
|
3295
|
-
break;
|
|
3296
|
-
}
|
|
3297
|
-
return res;
|
|
3298
|
-
}
|
|
3299
|
-
exports.parseNumberDef = parseNumberDef;
|
|
3300
|
-
}
|
|
3301
|
-
});
|
|
3302
|
-
|
|
3303
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/object.js
|
|
3304
|
-
var require_object = __commonJS({
|
|
3305
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/object.js"(exports) {
|
|
3306
|
-
"use strict";
|
|
3307
|
-
init_cjs_shims();
|
|
3308
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3309
|
-
exports.parseObjectDef = exports.parseObjectDefX = void 0;
|
|
3310
|
-
var parseDef_1 = require_parseDef();
|
|
3311
|
-
function parseObjectDefX(def, refs) {
|
|
3312
|
-
var _a, _b;
|
|
3313
|
-
Object.keys(def.shape()).reduce((schema, key) => {
|
|
3314
|
-
let prop = def.shape()[key], isOptional = prop.isOptional();
|
|
3315
|
-
isOptional || (prop = Object.assign({}, prop._def.innerSchema));
|
|
3316
|
-
let propSchema = (0, parseDef_1.parseDef)(prop._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "properties", key], propertyPath: [...refs.currentPath, "properties", key] }));
|
|
3317
|
-
return propSchema !== void 0 && (schema.properties[key] = propSchema, isOptional || (schema.required || (schema.required = []), schema.required.push(key))), schema;
|
|
3318
|
-
}, {
|
|
3319
|
-
type: "object",
|
|
3320
|
-
properties: {},
|
|
3321
|
-
additionalProperties: def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : (_a = (0, parseDef_1.parseDef)(def.catchall._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "additionalProperties"] }))) !== null && _a !== void 0 ? _a : !0
|
|
3322
|
-
});
|
|
3323
|
-
let result = Object.assign(Object.assign({ type: "object" }, Object.entries(def.shape()).reduce((acc, [propName, propDef]) => {
|
|
3324
|
-
if (propDef === void 0 || propDef._def === void 0)
|
|
3325
|
-
return acc;
|
|
3326
|
-
let parsedDef = (0, parseDef_1.parseDef)(propDef._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "properties", propName], propertyPath: [...refs.currentPath, "properties", propName] }));
|
|
3327
|
-
return parsedDef === void 0 ? acc : {
|
|
3328
|
-
properties: Object.assign(Object.assign({}, acc.properties), { [propName]: parsedDef }),
|
|
3329
|
-
required: propDef.isOptional() ? acc.required : [...acc.required, propName]
|
|
3330
|
-
};
|
|
3331
|
-
}, { properties: {}, required: [] })), { additionalProperties: def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : (_b = (0, parseDef_1.parseDef)(def.catchall._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "additionalProperties"] }))) !== null && _b !== void 0 ? _b : !0 });
|
|
3332
|
-
return result.required.length || delete result.required, result;
|
|
3333
|
-
}
|
|
3334
|
-
exports.parseObjectDefX = parseObjectDefX;
|
|
3335
|
-
function parseObjectDef(def, refs) {
|
|
3336
|
-
var _a;
|
|
3337
|
-
let result = Object.assign(Object.assign({ type: "object" }, Object.entries(def.shape()).reduce((acc, [propName, propDef]) => {
|
|
3338
|
-
if (propDef === void 0 || propDef._def === void 0)
|
|
3339
|
-
return acc;
|
|
3340
|
-
let parsedDef = (0, parseDef_1.parseDef)(propDef._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "properties", propName], propertyPath: [...refs.currentPath, "properties", propName] }));
|
|
3341
|
-
return parsedDef === void 0 ? acc : {
|
|
3342
|
-
properties: Object.assign(Object.assign({}, acc.properties), { [propName]: parsedDef }),
|
|
3343
|
-
required: propDef.isOptional() ? acc.required : [...acc.required, propName]
|
|
3344
|
-
};
|
|
3345
|
-
}, { properties: {}, required: [] })), { additionalProperties: def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : (_a = (0, parseDef_1.parseDef)(def.catchall._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "additionalProperties"] }))) !== null && _a !== void 0 ? _a : !0 });
|
|
3346
|
-
return result.required.length || delete result.required, result;
|
|
3347
|
-
}
|
|
3348
|
-
exports.parseObjectDef = parseObjectDef;
|
|
3349
|
-
}
|
|
3350
|
-
});
|
|
3351
|
-
|
|
3352
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/optional.js
|
|
3353
|
-
var require_optional = __commonJS({
|
|
3354
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/optional.js"(exports) {
|
|
3355
|
-
"use strict";
|
|
3356
|
-
init_cjs_shims();
|
|
3357
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3358
|
-
exports.parseOptionalDef = void 0;
|
|
3359
|
-
var parseDef_1 = require_parseDef(), parseOptionalDef = (def, refs) => {
|
|
3360
|
-
var _a;
|
|
3361
|
-
if (refs.currentPath.toString() === ((_a = refs.propertyPath) === null || _a === void 0 ? void 0 : _a.toString()))
|
|
3362
|
-
return (0, parseDef_1.parseDef)(def.innerType._def, refs);
|
|
3363
|
-
let innerSchema = (0, parseDef_1.parseDef)(def.innerType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "anyOf", "1"] }));
|
|
3364
|
-
return innerSchema ? {
|
|
3365
|
-
anyOf: [
|
|
3366
|
-
{
|
|
3367
|
-
not: {}
|
|
3368
|
-
},
|
|
3369
|
-
innerSchema
|
|
3370
|
-
]
|
|
3371
|
-
} : {};
|
|
3372
|
-
};
|
|
3373
|
-
exports.parseOptionalDef = parseOptionalDef;
|
|
3374
|
-
}
|
|
3375
|
-
});
|
|
3376
|
-
|
|
3377
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/pipeline.js
|
|
3378
|
-
var require_pipeline = __commonJS({
|
|
3379
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/pipeline.js"(exports) {
|
|
3380
|
-
"use strict";
|
|
3381
|
-
init_cjs_shims();
|
|
3382
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3383
|
-
exports.parsePipelineDef = void 0;
|
|
3384
|
-
var parseDef_1 = require_parseDef(), parsePipelineDef = (def, refs) => {
|
|
3385
|
-
if (refs.pipeStrategy === "input")
|
|
3386
|
-
return (0, parseDef_1.parseDef)(def.in._def, refs);
|
|
3387
|
-
let a = (0, parseDef_1.parseDef)(def.in._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "allOf", "0"] })), b = (0, parseDef_1.parseDef)(def.out._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"] }));
|
|
3388
|
-
return {
|
|
3389
|
-
allOf: [a, b].filter((x) => x !== void 0)
|
|
3390
|
-
};
|
|
3391
|
-
};
|
|
3392
|
-
exports.parsePipelineDef = parsePipelineDef;
|
|
3393
|
-
}
|
|
3394
|
-
});
|
|
3395
|
-
|
|
3396
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/promise.js
|
|
3397
|
-
var require_promise = __commonJS({
|
|
3398
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/promise.js"(exports) {
|
|
3399
|
-
"use strict";
|
|
3400
|
-
init_cjs_shims();
|
|
3401
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3402
|
-
exports.parsePromiseDef = void 0;
|
|
3403
|
-
var parseDef_1 = require_parseDef();
|
|
3404
|
-
function parsePromiseDef(def, refs) {
|
|
3405
|
-
return (0, parseDef_1.parseDef)(def.type._def, refs);
|
|
3406
|
-
}
|
|
3407
|
-
exports.parsePromiseDef = parsePromiseDef;
|
|
3408
|
-
}
|
|
3409
|
-
});
|
|
3410
|
-
|
|
3411
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/string.js
|
|
3412
|
-
var require_string = __commonJS({
|
|
3413
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/string.js"(exports) {
|
|
3414
|
-
"use strict";
|
|
3415
|
-
init_cjs_shims();
|
|
3416
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3417
|
-
exports.parseStringDef = exports.emojiPattern = exports.ulidPattern = exports.cuid2Pattern = exports.cuidPattern = exports.emailPattern = void 0;
|
|
3418
|
-
var errorMessages_1 = require_errorMessages();
|
|
3419
|
-
exports.emailPattern = '^(([^<>()[\\]\\\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\"]+)*)|(\\".+\\"))@((\\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\])|(\\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\\.[A-Za-z]{2,})+))$';
|
|
3420
|
-
exports.cuidPattern = "^c[^\\s-]{8,}$";
|
|
3421
|
-
exports.cuid2Pattern = "^[a-z][a-z0-9]*$";
|
|
3422
|
-
exports.ulidPattern = "/[0-9A-HJKMNP-TV-Z]{26}/";
|
|
3423
|
-
exports.emojiPattern = "/^(p{Extended_Pictographic}|p{Emoji_Component})+$/u";
|
|
3424
|
-
function parseStringDef(def, refs) {
|
|
3425
|
-
let res = {
|
|
3426
|
-
type: "string"
|
|
3427
|
-
};
|
|
3428
|
-
if (def.checks)
|
|
3429
|
-
for (let check of def.checks)
|
|
3430
|
-
switch (check.kind) {
|
|
3431
|
-
case "min":
|
|
3432
|
-
(0, errorMessages_1.setResponseValueAndErrors)(res, "minLength", typeof res.minLength == "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
3433
|
-
break;
|
|
3434
|
-
case "max":
|
|
3435
|
-
(0, errorMessages_1.setResponseValueAndErrors)(res, "maxLength", typeof res.maxLength == "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
3436
|
-
break;
|
|
3437
|
-
case "email":
|
|
3438
|
-
switch (refs.emailStrategy) {
|
|
3439
|
-
case "format:email":
|
|
3440
|
-
addFormat(res, "email", check.message, refs);
|
|
3441
|
-
break;
|
|
3442
|
-
case "format:idn-email":
|
|
3443
|
-
addFormat(res, "idn-email", check.message, refs);
|
|
3444
|
-
break;
|
|
3445
|
-
case "pattern:zod":
|
|
3446
|
-
addPattern(res, exports.emailPattern, check.message, refs);
|
|
3447
|
-
break;
|
|
3448
|
-
}
|
|
3449
|
-
break;
|
|
3450
|
-
case "url":
|
|
3451
|
-
addFormat(res, "uri", check.message, refs);
|
|
3452
|
-
break;
|
|
3453
|
-
case "uuid":
|
|
3454
|
-
addFormat(res, "uuid", check.message, refs);
|
|
3455
|
-
break;
|
|
3456
|
-
case "regex":
|
|
3457
|
-
addPattern(res, check.regex.source, check.message, refs);
|
|
3458
|
-
break;
|
|
3459
|
-
case "cuid":
|
|
3460
|
-
addPattern(res, exports.cuidPattern, check.message, refs);
|
|
3461
|
-
break;
|
|
3462
|
-
case "cuid2":
|
|
3463
|
-
addPattern(res, exports.cuid2Pattern, check.message, refs);
|
|
3464
|
-
break;
|
|
3465
|
-
case "startsWith":
|
|
3466
|
-
addPattern(res, "^" + escapeNonAlphaNumeric(check.value), check.message, refs);
|
|
3467
|
-
break;
|
|
3468
|
-
case "endsWith":
|
|
3469
|
-
addPattern(res, escapeNonAlphaNumeric(check.value) + "$", check.message, refs);
|
|
3470
|
-
break;
|
|
3471
|
-
case "datetime":
|
|
3472
|
-
addFormat(res, "date-time", check.message, refs);
|
|
3473
|
-
break;
|
|
3474
|
-
case "length":
|
|
3475
|
-
(0, errorMessages_1.setResponseValueAndErrors)(res, "minLength", typeof res.minLength == "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs), (0, errorMessages_1.setResponseValueAndErrors)(res, "maxLength", typeof res.maxLength == "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
3476
|
-
break;
|
|
3477
|
-
case "includes": {
|
|
3478
|
-
addPattern(res, escapeNonAlphaNumeric(check.value), check.message, refs);
|
|
3479
|
-
break;
|
|
3480
|
-
}
|
|
3481
|
-
case "ip": {
|
|
3482
|
-
check.version !== "v6" && addFormat(res, "ipv4", check.message, refs), check.version !== "v4" && addFormat(res, "ipv6", check.message, refs);
|
|
3483
|
-
break;
|
|
3484
|
-
}
|
|
3485
|
-
case "emoji":
|
|
3486
|
-
addPattern(res, exports.emojiPattern, check.message, refs);
|
|
3487
|
-
break;
|
|
3488
|
-
case "ulid": {
|
|
3489
|
-
addPattern(res, exports.ulidPattern, check.message, refs);
|
|
3490
|
-
break;
|
|
3491
|
-
}
|
|
3492
|
-
case "toLowerCase":
|
|
3493
|
-
case "toUpperCase":
|
|
3494
|
-
case "trim":
|
|
3495
|
-
break;
|
|
3496
|
-
default:
|
|
3497
|
-
}
|
|
3498
|
-
return res;
|
|
3499
|
-
}
|
|
3500
|
-
exports.parseStringDef = parseStringDef;
|
|
3501
|
-
var escapeNonAlphaNumeric = (value) => Array.from(value).map((c) => /[a-zA-Z0-9]/.test(c) ? c : `\\${c}`).join(""), addFormat = (schema, value, message, refs) => {
|
|
3502
|
-
var _a;
|
|
3503
|
-
schema.format || !((_a = schema.anyOf) === null || _a === void 0) && _a.some((x) => x.format) ? (schema.anyOf || (schema.anyOf = []), schema.format && (schema.anyOf.push(Object.assign({ format: schema.format }, schema.errorMessage && refs.errorMessages && {
|
|
3504
|
-
errorMessage: { format: schema.errorMessage.format }
|
|
3505
|
-
})), delete schema.format, schema.errorMessage && (delete schema.errorMessage.format, Object.keys(schema.errorMessage).length === 0 && delete schema.errorMessage)), schema.anyOf.push(Object.assign({ format: value }, message && refs.errorMessages && { errorMessage: { format: message } }))) : (0, errorMessages_1.setResponseValueAndErrors)(schema, "format", value, message, refs);
|
|
3506
|
-
}, addPattern = (schema, value, message, refs) => {
|
|
3507
|
-
var _a;
|
|
3508
|
-
schema.pattern || !((_a = schema.allOf) === null || _a === void 0) && _a.some((x) => x.pattern) ? (schema.allOf || (schema.allOf = []), schema.pattern && (schema.allOf.push(Object.assign({ pattern: schema.pattern }, schema.errorMessage && refs.errorMessages && {
|
|
3509
|
-
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
3510
|
-
})), delete schema.pattern, schema.errorMessage && (delete schema.errorMessage.pattern, Object.keys(schema.errorMessage).length === 0 && delete schema.errorMessage)), schema.allOf.push(Object.assign({ pattern: value }, message && refs.errorMessages && { errorMessage: { pattern: message } }))) : (0, errorMessages_1.setResponseValueAndErrors)(schema, "pattern", value, message, refs);
|
|
3511
|
-
};
|
|
3512
|
-
}
|
|
3513
|
-
});
|
|
3514
|
-
|
|
3515
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/record.js
|
|
3516
|
-
var require_record = __commonJS({
|
|
3517
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/record.js"(exports) {
|
|
3518
|
-
"use strict";
|
|
3519
|
-
init_cjs_shims();
|
|
3520
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3521
|
-
exports.parseRecordDef = void 0;
|
|
3522
|
-
var zod_1 = require_lib(), parseDef_1 = require_parseDef(), string_1 = require_string();
|
|
3523
|
-
function parseRecordDef(def, refs) {
|
|
3524
|
-
var _a, _b, _c, _d, _e;
|
|
3525
|
-
if (refs.target === "openApi3" && ((_a = def.keyType) === null || _a === void 0 ? void 0 : _a._def.typeName) === zod_1.ZodFirstPartyTypeKind.ZodEnum)
|
|
3526
|
-
return {
|
|
3527
|
-
type: "object",
|
|
3528
|
-
required: def.keyType._def.values,
|
|
3529
|
-
properties: def.keyType._def.values.reduce((acc, key) => {
|
|
3530
|
-
var _a2;
|
|
3531
|
-
return Object.assign(Object.assign({}, acc), { [key]: (_a2 = (0, parseDef_1.parseDef)(def.valueType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "properties", key] }))) !== null && _a2 !== void 0 ? _a2 : {} });
|
|
3532
|
-
}, {}),
|
|
3533
|
-
additionalProperties: !1
|
|
3534
|
-
};
|
|
3535
|
-
let schema = {
|
|
3536
|
-
type: "object",
|
|
3537
|
-
additionalProperties: (_b = (0, parseDef_1.parseDef)(def.valueType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "additionalProperties"] }))) !== null && _b !== void 0 ? _b : {}
|
|
3538
|
-
};
|
|
3539
|
-
if (refs.target === "openApi3")
|
|
3540
|
-
return schema;
|
|
3541
|
-
if (((_c = def.keyType) === null || _c === void 0 ? void 0 : _c._def.typeName) === zod_1.ZodFirstPartyTypeKind.ZodString && (!((_d = def.keyType._def.checks) === null || _d === void 0) && _d.length)) {
|
|
3542
|
-
let keyType = Object.entries((0, string_1.parseStringDef)(def.keyType._def, refs)).reduce((acc, [key, value]) => key === "type" ? acc : Object.assign(Object.assign({}, acc), { [key]: value }), {});
|
|
3543
|
-
return Object.assign(Object.assign({}, schema), { propertyNames: keyType });
|
|
3544
|
-
} else if (((_e = def.keyType) === null || _e === void 0 ? void 0 : _e._def.typeName) === zod_1.ZodFirstPartyTypeKind.ZodEnum)
|
|
3545
|
-
return Object.assign(Object.assign({}, schema), { propertyNames: {
|
|
3546
|
-
enum: def.keyType._def.values
|
|
3547
|
-
} });
|
|
3548
|
-
return schema;
|
|
3549
|
-
}
|
|
3550
|
-
exports.parseRecordDef = parseRecordDef;
|
|
3551
|
-
}
|
|
3552
|
-
});
|
|
3553
|
-
|
|
3554
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/set.js
|
|
3555
|
-
var require_set = __commonJS({
|
|
3556
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/set.js"(exports) {
|
|
3557
|
-
"use strict";
|
|
3558
|
-
init_cjs_shims();
|
|
3559
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3560
|
-
exports.parseSetDef = void 0;
|
|
3561
|
-
var errorMessages_1 = require_errorMessages(), parseDef_1 = require_parseDef();
|
|
3562
|
-
function parseSetDef(def, refs) {
|
|
3563
|
-
let schema = {
|
|
3564
|
-
type: "array",
|
|
3565
|
-
uniqueItems: !0,
|
|
3566
|
-
items: (0, parseDef_1.parseDef)(def.valueType._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "items"] }))
|
|
3567
|
-
};
|
|
3568
|
-
return def.minSize && (0, errorMessages_1.setResponseValueAndErrors)(schema, "minItems", def.minSize.value, def.minSize.message, refs), def.maxSize && (0, errorMessages_1.setResponseValueAndErrors)(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs), schema;
|
|
3569
|
-
}
|
|
3570
|
-
exports.parseSetDef = parseSetDef;
|
|
3571
|
-
}
|
|
3572
|
-
});
|
|
3573
|
-
|
|
3574
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/tuple.js
|
|
3575
|
-
var require_tuple = __commonJS({
|
|
3576
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/tuple.js"(exports) {
|
|
3577
|
-
"use strict";
|
|
3578
|
-
init_cjs_shims();
|
|
3579
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3580
|
-
exports.parseTupleDef = void 0;
|
|
3581
|
-
var parseDef_1 = require_parseDef();
|
|
3582
|
-
function parseTupleDef(def, refs) {
|
|
3583
|
-
return def.rest ? {
|
|
3584
|
-
type: "array",
|
|
3585
|
-
minItems: def.items.length,
|
|
3586
|
-
items: def.items.map((x, i) => (0, parseDef_1.parseDef)(x._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "items", `${i}`] }))).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
3587
|
-
additionalItems: (0, parseDef_1.parseDef)(def.rest._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "additionalItems"] }))
|
|
3588
|
-
} : {
|
|
3589
|
-
type: "array",
|
|
3590
|
-
minItems: def.items.length,
|
|
3591
|
-
maxItems: def.items.length,
|
|
3592
|
-
items: def.items.map((x, i) => (0, parseDef_1.parseDef)(x._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.currentPath, "items", `${i}`] }))).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
3593
|
-
};
|
|
3594
|
-
}
|
|
3595
|
-
exports.parseTupleDef = parseTupleDef;
|
|
3596
|
-
}
|
|
3597
|
-
});
|
|
3598
|
-
|
|
3599
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/undefined.js
|
|
3600
|
-
var require_undefined = __commonJS({
|
|
3601
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/undefined.js"(exports) {
|
|
3602
|
-
"use strict";
|
|
3603
|
-
init_cjs_shims();
|
|
3604
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3605
|
-
exports.parseUndefinedDef = void 0;
|
|
3606
|
-
function parseUndefinedDef() {
|
|
3607
|
-
return {
|
|
3608
|
-
not: {}
|
|
3609
|
-
};
|
|
3610
|
-
}
|
|
3611
|
-
exports.parseUndefinedDef = parseUndefinedDef;
|
|
3612
|
-
}
|
|
3613
|
-
});
|
|
3614
|
-
|
|
3615
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/unknown.js
|
|
3616
|
-
var require_unknown = __commonJS({
|
|
3617
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parsers/unknown.js"(exports) {
|
|
3618
|
-
"use strict";
|
|
3619
|
-
init_cjs_shims();
|
|
3620
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3621
|
-
exports.parseUnknownDef = void 0;
|
|
3622
|
-
function parseUnknownDef() {
|
|
3623
|
-
return {};
|
|
3624
|
-
}
|
|
3625
|
-
exports.parseUnknownDef = parseUnknownDef;
|
|
3626
|
-
}
|
|
3627
|
-
});
|
|
3628
|
-
|
|
3629
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parseDef.js
|
|
3630
|
-
var require_parseDef = __commonJS({
|
|
3631
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/parseDef.js"(exports) {
|
|
3632
|
-
"use strict";
|
|
3633
|
-
init_cjs_shims();
|
|
3634
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3635
|
-
exports.parseDef = void 0;
|
|
3636
|
-
var zod_1 = require_lib(), any_1 = require_any(), array_1 = require_array(), bigint_1 = require_bigint(), boolean_1 = require_boolean(), branded_1 = require_branded(), catch_1 = require_catch(), date_1 = require_date(), default_1 = require_default(), effects_1 = require_effects(), enum_1 = require_enum(), intersection_1 = require_intersection(), literal_1 = require_literal(), map_1 = require_map(), nativeEnum_1 = require_nativeEnum(), never_1 = require_never(), null_1 = require_null(), nullable_1 = require_nullable(), number_1 = require_number(), object_1 = require_object(), optional_1 = require_optional(), pipeline_1 = require_pipeline(), promise_1 = require_promise(), record_1 = require_record(), set_1 = require_set(), string_1 = require_string(), tuple_1 = require_tuple(), undefined_1 = require_undefined(), union_1 = require_union(), unknown_1 = require_unknown();
|
|
3637
|
-
function parseDef(def, refs, forceResolution = !1) {
|
|
3638
|
-
let seenItem = refs.seen.get(def);
|
|
3639
|
-
if (seenItem && !forceResolution) {
|
|
3640
|
-
let seenSchema = get$ref(seenItem, refs);
|
|
3641
|
-
if (seenSchema !== void 0)
|
|
3642
|
-
return seenSchema;
|
|
3643
|
-
}
|
|
3644
|
-
let newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
3645
|
-
refs.seen.set(def, newItem);
|
|
3646
|
-
let jsonSchema = selectParser(def, def.typeName, refs);
|
|
3647
|
-
return jsonSchema && addMeta(def, refs, jsonSchema), newItem.jsonSchema = jsonSchema, jsonSchema;
|
|
3648
|
-
}
|
|
3649
|
-
exports.parseDef = parseDef;
|
|
3650
|
-
var get$ref = (item, refs) => {
|
|
3651
|
-
switch (refs.$refStrategy) {
|
|
3652
|
-
case "root":
|
|
3653
|
-
return {
|
|
3654
|
-
$ref: item.path.length === 0 ? "" : item.path.length === 1 ? `${item.path[0]}/` : item.path.join("/")
|
|
3655
|
-
};
|
|
3656
|
-
case "relative":
|
|
3657
|
-
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
3658
|
-
case "none":
|
|
3659
|
-
return item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value) ? (console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`), {}) : void 0;
|
|
3660
|
-
case "seen":
|
|
3661
|
-
return item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value) ? (console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`), {}) : item.jsonSchema;
|
|
3662
|
-
}
|
|
3663
|
-
}, getRelativePath = (pathA, pathB) => {
|
|
3664
|
-
let i = 0;
|
|
3665
|
-
for (; i < pathA.length && i < pathB.length && pathA[i] === pathB[i]; i++)
|
|
3666
|
-
;
|
|
3667
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
3668
|
-
}, selectParser = (def, typeName, refs) => {
|
|
3669
|
-
switch (typeName) {
|
|
3670
|
-
case zod_1.ZodFirstPartyTypeKind.ZodString:
|
|
3671
|
-
return (0, string_1.parseStringDef)(def, refs);
|
|
3672
|
-
case zod_1.ZodFirstPartyTypeKind.ZodNumber:
|
|
3673
|
-
return (0, number_1.parseNumberDef)(def, refs);
|
|
3674
|
-
case zod_1.ZodFirstPartyTypeKind.ZodObject:
|
|
3675
|
-
return (0, object_1.parseObjectDef)(def, refs);
|
|
3676
|
-
case zod_1.ZodFirstPartyTypeKind.ZodBigInt:
|
|
3677
|
-
return (0, bigint_1.parseBigintDef)(def, refs);
|
|
3678
|
-
case zod_1.ZodFirstPartyTypeKind.ZodBoolean:
|
|
3679
|
-
return (0, boolean_1.parseBooleanDef)();
|
|
3680
|
-
case zod_1.ZodFirstPartyTypeKind.ZodDate:
|
|
3681
|
-
return (0, date_1.parseDateDef)(def, refs);
|
|
3682
|
-
case zod_1.ZodFirstPartyTypeKind.ZodUndefined:
|
|
3683
|
-
return (0, undefined_1.parseUndefinedDef)();
|
|
3684
|
-
case zod_1.ZodFirstPartyTypeKind.ZodNull:
|
|
3685
|
-
return (0, null_1.parseNullDef)(refs);
|
|
3686
|
-
case zod_1.ZodFirstPartyTypeKind.ZodArray:
|
|
3687
|
-
return (0, array_1.parseArrayDef)(def, refs);
|
|
3688
|
-
case zod_1.ZodFirstPartyTypeKind.ZodUnion:
|
|
3689
|
-
case zod_1.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
3690
|
-
return (0, union_1.parseUnionDef)(def, refs);
|
|
3691
|
-
case zod_1.ZodFirstPartyTypeKind.ZodIntersection:
|
|
3692
|
-
return (0, intersection_1.parseIntersectionDef)(def, refs);
|
|
3693
|
-
case zod_1.ZodFirstPartyTypeKind.ZodTuple:
|
|
3694
|
-
return (0, tuple_1.parseTupleDef)(def, refs);
|
|
3695
|
-
case zod_1.ZodFirstPartyTypeKind.ZodRecord:
|
|
3696
|
-
return (0, record_1.parseRecordDef)(def, refs);
|
|
3697
|
-
case zod_1.ZodFirstPartyTypeKind.ZodLiteral:
|
|
3698
|
-
return (0, literal_1.parseLiteralDef)(def, refs);
|
|
3699
|
-
case zod_1.ZodFirstPartyTypeKind.ZodEnum:
|
|
3700
|
-
return (0, enum_1.parseEnumDef)(def);
|
|
3701
|
-
case zod_1.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
3702
|
-
return (0, nativeEnum_1.parseNativeEnumDef)(def);
|
|
3703
|
-
case zod_1.ZodFirstPartyTypeKind.ZodNullable:
|
|
3704
|
-
return (0, nullable_1.parseNullableDef)(def, refs);
|
|
3705
|
-
case zod_1.ZodFirstPartyTypeKind.ZodOptional:
|
|
3706
|
-
return (0, optional_1.parseOptionalDef)(def, refs);
|
|
3707
|
-
case zod_1.ZodFirstPartyTypeKind.ZodMap:
|
|
3708
|
-
return (0, map_1.parseMapDef)(def, refs);
|
|
3709
|
-
case zod_1.ZodFirstPartyTypeKind.ZodSet:
|
|
3710
|
-
return (0, set_1.parseSetDef)(def, refs);
|
|
3711
|
-
case zod_1.ZodFirstPartyTypeKind.ZodLazy:
|
|
3712
|
-
return parseDef(def.getter()._def, refs);
|
|
3713
|
-
case zod_1.ZodFirstPartyTypeKind.ZodPromise:
|
|
3714
|
-
return (0, promise_1.parsePromiseDef)(def, refs);
|
|
3715
|
-
case zod_1.ZodFirstPartyTypeKind.ZodNaN:
|
|
3716
|
-
case zod_1.ZodFirstPartyTypeKind.ZodNever:
|
|
3717
|
-
return (0, never_1.parseNeverDef)();
|
|
3718
|
-
case zod_1.ZodFirstPartyTypeKind.ZodEffects:
|
|
3719
|
-
return (0, effects_1.parseEffectsDef)(def, refs);
|
|
3720
|
-
case zod_1.ZodFirstPartyTypeKind.ZodAny:
|
|
3721
|
-
return (0, any_1.parseAnyDef)();
|
|
3722
|
-
case zod_1.ZodFirstPartyTypeKind.ZodUnknown:
|
|
3723
|
-
return (0, unknown_1.parseUnknownDef)();
|
|
3724
|
-
case zod_1.ZodFirstPartyTypeKind.ZodDefault:
|
|
3725
|
-
return (0, default_1.parseDefaultDef)(def, refs);
|
|
3726
|
-
case zod_1.ZodFirstPartyTypeKind.ZodBranded:
|
|
3727
|
-
return (0, branded_1.parseBrandedDef)(def, refs);
|
|
3728
|
-
case zod_1.ZodFirstPartyTypeKind.ZodCatch:
|
|
3729
|
-
return (0, catch_1.parseCatchDef)(def, refs);
|
|
3730
|
-
case zod_1.ZodFirstPartyTypeKind.ZodPipeline:
|
|
3731
|
-
return (0, pipeline_1.parsePipelineDef)(def, refs);
|
|
3732
|
-
case zod_1.ZodFirstPartyTypeKind.ZodFunction:
|
|
3733
|
-
case zod_1.ZodFirstPartyTypeKind.ZodVoid:
|
|
3734
|
-
case zod_1.ZodFirstPartyTypeKind.ZodSymbol:
|
|
3735
|
-
return;
|
|
3736
|
-
default:
|
|
3737
|
-
return /* @__PURE__ */ ((_) => {
|
|
3738
|
-
})(typeName);
|
|
3739
|
-
}
|
|
3740
|
-
}, addMeta = (def, refs, jsonSchema) => (def.description && (jsonSchema.description = def.description, refs.markdownDescription && (jsonSchema.markdownDescription = def.description)), jsonSchema);
|
|
3741
|
-
}
|
|
3742
|
-
});
|
|
3743
|
-
|
|
3744
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/Options.js
|
|
3745
|
-
var require_Options = __commonJS({
|
|
3746
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/Options.js"(exports) {
|
|
3747
|
-
"use strict";
|
|
3748
|
-
init_cjs_shims();
|
|
3749
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3750
|
-
exports.getDefaultOptions = exports.defaultOptions = void 0;
|
|
3751
|
-
exports.defaultOptions = {
|
|
3752
|
-
name: void 0,
|
|
3753
|
-
$refStrategy: "root",
|
|
3754
|
-
basePath: ["#"],
|
|
3755
|
-
effectStrategy: "input",
|
|
3756
|
-
pipeStrategy: "all",
|
|
3757
|
-
dateStrategy: "string",
|
|
3758
|
-
definitionPath: "definitions",
|
|
3759
|
-
target: "jsonSchema7",
|
|
3760
|
-
strictUnions: !1,
|
|
3761
|
-
definitions: {},
|
|
3762
|
-
errorMessages: !1,
|
|
3763
|
-
markdownDescription: !1,
|
|
3764
|
-
emailStrategy: "format:email"
|
|
3765
|
-
};
|
|
3766
|
-
var getDefaultOptions = (options) => typeof options == "string" ? Object.assign(Object.assign({}, exports.defaultOptions), { name: options }) : Object.assign(Object.assign({}, exports.defaultOptions), options);
|
|
3767
|
-
exports.getDefaultOptions = getDefaultOptions;
|
|
3768
|
-
}
|
|
3769
|
-
});
|
|
3770
|
-
|
|
3771
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/Refs.js
|
|
3772
|
-
var require_Refs = __commonJS({
|
|
3773
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/Refs.js"(exports) {
|
|
3774
|
-
"use strict";
|
|
3775
|
-
init_cjs_shims();
|
|
3776
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3777
|
-
exports.getRefs = void 0;
|
|
3778
|
-
var Options_1 = require_Options(), getRefs = (options) => {
|
|
3779
|
-
let _options = (0, Options_1.getDefaultOptions)(options), currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
3780
|
-
return Object.assign(Object.assign({}, _options), { currentPath, propertyPath: void 0, seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
3781
|
-
def._def,
|
|
3782
|
-
{
|
|
3783
|
-
def: def._def,
|
|
3784
|
-
path: [..._options.basePath, _options.definitionPath, name],
|
|
3785
|
-
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
3786
|
-
jsonSchema: void 0
|
|
3787
|
-
}
|
|
3788
|
-
])) });
|
|
3789
|
-
};
|
|
3790
|
-
exports.getRefs = getRefs;
|
|
3791
|
-
}
|
|
3792
|
-
});
|
|
3793
|
-
|
|
3794
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/zodToJsonSchema.js
|
|
3795
|
-
var require_zodToJsonSchema = __commonJS({
|
|
3796
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/src/zodToJsonSchema.js"(exports) {
|
|
3797
|
-
"use strict";
|
|
3798
|
-
init_cjs_shims();
|
|
3799
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3800
|
-
exports.zodToJsonSchema = void 0;
|
|
3801
|
-
var parseDef_1 = require_parseDef(), Refs_1 = require_Refs(), zodToJsonSchema = (schema, options) => {
|
|
3802
|
-
var _a;
|
|
3803
|
-
let refs = (0, Refs_1.getRefs)(options), definitions = typeof options == "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => {
|
|
3804
|
-
var _a2;
|
|
3805
|
-
return Object.assign(Object.assign({}, acc), { [name2]: (_a2 = (0, parseDef_1.parseDef)(schema2._def, Object.assign(Object.assign({}, refs), { currentPath: [...refs.basePath, refs.definitionPath, name2] }), !0)) !== null && _a2 !== void 0 ? _a2 : {} });
|
|
3806
|
-
}, {}) : void 0, name = typeof options == "string" ? options : options?.name, main = (_a = (0, parseDef_1.parseDef)(schema._def, name === void 0 ? refs : Object.assign(Object.assign({}, refs), { currentPath: [...refs.basePath, refs.definitionPath, name] }), !1)) !== null && _a !== void 0 ? _a : {}, combined = name === void 0 ? definitions ? Object.assign(Object.assign({}, main), { [refs.definitionPath]: definitions }) : main : {
|
|
3807
|
-
$ref: [
|
|
3808
|
-
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
3809
|
-
refs.definitionPath,
|
|
3810
|
-
name
|
|
3811
|
-
].join("/"),
|
|
3812
|
-
[refs.definitionPath]: Object.assign(Object.assign({}, definitions), { [name]: main })
|
|
3813
|
-
};
|
|
3814
|
-
return refs.target === "jsonSchema7" ? combined.$schema = "http://json-schema.org/draft-07/schema#" : refs.target === "jsonSchema2019-09" && (combined.$schema = "https://json-schema.org/draft/2019-09/schema#"), combined;
|
|
3815
|
-
};
|
|
3816
|
-
exports.zodToJsonSchema = zodToJsonSchema;
|
|
3817
|
-
}
|
|
3818
|
-
});
|
|
3819
|
-
|
|
3820
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/index.js
|
|
3821
|
-
var require_zod_to_json_schema = __commonJS({
|
|
3822
|
-
"../../node_modules/.pnpm/zod-to-json-schema@3.21.4_zod@3.22.3/node_modules/zod-to-json-schema/index.js"(exports) {
|
|
3823
|
-
"use strict";
|
|
3824
|
-
init_cjs_shims();
|
|
3825
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3826
|
-
exports.zodToJsonSchema = void 0;
|
|
3827
|
-
var zodToJsonSchema_1 = require_zodToJsonSchema();
|
|
3828
|
-
Object.defineProperty(exports, "zodToJsonSchema", { enumerable: !0, get: function() {
|
|
3829
|
-
return zodToJsonSchema_1.zodToJsonSchema;
|
|
3830
|
-
} });
|
|
3831
|
-
exports.default = zodToJsonSchema_1.zodToJsonSchema;
|
|
3832
|
-
}
|
|
3833
|
-
});
|
|
3834
|
-
|
|
3835
|
-
export {
|
|
3836
|
-
require_zod_to_json_schema
|
|
3837
|
-
};
|
|
3838
|
-
//# sourceMappingURL=chunk-QSUS3GJF.js.map
|