import { LogDescriptor } from 'pino'; import { Writable } from 'stream'; import { EmailLogRateLimiterService } from './email-log-rate-limiter.service'; import { EmailLogFormatterService } from './email-log-formatter.service'; import { EmailLogOptions } from '../interfaces'; import type { IEmailLogTransport } from '../interfaces'; /** * Pino email transport service * Implements Writable stream interface for Pino compatibility * * Follows the pattern of RedisLock and Cache decorators: * - Global service holder pattern * - Graceful error handling * - Configurable via environment variables */ export declare class EmailLogTransportService extends Writable implements IEmailLogTransport, NodeJS.WritableStream { private readonly options; private readonly rateLimiter; private readonly formatter; private readonly logger; private readonly appName; private emailProvider; private isClosing; constructor(options: EmailLogOptions, rateLimiter: EmailLogRateLimiterService, formatter: EmailLogFormatterService); /** * Write method - implements Writable stream interface * Called by Pino for each log entry */ _write(data: LogDescriptor, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void; /** * Writev method - handles batch writes */ _writev(chunks: { chunk: LogDescriptor; encoding: BufferEncoding; }[], callback: (error?: Error | null) => void): void; /** * Final method - cleanup before stream closes */ _final(callback: (error?: Error | null) => void): void; /** * Process a single log entry */ private processLog; /** * Check if log should trigger email based on configuration */ private shouldSendLog; /** * Get rate limit key for this log entry * Uses 'email-log:appName:level' by default */ private getRateLimitKey; /** * Get level label from numeric level */ private getLevelLabel; /** * Get level value from level name */ private getLevelValueFromName; /** * Format and send email */ private sendEmail; /** * Check if transport is enabled for given log level * Part of IEmailLogTransport interface */ shouldSend(level: string): boolean; /** * Flush any pending writes * Part of IEmailLogTransport interface */ flush(): Promise; /** * Cleanup on module destroy */ onModuleDestroy(): Promise; }