// `verdict-review` for umtool's e2e editor stub (release 29 M8): the REAL // controller (controller/reportVerdicts.ts reviewProposal) over the fixture's // article store — what umtool/e2e/fixtures/editor-stub.mjs runs for each // `POST /api/ops/verdict-review`. Test-only; synthetic. // // tsx common/testing/verdicts/reviewStub.ts --articles // (the body on stdin) // // Prints one JSON line: {ok: true, proposal} or {ok: false, status, error}. import path from "node:path"; import { reviewProposal } from "../../controller/reportVerdicts"; import type { Paths } from "../../lib/paths"; async function main() { const at = process.argv.indexOf("--articles"); const articles = at >= 0 ? process.argv[at + 1] : ""; if (!articles) throw Object.assign(new Error("--articles is required"), { status: 500 }); let raw = ""; for await (const chunk of process.stdin) raw += chunk; const body = JSON.parse(raw || "{}") as Record; const paths = { articlesDir: articles, exportIndexDir: path.join(path.dirname(articles), ".export-index") } as Paths; const proposal = await reviewProposal(body, { paths }); process.stdout.write(`${JSON.stringify({ ok: true, proposal })}\n`); } main().catch((e: Error & { status?: number }) => { const status = typeof e.status === "number" ? e.status : e.name === "ArticleRegistryError" ? 409 : 400; process.stdout.write(`${JSON.stringify({ ok: false, status, error: e.message })}\n`); });