/games - /help - reload and delete

This commit is contained in:
RADEMAKER Robin
2022-03-30 01:44:17 +02:00
parent 3fca79ab64
commit dcd6105d03
3518 changed files with 259029 additions and 0 deletions

21
node_modules/zod/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Colin McDonnell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1969
node_modules/zod/README.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

150
node_modules/zod/lib/ZodError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,150 @@
import { ZodParsedType } from "./helpers/parseUtil";
import { Primitive } from "./helpers/typeAliases";
import { util } from "./helpers/util";
export declare const ZodIssueCode: {
invalid_type: "invalid_type";
custom: "custom";
invalid_union: "invalid_union";
invalid_union_discriminator: "invalid_union_discriminator";
invalid_enum_value: "invalid_enum_value";
unrecognized_keys: "unrecognized_keys";
invalid_arguments: "invalid_arguments";
invalid_return_type: "invalid_return_type";
invalid_date: "invalid_date";
invalid_string: "invalid_string";
too_small: "too_small";
too_big: "too_big";
invalid_intersection_types: "invalid_intersection_types";
not_multiple_of: "not_multiple_of";
};
export declare type ZodIssueCode = keyof typeof ZodIssueCode;
export declare type ZodIssueBase = {
path: (string | number)[];
message?: string;
};
export interface ZodInvalidTypeIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_type;
expected: ZodParsedType;
received: ZodParsedType;
}
export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
code: typeof ZodIssueCode.unrecognized_keys;
keys: string[];
}
export interface ZodInvalidUnionIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_union;
unionErrors: ZodError[];
}
export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_union_discriminator;
options: Primitive[];
}
export interface ZodInvalidEnumValueIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_enum_value;
options: (string | number)[];
}
export interface ZodInvalidArgumentsIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_arguments;
argumentsError: ZodError;
}
export interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_return_type;
returnTypeError: ZodError;
}
export interface ZodInvalidDateIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_date;
}
export declare type StringValidation = "email" | "url" | "uuid" | "regex" | "cuid";
export interface ZodInvalidStringIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_string;
validation: StringValidation;
}
export interface ZodTooSmallIssue extends ZodIssueBase {
code: typeof ZodIssueCode.too_small;
minimum: number;
inclusive: boolean;
type: "array" | "string" | "number" | "set";
}
export interface ZodTooBigIssue extends ZodIssueBase {
code: typeof ZodIssueCode.too_big;
maximum: number;
inclusive: boolean;
type: "array" | "string" | "number" | "set";
}
export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
code: typeof ZodIssueCode.invalid_intersection_types;
}
export interface ZodNotMultipleOfIssue extends ZodIssueBase {
code: typeof ZodIssueCode.not_multiple_of;
multipleOf: number;
}
export interface ZodCustomIssue extends ZodIssueBase {
code: typeof ZodIssueCode.custom;
params?: {
[k: string]: any;
};
}
export declare type DenormalizedError = {
[k: string]: DenormalizedError | string[];
};
export declare type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodCustomIssue;
export declare type ZodIssue = ZodIssueOptionalMessage & {
message: string;
};
export declare const quotelessJson: (obj: any) => string;
export declare type ZodFormattedError<T> = {
_errors: string[];
} & (T extends [any, ...any[]] ? {
[K in keyof T]?: ZodFormattedError<T[K]>;
} : T extends any[] ? ZodFormattedError<T[number]>[] : T extends object ? {
[K in keyof T]?: ZodFormattedError<T[K]>;
} : unknown);
export declare class ZodError<T = any> extends Error {
issues: ZodIssue[];
get errors(): ZodIssue[];
constructor(issues: ZodIssue[]);
format: () => ZodFormattedError<T>;
static create: (issues: ZodIssue[]) => ZodError<any>;
toString(): string;
get message(): string;
get isEmpty(): boolean;
addIssue: (sub: ZodIssue) => void;
addIssues: (subs?: ZodIssue[]) => void;
flatten(mapper?: (issue: ZodIssue) => string): {
formErrors: string[];
fieldErrors: {
[k: string]: string[];
};
};
flatten<U>(mapper?: (issue: ZodIssue) => U): {
formErrors: U[];
fieldErrors: {
[k: string]: U[];
};
};
get formErrors(): {
formErrors: string[];
fieldErrors: {
[k: string]: string[];
};
};
}
declare type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
export declare type IssueData = stripPath<ZodIssueOptionalMessage> & {
path?: (string | number)[];
fatal?: boolean;
};
export declare type MakeErrorData = IssueData;
declare type ErrorMapCtx = {
defaultError: string;
data: any;
};
export declare type ZodErrorMap = typeof defaultErrorMap;
export declare const defaultErrorMap: (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
message: string;
};
export declare let overrideErrorMap: (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
message: string;
};
export declare const setErrorMap: (map: ZodErrorMap) => void;
export {};

211
node_modules/zod/lib/ZodError.js generated vendored Normal file
View File

