@azohra/meteo.station 0.7.0 → 0.7.2
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/air.d.ts +4 -7
- package/dist/air.js +1 -2
- package/dist/client/climatology.d.ts +5 -8
- package/dist/client/climatology.js +1 -2
- package/dist/client/history.d.ts +14 -17
- package/dist/client/history.js +2 -3
- package/dist/client/index.js +1 -1
- package/dist/client/live.d.ts +10 -12
- package/dist/client/live.js +1 -2
- package/dist/client/poll.d.ts +9 -12
- package/dist/client/poll.js +1 -2
- package/dist/client/stores.d.ts +9 -11
- package/dist/client/stores.js +2 -3
- package/dist/client/ticker.d.ts +1 -4
- package/dist/client/ticker.js +1 -2
- package/dist/climatology.d.ts +13 -15
- package/dist/climatology.js +1 -2
- package/dist/connectivity.d.ts +7 -10
- package/dist/connectivity.js +1 -2
- package/dist/contract-climatology.d.ts +11 -14
- package/dist/contract-climatology.js +1 -2
- package/dist/contract.d.ts +45 -48
- package/dist/contract.js +1 -2
- package/dist/derive.d.ts +24 -26
- package/dist/derive.js +1 -2
- package/dist/display.d.ts +7 -10
- package/dist/display.js +1 -2
- package/dist/elements/elements/AirExtremesElement.d.ts +2 -5
- package/dist/elements/elements/AirExtremesElement.js +1 -2
- package/dist/elements/elements/AirMatrixElement.d.ts +2 -5
- package/dist/elements/elements/AirMatrixElement.js +1 -2
- package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +2 -5
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +2 -3
- package/dist/elements/elements/ClimatologyRoseElement.d.ts +2 -5
- package/dist/elements/elements/ClimatologyRoseElement.js +2 -3
- package/dist/elements/elements/CompassFanElement.d.ts +2 -5
- package/dist/elements/elements/CompassFanElement.js +1 -2
- package/dist/elements/elements/CurrentConditionsElement.d.ts +2 -5
- package/dist/elements/elements/CurrentConditionsElement.js +1 -2
- package/dist/elements/elements/DailyPatternElement.d.ts +2 -5
- package/dist/elements/elements/DailyPatternElement.js +2 -3
- package/dist/elements/elements/DialElement.d.ts +2 -5
- package/dist/elements/elements/DialElement.js +1 -2
- package/dist/elements/elements/FavorableShareElement.d.ts +2 -5
- package/dist/elements/elements/FavorableShareElement.js +1 -2
- package/dist/elements/elements/FreshnessBadgeElement.d.ts +2 -5
- package/dist/elements/elements/FreshnessBadgeElement.js +1 -2
- package/dist/elements/elements/RecentSummariesElement.d.ts +2 -5
- package/dist/elements/elements/RecentSummariesElement.js +1 -2
- package/dist/elements/elements/SparklineElement.d.ts +2 -5
- package/dist/elements/elements/SparklineElement.js +1 -2
- package/dist/elements/elements/StationCardElement.d.ts +6 -8
- package/dist/elements/elements/StationCardElement.js +4 -5
- package/dist/elements/elements/StationFeedElement.d.ts +2 -5
- package/dist/elements/elements/StationFeedElement.js +3 -4
- package/dist/elements/elements/StationStripElement.d.ts +2 -5
- package/dist/elements/elements/StationStripElement.js +1 -2
- package/dist/elements/elements/StationTableElement.d.ts +3 -6
- package/dist/elements/elements/StationTableElement.js +2 -3
- package/dist/elements/elements/TrendChartElement.d.ts +2 -5
- package/dist/elements/elements/TrendChartElement.js +2 -3
- package/dist/elements/elements/WindArrowElement.d.ts +2 -5
- package/dist/elements/elements/WindArrowElement.js +1 -2
- package/dist/elements/elements/WindHistoryChartElement.d.ts +2 -5
- package/dist/elements/elements/WindHistoryChartElement.js +4 -5
- package/dist/elements/elements/WindRoseElement.d.ts +2 -5
- package/dist/elements/elements/WindRoseElement.js +1 -2
- package/dist/elements/elements/atoms.d.ts +9 -11
- package/dist/elements/elements/atoms.js +2 -3
- package/dist/elements/index.d.ts +4 -6
- package/dist/elements/index.js +1 -2
- package/dist/elements/lib/ambient.d.ts +2 -5
- package/dist/elements/lib/ambient.js +1 -2
- package/dist/elements/lib/attributes.js +1 -2
- package/dist/elements/lib/base.d.ts +3 -6
- package/dist/elements/lib/base.js +2 -3
- package/dist/elements/lib/context.js +1 -2
- package/dist/elements/lib/fragments.js +2 -3
- package/dist/elements/lib/h.js +1 -2
- package/dist/elements/lib/pinned-cursor.js +1 -2
- package/dist/elements/lib/render.js +1 -2
- package/dist/elements/register.js +1 -2
- package/dist/endpoints.d.ts +6 -9
- package/dist/endpoints.js +6 -3
- package/dist/fixtures.d.ts +7 -10
- package/dist/fixtures.js +1 -2
- package/dist/format.d.ts +11 -14
- package/dist/format.js +1 -2
- package/dist/geometry.d.ts +36 -39
- package/dist/geometry.js +7 -8
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/instruments.d.ts +37 -40
- package/dist/instruments.js +1 -2
- package/dist/merge-current.d.ts +4 -7
- package/dist/merge-current.js +1 -2
- package/dist/react/components/AirExtremes.d.ts +2 -5
- package/dist/react/components/AirExtremes.js +1 -2
- package/dist/react/components/AirMatrix.d.ts +2 -5
- package/dist/react/components/AirMatrix.js +1 -2
- package/dist/react/components/ClimatologyDailyPattern.d.ts +2 -5
- package/dist/react/components/ClimatologyDailyPattern.js +1 -2
- package/dist/react/components/ClimatologyRose.d.ts +2 -5
- package/dist/react/components/ClimatologyRose.js +1 -2
- package/dist/react/components/CompassFan.d.ts +2 -5
- package/dist/react/components/CompassFan.js +1 -2
- package/dist/react/components/CurrentConditions.d.ts +2 -5
- package/dist/react/components/CurrentConditions.js +3 -4
- package/dist/react/components/DailyPattern.d.ts +2 -5
- package/dist/react/components/DailyPattern.js +2 -3
- package/dist/react/components/Dial.d.ts +2 -5
- package/dist/react/components/Dial.js +3 -4
- package/dist/react/components/FavorableShare.d.ts +2 -5
- package/dist/react/components/FavorableShare.js +1 -2
- package/dist/react/components/FreshnessBadge.d.ts +2 -5
- package/dist/react/components/FreshnessBadge.js +1 -2
- package/dist/react/components/Readout.d.ts +2 -5
- package/dist/react/components/Readout.js +1 -2
- package/dist/react/components/RecentSummaries.d.ts +2 -5
- package/dist/react/components/RecentSummaries.js +1 -2
- package/dist/react/components/SceneTree.js +1 -2
- package/dist/react/components/Sparkline.d.ts +2 -5
- package/dist/react/components/Sparkline.js +2 -3
- package/dist/react/components/StationCard.d.ts +6 -8
- package/dist/react/components/StationCard.js +4 -5
- package/dist/react/components/StationFeedProvider.d.ts +3 -6
- package/dist/react/components/StationFeedProvider.js +2 -3
- package/dist/react/components/StationStrip.d.ts +2 -5
- package/dist/react/components/StationStrip.js +3 -4
- package/dist/react/components/StationTable.d.ts +3 -6
- package/dist/react/components/StationTable.js +4 -5
- package/dist/react/components/TrendChart.d.ts +3 -6
- package/dist/react/components/TrendChart.js +3 -4
- package/dist/react/components/WindArrow.d.ts +2 -5
- package/dist/react/components/WindArrow.js +1 -2
- package/dist/react/components/WindHistoryChart.d.ts +2 -5
- package/dist/react/components/WindHistoryChart.js +4 -5
- package/dist/react/components/WindRose.d.ts +2 -5
- package/dist/react/components/WindRose.js +1 -2
- package/dist/react/components/WindSampleStrip.d.ts +2 -5
- package/dist/react/components/WindSampleStrip.js +4 -5
- package/dist/react/components/atoms.d.ts +9 -11
- package/dist/react/components/atoms.js +3 -4
- package/dist/react/hooks/useFreshness.d.ts +1 -4
- package/dist/react/hooks/useFreshness.js +2 -3
- package/dist/react/hooks/useMeasuredChartWidth.d.ts +2 -5
- package/dist/react/hooks/useMeasuredChartWidth.js +1 -2
- package/dist/react/hooks/usePolledJson.js +1 -2
- package/dist/react/hooks/useStation.d.ts +2 -5
- package/dist/react/hooks/useStation.js +1 -2
- package/dist/react/hooks/useStationClimatology.d.ts +2 -5
- package/dist/react/hooks/useStationClimatology.js +2 -3
- package/dist/react/hooks/useStationCurrent.d.ts +2 -5
- package/dist/react/hooks/useStationCurrent.js +1 -2
- package/dist/react/hooks/useStationFeed.d.ts +2 -5
- package/dist/react/hooks/useStationFeed.js +1 -2
- package/dist/react/hooks/useStationLive.d.ts +2 -5
- package/dist/react/hooks/useStationLive.js +1 -2
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +3 -3
- package/dist/react/lib/cells.js +1 -2
- package/dist/react/lib/use-pinned-cursor.js +1 -2
- package/dist/samples.d.ts +8 -11
- package/dist/samples.js +1 -2
- package/dist/scene/air-extremes.js +1 -2
- package/dist/scene/air-matrix.js +1 -2
- package/dist/scene/atoms.d.ts +2 -2
- package/dist/scene/atoms.js +2 -3
- package/dist/scene/card.js +2 -3
- package/dist/scene/cells.d.ts +2 -2
- package/dist/scene/cells.js +2 -3
- package/dist/scene/chart.d.ts +2 -5
- package/dist/scene/chart.js +1 -2
- package/dist/scene/climatology-pattern.d.ts +2 -2
- package/dist/scene/climatology-pattern.js +2 -3
- package/dist/scene/climatology-rose.d.ts +2 -2
- package/dist/scene/climatology-rose.js +2 -3
- package/dist/scene/compass-fan.d.ts +2 -2
- package/dist/scene/compass-fan.js +2 -3
- package/dist/scene/current.d.ts +2 -2
- package/dist/scene/current.js +3 -4
- package/dist/scene/daily-pattern.d.ts +2 -2
- package/dist/scene/daily-pattern.js +2 -3
- package/dist/scene/dial-parts.js +1 -2
- package/dist/scene/dial.d.ts +2 -2
- package/dist/scene/dial.js +3 -4
- package/dist/scene/favorable-share.d.ts +2 -2
- package/dist/scene/favorable-share.js +1 -2
- package/dist/scene/glyphs.js +1 -2
- package/dist/scene/node.js +1 -2
- package/dist/scene/recent-summaries.d.ts +2 -2
- package/dist/scene/recent-summaries.js +2 -3
- package/dist/scene/rose.d.ts +2 -2
- package/dist/scene/rose.js +1 -2
- package/dist/scene/sample-strip.d.ts +2 -2
- package/dist/scene/sample-strip.js +2 -3
- package/dist/scene/sparkline.js +2 -3
- package/dist/scene/strip.js +3 -4
- package/dist/scene/table.js +3 -4
- package/dist/scene/trend.d.ts +2 -2
- package/dist/scene/trend.js +1 -2
- package/dist/scene/wind-history.d.ts +2 -2
- package/dist/scene/wind-history.js +3 -4
- package/dist/scene/wind-plot.d.ts +1 -1
- package/dist/scene/wind-plot.js +2 -3
- package/dist/server/adapter.d.ts +7 -10
- package/dist/server/adapter.js +1 -2
- package/dist/server/adapters/campbell.d.ts +12 -14
- package/dist/server/adapters/campbell.js +2 -3
- package/dist/server/adapters/ecowitt.d.ts +5 -8
- package/dist/server/adapters/ecowitt.js +2 -3
- package/dist/server/adapters/tempest.d.ts +5 -8
- package/dist/server/adapters/tempest.js +2 -3
- package/dist/server/adapters/windnerd-climatology.d.ts +6 -9
- package/dist/server/adapters/windnerd-climatology.js +3 -4
- package/dist/server/adapters/windnerd-live.d.ts +3 -6
- package/dist/server/adapters/windnerd-live.js +1 -2
- package/dist/server/adapters/windnerd.d.ts +24 -27
- package/dist/server/adapters/windnerd.js +7 -8
- package/dist/server/config.d.ts +18 -20
- package/dist/server/config.js +1 -2
- package/dist/server/environment.d.ts +21 -23
- package/dist/server/environment.js +14 -15
- package/dist/server/feed.d.ts +20 -22
- package/dist/server/feed.js +3 -4
- package/dist/server/handler.d.ts +5 -8
- package/dist/server/handler.js +3 -4
- package/dist/server/hologram.d.ts +9 -12
- package/dist/server/hologram.js +1 -2
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +9 -9
- package/dist/server/live.d.ts +2 -5
- package/dist/server/live.js +1 -2
- package/dist/sse.js +1 -2
- package/dist/strings.d.ts +8 -11
- package/dist/strings.js +1 -2
- package/dist/windnerd.d.ts +4 -7
- package/dist/windnerd.js +1 -2
- package/package.json +10 -10
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { compassDirection, isCalm, thresholdsToMps } from "../derive.js";
|
|
2
|
-
import { bandPoints, compareTracePoints, compareWindow, historyGaps, isCalmHistory, thinVanes, windowPoints } from "../geometry.js";
|
|
3
2
|
import { roundSpeed } from "../format.js";
|
|
4
|
-
import {
|
|
3
|
+
import { bandPoints, compareTracePoints, compareWindow, historyGaps, isCalmHistory, thinVanes, windowPoints } from "../geometry.js";
|
|
5
4
|
import { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, plotLine, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
|
|
6
|
-
|
|
5
|
+
import { el } from "./node.js";
|
|
6
|
+
// src/scene/wind-history.ts
|
|
7
7
|
const WIND_CHART_CLASS = "meteo-wind-chart";
|
|
8
8
|
function windChartGate(station, words) {
|
|
9
9
|
if (!station.capabilities.history) return { kind: "hidden" };
|
|
@@ -135,5 +135,4 @@ function windChartScene(input) {
|
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
//#endregion
|
|
139
138
|
export { WIND_CHART_CLASS, windChartGate, windChartScene };
|
package/dist/scene/wind-plot.js
CHANGED
|
@@ -2,7 +2,7 @@ import { compassDirection, speedToMps } from "../derive.js";
|
|
|
2
2
|
import { averagePoints, chartFrame, chartScales, speedBand, stretchFrame, tickAnchor, vanePath, vaneTicks } from "../geometry.js";
|
|
3
3
|
import { el, keyed } from "./node.js";
|
|
4
4
|
import { inDirectionArcs, solarEventsForDate } from "@azohra/meteo.core";
|
|
5
|
-
|
|
5
|
+
// src/scene/wind-plot.ts
|
|
6
6
|
/** A plot label: the anchor is the SVG attribute, spelled as the DOM does. */
|
|
7
7
|
function plotText(attrs, anchor, x, y, text) {
|
|
8
8
|
return el("text", {
|
|
@@ -152,7 +152,7 @@ const VALUE_LABEL_PX = 24;
|
|
|
152
152
|
const TIME_LABEL_PX = 76;
|
|
153
153
|
function vaneCells(vanes, frame, scales, valueText, favorableDirections) {
|
|
154
154
|
const verdict = (directionDeg) => favorableDirections == null || favorableDirections.length === 0 ? "" : inDirectionArcs(directionDeg, favorableDirections) ? " meteo-wind-vane-favorable" : " meteo-wind-vane-unfavorable";
|
|
155
|
-
const pitch = vanes.length === 0 ?
|
|
155
|
+
const pitch = vanes.length === 0 ? 1e400 : (frame.right - frame.left) / vanes.length;
|
|
156
156
|
const step = (needPx) => Math.max(1, Math.ceil(needPx / pitch));
|
|
157
157
|
const labelStep = step(COMPASS_LABEL_PX);
|
|
158
158
|
const valueStep = step(VALUE_LABEL_PX);
|
|
@@ -174,5 +174,4 @@ function vaneTickTexts(vanes, frame, scales, labelText) {
|
|
|
174
174
|
key: String(index)
|
|
175
175
|
}));
|
|
176
176
|
}
|
|
177
|
-
//#endregion
|
|
178
177
|
export { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, plotLine, plotText, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects };
|
package/dist/server/adapter.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { History, LiveSamples, Reading, RecentSummary, Station, StationMeta, StationTelemetry } from "../contract.js";
|
|
2
2
|
import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
type StationAdapterOptions = {
|
|
3
|
+
export type StationAdapterMode = "full" | "current";
|
|
4
|
+
export type StationAdapterOptions = {
|
|
6
5
|
historyHours?: number;
|
|
7
6
|
mode?: StationAdapterMode;
|
|
8
7
|
environment?: ServerEnvironment;
|
|
9
8
|
};
|
|
10
|
-
type StationAdapterContext<O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
9
|
+
export type StationAdapterContext<O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
11
10
|
readonly environment: ResolvedEnvironment;
|
|
12
11
|
readonly historyHours: number;
|
|
13
12
|
readonly mode: StationAdapterMode;
|
|
14
13
|
readonly options: O;
|
|
15
14
|
};
|
|
16
|
-
type StationAdapterResult = {
|
|
15
|
+
export type StationAdapterResult = {
|
|
17
16
|
readonly reading: Reading;
|
|
18
17
|
readonly history: History | null;
|
|
19
18
|
readonly telemetry?: StationTelemetry | null;
|
|
@@ -21,11 +20,9 @@ type StationAdapterResult = {
|
|
|
21
20
|
readonly recentSummaries?: RecentSummary[] | null;
|
|
22
21
|
readonly meta?: Partial<StationMeta>;
|
|
23
22
|
};
|
|
24
|
-
type StationAdapterDefinition<C, O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
23
|
+
export type StationAdapterDefinition<C, O extends StationAdapterOptions = StationAdapterOptions> = {
|
|
25
24
|
readonly meta: (config: C) => StationMeta;
|
|
26
25
|
readonly load: (config: C, context: StationAdapterContext<O>) => Promise<StationAdapterResult>;
|
|
27
26
|
};
|
|
28
|
-
type StationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions> = (config: C, options?: O) => Promise<Station>;
|
|
29
|
-
declare function defineStationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions>(definition: StationAdapterDefinition<C, O>): StationAdapter<C, O>;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { StationAdapter, StationAdapterContext, StationAdapterDefinition, StationAdapterMode, StationAdapterOptions, StationAdapterResult, defineStationAdapter };
|
|
27
|
+
export type StationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions> = (config: C, options?: O) => Promise<Station>;
|
|
28
|
+
export declare function defineStationAdapter<C, O extends StationAdapterOptions = StationAdapterOptions>(definition: StationAdapterDefinition<C, O>): StationAdapter<C, O>;
|
package/dist/server/adapter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { unavailableStation } from "../contract.js";
|
|
2
2
|
import { logUpstreamFailure, resolveEnvironment, unavailableReasonForError } from "./environment.js";
|
|
3
3
|
import "./feed.js";
|
|
4
|
-
|
|
4
|
+
// src/server/adapter.ts
|
|
5
5
|
function defineStationAdapter(definition) {
|
|
6
6
|
return async (config, options) => {
|
|
7
7
|
const resolved = options ?? {};
|
|
@@ -31,5 +31,4 @@ function defineStationAdapter(definition) {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { defineStationAdapter };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
1
2
|
import { HistoryPoint, Reading, Station } from "../../contract.js";
|
|
2
3
|
import { CampbellStationConfig } from "../config.js";
|
|
3
|
-
|
|
4
|
-
//#region src/server/adapters/campbell.d.ts
|
|
5
|
-
type CampbellAdapterOptions = StationAdapterOptions;
|
|
4
|
+
export type CampbellAdapterOptions = StationAdapterOptions;
|
|
6
5
|
type CampbellField = {
|
|
7
6
|
name: string;
|
|
8
7
|
process: string;
|
|
@@ -13,12 +12,12 @@ type CampbellRecord = {
|
|
|
13
12
|
time: string;
|
|
14
13
|
vals: unknown[];
|
|
15
14
|
};
|
|
16
|
-
type CampbellTable = {
|
|
15
|
+
export type CampbellTable = {
|
|
17
16
|
fields: CampbellField[];
|
|
18
17
|
records: CampbellRecord[];
|
|
19
18
|
};
|
|
20
19
|
type TableRole = "current" | "history";
|
|
21
|
-
declare const CAMPBELL_FIELD_CONTRACTS: {
|
|
20
|
+
export declare const CAMPBELL_FIELD_CONTRACTS: {
|
|
22
21
|
readonly current: readonly [{
|
|
23
22
|
readonly name: "Wind_Speed";
|
|
24
23
|
readonly process: "Avg";
|
|
@@ -72,14 +71,14 @@ declare const CAMPBELL_FIELD_CONTRACTS: {
|
|
|
72
71
|
readonly units: "kilometers/hour";
|
|
73
72
|
}];
|
|
74
73
|
};
|
|
75
|
-
type CampbellTableExpectation = {
|
|
74
|
+
export type CampbellTableExpectation = {
|
|
76
75
|
role: TableRole;
|
|
77
76
|
tableName: string;
|
|
78
77
|
stationName: string;
|
|
79
78
|
intervalMs: number;
|
|
80
79
|
subject: string;
|
|
81
80
|
};
|
|
82
|
-
declare const loadCampbellStation: StationAdapter<{
|
|
81
|
+
export declare const loadCampbellStation: StationAdapter<{
|
|
83
82
|
elevationM?: number | null | undefined;
|
|
84
83
|
latitude?: number | null | undefined;
|
|
85
84
|
longitude?: number | null | undefined;
|
|
@@ -96,17 +95,16 @@ declare const loadCampbellStation: StationAdapter<{
|
|
|
96
95
|
historyPeriodMinutes: number;
|
|
97
96
|
currentCacheTtlSeconds: number;
|
|
98
97
|
}, StationAdapterOptions>;
|
|
99
|
-
declare function loadCampbellCurrent(config: CampbellStationConfig, options?: CampbellAdapterOptions): Promise<Station>;
|
|
100
|
-
declare function parseCampbellCurrent(value: string, config: CampbellStationConfig, nowMs?: number): Reading;
|
|
101
|
-
declare function parseCampbellHistory(value: string, config: CampbellStationConfig): {
|
|
98
|
+
export declare function loadCampbellCurrent(config: CampbellStationConfig, options?: CampbellAdapterOptions): Promise<Station>;
|
|
99
|
+
export declare function parseCampbellCurrent(value: string, config: CampbellStationConfig, nowMs?: number): Reading;
|
|
100
|
+
export declare function parseCampbellHistory(value: string, config: CampbellStationConfig): {
|
|
102
101
|
points: HistoryPoint[];
|
|
103
102
|
latestTemperatureC: number;
|
|
104
103
|
latestWindChillC: number;
|
|
105
104
|
};
|
|
106
|
-
declare function parseCampbellTable(value: string, expectation: CampbellTableExpectation): CampbellTable;
|
|
107
|
-
declare function naiveLocalToIso(naive: string, timeZone: string, context?: {
|
|
105
|
+
export declare function parseCampbellTable(value: string, expectation: CampbellTableExpectation): CampbellTable;
|
|
106
|
+
export declare function naiveLocalToIso(naive: string, timeZone: string, context?: {
|
|
108
107
|
afterMs?: number | null;
|
|
109
108
|
nearMs?: number;
|
|
110
109
|
}): string;
|
|
111
|
-
|
|
112
|
-
export { CAMPBELL_FIELD_CONTRACTS, CampbellAdapterOptions, CampbellTable, CampbellTableExpectation, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable };
|
|
110
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isCalm, normalizeDegrees } from "../../derive.js";
|
|
2
|
-
import { fetchUpstreamText, logUpstreamFailure } from "../environment.js";
|
|
3
2
|
import { defineStationAdapter } from "../adapter.js";
|
|
3
|
+
import { fetchUpstreamText, logUpstreamFailure } from "../environment.js";
|
|
4
4
|
import { kmhToMps } from "@azohra/meteo.core";
|
|
5
|
-
|
|
5
|
+
// src/server/adapters/campbell.ts
|
|
6
6
|
const HISTORY_CACHE_TTL_SECONDS = 120;
|
|
7
7
|
const MAX_RESPONSE_BYTES = 524288;
|
|
8
8
|
const CAMPBELL_FIELD_CONTRACTS = {
|
|
@@ -410,5 +410,4 @@ function naiveLocalToIso(naive, timeZone, context = {}) {
|
|
|
410
410
|
}
|
|
411
411
|
return new Date(high).toISOString();
|
|
412
412
|
}
|
|
413
|
-
//#endregion
|
|
414
413
|
export { CAMPBELL_FIELD_CONTRACTS, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
1
2
|
import { Reading, StationTelemetry } from "../../contract.js";
|
|
2
3
|
import { EcowittStationConfig } from "../config.js";
|
|
3
|
-
|
|
4
|
-
//#region src/server/adapters/ecowitt.d.ts
|
|
5
|
-
type EcowittAdapterOptions = StationAdapterOptions & {
|
|
4
|
+
export type EcowittAdapterOptions = StationAdapterOptions & {
|
|
6
5
|
realTimeUrl?: string;
|
|
7
6
|
};
|
|
8
|
-
type EcowittObservation = {
|
|
7
|
+
export type EcowittObservation = {
|
|
9
8
|
reading: Reading;
|
|
10
9
|
telemetry: StationTelemetry | null;
|
|
11
10
|
};
|
|
12
|
-
declare const loadEcowittStation: StationAdapter<{
|
|
11
|
+
export declare const loadEcowittStation: StationAdapter<{
|
|
13
12
|
elevationM?: number | null | undefined;
|
|
14
13
|
latitude?: number | null | undefined;
|
|
15
14
|
longitude?: number | null | undefined;
|
|
@@ -23,6 +22,4 @@ declare const loadEcowittStation: StationAdapter<{
|
|
|
23
22
|
mac: string;
|
|
24
23
|
hasBattery: boolean;
|
|
25
24
|
}, EcowittAdapterOptions>;
|
|
26
|
-
declare function parseEcowittRealTime(value: string, config: Pick<EcowittStationConfig, "mac" | "elevationM">): EcowittObservation;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { EcowittAdapterOptions, EcowittObservation, loadEcowittStation, parseEcowittRealTime };
|
|
25
|
+
export declare function parseEcowittRealTime(value: string, config: Pick<EcowittStationConfig, "mac" | "elevationM">): EcowittObservation;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { emptyConditions } from "../../contract.js";
|
|
2
2
|
import { isCalm, normalizeDegrees, seaLevelPressureHpa } from "../../derive.js";
|
|
3
|
-
import { fetchUpstreamText } from "../environment.js";
|
|
4
3
|
import { defineStationAdapter } from "../adapter.js";
|
|
4
|
+
import { fetchUpstreamText } from "../environment.js";
|
|
5
5
|
import { UpstreamError, plausibleWindMps } from "@azohra/meteo.core";
|
|
6
|
-
|
|
6
|
+
// src/server/adapters/ecowitt.ts
|
|
7
7
|
const ECOWITT_REAL_TIME_URL = "https://api.ecowitt.net/api/v3/device/real_time";
|
|
8
8
|
const CACHE_TTL_SECONDS = 60;
|
|
9
9
|
const ECOWITT_CALL_BACK = "outdoor,wind,pressure,rainfall,rainfall_piezo,solar_and_uvi,battery";
|
|
@@ -146,5 +146,4 @@ function directionDegrees(value) {
|
|
|
146
146
|
if (value < 0 || value > 360) throw new Error("Ecowitt returned an invalid wind direction");
|
|
147
147
|
return value;
|
|
148
148
|
}
|
|
149
|
-
//#endregion
|
|
150
149
|
export { loadEcowittStation, parseEcowittRealTime };
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { Reading } from "../../contract.js";
|
|
2
1
|
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
3
|
-
|
|
4
|
-
type TempestAdapterOptions = StationAdapterOptions & {
|
|
2
|
+
import { Reading } from "../../contract.js";
|
|
3
|
+
export type TempestAdapterOptions = StationAdapterOptions & {
|
|
5
4
|
observationsUrl?: string;
|
|
6
5
|
};
|
|
7
|
-
type TempestObservation = {
|
|
6
|
+
export type TempestObservation = {
|
|
8
7
|
reading: Reading;
|
|
9
8
|
elevationM: number | null;
|
|
10
9
|
latitude: number | null;
|
|
11
10
|
longitude: number | null;
|
|
12
11
|
};
|
|
13
|
-
declare const loadTempestStation: StationAdapter<{
|
|
12
|
+
export declare const loadTempestStation: StationAdapter<{
|
|
14
13
|
elevationM?: number | null | undefined;
|
|
15
14
|
latitude?: number | null | undefined;
|
|
16
15
|
longitude?: number | null | undefined;
|
|
@@ -22,6 +21,4 @@ declare const loadTempestStation: StationAdapter<{
|
|
|
22
21
|
stationId: number;
|
|
23
22
|
token: string;
|
|
24
23
|
}, TempestAdapterOptions>;
|
|
25
|
-
declare function parseTempestWind(value: string, expectedStationId: number): TempestObservation;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { TempestAdapterOptions, TempestObservation, loadTempestStation, parseTempestWind };
|
|
24
|
+
export declare function parseTempestWind(value: string, expectedStationId: number): TempestObservation;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isCalm, normalizeDegrees } from "../../derive.js";
|
|
2
|
-
import { fetchUpstreamText } from "../environment.js";
|
|
3
2
|
import { defineStationAdapter } from "../adapter.js";
|
|
3
|
+
import { fetchUpstreamText } from "../environment.js";
|
|
4
4
|
import { plausibleWindMps } from "@azohra/meteo.core";
|
|
5
|
-
|
|
5
|
+
// src/server/adapters/tempest.ts
|
|
6
6
|
const TEMPEST_OBSERVATIONS_URL = "https://swd.weatherflow.com/swd/rest/observations/station";
|
|
7
7
|
const CACHE_TTL_SECONDS = 60;
|
|
8
8
|
const loadTempestStation = defineStationAdapter({
|
|
@@ -133,5 +133,4 @@ function longitudeDegrees(value) {
|
|
|
133
133
|
if (value < -180 || value > 180) throw new Error("Tempest returned an invalid longitude");
|
|
134
134
|
return value === 180 ? -180 : value;
|
|
135
135
|
}
|
|
136
|
-
//#endregion
|
|
137
136
|
export { loadTempestStation, parseTempestWind };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { StationClimatology } from "../../contract-climatology.js";
|
|
2
2
|
import { SpeedThresholds } from "../../derive.js";
|
|
3
|
-
import { ServerEnvironment } from "../environment.js";
|
|
4
3
|
import { WindnerdStationConfig } from "../config.js";
|
|
5
|
-
|
|
6
|
-
declare const CLIMATOLOGY_RECORD_PERIOD_MINUTES = 180;
|
|
7
|
-
declare const CLIMATOLOGY_DEFAULT_YEARS = 8;
|
|
8
|
-
declare const CLIMATOLOGY_DEFAULT_SECTOR_COUNT = 16;
|
|
9
|
-
type WindnerdClimatologyOptions = {
|
|
4
|
+
import { ServerEnvironment } from "../environment.js";
|
|
5
|
+
export declare const CLIMATOLOGY_RECORD_PERIOD_MINUTES = 180;
|
|
6
|
+
export declare const CLIMATOLOGY_DEFAULT_YEARS = 8;
|
|
7
|
+
export declare const CLIMATOLOGY_DEFAULT_SECTOR_COUNT = 16;
|
|
8
|
+
export type WindnerdClimatologyOptions = {
|
|
10
9
|
/** The consumer's speed-band bounds — a judgment parameter with no
|
|
11
10
|
* default; it shapes every bandCounts stack and joins the cache key. */
|
|
12
11
|
thresholds: SpeedThresholds;
|
|
@@ -25,6 +24,4 @@ type WindnerdClimatologyOptions = {
|
|
|
25
24
|
* running year 6 hours), folded into (month, slot, sector) sums in the
|
|
26
25
|
* station's STANDARD time. Any refused year fails the whole document —
|
|
27
26
|
* a silently missing year would read as an outage. */
|
|
28
|
-
declare function loadWindnerdClimatology(config: WindnerdStationConfig, options: WindnerdClimatologyOptions): Promise<StationClimatology>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, WindnerdClimatologyOptions, loadWindnerdClimatology };
|
|
27
|
+
export declare function loadWindnerdClimatology(config: WindnerdStationConfig, options: WindnerdClimatologyOptions): Promise<StationClimatology>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { thresholdsToMps } from "../../derive.js";
|
|
2
|
-
import "../../contract-climatology.js";
|
|
3
1
|
import { accumulatedCells, coveredSlotCountByYear, createClimatologyAccumulator, foldClimatologyPoints } from "../../climatology.js";
|
|
2
|
+
import "../../contract-climatology.js";
|
|
3
|
+
import { thresholdsToMps } from "../../derive.js";
|
|
4
4
|
import { fetchUpstreamText, logUpstreamFailure, resolveEnvironment } from "../environment.js";
|
|
5
5
|
import { loadWindnerdLocation, parseWindnerdRecords, windnerdHistoryPoints } from "./windnerd.js";
|
|
6
|
-
|
|
6
|
+
// src/server/adapters/windnerd-climatology.ts
|
|
7
7
|
const CLIMATOLOGY_RECORD_PERIOD_MINUTES = 180;
|
|
8
8
|
const CLIMATOLOGY_DEFAULT_YEARS = 8;
|
|
9
9
|
const CLIMATOLOGY_DEFAULT_SECTOR_COUNT = 16;
|
|
@@ -79,5 +79,4 @@ async function standardOffsetMinutes(config, environment, options) {
|
|
|
79
79
|
return 0;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
//#endregion
|
|
83
82
|
export { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, loadWindnerdClimatology };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { StationLiveFrame } from "../../contract.js";
|
|
2
|
-
import { ServerEnvironment } from "../environment.js";
|
|
3
2
|
import { WindnerdStationConfig } from "../config.js";
|
|
4
|
-
|
|
5
|
-
type WindnerdLiveOptions = {
|
|
3
|
+
import { ServerEnvironment } from "../environment.js";
|
|
4
|
+
export type WindnerdLiveOptions = {
|
|
6
5
|
environment?: ServerEnvironment;
|
|
7
6
|
signal?: AbortSignal;
|
|
8
7
|
liveUrl?: string;
|
|
@@ -13,6 +12,4 @@ type WindnerdLiveOptions = {
|
|
|
13
12
|
* upstream init frame) rejects on failure; after that, failures degrade
|
|
14
13
|
* to a terminal unavailable frame. One call is one upstream connection;
|
|
15
14
|
* reconnect and fan-out belong to the caller. */
|
|
16
|
-
declare function openWindnerdLive(config: WindnerdStationConfig, options?: WindnerdLiveOptions): Promise<ReadableStream<StationLiveFrame>>;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { WindnerdLiveOptions, openWindnerdLive };
|
|
15
|
+
export declare function openWindnerdLive(config: WindnerdStationConfig, options?: WindnerdLiveOptions): Promise<ReadableStream<StationLiveFrame>>;
|
|
@@ -2,7 +2,7 @@ import "../../contract.js";
|
|
|
2
2
|
import { sseEvents } from "../../sse.js";
|
|
3
3
|
import { UpstreamError, fetchUpstreamStream, logUpstreamFailure, resolveEnvironment, unavailableReasonForError } from "../environment.js";
|
|
4
4
|
import { WINDNERD_LIVE_INIT_TIMEOUT_MS, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, windnerdEnrichedMeta, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl, windnerdStationMeta } from "./windnerd.js";
|
|
5
|
-
|
|
5
|
+
// src/server/adapters/windnerd-live.ts
|
|
6
6
|
const LIVE_IDLE_TIMEOUT_MS = 75e3;
|
|
7
7
|
/** Opens the station's live stream: one init frame, then
|
|
8
8
|
* samples/reading/ping as served. The connect phase (headers plus the
|
|
@@ -181,5 +181,4 @@ function mapLiveEvent(event, config, environment) {
|
|
|
181
181
|
function isRecord(value) {
|
|
182
182
|
return typeof value === "object" && value !== null;
|
|
183
183
|
}
|
|
184
|
-
//#endregion
|
|
185
184
|
export { openWindnerdLive };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import { StationAdapter, StationAdapterOptions } from "../adapter.js";
|
|
1
2
|
import { History, HistoryPoint, LiveSamples, Reading, RecentSummary, StationMeta, StationTelemetry } from "../../contract.js";
|
|
2
3
|
import { WindnerdRecordPeriodMinutes } from "../../windnerd.js";
|
|
3
|
-
import "../environment.js";
|
|
4
4
|
import { WindnerdStationConfig } from "../config.js";
|
|
5
|
-
import
|
|
5
|
+
import "../environment.js";
|
|
6
6
|
import { DirectionArc } from "@azohra/meteo.core";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type WindnerdAdapterOptions = StationAdapterOptions & {
|
|
7
|
+
export declare const WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS = 3;
|
|
8
|
+
export type WindnerdAdapterOptions = StationAdapterOptions & {
|
|
10
9
|
recordsUrl?: string;
|
|
11
10
|
liveUrl?: string;
|
|
12
11
|
recordPeriodMinutes?: WindnerdRecordPeriodMinutes;
|
|
13
12
|
cacheTtlSeconds?: number;
|
|
14
13
|
};
|
|
15
|
-
type WindnerdRecords = {
|
|
14
|
+
export type WindnerdRecords = {
|
|
16
15
|
averageSpeedMps: number[];
|
|
17
16
|
vectorAverageSpeedMps: Array<number | null>;
|
|
18
17
|
windDirectionDeg: number[];
|
|
@@ -26,7 +25,7 @@ type WindnerdRecords = {
|
|
|
26
25
|
stationPressureMinHpa: Array<number | null>;
|
|
27
26
|
stationPressureMaxHpa: Array<number | null>;
|
|
28
27
|
};
|
|
29
|
-
declare const loadWindnerdStation: StationAdapter<{
|
|
28
|
+
export declare const loadWindnerdStation: StationAdapter<{
|
|
30
29
|
elevationM?: number | null | undefined;
|
|
31
30
|
latitude?: number | null | undefined;
|
|
32
31
|
longitude?: number | null | undefined;
|
|
@@ -41,14 +40,14 @@ declare const loadWindnerdStation: StationAdapter<{
|
|
|
41
40
|
hasPressure: boolean;
|
|
42
41
|
hasBattery: boolean;
|
|
43
42
|
}, WindnerdAdapterOptions>;
|
|
44
|
-
declare function windnerdHistoryPoints(records: WindnerdRecords, config: Pick<WindnerdStationConfig, "hasTemperature" | "hasPressure" | "elevationM">): HistoryPoint[];
|
|
45
|
-
type WindnerdHistoryQuery = {
|
|
43
|
+
export declare function windnerdHistoryPoints(records: WindnerdRecords, config: Pick<WindnerdStationConfig, "hasTemperature" | "hasPressure" | "elevationM">): HistoryPoint[];
|
|
44
|
+
export type WindnerdHistoryQuery = {
|
|
46
45
|
fromMs: number;
|
|
47
46
|
toMs: number;
|
|
48
47
|
periodMinutes: WindnerdRecordPeriodMinutes;
|
|
49
48
|
};
|
|
50
|
-
declare function loadWindnerdHistory(config: WindnerdStationConfig, query: WindnerdHistoryQuery, options?: WindnerdAdapterOptions): Promise<History>;
|
|
51
|
-
type WindnerdLiveDigest = {
|
|
49
|
+
export declare function loadWindnerdHistory(config: WindnerdStationConfig, query: WindnerdHistoryQuery, options?: WindnerdAdapterOptions): Promise<History>;
|
|
50
|
+
export type WindnerdLiveDigest = {
|
|
52
51
|
observedAt: string;
|
|
53
52
|
windAvgMps: number;
|
|
54
53
|
gustMps: number | null;
|
|
@@ -58,12 +57,12 @@ type WindnerdLiveDigest = {
|
|
|
58
57
|
stationPressureHpa: number | null;
|
|
59
58
|
batteryVoltage: number | null;
|
|
60
59
|
};
|
|
61
|
-
type WindnerdLiveSampleRecord = {
|
|
60
|
+
export type WindnerdLiveSampleRecord = {
|
|
62
61
|
observedAt: string;
|
|
63
62
|
speedMps: number;
|
|
64
63
|
directionDeg: number;
|
|
65
64
|
};
|
|
66
|
-
type WindnerdLiveLocation = {
|
|
65
|
+
export type WindnerdLiveLocation = {
|
|
67
66
|
declaredFavorableDirections: DirectionArc[] | null;
|
|
68
67
|
altitudeM: number | null;
|
|
69
68
|
timeZone: string | null;
|
|
@@ -71,26 +70,24 @@ type WindnerdLiveLocation = {
|
|
|
71
70
|
longitude: number | null;
|
|
72
71
|
standardUtcOffsetMinutes: number | null;
|
|
73
72
|
};
|
|
74
|
-
type WindnerdLiveInit = {
|
|
73
|
+
export type WindnerdLiveInit = {
|
|
75
74
|
digest: WindnerdLiveDigest;
|
|
76
75
|
samples: WindnerdLiveSampleRecord[];
|
|
77
76
|
location: WindnerdLiveLocation | null;
|
|
78
77
|
broadcastDelaySeconds: number | null;
|
|
79
78
|
recentSummaries: RecentSummary[] | null;
|
|
80
79
|
};
|
|
81
|
-
declare function windnerdLiveStreamUrl(config: Pick<WindnerdStationConfig, "stationKey">, base?: string): URL;
|
|
82
|
-
declare function parseWindnerdLiveInit(value: string, locationId: number): WindnerdLiveInit;
|
|
83
|
-
declare function parseWindnerdRecentSummaries(value: unknown): RecentSummary[] | null;
|
|
84
|
-
declare function parseWindnerdLiveLocation(value: unknown): WindnerdLiveLocation | null;
|
|
85
|
-
declare function parseStandardTimeOffset(value: unknown): number | null;
|
|
86
|
-
declare function parseWindnerdLiveDigest(value: unknown, locationId: number): WindnerdLiveDigest;
|
|
87
|
-
declare function parseWindnerdLiveSampleRecords(value: unknown, locationId: number): WindnerdLiveSampleRecord[];
|
|
88
|
-
declare function windnerdLiveReading(digest: WindnerdLiveDigest, config: Pick<WindnerdStationConfig, "hasTemperature" | "hasPressure" | "hasBattery" | "elevationM">): {
|
|
80
|
+
export declare function windnerdLiveStreamUrl(config: Pick<WindnerdStationConfig, "stationKey">, base?: string): URL;
|
|
81
|
+
export declare function parseWindnerdLiveInit(value: string, locationId: number): WindnerdLiveInit;
|
|
82
|
+
export declare function parseWindnerdRecentSummaries(value: unknown): RecentSummary[] | null;
|
|
83
|
+
export declare function parseWindnerdLiveLocation(value: unknown): WindnerdLiveLocation | null;
|
|
84
|
+
export declare function parseStandardTimeOffset(value: unknown): number | null;
|
|
85
|
+
export declare function parseWindnerdLiveDigest(value: unknown, locationId: number): WindnerdLiveDigest;
|
|
86
|
+
export declare function parseWindnerdLiveSampleRecords(value: unknown, locationId: number): WindnerdLiveSampleRecord[];
|
|
87
|
+
export declare function windnerdLiveReading(digest: WindnerdLiveDigest, config: Pick<WindnerdStationConfig, "hasTemperature" | "hasPressure" | "hasBattery" | "elevationM">): {
|
|
89
88
|
reading: Reading;
|
|
90
89
|
telemetry: StationTelemetry | null;
|
|
91
90
|
};
|
|
92
|
-
declare function windnerdLiveSamples(records: WindnerdLiveSampleRecord[]): LiveSamples;
|
|
93
|
-
declare function windnerdEnrichedMeta(config: Pick<WindnerdStationConfig, "latitude" | "longitude" | "timeZone" | "elevationM">, location: WindnerdLiveLocation | null, broadcastDelaySeconds: number | null): Partial<StationMeta>;
|
|
94
|
-
declare function parseWindnerdRecords(value: string, locationId: number, hasPressure?: boolean): WindnerdRecords;
|
|
95
|
-
//#endregion
|
|
96
|
-
export { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WindnerdAdapterOptions, WindnerdHistoryQuery, WindnerdLiveDigest, WindnerdLiveInit, WindnerdLiveLocation, WindnerdLiveSampleRecord, WindnerdRecords, loadWindnerdHistory, loadWindnerdStation, parseStandardTimeOffset, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl };
|
|
91
|
+
export declare function windnerdLiveSamples(records: WindnerdLiveSampleRecord[]): LiveSamples;
|
|
92
|
+
export declare function windnerdEnrichedMeta(config: Pick<WindnerdStationConfig, "latitude" | "longitude" | "timeZone" | "elevationM">, location: WindnerdLiveLocation | null, broadcastDelaySeconds: number | null): Partial<StationMeta>;
|
|
93
|
+
export declare function parseWindnerdRecords(value: string, locationId: number, hasPressure?: boolean): WindnerdRecords;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { emptyConditions } from "../../contract.js";
|
|
2
2
|
import { isCalm, normalizeDegrees, pressureTendency, seaLevelPressureHpa } from "../../derive.js";
|
|
3
|
-
import { WINDNERD_RECORD_PERIODS_MINUTES, windnerdStationUrl } from "../../windnerd.js";
|
|
4
3
|
import { sseEvents } from "../../sse.js";
|
|
5
|
-
import {
|
|
4
|
+
import { WINDNERD_RECORD_PERIODS_MINUTES, windnerdStationUrl } from "../../windnerd.js";
|
|
6
5
|
import { defineStationAdapter } from "../adapter.js";
|
|
6
|
+
import { coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, resolveEnvironment } from "../environment.js";
|
|
7
7
|
import { UpstreamError } from "@azohra/meteo.core";
|
|
8
|
-
|
|
8
|
+
// src/server/adapters/windnerd.ts
|
|
9
9
|
const WINDNERD_RECORDS_URL = "https://windnerd.net/api/records";
|
|
10
10
|
const WINDNERD_LIVE_URL = "https://windnerd.net/api/live-url";
|
|
11
11
|
const RECORD_PERIOD_MINUTES = 1;
|
|
@@ -280,7 +280,7 @@ function parseWindnerdLiveDigest(value, locationId) {
|
|
|
280
280
|
gustMps: rangeOrNull(wind.wind_max, 0, MAX_WIND_MPS, "wind_max"),
|
|
281
281
|
lullMps: rangeOrNull(wind.wind_min, 0, MAX_WIND_MPS, "wind_min"),
|
|
282
282
|
windDirectionDeg,
|
|
283
|
-
temperatureC: rangeOrNull(recent.temperature, -
|
|
283
|
+
temperatureC: rangeOrNull(recent.temperature, -1e400, 1e400, "temperature"),
|
|
284
284
|
stationPressureHpa: rangeOrNull(recent.pressure_hpa, STATION_PRESSURE_MIN_HPA, STATION_PRESSURE_MAX_HPA, "pressure_hpa"),
|
|
285
285
|
batteryVoltage: rangeOrNull(recent.voltage, BATTERY_VOLTAGE_MIN, BATTERY_VOLTAGE_MAX, "voltage")
|
|
286
286
|
};
|
|
@@ -440,8 +440,8 @@ function parseWindnerdRecords(value, locationId, hasPressure = false) {
|
|
|
440
440
|
throw new Error(`WindNerd location ${locationId} returned an invalid ${name}`);
|
|
441
441
|
};
|
|
442
442
|
const speeds = (name) => numberSeries(records[name], dates.length, 0, MAX_WIND_MPS, name, fail);
|
|
443
|
-
const optionalSeries = (name, minimum = -
|
|
444
|
-
const requiredSeries = (name, minimum = -
|
|
443
|
+
const optionalSeries = (name, minimum = -1e400, maximum = 1e400) => records[name] == null ? dates.map(() => null) : nullableSeries(records[name], dates.length, name, fail, minimum, maximum);
|
|
444
|
+
const requiredSeries = (name, minimum = -1e400, maximum = 1e400) => dates.length === 0 ? [] : nullableSeries(records[name], dates.length, name, fail, minimum, maximum);
|
|
445
445
|
return {
|
|
446
446
|
averageSpeedMps: speeds("wind_avg_1D"),
|
|
447
447
|
vectorAverageSpeedMps: optionalSeries("wind_avg_2D", 0, MAX_WIND_MPS),
|
|
@@ -472,7 +472,7 @@ function numberSeries(value, length, minimum, maximum, name, fail) {
|
|
|
472
472
|
if (!Array.isArray(value) || value.length !== length || value.some((entry) => typeof entry !== "number" || !Number.isFinite(entry) || entry < minimum || entry > maximum)) fail(name);
|
|
473
473
|
return value;
|
|
474
474
|
}
|
|
475
|
-
function nullableSeries(value, length, name, fail, minimum = -
|
|
475
|
+
function nullableSeries(value, length, name, fail, minimum = -1e400, maximum = 1e400) {
|
|
476
476
|
if (!Array.isArray(value) || value.length !== length || value.some((entry) => entry != null && (typeof entry !== "number" || !Number.isFinite(entry) || entry < minimum || entry > maximum))) fail(name);
|
|
477
477
|
return value;
|
|
478
478
|
}
|
|
@@ -484,5 +484,4 @@ function recordTimeToIso(value, locationId) {
|
|
|
484
484
|
function isRecord(value) {
|
|
485
485
|
return typeof value === "object" && value !== null;
|
|
486
486
|
}
|
|
487
|
-
//#endregion
|
|
488
487
|
export { WINDNERD_LIVE_INIT_TIMEOUT_MS, WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WINDNERD_RECORDS_URL, loadWindnerdHistory, loadWindnerdLocation, loadWindnerdStation, parseStandardTimeOffset, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl, windnerdStationMeta };
|
package/dist/server/config.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { Station } from "../contract.js";
|
|
|
2
2
|
import { normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
3
3
|
import { ResolvedEnvironment } from "./environment.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
declare const windnerdStationConfigSchema: z.ZodObject<{
|
|
5
|
+
export declare const windnerdStationConfigSchema: z.ZodObject<{
|
|
7
6
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
8
7
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
9
8
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -18,8 +17,8 @@ declare const windnerdStationConfigSchema: z.ZodObject<{
|
|
|
18
17
|
hasPressure: z.ZodDefault<z.ZodBoolean>;
|
|
19
18
|
hasBattery: z.ZodDefault<z.ZodBoolean>;
|
|
20
19
|
}, z.core.$strict>;
|
|
21
|
-
type WindnerdStationConfig = z.output<typeof windnerdStationConfigSchema>;
|
|
22
|
-
declare const tempestStationConfigSchema: z.ZodObject<{
|
|
20
|
+
export type WindnerdStationConfig = z.output<typeof windnerdStationConfigSchema>;
|
|
21
|
+
export declare const tempestStationConfigSchema: z.ZodObject<{
|
|
23
22
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
24
23
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
25
24
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -31,8 +30,8 @@ declare const tempestStationConfigSchema: z.ZodObject<{
|
|
|
31
30
|
stationId: z.ZodNumber;
|
|
32
31
|
token: z.ZodString;
|
|
33
32
|
}, z.core.$strict>;
|
|
34
|
-
type TempestStationConfig = z.output<typeof tempestStationConfigSchema>;
|
|
35
|
-
declare const ecowittStationConfigSchema: z.ZodObject<{
|
|
33
|
+
export type TempestStationConfig = z.output<typeof tempestStationConfigSchema>;
|
|
34
|
+
export declare const ecowittStationConfigSchema: z.ZodObject<{
|
|
36
35
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
37
36
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
38
37
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -46,8 +45,8 @@ declare const ecowittStationConfigSchema: z.ZodObject<{
|
|
|
46
45
|
mac: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
47
46
|
hasBattery: z.ZodDefault<z.ZodBoolean>;
|
|
48
47
|
}, z.core.$strict>;
|
|
49
|
-
type EcowittStationConfig = z.output<typeof ecowittStationConfigSchema>;
|
|
50
|
-
declare const campbellStationConfigSchema: z.ZodObject<{
|
|
48
|
+
export type EcowittStationConfig = z.output<typeof ecowittStationConfigSchema>;
|
|
49
|
+
export declare const campbellStationConfigSchema: z.ZodObject<{
|
|
51
50
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
52
51
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
53
52
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -64,8 +63,8 @@ declare const campbellStationConfigSchema: z.ZodObject<{
|
|
|
64
63
|
historyPeriodMinutes: z.ZodDefault<z.ZodNumber>;
|
|
65
64
|
currentCacheTtlSeconds: z.ZodDefault<z.ZodNumber>;
|
|
66
65
|
}, z.core.$strict>;
|
|
67
|
-
type CampbellStationConfig = z.output<typeof campbellStationConfigSchema>;
|
|
68
|
-
type CustomStationIdentity = {
|
|
66
|
+
export type CampbellStationConfig = z.output<typeof campbellStationConfigSchema>;
|
|
67
|
+
export type CustomStationIdentity = {
|
|
69
68
|
readonly id: string;
|
|
70
69
|
readonly name: string;
|
|
71
70
|
readonly elevationM: number | null;
|
|
@@ -74,14 +73,14 @@ type CustomStationIdentity = {
|
|
|
74
73
|
readonly timeZone: string | null;
|
|
75
74
|
readonly pageUrl: string | null;
|
|
76
75
|
};
|
|
77
|
-
type CustomStationContext = {
|
|
76
|
+
export type CustomStationContext = {
|
|
78
77
|
environment: ResolvedEnvironment;
|
|
79
78
|
historyHours: number;
|
|
80
79
|
mode: "full" | "current";
|
|
81
80
|
station: CustomStationIdentity;
|
|
82
81
|
};
|
|
83
|
-
type CustomStationLoader = (context: CustomStationContext) => Promise<Station>;
|
|
84
|
-
declare const customStationConfigSchema: z.ZodObject<{
|
|
82
|
+
export type CustomStationLoader = (context: CustomStationContext) => Promise<Station>;
|
|
83
|
+
export declare const customStationConfigSchema: z.ZodObject<{
|
|
85
84
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
86
85
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
87
86
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -92,8 +91,8 @@ declare const customStationConfigSchema: z.ZodObject<{
|
|
|
92
91
|
vendor: z.ZodLiteral<"custom">;
|
|
93
92
|
load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
|
|
94
93
|
}, z.core.$strict>;
|
|
95
|
-
type CustomStationConfig = z.output<typeof customStationConfigSchema>;
|
|
96
|
-
declare const stationConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
94
|
+
export type CustomStationConfig = z.output<typeof customStationConfigSchema>;
|
|
95
|
+
export declare const stationConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
97
96
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
98
97
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
99
98
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
@@ -158,8 +157,7 @@ declare const stationConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
158
157
|
vendor: z.ZodLiteral<"custom">;
|
|
159
158
|
load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
|
|
160
159
|
}, z.core.$strict>], "vendor">;
|
|
161
|
-
type StationConfig = z.output<typeof stationConfigSchema>;
|
|
162
|
-
type StationConfigInput = z.input<typeof stationConfigSchema>;
|
|
163
|
-
declare function parseStationConfig(value: unknown): StationConfig;
|
|
164
|
-
|
|
165
|
-
export { CampbellStationConfig, CustomStationConfig, CustomStationContext, CustomStationIdentity, CustomStationLoader, EcowittStationConfig, StationConfig, StationConfigInput, TempestStationConfig, WindnerdStationConfig, campbellStationConfigSchema, customStationConfigSchema, ecowittStationConfigSchema, normalizeWindnerdStationKey, parseStationConfig, stationConfigSchema, tempestStationConfigSchema, windnerdStationConfigSchema, windnerdStationUrl };
|
|
160
|
+
export type StationConfig = z.output<typeof stationConfigSchema>;
|
|
161
|
+
export type StationConfigInput = z.input<typeof stationConfigSchema>;
|
|
162
|
+
export declare function parseStationConfig(value: unknown): StationConfig;
|
|
163
|
+
export { normalizeWindnerdStationKey, windnerdStationUrl };
|