import type { NamingStrategy } from './NamingStrategy' ; export abstract class AbstractNamingStrategy implements NamingStrategy { getClassName ( file , separator = '-' ) { const name = file . split ( '.' ) [ 0 ] ; const ret = name . replace ( new RegExp ( `${ separator }+(\\w)` , 'g' ) , m => m [ 1 ] . toUpperCase ( ) ) ; return ret . charAt ( 0 ) . toUpperCase ( ) + ret . slice ( 1 ) ; } classToMigrationName ( timestamp ) { return `Migration${ timestamp }` ; } indexName ( tableName , columns , type ) { if ( tableName . includes ( '.' ) ) { tableName = tableName . substr ( tableName . indexOf ( '.' ) + 1 ) ; } if ( type === 'primary' ) { return `${ tableName }_pkey` ; } if ( type === 'sequence' ) { return `${ tableName }_${ columns . join ( '_' ) }_seq` ; } return `${ tableName }_${ columns . join ( '_' ) }_${ type }` ; } columnNameToProperty ( columnName ) { return columnName . replace ( /[_ ](\w)/g , m => m [ 1 ] . toUpperCase ( ) ) . replace ( /_+/g , '' ) ; } aliasName ( entityName , index ) { return entityName . charAt ( 0 ) . toLowerCase ( ) + index ; } abstract classToTableName ( entityName ) ; abstract joinColumnName ( propertyName ) ; abstract joinKeyColumnName ( entityName , referencedColumnName ? ) ; abstract joinTableName ( sourceEntity , targetEntity , propertyName ? ) ; abstract propertyToColumnName ( propertyName ) ; abstract referenceColumnName ( ) ; }