kentico-cloud-delivery
Version:
Official Kentico Cloud Delivery SDK
177 lines (176 loc) • 6.78 kB
TypeScript
import { Observable } from 'rxjs';
import { IDeliveryClientConfig } from '../config';
import { IContentTypeQueryConfig, IHeader, IItemQueryConfig, IQueryConfig, IQueryParameter, ISDKInfo, ITaxonomyQueryConfig } from '../interfaces';
import { ResponseMapper } from '../mappers';
import { ContentItem, ElementResponses, ItemResponses, TaxonomyResponses, TypeResponses } from '../models';
import { IRichTextHtmlParser } from '../parser';
import { IBaseResponse } from '../services/http/models';
import { IDeliveryHttpService } from './http/idelivery-http-service';
export declare class QueryService {
/**
* Delivery client configuration
*/
protected config: IDeliveryClientConfig;
/**
* Http service for fetching data
*/
protected httpService: IDeliveryHttpService;
/**
* Used for manipulating with rich text HTML (required for Node / Browser support)
*/
private readonly richTextHtmlParser;
/**
* Information about the SDK
* This can contain information from both this & Node SDK for internal logging with 'SDKID' header
*/
protected sdkInfo: ISDKInfo;
/**
* Default number of retry attempts when user did not set any
*/
private readonly defaultRetryAttempts;
/**
* Excluded status code from retry functionality
*/
private readonly retryExcludedStatuses;
/**
* Header name for SDK usage
*/
private readonly sdkVersionHeader;
/**
* Default base Url to Kentico Delivery API
*/
private readonly defaultBaseDeliveryApiUrl;
/**
* Default preview url to Kentico Delivery API
*/
private readonly defaultPreviewDeliveryApiUrl;
/**
* Name of the header used when 'wait for loading new content' feature is used
*/
private readonly waitForLoadingNewContentHeader;
/**
* Service used to map responses (json) from Kentico cloud to strongly typed types
*/
protected responseMapper: ResponseMapper;
constructor(
/**
* Delivery client configuration
*/
config: IDeliveryClientConfig,
/**
* Http service for fetching data
*/
httpService: IDeliveryHttpService,
/**
* Used for manipulating with rich text HTML (required for Node / Browser support)
*/
richTextHtmlParser: IRichTextHtmlParser,
/**
* Information about the SDK
* This can contain information from both this & Node SDK for internal logging with 'SDKID' header
*/
sdkInfo: ISDKInfo);
/**
* Gets url based on the action, query configuration and options (parameters)
* @param action Action (= url part) that will be hit
* @param queryConfig Query configuration
* @param options Query options
*/
getUrl(action: string, queryConfig: IQueryConfig, options?: IQueryParameter[]): string;
/**
* Gets single item from given url
* @param url Url used to get single item
* @param queryConfig Query configuration
*/
getSingleItem<TItem extends ContentItem>(url: string, queryConfig: IItemQueryConfig): Observable<ItemResponses.DeliveryItemResponse<TItem>>;
/**
* Gets multiple items from given url
* @param url Url used to get multiple items
* @param queryConfig Query configuration
*/
getMultipleItems<TItem extends ContentItem>(url: string, queryConfig: IItemQueryConfig): Observable<ItemResponses.DeliveryItemListingResponse<TItem>>;
/**
* Gets single content type from given url
* @param url Url used to get single type
* @param queryConfig Query configuration
*/
getSingleType(url: string, queryConfig: IContentTypeQueryConfig): Observable<TypeResponses.DeliveryTypeResponse>;
/**
* Gets multiple content types from given url
* @param url Url used to get multiple types
* @param queryConfig Query configuration
*/
getMultipleTypes(url: string, queryConfig: IContentTypeQueryConfig): Observable<TypeResponses.DeliveryTypeListingResponse>;
/**
* Gets single taxonomy from given url
* @param url Url used to get single taxonomy
* @param queryConfig Query configuration
*/
getTaxonomy(url: string, queryConfig: ITaxonomyQueryConfig): Observable<TaxonomyResponses.TaxonomyResponse>;
/**
* Gets multiple taxonomies from given url
* @param url Url used to get multiple taxonomies
* @param queryConfig Query configuration
*/
getTaxonomies(url: string, queryConfig: ITaxonomyQueryConfig): Observable<TaxonomyResponses.TaxonomiesResponse>;
/**
* Gets single content type element from given url
* @param url Url used to get single content type element
* @param queryConfig Query configuration
*/
getElement(url: string, queryConfig: ITaxonomyQueryConfig): Observable<ElementResponses.ElementResponse>;
/**
* Gets proper set of headers for given request.
* @param queryConfig Query configuration
*/
getHeaders(queryConfig: IQueryConfig): IHeader[];
/**
* Http get response
* @param url Url of request
* @param queryConfig Query configuration
*/
protected getResponse(url: string, queryConfig: IQueryConfig): Observable<IBaseResponse>;
/**
* Gets number of retry attempts used by queries
*/
private getRetryAttempts();
/**
* Handles given error
* @param error Error to be handled
*/
private handleError(error);
/**
* Indicates if current query should use preview mode
* @param queryConfig Query configuration
*/
private isPreviewModeEnabled(queryConfig);
/**
* Indicates if current query should use secured mode
* @param queryConfig Query configuration
*/
private isSecuredModeEnabled(queryConfig);
/**
* Gets preview or standard URL based on client and query configuration
* @param queryConfig Query configuration
*/
private getDeliveryUrl(queryConfig);
/**
* Gets base URL of the request including the project Id
* @param queryConfig Query configuration
*/
private getBaseUrl(queryConfig);
/**
* Adds query parameters to given url
* @param url Url to which options will be added
* @param options Query parameters to add
*/
private addOptionsToUrl(url, options?);
/**
* Gets authorization header. This is used for 'preview' functionality
*/
private getAuthorizationHeader(key?);
/**
* Header identifying SDK type & version for internal purposes of Kentico
*/
private getSdkIdHeader();
}