/** Public API of the inventory module. */
import type pg from 'pg';
import { InventoryService } from './application/inventory-service.js';
import { PgInventoryRepository } from './infrastructure/pg-inventory-repository.js';

export { registerInventoryRoutes, type InventoryRoutesDeps } from './api/inventory.routes.js';
export { InventoryService } from './application/inventory-service.js';
export {
  InsufficientReservedStockError,
  InsufficientStockError,
  InvalidStockQuantityError,
} from './domain/errors.js';
export type {
  InventoryRepository,
  InventoryService as InventoryServicePort,
} from './domain/ports.js';
export type { Availability, StockCommand, StockItem, StockState } from './domain/stock.js';
export { DEFAULT_STORE_ID } from './domain/stock.js';

export function createInventoryService(pool: pg.Pool): InventoryService {
  return new InventoryService(new PgInventoryRepository(pool));
}
