/** * Mail provider interface — abstraction over IMAP, Gmail API, and Microsoft Graph. * Sync code uses this interface; never calls IMAP/REST directly. * * SOURCE OF TRUTH: this file is the single canonical definition. The earlier * mailx-imap/providers/types.ts and mailx-store-web/provider-types.ts have * been collapsed into this; both packages now re-export from here. */ export interface ProviderFolder { path: string; name: string; delimiter: string; specialUse: string; flags: string[]; } export interface ProviderMessage { uid: number; messageId: string; providerId: string; date: Date | null; sentDate?: Date; subject: string; from: { name?: string; address?: string; }[]; to: { name?: string; address?: string; }[]; cc: { name?: string; address?: string; }[]; inReplyTo?: string; references?: string[]; seen: boolean; flagged: boolean; answered: boolean; draft: boolean; size: number; source: string; } export interface FetchOptions { source?: boolean; providerId?: string; /** Lower bound for "since" queries — bounds the result set by date so * the default page-count cap doesn't silently truncate a large folder * to the last ~200 messages. */ since?: Date; /** UIDs already present in the local store for this folder. Providers whose * incremental sync re-lists a fixed recent page (Gmail — IDs aren't * monotonic, so it can't use a high-water mark) use this to SKIP fetching * metadata for messages already stored: list IDs (one cheap call), drop the * known ones, fetch only the genuinely-new. Steady state (nothing new) then * costs one list call and zero per-message GETs instead of re-fetching 200 * one-by-one (~40s on mobile → near-instant) (Bob 2026-06-27). */ knownUids?: Set; } /** * A mail provider that can list folders, fetch messages, and perform actions. * Implementations: ImapProvider (existing iflow), GmailApiProvider, GraphApiProvider. */ export interface MailProvider { /** List all folders/labels */ listFolders(): Promise; /** Fetch messages newer than sinceUid (incremental sync) */ fetchSince(folder: string, sinceUid: number, options?: FetchOptions): Promise; /** Fetch messages by date range (first sync) */ fetchByDate(folder: string, since: Date, before: Date, options?: FetchOptions, onChunk?: (msgs: ProviderMessage[]) => void): Promise; /** Fetch specific messages by UID */ fetchByUids(folder: string, uids: number[], options?: FetchOptions): Promise; /** Fetch a single message by UID */ fetchOne(folder: string, uid: number, options?: FetchOptions): Promise; /** Get all UIDs in a folder (for reconciliation) */ getUids(folder: string): Promise; /** Replace the full flag set on a message (idempotent). The provider is * responsible for translating IMAP flags like "\\Seen" / "\\Flagged" to * its native model — e.g. Gmail's UNREAD / STARRED labels. * Optional: IMAP uses the existing STORE path in sync-manager code. */ setFlags?(folder: string, uid: number, flags: string[]): Promise; /** Rename and/or reparent a folder/label. `newParentPath` is the * destination parent (Gmail: parent label path; Outlook: parent Graph id); * omit for a rename-in-place. Optional: IMAP renames via the iflow client's * mailboxRename, not through this interface. */ renameFolder?(folderPath: string, newName: string, newParentPath?: string): Promise; /** Close/cleanup */ close(): Promise; } //# sourceMappingURL=types.d.ts.map