import { Contracts } from '../../contracts' ; import { IDeliveryClientConfig } from '../../config' ; import { IContentTypeQueryConfig , IDeliveryNetworkResponse , Responses } from '../../models' ; import { QueryService } from '../../services' ; import { BaseQuery } from '../common/base-query.class' ; export class SingleTypeQuery extends BaseQuery < Responses . IViewContentTypeResponse , IContentTypeQueryConfig , Contracts . IViewContentTypeContract > { constructor ( protected config , protected queryService , private typeCodename ) { super ( config , queryService ) ; if ( ! typeCodename ) { throw Error ( `Cannot create type query without the codename of the type` ) ; } } toPromise ( ) { return this . queryService . getSingleType ( this . getUrl ( ) , this . _queryConfig ?? { } ) ; } getUrl ( ) { const action = '/types/' + this . typeCodename ; return super . resolveUrlInternal ( action ) ; } map ( json ) { return this . queryService . mappingService . viewContentTypeResponse ( json ) ; } }