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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +280 -0
  3. package/dist/__tests__/test-utils.d.ts +240 -0
  4. package/dist/__tests__/test-utils.d.ts.map +1 -0
  5. package/dist/__tests__/test-utils.js +278 -0
  6. package/dist/__tests__/test-utils.js.map +1 -0
  7. package/dist/api/hydro-stations.d.ts +133 -0
  8. package/dist/api/hydro-stations.d.ts.map +1 -0
  9. package/dist/api/hydro-stations.js +148 -0
  10. package/dist/api/hydro-stations.js.map +1 -0
  11. package/dist/api/index.d.ts +8 -0
  12. package/dist/api/index.d.ts.map +1 -0
  13. package/dist/api/index.js +8 -0
  14. package/dist/api/index.js.map +1 -0
  15. package/dist/api/places.d.ts +78 -0
  16. package/dist/api/places.d.ts.map +1 -0
  17. package/dist/api/places.js +87 -0
  18. package/dist/api/places.js.map +1 -0
  19. package/dist/api/stations.d.ts +80 -0
  20. package/dist/api/stations.d.ts.map +1 -0
  21. package/dist/api/stations.js +89 -0
  22. package/dist/api/stations.js.map +1 -0
  23. package/dist/client/MeteoClient.d.ts +85 -0
  24. package/dist/client/MeteoClient.d.ts.map +1 -0
  25. package/dist/client/MeteoClient.js +92 -0
  26. package/dist/client/MeteoClient.js.map +1 -0
  27. package/dist/client/config.d.ts +57 -0
  28. package/dist/client/config.d.ts.map +1 -0
  29. package/dist/client/config.js +29 -0
  30. package/dist/client/config.js.map +1 -0
  31. package/dist/client/http.d.ts +36 -0
  32. package/dist/client/http.d.ts.map +1 -0
  33. package/dist/client/http.js +115 -0
  34. package/dist/client/http.js.map +1 -0
  35. package/dist/client/index.d.ts +8 -0
  36. package/dist/client/index.d.ts.map +1 -0
  37. package/dist/client/index.js +7 -0
  38. package/dist/client/index.js.map +1 -0
  39. package/dist/client/rate-limiter.d.ts +64 -0
  40. package/dist/client/rate-limiter.d.ts.map +1 -0
  41. package/dist/client/rate-limiter.js +150 -0
  42. package/dist/client/rate-limiter.js.map +1 -0
  43. package/dist/index.d.ts +36 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +43 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/schemas/coordinates.d.ts +26 -0
  48. package/dist/schemas/coordinates.d.ts.map +1 -0
  49. package/dist/schemas/coordinates.js +32 -0
  50. package/dist/schemas/coordinates.js.map +1 -0
  51. package/dist/schemas/forecasts.d.ts +93 -0
  52. package/dist/schemas/forecasts.d.ts.map +1 -0
  53. package/dist/schemas/forecasts.js +38 -0
  54. package/dist/schemas/forecasts.js.map +1 -0
  55. package/dist/schemas/hydro-stations.d.ts +172 -0
  56. package/dist/schemas/hydro-stations.d.ts.map +1 -0
  57. package/dist/schemas/hydro-stations.js +99 -0
  58. package/dist/schemas/hydro-stations.js.map +1 -0
  59. package/dist/schemas/index.d.ts +10 -0
  60. package/dist/schemas/index.d.ts.map +1 -0
  61. package/dist/schemas/index.js +15 -0
  62. package/dist/schemas/index.js.map +1 -0
  63. package/dist/schemas/places.d.ts +77 -0
  64. package/dist/schemas/places.d.ts.map +1 -0
  65. package/dist/schemas/places.js +45 -0
  66. package/dist/schemas/places.js.map +1 -0
  67. package/dist/schemas/stations.d.ts +167 -0
  68. package/dist/schemas/stations.d.ts.map +1 -0
  69. package/dist/schemas/stations.js +69 -0
  70. package/dist/schemas/stations.js.map +1 -0
  71. package/dist/types/conditions.d.ts +47 -0
  72. package/dist/types/conditions.d.ts.map +1 -0
  73. package/dist/types/conditions.js +132 -0
  74. package/dist/types/conditions.js.map +1 -0
  75. package/dist/types/coordinates.d.ts +63 -0
  76. package/dist/types/coordinates.d.ts.map +1 -0
  77. package/dist/types/coordinates.js +58 -0
  78. package/dist/types/coordinates.js.map +1 -0
  79. package/dist/types/errors.d.ts +94 -0
  80. package/dist/types/errors.d.ts.map +1 -0
  81. package/dist/types/errors.js +116 -0
  82. package/dist/types/errors.js.map +1 -0
  83. package/dist/types/forecasts.d.ts +49 -0
  84. package/dist/types/forecasts.d.ts.map +1 -0
  85. package/dist/types/forecasts.js +6 -0
  86. package/dist/types/forecasts.js.map +1 -0
  87. package/dist/types/hydro-stations.d.ts +143 -0
  88. package/dist/types/hydro-stations.d.ts.map +1 -0
  89. package/dist/types/hydro-stations.js +6 -0
  90. package/dist/types/hydro-stations.js.map +1 -0
  91. package/dist/types/index.d.ts +14 -0
  92. package/dist/types/index.d.ts.map +1 -0
  93. package/dist/types/index.js +9 -0
  94. package/dist/types/index.js.map +1 -0
  95. package/dist/types/places.d.ts +54 -0
  96. package/dist/types/places.d.ts.map +1 -0
  97. package/dist/types/places.js +6 -0
  98. package/dist/types/places.js.map +1 -0
  99. package/dist/types/stations.d.ts +90 -0
  100. package/dist/types/stations.d.ts.map +1 -0
  101. package/dist/types/stations.js +6 -0
  102. package/dist/types/stations.js.map +1 -0
  103. package/package.json +90 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"places.d.ts","sourceRoot":"","sources":["../../src/api/places.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD;;;GAGG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;OAWG;IACG,MAAM,IAAI,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC;IAIhD;;;;;;;;;;;;;OAaG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI9C;;;;;;;;;;;;;;OAcG;IACG,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOjE;;;;;;;;;;;;;;;;OAgBG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;CAMvE"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @fileoverview Places API module.
3
+ * @module meteo-lt-sdk/api/places
4
+ */
5
+ import { placeSummaryArraySchema, placeDetailsSchema, placeForecastTypesSchema, } from '../schemas/places.js';
6
+ import { forecastSchema } from '../schemas/forecasts.js';
7
+ /**
8
+ * API module for place and forecast operations.
9
+ * Provides methods to query places and retrieve weather forecasts.
10
+ */
11
+ export class PlacesApi {
12
+ http;
13
+ constructor(http) {
14
+ this.http = http;
15
+ }
16
+ /**
17
+ * Gets a list of all places with weather forecast support.
18
+ *
19
+ * @returns Array of place summaries with codes, names, and coordinates
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const places = await client.places.getAll();
24
+ * console.log(`Found ${places.length} places`);
25
+ * places.forEach(p => console.log(`${p.name} (${p.code})`));
26
+ * ```
27
+ */
28
+ async getAll() {
29
+ return this.http.get('places', placeSummaryArraySchema);
30
+ }
31
+ /**
32
+ * Gets detailed information for a specific place.
33
+ *
34
+ * @param code - Place code (e.g., 'vilnius', 'kaunas')
35
+ * @returns Detailed place information including country name
36
+ * @throws {MeteoNotFoundError} If the place code doesn't exist
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const place = await client.places.get('vilnius');
41
+ * console.log(`${place.name}, ${place.country}`);
42
+ * console.log(`Coords: ${place.coordinates.latitude}, ${place.coordinates.longitude}`);
43
+ * ```
44
+ */
45
+ async get(code) {
46
+ return this.http.get(`places/${encodeURIComponent(code)}`, placeDetailsSchema);
47
+ }
48
+ /**
49
+ * Gets available forecast types for a place.
50
+ *
51
+ * @param code - Place code
52
+ * @returns Place details and available forecast types
53
+ * @throws {MeteoNotFoundError} If the place code doesn't exist
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const info = await client.places.getForecastTypes('vilnius');
58
+ * info.forecastTypes.forEach(ft => {
59
+ * console.log(`${ft.type}: ${ft.description}`);
60
+ * });
61
+ * ```
62
+ */
63
+ async getForecastTypes(code) {
64
+ return this.http.get(`places/${encodeURIComponent(code)}/forecasts`, placeForecastTypesSchema);
65
+ }
66
+ /**
67
+ * Gets weather forecast for a place.
68
+ *
69
+ * @param code - Place code
70
+ * @param type - Forecast type (currently only 'long-term' is supported)
71
+ * @returns Complete forecast with timestamps and weather data
72
+ * @throws {MeteoNotFoundError} If the place code doesn't exist
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const forecast = await client.places.getForecast('vilnius', 'long-term');
77
+ * console.log(`Forecast created: ${forecast.forecastCreationTimeUtc}`);
78
+ * forecast.forecastTimestamps.forEach(ts => {
79
+ * console.log(`${ts.forecastTimeUtc}: ${ts.airTemperature}°C, ${ts.conditionCode}`);
80
+ * });
81
+ * ```
82
+ */
83
+ async getForecast(code, type) {
84
+ return this.http.get(`places/${encodeURIComponent(code)}/forecasts/${encodeURIComponent(type)}`, forecastSchema);
85
+ }
86
+ }
87
+ //# sourceMappingURL=places.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"places.js","sourceRoot":"","sources":["../../src/api/places.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;GAGG;AACH,MAAM,OAAO,SAAS;IACS;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,gBAAgB,CAAC,IAAY;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,UAAU,kBAAkB,CAAC,IAAI,CAAC,YAAY,EAC9C,wBAAwB,CACzB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,IAAkB;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,UAAU,kBAAkB,CAAC,IAAI,CAAC,cAAc,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAC1E,cAAc,CACf,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @fileoverview Meteorological stations API module.
3
+ * @module meteo-lt-sdk/api/stations
4
+ */
5
+ import type { HttpClient } from '../client/http.js';
6
+ import type { StationSummary, StationDetails, StationObservationsInfo, StationObservations, ObservationDateParam } from '../types/stations.js';
7
+ /**
8
+ * API module for meteorological station operations.
9
+ * Provides methods to query stations and retrieve observation data.
10
+ */
11
+ export declare class StationsApi {
12
+ private readonly http;
13
+ constructor(http: HttpClient);
14
+ /**
15
+ * Gets a list of all meteorological stations.
16
+ *
17
+ * @returns Array of station summaries with codes, names, and coordinates
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const stations = await client.stations.getAll();
22
+ * console.log(`Found ${stations.length} stations`);
23
+ * stations.forEach(s => console.log(`${s.name} (${s.code})`));
24
+ * ```
25
+ */
26
+ getAll(): Promise<readonly StationSummary[]>;
27
+ /**
28
+ * Gets detailed information for a specific station.
29
+ *
30
+ * @param code - Station code (e.g., 'vilniaus-ams')
31
+ * @returns Detailed station information including type
32
+ * @throws {MeteoNotFoundError} If the station code doesn't exist
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const station = await client.stations.get('vilniaus-ams');
37
+ * console.log(`${station.name} (${station.type})`);
38
+ * ```
39
+ */
40
+ get(code: string): Promise<StationDetails>;
41
+ /**
42
+ * Gets information about available observation data for a station.
43
+ *
44
+ * @param code - Station code
45
+ * @returns Station info and available data time range
46
+ * @throws {MeteoNotFoundError} If the station code doesn't exist
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const info = await client.stations.getObservationsInfo('vilniaus-ams');
51
+ * console.log(`Data from ${info.observationsDataRange.startTimeUtc}`);
52
+ * console.log(`Data to ${info.observationsDataRange.endTimeUtc}`);
53
+ * ```
54
+ */
55
+ getObservationsInfo(code: string): Promise<StationObservationsInfo>;
56
+ /**
57
+ * Gets observation data for a station on a specific date.
58
+ *
59
+ * @param code - Station code
60
+ * @param date - Date in YYYY-MM-DD format, or 'latest' for last 24 hours.
61
+ * Historical data is available for the last 10 years.
62
+ * @returns Station info and observation data points
63
+ * @throws {MeteoNotFoundError} If no data exists for the requested date
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // Get latest observations
68
+ * const latest = await client.stations.getObservations('vilniaus-ams', 'latest');
69
+ *
70
+ * // Get specific date
71
+ * const historical = await client.stations.getObservations('vilniaus-ams', '2024-01-15');
72
+ *
73
+ * historical.observations.forEach(obs => {
74
+ * console.log(`${obs.observationTimeUtc}: ${obs.airTemperature}°C`);
75
+ * });
76
+ * ```
77
+ */
78
+ getObservations(code: string, date: ObservationDateParam): Promise<StationObservations>;
79
+ }
80
+ //# sourceMappingURL=stations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stations.d.ts","sourceRoot":"","sources":["../../src/api/stations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAQ9B;;;GAGG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;OAWG;IACG,MAAM,IAAI,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC;IAIlD;;;;;;;;;;;;OAYG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAIhD;;;;;;;;;;;;;OAaG;IACG,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAOzE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,eAAe,CACnB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,mBAAmB,CAAC;CAMhC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @fileoverview Meteorological stations API module.
3
+ * @module meteo-lt-sdk/api/stations
4
+ */
5
+ import { stationSummaryArraySchema, stationDetailsSchema, stationObservationsInfoSchema, stationObservationsSchema, } from '../schemas/stations.js';
6
+ /**
7
+ * API module for meteorological station operations.
8
+ * Provides methods to query stations and retrieve observation data.
9
+ */
10
+ export class StationsApi {
11
+ http;
12
+ constructor(http) {
13
+ this.http = http;
14
+ }
15
+ /**
16
+ * Gets a list of all meteorological stations.
17
+ *
18
+ * @returns Array of station summaries with codes, names, and coordinates
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const stations = await client.stations.getAll();
23
+ * console.log(`Found ${stations.length} stations`);
24
+ * stations.forEach(s => console.log(`${s.name} (${s.code})`));
25
+ * ```
26
+ */
27
+ async getAll() {
28
+ return this.http.get('stations', stationSummaryArraySchema);
29
+ }
30
+ /**
31
+ * Gets detailed information for a specific station.
32
+ *
33
+ * @param code - Station code (e.g., 'vilniaus-ams')
34
+ * @returns Detailed station information including type
35
+ * @throws {MeteoNotFoundError} If the station code doesn't exist
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const station = await client.stations.get('vilniaus-ams');
40
+ * console.log(`${station.name} (${station.type})`);
41
+ * ```
42
+ */
43
+ async get(code) {
44
+ return this.http.get(`stations/${encodeURIComponent(code)}`, stationDetailsSchema);
45
+ }
46
+ /**
47
+ * Gets information about available observation data for a station.
48
+ *
49
+ * @param code - Station code
50
+ * @returns Station info and available data time range
51
+ * @throws {MeteoNotFoundError} If the station code doesn't exist
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const info = await client.stations.getObservationsInfo('vilniaus-ams');
56
+ * console.log(`Data from ${info.observationsDataRange.startTimeUtc}`);
57
+ * console.log(`Data to ${info.observationsDataRange.endTimeUtc}`);
58
+ * ```
59
+ */
60
+ async getObservationsInfo(code) {
61
+ return this.http.get(`stations/${encodeURIComponent(code)}/observations`, stationObservationsInfoSchema);
62
+ }
63
+ /**
64
+ * Gets observation data for a station on a specific date.
65
+ *
66
+ * @param code - Station code
67
+ * @param date - Date in YYYY-MM-DD format, or 'latest' for last 24 hours.
68
+ * Historical data is available for the last 10 years.
69
+ * @returns Station info and observation data points
70
+ * @throws {MeteoNotFoundError} If no data exists for the requested date
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * // Get latest observations
75
+ * const latest = await client.stations.getObservations('vilniaus-ams', 'latest');
76
+ *
77
+ * // Get specific date
78
+ * const historical = await client.stations.getObservations('vilniaus-ams', '2024-01-15');
79
+ *
80
+ * historical.observations.forEach(obs => {
81
+ * console.log(`${obs.observationTimeUtc}: ${obs.airTemperature}°C`);
82
+ * });
83
+ * ```
84
+ */
85
+ async getObservations(code, date) {
86
+ return this.http.get(`stations/${encodeURIComponent(code)}/observations/${encodeURIComponent(date)}`, stationObservationsSchema);
87
+ }
88
+ }
89
+ //# sourceMappingURL=stations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stations.js","sourceRoot":"","sources":["../../src/api/stations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC;;;GAGG;AACH,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,mBAAmB,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,YAAY,kBAAkB,CAAC,IAAI,CAAC,eAAe,EACnD,6BAA6B,CAC9B,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,eAAe,CACnB,IAAY,EACZ,IAA0B;QAE1B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,YAAY,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAC/E,yBAAyB,CAC1B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @fileoverview Main Meteo.lt client.
3
+ * @module meteo-lt-sdk/client/MeteoClient
4
+ */
5
+ import type { MeteoClientConfig } from './config.js';
6
+ import { PlacesApi } from '../api/places.js';
7
+ import { StationsApi } from '../api/stations.js';
8
+ import { HydroStationsApi } from '../api/hydro-stations.js';
9
+ /**
10
+ * Main client for the Meteo.lt API.
11
+ *
12
+ * Provides access to weather forecasts, meteorological observations,
13
+ * and hydrological data from the Lithuanian Hydrometeorological Service (LHMT).
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { MeteoClient } from 'meteo-lt-sdk';
18
+ *
19
+ * const client = new MeteoClient();
20
+ *
21
+ * // Get weather forecast for Vilnius
22
+ * const forecast = await client.places.getForecast('vilnius', 'long-term');
23
+ * console.log(`Current temperature: ${forecast.forecastTimestamps[0]?.airTemperature}°C`);
24
+ *
25
+ * // Get latest observations from a weather station
26
+ * const observations = await client.stations.getObservations('vilniaus-ams', 'latest');
27
+ *
28
+ * // Get water level data
29
+ * const hydroData = await client.hydroStations.getMeasuredObservations('nemajunu-vms', 'latest');
30
+ * ```
31
+ *
32
+ * @example Custom configuration
33
+ * ```typescript
34
+ * const client = new MeteoClient({
35
+ * timeout: 10000, // 10 second timeout
36
+ * headers: { 'X-Custom-Header': 'value' },
37
+ * });
38
+ * ```
39
+ *
40
+ * @remarks
41
+ * Rate Limiting: The API limits requests to 180 per minute per IP address.
42
+ * Daily limit is recommended to be under 20,000 requests per IP.
43
+ *
44
+ * @see {@link https://api.meteo.lt/} Official API documentation
45
+ */
46
+ export declare class MeteoClient {
47
+ private readonly http;
48
+ /**
49
+ * API for places and weather forecasts.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const places = await client.places.getAll();
54
+ * const forecast = await client.places.getForecast('vilnius', 'long-term');
55
+ * ```
56
+ */
57
+ readonly places: PlacesApi;
58
+ /**
59
+ * API for meteorological stations and observations.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const stations = await client.stations.getAll();
64
+ * const data = await client.stations.getObservations('vilniaus-ams', 'latest');
65
+ * ```
66
+ */
67
+ readonly stations: StationsApi;
68
+ /**
69
+ * API for hydrological stations and water observations.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const stations = await client.hydroStations.getAll();
74
+ * const data = await client.hydroStations.getMeasuredObservations('nemajunu-vms', 'latest');
75
+ * ```
76
+ */
77
+ readonly hydroStations: HydroStationsApi;
78
+ /**
79
+ * Creates a new Meteo.lt client.
80
+ *
81
+ * @param config - Optional configuration options
82
+ */
83
+ constructor(config?: MeteoClientConfig);
84
+ }
85
+ //# sourceMappingURL=MeteoClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeteoClient.d.ts","sourceRoot":"","sources":["../../src/client/MeteoClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAElC;;;;;;;;OAQG;IACH,SAAgB,MAAM,EAAE,SAAS,CAAC;IAElC;;;;;;;;OAQG;IACH,SAAgB,QAAQ,EAAE,WAAW,CAAC;IAEtC;;;;;;;;OAQG;IACH,SAAgB,aAAa,EAAE,gBAAgB,CAAC;IAEhD;;;;OAIG;gBACS,MAAM,CAAC,EAAE,iBAAiB;CAOvC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @fileoverview Main Meteo.lt client.
3
+ * @module meteo-lt-sdk/client/MeteoClient
4
+ */
5
+ import { resolveConfig } from './config.js';
6
+ import { HttpClient } from './http.js';
7
+ import { PlacesApi } from '../api/places.js';
8
+ import { StationsApi } from '../api/stations.js';
9
+ import { HydroStationsApi } from '../api/hydro-stations.js';
10
+ /**
11
+ * Main client for the Meteo.lt API.
12
+ *
13
+ * Provides access to weather forecasts, meteorological observations,
14
+ * and hydrological data from the Lithuanian Hydrometeorological Service (LHMT).
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { MeteoClient } from 'meteo-lt-sdk';
19
+ *
20
+ * const client = new MeteoClient();
21
+ *
22
+ * // Get weather forecast for Vilnius
23
+ * const forecast = await client.places.getForecast('vilnius', 'long-term');
24
+ * console.log(`Current temperature: ${forecast.forecastTimestamps[0]?.airTemperature}°C`);
25
+ *
26
+ * // Get latest observations from a weather station
27
+ * const observations = await client.stations.getObservations('vilniaus-ams', 'latest');
28
+ *
29
+ * // Get water level data
30
+ * const hydroData = await client.hydroStations.getMeasuredObservations('nemajunu-vms', 'latest');
31
+ * ```
32
+ *
33
+ * @example Custom configuration
34
+ * ```typescript
35
+ * const client = new MeteoClient({
36
+ * timeout: 10000, // 10 second timeout
37
+ * headers: { 'X-Custom-Header': 'value' },
38
+ * });
39
+ * ```
40
+ *
41
+ * @remarks
42
+ * Rate Limiting: The API limits requests to 180 per minute per IP address.
43
+ * Daily limit is recommended to be under 20,000 requests per IP.
44
+ *
45
+ * @see {@link https://api.meteo.lt/} Official API documentation
46
+ */
47
+ export class MeteoClient {
48
+ http;
49
+ /**
50
+ * API for places and weather forecasts.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const places = await client.places.getAll();
55
+ * const forecast = await client.places.getForecast('vilnius', 'long-term');
56
+ * ```
57
+ */
58
+ places;
59
+ /**
60
+ * API for meteorological stations and observations.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const stations = await client.stations.getAll();
65
+ * const data = await client.stations.getObservations('vilniaus-ams', 'latest');
66
+ * ```
67
+ */
68
+ stations;
69
+ /**
70
+ * API for hydrological stations and water observations.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const stations = await client.hydroStations.getAll();
75
+ * const data = await client.hydroStations.getMeasuredObservations('nemajunu-vms', 'latest');
76
+ * ```
77
+ */
78
+ hydroStations;
79
+ /**
80
+ * Creates a new Meteo.lt client.
81
+ *
82
+ * @param config - Optional configuration options
83
+ */
84
+ constructor(config) {
85
+ const resolved = resolveConfig(config);
86
+ this.http = new HttpClient(resolved);
87
+ this.places = new PlacesApi(this.http);
88
+ this.stations = new StationsApi(this.http);
89
+ this.hydroStations = new HydroStationsApi(this.http);
90
+ }
91
+ }
92
+ //# sourceMappingURL=MeteoClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeteoClient.js","sourceRoot":"","sources":["../../src/client/MeteoClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,WAAW;IACL,IAAI,CAAa;IAElC;;;;;;;;OAQG;IACa,MAAM,CAAY;IAElC;;;;;;;;OAQG;IACa,QAAQ,CAAc;IAEtC;;;;;;;;OAQG;IACa,aAAa,CAAmB;IAEhD;;;;OAIG;IACH,YAAY,MAA0B;QACpC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @fileoverview Client configuration types.
3
+ * @module meteo-lt-sdk/client/config
4
+ */
5
+ /**
6
+ * Configuration options for the Meteo.lt client.
7
+ */
8
+ export interface MeteoClientConfig {
9
+ /**
10
+ * Base URL for the API.
11
+ * @default 'https://api.meteo.lt/v1/'
12
+ */
13
+ readonly baseUrl?: string;
14
+ /**
15
+ * Request timeout in milliseconds.
16
+ * @default 30000
17
+ */
18
+ readonly timeout?: number;
19
+ /**
20
+ * Custom fetch implementation.
21
+ * Useful for testing or custom environments.
22
+ * @default globalThis.fetch
23
+ */
24
+ readonly fetch?: typeof globalThis.fetch;
25
+ /**
26
+ * Custom headers to include in all requests.
27
+ */
28
+ readonly headers?: Readonly<Record<string, string>>;
29
+ /**
30
+ * Enable automatic rate limiting.
31
+ * When true, requests are queued to stay under the API limit (180 req/min).
32
+ * Uses a global rate limiter shared across all MeteoClient instances.
33
+ * @default false
34
+ */
35
+ readonly throttle?: boolean;
36
+ }
37
+ /**
38
+ * Resolved configuration with all defaults applied.
39
+ */
40
+ export interface ResolvedMeteoClientConfig {
41
+ readonly baseUrl: string;
42
+ readonly timeout: number;
43
+ readonly fetch: typeof globalThis.fetch;
44
+ readonly headers: Readonly<Record<string, string>>;
45
+ readonly throttle: boolean;
46
+ }
47
+ /**
48
+ * Default configuration values.
49
+ */
50
+ export declare const DEFAULT_CONFIG: ResolvedMeteoClientConfig;
51
+ /**
52
+ * Resolves partial config with defaults.
53
+ * @param config - Partial configuration
54
+ * @returns Fully resolved configuration
55
+ */
56
+ export declare function resolveConfig(config?: MeteoClientConfig): ResolvedMeteoClientConfig;
57
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/client/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,yBAMnB,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,yBAAyB,CAQnF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Client configuration types.
3
+ * @module meteo-lt-sdk/client/config
4
+ */
5
+ /**
6
+ * Default configuration values.
7
+ */
8
+ export const DEFAULT_CONFIG = {
9
+ baseUrl: 'https://api.meteo.lt/v1/',
10
+ timeout: 30000,
11
+ fetch: globalThis.fetch.bind(globalThis),
12
+ headers: {},
13
+ throttle: false,
14
+ };
15
+ /**
16
+ * Resolves partial config with defaults.
17
+ * @param config - Partial configuration
18
+ * @returns Fully resolved configuration
19
+ */
20
+ export function resolveConfig(config) {
21
+ return {
22
+ baseUrl: config?.baseUrl ?? DEFAULT_CONFIG.baseUrl,
23
+ timeout: config?.timeout ?? DEFAULT_CONFIG.timeout,
24
+ fetch: config?.fetch ?? DEFAULT_CONFIG.fetch,
25
+ headers: config?.headers ?? DEFAULT_CONFIG.headers,
26
+ throttle: config?.throttle ?? DEFAULT_CONFIG.throttle,
27
+ };
28
+ }
29
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/client/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkDH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAA8B;IACvD,OAAO,EAAE,0BAA0B;IACnC,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;IACxC,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,KAAK;CACP,CAAC;AAEX;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,OAAO;QACL,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,OAAO;QAClD,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,OAAO;QAClD,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,cAAc,CAAC,KAAK;QAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,OAAO;QAClD,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,cAAc,CAAC,QAAQ;KACtD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview Typed HTTP client with error handling and validation.
3
+ * @module meteo-lt-sdk/client/http
4
+ */
5
+ import type { z } from 'zod';
6
+ import type { ResolvedMeteoClientConfig } from './config.js';
7
+ /**
8
+ * Internal HTTP client for making API requests.
9
+ * Handles error mapping, timeouts, and response validation.
10
+ */
11
+ export declare class HttpClient {
12
+ private readonly config;
13
+ constructor(config: ResolvedMeteoClientConfig);
14
+ /**
15
+ * Makes a GET request and validates the response.
16
+ * @param path - API endpoint path (relative to base URL)
17
+ * @param schema - Zod schema for response validation
18
+ * @returns Validated and typed response data
19
+ * @throws {MeteoNotFoundError} When the resource is not found (404)
20
+ * @throws {MeteoRateLimitError} When rate limit is exceeded (429)
21
+ * @throws {MeteoApiError} For other HTTP errors
22
+ * @throws {MeteoNetworkError} For network failures
23
+ * @throws {MeteoTimeoutError} When request times out
24
+ * @throws {MeteoValidationError} When response doesn't match schema
25
+ */
26
+ get<T>(path: string, schema: z.ZodType<T>): Promise<T>;
27
+ /**
28
+ * Builds full URL from path.
29
+ */
30
+ private buildUrl;
31
+ /**
32
+ * Maps HTTP error responses to specific error types.
33
+ */
34
+ private handleHttpError;
35
+ }
36
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/client/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAW7D;;;GAGG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,yBAAyB;IAE9D;;;;;;;;;;;OAWG;IACG,GAAG,CAAC,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC;IA6Eb;;OAEG;IACH,OAAO,CAAC,QAAQ;IAQhB;;OAEG;IACH,OAAO,CAAC,eAAe;CAwBxB"}