/**
 * Per-Tenant Rate Limiting
 *
 * Provides tenant-scoped rate limiting with configurable limits per tier.
 * Uses in-memory sliding window with Redis support for distributed deployments.
 *
 * @packageDocumentation
 */
import { FastifyRequest, FastifyReply } from 'fastify';
/**
 * Rate limit configuration per tier
 */
export interface TierLimits {
    requestsPerMinute: number;
    requestsPerHour: number;
    burstLimit: number;
}
/**
 * Default tier configurations
 */
export declare const DEFAULT_TIER_LIMITS: Record<string, TierLimits>;
/**
 * Rate limit result
 */
export interface RateLimitResult {
    allowed: boolean;
    remaining: {
        minute: number;
        hour: number;
        burst: number;
    };
    resetAt: {
        minute: number;
        hour: number;
        burst: number;
    };
    retryAfter?: number;
}
/**
 * Per-Tenant Rate Limiter
 */
export declare class TenantRateLimiter {
    private state;
    private tierLimits;
    private cleanupInterval;
    constructor(tierLimits?: Record<string, TierLimits>);
    /**
     * Check and consume rate limit for a tenant
     */
    check(tenantId: string, tier?: string): RateLimitResult;
    /**
     * Get current state for a tenant (for monitoring)
     */
    getState(tenantId: string): {
        tier: string;
        usage: {
            second: number;
            minute: number;
            hour: number;
        };
        limits: TierLimits;
    } | null;
    /**
     * Reset rate limit for a tenant
     */
    reset(tenantId: string): void;
    /**
     * Update tier limits
     */
    setTierLimits(tier: string, limits: TierLimits): void;
    /**
     * Create initial state for a tenant
     */
    private createInitialState;
    /**
     * Reset expired windows
     */
    private resetExpiredWindows;
    /**
     * Start periodic cleanup of stale entries
     */
    private startCleanup;
    /**
     * Stop the rate limiter
     */
    stop(): void;
    /**
     * Get statistics
     */
    getStats(): {
        activeTenants: number;
        byTier: Record<string, number>;
    };
}
/**
 * Get the rate limiter singleton
 */
export declare function getRateLimiter(): TenantRateLimiter;
/**
 * Create rate limit middleware for Fastify
 */
export declare function createRateLimitMiddleware(options?: {
    tierLimits?: Record<string, TierLimits>;
    getTier?: (request: FastifyRequest) => string;
    skip?: (request: FastifyRequest) => boolean;
}): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
/**
 * Rate limit decorator for specific routes
 */
export declare function withRateLimit(customLimits?: Partial<TierLimits>): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
/**
 * Stop the rate limiter singleton and cleanup route-specific limiters
 */
export declare function stopRateLimiter(): void;
//# sourceMappingURL=rate-limit.d.ts.map