import type { SimulationFunction } from '@x12i/api-simulator'; import { checkoutsForMember, findBook } from '../state/checkout-ledger.js'; /** GET /members/:memberId/checkouts -- a small join across the ledger and catalog. */ export const memberCheckouts: SimulationFunction = ({ request }) => { const memberId = request.params.memberId ?? ''; const items = checkoutsForMember(memberId).map((record) => ({ ...record, title: findBook(record.bookId)?.title ?? 'Unknown title' })); return { status: 200, body: { memberId, count: items.length, items } }; };