/**
 * Constants - SSOT Entry Point
 *
 * Este archivo es el punto de entrada para todas las constantes del sistema.
 * Exporta desde los modulos especializados para mantener SSOT.
 *
 * @module @shared/constants
 */

// ============================================================================
// DATABASE CONSTANTS
// ============================================================================
export {
  DB_SCHEMAS,
  DB_TABLES,
  DB_COLUMNS,
  TABLE_REFS,
  getFullTableName,
  type DBSchema,
} from './database.constants';

// ============================================================================
// API CONSTANTS
// ============================================================================
export {
  API_VERSION,
  API_PREFIX,
  API_ROUTES,
  HTTP_METHODS,
  HTTP_STATUS,
  CONTENT_TYPES,
} from './api.constants';

// ============================================================================
// ENUMS
// ============================================================================
export {
  // Auth
  ROLES,
  USER_STATUS,
  type Role,
  type UserStatus,

  // Projects
  PROJECT_STATUS,
  PROJECT_TYPE,
  FRACCIONAMIENTO_STATUS,
  LOT_STATUS,
  type ProjectStatus,
  type ProjectType,
  type FraccionamientoStatus,
  type LotStatus,

  // Budget
  CONCEPT_TYPE,
  BUDGET_STATUS,
  type ConceptType,
  type BudgetStatus,

  // Purchases
  PURCHASE_ORDER_STATUS,
  REQUISITION_STATUS,
  STOCK_MOVE_TYPE,
  type PurchaseOrderStatus,
  type RequisitionStatus,
  type StockMoveType,

  // Estimates
  ESTIMATION_STATUS,
  RETENTION_TYPE,
  type EstimationStatus,
  type RetentionType,

  // HSE
  INCIDENT_SEVERITY,
  INCIDENT_TYPE,
  INCIDENT_STATUS,
  TRAINING_TYPE,
  WORK_PERMIT_TYPE,
  type IncidentSeverity,
  type IncidentType,
  type IncidentStatus,
  type TrainingType,
  type WorkPermitType,

  // HR
  EMPLOYEE_TYPE,
  ATTENDANCE_TYPE,
  ATTENDANCE_VALIDATION,
  type EmployeeType,
  type AttendanceType,
  type AttendanceValidation,

  // INFONAVIT
  INFONAVIT_ASSIGNMENT_STATUS,
  INFONAVIT_PROGRAM,
  type InfonavitAssignmentStatus,
  type InfonavitProgram,

  // Quality
  TICKET_STATUS,
  TICKET_PRIORITY,
  type TicketStatus,
  type TicketPriority,

  // Documents
  DOCUMENT_STATUS,
  DOCUMENT_TYPE,
  type DocumentStatus,
  type DocumentType,

  // Workflow
  WORKFLOW_ACTION,
  type WorkflowAction,

  // Audit
  AUDIT_ACTION,
  type AuditAction,
} from './enums.constants';

// ============================================================================
// APP CONFIG CONSTANTS
// ============================================================================

/**
 * Application Context for PostgreSQL RLS
 */
export const APP_CONTEXT = {
  TENANT_ID: 'app.current_tenant_id',
  USER_ID: 'app.current_user_id',
} as const;

/**
 * Custom HTTP Headers
 */
export const CUSTOM_HEADERS = {
  TENANT_ID: 'x-tenant-id',
  CORRELATION_ID: 'x-correlation-id',
  API_KEY: 'x-api-key',
} as const;

/**
 * Pagination Defaults
 */
export const PAGINATION = {
  DEFAULT_PAGE: 1,
  DEFAULT_LIMIT: 20,
  MAX_LIMIT: 100,
} as const;

/**
 * Regex Patterns for Validation
 */
export const PATTERNS = {
  UUID: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
  RFC: /^[A-Z&Ñ]{3,4}[0-9]{6}[A-Z0-9]{3}$/,
  CURP: /^[A-Z]{4}[0-9]{6}[HM][A-Z]{5}[0-9A-Z][0-9]$/,
  NSS: /^[0-9]{11}$/,
  EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  PHONE_MX: /^(\+52)?[0-9]{10}$/,
  POSTAL_CODE_MX: /^[0-9]{5}$/,
} as const;

/**
 * File Upload Limits
 */
export const FILE_LIMITS = {
  MAX_FILE_SIZE: 10 * 1024 * 1024, // 10MB
  MAX_FILES: 10,
  ALLOWED_IMAGE_TYPES: ['image/jpeg', 'image/png', 'image/webp'],
  ALLOWED_DOC_TYPES: ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
  ALLOWED_SPREADSHEET_TYPES: ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
} as const;

/**
 * Cache TTL (Time To Live) in seconds
 */
export const CACHE_TTL = {
  SHORT: 60,          // 1 minute
  MEDIUM: 300,        // 5 minutes
  LONG: 3600,         // 1 hour
  DAY: 86400,         // 24 hours
} as const;

/**
 * Date Formats
 */
export const DATE_FORMATS = {
  ISO: 'YYYY-MM-DDTHH:mm:ss.sssZ',
  DATE_ONLY: 'YYYY-MM-DD',
  TIME_ONLY: 'HH:mm:ss',
  DISPLAY_MX: 'DD/MM/YYYY',
  DISPLAY_FULL_MX: 'DD/MM/YYYY HH:mm',
} as const;
