import { getItemHubId , itemToContent , IHubContent , IModel , } from "@esri/hub-common" ; import { IGetContentOptions , getContentFromHub } from "./hub" ; import { getContentFromPortal } from "./portal" ; import { enrichContent } from "./enrichments" ; import { isSlug } from "./slugs" ; param identifier param options function getContentById ( identifier , options ? ) { let getContentPromise ; if ( options && options . isPortal ) { getContentPromise = getContentFromPortal ( identifier , options ) ; } else { getContentPromise = getContentFromHub ( identifier , options ) . catch ( ( e ) => { if ( ! isSlug ( identifier ) ) { return getContentFromPortal ( identifier , options ) ; } return Promise . reject ( e ) ; } ) ; } return getContentPromise ; } param idOrModel param options export function getContent ( idOrModel , options ? ) { let getContentPromise ; if ( typeof idOrModel === "string" ) { getContentPromise = getContentById ( idOrModel , options ) ; } else { const { item , data } = idOrModel ; const content = itemToContent ( item ) ; if ( ! options . isPortal ) { content . hubId = getItemHubId ( item ) ; } content . data = data ; getContentPromise = enrichContent ( content , options ) ; } return getContentPromise ; }