import { BaseConnector } from '../../base/base.connector'; import type { IEmailOptions, IEmailProvider, ISendMessageSuccessResponse, WithPassthrough, EmailSendInput, EmailSendResult, IEmailConnector } from '../../types'; import { ChannelTypeEnum } from '../../types'; import type { MailgunConfig } from './mailgun.config'; export declare class MailgunEmailConnector extends BaseConnector implements IEmailProvider, IEmailConnector { private config; readonly id = "mailgun"; readonly channelType: ChannelTypeEnum.EMAIL; constructor(config: MailgunConfig, fetchImpl?: typeof fetch); /** * Thinwrap-native send. Implements `IEmailConnector`. * Builds either an `application/x-www-form-urlencoded` body (no attachments) * or a `multipart/form-data` body (with attachments), authenticates with * HTTP Basic (`api:`), and POSTs to * `https://api.mailgun.net/v3//messages` (or the EU equivalent when * `region: 'eu'`). Returns `status: 'queued'` — Mailgun's response * is queue acceptance, not delivery confirmation. */ send(input: EmailSendInput): Promise; /** * Build the Mailgun form-field record from Thinwrap's `EmailSendInput`. * Mailgun's wire keys are hand-mapped (locality): `replyTo` → * `h:Reply-To`, custom `headers` → `h:`. `o:tag` is appended later as * a repeated key (URLSearchParams handles repetition; a plain `Record` does * not, so tags are handled at serialization time). */ private buildMailgunFields; /** * Resolve `/v3//messages`. The Basic credentials go to this URL, so * a `baseUrl` override must be https — Mailgun's own hosts * (`api.mailgun.net`, `api.eu.mailgun.net`) are https-only. */ private messagesUrl; /** * Map Mailgun error responses to canonical `ConnectorError` with the * 6-value `ProviderCode` union. Parses `Retry-After`: * parsed seconds embedded in `providerMessage` text; * raw header value on `cause.retryAfter`. No structured `retryAfterSeconds` * field — retry is consumer policy. */ private mapVendorError; sendMessage(options: IEmailOptions, bridgeProviderData?: WithPassthrough>): Promise; /** * Build a `multipart/form-data` body from Thinwrap's `EmailAttachment[]` * . Each attachment becomes a `name="attachment"` part (or * `name="inline"` when `contentId` is set, per Mailgun's cid pattern). */ private buildMultipartBody; /** * Multipart builder for the Novu-compatible `sendMessage()` surface. * Consumes Novu's `IAttachmentOptions` shape (`name`/`mime`/`file`) — kept * separate from `buildMultipartBody()` so the new Thinwrap surface speaks * the post attachment shape exclusively. */ private buildMultipartBodyLegacy; }