@azohra/meteo.station 0.6.0 → 0.7.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 (128) hide show
  1. package/README.md +17 -17
  2. package/dist/connectivity.d.ts +2 -2
  3. package/dist/contract.d.ts +105 -105
  4. package/dist/derive.js +4 -4
  5. package/dist/elements/elements/AirExtremesElement.js +5 -18
  6. package/dist/elements/elements/AirMatrixElement.js +6 -31
  7. package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
  8. package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
  9. package/dist/elements/elements/CompassFanElement.js +5 -64
  10. package/dist/elements/elements/CurrentConditionsElement.js +7 -26
  11. package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
  12. package/dist/elements/elements/DailyPatternElement.js +6 -120
  13. package/dist/elements/elements/DialElement.js +3 -95
  14. package/dist/elements/elements/FavorableShareElement.js +6 -21
  15. package/dist/elements/elements/RecentSummariesElement.js +6 -23
  16. package/dist/elements/elements/SparklineElement.d.ts +0 -1
  17. package/dist/elements/elements/SparklineElement.js +4 -39
  18. package/dist/elements/elements/StationCardElement.js +4 -18
  19. package/dist/elements/elements/StationFeedElement.js +4 -2
  20. package/dist/elements/elements/StationStripElement.js +4 -18
  21. package/dist/elements/elements/StationTableElement.js +15 -51
  22. package/dist/elements/elements/TrendChartElement.js +21 -69
  23. package/dist/elements/elements/WindHistoryChartElement.js +23 -164
  24. package/dist/elements/elements/WindRoseElement.d.ts +0 -1
  25. package/dist/elements/elements/WindRoseElement.js +6 -70
  26. package/dist/elements/elements/atoms.d.ts +1 -1
  27. package/dist/elements/elements/atoms.js +11 -38
  28. package/dist/elements/index.js +3 -3
  29. package/dist/elements/lib/fragments.js +8 -37
  30. package/dist/elements/lib/h.js +1 -1
  31. package/dist/elements/lib/render.js +30 -0
  32. package/dist/geometry.js +2 -1
  33. package/dist/instruments.js +2 -2
  34. package/dist/react/components/AirExtremes.d.ts +1 -1
  35. package/dist/react/components/AirExtremes.js +5 -22
  36. package/dist/react/components/AirMatrix.js +10 -43
  37. package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
  38. package/dist/react/components/ClimatologyDailyPattern.js +19 -13
  39. package/dist/react/components/ClimatologyRose.d.ts +1 -1
  40. package/dist/react/components/ClimatologyRose.js +11 -28
  41. package/dist/react/components/CompassFan.d.ts +1 -1
  42. package/dist/react/components/CompassFan.js +6 -73
  43. package/dist/react/components/CurrentConditions.d.ts +1 -1
  44. package/dist/react/components/CurrentConditions.js +11 -74
  45. package/dist/react/components/DailyPattern.d.ts +1 -3
  46. package/dist/react/components/DailyPattern.js +10 -149
  47. package/dist/react/components/Dial.d.ts +1 -1
  48. package/dist/react/components/Dial.js +5 -118
  49. package/dist/react/components/FavorableShare.d.ts +1 -1
  50. package/dist/react/components/FavorableShare.js +6 -27
  51. package/dist/react/components/FreshnessBadge.d.ts +1 -1
  52. package/dist/react/components/FreshnessBadge.js +5 -12
  53. package/dist/react/components/RecentSummaries.d.ts +1 -1
  54. package/dist/react/components/RecentSummaries.js +6 -44
  55. package/dist/react/components/SceneTree.js +38 -0
  56. package/dist/react/components/Sparkline.d.ts +1 -1
  57. package/dist/react/components/Sparkline.js +3 -39
  58. package/dist/react/components/StationCard.d.ts +2 -2
  59. package/dist/react/components/StationCard.js +5 -45
  60. package/dist/react/components/StationStrip.d.ts +1 -1
  61. package/dist/react/components/StationStrip.js +5 -60
  62. package/dist/react/components/StationTable.js +21 -75
  63. package/dist/react/components/TrendChart.js +8 -63
  64. package/dist/react/components/WindArrow.d.ts +1 -1
  65. package/dist/react/components/WindArrow.js +3 -15
  66. package/dist/react/components/WindHistoryChart.js +8 -182
  67. package/dist/react/components/WindRose.d.ts +1 -3
  68. package/dist/react/components/WindRose.js +6 -89
  69. package/dist/react/components/WindSampleStrip.js +8 -115
  70. package/dist/react/components/atoms.d.ts +5 -5
  71. package/dist/react/components/atoms.js +12 -48
  72. package/dist/react/hooks/useStationCurrent.js +3 -2
  73. package/dist/react/hooks/useStationFeed.js +3 -2
  74. package/dist/react/index.d.ts +2 -2
  75. package/dist/react/index.js +5 -5
  76. package/dist/react/lib/cells.js +4 -24
  77. package/dist/scene/air-extremes.js +12 -27
  78. package/dist/scene/air-matrix.js +45 -58
  79. package/dist/scene/card.js +14 -40
  80. package/dist/scene/cells.d.ts +4 -0
  81. package/dist/scene/cells.js +51 -0
  82. package/dist/scene/chart.js +2 -1
  83. package/dist/scene/climatology-pattern.d.ts +1 -2
  84. package/dist/scene/climatology-pattern.js +10 -11
  85. package/dist/scene/climatology-rose.d.ts +1 -2
  86. package/dist/scene/climatology-rose.js +14 -33
  87. package/dist/scene/compass-fan.js +28 -100
  88. package/dist/scene/current.d.ts +2 -1
  89. package/dist/scene/current.js +29 -56
  90. package/dist/scene/daily-pattern.d.ts +1 -3
  91. package/dist/scene/daily-pattern.js +20 -27
  92. package/dist/scene/dial-parts.d.ts +1 -0
  93. package/dist/scene/dial-parts.js +70 -0
  94. package/dist/scene/dial.d.ts +1 -2
  95. package/dist/scene/dial.js +48 -136
  96. package/dist/scene/favorable-share.js +16 -33
  97. package/dist/scene/glyphs.js +20 -16
  98. package/dist/scene/index.d.ts +5 -3
  99. package/dist/scene/node.js +19 -0
  100. package/dist/scene/recent-summaries.js +26 -63
  101. package/dist/scene/rose.js +89 -117
  102. package/dist/scene/sample-strip.d.ts +1 -2
  103. package/dist/scene/sample-strip.js +35 -36
  104. package/dist/scene/sparkline.js +31 -40
  105. package/dist/scene/strip.js +18 -57
  106. package/dist/scene/table.js +47 -69
  107. package/dist/scene/trend.d.ts +1 -2
  108. package/dist/scene/trend.js +29 -55
  109. package/dist/scene/wind-history.d.ts +1 -2
  110. package/dist/scene/wind-history.js +41 -51
  111. package/dist/scene/wind-plot.js +70 -140
  112. package/dist/server/adapters/campbell.d.ts +7 -7
  113. package/dist/server/adapters/campbell.js +1 -1
  114. package/dist/server/adapters/ecowitt.d.ts +8 -8
  115. package/dist/server/adapters/tempest.d.ts +6 -6
  116. package/dist/server/adapters/windnerd-climatology.js +4 -3
  117. package/dist/server/adapters/windnerd-live.js +3 -2
  118. package/dist/server/adapters/windnerd.d.ts +8 -8
  119. package/dist/server/adapters/windnerd.js +1 -1
  120. package/dist/server/config.d.ts +48 -48
  121. package/dist/server/hologram.js +2 -1
  122. package/package.json +6 -11
  123. package/schema/README.md +1 -1
  124. package/schema/stationclimatology.schema.json +64 -61
  125. package/schema/stationcurrent.schema.json +68 -156
  126. package/schema/stationfeed.schema.json +71 -163
  127. package/schema/stationhistory.schema.json +37 -46
  128. package/schema/stationlive.schema.json +221 -306
