import { BaseConnector } from '../../base/base.connector'; import type { IEmailOptions, IEmailProvider, ISendMessageSuccessResponse, WithPassthrough, EmailSendInput, EmailSendResult, IEmailConnector } from '../../types'; import { ChannelTypeEnum } from '../../types'; import type { SparkPostConfig } from './sparkpost.config'; export declare class SparkPostEmailConnector extends BaseConnector implements IEmailProvider, IEmailConnector { private config; readonly id = "sparkpost"; readonly channelType: ChannelTypeEnum.EMAIL; constructor(config: SparkPostConfig, fetchImpl?: typeof fetch); /** * Thinwrap-native send. Implements `IEmailConnector`. * Builds the SparkPost `transmissions` JSON body (with nested * `recipients`/`content`/`options` envelopes in snake_case wire shape) and * POSTs to `https://api.sparkpost.com/api/v1/transmissions` (or the EU * regional endpoint). * * Auth: `Authorization: ` — SparkPost is an outlier in NOT using a * `Bearer ` prefix; the raw key is sent verbatim. * * the connector explicitly invokes * `transformKeys(_passthrough.body, CasingEnum.SNAKE_CASE)` so * consumer-supplied camelCase keys (e.g., `campaignId`, `substitutionData`) * land as snake_case in the wire body. * * On 2xx, SparkPost may still report all recipients as rejected via * `results.total_accepted_recipients === 0`; this is surfaced as a * thrown `ConnectorError providerCode: 'invalid_recipient'` so consumers * handle it the same way as a 400-with-bad-recipient from other providers. */ send(input: EmailSendInput): Promise; /** * Resolve the SparkPost endpoint for the current config. Returns the US base * unless `region === 'eu'`. */ private resolveEndpoint; /** * Build the SparkPost wire body from Thinwrap's `EmailSendInput`. Assembles * `recipients[]` (via `buildRecipientsArray`) and `content` (subject, from, * html/text, reply_to, headers, attachments, inline_images). Tags are * mapped to `metadata.tags` as the default convention; consumers can * override via `_passthrough.body.metadata`. */ private buildSparkPostBody; /** * Build SparkPost's `recipients[]` array from * `EmailSendInput.{to,cc,bcc}`. Primary `to` recipients are added without * `header_to`; each cc and bcc recipient is appended as a separate entry * with `address.header_to: ` so the recipient's email client * displays the message as addressed to the primary `to`. */ private buildRecipientsArray; /** * Map SparkPost 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; }