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

Function parseYAML

apps/sim/lib/file-parsers/yaml-parser.ts:8–35  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

6 * Parse YAML files
7 */
8export async function parseYAML(filePath: string): Promise<FileParseResult> {
9 const fs = await import('fs/promises')
10 const content = await fs.readFile(filePath, 'utf-8')
11
12 try {
13 // Parse YAML to validate and extract structure
14 const yamlData = yaml.load(content)
15
16 // Convert to JSON for consistent processing
17 const jsonContent = JSON.stringify(yamlData, null, 2)
18
19 // Extract metadata about the YAML structure
20 const metadata = {
21 type: 'yaml',
22 isArray: Array.isArray(yamlData),
23 keys: Array.isArray(yamlData) ? [] : Object.keys(yamlData || {}),
24 itemCount: Array.isArray(yamlData) ? yamlData.length : undefined,
25 depth: getYamlDepth(yamlData),
26 }
27
28 return {
29 content: jsonContent,
30 metadata,
31 }
32 } catch (error) {
33 throw new Error(`Invalid YAML: ${getErrorMessage(error, 'Unknown error')}`)
34 }
35}
36
37/**
38 * Parse YAML from buffer

Callers

nothing calls this directly

Calls 4

getErrorMessageFunction · 0.90
getYamlDepthFunction · 0.85
readFileMethod · 0.80
loadMethod · 0.80

Tested by

no test coverage detected