import { cloneObject , IModelTemplate , IModel } from "@esri/hub-common" ; import { getPageItemType } from "./get-page-item-type" ; import { PAGE_TYPE_KEYWORD } from "./page-type-keyword" ; param { Object } pageModel param { Object } options export function ensureRequiredPageProperties ( pageModel , options ) { const result = cloneObject ( pageModel ) ; result . item . owner = options . username ; result . item . access = "private" ; if ( ! result . data . values ) { result . data . values = { } ; } result . data . values . updatedAt = new Date ( ) . toISOString ( ) ; result . data . values . updatedBy = options . username ; if ( ! result . data . values . sites ) { result . data . values . sites = [ ] ; } if ( result . item . url ) { result . item . url = "" ; } result . item . type = getPageItemType ( options . isPortal ) ; if ( result . item . typeKeywords . indexOf ( PAGE_TYPE_KEYWORD ) === - 1 ) { result . item . typeKeywords . push ( PAGE_TYPE_KEYWORD ) ; } return ( result as unknown ) as IModel ; }