UNPKG

@snehal96/unimail

Version:

Unified email fetching & document extraction layer for modern web apps

33 lines (32 loc) 1.5 kB
import { NormalizedEmail, EmailStreamOptions, EmailStreamCallbacks, EmailStreamProgress, EmailStreamBatch } from '../interfaces.js'; /** * Common streaming utility for email adapters * Provides shared functionality for streaming emails in batches */ export declare class EmailStreamService { /** * Creates an async generator that yields email batches * This is the core streaming implementation that adapters can use */ static createEmailStream(fetchPageFn: (pageToken?: string, pageSize?: number) => Promise<{ emails: NormalizedEmail[]; nextPageToken?: string; totalCount?: number; }>, options: EmailStreamOptions): AsyncGenerator<NormalizedEmail[], void, unknown>; /** * Executes email streaming with callbacks for progress tracking */ static processEmailStream(streamGenerator: AsyncGenerator<NormalizedEmail[], void, unknown>, callbacks: EmailStreamCallbacks): Promise<void>; /** * Utility to create a stream batch object with metadata */ static createStreamBatch(emails: NormalizedEmail[], batchNumber: number, progress: EmailStreamProgress, isLastBatch?: boolean): EmailStreamBatch; /** * Utility to calculate estimated remaining emails */ static calculateEstimatedRemaining(totalCount: number | undefined, currentProcessed: number): number | undefined; /** * Utility to validate streaming options */ static validateStreamOptions(options: EmailStreamOptions): void; }