@devp0nt/error0 1.0.0-next.41 → 1.0.0-next.42

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,44 +1,52 @@
1
- type ErrorExtensionPropOptions<TInputValue, TOutputValue, TError extends Error0 = Error0> = {
2
- init: (input: TInputValue) => TOutputValue;
1
+ type IsUnknown<T> = unknown extends T ? ([T] extends [unknown] ? true : false) : false;
2
+ type NormalizeUnknownToUndefined<T> = IsUnknown<T> extends true ? undefined : T;
3
+ type IsOnlyUndefined<T> = [Exclude<T, undefined>] extends [never] ? true : false;
4
+ type InferFirstArg<TFn> = TFn extends (...args: infer TArgs) => unknown ? TArgs extends [infer TFirst, ...unknown[]] ? TFirst : undefined : undefined;
5
+ type InferPluginPropInput<TProp extends ErrorPluginPropOptions<any, any, any>> = NormalizeUnknownToUndefined<InferFirstArg<TProp['init']>>;
6
+ type ErrorPluginPropInit<TInputValue, TOutputValue> = ((input: TInputValue) => TOutputValue) | (() => TOutputValue);
7
+ type ErrorPluginPropSerialize<TOutputValue, TError extends Error0> = ((options: {
8
+ value: TOutputValue;
9
+ error: TError;
10
+ isPublic: boolean;
11
+ }) => unknown) | false;
12
+ type ErrorPluginPropDeserialize<TOutputValue> = ((options: {
13
+ value: unknown;
14
+ serialized: Record<string, unknown>;
15
+ }) => TOutputValue | undefined) | false;
16
+ type ErrorPluginPropOptions<TInputValue, TOutputValue, TError extends Error0 = Error0> = {
17
+ init: ErrorPluginPropInit<TInputValue, TOutputValue>;
3
18
  resolve: (options: {
4
19
  value: TOutputValue | undefined;
5
20
  flow: Array<TOutputValue | undefined>;
6
21
  error: TError;
7
22
  }) => 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;
23
+ serialize: ErrorPluginPropSerialize<TOutputValue, TError>;
24
+ deserialize: ErrorPluginPropDeserialize<TOutputValue>;
17
25
  };
18
- type ErrorExtensionMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
19
- type ErrorExtensionRefineResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
20
- type ErrorExtensionRefineFn<TError extends Error0 = Error0, TOutputProps extends Record<string, unknown> = Record<never, never>> = ((error: TError) => void) | ((error: TError) => ErrorExtensionRefineResult<TOutputProps>);
26
+ type ErrorPluginMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
27
+ type ErrorPluginAdaptResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
28
+ type ErrorPluginAdaptFn<TError extends Error0 = Error0, TOutputProps extends Record<string, unknown> = Record<never, never>> = ((error: TError) => void) | ((error: TError) => ErrorPluginAdaptResult<TOutputProps>);
21
29
  type ErrorMethodRecord = {
22
30
  args: unknown[];
23
31
  output: unknown;
24
32
  };
25
- type ErrorExtensionProps = {
26
- [key: string]: ErrorExtensionPropOptions<any, any>;
33
+ type ErrorPluginProps = {
34
+ [key: string]: ErrorPluginPropOptions<any, any>;
27
35
  };
28
- type ErrorExtensionMethods = {
29
- [key: string]: ErrorExtensionMethodFn<any, any[]>;
36
+ type ErrorPluginMethods = {
37
+ [key: string]: ErrorPluginMethodFn<any, any[]>;
30
38
  };
31
- type ErrorExtension<TProps extends ErrorExtensionProps = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> = {
39
+ type ErrorPlugin<TProps extends ErrorPluginProps = Record<never, never>, TMethods extends ErrorPluginMethods = Record<never, never>> = {
32
40
  props?: TProps;
33
41
  methods?: TMethods;
34
- refine?: Array<ErrorExtensionRefineFn<Error0, ExtensionOutputProps<TProps>>>;
42
+ adapt?: Array<ErrorPluginAdaptFn<Error0, PluginOutputProps<TProps>>>;
35
43
  };
36
- type AddPropToExtensionProps<TProps extends ErrorExtensionProps, TKey extends string, TInputValue, TOutputValue> = TProps & Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>;
37
- type AddMethodToExtensionMethods<TMethods extends ErrorExtensionMethods, TKey extends string, TArgs extends unknown[], TOutputValue> = TMethods & Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>;
38
- type ExtensionOutputProps<TProps extends ErrorExtensionProps> = {
39
- [TKey in keyof TProps]: TProps[TKey] extends ErrorExtensionPropOptions<any, infer TOutputValue> ? TOutputValue : never;
44
+ type AddPropToPluginProps<TProps extends ErrorPluginProps, TKey extends string, TInputValue, TOutputValue> = TProps & Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue>>;
45
+ type AddMethodToPluginMethods<TMethods extends ErrorPluginMethods, TKey extends string, TArgs extends unknown[], TOutputValue> = TMethods & Record<TKey, ErrorPluginMethodFn<TOutputValue, TArgs>>;
46
+ type PluginOutputProps<TProps extends ErrorPluginProps> = {
47
+ [TKey in keyof TProps]: TProps[TKey] extends ErrorPluginPropOptions<any, infer TOutputValue> ? TOutputValue : never;
40
48
  };
41
- type ErrorExtensionsMap = {
49
+ type ErrorPluginsMap = {
42
50
  props: Record<string, {
43
51
  init: unknown;
44
52
  resolve: unknown;
@@ -49,103 +57,104 @@ type IsEmptyObject<T> = keyof T extends never ? true : false;
49
57
  type ErrorInputBase = {
50
58
  cause?: unknown;
51
59
  };
52
- type ErrorInput<TExtensionsMap extends ErrorExtensionsMap> = IsEmptyObject<TExtensionsMap['props']> extends true ? ErrorInputBase : ErrorInputBase & Partial<{
53
- [TKey in keyof TExtensionsMap['props']]: TExtensionsMap['props'][TKey]['init'];
54
- }>;
55
- type ErrorOutputProps<TExtensionsMap extends ErrorExtensionsMap> = {
56
- [TKey in keyof TExtensionsMap['props']]?: TExtensionsMap['props'][TKey]['resolve'];
60
+ type ErrorInputPluginProps<TPluginsMap extends ErrorPluginsMap> = {
61
+ [TKey in keyof TPluginsMap['props'] as IsOnlyUndefined<TPluginsMap['props'][TKey]['init']> extends true ? never : TKey]?: TPluginsMap['props'][TKey]['init'];
62
+ };
63
+ type ErrorInput<TPluginsMap extends ErrorPluginsMap> = IsEmptyObject<TPluginsMap['props']> extends true ? ErrorInputBase : ErrorInputBase & ErrorInputPluginProps<TPluginsMap>;
64
+ type ErrorOutputProps<TPluginsMap extends ErrorPluginsMap> = {
65
+ [TKey in keyof TPluginsMap['props']]: TPluginsMap['props'][TKey]['resolve'] | undefined;
57
66
  };
58
- type ErrorOutputMethods<TExtensionsMap extends ErrorExtensionsMap> = {
59
- [TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
67
+ type ErrorOutputMethods<TPluginsMap extends ErrorPluginsMap> = {
68
+ [TKey in keyof TPluginsMap['methods']]: TPluginsMap['methods'][TKey] extends {
60
69
  args: infer TArgs extends unknown[];
61
70
  output: infer TOutput;
62
71
  } ? (...args: TArgs) => TOutput : never;
63
72
  };
64
- type ErrorOutput<TExtensionsMap extends ErrorExtensionsMap> = ErrorOutputProps<TExtensionsMap> & ErrorOutputMethods<TExtensionsMap>;
65
- type ErrorStaticMethods<TExtensionsMap extends ErrorExtensionsMap> = {
66
- [TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {
73
+ type ErrorOutput<TPluginsMap extends ErrorPluginsMap> = ErrorOutputProps<TPluginsMap> & ErrorOutputMethods<TPluginsMap>;
74
+ type ErrorStaticMethods<TPluginsMap extends ErrorPluginsMap> = {
75
+ [TKey in keyof TPluginsMap['methods']]: TPluginsMap['methods'][TKey] extends {
67
76
  args: infer TArgs extends unknown[];
68
77
  output: infer TOutput;
69
78
  } ? (error: unknown, ...args: TArgs) => TOutput : never;
70
79
  };
71
- type EmptyExtensionsMap = {
80
+ type EmptyPluginsMap = {
72
81
  props: Record<never, {
73
82
  init: never;
74
83
  resolve: never;
75
84
  }>;
76
85
  methods: Record<never, ErrorMethodRecord>;
77
86
  };
78
- type ExtensionPropsMapOf<TExtension extends ErrorExtension> = {
79
- [TKey in keyof NonNullable<TExtension['props']>]: NonNullable<TExtension['props']>[TKey] extends ErrorExtensionPropOptions<infer TInputValue, infer TOutputValue> ? {
80
- init: TInputValue;
87
+ type PluginPropsMapOf<TPlugin extends ErrorPlugin> = {
88
+ [TKey in keyof NonNullable<TPlugin['props']>]: NonNullable<TPlugin['props']>[TKey] extends ErrorPluginPropOptions<any, infer TOutputValue> ? {
89
+ init: InferPluginPropInput<NonNullable<TPlugin['props']>[TKey]>;
81
90
  resolve: TOutputValue;
82
91
  } : never;
83
92
  };
84
- type ExtensionMethodsMapOf<TExtension extends ErrorExtension> = {
85
- [TKey in keyof NonNullable<TExtension['methods']>]: NonNullable<TExtension['methods']>[TKey] extends (error: Error0, ...args: infer TArgs extends unknown[]) => infer TOutput ? {
93
+ type PluginMethodsMapOf<TPlugin extends ErrorPlugin> = {
94
+ [TKey in keyof NonNullable<TPlugin['methods']>]: NonNullable<TPlugin['methods']>[TKey] extends (error: Error0, ...args: infer TArgs extends unknown[]) => infer TOutput ? {
86
95
  args: TArgs;
87
96
  output: TOutput;
88
97
  } : never;
89
98
  };
90
- type ErrorExtensionsMapOfExtension<TExtension extends ErrorExtension> = {
91
- props: ExtensionPropsMapOf<TExtension>;
92
- methods: ExtensionMethodsMapOf<TExtension>;
93
- };
94
- type ExtendErrorExtensionsMap<TMap extends ErrorExtensionsMap, TExtension extends ErrorExtension> = {
95
- props: TMap['props'] & ErrorExtensionsMapOfExtension<TExtension>['props'];
96
- methods: TMap['methods'] & ErrorExtensionsMapOfExtension<TExtension>['methods'];
97
- };
98
- type ExtendErrorExtensionsMapWithProp<TMap extends ErrorExtensionsMap, TKey extends string, TInputValue, TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>>>;
99
- type ExtendErrorExtensionsMapWithMethod<TMap extends ErrorExtensionsMap, TKey extends string, TArgs extends unknown[], TOutputValue> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<never, never>, Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>>>;
100
- type ExtensionsMapOf<TClass> = TClass extends {
101
- __extensionsMap?: infer TExtensionsMap;
102
- } ? TExtensionsMap extends ErrorExtensionsMap ? TExtensionsMap : EmptyExtensionsMap : EmptyExtensionsMap;
103
- type ExtensionsMapFromParts<TProps extends ErrorExtensionProps, TMethods extends ErrorExtensionMethods> = ErrorExtensionsMapOfExtension<ErrorExtension<TProps, TMethods>>;
104
- type ErrorInstanceOfMap<TMap extends ErrorExtensionsMap> = Error0 & ErrorOutput<TMap>;
105
- type BuilderError0<TProps extends ErrorExtensionProps, TMethods extends ErrorExtensionMethods> = Error0 & ErrorOutput<ExtensionsMapFromParts<TProps, TMethods>>;
106
- type ExtensionOfBuilder<TBuilder> = TBuilder extends ExtensionError0<infer TProps, infer TMethods> ? ErrorExtension<TProps, TMethods> : never;
107
- declare class ExtensionError0<TProps extends ErrorExtensionProps = Record<never, never>, TMethods extends ErrorExtensionMethods = Record<never, never>> {
108
- private readonly _extension;
99
+ type ErrorPluginsMapOfPlugin<TPlugin extends ErrorPlugin> = {
100
+ props: PluginPropsMapOf<TPlugin>;
101
+ methods: PluginMethodsMapOf<TPlugin>;
102
+ };
103
+ type ExtendErrorPluginsMap<TMap extends ErrorPluginsMap, TPlugin extends ErrorPlugin> = {
104
+ props: TMap['props'] & ErrorPluginsMapOfPlugin<TPlugin>['props'];
105
+ methods: TMap['methods'] & ErrorPluginsMapOfPlugin<TPlugin>['methods'];
106
+ };
107
+ type ExtendErrorPluginsMapWithProp<TMap extends ErrorPluginsMap, TKey extends string, TInputValue, TOutputValue> = ExtendErrorPluginsMap<TMap, ErrorPlugin<Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue>>>>;
108
+ type ExtendErrorPluginsMapWithMethod<TMap extends ErrorPluginsMap, TKey extends string, TArgs extends unknown[], TOutputValue> = ExtendErrorPluginsMap<TMap, ErrorPlugin<Record<never, never>, Record<TKey, ErrorPluginMethodFn<TOutputValue, TArgs>>>>;
109
+ type PluginsMapOf<TClass> = TClass extends {
110
+ __pluginsMap?: infer TPluginsMap;
111
+ } ? TPluginsMap extends ErrorPluginsMap ? TPluginsMap : EmptyPluginsMap : EmptyPluginsMap;
112
+ type PluginsMapFromParts<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = ErrorPluginsMapOfPlugin<ErrorPlugin<TProps, TMethods>>;
113
+ type ErrorInstanceOfMap<TMap extends ErrorPluginsMap> = Error0 & ErrorOutput<TMap>;
114
+ type BuilderError0<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = Error0 & ErrorOutput<PluginsMapFromParts<TProps, TMethods>>;
115
+ type PluginOfBuilder<TBuilder> = TBuilder extends PluginError0<infer TProps, infer TMethods> ? ErrorPlugin<TProps, TMethods> : never;
116
+ declare class PluginError0<TProps extends ErrorPluginProps = Record<never, never>, TMethods extends ErrorPluginMethods = Record<never, never>> {
117
+ private readonly _plugin;
109
118
  readonly Infer: {
110
119
  props: TProps;
111
120
  methods: TMethods;
112
121
  };
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>;
122
+ constructor(plugin?: ErrorPlugin<ErrorPluginProps, ErrorPluginMethods>);
123
+ prop<TKey extends string, TInputValue, TOutputValue>(key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue>, TMethods>;
124
+ method<TKey extends string, TArgs extends unknown[], TOutputValue>(key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TArgs, TOutputValue>>;
125
+ adapt(value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
126
+ use<TKey extends string, TInputValue, TOutputValue>(kind: 'prop', key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue>, TMethods>;
127
+ use<TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TArgs, TOutputValue>>;
128
+ use(kind: 'adapt', value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
120
129
  }
121
- type ClassError0<TExtensionsMap extends ErrorExtensionsMap = EmptyExtensionsMap> = {
122
- new (message: string, input?: ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
130
+ type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {
131
+ new (message: string, input?: ErrorInput<TPluginsMap>): Error0 & ErrorOutput<TPluginsMap>;
123
132
  new (input: {
124
133
  message: string;
125
- } & ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>;
126
- readonly __extensionsMap?: TExtensionsMap;
127
- from: (error: unknown) => Error0 & ErrorOutput<TExtensionsMap>;
134
+ } & ErrorInput<TPluginsMap>): Error0 & ErrorOutput<TPluginsMap>;
135
+ readonly __pluginsMap?: TPluginsMap;
136
+ from: (error: unknown) => Error0 & ErrorOutput<TPluginsMap>;
128
137
  serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>;
129
- prop: <TKey extends string, TInputValue, TOutputValue>(key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TExtensionsMap>>) => ClassError0<ExtendErrorExtensionsMapWithProp<TExtensionsMap, TKey, TInputValue, TOutputValue>>;
130
- method: <TKey extends string, TArgs extends unknown[], TOutputValue>(key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>) => ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>;
131
- refine: (value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>) => ClassError0<TExtensionsMap>;
132
- extend: {
133
- <TBuilder extends ExtensionError0>(extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<TExtensionsMap, ExtensionOfBuilder<TBuilder>>>;
134
- <TKey extends string, TInputValue, TOutputValue>(kind: 'prop', key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TExtensionsMap>>): ClassError0<ExtendErrorExtensionsMapWithProp<TExtensionsMap, TKey, TInputValue, TOutputValue>>;
135
- <TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>): ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>;
136
- (kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>): ClassError0<TExtensionsMap>;
138
+ prop: <TKey extends string, TInputValue, TOutputValue>(key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>>) => ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue>>;
139
+ method: <TKey extends string, TArgs extends unknown[], TOutputValue>(key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TPluginsMap>>) => ClassError0<ExtendErrorPluginsMapWithMethod<TPluginsMap, TKey, TArgs, TOutputValue>>;
140
+ adapt: (value: ErrorPluginAdaptFn<ErrorInstanceOfMap<TPluginsMap>, ErrorOutputProps<TPluginsMap>>) => ClassError0<TPluginsMap>;
141
+ use: {
142
+ <TBuilder extends PluginError0>(plugin: TBuilder): ClassError0<ExtendErrorPluginsMap<TPluginsMap, PluginOfBuilder<TBuilder>>>;
143
+ <TKey extends string, TInputValue, TOutputValue>(kind: 'prop', key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>>): ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue>>;
144
+ <TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TPluginsMap>>): ClassError0<ExtendErrorPluginsMapWithMethod<TPluginsMap, TKey, TArgs, TOutputValue>>;
145
+ (kind: 'adapt', value: ErrorPluginAdaptFn<ErrorInstanceOfMap<TPluginsMap>, ErrorOutputProps<TPluginsMap>>): ClassError0<TPluginsMap>;
137
146
  };
138
- extension: () => ExtensionError0;
139
- } & ErrorStaticMethods<TExtensionsMap>;
147
+ plugin: () => PluginError0;
148
+ } & ErrorStaticMethods<TPluginsMap>;
140
149
  declare class Error0 extends Error {
141
- static readonly __extensionsMap?: EmptyExtensionsMap;
142
- protected static _extensions: ErrorExtension[];
143
- private static readonly _emptyExtension;
144
- private static _getResolvedExtension;
145
- constructor(message: string, input?: ErrorInput<EmptyExtensionsMap>);
150
+ static readonly __pluginsMap?: EmptyPluginsMap;
151
+ protected static _plugins: ErrorPlugin[];
152
+ private static readonly _emptyPlugin;
153
+ private static _getResolvedPlugin;
154
+ constructor(message: string, input?: ErrorInput<EmptyPluginsMap>);
146
155
  constructor(input: {
147
156
  message: string;
148
- } & ErrorInput<EmptyExtensionsMap>);
157
+ } & ErrorInput<EmptyPluginsMap>);
149
158
  private static readonly isSelfProperty;
150
159
  static own(error: object, key: string): unknown;
151
160
  own(key: string): unknown;
@@ -158,22 +167,22 @@ declare class Error0 extends Error {
158
167
  static is<T extends typeof Error0>(this: T, error: unknown): error is InstanceType<T>;
159
168
  static isSerialized(error: unknown): error is Record<string, unknown>;
160
169
  static from(error: unknown): Error0;
161
- private static _applyRefine;
170
+ private static _applyAdapt;
162
171
  private static _fromSerialized;
163
172
  private static _fromNonError0;
164
173
  private static _extractMessage;
165
- private static _extendWithExtension;
166
- private static _extensionFromBuilder;
167
- static prop<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(this: TThis, key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithProp<ExtensionsMapOf<TThis>, TKey, TInputValue, TOutputValue>>;
168
- static method<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithMethod<ExtensionsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
169
- static refine<TThis extends typeof Error0>(this: TThis, value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>): ClassError0<ExtensionsMapOf<TThis>>;
170
- static extend<TThis extends typeof Error0, TBuilder extends ExtensionError0>(this: TThis, extension: TBuilder): ClassError0<ExtendErrorExtensionsMap<ExtensionsMapOf<TThis>, ExtensionOfBuilder<TBuilder>>>;
171
- static extend<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(this: TThis, kind: 'prop', key: TKey, value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithProp<ExtensionsMapOf<TThis>, TKey, TInputValue, TOutputValue>>;
172
- static extend<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, kind: 'method', key: TKey, value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>): ClassError0<ExtendErrorExtensionsMapWithMethod<ExtensionsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
173
- static extend<TThis extends typeof Error0>(this: TThis, kind: 'refine', value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>): ClassError0<ExtensionsMapOf<TThis>>;
174
- static extension(): ExtensionError0;
174
+ private static _useWithPlugin;
175
+ private static _pluginFromBuilder;
176
+ static prop<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(this: TThis, key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue>>;
177
+ static method<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
178
+ static adapt<TThis extends typeof Error0>(this: TThis, value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorOutputProps<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
179
+ static use<TThis extends typeof Error0, TBuilder extends PluginError0>(this: TThis, plugin: TBuilder): ClassError0<ExtendErrorPluginsMap<PluginsMapOf<TThis>, PluginOfBuilder<TBuilder>>>;
180
+ static use<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(this: TThis, kind: 'prop', key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue>>;
181
+ static use<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, kind: 'method', key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
182
+ static use<TThis extends typeof Error0>(this: TThis, kind: 'adapt', value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorOutputProps<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
183
+ static plugin(): PluginError0;
175
184
  static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
176
185
  serialize(isPublic?: boolean): object;
177
186
  }
178
187
 
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 };
188
+ export { type ClassError0, Error0, type ErrorInput, type ErrorInputBase, type ErrorOutput, type ErrorPlugin, type ErrorPluginAdaptFn, type ErrorPluginAdaptResult, type ErrorPluginMethodFn, type ErrorPluginMethods, type ErrorPluginPropOptions, type ErrorPluginProps, type ErrorPluginsMap, type IsEmptyObject, PluginError0 };