/**
 * @fileoverview Transport middleware system for log transformation and filtering
 * @module @nuanced-labs/lever-ui-logger/transports
 */
import type { LogLevel, LogEventData } from '../logger/types.js';
/**
 * Middleware context containing log data and metadata
 */
export interface MiddlewareContext {
    /** The log event being processed */
    event: LogEventData;
    /** Transport-specific metadata */
    metadata: Record<string, unknown>;
    /** Skip this log (don't send to transport) */
    skip?: boolean;
    /** Additional headers for the transport */
    headers?: Record<string, string>;
}
/**
 * Middleware function that processes log events
 */
export type MiddlewareFunction = (_context: MiddlewareContext, _next: () => void | Promise<void>) => void | Promise<void>;
/**
 * Middleware configuration options
 */
export interface MiddlewareOptions {
    /** Name for debugging and error messages */
    name?: string;
    /** Only apply to specific log levels */
    levels?: LogLevel[];
    /** Skip middleware based on condition */
    condition?: (_context: MiddlewareContext) => boolean;
}
/**
 * Transport middleware for processing log events
 */
export declare class TransportMiddleware {
    private middlewares;
    /**
     * Add middleware to the pipeline
     */
    use(fn: MiddlewareFunction, options?: MiddlewareOptions): this;
    /**
     * Execute middleware pipeline
     */
    execute(event: LogEventData, metadata?: Record<string, unknown>): Promise<MiddlewareContext | null>;
    /**
     * Clear all middleware
     */
    clear(): void;
    /**
     * Get middleware count
     */
    get length(): number;
}
/**
 * Built-in middleware: Filter by log level
 *
 * @param {LogLevel} minLevel - Minimum log level to allow through
 * @returns {MiddlewareFunction} Middleware that filters logs below the specified level
 */
export declare function filterByLevel(minLevel: LogLevel): MiddlewareFunction;
/**
 * Built-in middleware: Add timestamp if missing
 *
 * @returns {MiddlewareFunction} Middleware that ensures all events have timestamps
 */
export declare function ensureTimestamp(): MiddlewareFunction;
/**
 * Built-in middleware: Add metadata to all events
 *
 * @param {Record<string, unknown>} metadata - Metadata to add to all events
 * @returns {MiddlewareFunction} Middleware that enriches events with additional metadata
 */
export declare function addMetadata(metadata: Record<string, unknown>): MiddlewareFunction;
/**
 * Built-in middleware: Transform event data
 *
 * @param {Function} transformer - Function to transform the event
 * @returns {MiddlewareFunction} Middleware that transforms events
 */
export declare function transformEvent(transformer: (_event: LogEventData) => LogEventData | null): MiddlewareFunction;
/**
 * Built-in middleware: Rate limiting
 *
 * @param {number} maxPerSecond - Maximum events allowed per second
 * @returns {MiddlewareFunction} Middleware that rate limits events
 */
export declare function rateLimit(maxPerSecond: number): MiddlewareFunction;
/**
 * Built-in middleware: Batch aggregation
 *
 * @param {Object} options - Batch aggregation options
 * @param {number} options.maxSize - Maximum batch size before flush
 * @param {number} options.flushInterval - Time interval for automatic flush
 * @param {Function} options.onFlush - Callback when batch is flushed
 * @returns {MiddlewareFunction} Middleware that batches events
 */
export declare function batchAggregator(options: {
    maxSize?: number;
    flushInterval?: number;
    onFlush: (_events: LogEventData[]) => void | Promise<void>;
}): MiddlewareFunction;
/**
 * Built-in middleware: Sampling
 *
 * @param {number} rate - Sample rate between 0 and 1 (e.g., 0.1 for 10%)
 * @returns {MiddlewareFunction} Middleware that samples events
 * @throws {Error} If rate is not between 0 and 1
 */
export declare function sample(rate: number): MiddlewareFunction;
/**
 * Built-in middleware: Error enrichment
 *
 * @returns {MiddlewareFunction} Middleware that enriches error events with stack traces and details
 */
export declare function enrichErrors(): MiddlewareFunction;
//# sourceMappingURL=transport-middleware.d.ts.map