@rastrokit/sdk 0.15.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +4163 -44
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4166 -47
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +185 -50
- package/dist/index.d.ts +185 -50
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -3655,7 +3655,7 @@ var require_string_width = __commonJS({
|
|
|
3655
3655
|
"use strict";
|
|
3656
3656
|
var stripAnsi = require_strip_ansi();
|
|
3657
3657
|
var isFullwidthCodePoint = require_is_fullwidth_code_point();
|
|
3658
|
-
var
|
|
3658
|
+
var emojiRegex2 = require_emoji_regex();
|
|
3659
3659
|
var stringWidth = (string4) => {
|
|
3660
3660
|
if (typeof string4 !== "string" || string4.length === 0) {
|
|
3661
3661
|
return 0;
|
|
@@ -3664,7 +3664,7 @@ var require_string_width = __commonJS({
|
|
|
3664
3664
|
if (string4.length === 0) {
|
|
3665
3665
|
return 0;
|
|
3666
3666
|
}
|
|
3667
|
-
string4 = string4.replace(
|
|
3667
|
+
string4 = string4.replace(emojiRegex2(), " ");
|
|
3668
3668
|
let width = 0;
|
|
3669
3669
|
for (let i = 0; i < string4.length; i++) {
|
|
3670
3670
|
const code = string4.codePointAt(i);
|
|
@@ -11847,10 +11847,10 @@ var require_utf7 = __commonJS({
|
|
|
11847
11847
|
this.inBase64 = false;
|
|
11848
11848
|
this.base64Accum = "";
|
|
11849
11849
|
}
|
|
11850
|
-
var
|
|
11850
|
+
var base64Regex2 = /[A-Za-z0-9\/+]/;
|
|
11851
11851
|
var base64Chars = [];
|
|
11852
11852
|
for (i = 0; i < 256; i++) {
|
|
11853
|
-
base64Chars[i] =
|
|
11853
|
+
base64Chars[i] = base64Regex2.test(String.fromCharCode(i));
|
|
11854
11854
|
}
|
|
11855
11855
|
var i;
|
|
11856
11856
|
var plusChar = "+".charCodeAt(0);
|
|
@@ -15684,11 +15684,11 @@ var require_Observable = __commonJS({
|
|
|
15684
15684
|
var _a3;
|
|
15685
15685
|
return (_a3 = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config_1.config.Promise) !== null && _a3 !== void 0 ? _a3 : Promise;
|
|
15686
15686
|
}
|
|
15687
|
-
function
|
|
15687
|
+
function isObserver2(value) {
|
|
15688
15688
|
return value && isFunction_1.isFunction(value.next) && isFunction_1.isFunction(value.error) && isFunction_1.isFunction(value.complete);
|
|
15689
15689
|
}
|
|
15690
15690
|
function isSubscriber(value) {
|
|
15691
|
-
return value && value instanceof Subscriber_1.Subscriber ||
|
|
15691
|
+
return value && value instanceof Subscriber_1.Subscriber || isObserver2(value) && Subscription_1.isSubscription(value);
|
|
15692
15692
|
}
|
|
15693
15693
|
}
|
|
15694
15694
|
});
|
|
@@ -28389,14 +28389,14 @@ var esm_default2 = createPrompt((config2, done) => {
|
|
|
28389
28389
|
useKeypress(async (key) => {
|
|
28390
28390
|
if (isEnterKey(key)) {
|
|
28391
28391
|
const selection = items.filter(isChecked);
|
|
28392
|
-
const
|
|
28392
|
+
const isValid2 = await validate2([...selection]);
|
|
28393
28393
|
if (required2 && !items.some(isChecked)) {
|
|
28394
28394
|
setError("At least one choice must be selected");
|
|
28395
|
-
} else if (
|
|
28395
|
+
} else if (isValid2 === true) {
|
|
28396
28396
|
setStatus("done");
|
|
28397
28397
|
done(selection.map((choice) => choice.value));
|
|
28398
28398
|
} else {
|
|
28399
|
-
setError(
|
|
28399
|
+
setError(isValid2 || "You must select a valid value");
|
|
28400
28400
|
}
|
|
28401
28401
|
} else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
|
|
28402
28402
|
if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
|
|
@@ -28708,8 +28708,8 @@ var esm_default3 = createPrompt((config2, done) => {
|
|
|
28708
28708
|
} else {
|
|
28709
28709
|
setStatus("loading");
|
|
28710
28710
|
const finalAnswer = answer ?? "";
|
|
28711
|
-
const
|
|
28712
|
-
if (
|
|
28711
|
+
const isValid2 = await validate2(finalAnswer);
|
|
28712
|
+
if (isValid2 === true) {
|
|
28713
28713
|
setError(void 0);
|
|
28714
28714
|
setStatus("done");
|
|
28715
28715
|
done(finalAnswer);
|
|
@@ -28719,7 +28719,7 @@ var esm_default3 = createPrompt((config2, done) => {
|
|
|
28719
28719
|
} else {
|
|
28720
28720
|
setValue(finalAnswer);
|
|
28721
28721
|
}
|
|
28722
|
-
setError(
|
|
28722
|
+
setError(isValid2 || "You must provide a valid value");
|
|
28723
28723
|
setStatus("idle");
|
|
28724
28724
|
}
|
|
28725
28725
|
}
|
|
@@ -28835,8 +28835,8 @@ var esm_default5 = createPrompt((config2, done) => {
|
|
|
28835
28835
|
if (isEnterKey(key)) {
|
|
28836
28836
|
const answer = value || defaultValue;
|
|
28837
28837
|
setStatus("loading");
|
|
28838
|
-
const
|
|
28839
|
-
if (
|
|
28838
|
+
const isValid2 = await validate2(answer);
|
|
28839
|
+
if (isValid2 === true) {
|
|
28840
28840
|
setValue(answer);
|
|
28841
28841
|
setStatus("done");
|
|
28842
28842
|
done(answer);
|
|
@@ -28846,7 +28846,7 @@ var esm_default5 = createPrompt((config2, done) => {
|
|
|
28846
28846
|
} else {
|
|
28847
28847
|
rl.write(value);
|
|
28848
28848
|
}
|
|
28849
|
-
setError(
|
|
28849
|
+
setError(isValid2);
|
|
28850
28850
|
setStatus("idle");
|
|
28851
28851
|
}
|
|
28852
28852
|
} else if (isBackspaceKey(key) && !value) {
|
|
@@ -28922,20 +28922,20 @@ var esm_default6 = createPrompt((config2, done) => {
|
|
|
28922
28922
|
const input2 = value || defaultValue;
|
|
28923
28923
|
const answer = input2 === "" ? void 0 : Number(input2);
|
|
28924
28924
|
setStatus("loading");
|
|
28925
|
-
let
|
|
28925
|
+
let isValid2 = true;
|
|
28926
28926
|
if (required2 || answer != null) {
|
|
28927
|
-
|
|
28927
|
+
isValid2 = validateNumber(answer, { min, max, step });
|
|
28928
28928
|
}
|
|
28929
|
-
if (
|
|
28930
|
-
|
|
28929
|
+
if (isValid2 === true) {
|
|
28930
|
+
isValid2 = await validate2(answer);
|
|
28931
28931
|
}
|
|
28932
|
-
if (
|
|
28932
|
+
if (isValid2 === true) {
|
|
28933
28933
|
setValue(String(answer ?? ""));
|
|
28934
28934
|
setStatus("done");
|
|
28935
28935
|
done(answer);
|
|
28936
28936
|
} else {
|
|
28937
28937
|
rl.write(value);
|
|
28938
|
-
setError(
|
|
28938
|
+
setError(isValid2 || "You must provide a valid numeric value");
|
|
28939
28939
|
setStatus("idle");
|
|
28940
28940
|
}
|
|
28941
28941
|
} else if (isBackspaceKey(key) && !value) {
|
|
@@ -29190,14 +29190,14 @@ var esm_default9 = createPrompt((config2, done) => {
|
|
|
29190
29190
|
if (isEnterKey(key)) {
|
|
29191
29191
|
const answer = value;
|
|
29192
29192
|
setStatus("loading");
|
|
29193
|
-
const
|
|
29194
|
-
if (
|
|
29193
|
+
const isValid2 = await validate2(answer);
|
|
29194
|
+
if (isValid2 === true) {
|
|
29195
29195
|
setValue(answer);
|
|
29196
29196
|
setStatus("done");
|
|
29197
29197
|
done(answer);
|
|
29198
29198
|
} else {
|
|
29199
29199
|
rl.write(value);
|
|
29200
|
-
setError(
|
|
29200
|
+
setError(isValid2 || "You must provide a valid value");
|
|
29201
29201
|
setStatus("idle");
|
|
29202
29202
|
}
|
|
29203
29203
|
} else {
|
|
@@ -29309,13 +29309,13 @@ var esm_default10 = createPrompt((config2, done) => {
|
|
|
29309
29309
|
if (isEnterKey(key)) {
|
|
29310
29310
|
if (selectedChoice) {
|
|
29311
29311
|
setStatus("loading");
|
|
29312
|
-
const
|
|
29312
|
+
const isValid2 = await validate2(selectedChoice.value);
|
|
29313
29313
|
setStatus("idle");
|
|
29314
|
-
if (
|
|
29314
|
+
if (isValid2 === true) {
|
|
29315
29315
|
setStatus("done");
|
|
29316
29316
|
done(selectedChoice.value);
|
|
29317
29317
|
} else if (selectedChoice.name === searchTerm) {
|
|
29318
|
-
setSearchError(
|
|
29318
|
+
setSearchError(isValid2 || "You must provide a valid value");
|
|
29319
29319
|
} else {
|
|
29320
29320
|
rl.write(selectedChoice.name);
|
|
29321
29321
|
setSearchTerm(selectedChoice.name);
|
|
@@ -34954,8 +34954,8 @@ function datetime(args) {
|
|
|
34954
34954
|
if (args.offset)
|
|
34955
34955
|
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
34956
34956
|
const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
|
|
34957
|
-
const
|
|
34958
|
-
return new RegExp(`^${dateSource}T(?:${
|
|
34957
|
+
const timeRegex2 = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
34958
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
|
|
34959
34959
|
}
|
|
34960
34960
|
var anyString = /^[\s\S]{0,}$/;
|
|
34961
34961
|
var string = (params) => {
|
|
@@ -35540,7 +35540,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
35540
35540
|
const runChecks = (payload, checks2, ctx) => {
|
|
35541
35541
|
if (payload.memo)
|
|
35542
35542
|
return payload;
|
|
35543
|
-
let
|
|
35543
|
+
let isAborted2 = aborted(payload);
|
|
35544
35544
|
let asyncResult;
|
|
35545
35545
|
for (const ch of checks2) {
|
|
35546
35546
|
if (ch._zod.def.when) {
|
|
@@ -35549,7 +35549,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
35549
35549
|
const shouldRun = ch._zod.def.when(payload);
|
|
35550
35550
|
if (!shouldRun)
|
|
35551
35551
|
continue;
|
|
35552
|
-
} else if (
|
|
35552
|
+
} else if (isAborted2) {
|
|
35553
35553
|
continue;
|
|
35554
35554
|
}
|
|
35555
35555
|
const currLen = payload.issues.length;
|
|
@@ -35564,16 +35564,16 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
35564
35564
|
if (nextLen === currLen)
|
|
35565
35565
|
return;
|
|
35566
35566
|
attachSchema(payload.issues, currLen, inst);
|
|
35567
|
-
if (!
|
|
35568
|
-
|
|
35567
|
+
if (!isAborted2)
|
|
35568
|
+
isAborted2 = aborted(payload, currLen);
|
|
35569
35569
|
});
|
|
35570
35570
|
} else {
|
|
35571
35571
|
const nextLen = payload.issues.length;
|
|
35572
35572
|
if (nextLen === currLen)
|
|
35573
35573
|
continue;
|
|
35574
35574
|
attachSchema(payload.issues, currLen, inst);
|
|
35575
|
-
if (!
|
|
35576
|
-
|
|
35575
|
+
if (!isAborted2)
|
|
35576
|
+
isAborted2 = aborted(payload, currLen);
|
|
35577
35577
|
}
|
|
35578
35578
|
}
|
|
35579
35579
|
if (asyncResult) {
|
|
@@ -51645,7 +51645,7 @@ function getErrorMap() {
|
|
|
51645
51645
|
return config().customError;
|
|
51646
51646
|
}
|
|
51647
51647
|
var ZodFirstPartyTypeKind;
|
|
51648
|
-
/* @__PURE__ */ (function(
|
|
51648
|
+
/* @__PURE__ */ (function(ZodFirstPartyTypeKind3) {
|
|
51649
51649
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
51650
51650
|
|
|
51651
51651
|
// node_modules/zod/v4/classic/iso.js
|
|
@@ -52696,7 +52696,7 @@ var VALID_ADDON_CAPABILITIES = [
|
|
|
52696
52696
|
"auth",
|
|
52697
52697
|
"dataSource",
|
|
52698
52698
|
"analytics",
|
|
52699
|
-
"
|
|
52699
|
+
"observer",
|
|
52700
52700
|
"calendar",
|
|
52701
52701
|
"punch",
|
|
52702
52702
|
"theme"
|
|
@@ -52709,8 +52709,4127 @@ function isDataSource(capabilities) {
|
|
|
52709
52709
|
return hasCapability(capabilities, "dataSource");
|
|
52710
52710
|
}
|
|
52711
52711
|
|
|
52712
|
-
//
|
|
52712
|
+
// ../../packages/domain/node_modules/zod/v3/external.js
|
|
52713
|
+
var external_exports2 = {};
|
|
52714
|
+
__export(external_exports2, {
|
|
52715
|
+
BRAND: () => BRAND,
|
|
52716
|
+
DIRTY: () => DIRTY,
|
|
52717
|
+
EMPTY_PATH: () => EMPTY_PATH,
|
|
52718
|
+
INVALID: () => INVALID2,
|
|
52719
|
+
NEVER: () => NEVER2,
|
|
52720
|
+
OK: () => OK,
|
|
52721
|
+
ParseStatus: () => ParseStatus,
|
|
52722
|
+
Schema: () => ZodType2,
|
|
52723
|
+
ZodAny: () => ZodAny2,
|
|
52724
|
+
ZodArray: () => ZodArray2,
|
|
52725
|
+
ZodBigInt: () => ZodBigInt2,
|
|
52726
|
+
ZodBoolean: () => ZodBoolean2,
|
|
52727
|
+
ZodBranded: () => ZodBranded,
|
|
52728
|
+
ZodCatch: () => ZodCatch2,
|
|
52729
|
+
ZodDate: () => ZodDate2,
|
|
52730
|
+
ZodDefault: () => ZodDefault2,
|
|
52731
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion2,
|
|
52732
|
+
ZodEffects: () => ZodEffects,
|
|
52733
|
+
ZodEnum: () => ZodEnum2,
|
|
52734
|
+
ZodError: () => ZodError2,
|
|
52735
|
+
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind2,
|
|
52736
|
+
ZodFunction: () => ZodFunction2,
|
|
52737
|
+
ZodIntersection: () => ZodIntersection2,
|
|
52738
|
+
ZodIssueCode: () => ZodIssueCode2,
|
|
52739
|
+
ZodLazy: () => ZodLazy2,
|
|
52740
|
+
ZodLiteral: () => ZodLiteral2,
|
|
52741
|
+
ZodMap: () => ZodMap2,
|
|
52742
|
+
ZodNaN: () => ZodNaN2,
|
|
52743
|
+
ZodNativeEnum: () => ZodNativeEnum,
|
|
52744
|
+
ZodNever: () => ZodNever2,
|
|
52745
|
+
ZodNull: () => ZodNull2,
|
|
52746
|
+
ZodNullable: () => ZodNullable2,
|
|
52747
|
+
ZodNumber: () => ZodNumber2,
|
|
52748
|
+
ZodObject: () => ZodObject2,
|
|
52749
|
+
ZodOptional: () => ZodOptional2,
|
|
52750
|
+
ZodParsedType: () => ZodParsedType,
|
|
52751
|
+
ZodPipeline: () => ZodPipeline,
|
|
52752
|
+
ZodPromise: () => ZodPromise2,
|
|
52753
|
+
ZodReadonly: () => ZodReadonly2,
|
|
52754
|
+
ZodRecord: () => ZodRecord2,
|
|
52755
|
+
ZodSchema: () => ZodType2,
|
|
52756
|
+
ZodSet: () => ZodSet2,
|
|
52757
|
+
ZodString: () => ZodString2,
|
|
52758
|
+
ZodSymbol: () => ZodSymbol2,
|
|
52759
|
+
ZodTransformer: () => ZodEffects,
|
|
52760
|
+
ZodTuple: () => ZodTuple2,
|
|
52761
|
+
ZodType: () => ZodType2,
|
|
52762
|
+
ZodUndefined: () => ZodUndefined2,
|
|
52763
|
+
ZodUnion: () => ZodUnion2,
|
|
52764
|
+
ZodUnknown: () => ZodUnknown2,
|
|
52765
|
+
ZodVoid: () => ZodVoid2,
|
|
52766
|
+
addIssueToContext: () => addIssueToContext,
|
|
52767
|
+
any: () => anyType,
|
|
52768
|
+
array: () => arrayType,
|
|
52769
|
+
bigint: () => bigIntType,
|
|
52770
|
+
boolean: () => booleanType,
|
|
52771
|
+
coerce: () => coerce,
|
|
52772
|
+
custom: () => custom2,
|
|
52773
|
+
date: () => dateType,
|
|
52774
|
+
datetimeRegex: () => datetimeRegex,
|
|
52775
|
+
defaultErrorMap: () => en_default2,
|
|
52776
|
+
discriminatedUnion: () => discriminatedUnionType,
|
|
52777
|
+
effect: () => effectsType,
|
|
52778
|
+
enum: () => enumType,
|
|
52779
|
+
function: () => functionType,
|
|
52780
|
+
getErrorMap: () => getErrorMap2,
|
|
52781
|
+
getParsedType: () => getParsedType2,
|
|
52782
|
+
instanceof: () => instanceOfType,
|
|
52783
|
+
intersection: () => intersectionType,
|
|
52784
|
+
isAborted: () => isAborted,
|
|
52785
|
+
isAsync: () => isAsync,
|
|
52786
|
+
isDirty: () => isDirty,
|
|
52787
|
+
isValid: () => isValid,
|
|
52788
|
+
late: () => late,
|
|
52789
|
+
lazy: () => lazyType,
|
|
52790
|
+
literal: () => literalType,
|
|
52791
|
+
makeIssue: () => makeIssue,
|
|
52792
|
+
map: () => mapType,
|
|
52793
|
+
nan: () => nanType,
|
|
52794
|
+
nativeEnum: () => nativeEnumType,
|
|
52795
|
+
never: () => neverType,
|
|
52796
|
+
null: () => nullType,
|
|
52797
|
+
nullable: () => nullableType,
|
|
52798
|
+
number: () => numberType,
|
|
52799
|
+
object: () => objectType,
|
|
52800
|
+
objectUtil: () => objectUtil,
|
|
52801
|
+
oboolean: () => oboolean,
|
|
52802
|
+
onumber: () => onumber,
|
|
52803
|
+
optional: () => optionalType,
|
|
52804
|
+
ostring: () => ostring,
|
|
52805
|
+
pipeline: () => pipelineType,
|
|
52806
|
+
preprocess: () => preprocessType,
|
|
52807
|
+
promise: () => promiseType,
|
|
52808
|
+
quotelessJson: () => quotelessJson,
|
|
52809
|
+
record: () => recordType,
|
|
52810
|
+
set: () => setType,
|
|
52811
|
+
setErrorMap: () => setErrorMap2,
|
|
52812
|
+
strictObject: () => strictObjectType,
|
|
52813
|
+
string: () => stringType,
|
|
52814
|
+
symbol: () => symbolType,
|
|
52815
|
+
transformer: () => effectsType,
|
|
52816
|
+
tuple: () => tupleType,
|
|
52817
|
+
undefined: () => undefinedType,
|
|
52818
|
+
union: () => unionType,
|
|
52819
|
+
unknown: () => unknownType,
|
|
52820
|
+
util: () => util,
|
|
52821
|
+
void: () => voidType
|
|
52822
|
+
});
|
|
52823
|
+
|
|
52824
|
+
// ../../packages/domain/node_modules/zod/v3/helpers/util.js
|
|
52825
|
+
var util;
|
|
52826
|
+
(function(util2) {
|
|
52827
|
+
util2.assertEqual = (_2) => {
|
|
52828
|
+
};
|
|
52829
|
+
function assertIs2(_arg) {
|
|
52830
|
+
}
|
|
52831
|
+
util2.assertIs = assertIs2;
|
|
52832
|
+
function assertNever2(_x) {
|
|
52833
|
+
throw new Error();
|
|
52834
|
+
}
|
|
52835
|
+
util2.assertNever = assertNever2;
|
|
52836
|
+
util2.arrayToEnum = (items) => {
|
|
52837
|
+
const obj = {};
|
|
52838
|
+
for (const item of items) {
|
|
52839
|
+
obj[item] = item;
|
|
52840
|
+
}
|
|
52841
|
+
return obj;
|
|
52842
|
+
};
|
|
52843
|
+
util2.getValidEnumValues = (obj) => {
|
|
52844
|
+
const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
52845
|
+
const filtered = {};
|
|
52846
|
+
for (const k of validKeys) {
|
|
52847
|
+
filtered[k] = obj[k];
|
|
52848
|
+
}
|
|
52849
|
+
return util2.objectValues(filtered);
|
|
52850
|
+
};
|
|
52851
|
+
util2.objectValues = (obj) => {
|
|
52852
|
+
return util2.objectKeys(obj).map(function(e) {
|
|
52853
|
+
return obj[e];
|
|
52854
|
+
});
|
|
52855
|
+
};
|
|
52856
|
+
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
|
|
52857
|
+
const keys = [];
|
|
52858
|
+
for (const key in object2) {
|
|
52859
|
+
if (Object.prototype.hasOwnProperty.call(object2, key)) {
|
|
52860
|
+
keys.push(key);
|
|
52861
|
+
}
|
|
52862
|
+
}
|
|
52863
|
+
return keys;
|
|
52864
|
+
};
|
|
52865
|
+
util2.find = (arr, checker) => {
|
|
52866
|
+
for (const item of arr) {
|
|
52867
|
+
if (checker(item))
|
|
52868
|
+
return item;
|
|
52869
|
+
}
|
|
52870
|
+
return void 0;
|
|
52871
|
+
};
|
|
52872
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
52873
|
+
function joinValues2(array2, separator = " | ") {
|
|
52874
|
+
return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
52875
|
+
}
|
|
52876
|
+
util2.joinValues = joinValues2;
|
|
52877
|
+
util2.jsonStringifyReplacer = (_2, value) => {
|
|
52878
|
+
if (typeof value === "bigint") {
|
|
52879
|
+
return value.toString();
|
|
52880
|
+
}
|
|
52881
|
+
return value;
|
|
52882
|
+
};
|
|
52883
|
+
})(util || (util = {}));
|
|
52884
|
+
var objectUtil;
|
|
52885
|
+
(function(objectUtil2) {
|
|
52886
|
+
objectUtil2.mergeShapes = (first, second) => {
|
|
52887
|
+
return {
|
|
52888
|
+
...first,
|
|
52889
|
+
...second
|
|
52890
|
+
// second overwrites first
|
|
52891
|
+
};
|
|
52892
|
+
};
|
|
52893
|
+
})(objectUtil || (objectUtil = {}));
|
|
52894
|
+
var ZodParsedType = util.arrayToEnum([
|
|
52895
|
+
"string",
|
|
52896
|
+
"nan",
|
|
52897
|
+
"number",
|
|
52898
|
+
"integer",
|
|
52899
|
+
"float",
|
|
52900
|
+
"boolean",
|
|
52901
|
+
"date",
|
|
52902
|
+
"bigint",
|
|
52903
|
+
"symbol",
|
|
52904
|
+
"function",
|
|
52905
|
+
"undefined",
|
|
52906
|
+
"null",
|
|
52907
|
+
"array",
|
|
52908
|
+
"object",
|
|
52909
|
+
"unknown",
|
|
52910
|
+
"promise",
|
|
52911
|
+
"void",
|
|
52912
|
+
"never",
|
|
52913
|
+
"map",
|
|
52914
|
+
"set"
|
|
52915
|
+
]);
|
|
52916
|
+
var getParsedType2 = (data) => {
|
|
52917
|
+
const t = typeof data;
|
|
52918
|
+
switch (t) {
|
|
52919
|
+
case "undefined":
|
|
52920
|
+
return ZodParsedType.undefined;
|
|
52921
|
+
case "string":
|
|
52922
|
+
return ZodParsedType.string;
|
|
52923
|
+
case "number":
|
|
52924
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
52925
|
+
case "boolean":
|
|
52926
|
+
return ZodParsedType.boolean;
|
|
52927
|
+
case "function":
|
|
52928
|
+
return ZodParsedType.function;
|
|
52929
|
+
case "bigint":
|
|
52930
|
+
return ZodParsedType.bigint;
|
|
52931
|
+
case "symbol":
|
|
52932
|
+
return ZodParsedType.symbol;
|
|
52933
|
+
case "object":
|
|
52934
|
+
if (Array.isArray(data)) {
|
|
52935
|
+
return ZodParsedType.array;
|
|
52936
|
+
}
|
|
52937
|
+
if (data === null) {
|
|
52938
|
+
return ZodParsedType.null;
|
|
52939
|
+
}
|
|
52940
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
52941
|
+
return ZodParsedType.promise;
|
|
52942
|
+
}
|
|
52943
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
52944
|
+
return ZodParsedType.map;
|
|
52945
|
+
}
|
|
52946
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
52947
|
+
return ZodParsedType.set;
|
|
52948
|
+
}
|
|
52949
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
52950
|
+
return ZodParsedType.date;
|
|
52951
|
+
}
|
|
52952
|
+
return ZodParsedType.object;
|
|
52953
|
+
default:
|
|
52954
|
+
return ZodParsedType.unknown;
|
|
52955
|
+
}
|
|
52956
|
+
};
|
|
52957
|
+
|
|
52958
|
+
// ../../packages/domain/node_modules/zod/v3/ZodError.js
|
|
52959
|
+
var ZodIssueCode2 = util.arrayToEnum([
|
|
52960
|
+
"invalid_type",
|
|
52961
|
+
"invalid_literal",
|
|
52962
|
+
"custom",
|
|
52963
|
+
"invalid_union",
|
|
52964
|
+
"invalid_union_discriminator",
|
|
52965
|
+
"invalid_enum_value",
|
|
52966
|
+
"unrecognized_keys",
|
|
52967
|
+
"invalid_arguments",
|
|
52968
|
+
"invalid_return_type",
|
|
52969
|
+
"invalid_date",
|
|
52970
|
+
"invalid_string",
|
|
52971
|
+
"too_small",
|
|
52972
|
+
"too_big",
|
|
52973
|
+
"invalid_intersection_types",
|
|
52974
|
+
"not_multiple_of",
|
|
52975
|
+
"not_finite"
|
|
52976
|
+
]);
|
|
52977
|
+
var quotelessJson = (obj) => {
|
|
52978
|
+
const json3 = JSON.stringify(obj, null, 2);
|
|
52979
|
+
return json3.replace(/"([^"]+)":/g, "$1:");
|
|
52980
|
+
};
|
|
52981
|
+
var ZodError2 = class _ZodError extends Error {
|
|
52982
|
+
get errors() {
|
|
52983
|
+
return this.issues;
|
|
52984
|
+
}
|
|
52985
|
+
constructor(issues) {
|
|
52986
|
+
super();
|
|
52987
|
+
this.issues = [];
|
|
52988
|
+
this.addIssue = (sub) => {
|
|
52989
|
+
this.issues = [...this.issues, sub];
|
|
52990
|
+
};
|
|
52991
|
+
this.addIssues = (subs = []) => {
|
|
52992
|
+
this.issues = [...this.issues, ...subs];
|
|
52993
|
+
};
|
|
52994
|
+
const actualProto = new.target.prototype;
|
|
52995
|
+
if (Object.setPrototypeOf) {
|
|
52996
|
+
Object.setPrototypeOf(this, actualProto);
|
|
52997
|
+
} else {
|
|
52998
|
+
this.__proto__ = actualProto;
|
|
52999
|
+
}
|
|
53000
|
+
this.name = "ZodError";
|
|
53001
|
+
this.issues = issues;
|
|
53002
|
+
}
|
|
53003
|
+
format(_mapper) {
|
|
53004
|
+
const mapper = _mapper || function(issue2) {
|
|
53005
|
+
return issue2.message;
|
|
53006
|
+
};
|
|
53007
|
+
const fieldErrors = { _errors: [] };
|
|
53008
|
+
const processError = (error62) => {
|
|
53009
|
+
for (const issue2 of error62.issues) {
|
|
53010
|
+
if (issue2.code === "invalid_union") {
|
|
53011
|
+
issue2.unionErrors.map(processError);
|
|
53012
|
+
} else if (issue2.code === "invalid_return_type") {
|
|
53013
|
+
processError(issue2.returnTypeError);
|
|
53014
|
+
} else if (issue2.code === "invalid_arguments") {
|
|
53015
|
+
processError(issue2.argumentsError);
|
|
53016
|
+
} else if (issue2.path.length === 0) {
|
|
53017
|
+
fieldErrors._errors.push(mapper(issue2));
|
|
53018
|
+
} else {
|
|
53019
|
+
let curr = fieldErrors;
|
|
53020
|
+
let i = 0;
|
|
53021
|
+
while (i < issue2.path.length) {
|
|
53022
|
+
const el = issue2.path[i];
|
|
53023
|
+
const terminal = i === issue2.path.length - 1;
|
|
53024
|
+
if (!terminal) {
|
|
53025
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
53026
|
+
} else {
|
|
53027
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
53028
|
+
curr[el]._errors.push(mapper(issue2));
|
|
53029
|
+
}
|
|
53030
|
+
curr = curr[el];
|
|
53031
|
+
i++;
|
|
53032
|
+
}
|
|
53033
|
+
}
|
|
53034
|
+
}
|
|
53035
|
+
};
|
|
53036
|
+
processError(this);
|
|
53037
|
+
return fieldErrors;
|
|
53038
|
+
}
|
|
53039
|
+
static assert(value) {
|
|
53040
|
+
if (!(value instanceof _ZodError)) {
|
|
53041
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
53042
|
+
}
|
|
53043
|
+
}
|
|
53044
|
+
toString() {
|
|
53045
|
+
return this.message;
|
|
53046
|
+
}
|
|
53047
|
+
get message() {
|
|
53048
|
+
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
53049
|
+
}
|
|
53050
|
+
get isEmpty() {
|
|
53051
|
+
return this.issues.length === 0;
|
|
53052
|
+
}
|
|
53053
|
+
flatten(mapper = (issue2) => issue2.message) {
|
|
53054
|
+
const fieldErrors = {};
|
|
53055
|
+
const formErrors = [];
|
|
53056
|
+
for (const sub of this.issues) {
|
|
53057
|
+
if (sub.path.length > 0) {
|
|
53058
|
+
const firstEl = sub.path[0];
|
|
53059
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
53060
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
53061
|
+
} else {
|
|
53062
|
+
formErrors.push(mapper(sub));
|
|
53063
|
+
}
|
|
53064
|
+
}
|
|
53065
|
+
return { formErrors, fieldErrors };
|
|
53066
|
+
}
|
|
53067
|
+
get formErrors() {
|
|
53068
|
+
return this.flatten();
|
|
53069
|
+
}
|
|
53070
|
+
};
|
|
53071
|
+
ZodError2.create = (issues) => {
|
|
53072
|
+
const error62 = new ZodError2(issues);
|
|
53073
|
+
return error62;
|
|
53074
|
+
};
|
|
53075
|
+
|
|
53076
|
+
// ../../packages/domain/node_modules/zod/v3/locales/en.js
|
|
53077
|
+
var errorMap = (issue2, _ctx) => {
|
|
53078
|
+
let message;
|
|
53079
|
+
switch (issue2.code) {
|
|
53080
|
+
case ZodIssueCode2.invalid_type:
|
|
53081
|
+
if (issue2.received === ZodParsedType.undefined) {
|
|
53082
|
+
message = "Required";
|
|
53083
|
+
} else {
|
|
53084
|
+
message = `Expected ${issue2.expected}, received ${issue2.received}`;
|
|
53085
|
+
}
|
|
53086
|
+
break;
|
|
53087
|
+
case ZodIssueCode2.invalid_literal:
|
|
53088
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue2.expected, util.jsonStringifyReplacer)}`;
|
|
53089
|
+
break;
|
|
53090
|
+
case ZodIssueCode2.unrecognized_keys:
|
|
53091
|
+
message = `Unrecognized key(s) in object: ${util.joinValues(issue2.keys, ", ")}`;
|
|
53092
|
+
break;
|
|
53093
|
+
case ZodIssueCode2.invalid_union:
|
|
53094
|
+
message = `Invalid input`;
|
|
53095
|
+
break;
|
|
53096
|
+
case ZodIssueCode2.invalid_union_discriminator:
|
|
53097
|
+
message = `Invalid discriminator value. Expected ${util.joinValues(issue2.options)}`;
|
|
53098
|
+
break;
|
|
53099
|
+
case ZodIssueCode2.invalid_enum_value:
|
|
53100
|
+
message = `Invalid enum value. Expected ${util.joinValues(issue2.options)}, received '${issue2.received}'`;
|
|
53101
|
+
break;
|
|
53102
|
+
case ZodIssueCode2.invalid_arguments:
|
|
53103
|
+
message = `Invalid function arguments`;
|
|
53104
|
+
break;
|
|
53105
|
+
case ZodIssueCode2.invalid_return_type:
|
|
53106
|
+
message = `Invalid function return type`;
|
|
53107
|
+
break;
|
|
53108
|
+
case ZodIssueCode2.invalid_date:
|
|
53109
|
+
message = `Invalid date`;
|
|
53110
|
+
break;
|
|
53111
|
+
case ZodIssueCode2.invalid_string:
|
|
53112
|
+
if (typeof issue2.validation === "object") {
|
|
53113
|
+
if ("includes" in issue2.validation) {
|
|
53114
|
+
message = `Invalid input: must include "${issue2.validation.includes}"`;
|
|
53115
|
+
if (typeof issue2.validation.position === "number") {
|
|
53116
|
+
message = `${message} at one or more positions greater than or equal to ${issue2.validation.position}`;
|
|
53117
|
+
}
|
|
53118
|
+
} else if ("startsWith" in issue2.validation) {
|
|
53119
|
+
message = `Invalid input: must start with "${issue2.validation.startsWith}"`;
|
|
53120
|
+
} else if ("endsWith" in issue2.validation) {
|
|
53121
|
+
message = `Invalid input: must end with "${issue2.validation.endsWith}"`;
|
|
53122
|
+
} else {
|
|
53123
|
+
util.assertNever(issue2.validation);
|
|
53124
|
+
}
|
|
53125
|
+
} else if (issue2.validation !== "regex") {
|
|
53126
|
+
message = `Invalid ${issue2.validation}`;
|
|
53127
|
+
} else {
|
|
53128
|
+
message = "Invalid";
|
|
53129
|
+
}
|
|
53130
|
+
break;
|
|
53131
|
+
case ZodIssueCode2.too_small:
|
|
53132
|
+
if (issue2.type === "array")
|
|
53133
|
+
message = `Array must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `more than`} ${issue2.minimum} element(s)`;
|
|
53134
|
+
else if (issue2.type === "string")
|
|
53135
|
+
message = `String must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `over`} ${issue2.minimum} character(s)`;
|
|
53136
|
+
else if (issue2.type === "number")
|
|
53137
|
+
message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
|
|
53138
|
+
else if (issue2.type === "bigint")
|
|
53139
|
+
message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
|
|
53140
|
+
else if (issue2.type === "date")
|
|
53141
|
+
message = `Date must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue2.minimum))}`;
|
|
53142
|
+
else
|
|
53143
|
+
message = "Invalid input";
|
|
53144
|
+
break;
|
|
53145
|
+
case ZodIssueCode2.too_big:
|
|
53146
|
+
if (issue2.type === "array")
|
|
53147
|
+
message = `Array must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `less than`} ${issue2.maximum} element(s)`;
|
|
53148
|
+
else if (issue2.type === "string")
|
|
53149
|
+
message = `String must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `under`} ${issue2.maximum} character(s)`;
|
|
53150
|
+
else if (issue2.type === "number")
|
|
53151
|
+
message = `Number must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
|
|
53152
|
+
else if (issue2.type === "bigint")
|
|
53153
|
+
message = `BigInt must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
|
|
53154
|
+
else if (issue2.type === "date")
|
|
53155
|
+
message = `Date must be ${issue2.exact ? `exactly` : issue2.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue2.maximum))}`;
|
|
53156
|
+
else
|
|
53157
|
+
message = "Invalid input";
|
|
53158
|
+
break;
|
|
53159
|
+
case ZodIssueCode2.custom:
|
|
53160
|
+
message = `Invalid input`;
|
|
53161
|
+
break;
|
|
53162
|
+
case ZodIssueCode2.invalid_intersection_types:
|
|
53163
|
+
message = `Intersection results could not be merged`;
|
|
53164
|
+
break;
|
|
53165
|
+
case ZodIssueCode2.not_multiple_of:
|
|
53166
|
+
message = `Number must be a multiple of ${issue2.multipleOf}`;
|
|
53167
|
+
break;
|
|
53168
|
+
case ZodIssueCode2.not_finite:
|
|
53169
|
+
message = "Number must be finite";
|
|
53170
|
+
break;
|
|
53171
|
+
default:
|
|
53172
|
+
message = _ctx.defaultError;
|
|
53173
|
+
util.assertNever(issue2);
|
|
53174
|
+
}
|
|
53175
|
+
return { message };
|
|
53176
|
+
};
|
|
53177
|
+
var en_default2 = errorMap;
|
|
53178
|
+
|
|
53179
|
+
// ../../packages/domain/node_modules/zod/v3/errors.js
|
|
53180
|
+
var overrideErrorMap = en_default2;
|
|
53181
|
+
function setErrorMap2(map3) {
|
|
53182
|
+
overrideErrorMap = map3;
|
|
53183
|
+
}
|
|
53184
|
+
function getErrorMap2() {
|
|
53185
|
+
return overrideErrorMap;
|
|
53186
|
+
}
|
|
53187
|
+
|
|
53188
|
+
// ../../packages/domain/node_modules/zod/v3/helpers/parseUtil.js
|
|
53189
|
+
var makeIssue = (params) => {
|
|
53190
|
+
const { data, path: path11, errorMaps, issueData } = params;
|
|
53191
|
+
const fullPath = [...path11, ...issueData.path || []];
|
|
53192
|
+
const fullIssue = {
|
|
53193
|
+
...issueData,
|
|
53194
|
+
path: fullPath
|
|
53195
|
+
};
|
|
53196
|
+
if (issueData.message !== void 0) {
|
|
53197
|
+
return {
|
|
53198
|
+
...issueData,
|
|
53199
|
+
path: fullPath,
|
|
53200
|
+
message: issueData.message
|
|
53201
|
+
};
|
|
53202
|
+
}
|
|
53203
|
+
let errorMessage = "";
|
|
53204
|
+
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
53205
|
+
for (const map3 of maps) {
|
|
53206
|
+
errorMessage = map3(fullIssue, { data, defaultError: errorMessage }).message;
|
|
53207
|
+
}
|
|
53208
|
+
return {
|
|
53209
|
+
...issueData,
|
|
53210
|
+
path: fullPath,
|
|
53211
|
+
message: errorMessage
|
|
53212
|
+
};
|
|
53213
|
+
};
|
|
53214
|
+
var EMPTY_PATH = [];
|
|
53215
|
+
function addIssueToContext(ctx, issueData) {
|
|
53216
|
+
const overrideMap = getErrorMap2();
|
|
53217
|
+
const issue2 = makeIssue({
|
|
53218
|
+
issueData,
|
|
53219
|
+
data: ctx.data,
|
|
53220
|
+
path: ctx.path,
|
|
53221
|
+
errorMaps: [
|
|
53222
|
+
ctx.common.contextualErrorMap,
|
|
53223
|
+
// contextual error map is first priority
|
|
53224
|
+
ctx.schemaErrorMap,
|
|
53225
|
+
// then schema-bound map if available
|
|
53226
|
+
overrideMap,
|
|
53227
|
+
// then global override map
|
|
53228
|
+
overrideMap === en_default2 ? void 0 : en_default2
|
|
53229
|
+
// then global default map
|
|
53230
|
+
].filter((x) => !!x)
|
|
53231
|
+
});
|
|
53232
|
+
ctx.common.issues.push(issue2);
|
|
53233
|
+
}
|
|
53234
|
+
var ParseStatus = class _ParseStatus {
|
|
53235
|
+
constructor() {
|
|
53236
|
+
this.value = "valid";
|
|
53237
|
+
}
|
|
53238
|
+
dirty() {
|
|
53239
|
+
if (this.value === "valid")
|
|
53240
|
+
this.value = "dirty";
|
|
53241
|
+
}
|
|
53242
|
+
abort() {
|
|
53243
|
+
if (this.value !== "aborted")
|
|
53244
|
+
this.value = "aborted";
|
|
53245
|
+
}
|
|
53246
|
+
static mergeArray(status, results) {
|
|
53247
|
+
const arrayValue = [];
|
|
53248
|
+
for (const s of results) {
|
|
53249
|
+
if (s.status === "aborted")
|
|
53250
|
+
return INVALID2;
|
|
53251
|
+
if (s.status === "dirty")
|
|
53252
|
+
status.dirty();
|
|
53253
|
+
arrayValue.push(s.value);
|
|
53254
|
+
}
|
|
53255
|
+
return { status: status.value, value: arrayValue };
|
|
53256
|
+
}
|
|
53257
|
+
static async mergeObjectAsync(status, pairs2) {
|
|
53258
|
+
const syncPairs = [];
|
|
53259
|
+
for (const pair of pairs2) {
|
|
53260
|
+
const key = await pair.key;
|
|
53261
|
+
const value = await pair.value;
|
|
53262
|
+
syncPairs.push({
|
|
53263
|
+
key,
|
|
53264
|
+
value
|
|
53265
|
+
});
|
|
53266
|
+
}
|
|
53267
|
+
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
53268
|
+
}
|
|
53269
|
+
static mergeObjectSync(status, pairs2) {
|
|
53270
|
+
const finalObject = {};
|
|
53271
|
+
for (const pair of pairs2) {
|
|
53272
|
+
const { key, value } = pair;
|
|
53273
|
+
if (key.status === "aborted")
|
|
53274
|
+
return INVALID2;
|
|
53275
|
+
if (value.status === "aborted")
|
|
53276
|
+
return INVALID2;
|
|
53277
|
+
if (key.status === "dirty")
|
|
53278
|
+
status.dirty();
|
|
53279
|
+
if (value.status === "dirty")
|
|
53280
|
+
status.dirty();
|
|
53281
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
53282
|
+
finalObject[key.value] = value.value;
|
|
53283
|
+
}
|
|
53284
|
+
}
|
|
53285
|
+
return { status: status.value, value: finalObject };
|
|
53286
|
+
}
|
|
53287
|
+
};
|
|
53288
|
+
var INVALID2 = Object.freeze({
|
|
53289
|
+
status: "aborted"
|
|
53290
|
+
});
|
|
53291
|
+
var DIRTY = (value) => ({ status: "dirty", value });
|
|
53292
|
+
var OK = (value) => ({ status: "valid", value });
|
|
53293
|
+
var isAborted = (x) => x.status === "aborted";
|
|
53294
|
+
var isDirty = (x) => x.status === "dirty";
|
|
53295
|
+
var isValid = (x) => x.status === "valid";
|
|
53296
|
+
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
53297
|
+
|
|
53298
|
+
// ../../packages/domain/node_modules/zod/v3/helpers/errorUtil.js
|
|
53299
|
+
var errorUtil;
|
|
53300
|
+
(function(errorUtil2) {
|
|
53301
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
53302
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
53303
|
+
})(errorUtil || (errorUtil = {}));
|
|
53304
|
+
|
|
53305
|
+
// ../../packages/domain/node_modules/zod/v3/types.js
|
|
53306
|
+
var ParseInputLazyPath = class {
|
|
53307
|
+
constructor(parent, value, path11, key) {
|
|
53308
|
+
this._cachedPath = [];
|
|
53309
|
+
this.parent = parent;
|
|
53310
|
+
this.data = value;
|
|
53311
|
+
this._path = path11;
|
|
53312
|
+
this._key = key;
|
|
53313
|
+
}
|
|
53314
|
+
get path() {
|
|
53315
|
+
if (!this._cachedPath.length) {
|
|
53316
|
+
if (Array.isArray(this._key)) {
|
|
53317
|
+
this._cachedPath.push(...this._path, ...this._key);
|
|
53318
|
+
} else {
|
|
53319
|
+
this._cachedPath.push(...this._path, this._key);
|
|
53320
|
+
}
|
|
53321
|
+
}
|
|
53322
|
+
return this._cachedPath;
|
|
53323
|
+
}
|
|
53324
|
+
};
|
|
53325
|
+
var handleResult = (ctx, result) => {
|
|
53326
|
+
if (isValid(result)) {
|
|
53327
|
+
return { success: true, data: result.value };
|
|
53328
|
+
} else {
|
|
53329
|
+
if (!ctx.common.issues.length) {
|
|
53330
|
+
throw new Error("Validation failed but no issues detected.");
|
|
53331
|
+
}
|
|
53332
|
+
return {
|
|
53333
|
+
success: false,
|
|
53334
|
+
get error() {
|
|
53335
|
+
if (this._error)
|
|
53336
|
+
return this._error;
|
|
53337
|
+
const error62 = new ZodError2(ctx.common.issues);
|
|
53338
|
+
this._error = error62;
|
|
53339
|
+
return this._error;
|
|
53340
|
+
}
|
|
53341
|
+
};
|
|
53342
|
+
}
|
|
53343
|
+
};
|
|
53344
|
+
function processCreateParams(params) {
|
|
53345
|
+
if (!params)
|
|
53346
|
+
return {};
|
|
53347
|
+
const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
|
|
53348
|
+
if (errorMap2 && (invalid_type_error || required_error)) {
|
|
53349
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
53350
|
+
}
|
|
53351
|
+
if (errorMap2)
|
|
53352
|
+
return { errorMap: errorMap2, description };
|
|
53353
|
+
const customMap = (iss, ctx) => {
|
|
53354
|
+
const { message } = params;
|
|
53355
|
+
if (iss.code === "invalid_enum_value") {
|
|
53356
|
+
return { message: message ?? ctx.defaultError };
|
|
53357
|
+
}
|
|
53358
|
+
if (typeof ctx.data === "undefined") {
|
|
53359
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
53360
|
+
}
|
|
53361
|
+
if (iss.code !== "invalid_type")
|
|
53362
|
+
return { message: ctx.defaultError };
|
|
53363
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
53364
|
+
};
|
|
53365
|
+
return { errorMap: customMap, description };
|
|
53366
|
+
}
|
|
53367
|
+
var ZodType2 = class {
|
|
53368
|
+
get description() {
|
|
53369
|
+
return this._def.description;
|
|
53370
|
+
}
|
|
53371
|
+
_getType(input2) {
|
|
53372
|
+
return getParsedType2(input2.data);
|
|
53373
|
+
}
|
|
53374
|
+
_getOrReturnCtx(input2, ctx) {
|
|
53375
|
+
return ctx || {
|
|
53376
|
+
common: input2.parent.common,
|
|
53377
|
+
data: input2.data,
|
|
53378
|
+
parsedType: getParsedType2(input2.data),
|
|
53379
|
+
schemaErrorMap: this._def.errorMap,
|
|
53380
|
+
path: input2.path,
|
|
53381
|
+
parent: input2.parent
|
|
53382
|
+
};
|
|
53383
|
+
}
|
|
53384
|
+
_processInputParams(input2) {
|
|
53385
|
+
return {
|
|
53386
|
+
status: new ParseStatus(),
|
|
53387
|
+
ctx: {
|
|
53388
|
+
common: input2.parent.common,
|
|
53389
|
+
data: input2.data,
|
|
53390
|
+
parsedType: getParsedType2(input2.data),
|
|
53391
|
+
schemaErrorMap: this._def.errorMap,
|
|
53392
|
+
path: input2.path,
|
|
53393
|
+
parent: input2.parent
|
|
53394
|
+
}
|
|
53395
|
+
};
|
|
53396
|
+
}
|
|
53397
|
+
_parseSync(input2) {
|
|
53398
|
+
const result = this._parse(input2);
|
|
53399
|
+
if (isAsync(result)) {
|
|
53400
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
53401
|
+
}
|
|
53402
|
+
return result;
|
|
53403
|
+
}
|
|
53404
|
+
_parseAsync(input2) {
|
|
53405
|
+
const result = this._parse(input2);
|
|
53406
|
+
return Promise.resolve(result);
|
|
53407
|
+
}
|
|
53408
|
+
parse(data, params) {
|
|
53409
|
+
const result = this.safeParse(data, params);
|
|
53410
|
+
if (result.success)
|
|
53411
|
+
return result.data;
|
|
53412
|
+
throw result.error;
|
|
53413
|
+
}
|
|
53414
|
+
safeParse(data, params) {
|
|
53415
|
+
const ctx = {
|
|
53416
|
+
common: {
|
|
53417
|
+
issues: [],
|
|
53418
|
+
async: params?.async ?? false,
|
|
53419
|
+
contextualErrorMap: params?.errorMap
|
|
53420
|
+
},
|
|
53421
|
+
path: params?.path || [],
|
|
53422
|
+
schemaErrorMap: this._def.errorMap,
|
|
53423
|
+
parent: null,
|
|
53424
|
+
data,
|
|
53425
|
+
parsedType: getParsedType2(data)
|
|
53426
|
+
};
|
|
53427
|
+
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
53428
|
+
return handleResult(ctx, result);
|
|
53429
|
+
}
|
|
53430
|
+
"~validate"(data) {
|
|
53431
|
+
const ctx = {
|
|
53432
|
+
common: {
|
|
53433
|
+
issues: [],
|
|
53434
|
+
async: !!this["~standard"].async
|
|
53435
|
+
},
|
|
53436
|
+
path: [],
|
|
53437
|
+
schemaErrorMap: this._def.errorMap,
|
|
53438
|
+
parent: null,
|
|
53439
|
+
data,
|
|
53440
|
+
parsedType: getParsedType2(data)
|
|
53441
|
+
};
|
|
53442
|
+
if (!this["~standard"].async) {
|
|
53443
|
+
try {
|
|
53444
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
53445
|
+
return isValid(result) ? {
|
|
53446
|
+
value: result.value
|
|
53447
|
+
} : {
|
|
53448
|
+
issues: ctx.common.issues
|
|
53449
|
+
};
|
|
53450
|
+
} catch (err) {
|
|
53451
|
+
if (err?.message?.toLowerCase()?.includes("encountered")) {
|
|
53452
|
+
this["~standard"].async = true;
|
|
53453
|
+
}
|
|
53454
|
+
ctx.common = {
|
|
53455
|
+
issues: [],
|
|
53456
|
+
async: true
|
|
53457
|
+
};
|
|
53458
|
+
}
|
|
53459
|
+
}
|
|
53460
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
53461
|
+
value: result.value
|
|
53462
|
+
} : {
|
|
53463
|
+
issues: ctx.common.issues
|
|
53464
|
+
});
|
|
53465
|
+
}
|
|
53466
|
+
async parseAsync(data, params) {
|
|
53467
|
+
const result = await this.safeParseAsync(data, params);
|
|
53468
|
+
if (result.success)
|
|
53469
|
+
return result.data;
|
|
53470
|
+
throw result.error;
|
|
53471
|
+
}
|
|
53472
|
+
async safeParseAsync(data, params) {
|
|
53473
|
+
const ctx = {
|
|
53474
|
+
common: {
|
|
53475
|
+
issues: [],
|
|
53476
|
+
contextualErrorMap: params?.errorMap,
|
|
53477
|
+
async: true
|
|
53478
|
+
},
|
|
53479
|
+
path: params?.path || [],
|
|
53480
|
+
schemaErrorMap: this._def.errorMap,
|
|
53481
|
+
parent: null,
|
|
53482
|
+
data,
|
|
53483
|
+
parsedType: getParsedType2(data)
|
|
53484
|
+
};
|
|
53485
|
+
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
53486
|
+
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
53487
|
+
return handleResult(ctx, result);
|
|
53488
|
+
}
|
|
53489
|
+
refine(check3, message) {
|
|
53490
|
+
const getIssueProperties = (val) => {
|
|
53491
|
+
if (typeof message === "string" || typeof message === "undefined") {
|
|
53492
|
+
return { message };
|
|
53493
|
+
} else if (typeof message === "function") {
|
|
53494
|
+
return message(val);
|
|
53495
|
+
} else {
|
|
53496
|
+
return message;
|
|
53497
|
+
}
|
|
53498
|
+
};
|
|
53499
|
+
return this._refinement((val, ctx) => {
|
|
53500
|
+
const result = check3(val);
|
|
53501
|
+
const setError = () => ctx.addIssue({
|
|
53502
|
+
code: ZodIssueCode2.custom,
|
|
53503
|
+
...getIssueProperties(val)
|
|
53504
|
+
});
|
|
53505
|
+
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
|
53506
|
+
return result.then((data) => {
|
|
53507
|
+
if (!data) {
|
|
53508
|
+
setError();
|
|
53509
|
+
return false;
|
|
53510
|
+
} else {
|
|
53511
|
+
return true;
|
|
53512
|
+
}
|
|
53513
|
+
});
|
|
53514
|
+
}
|
|
53515
|
+
if (!result) {
|
|
53516
|
+
setError();
|
|
53517
|
+
return false;
|
|
53518
|
+
} else {
|
|
53519
|
+
return true;
|
|
53520
|
+
}
|
|
53521
|
+
});
|
|
53522
|
+
}
|
|
53523
|
+
refinement(check3, refinementData) {
|
|
53524
|
+
return this._refinement((val, ctx) => {
|
|
53525
|
+
if (!check3(val)) {
|
|
53526
|
+
ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
|
|
53527
|
+
return false;
|
|
53528
|
+
} else {
|
|
53529
|
+
return true;
|
|
53530
|
+
}
|
|
53531
|
+
});
|
|
53532
|
+
}
|
|
53533
|
+
_refinement(refinement) {
|
|
53534
|
+
return new ZodEffects({
|
|
53535
|
+
schema: this,
|
|
53536
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
53537
|
+
effect: { type: "refinement", refinement }
|
|
53538
|
+
});
|
|
53539
|
+
}
|
|
53540
|
+
superRefine(refinement) {
|
|
53541
|
+
return this._refinement(refinement);
|
|
53542
|
+
}
|
|
53543
|
+
constructor(def) {
|
|
53544
|
+
this.spa = this.safeParseAsync;
|
|
53545
|
+
this._def = def;
|
|
53546
|
+
this.parse = this.parse.bind(this);
|
|
53547
|
+
this.safeParse = this.safeParse.bind(this);
|
|
53548
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
53549
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
53550
|
+
this.spa = this.spa.bind(this);
|
|
53551
|
+
this.refine = this.refine.bind(this);
|
|
53552
|
+
this.refinement = this.refinement.bind(this);
|
|
53553
|
+
this.superRefine = this.superRefine.bind(this);
|
|
53554
|
+
this.optional = this.optional.bind(this);
|
|
53555
|
+
this.nullable = this.nullable.bind(this);
|
|
53556
|
+
this.nullish = this.nullish.bind(this);
|
|
53557
|
+
this.array = this.array.bind(this);
|
|
53558
|
+
this.promise = this.promise.bind(this);
|
|
53559
|
+
this.or = this.or.bind(this);
|
|
53560
|
+
this.and = this.and.bind(this);
|
|
53561
|
+
this.transform = this.transform.bind(this);
|
|
53562
|
+
this.brand = this.brand.bind(this);
|
|
53563
|
+
this.default = this.default.bind(this);
|
|
53564
|
+
this.catch = this.catch.bind(this);
|
|
53565
|
+
this.describe = this.describe.bind(this);
|
|
53566
|
+
this.pipe = this.pipe.bind(this);
|
|
53567
|
+
this.readonly = this.readonly.bind(this);
|
|
53568
|
+
this.isNullable = this.isNullable.bind(this);
|
|
53569
|
+
this.isOptional = this.isOptional.bind(this);
|
|
53570
|
+
this["~standard"] = {
|
|
53571
|
+
version: 1,
|
|
53572
|
+
vendor: "zod",
|
|
53573
|
+
validate: (data) => this["~validate"](data)
|
|
53574
|
+
};
|
|
53575
|
+
}
|
|
53576
|
+
optional() {
|
|
53577
|
+
return ZodOptional2.create(this, this._def);
|
|
53578
|
+
}
|
|
53579
|
+
nullable() {
|
|
53580
|
+
return ZodNullable2.create(this, this._def);
|
|
53581
|
+
}
|
|
53582
|
+
nullish() {
|
|
53583
|
+
return this.nullable().optional();
|
|
53584
|
+
}
|
|
53585
|
+
array() {
|
|
53586
|
+
return ZodArray2.create(this);
|
|
53587
|
+
}
|
|
53588
|
+
promise() {
|
|
53589
|
+
return ZodPromise2.create(this, this._def);
|
|
53590
|
+
}
|
|
53591
|
+
or(option) {
|
|
53592
|
+
return ZodUnion2.create([this, option], this._def);
|
|
53593
|
+
}
|
|
53594
|
+
and(incoming) {
|
|
53595
|
+
return ZodIntersection2.create(this, incoming, this._def);
|
|
53596
|
+
}
|
|
53597
|
+
transform(transform2) {
|
|
53598
|
+
return new ZodEffects({
|
|
53599
|
+
...processCreateParams(this._def),
|
|
53600
|
+
schema: this,
|
|
53601
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
53602
|
+
effect: { type: "transform", transform: transform2 }
|
|
53603
|
+
});
|
|
53604
|
+
}
|
|
53605
|
+
default(def) {
|
|
53606
|
+
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
53607
|
+
return new ZodDefault2({
|
|
53608
|
+
...processCreateParams(this._def),
|
|
53609
|
+
innerType: this,
|
|
53610
|
+
defaultValue: defaultValueFunc,
|
|
53611
|
+
typeName: ZodFirstPartyTypeKind2.ZodDefault
|
|
53612
|
+
});
|
|
53613
|
+
}
|
|
53614
|
+
brand() {
|
|
53615
|
+
return new ZodBranded({
|
|
53616
|
+
typeName: ZodFirstPartyTypeKind2.ZodBranded,
|
|
53617
|
+
type: this,
|
|
53618
|
+
...processCreateParams(this._def)
|
|
53619
|
+
});
|
|
53620
|
+
}
|
|
53621
|
+
catch(def) {
|
|
53622
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
53623
|
+
return new ZodCatch2({
|
|
53624
|
+
...processCreateParams(this._def),
|
|
53625
|
+
innerType: this,
|
|
53626
|
+
catchValue: catchValueFunc,
|
|
53627
|
+
typeName: ZodFirstPartyTypeKind2.ZodCatch
|
|
53628
|
+
});
|
|
53629
|
+
}
|
|
53630
|
+
describe(description) {
|
|
53631
|
+
const This = this.constructor;
|
|
53632
|
+
return new This({
|
|
53633
|
+
...this._def,
|
|
53634
|
+
description
|
|
53635
|
+
});
|
|
53636
|
+
}
|
|
53637
|
+
pipe(target) {
|
|
53638
|
+
return ZodPipeline.create(this, target);
|
|
53639
|
+
}
|
|
53640
|
+
readonly() {
|
|
53641
|
+
return ZodReadonly2.create(this);
|
|
53642
|
+
}
|
|
53643
|
+
isOptional() {
|
|
53644
|
+
return this.safeParse(void 0).success;
|
|
53645
|
+
}
|
|
53646
|
+
isNullable() {
|
|
53647
|
+
return this.safeParse(null).success;
|
|
53648
|
+
}
|
|
53649
|
+
};
|
|
53650
|
+
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
53651
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
53652
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
53653
|
+
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
53654
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
53655
|
+
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
53656
|
+
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
53657
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
53658
|
+
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
53659
|
+
var emojiRegex;
|
|
53660
|
+
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
53661
|
+
var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
|
|
53662
|
+
var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
53663
|
+
var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
53664
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
53665
|
+
var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
53666
|
+
var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
53667
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
53668
|
+
function timeRegexSource(args) {
|
|
53669
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
53670
|
+
if (args.precision) {
|
|
53671
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
53672
|
+
} else if (args.precision == null) {
|
|
53673
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
53674
|
+
}
|
|
53675
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
53676
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
53677
|
+
}
|
|
53678
|
+
function timeRegex(args) {
|
|
53679
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
53680
|
+
}
|
|
53681
|
+
function datetimeRegex(args) {
|
|
53682
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
53683
|
+
const opts = [];
|
|
53684
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
53685
|
+
if (args.offset)
|
|
53686
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
53687
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
53688
|
+
return new RegExp(`^${regex}$`);
|
|
53689
|
+
}
|
|
53690
|
+
function isValidIP(ip, version2) {
|
|
53691
|
+
if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
|
|
53692
|
+
return true;
|
|
53693
|
+
}
|
|
53694
|
+
if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
|
|
53695
|
+
return true;
|
|
53696
|
+
}
|
|
53697
|
+
return false;
|
|
53698
|
+
}
|
|
53699
|
+
function isValidJWT2(jwt2, alg) {
|
|
53700
|
+
if (!jwtRegex.test(jwt2))
|
|
53701
|
+
return false;
|
|
53702
|
+
try {
|
|
53703
|
+
const [header] = jwt2.split(".");
|
|
53704
|
+
if (!header)
|
|
53705
|
+
return false;
|
|
53706
|
+
const base643 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
53707
|
+
const decoded = JSON.parse(atob(base643));
|
|
53708
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
53709
|
+
return false;
|
|
53710
|
+
if ("typ" in decoded && decoded?.typ !== "JWT")
|
|
53711
|
+
return false;
|
|
53712
|
+
if (!decoded.alg)
|
|
53713
|
+
return false;
|
|
53714
|
+
if (alg && decoded.alg !== alg)
|
|
53715
|
+
return false;
|
|
53716
|
+
return true;
|
|
53717
|
+
} catch {
|
|
53718
|
+
return false;
|
|
53719
|
+
}
|
|
53720
|
+
}
|
|
53721
|
+
function isValidCidr(ip, version2) {
|
|
53722
|
+
if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
|
|
53723
|
+
return true;
|
|
53724
|
+
}
|
|
53725
|
+
if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
|
|
53726
|
+
return true;
|
|
53727
|
+
}
|
|
53728
|
+
return false;
|
|
53729
|
+
}
|
|
53730
|
+
var ZodString2 = class _ZodString2 extends ZodType2 {
|
|
53731
|
+
_parse(input2) {
|
|
53732
|
+
if (this._def.coerce) {
|
|
53733
|
+
input2.data = String(input2.data);
|
|
53734
|
+
}
|
|
53735
|
+
const parsedType2 = this._getType(input2);
|
|
53736
|
+
if (parsedType2 !== ZodParsedType.string) {
|
|
53737
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
53738
|
+
addIssueToContext(ctx2, {
|
|
53739
|
+
code: ZodIssueCode2.invalid_type,
|
|
53740
|
+
expected: ZodParsedType.string,
|
|
53741
|
+
received: ctx2.parsedType
|
|
53742
|
+
});
|
|
53743
|
+
return INVALID2;
|
|
53744
|
+
}
|
|
53745
|
+
const status = new ParseStatus();
|
|
53746
|
+
let ctx = void 0;
|
|
53747
|
+
for (const check3 of this._def.checks) {
|
|
53748
|
+
if (check3.kind === "min") {
|
|
53749
|
+
if (input2.data.length < check3.value) {
|
|
53750
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53751
|
+
addIssueToContext(ctx, {
|
|
53752
|
+
code: ZodIssueCode2.too_small,
|
|
53753
|
+
minimum: check3.value,
|
|
53754
|
+
type: "string",
|
|
53755
|
+
inclusive: true,
|
|
53756
|
+
exact: false,
|
|
53757
|
+
message: check3.message
|
|
53758
|
+
});
|
|
53759
|
+
status.dirty();
|
|
53760
|
+
}
|
|
53761
|
+
} else if (check3.kind === "max") {
|
|
53762
|
+
if (input2.data.length > check3.value) {
|
|
53763
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53764
|
+
addIssueToContext(ctx, {
|
|
53765
|
+
code: ZodIssueCode2.too_big,
|
|
53766
|
+
maximum: check3.value,
|
|
53767
|
+
type: "string",
|
|
53768
|
+
inclusive: true,
|
|
53769
|
+
exact: false,
|
|
53770
|
+
message: check3.message
|
|
53771
|
+
});
|
|
53772
|
+
status.dirty();
|
|
53773
|
+
}
|
|
53774
|
+
} else if (check3.kind === "length") {
|
|
53775
|
+
const tooBig = input2.data.length > check3.value;
|
|
53776
|
+
const tooSmall = input2.data.length < check3.value;
|
|
53777
|
+
if (tooBig || tooSmall) {
|
|
53778
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53779
|
+
if (tooBig) {
|
|
53780
|
+
addIssueToContext(ctx, {
|
|
53781
|
+
code: ZodIssueCode2.too_big,
|
|
53782
|
+
maximum: check3.value,
|
|
53783
|
+
type: "string",
|
|
53784
|
+
inclusive: true,
|
|
53785
|
+
exact: true,
|
|
53786
|
+
message: check3.message
|
|
53787
|
+
});
|
|
53788
|
+
} else if (tooSmall) {
|
|
53789
|
+
addIssueToContext(ctx, {
|
|
53790
|
+
code: ZodIssueCode2.too_small,
|
|
53791
|
+
minimum: check3.value,
|
|
53792
|
+
type: "string",
|
|
53793
|
+
inclusive: true,
|
|
53794
|
+
exact: true,
|
|
53795
|
+
message: check3.message
|
|
53796
|
+
});
|
|
53797
|
+
}
|
|
53798
|
+
status.dirty();
|
|
53799
|
+
}
|
|
53800
|
+
} else if (check3.kind === "email") {
|
|
53801
|
+
if (!emailRegex.test(input2.data)) {
|
|
53802
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53803
|
+
addIssueToContext(ctx, {
|
|
53804
|
+
validation: "email",
|
|
53805
|
+
code: ZodIssueCode2.invalid_string,
|
|
53806
|
+
message: check3.message
|
|
53807
|
+
});
|
|
53808
|
+
status.dirty();
|
|
53809
|
+
}
|
|
53810
|
+
} else if (check3.kind === "emoji") {
|
|
53811
|
+
if (!emojiRegex) {
|
|
53812
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
53813
|
+
}
|
|
53814
|
+
if (!emojiRegex.test(input2.data)) {
|
|
53815
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53816
|
+
addIssueToContext(ctx, {
|
|
53817
|
+
validation: "emoji",
|
|
53818
|
+
code: ZodIssueCode2.invalid_string,
|
|
53819
|
+
message: check3.message
|
|
53820
|
+
});
|
|
53821
|
+
status.dirty();
|
|
53822
|
+
}
|
|
53823
|
+
} else if (check3.kind === "uuid") {
|
|
53824
|
+
if (!uuidRegex.test(input2.data)) {
|
|
53825
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53826
|
+
addIssueToContext(ctx, {
|
|
53827
|
+
validation: "uuid",
|
|
53828
|
+
code: ZodIssueCode2.invalid_string,
|
|
53829
|
+
message: check3.message
|
|
53830
|
+
});
|
|
53831
|
+
status.dirty();
|
|
53832
|
+
}
|
|
53833
|
+
} else if (check3.kind === "nanoid") {
|
|
53834
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
53835
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53836
|
+
addIssueToContext(ctx, {
|
|
53837
|
+
validation: "nanoid",
|
|
53838
|
+
code: ZodIssueCode2.invalid_string,
|
|
53839
|
+
message: check3.message
|
|
53840
|
+
});
|
|
53841
|
+
status.dirty();
|
|
53842
|
+
}
|
|
53843
|
+
} else if (check3.kind === "cuid") {
|
|
53844
|
+
if (!cuidRegex.test(input2.data)) {
|
|
53845
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53846
|
+
addIssueToContext(ctx, {
|
|
53847
|
+
validation: "cuid",
|
|
53848
|
+
code: ZodIssueCode2.invalid_string,
|
|
53849
|
+
message: check3.message
|
|
53850
|
+
});
|
|
53851
|
+
status.dirty();
|
|
53852
|
+
}
|
|
53853
|
+
} else if (check3.kind === "cuid2") {
|
|
53854
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
53855
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53856
|
+
addIssueToContext(ctx, {
|
|
53857
|
+
validation: "cuid2",
|
|
53858
|
+
code: ZodIssueCode2.invalid_string,
|
|
53859
|
+
message: check3.message
|
|
53860
|
+
});
|
|
53861
|
+
status.dirty();
|
|
53862
|
+
}
|
|
53863
|
+
} else if (check3.kind === "ulid") {
|
|
53864
|
+
if (!ulidRegex.test(input2.data)) {
|
|
53865
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53866
|
+
addIssueToContext(ctx, {
|
|
53867
|
+
validation: "ulid",
|
|
53868
|
+
code: ZodIssueCode2.invalid_string,
|
|
53869
|
+
message: check3.message
|
|
53870
|
+
});
|
|
53871
|
+
status.dirty();
|
|
53872
|
+
}
|
|
53873
|
+
} else if (check3.kind === "url") {
|
|
53874
|
+
try {
|
|
53875
|
+
new URL(input2.data);
|
|
53876
|
+
} catch {
|
|
53877
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53878
|
+
addIssueToContext(ctx, {
|
|
53879
|
+
validation: "url",
|
|
53880
|
+
code: ZodIssueCode2.invalid_string,
|
|
53881
|
+
message: check3.message
|
|
53882
|
+
});
|
|
53883
|
+
status.dirty();
|
|
53884
|
+
}
|
|
53885
|
+
} else if (check3.kind === "regex") {
|
|
53886
|
+
check3.regex.lastIndex = 0;
|
|
53887
|
+
const testResult = check3.regex.test(input2.data);
|
|
53888
|
+
if (!testResult) {
|
|
53889
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53890
|
+
addIssueToContext(ctx, {
|
|
53891
|
+
validation: "regex",
|
|
53892
|
+
code: ZodIssueCode2.invalid_string,
|
|
53893
|
+
message: check3.message
|
|
53894
|
+
});
|
|
53895
|
+
status.dirty();
|
|
53896
|
+
}
|
|
53897
|
+
} else if (check3.kind === "trim") {
|
|
53898
|
+
input2.data = input2.data.trim();
|
|
53899
|
+
} else if (check3.kind === "includes") {
|
|
53900
|
+
if (!input2.data.includes(check3.value, check3.position)) {
|
|
53901
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53902
|
+
addIssueToContext(ctx, {
|
|
53903
|
+
code: ZodIssueCode2.invalid_string,
|
|
53904
|
+
validation: { includes: check3.value, position: check3.position },
|
|
53905
|
+
message: check3.message
|
|
53906
|
+
});
|
|
53907
|
+
status.dirty();
|
|
53908
|
+
}
|
|
53909
|
+
} else if (check3.kind === "toLowerCase") {
|
|
53910
|
+
input2.data = input2.data.toLowerCase();
|
|
53911
|
+
} else if (check3.kind === "toUpperCase") {
|
|
53912
|
+
input2.data = input2.data.toUpperCase();
|
|
53913
|
+
} else if (check3.kind === "startsWith") {
|
|
53914
|
+
if (!input2.data.startsWith(check3.value)) {
|
|
53915
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53916
|
+
addIssueToContext(ctx, {
|
|
53917
|
+
code: ZodIssueCode2.invalid_string,
|
|
53918
|
+
validation: { startsWith: check3.value },
|
|
53919
|
+
message: check3.message
|
|
53920
|
+
});
|
|
53921
|
+
status.dirty();
|
|
53922
|
+
}
|
|
53923
|
+
} else if (check3.kind === "endsWith") {
|
|
53924
|
+
if (!input2.data.endsWith(check3.value)) {
|
|
53925
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53926
|
+
addIssueToContext(ctx, {
|
|
53927
|
+
code: ZodIssueCode2.invalid_string,
|
|
53928
|
+
validation: { endsWith: check3.value },
|
|
53929
|
+
message: check3.message
|
|
53930
|
+
});
|
|
53931
|
+
status.dirty();
|
|
53932
|
+
}
|
|
53933
|
+
} else if (check3.kind === "datetime") {
|
|
53934
|
+
const regex = datetimeRegex(check3);
|
|
53935
|
+
if (!regex.test(input2.data)) {
|
|
53936
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53937
|
+
addIssueToContext(ctx, {
|
|
53938
|
+
code: ZodIssueCode2.invalid_string,
|
|
53939
|
+
validation: "datetime",
|
|
53940
|
+
message: check3.message
|
|
53941
|
+
});
|
|
53942
|
+
status.dirty();
|
|
53943
|
+
}
|
|
53944
|
+
} else if (check3.kind === "date") {
|
|
53945
|
+
const regex = dateRegex;
|
|
53946
|
+
if (!regex.test(input2.data)) {
|
|
53947
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53948
|
+
addIssueToContext(ctx, {
|
|
53949
|
+
code: ZodIssueCode2.invalid_string,
|
|
53950
|
+
validation: "date",
|
|
53951
|
+
message: check3.message
|
|
53952
|
+
});
|
|
53953
|
+
status.dirty();
|
|
53954
|
+
}
|
|
53955
|
+
} else if (check3.kind === "time") {
|
|
53956
|
+
const regex = timeRegex(check3);
|
|
53957
|
+
if (!regex.test(input2.data)) {
|
|
53958
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53959
|
+
addIssueToContext(ctx, {
|
|
53960
|
+
code: ZodIssueCode2.invalid_string,
|
|
53961
|
+
validation: "time",
|
|
53962
|
+
message: check3.message
|
|
53963
|
+
});
|
|
53964
|
+
status.dirty();
|
|
53965
|
+
}
|
|
53966
|
+
} else if (check3.kind === "duration") {
|
|
53967
|
+
if (!durationRegex.test(input2.data)) {
|
|
53968
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53969
|
+
addIssueToContext(ctx, {
|
|
53970
|
+
validation: "duration",
|
|
53971
|
+
code: ZodIssueCode2.invalid_string,
|
|
53972
|
+
message: check3.message
|
|
53973
|
+
});
|
|
53974
|
+
status.dirty();
|
|
53975
|
+
}
|
|
53976
|
+
} else if (check3.kind === "ip") {
|
|
53977
|
+
if (!isValidIP(input2.data, check3.version)) {
|
|
53978
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53979
|
+
addIssueToContext(ctx, {
|
|
53980
|
+
validation: "ip",
|
|
53981
|
+
code: ZodIssueCode2.invalid_string,
|
|
53982
|
+
message: check3.message
|
|
53983
|
+
});
|
|
53984
|
+
status.dirty();
|
|
53985
|
+
}
|
|
53986
|
+
} else if (check3.kind === "jwt") {
|
|
53987
|
+
if (!isValidJWT2(input2.data, check3.alg)) {
|
|
53988
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53989
|
+
addIssueToContext(ctx, {
|
|
53990
|
+
validation: "jwt",
|
|
53991
|
+
code: ZodIssueCode2.invalid_string,
|
|
53992
|
+
message: check3.message
|
|
53993
|
+
});
|
|
53994
|
+
status.dirty();
|
|
53995
|
+
}
|
|
53996
|
+
} else if (check3.kind === "cidr") {
|
|
53997
|
+
if (!isValidCidr(input2.data, check3.version)) {
|
|
53998
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
53999
|
+
addIssueToContext(ctx, {
|
|
54000
|
+
validation: "cidr",
|
|
54001
|
+
code: ZodIssueCode2.invalid_string,
|
|
54002
|
+
message: check3.message
|
|
54003
|
+
});
|
|
54004
|
+
status.dirty();
|
|
54005
|
+
}
|
|
54006
|
+
} else if (check3.kind === "base64") {
|
|
54007
|
+
if (!base64Regex.test(input2.data)) {
|
|
54008
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54009
|
+
addIssueToContext(ctx, {
|
|
54010
|
+
validation: "base64",
|
|
54011
|
+
code: ZodIssueCode2.invalid_string,
|
|
54012
|
+
message: check3.message
|
|
54013
|
+
});
|
|
54014
|
+
status.dirty();
|
|
54015
|
+
}
|
|
54016
|
+
} else if (check3.kind === "base64url") {
|
|
54017
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
54018
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54019
|
+
addIssueToContext(ctx, {
|
|
54020
|
+
validation: "base64url",
|
|
54021
|
+
code: ZodIssueCode2.invalid_string,
|
|
54022
|
+
message: check3.message
|
|
54023
|
+
});
|
|
54024
|
+
status.dirty();
|
|
54025
|
+
}
|
|
54026
|
+
} else {
|
|
54027
|
+
util.assertNever(check3);
|
|
54028
|
+
}
|
|
54029
|
+
}
|
|
54030
|
+
return { status: status.value, value: input2.data };
|
|
54031
|
+
}
|
|
54032
|
+
_regex(regex, validation, message) {
|
|
54033
|
+
return this.refinement((data) => regex.test(data), {
|
|
54034
|
+
validation,
|
|
54035
|
+
code: ZodIssueCode2.invalid_string,
|
|
54036
|
+
...errorUtil.errToObj(message)
|
|
54037
|
+
});
|
|
54038
|
+
}
|
|
54039
|
+
_addCheck(check3) {
|
|
54040
|
+
return new _ZodString2({
|
|
54041
|
+
...this._def,
|
|
54042
|
+
checks: [...this._def.checks, check3]
|
|
54043
|
+
});
|
|
54044
|
+
}
|
|
54045
|
+
email(message) {
|
|
54046
|
+
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
|
|
54047
|
+
}
|
|
54048
|
+
url(message) {
|
|
54049
|
+
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
54050
|
+
}
|
|
54051
|
+
emoji(message) {
|
|
54052
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
54053
|
+
}
|
|
54054
|
+
uuid(message) {
|
|
54055
|
+
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
54056
|
+
}
|
|
54057
|
+
nanoid(message) {
|
|
54058
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
54059
|
+
}
|
|
54060
|
+
cuid(message) {
|
|
54061
|
+
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
54062
|
+
}
|
|
54063
|
+
cuid2(message) {
|
|
54064
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
54065
|
+
}
|
|
54066
|
+
ulid(message) {
|
|
54067
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
54068
|
+
}
|
|
54069
|
+
base64(message) {
|
|
54070
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
54071
|
+
}
|
|
54072
|
+
base64url(message) {
|
|
54073
|
+
return this._addCheck({
|
|
54074
|
+
kind: "base64url",
|
|
54075
|
+
...errorUtil.errToObj(message)
|
|
54076
|
+
});
|
|
54077
|
+
}
|
|
54078
|
+
jwt(options) {
|
|
54079
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
54080
|
+
}
|
|
54081
|
+
ip(options) {
|
|
54082
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
54083
|
+
}
|
|
54084
|
+
cidr(options) {
|
|
54085
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
54086
|
+
}
|
|
54087
|
+
datetime(options) {
|
|
54088
|
+
if (typeof options === "string") {
|
|
54089
|
+
return this._addCheck({
|
|
54090
|
+
kind: "datetime",
|
|
54091
|
+
precision: null,
|
|
54092
|
+
offset: false,
|
|
54093
|
+
local: false,
|
|
54094
|
+
message: options
|
|
54095
|
+
});
|
|
54096
|
+
}
|
|
54097
|
+
return this._addCheck({
|
|
54098
|
+
kind: "datetime",
|
|
54099
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
54100
|
+
offset: options?.offset ?? false,
|
|
54101
|
+
local: options?.local ?? false,
|
|
54102
|
+
...errorUtil.errToObj(options?.message)
|
|
54103
|
+
});
|
|
54104
|
+
}
|
|
54105
|
+
date(message) {
|
|
54106
|
+
return this._addCheck({ kind: "date", message });
|
|
54107
|
+
}
|
|
54108
|
+
time(options) {
|
|
54109
|
+
if (typeof options === "string") {
|
|
54110
|
+
return this._addCheck({
|
|
54111
|
+
kind: "time",
|
|
54112
|
+
precision: null,
|
|
54113
|
+
message: options
|
|
54114
|
+
});
|
|
54115
|
+
}
|
|
54116
|
+
return this._addCheck({
|
|
54117
|
+
kind: "time",
|
|
54118
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
54119
|
+
...errorUtil.errToObj(options?.message)
|
|
54120
|
+
});
|
|
54121
|
+
}
|
|
54122
|
+
duration(message) {
|
|
54123
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
54124
|
+
}
|
|
54125
|
+
regex(regex, message) {
|
|
54126
|
+
return this._addCheck({
|
|
54127
|
+
kind: "regex",
|
|
54128
|
+
regex,
|
|
54129
|
+
...errorUtil.errToObj(message)
|
|
54130
|
+
});
|
|
54131
|
+
}
|
|
54132
|
+
includes(value, options) {
|
|
54133
|
+
return this._addCheck({
|
|
54134
|
+
kind: "includes",
|
|
54135
|
+
value,
|
|
54136
|
+
position: options?.position,
|
|
54137
|
+
...errorUtil.errToObj(options?.message)
|
|
54138
|
+
});
|
|
54139
|
+
}
|
|
54140
|
+
startsWith(value, message) {
|
|
54141
|
+
return this._addCheck({
|
|
54142
|
+
kind: "startsWith",
|
|
54143
|
+
value,
|
|
54144
|
+
...errorUtil.errToObj(message)
|
|
54145
|
+
});
|
|
54146
|
+
}
|
|
54147
|
+
endsWith(value, message) {
|
|
54148
|
+
return this._addCheck({
|
|
54149
|
+
kind: "endsWith",
|
|
54150
|
+
value,
|
|
54151
|
+
...errorUtil.errToObj(message)
|
|
54152
|
+
});
|
|
54153
|
+
}
|
|
54154
|
+
min(minLength, message) {
|
|
54155
|
+
return this._addCheck({
|
|
54156
|
+
kind: "min",
|
|
54157
|
+
value: minLength,
|
|
54158
|
+
...errorUtil.errToObj(message)
|
|
54159
|
+
});
|
|
54160
|
+
}
|
|
54161
|
+
max(maxLength, message) {
|
|
54162
|
+
return this._addCheck({
|
|
54163
|
+
kind: "max",
|
|
54164
|
+
value: maxLength,
|
|
54165
|
+
...errorUtil.errToObj(message)
|
|
54166
|
+
});
|
|
54167
|
+
}
|
|
54168
|
+
length(len, message) {
|
|
54169
|
+
return this._addCheck({
|
|
54170
|
+
kind: "length",
|
|
54171
|
+
value: len,
|
|
54172
|
+
...errorUtil.errToObj(message)
|
|
54173
|
+
});
|
|
54174
|
+
}
|
|
54175
|
+
/**
|
|
54176
|
+
* Equivalent to `.min(1)`
|
|
54177
|
+
*/
|
|
54178
|
+
nonempty(message) {
|
|
54179
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
54180
|
+
}
|
|
54181
|
+
trim() {
|
|
54182
|
+
return new _ZodString2({
|
|
54183
|
+
...this._def,
|
|
54184
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
54185
|
+
});
|
|
54186
|
+
}
|
|
54187
|
+
toLowerCase() {
|
|
54188
|
+
return new _ZodString2({
|
|
54189
|
+
...this._def,
|
|
54190
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
54191
|
+
});
|
|
54192
|
+
}
|
|
54193
|
+
toUpperCase() {
|
|
54194
|
+
return new _ZodString2({
|
|
54195
|
+
...this._def,
|
|
54196
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
54197
|
+
});
|
|
54198
|
+
}
|
|
54199
|
+
get isDatetime() {
|
|
54200
|
+
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
54201
|
+
}
|
|
54202
|
+
get isDate() {
|
|
54203
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
54204
|
+
}
|
|
54205
|
+
get isTime() {
|
|
54206
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
54207
|
+
}
|
|
54208
|
+
get isDuration() {
|
|
54209
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
54210
|
+
}
|
|
54211
|
+
get isEmail() {
|
|
54212
|
+
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
54213
|
+
}
|
|
54214
|
+
get isURL() {
|
|
54215
|
+
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
54216
|
+
}
|
|
54217
|
+
get isEmoji() {
|
|
54218
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
54219
|
+
}
|
|
54220
|
+
get isUUID() {
|
|
54221
|
+
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
54222
|
+
}
|
|
54223
|
+
get isNANOID() {
|
|
54224
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
54225
|
+
}
|
|
54226
|
+
get isCUID() {
|
|
54227
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
54228
|
+
}
|
|
54229
|
+
get isCUID2() {
|
|
54230
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
54231
|
+
}
|
|
54232
|
+
get isULID() {
|
|
54233
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
54234
|
+
}
|
|
54235
|
+
get isIP() {
|
|
54236
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
54237
|
+
}
|
|
54238
|
+
get isCIDR() {
|
|
54239
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
54240
|
+
}
|
|
54241
|
+
get isBase64() {
|
|
54242
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
54243
|
+
}
|
|
54244
|
+
get isBase64url() {
|
|
54245
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
54246
|
+
}
|
|
54247
|
+
get minLength() {
|
|
54248
|
+
let min = null;
|
|
54249
|
+
for (const ch of this._def.checks) {
|
|
54250
|
+
if (ch.kind === "min") {
|
|
54251
|
+
if (min === null || ch.value > min)
|
|
54252
|
+
min = ch.value;
|
|
54253
|
+
}
|
|
54254
|
+
}
|
|
54255
|
+
return min;
|
|
54256
|
+
}
|
|
54257
|
+
get maxLength() {
|
|
54258
|
+
let max = null;
|
|
54259
|
+
for (const ch of this._def.checks) {
|
|
54260
|
+
if (ch.kind === "max") {
|
|
54261
|
+
if (max === null || ch.value < max)
|
|
54262
|
+
max = ch.value;
|
|
54263
|
+
}
|
|
54264
|
+
}
|
|
54265
|
+
return max;
|
|
54266
|
+
}
|
|
54267
|
+
};
|
|
54268
|
+
ZodString2.create = (params) => {
|
|
54269
|
+
return new ZodString2({
|
|
54270
|
+
checks: [],
|
|
54271
|
+
typeName: ZodFirstPartyTypeKind2.ZodString,
|
|
54272
|
+
coerce: params?.coerce ?? false,
|
|
54273
|
+
...processCreateParams(params)
|
|
54274
|
+
});
|
|
54275
|
+
};
|
|
54276
|
+
function floatSafeRemainder2(val, step) {
|
|
54277
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
54278
|
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
54279
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
54280
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
54281
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
54282
|
+
return valInt % stepInt / 10 ** decCount;
|
|
54283
|
+
}
|
|
54284
|
+
var ZodNumber2 = class _ZodNumber extends ZodType2 {
|
|
54285
|
+
constructor() {
|
|
54286
|
+
super(...arguments);
|
|
54287
|
+
this.min = this.gte;
|
|
54288
|
+
this.max = this.lte;
|
|
54289
|
+
this.step = this.multipleOf;
|
|
54290
|
+
}
|
|
54291
|
+
_parse(input2) {
|
|
54292
|
+
if (this._def.coerce) {
|
|
54293
|
+
input2.data = Number(input2.data);
|
|
54294
|
+
}
|
|
54295
|
+
const parsedType2 = this._getType(input2);
|
|
54296
|
+
if (parsedType2 !== ZodParsedType.number) {
|
|
54297
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
54298
|
+
addIssueToContext(ctx2, {
|
|
54299
|
+
code: ZodIssueCode2.invalid_type,
|
|
54300
|
+
expected: ZodParsedType.number,
|
|
54301
|
+
received: ctx2.parsedType
|
|
54302
|
+
});
|
|
54303
|
+
return INVALID2;
|
|
54304
|
+
}
|
|
54305
|
+
let ctx = void 0;
|
|
54306
|
+
const status = new ParseStatus();
|
|
54307
|
+
for (const check3 of this._def.checks) {
|
|
54308
|
+
if (check3.kind === "int") {
|
|
54309
|
+
if (!util.isInteger(input2.data)) {
|
|
54310
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54311
|
+
addIssueToContext(ctx, {
|
|
54312
|
+
code: ZodIssueCode2.invalid_type,
|
|
54313
|
+
expected: "integer",
|
|
54314
|
+
received: "float",
|
|
54315
|
+
message: check3.message
|
|
54316
|
+
});
|
|
54317
|
+
status.dirty();
|
|
54318
|
+
}
|
|
54319
|
+
} else if (check3.kind === "min") {
|
|
54320
|
+
const tooSmall = check3.inclusive ? input2.data < check3.value : input2.data <= check3.value;
|
|
54321
|
+
if (tooSmall) {
|
|
54322
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54323
|
+
addIssueToContext(ctx, {
|
|
54324
|
+
code: ZodIssueCode2.too_small,
|
|
54325
|
+
minimum: check3.value,
|
|
54326
|
+
type: "number",
|
|
54327
|
+
inclusive: check3.inclusive,
|
|
54328
|
+
exact: false,
|
|
54329
|
+
message: check3.message
|
|
54330
|
+
});
|
|
54331
|
+
status.dirty();
|
|
54332
|
+
}
|
|
54333
|
+
} else if (check3.kind === "max") {
|
|
54334
|
+
const tooBig = check3.inclusive ? input2.data > check3.value : input2.data >= check3.value;
|
|
54335
|
+
if (tooBig) {
|
|
54336
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54337
|
+
addIssueToContext(ctx, {
|
|
54338
|
+
code: ZodIssueCode2.too_big,
|
|
54339
|
+
maximum: check3.value,
|
|
54340
|
+
type: "number",
|
|
54341
|
+
inclusive: check3.inclusive,
|
|
54342
|
+
exact: false,
|
|
54343
|
+
message: check3.message
|
|
54344
|
+
});
|
|
54345
|
+
status.dirty();
|
|
54346
|
+
}
|
|
54347
|
+
} else if (check3.kind === "multipleOf") {
|
|
54348
|
+
if (floatSafeRemainder2(input2.data, check3.value) !== 0) {
|
|
54349
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54350
|
+
addIssueToContext(ctx, {
|
|
54351
|
+
code: ZodIssueCode2.not_multiple_of,
|
|
54352
|
+
multipleOf: check3.value,
|
|
54353
|
+
message: check3.message
|
|
54354
|
+
});
|
|
54355
|
+
status.dirty();
|
|
54356
|
+
}
|
|
54357
|
+
} else if (check3.kind === "finite") {
|
|
54358
|
+
if (!Number.isFinite(input2.data)) {
|
|
54359
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54360
|
+
addIssueToContext(ctx, {
|
|
54361
|
+
code: ZodIssueCode2.not_finite,
|
|
54362
|
+
message: check3.message
|
|
54363
|
+
});
|
|
54364
|
+
status.dirty();
|
|
54365
|
+
}
|
|
54366
|
+
} else {
|
|
54367
|
+
util.assertNever(check3);
|
|
54368
|
+
}
|
|
54369
|
+
}
|
|
54370
|
+
return { status: status.value, value: input2.data };
|
|
54371
|
+
}
|
|
54372
|
+
gte(value, message) {
|
|
54373
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
54374
|
+
}
|
|
54375
|
+
gt(value, message) {
|
|
54376
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
54377
|
+
}
|
|
54378
|
+
lte(value, message) {
|
|
54379
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
54380
|
+
}
|
|
54381
|
+
lt(value, message) {
|
|
54382
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
54383
|
+
}
|
|
54384
|
+
setLimit(kind, value, inclusive, message) {
|
|
54385
|
+
return new _ZodNumber({
|
|
54386
|
+
...this._def,
|
|
54387
|
+
checks: [
|
|
54388
|
+
...this._def.checks,
|
|
54389
|
+
{
|
|
54390
|
+
kind,
|
|
54391
|
+
value,
|
|
54392
|
+
inclusive,
|
|
54393
|
+
message: errorUtil.toString(message)
|
|
54394
|
+
}
|
|
54395
|
+
]
|
|
54396
|
+
});
|
|
54397
|
+
}
|
|
54398
|
+
_addCheck(check3) {
|
|
54399
|
+
return new _ZodNumber({
|
|
54400
|
+
...this._def,
|
|
54401
|
+
checks: [...this._def.checks, check3]
|
|
54402
|
+
});
|
|
54403
|
+
}
|
|
54404
|
+
int(message) {
|
|
54405
|
+
return this._addCheck({
|
|
54406
|
+
kind: "int",
|
|
54407
|
+
message: errorUtil.toString(message)
|
|
54408
|
+
});
|
|
54409
|
+
}
|
|
54410
|
+
positive(message) {
|
|
54411
|
+
return this._addCheck({
|
|
54412
|
+
kind: "min",
|
|
54413
|
+
value: 0,
|
|
54414
|
+
inclusive: false,
|
|
54415
|
+
message: errorUtil.toString(message)
|
|
54416
|
+
});
|
|
54417
|
+
}
|
|
54418
|
+
negative(message) {
|
|
54419
|
+
return this._addCheck({
|
|
54420
|
+
kind: "max",
|
|
54421
|
+
value: 0,
|
|
54422
|
+
inclusive: false,
|
|
54423
|
+
message: errorUtil.toString(message)
|
|
54424
|
+
});
|
|
54425
|
+
}
|
|
54426
|
+
nonpositive(message) {
|
|
54427
|
+
return this._addCheck({
|
|
54428
|
+
kind: "max",
|
|
54429
|
+
value: 0,
|
|
54430
|
+
inclusive: true,
|
|
54431
|
+
message: errorUtil.toString(message)
|
|
54432
|
+
});
|
|
54433
|
+
}
|
|
54434
|
+
nonnegative(message) {
|
|
54435
|
+
return this._addCheck({
|
|
54436
|
+
kind: "min",
|
|
54437
|
+
value: 0,
|
|
54438
|
+
inclusive: true,
|
|
54439
|
+
message: errorUtil.toString(message)
|
|
54440
|
+
});
|
|
54441
|
+
}
|
|
54442
|
+
multipleOf(value, message) {
|
|
54443
|
+
return this._addCheck({
|
|
54444
|
+
kind: "multipleOf",
|
|
54445
|
+
value,
|
|
54446
|
+
message: errorUtil.toString(message)
|
|
54447
|
+
});
|
|
54448
|
+
}
|
|
54449
|
+
finite(message) {
|
|
54450
|
+
return this._addCheck({
|
|
54451
|
+
kind: "finite",
|
|
54452
|
+
message: errorUtil.toString(message)
|
|
54453
|
+
});
|
|
54454
|
+
}
|
|
54455
|
+
safe(message) {
|
|
54456
|
+
return this._addCheck({
|
|
54457
|
+
kind: "min",
|
|
54458
|
+
inclusive: true,
|
|
54459
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
54460
|
+
message: errorUtil.toString(message)
|
|
54461
|
+
})._addCheck({
|
|
54462
|
+
kind: "max",
|
|
54463
|
+
inclusive: true,
|
|
54464
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
54465
|
+
message: errorUtil.toString(message)
|
|
54466
|
+
});
|
|
54467
|
+
}
|
|
54468
|
+
get minValue() {
|
|
54469
|
+
let min = null;
|
|
54470
|
+
for (const ch of this._def.checks) {
|
|
54471
|
+
if (ch.kind === "min") {
|
|
54472
|
+
if (min === null || ch.value > min)
|
|
54473
|
+
min = ch.value;
|
|
54474
|
+
}
|
|
54475
|
+
}
|
|
54476
|
+
return min;
|
|
54477
|
+
}
|
|
54478
|
+
get maxValue() {
|
|
54479
|
+
let max = null;
|
|
54480
|
+
for (const ch of this._def.checks) {
|
|
54481
|
+
if (ch.kind === "max") {
|
|
54482
|
+
if (max === null || ch.value < max)
|
|
54483
|
+
max = ch.value;
|
|
54484
|
+
}
|
|
54485
|
+
}
|
|
54486
|
+
return max;
|
|
54487
|
+
}
|
|
54488
|
+
get isInt() {
|
|
54489
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
54490
|
+
}
|
|
54491
|
+
get isFinite() {
|
|
54492
|
+
let max = null;
|
|
54493
|
+
let min = null;
|
|
54494
|
+
for (const ch of this._def.checks) {
|
|
54495
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
54496
|
+
return true;
|
|
54497
|
+
} else if (ch.kind === "min") {
|
|
54498
|
+
if (min === null || ch.value > min)
|
|
54499
|
+
min = ch.value;
|
|
54500
|
+
} else if (ch.kind === "max") {
|
|
54501
|
+
if (max === null || ch.value < max)
|
|
54502
|
+
max = ch.value;
|
|
54503
|
+
}
|
|
54504
|
+
}
|
|
54505
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
|
54506
|
+
}
|
|
54507
|
+
};
|
|
54508
|
+
ZodNumber2.create = (params) => {
|
|
54509
|
+
return new ZodNumber2({
|
|
54510
|
+
checks: [],
|
|
54511
|
+
typeName: ZodFirstPartyTypeKind2.ZodNumber,
|
|
54512
|
+
coerce: params?.coerce || false,
|
|
54513
|
+
...processCreateParams(params)
|
|
54514
|
+
});
|
|
54515
|
+
};
|
|
54516
|
+
var ZodBigInt2 = class _ZodBigInt extends ZodType2 {
|
|
54517
|
+
constructor() {
|
|
54518
|
+
super(...arguments);
|
|
54519
|
+
this.min = this.gte;
|
|
54520
|
+
this.max = this.lte;
|
|
54521
|
+
}
|
|
54522
|
+
_parse(input2) {
|
|
54523
|
+
if (this._def.coerce) {
|
|
54524
|
+
try {
|
|
54525
|
+
input2.data = BigInt(input2.data);
|
|
54526
|
+
} catch {
|
|
54527
|
+
return this._getInvalidInput(input2);
|
|
54528
|
+
}
|
|
54529
|
+
}
|
|
54530
|
+
const parsedType2 = this._getType(input2);
|
|
54531
|
+
if (parsedType2 !== ZodParsedType.bigint) {
|
|
54532
|
+
return this._getInvalidInput(input2);
|
|
54533
|
+
}
|
|
54534
|
+
let ctx = void 0;
|
|
54535
|
+
const status = new ParseStatus();
|
|
54536
|
+
for (const check3 of this._def.checks) {
|
|
54537
|
+
if (check3.kind === "min") {
|
|
54538
|
+
const tooSmall = check3.inclusive ? input2.data < check3.value : input2.data <= check3.value;
|
|
54539
|
+
if (tooSmall) {
|
|
54540
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54541
|
+
addIssueToContext(ctx, {
|
|
54542
|
+
code: ZodIssueCode2.too_small,
|
|
54543
|
+
type: "bigint",
|
|
54544
|
+
minimum: check3.value,
|
|
54545
|
+
inclusive: check3.inclusive,
|
|
54546
|
+
message: check3.message
|
|
54547
|
+
});
|
|
54548
|
+
status.dirty();
|
|
54549
|
+
}
|
|
54550
|
+
} else if (check3.kind === "max") {
|
|
54551
|
+
const tooBig = check3.inclusive ? input2.data > check3.value : input2.data >= check3.value;
|
|
54552
|
+
if (tooBig) {
|
|
54553
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54554
|
+
addIssueToContext(ctx, {
|
|
54555
|
+
code: ZodIssueCode2.too_big,
|
|
54556
|
+
type: "bigint",
|
|
54557
|
+
maximum: check3.value,
|
|
54558
|
+
inclusive: check3.inclusive,
|
|
54559
|
+
message: check3.message
|
|
54560
|
+
});
|
|
54561
|
+
status.dirty();
|
|
54562
|
+
}
|
|
54563
|
+
} else if (check3.kind === "multipleOf") {
|
|
54564
|
+
if (input2.data % check3.value !== BigInt(0)) {
|
|
54565
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54566
|
+
addIssueToContext(ctx, {
|
|
54567
|
+
code: ZodIssueCode2.not_multiple_of,
|
|
54568
|
+
multipleOf: check3.value,
|
|
54569
|
+
message: check3.message
|
|
54570
|
+
});
|
|
54571
|
+
status.dirty();
|
|
54572
|
+
}
|
|
54573
|
+
} else {
|
|
54574
|
+
util.assertNever(check3);
|
|
54575
|
+
}
|
|
54576
|
+
}
|
|
54577
|
+
return { status: status.value, value: input2.data };
|
|
54578
|
+
}
|
|
54579
|
+
_getInvalidInput(input2) {
|
|
54580
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
54581
|
+
addIssueToContext(ctx, {
|
|
54582
|
+
code: ZodIssueCode2.invalid_type,
|
|
54583
|
+
expected: ZodParsedType.bigint,
|
|
54584
|
+
received: ctx.parsedType
|
|
54585
|
+
});
|
|
54586
|
+
return INVALID2;
|
|
54587
|
+
}
|
|
54588
|
+
gte(value, message) {
|
|
54589
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
54590
|
+
}
|
|
54591
|
+
gt(value, message) {
|
|
54592
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
54593
|
+
}
|
|
54594
|
+
lte(value, message) {
|
|
54595
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
54596
|
+
}
|
|
54597
|
+
lt(value, message) {
|
|
54598
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
54599
|
+
}
|
|
54600
|
+
setLimit(kind, value, inclusive, message) {
|
|
54601
|
+
return new _ZodBigInt({
|
|
54602
|
+
...this._def,
|
|
54603
|
+
checks: [
|
|
54604
|
+
...this._def.checks,
|
|
54605
|
+
{
|
|
54606
|
+
kind,
|
|
54607
|
+
value,
|
|
54608
|
+
inclusive,
|
|
54609
|
+
message: errorUtil.toString(message)
|
|
54610
|
+
}
|
|
54611
|
+
]
|
|
54612
|
+
});
|
|
54613
|
+
}
|
|
54614
|
+
_addCheck(check3) {
|
|
54615
|
+
return new _ZodBigInt({
|
|
54616
|
+
...this._def,
|
|
54617
|
+
checks: [...this._def.checks, check3]
|
|
54618
|
+
});
|
|
54619
|
+
}
|
|
54620
|
+
positive(message) {
|
|
54621
|
+
return this._addCheck({
|
|
54622
|
+
kind: "min",
|
|
54623
|
+
value: BigInt(0),
|
|
54624
|
+
inclusive: false,
|
|
54625
|
+
message: errorUtil.toString(message)
|
|
54626
|
+
});
|
|
54627
|
+
}
|
|
54628
|
+
negative(message) {
|
|
54629
|
+
return this._addCheck({
|
|
54630
|
+
kind: "max",
|
|
54631
|
+
value: BigInt(0),
|
|
54632
|
+
inclusive: false,
|
|
54633
|
+
message: errorUtil.toString(message)
|
|
54634
|
+
});
|
|
54635
|
+
}
|
|
54636
|
+
nonpositive(message) {
|
|
54637
|
+
return this._addCheck({
|
|
54638
|
+
kind: "max",
|
|
54639
|
+
value: BigInt(0),
|
|
54640
|
+
inclusive: true,
|
|
54641
|
+
message: errorUtil.toString(message)
|
|
54642
|
+
});
|
|
54643
|
+
}
|
|
54644
|
+
nonnegative(message) {
|
|
54645
|
+
return this._addCheck({
|
|
54646
|
+
kind: "min",
|
|
54647
|
+
value: BigInt(0),
|
|
54648
|
+
inclusive: true,
|
|
54649
|
+
message: errorUtil.toString(message)
|
|
54650
|
+
});
|
|
54651
|
+
}
|
|
54652
|
+
multipleOf(value, message) {
|
|
54653
|
+
return this._addCheck({
|
|
54654
|
+
kind: "multipleOf",
|
|
54655
|
+
value,
|
|
54656
|
+
message: errorUtil.toString(message)
|
|
54657
|
+
});
|
|
54658
|
+
}
|
|
54659
|
+
get minValue() {
|
|
54660
|
+
let min = null;
|
|
54661
|
+
for (const ch of this._def.checks) {
|
|
54662
|
+
if (ch.kind === "min") {
|
|
54663
|
+
if (min === null || ch.value > min)
|
|
54664
|
+
min = ch.value;
|
|
54665
|
+
}
|
|
54666
|
+
}
|
|
54667
|
+
return min;
|
|
54668
|
+
}
|
|
54669
|
+
get maxValue() {
|
|
54670
|
+
let max = null;
|
|
54671
|
+
for (const ch of this._def.checks) {
|
|
54672
|
+
if (ch.kind === "max") {
|
|
54673
|
+
if (max === null || ch.value < max)
|
|
54674
|
+
max = ch.value;
|
|
54675
|
+
}
|
|
54676
|
+
}
|
|
54677
|
+
return max;
|
|
54678
|
+
}
|
|
54679
|
+
};
|
|
54680
|
+
ZodBigInt2.create = (params) => {
|
|
54681
|
+
return new ZodBigInt2({
|
|
54682
|
+
checks: [],
|
|
54683
|
+
typeName: ZodFirstPartyTypeKind2.ZodBigInt,
|
|
54684
|
+
coerce: params?.coerce ?? false,
|
|
54685
|
+
...processCreateParams(params)
|
|
54686
|
+
});
|
|
54687
|
+
};
|
|
54688
|
+
var ZodBoolean2 = class extends ZodType2 {
|
|
54689
|
+
_parse(input2) {
|
|
54690
|
+
if (this._def.coerce) {
|
|
54691
|
+
input2.data = Boolean(input2.data);
|
|
54692
|
+
}
|
|
54693
|
+
const parsedType2 = this._getType(input2);
|
|
54694
|
+
if (parsedType2 !== ZodParsedType.boolean) {
|
|
54695
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
54696
|
+
addIssueToContext(ctx, {
|
|
54697
|
+
code: ZodIssueCode2.invalid_type,
|
|
54698
|
+
expected: ZodParsedType.boolean,
|
|
54699
|
+
received: ctx.parsedType
|
|
54700
|
+
});
|
|
54701
|
+
return INVALID2;
|
|
54702
|
+
}
|
|
54703
|
+
return OK(input2.data);
|
|
54704
|
+
}
|
|
54705
|
+
};
|
|
54706
|
+
ZodBoolean2.create = (params) => {
|
|
54707
|
+
return new ZodBoolean2({
|
|
54708
|
+
typeName: ZodFirstPartyTypeKind2.ZodBoolean,
|
|
54709
|
+
coerce: params?.coerce || false,
|
|
54710
|
+
...processCreateParams(params)
|
|
54711
|
+
});
|
|
54712
|
+
};
|
|
54713
|
+
var ZodDate2 = class _ZodDate extends ZodType2 {
|
|
54714
|
+
_parse(input2) {
|
|
54715
|
+
if (this._def.coerce) {
|
|
54716
|
+
input2.data = new Date(input2.data);
|
|
54717
|
+
}
|
|
54718
|
+
const parsedType2 = this._getType(input2);
|
|
54719
|
+
if (parsedType2 !== ZodParsedType.date) {
|
|
54720
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
54721
|
+
addIssueToContext(ctx2, {
|
|
54722
|
+
code: ZodIssueCode2.invalid_type,
|
|
54723
|
+
expected: ZodParsedType.date,
|
|
54724
|
+
received: ctx2.parsedType
|
|
54725
|
+
});
|
|
54726
|
+
return INVALID2;
|
|
54727
|
+
}
|
|
54728
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
54729
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
54730
|
+
addIssueToContext(ctx2, {
|
|
54731
|
+
code: ZodIssueCode2.invalid_date
|
|
54732
|
+
});
|
|
54733
|
+
return INVALID2;
|
|
54734
|
+
}
|
|
54735
|
+
const status = new ParseStatus();
|
|
54736
|
+
let ctx = void 0;
|
|
54737
|
+
for (const check3 of this._def.checks) {
|
|
54738
|
+
if (check3.kind === "min") {
|
|
54739
|
+
if (input2.data.getTime() < check3.value) {
|
|
54740
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54741
|
+
addIssueToContext(ctx, {
|
|
54742
|
+
code: ZodIssueCode2.too_small,
|
|
54743
|
+
message: check3.message,
|
|
54744
|
+
inclusive: true,
|
|
54745
|
+
exact: false,
|
|
54746
|
+
minimum: check3.value,
|
|
54747
|
+
type: "date"
|
|
54748
|
+
});
|
|
54749
|
+
status.dirty();
|
|
54750
|
+
}
|
|
54751
|
+
} else if (check3.kind === "max") {
|
|
54752
|
+
if (input2.data.getTime() > check3.value) {
|
|
54753
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
54754
|
+
addIssueToContext(ctx, {
|
|
54755
|
+
code: ZodIssueCode2.too_big,
|
|
54756
|
+
message: check3.message,
|
|
54757
|
+
inclusive: true,
|
|
54758
|
+
exact: false,
|
|
54759
|
+
maximum: check3.value,
|
|
54760
|
+
type: "date"
|
|
54761
|
+
});
|
|
54762
|
+
status.dirty();
|
|
54763
|
+
}
|
|
54764
|
+
} else {
|
|
54765
|
+
util.assertNever(check3);
|
|
54766
|
+
}
|
|
54767
|
+
}
|
|
54768
|
+
return {
|
|
54769
|
+
status: status.value,
|
|
54770
|
+
value: new Date(input2.data.getTime())
|
|
54771
|
+
};
|
|
54772
|
+
}
|
|
54773
|
+
_addCheck(check3) {
|
|
54774
|
+
return new _ZodDate({
|
|
54775
|
+
...this._def,
|
|
54776
|
+
checks: [...this._def.checks, check3]
|
|
54777
|
+
});
|
|
54778
|
+
}
|
|
54779
|
+
min(minDate, message) {
|
|
54780
|
+
return this._addCheck({
|
|
54781
|
+
kind: "min",
|
|
54782
|
+
value: minDate.getTime(),
|
|
54783
|
+
message: errorUtil.toString(message)
|
|
54784
|
+
});
|
|
54785
|
+
}
|
|
54786
|
+
max(maxDate, message) {
|
|
54787
|
+
return this._addCheck({
|
|
54788
|
+
kind: "max",
|
|
54789
|
+
value: maxDate.getTime(),
|
|
54790
|
+
message: errorUtil.toString(message)
|
|
54791
|
+
});
|
|
54792
|
+
}
|
|
54793
|
+
get minDate() {
|
|
54794
|
+
let min = null;
|
|
54795
|
+
for (const ch of this._def.checks) {
|
|
54796
|
+
if (ch.kind === "min") {
|
|
54797
|
+
if (min === null || ch.value > min)
|
|
54798
|
+
min = ch.value;
|
|
54799
|
+
}
|
|
54800
|
+
}
|
|
54801
|
+
return min != null ? new Date(min) : null;
|
|
54802
|
+
}
|
|
54803
|
+
get maxDate() {
|
|
54804
|
+
let max = null;
|
|
54805
|
+
for (const ch of this._def.checks) {
|
|
54806
|
+
if (ch.kind === "max") {
|
|
54807
|
+
if (max === null || ch.value < max)
|
|
54808
|
+
max = ch.value;
|
|
54809
|
+
}
|
|
54810
|
+
}
|
|
54811
|
+
return max != null ? new Date(max) : null;
|
|
54812
|
+
}
|
|
54813
|
+
};
|
|
54814
|
+
ZodDate2.create = (params) => {
|
|
54815
|
+
return new ZodDate2({
|
|
54816
|
+
checks: [],
|
|
54817
|
+
coerce: params?.coerce || false,
|
|
54818
|
+
typeName: ZodFirstPartyTypeKind2.ZodDate,
|
|
54819
|
+
...processCreateParams(params)
|
|
54820
|
+
});
|
|
54821
|
+
};
|
|
54822
|
+
var ZodSymbol2 = class extends ZodType2 {
|
|
54823
|
+
_parse(input2) {
|
|
54824
|
+
const parsedType2 = this._getType(input2);
|
|
54825
|
+
if (parsedType2 !== ZodParsedType.symbol) {
|
|
54826
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
54827
|
+
addIssueToContext(ctx, {
|
|
54828
|
+
code: ZodIssueCode2.invalid_type,
|
|
54829
|
+
expected: ZodParsedType.symbol,
|
|
54830
|
+
received: ctx.parsedType
|
|
54831
|
+
});
|
|
54832
|
+
return INVALID2;
|
|
54833
|
+
}
|
|
54834
|
+
return OK(input2.data);
|
|
54835
|
+
}
|
|
54836
|
+
};
|
|
54837
|
+
ZodSymbol2.create = (params) => {
|
|
54838
|
+
return new ZodSymbol2({
|
|
54839
|
+
typeName: ZodFirstPartyTypeKind2.ZodSymbol,
|
|
54840
|
+
...processCreateParams(params)
|
|
54841
|
+
});
|
|
54842
|
+
};
|
|
54843
|
+
var ZodUndefined2 = class extends ZodType2 {
|
|
54844
|
+
_parse(input2) {
|
|
54845
|
+
const parsedType2 = this._getType(input2);
|
|
54846
|
+
if (parsedType2 !== ZodParsedType.undefined) {
|
|
54847
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
54848
|
+
addIssueToContext(ctx, {
|
|
54849
|
+
code: ZodIssueCode2.invalid_type,
|
|
54850
|
+
expected: ZodParsedType.undefined,
|
|
54851
|
+
received: ctx.parsedType
|
|
54852
|
+
});
|
|
54853
|
+
return INVALID2;
|
|
54854
|
+
}
|
|
54855
|
+
return OK(input2.data);
|
|
54856
|
+
}
|
|
54857
|
+
};
|
|
54858
|
+
ZodUndefined2.create = (params) => {
|
|
54859
|
+
return new ZodUndefined2({
|
|
54860
|
+
typeName: ZodFirstPartyTypeKind2.ZodUndefined,
|
|
54861
|
+
...processCreateParams(params)
|
|
54862
|
+
});
|
|
54863
|
+
};
|
|
54864
|
+
var ZodNull2 = class extends ZodType2 {
|
|
54865
|
+
_parse(input2) {
|
|
54866
|
+
const parsedType2 = this._getType(input2);
|
|
54867
|
+
if (parsedType2 !== ZodParsedType.null) {
|
|
54868
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
54869
|
+
addIssueToContext(ctx, {
|
|
54870
|
+
code: ZodIssueCode2.invalid_type,
|
|
54871
|
+
expected: ZodParsedType.null,
|
|
54872
|
+
received: ctx.parsedType
|
|
54873
|
+
});
|
|
54874
|
+
return INVALID2;
|
|
54875
|
+
}
|
|
54876
|
+
return OK(input2.data);
|
|
54877
|
+
}
|
|
54878
|
+
};
|
|
54879
|
+
ZodNull2.create = (params) => {
|
|
54880
|
+
return new ZodNull2({
|
|
54881
|
+
typeName: ZodFirstPartyTypeKind2.ZodNull,
|
|
54882
|
+
...processCreateParams(params)
|
|
54883
|
+
});
|
|
54884
|
+
};
|
|
54885
|
+
var ZodAny2 = class extends ZodType2 {
|
|
54886
|
+
constructor() {
|
|
54887
|
+
super(...arguments);
|
|
54888
|
+
this._any = true;
|
|
54889
|
+
}
|
|
54890
|
+
_parse(input2) {
|
|
54891
|
+
return OK(input2.data);
|
|
54892
|
+
}
|
|
54893
|
+
};
|
|
54894
|
+
ZodAny2.create = (params) => {
|
|
54895
|
+
return new ZodAny2({
|
|
54896
|
+
typeName: ZodFirstPartyTypeKind2.ZodAny,
|
|
54897
|
+
...processCreateParams(params)
|
|
54898
|
+
});
|
|
54899
|
+
};
|
|
54900
|
+
var ZodUnknown2 = class extends ZodType2 {
|
|
54901
|
+
constructor() {
|
|
54902
|
+
super(...arguments);
|
|
54903
|
+
this._unknown = true;
|
|
54904
|
+
}
|
|
54905
|
+
_parse(input2) {
|
|
54906
|
+
return OK(input2.data);
|
|
54907
|
+
}
|
|
54908
|
+
};
|
|
54909
|
+
ZodUnknown2.create = (params) => {
|
|
54910
|
+
return new ZodUnknown2({
|
|
54911
|
+
typeName: ZodFirstPartyTypeKind2.ZodUnknown,
|
|
54912
|
+
...processCreateParams(params)
|
|
54913
|
+
});
|
|
54914
|
+
};
|
|
54915
|
+
var ZodNever2 = class extends ZodType2 {
|
|
54916
|
+
_parse(input2) {
|
|
54917
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
54918
|
+
addIssueToContext(ctx, {
|
|
54919
|
+
code: ZodIssueCode2.invalid_type,
|
|
54920
|
+
expected: ZodParsedType.never,
|
|
54921
|
+
received: ctx.parsedType
|
|
54922
|
+
});
|
|
54923
|
+
return INVALID2;
|
|
54924
|
+
}
|
|
54925
|
+
};
|
|
54926
|
+
ZodNever2.create = (params) => {
|
|
54927
|
+
return new ZodNever2({
|
|
54928
|
+
typeName: ZodFirstPartyTypeKind2.ZodNever,
|
|
54929
|
+
...processCreateParams(params)
|
|
54930
|
+
});
|
|
54931
|
+
};
|
|
54932
|
+
var ZodVoid2 = class extends ZodType2 {
|
|
54933
|
+
_parse(input2) {
|
|
54934
|
+
const parsedType2 = this._getType(input2);
|
|
54935
|
+
if (parsedType2 !== ZodParsedType.undefined) {
|
|
54936
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
54937
|
+
addIssueToContext(ctx, {
|
|
54938
|
+
code: ZodIssueCode2.invalid_type,
|
|
54939
|
+
expected: ZodParsedType.void,
|
|
54940
|
+
received: ctx.parsedType
|
|
54941
|
+
});
|
|
54942
|
+
return INVALID2;
|
|
54943
|
+
}
|
|
54944
|
+
return OK(input2.data);
|
|
54945
|
+
}
|
|
54946
|
+
};
|
|
54947
|
+
ZodVoid2.create = (params) => {
|
|
54948
|
+
return new ZodVoid2({
|
|
54949
|
+
typeName: ZodFirstPartyTypeKind2.ZodVoid,
|
|
54950
|
+
...processCreateParams(params)
|
|
54951
|
+
});
|
|
54952
|
+
};
|
|
54953
|
+
var ZodArray2 = class _ZodArray extends ZodType2 {
|
|
54954
|
+
_parse(input2) {
|
|
54955
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
54956
|
+
const def = this._def;
|
|
54957
|
+
if (ctx.parsedType !== ZodParsedType.array) {
|
|
54958
|
+
addIssueToContext(ctx, {
|
|
54959
|
+
code: ZodIssueCode2.invalid_type,
|
|
54960
|
+
expected: ZodParsedType.array,
|
|
54961
|
+
received: ctx.parsedType
|
|
54962
|
+
});
|
|
54963
|
+
return INVALID2;
|
|
54964
|
+
}
|
|
54965
|
+
if (def.exactLength !== null) {
|
|
54966
|
+
const tooBig = ctx.data.length > def.exactLength.value;
|
|
54967
|
+
const tooSmall = ctx.data.length < def.exactLength.value;
|
|
54968
|
+
if (tooBig || tooSmall) {
|
|
54969
|
+
addIssueToContext(ctx, {
|
|
54970
|
+
code: tooBig ? ZodIssueCode2.too_big : ZodIssueCode2.too_small,
|
|
54971
|
+
minimum: tooSmall ? def.exactLength.value : void 0,
|
|
54972
|
+
maximum: tooBig ? def.exactLength.value : void 0,
|
|
54973
|
+
type: "array",
|
|
54974
|
+
inclusive: true,
|
|
54975
|
+
exact: true,
|
|
54976
|
+
message: def.exactLength.message
|
|
54977
|
+
});
|
|
54978
|
+
status.dirty();
|
|
54979
|
+
}
|
|
54980
|
+
}
|
|
54981
|
+
if (def.minLength !== null) {
|
|
54982
|
+
if (ctx.data.length < def.minLength.value) {
|
|
54983
|
+
addIssueToContext(ctx, {
|
|
54984
|
+
code: ZodIssueCode2.too_small,
|
|
54985
|
+
minimum: def.minLength.value,
|
|
54986
|
+
type: "array",
|
|
54987
|
+
inclusive: true,
|
|
54988
|
+
exact: false,
|
|
54989
|
+
message: def.minLength.message
|
|
54990
|
+
});
|
|
54991
|
+
status.dirty();
|
|
54992
|
+
}
|
|
54993
|
+
}
|
|
54994
|
+
if (def.maxLength !== null) {
|
|
54995
|
+
if (ctx.data.length > def.maxLength.value) {
|
|
54996
|
+
addIssueToContext(ctx, {
|
|
54997
|
+
code: ZodIssueCode2.too_big,
|
|
54998
|
+
maximum: def.maxLength.value,
|
|
54999
|
+
type: "array",
|
|
55000
|
+
inclusive: true,
|
|
55001
|
+
exact: false,
|
|
55002
|
+
message: def.maxLength.message
|
|
55003
|
+
});
|
|
55004
|
+
status.dirty();
|
|
55005
|
+
}
|
|
55006
|
+
}
|
|
55007
|
+
if (ctx.common.async) {
|
|
55008
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
|
55009
|
+
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
55010
|
+
})).then((result2) => {
|
|
55011
|
+
return ParseStatus.mergeArray(status, result2);
|
|
55012
|
+
});
|
|
55013
|
+
}
|
|
55014
|
+
const result = [...ctx.data].map((item, i) => {
|
|
55015
|
+
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
55016
|
+
});
|
|
55017
|
+
return ParseStatus.mergeArray(status, result);
|
|
55018
|
+
}
|
|
55019
|
+
get element() {
|
|
55020
|
+
return this._def.type;
|
|
55021
|
+
}
|
|
55022
|
+
min(minLength, message) {
|
|
55023
|
+
return new _ZodArray({
|
|
55024
|
+
...this._def,
|
|
55025
|
+
minLength: { value: minLength, message: errorUtil.toString(message) }
|
|
55026
|
+
});
|
|
55027
|
+
}
|
|
55028
|
+
max(maxLength, message) {
|
|
55029
|
+
return new _ZodArray({
|
|
55030
|
+
...this._def,
|
|
55031
|
+
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
|
55032
|
+
});
|
|
55033
|
+
}
|
|
55034
|
+
length(len, message) {
|
|
55035
|
+
return new _ZodArray({
|
|
55036
|
+
...this._def,
|
|
55037
|
+
exactLength: { value: len, message: errorUtil.toString(message) }
|
|
55038
|
+
});
|
|
55039
|
+
}
|
|
55040
|
+
nonempty(message) {
|
|
55041
|
+
return this.min(1, message);
|
|
55042
|
+
}
|
|
55043
|
+
};
|
|
55044
|
+
ZodArray2.create = (schema2, params) => {
|
|
55045
|
+
return new ZodArray2({
|
|
55046
|
+
type: schema2,
|
|
55047
|
+
minLength: null,
|
|
55048
|
+
maxLength: null,
|
|
55049
|
+
exactLength: null,
|
|
55050
|
+
typeName: ZodFirstPartyTypeKind2.ZodArray,
|
|
55051
|
+
...processCreateParams(params)
|
|
55052
|
+
});
|
|
55053
|
+
};
|
|
55054
|
+
function deepPartialify(schema2) {
|
|
55055
|
+
if (schema2 instanceof ZodObject2) {
|
|
55056
|
+
const newShape = {};
|
|
55057
|
+
for (const key in schema2.shape) {
|
|
55058
|
+
const fieldSchema = schema2.shape[key];
|
|
55059
|
+
newShape[key] = ZodOptional2.create(deepPartialify(fieldSchema));
|
|
55060
|
+
}
|
|
55061
|
+
return new ZodObject2({
|
|
55062
|
+
...schema2._def,
|
|
55063
|
+
shape: () => newShape
|
|
55064
|
+
});
|
|
55065
|
+
} else if (schema2 instanceof ZodArray2) {
|
|
55066
|
+
return new ZodArray2({
|
|
55067
|
+
...schema2._def,
|
|
55068
|
+
type: deepPartialify(schema2.element)
|
|
55069
|
+
});
|
|
55070
|
+
} else if (schema2 instanceof ZodOptional2) {
|
|
55071
|
+
return ZodOptional2.create(deepPartialify(schema2.unwrap()));
|
|
55072
|
+
} else if (schema2 instanceof ZodNullable2) {
|
|
55073
|
+
return ZodNullable2.create(deepPartialify(schema2.unwrap()));
|
|
55074
|
+
} else if (schema2 instanceof ZodTuple2) {
|
|
55075
|
+
return ZodTuple2.create(schema2.items.map((item) => deepPartialify(item)));
|
|
55076
|
+
} else {
|
|
55077
|
+
return schema2;
|
|
55078
|
+
}
|
|
55079
|
+
}
|
|
55080
|
+
var ZodObject2 = class _ZodObject extends ZodType2 {
|
|
55081
|
+
constructor() {
|
|
55082
|
+
super(...arguments);
|
|
55083
|
+
this._cached = null;
|
|
55084
|
+
this.nonstrict = this.passthrough;
|
|
55085
|
+
this.augment = this.extend;
|
|
55086
|
+
}
|
|
55087
|
+
_getCached() {
|
|
55088
|
+
if (this._cached !== null)
|
|
55089
|
+
return this._cached;
|
|
55090
|
+
const shape = this._def.shape();
|
|
55091
|
+
const keys = util.objectKeys(shape);
|
|
55092
|
+
this._cached = { shape, keys };
|
|
55093
|
+
return this._cached;
|
|
55094
|
+
}
|
|
55095
|
+
_parse(input2) {
|
|
55096
|
+
const parsedType2 = this._getType(input2);
|
|
55097
|
+
if (parsedType2 !== ZodParsedType.object) {
|
|
55098
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
55099
|
+
addIssueToContext(ctx2, {
|
|
55100
|
+
code: ZodIssueCode2.invalid_type,
|
|
55101
|
+
expected: ZodParsedType.object,
|
|
55102
|
+
received: ctx2.parsedType
|
|
55103
|
+
});
|
|
55104
|
+
return INVALID2;
|
|
55105
|
+
}
|
|
55106
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
55107
|
+
const { shape, keys: shapeKeys } = this._getCached();
|
|
55108
|
+
const extraKeys = [];
|
|
55109
|
+
if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) {
|
|
55110
|
+
for (const key in ctx.data) {
|
|
55111
|
+
if (!shapeKeys.includes(key)) {
|
|
55112
|
+
extraKeys.push(key);
|
|
55113
|
+
}
|
|
55114
|
+
}
|
|
55115
|
+
}
|
|
55116
|
+
const pairs2 = [];
|
|
55117
|
+
for (const key of shapeKeys) {
|
|
55118
|
+
const keyValidator = shape[key];
|
|
55119
|
+
const value = ctx.data[key];
|
|
55120
|
+
pairs2.push({
|
|
55121
|
+
key: { status: "valid", value: key },
|
|
55122
|
+
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
55123
|
+
alwaysSet: key in ctx.data
|
|
55124
|
+
});
|
|
55125
|
+
}
|
|
55126
|
+
if (this._def.catchall instanceof ZodNever2) {
|
|
55127
|
+
const unknownKeys = this._def.unknownKeys;
|
|
55128
|
+
if (unknownKeys === "passthrough") {
|
|
55129
|
+
for (const key of extraKeys) {
|
|
55130
|
+
pairs2.push({
|
|
55131
|
+
key: { status: "valid", value: key },
|
|
55132
|
+
value: { status: "valid", value: ctx.data[key] }
|
|
55133
|
+
});
|
|
55134
|
+
}
|
|
55135
|
+
} else if (unknownKeys === "strict") {
|
|
55136
|
+
if (extraKeys.length > 0) {
|
|
55137
|
+
addIssueToContext(ctx, {
|
|
55138
|
+
code: ZodIssueCode2.unrecognized_keys,
|
|
55139
|
+
keys: extraKeys
|
|
55140
|
+
});
|
|
55141
|
+
status.dirty();
|
|
55142
|
+
}
|
|
55143
|
+
} else if (unknownKeys === "strip") {
|
|
55144
|
+
} else {
|
|
55145
|
+
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
55146
|
+
}
|
|
55147
|
+
} else {
|
|
55148
|
+
const catchall = this._def.catchall;
|
|
55149
|
+
for (const key of extraKeys) {
|
|
55150
|
+
const value = ctx.data[key];
|
|
55151
|
+
pairs2.push({
|
|
55152
|
+
key: { status: "valid", value: key },
|
|
55153
|
+
value: catchall._parse(
|
|
55154
|
+
new ParseInputLazyPath(ctx, value, ctx.path, key)
|
|
55155
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
55156
|
+
),
|
|
55157
|
+
alwaysSet: key in ctx.data
|
|
55158
|
+
});
|
|
55159
|
+
}
|
|
55160
|
+
}
|
|
55161
|
+
if (ctx.common.async) {
|
|
55162
|
+
return Promise.resolve().then(async () => {
|
|
55163
|
+
const syncPairs = [];
|
|
55164
|
+
for (const pair of pairs2) {
|
|
55165
|
+
const key = await pair.key;
|
|
55166
|
+
const value = await pair.value;
|
|
55167
|
+
syncPairs.push({
|
|
55168
|
+
key,
|
|
55169
|
+
value,
|
|
55170
|
+
alwaysSet: pair.alwaysSet
|
|
55171
|
+
});
|
|
55172
|
+
}
|
|
55173
|
+
return syncPairs;
|
|
55174
|
+
}).then((syncPairs) => {
|
|
55175
|
+
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
55176
|
+
});
|
|
55177
|
+
} else {
|
|
55178
|
+
return ParseStatus.mergeObjectSync(status, pairs2);
|
|
55179
|
+
}
|
|
55180
|
+
}
|
|
55181
|
+
get shape() {
|
|
55182
|
+
return this._def.shape();
|
|
55183
|
+
}
|
|
55184
|
+
strict(message) {
|
|
55185
|
+
errorUtil.errToObj;
|
|
55186
|
+
return new _ZodObject({
|
|
55187
|
+
...this._def,
|
|
55188
|
+
unknownKeys: "strict",
|
|
55189
|
+
...message !== void 0 ? {
|
|
55190
|
+
errorMap: (issue2, ctx) => {
|
|
55191
|
+
const defaultError = this._def.errorMap?.(issue2, ctx).message ?? ctx.defaultError;
|
|
55192
|
+
if (issue2.code === "unrecognized_keys")
|
|
55193
|
+
return {
|
|
55194
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
55195
|
+
};
|
|
55196
|
+
return {
|
|
55197
|
+
message: defaultError
|
|
55198
|
+
};
|
|
55199
|
+
}
|
|
55200
|
+
} : {}
|
|
55201
|
+
});
|
|
55202
|
+
}
|
|
55203
|
+
strip() {
|
|
55204
|
+
return new _ZodObject({
|
|
55205
|
+
...this._def,
|
|
55206
|
+
unknownKeys: "strip"
|
|
55207
|
+
});
|
|
55208
|
+
}
|
|
55209
|
+
passthrough() {
|
|
55210
|
+
return new _ZodObject({
|
|
55211
|
+
...this._def,
|
|
55212
|
+
unknownKeys: "passthrough"
|
|
55213
|
+
});
|
|
55214
|
+
}
|
|
55215
|
+
// const AugmentFactory =
|
|
55216
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
55217
|
+
// <Augmentation extends ZodRawShape>(
|
|
55218
|
+
// augmentation: Augmentation
|
|
55219
|
+
// ): ZodObject<
|
|
55220
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
55221
|
+
// Def["unknownKeys"],
|
|
55222
|
+
// Def["catchall"]
|
|
55223
|
+
// > => {
|
|
55224
|
+
// return new ZodObject({
|
|
55225
|
+
// ...def,
|
|
55226
|
+
// shape: () => ({
|
|
55227
|
+
// ...def.shape(),
|
|
55228
|
+
// ...augmentation,
|
|
55229
|
+
// }),
|
|
55230
|
+
// }) as any;
|
|
55231
|
+
// };
|
|
55232
|
+
extend(augmentation) {
|
|
55233
|
+
return new _ZodObject({
|
|
55234
|
+
...this._def,
|
|
55235
|
+
shape: () => ({
|
|
55236
|
+
...this._def.shape(),
|
|
55237
|
+
...augmentation
|
|
55238
|
+
})
|
|
55239
|
+
});
|
|
55240
|
+
}
|
|
55241
|
+
/**
|
|
55242
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
55243
|
+
* inferred type of merged objects. Please
|
|
55244
|
+
* upgrade if you are experiencing issues.
|
|
55245
|
+
*/
|
|
55246
|
+
merge(merging) {
|
|
55247
|
+
const merged = new _ZodObject({
|
|
55248
|
+
unknownKeys: merging._def.unknownKeys,
|
|
55249
|
+
catchall: merging._def.catchall,
|
|
55250
|
+
shape: () => ({
|
|
55251
|
+
...this._def.shape(),
|
|
55252
|
+
...merging._def.shape()
|
|
55253
|
+
}),
|
|
55254
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject
|
|
55255
|
+
});
|
|
55256
|
+
return merged;
|
|
55257
|
+
}
|
|
55258
|
+
// merge<
|
|
55259
|
+
// Incoming extends AnyZodObject,
|
|
55260
|
+
// Augmentation extends Incoming["shape"],
|
|
55261
|
+
// NewOutput extends {
|
|
55262
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
55263
|
+
// ? Augmentation[k]["_output"]
|
|
55264
|
+
// : k extends keyof Output
|
|
55265
|
+
// ? Output[k]
|
|
55266
|
+
// : never;
|
|
55267
|
+
// },
|
|
55268
|
+
// NewInput extends {
|
|
55269
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
55270
|
+
// ? Augmentation[k]["_input"]
|
|
55271
|
+
// : k extends keyof Input
|
|
55272
|
+
// ? Input[k]
|
|
55273
|
+
// : never;
|
|
55274
|
+
// }
|
|
55275
|
+
// >(
|
|
55276
|
+
// merging: Incoming
|
|
55277
|
+
// ): ZodObject<
|
|
55278
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
55279
|
+
// Incoming["_def"]["unknownKeys"],
|
|
55280
|
+
// Incoming["_def"]["catchall"],
|
|
55281
|
+
// NewOutput,
|
|
55282
|
+
// NewInput
|
|
55283
|
+
// > {
|
|
55284
|
+
// const merged: any = new ZodObject({
|
|
55285
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
55286
|
+
// catchall: merging._def.catchall,
|
|
55287
|
+
// shape: () =>
|
|
55288
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
55289
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
55290
|
+
// }) as any;
|
|
55291
|
+
// return merged;
|
|
55292
|
+
// }
|
|
55293
|
+
setKey(key, schema2) {
|
|
55294
|
+
return this.augment({ [key]: schema2 });
|
|
55295
|
+
}
|
|
55296
|
+
// merge<Incoming extends AnyZodObject>(
|
|
55297
|
+
// merging: Incoming
|
|
55298
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
55299
|
+
// ZodObject<
|
|
55300
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
55301
|
+
// Incoming["_def"]["unknownKeys"],
|
|
55302
|
+
// Incoming["_def"]["catchall"]
|
|
55303
|
+
// > {
|
|
55304
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
55305
|
+
// // this._def.shape(),
|
|
55306
|
+
// // merging._def.shape()
|
|
55307
|
+
// // );
|
|
55308
|
+
// const merged: any = new ZodObject({
|
|
55309
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
55310
|
+
// catchall: merging._def.catchall,
|
|
55311
|
+
// shape: () =>
|
|
55312
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
55313
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
55314
|
+
// }) as any;
|
|
55315
|
+
// return merged;
|
|
55316
|
+
// }
|
|
55317
|
+
catchall(index) {
|
|
55318
|
+
return new _ZodObject({
|
|
55319
|
+
...this._def,
|
|
55320
|
+
catchall: index
|
|
55321
|
+
});
|
|
55322
|
+
}
|
|
55323
|
+
pick(mask) {
|
|
55324
|
+
const shape = {};
|
|
55325
|
+
for (const key of util.objectKeys(mask)) {
|
|
55326
|
+
if (mask[key] && this.shape[key]) {
|
|
55327
|
+
shape[key] = this.shape[key];
|
|
55328
|
+
}
|
|
55329
|
+
}
|
|
55330
|
+
return new _ZodObject({
|
|
55331
|
+
...this._def,
|
|
55332
|
+
shape: () => shape
|
|
55333
|
+
});
|
|
55334
|
+
}
|
|
55335
|
+
omit(mask) {
|
|
55336
|
+
const shape = {};
|
|
55337
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
55338
|
+
if (!mask[key]) {
|
|
55339
|
+
shape[key] = this.shape[key];
|
|
55340
|
+
}
|
|
55341
|
+
}
|
|
55342
|
+
return new _ZodObject({
|
|
55343
|
+
...this._def,
|
|
55344
|
+
shape: () => shape
|
|
55345
|
+
});
|
|
55346
|
+
}
|
|
55347
|
+
/**
|
|
55348
|
+
* @deprecated
|
|
55349
|
+
*/
|
|
55350
|
+
deepPartial() {
|
|
55351
|
+
return deepPartialify(this);
|
|
55352
|
+
}
|
|
55353
|
+
partial(mask) {
|
|
55354
|
+
const newShape = {};
|
|
55355
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
55356
|
+
const fieldSchema = this.shape[key];
|
|
55357
|
+
if (mask && !mask[key]) {
|
|
55358
|
+
newShape[key] = fieldSchema;
|
|
55359
|
+
} else {
|
|
55360
|
+
newShape[key] = fieldSchema.optional();
|
|
55361
|
+
}
|
|
55362
|
+
}
|
|
55363
|
+
return new _ZodObject({
|
|
55364
|
+
...this._def,
|
|
55365
|
+
shape: () => newShape
|
|
55366
|
+
});
|
|
55367
|
+
}
|
|
55368
|
+
required(mask) {
|
|
55369
|
+
const newShape = {};
|
|
55370
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
55371
|
+
if (mask && !mask[key]) {
|
|
55372
|
+
newShape[key] = this.shape[key];
|
|
55373
|
+
} else {
|
|
55374
|
+
const fieldSchema = this.shape[key];
|
|
55375
|
+
let newField = fieldSchema;
|
|
55376
|
+
while (newField instanceof ZodOptional2) {
|
|
55377
|
+
newField = newField._def.innerType;
|
|
55378
|
+
}
|
|
55379
|
+
newShape[key] = newField;
|
|
55380
|
+
}
|
|
55381
|
+
}
|
|
55382
|
+
return new _ZodObject({
|
|
55383
|
+
...this._def,
|
|
55384
|
+
shape: () => newShape
|
|
55385
|
+
});
|
|
55386
|
+
}
|
|
55387
|
+
keyof() {
|
|
55388
|
+
return createZodEnum(util.objectKeys(this.shape));
|
|
55389
|
+
}
|
|
55390
|
+
};
|
|
55391
|
+
ZodObject2.create = (shape, params) => {
|
|
55392
|
+
return new ZodObject2({
|
|
55393
|
+
shape: () => shape,
|
|
55394
|
+
unknownKeys: "strip",
|
|
55395
|
+
catchall: ZodNever2.create(),
|
|
55396
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
55397
|
+
...processCreateParams(params)
|
|
55398
|
+
});
|
|
55399
|
+
};
|
|
55400
|
+
ZodObject2.strictCreate = (shape, params) => {
|
|
55401
|
+
return new ZodObject2({
|
|
55402
|
+
shape: () => shape,
|
|
55403
|
+
unknownKeys: "strict",
|
|
55404
|
+
catchall: ZodNever2.create(),
|
|
55405
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
55406
|
+
...processCreateParams(params)
|
|
55407
|
+
});
|
|
55408
|
+
};
|
|
55409
|
+
ZodObject2.lazycreate = (shape, params) => {
|
|
55410
|
+
return new ZodObject2({
|
|
55411
|
+
shape,
|
|
55412
|
+
unknownKeys: "strip",
|
|
55413
|
+
catchall: ZodNever2.create(),
|
|
55414
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
55415
|
+
...processCreateParams(params)
|
|
55416
|
+
});
|
|
55417
|
+
};
|
|
55418
|
+
var ZodUnion2 = class extends ZodType2 {
|
|
55419
|
+
_parse(input2) {
|
|
55420
|
+
const { ctx } = this._processInputParams(input2);
|
|
55421
|
+
const options = this._def.options;
|
|
55422
|
+
function handleResults(results) {
|
|
55423
|
+
for (const result of results) {
|
|
55424
|
+
if (result.result.status === "valid") {
|
|
55425
|
+
return result.result;
|
|
55426
|
+
}
|
|
55427
|
+
}
|
|
55428
|
+
for (const result of results) {
|
|
55429
|
+
if (result.result.status === "dirty") {
|
|
55430
|
+
ctx.common.issues.push(...result.ctx.common.issues);
|
|
55431
|
+
return result.result;
|
|
55432
|
+
}
|
|
55433
|
+
}
|
|
55434
|
+
const unionErrors = results.map((result) => new ZodError2(result.ctx.common.issues));
|
|
55435
|
+
addIssueToContext(ctx, {
|
|
55436
|
+
code: ZodIssueCode2.invalid_union,
|
|
55437
|
+
unionErrors
|
|
55438
|
+
});
|
|
55439
|
+
return INVALID2;
|
|
55440
|
+
}
|
|
55441
|
+
if (ctx.common.async) {
|
|
55442
|
+
return Promise.all(options.map(async (option) => {
|
|
55443
|
+
const childCtx = {
|
|
55444
|
+
...ctx,
|
|
55445
|
+
common: {
|
|
55446
|
+
...ctx.common,
|
|
55447
|
+
issues: []
|
|
55448
|
+
},
|
|
55449
|
+
parent: null
|
|
55450
|
+
};
|
|
55451
|
+
return {
|
|
55452
|
+
result: await option._parseAsync({
|
|
55453
|
+
data: ctx.data,
|
|
55454
|
+
path: ctx.path,
|
|
55455
|
+
parent: childCtx
|
|
55456
|
+
}),
|
|
55457
|
+
ctx: childCtx
|
|
55458
|
+
};
|
|
55459
|
+
})).then(handleResults);
|
|
55460
|
+
} else {
|
|
55461
|
+
let dirty = void 0;
|
|
55462
|
+
const issues = [];
|
|
55463
|
+
for (const option of options) {
|
|
55464
|
+
const childCtx = {
|
|
55465
|
+
...ctx,
|
|
55466
|
+
common: {
|
|
55467
|
+
...ctx.common,
|
|
55468
|
+
issues: []
|
|
55469
|
+
},
|
|
55470
|
+
parent: null
|
|
55471
|
+
};
|
|
55472
|
+
const result = option._parseSync({
|
|
55473
|
+
data: ctx.data,
|
|
55474
|
+
path: ctx.path,
|
|
55475
|
+
parent: childCtx
|
|
55476
|
+
});
|
|
55477
|
+
if (result.status === "valid") {
|
|
55478
|
+
return result;
|
|
55479
|
+
} else if (result.status === "dirty" && !dirty) {
|
|
55480
|
+
dirty = { result, ctx: childCtx };
|
|
55481
|
+
}
|
|
55482
|
+
if (childCtx.common.issues.length) {
|
|
55483
|
+
issues.push(childCtx.common.issues);
|
|
55484
|
+
}
|
|
55485
|
+
}
|
|
55486
|
+
if (dirty) {
|
|
55487
|
+
ctx.common.issues.push(...dirty.ctx.common.issues);
|
|
55488
|
+
return dirty.result;
|
|
55489
|
+
}
|
|
55490
|
+
const unionErrors = issues.map((issues2) => new ZodError2(issues2));
|
|
55491
|
+
addIssueToContext(ctx, {
|
|
55492
|
+
code: ZodIssueCode2.invalid_union,
|
|
55493
|
+
unionErrors
|
|
55494
|
+
});
|
|
55495
|
+
return INVALID2;
|
|
55496
|
+
}
|
|
55497
|
+
}
|
|
55498
|
+
get options() {
|
|
55499
|
+
return this._def.options;
|
|
55500
|
+
}
|
|
55501
|
+
};
|
|
55502
|
+
ZodUnion2.create = (types2, params) => {
|
|
55503
|
+
return new ZodUnion2({
|
|
55504
|
+
options: types2,
|
|
55505
|
+
typeName: ZodFirstPartyTypeKind2.ZodUnion,
|
|
55506
|
+
...processCreateParams(params)
|
|
55507
|
+
});
|
|
55508
|
+
};
|
|
55509
|
+
var getDiscriminator = (type2) => {
|
|
55510
|
+
if (type2 instanceof ZodLazy2) {
|
|
55511
|
+
return getDiscriminator(type2.schema);
|
|
55512
|
+
} else if (type2 instanceof ZodEffects) {
|
|
55513
|
+
return getDiscriminator(type2.innerType());
|
|
55514
|
+
} else if (type2 instanceof ZodLiteral2) {
|
|
55515
|
+
return [type2.value];
|
|
55516
|
+
} else if (type2 instanceof ZodEnum2) {
|
|
55517
|
+
return type2.options;
|
|
55518
|
+
} else if (type2 instanceof ZodNativeEnum) {
|
|
55519
|
+
return util.objectValues(type2.enum);
|
|
55520
|
+
} else if (type2 instanceof ZodDefault2) {
|
|
55521
|
+
return getDiscriminator(type2._def.innerType);
|
|
55522
|
+
} else if (type2 instanceof ZodUndefined2) {
|
|
55523
|
+
return [void 0];
|
|
55524
|
+
} else if (type2 instanceof ZodNull2) {
|
|
55525
|
+
return [null];
|
|
55526
|
+
} else if (type2 instanceof ZodOptional2) {
|
|
55527
|
+
return [void 0, ...getDiscriminator(type2.unwrap())];
|
|
55528
|
+
} else if (type2 instanceof ZodNullable2) {
|
|
55529
|
+
return [null, ...getDiscriminator(type2.unwrap())];
|
|
55530
|
+
} else if (type2 instanceof ZodBranded) {
|
|
55531
|
+
return getDiscriminator(type2.unwrap());
|
|
55532
|
+
} else if (type2 instanceof ZodReadonly2) {
|
|
55533
|
+
return getDiscriminator(type2.unwrap());
|
|
55534
|
+
} else if (type2 instanceof ZodCatch2) {
|
|
55535
|
+
return getDiscriminator(type2._def.innerType);
|
|
55536
|
+
} else {
|
|
55537
|
+
return [];
|
|
55538
|
+
}
|
|
55539
|
+
};
|
|
55540
|
+
var ZodDiscriminatedUnion2 = class _ZodDiscriminatedUnion extends ZodType2 {
|
|
55541
|
+
_parse(input2) {
|
|
55542
|
+
const { ctx } = this._processInputParams(input2);
|
|
55543
|
+
if (ctx.parsedType !== ZodParsedType.object) {
|
|
55544
|
+
addIssueToContext(ctx, {
|
|
55545
|
+
code: ZodIssueCode2.invalid_type,
|
|
55546
|
+
expected: ZodParsedType.object,
|
|
55547
|
+
received: ctx.parsedType
|
|
55548
|
+
});
|
|
55549
|
+
return INVALID2;
|
|
55550
|
+
}
|
|
55551
|
+
const discriminator = this.discriminator;
|
|
55552
|
+
const discriminatorValue = ctx.data[discriminator];
|
|
55553
|
+
const option = this.optionsMap.get(discriminatorValue);
|
|
55554
|
+
if (!option) {
|
|
55555
|
+
addIssueToContext(ctx, {
|
|
55556
|
+
code: ZodIssueCode2.invalid_union_discriminator,
|
|
55557
|
+
options: Array.from(this.optionsMap.keys()),
|
|
55558
|
+
path: [discriminator]
|
|
55559
|
+
});
|
|
55560
|
+
return INVALID2;
|
|
55561
|
+
}
|
|
55562
|
+
if (ctx.common.async) {
|
|
55563
|
+
return option._parseAsync({
|
|
55564
|
+
data: ctx.data,
|
|
55565
|
+
path: ctx.path,
|
|
55566
|
+
parent: ctx
|
|
55567
|
+
});
|
|
55568
|
+
} else {
|
|
55569
|
+
return option._parseSync({
|
|
55570
|
+
data: ctx.data,
|
|
55571
|
+
path: ctx.path,
|
|
55572
|
+
parent: ctx
|
|
55573
|
+
});
|
|
55574
|
+
}
|
|
55575
|
+
}
|
|
55576
|
+
get discriminator() {
|
|
55577
|
+
return this._def.discriminator;
|
|
55578
|
+
}
|
|
55579
|
+
get options() {
|
|
55580
|
+
return this._def.options;
|
|
55581
|
+
}
|
|
55582
|
+
get optionsMap() {
|
|
55583
|
+
return this._def.optionsMap;
|
|
55584
|
+
}
|
|
55585
|
+
/**
|
|
55586
|
+
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
55587
|
+
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
55588
|
+
* have a different value for each object in the union.
|
|
55589
|
+
* @param discriminator the name of the discriminator property
|
|
55590
|
+
* @param types an array of object schemas
|
|
55591
|
+
* @param params
|
|
55592
|
+
*/
|
|
55593
|
+
static create(discriminator, options, params) {
|
|
55594
|
+
const optionsMap = /* @__PURE__ */ new Map();
|
|
55595
|
+
for (const type2 of options) {
|
|
55596
|
+
const discriminatorValues = getDiscriminator(type2.shape[discriminator]);
|
|
55597
|
+
if (!discriminatorValues.length) {
|
|
55598
|
+
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
55599
|
+
}
|
|
55600
|
+
for (const value of discriminatorValues) {
|
|
55601
|
+
if (optionsMap.has(value)) {
|
|
55602
|
+
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
|
|
55603
|
+
}
|
|
55604
|
+
optionsMap.set(value, type2);
|
|
55605
|
+
}
|
|
55606
|
+
}
|
|
55607
|
+
return new _ZodDiscriminatedUnion({
|
|
55608
|
+
typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion,
|
|
55609
|
+
discriminator,
|
|
55610
|
+
options,
|
|
55611
|
+
optionsMap,
|
|
55612
|
+
...processCreateParams(params)
|
|
55613
|
+
});
|
|
55614
|
+
}
|
|
55615
|
+
};
|
|
55616
|
+
function mergeValues2(a, b) {
|
|
55617
|
+
const aType = getParsedType2(a);
|
|
55618
|
+
const bType = getParsedType2(b);
|
|
55619
|
+
if (a === b) {
|
|
55620
|
+
return { valid: true, data: a };
|
|
55621
|
+
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
55622
|
+
const bKeys = util.objectKeys(b);
|
|
55623
|
+
const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
55624
|
+
const newObj = { ...a, ...b };
|
|
55625
|
+
for (const key of sharedKeys) {
|
|
55626
|
+
const sharedValue = mergeValues2(a[key], b[key]);
|
|
55627
|
+
if (!sharedValue.valid) {
|
|
55628
|
+
return { valid: false };
|
|
55629
|
+
}
|
|
55630
|
+
newObj[key] = sharedValue.data;
|
|
55631
|
+
}
|
|
55632
|
+
return { valid: true, data: newObj };
|
|
55633
|
+
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
55634
|
+
if (a.length !== b.length) {
|
|
55635
|
+
return { valid: false };
|
|
55636
|
+
}
|
|
55637
|
+
const newArray = [];
|
|
55638
|
+
for (let index = 0; index < a.length; index++) {
|
|
55639
|
+
const itemA = a[index];
|
|
55640
|
+
const itemB = b[index];
|
|
55641
|
+
const sharedValue = mergeValues2(itemA, itemB);
|
|
55642
|
+
if (!sharedValue.valid) {
|
|
55643
|
+
return { valid: false };
|
|
55644
|
+
}
|
|
55645
|
+
newArray.push(sharedValue.data);
|
|
55646
|
+
}
|
|
55647
|
+
return { valid: true, data: newArray };
|
|
55648
|
+
} else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
|
|
55649
|
+
return { valid: true, data: a };
|
|
55650
|
+
} else {
|
|
55651
|
+
return { valid: false };
|
|
55652
|
+
}
|
|
55653
|
+
}
|
|
55654
|
+
var ZodIntersection2 = class extends ZodType2 {
|
|
55655
|
+
_parse(input2) {
|
|
55656
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
55657
|
+
const handleParsed = (parsedLeft, parsedRight) => {
|
|
55658
|
+
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
55659
|
+
return INVALID2;
|
|
55660
|
+
}
|
|
55661
|
+
const merged = mergeValues2(parsedLeft.value, parsedRight.value);
|
|
55662
|
+
if (!merged.valid) {
|
|
55663
|
+
addIssueToContext(ctx, {
|
|
55664
|
+
code: ZodIssueCode2.invalid_intersection_types
|
|
55665
|
+
});
|
|
55666
|
+
return INVALID2;
|
|
55667
|
+
}
|
|
55668
|
+
if (isDirty(parsedLeft) || isDirty(parsedRight)) {
|
|
55669
|
+
status.dirty();
|
|
55670
|
+
}
|
|
55671
|
+
return { status: status.value, value: merged.data };
|
|
55672
|
+
};
|
|
55673
|
+
if (ctx.common.async) {
|
|
55674
|
+
return Promise.all([
|
|
55675
|
+
this._def.left._parseAsync({
|
|
55676
|
+
data: ctx.data,
|
|
55677
|
+
path: ctx.path,
|
|
55678
|
+
parent: ctx
|
|
55679
|
+
}),
|
|
55680
|
+
this._def.right._parseAsync({
|
|
55681
|
+
data: ctx.data,
|
|
55682
|
+
path: ctx.path,
|
|
55683
|
+
parent: ctx
|
|
55684
|
+
})
|
|
55685
|
+
]).then(([left, right]) => handleParsed(left, right));
|
|
55686
|
+
} else {
|
|
55687
|
+
return handleParsed(this._def.left._parseSync({
|
|
55688
|
+
data: ctx.data,
|
|
55689
|
+
path: ctx.path,
|
|
55690
|
+
parent: ctx
|
|
55691
|
+
}), this._def.right._parseSync({
|
|
55692
|
+
data: ctx.data,
|
|
55693
|
+
path: ctx.path,
|
|
55694
|
+
parent: ctx
|
|
55695
|
+
}));
|
|
55696
|
+
}
|
|
55697
|
+
}
|
|
55698
|
+
};
|
|
55699
|
+
ZodIntersection2.create = (left, right, params) => {
|
|
55700
|
+
return new ZodIntersection2({
|
|
55701
|
+
left,
|
|
55702
|
+
right,
|
|
55703
|
+
typeName: ZodFirstPartyTypeKind2.ZodIntersection,
|
|
55704
|
+
...processCreateParams(params)
|
|
55705
|
+
});
|
|
55706
|
+
};
|
|
55707
|
+
var ZodTuple2 = class _ZodTuple extends ZodType2 {
|
|
55708
|
+
_parse(input2) {
|
|
55709
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
55710
|
+
if (ctx.parsedType !== ZodParsedType.array) {
|
|
55711
|
+
addIssueToContext(ctx, {
|
|
55712
|
+
code: ZodIssueCode2.invalid_type,
|
|
55713
|
+
expected: ZodParsedType.array,
|
|
55714
|
+
received: ctx.parsedType
|
|
55715
|
+
});
|
|
55716
|
+
return INVALID2;
|
|
55717
|
+
}
|
|
55718
|
+
if (ctx.data.length < this._def.items.length) {
|
|
55719
|
+
addIssueToContext(ctx, {
|
|
55720
|
+
code: ZodIssueCode2.too_small,
|
|
55721
|
+
minimum: this._def.items.length,
|
|
55722
|
+
inclusive: true,
|
|
55723
|
+
exact: false,
|
|
55724
|
+
type: "array"
|
|
55725
|
+
});
|
|
55726
|
+
return INVALID2;
|
|
55727
|
+
}
|
|
55728
|
+
const rest = this._def.rest;
|
|
55729
|
+
if (!rest && ctx.data.length > this._def.items.length) {
|
|
55730
|
+
addIssueToContext(ctx, {
|
|
55731
|
+
code: ZodIssueCode2.too_big,
|
|
55732
|
+
maximum: this._def.items.length,
|
|
55733
|
+
inclusive: true,
|
|
55734
|
+
exact: false,
|
|
55735
|
+
type: "array"
|
|
55736
|
+
});
|
|
55737
|
+
status.dirty();
|
|
55738
|
+
}
|
|
55739
|
+
const items = [...ctx.data].map((item, itemIndex) => {
|
|
55740
|
+
const schema2 = this._def.items[itemIndex] || this._def.rest;
|
|
55741
|
+
if (!schema2)
|
|
55742
|
+
return null;
|
|
55743
|
+
return schema2._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
|
55744
|
+
}).filter((x) => !!x);
|
|
55745
|
+
if (ctx.common.async) {
|
|
55746
|
+
return Promise.all(items).then((results) => {
|
|
55747
|
+
return ParseStatus.mergeArray(status, results);
|
|
55748
|
+
});
|
|
55749
|
+
} else {
|
|
55750
|
+
return ParseStatus.mergeArray(status, items);
|
|
55751
|
+
}
|
|
55752
|
+
}
|
|
55753
|
+
get items() {
|
|
55754
|
+
return this._def.items;
|
|
55755
|
+
}
|
|
55756
|
+
rest(rest) {
|
|
55757
|
+
return new _ZodTuple({
|
|
55758
|
+
...this._def,
|
|
55759
|
+
rest
|
|
55760
|
+
});
|
|
55761
|
+
}
|
|
55762
|
+
};
|
|
55763
|
+
ZodTuple2.create = (schemas, params) => {
|
|
55764
|
+
if (!Array.isArray(schemas)) {
|
|
55765
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
55766
|
+
}
|
|
55767
|
+
return new ZodTuple2({
|
|
55768
|
+
items: schemas,
|
|
55769
|
+
typeName: ZodFirstPartyTypeKind2.ZodTuple,
|
|
55770
|
+
rest: null,
|
|
55771
|
+
...processCreateParams(params)
|
|
55772
|
+
});
|
|
55773
|
+
};
|
|
55774
|
+
var ZodRecord2 = class _ZodRecord extends ZodType2 {
|
|
55775
|
+
get keySchema() {
|
|
55776
|
+
return this._def.keyType;
|
|
55777
|
+
}
|
|
55778
|
+
get valueSchema() {
|
|
55779
|
+
return this._def.valueType;
|
|
55780
|
+
}
|
|
55781
|
+
_parse(input2) {
|
|
55782
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
55783
|
+
if (ctx.parsedType !== ZodParsedType.object) {
|
|
55784
|
+
addIssueToContext(ctx, {
|
|
55785
|
+
code: ZodIssueCode2.invalid_type,
|
|
55786
|
+
expected: ZodParsedType.object,
|
|
55787
|
+
received: ctx.parsedType
|
|
55788
|
+
});
|
|
55789
|
+
return INVALID2;
|
|
55790
|
+
}
|
|
55791
|
+
const pairs2 = [];
|
|
55792
|
+
const keyType = this._def.keyType;
|
|
55793
|
+
const valueType = this._def.valueType;
|
|
55794
|
+
for (const key in ctx.data) {
|
|
55795
|
+
pairs2.push({
|
|
55796
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
55797
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
55798
|
+
alwaysSet: key in ctx.data
|
|
55799
|
+
});
|
|
55800
|
+
}
|
|
55801
|
+
if (ctx.common.async) {
|
|
55802
|
+
return ParseStatus.mergeObjectAsync(status, pairs2);
|
|
55803
|
+
} else {
|
|
55804
|
+
return ParseStatus.mergeObjectSync(status, pairs2);
|
|
55805
|
+
}
|
|
55806
|
+
}
|
|
55807
|
+
get element() {
|
|
55808
|
+
return this._def.valueType;
|
|
55809
|
+
}
|
|
55810
|
+
static create(first, second, third) {
|
|
55811
|
+
if (second instanceof ZodType2) {
|
|
55812
|
+
return new _ZodRecord({
|
|
55813
|
+
keyType: first,
|
|
55814
|
+
valueType: second,
|
|
55815
|
+
typeName: ZodFirstPartyTypeKind2.ZodRecord,
|
|
55816
|
+
...processCreateParams(third)
|
|
55817
|
+
});
|
|
55818
|
+
}
|
|
55819
|
+
return new _ZodRecord({
|
|
55820
|
+
keyType: ZodString2.create(),
|
|
55821
|
+
valueType: first,
|
|
55822
|
+
typeName: ZodFirstPartyTypeKind2.ZodRecord,
|
|
55823
|
+
...processCreateParams(second)
|
|
55824
|
+
});
|
|
55825
|
+
}
|
|
55826
|
+
};
|
|
55827
|
+
var ZodMap2 = class extends ZodType2 {
|
|
55828
|
+
get keySchema() {
|
|
55829
|
+
return this._def.keyType;
|
|
55830
|
+
}
|
|
55831
|
+
get valueSchema() {
|
|
55832
|
+
return this._def.valueType;
|
|
55833
|
+
}
|
|
55834
|
+
_parse(input2) {
|
|
55835
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
55836
|
+
if (ctx.parsedType !== ZodParsedType.map) {
|
|
55837
|
+
addIssueToContext(ctx, {
|
|
55838
|
+
code: ZodIssueCode2.invalid_type,
|
|
55839
|
+
expected: ZodParsedType.map,
|
|
55840
|
+
received: ctx.parsedType
|
|
55841
|
+
});
|
|
55842
|
+
return INVALID2;
|
|
55843
|
+
}
|
|
55844
|
+
const keyType = this._def.keyType;
|
|
55845
|
+
const valueType = this._def.valueType;
|
|
55846
|
+
const pairs2 = [...ctx.data.entries()].map(([key, value], index) => {
|
|
55847
|
+
return {
|
|
55848
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
|
|
55849
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
|
|
55850
|
+
};
|
|
55851
|
+
});
|
|
55852
|
+
if (ctx.common.async) {
|
|
55853
|
+
const finalMap = /* @__PURE__ */ new Map();
|
|
55854
|
+
return Promise.resolve().then(async () => {
|
|
55855
|
+
for (const pair of pairs2) {
|
|
55856
|
+
const key = await pair.key;
|
|
55857
|
+
const value = await pair.value;
|
|
55858
|
+
if (key.status === "aborted" || value.status === "aborted") {
|
|
55859
|
+
return INVALID2;
|
|
55860
|
+
}
|
|
55861
|
+
if (key.status === "dirty" || value.status === "dirty") {
|
|
55862
|
+
status.dirty();
|
|
55863
|
+
}
|
|
55864
|
+
finalMap.set(key.value, value.value);
|
|
55865
|
+
}
|
|
55866
|
+
return { status: status.value, value: finalMap };
|
|
55867
|
+
});
|
|
55868
|
+
} else {
|
|
55869
|
+
const finalMap = /* @__PURE__ */ new Map();
|
|
55870
|
+
for (const pair of pairs2) {
|
|
55871
|
+
const key = pair.key;
|
|
55872
|
+
const value = pair.value;
|
|
55873
|
+
if (key.status === "aborted" || value.status === "aborted") {
|
|
55874
|
+
return INVALID2;
|
|
55875
|
+
}
|
|
55876
|
+
if (key.status === "dirty" || value.status === "dirty") {
|
|
55877
|
+
status.dirty();
|
|
55878
|
+
}
|
|
55879
|
+
finalMap.set(key.value, value.value);
|
|
55880
|
+
}
|
|
55881
|
+
return { status: status.value, value: finalMap };
|
|
55882
|
+
}
|
|
55883
|
+
}
|
|
55884
|
+
};
|
|
55885
|
+
ZodMap2.create = (keyType, valueType, params) => {
|
|
55886
|
+
return new ZodMap2({
|
|
55887
|
+
valueType,
|
|
55888
|
+
keyType,
|
|
55889
|
+
typeName: ZodFirstPartyTypeKind2.ZodMap,
|
|
55890
|
+
...processCreateParams(params)
|
|
55891
|
+
});
|
|
55892
|
+
};
|
|
55893
|
+
var ZodSet2 = class _ZodSet extends ZodType2 {
|
|
55894
|
+
_parse(input2) {
|
|
55895
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
55896
|
+
if (ctx.parsedType !== ZodParsedType.set) {
|
|
55897
|
+
addIssueToContext(ctx, {
|
|
55898
|
+
code: ZodIssueCode2.invalid_type,
|
|
55899
|
+
expected: ZodParsedType.set,
|
|
55900
|
+
received: ctx.parsedType
|
|
55901
|
+
});
|
|
55902
|
+
return INVALID2;
|
|
55903
|
+
}
|
|
55904
|
+
const def = this._def;
|
|
55905
|
+
if (def.minSize !== null) {
|
|
55906
|
+
if (ctx.data.size < def.minSize.value) {
|
|
55907
|
+
addIssueToContext(ctx, {
|
|
55908
|
+
code: ZodIssueCode2.too_small,
|
|
55909
|
+
minimum: def.minSize.value,
|
|
55910
|
+
type: "set",
|
|
55911
|
+
inclusive: true,
|
|
55912
|
+
exact: false,
|
|
55913
|
+
message: def.minSize.message
|
|
55914
|
+
});
|
|
55915
|
+
status.dirty();
|
|
55916
|
+
}
|
|
55917
|
+
}
|
|
55918
|
+
if (def.maxSize !== null) {
|
|
55919
|
+
if (ctx.data.size > def.maxSize.value) {
|
|
55920
|
+
addIssueToContext(ctx, {
|
|
55921
|
+
code: ZodIssueCode2.too_big,
|
|
55922
|
+
maximum: def.maxSize.value,
|
|
55923
|
+
type: "set",
|
|
55924
|
+
inclusive: true,
|
|
55925
|
+
exact: false,
|
|
55926
|
+
message: def.maxSize.message
|
|
55927
|
+
});
|
|
55928
|
+
status.dirty();
|
|
55929
|
+
}
|
|
55930
|
+
}
|
|
55931
|
+
const valueType = this._def.valueType;
|
|
55932
|
+
function finalizeSet(elements2) {
|
|
55933
|
+
const parsedSet = /* @__PURE__ */ new Set();
|
|
55934
|
+
for (const element of elements2) {
|
|
55935
|
+
if (element.status === "aborted")
|
|
55936
|
+
return INVALID2;
|
|
55937
|
+
if (element.status === "dirty")
|
|
55938
|
+
status.dirty();
|
|
55939
|
+
parsedSet.add(element.value);
|
|
55940
|
+
}
|
|
55941
|
+
return { status: status.value, value: parsedSet };
|
|
55942
|
+
}
|
|
55943
|
+
const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
55944
|
+
if (ctx.common.async) {
|
|
55945
|
+
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
|
|
55946
|
+
} else {
|
|
55947
|
+
return finalizeSet(elements);
|
|
55948
|
+
}
|
|
55949
|
+
}
|
|
55950
|
+
min(minSize, message) {
|
|
55951
|
+
return new _ZodSet({
|
|
55952
|
+
...this._def,
|
|
55953
|
+
minSize: { value: minSize, message: errorUtil.toString(message) }
|
|
55954
|
+
});
|
|
55955
|
+
}
|
|
55956
|
+
max(maxSize, message) {
|
|
55957
|
+
return new _ZodSet({
|
|
55958
|
+
...this._def,
|
|
55959
|
+
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
|
55960
|
+
});
|
|
55961
|
+
}
|
|
55962
|
+
size(size, message) {
|
|
55963
|
+
return this.min(size, message).max(size, message);
|
|
55964
|
+
}
|
|
55965
|
+
nonempty(message) {
|
|
55966
|
+
return this.min(1, message);
|
|
55967
|
+
}
|
|
55968
|
+
};
|
|
55969
|
+
ZodSet2.create = (valueType, params) => {
|
|
55970
|
+
return new ZodSet2({
|
|
55971
|
+
valueType,
|
|
55972
|
+
minSize: null,
|
|
55973
|
+
maxSize: null,
|
|
55974
|
+
typeName: ZodFirstPartyTypeKind2.ZodSet,
|
|
55975
|
+
...processCreateParams(params)
|
|
55976
|
+
});
|
|
55977
|
+
};
|
|
55978
|
+
var ZodFunction2 = class _ZodFunction extends ZodType2 {
|
|
55979
|
+
constructor() {
|
|
55980
|
+
super(...arguments);
|
|
55981
|
+
this.validate = this.implement;
|
|
55982
|
+
}
|
|
55983
|
+
_parse(input2) {
|
|
55984
|
+
const { ctx } = this._processInputParams(input2);
|
|
55985
|
+
if (ctx.parsedType !== ZodParsedType.function) {
|
|
55986
|
+
addIssueToContext(ctx, {
|
|
55987
|
+
code: ZodIssueCode2.invalid_type,
|
|
55988
|
+
expected: ZodParsedType.function,
|
|
55989
|
+
received: ctx.parsedType
|
|
55990
|
+
});
|
|
55991
|
+
return INVALID2;
|
|
55992
|
+
}
|
|
55993
|
+
function makeArgsIssue(args, error62) {
|
|
55994
|
+
return makeIssue({
|
|
55995
|
+
data: args,
|
|
55996
|
+
path: ctx.path,
|
|
55997
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
|
|
55998
|
+
issueData: {
|
|
55999
|
+
code: ZodIssueCode2.invalid_arguments,
|
|
56000
|
+
argumentsError: error62
|
|
56001
|
+
}
|
|
56002
|
+
});
|
|
56003
|
+
}
|
|
56004
|
+
function makeReturnsIssue(returns, error62) {
|
|
56005
|
+
return makeIssue({
|
|
56006
|
+
data: returns,
|
|
56007
|
+
path: ctx.path,
|
|
56008
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
|
|
56009
|
+
issueData: {
|
|
56010
|
+
code: ZodIssueCode2.invalid_return_type,
|
|
56011
|
+
returnTypeError: error62
|
|
56012
|
+
}
|
|
56013
|
+
});
|
|
56014
|
+
}
|
|
56015
|
+
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
56016
|
+
const fn = ctx.data;
|
|
56017
|
+
if (this._def.returns instanceof ZodPromise2) {
|
|
56018
|
+
const me = this;
|
|
56019
|
+
return OK(async function(...args) {
|
|
56020
|
+
const error62 = new ZodError2([]);
|
|
56021
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
56022
|
+
error62.addIssue(makeArgsIssue(args, e));
|
|
56023
|
+
throw error62;
|
|
56024
|
+
});
|
|
56025
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
56026
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
56027
|
+
error62.addIssue(makeReturnsIssue(result, e));
|
|
56028
|
+
throw error62;
|
|
56029
|
+
});
|
|
56030
|
+
return parsedReturns;
|
|
56031
|
+
});
|
|
56032
|
+
} else {
|
|
56033
|
+
const me = this;
|
|
56034
|
+
return OK(function(...args) {
|
|
56035
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
56036
|
+
if (!parsedArgs.success) {
|
|
56037
|
+
throw new ZodError2([makeArgsIssue(args, parsedArgs.error)]);
|
|
56038
|
+
}
|
|
56039
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
56040
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
56041
|
+
if (!parsedReturns.success) {
|
|
56042
|
+
throw new ZodError2([makeReturnsIssue(result, parsedReturns.error)]);
|
|
56043
|
+
}
|
|
56044
|
+
return parsedReturns.data;
|
|
56045
|
+
});
|
|
56046
|
+
}
|
|
56047
|
+
}
|
|
56048
|
+
parameters() {
|
|
56049
|
+
return this._def.args;
|
|
56050
|
+
}
|
|
56051
|
+
returnType() {
|
|
56052
|
+
return this._def.returns;
|
|
56053
|
+
}
|
|
56054
|
+
args(...items) {
|
|
56055
|
+
return new _ZodFunction({
|
|
56056
|
+
...this._def,
|
|
56057
|
+
args: ZodTuple2.create(items).rest(ZodUnknown2.create())
|
|
56058
|
+
});
|
|
56059
|
+
}
|
|
56060
|
+
returns(returnType) {
|
|
56061
|
+
return new _ZodFunction({
|
|
56062
|
+
...this._def,
|
|
56063
|
+
returns: returnType
|
|
56064
|
+
});
|
|
56065
|
+
}
|
|
56066
|
+
implement(func) {
|
|
56067
|
+
const validatedFunc = this.parse(func);
|
|
56068
|
+
return validatedFunc;
|
|
56069
|
+
}
|
|
56070
|
+
strictImplement(func) {
|
|
56071
|
+
const validatedFunc = this.parse(func);
|
|
56072
|
+
return validatedFunc;
|
|
56073
|
+
}
|
|
56074
|
+
static create(args, returns, params) {
|
|
56075
|
+
return new _ZodFunction({
|
|
56076
|
+
args: args ? args : ZodTuple2.create([]).rest(ZodUnknown2.create()),
|
|
56077
|
+
returns: returns || ZodUnknown2.create(),
|
|
56078
|
+
typeName: ZodFirstPartyTypeKind2.ZodFunction,
|
|
56079
|
+
...processCreateParams(params)
|
|
56080
|
+
});
|
|
56081
|
+
}
|
|
56082
|
+
};
|
|
56083
|
+
var ZodLazy2 = class extends ZodType2 {
|
|
56084
|
+
get schema() {
|
|
56085
|
+
return this._def.getter();
|
|
56086
|
+
}
|
|
56087
|
+
_parse(input2) {
|
|
56088
|
+
const { ctx } = this._processInputParams(input2);
|
|
56089
|
+
const lazySchema = this._def.getter();
|
|
56090
|
+
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
56091
|
+
}
|
|
56092
|
+
};
|
|
56093
|
+
ZodLazy2.create = (getter, params) => {
|
|
56094
|
+
return new ZodLazy2({
|
|
56095
|
+
getter,
|
|
56096
|
+
typeName: ZodFirstPartyTypeKind2.ZodLazy,
|
|
56097
|
+
...processCreateParams(params)
|
|
56098
|
+
});
|
|
56099
|
+
};
|
|
56100
|
+
var ZodLiteral2 = class extends ZodType2 {
|
|
56101
|
+
_parse(input2) {
|
|
56102
|
+
if (input2.data !== this._def.value) {
|
|
56103
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
56104
|
+
addIssueToContext(ctx, {
|
|
56105
|
+
received: ctx.data,
|
|
56106
|
+
code: ZodIssueCode2.invalid_literal,
|
|
56107
|
+
expected: this._def.value
|
|
56108
|
+
});
|
|
56109
|
+
return INVALID2;
|
|
56110
|
+
}
|
|
56111
|
+
return { status: "valid", value: input2.data };
|
|
56112
|
+
}
|
|
56113
|
+
get value() {
|
|
56114
|
+
return this._def.value;
|
|
56115
|
+
}
|
|
56116
|
+
};
|
|
56117
|
+
ZodLiteral2.create = (value, params) => {
|
|
56118
|
+
return new ZodLiteral2({
|
|
56119
|
+
value,
|
|
56120
|
+
typeName: ZodFirstPartyTypeKind2.ZodLiteral,
|
|
56121
|
+
...processCreateParams(params)
|
|
56122
|
+
});
|
|
56123
|
+
};
|
|
56124
|
+
function createZodEnum(values, params) {
|
|
56125
|
+
return new ZodEnum2({
|
|
56126
|
+
values,
|
|
56127
|
+
typeName: ZodFirstPartyTypeKind2.ZodEnum,
|
|
56128
|
+
...processCreateParams(params)
|
|
56129
|
+
});
|
|
56130
|
+
}
|
|
56131
|
+
var ZodEnum2 = class _ZodEnum extends ZodType2 {
|
|
56132
|
+
_parse(input2) {
|
|
56133
|
+
if (typeof input2.data !== "string") {
|
|
56134
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
56135
|
+
const expectedValues = this._def.values;
|
|
56136
|
+
addIssueToContext(ctx, {
|
|
56137
|
+
expected: util.joinValues(expectedValues),
|
|
56138
|
+
received: ctx.parsedType,
|
|
56139
|
+
code: ZodIssueCode2.invalid_type
|
|
56140
|
+
});
|
|
56141
|
+
return INVALID2;
|
|
56142
|
+
}
|
|
56143
|
+
if (!this._cache) {
|
|
56144
|
+
this._cache = new Set(this._def.values);
|
|
56145
|
+
}
|
|
56146
|
+
if (!this._cache.has(input2.data)) {
|
|
56147
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
56148
|
+
const expectedValues = this._def.values;
|
|
56149
|
+
addIssueToContext(ctx, {
|
|
56150
|
+
received: ctx.data,
|
|
56151
|
+
code: ZodIssueCode2.invalid_enum_value,
|
|
56152
|
+
options: expectedValues
|
|
56153
|
+
});
|
|
56154
|
+
return INVALID2;
|
|
56155
|
+
}
|
|
56156
|
+
return OK(input2.data);
|
|
56157
|
+
}
|
|
56158
|
+
get options() {
|
|
56159
|
+
return this._def.values;
|
|
56160
|
+
}
|
|
56161
|
+
get enum() {
|
|
56162
|
+
const enumValues = {};
|
|
56163
|
+
for (const val of this._def.values) {
|
|
56164
|
+
enumValues[val] = val;
|
|
56165
|
+
}
|
|
56166
|
+
return enumValues;
|
|
56167
|
+
}
|
|
56168
|
+
get Values() {
|
|
56169
|
+
const enumValues = {};
|
|
56170
|
+
for (const val of this._def.values) {
|
|
56171
|
+
enumValues[val] = val;
|
|
56172
|
+
}
|
|
56173
|
+
return enumValues;
|
|
56174
|
+
}
|
|
56175
|
+
get Enum() {
|
|
56176
|
+
const enumValues = {};
|
|
56177
|
+
for (const val of this._def.values) {
|
|
56178
|
+
enumValues[val] = val;
|
|
56179
|
+
}
|
|
56180
|
+
return enumValues;
|
|
56181
|
+
}
|
|
56182
|
+
extract(values, newDef = this._def) {
|
|
56183
|
+
return _ZodEnum.create(values, {
|
|
56184
|
+
...this._def,
|
|
56185
|
+
...newDef
|
|
56186
|
+
});
|
|
56187
|
+
}
|
|
56188
|
+
exclude(values, newDef = this._def) {
|
|
56189
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
56190
|
+
...this._def,
|
|
56191
|
+
...newDef
|
|
56192
|
+
});
|
|
56193
|
+
}
|
|
56194
|
+
};
|
|
56195
|
+
ZodEnum2.create = createZodEnum;
|
|
56196
|
+
var ZodNativeEnum = class extends ZodType2 {
|
|
56197
|
+
_parse(input2) {
|
|
56198
|
+
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
56199
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
56200
|
+
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
56201
|
+
const expectedValues = util.objectValues(nativeEnumValues);
|
|
56202
|
+
addIssueToContext(ctx, {
|
|
56203
|
+
expected: util.joinValues(expectedValues),
|
|
56204
|
+
received: ctx.parsedType,
|
|
56205
|
+
code: ZodIssueCode2.invalid_type
|
|
56206
|
+
});
|
|
56207
|
+
return INVALID2;
|
|
56208
|
+
}
|
|
56209
|
+
if (!this._cache) {
|
|
56210
|
+
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
56211
|
+
}
|
|
56212
|
+
if (!this._cache.has(input2.data)) {
|
|
56213
|
+
const expectedValues = util.objectValues(nativeEnumValues);
|
|
56214
|
+
addIssueToContext(ctx, {
|
|
56215
|
+
received: ctx.data,
|
|
56216
|
+
code: ZodIssueCode2.invalid_enum_value,
|
|
56217
|
+
options: expectedValues
|
|
56218
|
+
});
|
|
56219
|
+
return INVALID2;
|
|
56220
|
+
}
|
|
56221
|
+
return OK(input2.data);
|
|
56222
|
+
}
|
|
56223
|
+
get enum() {
|
|
56224
|
+
return this._def.values;
|
|
56225
|
+
}
|
|
56226
|
+
};
|
|
56227
|
+
ZodNativeEnum.create = (values, params) => {
|
|
56228
|
+
return new ZodNativeEnum({
|
|
56229
|
+
values,
|
|
56230
|
+
typeName: ZodFirstPartyTypeKind2.ZodNativeEnum,
|
|
56231
|
+
...processCreateParams(params)
|
|
56232
|
+
});
|
|
56233
|
+
};
|
|
56234
|
+
var ZodPromise2 = class extends ZodType2 {
|
|
56235
|
+
unwrap() {
|
|
56236
|
+
return this._def.type;
|
|
56237
|
+
}
|
|
56238
|
+
_parse(input2) {
|
|
56239
|
+
const { ctx } = this._processInputParams(input2);
|
|
56240
|
+
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
56241
|
+
addIssueToContext(ctx, {
|
|
56242
|
+
code: ZodIssueCode2.invalid_type,
|
|
56243
|
+
expected: ZodParsedType.promise,
|
|
56244
|
+
received: ctx.parsedType
|
|
56245
|
+
});
|
|
56246
|
+
return INVALID2;
|
|
56247
|
+
}
|
|
56248
|
+
const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
56249
|
+
return OK(promisified.then((data) => {
|
|
56250
|
+
return this._def.type.parseAsync(data, {
|
|
56251
|
+
path: ctx.path,
|
|
56252
|
+
errorMap: ctx.common.contextualErrorMap
|
|
56253
|
+
});
|
|
56254
|
+
}));
|
|
56255
|
+
}
|
|
56256
|
+
};
|
|
56257
|
+
ZodPromise2.create = (schema2, params) => {
|
|
56258
|
+
return new ZodPromise2({
|
|
56259
|
+
type: schema2,
|
|
56260
|
+
typeName: ZodFirstPartyTypeKind2.ZodPromise,
|
|
56261
|
+
...processCreateParams(params)
|
|
56262
|
+
});
|
|
56263
|
+
};
|
|
56264
|
+
var ZodEffects = class extends ZodType2 {
|
|
56265
|
+
innerType() {
|
|
56266
|
+
return this._def.schema;
|
|
56267
|
+
}
|
|
56268
|
+
sourceType() {
|
|
56269
|
+
return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
56270
|
+
}
|
|
56271
|
+
_parse(input2) {
|
|
56272
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
56273
|
+
const effect = this._def.effect || null;
|
|
56274
|
+
const checkCtx = {
|
|
56275
|
+
addIssue: (arg) => {
|
|
56276
|
+
addIssueToContext(ctx, arg);
|
|
56277
|
+
if (arg.fatal) {
|
|
56278
|
+
status.abort();
|
|
56279
|
+
} else {
|
|
56280
|
+
status.dirty();
|
|
56281
|
+
}
|
|
56282
|
+
},
|
|
56283
|
+
get path() {
|
|
56284
|
+
return ctx.path;
|
|
56285
|
+
}
|
|
56286
|
+
};
|
|
56287
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
56288
|
+
if (effect.type === "preprocess") {
|
|
56289
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
56290
|
+
if (ctx.common.async) {
|
|
56291
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
56292
|
+
if (status.value === "aborted")
|
|
56293
|
+
return INVALID2;
|
|
56294
|
+
const result = await this._def.schema._parseAsync({
|
|
56295
|
+
data: processed2,
|
|
56296
|
+
path: ctx.path,
|
|
56297
|
+
parent: ctx
|
|
56298
|
+
});
|
|
56299
|
+
if (result.status === "aborted")
|
|
56300
|
+
return INVALID2;
|
|
56301
|
+
if (result.status === "dirty")
|
|
56302
|
+
return DIRTY(result.value);
|
|
56303
|
+
if (status.value === "dirty")
|
|
56304
|
+
return DIRTY(result.value);
|
|
56305
|
+
return result;
|
|
56306
|
+
});
|
|
56307
|
+
} else {
|
|
56308
|
+
if (status.value === "aborted")
|
|
56309
|
+
return INVALID2;
|
|
56310
|
+
const result = this._def.schema._parseSync({
|
|
56311
|
+
data: processed,
|
|
56312
|
+
path: ctx.path,
|
|
56313
|
+
parent: ctx
|
|
56314
|
+
});
|
|
56315
|
+
if (result.status === "aborted")
|
|
56316
|
+
return INVALID2;
|
|
56317
|
+
if (result.status === "dirty")
|
|
56318
|
+
return DIRTY(result.value);
|
|
56319
|
+
if (status.value === "dirty")
|
|
56320
|
+
return DIRTY(result.value);
|
|
56321
|
+
return result;
|
|
56322
|
+
}
|
|
56323
|
+
}
|
|
56324
|
+
if (effect.type === "refinement") {
|
|
56325
|
+
const executeRefinement = (acc) => {
|
|
56326
|
+
const result = effect.refinement(acc, checkCtx);
|
|
56327
|
+
if (ctx.common.async) {
|
|
56328
|
+
return Promise.resolve(result);
|
|
56329
|
+
}
|
|
56330
|
+
if (result instanceof Promise) {
|
|
56331
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
56332
|
+
}
|
|
56333
|
+
return acc;
|
|
56334
|
+
};
|
|
56335
|
+
if (ctx.common.async === false) {
|
|
56336
|
+
const inner = this._def.schema._parseSync({
|
|
56337
|
+
data: ctx.data,
|
|
56338
|
+
path: ctx.path,
|
|
56339
|
+
parent: ctx
|
|
56340
|
+
});
|
|
56341
|
+
if (inner.status === "aborted")
|
|
56342
|
+
return INVALID2;
|
|
56343
|
+
if (inner.status === "dirty")
|
|
56344
|
+
status.dirty();
|
|
56345
|
+
executeRefinement(inner.value);
|
|
56346
|
+
return { status: status.value, value: inner.value };
|
|
56347
|
+
} else {
|
|
56348
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
56349
|
+
if (inner.status === "aborted")
|
|
56350
|
+
return INVALID2;
|
|
56351
|
+
if (inner.status === "dirty")
|
|
56352
|
+
status.dirty();
|
|
56353
|
+
return executeRefinement(inner.value).then(() => {
|
|
56354
|
+
return { status: status.value, value: inner.value };
|
|
56355
|
+
});
|
|
56356
|
+
});
|
|
56357
|
+
}
|
|
56358
|
+
}
|
|
56359
|
+
if (effect.type === "transform") {
|
|
56360
|
+
if (ctx.common.async === false) {
|
|
56361
|
+
const base = this._def.schema._parseSync({
|
|
56362
|
+
data: ctx.data,
|
|
56363
|
+
path: ctx.path,
|
|
56364
|
+
parent: ctx
|
|
56365
|
+
});
|
|
56366
|
+
if (!isValid(base))
|
|
56367
|
+
return INVALID2;
|
|
56368
|
+
const result = effect.transform(base.value, checkCtx);
|
|
56369
|
+
if (result instanceof Promise) {
|
|
56370
|
+
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
56371
|
+
}
|
|
56372
|
+
return { status: status.value, value: result };
|
|
56373
|
+
} else {
|
|
56374
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
56375
|
+
if (!isValid(base))
|
|
56376
|
+
return INVALID2;
|
|
56377
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
56378
|
+
status: status.value,
|
|
56379
|
+
value: result
|
|
56380
|
+
}));
|
|
56381
|
+
});
|
|
56382
|
+
}
|
|
56383
|
+
}
|
|
56384
|
+
util.assertNever(effect);
|
|
56385
|
+
}
|
|
56386
|
+
};
|
|
56387
|
+
ZodEffects.create = (schema2, effect, params) => {
|
|
56388
|
+
return new ZodEffects({
|
|
56389
|
+
schema: schema2,
|
|
56390
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
56391
|
+
effect,
|
|
56392
|
+
...processCreateParams(params)
|
|
56393
|
+
});
|
|
56394
|
+
};
|
|
56395
|
+
ZodEffects.createWithPreprocess = (preprocess2, schema2, params) => {
|
|
56396
|
+
return new ZodEffects({
|
|
56397
|
+
schema: schema2,
|
|
56398
|
+
effect: { type: "preprocess", transform: preprocess2 },
|
|
56399
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
56400
|
+
...processCreateParams(params)
|
|
56401
|
+
});
|
|
56402
|
+
};
|
|
56403
|
+
var ZodOptional2 = class extends ZodType2 {
|
|
56404
|
+
_parse(input2) {
|
|
56405
|
+
const parsedType2 = this._getType(input2);
|
|
56406
|
+
if (parsedType2 === ZodParsedType.undefined) {
|
|
56407
|
+
return OK(void 0);
|
|
56408
|
+
}
|
|
56409
|
+
return this._def.innerType._parse(input2);
|
|
56410
|
+
}
|
|
56411
|
+
unwrap() {
|
|
56412
|
+
return this._def.innerType;
|
|
56413
|
+
}
|
|
56414
|
+
};
|
|
56415
|
+
ZodOptional2.create = (type2, params) => {
|
|
56416
|
+
return new ZodOptional2({
|
|
56417
|
+
innerType: type2,
|
|
56418
|
+
typeName: ZodFirstPartyTypeKind2.ZodOptional,
|
|
56419
|
+
...processCreateParams(params)
|
|
56420
|
+
});
|
|
56421
|
+
};
|
|
56422
|
+
var ZodNullable2 = class extends ZodType2 {
|
|
56423
|
+
_parse(input2) {
|
|
56424
|
+
const parsedType2 = this._getType(input2);
|
|
56425
|
+
if (parsedType2 === ZodParsedType.null) {
|
|
56426
|
+
return OK(null);
|
|
56427
|
+
}
|
|
56428
|
+
return this._def.innerType._parse(input2);
|
|
56429
|
+
}
|
|
56430
|
+
unwrap() {
|
|
56431
|
+
return this._def.innerType;
|
|
56432
|
+
}
|
|
56433
|
+
};
|
|
56434
|
+
ZodNullable2.create = (type2, params) => {
|
|
56435
|
+
return new ZodNullable2({
|
|
56436
|
+
innerType: type2,
|
|
56437
|
+
typeName: ZodFirstPartyTypeKind2.ZodNullable,
|
|
56438
|
+
...processCreateParams(params)
|
|
56439
|
+
});
|
|
56440
|
+
};
|
|
56441
|
+
var ZodDefault2 = class extends ZodType2 {
|
|
56442
|
+
_parse(input2) {
|
|
56443
|
+
const { ctx } = this._processInputParams(input2);
|
|
56444
|
+
let data = ctx.data;
|
|
56445
|
+
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
56446
|
+
data = this._def.defaultValue();
|
|
56447
|
+
}
|
|
56448
|
+
return this._def.innerType._parse({
|
|
56449
|
+
data,
|
|
56450
|
+
path: ctx.path,
|
|
56451
|
+
parent: ctx
|
|
56452
|
+
});
|
|
56453
|
+
}
|
|
56454
|
+
removeDefault() {
|
|
56455
|
+
return this._def.innerType;
|
|
56456
|
+
}
|
|
56457
|
+
};
|
|
56458
|
+
ZodDefault2.create = (type2, params) => {
|
|
56459
|
+
return new ZodDefault2({
|
|
56460
|
+
innerType: type2,
|
|
56461
|
+
typeName: ZodFirstPartyTypeKind2.ZodDefault,
|
|
56462
|
+
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
|
56463
|
+
...processCreateParams(params)
|
|
56464
|
+
});
|
|
56465
|
+
};
|
|
56466
|
+
var ZodCatch2 = class extends ZodType2 {
|
|
56467
|
+
_parse(input2) {
|
|
56468
|
+
const { ctx } = this._processInputParams(input2);
|
|
56469
|
+
const newCtx = {
|
|
56470
|
+
...ctx,
|
|
56471
|
+
common: {
|
|
56472
|
+
...ctx.common,
|
|
56473
|
+
issues: []
|
|
56474
|
+
}
|
|
56475
|
+
};
|
|
56476
|
+
const result = this._def.innerType._parse({
|
|
56477
|
+
data: newCtx.data,
|
|
56478
|
+
path: newCtx.path,
|
|
56479
|
+
parent: {
|
|
56480
|
+
...newCtx
|
|
56481
|
+
}
|
|
56482
|
+
});
|
|
56483
|
+
if (isAsync(result)) {
|
|
56484
|
+
return result.then((result2) => {
|
|
56485
|
+
return {
|
|
56486
|
+
status: "valid",
|
|
56487
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
56488
|
+
get error() {
|
|
56489
|
+
return new ZodError2(newCtx.common.issues);
|
|
56490
|
+
},
|
|
56491
|
+
input: newCtx.data
|
|
56492
|
+
})
|
|
56493
|
+
};
|
|
56494
|
+
});
|
|
56495
|
+
} else {
|
|
56496
|
+
return {
|
|
56497
|
+
status: "valid",
|
|
56498
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
56499
|
+
get error() {
|
|
56500
|
+
return new ZodError2(newCtx.common.issues);
|
|
56501
|
+
},
|
|
56502
|
+
input: newCtx.data
|
|
56503
|
+
})
|
|
56504
|
+
};
|
|
56505
|
+
}
|
|
56506
|
+
}
|
|
56507
|
+
removeCatch() {
|
|
56508
|
+
return this._def.innerType;
|
|
56509
|
+
}
|
|
56510
|
+
};
|
|
56511
|
+
ZodCatch2.create = (type2, params) => {
|
|
56512
|
+
return new ZodCatch2({
|
|
56513
|
+
innerType: type2,
|
|
56514
|
+
typeName: ZodFirstPartyTypeKind2.ZodCatch,
|
|
56515
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
56516
|
+
...processCreateParams(params)
|
|
56517
|
+
});
|
|
56518
|
+
};
|
|
56519
|
+
var ZodNaN2 = class extends ZodType2 {
|
|
56520
|
+
_parse(input2) {
|
|
56521
|
+
const parsedType2 = this._getType(input2);
|
|
56522
|
+
if (parsedType2 !== ZodParsedType.nan) {
|
|
56523
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
56524
|
+
addIssueToContext(ctx, {
|
|
56525
|
+
code: ZodIssueCode2.invalid_type,
|
|
56526
|
+
expected: ZodParsedType.nan,
|
|
56527
|
+
received: ctx.parsedType
|
|
56528
|
+
});
|
|
56529
|
+
return INVALID2;
|
|
56530
|
+
}
|
|
56531
|
+
return { status: "valid", value: input2.data };
|
|
56532
|
+
}
|
|
56533
|
+
};
|
|
56534
|
+
ZodNaN2.create = (params) => {
|
|
56535
|
+
return new ZodNaN2({
|
|
56536
|
+
typeName: ZodFirstPartyTypeKind2.ZodNaN,
|
|
56537
|
+
...processCreateParams(params)
|
|
56538
|
+
});
|
|
56539
|
+
};
|
|
56540
|
+
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
56541
|
+
var ZodBranded = class extends ZodType2 {
|
|
56542
|
+
_parse(input2) {
|
|
56543
|
+
const { ctx } = this._processInputParams(input2);
|
|
56544
|
+
const data = ctx.data;
|
|
56545
|
+
return this._def.type._parse({
|
|
56546
|
+
data,
|
|
56547
|
+
path: ctx.path,
|
|
56548
|
+
parent: ctx
|
|
56549
|
+
});
|
|
56550
|
+
}
|
|
56551
|
+
unwrap() {
|
|
56552
|
+
return this._def.type;
|
|
56553
|
+
}
|
|
56554
|
+
};
|
|
56555
|
+
var ZodPipeline = class _ZodPipeline extends ZodType2 {
|
|
56556
|
+
_parse(input2) {
|
|
56557
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
56558
|
+
if (ctx.common.async) {
|
|
56559
|
+
const handleAsync = async () => {
|
|
56560
|
+
const inResult = await this._def.in._parseAsync({
|
|
56561
|
+
data: ctx.data,
|
|
56562
|
+
path: ctx.path,
|
|
56563
|
+
parent: ctx
|
|
56564
|
+
});
|
|
56565
|
+
if (inResult.status === "aborted")
|
|
56566
|
+
return INVALID2;
|
|
56567
|
+
if (inResult.status === "dirty") {
|
|
56568
|
+
status.dirty();
|
|
56569
|
+
return DIRTY(inResult.value);
|
|
56570
|
+
} else {
|
|
56571
|
+
return this._def.out._parseAsync({
|
|
56572
|
+
data: inResult.value,
|
|
56573
|
+
path: ctx.path,
|
|
56574
|
+
parent: ctx
|
|
56575
|
+
});
|
|
56576
|
+
}
|
|
56577
|
+
};
|
|
56578
|
+
return handleAsync();
|
|
56579
|
+
} else {
|
|
56580
|
+
const inResult = this._def.in._parseSync({
|
|
56581
|
+
data: ctx.data,
|
|
56582
|
+
path: ctx.path,
|
|
56583
|
+
parent: ctx
|
|
56584
|
+
});
|
|
56585
|
+
if (inResult.status === "aborted")
|
|
56586
|
+
return INVALID2;
|
|
56587
|
+
if (inResult.status === "dirty") {
|
|
56588
|
+
status.dirty();
|
|
56589
|
+
return {
|
|
56590
|
+
status: "dirty",
|
|
56591
|
+
value: inResult.value
|
|
56592
|
+
};
|
|
56593
|
+
} else {
|
|
56594
|
+
return this._def.out._parseSync({
|
|
56595
|
+
data: inResult.value,
|
|
56596
|
+
path: ctx.path,
|
|
56597
|
+
parent: ctx
|
|
56598
|
+
});
|
|
56599
|
+
}
|
|
56600
|
+
}
|
|
56601
|
+
}
|
|
56602
|
+
static create(a, b) {
|
|
56603
|
+
return new _ZodPipeline({
|
|
56604
|
+
in: a,
|
|
56605
|
+
out: b,
|
|
56606
|
+
typeName: ZodFirstPartyTypeKind2.ZodPipeline
|
|
56607
|
+
});
|
|
56608
|
+
}
|
|
56609
|
+
};
|
|
56610
|
+
var ZodReadonly2 = class extends ZodType2 {
|
|
56611
|
+
_parse(input2) {
|
|
56612
|
+
const result = this._def.innerType._parse(input2);
|
|
56613
|
+
const freeze = (data) => {
|
|
56614
|
+
if (isValid(data)) {
|
|
56615
|
+
data.value = Object.freeze(data.value);
|
|
56616
|
+
}
|
|
56617
|
+
return data;
|
|
56618
|
+
};
|
|
56619
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
56620
|
+
}
|
|
56621
|
+
unwrap() {
|
|
56622
|
+
return this._def.innerType;
|
|
56623
|
+
}
|
|
56624
|
+
};
|
|
56625
|
+
ZodReadonly2.create = (type2, params) => {
|
|
56626
|
+
return new ZodReadonly2({
|
|
56627
|
+
innerType: type2,
|
|
56628
|
+
typeName: ZodFirstPartyTypeKind2.ZodReadonly,
|
|
56629
|
+
...processCreateParams(params)
|
|
56630
|
+
});
|
|
56631
|
+
};
|
|
56632
|
+
function cleanParams(params, data) {
|
|
56633
|
+
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
56634
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
56635
|
+
return p2;
|
|
56636
|
+
}
|
|
56637
|
+
function custom2(check3, _params = {}, fatal) {
|
|
56638
|
+
if (check3)
|
|
56639
|
+
return ZodAny2.create().superRefine((data, ctx) => {
|
|
56640
|
+
const r = check3(data);
|
|
56641
|
+
if (r instanceof Promise) {
|
|
56642
|
+
return r.then((r2) => {
|
|
56643
|
+
if (!r2) {
|
|
56644
|
+
const params = cleanParams(_params, data);
|
|
56645
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
56646
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
56647
|
+
}
|
|
56648
|
+
});
|
|
56649
|
+
}
|
|
56650
|
+
if (!r) {
|
|
56651
|
+
const params = cleanParams(_params, data);
|
|
56652
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
56653
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
56654
|
+
}
|
|
56655
|
+
return;
|
|
56656
|
+
});
|
|
56657
|
+
return ZodAny2.create();
|
|
56658
|
+
}
|
|
56659
|
+
var late = {
|
|
56660
|
+
object: ZodObject2.lazycreate
|
|
56661
|
+
};
|
|
56662
|
+
var ZodFirstPartyTypeKind2;
|
|
56663
|
+
(function(ZodFirstPartyTypeKind3) {
|
|
56664
|
+
ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
|
|
56665
|
+
ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
|
|
56666
|
+
ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
|
|
56667
|
+
ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
|
|
56668
|
+
ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
|
|
56669
|
+
ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
|
|
56670
|
+
ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
|
|
56671
|
+
ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
|
|
56672
|
+
ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
|
|
56673
|
+
ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
|
|
56674
|
+
ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
|
|
56675
|
+
ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
|
|
56676
|
+
ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
|
|
56677
|
+
ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
|
|
56678
|
+
ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
|
|
56679
|
+
ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
|
|
56680
|
+
ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
56681
|
+
ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
|
|
56682
|
+
ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
|
|
56683
|
+
ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
|
|
56684
|
+
ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
|
|
56685
|
+
ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
|
|
56686
|
+
ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
|
|
56687
|
+
ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
|
|
56688
|
+
ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
|
|
56689
|
+
ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
|
|
56690
|
+
ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
|
|
56691
|
+
ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
|
|
56692
|
+
ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
|
|
56693
|
+
ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
|
|
56694
|
+
ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
|
|
56695
|
+
ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
|
|
56696
|
+
ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
|
|
56697
|
+
ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
|
|
56698
|
+
ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
|
|
56699
|
+
ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
|
|
56700
|
+
})(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
|
|
56701
|
+
var instanceOfType = (cls, params = {
|
|
56702
|
+
message: `Input not instance of ${cls.name}`
|
|
56703
|
+
}) => custom2((data) => data instanceof cls, params);
|
|
56704
|
+
var stringType = ZodString2.create;
|
|
56705
|
+
var numberType = ZodNumber2.create;
|
|
56706
|
+
var nanType = ZodNaN2.create;
|
|
56707
|
+
var bigIntType = ZodBigInt2.create;
|
|
56708
|
+
var booleanType = ZodBoolean2.create;
|
|
56709
|
+
var dateType = ZodDate2.create;
|
|
56710
|
+
var symbolType = ZodSymbol2.create;
|
|
56711
|
+
var undefinedType = ZodUndefined2.create;
|
|
56712
|
+
var nullType = ZodNull2.create;
|
|
56713
|
+
var anyType = ZodAny2.create;
|
|
56714
|
+
var unknownType = ZodUnknown2.create;
|
|
56715
|
+
var neverType = ZodNever2.create;
|
|
56716
|
+
var voidType = ZodVoid2.create;
|
|
56717
|
+
var arrayType = ZodArray2.create;
|
|
56718
|
+
var objectType = ZodObject2.create;
|
|
56719
|
+
var strictObjectType = ZodObject2.strictCreate;
|
|
56720
|
+
var unionType = ZodUnion2.create;
|
|
56721
|
+
var discriminatedUnionType = ZodDiscriminatedUnion2.create;
|
|
56722
|
+
var intersectionType = ZodIntersection2.create;
|
|
56723
|
+
var tupleType = ZodTuple2.create;
|
|
56724
|
+
var recordType = ZodRecord2.create;
|
|
56725
|
+
var mapType = ZodMap2.create;
|
|
56726
|
+
var setType = ZodSet2.create;
|
|
56727
|
+
var functionType = ZodFunction2.create;
|
|
56728
|
+
var lazyType = ZodLazy2.create;
|
|
56729
|
+
var literalType = ZodLiteral2.create;
|
|
56730
|
+
var enumType = ZodEnum2.create;
|
|
56731
|
+
var nativeEnumType = ZodNativeEnum.create;
|
|
56732
|
+
var promiseType = ZodPromise2.create;
|
|
56733
|
+
var effectsType = ZodEffects.create;
|
|
56734
|
+
var optionalType = ZodOptional2.create;
|
|
56735
|
+
var nullableType = ZodNullable2.create;
|
|
56736
|
+
var preprocessType = ZodEffects.createWithPreprocess;
|
|
56737
|
+
var pipelineType = ZodPipeline.create;
|
|
56738
|
+
var ostring = () => stringType().optional();
|
|
56739
|
+
var onumber = () => numberType().optional();
|
|
56740
|
+
var oboolean = () => booleanType().optional();
|
|
56741
|
+
var coerce = {
|
|
56742
|
+
string: ((arg) => ZodString2.create({ ...arg, coerce: true })),
|
|
56743
|
+
number: ((arg) => ZodNumber2.create({ ...arg, coerce: true })),
|
|
56744
|
+
boolean: ((arg) => ZodBoolean2.create({
|
|
56745
|
+
...arg,
|
|
56746
|
+
coerce: true
|
|
56747
|
+
})),
|
|
56748
|
+
bigint: ((arg) => ZodBigInt2.create({ ...arg, coerce: true })),
|
|
56749
|
+
date: ((arg) => ZodDate2.create({ ...arg, coerce: true }))
|
|
56750
|
+
};
|
|
56751
|
+
var NEVER2 = INVALID2;
|
|
56752
|
+
|
|
56753
|
+
// ../../packages/domain/node_modules/zod/index.js
|
|
56754
|
+
var zod_default = external_exports2;
|
|
56755
|
+
|
|
56756
|
+
// ../../packages/domain/dist/index.js
|
|
56757
|
+
var MemberSchema = zod_default.object({
|
|
56758
|
+
id: zod_default.number().positive("id deve ser um n\xFAmero positivo"),
|
|
56759
|
+
login: zod_default.string().min(1, "login \xE9 obrigat\xF3rio"),
|
|
56760
|
+
firstname: zod_default.string().min(1, "firstname \xE9 obrigat\xF3rio"),
|
|
56761
|
+
lastname: zod_default.string().min(1, "lastname \xE9 obrigat\xF3rio"),
|
|
56762
|
+
admin: zod_default.boolean(),
|
|
56763
|
+
customFields: zod_default.array(
|
|
56764
|
+
zod_default.object({
|
|
56765
|
+
id: zod_default.number(),
|
|
56766
|
+
name: zod_default.string(),
|
|
56767
|
+
value: zod_default.string()
|
|
56768
|
+
})
|
|
56769
|
+
)
|
|
56770
|
+
});
|
|
56771
|
+
var TaskSchema = zod_default.object({
|
|
56772
|
+
title: zod_default.string().min(1, "title \xE9 obrigat\xF3rio").min(3, "title deve ter no m\xEDnimo 3 caracteres"),
|
|
56773
|
+
description: zod_default.string().min(1, "description \xE9 obrigat\xF3rio"),
|
|
56774
|
+
workspaceId: zod_default.string().min(1, "workspaceId \xE9 obrigat\xF3rio"),
|
|
56775
|
+
isFallback: zod_default.boolean().optional(),
|
|
56776
|
+
externalId: zod_default.string().optional(),
|
|
56777
|
+
externalType: zod_default.string().optional()
|
|
56778
|
+
});
|
|
56779
|
+
var CommentSchema = zod_default.string().max(255, "O coment\xE1rio n\xE3o pode ter mais que 255 caracteres").nullable().optional();
|
|
56780
|
+
var UserSchema = zod_default.object({
|
|
56781
|
+
id: zod_default.string().min(1, "user.id \xE9 obrigat\xF3rio"),
|
|
56782
|
+
name: zod_default.string().optional()
|
|
56783
|
+
});
|
|
56784
|
+
var ActivitySchema = zod_default.object({
|
|
56785
|
+
id: zod_default.string().min(1, "activity.id \xE9 obrigat\xF3rio"),
|
|
56786
|
+
name: zod_default.string().optional()
|
|
56787
|
+
});
|
|
56788
|
+
var TimeEntrySchema = zod_default.object({
|
|
56789
|
+
id: zod_default.string().optional(),
|
|
56790
|
+
task: zod_default.object({ id: zod_default.string() }),
|
|
56791
|
+
activity: ActivitySchema,
|
|
56792
|
+
user: UserSchema,
|
|
56793
|
+
startDate: zod_default.date().optional(),
|
|
56794
|
+
endDate: zod_default.date().optional(),
|
|
56795
|
+
timeSpent: zod_default.number().nonnegative().optional(),
|
|
56796
|
+
comments: CommentSchema
|
|
56797
|
+
});
|
|
56798
|
+
var avatarUrlSchema = zod_default.string().optional().or(zod_default.literal("")).refine(
|
|
56799
|
+
(val) => {
|
|
56800
|
+
if (!val) return true;
|
|
56801
|
+
if (val.startsWith("blob:")) return true;
|
|
56802
|
+
if (!URL.canParse(val)) return false;
|
|
56803
|
+
const url2 = new URL(val);
|
|
56804
|
+
if (!url2.hostname) return false;
|
|
56805
|
+
const isWebUrl = url2.protocol === "https:" || url2.protocol === "http:";
|
|
56806
|
+
if (url2.origin !== "null" && !isWebUrl) return false;
|
|
56807
|
+
if (["data:", "file:", "javascript:"].includes(url2.protocol)) return false;
|
|
56808
|
+
return /\.(png|jpe?g|gif|svg|webp)$/i.test(url2.pathname);
|
|
56809
|
+
},
|
|
56810
|
+
{
|
|
56811
|
+
message: "Avatar deve ser uma URL v\xE1lida de imagem (png, jpg, jpeg, gif, svg, webp)"
|
|
56812
|
+
}
|
|
56813
|
+
);
|
|
56814
|
+
var WorkspaceSchema = zod_default.object({
|
|
56815
|
+
name: zod_default.string().min(1, "Nome \xE9 obrigat\xF3rio").min(3, "Nome deve ter pelo menos 3 caracteres"),
|
|
56816
|
+
description: zod_default.string().max(500, "Descri\xE7\xE3o n\xE3o pode ter mais que 500 caracteres").optional().or(zod_default.literal("")),
|
|
56817
|
+
avatarUrl: avatarUrlSchema
|
|
56818
|
+
});
|
|
52713
56819
|
var VALID_ADDON_TIERS = ["free", "plus"];
|
|
56820
|
+
var OFFLINE_AUTHORIZATION_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
56821
|
+
var CLOCK_LEEWAY_MS = 60 * 1e3;
|
|
56822
|
+
var offlineAuthorizationClaimsSchema = external_exports2.object({
|
|
56823
|
+
formatVersion: external_exports2.literal(1),
|
|
56824
|
+
keyId: external_exports2.string().min(1),
|
|
56825
|
+
licenseId: external_exports2.string().min(1),
|
|
56826
|
+
installationId: external_exports2.string().min(1),
|
|
56827
|
+
plan: external_exports2.literal("plus"),
|
|
56828
|
+
status: external_exports2.enum(["active", "revoked"]),
|
|
56829
|
+
issuedAt: external_exports2.number().int().positive().max(864e13).finite(),
|
|
56830
|
+
paidThrough: external_exports2.number().int().positive().max(864e13).finite(),
|
|
56831
|
+
offlineThrough: external_exports2.number().int().positive().max(864e13).finite()
|
|
56832
|
+
}).strict();
|
|
52714
56833
|
|
|
52715
56834
|
// src/contracts/manifest/ISignedAddonCatalogManifest.ts
|
|
52716
56835
|
var ADDON_CATALOG_RECEIPT_FILE = "catalog-version.json";
|
|
@@ -52795,7 +56914,7 @@ async function runInitWizard(targetDirName) {
|
|
|
52795
56914
|
pack: "rastro pack ."
|
|
52796
56915
|
},
|
|
52797
56916
|
devDependencies: {
|
|
52798
|
-
"@rastrokit/sdk": `^${"0.
|
|
56917
|
+
"@rastrokit/sdk": `^${"0.17.0"}`,
|
|
52799
56918
|
tsup: "^8.5.0",
|
|
52800
56919
|
typescript: "^5.8.0"
|
|
52801
56920
|
}
|
|
@@ -52831,7 +56950,7 @@ async function runInitWizard(targetDirName) {
|
|
|
52831
56950
|
description: answers.description,
|
|
52832
56951
|
tags: [...answers.capabilities, "rastro"],
|
|
52833
56952
|
screenshots: [],
|
|
52834
|
-
requiredApiVersion: `^${"0.
|
|
56953
|
+
requiredApiVersion: `^${"0.17.0"}`,
|
|
52835
56954
|
releaseDate: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
52836
56955
|
changelog: ["Vers\xE3o inicial do plugin"]
|
|
52837
56956
|
};
|
|
@@ -53222,9 +57341,9 @@ function validateAddon(addonDir) {
|
|
|
53222
57341
|
);
|
|
53223
57342
|
}
|
|
53224
57343
|
const rawCapabilities = extractCapabilities(manifest);
|
|
53225
|
-
if (
|
|
57344
|
+
if (!Array.isArray(manifest.capabilities)) {
|
|
53226
57345
|
errors.push(
|
|
53227
|
-
`Campo "capabilities"
|
|
57346
|
+
`Campo "capabilities" deve ser uma lista (pode ser vazia para addons gerais). Capacidades v\xE1lidas: ${VALID_ADDON_CAPABILITIES.join(", ")}`
|
|
53228
57347
|
);
|
|
53229
57348
|
}
|
|
53230
57349
|
const seenCapabilities = /* @__PURE__ */ new Set();
|
|
@@ -53753,7 +57872,7 @@ function parseCliTier(rawTier) {
|
|
|
53753
57872
|
if (normalized === "free") return "free";
|
|
53754
57873
|
return void 0;
|
|
53755
57874
|
}
|
|
53756
|
-
program.name("rastro").description("CLI do Rastro SDK para criar, validar e empacotar plugins").version("0.
|
|
57875
|
+
program.name("rastro").description("CLI do Rastro SDK para criar, validar e empacotar plugins").version("0.17.0");
|
|
53757
57876
|
program.command("init [name]").description(
|
|
53758
57877
|
"Inicializa um novo projeto de plugin com TypeScript e boilerplates"
|
|
53759
57878
|
).action(async (name) => {
|
|
@@ -53789,7 +57908,7 @@ program.command("pack [addonDir]").alias("pkg").description("Empacota o plugin e
|
|
|
53789
57908
|
downloadUrl = answer.downloadUrl;
|
|
53790
57909
|
}
|
|
53791
57910
|
buildAddon(addonDir, {
|
|
53792
|
-
apiVersion: "0.
|
|
57911
|
+
apiVersion: "0.17.0",
|
|
53793
57912
|
signing: readCatalogSigningEnvironment(process.env),
|
|
53794
57913
|
downloadUrl,
|
|
53795
57914
|
tier: cliTier,
|