/** * RFC 5322 message builder for draft creation. * * Drafts go out as a single `text/html` part carrying the rendered `--body` * markdown. Gmail's composer adopts exactly one part of a draft as its editing * surface and discards the rest, so a message offering only HTML leaves it no * choice — the composer opens in rich text, our markup survives the human's * edits, and Gmail generates the `text/plain` alternative itself on send. * * Both alternatives were tried and rejected against live sends: * * - Single-part `text/plain` (the original bug) drops the composer into * plain-text mode. On send Gmail hard-wraps at ~70 columns with real CRLFs * and ships no HTML alternative, so recipients get ragged columns nothing * can reflow — while the compose window still shows the original unwrapped * paragraphs, hiding the damage until the message is gone. * - `multipart/alternative` (plain + HTML) fixes the wrapping but is a coin * flip: two identically-built drafts behaved differently, one keeping our * rendered markup and one adopting the plain part and delivering the raw * markdown source to the reader — `**bold**` and `[text](url)` and all. * * See specs/commands/gmail-draft.md ("Message structure", "Body rendering"). */ export interface ComposeFields { /** Sender — the authenticated account's address. */ from: string; to: string[]; cc?: string[]; bcc?: string[]; subject: string; /** Markdown source, rendered to the HTML body — unless `plain` is set. */ body: string; /** * Treat `body` as literal text rather than markdown. Still sends a single * `text/html` part (reverting to `text/plain` is the original defect); the * HTML is built structurally instead of through the markdown renderer. */ plain?: boolean; } /** Split a comma-separated recipient flag into trimmed, non-empty addresses. */ export declare function parseRecipients(value: string): string[]; /** * Render the body markdown to an HTML document. * * `breaks: true` is deliberate: email bodies carry meaningful single-line * breaks (signature blocks, addresses, value lists), and markdown's default of * collapsing them into spaces would silently reflow content the author laid * out. The flip side — a pre-wrapped body keeps its wrapping — is why * DRAFT_HELP tells callers not to hard-wrap. */ export declare function renderMarkdown(body: string): string; /** * Render the body as literal text: no markdown, so `*`, `_`, `#` and friends * reach the reader exactly as written. Blank line starts a paragraph, a single * newline is a line break — the same block semantics as the markdown path, so * `--plain` changes how the body is interpreted, not how it is laid out. */ export declare function renderPlainText(body: string): string; /** * Build a base64url-encoded RFC 5322 message suitable for * `users.drafts.create` / `users.messages.send` `raw` fields. */ export declare function buildRawMessage(fields: ComposeFields): string;