Scopes books to a media library and tracks their metadata enrichment status

This commit is contained in:
BinaryAlley committed 2026-08-12 11:01:59 -07:00
1 parent 386d583a2b
commit f33817f2d2
48 files changed
+2038 -63

No files matched your search

@@ -5,7 +5,7 @@ using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using Lumina.Contracts.DTO.Common;
using Lumina.Domain.Common.Enums.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.DTO.MediaContributors;
using System;
@@ -28,6 +28,8 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
Description = "Creates a new book and returns its details, including the location of the newly created resource.";
ExampleRequest = new AddBookRequest(
LibraryId: Guid.NewGuid(),
Path: "/books/the-fellowship-of-the-ring.epub",
Metadata: new(
Title: "The Fellowship of the Ring",
OriginalTitle: "The Fellowship of the Ring",
@@ -179,6 +181,8 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
Response(201, "The new book is returned.", example:
new BookResponse(
Id: Guid.NewGuid(),
LibraryId: Guid.NewGuid(),
Path: "/books/the-fellowship-of-the-ring.epub",
Metadata: new(
Title: "The Fellowship of the Ring",
OriginalTitle: "The Fellowship of the Ring",
@@ -276,6 +280,9 @@ public class AddLibraryEndpointSummary : Summary<AddBookEndpoint, AddBookRequest
VoteCount: 87654
)
],
MetadataStatus: MetadataStatus.Pending,
LastMetadataUpdateUtc: default,
MetadataProvider: default,
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
)
@@ -1,7 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Presentation.Api.Common.Routes.Library.WrittenContentLibrary.BookLibrary;
using Lumina.Presentation.Api.Core.Endpoints.Common;
@@ -17,7 +19,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.B
/// <summary>
/// API endpoint for the <c>/books</c> route.
/// </summary>
public class GetBooksEndpoint : BaseEndpoint<EmptyRequest, IResult>
public class GetBooksEndpoint : BaseEndpoint<GetBooksRequest, IResult>
{
private readonly ISender _sender;
@@ -42,12 +44,13 @@ public class GetBooksEndpoint : BaseEndpoint<EmptyRequest, IResult>
}
/// <summary>
/// Gets the list of all books.
/// Gets the list of all the books of the media library identified by <paramref name="request"/>.
/// </summary>
/// <param name="request">The request containing the Id of the media library whose books are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
public override async Task<IResult> ExecuteAsync(GetBooksRequest request, CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<BookResponse>> result = await _sender.Send(new GetBooksQuery(), cancellationToken).ConfigureAwait(false);
ErrorOr<IEnumerable<BookResponse>> result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -4,7 +4,7 @@ using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.Common.Enums.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -31,6 +31,8 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint>
example: new BookResponse[] {
new(
Id: Guid.NewGuid(),
LibraryId: Guid.NewGuid(),
Path: "/books/the-fellowship-of-the-ring.epub",
Metadata: new(
Title: "The Fellowship of the Ring",
OriginalTitle: "The Fellowship of the Ring",
@@ -128,11 +130,16 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint>
VoteCount: 87654
)
],
MetadataStatus: MetadataStatus.Pending,
LastMetadataUpdateUtc: default,
MetadataProvider: default,
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
),
new(
Id: Guid.NewGuid(),
LibraryId: Guid.NewGuid(),
Path: "/books/the-two-towers.epub",
Metadata: new(
Title: "The Two Towers",
OriginalTitle: "The Two Towers",
@@ -229,6 +236,9 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint>
VoteCount: 90000
)
],
MetadataStatus: MetadataStatus.Pending,
LastMetadataUpdateUtc: default,
MetadataProvider: default,
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
)