( key: string, settings: Settings, mergedSettings: Settings, )
| 112 | * Always returns a value (never undefined) - falls back to default if not set anywhere |
| 113 | */ |
| 114 | export function getEffectiveValue( |
| 115 | key: string, |
| 116 | settings: Settings, |
| 117 | mergedSettings: Settings, |
| 118 | ): SettingDefinition['default'] { |
| 119 | const definition = getSettingDefinition(key); |
| 120 | if (!definition) { |
| 121 | return undefined; |
| 122 | } |
| 123 | |
| 124 | const path = key.split('.'); |
| 125 | |
| 126 | // Check the current scope's settings first |
| 127 | let value = getNestedValue(settings as Record<string, unknown>, path); |
| 128 | if (value !== undefined) { |
| 129 | return value as SettingDefinition['default']; |
| 130 | } |
| 131 | |
| 132 | // Check the merged settings for an inherited value |
| 133 | value = getNestedValue(mergedSettings as Record<string, unknown>, path); |
| 134 | if (value !== undefined) { |
| 135 | return value as SettingDefinition['default']; |
| 136 | } |
| 137 | |
| 138 | // Return default value if no value is set anywhere |
| 139 | return definition.default; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Get all setting keys from the schema |
no test coverage detected