UNPKG

@sitecore/sc-contenthub-webclient-sdk

Version:

Sitecore Content Hub WebClient SDK.

254 lines (253 loc) 15.1 kB
import { Nullable, NullableResultPromise } from "./base-types"; import { AggregateLoadOption } from "./clients"; import { IExtendedContentHubClient } from "./clients/extended-client"; import { ViewMode } from "./contracts/base/view-mode"; import CultureInfo from "./culture-info"; import Link from "./link"; export interface ILinkHelper { /** * Extracts the name of a data source from the specified link. * @param link - The link to extract the name from * @returns The name as extracted from the link. If the link doesn't contain a name, null is returned. */ nameFromDataSourceAsync(link: Link): NullableResultPromise<string>; /** * Creates a link to the data source with the specified name. * @param name - The name of the data source to link to * @returns A link to the data source with the specified name. */ dataSourceToLinkAsync(name: string): Promise<Link>; /** * Creates a link to the data sources endpoint. * @returns A link to the data sources endpoint. */ dataSourcesLinkAsync(): Promise<Readonly<Link>>; /** * Extracts the name of an entity definition from the specified link. * @param link - The link to extract the name from * @returns The name as extracted from the link. If the link doesn't contain a name, null is returned. */ nameFromDefinitionAsync(link: Link): NullableResultPromise<string>; /** * Extracts the names of the specified entity definition links. * @param links - The links to extract the names from * @returns The names as extracted from the links. If the link doesn't contain a name, null is returned. */ namesFromDefinitionsAsync(links: Array<Link>): Promise<Array<Nullable<string>>>; /** * Creates a link to the entity definition with the specified name. * @param name - The name of the entity definition to link to * @param includeConditionalMembers - [Optional] Include conditional members * @param loadPermissions - [Optional] Load permissions for the definitions * @returns A link to the entity definition with the specified name. */ definitionToLinkAsync(name: string, includeConditionalMembers?: boolean, loadPermissions?: boolean): Promise<Link>; /** * Creates a link to the entity definition with the specified id. * @param id - The id of the entity definition to link to * @param includeConditionalMembers - [Optional] Include conditional members * @param loadPermissions - [Optional] Load permissions for the definitions * @returns A link to the entity definition with the specified id. */ definitionToLinkAsync(id: number, includeConditionalMembers?: boolean, loadPermissions?: boolean): Promise<Link>; definitionToLinkAsync(param: string | number, includeConditionalMembers?: boolean, loadPermissions?: boolean): Promise<Link>; /** * Creates a link to the entity definition with the specified name. * @param name - The name of the entity definition to link to * @param includeConditionalMembers - [Optional] Include conditional members * @param loadPermissions - [Optional] Load permissions for the definitions * @returns A link to the entity definition with the specified name. */ definitionToLinkV2Async(name: string, includeConditionalMembers?: boolean, loadPermissions?: boolean): Promise<Link>; /** *Creates links to the specified entity definitions by name. * @param names - The names of the entity definitions to include in the result * @param skip - [Optional] Number of results to skip * @param take - [Optional] Number of results to fetch * @param includeConditionalMembers - [Optional] Include conditional members * @param viewMode - [Optional] Select appropriate ViewMode * @param loadPermissions - [Optional] Load permissions for the definitions * @param excludeTaxonomyDefinitions - [Optional] Exclude taxonomy definitions from the result * @param excludeSystemOwnedDefinitions - [Optional] Exclude system owned definitions from the result * @returns Link to the entity definitions with the specified names. */ definitionsToLinkAsync(names: Nullable<Array<string>>, skip?: number, take?: number, includeConditionalMembers?: boolean, viewMode?: ViewMode, loadPermissions?: boolean, excludeTaxonomyDefinitions?: boolean, excludeSystemOwnedDefinitions?: boolean): Promise<Link>; /** * Creates links to the specified entity definitions by id. * @param ids - The ids of the entity definitions to include in the result * @param skip - [Optional] Number of results to skip * @param take - [Optional] Number of results to fetch * @param includeConditionalMembers - [Optional] Include conditional members * @param viewMode - [Optional] Select appropriate ViewMode * @param loadPermissions - [Optional] Load permissions for the definitions * @param excludeTaxonomyDefinitions - [Optional] Exclude taxonomy definitions from the result * @param excludeSystemOwnedDefinitions - [Optional] Exclude system owned definitions from the result * @returns Link to the entity definitions with the specified ids. */ definitionsToLinkAsync(ids: Nullable<Array<number>>, skip?: number, take?: number, includeConditionalMembers?: boolean, viewMode?: ViewMode, loadPermissions?: boolean, excludeTaxonomyDefinitions?: boolean, excludeSystemOwnedDefinitions?: boolean): Promise<Link>; /** * Creates a link to the entity definitions endpoint. * @param skip - [Optional] Number of results to skip * @param take - [Optional] Number of results to fetch * @param includeConditionalMembers - [Optional] Include conditional members * @param viewMode - [Optional] Select appropriate ViewMode * @param loadPermissions - [Optional] Load permissions for the definitions * @param excludeTaxonomyDefinitions - [Optional] Exclude taxonomy definitions from the result * @param excludeSystemOwnedDefinitions - [Optional] Exclude system owned definitions from the result * @param filter - [Optional] Filter to apply to the result * @param definitionsToLoadByName - [Optional] Comma separated list of entity definition names to load * @param definitionsToLoadById - [Optional] Comma separated list of entity definition ids to load * @param excludeLightDefinitions - [Optional] Exclude light definitions from the result * @returns Link to the entity definitions included in this batch. */ definitionsLinkAsync(skip?: number, take?: number, includeConditionalMembers?: boolean, viewMode?: ViewMode, loadPermissions?: boolean, excludeTaxonomyDefinitions?: boolean, excludeSystemOwnedDefinitions?: boolean, filter?: string, definitionsToLoadByName?: string, definitionsToLoadById?: string, excludeLightDefinitions?: boolean): Promise<Link>; relationToLinkAsync(id: number, name: string): Promise<Link>; /** * Extracts the id of an entity from the specified link. * @param link - The link to extract the name from * @returns The id as extracted from the link. If the link doesn't contain an id, null is returned. */ idFromEntityAsync(link: Link): NullableResultPromise<number>; /** * Extracts the id of entities from the specified links. * @param links - The links to extract the names from * @returns The ids as extracted from the links. */ idsFromEntitiesAsync(links: Array<Link>): Promise<Array<number>>; /** * Creates a link to the entity with the specified id. * @param id - The id of the entity to link to * @param culture - [Optional] Culture for the entity * @returns A link to the entity with the specified id. */ entityToLinkAsync(id: number, culture?: Nullable<CultureInfo>): Promise<Link>; /** * Creates a link to the entity with the specified identifier. * @param identifier - The identifier of the entity to link to * @returns A link to the entity with the specified identifier. */ entityToLinkAsync(identifier: string): Promise<Link>; /** * Creates links to the entities with the specified ids. * @param ids - The ids of the entities to link to * @returns Link to the entities with the specified ids. */ entitiesToLinksAsync(ids: Array<number>): Promise<Array<Link>>; /** * Extracts the identifier of an entity from the specified * @param link - The link to extract the identifier from * @returns The identifier as extracted from the link. If the link doesn't contain an identifier, null is returned. */ identifierFromEntityAsync(link: Link): NullableResultPromise<string>; /** * Creates a link to the entities endpoint. * @returns Link to entities endpoint. */ entitiesLinkAsync(): Promise<Readonly<Link>>; /** * Creates a link to the permissions for entity endpoint. * @param id - The entity id * @returns Link to the permissions for entity. */ permissionsForEntityToLinkAsync(id: number): Promise<Link>; /** * Creates a link to the permissions for entity endpoint. * @param id - The entity id * @param userId - The user id * @returns Link to the permissions for entity. */ explainUserPermissionsForEntityToLinkAsync(id: number, userId: number): Promise<Link>; /** * Creates a link to the copy entities endpoint. * @param id - The entity id * @returns Link to the copy entities endpoint. */ copyEntityToLinkAsync(id: number): Promise<Link>; /** * Gets the link to set the password of the specified user. * * @param userId - The id of the user * @returns Link to set user password. */ setUserPasswordToLinkAsync(userId: number): Promise<Link>; /** * Gets the link to reset the password of the specified user. * * @param userId - The id of the user * @returns Link to reset user password. */ resetPasswordToLinkAsync(userId: number): Promise<Link>; policyToLinkAsync(id: number): Promise<Link>; idFromPolicyAsync(link: Link): NullableResultPromise<number>; /** * Generates a link to a command. * * @param namespace - The name of the folder containing the command * @param command - The name of the command * @returns Link for the command. */ commandToLinkAsync(namespace: string, command: string): Promise<Link>; sendConfirmationMailToLinkAsync(userId: number): Promise<Link>; sendNotificationToLinkAsync(notificationType: string): Promise<Link>; /** * Generate a link to an aggregate resource. * @param aggregateName - The name of the aggregate * @param entityId - The entity id for which to get the aggregate * @param culture - Culture for the entity * @param options - Can optionally configure what needs to be loaded from the aggregates (everything will be loaded by default except for permissions) * @returns Link to the aggregate resource. */ aggregateToLinkAsync(aggregateName: string, entityId: number, culture?: CultureInfo, options?: AggregateLoadOption): Promise<Link>; /** * Generate a link to a page name. * @param pageName - The name or id of the page * @param culture - Culture of the page * @param entityId - The current entity id (Optional) */ pageResourceToLinkAsync(page: string | number, culture: CultureInfo, entityId?: number): Promise<Link>; searchLinkAsync(): Promise<Readonly<Link>>; allFacetsAsync(): Promise<Readonly<Link>>; createUploadToLinkAsync(): Promise<Readonly<Link>>; finalizeUploadToLinkAsync(): Promise<Readonly<Link>>; settingByNameLink(categoryName: string, settingName: string): Promise<Readonly<Link>>; } export declare class LinkHelper implements ILinkHelper { private readonly _client; constructor(client: IExtendedContentHubClient); nameFromDataSourceAsync(link: Link): NullableResultPromise<string>; dataSourceToLinkAsync(name: string): Promise<Link>; dataSourcesLinkAsync(): Promise<Readonly<Link>>; nameFromDefinitionAsync(link: Link): NullableResultPromise<string>; namesFromDefinitionsAsync(links: Array<Link>): Promise<Array<Nullable<string>>>; definitionToLinkAsync(param: string | number, includeConditionalMembers?: boolean, loadPermissions?: boolean): Promise<Link>; definitionToLinkV2Async(name: string, includeConditionalMembers?: boolean, loadPermissions?: boolean): Promise<Link>; definitionsToLinkAsync(values: Nullable<Array<string>> | Nullable<Array<number>>, skip?: number, take?: number, includeConditionalMembers?: boolean, viewMode?: ViewMode, loadPermissions?: boolean, excludeTaxonomyDefinitions?: boolean, excludeSystemOwnedDefinitions?: boolean): Promise<Link>; definitionsLinkAsync(skip?: number, take?: number, includeConditionalMembers?: boolean, viewMode?: ViewMode, loadPermissions?: boolean, excludeTaxonomyDefinitions?: boolean, excludeSystemOwnedDefinitions?: boolean, filter?: string, definitionsToLoadByName?: string, definitionsToLoadById?: string, excludeLightDefinitions?: boolean): Promise<Link>; idFromEntityAsync(link: Link): Promise<number | null>; idsFromEntitiesAsync(links: Array<Link>): Promise<Array<number>>; entityToLinkAsync(param: number | string, culture?: Nullable<CultureInfo>): Promise<Link>; relationToLinkAsync(id: number, name: string): Promise<Link>; entitiesToLinksAsync(ids: Array<number>): Promise<Array<Link>>; identifierFromEntityAsync(link: Link): NullableResultPromise<string>; entitiesLinkAsync(): Promise<Readonly<Link>>; permissionsForEntityToLinkAsync(id: number): Promise<Link>; explainUserPermissionsForEntityToLinkAsync(id: number, userId: number): Promise<Link>; copyEntityToLinkAsync(id: number): Promise<Link>; setUserPasswordToLinkAsync(userId: number): Promise<Link>; resetPasswordToLinkAsync(userId: number): Promise<Link>; policyToLinkAsync(id: number): Promise<Link>; idFromPolicyAsync(link: Link): NullableResultPromise<number>; commandToLinkAsync(namespace: string, command: string): Promise<Link>; sendConfirmationMailToLinkAsync(userId: number): Promise<Link>; sendNotificationToLinkAsync(notificationType: string): Promise<Link>; aggregateToLinkAsync(aggregateName: string, entityId: number, culture?: CultureInfo, { loadPermissions, loadOptionLists, loadSettings, loadEntities, loadDefinitions, }?: AggregateLoadOption): Promise<Link>; pageResourceToLinkAsync(page: string | number, culture: CultureInfo, entityId?: number): Promise<Link>; searchLinkAsync(): Promise<Readonly<Link>>; allFacetsAsync(): Promise<Readonly<Link>>; settingByNameLink(categoryName: string, settingName: string): Promise<Readonly<Link>>; createUploadToLinkAsync(): Promise<Readonly<Link>>; finalizeUploadToLinkAsync(): Promise<Readonly<Link>>; private getVariableValueAsync; private bindAsync; private static applyEntityDefinitionVariables; }