// // Copyright (c) PlaceholderCompany. All rights reserved. // #nullable disable #pragma warning disable CS1591 using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Jellyfin.Data.Enums; using Jellyfin.Database.Implementations.Entities; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Persistence; /// /// Provides an interface to implement an Item repository. /// public interface IItemRepository { /// /// Deletes the item. /// /// The identifier to delete. void DeleteItem(params IReadOnlyList ids); /// /// Deletes the item asynchronously. /// /// The identifier to delete. /// The cancellation token. /// A task representing the async operation. Task DeleteItemAsync(IReadOnlyList ids, CancellationToken cancellationToken = default); /// /// Saves the items. /// /// The items. /// The cancellation token. void SaveItems(IReadOnlyList items, CancellationToken cancellationToken); /// /// Saves the items asynchronously. /// /// The items. /// The cancellation token. /// A task representing the async operation. Task SaveItemsAsync(IReadOnlyList items, CancellationToken cancellationToken = default); Task SaveImagesAsync(BaseItem item, CancellationToken cancellationToken = default); /// /// Reattaches the user data to the item. /// /// The item. /// The cancellation token. /// A task that represents the asynchronous reattachment operation. Task ReattachUserDataAsync(BaseItem item, CancellationToken cancellationToken); /// /// Retrieves the item. /// /// The id. /// BaseItem. BaseItem RetrieveItem(Guid id); /// /// Retrieves the item asynchronously. /// /// The id. /// The cancellation token. /// A task representing the async operation. Task RetrieveItemAsync(Guid id, CancellationToken cancellationToken = default); /// /// Gets the items. /// /// The query. /// QueryResult<BaseItem>. QueryResult GetItems(InternalItemsQuery filter); /// /// Gets the items asynchronously. /// /// The query. /// The cancellation token. /// QueryResult<BaseItem>. Task> GetItemsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); /// /// Gets the item ids list. /// /// The query. /// List<Guid>. IReadOnlyList GetItemIdsList(InternalItemsQuery filter); /// /// Gets the item ids list asynchronously. /// /// The query. /// The cancellation token. /// List<Guid>. Task> GetItemIdsListAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); /// /// Gets the item list. /// /// The query. /// List<BaseItem>. IReadOnlyList GetItemList(InternalItemsQuery filter); /// /// Gets the item list asynchronously. /// /// The query. /// The cancellation token. /// List<BaseItem>. Task> GetItemListAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); /// /// Gets the item list. Used mainly by the Latest api endpoint. /// /// The query. /// Collection Type. /// List<BaseItem>. IReadOnlyList GetLatestItemList(InternalItemsQuery filter, CollectionType collectionType); /// /// Gets the item list asynchronously. Used mainly by the Latest api endpoint. /// /// The query. /// Collection Type. /// The cancellation token. /// A task representing the async operation. Task> GetLatestItemListAsync(InternalItemsQuery filter, CollectionType collectionType, CancellationToken cancellationToken = default); /// /// Gets the list of series presentation keys for next up. /// /// The query. /// The minimum date for a series to have been most recently watched. /// The list of keys. IReadOnlyList GetNextUpSeriesKeys(InternalItemsQuery filter, DateTime dateCutoff); /// /// Gets the list of series presentation keys for next up asynchronously. /// /// The query. /// The minimum date for a series to have been most recently watched. /// The cancellation token. /// A task representing the async operation. Task> GetNextUpSeriesKeysAsync(InternalItemsQuery filter, DateTime dateCutoff, CancellationToken cancellationToken = default); /// /// Updates the inherited values. /// void UpdateInheritedValues(); int GetCount(InternalItemsQuery filter); /// /// Gets the count of items asynchronously. /// /// The query. /// The cancellation token. /// The count. Task GetCountAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); ItemCounts GetItemCounts(InternalItemsQuery filter); /// /// Gets the item counts asynchronously. /// /// The query. /// The cancellation token. /// The item counts. Task GetItemCountsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery filter); Task> GetGenresAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery filter); Task> GetMusicGenresAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery filter); Task> GetStudiosAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery filter); Task> GetArtistsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery filter); Task> GetAlbumArtistsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery filter); Task> GetAllArtistsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default); IReadOnlyList GetMusicGenreNames(); Task> GetMusicGenreNamesAsync(CancellationToken cancellationToken = default); IReadOnlyList GetStudioNames(); Task> GetStudioNamesAsync(CancellationToken cancellationToken = default); IReadOnlyList GetGenreNames(); Task> GetGenreNamesAsync(CancellationToken cancellationToken = default); IReadOnlyList GetAllArtistNames(); Task> GetAllArtistNamesAsync(CancellationToken cancellationToken = default); /// /// Checks if an item has been persisted to the database. /// /// The id to check. /// True if the item exists, otherwise false. Task ItemExistsAsync(Guid id); /// /// Gets a value indicating wherever all children of the requested Id has been played. /// /// The userdata to check against. /// The Top id to check. /// Whever the check should be done recursive. Warning expensive operation. /// A value indicating whever all children has been played. bool GetIsPlayed(User user, Guid id, bool recursive); /// /// Gets all artist matches from the db. /// /// The names of the artists. /// A map of the artist name and the potential matches. IReadOnlyDictionary FindArtists(IReadOnlyList artistNames); }