UNPKG

@xtr-dev/payload-mailing

Version:

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

34 lines 1.37 kB
import { Payload } from 'payload'; import { JobPollingConfig } from '../types/index.js'; export interface PollForJobIdOptions { payload: Payload; collectionSlug: string; emailId: string | number; config?: JobPollingConfig; logger?: { debug: (message: string, ...args: any[]) => void; info: (message: string, ...args: any[]) => void; warn: (message: string, ...args: any[]) => void; error: (message: string, ...args: any[]) => void; }; } export interface PollForJobIdResult { jobId: string; attempts: number; elapsedTime: number; } /** * Polls for a job ID associated with an email document using exponential backoff. * This utility handles the complexity of waiting for auto-scheduled jobs to be created. * * The polling mechanism uses exponential backoff with configurable parameters: * - Starts with an initial delay and doubles on each retry * - Caps individual delays at maxBackoffDelay * - Enforces a maximum total polling time * * @param options - Polling options including payload, collection, email ID, and config * @returns Promise resolving to job ID and timing information * @throws Error if job is not found within the configured limits */ export declare const pollForJobId: (options: PollForJobIdOptions) => Promise<PollForJobIdResult>; //# sourceMappingURL=jobPolling.d.ts.map