import { ElasticsearchClient } from 'kibana/server' ; import type { ListItemArraySchema , Type } from '@kbn/securitysolution-io-ts-list-types' ; import { TransformElasticToListItemOptions , getQueryFilterFromTypeValue , transformElasticToListItem , } from '../utils' ; import { SearchEsListItemSchema } from '../../schemas/elastic_response' ; export interface GetListItemByValuesOptions { listId : string ; esClient : ElasticsearchClient ; listItemIndex : string ; type : Type ; value : string [ ] ; } export const getListItemByValues = async ( { listId , esClient , listItemIndex , type , value , } ) : Promise < ListItemArraySchema > => { const { body : response } = await esClient . search < SearchEsListItemSchema > ( { body : { query : { bool : { filter : getQueryFilterFromTypeValue ( { listId , type , value } ) , } , } , } , ignore_unavailable : true , index : listItemIndex , size : 10000 , } ) ; return transformElasticToListItem ( { response , type , } as unknown as TransformElasticToListItemOptions ) ; } ;