import { Type } from "class-transformer";
import {
  IsArray,
  IsDateString,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
  ValidateNested,
} from "class-validator";
import { FunctionDto } from "./function.dto.js";

export class ProjectDto {
  @IsNotEmpty()
  _id!: string;

  @IsNotEmpty()
  name!: string;

  @IsNotEmpty()
  slug!: string;

  @IsOptional()
  description?: string;

  @IsNumber()
  cpuTimeQuotaMsPerMinute!: number;

  @IsDateString()
  cpuTimeWindowStartedAt!: string;

  @IsNumber()
  cpuTimeUsedMs!: number;

  @IsNumber()
  functionsInvocationCount!: number;

  @IsNumber()
  functionsErrorCount!: number;

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => FunctionDto)
  functions!: FunctionDto[];
}
