@nathapp/nestjs-common 3.2.3 → 3.3.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/AGENTS.md +49 -0
- package/CLAUDE.md +18 -0
- package/GEMINI.md +47 -0
- package/codex.md +47 -0
- package/dist/exception/global-exception.filter.d.ts +4 -1
- package/dist/exception/global-exception.filter.js +22 -6
- package/dist/exception/global-exception.filter.js.map +1 -1
- package/dist/interceptor/serializable.interceptor.js +5 -2
- package/dist/interceptor/serializable.interceptor.js.map +1 -1
- package/dist/validation/validation.d.ts +1 -0
- package/package.json +4 -2
package/AGENTS.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
These instructions apply to all AI coding agents in this project.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Project Metadata
|
|
11
|
+
|
|
12
|
+
> Auto-injected by `nax generate`
|
|
13
|
+
|
|
14
|
+
**Project:** `@nathapp/nestjs-common`
|
|
15
|
+
|
|
16
|
+
**Language:** TypeScript
|
|
17
|
+
|
|
18
|
+
**Key dependencies:** @nathapp/typescript-config, @nestjs/throttler, typescript
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
# @nathapp/nestjs-common
|
|
22
|
+
|
|
23
|
+
Foundation package — exceptions, filters, interceptors, validation, pagination, shared types.
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
27
|
+
- Build: `npx tsc`
|
|
28
|
+
|
|
29
|
+
## Exception System
|
|
30
|
+
- `GlobalExceptionsFilter` with handler chain pattern — extensible via `ExceptionHandler` interface.
|
|
31
|
+
- `ExceptionHandler`: implement `canHandle(exception)` + `handle(exception, host)`.
|
|
32
|
+
- Register handlers: `ExceptionModule.forRoot({ handlers: [MyHandler] })` or `GlobalExceptionsFilter.registerHandler()` (static, deduped).
|
|
33
|
+
- Built-in handlers: AppException, Forbidden, NotFound, BadRequest, Throttler, Microservice, Unknown.
|
|
34
|
+
- ThrottlerException detected via `constructor.name` (no package import needed).
|
|
35
|
+
|
|
36
|
+
## Key Types
|
|
37
|
+
- `AppException` — base exception class with `errorCode`, `statusCode`, `i18nKey`.
|
|
38
|
+
- `Page<T>`, `PageOption`, `IPageOption` — ORM-agnostic pagination (moved from nestjs-data).
|
|
39
|
+
- `BaseEntity` — shared base with `id`, `createdAt`, `updatedAt`.
|
|
40
|
+
- `IServerSecurityConfig` — Helmet/CORS/trust-proxy config via `SERVER_SECURITY_CFG` token.
|
|
41
|
+
|
|
42
|
+
## Gotchas
|
|
43
|
+
- `SerializableInterceptor` clones arrays before transforming — don't mutate the original.
|
|
44
|
+
- `isPackageInstalled('')` returns `false` (empty string edge case handled).
|
|
45
|
+
- Validation decorators use nestjs-i18n for i18n support.
|
|
46
|
+
|
|
47
|
+
## IMPORTANT
|
|
48
|
+
- Many packages depend on this — changes here affect the entire monorepo.
|
|
49
|
+
- Rebuild (`npx tsc`) after changes before testing dependent packages.
|
package/CLAUDE.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# Project Context
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-common`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, @nestjs/throttler, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
1
19
|
# @nathapp/nestjs-common
|
|
2
20
|
|
|
3
21
|
Foundation package — exceptions, filters, interceptors, validation, pagination, shared types.
|
package/GEMINI.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Gemini CLI Context
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-common`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, @nestjs/throttler, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
# @nathapp/nestjs-common
|
|
20
|
+
|
|
21
|
+
Foundation package — exceptions, filters, interceptors, validation, pagination, shared types.
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
25
|
+
- Build: `npx tsc`
|
|
26
|
+
|
|
27
|
+
## Exception System
|
|
28
|
+
- `GlobalExceptionsFilter` with handler chain pattern — extensible via `ExceptionHandler` interface.
|
|
29
|
+
- `ExceptionHandler`: implement `canHandle(exception)` + `handle(exception, host)`.
|
|
30
|
+
- Register handlers: `ExceptionModule.forRoot({ handlers: [MyHandler] })` or `GlobalExceptionsFilter.registerHandler()` (static, deduped).
|
|
31
|
+
- Built-in handlers: AppException, Forbidden, NotFound, BadRequest, Throttler, Microservice, Unknown.
|
|
32
|
+
- ThrottlerException detected via `constructor.name` (no package import needed).
|
|
33
|
+
|
|
34
|
+
## Key Types
|
|
35
|
+
- `AppException` — base exception class with `errorCode`, `statusCode`, `i18nKey`.
|
|
36
|
+
- `Page<T>`, `PageOption`, `IPageOption` — ORM-agnostic pagination (moved from nestjs-data).
|
|
37
|
+
- `BaseEntity` — shared base with `id`, `createdAt`, `updatedAt`.
|
|
38
|
+
- `IServerSecurityConfig` — Helmet/CORS/trust-proxy config via `SERVER_SECURITY_CFG` token.
|
|
39
|
+
|
|
40
|
+
## Gotchas
|
|
41
|
+
- `SerializableInterceptor` clones arrays before transforming — don't mutate the original.
|
|
42
|
+
- `isPackageInstalled('')` returns `false` (empty string edge case handled).
|
|
43
|
+
- Validation decorators use nestjs-i18n for i18n support.
|
|
44
|
+
|
|
45
|
+
## IMPORTANT
|
|
46
|
+
- Many packages depend on this — changes here affect the entire monorepo.
|
|
47
|
+
- Rebuild (`npx tsc`) after changes before testing dependent packages.
|
package/codex.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Codex Instructions
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-common`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, @nestjs/throttler, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
# @nathapp/nestjs-common
|
|
20
|
+
|
|
21
|
+
Foundation package — exceptions, filters, interceptors, validation, pagination, shared types.
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
25
|
+
- Build: `npx tsc`
|
|
26
|
+
|
|
27
|
+
## Exception System
|
|
28
|
+
- `GlobalExceptionsFilter` with handler chain pattern — extensible via `ExceptionHandler` interface.
|
|
29
|
+
- `ExceptionHandler`: implement `canHandle(exception)` + `handle(exception, host)`.
|
|
30
|
+
- Register handlers: `ExceptionModule.forRoot({ handlers: [MyHandler] })` or `GlobalExceptionsFilter.registerHandler()` (static, deduped).
|
|
31
|
+
- Built-in handlers: AppException, Forbidden, NotFound, BadRequest, Throttler, Microservice, Unknown.
|
|
32
|
+
- ThrottlerException detected via `constructor.name` (no package import needed).
|
|
33
|
+
|
|
34
|
+
## Key Types
|
|
35
|
+
- `AppException` — base exception class with `errorCode`, `statusCode`, `i18nKey`.
|
|
36
|
+
- `Page<T>`, `PageOption`, `IPageOption` — ORM-agnostic pagination (moved from nestjs-data).
|
|
37
|
+
- `BaseEntity` — shared base with `id`, `createdAt`, `updatedAt`.
|
|
38
|
+
- `IServerSecurityConfig` — Helmet/CORS/trust-proxy config via `SERVER_SECURITY_CFG` token.
|
|
39
|
+
|
|
40
|
+
## Gotchas
|
|
41
|
+
- `SerializableInterceptor` clones arrays before transforming — don't mutate the original.
|
|
42
|
+
- `isPackageInstalled('')` returns `false` (empty string edge case handled).
|
|
43
|
+
- Validation decorators use nestjs-i18n for i18n support.
|
|
44
|
+
|
|
45
|
+
## IMPORTANT
|
|
46
|
+
- Many packages depend on this — changes here affect the entire monorepo.
|
|
47
|
+
- Rebuild (`npx tsc`) after changes before testing dependent packages.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { JsonResponse } from "@nathapp/common";
|
|
1
2
|
import { ExceptionFilter, ArgumentsHost } from "@nestjs/common";
|
|
2
3
|
import { HttpAdapterHost } from "@nestjs/core";
|
|
3
4
|
import { I18nService } from "nestjs-i18n";
|
|
5
|
+
import { Observable } from "rxjs";
|
|
4
6
|
import type { ExceptionHandler } from "./handler";
|
|
5
7
|
export declare class GlobalExceptionsFilter implements ExceptionFilter {
|
|
6
8
|
private readonly httpAdapterHost;
|
|
@@ -12,6 +14,7 @@ export declare class GlobalExceptionsFilter implements ExceptionFilter {
|
|
|
12
14
|
constructor(httpAdapterHost: HttpAdapterHost, i18nService?: I18nService, injectedHandlers?: ExceptionHandler[]);
|
|
13
15
|
static registerHandler(handler: ExceptionHandler): void;
|
|
14
16
|
static clearHandlers(): void;
|
|
15
|
-
catch(exception: unknown, host: ArgumentsHost): Promise<void
|
|
17
|
+
catch(exception: unknown, host: ArgumentsHost): Promise<void | JsonResponse | Observable<never>>;
|
|
18
|
+
private extractRequest;
|
|
16
19
|
translate(code: number, lang: string, args?: any, prefix?: string): Promise<string>;
|
|
17
20
|
}
|
|
@@ -18,6 +18,7 @@ const common_1 = require("@nathapp/common");
|
|
|
18
18
|
const common_2 = require("@nestjs/common");
|
|
19
19
|
const core_1 = require("@nestjs/core");
|
|
20
20
|
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
21
|
+
const rxjs_1 = require("rxjs");
|
|
21
22
|
const handler_1 = require("./handler");
|
|
22
23
|
const exception_constants_1 = require("./exception.constants");
|
|
23
24
|
const app_exception_code_enum_1 = require("./app-exception-code.enum");
|
|
@@ -45,11 +46,9 @@ let GlobalExceptionsFilter = GlobalExceptionsFilter_1 = class GlobalExceptionsFi
|
|
|
45
46
|
}
|
|
46
47
|
async catch(exception, host) {
|
|
47
48
|
var _a;
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const request = ctx.getRequest();
|
|
52
|
-
const lang = request.i18nLang;
|
|
49
|
+
const contextType = ((host.getType ? host.getType() : undefined) || 'http');
|
|
50
|
+
const request = this.extractRequest(host, contextType);
|
|
51
|
+
const lang = request === null || request === void 0 ? void 0 : request.i18nLang;
|
|
53
52
|
const context = {
|
|
54
53
|
lang,
|
|
55
54
|
request,
|
|
@@ -86,7 +85,24 @@ let GlobalExceptionsFilter = GlobalExceptionsFilter_1 = class GlobalExceptionsFi
|
|
|
86
85
|
const message = await this.translate(app_exception_code_enum_1.CommonExceptionCode.UNKNOWN_ERROR, lang);
|
|
87
86
|
result = { httpStatus: 500, errorCode: app_exception_code_enum_1.CommonExceptionCode.UNKNOWN_ERROR, message };
|
|
88
87
|
}
|
|
89
|
-
|
|
88
|
+
const errorPayload = common_1.JsonResponse.Error(result.errorCode, result.message);
|
|
89
|
+
if (contextType !== 'http') {
|
|
90
|
+
return (0, rxjs_1.throwError)(() => errorPayload);
|
|
91
|
+
}
|
|
92
|
+
const { httpAdapter } = this.httpAdapterHost;
|
|
93
|
+
const response = host.switchToHttp().getResponse();
|
|
94
|
+
httpAdapter.reply(response, errorPayload, result.httpStatus);
|
|
95
|
+
}
|
|
96
|
+
extractRequest(host, contextType) {
|
|
97
|
+
switch (contextType) {
|
|
98
|
+
case 'rpc':
|
|
99
|
+
return host.switchToRpc().getData();
|
|
100
|
+
case 'ws':
|
|
101
|
+
return host.switchToWs().getData();
|
|
102
|
+
case 'http':
|
|
103
|
+
default:
|
|
104
|
+
return host.switchToHttp().getRequest();
|
|
105
|
+
}
|
|
90
106
|
}
|
|
91
107
|
async translate(code, lang, args, prefix) {
|
|
92
108
|
const key = `${prefix || this.exceptionPrefix}.${code}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../../lib/exception/global-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA+C;AAC/C,2CAOwB;AACxB,uCAA+C;AAC/C,6CAA0C;
|
|
1
|
+
{"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../../lib/exception/global-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA+C;AAC/C,2CAOwB;AACxB,uCAA+C;AAC/C,6CAA0C;AAC1C,+BAA8C;AAE9C,uCAA4C;AAC5C,+DAA2D;AAC3D,uEAAgE;AAChE,mDAA+C;AAQxC,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAMjC,YACmB,eAAgC,EACrC,WAA0C,EACd,gBAAqC;QAF5D,oBAAe,GAAf,eAAe,CAAiB;QACpB,gBAAW,GAAX,WAAW,CAAc;QALvC,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;QACjD,oBAAe,GAAG,WAAW,CAAC;QAO7C,IAAI,CAAC,QAA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C,CAAC;IACzD,CAAC;;AAhJU,wDAAsB;AAClB,qCAAc,GAAG,IAAI,GAAG,EAA4B,AAAtC,CAAuC;iCADzD,sBAAsB;IADlC,IAAA,cAAK,GAAE;IASH,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,wCAAkB,CAAC,CAAA;qCAFL,sBAAe;QACN,yBAAW;GAR7C,sBAAsB,CAiJlC"}
|
|
@@ -32,8 +32,11 @@ let SerializableInterceptor = SerializableInterceptor_1 = class SerializableInte
|
|
|
32
32
|
this.isUndefined = (obj) => typeof obj === 'undefined';
|
|
33
33
|
}
|
|
34
34
|
intercept(context, next) {
|
|
35
|
-
|
|
36
|
-
const
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const contextType = (_a = context.getType) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
37
|
+
const lang = (!contextType || contextType === 'http')
|
|
38
|
+
? (_b = context.switchToHttp().getRequest()) === null || _b === void 0 ? void 0 : _b.i18nLang
|
|
39
|
+
: this.fallbackLanguage;
|
|
37
40
|
const contextOptions = this.getContextOptions(context);
|
|
38
41
|
const options = {
|
|
39
42
|
...this.defaultOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializable.interceptor.js","sourceRoot":"","sources":["../../lib/interceptor/serializable.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwM;AACxM,yDAA8E;AAC9E,+BAAuC;AACvC,4CAAwE;AACxE,0CAAwC;AAExC,MAAM,SAAS,GAAG,GAAG,CAAC;AAQf,IAAM,uBAAuB,+BAA7B,MAAM,uBAAwB,SAAQ,mCAA0B;IAIrE,YACqB,SAAiC,EAEpD,iBAAuE,EAAE;QAEzE,KAAK,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAJK,cAAS,GAAT,SAAS,CAAK;QAEjC,mBAAc,GAAd,cAAc,CAAwC;QAN1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AAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,oBAAS,CAAC,CAAA;IACjB,WAAA,IAAA,iBAAQ,GAAE,CAAA;;GANF,uBAAuB,CAmLnC"}
|
|
@@ -6,6 +6,7 @@ export declare const resolveI18nValidationOptions: (options: I18nValidationOptio
|
|
|
6
6
|
groups?: string[];
|
|
7
7
|
always?: boolean;
|
|
8
8
|
context?: any;
|
|
9
|
+
validateIf?: (object: any, value: any) => boolean;
|
|
9
10
|
message: (a: import("class-validator").ValidationArguments) => string;
|
|
10
11
|
};
|
|
11
12
|
export declare const resolveI18nValidationMessage: (key: string, prefix: string, args?: any) => (a: import("class-validator").ValidationArguments) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nestjs-common",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "NestJs Common Library",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist/ .turbo/",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"test": "jest --config ./test/jest-test.json",
|
|
10
10
|
"test:cov": "jest --config ./test/jest-test.json --coverage",
|
|
11
11
|
"test:watch": "jest --config ./test/jest-test.json --watch",
|
|
12
|
-
"lint": "eslint -c .eslintrc.js"
|
|
12
|
+
"lint": "eslint -c .eslintrc.js",
|
|
13
|
+
"type-check": "tsc --noEmit -p tsconfig.json",
|
|
14
|
+
"lint:fix": "eslint -c .eslintrc.js --fix"
|
|
13
15
|
},
|
|
14
16
|
"author": "",
|
|
15
17
|
"license": "ISC",
|