/** Public API of the orders module. */
import type pg from 'pg';
import { OrderService } from './application/order-service.js';
import { PgOrderRepository } from './infrastructure/pg-order-repository.js';
import { NoOpOrderEventPublisher } from './infrastructure/no-op-event-publisher.js';

export { registerOrdersRoutes, type OrdersRoutesDeps } from './api/orders.routes.js';
export { OrderService } from './application/order-service.js';
export { OrderStateTransitionError, OrderNotFoundError } from './domain/errors.js';
export { ALLOWED_TRANSITIONS, isTransitionAllowed } from './domain/order.js';
export {
  sendOrderStatusEmail,
  buildOrderStatusEmail,
  ORDER_STATE_LABELS,
  type OrderStatusNotificationInput,
} from './infrastructure/order-status-mailer.js';
export type {
  OrderEvent,
  OrderEventPublisher,
  OrderRepository,
  OrderServicePort,
  CreateOrderCommand,
} from './domain/ports.js';
export type { Order, OrderItem, OrderItemInput, OrderState, OrderView } from './domain/order.js';

export function createOrderService(pool: pg.Pool): OrderService {
  return new OrderService(new PgOrderRepository(pool), new NoOpOrderEventPublisher());
}
