unocab 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -4
- package/{script → dist}/errors.d.ts +13 -3
- package/dist/game.d.ts +459 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +786 -0
- package/dist/types.d.ts +1106 -0
- package/{esm → dist}/utils.d.ts +4 -3
- package/package.json +17 -11
- package/esm/_dnt.shims.d.ts +0 -4
- package/esm/_dnt.shims.js +0 -62
- package/esm/_dnt.test_shims.d.ts +0 -7
- package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
- package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
- package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
- package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
- package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +0 -163
- package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.js +0 -148
- package/esm/deps/deno.land/x/zod@v3.21.4/errors.d.ts +0 -5
- package/esm/deps/deno.land/x/zod@v3.21.4/errors.js +0 -9
- package/esm/deps/deno.land/x/zod@v3.21.4/external.d.ts +0 -6
- package/esm/deps/deno.land/x/zod@v3.21.4/external.js +0 -6
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +0 -8
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +0 -9
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +0 -5
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +0 -78
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +0 -104
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +0 -8
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +0 -2
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +0 -68
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.js +0 -138
- package/esm/deps/deno.land/x/zod@v3.21.4/index.d.ts +0 -4
- package/esm/deps/deno.land/x/zod@v3.21.4/index.js +0 -4
- package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +0 -3
- package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.js +0 -127
- package/esm/deps/deno.land/x/zod@v3.21.4/mod.d.ts +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/mod.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/types.d.ts +0 -965
- package/esm/deps/deno.land/x/zod@v3.21.4/types.js +0 -3689
- package/esm/errors.d.ts +0 -72
- package/esm/errors.js +0 -39
- package/esm/game.d.ts +0 -868
- package/esm/game.js +0 -868
- package/esm/mod.d.ts +0 -3
- package/esm/mod.js +0 -3
- package/esm/package.json +0 -3
- package/esm/tests/basic-tests.d.ts +0 -8
- package/esm/tests/draw-tests.d.ts +0 -8
- package/esm/tests/non-specific-tests.test.d.ts +0 -1
- package/esm/tests/rule-violation-tests.d.ts +0 -8
- package/esm/tests/specific-tests.test.d.ts +0 -1
- package/esm/tests/test-utils.d.ts +0 -91
- package/esm/tests/turn-tests.d.ts +0 -8
- package/esm/types.d.ts +0 -2280
- package/esm/types.js +0 -152
- package/esm/utils.js +0 -44
- package/script/_dnt.shims.d.ts +0 -4
- package/script/_dnt.shims.js +0 -66
- package/script/_dnt.test_shims.d.ts +0 -7
- package/script/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
- package/script/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
- package/script/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
- package/script/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
- package/script/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +0 -163
- package/script/deps/deno.land/x/zod@v3.21.4/ZodError.js +0 -152
- package/script/deps/deno.land/x/zod@v3.21.4/errors.d.ts +0 -5
- package/script/deps/deno.land/x/zod@v3.21.4/errors.js +0 -17
- package/script/deps/deno.land/x/zod@v3.21.4/external.d.ts +0 -6
- package/script/deps/deno.land/x/zod@v3.21.4/external.js +0 -22
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +0 -8
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +0 -9
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +0 -8
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +0 -78
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +0 -119
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +0 -8
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +0 -68
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.js +0 -142
- package/script/deps/deno.land/x/zod@v3.21.4/index.d.ts +0 -4
- package/script/deps/deno.land/x/zod@v3.21.4/index.js +0 -33
- package/script/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +0 -3
- package/script/deps/deno.land/x/zod@v3.21.4/locales/en.js +0 -129
- package/script/deps/deno.land/x/zod@v3.21.4/mod.d.ts +0 -1
- package/script/deps/deno.land/x/zod@v3.21.4/mod.js +0 -17
- package/script/deps/deno.land/x/zod@v3.21.4/types.d.ts +0 -965
- package/script/deps/deno.land/x/zod@v3.21.4/types.js +0 -3739
- package/script/errors.js +0 -43
- package/script/game.d.ts +0 -868
- package/script/game.js +0 -895
- package/script/mod.d.ts +0 -3
- package/script/mod.js +0 -19
- package/script/package.json +0 -3
- package/script/tests/basic-tests.d.ts +0 -8
- package/script/tests/draw-tests.d.ts +0 -8
- package/script/tests/non-specific-tests.test.d.ts +0 -1
- package/script/tests/rule-violation-tests.d.ts +0 -8
- package/script/tests/specific-tests.test.d.ts +0 -1
- package/script/tests/test-utils.d.ts +0 -91
- package/script/tests/turn-tests.d.ts +0 -8
- package/script/types.d.ts +0 -2280
- package/script/types.js +0 -155
- package/script/utils.d.ts +0 -19
- package/script/utils.js +0 -50
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
export declare class AssertionError extends Error {
|
|
2
|
-
name: string;
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Deep equality comparison used in assertions
|
|
7
|
-
* @param c actual value
|
|
8
|
-
* @param d expected value
|
|
9
|
-
*/
|
|
10
|
-
export declare function equal(c: unknown, d: unknown): boolean;
|
|
11
|
-
/** Make an assertion, error will be thrown if `expr` does not have truthy value. */
|
|
12
|
-
export declare function assert(expr: unknown, msg?: string): asserts expr;
|
|
13
|
-
/** Make an assertion, error will be thrown if `expr` have truthy value. */
|
|
14
|
-
type Falsy = false | 0 | 0n | "" | null | undefined;
|
|
15
|
-
export declare function assertFalse(expr: unknown, msg?: string): asserts expr is Falsy;
|
|
16
|
-
/**
|
|
17
|
-
* Make an assertion that `actual` and `expected` are equal, deeply. If not
|
|
18
|
-
* deeply equal, then throw.
|
|
19
|
-
*
|
|
20
|
-
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { assertEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
25
|
-
*
|
|
26
|
-
* Deno.test("example", function (): void {
|
|
27
|
-
* assertEquals("world", "world");
|
|
28
|
-
* assertEquals({ hello: "world" }, { hello: "world" });
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function assertEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
33
|
-
/**
|
|
34
|
-
* Make an assertion that `actual` and `expected` are not equal, deeply.
|
|
35
|
-
* If not then throw.
|
|
36
|
-
*
|
|
37
|
-
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { assertNotEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
42
|
-
*
|
|
43
|
-
* assertNotEquals<number>(1, 2)
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export declare function assertNotEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
47
|
-
/**
|
|
48
|
-
* Make an assertion that `actual` and `expected` are strictly equal. If
|
|
49
|
-
* not then throw.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* import { assertStrictEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
54
|
-
*
|
|
55
|
-
* Deno.test("isStrictlyEqual", function (): void {
|
|
56
|
-
* const a = {};
|
|
57
|
-
* const b = a;
|
|
58
|
-
* assertStrictEquals(a, b);
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* // This test fails
|
|
62
|
-
* Deno.test("isNotStrictlyEqual", function (): void {
|
|
63
|
-
* const a = {};
|
|
64
|
-
* const b = {};
|
|
65
|
-
* assertStrictEquals(a, b);
|
|
66
|
-
* });
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export declare function assertStrictEquals<T>(actual: unknown, expected: T, msg?: string): asserts actual is T;
|
|
70
|
-
/**
|
|
71
|
-
* Make an assertion that `actual` and `expected` are not strictly equal.
|
|
72
|
-
* If the values are strictly equal then throw.
|
|
73
|
-
*
|
|
74
|
-
* ```ts
|
|
75
|
-
* import { assertNotStrictEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
76
|
-
*
|
|
77
|
-
* assertNotStrictEquals(1, 1)
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export declare function assertNotStrictEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* Make an assertion that `actual` and `expected` are almost equal numbers through
|
|
83
|
-
* a given tolerance. It can be used to take into account IEEE-754 double-precision
|
|
84
|
-
* floating-point representation limitations.
|
|
85
|
-
* If the values are not almost equal then throw.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```ts
|
|
89
|
-
* import { assertAlmostEquals, assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
90
|
-
*
|
|
91
|
-
* assertAlmostEquals(0.1, 0.2);
|
|
92
|
-
*
|
|
93
|
-
* // Using a custom tolerance value
|
|
94
|
-
* assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16);
|
|
95
|
-
* assertThrows(() => assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17));
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export declare function assertAlmostEquals(actual: number, expected: number, tolerance?: number, msg?: string): void;
|
|
99
|
-
type AnyConstructor = new (...args: any[]) => any;
|
|
100
|
-
type GetConstructorType<T extends AnyConstructor> = T extends new (...args: any) => infer C ? C : never;
|
|
101
|
-
/**
|
|
102
|
-
* Make an assertion that `obj` is an instance of `type`.
|
|
103
|
-
* If not then throw.
|
|
104
|
-
*/
|
|
105
|
-
export declare function assertInstanceOf<T extends AnyConstructor>(actual: unknown, expectedType: T, msg?: string): asserts actual is GetConstructorType<T>;
|
|
106
|
-
/**
|
|
107
|
-
* Make an assertion that `obj` is not an instance of `type`.
|
|
108
|
-
* If so, then throw.
|
|
109
|
-
*/
|
|
110
|
-
export declare function assertNotInstanceOf<A, T>(actual: A, unexpectedType: new (...args: any[]) => T, msg?: string): asserts actual is Exclude<A, T>;
|
|
111
|
-
/**
|
|
112
|
-
* Make an assertion that actual is not null or undefined.
|
|
113
|
-
* If not then throw.
|
|
114
|
-
*/
|
|
115
|
-
export declare function assertExists<T>(actual: T, msg?: string): asserts actual is NonNullable<T>;
|
|
116
|
-
/**
|
|
117
|
-
* Make an assertion that actual includes expected. If not
|
|
118
|
-
* then throw.
|
|
119
|
-
*/
|
|
120
|
-
export declare function assertStringIncludes(actual: string, expected: string, msg?: string): void;
|
|
121
|
-
/**
|
|
122
|
-
* Make an assertion that `actual` includes the `expected` values.
|
|
123
|
-
* If not then an error will be thrown.
|
|
124
|
-
*
|
|
125
|
-
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```ts
|
|
129
|
-
* import { assertArrayIncludes } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
130
|
-
*
|
|
131
|
-
* assertArrayIncludes<number>([1, 2], [2])
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
export declare function assertArrayIncludes<T>(actual: ArrayLike<T>, expected: ArrayLike<T>, msg?: string): void;
|
|
135
|
-
/**
|
|
136
|
-
* Make an assertion that `actual` match RegExp `expected`. If not
|
|
137
|
-
* then throw.
|
|
138
|
-
*/
|
|
139
|
-
export declare function assertMatch(actual: string, expected: RegExp, msg?: string): void;
|
|
140
|
-
/**
|
|
141
|
-
* Make an assertion that `actual` not match RegExp `expected`. If match
|
|
142
|
-
* then throw.
|
|
143
|
-
*/
|
|
144
|
-
export declare function assertNotMatch(actual: string, expected: RegExp, msg?: string): void;
|
|
145
|
-
/**
|
|
146
|
-
* Make an assertion that `actual` object is a subset of `expected` object, deeply.
|
|
147
|
-
* If not, then throw.
|
|
148
|
-
*/
|
|
149
|
-
export declare function assertObjectMatch(actual: Record<PropertyKey, any>, expected: Record<PropertyKey, unknown>, msg?: string): void;
|
|
150
|
-
/**
|
|
151
|
-
* Forcefully throws a failed assertion
|
|
152
|
-
*/
|
|
153
|
-
export declare function fail(msg?: string): never;
|
|
154
|
-
/**
|
|
155
|
-
* Make an assertion that `error` is an `Error`.
|
|
156
|
-
* If not then an error will be thrown.
|
|
157
|
-
* An error class and a string that should be included in the
|
|
158
|
-
* error message can also be asserted.
|
|
159
|
-
*/
|
|
160
|
-
export declare function assertIsError<E extends Error = Error>(error: unknown, ErrorClass?: new (...args: any[]) => E, msgIncludes?: string, msg?: string): asserts error is E;
|
|
161
|
-
/**
|
|
162
|
-
* Executes a function, expecting it to throw. If it does not, then it
|
|
163
|
-
* throws.
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* ```ts
|
|
167
|
-
* import { assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
168
|
-
*
|
|
169
|
-
* Deno.test("doesThrow", function (): void {
|
|
170
|
-
* assertThrows((): void => {
|
|
171
|
-
* throw new TypeError("hello world!");
|
|
172
|
-
* });
|
|
173
|
-
* });
|
|
174
|
-
*
|
|
175
|
-
* // This test will not pass.
|
|
176
|
-
* Deno.test("fails", function (): void {
|
|
177
|
-
* assertThrows((): void => {
|
|
178
|
-
* console.log("Hello world");
|
|
179
|
-
* });
|
|
180
|
-
* });
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
export declare function assertThrows(fn: () => unknown, msg?: string): unknown;
|
|
184
|
-
/**
|
|
185
|
-
* Executes a function, expecting it to throw. If it does not, then it
|
|
186
|
-
* throws. An error class and a string that should be included in the
|
|
187
|
-
* error message can also be asserted.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
*
|
|
191
|
-
* ```ts
|
|
192
|
-
* import { assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
193
|
-
*
|
|
194
|
-
* Deno.test("doesThrow", function (): void {
|
|
195
|
-
* assertThrows((): void => {
|
|
196
|
-
* throw new TypeError("hello world!");
|
|
197
|
-
* }, TypeError);
|
|
198
|
-
* assertThrows(
|
|
199
|
-
* (): void => {
|
|
200
|
-
* throw new TypeError("hello world!");
|
|
201
|
-
* },
|
|
202
|
-
* TypeError,
|
|
203
|
-
* "hello",
|
|
204
|
-
* );
|
|
205
|
-
* });
|
|
206
|
-
*
|
|
207
|
-
* // This test will not pass.
|
|
208
|
-
* Deno.test("fails", function (): void {
|
|
209
|
-
* assertThrows((): void => {
|
|
210
|
-
* console.log("Hello world");
|
|
211
|
-
* });
|
|
212
|
-
* });
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
export declare function assertThrows<E extends Error = Error>(fn: () => unknown, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): E;
|
|
216
|
-
/**
|
|
217
|
-
* Executes a function which returns a promise, expecting it to reject.
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* ```ts
|
|
221
|
-
* import { assertRejects } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
222
|
-
*
|
|
223
|
-
* Deno.test("doesThrow", async function () {
|
|
224
|
-
* await assertRejects(
|
|
225
|
-
* async () => {
|
|
226
|
-
* throw new TypeError("hello world!");
|
|
227
|
-
* },
|
|
228
|
-
* );
|
|
229
|
-
* await assertRejects(
|
|
230
|
-
* async () => {
|
|
231
|
-
* return Promise.reject(new Error());
|
|
232
|
-
* },
|
|
233
|
-
* );
|
|
234
|
-
* });
|
|
235
|
-
*
|
|
236
|
-
* // This test will not pass.
|
|
237
|
-
* Deno.test("fails", async function () {
|
|
238
|
-
* await assertRejects(
|
|
239
|
-
* async () => {
|
|
240
|
-
* console.log("Hello world");
|
|
241
|
-
* },
|
|
242
|
-
* );
|
|
243
|
-
* });
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
export declare function assertRejects(fn: () => PromiseLike<unknown>, msg?: string): Promise<unknown>;
|
|
247
|
-
/**
|
|
248
|
-
* Executes a function which returns a promise, expecting it to reject.
|
|
249
|
-
* If it does not, then it throws. An error class and a string that should be
|
|
250
|
-
* included in the error message can also be asserted.
|
|
251
|
-
*
|
|
252
|
-
* @example
|
|
253
|
-
* ```ts
|
|
254
|
-
* import { assertRejects } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
255
|
-
*
|
|
256
|
-
* Deno.test("doesThrow", async function () {
|
|
257
|
-
* await assertRejects(async () => {
|
|
258
|
-
* throw new TypeError("hello world!");
|
|
259
|
-
* }, TypeError);
|
|
260
|
-
* await assertRejects(
|
|
261
|
-
* async () => {
|
|
262
|
-
* throw new TypeError("hello world!");
|
|
263
|
-
* },
|
|
264
|
-
* TypeError,
|
|
265
|
-
* "hello",
|
|
266
|
-
* );
|
|
267
|
-
* });
|
|
268
|
-
*
|
|
269
|
-
* // This test will not pass.
|
|
270
|
-
* Deno.test("fails", async function () {
|
|
271
|
-
* await assertRejects(
|
|
272
|
-
* async () => {
|
|
273
|
-
* console.log("Hello world");
|
|
274
|
-
* },
|
|
275
|
-
* );
|
|
276
|
-
* });
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
export declare function assertRejects<E extends Error = Error>(fn: () => PromiseLike<unknown>, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): Promise<E>;
|
|
280
|
-
/** Use this to stub out methods that will throw when invoked. */
|
|
281
|
-
export declare function unimplemented(msg?: string): never;
|
|
282
|
-
/** Use this to assert unreachable code. */
|
|
283
|
-
export declare function unreachable(): never;
|
|
284
|
-
export {};
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import type { TypeOf, ZodType } from "./index.js";
|
|
2
|
-
import { Primitive } from "./helpers/typeAliases.js";
|
|
3
|
-
import { util, ZodParsedType } from "./helpers/util.js";
|
|
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" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | {
|
|
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
|
-
toString(): string;
|
|
143
|
-
get message(): string;
|
|
144
|
-
get isEmpty(): boolean;
|
|
145
|
-
addIssue: (sub: ZodIssue) => void;
|
|
146
|
-
addIssues: (subs?: ZodIssue[]) => void;
|
|
147
|
-
flatten(): typeToFlattenedError<T>;
|
|
148
|
-
flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
|
|
149
|
-
get formErrors(): typeToFlattenedError<T, string>;
|
|
150
|
-
}
|
|
151
|
-
type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
|
|
152
|
-
export type IssueData = stripPath<ZodIssueOptionalMessage> & {
|
|
153
|
-
path?: (string | number)[];
|
|
154
|
-
fatal?: boolean;
|
|
155
|
-
};
|
|
156
|
-
export type ErrorMapCtx = {
|
|
157
|
-
defaultError: string;
|
|
158
|
-
data: any;
|
|
159
|
-
};
|
|
160
|
-
export type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
|
|
161
|
-
message: string;
|
|
162
|
-
};
|
|
163
|
-
export {};
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { util } from "./helpers/util.js";
|
|
2
|
-
export const ZodIssueCode = util.arrayToEnum([
|
|
3
|
-
"invalid_type",
|
|
4
|
-
"invalid_literal",
|
|
5
|
-
"custom",
|
|
6
|
-
"invalid_union",
|
|
7
|
-
"invalid_union_discriminator",
|
|
8
|
-
"invalid_enum_value",
|
|
9
|
-
"unrecognized_keys",
|
|
10
|
-
"invalid_arguments",
|
|
11
|
-
"invalid_return_type",
|
|
12
|
-
"invalid_date",
|
|
13
|
-
"invalid_string",
|
|
14
|
-
"too_small",
|
|
15
|
-
"too_big",
|
|
16
|
-
"invalid_intersection_types",
|
|
17
|
-
"not_multiple_of",
|
|
18
|
-
"not_finite",
|
|
19
|
-
]);
|
|
20
|
-
export const quotelessJson = (obj) => {
|
|
21
|
-
const json = JSON.stringify(obj, null, 2);
|
|
22
|
-
return json.replace(/"([^"]+)":/g, "$1:");
|
|
23
|
-
};
|
|
24
|
-
class ZodError extends Error {
|
|
25
|
-
get errors() {
|
|
26
|
-
return this.issues;
|
|
27
|
-
}
|
|
28
|
-
constructor(issues) {
|
|
29
|
-
super();
|
|
30
|
-
Object.defineProperty(this, "issues", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: []
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(this, "addIssue", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: (sub) => {
|
|
41
|
-
this.issues = [...this.issues, sub];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(this, "addIssues", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: (subs = []) => {
|
|
49
|
-
this.issues = [...this.issues, ...subs];
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const actualProto = new.target.prototype;
|
|
53
|
-
if (Object.setPrototypeOf) {
|
|
54
|
-
// eslint-disable-next-line ban/ban
|
|
55
|
-
Object.setPrototypeOf(this, actualProto);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
this.__proto__ = actualProto;
|
|
59
|
-
}
|
|
60
|
-
this.name = "ZodError";
|
|
61
|
-
this.issues = issues;
|
|
62
|
-
}
|
|
63
|
-
format(_mapper) {
|
|
64
|
-
const mapper = _mapper ||
|
|
65
|
-
function (issue) {
|
|
66
|
-
return issue.message;
|
|
67
|
-
};
|
|
68
|
-
const fieldErrors = { _errors: [] };
|
|
69
|
-
const processError = (error) => {
|
|
70
|
-
for (const issue of error.issues) {
|
|
71
|
-
if (issue.code === "invalid_union") {
|
|
72
|
-
issue.unionErrors.map(processError);
|
|
73
|
-
}
|
|
74
|
-
else if (issue.code === "invalid_return_type") {
|
|
75
|
-
processError(issue.returnTypeError);
|
|
76
|
-
}
|
|
77
|
-
else if (issue.code === "invalid_arguments") {
|
|
78
|
-
processError(issue.argumentsError);
|
|
79
|
-
}
|
|
80
|
-
else if (issue.path.length === 0) {
|
|
81
|
-
fieldErrors._errors.push(mapper(issue));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
let curr = fieldErrors;
|
|
85
|
-
let i = 0;
|
|
86
|
-
while (i < issue.path.length) {
|
|
87
|
-
const el = issue.path[i];
|
|
88
|
-
const terminal = i === issue.path.length - 1;
|
|
89
|
-
if (!terminal) {
|
|
90
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
91
|
-
// if (typeof el === "string") {
|
|
92
|
-
// curr[el] = curr[el] || { _errors: [] };
|
|
93
|
-
// } else if (typeof el === "number") {
|
|
94
|
-
// const errorArray: any = [];
|
|
95
|
-
// errorArray._errors = [];
|
|
96
|
-
// curr[el] = curr[el] || errorArray;
|
|
97
|
-
// }
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
101
|
-
curr[el]._errors.push(mapper(issue));
|
|
102
|
-
}
|
|
103
|
-
curr = curr[el];
|
|
104
|
-
i++;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
processError(this);
|
|
110
|
-
return fieldErrors;
|
|
111
|
-
}
|
|
112
|
-
toString() {
|
|
113
|
-
return this.message;
|
|
114
|
-
}
|
|
115
|
-
get message() {
|
|
116
|
-
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
117
|
-
}
|
|
118
|
-
get isEmpty() {
|
|
119
|
-
return this.issues.length === 0;
|
|
120
|
-
}
|
|
121
|
-
flatten(mapper = (issue) => issue.message) {
|
|
122
|
-
const fieldErrors = {};
|
|
123
|
-
const formErrors = [];
|
|
124
|
-
for (const sub of this.issues) {
|
|
125
|
-
if (sub.path.length > 0) {
|
|
126
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
127
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
formErrors.push(mapper(sub));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return { formErrors, fieldErrors };
|
|
134
|
-
}
|
|
135
|
-
get formErrors() {
|
|
136
|
-
return this.flatten();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
Object.defineProperty(ZodError, "create", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
configurable: true,
|
|
142
|
-
writable: true,
|
|
143
|
-
value: (issues) => {
|
|
144
|
-
const error = new ZodError(issues);
|
|
145
|
-
return error;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
export { ZodError };
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export var errorUtil;
|
|
2
|
-
(function (errorUtil) {
|
|
3
|
-
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
4
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
5
|
-
})(errorUtil || (errorUtil = {}));
|