package ai.decompile.workspace.model.dto;

import ai.decompile.workspace.model.entity.Workspace;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.Instant;
import java.util.UUID;

public record WorkspaceResponse(
    @NotNull UUID id,
    @NotBlank String name,
    String description,
    @NotNull Instant updatedAt,
    int projectCount) {
  public static WorkspaceResponse from(Workspace workspace) {
    return new WorkspaceResponse(
        workspace.getId(),
        workspace.getName(),
        workspace.getDescription(),
        workspace.getUpdatedAt(),
        workspace.getProjects().size());
  }
}
