UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

79 lines 3.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var kentico_cloud_core_1 = require("kentico-cloud-core"); var parser_adapter_1 = require("../parser/parser-adapter"); var query_1 = require("../query"); var sdk_info_generated_1 = require("../sdk-info.generated"); var services_1 = require("../services"); 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("Delivery client configuration is not set"); } this.mappingService = new services_1.MappingService(config, parser_adapter_1.getParserAdapter()); this.queryService = new services_1.QueryService(config, config.httpService ? config.httpService : new kentico_cloud_core_1.HttpService({ requestInterceptor: config.httpInterceptors && config.httpInterceptors.requestInterceptor ? config.httpInterceptors.requestInterceptor : undefined, responseInterceptor: config.httpInterceptors && config.httpInterceptors.responseInterceptor ? config.httpInterceptors.responseInterceptor : undefined, }), { host: sdk_info_generated_1.sdkInfo.host, name: sdk_info_generated_1.sdkInfo.name, version: sdk_info_generated_1.sdkInfo.version }, this.mappingService); } /** * Gets query for multiple types */ DeliveryClient.prototype.types = function () { return new query_1.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 query_1.SingleTypeQuery(this.config, this.queryService, typeCodename); }; /** * Gets query for multiple items */ DeliveryClient.prototype.items = function () { return new query_1.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 query_1.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 query_1.TaxonomyQuery(this.config, this.queryService, codename); }; /** * Gets query for multiple taxonomies */ DeliveryClient.prototype.taxonomies = function () { return new query_1.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 query_1.ElementQuery(this.config, this.queryService, typeCodename, elementCodename); }; return DeliveryClient; }()); exports.DeliveryClient = DeliveryClient; //# sourceMappingURL=delivery-client.js.map