@@ -1,7 +1,26 @@
1
1
  import { compassDirection, speedToMps } from "../derive.js";
2
2
  import { averagePoints, chartFrame, chartScales, speedBand, stretchFrame, tickAnchor, vanePath, vaneTicks } from "../geometry.js";
3
+ import { el, keyed } from "./node.js";
3
4
  import { inDirectionArcs, solarEventsForDate } from "@azohra/meteo.core";
4
5
  //#region src/scene/wind-plot.ts
6
+ /** A plot label: the anchor is the SVG attribute, spelled as the DOM does. */
7
+ function plotText(attrs, anchor, x, y, text) {
8
+ return el("text", {
9
+ ...attrs,
10
+ "text-anchor": anchor,
11
+ x,
12
+ y
13
+ }, text);
14
+ }
15
+ function plotLine(attrs, x1, x2, y1, y2) {
16
+ return el("line", {
17
+ ...attrs,
18
+ x1,
19
+ x2,
20
+ y1,
21
+ y2
22
+ });
23
+ }
5
24
  function stretchedChartFrame(width, plotHeight) {
6
25
  const core = chartFrame(width);
7
26
  const corePlotHeight = core.plotBottom - core.plotTop;
@@ -20,23 +39,7 @@ function speedGridLines(frame, scales, shown) {
20
39
  1
21
40
  ].map((fraction) => {
22
41
  const gridY = frame.plotBottom - fraction * (frame.plotBottom - frame.plotTop);
23
- return {
24
- key: fraction,
25
- line: {
26
- className: "meteo-grid-line",
27
- x1: frame.left,
28
- x2: frame.right,
29
- y1: gridY,
30
- y2: gridY
31
- },
32
- label: {
33
- className: "meteo-grid-label",
34
- anchor: "end",
35
- x: frame.left - 6,
36
- y: gridY + 5,
37
- text: String(shown(scales.scaleMax * fraction))
38
- }
39
- };
42
+ return keyed(String(fraction), "g", void 0, plotLine({ class: "meteo-grid-line" }, frame.left, frame.right, gridY, gridY), plotText({ class: "meteo-grid-label" }, "end", frame.left - 6, gridY + 5, String(shown(scales.scaleMax * fraction))));
40
43
  });
41
44
  }
42
45
  function windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown) {
@@ -44,23 +47,7 @@ function windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown)
44
47
  return boundsMps.map((boundMps, index) => ({
45
48
  boundMps,
46
49
  label: unit === thresholds.unit ? String(thresholds.values[index]) : String(shown(boundMps))
47
- })).filter(({ boundMps }) => boundMps > 0 && boundMps <= scales.scaleMax).map(({ boundMps, label }) => ({
48
- key: boundMps,
49
- line: {
50
- className: `meteo-wind-threshold meteo-band-${speedBand(boundMps, boundsMps)}`,
51
- x1: frame.left,
52
- x2: frame.right,
53
- y1: scales.yAt(boundMps),
54
- y2: scales.yAt(boundMps)
55
- },
56
- label: {
57
- className: `meteo-wind-threshold-label meteo-band-${speedBand(boundMps, boundsMps)}`,
58
- anchor: "end",
59
- x: frame.right - 3,
60
- y: scales.yAt(boundMps) - 3,
61
- text: label
62
- }
63
- }));
50
+ })).filter(({ boundMps }) => boundMps > 0 && boundMps <= scales.scaleMax).map(({ boundMps, label }) => keyed(String(boundMps), "g", void 0, plotLine({ class: `meteo-wind-threshold meteo-band-${speedBand(boundMps, boundsMps)}` }, frame.left, frame.right, scales.yAt(boundMps), scales.yAt(boundMps)), plotText({ class: `meteo-wind-threshold-label meteo-band-${speedBand(boundMps, boundsMps)}` }, "end", frame.right - 3, scales.yAt(boundMps) - 3, label)));
64
51
  }
65
52
  function windZoneRects(boundsMps, frame, scales) {
66
53
  if (boundsMps == null) return [];
@@ -71,100 +58,70 @@ function windZoneRects(boundsMps, frame, scales) {
71
58
  ];
72
59
  return cuts.slice(0, -1).map((lower, index) => {
73
60
  const upper = cuts[index + 1];
74
- return {
75
- key: lower,
76
- className: `meteo-wind-zone meteo-band-${speedBand((lower + upper) / 2, boundsMps)}`,
61
+ return keyed(String(lower), "rect", {
62
+ class: `meteo-wind-zone meteo-band-${speedBand((lower + upper) / 2, boundsMps)}`,
77
63
  height: scales.yAt(lower) - scales.yAt(upper),
78
64
  width: frame.right - frame.left,
79
65
  x: frame.left,
80
66
  y: scales.yAt(upper)
81
- };
67
+ });
82
68
  });
83
69
  }
84
70
  function vaneGuideLines(vanes, frame, scales) {
85
71
  return vanes.map((vane) => ({
86
- key: vane.midMs,
87
- className: "meteo-wind-guide",
88
- x1: scales.xAtMs(vane.midMs),
89
- x2: scales.xAtMs(vane.midMs),
90
- y1: frame.plotTop,
91
- y2: frame.vaneRow - 9
72
+ ...plotLine({ class: "meteo-wind-guide" }, scales.xAtMs(vane.midMs), scales.xAtMs(vane.midMs), frame.plotTop, frame.vaneRow - 9),
73
+ key: String(vane.midMs)
92
74
  }));
93
75
  }
94
76
  function gapHatchPattern(hatchId) {
95
- return {
96
- id: hatchId,
97
- width: "6",
77
+ return el("pattern", {
98
78
  height: "6",
99
- transform: "rotate(45)",
100
- units: "userSpaceOnUse",
101
- line: {
102
- className: "meteo-wind-gap-hatch",
103
- x1: "0",
104
- x2: "0",
105
- y1: "0",
106
- y2: "6"
107
- }
108
- };
79
+ id: hatchId,
80
+ patternTransform: "rotate(45)",
81
+ patternUnits: "userSpaceOnUse",
82
+ width: "6"
83
+ }, el("line", {
84
+ class: "meteo-wind-gap-hatch",
85
+ x1: "0",
86
+ x2: "0",
87
+ y1: "0",
88
+ y2: "6"
89
+ }));
109
90
  }
