UNPKG

@xtr-dev/payload-mailing

Version:

Template-based email system with scheduling and job processing for PayloadCMS

62 lines 2.61 kB
import { Payload } from 'payload'; import { TemplateVariables, PayloadID, PayloadRelation } from '../types/index.js'; /** * Parse and validate email addresses * @internal */ export declare const parseAndValidateEmails: (emails: string | string[] | null | undefined) => string[] | undefined; /** * Sanitize display names to prevent email header injection * Removes newlines, carriage returns, and control characters * @param displayName - The display name to sanitize * @param escapeQuotes - Whether to escape quotes (for email headers) * @returns Sanitized display name */ export declare const sanitizeDisplayName: (displayName: string, escapeQuotes?: boolean) => string; /** * Sanitize and validate fromName for emails * Wrapper around sanitizeDisplayName for consistent fromName handling * @param fromName - The fromName to sanitize * @returns Sanitized fromName or undefined if empty after sanitization */ export declare const sanitizeFromName: (fromName: string | null | undefined) => string | undefined; /** * Type guard to check if a Payload relation is populated (object) or unpopulated (ID) */ export declare const isPopulated: <T extends { id: PayloadID; }>(value: PayloadRelation<T> | null | undefined) => value is T; /** * Resolves a Payload relation to just the ID * Handles both populated (object with id) and unpopulated (string/number) values */ export declare const resolveID: <T extends { id: PayloadID; }>(value: PayloadRelation<T> | null | undefined) => PayloadID | undefined; /** * Resolves an array of Payload relations to an array of IDs * Handles mixed arrays of populated and unpopulated values */ export declare const resolveIDs: <T extends { id: PayloadID; }>(values: (PayloadRelation<T> | null | undefined)[] | null | undefined) => PayloadID[]; export declare const getMailing: (payload: Payload) => any; export declare const renderTemplate: (payload: Payload, templateSlug: string, variables: TemplateVariables) => Promise<{ html: string; text: string; subject: string; }>; /** * Render a template and return both rendered content and template ID * This is used by sendEmail to avoid duplicate template lookups * @internal */ export declare const renderTemplateWithId: (payload: Payload, templateSlug: string, variables: TemplateVariables) => Promise<{ html: string; text: string; subject: string; templateId: PayloadID; }>; export declare const processEmails: (payload: Payload) => Promise<void>; export declare const retryFailedEmails: (payload: Payload) => Promise<void>; //# sourceMappingURL=helpers.d.ts.map