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

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/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const RESERVED_STACK_PROP_ERROR = 'Error0: "stack" is a reserved prop key. Use .stack(...) plugin API instead';
1
2
  class PluginError0 {
2
3
  _plugin;
3
4
  Infer = void 0;
@@ -5,7 +6,9 @@ class PluginError0 {
5
6
  this._plugin = {
6
7
  props: { ...plugin?.props ?? {} },
7
8
  methods: { ...plugin?.methods ?? {} },
8
- adapt: [...plugin?.adapt ?? []]
9
+ adapt: [...plugin?.adapt ?? []],
10
+ stack: plugin?.stack,
11
+ cause: plugin?.cause
9
12
  };
10
13
  }
11
14
  prop(key, value) {
@@ -17,12 +20,23 @@ class PluginError0 {
17
20
  adapt(value) {
18
21
  return this.use("adapt", value);
19
22
  }
23
+ stack(value) {
24
+ return this.use("stack", value);
25
+ }
26
+ cause(value) {
27
+ return this.use("cause", value);
28
+ }
20
29
  use(kind, keyOrValue, value) {
21
30
  const nextProps = { ...this._plugin.props ?? {} };
22
31
  const nextMethods = { ...this._plugin.methods ?? {} };
23
32
  const nextAdapt = [...this._plugin.adapt ?? []];
33
+ let nextStack = this._plugin.stack;
34
+ let nextCause = this._plugin.cause;
24
35
  if (kind === "prop") {
25
36
  const key = keyOrValue;
37
+ if (key === "stack") {
38
+ throw new Error(RESERVED_STACK_PROP_ERROR);
39
+ }
26
40
  if (value === void 0) {
27
41
  throw new Error('PluginError0.use("prop", key, value) requires value');
28
42
  }
@@ -33,13 +47,19 @@ class PluginError0 {
33
47
  throw new Error('PluginError0.use("method", key, value) requires value');
34
48
  }
35
49
  nextMethods[key] = value;
36
- } else {
50
+ } else if (kind === "adapt") {
37
51
  nextAdapt.push(keyOrValue);
52
+ } else if (kind === "stack") {
53
+ nextStack = keyOrValue;
54
+ } else {
55
+ nextCause = keyOrValue;
38
56
  }
39
57
  return new PluginError0({
40
58
  props: nextProps,
41
59
  methods: nextMethods,
42
- adapt: nextAdapt
60
+ adapt: nextAdapt,
61
+ stack: nextStack,
62
+ cause: nextCause
43
63
  });
44
64
  }
45
65
  }
@@ -49,7 +69,9 @@ class Error0 extends Error {
49
69
  static _emptyPlugin = {
50
70
  props: {},
51
71
  methods: {},
52
- adapt: []
72
+ adapt: [],
73
+ stack: void 0,
74
+ cause: void 0
53
75
  };
54
76
  static _getResolvedPlugin() {
55
77
  const resolved = {
@@ -58,9 +80,18 @@ class Error0 extends Error {
58
80
  adapt: []
59
81
  };
60
82
  for (const plugin of this._plugins) {
83
+ if (plugin.props && "stack" in plugin.props) {
84
+ throw new Error(RESERVED_STACK_PROP_ERROR);
85
+ }
61
86
  Object.assign(resolved.props, plugin.props ?? this._emptyPlugin.props);
62
87
  Object.assign(resolved.methods, plugin.methods ?? this._emptyPlugin.methods);
63
88
  resolved.adapt.push(...plugin.adapt ?? this._emptyPlugin.adapt);
89
+ if (typeof plugin.stack !== "undefined") {
90
+ resolved.stack = plugin.stack;
91
+ }
92
+ if (typeof plugin.cause !== "undefined") {
93
+ resolved.cause = plugin.cause;
94
+ }
64
95
  }
65
96
  return resolved;
66
97
  }
@@ -72,12 +103,21 @@ class Error0 extends Error {
72
103
  const ctor = this.constructor;
73
104
  const plugin = ctor._getResolvedPlugin();
74
105
  for (const [key, prop] of Object.entries(plugin.props)) {
106
+ if (key === "stack") {
107
+ continue;
108
+ }
75
109
  if (key in input) {
76
110
  const ownValue = input[key];
77
- this[key] = prop.init(ownValue);
111
+ if (typeof prop.init === "function") {
112
+ ;
113
+ this[key] = prop.init(ownValue);
114
+ } else {
115
+ ;
116
+ this[key] = ownValue;
117
+ }
78
118
  } else {
79
119
  Object.defineProperty(this, key, {
80
- get: () => prop.resolve({ value: void 0, flow: this.flow(key), error: this }),
120
+ get: () => prop.resolve({ own: void 0, flow: this.flow(key), error: this }),
81
121
  set: (value) => {
82
122
  Object.defineProperty(this, key, {
83
123
  value,
@@ -104,24 +144,73 @@ class Error0 extends Error {
104
144
  }
105
145
  return true;
106
146
  };
107
- static own(error, key) {
147
+ static _ownByKey(error, key) {
108
148
  if (this.isSelfProperty(error, key)) {
109
149
  return error[key];
110
150
  }
111
151
  return void 0;
112
152
  }
153
+ static _flowByKey(error, key) {
154
+ return this.causes(error, true).map((cause) => {
155
+ return this._ownByKey(cause, key);
156
+ });
157
+ }
158
+ static own(error, key) {
159
+ const error0 = this.from(error);
160
+ if (key === void 0) {
161
+ const ownValues = {};
162
+ const plugin = this._getResolvedPlugin();
163
+ for (const ownKey of Object.keys(plugin.props)) {
164
+ ownValues[ownKey] = this._ownByKey(error0, ownKey);
165
+ }
166
+ return ownValues;
167
+ }
168
+ return this._ownByKey(error0, key);
169
+ }
113
170
  own(key) {
114
171
  const ctor = this.constructor;
115
- return ctor.own(this, key);
172
+ if (key === void 0) {
173
+ return ctor.own(this);
174
+ }
175
+ return ctor._ownByKey(this, key);
116
176
  }
117
177
  static flow(error, key) {
118
- return this.causes(error, true).map((cause) => {
119
- return this.own(cause, key);
120
- });
178
+ const error0 = this.from(error);
179
+ return this._flowByKey(error0, key);
121
180
  }
122
181
  flow(key) {
123
182
  const ctor = this.constructor;
124
- return ctor.flow(this, key);
183
+ return ctor._flowByKey(this, key);
184
+ }
185
+ static resolve(error) {
186
+ const error0 = this.from(error);
187
+ const resolved = {};
188
+ const plugin = this._getResolvedPlugin();
189
+ for (const [key, prop] of Object.entries(plugin.props)) {
190
+ try {
191
+ const options = Object.defineProperties(
192
+ {
193
+ error: error0
194
+ },
195
+ {
196
+ own: {
197
+ get: () => error0.own(key)
198
+ },
199
+ flow: {
200
+ get: () => error0.flow(key)
201
+ }
202
+ }
203
+ );
204
+ resolved[key] = prop.resolve(options);
205
+ } catch {
206
+ console.error(`Error0: failed to resolve property ${key}`, error0);
207
+ }
208
+ }
209
+ return resolved;
210
+ }
211
+ resolve() {
212
+ const ctor = this.constructor;
213
+ return ctor.resolve(this);
125
214
  }
126
215
  static causes(error, instancesOnly) {
127
216
  const causes = [];
@@ -195,11 +284,32 @@ class Error0 extends Error {
195
284
  const value = prop.deserialize({ value: errorRecord[key], serialized: errorRecord });
196
285
  recreated[key] = value;
197
286
  } catch {
287
+ console.error(`Error0: failed to deserialize property ${key}`, errorRecord);
198
288
  }
199
289
  }
200
- const isStackInProps = propsEntries.some(([key]) => key === "stack");
201
- if (typeof errorRecord.stack === "string" && !isStackInProps) {
202
- recreated.stack = errorRecord.stack;
290
+ const stackPlugin = plugin.stack;
291
+ if (stackPlugin !== false && "stack" in errorRecord) {
292
+ try {
293
+ if (typeof errorRecord.stack === "string") {
294
+ recreated.stack = errorRecord.stack;
295
+ }
296
+ } catch {
297
+ console.error("Error0: failed to deserialize stack", errorRecord);
298
+ }
299
+ }
300
+ const causePlugin = plugin.cause ?? false;
301
+ if (causePlugin && "cause" in errorRecord) {
302
+ try {
303
+ if (this.isSerialized(errorRecord.cause)) {
304
+ ;
305
+ recreated.cause = this._fromSerialized(errorRecord.cause);
306
+ } else {
307
+ ;
308
+ recreated.cause = errorRecord.cause;
309
+ }
310
+ } catch {
311
+ console.error("Error0: failed to deserialize cause", errorRecord);
312
+ }
203
313
  }
204
314
  return recreated;
205
315
  }
@@ -241,7 +351,9 @@ class Error0 extends Error {
241
351
  return {
242
352
  props: { ...pluginRecord._plugin.props ?? {} },
243
353
  methods: { ...pluginRecord._plugin.methods ?? {} },
244
- adapt: [...pluginRecord._plugin.adapt ?? []]
354
+ adapt: [...pluginRecord._plugin.adapt ?? []],
355
+ stack: pluginRecord._plugin.stack,
356
+ cause: pluginRecord._plugin.cause
245
357
  };
246
358
  }
247
359
  static prop(key, value) {
@@ -253,10 +365,38 @@ class Error0 extends Error {
253
365
  static adapt(value) {
254
366
  return this.use("adapt", value);
255
367
  }
368
+ static stack(value) {
369
+ return this.use("stack", value);
370
+ }
371
+ static cause(value) {
372
+ return this.use("cause", value);
373
+ }
256
374
  static use(first, key, value) {
257
375
  if (first instanceof PluginError0) {
258
376
  return this._useWithPlugin(this._pluginFromBuilder(first));
259
377
  }
378
+ if (first === "stack") {
379
+ if (typeof key === "undefined") {
380
+ throw new Error('Error0.use("stack", value) requires stack plugin value');
381
+ }
382
+ if (key !== "merge" && typeof key !== "boolean" && typeof key !== "function") {
383
+ throw new Error('Error0.use("stack", value) expects function | boolean | "merge"');
384
+ }
385
+ return this._useWithPlugin({
386
+ stack: key
387
+ });
388
+ }
389
+ if (first === "cause") {
390
+ if (typeof key === "undefined") {
391
+ throw new Error('Error0.use("cause", value) requires cause plugin value');
392
+ }
393
+ if (typeof key !== "boolean" && typeof key !== "function") {
394
+ throw new Error('Error0.use("cause", value) expects function | boolean');
395
+ }
396
+ return this._useWithPlugin({
397
+ cause: key
398
+ });
399
+ }
260
400
  if (first === "adapt") {
261
401
  if (typeof key !== "function") {
262
402
  throw new Error('Error0.use("adapt", value) requires adapt function');
@@ -269,6 +409,9 @@ class Error0 extends Error {
269
409
  throw new Error("Error0.use(kind, key, value) requires key and value");
270
410
  }
271
411
  if (first === "prop") {
412
+ if (key === "stack") {
413
+ throw new Error(RESERVED_STACK_PROP_ERROR);
414
+ }
272
415
  return this._useWithPlugin({
273
416
  props: { [key]: value }
274
417
  });
@@ -282,6 +425,8 @@ class Error0 extends Error {
282
425
  }
283
426
  static serialize(error, isPublic = true) {
284
427
  const error0 = this.from(error);
428
+ const resolvedProps = this.resolve(error0);
429
+ const resolvedRecord = resolvedProps;
285
430
  const json = {
286
431
  name: error0.name,
287
432
  message: error0.message
@@ -295,17 +440,56 @@ class Error0 extends Error {
295
440
  continue;
296
441
  }
297
442
  try {
298
- const value = prop.resolve({ value: error0.own(key), flow: error0.flow(key), error: error0 });
443
+ const value = resolvedRecord[key];
299
444
  const jsonValue = prop.serialize({ value, error: error0, isPublic });
300
445
  if (jsonValue !== void 0) {
301
446
  json[key] = jsonValue;
302
447
  }
303
448
  } catch {
449
+ console.error(`Error0: failed to serialize property ${key}`, resolvedRecord);
304
450
  }
305
451
  }
306
- const isStackInProps = propsEntries.some(([key]) => key === "stack");
307
- if (!isStackInProps && typeof error0.stack === "string") {
308
- json.stack = error0.stack;
452
+ const stackSerialize = plugin.stack;
453
+ if (stackSerialize !== false) {
454
+ try {
455
+ let serializedStack;
456
+ if (stackSerialize === "merge") {
457
+ serializedStack = error0.causes().map((cause) => {
458
+ return cause instanceof Error ? cause.stack : void 0;
459
+ }).filter((value) => typeof value === "string").join("\n");
460
+ } else if (typeof stackSerialize === "function") {
461
+ serializedStack = stackSerialize({ value: error0.stack, error: error0, isPublic });
462
+ } else {
463
+ serializedStack = error0.stack;
464
+ }
465
+ if (serializedStack !== void 0) {
466
+ json.stack = serializedStack;
467
+ }
468
+ } catch {
469
+ console.error("Error0: failed to serialize stack", error0);
470
+ }
471
+ }
472
+ const causeSerialize = plugin.cause ?? false;
473
+ if (causeSerialize) {
474
+ try {
475
+ if (causeSerialize === true) {
476
+ const causeValue = error0.cause;
477
+ if (this.is(causeValue)) {
478
+ json.cause = this.serialize(causeValue, isPublic);
479
+ }
480
+ } else {
481
+ const serializedCause = causeSerialize({
482
+ value: error0.cause,
483
+ error: error0,
484
+ isPublic
485
+ });
486
+ if (serializedCause !== void 0) {
487
+ json.cause = serializedCause;
488
+ }
489
+ }
490
+ } catch {
491
+ console.error("Error0: failed to serialize cause", error0);
492
+ }
309
493
  }
310
494
  return Object.fromEntries(Object.entries(json).filter(([, value]) => value !== void 0));
311
495
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["type IsUnknown<T> = unknown extends T ? ([T] extends [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":"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,YACA,OACwB;AACxB,UAAM,YAA8B,EAAE,GAAI,KAAK,QAAQ,SAAS,CAAC,EAAG;AACpE,UAAM,cAAkC,EAAE,GAAI,KAAK,QAAQ,WAAW,CAAC,EAAG;AAC1E,UAAM,YAAwE,CAAC,GAAI,KAAK,QAAQ,SAAS,CAAC,CAAE;AAC5G,QAAI,SAAS,QAAQ;AACnB,YAAM,MAAM;AACZ,UAAI,UAAU,QAAW;AACvB,cAAM,IAAI,MAAM,qD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QAAQ,SAAS,CAAC;AACnE,YAAI,cAAc,QAAW;AAC3B,eAAK,GAAG,IAAI;AAAA,QACd;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AACA,UAAM,iBAAiB,aAAa,KAAK,CAAC,CAAC,GAAG,MAAM,QAAQ,OAAO;AACnE,QAAI,CAAC,kBAAkB,OAAO,OAAO,UAAU,UAAU;AACvD,WAAK,QAAQ,OAAO;AAAA,IACtB;AACA,WAAO,OAAO,YAAY,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,CAAC;AAAA,EAI3F;AAAA,EAEA,UAAU,WAAW,MAAc;AACjC,UAAM,OAAO,KAAK;AAClB,WAAO,KAAK,UAAU,MAAM,QAAQ;AAAA,EACtC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["type IsUnknown<T> = unknown extends T ? ([T] extends [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, any>> = TProp extends {\n init: infer TInit\n}\n ? NormalizeUnknownToUndefined<InferFirstArg<TInit>>\n : undefined\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\ntype ErrorPluginPropOptionsBase<TOutputValue, TError extends Error0, TResolveValue extends TOutputValue | undefined> = {\n resolve: (options: {\n own: TOutputValue | undefined\n flow: Array<TOutputValue | undefined>\n error: TError\n }) => TResolveValue\n serialize: ErrorPluginPropSerialize<TResolveValue, TError>\n deserialize: ErrorPluginPropDeserialize<TOutputValue>\n}\ntype ErrorPluginPropOptionsWithInit<\n TInputValue,\n TOutputValue,\n TError extends Error0,\n TResolveValue extends TOutputValue | undefined,\n> = ErrorPluginPropOptionsBase<TOutputValue, TError, TResolveValue> & {\n init: ErrorPluginPropInit<TInputValue, TOutputValue>\n}\ntype ErrorPluginPropOptionsWithoutInit<\n TOutputValue,\n TError extends Error0,\n TResolveValue extends TOutputValue | undefined,\n> = ErrorPluginPropOptionsBase<TOutputValue, TError, TResolveValue> & {\n init?: undefined\n}\nexport type ErrorPluginPropOptions<\n TInputValue = undefined,\n TOutputValue = unknown,\n TError extends Error0 = Error0,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n> =\n | ErrorPluginPropOptionsWithInit<TInputValue, TOutputValue, TError, TResolveValue>\n | ErrorPluginPropOptionsWithoutInit<TOutputValue, TError, TResolveValue>\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>)\nexport type ErrorPluginStackSerialize<TError extends Error0> =\n | ((options: { value: string | undefined; error: TError; isPublic: boolean }) => unknown)\n | boolean\n | 'merge'\nexport type ErrorPluginStack<TError extends Error0 = Error0> = ErrorPluginStackSerialize<TError>\nexport type ErrorPluginCauseSerialize<TError extends Error0> =\n | ((options: { value: unknown; error: TError; isPublic: boolean }) => unknown)\n | boolean\nexport type ErrorPluginCause<TError extends Error0 = Error0> = ErrorPluginCauseSerialize<TError>\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 stack?: ErrorPluginStack\n cause?: ErrorPluginCause\n}\ntype AddPropToPluginProps<\n TProps extends ErrorPluginProps,\n TKey extends string,\n TInputValue,\n TOutputValue,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n> = TProps & Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue, Error0, TResolveValue>>\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, any, any, infer TResolveValue>\n ? TResolveValue\n : never\n}\nexport type ErrorPluginsMap = {\n props: Record<string, { init: unknown; output: 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 ErrorResolvedProps<TPluginsMap extends ErrorPluginsMap> = {\n [TKey in keyof TPluginsMap['props']]: TPluginsMap['props'][TKey]['resolve']\n}\ntype ErrorOwnProps<TPluginsMap extends ErrorPluginsMap> = {\n [TKey in keyof TPluginsMap['props']]: TPluginsMap['props'][TKey]['output'] | undefined\n}\ntype ErrorOwnMethods<TPluginsMap extends ErrorPluginsMap> = {\n own: {\n (): ErrorOwnProps<TPluginsMap>\n <TKey extends keyof TPluginsMap['props'] & string>(key: TKey): ErrorOwnProps<TPluginsMap>[TKey]\n }\n flow: <TKey extends keyof TPluginsMap['props'] & string>(key: TKey) => Array<ErrorOwnProps<TPluginsMap>[TKey]>\n}\ntype ErrorResolveMethods<TPluginsMap extends ErrorPluginsMap> = {\n resolve: () => ErrorResolvedProps<TPluginsMap>\n}\ntype ErrorMethods<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 ErrorResolved<TPluginsMap extends ErrorPluginsMap> = ErrorResolvedProps<TPluginsMap> &\n ErrorMethods<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; output: never; resolve: never }>\n methods: Record<never, ErrorMethodRecord>\n}\n\ntype ErrorPluginResolved = {\n props: Record<string, ErrorPluginPropOptions<unknown>>\n methods: Record<string, ErrorPluginMethodFn<unknown>>\n adapt: Array<ErrorPluginAdaptFn<Error0, Record<string, unknown>>>\n stack?: ErrorPluginStack\n cause?: ErrorPluginCause\n}\nconst RESERVED_STACK_PROP_ERROR = 'Error0: \"stack\" is a reserved prop key. Use .stack(...) plugin API instead'\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 any,\n infer TResolveValue\n >\n ? {\n init: InferPluginPropInput<NonNullable<TPlugin['props']>[TKey]>\n output: TOutputValue\n resolve: TResolveValue\n }\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 TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n> = ExtendErrorPluginsMap<\n TMap,\n ErrorPlugin<Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue, Error0, TResolveValue>>>\n>\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\ntype PluginsMapOfInstance<TInstance> = TInstance extends { constructor: { __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 & ErrorResolved<TMap>\ntype BuilderError0<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = Error0 &\n ErrorResolved<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 stack: plugin?.stack,\n cause: plugin?.cause,\n }\n }\n\n prop<\n TKey extends string,\n TInputValue = undefined,\n TOutputValue = unknown,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n >(\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>, TResolveValue>,\n ): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue, TResolveValue>, 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 stack(value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods> {\n return this.use('stack', value)\n }\n\n cause(value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods> {\n return this.use('cause', value)\n }\n\n use<\n TKey extends string,\n TInputValue = undefined,\n TOutputValue = unknown,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n >(\n kind: 'prop',\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>, TResolveValue>,\n ): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue, TResolveValue>, 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(kind: 'stack', value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>\n use(kind: 'cause', value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>\n use(\n kind: 'prop' | 'method' | 'adapt' | 'stack' | 'cause',\n keyOrValue: unknown,\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 let nextStack: ErrorPluginStack | undefined = this._plugin.stack\n let nextCause: ErrorPluginCause | undefined = this._plugin.cause\n if (kind === 'prop') {\n const key = keyOrValue as string\n if (key === 'stack') {\n throw new Error(RESERVED_STACK_PROP_ERROR)\n }\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 if (kind === 'adapt') {\n nextAdapt.push(keyOrValue as ErrorPluginAdaptFn<Error0, Record<string, unknown>>)\n } else if (kind === 'stack') {\n nextStack = keyOrValue as ErrorPluginStack\n } else {\n nextCause = keyOrValue as ErrorPluginCause\n }\n return new PluginError0({\n props: nextProps,\n methods: nextMethods,\n adapt: nextAdapt,\n stack: nextStack,\n cause: nextCause,\n })\n }\n}\n\nexport type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {\n new (\n message: string,\n input?: ErrorInput<TPluginsMap>,\n ): Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>\n new (\n input: { message: string } & ErrorInput<TPluginsMap>,\n ): Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>\n readonly __pluginsMap?: TPluginsMap\n from: (\n error: unknown,\n ) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>\n resolve: (error: unknown) => ErrorResolvedProps<TPluginsMap>\n serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>\n own: {\n (error: object): ErrorOwnProps<TPluginsMap>\n <TKey extends keyof TPluginsMap['props'] & string>(error: object, key: TKey): ErrorOwnProps<TPluginsMap>[TKey]\n }\n flow: <TKey extends keyof TPluginsMap['props'] & string>(\n error: object,\n key: TKey,\n ) => Array<ErrorOwnProps<TPluginsMap>[TKey]>\n prop: <\n TKey extends string,\n TInputValue = undefined,\n TOutputValue = unknown,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n >(\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>, TResolveValue>,\n ) => ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue, TResolveValue>>\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>, ErrorResolvedProps<TPluginsMap>>,\n ) => ClassError0<TPluginsMap>\n stack: (value: ErrorPluginStack<ErrorInstanceOfMap<TPluginsMap>>) => ClassError0<TPluginsMap>\n cause: (value: ErrorPluginCause<ErrorInstanceOfMap<TPluginsMap>>) => ClassError0<TPluginsMap>\n use: {\n <TBuilder extends PluginError0>(\n plugin: TBuilder,\n ): ClassError0<ExtendErrorPluginsMap<TPluginsMap, PluginOfBuilder<TBuilder>>>\n <\n TKey extends string,\n TInputValue = undefined,\n TOutputValue = unknown,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n >(\n kind: 'prop',\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>, TResolveValue>,\n ): ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue, TResolveValue>>\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>, ErrorResolvedProps<TPluginsMap>>,\n ): ClassError0<TPluginsMap>\n (kind: 'stack', value: ErrorPluginStack<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>\n (kind: 'cause', value: ErrorPluginCause<ErrorInstanceOfMap<TPluginsMap>>): 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 stack: undefined,\n cause: undefined,\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 if (plugin.props && 'stack' in plugin.props) {\n throw new Error(RESERVED_STACK_PROP_ERROR)\n }\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 if (typeof plugin.stack !== 'undefined') {\n resolved.stack = plugin.stack\n }\n if (typeof plugin.cause !== 'undefined') {\n resolved.cause = plugin.cause\n }\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 === 'stack') {\n continue\n }\n if (key in input) {\n const ownValue = (input as Record<string, unknown>)[key]\n if (typeof prop.init === 'function') {\n ;(this as Record<string, unknown>)[key] = prop.init(ownValue)\n } else {\n ;(this as Record<string, unknown>)[key] = ownValue\n }\n } else {\n Object.defineProperty(this, key, {\n get: () => prop.resolve({ own: 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 private static _ownByKey(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 private static _flowByKey(error: object, key: string): unknown[] {\n return this.causes(error, true).map((cause) => {\n return this._ownByKey(cause, key)\n })\n }\n\n static own<TThis extends typeof Error0>(this: TThis, error: unknown): ErrorOwnProps<PluginsMapOf<TThis>>\n static own<TThis extends typeof Error0, TKey extends keyof PluginsMapOf<TThis>['props'] & string>(\n this: TThis,\n error: unknown,\n key: TKey,\n ): ErrorOwnProps<PluginsMapOf<TThis>>[TKey]\n static own(error: unknown, key?: string): unknown {\n const error0 = this.from(error)\n if (key === undefined) {\n const ownValues: Record<string, unknown> = {}\n const plugin = this._getResolvedPlugin()\n for (const ownKey of Object.keys(plugin.props)) {\n ownValues[ownKey] = this._ownByKey(error0, ownKey)\n }\n return ownValues\n }\n return this._ownByKey(error0, key)\n }\n own<TThis extends Error0>(this: TThis): ErrorOwnProps<PluginsMapOfInstance<TThis>>\n own<TThis extends Error0, TKey extends keyof PluginsMapOfInstance<TThis>['props'] & string>(\n this: TThis,\n key: TKey,\n ): ErrorOwnProps<PluginsMapOfInstance<TThis>>[TKey]\n own(key?: string): unknown {\n const ctor = this.constructor as typeof Error0\n if (key === undefined) {\n return ctor.own(this)\n }\n return ctor._ownByKey(this, key)\n }\n\n static flow<TThis extends typeof Error0, TKey extends keyof PluginsMapOf<TThis>['props'] & string>(\n this: TThis,\n error: unknown,\n key: TKey,\n ): Array<ErrorOwnProps<PluginsMapOf<TThis>>[TKey]>\n static flow(error: unknown, key: string): unknown[]\n static flow(error: unknown, key: string): unknown[] {\n const error0 = this.from(error)\n return this._flowByKey(error0, key)\n }\n flow<TThis extends Error0, TKey extends keyof PluginsMapOfInstance<TThis>['props'] & string>(\n this: TThis,\n key: TKey,\n ): Array<ErrorOwnProps<PluginsMapOfInstance<TThis>>[TKey]>\n flow(key: string): unknown[]\n flow(key: string): unknown[] {\n const ctor = this.constructor as typeof Error0\n return ctor._flowByKey(this, key)\n }\n\n static resolve<TThis extends typeof Error0>(this: TThis, error: unknown): ErrorResolvedProps<PluginsMapOf<TThis>>\n static resolve(error: unknown): Record<string, unknown>\n static resolve(error: unknown): Record<string, unknown> {\n const error0 = this.from(error)\n const resolved: Record<string, unknown> = {}\n const plugin = this._getResolvedPlugin()\n for (const [key, prop] of Object.entries(plugin.props)) {\n try {\n // resolved[key] = (error0 as unknown as Record<string, unknown>)[key]\n const options = Object.defineProperties(\n {\n error: error0,\n },\n {\n own: {\n get: () => error0.own(key as never),\n },\n flow: {\n get: () => error0.flow(key),\n },\n },\n )\n resolved[key] = prop.resolve(options as never)\n // resolved[key] = prop.resolve({ own: error0.own(key as never), flow: error0.flow(key), error: error0 })\n } catch {\n // eslint-disable-next-line no-console\n console.error(`Error0: failed to resolve property ${key}`, error0)\n }\n }\n return resolved\n }\n resolve<TThis extends Error0>(this: TThis): ErrorResolvedProps<PluginsMapOfInstance<TThis>>\n resolve(): Record<string, unknown>\n resolve(): Record<string, unknown> {\n const ctor = this.constructor as typeof Error0\n return ctor.resolve(this)\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<TThis extends Error0>(this: TThis, instancesOnly?: false): [TThis, ...unknown[]]\n causes<TThis extends Error0>(this: TThis, instancesOnly: true): [TThis, ...TThis[]]\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 // eslint-disable-next-line no-console\n console.error(`Error0: failed to deserialize property ${key}`, errorRecord)\n }\n }\n // we do not serialize causes\n // ;(recreated as unknown as { cause?: unknown }).cause = errorRecord.cause\n const stackPlugin = plugin.stack\n if (stackPlugin !== false && 'stack' in errorRecord) {\n try {\n if (typeof errorRecord.stack === 'string') {\n recreated.stack = errorRecord.stack\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to deserialize stack', errorRecord)\n }\n }\n const causePlugin = plugin.cause ?? false\n if (causePlugin && 'cause' in errorRecord) {\n try {\n if (this.isSerialized(errorRecord.cause)) {\n ;(recreated as { cause?: unknown }).cause = this._fromSerialized(errorRecord.cause)\n } else {\n ;(recreated as { cause?: unknown }).cause = errorRecord.cause\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to deserialize cause', errorRecord)\n }\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 stack: pluginRecord._plugin.stack,\n cause: pluginRecord._plugin.cause,\n }\n }\n\n static prop<\n TThis extends typeof Error0,\n TKey extends string,\n TInputValue = undefined,\n TOutputValue = unknown,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n >(\n this: TThis,\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>, TResolveValue>,\n ): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue, TResolveValue>> {\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>>, ErrorResolvedProps<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>> {\n return this.use('adapt', value)\n }\n\n static stack<TThis extends typeof Error0>(\n this: TThis,\n value: ErrorPluginStack<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>> {\n return this.use('stack', value)\n }\n\n static cause<TThis extends typeof Error0>(\n this: TThis,\n value: ErrorPluginCause<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>> {\n return this.use('cause', 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<\n TThis extends typeof Error0,\n TKey extends string,\n TInputValue = undefined,\n TOutputValue = unknown,\n TResolveValue extends TOutputValue | undefined = TOutputValue | undefined,\n >(\n this: TThis,\n kind: 'prop',\n key: TKey,\n value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>, TResolveValue>,\n ): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue, TResolveValue>>\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>>, ErrorResolvedProps<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use<TThis extends typeof Error0>(\n this: TThis,\n kind: 'stack',\n value: ErrorPluginStack<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use<TThis extends typeof Error0>(\n this: TThis,\n kind: 'cause',\n value: ErrorPluginCause<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use(\n this: typeof Error0,\n first: PluginError0 | 'prop' | 'method' | 'adapt' | 'stack' | 'cause',\n key?: unknown,\n value?: ErrorPluginPropOptions<unknown> | ErrorPluginMethodFn<unknown>,\n ): ClassError0 {\n if (first instanceof PluginError0) {\n return this._useWithPlugin(this._pluginFromBuilder(first))\n }\n if (first === 'stack') {\n if (typeof key === 'undefined') {\n throw new Error('Error0.use(\"stack\", value) requires stack plugin value')\n }\n if (key !== 'merge' && typeof key !== 'boolean' && typeof key !== 'function') {\n throw new Error('Error0.use(\"stack\", value) expects function | boolean | \"merge\"')\n }\n return this._useWithPlugin({\n stack: key as ErrorPluginStack,\n })\n }\n if (first === 'cause') {\n if (typeof key === 'undefined') {\n throw new Error('Error0.use(\"cause\", value) requires cause plugin value')\n }\n if (typeof key !== 'boolean' && typeof key !== 'function') {\n throw new Error('Error0.use(\"cause\", value) expects function | boolean')\n }\n return this._useWithPlugin({\n cause: key as ErrorPluginCause,\n })\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 as ErrorPluginAdaptFn<Error0, Record<string, unknown>>],\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 if (key === 'stack') {\n throw new Error(RESERVED_STACK_PROP_ERROR)\n }\n return this._useWithPlugin({\n props: { [key]: value as ErrorPluginPropOptions<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 resolvedProps = this.resolve(error0)\n const resolvedRecord = resolvedProps as Record<string, unknown>\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 = resolvedRecord[key]\n const jsonValue = prop.serialize({ value, error: error0, isPublic })\n if (jsonValue !== undefined) {\n json[key] = jsonValue\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error(`Error0: failed to serialize property ${key}`, resolvedRecord)\n }\n }\n const stackSerialize = plugin.stack\n if (stackSerialize !== false) {\n try {\n let serializedStack: unknown\n if (stackSerialize === 'merge') {\n serializedStack = error0\n .causes()\n .map((cause) => {\n return cause instanceof Error ? cause.stack : undefined\n })\n .filter((value): value is string => typeof value === 'string')\n .join('\\n')\n } else if (typeof stackSerialize === 'function') {\n serializedStack = stackSerialize({ value: error0.stack, error: error0, isPublic })\n } else {\n serializedStack = error0.stack\n }\n if (serializedStack !== undefined) {\n json.stack = serializedStack\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to serialize stack', error0)\n }\n }\n const causeSerialize = plugin.cause ?? false\n if (causeSerialize) {\n try {\n if (causeSerialize === true) {\n const causeValue = (error0 as { cause?: unknown }).cause\n if (this.is(causeValue)) {\n json.cause = this.serialize(causeValue, isPublic)\n }\n } else {\n const serializedCause = causeSerialize({\n value: (error0 as { cause?: unknown }).cause,\n error: error0,\n isPublic,\n })\n if (serializedCause !== undefined) {\n json.cause = serializedCause\n }\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to serialize cause', error0)\n }\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): Record<string, unknown> {\n const ctor = this.constructor as typeof Error0\n return ctor.serialize(this, isPublic)\n }\n}\n"],"mappings":"AA4KA,MAAM,4BAA4B;AA0E3B,MAAM,aAGX;AAAA,EACiB;AAAA,EAER,QA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F,YAAI,mBAAmB,MAAM;AAC3B,gBAAM,aAAc,OAA+B;AACnD,cAAI,KAAK,GAAG,UAAU,GAAG;AACvB,iBAAK,QAAQ,KAAK,UAAU,YAAY,QAAQ;AAAA,UAClD;AAAA,QACF,OAAO;AACL,gBAAM,kBAAkB,eAAe;AAAA,YACrC,OAAQ,OAA+B;AAAA,YACvC,OAAO;AAAA,YACP;AAAA,UACF,CAAC;AACD,cAAI,oBAAoB,QAAW;AACjC,iBAAK,QAAQ;AAAA,UACf;AAAA,QACF;AAAA,MACF,QAAQ;AAEN,gBAAQ,MAAM,qCAAqC,MAAM;AAAA,MAC3D;AAAA,IACF;AACA,WAAO,OAAO,YAAY,OAAO,QAAQ,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,CAAC;AAAA,EAI3F;AAAA,EAEA,UAAU,WAAW,MAA+B;AAClD,UAAM,OAAO,KAAK;AAClB,WAAO,KAAK,UAAU,MAAM,QAAQ;AAAA,EACtC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devp0nt/error0",
3
- "version": "1.0.0-next.42",
3
+ "version": "1.0.0-next.44",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Sergei Dmitriev",