import { IsOptional, IsDateString, IsUUID, IsString } from "class-validator";

export class UsageAnalyticsQueryDto {
  @IsOptional()
  @IsUUID()
  workspaceId?: string;

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

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

  @IsOptional()
  @IsUUID()
  userId?: string;

  @IsOptional()
  @IsDateString()
  startDate?: string;

  @IsOptional()
  @IsDateString()
  endDate?: string;
}

export interface UsageAnalyticsResponseDto {
  totalCalls: number;
  totalPromptTokens: number;
  totalCompletionTokens: number;
  totalTokens: number;
  totalCostCents: number;
  averageDurationMs: number;
  byProvider: ProviderUsageDto[];
  byModel: ModelUsageDto[];
  byTaskType: TaskTypeUsageDto[];
}

export interface ProviderUsageDto {
  provider: string;
  calls: number;
  promptTokens: number;
  completionTokens: number;
  totalTokens: number;
  costCents: number;
  averageDurationMs: number;
}

export interface ModelUsageDto {
  model: string;
  calls: number;
  promptTokens: number;
  completionTokens: number;
  totalTokens: number;
  costCents: number;
  averageDurationMs: number;
}

export interface TaskTypeUsageDto {
  taskType: string;
  calls: number;
  promptTokens: number;
  completionTokens: number;
  totalTokens: number;
  costCents: number;
  averageDurationMs: number;
}
