import { IModel , IHubRequestOptions , failSafe , serializeModel , IModelTemplate } from "@esri/hub-common" ; import { updateItem , IUpdateItemResponse } from "@esri/arcgis-rest-portal" ; import { _secondPassAdlibPages } from "./_second-pass-adlib-pages" ; param { object } siteModel param { Array } solutionModels param { IHubRequestOptions } hubRequestOptions private export function _updatePages ( siteModel , solutionModels , hubRequestOptions ) { const pageModels = solutionModels . filter ( m => { return m . item . type . indexOf ( "Page" ) > - 1 ; } ) ; const failSafeUpdate = failSafe ( updateItem , { success : true } ) ; const siteEntry = { id : siteModel . item . id , title : siteModel . item . title } ; return Promise . all ( pageModels . map ( m => { m . data . values . sites . push ( siteEntry ) ; m = _secondPassAdlibPages ( siteModel , m ) ; return failSafeUpdate ( { item : serializeModel ( ( m as unknown ) as IModel ) , authentication : hubRequestOptions . authentication } ) ; } ) ) ; }