(obj: unknown)
| 5 | |
| 6 | // Helper to convert object to YAML string (for display) |
| 7 | const toYamlString = (obj: unknown): string => { |
| 8 | if (obj === null || obj === undefined) { |
| 9 | return ''; |
| 10 | } |
| 11 | if (typeof obj === 'object' && Object.keys(obj).length === 0) { |
| 12 | return ''; |
| 13 | } |
| 14 | try { |
| 15 | // Convert null/undefined values to empty strings to preserve keys |
| 16 | const normalized = Object.fromEntries( |
| 17 | Object.entries(obj as Record<string, unknown>).map(([key, value]) => [ |
| 18 | key, |
| 19 | value === null || value === undefined ? '' : value |
| 20 | ]) |
| 21 | ); |
| 22 | return yaml.dump(normalized, { |
| 23 | indent: 2, |
| 24 | lineWidth: -1, |
| 25 | skipInvalid: false, |
| 26 | forceQuotes: true, // Force quotes to preserve empty strings |
| 27 | }).trim(); |
| 28 | } catch { |
| 29 | return ''; |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | // Helper to parse YAML string to object |
| 34 | const parseYamlParams = (str: string): Record<string, unknown> | null => { |
no outgoing calls
no test coverage detected