mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
feat(guardian): add guardian package - code quality analyzer
Add @puaros/guardian package v0.1.0 - code quality guardian for vibe coders and enterprise teams. Features: - Hardcode detection (magic numbers, magic strings) - Circular dependency detection - Naming convention enforcement (Clean Architecture) - Architecture violation detection - CLI tool with comprehensive reporting - 159 tests with 80%+ coverage - Smart suggestions for fixes - Built for AI-assisted development Built with Clean Architecture and DDD principles. Works with Claude, GPT, Copilot, Cursor, and any AI coding assistant.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { User } from "../../domain/aggregates/User"
|
||||
import { UserResponseDto } from "../dtos/UserResponseDto"
|
||||
|
||||
/**
|
||||
* User Mapper
|
||||
*
|
||||
* DDD Pattern: Mapper
|
||||
* - Converts between domain and DTOs
|
||||
* - Isolates domain from presentation
|
||||
* - No business logic
|
||||
*
|
||||
* SOLID Principles:
|
||||
* - SRP: only mapping
|
||||
* - OCP: extend for new DTOs
|
||||
*
|
||||
* Clean Architecture:
|
||||
* - Application layer
|
||||
* - Protects domain integrity
|
||||
*/
|
||||
export class UserMapper {
|
||||
/**
|
||||
* Map domain entity to response DTO
|
||||
*/
|
||||
public static toDto(user: User): UserResponseDto {
|
||||
return {
|
||||
id: user.userId.value,
|
||||
email: user.email.value,
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
fullName: user.fullName,
|
||||
isActive: user.isActive,
|
||||
isBlocked: user.isBlocked,
|
||||
registeredAt: user.registeredAt.toISOString(),
|
||||
lastLoginAt: user.lastLoginAt?.toISOString(),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map array of entities to DTOs
|
||||
*/
|
||||
public static toDtoList(users: User[]): UserResponseDto[] {
|
||||
return users.map((user) => UserMapper.toDto(user))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user