feat: add entity exposure detection (v0.3.0)

Implement entity exposure detection to prevent domain entities
from leaking to API responses. Detects when controllers/routes
return domain entities instead of DTOs.

Features:
- EntityExposure value object with detailed suggestions
- IEntityExposureDetector interface in domain layer
- EntityExposureDetector implementation in infrastructure
- Integration into AnalyzeProject use case
- CLI display with helpful suggestions
- 24 comprehensive unit tests (98% coverage)
- Examples for bad and good patterns

Detection scope:
- Infrastructure layer only (controllers, routes, handlers, resolvers, gateways)
- Identifies PascalCase entities without Dto/Request/Response suffixes
- Parses async methods with Promise<T> return types
- Provides step-by-step remediation suggestions

Test coverage:
- EntityExposureDetector: 98.07%
- Overall project: 90.6% statements, 83.97% branches
- 218 tests passing

BREAKING CHANGE: Version bump to 0.3.0
This commit is contained in:
imfozilbek
2025-11-24 13:51:12 +05:00
parent a3cd71070e
commit f46048172f
14 changed files with 893 additions and 17 deletions

View File

@@ -2,7 +2,7 @@
This document outlines the current features and future plans for @puaros/guardian.
## Current Version: 0.1.0 ✅ RELEASED
## Current Version: 0.3.0 ✅ RELEASED
**Released:** 2025-11-24
@@ -42,10 +42,9 @@ This document outlines the current features and future plans for @puaros/guardia
---
## Future Roadmap
## Version 0.3.0 - Entity Exposure Detection 🎭 ✅ RELEASED
### Version 0.2.0 - Entity Exposure Detection 🎭
**Target:** Q1 2026
**Released:** 2025-11-24
**Priority:** HIGH
Prevent domain entities from leaking to API responses:
@@ -63,15 +62,18 @@ async getUser(id: string): Promise<UserResponseDto> {
}
```
**Planned Features:**
- Analyze return types in controllers/routes
- Check if returned type is from domain/entities
- Suggest using DTOs and Mappers
- Examples of proper DTO usage
**Implemented Features:**
- Analyze return types in controllers/routes
- Check if returned type is from domain/entities
- Suggest using DTOs and Mappers
- Examples of proper DTO usage
- ✅ 24 tests covering all scenarios
---
### Version 0.3.0 - Dependency Direction Enforcement 🎯
## Future Roadmap
### Version 0.4.0 - Dependency Direction Enforcement 🎯
**Target:** Q1 2026
**Priority:** HIGH
@@ -111,7 +113,7 @@ import { User } from '../../domain/entities/User' // OK
---
### Version 0.4.0 - Repository Pattern Validation 📚
### Version 0.5.0 - Repository Pattern Validation 📚
**Target:** Q1 2026
**Priority:** HIGH
@@ -152,7 +154,7 @@ class CreateUser {
---
### Version 0.5.0 - Aggregate Boundary Validation 🔒
### Version 0.6.0 - Aggregate Boundary Validation 🔒
**Target:** Q1 2026
**Priority:** MEDIUM
@@ -189,7 +191,7 @@ class Order {
---
### Version 0.6.0 - Anemic Domain Model Detection 🩺
### Version 0.7.0 - Anemic Domain Model Detection 🩺
**Target:** Q2 2026
**Priority:** MEDIUM
@@ -1746,4 +1748,4 @@ Until we reach 1.0.0, minor version bumps (0.x.0) may include breaking changes a
---
**Last Updated:** 2025-11-24
**Current Version:** 0.2.0
**Current Version:** 0.3.0