UNPKG

@sitecore/sc-contenthub-webclient-sdk

Version:

Sitecore Content Hub WebClient SDK.

99 lines (98 loc) 5.59 kB
import { Nullable, NullableResultPromise } from "../base-types"; import { IEntity } from "../contracts/base/entity"; import { IEntityLoadConfiguration } from "../contracts/querying/entity-load-configuration"; import { IEntityQueryResult } from "../contracts/querying/entity-query-result"; import { IEntitySearchAfterResult } from "../contracts/querying/entity-search-after-result"; import { IIdQueryResult } from "../contracts/querying/id-query-result"; import { Query } from "../contracts/querying/query"; import { IQueryLoadConfiguration } from "../contracts/querying/query-load-configuration"; import { SearchAfterQuery } from "../contracts/querying/search-after-query"; import { IContentHubClient } from "./content-hub-client"; import { IExtendedContentHubClient } from "./extended-client"; import { CancelCallback } from "./internal-client"; export interface IQueryingClient { singleAsync(query: Query, loadConfiguration?: IEntityLoadConfiguration, cancelCallback?: CancelCallback): NullableResultPromise<IEntity>; singleIdAsync(query: Query, cancelCallback?: CancelCallback): NullableResultPromise<number>; queryAsync(query: Query, loadConfiguration?: Nullable<IEntityLoadConfiguration>, cancelCallback?: CancelCallback): Promise<IEntityQueryResult>; queryIdsAsync(query: Query, cancelCallback?: CancelCallback): Promise<IIdQueryResult>; searchAfterAsync(query: SearchAfterQuery, cancelCallback?: CancelCallback): Promise<IEntitySearchAfterResult>; } /** * Contains functionality to query and scroll for entities. */ declare abstract class QueryingClientBase implements IQueryingClient { protected readonly _client: IContentHubClient; constructor(client: IContentHubClient); /** * Gets a single entity that matches the query. * * @param query - The query to execute * @param loadConfiguration - The load configuration. If it is null, then {@link EntityLoadConfiguration#Default} will be used * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided * @returns The entity that matches the query or null if there are no results. */ singleAsync(query: Query, loadConfiguration?: IEntityLoadConfiguration, cancelCallback?: CancelCallback): NullableResultPromise<IEntity>; /** * Gets a the id of the entity that matches the query. * * @param query - The query to execute * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided * @returns The id of the entity that matches the query or null if there are no results. */ singleIdAsync(query: Query, cancelCallback?: CancelCallback): NullableResultPromise<number>; /** * Retrieves entities matching the query. * * @param query - The query to execute * @param loadConfiguration - The load configuration. If it is null, then {@link EntityLoadConfiguration#Default} will be used * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided */ abstract queryAsync(query: Query, loadConfiguration?: Nullable<IEntityLoadConfiguration>, cancelCallback?: CancelCallback): Promise<IEntityQueryResult>; /** * Retrieves the ids of entities matching the query. * * @param query - The query to execute * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided */ abstract queryIdsAsync(query: Query, cancelCallback?: CancelCallback): Promise<IIdQueryResult>; /** * Retrieves entities matching the query. * * @param query - The query to execute * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided */ abstract searchAfterAsync(query: SearchAfterQuery, cancelCallback?: CancelCallback): Promise<IEntitySearchAfterResult>; protected resolveLoadConfiguration(query: Query, loadConfiguration?: IEntityLoadConfiguration): Nullable<IQueryLoadConfiguration>; } /** * Contains functionality to query and scroll for entities. */ export declare class QueryingClient extends QueryingClientBase { private readonly _extendedClient; private readonly _mapper; private readonly _schemaQuerying; constructor(client: IExtendedContentHubClient); /** * Retrieves entities matching the query. * * @param query - The query to execute * @param loadConfiguration - The load configuration. If it is null, then {@link EntityLoadConfiguration#Default} will be used * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided */ queryAsync(query: Query, loadConfiguration?: Nullable<IEntityLoadConfiguration>, cancelCallback?: CancelCallback): Promise<IEntityQueryResult>; /** * Retrieves the ids of entities matching the query. * * @param query - The query to execute * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided */ queryIdsAsync(query: Query, cancelCallback?: CancelCallback): Promise<IIdQueryResult>; /** * Retrieves entities matching the query. * * @param query - The query to execute * @param cancelCallback - A {@link CancelCallback} that will be placed in an Axios {@link CancelToken} if provided */ searchAfterAsync(query: SearchAfterQuery, cancelCallback?: CancelCallback): Promise<IEntitySearchAfterResult>; } export {};