import { listCases, readCase } from "../research/cases.mjs"; import { REPORTS_ROOT } from "../paths"; // Every research case that reads (R2), for the pieces a board's hand-offs made // (lib/pieces/board.mjs). Cases are few; one that does not read is skipped, // never an error on a piece page or in the pieces graph. SERVER ONLY. export type CaseDoc = { id: string; title: string; handoffs?: { to: string; href: string; at?: string }[] }; export async function readCases(): Promise { const list = (await listCases(REPORTS_ROOT).catch(() => [])) as { id: string; error?: string }[]; const cases = await Promise.all(list.filter((c) => !c.error).map((c) => readCase(REPORTS_ROOT, c.id).catch(() => null))); return cases.filter(Boolean) as CaseDoc[]; }