@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
|
@@ -5,16 +5,22 @@ import {
|
|
|
5
5
|
} from "./chunk-VSLR7ET4.js";
|
|
6
6
|
import {
|
|
7
7
|
CLI_KIT_VERSION
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NGHX3OJ3.js";
|
|
9
9
|
import {
|
|
10
10
|
Environment,
|
|
11
|
+
environmentVariables,
|
|
11
12
|
firstPartyDev,
|
|
12
13
|
import_ts_error,
|
|
14
|
+
isTruthy,
|
|
13
15
|
outputContent,
|
|
14
16
|
outputDebug,
|
|
15
17
|
runWithTimer,
|
|
16
|
-
serviceEnvironment
|
|
17
|
-
|
|
18
|
+
serviceEnvironment,
|
|
19
|
+
systemEnvironmentVariables
|
|
20
|
+
} from "./chunk-TM56R4RM.js";
|
|
21
|
+
import {
|
|
22
|
+
sniffForJson
|
|
23
|
+
} from "./chunk-3NSN5Z4N.js";
|
|
18
24
|
import {
|
|
19
25
|
__commonJS,
|
|
20
26
|
__require,
|
|
@@ -93,12 +99,12 @@ var require_extractFiles = __commonJS({
|
|
|
93
99
|
var require_delayed_stream = __commonJS({
|
|
94
100
|
"../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js"(exports, module) {
|
|
95
101
|
init_cjs_shims();
|
|
96
|
-
var Stream3 = __require("stream").Stream,
|
|
102
|
+
var Stream3 = __require("stream").Stream, util2 = __require("util");
|
|
97
103
|
module.exports = DelayedStream;
|
|
98
104
|
function DelayedStream() {
|
|
99
105
|
this.source = null, this.dataSize = 0, this.maxDataSize = 1024 * 1024, this.pauseStream = !0, this._maxDataSizeExceeded = !1, this._released = !1, this._bufferedEvents = [];
|
|
100
106
|
}
|
|
101
|
-
|
|
107
|
+
util2.inherits(DelayedStream, Stream3);
|
|
102
108
|
DelayedStream.create = function(source, options) {
|
|
103
109
|
var delayedStream = new this();
|
|
104
110
|
options = options || {};
|
|
@@ -157,12 +163,12 @@ var require_delayed_stream = __commonJS({
|
|
|
157
163
|
var require_combined_stream = __commonJS({
|
|
158
164
|
"../../node_modules/.pnpm/combined-stream@1.0.8/node_modules/combined-stream/lib/combined_stream.js"(exports, module) {
|
|
159
165
|
init_cjs_shims();
|
|
160
|
-
var
|
|
166
|
+
var util2 = __require("util"), Stream3 = __require("stream").Stream, DelayedStream = require_delayed_stream();
|
|
161
167
|
module.exports = CombinedStream;
|
|
162
168
|
function CombinedStream() {
|
|
163
169
|
this.writable = !1, this.readable = !0, this.dataSize = 0, this.maxDataSize = 2 * 1024 * 1024, this.pauseStreams = !0, this._released = !1, this._streams = [], this._currentStream = null, this._insideLoop = !1, this._pendingNext = !1;
|
|
164
170
|
}
|
|
165
|
-
|
|
171
|
+
util2.inherits(CombinedStream, Stream3);
|
|
166
172
|
CombinedStream.create = function(options) {
|
|
167
173
|
var combinedStream = new this();
|
|
168
174
|
options = options || {};
|
|
@@ -8890,11 +8896,11 @@ var require_async = __commonJS({
|
|
|
8890
8896
|
var defer = require_defer();
|
|
8891
8897
|
module.exports = async;
|
|
8892
8898
|
function async(callback) {
|
|
8893
|
-
var
|
|
8899
|
+
var isAsync2 = !1;
|
|
8894
8900
|
return defer(function() {
|
|
8895
|
-
|
|
8901
|
+
isAsync2 = !0;
|
|
8896
8902
|
}), function(err, result) {
|
|
8897
|
-
|
|
8903
|
+
isAsync2 ? callback(err, result) : defer(function() {
|
|
8898
8904
|
callback(err, result);
|
|
8899
8905
|
});
|
|
8900
8906
|
};
|
|
@@ -9061,9 +9067,9 @@ var require_populate = __commonJS({
|
|
|
9061
9067
|
var require_form_data = __commonJS({
|
|
9062
9068
|
"../../node_modules/.pnpm/form-data@3.0.1/node_modules/form-data/lib/form_data.js"(exports, module) {
|
|
9063
9069
|
init_cjs_shims();
|
|
9064
|
-
var CombinedStream = require_combined_stream(),
|
|
9070
|
+
var CombinedStream = require_combined_stream(), util2 = __require("util"), path = __require("path"), http3 = __require("http"), https3 = __require("https"), parseUrl = __require("url").parse, fs = __require("fs"), mime = require_mime_types(), asynckit = require_asynckit(), populate = require_populate();
|
|
9065
9071
|
module.exports = FormData4;
|
|
9066
|
-
|
|
9072
|
+
util2.inherits(FormData4, CombinedStream);
|
|
9067
9073
|
function FormData4(options) {
|
|
9068
9074
|
if (!(this instanceof FormData4))
|
|
9069
9075
|
return new FormData4(options);
|
|
@@ -9077,7 +9083,7 @@ var require_form_data = __commonJS({
|
|
|
9077
9083
|
FormData4.prototype.append = function(field, value, options) {
|
|
9078
9084
|
options = options || {}, typeof options == "string" && (options = { filename: options });
|
|
9079
9085
|
var append = CombinedStream.prototype.append.bind(this);
|
|
9080
|
-
if (typeof value == "number" && (value = "" + value),
|
|
9086
|
+
if (typeof value == "number" && (value = "" + value), util2.isArray(value)) {
|
|
9081
9087
|
this._error(new Error("Arrays are not supported."));
|
|
9082
9088
|
return;
|
|
9083
9089
|
}
|
|
@@ -13210,8 +13216,8 @@ var require_definition = __commonJS({
|
|
|
13210
13216
|
}
|
|
13211
13217
|
};
|
|
13212
13218
|
exports.GraphQLEnumType = GraphQLEnumType;
|
|
13213
|
-
function didYouMeanEnumValue(
|
|
13214
|
-
let allNames =
|
|
13219
|
+
function didYouMeanEnumValue(enumType2, unknownValueStr) {
|
|
13220
|
+
let allNames = enumType2.getValues().map((value) => value.name), suggestedValues = (0, _suggestionList.suggestionList)(
|
|
13215
13221
|
unknownValueStr,
|
|
13216
13222
|
allNames
|
|
13217
13223
|
);
|
|
@@ -14781,11 +14787,11 @@ var require_validate = __commonJS({
|
|
|
14781
14787
|
);
|
|
14782
14788
|
}
|
|
14783
14789
|
}
|
|
14784
|
-
function validateEnumValues(context,
|
|
14785
|
-
let enumValues =
|
|
14790
|
+
function validateEnumValues(context, enumType2) {
|
|
14791
|
+
let enumValues = enumType2.getValues();
|
|
14786
14792
|
enumValues.length === 0 && context.reportError(
|
|
14787
|
-
`Enum type ${
|
|
14788
|
-
[
|
|
14793
|
+
`Enum type ${enumType2.name} must define one or more values.`,
|
|
14794
|
+
[enumType2.astNode, ...enumType2.extensionASTNodes]
|
|
14789
14795
|
);
|
|
14790
14796
|
for (let enumValue of enumValues)
|
|
14791
14797
|
validateName(context, enumValue);
|
|
@@ -15007,8 +15013,8 @@ var require_TypeInfo = __commonJS({
|
|
|
15007
15013
|
break;
|
|
15008
15014
|
}
|
|
15009
15015
|
case _kinds.Kind.OBJECT_FIELD: {
|
|
15010
|
-
let
|
|
15011
|
-
(0, _definition.isInputObjectType)(
|
|
15016
|
+
let objectType2 = (0, _definition.getNamedType)(this.getInputType()), inputFieldType, inputField;
|
|
15017
|
+
(0, _definition.isInputObjectType)(objectType2) && (inputField = objectType2.getFields()[node.name.value], inputField && (inputFieldType = inputField.type)), this._defaultValueStack.push(
|
|
15012
15018
|
inputField ? inputField.defaultValue : void 0
|
|
15013
15019
|
), this._inputTypeStack.push(
|
|
15014
15020
|
(0, _definition.isInputType)(inputFieldType) ? inputFieldType : void 0
|
|
@@ -15016,8 +15022,8 @@ var require_TypeInfo = __commonJS({
|
|
|
15016
15022
|
break;
|
|
15017
15023
|
}
|
|
15018
15024
|
case _kinds.Kind.ENUM: {
|
|
15019
|
-
let
|
|
15020
|
-
(0, _definition.isEnumType)(
|
|
15025
|
+
let enumType2 = (0, _definition.getNamedType)(this.getInputType()), enumValue;
|
|
15026
|
+
(0, _definition.isEnumType)(enumType2) && (enumValue = enumType2.getValue(node.value)), this._enumValue = enumValue;
|
|
15021
15027
|
break;
|
|
15022
15028
|
}
|
|
15023
15029
|
default:
|
|
@@ -20534,9 +20540,9 @@ var require_buildClientSchema = __commonJS({
|
|
|
20534
20540
|
let nullableRef = typeRef.ofType;
|
|
20535
20541
|
if (!nullableRef)
|
|
20536
20542
|
throw new Error("Decorated type deeper than introspection query.");
|
|
20537
|
-
let
|
|
20543
|
+
let nullableType2 = getType(nullableRef);
|
|
20538
20544
|
return new _definition.GraphQLNonNull(
|
|
20539
|
-
(0, _definition.assertNullableType)(
|
|
20545
|
+
(0, _definition.assertNullableType)(nullableType2)
|
|
20540
20546
|
);
|
|
20541
20547
|
}
|
|
20542
20548
|
return getNamedType(typeRef);
|
|
@@ -26647,9 +26653,9 @@ var require_populate2 = __commonJS({
|
|
|
26647
26653
|
var require_form_data2 = __commonJS({
|
|
26648
26654
|
"../../node_modules/.pnpm/form-data@4.0.0/node_modules/form-data/lib/form_data.js"(exports, module) {
|
|
26649
26655
|
init_cjs_shims();
|
|
26650
|
-
var CombinedStream = require_combined_stream(),
|
|
26656
|
+
var CombinedStream = require_combined_stream(), util2 = __require("util"), path = __require("path"), http3 = __require("http"), https3 = __require("https"), parseUrl = __require("url").parse, fs = __require("fs"), Stream3 = __require("stream").Stream, mime = require_mime_types(), asynckit = require_asynckit(), populate = require_populate2();
|
|
26651
26657
|
module.exports = FormData4;
|
|
26652
|
-
|
|
26658
|
+
util2.inherits(FormData4, CombinedStream);
|
|
26653
26659
|
function FormData4(options) {
|
|
26654
26660
|
if (!(this instanceof FormData4))
|
|
26655
26661
|
return new FormData4(options);
|
|
@@ -26663,7 +26669,7 @@ var require_form_data2 = __commonJS({
|
|
|
26663
26669
|
FormData4.prototype.append = function(field, value, options) {
|
|
26664
26670
|
options = options || {}, typeof options == "string" && (options = { filename: options });
|
|
26665
26671
|
var append = CombinedStream.prototype.append.bind(this);
|
|
26666
|
-
if (typeof value == "number" && (value = "" + value),
|
|
26672
|
+
if (typeof value == "number" && (value = "" + value), util2.isArray(value)) {
|
|
26667
26673
|
this._error(new Error("Arrays are not supported."));
|
|
26668
26674
|
return;
|
|
26669
26675
|
}
|
|
@@ -27292,7 +27298,16 @@ async function makeVerboseRequest({ request, url }) {
|
|
|
27292
27298
|
requestId: responseHeaders["x-request-id"],
|
|
27293
27299
|
delayMs
|
|
27294
27300
|
};
|
|
27295
|
-
}
|
|
27301
|
+
} else if (err.response.status === 401)
|
|
27302
|
+
return {
|
|
27303
|
+
status: "unauthorized",
|
|
27304
|
+
clientError: err,
|
|
27305
|
+
duration,
|
|
27306
|
+
sanitizedHeaders,
|
|
27307
|
+
sanitizedUrl,
|
|
27308
|
+
requestId: responseHeaders["x-request-id"],
|
|
27309
|
+
delayMs: 500
|
|
27310
|
+
};
|
|
27296
27311
|
return {
|
|
27297
27312
|
status: "client-error",
|
|
27298
27313
|
clientError: err,
|
|
@@ -27338,9 +27353,11 @@ ${result.sanitizedHeaders}
|
|
|
27338
27353
|
throw errorHandler ? errorHandler(result.error, result.requestId) : result.error;
|
|
27339
27354
|
case "can-retry":
|
|
27340
27355
|
throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
|
|
27356
|
+
case "unauthorized":
|
|
27357
|
+
throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
|
|
27341
27358
|
}
|
|
27342
27359
|
}
|
|
27343
|
-
async function retryAwareRequest({ request, url }, errorHandler, retryOptions = {
|
|
27360
|
+
async function retryAwareRequest({ request, url }, errorHandler, unauthorizedHandler, retryOptions = {
|
|
27344
27361
|
scheduleDelay: setTimeout
|
|
27345
27362
|
}) {
|
|
27346
27363
|
let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest({ request, url });
|
|
@@ -27354,6 +27371,11 @@ ${result.sanitizedHeaders}
|
|
|
27354
27371
|
throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
|
|
27355
27372
|
if (result.status === "unknown-error")
|
|
27356
27373
|
throw errorHandler ? errorHandler(result.error, result.requestId) : result.error;
|
|
27374
|
+
if (result.status === "unauthorized")
|
|
27375
|
+
if (unauthorizedHandler)
|
|
27376
|
+
await unauthorizedHandler();
|
|
27377
|
+
else
|
|
27378
|
+
throw result.clientError;
|
|
27357
27379
|
if (limitRetriesTo <= retriesUsed)
|
|
27358
27380
|
throw outputDebug(`${limitRetriesTo} retries exhausted for request to ${result.sanitizedUrl}`), errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
|
|
27359
27381
|
retriesUsed += 1;
|
|
@@ -27367,7 +27389,7 @@ ${result.sanitizedHeaders}
|
|
|
27367
27389
|
}
|
|
27368
27390
|
|
|
27369
27391
|
// ../cli-kit/dist/public/node/http.js
|
|
27370
|
-
var import_form_data2 = __toESM(require_form_data2()
|
|
27392
|
+
var import_form_data2 = __toESM(require_form_data2());
|
|
27371
27393
|
|
|
27372
27394
|
// ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
|
|
27373
27395
|
init_cjs_shims();
|
|
@@ -28250,6 +28272,2749 @@ ${sanitizedHeadersOutput(options.headers ?? {})}
|
|
|
28250
28272
|
}));
|
|
28251
28273
|
}
|
|
28252
28274
|
|
|
28275
|
+
// ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs
|
|
28276
|
+
init_cjs_shims();
|
|
28277
|
+
var util;
|
|
28278
|
+
(function(util2) {
|
|
28279
|
+
util2.assertEqual = (val) => val;
|
|
28280
|
+
function assertIs(_arg) {
|
|
28281
|
+
}
|
|
28282
|
+
util2.assertIs = assertIs;
|
|
28283
|
+
function assertNever(_x) {
|
|
28284
|
+
throw new Error();
|
|
28285
|
+
}
|
|
28286
|
+
util2.assertNever = assertNever, util2.arrayToEnum = (items) => {
|
|
28287
|
+
let obj = {};
|
|
28288
|
+
for (let item of items)
|
|
28289
|
+
obj[item] = item;
|
|
28290
|
+
return obj;
|
|
28291
|
+
}, util2.getValidEnumValues = (obj) => {
|
|
28292
|
+
let validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] != "number"), filtered = {};
|
|
28293
|
+
for (let k of validKeys)
|
|
28294
|
+
filtered[k] = obj[k];
|
|
28295
|
+
return util2.objectValues(filtered);
|
|
28296
|
+
}, util2.objectValues = (obj) => util2.objectKeys(obj).map(function(e) {
|
|
28297
|
+
return obj[e];
|
|
28298
|
+
}), util2.objectKeys = typeof Object.keys == "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
28299
|
+
let keys = [];
|
|
28300
|
+
for (let key in object)
|
|
28301
|
+
Object.prototype.hasOwnProperty.call(object, key) && keys.push(key);
|
|
28302
|
+
return keys;
|
|
28303
|
+
}, util2.find = (arr, checker) => {
|
|
28304
|
+
for (let item of arr)
|
|
28305
|
+
if (checker(item))
|
|
28306
|
+
return item;
|
|
28307
|
+
}, util2.isInteger = typeof Number.isInteger == "function" ? (val) => Number.isInteger(val) : (val) => typeof val == "number" && isFinite(val) && Math.floor(val) === val;
|
|
28308
|
+
function joinValues(array, separator = " | ") {
|
|
28309
|
+
return array.map((val) => typeof val == "string" ? `'${val}'` : val).join(separator);
|
|
28310
|
+
}
|
|
28311
|
+
util2.joinValues = joinValues, util2.jsonStringifyReplacer = (_, value) => typeof value == "bigint" ? value.toString() : value;
|
|
28312
|
+
})(util || (util = {}));
|
|
28313
|
+
var objectUtil;
|
|
28314
|
+
(function(objectUtil2) {
|
|
28315
|
+
objectUtil2.mergeShapes = (first, second) => ({
|
|
28316
|
+
...first,
|
|
28317
|
+
...second
|
|
28318
|
+
// second overwrites first
|
|
28319
|
+
});
|
|
28320
|
+
})(objectUtil || (objectUtil = {}));
|
|
28321
|
+
var ZodParsedType = util.arrayToEnum([
|
|
28322
|
+
"string",
|
|
28323
|
+
"nan",
|
|
28324
|
+
"number",
|
|
28325
|
+
"integer",
|
|
28326
|
+
"float",
|
|
28327
|
+
"boolean",
|
|
28328
|
+
"date",
|
|
28329
|
+
"bigint",
|
|
28330
|
+
"symbol",
|
|
28331
|
+
"function",
|
|
28332
|
+
"undefined",
|
|
28333
|
+
"null",
|
|
28334
|
+
"array",
|
|
28335
|
+
"object",
|
|
28336
|
+
"unknown",
|
|
28337
|
+
"promise",
|
|
28338
|
+
"void",
|
|
28339
|
+
"never",
|
|
28340
|
+
"map",
|
|
28341
|
+
"set"
|
|
28342
|
+
]), getParsedType = (data) => {
|
|
28343
|
+
switch (typeof data) {
|
|
28344
|
+
case "undefined":
|
|
28345
|
+
return ZodParsedType.undefined;
|
|
28346
|
+
case "string":
|
|
28347
|
+
return ZodParsedType.string;
|
|
28348
|
+
case "number":
|
|
28349
|
+
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
28350
|
+
case "boolean":
|
|
28351
|
+
return ZodParsedType.boolean;
|
|
28352
|
+
case "function":
|
|
28353
|
+
return ZodParsedType.function;
|
|
28354
|
+
case "bigint":
|
|
28355
|
+
return ZodParsedType.bigint;
|
|
28356
|
+
case "symbol":
|
|
28357
|
+
return ZodParsedType.symbol;
|
|
28358
|
+
case "object":
|
|
28359
|
+
return Array.isArray(data) ? ZodParsedType.array : data === null ? ZodParsedType.null : data.then && typeof data.then == "function" && data.catch && typeof data.catch == "function" ? ZodParsedType.promise : typeof Map < "u" && data instanceof Map ? ZodParsedType.map : typeof Set < "u" && data instanceof Set ? ZodParsedType.set : typeof Date < "u" && data instanceof Date ? ZodParsedType.date : ZodParsedType.object;
|
|
28360
|
+
default:
|
|
28361
|
+
return ZodParsedType.unknown;
|
|
28362
|
+
}
|
|
28363
|
+
}, ZodIssueCode = util.arrayToEnum([
|
|
28364
|
+
"invalid_type",
|
|
28365
|
+
"invalid_literal",
|
|
28366
|
+
"custom",
|
|
28367
|
+
"invalid_union",
|
|
28368
|
+
"invalid_union_discriminator",
|
|
28369
|
+
"invalid_enum_value",
|
|
28370
|
+
"unrecognized_keys",
|
|
28371
|
+
"invalid_arguments",
|
|
28372
|
+
"invalid_return_type",
|
|
28373
|
+
"invalid_date",
|
|
28374
|
+
"invalid_string",
|
|
28375
|
+
"too_small",
|
|
28376
|
+
"too_big",
|
|
28377
|
+
"invalid_intersection_types",
|
|
28378
|
+
"not_multiple_of",
|
|
28379
|
+
"not_finite"
|
|
28380
|
+
]), quotelessJson = (obj) => JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:"), ZodError = class extends Error {
|
|
28381
|
+
constructor(issues) {
|
|
28382
|
+
super(), this.issues = [], this.addIssue = (sub) => {
|
|
28383
|
+
this.issues = [...this.issues, sub];
|
|
28384
|
+
}, this.addIssues = (subs = []) => {
|
|
28385
|
+
this.issues = [...this.issues, ...subs];
|
|
28386
|
+
};
|
|
28387
|
+
let actualProto = new.target.prototype;
|
|
28388
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, actualProto) : this.__proto__ = actualProto, this.name = "ZodError", this.issues = issues;
|
|
28389
|
+
}
|
|
28390
|
+
get errors() {
|
|
28391
|
+
return this.issues;
|
|
28392
|
+
}
|
|
28393
|
+
format(_mapper) {
|
|
28394
|
+
let mapper = _mapper || function(issue) {
|
|
28395
|
+
return issue.message;
|
|
28396
|
+
}, fieldErrors = { _errors: [] }, processError = (error) => {
|
|
28397
|
+
for (let issue of error.issues)
|
|
28398
|
+
if (issue.code === "invalid_union")
|
|
28399
|
+
issue.unionErrors.map(processError);
|
|
28400
|
+
else if (issue.code === "invalid_return_type")
|
|
28401
|
+
processError(issue.returnTypeError);
|
|
28402
|
+
else if (issue.code === "invalid_arguments")
|
|
28403
|
+
processError(issue.argumentsError);
|
|
28404
|
+
else if (issue.path.length === 0)
|
|
28405
|
+
fieldErrors._errors.push(mapper(issue));
|
|
28406
|
+
else {
|
|
28407
|
+
let curr = fieldErrors, i = 0;
|
|
28408
|
+
for (; i < issue.path.length; ) {
|
|
28409
|
+
let el = issue.path[i];
|
|
28410
|
+
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++;
|
|
28411
|
+
}
|
|
28412
|
+
}
|
|
28413
|
+
};
|
|
28414
|
+
return processError(this), fieldErrors;
|
|
28415
|
+
}
|
|
28416
|
+
toString() {
|
|
28417
|
+
return this.message;
|
|
28418
|
+
}
|
|
28419
|
+
get message() {
|
|
28420
|
+
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
28421
|
+
}
|
|
28422
|
+
get isEmpty() {
|
|
28423
|
+
return this.issues.length === 0;
|
|
28424
|
+
}
|
|
28425
|
+
flatten(mapper = (issue) => issue.message) {
|
|
28426
|
+
let fieldErrors = {}, formErrors = [];
|
|
28427
|
+
for (let sub of this.issues)
|
|
28428
|
+
sub.path.length > 0 ? (fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [], fieldErrors[sub.path[0]].push(mapper(sub))) : formErrors.push(mapper(sub));
|
|
28429
|
+
return { formErrors, fieldErrors };
|
|
28430
|
+
}
|
|
28431
|
+
get formErrors() {
|
|
28432
|
+
return this.flatten();
|
|
28433
|
+
}
|
|
28434
|
+
};
|
|
28435
|
+
ZodError.create = (issues) => new ZodError(issues);
|
|
28436
|
+
var errorMap = (issue, _ctx) => {
|
|
28437
|
+
let message;
|
|
28438
|
+
switch (issue.code) {
|
|
28439
|
+
case ZodIssueCode.invalid_type:
|
|
28440
|
+
issue.received === ZodParsedType.undefined ? message = "Required" : message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
28441
|
+
break;
|
|
28442
|
+
case ZodIssueCode.invalid_literal:
|
|
28443
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
28444
|
+
break;
|
|
28445
|
+
case ZodIssueCode.unrecognized_keys:
|
|
28446
|
+
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
28447
|
+
break;
|
|
28448
|
+
case ZodIssueCode.invalid_union:
|
|
28449
|
+
message = "Invalid input";
|
|
28450
|
+
break;
|
|
28451
|
+
case ZodIssueCode.invalid_union_discriminator:
|
|
28452
|
+
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
28453
|
+
break;
|
|
28454
|
+
case ZodIssueCode.invalid_enum_value:
|
|
28455
|
+
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
28456
|
+
break;
|
|
28457
|
+
case ZodIssueCode.invalid_arguments:
|
|
28458
|
+
message = "Invalid function arguments";
|
|
28459
|
+
break;
|
|
28460
|
+
case ZodIssueCode.invalid_return_type:
|
|
28461
|
+
message = "Invalid function return type";
|
|
28462
|
+
break;
|
|
28463
|
+
case ZodIssueCode.invalid_date:
|
|
28464
|
+
message = "Invalid date";
|
|
28465
|
+
break;
|
|
28466
|
+
case ZodIssueCode.invalid_string:
|
|
28467
|
+
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.assertNever(issue.validation) : issue.validation !== "regex" ? message = `Invalid ${issue.validation}` : message = "Invalid";
|
|
28468
|
+
break;
|
|
28469
|
+
case ZodIssueCode.too_small:
|
|
28470
|
+
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";
|
|
28471
|
+
break;
|
|
28472
|
+
case ZodIssueCode.too_big:
|
|
28473
|
+
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";
|
|
28474
|
+
break;
|
|
28475
|
+
case ZodIssueCode.custom:
|
|
28476
|
+
message = "Invalid input";
|
|
28477
|
+
break;
|
|
28478
|
+
case ZodIssueCode.invalid_intersection_types:
|
|
28479
|
+
message = "Intersection results could not be merged";
|
|
28480
|
+
break;
|
|
28481
|
+
case ZodIssueCode.not_multiple_of:
|
|
28482
|
+
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
28483
|
+
break;
|
|
28484
|
+
case ZodIssueCode.not_finite:
|
|
28485
|
+
message = "Number must be finite";
|
|
28486
|
+
break;
|
|
28487
|
+
default:
|
|
28488
|
+
message = _ctx.defaultError, util.assertNever(issue);
|
|
28489
|
+
}
|
|
28490
|
+
return { message };
|
|
28491
|
+
}, overrideErrorMap = errorMap;
|
|
28492
|
+
function setErrorMap(map) {
|
|
28493
|
+
overrideErrorMap = map;
|
|
28494
|
+
}
|
|
28495
|
+
function getErrorMap() {
|
|
28496
|
+
return overrideErrorMap;
|
|
28497
|
+
}
|
|
28498
|
+
var makeIssue = (params) => {
|
|
28499
|
+
let { data, path, errorMaps, issueData } = params, fullPath = [...path, ...issueData.path || []], fullIssue = {
|
|
28500
|
+
...issueData,
|
|
28501
|
+
path: fullPath
|
|
28502
|
+
}, errorMessage = "", maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
28503
|
+
for (let map of maps)
|
|
28504
|
+
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
28505
|
+
return {
|
|
28506
|
+
...issueData,
|
|
28507
|
+
path: fullPath,
|
|
28508
|
+
message: issueData.message || errorMessage
|
|
28509
|
+
};
|
|
28510
|
+
}, EMPTY_PATH = [];
|
|
28511
|
+
function addIssueToContext(ctx, issueData) {
|
|
28512
|
+
let issue = makeIssue({
|
|
28513
|
+
issueData,
|
|
28514
|
+
data: ctx.data,
|
|
28515
|
+
path: ctx.path,
|
|
28516
|
+
errorMaps: [
|
|
28517
|
+
ctx.common.contextualErrorMap,
|
|
28518
|
+
ctx.schemaErrorMap,
|
|
28519
|
+
getErrorMap(),
|
|
28520
|
+
errorMap
|
|
28521
|
+
// then global default map
|
|
28522
|
+
].filter((x) => !!x)
|
|
28523
|
+
});
|
|
28524
|
+
ctx.common.issues.push(issue);
|
|
28525
|
+
}
|
|
28526
|
+
var ParseStatus = class _ParseStatus {
|
|
28527
|
+
constructor() {
|
|
28528
|
+
this.value = "valid";
|
|
28529
|
+
}
|
|
28530
|
+
dirty() {
|
|
28531
|
+
this.value === "valid" && (this.value = "dirty");
|
|
28532
|
+
}
|
|
28533
|
+
abort() {
|
|
28534
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
28535
|
+
}
|
|
28536
|
+
static mergeArray(status, results) {
|
|
28537
|
+
let arrayValue = [];
|
|
28538
|
+
for (let s of results) {
|
|
28539
|
+
if (s.status === "aborted")
|
|
28540
|
+
return INVALID;
|
|
28541
|
+
s.status === "dirty" && status.dirty(), arrayValue.push(s.value);
|
|
28542
|
+
}
|
|
28543
|
+
return { status: status.value, value: arrayValue };
|
|
28544
|
+
}
|
|
28545
|
+
static async mergeObjectAsync(status, pairs) {
|
|
28546
|
+
let syncPairs = [];
|
|
28547
|
+
for (let pair of pairs)
|
|
28548
|
+
syncPairs.push({
|
|
28549
|
+
key: await pair.key,
|
|
28550
|
+
value: await pair.value
|
|
28551
|
+
});
|
|
28552
|
+
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
28553
|
+
}
|
|
28554
|
+
static mergeObjectSync(status, pairs) {
|
|
28555
|
+
let finalObject = {};
|
|
28556
|
+
for (let pair of pairs) {
|
|
28557
|
+
let { key, value } = pair;
|
|
28558
|
+
if (key.status === "aborted" || value.status === "aborted")
|
|
28559
|
+
return INVALID;
|
|
28560
|
+
key.status === "dirty" && status.dirty(), value.status === "dirty" && status.dirty(), key.value !== "__proto__" && (typeof value.value < "u" || pair.alwaysSet) && (finalObject[key.value] = value.value);
|
|
28561
|
+
}
|
|
28562
|
+
return { status: status.value, value: finalObject };
|
|
28563
|
+
}
|
|
28564
|
+
}, INVALID = Object.freeze({
|
|
28565
|
+
status: "aborted"
|
|
28566
|
+
}), DIRTY = (value) => ({ status: "dirty", value }), OK = (value) => ({ status: "valid", value }), isAborted = (x) => x.status === "aborted", isDirty = (x) => x.status === "dirty", isValid = (x) => x.status === "valid", isAsync = (x) => typeof Promise < "u" && x instanceof Promise, errorUtil;
|
|
28567
|
+
(function(errorUtil2) {
|
|
28568
|
+
errorUtil2.errToObj = (message) => typeof message == "string" ? { message } : message || {}, errorUtil2.toString = (message) => typeof message == "string" ? message : message?.message;
|
|
28569
|
+
})(errorUtil || (errorUtil = {}));
|
|
28570
|
+
var ParseInputLazyPath = class {
|
|
28571
|
+
constructor(parent, value, path, key) {
|
|
28572
|
+
this._cachedPath = [], this.parent = parent, this.data = value, this._path = path, this._key = key;
|
|
28573
|
+
}
|
|
28574
|
+
get path() {
|
|
28575
|
+
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
28576
|
+
}
|
|
28577
|
+
}, handleResult = (ctx, result) => {
|
|
28578
|
+
if (isValid(result))
|
|
28579
|
+
return { success: !0, data: result.value };
|
|
28580
|
+
if (!ctx.common.issues.length)
|
|
28581
|
+
throw new Error("Validation failed but no issues detected.");
|
|
28582
|
+
return {
|
|
28583
|
+
success: !1,
|
|
28584
|
+
get error() {
|
|
28585
|
+
if (this._error)
|
|
28586
|
+
return this._error;
|
|
28587
|
+
let error = new ZodError(ctx.common.issues);
|
|
28588
|
+
return this._error = error, this._error;
|
|
28589
|
+
}
|
|
28590
|
+
};
|
|
28591
|
+
};
|
|
28592
|
+
function processCreateParams(params) {
|
|
28593
|
+
if (!params)
|
|
28594
|
+
return {};
|
|
28595
|
+
let { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
|
|
28596
|
+
if (errorMap2 && (invalid_type_error || required_error))
|
|
28597
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
28598
|
+
return errorMap2 ? { errorMap: errorMap2, 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 };
|
|
28599
|
+
}
|
|
28600
|
+
var ZodType = class {
|
|
28601
|
+
constructor(def) {
|
|
28602
|
+
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);
|
|
28603
|
+
}
|
|
28604
|
+
get description() {
|
|
28605
|
+
return this._def.description;
|
|
28606
|
+
}
|
|
28607
|
+
_getType(input) {
|
|
28608
|
+
return getParsedType(input.data);
|
|
28609
|
+
}
|
|
28610
|
+
_getOrReturnCtx(input, ctx) {
|
|
28611
|
+
return ctx || {
|
|
28612
|
+
common: input.parent.common,
|
|
28613
|
+
data: input.data,
|
|
28614
|
+
parsedType: getParsedType(input.data),
|
|
28615
|
+
schemaErrorMap: this._def.errorMap,
|
|
28616
|
+
path: input.path,
|
|
28617
|
+
parent: input.parent
|
|
28618
|
+
};
|
|
28619
|
+
}
|
|
28620
|
+
_processInputParams(input) {
|
|
28621
|
+
return {
|
|
28622
|
+
status: new ParseStatus(),
|
|
28623
|
+
ctx: {
|
|
28624
|
+
common: input.parent.common,
|
|
28625
|
+
data: input.data,
|
|
28626
|
+
parsedType: getParsedType(input.data),
|
|
28627
|
+
schemaErrorMap: this._def.errorMap,
|
|
28628
|
+
path: input.path,
|
|
28629
|
+
parent: input.parent
|
|
28630
|
+
}
|
|
28631
|
+
};
|
|
28632
|
+
}
|
|
28633
|
+
_parseSync(input) {
|
|
28634
|
+
let result = this._parse(input);
|
|
28635
|
+
if (isAsync(result))
|
|
28636
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
28637
|
+
return result;
|
|
28638
|
+
}
|
|
28639
|
+
_parseAsync(input) {
|
|
28640
|
+
let result = this._parse(input);
|
|
28641
|
+
return Promise.resolve(result);
|
|
28642
|
+
}
|
|
28643
|
+
parse(data, params) {
|
|
28644
|
+
let result = this.safeParse(data, params);
|
|
28645
|
+
if (result.success)
|
|
28646
|
+
return result.data;
|
|
28647
|
+
throw result.error;
|
|
28648
|
+
}
|
|
28649
|
+
safeParse(data, params) {
|
|
28650
|
+
var _a;
|
|
28651
|
+
let ctx = {
|
|
28652
|
+
common: {
|
|
28653
|
+
issues: [],
|
|
28654
|
+
async: (_a = params?.async) !== null && _a !== void 0 ? _a : !1,
|
|
28655
|
+
contextualErrorMap: params?.errorMap
|
|
28656
|
+
},
|
|
28657
|
+
path: params?.path || [],
|
|
28658
|
+
schemaErrorMap: this._def.errorMap,
|
|
28659
|
+
parent: null,
|
|
28660
|
+
data,
|
|
28661
|
+
parsedType: getParsedType(data)
|
|
28662
|
+
}, result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
28663
|
+
return handleResult(ctx, result);
|
|
28664
|
+
}
|
|
28665
|
+
async parseAsync(data, params) {
|
|
28666
|
+
let result = await this.safeParseAsync(data, params);
|
|
28667
|
+
if (result.success)
|
|
28668
|
+
return result.data;
|
|
28669
|
+
throw result.error;
|
|
28670
|
+
}
|
|
28671
|
+
async safeParseAsync(data, params) {
|
|
28672
|
+
let ctx = {
|
|
28673
|
+
common: {
|
|
28674
|
+
issues: [],
|
|
28675
|
+
contextualErrorMap: params?.errorMap,
|
|
28676
|
+
async: !0
|
|
28677
|
+
},
|
|
28678
|
+
path: params?.path || [],
|
|
28679
|
+
schemaErrorMap: this._def.errorMap,
|
|
28680
|
+
parent: null,
|
|
28681
|
+
data,
|
|
28682
|
+
parsedType: getParsedType(data)
|
|
28683
|
+
}, maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }), result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
28684
|
+
return handleResult(ctx, result);
|
|
28685
|
+
}
|
|
28686
|
+
refine(check, message) {
|
|
28687
|
+
let getIssueProperties = (val) => typeof message == "string" || typeof message > "u" ? { message } : typeof message == "function" ? message(val) : message;
|
|
28688
|
+
return this._refinement((val, ctx) => {
|
|
28689
|
+
let result = check(val), setError = () => ctx.addIssue({
|
|
28690
|
+
code: ZodIssueCode.custom,
|
|
28691
|
+
...getIssueProperties(val)
|
|
28692
|
+
});
|
|
28693
|
+
return typeof Promise < "u" && result instanceof Promise ? result.then((data) => data ? !0 : (setError(), !1)) : result ? !0 : (setError(), !1);
|
|
28694
|
+
});
|
|
28695
|
+
}
|
|
28696
|
+
refinement(check, refinementData) {
|
|
28697
|
+
return this._refinement((val, ctx) => check(val) ? !0 : (ctx.addIssue(typeof refinementData == "function" ? refinementData(val, ctx) : refinementData), !1));
|
|
28698
|
+
}
|
|
28699
|
+
_refinement(refinement) {
|
|
28700
|
+
return new ZodEffects({
|
|
28701
|
+
schema: this,
|
|
28702
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
28703
|
+
effect: { type: "refinement", refinement }
|
|
28704
|
+
});
|
|
28705
|
+
}
|
|
28706
|
+
superRefine(refinement) {
|
|
28707
|
+
return this._refinement(refinement);
|
|
28708
|
+
}
|
|
28709
|
+
optional() {
|
|
28710
|
+
return ZodOptional.create(this, this._def);
|
|
28711
|
+
}
|
|
28712
|
+
nullable() {
|
|
28713
|
+
return ZodNullable.create(this, this._def);
|
|
28714
|
+
}
|
|
28715
|
+
nullish() {
|
|
28716
|
+
return this.nullable().optional();
|
|
28717
|
+
}
|
|
28718
|
+
array() {
|
|
28719
|
+
return ZodArray.create(this, this._def);
|
|
28720
|
+
}
|
|
28721
|
+
promise() {
|
|
28722
|
+
return ZodPromise.create(this, this._def);
|
|
28723
|
+
}
|
|
28724
|
+
or(option) {
|
|
28725
|
+
return ZodUnion.create([this, option], this._def);
|
|
28726
|
+
}
|
|
28727
|
+
and(incoming) {
|
|
28728
|
+
return ZodIntersection.create(this, incoming, this._def);
|
|
28729
|
+
}
|
|
28730
|
+
transform(transform) {
|
|
28731
|
+
return new ZodEffects({
|
|
28732
|
+
...processCreateParams(this._def),
|
|
28733
|
+
schema: this,
|
|
28734
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
28735
|
+
effect: { type: "transform", transform }
|
|
28736
|
+
});
|
|
28737
|
+
}
|
|
28738
|
+
default(def) {
|
|
28739
|
+
let defaultValueFunc = typeof def == "function" ? def : () => def;
|
|
28740
|
+
return new ZodDefault({
|
|
28741
|
+
...processCreateParams(this._def),
|
|
28742
|
+
innerType: this,
|
|
28743
|
+
defaultValue: defaultValueFunc,
|
|
28744
|
+
typeName: ZodFirstPartyTypeKind.ZodDefault
|
|
28745
|
+
});
|
|
28746
|
+
}
|
|
28747
|
+
brand() {
|
|
28748
|
+
return new ZodBranded({
|
|
28749
|
+
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
28750
|
+
type: this,
|
|
28751
|
+
...processCreateParams(this._def)
|
|
28752
|
+
});
|
|
28753
|
+
}
|
|
28754
|
+
catch(def) {
|
|
28755
|
+
let catchValueFunc = typeof def == "function" ? def : () => def;
|
|
28756
|
+
return new ZodCatch({
|
|
28757
|
+
...processCreateParams(this._def),
|
|
28758
|
+
innerType: this,
|
|
28759
|
+
catchValue: catchValueFunc,
|
|
28760
|
+
typeName: ZodFirstPartyTypeKind.ZodCatch
|
|
28761
|
+
});
|
|
28762
|
+
}
|
|
28763
|
+
describe(description) {
|
|
28764
|
+
let This = this.constructor;
|
|
28765
|
+
return new This({
|
|
28766
|
+
...this._def,
|
|
28767
|
+
description
|
|
28768
|
+
});
|
|
28769
|
+
}
|
|
28770
|
+
pipe(target) {
|
|
28771
|
+
return ZodPipeline.create(this, target);
|
|
28772
|
+
}
|
|
28773
|
+
readonly() {
|
|
28774
|
+
return ZodReadonly.create(this);
|
|
28775
|
+
}
|
|
28776
|
+
isOptional() {
|
|
28777
|
+
return this.safeParse(void 0).success;
|
|
28778
|
+
}
|
|
28779
|
+
isNullable() {
|
|
28780
|
+
return this.safeParse(null).success;
|
|
28781
|
+
}
|
|
28782
|
+
}, 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$");
|
|
28783
|
+
function isValidIP(ip, version) {
|
|
28784
|
+
return !!((version === "v4" || !version) && ipv4Regex.test(ip) || (version === "v6" || !version) && ipv6Regex.test(ip));
|
|
28785
|
+
}
|
|
28786
|
+
var ZodString = class _ZodString extends ZodType {
|
|
28787
|
+
constructor() {
|
|
28788
|
+
super(...arguments), this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
|
|
28789
|
+
validation,
|
|
28790
|
+
code: ZodIssueCode.invalid_string,
|
|
28791
|
+
...errorUtil.errToObj(message)
|
|
28792
|
+
}), this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)), this.trim = () => new _ZodString({
|
|
28793
|
+
...this._def,
|
|
28794
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
28795
|
+
}), this.toLowerCase = () => new _ZodString({
|
|
28796
|
+
...this._def,
|
|
28797
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
28798
|
+
}), this.toUpperCase = () => new _ZodString({
|
|
28799
|
+
...this._def,
|
|
28800
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
28801
|
+
});
|
|
28802
|
+
}
|
|
28803
|
+
_parse(input) {
|
|
28804
|
+
if (this._def.coerce && (input.data = String(input.data)), this._getType(input) !== ZodParsedType.string) {
|
|
28805
|
+
let ctx2 = this._getOrReturnCtx(input);
|
|
28806
|
+
return addIssueToContext(
|
|
28807
|
+
ctx2,
|
|
28808
|
+
{
|
|
28809
|
+
code: ZodIssueCode.invalid_type,
|
|
28810
|
+
expected: ZodParsedType.string,
|
|
28811
|
+
received: ctx2.parsedType
|
|
28812
|
+
}
|
|
28813
|
+
//
|
|
28814
|
+
), INVALID;
|
|
28815
|
+
}
|
|
28816
|
+
let status = new ParseStatus(), ctx;
|
|
28817
|
+
for (let check of this._def.checks)
|
|
28818
|
+
if (check.kind === "min")
|
|
28819
|
+
input.data.length < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28820
|
+
code: ZodIssueCode.too_small,
|
|
28821
|
+
minimum: check.value,
|
|
28822
|
+
type: "string",
|
|
28823
|
+
inclusive: !0,
|
|
28824
|
+
exact: !1,
|
|
28825
|
+
message: check.message
|
|
28826
|
+
}), status.dirty());
|
|
28827
|
+
else if (check.kind === "max")
|
|
28828
|
+
input.data.length > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28829
|
+
code: ZodIssueCode.too_big,
|
|
28830
|
+
maximum: check.value,
|
|
28831
|
+
type: "string",
|
|
28832
|
+
inclusive: !0,
|
|
28833
|
+
exact: !1,
|
|
28834
|
+
message: check.message
|
|
28835
|
+
}), status.dirty());
|
|
28836
|
+
else if (check.kind === "length") {
|
|
28837
|
+
let tooBig = input.data.length > check.value, tooSmall = input.data.length < check.value;
|
|
28838
|
+
(tooBig || tooSmall) && (ctx = this._getOrReturnCtx(input, ctx), tooBig ? addIssueToContext(ctx, {
|
|
28839
|
+
code: ZodIssueCode.too_big,
|
|
28840
|
+
maximum: check.value,
|
|
28841
|
+
type: "string",
|
|
28842
|
+
inclusive: !0,
|
|
28843
|
+
exact: !0,
|
|
28844
|
+
message: check.message
|
|
28845
|
+
}) : tooSmall && addIssueToContext(ctx, {
|
|
28846
|
+
code: ZodIssueCode.too_small,
|
|
28847
|
+
minimum: check.value,
|
|
28848
|
+
type: "string",
|
|
28849
|
+
inclusive: !0,
|
|
28850
|
+
exact: !0,
|
|
28851
|
+
message: check.message
|
|
28852
|
+
}), status.dirty());
|
|
28853
|
+
} else if (check.kind === "email")
|
|
28854
|
+
emailRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28855
|
+
validation: "email",
|
|
28856
|
+
code: ZodIssueCode.invalid_string,
|
|
28857
|
+
message: check.message
|
|
28858
|
+
}), status.dirty());
|
|
28859
|
+
else if (check.kind === "emoji")
|
|
28860
|
+
emojiRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28861
|
+
validation: "emoji",
|
|
28862
|
+
code: ZodIssueCode.invalid_string,
|
|
28863
|
+
message: check.message
|
|
28864
|
+
}), status.dirty());
|
|
28865
|
+
else if (check.kind === "uuid")
|
|
28866
|
+
uuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28867
|
+
validation: "uuid",
|
|
28868
|
+
code: ZodIssueCode.invalid_string,
|
|
28869
|
+
message: check.message
|
|
28870
|
+
}), status.dirty());
|
|
28871
|
+
else if (check.kind === "cuid")
|
|
28872
|
+
cuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28873
|
+
validation: "cuid",
|
|
28874
|
+
code: ZodIssueCode.invalid_string,
|
|
28875
|
+
message: check.message
|
|
28876
|
+
}), status.dirty());
|
|
28877
|
+
else if (check.kind === "cuid2")
|
|
28878
|
+
cuid2Regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28879
|
+
validation: "cuid2",
|
|
28880
|
+
code: ZodIssueCode.invalid_string,
|
|
28881
|
+
message: check.message
|
|
28882
|
+
}), status.dirty());
|
|
28883
|
+
else if (check.kind === "ulid")
|
|
28884
|
+
ulidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28885
|
+
validation: "ulid",
|
|
28886
|
+
code: ZodIssueCode.invalid_string,
|
|
28887
|
+
message: check.message
|
|
28888
|
+
}), status.dirty());
|
|
28889
|
+
else if (check.kind === "url")
|
|
28890
|
+
try {
|
|
28891
|
+
new URL(input.data);
|
|
28892
|
+
} catch {
|
|
28893
|
+
ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28894
|
+
validation: "url",
|
|
28895
|
+
code: ZodIssueCode.invalid_string,
|
|
28896
|
+
message: check.message
|
|
28897
|
+
}), status.dirty();
|
|
28898
|
+
}
|
|
28899
|
+
else
|
|
28900
|
+
check.kind === "regex" ? (check.regex.lastIndex = 0, check.regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28901
|
+
validation: "regex",
|
|
28902
|
+
code: ZodIssueCode.invalid_string,
|
|
28903
|
+
message: check.message
|
|
28904
|
+
}), 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), addIssueToContext(ctx, {
|
|
28905
|
+
code: ZodIssueCode.invalid_string,
|
|
28906
|
+
validation: { includes: check.value, position: check.position },
|
|
28907
|
+
message: check.message
|
|
28908
|
+
}), 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), addIssueToContext(ctx, {
|
|
28909
|
+
code: ZodIssueCode.invalid_string,
|
|
28910
|
+
validation: { startsWith: check.value },
|
|
28911
|
+
message: check.message
|
|
28912
|
+
}), status.dirty()) : check.kind === "endsWith" ? input.data.endsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28913
|
+
code: ZodIssueCode.invalid_string,
|
|
28914
|
+
validation: { endsWith: check.value },
|
|
28915
|
+
message: check.message
|
|
28916
|
+
}), status.dirty()) : check.kind === "datetime" ? datetimeRegex(check).test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28917
|
+
code: ZodIssueCode.invalid_string,
|
|
28918
|
+
validation: "datetime",
|
|
28919
|
+
message: check.message
|
|
28920
|
+
}), status.dirty()) : check.kind === "ip" ? isValidIP(input.data, check.version) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
28921
|
+
validation: "ip",
|
|
28922
|
+
code: ZodIssueCode.invalid_string,
|
|
28923
|
+
message: check.message
|
|
28924
|
+
}), status.dirty()) : util.assertNever(check);
|
|
28925
|
+
return { status: status.value, value: input.data };
|
|
28926
|
+
}
|
|
28927
|
+
_addCheck(check) {
|
|
28928
|
+
return new _ZodString({
|
|
28929
|
+
...this._def,
|
|
28930
|
+
checks: [...this._def.checks, check]
|
|
28931
|
+
});
|
|
28932
|
+
}
|
|
28933
|
+
email(message) {
|
|
28934
|
+
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
|
|
28935
|
+
}
|
|
28936
|
+
url(message) {
|
|
28937
|
+
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
28938
|
+
}
|
|
28939
|
+
emoji(message) {
|
|
28940
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
28941
|
+
}
|
|
28942
|
+
uuid(message) {
|
|
28943
|
+
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
28944
|
+
}
|
|
28945
|
+
cuid(message) {
|
|
28946
|
+
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
28947
|
+
}
|
|
28948
|
+
cuid2(message) {
|
|
28949
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
28950
|
+
}
|
|
28951
|
+
ulid(message) {
|
|
28952
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
28953
|
+
}
|
|
28954
|
+
ip(options) {
|
|
28955
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
28956
|
+
}
|
|
28957
|
+
datetime(options) {
|
|
28958
|
+
var _a;
|
|
28959
|
+
return typeof options == "string" ? this._addCheck({
|
|
28960
|
+
kind: "datetime",
|
|
28961
|
+
precision: null,
|
|
28962
|
+
offset: !1,
|
|
28963
|
+
message: options
|
|
28964
|
+
}) : this._addCheck({
|
|
28965
|
+
kind: "datetime",
|
|
28966
|
+
precision: typeof options?.precision > "u" ? null : options?.precision,
|
|
28967
|
+
offset: (_a = options?.offset) !== null && _a !== void 0 ? _a : !1,
|
|
28968
|
+
...errorUtil.errToObj(options?.message)
|
|
28969
|
+
});
|
|
28970
|
+
}
|
|
28971
|
+
regex(regex, message) {
|
|
28972
|
+
return this._addCheck({
|
|
28973
|
+
kind: "regex",
|
|
28974
|
+
regex,
|
|
28975
|
+
...errorUtil.errToObj(message)
|
|
28976
|
+
});
|
|
28977
|
+
}
|
|
28978
|
+
includes(value, options) {
|
|
28979
|
+
return this._addCheck({
|
|
28980
|
+
kind: "includes",
|
|
28981
|
+
value,
|
|
28982
|
+
position: options?.position,
|
|
28983
|
+
...errorUtil.errToObj(options?.message)
|
|
28984
|
+
});
|
|
28985
|
+
}
|
|
28986
|
+
startsWith(value, message) {
|
|
28987
|
+
return this._addCheck({
|
|
28988
|
+
kind: "startsWith",
|
|
28989
|
+
value,
|
|
28990
|
+
...errorUtil.errToObj(message)
|
|
28991
|
+
});
|
|
28992
|
+
}
|
|
28993
|
+
endsWith(value, message) {
|
|
28994
|
+
return this._addCheck({
|
|
28995
|
+
kind: "endsWith",
|
|
28996
|
+
value,
|
|
28997
|
+
...errorUtil.errToObj(message)
|
|
28998
|
+
});
|
|
28999
|
+
}
|
|
29000
|
+
min(minLength, message) {
|
|
29001
|
+
return this._addCheck({
|
|
29002
|
+
kind: "min",
|
|
29003
|
+
value: minLength,
|
|
29004
|
+
...errorUtil.errToObj(message)
|
|
29005
|
+
});
|
|
29006
|
+
}
|
|
29007
|
+
max(maxLength, message) {
|
|
29008
|
+
return this._addCheck({
|
|
29009
|
+
kind: "max",
|
|
29010
|
+
value: maxLength,
|
|
29011
|
+
...errorUtil.errToObj(message)
|
|
29012
|
+
});
|
|
29013
|
+
}
|
|
29014
|
+
length(len, message) {
|
|
29015
|
+
return this._addCheck({
|
|
29016
|
+
kind: "length",
|
|
29017
|
+
value: len,
|
|
29018
|
+
...errorUtil.errToObj(message)
|
|
29019
|
+
});
|
|
29020
|
+
}
|
|
29021
|
+
get isDatetime() {
|
|
29022
|
+
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
29023
|
+
}
|
|
29024
|
+
get isEmail() {
|
|
29025
|
+
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
29026
|
+
}
|
|
29027
|
+
get isURL() {
|
|
29028
|
+
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
29029
|
+
}
|
|
29030
|
+
get isEmoji() {
|
|
29031
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
29032
|
+
}
|
|
29033
|
+
get isUUID() {
|
|
29034
|
+
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
29035
|
+
}
|
|
29036
|
+
get isCUID() {
|
|
29037
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
29038
|
+
}
|
|
29039
|
+
get isCUID2() {
|
|
29040
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
29041
|
+
}
|
|
29042
|
+
get isULID() {
|
|
29043
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
29044
|
+
}
|
|
29045
|
+
get isIP() {
|
|
29046
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
29047
|
+
}
|
|
29048
|
+
get minLength() {
|
|
29049
|
+
let min = null;
|
|
29050
|
+
for (let ch of this._def.checks)
|
|
29051
|
+
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
29052
|
+
return min;
|
|
29053
|
+
}
|
|
29054
|
+
get maxLength() {
|
|
29055
|
+
let max = null;
|
|
29056
|
+
for (let ch of this._def.checks)
|
|
29057
|
+
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
29058
|
+
return max;
|
|
29059
|
+
}
|
|
29060
|
+
};
|
|
29061
|
+
ZodString.create = (params) => {
|
|
29062
|
+
var _a;
|
|
29063
|
+
return new ZodString({
|
|
29064
|
+
checks: [],
|
|
29065
|
+
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
29066
|
+
coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1,
|
|
29067
|
+
...processCreateParams(params)
|
|
29068
|
+
});
|
|
29069
|
+
};
|
|
29070
|
+
function floatSafeRemainder(val, step) {
|
|
29071
|
+
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(".", ""));
|
|
29072
|
+
return valInt % stepInt / Math.pow(10, decCount);
|
|
29073
|
+
}
|
|
29074
|
+
var ZodNumber = class _ZodNumber extends ZodType {
|
|
29075
|
+
constructor() {
|
|
29076
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
29077
|
+
}
|
|
29078
|
+
_parse(input) {
|
|
29079
|
+
if (this._def.coerce && (input.data = Number(input.data)), this._getType(input) !== ZodParsedType.number) {
|
|
29080
|
+
let ctx2 = this._getOrReturnCtx(input);
|
|
29081
|
+
return addIssueToContext(ctx2, {
|
|
29082
|
+
code: ZodIssueCode.invalid_type,
|
|
29083
|
+
expected: ZodParsedType.number,
|
|
29084
|
+
received: ctx2.parsedType
|
|
29085
|
+
}), INVALID;
|
|
29086
|
+
}
|
|
29087
|
+
let ctx, status = new ParseStatus();
|
|
29088
|
+
for (let check of this._def.checks)
|
|
29089
|
+
check.kind === "int" ? util.isInteger(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29090
|
+
code: ZodIssueCode.invalid_type,
|
|
29091
|
+
expected: "integer",
|
|
29092
|
+
received: "float",
|
|
29093
|
+
message: check.message
|
|
29094
|
+
}), status.dirty()) : check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29095
|
+
code: ZodIssueCode.too_small,
|
|
29096
|
+
minimum: check.value,
|
|
29097
|
+
type: "number",
|
|
29098
|
+
inclusive: check.inclusive,
|
|
29099
|
+
exact: !1,
|
|
29100
|
+
message: check.message
|
|
29101
|
+
}), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29102
|
+
code: ZodIssueCode.too_big,
|
|
29103
|
+
maximum: check.value,
|
|
29104
|
+
type: "number",
|
|
29105
|
+
inclusive: check.inclusive,
|
|
29106
|
+
exact: !1,
|
|
29107
|
+
message: check.message
|
|
29108
|
+
}), status.dirty()) : check.kind === "multipleOf" ? floatSafeRemainder(input.data, check.value) !== 0 && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29109
|
+
code: ZodIssueCode.not_multiple_of,
|
|
29110
|
+
multipleOf: check.value,
|
|
29111
|
+
message: check.message
|
|
29112
|
+
}), status.dirty()) : check.kind === "finite" ? Number.isFinite(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29113
|
+
code: ZodIssueCode.not_finite,
|
|
29114
|
+
message: check.message
|
|
29115
|
+
}), status.dirty()) : util.assertNever(check);
|
|
29116
|
+
return { status: status.value, value: input.data };
|
|
29117
|
+
}
|
|
29118
|
+
gte(value, message) {
|
|
29119
|
+
return this.setLimit("min", value, !0, errorUtil.toString(message));
|
|
29120
|
+
}
|
|
29121
|
+
gt(value, message) {
|
|
29122
|
+
return this.setLimit("min", value, !1, errorUtil.toString(message));
|
|
29123
|
+
}
|
|
29124
|
+
lte(value, message) {
|
|
29125
|
+
return this.setLimit("max", value, !0, errorUtil.toString(message));
|
|
29126
|
+
}
|
|
29127
|
+
lt(value, message) {
|
|
29128
|
+
return this.setLimit("max", value, !1, errorUtil.toString(message));
|
|
29129
|
+
}
|
|
29130
|
+
setLimit(kind, value, inclusive, message) {
|
|
29131
|
+
return new _ZodNumber({
|
|
29132
|
+
...this._def,
|
|
29133
|
+
checks: [
|
|
29134
|
+
...this._def.checks,
|
|
29135
|
+
{
|
|
29136
|
+
kind,
|
|
29137
|
+
value,
|
|
29138
|
+
inclusive,
|
|
29139
|
+
message: errorUtil.toString(message)
|
|
29140
|
+
}
|
|
29141
|
+
]
|
|
29142
|
+
});
|
|
29143
|
+
}
|
|
29144
|
+
_addCheck(check) {
|
|
29145
|
+
return new _ZodNumber({
|
|
29146
|
+
...this._def,
|
|
29147
|
+
checks: [...this._def.checks, check]
|
|
29148
|
+
});
|
|
29149
|
+
}
|
|
29150
|
+
int(message) {
|
|
29151
|
+
return this._addCheck({
|
|
29152
|
+
kind: "int",
|
|
29153
|
+
message: errorUtil.toString(message)
|
|
29154
|
+
});
|
|
29155
|
+
}
|
|
29156
|
+
positive(message) {
|
|
29157
|
+
return this._addCheck({
|
|
29158
|
+
kind: "min",
|
|
29159
|
+
value: 0,
|
|
29160
|
+
inclusive: !1,
|
|
29161
|
+
message: errorUtil.toString(message)
|
|
29162
|
+
});
|
|
29163
|
+
}
|
|
29164
|
+
negative(message) {
|
|
29165
|
+
return this._addCheck({
|
|
29166
|
+
kind: "max",
|
|
29167
|
+
value: 0,
|
|
29168
|
+
inclusive: !1,
|
|
29169
|
+
message: errorUtil.toString(message)
|
|
29170
|
+
});
|
|
29171
|
+
}
|
|
29172
|
+
nonpositive(message) {
|
|
29173
|
+
return this._addCheck({
|
|
29174
|
+
kind: "max",
|
|
29175
|
+
value: 0,
|
|
29176
|
+
inclusive: !0,
|
|
29177
|
+
message: errorUtil.toString(message)
|
|
29178
|
+
});
|
|
29179
|
+
}
|
|
29180
|
+
nonnegative(message) {
|
|
29181
|
+
return this._addCheck({
|
|
29182
|
+
kind: "min",
|
|
29183
|
+
value: 0,
|
|
29184
|
+
inclusive: !0,
|
|
29185
|
+
message: errorUtil.toString(message)
|
|
29186
|
+
});
|
|
29187
|
+
}
|
|
29188
|
+
multipleOf(value, message) {
|
|
29189
|
+
return this._addCheck({
|
|
29190
|
+
kind: "multipleOf",
|
|
29191
|
+
value,
|
|
29192
|
+
message: errorUtil.toString(message)
|
|
29193
|
+
});
|
|
29194
|
+
}
|
|
29195
|
+
finite(message) {
|
|
29196
|
+
return this._addCheck({
|
|
29197
|
+
kind: "finite",
|
|
29198
|
+
message: errorUtil.toString(message)
|
|
29199
|
+
});
|
|
29200
|
+
}
|
|
29201
|
+
safe(message) {
|
|
29202
|
+
return this._addCheck({
|
|
29203
|
+
kind: "min",
|
|
29204
|
+
inclusive: !0,
|
|
29205
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
29206
|
+
message: errorUtil.toString(message)
|
|
29207
|
+
})._addCheck({
|
|
29208
|
+
kind: "max",
|
|
29209
|
+
inclusive: !0,
|
|
29210
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
29211
|
+
message: errorUtil.toString(message)
|
|
29212
|
+
});
|
|
29213
|
+
}
|
|
29214
|
+
get minValue() {
|
|
29215
|
+
let min = null;
|
|
29216
|
+
for (let ch of this._def.checks)
|
|
29217
|
+
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
29218
|
+
return min;
|
|
29219
|
+
}
|
|
29220
|
+
get maxValue() {
|
|
29221
|
+
let max = null;
|
|
29222
|
+
for (let ch of this._def.checks)
|
|
29223
|
+
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
29224
|
+
return max;
|
|
29225
|
+
}
|
|
29226
|
+
get isInt() {
|
|
29227
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
29228
|
+
}
|
|
29229
|
+
get isFinite() {
|
|
29230
|
+
let max = null, min = null;
|
|
29231
|
+
for (let ch of this._def.checks) {
|
|
29232
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf")
|
|
29233
|
+
return !0;
|
|
29234
|
+
ch.kind === "min" ? (min === null || ch.value > min) && (min = ch.value) : ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
29235
|
+
}
|
|
29236
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
|
29237
|
+
}
|
|
29238
|
+
};
|
|
29239
|
+
ZodNumber.create = (params) => new ZodNumber({
|
|
29240
|
+
checks: [],
|
|
29241
|
+
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
29242
|
+
coerce: params?.coerce || !1,
|
|
29243
|
+
...processCreateParams(params)
|
|
29244
|
+
});
|
|
29245
|
+
var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
29246
|
+
constructor() {
|
|
29247
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
29248
|
+
}
|
|
29249
|
+
_parse(input) {
|
|
29250
|
+
if (this._def.coerce && (input.data = BigInt(input.data)), this._getType(input) !== ZodParsedType.bigint) {
|
|
29251
|
+
let ctx2 = this._getOrReturnCtx(input);
|
|
29252
|
+
return addIssueToContext(ctx2, {
|
|
29253
|
+
code: ZodIssueCode.invalid_type,
|
|
29254
|
+
expected: ZodParsedType.bigint,
|
|
29255
|
+
received: ctx2.parsedType
|
|
29256
|
+
}), INVALID;
|
|
29257
|
+
}
|
|
29258
|
+
let ctx, status = new ParseStatus();
|
|
29259
|
+
for (let check of this._def.checks)
|
|
29260
|
+
check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29261
|
+
code: ZodIssueCode.too_small,
|
|
29262
|
+
type: "bigint",
|
|
29263
|
+
minimum: check.value,
|
|
29264
|
+
inclusive: check.inclusive,
|
|
29265
|
+
message: check.message
|
|
29266
|
+
}), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29267
|
+
code: ZodIssueCode.too_big,
|
|
29268
|
+
type: "bigint",
|
|
29269
|
+
maximum: check.value,
|
|
29270
|
+
inclusive: check.inclusive,
|
|
29271
|
+
message: check.message
|
|
29272
|
+
}), status.dirty()) : check.kind === "multipleOf" ? input.data % check.value !== BigInt(0) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29273
|
+
code: ZodIssueCode.not_multiple_of,
|
|
29274
|
+
multipleOf: check.value,
|
|
29275
|
+
message: check.message
|
|
29276
|
+
}), status.dirty()) : util.assertNever(check);
|
|
29277
|
+
return { status: status.value, value: input.data };
|
|
29278
|
+
}
|
|
29279
|
+
gte(value, message) {
|
|
29280
|
+
return this.setLimit("min", value, !0, errorUtil.toString(message));
|
|
29281
|
+
}
|
|
29282
|
+
gt(value, message) {
|
|
29283
|
+
return this.setLimit("min", value, !1, errorUtil.toString(message));
|
|
29284
|
+
}
|
|
29285
|
+
lte(value, message) {
|
|
29286
|
+
return this.setLimit("max", value, !0, errorUtil.toString(message));
|
|
29287
|
+
}
|
|
29288
|
+
lt(value, message) {
|
|
29289
|
+
return this.setLimit("max", value, !1, errorUtil.toString(message));
|
|
29290
|
+
}
|
|
29291
|
+
setLimit(kind, value, inclusive, message) {
|
|
29292
|
+
return new _ZodBigInt({
|
|
29293
|
+
...this._def,
|
|
29294
|
+
checks: [
|
|
29295
|
+
...this._def.checks,
|
|
29296
|
+
{
|
|
29297
|
+
kind,
|
|
29298
|
+
value,
|
|
29299
|
+
inclusive,
|
|
29300
|
+
message: errorUtil.toString(message)
|
|
29301
|
+
}
|
|
29302
|
+
]
|
|
29303
|
+
});
|
|
29304
|
+
}
|
|
29305
|
+
_addCheck(check) {
|
|
29306
|
+
return new _ZodBigInt({
|
|
29307
|
+
...this._def,
|
|
29308
|
+
checks: [...this._def.checks, check]
|
|
29309
|
+
});
|
|
29310
|
+
}
|
|
29311
|
+
positive(message) {
|
|
29312
|
+
return this._addCheck({
|
|
29313
|
+
kind: "min",
|
|
29314
|
+
value: BigInt(0),
|
|
29315
|
+
inclusive: !1,
|
|
29316
|
+
message: errorUtil.toString(message)
|
|
29317
|
+
});
|
|
29318
|
+
}
|
|
29319
|
+
negative(message) {
|
|
29320
|
+
return this._addCheck({
|
|
29321
|
+
kind: "max",
|
|
29322
|
+
value: BigInt(0),
|
|
29323
|
+
inclusive: !1,
|
|
29324
|
+
message: errorUtil.toString(message)
|
|
29325
|
+
});
|
|
29326
|
+
}
|
|
29327
|
+
nonpositive(message) {
|
|
29328
|
+
return this._addCheck({
|
|
29329
|
+
kind: "max",
|
|
29330
|
+
value: BigInt(0),
|
|
29331
|
+
inclusive: !0,
|
|
29332
|
+
message: errorUtil.toString(message)
|
|
29333
|
+
});
|
|
29334
|
+
}
|
|
29335
|
+
nonnegative(message) {
|
|
29336
|
+
return this._addCheck({
|
|
29337
|
+
kind: "min",
|
|
29338
|
+
value: BigInt(0),
|
|
29339
|
+
inclusive: !0,
|
|
29340
|
+
message: errorUtil.toString(message)
|
|
29341
|
+
});
|
|
29342
|
+
}
|
|
29343
|
+
multipleOf(value, message) {
|
|
29344
|
+
return this._addCheck({
|
|
29345
|
+
kind: "multipleOf",
|
|
29346
|
+
value,
|
|
29347
|
+
message: errorUtil.toString(message)
|
|
29348
|
+
});
|
|
29349
|
+
}
|
|
29350
|
+
get minValue() {
|
|
29351
|
+
let min = null;
|
|
29352
|
+
for (let ch of this._def.checks)
|
|
29353
|
+
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
29354
|
+
return min;
|
|
29355
|
+
}
|
|
29356
|
+
get maxValue() {
|
|
29357
|
+
let max = null;
|
|
29358
|
+
for (let ch of this._def.checks)
|
|
29359
|
+
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
29360
|
+
return max;
|
|
29361
|
+
}
|
|
29362
|
+
};
|
|
29363
|
+
ZodBigInt.create = (params) => {
|
|
29364
|
+
var _a;
|
|
29365
|
+
return new ZodBigInt({
|
|
29366
|
+
checks: [],
|
|
29367
|
+
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
29368
|
+
coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1,
|
|
29369
|
+
...processCreateParams(params)
|
|
29370
|
+
});
|
|
29371
|
+
};
|
|
29372
|
+
var ZodBoolean = class extends ZodType {
|
|
29373
|
+
_parse(input) {
|
|
29374
|
+
if (this._def.coerce && (input.data = !!input.data), this._getType(input) !== ZodParsedType.boolean) {
|
|
29375
|
+
let ctx = this._getOrReturnCtx(input);
|
|
29376
|
+
return addIssueToContext(ctx, {
|
|
29377
|
+
code: ZodIssueCode.invalid_type,
|
|
29378
|
+
expected: ZodParsedType.boolean,
|
|
29379
|
+
received: ctx.parsedType
|
|
29380
|
+
}), INVALID;
|
|
29381
|
+
}
|
|
29382
|
+
return OK(input.data);
|
|
29383
|
+
}
|
|
29384
|
+
};
|
|
29385
|
+
ZodBoolean.create = (params) => new ZodBoolean({
|
|
29386
|
+
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
29387
|
+
coerce: params?.coerce || !1,
|
|
29388
|
+
...processCreateParams(params)
|
|
29389
|
+
});
|
|
29390
|
+
var ZodDate = class _ZodDate extends ZodType {
|
|
29391
|
+
_parse(input) {
|
|
29392
|
+
if (this._def.coerce && (input.data = new Date(input.data)), this._getType(input) !== ZodParsedType.date) {
|
|
29393
|
+
let ctx2 = this._getOrReturnCtx(input);
|
|
29394
|
+
return addIssueToContext(ctx2, {
|
|
29395
|
+
code: ZodIssueCode.invalid_type,
|
|
29396
|
+
expected: ZodParsedType.date,
|
|
29397
|
+
received: ctx2.parsedType
|
|
29398
|
+
}), INVALID;
|
|
29399
|
+
}
|
|
29400
|
+
if (isNaN(input.data.getTime())) {
|
|
29401
|
+
let ctx2 = this._getOrReturnCtx(input);
|
|
29402
|
+
return addIssueToContext(ctx2, {
|
|
29403
|
+
code: ZodIssueCode.invalid_date
|
|
29404
|
+
}), INVALID;
|
|
29405
|
+
}
|
|
29406
|
+
let status = new ParseStatus(), ctx;
|
|
29407
|
+
for (let check of this._def.checks)
|
|
29408
|
+
check.kind === "min" ? input.data.getTime() < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29409
|
+
code: ZodIssueCode.too_small,
|
|
29410
|
+
message: check.message,
|
|
29411
|
+
inclusive: !0,
|
|
29412
|
+
exact: !1,
|
|
29413
|
+
minimum: check.value,
|
|
29414
|
+
type: "date"
|
|
29415
|
+
}), status.dirty()) : check.kind === "max" ? input.data.getTime() > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
|
|
29416
|
+
code: ZodIssueCode.too_big,
|
|
29417
|
+
message: check.message,
|
|
29418
|
+
inclusive: !0,
|
|
29419
|
+
exact: !1,
|
|
29420
|
+
maximum: check.value,
|
|
29421
|
+
type: "date"
|
|
29422
|
+
}), status.dirty()) : util.assertNever(check);
|
|
29423
|
+
return {
|
|
29424
|
+
status: status.value,
|
|
29425
|
+
value: new Date(input.data.getTime())
|
|
29426
|
+
};
|
|
29427
|
+
}
|
|
29428
|
+
_addCheck(check) {
|
|
29429
|
+
return new _ZodDate({
|
|
29430
|
+
...this._def,
|
|
29431
|
+
checks: [...this._def.checks, check]
|
|
29432
|
+
});
|
|
29433
|
+
}
|
|
29434
|
+
min(minDate, message) {
|
|
29435
|
+
return this._addCheck({
|
|
29436
|
+
kind: "min",
|
|
29437
|
+
value: minDate.getTime(),
|
|
29438
|
+
message: errorUtil.toString(message)
|
|
29439
|
+
});
|
|
29440
|
+
}
|
|
29441
|
+
max(maxDate, message) {
|
|
29442
|
+
return this._addCheck({
|
|
29443
|
+
kind: "max",
|
|
29444
|
+
value: maxDate.getTime(),
|
|
29445
|
+
message: errorUtil.toString(message)
|
|
29446
|
+
});
|
|
29447
|
+
}
|
|
29448
|
+
get minDate() {
|
|
29449
|
+
let min = null;
|
|
29450
|
+
for (let ch of this._def.checks)
|
|
29451
|
+
ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
|
|
29452
|
+
return min != null ? new Date(min) : null;
|
|
29453
|
+
}
|
|
29454
|
+
get maxDate() {
|
|
29455
|
+
let max = null;
|
|
29456
|
+
for (let ch of this._def.checks)
|
|
29457
|
+
ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
|
|
29458
|
+
return max != null ? new Date(max) : null;
|
|
29459
|
+
}
|
|
29460
|
+
};
|
|
29461
|
+
ZodDate.create = (params) => new ZodDate({
|
|
29462
|
+
checks: [],
|
|
29463
|
+
coerce: params?.coerce || !1,
|
|
29464
|
+
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
29465
|
+
...processCreateParams(params)
|
|
29466
|
+
});
|
|
29467
|
+
var ZodSymbol = class extends ZodType {
|
|
29468
|
+
_parse(input) {
|
|
29469
|
+
if (this._getType(input) !== ZodParsedType.symbol) {
|
|
29470
|
+
let ctx = this._getOrReturnCtx(input);
|
|
29471
|
+
return addIssueToContext(ctx, {
|
|
29472
|
+
code: ZodIssueCode.invalid_type,
|
|
29473
|
+
expected: ZodParsedType.symbol,
|
|
29474
|
+
received: ctx.parsedType
|
|
29475
|
+
}), INVALID;
|
|
29476
|
+
}
|
|
29477
|
+
return OK(input.data);
|
|
29478
|
+
}
|
|
29479
|
+
};
|
|
29480
|
+
ZodSymbol.create = (params) => new ZodSymbol({
|
|
29481
|
+
typeName: ZodFirstPartyTypeKind.ZodSymbol,
|
|
29482
|
+
...processCreateParams(params)
|
|
29483
|
+
});
|
|
29484
|
+
var ZodUndefined = class extends ZodType {
|
|
29485
|
+
_parse(input) {
|
|
29486
|
+
if (this._getType(input) !== ZodParsedType.undefined) {
|
|
29487
|
+
let ctx = this._getOrReturnCtx(input);
|
|
29488
|
+
return addIssueToContext(ctx, {
|
|
29489
|
+
code: ZodIssueCode.invalid_type,
|
|
29490
|
+
expected: ZodParsedType.undefined,
|
|
29491
|
+
received: ctx.parsedType
|
|
29492
|
+
}), INVALID;
|
|
29493
|
+
}
|
|
29494
|
+
return OK(input.data);
|
|
29495
|
+
}
|
|
29496
|
+
};
|
|
29497
|
+
ZodUndefined.create = (params) => new ZodUndefined({
|
|
29498
|
+
typeName: ZodFirstPartyTypeKind.ZodUndefined,
|
|
29499
|
+
...processCreateParams(params)
|
|
29500
|
+
});
|
|
29501
|
+
var ZodNull = class extends ZodType {
|
|
29502
|
+
_parse(input) {
|
|
29503
|
+
if (this._getType(input) !== ZodParsedType.null) {
|
|
29504
|
+
let ctx = this._getOrReturnCtx(input);
|
|
29505
|
+
return addIssueToContext(ctx, {
|
|
29506
|
+
code: ZodIssueCode.invalid_type,
|
|
29507
|
+
expected: ZodParsedType.null,
|
|
29508
|
+
received: ctx.parsedType
|
|
29509
|
+
}), INVALID;
|
|
29510
|
+
}
|
|
29511
|
+
return OK(input.data);
|
|
29512
|
+
}
|
|
29513
|
+
};
|
|
29514
|
+
ZodNull.create = (params) => new ZodNull({
|
|
29515
|
+
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
29516
|
+
...processCreateParams(params)
|
|
29517
|
+
});
|
|
29518
|
+
var ZodAny = class extends ZodType {
|
|
29519
|
+
constructor() {
|
|
29520
|
+
super(...arguments), this._any = !0;
|
|
29521
|
+
}
|
|
29522
|
+
_parse(input) {
|
|
29523
|
+
return OK(input.data);
|
|
29524
|
+
}
|
|
29525
|
+
};
|
|
29526
|
+
ZodAny.create = (params) => new ZodAny({
|
|
29527
|
+
typeName: ZodFirstPartyTypeKind.ZodAny,
|
|
29528
|
+
...processCreateParams(params)
|
|
29529
|
+
});
|
|
29530
|
+
var ZodUnknown = class extends ZodType {
|
|
29531
|
+
constructor() {
|
|
29532
|
+
super(...arguments), this._unknown = !0;
|
|
29533
|
+
}
|
|
29534
|
+
_parse(input) {
|
|
29535
|
+
return OK(input.data);
|
|
29536
|
+
}
|
|
29537
|
+
};
|
|
29538
|
+
ZodUnknown.create = (params) => new ZodUnknown({
|
|
29539
|
+
typeName: ZodFirstPartyTypeKind.ZodUnknown,
|
|
29540
|
+
...processCreateParams(params)
|
|
29541
|
+
});
|
|
29542
|
+
var ZodNever = class extends ZodType {
|
|
29543
|
+
_parse(input) {
|
|
29544
|
+
let ctx = this._getOrReturnCtx(input);
|
|
29545
|
+
return addIssueToContext(ctx, {
|
|
29546
|
+
code: ZodIssueCode.invalid_type,
|
|
29547
|
+
expected: ZodParsedType.never,
|
|
29548
|
+
received: ctx.parsedType
|
|
29549
|
+
}), INVALID;
|
|
29550
|
+
}
|
|
29551
|
+
};
|
|
29552
|
+
ZodNever.create = (params) => new ZodNever({
|
|
29553
|
+
typeName: ZodFirstPartyTypeKind.ZodNever,
|
|
29554
|
+
...processCreateParams(params)
|
|
29555
|
+
});
|
|
29556
|
+
var ZodVoid = class extends ZodType {
|
|
29557
|
+
_parse(input) {
|
|
29558
|
+
if (this._getType(input) !== ZodParsedType.undefined) {
|
|
29559
|
+
let ctx = this._getOrReturnCtx(input);
|
|
29560
|
+
return addIssueToContext(ctx, {
|
|
29561
|
+
code: ZodIssueCode.invalid_type,
|
|
29562
|
+
expected: ZodParsedType.void,
|
|
29563
|
+
received: ctx.parsedType
|
|
29564
|
+
}), INVALID;
|
|
29565
|
+
}
|
|
29566
|
+
return OK(input.data);
|
|
29567
|
+
}
|
|
29568
|
+
};
|
|
29569
|
+
ZodVoid.create = (params) => new ZodVoid({
|
|
29570
|
+
typeName: ZodFirstPartyTypeKind.ZodVoid,
|
|
29571
|
+
...processCreateParams(params)
|
|
29572
|
+
});
|
|
29573
|
+
var ZodArray = class _ZodArray extends ZodType {
|
|
29574
|
+
_parse(input) {
|
|
29575
|
+
let { ctx, status } = this._processInputParams(input), def = this._def;
|
|
29576
|
+
if (ctx.parsedType !== ZodParsedType.array)
|
|
29577
|
+
return addIssueToContext(ctx, {
|
|
29578
|
+
code: ZodIssueCode.invalid_type,
|
|
29579
|
+
expected: ZodParsedType.array,
|
|
29580
|
+
received: ctx.parsedType
|
|
29581
|
+
}), INVALID;
|
|
29582
|
+
if (def.exactLength !== null) {
|
|
29583
|
+
let tooBig = ctx.data.length > def.exactLength.value, tooSmall = ctx.data.length < def.exactLength.value;
|
|
29584
|
+
(tooBig || tooSmall) && (addIssueToContext(ctx, {
|
|
29585
|
+
code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
|
|
29586
|
+
minimum: tooSmall ? def.exactLength.value : void 0,
|
|
29587
|
+
maximum: tooBig ? def.exactLength.value : void 0,
|
|
29588
|
+
type: "array",
|
|
29589
|
+
inclusive: !0,
|
|
29590
|
+
exact: !0,
|
|
29591
|
+
message: def.exactLength.message
|
|
29592
|
+
}), status.dirty());
|
|
29593
|
+
}
|
|
29594
|
+
if (def.minLength !== null && ctx.data.length < def.minLength.value && (addIssueToContext(ctx, {
|
|
29595
|
+
code: ZodIssueCode.too_small,
|
|
29596
|
+
minimum: def.minLength.value,
|
|
29597
|
+
type: "array",
|
|
29598
|
+
inclusive: !0,
|
|
29599
|
+
exact: !1,
|
|
29600
|
+
message: def.minLength.message
|
|
29601
|
+
}), status.dirty()), def.maxLength !== null && ctx.data.length > def.maxLength.value && (addIssueToContext(ctx, {
|
|
29602
|
+
code: ZodIssueCode.too_big,
|
|
29603
|
+
maximum: def.maxLength.value,
|
|
29604
|
+
type: "array",
|
|
29605
|
+
inclusive: !0,
|
|
29606
|
+
exact: !1,
|
|
29607
|
+
message: def.maxLength.message
|
|
29608
|
+
}), status.dirty()), ctx.common.async)
|
|
29609
|
+
return Promise.all([...ctx.data].map((item, i) => def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i)))).then((result2) => ParseStatus.mergeArray(status, result2));
|
|
29610
|
+
let result = [...ctx.data].map((item, i) => def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
29611
|
+
return ParseStatus.mergeArray(status, result);
|
|
29612
|
+
}
|
|
29613
|
+
get element() {
|
|
29614
|
+
return this._def.type;
|
|
29615
|
+
}
|
|
29616
|
+
min(minLength, message) {
|
|
29617
|
+
return new _ZodArray({
|
|
29618
|
+
...this._def,
|
|
29619
|
+
minLength: { value: minLength, message: errorUtil.toString(message) }
|
|
29620
|
+
});
|
|
29621
|
+
}
|
|
29622
|
+
max(maxLength, message) {
|
|
29623
|
+
return new _ZodArray({
|
|
29624
|
+
...this._def,
|
|
29625
|
+
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
|
29626
|
+
});
|
|
29627
|
+
}
|
|
29628
|
+
length(len, message) {
|
|
29629
|
+
return new _ZodArray({
|
|
29630
|
+
...this._def,
|
|
29631
|
+
exactLength: { value: len, message: errorUtil.toString(message) }
|
|
29632
|
+
});
|
|
29633
|
+
}
|
|
29634
|
+
nonempty(message) {
|
|
29635
|
+
return this.min(1, message);
|
|
29636
|
+
}
|
|
29637
|
+
};
|
|
29638
|
+
ZodArray.create = (schema, params) => new ZodArray({
|
|
29639
|
+
type: schema,
|
|
29640
|
+
minLength: null,
|
|
29641
|
+
maxLength: null,
|
|
29642
|
+
exactLength: null,
|
|
29643
|
+
typeName: ZodFirstPartyTypeKind.ZodArray,
|
|
29644
|
+
...processCreateParams(params)
|
|
29645
|
+
});
|
|
29646
|
+
function deepPartialify(schema) {
|
|
29647
|
+
if (schema instanceof ZodObject) {
|
|
29648
|
+
let newShape = {};
|
|
29649
|
+
for (let key in schema.shape) {
|
|
29650
|
+
let fieldSchema = schema.shape[key];
|
|
29651
|
+
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
29652
|
+
}
|
|
29653
|
+
return new ZodObject({
|
|
29654
|
+
...schema._def,
|
|
29655
|
+
shape: () => newShape
|
|
29656
|
+
});
|
|
29657
|
+
} else
|
|
29658
|
+
return schema instanceof ZodArray ? new ZodArray({
|
|
29659
|
+
...schema._def,
|
|
29660
|
+
type: deepPartialify(schema.element)
|
|
29661
|
+
}) : 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;
|
|
29662
|
+
}
|
|
29663
|
+
var ZodObject = class _ZodObject extends ZodType {
|
|
29664
|
+
constructor() {
|
|
29665
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
29666
|
+
}
|
|
29667
|
+
_getCached() {
|
|
29668
|
+
if (this._cached !== null)
|
|
29669
|
+
return this._cached;
|
|
29670
|
+
let shape = this._def.shape(), keys = util.objectKeys(shape);
|
|
29671
|
+
return this._cached = { shape, keys };
|
|
29672
|
+
}
|
|
29673
|
+
_parse(input) {
|
|
29674
|
+
if (this._getType(input) !== ZodParsedType.object) {
|
|
29675
|
+
let ctx2 = this._getOrReturnCtx(input);
|
|
29676
|
+
return addIssueToContext(ctx2, {
|
|
29677
|
+
code: ZodIssueCode.invalid_type,
|
|
29678
|
+
expected: ZodParsedType.object,
|
|
29679
|
+
received: ctx2.parsedType
|
|
29680
|
+
}), INVALID;
|
|
29681
|
+
}
|
|
29682
|
+
let { status, ctx } = this._processInputParams(input), { shape, keys: shapeKeys } = this._getCached(), extraKeys = [];
|
|
29683
|
+
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip"))
|
|
29684
|
+
for (let key in ctx.data)
|
|
29685
|
+
shapeKeys.includes(key) || extraKeys.push(key);
|
|
29686
|
+
let pairs = [];
|
|
29687
|
+
for (let key of shapeKeys) {
|
|
29688
|
+
let keyValidator = shape[key], value = ctx.data[key];
|
|
29689
|
+
pairs.push({
|
|
29690
|
+
key: { status: "valid", value: key },
|
|
29691
|
+
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
29692
|
+
alwaysSet: key in ctx.data
|
|
29693
|
+
});
|
|
29694
|
+
}
|
|
29695
|
+
if (this._def.catchall instanceof ZodNever) {
|
|
29696
|
+
let unknownKeys = this._def.unknownKeys;
|
|
29697
|
+
if (unknownKeys === "passthrough")
|
|
29698
|
+
for (let key of extraKeys)
|
|
29699
|
+
pairs.push({
|
|
29700
|
+
key: { status: "valid", value: key },
|
|
29701
|
+
value: { status: "valid", value: ctx.data[key] }
|
|
29702
|
+
});
|
|
29703
|
+
else if (unknownKeys === "strict")
|
|
29704
|
+
extraKeys.length > 0 && (addIssueToContext(ctx, {
|
|
29705
|
+
code: ZodIssueCode.unrecognized_keys,
|
|
29706
|
+
keys: extraKeys
|
|
29707
|
+
}), status.dirty());
|
|
29708
|
+
else if (unknownKeys !== "strip")
|
|
29709
|
+
throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
29710
|
+
} else {
|
|
29711
|
+
let catchall = this._def.catchall;
|
|
29712
|
+
for (let key of extraKeys) {
|
|
29713
|
+
let value = ctx.data[key];
|
|
29714
|
+
pairs.push({
|
|
29715
|
+
key: { status: "valid", value: key },
|
|
29716
|
+
value: catchall._parse(
|
|
29717
|
+
new ParseInputLazyPath(ctx, value, ctx.path, key)
|
|
29718
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
29719
|
+
),
|
|
29720
|
+
alwaysSet: key in ctx.data
|
|
29721
|
+
});
|
|
29722
|
+
}
|
|
29723
|
+
}
|
|
29724
|
+
return ctx.common.async ? Promise.resolve().then(async () => {
|
|
29725
|
+
let syncPairs = [];
|
|
29726
|
+
for (let pair of pairs) {
|
|
29727
|
+
let key = await pair.key;
|
|
29728
|
+
syncPairs.push({
|
|
29729
|
+
key,
|
|
29730
|
+
value: await pair.value,
|
|
29731
|
+
alwaysSet: pair.alwaysSet
|
|
29732
|
+
});
|
|
29733
|
+
}
|
|
29734
|
+
return syncPairs;
|
|
29735
|
+
}).then((syncPairs) => ParseStatus.mergeObjectSync(status, syncPairs)) : ParseStatus.mergeObjectSync(status, pairs);
|
|
29736
|
+
}
|
|
29737
|
+
get shape() {
|
|
29738
|
+
return this._def.shape();
|
|
29739
|
+
}
|
|
29740
|
+
strict(message) {
|
|
29741
|
+
return errorUtil.errToObj, new _ZodObject({
|
|
29742
|
+
...this._def,
|
|
29743
|
+
unknownKeys: "strict",
|
|
29744
|
+
...message !== void 0 ? {
|
|
29745
|
+
errorMap: (issue, ctx) => {
|
|
29746
|
+
var _a, _b, _c, _d;
|
|
29747
|
+
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;
|
|
29748
|
+
return issue.code === "unrecognized_keys" ? {
|
|
29749
|
+
message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
|
|
29750
|
+
} : {
|
|
29751
|
+
message: defaultError
|
|
29752
|
+
};
|
|
29753
|
+
}
|
|
29754
|
+
} : {}
|
|
29755
|
+
});
|
|
29756
|
+
}
|
|
29757
|
+
strip() {
|
|
29758
|
+
return new _ZodObject({
|
|
29759
|
+
...this._def,
|
|
29760
|
+
unknownKeys: "strip"
|
|
29761
|
+
});
|
|
29762
|
+
}
|
|
29763
|
+
passthrough() {
|
|
29764
|
+
return new _ZodObject({
|
|
29765
|
+
...this._def,
|
|
29766
|
+
unknownKeys: "passthrough"
|
|
29767
|
+
});
|
|
29768
|
+
}
|
|
29769
|
+
// const AugmentFactory =
|
|
29770
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
29771
|
+
// <Augmentation extends ZodRawShape>(
|
|
29772
|
+
// augmentation: Augmentation
|
|
29773
|
+
// ): ZodObject<
|
|
29774
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
29775
|
+
// Def["unknownKeys"],
|
|
29776
|
+
// Def["catchall"]
|
|
29777
|
+
// > => {
|
|
29778
|
+
// return new ZodObject({
|
|
29779
|
+
// ...def,
|
|
29780
|
+
// shape: () => ({
|
|
29781
|
+
// ...def.shape(),
|
|
29782
|
+
// ...augmentation,
|
|
29783
|
+
// }),
|
|
29784
|
+
// }) as any;
|
|
29785
|
+
// };
|
|
29786
|
+
extend(augmentation) {
|
|
29787
|
+
return new _ZodObject({
|
|
29788
|
+
...this._def,
|
|
29789
|
+
shape: () => ({
|
|
29790
|
+
...this._def.shape(),
|
|
29791
|
+
...augmentation
|
|
29792
|
+
})
|
|
29793
|
+
});
|
|
29794
|
+
}
|
|
29795
|
+
/**
|
|
29796
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
29797
|
+
* inferred type of merged objects. Please
|
|
29798
|
+
* upgrade if you are experiencing issues.
|
|
29799
|
+
*/
|
|
29800
|
+
merge(merging) {
|
|
29801
|
+
return new _ZodObject({
|
|
29802
|
+
unknownKeys: merging._def.unknownKeys,
|
|
29803
|
+
catchall: merging._def.catchall,
|
|
29804
|
+
shape: () => ({
|
|
29805
|
+
...this._def.shape(),
|
|
29806
|
+
...merging._def.shape()
|
|
29807
|
+
}),
|
|
29808
|
+
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
29809
|
+
});
|
|
29810
|
+
}
|
|
29811
|
+
// merge<
|
|
29812
|
+
// Incoming extends AnyZodObject,
|
|
29813
|
+
// Augmentation extends Incoming["shape"],
|
|
29814
|
+
// NewOutput extends {
|
|
29815
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
29816
|
+
// ? Augmentation[k]["_output"]
|
|
29817
|
+
// : k extends keyof Output
|
|
29818
|
+
// ? Output[k]
|
|
29819
|
+
// : never;
|
|
29820
|
+
// },
|
|
29821
|
+
// NewInput extends {
|
|
29822
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
29823
|
+
// ? Augmentation[k]["_input"]
|
|
29824
|
+
// : k extends keyof Input
|
|
29825
|
+
// ? Input[k]
|
|
29826
|
+
// : never;
|
|
29827
|
+
// }
|
|
29828
|
+
// >(
|
|
29829
|
+
// merging: Incoming
|
|
29830
|
+
// ): ZodObject<
|
|
29831
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
29832
|
+
// Incoming["_def"]["unknownKeys"],
|
|
29833
|
+
// Incoming["_def"]["catchall"],
|
|
29834
|
+
// NewOutput,
|
|
29835
|
+
// NewInput
|
|
29836
|
+
// > {
|
|
29837
|
+
// const merged: any = new ZodObject({
|
|
29838
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
29839
|
+
// catchall: merging._def.catchall,
|
|
29840
|
+
// shape: () =>
|
|
29841
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
29842
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
29843
|
+
// }) as any;
|
|
29844
|
+
// return merged;
|
|
29845
|
+
// }
|
|
29846
|
+
setKey(key, schema) {
|
|
29847
|
+
return this.augment({ [key]: schema });
|
|
29848
|
+
}
|
|
29849
|
+
// merge<Incoming extends AnyZodObject>(
|
|
29850
|
+
// merging: Incoming
|
|
29851
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
29852
|
+
// ZodObject<
|
|
29853
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
29854
|
+
// Incoming["_def"]["unknownKeys"],
|
|
29855
|
+
// Incoming["_def"]["catchall"]
|
|
29856
|
+
// > {
|
|
29857
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
29858
|
+
// // this._def.shape(),
|
|
29859
|
+
// // merging._def.shape()
|
|
29860
|
+
// // );
|
|
29861
|
+
// const merged: any = new ZodObject({
|
|
29862
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
29863
|
+
// catchall: merging._def.catchall,
|
|
29864
|
+
// shape: () =>
|
|
29865
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
29866
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
29867
|
+
// }) as any;
|
|
29868
|
+
// return merged;
|
|
29869
|
+
// }
|
|
29870
|
+
catchall(index) {
|
|
29871
|
+
return new _ZodObject({
|
|
29872
|
+
...this._def,
|
|
29873
|
+
catchall: index
|
|
29874
|
+
});
|
|
29875
|
+
}
|
|
29876
|
+
pick(mask) {
|
|
29877
|
+
let shape = {};
|
|
29878
|
+
return util.objectKeys(mask).forEach((key) => {
|
|
29879
|
+
mask[key] && this.shape[key] && (shape[key] = this.shape[key]);
|
|
29880
|
+
}), new _ZodObject({
|
|
29881
|
+
...this._def,
|
|
29882
|
+
shape: () => shape
|
|
29883
|
+
});
|
|
29884
|
+
}
|
|
29885
|
+
omit(mask) {
|
|
29886
|
+
let shape = {};
|
|
29887
|
+
return util.objectKeys(this.shape).forEach((key) => {
|
|
29888
|
+
mask[key] || (shape[key] = this.shape[key]);
|
|
29889
|
+
}), new _ZodObject({
|
|
29890
|
+
...this._def,
|
|
29891
|
+
shape: () => shape
|
|
29892
|
+
});
|
|
29893
|
+
}
|
|
29894
|
+
/**
|
|
29895
|
+
* @deprecated
|
|
29896
|
+
*/
|
|
29897
|
+
deepPartial() {
|
|
29898
|
+
return deepPartialify(this);
|
|
29899
|
+
}
|
|
29900
|
+
partial(mask) {
|
|
29901
|
+
let newShape = {};
|
|
29902
|
+
return util.objectKeys(this.shape).forEach((key) => {
|
|
29903
|
+
let fieldSchema = this.shape[key];
|
|
29904
|
+
mask && !mask[key] ? newShape[key] = fieldSchema : newShape[key] = fieldSchema.optional();
|
|
29905
|
+
}), new _ZodObject({
|
|
29906
|
+
...this._def,
|
|
29907
|
+
shape: () => newShape
|
|
29908
|
+
});
|
|
29909
|
+
}
|
|
29910
|
+
required(mask) {
|
|
29911
|
+
let newShape = {};
|
|
29912
|
+
return util.objectKeys(this.shape).forEach((key) => {
|
|
29913
|
+
if (mask && !mask[key])
|
|
29914
|
+
newShape[key] = this.shape[key];
|
|
29915
|
+
else {
|
|
29916
|
+
let newField = this.shape[key];
|
|
29917
|
+
for (; newField instanceof ZodOptional; )
|
|
29918
|
+
newField = newField._def.innerType;
|
|
29919
|
+
newShape[key] = newField;
|
|
29920
|
+
}
|
|
29921
|
+
}), new _ZodObject({
|
|
29922
|
+
...this._def,
|
|
29923
|
+
shape: () => newShape
|
|
29924
|
+
});
|
|
29925
|
+
}
|
|
29926
|
+
keyof() {
|
|
29927
|
+
return createZodEnum(util.objectKeys(this.shape));
|
|
29928
|
+
}
|
|
29929
|
+
};
|
|
29930
|
+
ZodObject.create = (shape, params) => new ZodObject({
|
|
29931
|
+
shape: () => shape,
|
|
29932
|
+
unknownKeys: "strip",
|
|
29933
|
+
catchall: ZodNever.create(),
|
|
29934
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
29935
|
+
...processCreateParams(params)
|
|
29936
|
+
});
|
|
29937
|
+
ZodObject.strictCreate = (shape, params) => new ZodObject({
|
|
29938
|
+
shape: () => shape,
|
|
29939
|
+
unknownKeys: "strict",
|
|
29940
|
+
catchall: ZodNever.create(),
|
|
29941
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
29942
|
+
...processCreateParams(params)
|
|
29943
|
+
});
|
|
29944
|
+
ZodObject.lazycreate = (shape, params) => new ZodObject({
|
|
29945
|
+
shape,
|
|
29946
|
+
unknownKeys: "strip",
|
|
29947
|
+
catchall: ZodNever.create(),
|
|
29948
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
29949
|
+
...processCreateParams(params)
|
|
29950
|
+
});
|
|
29951
|
+
var ZodUnion = class extends ZodType {
|
|
29952
|
+
_parse(input) {
|
|
29953
|
+
let { ctx } = this._processInputParams(input), options = this._def.options;
|
|
29954
|
+
function handleResults(results) {
|
|
29955
|
+
for (let result of results)
|
|
29956
|
+
if (result.result.status === "valid")
|
|
29957
|
+
return result.result;
|
|
29958
|
+
for (let result of results)
|
|
29959
|
+
if (result.result.status === "dirty")
|
|
29960
|
+
return ctx.common.issues.push(...result.ctx.common.issues), result.result;
|
|
29961
|
+
let unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
|
|
29962
|
+
return addIssueToContext(ctx, {
|
|
29963
|
+
code: ZodIssueCode.invalid_union,
|
|
29964
|
+
unionErrors
|
|
29965
|
+
}), INVALID;
|
|
29966
|
+
}
|
|
29967
|
+
if (ctx.common.async)
|
|
29968
|
+
return Promise.all(options.map(async (option) => {
|
|
29969
|
+
let childCtx = {
|
|
29970
|
+
...ctx,
|
|
29971
|
+
common: {
|
|
29972
|
+
...ctx.common,
|
|
29973
|
+
issues: []
|
|
29974
|
+
},
|
|
29975
|
+
parent: null
|
|
29976
|
+
};
|
|
29977
|
+
return {
|
|
29978
|
+
result: await option._parseAsync({
|
|
29979
|
+
data: ctx.data,
|
|
29980
|
+
path: ctx.path,
|
|
29981
|
+
parent: childCtx
|
|
29982
|
+
}),
|
|
29983
|
+
ctx: childCtx
|
|
29984
|
+
};
|
|
29985
|
+
})).then(handleResults);
|
|
29986
|
+
{
|
|
29987
|
+
let dirty, issues = [];
|
|
29988
|
+
for (let option of options) {
|
|
29989
|
+
let childCtx = {
|
|
29990
|
+
...ctx,
|
|
29991
|
+
common: {
|
|
29992
|
+
...ctx.common,
|
|
29993
|
+
issues: []
|
|
29994
|
+
},
|
|
29995
|
+
parent: null
|
|
29996
|
+
}, result = option._parseSync({
|
|
29997
|
+
data: ctx.data,
|
|
29998
|
+
path: ctx.path,
|
|
29999
|
+
parent: childCtx
|
|
30000
|
+
});
|
|
30001
|
+
if (result.status === "valid")
|
|
30002
|
+
return result;
|
|
30003
|
+
result.status === "dirty" && !dirty && (dirty = { result, ctx: childCtx }), childCtx.common.issues.length && issues.push(childCtx.common.issues);
|
|
30004
|
+
}
|
|
30005
|
+
if (dirty)
|
|
30006
|
+
return ctx.common.issues.push(...dirty.ctx.common.issues), dirty.result;
|
|
30007
|
+
let unionErrors = issues.map((issues2) => new ZodError(issues2));
|
|
30008
|
+
return addIssueToContext(ctx, {
|
|
30009
|
+
code: ZodIssueCode.invalid_union,
|
|
30010
|
+
unionErrors
|
|
30011
|
+
}), INVALID;
|
|
30012
|
+
}
|
|
30013
|
+
}
|
|
30014
|
+
get options() {
|
|
30015
|
+
return this._def.options;
|
|
30016
|
+
}
|
|
30017
|
+
};
|
|
30018
|
+
ZodUnion.create = (types3, params) => new ZodUnion({
|
|
30019
|
+
options: types3,
|
|
30020
|
+
typeName: ZodFirstPartyTypeKind.ZodUnion,
|
|
30021
|
+
...processCreateParams(params)
|
|
30022
|
+
});
|
|
30023
|
+
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 {
|
|
30024
|
+
_parse(input) {
|
|
30025
|
+
let { ctx } = this._processInputParams(input);
|
|
30026
|
+
if (ctx.parsedType !== ZodParsedType.object)
|
|
30027
|
+
return addIssueToContext(ctx, {
|
|
30028
|
+
code: ZodIssueCode.invalid_type,
|
|
30029
|
+
expected: ZodParsedType.object,
|
|
30030
|
+
received: ctx.parsedType
|
|
30031
|
+
}), INVALID;
|
|
30032
|
+
let discriminator = this.discriminator, discriminatorValue = ctx.data[discriminator], option = this.optionsMap.get(discriminatorValue);
|
|
30033
|
+
return option ? ctx.common.async ? option._parseAsync({
|
|
30034
|
+
data: ctx.data,
|
|
30035
|
+
path: ctx.path,
|
|
30036
|
+
parent: ctx
|
|
30037
|
+
}) : option._parseSync({
|
|
30038
|
+
data: ctx.data,
|
|
30039
|
+
path: ctx.path,
|
|
30040
|
+
parent: ctx
|
|
30041
|
+
}) : (addIssueToContext(ctx, {
|
|
30042
|
+
code: ZodIssueCode.invalid_union_discriminator,
|
|
30043
|
+
options: Array.from(this.optionsMap.keys()),
|
|
30044
|
+
path: [discriminator]
|
|
30045
|
+
}), INVALID);
|
|
30046
|
+
}
|
|
30047
|
+
get discriminator() {
|
|
30048
|
+
return this._def.discriminator;
|
|
30049
|
+
}
|
|
30050
|
+
get options() {
|
|
30051
|
+
return this._def.options;
|
|
30052
|
+
}
|
|
30053
|
+
get optionsMap() {
|
|
30054
|
+
return this._def.optionsMap;
|
|
30055
|
+
}
|
|
30056
|
+
/**
|
|
30057
|
+
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
30058
|
+
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
30059
|
+
* have a different value for each object in the union.
|
|
30060
|
+
* @param discriminator the name of the discriminator property
|
|
30061
|
+
* @param types an array of object schemas
|
|
30062
|
+
* @param params
|
|
30063
|
+
*/
|
|
30064
|
+
static create(discriminator, options, params) {
|
|
30065
|
+
let optionsMap = /* @__PURE__ */ new Map();
|
|
30066
|
+
for (let type of options) {
|
|
30067
|
+
let discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
30068
|
+
if (!discriminatorValues)
|
|
30069
|
+
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
30070
|
+
for (let value of discriminatorValues) {
|
|
30071
|
+
if (optionsMap.has(value))
|
|
30072
|
+
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
|
|
30073
|
+
optionsMap.set(value, type);
|
|
30074
|
+
}
|
|
30075
|
+
}
|
|
30076
|
+
return new _ZodDiscriminatedUnion({
|
|
30077
|
+
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
|
|
30078
|
+
discriminator,
|
|
30079
|
+
options,
|
|
30080
|
+
optionsMap,
|
|
30081
|
+
...processCreateParams(params)
|
|
30082
|
+
});
|
|
30083
|
+
}
|
|
30084
|
+
};
|
|
30085
|
+
function mergeValues(a, b) {
|
|
30086
|
+
let aType = getParsedType(a), bType = getParsedType(b);
|
|
30087
|
+
if (a === b)
|
|
30088
|
+
return { valid: !0, data: a };
|
|
30089
|
+
if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
30090
|
+
let bKeys = util.objectKeys(b), sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1), newObj = { ...a, ...b };
|
|
30091
|
+
for (let key of sharedKeys) {
|
|
30092
|
+
let sharedValue = mergeValues(a[key], b[key]);
|
|
30093
|
+
if (!sharedValue.valid)
|
|
30094
|
+
return { valid: !1 };
|
|
30095
|
+
newObj[key] = sharedValue.data;
|
|
30096
|
+
}
|
|
30097
|
+
return { valid: !0, data: newObj };
|
|
30098
|
+
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
30099
|
+
if (a.length !== b.length)
|
|
30100
|
+
return { valid: !1 };
|
|
30101
|
+
let newArray = [];
|
|
30102
|
+
for (let index = 0; index < a.length; index++) {
|
|
30103
|
+
let itemA = a[index], itemB = b[index], sharedValue = mergeValues(itemA, itemB);
|
|
30104
|
+
if (!sharedValue.valid)
|
|
30105
|
+
return { valid: !1 };
|
|
30106
|
+
newArray.push(sharedValue.data);
|
|
30107
|
+
}
|
|
30108
|
+
return { valid: !0, data: newArray };
|
|
30109
|
+
} else
|
|
30110
|
+
return aType === ZodParsedType.date && bType === ZodParsedType.date && +a == +b ? { valid: !0, data: a } : { valid: !1 };
|
|
30111
|
+
}
|
|
30112
|
+
var ZodIntersection = class extends ZodType {
|
|
30113
|
+
_parse(input) {
|
|
30114
|
+
let { status, ctx } = this._processInputParams(input), handleParsed = (parsedLeft, parsedRight) => {
|
|
30115
|
+
if (isAborted(parsedLeft) || isAborted(parsedRight))
|
|
30116
|
+
return INVALID;
|
|
30117
|
+
let merged = mergeValues(parsedLeft.value, parsedRight.value);
|
|
30118
|
+
return merged.valid ? ((isDirty(parsedLeft) || isDirty(parsedRight)) && status.dirty(), { status: status.value, value: merged.data }) : (addIssueToContext(ctx, {
|
|
30119
|
+
code: ZodIssueCode.invalid_intersection_types
|
|
30120
|
+
}), INVALID);
|
|
30121
|
+
};
|
|
30122
|
+
return ctx.common.async ? Promise.all([
|
|
30123
|
+
this._def.left._parseAsync({
|
|
30124
|
+
data: ctx.data,
|
|
30125
|
+
path: ctx.path,
|
|
30126
|
+
parent: ctx
|
|
30127
|
+
}),
|
|
30128
|
+
this._def.right._parseAsync({
|
|
30129
|
+
data: ctx.data,
|
|
30130
|
+
path: ctx.path,
|
|
30131
|
+
parent: ctx
|
|
30132
|
+
})
|
|
30133
|
+
]).then(([left, right]) => handleParsed(left, right)) : handleParsed(this._def.left._parseSync({
|
|
30134
|
+
data: ctx.data,
|
|
30135
|
+
path: ctx.path,
|
|
30136
|
+
parent: ctx
|
|
30137
|
+
}), this._def.right._parseSync({
|
|
30138
|
+
data: ctx.data,
|
|
30139
|
+
path: ctx.path,
|
|
30140
|
+
parent: ctx
|
|
30141
|
+
}));
|
|
30142
|
+
}
|
|
30143
|
+
};
|
|
30144
|
+
ZodIntersection.create = (left, right, params) => new ZodIntersection({
|
|
30145
|
+
left,
|
|
30146
|
+
right,
|
|
30147
|
+
typeName: ZodFirstPartyTypeKind.ZodIntersection,
|
|
30148
|
+
...processCreateParams(params)
|
|
30149
|
+
});
|
|
30150
|
+
var ZodTuple = class _ZodTuple extends ZodType {
|
|
30151
|
+
_parse(input) {
|
|
30152
|
+
let { status, ctx } = this._processInputParams(input);
|
|
30153
|
+
if (ctx.parsedType !== ZodParsedType.array)
|
|
30154
|
+
return addIssueToContext(ctx, {
|
|
30155
|
+
code: ZodIssueCode.invalid_type,
|
|
30156
|
+
expected: ZodParsedType.array,
|
|
30157
|
+
received: ctx.parsedType
|
|
30158
|
+
}), INVALID;
|
|
30159
|
+
if (ctx.data.length < this._def.items.length)
|
|
30160
|
+
return addIssueToContext(ctx, {
|
|
30161
|
+
code: ZodIssueCode.too_small,
|
|
30162
|
+
minimum: this._def.items.length,
|
|
30163
|
+
inclusive: !0,
|
|
30164
|
+
exact: !1,
|
|
30165
|
+
type: "array"
|
|
30166
|
+
}), INVALID;
|
|
30167
|
+
!this._def.rest && ctx.data.length > this._def.items.length && (addIssueToContext(ctx, {
|
|
30168
|
+
code: ZodIssueCode.too_big,
|
|
30169
|
+
maximum: this._def.items.length,
|
|
30170
|
+
inclusive: !0,
|
|
30171
|
+
exact: !1,
|
|
30172
|
+
type: "array"
|
|
30173
|
+
}), status.dirty());
|
|
30174
|
+
let items = [...ctx.data].map((item, itemIndex) => {
|
|
30175
|
+
let schema = this._def.items[itemIndex] || this._def.rest;
|
|
30176
|
+
return schema ? schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)) : null;
|
|
30177
|
+
}).filter((x) => !!x);
|
|
30178
|
+
return ctx.common.async ? Promise.all(items).then((results) => ParseStatus.mergeArray(status, results)) : ParseStatus.mergeArray(status, items);
|
|
30179
|
+
}
|
|
30180
|
+
get items() {
|
|
30181
|
+
return this._def.items;
|
|
30182
|
+
}
|
|
30183
|
+
rest(rest) {
|
|
30184
|
+
return new _ZodTuple({
|
|
30185
|
+
...this._def,
|
|
30186
|
+
rest
|
|
30187
|
+
});
|
|
30188
|
+
}
|
|
30189
|
+
};
|
|
30190
|
+
ZodTuple.create = (schemas, params) => {
|
|
30191
|
+
if (!Array.isArray(schemas))
|
|
30192
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
30193
|
+
return new ZodTuple({
|
|
30194
|
+
items: schemas,
|
|
30195
|
+
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
|
30196
|
+
rest: null,
|
|
30197
|
+
...processCreateParams(params)
|
|
30198
|
+
});
|
|
30199
|
+
};
|
|
30200
|
+
var ZodRecord = class _ZodRecord extends ZodType {
|
|
30201
|
+
get keySchema() {
|
|
30202
|
+
return this._def.keyType;
|
|
30203
|
+
}
|
|
30204
|
+
get valueSchema() {
|
|
30205
|
+
return this._def.valueType;
|
|
30206
|
+
}
|
|
30207
|
+
_parse(input) {
|
|
30208
|
+
let { status, ctx } = this._processInputParams(input);
|
|
30209
|
+
if (ctx.parsedType !== ZodParsedType.object)
|
|
30210
|
+
return addIssueToContext(ctx, {
|
|
30211
|
+
code: ZodIssueCode.invalid_type,
|
|
30212
|
+
expected: ZodParsedType.object,
|
|
30213
|
+
received: ctx.parsedType
|
|
30214
|
+
}), INVALID;
|
|
30215
|
+
let pairs = [], keyType = this._def.keyType, valueType = this._def.valueType;
|
|
30216
|
+
for (let key in ctx.data)
|
|
30217
|
+
pairs.push({
|
|
30218
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
30219
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
30220
|
+
});
|
|
30221
|
+
return ctx.common.async ? ParseStatus.mergeObjectAsync(status, pairs) : ParseStatus.mergeObjectSync(status, pairs);
|
|
30222
|
+
}
|
|
30223
|
+
get element() {
|
|
30224
|
+
return this._def.valueType;
|
|
30225
|
+
}
|
|
30226
|
+
static create(first, second, third) {
|
|
30227
|
+
return second instanceof ZodType ? new _ZodRecord({
|
|
30228
|
+
keyType: first,
|
|
30229
|
+
valueType: second,
|
|
30230
|
+
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
30231
|
+
...processCreateParams(third)
|
|
30232
|
+
}) : new _ZodRecord({
|
|
30233
|
+
keyType: ZodString.create(),
|
|
30234
|
+
valueType: first,
|
|
30235
|
+
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
30236
|
+
...processCreateParams(second)
|
|
30237
|
+
});
|
|
30238
|
+
}
|
|
30239
|
+
}, ZodMap = class extends ZodType {
|
|
30240
|
+
get keySchema() {
|
|
30241
|
+
return this._def.keyType;
|
|
30242
|
+
}
|
|
30243
|
+
get valueSchema() {
|
|
30244
|
+
return this._def.valueType;
|
|
30245
|
+
}
|
|
30246
|
+
_parse(input) {
|
|
30247
|
+
let { status, ctx } = this._processInputParams(input);
|
|
30248
|
+
if (ctx.parsedType !== ZodParsedType.map)
|
|
30249
|
+
return addIssueToContext(ctx, {
|
|
30250
|
+
code: ZodIssueCode.invalid_type,
|
|
30251
|
+
expected: ZodParsedType.map,
|
|
30252
|
+
received: ctx.parsedType
|
|
30253
|
+
}), INVALID;
|
|
30254
|
+
let keyType = this._def.keyType, valueType = this._def.valueType, pairs = [...ctx.data.entries()].map(([key, value], index) => ({
|
|
30255
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
|
|
30256
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
|
|
30257
|
+
}));
|
|
30258
|
+
if (ctx.common.async) {
|
|
30259
|
+
let finalMap = /* @__PURE__ */ new Map();
|
|
30260
|
+
return Promise.resolve().then(async () => {
|
|
30261
|
+
for (let pair of pairs) {
|
|
30262
|
+
let key = await pair.key, value = await pair.value;
|
|
30263
|
+
if (key.status === "aborted" || value.status === "aborted")
|
|
30264
|
+
return INVALID;
|
|
30265
|
+
(key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
|
|
30266
|
+
}
|
|
30267
|
+
return { status: status.value, value: finalMap };
|
|
30268
|
+
});
|
|
30269
|
+
} else {
|
|
30270
|
+
let finalMap = /* @__PURE__ */ new Map();
|
|
30271
|
+
for (let pair of pairs) {
|
|
30272
|
+
let key = pair.key, value = pair.value;
|
|
30273
|
+
if (key.status === "aborted" || value.status === "aborted")
|
|
30274
|
+
return INVALID;
|
|
30275
|
+
(key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
|
|
30276
|
+
}
|
|
30277
|
+
return { status: status.value, value: finalMap };
|
|
30278
|
+
}
|
|
30279
|
+
}
|
|
30280
|
+
};
|
|
30281
|
+
ZodMap.create = (keyType, valueType, params) => new ZodMap({
|
|
30282
|
+
valueType,
|
|
30283
|
+
keyType,
|
|
30284
|
+
typeName: ZodFirstPartyTypeKind.ZodMap,
|
|
30285
|
+
...processCreateParams(params)
|
|
30286
|
+
});
|
|
30287
|
+
var ZodSet = class _ZodSet extends ZodType {
|
|
30288
|
+
_parse(input) {
|
|
30289
|
+
let { status, ctx } = this._processInputParams(input);
|
|
30290
|
+
if (ctx.parsedType !== ZodParsedType.set)
|
|
30291
|
+
return addIssueToContext(ctx, {
|
|
30292
|
+
code: ZodIssueCode.invalid_type,
|
|
30293
|
+
expected: ZodParsedType.set,
|
|
30294
|
+
received: ctx.parsedType
|
|
30295
|
+
}), INVALID;
|
|
30296
|
+
let def = this._def;
|
|
30297
|
+
def.minSize !== null && ctx.data.size < def.minSize.value && (addIssueToContext(ctx, {
|
|
30298
|
+
code: ZodIssueCode.too_small,
|
|
30299
|
+
minimum: def.minSize.value,
|
|
30300
|
+
type: "set",
|
|
30301
|
+
inclusive: !0,
|
|
30302
|
+
exact: !1,
|
|
30303
|
+
message: def.minSize.message
|
|
30304
|
+
}), status.dirty()), def.maxSize !== null && ctx.data.size > def.maxSize.value && (addIssueToContext(ctx, {
|
|
30305
|
+
code: ZodIssueCode.too_big,
|
|
30306
|
+
maximum: def.maxSize.value,
|
|
30307
|
+
type: "set",
|
|
30308
|
+
inclusive: !0,
|
|
30309
|
+
exact: !1,
|
|
30310
|
+
message: def.maxSize.message
|
|
30311
|
+
}), status.dirty());
|
|
30312
|
+
let valueType = this._def.valueType;
|
|
30313
|
+
function finalizeSet(elements2) {
|
|
30314
|
+
let parsedSet = /* @__PURE__ */ new Set();
|
|
30315
|
+
for (let element of elements2) {
|
|
30316
|
+
if (element.status === "aborted")
|
|
30317
|
+
return INVALID;
|
|
30318
|
+
element.status === "dirty" && status.dirty(), parsedSet.add(element.value);
|
|
30319
|
+
}
|
|
30320
|
+
return { status: status.value, value: parsedSet };
|
|
30321
|
+
}
|
|
30322
|
+
let elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
30323
|
+
return ctx.common.async ? Promise.all(elements).then((elements2) => finalizeSet(elements2)) : finalizeSet(elements);
|
|
30324
|
+
}
|
|
30325
|
+
min(minSize, message) {
|
|
30326
|
+
return new _ZodSet({
|
|
30327
|
+
...this._def,
|
|
30328
|
+
minSize: { value: minSize, message: errorUtil.toString(message) }
|
|
30329
|
+
});
|
|
30330
|
+
}
|
|
30331
|
+
max(maxSize, message) {
|
|
30332
|
+
return new _ZodSet({
|
|
30333
|
+
...this._def,
|
|
30334
|
+
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
|
30335
|
+
});
|
|
30336
|
+
}
|
|
30337
|
+
size(size, message) {
|
|
30338
|
+
return this.min(size, message).max(size, message);
|
|
30339
|
+
}
|
|
30340
|
+
nonempty(message) {
|
|
30341
|
+
return this.min(1, message);
|
|
30342
|
+
}
|
|
30343
|
+
};
|
|
30344
|
+
ZodSet.create = (valueType, params) => new ZodSet({
|
|
30345
|
+
valueType,
|
|
30346
|
+
minSize: null,
|
|
30347
|
+
maxSize: null,
|
|
30348
|
+
typeName: ZodFirstPartyTypeKind.ZodSet,
|
|
30349
|
+
...processCreateParams(params)
|
|
30350
|
+
});
|
|
30351
|
+
var ZodFunction = class _ZodFunction extends ZodType {
|
|
30352
|
+
constructor() {
|
|
30353
|
+
super(...arguments), this.validate = this.implement;
|
|
30354
|
+
}
|
|
30355
|
+
_parse(input) {
|
|
30356
|
+
let { ctx } = this._processInputParams(input);
|
|
30357
|
+
if (ctx.parsedType !== ZodParsedType.function)
|
|
30358
|
+
return addIssueToContext(ctx, {
|
|
30359
|
+
code: ZodIssueCode.invalid_type,
|
|
30360
|
+
expected: ZodParsedType.function,
|
|
30361
|
+
received: ctx.parsedType
|
|
30362
|
+
}), INVALID;
|
|
30363
|
+
function makeArgsIssue(args, error) {
|
|
30364
|
+
return makeIssue({
|
|
30365
|
+
data: args,
|
|
30366
|
+
path: ctx.path,
|
|
30367
|
+
errorMaps: [
|
|
30368
|
+
ctx.common.contextualErrorMap,
|
|
30369
|
+
ctx.schemaErrorMap,
|
|
30370
|
+
getErrorMap(),
|
|
30371
|
+
errorMap
|
|
30372
|
+
].filter((x) => !!x),
|
|
30373
|
+
issueData: {
|
|
30374
|
+
code: ZodIssueCode.invalid_arguments,
|
|
30375
|
+
argumentsError: error
|
|
30376
|
+
}
|
|
30377
|
+
});
|
|
30378
|
+
}
|
|
30379
|
+
function makeReturnsIssue(returns, error) {
|
|
30380
|
+
return makeIssue({
|
|
30381
|
+
data: returns,
|
|
30382
|
+
path: ctx.path,
|
|
30383
|
+
errorMaps: [
|
|
30384
|
+
ctx.common.contextualErrorMap,
|
|
30385
|
+
ctx.schemaErrorMap,
|
|
30386
|
+
getErrorMap(),
|
|
30387
|
+
errorMap
|
|
30388
|
+
].filter((x) => !!x),
|
|
30389
|
+
issueData: {
|
|
30390
|
+
code: ZodIssueCode.invalid_return_type,
|
|
30391
|
+
returnTypeError: error
|
|
30392
|
+
}
|
|
30393
|
+
});
|
|
30394
|
+
}
|
|
30395
|
+
let params = { errorMap: ctx.common.contextualErrorMap }, fn = ctx.data;
|
|
30396
|
+
if (this._def.returns instanceof ZodPromise) {
|
|
30397
|
+
let me = this;
|
|
30398
|
+
return OK(async function(...args) {
|
|
30399
|
+
let error = new ZodError([]), parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
30400
|
+
throw error.addIssue(makeArgsIssue(args, e)), error;
|
|
30401
|
+
}), result = await Reflect.apply(fn, this, parsedArgs);
|
|
30402
|
+
return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
30403
|
+
throw error.addIssue(makeReturnsIssue(result, e)), error;
|
|
30404
|
+
});
|
|
30405
|
+
});
|
|
30406
|
+
} else {
|
|
30407
|
+
let me = this;
|
|
30408
|
+
return OK(function(...args) {
|
|
30409
|
+
let parsedArgs = me._def.args.safeParse(args, params);
|
|
30410
|
+
if (!parsedArgs.success)
|
|
30411
|
+
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
30412
|
+
let result = Reflect.apply(fn, this, parsedArgs.data), parsedReturns = me._def.returns.safeParse(result, params);
|
|
30413
|
+
if (!parsedReturns.success)
|
|
30414
|
+
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
30415
|
+
return parsedReturns.data;
|
|
30416
|
+
});
|
|
30417
|
+
}
|
|
30418
|
+
}
|
|
30419
|
+
parameters() {
|
|
30420
|
+
return this._def.args;
|
|
30421
|
+
}
|
|
30422
|
+
returnType() {
|
|
30423
|
+
return this._def.returns;
|
|
30424
|
+
}
|
|
30425
|
+
args(...items) {
|
|
30426
|
+
return new _ZodFunction({
|
|
30427
|
+
...this._def,
|
|
30428
|
+
args: ZodTuple.create(items).rest(ZodUnknown.create())
|
|
30429
|
+
});
|
|
30430
|
+
}
|
|
30431
|
+
returns(returnType) {
|
|
30432
|
+
return new _ZodFunction({
|
|
30433
|
+
...this._def,
|
|
30434
|
+
returns: returnType
|
|
30435
|
+
});
|
|
30436
|
+
}
|
|
30437
|
+
implement(func) {
|
|
30438
|
+
return this.parse(func);
|
|
30439
|
+
}
|
|
30440
|
+
strictImplement(func) {
|
|
30441
|
+
return this.parse(func);
|
|
30442
|
+
}
|
|
30443
|
+
static create(args, returns, params) {
|
|
30444
|
+
return new _ZodFunction({
|
|
30445
|
+
args: args || ZodTuple.create([]).rest(ZodUnknown.create()),
|
|
30446
|
+
returns: returns || ZodUnknown.create(),
|
|
30447
|
+
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
30448
|
+
...processCreateParams(params)
|
|
30449
|
+
});
|
|
30450
|
+
}
|
|
30451
|
+
}, ZodLazy = class extends ZodType {
|
|
30452
|
+
get schema() {
|
|
30453
|
+
return this._def.getter();
|
|
30454
|
+
}
|
|
30455
|
+
_parse(input) {
|
|
30456
|
+
let { ctx } = this._processInputParams(input);
|
|
30457
|
+
return this._def.getter()._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
30458
|
+
}
|
|
30459
|
+
};
|
|
30460
|
+
ZodLazy.create = (getter, params) => new ZodLazy({
|
|
30461
|
+
getter,
|
|
30462
|
+
typeName: ZodFirstPartyTypeKind.ZodLazy,
|
|
30463
|
+
...processCreateParams(params)
|
|
30464
|
+
});
|
|
30465
|
+
var ZodLiteral = class extends ZodType {
|
|
30466
|
+
_parse(input) {
|
|
30467
|
+
if (input.data !== this._def.value) {
|
|
30468
|
+
let ctx = this._getOrReturnCtx(input);
|
|
30469
|
+
return addIssueToContext(ctx, {
|
|
30470
|
+
received: ctx.data,
|
|
30471
|
+
code: ZodIssueCode.invalid_literal,
|
|
30472
|
+
expected: this._def.value
|
|
30473
|
+
}), INVALID;
|
|
30474
|
+
}
|
|
30475
|
+
return { status: "valid", value: input.data };
|
|
30476
|
+
}
|
|
30477
|
+
get value() {
|
|
30478
|
+
return this._def.value;
|
|
30479
|
+
}
|
|
30480
|
+
};
|
|
30481
|
+
ZodLiteral.create = (value, params) => new ZodLiteral({
|
|
30482
|
+
value,
|
|
30483
|
+
typeName: ZodFirstPartyTypeKind.ZodLiteral,
|
|
30484
|
+
...processCreateParams(params)
|
|
30485
|
+
});
|
|
30486
|
+
function createZodEnum(values, params) {
|
|
30487
|
+
return new ZodEnum({
|
|
30488
|
+
values,
|
|
30489
|
+
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
30490
|
+
...processCreateParams(params)
|
|
30491
|
+
});
|
|
30492
|
+
}
|
|
30493
|
+
var ZodEnum = class _ZodEnum extends ZodType {
|
|
30494
|
+
_parse(input) {
|
|
30495
|
+
if (typeof input.data != "string") {
|
|
30496
|
+
let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
|
|
30497
|
+
return addIssueToContext(ctx, {
|
|
30498
|
+
expected: util.joinValues(expectedValues),
|
|
30499
|
+
received: ctx.parsedType,
|
|
30500
|
+
code: ZodIssueCode.invalid_type
|
|
30501
|
+
}), INVALID;
|
|
30502
|
+
}
|
|
30503
|
+
if (this._def.values.indexOf(input.data) === -1) {
|
|
30504
|
+
let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
|
|
30505
|
+
return addIssueToContext(ctx, {
|
|
30506
|
+
received: ctx.data,
|
|
30507
|
+
code: ZodIssueCode.invalid_enum_value,
|
|
30508
|
+
options: expectedValues
|
|
30509
|
+
}), INVALID;
|
|
30510
|
+
}
|
|
30511
|
+
return OK(input.data);
|
|
30512
|
+
}
|
|
30513
|
+
get options() {
|
|
30514
|
+
return this._def.values;
|
|
30515
|
+
}
|
|
30516
|
+
get enum() {
|
|
30517
|
+
let enumValues = {};
|
|
30518
|
+
for (let val of this._def.values)
|
|
30519
|
+
enumValues[val] = val;
|
|
30520
|
+
return enumValues;
|
|
30521
|
+
}
|
|
30522
|
+
get Values() {
|
|
30523
|
+
let enumValues = {};
|
|
30524
|
+
for (let val of this._def.values)
|
|
30525
|
+
enumValues[val] = val;
|
|
30526
|
+
return enumValues;
|
|
30527
|
+
}
|
|
30528
|
+
get Enum() {
|
|
30529
|
+
let enumValues = {};
|
|
30530
|
+
for (let val of this._def.values)
|
|
30531
|
+
enumValues[val] = val;
|
|
30532
|
+
return enumValues;
|
|
30533
|
+
}
|
|
30534
|
+
extract(values) {
|
|
30535
|
+
return _ZodEnum.create(values);
|
|
30536
|
+
}
|
|
30537
|
+
exclude(values) {
|
|
30538
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
|
|
30539
|
+
}
|
|
30540
|
+
};
|
|
30541
|
+
ZodEnum.create = createZodEnum;
|
|
30542
|
+
var ZodNativeEnum = class extends ZodType {
|
|
30543
|
+
_parse(input) {
|
|
30544
|
+
let nativeEnumValues = util.getValidEnumValues(this._def.values), ctx = this._getOrReturnCtx(input);
|
|
30545
|
+
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
30546
|
+
let expectedValues = util.objectValues(nativeEnumValues);
|
|
30547
|
+
return addIssueToContext(ctx, {
|
|
30548
|
+
expected: util.joinValues(expectedValues),
|
|
30549
|
+
received: ctx.parsedType,
|
|
30550
|
+
code: ZodIssueCode.invalid_type
|
|
30551
|
+
}), INVALID;
|
|
30552
|
+
}
|
|
30553
|
+
if (nativeEnumValues.indexOf(input.data) === -1) {
|
|
30554
|
+
let expectedValues = util.objectValues(nativeEnumValues);
|
|
30555
|
+
return addIssueToContext(ctx, {
|
|
30556
|
+
received: ctx.data,
|
|
30557
|
+
code: ZodIssueCode.invalid_enum_value,
|
|
30558
|
+
options: expectedValues
|
|
30559
|
+
}), INVALID;
|
|
30560
|
+
}
|
|
30561
|
+
return OK(input.data);
|
|
30562
|
+
}
|
|
30563
|
+
get enum() {
|
|
30564
|
+
return this._def.values;
|
|
30565
|
+
}
|
|
30566
|
+
};
|
|
30567
|
+
ZodNativeEnum.create = (values, params) => new ZodNativeEnum({
|
|
30568
|
+
values,
|
|
30569
|
+
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
|
|
30570
|
+
...processCreateParams(params)
|
|
30571
|
+
});
|
|
30572
|
+
var ZodPromise = class extends ZodType {
|
|
30573
|
+
unwrap() {
|
|
30574
|
+
return this._def.type;
|
|
30575
|
+
}
|
|
30576
|
+
_parse(input) {
|
|
30577
|
+
let { ctx } = this._processInputParams(input);
|
|
30578
|
+
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === !1)
|
|
30579
|
+
return addIssueToContext(ctx, {
|
|
30580
|
+
code: ZodIssueCode.invalid_type,
|
|
30581
|
+
expected: ZodParsedType.promise,
|
|
30582
|
+
received: ctx.parsedType
|
|
30583
|
+
}), INVALID;
|
|
30584
|
+
let promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
30585
|
+
return OK(promisified.then((data) => this._def.type.parseAsync(data, {
|
|
30586
|
+
path: ctx.path,
|
|
30587
|
+
errorMap: ctx.common.contextualErrorMap
|
|
30588
|
+
})));
|
|
30589
|
+
}
|
|
30590
|
+
};
|
|
30591
|
+
ZodPromise.create = (schema, params) => new ZodPromise({
|
|
30592
|
+
type: schema,
|
|
30593
|
+
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
30594
|
+
...processCreateParams(params)
|
|
30595
|
+
});
|
|
30596
|
+
var ZodEffects = class extends ZodType {
|
|
30597
|
+
innerType() {
|
|
30598
|
+
return this._def.schema;
|
|
30599
|
+
}
|
|
30600
|
+
sourceType() {
|
|
30601
|
+
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
30602
|
+
}
|
|
30603
|
+
_parse(input) {
|
|
30604
|
+
let { status, ctx } = this._processInputParams(input), effect = this._def.effect || null, checkCtx = {
|
|
30605
|
+
addIssue: (arg) => {
|
|
30606
|
+
addIssueToContext(ctx, arg), arg.fatal ? status.abort() : status.dirty();
|
|
30607
|
+
},
|
|
30608
|
+
get path() {
|
|
30609
|
+
return ctx.path;
|
|
30610
|
+
}
|
|
30611
|
+
};
|
|
30612
|
+
if (checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx), effect.type === "preprocess") {
|
|
30613
|
+
let processed = effect.transform(ctx.data, checkCtx);
|
|
30614
|
+
return ctx.common.issues.length ? {
|
|
30615
|
+
status: "dirty",
|
|
30616
|
+
value: ctx.data
|
|
30617
|
+
} : ctx.common.async ? Promise.resolve(processed).then((processed2) => this._def.schema._parseAsync({
|
|
30618
|
+
data: processed2,
|
|
30619
|
+
path: ctx.path,
|
|
30620
|
+
parent: ctx
|
|
30621
|
+
})) : this._def.schema._parseSync({
|
|
30622
|
+
data: processed,
|
|
30623
|
+
path: ctx.path,
|
|
30624
|
+
parent: ctx
|
|
30625
|
+
});
|
|
30626
|
+
}
|
|
30627
|
+
if (effect.type === "refinement") {
|
|
30628
|
+
let executeRefinement = (acc) => {
|
|
30629
|
+
let result = effect.refinement(acc, checkCtx);
|
|
30630
|
+
if (ctx.common.async)
|
|
30631
|
+
return Promise.resolve(result);
|
|
30632
|
+
if (result instanceof Promise)
|
|
30633
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
30634
|
+
return acc;
|
|
30635
|
+
};
|
|
30636
|
+
if (ctx.common.async === !1) {
|
|
30637
|
+
let inner = this._def.schema._parseSync({
|
|
30638
|
+
data: ctx.data,
|
|
30639
|
+
path: ctx.path,
|
|
30640
|
+
parent: ctx
|
|
30641
|
+
});
|
|
30642
|
+
return inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value), { status: status.value, value: inner.value });
|
|
30643
|
+
} else
|
|
30644
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value).then(() => ({ status: status.value, value: inner.value }))));
|
|
30645
|
+
}
|
|
30646
|
+
if (effect.type === "transform")
|
|
30647
|
+
if (ctx.common.async === !1) {
|
|
30648
|
+
let base = this._def.schema._parseSync({
|
|
30649
|
+
data: ctx.data,
|
|
30650
|
+
path: ctx.path,
|
|
30651
|
+
parent: ctx
|
|
30652
|
+
});
|
|
30653
|
+
if (!isValid(base))
|
|
30654
|
+
return base;
|
|
30655
|
+
let result = effect.transform(base.value, checkCtx);
|
|
30656
|
+
if (result instanceof Promise)
|
|
30657
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
30658
|
+
return { status: status.value, value: result };
|
|
30659
|
+
} else
|
|
30660
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => isValid(base) ? Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result })) : base);
|
|
30661
|
+
util.assertNever(effect);
|
|
30662
|
+
}
|
|
30663
|
+
};
|
|
30664
|
+
ZodEffects.create = (schema, effect, params) => new ZodEffects({
|
|
30665
|
+
schema,
|
|
30666
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
30667
|
+
effect,
|
|
30668
|
+
...processCreateParams(params)
|
|
30669
|
+
});
|
|
30670
|
+
ZodEffects.createWithPreprocess = (preprocess, schema, params) => new ZodEffects({
|
|
30671
|
+
schema,
|
|
30672
|
+
effect: { type: "preprocess", transform: preprocess },
|
|
30673
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
30674
|
+
...processCreateParams(params)
|
|
30675
|
+
});
|
|
30676
|
+
var ZodOptional = class extends ZodType {
|
|
30677
|
+
_parse(input) {
|
|
30678
|
+
return this._getType(input) === ZodParsedType.undefined ? OK(void 0) : this._def.innerType._parse(input);
|
|
30679
|
+
}
|
|
30680
|
+
unwrap() {
|
|
30681
|
+
return this._def.innerType;
|
|
30682
|
+
}
|
|
30683
|
+
};
|
|
30684
|
+
ZodOptional.create = (type, params) => new ZodOptional({
|
|
30685
|
+
innerType: type,
|
|
30686
|
+
typeName: ZodFirstPartyTypeKind.ZodOptional,
|
|
30687
|
+
...processCreateParams(params)
|
|
30688
|
+
});
|
|
30689
|
+
var ZodNullable = class extends ZodType {
|
|
30690
|
+
_parse(input) {
|
|
30691
|
+
return this._getType(input) === ZodParsedType.null ? OK(null) : this._def.innerType._parse(input);
|
|
30692
|
+
}
|
|
30693
|
+
unwrap() {
|
|
30694
|
+
return this._def.innerType;
|
|
30695
|
+
}
|
|
30696
|
+
};
|
|
30697
|
+
ZodNullable.create = (type, params) => new ZodNullable({
|
|
30698
|
+
innerType: type,
|
|
30699
|
+
typeName: ZodFirstPartyTypeKind.ZodNullable,
|
|
30700
|
+
...processCreateParams(params)
|
|
30701
|
+
});
|
|
30702
|
+
var ZodDefault = class extends ZodType {
|
|
30703
|
+
_parse(input) {
|
|
30704
|
+
let { ctx } = this._processInputParams(input), data = ctx.data;
|
|
30705
|
+
return ctx.parsedType === ZodParsedType.undefined && (data = this._def.defaultValue()), this._def.innerType._parse({
|
|
30706
|
+
data,
|
|
30707
|
+
path: ctx.path,
|
|
30708
|
+
parent: ctx
|
|
30709
|
+
});
|
|
30710
|
+
}
|
|
30711
|
+
removeDefault() {
|
|
30712
|
+
return this._def.innerType;
|
|
30713
|
+
}
|
|
30714
|
+
};
|
|
30715
|
+
ZodDefault.create = (type, params) => new ZodDefault({
|
|
30716
|
+
innerType: type,
|
|
30717
|
+
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
30718
|
+
defaultValue: typeof params.default == "function" ? params.default : () => params.default,
|
|
30719
|
+
...processCreateParams(params)
|
|
30720
|
+
});
|
|
30721
|
+
var ZodCatch = class extends ZodType {
|
|
30722
|
+
_parse(input) {
|
|
30723
|
+
let { ctx } = this._processInputParams(input), newCtx = {
|
|
30724
|
+
...ctx,
|
|
30725
|
+
common: {
|
|
30726
|
+
...ctx.common,
|
|
30727
|
+
issues: []
|
|
30728
|
+
}
|
|
30729
|
+
}, result = this._def.innerType._parse({
|
|
30730
|
+
data: newCtx.data,
|
|
30731
|
+
path: newCtx.path,
|
|
30732
|
+
parent: {
|
|
30733
|
+
...newCtx
|
|
30734
|
+
}
|
|
30735
|
+
});
|
|
30736
|
+
return isAsync(result) ? result.then((result2) => ({
|
|
30737
|
+
status: "valid",
|
|
30738
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
30739
|
+
get error() {
|
|
30740
|
+
return new ZodError(newCtx.common.issues);
|
|
30741
|
+
},
|
|
30742
|
+
input: newCtx.data
|
|
30743
|
+
})
|
|
30744
|
+
})) : {
|
|
30745
|
+
status: "valid",
|
|
30746
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
30747
|
+
get error() {
|
|
30748
|
+
return new ZodError(newCtx.common.issues);
|
|
30749
|
+
},
|
|
30750
|
+
input: newCtx.data
|
|
30751
|
+
})
|
|
30752
|
+
};
|
|
30753
|
+
}
|
|
30754
|
+
removeCatch() {
|
|
30755
|
+
return this._def.innerType;
|
|
30756
|
+
}
|
|
30757
|
+
};
|
|
30758
|
+
ZodCatch.create = (type, params) => new ZodCatch({
|
|
30759
|
+
innerType: type,
|
|
30760
|
+
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
30761
|
+
catchValue: typeof params.catch == "function" ? params.catch : () => params.catch,
|
|
30762
|
+
...processCreateParams(params)
|
|
30763
|
+
});
|
|
30764
|
+
var ZodNaN = class extends ZodType {
|
|
30765
|
+
_parse(input) {
|
|
30766
|
+
if (this._getType(input) !== ZodParsedType.nan) {
|
|
30767
|
+
let ctx = this._getOrReturnCtx(input);
|
|
30768
|
+
return addIssueToContext(ctx, {
|
|
30769
|
+
code: ZodIssueCode.invalid_type,
|
|
30770
|
+
expected: ZodParsedType.nan,
|
|
30771
|
+
received: ctx.parsedType
|
|
30772
|
+
}), INVALID;
|
|
30773
|
+
}
|
|
30774
|
+
return { status: "valid", value: input.data };
|
|
30775
|
+
}
|
|
30776
|
+
};
|
|
30777
|
+
ZodNaN.create = (params) => new ZodNaN({
|
|
30778
|
+
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
30779
|
+
...processCreateParams(params)
|
|
30780
|
+
});
|
|
30781
|
+
var BRAND = Symbol("zod_brand"), ZodBranded = class extends ZodType {
|
|
30782
|
+
_parse(input) {
|
|
30783
|
+
let { ctx } = this._processInputParams(input), data = ctx.data;
|
|
30784
|
+
return this._def.type._parse({
|
|
30785
|
+
data,
|
|
30786
|
+
path: ctx.path,
|
|
30787
|
+
parent: ctx
|
|
30788
|
+
});
|
|
30789
|
+
}
|
|
30790
|
+
unwrap() {
|
|
30791
|
+
return this._def.type;
|
|
30792
|
+
}
|
|
30793
|
+
}, ZodPipeline = class _ZodPipeline extends ZodType {
|
|
30794
|
+
_parse(input) {
|
|
30795
|
+
let { status, ctx } = this._processInputParams(input);
|
|
30796
|
+
if (ctx.common.async)
|
|
30797
|
+
return (async () => {
|
|
30798
|
+
let inResult = await this._def.in._parseAsync({
|
|
30799
|
+
data: ctx.data,
|
|
30800
|
+
path: ctx.path,
|
|
30801
|
+
parent: ctx
|
|
30802
|
+
});
|
|
30803
|
+
return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), DIRTY(inResult.value)) : this._def.out._parseAsync({
|
|
30804
|
+
data: inResult.value,
|
|
30805
|
+
path: ctx.path,
|
|
30806
|
+
parent: ctx
|
|
30807
|
+
});
|
|
30808
|
+
})();
|
|
30809
|
+
{
|
|
30810
|
+
let inResult = this._def.in._parseSync({
|
|
30811
|
+
data: ctx.data,
|
|
30812
|
+
path: ctx.path,
|
|
30813
|
+
parent: ctx
|
|
30814
|
+
});
|
|
30815
|
+
return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), {
|
|
30816
|
+
status: "dirty",
|
|
30817
|
+
value: inResult.value
|
|
30818
|
+
}) : this._def.out._parseSync({
|
|
30819
|
+
data: inResult.value,
|
|
30820
|
+
path: ctx.path,
|
|
30821
|
+
parent: ctx
|
|
30822
|
+
});
|
|
30823
|
+
}
|
|
30824
|
+
}
|
|
30825
|
+
static create(a, b) {
|
|
30826
|
+
return new _ZodPipeline({
|
|
30827
|
+
in: a,
|
|
30828
|
+
out: b,
|
|
30829
|
+
typeName: ZodFirstPartyTypeKind.ZodPipeline
|
|
30830
|
+
});
|
|
30831
|
+
}
|
|
30832
|
+
}, ZodReadonly = class extends ZodType {
|
|
30833
|
+
_parse(input) {
|
|
30834
|
+
let result = this._def.innerType._parse(input);
|
|
30835
|
+
return isValid(result) && (result.value = Object.freeze(result.value)), result;
|
|
30836
|
+
}
|
|
30837
|
+
};
|
|
30838
|
+
ZodReadonly.create = (type, params) => new ZodReadonly({
|
|
30839
|
+
innerType: type,
|
|
30840
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
30841
|
+
...processCreateParams(params)
|
|
30842
|
+
});
|
|
30843
|
+
var custom = (check, params = {}, fatal) => check ? ZodAny.create().superRefine((data, ctx) => {
|
|
30844
|
+
var _a, _b;
|
|
30845
|
+
if (!check(data)) {
|
|
30846
|
+
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;
|
|
30847
|
+
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
|
|
30848
|
+
}
|
|
30849
|
+
}) : ZodAny.create(), late = {
|
|
30850
|
+
object: ZodObject.lazycreate
|
|
30851
|
+
}, ZodFirstPartyTypeKind;
|
|
30852
|
+
(function(ZodFirstPartyTypeKind2) {
|
|
30853
|
+
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";
|
|
30854
|
+
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
30855
|
+
var instanceOfType = (cls, params = {
|
|
30856
|
+
message: `Input not instance of ${cls.name}`
|
|
30857
|
+
}) => custom((data) => data instanceof cls, params), stringType = ZodString.create, numberType = ZodNumber.create, nanType = ZodNaN.create, bigIntType = ZodBigInt.create, booleanType = ZodBoolean.create, dateType = ZodDate.create, symbolType = ZodSymbol.create, undefinedType = ZodUndefined.create, nullType = ZodNull.create, anyType = ZodAny.create, unknownType = ZodUnknown.create, neverType = ZodNever.create, voidType = ZodVoid.create, arrayType = ZodArray.create, objectType = ZodObject.create, strictObjectType = ZodObject.strictCreate, unionType = ZodUnion.create, discriminatedUnionType = ZodDiscriminatedUnion.create, intersectionType = ZodIntersection.create, tupleType = ZodTuple.create, recordType = ZodRecord.create, mapType = ZodMap.create, setType = ZodSet.create, functionType = ZodFunction.create, lazyType = ZodLazy.create, literalType = ZodLiteral.create, enumType = ZodEnum.create, nativeEnumType = ZodNativeEnum.create, promiseType = ZodPromise.create, effectsType = ZodEffects.create, optionalType = ZodOptional.create, nullableType = ZodNullable.create, preprocessType = ZodEffects.createWithPreprocess, pipelineType = ZodPipeline.create, ostring = () => stringType().optional(), onumber = () => numberType().optional(), oboolean = () => booleanType().optional(), coerce = {
|
|
30858
|
+
string: (arg) => ZodString.create({ ...arg, coerce: !0 }),
|
|
30859
|
+
number: (arg) => ZodNumber.create({ ...arg, coerce: !0 }),
|
|
30860
|
+
boolean: (arg) => ZodBoolean.create({
|
|
30861
|
+
...arg,
|
|
30862
|
+
coerce: !0
|
|
30863
|
+
}),
|
|
30864
|
+
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: !0 }),
|
|
30865
|
+
date: (arg) => ZodDate.create({ ...arg, coerce: !0 })
|
|
30866
|
+
}, NEVER = INVALID, z = /* @__PURE__ */ Object.freeze({
|
|
30867
|
+
__proto__: null,
|
|
30868
|
+
defaultErrorMap: errorMap,
|
|
30869
|
+
setErrorMap,
|
|
30870
|
+
getErrorMap,
|
|
30871
|
+
makeIssue,
|
|
30872
|
+
EMPTY_PATH,
|
|
30873
|
+
addIssueToContext,
|
|
30874
|
+
ParseStatus,
|
|
30875
|
+
INVALID,
|
|
30876
|
+
DIRTY,
|
|
30877
|
+
OK,
|
|
30878
|
+
isAborted,
|
|
30879
|
+
isDirty,
|
|
30880
|
+
isValid,
|
|
30881
|
+
isAsync,
|
|
30882
|
+
get util() {
|
|
30883
|
+
return util;
|
|
30884
|
+
},
|
|
30885
|
+
get objectUtil() {
|
|
30886
|
+
return objectUtil;
|
|
30887
|
+
},
|
|
30888
|
+
ZodParsedType,
|
|
30889
|
+
getParsedType,
|
|
30890
|
+
ZodType,
|
|
30891
|
+
ZodString,
|
|
30892
|
+
ZodNumber,
|
|
30893
|
+
ZodBigInt,
|
|
30894
|
+
ZodBoolean,
|
|
30895
|
+
ZodDate,
|
|
30896
|
+
ZodSymbol,
|
|
30897
|
+
ZodUndefined,
|
|
30898
|
+
ZodNull,
|
|
30899
|
+
ZodAny,
|
|
30900
|
+
ZodUnknown,
|
|
30901
|
+
ZodNever,
|
|
30902
|
+
ZodVoid,
|
|
30903
|
+
ZodArray,
|
|
30904
|
+
ZodObject,
|
|
30905
|
+
ZodUnion,
|
|
30906
|
+
ZodDiscriminatedUnion,
|
|
30907
|
+
ZodIntersection,
|
|
30908
|
+
ZodTuple,
|
|
30909
|
+
ZodRecord,
|
|
30910
|
+
ZodMap,
|
|
30911
|
+
ZodSet,
|
|
30912
|
+
ZodFunction,
|
|
30913
|
+
ZodLazy,
|
|
30914
|
+
ZodLiteral,
|
|
30915
|
+
ZodEnum,
|
|
30916
|
+
ZodNativeEnum,
|
|
30917
|
+
ZodPromise,
|
|
30918
|
+
ZodEffects,
|
|
30919
|
+
ZodTransformer: ZodEffects,
|
|
30920
|
+
ZodOptional,
|
|
30921
|
+
ZodNullable,
|
|
30922
|
+
ZodDefault,
|
|
30923
|
+
ZodCatch,
|
|
30924
|
+
ZodNaN,
|
|
30925
|
+
BRAND,
|
|
30926
|
+
ZodBranded,
|
|
30927
|
+
ZodPipeline,
|
|
30928
|
+
ZodReadonly,
|
|
30929
|
+
custom,
|
|
30930
|
+
Schema: ZodType,
|
|
30931
|
+
ZodSchema: ZodType,
|
|
30932
|
+
late,
|
|
30933
|
+
get ZodFirstPartyTypeKind() {
|
|
30934
|
+
return ZodFirstPartyTypeKind;
|
|
30935
|
+
},
|
|
30936
|
+
coerce,
|
|
30937
|
+
any: anyType,
|
|
30938
|
+
array: arrayType,
|
|
30939
|
+
bigint: bigIntType,
|
|
30940
|
+
boolean: booleanType,
|
|
30941
|
+
date: dateType,
|
|
30942
|
+
discriminatedUnion: discriminatedUnionType,
|
|
30943
|
+
effect: effectsType,
|
|
30944
|
+
enum: enumType,
|
|
30945
|
+
function: functionType,
|
|
30946
|
+
instanceof: instanceOfType,
|
|
30947
|
+
intersection: intersectionType,
|
|
30948
|
+
lazy: lazyType,
|
|
30949
|
+
literal: literalType,
|
|
30950
|
+
map: mapType,
|
|
30951
|
+
nan: nanType,
|
|
30952
|
+
nativeEnum: nativeEnumType,
|
|
30953
|
+
never: neverType,
|
|
30954
|
+
null: nullType,
|
|
30955
|
+
nullable: nullableType,
|
|
30956
|
+
number: numberType,
|
|
30957
|
+
object: objectType,
|
|
30958
|
+
oboolean,
|
|
30959
|
+
onumber,
|
|
30960
|
+
optional: optionalType,
|
|
30961
|
+
ostring,
|
|
30962
|
+
pipeline: pipelineType,
|
|
30963
|
+
preprocess: preprocessType,
|
|
30964
|
+
promise: promiseType,
|
|
30965
|
+
record: recordType,
|
|
30966
|
+
set: setType,
|
|
30967
|
+
strictObject: strictObjectType,
|
|
30968
|
+
string: stringType,
|
|
30969
|
+
symbol: symbolType,
|
|
30970
|
+
transformer: effectsType,
|
|
30971
|
+
tuple: tupleType,
|
|
30972
|
+
undefined: undefinedType,
|
|
30973
|
+
union: unionType,
|
|
30974
|
+
unknown: unknownType,
|
|
30975
|
+
void: voidType,
|
|
30976
|
+
NEVER,
|
|
30977
|
+
ZodIssueCode,
|
|
30978
|
+
quotelessJson,
|
|
30979
|
+
ZodError
|
|
30980
|
+
});
|
|
30981
|
+
|
|
30982
|
+
// ../cli-kit/dist/public/node/schema.js
|
|
30983
|
+
init_cjs_shims();
|
|
30984
|
+
function deepStrict(schema) {
|
|
30985
|
+
if (schema instanceof ZodObject) {
|
|
30986
|
+
let shape = schema.shape, strictShape = Object.fromEntries(Object.entries(shape).map(([key, value]) => [key, deepStrict(value)]));
|
|
30987
|
+
return z.object(strictShape).strict();
|
|
30988
|
+
} else
|
|
30989
|
+
return schema instanceof ZodOptional ? deepStrict(schema._def.innerType).optional() : schema;
|
|
30990
|
+
}
|
|
30991
|
+
|
|
30992
|
+
// ../cli-kit/dist/public/node/environment.js
|
|
30993
|
+
init_cjs_shims();
|
|
30994
|
+
function getEnvironmentVariables() {
|
|
30995
|
+
return process.env;
|
|
30996
|
+
}
|
|
30997
|
+
function getPartnersToken() {
|
|
30998
|
+
return getEnvironmentVariables()[environmentVariables.partnersToken];
|
|
30999
|
+
}
|
|
31000
|
+
function getBackendPort() {
|
|
31001
|
+
let backendPort = getEnvironmentVariables()[systemEnvironmentVariables.backendPort];
|
|
31002
|
+
if (backendPort && !isNaN(Number(backendPort)))
|
|
31003
|
+
return Number(backendPort);
|
|
31004
|
+
}
|
|
31005
|
+
function getIdentityTokenInformation() {
|
|
31006
|
+
let identityToken = getEnvironmentVariables()[environmentVariables.identityToken], refreshToken = getEnvironmentVariables()[environmentVariables.refreshToken];
|
|
31007
|
+
if (!(!identityToken || !refreshToken))
|
|
31008
|
+
return {
|
|
31009
|
+
accessToken: identityToken,
|
|
31010
|
+
refreshToken,
|
|
31011
|
+
userId: nonRandomUUID(identityToken)
|
|
31012
|
+
};
|
|
31013
|
+
}
|
|
31014
|
+
function jsonOutputEnabled(environment = getEnvironmentVariables()) {
|
|
31015
|
+
return sniffForJson() || isTruthy(environment[environmentVariables.json]);
|
|
31016
|
+
}
|
|
31017
|
+
|
|
28253
31018
|
export {
|
|
28254
31019
|
RequestClientError,
|
|
28255
31020
|
GraphQLClientError,
|
|
@@ -28270,10 +31035,17 @@ export {
|
|
|
28270
31035
|
formData,
|
|
28271
31036
|
fetch2 as fetch,
|
|
28272
31037
|
shopifyFetch,
|
|
31038
|
+
z,
|
|
31039
|
+
deepStrict,
|
|
28273
31040
|
hashString,
|
|
28274
31041
|
fileHash,
|
|
28275
31042
|
randomUUID,
|
|
28276
|
-
nonRandomUUID
|
|
31043
|
+
nonRandomUUID,
|
|
31044
|
+
getEnvironmentVariables,
|
|
31045
|
+
getPartnersToken,
|
|
31046
|
+
getBackendPort,
|
|
31047
|
+
getIdentityTokenInformation,
|
|
31048
|
+
jsonOutputEnabled
|
|
28277
31049
|
};
|
|
28278
31050
|
/*! Bundled license information:
|
|
28279
31051
|
|
|
@@ -28293,4 +31065,4 @@ mime-types/index.js:
|
|
|
28293
31065
|
* MIT Licensed
|
|
28294
31066
|
*)
|
|
28295
31067
|
*/
|
|
28296
|
-
//# sourceMappingURL=chunk-
|
|
31068
|
+
//# sourceMappingURL=chunk-L5QY66M5.js.map
|