Check if a config path is allowed to be modified at runtime.
(config: Record<string, unknown>, path: string)
| 65 | |
| 66 | /** Check if a config path is allowed to be modified at runtime. */ |
| 67 | function isValidConfigPath(config: Record<string, unknown>, path: string): boolean { |
| 68 | if (!(path.startsWith("layers.") || path.startsWith("notifications."))) return false; |
| 69 | |
| 70 | const parts = path.split("."); |
| 71 | let current: unknown = config; |
| 72 | for (let i = 0; i < parts.length; i++) { |
| 73 | if (current === null || typeof current !== "object") return false; |
| 74 | if (!(parts[i] in current)) return false; |
| 75 | current = (current as Record<string, unknown>)[parts[i]]; |
| 76 | } |
| 77 | // Must be a leaf value, not an intermediate object that would wipe children. |
| 78 | return current === null || typeof current !== "object"; |
| 79 | } |
| 80 | |
| 81 | /** Format the entire config as a readable tree (leaf values only). */ |
| 82 | function formatConfigTree(config: PluginConfig): string { |
no outgoing calls
no test coverage detected