/** * Storage interface — what the shared sync code needs from a database. * * Two implementations satisfy this interface: * - Desktop: `@bobfrankston/mailx-store` (node:sqlite-backed `MailxDB`) * - Android: `@bobfrankston/mailx-store-web` (sql.js-backed `WebMailxDB`) * * Each adapts its own DB to this interface so the shared sync orchestration * (in `./sync.ts`) doesn't care which platform it's running on. Methods kept * deliberately small — only what sync orchestration actually needs. */ import type { ProviderMessage } from "./types.js"; export interface SyncFolder { id: number; accountId: string; path: string; name: string; specialUse: string; delimiter: string; } export interface SyncStorage { /** All folders for an account. Used to look up folder by id during sync. */ getFolders(accountId: string): SyncFolder[]; /** Highest UID currently cached for a folder. 0 means never synced. */ getHighestUid(accountId: string, folderId: number): number; /** All UIDs currently in the DB for a folder. Used by the reconcile path * to detect server-side deletions. */ getUidsForFolder(accountId: string, folderId: number): number[]; /** Insert-or-update a single message envelope. Returns true if a new row * was inserted, false if it was an update of an existing row. */ upsertProviderMessage(accountId: string, folderId: number, msg: ProviderMessage): boolean; /** Remove a message row + cascade folder counts. */ deleteMessage(accountId: string, uid: number): void; /** Recompute total/unread for a folder (called after batch insert/delete). */ recalcFolderCounts(folderId: number): void; /** Update the on-disk path where the body bytes are stored. Called after * a successful body fetch. */ updateBodyPath(accountId: string, uid: number, bodyPath: string): void; /** Find messages whose body hasn't been cached yet. Used by prefetch. * Returns up to `limit` rows ordered most-recent-first. */ getMessagesWithoutBody(accountId: string, limit: number): { uid: number; folderId: number; }[]; } /** Where message bodies (raw RFC 2822 .eml files or equivalent blobs) live. * Desktop: filesystem under ~/.mailx/mailxstore/. * Android: IndexedDB or local-storage equivalent. */ export interface SyncBodyStore { /** Write body bytes for a message. Returns an opaque path/id that * `updateBodyPath` will store in the DB. */ putMessage(accountId: string, folderId: number, uid: number, raw: Uint8Array): Promise; /** Delete a body — best-effort, may resolve even if missing. */ deleteMessage(accountId: string, folderId: number, uid: number): Promise; } /** Optional event sink so shared sync can emit progress. Both platforms have * some kind of event system; this is a thin shim. Callers can no-op. */ export interface SyncEventSink { folderCountsChanged(accountId: string): void; syncProgress?(accountId: string, phase: string, progress: number): void; } //# sourceMappingURL=storage.d.ts.map