import { evictClipWindowsAction } from "../../../storage/actions"; import { jobResponse, ops, optBool, optString } from "../_lib"; export const dynamic = "force-dynamic"; // POST { olderThanDays: number, slug?: string, dryRun?: boolean } // -> { ok: true, jobId } // // AN ADAPTER, like every route here: one call to the action the /storage button // posts. `olderThanDays` is required on purpose — there is no sensible default // for a control that deletes, and a route that picked one would be a rule the // UI does not have. // // Eviction is BY AGE. Nothing in the editor can know whether a umtool report // still cites a window, so a caller automating this should say so wherever it // reports the result — see controller/evictClipWindows.ts. export async function POST(request: Request) { return ops(request, ["olderThanDays", "slug", "dryRun"], async (body) => { const raw = body.olderThanDays; const olderThanDays = typeof raw === "number" ? raw : Number.NaN; const slug = optString(body, "slug"); const dryRun = optBool(body, "dryRun"); return jobResponse( await evictClipWindowsAction({ ...(slug ? { slug } : {}), olderThanDays, ...(dryRun ? { dryRun: true } : {}), }), ); }); }