UNPKG

@kontent-ai/delivery-sdk

Version:
119 lines 4.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeliveryClient = void 0; const core_sdk_1 = require("@kontent-ai/core-sdk"); const query_1 = require("../query"); const sdk_info_generated_1 = require("../sdk-info.generated"); const services_1 = require("../services"); class DeliveryClient { /** * Delivery client used to fetch data from Kontent.ai * @constructor * @param {IDeliveryClientConfig} config - The client configuration */ constructor(config) { this.config = config; if (!config) { throw Error(`Delivery client configuration is not set`); } this.mappingService = new services_1.MappingService(config); this.queryService = new services_1.QueryService(config, config.httpService ? config.httpService : new core_sdk_1.HttpService(), { 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 languages */ languages() { return new query_1.LanguagesQuery(this.config, this.queryService); } /** * Gets query for multiple types */ types() { return new query_1.MultipleTypeQuery(this.config, this.queryService); } /** * Gets query for single type * @param {string} typeCodename - Codename of the type to fetch */ type(typeCodename) { return new query_1.SingleTypeQuery(this.config, this.queryService, typeCodename); } /** * Gets query for multiple items */ items() { return new query_1.MultipleItemsQuery(this.config, this.queryService); } /** * Gets query for single item * @param {string} codename - Codename of item to fetch */ item(codename) { return new query_1.SingleItemQuery(this.config, this.queryService, codename); } /** * Gets query for items feed. Executes single HTTP request only */ itemsFeed() { return new query_1.ItemsFeedQuery(this.config, this.queryService); } /** * Gets query for single taxonomy * @param {string} codename - Codename of taxonomy to fetch */ taxonomy(codename) { return new query_1.TaxonomyQuery(this.config, this.queryService, codename); } /** * Gets query for multiple taxonomies */ taxonomies() { 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 */ element(typeCodename, elementCodename) { return new query_1.ElementQuery(this.config, this.queryService, typeCodename, elementCodename); } /** * @deprecated Sync API v1 is deprecated and will be shut down by the end of this year. * Please migrate to Sync API v2 using the `@kontent-ai/sync-sdk` package. * * For migration guidance and full documentation, visit: * https://kontent.ai/learn/docs/apis/openapi/sync-api-v2/ */ initializeSync() { return new query_1.InitializeSyncQuery(this.config, this.queryService); } /** * @deprecated Sync API v1 is deprecated and will be shut down by the end of this year. * Please migrate to Sync API v2 using the `@kontent-ai/sync-sdk` package. * * For migration guidance and full documentation, visit: * https://kontent.ai/learn/docs/apis/openapi/sync-api-v2/ */ syncChanges() { return new query_1.SyncChangesQuery(this.config, this.queryService); } /** * Item listing of where an asset is used */ assetUsedIn(assetCodename) { return new query_1.UsedInQuery(this.config, this.queryService, { entity: 'asset', codename: assetCodename }); } /** * Item listing of where a content item is used */ itemUsedIn(itemCodename) { return new query_1.UsedInQuery(this.config, this.queryService, { entity: 'contentItem', codename: itemCodename }); } } exports.DeliveryClient = DeliveryClient; //# sourceMappingURL=delivery-client.js.map