Adds favorites and aligns playlist and favorite pagination

This commit is contained in:
BinaryAlley committed 2026-10-22 20:27:07 +03:00
1 parent 2e9f7d8496
commit 525ac1348d
193 files changed
+10944 -643

No files matched your search

@@ -1,38 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
/// <summary>
/// Data transfer object for a paginated collection of lightweight album elements, together with pagination metadata.
/// </summary>
[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
public class PaginatedMusicAlbumLiteDto
{
/// <summary>
/// Gets or sets the collection of lightweight album elements associated with this instance.
/// </summary>
public IReadOnlyList<MusicAlbumLiteDto> Data { get; set; } = [];
/// <summary>
/// Gets or sets the current page number in a paginated collection.
/// </summary>
public int CurrentPage { get; set; }
/// <summary>
/// Gets or sets the number of items to include per page in paginated results.
/// </summary>
public int PerPage { get; set; }
/// <summary>
/// Gets or sets the total number of elements available in the paginated result set.
/// </summary>
public int Count { get; set; }
/// <summary>
/// Gets or sets the total number of pages based on elements available in the result set and per page.
/// </summary>
public int NumberOfPages { get; set; }
}
@@ -1,38 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
/// <summary>
/// Data transfer object for a paginated collection of lightweight music artist elements, together with pagination metadata.
/// </summary>
[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
public class PaginatedMusicArtistLiteDto
{
/// <summary>
/// Gets or sets the collection of lightweight music artist elements associated with this instance.
/// </summary>
public IReadOnlyList<MusicArtistLiteDto> Data { get; set; } = [];
/// <summary>
/// Gets or sets the current page number in a paginated collection.
/// </summary>
public int CurrentPage { get; set; }
/// <summary>
/// Gets or sets the number of items to include per page in paginated results.
/// </summary>
public int PerPage { get; set; }
/// <summary>
/// Gets or sets the total number of elements available in the paginated result set.
/// </summary>
public int Count { get; set; }
/// <summary>
/// Gets or sets the total number of pages based on elements available in the result set and per page.
/// </summary>
public int NumberOfPages { get; set; }
}
@@ -1,38 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
/// <summary>
/// Data transfer object for a paginated collection of lightweight track elements, together with pagination metadata.
/// </summary>
[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
public class PaginatedMusicTrackLiteDto
{
/// <summary>
/// Gets or sets the collection of lightweight track elements associated with this instance.
/// </summary>
public IReadOnlyList<MusicTrackLiteDto> Data { get; set; } = [];
/// <summary>
/// Gets or sets the current page number in a paginated collection.
/// </summary>
public int CurrentPage { get; set; }
/// <summary>
/// Gets or sets the number of items to include per page in paginated results.
/// </summary>
public int PerPage { get; set; }
/// <summary>
/// Gets or sets the total number of elements available in the paginated result set.
/// </summary>
public int Count { get; set; }
/// <summary>
/// Gets or sets the total number of pages based on elements available in the result set and per page.
/// </summary>
public int NumberOfPages { get; set; }
}
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for a page of elements together with its pagination metadata.
/// </summary>
/// <typeparam name="T">The type of the elements of the page.</typeparam>
/// <param name="Data">The elements of the requested page.</param>
/// <param name="CurrentPage">The one based number of the returned page.</param>
/// <param name="PerPage">The number of elements requested per page.</param>
/// <param name="Count">The total number of elements that match the filter, even when only a page of them is returned.</param>
/// <param name="NumberOfPages">The total number of pages that match the filter.</param>
[DebuggerDisplay("CurrentPage: {CurrentPage}; PerPage: {PerPage}; Count: {Count}")]
public sealed record PaginatedDto<T>(
List<T> Data,
int CurrentPage,
int PerPage,
int Count,
int NumberOfPages
);
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Favorites;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Favorites;
/// <summary>
/// Data transfer object for a favorite of the current user.
/// </summary>
/// <param name="Id">The Id of the favorite.</param>
/// <param name="MediaKind">The kind of the favorited media item.</param>
/// <param name="MediaItemId">The Id of the favorited media item.</param>
/// <param name="FavoritedOnUtc">The date and time when the media item was favorited.</param>
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; MediaItemId: {MediaItemId}")]
public sealed record FavoriteDto(
Guid Id,
FavoriteMediaKind MediaKind,
Guid MediaItemId,
DateTime FavoritedOnUtc
);
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Favorites;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Favorites;
/// <summary>
/// Data transfer object for a favorite of the current user together with the display details of the media item it references.
/// </summary>
/// <param name="MediaKind">The kind of the favorited media item.</param>
/// <param name="MediaItemId">The Id of the favorited media item.</param>
/// <param name="IsAvailable">Whether the media item still exists and can be accessed by the user. When <see langword="false"/>, every display field is empty.</param>
/// <param name="LibraryId">The Id of the media library that contains the media item, or an empty Guid when the item is not available.</param>
/// <param name="Title">The title of the media item, or an empty string when the item is not available.</param>
/// <param name="CollectionId">The Id of the collection that contains the media item, or an empty Guid when there is none.</param>
/// <param name="CollectionTitle">The title of the collection that contains the media item, or an empty string when there is none.</param>
/// <param name="CreatorId">The Id of the creator of the media item, or an empty Guid when there is none.</param>
/// <param name="CreatorName">The name of the creator of the media item, or an empty string when there is none.</param>
/// <param name="CoverPath">The path of the cover art of the media item, if available.</param>
[DebuggerDisplay("MediaKind: {MediaKind}; MediaItemId: {MediaItemId}")]
public sealed record FavoriteItemDto(
FavoriteMediaKind MediaKind,
Guid MediaItemId,
bool IsAvailable,
Guid LibraryId,
string Title,
Guid CollectionId,
string CollectionTitle,
Guid CreatorId,
string CreatorName,
string? CoverPath
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Favorites;
/// <summary>
/// Data transfer object that tells which of the checked media items are favorites of the current user.
/// </summary>
/// <param name="FavoritedMediaItemIds">The Ids, among the checked ones, of the media items that are favorites of the current user.</param>
[DebuggerDisplay("Favorited: {FavoritedMediaItemIds.Count}")]
public sealed record FavoriteStatusDto(
List<Guid> FavoritedMediaItemIds
);
@@ -1,38 +0,0 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
/// <summary>
/// Data transfer object for a paginated collection of lightweight book elements, together with pagination metadata.
/// </summary>
[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
public class PaginatedBookLiteDto
{
/// <summary>
/// Gets or sets the collection of lightweight book elements associated with this instance.
/// </summary>
public IReadOnlyList<BookLiteDto> Data { get; set; } = [];
/// <summary>
/// Gets or sets the current page number in a paginated collection.
/// </summary>
public int CurrentPage { get; set; }
/// <summary>
/// Gets or sets the number of items to include per page in paginated results.
/// </summary>
public int PerPage { get; set; }
/// <summary>
/// Gets or sets the total number of elements available in the paginated result set.
/// </summary>
public int Count { get; set; }
/// <summary>
/// Gets or sets the total number of pages based on elements available in the result set and per page.
/// </summary>
public int NumberOfPages { get; set; }
}
@@ -1,21 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Common;
using Lumina.Presentation.Web.Common.Enums.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Playlists;
/// <summary>
/// Data transfer object for a playlist together with its ordered entries.
/// Data transfer object for a playlist together with a page of its ordered entries.
/// </summary>
/// <param name="Id">The Id of the playlist.</param>
/// <param name="Name">The name of the playlist.</param>
/// <param name="Description">The description of the playlist, if applicable.</param>
/// <param name="Type">The kind of media the playlist holds.</param>
/// <param name="EntryCount">The number of entries the playlist holds, even when only a window of them is returned.</param>
/// <param name="Entries">The ordered entries of the requested window of the playlist.</param>
/// <param name="Entries">The page of ordered entries of the playlist, together with its pagination metadata.</param>
/// <param name="CreatedOnUtc">The date and time when the playlist was created.</param>
/// <param name="UpdatedOnUtc">The date and time when the playlist was last updated, if applicable.</param>
[DebuggerDisplay("Id: {Id}; Name: {Name}; Entries: {Entries.Count}")]
@@ -24,8 +23,7 @@ public sealed record PlaylistDto(
string Name,
string? Description,
PlaylistType Type,
int EntryCount,
List<PlaylistEntryDto> Entries,
PaginatedDto<PlaylistEntryDto> Entries,
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Enums.Favorites;
/// <summary>
/// Enumeration for the kinds of media item that can be marked as a favorite.
/// </summary>
[DebuggerDisplay("{ToString()}")]
public enum FavoriteMediaKind
{
/// <summary>
/// A favorite that references an artist of a music library.
/// </summary>
MusicArtist,
/// <summary>
/// A favorite that references an album of a music library.
/// </summary>
MusicAlbum,
/// <summary>
/// A favorite that references a track of a music library.
/// </summary>
MusicTrack,
/// <summary>
/// A favorite that references a book of a book library.
/// </summary>
Book,
/// <summary>
/// A favorite that references a video file. Planned: video libraries are not catalogued yet, so this kind cannot be favorited.
/// </summary>
Video,
/// <summary>
/// A favorite that references a photo. Planned: photo libraries are not catalogued yet, so this kind cannot be favorited.
/// </summary>
Photo,
}
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Favorites;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Favorites;
/// <summary>
/// Represents a request for marking a media item as a favorite of the current user.
/// </summary>
/// <param name="MediaKind">The kind of the media item to favorite. Required.</param>
/// <param name="MediaItemId">The Id of the media item to favorite. Required.</param>
[DebuggerDisplay("MediaKind: {MediaKind}; MediaItemId: {MediaItemId}")]
public record AddFavoriteRequest(
FavoriteMediaKind? MediaKind,
Guid? MediaItemId
);
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Favorites;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Favorites;
/// <summary>
/// Represents a request for finding out which media items of one kind are favorites of the current user.
/// </summary>
/// <param name="MediaKind">The kind of the media items to check. Required.</param>
/// <param name="MediaItemIds">The Ids of the media items to check, from 1 to 100. Required.</param>
[DebuggerDisplay("MediaKind: {MediaKind}")]
public record GetFavoriteStatusRequest(
FavoriteMediaKind? MediaKind,
List<Guid>? MediaItemIds
);
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Favorites;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Favorites;
/// <summary>
/// Represents a request for getting a page of the favorites of the current user.
/// </summary>
/// <param name="MediaKind">The kind of media item to restrict the favorites to. Optional; every kind is returned when omitted.</param>
/// <param name="CurrentPage">The one based page of favorites to return. Optional; defaults to 1.</param>
/// <param name="PerPage">The number of favorites per page. Optional; defaults to 200.</param>
[DebuggerDisplay("MediaKind: {MediaKind}; CurrentPage: {CurrentPage}; PerPage: {PerPage}")]
public record GetFavoritesRequest(
FavoriteMediaKind? MediaKind,
int? CurrentPage,
int? PerPage
);
@@ -5,12 +5,12 @@ using System.Diagnostics;
namespace Lumina.Presentation.Web.Common.Requests.Playlists;
/// <summary>
/// Represents a request for getting a window of the entries of a playlist of the current user.
/// Represents a request for getting a page of the entries of a playlist of the current user.
/// </summary>
/// <param name="Offset">The zero based position of the first entry to return. Optional; defaults to 0.</param>
/// <param name="Limit">The maximum number of entries to return, from 1 to 1000. Optional; defaults to 200.</param>
[DebuggerDisplay("Offset: {Offset}; Limit: {Limit}")]
/// <param name="CurrentPage">The one based page of entries to return. Optional; defaults to 1.</param>
/// <param name="PerPage">The number of entries per page. Optional; defaults to 200.</param>
[DebuggerDisplay("CurrentPage: {CurrentPage}; PerPage: {PerPage}")]
public record GetPlaylistRequest(
int? Offset,
int? Limit
int? CurrentPage,
int? PerPage
);
@@ -0,0 +1,18 @@
namespace Lumina.Presentation.Web.Common.Routes;
/// <summary>
/// Class for the collection of remote API routes called by this Web application.
/// </summary>
public static partial class ApiRoutes
{
/// <summary>
/// Routes for the favorites endpoints of the remote API.
/// </summary>
public static class Favorites
{
public const string GET_FAVORITES = "users/me/favorites";
public const string ADD_FAVORITE = "users/me/favorites";
public const string REMOVE_FAVORITE = "users/me/favorites/{mediaKind}/{mediaItemId}";
public const string GET_FAVORITE_STATUS = "users/me/favorites/status";
}
}
@@ -0,0 +1,19 @@
namespace Lumina.Presentation.Web.Common.Routes;
/// <summary>
/// Class for the collection of routes defined in the Web application.
/// </summary>
public static partial class WebRoutes
{
/// <summary>
/// Routes for the favorites pages.
/// </summary>
public static class Favorites
{
public const string INDEX = "{culture}/favorites";
public const string GET_FAVORITES = "{culture}/favorites/api-get-favorites";
public const string GET_FAVORITE_STATUS = "{culture}/favorites/api-get-favorite-status";
public const string ADD_FAVORITE = "{culture}/favorites/api-add-favorite";
public const string REMOVE_FAVORITE = "{culture}/favorites/{mediaKind}/{mediaItemId}/api-remove-favorite";
}
}