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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user