import { pipelineView, saveCaseDefinition } from "@/lib/research/pipeline"; import { CasePipelineError } from "yt-dlp-transcript-common/lib/research/casePipeline"; import { fail, ok } from "../../../_respond"; export const dynamic = "force-dynamic"; // A CASE'S PIPELINE (lib/research/pipeline.ts; plans/release-38/research-cases-and-assist.md, lane A), beside its // board. The stages and the rest are ./[op]/route.ts. // GET -> PipelineView (lib/research/pipeline-types.ts): the definition (private names as a count only), each // stage's file and last run, what the privacy gate says now // PUT the definition (pipeline.json): { subjects, scope, eras, groups, readerPrompts, keyDates, status, // privateNames: { note } } -> PipelineView. Private names are never part of it (POST ./private-names). export async function GET(_request: Request, ctx: { params: Promise<{ id: string }> }) { try { const { id } = await ctx.params; return ok(await pipelineView(decodeURIComponent(id))); } catch (e) { return fail(e); } } export async function PUT(request: Request, ctx: { params: Promise<{ id: string }> }) { try { const { id } = await ctx.params; const body = (await request.json().catch(() => null)) as unknown; if (!body || typeof body !== "object" || Array.isArray(body)) throw new CasePipelineError("expected the definition as a JSON object"); await saveCaseDefinition(decodeURIComponent(id), body); return ok(await pipelineView(decodeURIComponent(id))); } catch (e) { return fail(e); } }