import { IsString, IsDateString, IsOptional, IsEnum } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export enum TimeGranularity {
  HOUR = 'hour',
  DAY = 'day',
  WEEK = 'week',
  MONTH = 'month',
}

export class TrendsQueryDto {
  @ApiProperty({ description: 'Metric type to query (e.g., page_views, sessions, revenue)' })
  @IsString()
  metric!: string;

  @ApiProperty({ description: 'Start date in ISO 8601 format' })
  @IsDateString()
  startDate!: string;

  @ApiProperty({ description: 'End date in ISO 8601 format' })
  @IsDateString()
  endDate!: string;

  @ApiPropertyOptional({ enum: TimeGranularity, default: TimeGranularity.DAY })
  @IsOptional()
  @IsEnum(TimeGranularity)
  granularity?: TimeGranularity;

  @ApiPropertyOptional({ description: 'Filter by dimension' })
  @IsOptional()
  @IsString()
  dimension?: string;

  @ApiPropertyOptional({ description: 'Filter by dimension value' })
  @IsOptional()
  @IsString()
  dimensionValue?: string;
}
