/** * report-store — a durable holding pen for usage-report beacons. * * WHY THIS EXISTS: the hosted `/report` endpoint runs on serverless (Netlify * Functions), whose filesystem is read-only and ephemeral — so it cannot * durably append to `.eddie-brain/activity.json`. Instead, each beacon is * written to a small persistent blob store, and a *scheduled* job later flushes * the store into `activity.json` and commits it (see `eddie-brain activity * flush` and `.github/workflows/eddie-activity.yml`). This is what makes the * loop run on a schedule with no per-product wiring beyond the beacon. * * The store is behind a tiny `BlobBackend` interface so the logic is testable * with an in-memory backend and the Netlify dependency stays optional and * lazily loaded (absent locally, provided automatically on Netlify). */ /** The minimal key/value surface the report store needs from any backend. */ export interface BlobBackend { set(key: string, value: string): Promise; get(key: string): Promise; /** Return all keys currently stored. */ listKeys(): Promise; delete(key: string): Promise; } /** A pending, not-yet-ingested report pulled from the store. */ export interface PendingReport { key: string; receivedAt: string; report: unknown; } /** Options for creating a report store. */ export interface ReportStoreOptions { /** Injectable id factory (deterministic in tests). */ idFactory?: () => string; /** Injectable clock (deterministic in tests). */ now?: () => string; } /** * ReportStore — append beacons, list what's pending, and remove what's been * consumed. Values are stored as a small envelope `{ receivedAt, report }` so * the flush step preserves receipt time even if the report itself lacks one. */ export declare class ReportStore { private backend; private idFactory; private now; constructor(backend: BlobBackend, options?: ReportStoreOptions); /** Persist one raw report. Returns its storage key. */ append(report: unknown): Promise; /** List all pending reports (parsed). Unparseable entries are skipped. */ listPending(): Promise; /** Remove consumed reports by key. */ remove(keys: string[]): Promise; } /** Simple in-memory backend — used by tests and as a safe default. */ export declare class MemoryBlobBackend implements BlobBackend { private map; set(key: string, value: string): Promise; get(key: string): Promise; listKeys(): Promise; delete(key: string): Promise; } export interface NetlifyBackendOptions { /** Blob store name. */ name?: string; /** Netlify site id — required when running OUTSIDE Netlify (e.g. CI flush). */ siteID?: string; /** Netlify auth token — required when running OUTSIDE Netlify. */ token?: string; } /** * Create a Netlify Blobs backend, lazily importing `@netlify/blobs`. Returns * null when the module is unavailable or unconfigured (e.g. a local dev server) * so callers can degrade gracefully. Inside a Netlify Function no credentials * are needed; from CI, pass siteID + token. */ export declare function netlifyBlobBackend(options?: NetlifyBackendOptions): Promise; //# sourceMappingURL=report-store.d.ts.map