@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.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/air.d.ts +13 -0
- package/dist/air.js +76 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +4 -0
- package/dist/client/poll.d.ts +42 -0
- package/dist/client/poll.js +121 -0
- package/dist/client/stores.d.ts +46 -0
- package/dist/client/stores.js +128 -0
- package/dist/client/ticker.d.ts +4 -0
- package/dist/client/ticker.js +19 -0
- package/dist/contract.d.ts +381 -0
- package/dist/contract.js +143 -0
- package/dist/derive.d.ts +54 -0
- package/dist/derive.js +134 -0
- package/dist/display.d.ts +28 -0
- package/dist/display.js +27 -0
- package/dist/elements/elements/AirMatrixElement.d.ts +14 -0
- package/dist/elements/elements/AirMatrixElement.js +83 -0
- package/dist/elements/elements/CurrentConditionsElement.d.ts +9 -0
- package/dist/elements/elements/CurrentConditionsElement.js +52 -0
- package/dist/elements/elements/DailyPatternElement.d.ts +15 -0
- package/dist/elements/elements/DailyPatternElement.js +200 -0
- package/dist/elements/elements/DialElement.d.ts +9 -0
- package/dist/elements/elements/DialElement.js +128 -0
- package/dist/elements/elements/FreshnessBadgeElement.d.ts +8 -0
- package/dist/elements/elements/FreshnessBadgeElement.js +22 -0
- package/dist/elements/elements/SparklineElement.d.ts +9 -0
- package/dist/elements/elements/SparklineElement.js +74 -0
- package/dist/elements/elements/StationCardElement.d.ts +53 -0
- package/dist/elements/elements/StationCardElement.js +211 -0
- package/dist/elements/elements/StationFeedElement.d.ts +32 -0
- package/dist/elements/elements/StationFeedElement.js +215 -0
- package/dist/elements/elements/StationStripElement.d.ts +9 -0
- package/dist/elements/elements/StationStripElement.js +43 -0
- package/dist/elements/elements/StationTableElement.d.ts +18 -0
- package/dist/elements/elements/StationTableElement.js +102 -0
- package/dist/elements/elements/TrendChartElement.d.ts +10 -0
- package/dist/elements/elements/TrendChartElement.js +174 -0
- package/dist/elements/elements/WindArrowElement.d.ts +8 -0
- package/dist/elements/elements/WindArrowElement.js +14 -0
- package/dist/elements/elements/WindHistoryChartElement.d.ts +10 -0
- package/dist/elements/elements/WindHistoryChartElement.js +277 -0
- package/dist/elements/elements/WindRoseElement.d.ts +17 -0
- package/dist/elements/elements/WindRoseElement.js +106 -0
- package/dist/elements/elements/atoms.d.ts +48 -0
- package/dist/elements/elements/atoms.js +131 -0
- package/dist/elements/index.d.ts +48 -0
- package/dist/elements/index.js +57 -0
- package/dist/elements/lib/ambient.d.ts +15 -0
- package/dist/elements/lib/ambient.js +5 -0
- package/dist/elements/lib/attributes.js +21 -0
- package/dist/elements/lib/base.d.ts +45 -0
- package/dist/elements/lib/base.js +152 -0
- package/dist/elements/lib/context.js +28 -0
- package/dist/elements/lib/fragments.js +45 -0
- package/dist/elements/lib/h.js +35 -0
- package/dist/elements/register.d.ts +1 -0
- package/dist/elements/register.js +5 -0
- package/dist/endpoints.d.ts +5 -0
- package/dist/endpoints.js +10 -0
- package/dist/fixtures.d.ts +23 -0
- package/dist/fixtures.js +67 -0
- package/dist/format.d.ts +31 -0
- package/dist/format.js +82 -0
- package/dist/geometry.d.ts +84 -0
- package/dist/geometry.js +333 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/instruments.d.ts +75 -0
- package/dist/instruments.js +173 -0
- package/dist/merge-current.d.ts +13 -0
- package/dist/merge-current.js +54 -0
- package/dist/react/components/AirMatrix.d.ts +11 -0
- package/dist/react/components/AirMatrix.js +82 -0
- package/dist/react/components/CurrentConditions.d.ts +17 -0
- package/dist/react/components/CurrentConditions.js +98 -0
- package/dist/react/components/DailyPattern.d.ts +19 -0
- package/dist/react/components/DailyPattern.js +212 -0
- package/dist/react/components/Dial.d.ts +17 -0
- package/dist/react/components/Dial.js +133 -0
- package/dist/react/components/FreshnessBadge.d.ts +10 -0
- package/dist/react/components/FreshnessBadge.js +20 -0
- package/dist/react/components/Sparkline.d.ts +17 -0
- package/dist/react/components/Sparkline.js +60 -0
- package/dist/react/components/StationCard.d.ts +46 -0
- package/dist/react/components/StationCard.js +140 -0
- package/dist/react/components/StationFeedProvider.d.ts +27 -0
- package/dist/react/components/StationFeedProvider.js +40 -0
- package/dist/react/components/StationStrip.d.ts +16 -0
- package/dist/react/components/StationStrip.js +84 -0
- package/dist/react/components/StationTable.d.ts +18 -0
- package/dist/react/components/StationTable.js +115 -0
- package/dist/react/components/TrendChart.d.ts +14 -0
- package/dist/react/components/TrendChart.js +150 -0
- package/dist/react/components/WindArrow.d.ts +7 -0
- package/dist/react/components/WindArrow.js +21 -0
- package/dist/react/components/WindHistoryChart.d.ts +18 -0
- package/dist/react/components/WindHistoryChart.js +278 -0
- package/dist/react/components/WindRose.d.ts +17 -0
- package/dist/react/components/WindRose.js +99 -0
- package/dist/react/components/atoms.d.ts +33 -0
- package/dist/react/components/atoms.js +136 -0
- package/dist/react/hooks/useFreshness.d.ts +6 -0
- package/dist/react/hooks/useFreshness.js +21 -0
- package/dist/react/hooks/usePolledJson.js +17 -0
- package/dist/react/hooks/useStation.d.ts +23 -0
- package/dist/react/hooks/useStation.js +42 -0
- package/dist/react/hooks/useStationCurrent.d.ts +23 -0
- package/dist/react/hooks/useStationCurrent.js +32 -0
- package/dist/react/hooks/useStationFeed.d.ts +22 -0
- package/dist/react/hooks/useStationFeed.js +28 -0
- package/dist/react/index.d.ts +20 -0
- package/dist/react/index.js +21 -0
- package/dist/react/lib/cells.js +29 -0
- package/dist/scene/air-matrix.js +71 -0
- package/dist/scene/atoms.js +102 -0
- package/dist/scene/card.js +54 -0
- package/dist/scene/chart.js +28 -0
- package/dist/scene/current.js +66 -0
- package/dist/scene/daily-pattern.js +81 -0
- package/dist/scene/dial.js +141 -0
- package/dist/scene/glyphs.js +24 -0
- package/dist/scene/rose.js +120 -0
- package/dist/scene/sparkline.js +73 -0
- package/dist/scene/strip.js +63 -0
- package/dist/scene/table.js +76 -0
- package/dist/scene/trend.js +160 -0
- package/dist/scene/wind-history.js +148 -0
- package/dist/scene/wind-plot.js +214 -0
- package/dist/server/adapter.d.ts +28 -0
- package/dist/server/adapter.js +32 -0
- package/dist/server/adapters/campbell.d.ts +112 -0
- package/dist/server/adapters/campbell.js +414 -0
- package/dist/server/adapters/tempest.d.ts +27 -0
- package/dist/server/adapters/tempest.js +137 -0
- package/dist/server/adapters/windnerd.d.ts +39 -0
- package/dist/server/adapters/windnerd.js +159 -0
- package/dist/server/config.d.ts +135 -0
- package/dist/server/config.js +57 -0
- package/dist/server/environment.d.ts +48 -0
- package/dist/server/environment.js +128 -0
- package/dist/server/feed.d.ts +31 -0
- package/dist/server/feed.js +216 -0
- package/dist/server/handler.d.ts +17 -0
- package/dist/server/handler.js +133 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.js +10 -0
- package/dist/strings.d.ts +118 -0
- package/dist/strings.js +237 -0
- package/dist/windnerd.d.ts +5 -0
- package/dist/windnerd.js +25 -0
- package/package.json +97 -0
- package/schema/README.md +14 -0
- package/schema/example-current.json +48 -0
- package/schema/example-feed.json +147 -0
- package/schema/stationcurrent.schema.json +641 -0
- package/schema/stationfeed.schema.json +656 -0
- package/styles.css +1141 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { emptyConditions } from "../../contract.js";
|
|
2
|
+
import { isCalm, normalizeDegrees, pressureTendency, seaLevelPressureHpa } from "../../derive.js";
|
|
3
|
+
import { windnerdStationUrl } from "../../windnerd.js";
|
|
4
|
+
import { fetchUpstreamText } from "../environment.js";
|
|
5
|
+
import { defineStationAdapter } from "../adapter.js";
|
|
6
|
+
import { kmhToMps } from "@azohra/meteo.core";
|
|
7
|
+
//#region src/server/adapters/windnerd.ts
|
|
8
|
+
const WINDNERD_RECORDS_URL = "https://windnerd.net/api/records";
|
|
9
|
+
const RECORD_PERIOD_MINUTES = 1;
|
|
10
|
+
const WINDNERD_RECORD_PERIODS_MINUTES = [
|
|
11
|
+
1,
|
|
12
|
+
15,
|
|
13
|
+
60,
|
|
14
|
+
180
|
|
15
|
+
];
|
|
16
|
+
const CACHE_TTL_SECONDS = 60;
|
|
17
|
+
const AGGREGATE_CACHE_TTL_SECONDS = 900;
|
|
18
|
+
const SENSOR_VALUE_LOOKBACK_MS = 15 * 6e4;
|
|
19
|
+
const STATION_PRESSURE_MIN_HPA = 300;
|
|
20
|
+
const STATION_PRESSURE_MAX_HPA = 1100;
|
|
21
|
+
const UTC_OFFSET_MIN_MINUTES = -720;
|
|
22
|
+
const UTC_OFFSET_MAX_MINUTES = 840;
|
|
23
|
+
const loadWindnerdStation = defineStationAdapter({
|
|
24
|
+
meta: (config) => ({
|
|
25
|
+
id: config.id,
|
|
26
|
+
name: config.name,
|
|
27
|
+
sourceLabel: "WindNerd",
|
|
28
|
+
pageUrl: config.pageUrl ?? windnerdStationUrl(config.stationKey),
|
|
29
|
+
latitude: config.latitude ?? null,
|
|
30
|
+
longitude: config.longitude ?? null,
|
|
31
|
+
timeZone: config.timeZone ?? null,
|
|
32
|
+
elevationM: config.elevationM ?? null,
|
|
33
|
+
capabilities: {
|
|
34
|
+
gustLull: true,
|
|
35
|
+
temperature: config.hasTemperature,
|
|
36
|
+
conditions: config.hasPressure,
|
|
37
|
+
history: true
|
|
38
|
+
},
|
|
39
|
+
samplingWindowSeconds: 60,
|
|
40
|
+
recommendedPollSeconds: 60
|
|
41
|
+
}),
|
|
42
|
+
load: async (config, { environment, historyHours, options }) => {
|
|
43
|
+
const periodMinutes = options.recordPeriodMinutes ?? RECORD_PERIOD_MINUTES;
|
|
44
|
+
if (!WINDNERD_RECORD_PERIODS_MINUTES.includes(periodMinutes)) throw new Error(`WindNerd location ${config.locationId}: recordPeriodMinutes must be one of ${WINDNERD_RECORD_PERIODS_MINUTES.join(", ")}, got ${periodMinutes}`);
|
|
45
|
+
const now = environment.now();
|
|
46
|
+
const url = new URL(options.recordsUrl ?? WINDNERD_RECORDS_URL);
|
|
47
|
+
url.searchParams.set("location_id", String(config.locationId));
|
|
48
|
+
url.searchParams.set("from", (/* @__PURE__ */ new Date(now.getTime() - historyHours * 36e5)).toISOString());
|
|
49
|
+
url.searchParams.set("to", now.toISOString());
|
|
50
|
+
url.searchParams.set("period", String(periodMinutes));
|
|
51
|
+
const records = parseWindnerdRecords(await fetchUpstreamText(environment, {
|
|
52
|
+
url,
|
|
53
|
+
cacheKey: `windnerd/${config.locationId}/${historyHours}/${periodMinutes}`,
|
|
54
|
+
cacheTtlSeconds: options.cacheTtlSeconds ?? (periodMinutes === RECORD_PERIOD_MINUTES ? CACHE_TTL_SECONDS : AGGREGATE_CACHE_TTL_SECONDS),
|
|
55
|
+
subject: `WindNerd location ${config.locationId}`
|
|
56
|
+
}), config.locationId, config.hasPressure);
|
|
57
|
+
const points = windnerdHistoryPoints(records, config);
|
|
58
|
+
const last = points[points.length - 1];
|
|
59
|
+
if (!last) throw new Error(`WindNerd location ${config.locationId} returned no wind`);
|
|
60
|
+
const lastMs = Date.parse(last.observedAt);
|
|
61
|
+
return {
|
|
62
|
+
reading: {
|
|
63
|
+
observedAt: last.observedAt,
|
|
64
|
+
windAvgMps: last.windAvgMps,
|
|
65
|
+
windDirectionDeg: last.windDirectionDeg,
|
|
66
|
+
windGustMps: last.windGustMps,
|
|
67
|
+
windLullMps: last.windLullMps,
|
|
68
|
+
temperatureC: config.hasTemperature ? latestSensorValue(records.temperatureC, records.observedAt, lastMs)?.value ?? null : null,
|
|
69
|
+
windChillC: null,
|
|
70
|
+
conditions: config.hasPressure ? windnerdConditions(records, points, config, lastMs) : null
|
|
71
|
+
},
|
|
72
|
+
history: {
|
|
73
|
+
periodMinutes,
|
|
74
|
+
points
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
function windnerdHistoryPoints(records, config) {
|
|
80
|
+
const barometerElevationM = config.hasPressure ? config.elevationM ?? null : null;
|
|
81
|
+
return records.observedAt.map((observedAt, index) => {
|
|
82
|
+
const windAvgMps = kmhToMps(records.averageSpeedKmh[index]);
|
|
83
|
+
const stationPressure = records.stationPressureHpa[index] ?? null;
|
|
84
|
+
return {
|
|
85
|
+
observedAt,
|
|
86
|
+
windAvgMps,
|
|
87
|
+
windGustMps: kmhToMps(records.gustSpeedKmh[index]),
|
|
88
|
+
windLullMps: kmhToMps(records.lullSpeedKmh[index]),
|
|
89
|
+
windDirectionDeg: isCalm(windAvgMps) ? null : normalizeDegrees(records.windDirectionDeg[index]),
|
|
90
|
+
temperatureC: config.hasTemperature ? records.temperatureC[index] ?? null : null,
|
|
91
|
+
seaLevelPressureHpa: barometerElevationM != null && stationPressure != null ? seaLevelPressureHpa(stationPressure, barometerElevationM, records.temperatureC[index] ?? null) : null
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function windnerdConditions(records, points, config, readingObservedAtMs) {
|
|
96
|
+
const fresh = latestSensorValue(records.stationPressureHpa, records.observedAt, readingObservedAtMs);
|
|
97
|
+
const reduced = fresh != null && config.elevationM != null ? seaLevelPressureHpa(fresh.value, config.elevationM, records.temperatureC[fresh.index] ?? null) : null;
|
|
98
|
+
return emptyConditions({
|
|
99
|
+
pressureTrend: pressureTendency(points),
|
|
100
|
+
seaLevelPressureHpa: reduced
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function parseWindnerdRecords(value, locationId, hasPressure = false) {
|
|
104
|
+
const data = JSON.parse(value);
|
|
105
|
+
if (!isRecord(data) || !isRecord(data.records)) throw new Error(`WindNerd location ${locationId} returned no records`);
|
|
106
|
+
const { records } = data;
|
|
107
|
+
const dates = records.date_utc;
|
|
108
|
+
if (!Array.isArray(dates) || dates.some((date) => typeof date !== "string")) throw new Error(`WindNerd location ${locationId} returned invalid record times`);
|
|
109
|
+
const fail = (name) => {
|
|
110
|
+
throw new Error(`WindNerd location ${locationId} returned an invalid ${name}`);
|
|
111
|
+
};
|
|
112
|
+
const speeds = (name) => numberSeries(records[name], dates.length, 0, 500, name, fail);
|
|
113
|
+
return {
|
|
114
|
+
averageSpeedKmh: speeds("wind_avg_1D"),
|
|
115
|
+
windDirectionDeg: numberSeries(records.wind_dir, dates.length, 0, 360, "wind_dir", fail),
|
|
116
|
+
gustSpeedKmh: speeds("wind_max"),
|
|
117
|
+
lullSpeedKmh: speeds("wind_min"),
|
|
118
|
+
observedAt: dates.map((date) => recordTimeToIso(date, locationId)),
|
|
119
|
+
temperatureC: nullableSeries(records.temperature_avg, dates.length, "temperature_avg", fail),
|
|
120
|
+
stationPressureHpa: hasPressure ? nullableSeries(records.pressure_hpa_avg, dates.length, "pressure_hpa_avg", fail, STATION_PRESSURE_MIN_HPA, STATION_PRESSURE_MAX_HPA) : dates.map(() => null),
|
|
121
|
+
utcOffsetMinutes: parseUtcOffsetMinutes(records.time_offset, locationId)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function parseUtcOffsetMinutes(value, locationId) {
|
|
125
|
+
if (!Array.isArray(value)) return null;
|
|
126
|
+
const first = value.find((entry) => typeof entry === "number" && Number.isFinite(entry));
|
|
127
|
+
if (first == null) return null;
|
|
128
|
+
if (first < UTC_OFFSET_MIN_MINUTES || first > UTC_OFFSET_MAX_MINUTES) throw new Error(`WindNerd location ${locationId} returned an invalid time_offset`);
|
|
129
|
+
return first;
|
|
130
|
+
}
|
|
131
|
+
function latestSensorValue(series, observedAt, readingObservedAtMs) {
|
|
132
|
+
for (let index = series.length - 1; index >= 0; index -= 1) {
|
|
133
|
+
const value = series[index];
|
|
134
|
+
if (value == null) continue;
|
|
135
|
+
return readingObservedAtMs - Date.parse(observedAt[index]) <= SENSOR_VALUE_LOOKBACK_MS ? {
|
|
136
|
+
value,
|
|
137
|
+
index
|
|
138
|
+
} : null;
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
function numberSeries(value, length, minimum, maximum, name, fail) {
|
|
143
|
+
if (!Array.isArray(value) || value.length !== length || value.some((entry) => typeof entry !== "number" || !Number.isFinite(entry) || entry < minimum || entry > maximum)) fail(name);
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
function nullableSeries(value, length, name, fail, minimum = -Infinity, maximum = Infinity) {
|
|
147
|
+
if (!Array.isArray(value) || value.length !== length || value.some((entry) => entry != null && (typeof entry !== "number" || !Number.isFinite(entry) || entry < minimum || entry > maximum))) fail(name);
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
function recordTimeToIso(value, locationId) {
|
|
151
|
+
const parsed = Date.parse(value);
|
|
152
|
+
if (!Number.isFinite(parsed)) throw new Error(`WindNerd location ${locationId} returned an invalid record time`);
|
|
153
|
+
return new Date(parsed).toISOString();
|
|
154
|
+
}
|
|
155
|
+
function isRecord(value) {
|
|
156
|
+
return typeof value === "object" && value !== null;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { WINDNERD_RECORD_PERIODS_MINUTES, loadWindnerdStation, parseWindnerdRecords, windnerdHistoryPoints };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Station } from "../contract.js";
|
|
2
|
+
import { normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
3
|
+
import { ResolvedEnvironment } from "./environment.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/server/config.d.ts
|
|
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
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
14
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
15
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
vendor: z.ZodLiteral<"windnerd">;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
type WindnerdStationConfig = z.output<typeof windnerdStationConfigSchema>;
|
|
21
|
+
declare const tempestStationConfigSchema: z.ZodObject<{
|
|
22
|
+
stationId: z.ZodNumber;
|
|
23
|
+
token: z.ZodString;
|
|
24
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
27
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
vendor: z.ZodLiteral<"tempest">;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
type TempestStationConfig = z.output<typeof tempestStationConfigSchema>;
|
|
34
|
+
declare const campbellStationConfigSchema: z.ZodObject<{
|
|
35
|
+
baseUrl: z.ZodString;
|
|
36
|
+
source: z.ZodString;
|
|
37
|
+
timeZone: z.ZodString;
|
|
38
|
+
currentTable: z.ZodDefault<z.ZodString>;
|
|
39
|
+
historyTable: z.ZodDefault<z.ZodString>;
|
|
40
|
+
currentIntervalSeconds: z.ZodDefault<z.ZodNumber>;
|
|
41
|
+
historyPeriodMinutes: z.ZodDefault<z.ZodNumber>;
|
|
42
|
+
currentCacheTtlSeconds: z.ZodDefault<z.ZodNumber>;
|
|
43
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
46
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
vendor: z.ZodLiteral<"campbell">;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
type CampbellStationConfig = z.output<typeof campbellStationConfigSchema>;
|
|
52
|
+
type CustomStationIdentity = {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly elevationM: number | null;
|
|
56
|
+
readonly latitude: number | null;
|
|
57
|
+
readonly longitude: number | null;
|
|
58
|
+
readonly timeZone: string | null;
|
|
59
|
+
readonly pageUrl: string | null;
|
|
60
|
+
};
|
|
61
|
+
type CustomStationContext = {
|
|
62
|
+
environment: ResolvedEnvironment;
|
|
63
|
+
historyHours: number;
|
|
64
|
+
mode: "full" | "current";
|
|
65
|
+
station: CustomStationIdentity;
|
|
66
|
+
};
|
|
67
|
+
type CustomStationLoader = (context: CustomStationContext) => Promise<Station>;
|
|
68
|
+
declare const customStationConfigSchema: z.ZodObject<{
|
|
69
|
+
load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
|
|
70
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
72
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
73
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
74
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
vendor: z.ZodLiteral<"custom">;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
type CustomStationConfig = z.output<typeof customStationConfigSchema>;
|
|
80
|
+
declare const stationConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
81
|
+
stationKey: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
82
|
+
locationId: z.ZodNumber;
|
|
83
|
+
hasTemperature: z.ZodDefault<z.ZodBoolean>;
|
|
84
|
+
hasPressure: z.ZodDefault<z.ZodBoolean>;
|
|
85
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
86
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
87
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
88
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
89
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
90
|
+
id: z.ZodString;
|
|
91
|
+
name: z.ZodString;
|
|
92
|
+
vendor: z.ZodLiteral<"windnerd">;
|
|
93
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
94
|
+
stationId: z.ZodNumber;
|
|
95
|
+
token: z.ZodString;
|
|
96
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
97
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
99
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
100
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
101
|
+
id: z.ZodString;
|
|
102
|
+
name: z.ZodString;
|
|
103
|
+
vendor: z.ZodLiteral<"tempest">;
|
|
104
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
105
|
+
baseUrl: z.ZodString;
|
|
106
|
+
source: z.ZodString;
|
|
107
|
+
timeZone: z.ZodString;
|
|
108
|
+
currentTable: z.ZodDefault<z.ZodString>;
|
|
109
|
+
historyTable: z.ZodDefault<z.ZodString>;
|
|
110
|
+
currentIntervalSeconds: z.ZodDefault<z.ZodNumber>;
|
|
111
|
+
historyPeriodMinutes: z.ZodDefault<z.ZodNumber>;
|
|
112
|
+
currentCacheTtlSeconds: z.ZodDefault<z.ZodNumber>;
|
|
113
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
115
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
116
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
117
|
+
id: z.ZodString;
|
|
118
|
+
name: z.ZodString;
|
|
119
|
+
vendor: z.ZodLiteral<"campbell">;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
121
|
+
load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
|
|
122
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
123
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
124
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
125
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
126
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
name: z.ZodString;
|
|
129
|
+
vendor: z.ZodLiteral<"custom">;
|
|
130
|
+
}, z.core.$strict>], "vendor">;
|
|
131
|
+
type StationConfig = z.output<typeof stationConfigSchema>;
|
|
132
|
+
type StationConfigInput = z.input<typeof stationConfigSchema>;
|
|
133
|
+
declare function parseStationConfig(value: unknown): StationConfig;
|
|
134
|
+
//#endregion
|
|
135
|
+
export { CampbellStationConfig, CustomStationConfig, CustomStationContext, CustomStationIdentity, CustomStationLoader, StationConfig, StationConfigInput, TempestStationConfig, WindnerdStationConfig, campbellStationConfigSchema, customStationConfigSchema, normalizeWindnerdStationKey, parseStationConfig, stationConfigSchema, tempestStationConfigSchema, windnerdStationConfigSchema, windnerdStationUrl };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { httpUrl, ianaTimeZone, positionFields } from "@azohra/meteo.core";
|
|
4
|
+
//#region src/server/config.ts
|
|
5
|
+
const windnerdStationKey = z.string().refine((value) => normalizeWindnerdStationKey(value) != null, { message: "not a WindNerd station key or windnerd.net station URL" }).transform((value) => normalizeWindnerdStationKey(value));
|
|
6
|
+
const stationIdentity = {
|
|
7
|
+
id: z.string().min(1),
|
|
8
|
+
name: z.string().min(1),
|
|
9
|
+
...positionFields,
|
|
10
|
+
timeZone: ianaTimeZone.nullish(),
|
|
11
|
+
pageUrl: httpUrl.nullish()
|
|
12
|
+
};
|
|
13
|
+
const windnerdStationConfigSchema = z.strictObject({
|
|
14
|
+
vendor: z.literal("windnerd"),
|
|
15
|
+
...stationIdentity,
|
|
16
|
+
stationKey: windnerdStationKey,
|
|
17
|
+
locationId: z.number().int().positive(),
|
|
18
|
+
hasTemperature: z.boolean().default(true),
|
|
19
|
+
hasPressure: z.boolean().default(false)
|
|
20
|
+
}).refine((config) => !config.hasPressure || config.elevationM != null, {
|
|
21
|
+
message: "pressure needs the sensor's elevation to reduce to sea level — set elevationM to the sensor's elevation, not the launch's",
|
|
22
|
+
path: ["elevationM"]
|
|
23
|
+
});
|
|
24
|
+
const tempestStationConfigSchema = z.strictObject({
|
|
25
|
+
vendor: z.literal("tempest"),
|
|
26
|
+
...stationIdentity,
|
|
27
|
+
stationId: z.number().int().positive(),
|
|
28
|
+
token: z.string().min(1)
|
|
29
|
+
});
|
|
30
|
+
const campbellStationConfigSchema = z.strictObject({
|
|
31
|
+
vendor: z.literal("campbell"),
|
|
32
|
+
...stationIdentity,
|
|
33
|
+
baseUrl: httpUrl,
|
|
34
|
+
source: z.string().min(1),
|
|
35
|
+
timeZone: ianaTimeZone,
|
|
36
|
+
currentTable: z.string().min(1).default("I3Sec"),
|
|
37
|
+
historyTable: z.string().min(1).default("I5Min"),
|
|
38
|
+
currentIntervalSeconds: z.number().finite().positive().default(3),
|
|
39
|
+
historyPeriodMinutes: z.number().finite().positive().default(5),
|
|
40
|
+
currentCacheTtlSeconds: z.number().finite().min(3).default(15)
|
|
41
|
+
});
|
|
42
|
+
const customStationConfigSchema = z.strictObject({
|
|
43
|
+
vendor: z.literal("custom"),
|
|
44
|
+
...stationIdentity,
|
|
45
|
+
load: z.custom((value) => typeof value === "function", { message: "load must be a function returning Promise<Station>" })
|
|
46
|
+
});
|
|
47
|
+
const stationConfigSchema = z.discriminatedUnion("vendor", [
|
|
48
|
+
windnerdStationConfigSchema,
|
|
49
|
+
tempestStationConfigSchema,
|
|
50
|
+
campbellStationConfigSchema,
|
|
51
|
+
customStationConfigSchema
|
|
52
|
+
]);
|
|
53
|
+
function parseStationConfig(value) {
|
|
54
|
+
return stationConfigSchema.parse(value);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { campbellStationConfigSchema, customStationConfigSchema, normalizeWindnerdStationKey, parseStationConfig, stationConfigSchema, tempestStationConfigSchema, windnerdStationConfigSchema, windnerdStationUrl };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { UPSTREAM_FAILURE_REASONS as UPSTREAM_FAILURE_REASONS$1, UpstreamError, UpstreamErrorReason, UpstreamFailureReason, unavailableReasonForError } from "@azohra/meteo.core";
|
|
2
|
+
//#region src/server/environment.d.ts
|
|
3
|
+
type FeedCache = {
|
|
4
|
+
get(key: string): Promise<string | null>;
|
|
5
|
+
put(key: string, value: string, ttlSeconds: number): Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
type LogEventCode = "config_invalid" | "duplicate_station" | "upstream_failure" | "adapter_threw" | "custom_contract_break" | "clock_skew" | "resolver_invalid";
|
|
8
|
+
type LogEvent = {
|
|
9
|
+
level: "warn" | "error";
|
|
10
|
+
code: LogEventCode;
|
|
11
|
+
message: string;
|
|
12
|
+
detail?: unknown;
|
|
13
|
+
};
|
|
14
|
+
type ServerEnvironment = {
|
|
15
|
+
fetch?: typeof fetch;
|
|
16
|
+
cache?: FeedCache;
|
|
17
|
+
logger?: (event: LogEvent) => void;
|
|
18
|
+
userAgent?: string;
|
|
19
|
+
now?: () => Date;
|
|
20
|
+
};
|
|
21
|
+
type ResolvedEnvironment = Required<ServerEnvironment>;
|
|
22
|
+
declare const UPSTREAM_FETCH_TIMEOUT_MS = 4000;
|
|
23
|
+
declare const UPSTREAM_RESPONSE_LIMIT_BYTES = 524288;
|
|
24
|
+
declare function memoryCache(): FeedCache;
|
|
25
|
+
declare const DEFAULT_USER_AGENT = "azohra-meteo/0.1 (+https://meteo.azohra.com)";
|
|
26
|
+
declare function resolveEnvironment(environment?: ServerEnvironment): ResolvedEnvironment;
|
|
27
|
+
type UpstreamTextRequest = {
|
|
28
|
+
url: string | URL;
|
|
29
|
+
cacheKey: string;
|
|
30
|
+
cacheTtlSeconds: number;
|
|
31
|
+
subject: string;
|
|
32
|
+
accept?: string;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
method?: string;
|
|
35
|
+
body?: BodyInit;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
limitBytes?: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The one road to an upstream: cache lookup, bounded fetch under a timeout,
|
|
41
|
+
* cache fill. Concurrent misses on the same (cache instance, cacheKey)
|
|
42
|
+
* coalesce onto a single in-flight load.
|
|
43
|
+
*/
|
|
44
|
+
declare function fetchUpstreamText(environment: ResolvedEnvironment, request: UpstreamTextRequest): Promise<string>;
|
|
45
|
+
declare function boundedResponseText(response: Response, limitBytes: number, subject: string): Promise<string>;
|
|
46
|
+
declare function logUpstreamFailure(environment: ResolvedEnvironment, message: string, error: unknown, detail?: Record<string, unknown>): void;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { DEFAULT_USER_AGENT, FeedCache, LogEvent, LogEventCode, ResolvedEnvironment, ServerEnvironment, UPSTREAM_FAILURE_REASONS$1 as UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UpstreamError, type UpstreamErrorReason, type UpstreamFailureReason, UpstreamTextRequest, boundedResponseText, fetchUpstreamText, logUpstreamFailure, memoryCache, resolveEnvironment, unavailableReasonForError };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { UPSTREAM_FAILURE_REASONS as UPSTREAM_FAILURE_REASONS$1, UpstreamError, unavailableReasonForError } from "@azohra/meteo.core";
|
|
2
|
+
//#region src/server/environment.ts
|
|
3
|
+
const UPSTREAM_FETCH_TIMEOUT_MS = 4e3;
|
|
4
|
+
const UPSTREAM_RESPONSE_LIMIT_BYTES = 524288;
|
|
5
|
+
const MEMORY_CACHE_MAX_ENTRIES = 500;
|
|
6
|
+
function memoryCache() {
|
|
7
|
+
const entries = /* @__PURE__ */ new Map();
|
|
8
|
+
return {
|
|
9
|
+
async get(key) {
|
|
10
|
+
const entry = entries.get(key);
|
|
11
|
+
if (!entry) return null;
|
|
12
|
+
if (Date.now() >= entry.expiresAtMs) {
|
|
13
|
+
entries.delete(key);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return entry.value;
|
|
17
|
+
},
|
|
18
|
+
async put(key, value, ttlSeconds) {
|
|
19
|
+
entries.delete(key);
|
|
20
|
+
entries.set(key, {
|
|
21
|
+
value,
|
|
22
|
+
expiresAtMs: Date.now() + ttlSeconds * 1e3
|
|
23
|
+
});
|
|
24
|
+
while (entries.size > MEMORY_CACHE_MAX_ENTRIES) {
|
|
25
|
+
const oldest = entries.keys().next().value;
|
|
26
|
+
if (oldest === void 0) break;
|
|
27
|
+
entries.delete(oldest);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const sharedDefaultCache = memoryCache();
|
|
33
|
+
function consoleLogger(event) {
|
|
34
|
+
const log = event.level === "warn" ? console.warn : console.error;
|
|
35
|
+
if (event.detail === void 0) log(`[azohra-meteo] ${event.message}`);
|
|
36
|
+
else log(`[azohra-meteo] ${event.message}`, event.detail);
|
|
37
|
+
}
|
|
38
|
+
const DEFAULT_USER_AGENT = "azohra-meteo/0.1 (+https://meteo.azohra.com)";
|
|
39
|
+
function resolveEnvironment(environment = {}) {
|
|
40
|
+
return {
|
|
41
|
+
fetch: environment.fetch ?? globalThis.fetch.bind(globalThis),
|
|
42
|
+
cache: environment.cache ?? sharedDefaultCache,
|
|
43
|
+
logger: environment.logger ?? consoleLogger,
|
|
44
|
+
userAgent: environment.userAgent ?? "azohra-meteo/0.1 (+https://meteo.azohra.com)",
|
|
45
|
+
now: environment.now ?? (() => /* @__PURE__ */ new Date())
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const inFlightLoads = /* @__PURE__ */ new WeakMap();
|
|
49
|
+
/**
|
|
50
|
+
* The one road to an upstream: cache lookup, bounded fetch under a timeout,
|
|
51
|
+
* cache fill. Concurrent misses on the same (cache instance, cacheKey)
|
|
52
|
+
* coalesce onto a single in-flight load.
|
|
53
|
+
*/
|
|
54
|
+
async function fetchUpstreamText(environment, request) {
|
|
55
|
+
const cached = await environment.cache.get(request.cacheKey);
|
|
56
|
+
if (cached != null) return cached;
|
|
57
|
+
let pending = inFlightLoads.get(environment.cache);
|
|
58
|
+
if (!pending) {
|
|
59
|
+
pending = /* @__PURE__ */ new Map();
|
|
60
|
+
inFlightLoads.set(environment.cache, pending);
|
|
61
|
+
}
|
|
62
|
+
const inFlight = pending.get(request.cacheKey);
|
|
63
|
+
if (inFlight) return inFlight;
|
|
64
|
+
const settled = pending;
|
|
65
|
+
const load = loadUpstreamText(environment, request).finally(() => {
|
|
66
|
+
settled.delete(request.cacheKey);
|
|
67
|
+
});
|
|
68
|
+
pending.set(request.cacheKey, load);
|
|
69
|
+
return load;
|
|
70
|
+
}
|
|
71
|
+
async function loadUpstreamText(environment, request) {
|
|
72
|
+
let response;
|
|
73
|
+
try {
|
|
74
|
+
response = await environment.fetch(request.url, {
|
|
75
|
+
method: request.method,
|
|
76
|
+
body: request.body,
|
|
77
|
+
headers: {
|
|
78
|
+
Accept: request.accept ?? "application/json",
|
|
79
|
+
"User-Agent": environment.userAgent,
|
|
80
|
+
...request.headers
|
|
81
|
+
},
|
|
82
|
+
signal: AbortSignal.timeout(request.timeoutMs ?? 4e3)
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) throw new UpstreamError(`${request.subject} timed out`, "timeout");
|
|
86
|
+
throw new UpstreamError(`${request.subject} could not be reached: ${error instanceof Error ? error.message : String(error)}`);
|
|
87
|
+
}
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
try {
|
|
90
|
+
await response.body?.cancel();
|
|
91
|
+
} catch {}
|
|
92
|
+
if (response.status === 429) throw new UpstreamError(`${request.subject} is rate limiting requests`, "rate_limited");
|
|
93
|
+
throw new UpstreamError(`${request.subject} returned ${response.status}`);
|
|
94
|
+
}
|
|
95
|
+
const text = await boundedResponseText(response, request.limitBytes ?? 524288, request.subject);
|
|
96
|
+
await environment.cache.put(request.cacheKey, text, request.cacheTtlSeconds);
|
|
97
|
+
return text;
|
|
98
|
+
}
|
|
99
|
+
async function boundedResponseText(response, limitBytes, subject) {
|
|
100
|
+
const reader = response.body?.getReader();
|
|
101
|
+
if (!reader) throw new UpstreamError(`${subject} returned no body`);
|
|
102
|
+
const decoder = new TextDecoder();
|
|
103
|
+
let result = "";
|
|
104
|
+
let totalBytes = 0;
|
|
105
|
+
while (true) {
|
|
106
|
+
const { done, value } = await reader.read();
|
|
107
|
+
if (done) return result + decoder.decode();
|
|
108
|
+
totalBytes += value.byteLength;
|
|
109
|
+
if (totalBytes > limitBytes) {
|
|
110
|
+
await reader.cancel();
|
|
111
|
+
throw new UpstreamError(`${subject} exceeded the response limit`);
|
|
112
|
+
}
|
|
113
|
+
result += decoder.decode(value, { stream: true });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function logUpstreamFailure(environment, message, error, detail = {}) {
|
|
117
|
+
environment.logger({
|
|
118
|
+
level: "error",
|
|
119
|
+
code: "upstream_failure",
|
|
120
|
+
message,
|
|
121
|
+
detail: {
|
|
122
|
+
error: error instanceof Error ? error.message : String(error),
|
|
123
|
+
...detail
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { DEFAULT_USER_AGENT, UPSTREAM_FAILURE_REASONS$1 as UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UpstreamError, boundedResponseText, fetchUpstreamText, logUpstreamFailure, memoryCache, resolveEnvironment, unavailableReasonForError };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Station, StationCurrent, StationFeed } from "../contract.js";
|
|
2
|
+
import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
|
|
3
|
+
import { StationConfig, StationConfigInput } from "./config.js";
|
|
4
|
+
//#region src/server/feed.d.ts
|
|
5
|
+
declare const DEFAULT_HISTORY_HOURS = 6;
|
|
6
|
+
type StationsResolver = (request?: Request) => Promise<StationConfigInput[]> | StationConfigInput[];
|
|
7
|
+
type StationsInput = StationConfigInput[] | StationsResolver;
|
|
8
|
+
type LoadStationFeedOptions = {
|
|
9
|
+
stations: StationsInput;
|
|
10
|
+
primaryStationId?: string;
|
|
11
|
+
historyHours?: number;
|
|
12
|
+
maxHistoryHours?: number;
|
|
13
|
+
environment?: ServerEnvironment;
|
|
14
|
+
request?: Request;
|
|
15
|
+
};
|
|
16
|
+
type LoadStationCurrentOptions = LoadStationFeedOptions & {
|
|
17
|
+
stationId: string;
|
|
18
|
+
};
|
|
19
|
+
declare class UnknownStationError extends Error {
|
|
20
|
+
constructor(stationId: string);
|
|
21
|
+
}
|
|
22
|
+
declare function loadStationFeed(options: LoadStationFeedOptions): Promise<StationFeed>;
|
|
23
|
+
declare function loadStationCurrent(options: LoadStationCurrentOptions): Promise<StationCurrent>;
|
|
24
|
+
type AssembledStation = {
|
|
25
|
+
config: StationConfig;
|
|
26
|
+
} | {
|
|
27
|
+
degraded: Station;
|
|
28
|
+
};
|
|
29
|
+
declare function assembleStations(candidates: StationConfigInput[], environment: ResolvedEnvironment): AssembledStation[];
|
|
30
|
+
//#endregion
|
|
31
|
+
export { DEFAULT_HISTORY_HOURS, LoadStationCurrentOptions, LoadStationFeedOptions, StationsInput, StationsResolver, UnknownStationError, assembleStations, loadStationCurrent, loadStationFeed };
|