// storage/drift-monitor-store.ts — Drift Monitor persistence (SPEC-348)
// Layout: data/projects/{hash}/drift-monitor.json
import { readJson, writeJson, projectDataDir, hashProjectPath } from './base-store.js';
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
function dataFile(projectPath) {
    const projectId = hashProjectPath(projectPath);
    return `${projectDataDir(projectId)}/drift-monitor.json`;
}
const DEFAULT_DATA = { config: null, rules: [] };
// ---------------------------------------------------------------------------
// Store functions
// ---------------------------------------------------------------------------
async function getDriftMonitorData(projectPath) {
    return readJson(dataFile(projectPath), DEFAULT_DATA);
}
export async function getDriftMonitorConfig(projectPath) {
    const data = await getDriftMonitorData(projectPath);
    return data.config;
}
export async function saveDriftMonitorConfig(projectPath, config) {
    const data = await getDriftMonitorData(projectPath);
    data.config = config;
    await writeJson(dataFile(projectPath), data);
}
export async function getDriftAlertRules(projectPath) {
    const data = await getDriftMonitorData(projectPath);
    return data.rules;
}
export async function saveDriftAlertRules(projectPath, rules) {
    const data = await getDriftMonitorData(projectPath);
    data.rules = rules;
    await writeJson(dataFile(projectPath), data);
}
export async function updateLastReportAt(projectPath, timestamp) {
    const data = await getDriftMonitorData(projectPath);
    data.lastReportAt = timestamp;
    await writeJson(dataFile(projectPath), data);
}
export async function getLastReportAt(projectPath) {
    const data = await getDriftMonitorData(projectPath);
    return data.lastReportAt;
}
//# sourceMappingURL=drift-monitor-store.js.map