package domain

import "context"

type Repository interface {
	CreateRun(ctx context.Context, r *Run) error
	GetRun(ctx context.Context, ownerUID int64, id string) (*Run, error)
	ListRuns(ctx context.Context, filter RunFilter) (RunPage, error)
	ListRunPosts(ctx context.Context, ownerUID int64, runID string, page, pageSize int) (RunPostPage, error)
	ReplaceRunGuarded(ctx context.Context, ownerUID int64, id string, expected []string, replacement *Run) error
	DeleteRun(ctx context.Context, ownerUID int64, id string) error
	PublishRunPosts(ctx context.Context, ownerUID int64, runID string, posts []*Post) error
	HasSeenIdentity(ctx context.Context, ownerUID int64, identity string) (bool, error)
	MarkSeenIdentity(ctx context.Context, ownerUID int64, identity, postID string, seenAt int64) error

	SaveBrand(ctx context.Context, b *Brand) error
	GetBrand(ctx context.Context, id string) (*Brand, error)
	ListBrands(ctx context.Context, ownerUID int64) ([]*Brand, error)
	DeleteBrand(ctx context.Context, id string) error

	SaveProduct(ctx context.Context, p *Product) error
	GetProduct(ctx context.Context, id string) (*Product, error)
	ListProducts(ctx context.Context, ownerUID int64, brandID string) ([]*Product, error)
	DeleteProduct(ctx context.Context, id string) error

	GetActiveBrandID(ctx context.Context, ownerUID int64) (string, error)
	SetActiveBrandID(ctx context.Context, ownerUID int64, brandID string) error

	SavePost(ctx context.Context, p *Post) error
	GetPost(ctx context.Context, id string) (*Post, error)
	ListPosts(ctx context.Context, ownerUID int64, brandID string) ([]*Post, error)
	DeletePost(ctx context.Context, id string) error
	DeletePostsByTheme(ctx context.Context, ownerUID int64, themeKey string) error

	SaveHomework(ctx context.Context, h *Homework) error
	GetHomework(ctx context.Context, ownerUID int64, themeKey string) (*Homework, error)
	ListHomework(ctx context.Context, ownerUID int64) ([]*Homework, error)
	DeleteHomework(ctx context.Context, ownerUID int64, themeKey string) error

	GetCrawlerSession(ctx context.Context, ownerUID int64) (*CrawlerSession, error)
	SetCrawlerSession(ctx context.Context, sess *CrawlerSession) error
	ClearCrawlerSession(ctx context.Context, ownerUID int64) error
}