110
91
  function gapHatchRect(hatchId, frame, key, x, width) {
111
- return {
112
- key,
113
- className: "meteo-wind-gap",
92
+ return keyed(String(key), "rect", {
93
+ class: "meteo-wind-gap",
114
94
  fill: `url(#${hatchId})`,
115
95
  height: frame.plotBottom - frame.plotTop,
116
96
  width,
117
97
  x,
118
98
  y: frame.plotTop
119
- };
99
+ });
120
100
  }
121
101
  function gradedMeanTrace(points, scales, boundsMps) {
122
- if (boundsMps == null) return {
123
- kind: "polyline",
124
- className: "meteo-wind-mean",
102
+ if (boundsMps == null) return [el("polyline", {
103
+ class: "meteo-wind-mean",
125
104
  points: averagePoints(points, scales)
126
- };
127
- return {
128
- kind: "segments",
129
- segments: points.slice(1).map((point, index) => {
130
- const previous = points[index];
131
- return {
132
- key: point.observedAt,
133
- className: `meteo-wind-mean-segment meteo-band-${speedBand((previous.windAvgMps + point.windAvgMps) / 2, boundsMps)}`,
134
- x1: scales.xAt(previous.observedAt),
135
- x2: scales.xAt(point.observedAt),
136
- y1: scales.yAt(previous.windAvgMps),
137
- y2: scales.yAt(point.windAvgMps)
138
- };
139
- })
140
- };
105
+ })];
106
+ return points.slice(1).map((point, index) => {
107
+ const previous = points[index];
108
+ return {
109
+ ...plotLine({ class: `meteo-wind-mean-segment meteo-band-${speedBand((previous.windAvgMps + point.windAvgMps) / 2, boundsMps)}` }, scales.xAt(previous.observedAt), scales.xAt(point.observedAt), scales.yAt(previous.windAvgMps), scales.yAt(point.windAvgMps)),
110
+ key: point.observedAt
111
+ };
112
+ });
141
113
  }
142
114
  function calmNoteText(frame, words) {
143
- return {
144
- className: "meteo-wind-calm-note",
145
- anchor: "middle",
146
- x: (frame.left + frame.right) / 2,
147
- y: (frame.plotTop + frame.plotBottom) / 2 + 4,
148
- text: words.calmHistory
149
- };
115
+ return plotText({ class: "meteo-wind-calm-note" }, "middle", (frame.left + frame.right) / 2, (frame.plotTop + frame.plotBottom) / 2 + 4, words.calmHistory);
150
116
  }
151
117
  function windRowLabels(frame, words) {
152
- return {
153
- to: {
154
- className: "meteo-wind-row-label",
155
- anchor: "end",
156
- x: frame.left - 8,
157
- y: frame.vaneRow + 4,
158
- text: words.toLabel
159
- },
160
- avg: {
161
- className: "meteo-wind-row-label",
162
- anchor: "end",
163
- x: frame.left - 8,
164
- y: frame.valueRow + 4,
165
- text: words.avgLabel
166
- }
167
- };
118
+ return [{
119
+ ...plotText({ class: "meteo-wind-row-label" }, "end", frame.left - 8, frame.vaneRow + 4, words.toLabel),
120
+ key: "to"
121
+ }, {
122
+ ...plotText({ class: "meteo-wind-row-label" }, "end", frame.left - 8, frame.valueRow + 4, words.avgLabel),
123
+ key: "avg"
124
+ }];
168
125
  }
169
126
  function nightRects(points, frame, scales, night) {
170
127
  if (night?.latitude == null || night?.longitude == null || points.length < 2) return [];
@@ -180,14 +137,13 @@ function nightRects(points, frame, scales, night) {
180
137
  const darkTo = Math.min(tomorrow.sunrise.getTime(), endMs);
181
138
  if (darkFrom >= darkTo) continue;
182
139
  const x = scales.xAtMs(darkFrom);
183
- rects.push({
184
- key: dayStart,
185
- className: "meteo-night",
140
+ rects.push(keyed(String(dayStart), "rect", {
141
+ class: "meteo-night",
186
142
  height: frame.plotBottom - frame.plotTop,
187
143
  width: scales.xAtMs(darkTo) - x,
188
144
  x,
189
145
  y: frame.plotTop
190
- });
146
+ }));
191
147
  }
192
148
  return rects;
193
149
  }
