| |
| |
| |
|
|
| export async function getProject(projectId) { |
| const r = await fetch(`/api/projects/${projectId}`) |
| if (!r.ok) throw new Error(`getProject ${r.status}`) |
| return r.json() |
| } |
|
|
| export async function getTree(projectId) { |
| const r = await fetch(`/api/projects/${projectId}/tree`) |
| if (!r.ok) throw new Error(`getTree ${r.status}`) |
| return (await r.json()).entries |
| } |
|
|
| export async function readFile(projectId, path) { |
| const r = await fetch(`/api/projects/${projectId}/files?path=${encodeURIComponent(path)}`) |
| if (!r.ok) throw new Error(`readFile ${path} ${r.status}`) |
| return (await r.json()).content |
| } |
|
|
| export async function writeFile(projectId, path, content) { |
| const r = await fetch(`/api/projects/${projectId}/files`, { |
| method: 'PUT', |
| headers: { 'Content-Type': 'application/json' }, |
| body: JSON.stringify({ path, content }), |
| }) |
| if (!r.ok) throw new Error(`writeFile ${path} ${r.status}`) |
| } |
|
|
| export async function deleteFile(projectId, path) { |
| const r = await fetch( |
| `/api/projects/${projectId}/files?path=${encodeURIComponent(path)}`, |
| { method: 'DELETE' }, |
| ) |
| if (!r.ok && r.status !== 204) throw new Error(`deleteFile ${path} ${r.status}`) |
| } |
|
|
| |
|
|
| export async function startProcesses(projectId) { |
| const r = await fetch(`/api/projects/${projectId}/processes/start`, { method: 'POST' }) |
| if (!r.ok) throw new Error(`startProcesses ${r.status}`) |
| return r.json() |
| } |
|
|
| export async function stopProcesses(projectId) { |
| const r = await fetch(`/api/projects/${projectId}/processes/stop`, { method: 'POST' }) |
| if (!r.ok) throw new Error(`stopProcesses ${r.status}`) |
| return r.json() |
| } |
|
|
| export async function getProcessStatus(projectId) { |
| const r = await fetch(`/api/projects/${projectId}/processes`) |
| if (!r.ok) throw new Error(`getProcessStatus ${r.status}`) |
| return r.json() |
| } |
|
|