@devp0nt/error0 1.0.0-next.47 → 1.0.0-next.48
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 +7 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +18 -3
- package/src/index.ts +13 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -298,6 +298,9 @@ class Error0 extends Error {
|
|
|
298
298
|
}
|
|
299
299
|
return this._fromNonError0(error);
|
|
300
300
|
}
|
|
301
|
+
static round(error, isPublic = false) {
|
|
302
|
+
return this.from(this.serialize(error, isPublic));
|
|
303
|
+
}
|
|
301
304
|
static _applyAdapt(error) {
|
|
302
305
|
const plugin = this._getResolvedPlugin();
|
|
303
306
|
for (const adapt of plugin.adapt) {
|
|
@@ -537,6 +540,10 @@ class Error0 extends Error {
|
|
|
537
540
|
const ctor = this.constructor;
|
|
538
541
|
return ctor.serialize(this, isPublic);
|
|
539
542
|
}
|
|
543
|
+
round(isPublic = true) {
|
|
544
|
+
const ctor = this.constructor;
|
|
545
|
+
return ctor.round(this, isPublic);
|
|
546
|
+
}
|
|
540
547
|
}
|
|
541
548
|
// Annotate the CommonJS export names for ESM import in node:
|
|
542
549
|
0 && (module.exports = {
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -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, 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> = (options: {\n value: string | undefined\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginStack<TError extends Error0 = Error0> = { serialize: ErrorPluginStackSerialize<TError> }\nexport type ErrorPluginCauseSerialize<TError extends Error0> = (options: {\n value: unknown\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginCause<TError extends Error0 = Error0> = { serialize: ErrorPluginCauseSerialize<TError> }\nexport type ErrorPluginMessageSerialize<TError extends Error0> = (options: {\n value: string\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginMessage<TError extends Error0 = Error0> = { serialize: ErrorPluginMessageSerialize<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 message?: ErrorPluginMessage\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 message?: ErrorPluginMessage\n}\nconst RESERVED_STACK_PROP_ERROR = 'Error0: \"stack\" is a reserved prop key. Use .stack(...) plugin API instead'\nconst RESERVED_MESSAGE_PROP_ERROR = 'Error0: \"message\" is a reserved prop key. Use .message(...) 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 { __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 message: plugin?.message,\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 message(value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods> {\n return this.use('message', 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(kind: 'message', value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>\n use(\n kind: 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 let nextMessage: ErrorPluginMessage | undefined = this._plugin.message\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 (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 if (kind === 'cause') {\n nextCause = keyOrValue as ErrorPluginCause\n } else {\n nextMessage = keyOrValue as ErrorPluginMessage\n }\n return new PluginError0({\n props: nextProps,\n methods: nextMethods,\n adapt: nextAdapt,\n stack: nextStack,\n cause: nextCause,\n message: nextMessage,\n })\n }\n}\n\nexport type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {\n new (\n message: string,\n input?: ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: TPluginsMap }\n new (\n input: { message: string } & ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: 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 (kind: 'message', value: ErrorPluginMessage<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>\n }\n plugin: () => PluginError0\n} & ErrorStaticMethods<TPluginsMap>\n\nexport class Error0 extends Error {\n static readonly __pluginsMap?: EmptyPluginsMap\n 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 message: 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 if (plugin.props && 'message' in plugin.props) {\n throw new Error(RESERVED_MESSAGE_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 if (typeof plugin.message !== 'undefined') {\n resolved.message = plugin.message\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 if ('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\n if (causePlugin?.serialize && '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 message: pluginRecord._plugin.message,\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<TThis extends typeof Error0>(\n this: TThis,\n kind: 'message',\n value: ErrorPluginMessage<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use(\n this: typeof Error0,\n first: PluginError0 | 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"stack\", value) expects { serialize: function }')\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 !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"cause\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n cause: key as ErrorPluginCause,\n })\n }\n if (first === 'message') {\n if (typeof key === 'undefined') {\n throw new Error('Error0.use(\"message\", value) requires message plugin value')\n }\n if (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"message\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n message: key as ErrorPluginMessage,\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 if (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 plugin = this._getResolvedPlugin()\n const messagePlugin = plugin.message\n let serializedMessage: unknown = error0.message\n try {\n if (messagePlugin) {\n serializedMessage = messagePlugin.serialize({ value: error0.message, error: error0, isPublic })\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to serialize message', error0)\n serializedMessage = error0.message\n }\n const json: Record<string, unknown> = {\n name: error0.name,\n message: serializedMessage,\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 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 stackPlugin = plugin.stack\n try {\n let serializedStack: unknown\n if (stackPlugin) {\n serializedStack = stackPlugin.serialize({ 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 const causePlugin = plugin.cause\n if (causePlugin?.serialize) {\n try {\n const serializedCause = causePlugin.serialize({\n value: (error0 as { cause?: unknown }).cause,\n error: error0,\n isPublic,\n })\n if (serializedCause !== undefined) {\n json.cause = serializedCause\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuLA,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;AA0E7B,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,MAChC,OAAO,QAAQ;AAAA,MACf,OAAO,QAAQ;AAAA,MACf,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,KAME,KACA,OACsG;AACtG,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,EAEA,MAAM,OAA0F;AAC9F,WAAO,KAAK,IAAI,SAAS,KAAK;AAAA,EAChC;AAAA,EAEA,MAAM,OAA0F;AAC9F,WAAO,KAAK,IAAI,SAAS,KAAK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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":[]}
|
|
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> = (options: {\n value: string | undefined\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginStack<TError extends Error0 = Error0> = { serialize: ErrorPluginStackSerialize<TError> }\nexport type ErrorPluginCauseSerialize<TError extends Error0> = (options: {\n value: unknown\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginCause<TError extends Error0 = Error0> = { serialize: ErrorPluginCauseSerialize<TError> }\nexport type ErrorPluginMessageSerialize<TError extends Error0> = (options: {\n value: string\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginMessage<TError extends Error0 = Error0> = { serialize: ErrorPluginMessageSerialize<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 message?: ErrorPluginMessage\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 message?: ErrorPluginMessage\n}\nconst RESERVED_STACK_PROP_ERROR = 'Error0: \"stack\" is a reserved prop key. Use .stack(...) plugin API instead'\nconst RESERVED_MESSAGE_PROP_ERROR = 'Error0: \"message\" is a reserved prop key. Use .message(...) 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 { __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 message: plugin?.message,\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 message(value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods> {\n return this.use('message', 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(kind: 'message', value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>\n use(\n kind: 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 let nextMessage: ErrorPluginMessage | undefined = this._plugin.message\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 (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 if (kind === 'cause') {\n nextCause = keyOrValue as ErrorPluginCause\n } else {\n nextMessage = keyOrValue as ErrorPluginMessage\n }\n return new PluginError0({\n props: nextProps,\n methods: nextMethods,\n adapt: nextAdapt,\n stack: nextStack,\n cause: nextCause,\n message: nextMessage,\n })\n }\n}\n\nexport type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {\n new (\n message: string,\n input?: ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: TPluginsMap }\n new (\n input: { message: string } & ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: TPluginsMap }\n readonly __pluginsMap?: TPluginsMap\n from: (\n error: unknown,\n ) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>\n round: (\n error: unknown,\n isPublic?: boolean,\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 (kind: 'message', value: ErrorPluginMessage<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>\n }\n plugin: () => PluginError0\n} & ErrorStaticMethods<TPluginsMap>\n\nexport class Error0 extends Error {\n static readonly __pluginsMap?: EmptyPluginsMap\n 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 message: 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 if (plugin.props && 'message' in plugin.props) {\n throw new Error(RESERVED_MESSAGE_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 if (typeof plugin.message !== 'undefined') {\n resolved.message = plugin.message\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 static round(error: unknown, isPublic = false): Error0 {\n return this.from(this.serialize(error, isPublic))\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 if ('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\n if (causePlugin?.serialize && '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 message: pluginRecord._plugin.message,\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<TThis extends typeof Error0>(\n this: TThis,\n kind: 'message',\n value: ErrorPluginMessage<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use(\n this: typeof Error0,\n first: PluginError0 | 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"stack\", value) expects { serialize: function }')\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 !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"cause\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n cause: key as ErrorPluginCause,\n })\n }\n if (first === 'message') {\n if (typeof key === 'undefined') {\n throw new Error('Error0.use(\"message\", value) requires message plugin value')\n }\n if (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"message\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n message: key as ErrorPluginMessage,\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 if (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 plugin = this._getResolvedPlugin()\n const messagePlugin = plugin.message\n let serializedMessage: unknown = error0.message\n try {\n if (messagePlugin) {\n serializedMessage = messagePlugin.serialize({ value: error0.message, error: error0, isPublic })\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to serialize message', error0)\n serializedMessage = error0.message\n }\n const json: Record<string, unknown> = {\n name: error0.name,\n message: serializedMessage,\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 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 stackPlugin = plugin.stack\n try {\n let serializedStack: unknown\n if (stackPlugin) {\n serializedStack = stackPlugin.serialize({ 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 const causePlugin = plugin.cause\n if (causePlugin?.serialize) {\n try {\n const serializedCause = causePlugin.serialize({\n value: (error0 as { cause?: unknown }).cause,\n error: error0,\n isPublic,\n })\n if (serializedCause !== undefined) {\n json.cause = serializedCause\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 round<TThis extends Error0>(this: TThis, isPublic = true): TThis {\n const ctor = this.constructor as typeof Error0\n return ctor.round(this, isPublic) as TThis\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuLA,MAAM,4BAA4B;AAClC,MAAM,8B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mptyPluginsMap> = {
|
|
|
198
198
|
};
|
|
199
199
|
readonly __pluginsMap?: TPluginsMap;
|
|
200
200
|
from: (error: unknown) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>;
|
|
201
|
+
round: (error: unknown, isPublic?: boolean) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>;
|
|
201
202
|
resolve: (error: unknown) => ErrorResolvedProps<TPluginsMap>;
|
|
202
203
|
serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>;
|
|
203
204
|
own: {
|
|
@@ -248,6 +249,7 @@ declare class Error0 extends Error {
|
|
|
248
249
|
static is<T extends typeof Error0>(this: T, error: unknown): error is InstanceType<T>;
|
|
249
250
|
static isSerialized(error: unknown): error is Record<string, unknown>;
|
|
250
251
|
static from(error: unknown): Error0;
|
|
252
|
+
static round(error: unknown, isPublic?: boolean): Error0;
|
|
251
253
|
private static _applyAdapt;
|
|
252
254
|
private static _fromSerialized;
|
|
253
255
|
private static _fromNonError0;
|
|
@@ -264,6 +266,7 @@ declare class Error0 extends Error {
|
|
|
264
266
|
static plugin(): PluginError0;
|
|
265
267
|
static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
|
|
266
268
|
serialize(isPublic?: boolean): Record<string, unknown>;
|
|
269
|
+
round<TThis extends Error0>(this: TThis, isPublic?: boolean): TThis;
|
|
267
270
|
}
|
|
268
271
|
|
|
269
272
|
export { type ClassError0, Error0, type ErrorInput, type ErrorInputBase, type ErrorPlugin, type ErrorPluginAdaptFn, type ErrorPluginAdaptResult, type ErrorPluginCause, type ErrorPluginCauseSerialize, type ErrorPluginMessage, type ErrorPluginMessageSerialize, type ErrorPluginMethodFn, type ErrorPluginMethods, type ErrorPluginPropOptions, type ErrorPluginProps, type ErrorPluginStack, type ErrorPluginStackSerialize, type ErrorPluginsMap, type ErrorResolved, type IsEmptyObject, PluginError0 };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -198,6 +198,7 @@ type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {
|
|
|
198
198
|
};
|
|
199
199
|
readonly __pluginsMap?: TPluginsMap;
|
|
200
200
|
from: (error: unknown) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>;
|
|
201
|
+
round: (error: unknown, isPublic?: boolean) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>;
|
|
201
202
|
resolve: (error: unknown) => ErrorResolvedProps<TPluginsMap>;
|
|
202
203
|
serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>;
|
|
203
204
|
own: {
|
|
@@ -248,6 +249,7 @@ declare class Error0 extends Error {
|
|
|
248
249
|
static is<T extends typeof Error0>(this: T, error: unknown): error is InstanceType<T>;
|
|
249
250
|
static isSerialized(error: unknown): error is Record<string, unknown>;
|
|
250
251
|
static from(error: unknown): Error0;
|
|
252
|
+
static round(error: unknown, isPublic?: boolean): Error0;
|
|
251
253
|
private static _applyAdapt;
|
|
252
254
|
private static _fromSerialized;
|
|
253
255
|
private static _fromNonError0;
|
|
@@ -264,6 +266,7 @@ declare class Error0 extends Error {
|
|
|
264
266
|
static plugin(): PluginError0;
|
|
265
267
|
static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
|
|
266
268
|
serialize(isPublic?: boolean): Record<string, unknown>;
|
|
269
|
+
round<TThis extends Error0>(this: TThis, isPublic?: boolean): TThis;
|
|
267
270
|
}
|
|
268
271
|
|
|
269
272
|
export { type ClassError0, Error0, type ErrorInput, type ErrorInputBase, type ErrorPlugin, type ErrorPluginAdaptFn, type ErrorPluginAdaptResult, type ErrorPluginCause, type ErrorPluginCauseSerialize, type ErrorPluginMessage, type ErrorPluginMessageSerialize, type ErrorPluginMethodFn, type ErrorPluginMethods, type ErrorPluginPropOptions, type ErrorPluginProps, type ErrorPluginStack, type ErrorPluginStackSerialize, type ErrorPluginsMap, type ErrorResolved, type IsEmptyObject, PluginError0 };
|
package/dist/esm/index.js
CHANGED
|
@@ -274,6 +274,9 @@ class Error0 extends Error {
|
|
|
274
274
|
}
|
|
275
275
|
return this._fromNonError0(error);
|
|
276
276
|
}
|
|
277
|
+
static round(error, isPublic = false) {
|
|
278
|
+
return this.from(this.serialize(error, isPublic));
|
|
279
|
+
}
|
|
277
280
|
static _applyAdapt(error) {
|
|
278
281
|
const plugin = this._getResolvedPlugin();
|
|
279
282
|
for (const adapt of plugin.adapt) {
|
|
@@ -513,6 +516,10 @@ class Error0 extends Error {
|
|
|
513
516
|
const ctor = this.constructor;
|
|
514
517
|
return ctor.serialize(this, isPublic);
|
|
515
518
|
}
|
|
519
|
+
round(isPublic = true) {
|
|
520
|
+
const ctor = this.constructor;
|
|
521
|
+
return ctor.round(this, isPublic);
|
|
522
|
+
}
|
|
516
523
|
}
|
|
517
524
|
export {
|
|
518
525
|
Error0,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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, 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> = (options: {\n value: string | undefined\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginStack<TError extends Error0 = Error0> = { serialize: ErrorPluginStackSerialize<TError> }\nexport type ErrorPluginCauseSerialize<TError extends Error0> = (options: {\n value: unknown\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginCause<TError extends Error0 = Error0> = { serialize: ErrorPluginCauseSerialize<TError> }\nexport type ErrorPluginMessageSerialize<TError extends Error0> = (options: {\n value: string\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginMessage<TError extends Error0 = Error0> = { serialize: ErrorPluginMessageSerialize<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 message?: ErrorPluginMessage\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 message?: ErrorPluginMessage\n}\nconst RESERVED_STACK_PROP_ERROR = 'Error0: \"stack\" is a reserved prop key. Use .stack(...) plugin API instead'\nconst RESERVED_MESSAGE_PROP_ERROR = 'Error0: \"message\" is a reserved prop key. Use .message(...) 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 { __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 message: plugin?.message,\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 message(value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods> {\n return this.use('message', 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(kind: 'message', value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>\n use(\n kind: 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 let nextMessage: ErrorPluginMessage | undefined = this._plugin.message\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 (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 if (kind === 'cause') {\n nextCause = keyOrValue as ErrorPluginCause\n } else {\n nextMessage = keyOrValue as ErrorPluginMessage\n }\n return new PluginError0({\n props: nextProps,\n methods: nextMethods,\n adapt: nextAdapt,\n stack: nextStack,\n cause: nextCause,\n message: nextMessage,\n })\n }\n}\n\nexport type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {\n new (\n message: string,\n input?: ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: TPluginsMap }\n new (\n input: { message: string } & ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: 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 (kind: 'message', value: ErrorPluginMessage<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>\n }\n plugin: () => PluginError0\n} & ErrorStaticMethods<TPluginsMap>\n\nexport class Error0 extends Error {\n static readonly __pluginsMap?: EmptyPluginsMap\n 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 message: 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 if (plugin.props && 'message' in plugin.props) {\n throw new Error(RESERVED_MESSAGE_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 if (typeof plugin.message !== 'undefined') {\n resolved.message = plugin.message\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 if ('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\n if (causePlugin?.serialize && '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 message: pluginRecord._plugin.message,\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<TThis extends typeof Error0>(\n this: TThis,\n kind: 'message',\n value: ErrorPluginMessage<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use(\n this: typeof Error0,\n first: PluginError0 | 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"stack\", value) expects { serialize: function }')\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 !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"cause\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n cause: key as ErrorPluginCause,\n })\n }\n if (first === 'message') {\n if (typeof key === 'undefined') {\n throw new Error('Error0.use(\"message\", value) requires message plugin value')\n }\n if (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"message\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n message: key as ErrorPluginMessage,\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 if (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 plugin = this._getResolvedPlugin()\n const messagePlugin = plugin.message\n let serializedMessage: unknown = error0.message\n try {\n if (messagePlugin) {\n serializedMessage = messagePlugin.serialize({ value: error0.message, error: error0, isPublic })\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to serialize message', error0)\n serializedMessage = error0.message\n }\n const json: Record<string, unknown> = {\n name: error0.name,\n message: serializedMessage,\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 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 stackPlugin = plugin.stack\n try {\n let serializedStack: unknown\n if (stackPlugin) {\n serializedStack = stackPlugin.serialize({ 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 const causePlugin = plugin.cause\n if (causePlugin?.serialize) {\n try {\n const serializedCause = causePlugin.serialize({\n value: (error0 as { cause?: unknown }).cause,\n error: error0,\n isPublic,\n })\n if (serializedCause !== undefined) {\n json.cause = serializedCause\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":"AAuLA,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;AA0E7B,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,MAChC,OAAO,QAAQ;AAAA,MACf,OAAO,QAAQ;AAAA,MACf,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,KAME,KACA,OACsG;AACtG,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,EAEA,MAAM,OAA0F;AAC9F,WAAO,KAAK,IAAI,SAAS,KAAK;AAAA,EAChC;AAAA,EAEA,MAAM,OAA0F;AAC9F,WAAO,KAAK,IAAI,SAAS,KAAK;AAAA,EAChC;AAAA,EAEA,QAAQ,OAA4F;AAClG,WAAO,KAAK,IAAI,WAAW,KAAK;AAAA,EAClC;AAAA,EAwBA,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,YAA0C,KA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UAAI;AACF,cAAM,QAAQ,eAAe,GAAG;AAChC,cAAM,YAAY,KAAK,UAAU,EAAE,OAAO,OAAO,QAAQ,SAAS,CAAC;AACnE,YAAI,cAAc,QAAW;AAC3B,eAAK,GAAG,IAAI;AAAA,QACd;AAAA,MACF,QAAQ;AAEN,gBAAQ,MAAM,wCAAwC,GAAG,IAAI,cAAc;AAAA,MAC7E;AAAA,IACF;AACA,UAAM,cAAc,OAAO;AAC3B,QAAI;AACF,UAAI;AACJ,UAAI,aAAa;AACf,0BAAkB,YAAY,UAAU,EAAE,OAAO,OAAO,OAAO,OAAO,QAAQ,SAAS,CAAC;AAAA,MAC1F,OAAO;AACL,0BAAkB,OAAO;AAAA,MAC3B;AACA,UAAI,oBAAoB,QAAW;AACjC,aAAK,QAAQ;AAAA,MACf;AAAA,IACF,QAAQ;AAEN,cAAQ,MAAM,qCAAqC,MAAM;AAAA,IAC3D;AACA,UAAM,cAAc,OAAO;AAC3B,QAAI,aAAa,WAAW;AAC1B,UAAI;AACF,cAAM,kBAAkB,YAAY,UAAU;AAAA,UAC5C,OAAQ,OAA+B;AAAA,UACvC,OAAO;AAAA,UACP;AAAA,QACF,CAAC;AACD,YAAI,oBAAoB,QAAW;AACjC,eAAK,QAAQ;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":[]}
|
|
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> = (options: {\n value: string | undefined\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginStack<TError extends Error0 = Error0> = { serialize: ErrorPluginStackSerialize<TError> }\nexport type ErrorPluginCauseSerialize<TError extends Error0> = (options: {\n value: unknown\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginCause<TError extends Error0 = Error0> = { serialize: ErrorPluginCauseSerialize<TError> }\nexport type ErrorPluginMessageSerialize<TError extends Error0> = (options: {\n value: string\n error: TError\n isPublic: boolean\n}) => unknown\nexport type ErrorPluginMessage<TError extends Error0 = Error0> = { serialize: ErrorPluginMessageSerialize<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 message?: ErrorPluginMessage\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 message?: ErrorPluginMessage\n}\nconst RESERVED_STACK_PROP_ERROR = 'Error0: \"stack\" is a reserved prop key. Use .stack(...) plugin API instead'\nconst RESERVED_MESSAGE_PROP_ERROR = 'Error0: \"message\" is a reserved prop key. Use .message(...) 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 { __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 message: plugin?.message,\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 message(value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods> {\n return this.use('message', 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(kind: 'message', value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>\n use(\n kind: 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 let nextMessage: ErrorPluginMessage | undefined = this._plugin.message\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 (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 if (kind === 'cause') {\n nextCause = keyOrValue as ErrorPluginCause\n } else {\n nextMessage = keyOrValue as ErrorPluginMessage\n }\n return new PluginError0({\n props: nextProps,\n methods: nextMethods,\n adapt: nextAdapt,\n stack: nextStack,\n cause: nextCause,\n message: nextMessage,\n })\n }\n}\n\nexport type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {\n new (\n message: string,\n input?: ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: TPluginsMap }\n new (\n input: { message: string } & ErrorInput<TPluginsMap>,\n ): Error0 &\n ErrorResolved<TPluginsMap> &\n ErrorOwnMethods<TPluginsMap> &\n ErrorResolveMethods<TPluginsMap> & { readonly __pluginsMap?: TPluginsMap }\n readonly __pluginsMap?: TPluginsMap\n from: (\n error: unknown,\n ) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>\n round: (\n error: unknown,\n isPublic?: boolean,\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 (kind: 'message', value: ErrorPluginMessage<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>\n }\n plugin: () => PluginError0\n} & ErrorStaticMethods<TPluginsMap>\n\nexport class Error0 extends Error {\n static readonly __pluginsMap?: EmptyPluginsMap\n 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 message: 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 if (plugin.props && 'message' in plugin.props) {\n throw new Error(RESERVED_MESSAGE_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 if (typeof plugin.message !== 'undefined') {\n resolved.message = plugin.message\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 static round(error: unknown, isPublic = false): Error0 {\n return this.from(this.serialize(error, isPublic))\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 if ('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\n if (causePlugin?.serialize && '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 message: pluginRecord._plugin.message,\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<TThis extends typeof Error0>(\n this: TThis,\n kind: 'message',\n value: ErrorPluginMessage<ErrorInstanceOfMap<PluginsMapOf<TThis>>>,\n ): ClassError0<PluginsMapOf<TThis>>\n static use(\n this: typeof Error0,\n first: PluginError0 | 'prop' | 'method' | 'adapt' | 'stack' | 'cause' | 'message',\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 (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"stack\", value) expects { serialize: function }')\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 !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"cause\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n cause: key as ErrorPluginCause,\n })\n }\n if (first === 'message') {\n if (typeof key === 'undefined') {\n throw new Error('Error0.use(\"message\", value) requires message plugin value')\n }\n if (typeof key !== 'object' || key === null || typeof (key as { serialize?: unknown }).serialize !== 'function') {\n throw new Error('Error0.use(\"message\", value) expects { serialize: function }')\n }\n return this._useWithPlugin({\n message: key as ErrorPluginMessage,\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 if (key === 'message') {\n throw new Error(RESERVED_MESSAGE_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 plugin = this._getResolvedPlugin()\n const messagePlugin = plugin.message\n let serializedMessage: unknown = error0.message\n try {\n if (messagePlugin) {\n serializedMessage = messagePlugin.serialize({ value: error0.message, error: error0, isPublic })\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error('Error0: failed to serialize message', error0)\n serializedMessage = error0.message\n }\n const json: Record<string, unknown> = {\n name: error0.name,\n message: serializedMessage,\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 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 stackPlugin = plugin.stack\n try {\n let serializedStack: unknown\n if (stackPlugin) {\n serializedStack = stackPlugin.serialize({ 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 const causePlugin = plugin.cause\n if (causePlugin?.serialize) {\n try {\n const serializedCause = causePlugin.serialize({\n value: (error0 as { cause?: unknown }).cause,\n error: error0,\n isPublic,\n })\n if (serializedCause !== undefined) {\n json.cause = serializedCause\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 round<TThis extends Error0>(this: TThis, isPublic = true): TThis {\n const ctor = this.constructor as typeof Error0\n return ctor.round(this, isPublic) as TThis\n }\n}\n"],"mappings":"AAuLA,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;AA0E7B,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,MAChC,OAAO,QAAQ;AAAA,MACf,OAAO,QAAQ;AAAA,MACf,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,KAME,KACA,OACsG;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AACA,UAAI,oBAAoB,QAAW;AACjC,aAAK,QAAQ;AAAA,MACf;AAAA,IACF,QAAQ;AAEN,cAAQ,MAAM,qCAAqC,MAAM;AAAA,IAC3D;AACA,UAAM,cAAc,OAAO;AAC3B,QAAI,aAAa,WAAW;AAC1B,UAAI;AACF,cAAM,kBAAkB,YAAY,UAAU;AAAA,UAC5C,OAAQ,OAA+B;AAAA,UACvC,OAAO;AAAA,UACP;AAAA,QACF,CAAC;AACD,YAAI,oBAAoB,QAAW;AACjC,eAAK,QAAQ;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;AAAA,EAEA,MAAyC,WAAW,MAAa;AAC/D,UAAM,OAAO,KAAK;AAClB,WAAO,KAAK,MAAM,MAAM,QAAQ;AAAA,EAClC;AACF;","names":[]}
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -267,6 +267,24 @@ describe('Error0', () => {
|
|
|
267
267
|
expect(AppError.serialize(recreated, false)).toEqual(json)
|
|
268
268
|
})
|
|
269
269
|
|
|
270
|
+
it('.round() static and instance do serialize/from roundtrip', () => {
|
|
271
|
+
const AppError = Error0.use(statusPlugin).use(codePlugin)
|
|
272
|
+
const error = new AppError('test', { status: 409, code: 'NOT_FOUND' })
|
|
273
|
+
const roundedStatic = AppError.round(error, false)
|
|
274
|
+
const roundedInstance = error.round(false)
|
|
275
|
+
|
|
276
|
+
expect(roundedStatic).toBeInstanceOf(AppError)
|
|
277
|
+
expect(roundedInstance).toBeInstanceOf(AppError)
|
|
278
|
+
expect(roundedStatic.status).toBe(409)
|
|
279
|
+
expect(roundedStatic.code).toBe('NOT_FOUND')
|
|
280
|
+
expect(roundedInstance.status).toBe(409)
|
|
281
|
+
expect(roundedInstance.code).toBe('NOT_FOUND')
|
|
282
|
+
expectTypeOf(roundedStatic.status).toEqualTypeOf<number | undefined>()
|
|
283
|
+
expectTypeOf(roundedStatic.code).toEqualTypeOf<'NOT_FOUND' | 'BAD_REQUEST' | 'UNAUTHORIZED' | undefined>()
|
|
284
|
+
expectTypeOf(roundedInstance.status).toEqualTypeOf<number | undefined>()
|
|
285
|
+
expectTypeOf(roundedInstance.code).toEqualTypeOf<'NOT_FOUND' | 'BAD_REQUEST' | 'UNAUTHORIZED' | undefined>()
|
|
286
|
+
})
|
|
287
|
+
|
|
270
288
|
it('.serialize() floated props and not serialize causes', () => {
|
|
271
289
|
const AppError = Error0.use(statusPlugin).use(codePlugin)
|
|
272
290
|
const error1 = new AppError('test', { status: 409 })
|
|
@@ -277,7 +295,6 @@ describe('Error0', () => {
|
|
|
277
295
|
expect('cause' in json).toBe(false)
|
|
278
296
|
})
|
|
279
297
|
|
|
280
|
-
|
|
281
298
|
it('by default causes not serialized', () => {
|
|
282
299
|
const AppError = Error0.use(statusPlugin).use(codePlugin)
|
|
283
300
|
const error = new AppError('test', { status: 400, code: 'NOT_FOUND' })
|
|
@@ -554,7 +571,6 @@ describe('Error0', () => {
|
|
|
554
571
|
expect(error1.code).toBe(undefined)
|
|
555
572
|
})
|
|
556
573
|
|
|
557
|
-
|
|
558
574
|
it('messages can be combined on serialization', () => {
|
|
559
575
|
const AppError = Error0.use(statusPlugin)
|
|
560
576
|
.use(codePlugin)
|
|
@@ -609,7 +625,6 @@ describe('Error0', () => {
|
|
|
609
625
|
`)
|
|
610
626
|
})
|
|
611
627
|
|
|
612
|
-
|
|
613
628
|
it('Error0 assignable to LikeError0', () => {
|
|
614
629
|
type LikeError0 = {
|
|
615
630
|
from: (error: unknown) => Error
|
package/src/index.ts
CHANGED
|
@@ -404,6 +404,10 @@ export type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> =
|
|
|
404
404
|
from: (
|
|
405
405
|
error: unknown,
|
|
406
406
|
) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>
|
|
407
|
+
round: (
|
|
408
|
+
error: unknown,
|
|
409
|
+
isPublic?: boolean,
|
|
410
|
+
) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>
|
|
407
411
|
resolve: (error: unknown) => ErrorResolvedProps<TPluginsMap>
|
|
408
412
|
serialize: (error: unknown, isPublic?: boolean) => Record<string, unknown>
|
|
409
413
|
own: {
|
|
@@ -713,6 +717,10 @@ export class Error0 extends Error {
|
|
|
713
717
|
return this._fromNonError0(error)
|
|
714
718
|
}
|
|
715
719
|
|
|
720
|
+
static round(error: unknown, isPublic = false): Error0 {
|
|
721
|
+
return this.from(this.serialize(error, isPublic))
|
|
722
|
+
}
|
|
723
|
+
|
|
716
724
|
private static _applyAdapt(error: Error0): Error0 {
|
|
717
725
|
const plugin = this._getResolvedPlugin()
|
|
718
726
|
for (const adapt of plugin.adapt) {
|
|
@@ -1075,4 +1083,9 @@ export class Error0 extends Error {
|
|
|
1075
1083
|
const ctor = this.constructor as typeof Error0
|
|
1076
1084
|
return ctor.serialize(this, isPublic)
|
|
1077
1085
|
}
|
|
1086
|
+
|
|
1087
|
+
round<TThis extends Error0>(this: TThis, isPublic = true): TThis {
|
|
1088
|
+
const ctor = this.constructor as typeof Error0
|
|
1089
|
+
return ctor.round(this, isPublic) as TThis
|
|
1090
|
+
}
|
|
1078
1091
|
}
|