// WHERE A REPORT LIVES — the two stores of report directories (release 26, // plans/reports-on-homepage.md, "The model"): // // a SITE's pages transcripts/sites//reports// published by // the site's `pages` list (site.json) // the ARTICLES transcripts/reports// published by // transcripts/reports/index.json (./registry.ts) // // A report directory is the same in both: report.json, its stills/, sources/, // video, history-git/ and notes.json. What differs is where the directories // are, where their staging (prepared media, exports) goes, and how a message // names one — which is all a ReportStore says. Nothing here reads a file: // whether a report is published, who may read it and what it may cite is the // host's (publish/reportHost.ts). import path from "node:path"; import type { Paths } from "../paths"; export type ReportStoreKind = "site" | "articles"; // The id of the article store's staging (`.export-index/articles/`) and of its // prepared-media manifest. A site id may be spelled the same; their staging // dirs differ (`.export-index/sites//`), so they never meet. export const ARTICLES_STORE_ID = "articles"; export type ReportStore = { kind: ReportStoreKind; // The site's id, or ARTICLES_STORE_ID. id: string; // The directory holding the report directories. reportsDir: string; // Staging, never served: `report-media/` and `report-exports/` go under it. stagingDir: string; // How a message names the reports directory, relative to the corpus: // `sites//reports` or `reports`. label: string; }; export function siteReportStore(paths: Pick, siteId: string): ReportStore { return { kind: "site", id: siteId, reportsDir: path.join(paths.sitesDir, siteId, "reports"), stagingDir: path.join(paths.exportSitesIndexDir, siteId), label: `sites/${siteId}/reports`, }; } export function articleReportStore(paths: Pick): ReportStore { return { kind: "articles", id: ARTICLES_STORE_ID, reportsDir: paths.articlesDir, stagingDir: path.join(paths.exportIndexDir, ARTICLES_STORE_ID), label: "reports", }; } // A report's directory, its report.json, and how a message names the file. export function storeReportDir(store: Pick, reportId: string): string { return path.join(store.reportsDir, reportId); } export function storeReportFile(store: Pick, reportId: string): string { return path.join(storeReportDir(store, reportId), "report.json"); } export function storeReportLabel(store: Pick, reportId: string): string { return `${store.label}/${reportId}/report.json`; }