import { IItem } from "@esri/arcgis-rest-portal" ; import { IModel , IHubRequestOptions , getProp , isGuid } from "@esri/hub-common" ; import { updateItem , getItem } from "@esri/arcgis-rest-portal" ; param initiativeItemId param siteId param hubRequestOptions export function updateInitiativeSiteId ( maybeModel , siteId , hubRequestOptions ) { let itemPromise = Promise . resolve ( maybeModel ) ; if ( typeof maybeModel === "string" ) { if ( ! isGuid ( maybeModel ) ) { return Promise . reject ( new Error ( "updateInitiativeSiteId was passed a string that is not a GUID." ) ) ; } else { itemPromise = getItem ( maybeModel , { authentication : hubRequestOptions . authentication } ) ; } } else { if ( getProp ( maybeModel as IModel , "item.id" ) ) { const m = maybeModel as IModel ; itemPromise = Promise . resolve ( m . item ) ; } } return itemPromise . then ( ( item ) => { if ( ! item . properties ) { item . properties = { } ; } item . properties . siteId = siteId ; return updateItem ( { item , authentication : hubRequestOptions . authentication } ) ; } ) ; }