import type { ParsedEmail } from "../parse/index.mjs"; /** Contract every inbound adapter implements. Each provider knows how to: * - tell whether a request belongs to it (\`accepts\`), * - optionally verify its signature (\`verify\`), * - turn the request body into a \`ParsedEmail\` (\`parse\`). */ export interface InboundAdapter { readonly name: string; accepts: (request: Request) => boolean; verify?: (request: Request) => Promise | boolean; parse: (request: Request) => Promise; } /** Route handler returned by \`defineInboundHandler\`. Drop it into a Nitro * route, a Cloudflare Worker, a Hono app, or raw \`fetch\` handler. */ export type InboundHandler = (request: Request) => Promise; export interface DefineInboundHandlerOptions { providers: ReadonlyArray; onEmail: (mail: ParsedEmail, context: InboundContext) => void | Promise; onUnknown?: (request: Request) => Promise | Response; onVerificationFailure?: (request: Request, provider: string) => Promise | Response; } export interface InboundContext { provider: string; request: Request; } /** Builds a fetch-style handler that accepts inbound webhooks from any * registered provider and yields a unified \`ParsedEmail\` via \`onEmail\`. * * ```ts * import { defineInboundHandler } from "unemail/inbound" * import sesInbound from "unemail/inbound/ses" * import cfInbound from "unemail/inbound/cloudflare" * * export default defineInboundHandler({ * providers: [sesInbound(), cfInbound()], * onEmail(mail) { console.log(mail.subject) } * }) * ``` */ export declare function defineInboundHandler(options: DefineInboundHandlerOptions): InboundHandler;