(scope: string, regionId?: string)
| 52 | * |
| 53 | */ |
| 54 | export function buildRegionQueryKey(scope: string, regionId?: string) { |
| 55 | const store = getStore(); |
| 56 | const maybeRegionId = store.get(currentRegionIdAtomLoadable); |
| 57 | const currentRegionId = |
| 58 | maybeRegionId.state === "hasData" ? maybeRegionId.data : "no-region"; |
| 59 | |
| 60 | // Get the environment version if available |
| 61 | const environments = store.get(environmentsWithHealth); |
| 62 | const environment = environments?.get(regionId ?? currentRegionId); |
| 63 | const environmentVersion = |
| 64 | environment && |
| 65 | environment.state === "enabled" && |
| 66 | environment.status.health === "healthy" |
| 67 | ? environment.status.version.crateVersion.version |
| 68 | : undefined; |
| 69 | |
| 70 | return [ |
| 71 | buildQueryKeyPart(scope, { |
| 72 | regionId: regionId ?? currentRegionId, |
| 73 | environmentVersion, |
| 74 | }), |
| 75 | ] as const; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * A function that takes a scope (used for identification) and returns a query key. |
no test coverage detected