@devp0nt/error0 1.0.0-next.40 → 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 +61 -98
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +55 -59
- package/dist/esm/index.d.ts +55 -59
- package/dist/esm/index.js +61 -98
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +66 -86
- package/src/index.ts +140 -213
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
type ErrorExtensionPropOptions<TInputValue, TOutputValue, TError extends Error0 = Error0> = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
17
|
};
|
|
6
|
-
type ErrorExtensionCopmputedFn<TOutputValue, TError extends Error0 = Error0> = (error: TError) => TOutputValue;
|
|
7
18
|
type ErrorExtensionMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
|
|
8
19
|
type ErrorExtensionRefineResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
|
|
9
20
|
type ErrorExtensionRefineFn<TError extends Error0 = Error0, TOutputProps extends Record<string, unknown> = Record<never, never>> = ((error: TError) => void) | ((error: TError) => ErrorExtensionRefineResult<TOutputProps>);
|
|
@@ -14,30 +25,24 @@ type ErrorMethodRecord = {
|
|
|
14
25
|
type ErrorExtensionProps = {
|
|
15
26
|
[key: string]: ErrorExtensionPropOptions<any, any>;
|
|
16
27
|
};
|
|
17
|
-
type ErrorExtensionComputed = {
|
|
18
|
-
[key: string]: ErrorExtensionCopmputedFn<any>;
|
|
19
|
-
};
|
|
20
28
|
type ErrorExtensionMethods = {
|
|
21
29
|
[key: string]: ErrorExtensionMethodFn<any, any[]>;
|
|
22
30
|
};
|
|
23
|
-
type ErrorExtension<TProps extends ErrorExtensionProps = Record<never, never>,
|
|
31
|
+
type ErrorExtension<TProps extends ErrorExtensionProps = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> = {
|
|
24
32
|
props?: TProps;
|
|
25
|
-
computed?: TComputed;
|
|
26
33
|
methods?: TMethods;
|
|
27
34
|
refine?: Array<ErrorExtensionRefineFn<Error0, ExtensionOutputProps<TProps>>>;
|
|
28
35
|
};
|
|
29
36
|
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
37
|
type AddMethodToExtensionMethods<TMethods extends ErrorExtensionMethods, TKey extends string, TArgs extends unknown[], TOutputValue> = TMethods & Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>;
|
|
32
38
|
type ExtensionOutputProps<TProps extends ErrorExtensionProps> = {
|
|
33
39
|
[TKey in keyof TProps]: TProps[TKey] extends ErrorExtensionPropOptions<any, infer TOutputValue> ? TOutputValue : never;
|
|
34
40
|
};
|
|
35
41
|
type ErrorExtensionsMap = {
|
|
36
42
|
props: Record<string, {
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
init: unknown;
|
|
44
|
+
resolve: unknown;
|
|
39
45
|
}>;
|
|
40
|
-
computed: Record<string, unknown>;
|
|
41
46
|
methods: Record<string, ErrorMethodRecord>;
|
|
42
47
|
};
|
|
43
48
|
type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
@@ -45,13 +50,10 @@ type ErrorInputBase = {
|
|
|
45
50
|
cause?: unknown;
|
|
46
51
|
};
|
|
47
52
|
type ErrorInput<TExtensionsMap extends ErrorExtensionsMap> = IsEmptyObject<TExtensionsMap['props']> extends true ? ErrorInputBase : ErrorInputBase & Partial<{
|
|
48
|
-
[TKey in keyof TExtensionsMap['props']]: TExtensionsMap['props'][TKey]['
|
|
53
|
+
[TKey in keyof TExtensionsMap['props']]: TExtensionsMap['props'][TKey]['init'];
|
|
49
54
|
}>;
|
|
50
55
|
type ErrorOutputProps<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
51
|
-
[TKey in keyof TExtensionsMap['props']]
|
|
52
|
-
};
|
|
53
|
-
type ErrorOutputComputed<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
54
|
-
[TKey in keyof TExtensionsMap['computed']]: TExtensionsMap['computed'][TKey];
|
|
56
|
+
[TKey in keyof TExtensionsMap['props']]?: TExtensionsMap['props'][TKey]['resolve'];
|
|
55
57
|
};
|
|
56
58
|
type ErrorOutputMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
57
59
|
[TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
|
|
@@ -59,7 +61,7 @@ type ErrorOutputMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
|
59
61
|
output: infer TOutput;
|
|
60
62
|
} ? (...args: TArgs) => TOutput : never;
|
|
61
63
|
};
|
|
62
|
-
type ErrorOutput<TExtensionsMap extends ErrorExtensionsMap> = ErrorOutputProps<TExtensionsMap> &
|
|
64
|
+
type ErrorOutput<TExtensionsMap extends ErrorExtensionsMap> = ErrorOutputProps<TExtensionsMap> & ErrorOutputMethods<TExtensionsMap>;
|
|
63
65
|
type ErrorStaticMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
64
66
|
[TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
|
|
65
67
|
args: infer TArgs extends unknown[];
|
|
@@ -68,21 +70,17 @@ type ErrorStaticMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
|
68
70
|
};
|
|
69
71
|
type EmptyExtensionsMap = {
|
|
70
72
|
props: Record<never, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
init: never;
|
|
74
|
+
resolve: never;
|
|
73
75
|
}>;
|
|
74
|
-
computed: Record<never, never>;
|
|
75
76
|
methods: Record<never, ErrorMethodRecord>;
|
|
76
77
|
};
|
|
77
78
|
type ExtensionPropsMapOf<TExtension extends ErrorExtension> = {
|
|
78
79
|
[TKey in keyof NonNullable<TExtension['props']>]: NonNullable<TExtension['props']>[TKey] extends ErrorExtensionPropOptions<infer TInputValue, infer TOutputValue> ? {
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
init: TInputValue;
|
|
81
|
+
resolve: TOutputValue;
|
|
81
82
|
} : never;
|
|
82
83
|
};
|
|
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
84
|
type ExtensionMethodsMapOf<TExtension extends ErrorExtension> = {
|
|
87
85
|
[TKey in keyof NonNullable<TExtension['methods']>]: NonNullable<TExtension['methods']>[TKey] extends (error: Error0, ...args: infer TArgs extends unknown[]) => infer TOutput ? {
|
|
88
86
|
args: TArgs;
|
|
@@ -91,41 +89,34 @@ type ExtensionMethodsMapOf<TExtension extends ErrorExtension> = {
|
|
|
91
89
|
};
|
|
92
90
|
type ErrorExtensionsMapOfExtension<TExtension extends ErrorExtension> = {
|
|
93
91
|
props: ExtensionPropsMapOf<TExtension>;
|
|
94
|
-
computed: ExtensionComputedMapOf<TExtension>;
|
|
95
92
|
methods: ExtensionMethodsMapOf<TExtension>;
|
|
96
93
|
};
|
|
97
94
|
type ExtendErrorExtensionsMap<TMap extends ErrorExtensionsMap, TExtension extends ErrorExtension> = {
|
|
98
95
|
props: TMap['props'] & ErrorExtensionsMapOfExtension<TExtension>['props'];
|
|
99
|
-
computed: TMap['computed'] & ErrorExtensionsMapOfExtension<TExtension>['computed'];
|
|
100
96
|
methods: TMap['methods'] & ErrorExtensionsMapOfExtension<TExtension>['methods'];
|
|
101
97
|
};
|
|
102
98
|
type ExtendErrorExtensionsMapWithProp<TMap extends ErrorExtensionsMap, TKey extends string, TInputValue, TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>>>;
|
|
103
|
-
type
|
|
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>>>>;
|
|
99
|
+
type ExtendErrorExtensionsMapWithMethod<TMap extends ErrorExtensionsMap, TKey extends string, TArgs extends unknown[], TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<never, never>, Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>>>;
|
|
105
100
|
type ExtensionsMapOf<TClass> = TClass extends {
|
|
106
101
|
__extensionsMap?: infer TExtensionsMap;
|
|
107
102
|
} ? TExtensionsMap extends ErrorExtensionsMap ? TExtensionsMap : EmptyExtensionsMap : EmptyExtensionsMap;
|
|
108
|
-
type ExtensionsMapFromParts<TProps extends ErrorExtensionProps,
|
|
103
|
+
type ExtensionsMapFromParts<TProps extends ErrorExtensionProps, TMethods extends ErrorExtensionMethods> = ErrorExtensionsMapOfExtension<ErrorExtension<TProps, TMethods>>;
|
|
109
104
|
type ErrorInstanceOfMap<TMap extends ErrorExtensionsMap> = Error0 & ErrorOutput<TMap>;
|
|
110
|
-
type BuilderError0<TProps extends ErrorExtensionProps,
|
|
111
|
-
type ExtensionOfBuilder<TBuilder> = TBuilder extends ExtensionError0<infer TProps, infer
|
|
112
|
-
|
|
113
|
-
declare class ExtensionError0<TProps extends ErrorExtensionProps = Record<never, never>, TComputed extends ErrorExtensionComputed = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> {
|
|
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>> {
|
|
114
108
|
private readonly _extension;
|
|
115
109
|
readonly Infer: {
|
|
116
110
|
props: TProps;
|
|
117
|
-
computed: TComputed;
|
|
118
111
|
methods: TMethods;
|
|
119
112
|
};
|
|
120
|
-
constructor(extension?: ErrorExtension<ErrorExtensionProps,
|
|
121
|
-
prop<TKey extends string, TInputValue, TOutputValue>(key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, BuilderError0<TProps,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
extend<TKey extends string,
|
|
126
|
-
extend
|
|
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>;
|
|
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>;
|
|
129
120
|
}
|
|
130
121
|
type ClassError0<TExtensionsMap extends ErrorExtensionsMap = EmptyExtensionsMap> = {
|
|
131
122
|
new (message: string, input?: ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
|
|
@@ -134,11 +125,13 @@ type ClassError0<TExtensionsMap extends ErrorExtensionsMap = EmptyExtensionsMap>
|
|
|
134
125
|
} & ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
|
|
135
126
|
readonly __extensionsMap?: TExtensionsMap;
|
|
136
127
|
from: (error: unknown) => Error0 & ErrorOutput<TExtensionsMap>;
|
|
137
|
-
serialize: (error: unknown, isPublic?: boolean) =>
|
|
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>;
|
|
138
132
|
extend: {
|
|
139
133
|
<TBuilder extends ExtensionError0>(extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<TExtensionsMap, ExtensionOfBuilder<TBuilder>>>;
|
|
140
134
|
<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
135
|
<TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>): ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>;
|
|
143
136
|
(kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>): ClassError0<TExtensionsMap>;
|
|
144
137
|
};
|
|
@@ -156,28 +149,31 @@ declare class Error0 extends Error {
|
|
|
156
149
|
private static readonly isSelfProperty;
|
|
157
150
|
static own(error: object, key: string): unknown;
|
|
158
151
|
own(key: string): unknown;
|
|
159
|
-
static flow(error: object, key: string
|
|
160
|
-
flow(key: string
|
|
161
|
-
static causes(error:
|
|
162
|
-
causes(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
static
|
|
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>;
|
|
166
160
|
static from(error: unknown): Error0;
|
|
167
161
|
private static _applyRefine;
|
|
168
|
-
private static
|
|
162
|
+
private static _fromSerialized;
|
|
169
163
|
private static _fromNonError0;
|
|
170
164
|
private static _extractMessage;
|
|
171
165
|
private static _extendWithExtension;
|
|
172
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>>;
|
|
173
170
|
static extend<TThis extends typeof Error0, TBuilder extends ExtensionError0>(this: TThis, extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<ExtensionsMapOf<TThis>, ExtensionOfBuilder<TBuilder>>>;
|
|
174
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>>;
|
|
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
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>>;
|
|
177
173
|
static extend<TThis extends typeof Error0>(this: TThis, kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>): ClassError0<ExtensionsMapOf<TThis>>;
|
|
178
174
|
static extension(): ExtensionError0;
|
|
179
|
-
static serialize(error: unknown, isPublic?: boolean):
|
|
175
|
+
static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
|
|
180
176
|
serialize(isPublic?: boolean): object;
|
|
181
177
|
}
|
|
182
178
|
|
|
183
|
-
export { type ClassError0, Error0, type ErrorExtension, 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 };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
type ErrorExtensionPropOptions<TInputValue, TOutputValue, TError extends Error0 = Error0> = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
17
|
};
|
|
6
|
-
type ErrorExtensionCopmputedFn<TOutputValue, TError extends Error0 = Error0> = (error: TError) => TOutputValue;
|
|
7
18
|
type ErrorExtensionMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
|
|
8
19
|
type ErrorExtensionRefineResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
|
|
9
20
|
type ErrorExtensionRefineFn<TError extends Error0 = Error0, TOutputProps extends Record<string, unknown> = Record<never, never>> = ((error: TError) => void) | ((error: TError) => ErrorExtensionRefineResult<TOutputProps>);
|
|
@@ -14,30 +25,24 @@ type ErrorMethodRecord = {
|
|
|
14
25
|
type ErrorExtensionProps = {
|
|
15
26
|
[key: string]: ErrorExtensionPropOptions<any, any>;
|
|
16
27
|
};
|
|
17
|
-
type ErrorExtensionComputed = {
|
|
18
|
-
[key: string]: ErrorExtensionCopmputedFn<any>;
|
|
19
|
-
};
|
|
20
28
|
type ErrorExtensionMethods = {
|
|
21
29
|
[key: string]: ErrorExtensionMethodFn<any, any[]>;
|
|
22
30
|
};
|
|
23
|
-
type ErrorExtension<TProps extends ErrorExtensionProps = Record<never, never>,
|
|
31
|
+
type ErrorExtension<TProps extends ErrorExtensionProps = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> = {
|
|
24
32
|
props?: TProps;
|
|
25
|
-
computed?: TComputed;
|
|
26
33
|
methods?: TMethods;
|
|
27
34
|
refine?: Array<ErrorExtensionRefineFn<Error0, ExtensionOutputProps<TProps>>>;
|
|
28
35
|
};
|
|
29
36
|
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
37
|
type AddMethodToExtensionMethods<TMethods extends ErrorExtensionMethods, TKey extends string, TArgs extends unknown[], TOutputValue> = TMethods & Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>;
|
|
32
38
|
type ExtensionOutputProps<TProps extends ErrorExtensionProps> = {
|
|
33
39
|
[TKey in keyof TProps]: TProps[TKey] extends ErrorExtensionPropOptions<any, infer TOutputValue> ? TOutputValue : never;
|
|
34
40
|
};
|
|
35
41
|
type ErrorExtensionsMap = {
|
|
36
42
|
props: Record<string, {
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
init: unknown;
|
|
44
|
+
resolve: unknown;
|
|
39
45
|
}>;
|
|
40
|
-
computed: Record<string, unknown>;
|
|
41
46
|
methods: Record<string, ErrorMethodRecord>;
|
|
42
47
|
};
|
|
43
48
|
type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
@@ -45,13 +50,10 @@ type ErrorInputBase = {
|
|
|
45
50
|
cause?: unknown;
|
|
46
51
|
};
|
|
47
52
|
type ErrorInput<TExtensionsMap extends ErrorExtensionsMap> = IsEmptyObject<TExtensionsMap['props']> extends true ? ErrorInputBase : ErrorInputBase & Partial<{
|
|
48
|
-
[TKey in keyof TExtensionsMap['props']]: TExtensionsMap['props'][TKey]['
|
|
53
|
+
[TKey in keyof TExtensionsMap['props']]: TExtensionsMap['props'][TKey]['init'];
|
|
49
54
|
}>;
|
|
50
55
|
type ErrorOutputProps<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
51
|
-
[TKey in keyof TExtensionsMap['props']]
|
|
52
|
-
};
|
|
53
|
-
type ErrorOutputComputed<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
54
|
-
[TKey in keyof TExtensionsMap['computed']]: TExtensionsMap['computed'][TKey];
|
|
56
|
+
[TKey in keyof TExtensionsMap['props']]?: TExtensionsMap['props'][TKey]['resolve'];
|
|
55
57
|
};
|
|
56
58
|
type ErrorOutputMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
57
59
|
[TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
|
|
@@ -59,7 +61,7 @@ type ErrorOutputMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
|
59
61
|
output: infer TOutput;
|
|
60
62
|
} ? (...args: TArgs) => TOutput : never;
|
|
61
63
|
};
|
|
62
|
-
type ErrorOutput<TExtensionsMap extends ErrorExtensionsMap> = ErrorOutputProps<TExtensionsMap> &
|
|
64
|
+
type ErrorOutput<TExtensionsMap extends ErrorExtensionsMap> = ErrorOutputProps<TExtensionsMap> & ErrorOutputMethods<TExtensionsMap>;
|
|
63
65
|
type ErrorStaticMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
64
66
|
[TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
|
|
65
67
|
args: infer TArgs extends unknown[];
|
|
@@ -68,21 +70,17 @@ type ErrorStaticMethods<TExtensionsMap extends ErrorExtensionsMap> = {
|
|
|
68
70
|
};
|
|
69
71
|
type EmptyExtensionsMap = {
|
|
70
72
|
props: Record<never, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
init: never;
|
|
74
|
+
resolve: never;
|
|
73
75
|
}>;
|
|
74
|
-
computed: Record<never, never>;
|
|
75
76
|
methods: Record<never, ErrorMethodRecord>;
|
|
76
77
|
};
|
|
77
78
|
type ExtensionPropsMapOf<TExtension extends ErrorExtension> = {
|
|
78
79
|
[TKey in keyof NonNullable<TExtension['props']>]: NonNullable<TExtension['props']>[TKey] extends ErrorExtensionPropOptions<infer TInputValue, infer TOutputValue> ? {
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
init: TInputValue;
|
|
81
|
+
resolve: TOutputValue;
|
|
81
82
|
} : never;
|
|
82
83
|
};
|
|
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
84
|
type ExtensionMethodsMapOf<TExtension extends ErrorExtension> = {
|
|
87
85
|
[TKey in keyof NonNullable<TExtension['methods']>]: NonNullable<TExtension['methods']>[TKey] extends (error: Error0, ...args: infer TArgs extends unknown[]) => infer TOutput ? {
|
|
88
86
|
args: TArgs;
|
|
@@ -91,41 +89,34 @@ type ExtensionMethodsMapOf<TExtension extends ErrorExtension> = {
|
|
|
91
89
|
};
|
|
92
90
|
type ErrorExtensionsMapOfExtension<TExtension extends ErrorExtension> = {
|
|
93
91
|
props: ExtensionPropsMapOf<TExtension>;
|
|
94
|
-
computed: ExtensionComputedMapOf<TExtension>;
|
|
95
92
|
methods: ExtensionMethodsMapOf<TExtension>;
|
|
96
93
|
};
|
|
97
94
|
type ExtendErrorExtensionsMap<TMap extends ErrorExtensionsMap, TExtension extends ErrorExtension> = {
|
|
98
95
|
props: TMap['props'] & ErrorExtensionsMapOfExtension<TExtension>['props'];
|
|
99
|
-
computed: TMap['computed'] & ErrorExtensionsMapOfExtension<TExtension>['computed'];
|
|
100
96
|
methods: TMap['methods'] & ErrorExtensionsMapOfExtension<TExtension>['methods'];
|
|
101
97
|
};
|
|
102
98
|
type ExtendErrorExtensionsMapWithProp<TMap extends ErrorExtensionsMap, TKey extends string, TInputValue, TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>>>;
|
|
103
|
-
type
|
|
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>>>>;
|
|
99
|
+
type ExtendErrorExtensionsMapWithMethod<TMap extends ErrorExtensionsMap, TKey extends string, TArgs extends unknown[], TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<never, never>, Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>>>;
|
|
105
100
|
type ExtensionsMapOf<TClass> = TClass extends {
|
|
106
101
|
__extensionsMap?: infer TExtensionsMap;
|
|
107
102
|
} ? TExtensionsMap extends ErrorExtensionsMap ? TExtensionsMap : EmptyExtensionsMap : EmptyExtensionsMap;
|
|
108
|
-
type ExtensionsMapFromParts<TProps extends ErrorExtensionProps,
|
|
103
|
+
type ExtensionsMapFromParts<TProps extends ErrorExtensionProps, TMethods extends ErrorExtensionMethods> = ErrorExtensionsMapOfExtension<ErrorExtension<TProps, TMethods>>;
|
|
109
104
|
type ErrorInstanceOfMap<TMap extends ErrorExtensionsMap> = Error0 & ErrorOutput<TMap>;
|
|
110
|
-
type BuilderError0<TProps extends ErrorExtensionProps,
|
|
111
|
-
type ExtensionOfBuilder<TBuilder> = TBuilder extends ExtensionError0<infer TProps, infer
|
|
112
|
-
|
|
113
|
-
declare class ExtensionError0<TProps extends ErrorExtensionProps = Record<never, never>, TComputed extends ErrorExtensionComputed = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> {
|
|
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>> {
|
|
114
108
|
private readonly _extension;
|
|
115
109
|
readonly Infer: {
|
|
116
110
|
props: TProps;
|
|
117
|
-
computed: TComputed;
|
|
118
111
|
methods: TMethods;
|
|
119
112
|
};
|
|
120
|
-
constructor(extension?: ErrorExtension<ErrorExtensionProps,
|
|
121
|
-
prop<TKey extends string, TInputValue, TOutputValue>(key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, BuilderError0<TProps,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
extend<TKey extends string,
|
|
126
|
-
extend
|
|
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>;
|
|
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>;
|
|
129
120
|
}
|
|
130
121
|
type ClassError0<TExtensionsMap extends ErrorExtensionsMap = EmptyExtensionsMap> = {
|
|
131
122
|
new (message: string, input?: ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
|
|
@@ -134,11 +125,13 @@ type ClassError0<TExtensionsMap extends ErrorExtensionsMap = EmptyExtensionsMap>
|
|
|
134
125
|
} & ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
|
|
135
126
|
readonly __extensionsMap?: TExtensionsMap;
|
|
136
127
|
from: (error: unknown) => Error0 & ErrorOutput<TExtensionsMap>;
|
|
137
|
-
serialize: (error: unknown, isPublic?: boolean) =>
|
|
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>;
|
|
138
132
|
extend: {
|
|
139
133
|
<TBuilder extends ExtensionError0>(extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<TExtensionsMap, ExtensionOfBuilder<TBuilder>>>;
|
|
140
134
|
<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
135
|
<TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>): ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>;
|
|
143
136
|
(kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>): ClassError0<TExtensionsMap>;
|
|
144
137
|
};
|
|
@@ -156,28 +149,31 @@ declare class Error0 extends Error {
|
|
|
156
149
|
private static readonly isSelfProperty;
|
|
157
150
|
static own(error: object, key: string): unknown;
|
|
158
151
|
own(key: string): unknown;
|
|
159
|
-
static flow(error: object, key: string
|
|
160
|
-
flow(key: string
|
|
161
|
-
static causes(error:
|
|
162
|
-
causes(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
static
|
|
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>;
|
|
166
160
|
static from(error: unknown): Error0;
|
|
167
161
|
private static _applyRefine;
|
|
168
|
-
private static
|
|
162
|
+
private static _fromSerialized;
|
|
169
163
|
private static _fromNonError0;
|
|
170
164
|
private static _extractMessage;
|
|
171
165
|
private static _extendWithExtension;
|
|
172
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>>;
|
|
173
170
|
static extend<TThis extends typeof Error0, TBuilder extends ExtensionError0>(this: TThis, extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<ExtensionsMapOf<TThis>, ExtensionOfBuilder<TBuilder>>>;
|
|
174
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>>;
|
|
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
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>>;
|
|
177
173
|
static extend<TThis extends typeof Error0>(this: TThis, kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>): ClassError0<ExtensionsMapOf<TThis>>;
|
|
178
174
|
static extension(): ExtensionError0;
|
|
179
|
-
static serialize(error: unknown, isPublic?: boolean):
|
|
175
|
+
static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
|
|
180
176
|
serialize(isPublic?: boolean): object;
|
|
181
177
|
}
|
|
182
178
|
|
|
183
|
-
export { type ClassError0, Error0, type ErrorExtension, 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 };
|