import { HttpService } from '@kentico/kontent-core' ; import { IDeliveryClientConfig } from '../config' ; import { IContentItem } from '../models' ; import { ElementQuery , ItemsFeedQuery , MultipleItemsQuery , MultipleTypeQuery , SingleItemQuery , SingleTypeQuery , TaxonomiesQuery , TaxonomyQuery , LanguagesQuery } from '../query' ; import { sdkInfo } from '../sdk-info.generated' ; import { IMappingService , MappingService , QueryService } from '../services' ; import { IDeliveryClient } from './idelivery-client.interface' ; export class DeliveryClient implements IDeliveryClient { private queryService : QueryService ; public mappingService : IMappingService ; constructor param { IDeliveryClientConfig } config constructor ( protected config ) { if ( ! config ) { throw Error ( `Delivery client configuration is not set` ) ; } this . mappingService = new MappingService ( config ) ; this . queryService = new QueryService ( config , config . httpService ? config . httpService : new HttpService ( ) , { host : sdkInfo . host , name : sdkInfo . name , version : sdkInfo . version } , this . mappingService ) ; } /**
     * Gets query for multiple languages
     */ languages ( ) { return new LanguagesQuery ( this . config , this . queryService ) ; } /**
     * Gets query for multiple types
     */ types ( ) { return new MultipleTypeQuery ( this . config , this . queryService ) ; } param { string } typeCodename type ( typeCodename ) { return new SingleTypeQuery ( this . config , this . queryService , typeCodename ) ; } /**
     * Gets query for multiple items
     */ items < TContentItem extends IContentItem = IContentItem > ( ) { return new MultipleItemsQuery < TContentItem > ( this . config , this . queryService ) ; } param { string } codename item < TContentItem extends IContentItem = IContentItem > ( codename ) { return new SingleItemQuery < TContentItem > ( this . config , this . queryService , codename ) ; } /**
     * Gets query for items feed. Executes single HTTP request only. Might not get all items from your Kontent project.
     */ itemsFeed < TContentItem extends IContentItem = IContentItem > ( ) { return new ItemsFeedQuery < TContentItem > ( this . config , this . queryService ) ; } param { string } codename taxonomy ( codename ) { return new TaxonomyQuery ( this . config , this . queryService , codename ) ; } /**
     * Gets query for multiple taxonomies
     */ taxonomies ( ) { return new TaxonomiesQuery ( this . config , this . queryService ) ; } param { string } typeCodename param { string } elementCodename element ( typeCodename , elementCodename ) { return new ElementQuery ( this . config , this . queryService , typeCodename , elementCodename ) ; } }