import { IItem , getItem } from "@esri/arcgis-rest-portal" ; import { IHubContent , IHubRequestOptions , itemToContent , } from "@esri/hub-common" ; import { IEnrichContentOptions , enrichContent , getPortalUrls , } from "./enrichments" ; import { parseDatasetId } from "./slugs" ; export { itemToContent , parseItemCategories , getItemHubType , getFamily , } from "@esri/hub-common" ; param content param requestOptions returns export export function withPortalUrls ( content , requestOptions ) { console . warn ( "DEPRECATED: Use getPortalUrls() instead. withPortalUrls will be removed at v10.0.0" ) ; const portalUrls = getPortalUrls ( content , requestOptions ) ; return { ... content , ... portalUrls } ; } param item param options export function getContentFromPortal ( idOrItem , requestOptions ? ) { let getItemPromise ; let enrichContentOptions = requestOptions ; if ( typeof idOrItem === "string" ) { const { itemId , layerId : layerIdString } = parseDatasetId ( idOrItem ) ; getItemPromise = getItem ( itemId , requestOptions ) ; if ( layerIdString ) { const layerId = parseInt ( layerIdString , 10 ) ; enrichContentOptions = { layerId , ... requestOptions } ; } } else { getItemPromise = Promise . resolve ( idOrItem ) ; } return getItemPromise . then ( ( item ) => { return enrichContent ( itemToContent ( item ) , enrichContentOptions ) ; } ) ; }