import { UserSession } from "@esri/arcgis-rest-auth" ; import { IUpdateItemResponse , updateItem } from "@esri/arcgis-rest-portal" ; import { cloneObject , IModel , without } from "@esri/hub-common" ; export param { string } teamId param { IModel [ ] } models param { UserSession } authentication return { * } export async function removeTeamFromItems ( teamId , models , authentication ) { return Promise . all ( models . map ( ( model ) => { const clonedModel = cloneObject ( model ) ; clonedModel . item . properties . teams = without ( clonedModel . item . properties . teams , teamId ) ; return clonedModel . item . itemControl === "admin" || clonedModel . item . itemControl === "update" ? updateItem ( { item : clonedModel . item , authentication , } ) : { id : clonedModel . item . id , success : false } ; } ) ) ; }