import { SavedObjectUnsanitizedDoc , SavedObjectSanitizedDoc } from 'kibana/server' ; export const migrations = { '7.9.0' : ( doc ) : SavedObjectSanitizedDoc < any > => ( { ... doc , ... ( doc . attributes && { attributes : Object . keys ( doc . attributes ) . reduce ( ( acc , key ) => key . startsWith ( 'siem:' ) ? { ... acc , [ key . replace ( 'siem' , 'securitySolution' ) ] : doc . attributes [ key ] , } : { ... acc , [ key ] : doc . attributes [ key ] , } , { } ) , } ) , references : doc . references || [ ] , } ) , '7.12.0' : ( doc ) : SavedObjectSanitizedDoc < any > => ( { ... doc , ... ( doc . attributes && { attributes : Object . keys ( doc . attributes ) . reduce ( ( acc , key ) => { if ( key === 'timepicker:quickRanges' && doc . attributes [ key ] ?. indexOf ( 'section' ) > - 1 ) { const ranges = JSON . parse ( doc . attributes [ key ] ) . map ( ( { from , to , display } ) => { return { from , to , display , } ; } ) ; return { ... acc , 'timepicker:quickRanges' : JSON . stringify ( ranges , null , 2 ) , } ; } else { return { ... acc , [ key ] : doc . attributes [ key ] , } ; } } , { } ) , } ) , references : doc . references || [ ] , } ) , '7.13.0' : ( doc ) : SavedObjectSanitizedDoc < any > => ( { ... doc , ... ( doc . attributes && { attributes : Object . keys ( doc . attributes ) . reduce ( ( acc , key ) => key === 'ml:fileDataVisualizerMaxFileSize' ? { ... acc , [ 'fileUpload:maxFileSize' ] : doc . attributes [ key ] , } : { ... acc , [ key ] : doc . attributes [ key ] , } , { } ) , } ) , references : doc . references || [ ] , } ) , '8.0.0' : ( doc ) : SavedObjectSanitizedDoc < any > => ( { ... doc , ... ( doc . attributes && { attributes : Object . keys ( doc . attributes ) . reduce ( ( acc , key ) => [ 'visualization:regionmap:showWarnings' , 'visualization:tileMap:WMSdefaults' , 'visualization:tileMap:maxPrecision' , 'telemetry:optIn' , 'xPackMonitoring:allowReport' , 'theme:version' , 'courier:batchSearches' , ] . includes ( key ) ? { ... acc , } : { ... acc , [ key ] : doc . attributes [ key ] , } , { } ) , } ) , references : doc . references || [ ] , } ) , '8.1.0' : ( doc ) : SavedObjectSanitizedDoc < any > => ( { ... doc , ... ( doc . attributes && { attributes : Object . keys ( doc . attributes ) . reduce ( ( acc , key ) => { if ( key === 'format:defaultTypeMap' ) { const initial = JSON . parse ( doc . attributes [ key ] ) ; const updated = { ... initial , geo_point : { id : 'geo_point' , params : { transform : 'wkt' } } , } ; return { ... acc , 'format:defaultTypeMap' : JSON . stringify ( updated , null , 2 ) , } ; } else { return { ... acc , [ key ] : doc . attributes [ key ] , } ; } } , { } ) , } ) , references : doc . references || [ ] , } ) , } ;