import { NextResponse } from "next/server"; import { REPORT_SCHEDULE_BODY_KEYS, reportScheduleAction, } from "yt-dlp-transcript-common/controller/reportScheduleOps"; import { ops, opsFail } from "../_lib"; import { reportScheduleDeps } from "../_reportSchedule"; export const dynamic = "force-dynamic"; // POST {"action": "list" | "create" | "update" | "pause" | "resume" | // "delete" | "tick-now" | "reset-triage" | "learn" | "unlearn" | // "promote-alias" | "add-spelling", …} // // A recurring report (umtool R5): a LIVING report (one article kept current — // each tick re-fetches the scope and refreshes it), a SERIES (a dated // edition each tick over the window since the last) or a WATCH (umtool R6: no // article until a triage finds something), on a cadence the editor // keeps (its report-schedule lane, held by `pnpm ops lane // {"lane":"report-schedule","held":true}`). // list {id?} -> {schedules | schedule, problems, lane: {held, armed}} // create {shape: living | series | watch, topic, question?, channels, // case?, from?, terms?, regex?, cadence ({kind, at, dow?, days?} // or "weekly mon 06:00"), tz?, article? (living), // autoMakeCurrent? (living), model?, maxUsd?, triageFirst? // (living, series), topics?, threshold? {strong, weak}, // dryRun?} -> {plan, schedule?} // update {id, …} -> {schedule} a new cadence re-plans from now // pause / resume {id} -> {schedule} a resume re-plans from now // delete {id, confirm?} -> {plan} | {deleted} the plan unless confirm // tick-now {id} -> {jobId} one `report-tick` job now (409 while // one is queued or running) // reset-triage {id, k?, confirm?} -> {plan} | {reset} (R6.1) discard the // triage runs (from k on), seen.json and the quiet editions they // covered; the plan unless confirm // learn {id, dryRun?} -> {plan, jobId?} (R6.3) the proposal pass now: // the names it asks about; a `report-draft` job on the triage // model's lane. A create or a change of terms starts one too // (the answer's `learn`) // unlearn {id, spelling} -> {removed, blocked} never learned again // add-spelling {id, spelling, means} -> {added, unblocked} (release 32) // a spelling added by hand: counted in scope, its proving line // found by code — no model; refused when it does not occur // promote-alias {id, spelling, site?, confirm?} -> {plan} | {promoted} // a learned spelling as a search alias (global, or a site's), // through the alias writer; the plan unless confirm // AN ADAPTER: every refusal and write is the controller's // (common/controller/reportScheduleOps.ts). export async function POST(request: Request) { return ops(request, REPORT_SCHEDULE_BODY_KEYS, async (body) => { const out = await reportScheduleAction(body, reportScheduleDeps()); if (!out.ok) return opsFail(out.error, out.status ?? 400); return NextResponse.json(out); }); }