/**
 * Express type extensions for authentication and request context
 */

import { JWTPayload, ApiKeyData, LicenseData, AdminRole } from './index';

declare global {
  namespace Express {
    /**
     * Extended Request interface with authentication data
     */
    interface Request {
      /**
       * JWT payload (set by JWT authentication middleware)
       */
      user?: JWTPayload;

      /**
       * API key data (set by API key authentication middleware)
       */
      apiKey?: ApiKeyData;

      /**
       * License data (set by license authentication middleware)
       */
      license?: LicenseData;

      /**
       * Authenticated site origin from X-Site-URL for license requests.
       */
      siteUrl?: string;

      /**
       * Admin user data (for admin panel routes)
       */
      admin?: {
        id: string;
        email: string;
        role: AdminRole;
      };

      /**
       * Request ID for logging and tracing
       */
      requestId?: string;

      /**
       * Client IP address (extracted from X-Forwarded-For or req.ip)
       */
      clientIp?: string;
    }
  }
}

export {};
