import { ReportType, ExecutionStatus, ExportFormat, WidgetType } from '../entities';

/**
 * Parameter type enum for report parameters
 */
export enum ParamType {
  STRING = 'string',
  NUMBER = 'number',
  DATE = 'date',
  DATERANGE = 'daterange',
  BOOLEAN = 'boolean',
  SELECT = 'select',
  MULTISELECT = 'multiselect',
  ENTITY = 'entity',
}

/**
 * Filter operator enum
 */
export enum FilterOperator {
  EQ = 'eq',
  NE = 'ne',
  GT = 'gt',
  GTE = 'gte',
  LT = 'lt',
  LTE = 'lte',
  LIKE = 'like',
  ILIKE = 'ilike',
  IN = 'in',
  NOT_IN = 'not_in',
  BETWEEN = 'between',
  IS_NULL = 'is_null',
  IS_NOT_NULL = 'is_not_null',
}

/**
 * Base pagination DTO
 */
export interface PaginationDto {
  page?: number;
  limit?: number;
}

/**
 * DTO for filtering report definitions.
 */
export interface ReportDefinitionFiltersDto extends PaginationDto {
  reportType?: ReportType;
  category?: string;
  isPublic?: boolean;
  isActive?: boolean;
  search?: string;
}

/**
 * DTO for filtering report executions.
 */
export interface ReportExecutionFiltersDto extends PaginationDto {
  reportDefinitionId?: string;
  status?: ExecutionStatus;
  executedBy?: string;
  exportFormat?: ExportFormat;
  dateFrom?: string;
  dateTo?: string;
}

/**
 * DTO for filtering report schedules.
 */
export interface ReportScheduleFiltersDto extends PaginationDto {
  reportDefinitionId?: string;
  isActive?: boolean;
  search?: string;
}

/**
 * DTO for filtering dashboards.
 */
export interface DashboardFiltersDto extends PaginationDto {
  ownerId?: string;
  isDefault?: boolean;
  isPublic?: boolean;
  isActive?: boolean;
  search?: string;
}

/**
 * DTO for filtering dashboard widgets.
 */
export interface DashboardWidgetFiltersDto extends PaginationDto {
  dashboardId?: string;
  widgetType?: WidgetType;
  isActive?: boolean;
}

/**
 * DTO for filtering custom reports.
 */
export interface CustomReportFiltersDto extends PaginationDto {
  baseDefinitionId?: string;
  isFavorite?: boolean;
  search?: string;
}

/**
 * Parameter definition for report parameters schema
 */
export interface ReportParameterDefinition {
  name: string;
  label: string;
  type: ParamType;
  required: boolean;
  defaultValue?: any;
  options?: Array<{ value: any; label: string }>;
  entityType?: string;
  validation?: {
    min?: number;
    max?: number;
    pattern?: string;
  };
}

/**
 * Column definition for report columns config
 */
export interface ReportColumnDefinition {
  field: string;
  header: string;
  type: 'string' | 'number' | 'date' | 'boolean' | 'currency' | 'percentage';
  width?: number;
  align?: 'left' | 'center' | 'right';
  format?: string;
  sortable?: boolean;
  filterable?: boolean;
  hidden?: boolean;
}

/**
 * Filter definition for custom reports
 */
export interface ReportFilterDefinition {
  field: string;
  operator: FilterOperator;
  value: any;
  valueEnd?: any; // For BETWEEN operator
}
