// How the derived fixtures are made from the sweeps (regenerate.ts writes them, // fixtures.test.ts checks the committed files still match). import { readFile } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { sweepToReport } from "../../lib/report/convertSweep"; import { reportToManifest, type PostOf } from "../../lib/report/convertManifest"; import { cuesOf, ORIGIN, POSTS } from "./corpus.mjs"; const HERE = path.dirname(/* turbopackIgnore: true */ fileURLToPath(import.meta.url)); export const SWEEPS = ["basic", "quotes-in-claims", "multi-quote", "posts-only", "paragraphs", "inexact", "two-line", "fragment"] as const; export type SweepName = (typeof SWEEPS)[number]; // The sweeps whose report and manifest are committed. export const DERIVED = ["basic", "posts-only", "paragraphs"] as const satisfies readonly SweepName[]; export const readSweep = (name: SweepName) => readFile(/* turbopackIgnore: true */ path.join(/* turbopackIgnore: true */ HERE, "sweeps", `${name}.md`), "utf8"); export const postOf: PostOf = async (channel, id) => { const p = POSTS.find((x) => x.channelSlug === channel && x.id === id); return p ? { platform: "x", url: `https://x.example/${p.author}/status/${p.id}`, createdAt: `${p.date}T12:00:00Z`, author: p.author } : null; }; export async function convertFixture(name: SweepName) { return sweepToReport(await readSweep(name), { cuesOf, id: `synth-${name}` }); } export async function deriveFixture(name: SweepName) { const { report, problems } = await convertFixture(name); if (problems.length) throw new Error(`${name}: ${JSON.stringify(problems)}`); const m = await reportToManifest(report, { siteOrigin: ORIGIN, postOf, today: "2026-10-13" }); if (!m.ok) throw new Error(`${name}: ${JSON.stringify(m.problems)}`); return { report, manifest: m.manifest }; }