feat(FN-3764): add manage view with edit modal for CLI printing press plugi

FN-3764 adds a manage view and edit draft modal to the CLI printing press plugin, wiring in draft storage, wizard routes, and plugin view registry integration so users can view and edit their printing press drafts directly from the dashboard. Includes corresponding tests, documentation updates, and

Fusion-Task-Id: FN-3764
This commit is contained in:
Fusion
2026-05-10 15:59:15 -07:00
committed by gsxdsm
parent d7980d5a59
commit 0fb9bb5b91
20 changed files with 646 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
import type { PluginContext, PluginRouteDefinition, PluginRouteResult } from "@fusion/core";
import { createDraftStore } from "../storage/draft-store.js";
import { createDraftStore, NotFoundError } from "../storage/draft-store.js";
import type { ServiceDraft } from "../wizard/types.js";
import { validateDraft } from "../wizard/validation.js";
@@ -45,6 +45,39 @@ export function createCliPrintingPressRoutes(): PluginRouteDefinition[] {
return draft ? ok(draft) : ok({ error: "Draft not found" }, 404);
},
},
{
method: "PUT",
path: "/drafts/:id",
handler: async (req, ctx: PluginContext) => {
const request = asRequest(req);
const draft = request.body as ServiceDraft;
const result = validateDraft(draft);
if (!result.ok) return { status: 400, body: { error: Object.values(result.errors)[0] ?? "Validation failed", errors: result.errors } };
const store = createDraftStore({ rootDir: ctx.taskStore.getRootDir() });
try {
const updated = await store.update(request.params.id, draft);
return ok(updated);
} catch (error) {
if (error instanceof NotFoundError) return ok({ error: "Draft not found" }, 404);
throw error;
}
},
},
{
method: "POST",
path: "/drafts/:id/regenerate",
handler: async (req, ctx: PluginContext) => {
const request = asRequest(req);
const store = createDraftStore({ rootDir: ctx.taskStore.getRootDir() });
try {
const draft = await store.update(request.params.id, { regeneratedAt: new Date().toISOString() });
return ok({ draft, stub: true, message: "Regenerate stub — full generation lands in FN-3765/FN-3767" });
} catch (error) {
if (error instanceof NotFoundError) return ok({ error: "Draft not found" }, 404);
throw error;
}
},
},
{
method: "DELETE",
path: "/drafts/:id",