package handlers

import "github.com/orchard9/rdev/internal/domain"

// BlueprintDTO is the data transfer object for blueprints.
type BlueprintDTO struct {
	ID          string         `json:"id"`
	ProjectID   string         `json:"project_id"`
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Spec        map[string]any `json:"spec"`
	CreatedAt   string         `json:"created_at"`
	UpdatedAt   string         `json:"updated_at"`
}

func toBlueprintDTO(b *domain.Blueprint) *BlueprintDTO {
	if b == nil {
		return nil
	}
	return &BlueprintDTO{
		ID:          string(b.ID),
		ProjectID:   b.ProjectID,
		Name:        b.Name,
		Description: b.Description,
		Spec:        b.Spec,
		CreatedAt:   b.CreatedAt.Format("2006-01-02T15:04:05Z07:00"),
		UpdatedAt:   b.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
	}
}
