#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
///
/// Interface for the repository for books.
///
public interface IBookRepository : IRepository,
IInsertRepositoryAction,
IUpdateRepositoryAction,
IGetByIdRepositoryAction,
IGetAllRepositoryAction,
IGetPaginatedRepositoryAction
{
///
/// Gets all the books of the media library identified by .
///
/// The Id of the media library whose books are retrieved.
/// Cancellation token that can be used to stop the execution.
/// An containing either a collection of , or an error.
Task>> GetByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
///
/// Gets the book of the media library identified by that is stored at the provided .
///
/// The Id of the media library whose book is retrieved.
/// The file system path of the book to be retrieved.
/// Cancellation token that can be used to stop the execution.
/// An containing either the stored at the provided path, or an error.
Task> GetByPathAsync(Guid libraryId, string path, CancellationToken cancellationToken);
///
/// Gets a page of the books of the media library identified by whose metadata has not been enriched yet,
/// ordered by path, using keyset pagination.
///
/// The Id of the media library whose books are retrieved.
/// The path of the last retrieved book, used for keyset pagination. Pass to get the first page.
/// The maximum number of books to retrieve.
/// Cancellation token that can be used to stop the execution.
/// An containing either a page of books needing their metadata enriched, or an error.
Task>> GetBooksNeedingMetadataAsync(Guid libraryId, string? lastPath, int pageSize, CancellationToken cancellationToken);
///
/// Gets the number of books of the media library identified by whose metadata has not been enriched yet.
///
/// The Id of the media library whose books are counted.
/// Cancellation token that can be used to stop the execution.
/// An containing either the number of books needing their metadata enriched, or an error.
Task> GetBooksNeedingMetadataCountAsync(Guid libraryId, CancellationToken cancellationToken);
///
/// Gets a page of the books of the media library identified by that need their artwork resolved,
/// meaning they lack at least one required piece of artwork with an enriched status, ordered by path, using keyset pagination.
///
/// The Id of the media library whose books are retrieved.
/// The path of the last retrieved book, used for keyset pagination. Pass to get the first page.
/// The maximum number of books to retrieve.
/// Cancellation token that can be used to stop the execution.
/// An containing either a page of books needing their artwork resolved, or an error.
Task>> GetBooksNeedingArtworkAsync(Guid libraryId, string? lastPath, int pageSize, CancellationToken cancellationToken);
///
/// Gets the number of books of the media library identified by that need their artwork resolved.
///
/// The Id of the media library whose books are counted.
/// Cancellation token that can be used to stop the execution.
/// An containing either the number of books needing their artwork resolved, or an error.
Task> GetBooksNeedingArtworkCountAsync(Guid libraryId, CancellationToken cancellationToken);
///
/// Resets the enrichment state of the books stored at the provided in the media library identified by
/// , so that they are re-enriched, because their content changed since the last scan.
///
/// The Id of the media library whose books are reset.
/// The file system paths of the books whose enrichment state is reset.
/// Cancellation token that can be used to stop the execution.
/// An representing either a successful operation, or an error.
Task> ResetEnrichmentStateForPathsAsync(Guid libraryId, IReadOnlyCollection paths, CancellationToken cancellationToken);
///
/// Resets the metadata enrichment status of all the books of the media library identified by ,
/// so that they are re-enriched, because the metadata provider configuration of the library changed.
///
/// The Id of the media library whose books are reset.
/// Cancellation token that can be used to stop the execution.
/// An representing either a successful operation, or an error.
Task> ResetMetadataStatusForLibraryAsync(Guid libraryId, CancellationToken cancellationToken);
///
/// Resets the artwork status of all the artwork of the books of the media library identified by ,
/// so that they are re-resolved, because the artwork provider configuration of the library changed.
///
/// The Id of the media library whose artwork is reset.
/// Cancellation token that can be used to stop the execution.
/// An representing either a successful operation, or an error.
Task> ResetArtworkStatusForLibraryAsync(Guid libraryId, CancellationToken cancellationToken);
///
/// Gets the display names of the author of the books identified by the provided ,
/// keyed by the Id of the book, or when a book has no author.
///
/// The unique identifiers of the books whose authors are retrieved.
/// Cancellation token that can be used to stop the execution.
/// An containing either the display names of the authors of the books, keyed by book Id, or an error.
Task>> GetAuthorsDisplayNamesByBookIdsAsync(IReadOnlyCollection bookIds, CancellationToken cancellationToken);
///
/// Deletes the book identified by .
///
/// The Id of the book to delete.
/// Cancellation token that can be used to stop the execution.
/// An representing either a successful operation, or an error.
Task> DeleteAsync(Guid bookId, CancellationToken cancellationToken);
}