(workflows: WorkflowExportData[])
| 182 | * Workflows are placed at the root level (no folder structure). |
| 183 | */ |
| 184 | export async function exportWorkflowsToZip(workflows: WorkflowExportData[]): Promise<Blob> { |
| 185 | const JSZip = await getJSZip() |
| 186 | const zip = new JSZip() |
| 187 | const seenFilenames = new Set<string>() |
| 188 | |
| 189 | for (const workflow of workflows) { |
| 190 | const jsonContent = exportWorkflowToJson(workflow) |
| 191 | const baseName = sanitizePathSegment(workflow.workflow.name) |
| 192 | let filename = `${baseName}.json` |
| 193 | let counter = 1 |
| 194 | |
| 195 | while (seenFilenames.has(filename.toLowerCase())) { |
| 196 | filename = `${baseName}-${counter}.json` |
| 197 | counter++ |
| 198 | } |
| 199 | seenFilenames.add(filename.toLowerCase()) |
| 200 | zip.file(filename, jsonContent) |
| 201 | } |
| 202 | |
| 203 | return await zip.generateAsync({ type: 'blob' }) |
| 204 | } |
| 205 | |
| 206 | function buildFolderPath( |
| 207 | folderId: string | null | undefined, |
no test coverage detected