import { IRequestOptions } from "@esri/arcgis-rest-request" ; import { getItem , updateItem , shareItemWithGroup , IItem , IUpdateItemOptions , IGroupSharingOptions } from "@esri/arcgis-rest-portal" ; export param { string } siteId param { * } collaborationGroupId param { IRequestOptions } requestOptions returns { Promise < any > } export function detachSiteFromInitiative ( siteId , collaborationGroupId , requestOptions ) { return getItem ( siteId , requestOptions ) . then ( ( site ) => { delete site . properties . parentInitiativeId ; if ( collaborationGroupId ) { site . properties . collaborationGroupId = collaborationGroupId ; } const opts = { item : site , ... requestOptions } as any ; return updateItem ( opts as IUpdateItemOptions ) ; } ) . then ( ( ) => { if ( collaborationGroupId ) { const opts = { id : siteId , groupId : collaborationGroupId , ... requestOptions } as IGroupSharingOptions ; return shareItemWithGroup ( opts ) as Promise < any > ; } else { return Promise . resolve ( { success : true } ) ; } } ) ; }