diff --git a/docs/technical/api/Api.Book.md b/docs/technical/api/Api.Book.md
index 6cef1a60..30c4ae9c 100644
--- a/docs/technical/api/Api.Book.md
+++ b/docs/technical/api/Api.Book.md
@@ -21,6 +21,8 @@ POST api/v1/books
```json
{
+ "libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
+ "path": "/books/the-fellowship-of-the-ring.epub",
"metadata": {
"title": "The Fellowship of the Ring",
"originalTitle": "The Fellowship of the Ring",
@@ -122,6 +124,9 @@ POST api/v1/books
```json
{
+ "id": "32b336e8-dafc-4a08-9dec-9454e66dd55d",
+ "libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
+ "path": "/books/the-fellowship-of-the-ring.epub",
"metadata": {
"publisher": "Houghton Mifflin",
"pageCount": 398,
@@ -205,9 +210,9 @@ POST api/v1/books
"voteCount": 87654
}
],
- "id": {
- "value": "32b336e8-dafc-4a08-9dec-9454e66dd55d"
- }
+ "metadataStatus": "Pending",
+ "lastMetadataUpdateUtc": null,
+ "metadataProvider": null
}
```
@@ -216,7 +221,7 @@ POST api/v1/books
#### Get Books Request
```js
-GET /books
+GET /books?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a
```
#### Get Books Response
diff --git a/docs/technical/requests/books/Add.http b/docs/technical/requests/books/Add.http
index eacdfed3..73a9c33e 100644
--- a/docs/technical/requests/books/Add.http
+++ b/docs/technical/requests/books/Add.http
@@ -2,6 +2,8 @@ POST {{host}}/api/v1/books
Content-Type: application/json
{
+ "libraryId": "00000000-0000-0000-0000-000000000000",
+ "path": "/books/the-fellowship-of-the-ring.epub",
"metadata": {
"title": "The Fellowship of the Ring",
"originalTitle": "The Fellowship of the Ring",
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
index 101bf831..b526c7b5 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -19,6 +19,16 @@ public class BookEntity : IStorageEntity, IAuditableEntity
///
public required Guid Id { get; init; }
+ ///
+ /// Gets or sets the Id of the media library this book belongs to.
+ ///
+ public required Guid LibraryId { get; set; }
+
+ ///
+ /// Gets or sets the file system path of the book.
+ ///
+ public required string Path { get; set; }
+
///
/// Gets or sets the title of the media item.
///
@@ -195,6 +205,21 @@ public class BookEntity : IStorageEntity, IAuditableEntity
///
public List Ratings { get; set; } = [];
+ ///
+ /// Gets or sets the status of the metadata enrichment of the book.
+ ///
+ public MetadataStatus MetadataStatus { get; set; }
+
+ ///
+ /// Gets or sets the date and time when the metadata of the book was last enriched.
+ ///
+ public DateTime? LastMetadataUpdateUtc { get; set; }
+
+ ///
+ /// Gets or sets the name of the plugin that enriched the metadata of the book.
+ ///
+ public string? MetadataProvider { get; set; }
+
///
/// Gets or sets the time and date when the entity was added.
///
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
index 6dbabc93..f6dba43d 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
@@ -1,7 +1,12 @@
#region ========================================================================= USING =====================================================================================
+using ErrorOr;
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;
@@ -11,6 +16,43 @@ namespace Lumina.Application.Common.DataAccess.Repositories.Books;
///
public interface IBookRepository : IRepository,
IInsertRepositoryAction,
+ IUpdateRepositoryAction,
+ IGetByIdRepositoryAction,
IGetAllRepositoryAction
{
+ ///
+ /// 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);
}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
index b8d260c9..a34e4692 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
@@ -24,6 +24,14 @@ public interface ILibraryScanSnapshotRepository : IRepositoryAn containing either a collection of deleted media library scan snapshot item paths, or an error.
Task>> GetDeletedPathsAsync(Guid libraryId, Guid scanId, CancellationToken cancellationToken);
+ ///
+ /// Gets the paths of all the media library scan snapshot items of the media library identified by .
+ ///
+ /// The unique identifier of the library whose media library scan snapshot item paths are retrieved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a collection of media library scan snapshot item paths, or an error.
+ Task>> GetPathsAsync(Guid libraryId, CancellationToken cancellationToken);
+
///
/// Atomically applies the results of the current scan to the storage medium, by replacing the media library scan snapshot of the previous scan with the snapshot of the current scan.
/// The operation updates the changed media library scan snapshot items, deletes the ones that are no longer present on disk, adds audit entries for all changed, new and deleted items,
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
index f0f436d8..37aed932 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
@@ -19,6 +19,8 @@ public static class AddBookRequestMapping
public static AddBookCommand ToCommand(this AddBookRequest request)
{
return new AddBookCommand(
+ request.LibraryId,
+ request.Path,
request.Metadata,
request.Format,
request.Edition,
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
index cb759693..6d6f0e0c 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
@@ -7,12 +7,13 @@ using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookL
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -110,6 +111,8 @@ public static class BookEntityMapping
return Book.Create(
BookId.Create(repositoryEntity.Id),
+ LibraryId.Create(repositoryEntity.LibraryId),
+ repositoryEntity.Path,
writtenContentMetadataResult.Value,
bookFormat,
Optional.FromNullable(repositoryEntity.Edition),
@@ -190,6 +193,8 @@ public static class BookEntityMapping
);
return new BookResponse(
repositoryEntity.Id,
+ repositoryEntity.LibraryId,
+ repositoryEntity.Path,
metadata,
repositoryEntity.Format,
repositoryEntity.Edition,
@@ -207,6 +212,9 @@ public static class BookEntityMapping
[.. repositoryEntity.ISBNs.ToResponses()],
null,
[.. repositoryEntity.Ratings.ToResponses()],
+ repositoryEntity.MetadataStatus,
+ repositoryEntity.LastMetadataUpdateUtc,
+ repositoryEntity.MetadataProvider,
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
index 04b10163..6738c03b 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
@@ -24,6 +24,8 @@ public static class BookMapping
return new BookEntity
{
Id = domainEntity.Id.Value,
+ LibraryId = domainEntity.LibraryId.Value,
+ Path = domainEntity.Path,
Title = domainEntity.Metadata.Title,
OriginalTitle = domainEntity.Metadata.OriginalTitle.HasValue ? domainEntity.Metadata.OriginalTitle.Value : null,
Description = domainEntity.Metadata.Description.HasValue ? domainEntity.Metadata.Description.Value : null,
@@ -57,6 +59,9 @@ public static class BookMapping
AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
ISBNs = domainEntity.ISBNs.ToRepositoryEntities().ToList(),
Ratings = domainEntity.Ratings.ToRepositoryEntities().ToList(),
+ MetadataStatus = domainEntity.MetadataStatus,
+ LastMetadataUpdateUtc = domainEntity.LastMetadataUpdateUtc.HasValue ? domainEntity.LastMetadataUpdateUtc.Value : null,
+ MetadataProvider = domainEntity.MetadataProvider.HasValue ? domainEntity.MetadataProvider.Value : null,
CreatedOnUtc = domainEntity.CreatedOnUtc,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequestMapping.cs
new file mode 100644
index 00000000..87f39126
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequestMapping.cs
@@ -0,0 +1,23 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
+using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Extension methods for converting .
+///
+public static class GetBooksRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetBooksQuery ToQuery(this GetBooksRequest request)
+ {
+ return new GetBooksQuery(request.LibraryId);
+ }
+}
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs
index 7028f53c..08f2cb79 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs
@@ -2,10 +2,9 @@
using ErrorOr;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW;
-using Lumina.Application.Common.Infrastructure.Models.Configuration;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
-using Lumina.Domain.Common.Enums.PhotoLibrary;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
+using Lumina.Domain.SharedKernel.Common.Errors;
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
@@ -18,6 +17,7 @@ using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Events;
@@ -30,7 +30,7 @@ public class LibrarySavedDomainEventHandler : INotificationHandler
/// Initializes a new instance of the class.
@@ -38,12 +38,12 @@ public class LibrarySavedDomainEventHandler : INotificationHandlerInjected unit of work for interacting with the data access layer repositories.
/// Injected facade service for environment contextual services.
/// Injected service for handling file system paths.
- /// Injected service for retrieving .
+ /// Injected service for retrieving .
public LibrarySavedDomainEventHandler(
IUnitOfWork unitOfWork,
IEnvironmentContext environmentContext,
IPathService pathService,
- IOptions mediaSettingsModelOptions)
+ IOptions mediaSettingsModelOptions)
{
_unitOfWork = unitOfWork;
_environmentContext = environmentContext;
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs
index 707d829f..9b04da3d 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs
@@ -1,8 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Mediator;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using Lumina.Contracts.DTO.MediaContributors;
@@ -15,6 +16,8 @@ namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrar
///
/// Command for adding a book.
///
+/// The Id of the media library this book belongs to.
+/// The file system path of the book.
/// Written content metadata of the book.
/// The format of the book (e.g., Hardcover, Paperback), if applicable.
/// The edition of the book, if applicable.
@@ -32,8 +35,10 @@ namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrar
/// The list of ISBN (International Standard Book Number) of the book.
/// The list of media contributors (actors, directors, etc) starring in this book.
/// The list of ratings for this book.
-[DebuggerDisplay("Title: {Title}")]
+[DebuggerDisplay("Title: {Metadata.Title}")]
public record AddBookCommand(
+ Guid LibraryId,
+ string Path,
WrittenContentMetadataDto? Metadata,
BookFormat? Format,
string? Edition,
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs
index 2e44ac44..e7bb8234 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs
@@ -4,7 +4,7 @@ using Lumina.Application.Common.DataAccess.Repositories.Books;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
@@ -12,6 +12,7 @@ using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaCon
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Mediator;
using System;
using System.Collections.Generic;
@@ -139,6 +140,8 @@ public class AddBookCommandHandler : IRequestHandler createBookResult = Book.Create(
+ LibraryId.Create(request.LibraryId),
+ request.Path,
metadataResult.Value,
Optional.FromNullable(request.Format),
Optional.FromNullable(request.Edition),
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs
index 631c49ee..169a8424 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Enums.BookLibrary;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
@@ -16,6 +16,10 @@ public class AddBookCommandValidator : AbstractValidator
///
public AddBookCommandValidator()
{
+ RuleFor(x => x.LibraryId)
+ .NotEmpty().WithMessage(Errors.WrittenContent.BookLibraryCannotBeNull.Description);
+ RuleFor(x => x.Path)
+ .NotEmpty().WithMessage(Errors.WrittenContent.BookPathCannotBeEmpty.Description);
RuleFor(x => x.Metadata)
.NotNull().WithMessage(Errors.Metadata.MetadataCannotBeNull.Description)
.ChildRules(metadata =>
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs
index 85fe67f8..a70060c9 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs
@@ -2,12 +2,16 @@
using ErrorOr;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Mediator;
+using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
///
-/// Query for getting all books.
+/// Query for getting all the books of a media library.
///
-public record class GetBooksQuery() : IRequest>>;
+/// The Id of the media library whose books are retrieved.
+public record GetBooksQuery(
+ Guid LibraryId
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs
index 826ddac7..6f1af200 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs
@@ -41,8 +41,8 @@ public class GetBooksQueryHandler : IRequestHandler();
- // get all books from the book repository
- ErrorOr> getBooksResult = await bookRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
+ // get all books of the media library from the book repository
+ ErrorOr> getBooksResult = await bookRepository.GetByLibraryIdAsync(request.LibraryId, cancellationToken).ConfigureAwait(false);
return getBooksResult.Match(result => ErrorOrFactory.From(getBooksResult.Value.ToResponses()), errors => errors);
}
}
diff --git a/src/Lumina.Contracts/DTO/Common/GenreDto.cs b/src/Lumina.Contracts/DTO/Common/GenreDto.cs
index 2841eb1f..40fd0745 100644
--- a/src/Lumina.Contracts/DTO/Common/GenreDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/GenreDto.cs
@@ -7,7 +7,7 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a genre.
///
-/// Gets the name of the genre.
+/// The name of the genre.
[DebuggerDisplay("Name: {Name}")]
public record GenreDto(
string? Name
diff --git a/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs b/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs
index a3db4e05..b0f702cd 100644
--- a/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs
@@ -7,9 +7,9 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for language information.
///
-/// Gets the ISO code of the language (e.g., "en" for English). Required.
-/// Gets the name of the language in English. Required.
-/// Gets the native name of the language (e.g., "Español" for Spanish). Optional.
+/// The ISO code of the language (e.g., "en" for English). Required.
+/// The name of the language in English. Required.
+/// The native name of the language (e.g., "Español" for Spanish). Optional.
[DebuggerDisplay("LanguageName: {LanguageName}")]
public record LanguageInfoDto(
string? LanguageCode,
diff --git a/src/Lumina.Contracts/DTO/Common/RatingDto.cs b/src/Lumina.Contracts/DTO/Common/RatingDto.cs
index df956380..16694782 100644
--- a/src/Lumina.Contracts/DTO/Common/RatingDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/RatingDto.cs
@@ -7,9 +7,9 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a rating.
///
-/// Gets the rating value.
-/// Gets the maximum possible rating value.
-/// Gets the number of votes that contributed to the rating.
+/// The rating value.
+/// The maximum possible rating value.
+/// The number of votes that contributed to the rating.
[DebuggerDisplay("{Value}/{MaxValue}")]
public abstract record RatingDto(
decimal? Value,
diff --git a/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs b/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs
index 34b314b0..7738b2e2 100644
--- a/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs
@@ -8,12 +8,12 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a release information.
///
-/// Gets the original release date of the content. Optional.
-/// Gets the original release year of the content. Optional.
-/// Gets the re-release date of the content. Optional.
-/// Gets the re-release year of the content. Optional.
-/// Gets the country where the content was released. Optional.
-/// Gets the version or edition of the content's release. Optional.
+/// The original release date of the content. Optional.
+/// The original release year of the content. Optional.
+/// The re-release date of the content. Optional.
+/// The re-release year of the content. Optional.
+/// The country where the content was released. Optional.
+/// The version or edition of the content's release. Optional.
[DebuggerDisplay("OriginalReleaseDate: {OriginalReleaseDate}")]
public record ReleaseInfoDto(
DateOnly? OriginalReleaseDate,
diff --git a/src/Lumina.Contracts/DTO/Common/TagDto.cs b/src/Lumina.Contracts/DTO/Common/TagDto.cs
index b2d1e834..45ecc898 100644
--- a/src/Lumina.Contracts/DTO/Common/TagDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/TagDto.cs
@@ -7,7 +7,7 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a tag.
///
-/// Gets the name of the tag.
+/// The name of the tag.
[DebuggerDisplay("Name: {Name}")]
public record TagDto(
string? Name
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs
index a6c2b4e1..d46fa0c9 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs
@@ -2,7 +2,8 @@
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
@@ -12,6 +13,8 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
///
/// Represents a request to add a book.
///
+/// The Id of the media library this book belongs to. Required.
+/// The file system path of the book. Required.
/// Written content metadata of the book. Required.
/// The format of the book (e.g., Hardcover, Paperback). Optional.
/// The edition of the book. Optional.
@@ -31,6 +34,8 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
/// The list of ratings for this book. Required.
[DebuggerDisplay("Title: {Metadata.Title}")]
public record AddBookRequest(
+ Guid LibraryId,
+ string Path,
WrittenContentMetadataDto? Metadata,
BookFormat? Format,
string? Edition,
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequest.cs
new file mode 100644
index 00000000..cbfb36f0
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Represents a request to get the books of a media library.
+///
+/// The Id of the media library whose books are retrieved. Required.
+[DebuggerDisplay("LibraryId: {LibraryId}")]
+public record GetBooksRequest(
+ Guid LibraryId
+);
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs
index 0a67e27e..483b7579 100644
--- a/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs
@@ -2,7 +2,7 @@
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -14,6 +14,8 @@ namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibr
/// Represents a book response.
///
/// The id of the book.
+/// The Id of the media library this book belongs to.
+/// The file system path of the book.
/// Written content metadata of the book.
/// The format of the book (e.g., Hardcover, Paperback), if applicable.
/// The edition of the book, if applicable.
@@ -31,11 +33,16 @@ namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibr
/// The list of ISBN (International Standard Book Number) of the book.
/// The list of media contributors (actors, directors, etc) starring in this book.
/// The list of ratings for this book.
+/// The status of the metadata enrichment of the book.
+/// The date and time when the metadata of the book was last enriched, if applicable.
+/// The name of the plugin that enriched the metadata of the book, if applicable.
/// The date and time when the book was created.
/// The optional date and time when the book was updated.
[DebuggerDisplay("Title: {Metadata.Title}")]
public record BookResponse(
Guid Id,
+ Guid LibraryId,
+ string Path,
WrittenContentMetadataDto Metadata,
BookFormat? Format,
string? Edition,
@@ -53,6 +60,9 @@ public record BookResponse(
List? ISBNs,
List? Contributors,
List? Ratings,
+ MetadataStatus MetadataStatus,
+ DateTime? LastMetadataUpdateUtc,
+ string? MetadataProvider,
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
diff --git a/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs
index 438cc6a1..0ad36b8a 100644
--- a/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs
+++ b/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs
@@ -130,6 +130,23 @@ public class BookConfiguration : IEntityTypeConfiguration
.HasColumnOrder(28);
builder.Property(book => book.AppleBooksId)
.HasColumnOrder(29);
+ builder.Property(book => book.LibraryId)
+ .IsRequired()
+ .HasColumnOrder(36);
+ builder.Property(book => book.Path)
+ .IsRequired()
+ .HasMaxLength(2048)
+ .HasColumnOrder(37);
+ builder.Property(book => book.MetadataStatus)
+ .HasConversion()
+ .HasMaxLength(20)
+ .IsRequired()
+ .HasColumnOrder(38);
+ builder.Property(book => book.LastMetadataUpdateUtc)
+ .HasColumnOrder(39);
+ builder.Property(book => book.MetadataProvider)
+ .HasMaxLength(100)
+ .HasColumnOrder(40);
builder.Property(book => book.CreatedOnUtc)
.HasColumnOrder(30);
builder.Property(book => book.UpdatedOnUtc)
@@ -219,6 +236,9 @@ public class BookConfiguration : IEntityTypeConfiguration
builder.Property(book => book.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(35);
+
+ builder.HasIndex(book => new { book.LibraryId, book.Path });
+ builder.HasIndex(book => new { book.LibraryId, book.MetadataStatus });
}
}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.Designer.cs
new file mode 100644
index 00000000..fd0489a7
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.Designer.cs
@@ -0,0 +1,1048 @@
+//
+using System;
+using Lumina.DataAccess.Core.UoW;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations
+{
+ [DbContext(typeof(LuminaDbContext))]
+ [Migration("20260809171050_AddsBookLibraryAndPathAndMetadataStatus")]
+ partial class AddsBookLibraryAndPathAndMetadataStatus
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.0");
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("GenreId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "GenreId");
+
+ b.HasIndex("GenreId");
+
+ b.ToTable("BookGenres", (string)null);
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("TagId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "TagId");
+
+ b.HasIndex("TagId");
+
+ b.ToTable("BookTags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("PermissionName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Permissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("RoleId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("RoleId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("RolePermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("UserId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("UserPermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("UserId", "RoleId")
+ .IsUnique();
+
+ b.ToTable("UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Genres", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Tags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b =>
+ {
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("LastWriteTimeUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.HasKey("LibraryId", "Path");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("DirectoryScanFingerprints", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CoverImage")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("DownloadMetadataFromWeb")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(6);
+
+ b.Property("IsEnabled")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(4);
+
+ b.Property("IsLocked")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("LibraryType")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("ShouldSaveMetadataInMediaDirectories")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("ShouldSkipUnchangedDirectoriesDuringScan")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(8);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Libraries", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("LibraryId", "Status", "CreatedOnUtc")
+ .IsDescending(true, false, true);
+
+ b.ToTable("LibraryScans", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b =>
+ {
+ b.Property("LibraryScanId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasMaxLength(24)
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("FileSize")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("Ticks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.HasKey("LibraryScanId", "Path");
+
+ b.HasIndex("Path");
+
+ b.HasIndex("ContentHash", "FileSize", "Path");
+
+ b.ToTable("LibraryScanResults", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanSnapshotEntity", b =>
+ {
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("FileSize")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Ticks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.HasKey("LibraryId", "Path");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("LibraryScanSnapshots", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanStagingResultsEntity", b =>
+ {
+ b.Property("LibraryScanId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("IsNew")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("NeedsRehash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(6);
+
+ b.Property("PreviousContentHash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("Size")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("Ticks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.HasKey("LibraryScanId", "Path");
+
+ b.HasIndex("LibraryScanId", "NeedsRehash");
+
+ b.ToTable("LibraryScanStagingResults", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ASIN")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(21);
+
+ b.Property("AppleBooksId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(29);
+
+ b.Property("BarnesAndNobleId")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(28);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(33);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(32);
+
+ b.Property("Description")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("Edition")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("Format")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("GoodreadsId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(22);
+
+ b.Property("GoogleBooksId")
+ .HasMaxLength(12)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(27);
+
+ b.Property("LCCN")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(23);
+
+ b.Property("LanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("LanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("LanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("LastMetadataUpdateUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(39);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(36);
+
+ b.Property("LibraryThingId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(26);
+
+ b.Property("MetadataProvider")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(40);
+
+ b.Property("MetadataStatus")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(38);
+
+ b.Property("OCLCNumber")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.Property("OpenLibraryId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(25);
+
+ b.Property("OriginalLanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("OriginalLanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("OriginalLanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("OriginalReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("OriginalReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("OriginalTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("PageCount")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(17);
+
+ b.Property("Path")
+ .IsRequired()
+ .HasMaxLength(2048)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(37);
+
+ b.Property("Publisher")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("ReReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("ReReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("ReleaseCountry")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("ReleaseVersion")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(35);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(34);
+
+ b.Property("VolumeNumber")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(20);
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId", "MetadataStatus");
+
+ b.HasIndex("LibraryId", "Path");
+
+ b.ToTable("Books", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("TempPassword")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("TempPasswordCreated")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("TotpSecret")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("Username")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.HasKey("Id");
+
+ b.HasIndex("Username")
+ .IsUnique();
+
+ b.ToTable("Users", (string)null);
+ });
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
+ .WithMany()
+ .HasForeignKey("BookId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null)
+ .WithMany()
+ .HasForeignKey("GenreId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
+ .WithMany()
+ .HasForeignKey("BookId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null)
+ .WithMany()
+ .HasForeignKey("TagId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
+ .WithMany("RolePermissions")
+ .HasForeignKey("PermissionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
+ .WithMany("RolePermissions")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Permission");
+
+ b.Navigation("Role");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
+ .WithMany("UserPermissions")
+ .HasForeignKey("PermissionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("UserPermissions")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Permission");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
+ .WithMany("UserRoles")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithOne("UserRole")
+ .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", "UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", null)
+ .WithMany()
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("Libraries")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b1.Property("Path")
+ .IsRequired()
+ .HasMaxLength(260)
+ .HasColumnType("TEXT")
+ .HasColumnName("Path");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("LibraryId");
+
+ b1.ToTable("LibraryContentLocations", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("LibraryId");
+ });
+
+ b.Navigation("ContentLocations");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", "Library")
+ .WithMany("LibraryScans")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("LibraryScans")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", "LibraryScan")
+ .WithMany("LibraryScanResults")
+ .HasForeignKey("LibraryScanId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("LibraryScan");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanSnapshotEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", "Library")
+ .WithMany()
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanStagingResultsEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", null)
+ .WithMany()
+ .HasForeignKey("LibraryScanId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b1.Property("MaxValue")
+ .HasColumnType("decimal(3,2)");
+
+ b1.Property("Source")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b1.Property("Value")
+ .HasColumnType("decimal(3,2)");
+
+ b1.Property("VoteCount")
+ .HasColumnType("INTEGER");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("BookId");
+
+ b1.ToTable("BookRatings", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("BookId");
+ });
+
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b1.Property("Format")
+ .IsRequired()
+ .HasMaxLength(6)
+ .HasColumnType("TEXT");
+
+ b1.Property("Value")
+ .IsRequired()
+ .HasMaxLength(13)
+ .HasColumnType("TEXT")
+ .HasColumnName("ISBN");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("BookId");
+
+ b1.ToTable("BookISBNs", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("BookId");
+ });
+
+ b.Navigation("ISBNs");
+
+ b.Navigation("Ratings");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Navigation("RolePermissions");
+
+ b.Navigation("UserPermissions");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Navigation("RolePermissions");
+
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.Navigation("LibraryScans");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.Navigation("LibraryScanResults");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
+ {
+ b.Navigation("Libraries");
+
+ b.Navigation("LibraryScans");
+
+ b.Navigation("UserPermissions");
+
+ b.Navigation("UserRole");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.cs b/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.cs
new file mode 100644
index 00000000..56067913
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.cs
@@ -0,0 +1,98 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations
+{
+ ///
+ public partial class AddsBookLibraryAndPathAndMetadataStatus : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "LastMetadataUpdateUtc",
+ table: "Books",
+ type: "TEXT",
+ nullable: true)
+ .Annotation("Relational:ColumnOrder", 39);
+
+ migrationBuilder.AddColumn(
+ name: "LibraryId",
+ table: "Books",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new Guid("00000000-0000-0000-0000-000000000000"))
+ .Annotation("Relational:ColumnOrder", 36);
+
+ migrationBuilder.AddColumn(
+ name: "MetadataProvider",
+ table: "Books",
+ type: "TEXT",
+ maxLength: 100,
+ nullable: true)
+ .Annotation("Relational:ColumnOrder", 40);
+
+ migrationBuilder.AddColumn(
+ name: "MetadataStatus",
+ table: "Books",
+ type: "TEXT",
+ maxLength: 20,
+ nullable: false,
+ defaultValue: "")
+ .Annotation("Relational:ColumnOrder", 38);
+
+ migrationBuilder.AddColumn(
+ name: "Path",
+ table: "Books",
+ type: "TEXT",
+ maxLength: 2048,
+ nullable: false,
+ defaultValue: "")
+ .Annotation("Relational:ColumnOrder", 37);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Books_LibraryId_MetadataStatus",
+ table: "Books",
+ columns: new[] { "LibraryId", "MetadataStatus" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Books_LibraryId_Path",
+ table: "Books",
+ columns: new[] { "LibraryId", "Path" });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_Books_LibraryId_MetadataStatus",
+ table: "Books");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Books_LibraryId_Path",
+ table: "Books");
+
+ migrationBuilder.DropColumn(
+ name: "LastMetadataUpdateUtc",
+ table: "Books");
+
+ migrationBuilder.DropColumn(
+ name: "LibraryId",
+ table: "Books");
+
+ migrationBuilder.DropColumn(
+ name: "MetadataProvider",
+ table: "Books");
+
+ migrationBuilder.DropColumn(
+ name: "MetadataStatus",
+ table: "Books");
+
+ migrationBuilder.DropColumn(
+ name: "Path",
+ table: "Books");
+ }
+ }
+}
diff --git a/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs b/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs
index be6e0c3e..7f577a6e 100644
--- a/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs
+++ b/src/Lumina.DataAccess/Core/Repositories/Books/BookRepository.cs
@@ -4,8 +4,10 @@ using Lumina.Application.Common.DataAccess.Repositories.Books;
using Lumina.Application.Common.DataAccess.Entities.Common;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.DataAccess.Core.UoW;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Errors;
using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -59,6 +61,21 @@ internal sealed class BookRepository : IBookRepository
return Result.Created;
}
+ ///
+ /// Gets a book by its Id.
+ ///
+ /// The Id of the book to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a , or an error.
+ public async Task> GetByIdAsync(Guid id, CancellationToken cancellationToken)
+ {
+ return await _luminaDbContext.Books
+ .Include(book => book.Tags)
+ .Include(book => book.Genres)
+ .Include(book => book.ISBNs)
+ .FirstOrDefaultAsync(book => book.Id == id, cancellationToken).ConfigureAwait(false);
+ }
+
///
/// Gets all books.
///
@@ -72,4 +89,91 @@ internal sealed class BookRepository : IBookRepository
.Include(book => book.ISBNs)
.ToListAsync(cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// 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.
+ public async Task>> GetByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken)
+ {
+ return await _luminaDbContext.Books
+ .Include(book => book.Tags)
+ .Include(book => book.Genres)
+ .Include(book => book.ISBNs)
+ .Where(book => book.LibraryId == libraryId)
+ .ToListAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// 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.
+ public async Task> GetByPathAsync(Guid libraryId, string path, CancellationToken cancellationToken)
+ {
+ return await _luminaDbContext.Books
+ .Include(book => book.Tags)
+ .Include(book => book.Genres)
+ .Include(book => book.ISBNs)
+ .FirstOrDefaultAsync(book => book.LibraryId == libraryId && book.Path == path, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// 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.
+ public async Task>> GetBooksNeedingMetadataAsync(Guid libraryId, string? lastPath, int pageSize, CancellationToken cancellationToken)
+ {
+ return await _luminaDbContext.Books
+ .Include(book => book.Tags)
+ .Include(book => book.Genres)
+ .Include(book => book.ISBNs)
+ .Where(book => book.LibraryId == libraryId
+ && book.MetadataStatus != MetadataStatus.Enriched
+ && (lastPath == null || book.Path.CompareTo(lastPath) > 0))
+ .OrderBy(book => book.Path)
+ .Take(pageSize)
+ .ToListAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// 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.
+ public async Task> GetBooksNeedingMetadataCountAsync(Guid libraryId, CancellationToken cancellationToken)
+ {
+ return await _luminaDbContext.Books
+ .CountAsync(book => book.LibraryId == libraryId && book.MetadataStatus != MetadataStatus.Enriched, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Updates a book.
+ ///
+ /// The book to update.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ public async Task> UpdateAsync(BookEntity data, CancellationToken cancellationToken)
+ {
+ BookEntity? foundBook = await _luminaDbContext.Books
+ .Include(book => book.Tags)
+ .Include(book => book.Genres)
+ .Include(book => book.ISBNs)
+ .FirstOrDefaultAsync(book => book.Id == data.Id, cancellationToken).ConfigureAwait(false);
+ if (foundBook is null)
+ return Errors.WrittenContent.BookNotFound;
+ // update the scalar properties of the book
+ _luminaDbContext.Entry(foundBook).CurrentValues.SetValues(data);
+ return Result.Updated;
+ }
}
diff --git a/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryScanSnapshotRepository.cs b/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryScanSnapshotRepository.cs
index 69efca97..d76d00ac 100644
--- a/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryScanSnapshotRepository.cs
+++ b/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryScanSnapshotRepository.cs
@@ -59,6 +59,27 @@ internal sealed class LibraryScanSnapshotRepository : ILibraryScanSnapshotReposi
return deletedPaths.ToList();
}
+ ///
+ /// Gets the paths of all the media library scan snapshot items of the media library identified by .
+ ///
+ /// The unique identifier of the library whose media library scan snapshot item paths are retrieved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a collection of media library scan snapshot item paths, or an error.
+ public async Task>> GetPathsAsync(Guid libraryId, CancellationToken cancellationToken)
+ {
+ await using SqliteConnection connection = await OpenConnectionAsync(cancellationToken).ConfigureAwait(false);
+ const string GET_PATHS_SQL = """
+ SELECT snapshot.Path
+ FROM LibraryScanSnapshots AS snapshot
+ WHERE snapshot.LibraryId = @libraryId;
+ """;
+
+ CommandDefinition command = new(GET_PATHS_SQL, new { libraryId }, cancellationToken: cancellationToken);
+
+ IEnumerable paths = await connection.QueryAsync(command).ConfigureAwait(false);
+ return paths.ToList();
+ }
+
///
/// Atomically applies the results of the current scan to the storage medium, by replacing the media library scan snapshot of the previous scan with the snapshot of the current scan.
/// The operation updates the changed media library scan snapshot items, deletes the ones that are no longer present on disk, adds audit entries for all changed, new and deleted items,
diff --git a/src/Lumina.Domain/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/Book.cs b/src/Lumina.Domain/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/Book.cs
index 4ca32fac..deba69ec 100644
--- a/src/Lumina.Domain/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/Book.cs
+++ b/src/Lumina.Domain/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/Book.cs
@@ -1,11 +1,12 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -28,6 +29,31 @@ public sealed class Book : AggregateRoot
///
public WrittenContentMetadata Metadata { get; private set; }
+ ///
+ /// Gets the Id of the media library this book belongs to.
+ ///
+ public LibraryId LibraryId { get; private set; }
+
+ ///
+ /// Gets the file system path of the book.
+ ///
+ public string Path { get; private set; }
+
+ ///
+ /// Gets the status of the metadata enrichment of the book.
+ ///
+ public MetadataStatus MetadataStatus { get; private set; }
+
+ ///
+ /// Gets the date and time when the metadata of the book was last enriched, if applicable.
+ ///
+ public Optional LastMetadataUpdateUtc { get; private set; }
+
+ ///
+ /// Gets the name of the plugin that enriched the metadata of the book, if applicable.
+ ///
+ public Optional MetadataProvider { get; private set; }
+
///
/// Gets the format of the book (e.g., Hardcover, Paperback), if applicable.
///
@@ -133,6 +159,8 @@ public sealed class Book : AggregateRoot
/// The list of ratings for the book.
private Book(
BookId id,
+ LibraryId libraryId,
+ string path,
WrittenContentMetadata metadata,
Optional format,
Optional edition,
@@ -154,7 +182,12 @@ public sealed class Book : AggregateRoot
List ratings) : base(id)
{
Id = id;
+ LibraryId = libraryId;
+ Path = path;
Metadata = metadata;
+ MetadataStatus = MetadataStatus.Pending;
+ LastMetadataUpdateUtc = Optional.None();
+ MetadataProvider = Optional.None();
Format = format;
Edition = edition;
VolumeNumber = volumeNumber;
@@ -178,6 +211,8 @@ public sealed class Book : AggregateRoot
///
/// Creates a new instance of the class.
///
+ /// The Id of the media library this book belongs to.
+ /// The file system path of the book.
/// The metadata of the book.
/// The optional format of the book (e.g., Hardcover, Paperback).
/// The optional edition of the book.
@@ -199,6 +234,8 @@ public sealed class Book : AggregateRoot
/// An containing either a successfully created , or an error message.
///
public static ErrorOr Create(
+ LibraryId libraryId,
+ string path,
WrittenContentMetadata metadata,
Optional format,
Optional edition,
@@ -220,6 +257,8 @@ public sealed class Book : AggregateRoot
// TODO: enforce invariants
return new Book(
BookId.CreateUnique(),
+ libraryId,
+ path,
metadata,
format,
edition,
@@ -246,6 +285,8 @@ public sealed class Book : AggregateRoot
/// Creates a new instance of the , with a pre-existing .
///
/// The object representing the unique identifier of the book.
+ /// The Id of the media library this book belongs to.
+ /// The file system path of the book.
/// The metadata of the book.
/// The optional format of the book (e.g., Hardcover, Paperback).
/// The optional edition of the book.
@@ -270,6 +311,8 @@ public sealed class Book : AggregateRoot
///
public static ErrorOr Create(
BookId id,
+ LibraryId libraryId,
+ string path,
WrittenContentMetadata metadata,
Optional format,
Optional edition,
@@ -293,6 +336,8 @@ public sealed class Book : AggregateRoot
// TODO: enforce invariants
return new Book(
id,
+ libraryId,
+ path,
metadata,
format,
edition,
@@ -314,4 +359,87 @@ public sealed class Book : AggregateRoot
ratings
);
}
+
+ ///
+ /// Marks the metadata of the book as enriched by the provided .
+ ///
+ /// The name of the metadata provider that enriched the book.
+ /// The date and time when the metadata of the book was enriched.
+ public void MarkMetadataAsEnriched(string providerName, DateTime lastUpdateUtc)
+ {
+ MetadataProvider = providerName;
+ LastMetadataUpdateUtc = lastUpdateUtc;
+ MetadataStatus = MetadataStatus.Enriched;
+ }
+
+ ///
+ /// Marks the metadata enrichment of the book as failed.
+ ///
+ public void MarkMetadataAsFailed()
+ {
+ MetadataStatus = MetadataStatus.Failed;
+ }
+
+ ///
+ /// Applies the enriched and the related fields to the book, marking its metadata as enriched by the provided .
+ ///
+ /// The enriched metadata of the book.
+ /// The optional format of the book.
+ /// The optional edition of the book.
+ /// The optional volume or book number in the series.
+ /// The optional series the book is part of.
+ /// The optional ASIN of the book.
+ /// The optional Goodreads ID of the book.
+ /// The optional LCCN of the book.
+ /// The optional OCLC Number of the book.
+ /// The optional Open Library ID of the book.
+ /// The optional LibraryThing ID of the book.
+ /// The optional Google Books ID of the book.
+ /// The optional Barnes & Noble ID of the book.
+ /// The optional Apple Books ID of the book.
+ /// The list of ISBNs of the book.
+ /// The list of ratings for the book.
+ /// The name of the metadata provider that enriched the book.
+ /// The date and time when the metadata was enriched.
+ public void ApplyEnrichedMetadata(
+ WrittenContentMetadata metadata,
+ Optional format,
+ Optional edition,
+ Optional volumeNumber,
+ Optional series,
+ Optional asin,
+ Optional goodreadsId,
+ Optional lccn,
+ Optional oclcNumber,
+ Optional openLibraryId,
+ Optional libraryThingId,
+ Optional googleBooksId,
+ Optional barnesAndNobleId,
+ Optional appleBooksId,
+ List isbns,
+ List ratings,
+ string providerName,
+ DateTime lastUpdateUtc)
+ {
+ Metadata = metadata;
+ Format = format;
+ Edition = edition;
+ VolumeNumber = volumeNumber;
+ Series = series;
+ ASIN = asin;
+ GoodreadsId = goodreadsId;
+ LCCN = lccn;
+ OCLCNumber = oclcNumber;
+ OpenLibraryId = openLibraryId;
+ LibraryThingId = libraryThingId;
+ GoogleBooksId = googleBooksId;
+ BarnesAndNobleId = barnesAndNobleId;
+ AppleBooksId = appleBooksId;
+ // replace the contents of the collections in place, preserving the readonly reference invariants of the aggregate
+ _isbns.Clear();
+ _isbns.AddRange(isbns);
+ _ratings.Clear();
+ _ratings.AddRange(ratings);
+ MarkMetadataAsEnriched(providerName, lastUpdateUtc);
+ }
}
diff --git a/src/Lumina.Domain/Core/BoundedContexts/WrittenContentLibraryBoundedContext/ExternalIdentifiers/LibraryManagementBoundedContext/LibraryAggregate/LibraryId.cs b/src/Lumina.Domain/Core/BoundedContexts/WrittenContentLibraryBoundedContext/ExternalIdentifiers/LibraryManagementBoundedContext/LibraryAggregate/LibraryId.cs
new file mode 100644
index 00000000..be9d5da1
--- /dev/null
+++ b/src/Lumina.Domain/Core/BoundedContexts/WrittenContentLibraryBoundedContext/ExternalIdentifiers/LibraryManagementBoundedContext/LibraryAggregate/LibraryId.cs
@@ -0,0 +1,48 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.Common.Models.Core;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
+
+///
+/// Value Object for the Id of a media library, duplicated from the LibraryManagement bounded context to keep the cross bounded context references decoupled.
+///
+[DebuggerDisplay("{Value}")]
+public sealed class LibraryId : EntityId
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The value representing this object.
+ private LibraryId(Guid value) : base(value)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The created instance.
+ public static LibraryId CreateUnique()
+ {
+ return new LibraryId(Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a new instance of the class, from a pre-existing .
+ ///
+ /// The value used to create the instance.
+ /// The created instance.
+ public static LibraryId Create(Guid value)
+ {
+ return new LibraryId(value);
+ }
+
+ ///
+ public override IEnumerable