/**
 * 📊 Interfaces pour la gestion des données et requêtes
 * Utilisé par DataService et services métier
 */

export interface QueryOptions {
  filters?: Record<string, any>;
  sort?: string;
  search?: string;
  include?: string[];
  exclude?: string[];
}

export interface PagedQueryOptions extends QueryOptions {
  page: number;
  size: number;
}

export interface PagedResult<T = any> {
  success: boolean;
  data: T[];
  totalRecords: number;
  pagination: {
    currentPage: number;
    pageSize: number;
    totalRecords: number;
    totalFiltered: number;
    totalPages: number;
    hasNextPage: boolean;
    hasPreviousPage: boolean;
  };
  indicators?: {
    total: number;
    actifs: number;
    inactifs: number;
  };
}

export interface SortOptions {
  field: string;
  direction: 'asc' | 'desc';
}

export interface FilterOptions {
  field: string;
  operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'in' | 'nin';
  value: any;
}

export interface DataServiceConfig {
  endpoint: string;
  enableCache: boolean;
  defaultPageSize: number;
  maxPageSize: number;
  cacheTtl: number;
}

export interface Entity {
  id?: string | number;
  createdAt?: Date;
  updatedAt?: Date;
  version?: number;
}

export interface ImportOptions {
  fileFormat: 'csv' | 'xlsx' | 'json';
  delimiter?: string;
  mapping?: Record<string, string>;
  validateHeaders?: boolean;
  skipRows?: number;
}

export interface ImportResult {
  success: boolean;
  totalRows: number;
  successfulRows: number;
  errorRows: number;
  errors: ImportError[];
  warnings: ImportWarning[];
}

export interface ImportError {
  row: number;
  field?: string;
  message: string;
  value?: any;
}

export interface ImportWarning {
  row: number;
  field?: string;
  message: string;
  value?: any;
}