ts-mailkit 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -63
- package/dist/core/client.d.ts +35 -40
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/errors.d.ts +3 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/types.d.ts +126 -7
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.cjs +329 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +327 -68
- package/dist/index.js.map +1 -1
- package/dist/renderers/default/default-renderer.d.ts +2 -2
- package/dist/renderers/renderer.interface.d.ts +1 -1
- package/dist/templates/factory.d.ts +1 -1
- package/dist/templates/factory.d.ts.map +1 -1
- package/dist/templates/template-builder.d.ts +36 -0
- package/dist/templates/template-builder.d.ts.map +1 -0
- package/dist/transports/console/console-sender.d.ts +7 -2
- package/dist/transports/console/console-sender.d.ts.map +1 -1
- package/dist/transports/cpaas/cpaas-sender.d.ts +51 -0
- package/dist/transports/cpaas/cpaas-sender.d.ts.map +1 -0
- package/dist/transports/cpaas/types.d.ts +133 -0
- package/dist/transports/cpaas/types.d.ts.map +1 -0
- package/dist/transports/memory/memory-sender.d.ts +26 -6
- package/dist/transports/memory/memory-sender.d.ts.map +1 -1
- package/dist/transports/sender.interface.d.ts +34 -3
- package/dist/transports/sender.interface.d.ts.map +1 -1
- package/package.json +39 -37
- package/dist/transports/zeptomail/types.d.ts +0 -47
- package/dist/transports/zeptomail/types.d.ts.map +0 -1
- package/dist/transports/zeptomail/zeptomail-sender.d.ts +0 -22
- package/dist/transports/zeptomail/zeptomail-sender.d.ts.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/core/types.ts","../src/core/errors.ts","../src/renderers/utils/html-to-plaintext.ts","../src/renderers/default/default-renderer.ts","../src/core/client.ts","../src/transports/zeptomail/zeptomail-sender.ts","../src/transports/memory/memory-sender.ts","../src/transports/console/console-sender.ts","../src/templates/factory.ts"],"sourcesContent":["/**\n * Standard email address representation with optional display name.\n */\nexport interface EmailAddress {\n address: string;\n name?: string;\n}\n\n/**\n * Flexible recipient representation allowing string ('user@example.com'),\n * EmailAddress ({ address: 'user@example.com', name: 'User' }),\n * or legacy/standard object ({ email: 'user@example.com', name: 'User' }).\n */\nexport type Recipient =\n | string\n | EmailAddress\n | { email: string; name?: string };\n\n/**\n * Parses an RFC 5322 formatted address string into an EmailAddress.\n * Supports formats such as:\n * - \"user@example.com\" -> { address: \"user@example.com\" }\n * - \"Sender Name <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n * - \"\\\"Sender Name\\\" <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n */\nexport function parseEmailAddress(input: string): EmailAddress {\n if (!input || typeof input !== 'string') {\n return { address: '' };\n }\n const trimmed = input.trim();\n const match = trimmed.match(/^(?:[\"']?([^\"']+)[\"']?\\s+)?<?([^\\s<>@]+@[^\\s<>@]+)>?$/);\n if (!match) {\n return { address: trimmed };\n }\n return {\n address: match[2].trim(),\n name: match[1]?.trim() || undefined,\n };\n}\n\n/**\n * Normalizes a Recipient value into a standardized EmailAddress.\n */\nexport function normalizeRecipient(recipient: Recipient): EmailAddress {\n if (typeof recipient === 'string') {\n return { address: recipient.trim() };\n }\n if ('email' in recipient) {\n return {\n address: (recipient.email ?? '').trim(),\n name: recipient.name?.trim(),\n };\n }\n return {\n address: (recipient.address ?? '').trim(),\n name: recipient.name?.trim(),\n };\n}\n\n/**\n * Normalizes a single or array of Recipients into an array of EmailAddress.\n */\nexport function normalizeRecipients(\n recipients?: Recipient | Recipient[]\n): EmailAddress[] {\n if (!recipients) return [];\n const list = Array.isArray(recipients) ? recipients : [recipients];\n return list.map(normalizeRecipient).filter((r) => r.address.length > 0);\n}\n\n/**\n * Email attachment representation.\n */\nexport interface EmailAttachment {\n filename: string;\n /**\n * Content can be base64-encoded string, plain text, or binary Buffer/Uint8Array.\n */\n content: string | Uint8Array;\n mimeType?: string;\n contentType?: string;\n cid?: string;\n}\n\n/**\n * Options for sending an email through a transport adapter.\n */\nexport interface SendMailOptions {\n to: Recipient | Recipient[];\n from?: Recipient;\n subject: string;\n html: string;\n text?: string;\n cc?: Recipient | Recipient[];\n bcc?: Recipient | Recipient[];\n replyTo?: Recipient | Recipient[];\n attachments?: EmailAttachment[];\n headers?: Record<string, string>;\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\n/**\n * Result returned by an IEmailSender upon dispatch.\n */\nexport interface SendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n}\n","/**\n * Base error class for all ts-mailkit errors.\n */\nexport class MailKitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'MailKitError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when transport configuration is missing or invalid.\n */\nexport class ConfigurationError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'ConfigurationError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when an email transport fails to dispatch an email.\n */\nexport class TransportError extends MailKitError {\n readonly transportName: string;\n readonly statusCode?: number;\n readonly responseBody?: string;\n readonly cause?: unknown;\n\n constructor(\n message: string,\n options: {\n transportName: string;\n statusCode?: number;\n responseBody?: string;\n cause?: unknown;\n }\n ) {\n super(message);\n this.name = 'TransportError';\n this.transportName = options.transportName;\n this.statusCode = options.statusCode;\n this.responseBody = options.responseBody;\n this.cause = options.cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when template rendering or DTO validation fails.\n */\nexport class TemplateError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = 'TemplateError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Decodes common HTML entities into their plain text equivalents.\n */\nexport function decodeHtmlEntities(text: string): string {\n return text\n .replace(/ /gi, ' ')\n .replace(/&/gi, '&')\n .replace(/</gi, '<')\n .replace(/>/gi, '>')\n .replace(/"/gi, '\"')\n .replace(/'/gi, \"'\")\n .replace(/©/gi, '©')\n .replace(/®/gi, '®')\n .replace(/™/gi, '™');\n}\n\n/**\n * Strips HTML tags and normalizes whitespace into readable plain text.\n * Converts <br>, <p>, and <div> into appropriate line breaks.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return '';\n\n return decodeHtmlEntities(\n html\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<\\/p>/gi, '\\n\\n')\n .replace(/<\\/div>/gi, '\\n')\n .replace(/<\\/h[1-6]>/gi, '\\n\\n')\n .replace(/<[^>]*>/g, '')\n )\n .replace(/[ \\t]+/g, ' ')\n .replace(/\\n\\s*\\n\\s*\\n+/g, '\\n\\n')\n .trim();\n}\n","import type { EmailTemplateDto } from '../../templates/dto/index.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderer.interface.js';\nimport { htmlToPlainText } from '../utils/html-to-plaintext.js';\n\nexport interface DefaultRendererOptions {\n /**\n * Primary brand color for buttons and accents.\n * @default '#4f46e5'\n */\n primaryColor?: string;\n\n /**\n * Font stack used in the HTML wrapper.\n * @default \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\"\n */\n fontFamily?: string;\n\n /**\n * Container maximum width.\n * @default '600px'\n */\n maxWidth?: string;\n\n /**\n * Default logo URL displayed at the top-center of the email if not provided in the DTO.\n * Must be a valid http(s) URL.\n */\n logoUrl?: string;\n}\n\n/**\n * Validates whether a string is a valid HTTP or HTTPS URL.\n */\nexport function isValidHttpUrl(urlString?: string): boolean {\n if (!urlString || typeof urlString !== 'string') return false;\n try {\n const url = new URL(urlString.trim());\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Builds a plain-text fallback string from an email DTO.\n */\nexport function buildPlainText(dto: EmailTemplateDto): string {\n if (dto.noHtmlMessage) {\n return dto.noHtmlMessage;\n }\n\n const divider = '──────────────────────────────';\n const parts: string[] = [];\n\n if (dto.header) {\n parts.push(dto.header, divider);\n }\n\n if (dto.body) {\n parts.push(htmlToPlainText(dto.body));\n }\n\n if (dto.otpCode) {\n parts.push(`Verification Code: ${dto.otpCode}`);\n }\n\n if (dto.actionText && dto.actionUrl) {\n parts.push(`${dto.actionText}: ${dto.actionUrl}`);\n }\n\n if (dto.extraMessage) {\n parts.push(htmlToPlainText(dto.extraMessage));\n }\n\n if (dto.footer) {\n parts.push(`${divider}\\n${htmlToPlainText(dto.footer)}`);\n }\n\n return parts.join('\\n\\n');\n}\n\n/**\n * Builds a responsive, styled HTML email document from an email DTO.\n */\nexport function buildHtml(dto: EmailTemplateDto, options: DefaultRendererOptions = {}): string {\n const primaryColor = options.primaryColor || '#4f46e5';\n const fontFamily =\n options.fontFamily ||\n \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\n const maxWidth = options.maxWidth || '600px';\n\n const parts: string[] = [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n `<meta charset=\"UTF-8\">`,\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">`,\n `<title>${dto.subject}</title>`,\n `</head>`,\n `<body style=\"margin:0;padding:24px 16px;background-color:#f9fafb;font-family:${fontFamily};color:#1f2937;line-height:1.6;\">`,\n `<div style=\"max-width:${maxWidth};margin:0 auto;background-color:#ffffff;padding:32px 28px;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,0.1);border:1px solid #f3f4f6;\">`,\n ];\n\n const logoCandidate = dto.logoUrl ?? options.logoUrl;\n if (logoCandidate && isValidHttpUrl(logoCandidate)) {\n const validLogo = logoCandidate.trim();\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${validLogo}\" alt=\"${dto.fromName || 'Logo'}\" style=\"max-height:48px;max-width:200px;height:auto;width:auto;display:inline-block;border:0;outline:none;text-decoration:none;\" />`,\n `</div>`\n );\n }\n\n if (dto.imageUrl) {\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${dto.imageUrl}\" alt=\"Header\" style=\"max-width:100%;height:auto;border-radius:6px;\" />`,\n `</div>`\n );\n }\n\n if (dto.header) {\n parts.push(\n `<h2 style=\"margin:0 0 16px;font-size:1.5rem;font-weight:700;color:#111827;letter-spacing:-0.025em;\">${dto.header}</h2>`\n );\n }\n\n if (dto.body) {\n parts.push(`<div style=\"margin:0 0 20px;font-size:1rem;color:#374151;\">${dto.body}</div>`);\n }\n\n if (dto.otpCode) {\n parts.push(\n `<div style=\"margin:24px 0;padding:20px;background-color:#f3f4f6;border-radius:8px;text-align:center;\">`,\n ` <span style=\"font-size:2rem;letter-spacing:0.5rem;font-weight:700;color:#111827;font-family:monospace;\">${dto.otpCode}</span>`,\n `</div>`\n );\n }\n\n if (dto.actionUrl && dto.actionText) {\n parts.push(\n `<div style=\"margin:24px 0;text-align:center;\">`,\n ` <a href=\"${dto.actionUrl}\" style=\"display:inline-block;padding:12px 28px;background-color:${primaryColor};color:#ffffff;border-radius:6px;text-decoration:none;font-weight:600;font-size:1rem;text-align:center;box-sizing:border-box;\">${dto.actionText}</a>`,\n `</div>`\n );\n }\n\n if (dto.extraMessage) {\n parts.push(\n `<div style=\"margin:20px 0 0;font-size:0.875rem;color:#6b7280;line-height:1.5;\">${dto.extraMessage}</div>`\n );\n }\n\n if (dto.footer) {\n parts.push(\n `<div style=\"margin-top:32px;padding-top:20px;border-top:1px solid #e5e7eb;font-size:0.75rem;color:#9ca3af;text-align:center;\">${dto.footer}</div>`\n );\n }\n\n parts.push(`</div>`, `</body>`, `</html>`);\n return parts.join('\\n');\n}\n\n/**\n * Default HTML and plain-text email renderer for ts-mailkit.\n */\nexport class DefaultEmailRenderer implements IEmailRenderer {\n private readonly options: DefaultRendererOptions;\n\n constructor(options: DefaultRendererOptions = {}) {\n this.options = options;\n }\n\n render(dto: EmailTemplateDto): RenderedEmail {\n return {\n html: buildHtml(dto, this.options),\n text: buildPlainText(dto),\n };\n }\n}\n","import type { IEmailSender } from '../transports/sender.interface.js';\nimport type { IEmailRenderer, RenderedEmail } from '../renderers/renderer.interface.js';\nimport { DefaultEmailRenderer } from '../renderers/default/default-renderer.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\nimport type { EmailTemplateDto } from '../templates/dto/index.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type Recipient,\n type SendMailOptions,\n type SendResult,\n} from './types.js';\nimport { ConfigurationError } from './errors.js';\n\nexport interface SendTemplateOptions {\n /**\n * One or more recipient email addresses.\n */\n to: Recipient | Recipient[];\n /**\n * Templated email DTO to render and send.\n */\n template: EmailTemplateDto;\n /**\n * Optional recipient display name (used when `to` is a plain string).\n */\n toName?: string;\n /**\n * Optional sender display name override for this specific email.\n */\n fromName?: string;\n /**\n * Optional sender email address override.\n */\n from?: Recipient;\n /**\n * Optional CC recipients.\n */\n cc?: Recipient | Recipient[];\n /**\n * Optional BCC recipients.\n */\n bcc?: Recipient | Recipient[];\n /**\n * Optional Reply-To recipients.\n */\n replyTo?: Recipient | Recipient[];\n /**\n * Optional file attachments.\n */\n attachments?: SendMailOptions['attachments'];\n /**\n * Optional custom headers.\n */\n headers?: Record<string, string>;\n /**\n * Optional tags for tracking.\n */\n tags?: string[];\n /**\n * Optional metadata.\n */\n metadata?: Record<string, string>;\n}\n\nexport interface MailKitOptions {\n /**\n * The transport adapter used to dispatch emails (e.g. ZeptoMailHttpSender, MemoryEmailSender).\n */\n transport: IEmailSender;\n /**\n * Custom renderer implementation. Defaults to DefaultEmailRenderer.\n */\n renderer?: IEmailRenderer;\n /**\n * Default sender address or Recipient.\n */\n defaultFrom?: Recipient;\n /**\n * Default brand or application name.\n */\n defaultBrandName?: string;\n /**\n * Optional asynchronous or synchronous resolver to dynamically resolve brand/tenant name.\n * Useful for multitenant applications.\n */\n brandNameResolver?: () => Promise<string> | string;\n}\n\n/**\n * Main email client and orchestration service for ts-mailkit.\n */\nexport class MailKit {\n private readonly transport: IEmailSender;\n private readonly renderer: IEmailRenderer;\n private readonly defaultFrom?: Recipient;\n private readonly defaultBrandName?: string;\n private readonly brandNameResolver?: () => Promise<string> | string;\n\n constructor(options: MailKitOptions) {\n if (!options.transport) {\n throw new ConfigurationError('MailKit: A transport adapter (IEmailSender) is required.');\n }\n this.transport = options.transport;\n this.renderer = options.renderer ?? new DefaultEmailRenderer();\n this.defaultFrom = options.defaultFrom;\n this.defaultBrandName = options.defaultBrandName;\n this.brandNameResolver = options.brandNameResolver;\n }\n\n /**\n * Returns the underlying transport instance.\n */\n getTransport(): IEmailSender {\n return this.transport;\n }\n\n /**\n * Renders an email DTO to HTML and plain text without dispatching.\n */\n async render(template: EmailTemplateDto): Promise<RenderedEmail> {\n return await this.renderer.render(template);\n }\n\n /**\n * Sends an email using a strongly-typed template DTO.\n *\n * Example:\n * ```ts\n * await mailer.send({\n * to: 'user@example.com',\n * template: myDto,\n * });\n * ```\n */\n async send(options: SendTemplateOptions): Promise<SendResult> {\n const template = options.template;\n const recipientName = options.toName ?? template.userName;\n\n // Resolve fromName: explicit option > template.fromName > brand resolver > defaultBrandName\n let resolvedFromName = options.fromName ?? template.fromName;\n if (!resolvedFromName && this.brandNameResolver) {\n resolvedFromName = await this.brandNameResolver();\n }\n if (!resolvedFromName) {\n resolvedFromName = this.defaultBrandName;\n }\n\n // Render template DTO\n const rendered = await this.renderer.render(template);\n const plaintextBody = template.noHtmlMessage ?? rendered.text;\n\n // Format recipients\n let toRecipients: Recipient | Recipient[];\n if (typeof options.to === 'string' && recipientName) {\n toRecipients = { address: options.to, name: recipientName };\n } else {\n toRecipients = options.to;\n }\n\n // Resolve From address\n let from = options.from ?? this.defaultFrom;\n if (resolvedFromName && from) {\n const normalizedFrom = normalizeRecipient(from);\n from = { address: normalizedFrom.address, name: resolvedFromName };\n }\n\n return await this.sendRaw({\n to: toRecipients,\n from,\n subject: template.subject,\n html: rendered.html,\n text: plaintextBody,\n cc: options.cc,\n bcc: options.bcc,\n replyTo: options.replyTo,\n attachments: options.attachments,\n headers: options.headers,\n tags: options.tags,\n metadata: options.metadata,\n });\n }\n\n /**\n * Dispatches a raw, pre-rendered email directly through the transport.\n * If `options.text` is omitted, plain text is automatically derived from `options.html`.\n */\n async sendRaw(options: SendMailOptions): Promise<SendResult> {\n const from = options.from ?? this.defaultFrom;\n const text = options.text ?? (options.html ? htmlToPlainText(options.html) : undefined);\n return await this.transport.send({\n ...options,\n from,\n text,\n });\n }\n}\n\n/**\n * Convenience factory to create a MailKit client instance.\n */\nexport function createMailKit(options: MailKitOptions): MailKit {\n return new MailKit(options);\n}\n","import { ConfigurationError, TransportError } from '../../core/errors.js';\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type SendMailOptions,\n type SendResult,\n} from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\nimport type {\n ZeptoMailHttpConfig,\n ZeptoMailSendPayload,\n ZeptoMailAttachmentPayload,\n} from './types.js';\n\n/**\n * ZeptoMail (Zoho Mail transactional email HTTP API) transport adapter.\n *\n * Designed for zero dependencies and universal edge compatibility (Node.js, Bun, Deno, Cloudflare Workers)\n * by utilizing the standard global `fetch` API.\n */\nexport class ZeptoMailHttpSender implements IEmailSender {\n readonly name = 'zeptomail';\n\n private readonly apiUrl: string;\n private readonly authHeader: string;\n private readonly defaultFrom: { address: string; name?: string };\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: ZeptoMailHttpConfig) {\n if (!config.apiToken || typeof config.apiToken !== 'string') {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing or invalid apiToken.');\n }\n if (!config.from) {\n throw new ConfigurationError('ZeptoMailHttpSender: Missing required default from address.');\n }\n\n const host = (config.apiHost || 'api.zeptomail.com').replace(/^https?:\\/\\//, '').replace(/\\/+$/, '');\n this.apiUrl = `https://${host}/v1.1/email`;\n\n // Normalize auth token header. In ZeptoMail, if the user already included \"Zoho-enczapikey \", use as is; otherwise format standard header.\n const token = config.apiToken.trim();\n this.authHeader = token.startsWith('Zoho-') ? token : `Zoho-enczapikey ${token}`;\n\n this.defaultFrom = normalizeRecipient(config.from);\n if (!this.defaultFrom.address) {\n throw new ConfigurationError('ZeptoMailHttpSender: Configured from address must not be empty.');\n }\n\n const fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== 'function') {\n throw new ConfigurationError(\n 'ZeptoMailHttpSender: No global fetch implementation found. Pass a custom fetch to ZeptoMailHttpConfig if running on Node < 18.'\n );\n }\n // Bind: detached fetch throws \"Illegal invocation\" on strict-this runtimes (undici/workerd).\n this.fetchImpl = fetchImpl.bind(globalThis);\n }\n\n /**\n * Dispatches an email using Zoho ZeptoMail API v1.1.\n */\n async send(options: SendMailOptions): Promise<SendResult> {\n const toRecipients = normalizeRecipients(options.to);\n if (toRecipients.length === 0) {\n throw new TransportError('ZeptoMailHttpSender: At least one recipient (to) must be specified.', {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: ZeptoMailSendPayload = {\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: toRecipients.map((r) => ({\n email_address: {\n address: r.address,\n name: r.name || '',\n },\n })),\n subject: options.subject,\n htmlbody: options.html,\n textbody: options.text,\n };\n\n if (options.cc) {\n const ccList = normalizeRecipients(options.cc);\n if (ccList.length > 0) {\n payload.cc = ccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.bcc) {\n const bccList = normalizeRecipients(options.bcc);\n if (bccList.length > 0) {\n payload.bcc = bccList.map((r) => ({\n email_address: { address: r.address, name: r.name || '' },\n }));\n }\n }\n\n if (options.replyTo) {\n const replyToList = normalizeRecipients(options.replyTo);\n if (replyToList.length > 0) {\n payload.reply_to = replyToList.map((r) => ({\n address: r.address,\n name: r.name,\n }));\n }\n }\n\n if (options.attachments && options.attachments.length > 0) {\n payload.attachments = options.attachments.map((att): ZeptoMailAttachmentPayload => {\n let contentBase64: string;\n if (typeof att.content === 'string') {\n contentBase64 = att.content;\n } else {\n // Buffer or Uint8Array\n if (typeof Buffer !== 'undefined') {\n contentBase64 = Buffer.from(att.content).toString('base64');\n } else {\n // Browser / Edge fallback for Uint8Array\n let binary = '';\n const bytes = new Uint8Array(att.content);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n contentBase64 = btoa(binary);\n }\n }\n\n return {\n name: att.filename,\n content: contentBase64,\n mime_type: att.mimeType || att.contentType || 'application/octet-stream',\n cid: att.cid,\n };\n });\n }\n\n let response: Response;\n try {\n response = await this.fetchImpl(this.apiUrl, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: this.authHeader,\n },\n body: JSON.stringify(payload),\n });\n } catch (err) {\n throw new TransportError(`ZeptoMailHttpSender: Network request failed: ${err instanceof Error ? err.message : String(err)}`, {\n transportName: this.name,\n cause: err,\n });\n }\n\n const responseText = await response.text();\n let responseData: any;\n try {\n responseData = responseText ? JSON.parse(responseText) : {};\n } catch {\n responseData = { raw: responseText };\n }\n\n if (!response.ok) {\n const errorMessage =\n responseData?.error?.message ||\n responseData?.message ||\n `HTTP ${response.status}: ${responseText || response.statusText}`;\n\n throw new TransportError(`ZeptoMailHttpSender: Failed to send email - ${errorMessage}`, {\n transportName: this.name,\n statusCode: response.status,\n responseBody: responseText,\n });\n }\n\n // Extract message ID from standard ZeptoMail v1.1 response structure:\n // { data: [ { message_id: \"...\" } ] }\n const messageId = responseData?.data?.[0]?.message_id;\n\n return {\n success: true,\n messageId,\n response: responseData,\n };\n }\n}\n","import type { SendMailOptions, SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\n/**\n * In-memory email sender for automated testing, local development, and CI environments.\n * Captures all dispatched emails and provides inspection methods.\n */\nexport class MemoryEmailSender implements IEmailSender {\n readonly name = 'memory';\n\n private sentMails: SendMailOptions[] = [];\n private nextId = 1;\n\n async send(options: SendMailOptions): Promise<SendResult> {\n this.sentMails.push({ ...options });\n const messageId = `mem-${this.nextId++}-${Date.now()}`;\n return {\n success: true,\n messageId,\n response: { id: messageId },\n };\n }\n\n /**\n * Returns a copy of all emails sent through this transport instance.\n */\n getSentMails(): SendMailOptions[] {\n return [...this.sentMails];\n }\n\n /**\n * Returns the most recent email sent, or undefined if no emails have been sent.\n */\n getLastMail(): SendMailOptions | undefined {\n return this.sentMails.length > 0\n ? { ...this.sentMails[this.sentMails.length - 1] }\n : undefined;\n }\n\n /**\n * Clears all recorded sent emails.\n */\n clear(): void {\n this.sentMails = [];\n }\n\n /**\n * Returns the total count of sent emails.\n */\n count(): number {\n return this.sentMails.length;\n }\n}\n","import { normalizeRecipients, type SendMailOptions, type SendResult } from '../../core/types.js';\nimport type { IEmailSender } from '../sender.interface.js';\n\nexport interface ConsoleEmailSenderOptions {\n /**\n * Log level or custom log printer. Defaults to `console.log`.\n */\n logger?: (message: string) => void;\n /**\n * Whether to include the full HTML body in console output.\n * Defaults to false (prints plain text or a summary).\n */\n includeHtml?: boolean;\n}\n\n/**\n * Console logger transport that prints dispatched emails to stdout/stderr.\n * Ideal for development and debugging.\n */\nexport class ConsoleEmailSender implements IEmailSender {\n readonly name = 'console';\n\n private readonly log: (message: string) => void;\n private readonly includeHtml: boolean;\n private nextId = 1;\n\n constructor(options: ConsoleEmailSenderOptions = {}) {\n this.log = options.logger ?? console.log;\n this.includeHtml = options.includeHtml ?? false;\n }\n\n async send(options: SendMailOptions): Promise<SendResult> {\n const to = normalizeRecipients(options.to).map((r) => r.name ? `${r.name} <${r.address}>` : r.address).join(', ');\n const from = options.from ? JSON.stringify(options.from) : '(default)';\n const messageId = `console-${this.nextId++}-${Date.now()}`;\n\n const separator = '─'.repeat(60);\n const lines = [\n `\\n┌${separator}┐`,\n `│ [ts-mailkit:console] DISPATCHED EMAIL (${messageId})`,\n `├${separator}┤`,\n `│ From: ${from}`,\n `│ To: ${to}`,\n `│ Subject: ${options.subject}`,\n `├${separator}┤`,\n ];\n\n if (options.text) {\n lines.push('│ Text Body:');\n for (const line of options.text.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n if (this.includeHtml && options.html) {\n lines.push('│ HTML Body:');\n for (const line of options.html.split('\\n')) {\n lines.push(`│ ${line}`);\n }\n }\n\n lines.push(`└${separator}┘\\n`);\n\n this.log(lines.join('\\n'));\n\n return {\n success: true,\n messageId,\n response: { logged: true },\n };\n }\n}\n","import type { EmailTemplateDto, EmailVerificationParams, MagicLinkParams, NewsletterParams, PasswordResetParams, SimpleMessageParams, TwoFactorParams,} from './dto/index.js';\nimport { htmlToPlainText } from '../renderers/utils/html-to-plaintext.js';\n\nexport interface BrandingConfig {\n /**\n * Default brand, application, or company name.\n * @default 'Application'\n */\n brandName?: string;\n\n /**\n * Optional custom security / disclaimer advisory message.\n */\n securityMessage?: string;\n\n /**\n * Optional custom footer generator or string.\n */\n footer?: string | ((brandName: string) => string);\n\n /**\n * Optional default logo URL to display top-center in templated emails.\n */\n logoUrl?: string;\n}\n\nconst DEFAULT_SECURITY_MESSAGE =\n 'If you did not request this, please ignore this email or contact support if you have concerns.';\n\nfunction defaultFooter(brandName: string): string {\n return `© ${new Date().getFullYear()} ${brandName}. All rights reserved.`;\n}\n\n/**\n * Factory for creating pre-populated, type-safe email template DTOs.\n */\nexport class EmailTemplateFactory {\n private readonly defaultBrandName: string;\n private readonly defaultSecurityMessage: string;\n private readonly footerResolver: (brandName: string) => string;\n private readonly defaultLogoUrl?: string;\n\n constructor(config: BrandingConfig = {}) {\n this.defaultBrandName = config.brandName || 'Application';\n this.defaultSecurityMessage = config.securityMessage || DEFAULT_SECURITY_MESSAGE;\n this.defaultLogoUrl = config.logoUrl;\n if (typeof config.footer === 'function') {\n this.footerResolver = config.footer;\n } else if (typeof config.footer === 'string') {\n const fixedFooter = config.footer;\n this.footerResolver = () => fixedFooter;\n } else {\n this.footerResolver = defaultFooter;\n }\n }\n\n private resolveBrand(override?: string): string {\n return override || this.defaultBrandName;\n }\n\n private buildFooter(brandName: string): string {\n return this.footerResolver(brandName);\n }\n\n /**\n * Welcome / email-verification email sent after registration.\n */\n createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n const { username, verificationUrl, otp, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;\n return {\n subject: 'Verify Your Email Address',\n header: `Welcome to ${brand}!`,\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: verificationUrl,\n actionText: 'Verify Email',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n `\\n\\nYour verification code is: ${otp}\\n\\nAlternatively, verify here:\\n${verificationUrl}`,\n };\n }\n\n /**\n * Password-reset email with an optional OTP code and action link.\n */\n createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n const { username, resetUrl, otp = '', brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;\n const plainTextOtp = otp ? `\\n\\nYour OTP code is: ${otp}` : '';\n return {\n subject: 'Password Reset Request',\n header: 'Reset Your Password',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp || undefined,\n actionUrl: resetUrl,\n actionText: 'Reset Password',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n plainTextOtp +\n `\\n\\nAlternatively, you can use the following link to reset your password:\\n${resetUrl}`,\n };\n }\n\n /**\n * Generic plain message email (no action button, no OTP).\n */\n createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n const { subject, header, body, brandName } = params;\n const brand = this.resolveBrand(brandName);\n return {\n subject,\n header,\n body,\n logoUrl: this.defaultLogoUrl,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body),\n };\n }\n\n /**\n * Newsletter / announcement email with an optional hero image and CTA button.\n */\n createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n const { subject, header, body, imageUrl, actionUrl, actionText, brandName, logoUrl } = params;\n const brand = this.resolveBrand(brandName);\n let noHtmlMessage = htmlToPlainText(body);\n if (actionUrl) {\n noHtmlMessage += `\\n\\n${actionText || 'Learn more'}: ${actionUrl}`;\n }\n return {\n subject,\n header,\n body,\n logoUrl: logoUrl || this.defaultLogoUrl,\n imageUrl,\n actionUrl,\n actionText,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage,\n };\n }\n\n /**\n * Two-factor authentication email with OTP code and optional magic link.\n */\n create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n const { username, otp, magicLink = '', brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;\n const plainLink = magicLink ? `\\n\\nAlternatively, verify here:\\n${magicLink}` : '';\n return {\n subject: 'Your Login Verification Code',\n header: 'Two-Factor Authentication',\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: magicLink || undefined,\n actionText: magicLink ? 'Verify Login' : undefined,\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nYour verification code is: ${otp}` + plainLink,\n };\n }\n\n /**\n * Magic link sign-in email (no OTP, button only).\n */\n createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n const { username, magicLink, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;\n return {\n subject: 'Your Magic Link',\n header: `Sign In to ${brand}`,\n body,\n logoUrl: this.defaultLogoUrl,\n actionUrl: magicLink,\n actionText: 'Sign In',\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nSign in here:\\n${magicLink}`,\n };\n }\n\n // ─── Default Static Instance ──────────────────────────────────────────────\n private static _defaultInstance?: EmailTemplateFactory;\n\n private static get defaultInstance(): EmailTemplateFactory {\n if (!this._defaultInstance) {\n this._defaultInstance = new EmailTemplateFactory();\n }\n return this._defaultInstance;\n }\n\n static createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n return this.defaultInstance.createEmailVerification(params);\n }\n\n static createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n return this.defaultInstance.createPasswordReset(params);\n }\n\n static createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n return this.defaultInstance.createSimpleMessage(params);\n }\n\n static createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n return this.defaultInstance.createNewsLetter(params);\n }\n\n static create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n return this.defaultInstance.create2FAEmail(params);\n }\n\n static createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n return this.defaultInstance.createMagicLinkEmail(params);\n }\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,kBAAkB,OAA6B;CAC7D,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO,EAAE,SAAS,GAAG;CAEvB,MAAM,UAAU,MAAM,KAAK;CAC3B,MAAM,QAAQ,QAAQ,MAAM,uDAAuD;CACnF,IAAI,CAAC,OACH,OAAO,EAAE,SAAS,QAAQ;CAE5B,OAAO;EACL,SAAS,MAAM,EAAE,CAAC,KAAK;EACvB,MAAM,MAAM,EAAE,EAAE,KAAK,KAAK;CAC5B;AACF;;;;AAKA,SAAgB,mBAAmB,WAAoC;CACrE,IAAI,OAAO,cAAc,UACvB,OAAO,EAAE,SAAS,UAAU,KAAK,EAAE;CAErC,IAAI,WAAW,WACb,OAAO;EACL,UAAU,UAA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js","names":[],"sources":["../src/core/types.ts","../src/core/errors.ts","../src/renderers/utils/html-to-plaintext.ts","../src/renderers/default/default-renderer.ts","../src/core/client.ts","../src/transports/cpaas/cpaas-sender.ts","../src/transports/memory/memory-sender.ts","../src/transports/console/console-sender.ts","../src/templates/factory.ts","../src/templates/template-builder.ts"],"sourcesContent":["import type { EmailTemplateDto } from \"../templates/dto/index.js\";\n\n/**\n * Standard email address representation with optional display name.\n */\nexport interface EmailAddress {\n address: string;\n name?: string;\n}\n\n/**\n * A recipient with optional provider-side merge variables.\n */\nexport interface BulkRecipient extends EmailAddress {\n /**\n * Provider-side merge variables (e.g. Zoho CPaaS `merge_info`).\n */\n mergeInfo?: Record<string, string>;\n}\n\n/**\n * Flexible recipient representation allowing string ('user@example.com'),\n * EmailAddress ({ address: 'user@example.com', name: 'User' }),\n * or legacy/standard object ({ email: 'user@example.com', name: 'User' }).\n */\nexport type Recipient = string | EmailAddress | { email: string; name?: string };\n\n/**\n * Parses an RFC 5322 formatted address string into an EmailAddress.\n * Supports formats such as:\n * - \"user@example.com\" -> { address: \"user@example.com\" }\n * - \"Sender Name <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n * - \"\\\"Sender Name\\\" <sender@example.com>\" -> { name: \"Sender Name\", address: \"sender@example.com\" }\n */\nexport function parseEmailAddress(input: string): EmailAddress {\n if (!input || typeof input !== \"string\") {\n return { address: \"\" };\n }\n const trimmed = input.trim();\n const match = trimmed.match(/^(?:[\"']?([^\"']+)[\"']?\\s+)?<?([^\\s<>@]+@[^\\s<>@]+)>?$/);\n if (!match) {\n return { address: trimmed };\n }\n return {\n address: match[2].trim(),\n name: match[1]?.trim() || undefined,\n };\n}\n\n/**\n * Normalizes a Recipient value into a standardized EmailAddress.\n */\nexport function normalizeRecipient(recipient: Recipient): EmailAddress {\n if (typeof recipient === \"string\") {\n return { address: recipient.trim() };\n }\n if (\"email\" in recipient) {\n return {\n address: (recipient.email ?? \"\").trim(),\n name: recipient.name?.trim(),\n };\n }\n return {\n address: (recipient.address ?? \"\").trim(),\n name: recipient.name?.trim(),\n };\n}\n\n/**\n * Normalizes a single or array of Recipients into an array of EmailAddress.\n */\nexport function normalizeRecipients(recipients?: Recipient | Recipient[]): EmailAddress[] {\n if (!recipients) return [];\n const list = Array.isArray(recipients) ? recipients : [recipients];\n return list.map(normalizeRecipient).filter((r) => r.address.length > 0);\n}\n\n/**\n * Email attachment representation.\n */\nexport interface EmailAttachment {\n filename: string;\n /**\n * Content can be base64-encoded string, plain text, or binary Buffer/Uint8Array.\n */\n content: string | Uint8Array;\n mimeType?: string;\n contentType?: string;\n cid?: string;\n}\n\n/**\n * Common sender and recipient addressing options.\n */\nexport interface MailAddressOptions {\n /**\n * Optional sender address override.\n */\n from?: Recipient;\n /**\n * Optional CC recipients.\n */\n cc?: Recipient | Recipient[];\n /**\n * Optional BCC recipients.\n */\n bcc?: Recipient | Recipient[];\n /**\n * Optional Reply-To recipients.\n */\n replyTo?: Recipient | Recipient[];\n /**\n * Optional file attachments.\n */\n attachments?: EmailAttachment[];\n}\n\n/**\n * Common custom header, tag, and metadata options.\n */\nexport interface MailMetadataOptions {\n /**\n * Optional custom headers.\n */\n headers?: Record<string, string>;\n /**\n * Optional tags for tracking.\n */\n tags?: string[];\n /**\n * Optional metadata.\n */\n metadata?: Record<string, string>;\n}\n\n/**\n * Common provider tracking and reference options.\n */\nexport interface TrackingOptions {\n /**\n * Enable or disable click tracking.\n */\n trackClicks?: boolean;\n /**\n * Enable or disable open tracking.\n */\n trackOpens?: boolean;\n /**\n * Verified bounce (Return-Path) address.\n */\n bounceAddress?: string;\n /**\n * Custom reference string to identify the email in your system.\n */\n clientReference?: string;\n}\n\n/**\n * Options for sending an email through a transport adapter.\n */\nexport interface SendMailOptions extends MailAddressOptions, MailMetadataOptions {\n to: Recipient | Recipient[];\n subject: string;\n html: string;\n text?: string;\n}\n\n/**\n * Transport-level batch of a single raw email content to many recipients.\n *\n * The provider delivers an individual copy to each recipient, so recipients\n * are not exposed to one another.\n */\nexport type BulkSendOptions = SendMailOptions & TrackingOptions;\n\n/**\n * Options for sending a single email using a provider-side template.\n */\nexport interface KnownTemplateSendOptions extends MailAddressOptions, TrackingOptions {\n /**\n * Provider-side template identifier (e.g. Zoho `template_key`).\n */\n templateId: string;\n /**\n * Recipient email address.\n */\n to: Recipient;\n /**\n * Template variable substitutions.\n */\n mergeInfo?: Record<string, string>;\n}\n\n/**\n * Options for sending a batch of emails using a provider-side template.\n *\n * Each recipient may carry its own `mergeInfo` so the provider can\n * personalize the template per recipient.\n */\nexport interface BulkKnownTemplateSendOptions extends MailAddressOptions, TrackingOptions {\n /**\n * Provider-side template identifier (e.g. Zoho `template_key`).\n */\n templateId: string;\n /**\n * Recipients, each with optional per-recipient merge variables.\n */\n to: BulkRecipient[];\n}\n\n/**\n * Client-level options for sending a bulk email using the in-built template DTO.\n */\nexport interface SendBulkMailOptions\n extends MailAddressOptions, MailMetadataOptions, TrackingOptions {\n /**\n * Templated email DTO to render and send to every recipient.\n */\n template: EmailTemplateDto;\n /**\n * One or more recipient email addresses.\n */\n to: Recipient | Recipient[];\n}\n\n/**\n * Result returned by an IEmailSender upon dispatch.\n */\nexport interface SendResult {\n success: boolean;\n messageId?: string;\n /** Raw provider response (e.g. Zoho CPaaS JSON body). */\n rawResponse?: unknown;\n}\n","/**\n * Base error class for all ts-mailkit errors.\n */\nexport class MailKitError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"MailKitError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when transport configuration is missing or invalid.\n */\nexport class ConfigurationError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigurationError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when an email transport fails to dispatch an email.\n */\nexport class TransportError extends MailKitError {\n readonly transportName: string;\n readonly statusCode?: number;\n readonly responseBody?: string;\n /** Parsed raw provider response, when available. */\n readonly rawResponse?: unknown;\n readonly cause?: unknown;\n\n constructor(\n message: string,\n options: {\n transportName: string;\n statusCode?: number;\n responseBody?: string;\n rawResponse?: unknown;\n cause?: unknown;\n },\n ) {\n super(message);\n this.name = \"TransportError\";\n this.transportName = options.transportName;\n this.statusCode = options.statusCode;\n this.responseBody = options.responseBody;\n this.rawResponse = options.rawResponse;\n this.cause = options.cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when template rendering or DTO validation fails.\n */\nexport class TemplateError extends MailKitError {\n constructor(message: string) {\n super(message);\n this.name = \"TemplateError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Decodes common HTML entities into their plain text equivalents.\n */\nexport function decodeHtmlEntities(text: string): string {\n return text\n .replace(/ /gi, \" \")\n .replace(/&/gi, \"&\")\n .replace(/</gi, \"<\")\n .replace(/>/gi, \">\")\n .replace(/"/gi, '\"')\n .replace(/'/gi, \"'\")\n .replace(/©/gi, \"©\")\n .replace(/®/gi, \"®\")\n .replace(/™/gi, \"™\");\n}\n\n/**\n * Strips HTML tags and normalizes whitespace into readable plain text.\n * Converts <br>, <p>, and <div> into appropriate line breaks.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return \"\";\n\n return decodeHtmlEntities(\n html\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<\\/p>/gi, \"\\n\\n\")\n .replace(/<\\/div>/gi, \"\\n\")\n .replace(/<\\/h[1-6]>/gi, \"\\n\\n\")\n .replace(/<[^>]*>/g, \"\"),\n )\n .replace(/[ \\t]+/g, \" \")\n .replace(/\\n\\s*\\n\\s*\\n+/g, \"\\n\\n\")\n .trim();\n}\n","import type { EmailTemplateDto } from \"../../templates/dto/index.js\";\nimport type { IEmailRenderer, RenderedEmail } from \"../renderer.interface.js\";\nimport { htmlToPlainText } from \"../utils/html-to-plaintext.js\";\n\nexport interface DefaultRendererOptions {\n /**\n * Primary brand color for buttons and accents.\n * @default '#4f46e5'\n */\n primaryColor?: string;\n\n /**\n * Font stack used in the HTML wrapper.\n * @default \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\"\n */\n fontFamily?: string;\n\n /**\n * Container maximum width.\n * @default '600px'\n */\n maxWidth?: string;\n\n /**\n * Default logo URL displayed at the top-center of the email if not provided in the DTO.\n * Must be a valid http(s) URL.\n */\n logoUrl?: string;\n}\n\n/**\n * Validates whether a string is a valid HTTP or HTTPS URL.\n */\nexport function isValidHttpUrl(urlString?: string): boolean {\n if (!urlString || typeof urlString !== \"string\") return false;\n try {\n const url = new URL(urlString.trim());\n return (url.protocol === \"http:\" || url.protocol === \"https:\") && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Builds a plain-text fallback string from an email DTO.\n */\nexport function buildPlainText(dto: EmailTemplateDto): string {\n if (dto.noHtmlMessage) {\n return dto.noHtmlMessage;\n }\n\n const divider = \"──────────────────────────────\";\n const parts: string[] = [];\n\n if (dto.header) {\n parts.push(dto.header, divider);\n }\n\n if (dto.body) {\n parts.push(htmlToPlainText(dto.body));\n }\n\n if (dto.otpCode) {\n parts.push(`Verification Code: ${dto.otpCode}`);\n }\n\n if (dto.actionText && dto.actionUrl) {\n parts.push(`${dto.actionText}: ${dto.actionUrl}`);\n }\n\n if (dto.extraMessage) {\n parts.push(htmlToPlainText(dto.extraMessage));\n }\n\n if (dto.footer) {\n parts.push(`${divider}\\n${htmlToPlainText(dto.footer)}`);\n }\n\n return parts.join(\"\\n\\n\");\n}\n\n/**\n * Builds a responsive, styled HTML email document from an email DTO.\n */\nexport function buildHtml(dto: EmailTemplateDto, options: DefaultRendererOptions = {}): string {\n const primaryColor = options.primaryColor || \"#4f46e5\";\n const fontFamily =\n options.fontFamily ||\n \"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif\";\n const maxWidth = options.maxWidth || \"600px\";\n\n const parts: string[] = [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n `<meta charset=\"UTF-8\">`,\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">`,\n `<title>${dto.subject}</title>`,\n `</head>`,\n `<body style=\"margin:0;padding:24px 16px;background-color:#f9fafb;font-family:${fontFamily};color:#1f2937;line-height:1.6;\">`,\n `<div style=\"max-width:${maxWidth};margin:0 auto;background-color:#ffffff;padding:32px 28px;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,0.1);border:1px solid #f3f4f6;\">`,\n ];\n\n const logoCandidate = dto.logoUrl ?? options.logoUrl;\n if (logoCandidate && isValidHttpUrl(logoCandidate)) {\n const validLogo = logoCandidate.trim();\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${validLogo}\" alt=\"${dto.fromName || \"Logo\"}\" style=\"max-height:48px;max-width:200px;height:auto;width:auto;display:inline-block;border:0;outline:none;text-decoration:none;\" />`,\n `</div>`,\n );\n }\n\n if (dto.imageUrl) {\n parts.push(\n `<div style=\"margin-bottom:24px;text-align:center;\">`,\n ` <img src=\"${dto.imageUrl}\" alt=\"Header\" style=\"max-width:100%;height:auto;border-radius:6px;\" />`,\n `</div>`,\n );\n }\n\n if (dto.header) {\n parts.push(\n `<h2 style=\"margin:0 0 16px;font-size:1.5rem;font-weight:700;color:#111827;letter-spacing:-0.025em;\">${dto.header}</h2>`,\n );\n }\n\n if (dto.body) {\n parts.push(`<div style=\"margin:0 0 20px;font-size:1rem;color:#374151;\">${dto.body}</div>`);\n }\n\n if (dto.otpCode) {\n parts.push(\n `<div style=\"margin:24px 0;padding:20px;background-color:#f3f4f6;border-radius:8px;text-align:center;\">`,\n ` <span style=\"font-size:2rem;letter-spacing:0.5rem;font-weight:700;color:#111827;font-family:monospace;\">${dto.otpCode}</span>`,\n `</div>`,\n );\n }\n\n if (dto.actionUrl && dto.actionText) {\n parts.push(\n `<div style=\"margin:24px 0;text-align:center;\">`,\n ` <a href=\"${dto.actionUrl}\" style=\"display:inline-block;padding:12px 28px;background-color:${primaryColor};color:#ffffff;border-radius:6px;text-decoration:none;font-weight:600;font-size:1rem;text-align:center;box-sizing:border-box;\">${dto.actionText}</a>`,\n `</div>`,\n );\n }\n\n if (dto.extraMessage) {\n parts.push(\n `<div style=\"margin:20px 0 0;font-size:0.875rem;color:#6b7280;line-height:1.5;\">${dto.extraMessage}</div>`,\n );\n }\n\n if (dto.footer) {\n parts.push(\n `<div style=\"margin-top:32px;padding-top:20px;border-top:1px solid #e5e7eb;font-size:0.75rem;color:#9ca3af;text-align:center;\">${dto.footer}</div>`,\n );\n }\n\n parts.push(`</div>`, `</body>`, `</html>`);\n return parts.join(\"\\n\");\n}\n\n/**\n * Default HTML and plain-text email renderer for ts-mailkit.\n */\nexport class DefaultEmailRenderer implements IEmailRenderer {\n private readonly options: DefaultRendererOptions;\n\n constructor(options: DefaultRendererOptions = {}) {\n this.options = options;\n }\n\n render(dto: EmailTemplateDto): RenderedEmail {\n return {\n html: buildHtml(dto, this.options),\n text: buildPlainText(dto),\n };\n }\n}\n","import type { IEmailSender } from \"../transports/sender.interface.js\";\nimport type { IEmailRenderer, RenderedEmail } from \"../renderers/renderer.interface.js\";\nimport { DefaultEmailRenderer } from \"../renderers/default/default-renderer.js\";\nimport { htmlToPlainText } from \"../renderers/utils/html-to-plaintext.js\";\nimport type { EmailTemplateDto } from \"../templates/dto/index.js\";\nimport {\n normalizeRecipient,\n type BulkKnownTemplateSendOptions,\n type KnownTemplateSendOptions,\n type MailAddressOptions,\n type MailMetadataOptions,\n type Recipient,\n type SendBulkMailOptions,\n type SendMailOptions,\n type SendResult,\n} from \"./types.js\";\nimport { ConfigurationError } from \"./errors.js\";\n\nexport interface SendTemplateOptions extends MailAddressOptions, MailMetadataOptions {\n /**\n * One or more recipient email addresses.\n */\n to: Recipient | Recipient[];\n /**\n * Templated email DTO to render and send.\n */\n template: EmailTemplateDto;\n /**\n * Optional recipient display name (used when `to` is a plain string).\n */\n toName?: string;\n /**\n * Optional sender display name override for this specific email.\n */\n fromName?: string;\n}\n\nexport interface MailKitOptions {\n /**\n * The transport adapter used to dispatch emails (e.g. CpaasHttpSender, MemoryEmailSender).\n */\n transport: IEmailSender;\n /**\n * Custom renderer implementation. Defaults to DefaultEmailRenderer.\n */\n renderer?: IEmailRenderer;\n /**\n * Default sender address or Recipient.\n */\n defaultFrom?: Recipient;\n /**\n * Default brand or application name.\n */\n defaultBrandName?: string;\n /**\n * Optional asynchronous or synchronous resolver to dynamically resolve brand/tenant name.\n * Useful for multitenant applications.\n */\n brandNameResolver?: () => Promise<string> | string;\n}\n\n/**\n * Main email client and orchestration service for ts-mailkit.\n */\nexport class MailKit {\n private readonly transport: IEmailSender;\n private readonly renderer: IEmailRenderer;\n private readonly defaultFrom?: Recipient;\n private readonly defaultBrandName?: string;\n private readonly brandNameResolver?: () => Promise<string> | string;\n\n constructor(options: MailKitOptions) {\n if (!options.transport) {\n throw new ConfigurationError(\"MailKit: A transport adapter (IEmailSender) is required.\");\n }\n this.transport = options.transport;\n this.renderer = options.renderer ?? new DefaultEmailRenderer();\n this.defaultFrom = options.defaultFrom;\n this.defaultBrandName = options.defaultBrandName;\n this.brandNameResolver = options.brandNameResolver;\n }\n\n /**\n * Returns the underlying transport instance.\n */\n getTransport(): IEmailSender {\n return this.transport;\n }\n\n /**\n * Renders an email DTO to HTML and plain text without dispatching.\n */\n async render(template: EmailTemplateDto): Promise<RenderedEmail> {\n return await this.renderer.render(template);\n }\n\n /**\n * Sends an email using a strongly-typed template DTO.\n *\n * Example:\n * ```ts\n * await mailer.sendMail({\n * to: 'user@example.com',\n * template: myDto,\n * });\n * ```\n */\n async sendMail(options: SendTemplateOptions): Promise<SendResult> {\n const template = options.template;\n const recipientName = options.toName ?? template.userName;\n const resolvedFromName = await this.resolveFromName(template, options.fromName);\n\n // Render template DTO\n const rendered = await this.renderer.render(template);\n const plaintextBody = template.noHtmlMessage ?? rendered.text;\n\n // Format recipients\n let toRecipients: Recipient | Recipient[];\n if (typeof options.to === \"string\" && recipientName) {\n toRecipients = { address: options.to, name: recipientName };\n } else {\n toRecipients = options.to;\n }\n\n // Resolve From address\n const from = this.applyFromName(options.from ?? this.defaultFrom, resolvedFromName);\n\n return await this.sendRaw({\n to: toRecipients,\n from,\n subject: template.subject,\n html: rendered.html,\n text: plaintextBody,\n cc: options.cc,\n bcc: options.bcc,\n replyTo: options.replyTo,\n attachments: options.attachments,\n headers: options.headers,\n tags: options.tags,\n metadata: options.metadata,\n });\n }\n\n /**\n * Sends a bulk email using a strongly-typed template DTO.\n *\n * The transport delivers an individual copy to each recipient, so\n * recipients are not exposed to one another. Per-recipient personalization\n * is available via {@link sendBulkKnownTemplate}.\n *\n * Example:\n * ```ts\n * await mailer.sendBulkMail({\n * to: ['a@example.com', 'b@example.com'],\n * template: myDto,\n * });\n * ```\n */\n async sendBulkMail(options: SendBulkMailOptions): Promise<SendResult> {\n const transport = this.transport;\n if (typeof transport.sendBulk !== \"function\") {\n throw new ConfigurationError(\n \"MailKit: The configured transport does not support bulk sending (sendBulk).\",\n );\n }\n\n const template = options.template;\n const resolvedFromName = await this.resolveFromName(template);\n\n const rendered = await this.renderer.render(template);\n const plaintextBody = template.noHtmlMessage ?? rendered.text;\n const from = this.applyFromName(options.from ?? this.defaultFrom, resolvedFromName);\n\n return await transport.sendBulk({\n to: options.to,\n from,\n subject: template.subject,\n html: rendered.html,\n text: plaintextBody,\n cc: options.cc,\n bcc: options.bcc,\n replyTo: options.replyTo,\n attachments: options.attachments,\n headers: options.headers,\n tags: options.tags,\n metadata: options.metadata,\n trackClicks: options.trackClicks,\n trackOpens: options.trackOpens,\n bounceAddress: options.bounceAddress,\n clientReference: options.clientReference,\n });\n }\n\n /**\n * Sends a single email using a provider-side template.\n */\n async sendKnownTemplate(options: KnownTemplateSendOptions): Promise<SendResult> {\n const transport = this.transport;\n if (typeof transport.sendKnownTemplate !== \"function\") {\n throw new ConfigurationError(\n \"MailKit: The configured transport does not support template sending (sendKnownTemplate).\",\n );\n }\n\n return await transport.sendKnownTemplate({\n ...options,\n from: options.from ?? this.defaultFrom,\n });\n }\n\n /**\n * Sends a bulk email using a provider-side template with optional\n * per-recipient merge data.\n */\n async sendBulkKnownTemplate(options: BulkKnownTemplateSendOptions): Promise<SendResult> {\n const transport = this.transport;\n if (typeof transport.sendBulkKnownTemplate !== \"function\") {\n throw new ConfigurationError(\n \"MailKit: The configured transport does not support bulk template sending (sendBulkKnownTemplate).\",\n );\n }\n\n return await transport.sendBulkKnownTemplate({\n ...options,\n from: options.from ?? this.defaultFrom,\n });\n }\n\n private async resolveFromName(\n template: EmailTemplateDto,\n explicitFromName?: string,\n ): Promise<string | undefined> {\n let resolved = explicitFromName ?? template.fromName;\n if (!resolved && this.brandNameResolver) {\n resolved = await this.brandNameResolver();\n }\n if (!resolved) {\n resolved = this.defaultBrandName;\n }\n return resolved;\n }\n\n private applyFromName(\n from: Recipient | undefined,\n fromName: string | undefined,\n ): Recipient | undefined {\n if (fromName && from) {\n const normalizedFrom = normalizeRecipient(from);\n return { address: normalizedFrom.address, name: fromName };\n }\n return from;\n }\n\n /**\n * Dispatches a raw, pre-rendered email directly through the transport.\n * If `options.text` is omitted, plain text is automatically derived from `options.html`.\n */\n async sendRaw(options: SendMailOptions): Promise<SendResult> {\n const from = options.from ?? this.defaultFrom;\n const text = options.text ?? (options.html ? htmlToPlainText(options.html) : undefined);\n return await this.transport.send({\n ...options,\n from,\n text,\n });\n }\n}\n\n/**\n * Convenience factory to create a MailKit client instance.\n */\nexport function createMailKit(options: MailKitOptions): MailKit {\n return new MailKit(options);\n}\n","import { ConfigurationError, TransportError } from \"../../core/errors.js\";\nimport {\n normalizeRecipient,\n normalizeRecipients,\n type EmailAttachment,\n type Recipient,\n type SendMailOptions,\n type SendResult,\n} from \"../../core/types.js\";\nimport type {\n BulkKnownTemplateSendOptions,\n BulkSendOptions,\n KnownTemplateSendOptions,\n} from \"../../core/types.js\";\nimport type { IEmailSender } from \"../sender.interface.js\";\nimport type {\n CpaasAddressObject,\n CpaasAttachmentPayload,\n CpaasBatchSendPayload,\n CpaasBatchTemplateSendPayload,\n CpaasHttpConfig,\n CpaasRecipientWrapper,\n CpaasSendPayload,\n CpaasTemplateSendPayload,\n} from \"./types.js\";\n\n/** Fields shared by every CPaaS request payload. */\ninterface CommonPayloadFields {\n cc?: CpaasRecipientWrapper[];\n bcc?: CpaasRecipientWrapper[];\n reply_to?: CpaasAddressObject[];\n attachments?: CpaasAttachmentPayload[];\n track_clicks?: boolean;\n track_opens?: boolean;\n bounce_address?: string;\n client_reference?: string;\n}\n\n/** Options accepted by {@link CpaasHttpSender.applyCommon}. */\ninterface CommonOptions {\n cc?: Recipient | Recipient[];\n bcc?: Recipient | Recipient[];\n replyTo?: Recipient | Recipient[];\n attachments?: EmailAttachment[];\n trackClicks?: boolean;\n trackOpens?: boolean;\n bounceAddress?: string;\n clientReference?: string;\n}\n\n/**\n * Zoho CPaaS transactional email HTTP transport adapter.\n *\n * Uses the standard global `fetch` API for zero-dependency, universal edge\n * compatibility (Node.js, Bun, Deno, Cloudflare Workers).\n *\n * Supports:\n * - `send` — single raw email (`POST /v1.1/email`)\n * - `sendBulk` — batch raw email (`POST /v1.1/email/batch`)\n * - `sendKnownTemplate` — single template email (`POST /v1.1/email/template`)\n * - `sendBulkKnownTemplate` — batch template email (`POST /v1.1/email/template/batch`)\n */\nexport class CpaasHttpSender implements IEmailSender {\n readonly name = \"cpaas\";\n\n private readonly apiBase: string;\n private readonly authHeader: string;\n private readonly defaultFrom: { address: string; name?: string };\n private readonly preferTemplateAlias: boolean;\n private readonly fetchImpl: typeof fetch;\n\n constructor(config: CpaasHttpConfig) {\n if (!config.apiToken || typeof config.apiToken !== \"string\") {\n throw new ConfigurationError(\"CpaasHttpSender: Missing or invalid apiToken.\");\n }\n if (!config.from) {\n throw new ConfigurationError(\"CpaasHttpSender: Missing required default from address.\");\n }\n\n const host = (config.apiHost || \"cpaas.zoho.com\")\n .replace(/^https?:\\/\\//, \"\")\n .replace(/\\/+$/, \"\");\n this.apiBase = `https://${host}/v1.1`;\n\n // Normalize auth token header. If the caller already included \"Zoho-\", use as is.\n const token = config.apiToken.trim();\n this.authHeader = token.startsWith(\"Zoho-\") ? token : `Zoho-enczapikey ${token}`;\n\n this.defaultFrom = normalizeRecipient(config.from);\n if (!this.defaultFrom.address) {\n throw new ConfigurationError(\"CpaasHttpSender: Configured from address must not be empty.\");\n }\n\n this.preferTemplateAlias = config.preferTemplateAlias ?? false;\n\n const fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") {\n throw new ConfigurationError(\n \"CpaasHttpSender: No global fetch implementation found. Pass a custom fetch to CpaasHttpConfig if running on Node < 18.\",\n );\n }\n // Bind: detached fetch throws \"Illegal invocation\" on strict-this runtimes (undici/workerd).\n this.fetchImpl = fetchImpl.bind(globalThis);\n }\n\n /**\n * Dispatches a single raw email using Zoho CPaaS API.\n */\n async send(options: SendMailOptions): Promise<SendResult> {\n const payload = this.buildSendPayload(options);\n return await this.post(`${this.apiBase}/email`, payload);\n }\n\n /**\n * Dispatches a batch of a single raw email content to many recipients.\n * The provider delivers an individual copy to each recipient.\n */\n async sendBulk(options: BulkSendOptions): Promise<SendResult> {\n const payload: CpaasBatchSendPayload = this.buildSendPayload(options);\n return await this.post(`${this.apiBase}/email/batch`, payload);\n }\n\n /**\n * Dispatches a single email using a provider-side template.\n */\n async sendKnownTemplate(options: KnownTemplateSendOptions): Promise<SendResult> {\n const payload = this.buildTemplatePayload(options);\n return await this.post(`${this.apiBase}/email/template`, payload);\n }\n\n /**\n * Dispatches a batch of emails using a provider-side template, with\n * optional per-recipient merge data.\n */\n async sendBulkKnownTemplate(options: BulkKnownTemplateSendOptions): Promise<SendResult> {\n const payload = this.buildBatchTemplatePayload(options);\n return await this.post(`${this.apiBase}/email/template/batch`, payload);\n }\n\n // ─── Payload builders ──────────────────────────────────────────────────────\n\n private buildSendPayload(options: SendMailOptions): CpaasSendPayload {\n const toRecipients = normalizeRecipients(options.to);\n if (toRecipients.length === 0) {\n throw new TransportError(\"CpaasHttpSender: At least one recipient (to) must be specified.\", {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: CpaasSendPayload = {\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: toRecipients.map((r) => ({\n email_address: { address: r.address, name: r.name || \"\" },\n })),\n subject: options.subject,\n htmlbody: options.html,\n textbody: options.text,\n };\n\n this.applyCommon(payload, options);\n return payload;\n }\n\n private buildTemplatePayload(options: KnownTemplateSendOptions): CpaasTemplateSendPayload {\n const toRecipients = normalizeRecipients(options.to);\n if (toRecipients.length === 0) {\n throw new TransportError(\"CpaasHttpSender: At least one recipient (to) must be specified.\", {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: CpaasTemplateSendPayload = {\n ...this.templateRef(options.templateId),\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: toRecipients.map((r) => ({\n email_address: { address: r.address, name: r.name || \"\" },\n })),\n };\n\n if (options.mergeInfo) {\n payload.merge_info = options.mergeInfo;\n }\n\n this.applyCommon(payload, options);\n return payload;\n }\n\n private buildBatchTemplatePayload(\n options: BulkKnownTemplateSendOptions,\n ): CpaasBatchTemplateSendPayload {\n if (!options.to || options.to.length === 0) {\n throw new TransportError(\"CpaasHttpSender: At least one recipient (to) must be specified.\", {\n transportName: this.name,\n });\n }\n\n const resolvedFrom = options.from ? normalizeRecipient(options.from) : this.defaultFrom;\n\n const payload: CpaasBatchTemplateSendPayload = {\n ...this.templateRef(options.templateId),\n from: {\n address: resolvedFrom.address,\n name: resolvedFrom.name,\n },\n to: options.to.map((r) => ({\n email_address: { address: r.address, name: r.name || \"\" },\n ...(r.mergeInfo ? { merge_info: r.mergeInfo } : {}),\n })),\n };\n\n this.applyCommon(payload, options);\n return payload;\n }\n\n private templateRef(templateId: string): { template_key?: string; template_alias?: string } {\n return this.preferTemplateAlias ? { template_alias: templateId } : { template_key: templateId };\n }\n\n private applyCommon(payload: CommonPayloadFields, options: CommonOptions): void {\n if (options.cc) {\n const ccList = normalizeRecipients(options.cc);\n if (ccList.length > 0) {\n payload.cc = ccList.map((r) => ({\n email_address: { address: r.address, name: r.name || \"\" },\n }));\n }\n }\n\n if (options.bcc) {\n const bccList = normalizeRecipients(options.bcc);\n if (bccList.length > 0) {\n payload.bcc = bccList.map((r) => ({\n email_address: { address: r.address, name: r.name || \"\" },\n }));\n }\n }\n\n if (options.replyTo) {\n const replyToList = normalizeRecipients(options.replyTo);\n if (replyToList.length > 0) {\n payload.reply_to = replyToList.map((r) => ({\n address: r.address,\n name: r.name,\n }));\n }\n }\n\n if (options.attachments && options.attachments.length > 0) {\n payload.attachments = options.attachments.map((att) => this.toAttachmentPayload(att));\n }\n\n if (options.trackClicks !== undefined) payload.track_clicks = options.trackClicks;\n if (options.trackOpens !== undefined) payload.track_opens = options.trackOpens;\n if (options.bounceAddress !== undefined) payload.bounce_address = options.bounceAddress;\n if (options.clientReference !== undefined) payload.client_reference = options.clientReference;\n }\n\n private toAttachmentPayload(att: EmailAttachment): CpaasAttachmentPayload {\n let contentBase64: string;\n if (typeof att.content === \"string\") {\n contentBase64 = att.content;\n } else if (typeof Buffer !== \"undefined\") {\n contentBase64 = Buffer.from(att.content).toString(\"base64\");\n } else {\n // Browser / Edge fallback for Uint8Array\n let binary = \"\";\n const bytes = new Uint8Array(att.content);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n contentBase64 = btoa(binary);\n }\n\n return {\n name: att.filename,\n content: contentBase64,\n mime_type: att.mimeType || att.contentType || \"application/octet-stream\",\n cid: att.cid,\n };\n }\n\n // ─── HTTP ──────────────────────────────────────────────────────────────────\n\n private async post(url: string, payload: unknown): Promise<SendResult> {\n let response: Response;\n try {\n response = await this.fetchImpl(url, {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n Authorization: this.authHeader,\n },\n body: JSON.stringify(payload),\n });\n } catch (err) {\n throw new TransportError(\n `CpaasHttpSender: Network request failed: ${err instanceof Error ? err.message : String(err)}`,\n {\n transportName: this.name,\n cause: err,\n },\n );\n }\n\n const responseText = await response.text();\n let responseData: any;\n try {\n responseData = responseText ? JSON.parse(responseText) : {};\n } catch {\n responseData = { raw: responseText };\n }\n\n if (!response.ok) {\n const errorMessage =\n responseData?.data?.message ||\n responseData?.error?.message ||\n responseData?.message ||\n `HTTP ${response.status}: ${responseText || response.statusText}`;\n\n throw new TransportError(`CpaasHttpSender: Failed to send email - ${errorMessage}`, {\n transportName: this.name,\n statusCode: response.status,\n responseBody: responseText,\n rawResponse: responseData,\n });\n }\n\n // Single-send responses carry `message_id`; batch/template responses carry\n // `code`/`message` entries.\n const messageId = responseData?.data?.[0]?.message_id;\n\n return {\n success: true,\n messageId,\n rawResponse: responseData,\n };\n }\n}\n","import type { SendMailOptions, SendResult } from \"../../core/types.js\";\nimport type {\n BulkKnownTemplateSendOptions,\n BulkSendOptions,\n KnownTemplateSendOptions,\n} from \"../../core/types.js\";\nimport type { IEmailSender } from \"../sender.interface.js\";\n\n/**\n * In-memory email sender for automated testing, local development, and CI environments.\n * Captures all dispatched emails and provides inspection methods.\n */\nexport class MemoryEmailSender implements IEmailSender {\n readonly name = \"memory\";\n\n private sentMails: SendMailOptions[] = [];\n private sentBulkMails: BulkSendOptions[] = [];\n private sentTemplateMails: KnownTemplateSendOptions[] = [];\n private sentBulkTemplateMails: BulkKnownTemplateSendOptions[] = [];\n private nextId = 1;\n\n private result(prefix?: string): SendResult {\n const id = this.nextId++;\n const messageId = prefix ? `mem-${prefix}-${id}-${Date.now()}` : `mem-${id}-${Date.now()}`;\n const rawResponse = { id: messageId };\n return {\n success: true,\n messageId,\n rawResponse,\n };\n }\n\n async send(options: SendMailOptions): Promise<SendResult> {\n this.sentMails.push({ ...options });\n return this.result();\n }\n\n async sendBulk(options: BulkSendOptions): Promise<SendResult> {\n this.sentBulkMails.push({ ...options });\n return this.result(\"bulk\");\n }\n\n async sendKnownTemplate(options: KnownTemplateSendOptions): Promise<SendResult> {\n this.sentTemplateMails.push({ ...options });\n return this.result(\"tpl\");\n }\n\n async sendBulkKnownTemplate(options: BulkKnownTemplateSendOptions): Promise<SendResult> {\n this.sentBulkTemplateMails.push({ ...options });\n return this.result(\"bulk-tpl\");\n }\n\n /**\n * Returns a copy of all single emails sent through this transport instance.\n */\n getSentMails(): SendMailOptions[] {\n return [...this.sentMails];\n }\n\n /**\n * Returns the most recent single email sent, or undefined if none have been sent.\n */\n getLastMail(): SendMailOptions | undefined {\n return this.sentMails.length > 0 ? { ...this.sentMails[this.sentMails.length - 1] } : undefined;\n }\n\n /**\n * Returns a copy of all bulk emails sent through this transport instance.\n */\n getSentBulkMails(): BulkSendOptions[] {\n return [...this.sentBulkMails];\n }\n\n /**\n * Returns a copy of all single template emails sent through this transport instance.\n */\n getSentTemplateMails(): KnownTemplateSendOptions[] {\n return [...this.sentTemplateMails];\n }\n\n /**\n * Returns a copy of all bulk template emails sent through this transport instance.\n */\n getSentBulkTemplateMails(): BulkKnownTemplateSendOptions[] {\n return [...this.sentBulkTemplateMails];\n }\n\n /**\n * Clears all recorded emails.\n */\n clear(): void {\n this.sentMails = [];\n this.sentBulkMails = [];\n this.sentTemplateMails = [];\n this.sentBulkTemplateMails = [];\n }\n\n /**\n * Returns the total count of single emails sent.\n */\n count(): number {\n return this.sentMails.length;\n }\n}\n","import {\n normalizeRecipients,\n type Recipient,\n type SendMailOptions,\n type SendResult,\n} from \"../../core/types.js\";\nimport type {\n BulkKnownTemplateSendOptions,\n BulkSendOptions,\n KnownTemplateSendOptions,\n} from \"../../core/types.js\";\nimport type { IEmailSender } from \"../sender.interface.js\";\n\nexport interface ConsoleEmailSenderOptions {\n /**\n * Log level or custom log printer. Defaults to `console.log`.\n */\n logger?: (message: string) => void;\n /**\n * Whether to include the full HTML body in console output.\n * Defaults to false (prints plain text or a summary).\n */\n includeHtml?: boolean;\n}\n\ninterface DispatchLog {\n kind: string;\n to: Recipient | Recipient[];\n from?: Recipient;\n subject?: string;\n templateId?: string;\n text?: string;\n html?: string;\n}\n\n/**\n * Console logger transport that prints dispatched emails to stdout/stderr.\n * Ideal for development and debugging.\n */\nexport class ConsoleEmailSender implements IEmailSender {\n readonly name = \"console\";\n\n private readonly log: (message: string) => void;\n private readonly includeHtml: boolean;\n private nextId = 1;\n\n constructor(options: ConsoleEmailSenderOptions = {}) {\n this.log = options.logger ?? console.log;\n this.includeHtml = options.includeHtml ?? false;\n }\n\n async send(options: SendMailOptions): Promise<SendResult> {\n return this.logDispatch({\n kind: \"EMAIL\",\n to: options.to,\n from: options.from,\n subject: options.subject,\n text: options.text,\n html: options.html,\n });\n }\n\n async sendBulk(options: BulkSendOptions): Promise<SendResult> {\n return this.logDispatch({\n kind: \"BULK EMAIL\",\n to: options.to,\n from: options.from,\n subject: options.subject,\n text: options.text,\n html: options.html,\n });\n }\n\n async sendKnownTemplate(options: KnownTemplateSendOptions): Promise<SendResult> {\n return this.logDispatch({\n kind: \"TEMPLATE EMAIL\",\n to: options.to,\n from: options.from,\n templateId: options.templateId,\n });\n }\n\n async sendBulkKnownTemplate(options: BulkKnownTemplateSendOptions): Promise<SendResult> {\n return this.logDispatch({\n kind: \"BULK TEMPLATE EMAIL\",\n to: options.to,\n from: options.from,\n templateId: options.templateId,\n });\n }\n\n private logDispatch(entry: DispatchLog): SendResult {\n const to = normalizeRecipients(entry.to)\n .map((r) => (r.name ? `${r.name} <${r.address}>` : r.address))\n .join(\", \");\n const from = entry.from ? JSON.stringify(entry.from) : \"(default)\";\n const messageId = `console-${this.nextId++}-${Date.now()}`;\n\n const separator = \"─\".repeat(60);\n const lines = [\n `\\n┌${separator}┐`,\n `│ [ts-mailkit:console] DISPATCHED ${entry.kind} (${messageId})`,\n `├${separator}┤`,\n `│ From: ${from}`,\n `│ To: ${to}`,\n ];\n\n if (entry.subject !== undefined) {\n lines.push(`│ Subject: ${entry.subject}`);\n }\n if (entry.templateId !== undefined) {\n lines.push(`│ Template: ${entry.templateId}`);\n }\n lines.push(`├${separator}┤`);\n\n if (entry.text) {\n lines.push(\"│ Text Body:\");\n for (const line of entry.text.split(\"\\n\")) {\n lines.push(`│ ${line}`);\n }\n }\n\n if (this.includeHtml && entry.html) {\n lines.push(\"│ HTML Body:\");\n for (const line of entry.html.split(\"\\n\")) {\n lines.push(`│ ${line}`);\n }\n }\n\n lines.push(`└${separator}┘\\n`);\n\n this.log(lines.join(\"\\n\"));\n\n const rawResponse = { logged: true };\n return {\n success: true,\n messageId,\n rawResponse,\n };\n }\n}\n","import type {\n EmailTemplateDto,\n EmailVerificationParams,\n MagicLinkParams,\n NewsletterParams,\n PasswordResetParams,\n SimpleMessageParams,\n TwoFactorParams,\n} from \"./dto/index.js\";\nimport { htmlToPlainText } from \"../renderers/utils/html-to-plaintext.js\";\n\nexport interface BrandingConfig {\n /**\n * Default brand, application, or company name.\n * @default 'Application'\n */\n brandName?: string;\n\n /**\n * Optional custom security / disclaimer advisory message.\n */\n securityMessage?: string;\n\n /**\n * Optional custom footer generator or string.\n */\n footer?: string | ((brandName: string) => string);\n\n /**\n * Optional default logo URL to display top-center in templated emails.\n */\n logoUrl?: string;\n}\n\nconst DEFAULT_SECURITY_MESSAGE =\n \"If you did not request this, please ignore this email or contact support if you have concerns.\";\n\nfunction defaultFooter(brandName: string): string {\n return `© ${new Date().getFullYear()} ${brandName}. All rights reserved.`;\n}\n\n/**\n * Factory for creating pre-populated, type-safe email template DTOs.\n */\nexport class EmailTemplateFactory {\n private readonly defaultBrandName: string;\n private readonly defaultSecurityMessage: string;\n private readonly footerResolver: (brandName: string) => string;\n private readonly defaultLogoUrl?: string;\n\n constructor(config: BrandingConfig = {}) {\n this.defaultBrandName = config.brandName || \"Application\";\n this.defaultSecurityMessage = config.securityMessage || DEFAULT_SECURITY_MESSAGE;\n this.defaultLogoUrl = config.logoUrl;\n if (typeof config.footer === \"function\") {\n this.footerResolver = config.footer;\n } else if (typeof config.footer === \"string\") {\n const fixedFooter = config.footer;\n this.footerResolver = () => fixedFooter;\n } else {\n this.footerResolver = defaultFooter;\n }\n }\n\n private resolveBrand(override?: string): string {\n return override || this.defaultBrandName;\n }\n\n private buildFooter(brandName: string): string {\n return this.footerResolver(brandName);\n }\n\n /**\n * Welcome / email-verification email sent after registration.\n */\n createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n const { username, verificationUrl, otp, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Thank you for signing up. Use the code below or click the button to verify your email address.`;\n return {\n subject: \"Verify Your Email Address\",\n header: `Welcome to ${brand}!`,\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: verificationUrl,\n actionText: \"Verify Email\",\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n `\\n\\nYour verification code is: ${otp}\\n\\nAlternatively, verify here:\\n${verificationUrl}`,\n };\n }\n\n /**\n * Password-reset email with an optional OTP code and action link.\n */\n createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n const { username, resetUrl, otp = \"\", brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>We received a request to reset your password. Use the OTP code below or click the button to proceed.`;\n const plainTextOtp = otp ? `\\n\\nYour OTP code is: ${otp}` : \"\";\n return {\n subject: \"Password Reset Request\",\n header: \"Reset Your Password\",\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp || undefined,\n actionUrl: resetUrl,\n actionText: \"Reset Password\",\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage:\n htmlToPlainText(body) +\n plainTextOtp +\n `\\n\\nAlternatively, you can use the following link to reset your password:\\n${resetUrl}`,\n };\n }\n\n /**\n * Generic plain message email (no action button, no OTP).\n */\n createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n const { subject, header, body, brandName } = params;\n const brand = this.resolveBrand(brandName);\n return {\n subject,\n header,\n body,\n logoUrl: this.defaultLogoUrl,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body),\n };\n }\n\n /**\n * Newsletter / announcement email with an optional hero image and CTA button.\n */\n createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n const { subject, header, body, imageUrl, actionUrl, actionText, brandName, logoUrl } = params;\n const brand = this.resolveBrand(brandName);\n let noHtmlMessage = htmlToPlainText(body);\n if (actionUrl) {\n noHtmlMessage += `\\n\\n${actionText || \"Learn more\"}: ${actionUrl}`;\n }\n return {\n subject,\n header,\n body,\n logoUrl: logoUrl || this.defaultLogoUrl,\n imageUrl,\n actionUrl,\n actionText,\n footer: this.buildFooter(brand),\n fromName: brand,\n noHtmlMessage,\n };\n }\n\n /**\n * Two-factor authentication email with OTP code and optional magic link.\n */\n create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n const { username, otp, magicLink = \"\", brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Use the code below or click the button to complete your login.`;\n const plainLink = magicLink ? `\\n\\nAlternatively, verify here:\\n${magicLink}` : \"\";\n return {\n subject: \"Your Login Verification Code\",\n header: \"Two-Factor Authentication\",\n body,\n logoUrl: this.defaultLogoUrl,\n otpCode: otp,\n actionUrl: magicLink || undefined,\n actionText: magicLink ? \"Verify Login\" : undefined,\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nYour verification code is: ${otp}` + plainLink,\n };\n }\n\n /**\n * Magic link sign-in email (no OTP, button only).\n */\n createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n const { username, magicLink, brandName } = params;\n const brand = this.resolveBrand(brandName);\n const body = `Hi ${username},<br/>Click the button below to sign in. No password needed.`;\n return {\n subject: \"Your Magic Link\",\n header: `Sign In to ${brand}`,\n body,\n logoUrl: this.defaultLogoUrl,\n actionUrl: magicLink,\n actionText: \"Sign In\",\n extraMessage: this.defaultSecurityMessage,\n footer: this.buildFooter(brand),\n userName: username,\n fromName: brand,\n noHtmlMessage: htmlToPlainText(body) + `\\n\\nSign in here:\\n${magicLink}`,\n };\n }\n\n // ─── Default Static Instance ──────────────────────────────────────────────\n private static _defaultInstance?: EmailTemplateFactory;\n\n private static get defaultInstance(): EmailTemplateFactory {\n if (!this._defaultInstance) {\n this._defaultInstance = new EmailTemplateFactory();\n }\n return this._defaultInstance;\n }\n\n static createEmailVerification(params: EmailVerificationParams): EmailTemplateDto {\n return this.defaultInstance.createEmailVerification(params);\n }\n\n static createPasswordReset(params: PasswordResetParams): EmailTemplateDto {\n return this.defaultInstance.createPasswordReset(params);\n }\n\n static createSimpleMessage(params: SimpleMessageParams): EmailTemplateDto {\n return this.defaultInstance.createSimpleMessage(params);\n }\n\n static createNewsLetter(params: NewsletterParams): EmailTemplateDto {\n return this.defaultInstance.createNewsLetter(params);\n }\n\n static create2FAEmail(params: TwoFactorParams): EmailTemplateDto {\n return this.defaultInstance.create2FAEmail(params);\n }\n\n static createMagicLinkEmail(params: MagicLinkParams): EmailTemplateDto {\n return this.defaultInstance.createMagicLinkEmail(params);\n }\n}\n","import type { EmailTemplateDto } from \"./dto/index.js\";\nimport {\n buildHtml,\n buildPlainText,\n type DefaultRendererOptions,\n} from \"../renderers/default/default-renderer.js\";\n\n/**\n * Styling options for building upload-ready templates.\n */\nexport interface TemplateBuildOptions {\n /**\n * Primary brand color for buttons and accents.\n * @default '#4f46e5'\n */\n primaryColor?: string;\n\n /**\n * Font stack used in the HTML wrapper.\n */\n fontFamily?: string;\n\n /**\n * Container maximum width.\n * @default '600px'\n */\n maxWidth?: string;\n\n /**\n * Default logo URL displayed at the top-center of the template.\n */\n logoUrl?: string;\n}\n\n/**\n * Builds an upload-ready HTML template from the canonical {@link EmailTemplateDto}.\n *\n * The output can be uploaded to a messaging platform (Zoho CPaaS, SendGrid, etc.)\n * as a provider-side template.\n */\nexport function buildHTMLTemplate(\n dto: EmailTemplateDto,\n options: TemplateBuildOptions = {},\n): string {\n return buildHtml(dto, options as DefaultRendererOptions);\n}\n\n/**\n * Builds an upload-ready plain-text template from the canonical {@link EmailTemplateDto}.\n */\nexport function buildPlainTextTemplate(\n dto: EmailTemplateDto,\n _options?: TemplateBuildOptions,\n): string {\n return buildPlainText(dto);\n}\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,kBAAkB,OAA6B;CAC7D,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO,EAAE,SAAS,GAAG;CAEvB,MAAM,UAAU,MAAM,KAAK;CAC3B,MAAM,QAAQ,QAAQ,MAAM,uDAAuD;CACnF,IAAI,CAAC,OACH,OAAO,EAAE,SAAS,QAAQ;CAE5B,OAAO;EACL,SAAS,MAAM,EAAE,CAAC,KAAK;EACvB,MAAM,MAAM,EAAE,EAAE,KAAK,KAAK;CAC5B;AACF;;;;AAKA,SAAgB,mBAAmB,WAAoC;CACrE,IAAI,OAAO,cAAc,UACvB,OAAO,EAAE,SAAS,UAAU,KAAK,EAAE;CAErC,IAAI,WAAW,WACb,OAAO;EACL,UAAU,UAAU,SAAS,GAAE,CAAE,KAAK;EACtC,MAAM,UAAU,MAAM,KAAK;CAC7B;CAEF,OAAO;EACL,UAAU,UAAU,WAAW,GAAE,CAAE,KAAK;EACxC,MAAM,UAAU,MAAM,KAAK;CAC7B;AACF;;;;AAKA,SAAgB,oBAAoB,YAAsD;CACxF,IAAI,CAAC,YAAY,OAAO,CAAC;CAEzB,QADa,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU,EACtD,CAAC,IAAI,kBAAkB,CAAC,CAAC,QAAQ,MAAM,EAAE,QAAQ,SAAS,CAAC;AACxE;;;;;;;ACxEA,IAAa,eAAb,cAAkC,MAAM;CACtC,YAAY,SAAiB;EAC3B,MA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
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
1
|
+
export * from "./core/types.js";
|
|
2
|
+
export * from "./core/errors.js";
|
|
3
|
+
export * from "./core/client.js";
|
|
4
|
+
export * from "./transports/sender.interface.js";
|
|
5
|
+
export * from "./transports/cpaas/cpaas-sender.js";
|
|
6
|
+
export * from "./transports/cpaas/types.js";
|
|
7
|
+
export * from "./transports/memory/memory-sender.js";
|
|
8
|
+
export * from "./transports/console/console-sender.js";
|
|
9
|
+
export * from "./templates/dto/index.js";
|
|
10
|
+
export * from "./templates/factory.js";
|
|
11
|
+
export * from "./templates/template-builder.js";
|
|
12
|
+
export * from "./renderers/renderer.interface.js";
|
|
13
|
+
export * from "./renderers/default/default-renderer.js";
|
|
14
|
+
export * from "./renderers/utils/html-to-plaintext.js";
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,kCAAkC,CAAC;AACjD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AAGvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAGhD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC"}
|