/** What the receiving server recorded about a message's origin. Backs the untrusted-read lock. */ export interface SenderAuth { /** Authentication-Results header values, topmost (the receiving server's) first. */ authenticationResults: string[]; } export interface EmailSummary { id: string; threadId?: string; from: string; to: string[]; subject: string; snippet: string; date: string; labels: string[]; hasAttachments: boolean; /** Absent when the provider could not say, which the lock treats as unauthenticated. */ auth?: SenderAuth; } export interface EmailMessage extends EmailSummary { body: string; /** True when `body` is the HTML part (no text/plain part was available). */ bodyIsHtml?: boolean; cc: string[]; bcc: string[]; replyTo?: string; attachments: AttachmentInfo[]; } export interface EmailThread { id: string; subject: string; messages: EmailMessage[]; } export interface AttachmentInfo { id: string; filename: string; mimeType: string; size: number; } export interface DraftSummary { id: string; messageId?: string; subject: string; to: string[]; snippet: string; updatedAt: string; } export interface UnreadCount { labelId: string; name: string; unread: number; } export interface ExportedMessage { filename: string; data: Buffer; mimeType: string; } /** Resolved outbound attachment, ready to hand to a provider. */ export interface Attachment { filename: string; mimeType: string; data: Buffer; } export interface Label { id: string; name: string; type: "system" | "user"; } export interface SendOptions { /** * Sender address. Must be an address the account is allowed to send as * (a Gmail send-as alias, a JMAP identity). Defaults to the account's * primary address. */ from?: string; cc?: string[]; bcc?: string[]; html?: boolean; replyTo?: string; attachments?: Attachment[]; } export interface ReplyOptions { from?: string; replyAll?: boolean; cc?: string[]; bcc?: string[]; html?: boolean; attachments?: Attachment[]; } export interface ForwardOptions { from?: string; message?: string; html?: boolean; attachments?: Attachment[]; } export interface DraftOptions { from?: string; cc?: string[]; bcc?: string[]; html?: boolean; inReplyTo?: string; attachments?: Attachment[]; } export interface ProviderCapabilities { threads: boolean; filters: boolean; templates: boolean; signatures: boolean; vacation: boolean; unsubscribe: boolean; attachments: boolean; inboxSummary: boolean; } export interface MailProvider { readonly type: string; readonly capabilities: ProviderCapabilities; searchMessages(query: string, maxResults?: number, folder?: string): Promise; findMessageIds(query: string, folder?: string, maxResults?: number): Promise; readMessage(messageId: string): Promise; readThread(threadId: string): Promise; sendMessage(to: string[], subject: string, body: string, options?: SendOptions): Promise; replyToMessage(messageId: string, body: string, options?: ReplyOptions): Promise; forwardMessage(messageId: string, to: string[], options?: ForwardOptions): Promise; createDraft(to: string[], subject: string, body: string, options?: DraftOptions): Promise; trashMessages(messageIds: string[]): Promise; listLabels(): Promise; createLabel(name: string): Promise