import { createLogger , pick , removeTrailingSlashes } from '@sap-cloud-sdk/util' ; import { DeSerializers } from '../de-serializers' ; import { EntityBase } from '../entity-base' ; import type { GetAllRequestBuilderBase } from '../request-builder' ; import { ODataRequestConfig } from './odata-request-config' ; const logger = createLogger ( { package : 'odata-common' , messageContext : 'count-request-config' } ) ; typeparam internal export class ODataCountRequestConfig < EntityT extends EntityBase , DeSerializersT extends DeSerializers > extends ODataRequestConfig { param getAllRequest constructor ( readonly getAllRequest ) { super ( 'get' , getAllRequest . _entityApi . entityConstructor . _defaultServicePath ) ; } resourcePath ( ) { return `${ removeTrailingSlashes ( this . getAllRequest . _entityApi . entityConstructor . _entityName ) }/$count` ; } queryParameters ( ) { const parametersAllowedInCount = [ '$apply' , '$search' , '$filter' ] ; const defaultParameters = [ '$format' ] ; const parameters = this . getAllRequest . requestConfig . queryParameters ( ) ; Object . keys ( parameters ) . forEach ( key => { if ( ! parametersAllowedInCount . includes ( key ) && ! defaultParameters . includes ( key ) ) { logger . warn ( `The query parameter ${ key } must not be used in a count request and has been ignored.` ) ; } } ) ; return pick ( parametersAllowedInCount , parameters ) ; } }