@azohra/meteo.station 0.1.1

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 (160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/air.d.ts +13 -0
  4. package/dist/air.js +76 -0
  5. package/dist/client/index.d.ts +4 -0
  6. package/dist/client/index.js +4 -0
  7. package/dist/client/poll.d.ts +42 -0
  8. package/dist/client/poll.js +121 -0
  9. package/dist/client/stores.d.ts +46 -0
  10. package/dist/client/stores.js +128 -0
  11. package/dist/client/ticker.d.ts +4 -0
  12. package/dist/client/ticker.js +19 -0
  13. package/dist/contract.d.ts +381 -0
  14. package/dist/contract.js +143 -0
  15. package/dist/derive.d.ts +54 -0
  16. package/dist/derive.js +134 -0
  17. package/dist/display.d.ts +28 -0
  18. package/dist/display.js +27 -0
  19. package/dist/elements/elements/AirMatrixElement.d.ts +14 -0
  20. package/dist/elements/elements/AirMatrixElement.js +83 -0
  21. package/dist/elements/elements/CurrentConditionsElement.d.ts +9 -0
  22. package/dist/elements/elements/CurrentConditionsElement.js +52 -0
  23. package/dist/elements/elements/DailyPatternElement.d.ts +15 -0
  24. package/dist/elements/elements/DailyPatternElement.js +200 -0
  25. package/dist/elements/elements/DialElement.d.ts +9 -0
  26. package/dist/elements/elements/DialElement.js +128 -0
  27. package/dist/elements/elements/FreshnessBadgeElement.d.ts +8 -0
  28. package/dist/elements/elements/FreshnessBadgeElement.js +22 -0
  29. package/dist/elements/elements/SparklineElement.d.ts +9 -0
  30. package/dist/elements/elements/SparklineElement.js +74 -0
  31. package/dist/elements/elements/StationCardElement.d.ts +53 -0
  32. package/dist/elements/elements/StationCardElement.js +211 -0
  33. package/dist/elements/elements/StationFeedElement.d.ts +32 -0
  34. package/dist/elements/elements/StationFeedElement.js +215 -0
  35. package/dist/elements/elements/StationStripElement.d.ts +9 -0
  36. package/dist/elements/elements/StationStripElement.js +43 -0
  37. package/dist/elements/elements/StationTableElement.d.ts +18 -0
  38. package/dist/elements/elements/StationTableElement.js +102 -0
  39. package/dist/elements/elements/TrendChartElement.d.ts +10 -0
  40. package/dist/elements/elements/TrendChartElement.js +174 -0
  41. package/dist/elements/elements/WindArrowElement.d.ts +8 -0
  42. package/dist/elements/elements/WindArrowElement.js +14 -0
  43. package/dist/elements/elements/WindHistoryChartElement.d.ts +10 -0
  44. package/dist/elements/elements/WindHistoryChartElement.js +277 -0
  45. package/dist/elements/elements/WindRoseElement.d.ts +17 -0
  46. package/dist/elements/elements/WindRoseElement.js +106 -0
  47. package/dist/elements/elements/atoms.d.ts +48 -0
  48. package/dist/elements/elements/atoms.js +131 -0
  49. package/dist/elements/index.d.ts +48 -0
  50. package/dist/elements/index.js +57 -0
  51. package/dist/elements/lib/ambient.d.ts +15 -0
  52. package/dist/elements/lib/ambient.js +5 -0
  53. package/dist/elements/lib/attributes.js +21 -0
  54. package/dist/elements/lib/base.d.ts +45 -0
  55. package/dist/elements/lib/base.js +152 -0
  56. package/dist/elements/lib/context.js +28 -0
  57. package/dist/elements/lib/fragments.js +45 -0
  58. package/dist/elements/lib/h.js +35 -0
  59. package/dist/elements/register.d.ts +1 -0
  60. package/dist/elements/register.js +5 -0
  61. package/dist/endpoints.d.ts +5 -0
  62. package/dist/endpoints.js +10 -0
  63. package/dist/fixtures.d.ts +23 -0
  64. package/dist/fixtures.js +67 -0
  65. package/dist/format.d.ts +31 -0
  66. package/dist/format.js +82 -0
  67. package/dist/geometry.d.ts +84 -0
  68. package/dist/geometry.js +333 -0
  69. package/dist/index.d.ts +12 -0
  70. package/dist/index.js +12 -0
  71. package/dist/instruments.d.ts +75 -0
  72. package/dist/instruments.js +173 -0
  73. package/dist/merge-current.d.ts +13 -0
  74. package/dist/merge-current.js +54 -0
  75. package/dist/react/components/AirMatrix.d.ts +11 -0
  76. package/dist/react/components/AirMatrix.js +82 -0
  77. package/dist/react/components/CurrentConditions.d.ts +17 -0
  78. package/dist/react/components/CurrentConditions.js +98 -0
  79. package/dist/react/components/DailyPattern.d.ts +19 -0
  80. package/dist/react/components/DailyPattern.js +212 -0
  81. package/dist/react/components/Dial.d.ts +17 -0
  82. package/dist/react/components/Dial.js +133 -0
  83. package/dist/react/components/FreshnessBadge.d.ts +10 -0
  84. package/dist/react/components/FreshnessBadge.js +20 -0
  85. package/dist/react/components/Sparkline.d.ts +17 -0
  86. package/dist/react/components/Sparkline.js +60 -0
  87. package/dist/react/components/StationCard.d.ts +46 -0
  88. package/dist/react/components/StationCard.js +140 -0
  89. package/dist/react/components/StationFeedProvider.d.ts +27 -0
  90. package/dist/react/components/StationFeedProvider.js +40 -0
  91. package/dist/react/components/StationStrip.d.ts +16 -0
  92. package/dist/react/components/StationStrip.js +84 -0
  93. package/dist/react/components/StationTable.d.ts +18 -0
  94. package/dist/react/components/StationTable.js +115 -0
  95. package/dist/react/components/TrendChart.d.ts +14 -0
  96. package/dist/react/components/TrendChart.js +150 -0
  97. package/dist/react/components/WindArrow.d.ts +7 -0
  98. package/dist/react/components/WindArrow.js +21 -0
  99. package/dist/react/components/WindHistoryChart.d.ts +18 -0
  100. package/dist/react/components/WindHistoryChart.js +278 -0
  101. package/dist/react/components/WindRose.d.ts +17 -0
  102. package/dist/react/components/WindRose.js +99 -0
  103. package/dist/react/components/atoms.d.ts +33 -0
  104. package/dist/react/components/atoms.js +136 -0
  105. package/dist/react/hooks/useFreshness.d.ts +6 -0
  106. package/dist/react/hooks/useFreshness.js +21 -0
  107. package/dist/react/hooks/usePolledJson.js +17 -0
  108. package/dist/react/hooks/useStation.d.ts +23 -0
  109. package/dist/react/hooks/useStation.js +42 -0
  110. package/dist/react/hooks/useStationCurrent.d.ts +23 -0
  111. package/dist/react/hooks/useStationCurrent.js +32 -0
  112. package/dist/react/hooks/useStationFeed.d.ts +22 -0
  113. package/dist/react/hooks/useStationFeed.js +28 -0
  114. package/dist/react/index.d.ts +20 -0
  115. package/dist/react/index.js +21 -0
  116. package/dist/react/lib/cells.js +29 -0
  117. package/dist/scene/air-matrix.js +71 -0
  118. package/dist/scene/atoms.js +102 -0
  119. package/dist/scene/card.js +54 -0
  120. package/dist/scene/chart.js +28 -0
  121. package/dist/scene/current.js +66 -0
  122. package/dist/scene/daily-pattern.js +81 -0
  123. package/dist/scene/dial.js +141 -0
  124. package/dist/scene/glyphs.js +24 -0
  125. package/dist/scene/rose.js +120 -0
  126. package/dist/scene/sparkline.js +73 -0
  127. package/dist/scene/strip.js +63 -0
  128. package/dist/scene/table.js +76 -0
  129. package/dist/scene/trend.js +160 -0
  130. package/dist/scene/wind-history.js +148 -0
  131. package/dist/scene/wind-plot.js +214 -0
  132. package/dist/server/adapter.d.ts +28 -0
  133. package/dist/server/adapter.js +32 -0
  134. package/dist/server/adapters/campbell.d.ts +112 -0
  135. package/dist/server/adapters/campbell.js +414 -0
  136. package/dist/server/adapters/tempest.d.ts +27 -0
  137. package/dist/server/adapters/tempest.js +137 -0
  138. package/dist/server/adapters/windnerd.d.ts +39 -0
  139. package/dist/server/adapters/windnerd.js +159 -0
  140. package/dist/server/config.d.ts +135 -0
  141. package/dist/server/config.js +57 -0
  142. package/dist/server/environment.d.ts +48 -0
  143. package/dist/server/environment.js +128 -0
  144. package/dist/server/feed.d.ts +31 -0
  145. package/dist/server/feed.js +216 -0
  146. package/dist/server/handler.d.ts +17 -0
  147. package/dist/server/handler.js +133 -0
  148. package/dist/server/index.d.ts +10 -0
  149. package/dist/server/index.js +10 -0
  150. package/dist/strings.d.ts +118 -0
  151. package/dist/strings.js +237 -0
  152. package/dist/windnerd.d.ts +5 -0
  153. package/dist/windnerd.js +25 -0
  154. package/package.json +97 -0
  155. package/schema/README.md +14 -0
  156. package/schema/example-current.json +48 -0
  157. package/schema/example-feed.json +147 -0
  158. package/schema/stationcurrent.schema.json +641 -0
  159. package/schema/stationfeed.schema.json +656 -0
  160. package/styles.css +1141 -0
@@ -0,0 +1,381 @@
1
+ import { z } from "zod";
2
+ //#region src/contract.d.ts
3
+ declare const STATION_SCHEMA_VERSION = 2;
4
+ declare const UNAVAILABLE_REASONS: readonly ["upstream_error", "timeout", "rate_limited", "contract_break", "not_configured"];
5
+ type UnavailableReason = (typeof UNAVAILABLE_REASONS)[number];
6
+ declare const airConditionsSchema: z.ZodObject<{
7
+ dewPointC: z.ZodNullable<z.ZodNumber>;
8
+ lastLightningStrikeAt: z.ZodNullable<z.ZodString>;
9
+ lastLightningStrikeDistanceKm: z.ZodNullable<z.ZodNumber>;
10
+ lightningStrikeCountLastHour: z.ZodNullable<z.ZodNumber>;
11
+ precipitationMinutesToday: z.ZodNullable<z.ZodNumber>;
12
+ precipitationRateMmPerHour: z.ZodNullable<z.ZodNumber>;
13
+ precipitationTodayMm: z.ZodNullable<z.ZodNumber>;
14
+ pressureTrend: z.ZodNullable<z.ZodEnum<{
15
+ falling: "falling";
16
+ rising: "rising";
17
+ steady: "steady";
18
+ unknown: "unknown";
19
+ }>>;
20
+ relativeHumidityPercent: z.ZodNullable<z.ZodNumber>;
21
+ seaLevelPressureHpa: z.ZodNullable<z.ZodNumber>;
22
+ solarRadiationWm2: z.ZodNullable<z.ZodNumber>;
23
+ uvIndex: z.ZodNullable<z.ZodNumber>;
24
+ }, z.core.$strip>;
25
+ type AirConditions = z.infer<typeof airConditionsSchema>;
26
+ declare const readingSchema: z.ZodObject<{
27
+ observedAt: z.ZodString;
28
+ windAvgMps: z.ZodNumber;
29
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
30
+ windGustMps: z.ZodNullable<z.ZodNumber>;
31
+ windLullMps: z.ZodNullable<z.ZodNumber>;
32
+ temperatureC: z.ZodNullable<z.ZodNumber>;
33
+ windChillC: z.ZodNullable<z.ZodNumber>;
34
+ conditions: z.ZodNullable<z.ZodObject<{
35
+ dewPointC: z.ZodNullable<z.ZodNumber>;
36
+ lastLightningStrikeAt: z.ZodNullable<z.ZodString>;
37
+ lastLightningStrikeDistanceKm: z.ZodNullable<z.ZodNumber>;
38
+ lightningStrikeCountLastHour: z.ZodNullable<z.ZodNumber>;
39
+ precipitationMinutesToday: z.ZodNullable<z.ZodNumber>;
40
+ precipitationRateMmPerHour: z.ZodNullable<z.ZodNumber>;
41
+ precipitationTodayMm: z.ZodNullable<z.ZodNumber>;
42
+ pressureTrend: z.ZodNullable<z.ZodEnum<{
43
+ falling: "falling";
44
+ rising: "rising";
45
+ steady: "steady";
46
+ unknown: "unknown";
47
+ }>>;
48
+ relativeHumidityPercent: z.ZodNullable<z.ZodNumber>;
49
+ seaLevelPressureHpa: z.ZodNullable<z.ZodNumber>;
50
+ solarRadiationWm2: z.ZodNullable<z.ZodNumber>;
51
+ uvIndex: z.ZodNullable<z.ZodNumber>;
52
+ }, z.core.$strip>>;
53
+ }, z.core.$strip>;
54
+ type Reading = z.infer<typeof readingSchema>;
55
+ declare const historyPointSchema: z.ZodObject<{
56
+ observedAt: z.ZodString;
57
+ windAvgMps: z.ZodNumber;
58
+ windGustMps: z.ZodNullable<z.ZodNumber>;
59
+ windLullMps: z.ZodNullable<z.ZodNumber>;
60
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
61
+ temperatureC: z.ZodNullable<z.ZodNumber>;
62
+ seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
63
+ }, z.core.$strip>;
64
+ type HistoryPoint = z.infer<typeof historyPointSchema>;
65
+ declare const historySchema: z.ZodObject<{
66
+ periodMinutes: z.ZodNumber;
67
+ points: z.ZodArray<z.ZodObject<{
68
+ observedAt: z.ZodString;
69
+ windAvgMps: z.ZodNumber;
70
+ windGustMps: z.ZodNullable<z.ZodNumber>;
71
+ windLullMps: z.ZodNullable<z.ZodNumber>;
72
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
73
+ temperatureC: z.ZodNullable<z.ZodNumber>;
74
+ seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$strip>;
77
+ type History = z.infer<typeof historySchema>;
78
+ declare const capabilitiesSchema: z.ZodObject<{
79
+ gustLull: z.ZodBoolean;
80
+ temperature: z.ZodBoolean;
81
+ conditions: z.ZodBoolean;
82
+ history: z.ZodBoolean;
83
+ }, z.core.$strip>;
84
+ type StationCapabilities = z.infer<typeof capabilitiesSchema>;
85
+ declare const stationMetaSchema: z.ZodObject<{
86
+ id: z.ZodString;
87
+ name: z.ZodString;
88
+ sourceLabel: z.ZodString;
89
+ pageUrl: z.ZodNullable<z.ZodString>;
90
+ latitude: z.ZodNullable<z.ZodNumber>;
91
+ longitude: z.ZodNullable<z.ZodNumber>;
92
+ timeZone: z.ZodNullable<z.ZodString>;
93
+ elevationM: z.ZodNullable<z.ZodNumber>;
94
+ capabilities: z.ZodObject<{
95
+ gustLull: z.ZodBoolean;
96
+ temperature: z.ZodBoolean;
97
+ conditions: z.ZodBoolean;
98
+ history: z.ZodBoolean;
99
+ }, z.core.$strip>;
100
+ samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
101
+ recommendedPollSeconds: z.ZodNumber;
102
+ }, z.core.$strip>;
103
+ type StationMeta = z.infer<typeof stationMetaSchema>;
104
+ declare const stationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
105
+ status: z.ZodLiteral<"ok">;
106
+ reading: z.ZodObject<{
107
+ observedAt: z.ZodString;
108
+ windAvgMps: z.ZodNumber;
109
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
110
+ windGustMps: z.ZodNullable<z.ZodNumber>;
111
+ windLullMps: z.ZodNullable<z.ZodNumber>;
112
+ temperatureC: z.ZodNullable<z.ZodNumber>;
113
+ windChillC: z.ZodNullable<z.ZodNumber>;
114
+ conditions: z.ZodNullable<z.ZodObject<{
115
+ dewPointC: z.ZodNullable<z.ZodNumber>;
116
+ lastLightningStrikeAt: z.ZodNullable<z.ZodString>;
117
+ lastLightningStrikeDistanceKm: z.ZodNullable<z.ZodNumber>;
118
+ lightningStrikeCountLastHour: z.ZodNullable<z.ZodNumber>;
119
+ precipitationMinutesToday: z.ZodNullable<z.ZodNumber>;
120
+ precipitationRateMmPerHour: z.ZodNullable<z.ZodNumber>;
121
+ precipitationTodayMm: z.ZodNullable<z.ZodNumber>;
122
+ pressureTrend: z.ZodNullable<z.ZodEnum<{
123
+ falling: "falling";
124
+ rising: "rising";
125
+ steady: "steady";
126
+ unknown: "unknown";
127
+ }>>;
128
+ relativeHumidityPercent: z.ZodNullable<z.ZodNumber>;
129
+ seaLevelPressureHpa: z.ZodNullable<z.ZodNumber>;
130
+ solarRadiationWm2: z.ZodNullable<z.ZodNumber>;
131
+ uvIndex: z.ZodNullable<z.ZodNumber>;
132
+ }, z.core.$strip>>;
133
+ }, z.core.$strip>;
134
+ history: z.ZodNullable<z.ZodObject<{
135
+ periodMinutes: z.ZodNumber;
136
+ points: z.ZodArray<z.ZodObject<{
137
+ observedAt: z.ZodString;
138
+ windAvgMps: z.ZodNumber;
139
+ windGustMps: z.ZodNullable<z.ZodNumber>;
140
+ windLullMps: z.ZodNullable<z.ZodNumber>;
141
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
142
+ temperatureC: z.ZodNullable<z.ZodNumber>;
143
+ seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
144
+ }, z.core.$strip>>;
145
+ }, z.core.$strip>>;
146
+ id: z.ZodString;
147
+ name: z.ZodString;
148
+ sourceLabel: z.ZodString;
149
+ pageUrl: z.ZodNullable<z.ZodString>;
150
+ latitude: z.ZodNullable<z.ZodNumber>;
151
+ longitude: z.ZodNullable<z.ZodNumber>;
152
+ timeZone: z.ZodNullable<z.ZodString>;
153
+ elevationM: z.ZodNullable<z.ZodNumber>;
154
+ capabilities: z.ZodObject<{
155
+ gustLull: z.ZodBoolean;
156
+ temperature: z.ZodBoolean;
157
+ conditions: z.ZodBoolean;
158
+ history: z.ZodBoolean;
159
+ }, z.core.$strip>;
160
+ samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
161
+ recommendedPollSeconds: z.ZodNumber;
162
+ }, z.core.$strip>, z.ZodObject<{
163
+ status: z.ZodLiteral<"unavailable">;
164
+ reason: z.ZodEnum<{
165
+ upstream_error: "upstream_error";
166
+ timeout: "timeout";
167
+ rate_limited: "rate_limited";
168
+ contract_break: "contract_break";
169
+ not_configured: "not_configured";
170
+ }>;
171
+ reading: z.ZodNull;
172
+ history: z.ZodNull;
173
+ id: z.ZodString;
174
+ name: z.ZodString;
175
+ sourceLabel: z.ZodString;
176
+ pageUrl: z.ZodNullable<z.ZodString>;
177
+ latitude: z.ZodNullable<z.ZodNumber>;
178
+ longitude: z.ZodNullable<z.ZodNumber>;
179
+ timeZone: z.ZodNullable<z.ZodString>;
180
+ elevationM: z.ZodNullable<z.ZodNumber>;
181
+ capabilities: z.ZodObject<{
182
+ gustLull: z.ZodBoolean;
183
+ temperature: z.ZodBoolean;
184
+ conditions: z.ZodBoolean;
185
+ history: z.ZodBoolean;
186
+ }, z.core.$strip>;
187
+ samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
188
+ recommendedPollSeconds: z.ZodNumber;
189
+ }, z.core.$strip>], "status">;
190
+ type Station = z.infer<typeof stationSchema>;
191
+ declare const stationFeedSchema: z.ZodObject<{
192
+ schemaVersion: z.ZodLiteral<2>;
193
+ servedAt: z.ZodString;
194
+ primaryStationId: z.ZodNullable<z.ZodString>;
195
+ stations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
196
+ status: z.ZodLiteral<"ok">;
197
+ reading: z.ZodObject<{
198
+ observedAt: z.ZodString;
199
+ windAvgMps: z.ZodNumber;
200
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
201
+ windGustMps: z.ZodNullable<z.ZodNumber>;
202
+ windLullMps: z.ZodNullable<z.ZodNumber>;
203
+ temperatureC: z.ZodNullable<z.ZodNumber>;
204
+ windChillC: z.ZodNullable<z.ZodNumber>;
205
+ conditions: z.ZodNullable<z.ZodObject<{
206
+ dewPointC: z.ZodNullable<z.ZodNumber>;
207
+ lastLightningStrikeAt: z.ZodNullable<z.ZodString>;
208
+ lastLightningStrikeDistanceKm: z.ZodNullable<z.ZodNumber>;
209
+ lightningStrikeCountLastHour: z.ZodNullable<z.ZodNumber>;
210
+ precipitationMinutesToday: z.ZodNullable<z.ZodNumber>;
211
+ precipitationRateMmPerHour: z.ZodNullable<z.ZodNumber>;
212
+ precipitationTodayMm: z.ZodNullable<z.ZodNumber>;
213
+ pressureTrend: z.ZodNullable<z.ZodEnum<{
214
+ falling: "falling";
215
+ rising: "rising";
216
+ steady: "steady";
217
+ unknown: "unknown";
218
+ }>>;
219
+ relativeHumidityPercent: z.ZodNullable<z.ZodNumber>;
220
+ seaLevelPressureHpa: z.ZodNullable<z.ZodNumber>;
221
+ solarRadiationWm2: z.ZodNullable<z.ZodNumber>;
222
+ uvIndex: z.ZodNullable<z.ZodNumber>;
223
+ }, z.core.$strip>>;
224
+ }, z.core.$strip>;
225
+ history: z.ZodNullable<z.ZodObject<{
226
+ periodMinutes: z.ZodNumber;
227
+ points: z.ZodArray<z.ZodObject<{
228
+ observedAt: z.ZodString;
229
+ windAvgMps: z.ZodNumber;
230
+ windGustMps: z.ZodNullable<z.ZodNumber>;
231
+ windLullMps: z.ZodNullable<z.ZodNumber>;
232
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
233
+ temperatureC: z.ZodNullable<z.ZodNumber>;
234
+ seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
235
+ }, z.core.$strip>>;
236
+ }, z.core.$strip>>;
237
+ id: z.ZodString;
238
+ name: z.ZodString;
239
+ sourceLabel: z.ZodString;
240
+ pageUrl: z.ZodNullable<z.ZodString>;
241
+ latitude: z.ZodNullable<z.ZodNumber>;
242
+ longitude: z.ZodNullable<z.ZodNumber>;
243
+ timeZone: z.ZodNullable<z.ZodString>;
244
+ elevationM: z.ZodNullable<z.ZodNumber>;
245
+ capabilities: z.ZodObject<{
246
+ gustLull: z.ZodBoolean;
247
+ temperature: z.ZodBoolean;
248
+ conditions: z.ZodBoolean;
249
+ history: z.ZodBoolean;
250
+ }, z.core.$strip>;
251
+ samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
252
+ recommendedPollSeconds: z.ZodNumber;
253
+ }, z.core.$strip>, z.ZodObject<{
254
+ status: z.ZodLiteral<"unavailable">;
255
+ reason: z.ZodEnum<{
256
+ upstream_error: "upstream_error";
257
+ timeout: "timeout";
258
+ rate_limited: "rate_limited";
259
+ contract_break: "contract_break";
260
+ not_configured: "not_configured";
261
+ }>;
262
+ reading: z.ZodNull;
263
+ history: z.ZodNull;
264
+ id: z.ZodString;
265
+ name: z.ZodString;
266
+ sourceLabel: z.ZodString;
267
+ pageUrl: z.ZodNullable<z.ZodString>;
268
+ latitude: z.ZodNullable<z.ZodNumber>;
269
+ longitude: z.ZodNullable<z.ZodNumber>;
270
+ timeZone: z.ZodNullable<z.ZodString>;
271
+ elevationM: z.ZodNullable<z.ZodNumber>;
272
+ capabilities: z.ZodObject<{
273
+ gustLull: z.ZodBoolean;
274
+ temperature: z.ZodBoolean;
275
+ conditions: z.ZodBoolean;
276
+ history: z.ZodBoolean;
277
+ }, z.core.$strip>;
278
+ samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
279
+ recommendedPollSeconds: z.ZodNumber;
280
+ }, z.core.$strip>], "status">>;
281
+ }, z.core.$strip>;
282
+ type StationFeed = z.infer<typeof stationFeedSchema>;
283
+ declare const stationCurrentSchema: z.ZodObject<{
284
+ schemaVersion: z.ZodLiteral<2>;
285
+ servedAt: z.ZodString;
286
+ station: z.ZodDiscriminatedUnion<[z.ZodObject<{
287
+ status: z.ZodLiteral<"ok">;
288
+ reading: z.ZodObject<{
289
+ observedAt: z.ZodString;
290
+ windAvgMps: z.ZodNumber;
291
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
292
+ windGustMps: z.ZodNullable<z.ZodNumber>;
293
+ windLullMps: z.ZodNullable<z.ZodNumber>;
294
+ temperatureC: z.ZodNullable<z.ZodNumber>;
295
+ windChillC: z.ZodNullable<z.ZodNumber>;
296
+ conditions: z.ZodNullable<z.ZodObject<{
297
+ dewPointC: z.ZodNullable<z.ZodNumber>;
298
+ lastLightningStrikeAt: z.ZodNullable<z.ZodString>;
299
+ lastLightningStrikeDistanceKm: z.ZodNullable<z.ZodNumber>;
300
+ lightningStrikeCountLastHour: z.ZodNullable<z.ZodNumber>;
301
+ precipitationMinutesToday: z.ZodNullable<z.ZodNumber>;
302
+ precipitationRateMmPerHour: z.ZodNullable<z.ZodNumber>;
303
+ precipitationTodayMm: z.ZodNullable<z.ZodNumber>;
304
+ pressureTrend: z.ZodNullable<z.ZodEnum<{
305
+ falling: "falling";
306
+ rising: "rising";
307
+ steady: "steady";
308
+ unknown: "unknown";
309
+ }>>;
310
+ relativeHumidityPercent: z.ZodNullable<z.ZodNumber>;
311
+ seaLevelPressureHpa: z.ZodNullable<z.ZodNumber>;
312
+ solarRadiationWm2: z.ZodNullable<z.ZodNumber>;
313
+ uvIndex: z.ZodNullable<z.ZodNumber>;
314
+ }, z.core.$strip>>;
315
+ }, z.core.$strip>;
316
+ history: z.ZodNullable<z.ZodObject<{
317
+ periodMinutes: z.ZodNumber;
318
+ points: z.ZodArray<z.ZodObject<{
319
+ observedAt: z.ZodString;
320
+ windAvgMps: z.ZodNumber;
321
+ windGustMps: z.ZodNullable<z.ZodNumber>;
322
+ windLullMps: z.ZodNullable<z.ZodNumber>;
323
+ windDirectionDeg: z.ZodNullable<z.ZodNumber>;
324
+ temperatureC: z.ZodNullable<z.ZodNumber>;
325
+ seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
326
+ }, z.core.$strip>>;
327
+ }, z.core.$strip>>;
328
+ id: z.ZodString;
329
+ name: z.ZodString;
330
+ sourceLabel: z.ZodString;
331
+ pageUrl: z.ZodNullable<z.ZodString>;
332
+ latitude: z.ZodNullable<z.ZodNumber>;
333
+ longitude: z.ZodNullable<z.ZodNumber>;
334
+ timeZone: z.ZodNullable<z.ZodString>;
335
+ elevationM: z.ZodNullable<z.ZodNumber>;
336
+ capabilities: z.ZodObject<{
337
+ gustLull: z.ZodBoolean;
338
+ temperature: z.ZodBoolean;
339
+ conditions: z.ZodBoolean;
340
+ history: z.ZodBoolean;
341
+ }, z.core.$strip>;
342
+ samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
343
+ recommendedPollSeconds: z.ZodNumber;
344
+ }, z.core.$strip>, z.ZodObject<{
345
+ status: z.ZodLiteral<"unavailable">;
346
+ reason: z.ZodEnum<{
347
+ upstream_error: "upstream_error";
348
+ timeout: "timeout";
349
+ rate_limited: "rate_limited";
350
+ contract_break: "contract_break";
351
+ not_configured: "not_configured";
352
+ }>;
353
+ reading: z.ZodNull;
354
+ history: z.ZodNull;
355
+ id: z.ZodString;
356
+ name: z.ZodString;
357
+ sourceLabel: z.ZodString;
358
+ pageUrl: z.ZodNullable<z.ZodString>;
359
+ latitude: z.ZodNullable<z.ZodNumber>;
360
+ longitude: z.ZodNullable<z.ZodNumber>;
361
+ timeZone: z.ZodNullable<z.ZodString>;
362
+ elevationM: z.ZodNullable<z.ZodNumber>;
363
+ capabilities: z.ZodObject<{
364
+ gustLull: z.ZodBoolean;
365
+ temperature: z.ZodBoolean;
366
+ conditions: z.ZodBoolean;
367
+ history: z.ZodBoolean;
368
+ }, z.core.$strip>;
369
+ samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
370
+ recommendedPollSeconds: z.ZodNumber;
371
+ }, z.core.$strip>], "status">;
372
+ }, z.core.$strip>;
373
+ type StationCurrent = z.infer<typeof stationCurrentSchema>;
374
+ declare function parseStationFeed(value: unknown): StationFeed | null;
375
+ declare function parseStationFeedJson(text: string): StationFeed | null;
376
+ declare function parseStationCurrent(value: unknown): StationCurrent | null;
377
+ declare function parseStationCurrentJson(text: string): StationCurrent | null;
378
+ declare function emptyConditions(overrides?: Partial<AirConditions>): AirConditions;
379
+ declare function unavailableStation(meta: StationMeta, reason: UnavailableReason): Station;
380
+ //#endregion
381
+ export { AirConditions, History, HistoryPoint, Reading, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationMeta, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationMetaSchema, stationSchema, unavailableStation };
@@ -0,0 +1,143 @@
1
+ import { z } from "zod";
2
+ import { UPSTREAM_FAILURE_REASONS } from "@azohra/meteo.core";
3
+ //#region src/contract.ts
4
+ const STATION_SCHEMA_VERSION = 2;
5
+ const UNAVAILABLE_REASONS = [...UPSTREAM_FAILURE_REASONS, "not_configured"];
6
+ const isoTime = z.string().refine((value) => Number.isFinite(Date.parse(value)), { message: "not an ISO timestamp" }).meta({ format: "date-time" });
7
+ const speedMps = z.number().finite().min(0);
8
+ const windDirectionDeg = z.number().finite().min(0).lt(360);
9
+ const airConditionsSchema = z.object({
10
+ dewPointC: z.number().finite().nullable(),
11
+ lastLightningStrikeAt: isoTime.nullable(),
12
+ lastLightningStrikeDistanceKm: z.number().finite().nullable(),
13
+ lightningStrikeCountLastHour: z.number().finite().nullable(),
14
+ precipitationMinutesToday: z.number().finite().nullable(),
15
+ precipitationRateMmPerHour: z.number().finite().nullable(),
16
+ precipitationTodayMm: z.number().finite().nullable(),
17
+ pressureTrend: z.enum([
18
+ "falling",
19
+ "rising",
20
+ "steady",
21
+ "unknown"
22
+ ]).nullable(),
23
+ relativeHumidityPercent: z.number().finite().nullable(),
24
+ seaLevelPressureHpa: z.number().finite().nullable(),
25
+ solarRadiationWm2: z.number().finite().nullable(),
26
+ uvIndex: z.number().finite().min(0).nullable()
27
+ }).describe("Extended air data. null means 'not reported here' — it does not distinguish a missing sensor from a dark one; the station-level conditions capability gates whether a client allocates UI structure.").meta({ id: "AirConditions" });
28
+ const readingSchema = z.object({
29
+ observedAt: isoTime,
30
+ windAvgMps: speedMps.describe("Wind speed in m/s, averaged over samplingWindowSeconds. Absence is null, never zero."),
31
+ windDirectionDeg: windDirectionDeg.nullable().describe("Bearing the wind blows FROM, degrees [0, 360). null exactly when calm (windAvgMps below the WMO 0.5 m/s threshold) — calm carries no direction; a null on a blowing reading is a dead vane."),
32
+ windGustMps: speedMps.nullable().describe("Peak m/s within the sampling window; null ≠ zero."),
33
+ windLullMps: speedMps.nullable().describe("Minimum m/s within the sampling window; null ≠ zero."),
34
+ temperatureC: z.number().finite().nullable(),
35
+ windChillC: z.number().finite().nullable(),
36
+ conditions: airConditionsSchema.nullable()
37
+ }).meta({ id: "Reading" });
38
+ const historyPointSchema = z.object({
39
+ observedAt: isoTime,
40
+ windAvgMps: speedMps.describe("Mean m/s over the record's period."),
41
+ windGustMps: speedMps.nullable(),
42
+ windLullMps: speedMps.nullable(),
43
+ windDirectionDeg: windDirectionDeg.nullable().describe("Degrees FROM; null exactly when the period was calm (below 0.5 m/s)."),
44
+ temperatureC: z.number().finite().nullable(),
45
+ seaLevelPressureHpa: z.number().finite().positive().nullish()
46
+ }).meta({ id: "HistoryPoint" });
47
+ const historySchema = z.object({
48
+ periodMinutes: z.number().finite().positive().describe("Minutes each point covers. Wind run, vane thinning, and dropout detection are functions of it."),
49
+ points: z.array(historyPointSchema).describe("A dropout is an ABSENT record, never a zeroed one — gaps carry no points.")
50
+ }).meta({ id: "History" });
51
+ const capabilitiesSchema = z.object({
52
+ gustLull: z.boolean(),
53
+ temperature: z.boolean(),
54
+ conditions: z.boolean(),
55
+ history: z.boolean()
56
+ }).describe("Declared from what the hardware carries, never inferred from data. Capabilities gate client UI structure; a dark sensor keeps its structure and reports null.").meta({ id: "StationCapabilities" });
57
+ const stationMetaShape = {
58
+ id: z.string().min(1),
59
+ name: z.string().min(1),
60
+ sourceLabel: z.string(),
61
+ pageUrl: z.string().nullable(),
62
+ latitude: z.number().finite().min(-90).max(90).nullable(),
63
+ longitude: z.number().finite().min(-180).lt(180).nullable(),
64
+ timeZone: z.string().min(1).nullable(),
65
+ elevationM: z.number().finite().nullable(),
66
+ capabilities: capabilitiesSchema,
67
+ samplingWindowSeconds: z.number().finite().positive().nullable(),
68
+ recommendedPollSeconds: z.number().finite().positive()
69
+ };
70
+ const stationMetaSchema = z.object(stationMetaShape);
71
+ const stationSchema = z.discriminatedUnion("status", [z.object({
72
+ ...stationMetaShape,
73
+ status: z.literal("ok"),
74
+ reading: readingSchema,
75
+ history: historySchema.nullable()
76
+ }), z.object({
77
+ ...stationMetaShape,
78
+ status: z.literal("unavailable"),
79
+ reason: z.enum(UNAVAILABLE_REASONS),
80
+ reading: z.null(),
81
+ history: z.null()
82
+ })]).meta({ id: "Station" });
83
+ const stationFeedSchema = z.object({
84
+ schemaVersion: z.literal(2),
85
+ servedAt: isoTime.describe("The server clock at response time. Freshness is judged client-side against this anchor, so a wrong client clock cannot declare a live station stale."),
86
+ primaryStationId: z.string().nullable(),
87
+ stations: z.array(stationSchema)
88
+ });
89
+ const stationCurrentSchema = z.object({
90
+ schemaVersion: z.literal(2),
91
+ servedAt: isoTime,
92
+ station: stationSchema
93
+ });
94
+ function parseStationFeed(value) {
95
+ const result = stationFeedSchema.safeParse(value);
96
+ return result.success ? result.data : null;
97
+ }
98
+ function parseStationFeedJson(text) {
99
+ try {
100
+ return parseStationFeed(JSON.parse(text));
101
+ } catch {
102
+ return null;
103
+ }
104
+ }
105
+ function parseStationCurrent(value) {
106
+ const result = stationCurrentSchema.safeParse(value);
107
+ return result.success ? result.data : null;
108
+ }
109
+ function parseStationCurrentJson(text) {
110
+ try {
111
+ return parseStationCurrent(JSON.parse(text));
112
+ } catch {
113
+ return null;
114
+ }
115
+ }
116
+ function emptyConditions(overrides = {}) {
117
+ return {
118
+ dewPointC: null,
119
+ lastLightningStrikeAt: null,
120
+ lastLightningStrikeDistanceKm: null,
121
+ lightningStrikeCountLastHour: null,
122
+ precipitationMinutesToday: null,
123
+ precipitationRateMmPerHour: null,
124
+ precipitationTodayMm: null,
125
+ pressureTrend: null,
126
+ relativeHumidityPercent: null,
127
+ seaLevelPressureHpa: null,
128
+ solarRadiationWm2: null,
129
+ uvIndex: null,
130
+ ...overrides
131
+ };
132
+ }
133
+ function unavailableStation(meta, reason) {
134
+ return {
135
+ ...meta,
136
+ status: "unavailable",
137
+ reason,
138
+ reading: null,
139
+ history: null
140
+ };
141
+ }
142
+ //#endregion
143
+ export { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationMetaSchema, stationSchema, unavailableStation };
@@ -0,0 +1,54 @@
1
+ import { History, StationMeta } from "./contract.js";
2
+ import { normalizeDegrees } from "@azohra/meteo.core";
3
+ //#region src/derive.d.ts
4
+ declare const CALM_THRESHOLD_MPS = 0.5;
5
+ declare function isCalm(speedMps: number): boolean;
6
+ declare const SPEED_UNITS: readonly ["kmh", "knots", "mph", "mps"];
7
+ type SpeedUnit = (typeof SPEED_UNITS)[number];
8
+ declare function speedFromMps(mps: number, unit: SpeedUnit): number;
9
+ declare function speedToMps(value: number, unit: SpeedUnit): number;
10
+ type SpeedThresholds = {
11
+ unit: SpeedUnit;
12
+ values: readonly number[];
13
+ };
14
+ declare function thresholdsToMps(thresholds: SpeedThresholds): number[];
15
+ declare function speedUnitLabel(unit: SpeedUnit): string;
16
+ declare const COMPASS_POINTS: readonly ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"];
17
+ type CompassPoint = (typeof COMPASS_POINTS)[number];
18
+ declare function compassDirection(bearingDeg: number): CompassPoint;
19
+ type PeriodSummary = {
20
+ windAvgMps: number;
21
+ peakGustMps: number | null;
22
+ peakGustAt: string | null;
23
+ lowestLullMps: number | null;
24
+ periodEndedAt: string;
25
+ temperatureHighC: number | null;
26
+ temperatureHighAt: string | null;
27
+ temperatureLowC: number | null;
28
+ temperatureLowAt: string | null;
29
+ windRunKm: number;
30
+ };
31
+ declare function periodSummary(history: History): PeriodSummary | null;
32
+ declare function seaLevelPressureHpa(stationPressureHpa: number, elevationM: number, temperatureC?: number | null): number;
33
+ type PressureTendency = "falling" | "rising" | "steady";
34
+ declare function pressureTendency(points: ReadonlyArray<{
35
+ observedAt: string;
36
+ seaLevelPressureHpa?: number | null;
37
+ }>, { windowHours, thresholdHpa }?: {
38
+ windowHours?: number;
39
+ thresholdHpa?: number;
40
+ }): PressureTendency | null;
41
+ type FreshnessStatus = "live" | "aging" | "stale";
42
+ type FreshnessThresholds = {
43
+ currentForMs: number;
44
+ staleAfterMs: number;
45
+ };
46
+ declare function stationFreshnessThresholds(meta: Pick<StationMeta, "recommendedPollSeconds">): FreshnessThresholds;
47
+ declare function freshness(input: {
48
+ observedAt: string;
49
+ servedAt: string;
50
+ receivedAtMs: number;
51
+ nowMs: number;
52
+ }, thresholds?: FreshnessThresholds): FreshnessStatus;
53
+ //#endregion
54
+ export { CALM_THRESHOLD_MPS, COMPASS_POINTS, CompassPoint, FreshnessStatus, FreshnessThresholds, PeriodSummary, PressureTendency, SPEED_UNITS, SpeedThresholds, SpeedUnit, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps };