import { pick , reduce } from 'lodash' ; import { convertECSMappingToArray , convertECSMappingToObject } from '../utils' ; export const convertPackQueriesToSO = ( queries ) => reduce ( queries , ( acc , value , key ) => { const ecsMapping = value . ecs_mapping && convertECSMappingToArray ( value . ecs_mapping ) ; acc . push ( { id : key , ... pick ( value , [ 'query' , 'interval' , 'platform' , 'version' ] ) , ... ( ecsMapping ? { ecs_mapping : ecsMapping } : { } ) , } ) ; return acc ; } , [ ] as Array < Record < string , any > > ) ; export const convertSOQueriesToPack = ( queries ) => reduce ( queries , ( acc , { id : queryId , ecs_mapping , ... query } ) => { acc [ queryId ] = { ... query , ecs_mapping : convertECSMappingToObject ( ecs_mapping ) , } ; return acc ; } , { } as Record < string , any > ) ;