feat: add global weather support
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m54s
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m54s
This commit is contained in:
53
types/weather-region.ts
Normal file
53
types/weather-region.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
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"];
|
||||
}
|
||||
Reference in New Issue
Block a user