@telemetryos/root-sdk 1.8.3 → 1.10.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/dist/mqtt.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { Client, type MessageHandler } from './client.js';
2
+ export type MqttBrokerInfo = {
3
+ name: string;
4
+ address: string;
5
+ port: number;
6
+ protocol: 'mqtt' | 'mqtts' | 'ws' | 'wss';
7
+ };
8
+ export type MqttConnectOptions = {
9
+ username?: string;
10
+ password?: string;
11
+ clientId?: string;
12
+ keepalive?: number;
13
+ clean?: boolean;
14
+ reconnectPeriod?: number;
15
+ connectTimeout?: number;
16
+ };
17
+ export type MqttPublishOptions = {
18
+ qos?: 0 | 1 | 2;
19
+ retain?: boolean;
20
+ };
21
+ export type MqttSubscribeOptions = {
22
+ qos?: 0 | 1 | 2;
23
+ };
24
+ export type MqttConnectionStatus = 'connected' | 'disconnected' | 'connecting' | 'reconnecting' | 'error';
25
+ export type MqttMessage = {
26
+ topic: string;
27
+ payload: string;
28
+ qos: 0 | 1 | 2;
29
+ retain: boolean;
30
+ };
31
+ export declare class Mqtt {
32
+ _client: Client;
33
+ constructor(client: Client);
34
+ discover(): Promise<MqttBrokerInfo[]>;
35
+ connect(brokerUrl: string, options?: MqttConnectOptions): Promise<string>;
36
+ disconnect(clientId: string): Promise<void>;
37
+ publish(clientId: string, topic: string, payload: string, options?: MqttPublishOptions): Promise<void>;
38
+ subscribe(clientId: string, topic: string, handler: MessageHandler<MqttMessage>, options?: MqttSubscribeOptions): Promise<boolean>;
39
+ unsubscribe(clientId: string, topic: string, handler?: MessageHandler<MqttMessage>): Promise<boolean>;
40
+ getConnectionStatus(clientId: string): Promise<MqttConnectionStatus>;
41
+ subscribeConnectionStatus(clientId: string, handler: MessageHandler<MqttConnectionStatus>): Promise<boolean>;
42
+ unsubscribeConnectionStatus(clientId: string, handler?: MessageHandler<MqttConnectionStatus>): Promise<boolean>;
43
+ }
package/dist/weather.d.ts CHANGED
@@ -1,165 +1,378 @@
1
1
  import type { Client } from './client.js';
2
2
  /**
3
- * Weather condition data with current conditions
3
+ * Weather location information shared across all weather endpoints
4
4
  */
