import { ActivityAction, EntityType } from "@prisma/client";
import { IsUUID, IsEnum, IsOptional, IsObject, IsString, MaxLength } from "class-validator";

/**
 * DTO for creating a new activity log entry
 */
export class CreateActivityLogDto {
  @IsUUID("4", { message: "workspaceId must be a valid UUID" })
  workspaceId!: string;

  @IsUUID("4", { message: "userId must be a valid UUID" })
  userId!: string;

  @IsEnum(ActivityAction, { message: "action must be a valid ActivityAction" })
  action!: ActivityAction;

  @IsEnum(EntityType, { message: "entityType must be a valid EntityType" })
  entityType!: EntityType;

  @IsUUID("4", { message: "entityId must be a valid UUID" })
  entityId!: string;

  @IsOptional()
  @IsObject({ message: "details must be an object" })
  details?: Record<string, unknown>;

  @IsOptional()
  @IsString({ message: "ipAddress must be a string" })
  @MaxLength(45, { message: "ipAddress must not exceed 45 characters" })
  ipAddress?: string;

  @IsOptional()
  @IsString({ message: "userAgent must be a string" })
  @MaxLength(500, { message: "userAgent must not exceed 500 characters" })
  userAgent?: string;
}
