@rspack/core 1.3.11 → 1.3.12
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/compiled/watchpack/index.js +56 -18
- package/compiled/watchpack/package.json +1 -1
- package/compiled/webpack-sources/index.js +1539 -339
- package/compiled/webpack-sources/package.json +1 -1
- package/compiled/webpack-sources/types.d.ts +320 -0
- package/compiled/zod/dist/types/index.d.ts +3 -0
- package/compiled/zod/{lib → dist/types/v3}/ZodError.d.ts +7 -7
- package/compiled/zod/{lib → dist/types/v3}/errors.d.ts +2 -2
- package/compiled/zod/dist/types/v3/external.d.ts +6 -0
- package/compiled/zod/{lib → dist/types/v3}/helpers/errorUtil.d.ts +1 -1
- package/compiled/zod/{lib → dist/types/v3}/helpers/parseUtil.d.ts +4 -4
- package/compiled/zod/{lib → dist/types/v3}/helpers/partialUtil.d.ts +1 -1
- package/compiled/zod/{lib → dist/types/v3}/helpers/util.d.ts +12 -9
- package/compiled/zod/dist/types/v3/index.d.ts +4 -0
- package/compiled/zod/{lib → dist/types/v3}/locales/en.d.ts +1 -1
- package/compiled/zod/{lib/__tests__ → dist/types/v3/tests}/Mocker.d.ts +6 -6
- package/compiled/zod/{lib → dist/types/v3}/types.d.ts +118 -149
- package/compiled/zod/dist/types/v4/classic/checks.d.ts +1 -0
- package/compiled/zod/dist/types/v4/classic/coerce.d.ts +17 -0
- package/compiled/zod/dist/types/v4/classic/compat.d.ts +48 -0
- package/compiled/zod/dist/types/v4/classic/errors.d.ts +30 -0
- package/compiled/zod/dist/types/v4/classic/external.d.ts +8 -0
- package/compiled/zod/dist/types/v4/classic/index.d.ts +4 -0
- package/compiled/zod/dist/types/v4/classic/iso.d.ts +22 -0
- package/compiled/zod/dist/types/v4/classic/parse.d.ts +23 -0
- package/compiled/zod/dist/types/v4/classic/schemas.d.ts +657 -0
- package/compiled/zod/dist/types/v4/core/api.d.ts +273 -0
- package/compiled/zod/dist/types/v4/core/checks.d.ts +277 -0
- package/compiled/zod/dist/types/v4/core/config.d.ts +9 -0
- package/compiled/zod/dist/types/v4/core/core.d.ts +43 -0
- package/compiled/zod/dist/types/v4/core/doc.d.ts +14 -0
- package/compiled/zod/dist/types/v4/core/errors.d.ts +205 -0
- package/compiled/zod/dist/types/v4/core/function.d.ts +47 -0
- package/compiled/zod/dist/types/v4/core/index.d.ts +15 -0
- package/compiled/zod/dist/types/v4/core/json-schema.d.ts +100 -0
- package/compiled/zod/dist/types/v4/core/parse.d.ts +25 -0
- package/compiled/zod/dist/types/v4/core/regexes.d.ts +62 -0
- package/compiled/zod/dist/types/v4/core/registries.d.ts +32 -0
- package/compiled/zod/dist/types/v4/core/schemas.d.ts +983 -0
- package/compiled/zod/dist/types/v4/core/standard-schema.d.ts +55 -0
- package/compiled/zod/dist/types/v4/core/to-json-schema.d.ts +84 -0
- package/compiled/zod/dist/types/v4/core/util.d.ts +186 -0
- package/compiled/zod/dist/types/v4/core/versions.d.ts +5 -0
- package/compiled/zod/dist/types/v4/core/zsf.d.ts +91 -0
- package/compiled/zod/dist/types/v4/index.d.ts +3 -0
- package/compiled/zod/dist/types/v4/locales/ar.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/az.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/be.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ca.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/cs.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/de.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/en.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/es.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/fa.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/fi.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/fr.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/frCA.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/he.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/hu.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/id.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/index.d.ts +34 -0
- package/compiled/zod/dist/types/v4/locales/it.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ja.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ko.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/mk.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ms.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/no.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ota.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/pl.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/pt.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ru.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/sl.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ta.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/th.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/tr.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ua.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/ur.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/vi.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/zh-CN.d.ts +7 -0
- package/compiled/zod/dist/types/v4/locales/zh-tw.d.ts +7 -0
- package/compiled/zod/dist/types/v4/mini/checks.d.ts +1 -0
- package/compiled/zod/dist/types/v4/mini/coerce.d.ts +7 -0
- package/compiled/zod/dist/types/v4/mini/external.d.ts +7 -0
- package/compiled/zod/dist/types/v4/mini/index.d.ts +3 -0
- package/compiled/zod/dist/types/v4/mini/iso.d.ts +22 -0
- package/compiled/zod/dist/types/v4/mini/parse.d.ts +1 -0
- package/compiled/zod/dist/types/v4/mini/schemas.d.ts +407 -0
- package/compiled/zod/index.js +555 -602
- package/compiled/zod/license +1 -1
- package/compiled/zod/package.json +1 -1
- package/compiled/zod/v3/index.d.ts +1 -0
- package/compiled/zod/v4/core/index.d.ts +1 -0
- package/compiled/zod/v4/index.d.ts +1 -0
- package/compiled/zod/v4/locales/en.d.ts +2 -0
- package/compiled/zod/v4/locales/index.d.ts +1 -0
- package/compiled/zod/v4-mini/index.d.ts +1 -0
- package/dist/Compilation.d.ts +2 -2
- package/dist/Compiler.d.ts +1 -1
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +2 -3
- package/dist/builtin-plugin/RstestPlugin.d.ts +11 -0
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/exports.d.ts +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +171 -210
- package/dist/node/NodeWatchFileSystem.d.ts +2 -2
- package/dist/trace/index.d.ts +5 -0
- package/package.json +7 -8
- package/compiled/webpack-sources/index.d.ts +0 -130
- package/compiled/zod/index.d.ts +0 -2
- package/compiled/zod/lib/external.d.ts +0 -6
- package/compiled/zod/lib/index.d.ts +0 -4
- package/dist/setupEnv.d.ts +0 -1
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/datetime.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/discriminatedUnion.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/index.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/ipv4.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/object.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/primitives.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/realworld.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/string.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/benchmarks/union.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/helpers/enumUtil.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/helpers/typeAliases.d.ts +0 -0
- /package/compiled/zod/{lib → dist/types/v3}/standard-schema.d.ts +0 -0
@@ -0,0 +1,205 @@
|
|
1
|
+
import type { $ZodCheck, $ZodStringFormats } from "./checks.js";
|
2
|
+
import { $constructor } from "./core.js";
|
3
|
+
import type { $ZodType } from "./schemas.js";
|
4
|
+
import * as util from "./util.js";
|
5
|
+
export interface $ZodIssueBase {
|
6
|
+
readonly code?: string;
|
7
|
+
readonly input?: unknown;
|
8
|
+
readonly path: PropertyKey[];
|
9
|
+
readonly message: string;
|
10
|
+
}
|
11
|
+
export interface $ZodIssueInvalidType<Input = unknown> extends $ZodIssueBase {
|
12
|
+
readonly code: "invalid_type";
|
13
|
+
readonly expected: $ZodType["_zod"]["def"]["type"];
|
14
|
+
readonly input: Input;
|
15
|
+
}
|
16
|
+
export interface $ZodIssueTooBig<Input = unknown> extends $ZodIssueBase {
|
17
|
+
readonly code: "too_big";
|
18
|
+
readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});
|
19
|
+
readonly maximum: number | bigint;
|
20
|
+
readonly inclusive?: boolean;
|
21
|
+
readonly input: Input;
|
22
|
+
}
|
23
|
+
export interface $ZodIssueTooSmall<Input = unknown> extends $ZodIssueBase {
|
24
|
+
readonly code: "too_small";
|
25
|
+
readonly origin: "number" | "int" | "bigint" | "date" | "string" | "array" | "set" | "file" | (string & {});
|
26
|
+
readonly minimum: number | bigint;
|
27
|
+
readonly inclusive?: boolean;
|
28
|
+
readonly input: Input;
|
29
|
+
}
|
30
|
+
export interface $ZodIssueInvalidStringFormat extends $ZodIssueBase {
|
31
|
+
readonly code: "invalid_format";
|
32
|
+
readonly format: $ZodStringFormats | (string & {});
|
33
|
+
readonly pattern?: string;
|
34
|
+
readonly input: string;
|
35
|
+
}
|
36
|
+
export interface $ZodIssueNotMultipleOf<Input extends number | bigint = number | bigint> extends $ZodIssueBase {
|
37
|
+
readonly code: "not_multiple_of";
|
38
|
+
readonly divisor: number;
|
39
|
+
readonly input: Input;
|
40
|
+
}
|
41
|
+
export interface $ZodIssueUnrecognizedKeys extends $ZodIssueBase {
|
42
|
+
readonly code: "unrecognized_keys";
|
43
|
+
readonly keys: string[];
|
44
|
+
readonly input: Record<string, unknown>;
|
45
|
+
}
|
46
|
+
export interface $ZodIssueInvalidUnion extends $ZodIssueBase {
|
47
|
+
readonly code: "invalid_union";
|
48
|
+
readonly errors: $ZodIssue[][];
|
49
|
+
readonly input: unknown;
|
50
|
+
}
|
51
|
+
export interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
|
52
|
+
readonly code: "invalid_key";
|
53
|
+
readonly origin: "map" | "record";
|
54
|
+
readonly issues: $ZodIssue[];
|
55
|
+
readonly input: Input;
|
56
|
+
}
|
57
|
+
export interface $ZodIssueInvalidElement<Input = unknown> extends $ZodIssueBase {
|
58
|
+
readonly code: "invalid_element";
|
59
|
+
readonly origin: "map" | "set";
|
60
|
+
readonly key: unknown;
|
61
|
+
readonly issues: $ZodIssue[];
|
62
|
+
readonly input: Input;
|
63
|
+
}
|
64
|
+
export interface $ZodIssueInvalidValue<Input = unknown> extends $ZodIssueBase {
|
65
|
+
readonly code: "invalid_value";
|
66
|
+
readonly values: util.Primitive[];
|
67
|
+
readonly input: Input;
|
68
|
+
}
|
69
|
+
export interface $ZodIssueCustom extends $ZodIssueBase {
|
70
|
+
readonly code: "custom";
|
71
|
+
readonly params?: Record<string, any> | undefined;
|
72
|
+
readonly input: unknown;
|
73
|
+
}
|
74
|
+
export interface $ZodIssueStringCommonFormats extends $ZodIssueInvalidStringFormat {
|
75
|
+
format: Exclude<$ZodStringFormats, "regex" | "jwt" | "starts_with" | "ends_with" | "includes">;
|
76
|
+
}
|
77
|
+
export interface $ZodIssueStringInvalidRegex extends $ZodIssueInvalidStringFormat {
|
78
|
+
format: "regex";
|
79
|
+
pattern: string;
|
80
|
+
}
|
81
|
+
export interface $ZodIssueStringInvalidJWT extends $ZodIssueInvalidStringFormat {
|
82
|
+
format: "jwt";
|
83
|
+
algorithm?: string;
|
84
|
+
}
|
85
|
+
export interface $ZodIssueStringStartsWith extends $ZodIssueInvalidStringFormat {
|
86
|
+
format: "starts_with";
|
87
|
+
prefix: string;
|
88
|
+
}
|
89
|
+
export interface $ZodIssueStringEndsWith extends $ZodIssueInvalidStringFormat {
|
90
|
+
format: "ends_with";
|
91
|
+
suffix: string;
|
92
|
+
}
|
93
|
+
export interface $ZodIssueStringIncludes extends $ZodIssueInvalidStringFormat {
|
94
|
+
format: "includes";
|
95
|
+
includes: string;
|
96
|
+
}
|
97
|
+
export type $ZodStringFormatIssues = $ZodIssueStringCommonFormats | $ZodIssueStringInvalidRegex | $ZodIssueStringInvalidJWT | $ZodIssueStringStartsWith | $ZodIssueStringEndsWith | $ZodIssueStringIncludes;
|
98
|
+
export type $ZodIssue = $ZodIssueInvalidType | $ZodIssueTooBig | $ZodIssueTooSmall | $ZodIssueInvalidStringFormat | $ZodIssueNotMultipleOf | $ZodIssueUnrecognizedKeys | $ZodIssueInvalidUnion | $ZodIssueInvalidKey | $ZodIssueInvalidElement | $ZodIssueInvalidValue | $ZodIssueCustom;
|
99
|
+
export type $ZodIssueCode = $ZodIssue["code"];
|
100
|
+
export type $ZodRawIssue<T extends $ZodIssueBase = $ZodIssue> = T extends any ? RawIssue<T> : never;
|
101
|
+
type RawIssue<T extends $ZodIssueBase> = util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
102
|
+
/** The input data */
|
103
|
+
readonly input?: unknown;
|
104
|
+
/** The schema or check that originated this issue. */
|
105
|
+
readonly inst?: $ZodType | $ZodCheck;
|
106
|
+
/** @deprecated Internal use only. If `true`, Zod will continue executing validation despite this issue. */
|
107
|
+
readonly continue?: boolean | undefined;
|
108
|
+
} & Record<string, any>>;
|
109
|
+
export interface $ZodErrorMap<T extends $ZodIssueBase = $ZodIssue> {
|
110
|
+
(issue: $ZodRawIssue<T>): {
|
111
|
+
message: string;
|
112
|
+
} | string | undefined | null;
|
113
|
+
}
|
114
|
+
export interface $ZodError<T = unknown> extends Error {
|
115
|
+
type: T;
|
116
|
+
issues: $ZodIssue[];
|
117
|
+
_zod: {
|
118
|
+
output: T;
|
119
|
+
def: $ZodIssue[];
|
120
|
+
};
|
121
|
+
stack?: string;
|
122
|
+
name: string;
|
123
|
+
}
|
124
|
+
export declare const $ZodError: $constructor<$ZodError>;
|
125
|
+
interface $ZodRealError<T = any> extends $ZodError<T> {
|
126
|
+
}
|
127
|
+
export declare const $ZodRealError: $constructor<$ZodRealError>;
|
128
|
+
export type $ZodFlattenedError<T, U = string> = _FlattenedError<T, U>;
|
129
|
+
type _FlattenedError<T, U = string> = {
|
130
|
+
formErrors: U[];
|
131
|
+
fieldErrors: {
|
132
|
+
[P in keyof T]?: U[];
|
133
|
+
};
|
134
|
+
};
|
135
|
+
/** @deprecated Use `z.treeifyError()` instead. */
|
136
|
+
export declare function flattenError<T>(error: $ZodError<T>): _FlattenedError<T>;
|
137
|
+
export declare function flattenError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): _FlattenedError<T, U>;
|
138
|
+
type _ZodFormattedError<T, U = string> = T extends [any, ...any[]] ? {
|
139
|
+
[K in keyof T]?: $ZodFormattedError<T[K], U>;
|
140
|
+
} : T extends any[] ? {
|
141
|
+
[k: number]: $ZodFormattedError<T[number], U>;
|
142
|
+
} : T extends object ? util.Flatten<{
|
143
|
+
[K in keyof T]?: $ZodFormattedError<T[K], U>;
|
144
|
+
}> : any;
|
145
|
+
export type $ZodFormattedError<T, U = string> = {
|
146
|
+
_errors: U[];
|
147
|
+
} & util.Flatten<_ZodFormattedError<T, U>>;
|
148
|
+
export declare function formatError<T>(error: $ZodError<T>): $ZodFormattedError<T>;
|
149
|
+
export declare function formatError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodFormattedError<T, U>;
|
150
|
+
export type $ZodErrorTree<T, U = string> = T extends [any, ...any[]] ? {
|
151
|
+
errors: U[];
|
152
|
+
items?: {
|
153
|
+
[K in keyof T]?: $ZodErrorTree<T[K], U>;
|
154
|
+
};
|
155
|
+
} : T extends any[] ? {
|
156
|
+
errors: U[];
|
157
|
+
items?: Array<$ZodErrorTree<T[number], U>>;
|
158
|
+
} : T extends object ? {
|
159
|
+
errors: U[];
|
160
|
+
properties?: {
|
161
|
+
[K in keyof T]?: $ZodErrorTree<T[K], U>;
|
162
|
+
};
|
163
|
+
} : {
|
164
|
+
errors: U[];
|
165
|
+
};
|
166
|
+
export declare function treeifyError<T>(error: $ZodError<T>): $ZodErrorTree<T>;
|
167
|
+
export declare function treeifyError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodErrorTree<T, U>;
|
168
|
+
/** Format a ZodError as a human-readable string in the following form.
|
169
|
+
*
|
170
|
+
* From
|
171
|
+
*
|
172
|
+
* ```ts
|
173
|
+
* ZodError {
|
174
|
+
* issues: [
|
175
|
+
* {
|
176
|
+
* expected: 'string',
|
177
|
+
* code: 'invalid_type',
|
178
|
+
* path: [ 'username' ],
|
179
|
+
* message: 'Invalid input: expected string'
|
180
|
+
* },
|
181
|
+
* {
|
182
|
+
* expected: 'number',
|
183
|
+
* code: 'invalid_type',
|
184
|
+
* path: [ 'favoriteNumbers', 1 ],
|
185
|
+
* message: 'Invalid input: expected number'
|
186
|
+
* }
|
187
|
+
* ];
|
188
|
+
* }
|
189
|
+
* ```
|
190
|
+
*
|
191
|
+
* to
|
192
|
+
*
|
193
|
+
* ```
|
194
|
+
* username
|
195
|
+
* ✖ Expected number, received string at "username
|
196
|
+
* favoriteNumbers[0]
|
197
|
+
* ✖ Invalid input: expected number
|
198
|
+
* ```
|
199
|
+
*/
|
200
|
+
export declare function toDotPath(path: (string | number | symbol)[]): string;
|
201
|
+
interface BaseError {
|
202
|
+
issues: $ZodIssueBase[];
|
203
|
+
}
|
204
|
+
export declare function prettifyError(error: BaseError): string;
|
205
|
+
export {};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import * as schemas from "./schemas.js";
|
2
|
+
import { $ZodTuple } from "./schemas.js";
|
3
|
+
import type * as util from "./util.js";
|
4
|
+
export interface $ZodFunctionDef<In extends $ZodFunctionIn = $ZodFunctionIn, Out extends $ZodFunctionOut = $ZodFunctionOut> {
|
5
|
+
type: "function";
|
6
|
+
input: In;
|
7
|
+
output: Out;
|
8
|
+
}
|
9
|
+
export type $ZodFunctionArgs = schemas.$ZodType<unknown[], unknown[]>;
|
10
|
+
export type $ZodFunctionIn = $ZodFunctionArgs | null;
|
11
|
+
export type $ZodFunctionOut = schemas.$ZodType | null;
|
12
|
+
export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: null extends Args ? never[] : NonNullable<Args>["_zod"]["output"]) => null extends Returns ? unknown : NonNullable<Returns>["_zod"]["input"];
|
13
|
+
export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: null extends Args ? never[] : NonNullable<Args>["_zod"]["output"]) => null extends Returns ? unknown : util.MaybeAsync<NonNullable<Returns>["_zod"]["input"]>;
|
14
|
+
export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: null extends Args ? never[] : NonNullable<Args>["_zod"]["input"]) => null extends Returns ? unknown : NonNullable<Returns>["_zod"]["output"];
|
15
|
+
export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (...args: null extends Args ? never[] : NonNullable<Args>["_zod"]["input"]) => null extends Returns ? unknown : util.MaybeAsync<NonNullable<Returns>["_zod"]["output"]>;
|
16
|
+
export declare class $ZodFunction<Args extends $ZodFunctionIn = $ZodFunctionIn, Returns extends $ZodFunctionOut = $ZodFunctionOut> {
|
17
|
+
def: $ZodFunctionDef<Args, Returns>;
|
18
|
+
/** @deprecated */
|
19
|
+
_def: $ZodFunctionDef<Args, Returns>;
|
20
|
+
_input: $InferInnerFunctionType<Args, Returns>;
|
21
|
+
_output: $InferOuterFunctionType<Args, Returns>;
|
22
|
+
constructor(def: $ZodFunctionDef<Args, Returns>);
|
23
|
+
implement<F extends $InferInnerFunctionType<Args, Returns>>(func: F): F extends this["_output"] ? F : this["_output"];
|
24
|
+
implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(func: F): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns>;
|
25
|
+
input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = null>(args: Items, rest?: Rest): $ZodFunction<schemas.$ZodTuple<Items, Rest>, Returns>;
|
26
|
+
input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
|
27
|
+
output<NewReturns extends schemas.$ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns>;
|
28
|
+
}
|
29
|
+
export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends schemas.$ZodType> {
|
30
|
+
input?: I;
|
31
|
+
output?: O;
|
32
|
+
}
|
33
|
+
declare function _function(): $ZodFunction;
|
34
|
+
declare function _function<const In extends Array<schemas.$ZodType> = Array<schemas.$ZodType>>(params: {
|
35
|
+
input: In;
|
36
|
+
}): $ZodFunction<$ZodTuple<In, null>, null>;
|
37
|
+
declare function _function<const In extends $ZodFunctionIn = $ZodFunctionIn>(params: {
|
38
|
+
input: In;
|
39
|
+
}): $ZodFunction<In, null>;
|
40
|
+
declare function _function<const Out extends $ZodFunctionOut = $ZodFunctionOut>(params: {
|
41
|
+
output: Out;
|
42
|
+
}): $ZodFunction<null, Out>;
|
43
|
+
declare function _function<In extends $ZodFunctionIn = $ZodFunctionIn, Out extends schemas.$ZodType = schemas.$ZodType>(params?: {
|
44
|
+
input: In;
|
45
|
+
output: Out;
|
46
|
+
}): $ZodFunction<In, Out>;
|
47
|
+
export { _function as function };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export * from "./core.js";
|
2
|
+
export * from "./parse.js";
|
3
|
+
export * from "./errors.js";
|
4
|
+
export * from "./schemas.js";
|
5
|
+
export * from "./checks.js";
|
6
|
+
export * from "./versions.js";
|
7
|
+
export * as util from "./util.js";
|
8
|
+
export * as regexes from "./regexes.js";
|
9
|
+
export * as locales from "../locales/index.js";
|
10
|
+
export * from "./registries.js";
|
11
|
+
export * from "./doc.js";
|
12
|
+
export * from "./function.js";
|
13
|
+
export * from "./api.js";
|
14
|
+
export * from "./to-json-schema.js";
|
15
|
+
export * as JSONSchema from "./json-schema.js";
|
@@ -0,0 +1,100 @@
|
|
1
|
+
export type Schema = ObjectSchema | ArraySchema | StringSchema | NumberSchema | IntegerSchema | BooleanSchema | NullSchema;
|
2
|
+
export interface BaseSchema {
|
3
|
+
type?: string | undefined;
|
4
|
+
$id?: string | undefined;
|
5
|
+
id?: string | undefined;
|
6
|
+
$schema?: string | undefined;
|
7
|
+
$ref?: string | undefined;
|
8
|
+
$anchor?: string | undefined;
|
9
|
+
$defs?: {
|
10
|
+
[key: string]: BaseSchema;
|
11
|
+
} | undefined;
|
12
|
+
definitions?: {
|
13
|
+
[key: string]: BaseSchema;
|
14
|
+
} | undefined;
|
15
|
+
$comment?: string | undefined;
|
16
|
+
title?: string | undefined;
|
17
|
+
description?: string | undefined;
|
18
|
+
default?: unknown | undefined;
|
19
|
+
examples?: unknown[] | undefined;
|
20
|
+
readOnly?: boolean | undefined;
|
21
|
+
writeOnly?: boolean | undefined;
|
22
|
+
deprecated?: boolean | undefined;
|
23
|
+
allOf?: BaseSchema[] | undefined;
|
24
|
+
anyOf?: BaseSchema[] | undefined;
|
25
|
+
oneOf?: BaseSchema[] | undefined;
|
26
|
+
not?: BaseSchema | undefined;
|
27
|
+
if?: BaseSchema | undefined;
|
28
|
+
then?: BaseSchema | undefined;
|
29
|
+
else?: BaseSchema | undefined;
|
30
|
+
enum?: Array<string | number | boolean | null> | undefined;
|
31
|
+
const?: string | number | boolean | null | undefined;
|
32
|
+
[k: string]: unknown;
|
33
|
+
/** A special key used as an intermediate representation of extends-style relationships. Omitted as a $ref with additional properties. */
|
34
|
+
_prefault?: unknown | undefined;
|
35
|
+
}
|
36
|
+
export interface ObjectSchema extends BaseSchema {
|
37
|
+
type: "object";
|
38
|
+
properties?: {
|
39
|
+
[key: string]: BaseSchema;
|
40
|
+
} | undefined;
|
41
|
+
patternProperties?: {
|
42
|
+
[key: string]: BaseSchema;
|
43
|
+
} | undefined;
|
44
|
+
additionalProperties?: BaseSchema | boolean | undefined;
|
45
|
+
required?: string[] | undefined;
|
46
|
+
dependentRequired?: {
|
47
|
+
[key: string]: string[];
|
48
|
+
} | undefined;
|
49
|
+
propertyNames?: BaseSchema | undefined;
|
50
|
+
minProperties?: number | undefined;
|
51
|
+
maxProperties?: number | undefined;
|
52
|
+
unevaluatedProperties?: BaseSchema | boolean | undefined;
|
53
|
+
dependentSchemas?: {
|
54
|
+
[key: string]: BaseSchema;
|
55
|
+
} | undefined;
|
56
|
+
}
|
57
|
+
export interface ArraySchema extends BaseSchema {
|
58
|
+
type: "array";
|
59
|
+
items?: BaseSchema | BaseSchema[] | undefined;
|
60
|
+
prefixItems?: BaseSchema[] | undefined;
|
61
|
+
additionalItems?: BaseSchema | boolean;
|
62
|
+
contains?: BaseSchema | undefined;
|
63
|
+
minItems?: number | undefined;
|
64
|
+
maxItems?: number | undefined;
|
65
|
+
minContains?: number | undefined;
|
66
|
+
maxContains?: number | undefined;
|
67
|
+
uniqueItems?: boolean | undefined;
|
68
|
+
unevaluatedItems?: BaseSchema | boolean | undefined;
|
69
|
+
}
|
70
|
+
export interface StringSchema extends BaseSchema {
|
71
|
+
type: "string";
|
72
|
+
minLength?: number | undefined;
|
73
|
+
maxLength?: number | undefined;
|
74
|
+
pattern?: string | undefined;
|
75
|
+
format?: string | undefined;
|
76
|
+
contentEncoding?: string | undefined;
|
77
|
+
contentMediaType?: string | undefined;
|
78
|
+
}
|
79
|
+
export interface NumberSchema extends BaseSchema {
|
80
|
+
type: "number";
|
81
|
+
minimum?: number | undefined;
|
82
|
+
maximum?: number | undefined;
|
83
|
+
exclusiveMinimum?: number | undefined;
|
84
|
+
exclusiveMaximum?: number | undefined;
|
85
|
+
multipleOf?: number | undefined;
|
86
|
+
}
|
87
|
+
export interface IntegerSchema extends BaseSchema {
|
88
|
+
type: "integer";
|
89
|
+
minimum?: number | undefined;
|
90
|
+
maximum?: number | undefined;
|
91
|
+
exclusiveMinimum?: number | undefined;
|
92
|
+
exclusiveMaximum?: number | undefined;
|
93
|
+
multipleOf?: number | undefined;
|
94
|
+
}
|
95
|
+
export interface BooleanSchema extends BaseSchema {
|
96
|
+
type: "boolean";
|
97
|
+
}
|
98
|
+
export interface NullSchema extends BaseSchema {
|
99
|
+
type: "null";
|
100
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import * as core from "./core.js";
|
2
|
+
import * as errors from "./errors.js";
|
3
|
+
import type * as schemas from "./schemas.js";
|
4
|
+
import * as util from "./util.js";
|
5
|
+
export type $ZodErrorClass = {
|
6
|
+
new (issues: errors.$ZodIssue[]): errors.$ZodError;
|
7
|
+
};
|
8
|
+
export type $Parse = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>, _params?: {
|
9
|
+
callee?: util.AnyFunc;
|
10
|
+
Err?: $ZodErrorClass;
|
11
|
+
}) => core.output<T>;
|
12
|
+
export declare const _parse: (_Err: $ZodErrorClass) => $Parse;
|
13
|
+
export declare const parse: $Parse;
|
14
|
+
export type $ParseAsync = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>, _params?: {
|
15
|
+
callee?: util.AnyFunc;
|
16
|
+
Err?: $ZodErrorClass;
|
17
|
+
}) => Promise<core.output<T>>;
|
18
|
+
export declare const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync;
|
19
|
+
export declare const parseAsync: $ParseAsync;
|
20
|
+
export type $SafeParse = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => util.SafeParseResult<core.output<T>>;
|
21
|
+
export declare const _safeParse: (_Err: $ZodErrorClass) => $SafeParse;
|
22
|
+
export declare const safeParse: $SafeParse;
|
23
|
+
export type $SafeParseAsync = <T extends schemas.$ZodType>(schema: T, value: unknown, _ctx?: schemas.ParseContext<errors.$ZodIssue>) => Promise<util.SafeParseResult<core.output<T>>>;
|
24
|
+
export declare const _safeParseAsync: (_Err: $ZodErrorClass) => $SafeParseAsync;
|
25
|
+
export declare const safeParseAsync: $SafeParseAsync;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
export declare const cuid: RegExp;
|
2
|
+
export declare const cuid2: RegExp;
|
3
|
+
export declare const ulid: RegExp;
|
4
|
+
export declare const xid: RegExp;
|
5
|
+
export declare const ksuid: RegExp;
|
6
|
+
export declare const nanoid: RegExp;
|
7
|
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
8
|
+
export declare const duration: RegExp;
|
9
|
+
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
|
10
|
+
export declare const extendedDuration: RegExp;
|
11
|
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
12
|
+
export declare const guid: RegExp;
|
13
|
+
/** Returns a regex for validating an RFC 4122 UUID.
|
14
|
+
*
|
15
|
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
16
|
+
export declare const uuid: (version?: number | undefined) => RegExp;
|
17
|
+
export declare const uuid4: RegExp;
|
18
|
+
export declare const uuid6: RegExp;
|
19
|
+
export declare const uuid7: RegExp;
|
20
|
+
/** Practical email validation */
|
21
|
+
export declare const email: RegExp;
|
22
|
+
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
|
23
|
+
export declare const html5Email: RegExp;
|
24
|
+
/** The classic emailregex.com regex for RFC 5322-compliant emails */
|
25
|
+
export declare const rfc5322Email: RegExp;
|
26
|
+
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
|
27
|
+
export declare const unicodeEmail: RegExp;
|
28
|
+
export declare const browserEmail: RegExp;
|
29
|
+
export declare const _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
30
|
+
export declare function emoji(): RegExp;
|
31
|
+
export declare const ipv4: RegExp;
|
32
|
+
export declare const ipv6: RegExp;
|
33
|
+
export declare const cidrv4: RegExp;
|
34
|
+
export declare const cidrv6: RegExp;
|
35
|
+
export declare const ip: RegExp;
|
36
|
+
export declare const base64: RegExp;
|
37
|
+
export declare const base64url: RegExp;
|
38
|
+
export declare const hostname: RegExp;
|
39
|
+
export declare const e164: RegExp;
|
40
|
+
export declare const date: RegExp;
|
41
|
+
export declare function time(args: {
|
42
|
+
precision?: number | null;
|
43
|
+
}): RegExp;
|
44
|
+
export declare function datetime(args: {
|
45
|
+
precision?: number | null;
|
46
|
+
offset?: boolean;
|
47
|
+
local?: boolean;
|
48
|
+
}): RegExp;
|
49
|
+
export declare const string: (params?: {
|
50
|
+
minimum?: number | undefined;
|
51
|
+
maximum?: number | undefined;
|
52
|
+
}) => RegExp;
|
53
|
+
export declare const bigint: RegExp;
|
54
|
+
export declare const integer: RegExp;
|
55
|
+
export declare const number: RegExp;
|
56
|
+
export declare const boolean: RegExp;
|
57
|
+
declare const _null: RegExp;
|
58
|
+
export { _null as null };
|
59
|
+
declare const _undefined: RegExp;
|
60
|
+
export { _undefined as undefined };
|
61
|
+
export declare const lowercase: RegExp;
|
62
|
+
export declare const uppercase: RegExp;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import type * as core from "./core.js";
|
2
|
+
import type { $ZodType } from "./schemas.js";
|
3
|
+
export declare const $output: unique symbol;
|
4
|
+
export type $output = typeof $output;
|
5
|
+
export declare const $input: unique symbol;
|
6
|
+
export type $input = typeof $input;
|
7
|
+
export type $replace<Meta, S extends $ZodType> = Meta extends $output ? core.output<S> : Meta extends $input ? core.input<S> : Meta extends (infer M)[] ? $replace<M, S>[] : Meta extends object ? {
|
8
|
+
[K in keyof Meta]: $replace<Meta[K], S>;
|
9
|
+
} : Meta;
|
10
|
+
type MetadataType = Record<string, unknown> | undefined;
|
11
|
+
export declare class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema extends $ZodType = $ZodType> {
|
12
|
+
_meta: Meta;
|
13
|
+
_schema: Schema;
|
14
|
+
_map: WeakMap<Schema, $replace<Meta, Schema>>;
|
15
|
+
_idmap: Map<string, Schema>;
|
16
|
+
add<S extends Schema>(schema: S, ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]): this;
|
17
|
+
remove(schema: Schema): this;
|
18
|
+
get<S extends Schema>(schema: S): $replace<Meta, S> | undefined;
|
19
|
+
has(schema: Schema): boolean;
|
20
|
+
}
|
21
|
+
export interface JSONSchemaMeta {
|
22
|
+
id?: string | undefined;
|
23
|
+
title?: string | undefined;
|
24
|
+
description?: string | undefined;
|
25
|
+
examples?: $output[] | undefined;
|
26
|
+
[k: string]: unknown;
|
27
|
+
}
|
28
|
+
export interface GlobalMeta extends JSONSchemaMeta {
|
29
|
+
}
|
30
|
+
export declare function registry<T extends MetadataType = MetadataType, S extends $ZodType = $ZodType>(): $ZodRegistry<T, S>;
|
31
|
+
export declare const globalRegistry: $ZodRegistry<GlobalMeta>;
|
32
|
+
export {};
|