# Copyright (c) 2026 MergeGuide, Inc. All rights reserved.
# SPDX-License-Identifier: Proprietary
"""Rate limiting module for MergeGuide.

Provides DynamoDB-based rate limiting with atomic counters and
sliding window approach. Designed for Lambda-level enforcement
with fail-open behavior.

Public API:
    - RateLimiter: Context manager for rate limiting (future)
    - rate_limited: Decorator for Lambda handlers
    - check_rate_limit: Direct rate limit check function
    - build_rate_limit_headers: Build HTTP headers from result
    - TIER_LIMITS: Tier configuration dictionary
    - RateLimitResult: Result dataclass

Example Usage:
    from mergeguide.rate_limiting import check_rate_limit, RateLimitResult

    result = check_rate_limit(identifier="org-123", tier="team")
    if not result.allowed:
        return {"statusCode": 429, "headers": result.to_headers()}
"""

from .config import (
    DEFAULT_TIER,
    TIER_LIMITS,
    BillingTier,
    TierConfig,
    get_limit_for_tier,
    get_tier_config,
)
from .decorator import rate_limited
from .limiter import (
    RateLimitResult,
    build_rate_limit_headers,
    check_rate_limit,
    get_current_usage,
)

__all__ = [
    # Core types
    "RateLimitResult",
    "BillingTier",
    "TierConfig",
    # Configuration
    "TIER_LIMITS",
    "DEFAULT_TIER",
    "get_tier_config",
    "get_limit_for_tier",
    # Rate limit functions
    "check_rate_limit",
    "get_current_usage",
    "build_rate_limit_headers",
    # Decorator
    "rate_limited",
]
