/**
 * SLM Framework - Constants
 * Códigos HTTP y mensajes de error estándar
 */

/**
 * Códigos de estado HTTP
 */
const HTTP = {
    // 2xx Success
    OK: 200,
    CREATED: 201,
    ACCEPTED: 202,
    NO_CONTENT: 204,

    // 3xx Redirection
    MOVED_PERMANENTLY: 301,
    FOUND: 302,
    NOT_MODIFIED: 304,

    // 4xx Client Errors
    BAD_REQUEST: 400,
    UNAUTHORIZED: 401,
    FORBIDDEN: 403,
    NOT_FOUND: 404,
    METHOD_NOT_ALLOWED: 405,
    CONFLICT: 409,
    UNPROCESSABLE_ENTITY: 422,
    TOO_MANY_REQUESTS: 429,

    // 5xx Server Errors
    INTERNAL_ERROR: 500,
    NOT_IMPLEMENTED: 501,
    BAD_GATEWAY: 502,
    SERVICE_UNAVAILABLE: 503,
    GATEWAY_TIMEOUT: 504
};

/**
 * Mensajes de error estándar
 */
const ERRORS = {
    // Autenticación y Autorización
    PERMISSION_REQUIRED: 'API Key is required',
    INVALID_APIKEY: 'Invalid API Key',
    INVALID_APIKEY_NOT_ASSIGNED: 'API Key not assigned to user',
    USER_DISABLED: 'User account is disabled',
    USER_SECURITY_RESTRICTIONS: 'User has security restrictions',
    NETWORK_NOT_ALLOWED: 'IP address not authorized',

    // Endpoints y Recursos
    ENDPOINT_NOT_FOUND: 'Endpoint not found',
    RESOURCE_NOT_FOUND: 'Resource not found',
    METHOD_NOT_ALLOWED: 'Method not allowed',

    // Validación
    VALIDATION_ERROR: 'Validation error',
    MISSING_PARAMETERS: 'Missing required parameters',
    INVALID_PARAMETERS: 'Invalid parameters',

    // Base de Datos
    DB_ERROR: 'Database error',
    DB_CONNECTION_ERROR: 'Database connection error',
    ES_ERROR: 'Elasticsearch error',

    // Genérico
    INTERNAL_ERROR: 'Internal server error',
    SERVICE_UNAVAILABLE: 'Service temporarily unavailable',
    RATE_LIMIT_EXCEEDED: 'Rate limit exceeded'
};

/**
 * Mensajes de éxito estándar
 */
const SUCCESS = {
    OK: 'Success',
    CREATED: 'Resource created successfully',
    UPDATED: 'Resource updated successfully',
    DELETED: 'Resource deleted successfully',
    OPERATION_COMPLETED: 'Operation completed successfully'
};

/**
 * Tipos de contenido
 */
const CONTENT_TYPES = {
    JSON: 'application/json',
    XML: 'application/xml',
    HTML: 'text/html',
    TEXT: 'text/plain',
    PDF: 'application/pdf',
    CSV: 'text/csv'
};

/**
 * Configuración de caché
 */
const CACHE = {
    TTL_SHORT: 15,      // 15 segundos
    TTL_MEDIUM: 300,    // 5 minutos
    TTL_LONG: 3600,     // 1 hora
    TTL_DAY: 86400      // 24 horas
};

/**
 * Rate limiting
 */
const RATE_LIMIT = {
    WINDOW_MS: 60000,   // 1 minuto
    MAX_REQUESTS: 100    // Máximo de peticiones por ventana
};

module.exports = {
    HTTP,
    ERRORS,
    SUCCESS,
    CONTENT_TYPES,
    CACHE,
    RATE_LIMIT
};
