import { IItem } from '../../types'; import { WebmapData, WebmapLayerDataByItemId } from '../../types/item-data'; export type FetchWebmapWithLayerDetailsParams = { /** * The item for which to fetch the webmap data and associated layer details. * This should be a valid IItem object representing a webmap item. * The function will validate that the item is of type 'Web Map' before attempting to fetch data. */ item: IItem; /** * The root URL of the portal from which to fetch the webmap data. * This should be a valid URL string pointing to the portal's sharing/rest endpoint. * If not provided, it defaults to 'https://www.arcgis.com', which is the URL for ArcGIS Online. */ portalRoot?: string; /** * The authentication token to access the portal. * This is required if the webmap item or any of its layers are secured and require authentication to access their data. */ token?: string; /** * Optional flag to bypass any caching by adding a query timestamp. * This can be useful in scenarios where you want to ensure you are fetching the most up-to-date data from the portal, * especially if the webmap or its layers are frequently updated. */ bypassCache?: boolean; /** * If true, the function will attempt to use cached response for layer items if available. * Defaults to false. This can improve performance by avoiding redundant network requests for layer items that have already been fetched. * Only use this if you are okay with potentially stale data for layer items, as it will return cached data if available without checking for updates. */ shouldUseCachedLayerItems?: boolean; }; export type FetchWebmapWithLayerDetailsResult = { /** * Id of the webmap item for which the data was fetched. This is useful for reference and to correlate the fetched data with the original item request. */ itemId: string; /** * The webmap data object containing all the information about the webmap, including its operational layers, basemap, and other properties. * This will be null if the item is not a webmap or if there was an error fetching the webmap data. */ webmapData: WebmapData | null; /** * This property contains an array of items for all layers in the webmap. Each item in the array corresponds to a layer defined in the webmap's operational layers or basemap layers. */ webmapLayerItems: IItem[]; /** * This property contains a mapping of item IDs to their corresponding layer data for operational layers that do not have popupInfo defined in the webmap data. */ webmapLayerDataByItemId: WebmapLayerDataByItemId; /** * If an error occurs during the fetch process, the error message will be captured in this property. * The presence of an error message indicates that the fetch operation did not complete successfully, * and the other properties may contain partial or default values. * Consumers of this function should check for the existence of an error message to determine if the data was fetched successfully or if they need to handle an error scenario. */ error?: string; }; /** * Fetches a webmap and its associated layer information including layer items and layer data. * * This function retrieves the webmap data along with detailed information about its layers. * It fetches layer items for all operational and basemap layers, and additionally retrieves * layer data for operational layers that don't have popupInfo defined in the webmap. * * The function includes performance optimizations such as early returns for non-webmap items * and webmaps that exceed the maximum layer count limit. * * @param params - Function parameters * @param params.item - The webmap item to fetch data for. Must be a valid IItem object. * @param params.portalRoot - The portal root URL. Defaults to 'https://www.arcgis.com'. * @param params.token - Authentication token for accessing secured content. Defaults to empty string. * @param params.bypassCache - Optional flag to bypass caching by adding a query timestamp. Defaults to false. * @param params.shouldUseCachedLayerItems - If true, the function will attempt to use cached response for layer items if available. Defaults to false. * * @returns A promise that resolves to an object containing: * - itemId: The ID of the webmap item * - webmapData: The webmap data object (null if not a webmap or error occurred) * - webmapLayerItems: Array of items for all layers in the webmap * - webmapLayerDataByItemId: Mapping of item IDs to layer data for layers without popupInfo * - error: Optional error message if the fetch operation failed * * @throws {Error} Throws an error if the item parameter is not provided */ export declare const fetchWebmapWithLayerDetails: ({ item, portalRoot, token, bypassCache, shouldUseCachedLayerItems, }: FetchWebmapWithLayerDetailsParams) => Promise;