@devp0nt/error0 1.0.0-next.53 → 1.0.0-next.54
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 +109 -105
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +42 -35
- package/dist/cjs/plugins/code.d.cts +40 -2
- package/dist/cjs/plugins/expected.d.cts +53 -11
- package/dist/cjs/plugins/meta.d.cts +40 -2
- package/dist/cjs/plugins/stack-merge.cjs +3 -3
- package/dist/cjs/plugins/stack-merge.cjs.map +1 -1
- package/dist/cjs/plugins/status.d.cts +40 -2
- package/dist/cjs/plugins/tags.d.cts +53 -11
- package/dist/esm/index.d.ts +42 -35
- package/dist/esm/index.js +109 -105
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/plugins/code.d.ts +40 -2
- package/dist/esm/plugins/expected.d.ts +53 -11
- package/dist/esm/plugins/meta.d.ts +40 -2
- package/dist/esm/plugins/stack-merge.js +3 -3
- package/dist/esm/plugins/stack-merge.js.map +1 -1
- package/dist/esm/plugins/status.d.ts +40 -2
- package/dist/esm/plugins/tags.d.ts +53 -11
- package/package.json +4 -2
- package/src/index.test.ts +187 -5
- package/src/index.ts +256 -246
- package/src/plugins/stack-merge.ts +2 -3
- package/src/plugins/tags.test.ts +1 -1
package/dist/cjs/index.d.cts
CHANGED
|
@@ -35,6 +35,18 @@ type ErrorPluginPropOptionsWithoutInit<TOutputValue, TError extends Error0, TRes
|
|
|
35
35
|
init?: undefined;
|
|
36
36
|
};
|
|
37
37
|
type ErrorPluginPropOptions<TInputValue = undefined, TOutputValue = unknown, TError extends Error0 = Error0, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined> = ErrorPluginPropOptionsWithInit<TInputValue, TOutputValue, TError, TResolveValue> | ErrorPluginPropOptionsWithoutInit<TOutputValue, TError, TResolveValue>;
|
|
38
|
+
type ErrorPluginPropOptionsBaseDefinition<TOutputValue, TError extends Error0, TResolveValue extends TOutputValue | undefined> = {
|
|
39
|
+
resolve?: ((options: ErrorPluginPropOptionsResolveOptions<TOutputValue, TError>) => TResolveValue) | boolean;
|
|
40
|
+
serialize?: ErrorPluginPropSerialize<TOutputValue, TError, TResolveValue>;
|
|
41
|
+
deserialize?: ErrorPluginPropDeserialize<TOutputValue>;
|
|
42
|
+
};
|
|
43
|
+
type ErrorPluginPropOptionsWithInitDefinition<TInputValue, TOutputValue, TError extends Error0, TResolveValue extends TOutputValue | undefined> = ErrorPluginPropOptionsBaseDefinition<TOutputValue, TError, TResolveValue> & {
|
|
44
|
+
init: ErrorPluginPropInit<TInputValue, TOutputValue>;
|
|
45
|
+
};
|
|
46
|
+
type ErrorPluginPropOptionsWithoutInitDefinition<TOutputValue, TError extends Error0, TResolveValue extends TOutputValue | undefined> = ErrorPluginPropOptionsBaseDefinition<TOutputValue, TError, TResolveValue> & {
|
|
47
|
+
init?: undefined;
|
|
48
|
+
};
|
|
49
|
+
type ErrorPluginPropOptionsDefinition<TInputValue = undefined, TOutputValue = unknown, TError extends Error0 = Error0, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined> = ErrorPluginPropOptionsWithInitDefinition<TInputValue, TOutputValue, TError, TResolveValue> | ErrorPluginPropOptionsWithoutInitDefinition<TOutputValue, TError, TResolveValue>;
|
|
38
50
|
type ErrorPluginMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
|
|
39
51
|
type ErrorPluginAnyMethodFn = (error: any, ...args: any[]) => any;
|
|
40
52
|
type ErrorPluginAdaptResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
|
|
@@ -116,15 +128,17 @@ type ErrorResolvedProps<TPluginsMap extends ErrorPluginsMap> = {
|
|
|
116
128
|
type ErrorOwnProps<TPluginsMap extends ErrorPluginsMap> = {
|
|
117
129
|
[TKey in keyof TPluginsMap['props']]: TPluginsMap['props'][TKey]['output'] | undefined;
|
|
118
130
|
};
|
|
131
|
+
type ErrorResolveMethods<TPluginsMap extends ErrorPluginsMap> = {
|
|
132
|
+
resolve: () => ErrorResolvedProps<TPluginsMap>;
|
|
133
|
+
};
|
|
134
|
+
type Error0ResolvedInstance<TPluginsMap extends ErrorPluginsMap> = Error0 & ErrorResolved<TPluginsMap> & ErrorResolveMethods<TPluginsMap>;
|
|
119
135
|
type ErrorOwnMethods<TPluginsMap extends ErrorPluginsMap> = {
|
|
120
|
-
own
|
|
121
|
-
(): ErrorOwnProps<TPluginsMap>;
|
|
122
|
-
<TKey extends keyof TPluginsMap['props'] & string>(key: TKey): ErrorOwnProps<TPluginsMap>[TKey];
|
|
123
|
-
};
|
|
136
|
+
own?: Partial<ErrorOwnProps<TPluginsMap>>;
|
|
124
137
|
flow: <TKey extends keyof TPluginsMap['props'] & string>(key: TKey) => Array<ErrorOwnProps<TPluginsMap>[TKey]>;
|
|
138
|
+
assign: (props: Partial<ErrorOwnProps<TPluginsMap>>) => Error0ResolvedInstance<TPluginsMap>;
|
|
125
139
|
};
|
|
126
|
-
type
|
|
127
|
-
|
|
140
|
+
type InstanceError0<TPluginsMap extends ErrorPluginsMap> = Error0ResolvedInstance<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & {
|
|
141
|
+
readonly __pluginsMap?: TPluginsMap;
|
|
128
142
|
};
|
|
129
143
|
type BindInstanceMethod<TMethod> = TMethod extends (error: any, ...args: infer TArgs) => infer TOutput ? (...args: TArgs) => TOutput : never;
|
|
130
144
|
type BindStaticMethod<TMethod> = TMethod extends (error: any, ...args: infer TArgs) => infer TOutput ? (error: unknown, ...args: TArgs) => TOutput : never;
|
|
@@ -183,12 +197,8 @@ type PluginsMapOfInstance<TInstance> = TInstance extends {
|
|
|
183
197
|
__pluginsMap?: infer TPluginsMap;
|
|
184
198
|
} ? TPluginsMap extends ErrorPluginsMap ? TPluginsMap : EmptyPluginsMap : EmptyPluginsMap;
|
|
185
199
|
type PluginsMapFromParts<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = ErrorPluginsMapOfPlugin<ErrorPlugin<TProps, TMethods>>;
|
|
186
|
-
type ErrorInstanceOfMap<TMap extends ErrorPluginsMap> =
|
|
187
|
-
|
|
188
|
-
};
|
|
189
|
-
type BuilderError0<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = Error0 & ErrorResolved<PluginsMapFromParts<TProps, TMethods>> & ErrorOwnMethods<PluginsMapFromParts<TProps, TMethods>> & ErrorResolveMethods<PluginsMapFromParts<TProps, TMethods>> & {
|
|
190
|
-
readonly __pluginsMap?: PluginsMapFromParts<TProps, TMethods>;
|
|
191
|
-
};
|
|
200
|
+
type ErrorInstanceOfMap<TMap extends ErrorPluginsMap> = InstanceError0<TMap>;
|
|
201
|
+
type BuilderError0<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = InstanceError0<PluginsMapFromParts<TProps, TMethods>>;
|
|
192
202
|
type PluginOfBuilder<TBuilder> = TBuilder extends PluginError0<infer TProps, infer TMethods> ? ErrorPlugin<TProps, TMethods> : never;
|
|
193
203
|
declare class PluginError0<TProps extends ErrorPluginProps = Record<never, never>, TMethods extends ErrorPluginMethods = Record<never, never>> {
|
|
194
204
|
private readonly _plugin;
|
|
@@ -197,38 +207,36 @@ declare class PluginError0<TProps extends ErrorPluginProps = Record<never, never
|
|
|
197
207
|
methods: TMethods;
|
|
198
208
|
};
|
|
199
209
|
constructor(plugin?: ErrorPlugin<ErrorPluginProps, ErrorPluginMethods>);
|
|
200
|
-
prop<TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(key: TKey, value:
|
|
210
|
+
prop<TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(key: TKey, value: ErrorPluginPropOptionsDefinition<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>, TResolveValue>): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue, TResolveValue>, TMethods>;
|
|
201
211
|
method<TKey extends string, TMethod extends (error: BuilderError0<TProps, TMethods>, ...args: any[]) => any>(key: TKey, value: TMethod): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TMethod>>;
|
|
202
212
|
adapt(value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
|
|
203
213
|
stack(value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
204
214
|
cause(value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
205
215
|
message(value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
206
|
-
use<TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(kind: 'prop', key: TKey, value:
|
|
216
|
+
use<TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(kind: 'prop', key: TKey, value: ErrorPluginPropOptionsDefinition<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>, TResolveValue>): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue, TResolveValue>, TMethods>;
|
|
207
217
|
use<TKey extends string, TMethod extends (error: BuilderError0<TProps, TMethods>, ...args: any[]) => any>(kind: 'method', key: TKey, value: TMethod): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TMethod>>;
|
|
208
218
|
use(kind: 'adapt', value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
|
|
209
219
|
use(kind: 'stack', value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
210
220
|
use(kind: 'cause', value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
211
221
|
use(kind: 'message', value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
212
222
|
}
|
|
223
|
+
type ErrorOwnStore = Record<string, unknown>;
|
|
213
224
|
type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {
|
|
214
225
|
MAX_CAUSES_DEPTH: number;
|
|
215
|
-
new (message: string, input?: ErrorInput<TPluginsMap>):
|
|
216
|
-
readonly __pluginsMap?: TPluginsMap;
|
|
217
|
-
};
|
|
226
|
+
new (message: string, input?: ErrorInput<TPluginsMap>): InstanceError0<TPluginsMap>;
|
|
218
227
|
new (input: {
|
|
219
228
|
message: string;
|
|
220
|
-
} & ErrorInput<TPluginsMap>):
|
|
221
|
-
readonly __pluginsMap?: TPluginsMap;
|
|
222
|
-
};
|
|
229
|
+
} & ErrorInput<TPluginsMap>): InstanceError0<TPluginsMap>;
|
|
223
230
|
readonly __pluginsMap?: TPluginsMap;
|
|
224
|
-
from: (error: unknown) =>
|
|
225
|
-
round: (error: unknown, isPublic?: boolean) =>
|
|
231
|
+
from: <TThis extends ClassError0<any>>(this: TThis, error: unknown) => InstanceType<TThis>;
|
|
232
|
+
round: <TThis extends ClassError0<any>>(this: TThis, error: unknown, isPublic?: boolean) => InstanceType<TThis>;
|
|
226
233
|
causes: {
|
|
227
234
|
(error: unknown, instancesOnly?: false): unknown[];
|
|
228
|
-
(error: unknown, instancesOnly: true): Array<
|
|
235
|
+
(error: unknown, instancesOnly: true): Array<InstanceError0<TPluginsMap>>;
|
|
229
236
|
};
|
|
230
237
|
resolve: (error: unknown) => ErrorResolvedProps<TPluginsMap>;
|
|
231
238
|
serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>;
|
|
239
|
+
assign: <TThis extends ClassError0<any>>(this: TThis, error: unknown, props: Partial<ErrorOwnProps<PluginsMapOf<TThis>>>) => InstanceError0<PluginsMapOf<TThis>>;
|
|
232
240
|
own: {
|
|
233
241
|
(error: object): ErrorOwnProps<TPluginsMap>;
|
|
234
242
|
<TKey extends keyof TPluginsMap['props'] & string>(error: object, key: TKey): ErrorOwnProps<TPluginsMap>[TKey];
|
|
@@ -251,6 +259,7 @@ declare class Error0 extends Error {
|
|
|
251
259
|
static MAX_CAUSES_DEPTH: number;
|
|
252
260
|
protected static _plugins: ErrorPlugin[];
|
|
253
261
|
protected static _resolvedPlugin?: ErrorPluginResolved;
|
|
262
|
+
own?: ErrorOwnStore;
|
|
254
263
|
private static readonly _emptyPlugin;
|
|
255
264
|
private static _indexResolvedPlugin;
|
|
256
265
|
private static _applyPlugin;
|
|
@@ -260,17 +269,13 @@ declare class Error0 extends Error {
|
|
|
260
269
|
constructor(input: {
|
|
261
270
|
message: string;
|
|
262
271
|
} & ErrorInput<EmptyPluginsMap>);
|
|
263
|
-
private static
|
|
264
|
-
private static readonly isOwnProperty;
|
|
265
|
-
private static _ownByKey;
|
|
266
|
-
private static _flowByKey;
|
|
272
|
+
private static fixStack;
|
|
267
273
|
static own<TThis extends typeof Error0>(this: TThis, error: unknown): ErrorOwnProps<PluginsMapOf<TThis>>;
|
|
268
274
|
static own<TThis extends typeof Error0, TKey extends keyof PluginsMapOf<TThis>['props'] & string>(this: TThis, error: unknown, key: TKey): ErrorOwnProps<PluginsMapOf<TThis>>[TKey];
|
|
269
|
-
own<TThis extends Error0>(this: TThis): ErrorOwnProps<PluginsMapOfInstance<TThis>>;
|
|
270
|
-
own<TThis extends Error0, TKey extends keyof PluginsMapOfInstance<TThis>['props'] & string>(this: TThis, key: TKey): ErrorOwnProps<PluginsMapOfInstance<TThis>>[TKey];
|
|
271
275
|
static flow<TThis extends typeof Error0, TKey extends keyof PluginsMapOf<TThis>['props'] & string>(this: TThis, error: unknown, key: TKey): Array<ErrorOwnProps<PluginsMapOf<TThis>>[TKey]>;
|
|
272
276
|
flow<TThis extends Error0, TKey extends keyof PluginsMapOfInstance<TThis>['props'] & string>(this: TThis, key: TKey): Array<ErrorOwnProps<PluginsMapOfInstance<TThis>>[TKey]>;
|
|
273
|
-
|
|
277
|
+
private readonly _resolveByKeyCache;
|
|
278
|
+
private _resolveByKey;
|
|
274
279
|
static resolve<TThis extends typeof Error0>(this: TThis, error: unknown): ErrorResolvedProps<PluginsMapOf<TThis>>;
|
|
275
280
|
static resolve(error: unknown): Record<string, unknown>;
|
|
276
281
|
resolve<TThis extends Error0>(this: TThis): ErrorResolvedProps<PluginsMapOfInstance<TThis>>;
|
|
@@ -280,8 +285,11 @@ declare class Error0 extends Error {
|
|
|
280
285
|
causes<TThis extends Error0>(this: TThis, instancesOnly: true): [TThis, ...TThis[]];
|
|
281
286
|
static is<T extends typeof Error0>(this: T, error: unknown): error is InstanceType<T>;
|
|
282
287
|
static isSerialized(error: unknown): error is Record<string, unknown>;
|
|
283
|
-
static from(error: unknown):
|
|
284
|
-
static round(error: unknown, isPublic?: boolean):
|
|
288
|
+
static from<TThis extends typeof Error0>(this: TThis, error: unknown): InstanceType<TThis>;
|
|
289
|
+
static round<TThis extends typeof Error0>(this: TThis, error: unknown, isPublic?: boolean): InstanceType<TThis>;
|
|
290
|
+
round<TThis extends Error0>(this: TThis, isPublic?: boolean): TThis;
|
|
291
|
+
static assign<TThis extends typeof Error0>(this: TThis, error: unknown, props: Partial<ErrorOwnProps<PluginsMapOf<TThis>>>): InstanceType<TThis>;
|
|
292
|
+
assign<TThis extends Error0>(this: TThis, props: Partial<ErrorOwnProps<PluginsMapOfInstance<TThis>>>): TThis;
|
|
285
293
|
private static _applyAdapt;
|
|
286
294
|
private static _fromSerialized;
|
|
287
295
|
private static _fromNonError0;
|
|
@@ -289,7 +297,7 @@ declare class Error0 extends Error {
|
|
|
289
297
|
private static _useWithPlugin;
|
|
290
298
|
private static _pluginFromBuilder;
|
|
291
299
|
static use<TThis extends typeof Error0, TBuilder extends PluginError0>(this: TThis, plugin: TBuilder): ClassError0<ExtendErrorPluginsMap<PluginsMapOf<TThis>, PluginOfBuilder<TBuilder>>>;
|
|
292
|
-
static use<TThis extends typeof Error0, TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(this: TThis, kind: 'prop', key: TKey, value:
|
|
300
|
+
static use<TThis extends typeof Error0, TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(this: TThis, kind: 'prop', key: TKey, value: ErrorPluginPropOptionsDefinition<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>, TResolveValue>): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue, TResolveValue>>;
|
|
293
301
|
static use<TThis extends typeof Error0, TKey extends string, TMethod extends (error: ErrorInstanceOfMap<PluginsMapOf<TThis>>, ...args: any[]) => any>(this: TThis, kind: 'method', key: TKey, value: TMethod): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TMethod>>;
|
|
294
302
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'adapt', value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorResolvedProps<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
295
303
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'stack', value: ErrorPluginStack<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
@@ -298,7 +306,6 @@ declare class Error0 extends Error {
|
|
|
298
306
|
static plugin(): PluginError0;
|
|
299
307
|
static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
|
|
300
308
|
serialize(isPublic?: boolean): Record<string, unknown>;
|
|
301
|
-
round<TThis extends Error0>(this: TThis, isPublic?: boolean): TThis;
|
|
302
309
|
}
|
|
303
310
|
|
|
304
|
-
export { type ClassError0, Error0, type
|
|
311
|
+
export { type ClassError0, Error0, type ErrorPlugin, type InstanceError0, PluginError0 };
|
|
@@ -1,8 +1,46 @@
|
|
|
1
|
-
import { PluginError0,
|
|
1
|
+
import { PluginError0, Error0 } from '../index.cjs';
|
|
2
2
|
|
|
3
3
|
declare const codePlugin: <TCode extends string>({ codes, isPublic, }?: {
|
|
4
4
|
codes?: TCode[];
|
|
5
5
|
isPublic?: boolean;
|
|
6
|
-
}) => PluginError0<Record<never, never> & Record<"code",
|
|
6
|
+
}) => PluginError0<Record<never, never> & Record<"code", ({
|
|
7
|
+
resolve: (options: {
|
|
8
|
+
own: TCode | undefined;
|
|
9
|
+
flow: (TCode | undefined)[];
|
|
10
|
+
error: Error0;
|
|
11
|
+
}) => TCode | undefined;
|
|
12
|
+
serialize: false | ((options: {
|
|
13
|
+
own: TCode | undefined;
|
|
14
|
+
flow: (TCode | undefined)[];
|
|
15
|
+
resolved: TCode | undefined;
|
|
16
|
+
error: Error0;
|
|
17
|
+
isPublic: boolean;
|
|
18
|
+
}) => unknown);
|
|
19
|
+
deserialize: false | ((options: {
|
|
20
|
+
value: unknown;
|
|
21
|
+
record: Record<string, unknown>;
|
|
22
|
+
}) => TCode | undefined);
|
|
23
|
+
} & {
|
|
24
|
+
init: ((input: TCode) => TCode) | (() => TCode);
|
|
25
|
+
}) | ({
|
|
26
|
+
resolve: (options: {
|
|
27
|
+
own: TCode | undefined;
|
|
28
|
+
flow: (TCode | undefined)[];
|
|
29
|
+
error: Error0;
|
|
30
|
+
}) => TCode | undefined;
|
|
31
|
+
serialize: false | ((options: {
|
|
32
|
+
own: TCode | undefined;
|
|
33
|
+
flow: (TCode | undefined)[];
|
|
34
|
+
resolved: TCode | undefined;
|
|
35
|
+
error: Error0;
|
|
36
|
+
isPublic: boolean;
|
|
37
|
+
}) => unknown);
|
|
38
|
+
deserialize: false | ((options: {
|
|
39
|
+
value: unknown;
|
|
40
|
+
record: Record<string, unknown>;
|
|
41
|
+
}) => TCode | undefined);
|
|
42
|
+
} & {
|
|
43
|
+
init?: undefined;
|
|
44
|
+
})>, Record<never, never>>;
|
|
7
45
|
|
|
8
46
|
export { codePlugin };
|
|
@@ -1,25 +1,67 @@
|
|
|
1
|
-
import { Error0, PluginError0
|
|
1
|
+
import { Error0, PluginError0 } from '../index.cjs';
|
|
2
2
|
|
|
3
3
|
declare const expectedPlugin: <TError extends Error0>({ isPublic, override, }?: {
|
|
4
4
|
isPublic?: boolean;
|
|
5
5
|
override?: (error: TError) => boolean | undefined;
|
|
6
|
-
}) => PluginError0<Record<never, never> & Record<"expected",
|
|
6
|
+
}) => PluginError0<Record<never, never> & Record<"expected", ({
|
|
7
|
+
resolve: (options: {
|
|
8
|
+
own: boolean | undefined;
|
|
9
|
+
flow: (boolean | undefined)[];
|
|
10
|
+
error: Error0;
|
|
11
|
+
}) => boolean;
|
|
12
|
+
serialize: false | ((options: {
|
|
13
|
+
own: boolean | undefined;
|
|
14
|
+
flow: (boolean | undefined)[];
|
|
15
|
+
resolved: boolean;
|
|
16
|
+
error: Error0;
|
|
17
|
+
isPublic: boolean;
|
|
18
|
+
}) => unknown);
|
|
19
|
+
deserialize: false | ((options: {
|
|
20
|
+
value: unknown;
|
|
21
|
+
record: Record<string, unknown>;
|
|
22
|
+
}) => boolean | undefined);
|
|
23
|
+
} & {
|
|
24
|
+
init: ((input: boolean) => boolean) | (() => boolean);
|
|
25
|
+
}) | ({
|
|
26
|
+
resolve: (options: {
|
|
27
|
+
own: boolean | undefined;
|
|
28
|
+
flow: (boolean | undefined)[];
|
|
29
|
+
error: Error0;
|
|
30
|
+
}) => boolean;
|
|
31
|
+
serialize: false | ((options: {
|
|
32
|
+
own: boolean | undefined;
|
|
33
|
+
flow: (boolean | undefined)[];
|
|
34
|
+
resolved: boolean;
|
|
35
|
+
error: Error0;
|
|
36
|
+
isPublic: boolean;
|
|
37
|
+
}) => unknown);
|
|
38
|
+
deserialize: false | ((options: {
|
|
39
|
+
value: unknown;
|
|
40
|
+
record: Record<string, unknown>;
|
|
41
|
+
}) => boolean | undefined);
|
|
42
|
+
} & {
|
|
43
|
+
init?: undefined;
|
|
44
|
+
})>, Record<never, never> & Record<"isExpected", (error: Error0 & {
|
|
7
45
|
expected: boolean;
|
|
8
46
|
} & {} & {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
expected: boolean | undefined;
|
|
12
|
-
};
|
|
13
|
-
<TKey extends "expected">(key: TKey): {
|
|
14
|
-
expected: boolean | undefined;
|
|
15
|
-
}[TKey];
|
|
47
|
+
resolve: () => {
|
|
48
|
+
expected: boolean;
|
|
16
49
|
};
|
|
50
|
+
} & {
|
|
51
|
+
own?: Partial<{
|
|
52
|
+
expected: boolean | undefined;
|
|
53
|
+
}> | undefined;
|
|
17
54
|
flow: <TKey extends "expected">(key: TKey) => {
|
|
18
55
|
expected: boolean | undefined;
|
|
19
56
|
}[TKey][];
|
|
20
|
-
|
|
21
|
-
|
|
57
|
+
assign: (props: Partial<{
|
|
58
|
+
expected: boolean | undefined;
|
|
59
|
+
}>) => Error0 & {
|
|
22
60
|
expected: boolean;
|
|
61
|
+
} & {} & {
|
|
62
|
+
resolve: () => {
|
|
63
|
+
expected: boolean;
|
|
64
|
+
};
|
|
23
65
|
};
|
|
24
66
|
} & {
|
|
25
67
|
readonly __pluginsMap?: {
|
|
@@ -1,7 +1,45 @@
|
|
|
1
|
-
import { PluginError0,
|
|
1
|
+
import { PluginError0, Error0 } from '../index.cjs';
|
|
2
2
|
|
|
3
3
|
declare const metaPlugin: ({ isPublic }?: {
|
|
4
4
|
isPublic?: boolean;
|
|
5
|
-
}) => PluginError0<Record<never, never> & Record<"meta",
|
|
5
|
+
}) => PluginError0<Record<never, never> & Record<"meta", ({
|
|
6
|
+
resolve: (options: {
|
|
7
|
+
own: Record<string, unknown> | undefined;
|
|
8
|
+
flow: (Record<string, unknown> | undefined)[];
|
|
9
|
+
error: Error0;
|
|
10
|
+
}) => Record<string, unknown> | undefined;
|
|
11
|
+
serialize: false | ((options: {
|
|
12
|
+
own: Record<string, unknown> | undefined;
|
|
13
|
+
flow: (Record<string, unknown> | undefined)[];
|
|
14
|
+
resolved: Record<string, unknown> | undefined;
|
|
15
|
+
error: Error0;
|
|
16
|
+
isPublic: boolean;
|
|
17
|
+
}) => unknown);
|
|
18
|
+
deserialize: false | ((options: {
|
|
19
|
+
value: unknown;
|
|
20
|
+
record: Record<string, unknown>;
|
|
21
|
+
}) => Record<string, unknown> | undefined);
|
|
22
|
+
} & {
|
|
23
|
+
init: ((input: Record<string, unknown>) => Record<string, unknown>) | (() => Record<string, unknown>);
|
|
24
|
+
}) | ({
|
|
25
|
+
resolve: (options: {
|
|
26
|
+
own: Record<string, unknown> | undefined;
|
|
27
|
+
flow: (Record<string, unknown> | undefined)[];
|
|
28
|
+
error: Error0;
|
|
29
|
+
}) => Record<string, unknown> | undefined;
|
|
30
|
+
serialize: false | ((options: {
|
|
31
|
+
own: Record<string, unknown> | undefined;
|
|
32
|
+
flow: (Record<string, unknown> | undefined)[];
|
|
33
|
+
resolved: Record<string, unknown> | undefined;
|
|
34
|
+
error: Error0;
|
|
35
|
+
isPublic: boolean;
|
|
36
|
+
}) => unknown);
|
|
37
|
+
deserialize: false | ((options: {
|
|
38
|
+
value: unknown;
|
|
39
|
+
record: Record<string, unknown>;
|
|
40
|
+
}) => Record<string, unknown> | undefined);
|
|
41
|
+
} & {
|
|
42
|
+
init?: undefined;
|
|
43
|
+
})>, Record<never, never>>;
|
|
6
44
|
|
|
7
45
|
export { metaPlugin };
|
|
@@ -30,9 +30,9 @@ const stackMergePlugin = ({
|
|
|
30
30
|
if (!isPublic && _isPublic) {
|
|
31
31
|
return void 0;
|
|
32
32
|
}
|
|
33
|
-
return error.causes().
|
|
34
|
-
return cause instanceof Error ? cause.stack :
|
|
35
|
-
}).
|
|
33
|
+
return error.causes().flatMap((cause) => {
|
|
34
|
+
return cause instanceof Error && cause.stack && typeof cause.stack === "string" ? cause.stack : [];
|
|
35
|
+
}).join(delimiter);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/stack-merge.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const stackMergePlugin = ({\n isPublic = false,\n delimiter = '\\n',\n}: { isPublic?: boolean; delimiter?: string } = {}) =>\n Error0.plugin().stack({\n serialize: ({ error, isPublic: _isPublic }) => {\n if (!isPublic && _isPublic) {\n return undefined\n }\n return error\n .causes()\n .
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/stack-merge.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const stackMergePlugin = ({\n isPublic = false,\n delimiter = '\\n',\n}: { isPublic?: boolean; delimiter?: string } = {}) =>\n Error0.plugin().stack({\n serialize: ({ error, isPublic: _isPublic }) => {\n if (!isPublic && _isPublic) {\n return undefined\n }\n return error\n .causes()\n .flatMap((cause) => {\n return cause instanceof Error && cause.stack && typeof cause.stack === 'string' ? cause.stack : []\n })\n .join(delimiter)\n },\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,mBAAmB,CAAC;AAAA,EAC/B,WAAW;AAAA,EACX,YAAY;AACd,IAAgD,CAAC,MAC/C,gBAAO,OAAO,EAAE,MAAM;AAAA,EACpB,WAAW,CAAC,EAAE,OAAO,UAAU,UAAU,MAAM;AAC7C,QAAI,CAAC,YAAY,WAAW;AAC1B,aAAO;AAAA,IACT;AACA,WAAO,MACJ,OAAO,EACP,QAAQ,CAAC,UAAU;AAClB,aAAO,iBAAiB,SAAS,MAAM,SAAS,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ,CAAC;AAAA,IACnG,CAAC,EACA,KAAK,SAAS;AAAA,EACnB;AACF,CAAC;","names":[]}
|
|
@@ -1,9 +1,47 @@
|
|
|
1
|
-
import { PluginError0,
|
|
1
|
+
import { PluginError0, Error0 } from '../index.cjs';
|
|
2
2
|
|
|
3
3
|
declare const statusPlugin: <TStatuses extends Record<string, number> = Record<never, number>>({ isPublic, statuses, strict, }?: {
|
|
4
4
|
isPublic?: boolean;
|
|
5
5
|
statuses?: TStatuses;
|
|
6
6
|
strict?: boolean;
|
|
7
|
-
}) => PluginError0<Record<never, never> & Record<"status",
|
|
7
|
+
}) => PluginError0<Record<never, never> & Record<"status", ({
|
|
8
|
+
resolve: (options: {
|
|
9
|
+
own: number | undefined;
|
|
10
|
+
flow: (number | undefined)[];
|
|
11
|
+
error: Error0;
|
|
12
|
+
}) => number | undefined;
|
|
13
|
+
serialize: false | ((options: {
|
|
14
|
+
own: number | undefined;
|
|
15
|
+
flow: (number | undefined)[];
|
|
16
|
+
resolved: number | undefined;
|
|
17
|
+
error: Error0;
|
|
18
|
+
isPublic: boolean;
|
|
19
|
+
}) => unknown);
|
|
20
|
+
deserialize: false | ((options: {
|
|
21
|
+
value: unknown;
|
|
22
|
+
record: Record<string, unknown>;
|
|
23
|
+
}) => number | undefined);
|
|
24
|
+
} & {
|
|
25
|
+
init: ((input: number | Extract<keyof TStatuses, string>) => number | undefined) | (() => number | undefined);
|
|
26
|
+
}) | ({
|
|
27
|
+
resolve: (options: {
|
|
28
|
+
own: number | undefined;
|
|
29
|
+
flow: (number | undefined)[];
|
|
30
|
+
error: Error0;
|
|
31
|
+
}) => number | undefined;
|
|
32
|
+
serialize: false | ((options: {
|
|
33
|
+
own: number | undefined;
|
|
34
|
+
flow: (number | undefined)[];
|
|
35
|
+
resolved: number | undefined;
|
|
36
|
+
error: Error0;
|
|
37
|
+
isPublic: boolean;
|
|
38
|
+
}) => unknown);
|
|
39
|
+
deserialize: false | ((options: {
|
|
40
|
+
value: unknown;
|
|
41
|
+
record: Record<string, unknown>;
|
|
42
|
+
}) => number | undefined);
|
|
43
|
+
} & {
|
|
44
|
+
init?: undefined;
|
|
45
|
+
})>, Record<never, never>>;
|
|
8
46
|
|
|
9
47
|
export { statusPlugin };
|
|
@@ -1,26 +1,68 @@
|
|
|
1
|
-
import { PluginError0,
|
|
1
|
+
import { PluginError0, Error0 } from '../index.cjs';
|
|
2
2
|
|
|
3
3
|
declare const tagsPlugin: <TTag extends string>({ isPublic, tags, strict, }?: {
|
|
4
4
|
isPublic?: boolean;
|
|
5
5
|
tags?: TTag[] | readonly TTag[];
|
|
6
6
|
strict?: boolean;
|
|
7
|
-
}) => PluginError0<Record<never, never> & Record<"tags",
|
|
7
|
+
}) => PluginError0<Record<never, never> & Record<"tags", ({
|
|
8
|
+
resolve: (options: {
|
|
9
|
+
own: string[] | undefined;
|
|
10
|
+
flow: (string[] | undefined)[];
|
|
11
|
+
error: Error0;
|
|
12
|
+
}) => string[] | undefined;
|
|
13
|
+
serialize: false | ((options: {
|
|
14
|
+
own: string[] | undefined;
|
|
15
|
+
flow: (string[] | undefined)[];
|
|
16
|
+
resolved: string[] | undefined;
|
|
17
|
+
error: Error0;
|
|
18
|
+
isPublic: boolean;
|
|
19
|
+
}) => unknown);
|
|
20
|
+
deserialize: false | ((options: {
|
|
21
|
+
value: unknown;
|
|
22
|
+
record: Record<string, unknown>;
|
|
23
|
+
}) => string[] | undefined);
|
|
24
|
+
} & {
|
|
25
|
+
init: ((input: string[]) => string[]) | (() => string[]);
|
|
26
|
+
}) | ({
|
|
27
|
+
resolve: (options: {
|
|
28
|
+
own: string[] | undefined;
|
|
29
|
+
flow: (string[] | undefined)[];
|
|
30
|
+
error: Error0;
|
|
31
|
+
}) => string[] | undefined;
|
|
32
|
+
serialize: false | ((options: {
|
|
33
|
+
own: string[] | undefined;
|
|
34
|
+
flow: (string[] | undefined)[];
|
|
35
|
+
resolved: string[] | undefined;
|
|
36
|
+
error: Error0;
|
|
37
|
+
isPublic: boolean;
|
|
38
|
+
}) => unknown);
|
|
39
|
+
deserialize: false | ((options: {
|
|
40
|
+
value: unknown;
|
|
41
|
+
record: Record<string, unknown>;
|
|
42
|
+
}) => string[] | undefined);
|
|
43
|
+
} & {
|
|
44
|
+
init?: undefined;
|
|
45
|
+
})>, Record<never, never> & Record<"hasTag", (error: Error0 & {
|
|
8
46
|
tags: string[] | undefined;
|
|
9
47
|
} & {} & {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
tags: string[] | undefined;
|
|
13
|
-
};
|
|
14
|
-
<TKey extends "tags">(key: TKey): {
|
|
15
|
-
tags: string[] | undefined;
|
|
16
|
-
}[TKey];
|
|
48
|
+
resolve: () => {
|
|
49
|
+
tags: string[] | undefined;
|
|
17
50
|
};
|
|
51
|
+
} & {
|
|
52
|
+
own?: Partial<{
|
|
53
|
+
tags: string[] | undefined;
|
|
54
|
+
}> | undefined;
|
|
18
55
|
flow: <TKey extends "tags">(key: TKey) => {
|
|
19
56
|
tags: string[] | undefined;
|
|
20
57
|
}[TKey][];
|
|
21
|
-
|
|
22
|
-
resolve: () => {
|
|
58
|
+
assign: (props: Partial<{
|
|
23
59
|
tags: string[] | undefined;
|
|
60
|
+
}>) => Error0 & {
|
|
61
|
+
tags: string[] | undefined;
|
|
62
|
+
} & {} & {
|
|
63
|
+
resolve: () => {
|
|
64
|
+
tags: string[] | undefined;
|
|
65
|
+
};
|
|
24
66
|
};
|
|
25
67
|
} & {
|
|
26
68
|
readonly __pluginsMap?: {
|