MCPcopy Index your code
hub / github.com/simstudioai/sim / buildVfsFolderPathMap

Function buildVfsFolderPathMap

apps/sim/lib/copilot/vfs/path-utils.ts:72–96  ·  view source on GitHub ↗
(
  folders: Array<{ folderId: string; folderName: string; parentId: string | null }>
)

Source from the content-addressed store, hash-verified

70 * folders and file folders both qualify).
71 */
72export 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

Callers 4

loadFolderPathToIdMapFunction · 0.90
path-utils.test.tsFile · 0.90
buildFolderPathsMethod · 0.90

Calls 2

resolveFunction · 0.70
setMethod · 0.65

Tested by

no test coverage detected