import { applyStorage, parseStorage, planStorage } from "@/lib/system/actions"; import { bodyOf, fail, ok } from "../_respond"; export const dynamic = "force-dynamic"; // STORAGE MOVES, from Settings ยท system (P5): `umtool storage move-out | // move-back | deliverables` behind a plan (lib/system/actions.ts). The body // names a project id (or all), never a path. // // POST { action: "move-out" | "move-back", project | all: true, dryRun: true } -> { plan } // POST { action: "deliverables", project, to: "media" | "local", dryRun: true } -> { plan } // the same without dryRun -> { applied, message, job }: a umtool job running // the CLI; a confirm the plan now refuses is 409 with the plan. export async function POST(request: Request) { try { const b = await bodyOf(request); const input = parseStorage(b); if (b.dryRun === true) return ok({ plan: await planStorage(input) }); return ok({ applied: true, ...(await applyStorage(input)) }); } catch (e) { return fail(e); } }