@bobfrankston/mailx 1.0.171 → 1.0.173

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Mail provider interface — abstraction over IMAP, Gmail API, and Microsoft Graph.
3
+ * Sync code uses this interface; never calls IMAP/REST directly.
4
+ */
5
+ export interface ProviderFolder {
6
+ path: string;
7
+ name: string;
8
+ delimiter: string;
9
+ specialUse: string;
10
+ flags: string[];
11
+ }
12
+ export interface ProviderMessage {
13
+ uid: number;
14
+ messageId: string;
15
+ providerId: string;
16
+ date: Date | null;
17
+ subject: string;
18
+ from: {
19
+ name?: string;
20
+ address?: string;
21
+ }[];
22
+ to: {
23
+ name?: string;
24
+ address?: string;
25
+ }[];
26
+ cc: {
27
+ name?: string;
28
+ address?: string;
29
+ }[];
30
+ seen: boolean;
31
+ flagged: boolean;
32
+ answered: boolean;
33
+ draft: boolean;
34
+ size: number;
35
+ source: string;
36
+ }
37
+ export interface FetchOptions {
38
+ source?: boolean;
39
+ }
40
+ /**
41
+ * A mail provider that can list folders, fetch messages, and perform actions.
42
+ * Implementations: ImapProvider (existing iflow), GmailApiProvider, GraphApiProvider.
43
+ */
44
+ export interface MailProvider {
45
+ /** List all folders/labels */
46
+ listFolders(): Promise<ProviderFolder[]>;
47
+ /** Fetch messages newer than sinceUid (incremental sync) */
48
+ fetchSince(folder: string, sinceUid: number, options?: FetchOptions): Promise<ProviderMessage[]>;
49
+ /** Fetch messages by date range (first sync) */
50
+ fetchByDate(folder: string, since: Date, before: Date, options?: FetchOptions, onChunk?: (msgs: ProviderMessage[]) => void): Promise<ProviderMessage[]>;
51
+ /** Fetch specific messages by UID */
52
+ fetchByUids(folder: string, uids: number[], options?: FetchOptions): Promise<ProviderMessage[]>;
53
+ /** Fetch a single message by UID */
54
+ fetchOne(folder: string, uid: number, options?: FetchOptions): Promise<ProviderMessage | null>;
55
+ /** Get all UIDs in a folder (for reconciliation) */
56
+ getUids(folder: string): Promise<number[]>;
57
+ /** Close/cleanup */
58
+ close(): Promise<void>;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Mail provider interface — abstraction over IMAP, Gmail API, and Microsoft Graph.
3
+ * Sync code uses this interface; never calls IMAP/REST directly.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -58,6 +58,11 @@ export declare class MailxDB {
58
58
  getMessageBodyPath(accountId: string, uid: number): string;
59
59
  updateMessageFlags(accountId: string, uid: number, flags: string[]): void;
60
60
  updateBodyPath(accountId: string, uid: number, bodyPath: string): void;
61
+ /** Get messages without cached bodies (for background prefetch) */
62
+ getMessagesWithoutBody(accountId: string, limit?: number): {
63
+ uid: number;
64
+ folderId: number;
65
+ }[];
61
66
  getHighestUid(accountId: string, folderId: number): number;
62
67
  getOldestDate(accountId: string, folderId: number): number;
63
68
  getMessageCount(accountId: string, folderId: number): number;
@@ -320,6 +320,10 @@ export class MailxDB {
320
320
  updateBodyPath(accountId, uid, bodyPath) {
321
321
  this.db.prepare("UPDATE messages SET body_path = ? WHERE account_id = ? AND uid = ?").run(bodyPath, accountId, uid);
322
322
  }
323
+ /** Get messages without cached bodies (for background prefetch) */
324
+ getMessagesWithoutBody(accountId, limit = 50) {
325
+ return this.db.prepare("SELECT uid, folder_id as folderId FROM messages WHERE account_id = ? AND (body_path IS NULL OR body_path = '') ORDER BY date DESC LIMIT ?").all(accountId, limit);
326
+ }
323
327
  getHighestUid(accountId, folderId) {
324
328
  const r = this.db.prepare("SELECT MAX(uid) as maxUid FROM messages WHERE account_id = ? AND folder_id = ?").get(accountId, folderId);
325
329
  return r?.maxUid || 0;