@@ -203,46 +159,20 @@ function vaneCells(vanes, frame, scales, valueText, favorableDirections) {
203
159
  const speaks = (index, every) => (vanes.length - 1 - index) % every === 0;
204
160
  return vanes.map((vane, index) => ({
205
161
  key: vane.midMs,
206
- mark: vane.windDirectionDeg == null ? {
207
- kind: "calm",
208
- text: {
209
- className: "meteo-wind-vane-calm",
210
- anchor: "middle",
211
- x: scales.xAtMs(vane.midMs),
212
- y: frame.vaneRow + 4,
213
- text: "—"
214
- }
215
- } : {
216
- kind: "vane",
217
- className: `meteo-wind-vane${verdict(vane.windDirectionDeg)}`,
162
+ mark: vane.windDirectionDeg == null ? plotText({ class: "meteo-wind-vane-calm" }, "middle", scales.xAtMs(vane.midMs), frame.vaneRow + 4, "—") : el("path", {
163
+ class: `meteo-wind-vane${verdict(vane.windDirectionDeg)}`,
218
164
  d: vanePath(scales.xAtMs(vane.midMs), frame.vaneRow, vane.windDirectionDeg)
219
- },
220
- label: speaks(index, labelStep) ? {
221
- className: "meteo-wind-vane-label",
222
- anchor: "middle",
223
- x: scales.xAtMs(vane.midMs),
224
- y: frame.vaneLabelRow + 4,
225
- text: vane.windDirectionDeg == null ? "—" : compassDirection(vane.windDirectionDeg)
226
- } : null,
227
- value: speaks(index, valueStep) ? {
228
- className: "meteo-wind-vane-value",
229
- anchor: "middle",
230
- x: scales.xAtMs(vane.midMs),
231
- y: frame.valueRow + 4,
232
- text: valueText(vane)
233
- } : null
165
+ }),
166
+ label: speaks(index, labelStep) ? plotText({ class: "meteo-wind-vane-label" }, "middle", scales.xAtMs(vane.midMs), frame.vaneLabelRow + 4, vane.windDirectionDeg == null ? "—" : compassDirection(vane.windDirectionDeg)) : null,
167
+ value: speaks(index, valueStep) ? plotText({ class: "meteo-wind-vane-value" }, "middle", scales.xAtMs(vane.midMs), frame.valueRow + 4, valueText(vane)) : null
234
168
  }));
235
169
  }
236
170
  function vaneTickTexts(vanes, frame, scales, labelText) {
237
171
  const ticks = vaneTicks(vanes, scales, Math.floor((frame.right - frame.left) / TIME_LABEL_PX));
238
172
  return ticks.map(({ index, timeMs, x }) => ({
239
- key: index,
240
- className: "meteo-tick",
241
- anchor: tickAnchor(index, ticks.length - 1),
242
- x,
243
- y: frame.labelRow,
244
- text: labelText(timeMs)
173
+ ...plotText({ class: "meteo-tick" }, tickAnchor(index, ticks.length - 1), x, frame.labelRow, labelText(timeMs)),
174
+ key: String(index)
245
175
  }));
246
176
  }
247
177
  //#endregion
248
- export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
178
+ export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, plotLine, plotText, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
@@ -80,6 +80,13 @@ type CampbellTableExpectation = {
80
80
  subject: string;
81
81
  };
