import { IDeliveryClientConfig } from '../../config' ; import { continuationTokenHeaderName , Filters , IGroupedNetworkResponse , IKontentListAllResponse , IKontentListResponse , IDeliveryNetworkResponse , IListAllQueryConfig , IQueryConfig , Parameters , SortOrder } from '../../models' ; import { QueryService } from '../../services' ; import { BaseQuery } from './base-query.class' ; export abstract class BaseListingQuery < TResponse extends IKontentListResponse , TAllResponse extends IKontentListAllResponse , TQueryConfig extends IQueryConfig , TContract > extends BaseQuery < TResponse , TQueryConfig , TContract > { constructor ( protected config , protected queryService ) { super ( config , queryService ) ; } param element emptyFilter ( element ) { this . parameters . push ( new Filters . EmptyFilter ( element ) ) ; return this ; } param element notEmptyFilter ( element ) { this . parameters . push ( new Filters . NotEmptyFilter ( element ) ) ; return this ; } param element param value equalsFilter ( element , value ) { this . parameters . push ( new Filters . EqualsFilter ( element , value ) ) ; return this ; } param element param value notEqualsFilter ( element , value ) { this . parameters . push ( new Filters . NotEqualsFilter ( element , value ) ) ; return this ; } param element param values allFilter ( element , values ) { this . parameters . push ( new Filters . AllFilter ( element , values ) ) ; return this ; } param element param values anyFilter ( element , values ) { this . parameters . push ( new Filters . AnyFilter ( element , values ) ) ; return this ; } param element param values containsFilter ( element , values ) { this . parameters . push ( new Filters . ContainsFilter ( element , values ) ) ; return this ; } param element param value greaterThanFilter ( element , value ) { this . parameters . push ( new Filters . GreaterThanFilter ( element , value ) ) ; return this ; } param element param value greaterThanOrEqualFilter ( element , value ) { this . parameters . push ( new Filters . GreaterThanOrEqualFilter ( element , value ) ) ; return this ; } param element param values inFilter ( element , values ) { this . parameters . push ( new Filters . InFilter ( element , values ) ) ; return this ; } param element param values notInFilter ( element , values ) { this . parameters . push ( new Filters . NotInFilter ( element , values ) ) ; return this ; } param element param value lessThanFilter ( element , value ) { this . parameters . push ( new Filters . LessThanFilter ( element , value ) ) ; return this ; } param element param value lessThanOrEqualFilter ( element , value ) { this . parameters . push ( new Filters . LessThanOrEqualFilter ( element , value ) ) ; return this ; } param element param lowerValue param higherValue rangeFilter ( element , lowerValue , higherValue ) { this . parameters . push ( new Filters . RangeFilter ( element , lowerValue , higherValue ) ) ; return this ; } param limit limitParameter ( limit ) { this . parameters . push ( new Parameters . LimitParameter ( limit ) ) ; return this ; } param element param sortOrder orderParameter ( element , sortOrder ) { this . parameters . push ( new Parameters . OrderParameter ( element , sortOrder ) ) ; return this ; } param element orderByDescending ( element ) { this . parameters . push ( new Parameters . OrderParameter ( element , 'desc' ) ) ; return this ; } param element orderByAscending ( element ) { this . parameters . push ( new Parameters . OrderParameter ( element , 'asc' ) ) ; return this ; } param skip skipParameter ( skip ) { this . parameters . push ( new Parameters . SkipParameter ( skip ) ) ; return this ; } /**
     * Sets continuation token header
     */ withContinuationToken ( token ) { this . withHeaders ( [ { header : continuationTokenHeaderName , value : token } ] ) ; return this ; } /**
     * Query to get all items. Uses paging data and may execute multiple HTTP requests depending on number of items
     */ toAllPromise ( queryAllConfig ? ) { return this . queryService . getListAllResponse < TResponse , TAllResponse , TContract > ( { page : 1 , listQueryConfig : queryAllConfig , allResponseFactory : ( items , responses ) => { const response = this . allResponseFactory ( items , responses ) ; return { data : response , responses : responses } ; } , getResponse : ( nextPageUrl , continuationToken ) => { if ( nextPageUrl ) { this . withCustomUrl ( nextPageUrl ) . toPromise ( ) ; } if ( continuationToken ) { this . withContinuationToken ( continuationToken ) ; } return this . toPromise ( ) ; } } ) ; } protected abstract allResponseFactory ( items , responses ) ; }