import { UserSession } from "@esri/arcgis-rest-auth" ; import { isServiceNameAvailable } from "./is-service-name-available" ; export param { string } name param { UserSession } session param { number } step return { * } export function getUniqueServiceName ( name , type , session , step ) { let nameToCheck = name ; if ( step ) { nameToCheck = `${ name }_${ step }` ; } return isServiceNameAvailable ( nameToCheck , type , session ) . then ( ( response ) => { if ( response . available ) { return nameToCheck ; } else { step = step + 1 ; return getUniqueServiceName ( name , type , session , step ) ; } } ) ; }