import { Fields } from '../entity' ; import { dedot } from './dedot' ; export interface ElasticsearchOutput { _index : string ; _source : unknown ; timestamp : number ; } export function eventsToElasticsearchOutput ( { events , writeTarget , } ) { return events . map ( ( event ) => { const values = { } ; const timestamp = event [ '@timestamp' ] ! ; Object . assign ( values , event , { '@timestamp' : new Date ( timestamp ) . toISOString ( ) , } ) ; const document = { } ; dedot ( values , document ) ; return { _index : writeTarget , _source : document , timestamp , } ; } ) ; }