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

import (
	"context"

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

// SessionRepository manages session persistence.
type SessionRepository interface {
	// Create stores a new session record.
	Create(ctx context.Context, session *domain.Session) error

	// Get retrieves a session by ID.
	Get(ctx context.Context, id domain.SessionID) (*domain.Session, error)

	// GetActiveByProject retrieves the active session for a project (at most one).
	GetActiveByProject(ctx context.Context, projectID domain.ProjectID) (*domain.Session, error)

	// ListByProject returns all sessions for a project, ordered by created_at DESC.
	ListByProject(ctx context.Context, projectID domain.ProjectID) ([]*domain.Session, error)

	// SetEnded marks a session as ended with a timestamp.
	SetEnded(ctx context.Context, id domain.SessionID) error

	// CleanupExpired marks expired sessions and returns them for preview teardown.
	CleanupExpired(ctx context.Context) ([]*domain.Session, error)
}
