@ts-typed/nestjs 0.1.0 → 0.1.2
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ All notable changes to `@ts-typed/nestjs` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.1.2] - 2026-10-17
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Depends on `@ts-typed/compiler@0.1.2`, which fixes a severe regression 0.1.1 introduced (a readonly field with `?`/`!` locked immediately, breaking class-transformer-built DTOs) and adds `static` field and `Map`/`Set` support. No code changes in this package itself; this bump keeps both packages pinned to compatible, non-duplicated versions of `StrictTypeError` (an exact-pinned transitive dependency on a different compiler version than the app's own direct dependency would create two separate `StrictTypeError` classes, breaking `instanceof` checks across the package boundary).
|
|
12
|
+
|
|
13
|
+
## [0.1.1] - 2026-10-17
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `StrictTypeErrorFilter` kept returning HTTP 400 for a violation on a plain local variable (e.g. `const entity = await repo.findOneBy(...)` reading corrupted data back from a database) because the value flowed through an `initialize`/`set` operation, not `return`/`resolve`. A local variable is never the client-facing surface of a request — client input only ever reaches a protected contract through a `parameter` or a `property` (a DTO's own fields) — so a violation whose `contractKind` is `variable` now also maps to HTTP 500, regardless of its `operation`.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Depends on `@ts-typed/compiler@0.1.1`.
|
|
22
|
+
|
|
7
23
|
## [0.1.0] - 2026-10-17
|
|
8
24
|
|
|
9
25
|
### Fixed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-type-error.filter.d.ts","sourceRoot":"","sources":["../src/strict-type-error.filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"strict-type-error.filter.d.ts","sourceRoot":"","sources":["../src/strict-type-error.filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA+BrD;;;;;;;;;GASG;AACH,qBACa,qBAAsB,YAAW,eAAe;IACpD,KAAK,CAAC,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;CAapE"}
|
|
@@ -19,6 +19,18 @@ const compiler_1 = require("@ts-typed/compiler");
|
|
|
19
19
|
* point — closer to client-controlled input — and keeps the 400 default.
|
|
20
20
|
*/
|
|
21
21
|
const SERVER_FAULT_OPERATIONS = new Set(['return', 'resolve']);
|
|
22
|
+
/**
|
|
23
|
+
* A plain local variable (`const entity = await repo.findOneBy(...)`) is
|
|
24
|
+
* never the client-facing surface of a request: client input only ever
|
|
25
|
+
* reaches a protected contract through a `parameter` (`@Body()`/`@Param()`
|
|
26
|
+
* decorated arguments, which use the `argument` operation, never
|
|
27
|
+
* `variable`) or a `property` (a DTO's own fields). A violation whose
|
|
28
|
+
* `contractKind` is `variable` is therefore always a server-side data
|
|
29
|
+
* problem — typically corrupted data read back from a database — even
|
|
30
|
+
* though its `operation` is `initialize`/`set`, which otherwise means
|
|
31
|
+
* "value came from outside this function" and defaults to 400.
|
|
32
|
+
*/
|
|
33
|
+
const SERVER_FAULT_CONTRACT_KINDS = new Set(['variable']);
|
|
22
34
|
/**
|
|
23
35
|
* Translates a `StrictTypeError` thrown by instrumented code (a DTO/provider
|
|
24
36
|
* field failing validation at a protected boundary) into an HTTP response,
|
|
@@ -32,9 +44,9 @@ const SERVER_FAULT_OPERATIONS = new Set(['return', 'resolve']);
|
|
|
32
44
|
let StrictTypeErrorFilter = class StrictTypeErrorFilter {
|
|
33
45
|
catch(exception, host) {
|
|
34
46
|
const response = host.switchToHttp().getResponse();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
const isServerFault = SERVER_FAULT_OPERATIONS.has(exception.operation) ||
|
|
48
|
+
SERVER_FAULT_CONTRACT_KINDS.has(exception.contractKind);
|
|
49
|
+
const status = isServerFault ? common_1.HttpStatus.INTERNAL_SERVER_ERROR : common_1.HttpStatus.BAD_REQUEST;
|
|
38
50
|
const httpException = new common_1.HttpException({
|
|
39
51
|
statusCode: status,
|
|
40
52
|
message: exception.message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-type-error.filter.js","sourceRoot":"","sources":["../src/strict-type-error.filter.ts"],"names":[],"mappings":";;;;;;;;;AACA,2CAAkE;AAClE,iDAAqD;AAOrD;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAEpF;;;;;;;;;GASG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACzB,KAAK,CAAC,SAA0B,EAAE,IAAmB;QAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,WAAW,EAAuB,CAAC;QACxE,MAAM,
|
|
1
|
+
{"version":3,"file":"strict-type-error.filter.js","sourceRoot":"","sources":["../src/strict-type-error.filter.ts"],"names":[],"mappings":";;;;;;;;;AACA,2CAAkE;AAClE,iDAAqD;AAOrD;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAE/E;;;;;;;;;GASG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACzB,KAAK,CAAC,SAA0B,EAAE,IAAmB;QAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,WAAW,EAAuB,CAAC;QACxE,MAAM,aAAa,GACjB,uBAAuB,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC;YAChD,2BAA2B,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,mBAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC,mBAAU,CAAC,WAAW,CAAC;QACzF,MAAM,aAAa,GAAG,IAAI,sBAAa,CAAC;YACtC,UAAU,EAAE,MAAM;YAClB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,GAAG,SAAS,CAAC,MAAM,EAAE;SACtB,EAAE,MAAM,CAAC,CAAC;QACX,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/E,CAAC;CACF,CAAA;AAdY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,cAAK,EAAC,0BAAe,CAAC;GACV,qBAAqB,CAcjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-typed/nestjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test": "npm run build && node --test --test-concurrency=1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ts-typed/compiler": "0.1.
|
|
36
|
+
"@ts-typed/compiler": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@nestjs/common": ">=10 <13",
|