@thangnv-dev/error-common 0.0.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,12 @@
1
+ export type StandardErrorInput = {
2
+ package: string;
3
+ code: string;
4
+ cause?: unknown;
5
+ message?: string;
6
+ };
7
+ export declare class StandardError extends Error {
8
+ readonly package: string;
9
+ readonly code: string;
10
+ constructor(input: StandardErrorInput);
11
+ }
12
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBAET,KAAK,EAAE,kBAAkB;CAQtC"}
package/dist/error.js ADDED
@@ -0,0 +1,13 @@
1
+ export class StandardError extends Error {
2
+ package;
3
+ code;
4
+ constructor(input) {
5
+ const { package: packageName, code, cause, message } = input;
6
+ const resolvedMessage = message ?? `${packageName}:${code}`;
7
+ super(resolvedMessage, cause === undefined ? undefined : { cause });
8
+ this.name = new.target.name;
9
+ this.package = packageName;
10
+ this.code = code;
11
+ }
12
+ }
13
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,OAAO,CAAQ;IACf,IAAI,CAAQ;IAErB,YAAY,KAAyB;QACnC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;QAC5D,MAAM,eAAe,GAAG,OAAO,IAAI,GAAG,WAAW,IAAI,IAAI,EAAE,CAAA;QAC3D,KAAK,CAAC,eAAe,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,WAAW,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { StandardError } from './error.js';
2
+ export type { StandardErrorInput } from './error.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { StandardError } from './error.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@thangnv-dev/error-common",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.build.json",
22
+ "lint": "eslint .",
23
+ "typecheck": "tsc --noEmit",
24
+ "test": "vitest run"
25
+ },
26
+ "devDependencies": {
27
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
28
+ "@typescript-eslint/parser": "^8.56.0",
29
+ "eslint": "^10.0.0",
30
+ "typescript": "^5.9.3",
31
+ "vitest": "^4.0.18"
32
+ },
33
+ "peerDependencies": {
34
+ "temporal-polyfill": "*"
35
+ }
36
+ }