@rspack/core 1.3.7 → 1.3.9
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/browserslist/index.js +77 -57
- package/compiled/browserslist/package.json +1 -1
- package/compiled/graceful-fs/index.js +8 -8
- package/compiled/zod/index.d.ts +2 -1772
- package/compiled/zod/index.js +35 -35
- package/compiled/zod/lib/ZodError.d.ts +164 -0
- package/compiled/zod/lib/__tests__/Mocker.d.ts +17 -0
- package/compiled/zod/lib/benchmarks/datetime.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/discriminatedUnion.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/index.d.ts +1 -0
- package/compiled/zod/lib/benchmarks/ipv4.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/object.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/primitives.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/realworld.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/string.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/union.d.ts +5 -0
- package/compiled/zod/lib/errors.d.ts +5 -0
- package/compiled/zod/lib/external.d.ts +6 -0
- package/compiled/zod/lib/helpers/enumUtil.d.ts +8 -0
- package/compiled/zod/lib/helpers/errorUtil.d.ts +9 -0
- package/compiled/zod/lib/helpers/parseUtil.d.ts +78 -0
- package/compiled/zod/lib/helpers/partialUtil.d.ts +8 -0
- package/compiled/zod/lib/helpers/typeAliases.d.ts +2 -0
- package/compiled/zod/lib/helpers/util.d.ts +82 -0
- package/compiled/zod/lib/index.d.ts +4 -0
- package/compiled/zod/lib/locales/en.d.ts +3 -0
- package/compiled/zod/lib/standard-schema.d.ts +102 -0
- package/compiled/zod/lib/types.d.ts +1062 -0
- package/compiled/zod/package.json +1 -1
- package/dist/ChunkGroup.d.ts +10 -0
- package/dist/builtin-loader/swc/pluginImport.d.ts +1 -1
- package/dist/builtin-loader/swc/types.d.ts +632 -631
- package/dist/builtin-plugin/html-plugin/hooks.d.ts +3 -1
- package/dist/builtin-plugin/html-plugin/options.d.ts +7 -3
- package/dist/builtin-plugin/html-plugin/plugin.d.ts +0 -1
- package/dist/config/types.d.ts +11 -3
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/zod.d.ts +77 -77
- package/dist/exports.d.ts +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +644 -597
- package/dist/setupEnv.d.ts +1 -0
- package/dist/stats/statsFactoryUtils.d.ts +1 -0
- package/dist/swc.d.ts +5 -0
- package/package.json +11 -11
package/compiled/zod/index.js
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
/******/ "use strict";
|
3
3
|
/******/ var __webpack_modules__ = ({
|
4
4
|
|
5
|
-
/***/
|
5
|
+
/***/ 36:
|
6
6
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
7
7
|
|
8
8
|
|
9
9
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
10
10
|
exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
|
11
|
-
const util_1 = __nccwpck_require__(
|
11
|
+
const util_1 = __nccwpck_require__(919);
|
12
12
|
exports.ZodIssueCode = util_1.util.arrayToEnum([
|
13
13
|
"invalid_type",
|
14
14
|
"invalid_literal",
|
@@ -146,7 +146,7 @@ ZodError.create = (issues) => {
|
|
146
146
|
|
147
147
|
/***/ }),
|
148
148
|
|
149
|
-
/***/
|
149
|
+
/***/ 874:
|
150
150
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
151
151
|
|
152
152
|
|
@@ -155,7 +155,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
155
155
|
};
|
156
156
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
157
157
|
exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0;
|
158
|
-
const en_1 = __importDefault(__nccwpck_require__(
|
158
|
+
const en_1 = __importDefault(__nccwpck_require__(986));
|
159
159
|
exports.defaultErrorMap = en_1.default;
|
160
160
|
let overrideErrorMap = en_1.default;
|
161
161
|
function setErrorMap(map) {
|
@@ -170,7 +170,7 @@ exports.getErrorMap = getErrorMap;
|
|
170
170
|
|
171
171
|
/***/ }),
|
172
172
|
|
173
|
-
/***/
|
173
|
+
/***/ 286:
|
174
174
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
175
175
|
|
176
176
|
|
@@ -189,17 +189,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
189
189
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
190
190
|
};
|
191
191
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
192
|
-
__exportStar(__nccwpck_require__(
|
193
|
-
__exportStar(__nccwpck_require__(
|
194
|
-
__exportStar(__nccwpck_require__(
|
195
|
-
__exportStar(__nccwpck_require__(
|
196
|
-
__exportStar(__nccwpck_require__(
|
197
|
-
__exportStar(__nccwpck_require__(
|
192
|
+
__exportStar(__nccwpck_require__(874), exports);
|
193
|
+
__exportStar(__nccwpck_require__(148), exports);
|
194
|
+
__exportStar(__nccwpck_require__(163), exports);
|
195
|
+
__exportStar(__nccwpck_require__(919), exports);
|
196
|
+
__exportStar(__nccwpck_require__(796), exports);
|
197
|
+
__exportStar(__nccwpck_require__(36), exports);
|
198
198
|
|
199
199
|
|
200
200
|
/***/ }),
|
201
201
|
|
202
|
-
/***/
|
202
|
+
/***/ 121:
|
203
203
|
/***/ ((__unused_webpack_module, exports) => {
|
204
204
|
|
205
205
|
|
@@ -214,7 +214,7 @@ var errorUtil;
|
|
214
214
|
|
215
215
|
/***/ }),
|
216
216
|
|
217
|
-
/***/
|
217
|
+
/***/ 148:
|
218
218
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
219
219
|
|
220
220
|
|
@@ -223,8 +223,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
223
223
|
};
|
224
224
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
225
225
|
exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
|
226
|
-
const errors_1 = __nccwpck_require__(
|
227
|
-
const en_1 = __importDefault(__nccwpck_require__(
|
226
|
+
const errors_1 = __nccwpck_require__(874);
|
227
|
+
const en_1 = __importDefault(__nccwpck_require__(986));
|
228
228
|
const makeIssue = (params) => {
|
229
229
|
const { data, path, errorMaps, issueData } = params;
|
230
230
|
const fullPath = [...path, ...(issueData.path || [])];
|
@@ -346,7 +346,7 @@ exports.isAsync = isAsync;
|
|
346
346
|
|
347
347
|
/***/ }),
|
348
348
|
|
349
|
-
/***/
|
349
|
+
/***/ 163:
|
350
350
|
/***/ ((__unused_webpack_module, exports) => {
|
351
351
|
|
352
352
|
|
@@ -355,7 +355,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
355
355
|
|
356
356
|
/***/ }),
|
357
357
|
|
358
|
-
/***/
|
358
|
+
/***/ 919:
|
359
359
|
/***/ ((__unused_webpack_module, exports) => {
|
360
360
|
|
361
361
|
|
@@ -504,7 +504,7 @@ exports.getParsedType = getParsedType;
|
|
504
504
|
|
505
505
|
/***/ }),
|
506
506
|
|
507
|
-
/***/
|
507
|
+
/***/ 437:
|
508
508
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
509
509
|
|
510
510
|
|
@@ -536,21 +536,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
536
536
|
};
|
537
537
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
538
538
|
exports.z = void 0;
|
539
|
-
const z = __importStar(__nccwpck_require__(
|
539
|
+
const z = __importStar(__nccwpck_require__(286));
|
540
540
|
exports.z = z;
|
541
|
-
__exportStar(__nccwpck_require__(
|
541
|
+
__exportStar(__nccwpck_require__(286), exports);
|
542
542
|
exports["default"] = z;
|
543
543
|
|
544
544
|
|
545
545
|
/***/ }),
|
546
546
|
|
547
|
-
/***/
|
547
|
+
/***/ 986:
|
548
548
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
549
549
|
|
550
550
|
|
551
551
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
552
|
-
const util_1 = __nccwpck_require__(
|
553
|
-
const ZodError_1 = __nccwpck_require__(
|
552
|
+
const util_1 = __nccwpck_require__(919);
|
553
|
+
const ZodError_1 = __nccwpck_require__(36);
|
554
554
|
const errorMap = (issue, _ctx) => {
|
555
555
|
let message;
|
556
556
|
switch (issue.code) {
|
@@ -680,7 +680,7 @@ exports["default"] = errorMap;
|
|
680
680
|
|
681
681
|
/***/ }),
|
682
682
|
|
683
|
-
/***/
|
683
|
+
/***/ 796:
|
684
684
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
685
685
|
|
686
686
|
|
@@ -699,11 +699,11 @@ var _ZodEnum_cache, _ZodNativeEnum_cache;
|
|
699
699
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
700
700
|
exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.datetimeRegex = exports.ZodType = void 0;
|
701
701
|
exports.NEVER = exports["void"] = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports["null"] = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports["instanceof"] = exports["function"] = exports["enum"] = exports.effect = exports.discriminatedUnion = exports.date = void 0;
|
702
|
-
const errors_1 = __nccwpck_require__(
|
703
|
-
const errorUtil_1 = __nccwpck_require__(
|
704
|
-
const parseUtil_1 = __nccwpck_require__(
|
705
|
-
const util_1 = __nccwpck_require__(
|
706
|
-
const ZodError_1 = __nccwpck_require__(
|
702
|
+
const errors_1 = __nccwpck_require__(874);
|
703
|
+
const errorUtil_1 = __nccwpck_require__(121);
|
704
|
+
const parseUtil_1 = __nccwpck_require__(148);
|
705
|
+
const util_1 = __nccwpck_require__(919);
|
706
|
+
const ZodError_1 = __nccwpck_require__(36);
|
707
707
|
class ParseInputLazyPath {
|
708
708
|
constructor(parent, value, path, key) {
|
709
709
|
this._cachedPath = [];
|
@@ -1117,15 +1117,15 @@ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z
|
|
1117
1117
|
const dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
1118
1118
|
const dateRegex = new RegExp(`^${dateRegexSource}$`);
|
1119
1119
|
function timeRegexSource(args) {
|
1120
|
-
|
1121
|
-
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
1120
|
+
let secondsRegexSource = `[0-5]\\d`;
|
1122
1121
|
if (args.precision) {
|
1123
|
-
|
1122
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
1124
1123
|
}
|
1125
1124
|
else if (args.precision == null) {
|
1126
|
-
|
1125
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
1127
1126
|
}
|
1128
|
-
|
1127
|
+
const secondsQuantifier = args.precision ? "+" : "?"; // require seconds if precision is nonzero
|
1128
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
1129
1129
|
}
|
1130
1130
|
function timeRegex(args) {
|
1131
1131
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
@@ -4575,7 +4575,7 @@ exports.NEVER = parseUtil_1.INVALID;
|
|
4575
4575
|
/******/ // startup
|
4576
4576
|
/******/ // Load entry module and return exports
|
4577
4577
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
4578
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
4578
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(437);
|
4579
4579
|
/******/ module.exports = __webpack_exports__;
|
4580
4580
|
/******/
|
4581
4581
|
/******/ })()
|
@@ -0,0 +1,164 @@
|
|
1
|
+
import type { TypeOf, ZodType } from ".";
|
2
|
+
import { Primitive } from "./helpers/typeAliases";
|
3
|
+
import { util, ZodParsedType } from "./helpers/util";
|
4
|
+
type allKeys<T> = T extends any ? keyof T : never;
|
5
|
+
export type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
|
6
|
+
export type typeToFlattenedError<T, U = string> = {
|
7
|
+
formErrors: U[];
|
8
|
+
fieldErrors: {
|
9
|
+
[P in allKeys<T>]?: U[];
|
10
|
+
};
|
11
|
+
};
|
12
|
+
export declare const ZodIssueCode: {
|
13
|
+
invalid_type: "invalid_type";
|
14
|
+
invalid_literal: "invalid_literal";
|
15
|
+
custom: "custom";
|
16
|
+
invalid_union: "invalid_union";
|
17
|
+
invalid_union_discriminator: "invalid_union_discriminator";
|
18
|
+
invalid_enum_value: "invalid_enum_value";
|
19
|
+
unrecognized_keys: "unrecognized_keys";
|
20
|
+
invalid_arguments: "invalid_arguments";
|
21
|
+
invalid_return_type: "invalid_return_type";
|
22
|
+
invalid_date: "invalid_date";
|
23
|
+
invalid_string: "invalid_string";
|
24
|
+
too_small: "too_small";
|
25
|
+
too_big: "too_big";
|
26
|
+
invalid_intersection_types: "invalid_intersection_types";
|
27
|
+
not_multiple_of: "not_multiple_of";
|
28
|
+
not_finite: "not_finite";
|
29
|
+
};
|
30
|
+
export type ZodIssueCode = keyof typeof ZodIssueCode;
|
31
|
+
export type ZodIssueBase = {
|
32
|
+
path: (string | number)[];
|
33
|
+
message?: string;
|
34
|
+
};
|
35
|
+
export interface ZodInvalidTypeIssue extends ZodIssueBase {
|
36
|
+
code: typeof ZodIssueCode.invalid_type;
|
37
|
+
expected: ZodParsedType;
|
38
|
+
received: ZodParsedType;
|
39
|
+
}
|
40
|
+
export interface ZodInvalidLiteralIssue extends ZodIssueBase {
|
41
|
+
code: typeof ZodIssueCode.invalid_literal;
|
42
|
+
expected: unknown;
|
43
|
+
received: unknown;
|
44
|
+
}
|
45
|
+
export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
|
46
|
+
code: typeof ZodIssueCode.unrecognized_keys;
|
47
|
+
keys: string[];
|
48
|
+
}
|
49
|
+
export interface ZodInvalidUnionIssue extends ZodIssueBase {
|
50
|
+
code: typeof ZodIssueCode.invalid_union;
|
51
|
+
unionErrors: ZodError[];
|
52
|
+
}
|
53
|
+
export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
|
54
|
+
code: typeof ZodIssueCode.invalid_union_discriminator;
|
55
|
+
options: Primitive[];
|
56
|
+
}
|
57
|
+
export interface ZodInvalidEnumValueIssue extends ZodIssueBase {
|
58
|
+
received: string | number;
|
59
|
+
code: typeof ZodIssueCode.invalid_enum_value;
|
60
|
+
options: (string | number)[];
|
61
|
+
}
|
62
|
+
export interface ZodInvalidArgumentsIssue extends ZodIssueBase {
|
63
|
+
code: typeof ZodIssueCode.invalid_arguments;
|
64
|
+
argumentsError: ZodError;
|
65
|
+
}
|
66
|
+
export interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
|
67
|
+
code: typeof ZodIssueCode.invalid_return_type;
|
68
|
+
returnTypeError: ZodError;
|
69
|
+
}
|
70
|
+
export interface ZodInvalidDateIssue extends ZodIssueBase {
|
71
|
+
code: typeof ZodIssueCode.invalid_date;
|
72
|
+
}
|
73
|
+
export type StringValidation = "email" | "url" | "emoji" | "uuid" | "nanoid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "date" | "time" | "duration" | "ip" | "cidr" | "base64" | "jwt" | "base64url" | {
|
74
|
+
includes: string;
|
75
|
+
position?: number;
|
76
|
+
} | {
|
77
|
+
startsWith: string;
|
78
|
+
} | {
|
79
|
+
endsWith: string;
|
80
|
+
};
|
81
|
+
export interface ZodInvalidStringIssue extends ZodIssueBase {
|
82
|
+
code: typeof ZodIssueCode.invalid_string;
|
83
|
+
validation: StringValidation;
|
84
|
+
}
|
85
|
+
export interface ZodTooSmallIssue extends ZodIssueBase {
|
86
|
+
code: typeof ZodIssueCode.too_small;
|
87
|
+
minimum: number | bigint;
|
88
|
+
inclusive: boolean;
|
89
|
+
exact?: boolean;
|
90
|
+
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
91
|
+
}
|
92
|
+
export interface ZodTooBigIssue extends ZodIssueBase {
|
93
|
+
code: typeof ZodIssueCode.too_big;
|
94
|
+
maximum: number | bigint;
|
95
|
+
inclusive: boolean;
|
96
|
+
exact?: boolean;
|
97
|
+
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
98
|
+
}
|
99
|
+
export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
|
100
|
+
code: typeof ZodIssueCode.invalid_intersection_types;
|
101
|
+
}
|
102
|
+
export interface ZodNotMultipleOfIssue extends ZodIssueBase {
|
103
|
+
code: typeof ZodIssueCode.not_multiple_of;
|
104
|
+
multipleOf: number | bigint;
|
105
|
+
}
|
106
|
+
export interface ZodNotFiniteIssue extends ZodIssueBase {
|
107
|
+
code: typeof ZodIssueCode.not_finite;
|
108
|
+
}
|
109
|
+
export interface ZodCustomIssue extends ZodIssueBase {
|
110
|
+
code: typeof ZodIssueCode.custom;
|
111
|
+
params?: {
|
112
|
+
[k: string]: any;
|
113
|
+
};
|
114
|
+
}
|
115
|
+
export type DenormalizedError = {
|
116
|
+
[k: string]: DenormalizedError | string[];
|
117
|
+
};
|
118
|
+
export type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue;
|
119
|
+
export type ZodIssue = ZodIssueOptionalMessage & {
|
120
|
+
fatal?: boolean;
|
121
|
+
message: string;
|
122
|
+
};
|
123
|
+
export declare const quotelessJson: (obj: any) => string;
|
124
|
+
type recursiveZodFormattedError<T> = T extends [any, ...any[]] ? {
|
125
|
+
[K in keyof T]?: ZodFormattedError<T[K]>;
|
126
|
+
} : T extends any[] ? {
|
127
|
+
[k: number]: ZodFormattedError<T[number]>;
|
128
|
+
} : T extends object ? {
|
129
|
+
[K in keyof T]?: ZodFormattedError<T[K]>;
|
130
|
+
} : unknown;
|
131
|
+
export type ZodFormattedError<T, U = string> = {
|
132
|
+
_errors: U[];
|
133
|
+
} & recursiveZodFormattedError<NonNullable<T>>;
|
134
|
+
export type inferFormattedError<T extends ZodType<any, any, any>, U = string> = ZodFormattedError<TypeOf<T>, U>;
|
135
|
+
export declare class ZodError<T = any> extends Error {
|
136
|
+
issues: ZodIssue[];
|
137
|
+
get errors(): ZodIssue[];
|
138
|
+
constructor(issues: ZodIssue[]);
|
139
|
+
format(): ZodFormattedError<T>;
|
140
|
+
format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
|
141
|
+
static create: (issues: ZodIssue[]) => ZodError<any>;
|
142
|
+
static assert(value: unknown): asserts value is ZodError;
|
143
|
+
toString(): string;
|
144
|
+
get message(): string;
|
145
|
+
get isEmpty(): boolean;
|
146
|
+
addIssue: (sub: ZodIssue) => void;
|
147
|
+
addIssues: (subs?: ZodIssue[]) => void;
|
148
|
+
flatten(): typeToFlattenedError<T>;
|
149
|
+
flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
|
150
|
+
get formErrors(): typeToFlattenedError<T, string>;
|
151
|
+
}
|
152
|
+
type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
|
153
|
+
export type IssueData = stripPath<ZodIssueOptionalMessage> & {
|
154
|
+
path?: (string | number)[];
|
155
|
+
fatal?: boolean;
|
156
|
+
};
|
157
|
+
export type ErrorMapCtx = {
|
158
|
+
defaultError: string;
|
159
|
+
data: any;
|
160
|
+
};
|
161
|
+
export type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
|
162
|
+
message: string;
|
163
|
+
};
|
164
|
+
export {};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export declare class Mocker {
|
2
|
+
pick: (...args: any[]) => any;
|
3
|
+
get string(): string;
|
4
|
+
get number(): number;
|
5
|
+
get bigint(): bigint;
|
6
|
+
get boolean(): boolean;
|
7
|
+
get date(): Date;
|
8
|
+
get symbol(): symbol;
|
9
|
+
get null(): null;
|
10
|
+
get undefined(): undefined;
|
11
|
+
get stringOptional(): any;
|
12
|
+
get stringNullable(): any;
|
13
|
+
get numberOptional(): any;
|
14
|
+
get numberNullable(): any;
|
15
|
+
get booleanOptional(): any;
|
16
|
+
get booleanNullable(): any;
|
17
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare namespace enumUtil {
|
2
|
+
type UnionToIntersectionFn<T> = (T extends unknown ? (k: () => T) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
|
3
|
+
type GetUnionLast<T> = UnionToIntersectionFn<T> extends () => infer Last ? Last : never;
|
4
|
+
type UnionToTuple<T, Tuple extends unknown[] = []> = [T] extends [never] ? Tuple : UnionToTuple<Exclude<T, GetUnionLast<T>>, [GetUnionLast<T>, ...Tuple]>;
|
5
|
+
type CastToStringTuple<T> = T extends [string, ...string[]] ? T : never;
|
6
|
+
export type UnionToTupleString<T> = CastToStringTuple<UnionToTuple<T>>;
|
7
|
+
export {};
|
8
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
|
2
|
+
import type { ZodParsedType } from "./util";
|
3
|
+
export declare const makeIssue: (params: {
|
4
|
+
data: any;
|
5
|
+
path: (string | number)[];
|
6
|
+
errorMaps: ZodErrorMap[];
|
7
|
+
issueData: IssueData;
|
8
|
+
}) => ZodIssue;
|
9
|
+
export type ParseParams = {
|
10
|
+
path: (string | number)[];
|
11
|
+
errorMap: ZodErrorMap;
|
12
|
+
async: boolean;
|
13
|
+
};
|
14
|
+
export type ParsePathComponent = string | number;
|
15
|
+
export type ParsePath = ParsePathComponent[];
|
16
|
+
export declare const EMPTY_PATH: ParsePath;
|
17
|
+
export interface ParseContext {
|
18
|
+
readonly common: {
|
19
|
+
readonly issues: ZodIssue[];
|
20
|
+
readonly contextualErrorMap?: ZodErrorMap;
|
21
|
+
readonly async: boolean;
|
22
|
+
};
|
23
|
+
readonly path: ParsePath;
|
24
|
+
readonly schemaErrorMap?: ZodErrorMap;
|
25
|
+
readonly parent: ParseContext | null;
|
26
|
+
readonly data: any;
|
27
|
+
readonly parsedType: ZodParsedType;
|
28
|
+
}
|
29
|
+
export type ParseInput = {
|
30
|
+
data: any;
|
31
|
+
path: (string | number)[];
|
32
|
+
parent: ParseContext;
|
33
|
+
};
|
34
|
+
export declare function addIssueToContext(ctx: ParseContext, issueData: IssueData): void;
|
35
|
+
export type ObjectPair = {
|
36
|
+
key: SyncParseReturnType<any>;
|
37
|
+
value: SyncParseReturnType<any>;
|
38
|
+
};
|
39
|
+
export declare class ParseStatus {
|
40
|
+
value: "aborted" | "dirty" | "valid";
|
41
|
+
dirty(): void;
|
42
|
+
abort(): void;
|
43
|
+
static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
|
44
|
+
static mergeObjectAsync(status: ParseStatus, pairs: {
|
45
|
+
key: ParseReturnType<any>;
|
46
|
+
value: ParseReturnType<any>;
|
47
|
+
}[]): Promise<SyncParseReturnType<any>>;
|
48
|
+
static mergeObjectSync(status: ParseStatus, pairs: {
|
49
|
+
key: SyncParseReturnType<any>;
|
50
|
+
value: SyncParseReturnType<any>;
|
51
|
+
alwaysSet?: boolean;
|
52
|
+
}[]): SyncParseReturnType;
|
53
|
+
}
|
54
|
+
export interface ParseResult {
|
55
|
+
status: "aborted" | "dirty" | "valid";
|
56
|
+
data: any;
|
57
|
+
}
|
58
|
+
export type INVALID = {
|
59
|
+
status: "aborted";
|
60
|
+
};
|
61
|
+
export declare const INVALID: INVALID;
|
62
|
+
export type DIRTY<T> = {
|
63
|
+
status: "dirty";
|
64
|
+
value: T;
|
65
|
+
};
|
66
|
+
export declare const DIRTY: <T>(value: T) => DIRTY<T>;
|
67
|
+
export type OK<T> = {
|
68
|
+
status: "valid";
|
69
|
+
value: T;
|
70
|
+
};
|
71
|
+
export declare const OK: <T>(value: T) => OK<T>;
|
72
|
+
export type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
|
73
|
+
export type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
|
74
|
+
export type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
|
75
|
+
export declare const isAborted: (x: ParseReturnType<any>) => x is INVALID;
|
76
|
+
export declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
|
77
|
+
export declare const isValid: <T>(x: ParseReturnType<T>) => x is OK<T>;
|
78
|
+
export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { ZodArray, ZodNullable, ZodObject, ZodOptional, ZodRawShape, ZodTuple, ZodTupleItems, ZodTypeAny } from "../index";
|
2
|
+
export declare namespace partialUtil {
|
3
|
+
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
|
4
|
+
[k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
|
5
|
+
}, T["_def"]["unknownKeys"], T["_def"]["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> ? {
|
6
|
+
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
|
7
|
+
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
|
8
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
export declare namespace util {
|
2
|
+
type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
3
|
+
export type isAny<T> = 0 extends 1 & T ? true : false;
|
4
|
+
export const assertEqual: <A, B>(val: AssertEqual<A, B>) => AssertEqual<A, B>;
|
5
|
+
export function assertIs<T>(_arg: T): void;
|
6
|
+
export function assertNever(_x: never): never;
|
7
|
+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
8
|
+
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
9
|
+
export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
10
|
+
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
11
|
+
export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
|
12
|
+
export const getValidEnumValues: (obj: any) => any[];
|
13
|
+
export const objectValues: (obj: any) => any[];
|
14
|
+
export const objectKeys: ObjectConstructor["keys"];
|
15
|
+
export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
|
16
|
+
export type identity<T> = objectUtil.identity<T>;
|
17
|
+
export type flatten<T> = objectUtil.flatten<T>;
|
18
|
+
export type noUndefined<T> = T extends undefined ? never : T;
|
19
|
+
export const isInteger: NumberConstructor["isInteger"];
|
20
|
+
export function joinValues<T extends any[]>(array: T, separator?: string): string;
|
21
|
+
export const jsonStringifyReplacer: (_: string, value: any) => any;
|
22
|
+
export {};
|
23
|
+
}
|
24
|
+
export declare namespace objectUtil {
|
25
|
+
export type MergeShapes<U, V> = keyof U & keyof V extends never ? U & V : {
|
26
|
+
[k in Exclude<keyof U, keyof V>]: U[k];
|
27
|
+
} & V;
|
28
|
+
type optionalKeys<T extends object> = {
|
29
|
+
[k in keyof T]: undefined extends T[k] ? k : never;
|
30
|
+
}[keyof T];
|
31
|
+
type requiredKeys<T extends object> = {
|
32
|
+
[k in keyof T]: undefined extends T[k] ? never : k;
|
33
|
+
}[keyof T];
|
34
|
+
export type addQuestionMarks<T extends object, _O = any> = {
|
35
|
+
[K in requiredKeys<T>]: T[K];
|
36
|
+
} & {
|
37
|
+
[K in optionalKeys<T>]?: T[K];
|
38
|
+
} & {
|
39
|
+
[k in keyof T]?: unknown;
|
40
|
+
};
|
41
|
+
export type identity<T> = T;
|
42
|
+
export type flatten<T> = identity<{
|
43
|
+
[k in keyof T]: T[k];
|
44
|
+
}>;
|
45
|
+
export type noNeverKeys<T> = {
|
46
|
+
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
47
|
+
}[keyof T];
|
48
|
+
export type noNever<T> = identity<{
|
49
|
+
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
50
|
+
}>;
|
51
|
+
export const mergeShapes: <U, T>(first: U, second: T) => T & U;
|
52
|
+
export type extendShape<A extends object, B extends object> = keyof A & keyof B extends never ? A & B : {
|
53
|
+
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
54
|
+
} & {
|
55
|
+
[K in keyof B]: B[K];
|
56
|
+
};
|
57
|
+
export {};
|
58
|
+
}
|
59
|
+
export declare const ZodParsedType: {
|
60
|
+
string: "string";
|
61
|
+
number: "number";
|
62
|
+
bigint: "bigint";
|
63
|
+
boolean: "boolean";
|
64
|
+
symbol: "symbol";
|
65
|
+
undefined: "undefined";
|
66
|
+
object: "object";
|
67
|
+
function: "function";
|
68
|
+
map: "map";
|
69
|
+
nan: "nan";
|
70
|
+
integer: "integer";
|
71
|
+
float: "float";
|
72
|
+
date: "date";
|
73
|
+
null: "null";
|
74
|
+
array: "array";
|
75
|
+
unknown: "unknown";
|
76
|
+
promise: "promise";
|
77
|
+
void: "void";
|
78
|
+
never: "never";
|
79
|
+
set: "set";
|
80
|
+
};
|
81
|
+
export type ZodParsedType = keyof typeof ZodParsedType;
|
82
|
+
export declare const getParsedType: (data: any) => ZodParsedType;
|