@kontent-ai/management-sdk
Version:
Official Kontent.ai management SDK
48 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseListingQuery = void 0;
const base_query_1 = require("./base-query");
class BaseListingQuery extends base_query_1.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();
}
});
}
}
exports.BaseListingQuery = BaseListingQuery;
//# sourceMappingURL=base-listing-query.js.map