@devp0nt/error0 1.0.0-next.2 → 1.0.0-next.21

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.
@@ -1,110 +1,80 @@
1
1
  import * as undici_types from 'undici-types';
2
2
  import { Meta0 } from '@devp0nt/meta0';
3
- import { HttpStatusCode, AxiosError } from 'axios';
3
+ import { AxiosError, HttpStatusCode } from 'axios';
4
4
  import { ZodError } from 'zod';
5
5
 
6
- interface Error0Input {
7
- message?: string;
8
- tag?: string;
9
- code?: string;
10
- httpStatus?: HttpStatusCode | HttpStatusCodeString;
11
- expected?: boolean | ExpectedFn;
12
- clientMessage?: string;
13
- cause?: Error0Cause;
14
- stack?: string;
15
- meta?: Meta0.Meta0OrValueTypeNullish;
16
- zodError?: ZodError;
17
- axiosError?: AxiosError;
18
- }
19
- interface Error0GeneralProps {
20
- message: Error0Input['message'];
21
- tag: Error0Input['tag'];
22
- code: Error0Input['code'];
23
- httpStatus: number | undefined;
24
- expected: boolean | undefined;
25
- clientMessage: Error0Input['clientMessage'];
26
- anyMessage: string | undefined;
27
- cause: Error0Input['cause'];
28
- stack: Error['stack'];
29
- meta: Meta0.ValueType;
30
- zodError?: ZodError;
31
- axiosError?: AxiosError;
32
- }
33
- type HttpStatusCodeString = keyof typeof HttpStatusCode;
34
- type Error0Cause = Error | Error0 | unknown;
35
- type ExpectedFn = (error: Error0GeneralProps) => boolean | undefined;
36
6
  declare class Error0 extends Error {
37
7
  readonly __I_AM_ERROR_0: true;
38
- readonly tag?: Error0GeneralProps['tag'];
39
- readonly code?: Error0GeneralProps['code'];
40
- readonly httpStatus?: Error0GeneralProps['httpStatus'];
41
- readonly expected?: Error0GeneralProps['expected'];
42
- readonly clientMessage?: Error0GeneralProps['clientMessage'];
43
- readonly anyMessage?: Error0GeneralProps['anyMessage'];
44
- readonly cause?: Error0GeneralProps['cause'];
45
- readonly meta?: Meta0.Meta0OrValueTypeNullish;
46
- readonly zodError?: Error0GeneralProps['zodError'];
47
- readonly axiosError?: Error0GeneralProps['axiosError'];
8
+ readonly tag?: Error0.GeneralProps['tag'];
9
+ readonly code?: Error0.GeneralProps['code'];
10
+ readonly httpStatus?: Error0.GeneralProps['httpStatus'];
11
+ readonly expected?: Error0.GeneralProps['expected'];
12
+ readonly clientMessage?: Error0.GeneralProps['clientMessage'];
13
+ readonly anyMessage?: Error0.GeneralProps['anyMessage'];
14
+ readonly cause?: Error0.GeneralProps['cause'];
15
+ readonly meta?: Meta0.ValueTypeNullish;
16
+ readonly zodError?: Error0.GeneralProps['zodError'];
17
+ readonly axiosError?: Error0.GeneralProps['axiosError'];
48
18
  static defaultMessage: string;
49
- static defaultCode?: Error0GeneralProps['code'];
50
- static defaultHttpStatus?: Error0GeneralProps['httpStatus'];
51
- static defaultExpected?: Error0GeneralProps['expected'];
52
- static defaultClientMessage?: Error0GeneralProps['clientMessage'];
19
+ static defaultCode?: Error0.GeneralProps['code'];
20
+ static defaultHttpStatus?: Error0.GeneralProps['httpStatus'];
21
+ static defaultExpected?: Error0.GeneralProps['expected'];
22
+ static defaultClientMessage?: Error0.GeneralProps['clientMessage'];
53
23
  static defaultMeta?: Meta0.Meta0OrValueTypeNullish;
54
- readonly propsOriginal: Error0GeneralProps;
24
+ readonly propsOriginal: Error0.GeneralProps;
55
25
  constructor(message: string);
56
- constructor(input: Error0Input);
57
- constructor(message: string, input: Error0Input);
26
+ constructor(input: Error0.Input);
27
+ constructor(message: string, input: Error0.Input);
58
28
  constructor(error: Error);
59
- constructor(error: Error, input: Error0Input);
29
+ constructor(error: Error, input: Error0.Input);
60
30
  constructor(value: unknown);
61
- constructor(value: unknown, input: Error0Input);
31
+ constructor(value: unknown, input: Error0.Input);
62
32
  static defaultMaxLevel: number;
63
- static _safeParseInput(error0Input: Record<string, unknown>): Error0Input;
33
+ static _safeParseInput(error0Input: Record<string, unknown>): Error0.Input;
64
34
  static _getSelfGeneralProps({ error0Input, message, stack, }: {
65
- error0Input: Error0Input;
35
+ error0Input: Error0.Input;
66
36
  message: string;
67
- stack: Error0GeneralProps['stack'];
68
- }): Error0GeneralProps;
69
- static _getSelfPropsFloated(causesProps: Error0GeneralProps[]): Error0GeneralProps;
70
- static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0GeneralProps>;
71
- static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0GeneralProps>;
72
- static _assignError0Props(error0Props: Error0GeneralProps, extraError0Props: Partial<Error0GeneralProps>): void;
73
- static _normalizeSelfExpected(error0Props: Error0GeneralProps, expectedProvided: Error0Input['expected']): boolean | undefined;
74
- static _isExpected(causesProps: Error0GeneralProps[]): boolean;
75
- static _getPropsFromUnknown(error: unknown, defaults?: Error0Input): Error0GeneralProps;
76
- static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0GeneralProps[];
77
- static _getCausesPropsFromError0Props(error0Props: Error0GeneralProps, maxLevel: number): Error0GeneralProps[];
78
- static _getClosestPropValue<TPropKey extends keyof Error0GeneralProps>(causesProps: Error0GeneralProps[], propKey: TPropKey): NonNullable<Error0GeneralProps[TPropKey]> | undefined;
79
- static _getFilledPropValues<TPropKey extends keyof Error0Input>(causesProps: Error0GeneralProps[], propKey: TPropKey): NonNullable<Error0GeneralProps[TPropKey]>[];
80
- static _getMergedMetaValue(causesProps: Error0GeneralProps[]): Meta0.ValueType;
81
- static _removeConstructorStackPart(stack: Error0GeneralProps['stack']): Error0GeneralProps['stack'];
82
- static _mergeStack(prevStack: Error0GeneralProps['stack'], nextStack: Error0GeneralProps['stack']): Error0GeneralProps['stack'];
37
+ stack: Error0.GeneralProps['stack'];
38
+ }): Error0.GeneralProps;
39
+ static _getSelfPropsFloated(causesProps: Error0.GeneralProps[]): Error0.GeneralProps;
40
+ static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0.GeneralProps>;
41
+ static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0.GeneralProps>;
42
+ static _assignError0Props(error0Props: Error0.GeneralProps, extraError0Props: Partial<Error0.GeneralProps>): void;
43
+ static _normalizeSelfExpected(error0Props: Error0.GeneralProps, expectedProvided: Error0.Input['expected']): boolean | undefined;
44
+ static _isExpected(causesProps: Error0.GeneralProps[]): boolean;
45
+ static _getPropsFromUnknown(error: unknown, defaults?: Error0.Input): Error0.GeneralProps;
46
+ static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[];
47
+ static _getCausesPropsFromError0Props(error0Props: Error0.GeneralProps, maxLevel: number): Error0.GeneralProps[];
48
+ static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]> | undefined;
49
+ static _getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): Array<NonNullable<Error0.GeneralProps[TPropKey]>>;
50
+ static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType;
51
+ static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'];
52
+ static _mergeStack(prevStack: Error0.GeneralProps['stack'], nextStack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'];
83
53
  static isError0(error: unknown): error is Error0;
84
54
  static isLikelyError0(error: unknown): error is Error0;
85
- static _toError0(error: unknown, inputOverride?: Error0Input): Error0;
86
- static from(error: unknown, inputOverride?: Error0Input): Error0;
55
+ static _toError0(error: unknown, inputOverride?: Error0.Input): Error0;
56
+ static from(error: unknown, inputOverride?: Error0.Input): Error0;
87
57
  static extend(props: {
88
- defaultMessage?: Error0GeneralProps['message'];
89
- defaultCode?: Error0GeneralProps['code'];
90
- defaultHttpStatus?: Error0GeneralProps['httpStatus'];
91
- defaultExpected?: Error0GeneralProps['expected'];
92
- defaultClientMessage?: Error0GeneralProps['clientMessage'];
58
+ defaultMessage?: Error0.GeneralProps['message'];
59
+ defaultCode?: Error0.GeneralProps['code'];
60
+ defaultHttpStatus?: Error0.GeneralProps['httpStatus'];
61
+ defaultExpected?: Error0.GeneralProps['expected'];
62
+ defaultClientMessage?: Error0.GeneralProps['clientMessage'];
93
63
  defaultMeta?: Meta0.Meta0OrValueTypeNullish;
94
64
  }): {
95
65
  new (message: string): {
96
66
  readonly __I_AM_ERROR_0: true;
97
- readonly tag?: Error0GeneralProps["tag"];
98
- readonly code?: Error0GeneralProps["code"];
99
- readonly httpStatus?: Error0GeneralProps["httpStatus"];
100
- readonly expected?: Error0GeneralProps["expected"];
101
- readonly clientMessage?: Error0GeneralProps["clientMessage"];
102
- readonly anyMessage?: Error0GeneralProps["anyMessage"];
103
- readonly cause?: Error0GeneralProps["cause"];
104
- readonly meta?: Meta0.Meta0OrValueTypeNullish;
105
- readonly zodError?: Error0GeneralProps["zodError"];
106
- readonly axiosError?: Error0GeneralProps["axiosError"];
107
- readonly propsOriginal: Error0GeneralProps;
67
+ readonly tag?: Error0.GeneralProps["tag"];
68
+ readonly code?: Error0.GeneralProps["code"];
69
+ readonly httpStatus?: Error0.GeneralProps["httpStatus"];
70
+ readonly expected?: Error0.GeneralProps["expected"];
71
+ readonly clientMessage?: Error0.GeneralProps["clientMessage"];
72
+ readonly anyMessage?: Error0.GeneralProps["anyMessage"];
73
+ readonly cause?: Error0.GeneralProps["cause"];
74
+ readonly meta?: Meta0.ValueTypeNullish;
75
+ readonly zodError?: Error0.GeneralProps["zodError"];
76
+ readonly axiosError?: Error0.GeneralProps["axiosError"];
77
+ readonly propsOriginal: Error0.GeneralProps;
108
78
  toJSON(): {
109
79
  message: string;
110
80
  tag: string | undefined;
@@ -123,19 +93,19 @@ declare class Error0 extends Error {
123
93
  message: string;
124
94
  stack?: string;
125
95
  };
126
- new (input: Error0Input): {
96
+ new (input: Error0.Input): {
127
97
  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;
98
+ readonly tag?: Error0.GeneralProps["tag"];
99
+ readonly code?: Error0.GeneralProps["code"];
100
+ readonly httpStatus?: Error0.GeneralProps["httpStatus"];
101
+ readonly expected?: Error0.GeneralProps["expected"];
102
+ readonly clientMessage?: Error0.GeneralProps["clientMessage"];
103
+ readonly anyMessage?: Error0.GeneralProps["anyMessage"];
104
+ readonly cause?: Error0.GeneralProps["cause"];
105
+ readonly meta?: Meta0.ValueTypeNullish;
106
+ readonly zodError?: Error0.GeneralProps["zodError"];
107
+ readonly axiosError?: Error0.GeneralProps["axiosError"];
108
+ readonly propsOriginal: Error0.GeneralProps;
139
109
  toJSON(): {
140
110
  message: string;
141
111
  tag: string | undefined;
@@ -154,19 +124,19 @@ declare class Error0 extends Error {
154
124
  message: string;
155
125
  stack?: string;
156
126
  };
157
- new (message: string, input: Error0Input): {
127
+ new (message: string, input: Error0.Input): {
158
128
  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;
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;
170
140
  toJSON(): {
171
141
  message: string;
172
142
  tag: string | undefined;
@@ -187,17 +157,17 @@ declare class Error0 extends Error {
187
157
  };
188
158
  new (error: Error): {
189
159
  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;
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;
201
171
  toJSON(): {
202
172
  message: string;
203
173
  tag: string | undefined;
@@ -216,19 +186,19 @@ declare class Error0 extends Error {
216
186
  message: string;
217
187
  stack?: string;
218
188
  };
219
- new (error: Error, input: Error0Input): {
189
+ new (error: Error, input: Error0.Input): {
220
190
  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;
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;
232
202
  toJSON(): {
233
203
  message: string;
234
204
  tag: string | undefined;
@@ -249,17 +219,17 @@ declare class Error0 extends Error {
249
219
  };
250
220
  new (value: unknown): {
251
221
  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;
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;
263
233
  toJSON(): {
264
234
  message: string;
265
235
  tag: string | undefined;
@@ -278,19 +248,19 @@ declare class Error0 extends Error {
278
248
  message: string;
279
249
  stack?: string;
280
250
  };
281
- new (value: unknown, input: Error0Input): {
251
+ new (value: unknown, input: Error0.Input): {
282
252
  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;
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;
294
264
  toJSON(): {
295
265
  message: string;
296
266
  tag: string | undefined;
@@ -316,47 +286,47 @@ declare class Error0 extends Error {
316
286
  defaultClientMessage: string | undefined;
317
287
  defaultMeta: Meta0;
318
288
  defaultMaxLevel: number;
319
- _safeParseInput(error0Input: Record<string, unknown>): Error0Input;
289
+ _safeParseInput(error0Input: Record<string, unknown>): Error0.Input;
320
290
  _getSelfGeneralProps({ error0Input, message, stack, }: {
321
- error0Input: Error0Input;
291
+ error0Input: Error0.Input;
322
292
  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"];
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"];
339
309
  isError0(error: unknown): error is Error0;
340
310
  isLikelyError0(error: unknown): error is Error0;
341
- _toError0(error: unknown, inputOverride?: Error0Input): Error0;
342
- from(error: unknown, inputOverride?: Error0Input): Error0;
311
+ _toError0(error: unknown, inputOverride?: Error0.Input): Error0;
312
+ from(error: unknown, inputOverride?: Error0.Input): Error0;
343
313
  extend(props: {
344
- defaultMessage?: Error0GeneralProps["message"];
345
- defaultCode?: Error0GeneralProps["code"];
346
- defaultHttpStatus?: Error0GeneralProps["httpStatus"];
347
- defaultExpected?: Error0GeneralProps["expected"];
348
- defaultClientMessage?: Error0GeneralProps["clientMessage"];
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"];
349
319
  defaultMeta?: Meta0.Meta0OrValueTypeNullish;
350
320
  }): /*elided*/ any;
351
321
  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"];
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"];
357
327
  defaultMeta?: Meta0.Meta0OrValueTypeNullish;
358
328
  }): T;
359
- toJSON(error: unknown, inputOverride?: Error0Input): {
329
+ toJSON(error: unknown, inputOverride?: Error0.Input): {
360
330
  message: string;
361
331
  tag: string | undefined;
362
332
  code: string | undefined;
@@ -374,11 +344,11 @@ declare class Error0 extends Error {
374
344
  stackTraceLimit: number;
375
345
  };
376
346
  static extendCollection<T extends Record<string, typeof Error0>>(classes: T, props: {
377
- defaultMessage?: Error0GeneralProps['message'];
378
- defaultCode?: Error0GeneralProps['code'];
379
- defaultHttpStatus?: Error0GeneralProps['httpStatus'];
380
- defaultExpected?: Error0GeneralProps['expected'];
381
- defaultClientMessage?: Error0GeneralProps['clientMessage'];
347
+ defaultMessage?: Error0.GeneralProps['message'];
348
+ defaultCode?: Error0.GeneralProps['code'];
349
+ defaultHttpStatus?: Error0.GeneralProps['httpStatus'];
350
+ defaultExpected?: Error0.GeneralProps['expected'];
351
+ defaultClientMessage?: Error0.GeneralProps['clientMessage'];
382
352
  defaultMeta?: Meta0.Meta0OrValueTypeNullish;
383
353
  }): T;
384
354
  toJSON(): {
@@ -394,7 +364,7 @@ declare class Error0 extends Error {
394
364
  stack: string | undefined;
395
365
  __I_AM_ERROR_0: true;
396
366
  };
397
- static toJSON(error: unknown, inputOverride?: Error0Input): {
367
+ static toJSON(error: unknown, inputOverride?: Error0.Input): {
398
368
  message: string;
399
369
  tag: string | undefined;
400
370
  code: string | undefined;
@@ -410,12 +380,38 @@ declare class Error0 extends Error {
410
380
  toResponse(data?: Record<string, unknown>): undici_types.Response;
411
381
  }
412
382
  declare namespace Error0 {
383
+ interface Input {
384
+ message?: string;
385
+ tag?: string;
386
+ code?: string;
387
+ httpStatus?: HttpStatusCode | HttpStatusCodeString;
388
+ expected?: boolean | ExpectedFn;
389
+ clientMessage?: string;
390
+ cause?: Error0Cause;
391
+ stack?: string;
392
+ meta?: Meta0.Meta0OrValueTypeNullish;
393
+ zodError?: ZodError;
394
+ axiosError?: AxiosError;
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
413
  type JSON = ReturnType<Error0['toJSON']>;
414
414
  type Collection = Record<string, typeof Error0>;
415
415
  }
416
- declare const e0s: {
417
- Default: typeof Error0;
418
- Expected: typeof Error0;
419
- };
420
416
 
421
- export { Error0, type Error0Input, e0s };
417
+ export { Error0 };
package/dist/cjs/index.js CHANGED
@@ -28,15 +28,34 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var index_exports = {};
30
30
  __export(index_exports, {
31
- Error0: () => Error0,
32
- e0s: () => e0s
31
+ Error0: () => Error0
33
32
  });
34
33
  module.exports = __toCommonJS(index_exports);
35
34
  var import_meta0 = require("@devp0nt/meta0");
35
+ var import_meta0_plugin_tag = require("@devp0nt/meta0/plugins/meta0-plugin-tag");
36
36
  var import_axios = require("axios");
37
37
  var import_get = __toESM(require("lodash/get.js"), 1);
38
38
  var import_zod = require("zod");
39
39
  const isFilled = (value) => value !== null && value !== void 0 && value !== "";
40
+ const toStringOrUndefined = (value) => {
41
+ return typeof value === "string" ? value : void 0;
42
+ };
43
+ const toNumberOrUndefined = (value) => {
44
+ if (typeof value === "number") {
45
+ return value;
46
+ }
47
+ const number = Number(value);
48
+ if (typeof value === "string" && !Number.isNaN(number)) {
49
+ return number;
50
+ }
51
+ return void 0;
52
+ };
53
+ const toBooleanOrUndefined = (value) => {
54
+ if (typeof value === "boolean") {
55
+ return value;
56
+ }
57
+ return void 0;
58
+ };
40
59
  class Error0 extends Error {
41
60
  __I_AM_ERROR_0 = true;
42
61
  tag;
@@ -117,15 +136,16 @@ class Error0 extends Error {
117
136
  message,
118
137
  stack
119
138
  }) {
120
- const meta0 = import_meta0.Meta0.extend(error0Input.meta, this.defaultMeta);
139
+ const meta0 = import_meta0.Meta0.extend(this.defaultMeta, error0Input.meta);
121
140
  const meta = meta0.getValue();
122
- const finalTag = meta0.getFinalTag(error0Input.tag);
141
+ const finalTag = import_meta0_plugin_tag.meta0PluginTag.public.getFullTag(meta0, error0Input.tag);
142
+ delete meta.tagPrefix;
123
143
  const clientMessage = error0Input.clientMessage || this.defaultClientMessage;
124
144
  const result = {
125
145
  message: error0Input.message || this.defaultMessage,
126
146
  tag: finalTag,
127
- code: error0Input.code || meta.code || this.defaultCode,
128
- httpStatus: typeof error0Input.httpStatus === "number" ? error0Input.httpStatus : error0Input.httpStatus && typeof error0Input.httpStatus === "string" && error0Input.httpStatus in import_axios.HttpStatusCode ? import_axios.HttpStatusCode[error0Input.httpStatus] : meta.httpStatus || this.defaultHttpStatus,
147
+ code: error0Input.code || toStringOrUndefined(meta.code) || this.defaultCode,
148
+ httpStatus: typeof error0Input.httpStatus === "number" ? error0Input.httpStatus : error0Input.httpStatus && typeof error0Input.httpStatus === "string" && error0Input.httpStatus in import_axios.HttpStatusCode ? import_axios.HttpStatusCode[error0Input.httpStatus] : toNumberOrUndefined(meta.httpStatus) || this.defaultHttpStatus,
129
149
  expected: void 0,
130
150
  clientMessage,
131
151
  anyMessage: clientMessage || message,
@@ -137,7 +157,7 @@ class Error0 extends Error {
137
157
  };
138
158
  result.expected = this._normalizeSelfExpected(
139
159
  result,
140
- typeof error0Input.expected === "boolean" || typeof error0Input.expected === "function" ? error0Input.expected : meta.expected || this.defaultExpected
160
+ typeof error0Input.expected === "boolean" || typeof error0Input.expected === "function" ? error0Input.expected : toBooleanOrUndefined(meta.expected) || this.defaultExpected
141
161
  );
142
162
  result.stack = this._removeConstructorStackPart(stack);
143
163
  return result;
@@ -147,7 +167,7 @@ class Error0 extends Error {
147
167
  const stack = this._mergeStack(causesProps[1]?.stack, causesProps[0]?.stack);
148
168
  const closestTag = this._getClosestPropValue(causesProps, "tag");
149
169
  const meta = this._getMergedMetaValue(causesProps);
150
- const tag = import_meta0.Meta0.getFinalTag(meta, closestTag);
170
+ const tag = import_meta0_plugin_tag.meta0PluginTag.public.getFullTag(meta, closestTag);
151
171
  const propsFloated = {
152
172
  message: this._getClosestPropValue(causesProps, "message"),
153
173
  tag,
@@ -237,7 +257,10 @@ class Error0 extends Error {
237
257
  stack: "stack" in error && typeof error.stack === "string" ? error.stack : void 0,
238
258
  tag: "tag" in error && typeof error.tag === "string" ? error.tag : defaults?.tag || void 0,
239
259
  cause: "cause" in error ? error.cause : defaults?.cause || void 0,
240
- meta: "meta" in error && typeof error.meta === "object" && error.meta !== null ? import_meta0.Meta0.getValue(error.meta) : import_meta0.Meta0.getValue(defaults?.meta) || {},
260
+ meta: "meta" in error && typeof error.meta === "object" && error.meta !== null ? import_meta0.Meta0.getValue(error.meta) : (
261
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
262
+ import_meta0.Meta0.getValue(defaults?.meta) || {}
263
+ ),
241
264
  httpStatus: "httpStatus" in error && typeof error.httpStatus === "number" && error.httpStatus in import_axios.HttpStatusCode ? error.httpStatus : typeof defaults?.httpStatus === "string" ? import_axios.HttpStatusCode[defaults.httpStatus] : defaults?.httpStatus,
242
265
  zodError: "zodError" in error && error.zodError instanceof import_zod.ZodError ? error.zodError : error instanceof import_zod.ZodError ? error : defaults?.zodError,
243
266
  axiosError: "axiosError" in error && (0, import_axios.isAxiosError)(error.axiosError) ? error.axiosError : (0, import_axios.isAxiosError)(error) ? error : defaults?.axiosError
@@ -281,8 +304,8 @@ class Error0 extends Error {
281
304
  return void 0;
282
305
  }
283
306
  // private static getClosestByGetter<TResult>(
284
- // causesProps: Error0GeneralProps[],
285
- // getter: (props: Error0GeneralProps) => TResult,
307
+ // causesProps: Error0.GeneralProps[],
308
+ // getter: (props: Error0.GeneralProps) => TResult,
286
309
  // ): NonNullable<TResult> | undefined {
287
310
  // for (const causeProps of causesProps) {
288
311
  // const result = getter(causeProps)
@@ -358,13 +381,13 @@ class Error0 extends Error {
358
381
  ...inputOverride
359
382
  });
360
383
  }
361
- const inputFromData = (0, import_get.default)(error, "data");
384
+ const inputFromData = (0, import_get.default)(error, "data", void 0);
362
385
  if (inputFromData) {
363
386
  if (Error0.isLikelyError0(inputFromData)) {
364
387
  return this._toError0(inputFromData, inputOverride);
365
388
  }
366
389
  }
367
- const inputFromDataError0 = (0, import_get.default)(error, "data.error0");
390
+ const inputFromDataError0 = (0, import_get.default)(error, "data.error0", void 0);
368
391
  if (inputFromDataError0) {
369
392
  if (Error0.isLikelyError0(inputFromDataError0)) {
370
393
  return this._toError0(inputFromDataError0, inputOverride);
@@ -383,7 +406,7 @@ class Error0 extends Error {
383
406
  static defaultHttpStatus = props.defaultHttpStatus ?? parent.defaultHttpStatus;
384
407
  static defaultExpected = props.defaultExpected ?? parent.defaultExpected;
385
408
  static defaultClientMessage = props.defaultClientMessage ?? parent.defaultClientMessage;
386
- static defaultMeta = import_meta0.Meta0.extend(props.defaultMeta, parent.defaultMeta);
409
+ static defaultMeta = import_meta0.Meta0.extend(parent.defaultMeta, props.defaultMeta);
387
410
  };
388
411
  }
389
412
  static extendCollection(classes, props) {
@@ -421,15 +444,8 @@ class Error0 extends Error {
421
444
  );
422
445
  }
423
446
  }
424
- const e0s = {
425
- Default: Error0,
426
- Expected: Error0.extend({
427
- defaultExpected: true
428
- })
429
- };
430
447
  // Annotate the CommonJS export names for ESM import in node:
431
448
  0 && (module.exports = {
432
- Error0,
433
- e0s
449
+ Error0
434
450
  });
435
451
  //# sourceMappingURL=index.js.map