import type { Attachment, EmailAddress } from "../types.mjs"; /** Unified shape every parser and inbound adapter produces. Mirrors the * shape of \`postal-mime\` with the addresses normalized into our own * \`EmailAddress\` struct. */ export interface ParsedEmail { messageId?: string; date?: Date; subject?: string; from?: EmailAddress; to: EmailAddress[]; cc: EmailAddress[]; bcc: EmailAddress[]; replyTo?: EmailAddress; inReplyTo?: string; references: string[]; text?: string; html?: string; headers: Record; attachments: ParsedAttachment[]; } /** Attachment discovered during parsing. \`content\` is the raw bytes. */ export interface ParsedAttachment extends Omit { content: Uint8Array; } export interface ParseEmailOptions { /** Override the parser for tests. Defaults to the `postal-mime` peer. */ parse?: (raw: unknown) => Promise; } /** A subset of \`postal-mime\`'s result shape we actually read. */ interface PostalMimeLike { messageId?: string; date?: string | Date; subject?: string; from?: { address?: string; name?: string; }; to?: Array<{ address?: string; name?: string; }>; cc?: Array<{ address?: string; name?: string; }>; bcc?: Array<{ address?: string; name?: string; }>; replyTo?: Array<{ address?: string; name?: string; }> | { address?: string; name?: string; }; inReplyTo?: string; references?: string | string[]; text?: string; html?: string; headers?: Array<{ key: string; value: string; }> | Record; attachments?: Array<{ filename?: string; mimeType?: string; contentType?: string; content?: Uint8Array | ArrayBuffer | string; contentId?: string; disposition?: string; }>; } /** Parse a raw MIME message into a \`ParsedEmail\`. Works on every runtime * \`postal-mime\` supports (Node, Bun, Deno, browsers, Cloudflare Workers). * * Accepts the same inputs \`postal-mime\`'s \`parse\` does: \`string\`, * \`ArrayBuffer\`, \`Uint8Array\`, \`Blob\`, or a \`ReadableStream\`. */ export declare function parseEmail(raw: unknown, options?: ParseEmailOptions): Promise; export declare function normalizeParsed(mail: PostalMimeLike): ParsedEmail; export {};