UNPKG

payload-email-ahasend

Version:
62 lines (61 loc) 2 kB
import type { EmailAdapter } from 'payload'; /** * Configuration options for the Ahasend email adapter * @interface AhasendAdapterConfig * @property {string} apiKey - API key for Ahasend service authentication * @property {string} defaultFromAddress - Default sender email address * @property {string} defaultFromName - Default sender name */ export interface AhasendAdapterConfig { apiKey: string; defaultFromAddress: string; defaultFromName: string; } /** * Response types from Ahasend API * @typedef {AhasendError | AhasendSuccess} AhasendResponse */ type AhasendResponse = AhasendError | AhasendSuccess; /** * Error response structure from Ahasend API * @interface AhasendError * @property {string} status - Error status message */ export interface AhasendError { status: string; } /** * Success response structure from Ahasend API * @interface AhasendSuccess * @property {string[]} errors - Array of error messages if any * @property {number} fail_count - Number of failed deliveries * @property {string[]} failed_recipients - List of recipients that failed * @property {number} success_count - Number of successful deliveries */ export interface AhasendSuccess { errors: string[]; fail_count: number; failed_recipients: string[]; success_count: number; } /** * Creates an Ahasend email adapter for Payload CMS * @function ahasendAdapter * @param {AhasendAdapterConfig} config - Configuration for the adapter * @returns {EmailAdapter<AhasendResponse>} - Configured email adapter * @example * // Create and configure the adapter * const emailAdapter = ahasendAdapter({ * apiKey: 'your-ahasend-api-key', * defaultFromAddress: 'noreply@example.com', * defaultFromName: 'Example Company' * }); * * // Use in Payload config * export const config = { * email: emailAdapter(), * // rest of Payload config * }; */ export declare const ahasendAdapter: (config: AhasendAdapterConfig) => EmailAdapter<AhasendResponse>; export {};