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

import (
	"context"

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

// CheckoutRepository manages checkout persistence.
type CheckoutRepository interface {
	// Create stores a new checkout record.
	Create(ctx context.Context, checkout *domain.Checkout) error

	// Get retrieves a checkout by ID.
	Get(ctx context.Context, id domain.CheckoutID) (*domain.Checkout, error)

	// GetByProjectBranch retrieves an active checkout for a project+branch.
	GetByProjectBranch(ctx context.Context, projectID domain.ProjectID, branch string) (*domain.Checkout, error)

	// List returns checkouts matching the given options.
	List(ctx context.Context, opts domain.CheckoutListOptions) ([]*domain.Checkout, error)

	// ListByProject returns all checkouts for a project.
	ListByProject(ctx context.Context, projectID domain.ProjectID) ([]*domain.Checkout, error)

	// UpdateStatus updates the status of a checkout.
	UpdateStatus(ctx context.Context, id domain.CheckoutID, status domain.CheckoutStatus) error

	// SetCheckedIn marks a checkout as checked in with timestamp.
	SetCheckedIn(ctx context.Context, id domain.CheckoutID, reviewTaskID string) error

	// SetReviewTask sets the review task ID for a checkout.
	SetReviewTask(ctx context.Context, id domain.CheckoutID, taskID string) error

	// CleanupExpired marks expired checkouts and returns their Gitea token IDs for revocation.
	CleanupExpired(ctx context.Context) ([]int64, error)
}
