mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +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,41 @@
|
||||
import { Order } from "../../domain/aggregates/Order"
|
||||
import { OrderItemDto, OrderResponseDto } from "../dtos/OrderResponseDto"
|
||||
|
||||
/**
|
||||
* Order Mapper
|
||||
*/
|
||||
export class OrderMapper {
|
||||
public static toDto(order: Order): OrderResponseDto {
|
||||
const total = order.calculateTotal()
|
||||
|
||||
return {
|
||||
id: order.orderId.value,
|
||||
userId: order.userId.value,
|
||||
items: order.items.map((item) => OrderMapper.toItemDto(item)),
|
||||
status: order.status.value,
|
||||
subtotal: total.amount,
|
||||
currency: total.currency,
|
||||
createdAt: order.createdAt.toISOString(),
|
||||
confirmedAt: order.confirmedAt?.toISOString(),
|
||||
deliveredAt: order.deliveredAt?.toISOString(),
|
||||
}
|
||||
}
|
||||
|
||||
private static toItemDto(item: any): OrderItemDto {
|
||||
const total = item.calculateTotal()
|
||||
|
||||
return {
|
||||
id: item.id,
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
price: item.price.amount,
|
||||
currency: item.price.currency,
|
||||
quantity: item.quantity,
|
||||
total: total.amount,
|
||||
}
|
||||
}
|
||||
|
||||
public static toDtoList(orders: Order[]): OrderResponseDto[] {
|
||||
return orders.map((order) => OrderMapper.toDto(order))
|
||||
}
|
||||
}
|
||||
@@ -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