@@ -0,0 +1,211 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setErrorMap = exports.overrideErrorMap = exports.defaultErrorMap = exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
const util_1 = require("./helpers/util");
exports.ZodIssueCode = util_1.util.arrayToEnum([
"invalid_type",
"custom",
"invalid_union",
"invalid_union_discriminator",
"invalid_enum_value",
"unrecognized_keys",
"invalid_arguments",
"invalid_return_type",
"invalid_date",
"invalid_string",
"too_small",
"too_big",
"invalid_intersection_types",
"not_multiple_of",
]);
const quotelessJson = (obj) => {
const json = JSON.stringify(obj, null, 2);
return json.replace(/"([^"]+)":/g, "$1:");
};
exports.quotelessJson = quotelessJson;
class ZodError extends Error {
constructor(issues) {
super();
this.issues = [];
this.format = () => {
const fieldErrors = { _errors: [] };
const processError = (error) => {
for (const issue of error.issues) {
if (issue.code === "invalid_union") {
issue.unionErrors.map(processError);
}
else if (issue.code === "invalid_return_type") {
processError(issue.returnTypeError);
}
else if (issue.code === "invalid_arguments") {
processError(issue.argumentsError);
}
else if (issue.path.length === 0) {
fieldErrors._errors.push(issue.message);
}
else {
let curr = fieldErrors;
let i = 0;
while (i < issue.path.length) {
const el = issue.path[i];
const terminal = i === issue.path.length - 1;
if (!terminal) {
if (typeof el === "string") {
curr[el] = curr[el] || { _errors: [] };
}
else if (typeof el === "number") {
const errorArray = [];
errorArray._errors = [];
curr[el] = curr[el] || errorArray;
}
}
else {
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(issue.message);
}
curr = curr[el];
i++;
}
}
}
};
processError(this);
return fieldErrors;
};
this.addIssue = (sub) => {
this.issues = [...this.issues, sub];
};
this.addIssues = (subs = []) => {
this.issues = [...this.issues, ...subs];
};
const actualProto = new.target.prototype;
if (Object.setPrototypeOf) {
// eslint-disable-next-line ban/ban
Object.setPrototypeOf(this, actualProto);
}
else {
this.__proto__ = actualProto;
}
this.name = "ZodError";
this.issues = issues;
}
get errors() {
return this.issues;
}
toString() {
return this.message;
}
get message() {
return JSON.stringify(this.issues, null, 2);
}
get isEmpty() {
return this.issues.length === 0;
}
flatten(mapper = (issue) => issue.message) {
const fieldErrors = {};
const formErrors = [];
for (const sub of this.issues) {
if (sub.path.length > 0) {
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
fieldErrors[sub.path[0]].push(mapper(sub));
}
else {
formErrors.push(mapper(sub));
}
}
return { formErrors, fieldErrors };
}
get formErrors() {
return this.flatten();
}
}
exports.ZodError = ZodError;
ZodError.create = (issues) => {
const error = new ZodError(issues);
return error;
};
const defaultErrorMap = (issue, _ctx) => {
let message;
switch (issue.code) {
case exports.ZodIssueCode.invalid_type:
if (issue.received === "undefined") {
message = "Required";
}
else {
message = `Expected ${issue.expected}, received ${issue.received}`;
}
break;
case exports.ZodIssueCode.unrecognized_keys:
message = `Unrecognized key(s) in object: ${issue.keys
.map((k) => `'${k}'`)
.join(", ")}`;
break;
case exports.ZodIssueCode.invalid_union:
message = `Invalid input`;
break;
case exports.ZodIssueCode.invalid_union_discriminator:
message = `Invalid discriminator value. Expected ${issue.options
.map((val) => (typeof val === "string" ? `'${val}'` : val))
.join(" | ")}`;
break;
case exports.ZodIssueCode.invalid_enum_value:
message = `Invalid enum value. Expected ${issue.options
.map((val) => (typeof val === "string" ? `'${val}'` : val))
.join(" | ")}`;
break;
case exports.ZodIssueCode.invalid_arguments:
message = `Invalid function arguments`;
break;
case exports.ZodIssueCode.invalid_return_type:
message = `Invalid function return type`;
break;
case exports.ZodIssueCode.invalid_date:
message = `Invalid date`;
break;
case exports.ZodIssueCode.invalid_string:
if (issue.validation !== "regex")
message = `Invalid ${issue.validation}`;
else
message = "Invalid";
break;
case exports.ZodIssueCode.too_small:
if (issue.type === "array")
message = `Array must contain ${issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
else if (issue.type === "string")
message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
else if (issue.type === "number")
message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
else
message = "Invalid input";
break;
case exports.ZodIssueCode.too_big:
if (issue.type === "array")
message = `Array must contain ${issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
else if (issue.type === "string")
message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
else if (issue.type === "number")
message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
else
message = "Invalid input";
break;
case exports.ZodIssueCode.custom:
message = `Invalid input`;
break;
case exports.ZodIssueCode.invalid_intersection_types:
message = `Intersection results could not be merged`;
break;
case exports.ZodIssueCode.not_multiple_of:
message = `Number must be a multiple of ${issue.multipleOf}`;
break;
default:
message = _ctx.defaultError;
util_1.util.assertNever(issue);
}
return { message };
};
exports.defaultErrorMap = defaultErrorMap;
exports.overrideErrorMap = exports.defaultErrorMap;
const setErrorMap = (map) => {
exports.overrideErrorMap = map;
};
exports.setErrorMap = setErrorMap;

View File

@@ -0,0 +1,5 @@
import Benchmark from "benchmark";
declare const _default: {
suites: Benchmark.Suite[];
};
export default _default;

79
node_modules/zod/lib/benchmarks/discriminatedUnion.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const doubleSuite = new benchmark_1.default.Suite("z.discriminatedUnion: double");
const manySuite = new benchmark_1.default.Suite("z.discriminatedUnion: many");
const aSchema = index_1.z.object({
type: index_1.z.literal("a"),
});
const objA = {
type: "a",
};
const bSchema = index_1.z.object({
type: index_1.z.literal("b"),
});
const objB = {
type: "b",
};
const cSchema = index_1.z.object({
type: index_1.z.literal("c"),
});
const objC = {
type: "c",
};
const dSchema = index_1.z.object({
type: index_1.z.literal("d"),
});
const double = index_1.z.discriminatedUnion("type", [aSchema, bSchema]);
const many = index_1.z.discriminatedUnion("type", [aSchema, bSchema, cSchema, dSchema]);
doubleSuite
.add("valid: a", () => {
double.parse(objA);
})
.add("valid: b", () => {
double.parse(objB);
})
.add("invalid: null", () => {
try {
double.parse(null);
}
catch (err) { }
})
.add("invalid: wrong shape", () => {
try {
double.parse(objC);
}
catch (err) { }
})
.on("cycle", (e) => {
console.log(`${doubleSuite.name}: ${e.target}`);
});
manySuite
.add("valid: a", () => {
many.parse(objA);
})
.add("valid: c", () => {
many.parse(objC);
})
.add("invalid: null", () => {
try {
many.parse(null);
}
catch (err) { }
})
.add("invalid: wrong shape", () => {
try {
many.parse({ type: "unknown" });
}
catch (err) { }
})
.on("cycle", (e) => {
console.log(`${manySuite.name}: ${e.target}`);
});
exports.default = {
suites: [doubleSuite, manySuite],
};

1
node_modules/zod/lib/benchmarks/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

21
node_modules/zod/lib/benchmarks/index.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const discriminatedUnion_1 = __importDefault(require("./discriminatedUnion"));
const object_1 = __importDefault(require("./object"));
const primitives_1 = __importDefault(require("./primitives"));
const realworld_1 = __importDefault(require("./realworld"));
const string_1 = __importDefault(require("./string"));
const union_1 = __importDefault(require("./union"));
for (const suite of [
...realworld_1.default.suites,
...primitives_1.default.suites,
...string_1.default.suites,
...object_1.default.suites,
...union_1.default.suites,
...discriminatedUnion_1.default.suites,
]) {
suite.run();
}

5
node_modules/zod/lib/benchmarks/object.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import Benchmark from "benchmark";
declare const _default: {
suites: Benchmark.Suite[];
};
export default _default;

70
node_modules/zod/lib/benchmarks/object.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const emptySuite = new benchmark_1.default.Suite("z.object: empty");
const shortSuite = new benchmark_1.default.Suite("z.object: short");
const longSuite = new benchmark_1.default.Suite("z.object: long");
const empty = index_1.z.object({});
const short = index_1.z.object({
string: index_1.z.string(),
});
const long = index_1.z.object({
string: index_1.z.string(),
number: index_1.z.number(),
boolean: index_1.z.boolean(),
});
emptySuite
.add("valid", () => {
empty.parse({});
})
.add("valid: extra keys", () => {
empty.parse({ string: "string" });
})
.add("invalid: null", () => {
try {
empty.parse(null);
}
catch (err) { }
})
.on("cycle", (e) => {
console.log(`${emptySuite.name}: ${e.target}`);
});
shortSuite
.add("valid", () => {
short.parse({ string: "string" });
})
.add("valid: extra keys", () => {
short.parse({ string: "string", number: 42 });
})
.add("invalid: null", () => {
try {
short.parse(null);
}
catch (err) { }
})
.on("cycle", (e) => {
console.log(`${shortSuite.name}: ${e.target}`);
});
longSuite
.add("valid", () => {
long.parse({ string: "string", number: 42, boolean: true });
})
.add("valid: extra keys", () => {
long.parse({ string: "string", number: 42, boolean: true, list: [] });
})
.add("invalid: null", () => {
try {
long.parse(null);
}
catch (err) { }
})
.on("cycle", (e) => {
console.log(`${longSuite.name}: ${e.target}`);
});
exports.default = {
suites: [emptySuite, shortSuite, longSuite],
};

5
node_modules/zod/lib/benchmarks/primitives.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import Benchmark from "benchmark";
declare const _default: {
suites: Benchmark.Suite[];
};
export default _default;

78
node_modules/zod/lib/benchmarks/primitives.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const enumSuite = new benchmark_1.default.Suite("z.enum");
const enumSchema = index_1.z.enum(["a", "b", "c"]);
enumSuite
.add("valid", () => {
enumSchema.parse("a");
})
.add("invalid", () => {
try {
enumSchema.parse("x");
}
catch (e) { }
})
.on("cycle", (e) => {
console.log(`z.enum: ${e.target}`);
});
const undefinedSuite = new benchmark_1.default.Suite("z.undefined");
const undefinedSchema = index_1.z.undefined();
undefinedSuite
.add("valid", () => {
undefinedSchema.parse(undefined);
})
.add("invalid", () => {
try {
undefinedSchema.parse(1);
}
catch (e) { }
})
.on("cycle", (e) => {
console.log(`z.undefined: ${e.target}`);
});
const literalSuite = new benchmark_1.default.Suite("z.literal");
const short = "short";
const bad = "bad";
const literalSchema = index_1.z.literal("short");
literalSuite
.add("valid", () => {
literalSchema.parse(short);
})
.add("invalid", () => {
try {
literalSchema.parse(bad);
}
catch (e) { }
})
.on("cycle", (e) => {
console.log(`z.literal: ${e.target}`);
});
const numberSuite = new benchmark_1.default.Suite("z.number");
const numberSchema = index_1.z.number().int();
numberSuite
.add("valid", () => {
numberSchema.parse(1);
})
.add("invalid type", () => {
try {
numberSchema.parse("bad");
}
catch (e) { }
})
.add("invalid number", () => {
try {
numberSchema.parse(0.5);
}
catch (e) { }
})
.on("cycle", (e) => {
console.log(`z.number: ${e.target}`);
});
exports.default = {
suites: [enumSuite, undefinedSuite, literalSuite, numberSuite],
};

5
node_modules/zod/lib/benchmarks/realworld.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import Benchmark from "benchmark";
declare const _default: {
suites: Benchmark.Suite[];
};
export default _default;

56
node_modules/zod/lib/benchmarks/realworld.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const shortSuite = new benchmark_1.default.Suite("realworld");
const People = index_1.z.array(index_1.z.object({
type: index_1.z.literal("person"),
hair: index_1.z.enum(["blue", "brown"]),
active: index_1.z.boolean(),
name: index_1.z.string(),
age: index_1.z.number().int(),
hobbies: index_1.z.array(index_1.z.string()),
address: index_1.z.object({
street: index_1.z.string(),
zip: index_1.z.string(),
country: index_1.z.string(),
}),
}));
let i = 0;
function num() {
return ++i;
}
function str() {
return (++i % 100).toString(16);
}
function array(fn) {
return Array.from({ length: ++i % 10 }, () => fn());
}
const people = Array.from({ length: 100 }, () => {
return {
type: "person",
hair: i % 2 ? "blue" : "brown",
active: !!(i % 2),
name: str(),
age: num(),
hobbies: array(str),
address: {
street: str(),
zip: str(),
country: str(),
},
};
});
shortSuite
.add("valid", () => {
People.parse(people);
})
.on("cycle", (e) => {
console.log(`${shortSuite.name}: ${e.target}`);
});
exports.default = {
suites: [shortSuite],
};

5
node_modules/zod/lib/benchmarks/string.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import Benchmark from "benchmark";
declare const _default: {
suites: Benchmark.Suite[];
};
export default _default;

55
node_modules/zod/lib/benchmarks/string.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const SUITE_NAME = "z.string";
const suite = new benchmark_1.default.Suite(SUITE_NAME);
const empty = "";
const short = "short";
const long = "long".repeat(256);
const manual = (str) => {
if (typeof str !== "string") {
throw new Error("Not a string");
}
return str;
};
const stringSchema = index_1.z.string();
const optionalStringSchema = index_1.z.string().optional();
const optionalNullableStringSchema = index_1.z.string().optional().nullable();
suite
.add("empty string", () => {
stringSchema.parse(empty);
})
.add("short string", () => {
stringSchema.parse(short);
})
.add("long string", () => {
stringSchema.parse(long);
})
.add("optional string", () => {
optionalStringSchema.parse(long);
})
.add("nullable string", () => {
optionalNullableStringSchema.parse(long);
})
.add("nullable (null) string", () => {
optionalNullableStringSchema.parse(null);
})
.add("invalid: null", () => {
try {
stringSchema.parse(null);
}
catch (err) { }
})
.add("manual parser: long", () => {
manual(long);
})
.on("cycle", (e) => {
console.log(`${SUITE_NAME}: ${e.target}`);
});
exports.default = {
suites: [suite],
};

5
node_modules/zod/lib/benchmarks/union.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import Benchmark from "benchmark";
declare const _default: {
suites: Benchmark.Suite[];
};
export default _default;

79
node_modules/zod/lib/benchmarks/union.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const benchmark_1 = __importDefault(require("benchmark"));
const index_1 = require("../index");
const doubleSuite = new benchmark_1.default.Suite("z.union: double");
const manySuite = new benchmark_1.default.Suite("z.union: many");
const aSchema = index_1.z.object({
type: index_1.z.literal("a"),
});
const objA = {
type: "a",
};
const bSchema = index_1.z.object({
type: index_1.z.literal("b"),
});
const objB = {
type: "b",
};
const cSchema = index_1.z.object({
type: index_1.z.literal("c"),
});
const objC = {
type: "c",
};
const dSchema = index_1.z.object({
type: index_1.z.literal("d"),
});
const double = index_1.z.union([aSchema, bSchema]);
const many = index_1.z.union([aSchema, bSchema, cSchema, dSchema]);
doubleSuite
.add("valid: a", () => {
double.parse(objA);
})
.add("valid: b", () => {
double.parse(objB);
})
.add("invalid: null", () => {
try {
double.parse(null);
}
catch (err) { }
})
.add("invalid: wrong shape", () => {
try {
double.parse(objC);
}
catch (err) { }
})
.on("cycle", (e) => {
console.log(`${doubleSuite.name}: ${e.target}`);
});
manySuite
.add("valid: a", () => {
many.parse(objA);
})
.add("valid: c", () => {
many.parse(objC);
})
.add("invalid: null", () => {
try {
many.parse(null);
}
catch (err) { }
})
.add("invalid: wrong shape", () => {
try {
many.parse({ type: "unknown" });
}
catch (err) { }
})
.on("cycle", (e) => {
console.log(`${manySuite.name}: ${e.target}`);
});
exports.default = {
suites: [doubleSuite, manySuite],
};

4
node_modules/zod/lib/external.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export * from "./helpers/parseUtil";
export * from "./helpers/typeAliases";
export * from "./types";
export * from "./ZodError";

20
node_modules/zod/lib/external.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./helpers/parseUtil"), exports);
__exportStar(require("./helpers/typeAliases"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./ZodError"), exports);

9
node_modules/zod/lib/helpers/errorUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export declare namespace errorUtil {
type ErrMessage = string | {
message?: string;
};
const errToObj: (message?: ErrMessage | undefined) => {
message?: string | undefined;
};
const toString: (message?: ErrMessage | undefined) => string | undefined;
}

8
node_modules/zod/lib/helpers/errorUtil.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorUtil = void 0;
var errorUtil;
(function (errorUtil) {
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
})(errorUtil = exports.errorUtil || (exports.errorUtil = {}));

102
node_modules/zod/lib/helpers/parseUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,102 @@
import { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
export declare const ZodParsedType: {
function: "function";
number: "number";
string: "string";
nan: "nan";
integer: "integer";
float: "float";
boolean: "boolean";
date: "date";
bigint: "bigint";
symbol: "symbol";
undefined: "undefined";
null: "null";
array: "array";
object: "object";
unknown: "unknown";
promise: "promise";
void: "void";
never: "never";
map: "map";
set: "set";
};
export declare type ZodParsedType = keyof typeof ZodParsedType;
export declare const getParsedType: (data: any) => ZodParsedType;
export declare const makeIssue: (params: {
data: any;
path: (string | number)[];
errorMaps: ZodErrorMap[];
issueData: IssueData;
}) => ZodIssue;
export declare type ParseParams = {
path: (string | number)[];
errorMap: ZodErrorMap;
async: boolean;
};
export declare type ParsePathComponent = string | number;
export declare type ParsePath = ParsePathComponent[];
export declare const EMPTY_PATH: ParsePath;
export interface ParseContext {
readonly common: {
readonly issues: ZodIssue[];
readonly contextualErrorMap?: ZodErrorMap;
readonly async: boolean;
readonly typeCache: Map<any, ZodParsedType> | undefined;
};
readonly path: ParsePath;
readonly schemaErrorMap?: ZodErrorMap;
readonly parent: ParseContext | null;
readonly data: any;
readonly parsedType: ZodParsedType;
}
export declare type ParseInput = {
data: any;
path: (string | number)[];
parent: ParseContext;
};
export declare function addIssueToContext(ctx: ParseContext, issueData: IssueData): void;
export declare type ObjectPair = {
key: SyncParseReturnType<any>;
value: SyncParseReturnType<any>;
};
export declare class ParseStatus {
value: "aborted" | "dirty" | "valid";
dirty(): void;
abort(): void;
static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
static mergeObjectAsync(status: ParseStatus, pairs: {
key: ParseReturnType<any>;
value: ParseReturnType<any>;
}[]): Promise<SyncParseReturnType<any>>;
static mergeObjectSync(status: ParseStatus, pairs: {
key: SyncParseReturnType<any>;
value: SyncParseReturnType<any>;
alwaysSet?: boolean;
}[]): SyncParseReturnType;
}
export interface ParseResult {
status: "aborted" | "dirty" | "valid";
data: any;
}
export declare type INVALID = {
status: "aborted";
};
export declare const INVALID: INVALID;
export declare type DIRTY<T> = {
status: "dirty";
value: T;
};
export declare const DIRTY: <T>(value: T) => DIRTY<T>;
export declare type OK<T> = {
status: "valid";
value: T;
};
export declare const OK: <T>(value: T) => OK<T>;
export declare type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
export declare type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
export declare type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
export declare const isAborted: (x: ParseReturnType<any>) => x is INVALID;
export declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
export declare const isValid: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;

176
node_modules/zod/lib/helpers/parseUtil.js generated vendored Normal file
View File

@@ -0,0 +1,176 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = exports.getParsedType = exports.ZodParsedType = void 0;
const ZodError_1 = require("../ZodError");
const util_1 = require("./util");
exports.ZodParsedType = util_1.util.arrayToEnum([
"string",
"nan",
"number",
"integer",
"float",
"boolean",
"date",
"bigint",
"symbol",
"function",
"undefined",
"null",
"array",
"object",
"unknown",
"promise",
"void",
"never",
"map",
"set",
]);
const getParsedType = (data) => {
const t = typeof data;
switch (t) {
case "undefined":
return exports.ZodParsedType.undefined;
case "string":
return exports.ZodParsedType.string;
case "number":
return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
case "boolean":
return exports.ZodParsedType.boolean;
case "function":
return exports.ZodParsedType.function;
case "bigint":
return exports.ZodParsedType.bigint;
case "object":
if (Array.isArray(data)) {
return exports.ZodParsedType.array;
}
if (data === null) {
return exports.ZodParsedType.null;
}
if (data.then &&
typeof data.then === "function" &&
data.catch &&
typeof data.catch === "function") {
return exports.ZodParsedType.promise;
}
if (typeof Map !== "undefined" && data instanceof Map) {
return exports.ZodParsedType.map;
}
if (typeof Set !== "undefined" && data instanceof Set) {
return exports.ZodParsedType.set;
}
if (typeof Date !== "undefined" && data instanceof Date) {
return exports.ZodParsedType.date;
}
return exports.ZodParsedType.object;
default:
return exports.ZodParsedType.unknown;
}
};
exports.getParsedType = getParsedType;
const makeIssue = (params) => {
const { data, path, errorMaps, issueData } = params;
const fullPath = [...path, ...(issueData.path || [])];
const fullIssue = {
...issueData,
path: fullPath,
};
let errorMessage = "";
const maps = errorMaps
.filter((m) => !!m)
.slice()
.reverse();
for (const map of maps) {
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
}
return {
...issueData,
path: fullPath,
message: issueData.message || errorMessage,
};
};
exports.makeIssue = makeIssue;
exports.EMPTY_PATH = [];
function addIssueToContext(ctx, issueData) {
const issue = (0, exports.makeIssue)({
issueData: issueData,
data: ctx.data,
path: ctx.path,
errorMaps: [
ctx.common.contextualErrorMap,
ctx.schemaErrorMap,
ZodError_1.overrideErrorMap,
ZodError_1.defaultErrorMap, // then global default map
].filter((x) => !!x),
});
ctx.common.issues.push(issue);
}
exports.addIssueToContext = addIssueToContext;
class ParseStatus {
constructor() {
this.value = "valid";
}
dirty() {
if (this.value === "valid")
this.value = "dirty";
}
abort() {
if (this.value !== "aborted")
this.value = "aborted";
}
static mergeArray(status, results) {
const arrayValue = [];
for (const s of results) {
if (s.status === "aborted")
return exports.INVALID;
if (s.status === "dirty")
status.dirty();
arrayValue.push(s.value);
}
return { status: status.value, value: arrayValue };
}
static async mergeObjectAsync(status, pairs) {
const syncPairs = [];
for (const pair of pairs) {
syncPairs.push({
key: await pair.key,
value: await pair.value,
});
}
return ParseStatus.mergeObjectSync(status, syncPairs);
}
static mergeObjectSync(status, pairs) {
const finalObject = {};
for (const pair of pairs) {
const { key, value } = pair;
if (key.status === "aborted")
return exports.INVALID;
if (value.status === "aborted")
return exports.INVALID;
if (key.status === "dirty")
status.dirty();
if (value.status === "dirty")
status.dirty();
if (typeof value.value !== "undefined" || pair.alwaysSet) {
finalObject[key.value] = value.value;
}
}
return { status: status.value, value: finalObject };
}
}
exports.ParseStatus = ParseStatus;
exports.INVALID = Object.freeze({
status: "aborted",
});
const DIRTY = (value) => ({ status: "dirty", value });
exports.DIRTY = DIRTY;
const OK = (value) => ({ status: "valid", value });
exports.OK = OK;
const isAborted = (x) => x.status === "aborted";
exports.isAborted = isAborted;
const isDirty = (x) => x.status === "dirty";
exports.isDirty = isDirty;
const isValid = (x) => x.status === "valid";
exports.isValid = isValid;
const isAsync = (x) => typeof Promise !== undefined && x instanceof Promise;
exports.isAsync = isAsync;

8
node_modules/zod/lib/helpers/partialUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodTuple, ZodTupleItems, ZodTypeAny } from "../index";
export declare namespace partialUtil {
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<infer Shape, infer Params, infer Catchall> ? ZodObject<{
[k in keyof Shape]: ZodOptional<DeepPartial<Shape[k]>>;
}, Params, Catchall> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
}

2
node_modules/zod/lib/helpers/partialUtil.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

2
node_modules/zod/lib/helpers/typeAliases.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare type Primitive = string | number | bigint | boolean | null | undefined;
export declare type Scalars = Primitive | Primitive[];

2
node_modules/zod/lib/helpers/typeAliases.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

18
node_modules/zod/lib/helpers/util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
export declare namespace util {
type AssertEqual<T, Expected> = [T] extends [Expected] ? [Expected] extends [T] ? true : false : false;
function assertNever(_x: never): never;
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
const getValidEnumValues: (obj: any) => any[];
const objectValues: (obj: any) => any[];
const objectKeys: ObjectConstructor["keys"];
const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
type identity<T> = T;
type flatten<T extends object> = identity<{
[k in keyof T]: T[k];
}>;
type noUndefined<T> = T extends undefined ? never : T;
const isInteger: NumberConstructor["isInteger"];
}

51
node_modules/zod/lib/helpers/util.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
var util;
(function (util) {
function assertNever(_x) {
throw new Error();
}
util.assertNever = assertNever;
util.arrayToEnum = (items) => {
const obj = {};
for (const item of items) {
obj[item] = item;
}
return obj;
};
util.getValidEnumValues = (obj) => {
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
const filtered = {};
for (const k of validKeys) {
filtered[k] = obj[k];
}
return util.objectValues(filtered);
};
util.objectValues = (obj) => {
return util.objectKeys(obj).map(function (e) {
return obj[e];
});
};
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
: (object) => {
const keys = [];
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
keys.push(key);
}
}
return keys;
};
util.find = (arr, checker) => {
for (const item of arr) {
if (checker(item))
return item;
}
return undefined;
};
util.isInteger = typeof Number.isInteger === "function"
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
: (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
})(util = exports.util || (exports.util = {}));

4
node_modules/zod/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import * as mod from "./external";
export * from "./external";
export { mod as z };
export default mod;

33
node_modules/zod/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.z = void 0;
const mod = __importStar(require("./external"));
exports.z = mod;
__exportStar(require("./external"), exports);
exports.default = mod;

2871
node_modules/zod/lib/index.mjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

723
node_modules/zod/lib/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,723 @@
import { errorUtil } from "./helpers/errorUtil";
import { AsyncParseReturnType, ParseContext, ParseInput, ParseParams, ParseReturnType, ParseStatus, SyncParseReturnType } from "./helpers/parseUtil";
import { partialUtil } from "./helpers/partialUtil";
import { Primitive } from "./helpers/typeAliases";
import { util } from "./helpers/util";
import { IssueData, StringValidation, ZodCustomIssue, ZodError, ZodErrorMap } from "./ZodError";
export declare type RefinementCtx = {
addIssue: (arg: IssueData) => void;
path: (string | number)[];
};
export declare type ZodRawShape = {
[k: string]: ZodTypeAny;
};
export declare type ZodTypeAny = ZodType<any, any, any>;
export declare type TypeOf<T extends ZodType<any, any, any>> = T["_output"];
export declare type input<T extends ZodType<any, any, any>> = T["_input"];
export declare type output<T extends ZodType<any, any, any>> = T["_output"];
declare type allKeys<T> = T extends any ? keyof T : never;
export declare type TypeOfFlattenedError<T extends ZodType<any, any, any>, U = string> = {
formErrors: U[];
fieldErrors: {
[P in allKeys<TypeOf<T>>]?: U[];
};
};
export declare type TypeOfFormErrors<T extends ZodType<any, any, any>> = TypeOfFlattenedError<T>;
export type { TypeOf as infer, TypeOfFlattenedError as inferFlattenedErrors, TypeOfFormErrors as inferFormErrors, };
export declare type CustomErrorParams = Partial<util.Omit<ZodCustomIssue, "code">>;
export interface ZodTypeDef {
errorMap?: ZodErrorMap;
description?: string;
}
declare type RawCreateParams = {
errorMap?: ZodErrorMap;
invalid_type_error?: string;
required_error?: string;
description?: string;
} | undefined;
export declare type SafeParseSuccess<Output> = {
success: true;
data: Output;
};
export declare type SafeParseError<Input> = {
success: false;
error: ZodError<Input>;
};
export declare type SafeParseReturnType<Input, Output> = SafeParseSuccess<Output> | SafeParseError<Input>;
export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
readonly _type: Output;
readonly _output: Output;
readonly _input: Input;
readonly _def: Def;
get description(): string | undefined;
abstract _parse(input: ParseInput): ParseReturnType<Output>;
_getType(input: ParseInput): string;
_getOrReturnCtx(input: ParseInput, ctx?: ParseContext | undefined): ParseContext;
_processInputParams(input: ParseInput): {
status: ParseStatus;
ctx: ParseContext;
};
_parseSync(input: ParseInput): SyncParseReturnType<Output>;
_parseAsync(input: ParseInput): AsyncParseReturnType<Output>;
parse(data: unknown, params?: Partial<ParseParams>): Output;
safeParse(data: unknown, params?: Partial<ParseParams>): SafeParseReturnType<Input, Output>;
parseAsync(data: unknown, params?: Partial<ParseParams>): Promise<Output>;
safeParseAsync(data: unknown, params?: Partial<ParseParams>): Promise<SafeParseReturnType<Input, Output>>;
/** Alias of safeParseAsync */
spa: (data: unknown, params?: Partial<ParseParams> | undefined) => Promise<SafeParseReturnType<Input, Output>>;
refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, RefinedOutput>;
refine(check: (arg: Output) => unknown | Promise<unknown>, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, Output, Input>;
refinement<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, RefinedOutput, RefinedOutput>;
refinement(check: (arg: Output) => boolean, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, Output, Input>;
_refinement(refinement: RefinementEffect<Output>["refinement"]): ZodEffects<this, Output, Input>;
superRefine: (refinement: RefinementEffect<Output>["refinement"]) => ZodEffects<this, Output, Input>;
constructor(def: Def);
optional(): ZodOptional<this>;
nullable(): ZodNullable<this>;
nullish(): ZodNullable<ZodOptional<this>>;
array(): ZodArray<this>;
promise(): ZodPromise<this>;
or<T extends ZodTypeAny>(option: T): ZodUnion<[this, T]>;
and<T extends ZodTypeAny>(incoming: T): ZodIntersection<this, T>;
transform<NewOut>(transform: (arg: Output) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>;
default(def: util.noUndefined<Input>): ZodDefault<this>;
default(def: () => util.noUndefined<Input>): ZodDefault<this>;
describe(description: string): this;
isOptional(): boolean;
isNullable(): boolean;
}
declare type ZodStringCheck = {
kind: "min";
value: number;
message?: string;
} | {
kind: "max";
value: number;
message?: string;
} | {
kind: "email";
message?: string;
} | {
kind: "url";
message?: string;
} | {
kind: "uuid";
message?: string;
} | {
kind: "cuid";
message?: string;
} | {
kind: "regex";
regex: RegExp;
message?: string;
};
export interface ZodStringDef extends ZodTypeDef {
checks: ZodStringCheck[];
typeName: ZodFirstPartyTypeKind.ZodString;
}
export declare class ZodString extends ZodType<string, ZodStringDef> {
_parse(input: ParseInput): ParseReturnType<string>;
protected _regex: (regex: RegExp, validation: StringValidation, message?: errorUtil.ErrMessage | undefined) => ZodEffects<this, string, string>;
_addCheck(check: ZodStringCheck): ZodString;
email(message?: errorUtil.ErrMessage): ZodString;
url(message?: errorUtil.ErrMessage): ZodString;
uuid(message?: errorUtil.ErrMessage): ZodString;
cuid(message?: errorUtil.ErrMessage): ZodString;
regex(regex: RegExp, message?: errorUtil.ErrMessage): ZodString;
min(minLength: number, message?: errorUtil.ErrMessage): ZodString;
max(maxLength: number, message?: errorUtil.ErrMessage): ZodString;
length(len: number, message?: errorUtil.ErrMessage): ZodString;
/**
* Deprecated.
* Use z.string().min(1) instead.
*/
nonempty: (message?: errorUtil.ErrMessage | undefined) => ZodString;
get isEmail(): boolean;
get isURL(): boolean;
get isUUID(): boolean;
get isCUID(): boolean;
get minLength(): number;
get maxLength(): null;
static create: (params?: RawCreateParams) => ZodString;
}
declare type ZodNumberCheck = {
kind: "min";
value: number;
inclusive: boolean;
message?: string;
} | {
kind: "max";
value: number;
inclusive: boolean;
message?: string;
} | {
kind: "int";
message?: string;
} | {
kind: "multipleOf";
value: number;
message?: string;
};
export interface ZodNumberDef extends ZodTypeDef {
checks: ZodNumberCheck[];
typeName: ZodFirstPartyTypeKind.ZodNumber;
}
export declare class ZodNumber extends ZodType<number, ZodNumberDef> {
_parse(input: ParseInput): ParseReturnType<number>;
static create: (params?: RawCreateParams) => ZodNumber;
gte(value: number, message?: errorUtil.ErrMessage): ZodNumber;
min: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
gt(value: number, message?: errorUtil.ErrMessage): ZodNumber;
lte(value: number, message?: errorUtil.ErrMessage): ZodNumber;
max: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
lt(value: number, message?: errorUtil.ErrMessage): ZodNumber;
protected setLimit(kind: "min" | "max", value: number, inclusive: boolean, message?: string): ZodNumber;
_addCheck(check: ZodNumberCheck): ZodNumber;
int(message?: errorUtil.ErrMessage): ZodNumber;
positive(message?: errorUtil.ErrMessage): ZodNumber;
negative(message?: errorUtil.ErrMessage): ZodNumber;
nonpositive(message?: errorUtil.ErrMessage): ZodNumber;
nonnegative(message?: errorUtil.ErrMessage): ZodNumber;
multipleOf(value: number, message?: errorUtil.ErrMessage): ZodNumber;
step: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
get minValue(): number | null;
get maxValue(): number | null;
get isInt(): boolean;
}
export interface ZodBigIntDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodBigInt;
}
export declare class ZodBigInt extends ZodType<bigint, ZodBigIntDef> {
_parse(input: ParseInput): ParseReturnType<bigint>;
static create: (params?: RawCreateParams) => ZodBigInt;
}
export interface ZodBooleanDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodBoolean;
}
export declare class ZodBoolean extends ZodType<boolean, ZodBooleanDef> {
_parse(input: ParseInput): ParseReturnType<boolean>;
static create: (params?: RawCreateParams) => ZodBoolean;
}
export interface ZodDateDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodDate;
}
export declare class ZodDate extends ZodType<Date, ZodDateDef> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodDate;
}
export interface ZodUndefinedDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodUndefined;
}
export declare class ZodUndefined extends ZodType<undefined, ZodUndefinedDef> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
params?: RawCreateParams;
static create: (params?: RawCreateParams) => ZodUndefined;
}
export interface ZodNullDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodNull;
}
export declare class ZodNull extends ZodType<null, ZodNullDef> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodNull;
}
export interface ZodAnyDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodAny;
}
export declare class ZodAny extends ZodType<any, ZodAnyDef> {
_any: true;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodAny;
}
export interface ZodUnknownDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodUnknown;
}
export declare class ZodUnknown extends ZodType<unknown, ZodUnknownDef> {
_unknown: true;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodUnknown;
}
export interface ZodNeverDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodNever;
}
export declare class ZodNever extends ZodType<never, ZodNeverDef> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodNever;
}
export interface ZodVoidDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodVoid;
}
export declare class ZodVoid extends ZodType<void, ZodVoidDef> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: (params?: RawCreateParams) => ZodVoid;
}
export interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
type: T;
typeName: ZodFirstPartyTypeKind.ZodArray;
minLength: {
value: number;
message?: string;
} | null;
maxLength: {
value: number;
message?: string;
} | null;
}
export declare type ArrayCardinality = "many" | "atleastone";
declare type arrayOutputType<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> = Cardinality extends "atleastone" ? [T["_output"], ...T["_output"][]] : T["_output"][];
export declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> extends ZodType<arrayOutputType<T, Cardinality>, ZodArrayDef<T>, Cardinality extends "atleastone" ? [T["_input"], ...T["_input"][]] : T["_input"][]> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get element(): T;
min(minLength: number, message?: errorUtil.ErrMessage): this;
max(maxLength: number, message?: errorUtil.ErrMessage): this;
length(len: number, message?: errorUtil.ErrMessage): this;
nonempty(message?: errorUtil.ErrMessage): ZodArray<T, "atleastone">;
static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodArray<T_1, "many">;
}
export declare type ZodNonEmptyArray<T extends ZodTypeAny> = ZodArray<T, "atleastone">;
export declare namespace objectUtil {
export type MergeShapes<U extends ZodRawShape, V extends ZodRawShape> = {
[k in Exclude<keyof U, keyof V>]: U[k];
} & V;
type optionalKeys<T extends object> = {
[k in keyof T]: undefined extends T[k] ? k : never;
}[keyof T];
type requiredKeys<T extends object> = {
[k in keyof T]: undefined extends T[k] ? never : k;
}[keyof T];
export type addQuestionMarks<T extends object> = {
[k in optionalKeys<T>]?: T[k];
} & {
[k in requiredKeys<T>]: T[k];
};
export type identity<T> = T;
export type flatten<T extends object> = identity<{
[k in keyof T]: T[k];
}>;
export type noNeverKeys<T extends ZodRawShape> = {
[k in keyof T]: [T[k]] extends [never] ? never : k;
}[keyof T];
export type noNever<T extends ZodRawShape> = identity<{
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
}>;
export const mergeShapes: <U extends ZodRawShape, T extends ZodRawShape>(first: U, second: T) => T & U;
export {};
}
export declare type extendShape<A, B> = {
[k in Exclude<keyof A, keyof B>]: A[k];
} & {
[k in keyof B]: B[k];
};
declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
export interface ZodObjectDef<T extends ZodRawShape = ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodObject;
shape: () => T;
catchall: Catchall;
unknownKeys: UnknownKeys;
}
export declare type baseObjectOutputType<Shape extends ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
[k in keyof Shape]: Shape[k]["_output"];
}>>;
export declare type objectOutputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny> = ZodTypeAny extends Catchall ? baseObjectOutputType<Shape> : objectUtil.flatten<baseObjectOutputType<Shape> & {
[k: string]: Catchall["_output"];
}>;
export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
[k in keyof Shape]: Shape[k]["_input"];
}>>;
export declare type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny> = ZodTypeAny extends Catchall ? baseObjectInputType<Shape> : objectUtil.flatten<baseObjectInputType<Shape> & {
[k: string]: Catchall["_input"];
}>;
declare type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U> ? deoptional<U> : T;
export declare type SomeZodObject = ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny, any, any>;
export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = "strip", Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall>, Input = objectInputType<T, Catchall>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
readonly _shape: T;
readonly _unknownKeys: UnknownKeys;
readonly _catchall: Catchall;
private _cached;
_getCached(): {
shape: T;
keys: string[];
};
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get shape(): T;
strict(message?: errorUtil.ErrMessage): ZodObject<T, "strict", Catchall>;
strip(): ZodObject<T, "strip", Catchall>;
passthrough(): ZodObject<T, "passthrough", Catchall>;
/**
* @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
* If you want to pass through unknown properties, use `.passthrough()` instead.
*/
nonstrict: () => ZodObject<T, "passthrough", Catchall>;
augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<extendShape<T, Augmentation>, UnknownKeys, Catchall, objectOutputType<extendShape<T, Augmentation>, Catchall>, objectInputType<extendShape<T, Augmentation>, Catchall>>;
extend: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<extendShape<T, Augmentation>, UnknownKeys, Catchall, objectOutputType<extendShape<T, Augmentation>, Catchall>, objectInputType<extendShape<T, Augmentation>, Catchall>>;
setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & {
[k in Key]: Schema;
}, UnknownKeys, Catchall>;
/**
* Prior to zod@1.0.12 there was a bug in the
* inferred type of merged objects. Please
* upgrade if you are experiencing issues.
*/
merge<Incoming extends AnyZodObject>(merging: Incoming): ZodObject<extendShape<T, Incoming["_shape"]>, UnknownKeys, Catchall>;
catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>;
pick<Mask extends {
[k in keyof T]?: true;
}>(mask: Mask): ZodObject<objectUtil.noNever<{
[k in keyof Mask]: k extends keyof T ? T[k] : never;
}>, UnknownKeys, Catchall>;
omit<Mask extends {
[k in keyof T]?: true;
}>(mask: Mask): ZodObject<objectUtil.noNever<{
[k in keyof T]: k extends keyof Mask ? never : T[k];
}>, UnknownKeys, Catchall>;
deepPartial(): partialUtil.DeepPartial<this>;
partial(): ZodObject<{
[k in keyof T]: ZodOptional<T[k]>;
}, UnknownKeys, Catchall>;
partial<Mask extends {
[k in keyof T]?: true;
}>(mask: Mask): ZodObject<objectUtil.noNever<{
[k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k];
}>, UnknownKeys, Catchall>;
required(): ZodObject<{
[k in keyof T]: deoptional<T[k]>;
}, UnknownKeys, Catchall>;
static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>[k_3]; }>;
static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>[k_3]; }>;
static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T_1]: T_1[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T_1]: T_1[k_2]["_input"]; }>[k_3]; }>;
}
export declare type AnyZodObject = ZodObject<any, any, any>;
declare type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
export interface ZodUnionDef<T extends ZodUnionOptions = Readonly<[
ZodTypeAny,
ZodTypeAny,
...ZodTypeAny[]
]>> extends ZodTypeDef {
options: T;
typeName: ZodFirstPartyTypeKind.ZodUnion;
}
export declare class ZodUnion<T extends ZodUnionOptions> extends ZodType<T[number]["_output"], ZodUnionDef<T>, T[number]["_input"]> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get options(): T;
static create: <T_1 extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T_1, params?: RawCreateParams) => ZodUnion<T_1>;
}
export declare type ZodDiscriminatedUnionOption<Discriminator extends string, DiscriminatorValue extends Primitive> = ZodObject<{
[key in Discriminator]: ZodLiteral<DiscriminatorValue>;
} & ZodRawShape, any, any>;
export interface ZodDiscriminatedUnionDef<Discriminator extends string, DiscriminatorValue extends Primitive, Option extends ZodDiscriminatedUnionOption<Discriminator, DiscriminatorValue>> extends ZodTypeDef {
discriminator: Discriminator;
options: Map<DiscriminatorValue, Option>;
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion;
}
export declare class ZodDiscriminatedUnion<Discriminator extends string, DiscriminatorValue extends Primitive, Option extends ZodDiscriminatedUnionOption<Discriminator, DiscriminatorValue>> extends ZodType<Option["_output"], ZodDiscriminatedUnionDef<Discriminator, DiscriminatorValue, Option>, Option["_input"]> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get discriminator(): Discriminator;
get validDiscriminatorValues(): DiscriminatorValue[];
get options(): Map<DiscriminatorValue, Option>;
/**
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
* have a different value for each object in the union.
* @param discriminator the name of the discriminator property
* @param types an array of object schemas
* @param params
*/
static create<Discriminator extends string, DiscriminatorValue extends Primitive, Types extends [
ZodDiscriminatedUnionOption<Discriminator, DiscriminatorValue>,
ZodDiscriminatedUnionOption<Discriminator, DiscriminatorValue>,
...ZodDiscriminatedUnionOption<Discriminator, DiscriminatorValue>[]
]>(discriminator: Discriminator, types: Types, params?: RawCreateParams): ZodDiscriminatedUnion<Discriminator, DiscriminatorValue, Types[number]>;
}
export interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
left: T;
right: U;
typeName: ZodFirstPartyTypeKind.ZodIntersection;
}
export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<T["_output"] & U["_output"], ZodIntersectionDef<T, U>, T["_input"] & U["_input"]> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: <T_1 extends ZodTypeAny, U_1 extends ZodTypeAny>(left: T_1, right: U_1, params?: RawCreateParams) => ZodIntersection<T_1, U_1>;
}
export declare type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
export declare type AssertArray<T> = T extends any[] ? T : never;
export declare type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
[k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;
}>;
export declare type OutputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...OutputTypeOfTuple<T>, ...Rest["_output"][]] : OutputTypeOfTuple<T>;
export declare type InputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
[k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_input"] : never;
}>;
export declare type InputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...InputTypeOfTuple<T>, ...Rest["_input"][]] : InputTypeOfTuple<T>;
export interface ZodTupleDef<T extends ZodTupleItems | [] = ZodTupleItems, Rest extends ZodTypeAny | null = null> extends ZodTypeDef {
items: T;
rest: Rest;
typeName: ZodFirstPartyTypeKind.ZodTuple;
}
export declare class ZodTuple<T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]], Rest extends ZodTypeAny | null = null> extends ZodType<OutputTypeOfTupleWithRest<T, Rest>, ZodTupleDef<T, Rest>, InputTypeOfTupleWithRest<T, Rest>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get items(): T;
rest<Rest extends ZodTypeAny>(rest: Rest): ZodTuple<T, Rest>;
static create: <T_1 extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: T_1, params?: RawCreateParams) => ZodTuple<T_1, null>;
}
export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
valueType: Value;
keyType: Key;
typeName: ZodFirstPartyTypeKind.ZodRecord;
}
declare type KeySchema = ZodType<string | number | symbol, any, any>;
declare type RecordType<K extends string | number | symbol, V> = [string] extends [K] ? Record<K, V> : [number] extends [K] ? Record<K, V> : [symbol] extends [K] ? Record<K, V> : Partial<Record<K, V>>;
export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<RecordType<Key["_output"], Value["_output"]>, ZodRecordDef<Key, Value>, RecordType<Key["_input"], Value["_input"]>> {
get keySchema(): Key;
get valueSchema(): Value;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get element(): Value;
static create<Value extends ZodTypeAny>(valueType: Value, params?: RawCreateParams): ZodRecord<ZodString, Value>;
static create<Keys extends KeySchema, Value extends ZodTypeAny>(keySchema: Keys, valueType: Value, params?: RawCreateParams): ZodRecord<Keys, Value>;
}
export interface ZodMapDef<Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
valueType: Value;
keyType: Key;
typeName: ZodFirstPartyTypeKind.ZodMap;
}
export declare class ZodMap<Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Map<Key["_output"], Value["_output"]>, ZodMapDef<Key, Value>, Map<Key["_input"], Value["_input"]>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: <Key_1 extends ZodTypeAny = ZodTypeAny, Value_1 extends ZodTypeAny = ZodTypeAny>(keyType: Key_1, valueType: Value_1, params?: RawCreateParams) => ZodMap<Key_1, Value_1>;
}
export interface ZodSetDef<Value extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
valueType: Value;
typeName: ZodFirstPartyTypeKind.ZodSet;
minSize: {
value: number;
message?: string;
} | null;
maxSize: {
value: number;
message?: string;
} | null;
}
export declare class ZodSet<Value extends ZodTypeAny = ZodTypeAny> extends ZodType<Set<Value["_output"]>, ZodSetDef<Value>, Set<Value["_input"]>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
min(minSize: number, message?: errorUtil.ErrMessage): this;
max(maxSize: number, message?: errorUtil.ErrMessage): this;
size(size: number, message?: errorUtil.ErrMessage): this;
nonempty(message?: errorUtil.ErrMessage): ZodSet<Value>;
static create: <Value_1 extends ZodTypeAny = ZodTypeAny>(valueType: Value_1, params?: RawCreateParams) => ZodSet<Value_1>;
}
export interface ZodFunctionDef<Args extends ZodTuple<any, any> = ZodTuple<any, any>, Returns extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
args: Args;
returns: Returns;
typeName: ZodFirstPartyTypeKind.ZodFunction;
}
export declare type OuterTypeOfFunction<Args extends ZodTuple<any, any>, Returns extends ZodTypeAny> = Args["_input"] extends Array<any> ? (...args: Args["_input"]) => Returns["_output"] : never;
export declare type InnerTypeOfFunction<Args extends ZodTuple<any, any>, Returns extends ZodTypeAny> = Args["_output"] extends Array<any> ? (...args: Args["_output"]) => Returns["_input"] : never;
export declare class ZodFunction<Args extends ZodTuple<any, any>, Returns extends ZodTypeAny> extends ZodType<OuterTypeOfFunction<Args, Returns>, ZodFunctionDef<Args, Returns>, InnerTypeOfFunction<Args, Returns>> {
_parse(input: ParseInput): ParseReturnType<any>;
parameters(): Args;
returnType(): Returns;
args<Items extends Parameters<typeof ZodTuple["create"]>[0]>(...items: Items): ZodFunction<ZodTuple<Items, ZodUnknown>, Returns>;
returns<NewReturnType extends ZodType<any, any>>(returnType: NewReturnType): ZodFunction<Args, NewReturnType>;
implement<F extends InnerTypeOfFunction<Args, Returns>>(func: F): F;
strictImplement(func: InnerTypeOfFunction<Args, Returns>): InnerTypeOfFunction<Args, Returns>;
validate: <F extends InnerTypeOfFunction<Args, Returns>>(func: F) => F;
static create: <T extends ZodTuple<any, any> = ZodTuple<[], ZodUnknown>, U extends ZodTypeAny = ZodUnknown>(args?: T | undefined, returns?: U | undefined, params?: RawCreateParams) => ZodFunction<T, U>;
}
export interface ZodLazyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
getter: () => T;
typeName: ZodFirstPartyTypeKind.ZodLazy;
}
export declare class ZodLazy<T extends ZodTypeAny> extends ZodType<output<T>, ZodLazyDef<T>, input<T>> {
get schema(): T;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: <T_1 extends ZodTypeAny>(getter: () => T_1, params?: RawCreateParams) => ZodLazy<T_1>;
}
export interface ZodLiteralDef<T = any> extends ZodTypeDef {
value: T;
typeName: ZodFirstPartyTypeKind.ZodLiteral;
}
export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get value(): T;
static create: <T_1 extends Primitive>(value: T_1, params?: RawCreateParams) => ZodLiteral<T_1>;
}
export declare type ArrayKeys = keyof any[];
export declare type Indices<T> = Exclude<keyof T, ArrayKeys>;
declare type EnumValues = [string, ...string[]];
declare type Values<T extends EnumValues> = {
[k in T[number]]: k;
};
export interface ZodEnumDef<T extends EnumValues = EnumValues> extends ZodTypeDef {
values: T;
typeName: ZodFirstPartyTypeKind.ZodEnum;
}
declare type Writeable<T> = {
-readonly [P in keyof T]: T[P];
};
declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T): ZodEnum<Writeable<T>>;
declare function createZodEnum<U extends string, T extends [U, ...U[]]>(values: T): ZodEnum<T>;
export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
get options(): T;
get enum(): Values<T>;
get Values(): Values<T>;
get Enum(): Values<T>;
static create: typeof createZodEnum;
}
export interface ZodNativeEnumDef<T extends EnumLike = EnumLike> extends ZodTypeDef {
values: T;
typeName: ZodFirstPartyTypeKind.ZodNativeEnum;
}
declare type EnumLike = {
[k: string]: string | number;
[nu: number]: string;
};
export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T], ZodNativeEnumDef<T>> {
_parse(input: ParseInput): ParseReturnType<T[keyof T]>;
get enum(): T;
static create: <T_1 extends EnumLike>(values: T_1, params?: RawCreateParams) => ZodNativeEnum<T_1>;
}
export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
type: T;
typeName: ZodFirstPartyTypeKind.ZodPromise;
}
export declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodPromise<T_1>;
}
export declare type Refinement<T> = (arg: T, ctx: RefinementCtx) => any;
export declare type SuperRefinement<T> = (arg: T, ctx: RefinementCtx) => void;
export declare type RefinementEffect<T> = {
type: "refinement";
refinement: (arg: T, ctx: RefinementCtx) => any;
};
export declare type TransformEffect<T> = {
type: "transform";
transform: (arg: T) => any;
};
export declare type PreprocessEffect<T> = {
type: "preprocess";
transform: (arg: T) => any;
};
export declare type Effect<T> = RefinementEffect<T> | TransformEffect<T> | PreprocessEffect<T>;
export interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
schema: T;
typeName: ZodFirstPartyTypeKind.ZodEffects;
effect: Effect<any>;
}
export declare class ZodEffects<T extends ZodTypeAny, Output = T["_output"], Input = T["_input"]> extends ZodType<Output, ZodEffectsDef<T>, Input> {
innerType(): T;
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
static create: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
}
export { ZodEffects as ZodTransformer };
export interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodOptional;
}
export declare type ZodOptionalType<T extends ZodTypeAny> = ZodOptional<T>;
export declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T["_output"] | undefined, ZodOptionalDef<T>, T["_input"] | undefined> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
unwrap(): T;
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodOptional<T_1>;
}
export interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
innerType: T;
typeName: ZodFirstPartyTypeKind.ZodNullable;
}
export declare type ZodNullableType<T extends ZodTypeAny> = ZodNullable<T>;
export declare class ZodNullable<T extends ZodTypeAny> extends ZodType<T["_output"] | null, ZodNullableDef<T>, T["_input"] | null> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
unwrap(): T;
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodNullable<T_1>;
}
export interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
innerType: T;
defaultValue: () => util.noUndefined<T["_input"]>;
typeName: ZodFirstPartyTypeKind.ZodDefault;
}
export declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUndefined<T["_output"]>, ZodDefaultDef<T>, T["_input"] | undefined> {
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
removeDefault(): T;
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodOptional<T_1>;
}
export interface ZodNaNDef extends ZodTypeDef {
typeName: ZodFirstPartyTypeKind.ZodNaN;
}
export declare class ZodNaN extends ZodType<number, ZodNaNDef> {
_parse(input: ParseInput): ParseReturnType<any>;
static create: (params?: RawCreateParams) => ZodNaN;
}
export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<T, ZodTypeDef, T>;
export { ZodType as Schema, ZodType as ZodSchema };
export declare const late: {
object: <T extends ZodRawShape>(shape: () => T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
};
export declare enum ZodFirstPartyTypeKind {
ZodString = "ZodString",
ZodNumber = "ZodNumber",
ZodNaN = "ZodNaN",
ZodBigInt = "ZodBigInt",
ZodBoolean = "ZodBoolean",
ZodDate = "ZodDate",
ZodUndefined = "ZodUndefined",
ZodNull = "ZodNull",
ZodAny = "ZodAny",
ZodUnknown = "ZodUnknown",
ZodNever = "ZodNever",
ZodVoid = "ZodVoid",
ZodArray = "ZodArray",
ZodObject = "ZodObject",
ZodUnion = "ZodUnion",
ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
ZodIntersection = "ZodIntersection",
ZodTuple = "ZodTuple",
ZodRecord = "ZodRecord",
ZodMap = "ZodMap",
ZodSet = "ZodSet",
ZodFunction = "ZodFunction",
ZodLazy = "ZodLazy",
ZodLiteral = "ZodLiteral",
ZodEnum = "ZodEnum",
ZodEffects = "ZodEffects",
ZodNativeEnum = "ZodNativeEnum",
ZodOptional = "ZodOptional",
ZodNullable = "ZodNullable",
ZodDefault = "ZodDefault",
ZodPromise = "ZodPromise"
}
export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any, any, any> | ZodUnion<any> | ZodDiscriminatedUnion<any, any, any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodPromise<any>;
declare const instanceOfType: <T extends new (...args: any[]) => any>(cls: T, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
declare const stringType: (params?: RawCreateParams) => ZodString;
declare const numberType: (params?: RawCreateParams) => ZodNumber;
declare const nanType: (params?: RawCreateParams) => ZodNaN;
declare const bigIntType: (params?: RawCreateParams) => ZodBigInt;
declare const booleanType: (params?: RawCreateParams) => ZodBoolean;
declare const dateType: (params?: RawCreateParams) => ZodDate;
declare const undefinedType: (params?: RawCreateParams) => ZodUndefined;
declare const nullType: (params?: RawCreateParams) => ZodNull;
declare const anyType: (params?: RawCreateParams) => ZodAny;
declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
declare const neverType: (params?: RawCreateParams) => ZodNever;
declare const voidType: (params?: RawCreateParams) => ZodVoid;
declare const arrayType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodArray<T, "many">;
declare const objectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
declare const strictObjectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>]: objectUtil.addQuestionMarks<{ [k in keyof T]: T[k]["_output"]; }>[k_1]; }, { [k_3 in keyof objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_2 in keyof T]: T[k_2]["_input"]; }>[k_3]; }>;
declare const unionType: <T extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T, params?: RawCreateParams) => ZodUnion<T>;
declare const discriminatedUnionType: typeof ZodDiscriminatedUnion.create;
declare const intersectionType: <T extends ZodTypeAny, U extends ZodTypeAny>(left: T, right: U, params?: RawCreateParams) => ZodIntersection<T, U>;
declare const tupleType: <T extends [ZodTypeAny, ...ZodTypeAny[]] | []>(schemas: T, params?: RawCreateParams) => ZodTuple<T, null>;
declare const recordType: typeof ZodRecord.create;
declare const mapType: <Key extends ZodTypeAny = ZodTypeAny, Value extends ZodTypeAny = ZodTypeAny>(keyType: Key, valueType: Value, params?: RawCreateParams) => ZodMap<Key, Value>;
declare const setType: <Value extends ZodTypeAny = ZodTypeAny>(valueType: Value, params?: RawCreateParams) => ZodSet<Value>;
declare const functionType: <T extends ZodTuple<any, any> = ZodTuple<[], ZodUnknown>, U extends ZodTypeAny = ZodUnknown>(args?: T | undefined, returns?: U | undefined, params?: RawCreateParams) => ZodFunction<T, U>;
declare const lazyType: <T extends ZodTypeAny>(getter: () => T, params?: RawCreateParams) => ZodLazy<T>;
declare const literalType: <T extends Primitive>(value: T, params?: RawCreateParams) => ZodLiteral<T>;
declare const enumType: typeof createZodEnum;
declare const nativeEnumType: <T extends EnumLike>(values: T, params?: RawCreateParams) => ZodNativeEnum<T>;
declare const promiseType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodPromise<T>;
declare const effectsType: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
declare const optionalType: <T extends ZodTypeAny>(type: T, params?: RawCreateParams) => ZodOptional<T>;
declare const nullableType: <T extends ZodTypeAny>(type: T, params?: RawCreateParams) => ZodNullable<T>;
declare const preprocessType: <I extends ZodTypeAny>(preprocess: (arg: unknown) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], I["_input"]>;
declare const ostring: () => ZodOptional<ZodString>;
declare const onumber: () => ZodOptional<ZodNumber>;
declare const oboolean: () => ZodOptional<ZodBoolean>;
export { anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, dateType as date, discriminatedUnionType as discriminatedUnion, effectsType as effect, enumType as enum, functionType as function, instanceOfType as instanceof, intersectionType as intersection, lazyType as lazy, literalType as literal, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, oboolean, onumber, optionalType as optional, ostring, preprocessType as preprocess, promiseType as promise, recordType as record, setType as set, strictObjectType as strictObject, stringType as string, effectsType as transformer, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void, };

