(yamlContent: string)
| 122 | * - Explicit typing enforced by schema |
| 123 | */ |
| 124 | export function parseYaml(yamlContent: string): unknown { |
| 125 | try { |
| 126 | // Validate no BOM prefix (string-level check only) |
| 127 | // Note: For proper UTF-8 validation, use decodeUtf8NoBom() on raw bytes before calling this |
| 128 | validateNoBomPrefix(yamlContent) |
| 129 | |
| 130 | // Validate YAML structure (no anchors, aliases, merge keys, custom tags) |
| 131 | validateYamlStructure(yamlContent) |
| 132 | |
| 133 | // Parse and validate in a single pass (checks duplicate keys and converts to JS) |
| 134 | const parsed = parseAndValidate(yamlContent) |
| 135 | |
| 136 | return parsed |
| 137 | } catch (error) { |
| 138 | if (error instanceof DeepnoteError) { |
| 139 | throw error |
| 140 | } |
| 141 | const message = error instanceof Error ? error.message : String(error) |
| 142 | throw new ParseError(`Failed to parse Deepnote file: ${message}`, { cause: error }) |
| 143 | } |
| 144 | } |
no test coverage detected