import { RestoreSettings , RestoreSettingsEs } from '../types' ; const removeUndefinedSettings = ( settings ) : RestoreSettingsEs => { return Object . entries ( settings ) . reduce ( ( sts , [ key , value ] ) => { if ( value !== undefined ) { sts [ key as keyof RestoreSettingsEs ] = value ; } return sts ; } , { } ) ; } ; export function serializeRestoreSettings ( restoreSettings ) { const { indices , renamePattern , renameReplacement , includeGlobalState , partial , indexSettings , ignoreIndexSettings , ignoreUnavailable , includeAliases , } = restoreSettings ; let parsedIndexSettings ; if ( indexSettings ) { try { parsedIndexSettings = JSON . parse ( indexSettings ) ; } catch ( e ) { } } const settings = { indices , rename_pattern : renamePattern , rename_replacement : renameReplacement , include_global_state : includeGlobalState , partial , index_settings : parsedIndexSettings , ignore_index_settings : ignoreIndexSettings , ignore_unavailable : ignoreUnavailable , include_aliases : includeAliases , } ; return removeUndefinedSettings ( settings ) ; }