Files
wtr/types/weather-region.ts
zv 2182297adc
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m54s
feat: add global weather support
2026-06-14 15:59:14 +02:00

54 lines
1.3 KiB
TypeScript

export type WeatherRegion = "PL" | "GLOBAL";
export type WeatherSource = "IMGW" | "ALARO" | "OPEN_METEO";
export type WeatherSourceType = "observation" | "model" | "hybrid" | "official_warning";
export interface WeatherCapabilities {
current: boolean;
forecastHourly: boolean;
forecastDaily: boolean;
officialWarnings: boolean;
countyFiltering: boolean;
brief: boolean;
pushOfficialAlerts: boolean;
}
export interface WeatherSourceMetadata {
source: WeatherSource;
sourceLabel: string;
sourceType: WeatherSourceType;
isOfficial: boolean;
fetchedAt?: string;
generatedAt?: string;
}
export const WEATHER_CAPABILITIES: Record<WeatherRegion, WeatherCapabilities> = {
PL: {
current: true,
forecastHourly: true,
forecastDaily: true,
officialWarnings: true,
countyFiltering: true,
brief: true,
pushOfficialAlerts: true,
},
GLOBAL: {
current: true,
forecastHourly: true,
forecastDaily: true,
officialWarnings: false,
countyFiltering: false,
brief: true,
pushOfficialAlerts: false,
},
};
export function getWeatherRegionForCountryCode(countryCode?: string | null): WeatherRegion {
return countryCode?.trim().toUpperCase() === "PL" ? "PL" : "GLOBAL";
}
export function getWeatherCapabilities(region?: WeatherRegion | null) {
return WEATHER_CAPABILITIES[region ?? "PL"];
}