( source: SettingSource, )
| 402 | } |
| 403 | |
| 404 | function getSettingsForSourceUncached( |
| 405 | source: SettingSource, |
| 406 | ): SettingsJson | null { |
| 407 | // For policySettings: first source wins (remote > HKLM/plist > file > HKCU) |
| 408 | if (source === 'policySettings') { |
| 409 | const remoteSettings = getRemoteManagedSettingsSyncFromCache() |
| 410 | if (remoteSettings && Object.keys(remoteSettings).length > 0) { |
| 411 | return remoteSettings |
| 412 | } |
| 413 | |
| 414 | const mdmResult = getMdmSettings() |
| 415 | if (Object.keys(mdmResult.settings).length > 0) { |
| 416 | return mdmResult.settings |
| 417 | } |
| 418 | |
| 419 | const { settings: fileSettings } = loadManagedFileSettings() |
| 420 | if (fileSettings) { |
| 421 | return fileSettings |
| 422 | } |
| 423 | |
| 424 | const hkcu = getHkcuSettings() |
| 425 | if (Object.keys(hkcu.settings).length > 0) { |
| 426 | return hkcu.settings |
| 427 | } |
| 428 | |
| 429 | return null |
| 430 | } |
| 431 | |
| 432 | const settingsFilePath = getSettingsFilePathForSource(source) |
| 433 | const { settings: fileSettings } = settingsFilePath |
| 434 | ? parseSettingsFile(settingsFilePath) |
| 435 | : { settings: null } |
| 436 | |
| 437 | // For flagSettings, merge in any inline settings set via the SDK |
| 438 | if (source === 'flagSettings') { |
| 439 | const inlineSettings = getFlagSettingsInline() |
| 440 | if (inlineSettings) { |
| 441 | const parsed = SettingsSchema().safeParse(inlineSettings) |
| 442 | if (parsed.success) { |
| 443 | return mergeWith( |
| 444 | fileSettings || {}, |
| 445 | parsed.data, |
| 446 | settingsMergeCustomizer, |
| 447 | ) as SettingsJson |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | return fileSettings |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * Get the origin of the highest-priority active policy settings source. |
no test coverage detected