import Boom from '@hapi/boom' ; import { IndexMapping } from '../../../mappings' ; import { getQueryParams } from './query_params' ; import { getSortingParams } from './sorting_params' ; import { ISavedObjectTypeRegistry } from '../../../saved_objects_type_registry' ; type KueryNode = any ; interface GetSearchDslOptions { type : string | string [ ] ; search ? : string ; defaultSearchOperator ? : string ; searchFields ? : string [ ] ; rootSearchFields ? : string [ ] ; sortField ? : string ; sortOrder ? : string ; namespaces ? : string [ ] ; typeToNamespacesMap ? : Map < string , string [ ] | undefined > ; hasReference ? : { type : string ; id : string ; } ; kueryNode ? : KueryNode ; } export function getSearchDsl ( mappings , registry , options ) { const { type , search , defaultSearchOperator , searchFields , rootSearchFields , sortField , sortOrder , namespaces , typeToNamespacesMap , hasReference , kueryNode , } = options ; if ( ! type ) { throw Boom . notAcceptable ( 'type must be specified' ) ; } if ( sortOrder && ! sortField ) { throw Boom . notAcceptable ( 'sortOrder requires a sortField' ) ; } return { ... getQueryParams ( { registry , namespaces , type , typeToNamespacesMap , search , searchFields , rootSearchFields , defaultSearchOperator , hasReference , kueryNode , } ) , ... getSortingParams ( mappings , type , sortField , sortOrder ) , } ; }