mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
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.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
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))
|
|
}
|
|
}
|