meteo-lt-sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +280 -0
- package/dist/__tests__/test-utils.d.ts +240 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/__tests__/test-utils.js +278 -0
- package/dist/__tests__/test-utils.js.map +1 -0
- package/dist/api/hydro-stations.d.ts +133 -0
- package/dist/api/hydro-stations.d.ts.map +1 -0
- package/dist/api/hydro-stations.js +148 -0
- package/dist/api/hydro-stations.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/places.d.ts +78 -0
- package/dist/api/places.d.ts.map +1 -0
- package/dist/api/places.js +87 -0
- package/dist/api/places.js.map +1 -0
- package/dist/api/stations.d.ts +80 -0
- package/dist/api/stations.d.ts.map +1 -0
- package/dist/api/stations.js +89 -0
- package/dist/api/stations.js.map +1 -0
- package/dist/client/MeteoClient.d.ts +85 -0
- package/dist/client/MeteoClient.d.ts.map +1 -0
- package/dist/client/MeteoClient.js +92 -0
- package/dist/client/MeteoClient.js.map +1 -0
- package/dist/client/config.d.ts +57 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +29 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/http.d.ts +36 -0
- package/dist/client/http.d.ts.map +1 -0
- package/dist/client/http.js +115 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +7 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/rate-limiter.d.ts +64 -0
- package/dist/client/rate-limiter.d.ts.map +1 -0
- package/dist/client/rate-limiter.js +150 -0
- package/dist/client/rate-limiter.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/coordinates.d.ts +26 -0
- package/dist/schemas/coordinates.d.ts.map +1 -0
- package/dist/schemas/coordinates.js +32 -0
- package/dist/schemas/coordinates.js.map +1 -0
- package/dist/schemas/forecasts.d.ts +93 -0
- package/dist/schemas/forecasts.d.ts.map +1 -0
- package/dist/schemas/forecasts.js +38 -0
- package/dist/schemas/forecasts.js.map +1 -0
- package/dist/schemas/hydro-stations.d.ts +172 -0
- package/dist/schemas/hydro-stations.d.ts.map +1 -0
- package/dist/schemas/hydro-stations.js +99 -0
- package/dist/schemas/hydro-stations.js.map +1 -0
- package/dist/schemas/index.d.ts +10 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +15 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/places.d.ts +77 -0
- package/dist/schemas/places.d.ts.map +1 -0
- package/dist/schemas/places.js +45 -0
- package/dist/schemas/places.js.map +1 -0
- package/dist/schemas/stations.d.ts +167 -0
- package/dist/schemas/stations.d.ts.map +1 -0
- package/dist/schemas/stations.js +69 -0
- package/dist/schemas/stations.js.map +1 -0
- package/dist/types/conditions.d.ts +47 -0
- package/dist/types/conditions.d.ts.map +1 -0
- package/dist/types/conditions.js +132 -0
- package/dist/types/conditions.js.map +1 -0
- package/dist/types/coordinates.d.ts +63 -0
- package/dist/types/coordinates.d.ts.map +1 -0
- package/dist/types/coordinates.js +58 -0
- package/dist/types/coordinates.js.map +1 -0
- package/dist/types/errors.d.ts +94 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +116 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/forecasts.d.ts +49 -0
- package/dist/types/forecasts.d.ts.map +1 -0
- package/dist/types/forecasts.js +6 -0
- package/dist/types/forecasts.js.map +1 -0
- package/dist/types/hydro-stations.d.ts +143 -0
- package/dist/types/hydro-stations.d.ts.map +1 -0
- package/dist/types/hydro-stations.js +6 -0
- package/dist/types/hydro-stations.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/places.d.ts +54 -0
- package/dist/types/places.d.ts.map +1 -0
- package/dist/types/places.js +6 -0
- package/dist/types/places.js.map +1 -0
- package/dist/types/stations.d.ts +90 -0
- package/dist/types/stations.d.ts.map +1 -0
- package/dist/types/stations.js +6 -0
- package/dist/types/stations.js.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test utilities and mock helpers for Meteo.lt SDK tests.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates a mock fetch function that returns the specified response.
|
|
6
|
+
*/
|
|
7
|
+
export function createMockFetch(response, options = {}) {
|
|
8
|
+
const { status = 200, statusText = 'OK', headers = {} } = options;
|
|
9
|
+
return async () => {
|
|
10
|
+
const responseHeaders = new Headers(headers);
|
|
11
|
+
return new Response(JSON.stringify(response), {
|
|
12
|
+
status,
|
|
13
|
+
statusText,
|
|
14
|
+
headers: responseHeaders,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a mock fetch that throws a network error.
|
|
20
|
+
*/
|
|
21
|
+
export function createNetworkErrorFetch(message = 'Network error') {
|
|
22
|
+
return async () => {
|
|
23
|
+
throw new Error(message);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a mock fetch that times out via AbortController.
|
|
28
|
+
*/
|
|
29
|
+
export function createTimeoutFetch() {
|
|
30
|
+
return async (_url, init) => {
|
|
31
|
+
// Simulate timeout by checking abort signal
|
|
32
|
+
if (init?.signal) {
|
|
33
|
+
const error = new DOMException('The operation was aborted', 'AbortError');
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
return new Response('{}', { status: 200 });
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a resolved config with a mock fetch.
|
|
41
|
+
*/
|
|
42
|
+
export function createMockConfig(mockFetch, overrides = {}) {
|
|
43
|
+
return {
|
|
44
|
+
baseUrl: 'https://api.meteo.lt/v1/',
|
|
45
|
+
timeout: 1000,
|
|
46
|
+
fetch: mockFetch,
|
|
47
|
+
headers: {},
|
|
48
|
+
throttle: false,
|
|
49
|
+
...overrides,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sample data for testing places API.
|
|
54
|
+
*/
|
|
55
|
+
export const MOCK_PLACES = [
|
|
56
|
+
{
|
|
57
|
+
code: 'vilnius',
|
|
58
|
+
name: 'Vilnius',
|
|
59
|
+
administrativeDivision: 'Vilniaus miesto savivaldybė',
|
|
60
|
+
countryCode: 'LT',
|
|
61
|
+
coordinates: { latitude: 54.6872, longitude: 25.2797 },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
code: 'kaunas',
|
|
65
|
+
name: 'Kaunas',
|
|
66
|
+
administrativeDivision: 'Kauno miesto savivaldybė',
|
|
67
|
+
countryCode: 'LT',
|
|
68
|
+
coordinates: { latitude: 54.8985, longitude: 23.9036 },
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
export const MOCK_PLACE_DETAILS = {
|
|
72
|
+
code: 'vilnius',
|
|
73
|
+
name: 'Vilnius',
|
|
74
|
+
administrativeDivision: 'Vilniaus miesto savivaldybė',
|
|
75
|
+
country: 'Lietuva',
|
|
76
|
+
countryCode: 'LT',
|
|
77
|
+
coordinates: { latitude: 54.6872, longitude: 25.2797 },
|
|
78
|
+
};
|
|
79
|
+
export const MOCK_FORECAST_TYPES = {
|
|
80
|
+
place: MOCK_PLACE_DETAILS,
|
|
81
|
+
forecastTypes: [
|
|
82
|
+
{ type: 'long-term', description: 'Long-term forecast' },
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
export const MOCK_FORECAST = {
|
|
86
|
+
place: MOCK_PLACE_DETAILS,
|
|
87
|
+
forecastType: 'long-term',
|
|
88
|
+
forecastCreationTimeUtc: '2026-01-04 14:00:00',
|
|
89
|
+
forecastTimestamps: [
|
|
90
|
+
{
|
|
91
|
+
forecastTimeUtc: '2026-01-04 15:00:00',
|
|
92
|
+
airTemperature: -2.5,
|
|
93
|
+
feelsLikeTemperature: -5.0,
|
|
94
|
+
windSpeed: 3.5,
|
|
95
|
+
windGust: 6.2,
|
|
96
|
+
windDirection: 180,
|
|
97
|
+
cloudCover: 75,
|
|
98
|
+
seaLevelPressure: 1015,
|
|
99
|
+
relativeHumidity: 85,
|
|
100
|
+
totalPrecipitation: 0.5,
|
|
101
|
+
conditionCode: 'cloudy',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
forecastTimeUtc: '2026-01-04 18:00:00',
|
|
105
|
+
airTemperature: -4.0,
|
|
106
|
+
feelsLikeTemperature: -7.5,
|
|
107
|
+
windSpeed: 2.0,
|
|
108
|
+
windGust: 4.0,
|
|
109
|
+
windDirection: 200,
|
|
110
|
+
cloudCover: 50,
|
|
111
|
+
seaLevelPressure: 1016,
|
|
112
|
+
relativeHumidity: 80,
|
|
113
|
+
totalPrecipitation: 0,
|
|
114
|
+
conditionCode: 'partly-cloudy',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Sample data for testing stations API.
|
|
120
|
+
*/
|
|
121
|
+
export const MOCK_STATIONS = [
|
|
122
|
+
{
|
|
123
|
+
code: 'vilniaus-ams',
|
|
124
|
+
name: 'Vilniaus AMS',
|
|
125
|
+
coordinates: { latitude: 54.6339, longitude: 25.1008 },
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
code: 'kauno-ams',
|
|
129
|
+
name: 'Kauno AMS',
|
|
130
|
+
coordinates: { latitude: 54.8839, longitude: 23.8365 },
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
export const MOCK_STATION_DETAILS = {
|
|
134
|
+
code: 'vilniaus-ams',
|
|
135
|
+
name: 'Vilniaus AMS',
|
|
136
|
+
type: 'Automatic weather station',
|
|
137
|
+
coordinates: { latitude: 54.6339, longitude: 25.1008 },
|
|
138
|
+
};
|
|
139
|
+
export const MOCK_STATION_OBS_INFO = {
|
|
140
|
+
station: {
|
|
141
|
+
code: 'vilniaus-ams',
|
|
142
|
+
name: 'Vilniaus AMS',
|
|
143
|
+
coordinates: { latitude: 54.6339, longitude: 25.1008 },
|
|
144
|
+
},
|
|
145
|
+
observationsDataRange: {
|
|
146
|
+
startTimeUtc: '2016-01-01 00:00:00',
|
|
147
|
+
endTimeUtc: '2026-01-04 14:00:00',
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
export const MOCK_OBSERVATIONS = {
|
|
151
|
+
station: {
|
|
152
|
+
code: 'vilniaus-ams',
|
|
153
|
+
name: 'Vilniaus AMS',
|
|
154
|
+
coordinates: { latitude: 54.6339, longitude: 25.1008 },
|
|
155
|
+
},
|
|
156
|
+
observations: [
|
|
157
|
+
{
|
|
158
|
+
observationTimeUtc: '2026-01-04 12:00:00',
|
|
159
|
+
airTemperature: -3.2,
|
|
160
|
+
feelsLikeTemperature: -6.5,
|
|
161
|
+
windSpeed: 2.8,
|
|
162
|
+
windGust: 5.1,
|
|
163
|
+
windDirection: 190,
|
|
164
|
+
cloudCover: 80,
|
|
165
|
+
seaLevelPressure: 1014,
|
|
166
|
+
relativeHumidity: 88,
|
|
167
|
+
precipitation: 0.2,
|
|
168
|
+
conditionCode: 'cloudy',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
observationTimeUtc: '2026-01-04 13:00:00',
|
|
172
|
+
airTemperature: -2.8,
|
|
173
|
+
feelsLikeTemperature: -5.8,
|
|
174
|
+
windSpeed: 3.1,
|
|
175
|
+
windGust: 5.5,
|
|
176
|
+
windDirection: 185,
|
|
177
|
+
cloudCover: 75,
|
|
178
|
+
seaLevelPressure: 1015,
|
|
179
|
+
relativeHumidity: 85,
|
|
180
|
+
precipitation: 0,
|
|
181
|
+
conditionCode: 'cloudy-with-sunny-intervals',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Sample data for testing hydro stations API.
|
|
187
|
+
*/
|
|
188
|
+
export const MOCK_HYDRO_STATIONS = [
|
|
189
|
+
{
|
|
190
|
+
code: 'nemajunu-vms',
|
|
191
|
+
name: 'Nemajūnų VMS',
|
|
192
|
+
waterBody: 'Nemunas',
|
|
193
|
+
coordinates: { latitude: 54.4336, longitude: 24.0678 },
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
code: 'kauno-vms',
|
|
197
|
+
name: 'Kauno VMS',
|
|
198
|
+
waterBody: 'Nemunas',
|
|
199
|
+
coordinates: { latitude: 54.8989, longitude: 23.9012 },
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
export const MOCK_HYDRO_OBS_TYPES = {
|
|
203
|
+
station: {
|
|
204
|
+
code: 'nemajunu-vms',
|
|
205
|
+
name: 'Nemajūnų VMS',
|
|
206
|
+
waterBody: 'Nemunas',
|
|
207
|
+
coordinates: { latitude: 54.4336, longitude: 24.0678 },
|
|
208
|
+
},
|
|
209
|
+
observationTypes: [
|
|
210
|
+
{ type: 'measured', description: 'Current year measurements' },
|
|
211
|
+
{ type: 'historical', description: 'Historical data' },
|
|
212
|
+
],
|
|
213
|
+
};
|
|
214
|
+
export const MOCK_HYDRO_MEASURED_INFO = {
|
|
215
|
+
station: {
|
|
216
|
+
code: 'nemajunu-vms',
|
|
217
|
+
name: 'Nemajūnų VMS',
|
|
218
|
+
waterBody: 'Nemunas',
|
|
219
|
+
coordinates: { latitude: 54.4336, longitude: 24.0678 },
|
|
220
|
+
},
|
|
221
|
+
observationsDataRange: {
|
|
222
|
+
startTimeUtc: '2025-12-05 00:00:00',
|
|
223
|
+
endTimeUtc: '2026-01-04 14:00:00',
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
export const MOCK_HYDRO_HISTORICAL_INFO = {
|
|
227
|
+
station: {
|
|
228
|
+
code: 'nemajunu-vms',
|
|
229
|
+
name: 'Nemajūnų VMS',
|
|
230
|
+
waterBody: 'Nemunas',
|
|
231
|
+
coordinates: { latitude: 54.4336, longitude: 24.0678 },
|
|
232
|
+
},
|
|
233
|
+
observationsDataRange: {
|
|
234
|
+
startDateUtc: '2000-01-01',
|
|
235
|
+
endDateUtc: '2025-12-31',
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
export const MOCK_HYDRO_MEASURED_OBS = {
|
|
239
|
+
station: {
|
|
240
|
+
code: 'nemajunu-vms',
|
|
241
|
+
name: 'Nemajūnų VMS',
|
|
242
|
+
waterBody: 'Nemunas',
|
|
243
|
+
coordinates: { latitude: 54.4336, longitude: 24.0678 },
|
|
244
|
+
},
|
|
245
|
+
observations: [
|
|
246
|
+
{
|
|
247
|
+
observationTimeUtc: '2026-01-04 12:00:00',
|
|
248
|
+
waterLevel: 38.5,
|
|
249
|
+
waterTemperature: 2.1,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
observationTimeUtc: '2026-01-04 13:00:00',
|
|
253
|
+
waterLevel: 38.2,
|
|
254
|
+
waterTemperature: 2.0,
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
};
|
|
258
|
+
export const MOCK_HYDRO_HISTORICAL_OBS = {
|
|
259
|
+
station: {
|
|
260
|
+
code: 'nemajunu-vms',
|
|
261
|
+
name: 'Nemajūnų VMS',
|
|
262
|
+
waterBody: 'Nemunas',
|
|
263
|
+
coordinates: { latitude: 54.4336, longitude: 24.0678 },
|
|
264
|
+
},
|
|
265
|
+
observations: [
|
|
266
|
+
{
|
|
267
|
+
observationDateUtc: '2024-06-15',
|
|
268
|
+
waterLevel: 120.5,
|
|
269
|
+
waterDischarge: 285.3,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
observationDateUtc: '2024-06-16',
|
|
273
|
+
waterLevel: 118.2,
|
|
274
|
+
waterDischarge: 278.1,
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
};
|
|
278
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAiB,EACjB,UAAsF,EAAE;IAExF,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,UAAU,GAAG,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAElE,OAAO,KAAK,IAAuB,EAAE;QACnC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YAC5C,MAAM;YACN,UAAU;YACV,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAO,GAAG,eAAe;IAC/D,OAAO,KAAK,IAAuB,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,KAAK,EAAE,IAA4B,EAAE,IAAkB,EAAqB,EAAE;QACnF,4CAA4C;QAC5C,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;YAC1E,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC;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EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;KACvD;IACD,YAAY,EAAE;QACZ;YACE,kBAAkB,EAAE,qBAAqB;YACzC,UAAU,EAAE,IAAI;YAChB,gBAAgB,EAAE,GAAG;SACtB;QACD;YACE,kBAAkB,EAAE,qBAAqB;YACzC,UAAU,EAAE,IAAI;YAChB,gBAAgB,EAAE,GAAG;SACtB;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,OAAO,EAAE;QACP,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,SAAS;QACpB,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;KACvD;IACD,YAAY,EAAE;QACZ;YACE,kBAAkB,EAAE,YAAY;YAChC,UAAU,EAAE,KAAK;YACjB,cAAc,EAAE,KAAK;SACtB;QACD;YACE,kBAAkB,EAAE,YAAY;YAChC,UAAU,EAAE,KAAK;YACjB,cAAc,EAAE,KAAK;SACtB;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Hydrological stations API module.
|
|
3
|
+
* @module meteo-lt-sdk/api/hydro-stations
|
|
4
|
+
*/
|
|
5
|
+
import type { HttpClient } from '../client/http.js';
|
|
6
|
+
import type { HydroStationSummary, HydroStationDetails, HydroStationObservationTypes, HydroStationMeasuredInfo, HydroStationHistoricalInfo, HydroStationMeasuredObservations, HydroStationHistoricalObservations, MeasuredDateParam, HistoricalDateParam } from '../types/hydro-stations.js';
|
|
7
|
+
/**
|
|
8
|
+
* API module for hydrological station operations.
|
|
9
|
+
* Provides methods to query hydro stations and retrieve water observation data.
|
|
10
|
+
*/
|
|
11
|
+
export declare class HydroStationsApi {
|
|
12
|
+
private readonly http;
|
|
13
|
+
constructor(http: HttpClient);
|
|
14
|
+
/**
|
|
15
|
+
* Gets a list of all hydrological stations.
|
|
16
|
+
*
|
|
17
|
+
* @returns Array of hydro station summaries with codes, names, water bodies, and coordinates
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const stations = await client.hydroStations.getAll();
|
|
22
|
+
* console.log(`Found ${stations.length} hydro stations`);
|
|
23
|
+
* stations.forEach(s => console.log(`${s.name} on ${s.waterBody}`));
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
getAll(): Promise<readonly HydroStationSummary[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets detailed information for a specific hydrological station.
|
|
29
|
+
*
|
|
30
|
+
* @param code - Station code (e.g., 'nemajunu-vms')
|
|
31
|
+
* @returns Detailed hydro station information
|
|
32
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const station = await client.hydroStations.get('nemajunu-vms');
|
|
37
|
+
* console.log(`${station.name} monitors ${station.waterBody}`);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
get(code: string): Promise<HydroStationDetails>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets available observation types for a hydro station.
|
|
43
|
+
*
|
|
44
|
+
* @param code - Station code
|
|
45
|
+
* @returns Station info and available observation types (measured, historical)
|
|
46
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const info = await client.hydroStations.getObservationTypes('nemajunu-vms');
|
|
51
|
+
* info.observationTypes.forEach(ot => {
|
|
52
|
+
* console.log(`${ot.type}: ${ot.description}`);
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
getObservationTypes(code: string): Promise<HydroStationObservationTypes>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets information about available measured (current year) observation data.
|
|
59
|
+
*
|
|
60
|
+
* @param code - Station code
|
|
61
|
+
* @returns Station info and available data time range
|
|
62
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const info = await client.hydroStations.getMeasuredInfo('nemajunu-vms');
|
|
67
|
+
* console.log(`Data from ${info.observationsDataRange.startTimeUtc}`);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
getMeasuredInfo(code: string): Promise<HydroStationMeasuredInfo>;
|
|
71
|
+
/**
|
|
72
|
+
* Gets information about available historical observation data.
|
|
73
|
+
*
|
|
74
|
+
* @param code - Station code
|
|
75
|
+
* @returns Station info and available data date range
|
|
76
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const info = await client.hydroStations.getHistoricalInfo('nemajunu-vms');
|
|
81
|
+
* console.log(`Historical data from ${info.observationsDataRange.startDateUtc}`);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
getHistoricalInfo(code: string): Promise<HydroStationHistoricalInfo>;
|
|
85
|
+
/**
|
|
86
|
+
* Gets measured (current year) observation data for a hydro station.
|
|
87
|
+
*
|
|
88
|
+
* @param code - Station code
|
|
89
|
+
* @param date - Date in YYYY-MM-DD format, or 'latest' for last 24 hours.
|
|
90
|
+
* Data is available for the last 30 days.
|
|
91
|
+
* @returns Station info and measured observation data points
|
|
92
|
+
* @throws {MeteoNotFoundError} If no data exists for the requested date
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const data = await client.hydroStations.getMeasuredObservations('nemajunu-vms', 'latest');
|
|
97
|
+
* data.observations.forEach(obs => {
|
|
98
|
+
* console.log(`${obs.observationTimeUtc}: ${obs.waterLevel}cm, ${obs.waterTemperature}°C`);
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
getMeasuredObservations(code: string, date: MeasuredDateParam): Promise<HydroStationMeasuredObservations>;
|
|
103
|
+
/**
|
|
104
|
+
* Gets historical observation data for a hydro station.
|
|
105
|
+
*
|
|
106
|
+
* @param code - Station code
|
|
107
|
+
* @param date - Can be:
|
|
108
|
+
* - 'latest' for last 31 days
|
|
109
|
+
* - 'YYYY-MM' for a specific month
|
|
110
|
+
* - 'YYYY-MM-DD' for a specific day
|
|
111
|
+
* Historical data is available from 2000 onwards.
|
|
112
|
+
* @returns Station info and historical observation data points (daily averages)
|
|
113
|
+
* @throws {MeteoNotFoundError} If no data exists for the requested date
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // Get last 31 days
|
|
118
|
+
* const latest = await client.hydroStations.getHistoricalObservations('nemajunu-vms', 'latest');
|
|
119
|
+
*
|
|
120
|
+
* // Get specific month
|
|
121
|
+
* const monthly = await client.hydroStations.getHistoricalObservations('nemajunu-vms', '2024-06');
|
|
122
|
+
*
|
|
123
|
+
* // Get specific day
|
|
124
|
+
* const daily = await client.hydroStations.getHistoricalObservations('nemajunu-vms', '2024-06-15');
|
|
125
|
+
*
|
|
126
|
+
* latest.observations.forEach(obs => {
|
|
127
|
+
* console.log(`${obs.observationDateUtc}: ${obs.waterLevel}cm, ${obs.waterDischarge}m³/s`);
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
getHistoricalObservations(code: string, date: HistoricalDateParam): Promise<HydroStationHistoricalObservations>;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=hydro-stations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydro-stations.d.ts","sourceRoot":"","sources":["../../src/api/hydro-stations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,EAC1B,gCAAgC,EAChC,kCAAkC,EAClC,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAWpC;;;GAGG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;OAWG;IACG,MAAM,IAAI,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC;IAIvD;;;;;;;;;;;;OAYG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOrD;;;;;;;;;;;;;;OAcG;IACG,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAO9E;;;;;;;;;;;;OAYG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAOtE;;;;;;;;;;;;OAYG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAO1E;;;;;;;;;;;;;;;;OAgBG;IACG,uBAAuB,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,gCAAgC,CAAC;IAO5C;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,yBAAyB,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,kCAAkC,CAAC;CAM/C"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Hydrological stations API module.
|
|
3
|
+
* @module meteo-lt-sdk/api/hydro-stations
|
|
4
|
+
*/
|
|
5
|
+
import { hydroStationSummaryArraySchema, hydroStationSummarySchema, hydroStationObservationTypesSchema, hydroStationMeasuredInfoSchema, hydroStationHistoricalInfoSchema, hydroStationMeasuredObservationsSchema, hydroStationHistoricalObservationsSchema, } from '../schemas/hydro-stations.js';
|
|
6
|
+
/**
|
|
7
|
+
* API module for hydrological station operations.
|
|
8
|
+
* Provides methods to query hydro stations and retrieve water observation data.
|
|
9
|
+
*/
|
|
10
|
+
export class HydroStationsApi {
|
|
11
|
+
http;
|
|
12
|
+
constructor(http) {
|
|
13
|
+
this.http = http;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets a list of all hydrological stations.
|
|
17
|
+
*
|
|
18
|
+
* @returns Array of hydro station summaries with codes, names, water bodies, and coordinates
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const stations = await client.hydroStations.getAll();
|
|
23
|
+
* console.log(`Found ${stations.length} hydro stations`);
|
|
24
|
+
* stations.forEach(s => console.log(`${s.name} on ${s.waterBody}`));
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
async getAll() {
|
|
28
|
+
return this.http.get('hydro-stations', hydroStationSummaryArraySchema);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets detailed information for a specific hydrological station.
|
|
32
|
+
*
|
|
33
|
+
* @param code - Station code (e.g., 'nemajunu-vms')
|
|
34
|
+
* @returns Detailed hydro station information
|
|
35
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const station = await client.hydroStations.get('nemajunu-vms');
|
|
40
|
+
* console.log(`${station.name} monitors ${station.waterBody}`);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
async get(code) {
|
|
44
|
+
return this.http.get(`hydro-stations/${encodeURIComponent(code)}`, hydroStationSummarySchema);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets available observation types for a hydro station.
|
|
48
|
+
*
|
|
49
|
+
* @param code - Station code
|
|
50
|
+
* @returns Station info and available observation types (measured, historical)
|
|
51
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const info = await client.hydroStations.getObservationTypes('nemajunu-vms');
|
|
56
|
+
* info.observationTypes.forEach(ot => {
|
|
57
|
+
* console.log(`${ot.type}: ${ot.description}`);
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
async getObservationTypes(code) {
|
|
62
|
+
return this.http.get(`hydro-stations/${encodeURIComponent(code)}/observations`, hydroStationObservationTypesSchema);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets information about available measured (current year) observation data.
|
|
66
|
+
*
|
|
67
|
+
* @param code - Station code
|
|
68
|
+
* @returns Station info and available data time range
|
|
69
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const info = await client.hydroStations.getMeasuredInfo('nemajunu-vms');
|
|
74
|
+
* console.log(`Data from ${info.observationsDataRange.startTimeUtc}`);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
async getMeasuredInfo(code) {
|
|
78
|
+
return this.http.get(`hydro-stations/${encodeURIComponent(code)}/observations/measured`, hydroStationMeasuredInfoSchema);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets information about available historical observation data.
|
|
82
|
+
*
|
|
83
|
+
* @param code - Station code
|
|
84
|
+
* @returns Station info and available data date range
|
|
85
|
+
* @throws {MeteoNotFoundError} If the station code doesn't exist
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const info = await client.hydroStations.getHistoricalInfo('nemajunu-vms');
|
|
90
|
+
* console.log(`Historical data from ${info.observationsDataRange.startDateUtc}`);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
async getHistoricalInfo(code) {
|
|
94
|
+
return this.http.get(`hydro-stations/${encodeURIComponent(code)}/observations/historical`, hydroStationHistoricalInfoSchema);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets measured (current year) observation data for a hydro station.
|
|
98
|
+
*
|
|
99
|
+
* @param code - Station code
|
|
100
|
+
* @param date - Date in YYYY-MM-DD format, or 'latest' for last 24 hours.
|
|
101
|
+
* Data is available for the last 30 days.
|
|
102
|
+
* @returns Station info and measured observation data points
|
|
103
|
+
* @throws {MeteoNotFoundError} If no data exists for the requested date
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const data = await client.hydroStations.getMeasuredObservations('nemajunu-vms', 'latest');
|
|
108
|
+
* data.observations.forEach(obs => {
|
|
109
|
+
* console.log(`${obs.observationTimeUtc}: ${obs.waterLevel}cm, ${obs.waterTemperature}°C`);
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
async getMeasuredObservations(code, date) {
|
|
114
|
+
return this.http.get(`hydro-stations/${encodeURIComponent(code)}/observations/measured/${encodeURIComponent(date)}`, hydroStationMeasuredObservationsSchema);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets historical observation data for a hydro station.
|
|
118
|
+
*
|
|
119
|
+
* @param code - Station code
|
|
120
|
+
* @param date - Can be:
|
|
121
|
+
* - 'latest' for last 31 days
|
|
122
|
+
* - 'YYYY-MM' for a specific month
|
|
123
|
+
* - 'YYYY-MM-DD' for a specific day
|
|
124
|
+
* Historical data is available from 2000 onwards.
|
|
125
|
+
* @returns Station info and historical observation data points (daily averages)
|
|
126
|
+
* @throws {MeteoNotFoundError} If no data exists for the requested date
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* // Get last 31 days
|
|
131
|
+
* const latest = await client.hydroStations.getHistoricalObservations('nemajunu-vms', 'latest');
|
|
132
|
+
*
|
|
133
|
+
* // Get specific month
|
|
134
|
+
* const monthly = await client.hydroStations.getHistoricalObservations('nemajunu-vms', '2024-06');
|
|
135
|
+
*
|
|
136
|
+
* // Get specific day
|
|
137
|
+
* const daily = await client.hydroStations.getHistoricalObservations('nemajunu-vms', '2024-06-15');
|
|
138
|
+
*
|
|
139
|
+
* latest.observations.forEach(obs => {
|
|
140
|
+
* console.log(`${obs.observationDateUtc}: ${obs.waterLevel}cm, ${obs.waterDischarge}m³/s`);
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
async getHistoricalObservations(code, date) {
|
|
145
|
+
return this.http.get(`hydro-stations/${encodeURIComponent(code)}/observations/historical/${encodeURIComponent(date)}`, hydroStationHistoricalObservationsSchema);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=hydro-stations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydro-stations.js","sourceRoot":"","sources":["../../src/api/hydro-stations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,kCAAkC,EAClC,8BAA8B,EAC9B,gCAAgC,EAChC,sCAAsC,EACtC,wCAAwC,GACzC,MAAM,8BAA8B,CAAC;AAEtC;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,8BAA8B,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,kBAAkB,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAC5C,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,mBAA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AM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Places API module.
|
|
3
|
+
* @module meteo-lt-sdk/api/places
|
|
4
|
+
*/
|
|
5
|
+
import type { HttpClient } from '../client/http.js';
|
|
6
|
+
import type { PlaceSummary, PlaceDetails, PlaceForecastTypes, ForecastType } from '../types/places.js';
|
|
7
|
+
import type { Forecast } from '../types/forecasts.js';
|
|
8
|
+
/**
|
|
9
|
+
* API module for place and forecast operations.
|
|
10
|
+
* Provides methods to query places and retrieve weather forecasts.
|
|
11
|
+
*/
|
|
12
|
+
export declare class PlacesApi {
|
|
13
|
+
private readonly http;
|
|
14
|
+
constructor(http: HttpClient);
|
|
15
|
+
/**
|
|
16
|
+
* Gets a list of all places with weather forecast support.
|
|
17
|
+
*
|
|
18
|
+
* @returns Array of place summaries with codes, names, and coordinates
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const places = await client.places.getAll();
|
|
23
|
+
* console.log(`Found ${places.length} places`);
|
|
24
|
+
* places.forEach(p => console.log(`${p.name} (${p.code})`));
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
getAll(): Promise<readonly PlaceSummary[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets detailed information for a specific place.
|
|
30
|
+
*
|
|
31
|
+
* @param code - Place code (e.g., 'vilnius', 'kaunas')
|
|
32
|
+
* @returns Detailed place information including country name
|
|
33
|
+
* @throws {MeteoNotFoundError} If the place code doesn't exist
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const place = await client.places.get('vilnius');
|
|
38
|
+
* console.log(`${place.name}, ${place.country}`);
|
|
39
|
+
* console.log(`Coords: ${place.coordinates.latitude}, ${place.coordinates.longitude}`);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
get(code: string): Promise<PlaceDetails>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets available forecast types for a place.
|
|
45
|
+
*
|
|
46
|
+
* @param code - Place code
|
|
47
|
+
* @returns Place details and available forecast types
|
|
48
|
+
* @throws {MeteoNotFoundError} If the place code doesn't exist
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const info = await client.places.getForecastTypes('vilnius');
|
|
53
|
+
* info.forecastTypes.forEach(ft => {
|
|
54
|
+
* console.log(`${ft.type}: ${ft.description}`);
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
getForecastTypes(code: string): Promise<PlaceForecastTypes>;
|
|
59
|
+
/**
|
|
60
|
+
* Gets weather forecast for a place.
|
|
61
|
+
*
|
|
62
|
+
* @param code - Place code
|
|
63
|
+
* @param type - Forecast type (currently only 'long-term' is supported)
|
|
64
|
+
* @returns Complete forecast with timestamps and weather data
|
|
65
|
+
* @throws {MeteoNotFoundError} If the place code doesn't exist
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const forecast = await client.places.getForecast('vilnius', 'long-term');
|
|
70
|
+
* console.log(`Forecast created: ${forecast.forecastCreationTimeUtc}`);
|
|
71
|
+
* forecast.forecastTimestamps.forEach(ts => {
|
|
72
|
+
* console.log(`${ts.forecastTimeUtc}: ${ts.airTemperature}°C, ${ts.conditionCode}`);
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
getForecast(code: string, type: ForecastType): Promise<Forecast>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=places.d.ts.map
|