import { IHubUserRequestOptions , IModel } from "@esri/hub-common" ; import { updateSite } from "../update-site" ; import { updatePage , isPage } from "../pages" ; import { isSite } from "../is-site" ; import { IUpdateItemResponse } from "@esri/arcgis-rest-portal" ; import { hasUnpublishedChanges } from "./has-unpublished-changes" ; param siteOrPageModel param requestOptions export function savePublishedStatus ( siteOrPageModel , requestOptions ) { const allowList = [ "item.typeKeywords" ] ; const { item } = siteOrPageModel ; let prms ; if ( isSite ( item ) ) { const isUnpublished = hasUnpublishedChanges ( siteOrPageModel ) ; prms = updateSite ( siteOrPageModel , { ... requestOptions , allowList , updateVersions : ! isUnpublished , } ) ; } else if ( isPage ( item ) ) { prms = updatePage ( siteOrPageModel , { ... requestOptions , allowList , } ) ; } else { throw TypeError ( "@esri/hub-sites: only page or site models have a published state" ) ; } return prms ; }