@devp0nt/error0 1.0.0-next.4 → 1.0.0-next.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +342 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +173 -415
- package/dist/esm/index.d.ts +173 -415
- package/dist/esm/index.js +268 -351
- package/dist/esm/index.js.map +1 -1
- package/package.json +45 -22
- package/src/index.test.ts +295 -478
- package/src/index.ts +566 -508
- package/dist/cjs/index.js +0 -435
- package/dist/cjs/index.js.map +0 -1
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,421 +1,179 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
httpStatus: number | undefined;
|
|
113
|
-
expected: boolean | undefined;
|
|
114
|
-
clientMessage: string | undefined;
|
|
115
|
-
anyMessage: string | undefined;
|
|
116
|
-
cause: unknown;
|
|
117
|
-
meta: Meta0.ValueType;
|
|
118
|
-
stack: string | undefined;
|
|
119
|
-
__I_AM_ERROR_0: true;
|
|
120
|
-
};
|
|
121
|
-
toResponse(data?: Record<string, unknown>): undici_types.Response;
|
|
122
|
-
name: string;
|
|
123
|
-
message: string;
|
|
124
|
-
stack?: string;
|
|
125
|
-
};
|
|
126
|
-
new (input: Error0Input): {
|
|
127
|
-
readonly __I_AM_ERROR_0: true;
|
|
128
|
-
readonly tag?: Error0GeneralProps["tag"];
|
|
129
|
-
readonly code?: Error0GeneralProps["code"];
|
|
130
|
-
readonly httpStatus?: Error0GeneralProps["httpStatus"];
|
|
131
|
-
readonly expected?: Error0GeneralProps["expected"];
|
|
132
|
-
readonly clientMessage?: Error0GeneralProps["clientMessage"];
|
|
133
|
-
readonly anyMessage?: Error0GeneralProps["anyMessage"];
|
|
134
|
-
readonly cause?: Error0GeneralProps["cause"];
|
|
135
|
-
readonly meta?: Meta0.Meta0OrValueTypeNullish;
|
|
136
|
-
readonly zodError?: Error0GeneralProps["zodError"];
|
|
137
|
-
readonly axiosError?: Error0GeneralProps["axiosError"];
|
|
138
|
-
readonly propsOriginal: Error0GeneralProps;
|
|
139
|
-
toJSON(): {
|
|
140
|
-
message: string;
|
|
141
|
-
tag: string | undefined;
|
|
142
|
-
code: string | undefined;
|
|
143
|
-
httpStatus: number | undefined;
|
|
144
|
-
expected: boolean | undefined;
|
|
145
|
-
clientMessage: string | undefined;
|
|
146
|
-
anyMessage: string | undefined;
|
|
147
|
-
cause: unknown;
|
|
148
|
-
meta: Meta0.ValueType;
|
|
149
|
-
stack: string | undefined;
|
|
150
|
-
__I_AM_ERROR_0: true;
|
|
151
|
-
};
|
|
152
|
-
toResponse(data?: Record<string, unknown>): undici_types.Response;
|
|
153
|
-
name: string;
|
|
154
|
-
message: string;
|
|
155
|
-
stack?: string;
|
|
156
|
-
};
|
|
157
|
-
new (message: string, input: Error0Input): {
|
|
158
|
-
readonly __I_AM_ERROR_0: true;
|
|
159
|
-
readonly tag?: Error0GeneralProps["tag"];
|
|
160
|
-
readonly code?: Error0GeneralProps["code"];
|
|
161
|
-
readonly httpStatus?: Error0GeneralProps["httpStatus"];
|
|
162
|
-
readonly expected?: Error0GeneralProps["expected"];
|
|
163
|
-
readonly clientMessage?: Error0GeneralProps["clientMessage"];
|
|
164
|
-
readonly anyMessage?: Error0GeneralProps["anyMessage"];
|
|
165
|
-
readonly cause?: Error0GeneralProps["cause"];
|
|
166
|
-
readonly meta?: Meta0.Meta0OrValueTypeNullish;
|
|
167
|
-
readonly zodError?: Error0GeneralProps["zodError"];
|
|
168
|
-
readonly axiosError?: Error0GeneralProps["axiosError"];
|
|
169
|
-
readonly propsOriginal: Error0GeneralProps;
|
|
170
|
-
toJSON(): {
|
|
171
|
-
message: string;
|
|
172
|
-
tag: string | undefined;
|
|
173
|
-
code: string | undefined;
|
|
174
|
-
httpStatus: number | undefined;
|
|
175
|
-
expected: boolean | undefined;
|
|
176
|
-
clientMessage: string | undefined;
|
|
177
|
-
anyMessage: string | undefined;
|
|
178
|
-
cause: unknown;
|
|
179
|
-
meta: Meta0.ValueType;
|
|
180
|
-
stack: string | undefined;
|
|
181
|
-
__I_AM_ERROR_0: true;
|
|
182
|
-
};
|
|
183
|
-
toResponse(data?: Record<string, unknown>): undici_types.Response;
|
|
184
|
-
name: string;
|
|
185
|
-
message: string;
|
|
186
|
-
stack?: string;
|
|
187
|
-
};
|
|
188
|
-
new (error: Error): {
|
|
189
|
-
readonly __I_AM_ERROR_0: true;
|
|
190
|
-
readonly tag?: Error0GeneralProps["tag"];
|
|
191
|
-
readonly code?: Error0GeneralProps["code"];
|
|
192
|
-
readonly httpStatus?: Error0GeneralProps["httpStatus"];
|
|
193
|
-
readonly expected?: Error0GeneralProps["expected"];
|
|
194
|
-
readonly clientMessage?: Error0GeneralProps["clientMessage"];
|
|
195
|
-
readonly anyMessage?: Error0GeneralProps["anyMessage"];
|
|
196
|
-
readonly cause?: Error0GeneralProps["cause"];
|
|
197
|
-
readonly meta?: Meta0.Meta0OrValueTypeNullish;
|
|
198
|
-
readonly zodError?: Error0GeneralProps["zodError"];
|
|
199
|
-
readonly axiosError?: Error0GeneralProps["axiosError"];
|
|
200
|
-
readonly propsOriginal: Error0GeneralProps;
|
|
201
|
-
toJSON(): {
|
|
202
|
-
message: string;
|
|
203
|
-
tag: string | undefined;
|
|
204
|
-
code: string | undefined;
|
|
205
|
-
httpStatus: number | undefined;
|
|
206
|
-
expected: boolean | undefined;
|
|
207
|
-
clientMessage: string | undefined;
|
|
208
|
-
anyMessage: string | undefined;
|
|
209
|
-
cause: unknown;
|
|
210
|
-
meta: Meta0.ValueType;
|
|
211
|
-
stack: string | undefined;
|
|
212
|
-
__I_AM_ERROR_0: true;
|
|
213
|
-
};
|
|
214
|
-
toResponse(data?: Record<string, unknown>): undici_types.Response;
|
|
215
|
-
name: string;
|
|
216
|
-
message: string;
|
|
217
|
-
stack?: string;
|
|
218
|
-
};
|
|
219
|
-
new (error: Error, input: Error0Input): {
|
|
220
|
-
readonly __I_AM_ERROR_0: true;
|
|
221
|
-
readonly tag?: Error0GeneralProps["tag"];
|
|
222
|
-
readonly code?: Error0GeneralProps["code"];
|
|
223
|
-
readonly httpStatus?: Error0GeneralProps["httpStatus"];
|
|
224
|
-
readonly expected?: Error0GeneralProps["expected"];
|
|
225
|
-
readonly clientMessage?: Error0GeneralProps["clientMessage"];
|
|
226
|
-
readonly anyMessage?: Error0GeneralProps["anyMessage"];
|
|
227
|
-
readonly cause?: Error0GeneralProps["cause"];
|
|
228
|
-
readonly meta?: Meta0.Meta0OrValueTypeNullish;
|
|
229
|
-
readonly zodError?: Error0GeneralProps["zodError"];
|
|
230
|
-
readonly axiosError?: Error0GeneralProps["axiosError"];
|
|
231
|
-
readonly propsOriginal: Error0GeneralProps;
|
|
232
|
-
toJSON(): {
|
|
233
|
-
message: string;
|
|
234
|
-
tag: string | undefined;
|
|
235
|
-
code: string | undefined;
|
|
236
|
-
httpStatus: number | undefined;
|
|
237
|
-
expected: boolean | undefined;
|
|
238
|
-
clientMessage: string | undefined;
|
|
239
|
-
anyMessage: string | undefined;
|
|
240
|
-
cause: unknown;
|
|
241
|
-
meta: Meta0.ValueType;
|
|
242
|
-
stack: string | undefined;
|
|
243
|
-
__I_AM_ERROR_0: true;
|
|
244
|
-
};
|
|
245
|
-
toResponse(data?: Record<string, unknown>): undici_types.Response;
|
|
246
|
-
name: string;
|
|
247
|
-
message: string;
|
|
248
|
-
stack?: string;
|
|
249
|
-
};
|
|
250
|
-
new (value: unknown): {
|
|
251
|
-
readonly __I_AM_ERROR_0: true;
|
|
252
|
-
readonly tag?: Error0GeneralProps["tag"];
|
|
253
|
-
readonly code?: Error0GeneralProps["code"];
|
|
254
|
-
readonly httpStatus?: Error0GeneralProps["httpStatus"];
|
|
255
|
-
readonly expected?: Error0GeneralProps["expected"];
|
|
256
|
-
readonly clientMessage?: Error0GeneralProps["clientMessage"];
|
|
257
|
-
readonly anyMessage?: Error0GeneralProps["anyMessage"];
|
|
258
|
-
readonly cause?: Error0GeneralProps["cause"];
|
|
259
|
-
readonly meta?: Meta0.Meta0OrValueTypeNullish;
|
|
260
|
-
readonly zodError?: Error0GeneralProps["zodError"];
|
|
261
|
-
readonly axiosError?: Error0GeneralProps["axiosError"];
|
|
262
|
-
readonly propsOriginal: Error0GeneralProps;
|
|
263
|
-
toJSON(): {
|
|
264
|
-
message: string;
|
|
265
|
-
tag: string | undefined;
|
|
266
|
-
code: string | undefined;
|
|
267
|
-
httpStatus: number | undefined;
|
|
268
|
-
expected: boolean | undefined;
|
|
269
|
-
clientMessage: string | undefined;
|
|
270
|
-
anyMessage: string | undefined;
|
|
271
|
-
cause: unknown;
|
|
272
|
-
meta: Meta0.ValueType;
|
|
273
|
-
stack: string | undefined;
|
|
274
|
-
__I_AM_ERROR_0: true;
|
|
275
|
-
};
|
|
276
|
-
toResponse(data?: Record<string, unknown>): undici_types.Response;
|
|
277
|
-
name: string;
|
|
278
|
-
message: string;
|
|
279
|
-
stack?: string;
|
|
280
|
-
};
|
|
281
|
-
new (value: unknown, input: Error0Input): {
|
|
282
|
-
readonly __I_AM_ERROR_0: true;
|
|
283
|
-
readonly tag?: Error0GeneralProps["tag"];
|
|
284
|
-
readonly code?: Error0GeneralProps["code"];
|
|
285
|
-
readonly httpStatus?: Error0GeneralProps["httpStatus"];
|
|
286
|
-
readonly expected?: Error0GeneralProps["expected"];
|
|
287
|
-
readonly clientMessage?: Error0GeneralProps["clientMessage"];
|
|
288
|
-
readonly anyMessage?: Error0GeneralProps["anyMessage"];
|
|
289
|
-
readonly cause?: Error0GeneralProps["cause"];
|
|
290
|
-
readonly meta?: Meta0.Meta0OrValueTypeNullish;
|
|
291
|
-
readonly zodError?: Error0GeneralProps["zodError"];
|
|
292
|
-
readonly axiosError?: Error0GeneralProps["axiosError"];
|
|
293
|
-
readonly propsOriginal: Error0GeneralProps;
|
|
294
|
-
toJSON(): {
|
|
295
|
-
message: string;
|
|
296
|
-
tag: string | undefined;
|
|
297
|
-
code: string | undefined;
|
|
298
|
-
httpStatus: number | undefined;
|
|
299
|
-
expected: boolean | undefined;
|
|
300
|
-
clientMessage: string | undefined;
|
|
301
|
-
anyMessage: string | undefined;
|
|
302
|
-
cause: unknown;
|
|
303
|
-
meta: Meta0.ValueType;
|
|
304
|
-
stack: string | undefined;
|
|
305
|
-
__I_AM_ERROR_0: true;
|
|
306
|
-
};
|
|
307
|
-
toResponse(data?: Record<string, unknown>): undici_types.Response;
|
|
308
|
-
name: string;
|
|
309
|
-
message: string;
|
|
310
|
-
stack?: string;
|
|
311
|
-
};
|
|
312
|
-
defaultMessage: string;
|
|
313
|
-
defaultCode: string | undefined;
|
|
314
|
-
defaultHttpStatus: number | undefined;
|
|
315
|
-
defaultExpected: boolean | undefined;
|
|
316
|
-
defaultClientMessage: string | undefined;
|
|
317
|
-
defaultMeta: Meta0;
|
|
318
|
-
defaultMaxLevel: number;
|
|
319
|
-
_safeParseInput(error0Input: Record<string, unknown>): Error0Input;
|
|
320
|
-
_getSelfGeneralProps({ error0Input, message, stack, }: {
|
|
321
|
-
error0Input: Error0Input;
|
|
322
|
-
message: string;
|
|
323
|
-
stack: Error0GeneralProps["stack"];
|
|
324
|
-
}): Error0GeneralProps;
|
|
325
|
-
_getSelfPropsFloated(causesProps: Error0GeneralProps[]): Error0GeneralProps;
|
|
326
|
-
_getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0GeneralProps>;
|
|
327
|
-
_getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0GeneralProps>;
|
|
328
|
-
_assignError0Props(error0Props: Error0GeneralProps, extraError0Props: Partial<Error0GeneralProps>): void;
|
|
329
|
-
_normalizeSelfExpected(error0Props: Error0GeneralProps, expectedProvided: Error0Input["expected"]): boolean | undefined;
|
|
330
|
-
_isExpected(causesProps: Error0GeneralProps[]): boolean;
|
|
331
|
-
_getPropsFromUnknown(error: unknown, defaults?: Error0Input): Error0GeneralProps;
|
|
332
|
-
_getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0GeneralProps[];
|
|
333
|
-
_getCausesPropsFromError0Props(error0Props: Error0GeneralProps, maxLevel: number): Error0GeneralProps[];
|
|
334
|
-
_getClosestPropValue<TPropKey extends keyof Error0GeneralProps>(causesProps: Error0GeneralProps[], propKey: TPropKey): NonNullable<Error0GeneralProps[TPropKey]> | undefined;
|
|
335
|
-
_getFilledPropValues<TPropKey extends keyof Error0Input>(causesProps: Error0GeneralProps[], propKey: TPropKey): NonNullable<Error0GeneralProps[TPropKey]>[];
|
|
336
|
-
_getMergedMetaValue(causesProps: Error0GeneralProps[]): Meta0.ValueType;
|
|
337
|
-
_removeConstructorStackPart(stack: Error0GeneralProps["stack"]): Error0GeneralProps["stack"];
|
|
338
|
-
_mergeStack(prevStack: Error0GeneralProps["stack"], nextStack: Error0GeneralProps["stack"]): Error0GeneralProps["stack"];
|
|
339
|
-
isError0(error: unknown): error is Error0;
|
|
340
|
-
isLikelyError0(error: unknown): error is Error0;
|
|
341
|
-
_toError0(error: unknown, inputOverride?: Error0Input): Error0;
|
|
342
|
-
from(error: unknown, inputOverride?: Error0Input): Error0;
|
|
343
|
-
extend(props: {
|
|
344
|
-
defaultMessage?: Error0GeneralProps["message"];
|
|
345
|
-
defaultCode?: Error0GeneralProps["code"];
|
|
346
|
-
defaultHttpStatus?: Error0GeneralProps["httpStatus"];
|
|
347
|
-
defaultExpected?: Error0GeneralProps["expected"];
|
|
348
|
-
defaultClientMessage?: Error0GeneralProps["clientMessage"];
|
|
349
|
-
defaultMeta?: Meta0.Meta0OrValueTypeNullish;
|
|
350
|
-
}): /*elided*/ any;
|
|
351
|
-
extendCollection<T extends Record<string, typeof Error0>>(classes: T, props: {
|
|
352
|
-
defaultMessage?: Error0GeneralProps["message"];
|
|
353
|
-
defaultCode?: Error0GeneralProps["code"];
|
|
354
|
-
defaultHttpStatus?: Error0GeneralProps["httpStatus"];
|
|
355
|
-
defaultExpected?: Error0GeneralProps["expected"];
|
|
356
|
-
defaultClientMessage?: Error0GeneralProps["clientMessage"];
|
|
357
|
-
defaultMeta?: Meta0.Meta0OrValueTypeNullish;
|
|
358
|
-
}): T;
|
|
359
|
-
toJSON(error: unknown, inputOverride?: Error0Input): {
|
|
360
|
-
message: string;
|
|
361
|
-
tag: string | undefined;
|
|
362
|
-
code: string | undefined;
|
|
363
|
-
httpStatus: number | undefined;
|
|
364
|
-
expected: boolean | undefined;
|
|
365
|
-
clientMessage: string | undefined;
|
|
366
|
-
anyMessage: string | undefined;
|
|
367
|
-
cause: unknown;
|
|
368
|
-
meta: Meta0.ValueType;
|
|
369
|
-
stack: string | undefined;
|
|
370
|
-
__I_AM_ERROR_0: true;
|
|
371
|
-
};
|
|
372
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
373
|
-
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
374
|
-
stackTraceLimit: number;
|
|
1
|
+
type ErrorExtensionPropOptions<TInputValue, TOutputValue, TError extends Error0 = Error0> = {
|
|
2
|
+
init: (input: TInputValue) => TOutputValue;
|
|
3
|
+
resolve: (options: {
|
|
4
|
+
value: TOutputValue | undefined;
|
|
5
|
+
flow: Array<TOutputValue | undefined>;
|
|
6
|
+
error: TError;
|
|
7
|
+
}) => TOutputValue | undefined;
|
|
8
|
+
serialize: (options: {
|
|
9
|
+
value: TOutputValue;
|
|
10
|
+
error: TError;
|
|
11
|
+
isPublic: boolean;
|
|
12
|
+
}) => unknown;
|
|
13
|
+
deserialize: (options: {
|
|
14
|
+
value: unknown;
|
|
15
|
+
serialized: Record<string, unknown>;
|
|
16
|
+
}) => TOutputValue | undefined;
|
|
17
|
+
};
|
|
18
|
+
type ErrorExtensionMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
|
|
19
|
+
type ErrorExtensionRefineResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
|
|
20
|
+
type ErrorExtensionRefineFn<TError extends Error0 = Error0, TOutputProps extends Record<string, unknown> = Record<never, never>> = ((error: TError) => void) | ((error: TError) => ErrorExtensionRefineResult<TOutputProps>);
|
|
21
|
+
type ErrorMethodRecord = {
|
|
22
|
+
args: unknown[];
|
|
23
|
+
output: unknown;
|
|
24
|
+
};
|
|
25
|
+
type ErrorExtensionProps = {
|
|
26
|
+
[key: string]: ErrorExtensionPropOptions<any, any>;
|
|
27
|
+
};
|
|
28
|
+
type ErrorExtensionMethods = {
|
|
29
|
+
[key: string]: ErrorExtensionMethodFn<any, any[]>;
|
|
30
|
+
};
|
|
31
|
+
type ErrorExtension<TProps extends ErrorExtensionProps = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> = {
|
|
32
|
+
props?: TProps;
|
|
33
|
+
methods?: TMethods;
|
|
34
|
+
refine?: Array<ErrorExtensionRefineFn<Error0, ExtensionOutputProps<TProps>>>;
|
|
35
|
+
};
|
|
36
|
+
type AddPropToExtensionProps<TProps extends ErrorExtensionProps, TKey extends string, TInputValue, TOutputValue> = TProps & Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>;
|
|
37
|
+
type AddMethodToExtensionMethods<TMethods extends ErrorExtensionMethods, TKey extends string, TArgs extends unknown[], TOutputValue> = TMethods & Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>;
|
|
38
|
+
type ExtensionOutputProps<TProps extends ErrorExtensionProps> = {
|
|
39
|
+
[TKey in keyof TProps]: TProps[TKey] extends ErrorExtensionPropOptions<any, infer TOutputValue> ? TOutputValue : never;
|
|
40
|
+
};
|
|
41
|
+
type ErrorExtensionsMap = {
|
|
42
|
+
props: Record<string, {
|
|
43
|
+
init: unknown;
|
|
44
|
+
resolve: unknown;
|
|
45
|
+
}>;
|
|
46
|
+
methods: Record<string, ErrorMethodRecord>;
|
|
47
|
+
};
|
|
48
|
+
type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
49
|
+
type ErrorInputBase = {
|
|
50
|
+
cause?: unknown;
|
|
51
|
+
};
|
|
52
|
+
type ErrorInput<TExtensionsMap extends ErrorExtensionsMap> = IsEmptyObject<TExtensionsMap['props']> extends true ? ErrorInputBase : ErrorInputBase & Partial<{
|
|
53
|
+
[TKey in keyof TExtensionsMap['props']]: TExtensionsMap['props'][TKey]['init'];
|
|
54
|
+
}>;
|
|
55
|
+
type ErrorOutputProps<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
56
|
+
[TKey in keyof TExtensionsMap['props']]?: TExtensionsMap['props'][TKey]['resolve'];
|
|
57
|
+
};
|
|
58
|
+
type ErrorOutputMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
59
|
+
[TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
|
|
60
|
+
args: infer TArgs extends unknown[];
|
|
61
|
+
output: infer TOutput;
|
|
62
|
+
} ? (...args: TArgs) => TOutput : never;
|
|
63
|
+
};
|
|
64
|
+
type ErrorOutput<TExtensionsMap extends ErrorExtensionsMap> = ErrorOutputProps<TExtensionsMap> & ErrorOutputMethods<TExtensionsMap>;
|
|
65
|
+
type ErrorStaticMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
66
|
+
[TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
|
|
67
|
+
args: infer TArgs extends unknown[];
|
|
68
|
+
output: infer TOutput;
|
|
69
|
+
} ? (error: unknown, ...args: TArgs) => TOutput : never;
|
|
70
|
+
};
|
|
71
|
+
type EmptyExtensionsMap = {
|
|
72
|
+
props: Record<never, {
|
|
73
|
+
init: never;
|
|
74
|
+
resolve: never;
|
|
75
|
+
}>;
|
|
76
|
+
methods: Record<never, ErrorMethodRecord>;
|
|
77
|
+
};
|
|
78
|
+
type ExtensionPropsMapOf<TExtension extends ErrorExtension> = {
|
|
79
|
+
[TKey in keyof NonNullable<TExtension['props']>]: NonNullable<TExtension['props']>[TKey] extends ErrorExtensionPropOptions<infer TInputValue, infer TOutputValue> ? {
|
|
80
|
+
init: TInputValue;
|
|
81
|
+
resolve: TOutputValue;
|
|
82
|
+
} : never;
|
|
83
|
+
};
|
|
84
|
+
type ExtensionMethodsMapOf<TExtension extends ErrorExtension> = {
|
|
85
|
+
[TKey in keyof NonNullable<TExtension['methods']>]: NonNullable<TExtension['methods']>[TKey] extends (error: Error0, ...args: infer TArgs extends unknown[]) => infer TOutput ? {
|
|
86
|
+
args: TArgs;
|
|
87
|
+
output: TOutput;
|
|
88
|
+
} : never;
|
|
89
|
+
};
|
|
90
|
+
type ErrorExtensionsMapOfExtension<TExtension extends ErrorExtension> = {
|
|
91
|
+
props: ExtensionPropsMapOf<TExtension>;
|
|
92
|
+
methods: ExtensionMethodsMapOf<TExtension>;
|
|
93
|
+
};
|
|
94
|
+
type ExtendErrorExtensionsMap<TMap extends ErrorExtensionsMap, TExtension extends ErrorExtension> = {
|
|
95
|
+
props: TMap['props'] & ErrorExtensionsMapOfExtension<TExtension>['props'];
|
|
96
|
+
methods: TMap['methods'] & ErrorExtensionsMapOfExtension<TExtension>['methods'];
|
|
97
|
+
};
|
|
98
|
+
type ExtendErrorExtensionsMapWithProp<TMap extends ErrorExtensionsMap, TKey extends string, TInputValue, TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>>>;
|
|
99
|
+
type ExtendErrorExtensionsMapWithMethod<TMap extends ErrorExtensionsMap, TKey extends string, TArgs extends unknown[], TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<never, never>, Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>>>;
|
|
100
|
+
type ExtensionsMapOf<TClass> = TClass extends {
|
|
101
|
+
__extensionsMap?: infer TExtensionsMap;
|
|
102
|
+
} ? TExtensionsMap extends ErrorExtensionsMap ? TExtensionsMap : EmptyExtensionsMap : EmptyExtensionsMap;
|
|
103
|
+
type ExtensionsMapFromParts<TProps extends ErrorExtensionProps, TMethods extends ErrorExtensionMethods> = ErrorExtensionsMapOfExtension<ErrorExtension<TProps, TMethods>>;
|
|
104
|
+
type ErrorInstanceOfMap<TMap extends ErrorExtensionsMap> = Error0 & ErrorOutput<TMap>;
|
|
105
|
+
type BuilderError0<TProps extends ErrorExtensionProps, TMethods extends ErrorExtensionMethods> = Error0 & ErrorOutput<ExtensionsMapFromParts<TProps, TMethods>>;
|
|
106
|
+
type ExtensionOfBuilder<TBuilder> = TBuilder extends ExtensionError0<infer TProps, infer TMethods> ? ErrorExtension<TProps, TMethods> : never;
|
|
107
|
+
declare class ExtensionError0<TProps extends ErrorExtensionProps = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> {
|
|
108
|
+
private readonly _extension;
|
|
109
|
+
readonly Infer: {
|
|
110
|
+
props: TProps;
|
|
111
|
+
methods: TMethods;
|
|
375
112
|
};
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
113
|
+
constructor(extension?: ErrorExtension<ErrorExtensionProps, ErrorExtensionMethods>);
|
|
114
|
+
prop<TKey extends string, TInputValue, TOutputValue>(key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>): ExtensionError0<AddPropToExtensionProps<TProps, TKey, TInputValue, TOutputValue>, TMethods>;
|
|
115
|
+
method<TKey extends string, TArgs extends unknown[], TOutputValue>(key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>): ExtensionError0<TProps, AddMethodToExtensionMethods<TMethods, TKey, TArgs, TOutputValue>>;
|
|
116
|
+
refine(value: ErrorExtensionRefineFn<BuilderError0<TProps, TMethods>, ExtensionOutputProps<TProps>>): ExtensionError0<TProps, TMethods>;
|
|
117
|
+
extend<TKey extends string, TInputValue, TOutputValue>(kind: 'prop', key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>): ExtensionError0<AddPropToExtensionProps<TProps, TKey, TInputValue, TOutputValue>, TMethods>;
|
|
118
|
+
extend<TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>): ExtensionError0<TProps, AddMethodToExtensionMethods<TMethods, TKey, TArgs, TOutputValue>>;
|
|
119
|
+
extend(kind: 'refine', value: ErrorExtensionRefineFn<BuilderError0<TProps, TMethods>, ExtensionOutputProps<TProps>>): ExtensionError0<TProps, TMethods>;
|
|
120
|
+
}
|
|
121
|
+
type ClassError0<TExtensionsMap extends ErrorExtensionsMap = EmptyExtensionsMap> = {
|
|
122
|
+
new (message: string, input?: ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
|
|
123
|
+
new (input: {
|
|
385
124
|
message: string;
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
125
|
+
} & ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
|
|
126
|
+
readonly __extensionsMap?: TExtensionsMap;
|
|
127
|
+
from: (error: unknown) => Error0 & ErrorOutput<TExtensionsMap>;
|
|
128
|
+
serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>;
|
|
129
|
+
prop: <TKey extends string, TInputValue, TOutputValue>(key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TExtensionsMap>>) => ClassError0<ExtendErrorExtensionsMapWithProp<TExtensionsMap, TKey, TInputValue, TOutputValue>>;
|
|
130
|
+
method: <TKey extends string, TArgs extends unknown[], TOutputValue>(key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>) => ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>;
|
|
131
|
+
refine: (value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>) => ClassError0<TExtensionsMap>;
|
|
132
|
+
extend: {
|
|
133
|
+
<TBuilder extends ExtensionError0>(extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<TExtensionsMap, ExtensionOfBuilder<TBuilder>>>;
|
|
134
|
+
<TKey extends string, TInputValue, TOutputValue>(kind: 'prop', key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TExtensionsMap>>): ClassError0<ExtendErrorExtensionsMapWithProp<TExtensionsMap, TKey, TInputValue, TOutputValue>>;
|
|
135
|
+
<TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>): ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>;
|
|
136
|
+
(kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>): ClassError0<TExtensionsMap>;
|
|
396
137
|
};
|
|
397
|
-
|
|
138
|
+
extension: () => ExtensionError0;
|
|
139
|
+
} & ErrorStaticMethods<TExtensionsMap>;
|
|
140
|
+
declare class Error0 extends Error {
|
|
141
|
+
static readonly __extensionsMap?: EmptyExtensionsMap;
|
|
142
|
+
protected static _extensions: ErrorExtension[];
|
|
143
|
+
private static readonly _emptyExtension;
|
|
144
|
+
private static _getResolvedExtension;
|
|
145
|
+
constructor(message: string, input?: ErrorInput<EmptyExtensionsMap>);
|
|
146
|
+
constructor(input: {
|
|
398
147
|
message: string;
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
148
|
+
} & ErrorInput<EmptyExtensionsMap>);
|
|
149
|
+
private static readonly isSelfProperty;
|
|
150
|
+
static own(error: object, key: string): unknown;
|
|
151
|
+
own(key: string): unknown;
|
|
152
|
+
static flow(error: object, key: string): unknown[];
|
|
153
|
+
flow(key: string): unknown[];
|
|
154
|
+
static causes(error: unknown, instancesOnly?: false): unknown[];
|
|
155
|
+
static causes<T extends typeof Error0>(this: T, error: unknown, instancesOnly: true): Array<InstanceType<T>>;
|
|
156
|
+
causes<T extends typeof Error0>(this: T, instancesOnly?: false): [InstanceType<T>, ...unknown[]];
|
|
157
|
+
causes<T extends typeof Error0>(this: T, instancesOnly: true): [InstanceType<T>, ...Array<InstanceType<T>>];
|
|
158
|
+
static is<T extends typeof Error0>(this: T, error: unknown): error is InstanceType<T>;
|
|
159
|
+
static isSerialized(error: unknown): error is Record<string, unknown>;
|
|
160
|
+
static from(error: unknown): Error0;
|
|
161
|
+
private static _applyRefine;
|
|
162
|
+
private static _fromSerialized;
|
|
163
|
+
private static _fromNonError0;
|
|
164
|
+
private static _extractMessage;
|
|
165
|
+
private static _extendWithExtension;
|
|
166
|
+
private static _extensionFromBuilder;
|
|
167
|
+
static prop<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(this: TThis, key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithProp<ExtensionsMapOf<TThis>, TKey, TInputValue, TOutputValue>>;
|
|
168
|
+
static method<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithMethod<ExtensionsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
|
|
169
|
+
static refine<TThis extends typeof Error0>(this: TThis, value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>): ClassError0<ExtensionsMapOf<TThis>>;
|
|
170
|
+
static extend<TThis extends typeof Error0, TBuilder extends ExtensionError0>(this: TThis, extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<ExtensionsMapOf<TThis>, ExtensionOfBuilder<TBuilder>>>;
|
|
171
|
+
static extend<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(this: TThis, kind: 'prop', key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithProp<ExtensionsMapOf<TThis>, TKey, TInputValue, TOutputValue>>;
|
|
172
|
+
static extend<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, kind: 'method', key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithMethod<ExtensionsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
|
|
173
|
+
static extend<TThis extends typeof Error0>(this: TThis, kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>): ClassError0<ExtensionsMapOf<TThis>>;
|
|
174
|
+
static extension(): ExtensionError0;
|
|
175
|
+
static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
|
|
176
|
+
serialize(isPublic?: boolean): object;
|
|
415
177
|
}
|
|
416
|
-
declare const e0s: {
|
|
417
|
-
Default: typeof Error0;
|
|
418
|
-
Expected: typeof Error0;
|
|
419
|
-
};
|
|
420
178
|
|
|
421
|
-
export { Error0, type
|
|
179
|
+
export { type ClassError0, Error0, type ErrorExtension, type ErrorExtensionMethodFn, type ErrorExtensionMethods, type ErrorExtensionPropOptions, type ErrorExtensionProps, type ErrorExtensionRefineFn, type ErrorExtensionRefineResult, type ErrorExtensionsMap, type ErrorInput, type ErrorInputBase, type ErrorOutput, ExtensionError0, type IsEmptyObject };
|