()
| 226 | * Get environment variables from React Query cache (client-side only) |
| 227 | */ |
| 228 | export function getClientEnvVars(): Record<string, string> { |
| 229 | if (typeof window === 'undefined') return {} |
| 230 | |
| 231 | try { |
| 232 | const allEnvVars = |
| 233 | getQueryClient().getQueryData<Record<string, EnvironmentVariable>>( |
| 234 | environmentKeys.personal() |
| 235 | ) ?? {} |
| 236 | |
| 237 | // Convert environment variables to a simple key-value object |
| 238 | return Object.entries(allEnvVars).reduce( |
| 239 | (acc, [key, variable]) => { |
| 240 | acc[key] = variable.value |
| 241 | return acc |
| 242 | }, |
| 243 | {} as Record<string, string> |
| 244 | ) |
| 245 | } catch (_error) { |
| 246 | // In case of any errors (like in testing), return empty object |
| 247 | return {} |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Creates the request body configuration for custom tools |
no test coverage detected