Spaces:
Sleeping
Sleeping
File size: 1,866 Bytes
c993983 572b786 c993983 572b786 c993983 572b786 c993983 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | import client from './client';
import type { ProjectState } from '../types/project';
export async function importJsonFile(file: File): Promise<{ project_id: string; state: ProjectState }> {
const form = new FormData();
form.append('file', file);
const res = await client.post('/api/io/import-json', form, {
headers: { 'Content-Type': 'multipart/form-data' },
});
return res.data;
}
export async function importJsonBody(state: ProjectState): Promise<{ project_id: string; state: ProjectState }> {
const res = await client.post('/api/io/import-json-body', state);
return res.data;
}
export function exportJsonUrl(projectId: string): string {
const base = import.meta.env.VITE_API_BASE || '';
return `${base}/api/io/export-json/${projectId}`;
}
export function exportCsvUrl(projectId: string): string {
const base = import.meta.env.VITE_API_BASE || '';
return `${base}/api/io/export-csv/${projectId}`;
}
export function exportReportUrl(projectId: string): string {
const base = import.meta.env.VITE_API_BASE || '';
return `${base}/api/io/export-report/${projectId}`;
}
export async function importCsv(projectId: string, file: File) {
const form = new FormData();
form.append('file', file);
const res = await client.post(`/api/io/import-csv/${projectId}`, form, {
headers: { 'Content-Type': 'multipart/form-data' },
});
return res.data;
}
export async function getProcessModels(): Promise<Record<string, Record<string, string[]>>> {
const res = await client.get('/api/assets/models');
return res.data;
}
export async function listExamples(): Promise<string[]> {
const res = await client.get('/api/assets/examples');
return res.data.examples;
}
export async function getExample(filename: string): Promise<ProjectState> {
const res = await client.get(`/api/assets/examples/${filename}`);
return res.data;
}
|