|
| 1 | +## ADDED Requirements |
| 2 | + |
| 3 | +### Requirement: API key resolved via computed atom |
| 4 | + |
| 5 | +The Maps container SHALL provide a `ComputedAtom<string | null>` that reactively resolves the API key from widget props. |
| 6 | + |
| 7 | +#### Scenario: Expression value takes priority |
| 8 | + |
| 9 | +- **WHEN** `apiKeyExp.value` is a non-empty string |
| 10 | +- **THEN** the atom returns that value |
| 11 | + |
| 12 | +#### Scenario: Falls back to static apiKey |
| 13 | + |
| 14 | +- **WHEN** `apiKeyExp.value` is undefined or empty |
| 15 | +- **AND** `apiKey` is a non-empty string |
| 16 | +- **THEN** the atom returns the static `apiKey` value |
| 17 | + |
| 18 | +#### Scenario: Returns null when no key available |
| 19 | + |
| 20 | +- **WHEN** both `apiKeyExp.value` and `apiKey` are empty or undefined |
| 21 | +- **THEN** the atom returns `null` |
| 22 | + |
| 23 | +### Requirement: API key cached once resolved |
| 24 | + |
| 25 | +Once the atom returns a non-null value, it SHALL cache that value permanently and never revert to `null`. |
| 26 | + |
| 27 | +#### Scenario: Key remains after expression becomes unavailable |
| 28 | + |
| 29 | +- **WHEN** the atom has previously returned a non-null value |
| 30 | +- **AND** `apiKeyExp.value` subsequently becomes undefined |
| 31 | +- **THEN** the atom still returns the previously cached value |
| 32 | + |
| 33 | +### Requirement: API key atom registered in DI container |
| 34 | + |
| 35 | +The atom SHALL be registered as a `CORE_TOKENS.apiKey` token in the Maps container and injectable into services. |
| 36 | + |
| 37 | +#### Scenario: LocationResolverService uses atom |
| 38 | + |
| 39 | +- **WHEN** `LocationResolverService` needs the API key for geocoding |
| 40 | +- **THEN** it reads from the injected `ComputedAtom<string | null>` via `.get()` |
| 41 | + |
| 42 | +### Requirement: Geodecode API key resolved via computed atom |
| 43 | + |
| 44 | +The Maps container SHALL provide a `ComputedAtom<string | null>` that reactively resolves the geodecode API key from widget props, following the same pattern as the main API key atom. |
| 45 | + |
| 46 | +#### Scenario: Expression value takes priority |
| 47 | + |
| 48 | +- **WHEN** `geodecodeApiKeyExp.value` is a non-empty string |
| 49 | +- **THEN** the atom returns that value |
| 50 | + |
| 51 | +#### Scenario: Falls back to static geodecodeApiKey |
| 52 | + |
| 53 | +- **WHEN** `geodecodeApiKeyExp.value` is undefined or empty |
| 54 | +- **AND** `geodecodeApiKey` is a non-empty string |
| 55 | +- **THEN** the atom returns the static `geodecodeApiKey` value |
| 56 | + |
| 57 | +#### Scenario: Returns null when no key available |
| 58 | + |
| 59 | +- **WHEN** both `geodecodeApiKeyExp.value` and `geodecodeApiKey` are empty or undefined |
| 60 | +- **THEN** the atom returns `null` |
| 61 | + |
| 62 | +### Requirement: Geodecode API key cached once resolved |
| 63 | + |
| 64 | +Once the geodecode atom returns a non-null value, it SHALL cache that value permanently and never revert to `null`. |
| 65 | + |
| 66 | +#### Scenario: Key remains after expression becomes unavailable |
| 67 | + |
| 68 | +- **WHEN** the atom has previously returned a non-null value |
| 69 | +- **AND** `geodecodeApiKeyExp.value` subsequently becomes undefined |
| 70 | +- **THEN** the atom still returns the previously cached value |
| 71 | + |
| 72 | +### Requirement: apiKey and geodecodeApiKey removed from MapsConfig |
| 73 | + |
| 74 | +The static `MapsConfig` interface SHALL NOT contain `apiKey` or `geodecodeApiKey` fields. Both keys are resolved reactively via atoms. |
| 75 | + |
| 76 | +#### Scenario: MapsConfig only contains static fields |
| 77 | + |
| 78 | +- **WHEN** `mapsConfig()` is called |
| 79 | +- **THEN** the returned object contains `id`, `name`, and `showCurrentLocation` only |
0 commit comments