File size: 1,311 Bytes
fcacf10 37e137f | 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 | import { apiRequest } from "./client";
/**
* Uploads one or more files to a workspace.
* Response shape (per app/schemas/document.py DocumentUploadResponse):
* {
* uploaded: [{ document_id, version_id, workflow_id, filename, processing_stage, uploaded_at }],
* failed: [{ filename, detail }]
* }
*/
export async function uploadDocuments(workspaceId, files) {
const formData = new FormData();
for (const file of files) {
formData.append("files", file);
}
return apiRequest(
`/documents/upload?workspace_id=${encodeURIComponent(workspaceId)}`,
"POST",
formData
);
}
/**
* GET /documents?workspace_id={uuid}
* Returns all documents in the workspace with latest version/workflow info.
*/
export async function listDocuments(workspaceId) {
return apiRequest(`/documents?workspace_id=${encodeURIComponent(workspaceId)}`);
}
/**
* DELETE /documents/{document_id}
* Deletes a document and cancels any active workflows.
*/
export async function deleteDocument(documentId) {
return apiRequest(`/documents/${documentId}`, "DELETE");
}
/**
* POST /documents/{document_id}/retry
* Retries processing a failed document.
*/
export async function retryDocument(documentId) {
return apiRequest(`/documents/${documentId}/retry`, "POST");
}
|