82
82
  declare const loadCampbellStation: StationAdapter<{
83
+ elevationM?: number | null | undefined;
84
+ latitude?: number | null | undefined;
85
+ longitude?: number | null | undefined;
86
+ id: string;
87
+ name: string;
88
+ pageUrl?: string | null | undefined;
89
+ vendor: "campbell";
83
90
  baseUrl: string;
84
91
  source: string;
85
92
  timeZone: string;
@@ -88,13 +95,6 @@ declare const loadCampbellStation: StationAdapter<{
88
95
  currentIntervalSeconds: number;
89
96
  historyPeriodMinutes: number;
90
97
  currentCacheTtlSeconds: number;
91
- id: string;
92
- name: string;
93
- vendor: "campbell";
94
- pageUrl?: string | null | undefined;
95
- elevationM?: number | null | undefined;
96
- latitude?: number | null | undefined;
97
- longitude?: number | null | undefined;
98
98
  }, StationAdapterOptions>;
99
99
  declare function loadCampbellCurrent(config: CampbellStationConfig, options?: CampbellAdapterOptions): Promise<Station>;
100
100
  declare function parseCampbellCurrent(value: string, config: CampbellStationConfig, nowMs?: number): Reading;
@@ -191,7 +191,7 @@ function finiteOrNull(value) {
191
191
  return typeof value === "number" && Number.isFinite(value) ? value : null;
192
192
  }
193
193
  const HOUR_MS = 36e5;
194
- const HOUR_SKEW_TOLERANCE_MS = 5 * 6e4;
194
+ const HOUR_SKEW_TOLERANCE_MS = 3e5;
195
195
  function warnOnHourSkew(environment, config, observedAtIso, nowMs) {
196
196
  const skewMs = Math.abs(Date.parse(observedAtIso) - nowMs);
197
197
  if (Math.abs(skewMs - HOUR_MS) > HOUR_SKEW_TOLERANCE_MS) return;
@@ -10,18 +10,18 @@ type EcowittObservation = {
10
10
  telemetry: StationTelemetry | null;
11
11
  };
12
12
  declare const loadEcowittStation: StationAdapter<{
13
- applicationKey: string;
14
- apiKey: string;
15
- mac: string;
16
- hasBattery: boolean;
13
+ elevationM?: number | null | undefined;
14
+ latitude?: number | null | undefined;
15
+ longitude?: number | null | undefined;
17
16
  id: string;
18
17
  name: string;
19
- vendor: "ecowitt";
20
18
  timeZone?: string | null | undefined;
21
19
  pageUrl?: string | null | undefined;
22
- elevationM?: number | null | undefined;
23
- latitude?: number | null | undefined;
24
- longitude?: number | null | undefined;
20
+ vendor: "ecowitt";
21
+ applicationKey: string;
22
+ apiKey: string;
23
+ mac: string;
24
+ hasBattery: boolean;
25
25
  }, EcowittAdapterOptions>;
26
26
  declare function parseEcowittRealTime(value: string, config: Pick<EcowittStationConfig, "mac" | "elevationM">): EcowittObservation;
27
27
  //#endregion
@@ -11,16 +11,16 @@ type TempestObservation = {
11
11
  longitude: number | null;
12
12
  };
13
13
  declare const loadTempestStation: StationAdapter<{
14
- stationId: number;
15
- token: string;
14
+ elevationM?: number | null | undefined;
15
+ latitude?: number | null | undefined;
16
+ longitude?: number | null | undefined;
16
17
  id: string;
17
18
  name: string;
18
- vendor: "tempest";
19
19
  timeZone?: string | null | undefined;
20
20
  pageUrl?: string | null | undefined;
21
- elevationM?: number | null | undefined;
22
- latitude?: number | null | undefined;
23
- longitude?: number | null | undefined;
21
+ vendor: "tempest";
22
+ stationId: number;
23
+ token: string;
24
24
  }, TempestAdapterOptions>;
25
25
  declare function parseTempestWind(value: string, expectedStationId: number): TempestObservation;
26
26
  //#endregion
@@ -40,17 +40,18 @@ async function loadWindnerdClimatology(config, options) {
40
40
  url.searchParams.set("from", new Date(from).toISOString());
41
41
  url.searchParams.set("to", new Date(Date.UTC(year + 1, 0, 1)).toISOString());
42
42
  url.searchParams.set("period", String(180));
43
- const points = windnerdHistoryPoints(parseWindnerdRecords(await fetchUpstreamText(environment, {
43
+ const records = parseWindnerdRecords(await fetchUpstreamText(environment, {
44
44
  url,
45
45
  cacheKey: `windnerd/climo/${config.locationId}/${year}/180`,
46
46
  cacheTtlSeconds: year < currentYear ? CLOSED_YEAR_CACHE_TTL_SECONDS : CURRENT_YEAR_CACHE_TTL_SECONDS,
47
47
  subject: `WindNerd location ${config.locationId} climatology ${year}`
48
- }), config.locationId, config.hasPressure), config);
48
+ }), config.locationId, config.hasPressure);
49
+ const points = windnerdHistoryPoints(records, config);
49
50
  foldClimatologyPoints(accumulator, points);
50
51
  years.push({
51
52
  year,
52
53
  sampleCount: points.length,
53
- expectedCount: Math.floor((to - from) / (180 * 6e4)),
54
+ expectedCount: Math.floor((to - from) / 108e5),
54
55
  coveredSlotCount: 0,
55
56
  expectedSlotCount: Math.floor((to - from) / (slotMinutes * 6e4))
56
57
  });
@@ -20,11 +20,12 @@ async function openWindnerdLive(config, options = {}) {
20
20
  let events;
21
21
  let initFrame;
22
22
  try {
23
- events = sseEvents((await fetchUpstreamStream(environment, {
23
+ const response = await fetchUpstreamStream(environment, {
24
24
  url: windnerdLiveStreamUrl(config, options.liveUrl),
25
25
  subject,
26
26
  signal: upstream.signal
27
- })).body, { signal: upstream.signal });
27
+ });
28
+ events = sseEvents(response.body, { signal: upstream.signal });
28
29
  initFrame = await readInitFrame(events, config, environment, upstream, options, subject);
29
30
  } catch (error) {
30
31
  upstream.abort();
@@ -27,19 +27,19 @@ type WindnerdRecords = {
27
27
  stationPressureMaxHpa: Array<number | null>;
28
28
  };
29
29
  declare const loadWindnerdStation: StationAdapter<{
30
+ elevationM?: number | null | undefined;
31
+ latitude?: number | null | undefined;
32
+ longitude?: number | null | undefined;
33
+ id: string;
34
+ name: string;
35
+ timeZone?: string | null | undefined;
36
+ pageUrl?: string | null | undefined;
37
+ vendor: "windnerd";
30
38
  stationKey: string;
31
39
  locationId: number;
32
40
  hasTemperature: boolean;
33
41
  hasPressure: boolean;
34
42
  hasBattery: boolean;
35
- id: string;
36
- name: string;
37
- vendor: "windnerd";
38
- timeZone?: string | null | undefined;
39
- pageUrl?: string | null | undefined;
40
- elevationM?: number | null | undefined;
41
- latitude?: number | null | undefined;
42
- longitude?: number | null | undefined;
43
43
  }, WindnerdAdapterOptions>;
44
44
  declare function windnerdHistoryPoints(records: WindnerdRecords, config: Pick<WindnerdStationConfig, "hasTemperature" | "hasPressure" | "elevationM">): HistoryPoint[];
45
45
  type WindnerdHistoryQuery = {
@@ -16,7 +16,7 @@ const LOCATION_CACHE_TTL_SECONDS = 21600;
16
16
  const LOCATION_MISS_CACHE_TTL_SECONDS = 900;
17
17
  const WINDNERD_LIVE_INIT_TIMEOUT_MS = 8e3;
18
18
  const WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS = 3;
19
- const SENSOR_VALUE_LOOKBACK_MS = 15 * 6e4;
19
+ const SENSOR_VALUE_LOOKBACK_MS = 9e5;
20
20
  const MAX_WIND_MPS = 140;
21
21
  const STATION_PRESSURE_MIN_HPA = 300;
22
22
  const STATION_PRESSURE_MAX_HPA = 1100;
@@ -4,50 +4,57 @@ import { ResolvedEnvironment } from "./environment.js";
4
4
  import { z } from "zod";
5
5
  //#region src/server/config.d.ts
6
6
  declare const windnerdStationConfigSchema: z.ZodObject<{
7
- stationKey: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
8
- locationId: z.ZodNumber;
9
- hasTemperature: z.ZodDefault<z.ZodBoolean>;
10
- hasPressure: z.ZodDefault<z.ZodBoolean>;
11
- hasBattery: z.ZodDefault<z.ZodBoolean>;
12
- timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
7
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
15
8
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
9
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
17
10
  id: z.ZodString;
18
11
  name: z.ZodString;
12
+ timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
14
  vendor: z.ZodLiteral<"windnerd">;
15
+ stationKey: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
16
+ locationId: z.ZodNumber;
17
+ hasTemperature: z.ZodDefault<z.ZodBoolean>;
18
+ hasPressure: z.ZodDefault<z.ZodBoolean>;
19
+ hasBattery: z.ZodDefault<z.ZodBoolean>;
20
20
  }, z.core.$strict>;
21
21
  type WindnerdStationConfig = z.output<typeof windnerdStationConfigSchema>;
22
22
  declare const tempestStationConfigSchema: z.ZodObject<{
23
- stationId: z.ZodNumber;
24
- token: z.ZodString;
25
- timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
23
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
28
24
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
29
25
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
30
26
  id: z.ZodString;
31
27
  name: z.ZodString;
28
+ timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
30
  vendor: z.ZodLiteral<"tempest">;
31
+ stationId: z.ZodNumber;
32
+ token: z.ZodString;
33
33
  }, z.core.$strict>;
34
34
  type TempestStationConfig = z.output<typeof tempestStationConfigSchema>;
35
35
  declare const ecowittStationConfigSchema: z.ZodObject<{
36
- applicationKey: z.ZodString;
37
- apiKey: z.ZodString;
38
- mac: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
39
- hasBattery: z.ZodDefault<z.ZodBoolean>;
40
- timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
36
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
43
37
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
44
38
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
45
39
  id: z.ZodString;
46
40
  name: z.ZodString;
41
+ timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
43
  vendor: z.ZodLiteral<"ecowitt">;
44
+ applicationKey: z.ZodString;
45
+ apiKey: z.ZodString;
46
+ mac: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
47
+ hasBattery: z.ZodDefault<z.ZodBoolean>;
48
48
  }, z.core.$strict>;
49
49
  type EcowittStationConfig = z.output<typeof ecowittStationConfigSchema>;
50
50
  declare const campbellStationConfigSchema: z.ZodObject<{
51
+ elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
52
+ latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
53
+ longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
54
+ id: z.ZodString;
55
+ name: z.ZodString;
56
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
+ vendor: z.ZodLiteral<"campbell">;
51
58
  baseUrl: z.ZodString;
52
59
  source: z.ZodString;
53
60
  timeZone: z.ZodString;
@@ -56,13 +63,6 @@ declare const campbellStationConfigSchema: z.ZodObject<{
56
63
  currentIntervalSeconds: z.ZodDefault<z.ZodNumber>;
57
64
  historyPeriodMinutes: z.ZodDefault<z.ZodNumber>;
58
65
  currentCacheTtlSeconds: z.ZodDefault<z.ZodNumber>;
59
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
- elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
61
- latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
62
- longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
63
- id: z.ZodString;
64
- name: z.ZodString;
65
- vendor: z.ZodLiteral<"campbell">;
66
66
  }, z.core.$strict>;
67
67
  type CampbellStationConfig = z.output<typeof campbellStationConfigSchema>;
68
68
  type CustomStationIdentity = {
@@ -82,43 +82,50 @@ type CustomStationContext = {
82
82
  };
83
83
  type CustomStationLoader = (context: CustomStationContext) => Promise<Station>;
84
84
  declare const customStationConfigSchema: z.ZodObject<{
85
- load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
86
- timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
87
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
88
85
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
89
86
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
90
87
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
91
88
  id: z.ZodString;
92
89
  name: z.ZodString;
90
+ timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
92
  vendor: z.ZodLiteral<"custom">;
93
+ load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
94
94
  }, z.core.$strict>;
95
95
  type CustomStationConfig = z.output<typeof customStationConfigSchema>;
96
96
  declare const stationConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
97
+ elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
98
+ latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
99
+ longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
100
+ id: z.ZodString;
101
+ name: z.ZodString;
102
+ timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
103
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
104
+ vendor: z.ZodLiteral<"windnerd">;
97
105
  stationKey: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
98
106
  locationId: z.ZodNumber;
99
107
  hasTemperature: z.ZodDefault<z.ZodBoolean>;
100
108
  hasPressure: z.ZodDefault<z.ZodBoolean>;
101
109
  hasBattery: z.ZodDefault<z.ZodBoolean>;
102
- timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
103
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
110
+ }, z.core.$strict>, z.ZodObject<{
104
111
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
105
112
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
106
113
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
107
114
  id: z.ZodString;
108
115
  name: z.ZodString;
109
- vendor: z.ZodLiteral<"windnerd">;
110
- }, z.core.$strict>, z.ZodObject<{
111
- stationId: z.ZodNumber;
112
- token: z.ZodString;
113
116
  timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
117
  pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
+ vendor: z.ZodLiteral<"tempest">;
119
+ stationId: z.ZodNumber;
120
+ token: z.ZodString;
121
+ }, z.core.$strict>, z.ZodObject<{
115
122
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
116
123
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
117
124
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
118
125
  id: z.ZodString;
119
126
  name: z.ZodString;
120
- vendor: z.ZodLiteral<"tempest">;
121
- }, z.core.$strict>, z.ZodObject<{
127
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
128
+ vendor: z.ZodLiteral<"campbell">;
122
129
  baseUrl: z.ZodString;
123
130
  source: z.ZodString;
124
131
  timeZone: z.ZodString;
@@ -127,36 +134,29 @@ declare const stationConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
127
134
  currentIntervalSeconds: z.ZodDefault<z.ZodNumber>;
128
135
  historyPeriodMinutes: z.ZodDefault<z.ZodNumber>;
129
136
  currentCacheTtlSeconds: z.ZodDefault<z.ZodNumber>;
130
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
137
+ }, z.core.$strict>, z.ZodObject<{
131
138
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
132
139
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
133
140
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
134
141
  id: z.ZodString;
135
142
  name: z.ZodString;
136
- vendor: z.ZodLiteral<"campbell">;
137
- }, z.core.$strict>, z.ZodObject<{
143
+ timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
144
+ pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
145
+ vendor: z.ZodLiteral<"ecowitt">;
138
146
  applicationKey: z.ZodString;
139
147
  apiKey: z.ZodString;
140
148
  mac: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
141
149
  hasBattery: z.ZodDefault<z.ZodBoolean>;
142
- timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
143
- pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
150
+ }, z.core.$strict>, z.ZodObject<{
144
151
  elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
145
152
  latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
146
153
  longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
147
154
  id: z.ZodString;
148
155
  name: z.ZodString;
149
- vendor: z.ZodLiteral<"ecowitt">;
150
- }, z.core.$strict>, z.ZodObject<{
151
- load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
152
156
  timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
153
157
  pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
- elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
155
- latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
156
- longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
157
- id: z.ZodString;
158
- name: z.ZodString;
159
158
  vendor: z.ZodLiteral<"custom">;
159
+ load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
160
160
  }, z.core.$strict>], "vendor">;
161
161
  type StationConfig = z.output<typeof stationConfigSchema>;
162
162
  type StationConfigInput = z.input<typeof stationConfigSchema>;
@@ -101,8 +101,9 @@ function parseHologramConnectivity(value, expectedDeviceId, checkedAt) {
101
101
  }
102
102
  async function loadHologramConnectivity(config, options = {}) {
103
103
  const environment = resolveEnvironment(options.environment);
104
+ const base = options.apiBase ?? "https://dashboard.hologram.io/api/1";
104
105
  return parseHologramConnectivity(await fetchUpstreamText(environment, {
105
- url: `${options.apiBase ?? "https://dashboard.hologram.io/api/1"}/devices/${config.deviceId}`,
106
+ url: `${base}/devices/${config.deviceId}`,
106
107
  cacheKey: `hologram/device/${config.deviceId}`,
107
108
  cacheTtlSeconds: options.cacheTtlSeconds ?? 300,
108
109
  subject: `Hologram device ${config.deviceId}`,