@devp0nt/error0 1.0.0-next.1

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.
@@ -0,0 +1,400 @@
1
+ import { Meta0 } from "@devp0nt/meta0";
2
+ import { HttpStatusCode, isAxiosError } from "axios";
3
+ import get from "lodash/get.js";
4
+ import { ZodError } from "zod";
5
+ const isFilled = (value) => value !== null && value !== void 0 && value !== "";
6
+ class Error0 extends Error {
7
+ __I_AM_ERROR_0 = true;
8
+ tag;
9
+ code;
10
+ httpStatus;
11
+ expected;
12
+ clientMessage;
13
+ anyMessage;
14
+ cause;
15
+ meta;
16
+ zodError;
17
+ axiosError;
18
+ static defaultMessage = "Unknown error";
19
+ static defaultCode;
20
+ static defaultHttpStatus;
21
+ static defaultExpected;
22
+ static defaultClientMessage;
23
+ static defaultMeta;
24
+ propsOriginal;
25
+ constructor(...args) {
26
+ const input = {};
27
+ if (args[0] instanceof Error) {
28
+ input.cause = args[0];
29
+ } else if (typeof args[0] === "object" && args[0] !== null) {
30
+ Object.assign(input, args[0]);
31
+ } else if (typeof args[0] === "string") {
32
+ input.message = args[0];
33
+ }
34
+ if (typeof args[1] === "object" && args[1] !== null) {
35
+ Object.assign(input, args[1]);
36
+ }
37
+ const safeInput = Error0._safeParseInput(input);
38
+ const message = safeInput.message || Error0.defaultMessage;
39
+ super(message);
40
+ Object.setPrototypeOf(this, this.constructor.prototype);
41
+ this.name = "Error0";
42
+ this.propsOriginal = this.constructor._getSelfGeneralProps({
43
+ error0Input: safeInput,
44
+ message,
45
+ stack: safeInput.stack || this.stack
46
+ });
47
+ const causesProps = this.constructor._getCausesPropsFromError0Props(
48
+ this.propsOriginal,
49
+ this.constructor.defaultMaxLevel
50
+ );
51
+ const propsFloated = this.constructor._getSelfPropsFloated(causesProps);
52
+ this.tag = propsFloated.tag;
53
+ this.code = propsFloated.code;
54
+ this.httpStatus = propsFloated.httpStatus;
55
+ this.expected = propsFloated.expected;
56
+ this.clientMessage = propsFloated.clientMessage;
57
+ this.cause = propsFloated.cause;
58
+ this.stack = propsFloated.stack;
59
+ this.meta = propsFloated.meta;
60
+ this.zodError = propsFloated.zodError;
61
+ this.axiosError = propsFloated.axiosError;
62
+ }
63
+ // settings
64
+ static defaultMaxLevel = 10;
65
+ // props
66
+ static _safeParseInput(error0Input) {
67
+ const result = {};
68
+ result.message = typeof error0Input.message === "string" ? error0Input.message : void 0;
69
+ result.tag = typeof error0Input.tag === "string" ? error0Input.tag : void 0;
70
+ result.code = typeof error0Input.code === "string" ? error0Input.code : void 0;
71
+ result.httpStatus = typeof error0Input.httpStatus === "number" || typeof error0Input.httpStatus === "string" ? error0Input.httpStatus : void 0;
72
+ result.expected = typeof error0Input.expected === "function" || typeof error0Input.expected === "boolean" ? error0Input.expected : void 0;
73
+ result.clientMessage = typeof error0Input.clientMessage === "string" ? error0Input.clientMessage : void 0;
74
+ result.cause = error0Input.cause;
75
+ result.stack = typeof error0Input.stack === "string" ? error0Input.stack : void 0;
76
+ result.meta = error0Input.meta instanceof Meta0 ? error0Input.meta : typeof error0Input.meta === "object" && error0Input.meta !== null ? error0Input.meta : void 0;
77
+ result.zodError = error0Input.zodError instanceof ZodError ? error0Input.zodError : void 0;
78
+ result.axiosError = isAxiosError(error0Input.axiosError) ? error0Input.axiosError : void 0;
79
+ return result;
80
+ }
81
+ static _getSelfGeneralProps({
82
+ error0Input,
83
+ message,
84
+ stack
85
+ }) {
86
+ const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta);
87
+ const meta = meta0.getValue();
88
+ const finalTag = meta0.getFinalTag(error0Input.tag);
89
+ const clientMessage = error0Input.clientMessage || this.defaultClientMessage;
90
+ const result = {
91
+ message: error0Input.message || this.defaultMessage,
92
+ tag: finalTag,
93
+ code: error0Input.code || meta.code || this.defaultCode,
94
+ httpStatus: typeof error0Input.httpStatus === "number" ? error0Input.httpStatus : error0Input.httpStatus && typeof error0Input.httpStatus === "string" && error0Input.httpStatus in HttpStatusCode ? HttpStatusCode[error0Input.httpStatus] : meta.httpStatus || this.defaultHttpStatus,
95
+ expected: void 0,
96
+ clientMessage,
97
+ anyMessage: clientMessage || message,
98
+ cause: error0Input.cause,
99
+ stack: void 0,
100
+ meta,
101
+ zodError: error0Input.zodError,
102
+ axiosError: error0Input.axiosError
103
+ };
104
+ result.expected = this._normalizeSelfExpected(
105
+ result,
106
+ typeof error0Input.expected === "boolean" || typeof error0Input.expected === "function" ? error0Input.expected : meta.expected || this.defaultExpected
107
+ );
108
+ result.stack = this._removeConstructorStackPart(stack);
109
+ return result;
110
+ }
111
+ static _getSelfPropsFloated(causesProps) {
112
+ const cause = this._getClosestPropValue(causesProps, "cause");
113
+ const stack = this._mergeStack(causesProps[1]?.stack, causesProps[0]?.stack);
114
+ const closestTag = this._getClosestPropValue(causesProps, "tag");
115
+ const meta = this._getMergedMetaValue(causesProps);
116
+ const tag = Meta0.getFinalTag(meta, closestTag);
117
+ const propsFloated = {
118
+ message: this._getClosestPropValue(causesProps, "message"),
119
+ tag,
120
+ code: this._getClosestPropValue(causesProps, "code"),
121
+ httpStatus: this._getClosestPropValue(causesProps, "httpStatus"),
122
+ expected: this._isExpected(causesProps),
123
+ clientMessage: this._getClosestPropValue(causesProps, "clientMessage"),
124
+ cause,
125
+ stack,
126
+ anyMessage: causesProps[0].anyMessage,
127
+ meta,
128
+ zodError: this._getClosestPropValue(causesProps, "zodError"),
129
+ axiosError: this._getClosestPropValue(causesProps, "axiosError")
130
+ };
131
+ return propsFloated;
132
+ }
133
+ // sepcial
134
+ static _getExtraError0PropsByZodError(zodError) {
135
+ return {
136
+ message: `Zod Validation Error: ${zodError.message}`
137
+ };
138
+ }
139
+ static _getExtraError0PropsByAxiosError(axiosError) {
140
+ return {
141
+ message: "Axios Error",
142
+ meta: {
143
+ axiosData: (() => {
144
+ try {
145
+ return JSON.stringify(axiosError.response?.data);
146
+ } catch {
147
+ return void 0;
148
+ }
149
+ })(),
150
+ axiosStatus: axiosError.response?.status
151
+ }
152
+ };
153
+ }
154
+ static _assignError0Props(error0Props, extraError0Props) {
155
+ const metaValue = Meta0.mergeValues(error0Props.meta, extraError0Props.meta);
156
+ Object.assign(error0Props, extraError0Props, { meta: metaValue });
157
+ }
158
+ // expected
159
+ static _normalizeSelfExpected(error0Props, expectedProvided) {
160
+ if (typeof expectedProvided === "function") {
161
+ return expectedProvided(error0Props);
162
+ }
163
+ return expectedProvided;
164
+ }
165
+ static _isExpected(causesProps) {
166
+ let hasExpectedTrue = false;
167
+ for (const causeProps of causesProps) {
168
+ if (causeProps.expected === false) {
169
+ return false;
170
+ }
171
+ if (causeProps.expected === true) {
172
+ hasExpectedTrue = true;
173
+ }
174
+ }
175
+ return hasExpectedTrue;
176
+ }
177
+ // getters
178
+ static _getPropsFromUnknown(error, defaults) {
179
+ if (typeof error !== "object" || error === null) {
180
+ return {
181
+ message: void 0,
182
+ tag: void 0,
183
+ code: void 0,
184
+ httpStatus: void 0,
185
+ expected: void 0,
186
+ clientMessage: void 0,
187
+ anyMessage: this.defaultMessage,
188
+ cause: void 0,
189
+ stack: void 0,
190
+ zodError: void 0,
191
+ axiosError: void 0,
192
+ meta: {}
193
+ };
194
+ }
195
+ const message = "message" in error && typeof error.message === "string" ? error.message : void 0;
196
+ const clientMessage = "clientMessage" in error && typeof error.clientMessage === "string" ? error.clientMessage : defaults?.clientMessage || void 0;
197
+ const result = {
198
+ message,
199
+ code: "code" in error && typeof error.code === "string" ? error.code : defaults?.code || void 0,
200
+ clientMessage,
201
+ anyMessage: clientMessage || message || this.defaultMessage,
202
+ expected: void 0,
203
+ stack: "stack" in error && typeof error.stack === "string" ? error.stack : void 0,
204
+ tag: "tag" in error && typeof error.tag === "string" ? error.tag : defaults?.tag || void 0,
205
+ cause: "cause" in error ? error.cause : defaults?.cause || void 0,
206
+ meta: "meta" in error && typeof error.meta === "object" && error.meta !== null ? Meta0.getValue(error.meta) : Meta0.getValue(defaults?.meta) || {},
207
+ httpStatus: "httpStatus" in error && typeof error.httpStatus === "number" && error.httpStatus in HttpStatusCode ? error.httpStatus : typeof defaults?.httpStatus === "string" ? HttpStatusCode[defaults.httpStatus] : defaults?.httpStatus,
208
+ zodError: "zodError" in error && error.zodError instanceof ZodError ? error.zodError : error instanceof ZodError ? error : defaults?.zodError,
209
+ axiosError: "axiosError" in error && isAxiosError(error.axiosError) ? error.axiosError : isAxiosError(error) ? error : defaults?.axiosError
210
+ };
211
+ result.expected = this._normalizeSelfExpected(
212
+ result,
213
+ "expected" in error && (typeof error.expected === "boolean" || typeof error.expected === "function") ? error.expected : defaults?.expected || void 0
214
+ );
215
+ if (result.zodError) {
216
+ this._assignError0Props(result, this._getExtraError0PropsByZodError(result.zodError));
217
+ }
218
+ if (result.axiosError) {
219
+ this._assignError0Props(result, this._getExtraError0PropsByAxiosError(result.axiosError));
220
+ }
221
+ return result;
222
+ }
223
+ static _getCausesPropsFromUnknown(error, maxLevel) {
224
+ if (!error) {
225
+ return [];
226
+ }
227
+ const causeProps = this._getPropsFromUnknown(error);
228
+ const causesProps = [causeProps];
229
+ if (!causeProps.cause) {
230
+ return causesProps;
231
+ }
232
+ if (maxLevel > 0) {
233
+ causesProps.push(...this._getCausesPropsFromUnknown(this._getPropsFromUnknown(causeProps.cause), maxLevel - 1));
234
+ }
235
+ return causesProps;
236
+ }
237
+ static _getCausesPropsFromError0Props(error0Props, maxLevel) {
238
+ return [error0Props, ...this._getCausesPropsFromUnknown(error0Props.cause, maxLevel - 1)];
239
+ }
240
+ static _getClosestPropValue(causesProps, propKey) {
241
+ for (const causeProps of causesProps) {
242
+ const propValue = causeProps[propKey];
243
+ if (isFilled(propValue)) {
244
+ return propValue;
245
+ }
246
+ }
247
+ return void 0;
248
+ }
249
+ // private static getClosestByGetter<TResult>(
250
+ // causesProps: Error0GeneralProps[],
251
+ // getter: (props: Error0GeneralProps) => TResult,
252
+ // ): NonNullable<TResult> | undefined {
253
+ // for (const causeProps of causesProps) {
254
+ // const result = getter(causeProps)
255
+ // if (isFilled(result)) {
256
+ // return result
257
+ // }
258
+ // }
259
+ // return undefined
260
+ // }
261
+ static _getFilledPropValues(causesProps, propKey) {
262
+ const values = [];
263
+ for (const causeProps of causesProps) {
264
+ const propValue = causeProps[propKey];
265
+ if (isFilled(propValue)) {
266
+ values.push(propValue);
267
+ }
268
+ }
269
+ return values;
270
+ }
271
+ static _getMergedMetaValue(causesProps) {
272
+ const metas = this._getFilledPropValues(causesProps, "meta");
273
+ if (metas.length === 0) {
274
+ return {};
275
+ } else if (metas.length === 1) {
276
+ return metas[0];
277
+ } else {
278
+ return Meta0.mergeValues(metas[0], ...metas.slice(1));
279
+ }
280
+ }
281
+ // stack
282
+ static _removeConstructorStackPart(stack) {
283
+ if (!stack) {
284
+ return stack;
285
+ }
286
+ let lines = stack.split("\n");
287
+ const removeAllLinesContains = (search) => {
288
+ lines = lines.filter((line) => !line.includes(search));
289
+ };
290
+ removeAllLinesContains("at new Error0");
291
+ removeAllLinesContains("at _toError0");
292
+ removeAllLinesContains("at Error0.from");
293
+ removeAllLinesContains("at Error0._toError0");
294
+ return lines.join("\n");
295
+ }
296
+ static _mergeStack(prevStack, nextStack) {
297
+ return [nextStack, prevStack].filter(Boolean).join("\n\n") || void 0;
298
+ }
299
+ // transformations
300
+ static isError0(error) {
301
+ return error instanceof Error0;
302
+ }
303
+ static isLikelyError0(error) {
304
+ if (error instanceof Error0) {
305
+ return true;
306
+ }
307
+ if (typeof error === "object" && error !== null) {
308
+ if ("__I_AM_ERROR_0" in error && error.__I_AM_ERROR_0 === true) {
309
+ return true;
310
+ }
311
+ }
312
+ return false;
313
+ }
314
+ static _toError0(error, inputOverride = {}) {
315
+ if (error instanceof Error0) {
316
+ return error;
317
+ }
318
+ if (typeof error === "string") {
319
+ return new Error0(error, inputOverride);
320
+ }
321
+ if (typeof error !== "object" || error === null) {
322
+ return new Error0({
323
+ message: this.defaultMessage,
324
+ ...inputOverride
325
+ });
326
+ }
327
+ const inputFromData = get(error, "data");
328
+ if (inputFromData) {
329
+ if (Error0.isLikelyError0(inputFromData)) {
330
+ return this._toError0(inputFromData, inputOverride);
331
+ }
332
+ }
333
+ const inputFromDataError0 = get(error, "data.error0");
334
+ if (inputFromDataError0) {
335
+ if (Error0.isLikelyError0(inputFromDataError0)) {
336
+ return this._toError0(inputFromDataError0, inputOverride);
337
+ }
338
+ }
339
+ return new Error0(this._getPropsFromUnknown(error, inputOverride));
340
+ }
341
+ static from(error, inputOverride) {
342
+ return this._toError0(error, inputOverride);
343
+ }
344
+ static extend(props) {
345
+ const parent = this;
346
+ return class Error0 extends parent {
347
+ static defaultMessage = props.defaultMessage ?? parent.defaultMessage;
348
+ static defaultCode = props.defaultCode ?? parent.defaultCode;
349
+ static defaultHttpStatus = props.defaultHttpStatus ?? parent.defaultHttpStatus;
350
+ static defaultExpected = props.defaultExpected ?? parent.defaultExpected;
351
+ static defaultClientMessage = props.defaultClientMessage ?? parent.defaultClientMessage;
352
+ static defaultMeta = Meta0.extend(props.defaultMeta, parent.defaultMeta);
353
+ };
354
+ }
355
+ static extendCollection(classes, props) {
356
+ return Object.fromEntries(Object.entries(classes).map(([name, Class]) => [name, Class.extend(props)]));
357
+ }
358
+ toJSON() {
359
+ return {
360
+ message: this.message,
361
+ tag: this.tag,
362
+ code: this.code,
363
+ httpStatus: this.httpStatus,
364
+ expected: this.expected,
365
+ clientMessage: this.clientMessage,
366
+ anyMessage: this.anyMessage,
367
+ cause: this.cause,
368
+ meta: Meta0.getValue(this.meta),
369
+ stack: this.stack,
370
+ __I_AM_ERROR_0: this.__I_AM_ERROR_0
371
+ };
372
+ }
373
+ static toJSON(error, inputOverride) {
374
+ const error0 = this.from(error, inputOverride);
375
+ return error0.toJSON();
376
+ }
377
+ toResponse(data) {
378
+ return Response.json(
379
+ {
380
+ ...this.toJSON(),
381
+ ...data
382
+ },
383
+ {
384
+ status: this.httpStatus,
385
+ statusText: this.message
386
+ }
387
+ );
388
+ }
389
+ }
390
+ const e0s = {
391
+ Default: Error0,
392
+ Expected: Error0.extend({
393
+ defaultExpected: true
394
+ })
395
+ };
396
+ export {
397
+ Error0,
398
+ e0s
399
+ };
400
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { Meta0 } from '@devp0nt/meta0'\nimport { type AxiosError, HttpStatusCode, isAxiosError } from 'axios'\nimport get from 'lodash/get.js'\nimport { ZodError } from 'zod'\n\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\nexport interface Error0Input {\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\ninterface Error0GeneralProps {\n message: Error0Input['message']\n tag: Error0Input['tag']\n code: Error0Input['code']\n httpStatus: number | undefined\n expected: boolean | undefined\n clientMessage: Error0Input['clientMessage']\n anyMessage: string | undefined\n cause: Error0Input['cause']\n stack: Error['stack']\n meta: Meta0.ValueType\n zodError?: ZodError\n axiosError?: AxiosError\n}\n\ntype HttpStatusCodeString = keyof typeof HttpStatusCode\ntype Error0Cause = Error | Error0 | unknown\ntype ExpectedFn = (error: Error0GeneralProps) => boolean | undefined\n\nconst isFilled = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined && value !== ''\n\nexport class Error0 extends Error {\n public readonly __I_AM_ERROR_0: true = true\n\n public readonly tag?: Error0GeneralProps['tag']\n public readonly code?: Error0GeneralProps['code']\n public readonly httpStatus?: Error0GeneralProps['httpStatus']\n public readonly expected?: Error0GeneralProps['expected']\n public readonly clientMessage?: Error0GeneralProps['clientMessage']\n public readonly anyMessage?: Error0GeneralProps['anyMessage']\n public override readonly cause?: Error0GeneralProps['cause']\n public readonly meta?: Meta0.Meta0OrValueTypeNullish\n public readonly zodError?: Error0GeneralProps['zodError']\n public readonly axiosError?: Error0GeneralProps['axiosError']\n\n static defaultMessage = 'Unknown error'\n static defaultCode?: Error0GeneralProps['code']\n static defaultHttpStatus?: Error0GeneralProps['httpStatus']\n static defaultExpected?: Error0GeneralProps['expected']\n static defaultClientMessage?: Error0GeneralProps['clientMessage']\n static defaultMeta?: Meta0.Meta0OrValueTypeNullish\n\n public readonly propsOriginal: Error0GeneralProps\n\n constructor(message: string)\n constructor(input: Error0Input)\n constructor(message: string, input: Error0Input)\n constructor(error: Error)\n constructor(error: Error, input: Error0Input)\n constructor(value: unknown)\n constructor(value: unknown, input: Error0Input)\n constructor(...args: unknown[]) {\n const input: Partial<Error0Input> = {}\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>): Error0Input {\n const result: Error0Input = {}\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: Error0Input\n message: string\n stack: Error0GeneralProps['stack']\n }): Error0GeneralProps {\n // const meta = Meta0.merge(error0Input.meta0, error0Input.meta).value\n const meta0 = Meta0.extend(error0Input.meta, this.defaultMeta)\n const meta = meta0.getValue()\n const finalTag = meta0.getFinalTag(error0Input.tag)\n const clientMessage = error0Input.clientMessage || this.defaultClientMessage\n const result: Error0GeneralProps = {\n message: error0Input.message || this.defaultMessage,\n tag: finalTag,\n code: error0Input.code || 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 : 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 : meta.expected || this.defaultExpected,\n )\n result.stack = this._removeConstructorStackPart(stack)\n return result\n }\n\n public static _getSelfPropsFloated(causesProps: Error0GeneralProps[]): Error0GeneralProps {\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 = Meta0.getFinalTag(meta, closestTag)\n const propsFloated: Error0GeneralProps = {\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<Error0GeneralProps> {\n return {\n message: `Zod Validation Error: ${zodError.message}`,\n }\n }\n\n public static _getExtraError0PropsByAxiosError(axiosError: AxiosError): Partial<Error0GeneralProps> {\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: Error0GeneralProps,\n extraError0Props: Partial<Error0GeneralProps>,\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: Error0GeneralProps,\n expectedProvided: Error0Input['expected'],\n ): boolean | undefined {\n if (typeof expectedProvided === 'function') {\n return expectedProvided(error0Props)\n }\n return expectedProvided\n }\n\n public static _isExpected(causesProps: Error0GeneralProps[]): 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?: Error0Input): Error0GeneralProps {\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: Error0GeneralProps = {\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 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): Error0GeneralProps[] {\n if (!error) {\n return []\n }\n const causeProps = this._getPropsFromUnknown(error)\n const causesProps: Error0GeneralProps[] = [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: Error0GeneralProps,\n maxLevel: number,\n ): Error0GeneralProps[] {\n return [error0Props, ...this._getCausesPropsFromUnknown(error0Props.cause, maxLevel - 1)]\n }\n\n public static _getClosestPropValue<TPropKey extends keyof Error0GeneralProps>(\n causesProps: Error0GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0GeneralProps[TPropKey]> | undefined {\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n return propValue as NonNullable<Error0GeneralProps[TPropKey]>\n }\n }\n return undefined\n }\n\n // private static getClosestByGetter<TResult>(\n // causesProps: Error0GeneralProps[],\n // getter: (props: Error0GeneralProps) => 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 Error0Input>(\n causesProps: Error0GeneralProps[],\n propKey: TPropKey,\n ): NonNullable<Error0GeneralProps[TPropKey]>[] {\n const values: NonNullable<Error0GeneralProps[TPropKey]>[] = []\n for (const causeProps of causesProps) {\n const propValue = causeProps[propKey]\n if (isFilled(propValue)) {\n values.push(propValue as NonNullable<Error0GeneralProps[TPropKey]>)\n }\n }\n return values\n }\n\n public static _getMergedMetaValue(causesProps: Error0GeneralProps[]): 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: Error0GeneralProps['stack']): Error0GeneralProps['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: Error0GeneralProps['stack'],\n nextStack: Error0GeneralProps['stack'],\n ): Error0GeneralProps['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: Error0Input = {}): 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?: Error0Input): Error0 {\n return this._toError0(error, inputOverride)\n }\n\n static extend(props: {\n defaultMessage?: Error0GeneralProps['message']\n defaultCode?: Error0GeneralProps['code']\n defaultHttpStatus?: Error0GeneralProps['httpStatus']\n defaultExpected?: Error0GeneralProps['expected']\n defaultClientMessage?: Error0GeneralProps['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(props.defaultMeta, parent.defaultMeta)\n }\n }\n\n static extendCollection<T extends Record<string, typeof Error0>>(\n classes: T,\n props: {\n defaultMessage?: Error0GeneralProps['message']\n defaultCode?: Error0GeneralProps['code']\n defaultHttpStatus?: Error0GeneralProps['httpStatus']\n defaultExpected?: Error0GeneralProps['expected']\n defaultClientMessage?: Error0GeneralProps['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?: Error0Input) {\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 type JSON = ReturnType<Error0['toJSON']>\n export type Collection = Record<string, typeof Error0>\n}\n\nexport const e0s = {\n Default: Error0,\n Expected: Error0.extend({\n defaultExpected: true,\n }),\n} satisfies Error0.Collection\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAA0B,gBAAgB,oBAAoB;AAC9D,OAAO,SAAS;AAChB,SAAS,gBAAgB;AAyCzB,MAAM,WAAW,CAAI,UAAsC,UAAU,QAAQ,UAAU,UAAa,UAAU;AAEvG,MAAM,eAAe,MAAM;AAAA,EAChB,iBAAuB;AAAA,EAEvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,OAAO,iBAAiB;AAAA,EACxB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EAES;AAAA,EAShB,eAAe,MAAiB;AAC9B,UAAM,QAA8B,CAAC;AACrC,QAAI,KAAK,CAAC,aAAa,OAAO;AAC5B,YAAM,QAAQ,KAAK,CAAC;AAAA,IACtB,WAAW,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AAC1D,aAAO,OAAO,OAAO,KAAK,CAAC,CAAC;AAAA,IAC9B,WAAW,OAAO,KAAK,CAAC,MAAM,UAAU;AACtC,YAAM,UAAU,KAAK,C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Y,KAAK;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACF;AAOO,MAAM,MAAM;AAAA,EACjB,SAAS;AAAA,EACT,UAAU,OAAO,OAAO;AAAA,IACtB,iBAAiB;AAAA,EACnB,CAAC;AACH;","names":[]}
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@devp0nt/error0",
3
+ "license": "MIT",
4
+ "author": {
5
+ "name": "Sergei Dmitriev",
6
+ "url": "https://p0nt.dev"
7
+ },
8
+ "homepage": "https://github.com/devp0nt/error0#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/devp0nt/error0.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/devp0nt/error0/issues"
15
+ },
16
+ "type": "module",
17
+ "main": "./dist/cjs/index.js",
18
+ "module": "./dist/esm/index.js",
19
+ "types": "./dist/esm/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/esm/index.d.ts",
23
+ "import": "./dist/esm/index.js",
24
+ "require": "./dist/cjs/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist/**/*",
29
+ "src/**/*",
30
+ "README.md",
31
+ "LICENSE"
32
+ ],
33
+ "scripts": {
34
+ "dev": "tsc --watch --preserveWatchOutput --project tsconfig.build.json",
35
+ "build": "tsup",
36
+ "build:test:esm": "tsup --outDir dist-test/esm --tsconfig tsconfig.build.test.json --format esm src",
37
+ "build:test:esm:watch": "bun run build:test:esm --watch",
38
+ "build:test:cjs": "tsup --outDir dist-test/cjs --tsconfig tsconfig.build.test.json --format cjs src",
39
+ "build:test:cjs:watch": "bun run build:test:cjs --watch",
40
+ "build:test": "bun run build:test:esm && bun run build:test:cjs",
41
+ "build:test:watch": "bun run build:test:esm:watch & bun run build:test:cjs:watch",
42
+ "build:all": "bun run build && bun run build:test",
43
+ "test": "bun test src",
44
+ "test:watch": "bun test --watch",
45
+ "test:coverage": "bun test --coverage",
46
+ "test:dist:esm": "bun test dist-test/esm",
47
+ "test:dist:esm:watch": "bun run test:dist:esm --watch",
48
+ "test:dist:esm:build:watch": "bun build:test:esm:watch --no-clean & bun test:dist:esm:watch",
49
+ "test:dist:cjs": "bun test dist-test/cjs",
50
+ "test:dist:cjs:watch": "bun run test:dist:cjs --watch",
51
+ "test:dist:cjs:build:watch": "bun build:test:cjs:watch --no-clean & bun test:dist:cjs:watch",
52
+ "test:dist": "bun run test:dist:esm && bun run test:dist:cjs",
53
+ "test:dist:watch": "bun run test:dist:esm:watch & bun run test:dist:cjs:watch",
54
+ "test:dist:build:watch": "bun build:test:watch & bun test:dist:watch",
55
+ "test:all": "bun run test && bun run test:dist",
56
+ "test:all:watch": "bun run test:watch & bun run test:dist:watch",
57
+ "test:all:build": "bun run build:all && bun run test:all",
58
+ "test:all:build:watch": "bun run build:all:watch & bun run test:all:watch",
59
+ "lint": "biome check --write",
60
+ "types:build": "tsc --noEmit --project tsconfig.build.json",
61
+ "types:dev": "tsc --noEmit",
62
+ "types": "bun run types:dev",
63
+ "pack:dry": "npm pack --dry-run",
64
+ "prepare": "husky"
65
+ },
66
+ "dependencies": {
67
+ "@devp0nt/meta0": "^1.0.0-next.2",
68
+ "axios": "^1.12.2",
69
+ "zod": "^4.1.9"
70
+ },
71
+ "devDependencies": {
72
+ "@biomejs/biome": "^2.2.4",
73
+ "@commitlint/cli": "^19.8.1",
74
+ "@commitlint/config-conventional": "^19.8.1",
75
+ "@semantic-release/changelog": "^6.0.3",
76
+ "@semantic-release/git": "^10.0.1",
77
+ "@semantic-release/github": "^11.0.6",
78
+ "@semantic-release/npm": "^12.0.2",
79
+ "@types/bun": "^1.2.22",
80
+ "@types/lodash": "^4.17.20",
81
+ "@types/node": "^20.0.0",
82
+ "cross-env": "^10.0.0",
83
+ "husky": "^9.1.7",
84
+ "lodash": "^4.17.21",
85
+ "semantic-release": "^24.2.8",
86
+ "tsup": "^8.0.0",
87
+ "typescript": "^5.0.0"
88
+ },
89
+ "engines": {
90
+ "node": ">=18.0.0",
91
+ "bun": ">=1.0.0"
92
+ },
93
+ "publishConfig": {
94
+ "access": "public"
95
+ },
96
+ "version": "1.0.0-next.1"
97
+ }