38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { apiGet, apiPost, apiUrl } from './client'
|
|
import type {
|
|
ExportContentResponse,
|
|
ExportCreateResponse,
|
|
ExportKind,
|
|
ExportListResponse,
|
|
ExportRead,
|
|
VectorSelectionBBox,
|
|
} from '../../types'
|
|
|
|
export const exportsApi = {
|
|
exportGeojson: (
|
|
payload:
|
|
| {
|
|
dataset_id?: string
|
|
analysis_run_id?: string
|
|
export_kind?: ExportKind
|
|
name?: string
|
|
bbox?: VectorSelectionBBox
|
|
limit?: number
|
|
}
|
|
| string,
|
|
): Promise<ExportCreateResponse> => {
|
|
const body = typeof payload === 'string' ? { dataset_id: payload, export_kind: 'dataset' } : payload
|
|
return apiPost<ExportCreateResponse>(`/api/v1/exports/geojson`, body)
|
|
},
|
|
exportProjectMetadata: (projectId: string, name?: string): Promise<ExportCreateResponse> =>
|
|
apiPost<ExportCreateResponse>(`/api/v1/exports/metadata`, { project_id: projectId, name }),
|
|
exportProjectReport: (projectId: string, name?: string): Promise<ExportCreateResponse> =>
|
|
apiPost<ExportCreateResponse>(`/api/v1/exports/report`, { project_id: projectId, name }),
|
|
listProjectExports: (projectId: string): Promise<ExportListResponse> =>
|
|
apiGet<ExportListResponse>(`/api/v1/exports/projects/${projectId}/exports`),
|
|
getExport: (exportId: string): Promise<ExportRead> => apiGet<ExportRead>(`/api/v1/exports/${exportId}`),
|
|
getContent: (exportId: string): Promise<ExportContentResponse> =>
|
|
apiGet<ExportContentResponse>(`/api/v1/exports/${exportId}/content`),
|
|
downloadUrl: (exportId: string): string => apiUrl(`/api/v1/exports/${exportId}/download`),
|
|
}
|