// Package port defines interfaces (ports) for external dependencies.
package port

import (
	"context"

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

// ComponentService manages components within monorepo projects.
type ComponentService interface {
	// AddComponent adds a new component to a project's monorepo.
	AddComponent(ctx context.Context, projectID string, req AddComponentRequest) (*domain.Component, error)

	// AddComponentBatch adds multiple components in a single atomic operation.
	// All components are validated upfront, then committed in a single git commit.
	AddComponentBatch(ctx context.Context, projectID string, reqs []AddComponentRequest) ([]*domain.Component, error)

	// ListComponents lists all components in a project's monorepo.
	ListComponents(ctx context.Context, projectID string) ([]domain.Component, error)

	// RemoveComponent removes a component from a project's monorepo.
	RemoveComponent(ctx context.Context, projectID string, componentPath string) error
}

// AddComponentRequest contains the parameters for adding a component.
type AddComponentRequest struct {
	Type     string `json:"type"`     // service, worker, app-astro, app-react, cli
	Name     string `json:"name"`     // component name (slug format)
	Template string `json:"template"` // optional: specific template variant
	Port     int    `json:"port"`     // optional: specific port (auto-assigned if 0)
}
