using System;
using System.Linq;
using Jellyfin.Database.Implementations;
using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Persistence;
///
/// Provides shared query-building methods used by extracted item services.
/// Implemented by BaseItemRepository.
///
public interface IItemQueryHelpers
{
///
/// Translates an into EF Core filter expressions.
///
/// The base queryable to filter.
/// The database context.
/// The query filter.
/// The filtered queryable.
IQueryable TranslateQuery(
IQueryable baseQuery,
JellyfinDbContext context,
InternalItemsQuery filter);
///
/// Prepares a base query for items from the context.
///
/// The database context.
/// The query filter.
/// The prepared queryable.
IQueryable PrepareItemQuery(JellyfinDbContext context, InternalItemsQuery filter);
///
/// Applies user access filtering (library access, parental controls, tags) to a query.
///
/// The database context.
/// The base queryable to filter.
/// The query filter containing access settings.
/// The access-filtered queryable.
IQueryable ApplyAccessFiltering(
JellyfinDbContext context,
IQueryable baseQuery,
InternalItemsQuery filter);
///
/// Applies navigation property includes to a query based on filter options.
///
/// The queryable to apply navigations to.
/// The query filter.
/// The queryable with navigation includes.
IQueryable ApplyNavigations(
IQueryable dbQuery,
InternalItemsQuery filter);
///
/// Applies ordering to a query based on filter options.
///
/// The queryable to order.
/// The query filter.
/// The database context.
/// The ordered queryable.
IQueryable ApplyOrder(
IQueryable query,
InternalItemsQuery filter,
JellyfinDbContext context);
///
/// Builds a query for descendants of an ancestor with user access filtering applied.
///
/// The database context.
/// The query filter.
/// The ancestor item ID.
/// The filtered descendant queryable.
IQueryable BuildAccessFilteredDescendantsQuery(
JellyfinDbContext context,
InternalItemsQuery filter,
Guid ancestorId);
///
/// Deserializes a into a .
///
/// The database entity.
/// Whether to skip JSON deserialization.
/// The deserialized item, or null.
BaseItem? DeserializeBaseItem(BaseItemEntity entity, bool skipDeserialization = false);
///
/// Prepares a filter query by adjusting limits and virtual item settings.
///
/// The query to prepare.
void PrepareFilterQuery(InternalItemsQuery query);
}