import { resolveReport } from "@/lib/report/serve.mjs"; import { draftRuns, projectIteration } from "@/lib/articles/projectDraft"; export const dynamic = "force-dynamic"; // A VIDEO PROJECT'S DRAFTS (release 28 M9): the iteration it was made from // (the media tasks are report-draft steps on it; a project that names none // has no "Draft with") and each task's last run, from its `-draft.json`. // A draft is STARTED through /api/articles/generate (the editor's // report-draft), never here: this route reads. // // GET ?project= -> { link: {ok, article, n, status} | {ok: false, why}, runs: {: summary} } export async function GET(request: Request) { const url = new URL(request.url); const r = await resolveReport(url.searchParams.get("project") ?? ""); if ("error" in r) return Response.json({ error: r.error }, { status: r.status }); return Response.json( { link: await projectIteration(r.project.dir), runs: await draftRuns(r.project.dir) }, { headers: { "cache-control": "no-store" } }, ); }