@kontent-ai/delivery-sdk
Version:
Official Kontent.AI Delivery API SDK
111 lines (110 loc) • 3.75 kB
TypeScript
import { IResponse, IHeader, IHttpService, IQueryParameter } from '@kontent-ai/core-sdk';
import { IQueryConfig, ISDKInfo, IDeliveryNetworkResponse, ClientTypes } from '../models';
import { IDeliveryClientConfig } from '../config';
import { IMappingService } from './mapping.service';
export declare abstract class BaseDeliveryQueryService<TClientTypes extends ClientTypes> {
/**
* Delivery client configuration
*/
readonly config: IDeliveryClientConfig;
/**
* Http service for fetching data
*/
readonly httpService: IHttpService<any>;
/**
* Information about the SDK
*/
readonly sdkInfo: ISDKInfo;
/**
* Mapping service
*/
readonly mappingService: IMappingService<TClientTypes>;
/**
* Default base Url to Kontent.ai Delivery API
*/
private readonly defaultBaseDeliveryApiUrl;
/**
* Default preview url to Kontent.ai Delivery API
*/
private readonly defaultPreviewDeliveryApiUrl;
constructor(
/**
* Delivery client configuration
*/
config: IDeliveryClientConfig,
/**
* Http service for fetching data
*/
httpService: IHttpService<any>,
/**
* Information about the SDK
*/
sdkInfo: ISDKInfo,
/**
* Mapping service
*/
mappingService: IMappingService<TClientTypes>);
/**
* 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 proper set of headers for given request.
* @param queryConfig Query configuration
* @param additionalHeaders Custom headers
*/
getHeaders(queryConfig: IQueryConfig, additionalHeaders?: IHeader[]): IHeader[];
/**
* Http POST response
* @param url Url of request
* @param queryConfig Query config configuration
*/
protected postResponseAsync<TRawData>(url: string, body: any, queryConfig?: IQueryConfig, serviceConfig?: {
headers?: IHeader[];
}): Promise<IResponse<TRawData>>;
/**
* Http GET response
* @param url Url of request
* @param queryConfig Query config configuration
*/
protected getResponseAsync<TRawData>(url: string, queryConfig?: IQueryConfig, serviceConfig?: {
headers?: IHeader[];
}): Promise<IResponse<TRawData>>;
/**
* Gets base URL of the request including the environment Id
* @param queryConfig Query configuration
*/
protected getBaseUrl(queryConfig: IQueryConfig): string;
protected mapNetworkResponse<TData, TContract>(data: TData, response: IResponse<any>): IDeliveryNetworkResponse<TData, TContract>;
/**
* Indicates if current query should use preview mode
* @param queryConfig Query configuration
*/
private isPreviewModeEnabled;
private getQueryHeaders;
private shouldAddWaitForLoadingNewContentHeader;
/**
* Indicates if current query should use secured mode
* @param queryConfig Query configuration
*/
private isSecuredModeEnabled;
/**
* Gets preview or standard URL based on client and query configuration
* @param queryConfig Query configuration
*/
private getDomain;
/**
* Gets authorization header. This is used for 'preview' functionality
*/
private getAuthorizationHeader;
/**
* Header identifying SDK type & version for internal purposes of Kontent.ai
*/
private getSdkIdHeader;
private mapDeliveryError;
private getHasStaleContent;
private getContinuationToken;
}