()
| 186 | |
| 187 | // Load the YAML file list from the API with names and descriptions |
| 188 | export async function fetchWorkflowsWithDesc() { |
| 189 | try { |
| 190 | const response = await fetch(apiUrl('/api/workflows')) |
| 191 | if (!response.ok) { |
| 192 | throw new Error(`/api/workflows fetch error, status: ${response.status}`) |
| 193 | } |
| 194 | const data = await response.json() |
| 195 | |
| 196 | // Fetch YAML descriptions by filename |
| 197 | const filesWithDesc = await Promise.all( |
| 198 | data.workflows.map(async (filename) => { |
| 199 | try { |
| 200 | const response = await fetch(apiUrl(`/api/workflows/${encodeURIComponent(filename)}/desc`)) |
| 201 | const fileData = await response.json() |
| 202 | return { |
| 203 | name: filename, |
| 204 | description: getYAMLDescription(fileData.content) |
| 205 | } |
| 206 | } catch { |
| 207 | return { name: filename, description: 'No description' } |
| 208 | } |
| 209 | }) |
| 210 | ) |
| 211 | |
| 212 | return { |
| 213 | success: true, |
| 214 | workflows: filesWithDesc |
| 215 | } |
| 216 | } catch (err) { |
| 217 | console.error('Failed to load YAML files:', err) |
| 218 | return { |
| 219 | success: false, |
| 220 | error: 'Failure loading YAML files, please run API service' |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | function getYAMLDescription(content) { |
| 225 | try { |
| 226 | const doc = yaml.load(content) |
| 227 | return doc.graph.description || 'No description' |
| 228 | } catch { |
| 229 | return 'No description' |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | // Fetch YAML file content |
| 235 | export async function fetchWorkflowYAML(filename) { |
nothing calls this directly
no test coverage detected