@lssm/lib.error 0.0.0-canary-20251217083314 → 0.0.0-canary-20251220002821

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Chaman Ventures, SASU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -64,6 +64,9 @@ try {
64
64
 
65
65
 
66
66
 
67
+
68
+
69
+
67
70
 
68
71
 
69
72
 
@@ -13,4 +13,5 @@ declare class AppError extends Error {
13
13
  /** Type guard to detect AppError */
14
14
  declare function isAppError(err: unknown): err is AppError;
15
15
  //#endregion
16
- export { AppError, isAppError };
16
+ export { AppError, isAppError };
17
+ //# sourceMappingURL=appError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appError.d.ts","names":[],"sources":["../src/appError.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAEiB,cAFJ,QAAA,SAAiB,KAAA,CAEb;EAEI,IAAA,EAFJ,SAEI;EAFJ,OAAA,CAAA,EAEI,MAFJ,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,SAAA;EAEI,WAAA,CAAA,IAAA,EAFJ,SAEI,EAAA,OAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,SAAA;;;AASL,iBAAA,UAAA,CAAiC,GAAQ,EAAA,OAAA,CAAA,EAAA,GAAA,IAAR,QAAQ"}
package/dist/appError.js CHANGED
@@ -17,4 +17,5 @@ function isAppError(err) {
17
17
  }
18
18
 
19
19
  //#endregion
20
- export { AppError, isAppError };
20
+ export { AppError, isAppError };
21
+ //# sourceMappingURL=appError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appError.js","names":["code: ErrorCode","details?: Record<string, unknown>"],"sources":["../src/appError.ts"],"sourcesContent":["import { ErrorCode } from './codes';\n\n/**\n * Generic application error with code and optional details.\n */\nexport class AppError extends Error {\n constructor(\n public code: ErrorCode,\n message: string,\n public details?: Record<string, unknown>\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'AppError';\n }\n}\n\n/** Type guard to detect AppError */\nexport function isAppError(err: unknown): err is AppError {\n return err instanceof AppError;\n}\n"],"mappings":";;;;AAKA,IAAa,WAAb,cAA8B,MAAM;CAClC,YACE,AAAOA,MACP,SACA,AAAOC,SACP;AACA,QAAM,QAAQ;EAJP;EAEA;AAGP,SAAO,eAAe,MAAM,IAAI,OAAO,UAAU;AACjD,OAAK,OAAO;;;;AAKhB,SAAgB,WAAW,KAA+B;AACxD,QAAO,eAAe"}
package/dist/codes.d.ts CHANGED
@@ -15,4 +15,5 @@ declare enum ErrorCode {
15
15
  }
16
16
  declare function isKnownErrorCode(code: string): code is ErrorCode;
17
17
  //#endregion
18
- export { ErrorCode, isKnownErrorCode };
18
+ export { ErrorCode, isKnownErrorCode };
19
+ //# sourceMappingURL=codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.d.ts","names":[],"sources":["../src/codes.ts"],"sourcesContent":[],"mappings":";;AAIA;AAYA;;aAZY,SAAA;;;;;;;;;;iBAYI,gBAAA,wBAAwC"}
package/dist/codes.js CHANGED
@@ -19,4 +19,5 @@ function isKnownErrorCode(code) {
19
19
  }
20
20
 
21
21
  //#endregion
22
- export { ErrorCode, isKnownErrorCode };
22
+ export { ErrorCode, isKnownErrorCode };
23
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.js","names":[],"sources":["../src/codes.ts"],"sourcesContent":["/**\n * Centralised error codes used across services.\n * Extend this enum to add more domain-specific codes.\n */\nexport enum ErrorCode {\n UNAUTHENTICATED = 'UNAUTHENTICATED',\n FORBIDDEN = 'FORBIDDEN',\n NOT_FOUND = 'NOT_FOUND',\n INVALID_INPUT = 'INVALID_INPUT',\n CONFLICT = 'CONFLICT',\n RATE_LIMITED = 'RATE_LIMITED',\n SERVER_ERROR = 'SERVER_ERROR',\n POLICY_DENIED = 'POLICY_DENIED',\n // add more codes here\n}\n\nexport function isKnownErrorCode(code: string): code is ErrorCode {\n return Object.values(ErrorCode).includes(code as ErrorCode);\n}\n"],"mappings":";;;;;AAIA,IAAY,kDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAIF,SAAgB,iBAAiB,MAAiC;AAChE,QAAO,OAAO,OAAO,UAAU,CAAC,SAAS,KAAkB"}
package/dist/http.d.ts CHANGED
@@ -7,4 +7,5 @@ import { ErrorCode } from "./codes.js";
7
7
  */
8
8
  declare function httpStatus(code: ErrorCode): number;
9
9
  //#endregion
10
- export { httpStatus };
10
+ export { httpStatus };
11
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","names":[],"sources":["../src/http.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;iBAAgB,UAAA,OAAiB"}
package/dist/http.js CHANGED
@@ -21,4 +21,5 @@ function httpStatus(code) {
21
21
  */
22
22
 
23
23
  //#endregion
24
- export { httpStatus };
24
+ export { httpStatus };
25
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","names":[],"sources":["../src/http.ts"],"sourcesContent":["import { ErrorCode } from './codes';\n\n/**\n * Map known error codes to HTTP status codes.\n */\nexport function httpStatus(code: ErrorCode): number {\n switch (code) {\n case ErrorCode.UNAUTHENTICATED:\n return 401;\n case ErrorCode.FORBIDDEN:\n case ErrorCode.POLICY_DENIED:\n return 403;\n case ErrorCode.NOT_FOUND:\n return 404;\n case ErrorCode.INVALID_INPUT:\n return 400;\n case ErrorCode.CONFLICT:\n return 409;\n case ErrorCode.RATE_LIMITED:\n return 429;\n default:\n return 500;\n }\n}\n\n/**\n * Convert AppError or unknown error into a Problem JSON response body and status code.\n */\n// export function toHttpResponse(err: unknown): { status: number; body: any } {\n// if (isAppError(err)) {\n// const status = httpStatus(err.code);\n// return {\n// status,\n// body: {\n// type: `https://api.chaman.dev/errors/${err.code.toLowerCase()}`,\n// title: err.message,\n// detail: err.details ?? null,\n// status,\n// },\n// };\n// }\n// // Unknown error: hide internal details\n// return {\n// status: 500,\n// body: {\n// type: 'https://api.chaman.dev/errors/server_error',\n// title: 'Unexpected Error',\n// detail: null,\n// status: 500,\n// },\n// };\n// }\n"],"mappings":";;;;;;AAKA,SAAgB,WAAW,MAAyB;AAClD,SAAQ,MAAR;EACE,KAAK,UAAU,gBACb,QAAO;EACT,KAAK,UAAU;EACf,KAAK,UAAU,cACb,QAAO;EACT,KAAK,UAAU,UACb,QAAO;EACT,KAAK,UAAU,cACb,QAAO;EACT,KAAK,UAAU,SACb,QAAO;EACT,KAAK,UAAU,aACb,QAAO;EACT,QACE,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/lib.error",
3
- "version": "0.0.0-canary-20251217083314",
3
+ "version": "0.0.0-canary-20251220002821",
4
4
  "scripts": {
5
5
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
6
6
  "publish:pkg:canary": "bun publish:pkg --tag canary",
@@ -14,16 +14,16 @@
14
14
  "lint:check": "eslint src"
15
15
  },
16
16
  "devDependencies": {
17
- "@lssm/tool.tsdown": "0.0.0-canary-20251217083314",
18
- "@lssm/tool.typescript": "0.0.0-canary-20251217083314",
19
- "tsdown": "^0.17.4",
17
+ "@lssm/tool.tsdown": "0.0.0-canary-20251220002821",
18
+ "@lssm/tool.typescript": "0.0.0-canary-20251220002821",
19
+ "tsdown": "^0.18.1",
20
20
  "typescript": "^5.9.3"
21
21
  },
22
22
  "dependencies": {},
23
23
  "peerDependencies": {
24
24
  "elysia": "^1.4.19",
25
25
  "express": "^5.2.1",
26
- "next": "16.0.10"
26
+ "next": "16.1.0"
27
27
  },
28
28
  "type": "module",
29
29
  "main": "./dist/index.js",
@@ -48,6 +48,13 @@
48
48
  "./codes": "./dist/codes.js",
49
49
  "./http": "./dist/http.js",
50
50
  "./*": "./*"
51
- }
51
+ },
52
+ "registry": "https://registry.npmjs.org/"
53
+ },
54
+ "license": "MIT",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "https://github.com/lssm-tech/contractspec.git",
58
+ "directory": "packages/libs/error"
52
59
  }
53
60
  }