UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

72 lines 2.8 kB
import { ElementQuery, MultipleItemQuery, MultipleTypeQuery, SingleItemQuery, SingleTypeQuery, TaxonomiesQuery, TaxonomyQuery, } from '../query'; import { sdkInfo } from '../sdk-info.generated'; import { DeliveryHttpService, QueryService } from '../services'; import { getParserAdapter } from '../parser/parser-adapter'; var DeliveryClient = /** @class */ (function () { /** * Delivery client used to fetch data from Kentico Cloud * @constructor * @param {IDeliveryClientConfig} config - The client configuration */ function DeliveryClient(config) { this.config = config; if (!config) { throw Error("Please provide Delivery client configuration"); } this.queryService = new QueryService(config, new DeliveryHttpService(), getParserAdapter(), { host: sdkInfo.host, name: sdkInfo.name, version: sdkInfo.version }); } /** * Gets query for multiple types */ DeliveryClient.prototype.types = function () { return new MultipleTypeQuery(this.config, this.queryService); }; /** * Gets query for single type * @param {string} typeCodename - Codename of the type to fetch */ DeliveryClient.prototype.type = function (typeCodename) { return new SingleTypeQuery(this.config, this.queryService, typeCodename); }; /** * Gets query for multiple items */ DeliveryClient.prototype.items = function () { return new MultipleItemQuery(this.config, this.queryService); }; /** * Gets query for single item * @param {string} codename - Codename of item to fetch */ DeliveryClient.prototype.item = function (codename) { return new SingleItemQuery(this.config, this.queryService, codename); }; /** * Gets query for single taxonomy * @param {string} codename - Codename of taxonomy to fetch */ DeliveryClient.prototype.taxonomy = function (codename) { return new TaxonomyQuery(this.config, this.queryService, codename); }; /** * Gets query for multiple taxonomies */ DeliveryClient.prototype.taxonomies = function () { return new TaxonomiesQuery(this.config, this.queryService); }; /** * Gets query for an element within a type * @param {string} typeCodename - Codename of the type * @param {string} elementCodename - Codename of the element */ DeliveryClient.prototype.element = function (typeCodename, elementCodename) { return new ElementQuery(this.config, this.queryService, typeCodename, elementCodename); }; return DeliveryClient; }()); export { DeliveryClient }; //# sourceMappingURL=delivery-client.js.map