package port

import (
	"context"

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

// APIKeyRepository defines operations for managing API keys.
type APIKeyRepository interface {
	// Create stores a new API key.
	Create(ctx context.Context, key *domain.APIKey, keyHash string) error

	// GetByHash retrieves an API key by its hash.
	GetByHash(ctx context.Context, keyHash string) (*domain.APIKey, error)

	// Get retrieves an API key by ID.
	Get(ctx context.Context, id domain.APIKeyID) (*domain.APIKey, error)

	// List returns all API keys (without secrets).
	List(ctx context.Context) ([]*domain.APIKey, error)

	// Revoke marks an API key as revoked.
	Revoke(ctx context.Context, id domain.APIKeyID) error

	// UpdateLastUsed updates the last used timestamp for a key.
	UpdateLastUsed(ctx context.Context, id domain.APIKeyID) error
}
