@devp0nt/error0 1.0.0-next.18 → 1.0.0-next.19
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.d.cts +4 -4
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +6 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +15 -4
- package/src/index.test.ts +0 -3
- package/src/index.ts +16 -10
package/dist/cjs/index.d.cts
CHANGED
|
@@ -46,7 +46,7 @@ declare class Error0 extends Error {
|
|
|
46
46
|
static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[];
|
|
47
47
|
static _getCausesPropsFromError0Props(error0Props: Error0.GeneralProps, maxLevel: number): Error0.GeneralProps[];
|
|
48
48
|
static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]> | undefined;
|
|
49
|
-
static _getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]
|
|
49
|
+
static _getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): Array<NonNullable<Error0.GeneralProps[TPropKey]>>;
|
|
50
50
|
static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType;
|
|
51
51
|
static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'];
|
|
52
52
|
static _mergeStack(prevStack: Error0.GeneralProps['stack'], nextStack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'];
|
|
@@ -302,7 +302,7 @@ declare class Error0 extends Error {
|
|
|
302
302
|
_getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[];
|
|
303
303
|
_getCausesPropsFromError0Props(error0Props: Error0.GeneralProps, maxLevel: number): Error0.GeneralProps[];
|
|
304
304
|
_getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]> | undefined;
|
|
305
|
-
_getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]
|
|
305
|
+
_getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): Array<NonNullable<Error0.GeneralProps[TPropKey]>>;
|
|
306
306
|
_getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType;
|
|
307
307
|
_removeConstructorStackPart(stack: Error0.GeneralProps["stack"]): Error0.GeneralProps["stack"];
|
|
308
308
|
_mergeStack(prevStack: Error0.GeneralProps["stack"], nextStack: Error0.GeneralProps["stack"]): Error0.GeneralProps["stack"];
|
|
@@ -385,7 +385,7 @@ declare namespace Error0 {
|
|
|
385
385
|
tag?: string;
|
|
386
386
|
code?: string;
|
|
387
387
|
httpStatus?: HttpStatusCode | HttpStatusCodeString;
|
|
388
|
-
expected?: boolean |
|
|
388
|
+
expected?: boolean | ExpectedFn;
|
|
389
389
|
clientMessage?: string;
|
|
390
390
|
cause?: Error0Cause;
|
|
391
391
|
stack?: string;
|
|
@@ -408,7 +408,7 @@ declare namespace Error0 {
|
|
|
408
408
|
axiosError?: AxiosError;
|
|
409
409
|
}
|
|
410
410
|
type HttpStatusCodeString = keyof typeof HttpStatusCode;
|
|
411
|
-
type Error0Cause =
|
|
411
|
+
type Error0Cause = unknown;
|
|
412
412
|
type ExpectedFn = (error: GeneralProps) => boolean | undefined;
|
|
413
413
|
type JSON = ReturnType<Error0['toJSON']>;
|
|
414
414
|
type Collection = Record<string, typeof Error0>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -257,7 +257,10 @@ class Error0 extends Error {
|
|
|
257
257
|
stack: "stack" in error && typeof error.stack === "string" ? error.stack : void 0,
|
|
258
258
|
tag: "tag" in error && typeof error.tag === "string" ? error.tag : defaults?.tag || void 0,
|
|
259
259
|
cause: "cause" in error ? error.cause : defaults?.cause || void 0,
|
|
260
|
-
meta: "meta" in error && typeof error.meta === "object" && error.meta !== null ? import_meta0.Meta0.getValue(error.meta) :
|
|
260
|
+
meta: "meta" in error && typeof error.meta === "object" && error.meta !== null ? import_meta0.Meta0.getValue(error.meta) : (
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
262
|
+
import_meta0.Meta0.getValue(defaults?.meta) || {}
|
|
263
|
+
),
|
|
261
264
|
httpStatus: "httpStatus" in error && typeof error.httpStatus === "number" && error.httpStatus in import_axios.HttpStatusCode ? error.httpStatus : typeof defaults?.httpStatus === "string" ? import_axios.HttpStatusCode[defaults.httpStatus] : defaults?.httpStatus,
|
|
262
265
|
zodError: "zodError" in error && error.zodError instanceof import_zod.ZodError ? error.zodError : error instanceof import_zod.ZodError ? error : defaults?.zodError,
|
|
263
266
|
axiosError: "axiosError" in error && (0, import_axios.isAxiosError)(error.axiosError) ? error.axiosError : (0, import_axios.isAxiosError)(error) ? error : defaults?.axiosError
|
|
@@ -378,13 +381,13 @@ class Error0 extends Error {
|
|
|
378
381
|
...inputOverride
|
|
379
382
|
});
|
|
380
383
|
}
|
|
381
|
-
const inputFromData = (0, import_get.default)(error, "data");
|
|
384
|
+
const inputFromData = (0, import_get.default)(error, "data", void 0);
|
|
382
385
|
if (inputFromData) {
|
|
383
386
|
if (Error0.isLikelyError0(inputFromData)) {
|
|
384
387
|
return this._toError0(inputFromData, inputOverride);
|
|
385
388
|
}
|
|
386
389
|
}
|
|
387
|
-
const inputFromDataError0 = (0, import_get.default)(error, "data.error0");
|
|
390
|
+
const inputFromDataError0 = (0, import_get.default)(error, "data.error0", void 0);
|
|
388
391
|
if (inputFromDataError0) {
|
|
389
392
|
if (Error0.isLikelyError0(inputFromDataError0)) {
|
|
390
393
|
return this._toError0(inputFromDataError0, inputOverride);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { Meta0 } from '@devp0nt/meta0'\nimport { meta0PluginTag } from '@devp0nt/meta0/plugins/meta0-plugin-tag'\nimport { type AxiosError, HttpStatusCode, isAxiosError } from 'axios'\nimport get from 'lodash/get.js'\nimport { ZodError } from 'zod'\n\n// TODO: Эррор 0 можно передать и вторым аргументом в логгер, тогда её месадж попадёт в мету, а первый месадж в сам месадж логера\n// TODO: Зод, аксиос, это всё плагины\n// TODO: В эррор0 добавить ориджинал\n// TODO: store tags as array from all causes\n// TODO: not use self stack if toError0\n// TODO: fix default message in extended error0, should be used in constuctor of Error0\n// TODO: remove defaults prop from getPropsFromUnknown\n// TODO: code has enum type, fn to check if code exists\n\nconst isFilled = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined && value !== ''\nconst toStringOrUndefined = (value: unknown): string | undefined => {\n return typeof value === 'string' ? value : undefined\n}\nconst toNumberOrUndefined = (value: unknown): number | undefined => {\n if (typeof value === 'number') {\n return value\n }\n const number = Number(value)\n if (typeof value === 'string' && !Number.isNaN(number)) {\n return number\n }\n return undefined\n}\nconst toBooleanOrUndefined = (value: unknown): boolean | undefined => {\n if (typeof value === 'boolean') {\n return value\n }\n return undefined\n}\n\nexport class Error0 extends Error {\n public readonly __I_AM_ERROR_0: true = true\n\n public readonly tag?: Error0.GeneralProps['tag']\n public readonly code?: Error0.GeneralProps['code']\n public readonly httpStatus?: Error0.GeneralProps['httpStatus']\n public readonly expected?: Error0.GeneralProps['expected']\n public readonly clientMessage?: Error0.GeneralProps['clientMessage']\n public readonly anyMessage?: Error0.GeneralProps['anyMessage']\n public override readonly cause?: Error0.GeneralProps['cause']\n public readonly meta?: Meta0.ValueTypeNullish\n public readonly zodError?: Error0.GeneralProps['zodError']\n public readonly axiosError?: Error0.GeneralProps['axiosError']\n\n static defaultMessage = 'Unknown error'\n static defaultCode?: Error0.GeneralProps['code']\n static defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n static defaultExpected?: Error0.GeneralProps['expected']\n static defaultClientMessage?: Error0.GeneralProps['clientMessage']\n static defaultMeta?: Meta0.Meta0OrValueTypeNullish\n\n public readonly propsOriginal: Error0.GeneralProps\n\n constructor(message: string)\n constructor(input: Error0.Input)\n constructor(message: string, input: Error0.Input)\n constructor(error: Error)\n constructor(error: Error, input: Error0.Input)\n constructor(value: unknown)\n constructor(value: unknown, input: Error0.Input)\n constructor(...args: unknown[]) {\n const input: Partial<Error0.Input> = {}\n if (args[0] instanceof Error) {\n input.cause = args[0]\n } else if (typeof args[0] === 'object' && args[0] !== null) {\n Object.assign(input, args[0])\n } else if (typeof args[0] === 'string') {\n input.message = args[0]\n }\n if (typeof args[1] === 'object' && args[1] !== null) {\n Object.assign(input, args[1])\n }\n const safeInput = Error0._safeParseInput(input)\n\n const message = safeInput.message || Error0.defaultMessage\n super(message)\n Object.setPrototypeOf(this, (this.constructor as typeof Error0).prototype)\n this.name = 'Error0'\n\n this.propsOriginal = (this.constructor as typeof Error0)._getSelfGeneralProps({\n error0Input: safeInput,\n message,\n stack: safeInput.stack || this.stack,\n })\n const causesProps = (this.constructor as typeof Error0)._getCausesPropsFromError0Props(\n this.propsOriginal,\n (this.constructor as typeof Error0).defaultMaxLevel,\n )\n const propsFloated = (this.constructor as typeof Error0)._getSelfPropsFloated(causesProps)\n this.tag = propsFloated.tag\n this.code = propsFloated.code\n this.httpStatus = propsFloated.httpStatus\n this.expected = propsFloated.expected\n this.clientMessage = propsFloated.clientMessage\n this.cause = propsFloated.cause\n this.stack = propsFloated.stack\n this.meta = propsFloated.meta\n this.zodError = propsFloated.zodError\n this.axiosError = propsFloated.axiosError\n }\n\n // settings\n\n static defaultMaxLevel = 10\n\n // props\n\n public static _safeParseInput(error0Input: Record<string, unknown>): Error0.Input {\n const result: Error0.Input = {}\n result.message = typeof error0Input.message === 'string' ? error0Input.message : undefined\n result.tag = typeof error0Input.tag === 'string' ? error0Input.tag : undefined\n result.code = typeof error0Input.code === 'string' ? error0Input.code : undefined\n result.httpStatus =\n typeof error0Input.httpStatus === 'number' || typeof error0Input.httpStatus === 'string'\n ? (error0Input.httpStatus as never)\n : undefined\n result.expected =\n typeof error0Input.expected === 'function' || typeof error0Input.expected === 'boolean'\n ? (error0Input.expected as never)\n : undefined\n result.clientMessage = typeof error0Input.clientMessage === 'string' ? error0Input.clientMessage : undefined\n result.cause = error0Input.cause\n result.stack = typeof error0Input.stack === 'string' ? error0Input.stack : undefined\n // result.meta0 =\n // error0Input.meta0 instanceof Meta0 ? error0Input.meta0 : undefined\n // result.meta =\n // typeof error0Input.meta === \"object\" && error0Input.meta !== null\n // ? error0Input.meta\n // : undefined\n result.meta =\n error0Input.meta instanceof Meta0\n ? error0Input.meta\n : typeof error0Input.meta === 'object' && error0Input.meta !== null\n ? (error0Input.meta as Meta0.ValueType)\n : undefined\n result.zodError = error0Input.zodError instanceof ZodError ? error0Input.zodError : undefined\n result.axiosError = isAxiosError(error0Input.axiosError) ? error0Input.axiosError : undefined\n return result\n }\n\n public static _getSelfGeneralProps({\n error0Input,\n message,\n stack,\n }: {\n error0Input: Error0.Input\n message: string\n stack: Error0.GeneralProps['stack']\n }): Error0.GeneralProps {\n // const meta = Meta0.merge(error0Input.meta0, error0Input.meta).value\n\n // const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta)\n // const defaultMetaValue =\n // this.defaultMeta && typeof this.defaultMeta === 'object' && 'getValue' in this.defaultMeta\n // ? (this.defaultMeta as any).getValue()\n // : this.defaultMeta\n\n const meta0 = Meta0.extend(this.defaultMeta, error0Input.meta)\n const meta = meta0.getValue()\n const finalTag = meta0PluginTag.public.getFullTag(meta0, error0Input.tag)\n delete meta.tagPrefix\n const clientMessage = error0Input.clientMessage || this.defaultClientMessage\n const result: Error0.GeneralProps = {\n message: error0Input.message || this.defaultMessage,\n tag: finalTag,\n code: error0Input.code || toStringOrUndefined(meta.code) || this.defaultCode,\n httpStatus:\n typeof error0Input.httpStatus === 'number'\n ? error0Input.httpStatus\n : error0Input.httpStatus &&\n typeof error0Input.httpStatus === 'string' &&\n error0Input.httpStatus in HttpStatusCode\n ? HttpStatusCode[error0Input.httpStatus]\n : toNumberOrUndefined(meta.httpStatus) || this.defaultHttpStatus,\n expected: undefined,\n clientMessage,\n anyMessage: clientMessage || message,\n cause: error0Input.cause,\n stack: undefined,\n meta,\n zodError: error0Input.zodError,\n axiosError: error0Input.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n typeof error0Input.expected === 'boolean' || typeof error0Input.expected === 'function'\n ? error0Input.expected\n : toBooleanOrUndefined(meta.expected) || this.defaultExpected,\n )\n result.stack = this._removeConstructorStackPart(stack)\n return result\n }\n\n public static _getSelfPropsFloated(causesProps: Error0.GeneralProps[]): Error0.GeneralProps {\n const cause = this._getClosestPropValue(causesProps, 'cause')\n const stack = this._mergeStack(causesProps[1]?.stack, causesProps[0]?.stack)\n const closestTag = this._getClosestPropValue(causesProps, 'tag')\n const meta = this._getMergedMetaValue(causesProps)\n const tag = meta0PluginTag.public.getFullTag(meta, closestTag)\n const propsFloated: Error0.GeneralProps = {\n message: this._getClosestPropValue(causesProps, 'message'),\n tag,\n code: this._getClosestPropValue(causesProps, 'code'),\n httpStatus: this._getClosestPropValue(causesProps, 'httpStatus'),\n expected: this._isExpected(causesProps),\n clientMessage: this._getClosestPropValue(causesProps, 'clientMessage'),\n cause,\n stack,\n anyMessage: causesProps[0].anyMessage,\n meta,\n zodError: this._getClosestPropValue(causesProps, 'zodError'),\n axiosError: this._getClosestPropValue(causesProps, 'axiosError'),\n }\n return propsFloated\n }\n\n // sepcial\n\n public static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0.GeneralProps> {\n return {\n message: `Zod Validation Error: ${zodError.message}`,\n }\n }\n\n public static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0.GeneralProps> {\n return {\n message: 'Axios Error',\n meta: {\n axiosData: (() => {\n try {\n return JSON.stringify(axiosError.response?.data)\n } catch {\n return undefined\n }\n })(),\n axiosStatus: axiosError.response?.status,\n },\n }\n }\n\n public static _assignError0Props(\n error0Props: Error0.GeneralProps,\n extraError0Props: Partial<Error0.GeneralProps>,\n ): void {\n const metaValue = Meta0.mergeValues(error0Props.meta, extraError0Props.meta)\n Object.assign(error0Props, extraError0Props, { meta: metaValue })\n }\n\n // expected\n\n public static _normalizeSelfExpected(\n error0Props: Error0.GeneralProps,\n expectedProvided: Error0.Input['expected'],\n ): boolean | undefined {\n if (typeof expectedProvided === 'function') {\n return expectedProvided(error0Props)\n }\n return expectedProvided\n }\n\n public static _isExpected(causesProps: Error0.GeneralProps[]): boolean {\n let hasExpectedTrue = false\n for (const causeProps of causesProps) {\n if (causeProps.expected === false) {\n return false\n }\n if (causeProps.expected === true) {\n hasExpectedTrue = true\n }\n }\n return hasExpectedTrue\n }\n\n // getters\n\n public static _getPropsFromUnknown(error: unknown, defaults?: Error0.Input): Error0.GeneralProps {\n if (typeof error !== 'object' || error === null) {\n return {\n message: undefined,\n tag: undefined,\n code: undefined,\n httpStatus: undefined,\n expected: undefined,\n clientMessage: undefined,\n anyMessage: this.defaultMessage,\n cause: undefined,\n stack: undefined,\n zodError: undefined,\n axiosError: undefined,\n meta: {},\n }\n }\n const message = 'message' in error && typeof error.message === 'string' ? error.message : undefined\n const clientMessage =\n 'clientMessage' in error && typeof error.clientMessage === 'string'\n ? error.clientMessage\n : defaults?.clientMessage || undefined\n const result: Error0.GeneralProps = {\n message,\n code: 'code' in error && typeof error.code === 'string' ? error.code : defaults?.code || undefined,\n clientMessage,\n anyMessage: clientMessage || message || this.defaultMessage,\n expected: undefined,\n stack: 'stack' in error && typeof error.stack === 'string' ? error.stack : undefined,\n tag: 'tag' in error && typeof error.tag === 'string' ? error.tag : defaults?.tag || undefined,\n cause: 'cause' in error ? error.cause : defaults?.cause || undefined,\n meta:\n 'meta' in error && typeof error.meta === 'object' && error.meta !== null\n ? Meta0.getValue(error.meta as Meta0.ValueType)\n : Meta0.getValue(defaults?.meta) || {},\n httpStatus:\n 'httpStatus' in error && typeof error.httpStatus === 'number' && error.httpStatus in HttpStatusCode\n ? error.httpStatus\n : typeof defaults?.httpStatus === 'string'\n ? HttpStatusCode[defaults.httpStatus]\n : defaults?.httpStatus,\n zodError:\n 'zodError' in error && error.zodError instanceof ZodError\n ? error.zodError\n : error instanceof ZodError\n ? error\n : defaults?.zodError,\n axiosError:\n 'axiosError' in error && isAxiosError(error.axiosError)\n ? error.axiosError\n : isAxiosError(error)\n ? error\n : defaults?.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n 'expected' in error && (typeof error.expected === 'boolean' || typeof error.expected === 'function')\n ? (error.expected as Error0.ExpectedFn)\n : defaults?.expected || undefined,\n )\n if (result.zodError) {\n this._assignError0Props(result, this._getExtraError0PropsByZodError(result.zodError))\n }\n if (result.axiosError) {\n this._assignError0Props(result, this._getExtraError0PropsByAxiosError(result.axiosError))\n }\n return result\n }\n\n public static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[] {\n if (!error) {\n return []\n }\n const causeProps = this._getPropsFromUnknown(error)\n const causesProps: Error0.GeneralProps[] = [causeProps]\n if (!causeProps.cause) {\n return causesProps\n }\n if (maxLevel > 0) {\n causesProps.push(...this._getCausesPropsFromUnknown(this._getPropsFromUnknown(causeProps.cause), maxLevel - 1))\n }\n return causesProps\n }\n\n public static _getCausesPropsFromError0Props(\n error0Props: Error0.GeneralProps,\n maxLevel: number,\n ): Error0.GeneralProps[] {\n return [error0Props, ...this._getCausesPropsFromUnknown(error0Props.cause, maxLevel - 1)]\n }\n\n public static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0.GeneralProps[TPropKey]> | undefined {\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n return propValue as NonNullable<Error0.GeneralProps[TPropKey]>\n }\n }\n return undefined\n }\n\n // private static getClosestByGetter<TResult>(\n // causesProps: Error0.GeneralProps[],\n // getter: (props: Error0.GeneralProps) => TResult,\n // ): NonNullable<TResult> | undefined {\n // for (const causeProps of causesProps) {\n // const result = getter(causeProps)\n // if (isFilled(result)) {\n // return result\n // }\n // }\n // return undefined\n // }\n\n public static _getFilledPropValues<TPropKey extends keyof Error0.Input>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0.GeneralProps[TPropKey]>[] {\n const values: NonNullable<Error0.GeneralProps[TPropKey]>[] = []\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n values.push(propValue as NonNullable<Error0.GeneralProps[TPropKey]>)\n }\n }\n return values\n }\n\n public static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType {\n const metas = this._getFilledPropValues(causesProps, 'meta')\n if (metas.length === 0) {\n return {}\n } else if (metas.length === 1) {\n return metas[0]\n } else {\n return Meta0.mergeValues(metas[0], ...metas.slice(1))\n }\n }\n\n // stack\n\n public static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'] {\n if (!stack) {\n return stack\n }\n let lines = stack.split('\\n')\n const removeAllLinesContains = (search: string) => {\n lines = lines.filter((line) => !line.includes(search))\n }\n removeAllLinesContains('at new Error0')\n removeAllLinesContains('at _toError0')\n removeAllLinesContains('at Error0.from')\n removeAllLinesContains('at Error0._toError0')\n return lines.join('\\n')\n }\n\n public static _mergeStack(\n prevStack: Error0.GeneralProps['stack'],\n nextStack: Error0.GeneralProps['stack'],\n ): Error0.GeneralProps['stack'] {\n return [nextStack, prevStack].filter(Boolean).join('\\n\\n') || undefined\n }\n\n // transformations\n\n static isError0(error: unknown): error is Error0 {\n return error instanceof Error0\n }\n\n static isLikelyError0(error: unknown): error is Error0 {\n if (error instanceof Error0) {\n return true\n }\n\n if (typeof error === 'object' && error !== null) {\n if ('__I_AM_ERROR_0' in error && error.__I_AM_ERROR_0 === true) {\n return true\n }\n }\n\n return false\n }\n\n public static _toError0(error: unknown, inputOverride: Error0.Input = {}): Error0 {\n if (error instanceof Error0) {\n return error\n }\n\n if (typeof error === 'string') {\n return new Error0(error, inputOverride)\n }\n\n if (typeof error !== 'object' || error === null) {\n return new Error0({\n message: this.defaultMessage,\n ...inputOverride,\n })\n }\n\n const inputFromData = get(error, 'data')\n if (inputFromData) {\n if (Error0.isLikelyError0(inputFromData)) {\n return this._toError0(inputFromData, inputOverride)\n }\n }\n\n const inputFromDataError0 = get(error, 'data.error0')\n if (inputFromDataError0) {\n if (Error0.isLikelyError0(inputFromDataError0)) {\n return this._toError0(inputFromDataError0, inputOverride)\n }\n }\n\n return new Error0(this._getPropsFromUnknown(error, inputOverride))\n }\n\n static from(error: unknown, inputOverride?: Error0.Input): Error0 {\n return this._toError0(error, inputOverride)\n }\n\n static extend(props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n }) {\n const parent = this\n return class Error0 extends parent {\n static override defaultMessage = props.defaultMessage ?? parent.defaultMessage\n static override defaultCode = props.defaultCode ?? parent.defaultCode\n static override defaultHttpStatus = props.defaultHttpStatus ?? parent.defaultHttpStatus\n static override defaultExpected = props.defaultExpected ?? parent.defaultExpected\n static override defaultClientMessage = props.defaultClientMessage ?? parent.defaultClientMessage\n static override defaultMeta = Meta0.extend(parent.defaultMeta, props.defaultMeta)\n }\n }\n\n static extendCollection<T extends Record<string, typeof Error0>>(\n classes: T,\n props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n },\n ): T {\n return Object.fromEntries(Object.entries(classes).map(([name, Class]) => [name, Class.extend(props)])) as T\n }\n\n toJSON() {\n return {\n message: this.message,\n tag: this.tag,\n code: this.code,\n httpStatus: this.httpStatus,\n expected: this.expected,\n clientMessage: this.clientMessage,\n anyMessage: this.anyMessage,\n cause: this.cause,\n meta: Meta0.getValue(this.meta),\n stack: this.stack,\n __I_AM_ERROR_0: this.__I_AM_ERROR_0,\n }\n }\n static toJSON(error: unknown, inputOverride?: Error0.Input) {\n const error0 = this.from(error, inputOverride)\n return error0.toJSON()\n }\n\n toResponse(data?: Record<string, unknown>) {\n return Response.json(\n {\n ...this.toJSON(),\n ...data,\n },\n {\n status: this.httpStatus,\n statusText: this.message,\n },\n )\n }\n}\n\nexport namespace Error0 {\n export interface Input {\n message?: string\n tag?: string\n code?: string\n httpStatus?: HttpStatusCode | HttpStatusCodeString\n expected?: boolean | Error0.ExpectedFn\n clientMessage?: string\n cause?: Error0Cause\n stack?: string\n meta?: Meta0.Meta0OrValueTypeNullish\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export interface GeneralProps {\n message: Input['message']\n tag: Input['tag']\n code: Input['code']\n httpStatus: number | undefined\n expected: boolean | undefined\n clientMessage: Input['clientMessage']\n anyMessage: string | undefined\n cause: Input['cause']\n stack: Error['stack']\n meta: Meta0.ValueType\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export type HttpStatusCodeString = keyof typeof HttpStatusCode\n export type Error0Cause = Error | Error0 | unknown\n export type ExpectedFn = (error: GeneralProps) => boolean | undefined\n export type JSON = ReturnType<Error0['toJSON']>\n export type Collection = Record<string, typeof Error0>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,8BAA+B;AAC/B,mBAA8D;AAC9D,iBAAgB;AA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}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { Meta0 } from '@devp0nt/meta0'\nimport { meta0PluginTag } from '@devp0nt/meta0/plugins/meta0-plugin-tag'\nimport { type AxiosError, HttpStatusCode, isAxiosError } from 'axios'\nimport get from 'lodash/get.js'\nimport { ZodError } from 'zod'\n\n// TODO: Эррор 0 можно передать и вторым аргументом в логгер, тогда её месадж попадёт в мету, а первый месадж в сам месадж логера\n// TODO: Зод, аксиос, это всё плагины\n// TODO: В эррор0 добавить ориджинал\n// TODO: store tags as array from all causes\n// TODO: not use self stack if toError0\n// TODO: fix default message in extended error0, should be used in constuctor of Error0\n// TODO: remove defaults prop from getPropsFromUnknown\n// TODO: code has enum type, fn to check if code exists\n\nconst isFilled = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined && value !== ''\nconst toStringOrUndefined = (value: unknown): string | undefined => {\n return typeof value === 'string' ? value : undefined\n}\nconst toNumberOrUndefined = (value: unknown): number | undefined => {\n if (typeof value === 'number') {\n return value\n }\n const number = Number(value)\n if (typeof value === 'string' && !Number.isNaN(number)) {\n return number\n }\n return undefined\n}\nconst toBooleanOrUndefined = (value: unknown): boolean | undefined => {\n if (typeof value === 'boolean') {\n return value\n }\n return undefined\n}\n\nexport class Error0 extends Error {\n public readonly __I_AM_ERROR_0 = true as const\n\n public readonly tag?: Error0.GeneralProps['tag']\n public readonly code?: Error0.GeneralProps['code']\n public readonly httpStatus?: Error0.GeneralProps['httpStatus']\n public readonly expected?: Error0.GeneralProps['expected']\n public readonly clientMessage?: Error0.GeneralProps['clientMessage']\n public readonly anyMessage?: Error0.GeneralProps['anyMessage']\n public override readonly cause?: Error0.GeneralProps['cause']\n public readonly meta?: Meta0.ValueTypeNullish\n public readonly zodError?: Error0.GeneralProps['zodError']\n public readonly axiosError?: Error0.GeneralProps['axiosError']\n\n static defaultMessage = 'Unknown error'\n static defaultCode?: Error0.GeneralProps['code']\n static defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n static defaultExpected?: Error0.GeneralProps['expected']\n static defaultClientMessage?: Error0.GeneralProps['clientMessage']\n static defaultMeta?: Meta0.Meta0OrValueTypeNullish\n\n public readonly propsOriginal: Error0.GeneralProps\n\n constructor(message: string)\n constructor(input: Error0.Input)\n constructor(message: string, input: Error0.Input)\n constructor(error: Error)\n constructor(error: Error, input: Error0.Input)\n constructor(value: unknown)\n constructor(value: unknown, input: Error0.Input)\n constructor(...args: unknown[]) {\n const input: Partial<Error0.Input> = {}\n if (args[0] instanceof Error) {\n input.cause = args[0]\n } else if (typeof args[0] === 'object' && args[0] !== null) {\n Object.assign(input, args[0])\n } else if (typeof args[0] === 'string') {\n input.message = args[0]\n }\n if (typeof args[1] === 'object' && args[1] !== null) {\n Object.assign(input, args[1])\n }\n const safeInput = Error0._safeParseInput(input)\n\n const message = safeInput.message || Error0.defaultMessage\n super(message)\n Object.setPrototypeOf(this, (this.constructor as typeof Error0).prototype)\n this.name = 'Error0'\n\n this.propsOriginal = (this.constructor as typeof Error0)._getSelfGeneralProps({\n error0Input: safeInput,\n message,\n stack: safeInput.stack || this.stack,\n })\n const causesProps = (this.constructor as typeof Error0)._getCausesPropsFromError0Props(\n this.propsOriginal,\n (this.constructor as typeof Error0).defaultMaxLevel,\n )\n const propsFloated = (this.constructor as typeof Error0)._getSelfPropsFloated(causesProps)\n this.tag = propsFloated.tag\n this.code = propsFloated.code\n this.httpStatus = propsFloated.httpStatus\n this.expected = propsFloated.expected\n this.clientMessage = propsFloated.clientMessage\n this.cause = propsFloated.cause\n this.stack = propsFloated.stack\n this.meta = propsFloated.meta\n this.zodError = propsFloated.zodError\n this.axiosError = propsFloated.axiosError\n }\n\n // settings\n\n static defaultMaxLevel = 10\n\n // props\n\n public static _safeParseInput(error0Input: Record<string, unknown>): Error0.Input {\n const result: Error0.Input = {}\n result.message = typeof error0Input.message === 'string' ? error0Input.message : undefined\n result.tag = typeof error0Input.tag === 'string' ? error0Input.tag : undefined\n result.code = typeof error0Input.code === 'string' ? error0Input.code : undefined\n result.httpStatus =\n typeof error0Input.httpStatus === 'number' || typeof error0Input.httpStatus === 'string'\n ? (error0Input.httpStatus as never)\n : undefined\n result.expected =\n typeof error0Input.expected === 'function' || typeof error0Input.expected === 'boolean'\n ? (error0Input.expected as never)\n : undefined\n result.clientMessage = typeof error0Input.clientMessage === 'string' ? error0Input.clientMessage : undefined\n result.cause = error0Input.cause\n result.stack = typeof error0Input.stack === 'string' ? error0Input.stack : undefined\n // result.meta0 =\n // error0Input.meta0 instanceof Meta0 ? error0Input.meta0 : undefined\n // result.meta =\n // typeof error0Input.meta === \"object\" && error0Input.meta !== null\n // ? error0Input.meta\n // : undefined\n result.meta =\n error0Input.meta instanceof Meta0\n ? error0Input.meta\n : typeof error0Input.meta === 'object' && error0Input.meta !== null\n ? (error0Input.meta as Meta0.ValueType)\n : undefined\n result.zodError = error0Input.zodError instanceof ZodError ? error0Input.zodError : undefined\n result.axiosError = isAxiosError(error0Input.axiosError) ? error0Input.axiosError : undefined\n return result\n }\n\n public static _getSelfGeneralProps({\n error0Input,\n message,\n stack,\n }: {\n error0Input: Error0.Input\n message: string\n stack: Error0.GeneralProps['stack']\n }): Error0.GeneralProps {\n // const meta = Meta0.merge(error0Input.meta0, error0Input.meta).value\n\n // const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta)\n // const defaultMetaValue =\n // this.defaultMeta && typeof this.defaultMeta === 'object' && 'getValue' in this.defaultMeta\n // ? (this.defaultMeta as any).getValue()\n // : this.defaultMeta\n\n const meta0 = Meta0.extend(this.defaultMeta, error0Input.meta)\n const meta = meta0.getValue()\n const finalTag = meta0PluginTag.public.getFullTag(meta0, error0Input.tag)\n delete meta.tagPrefix\n const clientMessage = error0Input.clientMessage || this.defaultClientMessage\n const result: Error0.GeneralProps = {\n message: error0Input.message || this.defaultMessage,\n tag: finalTag,\n code: error0Input.code || toStringOrUndefined(meta.code) || this.defaultCode,\n httpStatus:\n typeof error0Input.httpStatus === 'number'\n ? error0Input.httpStatus\n : error0Input.httpStatus &&\n typeof error0Input.httpStatus === 'string' &&\n error0Input.httpStatus in HttpStatusCode\n ? HttpStatusCode[error0Input.httpStatus]\n : toNumberOrUndefined(meta.httpStatus) || this.defaultHttpStatus,\n expected: undefined,\n clientMessage,\n anyMessage: clientMessage || message,\n cause: error0Input.cause,\n stack: undefined,\n meta,\n zodError: error0Input.zodError,\n axiosError: error0Input.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n typeof error0Input.expected === 'boolean' || typeof error0Input.expected === 'function'\n ? error0Input.expected\n : toBooleanOrUndefined(meta.expected) || this.defaultExpected,\n )\n result.stack = this._removeConstructorStackPart(stack)\n return result\n }\n\n public static _getSelfPropsFloated(causesProps: Error0.GeneralProps[]): Error0.GeneralProps {\n const cause = this._getClosestPropValue(causesProps, 'cause')\n const stack = this._mergeStack(causesProps[1]?.stack, causesProps[0]?.stack)\n const closestTag = this._getClosestPropValue(causesProps, 'tag')\n const meta = this._getMergedMetaValue(causesProps)\n const tag = meta0PluginTag.public.getFullTag(meta, closestTag)\n const propsFloated: Error0.GeneralProps = {\n message: this._getClosestPropValue(causesProps, 'message'),\n tag,\n code: this._getClosestPropValue(causesProps, 'code'),\n httpStatus: this._getClosestPropValue(causesProps, 'httpStatus'),\n expected: this._isExpected(causesProps),\n clientMessage: this._getClosestPropValue(causesProps, 'clientMessage'),\n cause,\n stack,\n anyMessage: causesProps[0].anyMessage,\n meta,\n zodError: this._getClosestPropValue(causesProps, 'zodError'),\n axiosError: this._getClosestPropValue(causesProps, 'axiosError'),\n }\n return propsFloated\n }\n\n // sepcial\n\n public static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0.GeneralProps> {\n return {\n message: `Zod Validation Error: ${zodError.message}`,\n }\n }\n\n public static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0.GeneralProps> {\n return {\n message: 'Axios Error',\n meta: {\n axiosData: (() => {\n try {\n return JSON.stringify(axiosError.response?.data)\n } catch {\n return undefined\n }\n })(),\n axiosStatus: axiosError.response?.status,\n },\n }\n }\n\n public static _assignError0Props(\n error0Props: Error0.GeneralProps,\n extraError0Props: Partial<Error0.GeneralProps>,\n ): void {\n const metaValue = Meta0.mergeValues(error0Props.meta, extraError0Props.meta)\n Object.assign(error0Props, extraError0Props, { meta: metaValue })\n }\n\n // expected\n\n public static _normalizeSelfExpected(\n error0Props: Error0.GeneralProps,\n expectedProvided: Error0.Input['expected'],\n ): boolean | undefined {\n if (typeof expectedProvided === 'function') {\n return expectedProvided(error0Props)\n }\n return expectedProvided\n }\n\n public static _isExpected(causesProps: Error0.GeneralProps[]): boolean {\n let hasExpectedTrue = false\n for (const causeProps of causesProps) {\n if (causeProps.expected === false) {\n return false\n }\n if (causeProps.expected === true) {\n hasExpectedTrue = true\n }\n }\n return hasExpectedTrue\n }\n\n // getters\n\n public static _getPropsFromUnknown(error: unknown, defaults?: Error0.Input): Error0.GeneralProps {\n if (typeof error !== 'object' || error === null) {\n return {\n message: undefined,\n tag: undefined,\n code: undefined,\n httpStatus: undefined,\n expected: undefined,\n clientMessage: undefined,\n anyMessage: this.defaultMessage,\n cause: undefined,\n stack: undefined,\n zodError: undefined,\n axiosError: undefined,\n meta: {},\n }\n }\n const message = 'message' in error && typeof error.message === 'string' ? error.message : undefined\n const clientMessage =\n 'clientMessage' in error && typeof error.clientMessage === 'string'\n ? error.clientMessage\n : defaults?.clientMessage || undefined\n const result: Error0.GeneralProps = {\n message,\n code: 'code' in error && typeof error.code === 'string' ? error.code : defaults?.code || undefined,\n clientMessage,\n anyMessage: clientMessage || message || this.defaultMessage,\n expected: undefined,\n stack: 'stack' in error && typeof error.stack === 'string' ? error.stack : undefined,\n tag: 'tag' in error && typeof error.tag === 'string' ? error.tag : defaults?.tag || undefined,\n cause: 'cause' in error ? error.cause : defaults?.cause || undefined,\n meta:\n 'meta' in error && typeof error.meta === 'object' && error.meta !== null\n ? Meta0.getValue(error.meta as Meta0.ValueType)\n : // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n Meta0.getValue(defaults?.meta) || {},\n httpStatus:\n 'httpStatus' in error && typeof error.httpStatus === 'number' && error.httpStatus in HttpStatusCode\n ? error.httpStatus\n : typeof defaults?.httpStatus === 'string'\n ? HttpStatusCode[defaults.httpStatus]\n : defaults?.httpStatus,\n zodError:\n 'zodError' in error && error.zodError instanceof ZodError\n ? error.zodError\n : error instanceof ZodError\n ? error\n : defaults?.zodError,\n axiosError:\n 'axiosError' in error && isAxiosError(error.axiosError)\n ? error.axiosError\n : isAxiosError(error)\n ? error\n : defaults?.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n 'expected' in error && (typeof error.expected === 'boolean' || typeof error.expected === 'function')\n ? (error.expected as Error0.ExpectedFn)\n : defaults?.expected || undefined,\n )\n if (result.zodError) {\n this._assignError0Props(result, this._getExtraError0PropsByZodError(result.zodError))\n }\n if (result.axiosError) {\n this._assignError0Props(result, this._getExtraError0PropsByAxiosError(result.axiosError))\n }\n return result\n }\n\n public static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[] {\n if (!error) {\n return []\n }\n const causeProps = this._getPropsFromUnknown(error)\n const causesProps: Error0.GeneralProps[] = [causeProps]\n if (!causeProps.cause) {\n return causesProps\n }\n if (maxLevel > 0) {\n causesProps.push(...this._getCausesPropsFromUnknown(this._getPropsFromUnknown(causeProps.cause), maxLevel - 1))\n }\n return causesProps\n }\n\n public static _getCausesPropsFromError0Props(\n error0Props: Error0.GeneralProps,\n maxLevel: number,\n ): Error0.GeneralProps[] {\n return [error0Props, ...this._getCausesPropsFromUnknown(error0Props.cause, maxLevel - 1)]\n }\n\n public static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0.GeneralProps[TPropKey]> | undefined {\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n return propValue\n }\n }\n return undefined\n }\n\n // private static getClosestByGetter<TResult>(\n // causesProps: Error0.GeneralProps[],\n // getter: (props: Error0.GeneralProps) => TResult,\n // ): NonNullable<TResult> | undefined {\n // for (const causeProps of causesProps) {\n // const result = getter(causeProps)\n // if (isFilled(result)) {\n // return result\n // }\n // }\n // return undefined\n // }\n\n public static _getFilledPropValues<TPropKey extends keyof Error0.Input>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): Array<NonNullable<Error0.GeneralProps[TPropKey]>> {\n const values: Array<NonNullable<Error0.GeneralProps[TPropKey]>> = []\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n values.push(propValue)\n }\n }\n return values\n }\n\n public static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType {\n const metas = this._getFilledPropValues(causesProps, 'meta')\n if (metas.length === 0) {\n return {}\n } else if (metas.length === 1) {\n return metas[0]\n } else {\n return Meta0.mergeValues(metas[0], ...metas.slice(1))\n }\n }\n\n // stack\n\n public static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'] {\n if (!stack) {\n return stack\n }\n let lines = stack.split('\\n')\n const removeAllLinesContains = (search: string) => {\n lines = lines.filter((line) => !line.includes(search))\n }\n removeAllLinesContains('at new Error0')\n removeAllLinesContains('at _toError0')\n removeAllLinesContains('at Error0.from')\n removeAllLinesContains('at Error0._toError0')\n return lines.join('\\n')\n }\n\n public static _mergeStack(\n prevStack: Error0.GeneralProps['stack'],\n nextStack: Error0.GeneralProps['stack'],\n ): Error0.GeneralProps['stack'] {\n return [nextStack, prevStack].filter(Boolean).join('\\n\\n') || undefined\n }\n\n // transformations\n\n static isError0(error: unknown): error is Error0 {\n return error instanceof Error0\n }\n\n static isLikelyError0(error: unknown): error is Error0 {\n if (error instanceof Error0) {\n return true\n }\n\n if (typeof error === 'object' && error !== null) {\n if ('__I_AM_ERROR_0' in error && error.__I_AM_ERROR_0 === true) {\n return true\n }\n }\n\n return false\n }\n\n public static _toError0(error: unknown, inputOverride: Error0.Input = {}): Error0 {\n if (error instanceof Error0) {\n return error\n }\n\n if (typeof error === 'string') {\n return new Error0(error, inputOverride)\n }\n\n if (typeof error !== 'object' || error === null) {\n return new Error0({\n message: this.defaultMessage,\n ...inputOverride,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n const inputFromData = get(error, 'data', undefined)\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (inputFromData) {\n if (Error0.isLikelyError0(inputFromData)) {\n return this._toError0(inputFromData, inputOverride)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n const inputFromDataError0 = get(error, 'data.error0', undefined)\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (inputFromDataError0) {\n if (Error0.isLikelyError0(inputFromDataError0)) {\n return this._toError0(inputFromDataError0, inputOverride)\n }\n }\n\n return new Error0(this._getPropsFromUnknown(error, inputOverride))\n }\n\n static from(error: unknown, inputOverride?: Error0.Input): Error0 {\n return this._toError0(error, inputOverride)\n }\n\n static extend(props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n }) {\n // eslint-disable-next-line consistent-this, @typescript-eslint/no-this-alias\n const parent = this\n return class Error0 extends parent {\n static override defaultMessage = props.defaultMessage ?? parent.defaultMessage\n static override defaultCode = props.defaultCode ?? parent.defaultCode\n static override defaultHttpStatus = props.defaultHttpStatus ?? parent.defaultHttpStatus\n static override defaultExpected = props.defaultExpected ?? parent.defaultExpected\n static override defaultClientMessage = props.defaultClientMessage ?? parent.defaultClientMessage\n static override defaultMeta = Meta0.extend(parent.defaultMeta, props.defaultMeta)\n }\n }\n\n static extendCollection<T extends Record<string, typeof Error0>>(\n classes: T,\n props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n },\n ): T {\n return Object.fromEntries(Object.entries(classes).map(([name, Class]) => [name, Class.extend(props)])) as T\n }\n\n toJSON() {\n return {\n message: this.message,\n tag: this.tag,\n code: this.code,\n httpStatus: this.httpStatus,\n expected: this.expected,\n clientMessage: this.clientMessage,\n anyMessage: this.anyMessage,\n cause: this.cause,\n meta: Meta0.getValue(this.meta),\n stack: this.stack,\n __I_AM_ERROR_0: this.__I_AM_ERROR_0,\n }\n }\n static toJSON(error: unknown, inputOverride?: Error0.Input) {\n const error0 = this.from(error, inputOverride)\n return error0.toJSON()\n }\n\n toResponse(data?: Record<string, unknown>) {\n return Response.json(\n {\n ...this.toJSON(),\n ...data,\n },\n {\n status: this.httpStatus,\n statusText: this.message,\n },\n )\n }\n}\n\nexport namespace Error0 {\n export interface Input {\n message?: string\n tag?: string\n code?: string\n httpStatus?: HttpStatusCode | HttpStatusCodeString\n expected?: boolean | ExpectedFn\n clientMessage?: string\n cause?: Error0Cause\n stack?: string\n meta?: Meta0.Meta0OrValueTypeNullish\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export interface GeneralProps {\n message: Input['message']\n tag: Input['tag']\n code: Input['code']\n httpStatus: number | undefined\n expected: boolean | undefined\n clientMessage: Input['clientMessage']\n anyMessage: string | undefined\n cause: Input['cause']\n stack: Error['stack']\n meta: Meta0.ValueType\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export type HttpStatusCodeString = keyof typeof HttpStatusCode\n export type Error0Cause = unknown\n export type ExpectedFn = (error: GeneralProps) => boolean | undefined\n export type JSON = ReturnType<Error0['toJSON']>\n export type Collection = Record<string, typeof Error0>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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,QACf,GAAG;AAAA,MACL;AAAA,MACA;AAAA,QACE,QAAQ,KAAK;AAAA,QACb,YAAY,KAAK;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACF;","names":["get"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ declare class Error0 extends Error {
|
|
|
46
46
|
static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[];
|
|
47
47
|
static _getCausesPropsFromError0Props(error0Props: Error0.GeneralProps, maxLevel: number): Error0.GeneralProps[];
|
|
48
48
|
static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]> | undefined;
|
|
49
|
-
static _getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]
|
|
49
|
+
static _getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): Array<NonNullable<Error0.GeneralProps[TPropKey]>>;
|
|
50
50
|
static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType;
|
|
51
51
|
static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'];
|
|
52
52
|
static _mergeStack(prevStack: Error0.GeneralProps['stack'], nextStack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'];
|
|
@@ -302,7 +302,7 @@ declare class Error0 extends Error {
|
|
|
302
302
|
_getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[];
|
|
303
303
|
_getCausesPropsFromError0Props(error0Props: Error0.GeneralProps, maxLevel: number): Error0.GeneralProps[];
|
|
304
304
|
_getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]> | undefined;
|
|
305
|
-
_getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): NonNullable<Error0.GeneralProps[TPropKey]
|
|
305
|
+
_getFilledPropValues<TPropKey extends keyof Error0.Input>(causesProps: Error0.GeneralProps[], propKey: TPropKey): Array<NonNullable<Error0.GeneralProps[TPropKey]>>;
|
|
306
306
|
_getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType;
|
|
307
307
|
_removeConstructorStackPart(stack: Error0.GeneralProps["stack"]): Error0.GeneralProps["stack"];
|
|
308
308
|
_mergeStack(prevStack: Error0.GeneralProps["stack"], nextStack: Error0.GeneralProps["stack"]): Error0.GeneralProps["stack"];
|
|
@@ -385,7 +385,7 @@ declare namespace Error0 {
|
|
|
385
385
|
tag?: string;
|
|
386
386
|
code?: string;
|
|
387
387
|
httpStatus?: HttpStatusCode | HttpStatusCodeString;
|
|
388
|
-
expected?: boolean |
|
|
388
|
+
expected?: boolean | ExpectedFn;
|
|
389
389
|
clientMessage?: string;
|
|
390
390
|
cause?: Error0Cause;
|
|
391
391
|
stack?: string;
|
|
@@ -408,7 +408,7 @@ declare namespace Error0 {
|
|
|
408
408
|
axiosError?: AxiosError;
|
|
409
409
|
}
|
|
410
410
|
type HttpStatusCodeString = keyof typeof HttpStatusCode;
|
|
411
|
-
type Error0Cause =
|
|
411
|
+
type Error0Cause = unknown;
|
|
412
412
|
type ExpectedFn = (error: GeneralProps) => boolean | undefined;
|
|
413
413
|
type JSON = ReturnType<Error0['toJSON']>;
|
|
414
414
|
type Collection = Record<string, typeof Error0>;
|
package/dist/esm/index.js
CHANGED
|
@@ -224,7 +224,10 @@ class Error0 extends Error {
|
|
|
224
224
|
stack: "stack" in error && typeof error.stack === "string" ? error.stack : void 0,
|
|
225
225
|
tag: "tag" in error && typeof error.tag === "string" ? error.tag : defaults?.tag || void 0,
|
|
226
226
|
cause: "cause" in error ? error.cause : defaults?.cause || void 0,
|
|
227
|
-
meta: "meta" in error && typeof error.meta === "object" && error.meta !== null ? Meta0.getValue(error.meta) :
|
|
227
|
+
meta: "meta" in error && typeof error.meta === "object" && error.meta !== null ? Meta0.getValue(error.meta) : (
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
229
|
+
Meta0.getValue(defaults?.meta) || {}
|
|
230
|
+
),
|
|
228
231
|
httpStatus: "httpStatus" in error && typeof error.httpStatus === "number" && error.httpStatus in HttpStatusCode ? error.httpStatus : typeof defaults?.httpStatus === "string" ? HttpStatusCode[defaults.httpStatus] : defaults?.httpStatus,
|
|
229
232
|
zodError: "zodError" in error && error.zodError instanceof ZodError ? error.zodError : error instanceof ZodError ? error : defaults?.zodError,
|
|
230
233
|
axiosError: "axiosError" in error && isAxiosError(error.axiosError) ? error.axiosError : isAxiosError(error) ? error : defaults?.axiosError
|
|
@@ -345,13 +348,13 @@ class Error0 extends Error {
|
|
|
345
348
|
...inputOverride
|
|
346
349
|
});
|
|
347
350
|
}
|
|
348
|
-
const inputFromData = get(error, "data");
|
|
351
|
+
const inputFromData = get(error, "data", void 0);
|
|
349
352
|
if (inputFromData) {
|
|
350
353
|
if (Error0.isLikelyError0(inputFromData)) {
|
|
351
354
|
return this._toError0(inputFromData, inputOverride);
|
|
352
355
|
}
|
|
353
356
|
}
|
|
354
|
-
const inputFromDataError0 = get(error, "data.error0");
|
|
357
|
+
const inputFromDataError0 = get(error, "data.error0", void 0);
|
|
355
358
|
if (inputFromDataError0) {
|
|
356
359
|
if (Error0.isLikelyError0(inputFromDataError0)) {
|
|
357
360
|
return this._toError0(inputFromDataError0, inputOverride);
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { Meta0 } from '@devp0nt/meta0'\nimport { meta0PluginTag } from '@devp0nt/meta0/plugins/meta0-plugin-tag'\nimport { type AxiosError, HttpStatusCode, isAxiosError } from 'axios'\nimport get from 'lodash/get.js'\nimport { ZodError } from 'zod'\n\n// TODO: Эррор 0 можно передать и вторым аргументом в логгер, тогда её месадж попадёт в мету, а первый месадж в сам месадж логера\n// TODO: Зод, аксиос, это всё плагины\n// TODO: В эррор0 добавить ориджинал\n// TODO: store tags as array from all causes\n// TODO: not use self stack if toError0\n// TODO: fix default message in extended error0, should be used in constuctor of Error0\n// TODO: remove defaults prop from getPropsFromUnknown\n// TODO: code has enum type, fn to check if code exists\n\nconst isFilled = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined && value !== ''\nconst toStringOrUndefined = (value: unknown): string | undefined => {\n return typeof value === 'string' ? value : undefined\n}\nconst toNumberOrUndefined = (value: unknown): number | undefined => {\n if (typeof value === 'number') {\n return value\n }\n const number = Number(value)\n if (typeof value === 'string' && !Number.isNaN(number)) {\n return number\n }\n return undefined\n}\nconst toBooleanOrUndefined = (value: unknown): boolean | undefined => {\n if (typeof value === 'boolean') {\n return value\n }\n return undefined\n}\n\nexport class Error0 extends Error {\n public readonly __I_AM_ERROR_0: true = true\n\n public readonly tag?: Error0.GeneralProps['tag']\n public readonly code?: Error0.GeneralProps['code']\n public readonly httpStatus?: Error0.GeneralProps['httpStatus']\n public readonly expected?: Error0.GeneralProps['expected']\n public readonly clientMessage?: Error0.GeneralProps['clientMessage']\n public readonly anyMessage?: Error0.GeneralProps['anyMessage']\n public override readonly cause?: Error0.GeneralProps['cause']\n public readonly meta?: Meta0.ValueTypeNullish\n public readonly zodError?: Error0.GeneralProps['zodError']\n public readonly axiosError?: Error0.GeneralProps['axiosError']\n\n static defaultMessage = 'Unknown error'\n static defaultCode?: Error0.GeneralProps['code']\n static defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n static defaultExpected?: Error0.GeneralProps['expected']\n static defaultClientMessage?: Error0.GeneralProps['clientMessage']\n static defaultMeta?: Meta0.Meta0OrValueTypeNullish\n\n public readonly propsOriginal: Error0.GeneralProps\n\n constructor(message: string)\n constructor(input: Error0.Input)\n constructor(message: string, input: Error0.Input)\n constructor(error: Error)\n constructor(error: Error, input: Error0.Input)\n constructor(value: unknown)\n constructor(value: unknown, input: Error0.Input)\n constructor(...args: unknown[]) {\n const input: Partial<Error0.Input> = {}\n if (args[0] instanceof Error) {\n input.cause = args[0]\n } else if (typeof args[0] === 'object' && args[0] !== null) {\n Object.assign(input, args[0])\n } else if (typeof args[0] === 'string') {\n input.message = args[0]\n }\n if (typeof args[1] === 'object' && args[1] !== null) {\n Object.assign(input, args[1])\n }\n const safeInput = Error0._safeParseInput(input)\n\n const message = safeInput.message || Error0.defaultMessage\n super(message)\n Object.setPrototypeOf(this, (this.constructor as typeof Error0).prototype)\n this.name = 'Error0'\n\n this.propsOriginal = (this.constructor as typeof Error0)._getSelfGeneralProps({\n error0Input: safeInput,\n message,\n stack: safeInput.stack || this.stack,\n })\n const causesProps = (this.constructor as typeof Error0)._getCausesPropsFromError0Props(\n this.propsOriginal,\n (this.constructor as typeof Error0).defaultMaxLevel,\n )\n const propsFloated = (this.constructor as typeof Error0)._getSelfPropsFloated(causesProps)\n this.tag = propsFloated.tag\n this.code = propsFloated.code\n this.httpStatus = propsFloated.httpStatus\n this.expected = propsFloated.expected\n this.clientMessage = propsFloated.clientMessage\n this.cause = propsFloated.cause\n this.stack = propsFloated.stack\n this.meta = propsFloated.meta\n this.zodError = propsFloated.zodError\n this.axiosError = propsFloated.axiosError\n }\n\n // settings\n\n static defaultMaxLevel = 10\n\n // props\n\n public static _safeParseInput(error0Input: Record<string, unknown>): Error0.Input {\n const result: Error0.Input = {}\n result.message = typeof error0Input.message === 'string' ? error0Input.message : undefined\n result.tag = typeof error0Input.tag === 'string' ? error0Input.tag : undefined\n result.code = typeof error0Input.code === 'string' ? error0Input.code : undefined\n result.httpStatus =\n typeof error0Input.httpStatus === 'number' || typeof error0Input.httpStatus === 'string'\n ? (error0Input.httpStatus as never)\n : undefined\n result.expected =\n typeof error0Input.expected === 'function' || typeof error0Input.expected === 'boolean'\n ? (error0Input.expected as never)\n : undefined\n result.clientMessage = typeof error0Input.clientMessage === 'string' ? error0Input.clientMessage : undefined\n result.cause = error0Input.cause\n result.stack = typeof error0Input.stack === 'string' ? error0Input.stack : undefined\n // result.meta0 =\n // error0Input.meta0 instanceof Meta0 ? error0Input.meta0 : undefined\n // result.meta =\n // typeof error0Input.meta === \"object\" && error0Input.meta !== null\n // ? error0Input.meta\n // : undefined\n result.meta =\n error0Input.meta instanceof Meta0\n ? error0Input.meta\n : typeof error0Input.meta === 'object' && error0Input.meta !== null\n ? (error0Input.meta as Meta0.ValueType)\n : undefined\n result.zodError = error0Input.zodError instanceof ZodError ? error0Input.zodError : undefined\n result.axiosError = isAxiosError(error0Input.axiosError) ? error0Input.axiosError : undefined\n return result\n }\n\n public static _getSelfGeneralProps({\n error0Input,\n message,\n stack,\n }: {\n error0Input: Error0.Input\n message: string\n stack: Error0.GeneralProps['stack']\n }): Error0.GeneralProps {\n // const meta = Meta0.merge(error0Input.meta0, error0Input.meta).value\n\n // const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta)\n // const defaultMetaValue =\n // this.defaultMeta && typeof this.defaultMeta === 'object' && 'getValue' in this.defaultMeta\n // ? (this.defaultMeta as any).getValue()\n // : this.defaultMeta\n\n const meta0 = Meta0.extend(this.defaultMeta, error0Input.meta)\n const meta = meta0.getValue()\n const finalTag = meta0PluginTag.public.getFullTag(meta0, error0Input.tag)\n delete meta.tagPrefix\n const clientMessage = error0Input.clientMessage || this.defaultClientMessage\n const result: Error0.GeneralProps = {\n message: error0Input.message || this.defaultMessage,\n tag: finalTag,\n code: error0Input.code || toStringOrUndefined(meta.code) || this.defaultCode,\n httpStatus:\n typeof error0Input.httpStatus === 'number'\n ? error0Input.httpStatus\n : error0Input.httpStatus &&\n typeof error0Input.httpStatus === 'string' &&\n error0Input.httpStatus in HttpStatusCode\n ? HttpStatusCode[error0Input.httpStatus]\n : toNumberOrUndefined(meta.httpStatus) || this.defaultHttpStatus,\n expected: undefined,\n clientMessage,\n anyMessage: clientMessage || message,\n cause: error0Input.cause,\n stack: undefined,\n meta,\n zodError: error0Input.zodError,\n axiosError: error0Input.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n typeof error0Input.expected === 'boolean' || typeof error0Input.expected === 'function'\n ? error0Input.expected\n : toBooleanOrUndefined(meta.expected) || this.defaultExpected,\n )\n result.stack = this._removeConstructorStackPart(stack)\n return result\n }\n\n public static _getSelfPropsFloated(causesProps: Error0.GeneralProps[]): Error0.GeneralProps {\n const cause = this._getClosestPropValue(causesProps, 'cause')\n const stack = this._mergeStack(causesProps[1]?.stack, causesProps[0]?.stack)\n const closestTag = this._getClosestPropValue(causesProps, 'tag')\n const meta = this._getMergedMetaValue(causesProps)\n const tag = meta0PluginTag.public.getFullTag(meta, closestTag)\n const propsFloated: Error0.GeneralProps = {\n message: this._getClosestPropValue(causesProps, 'message'),\n tag,\n code: this._getClosestPropValue(causesProps, 'code'),\n httpStatus: this._getClosestPropValue(causesProps, 'httpStatus'),\n expected: this._isExpected(causesProps),\n clientMessage: this._getClosestPropValue(causesProps, 'clientMessage'),\n cause,\n stack,\n anyMessage: causesProps[0].anyMessage,\n meta,\n zodError: this._getClosestPropValue(causesProps, 'zodError'),\n axiosError: this._getClosestPropValue(causesProps, 'axiosError'),\n }\n return propsFloated\n }\n\n // sepcial\n\n public static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0.GeneralProps> {\n return {\n message: `Zod Validation Error: ${zodError.message}`,\n }\n }\n\n public static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0.GeneralProps> {\n return {\n message: 'Axios Error',\n meta: {\n axiosData: (() => {\n try {\n return JSON.stringify(axiosError.response?.data)\n } catch {\n return undefined\n }\n })(),\n axiosStatus: axiosError.response?.status,\n },\n }\n }\n\n public static _assignError0Props(\n error0Props: Error0.GeneralProps,\n extraError0Props: Partial<Error0.GeneralProps>,\n ): void {\n const metaValue = Meta0.mergeValues(error0Props.meta, extraError0Props.meta)\n Object.assign(error0Props, extraError0Props, { meta: metaValue })\n }\n\n // expected\n\n public static _normalizeSelfExpected(\n error0Props: Error0.GeneralProps,\n expectedProvided: Error0.Input['expected'],\n ): boolean | undefined {\n if (typeof expectedProvided === 'function') {\n return expectedProvided(error0Props)\n }\n return expectedProvided\n }\n\n public static _isExpected(causesProps: Error0.GeneralProps[]): boolean {\n let hasExpectedTrue = false\n for (const causeProps of causesProps) {\n if (causeProps.expected === false) {\n return false\n }\n if (causeProps.expected === true) {\n hasExpectedTrue = true\n }\n }\n return hasExpectedTrue\n }\n\n // getters\n\n public static _getPropsFromUnknown(error: unknown, defaults?: Error0.Input): Error0.GeneralProps {\n if (typeof error !== 'object' || error === null) {\n return {\n message: undefined,\n tag: undefined,\n code: undefined,\n httpStatus: undefined,\n expected: undefined,\n clientMessage: undefined,\n anyMessage: this.defaultMessage,\n cause: undefined,\n stack: undefined,\n zodError: undefined,\n axiosError: undefined,\n meta: {},\n }\n }\n const message = 'message' in error && typeof error.message === 'string' ? error.message : undefined\n const clientMessage =\n 'clientMessage' in error && typeof error.clientMessage === 'string'\n ? error.clientMessage\n : defaults?.clientMessage || undefined\n const result: Error0.GeneralProps = {\n message,\n code: 'code' in error && typeof error.code === 'string' ? error.code : defaults?.code || undefined,\n clientMessage,\n anyMessage: clientMessage || message || this.defaultMessage,\n expected: undefined,\n stack: 'stack' in error && typeof error.stack === 'string' ? error.stack : undefined,\n tag: 'tag' in error && typeof error.tag === 'string' ? error.tag : defaults?.tag || undefined,\n cause: 'cause' in error ? error.cause : defaults?.cause || undefined,\n meta:\n 'meta' in error && typeof error.meta === 'object' && error.meta !== null\n ? Meta0.getValue(error.meta as Meta0.ValueType)\n : Meta0.getValue(defaults?.meta) || {},\n httpStatus:\n 'httpStatus' in error && typeof error.httpStatus === 'number' && error.httpStatus in HttpStatusCode\n ? error.httpStatus\n : typeof defaults?.httpStatus === 'string'\n ? HttpStatusCode[defaults.httpStatus]\n : defaults?.httpStatus,\n zodError:\n 'zodError' in error && error.zodError instanceof ZodError\n ? error.zodError\n : error instanceof ZodError\n ? error\n : defaults?.zodError,\n axiosError:\n 'axiosError' in error && isAxiosError(error.axiosError)\n ? error.axiosError\n : isAxiosError(error)\n ? error\n : defaults?.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n 'expected' in error && (typeof error.expected === 'boolean' || typeof error.expected === 'function')\n ? (error.expected as Error0.ExpectedFn)\n : defaults?.expected || undefined,\n )\n if (result.zodError) {\n this._assignError0Props(result, this._getExtraError0PropsByZodError(result.zodError))\n }\n if (result.axiosError) {\n this._assignError0Props(result, this._getExtraError0PropsByAxiosError(result.axiosError))\n }\n return result\n }\n\n public static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[] {\n if (!error) {\n return []\n }\n const causeProps = this._getPropsFromUnknown(error)\n const causesProps: Error0.GeneralProps[] = [causeProps]\n if (!causeProps.cause) {\n return causesProps\n }\n if (maxLevel > 0) {\n causesProps.push(...this._getCausesPropsFromUnknown(this._getPropsFromUnknown(causeProps.cause), maxLevel - 1))\n }\n return causesProps\n }\n\n public static _getCausesPropsFromError0Props(\n error0Props: Error0.GeneralProps,\n maxLevel: number,\n ): Error0.GeneralProps[] {\n return [error0Props, ...this._getCausesPropsFromUnknown(error0Props.cause, maxLevel - 1)]\n }\n\n public static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0.GeneralProps[TPropKey]> | undefined {\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n return propValue as NonNullable<Error0.GeneralProps[TPropKey]>\n }\n }\n return undefined\n }\n\n // private static getClosestByGetter<TResult>(\n // causesProps: Error0.GeneralProps[],\n // getter: (props: Error0.GeneralProps) => TResult,\n // ): NonNullable<TResult> | undefined {\n // for (const causeProps of causesProps) {\n // const result = getter(causeProps)\n // if (isFilled(result)) {\n // return result\n // }\n // }\n // return undefined\n // }\n\n public static _getFilledPropValues<TPropKey extends keyof Error0.Input>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0.GeneralProps[TPropKey]>[] {\n const values: NonNullable<Error0.GeneralProps[TPropKey]>[] = []\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n values.push(propValue as NonNullable<Error0.GeneralProps[TPropKey]>)\n }\n }\n return values\n }\n\n public static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType {\n const metas = this._getFilledPropValues(causesProps, 'meta')\n if (metas.length === 0) {\n return {}\n } else if (metas.length === 1) {\n return metas[0]\n } else {\n return Meta0.mergeValues(metas[0], ...metas.slice(1))\n }\n }\n\n // stack\n\n public static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'] {\n if (!stack) {\n return stack\n }\n let lines = stack.split('\\n')\n const removeAllLinesContains = (search: string) => {\n lines = lines.filter((line) => !line.includes(search))\n }\n removeAllLinesContains('at new Error0')\n removeAllLinesContains('at _toError0')\n removeAllLinesContains('at Error0.from')\n removeAllLinesContains('at Error0._toError0')\n return lines.join('\\n')\n }\n\n public static _mergeStack(\n prevStack: Error0.GeneralProps['stack'],\n nextStack: Error0.GeneralProps['stack'],\n ): Error0.GeneralProps['stack'] {\n return [nextStack, prevStack].filter(Boolean).join('\\n\\n') || undefined\n }\n\n // transformations\n\n static isError0(error: unknown): error is Error0 {\n return error instanceof Error0\n }\n\n static isLikelyError0(error: unknown): error is Error0 {\n if (error instanceof Error0) {\n return true\n }\n\n if (typeof error === 'object' && error !== null) {\n if ('__I_AM_ERROR_0' in error && error.__I_AM_ERROR_0 === true) {\n return true\n }\n }\n\n return false\n }\n\n public static _toError0(error: unknown, inputOverride: Error0.Input = {}): Error0 {\n if (error instanceof Error0) {\n return error\n }\n\n if (typeof error === 'string') {\n return new Error0(error, inputOverride)\n }\n\n if (typeof error !== 'object' || error === null) {\n return new Error0({\n message: this.defaultMessage,\n ...inputOverride,\n })\n }\n\n const inputFromData = get(error, 'data')\n if (inputFromData) {\n if (Error0.isLikelyError0(inputFromData)) {\n return this._toError0(inputFromData, inputOverride)\n }\n }\n\n const inputFromDataError0 = get(error, 'data.error0')\n if (inputFromDataError0) {\n if (Error0.isLikelyError0(inputFromDataError0)) {\n return this._toError0(inputFromDataError0, inputOverride)\n }\n }\n\n return new Error0(this._getPropsFromUnknown(error, inputOverride))\n }\n\n static from(error: unknown, inputOverride?: Error0.Input): Error0 {\n return this._toError0(error, inputOverride)\n }\n\n static extend(props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n }) {\n const parent = this\n return class Error0 extends parent {\n static override defaultMessage = props.defaultMessage ?? parent.defaultMessage\n static override defaultCode = props.defaultCode ?? parent.defaultCode\n static override defaultHttpStatus = props.defaultHttpStatus ?? parent.defaultHttpStatus\n static override defaultExpected = props.defaultExpected ?? parent.defaultExpected\n static override defaultClientMessage = props.defaultClientMessage ?? parent.defaultClientMessage\n static override defaultMeta = Meta0.extend(parent.defaultMeta, props.defaultMeta)\n }\n }\n\n static extendCollection<T extends Record<string, typeof Error0>>(\n classes: T,\n props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n },\n ): T {\n return Object.fromEntries(Object.entries(classes).map(([name, Class]) => [name, Class.extend(props)])) as T\n }\n\n toJSON() {\n return {\n message: this.message,\n tag: this.tag,\n code: this.code,\n httpStatus: this.httpStatus,\n expected: this.expected,\n clientMessage: this.clientMessage,\n anyMessage: this.anyMessage,\n cause: this.cause,\n meta: Meta0.getValue(this.meta),\n stack: this.stack,\n __I_AM_ERROR_0: this.__I_AM_ERROR_0,\n }\n }\n static toJSON(error: unknown, inputOverride?: Error0.Input) {\n const error0 = this.from(error, inputOverride)\n return error0.toJSON()\n }\n\n toResponse(data?: Record<string, unknown>) {\n return Response.json(\n {\n ...this.toJSON(),\n ...data,\n },\n {\n status: this.httpStatus,\n statusText: this.message,\n },\n )\n }\n}\n\nexport namespace Error0 {\n export interface Input {\n message?: string\n tag?: string\n code?: string\n httpStatus?: HttpStatusCode | HttpStatusCodeString\n expected?: boolean | Error0.ExpectedFn\n clientMessage?: string\n cause?: Error0Cause\n stack?: string\n meta?: Meta0.Meta0OrValueTypeNullish\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export interface GeneralProps {\n message: Input['message']\n tag: Input['tag']\n code: Input['code']\n httpStatus: number | undefined\n expected: boolean | undefined\n clientMessage: Input['clientMessage']\n anyMessage: string | undefined\n cause: Input['cause']\n stack: Error['stack']\n meta: Meta0.ValueType\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export type HttpStatusCodeString = keyof typeof HttpStatusCode\n export type Error0Cause = Error | Error0 | unknown\n export type ExpectedFn = (error: GeneralProps) => boolean | undefined\n export type JSON = ReturnType<Error0['toJSON']>\n export type Collection = Record<string, typeof Error0>\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,SAA0B,gBAAgB,oBAAoB;AAC9D,OAAO,SAAS;AAChB,SAAS,gBAAgB;AAWzB,MAAM,WAAW,CAAI,UAAsC,UAAU,QAAQ,UAAU,UAAa,UAAU;AAC9G,MAAM,sBAAsB,CAAC,UAAuC;AAClE,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AACA,MAAM,sBAAsB,CAAC,UAAuC;AAClE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,QAAM,SAAS,OAAO,KAAK;AAC3B,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,MAAM,MAAM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;AAAA,IAClF;AAAA,EACF;AAAA,EAEA,OAAO,iBACL,SACA,OAQG;AACH,WAAO,OAAO,YAAY,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,EACvG;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,MACL,SAAS,KAAK;AAAA,MACd,KAAK,KAAK;AAAA,MACV,MAAM,KAAK;AAAA,MACX,YAAY,KAAK;AAAA,MACjB,UAAU,KAAK;AAAA,MACf,eAAe,KAAK;AAAA,MACpB,YAAY,KAAK;AAAA,MACjB,OAAO,KAAK;AAAA,MACZ,MAAM,MAAM,SAAS,KAAK,IAAI;AAAA,MAC9B,OAAO,KAAK;AAAA,MACZ,gBAAgB,KAAK;AAAA,IACvB;AAAA,EACF;AAAA,EACA,OAAO,OAAO,OAAgB,eAA8B;AAC1D,UAAM,SAAS,KAAK,KAAK,OAAO,aAAa;AAC7C,WAAO,OAAO,OAAO;AAAA,EACvB;AAAA,EAEA,WAAW,MAAgC;AACzC,WAAO,SAAS;AAAA,MACd;AAAA,QACE,GAAG,KAAK,OAAO;AAAA,QACf,GAAG;AAAA,MACL;AAAA,MACA;AAAA,QACE,QAAQ,KAAK;AAAA,QACb,YAAY,KAAK;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { Meta0 } from '@devp0nt/meta0'\nimport { meta0PluginTag } from '@devp0nt/meta0/plugins/meta0-plugin-tag'\nimport { type AxiosError, HttpStatusCode, isAxiosError } from 'axios'\nimport get from 'lodash/get.js'\nimport { ZodError } from 'zod'\n\n// TODO: Эррор 0 можно передать и вторым аргументом в логгер, тогда её месадж попадёт в мету, а первый месадж в сам месадж логера\n// TODO: Зод, аксиос, это всё плагины\n// TODO: В эррор0 добавить ориджинал\n// TODO: store tags as array from all causes\n// TODO: not use self stack if toError0\n// TODO: fix default message in extended error0, should be used in constuctor of Error0\n// TODO: remove defaults prop from getPropsFromUnknown\n// TODO: code has enum type, fn to check if code exists\n\nconst isFilled = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined && value !== ''\nconst toStringOrUndefined = (value: unknown): string | undefined => {\n return typeof value === 'string' ? value : undefined\n}\nconst toNumberOrUndefined = (value: unknown): number | undefined => {\n if (typeof value === 'number') {\n return value\n }\n const number = Number(value)\n if (typeof value === 'string' && !Number.isNaN(number)) {\n return number\n }\n return undefined\n}\nconst toBooleanOrUndefined = (value: unknown): boolean | undefined => {\n if (typeof value === 'boolean') {\n return value\n }\n return undefined\n}\n\nexport class Error0 extends Error {\n public readonly __I_AM_ERROR_0 = true as const\n\n public readonly tag?: Error0.GeneralProps['tag']\n public readonly code?: Error0.GeneralProps['code']\n public readonly httpStatus?: Error0.GeneralProps['httpStatus']\n public readonly expected?: Error0.GeneralProps['expected']\n public readonly clientMessage?: Error0.GeneralProps['clientMessage']\n public readonly anyMessage?: Error0.GeneralProps['anyMessage']\n public override readonly cause?: Error0.GeneralProps['cause']\n public readonly meta?: Meta0.ValueTypeNullish\n public readonly zodError?: Error0.GeneralProps['zodError']\n public readonly axiosError?: Error0.GeneralProps['axiosError']\n\n static defaultMessage = 'Unknown error'\n static defaultCode?: Error0.GeneralProps['code']\n static defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n static defaultExpected?: Error0.GeneralProps['expected']\n static defaultClientMessage?: Error0.GeneralProps['clientMessage']\n static defaultMeta?: Meta0.Meta0OrValueTypeNullish\n\n public readonly propsOriginal: Error0.GeneralProps\n\n constructor(message: string)\n constructor(input: Error0.Input)\n constructor(message: string, input: Error0.Input)\n constructor(error: Error)\n constructor(error: Error, input: Error0.Input)\n constructor(value: unknown)\n constructor(value: unknown, input: Error0.Input)\n constructor(...args: unknown[]) {\n const input: Partial<Error0.Input> = {}\n if (args[0] instanceof Error) {\n input.cause = args[0]\n } else if (typeof args[0] === 'object' && args[0] !== null) {\n Object.assign(input, args[0])\n } else if (typeof args[0] === 'string') {\n input.message = args[0]\n }\n if (typeof args[1] === 'object' && args[1] !== null) {\n Object.assign(input, args[1])\n }\n const safeInput = Error0._safeParseInput(input)\n\n const message = safeInput.message || Error0.defaultMessage\n super(message)\n Object.setPrototypeOf(this, (this.constructor as typeof Error0).prototype)\n this.name = 'Error0'\n\n this.propsOriginal = (this.constructor as typeof Error0)._getSelfGeneralProps({\n error0Input: safeInput,\n message,\n stack: safeInput.stack || this.stack,\n })\n const causesProps = (this.constructor as typeof Error0)._getCausesPropsFromError0Props(\n this.propsOriginal,\n (this.constructor as typeof Error0).defaultMaxLevel,\n )\n const propsFloated = (this.constructor as typeof Error0)._getSelfPropsFloated(causesProps)\n this.tag = propsFloated.tag\n this.code = propsFloated.code\n this.httpStatus = propsFloated.httpStatus\n this.expected = propsFloated.expected\n this.clientMessage = propsFloated.clientMessage\n this.cause = propsFloated.cause\n this.stack = propsFloated.stack\n this.meta = propsFloated.meta\n this.zodError = propsFloated.zodError\n this.axiosError = propsFloated.axiosError\n }\n\n // settings\n\n static defaultMaxLevel = 10\n\n // props\n\n public static _safeParseInput(error0Input: Record<string, unknown>): Error0.Input {\n const result: Error0.Input = {}\n result.message = typeof error0Input.message === 'string' ? error0Input.message : undefined\n result.tag = typeof error0Input.tag === 'string' ? error0Input.tag : undefined\n result.code = typeof error0Input.code === 'string' ? error0Input.code : undefined\n result.httpStatus =\n typeof error0Input.httpStatus === 'number' || typeof error0Input.httpStatus === 'string'\n ? (error0Input.httpStatus as never)\n : undefined\n result.expected =\n typeof error0Input.expected === 'function' || typeof error0Input.expected === 'boolean'\n ? (error0Input.expected as never)\n : undefined\n result.clientMessage = typeof error0Input.clientMessage === 'string' ? error0Input.clientMessage : undefined\n result.cause = error0Input.cause\n result.stack = typeof error0Input.stack === 'string' ? error0Input.stack : undefined\n // result.meta0 =\n // error0Input.meta0 instanceof Meta0 ? error0Input.meta0 : undefined\n // result.meta =\n // typeof error0Input.meta === \"object\" && error0Input.meta !== null\n // ? error0Input.meta\n // : undefined\n result.meta =\n error0Input.meta instanceof Meta0\n ? error0Input.meta\n : typeof error0Input.meta === 'object' && error0Input.meta !== null\n ? (error0Input.meta as Meta0.ValueType)\n : undefined\n result.zodError = error0Input.zodError instanceof ZodError ? error0Input.zodError : undefined\n result.axiosError = isAxiosError(error0Input.axiosError) ? error0Input.axiosError : undefined\n return result\n }\n\n public static _getSelfGeneralProps({\n error0Input,\n message,\n stack,\n }: {\n error0Input: Error0.Input\n message: string\n stack: Error0.GeneralProps['stack']\n }): Error0.GeneralProps {\n // const meta = Meta0.merge(error0Input.meta0, error0Input.meta).value\n\n // const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta)\n // const defaultMetaValue =\n // this.defaultMeta && typeof this.defaultMeta === 'object' && 'getValue' in this.defaultMeta\n // ? (this.defaultMeta as any).getValue()\n // : this.defaultMeta\n\n const meta0 = Meta0.extend(this.defaultMeta, error0Input.meta)\n const meta = meta0.getValue()\n const finalTag = meta0PluginTag.public.getFullTag(meta0, error0Input.tag)\n delete meta.tagPrefix\n const clientMessage = error0Input.clientMessage || this.defaultClientMessage\n const result: Error0.GeneralProps = {\n message: error0Input.message || this.defaultMessage,\n tag: finalTag,\n code: error0Input.code || toStringOrUndefined(meta.code) || this.defaultCode,\n httpStatus:\n typeof error0Input.httpStatus === 'number'\n ? error0Input.httpStatus\n : error0Input.httpStatus &&\n typeof error0Input.httpStatus === 'string' &&\n error0Input.httpStatus in HttpStatusCode\n ? HttpStatusCode[error0Input.httpStatus]\n : toNumberOrUndefined(meta.httpStatus) || this.defaultHttpStatus,\n expected: undefined,\n clientMessage,\n anyMessage: clientMessage || message,\n cause: error0Input.cause,\n stack: undefined,\n meta,\n zodError: error0Input.zodError,\n axiosError: error0Input.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n typeof error0Input.expected === 'boolean' || typeof error0Input.expected === 'function'\n ? error0Input.expected\n : toBooleanOrUndefined(meta.expected) || this.defaultExpected,\n )\n result.stack = this._removeConstructorStackPart(stack)\n return result\n }\n\n public static _getSelfPropsFloated(causesProps: Error0.GeneralProps[]): Error0.GeneralProps {\n const cause = this._getClosestPropValue(causesProps, 'cause')\n const stack = this._mergeStack(causesProps[1]?.stack, causesProps[0]?.stack)\n const closestTag = this._getClosestPropValue(causesProps, 'tag')\n const meta = this._getMergedMetaValue(causesProps)\n const tag = meta0PluginTag.public.getFullTag(meta, closestTag)\n const propsFloated: Error0.GeneralProps = {\n message: this._getClosestPropValue(causesProps, 'message'),\n tag,\n code: this._getClosestPropValue(causesProps, 'code'),\n httpStatus: this._getClosestPropValue(causesProps, 'httpStatus'),\n expected: this._isExpected(causesProps),\n clientMessage: this._getClosestPropValue(causesProps, 'clientMessage'),\n cause,\n stack,\n anyMessage: causesProps[0].anyMessage,\n meta,\n zodError: this._getClosestPropValue(causesProps, 'zodError'),\n axiosError: this._getClosestPropValue(causesProps, 'axiosError'),\n }\n return propsFloated\n }\n\n // sepcial\n\n public static _getExtraError0PropsByZodError(zodError: ZodError): Partial<Error0.GeneralProps> {\n return {\n message: `Zod Validation Error: ${zodError.message}`,\n }\n }\n\n public static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0.GeneralProps> {\n return {\n message: 'Axios Error',\n meta: {\n axiosData: (() => {\n try {\n return JSON.stringify(axiosError.response?.data)\n } catch {\n return undefined\n }\n })(),\n axiosStatus: axiosError.response?.status,\n },\n }\n }\n\n public static _assignError0Props(\n error0Props: Error0.GeneralProps,\n extraError0Props: Partial<Error0.GeneralProps>,\n ): void {\n const metaValue = Meta0.mergeValues(error0Props.meta, extraError0Props.meta)\n Object.assign(error0Props, extraError0Props, { meta: metaValue })\n }\n\n // expected\n\n public static _normalizeSelfExpected(\n error0Props: Error0.GeneralProps,\n expectedProvided: Error0.Input['expected'],\n ): boolean | undefined {\n if (typeof expectedProvided === 'function') {\n return expectedProvided(error0Props)\n }\n return expectedProvided\n }\n\n public static _isExpected(causesProps: Error0.GeneralProps[]): boolean {\n let hasExpectedTrue = false\n for (const causeProps of causesProps) {\n if (causeProps.expected === false) {\n return false\n }\n if (causeProps.expected === true) {\n hasExpectedTrue = true\n }\n }\n return hasExpectedTrue\n }\n\n // getters\n\n public static _getPropsFromUnknown(error: unknown, defaults?: Error0.Input): Error0.GeneralProps {\n if (typeof error !== 'object' || error === null) {\n return {\n message: undefined,\n tag: undefined,\n code: undefined,\n httpStatus: undefined,\n expected: undefined,\n clientMessage: undefined,\n anyMessage: this.defaultMessage,\n cause: undefined,\n stack: undefined,\n zodError: undefined,\n axiosError: undefined,\n meta: {},\n }\n }\n const message = 'message' in error && typeof error.message === 'string' ? error.message : undefined\n const clientMessage =\n 'clientMessage' in error && typeof error.clientMessage === 'string'\n ? error.clientMessage\n : defaults?.clientMessage || undefined\n const result: Error0.GeneralProps = {\n message,\n code: 'code' in error && typeof error.code === 'string' ? error.code : defaults?.code || undefined,\n clientMessage,\n anyMessage: clientMessage || message || this.defaultMessage,\n expected: undefined,\n stack: 'stack' in error && typeof error.stack === 'string' ? error.stack : undefined,\n tag: 'tag' in error && typeof error.tag === 'string' ? error.tag : defaults?.tag || undefined,\n cause: 'cause' in error ? error.cause : defaults?.cause || undefined,\n meta:\n 'meta' in error && typeof error.meta === 'object' && error.meta !== null\n ? Meta0.getValue(error.meta as Meta0.ValueType)\n : // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n Meta0.getValue(defaults?.meta) || {},\n httpStatus:\n 'httpStatus' in error && typeof error.httpStatus === 'number' && error.httpStatus in HttpStatusCode\n ? error.httpStatus\n : typeof defaults?.httpStatus === 'string'\n ? HttpStatusCode[defaults.httpStatus]\n : defaults?.httpStatus,\n zodError:\n 'zodError' in error && error.zodError instanceof ZodError\n ? error.zodError\n : error instanceof ZodError\n ? error\n : defaults?.zodError,\n axiosError:\n 'axiosError' in error && isAxiosError(error.axiosError)\n ? error.axiosError\n : isAxiosError(error)\n ? error\n : defaults?.axiosError,\n }\n result.expected = this._normalizeSelfExpected(\n result,\n 'expected' in error && (typeof error.expected === 'boolean' || typeof error.expected === 'function')\n ? (error.expected as Error0.ExpectedFn)\n : defaults?.expected || undefined,\n )\n if (result.zodError) {\n this._assignError0Props(result, this._getExtraError0PropsByZodError(result.zodError))\n }\n if (result.axiosError) {\n this._assignError0Props(result, this._getExtraError0PropsByAxiosError(result.axiosError))\n }\n return result\n }\n\n public static _getCausesPropsFromUnknown(error: unknown, maxLevel: number): Error0.GeneralProps[] {\n if (!error) {\n return []\n }\n const causeProps = this._getPropsFromUnknown(error)\n const causesProps: Error0.GeneralProps[] = [causeProps]\n if (!causeProps.cause) {\n return causesProps\n }\n if (maxLevel > 0) {\n causesProps.push(...this._getCausesPropsFromUnknown(this._getPropsFromUnknown(causeProps.cause), maxLevel - 1))\n }\n return causesProps\n }\n\n public static _getCausesPropsFromError0Props(\n error0Props: Error0.GeneralProps,\n maxLevel: number,\n ): Error0.GeneralProps[] {\n return [error0Props, ...this._getCausesPropsFromUnknown(error0Props.cause, maxLevel - 1)]\n }\n\n public static _getClosestPropValue<TPropKey extends keyof Error0.GeneralProps>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0.GeneralProps[TPropKey]> | undefined {\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n return propValue\n }\n }\n return undefined\n }\n\n // private static getClosestByGetter<TResult>(\n // causesProps: Error0.GeneralProps[],\n // getter: (props: Error0.GeneralProps) => TResult,\n // ): NonNullable<TResult> | undefined {\n // for (const causeProps of causesProps) {\n // const result = getter(causeProps)\n // if (isFilled(result)) {\n // return result\n // }\n // }\n // return undefined\n // }\n\n public static _getFilledPropValues<TPropKey extends keyof Error0.Input>(\n causesProps: Error0.GeneralProps[],\n propKey: TPropKey,\n ): Array<NonNullable<Error0.GeneralProps[TPropKey]>> {\n const values: Array<NonNullable<Error0.GeneralProps[TPropKey]>> = []\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n values.push(propValue)\n }\n }\n return values\n }\n\n public static _getMergedMetaValue(causesProps: Error0.GeneralProps[]): Meta0.ValueType {\n const metas = this._getFilledPropValues(causesProps, 'meta')\n if (metas.length === 0) {\n return {}\n } else if (metas.length === 1) {\n return metas[0]\n } else {\n return Meta0.mergeValues(metas[0], ...metas.slice(1))\n }\n }\n\n // stack\n\n public static _removeConstructorStackPart(stack: Error0.GeneralProps['stack']): Error0.GeneralProps['stack'] {\n if (!stack) {\n return stack\n }\n let lines = stack.split('\\n')\n const removeAllLinesContains = (search: string) => {\n lines = lines.filter((line) => !line.includes(search))\n }\n removeAllLinesContains('at new Error0')\n removeAllLinesContains('at _toError0')\n removeAllLinesContains('at Error0.from')\n removeAllLinesContains('at Error0._toError0')\n return lines.join('\\n')\n }\n\n public static _mergeStack(\n prevStack: Error0.GeneralProps['stack'],\n nextStack: Error0.GeneralProps['stack'],\n ): Error0.GeneralProps['stack'] {\n return [nextStack, prevStack].filter(Boolean).join('\\n\\n') || undefined\n }\n\n // transformations\n\n static isError0(error: unknown): error is Error0 {\n return error instanceof Error0\n }\n\n static isLikelyError0(error: unknown): error is Error0 {\n if (error instanceof Error0) {\n return true\n }\n\n if (typeof error === 'object' && error !== null) {\n if ('__I_AM_ERROR_0' in error && error.__I_AM_ERROR_0 === true) {\n return true\n }\n }\n\n return false\n }\n\n public static _toError0(error: unknown, inputOverride: Error0.Input = {}): Error0 {\n if (error instanceof Error0) {\n return error\n }\n\n if (typeof error === 'string') {\n return new Error0(error, inputOverride)\n }\n\n if (typeof error !== 'object' || error === null) {\n return new Error0({\n message: this.defaultMessage,\n ...inputOverride,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n const inputFromData = get(error, 'data', undefined)\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (inputFromData) {\n if (Error0.isLikelyError0(inputFromData)) {\n return this._toError0(inputFromData, inputOverride)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n const inputFromDataError0 = get(error, 'data.error0', undefined)\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (inputFromDataError0) {\n if (Error0.isLikelyError0(inputFromDataError0)) {\n return this._toError0(inputFromDataError0, inputOverride)\n }\n }\n\n return new Error0(this._getPropsFromUnknown(error, inputOverride))\n }\n\n static from(error: unknown, inputOverride?: Error0.Input): Error0 {\n return this._toError0(error, inputOverride)\n }\n\n static extend(props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n }) {\n // eslint-disable-next-line consistent-this, @typescript-eslint/no-this-alias\n const parent = this\n return class Error0 extends parent {\n static override defaultMessage = props.defaultMessage ?? parent.defaultMessage\n static override defaultCode = props.defaultCode ?? parent.defaultCode\n static override defaultHttpStatus = props.defaultHttpStatus ?? parent.defaultHttpStatus\n static override defaultExpected = props.defaultExpected ?? parent.defaultExpected\n static override defaultClientMessage = props.defaultClientMessage ?? parent.defaultClientMessage\n static override defaultMeta = Meta0.extend(parent.defaultMeta, props.defaultMeta)\n }\n }\n\n static extendCollection<T extends Record<string, typeof Error0>>(\n classes: T,\n props: {\n defaultMessage?: Error0.GeneralProps['message']\n defaultCode?: Error0.GeneralProps['code']\n defaultHttpStatus?: Error0.GeneralProps['httpStatus']\n defaultExpected?: Error0.GeneralProps['expected']\n defaultClientMessage?: Error0.GeneralProps['clientMessage']\n defaultMeta?: Meta0.Meta0OrValueTypeNullish\n },\n ): T {\n return Object.fromEntries(Object.entries(classes).map(([name, Class]) => [name, Class.extend(props)])) as T\n }\n\n toJSON() {\n return {\n message: this.message,\n tag: this.tag,\n code: this.code,\n httpStatus: this.httpStatus,\n expected: this.expected,\n clientMessage: this.clientMessage,\n anyMessage: this.anyMessage,\n cause: this.cause,\n meta: Meta0.getValue(this.meta),\n stack: this.stack,\n __I_AM_ERROR_0: this.__I_AM_ERROR_0,\n }\n }\n static toJSON(error: unknown, inputOverride?: Error0.Input) {\n const error0 = this.from(error, inputOverride)\n return error0.toJSON()\n }\n\n toResponse(data?: Record<string, unknown>) {\n return Response.json(\n {\n ...this.toJSON(),\n ...data,\n },\n {\n status: this.httpStatus,\n statusText: this.message,\n },\n )\n }\n}\n\nexport namespace Error0 {\n export interface Input {\n message?: string\n tag?: string\n code?: string\n httpStatus?: HttpStatusCode | HttpStatusCodeString\n expected?: boolean | ExpectedFn\n clientMessage?: string\n cause?: Error0Cause\n stack?: string\n meta?: Meta0.Meta0OrValueTypeNullish\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export interface GeneralProps {\n message: Input['message']\n tag: Input['tag']\n code: Input['code']\n httpStatus: number | undefined\n expected: boolean | undefined\n clientMessage: Input['clientMessage']\n anyMessage: string | undefined\n cause: Input['cause']\n stack: Error['stack']\n meta: Meta0.ValueType\n zodError?: ZodError\n axiosError?: AxiosError\n }\n\n export type HttpStatusCodeString = keyof typeof HttpStatusCode\n export type Error0Cause = unknown\n export type ExpectedFn = (error: GeneralProps) => boolean | undefined\n export type JSON = ReturnType<Error0['toJSON']>\n export type Collection = Record<string, typeof Error0>\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,sBAAsB;AAC/B,SAA0B,gBAAgB,oBAAoB;AAC9D,OAAO,SAAS;AAChB,SAAS,gBAAgB;AAWzB,MAAM,WAAW,CAAI,UAAsC,UAAU,QAAQ,UAAU,UAAa,UAAU;AAC9G,MAAM,sBAAsB,CAAC,UAAuC;AAClE,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AACA,MAAM,sBAAsB,CAAC,UAAuC;AAClE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,QAAM,SAAS,OAAO,KAAK;AAC3B,MAAI,OAAO,UAA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AA,MAC5E,OAAgB,cAAc,MAAM,OAAO,OAAO,aAAa,MAAM,WAAW;AAAA,IAClF;AAAA,EACF;AAAA,EAEA,OAAO,iBACL,SACA,OAQG;AACH,WAAO,OAAO,YAAY,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,EACvG;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,MACL,SAAS,KAAK;AAAA,MACd,KAAK,KAAK;AAAA,MACV,MAAM,KAAK;AAAA,MACX,YAAY,KAAK;AAAA,MACjB,UAAU,KAAK;AAAA,MACf,eAAe,KAAK;AAAA,MACpB,YAAY,KAAK;AAAA,MACjB,OAAO,KAAK;AAAA,MACZ,MAAM,MAAM,SAAS,KAAK,IAAI;AAAA,MAC9B,OAAO,KAAK;AAAA,MACZ,gBAAgB,KAAK;AAAA,IACvB;AAAA,EACF;AAAA,EACA,OAAO,OAAO,OAAgB,eAA8B;AAC1D,UAAM,SAAS,KAAK,KAAK,OAAO,aAAa;AAC7C,WAAO,OAAO,OAAO;AAAA,EACvB;AAAA,EAEA,WAAW,MAAgC;AACzC,WAAO,SAAS;AAAA,MACd;AAAA,QACE,GAAG,KAAK,OAAO;AAAA,QACf,GAAG;AAAA,MACL;AAAA,MACA;AAAA,QACE,QAAQ,KAAK;AAAA,QACb,YAAY,KAAK;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -57,12 +57,18 @@
|
|
|
57
57
|
"test:all:watch": "bun run test:watch & bun run test:dist:watch",
|
|
58
58
|
"test:all:build": "bun run build:all && bun run test:all",
|
|
59
59
|
"test:all:build:watch": "bun run build:all:watch & bun run test:all:watch",
|
|
60
|
-
"lint": "
|
|
60
|
+
"lint": "bun run lint:base .",
|
|
61
|
+
"lint:base": "eslint --cache --cache-location node_modules/.cache/eslint/.eslintcache",
|
|
62
|
+
"lint:fix": "bun run lint --fix",
|
|
63
|
+
"format": "bun run format:base .",
|
|
64
|
+
"format:base": "prettier --cache --cache-location node_modules/.cache/prettier/.prettiercache --ignore-path .gitignore",
|
|
65
|
+
"format:fix": "bun run format:base --write",
|
|
61
66
|
"types:build": "tsc --noEmit --project tsconfig.build.json",
|
|
62
67
|
"types:dev": "tsc --noEmit",
|
|
63
68
|
"types": "bun run types:dev",
|
|
64
69
|
"pack:dry": "npm pack --dry-run",
|
|
65
|
-
"prepare": "husky"
|
|
70
|
+
"prepare": "husky",
|
|
71
|
+
"clean": "rimraf dist && rimraf dist-test && rimraf node_modules/.cache"
|
|
66
72
|
},
|
|
67
73
|
"dependencies": {},
|
|
68
74
|
"peerDependencies": {
|
|
@@ -71,7 +77,6 @@
|
|
|
71
77
|
"zod": "^4.1.9"
|
|
72
78
|
},
|
|
73
79
|
"devDependencies": {
|
|
74
|
-
"@biomejs/biome": "^2.2.4",
|
|
75
80
|
"@commitlint/cli": "^19.8.1",
|
|
76
81
|
"@commitlint/config-conventional": "^19.8.1",
|
|
77
82
|
"@semantic-release/changelog": "^6.0.3",
|
|
@@ -82,8 +87,14 @@
|
|
|
82
87
|
"@types/lodash": "^4.17.20",
|
|
83
88
|
"@types/node": "^20.0.0",
|
|
84
89
|
"cross-env": "^10.0.0",
|
|
90
|
+
"eslint": "^9.36.0",
|
|
91
|
+
"eslint-config-love": "^130.0.0",
|
|
92
|
+
"eslint-config-prettier": "^10.1.8",
|
|
85
93
|
"husky": "^9.1.7",
|
|
94
|
+
"lint-staged": "^16.2.1",
|
|
86
95
|
"lodash": "^4.17.21",
|
|
96
|
+
"prettier": "^3.6.2",
|
|
97
|
+
"rimraf": "^6.0.1",
|
|
87
98
|
"semantic-release": "^24.2.8",
|
|
88
99
|
"tsup": "^8.0.0",
|
|
89
100
|
"typescript": "^5.0.0"
|
|
@@ -95,5 +106,5 @@
|
|
|
95
106
|
"publishConfig": {
|
|
96
107
|
"access": "public"
|
|
97
108
|
},
|
|
98
|
-
"version": "1.0.0-next.
|
|
109
|
+
"version": "1.0.0-next.19"
|
|
99
110
|
}
|
package/src/index.test.ts
CHANGED
|
@@ -532,9 +532,6 @@ describe('error0', () => {
|
|
|
532
532
|
} as AxiosError
|
|
533
533
|
}
|
|
534
534
|
const axiosError = makeFakeAxiosError()
|
|
535
|
-
if (!axiosError) {
|
|
536
|
-
throw new Error('axiosError is undefined')
|
|
537
|
-
}
|
|
538
535
|
expect(isAxiosError(axiosError)).toBe(true)
|
|
539
536
|
const error0 = Error0.from(axiosError)
|
|
540
537
|
expect(error0.axiosError).toBe(axiosError)
|
package/src/index.ts
CHANGED
|
@@ -35,7 +35,7 @@ const toBooleanOrUndefined = (value: unknown): boolean | undefined => {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export class Error0 extends Error {
|
|
38
|
-
public readonly __I_AM_ERROR_0
|
|
38
|
+
public readonly __I_AM_ERROR_0 = true as const
|
|
39
39
|
|
|
40
40
|
public readonly tag?: Error0.GeneralProps['tag']
|
|
41
41
|
public readonly code?: Error0.GeneralProps['code']
|
|
@@ -313,7 +313,8 @@ export class Error0 extends Error {
|
|
|
313
313
|
meta:
|
|
314
314
|
'meta' in error && typeof error.meta === 'object' && error.meta !== null
|
|
315
315
|
? Meta0.getValue(error.meta as Meta0.ValueType)
|
|
316
|
-
:
|
|
316
|
+
: // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
317
|
+
Meta0.getValue(defaults?.meta) || {},
|
|
317
318
|
httpStatus:
|
|
318
319
|
'httpStatus' in error && typeof error.httpStatus === 'number' && error.httpStatus in HttpStatusCode
|
|
319
320
|
? error.httpStatus
|
|
@@ -377,7 +378,7 @@ export class Error0 extends Error {
|
|
|
377
378
|
for (const causeProps of causesProps) {
|
|
378
379
|
const propValue = causeProps[propKey]
|
|
379
380
|
if (isFilled(propValue)) {
|
|
380
|
-
return propValue
|
|
381
|
+
return propValue
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
return undefined
|
|
@@ -399,12 +400,12 @@ export class Error0 extends Error {
|
|
|
399
400
|
public static _getFilledPropValues<TPropKey extends keyof Error0.Input>(
|
|
400
401
|
causesProps: Error0.GeneralProps[],
|
|
401
402
|
propKey: TPropKey,
|
|
402
|
-
): NonNullable<Error0.GeneralProps[TPropKey]
|
|
403
|
-
const values: NonNullable<Error0.GeneralProps[TPropKey]
|
|
403
|
+
): Array<NonNullable<Error0.GeneralProps[TPropKey]>> {
|
|
404
|
+
const values: Array<NonNullable<Error0.GeneralProps[TPropKey]>> = []
|
|
404
405
|
for (const causeProps of causesProps) {
|
|
405
406
|
const propValue = causeProps[propKey]
|
|
406
407
|
if (isFilled(propValue)) {
|
|
407
|
-
values.push(propValue
|
|
408
|
+
values.push(propValue)
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
return values
|
|
@@ -481,14 +482,18 @@ export class Error0 extends Error {
|
|
|
481
482
|
})
|
|
482
483
|
}
|
|
483
484
|
|
|
484
|
-
|
|
485
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
486
|
+
const inputFromData = get(error, 'data', undefined)
|
|
487
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
485
488
|
if (inputFromData) {
|
|
486
489
|
if (Error0.isLikelyError0(inputFromData)) {
|
|
487
490
|
return this._toError0(inputFromData, inputOverride)
|
|
488
491
|
}
|
|
489
492
|
}
|
|
490
493
|
|
|
491
|
-
|
|
494
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
495
|
+
const inputFromDataError0 = get(error, 'data.error0', undefined)
|
|
496
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
492
497
|
if (inputFromDataError0) {
|
|
493
498
|
if (Error0.isLikelyError0(inputFromDataError0)) {
|
|
494
499
|
return this._toError0(inputFromDataError0, inputOverride)
|
|
@@ -510,6 +515,7 @@ export class Error0 extends Error {
|
|
|
510
515
|
defaultClientMessage?: Error0.GeneralProps['clientMessage']
|
|
511
516
|
defaultMeta?: Meta0.Meta0OrValueTypeNullish
|
|
512
517
|
}) {
|
|
518
|
+
// eslint-disable-next-line consistent-this, @typescript-eslint/no-this-alias
|
|
513
519
|
const parent = this
|
|
514
520
|
return class Error0 extends parent {
|
|
515
521
|
static override defaultMessage = props.defaultMessage ?? parent.defaultMessage
|
|
@@ -575,7 +581,7 @@ export namespace Error0 {
|
|
|
575
581
|
tag?: string
|
|
576
582
|
code?: string
|
|
577
583
|
httpStatus?: HttpStatusCode | HttpStatusCodeString
|
|
578
|
-
expected?: boolean |
|
|
584
|
+
expected?: boolean | ExpectedFn
|
|
579
585
|
clientMessage?: string
|
|
580
586
|
cause?: Error0Cause
|
|
581
587
|
stack?: string
|
|
@@ -600,7 +606,7 @@ export namespace Error0 {
|
|
|
600
606
|
}
|
|
601
607
|
|
|
602
608
|
export type HttpStatusCodeString = keyof typeof HttpStatusCode
|
|
603
|
-
export type Error0Cause =
|
|
609
|
+
export type Error0Cause = unknown
|
|
604
610
|
export type ExpectedFn = (error: GeneralProps) => boolean | undefined
|
|
605
611
|
export type JSON = ReturnType<Error0['toJSON']>
|
|
606
612
|
export type Collection = Record<string, typeof Error0>
|