import { ElasticsearchClient } from 'kibana/server' ; import type { Id , ListSchema } from '@kbn/securitysolution-io-ts-list-types' ; import { transformElasticToList } from '../utils/transform_elastic_to_list' ; import { SearchEsListSchema } from '../../schemas/elastic_response' ; interface GetListOptions { id : Id ; esClient : ElasticsearchClient ; listIndex : string ; } export const getList = async ( { id , esClient , listIndex , } ) : Promise < ListSchema | null > => { const { body : response } = await esClient . search < SearchEsListSchema > ( { body : { query : { term : { _id : id , } , } , } , ignore_unavailable : true , index : listIndex , seq_no_primary_term : true , } ) ; const list = transformElasticToList ( { response } ) ; return list [ 0 ] ?? null ; } ;