import { OdataService } from '../types' ; import { DEFAULT_DATASOURCE_NAME } from './constants' ; param { OdataService } data export function enhanceData ( data ) { if ( data . path === undefined ) { data . path = '/' ; } else if ( data . path . substring ( data . path . length - 1 ) !== '/' ) { data . path = data . path + '/' ; } if ( data . name === undefined ) { data . name = DEFAULT_DATASOURCE_NAME ; } if ( data . model === undefined ) { data . model = '' ; } data . previewSettings = data . previewSettings || { } ; data . previewSettings . path = data . previewSettings . path || `/${ data . path ?. split ( '/' ) . filter ( ( s ) => s !== '' ) [ 0 ] || '' }` ; data . previewSettings . url = data . previewSettings . url || data . url || 'http://localhost' ; if ( data . client && ! data . previewSettings . client ) { data . previewSettings . client = data . client ; } if ( data . destination && ! data . previewSettings . destination ) { data . previewSettings . destination = data . destination . name ; if ( data . destination . instance ) { data . previewSettings . destinationInstance = data . destination . instance ; } } }