export type TableName =
  | 'anticipos'
  | 'asistencias'
  | 'carretas'
  | 'clientes'
  | 'comercios'
  | 'cupones'
  | 'depositos'
  | 'ingresos'
  | 'pagos_anticipo'
  | 'rechazos'
  | 'retenciones'
  | 'salidas'
  | 'tareas_realizadas'
  | 'vista_detalle_ingresos'
  | 'vista_resumen_ingresos'
  | 'vista_resumen_ingresos_por_comercio'

export type TableTransform = {
  readonly serializeRow?: (row: Record<string, unknown>) => Record<string, unknown>
}

export interface TableConfig {
  readonly name: string // Nombre de la datasource (ej: 'ingresos')
  readonly table: TableName // Nombre de la tabla real (ej: 'vista_detalle_ingresos')
  readonly primaryKey?: string
  readonly defaultSelect?: string
  readonly transforms?: TableTransform
  readonly description?: string
}

export interface QueryFilter {
  field: string
  operator?: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike'
  value: string | number | boolean
}

export interface ParsedQuery {
  filters: QueryFilter[]
  limit?: number
  offset?: number
  orderBy?: { field: string; ascending?: boolean }
}
