(
folders: Array<{ folderId: string; folderName: string; parentId: string | null }>
)
| 70 | * folders and file folders both qualify). |
| 71 | */ |
| 72 | export function buildVfsFolderPathMap( |
| 73 | folders: Array<{ folderId: string; folderName: string; parentId: string | null }> |
| 74 | ): Map<string, string> { |
| 75 | const folderMap = new Map<string, { name: string; parentId: string | null }>() |
| 76 | for (const f of folders) { |
| 77 | folderMap.set(f.folderId, { name: f.folderName, parentId: f.parentId }) |
| 78 | } |
| 79 | |
| 80 | const cache = new Map<string, string>() |
| 81 | const resolve = (id: string): string => { |
| 82 | const cached = cache.get(id) |
| 83 | if (cached !== undefined) return cached |
| 84 | const folder = folderMap.get(id) |
| 85 | if (!folder) return '' |
| 86 | const parentPath = folder.parentId ? resolve(folder.parentId) : '' |
| 87 | const path = parentPath |
| 88 | ? `${parentPath}/${encodeVfsSegment(folder.name)}` |
| 89 | : encodeVfsSegment(folder.name) |
| 90 | cache.set(id, path) |
| 91 | return path |
| 92 | } |
| 93 | |
| 94 | for (const id of folderMap.keys()) resolve(id) |
| 95 | return cache |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Canonical VFS directory for a workflow. `folderPath` is the already |
no test coverage detected