(filename, content)
| 67 | } |
| 68 | |
| 69 | export async function updateYaml(filename, content) { |
| 70 | try { |
| 71 | const yamlFilename = addYamlSuffix(filename) |
| 72 | const response = await fetch(apiUrl(`/api/workflows/${encodeURIComponent(yamlFilename)}/update`), { |
| 73 | method: 'PUT', |
| 74 | headers: { |
| 75 | 'Content-Type': 'application/json', |
| 76 | }, |
| 77 | body: JSON.stringify({ |
| 78 | content |
| 79 | }) |
| 80 | }) |
| 81 | |
| 82 | const data = await response.json().catch(() => ({})) |
| 83 | |
| 84 | if (response.ok) { |
| 85 | return { |
| 86 | success: true, |
| 87 | filename: data?.filename || yamlFilename, |
| 88 | message: data?.message || 'Workflow updated successfully' |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return { |
| 93 | success: false, |
| 94 | detail: data?.detail, |
| 95 | message: data.error?.message || 'Failed to update workflow', |
| 96 | status: response.status |
| 97 | } |
| 98 | } catch (error) { |
| 99 | console.error('Error updating workflow YAML:', error) |
| 100 | return { |
| 101 | success: false, |
| 102 | message: 'API error' |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Rename YAML file |
| 108 | export async function postYamlNameChange(filename, newFilename) { |
nothing calls this directly
no test coverage detected