import { IUser } from "@esri/arcgis-rest-auth" ; import { cloneObject , includes , without } from "@esri/hub-common" ; const ALLOWED_SUBSCRIPTION_TYPES = [ "Demo & Marketing" , "Demo and Marketing" , "Organizational Plan" , "Community" , "In House" , "ConnectED" , "ELA" , "Education Site License" , "Education" , "HUP Online" , ] ; param { object } user param { string } subscriptionInfoType returns export function removeInvalidPrivs ( user , subscriptionInfoType ) { const clonedUser = cloneObject ( user ) ; const allowedSubscriptionTypes = ALLOWED_SUBSCRIPTION_TYPES ; if ( ! includes ( allowedSubscriptionTypes , subscriptionInfoType ) ) { clonedUser . privileges = without ( clonedUser . privileges , "portal:user:addExternalMembersToGroup" ) ; } return clonedUser ; }