package port

import (
	"context"

	"{{GO_MODULE}}/services/{{COMPONENT_NAME}}/internal/domain"
)

// AuthCodeRepository defines the interface for auth code persistence.
type AuthCodeRepository interface {
	// Create persists a new auth code.
	Create(ctx context.Context, code *domain.AuthCode) error

	// FindValid returns an unused, non-expired code matching the criteria.
	// Returns domain.ErrInvalidAuthCode if no valid code exists.
	FindValid(ctx context.Context, email string, code string, purpose domain.AuthCodePurpose) (*domain.AuthCode, error)

	// MarkUsed sets the used_at timestamp on a code, making it single-use.
	MarkUsed(ctx context.Context, id string) error

	// DeleteExpired removes codes that have passed their expiry time.
	// Returns the number of codes deleted.
	DeleteExpired(ctx context.Context) (int, error)
}
