* Fetches workflow metadata (name and description) from the API
( workflowId: string )
| 69 | * Fetches workflow metadata (name and description) from the API |
| 70 | */ |
| 71 | async function fetchWorkflowMetadata( |
| 72 | workflowId: string |
| 73 | ): Promise<{ name: string; description: string | null } | null> { |
| 74 | try { |
| 75 | const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http') |
| 76 | |
| 77 | const headers = await buildAuthHeaders() |
| 78 | const url = buildAPIUrl(`/api/workflows/${workflowId}`) |
| 79 | |
| 80 | const response = await fetch(url.toString(), { headers }) |
| 81 | if (!response.ok) { |
| 82 | await response.text().catch(() => {}) |
| 83 | logger.warn(`Failed to fetch workflow metadata for ${workflowId}`) |
| 84 | return null |
| 85 | } |
| 86 | |
| 87 | const { data } = await response.json() |
| 88 | return { |
| 89 | name: data?.name || 'Workflow', |
| 90 | description: data?.description || null, |
| 91 | } |
| 92 | } catch (error) { |
| 93 | logger.error('Error fetching workflow metadata:', error) |
| 94 | return null |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Client-safe provider metadata. |
no test coverage detected