(item)
| 77 | } |
| 78 | |
| 79 | function yamlItemToNode(item) { |
| 80 | if (typeof item === 'string') { |
| 81 | const label = parseLabel(item) |
| 82 | if (!label) return null |
| 83 | const node = { role: label.role, name: label.name, attributes: label.attributes, children: [] } |
| 84 | return node |
| 85 | } |
| 86 | if (!item || typeof item !== 'object' || Array.isArray(item)) return null |
| 87 | |
| 88 | const entries = Object.entries(item) |
| 89 | if (entries.length === 0) return null |
| 90 | const [key, value] = entries[0] |
| 91 | const label = parseLabel(key) |
| 92 | if (!label) return null |
| 93 | const node = { role: label.role, name: label.name, attributes: label.attributes, children: [] } |
| 94 | |
| 95 | if (Array.isArray(value)) { |
| 96 | node.children = value.map(yamlItemToNode).filter(n => n !== null) |
| 97 | return node |
| 98 | } |
| 99 | if (value !== null && value !== undefined) node.value = String(value) |
| 100 | return node |
| 101 | } |
| 102 | |
| 103 | function parseSnapshot(snapshot) { |
| 104 | if (!snapshot) return [] |
nothing calls this directly
no test coverage detected