@selinac887/weather-sdk 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/src/index.ts +10 -0
package/dist/index.d.ts
CHANGED
|
@@ -36,11 +36,14 @@ export interface GetForecastInput extends BaseLocationInput {
|
|
|
36
36
|
daily?: string[];
|
|
37
37
|
forecastHours?: number;
|
|
38
38
|
forecastDays?: number;
|
|
39
|
+
current?: string[];
|
|
39
40
|
}
|
|
40
41
|
export interface GetForecastResponse {
|
|
41
42
|
hourly?: HourlyForecast;
|
|
42
43
|
hourly_units?: HourlyForecastUnits;
|
|
43
44
|
daily?: DailyForecast;
|
|
44
45
|
daily_units?: DailyForecastUnits;
|
|
46
|
+
current?: CurrentWeather;
|
|
47
|
+
current_units?: CurrentWeatherUnits;
|
|
45
48
|
}
|
|
46
49
|
export declare function getForecast(input: GetForecastInput): Promise<GetForecastResponse>;
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export async function getCurrentWeather(input) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
export async function getForecast(input) {
|
|
19
|
-
const { latitude, longitude, timezone = "auto", hourly, daily, forecastHours, forecastDays, } = input;
|
|
19
|
+
const { latitude, longitude, timezone = "auto", hourly, daily, forecastHours, forecastDays, current, } = input;
|
|
20
20
|
const url = new URL("https://api.open-meteo.com/v1/forecast");
|
|
21
21
|
url.searchParams.set("latitude", latitude.toString());
|
|
22
22
|
url.searchParams.set("longitude", longitude.toString());
|
|
@@ -33,6 +33,9 @@ export async function getForecast(input) {
|
|
|
33
33
|
url.searchParams.set("forecast_days", forecastDays.toString());
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
if (current?.length) {
|
|
37
|
+
url.searchParams.set("current", current.join(","));
|
|
38
|
+
}
|
|
36
39
|
const res = await fetch(url.toString());
|
|
37
40
|
if (!res.ok) {
|
|
38
41
|
throw new Error(`Open-Meteo API error: ${res.status}`);
|
|
@@ -46,5 +49,7 @@ export async function getForecast(input) {
|
|
|
46
49
|
hourly_units: hourlyUnits,
|
|
47
50
|
daily: raw.daily,
|
|
48
51
|
daily_units: dailyUnits,
|
|
52
|
+
current: raw.current,
|
|
53
|
+
current_units: raw.current_units,
|
|
49
54
|
};
|
|
50
55
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -76,6 +76,7 @@ export interface GetForecastInput extends BaseLocationInput {
|
|
|
76
76
|
daily?: string[];
|
|
77
77
|
forecastHours?: number;
|
|
78
78
|
forecastDays?: number;
|
|
79
|
+
current?: string[];
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
export interface GetForecastResponse {
|
|
@@ -83,6 +84,8 @@ export interface GetForecastResponse {
|
|
|
83
84
|
hourly_units?: HourlyForecastUnits;
|
|
84
85
|
daily?: DailyForecast;
|
|
85
86
|
daily_units?: DailyForecastUnits;
|
|
87
|
+
current?: CurrentWeather;
|
|
88
|
+
current_units?: CurrentWeatherUnits;
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
export async function getForecast(
|
|
@@ -96,6 +99,7 @@ export async function getForecast(
|
|
|
96
99
|
daily,
|
|
97
100
|
forecastHours,
|
|
98
101
|
forecastDays,
|
|
102
|
+
current,
|
|
99
103
|
} = input;
|
|
100
104
|
|
|
101
105
|
const url = new URL("https://api.open-meteo.com/v1/forecast");
|
|
@@ -117,6 +121,10 @@ export async function getForecast(
|
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
|
|
124
|
+
if (current?.length) {
|
|
125
|
+
url.searchParams.set("current", current.join(","));
|
|
126
|
+
}
|
|
127
|
+
|
|
120
128
|
const res = await fetch(url.toString());
|
|
121
129
|
if (!res.ok) {
|
|
122
130
|
throw new Error(`Open-Meteo API error: ${res.status}`);
|
|
@@ -133,5 +141,7 @@ export async function getForecast(
|
|
|
133
141
|
hourly_units: hourlyUnits,
|
|
134
142
|
daily: raw.daily,
|
|
135
143
|
daily_units: dailyUnits,
|
|
144
|
+
current: raw.current,
|
|
145
|
+
current_units: raw.current_units,
|
|
136
146
|
};
|
|
137
147
|
}
|