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

import (
	"context"

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

// CredentialStore manages secure storage and retrieval of credentials.
// Credentials are encrypted at rest in the database.
type CredentialStore interface {
	// Get retrieves a credential by key. Returns empty string if not found.
	Get(ctx context.Context, key string) (string, error)

	// GetRequired retrieves a credential by key.
	// Returns domain.ErrCredentialNotFound if the key does not exist.
	GetRequired(ctx context.Context, key string) (string, error)

	// Set stores or updates a credential.
	Set(ctx context.Context, cred domain.Credential) error

	// Delete removes a credential by key.
	// Returns domain.ErrCredentialNotFound if the key does not exist.
	Delete(ctx context.Context, key string) error

	// List returns all credentials (with values masked).
	List(ctx context.Context) ([]domain.Credential, error)

	// ListByCategory returns credentials in a category (with values masked).
	ListByCategory(ctx context.Context, category string) ([]domain.Credential, error)

	// GetMultiple retrieves multiple credentials by keys.
	// Returns a map of key -> value. Missing keys are omitted.
	GetMultiple(ctx context.Context, keys []string) (map[string]string, error)

	// SetMultiple stores multiple credentials in a single transaction.
	SetMultiple(ctx context.Context, creds []domain.Credential) error
}
