import type { EmailDriver, EmailMessage, EmailResult, IdempotencyStore, Middleware, Result, SendStatus } from "./types.mjs"; /** Options accepted by `createEmail()`. Only `driver` is required; the rest * have sensible, zero-dependency defaults. */ export interface CreateEmailOptions { driver: EmailDriver; /** When set, enables idempotency-key deduplication backed by this store. * Defaults to an in-memory TTL store when `idempotency` is `true`. */ idempotency?: boolean | { store?: IdempotencyStore; ttlSeconds?: number; }; /** Abort signal forwarded to drivers via `SendContext.signal`. */ signal?: AbortSignal; } /** Public handle returned by `createEmail()`. Mirrors the unstorage-style * mount API so callers can route by `message.stream`. */ export interface Email { readonly driver: EmailDriver; use: (middleware: Middleware) => Email; mount: (stream: string, driver: EmailDriver) => Email; unmount: (stream: string, dispose?: boolean) => Promise; getMount: (stream?: string) => EmailDriver; getMounts: () => ReadonlyArray<{ stream: string; driver: EmailDriver; }>; isAvailable: (stream?: string) => Promise; send: (msg: EmailMessage) => Promise>; sendBatch: (msgs: ReadonlyArray) => Promise>>; /** Stream the results of `sendBatch` one at a time — useful for * large (5k+) fan-outs where you don't want every `EmailResult` in * memory. Unlike `sendBatch` it never short-circuits on the first * error; each message yields its own Result. */ sendBatchStream: (msgs: ReadonlyArray) => AsyncIterable>; /** Cancel a scheduled send on the active (or mounted) driver. Routes * to `UNSUPPORTED` when the driver's `flags.cancelable` is unset. */ cancel: (id: string, options?: { stream?: string; }) => Promise>; /** Retrieve the state of a previously-sent message. Routes to * `UNSUPPORTED` when the driver's `flags.retrievable` is unset. */ retrieve: (id: string, options?: { stream?: string; }) => Promise>; dispose: () => Promise; } /** Construct an `Email` instance. This is the single entry point — every * transport (SMTP, Resend, SES, Postmark, Workers, …) is a `driver` plug. * * ```ts * const email = createEmail({ driver: resend({ apiKey }) }) * const { data, error } = await email.send({ from, to, subject, text }) * ``` */ export declare function createEmail(options: CreateEmailOptions): Email;