import Conversion from './Conversion' ; /**
 * Retrieves current table's name.
 */ export const getTableName = ( conversion , currentTableName , shouldGetOriginal ) : string => { if ( conversion . _extraConfig !== null && 'tables' in conversion . _extraConfig ) { for ( let i = 0 ; i < conversion . _extraConfig . tables . length ; ++ i ) { if ( ( shouldGetOriginal ? conversion . _extraConfig . tables [ i ] . name . new : conversion . _extraConfig . tables [ i ] . name . original ) === currentTableName ) { return shouldGetOriginal ? conversion . _extraConfig . tables [ i ] . name . original : conversion . _extraConfig . tables [ i ] . name . new ; } } } return currentTableName ; } ; /**
 * Retrieves current column's name.
 */ export const getColumnName = ( conversion , originalTableName , currentColumnName , shouldGetOriginal ) : string => { if ( conversion . _extraConfig !== null && 'tables' in conversion . _extraConfig ) { for ( let i = 0 ; i < conversion . _extraConfig . tables . length ; ++ i ) { if ( conversion . _extraConfig . tables [ i ] . name . original === originalTableName && 'columns' in conversion . _extraConfig . tables [ i ] ) { for ( let columnsCount = 0 ; columnsCount < conversion . _extraConfig . tables [ i ] . columns . length ; ++ columnsCount ) { if ( conversion . _extraConfig . tables [ i ] . columns [ columnsCount ] . original === currentColumnName ) { return shouldGetOriginal ? conversion . _extraConfig . tables [ i ] . columns [ columnsCount ] . original : conversion . _extraConfig . tables [ i ] . columns [ columnsCount ] . new ; } } } } } return currentColumnName ; } ; /**
 * Parses the extra_config foreign_keys attributes and generate
 * an output array required by ForeignKeyProcessor::processForeignKeyWorker.
 */ export const parseForeignKeys = ( conversion , tableName ) : any [ ] => { const retVal = [ ] ; if ( conversion . _extraConfig !== null && 'foreign_keys' in conversion . _extraConfig ) { for ( let i = 0 ; i < conversion . _extraConfig . foreign_keys . length ; ++ i ) { if ( conversion . _extraConfig . foreign_keys [ i ] . table_name === tableName ) { const objFk = Object . create ( null ) ; for ( const attribute in conversion . _extraConfig . foreign_keys [ i ] ) { objFk [ attribute . toUpperCase ( ) ] = conversion . _extraConfig . foreign_keys [ i ] [ attribute ] ; } retVal . push ( objFk ) ; } } } return retVal ; } ;