using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Api.Management.Models.Entities;
namespace Umbraco.Cms.Api.Management.Services.Entities;
public interface IUserStartNodeEntitiesService
{
///
/// Calculates the applicable root entities for a given object type for users without root access.
///
/// The object type.
/// The calculated start node IDs for the user.
/// A list of root entities for the user.
///
/// The returned entities may include entities that outside of the user start node scope, but are needed to
/// for browsing to the actual user start nodes. These entities will be marked as "no access" entities.
///
/// This method does not support pagination, because it must load all entities explicitly in order to calculate
/// the correct result, given that user start nodes can be descendants of root nodes. Consumers need to apply
/// pagination to the result if applicable.
///
IEnumerable RootUserAccessEntities(UmbracoObjectTypes umbracoObjectType, int[] userStartNodeIds);
///
/// Calculates the applicable child entities for a given object type for users without root access.
///
/// The object type.
/// The calculated start node paths for the user.
/// The key of the parent.
/// The number of applicable children to skip.
/// The number of applicable children to take.
/// The ordering to apply when fetching and paginating the children.
/// The total number of applicable children available.
/// A list of child entities applicable for the user.
///
/// The returned entities may include entities that outside of the user start node scope, but are needed to
/// for browsing to the actual user start nodes. These entities will be marked as "no access" entities.
///
IEnumerable ChildUserAccessEntities(
UmbracoObjectTypes umbracoObjectType,
string[] userStartNodePaths,
Guid parentKey,
int skip,
int take,
Ordering ordering,
out long totalItems)
{
totalItems = 0;
return [];
}
///
/// Calculates the applicable child entities from a list of candidate child entities for users without root access.
///
/// The candidate child entities to filter (i.e. entities fetched with ).
/// The calculated start node paths for the user.
/// A list of child entities applicable entities for the user.
///
/// The returned entities may include entities that outside of the user start node scope, but are needed to
/// for browsing to the actual user start nodes. These entities will be marked as "no access" entities.
/// Some candidate entities may be filtered out if they are not applicable for the user scope.
///
IEnumerable ChildUserAccessEntities(IEnumerable candidateChildren, string[] userStartNodePaths);
///
/// Calculates the applicable sibling entities for a given object type for users without root access.
///
/// The object type.
/// The calculated start node paths for the user.
/// The key of the target.
/// The number of applicable siblings to retrieve before the target.
/// The number of applicable siblings to retrieve after the target.
/// The ordering to apply when fetching and paginating the children.
/// A list of sibling entities applicable for the user.
///
/// The returned entities may include entities that outside of the user start node scope, but are needed to
/// for browsing to the actual user start nodes. These entities will be marked as "no access" entities.
///
IEnumerable SiblingUserAccessEntities(
UmbracoObjectTypes umbracoObjectType,
string[] userStartNodePaths,
Guid targetKey,
int before,
int after,
Ordering ordering) => [];
///
/// Calculates the access level of a collection of entities for users without root access.
///
/// The entities.
/// The calculated start node paths for the user.
/// The access level for each entity.
IEnumerable UserAccessEntities(IEnumerable entities, string[] userStartNodePaths);
}