import { deleteArticle, planArticleDelete } from "yt-dlp-transcript-common/lib/report/delete"; import { ops, optBool, reqString } from "../_lib"; import { articleDeleteAnswer, articleDeleteOptions } from "../_articleDelete"; export const dynamic = "force-dynamic"; // POST { id: string, force?: boolean, dryRun?: boolean } // -> { ok, applied, plan, removed?, failed? } // // DELETE AN ARTICLE (release 27 follow-up), as `archilyzer reports delete` // does: its directory under transcripts/reports/ (report, video, history, // notes, iterations), each iteration's video project under // settings.generation.projectsRoot, and its staged exports — through // lib/report/delete.ts, under the article registry's lock. `dryRun` answers // the plan (every path with its size, what is kept and why) and writes // nothing. Refused (409, with the plan): a published article, or a site page // naming it with no report of its own — `force` unpublishes it and drops the // page first; a queued or running iteration, force or not. // // There is no undo, and transcripts/ is its own git repo — the only way back // is a commit there. export async function POST(request: Request) { return ops(request, ["id", "force", "dryRun"], async (body) => { const id = reqString(body, "id"); const force = optBool(body, "force") === true; const opts = articleDeleteOptions(force); return articleDeleteAnswer(optBool(body, "dryRun") === true, force, () => planArticleDelete(id, opts), () => deleteArticle(id, opts)); }); }