import { portalRequestDownloadMetadata } from "./portal/portal-request-download-metadata" ; import { hubRequestDownloadMetadata } from "./hub/hub-request-download-metadata" ; import { DownloadFormat } from "./download-format" ; import { DownloadTarget } from "./download-target" ; import { DownloadStatuses } from "./download-status" ; import { UserSession } from "@esri/arcgis-rest-auth" ; export interface IDownloadMetadataRequestParams { target ? : DownloadTarget ; host : string ; datasetId : string ; format : DownloadFormat ; spatialRefId ? : string ; geometry ? : string ; where ? : string ; authentication ? : UserSession ; } export interface IDownloadMetadataResults { downloadId : string ; status : DownloadStatuses ; errors ? : Error [ ] ; lastEditDate ? : string ; contentLastModified ? : string ; lastModified ? : string ; downloadUrl ? : string ; contentLength ? : number ; cacheTime ? : number ; } param { IDownloadMetadataRequestParams } params returns { Promise < ISearchResult > } export function requestDownloadMetadata ( params ) { const { host , datasetId , spatialRefId , format , geometry , where , target , authentication , } = params ; if ( ! target || target === "hub" ) { return hubRequestDownloadMetadata ( { host , datasetId , format , spatialRefId , geometry , where , } ) ; } return portalRequestDownloadMetadata ( { portal : `${ host }/sharing/rest` , datasetId , format , authentication , spatialRefId , target , } ) ; }