import { IHubRequestOptions , IModel , getProp } from "@esri/hub-common" ; import { addDomain } from "@esri/hub-common" ; param { Object } model param { IHubRequestOptions } hubRequestOptions private export function _addSiteDomains ( model , hubRequestOptions ) { if ( hubRequestOptions . isPortal ) { return Promise . resolve ( [ ] ) ; } else { const props = [ "defaultHostname" , "customHostname" ] ; return Promise . all ( props . reduce ( ( acc , prop ) => { const hostname = getProp ( model , `data.values.${ prop }` ) ; if ( hostname ) { const domainOpts = { hostname , clientKey : model . data . values . clientId , orgId : hubRequestOptions . portalSelf . id , orgTitle : hubRequestOptions . portalSelf . name , orgKey : hubRequestOptions . portalSelf . urlKey , siteId : model . item . id , siteTitle : model . item . title , sslOnly : true , } ; acc . push ( addDomain ( domainOpts , hubRequestOptions ) ) ; } return acc ; } , [ ] as Array < Promise < any > > ) ) ; } }