Adds deletion and restore for music library items.

This commit is contained in:
BinaryAlley committed 2026-11-15 18:53:10 +02:00
1 parent 98515dc5e8
commit f9ad8b2fc5
224 files changed
+22384 -1360

No files matched your search

@@ -24,13 +24,61 @@ public interface IAlbumRepository : IRepository<AlbumEntity>,
IDeleteByIdRepositoryAction<Guid>
{
/// <summary>
/// Gets all the albums of the artist identified by <paramref name="artistId"/>.
/// Gets the albums of the artist identified by <paramref name="artistId"/> that are not soft deleted.
/// </summary>
/// <param name="artistId">The Id of the artist whose albums are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="AlbumEntity"/>, or an error.</returns>
Task<Result<IReadOnlyList<AlbumEntity>>> GetByArtistIdAsync(Guid artistId, CancellationToken cancellationToken);
/// <summary>
/// Gets all the albums of the artist identified by <paramref name="artistId"/>, whether they are soft deleted or not.
/// </summary>
/// <param name="artistId">The Id of the artist whose albums are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="AlbumEntity"/>, or an error.</returns>
Task<Result<IReadOnlyList<AlbumEntity>>> GetByArtistIdIncludingDeletedAsync(Guid artistId, CancellationToken cancellationToken);
/// <summary>
/// Gets the album identified by <paramref name="id"/>, whether it is soft deleted or not, without loading its navigation properties.
/// </summary>
/// <param name="id">The Id of the album to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the <see cref="AlbumEntity"/>, or an error.</returns>
Task<Result<AlbumEntity?>> GetIncludingDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Gets the soft deleted album identified by <paramref name="id"/>, when its artist is not soft deleted.
/// </summary>
/// <param name="id">The Id of the soft deleted album to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted <see cref="AlbumEntity"/>, <see langword="null"/> when the album does not exist, is not soft deleted, or its artist is soft deleted, or an error.</returns>
Task<Result<AlbumEntity?>> GetSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Gets the soft deleted albums of the media library identified by <paramref name="libraryId"/>, whose artist is not soft deleted.
/// </summary>
/// <param name="libraryId">The Id of the media library whose soft deleted albums are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted albums, or an error.</returns>
Task<Result<IReadOnlyList<AlbumEntity>>> GetSoftDeletedByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Soft deletes the album identified by <paramref name="id"/>, without removing its stored metadata or artwork, when another visible album of its artist remains.
/// </summary>
/// <param name="id">The Id of the album to soft delete.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> SoftDeleteByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Restores the soft deleted album identified by <paramref name="id"/>.
/// </summary>
/// <param name="id">The Id of the album to restore.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> RestoreSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Gets the lightweight read models of the albums of the artist identified by <paramref name="artistId"/>, projecting only the fields needed to display the albums in a card-based grid or a list.
/// </summary>
@@ -86,4 +86,36 @@ public interface IArtistRepository : IRepository<ArtistEntity>,
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> DeleteByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Gets the soft deleted artist identified by <paramref name="id"/>.
/// </summary>
/// <param name="id">The Id of the soft deleted artist to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted <see cref="ArtistEntity"/>, <see langword="null"/> when the artist does not exist or is not soft deleted, or an error.</returns>
Task<Result<ArtistEntity?>> GetSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Gets the soft deleted artists of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose soft deleted artists are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted artists, or an error.</returns>
Task<Result<IReadOnlyList<ArtistEntity>>> GetSoftDeletedByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Soft deletes the artist identified by <paramref name="id"/>, without removing its stored metadata or artwork.
/// </summary>
/// <param name="id">The Id of the artist to soft delete.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> SoftDeleteByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Restores the soft deleted artist identified by <paramref name="id"/>.
/// </summary>
/// <param name="id">The Id of the artist to restore.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> RestoreSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
}
@@ -33,13 +33,21 @@ public interface ITrackRepository : IRepository<TrackEntity>,
Task<Result<IReadOnlyCollection<string>>> GetExistingPathsAsync(Guid libraryId, IReadOnlyCollection<string> paths, CancellationToken cancellationToken);
/// <summary>
/// Gets all the tracks of the album identified by <paramref name="albumId"/>.
/// Gets the tracks of the album identified by <paramref name="albumId"/> that are not soft deleted.
/// </summary>
/// <param name="albumId">The Id of the album whose tracks are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="TrackEntity"/>, or an error.</returns>
Task<Result<IReadOnlyList<TrackEntity>>> GetByAlbumIdAsync(Guid albumId, CancellationToken cancellationToken);
/// <summary>
/// Gets all the tracks of the album identified by <paramref name="albumId"/>, whether they are soft deleted or not.
/// </summary>
/// <param name="albumId">The Id of the album whose tracks are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="TrackEntity"/>, or an error.</returns>
Task<Result<IReadOnlyList<TrackEntity>>> GetByAlbumIdIncludingDeletedAsync(Guid albumId, CancellationToken cancellationToken);
/// <summary>
/// Gets the lightweight read models of the tracks of the album identified by <paramref name="albumId"/>, projecting only the fields needed to display the tracks of an album.
/// </summary>
@@ -146,4 +154,36 @@ public interface ITrackRepository : IRepository<TrackEntity>,
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the existing tracks, or an error.</returns>
Task<Result<IReadOnlyList<TrackEntity>>> GetByIdsAsync(IReadOnlyCollection<Guid> trackIds, bool shouldIncludeNavigationProperties, CancellationToken cancellationToken);
/// <summary>
/// Gets the soft deleted track identified by <paramref name="id"/>, when its album and artist are not soft deleted.
/// </summary>
/// <param name="id">The Id of the soft deleted track to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted <see cref="TrackEntity"/>, <see langword="null"/> when the track does not exist, is not soft deleted, or its album or artist is soft deleted, or an error.</returns>
Task<Result<TrackEntity?>> GetSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Gets the soft deleted tracks of the media library identified by <paramref name="libraryId"/>, whose album and artist are not soft deleted.
/// </summary>
/// <param name="libraryId">The Id of the media library whose soft deleted tracks are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the soft deleted tracks, or an error.</returns>
Task<Result<IReadOnlyList<TrackEntity>>> GetSoftDeletedByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Soft deletes the track identified by <paramref name="id"/>, without removing its stored metadata or artwork.
/// </summary>
/// <param name="id">The Id of the track to soft delete.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> SoftDeleteByIdAsync(Guid id, CancellationToken cancellationToken);
/// <summary>
/// Restores the soft deleted track identified by <paramref name="id"/>.
/// </summary>
/// <param name="id">The Id of the track to restore.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> RestoreSoftDeletedByIdAsync(Guid id, CancellationToken cancellationToken);
}