2433
node_modules/zod/lib/types.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

99
node_modules/zod/package.json generated vendored Normal file
View File

@@ -0,0 +1,99 @@
{
"name": "zod",
"version": "3.14.3",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"module": "./lib/index.mjs",
"dependencies": {},
"exports": {
".": {
"require": "./lib/index.js",
"import": "./lib/index.mjs",
"types": "./lib/index.d.ts"
},
"./package.json": "./package.json"
},
"files": [
"/lib"
],
"repository": {
"type": "git",
"url": "https://github.com/colinhacks/zod"
},
"author": "Colin McDonnell <colin@colinhacks.com>",
"license": "MIT",
"sideEffects": false,
"bugs": {
"url": "https://github.com/colinhacks/zod/issues"
},
"homepage": "https://github.com/colinhacks/zod",
"funding": "https://github.com/sponsors/colinhacks",
"support": {
"backing": {
"npm-funding": true
}
},
"keywords": [
"typescript",
"schema",
"validation",
"type",
"inference"
],
"scripts": {
"prettier:check": "prettier --check src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
"prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts --ignore-unknown --no-error-on-unmatched-pattern",
"lint:check": "eslint --ext .ts ./src",
"lint:fix": "eslint --fix --ext .ts ./src",
"check": "yarn lint:check && yarn prettier:check",
"fix": "yarn lint:fix && yarn prettier:fix",
"clean": "rm -rf lib/* deno/lib/*",
"build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno",
"build:deno": "node ./deno/build.mjs",
"build:esm": "rollup --config rollup.config.js",
"build:cjs": "tsc --p tsconfig.cjs.json",
"build:types": "tsc --p tsconfig.types.json",
"rollup": "rollup --config rollup.config.js",
"test": "jest --coverage",
"test:deno": "cd deno && deno test",
"prepublishOnly": "npm run test && npm run build && npm run build:deno",
"play": "nodemon -e ts -w . -x ts-node src/playground.ts --project tsconfig.json --trace-warnings",
"depcruise": "depcruise -c .dependency-cruiser.js src",
"benchmark": "ts-node src/benchmarks/index.ts",
"prepare": "husky install"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.0",
"@types/benchmark": "^2.1.0",
"@types/jest": "^26.0.17",
"@types/node": "14",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"benchmark": "^2.1.4",
"dependency-cruiser": "^9.19.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-ban": "^1.6.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"lint-staged": "^12.3.7",
"nodemon": "^2.0.15",
"prettier": "^2.6.0",
"pretty-quick": "^3.1.3",
"rollup": "^2.70.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.7.0",
"tslib": "^2.3.1",
"typescript": "^4.6.2"
},
"lint-staged": {
"src/*.ts": [
"eslint --cache --fix",
"prettier --ignore-unknown --write"
]
}
}