UNPKG

@kontent-ai/management-sdk

Version:
44 lines 1.47 kB
import { BaseQuery } from './base-query'; export class BaseListingQuery extends BaseQuery { constructor(config, queryService) { super(config, queryService); this.config = config; this.queryService = queryService; this.xContinuationHeaderName = 'x-continuation'; } /** * Configuration for list queries * @param config List configuration */ withListQueryConfig(config) { this.listQueryConfig = config; return this; } /** * Sets the 'x-continuation' header value. This can be used for fetching next pages. * @param token Value from continuation_token property */ xContinuationToken(token) { this.queryConfig.headers.push({ header: this.xContinuationHeaderName, value: token }); return this; } /** * Query to get all items. Uses paging data and may execute multiple HTTP requests depending on number of items */ toAllPromise() { return this.queryService.getListAllResponseAsync({ listQueryConfig: this.listQueryConfig, allResponseFactory: (items, responses) => this.allResponseFactory(items, responses), getResponse: (token) => { if (token) { this.xContinuationToken(token); } return this.toPromise(); } }); } } //# sourceMappingURL=base-listing-query.js.map