@bryan-thompson/inspector-assessment-client 1.30.0 → 1.31.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/assets/{OAuthCallback-BbE88qbF.js → OAuthCallback-CXcl26vR.js} +1 -1
- package/dist/assets/{OAuthDebugCallback-CfRYq1JG.js → OAuthDebugCallback-J9s4SF_c.js} +1 -1
- package/dist/assets/{index-cHhcEXbr.css → index-BoUA5OL1.css} +3 -0
- package/dist/assets/{index-CsUB73MT.js → index-_HAw2b2G.js} +3746 -115
- package/dist/index.html +2 -2
- package/lib/lib/assessment/configTypes.d.ts +6 -0
- package/lib/lib/assessment/configTypes.d.ts.map +1 -1
- package/lib/lib/assessment/extendedTypes.d.ts +74 -0
- package/lib/lib/assessment/extendedTypes.d.ts.map +1 -1
- package/lib/lib/assessment/resultTypes.d.ts +3 -1
- package/lib/lib/assessment/resultTypes.d.ts.map +1 -1
- package/lib/lib/assessment/sharedSchemas.d.ts +140 -0
- package/lib/lib/assessment/sharedSchemas.d.ts.map +1 -0
- package/lib/lib/assessment/sharedSchemas.js +113 -0
- package/lib/lib/securityPatterns.d.ts.map +1 -1
- package/lib/lib/securityPatterns.js +2 -2
- package/lib/services/assessment/AssessmentOrchestrator.d.ts +1 -0
- package/lib/services/assessment/AssessmentOrchestrator.d.ts.map +1 -1
- package/lib/services/assessment/AssessmentOrchestrator.js +34 -1
- package/lib/services/assessment/ResponseValidator.d.ts +10 -0
- package/lib/services/assessment/ResponseValidator.d.ts.map +1 -1
- package/lib/services/assessment/ResponseValidator.js +30 -6
- package/lib/services/assessment/config/performanceConfig.d.ts +2 -0
- package/lib/services/assessment/config/performanceConfig.d.ts.map +1 -1
- package/lib/services/assessment/config/performanceConfig.js +5 -33
- package/lib/services/assessment/config/performanceConfigSchemas.d.ts +111 -0
- package/lib/services/assessment/config/performanceConfigSchemas.d.ts.map +1 -0
- package/lib/services/assessment/config/performanceConfigSchemas.js +123 -0
- package/lib/services/assessment/modules/ConformanceAssessor.d.ts +60 -0
- package/lib/services/assessment/modules/ConformanceAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/ConformanceAssessor.js +308 -0
- package/lib/services/assessment/modules/ResourceAssessor.d.ts +14 -0
- package/lib/services/assessment/modules/ResourceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ResourceAssessor.js +221 -0
- package/lib/services/assessment/modules/TemporalAssessor.d.ts +14 -0
- package/lib/services/assessment/modules/TemporalAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/TemporalAssessor.js +29 -1
- package/lib/services/assessment/modules/annotations/AlignmentChecker.d.ts +9 -0
- package/lib/services/assessment/modules/annotations/AlignmentChecker.d.ts.map +1 -1
- package/lib/services/assessment/modules/annotations/AlignmentChecker.js +97 -5
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.d.ts +6 -4
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.d.ts.map +1 -1
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.js +58 -0
- package/lib/services/assessment/modules/annotations/index.d.ts +1 -1
- package/lib/services/assessment/modules/annotations/index.d.ts.map +1 -1
- package/lib/services/assessment/modules/annotations/index.js +2 -1
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +3 -3
- package/lib/services/assessment/responseValidatorSchemas.d.ts +751 -0
- package/lib/services/assessment/responseValidatorSchemas.d.ts.map +1 -0
- package/lib/services/assessment/responseValidatorSchemas.js +244 -0
- package/package.json +1 -1
|
@@ -11424,7 +11424,7 @@ function cleanRegex(source) {
|
|
|
11424
11424
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
11425
11425
|
return source.slice(start, end);
|
|
11426
11426
|
}
|
|
11427
|
-
function floatSafeRemainder(val, step) {
|
|
11427
|
+
function floatSafeRemainder$1(val, step) {
|
|
11428
11428
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
11429
11429
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
11430
11430
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
@@ -11866,8 +11866,8 @@ function datetime$1(args) {
|
|
|
11866
11866
|
opts.push("");
|
|
11867
11867
|
if (args.offset)
|
|
11868
11868
|
opts.push(`([+-]\\d{2}:\\d{2})`);
|
|
11869
|
-
const
|
|
11870
|
-
return new RegExp(`^${dateSource}T(?:${
|
|
11869
|
+
const timeRegex2 = `${time2}(?:${opts.join("|")})`;
|
|
11870
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
|
|
11871
11871
|
}
|
|
11872
11872
|
const string$1 = (params) => {
|
|
11873
11873
|
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
@@ -11955,7 +11955,7 @@ const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf",
|
|
|
11955
11955
|
inst._zod.check = (payload) => {
|
|
11956
11956
|
if (typeof payload.value !== typeof def.value)
|
|
11957
11957
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
11958
|
-
const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
11958
|
+
const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder$1(payload.value, def.value) === 0;
|
|
11959
11959
|
if (isMultiple)
|
|
11960
11960
|
return;
|
|
11961
11961
|
payload.issues.push({
|
|
@@ -12323,14 +12323,14 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
12323
12323
|
});
|
|
12324
12324
|
} else {
|
|
12325
12325
|
const runChecks = (payload, checks2, ctx) => {
|
|
12326
|
-
let
|
|
12326
|
+
let isAborted2 = aborted(payload);
|
|
12327
12327
|
let asyncResult;
|
|
12328
12328
|
for (const ch of checks2) {
|
|
12329
12329
|
if (ch._zod.def.when) {
|
|
12330
12330
|
const shouldRun = ch._zod.def.when(payload);
|
|
12331
12331
|
if (!shouldRun)
|
|
12332
12332
|
continue;
|
|
12333
|
-
} else if (
|
|
12333
|
+
} else if (isAborted2) {
|
|
12334
12334
|
continue;
|
|
12335
12335
|
}
|
|
12336
12336
|
const currLen = payload.issues.length;
|
|
@@ -12344,15 +12344,15 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
12344
12344
|
const nextLen = payload.issues.length;
|
|
12345
12345
|
if (nextLen === currLen)
|
|
12346
12346
|
return;
|
|
12347
|
-
if (!
|
|
12348
|
-
|
|
12347
|
+
if (!isAborted2)
|
|
12348
|
+
isAborted2 = aborted(payload, currLen);
|
|
12349
12349
|
});
|
|
12350
12350
|
} else {
|
|
12351
12351
|
const nextLen = payload.issues.length;
|
|
12352
12352
|
if (nextLen === currLen)
|
|
12353
12353
|
continue;
|
|
12354
|
-
if (!
|
|
12355
|
-
|
|
12354
|
+
if (!isAborted2)
|
|
12355
|
+
isAborted2 = aborted(payload, currLen);
|
|
12356
12356
|
}
|
|
12357
12357
|
}
|
|
12358
12358
|
if (asyncResult) {
|
|
@@ -12650,7 +12650,7 @@ const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
|
12650
12650
|
def.pattern ?? (def.pattern = e164);
|
|
12651
12651
|
$ZodStringFormat.init(inst, def);
|
|
12652
12652
|
});
|
|
12653
|
-
function isValidJWT(token, algorithm = null) {
|
|
12653
|
+
function isValidJWT$1(token, algorithm = null) {
|
|
12654
12654
|
try {
|
|
12655
12655
|
const tokensParts = token.split(".");
|
|
12656
12656
|
if (tokensParts.length !== 3)
|
|
@@ -12673,7 +12673,7 @@ function isValidJWT(token, algorithm = null) {
|
|
|
12673
12673
|
const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
12674
12674
|
$ZodStringFormat.init(inst, def);
|
|
12675
12675
|
inst._zod.check = (payload) => {
|
|
12676
|
-
if (isValidJWT(payload.value, def.alg))
|
|
12676
|
+
if (isValidJWT$1(payload.value, def.alg))
|
|
12677
12677
|
return;
|
|
12678
12678
|
payload.issues.push({
|
|
12679
12679
|
code: "invalid_format",
|
|
@@ -13130,7 +13130,7 @@ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst,
|
|
|
13130
13130
|
return handleIntersectionResults(payload, left, right);
|
|
13131
13131
|
};
|
|
13132
13132
|
});
|
|
13133
|
-
function mergeValues(a, b) {
|
|
13133
|
+
function mergeValues$1(a, b) {
|
|
13134
13134
|
if (a === b) {
|
|
13135
13135
|
return { valid: true, data: a };
|
|
13136
13136
|
}
|
|
@@ -13142,7 +13142,7 @@ function mergeValues(a, b) {
|
|
|
13142
13142
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
13143
13143
|
const newObj = { ...a, ...b };
|
|
13144
13144
|
for (const key of sharedKeys) {
|
|
13145
|
-
const sharedValue = mergeValues(a[key], b[key]);
|
|
13145
|
+
const sharedValue = mergeValues$1(a[key], b[key]);
|
|
13146
13146
|
if (!sharedValue.valid) {
|
|
13147
13147
|
return {
|
|
13148
13148
|
valid: false,
|
|
@@ -13161,7 +13161,7 @@ function mergeValues(a, b) {
|
|
|
13161
13161
|
for (let index2 = 0; index2 < a.length; index2++) {
|
|
13162
13162
|
const itemA = a[index2];
|
|
13163
13163
|
const itemB = b[index2];
|
|
13164
|
-
const sharedValue = mergeValues(itemA, itemB);
|
|
13164
|
+
const sharedValue = mergeValues$1(itemA, itemB);
|
|
13165
13165
|
if (!sharedValue.valid) {
|
|
13166
13166
|
return {
|
|
13167
13167
|
valid: false,
|
|
@@ -13183,7 +13183,7 @@ function handleIntersectionResults(result, left, right) {
|
|
|
13183
13183
|
}
|
|
13184
13184
|
if (aborted(result))
|
|
13185
13185
|
return result;
|
|
13186
|
-
const merged = mergeValues(left.value, right.value);
|
|
13186
|
+
const merged = mergeValues$1(left.value, right.value);
|
|
13187
13187
|
if (!merged.valid) {
|
|
13188
13188
|
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
13189
13189
|
}
|
|
@@ -14100,7 +14100,7 @@ const parse$1 = /* @__PURE__ */ _parse(ZodRealError);
|
|
|
14100
14100
|
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
14101
14101
|
const safeParse$1 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
14102
14102
|
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
14103
|
-
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
14103
|
+
const ZodType$1 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
14104
14104
|
$ZodType.init(inst, def);
|
|
14105
14105
|
inst.def = def;
|
|
14106
14106
|
Object.defineProperty(inst, "_def", { value: def });
|
|
@@ -14168,7 +14168,7 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
14168
14168
|
});
|
|
14169
14169
|
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
14170
14170
|
$ZodString.init(inst, def);
|
|
14171
|
-
ZodType.init(inst, def);
|
|
14171
|
+
ZodType$1.init(inst, def);
|
|
14172
14172
|
const bag = inst._zod.bag;
|
|
14173
14173
|
inst.format = bag.format ?? null;
|
|
14174
14174
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -14188,7 +14188,7 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
14188
14188
|
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
14189
14189
|
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
14190
14190
|
});
|
|
14191
|
-
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
14191
|
+
const ZodString$1 = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
14192
14192
|
$ZodString.init(inst, def);
|
|
14193
14193
|
_ZodString.init(inst, def);
|
|
14194
14194
|
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
@@ -14220,7 +14220,7 @@ const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
|
14220
14220
|
inst.duration = (params) => inst.check(duration(params));
|
|
14221
14221
|
});
|
|
14222
14222
|
function string(params) {
|
|
14223
|
-
return _string(ZodString, params);
|
|
14223
|
+
return _string(ZodString$1, params);
|
|
14224
14224
|
}
|
|
14225
14225
|
const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
14226
14226
|
$ZodStringFormat.init(inst, def);
|
|
@@ -14305,9 +14305,9 @@ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
|
14305
14305
|
$ZodJWT.init(inst, def);
|
|
14306
14306
|
ZodStringFormat.init(inst, def);
|
|
14307
14307
|
});
|
|
14308
|
-
const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
14308
|
+
const ZodNumber$1 = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
14309
14309
|
$ZodNumber.init(inst, def);
|
|
14310
|
-
ZodType.init(inst, def);
|
|
14310
|
+
ZodType$1.init(inst, def);
|
|
14311
14311
|
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
14312
14312
|
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
14313
14313
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
@@ -14331,53 +14331,53 @@ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
14331
14331
|
inst.format = bag.format ?? null;
|
|
14332
14332
|
});
|
|
14333
14333
|
function number$1(params) {
|
|
14334
|
-
return _number(ZodNumber, params);
|
|
14334
|
+
return _number(ZodNumber$1, params);
|
|
14335
14335
|
}
|
|
14336
14336
|
const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
|
|
14337
14337
|
$ZodNumberFormat.init(inst, def);
|
|
14338
|
-
ZodNumber.init(inst, def);
|
|
14338
|
+
ZodNumber$1.init(inst, def);
|
|
14339
14339
|
});
|
|
14340
14340
|
function int(params) {
|
|
14341
14341
|
return _int(ZodNumberFormat, params);
|
|
14342
14342
|
}
|
|
14343
|
-
const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
14343
|
+
const ZodBoolean$1 = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
14344
14344
|
$ZodBoolean.init(inst, def);
|
|
14345
|
-
ZodType.init(inst, def);
|
|
14345
|
+
ZodType$1.init(inst, def);
|
|
14346
14346
|
});
|
|
14347
14347
|
function boolean(params) {
|
|
14348
|
-
return _boolean(ZodBoolean, params);
|
|
14348
|
+
return _boolean(ZodBoolean$1, params);
|
|
14349
14349
|
}
|
|
14350
|
-
const ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
14350
|
+
const ZodNull$1 = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
14351
14351
|
$ZodNull.init(inst, def);
|
|
14352
|
-
ZodType.init(inst, def);
|
|
14352
|
+
ZodType$1.init(inst, def);
|
|
14353
14353
|
});
|
|
14354
14354
|
function _null(params) {
|
|
14355
|
-
return _null$1(ZodNull, params);
|
|
14355
|
+
return _null$1(ZodNull$1, params);
|
|
14356
14356
|
}
|
|
14357
|
-
const ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
14357
|
+
const ZodAny$1 = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
14358
14358
|
$ZodAny.init(inst, def);
|
|
14359
|
-
ZodType.init(inst, def);
|
|
14359
|
+
ZodType$1.init(inst, def);
|
|
14360
14360
|
});
|
|
14361
14361
|
function any() {
|
|
14362
|
-
return _any(ZodAny);
|
|
14362
|
+
return _any(ZodAny$1);
|
|
14363
14363
|
}
|
|
14364
|
-
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
14364
|
+
const ZodUnknown$1 = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
14365
14365
|
$ZodUnknown.init(inst, def);
|
|
14366
|
-
ZodType.init(inst, def);
|
|
14366
|
+
ZodType$1.init(inst, def);
|
|
14367
14367
|
});
|
|
14368
14368
|
function unknown() {
|
|
14369
|
-
return _unknown(ZodUnknown);
|
|
14369
|
+
return _unknown(ZodUnknown$1);
|
|
14370
14370
|
}
|
|
14371
|
-
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
14371
|
+
const ZodNever$1 = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
14372
14372
|
$ZodNever.init(inst, def);
|
|
14373
|
-
ZodType.init(inst, def);
|
|
14373
|
+
ZodType$1.init(inst, def);
|
|
14374
14374
|
});
|
|
14375
14375
|
function never(params) {
|
|
14376
|
-
return _never(ZodNever, params);
|
|
14376
|
+
return _never(ZodNever$1, params);
|
|
14377
14377
|
}
|
|
14378
|
-
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
14378
|
+
const ZodArray$1 = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
14379
14379
|
$ZodArray.init(inst, def);
|
|
14380
|
-
ZodType.init(inst, def);
|
|
14380
|
+
ZodType$1.init(inst, def);
|
|
14381
14381
|
inst.element = def.element;
|
|
14382
14382
|
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
14383
14383
|
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
@@ -14386,11 +14386,11 @@ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
14386
14386
|
inst.unwrap = () => inst.element;
|
|
14387
14387
|
});
|
|
14388
14388
|
function array(element, params) {
|
|
14389
|
-
return _array(ZodArray, element, params);
|
|
14389
|
+
return _array(ZodArray$1, element, params);
|
|
14390
14390
|
}
|
|
14391
|
-
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
14391
|
+
const ZodObject$1 = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
14392
14392
|
$ZodObject.init(inst, def);
|
|
14393
|
-
ZodType.init(inst, def);
|
|
14393
|
+
ZodType$1.init(inst, def);
|
|
14394
14394
|
defineLazy(inst, "shape", () => def.shape);
|
|
14395
14395
|
inst.keyof = () => _enum$2(Object.keys(inst._zod.def.shape));
|
|
14396
14396
|
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
@@ -14404,7 +14404,7 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
14404
14404
|
inst.merge = (other) => merge(inst, other);
|
|
14405
14405
|
inst.pick = (mask) => pick(inst, mask);
|
|
14406
14406
|
inst.omit = (mask) => omit(inst, mask);
|
|
14407
|
-
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
14407
|
+
inst.partial = (...args) => partial(ZodOptional$1, inst, args[0]);
|
|
14408
14408
|
inst.required = (...args) => required$4(ZodNonOptional, inst, args[0]);
|
|
14409
14409
|
});
|
|
14410
14410
|
function object(shape, params) {
|
|
@@ -14416,10 +14416,10 @@ function object(shape, params) {
|
|
|
14416
14416
|
},
|
|
14417
14417
|
...normalizeParams(params)
|
|
14418
14418
|
};
|
|
14419
|
-
return new ZodObject(def);
|
|
14419
|
+
return new ZodObject$1(def);
|
|
14420
14420
|
}
|
|
14421
14421
|
function looseObject(shape, params) {
|
|
14422
|
-
return new ZodObject({
|
|
14422
|
+
return new ZodObject$1({
|
|
14423
14423
|
type: "object",
|
|
14424
14424
|
get shape() {
|
|
14425
14425
|
assignProp(this, "shape", { ...shape });
|
|
@@ -14429,20 +14429,20 @@ function looseObject(shape, params) {
|
|
|
14429
14429
|
...normalizeParams(params)
|
|
14430
14430
|
});
|
|
14431
14431
|
}
|
|
14432
|
-
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
14432
|
+
const ZodUnion$1 = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
14433
14433
|
$ZodUnion.init(inst, def);
|
|
14434
|
-
ZodType.init(inst, def);
|
|
14434
|
+
ZodType$1.init(inst, def);
|
|
14435
14435
|
inst.options = def.options;
|
|
14436
14436
|
});
|
|
14437
14437
|
function union(options, params) {
|
|
14438
|
-
return new ZodUnion({
|
|
14438
|
+
return new ZodUnion$1({
|
|
14439
14439
|
type: "union",
|
|
14440
14440
|
options,
|
|
14441
14441
|
...normalizeParams(params)
|
|
14442
14442
|
});
|
|
14443
14443
|
}
|
|
14444
14444
|
const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
14445
|
-
ZodUnion.init(inst, def);
|
|
14445
|
+
ZodUnion$1.init(inst, def);
|
|
14446
14446
|
$ZodDiscriminatedUnion.init(inst, def);
|
|
14447
14447
|
});
|
|
14448
14448
|
function discriminatedUnion(discriminator2, options, params) {
|
|
@@ -14453,12 +14453,12 @@ function discriminatedUnion(discriminator2, options, params) {
|
|
|
14453
14453
|
...normalizeParams(params)
|
|
14454
14454
|
});
|
|
14455
14455
|
}
|
|
14456
|
-
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
14456
|
+
const ZodIntersection$1 = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
14457
14457
|
$ZodIntersection.init(inst, def);
|
|
14458
|
-
ZodType.init(inst, def);
|
|
14458
|
+
ZodType$1.init(inst, def);
|
|
14459
14459
|
});
|
|
14460
14460
|
function intersection(left, right) {
|
|
14461
|
-
return new ZodIntersection({
|
|
14461
|
+
return new ZodIntersection$1({
|
|
14462
14462
|
type: "intersection",
|
|
14463
14463
|
left,
|
|
14464
14464
|
right
|
|
@@ -14466,7 +14466,7 @@ function intersection(left, right) {
|
|
|
14466
14466
|
}
|
|
14467
14467
|
const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
14468
14468
|
$ZodRecord.init(inst, def);
|
|
14469
|
-
ZodType.init(inst, def);
|
|
14469
|
+
ZodType$1.init(inst, def);
|
|
14470
14470
|
inst.keyType = def.keyType;
|
|
14471
14471
|
inst.valueType = def.valueType;
|
|
14472
14472
|
});
|
|
@@ -14478,9 +14478,9 @@ function record(keyType, valueType, params) {
|
|
|
14478
14478
|
...normalizeParams(params)
|
|
14479
14479
|
});
|
|
14480
14480
|
}
|
|
14481
|
-
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
14481
|
+
const ZodEnum$1 = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
14482
14482
|
$ZodEnum.init(inst, def);
|
|
14483
|
-
ZodType.init(inst, def);
|
|
14483
|
+
ZodType$1.init(inst, def);
|
|
14484
14484
|
inst.enum = def.entries;
|
|
14485
14485
|
inst.options = Object.values(def.entries);
|
|
14486
14486
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -14492,7 +14492,7 @@ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
14492
14492
|
} else
|
|
14493
14493
|
throw new Error(`Key ${value} not found in enum`);
|
|
14494
14494
|
}
|
|
14495
|
-
return new ZodEnum({
|
|
14495
|
+
return new ZodEnum$1({
|
|
14496
14496
|
...def,
|
|
14497
14497
|
checks: [],
|
|
14498
14498
|
...normalizeParams(params),
|
|
@@ -14507,7 +14507,7 @@ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
14507
14507
|
} else
|
|
14508
14508
|
throw new Error(`Key ${value} not found in enum`);
|
|
14509
14509
|
}
|
|
14510
|
-
return new ZodEnum({
|
|
14510
|
+
return new ZodEnum$1({
|
|
14511
14511
|
...def,
|
|
14512
14512
|
checks: [],
|
|
14513
14513
|
...normalizeParams(params),
|
|
@@ -14517,15 +14517,15 @@ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
14517
14517
|
});
|
|
14518
14518
|
function _enum$2(values, params) {
|
|
14519
14519
|
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
14520
|
-
return new ZodEnum({
|
|
14520
|
+
return new ZodEnum$1({
|
|
14521
14521
|
type: "enum",
|
|
14522
14522
|
entries,
|
|
14523
14523
|
...normalizeParams(params)
|
|
14524
14524
|
});
|
|
14525
14525
|
}
|
|
14526
|
-
const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
14526
|
+
const ZodLiteral$1 = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
14527
14527
|
$ZodLiteral.init(inst, def);
|
|
14528
|
-
ZodType.init(inst, def);
|
|
14528
|
+
ZodType$1.init(inst, def);
|
|
14529
14529
|
inst.values = new Set(def.values);
|
|
14530
14530
|
Object.defineProperty(inst, "value", {
|
|
14531
14531
|
get() {
|
|
@@ -14537,7 +14537,7 @@ const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
|
14537
14537
|
});
|
|
14538
14538
|
});
|
|
14539
14539
|
function literal(value, params) {
|
|
14540
|
-
return new ZodLiteral({
|
|
14540
|
+
return new ZodLiteral$1({
|
|
14541
14541
|
type: "literal",
|
|
14542
14542
|
values: Array.isArray(value) ? value : [value],
|
|
14543
14543
|
...normalizeParams(params)
|
|
@@ -14545,7 +14545,7 @@ function literal(value, params) {
|
|
|
14545
14545
|
}
|
|
14546
14546
|
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
14547
14547
|
$ZodTransform.init(inst, def);
|
|
14548
|
-
ZodType.init(inst, def);
|
|
14548
|
+
ZodType$1.init(inst, def);
|
|
14549
14549
|
inst._zod.parse = (payload, _ctx) => {
|
|
14550
14550
|
payload.addIssue = (issue$1) => {
|
|
14551
14551
|
if (typeof issue$1 === "string") {
|
|
@@ -14578,36 +14578,36 @@ function transform(fn) {
|
|
|
14578
14578
|
transform: fn
|
|
14579
14579
|
});
|
|
14580
14580
|
}
|
|
14581
|
-
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
14581
|
+
const ZodOptional$1 = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
14582
14582
|
$ZodOptional.init(inst, def);
|
|
14583
|
-
ZodType.init(inst, def);
|
|
14583
|
+
ZodType$1.init(inst, def);
|
|
14584
14584
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
14585
14585
|
});
|
|
14586
14586
|
function optional(innerType) {
|
|
14587
|
-
return new ZodOptional({
|
|
14587
|
+
return new ZodOptional$1({
|
|
14588
14588
|
type: "optional",
|
|
14589
14589
|
innerType
|
|
14590
14590
|
});
|
|
14591
14591
|
}
|
|
14592
|
-
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
14592
|
+
const ZodNullable$1 = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
14593
14593
|
$ZodNullable.init(inst, def);
|
|
14594
|
-
ZodType.init(inst, def);
|
|
14594
|
+
ZodType$1.init(inst, def);
|
|
14595
14595
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
14596
14596
|
});
|
|
14597
14597
|
function nullable(innerType) {
|
|
14598
|
-
return new ZodNullable({
|
|
14598
|
+
return new ZodNullable$1({
|
|
14599
14599
|
type: "nullable",
|
|
14600
14600
|
innerType
|
|
14601
14601
|
});
|
|
14602
14602
|
}
|
|
14603
|
-
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
14603
|
+
const ZodDefault$1 = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
14604
14604
|
$ZodDefault.init(inst, def);
|
|
14605
|
-
ZodType.init(inst, def);
|
|
14605
|
+
ZodType$1.init(inst, def);
|
|
14606
14606
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
14607
14607
|
inst.removeDefault = inst.unwrap;
|
|
14608
14608
|
});
|
|
14609
14609
|
function _default(innerType, defaultValue) {
|
|
14610
|
-
return new ZodDefault({
|
|
14610
|
+
return new ZodDefault$1({
|
|
14611
14611
|
type: "default",
|
|
14612
14612
|
innerType,
|
|
14613
14613
|
get defaultValue() {
|
|
@@ -14617,7 +14617,7 @@ function _default(innerType, defaultValue) {
|
|
|
14617
14617
|
}
|
|
14618
14618
|
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
14619
14619
|
$ZodPrefault.init(inst, def);
|
|
14620
|
-
ZodType.init(inst, def);
|
|
14620
|
+
ZodType$1.init(inst, def);
|
|
14621
14621
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
14622
14622
|
});
|
|
14623
14623
|
function prefault(innerType, defaultValue) {
|
|
@@ -14631,7 +14631,7 @@ function prefault(innerType, defaultValue) {
|
|
|
14631
14631
|
}
|
|
14632
14632
|
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
14633
14633
|
$ZodNonOptional.init(inst, def);
|
|
14634
|
-
ZodType.init(inst, def);
|
|
14634
|
+
ZodType$1.init(inst, def);
|
|
14635
14635
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
14636
14636
|
});
|
|
14637
14637
|
function nonoptional(innerType, params) {
|
|
@@ -14641,14 +14641,14 @@ function nonoptional(innerType, params) {
|
|
|
14641
14641
|
...normalizeParams(params)
|
|
14642
14642
|
});
|
|
14643
14643
|
}
|
|
14644
|
-
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
14644
|
+
const ZodCatch$1 = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
14645
14645
|
$ZodCatch.init(inst, def);
|
|
14646
|
-
ZodType.init(inst, def);
|
|
14646
|
+
ZodType$1.init(inst, def);
|
|
14647
14647
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
14648
14648
|
inst.removeCatch = inst.unwrap;
|
|
14649
14649
|
});
|
|
14650
14650
|
function _catch(innerType, catchValue) {
|
|
14651
|
-
return new ZodCatch({
|
|
14651
|
+
return new ZodCatch$1({
|
|
14652
14652
|
type: "catch",
|
|
14653
14653
|
innerType,
|
|
14654
14654
|
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
@@ -14656,7 +14656,7 @@ function _catch(innerType, catchValue) {
|
|
|
14656
14656
|
}
|
|
14657
14657
|
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
14658
14658
|
$ZodPipe.init(inst, def);
|
|
14659
|
-
ZodType.init(inst, def);
|
|
14659
|
+
ZodType$1.init(inst, def);
|
|
14660
14660
|
inst.in = def.in;
|
|
14661
14661
|
inst.out = def.out;
|
|
14662
14662
|
});
|
|
@@ -14668,19 +14668,19 @@ function pipe(in_, out) {
|
|
|
14668
14668
|
// ...util.normalizeParams(params),
|
|
14669
14669
|
});
|
|
14670
14670
|
}
|
|
14671
|
-
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
14671
|
+
const ZodReadonly$1 = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
14672
14672
|
$ZodReadonly.init(inst, def);
|
|
14673
|
-
ZodType.init(inst, def);
|
|
14673
|
+
ZodType$1.init(inst, def);
|
|
14674
14674
|
});
|
|
14675
14675
|
function readonly(innerType) {
|
|
14676
|
-
return new ZodReadonly({
|
|
14676
|
+
return new ZodReadonly$1({
|
|
14677
14677
|
type: "readonly",
|
|
14678
14678
|
innerType
|
|
14679
14679
|
});
|
|
14680
14680
|
}
|
|
14681
14681
|
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
14682
14682
|
$ZodCustom.init(inst, def);
|
|
14683
|
-
ZodType.init(inst, def);
|
|
14683
|
+
ZodType$1.init(inst, def);
|
|
14684
14684
|
});
|
|
14685
14685
|
function check(fn) {
|
|
14686
14686
|
const ch = new $ZodCheck({
|
|
@@ -14719,11 +14719,11 @@ function superRefine(fn) {
|
|
|
14719
14719
|
function preprocess(fn, schema) {
|
|
14720
14720
|
return pipe(transform(fn), schema);
|
|
14721
14721
|
}
|
|
14722
|
-
const ZodIssueCode = {
|
|
14722
|
+
const ZodIssueCode$1 = {
|
|
14723
14723
|
custom: "custom"
|
|
14724
14724
|
};
|
|
14725
14725
|
function number(params) {
|
|
14726
|
-
return _coercedNumber(ZodNumber, params);
|
|
14726
|
+
return _coercedNumber(ZodNumber$1, params);
|
|
14727
14727
|
}
|
|
14728
14728
|
const LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
14729
14729
|
const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
@@ -16233,7 +16233,7 @@ class UrlElicitationRequiredError extends McpError {
|
|
|
16233
16233
|
const SafeUrlSchema = url().superRefine((val, ctx) => {
|
|
16234
16234
|
if (!URL.canParse(val)) {
|
|
16235
16235
|
ctx.addIssue({
|
|
16236
|
-
code: ZodIssueCode.custom,
|
|
16236
|
+
code: ZodIssueCode$1.custom,
|
|
16237
16237
|
message: "URL must be parseable",
|
|
16238
16238
|
fatal: true
|
|
16239
16239
|
});
|
|
@@ -16373,7 +16373,7 @@ object({
|
|
|
16373
16373
|
token_type_hint: string().optional()
|
|
16374
16374
|
}).strip();
|
|
16375
16375
|
const name = "@bryan-thompson/inspector-assessment-client";
|
|
16376
|
-
const version$1 = "1.
|
|
16376
|
+
const version$1 = "1.30.1";
|
|
16377
16377
|
const packageJson = {
|
|
16378
16378
|
name,
|
|
16379
16379
|
version: version$1
|
|
@@ -18702,12 +18702,12 @@ function requireUcs2length$1() {
|
|
|
18702
18702
|
};
|
|
18703
18703
|
return ucs2length$1;
|
|
18704
18704
|
}
|
|
18705
|
-
var util$
|
|
18705
|
+
var util$2;
|
|
18706
18706
|
var hasRequiredUtil$1;
|
|
18707
18707
|
function requireUtil$1() {
|
|
18708
|
-
if (hasRequiredUtil$1) return util$
|
|
18708
|
+
if (hasRequiredUtil$1) return util$2;
|
|
18709
18709
|
hasRequiredUtil$1 = 1;
|
|
18710
|
-
util$
|
|
18710
|
+
util$2 = {
|
|
18711
18711
|
copy,
|
|
18712
18712
|
checkDataType,
|
|
18713
18713
|
checkDataTypes,
|
|
@@ -18737,18 +18737,18 @@ function requireUtil$1() {
|
|
|
18737
18737
|
return to;
|
|
18738
18738
|
}
|
|
18739
18739
|
function checkDataType(dataType2, data2, strictNumbers, negate) {
|
|
18740
|
-
var EQUAL = negate ? " !== " : " === ", AND = negate ? " || " : " && ",
|
|
18740
|
+
var EQUAL = negate ? " !== " : " === ", AND = negate ? " || " : " && ", OK2 = negate ? "!" : "", NOT = negate ? "" : "!";
|
|
18741
18741
|
switch (dataType2) {
|
|
18742
18742
|
case "null":
|
|
18743
18743
|
return data2 + EQUAL + "null";
|
|
18744
18744
|
case "array":
|
|
18745
|
-
return
|
|
18745
|
+
return OK2 + "Array.isArray(" + data2 + ")";
|
|
18746
18746
|
case "object":
|
|
18747
|
-
return "(" +
|
|
18747
|
+
return "(" + OK2 + data2 + AND + "typeof " + data2 + EQUAL + '"object"' + AND + NOT + "Array.isArray(" + data2 + "))";
|
|
18748
18748
|
case "integer":
|
|
18749
|
-
return "(typeof " + data2 + EQUAL + '"number"' + AND + NOT + "(" + data2 + " % 1)" + AND + data2 + EQUAL + data2 + (strictNumbers ? AND +
|
|
18749
|
+
return "(typeof " + data2 + EQUAL + '"number"' + AND + NOT + "(" + data2 + " % 1)" + AND + data2 + EQUAL + data2 + (strictNumbers ? AND + OK2 + "isFinite(" + data2 + ")" : "") + ")";
|
|
18750
18750
|
case "number":
|
|
18751
|
-
return "(typeof " + data2 + EQUAL + '"' + dataType2 + '"' + (strictNumbers ? AND +
|
|
18751
|
+
return "(typeof " + data2 + EQUAL + '"' + dataType2 + '"' + (strictNumbers ? AND + OK2 + "isFinite(" + data2 + ")" : "") + ")";
|
|
18752
18752
|
default:
|
|
18753
18753
|
return "typeof " + data2 + EQUAL + '"' + dataType2 + '"';
|
|
18754
18754
|
}
|
|
@@ -18884,7 +18884,7 @@ function requireUtil$1() {
|
|
|
18884
18884
|
function unescapeJsonPointer(str) {
|
|
18885
18885
|
return str.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
18886
18886
|
}
|
|
18887
|
-
return util$
|
|
18887
|
+
return util$2;
|
|
18888
18888
|
}
|
|
18889
18889
|
var schema_obj;
|
|
18890
18890
|
var hasRequiredSchema_obj;
|
|
@@ -23684,8 +23684,8 @@ function validateToolOutput(toolName, structuredContent) {
|
|
|
23684
23684
|
if (!validator) {
|
|
23685
23685
|
return { isValid: true };
|
|
23686
23686
|
}
|
|
23687
|
-
const
|
|
23688
|
-
if (!
|
|
23687
|
+
const isValid2 = validator(structuredContent);
|
|
23688
|
+
if (!isValid2) {
|
|
23689
23689
|
return {
|
|
23690
23690
|
isValid: false,
|
|
23691
23691
|
error: ajv$1.errorsText(validator.errors)
|
|
@@ -23855,6 +23855,3578 @@ function cleanParams(params, schema) {
|
|
|
23855
23855
|
}
|
|
23856
23856
|
return cleaned;
|
|
23857
23857
|
}
|
|
23858
|
+
var util$1;
|
|
23859
|
+
(function(util2) {
|
|
23860
|
+
util2.assertEqual = (_) => {
|
|
23861
|
+
};
|
|
23862
|
+
function assertIs(_arg) {
|
|
23863
|
+
}
|
|
23864
|
+
util2.assertIs = assertIs;
|
|
23865
|
+
function assertNever(_x) {
|
|
23866
|
+
throw new Error();
|
|
23867
|
+
}
|
|
23868
|
+
util2.assertNever = assertNever;
|
|
23869
|
+
util2.arrayToEnum = (items2) => {
|
|
23870
|
+
const obj = {};
|
|
23871
|
+
for (const item of items2) {
|
|
23872
|
+
obj[item] = item;
|
|
23873
|
+
}
|
|
23874
|
+
return obj;
|
|
23875
|
+
};
|
|
23876
|
+
util2.getValidEnumValues = (obj) => {
|
|
23877
|
+
const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");
|
|
23878
|
+
const filtered = {};
|
|
23879
|
+
for (const k2 of validKeys) {
|
|
23880
|
+
filtered[k2] = obj[k2];
|
|
23881
|
+
}
|
|
23882
|
+
return util2.objectValues(filtered);
|
|
23883
|
+
};
|
|
23884
|
+
util2.objectValues = (obj) => {
|
|
23885
|
+
return util2.objectKeys(obj).map(function(e) {
|
|
23886
|
+
return obj[e];
|
|
23887
|
+
});
|
|
23888
|
+
};
|
|
23889
|
+
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
|
|
23890
|
+
const keys = [];
|
|
23891
|
+
for (const key in object2) {
|
|
23892
|
+
if (Object.prototype.hasOwnProperty.call(object2, key)) {
|
|
23893
|
+
keys.push(key);
|
|
23894
|
+
}
|
|
23895
|
+
}
|
|
23896
|
+
return keys;
|
|
23897
|
+
};
|
|
23898
|
+
util2.find = (arr, checker) => {
|
|
23899
|
+
for (const item of arr) {
|
|
23900
|
+
if (checker(item))
|
|
23901
|
+
return item;
|
|
23902
|
+
}
|
|
23903
|
+
return void 0;
|
|
23904
|
+
};
|
|
23905
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
23906
|
+
function joinValues(array2, separator = " | ") {
|
|
23907
|
+
return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
23908
|
+
}
|
|
23909
|
+
util2.joinValues = joinValues;
|
|
23910
|
+
util2.jsonStringifyReplacer = (_, value) => {
|
|
23911
|
+
if (typeof value === "bigint") {
|
|
23912
|
+
return value.toString();
|
|
23913
|
+
}
|
|
23914
|
+
return value;
|
|
23915
|
+
};
|
|
23916
|
+
})(util$1 || (util$1 = {}));
|
|
23917
|
+
var objectUtil;
|
|
23918
|
+
(function(objectUtil2) {
|
|
23919
|
+
objectUtil2.mergeShapes = (first, second) => {
|
|
23920
|
+
return {
|
|
23921
|
+
...first,
|
|
23922
|
+
...second
|
|
23923
|
+
// second overwrites first
|
|
23924
|
+
};
|
|
23925
|
+
};
|
|
23926
|
+
})(objectUtil || (objectUtil = {}));
|
|
23927
|
+
const ZodParsedType = util$1.arrayToEnum([
|
|
23928
|
+
"string",
|
|
23929
|
+
"nan",
|
|
23930
|
+
"number",
|
|
23931
|
+
"integer",
|
|
23932
|
+
"float",
|
|
23933
|
+
"boolean",
|
|
23934
|
+
"date",
|
|
23935
|
+
"bigint",
|
|
23936
|
+
"symbol",
|
|
23937
|
+
"function",
|
|
23938
|
+
"undefined",
|
|
23939
|
+
"null",
|
|
23940
|
+
"array",
|
|
23941
|
+
"object",
|
|
23942
|
+
"unknown",
|
|
23943
|
+
"promise",
|
|
23944
|
+
"void",
|
|
23945
|
+
"never",
|
|
23946
|
+
"map",
|
|
23947
|
+
"set"
|
|
23948
|
+
]);
|
|
23949
|
+
const getParsedType = (data2) => {
|
|
23950
|
+
const t = typeof data2;
|
|
23951
|
+
switch (t) {
|
|
23952
|
+
case "undefined":
|
|
23953
|
+
return ZodParsedType.undefined;
|
|
23954
|
+
case "string":
|
|
23955
|
+
return ZodParsedType.string;
|
|
23956
|
+
case "number":
|
|
23957
|
+
return Number.isNaN(data2) ? ZodParsedType.nan : ZodParsedType.number;
|
|
23958
|
+
case "boolean":
|
|
23959
|
+
return ZodParsedType.boolean;
|
|
23960
|
+
case "function":
|
|
23961
|
+
return ZodParsedType.function;
|
|
23962
|
+
case "bigint":
|
|
23963
|
+
return ZodParsedType.bigint;
|
|
23964
|
+
case "symbol":
|
|
23965
|
+
return ZodParsedType.symbol;
|
|
23966
|
+
case "object":
|
|
23967
|
+
if (Array.isArray(data2)) {
|
|
23968
|
+
return ZodParsedType.array;
|
|
23969
|
+
}
|
|
23970
|
+
if (data2 === null) {
|
|
23971
|
+
return ZodParsedType.null;
|
|
23972
|
+
}
|
|
23973
|
+
if (data2.then && typeof data2.then === "function" && data2.catch && typeof data2.catch === "function") {
|
|
23974
|
+
return ZodParsedType.promise;
|
|
23975
|
+
}
|
|
23976
|
+
if (typeof Map !== "undefined" && data2 instanceof Map) {
|
|
23977
|
+
return ZodParsedType.map;
|
|
23978
|
+
}
|
|
23979
|
+
if (typeof Set !== "undefined" && data2 instanceof Set) {
|
|
23980
|
+
return ZodParsedType.set;
|
|
23981
|
+
}
|
|
23982
|
+
if (typeof Date !== "undefined" && data2 instanceof Date) {
|
|
23983
|
+
return ZodParsedType.date;
|
|
23984
|
+
}
|
|
23985
|
+
return ZodParsedType.object;
|
|
23986
|
+
default:
|
|
23987
|
+
return ZodParsedType.unknown;
|
|
23988
|
+
}
|
|
23989
|
+
};
|
|
23990
|
+
const ZodIssueCode = util$1.arrayToEnum([
|
|
23991
|
+
"invalid_type",
|
|
23992
|
+
"invalid_literal",
|
|
23993
|
+
"custom",
|
|
23994
|
+
"invalid_union",
|
|
23995
|
+
"invalid_union_discriminator",
|
|
23996
|
+
"invalid_enum_value",
|
|
23997
|
+
"unrecognized_keys",
|
|
23998
|
+
"invalid_arguments",
|
|
23999
|
+
"invalid_return_type",
|
|
24000
|
+
"invalid_date",
|
|
24001
|
+
"invalid_string",
|
|
24002
|
+
"too_small",
|
|
24003
|
+
"too_big",
|
|
24004
|
+
"invalid_intersection_types",
|
|
24005
|
+
"not_multiple_of",
|
|
24006
|
+
"not_finite"
|
|
24007
|
+
]);
|
|
24008
|
+
class ZodError extends Error {
|
|
24009
|
+
get errors() {
|
|
24010
|
+
return this.issues;
|
|
24011
|
+
}
|
|
24012
|
+
constructor(issues) {
|
|
24013
|
+
super();
|
|
24014
|
+
this.issues = [];
|
|
24015
|
+
this.addIssue = (sub) => {
|
|
24016
|
+
this.issues = [...this.issues, sub];
|
|
24017
|
+
};
|
|
24018
|
+
this.addIssues = (subs = []) => {
|
|
24019
|
+
this.issues = [...this.issues, ...subs];
|
|
24020
|
+
};
|
|
24021
|
+
const actualProto = new.target.prototype;
|
|
24022
|
+
if (Object.setPrototypeOf) {
|
|
24023
|
+
Object.setPrototypeOf(this, actualProto);
|
|
24024
|
+
} else {
|
|
24025
|
+
this.__proto__ = actualProto;
|
|
24026
|
+
}
|
|
24027
|
+
this.name = "ZodError";
|
|
24028
|
+
this.issues = issues;
|
|
24029
|
+
}
|
|
24030
|
+
format(_mapper) {
|
|
24031
|
+
const mapper = _mapper || function(issue2) {
|
|
24032
|
+
return issue2.message;
|
|
24033
|
+
};
|
|
24034
|
+
const fieldErrors = { _errors: [] };
|
|
24035
|
+
const processError = (error) => {
|
|
24036
|
+
for (const issue2 of error.issues) {
|
|
24037
|
+
if (issue2.code === "invalid_union") {
|
|
24038
|
+
issue2.unionErrors.map(processError);
|
|
24039
|
+
} else if (issue2.code === "invalid_return_type") {
|
|
24040
|
+
processError(issue2.returnTypeError);
|
|
24041
|
+
} else if (issue2.code === "invalid_arguments") {
|
|
24042
|
+
processError(issue2.argumentsError);
|
|
24043
|
+
} else if (issue2.path.length === 0) {
|
|
24044
|
+
fieldErrors._errors.push(mapper(issue2));
|
|
24045
|
+
} else {
|
|
24046
|
+
let curr = fieldErrors;
|
|
24047
|
+
let i = 0;
|
|
24048
|
+
while (i < issue2.path.length) {
|
|
24049
|
+
const el = issue2.path[i];
|
|
24050
|
+
const terminal = i === issue2.path.length - 1;
|
|
24051
|
+
if (!terminal) {
|
|
24052
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
24053
|
+
} else {
|
|
24054
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
24055
|
+
curr[el]._errors.push(mapper(issue2));
|
|
24056
|
+
}
|
|
24057
|
+
curr = curr[el];
|
|
24058
|
+
i++;
|
|
24059
|
+
}
|
|
24060
|
+
}
|
|
24061
|
+
}
|
|
24062
|
+
};
|
|
24063
|
+
processError(this);
|
|
24064
|
+
return fieldErrors;
|
|
24065
|
+
}
|
|
24066
|
+
static assert(value) {
|
|
24067
|
+
if (!(value instanceof ZodError)) {
|
|
24068
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
24069
|
+
}
|
|
24070
|
+
}
|
|
24071
|
+
toString() {
|
|
24072
|
+
return this.message;
|
|
24073
|
+
}
|
|
24074
|
+
get message() {
|
|
24075
|
+
return JSON.stringify(this.issues, util$1.jsonStringifyReplacer, 2);
|
|
24076
|
+
}
|
|
24077
|
+
get isEmpty() {
|
|
24078
|
+
return this.issues.length === 0;
|
|
24079
|
+
}
|
|
24080
|
+
flatten(mapper = (issue2) => issue2.message) {
|
|
24081
|
+
const fieldErrors = {};
|
|
24082
|
+
const formErrors = [];
|
|
24083
|
+
for (const sub of this.issues) {
|
|
24084
|
+
if (sub.path.length > 0) {
|
|
24085
|
+
const firstEl = sub.path[0];
|
|
24086
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
24087
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
24088
|
+
} else {
|
|
24089
|
+
formErrors.push(mapper(sub));
|
|
24090
|
+
}
|
|
24091
|
+
}
|
|
24092
|
+
return { formErrors, fieldErrors };
|
|
24093
|
+
}
|
|
24094
|
+
get formErrors() {
|
|
24095
|
+
return this.flatten();
|
|
24096
|
+
}
|
|
24097
|
+
}
|
|
24098
|
+
ZodError.create = (issues) => {
|
|
24099
|
+
const error = new ZodError(issues);
|
|
24100
|
+
return error;
|
|
24101
|
+
};
|
|
24102
|
+
const errorMap = (issue2, _ctx) => {
|
|
24103
|
+
let message;
|
|
24104
|
+
switch (issue2.code) {
|
|
24105
|
+
case ZodIssueCode.invalid_type:
|
|
24106
|
+
if (issue2.received === ZodParsedType.undefined) {
|
|
24107
|
+
message = "Required";
|
|
24108
|
+
} else {
|
|
24109
|
+
message = `Expected ${issue2.expected}, received ${issue2.received}`;
|
|
24110
|
+
}
|
|
24111
|
+
break;
|
|
24112
|
+
case ZodIssueCode.invalid_literal:
|
|
24113
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue2.expected, util$1.jsonStringifyReplacer)}`;
|
|
24114
|
+
break;
|
|
24115
|
+
case ZodIssueCode.unrecognized_keys:
|
|
24116
|
+
message = `Unrecognized key(s) in object: ${util$1.joinValues(issue2.keys, ", ")}`;
|
|
24117
|
+
break;
|
|
24118
|
+
case ZodIssueCode.invalid_union:
|
|
24119
|
+
message = `Invalid input`;
|
|
24120
|
+
break;
|
|
24121
|
+
case ZodIssueCode.invalid_union_discriminator:
|
|
24122
|
+
message = `Invalid discriminator value. Expected ${util$1.joinValues(issue2.options)}`;
|
|
24123
|
+
break;
|
|
24124
|
+
case ZodIssueCode.invalid_enum_value:
|
|
24125
|
+
message = `Invalid enum value. Expected ${util$1.joinValues(issue2.options)}, received '${issue2.received}'`;
|
|
24126
|
+
break;
|
|
24127
|
+
case ZodIssueCode.invalid_arguments:
|
|
24128
|
+
message = `Invalid function arguments`;
|
|
24129
|
+
break;
|
|
24130
|
+
case ZodIssueCode.invalid_return_type:
|
|
24131
|
+
message = `Invalid function return type`;
|
|
24132
|
+
break;
|
|
24133
|
+
case ZodIssueCode.invalid_date:
|
|
24134
|
+
message = `Invalid date`;
|
|
24135
|
+
break;
|
|
24136
|
+
case ZodIssueCode.invalid_string:
|
|
24137
|
+
if (typeof issue2.validation === "object") {
|
|
24138
|
+
if ("includes" in issue2.validation) {
|
|
24139
|
+
message = `Invalid input: must include "${issue2.validation.includes}"`;
|
|
24140
|
+
if (typeof issue2.validation.position === "number") {
|
|
24141
|
+
message = `${message} at one or more positions greater than or equal to ${issue2.validation.position}`;
|
|
24142
|
+
}
|
|
24143
|
+
} else if ("startsWith" in issue2.validation) {
|
|
24144
|
+
message = `Invalid input: must start with "${issue2.validation.startsWith}"`;
|
|
24145
|
+
} else if ("endsWith" in issue2.validation) {
|
|
24146
|
+
message = `Invalid input: must end with "${issue2.validation.endsWith}"`;
|
|
24147
|
+
} else {
|
|
24148
|
+
util$1.assertNever(issue2.validation);
|
|
24149
|
+
}
|
|
24150
|
+
} else if (issue2.validation !== "regex") {
|
|
24151
|
+
message = `Invalid ${issue2.validation}`;
|
|
24152
|
+
} else {
|
|
24153
|
+
message = "Invalid";
|
|
24154
|
+
}
|
|
24155
|
+
break;
|
|
24156
|
+
case ZodIssueCode.too_small:
|
|
24157
|
+
if (issue2.type === "array")
|
|
24158
|
+
message = `Array must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `more than`} ${issue2.minimum} element(s)`;
|
|
24159
|
+
else if (issue2.type === "string")
|
|
24160
|
+
message = `String must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `over`} ${issue2.minimum} character(s)`;
|
|
24161
|
+
else if (issue2.type === "number")
|
|
24162
|
+
message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
|
|
24163
|
+
else if (issue2.type === "bigint")
|
|
24164
|
+
message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
|
|
24165
|
+
else if (issue2.type === "date")
|
|
24166
|
+
message = `Date must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue2.minimum))}`;
|
|
24167
|
+
else
|
|
24168
|
+
message = "Invalid input";
|
|
24169
|
+
break;
|
|
24170
|
+
case ZodIssueCode.too_big:
|
|
24171
|
+
if (issue2.type === "array")
|
|
24172
|
+
message = `Array must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `less than`} ${issue2.maximum} element(s)`;
|
|
24173
|
+
else if (issue2.type === "string")
|
|
24174
|
+
message = `String must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `under`} ${issue2.maximum} character(s)`;
|
|
24175
|
+
else if (issue2.type === "number")
|
|
24176
|
+
message = `Number must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
|
|
24177
|
+
else if (issue2.type === "bigint")
|
|
24178
|
+
message = `BigInt must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
|
|
24179
|
+
else if (issue2.type === "date")
|
|
24180
|
+
message = `Date must be ${issue2.exact ? `exactly` : issue2.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue2.maximum))}`;
|
|
24181
|
+
else
|
|
24182
|
+
message = "Invalid input";
|
|
24183
|
+
break;
|
|
24184
|
+
case ZodIssueCode.custom:
|
|
24185
|
+
message = `Invalid input`;
|
|
24186
|
+
break;
|
|
24187
|
+
case ZodIssueCode.invalid_intersection_types:
|
|
24188
|
+
message = `Intersection results could not be merged`;
|
|
24189
|
+
break;
|
|
24190
|
+
case ZodIssueCode.not_multiple_of:
|
|
24191
|
+
message = `Number must be a multiple of ${issue2.multipleOf}`;
|
|
24192
|
+
break;
|
|
24193
|
+
case ZodIssueCode.not_finite:
|
|
24194
|
+
message = "Number must be finite";
|
|
24195
|
+
break;
|
|
24196
|
+
default:
|
|
24197
|
+
message = _ctx.defaultError;
|
|
24198
|
+
util$1.assertNever(issue2);
|
|
24199
|
+
}
|
|
24200
|
+
return { message };
|
|
24201
|
+
};
|
|
24202
|
+
let overrideErrorMap = errorMap;
|
|
24203
|
+
function getErrorMap() {
|
|
24204
|
+
return overrideErrorMap;
|
|
24205
|
+
}
|
|
24206
|
+
const makeIssue = (params) => {
|
|
24207
|
+
const { data: data2, path, errorMaps, issueData } = params;
|
|
24208
|
+
const fullPath = [...path, ...issueData.path || []];
|
|
24209
|
+
const fullIssue = {
|
|
24210
|
+
...issueData,
|
|
24211
|
+
path: fullPath
|
|
24212
|
+
};
|
|
24213
|
+
if (issueData.message !== void 0) {
|
|
24214
|
+
return {
|
|
24215
|
+
...issueData,
|
|
24216
|
+
path: fullPath,
|
|
24217
|
+
message: issueData.message
|
|
24218
|
+
};
|
|
24219
|
+
}
|
|
24220
|
+
let errorMessage = "";
|
|
24221
|
+
const maps = errorMaps.filter((m2) => !!m2).slice().reverse();
|
|
24222
|
+
for (const map of maps) {
|
|
24223
|
+
errorMessage = map(fullIssue, { data: data2, defaultError: errorMessage }).message;
|
|
24224
|
+
}
|
|
24225
|
+
return {
|
|
24226
|
+
...issueData,
|
|
24227
|
+
path: fullPath,
|
|
24228
|
+
message: errorMessage
|
|
24229
|
+
};
|
|
24230
|
+
};
|
|
24231
|
+
function addIssueToContext(ctx, issueData) {
|
|
24232
|
+
const overrideMap = getErrorMap();
|
|
24233
|
+
const issue2 = makeIssue({
|
|
24234
|
+
issueData,
|
|
24235
|
+
data: ctx.data,
|
|
24236
|
+
path: ctx.path,
|
|
24237
|
+
errorMaps: [
|
|
24238
|
+
ctx.common.contextualErrorMap,
|
|
24239
|
+
// contextual error map is first priority
|
|
24240
|
+
ctx.schemaErrorMap,
|
|
24241
|
+
// then schema-bound map if available
|
|
24242
|
+
overrideMap,
|
|
24243
|
+
// then global override map
|
|
24244
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
24245
|
+
// then global default map
|
|
24246
|
+
].filter((x) => !!x)
|
|
24247
|
+
});
|
|
24248
|
+
ctx.common.issues.push(issue2);
|
|
24249
|
+
}
|
|
24250
|
+
class ParseStatus {
|
|
24251
|
+
constructor() {
|
|
24252
|
+
this.value = "valid";
|
|
24253
|
+
}
|
|
24254
|
+
dirty() {
|
|
24255
|
+
if (this.value === "valid")
|
|
24256
|
+
this.value = "dirty";
|
|
24257
|
+
}
|
|
24258
|
+
abort() {
|
|
24259
|
+
if (this.value !== "aborted")
|
|
24260
|
+
this.value = "aborted";
|
|
24261
|
+
}
|
|
24262
|
+
static mergeArray(status, results) {
|
|
24263
|
+
const arrayValue = [];
|
|
24264
|
+
for (const s of results) {
|
|
24265
|
+
if (s.status === "aborted")
|
|
24266
|
+
return INVALID;
|
|
24267
|
+
if (s.status === "dirty")
|
|
24268
|
+
status.dirty();
|
|
24269
|
+
arrayValue.push(s.value);
|
|
24270
|
+
}
|
|
24271
|
+
return { status: status.value, value: arrayValue };
|
|
24272
|
+
}
|
|
24273
|
+
static async mergeObjectAsync(status, pairs) {
|
|
24274
|
+
const syncPairs = [];
|
|
24275
|
+
for (const pair of pairs) {
|
|
24276
|
+
const key = await pair.key;
|
|
24277
|
+
const value = await pair.value;
|
|
24278
|
+
syncPairs.push({
|
|
24279
|
+
key,
|
|
24280
|
+
value
|
|
24281
|
+
});
|
|
24282
|
+
}
|
|
24283
|
+
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
24284
|
+
}
|
|
24285
|
+
static mergeObjectSync(status, pairs) {
|
|
24286
|
+
const finalObject = {};
|
|
24287
|
+
for (const pair of pairs) {
|
|
24288
|
+
const { key, value } = pair;
|
|
24289
|
+
if (key.status === "aborted")
|
|
24290
|
+
return INVALID;
|
|
24291
|
+
if (value.status === "aborted")
|
|
24292
|
+
return INVALID;
|
|
24293
|
+
if (key.status === "dirty")
|
|
24294
|
+
status.dirty();
|
|
24295
|
+
if (value.status === "dirty")
|
|
24296
|
+
status.dirty();
|
|
24297
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
24298
|
+
finalObject[key.value] = value.value;
|
|
24299
|
+
}
|
|
24300
|
+
}
|
|
24301
|
+
return { status: status.value, value: finalObject };
|
|
24302
|
+
}
|
|
24303
|
+
}
|
|
24304
|
+
const INVALID = Object.freeze({
|
|
24305
|
+
status: "aborted"
|
|
24306
|
+
});
|
|
24307
|
+
const DIRTY = (value) => ({ status: "dirty", value });
|
|
24308
|
+
const OK = (value) => ({ status: "valid", value });
|
|
24309
|
+
const isAborted = (x) => x.status === "aborted";
|
|
24310
|
+
const isDirty = (x) => x.status === "dirty";
|
|
24311
|
+
const isValid = (x) => x.status === "valid";
|
|
24312
|
+
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
24313
|
+
var errorUtil;
|
|
24314
|
+
(function(errorUtil2) {
|
|
24315
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
24316
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
24317
|
+
})(errorUtil || (errorUtil = {}));
|
|
24318
|
+
class ParseInputLazyPath {
|
|
24319
|
+
constructor(parent, value, path, key) {
|
|
24320
|
+
this._cachedPath = [];
|
|
24321
|
+
this.parent = parent;
|
|
24322
|
+
this.data = value;
|
|
24323
|
+
this._path = path;
|
|
24324
|
+
this._key = key;
|
|
24325
|
+
}
|
|
24326
|
+
get path() {
|
|
24327
|
+
if (!this._cachedPath.length) {
|
|
24328
|
+
if (Array.isArray(this._key)) {
|
|
24329
|
+
this._cachedPath.push(...this._path, ...this._key);
|
|
24330
|
+
} else {
|
|
24331
|
+
this._cachedPath.push(...this._path, this._key);
|
|
24332
|
+
}
|
|
24333
|
+
}
|
|
24334
|
+
return this._cachedPath;
|
|
24335
|
+
}
|
|
24336
|
+
}
|
|
24337
|
+
const handleResult = (ctx, result) => {
|
|
24338
|
+
if (isValid(result)) {
|
|
24339
|
+
return { success: true, data: result.value };
|
|
24340
|
+
} else {
|
|
24341
|
+
if (!ctx.common.issues.length) {
|
|
24342
|
+
throw new Error("Validation failed but no issues detected.");
|
|
24343
|
+
}
|
|
24344
|
+
return {
|
|
24345
|
+
success: false,
|
|
24346
|
+
get error() {
|
|
24347
|
+
if (this._error)
|
|
24348
|
+
return this._error;
|
|
24349
|
+
const error = new ZodError(ctx.common.issues);
|
|
24350
|
+
this._error = error;
|
|
24351
|
+
return this._error;
|
|
24352
|
+
}
|
|
24353
|
+
};
|
|
24354
|
+
}
|
|
24355
|
+
};
|
|
24356
|
+
function processCreateParams(params) {
|
|
24357
|
+
if (!params)
|
|
24358
|
+
return {};
|
|
24359
|
+
const { errorMap: errorMap2, invalid_type_error, required_error, description: description2 } = params;
|
|
24360
|
+
if (errorMap2 && (invalid_type_error || required_error)) {
|
|
24361
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
24362
|
+
}
|
|
24363
|
+
if (errorMap2)
|
|
24364
|
+
return { errorMap: errorMap2, description: description2 };
|
|
24365
|
+
const customMap = (iss, ctx) => {
|
|
24366
|
+
const { message } = params;
|
|
24367
|
+
if (iss.code === "invalid_enum_value") {
|
|
24368
|
+
return { message: message ?? ctx.defaultError };
|
|
24369
|
+
}
|
|
24370
|
+
if (typeof ctx.data === "undefined") {
|
|
24371
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
24372
|
+
}
|
|
24373
|
+
if (iss.code !== "invalid_type")
|
|
24374
|
+
return { message: ctx.defaultError };
|
|
24375
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
24376
|
+
};
|
|
24377
|
+
return { errorMap: customMap, description: description2 };
|
|
24378
|
+
}
|
|
24379
|
+
class ZodType {
|
|
24380
|
+
get description() {
|
|
24381
|
+
return this._def.description;
|
|
24382
|
+
}
|
|
24383
|
+
_getType(input) {
|
|
24384
|
+
return getParsedType(input.data);
|
|
24385
|
+
}
|
|
24386
|
+
_getOrReturnCtx(input, ctx) {
|
|
24387
|
+
return ctx || {
|
|
24388
|
+
common: input.parent.common,
|
|
24389
|
+
data: input.data,
|
|
24390
|
+
parsedType: getParsedType(input.data),
|
|
24391
|
+
schemaErrorMap: this._def.errorMap,
|
|
24392
|
+
path: input.path,
|
|
24393
|
+
parent: input.parent
|
|
24394
|
+
};
|
|
24395
|
+
}
|
|
24396
|
+
_processInputParams(input) {
|
|
24397
|
+
return {
|
|
24398
|
+
status: new ParseStatus(),
|
|
24399
|
+
ctx: {
|
|
24400
|
+
common: input.parent.common,
|
|
24401
|
+
data: input.data,
|
|
24402
|
+
parsedType: getParsedType(input.data),
|
|
24403
|
+
schemaErrorMap: this._def.errorMap,
|
|
24404
|
+
path: input.path,
|
|
24405
|
+
parent: input.parent
|
|
24406
|
+
}
|
|
24407
|
+
};
|
|
24408
|
+
}
|
|
24409
|
+
_parseSync(input) {
|
|
24410
|
+
const result = this._parse(input);
|
|
24411
|
+
if (isAsync(result)) {
|
|
24412
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
24413
|
+
}
|
|
24414
|
+
return result;
|
|
24415
|
+
}
|
|
24416
|
+
_parseAsync(input) {
|
|
24417
|
+
const result = this._parse(input);
|
|
24418
|
+
return Promise.resolve(result);
|
|
24419
|
+
}
|
|
24420
|
+
parse(data2, params) {
|
|
24421
|
+
const result = this.safeParse(data2, params);
|
|
24422
|
+
if (result.success)
|
|
24423
|
+
return result.data;
|
|
24424
|
+
throw result.error;
|
|
24425
|
+
}
|
|
24426
|
+
safeParse(data2, params) {
|
|
24427
|
+
const ctx = {
|
|
24428
|
+
common: {
|
|
24429
|
+
issues: [],
|
|
24430
|
+
async: params?.async ?? false,
|
|
24431
|
+
contextualErrorMap: params?.errorMap
|
|
24432
|
+
},
|
|
24433
|
+
path: params?.path || [],
|
|
24434
|
+
schemaErrorMap: this._def.errorMap,
|
|
24435
|
+
parent: null,
|
|
24436
|
+
data: data2,
|
|
24437
|
+
parsedType: getParsedType(data2)
|
|
24438
|
+
};
|
|
24439
|
+
const result = this._parseSync({ data: data2, path: ctx.path, parent: ctx });
|
|
24440
|
+
return handleResult(ctx, result);
|
|
24441
|
+
}
|
|
24442
|
+
"~validate"(data2) {
|
|
24443
|
+
const ctx = {
|
|
24444
|
+
common: {
|
|
24445
|
+
issues: [],
|
|
24446
|
+
async: !!this["~standard"].async
|
|
24447
|
+
},
|
|
24448
|
+
path: [],
|
|
24449
|
+
schemaErrorMap: this._def.errorMap,
|
|
24450
|
+
parent: null,
|
|
24451
|
+
data: data2,
|
|
24452
|
+
parsedType: getParsedType(data2)
|
|
24453
|
+
};
|
|
24454
|
+
if (!this["~standard"].async) {
|
|
24455
|
+
try {
|
|
24456
|
+
const result = this._parseSync({ data: data2, path: [], parent: ctx });
|
|
24457
|
+
return isValid(result) ? {
|
|
24458
|
+
value: result.value
|
|
24459
|
+
} : {
|
|
24460
|
+
issues: ctx.common.issues
|
|
24461
|
+
};
|
|
24462
|
+
} catch (err) {
|
|
24463
|
+
if (err?.message?.toLowerCase()?.includes("encountered")) {
|
|
24464
|
+
this["~standard"].async = true;
|
|
24465
|
+
}
|
|
24466
|
+
ctx.common = {
|
|
24467
|
+
issues: [],
|
|
24468
|
+
async: true
|
|
24469
|
+
};
|
|
24470
|
+
}
|
|
24471
|
+
}
|
|
24472
|
+
return this._parseAsync({ data: data2, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
24473
|
+
value: result.value
|
|
24474
|
+
} : {
|
|
24475
|
+
issues: ctx.common.issues
|
|
24476
|
+
});
|
|
24477
|
+
}
|
|
24478
|
+
async parseAsync(data2, params) {
|
|
24479
|
+
const result = await this.safeParseAsync(data2, params);
|
|
24480
|
+
if (result.success)
|
|
24481
|
+
return result.data;
|
|
24482
|
+
throw result.error;
|
|
24483
|
+
}
|
|
24484
|
+
async safeParseAsync(data2, params) {
|
|
24485
|
+
const ctx = {
|
|
24486
|
+
common: {
|
|
24487
|
+
issues: [],
|
|
24488
|
+
contextualErrorMap: params?.errorMap,
|
|
24489
|
+
async: true
|
|
24490
|
+
},
|
|
24491
|
+
path: params?.path || [],
|
|
24492
|
+
schemaErrorMap: this._def.errorMap,
|
|
24493
|
+
parent: null,
|
|
24494
|
+
data: data2,
|
|
24495
|
+
parsedType: getParsedType(data2)
|
|
24496
|
+
};
|
|
24497
|
+
const maybeAsyncResult = this._parse({ data: data2, path: ctx.path, parent: ctx });
|
|
24498
|
+
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
24499
|
+
return handleResult(ctx, result);
|
|
24500
|
+
}
|
|
24501
|
+
refine(check2, message) {
|
|
24502
|
+
const getIssueProperties = (val) => {
|
|
24503
|
+
if (typeof message === "string" || typeof message === "undefined") {
|
|
24504
|
+
return { message };
|
|
24505
|
+
} else if (typeof message === "function") {
|
|
24506
|
+
return message(val);
|
|
24507
|
+
} else {
|
|
24508
|
+
return message;
|
|
24509
|
+
}
|
|
24510
|
+
};
|
|
24511
|
+
return this._refinement((val, ctx) => {
|
|
24512
|
+
const result = check2(val);
|
|
24513
|
+
const setError = () => ctx.addIssue({
|
|
24514
|
+
code: ZodIssueCode.custom,
|
|
24515
|
+
...getIssueProperties(val)
|
|
24516
|
+
});
|
|
24517
|
+
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
|
24518
|
+
return result.then((data2) => {
|
|
24519
|
+
if (!data2) {
|
|
24520
|
+
setError();
|
|
24521
|
+
return false;
|
|
24522
|
+
} else {
|
|
24523
|
+
return true;
|
|
24524
|
+
}
|
|
24525
|
+
});
|
|
24526
|
+
}
|
|
24527
|
+
if (!result) {
|
|
24528
|
+
setError();
|
|
24529
|
+
return false;
|
|
24530
|
+
} else {
|
|
24531
|
+
return true;
|
|
24532
|
+
}
|
|
24533
|
+
});
|
|
24534
|
+
}
|
|
24535
|
+
refinement(check2, refinementData) {
|
|
24536
|
+
return this._refinement((val, ctx) => {
|
|
24537
|
+
if (!check2(val)) {
|
|
24538
|
+
ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
|
|
24539
|
+
return false;
|
|
24540
|
+
} else {
|
|
24541
|
+
return true;
|
|
24542
|
+
}
|
|
24543
|
+
});
|
|
24544
|
+
}
|
|
24545
|
+
_refinement(refinement) {
|
|
24546
|
+
return new ZodEffects({
|
|
24547
|
+
schema: this,
|
|
24548
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
24549
|
+
effect: { type: "refinement", refinement }
|
|
24550
|
+
});
|
|
24551
|
+
}
|
|
24552
|
+
superRefine(refinement) {
|
|
24553
|
+
return this._refinement(refinement);
|
|
24554
|
+
}
|
|
24555
|
+
constructor(def) {
|
|
24556
|
+
this.spa = this.safeParseAsync;
|
|
24557
|
+
this._def = def;
|
|
24558
|
+
this.parse = this.parse.bind(this);
|
|
24559
|
+
this.safeParse = this.safeParse.bind(this);
|
|
24560
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
24561
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
24562
|
+
this.spa = this.spa.bind(this);
|
|
24563
|
+
this.refine = this.refine.bind(this);
|
|
24564
|
+
this.refinement = this.refinement.bind(this);
|
|
24565
|
+
this.superRefine = this.superRefine.bind(this);
|
|
24566
|
+
this.optional = this.optional.bind(this);
|
|
24567
|
+
this.nullable = this.nullable.bind(this);
|
|
24568
|
+
this.nullish = this.nullish.bind(this);
|
|
24569
|
+
this.array = this.array.bind(this);
|
|
24570
|
+
this.promise = this.promise.bind(this);
|
|
24571
|
+
this.or = this.or.bind(this);
|
|
24572
|
+
this.and = this.and.bind(this);
|
|
24573
|
+
this.transform = this.transform.bind(this);
|
|
24574
|
+
this.brand = this.brand.bind(this);
|
|
24575
|
+
this.default = this.default.bind(this);
|
|
24576
|
+
this.catch = this.catch.bind(this);
|
|
24577
|
+
this.describe = this.describe.bind(this);
|
|
24578
|
+
this.pipe = this.pipe.bind(this);
|
|
24579
|
+
this.readonly = this.readonly.bind(this);
|
|
24580
|
+
this.isNullable = this.isNullable.bind(this);
|
|
24581
|
+
this.isOptional = this.isOptional.bind(this);
|
|
24582
|
+
this["~standard"] = {
|
|
24583
|
+
version: 1,
|
|
24584
|
+
vendor: "zod",
|
|
24585
|
+
validate: (data2) => this["~validate"](data2)
|
|
24586
|
+
};
|
|
24587
|
+
}
|
|
24588
|
+
optional() {
|
|
24589
|
+
return ZodOptional.create(this, this._def);
|
|
24590
|
+
}
|
|
24591
|
+
nullable() {
|
|
24592
|
+
return ZodNullable.create(this, this._def);
|
|
24593
|
+
}
|
|
24594
|
+
nullish() {
|
|
24595
|
+
return this.nullable().optional();
|
|
24596
|
+
}
|
|
24597
|
+
array() {
|
|
24598
|
+
return ZodArray.create(this);
|
|
24599
|
+
}
|
|
24600
|
+
promise() {
|
|
24601
|
+
return ZodPromise.create(this, this._def);
|
|
24602
|
+
}
|
|
24603
|
+
or(option) {
|
|
24604
|
+
return ZodUnion.create([this, option], this._def);
|
|
24605
|
+
}
|
|
24606
|
+
and(incoming) {
|
|
24607
|
+
return ZodIntersection.create(this, incoming, this._def);
|
|
24608
|
+
}
|
|
24609
|
+
transform(transform2) {
|
|
24610
|
+
return new ZodEffects({
|
|
24611
|
+
...processCreateParams(this._def),
|
|
24612
|
+
schema: this,
|
|
24613
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
24614
|
+
effect: { type: "transform", transform: transform2 }
|
|
24615
|
+
});
|
|
24616
|
+
}
|
|
24617
|
+
default(def) {
|
|
24618
|
+
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
24619
|
+
return new ZodDefault({
|
|
24620
|
+
...processCreateParams(this._def),
|
|
24621
|
+
innerType: this,
|
|
24622
|
+
defaultValue: defaultValueFunc,
|
|
24623
|
+
typeName: ZodFirstPartyTypeKind.ZodDefault
|
|
24624
|
+
});
|
|
24625
|
+
}
|
|
24626
|
+
brand() {
|
|
24627
|
+
return new ZodBranded({
|
|
24628
|
+
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
24629
|
+
type: this,
|
|
24630
|
+
...processCreateParams(this._def)
|
|
24631
|
+
});
|
|
24632
|
+
}
|
|
24633
|
+
catch(def) {
|
|
24634
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
24635
|
+
return new ZodCatch({
|
|
24636
|
+
...processCreateParams(this._def),
|
|
24637
|
+
innerType: this,
|
|
24638
|
+
catchValue: catchValueFunc,
|
|
24639
|
+
typeName: ZodFirstPartyTypeKind.ZodCatch
|
|
24640
|
+
});
|
|
24641
|
+
}
|
|
24642
|
+
describe(description2) {
|
|
24643
|
+
const This = this.constructor;
|
|
24644
|
+
return new This({
|
|
24645
|
+
...this._def,
|
|
24646
|
+
description: description2
|
|
24647
|
+
});
|
|
24648
|
+
}
|
|
24649
|
+
pipe(target) {
|
|
24650
|
+
return ZodPipeline.create(this, target);
|
|
24651
|
+
}
|
|
24652
|
+
readonly() {
|
|
24653
|
+
return ZodReadonly.create(this);
|
|
24654
|
+
}
|
|
24655
|
+
isOptional() {
|
|
24656
|
+
return this.safeParse(void 0).success;
|
|
24657
|
+
}
|
|
24658
|
+
isNullable() {
|
|
24659
|
+
return this.safeParse(null).success;
|
|
24660
|
+
}
|
|
24661
|
+
}
|
|
24662
|
+
const cuidRegex = /^c[^\s-]{8,}$/i;
|
|
24663
|
+
const cuid2Regex = /^[0-9a-z]+$/;
|
|
24664
|
+
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
24665
|
+
const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
24666
|
+
const nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
24667
|
+
const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
24668
|
+
const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
24669
|
+
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
24670
|
+
const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
24671
|
+
let emojiRegex;
|
|
24672
|
+
const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
24673
|
+
const ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
|
|
24674
|
+
const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
24675
|
+
const ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
24676
|
+
const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
24677
|
+
const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
24678
|
+
const dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
24679
|
+
const dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
24680
|
+
function timeRegexSource(args) {
|
|
24681
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
24682
|
+
if (args.precision) {
|
|
24683
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
24684
|
+
} else if (args.precision == null) {
|
|
24685
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
24686
|
+
}
|
|
24687
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
24688
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
24689
|
+
}
|
|
24690
|
+
function timeRegex(args) {
|
|
24691
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
24692
|
+
}
|
|
24693
|
+
function datetimeRegex(args) {
|
|
24694
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
24695
|
+
const opts = [];
|
|
24696
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
24697
|
+
if (args.offset)
|
|
24698
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
24699
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
24700
|
+
return new RegExp(`^${regex}$`);
|
|
24701
|
+
}
|
|
24702
|
+
function isValidIP(ip, version2) {
|
|
24703
|
+
if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
|
|
24704
|
+
return true;
|
|
24705
|
+
}
|
|
24706
|
+
if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
|
|
24707
|
+
return true;
|
|
24708
|
+
}
|
|
24709
|
+
return false;
|
|
24710
|
+
}
|
|
24711
|
+
function isValidJWT(jwt, alg) {
|
|
24712
|
+
if (!jwtRegex.test(jwt))
|
|
24713
|
+
return false;
|
|
24714
|
+
try {
|
|
24715
|
+
const [header] = jwt.split(".");
|
|
24716
|
+
if (!header)
|
|
24717
|
+
return false;
|
|
24718
|
+
const base642 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
24719
|
+
const decoded = JSON.parse(atob(base642));
|
|
24720
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
24721
|
+
return false;
|
|
24722
|
+
if ("typ" in decoded && decoded?.typ !== "JWT")
|
|
24723
|
+
return false;
|
|
24724
|
+
if (!decoded.alg)
|
|
24725
|
+
return false;
|
|
24726
|
+
if (alg && decoded.alg !== alg)
|
|
24727
|
+
return false;
|
|
24728
|
+
return true;
|
|
24729
|
+
} catch {
|
|
24730
|
+
return false;
|
|
24731
|
+
}
|
|
24732
|
+
}
|
|
24733
|
+
function isValidCidr(ip, version2) {
|
|
24734
|
+
if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
|
|
24735
|
+
return true;
|
|
24736
|
+
}
|
|
24737
|
+
if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
|
|
24738
|
+
return true;
|
|
24739
|
+
}
|
|
24740
|
+
return false;
|
|
24741
|
+
}
|
|
24742
|
+
class ZodString extends ZodType {
|
|
24743
|
+
_parse(input) {
|
|
24744
|
+
if (this._def.coerce) {
|
|
24745
|
+
input.data = String(input.data);
|
|
24746
|
+
}
|
|
24747
|
+
const parsedType = this._getType(input);
|
|
24748
|
+
if (parsedType !== ZodParsedType.string) {
|
|
24749
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
24750
|
+
addIssueToContext(ctx2, {
|
|
24751
|
+
code: ZodIssueCode.invalid_type,
|
|
24752
|
+
expected: ZodParsedType.string,
|
|
24753
|
+
received: ctx2.parsedType
|
|
24754
|
+
});
|
|
24755
|
+
return INVALID;
|
|
24756
|
+
}
|
|
24757
|
+
const status = new ParseStatus();
|
|
24758
|
+
let ctx = void 0;
|
|
24759
|
+
for (const check2 of this._def.checks) {
|
|
24760
|
+
if (check2.kind === "min") {
|
|
24761
|
+
if (input.data.length < check2.value) {
|
|
24762
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24763
|
+
addIssueToContext(ctx, {
|
|
24764
|
+
code: ZodIssueCode.too_small,
|
|
24765
|
+
minimum: check2.value,
|
|
24766
|
+
type: "string",
|
|
24767
|
+
inclusive: true,
|
|
24768
|
+
exact: false,
|
|
24769
|
+
message: check2.message
|
|
24770
|
+
});
|
|
24771
|
+
status.dirty();
|
|
24772
|
+
}
|
|
24773
|
+
} else if (check2.kind === "max") {
|
|
24774
|
+
if (input.data.length > check2.value) {
|
|
24775
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24776
|
+
addIssueToContext(ctx, {
|
|
24777
|
+
code: ZodIssueCode.too_big,
|
|
24778
|
+
maximum: check2.value,
|
|
24779
|
+
type: "string",
|
|
24780
|
+
inclusive: true,
|
|
24781
|
+
exact: false,
|
|
24782
|
+
message: check2.message
|
|
24783
|
+
});
|
|
24784
|
+
status.dirty();
|
|
24785
|
+
}
|
|
24786
|
+
} else if (check2.kind === "length") {
|
|
24787
|
+
const tooBig = input.data.length > check2.value;
|
|
24788
|
+
const tooSmall = input.data.length < check2.value;
|
|
24789
|
+
if (tooBig || tooSmall) {
|
|
24790
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24791
|
+
if (tooBig) {
|
|
24792
|
+
addIssueToContext(ctx, {
|
|
24793
|
+
code: ZodIssueCode.too_big,
|
|
24794
|
+
maximum: check2.value,
|
|
24795
|
+
type: "string",
|
|
24796
|
+
inclusive: true,
|
|
24797
|
+
exact: true,
|
|
24798
|
+
message: check2.message
|
|
24799
|
+
});
|
|
24800
|
+
} else if (tooSmall) {
|
|
24801
|
+
addIssueToContext(ctx, {
|
|
24802
|
+
code: ZodIssueCode.too_small,
|
|
24803
|
+
minimum: check2.value,
|
|
24804
|
+
type: "string",
|
|
24805
|
+
inclusive: true,
|
|
24806
|
+
exact: true,
|
|
24807
|
+
message: check2.message
|
|
24808
|
+
});
|
|
24809
|
+
}
|
|
24810
|
+
status.dirty();
|
|
24811
|
+
}
|
|
24812
|
+
} else if (check2.kind === "email") {
|
|
24813
|
+
if (!emailRegex.test(input.data)) {
|
|
24814
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24815
|
+
addIssueToContext(ctx, {
|
|
24816
|
+
validation: "email",
|
|
24817
|
+
code: ZodIssueCode.invalid_string,
|
|
24818
|
+
message: check2.message
|
|
24819
|
+
});
|
|
24820
|
+
status.dirty();
|
|
24821
|
+
}
|
|
24822
|
+
} else if (check2.kind === "emoji") {
|
|
24823
|
+
if (!emojiRegex) {
|
|
24824
|
+
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
24825
|
+
}
|
|
24826
|
+
if (!emojiRegex.test(input.data)) {
|
|
24827
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24828
|
+
addIssueToContext(ctx, {
|
|
24829
|
+
validation: "emoji",
|
|
24830
|
+
code: ZodIssueCode.invalid_string,
|
|
24831
|
+
message: check2.message
|
|
24832
|
+
});
|
|
24833
|
+
status.dirty();
|
|
24834
|
+
}
|
|
24835
|
+
} else if (check2.kind === "uuid") {
|
|
24836
|
+
if (!uuidRegex.test(input.data)) {
|
|
24837
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24838
|
+
addIssueToContext(ctx, {
|
|
24839
|
+
validation: "uuid",
|
|
24840
|
+
code: ZodIssueCode.invalid_string,
|
|
24841
|
+
message: check2.message
|
|
24842
|
+
});
|
|
24843
|
+
status.dirty();
|
|
24844
|
+
}
|
|
24845
|
+
} else if (check2.kind === "nanoid") {
|
|
24846
|
+
if (!nanoidRegex.test(input.data)) {
|
|
24847
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24848
|
+
addIssueToContext(ctx, {
|
|
24849
|
+
validation: "nanoid",
|
|
24850
|
+
code: ZodIssueCode.invalid_string,
|
|
24851
|
+
message: check2.message
|
|
24852
|
+
});
|
|
24853
|
+
status.dirty();
|
|
24854
|
+
}
|
|
24855
|
+
} else if (check2.kind === "cuid") {
|
|
24856
|
+
if (!cuidRegex.test(input.data)) {
|
|
24857
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24858
|
+
addIssueToContext(ctx, {
|
|
24859
|
+
validation: "cuid",
|
|
24860
|
+
code: ZodIssueCode.invalid_string,
|
|
24861
|
+
message: check2.message
|
|
24862
|
+
});
|
|
24863
|
+
status.dirty();
|
|
24864
|
+
}
|
|
24865
|
+
} else if (check2.kind === "cuid2") {
|
|
24866
|
+
if (!cuid2Regex.test(input.data)) {
|
|
24867
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24868
|
+
addIssueToContext(ctx, {
|
|
24869
|
+
validation: "cuid2",
|
|
24870
|
+
code: ZodIssueCode.invalid_string,
|
|
24871
|
+
message: check2.message
|
|
24872
|
+
});
|
|
24873
|
+
status.dirty();
|
|
24874
|
+
}
|
|
24875
|
+
} else if (check2.kind === "ulid") {
|
|
24876
|
+
if (!ulidRegex.test(input.data)) {
|
|
24877
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24878
|
+
addIssueToContext(ctx, {
|
|
24879
|
+
validation: "ulid",
|
|
24880
|
+
code: ZodIssueCode.invalid_string,
|
|
24881
|
+
message: check2.message
|
|
24882
|
+
});
|
|
24883
|
+
status.dirty();
|
|
24884
|
+
}
|
|
24885
|
+
} else if (check2.kind === "url") {
|
|
24886
|
+
try {
|
|
24887
|
+
new URL(input.data);
|
|
24888
|
+
} catch {
|
|
24889
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24890
|
+
addIssueToContext(ctx, {
|
|
24891
|
+
validation: "url",
|
|
24892
|
+
code: ZodIssueCode.invalid_string,
|
|
24893
|
+
message: check2.message
|
|
24894
|
+
});
|
|
24895
|
+
status.dirty();
|
|
24896
|
+
}
|
|
24897
|
+
} else if (check2.kind === "regex") {
|
|
24898
|
+
check2.regex.lastIndex = 0;
|
|
24899
|
+
const testResult = check2.regex.test(input.data);
|
|
24900
|
+
if (!testResult) {
|
|
24901
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24902
|
+
addIssueToContext(ctx, {
|
|
24903
|
+
validation: "regex",
|
|
24904
|
+
code: ZodIssueCode.invalid_string,
|
|
24905
|
+
message: check2.message
|
|
24906
|
+
});
|
|
24907
|
+
status.dirty();
|
|
24908
|
+
}
|
|
24909
|
+
} else if (check2.kind === "trim") {
|
|
24910
|
+
input.data = input.data.trim();
|
|
24911
|
+
} else if (check2.kind === "includes") {
|
|
24912
|
+
if (!input.data.includes(check2.value, check2.position)) {
|
|
24913
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24914
|
+
addIssueToContext(ctx, {
|
|
24915
|
+
code: ZodIssueCode.invalid_string,
|
|
24916
|
+
validation: { includes: check2.value, position: check2.position },
|
|
24917
|
+
message: check2.message
|
|
24918
|
+
});
|
|
24919
|
+
status.dirty();
|
|
24920
|
+
}
|
|
24921
|
+
} else if (check2.kind === "toLowerCase") {
|
|
24922
|
+
input.data = input.data.toLowerCase();
|
|
24923
|
+
} else if (check2.kind === "toUpperCase") {
|
|
24924
|
+
input.data = input.data.toUpperCase();
|
|
24925
|
+
} else if (check2.kind === "startsWith") {
|
|
24926
|
+
if (!input.data.startsWith(check2.value)) {
|
|
24927
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24928
|
+
addIssueToContext(ctx, {
|
|
24929
|
+
code: ZodIssueCode.invalid_string,
|
|
24930
|
+
validation: { startsWith: check2.value },
|
|
24931
|
+
message: check2.message
|
|
24932
|
+
});
|
|
24933
|
+
status.dirty();
|
|
24934
|
+
}
|
|
24935
|
+
} else if (check2.kind === "endsWith") {
|
|
24936
|
+
if (!input.data.endsWith(check2.value)) {
|
|
24937
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24938
|
+
addIssueToContext(ctx, {
|
|
24939
|
+
code: ZodIssueCode.invalid_string,
|
|
24940
|
+
validation: { endsWith: check2.value },
|
|
24941
|
+
message: check2.message
|
|
24942
|
+
});
|
|
24943
|
+
status.dirty();
|
|
24944
|
+
}
|
|
24945
|
+
} else if (check2.kind === "datetime") {
|
|
24946
|
+
const regex = datetimeRegex(check2);
|
|
24947
|
+
if (!regex.test(input.data)) {
|
|
24948
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24949
|
+
addIssueToContext(ctx, {
|
|
24950
|
+
code: ZodIssueCode.invalid_string,
|
|
24951
|
+
validation: "datetime",
|
|
24952
|
+
message: check2.message
|
|
24953
|
+
});
|
|
24954
|
+
status.dirty();
|
|
24955
|
+
}
|
|
24956
|
+
} else if (check2.kind === "date") {
|
|
24957
|
+
const regex = dateRegex;
|
|
24958
|
+
if (!regex.test(input.data)) {
|
|
24959
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24960
|
+
addIssueToContext(ctx, {
|
|
24961
|
+
code: ZodIssueCode.invalid_string,
|
|
24962
|
+
validation: "date",
|
|
24963
|
+
message: check2.message
|
|
24964
|
+
});
|
|
24965
|
+
status.dirty();
|
|
24966
|
+
}
|
|
24967
|
+
} else if (check2.kind === "time") {
|
|
24968
|
+
const regex = timeRegex(check2);
|
|
24969
|
+
if (!regex.test(input.data)) {
|
|
24970
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24971
|
+
addIssueToContext(ctx, {
|
|
24972
|
+
code: ZodIssueCode.invalid_string,
|
|
24973
|
+
validation: "time",
|
|
24974
|
+
message: check2.message
|
|
24975
|
+
});
|
|
24976
|
+
status.dirty();
|
|
24977
|
+
}
|
|
24978
|
+
} else if (check2.kind === "duration") {
|
|
24979
|
+
if (!durationRegex.test(input.data)) {
|
|
24980
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24981
|
+
addIssueToContext(ctx, {
|
|
24982
|
+
validation: "duration",
|
|
24983
|
+
code: ZodIssueCode.invalid_string,
|
|
24984
|
+
message: check2.message
|
|
24985
|
+
});
|
|
24986
|
+
status.dirty();
|
|
24987
|
+
}
|
|
24988
|
+
} else if (check2.kind === "ip") {
|
|
24989
|
+
if (!isValidIP(input.data, check2.version)) {
|
|
24990
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
24991
|
+
addIssueToContext(ctx, {
|
|
24992
|
+
validation: "ip",
|
|
24993
|
+
code: ZodIssueCode.invalid_string,
|
|
24994
|
+
message: check2.message
|
|
24995
|
+
});
|
|
24996
|
+
status.dirty();
|
|
24997
|
+
}
|
|
24998
|
+
} else if (check2.kind === "jwt") {
|
|
24999
|
+
if (!isValidJWT(input.data, check2.alg)) {
|
|
25000
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25001
|
+
addIssueToContext(ctx, {
|
|
25002
|
+
validation: "jwt",
|
|
25003
|
+
code: ZodIssueCode.invalid_string,
|
|
25004
|
+
message: check2.message
|
|
25005
|
+
});
|
|
25006
|
+
status.dirty();
|
|
25007
|
+
}
|
|
25008
|
+
} else if (check2.kind === "cidr") {
|
|
25009
|
+
if (!isValidCidr(input.data, check2.version)) {
|
|
25010
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25011
|
+
addIssueToContext(ctx, {
|
|
25012
|
+
validation: "cidr",
|
|
25013
|
+
code: ZodIssueCode.invalid_string,
|
|
25014
|
+
message: check2.message
|
|
25015
|
+
});
|
|
25016
|
+
status.dirty();
|
|
25017
|
+
}
|
|
25018
|
+
} else if (check2.kind === "base64") {
|
|
25019
|
+
if (!base64Regex.test(input.data)) {
|
|
25020
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25021
|
+
addIssueToContext(ctx, {
|
|
25022
|
+
validation: "base64",
|
|
25023
|
+
code: ZodIssueCode.invalid_string,
|
|
25024
|
+
message: check2.message
|
|
25025
|
+
});
|
|
25026
|
+
status.dirty();
|
|
25027
|
+
}
|
|
25028
|
+
} else if (check2.kind === "base64url") {
|
|
25029
|
+
if (!base64urlRegex.test(input.data)) {
|
|
25030
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25031
|
+
addIssueToContext(ctx, {
|
|
25032
|
+
validation: "base64url",
|
|
25033
|
+
code: ZodIssueCode.invalid_string,
|
|
25034
|
+
message: check2.message
|
|
25035
|
+
});
|
|
25036
|
+
status.dirty();
|
|
25037
|
+
}
|
|
25038
|
+
} else {
|
|
25039
|
+
util$1.assertNever(check2);
|
|
25040
|
+
}
|
|
25041
|
+
}
|
|
25042
|
+
return { status: status.value, value: input.data };
|
|
25043
|
+
}
|
|
25044
|
+
_regex(regex, validation2, message) {
|
|
25045
|
+
return this.refinement((data2) => regex.test(data2), {
|
|
25046
|
+
validation: validation2,
|
|
25047
|
+
code: ZodIssueCode.invalid_string,
|
|
25048
|
+
...errorUtil.errToObj(message)
|
|
25049
|
+
});
|
|
25050
|
+
}
|
|
25051
|
+
_addCheck(check2) {
|
|
25052
|
+
return new ZodString({
|
|
25053
|
+
...this._def,
|
|
25054
|
+
checks: [...this._def.checks, check2]
|
|
25055
|
+
});
|
|
25056
|
+
}
|
|
25057
|
+
email(message) {
|
|
25058
|
+
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
|
|
25059
|
+
}
|
|
25060
|
+
url(message) {
|
|
25061
|
+
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
25062
|
+
}
|
|
25063
|
+
emoji(message) {
|
|
25064
|
+
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
25065
|
+
}
|
|
25066
|
+
uuid(message) {
|
|
25067
|
+
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
25068
|
+
}
|
|
25069
|
+
nanoid(message) {
|
|
25070
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
25071
|
+
}
|
|
25072
|
+
cuid(message) {
|
|
25073
|
+
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
25074
|
+
}
|
|
25075
|
+
cuid2(message) {
|
|
25076
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
25077
|
+
}
|
|
25078
|
+
ulid(message) {
|
|
25079
|
+
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
25080
|
+
}
|
|
25081
|
+
base64(message) {
|
|
25082
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
25083
|
+
}
|
|
25084
|
+
base64url(message) {
|
|
25085
|
+
return this._addCheck({
|
|
25086
|
+
kind: "base64url",
|
|
25087
|
+
...errorUtil.errToObj(message)
|
|
25088
|
+
});
|
|
25089
|
+
}
|
|
25090
|
+
jwt(options) {
|
|
25091
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
25092
|
+
}
|
|
25093
|
+
ip(options) {
|
|
25094
|
+
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
25095
|
+
}
|
|
25096
|
+
cidr(options) {
|
|
25097
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
25098
|
+
}
|
|
25099
|
+
datetime(options) {
|
|
25100
|
+
if (typeof options === "string") {
|
|
25101
|
+
return this._addCheck({
|
|
25102
|
+
kind: "datetime",
|
|
25103
|
+
precision: null,
|
|
25104
|
+
offset: false,
|
|
25105
|
+
local: false,
|
|
25106
|
+
message: options
|
|
25107
|
+
});
|
|
25108
|
+
}
|
|
25109
|
+
return this._addCheck({
|
|
25110
|
+
kind: "datetime",
|
|
25111
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
25112
|
+
offset: options?.offset ?? false,
|
|
25113
|
+
local: options?.local ?? false,
|
|
25114
|
+
...errorUtil.errToObj(options?.message)
|
|
25115
|
+
});
|
|
25116
|
+
}
|
|
25117
|
+
date(message) {
|
|
25118
|
+
return this._addCheck({ kind: "date", message });
|
|
25119
|
+
}
|
|
25120
|
+
time(options) {
|
|
25121
|
+
if (typeof options === "string") {
|
|
25122
|
+
return this._addCheck({
|
|
25123
|
+
kind: "time",
|
|
25124
|
+
precision: null,
|
|
25125
|
+
message: options
|
|
25126
|
+
});
|
|
25127
|
+
}
|
|
25128
|
+
return this._addCheck({
|
|
25129
|
+
kind: "time",
|
|
25130
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
25131
|
+
...errorUtil.errToObj(options?.message)
|
|
25132
|
+
});
|
|
25133
|
+
}
|
|
25134
|
+
duration(message) {
|
|
25135
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
25136
|
+
}
|
|
25137
|
+
regex(regex, message) {
|
|
25138
|
+
return this._addCheck({
|
|
25139
|
+
kind: "regex",
|
|
25140
|
+
regex,
|
|
25141
|
+
...errorUtil.errToObj(message)
|
|
25142
|
+
});
|
|
25143
|
+
}
|
|
25144
|
+
includes(value, options) {
|
|
25145
|
+
return this._addCheck({
|
|
25146
|
+
kind: "includes",
|
|
25147
|
+
value,
|
|
25148
|
+
position: options?.position,
|
|
25149
|
+
...errorUtil.errToObj(options?.message)
|
|
25150
|
+
});
|
|
25151
|
+
}
|
|
25152
|
+
startsWith(value, message) {
|
|
25153
|
+
return this._addCheck({
|
|
25154
|
+
kind: "startsWith",
|
|
25155
|
+
value,
|
|
25156
|
+
...errorUtil.errToObj(message)
|
|
25157
|
+
});
|
|
25158
|
+
}
|
|
25159
|
+
endsWith(value, message) {
|
|
25160
|
+
return this._addCheck({
|
|
25161
|
+
kind: "endsWith",
|
|
25162
|
+
value,
|
|
25163
|
+
...errorUtil.errToObj(message)
|
|
25164
|
+
});
|
|
25165
|
+
}
|
|
25166
|
+
min(minLength, message) {
|
|
25167
|
+
return this._addCheck({
|
|
25168
|
+
kind: "min",
|
|
25169
|
+
value: minLength,
|
|
25170
|
+
...errorUtil.errToObj(message)
|
|
25171
|
+
});
|
|
25172
|
+
}
|
|
25173
|
+
max(maxLength, message) {
|
|
25174
|
+
return this._addCheck({
|
|
25175
|
+
kind: "max",
|
|
25176
|
+
value: maxLength,
|
|
25177
|
+
...errorUtil.errToObj(message)
|
|
25178
|
+
});
|
|
25179
|
+
}
|
|
25180
|
+
length(len, message) {
|
|
25181
|
+
return this._addCheck({
|
|
25182
|
+
kind: "length",
|
|
25183
|
+
value: len,
|
|
25184
|
+
...errorUtil.errToObj(message)
|
|
25185
|
+
});
|
|
25186
|
+
}
|
|
25187
|
+
/**
|
|
25188
|
+
* Equivalent to `.min(1)`
|
|
25189
|
+
*/
|
|
25190
|
+
nonempty(message) {
|
|
25191
|
+
return this.min(1, errorUtil.errToObj(message));
|
|
25192
|
+
}
|
|
25193
|
+
trim() {
|
|
25194
|
+
return new ZodString({
|
|
25195
|
+
...this._def,
|
|
25196
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
25197
|
+
});
|
|
25198
|
+
}
|
|
25199
|
+
toLowerCase() {
|
|
25200
|
+
return new ZodString({
|
|
25201
|
+
...this._def,
|
|
25202
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
25203
|
+
});
|
|
25204
|
+
}
|
|
25205
|
+
toUpperCase() {
|
|
25206
|
+
return new ZodString({
|
|
25207
|
+
...this._def,
|
|
25208
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
25209
|
+
});
|
|
25210
|
+
}
|
|
25211
|
+
get isDatetime() {
|
|
25212
|
+
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
25213
|
+
}
|
|
25214
|
+
get isDate() {
|
|
25215
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
25216
|
+
}
|
|
25217
|
+
get isTime() {
|
|
25218
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
25219
|
+
}
|
|
25220
|
+
get isDuration() {
|
|
25221
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
25222
|
+
}
|
|
25223
|
+
get isEmail() {
|
|
25224
|
+
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
25225
|
+
}
|
|
25226
|
+
get isURL() {
|
|
25227
|
+
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
25228
|
+
}
|
|
25229
|
+
get isEmoji() {
|
|
25230
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
25231
|
+
}
|
|
25232
|
+
get isUUID() {
|
|
25233
|
+
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
25234
|
+
}
|
|
25235
|
+
get isNANOID() {
|
|
25236
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
25237
|
+
}
|
|
25238
|
+
get isCUID() {
|
|
25239
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
25240
|
+
}
|
|
25241
|
+
get isCUID2() {
|
|
25242
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
25243
|
+
}
|
|
25244
|
+
get isULID() {
|
|
25245
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
25246
|
+
}
|
|
25247
|
+
get isIP() {
|
|
25248
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
25249
|
+
}
|
|
25250
|
+
get isCIDR() {
|
|
25251
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
25252
|
+
}
|
|
25253
|
+
get isBase64() {
|
|
25254
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
25255
|
+
}
|
|
25256
|
+
get isBase64url() {
|
|
25257
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
25258
|
+
}
|
|
25259
|
+
get minLength() {
|
|
25260
|
+
let min2 = null;
|
|
25261
|
+
for (const ch of this._def.checks) {
|
|
25262
|
+
if (ch.kind === "min") {
|
|
25263
|
+
if (min2 === null || ch.value > min2)
|
|
25264
|
+
min2 = ch.value;
|
|
25265
|
+
}
|
|
25266
|
+
}
|
|
25267
|
+
return min2;
|
|
25268
|
+
}
|
|
25269
|
+
get maxLength() {
|
|
25270
|
+
let max2 = null;
|
|
25271
|
+
for (const ch of this._def.checks) {
|
|
25272
|
+
if (ch.kind === "max") {
|
|
25273
|
+
if (max2 === null || ch.value < max2)
|
|
25274
|
+
max2 = ch.value;
|
|
25275
|
+
}
|
|
25276
|
+
}
|
|
25277
|
+
return max2;
|
|
25278
|
+
}
|
|
25279
|
+
}
|
|
25280
|
+
ZodString.create = (params) => {
|
|
25281
|
+
return new ZodString({
|
|
25282
|
+
checks: [],
|
|
25283
|
+
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
25284
|
+
coerce: params?.coerce ?? false,
|
|
25285
|
+
...processCreateParams(params)
|
|
25286
|
+
});
|
|
25287
|
+
};
|
|
25288
|
+
function floatSafeRemainder(val, step) {
|
|
25289
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
25290
|
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
25291
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
25292
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
25293
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
25294
|
+
return valInt % stepInt / 10 ** decCount;
|
|
25295
|
+
}
|
|
25296
|
+
class ZodNumber extends ZodType {
|
|
25297
|
+
constructor() {
|
|
25298
|
+
super(...arguments);
|
|
25299
|
+
this.min = this.gte;
|
|
25300
|
+
this.max = this.lte;
|
|
25301
|
+
this.step = this.multipleOf;
|
|
25302
|
+
}
|
|
25303
|
+
_parse(input) {
|
|
25304
|
+
if (this._def.coerce) {
|
|
25305
|
+
input.data = Number(input.data);
|
|
25306
|
+
}
|
|
25307
|
+
const parsedType = this._getType(input);
|
|
25308
|
+
if (parsedType !== ZodParsedType.number) {
|
|
25309
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
25310
|
+
addIssueToContext(ctx2, {
|
|
25311
|
+
code: ZodIssueCode.invalid_type,
|
|
25312
|
+
expected: ZodParsedType.number,
|
|
25313
|
+
received: ctx2.parsedType
|
|
25314
|
+
});
|
|
25315
|
+
return INVALID;
|
|
25316
|
+
}
|
|
25317
|
+
let ctx = void 0;
|
|
25318
|
+
const status = new ParseStatus();
|
|
25319
|
+
for (const check2 of this._def.checks) {
|
|
25320
|
+
if (check2.kind === "int") {
|
|
25321
|
+
if (!util$1.isInteger(input.data)) {
|
|
25322
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25323
|
+
addIssueToContext(ctx, {
|
|
25324
|
+
code: ZodIssueCode.invalid_type,
|
|
25325
|
+
expected: "integer",
|
|
25326
|
+
received: "float",
|
|
25327
|
+
message: check2.message
|
|
25328
|
+
});
|
|
25329
|
+
status.dirty();
|
|
25330
|
+
}
|
|
25331
|
+
} else if (check2.kind === "min") {
|
|
25332
|
+
const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
|
|
25333
|
+
if (tooSmall) {
|
|
25334
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25335
|
+
addIssueToContext(ctx, {
|
|
25336
|
+
code: ZodIssueCode.too_small,
|
|
25337
|
+
minimum: check2.value,
|
|
25338
|
+
type: "number",
|
|
25339
|
+
inclusive: check2.inclusive,
|
|
25340
|
+
exact: false,
|
|
25341
|
+
message: check2.message
|
|
25342
|
+
});
|
|
25343
|
+
status.dirty();
|
|
25344
|
+
}
|
|
25345
|
+
} else if (check2.kind === "max") {
|
|
25346
|
+
const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
|
|
25347
|
+
if (tooBig) {
|
|
25348
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25349
|
+
addIssueToContext(ctx, {
|
|
25350
|
+
code: ZodIssueCode.too_big,
|
|
25351
|
+
maximum: check2.value,
|
|
25352
|
+
type: "number",
|
|
25353
|
+
inclusive: check2.inclusive,
|
|
25354
|
+
exact: false,
|
|
25355
|
+
message: check2.message
|
|
25356
|
+
});
|
|
25357
|
+
status.dirty();
|
|
25358
|
+
}
|
|
25359
|
+
} else if (check2.kind === "multipleOf") {
|
|
25360
|
+
if (floatSafeRemainder(input.data, check2.value) !== 0) {
|
|
25361
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25362
|
+
addIssueToContext(ctx, {
|
|
25363
|
+
code: ZodIssueCode.not_multiple_of,
|
|
25364
|
+
multipleOf: check2.value,
|
|
25365
|
+
message: check2.message
|
|
25366
|
+
});
|
|
25367
|
+
status.dirty();
|
|
25368
|
+
}
|
|
25369
|
+
} else if (check2.kind === "finite") {
|
|
25370
|
+
if (!Number.isFinite(input.data)) {
|
|
25371
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25372
|
+
addIssueToContext(ctx, {
|
|
25373
|
+
code: ZodIssueCode.not_finite,
|
|
25374
|
+
message: check2.message
|
|
25375
|
+
});
|
|
25376
|
+
status.dirty();
|
|
25377
|
+
}
|
|
25378
|
+
} else {
|
|
25379
|
+
util$1.assertNever(check2);
|
|
25380
|
+
}
|
|
25381
|
+
}
|
|
25382
|
+
return { status: status.value, value: input.data };
|
|
25383
|
+
}
|
|
25384
|
+
gte(value, message) {
|
|
25385
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
25386
|
+
}
|
|
25387
|
+
gt(value, message) {
|
|
25388
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
25389
|
+
}
|
|
25390
|
+
lte(value, message) {
|
|
25391
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
25392
|
+
}
|
|
25393
|
+
lt(value, message) {
|
|
25394
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
25395
|
+
}
|
|
25396
|
+
setLimit(kind, value, inclusive, message) {
|
|
25397
|
+
return new ZodNumber({
|
|
25398
|
+
...this._def,
|
|
25399
|
+
checks: [
|
|
25400
|
+
...this._def.checks,
|
|
25401
|
+
{
|
|
25402
|
+
kind,
|
|
25403
|
+
value,
|
|
25404
|
+
inclusive,
|
|
25405
|
+
message: errorUtil.toString(message)
|
|
25406
|
+
}
|
|
25407
|
+
]
|
|
25408
|
+
});
|
|
25409
|
+
}
|
|
25410
|
+
_addCheck(check2) {
|
|
25411
|
+
return new ZodNumber({
|
|
25412
|
+
...this._def,
|
|
25413
|
+
checks: [...this._def.checks, check2]
|
|
25414
|
+
});
|
|
25415
|
+
}
|
|
25416
|
+
int(message) {
|
|
25417
|
+
return this._addCheck({
|
|
25418
|
+
kind: "int",
|
|
25419
|
+
message: errorUtil.toString(message)
|
|
25420
|
+
});
|
|
25421
|
+
}
|
|
25422
|
+
positive(message) {
|
|
25423
|
+
return this._addCheck({
|
|
25424
|
+
kind: "min",
|
|
25425
|
+
value: 0,
|
|
25426
|
+
inclusive: false,
|
|
25427
|
+
message: errorUtil.toString(message)
|
|
25428
|
+
});
|
|
25429
|
+
}
|
|
25430
|
+
negative(message) {
|
|
25431
|
+
return this._addCheck({
|
|
25432
|
+
kind: "max",
|
|
25433
|
+
value: 0,
|
|
25434
|
+
inclusive: false,
|
|
25435
|
+
message: errorUtil.toString(message)
|
|
25436
|
+
});
|
|
25437
|
+
}
|
|
25438
|
+
nonpositive(message) {
|
|
25439
|
+
return this._addCheck({
|
|
25440
|
+
kind: "max",
|
|
25441
|
+
value: 0,
|
|
25442
|
+
inclusive: true,
|
|
25443
|
+
message: errorUtil.toString(message)
|
|
25444
|
+
});
|
|
25445
|
+
}
|
|
25446
|
+
nonnegative(message) {
|
|
25447
|
+
return this._addCheck({
|
|
25448
|
+
kind: "min",
|
|
25449
|
+
value: 0,
|
|
25450
|
+
inclusive: true,
|
|
25451
|
+
message: errorUtil.toString(message)
|
|
25452
|
+
});
|
|
25453
|
+
}
|
|
25454
|
+
multipleOf(value, message) {
|
|
25455
|
+
return this._addCheck({
|
|
25456
|
+
kind: "multipleOf",
|
|
25457
|
+
value,
|
|
25458
|
+
message: errorUtil.toString(message)
|
|
25459
|
+
});
|
|
25460
|
+
}
|
|
25461
|
+
finite(message) {
|
|
25462
|
+
return this._addCheck({
|
|
25463
|
+
kind: "finite",
|
|
25464
|
+
message: errorUtil.toString(message)
|
|
25465
|
+
});
|
|
25466
|
+
}
|
|
25467
|
+
safe(message) {
|
|
25468
|
+
return this._addCheck({
|
|
25469
|
+
kind: "min",
|
|
25470
|
+
inclusive: true,
|
|
25471
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
25472
|
+
message: errorUtil.toString(message)
|
|
25473
|
+
})._addCheck({
|
|
25474
|
+
kind: "max",
|
|
25475
|
+
inclusive: true,
|
|
25476
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
25477
|
+
message: errorUtil.toString(message)
|
|
25478
|
+
});
|
|
25479
|
+
}
|
|
25480
|
+
get minValue() {
|
|
25481
|
+
let min2 = null;
|
|
25482
|
+
for (const ch of this._def.checks) {
|
|
25483
|
+
if (ch.kind === "min") {
|
|
25484
|
+
if (min2 === null || ch.value > min2)
|
|
25485
|
+
min2 = ch.value;
|
|
25486
|
+
}
|
|
25487
|
+
}
|
|
25488
|
+
return min2;
|
|
25489
|
+
}
|
|
25490
|
+
get maxValue() {
|
|
25491
|
+
let max2 = null;
|
|
25492
|
+
for (const ch of this._def.checks) {
|
|
25493
|
+
if (ch.kind === "max") {
|
|
25494
|
+
if (max2 === null || ch.value < max2)
|
|
25495
|
+
max2 = ch.value;
|
|
25496
|
+
}
|
|
25497
|
+
}
|
|
25498
|
+
return max2;
|
|
25499
|
+
}
|
|
25500
|
+
get isInt() {
|
|
25501
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util$1.isInteger(ch.value));
|
|
25502
|
+
}
|
|
25503
|
+
get isFinite() {
|
|
25504
|
+
let max2 = null;
|
|
25505
|
+
let min2 = null;
|
|
25506
|
+
for (const ch of this._def.checks) {
|
|
25507
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
25508
|
+
return true;
|
|
25509
|
+
} else if (ch.kind === "min") {
|
|
25510
|
+
if (min2 === null || ch.value > min2)
|
|
25511
|
+
min2 = ch.value;
|
|
25512
|
+
} else if (ch.kind === "max") {
|
|
25513
|
+
if (max2 === null || ch.value < max2)
|
|
25514
|
+
max2 = ch.value;
|
|
25515
|
+
}
|
|
25516
|
+
}
|
|
25517
|
+
return Number.isFinite(min2) && Number.isFinite(max2);
|
|
25518
|
+
}
|
|
25519
|
+
}
|
|
25520
|
+
ZodNumber.create = (params) => {
|
|
25521
|
+
return new ZodNumber({
|
|
25522
|
+
checks: [],
|
|
25523
|
+
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
25524
|
+
coerce: params?.coerce || false,
|
|
25525
|
+
...processCreateParams(params)
|
|
25526
|
+
});
|
|
25527
|
+
};
|
|
25528
|
+
class ZodBigInt extends ZodType {
|
|
25529
|
+
constructor() {
|
|
25530
|
+
super(...arguments);
|
|
25531
|
+
this.min = this.gte;
|
|
25532
|
+
this.max = this.lte;
|
|
25533
|
+
}
|
|
25534
|
+
_parse(input) {
|
|
25535
|
+
if (this._def.coerce) {
|
|
25536
|
+
try {
|
|
25537
|
+
input.data = BigInt(input.data);
|
|
25538
|
+
} catch {
|
|
25539
|
+
return this._getInvalidInput(input);
|
|
25540
|
+
}
|
|
25541
|
+
}
|
|
25542
|
+
const parsedType = this._getType(input);
|
|
25543
|
+
if (parsedType !== ZodParsedType.bigint) {
|
|
25544
|
+
return this._getInvalidInput(input);
|
|
25545
|
+
}
|
|
25546
|
+
let ctx = void 0;
|
|
25547
|
+
const status = new ParseStatus();
|
|
25548
|
+
for (const check2 of this._def.checks) {
|
|
25549
|
+
if (check2.kind === "min") {
|
|
25550
|
+
const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
|
|
25551
|
+
if (tooSmall) {
|
|
25552
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25553
|
+
addIssueToContext(ctx, {
|
|
25554
|
+
code: ZodIssueCode.too_small,
|
|
25555
|
+
type: "bigint",
|
|
25556
|
+
minimum: check2.value,
|
|
25557
|
+
inclusive: check2.inclusive,
|
|
25558
|
+
message: check2.message
|
|
25559
|
+
});
|
|
25560
|
+
status.dirty();
|
|
25561
|
+
}
|
|
25562
|
+
} else if (check2.kind === "max") {
|
|
25563
|
+
const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
|
|
25564
|
+
if (tooBig) {
|
|
25565
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25566
|
+
addIssueToContext(ctx, {
|
|
25567
|
+
code: ZodIssueCode.too_big,
|
|
25568
|
+
type: "bigint",
|
|
25569
|
+
maximum: check2.value,
|
|
25570
|
+
inclusive: check2.inclusive,
|
|
25571
|
+
message: check2.message
|
|
25572
|
+
});
|
|
25573
|
+
status.dirty();
|
|
25574
|
+
}
|
|
25575
|
+
} else if (check2.kind === "multipleOf") {
|
|
25576
|
+
if (input.data % check2.value !== BigInt(0)) {
|
|
25577
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25578
|
+
addIssueToContext(ctx, {
|
|
25579
|
+
code: ZodIssueCode.not_multiple_of,
|
|
25580
|
+
multipleOf: check2.value,
|
|
25581
|
+
message: check2.message
|
|
25582
|
+
});
|
|
25583
|
+
status.dirty();
|
|
25584
|
+
}
|
|
25585
|
+
} else {
|
|
25586
|
+
util$1.assertNever(check2);
|
|
25587
|
+
}
|
|
25588
|
+
}
|
|
25589
|
+
return { status: status.value, value: input.data };
|
|
25590
|
+
}
|
|
25591
|
+
_getInvalidInput(input) {
|
|
25592
|
+
const ctx = this._getOrReturnCtx(input);
|
|
25593
|
+
addIssueToContext(ctx, {
|
|
25594
|
+
code: ZodIssueCode.invalid_type,
|
|
25595
|
+
expected: ZodParsedType.bigint,
|
|
25596
|
+
received: ctx.parsedType
|
|
25597
|
+
});
|
|
25598
|
+
return INVALID;
|
|
25599
|
+
}
|
|
25600
|
+
gte(value, message) {
|
|
25601
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
25602
|
+
}
|
|
25603
|
+
gt(value, message) {
|
|
25604
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
25605
|
+
}
|
|
25606
|
+
lte(value, message) {
|
|
25607
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
25608
|
+
}
|
|
25609
|
+
lt(value, message) {
|
|
25610
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
25611
|
+
}
|
|
25612
|
+
setLimit(kind, value, inclusive, message) {
|
|
25613
|
+
return new ZodBigInt({
|
|
25614
|
+
...this._def,
|
|
25615
|
+
checks: [
|
|
25616
|
+
...this._def.checks,
|
|
25617
|
+
{
|
|
25618
|
+
kind,
|
|
25619
|
+
value,
|
|
25620
|
+
inclusive,
|
|
25621
|
+
message: errorUtil.toString(message)
|
|
25622
|
+
}
|
|
25623
|
+
]
|
|
25624
|
+
});
|
|
25625
|
+
}
|
|
25626
|
+
_addCheck(check2) {
|
|
25627
|
+
return new ZodBigInt({
|
|
25628
|
+
...this._def,
|
|
25629
|
+
checks: [...this._def.checks, check2]
|
|
25630
|
+
});
|
|
25631
|
+
}
|
|
25632
|
+
positive(message) {
|
|
25633
|
+
return this._addCheck({
|
|
25634
|
+
kind: "min",
|
|
25635
|
+
value: BigInt(0),
|
|
25636
|
+
inclusive: false,
|
|
25637
|
+
message: errorUtil.toString(message)
|
|
25638
|
+
});
|
|
25639
|
+
}
|
|
25640
|
+
negative(message) {
|
|
25641
|
+
return this._addCheck({
|
|
25642
|
+
kind: "max",
|
|
25643
|
+
value: BigInt(0),
|
|
25644
|
+
inclusive: false,
|
|
25645
|
+
message: errorUtil.toString(message)
|
|
25646
|
+
});
|
|
25647
|
+
}
|
|
25648
|
+
nonpositive(message) {
|
|
25649
|
+
return this._addCheck({
|
|
25650
|
+
kind: "max",
|
|
25651
|
+
value: BigInt(0),
|
|
25652
|
+
inclusive: true,
|
|
25653
|
+
message: errorUtil.toString(message)
|
|
25654
|
+
});
|
|
25655
|
+
}
|
|
25656
|
+
nonnegative(message) {
|
|
25657
|
+
return this._addCheck({
|
|
25658
|
+
kind: "min",
|
|
25659
|
+
value: BigInt(0),
|
|
25660
|
+
inclusive: true,
|
|
25661
|
+
message: errorUtil.toString(message)
|
|
25662
|
+
});
|
|
25663
|
+
}
|
|
25664
|
+
multipleOf(value, message) {
|
|
25665
|
+
return this._addCheck({
|
|
25666
|
+
kind: "multipleOf",
|
|
25667
|
+
value,
|
|
25668
|
+
message: errorUtil.toString(message)
|
|
25669
|
+
});
|
|
25670
|
+
}
|
|
25671
|
+
get minValue() {
|
|
25672
|
+
let min2 = null;
|
|
25673
|
+
for (const ch of this._def.checks) {
|
|
25674
|
+
if (ch.kind === "min") {
|
|
25675
|
+
if (min2 === null || ch.value > min2)
|
|
25676
|
+
min2 = ch.value;
|
|
25677
|
+
}
|
|
25678
|
+
}
|
|
25679
|
+
return min2;
|
|
25680
|
+
}
|
|
25681
|
+
get maxValue() {
|
|
25682
|
+
let max2 = null;
|
|
25683
|
+
for (const ch of this._def.checks) {
|
|
25684
|
+
if (ch.kind === "max") {
|
|
25685
|
+
if (max2 === null || ch.value < max2)
|
|
25686
|
+
max2 = ch.value;
|
|
25687
|
+
}
|
|
25688
|
+
}
|
|
25689
|
+
return max2;
|
|
25690
|
+
}
|
|
25691
|
+
}
|
|
25692
|
+
ZodBigInt.create = (params) => {
|
|
25693
|
+
return new ZodBigInt({
|
|
25694
|
+
checks: [],
|
|
25695
|
+
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
25696
|
+
coerce: params?.coerce ?? false,
|
|
25697
|
+
...processCreateParams(params)
|
|
25698
|
+
});
|
|
25699
|
+
};
|
|
25700
|
+
class ZodBoolean extends ZodType {
|
|
25701
|
+
_parse(input) {
|
|
25702
|
+
if (this._def.coerce) {
|
|
25703
|
+
input.data = Boolean(input.data);
|
|
25704
|
+
}
|
|
25705
|
+
const parsedType = this._getType(input);
|
|
25706
|
+
if (parsedType !== ZodParsedType.boolean) {
|
|
25707
|
+
const ctx = this._getOrReturnCtx(input);
|
|
25708
|
+
addIssueToContext(ctx, {
|
|
25709
|
+
code: ZodIssueCode.invalid_type,
|
|
25710
|
+
expected: ZodParsedType.boolean,
|
|
25711
|
+
received: ctx.parsedType
|
|
25712
|
+
});
|
|
25713
|
+
return INVALID;
|
|
25714
|
+
}
|
|
25715
|
+
return OK(input.data);
|
|
25716
|
+
}
|
|
25717
|
+
}
|
|
25718
|
+
ZodBoolean.create = (params) => {
|
|
25719
|
+
return new ZodBoolean({
|
|
25720
|
+
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
25721
|
+
coerce: params?.coerce || false,
|
|
25722
|
+
...processCreateParams(params)
|
|
25723
|
+
});
|
|
25724
|
+
};
|
|
25725
|
+
class ZodDate extends ZodType {
|
|
25726
|
+
_parse(input) {
|
|
25727
|
+
if (this._def.coerce) {
|
|
25728
|
+
input.data = new Date(input.data);
|
|
25729
|
+
}
|
|
25730
|
+
const parsedType = this._getType(input);
|
|
25731
|
+
if (parsedType !== ZodParsedType.date) {
|
|
25732
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
25733
|
+
addIssueToContext(ctx2, {
|
|
25734
|
+
code: ZodIssueCode.invalid_type,
|
|
25735
|
+
expected: ZodParsedType.date,
|
|
25736
|
+
received: ctx2.parsedType
|
|
25737
|
+
});
|
|
25738
|
+
return INVALID;
|
|
25739
|
+
}
|
|
25740
|
+
if (Number.isNaN(input.data.getTime())) {
|
|
25741
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
25742
|
+
addIssueToContext(ctx2, {
|
|
25743
|
+
code: ZodIssueCode.invalid_date
|
|
25744
|
+
});
|
|
25745
|
+
return INVALID;
|
|
25746
|
+
}
|
|
25747
|
+
const status = new ParseStatus();
|
|
25748
|
+
let ctx = void 0;
|
|
25749
|
+
for (const check2 of this._def.checks) {
|
|
25750
|
+
if (check2.kind === "min") {
|
|
25751
|
+
if (input.data.getTime() < check2.value) {
|
|
25752
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25753
|
+
addIssueToContext(ctx, {
|
|
25754
|
+
code: ZodIssueCode.too_small,
|
|
25755
|
+
message: check2.message,
|
|
25756
|
+
inclusive: true,
|
|
25757
|
+
exact: false,
|
|
25758
|
+
minimum: check2.value,
|
|
25759
|
+
type: "date"
|
|
25760
|
+
});
|
|
25761
|
+
status.dirty();
|
|
25762
|
+
}
|
|
25763
|
+
} else if (check2.kind === "max") {
|
|
25764
|
+
if (input.data.getTime() > check2.value) {
|
|
25765
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
25766
|
+
addIssueToContext(ctx, {
|
|
25767
|
+
code: ZodIssueCode.too_big,
|
|
25768
|
+
message: check2.message,
|
|
25769
|
+
inclusive: true,
|
|
25770
|
+
exact: false,
|
|
25771
|
+
maximum: check2.value,
|
|
25772
|
+
type: "date"
|
|
25773
|
+
});
|
|
25774
|
+
status.dirty();
|
|
25775
|
+
}
|
|
25776
|
+
} else {
|
|
25777
|
+
util$1.assertNever(check2);
|
|
25778
|
+
}
|
|
25779
|
+
}
|
|
25780
|
+
return {
|
|
25781
|
+
status: status.value,
|
|
25782
|
+
value: new Date(input.data.getTime())
|
|
25783
|
+
};
|
|
25784
|
+
}
|
|
25785
|
+
_addCheck(check2) {
|
|
25786
|
+
return new ZodDate({
|
|
25787
|
+
...this._def,
|
|
25788
|
+
checks: [...this._def.checks, check2]
|
|
25789
|
+
});
|
|
25790
|
+
}
|
|
25791
|
+
min(minDate, message) {
|
|
25792
|
+
return this._addCheck({
|
|
25793
|
+
kind: "min",
|
|
25794
|
+
value: minDate.getTime(),
|
|
25795
|
+
message: errorUtil.toString(message)
|
|
25796
|
+
});
|
|
25797
|
+
}
|
|
25798
|
+
max(maxDate, message) {
|
|
25799
|
+
return this._addCheck({
|
|
25800
|
+
kind: "max",
|
|
25801
|
+
value: maxDate.getTime(),
|
|
25802
|
+
message: errorUtil.toString(message)
|
|
25803
|
+
});
|
|
25804
|
+
}
|
|
25805
|
+
get minDate() {
|
|
25806
|
+
let min2 = null;
|
|
25807
|
+
for (const ch of this._def.checks) {
|
|
25808
|
+
if (ch.kind === "min") {
|
|
25809
|
+
if (min2 === null || ch.value > min2)
|
|
25810
|
+
min2 = ch.value;
|
|
25811
|
+
}
|
|
25812
|
+
}
|
|
25813
|
+
return min2 != null ? new Date(min2) : null;
|
|
25814
|
+
}
|
|
25815
|
+
get maxDate() {
|
|
25816
|
+
let max2 = null;
|
|
25817
|
+
for (const ch of this._def.checks) {
|
|
25818
|
+
if (ch.kind === "max") {
|
|
25819
|
+
if (max2 === null || ch.value < max2)
|
|
25820
|
+
max2 = ch.value;
|
|
25821
|
+
}
|
|
25822
|
+
}
|
|
25823
|
+
return max2 != null ? new Date(max2) : null;
|
|
25824
|
+
}
|
|
25825
|
+
}
|
|
25826
|
+
ZodDate.create = (params) => {
|
|
25827
|
+
return new ZodDate({
|
|
25828
|
+
checks: [],
|
|
25829
|
+
coerce: params?.coerce || false,
|
|
25830
|
+
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
25831
|
+
...processCreateParams(params)
|
|
25832
|
+
});
|
|
25833
|
+
};
|
|
25834
|
+
class ZodSymbol extends ZodType {
|
|
25835
|
+
_parse(input) {
|
|
25836
|
+
const parsedType = this._getType(input);
|
|
25837
|
+
if (parsedType !== ZodParsedType.symbol) {
|
|
25838
|
+
const ctx = this._getOrReturnCtx(input);
|
|
25839
|
+
addIssueToContext(ctx, {
|
|
25840
|
+
code: ZodIssueCode.invalid_type,
|
|
25841
|
+
expected: ZodParsedType.symbol,
|
|
25842
|
+
received: ctx.parsedType
|
|
25843
|
+
});
|
|
25844
|
+
return INVALID;
|
|
25845
|
+
}
|
|
25846
|
+
return OK(input.data);
|
|
25847
|
+
}
|
|
25848
|
+
}
|
|
25849
|
+
ZodSymbol.create = (params) => {
|
|
25850
|
+
return new ZodSymbol({
|
|
25851
|
+
typeName: ZodFirstPartyTypeKind.ZodSymbol,
|
|
25852
|
+
...processCreateParams(params)
|
|
25853
|
+
});
|
|
25854
|
+
};
|
|
25855
|
+
class ZodUndefined extends ZodType {
|
|
25856
|
+
_parse(input) {
|
|
25857
|
+
const parsedType = this._getType(input);
|
|
25858
|
+
if (parsedType !== ZodParsedType.undefined) {
|
|
25859
|
+
const ctx = this._getOrReturnCtx(input);
|
|
25860
|
+
addIssueToContext(ctx, {
|
|
25861
|
+
code: ZodIssueCode.invalid_type,
|
|
25862
|
+
expected: ZodParsedType.undefined,
|
|
25863
|
+
received: ctx.parsedType
|
|
25864
|
+
});
|
|
25865
|
+
return INVALID;
|
|
25866
|
+
}
|
|
25867
|
+
return OK(input.data);
|
|
25868
|
+
}
|
|
25869
|
+
}
|
|
25870
|
+
ZodUndefined.create = (params) => {
|
|
25871
|
+
return new ZodUndefined({
|
|
25872
|
+
typeName: ZodFirstPartyTypeKind.ZodUndefined,
|
|
25873
|
+
...processCreateParams(params)
|
|
25874
|
+
});
|
|
25875
|
+
};
|
|
25876
|
+
class ZodNull extends ZodType {
|
|
25877
|
+
_parse(input) {
|
|
25878
|
+
const parsedType = this._getType(input);
|
|
25879
|
+
if (parsedType !== ZodParsedType.null) {
|
|
25880
|
+
const ctx = this._getOrReturnCtx(input);
|
|
25881
|
+
addIssueToContext(ctx, {
|
|
25882
|
+
code: ZodIssueCode.invalid_type,
|
|
25883
|
+
expected: ZodParsedType.null,
|
|
25884
|
+
received: ctx.parsedType
|
|
25885
|
+
});
|
|
25886
|
+
return INVALID;
|
|
25887
|
+
}
|
|
25888
|
+
return OK(input.data);
|
|
25889
|
+
}
|
|
25890
|
+
}
|
|
25891
|
+
ZodNull.create = (params) => {
|
|
25892
|
+
return new ZodNull({
|
|
25893
|
+
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
25894
|
+
...processCreateParams(params)
|
|
25895
|
+
});
|
|
25896
|
+
};
|
|
25897
|
+
class ZodAny extends ZodType {
|
|
25898
|
+
constructor() {
|
|
25899
|
+
super(...arguments);
|
|
25900
|
+
this._any = true;
|
|
25901
|
+
}
|
|
25902
|
+
_parse(input) {
|
|
25903
|
+
return OK(input.data);
|
|
25904
|
+
}
|
|
25905
|
+
}
|
|
25906
|
+
ZodAny.create = (params) => {
|
|
25907
|
+
return new ZodAny({
|
|
25908
|
+
typeName: ZodFirstPartyTypeKind.ZodAny,
|
|
25909
|
+
...processCreateParams(params)
|
|
25910
|
+
});
|
|
25911
|
+
};
|
|
25912
|
+
class ZodUnknown extends ZodType {
|
|
25913
|
+
constructor() {
|
|
25914
|
+
super(...arguments);
|
|
25915
|
+
this._unknown = true;
|
|
25916
|
+
}
|
|
25917
|
+
_parse(input) {
|
|
25918
|
+
return OK(input.data);
|
|
25919
|
+
}
|
|
25920
|
+
}
|
|
25921
|
+
ZodUnknown.create = (params) => {
|
|
25922
|
+
return new ZodUnknown({
|
|
25923
|
+
typeName: ZodFirstPartyTypeKind.ZodUnknown,
|
|
25924
|
+
...processCreateParams(params)
|
|
25925
|
+
});
|
|
25926
|
+
};
|
|
25927
|
+
class ZodNever extends ZodType {
|
|
25928
|
+
_parse(input) {
|
|
25929
|
+
const ctx = this._getOrReturnCtx(input);
|
|
25930
|
+
addIssueToContext(ctx, {
|
|
25931
|
+
code: ZodIssueCode.invalid_type,
|
|
25932
|
+
expected: ZodParsedType.never,
|
|
25933
|
+
received: ctx.parsedType
|
|
25934
|
+
});
|
|
25935
|
+
return INVALID;
|
|
25936
|
+
}
|
|
25937
|
+
}
|
|
25938
|
+
ZodNever.create = (params) => {
|
|
25939
|
+
return new ZodNever({
|
|
25940
|
+
typeName: ZodFirstPartyTypeKind.ZodNever,
|
|
25941
|
+
...processCreateParams(params)
|
|
25942
|
+
});
|
|
25943
|
+
};
|
|
25944
|
+
class ZodVoid extends ZodType {
|
|
25945
|
+
_parse(input) {
|
|
25946
|
+
const parsedType = this._getType(input);
|
|
25947
|
+
if (parsedType !== ZodParsedType.undefined) {
|
|
25948
|
+
const ctx = this._getOrReturnCtx(input);
|
|
25949
|
+
addIssueToContext(ctx, {
|
|
25950
|
+
code: ZodIssueCode.invalid_type,
|
|
25951
|
+
expected: ZodParsedType.void,
|
|
25952
|
+
received: ctx.parsedType
|
|
25953
|
+
});
|
|
25954
|
+
return INVALID;
|
|
25955
|
+
}
|
|
25956
|
+
return OK(input.data);
|
|
25957
|
+
}
|
|
25958
|
+
}
|
|
25959
|
+
ZodVoid.create = (params) => {
|
|
25960
|
+
return new ZodVoid({
|
|
25961
|
+
typeName: ZodFirstPartyTypeKind.ZodVoid,
|
|
25962
|
+
...processCreateParams(params)
|
|
25963
|
+
});
|
|
25964
|
+
};
|
|
25965
|
+
class ZodArray extends ZodType {
|
|
25966
|
+
_parse(input) {
|
|
25967
|
+
const { ctx, status } = this._processInputParams(input);
|
|
25968
|
+
const def = this._def;
|
|
25969
|
+
if (ctx.parsedType !== ZodParsedType.array) {
|
|
25970
|
+
addIssueToContext(ctx, {
|
|
25971
|
+
code: ZodIssueCode.invalid_type,
|
|
25972
|
+
expected: ZodParsedType.array,
|
|
25973
|
+
received: ctx.parsedType
|
|
25974
|
+
});
|
|
25975
|
+
return INVALID;
|
|
25976
|
+
}
|
|
25977
|
+
if (def.exactLength !== null) {
|
|
25978
|
+
const tooBig = ctx.data.length > def.exactLength.value;
|
|
25979
|
+
const tooSmall = ctx.data.length < def.exactLength.value;
|
|
25980
|
+
if (tooBig || tooSmall) {
|
|
25981
|
+
addIssueToContext(ctx, {
|
|
25982
|
+
code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
|
|
25983
|
+
minimum: tooSmall ? def.exactLength.value : void 0,
|
|
25984
|
+
maximum: tooBig ? def.exactLength.value : void 0,
|
|
25985
|
+
type: "array",
|
|
25986
|
+
inclusive: true,
|
|
25987
|
+
exact: true,
|
|
25988
|
+
message: def.exactLength.message
|
|
25989
|
+
});
|
|
25990
|
+
status.dirty();
|
|
25991
|
+
}
|
|
25992
|
+
}
|
|
25993
|
+
if (def.minLength !== null) {
|
|
25994
|
+
if (ctx.data.length < def.minLength.value) {
|
|
25995
|
+
addIssueToContext(ctx, {
|
|
25996
|
+
code: ZodIssueCode.too_small,
|
|
25997
|
+
minimum: def.minLength.value,
|
|
25998
|
+
type: "array",
|
|
25999
|
+
inclusive: true,
|
|
26000
|
+
exact: false,
|
|
26001
|
+
message: def.minLength.message
|
|
26002
|
+
});
|
|
26003
|
+
status.dirty();
|
|
26004
|
+
}
|
|
26005
|
+
}
|
|
26006
|
+
if (def.maxLength !== null) {
|
|
26007
|
+
if (ctx.data.length > def.maxLength.value) {
|
|
26008
|
+
addIssueToContext(ctx, {
|
|
26009
|
+
code: ZodIssueCode.too_big,
|
|
26010
|
+
maximum: def.maxLength.value,
|
|
26011
|
+
type: "array",
|
|
26012
|
+
inclusive: true,
|
|
26013
|
+
exact: false,
|
|
26014
|
+
message: def.maxLength.message
|
|
26015
|
+
});
|
|
26016
|
+
status.dirty();
|
|
26017
|
+
}
|
|
26018
|
+
}
|
|
26019
|
+
if (ctx.common.async) {
|
|
26020
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
|
26021
|
+
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
26022
|
+
})).then((result2) => {
|
|
26023
|
+
return ParseStatus.mergeArray(status, result2);
|
|
26024
|
+
});
|
|
26025
|
+
}
|
|
26026
|
+
const result = [...ctx.data].map((item, i) => {
|
|
26027
|
+
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
26028
|
+
});
|
|
26029
|
+
return ParseStatus.mergeArray(status, result);
|
|
26030
|
+
}
|
|
26031
|
+
get element() {
|
|
26032
|
+
return this._def.type;
|
|
26033
|
+
}
|
|
26034
|
+
min(minLength, message) {
|
|
26035
|
+
return new ZodArray({
|
|
26036
|
+
...this._def,
|
|
26037
|
+
minLength: { value: minLength, message: errorUtil.toString(message) }
|
|
26038
|
+
});
|
|
26039
|
+
}
|
|
26040
|
+
max(maxLength, message) {
|
|
26041
|
+
return new ZodArray({
|
|
26042
|
+
...this._def,
|
|
26043
|
+
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
|
26044
|
+
});
|
|
26045
|
+
}
|
|
26046
|
+
length(len, message) {
|
|
26047
|
+
return new ZodArray({
|
|
26048
|
+
...this._def,
|
|
26049
|
+
exactLength: { value: len, message: errorUtil.toString(message) }
|
|
26050
|
+
});
|
|
26051
|
+
}
|
|
26052
|
+
nonempty(message) {
|
|
26053
|
+
return this.min(1, message);
|
|
26054
|
+
}
|
|
26055
|
+
}
|
|
26056
|
+
ZodArray.create = (schema, params) => {
|
|
26057
|
+
return new ZodArray({
|
|
26058
|
+
type: schema,
|
|
26059
|
+
minLength: null,
|
|
26060
|
+
maxLength: null,
|
|
26061
|
+
exactLength: null,
|
|
26062
|
+
typeName: ZodFirstPartyTypeKind.ZodArray,
|
|
26063
|
+
...processCreateParams(params)
|
|
26064
|
+
});
|
|
26065
|
+
};
|
|
26066
|
+
function deepPartialify(schema) {
|
|
26067
|
+
if (schema instanceof ZodObject) {
|
|
26068
|
+
const newShape = {};
|
|
26069
|
+
for (const key in schema.shape) {
|
|
26070
|
+
const fieldSchema = schema.shape[key];
|
|
26071
|
+
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
26072
|
+
}
|
|
26073
|
+
return new ZodObject({
|
|
26074
|
+
...schema._def,
|
|
26075
|
+
shape: () => newShape
|
|
26076
|
+
});
|
|
26077
|
+
} else if (schema instanceof ZodArray) {
|
|
26078
|
+
return new ZodArray({
|
|
26079
|
+
...schema._def,
|
|
26080
|
+
type: deepPartialify(schema.element)
|
|
26081
|
+
});
|
|
26082
|
+
} else if (schema instanceof ZodOptional) {
|
|
26083
|
+
return ZodOptional.create(deepPartialify(schema.unwrap()));
|
|
26084
|
+
} else if (schema instanceof ZodNullable) {
|
|
26085
|
+
return ZodNullable.create(deepPartialify(schema.unwrap()));
|
|
26086
|
+
} else if (schema instanceof ZodTuple) {
|
|
26087
|
+
return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
|
|
26088
|
+
} else {
|
|
26089
|
+
return schema;
|
|
26090
|
+
}
|
|
26091
|
+
}
|
|
26092
|
+
class ZodObject extends ZodType {
|
|
26093
|
+
constructor() {
|
|
26094
|
+
super(...arguments);
|
|
26095
|
+
this._cached = null;
|
|
26096
|
+
this.nonstrict = this.passthrough;
|
|
26097
|
+
this.augment = this.extend;
|
|
26098
|
+
}
|
|
26099
|
+
_getCached() {
|
|
26100
|
+
if (this._cached !== null)
|
|
26101
|
+
return this._cached;
|
|
26102
|
+
const shape = this._def.shape();
|
|
26103
|
+
const keys = util$1.objectKeys(shape);
|
|
26104
|
+
this._cached = { shape, keys };
|
|
26105
|
+
return this._cached;
|
|
26106
|
+
}
|
|
26107
|
+
_parse(input) {
|
|
26108
|
+
const parsedType = this._getType(input);
|
|
26109
|
+
if (parsedType !== ZodParsedType.object) {
|
|
26110
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
26111
|
+
addIssueToContext(ctx2, {
|
|
26112
|
+
code: ZodIssueCode.invalid_type,
|
|
26113
|
+
expected: ZodParsedType.object,
|
|
26114
|
+
received: ctx2.parsedType
|
|
26115
|
+
});
|
|
26116
|
+
return INVALID;
|
|
26117
|
+
}
|
|
26118
|
+
const { status, ctx } = this._processInputParams(input);
|
|
26119
|
+
const { shape, keys: shapeKeys } = this._getCached();
|
|
26120
|
+
const extraKeys = [];
|
|
26121
|
+
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
26122
|
+
for (const key in ctx.data) {
|
|
26123
|
+
if (!shapeKeys.includes(key)) {
|
|
26124
|
+
extraKeys.push(key);
|
|
26125
|
+
}
|
|
26126
|
+
}
|
|
26127
|
+
}
|
|
26128
|
+
const pairs = [];
|
|
26129
|
+
for (const key of shapeKeys) {
|
|
26130
|
+
const keyValidator = shape[key];
|
|
26131
|
+
const value = ctx.data[key];
|
|
26132
|
+
pairs.push({
|
|
26133
|
+
key: { status: "valid", value: key },
|
|
26134
|
+
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
26135
|
+
alwaysSet: key in ctx.data
|
|
26136
|
+
});
|
|
26137
|
+
}
|
|
26138
|
+
if (this._def.catchall instanceof ZodNever) {
|
|
26139
|
+
const unknownKeys = this._def.unknownKeys;
|
|
26140
|
+
if (unknownKeys === "passthrough") {
|
|
26141
|
+
for (const key of extraKeys) {
|
|
26142
|
+
pairs.push({
|
|
26143
|
+
key: { status: "valid", value: key },
|
|
26144
|
+
value: { status: "valid", value: ctx.data[key] }
|
|
26145
|
+
});
|
|
26146
|
+
}
|
|
26147
|
+
} else if (unknownKeys === "strict") {
|
|
26148
|
+
if (extraKeys.length > 0) {
|
|
26149
|
+
addIssueToContext(ctx, {
|
|
26150
|
+
code: ZodIssueCode.unrecognized_keys,
|
|
26151
|
+
keys: extraKeys
|
|
26152
|
+
});
|
|
26153
|
+
status.dirty();
|
|
26154
|
+
}
|
|
26155
|
+
} else if (unknownKeys === "strip") ;
|
|
26156
|
+
else {
|
|
26157
|
+
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
26158
|
+
}
|
|
26159
|
+
} else {
|
|
26160
|
+
const catchall = this._def.catchall;
|
|
26161
|
+
for (const key of extraKeys) {
|
|
26162
|
+
const value = ctx.data[key];
|
|
26163
|
+
pairs.push({
|
|
26164
|
+
key: { status: "valid", value: key },
|
|
26165
|
+
value: catchall._parse(
|
|
26166
|
+
new ParseInputLazyPath(ctx, value, ctx.path, key)
|
|
26167
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
26168
|
+
),
|
|
26169
|
+
alwaysSet: key in ctx.data
|
|
26170
|
+
});
|
|
26171
|
+
}
|
|
26172
|
+
}
|
|
26173
|
+
if (ctx.common.async) {
|
|
26174
|
+
return Promise.resolve().then(async () => {
|
|
26175
|
+
const syncPairs = [];
|
|
26176
|
+
for (const pair of pairs) {
|
|
26177
|
+
const key = await pair.key;
|
|
26178
|
+
const value = await pair.value;
|
|
26179
|
+
syncPairs.push({
|
|
26180
|
+
key,
|
|
26181
|
+
value,
|
|
26182
|
+
alwaysSet: pair.alwaysSet
|
|
26183
|
+
});
|
|
26184
|
+
}
|
|
26185
|
+
return syncPairs;
|
|
26186
|
+
}).then((syncPairs) => {
|
|
26187
|
+
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
26188
|
+
});
|
|
26189
|
+
} else {
|
|
26190
|
+
return ParseStatus.mergeObjectSync(status, pairs);
|
|
26191
|
+
}
|
|
26192
|
+
}
|
|
26193
|
+
get shape() {
|
|
26194
|
+
return this._def.shape();
|
|
26195
|
+
}
|
|
26196
|
+
strict(message) {
|
|
26197
|
+
errorUtil.errToObj;
|
|
26198
|
+
return new ZodObject({
|
|
26199
|
+
...this._def,
|
|
26200
|
+
unknownKeys: "strict",
|
|
26201
|
+
...message !== void 0 ? {
|
|
26202
|
+
errorMap: (issue2, ctx) => {
|
|
26203
|
+
const defaultError = this._def.errorMap?.(issue2, ctx).message ?? ctx.defaultError;
|
|
26204
|
+
if (issue2.code === "unrecognized_keys")
|
|
26205
|
+
return {
|
|
26206
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
26207
|
+
};
|
|
26208
|
+
return {
|
|
26209
|
+
message: defaultError
|
|
26210
|
+
};
|
|
26211
|
+
}
|
|
26212
|
+
} : {}
|
|
26213
|
+
});
|
|
26214
|
+
}
|
|
26215
|
+
strip() {
|
|
26216
|
+
return new ZodObject({
|
|
26217
|
+
...this._def,
|
|
26218
|
+
unknownKeys: "strip"
|
|
26219
|
+
});
|
|
26220
|
+
}
|
|
26221
|
+
passthrough() {
|
|
26222
|
+
return new ZodObject({
|
|
26223
|
+
...this._def,
|
|
26224
|
+
unknownKeys: "passthrough"
|
|
26225
|
+
});
|
|
26226
|
+
}
|
|
26227
|
+
// const AugmentFactory =
|
|
26228
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
26229
|
+
// <Augmentation extends ZodRawShape>(
|
|
26230
|
+
// augmentation: Augmentation
|
|
26231
|
+
// ): ZodObject<
|
|
26232
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
26233
|
+
// Def["unknownKeys"],
|
|
26234
|
+
// Def["catchall"]
|
|
26235
|
+
// > => {
|
|
26236
|
+
// return new ZodObject({
|
|
26237
|
+
// ...def,
|
|
26238
|
+
// shape: () => ({
|
|
26239
|
+
// ...def.shape(),
|
|
26240
|
+
// ...augmentation,
|
|
26241
|
+
// }),
|
|
26242
|
+
// }) as any;
|
|
26243
|
+
// };
|
|
26244
|
+
extend(augmentation) {
|
|
26245
|
+
return new ZodObject({
|
|
26246
|
+
...this._def,
|
|
26247
|
+
shape: () => ({
|
|
26248
|
+
...this._def.shape(),
|
|
26249
|
+
...augmentation
|
|
26250
|
+
})
|
|
26251
|
+
});
|
|
26252
|
+
}
|
|
26253
|
+
/**
|
|
26254
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
26255
|
+
* inferred type of merged objects. Please
|
|
26256
|
+
* upgrade if you are experiencing issues.
|
|
26257
|
+
*/
|
|
26258
|
+
merge(merging) {
|
|
26259
|
+
const merged = new ZodObject({
|
|
26260
|
+
unknownKeys: merging._def.unknownKeys,
|
|
26261
|
+
catchall: merging._def.catchall,
|
|
26262
|
+
shape: () => ({
|
|
26263
|
+
...this._def.shape(),
|
|
26264
|
+
...merging._def.shape()
|
|
26265
|
+
}),
|
|
26266
|
+
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
26267
|
+
});
|
|
26268
|
+
return merged;
|
|
26269
|
+
}
|
|
26270
|
+
// merge<
|
|
26271
|
+
// Incoming extends AnyZodObject,
|
|
26272
|
+
// Augmentation extends Incoming["shape"],
|
|
26273
|
+
// NewOutput extends {
|
|
26274
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
26275
|
+
// ? Augmentation[k]["_output"]
|
|
26276
|
+
// : k extends keyof Output
|
|
26277
|
+
// ? Output[k]
|
|
26278
|
+
// : never;
|
|
26279
|
+
// },
|
|
26280
|
+
// NewInput extends {
|
|
26281
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
26282
|
+
// ? Augmentation[k]["_input"]
|
|
26283
|
+
// : k extends keyof Input
|
|
26284
|
+
// ? Input[k]
|
|
26285
|
+
// : never;
|
|
26286
|
+
// }
|
|
26287
|
+
// >(
|
|
26288
|
+
// merging: Incoming
|
|
26289
|
+
// ): ZodObject<
|
|
26290
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
26291
|
+
// Incoming["_def"]["unknownKeys"],
|
|
26292
|
+
// Incoming["_def"]["catchall"],
|
|
26293
|
+
// NewOutput,
|
|
26294
|
+
// NewInput
|
|
26295
|
+
// > {
|
|
26296
|
+
// const merged: any = new ZodObject({
|
|
26297
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
26298
|
+
// catchall: merging._def.catchall,
|
|
26299
|
+
// shape: () =>
|
|
26300
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
26301
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
26302
|
+
// }) as any;
|
|
26303
|
+
// return merged;
|
|
26304
|
+
// }
|
|
26305
|
+
setKey(key, schema) {
|
|
26306
|
+
return this.augment({ [key]: schema });
|
|
26307
|
+
}
|
|
26308
|
+
// merge<Incoming extends AnyZodObject>(
|
|
26309
|
+
// merging: Incoming
|
|
26310
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
26311
|
+
// ZodObject<
|
|
26312
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
26313
|
+
// Incoming["_def"]["unknownKeys"],
|
|
26314
|
+
// Incoming["_def"]["catchall"]
|
|
26315
|
+
// > {
|
|
26316
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
26317
|
+
// // this._def.shape(),
|
|
26318
|
+
// // merging._def.shape()
|
|
26319
|
+
// // );
|
|
26320
|
+
// const merged: any = new ZodObject({
|
|
26321
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
26322
|
+
// catchall: merging._def.catchall,
|
|
26323
|
+
// shape: () =>
|
|
26324
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
26325
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
26326
|
+
// }) as any;
|
|
26327
|
+
// return merged;
|
|
26328
|
+
// }
|
|
26329
|
+
catchall(index2) {
|
|
26330
|
+
return new ZodObject({
|
|
26331
|
+
...this._def,
|
|
26332
|
+
catchall: index2
|
|
26333
|
+
});
|
|
26334
|
+
}
|
|
26335
|
+
pick(mask) {
|
|
26336
|
+
const shape = {};
|
|
26337
|
+
for (const key of util$1.objectKeys(mask)) {
|
|
26338
|
+
if (mask[key] && this.shape[key]) {
|
|
26339
|
+
shape[key] = this.shape[key];
|
|
26340
|
+
}
|
|
26341
|
+
}
|
|
26342
|
+
return new ZodObject({
|
|
26343
|
+
...this._def,
|
|
26344
|
+
shape: () => shape
|
|
26345
|
+
});
|
|
26346
|
+
}
|
|
26347
|
+
omit(mask) {
|
|
26348
|
+
const shape = {};
|
|
26349
|
+
for (const key of util$1.objectKeys(this.shape)) {
|
|
26350
|
+
if (!mask[key]) {
|
|
26351
|
+
shape[key] = this.shape[key];
|
|
26352
|
+
}
|
|
26353
|
+
}
|
|
26354
|
+
return new ZodObject({
|
|
26355
|
+
...this._def,
|
|
26356
|
+
shape: () => shape
|
|
26357
|
+
});
|
|
26358
|
+
}
|
|
26359
|
+
/**
|
|
26360
|
+
* @deprecated
|
|
26361
|
+
*/
|
|
26362
|
+
deepPartial() {
|
|
26363
|
+
return deepPartialify(this);
|
|
26364
|
+
}
|
|
26365
|
+
partial(mask) {
|
|
26366
|
+
const newShape = {};
|
|
26367
|
+
for (const key of util$1.objectKeys(this.shape)) {
|
|
26368
|
+
const fieldSchema = this.shape[key];
|
|
26369
|
+
if (mask && !mask[key]) {
|
|
26370
|
+
newShape[key] = fieldSchema;
|
|
26371
|
+
} else {
|
|
26372
|
+
newShape[key] = fieldSchema.optional();
|
|
26373
|
+
}
|
|
26374
|
+
}
|
|
26375
|
+
return new ZodObject({
|
|
26376
|
+
...this._def,
|
|
26377
|
+
shape: () => newShape
|
|
26378
|
+
});
|
|
26379
|
+
}
|
|
26380
|
+
required(mask) {
|
|
26381
|
+
const newShape = {};
|
|
26382
|
+
for (const key of util$1.objectKeys(this.shape)) {
|
|
26383
|
+
if (mask && !mask[key]) {
|
|
26384
|
+
newShape[key] = this.shape[key];
|
|
26385
|
+
} else {
|
|
26386
|
+
const fieldSchema = this.shape[key];
|
|
26387
|
+
let newField = fieldSchema;
|
|
26388
|
+
while (newField instanceof ZodOptional) {
|
|
26389
|
+
newField = newField._def.innerType;
|
|
26390
|
+
}
|
|
26391
|
+
newShape[key] = newField;
|
|
26392
|
+
}
|
|
26393
|
+
}
|
|
26394
|
+
return new ZodObject({
|
|
26395
|
+
...this._def,
|
|
26396
|
+
shape: () => newShape
|
|
26397
|
+
});
|
|
26398
|
+
}
|
|
26399
|
+
keyof() {
|
|
26400
|
+
return createZodEnum(util$1.objectKeys(this.shape));
|
|
26401
|
+
}
|
|
26402
|
+
}
|
|
26403
|
+
ZodObject.create = (shape, params) => {
|
|
26404
|
+
return new ZodObject({
|
|
26405
|
+
shape: () => shape,
|
|
26406
|
+
unknownKeys: "strip",
|
|
26407
|
+
catchall: ZodNever.create(),
|
|
26408
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
26409
|
+
...processCreateParams(params)
|
|
26410
|
+
});
|
|
26411
|
+
};
|
|
26412
|
+
ZodObject.strictCreate = (shape, params) => {
|
|
26413
|
+
return new ZodObject({
|
|
26414
|
+
shape: () => shape,
|
|
26415
|
+
unknownKeys: "strict",
|
|
26416
|
+
catchall: ZodNever.create(),
|
|
26417
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
26418
|
+
...processCreateParams(params)
|
|
26419
|
+
});
|
|
26420
|
+
};
|
|
26421
|
+
ZodObject.lazycreate = (shape, params) => {
|
|
26422
|
+
return new ZodObject({
|
|
26423
|
+
shape,
|
|
26424
|
+
unknownKeys: "strip",
|
|
26425
|
+
catchall: ZodNever.create(),
|
|
26426
|
+
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
26427
|
+
...processCreateParams(params)
|
|
26428
|
+
});
|
|
26429
|
+
};
|
|
26430
|
+
class ZodUnion extends ZodType {
|
|
26431
|
+
_parse(input) {
|
|
26432
|
+
const { ctx } = this._processInputParams(input);
|
|
26433
|
+
const options = this._def.options;
|
|
26434
|
+
function handleResults(results) {
|
|
26435
|
+
for (const result of results) {
|
|
26436
|
+
if (result.result.status === "valid") {
|
|
26437
|
+
return result.result;
|
|
26438
|
+
}
|
|
26439
|
+
}
|
|
26440
|
+
for (const result of results) {
|
|
26441
|
+
if (result.result.status === "dirty") {
|
|
26442
|
+
ctx.common.issues.push(...result.ctx.common.issues);
|
|
26443
|
+
return result.result;
|
|
26444
|
+
}
|
|
26445
|
+
}
|
|
26446
|
+
const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
|
|
26447
|
+
addIssueToContext(ctx, {
|
|
26448
|
+
code: ZodIssueCode.invalid_union,
|
|
26449
|
+
unionErrors
|
|
26450
|
+
});
|
|
26451
|
+
return INVALID;
|
|
26452
|
+
}
|
|
26453
|
+
if (ctx.common.async) {
|
|
26454
|
+
return Promise.all(options.map(async (option) => {
|
|
26455
|
+
const childCtx = {
|
|
26456
|
+
...ctx,
|
|
26457
|
+
common: {
|
|
26458
|
+
...ctx.common,
|
|
26459
|
+
issues: []
|
|
26460
|
+
},
|
|
26461
|
+
parent: null
|
|
26462
|
+
};
|
|
26463
|
+
return {
|
|
26464
|
+
result: await option._parseAsync({
|
|
26465
|
+
data: ctx.data,
|
|
26466
|
+
path: ctx.path,
|
|
26467
|
+
parent: childCtx
|
|
26468
|
+
}),
|
|
26469
|
+
ctx: childCtx
|
|
26470
|
+
};
|
|
26471
|
+
})).then(handleResults);
|
|
26472
|
+
} else {
|
|
26473
|
+
let dirty = void 0;
|
|
26474
|
+
const issues = [];
|
|
26475
|
+
for (const option of options) {
|
|
26476
|
+
const childCtx = {
|
|
26477
|
+
...ctx,
|
|
26478
|
+
common: {
|
|
26479
|
+
...ctx.common,
|
|
26480
|
+
issues: []
|
|
26481
|
+
},
|
|
26482
|
+
parent: null
|
|
26483
|
+
};
|
|
26484
|
+
const result = option._parseSync({
|
|
26485
|
+
data: ctx.data,
|
|
26486
|
+
path: ctx.path,
|
|
26487
|
+
parent: childCtx
|
|
26488
|
+
});
|
|
26489
|
+
if (result.status === "valid") {
|
|
26490
|
+
return result;
|
|
26491
|
+
} else if (result.status === "dirty" && !dirty) {
|
|
26492
|
+
dirty = { result, ctx: childCtx };
|
|
26493
|
+
}
|
|
26494
|
+
if (childCtx.common.issues.length) {
|
|
26495
|
+
issues.push(childCtx.common.issues);
|
|
26496
|
+
}
|
|
26497
|
+
}
|
|
26498
|
+
if (dirty) {
|
|
26499
|
+
ctx.common.issues.push(...dirty.ctx.common.issues);
|
|
26500
|
+
return dirty.result;
|
|
26501
|
+
}
|
|
26502
|
+
const unionErrors = issues.map((issues2) => new ZodError(issues2));
|
|
26503
|
+
addIssueToContext(ctx, {
|
|
26504
|
+
code: ZodIssueCode.invalid_union,
|
|
26505
|
+
unionErrors
|
|
26506
|
+
});
|
|
26507
|
+
return INVALID;
|
|
26508
|
+
}
|
|
26509
|
+
}
|
|
26510
|
+
get options() {
|
|
26511
|
+
return this._def.options;
|
|
26512
|
+
}
|
|
26513
|
+
}
|
|
26514
|
+
ZodUnion.create = (types2, params) => {
|
|
26515
|
+
return new ZodUnion({
|
|
26516
|
+
options: types2,
|
|
26517
|
+
typeName: ZodFirstPartyTypeKind.ZodUnion,
|
|
26518
|
+
...processCreateParams(params)
|
|
26519
|
+
});
|
|
26520
|
+
};
|
|
26521
|
+
function mergeValues(a, b) {
|
|
26522
|
+
const aType = getParsedType(a);
|
|
26523
|
+
const bType = getParsedType(b);
|
|
26524
|
+
if (a === b) {
|
|
26525
|
+
return { valid: true, data: a };
|
|
26526
|
+
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
26527
|
+
const bKeys = util$1.objectKeys(b);
|
|
26528
|
+
const sharedKeys = util$1.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
26529
|
+
const newObj = { ...a, ...b };
|
|
26530
|
+
for (const key of sharedKeys) {
|
|
26531
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
26532
|
+
if (!sharedValue.valid) {
|
|
26533
|
+
return { valid: false };
|
|
26534
|
+
}
|
|
26535
|
+
newObj[key] = sharedValue.data;
|
|
26536
|
+
}
|
|
26537
|
+
return { valid: true, data: newObj };
|
|
26538
|
+
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
26539
|
+
if (a.length !== b.length) {
|
|
26540
|
+
return { valid: false };
|
|
26541
|
+
}
|
|
26542
|
+
const newArray = [];
|
|
26543
|
+
for (let index2 = 0; index2 < a.length; index2++) {
|
|
26544
|
+
const itemA = a[index2];
|
|
26545
|
+
const itemB = b[index2];
|
|
26546
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
26547
|
+
if (!sharedValue.valid) {
|
|
26548
|
+
return { valid: false };
|
|
26549
|
+
}
|
|
26550
|
+
newArray.push(sharedValue.data);
|
|
26551
|
+
}
|
|
26552
|
+
return { valid: true, data: newArray };
|
|
26553
|
+
} else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
|
|
26554
|
+
return { valid: true, data: a };
|
|
26555
|
+
} else {
|
|
26556
|
+
return { valid: false };
|
|
26557
|
+
}
|
|
26558
|
+
}
|
|
26559
|
+
class ZodIntersection extends ZodType {
|
|
26560
|
+
_parse(input) {
|
|
26561
|
+
const { status, ctx } = this._processInputParams(input);
|
|
26562
|
+
const handleParsed = (parsedLeft, parsedRight) => {
|
|
26563
|
+
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
26564
|
+
return INVALID;
|
|
26565
|
+
}
|
|
26566
|
+
const merged = mergeValues(parsedLeft.value, parsedRight.value);
|
|
26567
|
+
if (!merged.valid) {
|
|
26568
|
+
addIssueToContext(ctx, {
|
|
26569
|
+
code: ZodIssueCode.invalid_intersection_types
|
|
26570
|
+
});
|
|
26571
|
+
return INVALID;
|
|
26572
|
+
}
|
|
26573
|
+
if (isDirty(parsedLeft) || isDirty(parsedRight)) {
|
|
26574
|
+
status.dirty();
|
|
26575
|
+
}
|
|
26576
|
+
return { status: status.value, value: merged.data };
|
|
26577
|
+
};
|
|
26578
|
+
if (ctx.common.async) {
|
|
26579
|
+
return Promise.all([
|
|
26580
|
+
this._def.left._parseAsync({
|
|
26581
|
+
data: ctx.data,
|
|
26582
|
+
path: ctx.path,
|
|
26583
|
+
parent: ctx
|
|
26584
|
+
}),
|
|
26585
|
+
this._def.right._parseAsync({
|
|
26586
|
+
data: ctx.data,
|
|
26587
|
+
path: ctx.path,
|
|
26588
|
+
parent: ctx
|
|
26589
|
+
})
|
|
26590
|
+
]).then(([left, right]) => handleParsed(left, right));
|
|
26591
|
+
} else {
|
|
26592
|
+
return handleParsed(this._def.left._parseSync({
|
|
26593
|
+
data: ctx.data,
|
|
26594
|
+
path: ctx.path,
|
|
26595
|
+
parent: ctx
|
|
26596
|
+
}), this._def.right._parseSync({
|
|
26597
|
+
data: ctx.data,
|
|
26598
|
+
path: ctx.path,
|
|
26599
|
+
parent: ctx
|
|
26600
|
+
}));
|
|
26601
|
+
}
|
|
26602
|
+
}
|
|
26603
|
+
}
|
|
26604
|
+
ZodIntersection.create = (left, right, params) => {
|
|
26605
|
+
return new ZodIntersection({
|
|
26606
|
+
left,
|
|
26607
|
+
right,
|
|
26608
|
+
typeName: ZodFirstPartyTypeKind.ZodIntersection,
|
|
26609
|
+
...processCreateParams(params)
|
|
26610
|
+
});
|
|
26611
|
+
};
|
|
26612
|
+
class ZodTuple extends ZodType {
|
|
26613
|
+
_parse(input) {
|
|
26614
|
+
const { status, ctx } = this._processInputParams(input);
|
|
26615
|
+
if (ctx.parsedType !== ZodParsedType.array) {
|
|
26616
|
+
addIssueToContext(ctx, {
|
|
26617
|
+
code: ZodIssueCode.invalid_type,
|
|
26618
|
+
expected: ZodParsedType.array,
|
|
26619
|
+
received: ctx.parsedType
|
|
26620
|
+
});
|
|
26621
|
+
return INVALID;
|
|
26622
|
+
}
|
|
26623
|
+
if (ctx.data.length < this._def.items.length) {
|
|
26624
|
+
addIssueToContext(ctx, {
|
|
26625
|
+
code: ZodIssueCode.too_small,
|
|
26626
|
+
minimum: this._def.items.length,
|
|
26627
|
+
inclusive: true,
|
|
26628
|
+
exact: false,
|
|
26629
|
+
type: "array"
|
|
26630
|
+
});
|
|
26631
|
+
return INVALID;
|
|
26632
|
+
}
|
|
26633
|
+
const rest = this._def.rest;
|
|
26634
|
+
if (!rest && ctx.data.length > this._def.items.length) {
|
|
26635
|
+
addIssueToContext(ctx, {
|
|
26636
|
+
code: ZodIssueCode.too_big,
|
|
26637
|
+
maximum: this._def.items.length,
|
|
26638
|
+
inclusive: true,
|
|
26639
|
+
exact: false,
|
|
26640
|
+
type: "array"
|
|
26641
|
+
});
|
|
26642
|
+
status.dirty();
|
|
26643
|
+
}
|
|
26644
|
+
const items2 = [...ctx.data].map((item, itemIndex) => {
|
|
26645
|
+
const schema = this._def.items[itemIndex] || this._def.rest;
|
|
26646
|
+
if (!schema)
|
|
26647
|
+
return null;
|
|
26648
|
+
return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
|
26649
|
+
}).filter((x) => !!x);
|
|
26650
|
+
if (ctx.common.async) {
|
|
26651
|
+
return Promise.all(items2).then((results) => {
|
|
26652
|
+
return ParseStatus.mergeArray(status, results);
|
|
26653
|
+
});
|
|
26654
|
+
} else {
|
|
26655
|
+
return ParseStatus.mergeArray(status, items2);
|
|
26656
|
+
}
|
|
26657
|
+
}
|
|
26658
|
+
get items() {
|
|
26659
|
+
return this._def.items;
|
|
26660
|
+
}
|
|
26661
|
+
rest(rest) {
|
|
26662
|
+
return new ZodTuple({
|
|
26663
|
+
...this._def,
|
|
26664
|
+
rest
|
|
26665
|
+
});
|
|
26666
|
+
}
|
|
26667
|
+
}
|
|
26668
|
+
ZodTuple.create = (schemas, params) => {
|
|
26669
|
+
if (!Array.isArray(schemas)) {
|
|
26670
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
26671
|
+
}
|
|
26672
|
+
return new ZodTuple({
|
|
26673
|
+
items: schemas,
|
|
26674
|
+
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
|
26675
|
+
rest: null,
|
|
26676
|
+
...processCreateParams(params)
|
|
26677
|
+
});
|
|
26678
|
+
};
|
|
26679
|
+
class ZodMap extends ZodType {
|
|
26680
|
+
get keySchema() {
|
|
26681
|
+
return this._def.keyType;
|
|
26682
|
+
}
|
|
26683
|
+
get valueSchema() {
|
|
26684
|
+
return this._def.valueType;
|
|
26685
|
+
}
|
|
26686
|
+
_parse(input) {
|
|
26687
|
+
const { status, ctx } = this._processInputParams(input);
|
|
26688
|
+
if (ctx.parsedType !== ZodParsedType.map) {
|
|
26689
|
+
addIssueToContext(ctx, {
|
|
26690
|
+
code: ZodIssueCode.invalid_type,
|
|
26691
|
+
expected: ZodParsedType.map,
|
|
26692
|
+
received: ctx.parsedType
|
|
26693
|
+
});
|
|
26694
|
+
return INVALID;
|
|
26695
|
+
}
|
|
26696
|
+
const keyType = this._def.keyType;
|
|
26697
|
+
const valueType = this._def.valueType;
|
|
26698
|
+
const pairs = [...ctx.data.entries()].map(([key, value], index2) => {
|
|
26699
|
+
return {
|
|
26700
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index2, "key"])),
|
|
26701
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"]))
|
|
26702
|
+
};
|
|
26703
|
+
});
|
|
26704
|
+
if (ctx.common.async) {
|
|
26705
|
+
const finalMap = /* @__PURE__ */ new Map();
|
|
26706
|
+
return Promise.resolve().then(async () => {
|
|
26707
|
+
for (const pair of pairs) {
|
|
26708
|
+
const key = await pair.key;
|
|
26709
|
+
const value = await pair.value;
|
|
26710
|
+
if (key.status === "aborted" || value.status === "aborted") {
|
|
26711
|
+
return INVALID;
|
|
26712
|
+
}
|
|
26713
|
+
if (key.status === "dirty" || value.status === "dirty") {
|
|
26714
|
+
status.dirty();
|
|
26715
|
+
}
|
|
26716
|
+
finalMap.set(key.value, value.value);
|
|
26717
|
+
}
|
|
26718
|
+
return { status: status.value, value: finalMap };
|
|
26719
|
+
});
|
|
26720
|
+
} else {
|
|
26721
|
+
const finalMap = /* @__PURE__ */ new Map();
|
|
26722
|
+
for (const pair of pairs) {
|
|
26723
|
+
const key = pair.key;
|
|
26724
|
+
const value = pair.value;
|
|
26725
|
+
if (key.status === "aborted" || value.status === "aborted") {
|
|
26726
|
+
return INVALID;
|
|
26727
|
+
}
|
|
26728
|
+
if (key.status === "dirty" || value.status === "dirty") {
|
|
26729
|
+
status.dirty();
|
|
26730
|
+
}
|
|
26731
|
+
finalMap.set(key.value, value.value);
|
|
26732
|
+
}
|
|
26733
|
+
return { status: status.value, value: finalMap };
|
|
26734
|
+
}
|
|
26735
|
+
}
|
|
26736
|
+
}
|
|
26737
|
+
ZodMap.create = (keyType, valueType, params) => {
|
|
26738
|
+
return new ZodMap({
|
|
26739
|
+
valueType,
|
|
26740
|
+
keyType,
|
|
26741
|
+
typeName: ZodFirstPartyTypeKind.ZodMap,
|
|
26742
|
+
...processCreateParams(params)
|
|
26743
|
+
});
|
|
26744
|
+
};
|
|
26745
|
+
class ZodSet extends ZodType {
|
|
26746
|
+
_parse(input) {
|
|
26747
|
+
const { status, ctx } = this._processInputParams(input);
|
|
26748
|
+
if (ctx.parsedType !== ZodParsedType.set) {
|
|
26749
|
+
addIssueToContext(ctx, {
|
|
26750
|
+
code: ZodIssueCode.invalid_type,
|
|
26751
|
+
expected: ZodParsedType.set,
|
|
26752
|
+
received: ctx.parsedType
|
|
26753
|
+
});
|
|
26754
|
+
return INVALID;
|
|
26755
|
+
}
|
|
26756
|
+
const def = this._def;
|
|
26757
|
+
if (def.minSize !== null) {
|
|
26758
|
+
if (ctx.data.size < def.minSize.value) {
|
|
26759
|
+
addIssueToContext(ctx, {
|
|
26760
|
+
code: ZodIssueCode.too_small,
|
|
26761
|
+
minimum: def.minSize.value,
|
|
26762
|
+
type: "set",
|
|
26763
|
+
inclusive: true,
|
|
26764
|
+
exact: false,
|
|
26765
|
+
message: def.minSize.message
|
|
26766
|
+
});
|
|
26767
|
+
status.dirty();
|
|
26768
|
+
}
|
|
26769
|
+
}
|
|
26770
|
+
if (def.maxSize !== null) {
|
|
26771
|
+
if (ctx.data.size > def.maxSize.value) {
|
|
26772
|
+
addIssueToContext(ctx, {
|
|
26773
|
+
code: ZodIssueCode.too_big,
|
|
26774
|
+
maximum: def.maxSize.value,
|
|
26775
|
+
type: "set",
|
|
26776
|
+
inclusive: true,
|
|
26777
|
+
exact: false,
|
|
26778
|
+
message: def.maxSize.message
|
|
26779
|
+
});
|
|
26780
|
+
status.dirty();
|
|
26781
|
+
}
|
|
26782
|
+
}
|
|
26783
|
+
const valueType = this._def.valueType;
|
|
26784
|
+
function finalizeSet(elements2) {
|
|
26785
|
+
const parsedSet = /* @__PURE__ */ new Set();
|
|
26786
|
+
for (const element of elements2) {
|
|
26787
|
+
if (element.status === "aborted")
|
|
26788
|
+
return INVALID;
|
|
26789
|
+
if (element.status === "dirty")
|
|
26790
|
+
status.dirty();
|
|
26791
|
+
parsedSet.add(element.value);
|
|
26792
|
+
}
|
|
26793
|
+
return { status: status.value, value: parsedSet };
|
|
26794
|
+
}
|
|
26795
|
+
const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
26796
|
+
if (ctx.common.async) {
|
|
26797
|
+
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
|
|
26798
|
+
} else {
|
|
26799
|
+
return finalizeSet(elements);
|
|
26800
|
+
}
|
|
26801
|
+
}
|
|
26802
|
+
min(minSize, message) {
|
|
26803
|
+
return new ZodSet({
|
|
26804
|
+
...this._def,
|
|
26805
|
+
minSize: { value: minSize, message: errorUtil.toString(message) }
|
|
26806
|
+
});
|
|
26807
|
+
}
|
|
26808
|
+
max(maxSize, message) {
|
|
26809
|
+
return new ZodSet({
|
|
26810
|
+
...this._def,
|
|
26811
|
+
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
|
26812
|
+
});
|
|
26813
|
+
}
|
|
26814
|
+
size(size2, message) {
|
|
26815
|
+
return this.min(size2, message).max(size2, message);
|
|
26816
|
+
}
|
|
26817
|
+
nonempty(message) {
|
|
26818
|
+
return this.min(1, message);
|
|
26819
|
+
}
|
|
26820
|
+
}
|
|
26821
|
+
ZodSet.create = (valueType, params) => {
|
|
26822
|
+
return new ZodSet({
|
|
26823
|
+
valueType,
|
|
26824
|
+
minSize: null,
|
|
26825
|
+
maxSize: null,
|
|
26826
|
+
typeName: ZodFirstPartyTypeKind.ZodSet,
|
|
26827
|
+
...processCreateParams(params)
|
|
26828
|
+
});
|
|
26829
|
+
};
|
|
26830
|
+
class ZodLazy extends ZodType {
|
|
26831
|
+
get schema() {
|
|
26832
|
+
return this._def.getter();
|
|
26833
|
+
}
|
|
26834
|
+
_parse(input) {
|
|
26835
|
+
const { ctx } = this._processInputParams(input);
|
|
26836
|
+
const lazySchema = this._def.getter();
|
|
26837
|
+
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
26838
|
+
}
|
|
26839
|
+
}
|
|
26840
|
+
ZodLazy.create = (getter, params) => {
|
|
26841
|
+
return new ZodLazy({
|
|
26842
|
+
getter,
|
|
26843
|
+
typeName: ZodFirstPartyTypeKind.ZodLazy,
|
|
26844
|
+
...processCreateParams(params)
|
|
26845
|
+
});
|
|
26846
|
+
};
|
|
26847
|
+
class ZodLiteral extends ZodType {
|
|
26848
|
+
_parse(input) {
|
|
26849
|
+
if (input.data !== this._def.value) {
|
|
26850
|
+
const ctx = this._getOrReturnCtx(input);
|
|
26851
|
+
addIssueToContext(ctx, {
|
|
26852
|
+
received: ctx.data,
|
|
26853
|
+
code: ZodIssueCode.invalid_literal,
|
|
26854
|
+
expected: this._def.value
|
|
26855
|
+
});
|
|
26856
|
+
return INVALID;
|
|
26857
|
+
}
|
|
26858
|
+
return { status: "valid", value: input.data };
|
|
26859
|
+
}
|
|
26860
|
+
get value() {
|
|
26861
|
+
return this._def.value;
|
|
26862
|
+
}
|
|
26863
|
+
}
|
|
26864
|
+
ZodLiteral.create = (value, params) => {
|
|
26865
|
+
return new ZodLiteral({
|
|
26866
|
+
value,
|
|
26867
|
+
typeName: ZodFirstPartyTypeKind.ZodLiteral,
|
|
26868
|
+
...processCreateParams(params)
|
|
26869
|
+
});
|
|
26870
|
+
};
|
|
26871
|
+
function createZodEnum(values, params) {
|
|
26872
|
+
return new ZodEnum({
|
|
26873
|
+
values,
|
|
26874
|
+
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
26875
|
+
...processCreateParams(params)
|
|
26876
|
+
});
|
|
26877
|
+
}
|
|
26878
|
+
class ZodEnum extends ZodType {
|
|
26879
|
+
_parse(input) {
|
|
26880
|
+
if (typeof input.data !== "string") {
|
|
26881
|
+
const ctx = this._getOrReturnCtx(input);
|
|
26882
|
+
const expectedValues = this._def.values;
|
|
26883
|
+
addIssueToContext(ctx, {
|
|
26884
|
+
expected: util$1.joinValues(expectedValues),
|
|
26885
|
+
received: ctx.parsedType,
|
|
26886
|
+
code: ZodIssueCode.invalid_type
|
|
26887
|
+
});
|
|
26888
|
+
return INVALID;
|
|
26889
|
+
}
|
|
26890
|
+
if (!this._cache) {
|
|
26891
|
+
this._cache = new Set(this._def.values);
|
|
26892
|
+
}
|
|
26893
|
+
if (!this._cache.has(input.data)) {
|
|
26894
|
+
const ctx = this._getOrReturnCtx(input);
|
|
26895
|
+
const expectedValues = this._def.values;
|
|
26896
|
+
addIssueToContext(ctx, {
|
|
26897
|
+
received: ctx.data,
|
|
26898
|
+
code: ZodIssueCode.invalid_enum_value,
|
|
26899
|
+
options: expectedValues
|
|
26900
|
+
});
|
|
26901
|
+
return INVALID;
|
|
26902
|
+
}
|
|
26903
|
+
return OK(input.data);
|
|
26904
|
+
}
|
|
26905
|
+
get options() {
|
|
26906
|
+
return this._def.values;
|
|
26907
|
+
}
|
|
26908
|
+
get enum() {
|
|
26909
|
+
const enumValues = {};
|
|
26910
|
+
for (const val of this._def.values) {
|
|
26911
|
+
enumValues[val] = val;
|
|
26912
|
+
}
|
|
26913
|
+
return enumValues;
|
|
26914
|
+
}
|
|
26915
|
+
get Values() {
|
|
26916
|
+
const enumValues = {};
|
|
26917
|
+
for (const val of this._def.values) {
|
|
26918
|
+
enumValues[val] = val;
|
|
26919
|
+
}
|
|
26920
|
+
return enumValues;
|
|
26921
|
+
}
|
|
26922
|
+
get Enum() {
|
|
26923
|
+
const enumValues = {};
|
|
26924
|
+
for (const val of this._def.values) {
|
|
26925
|
+
enumValues[val] = val;
|
|
26926
|
+
}
|
|
26927
|
+
return enumValues;
|
|
26928
|
+
}
|
|
26929
|
+
extract(values, newDef = this._def) {
|
|
26930
|
+
return ZodEnum.create(values, {
|
|
26931
|
+
...this._def,
|
|
26932
|
+
...newDef
|
|
26933
|
+
});
|
|
26934
|
+
}
|
|
26935
|
+
exclude(values, newDef = this._def) {
|
|
26936
|
+
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
26937
|
+
...this._def,
|
|
26938
|
+
...newDef
|
|
26939
|
+
});
|
|
26940
|
+
}
|
|
26941
|
+
}
|
|
26942
|
+
ZodEnum.create = createZodEnum;
|
|
26943
|
+
class ZodNativeEnum extends ZodType {
|
|
26944
|
+
_parse(input) {
|
|
26945
|
+
const nativeEnumValues = util$1.getValidEnumValues(this._def.values);
|
|
26946
|
+
const ctx = this._getOrReturnCtx(input);
|
|
26947
|
+
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
26948
|
+
const expectedValues = util$1.objectValues(nativeEnumValues);
|
|
26949
|
+
addIssueToContext(ctx, {
|
|
26950
|
+
expected: util$1.joinValues(expectedValues),
|
|
26951
|
+
received: ctx.parsedType,
|
|
26952
|
+
code: ZodIssueCode.invalid_type
|
|
26953
|
+
});
|
|
26954
|
+
return INVALID;
|
|
26955
|
+
}
|
|
26956
|
+
if (!this._cache) {
|
|
26957
|
+
this._cache = new Set(util$1.getValidEnumValues(this._def.values));
|
|
26958
|
+
}
|
|
26959
|
+
if (!this._cache.has(input.data)) {
|
|
26960
|
+
const expectedValues = util$1.objectValues(nativeEnumValues);
|
|
26961
|
+
addIssueToContext(ctx, {
|
|
26962
|
+
received: ctx.data,
|
|
26963
|
+
code: ZodIssueCode.invalid_enum_value,
|
|
26964
|
+
options: expectedValues
|
|
26965
|
+
});
|
|
26966
|
+
return INVALID;
|
|
26967
|
+
}
|
|
26968
|
+
return OK(input.data);
|
|
26969
|
+
}
|
|
26970
|
+
get enum() {
|
|
26971
|
+
return this._def.values;
|
|
26972
|
+
}
|
|
26973
|
+
}
|
|
26974
|
+
ZodNativeEnum.create = (values, params) => {
|
|
26975
|
+
return new ZodNativeEnum({
|
|
26976
|
+
values,
|
|
26977
|
+
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
|
|
26978
|
+
...processCreateParams(params)
|
|
26979
|
+
});
|
|
26980
|
+
};
|
|
26981
|
+
class ZodPromise extends ZodType {
|
|
26982
|
+
unwrap() {
|
|
26983
|
+
return this._def.type;
|
|
26984
|
+
}
|
|
26985
|
+
_parse(input) {
|
|
26986
|
+
const { ctx } = this._processInputParams(input);
|
|
26987
|
+
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
26988
|
+
addIssueToContext(ctx, {
|
|
26989
|
+
code: ZodIssueCode.invalid_type,
|
|
26990
|
+
expected: ZodParsedType.promise,
|
|
26991
|
+
received: ctx.parsedType
|
|
26992
|
+
});
|
|
26993
|
+
return INVALID;
|
|
26994
|
+
}
|
|
26995
|
+
const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
26996
|
+
return OK(promisified.then((data2) => {
|
|
26997
|
+
return this._def.type.parseAsync(data2, {
|
|
26998
|
+
path: ctx.path,
|
|
26999
|
+
errorMap: ctx.common.contextualErrorMap
|
|
27000
|
+
});
|
|
27001
|
+
}));
|
|
27002
|
+
}
|
|
27003
|
+
}
|
|
27004
|
+
ZodPromise.create = (schema, params) => {
|
|
27005
|
+
return new ZodPromise({
|
|
27006
|
+
type: schema,
|
|
27007
|
+
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
27008
|
+
...processCreateParams(params)
|
|
27009
|
+
});
|
|
27010
|
+
};
|
|
27011
|
+
class ZodEffects extends ZodType {
|
|
27012
|
+
innerType() {
|
|
27013
|
+
return this._def.schema;
|
|
27014
|
+
}
|
|
27015
|
+
sourceType() {
|
|
27016
|
+
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
27017
|
+
}
|
|
27018
|
+
_parse(input) {
|
|
27019
|
+
const { status, ctx } = this._processInputParams(input);
|
|
27020
|
+
const effect = this._def.effect || null;
|
|
27021
|
+
const checkCtx = {
|
|
27022
|
+
addIssue: (arg) => {
|
|
27023
|
+
addIssueToContext(ctx, arg);
|
|
27024
|
+
if (arg.fatal) {
|
|
27025
|
+
status.abort();
|
|
27026
|
+
} else {
|
|
27027
|
+
status.dirty();
|
|
27028
|
+
}
|
|
27029
|
+
},
|
|
27030
|
+
get path() {
|
|
27031
|
+
return ctx.path;
|
|
27032
|
+
}
|
|
27033
|
+
};
|
|
27034
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
27035
|
+
if (effect.type === "preprocess") {
|
|
27036
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
27037
|
+
if (ctx.common.async) {
|
|
27038
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
27039
|
+
if (status.value === "aborted")
|
|
27040
|
+
return INVALID;
|
|
27041
|
+
const result = await this._def.schema._parseAsync({
|
|
27042
|
+
data: processed2,
|
|
27043
|
+
path: ctx.path,
|
|
27044
|
+
parent: ctx
|
|
27045
|
+
});
|
|
27046
|
+
if (result.status === "aborted")
|
|
27047
|
+
return INVALID;
|
|
27048
|
+
if (result.status === "dirty")
|
|
27049
|
+
return DIRTY(result.value);
|
|
27050
|
+
if (status.value === "dirty")
|
|
27051
|
+
return DIRTY(result.value);
|
|
27052
|
+
return result;
|
|
27053
|
+
});
|
|
27054
|
+
} else {
|
|
27055
|
+
if (status.value === "aborted")
|
|
27056
|
+
return INVALID;
|
|
27057
|
+
const result = this._def.schema._parseSync({
|
|
27058
|
+
data: processed,
|
|
27059
|
+
path: ctx.path,
|
|
27060
|
+
parent: ctx
|
|
27061
|
+
});
|
|
27062
|
+
if (result.status === "aborted")
|
|
27063
|
+
return INVALID;
|
|
27064
|
+
if (result.status === "dirty")
|
|
27065
|
+
return DIRTY(result.value);
|
|
27066
|
+
if (status.value === "dirty")
|
|
27067
|
+
return DIRTY(result.value);
|
|
27068
|
+
return result;
|
|
27069
|
+
}
|
|
27070
|
+
}
|
|
27071
|
+
if (effect.type === "refinement") {
|
|
27072
|
+
const executeRefinement = (acc) => {
|
|
27073
|
+
const result = effect.refinement(acc, checkCtx);
|
|
27074
|
+
if (ctx.common.async) {
|
|
27075
|
+
return Promise.resolve(result);
|
|
27076
|
+
}
|
|
27077
|
+
if (result instanceof Promise) {
|
|
27078
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
27079
|
+
}
|
|
27080
|
+
return acc;
|
|
27081
|
+
};
|
|
27082
|
+
if (ctx.common.async === false) {
|
|
27083
|
+
const inner = this._def.schema._parseSync({
|
|
27084
|
+
data: ctx.data,
|
|
27085
|
+
path: ctx.path,
|
|
27086
|
+
parent: ctx
|
|
27087
|
+
});
|
|
27088
|
+
if (inner.status === "aborted")
|
|
27089
|
+
return INVALID;
|
|
27090
|
+
if (inner.status === "dirty")
|
|
27091
|
+
status.dirty();
|
|
27092
|
+
executeRefinement(inner.value);
|
|
27093
|
+
return { status: status.value, value: inner.value };
|
|
27094
|
+
} else {
|
|
27095
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
27096
|
+
if (inner.status === "aborted")
|
|
27097
|
+
return INVALID;
|
|
27098
|
+
if (inner.status === "dirty")
|
|
27099
|
+
status.dirty();
|
|
27100
|
+
return executeRefinement(inner.value).then(() => {
|
|
27101
|
+
return { status: status.value, value: inner.value };
|
|
27102
|
+
});
|
|
27103
|
+
});
|
|
27104
|
+
}
|
|
27105
|
+
}
|
|
27106
|
+
if (effect.type === "transform") {
|
|
27107
|
+
if (ctx.common.async === false) {
|
|
27108
|
+
const base = this._def.schema._parseSync({
|
|
27109
|
+
data: ctx.data,
|
|
27110
|
+
path: ctx.path,
|
|
27111
|
+
parent: ctx
|
|
27112
|
+
});
|
|
27113
|
+
if (!isValid(base))
|
|
27114
|
+
return INVALID;
|
|
27115
|
+
const result = effect.transform(base.value, checkCtx);
|
|
27116
|
+
if (result instanceof Promise) {
|
|
27117
|
+
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
27118
|
+
}
|
|
27119
|
+
return { status: status.value, value: result };
|
|
27120
|
+
} else {
|
|
27121
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
27122
|
+
if (!isValid(base))
|
|
27123
|
+
return INVALID;
|
|
27124
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
27125
|
+
status: status.value,
|
|
27126
|
+
value: result
|
|
27127
|
+
}));
|
|
27128
|
+
});
|
|
27129
|
+
}
|
|
27130
|
+
}
|
|
27131
|
+
util$1.assertNever(effect);
|
|
27132
|
+
}
|
|
27133
|
+
}
|
|
27134
|
+
ZodEffects.create = (schema, effect, params) => {
|
|
27135
|
+
return new ZodEffects({
|
|
27136
|
+
schema,
|
|
27137
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
27138
|
+
effect,
|
|
27139
|
+
...processCreateParams(params)
|
|
27140
|
+
});
|
|
27141
|
+
};
|
|
27142
|
+
ZodEffects.createWithPreprocess = (preprocess2, schema, params) => {
|
|
27143
|
+
return new ZodEffects({
|
|
27144
|
+
schema,
|
|
27145
|
+
effect: { type: "preprocess", transform: preprocess2 },
|
|
27146
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
27147
|
+
...processCreateParams(params)
|
|
27148
|
+
});
|
|
27149
|
+
};
|
|
27150
|
+
class ZodOptional extends ZodType {
|
|
27151
|
+
_parse(input) {
|
|
27152
|
+
const parsedType = this._getType(input);
|
|
27153
|
+
if (parsedType === ZodParsedType.undefined) {
|
|
27154
|
+
return OK(void 0);
|
|
27155
|
+
}
|
|
27156
|
+
return this._def.innerType._parse(input);
|
|
27157
|
+
}
|
|
27158
|
+
unwrap() {
|
|
27159
|
+
return this._def.innerType;
|
|
27160
|
+
}
|
|
27161
|
+
}
|
|
27162
|
+
ZodOptional.create = (type2, params) => {
|
|
27163
|
+
return new ZodOptional({
|
|
27164
|
+
innerType: type2,
|
|
27165
|
+
typeName: ZodFirstPartyTypeKind.ZodOptional,
|
|
27166
|
+
...processCreateParams(params)
|
|
27167
|
+
});
|
|
27168
|
+
};
|
|
27169
|
+
class ZodNullable extends ZodType {
|
|
27170
|
+
_parse(input) {
|
|
27171
|
+
const parsedType = this._getType(input);
|
|
27172
|
+
if (parsedType === ZodParsedType.null) {
|
|
27173
|
+
return OK(null);
|
|
27174
|
+
}
|
|
27175
|
+
return this._def.innerType._parse(input);
|
|
27176
|
+
}
|
|
27177
|
+
unwrap() {
|
|
27178
|
+
return this._def.innerType;
|
|
27179
|
+
}
|
|
27180
|
+
}
|
|
27181
|
+
ZodNullable.create = (type2, params) => {
|
|
27182
|
+
return new ZodNullable({
|
|
27183
|
+
innerType: type2,
|
|
27184
|
+
typeName: ZodFirstPartyTypeKind.ZodNullable,
|
|
27185
|
+
...processCreateParams(params)
|
|
27186
|
+
});
|
|
27187
|
+
};
|
|
27188
|
+
class ZodDefault extends ZodType {
|
|
27189
|
+
_parse(input) {
|
|
27190
|
+
const { ctx } = this._processInputParams(input);
|
|
27191
|
+
let data2 = ctx.data;
|
|
27192
|
+
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
27193
|
+
data2 = this._def.defaultValue();
|
|
27194
|
+
}
|
|
27195
|
+
return this._def.innerType._parse({
|
|
27196
|
+
data: data2,
|
|
27197
|
+
path: ctx.path,
|
|
27198
|
+
parent: ctx
|
|
27199
|
+
});
|
|
27200
|
+
}
|
|
27201
|
+
removeDefault() {
|
|
27202
|
+
return this._def.innerType;
|
|
27203
|
+
}
|
|
27204
|
+
}
|
|
27205
|
+
ZodDefault.create = (type2, params) => {
|
|
27206
|
+
return new ZodDefault({
|
|
27207
|
+
innerType: type2,
|
|
27208
|
+
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
27209
|
+
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
|
27210
|
+
...processCreateParams(params)
|
|
27211
|
+
});
|
|
27212
|
+
};
|
|
27213
|
+
class ZodCatch extends ZodType {
|
|
27214
|
+
_parse(input) {
|
|
27215
|
+
const { ctx } = this._processInputParams(input);
|
|
27216
|
+
const newCtx = {
|
|
27217
|
+
...ctx,
|
|
27218
|
+
common: {
|
|
27219
|
+
...ctx.common,
|
|
27220
|
+
issues: []
|
|
27221
|
+
}
|
|
27222
|
+
};
|
|
27223
|
+
const result = this._def.innerType._parse({
|
|
27224
|
+
data: newCtx.data,
|
|
27225
|
+
path: newCtx.path,
|
|
27226
|
+
parent: {
|
|
27227
|
+
...newCtx
|
|
27228
|
+
}
|
|
27229
|
+
});
|
|
27230
|
+
if (isAsync(result)) {
|
|
27231
|
+
return result.then((result2) => {
|
|
27232
|
+
return {
|
|
27233
|
+
status: "valid",
|
|
27234
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
27235
|
+
get error() {
|
|
27236
|
+
return new ZodError(newCtx.common.issues);
|
|
27237
|
+
},
|
|
27238
|
+
input: newCtx.data
|
|
27239
|
+
})
|
|
27240
|
+
};
|
|
27241
|
+
});
|
|
27242
|
+
} else {
|
|
27243
|
+
return {
|
|
27244
|
+
status: "valid",
|
|
27245
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
27246
|
+
get error() {
|
|
27247
|
+
return new ZodError(newCtx.common.issues);
|
|
27248
|
+
},
|
|
27249
|
+
input: newCtx.data
|
|
27250
|
+
})
|
|
27251
|
+
};
|
|
27252
|
+
}
|
|
27253
|
+
}
|
|
27254
|
+
removeCatch() {
|
|
27255
|
+
return this._def.innerType;
|
|
27256
|
+
}
|
|
27257
|
+
}
|
|
27258
|
+
ZodCatch.create = (type2, params) => {
|
|
27259
|
+
return new ZodCatch({
|
|
27260
|
+
innerType: type2,
|
|
27261
|
+
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
27262
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
27263
|
+
...processCreateParams(params)
|
|
27264
|
+
});
|
|
27265
|
+
};
|
|
27266
|
+
class ZodNaN extends ZodType {
|
|
27267
|
+
_parse(input) {
|
|
27268
|
+
const parsedType = this._getType(input);
|
|
27269
|
+
if (parsedType !== ZodParsedType.nan) {
|
|
27270
|
+
const ctx = this._getOrReturnCtx(input);
|
|
27271
|
+
addIssueToContext(ctx, {
|
|
27272
|
+
code: ZodIssueCode.invalid_type,
|
|
27273
|
+
expected: ZodParsedType.nan,
|
|
27274
|
+
received: ctx.parsedType
|
|
27275
|
+
});
|
|
27276
|
+
return INVALID;
|
|
27277
|
+
}
|
|
27278
|
+
return { status: "valid", value: input.data };
|
|
27279
|
+
}
|
|
27280
|
+
}
|
|
27281
|
+
ZodNaN.create = (params) => {
|
|
27282
|
+
return new ZodNaN({
|
|
27283
|
+
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
27284
|
+
...processCreateParams(params)
|
|
27285
|
+
});
|
|
27286
|
+
};
|
|
27287
|
+
class ZodBranded extends ZodType {
|
|
27288
|
+
_parse(input) {
|
|
27289
|
+
const { ctx } = this._processInputParams(input);
|
|
27290
|
+
const data2 = ctx.data;
|
|
27291
|
+
return this._def.type._parse({
|
|
27292
|
+
data: data2,
|
|
27293
|
+
path: ctx.path,
|
|
27294
|
+
parent: ctx
|
|
27295
|
+
});
|
|
27296
|
+
}
|
|
27297
|
+
unwrap() {
|
|
27298
|
+
return this._def.type;
|
|
27299
|
+
}
|
|
27300
|
+
}
|
|
27301
|
+
class ZodPipeline extends ZodType {
|
|
27302
|
+
_parse(input) {
|
|
27303
|
+
const { status, ctx } = this._processInputParams(input);
|
|
27304
|
+
if (ctx.common.async) {
|
|
27305
|
+
const handleAsync = async () => {
|
|
27306
|
+
const inResult = await this._def.in._parseAsync({
|
|
27307
|
+
data: ctx.data,
|
|
27308
|
+
path: ctx.path,
|
|
27309
|
+
parent: ctx
|
|
27310
|
+
});
|
|
27311
|
+
if (inResult.status === "aborted")
|
|
27312
|
+
return INVALID;
|
|
27313
|
+
if (inResult.status === "dirty") {
|
|
27314
|
+
status.dirty();
|
|
27315
|
+
return DIRTY(inResult.value);
|
|
27316
|
+
} else {
|
|
27317
|
+
return this._def.out._parseAsync({
|
|
27318
|
+
data: inResult.value,
|
|
27319
|
+
path: ctx.path,
|
|
27320
|
+
parent: ctx
|
|
27321
|
+
});
|
|
27322
|
+
}
|
|
27323
|
+
};
|
|
27324
|
+
return handleAsync();
|
|
27325
|
+
} else {
|
|
27326
|
+
const inResult = this._def.in._parseSync({
|
|
27327
|
+
data: ctx.data,
|
|
27328
|
+
path: ctx.path,
|
|
27329
|
+
parent: ctx
|
|
27330
|
+
});
|
|
27331
|
+
if (inResult.status === "aborted")
|
|
27332
|
+
return INVALID;
|
|
27333
|
+
if (inResult.status === "dirty") {
|
|
27334
|
+
status.dirty();
|
|
27335
|
+
return {
|
|
27336
|
+
status: "dirty",
|
|
27337
|
+
value: inResult.value
|
|
27338
|
+
};
|
|
27339
|
+
} else {
|
|
27340
|
+
return this._def.out._parseSync({
|
|
27341
|
+
data: inResult.value,
|
|
27342
|
+
path: ctx.path,
|
|
27343
|
+
parent: ctx
|
|
27344
|
+
});
|
|
27345
|
+
}
|
|
27346
|
+
}
|
|
27347
|
+
}
|
|
27348
|
+
static create(a, b) {
|
|
27349
|
+
return new ZodPipeline({
|
|
27350
|
+
in: a,
|
|
27351
|
+
out: b,
|
|
27352
|
+
typeName: ZodFirstPartyTypeKind.ZodPipeline
|
|
27353
|
+
});
|
|
27354
|
+
}
|
|
27355
|
+
}
|
|
27356
|
+
class ZodReadonly extends ZodType {
|
|
27357
|
+
_parse(input) {
|
|
27358
|
+
const result = this._def.innerType._parse(input);
|
|
27359
|
+
const freeze = (data2) => {
|
|
27360
|
+
if (isValid(data2)) {
|
|
27361
|
+
data2.value = Object.freeze(data2.value);
|
|
27362
|
+
}
|
|
27363
|
+
return data2;
|
|
27364
|
+
};
|
|
27365
|
+
return isAsync(result) ? result.then((data2) => freeze(data2)) : freeze(result);
|
|
27366
|
+
}
|
|
27367
|
+
unwrap() {
|
|
27368
|
+
return this._def.innerType;
|
|
27369
|
+
}
|
|
27370
|
+
}
|
|
27371
|
+
ZodReadonly.create = (type2, params) => {
|
|
27372
|
+
return new ZodReadonly({
|
|
27373
|
+
innerType: type2,
|
|
27374
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
27375
|
+
...processCreateParams(params)
|
|
27376
|
+
});
|
|
27377
|
+
};
|
|
27378
|
+
var ZodFirstPartyTypeKind;
|
|
27379
|
+
(function(ZodFirstPartyTypeKind2) {
|
|
27380
|
+
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
|
27381
|
+
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
|
|
27382
|
+
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
|
|
27383
|
+
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
|
|
27384
|
+
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
|
|
27385
|
+
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
|
|
27386
|
+
ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
|
|
27387
|
+
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
|
|
27388
|
+
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
|
|
27389
|
+
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
|
|
27390
|
+
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
|
|
27391
|
+
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
|
|
27392
|
+
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
|
|
27393
|
+
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
|
|
27394
|
+
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
|
|
27395
|
+
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
|
|
27396
|
+
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
27397
|
+
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
|
|
27398
|
+
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
|
|
27399
|
+
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
|
|
27400
|
+
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
|
|
27401
|
+
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
|
|
27402
|
+
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
|
|
27403
|
+
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
|
|
27404
|
+
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
|
|
27405
|
+
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
|
|
27406
|
+
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
|
|
27407
|
+
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
|
|
27408
|
+
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
|
|
27409
|
+
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
|
|
27410
|
+
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
|
|
27411
|
+
ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
|
|
27412
|
+
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
27413
|
+
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
27414
|
+
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
27415
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
27416
|
+
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
27417
|
+
const stringType = ZodString.create;
|
|
27418
|
+
const numberType = ZodNumber.create;
|
|
27419
|
+
const booleanType = ZodBoolean.create;
|
|
27420
|
+
ZodNever.create;
|
|
27421
|
+
ZodArray.create;
|
|
27422
|
+
const objectType = ZodObject.create;
|
|
27423
|
+
const unionType = ZodUnion.create;
|
|
27424
|
+
ZodIntersection.create;
|
|
27425
|
+
ZodTuple.create;
|
|
27426
|
+
const enumType = ZodEnum.create;
|
|
27427
|
+
ZodPromise.create;
|
|
27428
|
+
ZodOptional.create;
|
|
27429
|
+
ZodNullable.create;
|
|
23858
27430
|
function isZ4Schema(s) {
|
|
23859
27431
|
const schema = s;
|
|
23860
27432
|
return !!schema._zod;
|
|
@@ -32313,7 +35885,7 @@ function splitLines(chunk) {
|
|
|
32313
35885
|
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
32314
35886
|
`, searchIndex);
|
|
32315
35887
|
let lineEnd = -1;
|
|
32316
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
35888
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
32317
35889
|
incompleteLine = chunk.slice(searchIndex);
|
|
32318
35890
|
break;
|
|
32319
35891
|
} else {
|
|
@@ -33221,6 +36793,31 @@ class StreamableHTTPClientTransport {
|
|
|
33221
36793
|
});
|
|
33222
36794
|
}
|
|
33223
36795
|
}
|
|
36796
|
+
enumType([
|
|
36797
|
+
"silent",
|
|
36798
|
+
"error",
|
|
36799
|
+
"warn",
|
|
36800
|
+
"info",
|
|
36801
|
+
"debug"
|
|
36802
|
+
]);
|
|
36803
|
+
enumType(["stdio", "http", "sse"]);
|
|
36804
|
+
enumType(["json", "markdown"]);
|
|
36805
|
+
const ConfigItemSchema = objectType({
|
|
36806
|
+
label: stringType().min(1, "label is required"),
|
|
36807
|
+
description: stringType(),
|
|
36808
|
+
value: unionType([stringType(), numberType(), booleanType()]),
|
|
36809
|
+
is_session_item: booleanType()
|
|
36810
|
+
});
|
|
36811
|
+
const InspectorConfigSchema = objectType({
|
|
36812
|
+
MCP_SERVER_REQUEST_TIMEOUT: ConfigItemSchema,
|
|
36813
|
+
MCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS: ConfigItemSchema,
|
|
36814
|
+
MCP_REQUEST_MAX_TOTAL_TIMEOUT: ConfigItemSchema,
|
|
36815
|
+
MCP_PROXY_FULL_ADDRESS: ConfigItemSchema,
|
|
36816
|
+
MCP_PROXY_AUTH_TOKEN: ConfigItemSchema
|
|
36817
|
+
});
|
|
36818
|
+
function safeParseInspectorConfig(config2) {
|
|
36819
|
+
return InspectorConfigSchema.safeParse(config2);
|
|
36820
|
+
}
|
|
33224
36821
|
const getSearchParam = (key) => {
|
|
33225
36822
|
try {
|
|
33226
36823
|
const url2 = new URL(window.location.href);
|
|
@@ -33230,7 +36827,10 @@ const getSearchParam = (key) => {
|
|
|
33230
36827
|
}
|
|
33231
36828
|
};
|
|
33232
36829
|
const getMCPProxyAddress = (config2) => {
|
|
33233
|
-
|
|
36830
|
+
const rawValue = config2.MCP_PROXY_FULL_ADDRESS?.value;
|
|
36831
|
+
let proxyFullAddress = typeof rawValue === "string" ? rawValue : String(
|
|
36832
|
+
rawValue ?? DEFAULT_INSPECTOR_CONFIG.MCP_PROXY_FULL_ADDRESS.value
|
|
36833
|
+
);
|
|
33234
36834
|
if (proxyFullAddress) {
|
|
33235
36835
|
proxyFullAddress = proxyFullAddress.replace(/\/+$/, "");
|
|
33236
36836
|
return proxyFullAddress;
|
|
@@ -33239,17 +36839,22 @@ const getMCPProxyAddress = (config2) => {
|
|
|
33239
36839
|
return `${window.location.protocol}//${window.location.hostname}:${proxyPort}`;
|
|
33240
36840
|
};
|
|
33241
36841
|
const getMCPServerRequestTimeout = (config2) => {
|
|
33242
|
-
|
|
36842
|
+
const rawValue = config2.MCP_SERVER_REQUEST_TIMEOUT?.value;
|
|
36843
|
+
return typeof rawValue === "number" ? rawValue : Number(rawValue) || DEFAULT_INSPECTOR_CONFIG.MCP_SERVER_REQUEST_TIMEOUT.value;
|
|
33243
36844
|
};
|
|
33244
36845
|
const resetRequestTimeoutOnProgress = (config2) => {
|
|
33245
|
-
|
|
36846
|
+
const rawValue = config2.MCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS?.value;
|
|
36847
|
+
return typeof rawValue === "boolean" ? rawValue : DEFAULT_INSPECTOR_CONFIG.MCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS.value;
|
|
33246
36848
|
};
|
|
33247
36849
|
const getMCPServerRequestMaxTotalTimeout = (config2) => {
|
|
33248
|
-
|
|
36850
|
+
const rawValue = config2.MCP_REQUEST_MAX_TOTAL_TIMEOUT?.value;
|
|
36851
|
+
return typeof rawValue === "number" ? rawValue : Number(rawValue) || DEFAULT_INSPECTOR_CONFIG.MCP_REQUEST_MAX_TOTAL_TIMEOUT.value;
|
|
33249
36852
|
};
|
|
33250
36853
|
const getMCPProxyAuthToken = (config2) => {
|
|
36854
|
+
const rawValue = config2.MCP_PROXY_AUTH_TOKEN?.value;
|
|
36855
|
+
const token = typeof rawValue === "string" ? rawValue : String(rawValue ?? DEFAULT_INSPECTOR_CONFIG.MCP_PROXY_AUTH_TOKEN.value);
|
|
33251
36856
|
return {
|
|
33252
|
-
token
|
|
36857
|
+
token,
|
|
33253
36858
|
header: "X-MCP-Proxy-Auth"
|
|
33254
36859
|
};
|
|
33255
36860
|
};
|
|
@@ -33303,12 +36908,38 @@ const initializeInspectorConfig = (localStorageKey) => {
|
|
|
33303
36908
|
);
|
|
33304
36909
|
let baseConfig = { ...DEFAULT_INSPECTOR_CONFIG };
|
|
33305
36910
|
if (savedPersistentConfig) {
|
|
33306
|
-
|
|
33307
|
-
|
|
36911
|
+
try {
|
|
36912
|
+
const parsedPersistentConfig = JSON.parse(savedPersistentConfig);
|
|
36913
|
+
const mergedConfig = { ...baseConfig, ...parsedPersistentConfig };
|
|
36914
|
+
const validationResult = safeParseInspectorConfig(mergedConfig);
|
|
36915
|
+
if (validationResult.success) {
|
|
36916
|
+
baseConfig = validationResult.data;
|
|
36917
|
+
} else {
|
|
36918
|
+
console.warn(
|
|
36919
|
+
"Invalid config in localStorage, using defaults:",
|
|
36920
|
+
validationResult.error.errors.map((e) => e.message)
|
|
36921
|
+
);
|
|
36922
|
+
}
|
|
36923
|
+
} catch (e) {
|
|
36924
|
+
console.warn("Failed to parse localStorage config:", e);
|
|
36925
|
+
}
|
|
33308
36926
|
}
|
|
33309
36927
|
if (savedEphemeralConfig) {
|
|
33310
|
-
|
|
33311
|
-
|
|
36928
|
+
try {
|
|
36929
|
+
const parsedEphemeralConfig = JSON.parse(savedEphemeralConfig);
|
|
36930
|
+
const mergedConfig = { ...baseConfig, ...parsedEphemeralConfig };
|
|
36931
|
+
const validationResult = safeParseInspectorConfig(mergedConfig);
|
|
36932
|
+
if (validationResult.success) {
|
|
36933
|
+
baseConfig = validationResult.data;
|
|
36934
|
+
} else {
|
|
36935
|
+
console.warn(
|
|
36936
|
+
"Invalid config in sessionStorage, using current config:",
|
|
36937
|
+
validationResult.error.errors.map((e) => e.message)
|
|
36938
|
+
);
|
|
36939
|
+
}
|
|
36940
|
+
} catch (e) {
|
|
36941
|
+
console.warn("Failed to parse sessionStorage config:", e);
|
|
36942
|
+
}
|
|
33312
36943
|
}
|
|
33313
36944
|
for (const [key, value] of Object.entries(baseConfig)) {
|
|
33314
36945
|
baseConfig[key] = {
|
|
@@ -45288,7 +48919,7 @@ const useTheme = () => {
|
|
|
45288
48919
|
[theme, setThemeWithSideEffect]
|
|
45289
48920
|
);
|
|
45290
48921
|
};
|
|
45291
|
-
const version = "1.
|
|
48922
|
+
const version = "1.30.1";
|
|
45292
48923
|
var [createTooltipContext] = createContextScope("Tooltip", [
|
|
45293
48924
|
createPopperScope
|
|
45294
48925
|
]);
|
|
@@ -48008,8 +51639,8 @@ const ElicitationRequest = ({
|
|
|
48008
51639
|
setValidationError(null);
|
|
48009
51640
|
}, [request.request.requestedSchema]);
|
|
48010
51641
|
const validateEmailFormat = (email2) => {
|
|
48011
|
-
const
|
|
48012
|
-
return
|
|
51642
|
+
const emailRegex2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
51643
|
+
return emailRegex2.test(email2);
|
|
48013
51644
|
};
|
|
48014
51645
|
const validateFormData = (data2, schema) => {
|
|
48015
51646
|
if (schema.type === "object" && schema.properties && typeof data2 === "object" && data2 !== null) {
|
|
@@ -48042,8 +51673,8 @@ const ElicitationRequest = ({
|
|
|
48042
51673
|
}
|
|
48043
51674
|
const ajv2 = new Ajv$1();
|
|
48044
51675
|
const validate2 = ajv2.compile(request.request.requestedSchema);
|
|
48045
|
-
const
|
|
48046
|
-
if (!
|
|
51676
|
+
const isValid2 = validate2(formData);
|
|
51677
|
+
if (!isValid2) {
|
|
48047
51678
|
const errorMessage = ajv2.errorsText(validate2.errors);
|
|
48048
51679
|
setValidationError(errorMessage);
|
|
48049
51680
|
return;
|
|
@@ -48883,13 +52514,13 @@ const App = () => {
|
|
|
48883
52514
|
) });
|
|
48884
52515
|
if (window.location.pathname === "/oauth/callback") {
|
|
48885
52516
|
const OAuthCallback = React.lazy(
|
|
48886
|
-
() => __vitePreload(() => import("./OAuthCallback-
|
|
52517
|
+
() => __vitePreload(() => import("./OAuthCallback-CXcl26vR.js"), true ? [] : void 0)
|
|
48887
52518
|
);
|
|
48888
52519
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthCallback, { onConnect: onOAuthConnect }) });
|
|
48889
52520
|
}
|
|
48890
52521
|
if (window.location.pathname === "/oauth/callback/debug") {
|
|
48891
52522
|
const OAuthDebugCallback = React.lazy(
|
|
48892
|
-
() => __vitePreload(() => import("./OAuthDebugCallback-
|
|
52523
|
+
() => __vitePreload(() => import("./OAuthDebugCallback-J9s4SF_c.js"), true ? [] : void 0)
|
|
48893
52524
|
);
|
|
48894
52525
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthDebugCallback, { onConnect: onOAuthDebugConnect }) });
|
|
48895
52526
|
}
|