import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsDateString, IsEnum, IsInt, IsNumber, IsOptional, IsString, Min } from 'class-validator';
import { AlertSeverity, CheckStatus, MonitoringCheckType } from '../enums/website-monitoring.enum';

export class CreateBreachCheckResultDto {
  @ApiProperty({
    description: 'Website ID',
    example: 1,
  })
  @IsNumber()
  websiteId: number;

  @ApiProperty({
    description: 'Type of monitoring check performed',
    enum: MonitoringCheckType,
    example: MonitoringCheckType.CONTENT_CHANGE,
  })
  @IsEnum(MonitoringCheckType)
  checkType: MonitoringCheckType;

  @ApiProperty({
    description: 'Timestamp when the check was performed',
    example: '2024-01-01T00:00:00.000Z',
  })
  @IsDateString()
  timestamp: Date;

  @ApiProperty({
    description: 'Status of the check result',
    enum: CheckStatus,
    example: CheckStatus.PASS,
    default: CheckStatus.PASS,
  })
  @IsEnum(CheckStatus)
  @IsOptional()
  status?: CheckStatus = CheckStatus.PASS;

  @ApiProperty({
    description: 'Severity level of the check result',
    enum: AlertSeverity,
    example: AlertSeverity.INFO,
    default: AlertSeverity.INFO,
  })
  @IsEnum(AlertSeverity)
  @IsOptional()
  severity?: AlertSeverity = AlertSeverity.INFO;

  @ApiPropertyOptional({
    description: 'Detailed information about the check result',
    example: {
      changedElements: ['title', 'header'],
      previousHash: 'abc123...',
      currentHash: 'def456...',
      confidence: 0.95,
    },
  })
  @IsOptional()
  details?: Record<string, any>;

  @ApiPropertyOptional({
    description: 'Raw data from the check (HTML, JSON, etc.)',
    example: '<html><head><title>My Site</title></head>...</html>',
  })
  @IsString()
  @IsOptional()
  rawData?: string;

  @ApiPropertyOptional({
    description: 'Whether an alert was generated for this result',
    default: false,
  })
  @IsBoolean()
  @IsOptional()
  alertGenerated?: boolean = false;

  @ApiPropertyOptional({
    description: 'Response time in milliseconds',
    example: 250,
    minimum: 0,
  })
  @IsInt()
  @Min(0)
  @IsOptional()
  responseTimeMs?: number;
}
