import { ArcGISRequestError , IAuthenticationManager , } from "@esri/arcgis-rest-request" ; import { addOrInviteUsersToTeam } from "./add-or-invite-users-to-team" ; import { IAddOrInviteEmail , IAddOrInviteToTeamResult , IUserWithOrgType , } from "./types" ; export param { string [ ] } groupIds param { IUserWithOrgType [ ] } users param { IAuthenticationManager } primaryRO param { boolean } canAutoAddUser param { boolean } addUserAsGroupAdmin param { IAddOrInviteEmail } email return { * } export async function addOrInviteUsersToTeams ( groupIds , users , primaryRO , canAutoAddUser = false , addUserAsGroupAdmin = false , email ? ) { let notAdded = [ ] ; let notInvited = [ ] ; let notEmailed = [ ] ; let errors = [ ] ; const responses = [ ] ; for ( const groupId of groupIds ) { const result = await addOrInviteUsersToTeam ( groupId , users , primaryRO , canAutoAddUser , addUserAsGroupAdmin , email ) ; responses . push ( result ) ; notAdded = notAdded . concat ( result . notAdded ) ; errors = errors . concat ( result . errors ) ; notInvited = notInvited . concat ( result . notInvited ) ; notEmailed = notEmailed . concat ( result . notEmailed ) ; } return { notAdded , notInvited , notEmailed , errors , responses , } ; }