import { ClientDetails } from "./models/clientDetails" ; const RESERVED_MEMBER_NAMES = [ "pipeline" ] ; export function conflictResolver ( clientDetails ) { resolveConflictWithOperationGroupNames ( clientDetails ) ; } function resolveConflictWithOperationGroupNames ( clientDetails ) { clientDetails . operationGroups . forEach ( operationGroup => { const isConflict = checkForConflictWithDefinitions ( operationGroup . name , clientDetails ) ; if ( isConflict ) { if ( ! checkForConflictWithOperationGroupName ( `${ operationGroup . name }Operations` , clientDetails ) ) { operationGroup . name = `${ operationGroup . name }Operations` ; operationGroup . key = `${ operationGroup . key }Operations` ; } else { operationGroup . name = `${ operationGroup . name }OperationGrp` ; operationGroup . key = `${ operationGroup . key }OperationGrp` ; } } } ) ; } function checkForConflictWithDefinitions ( operationGroupName , clientDetails ) { if ( RESERVED_MEMBER_NAMES . includes ( operationGroupName . toLowerCase ( ) ) ) { return true ; } for ( const model of clientDetails . objects ) { if ( model . name === operationGroupName ) { return true ; } } return false ; } function checkForConflictWithOperationGroupName ( operationGroupName , clientDetails ) { for ( const og of clientDetails . operationGroups ) { if ( og . name === operationGroupName ) { return true ; } } return false ; }