@lssm/lib.error 1.11.0 → 1.41.0
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/README.md +5 -0
- package/dist/appError.js +1 -2
- package/dist/codes.js +1 -2
- package/dist/http.js +1 -2
- package/package.json +10 -10
- package/dist/appError.d.ts +0 -17
- package/dist/appError.d.ts.map +0 -1
- package/dist/appError.js.map +0 -1
- package/dist/codes.d.ts +0 -19
- package/dist/codes.d.ts.map +0 -1
- package/dist/codes.js.map +0 -1
- package/dist/http.d.ts +0 -11
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js.map +0 -1
- package/dist/index.d.ts +0 -4
package/README.md
CHANGED
package/dist/appError.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var e=class extends Error{constructor(e,t,n){super(t),this.code=e,this.details=n,Object.setPrototypeOf(this,new.target.prototype),this.name=`AppError`}};function t(t){return t instanceof e}export{e as AppError,t as isAppError};
|
|
2
|
-
//# sourceMappingURL=appError.js.map
|
|
1
|
+
var e=class extends Error{constructor(e,t,n){super(t),this.code=e,this.details=n,Object.setPrototypeOf(this,new.target.prototype),this.name=`AppError`}};function t(t){return t instanceof e}export{e as AppError,t as isAppError};
|
package/dist/codes.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
let e=function(e){return e.UNAUTHENTICATED=`UNAUTHENTICATED`,e.FORBIDDEN=`FORBIDDEN`,e.NOT_FOUND=`NOT_FOUND`,e.INVALID_INPUT=`INVALID_INPUT`,e.CONFLICT=`CONFLICT`,e.RATE_LIMITED=`RATE_LIMITED`,e.SERVER_ERROR=`SERVER_ERROR`,e.POLICY_DENIED=`POLICY_DENIED`,e}({});function t(t){return Object.values(e).includes(t)}export{e as ErrorCode,t as isKnownErrorCode};
|
|
2
|
-
//# sourceMappingURL=codes.js.map
|
|
1
|
+
let e=function(e){return e.UNAUTHENTICATED=`UNAUTHENTICATED`,e.FORBIDDEN=`FORBIDDEN`,e.NOT_FOUND=`NOT_FOUND`,e.INVALID_INPUT=`INVALID_INPUT`,e.CONFLICT=`CONFLICT`,e.RATE_LIMITED=`RATE_LIMITED`,e.SERVER_ERROR=`SERVER_ERROR`,e.POLICY_DENIED=`POLICY_DENIED`,e}({});function t(t){return Object.values(e).includes(t)}export{e as ErrorCode,t as isKnownErrorCode};
|
package/dist/http.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{ErrorCode as e}from"./codes.js";function t(t){switch(t){case e.UNAUTHENTICATED:return 401;case e.FORBIDDEN:case e.POLICY_DENIED:return 403;case e.NOT_FOUND:return 404;case e.INVALID_INPUT:return 400;case e.CONFLICT:return 409;case e.RATE_LIMITED:return 429;default:return 500}}export{t as httpStatus};
|
|
2
|
-
//# sourceMappingURL=http.js.map
|
|
1
|
+
import{ErrorCode as e}from"./codes.js";function t(t){switch(t){case e.UNAUTHENTICATED:return 401;case e.FORBIDDEN:case e.POLICY_DENIED:return 403;case e.NOT_FOUND:return 404;case e.INVALID_INPUT:return 400;case e.CONFLICT:return 409;case e.RATE_LIMITED:return 429;default:return 500}}export{t as httpStatus};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.error",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
6
6
|
"build": "bun build:bundle && bun build:types",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"lint:check": "eslint src"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@lssm/tool.typescript": "
|
|
17
|
-
"tsdown": "^0.
|
|
16
|
+
"@lssm/tool.typescript": "workspace:*",
|
|
17
|
+
"tsdown": "^0.17.4",
|
|
18
18
|
"typescript": "^5.9.3"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"elysia": "^1.4.
|
|
23
|
-
"express": "^5.1
|
|
24
|
-
"next": "16.0.
|
|
22
|
+
"elysia": "^1.4.19",
|
|
23
|
+
"express": "^5.2.1",
|
|
24
|
+
"next": "16.0.10"
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
27
27
|
"main": "./dist/index.js",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
34
|
"exports": {
|
|
35
|
-
".": "./
|
|
36
|
-
"./appError": "./
|
|
37
|
-
"./codes": "./
|
|
38
|
-
"./http": "./
|
|
35
|
+
".": "./src/index.ts",
|
|
36
|
+
"./appError": "./src/appError.ts",
|
|
37
|
+
"./codes": "./src/codes.ts",
|
|
38
|
+
"./http": "./src/http.ts",
|
|
39
39
|
"./*": "./*"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
package/dist/appError.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ErrorCode } from "./codes.js";
|
|
2
|
-
|
|
3
|
-
//#region src/appError.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generic application error with code and optional details.
|
|
7
|
-
*/
|
|
8
|
-
declare class AppError extends Error {
|
|
9
|
-
code: ErrorCode;
|
|
10
|
-
details?: Record<string, unknown> | undefined;
|
|
11
|
-
constructor(code: ErrorCode, message: string, details?: Record<string, unknown> | undefined);
|
|
12
|
-
}
|
|
13
|
-
/** Type guard to detect AppError */
|
|
14
|
-
declare function isAppError(err: unknown): err is AppError;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { AppError, isAppError };
|
|
17
|
-
//# sourceMappingURL=appError.d.ts.map
|
package/dist/appError.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAb,cAA8B,KAAM,CAClC,YACE,EACA,EACA,EACA,CACA,MAAM,EAAQ,CAJP,KAAA,KAAA,EAEA,KAAA,QAAA,EAGP,OAAO,eAAe,KAAM,IAAI,OAAO,UAAU,CACjD,KAAK,KAAO,aAKhB,SAAgB,EAAW,EAA+B,CACxD,OAAO,aAAe"}
|
package/dist/codes.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/codes.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Centralised error codes used across services.
|
|
4
|
-
* Extend this enum to add more domain-specific codes.
|
|
5
|
-
*/
|
|
6
|
-
declare enum ErrorCode {
|
|
7
|
-
UNAUTHENTICATED = "UNAUTHENTICATED",
|
|
8
|
-
FORBIDDEN = "FORBIDDEN",
|
|
9
|
-
NOT_FOUND = "NOT_FOUND",
|
|
10
|
-
INVALID_INPUT = "INVALID_INPUT",
|
|
11
|
-
CONFLICT = "CONFLICT",
|
|
12
|
-
RATE_LIMITED = "RATE_LIMITED",
|
|
13
|
-
SERVER_ERROR = "SERVER_ERROR",
|
|
14
|
-
POLICY_DENIED = "POLICY_DENIED",
|
|
15
|
-
}
|
|
16
|
-
declare function isKnownErrorCode(code: string): code is ErrorCode;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { ErrorCode, isKnownErrorCode };
|
|
19
|
-
//# sourceMappingURL=codes.d.ts.map
|
package/dist/codes.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAA,SAAA,EAAL,OACL,GAAA,gBAAA,kBACA,EAAA,UAAA,YACA,EAAA,UAAA,YACA,EAAA,cAAA,gBACA,EAAA,SAAA,WACA,EAAA,aAAA,eACA,EAAA,aAAA,eACA,EAAA,cAAA,uBAIF,SAAgB,EAAiB,EAAiC,CAChE,OAAO,OAAO,OAAO,EAAU,CAAC,SAAS,EAAkB"}
|
package/dist/http.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ErrorCode } from "./codes.js";
|
|
2
|
-
|
|
3
|
-
//#region src/http.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Map known error codes to HTTP status codes.
|
|
7
|
-
*/
|
|
8
|
-
declare function httpStatus(code: ErrorCode): number;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { httpStatus };
|
|
11
|
-
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","names":[],"sources":["../src/http.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;iBAAgB,UAAA,OAAiB"}
|
package/dist/http.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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":"uCAKA,SAAgB,EAAW,EAAyB,CAClD,OAAQ,EAAR,CACE,KAAK,EAAU,gBACb,MAAO,KACT,KAAK,EAAU,UACf,KAAK,EAAU,cACb,MAAO,KACT,KAAK,EAAU,UACb,MAAO,KACT,KAAK,EAAU,cACb,MAAO,KACT,KAAK,EAAU,SACb,MAAO,KACT,KAAK,EAAU,aACb,MAAO,KACT,QACE,MAAO"}
|
package/dist/index.d.ts
DELETED