@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.
- package/dist/cjs/index.cjs +77 -73
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +109 -100
- package/dist/esm/index.d.ts +109 -100
- package/dist/esm/index.js +76 -72
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +68 -36
- package/src/index.ts +258 -239
package/dist/cjs/index.cjs
CHANGED
|
@@ -19,74 +19,72 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var index_exports = {};
|
|
20
20
|
__export(index_exports, {
|
|
21
21
|
Error0: () => Error0,
|
|
22
|
-
|
|
22
|
+
PluginError0: () => PluginError0
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(index_exports);
|
|
25
|
-
class
|
|
26
|
-
|
|
25
|
+
class PluginError0 {
|
|
26
|
+
_plugin;
|
|
27
27
|
Infer = void 0;
|
|
28
|
-
constructor(
|
|
29
|
-
this.
|
|
30
|
-
props: { ...
|
|
31
|
-
methods: { ...
|
|
32
|
-
|
|
28
|
+
constructor(plugin) {
|
|
29
|
+
this._plugin = {
|
|
30
|
+
props: { ...plugin?.props ?? {} },
|
|
31
|
+
methods: { ...plugin?.methods ?? {} },
|
|
32
|
+
adapt: [...plugin?.adapt ?? []]
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
prop(key, value) {
|
|
36
|
-
return this.
|
|
36
|
+
return this.use("prop", key, value);
|
|
37
37
|
}
|
|
38
38
|
method(key, value) {
|
|
39
|
-
return this.
|
|
39
|
+
return this.use("method", key, value);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
return this.
|
|
41
|
+
adapt(value) {
|
|
42
|
+
return this.use("adapt", value);
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
const nextProps = { ...this.
|
|
46
|
-
const nextMethods = { ...this.
|
|
47
|
-
const
|
|
48
|
-
...this._extension.refine ?? []
|
|
49
|
-
];
|
|
44
|
+
use(kind, keyOrValue, value) {
|
|
45
|
+
const nextProps = { ...this._plugin.props ?? {} };
|
|
46
|
+
const nextMethods = { ...this._plugin.methods ?? {} };
|
|
47
|
+
const nextAdapt = [...this._plugin.adapt ?? []];
|
|
50
48
|
if (kind === "prop") {
|
|
51
49
|
const key = keyOrValue;
|
|
52
50
|
if (value === void 0) {
|
|
53
|
-
throw new Error('
|
|
51
|
+
throw new Error('PluginError0.use("prop", key, value) requires value');
|
|
54
52
|
}
|
|
55
53
|
nextProps[key] = value;
|
|
56
54
|
} else if (kind === "method") {
|
|
57
55
|
const key = keyOrValue;
|
|
58
56
|
if (value === void 0) {
|
|
59
|
-
throw new Error('
|
|
57
|
+
throw new Error('PluginError0.use("method", key, value) requires value');
|
|
60
58
|
}
|
|
61
59
|
nextMethods[key] = value;
|
|
62
60
|
} else {
|
|
63
|
-
|
|
61
|
+
nextAdapt.push(keyOrValue);
|
|
64
62
|
}
|
|
65
|
-
return new
|
|
63
|
+
return new PluginError0({
|
|
66
64
|
props: nextProps,
|
|
67
65
|
methods: nextMethods,
|
|
68
|
-
|
|
66
|
+
adapt: nextAdapt
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
class Error0 extends Error {
|
|
73
|
-
static
|
|
74
|
-
static
|
|
75
|
-
static
|
|
71
|
+
static __pluginsMap;
|
|
72
|
+
static _plugins = [];
|
|
73
|
+
static _emptyPlugin = {
|
|
76
74
|
props: {},
|
|
77
75
|
methods: {},
|
|
78
|
-
|
|
76
|
+
adapt: []
|
|
79
77
|
};
|
|
80
|
-
static
|
|
78
|
+
static _getResolvedPlugin() {
|
|
81
79
|
const resolved = {
|
|
82
80
|
props: {},
|
|
83
81
|
methods: {},
|
|
84
|
-
|
|
82
|
+
adapt: []
|
|
85
83
|
};
|
|
86
|
-
for (const
|
|
87
|
-
Object.assign(resolved.props,
|
|
88
|
-
Object.assign(resolved.methods,
|
|
89
|
-
resolved.
|
|
84
|
+
for (const plugin of this._plugins) {
|
|
85
|
+
Object.assign(resolved.props, plugin.props ?? this._emptyPlugin.props);
|
|
86
|
+
Object.assign(resolved.methods, plugin.methods ?? this._emptyPlugin.methods);
|
|
87
|
+
resolved.adapt.push(...plugin.adapt ?? this._emptyPlugin.adapt);
|
|
90
88
|
}
|
|
91
89
|
return resolved;
|
|
92
90
|
}
|
|
@@ -96,8 +94,8 @@ class Error0 extends Error {
|
|
|
96
94
|
super(input.message, { cause: input.cause });
|
|
97
95
|
this.name = "Error0";
|
|
98
96
|
const ctor = this.constructor;
|
|
99
|
-
const
|
|
100
|
-
for (const [key, prop] of Object.entries(
|
|
97
|
+
const plugin = ctor._getResolvedPlugin();
|
|
98
|
+
for (const [key, prop] of Object.entries(plugin.props)) {
|
|
101
99
|
if (key in input) {
|
|
102
100
|
const ownValue = input[key];
|
|
103
101
|
this[key] = prop.init(ownValue);
|
|
@@ -191,12 +189,12 @@ class Error0 extends Error {
|
|
|
191
189
|
}
|
|
192
190
|
return this._fromNonError0(error);
|
|
193
191
|
}
|
|
194
|
-
static
|
|
195
|
-
const
|
|
196
|
-
for (const
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
Object.assign(error,
|
|
192
|
+
static _applyAdapt(error) {
|
|
193
|
+
const plugin = this._getResolvedPlugin();
|
|
194
|
+
for (const adapt of plugin.adapt) {
|
|
195
|
+
const adapted = adapt(error);
|
|
196
|
+
if (adapted && typeof adapted === "object") {
|
|
197
|
+
Object.assign(error, adapted);
|
|
200
198
|
}
|
|
201
199
|
}
|
|
202
200
|
return error;
|
|
@@ -204,13 +202,16 @@ class Error0 extends Error {
|
|
|
204
202
|
static _fromSerialized(error) {
|
|
205
203
|
const message = this._extractMessage(error);
|
|
206
204
|
if (typeof error !== "object" || error === null) {
|
|
207
|
-
return this.
|
|
205
|
+
return this._applyAdapt(new this(message, { cause: error }));
|
|
208
206
|
}
|
|
209
207
|
const errorRecord = error;
|
|
210
208
|
const recreated = new this(message);
|
|
211
|
-
const
|
|
212
|
-
const propsEntries = Object.entries(
|
|
209
|
+
const plugin = this._getResolvedPlugin();
|
|
210
|
+
const propsEntries = Object.entries(plugin.props);
|
|
213
211
|
for (const [key, prop] of propsEntries) {
|
|
212
|
+
if (prop.deserialize === false) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
214
215
|
if (!(key in errorRecord)) {
|
|
215
216
|
continue;
|
|
216
217
|
}
|
|
@@ -228,17 +229,17 @@ class Error0 extends Error {
|
|
|
228
229
|
}
|
|
229
230
|
static _fromNonError0(error) {
|
|
230
231
|
const message = this._extractMessage(error);
|
|
231
|
-
return this.
|
|
232
|
+
return this._applyAdapt(new this(message, { cause: error }));
|
|
232
233
|
}
|
|
233
234
|
static _extractMessage(error) {
|
|
234
235
|
return (typeof error === "string" ? error : typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? error.message : void 0) || "Unknown error";
|
|
235
236
|
}
|
|
236
|
-
static
|
|
237
|
+
static _useWithPlugin(plugin) {
|
|
237
238
|
const Base = this;
|
|
238
239
|
const Error0Extended = class Error0 extends Base {
|
|
239
240
|
};
|
|
240
|
-
Error0Extended.
|
|
241
|
-
const resolved = Error0Extended.
|
|
241
|
+
Error0Extended._plugins = [...Base._plugins, plugin];
|
|
242
|
+
const resolved = Error0Extended._getResolvedPlugin();
|
|
242
243
|
for (const [key, method] of Object.entries(resolved.methods)) {
|
|
243
244
|
Object.defineProperty(Error0Extended.prototype, key, {
|
|
244
245
|
value: function(...args) {
|
|
@@ -259,61 +260,64 @@ class Error0 extends Error {
|
|
|
259
260
|
}
|
|
260
261
|
return Error0Extended;
|
|
261
262
|
}
|
|
262
|
-
static
|
|
263
|
-
const
|
|
263
|
+
static _pluginFromBuilder(plugin) {
|
|
264
|
+
const pluginRecord = plugin;
|
|
264
265
|
return {
|
|
265
|
-
props: { ...
|
|
266
|
-
methods: { ...
|
|
267
|
-
|
|
266
|
+
props: { ...pluginRecord._plugin.props ?? {} },
|
|
267
|
+
methods: { ...pluginRecord._plugin.methods ?? {} },
|
|
268
|
+
adapt: [...pluginRecord._plugin.adapt ?? []]
|
|
268
269
|
};
|
|
269
270
|
}
|
|
270
271
|
static prop(key, value) {
|
|
271
|
-
return this.
|
|
272
|
+
return this.use("prop", key, value);
|
|
272
273
|
}
|
|
273
274
|
static method(key, value) {
|
|
274
|
-
return this.
|
|
275
|
+
return this.use("method", key, value);
|
|
275
276
|
}
|
|
276
|
-
static
|
|
277
|
-
return this.
|
|
277
|
+
static adapt(value) {
|
|
278
|
+
return this.use("adapt", value);
|
|
278
279
|
}
|
|
279
|
-
static
|
|
280
|
-
if (first instanceof
|
|
281
|
-
return this.
|
|
280
|
+
static use(first, key, value) {
|
|
281
|
+
if (first instanceof PluginError0) {
|
|
282
|
+
return this._useWithPlugin(this._pluginFromBuilder(first));
|
|
282
283
|
}
|
|
283
|
-
if (first === "
|
|
284
|
+
if (first === "adapt") {
|
|
284
285
|
if (typeof key !== "function") {
|
|
285
|
-
throw new Error('Error0.
|
|
286
|
+
throw new Error('Error0.use("adapt", value) requires adapt function');
|
|
286
287
|
}
|
|
287
|
-
return this.
|
|
288
|
-
|
|
288
|
+
return this._useWithPlugin({
|
|
289
|
+
adapt: [key]
|
|
289
290
|
});
|
|
290
291
|
}
|
|
291
292
|
if (typeof key !== "string" || value === void 0) {
|
|
292
|
-
throw new Error("Error0.
|
|
293
|
+
throw new Error("Error0.use(kind, key, value) requires key and value");
|
|
293
294
|
}
|
|
294
295
|
if (first === "prop") {
|
|
295
|
-
return this.
|
|
296
|
+
return this._useWithPlugin({
|
|
296
297
|
props: { [key]: value }
|
|
297
298
|
});
|
|
298
299
|
}
|
|
299
|
-
return this.
|
|
300
|
+
return this._useWithPlugin({
|
|
300
301
|
methods: { [key]: value }
|
|
301
302
|
});
|
|
302
303
|
}
|
|
303
|
-
static
|
|
304
|
-
return new
|
|
304
|
+
static plugin() {
|
|
305
|
+
return new PluginError0();
|
|
305
306
|
}
|
|
306
307
|
static serialize(error, isPublic = true) {
|
|
307
308
|
const error0 = this.from(error);
|
|
308
309
|
const json = {
|
|
309
310
|
name: error0.name,
|
|
310
311
|
message: error0.message
|
|
311
|
-
// we do not serialize causes, it is enough that we have floated props and
|
|
312
|
+
// we do not serialize causes, it is enough that we have floated props and adapt helper
|
|
312
313
|
// cause: error0.cause,
|
|
313
314
|
};
|
|
314
|
-
const
|
|
315
|
-
const propsEntries = Object.entries(
|
|
315
|
+
const plugin = this._getResolvedPlugin();
|
|
316
|
+
const propsEntries = Object.entries(plugin.props);
|
|
316
317
|
for (const [key, prop] of propsEntries) {
|
|
318
|
+
if (prop.serialize === false) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
317
321
|
try {
|
|
318
322
|
const value = prop.resolve({ value: error0.own(key), flow: error0.flow(key), error: error0 });
|
|
319
323
|
const jsonValue = prop.serialize({ value, error: error0, isPublic });
|
|
@@ -337,6 +341,6 @@ class Error0 extends Error {
|
|
|
337
341
|
// Annotate the CommonJS export names for ESM import in node:
|
|
338
342
|
0 && (module.exports = {
|
|
339
343
|
Error0,
|
|
340
|
-
|
|
344
|
+
PluginError0
|
|
341
345
|
});
|
|
342
346
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type ErrorExtensionPropOptions<TInputValue, TOutputValue, TError extends Error0 = Error0> = {\n init: (input: TInputValue) => TOutputValue\n resolve: (options: {\n value: TOutputValue | undefined\n flow: Array<TOutputValue | undefined>\n error: TError\n }) => TOutputValue | undefined\n serialize: (options: { value: TOutputValue; error: TError; isPublic: boolean }) => unknown\n deserialize: (options: { value: unknown; serialized: Record<string, unknown> }) => TOutputValue | undefined\n}\nexport type ErrorExtensionMethodFn<\n TOutputValue,\n TArgs extends unknown[] = unknown[],\n TError extends Error0 = Error0,\n> = (error: TError, ...args: TArgs) => TOutputValue\nexport type ErrorExtensionRefineResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined\nexport type ErrorExtensionRefineFn<\n TError extends Error0 = Error0,\n TOutputProps extends Record<string, unknown> = Record<never, never>,\n> = ((error: TError) => void) | ((error: TError) => ErrorExtensionRefineResult<TOutputProps>)\ntype ErrorMethodRecord = {\n args: unknown[]\n output: unknown\n}\n\nexport type ErrorExtensionProps = { [key: string]: ErrorExtensionPropOptions<any, any> }\nexport type ErrorExtensionMethods = { [key: string]: ErrorExtensionMethodFn<any, any[]> }\n\nexport type ErrorExtension<\n TProps extends ErrorExtensionProps = Record<never, never>,\n TMethods extends ErrorExtensionMethods = Record<never, never>,\n> = {\n props?: TProps\n methods?: TMethods\n refine?: Array<ErrorExtensionRefineFn<Error0, ExtensionOutputProps<TProps>>>\n}\ntype AddPropToExtensionProps<\n TProps extends ErrorExtensionProps,\n TKey extends string,\n TInputValue,\n TOutputValue,\n> = TProps & Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>\ntype AddMethodToExtensionMethods<\n TMethods extends ErrorExtensionMethods,\n TKey extends string,\n TArgs extends unknown[],\n TOutputValue,\n> = TMethods & Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>\ntype ExtensionOutputProps<TProps extends ErrorExtensionProps> = {\n [TKey in keyof TProps]: TProps[TKey] extends ErrorExtensionPropOptions<any, infer TOutputValue> ? TOutputValue : never\n}\nexport type ErrorExtensionsMap = {\n props: Record<string, { init: unknown; resolve: unknown }>\n methods: Record<string, ErrorMethodRecord>\n}\nexport type IsEmptyObject<T> = keyof T extends never ? true : false\nexport type ErrorInputBase = {\n cause?: unknown\n}\nexport type ErrorInput<TExtensionsMap extends ErrorExtensionsMap> =\n IsEmptyObject<TExtensionsMap['props']> extends true\n ? ErrorInputBase\n : ErrorInputBase &\n Partial<{\n [TKey in keyof TExtensionsMap['props']]: TExtensionsMap['props'][TKey]['init']\n }>\n\ntype ErrorOutputProps<TExtensionsMap extends ErrorExtensionsMap> = {\n [TKey in keyof TExtensionsMap['props']]?: TExtensionsMap['props'][TKey]['resolve']\n}\ntype ErrorOutputMethods<TExtensionsMap extends ErrorExtensionsMap> = {\n [TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {\n args: infer TArgs extends unknown[]\n output: infer TOutput\n }\n ? (...args: TArgs) => TOutput\n : never\n}\nexport type ErrorOutput<TExtensionsMap extends ErrorExtensionsMap> = ErrorOutputProps<TExtensionsMap> &\n ErrorOutputMethods<TExtensionsMap>\n\ntype ErrorStaticMethods<TExtensionsMap extends ErrorExtensionsMap> = {\n [TKey in keyof TExtensionsMap['methods']]: TExtensionsMap['methods'][TKey] extends {\n args: infer TArgs extends unknown[]\n output: infer TOutput\n }\n ? (error: unknown, ...args: TArgs) => TOutput\n : never\n}\n\ntype EmptyExtensionsMap = {\n props: Record<never, { init: never; resolve: never }>\n methods: Record<never, ErrorMethodRecord>\n}\n\ntype ErrorExtensionResolved = {\n props: Record<string, ErrorExtensionPropOptions<unknown, unknown>>\n methods: Record<string, ErrorExtensionMethodFn<unknown>>\n refine: Array<ErrorExtensionRefineFn<Error0, Record<string, unknown>>>\n}\n\ntype ExtensionPropsMapOf<TExtension extends ErrorExtension> = {\n [TKey in keyof NonNullable<TExtension['props']>]: NonNullable<\n TExtension['props']\n >[TKey] extends ErrorExtensionPropOptions<infer TInputValue, infer TOutputValue>\n ? { init: TInputValue; resolve: TOutputValue }\n : never\n}\ntype ExtensionMethodsMapOf<TExtension extends ErrorExtension> = {\n [TKey in keyof NonNullable<TExtension['methods']>]: NonNullable<TExtension['methods']>[TKey] extends (\n error: Error0,\n ...args: infer TArgs extends unknown[]\n ) => infer TOutput\n ? { args: TArgs; output: TOutput }\n : never\n}\ntype ErrorExtensionsMapOfExtension<TExtension extends ErrorExtension> = {\n props: ExtensionPropsMapOf<TExtension>\n methods: ExtensionMethodsMapOf<TExtension>\n}\ntype ExtendErrorExtensionsMap<TMap extends ErrorExtensionsMap, TExtension extends ErrorExtension> = {\n props: TMap['props'] & ErrorExtensionsMapOfExtension<TExtension>['props']\n methods: TMap['methods'] & ErrorExtensionsMapOfExtension<TExtension>['methods']\n}\ntype ExtendErrorExtensionsMapWithProp<\n TMap extends ErrorExtensionsMap,\n TKey extends string,\n TInputValue,\n TOutputValue,\n> = ExtendErrorExtensionsMap<TMap, ErrorExtension<Record<TKey, ErrorExtensionPropOptions<TInputValue, TOutputValue>>>>\ntype ExtendErrorExtensionsMapWithMethod<\n TMap extends ErrorExtensionsMap,\n TKey extends string,\n TArgs extends unknown[],\n TOutputValue,\n> = ExtendErrorExtensionsMap<\n TMap,\n ErrorExtension<Record<never, never>, Record<TKey, ErrorExtensionMethodFn<TOutputValue, TArgs>>>\n>\n\ntype ExtensionsMapOf<TClass> = TClass extends { __extensionsMap?: infer TExtensionsMap }\n ? TExtensionsMap extends ErrorExtensionsMap\n ? TExtensionsMap\n : EmptyExtensionsMap\n : EmptyExtensionsMap\n\ntype ExtensionsMapFromParts<\n TProps extends ErrorExtensionProps,\n TMethods extends ErrorExtensionMethods,\n> = ErrorExtensionsMapOfExtension<ErrorExtension<TProps, TMethods>>\ntype ErrorInstanceOfMap<TMap extends ErrorExtensionsMap> = Error0 & ErrorOutput<TMap>\ntype BuilderError0<TProps extends ErrorExtensionProps, TMethods extends ErrorExtensionMethods> = Error0 &\n ErrorOutput<ExtensionsMapFromParts<TProps, TMethods>>\n\ntype ExtensionOfBuilder<TBuilder> =\n TBuilder extends ExtensionError0<infer TProps, infer TMethods> ? ErrorExtension<TProps, TMethods> : never\n\nexport class ExtensionError0<\n TProps extends ErrorExtensionProps = Record<never, never>,\n TMethods extends ErrorExtensionMethods = Record<never, never>,\n> {\n private readonly _extension: ErrorExtension<ErrorExtensionProps, ErrorExtensionMethods>\n\n readonly Infer = undefined as unknown as {\n props: TProps\n methods: TMethods\n }\n\n constructor(extension?: ErrorExtension<ErrorExtensionProps, ErrorExtensionMethods>) {\n this._extension = {\n props: { ...(extension?.props ?? {}) },\n methods: { ...(extension?.methods ?? {}) },\n refine: [...(extension?.refine ?? [])],\n }\n }\n\n prop<TKey extends string, TInputValue, TOutputValue>(\n key: TKey,\n value: ErrorExtensionPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>,\n ): ExtensionError0<AddPropToExtensionProps<TProps, TKey, TInputValue, TOutputValue>, TMethods> {\n return this.extend('prop', key, value)\n }\n\n method<TKey extends string, TArgs extends unknown[], TOutputValue>(\n key: TKey,\n value: ErrorExtensionMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>,\n ): ExtensionError0<TProps, AddMethodToExtensionMethods<TMethods, TKey, TArgs, TOutputValue>> {\n return this.extend('method', key, value)\n }\n\n refine(\n value: ErrorExtensionRefineFn<BuilderError0<TProps, TMethods>, ExtensionOutputProps<TProps>>,\n ): ExtensionError0<TProps, TMethods> {\n return this.extend('refine', value)\n }\n\n extend<TKey extends string, TInputValue, TOutputValue>(\n kind: 'prop',\n key: TKey,\n value: ErrorExtensionPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>,\n ): ExtensionError0<AddPropToExtensionProps<TProps, TKey, TInputValue, TOutputValue>, TMethods>\n extend<TKey extends string, TArgs extends unknown[], TOutputValue>(\n kind: 'method',\n key: TKey,\n value: ErrorExtensionMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>,\n ): ExtensionError0<TProps, AddMethodToExtensionMethods<TMethods, TKey, TArgs, TOutputValue>>\n extend(\n kind: 'refine',\n value: ErrorExtensionRefineFn<BuilderError0<TProps, TMethods>, ExtensionOutputProps<TProps>>,\n ): ExtensionError0<TProps, TMethods>\n extend(\n kind: 'prop' | 'method' | 'refine',\n keyOrValue: string | ErrorExtensionRefineFn<any, any>,\n value?: ErrorExtensionPropOptions<unknown, unknown, any> | ErrorExtensionMethodFn<unknown, unknown[], any>,\n ): ExtensionError0<any, any> {\n const nextProps: ErrorExtensionProps = { ...(this._extension.props ?? {}) }\n const nextMethods: ErrorExtensionMethods = { ...(this._extension.methods ?? {}) }\n const nextRefine: Array<ErrorExtensionRefineFn<Error0, Record<string, unknown>>> = [\n ...(this._extension.refine ?? []),\n ]\n if (kind === 'prop') {\n const key = keyOrValue as string\n if (value === undefined) {\n throw new Error('ExtensionError0.extend(\"prop\", key, value) requires value')\n }\n nextProps[key] = value as ErrorExtensionPropOptions<any, any>\n } else if (kind === 'method') {\n const key = keyOrValue as string\n if (value === undefined) {\n throw new Error('ExtensionError0.extend(\"method\", key, value) requires value')\n }\n nextMethods[key] = value as ErrorExtensionMethodFn<any, any[]>\n } else {\n nextRefine.push(keyOrValue as ErrorExtensionRefineFn<Error0, Record<string, unknown>>)\n }\n return new ExtensionError0({\n props: nextProps,\n methods: nextMethods,\n refine: nextRefine,\n })\n }\n}\n\nexport type ClassError0<TExtensionsMap extends ErrorExtensionsMap = EmptyExtensionsMap> = {\n new (message: string, input?: ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>\n new (input: { message: string } & ErrorInput<TExtensionsMap>): Error0 & ErrorOutput<TExtensionsMap>\n readonly __extensionsMap?: TExtensionsMap\n from: (error: unknown) => Error0 & ErrorOutput<TExtensionsMap>\n serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>\n prop: <TKey extends string, TInputValue, TOutputValue>(\n key: TKey,\n value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TExtensionsMap>>,\n ) => ClassError0<ExtendErrorExtensionsMapWithProp<TExtensionsMap, TKey, TInputValue, TOutputValue>>\n method: <TKey extends string, TArgs extends unknown[], TOutputValue>(\n key: TKey,\n value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>,\n ) => ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>\n refine: (\n value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>,\n ) => ClassError0<TExtensionsMap>\n extend: {\n <TBuilder extends ExtensionError0>(\n extension: TBuilder,\n ): ClassError0<ExtendErrorExtensionsMap<TExtensionsMap, ExtensionOfBuilder<TBuilder>>>\n <TKey extends string, TInputValue, TOutputValue>(\n kind: 'prop',\n key: TKey,\n value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TExtensionsMap>>,\n ): ClassError0<ExtendErrorExtensionsMapWithProp<TExtensionsMap, TKey, TInputValue, TOutputValue>>\n <TKey extends string, TArgs extends unknown[], TOutputValue>(\n kind: 'method',\n key: TKey,\n value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TExtensionsMap>>,\n ): ClassError0<ExtendErrorExtensionsMapWithMethod<TExtensionsMap, TKey, TArgs, TOutputValue>>\n (\n kind: 'refine',\n value: ErrorExtensionRefineFn<ErrorInstanceOfMap<TExtensionsMap>, ErrorOutputProps<TExtensionsMap>>,\n ): ClassError0<TExtensionsMap>\n }\n extension: () => ExtensionError0\n} & ErrorStaticMethods<TExtensionsMap>\n\nexport class Error0 extends Error {\n static readonly __extensionsMap?: EmptyExtensionsMap\n protected static _extensions: ErrorExtension[] = []\n\n private static readonly _emptyExtension: ErrorExtensionResolved = {\n props: {},\n methods: {},\n refine: [],\n }\n\n private static _getResolvedExtension(this: typeof Error0): ErrorExtensionResolved {\n const resolved: ErrorExtensionResolved = {\n props: {},\n methods: {},\n refine: [],\n }\n for (const extension of this._extensions) {\n Object.assign(resolved.props, extension.props ?? this._emptyExtension.props)\n Object.assign(resolved.methods, extension.methods ?? this._emptyExtension.methods)\n resolved.refine.push(...(extension.refine ?? this._emptyExtension.refine))\n }\n return resolved\n }\n\n constructor(message: string, input?: ErrorInput<EmptyExtensionsMap>)\n constructor(input: { message: string } & ErrorInput<EmptyExtensionsMap>)\n constructor(\n ...args:\n | [message: string, input?: ErrorInput<EmptyExtensionsMap>]\n | [{ message: string } & ErrorInput<EmptyExtensionsMap>]\n ) {\n const [first, second] = args\n const input = typeof first === 'string' ? { message: first, ...(second ?? {}) } : first\n\n super(input.message, { cause: input.cause })\n this.name = 'Error0'\n\n const ctor = this.constructor as typeof Error0\n const extension = ctor._getResolvedExtension()\n\n for (const [key, prop] of Object.entries(extension.props)) {\n if (key in input) {\n const ownValue = (input as Record<string, unknown>)[key]\n ;(this as Record<string, unknown>)[key] = prop.init(ownValue)\n } else {\n Object.defineProperty(this, key, {\n get: () => prop.resolve({ value: undefined, flow: this.flow(key), error: this }),\n set: (value) => {\n Object.defineProperty(this, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n })\n },\n enumerable: true,\n configurable: true,\n })\n }\n }\n }\n\n private static readonly isSelfProperty = (object: object, key: string): boolean => {\n const d = Object.getOwnPropertyDescriptor(object, key)\n if (!d) return false\n if (typeof d.get === 'function' || typeof d.set === 'function') {\n if ('name' in object && object.name === 'Error0') {\n return false\n } else {\n return true\n }\n }\n return true\n }\n\n static own(error: object, key: string): unknown {\n if (this.isSelfProperty(error, key)) {\n return (error as Record<string, unknown>)[key]\n }\n return undefined\n }\n own(key: string): unknown {\n const ctor = this.constructor as typeof Error0\n return ctor.own(this, key)\n }\n\n static flow(error: object, key: string): unknown[] {\n return this.causes(error, true).map((cause) => {\n return this.own(cause, key)\n })\n }\n flow(key: string): unknown[] {\n const ctor = this.constructor as typeof Error0\n return ctor.flow(this, key)\n }\n\n static causes(error: unknown, instancesOnly?: false): unknown[]\n static causes<T extends typeof Error0>(this: T, error: unknown, instancesOnly: true): Array<InstanceType<T>>\n static causes(error: unknown, instancesOnly?: boolean): unknown[] {\n const causes: unknown[] = []\n let current: unknown = error\n const maxDepth = 99\n const seen = new Set<unknown>()\n for (let depth = 0; depth < maxDepth; depth += 1) {\n if (seen.has(current)) {\n break\n }\n seen.add(current)\n if (!instancesOnly || this.is(current)) {\n causes.push(current)\n }\n if (!current || typeof current !== 'object') {\n break\n }\n current = (current as { cause?: unknown }).cause\n }\n return causes\n }\n causes<T extends typeof Error0>(this: T, instancesOnly?: false): [InstanceType<T>, ...unknown[]]\n causes<T extends typeof Error0>(this: T, instancesOnly: true): [InstanceType<T>, ...Array<InstanceType<T>>]\n causes(instancesOnly?: boolean): unknown[] {\n const ctor = this.constructor as typeof Error0\n if (instancesOnly) {\n return ctor.causes(this, true)\n }\n return ctor.causes(this)\n }\n\n static is<T extends typeof Error0>(this: T, error: unknown): error is InstanceType<T> {\n return error instanceof this\n }\n\n static isSerialized(error: unknown): error is Record<string, unknown> {\n return !this.is(error) && typeof error === 'object' && error !== null && 'name' in error && error.name === 'Error0'\n }\n\n static from(error: unknown): Error0 {\n if (this.is(error)) {\n return error\n }\n if (this.isSerialized(error)) {\n return this._fromSerialized(error)\n }\n return this._fromNonError0(error)\n }\n\n private static _applyRefine(error: Error0): Error0 {\n const extension = this._getResolvedExtension()\n for (const refine of extension.refine) {\n const refined = refine(error as any)\n if (refined && typeof refined === 'object') {\n Object.assign(error as unknown as Record<string, unknown>, refined)\n }\n }\n return error\n }\n\n private static _fromSerialized(error: unknown): Error0 {\n const message = this._extractMessage(error)\n if (typeof error !== 'object' || error === null) {\n return this._applyRefine(new this(message, { cause: error }))\n }\n const errorRecord = error as Record<string, unknown>\n const recreated = new this(message)\n const extension = this._getResolvedExtension()\n const propsEntries = Object.entries(extension.props)\n for (const [key, prop] of propsEntries) {\n if (!(key in errorRecord)) {\n continue\n }\n try {\n const value = prop.deserialize({ value: errorRecord[key], serialized: errorRecord })\n ;(recreated as unknown as Record<string, unknown>)[key] = value\n } catch {\n // ignore\n }\n }\n // we do not serialize causes\n // ;(recreated as unknown as { cause?: unknown }).cause = errorRecord.cause\n const isStackInProps = propsEntries.some(([key]) => key === 'stack')\n if (typeof errorRecord.stack === 'string' && !isStackInProps) {\n recreated.stack = errorRecord.stack\n }\n return recreated\n }\n\n private static _fromNonError0(error: unknown): Error0 {\n const message = this._extractMessage(error)\n return this._applyRefine(new this(message, { cause: error }))\n }\n\n private static _extractMessage(error: unknown): string {\n return (\n (typeof error === 'string'\n ? error\n : typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string'\n ? error.message\n : undefined) || 'Unknown error'\n )\n }\n\n private static _extendWithExtension(\n this: typeof Error0,\n extension: ErrorExtension<ErrorExtensionProps, ErrorExtensionMethods>,\n ): ClassError0 {\n const Base = this as unknown as typeof Error0\n const Error0Extended = class Error0 extends Base {}\n ;(Error0Extended as typeof Error0)._extensions = [...Base._extensions, extension]\n\n const resolved = (Error0Extended as typeof Error0)._getResolvedExtension()\n for (const [key, method] of Object.entries(resolved.methods)) {\n Object.defineProperty((Error0Extended as typeof Error0).prototype, key, {\n value: function (...args: unknown[]) {\n return method(this as Error0, ...args)\n },\n writable: true,\n enumerable: true,\n configurable: true,\n })\n Object.defineProperty(Error0Extended, key, {\n value: function (error: unknown, ...args: unknown[]) {\n return method(this.from(error), ...args)\n },\n writable: true,\n enumerable: true,\n configurable: true,\n })\n }\n\n return Error0Extended as unknown as ClassError0\n }\n\n private static _extensionFromBuilder(\n extension: ExtensionError0,\n ): ErrorExtension<ErrorExtensionProps, ErrorExtensionMethods> {\n const extensionRecord = extension as unknown as {\n _extension: ErrorExtension<ErrorExtensionProps, ErrorExtensionMethods>\n }\n return {\n props: { ...(extensionRecord._extension.props ?? {}) },\n methods: { ...(extensionRecord._extension.methods ?? {}) },\n refine: [...(extensionRecord._extension.refine ?? [])],\n }\n }\n\n static prop<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(\n this: TThis,\n key: TKey,\n value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorExtensionsMapWithProp<ExtensionsMapOf<TThis>, TKey, TInputValue, TOutputValue>> {\n return this.extend('prop', key, value)\n }\n\n static method<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(\n this: TThis,\n key: TKey,\n value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorExtensionsMapWithMethod<ExtensionsMapOf<TThis>, TKey, TArgs, TOutputValue>> {\n return this.extend('method', key, value)\n }\n\n static refine<TThis extends typeof Error0>(\n this: TThis,\n value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>,\n ): ClassError0<ExtensionsMapOf<TThis>> {\n return this.extend('refine', value)\n }\n\n static extend<TThis extends typeof Error0, TBuilder extends ExtensionError0>(\n this: TThis,\n extension: TBuilder,\n ): ClassError0<ExtendErrorExtensionsMap<ExtensionsMapOf<TThis>, ExtensionOfBuilder<TBuilder>>>\n static extend<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(\n this: TThis,\n kind: 'prop',\n key: TKey,\n value: ErrorExtensionPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorExtensionsMapWithProp<ExtensionsMapOf<TThis>, TKey, TInputValue, TOutputValue>>\n static extend<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(\n this: TThis,\n kind: 'method',\n key: TKey,\n value: ErrorExtensionMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<ExtensionsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorExtensionsMapWithMethod<ExtensionsMapOf<TThis>, TKey, TArgs, TOutputValue>>\n static extend<TThis extends typeof Error0>(\n this: TThis,\n kind: 'refine',\n value: ErrorExtensionRefineFn<ErrorInstanceOfMap<ExtensionsMapOf<TThis>>, ErrorOutputProps<ExtensionsMapOf<TThis>>>,\n ): ClassError0<ExtensionsMapOf<TThis>>\n static extend(\n this: typeof Error0,\n first: ExtensionError0 | 'prop' | 'method' | 'refine',\n key?: string | ErrorExtensionRefineFn<any, any>,\n value?: ErrorExtensionPropOptions<unknown, unknown> | ErrorExtensionMethodFn<unknown>,\n ): ClassError0 {\n if (first instanceof ExtensionError0) {\n return this._extendWithExtension(this._extensionFromBuilder(first))\n }\n if (first === 'refine') {\n if (typeof key !== 'function') {\n throw new Error('Error0.extend(\"refine\", value) requires refine function')\n }\n return this._extendWithExtension({\n refine: [key],\n })\n }\n if (typeof key !== 'string' || value === undefined) {\n throw new Error('Error0.extend(kind, key, value) requires key and value')\n }\n\n if (first === 'prop') {\n return this._extendWithExtension({\n props: { [key]: value as ErrorExtensionPropOptions<unknown, unknown> },\n })\n }\n return this._extendWithExtension({\n methods: { [key]: value as ErrorExtensionMethodFn<unknown> },\n })\n }\n\n static extension(): ExtensionError0 {\n return new ExtensionError0()\n }\n\n static serialize(error: unknown, isPublic = true): Record<string, unknown> {\n const error0 = this.from(error)\n const json: Record<string, unknown> = {\n name: error0.name,\n message: error0.message,\n // we do not serialize causes, it is enough that we have floated props and refine helper\n // cause: error0.cause,\n }\n\n const extension = this._getResolvedExtension()\n const propsEntries = Object.entries(extension.props)\n for (const [key, prop] of propsEntries) {\n try {\n const value = prop.resolve({ value: error0.own(key), flow: error0.flow(key), error: error0 })\n const jsonValue = prop.serialize({ value, error: error0, isPublic })\n if (jsonValue !== undefined) {\n json[key] = jsonValue\n }\n } catch {\n // ignore\n }\n }\n const isStackInProps = propsEntries.some(([key]) => key === 'stack')\n if (!isStackInProps && typeof error0.stack === 'string') {\n json.stack = error0.stack\n }\n return Object.fromEntries(Object.entries(json).filter(([, value]) => value !== undefined)) as Record<\n string,\n unknown\n >\n }\n\n serialize(isPublic = true): object {\n const ctor = this.constructor as typeof Error0\n return ctor.serialize(this, isPublic)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6JO,MAAM,gBAGX;AAAA,EACiB;AAAA,EAER,QAAQ;AAAA,EAKjB,YAAY,WAAwE;AAClF,SAAK,aAAa;AAAA,MAChB,OAAO,EAAE,GAAI,WAAW,SAAS,CAAC,EAA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[unknown] ? true : false) : false\ntype NormalizeUnknownToUndefined<T> = IsUnknown<T> extends true ? undefined : T\ntype IsOnlyUndefined<T> = [Exclude<T, undefined>] extends [never] ? true : false\ntype InferFirstArg<TFn> = TFn extends (...args: infer TArgs) => unknown\n ? TArgs extends [infer TFirst, ...unknown[]]\n ? TFirst\n : undefined\n : undefined\ntype InferPluginPropInput<TProp extends ErrorPluginPropOptions<any, any, any>> = NormalizeUnknownToUndefined<\n InferFirstArg<TProp['init']>\n>\ntype ErrorPluginPropInit<TInputValue, TOutputValue> = ((input: TInputValue) => TOutputValue) | (() => TOutputValue)\ntype ErrorPluginPropSerialize<TOutputValue, TError extends Error0> =\n | ((options: { value: TOutputValue; error: TError; isPublic: boolean }) => unknown)\n | false\ntype ErrorPluginPropDeserialize<TOutputValue> =\n | ((options: { value: unknown; serialized: Record<string, unknown> }) => TOutputValue | undefined)\n | false\n\nexport type ErrorPluginPropOptions<TInputValue, TOutputValue, TError extends Error0 = Error0> = {\n init: ErrorPluginPropInit<TInputValue, TOutputValue>\n resolve: (options: {\n value: TOutputValue | undefined\n flow: Array<TOutputValue | undefined>\n error: TError\n }) => TOutputValue | undefined\n serialize: ErrorPluginPropSerialize<TOutputValue, TError>\n deserialize: ErrorPluginPropDeserialize<TOutputValue>\n}\nexport type ErrorPluginMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (\n error: TError,\n ...args: TArgs\n) => TOutputValue\nexport type ErrorPluginAdaptResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined\nexport type ErrorPluginAdaptFn<\n TError extends Error0 = Error0,\n TOutputProps extends Record<string, unknown> = Record<never, never>,\n> = ((error: TError) => void) | ((error: TError) => ErrorPluginAdaptResult<TOutputProps>)\ntype ErrorMethodRecord = {\n args: unknown[]\n output: unknown\n}\n\nexport type ErrorPluginProps = { [key: string]: ErrorPluginPropOptions<any, any> }\nexport type ErrorPluginMethods = { [key: string]: ErrorPluginMethodFn<any, any[]> }\n\nexport type ErrorPlugin<\n TProps extends ErrorPluginProps = Record<never, never>,\n TMethods extends ErrorPluginMethods = Record<never, never>,\n> = {\n props?: TProps\n methods?: TMethods\n adapt?: Array<ErrorPluginAdaptFn<Error0, PluginOutputProps<TProps>>>\n}\ntype AddPropToPluginProps<TProps extends ErrorPluginProps, TKey extends string, TInputValue, TOutputValue> = TProps &\n Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue>>\ntype AddMethodToPluginMethods<\n TMethods extends ErrorPluginMethods,\n TKey extends string,\n TArgs extends unknown[],\n TOutputValue,\n> = TMethods & Record<TKey, ErrorPluginMethodFn<TOutputValue, TArgs>>\ntype PluginOutputProps<TProps extends ErrorPluginProps> = {\n [TKey in keyof TProps]: TProps[TKey] extends ErrorPluginPropOptions<any, infer TOutputValue> ? TOutputValue : never\n}\nexport type ErrorPluginsMap = {\n props: Record<string, { init: unknown; resolve: unknown }>\n methods: Record<string, ErrorMethodRecord>\n}\nexport type IsEmptyObject<T> = keyof T extends never ? true : false\nexport type ErrorInputBase = {\n cause?: unknown\n}\ntype ErrorInputPluginProps<TPluginsMap extends ErrorPluginsMap> = {\n [TKey in keyof TPluginsMap['props'] as IsOnlyUndefined<TPluginsMap['props'][TKey]['init']> extends true\n ? never\n : TKey]?: TPluginsMap['props'][TKey]['init']\n}\nexport type ErrorInput<TPluginsMap extends ErrorPluginsMap> =\n IsEmptyObject<TPluginsMap['props']> extends true\n ? ErrorInputBase\n : ErrorInputBase & ErrorInputPluginProps<TPluginsMap>\n\ntype ErrorOutputProps<TPluginsMap extends ErrorPluginsMap> = {\n [TKey in keyof TPluginsMap['props']]: TPluginsMap['props'][TKey]['resolve'] | undefined\n}\ntype ErrorOutputMethods<TPluginsMap extends ErrorPluginsMap> = {\n [TKey in keyof TPluginsMap['methods']]: TPluginsMap['methods'][TKey] extends {\n args: infer TArgs extends unknown[]\n output: infer TOutput\n }\n ? (...args: TArgs) => TOutput\n : never\n}\nexport type ErrorOutput<TPluginsMap extends ErrorPluginsMap> = ErrorOutputProps<TPluginsMap> &\n ErrorOutputMethods<TPluginsMap>\n\ntype ErrorStaticMethods<TPluginsMap extends ErrorPluginsMap> = {\n [TKey in keyof TPluginsMap['methods']]: TPluginsMap['methods'][TKey] extends {\n args: infer TArgs extends unknown[]\n output: infer TOutput\n }\n ? (error: unknown, ...args: TArgs) => TOutput\n : never\n}\n\ntype EmptyPluginsMap = {\n props: Record<never, { init: never; resolve: never }>\n methods: Record<never, ErrorMethodRecord>\n}\n\ntype ErrorPluginResolved = {\n props: Record<string, ErrorPluginPropOptions<unknown, unknown>>\n methods: Record<string, ErrorPluginMethodFn<unknown>>\n adapt: Array<ErrorPluginAdaptFn<Error0, Record<string, unknown>>>\n}\n\ntype PluginPropsMapOf<TPlugin extends ErrorPlugin> = {\n [TKey in keyof NonNullable<TPlugin['props']>]: NonNullable<TPlugin['props']>[TKey] extends ErrorPluginPropOptions<\n any,\n infer TOutputValue\n >\n ? { init: InferPluginPropInput<NonNullable<TPlugin['props']>[TKey]>; resolve: TOutputValue }\n : never\n}\ntype PluginMethodsMapOf<TPlugin extends ErrorPlugin> = {\n [TKey in keyof NonNullable<TPlugin['methods']>]: NonNullable<TPlugin['methods']>[TKey] extends (\n error: Error0,\n ...args: infer TArgs extends unknown[]\n ) => infer TOutput\n ? { args: TArgs; output: TOutput }\n : never\n}\ntype ErrorPluginsMapOfPlugin<TPlugin extends ErrorPlugin> = {\n props: PluginPropsMapOf<TPlugin>\n methods: PluginMethodsMapOf<TPlugin>\n}\ntype ExtendErrorPluginsMap<TMap extends ErrorPluginsMap, TPlugin extends ErrorPlugin> = {\n props: TMap['props'] & ErrorPluginsMapOfPlugin<TPlugin>['props']\n methods: TMap['methods'] & ErrorPluginsMapOfPlugin<TPlugin>['methods']\n}\ntype ExtendErrorPluginsMapWithProp<\n TMap extends ErrorPluginsMap,\n TKey extends string,\n TInputValue,\n TOutputValue,\n> = ExtendErrorPluginsMap<TMap, ErrorPlugin<Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue>>>>\ntype ExtendErrorPluginsMapWithMethod<\n TMap extends ErrorPluginsMap,\n TKey extends string,\n TArgs extends unknown[],\n TOutputValue,\n> = ExtendErrorPluginsMap<\n TMap,\n ErrorPlugin<Record<never, never>, Record<TKey, ErrorPluginMethodFn<TOutputValue, TArgs>>>\n>\n\ntype PluginsMapOf<TClass> = TClass extends { __pluginsMap?: infer TPluginsMap }\n ? TPluginsMap extends ErrorPluginsMap\n ? TPluginsMap\n : EmptyPluginsMap\n : EmptyPluginsMap\n\ntype PluginsMapFromParts<\n TProps extends ErrorPluginProps,\n TMethods extends ErrorPluginMethods,\n> = ErrorPluginsMapOfPlugin<ErrorPlugin<TProps, TMethods>>\ntype ErrorInstanceOfMap<TMap extends ErrorPluginsMap> = Error0 & ErrorOutput<TMap>\ntype BuilderError0<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = Error0 &\n ErrorOutput<PluginsMapFromParts<TProps, TMethods>>\n\ntype PluginOfBuilder<TBuilder> =\n TBuilder extends PluginError0<infer TProps, infer TMethods> ? ErrorPlugin<TProps, TMethods> : never\n\nexport class PluginError0<\n TProps extends ErrorPluginProps = Record<never, never>,\n TMethods extends ErrorPluginMethods = Record<never, never>,\n> {\n private readonly _plugin: ErrorPlugin<ErrorPluginProps, ErrorPluginMethods>\n\n readonly Infer = undefined as unknown as {\n props: TProps\n methods: TMethods\n }\n\n constructor(plugin?: ErrorPlugin<ErrorPluginProps, ErrorPluginMethods>) {\n this._plugin = {\n props: { ...(plugin?.props ?? {}) },\n methods: { ...(plugin?.methods ?? {}) },\n adapt: [...(plugin?.adapt ?? [])],\n }\n }\n\n prop<TKey extends string, TInputValue, TOutputValue>(\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>,\n ): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue>, TMethods> {\n return this.use('prop', key, value)\n }\n\n method<TKey extends string, TArgs extends unknown[], TOutputValue>(\n key: TKey,\n value: ErrorPluginMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>,\n ): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TArgs, TOutputValue>> {\n return this.use('method', key, value)\n }\n\n adapt(\n value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>,\n ): PluginError0<TProps, TMethods> {\n return this.use('adapt', value)\n }\n\n use<TKey extends string, TInputValue, TOutputValue>(\n kind: 'prop',\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>>,\n ): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue>, TMethods>\n use<TKey extends string, TArgs extends unknown[], TOutputValue>(\n kind: 'method',\n key: TKey,\n value: ErrorPluginMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>,\n ): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TArgs, TOutputValue>>\n use(\n kind: 'adapt',\n value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>,\n ): PluginError0<TProps, TMethods>\n use(\n kind: 'prop' | 'method' | 'adapt',\n keyOrValue: string | ErrorPluginAdaptFn<any, any>,\n value?: ErrorPluginPropOptions<unknown, unknown, any> | ErrorPluginMethodFn<unknown, unknown[], any>,\n ): PluginError0<any, any> {\n const nextProps: ErrorPluginProps = { ...(this._plugin.props ?? {}) }\n const nextMethods: ErrorPluginMethods = { ...(this._plugin.methods ?? {}) }\n const nextAdapt: Array<ErrorPluginAdaptFn<Error0, Record<string, unknown>>> = [...(this._plugin.adapt ?? [])]\n if (kind === 'prop') {\n const key = keyOrValue as string\n if (value === undefined) {\n throw new Error('PluginError0.use(\"prop\", key, value) requires value')\n }\n nextProps[key] = value as ErrorPluginPropOptions<any, any>\n } else if (kind === 'method') {\n const key = keyOrValue as string\n if (value === undefined) {\n throw new Error('PluginError0.use(\"method\", key, value) requires value')\n }\n nextMethods[key] = value as ErrorPluginMethodFn<any, any[]>\n } else {\n nextAdapt.push(keyOrValue as ErrorPluginAdaptFn<Error0, Record<string, unknown>>)\n }\n return new PluginError0({\n props: nextProps,\n methods: nextMethods,\n adapt: nextAdapt,\n })\n }\n}\n\nexport type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {\n new (message: string, input?: ErrorInput<TPluginsMap>): Error0 & ErrorOutput<TPluginsMap>\n new (input: { message: string } & ErrorInput<TPluginsMap>): Error0 & ErrorOutput<TPluginsMap>\n readonly __pluginsMap?: TPluginsMap\n from: (error: unknown) => Error0 & ErrorOutput<TPluginsMap>\n serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>\n prop: <TKey extends string, TInputValue, TOutputValue>(\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>>,\n ) => ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue>>\n method: <TKey extends string, TArgs extends unknown[], TOutputValue>(\n key: TKey,\n value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TPluginsMap>>,\n ) => ClassError0<ExtendErrorPluginsMapWithMethod<TPluginsMap, TKey, TArgs, TOutputValue>>\n adapt: (\n value: ErrorPluginAdaptFn<ErrorInstanceOfMap<TPluginsMap>, ErrorOutputProps<TPluginsMap>>,\n ) => ClassError0<TPluginsMap>\n use: {\n <TBuilder extends PluginError0>(\n plugin: TBuilder,\n ): ClassError0<ExtendErrorPluginsMap<TPluginsMap, PluginOfBuilder<TBuilder>>>\n <TKey extends string, TInputValue, TOutputValue>(\n kind: 'prop',\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>>,\n ): ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue>>\n <TKey extends string, TArgs extends unknown[], TOutputValue>(\n kind: 'method',\n key: TKey,\n value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TPluginsMap>>,\n ): ClassError0<ExtendErrorPluginsMapWithMethod<TPluginsMap, TKey, TArgs, TOutputValue>>\n (\n kind: 'adapt',\n value: ErrorPluginAdaptFn<ErrorInstanceOfMap<TPluginsMap>, ErrorOutputProps<TPluginsMap>>,\n ): ClassError0<TPluginsMap>\n }\n plugin: () => PluginError0\n} & ErrorStaticMethods<TPluginsMap>\n\nexport class Error0 extends Error {\n static readonly __pluginsMap?: EmptyPluginsMap\n protected static _plugins: ErrorPlugin[] = []\n\n private static readonly _emptyPlugin: ErrorPluginResolved = {\n props: {},\n methods: {},\n adapt: [],\n }\n\n private static _getResolvedPlugin(this: typeof Error0): ErrorPluginResolved {\n const resolved: ErrorPluginResolved = {\n props: {},\n methods: {},\n adapt: [],\n }\n for (const plugin of this._plugins) {\n Object.assign(resolved.props, plugin.props ?? this._emptyPlugin.props)\n Object.assign(resolved.methods, plugin.methods ?? this._emptyPlugin.methods)\n resolved.adapt.push(...(plugin.adapt ?? this._emptyPlugin.adapt))\n }\n return resolved\n }\n\n constructor(message: string, input?: ErrorInput<EmptyPluginsMap>)\n constructor(input: { message: string } & ErrorInput<EmptyPluginsMap>)\n constructor(\n ...args:\n | [message: string, input?: ErrorInput<EmptyPluginsMap>]\n | [{ message: string } & ErrorInput<EmptyPluginsMap>]\n ) {\n const [first, second] = args\n const input = typeof first === 'string' ? { message: first, ...(second ?? {}) } : first\n\n super(input.message, { cause: input.cause })\n this.name = 'Error0'\n\n const ctor = this.constructor as typeof Error0\n const plugin = ctor._getResolvedPlugin()\n\n for (const [key, prop] of Object.entries(plugin.props)) {\n if (key in input) {\n const ownValue = (input as Record<string, unknown>)[key]\n ;(this as Record<string, unknown>)[key] = prop.init(ownValue)\n } else {\n Object.defineProperty(this, key, {\n get: () => prop.resolve({ value: undefined, flow: this.flow(key), error: this }),\n set: (value) => {\n Object.defineProperty(this, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n })\n },\n enumerable: true,\n configurable: true,\n })\n }\n }\n }\n\n private static readonly isSelfProperty = (object: object, key: string): boolean => {\n const d = Object.getOwnPropertyDescriptor(object, key)\n if (!d) return false\n if (typeof d.get === 'function' || typeof d.set === 'function') {\n if ('name' in object && object.name === 'Error0') {\n return false\n } else {\n return true\n }\n }\n return true\n }\n\n static own(error: object, key: string): unknown {\n if (this.isSelfProperty(error, key)) {\n return (error as Record<string, unknown>)[key]\n }\n return undefined\n }\n own(key: string): unknown {\n const ctor = this.constructor as typeof Error0\n return ctor.own(this, key)\n }\n\n static flow(error: object, key: string): unknown[] {\n return this.causes(error, true).map((cause) => {\n return this.own(cause, key)\n })\n }\n flow(key: string): unknown[] {\n const ctor = this.constructor as typeof Error0\n return ctor.flow(this, key)\n }\n\n static causes(error: unknown, instancesOnly?: false): unknown[]\n static causes<T extends typeof Error0>(this: T, error: unknown, instancesOnly: true): Array<InstanceType<T>>\n static causes(error: unknown, instancesOnly?: boolean): unknown[] {\n const causes: unknown[] = []\n let current: unknown = error\n const maxDepth = 99\n const seen = new Set<unknown>()\n for (let depth = 0; depth < maxDepth; depth += 1) {\n if (seen.has(current)) {\n break\n }\n seen.add(current)\n if (!instancesOnly || this.is(current)) {\n causes.push(current)\n }\n if (!current || typeof current !== 'object') {\n break\n }\n current = (current as { cause?: unknown }).cause\n }\n return causes\n }\n causes<T extends typeof Error0>(this: T, instancesOnly?: false): [InstanceType<T>, ...unknown[]]\n causes<T extends typeof Error0>(this: T, instancesOnly: true): [InstanceType<T>, ...Array<InstanceType<T>>]\n causes(instancesOnly?: boolean): unknown[] {\n const ctor = this.constructor as typeof Error0\n if (instancesOnly) {\n return ctor.causes(this, true)\n }\n return ctor.causes(this)\n }\n\n static is<T extends typeof Error0>(this: T, error: unknown): error is InstanceType<T> {\n return error instanceof this\n }\n\n static isSerialized(error: unknown): error is Record<string, unknown> {\n return !this.is(error) && typeof error === 'object' && error !== null && 'name' in error && error.name === 'Error0'\n }\n\n static from(error: unknown): Error0 {\n if (this.is(error)) {\n return error\n }\n if (this.isSerialized(error)) {\n return this._fromSerialized(error)\n }\n return this._fromNonError0(error)\n }\n\n private static _applyAdapt(error: Error0): Error0 {\n const plugin = this._getResolvedPlugin()\n for (const adapt of plugin.adapt) {\n const adapted = adapt(error as any)\n if (adapted && typeof adapted === 'object') {\n Object.assign(error as unknown as Record<string, unknown>, adapted)\n }\n }\n return error\n }\n\n private static _fromSerialized(error: unknown): Error0 {\n const message = this._extractMessage(error)\n if (typeof error !== 'object' || error === null) {\n return this._applyAdapt(new this(message, { cause: error }))\n }\n const errorRecord = error as Record<string, unknown>\n const recreated = new this(message)\n const plugin = this._getResolvedPlugin()\n const propsEntries = Object.entries(plugin.props)\n for (const [key, prop] of propsEntries) {\n if (prop.deserialize === false) {\n continue\n }\n if (!(key in errorRecord)) {\n continue\n }\n try {\n const value = prop.deserialize({ value: errorRecord[key], serialized: errorRecord })\n ;(recreated as unknown as Record<string, unknown>)[key] = value\n } catch {\n // ignore\n }\n }\n // we do not serialize causes\n // ;(recreated as unknown as { cause?: unknown }).cause = errorRecord.cause\n const isStackInProps = propsEntries.some(([key]) => key === 'stack')\n if (typeof errorRecord.stack === 'string' && !isStackInProps) {\n recreated.stack = errorRecord.stack\n }\n return recreated\n }\n\n private static _fromNonError0(error: unknown): Error0 {\n const message = this._extractMessage(error)\n return this._applyAdapt(new this(message, { cause: error }))\n }\n\n private static _extractMessage(error: unknown): string {\n return (\n (typeof error === 'string'\n ? error\n : typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string'\n ? error.message\n : undefined) || 'Unknown error'\n )\n }\n\n private static _useWithPlugin(\n this: typeof Error0,\n plugin: ErrorPlugin<ErrorPluginProps, ErrorPluginMethods>,\n ): ClassError0 {\n const Base = this as unknown as typeof Error0\n const Error0Extended = class Error0 extends Base {}\n ;(Error0Extended as typeof Error0)._plugins = [...Base._plugins, plugin]\n\n const resolved = (Error0Extended as typeof Error0)._getResolvedPlugin()\n for (const [key, method] of Object.entries(resolved.methods)) {\n Object.defineProperty((Error0Extended as typeof Error0).prototype, key, {\n value: function (...args: unknown[]) {\n return method(this as Error0, ...args)\n },\n writable: true,\n enumerable: true,\n configurable: true,\n })\n Object.defineProperty(Error0Extended, key, {\n value: function (error: unknown, ...args: unknown[]) {\n return method(this.from(error), ...args)\n },\n writable: true,\n enumerable: true,\n configurable: true,\n })\n }\n\n return Error0Extended as unknown as ClassError0\n }\n\n private static _pluginFromBuilder(plugin: PluginError0): ErrorPlugin<ErrorPluginProps, ErrorPluginMethods> {\n const pluginRecord = plugin as unknown as {\n _plugin: ErrorPlugin<ErrorPluginProps, ErrorPluginMethods>\n }\n return {\n props: { ...(pluginRecord._plugin.props ?? {}) },\n methods: { ...(pluginRecord._plugin.methods ?? {}) },\n adapt: [...(pluginRecord._plugin.adapt ?? [])],\n }\n }\n\n static prop<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(\n this: TThis,\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue>> {\n return this.use('prop', key, value)\n }\n\n static method<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(\n this: TThis,\n key: TKey,\n value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TArgs, TOutputValue>> {\n return this.use('method', key, value)\n }\n\n static adapt<TThis extends typeof Error0>(\n this: TThis,\n value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorOutputProps<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>> {\n return this.use('adapt', value)\n }\n\n static use<TThis extends typeof Error0, TBuilder extends PluginError0>(\n this: TThis,\n plugin: TBuilder,\n ): ClassError0<ExtendErrorPluginsMap<PluginsMapOf<TThis>, PluginOfBuilder<TBuilder>>>\n static use<TThis extends typeof Error0, TKey extends string, TInputValue, TOutputValue>(\n this: TThis,\n kind: 'prop',\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue>>\n static use<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(\n this: TThis,\n kind: 'method',\n key: TKey,\n value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TArgs, TOutputValue>>\n static use<TThis extends typeof Error0>(\n this: TThis,\n kind: 'adapt',\n value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorOutputProps<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use(\n this: typeof Error0,\n first: PluginError0 | 'prop' | 'method' | 'adapt',\n key?: string | ErrorPluginAdaptFn<any, any>,\n value?: ErrorPluginPropOptions<unknown, unknown> | ErrorPluginMethodFn<unknown>,\n ): ClassError0 {\n if (first instanceof PluginError0) {\n return this._useWithPlugin(this._pluginFromBuilder(first))\n }\n if (first === 'adapt') {\n if (typeof key !== 'function') {\n throw new Error('Error0.use(\"adapt\", value) requires adapt function')\n }\n return this._useWithPlugin({\n adapt: [key],\n })\n }\n if (typeof key !== 'string' || value === undefined) {\n throw new Error('Error0.use(kind, key, value) requires key and value')\n }\n\n if (first === 'prop') {\n return this._useWithPlugin({\n props: { [key]: value as ErrorPluginPropOptions<unknown, unknown> },\n })\n }\n return this._useWithPlugin({\n methods: { [key]: value as ErrorPluginMethodFn<unknown> },\n })\n }\n\n static plugin(): PluginError0 {\n return new PluginError0()\n }\n\n static serialize(error: unknown, isPublic = true): Record<string, unknown> {\n const error0 = this.from(error)\n const json: Record<string, unknown> = {\n name: error0.name,\n message: error0.message,\n // we do not serialize causes, it is enough that we have floated props and adapt helper\n // cause: error0.cause,\n }\n\n const plugin = this._getResolvedPlugin()\n const propsEntries = Object.entries(plugin.props)\n for (const [key, prop] of propsEntries) {\n if (prop.serialize === false) {\n continue\n }\n try {\n const value = prop.resolve({ value: error0.own(key), flow: error0.flow(key), error: error0 })\n const jsonValue = prop.serialize({ value, error: error0, isPublic })\n if (jsonValue !== undefined) {\n json[key] = jsonValue\n }\n } catch {\n // ignore\n }\n }\n const isStackInProps = propsEntries.some(([key]) => key === 'stack')\n if (!isStackInProps && typeof error0.stack === 'string') {\n json.stack = error0.stack\n }\n return Object.fromEntries(Object.entries(json).filter(([, value]) => value !== undefined)) as Record<\n string,\n unknown\n >\n }\n\n serialize(isPublic = true): object {\n const ctor = this.constructor as typeof Error0\n return ctor.serialize(this, isPublic)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8KO,MAAM,aAGX;AAAA,EACiB;AAAA,EAER,QAAQ;AAAA,EAKjB,YAAY,QAA4D;AACtE,SAAK,UAAU;AAAA,MACb,OAAO,EAAE,GAAI,QAAQ,SAAS,CAAC,EAAG;AAAA,MAClC,SAAS,EAAE,GAAI,QAAQ,WAAW,CAAC,EAAG;AAAA,MACtC,OAAO,CAAC,GAAI,QAAQ,SAAS,CAAC,CAAE;AAAA,IAClC;AAAA,EACF;AAAA,EAEA,KACE,KACA,OACuF;AACvF,WAAO,KAAK,IAAI,QAAQ,KAAK,KAAK;AAAA,EACpC;AAAA,EAEA,OACE,KACA,OACqF;AACrF,WAAO,KAAK,IAAI,UAAU,KAAK,KAAK;AAAA,EACtC;AAAA,EAEA,MACE,OACgC;AAChC,WAAO,KAAK,IAAI,SAAS,KAAK;AAAA,EAChC;AAAA,EAgBA,IACE,MACA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