import { ArcGISRequestError } from "@esri/arcgis-rest-request" ; import { IUser } from "@esri/arcgis-rest-types" ; import { getProp , inviteUsers } from "@esri/hub-common" ; import { IAddOrInviteContext , IAddOrInviteResponse } from "../types" ; private export param { IAddOrInviteContext } context param { string } userType return { IAddOrInviteResponse } export async function processInviteUsers ( context , userType ) { const users = getProp ( context , userType ) ; const notInvited = [ ] ; let errors = [ ] ; const { addUserAsGroupAdmin } = context ; for ( const user of users ) { const inviteResponse = await inviteUsers ( getProp ( context , "groupId" ) , [ user ] , getProp ( context , "primaryRO" ) , 20160 , addUserAsGroupAdmin ? "group_admin" : "group_member" ) ; if ( ! inviteResponse . success ) { notInvited . push ( user . username ) ; if ( inviteResponse . errors ) { errors = errors . concat ( inviteResponse . errors ) ; } } } return { users : users . map ( ( u ) => u . username ) , notInvited , errors , notEmailed : [ ] , notAdded : [ ] , } ; }