/** Public API of the cart module. */
import type pg from 'pg';
import type { InventoryServicePort } from '../inventory/index.js';
import type { PricingServicePort } from '../pricing/index.js';
import type { PromotionServicePort } from '../promotions/index.js';
import { CartService } from './application/cart-service.js';
import { PgCartRepository } from './infrastructure/pg-cart-repository.js';

export { registerCartRoutes, type CartRoutesDeps } from './api/cart.routes.js';
export { CartService } from './application/cart-service.js';
export type { Cart, CartItem, CartItemInput, CartItemView, CartView } from './domain/cart.js';
export type { CartRepository } from './domain/ports.js';

export function createCartService(
  pool: pg.Pool,
  pricing: PricingServicePort,
  inventory: InventoryServicePort,
  promotions?: PromotionServicePort,
): CartService {
  return new CartService(new PgCartRepository(pool), pricing, inventory, promotions);
}
