package storage

import (
	"context"
	"os"

	auditmodels "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/audit"
	"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/auth"
	"git.optclblast.xyz/draincloud/draincloud-core/internal/storage/models/files"
	"github.com/google/uuid"
)

type Database interface {
	AuthStorage
}

type AuthStorage interface {
	AddUser(ctx context.Context, id uuid.UUID, login string, username string, passwordHash []byte) error
	GetUserByLogin(ctx context.Context, login string) (*auth.User, error)
	GetUserByID(ctx context.Context, id uuid.UUID) (*auth.User, error)

	AddSession(ctx context.Context, ses *auth.Session) (uuid.UUID, error)
	GetSession(ctx context.Context, sessionToken string) (*auth.Session, error)
	RemoveSession(ctx context.Context, id uuid.UUID) error
}

type AuthAuditLogStorage interface {
	AddEntry(ctx context.Context, entry auditmodels.AuditLogEntry) error
}

type MetaStorage interface {
	SaveMetadata(ctx context.Context, meta files.FileMetadata) (uuid.UUID, error)
}

type BlobStorage interface {
	GetFile(ctx context.Context, id uuid.UUID) (*os.File, error)
	SaveBlob(ctx context.Context, id uuid.UUID, data []byte) error
	DeleteFile(ctx context.Context, id uuid.UUID) error
	GetFSLink(ctx context.Context, fileID uuid.UUID) (string, error)
}
