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