import { REPORTS_ROOT } from "./paths"; import { MuteError, isMuted as isMutedRead, muteCount, readMutes as readAt, setMute as setAt } from "./mutes.mjs"; // The app's view of lib/mutes.mjs, typed and bound to REPORTS_ROOT. The logic, // the file format and the rules are there (plain ESM, unit-tested). export type MutesRead = { mutes: Record>; error?: string }; export { MuteError, muteCount }; export async function readMutes(): Promise { return (await readAt(REPORTS_ROOT)) as MutesRead; } export const isMuted = (read: MutesRead, piece: string | null | undefined, kind: string): boolean => isMutedRead(read, piece, kind); export async function setMute(piece: string, kind: string, muted: boolean): Promise<{ piece: string; kind: string; muted: boolean; at: string }> { return (await setAt(REPORTS_ROOT, piece, kind, muted)) as { piece: string; kind: string; muted: boolean; at: string }; }