import { IModel , IUpdatePageOptions , serializeModel , getModel , getProp , mergeObjects } from "@esri/hub-common" ; import { updateItem , IUpdateItemResponse } from "@esri/arcgis-rest-portal" ; param { Object } model param { IUpdatePageOptions } updateSiteOptions export function updatePage ( model , updateSiteOptions ) { const patchList = Array . isArray ( updateSiteOptions . allowList ) ? updateSiteOptions . allowList : [ ] ; model . data . values . updatedAt = new Date ( ) . toISOString ( ) ; model . data . values . updatedBy = updateSiteOptions . authentication . username ; model . item . url = "" ; let prms = Promise . resolve ( model ) ; if ( patchList . length ) { prms = getModel ( getProp ( model , "item.id" ) , updateSiteOptions ) ; } return prms . then ( modelFromAGO => { if ( patchList . length ) { model = mergeObjects ( model , modelFromAGO , patchList ) ; } const opts = Object . assign ( { item : serializeModel ( model ) } , updateSiteOptions ) ; opts . params = { clearEmptyFields : true } ; return updateItem ( opts ) ; } ) ; }