(value: unknown)
| 22 | } |
| 23 | |
| 24 | export function normalizeProfilesData(value: unknown): ProfilesData { |
| 25 | if (!isRecord(value) || !isRecord(value.profiles)) { |
| 26 | return DEFAULT_PROFILES_DATA; |
| 27 | } |
| 28 | |
| 29 | const profiles: ProfilesData['profiles'] = {}; |
| 30 | for (const [name, config] of Object.entries(value.profiles)) { |
| 31 | if (name === DEFAULT_PROFILE_NAME) continue; |
| 32 | |
| 33 | const validation = validateConfiguration(config); |
| 34 | if (validation.valid && validation.config !== null) { |
| 35 | profiles[name] = validation.config; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | return { |
| 40 | profiles, |
| 41 | activeProfile: normalizeActiveProfile(value.activeProfile, profiles), |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | export function parseProfilesDataJson(stored: string | null): ProfilesData { |
| 46 | if (!stored) return DEFAULT_PROFILES_DATA; |
no test coverage detected