import { IsArray, IsInt, IsOptional, IsString, Max, Min, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';

export class ReadingEventUploadItemDto {
  @IsString()
  eventId!: string;

  @IsString()
  clientSessionId!: string;

  @IsString()
  materialId!: string;

  @IsString()
  readingTargetType!: string;

  @IsString()
  eventType!: string;

  @IsOptional()
  position?: any;

  @IsInt()
  @Min(0)
  @Max(3600)
  activeSecondsDelta!: number;

  @IsInt()
  clientTimestampMs!: number;

  @IsInt()
  sequence!: number;

  @IsString()
  platform!: string;

  @IsOptional()
  @IsString()
  appVersion?: string;

  @IsOptional()
  @IsInt()
  clientTimezoneOffsetMinutes?: number;

  @IsOptional()
  @IsString()
  knowledgeBaseId?: string;
}

export class BatchUploadReadingEventsDto {
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => ReadingEventUploadItemDto)
  events!: ReadingEventUploadItemDto[];
}