5
- export type WeatherConditions = {
6
- /** City name (localized) */
7
- CityLocalized: string;
8
- /** City name (English) */
9
- CityEnglish: string;
10
- /** Wind abbreviation */
11
- WindAbbr: string;
12
- /** ISO country code */
13
- CountryCode: string;
14
- /** Timezone */
15
- Timezone: string;
16
- /** Weather description text */
17
- WeatherText: string;
18
- /** State/Province */
19
- State: string;
20
- /** Part of day (day/night indicator) */
21
- Pod: string;
22
- /** Weather code (internal mapping) */
23
- WeatherCode: string;
24
- /** Wind direction in degrees */
25
- WindDirectionDegrees: string;
26
- /** Wind direction (cardinal direction in English) */
27
- WindDirectionEnglish: string;
28
- /** Wind direction (localized) */
29
- WindDirectionLocalized: string;
30
- /** Relative humidity percentage */
31
- RelativeHumidity: number;
32
- /** Unix timestamp */
33
- Timestamp: number;
34
- /** Longitude */
35
- Longitude: number;
36
- /** Latitude */
37
- Latitude: number;
38
- /** Temperature */
39
- Temp: number;
40
- /** Atmospheric pressure */
41
- Pressure: number;
42
- /** Wind speed */
43
- WindSpeed: number;
44
- /** Visibility distance */
45
- Visibility: number;
46
- /** Precipitation amount */
47
- Precip: number;
5
+ type WeatherLocation = {
6
+ latitude: number;
7
+ longitude: number;
8
+ cityName: string;
9
+ stateName?: string;
10
+ stateCode?: string;
11
+ countryName: string;
12
+ countryCode: string;
13
+ timezone: string;
48
14
  };
49
15
  /**
50
- * Weather forecast data point
16
+ * Current weather conditions
51
17
  */
52
- export type WeatherForecast = {
53
- /** ISO datetime string */
54
- Datetime: string;
55
- /** Part of day (day/night indicator) */
56
- Pod: string;
57
- /** Weather description label */
58
- Label: string;
59
- /** Weather code */
60
- WeatherCode: string;
61
- /** Unix timestamp */
62
- Timestamp: number;
63
- /** Temperature */
64
- Temp: number;
65
- /** Minimum temperature */
66
- MinTemp: number;
67
- /** Maximum temperature */
68
- MaxTemp: number;
18
+ export type WeatherPartOfDay = 'day' | 'night';
19
+ export type WeatherConditions = WeatherLocation & {
20
+ observedAtSec: number;
21
+ observedAtLocal: string;
22
+ sunrise: string;
23
+ sunset: string;
24
+ partOfDay: WeatherPartOfDay;
25
+ weatherCode: number;
26
+ weatherDescription: string;
27
+ weatherIcon: string;
28
+ temperatureC: number;
29
+ temperatureF: number;
30
+ temperatureFeelsLikeC: number;
31
+ temperatureFeelsLikeF: number;
32
+ dewPointC: number;
33
+ dewPointF: number;
34
+ windSpeedKph: number;
35
+ windSpeedMph: number;
36
+ gustSpeedKph: number;
37
+ gustSpeedMph: number;
38
+ windDirectionDeg: number;
39
+ windDirectionFull: string;
40
+ windDirectionShort: string;
41
+ pressureMb: number;
42
+ pressureInHg: number;
43
+ seaLevelPressureMb: number;
44
+ seaLevelPressureInHg: number;
45
+ visibilityKm: number;
46
+ visibilityMi: number;
47
+ humidity: number;
48
+ clouds: number;
49
+ precipitationRateMmph: number;
50
+ precipitationRateInph: number;
51
+ snowfallRateMmph: number;
52
+ snowfallRateInph: number;
53
+ uvIndex: number;
54
+ airQualityIndex: number;
69
55
  };
70
56
  /**
71
- * Parameters for weather requests
57
+ * Single day of forecast data
72
58
  */
73
- export type WeatherRequestParams = {
74
- /** City name (can include state/country: "city, state, country") */
75
- city?: string;
76
- /** Postal/ZIP code (alternative to city) */
77
- postalCode?: string;
78
- /** Latitude (if city not provided) */
79
- lat?: string;
80
- /** Longitude (if city not provided) */
81
- lon?: string;
82
- /** Units system: "imperial" or "metric" */
83
- units?: 'imperial' | 'metric';
84
- /** Language code for localized responses */
59
+ export type DailyForecastData = {
60
+ forecastDate: string;
61
+ forecastDateSec: number;
62
+ weatherCode: number;
63
+ weatherDescription: string;
64
+ weatherIcon: string;
65
+ precipitationProbability: number;
66
+ temperatureC: number;
67
+ temperatureF: number;
68
+ maxTemperatureC: number;
69
+ maxTemperatureF: number;
70
+ minTemperatureC: number;
71
+ minTemperatureF: number;
72
+ highTemperatureC: number;
73
+ highTemperatureF: number;
74
+ lowTemperatureC: number;
75
+ lowTemperatureF: number;
76
+ maxTemperatureFeelsLikeC: number;
77
+ maxTemperatureFeelsLikeF: number;
78
+ minTemperatureFeelsLikeC: number;
79
+ minTemperatureFeelsLikeF: number;
80
+ dewPointC: number;
81
+ dewPointF: number;
82
+ windSpeedKph: number;
83
+ windSpeedMph: number;
84
+ gustSpeedKph: number;
85
+ gustSpeedMph: number;
86
+ windDirectionDeg: number;
87
+ windDirectionFull: string;
88
+ windDirectionShort: string;
89
+ pressureMb: number;
90
+ pressureInHg: number;
91
+ seaLevelPressureMb: number;
92
+ seaLevelPressureInHg: number;
93
+ visibilityKm: number;
94
+ visibilityMi: number;
95
+ humidity: number;
96
+ clouds: number;
97
+ precipitationMm: number;
98
+ precipitationIn: number;
99
+ snowfallMm: number;
100
+ snowfallIn: number;
101
+ snowDepthMm: number;
102
+ snowDepthIn: number;
103
+ uvIndex: number;
104
+ sunrise: string;
105
+ sunset: string;
106
+ moonrise: string;
107
+ moonset: string;
108
+ moonIllumination: number;
109
+ moonLunationPhase: number;
110
+ };
111
+ /**
112
+ * Daily weather forecast with location
113
+ */
114
+ export type DailyForecast = WeatherLocation & {
115
+ data: DailyForecastData[];
116
+ };
117
+ /**
118
+ * Single hour of forecast data
119
+ */
120
+ export type HourlyForecastData = {
121
+ forecastTimeSec: number;
122
+ forecastTimeLocal: string;
123
+ forecastTimeUtc: string;
124
+ partOfDay: WeatherPartOfDay;
125
+ weatherCode: number;
126
+ weatherDescription: string;
127
+ weatherIcon: string;
128
+ precipitationProbability: number;
129
+ temperatureC: number;
130
+ temperatureF: number;
131
+ temperatureFeelsLikeC: number;
132
+ temperatureFeelsLikeF: number;
133
+ dewPointC: number;
134
+ dewPointF: number;
135
+ windSpeedKph: number;
136
+ windSpeedMph: number;
137
+ gustSpeedKph: number;
138
+ gustSpeedMph: number;
139
+ windDirectionDeg: number;
140
+ windDirectionFull: string;
141
+ windDirectionShort: string;
142
+ pressureMb: number;
143
+ pressureInHg: number;
144
+ seaLevelPressureMb: number;
145
+ seaLevelPressureInHg: number;
146
+ visibilityKm: number;
147
+ visibilityMi: number;
148
+ humidity: number;
149
+ clouds: number;
150
+ precipitationMm: number;
151
+ precipitationIn: number;
152
+ snowfallMm: number;
153
+ snowfallIn: number;
154
+ snowDepthMm: number;
155
+ snowDepthIn: number;
156
+ uvIndex: number;
157
+ };
158
+ /**
159
+ * Hourly weather forecast with location
160
+ */
161
+ export type HourlyForecast = WeatherLocation & {
162
+ data: HourlyForecastData[];
163
+ };
164
+ /**
165
+ * Single weather alert/warning
166
+ */
167
+ export type WeatherAlertSeverity = 'Advisory' | 'Watch' | 'Warning';
168
+ export type WeatherAlert = {
169
+ title: string;
170
+ description: string;
171
+ severity: WeatherAlertSeverity;
172
+ effectiveSec: number;
173
+ effectiveUtc: string;
174
+ effectiveLocal: string;
175
+ expiresSec: number;
176
+ expiresUtc: string;
177
+ expiresLocal: string;
178
+ onsetSec?: number;
179
+ onsetUtc?: string;
180
+ onsetLocal?: string;
181
+ endsSec?: number;
182
+ endsUtc?: string;
183
+ endsLocal?: string;
184
+ uri: string;
185
+ regions: string[];
186
+ };
187
+ /**
188
+ * Weather alerts with location
189
+ */
190
+ export type WeatherAlerts = WeatherLocation & {
191
+ alerts: WeatherAlert[];
192
+ };
193
+ /**
194
+ * City information for location search
195
+ */
196
+ export type WeatherCity = {
197
+ cityId: number;
198
+ cityName: string;
199
+ stateName?: string;
200
+ stateCode?: string;
201
+ countryName: string;
202
+ countryCode: string;
203
+ latitude: number;
204
+ longitude: number;
205
+ };
206
+ /**
207
+ * Parameters for getting current weather conditions
208
+ */
209
+ export type WeatherConditionsParams = {
210
+ /** WeatherBit city ID (required) */
211
+ cityId: number;
212
+ /** Language code for localized responses (optional) */
85
213
  language?: string;
86
214
  };
87
215
  /**
88
- * Parameters for daily forecast requests
216
+ * Parameters for getting daily forecast
89
217
  */
90
- export type DailyForecastParams = WeatherRequestParams & {
91
- /** Number of days to forecast */
218
+ export type DailyForecastParams = {
219
+ /** WeatherBit city ID (required) */
220
+ cityId: number;
221
+ /** Language code for localized responses (optional) */
222
+ language?: string;
223
+ /** Number of days to forecast, max 16 (optional, default 5) */
92
224
  days?: number;
93
225
  };
94
226
  /**
95
- * Parameters for hourly forecast requests
227
+ * Parameters for getting hourly forecast
96
228
  */
97
- export type HourlyForecastParams = WeatherRequestParams & {
98
- /** Number of hours to forecast */
229
+ export type HourlyForecastParams = {
230
+ /** WeatherBit city ID (required) */
231
+ cityId: number;
232
+ /** Language code for localized responses (optional) */
233
+ language?: string;
234
+ /** Number of hours to forecast, max 120 (optional, default 12) */
99
235
  hours?: number;
100
236
  };
237
+ /**
238
+ * Parameters for getting weather alerts
239
+ */
240
+ export type WeatherAlertsParams = {
241
+ /** WeatherBit city ID (required) */
242
+ cityId: number;
243
+ /** Language code for localized responses (optional) */
244
+ language?: string;
245
+ };
246
+ /**
247
+ * Parameters for searching cities
248
+ */
249
+ export type CitiesSearchParams = {
250
+ /** ISO country code filter (optional) */
251
+ countryCode?: string;
252
+ /** City name search query (optional) */
253
+ search?: string;
254
+ };
101
255
  /**
102
256
  * Weather API for retrieving weather data
103
257
  *
104
- * Provides access to current conditions and forecasts through the TelemetryOS API.
258
+ * Provides access to current conditions, forecasts, alerts, and city search
259
+ * through the TelemetryOS weather API v2.
105
260
  */
106
261
  export declare class Weather {
107
262
  _client: Client;
108
263
  constructor(client: Client);
109
264
  /**
110
- * Retrieves current weather conditions for a specified location.
265
+ * Searches for cities by name or country
266
+ *
267
+ * @param params - Search parameters including optional country code and search query
268
+ * @returns A promise that resolves to an array of matching cities
269
+ * @throws {Error} If the request fails
270
+ *
271
+ * @example
272
+ * ```typescript
273
+ * // Search for cities named "New York"
274
+ * const cities = await weather.getCities({ search: 'New York' })
275
+ *
276
+ * // Search for cities in the United States
277
+ * const cities = await weather.getCities({ countryCode: 'US' })
278
+ *
279
+ * // Get a cityId for use in other methods
280
+ * const cities = await weather.getCities({ search: 'London' })
281
+ * const cityId = cities[0].cityId
282
+ * ```
283
+ */
284
+ getCities(params: CitiesSearchParams): Promise<WeatherCity[]>;
285
+ /**
286
+ * Retrieves current weather conditions for a specified city
111
287
  *
112
- * @param params - Weather request parameters including location and units
113
- * @returns A promise that resolves to the current weather conditions
114
- * @throws {Error} If the request fails or location is invalid
288
+ * @param params - Weather request parameters including cityId and optional language
289
+ * @returns A promise that resolves to the current weather conditions with dual units (C/F, kph/mph, etc.)
290
+ * @throws {Error} If the request fails or cityId is invalid
115
291
  *
116
292
  * @example
117
293
  * ```typescript
118
- * // Get weather by city
119
- * const weather = await weather.getConditions({ city: 'New York', units: 'imperial' })
294
+ * // Get current conditions for a city
295
+ * const conditions = await weather.getConditions({ cityId: 12345 })
120
296
  *
121
- * // Get weather by postal code
122
- * const weather = await weather.getConditions({ postalCode: '10001', units: 'metric' })
297
+ * // With localized language
298
+ * const conditions = await weather.getConditions({
299
+ * cityId: 12345,
300
+ * language: 'es'
301
+ * })
123
302
  *
124
- * // Get weather by coordinates
125
- * const weather = await weather.getConditions({ lat: '40.7128', lon: '-74.0060' })
303
+ * // Access both units
304
+ * console.log(`${conditions.temperatureC}°C / ${conditions.temperatureF}°F`)
305
+ * console.log(`${conditions.windSpeedKph} kph / ${conditions.windSpeedMph} mph`)
126
306
  * ```
127
307
  */
128
- getConditions(params: WeatherRequestParams): Promise<WeatherConditions>;
308
+ getConditions(params: WeatherConditionsParams): Promise<WeatherConditions>;
129
309
  /**
130
- * Retrieves daily weather forecast for a specified location.
310
+ * Retrieves daily weather forecast for a specified city
131
311
  *
132
- * @param params - Forecast request parameters including location, units, and number of days
133
- * @returns A promise that resolves to an array of daily forecast data
134
- * @throws {Error} If the request fails or location is invalid
312
+ * @param params - Forecast request parameters including cityId, optional language and days
313
+ * @returns A promise that resolves to daily forecast data with location information
314
+ * @throws {Error} If the request fails or cityId is invalid
135
315
  *
136
316
  * @example
137
317
  * ```typescript
138
318
  * // Get 5-day forecast
139
- * const forecast = await weather.getDailyForecast({
140
- * city: 'London',
141
- * units: 'metric',
142
- * days: 5
319
+ * const forecast = await weather.getDailyForecast({ cityId: 12345 })
320
+ *
321
+ * // Get 10-day forecast
322
+ * const forecast = await weather.getDailyForecast({ cityId: 12345, days: 10 })
323
+ *
324
+ * // Access forecast data
325
+ * forecast.data.forEach(day => {
326
+ * console.log(`${day.forecastDate}: ${day.weatherDescription}`)
327
+ * console.log(`High: ${day.maxTemperatureC}°C, Low: ${day.minTemperatureC}°C`)
143
328
  * })
144
329
  * ```
145
330
  */
146
- getDailyForecast(params: DailyForecastParams): Promise<WeatherForecast[]>;
331
+ getDailyForecast(params: DailyForecastParams): Promise<DailyForecast>;
147
332
  /**
148
- * Retrieves hourly weather forecast for a specified location.
333
+ * Retrieves hourly weather forecast for a specified city
149
334
  *
150
- * @param params - Forecast request parameters including location, units, and number of hours
151
- * @returns A promise that resolves to an array of hourly forecast data
152
- * @throws {Error} If the request fails or location is invalid
335
+ * @param params - Forecast request parameters including cityId, optional language and hours
336
+ * @returns A promise that resolves to hourly forecast data with location information
337
+ * @throws {Error} If the request fails or cityId is invalid
153
338
  *
154
339
  * @example
155
340
  * ```typescript
156
341
  * // Get 24-hour forecast
157
- * const forecast = await weather.getHourlyForecast({
158
- * city: 'Tokyo',
159
- * units: 'metric',
160
- * hours: 24
342
+ * const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 24 })
343
+ *
344
+ * // Get 48-hour forecast
345
+ * const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 48 })
346
+ *
347
+ * // Access forecast data
348
+ * forecast.data.forEach(hour => {
349
+ * console.log(`${hour.forecastTimeLocal}: ${hour.weatherDescription}`)
350
+ * console.log(`Temp: ${hour.temperatureC}°C`)
161
351
  * })
162
352
  * ```
163
353
  */
164
- getHourlyForecast(params: HourlyForecastParams): Promise<WeatherForecast[]>;
354
+ getHourlyForecast(params: HourlyForecastParams): Promise<HourlyForecast>;
355
+ /**
356
+ * Retrieves weather alerts and warnings for a specified city
357
+ *
358
+ * @param params - Alert request parameters including cityId and optional language
359
+ * @returns A promise that resolves to weather alerts with location information
360
+ * @throws {Error} If the request fails or cityId is invalid
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * // Get weather alerts for a city
365
+ * const alerts = await weather.getAlerts({ cityId: 12345 })
366
+ *
367
+ * // Check if there are any active alerts
368
+ * if (alerts.alerts.length > 0) {
369
+ * alerts.alerts.forEach(alert => {
370
+ * console.log(`${alert.severity}: ${alert.title}`)
371
+ * console.log(alert.description)
372
+ * })
373
+ * }
374
+ * ```
375
+ */
376
+ getAlerts(params: WeatherAlertsParams): Promise<WeatherAlerts>;
165
377
  }
378
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telemetryos/root-sdk",
3
- "version": "1.8.3",
3
+ "version": "1.10.0",
4
4
  "description": "The official TelemetryOS root application sdk package. Provides types and apis for building root TelemetryOS applications.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",