( source: SettingSource, )
| 317 | } |
| 318 | |
| 319 | function getSettingsForSourceUncached( |
| 320 | source: SettingSource, |
| 321 | ): SettingsJson | null { |
| 322 | // For policySettings: first source wins (remote > HKLM/plist > file > HKCU) |
| 323 | if (source === 'policySettings') { |
| 324 | const remoteSettings = getRemoteManagedSettingsSyncFromCache() |
| 325 | if (remoteSettings && Object.keys(remoteSettings).length > 0) { |
| 326 | return remoteSettings |
| 327 | } |
| 328 | |
| 329 | const mdmResult = getMdmSettings() |
| 330 | if (Object.keys(mdmResult.settings).length > 0) { |
| 331 | return mdmResult.settings |
| 332 | } |
| 333 | |
| 334 | const { settings: fileSettings } = loadManagedFileSettings() |
| 335 | if (fileSettings) { |
| 336 | return fileSettings |
| 337 | } |
| 338 | |
| 339 | const hkcu = getHkcuSettings() |
| 340 | if (Object.keys(hkcu.settings).length > 0) { |
| 341 | return hkcu.settings |
| 342 | } |
| 343 | |
| 344 | return null |
| 345 | } |
| 346 | |
| 347 | const settingsFilePath = getSettingsFilePathForSource(source) |
| 348 | const { settings: fileSettings } = settingsFilePath |
| 349 | ? parseSettingsFile(settingsFilePath) |
| 350 | : { settings: null } |
| 351 | |
| 352 | // For flagSettings, merge in any inline settings set via the SDK |
| 353 | if (source === 'flagSettings') { |
| 354 | const inlineSettings = getFlagSettingsInline() |
| 355 | if (inlineSettings) { |
| 356 | const parsed = SettingsSchema().safeParse(inlineSettings) |
| 357 | if (parsed.success) { |
| 358 | return mergeWith( |
| 359 | fileSettings || {}, |
| 360 | parsed.data, |
| 361 | settingsMergeCustomizer, |
| 362 | ) as SettingsJson |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | return fileSettings |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * Get the origin of the highest-priority active policy settings source. |
no test coverage detected