import api from "../api"; export async function listFiles(projectId){ const {data}=await api.get(`/api/projects/${projectId}/files`); return data; } export async function readFile(projectId,path){ const {data}=await api.get(`/api/projects/${projectId}/file`,{ params:{path} }); return data; } export async function saveFile(projectId,path,content){ const {data}=await api.put(`/api/projects/${projectId}/file`,{ path, content }); return data; } export async function createFile(projectId,path){ const {data}=await api.post(`/api/projects/${projectId}/file`,{ path }); return data; } export async function renameFile(projectId,oldPath,newPath){ const {data}=await api.patch(`/api/projects/${projectId}/file`,{ old_path:oldPath, new_path:newPath }); return data; } export async function deleteFile(projectId,path){ const {data}=await api.delete(`/api/projects/${projectId}/file`,{ data:{path} }); return data; } export async function uploadFile(projectId,file){ const form=new FormData(); form.append("file",file); const {data}=await api.post( `/api/projects/${projectId}/upload`, form, { headers:{ "Content-Type":"multipart/form-data" } } ); return data; } export async function downloadFile(projectId,path){ const {data}=await api.get( `/api/projects/${projectId}/download`, { params:{path}, responseType:"blob" } ); return data; }