@azohra/meteo.station 0.6.0 → 0.7.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/README.md +17 -17
- package/dist/air.d.ts +4 -7
- package/dist/air.js +1 -2
- package/dist/client/climatology.d.ts +4 -7
- package/dist/client/climatology.js +1 -2
- package/dist/client/history.d.ts +14 -17
- package/dist/client/history.js +1 -2
- package/dist/client/live.d.ts +9 -11
- 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 +8 -10
- package/dist/client/stores.js +1 -2
- 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 +9 -12
- 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 +148 -151
- package/dist/contract.js +1 -2
- package/dist/derive.d.ts +24 -26
- package/dist/derive.js +5 -6
- package/dist/display.d.ts +6 -9
- package/dist/display.js +1 -2
- package/dist/elements/elements/AirExtremesElement.d.ts +2 -5
- package/dist/elements/elements/AirExtremesElement.js +6 -20
- package/dist/elements/elements/AirMatrixElement.d.ts +2 -5
- package/dist/elements/elements/AirMatrixElement.js +7 -33
- package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +2 -5
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +18 -14
- package/dist/elements/elements/ClimatologyRoseElement.d.ts +2 -5
- package/dist/elements/elements/ClimatologyRoseElement.js +6 -17
- package/dist/elements/elements/CompassFanElement.d.ts +2 -5
- package/dist/elements/elements/CompassFanElement.js +6 -66
- package/dist/elements/elements/CurrentConditionsElement.d.ts +2 -5
- package/dist/elements/elements/CurrentConditionsElement.js +8 -28
- package/dist/elements/elements/DailyPatternElement.d.ts +2 -6
- package/dist/elements/elements/DailyPatternElement.js +7 -122
- package/dist/elements/elements/DialElement.d.ts +2 -5
- package/dist/elements/elements/DialElement.js +4 -97
- package/dist/elements/elements/FavorableShareElement.d.ts +2 -5
- package/dist/elements/elements/FavorableShareElement.js +7 -23
- 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 +7 -25
- package/dist/elements/elements/SparklineElement.d.ts +2 -6
- package/dist/elements/elements/SparklineElement.js +5 -41
- package/dist/elements/elements/StationCardElement.d.ts +6 -8
- package/dist/elements/elements/StationCardElement.js +5 -20
- package/dist/elements/elements/StationFeedElement.d.ts +2 -5
- package/dist/elements/elements/StationFeedElement.js +5 -4
- package/dist/elements/elements/StationStripElement.d.ts +2 -5
- package/dist/elements/elements/StationStripElement.js +5 -20
- package/dist/elements/elements/StationTableElement.d.ts +3 -6
- package/dist/elements/elements/StationTableElement.js +16 -53
- package/dist/elements/elements/TrendChartElement.d.ts +2 -5
- package/dist/elements/elements/TrendChartElement.js +22 -71
- 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 +24 -166
- package/dist/elements/elements/WindRoseElement.d.ts +2 -6
- package/dist/elements/elements/WindRoseElement.js +7 -72
- package/dist/elements/elements/atoms.d.ts +10 -12
- package/dist/elements/elements/atoms.js +12 -40
- package/dist/elements/index.d.ts +3 -5
- package/dist/elements/index.js +4 -5
- 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 +1 -2
- package/dist/elements/lib/context.js +1 -2
- package/dist/elements/lib/fragments.js +9 -39
- package/dist/elements/lib/h.js +2 -3
- package/dist/elements/lib/pinned-cursor.js +1 -2
- package/dist/elements/lib/render.js +29 -0
- package/dist/elements/register.js +1 -2
- package/dist/endpoints.d.ts +6 -9
- package/dist/endpoints.js +1 -2
- 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 -38
- package/dist/geometry.js +3 -3
- package/dist/instruments.d.ts +37 -40
- package/dist/instruments.js +3 -4
- 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 +6 -24
- package/dist/react/components/AirMatrix.d.ts +2 -5
- package/dist/react/components/AirMatrix.js +11 -45
- package/dist/react/components/ClimatologyDailyPattern.d.ts +2 -5
- package/dist/react/components/ClimatologyDailyPattern.js +20 -15
- package/dist/react/components/ClimatologyRose.d.ts +2 -5
- package/dist/react/components/ClimatologyRose.js +12 -30
- package/dist/react/components/CompassFan.d.ts +2 -5
- package/dist/react/components/CompassFan.js +7 -75
- package/dist/react/components/CurrentConditions.d.ts +2 -5
- package/dist/react/components/CurrentConditions.js +12 -76
- package/dist/react/components/DailyPattern.d.ts +3 -8
- package/dist/react/components/DailyPattern.js +11 -151
- package/dist/react/components/Dial.d.ts +2 -5
- package/dist/react/components/Dial.js +6 -120
- package/dist/react/components/FavorableShare.d.ts +2 -5
- package/dist/react/components/FavorableShare.js +7 -29
- package/dist/react/components/FreshnessBadge.d.ts +2 -5
- package/dist/react/components/FreshnessBadge.js +6 -14
- 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 +7 -46
- package/dist/react/components/SceneTree.js +37 -0
- package/dist/react/components/Sparkline.d.ts +2 -5
- package/dist/react/components/Sparkline.js +4 -41
- package/dist/react/components/StationCard.d.ts +8 -10
- package/dist/react/components/StationCard.js +6 -47
- package/dist/react/components/StationFeedProvider.d.ts +3 -6
- package/dist/react/components/StationFeedProvider.js +1 -2
- package/dist/react/components/StationStrip.d.ts +2 -5
- package/dist/react/components/StationStrip.js +6 -62
- package/dist/react/components/StationTable.d.ts +3 -6
- package/dist/react/components/StationTable.js +22 -77
- package/dist/react/components/TrendChart.d.ts +2 -5
- package/dist/react/components/TrendChart.js +9 -65
- package/dist/react/components/WindArrow.d.ts +2 -5
- package/dist/react/components/WindArrow.js +4 -17
- package/dist/react/components/WindHistoryChart.d.ts +2 -5
- package/dist/react/components/WindHistoryChart.js +9 -184
- package/dist/react/components/WindRose.d.ts +2 -7
- package/dist/react/components/WindRose.js +7 -91
- package/dist/react/components/WindSampleStrip.d.ts +2 -5
- package/dist/react/components/WindSampleStrip.js +9 -117
- package/dist/react/components/atoms.d.ts +12 -14
- package/dist/react/components/atoms.js +13 -50
- package/dist/react/hooks/useFreshness.d.ts +1 -4
- package/dist/react/hooks/useFreshness.js +1 -2
- 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 +1 -2
- package/dist/react/hooks/useStationCurrent.d.ts +2 -5
- package/dist/react/hooks/useStationCurrent.js +4 -4
- package/dist/react/hooks/useStationFeed.d.ts +2 -5
- package/dist/react/hooks/useStationFeed.js +4 -4
- package/dist/react/hooks/useStationLive.d.ts +2 -5
- package/dist/react/hooks/useStationLive.js +1 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +5 -5
- package/dist/react/lib/cells.js +5 -26
- 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 +13 -29
- package/dist/scene/air-matrix.js +46 -60
- package/dist/scene/atoms.js +1 -2
- package/dist/scene/card.js +15 -42
- package/dist/scene/cells.d.ts +4 -0
- package/dist/scene/cells.js +50 -0
- package/dist/scene/chart.d.ts +2 -5
- package/dist/scene/chart.js +3 -3
- package/dist/scene/climatology-pattern.d.ts +1 -2
- package/dist/scene/climatology-pattern.js +11 -13
- package/dist/scene/climatology-rose.d.ts +1 -2
- package/dist/scene/climatology-rose.js +15 -35
- package/dist/scene/compass-fan.js +29 -102
- package/dist/scene/current.d.ts +2 -1
- package/dist/scene/current.js +30 -58
- package/dist/scene/daily-pattern.d.ts +1 -3
- package/dist/scene/daily-pattern.js +21 -29
- package/dist/scene/dial-parts.d.ts +1 -0
- package/dist/scene/dial-parts.js +69 -0
- package/dist/scene/dial.d.ts +1 -2
- package/dist/scene/dial.js +49 -138
- package/dist/scene/favorable-share.js +17 -35
- package/dist/scene/glyphs.js +21 -18
- package/dist/scene/index.d.ts +5 -3
- package/dist/scene/node.js +18 -0
- package/dist/scene/recent-summaries.js +27 -65
- package/dist/scene/rose.js +90 -119
- package/dist/scene/sample-strip.d.ts +1 -2
- package/dist/scene/sample-strip.js +36 -38
- package/dist/scene/sparkline.js +32 -42
- package/dist/scene/strip.js +19 -59
- package/dist/scene/table.js +48 -71
- package/dist/scene/trend.d.ts +1 -2
- package/dist/scene/trend.js +30 -57
- package/dist/scene/wind-history.d.ts +1 -2
- package/dist/scene/wind-history.js +42 -53
- package/dist/scene/wind-plot.js +71 -142
- package/dist/server/adapter.d.ts +7 -10
- package/dist/server/adapter.js +1 -2
- package/dist/server/adapters/campbell.d.ts +18 -20
- package/dist/server/adapters/campbell.js +2 -3
- package/dist/server/adapters/ecowitt.d.ts +12 -15
- package/dist/server/adapters/ecowitt.js +1 -2
- package/dist/server/adapters/tempest.d.ts +10 -13
- package/dist/server/adapters/tempest.js +1 -2
- package/dist/server/adapters/windnerd-climatology.d.ts +5 -8
- package/dist/server/adapters/windnerd-climatology.js +5 -5
- package/dist/server/adapters/windnerd-live.d.ts +2 -5
- package/dist/server/adapters/windnerd-live.js +4 -4
- package/dist/server/adapters/windnerd.d.ts +30 -33
- package/dist/server/adapters/windnerd.js +2 -3
- package/dist/server/config.d.ts +61 -63
- package/dist/server/config.js +1 -2
- package/dist/server/environment.d.ts +20 -22
- package/dist/server/environment.js +1 -2
- package/dist/server/feed.d.ts +19 -21
- package/dist/server/feed.js +1 -2
- package/dist/server/handler.d.ts +4 -7
- package/dist/server/handler.js +1 -2
- package/dist/server/hologram.d.ts +9 -12
- package/dist/server/hologram.js +3 -3
- 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 +12 -17
- package/schema/README.md +1 -1
- package/schema/stationclimatology.schema.json +64 -61
- package/schema/stationcurrent.schema.json +68 -156
- package/schema/stationfeed.schema.json +71 -163
- package/schema/stationhistory.schema.json +37 -46
- package/schema/stationlive.schema.json +221 -306
|
@@ -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
|
|
@@ -20,11 +20,12 @@ async function openWindnerdLive(config, options = {}) {
|
|
|
20
20
|
let events;
|
|
21
21
|
let initFrame;
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
const response = await fetchUpstreamStream(environment, {
|
|
24
24
|
url: windnerdLiveStreamUrl(config, options.liveUrl),
|
|
25
25
|
subject,
|
|
26
26
|
signal: upstream.signal
|
|
27
|
-
})
|
|
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();
|
|
@@ -180,5 +181,4 @@ function mapLiveEvent(event, config, environment) {
|
|
|
180
181
|
function isRecord(value) {
|
|
181
182
|
return typeof value === "object" && value !== null;
|
|
182
183
|
}
|
|
183
|
-
//#endregion
|
|
184
184
|
export { openWindnerdLive };
|
|
@@ -4,15 +4,14 @@ import "../environment.js";
|
|
|
4
4
|
import { WindnerdStationConfig } from "../config.js";
|
|
5
5
|
import { StationAdapter, StationAdapterOptions } from "../adapter.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,29 +25,29 @@ 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<{
|
|
29
|
+
elevationM?: number | null | undefined;
|
|
30
|
+
latitude?: number | null | undefined;
|
|
31
|
+
longitude?: number | null | undefined;
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
timeZone?: string | null | undefined;
|
|
35
|
+
pageUrl?: string | null | undefined;
|
|
36
|
+
vendor: "windnerd";
|
|
30
37
|
stationKey: string;
|
|
31
38
|
locationId: number;
|
|
32
39
|
hasTemperature: boolean;
|
|
33
40
|
hasPressure: boolean;
|
|
34
41
|
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
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;
|
|
@@ -5,7 +5,7 @@ import { sseEvents } from "../../sse.js";
|
|
|
5
5
|
import { coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, resolveEnvironment } from "../environment.js";
|
|
6
6
|
import { defineStationAdapter } from "../adapter.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;
|
|
@@ -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 =
|
|
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;
|
|
@@ -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,52 +2,58 @@ 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
|
-
|
|
5
|
+
export declare const windnerdStationConfigSchema: z.ZodObject<{
|
|
6
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
7
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
8
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
vendor: z.ZodLiteral<"windnerd">;
|
|
7
14
|
stationKey: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
8
15
|
locationId: z.ZodNumber;
|
|
9
16
|
hasTemperature: z.ZodDefault<z.ZodBoolean>;
|
|
10
17
|
hasPressure: z.ZodDefault<z.ZodBoolean>;
|
|
11
18
|
hasBattery: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export type WindnerdStationConfig = z.output<typeof windnerdStationConfigSchema>;
|
|
21
|
+
export declare const tempestStationConfigSchema: z.ZodObject<{
|
|
14
22
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
15
23
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
24
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
17
25
|
id: z.ZodString;
|
|
18
26
|
name: z.ZodString;
|
|
19
|
-
vendor: z.ZodLiteral<"windnerd">;
|
|
20
|
-
}, z.core.$strict>;
|
|
21
|
-
type WindnerdStationConfig = z.output<typeof windnerdStationConfigSchema>;
|
|
22
|
-
declare const tempestStationConfigSchema: z.ZodObject<{
|
|
23
|
-
stationId: z.ZodNumber;
|
|
24
|
-
token: z.ZodString;
|
|
25
27
|
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
28
|
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
vendor: z.ZodLiteral<"tempest">;
|
|
30
|
+
stationId: z.ZodNumber;
|
|
31
|
+
token: z.ZodString;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export type TempestStationConfig = z.output<typeof tempestStationConfigSchema>;
|
|
34
|
+
export declare const ecowittStationConfigSchema: z.ZodObject<{
|
|
27
35
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
36
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
29
37
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
30
38
|
id: z.ZodString;
|
|
31
39
|
name: z.ZodString;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
declare const ecowittStationConfigSchema: z.ZodObject<{
|
|
40
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
vendor: z.ZodLiteral<"ecowitt">;
|
|
36
43
|
applicationKey: z.ZodString;
|
|
37
44
|
apiKey: z.ZodString;
|
|
38
45
|
mac: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
39
46
|
hasBattery: z.ZodDefault<z.ZodBoolean>;
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type EcowittStationConfig = z.output<typeof ecowittStationConfigSchema>;
|
|
49
|
+
export declare const campbellStationConfigSchema: z.ZodObject<{
|
|
42
50
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
43
51
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
52
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
53
|
id: z.ZodString;
|
|
46
54
|
name: z.ZodString;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
type EcowittStationConfig = z.output<typeof ecowittStationConfigSchema>;
|
|
50
|
-
declare const campbellStationConfigSchema: z.ZodObject<{
|
|
55
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
vendor: z.ZodLiteral<"campbell">;
|
|
51
57
|
baseUrl: z.ZodString;
|
|
52
58
|
source: z.ZodString;
|
|
53
59
|
timeZone: z.ZodString;
|
|
@@ -56,16 +62,9 @@ declare const campbellStationConfigSchema: z.ZodObject<{
|
|
|
56
62
|
currentIntervalSeconds: z.ZodDefault<z.ZodNumber>;
|
|
57
63
|
historyPeriodMinutes: z.ZodDefault<z.ZodNumber>;
|
|
58
64
|
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
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,51 +73,58 @@ 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<{
|
|
85
|
-
load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
|
|
86
|
-
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
87
|
-
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
82
|
+
export type CustomStationLoader = (context: CustomStationContext) => Promise<Station>;
|
|
83
|
+
export declare const customStationConfigSchema: z.ZodObject<{
|
|
88
84
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
89
85
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
90
86
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
91
87
|
id: z.ZodString;
|
|
92
88
|
name: z.ZodString;
|
|
89
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
93
91
|
vendor: z.ZodLiteral<"custom">;
|
|
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<{
|
|
96
|
+
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
97
|
+
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
98
|
+
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
name: z.ZodString;
|
|
101
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
102
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
103
|
+
vendor: z.ZodLiteral<"windnerd">;
|
|
97
104
|
stationKey: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
98
105
|
locationId: z.ZodNumber;
|
|
99
106
|
hasTemperature: z.ZodDefault<z.ZodBoolean>;
|
|
100
107
|
hasPressure: z.ZodDefault<z.ZodBoolean>;
|
|
101
108
|
hasBattery: z.ZodDefault<z.ZodBoolean>;
|
|
102
|
-
|
|
103
|
-
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
109
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
104
110
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
105
111
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
106
112
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
107
113
|
id: z.ZodString;
|
|
108
114
|
name: z.ZodString;
|
|
109
|
-
vendor: z.ZodLiteral<"windnerd">;
|
|
110
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
-
stationId: z.ZodNumber;
|
|
112
|
-
token: z.ZodString;
|
|
113
115
|
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
116
|
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
|
+
vendor: z.ZodLiteral<"tempest">;
|
|
118
|
+
stationId: z.ZodNumber;
|
|
119
|
+
token: z.ZodString;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
115
121
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
116
122
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
117
123
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
118
124
|
id: z.ZodString;
|
|
119
125
|
name: z.ZodString;
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
127
|
+
vendor: z.ZodLiteral<"campbell">;
|
|
122
128
|
baseUrl: z.ZodString;
|
|
123
129
|
source: z.ZodString;
|
|
124
130
|
timeZone: z.ZodString;
|
|
@@ -127,39 +133,31 @@ declare const stationConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
127
133
|
currentIntervalSeconds: z.ZodDefault<z.ZodNumber>;
|
|
128
134
|
historyPeriodMinutes: z.ZodDefault<z.ZodNumber>;
|
|
129
135
|
currentCacheTtlSeconds: z.ZodDefault<z.ZodNumber>;
|
|
130
|
-
|
|
136
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
131
137
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
132
138
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
133
139
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
134
140
|
id: z.ZodString;
|
|
135
141
|
name: z.ZodString;
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
143
|
+
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
144
|
+
vendor: z.ZodLiteral<"ecowitt">;
|
|
138
145
|
applicationKey: z.ZodString;
|
|
139
146
|
apiKey: z.ZodString;
|
|
140
147
|
mac: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
141
148
|
hasBattery: z.ZodDefault<z.ZodBoolean>;
|
|
142
|
-
|
|
143
|
-
pageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
149
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
144
150
|
elevationM: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
145
151
|
latitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
146
152
|
longitude: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
147
153
|
id: z.ZodString;
|
|
148
154
|
name: z.ZodString;
|
|
149
|
-
vendor: z.ZodLiteral<"ecowitt">;
|
|
150
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
151
|
-
load: z.ZodCustom<CustomStationLoader, CustomStationLoader>;
|
|
152
155
|
timeZone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
153
156
|
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
157
|
vendor: z.ZodLiteral<"custom">;
|
|
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 };
|
package/dist/server/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { httpUrl, ianaTimeZone, positionFields } from "@azohra/meteo.core";
|
|
4
|
-
|
|
4
|
+
// src/server/config.ts
|
|
5
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
6
|
const stationIdentity = {
|
|
7
7
|
id: z.string().min(1),
|
|
@@ -67,5 +67,4 @@ const stationConfigSchema = z.discriminatedUnion("vendor", [
|
|
|
67
67
|
function parseStationConfig(value) {
|
|
68
68
|
return stationConfigSchema.parse(value);
|
|
69
69
|
}
|
|
70
|
-
//#endregion
|
|
71
70
|
export { campbellStationConfigSchema, customStationConfigSchema, ecowittStationConfigSchema, normalizeWindnerdStationKey, parseStationConfig, stationConfigSchema, tempestStationConfigSchema, windnerdStationConfigSchema, windnerdStationUrl };
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { UPSTREAM_FAILURE_REASONS as UPSTREAM_FAILURE_REASONS$1, UpstreamError as UpstreamError$1, UpstreamErrorReason, UpstreamFailureReason, unavailableReasonForError } from "@azohra/meteo.core";
|
|
2
|
-
|
|
3
|
-
type FeedCache = {
|
|
2
|
+
export type FeedCache = {
|
|
4
3
|
get(key: string): Promise<string | null>;
|
|
5
4
|
put(key: string, value: string, ttlSeconds: number): Promise<void>;
|
|
6
5
|
};
|
|
7
|
-
type LogEventCode = "config_invalid" | "duplicate_station" | "upstream_failure" | "adapter_threw" | "custom_contract_break" | "clock_skew" | "resolver_invalid";
|
|
8
|
-
type LogEvent = {
|
|
6
|
+
export type LogEventCode = "config_invalid" | "duplicate_station" | "upstream_failure" | "adapter_threw" | "custom_contract_break" | "clock_skew" | "resolver_invalid";
|
|
7
|
+
export type LogEvent = {
|
|
9
8
|
level: "warn" | "error";
|
|
10
9
|
code: LogEventCode;
|
|
11
10
|
message: string;
|
|
12
11
|
detail?: unknown;
|
|
13
12
|
};
|
|
14
|
-
type ServerEnvironment = {
|
|
13
|
+
export type ServerEnvironment = {
|
|
15
14
|
fetch?: typeof fetch;
|
|
16
15
|
cache?: FeedCache;
|
|
17
16
|
logger?: (event: LogEvent) => void;
|
|
18
17
|
userAgent?: string;
|
|
19
18
|
now?: () => Date;
|
|
20
19
|
};
|
|
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;
|
|
20
|
+
export type ResolvedEnvironment = Required<ServerEnvironment>;
|
|
21
|
+
export declare const UPSTREAM_FETCH_TIMEOUT_MS = 4000;
|
|
22
|
+
export declare const UPSTREAM_RESPONSE_LIMIT_BYTES = 524288;
|
|
23
|
+
export declare function memoryCache(): FeedCache;
|
|
25
24
|
/**
|
|
26
25
|
* A FeedCache over the ambient Cloudflare Workers cache (`caches.default`),
|
|
27
26
|
* shared across the isolates of a deployment. Returns undefined where no
|
|
28
27
|
* ambient cache exists (node, vitest), so `cache: workersCache()` falls
|
|
29
28
|
* through to the memory-cache default.
|
|
30
29
|
*/
|
|
31
|
-
declare function workersCache(): FeedCache | undefined;
|
|
32
|
-
declare const DEFAULT_USER_AGENT = "azohra-meteo/0.1 (+https://meteo.azohra.com)";
|
|
33
|
-
declare function resolveEnvironment(environment?: ServerEnvironment): ResolvedEnvironment;
|
|
34
|
-
type UpstreamTextRequest = {
|
|
30
|
+
export declare function workersCache(): FeedCache | undefined;
|
|
31
|
+
export declare const DEFAULT_USER_AGENT = "azohra-meteo/0.1 (+https://meteo.azohra.com)";
|
|
32
|
+
export declare function resolveEnvironment(environment?: ServerEnvironment): ResolvedEnvironment;
|
|
33
|
+
export type UpstreamTextRequest = {
|
|
35
34
|
url: string | URL;
|
|
36
35
|
cacheKey: string;
|
|
37
36
|
cacheTtlSeconds: number;
|
|
@@ -47,11 +46,11 @@ type UpstreamTextRequest = {
|
|
|
47
46
|
* Coalesces concurrent misses on the same (cache instance, key) onto a single
|
|
48
47
|
* in-flight load. The load owns its own cache fill; this only deduplicates.
|
|
49
48
|
*/
|
|
50
|
-
declare function coalesceUpstreamLoad(cache: FeedCache, key: string, load: () => Promise<string>): Promise<string>;
|
|
49
|
+
export declare function coalesceUpstreamLoad(cache: FeedCache, key: string, load: () => Promise<string>): Promise<string>;
|
|
51
50
|
/** Cache lookup, bounded fetch under a timeout, cache fill. Concurrent
|
|
52
51
|
* misses on one (cache instance, cacheKey) coalesce onto a single load. */
|
|
53
|
-
declare function fetchUpstreamText(environment: ResolvedEnvironment, request: UpstreamTextRequest): Promise<string>;
|
|
54
|
-
type UpstreamStreamRequest = {
|
|
52
|
+
export declare function fetchUpstreamText(environment: ResolvedEnvironment, request: UpstreamTextRequest): Promise<string>;
|
|
53
|
+
export type UpstreamStreamRequest = {
|
|
55
54
|
url: string | URL;
|
|
56
55
|
subject: string;
|
|
57
56
|
accept?: string;
|
|
@@ -59,11 +58,10 @@ type UpstreamStreamRequest = {
|
|
|
59
58
|
connectTimeoutMs?: number;
|
|
60
59
|
signal?: AbortSignal;
|
|
61
60
|
};
|
|
62
|
-
declare const UPSTREAM_CONNECT_TIMEOUT_MS = 10000;
|
|
61
|
+
export declare const UPSTREAM_CONNECT_TIMEOUT_MS = 10000;
|
|
63
62
|
/** Long-lived upstream body: no cache, no byte cap, never coalesced —
|
|
64
63
|
* the caller owns the connection and tears it down through its signal. */
|
|
65
|
-
declare function fetchUpstreamStream(environment: ResolvedEnvironment, request: UpstreamStreamRequest): Promise<Response>;
|
|
66
|
-
declare function boundedResponseText(response: Response, limitBytes: number, subject: string): Promise<string>;
|
|
67
|
-
declare function logUpstreamFailure(environment: ResolvedEnvironment, message: string, error: unknown, detail?: Record<string, unknown>): void;
|
|
68
|
-
|
|
69
|
-
export { DEFAULT_USER_AGENT, FeedCache, LogEvent, LogEventCode, ResolvedEnvironment, ServerEnvironment, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS$1 as UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UpstreamError$1 as UpstreamError, type UpstreamErrorReason, type UpstreamFailureReason, UpstreamStreamRequest, UpstreamTextRequest, boundedResponseText, coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, memoryCache, resolveEnvironment, unavailableReasonForError, workersCache };
|
|
64
|
+
export declare function fetchUpstreamStream(environment: ResolvedEnvironment, request: UpstreamStreamRequest): Promise<Response>;
|
|
65
|
+
export declare function boundedResponseText(response: Response, limitBytes: number, subject: string): Promise<string>;
|
|
66
|
+
export declare function logUpstreamFailure(environment: ResolvedEnvironment, message: string, error: unknown, detail?: Record<string, unknown>): void;
|
|
67
|
+
export { UPSTREAM_FAILURE_REASONS$1 as UPSTREAM_FAILURE_REASONS, UpstreamError$1 as UpstreamError, type UpstreamErrorReason, type UpstreamFailureReason, unavailableReasonForError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UPSTREAM_FAILURE_REASONS as UPSTREAM_FAILURE_REASONS$1, UpstreamError as UpstreamError$1, unavailableReasonForError } from "@azohra/meteo.core";
|
|
2
|
-
|
|
2
|
+
// src/server/environment.ts
|
|
3
3
|
const UPSTREAM_FETCH_TIMEOUT_MS = 4e3;
|
|
4
4
|
const UPSTREAM_RESPONSE_LIMIT_BYTES = 524288;
|
|
5
5
|
const MEMORY_CACHE_MAX_ENTRIES = 500;
|
|
@@ -184,5 +184,4 @@ function logUpstreamFailure(environment, message, error, detail = {}) {
|
|
|
184
184
|
}
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
//#endregion
|
|
188
187
|
export { DEFAULT_USER_AGENT, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS$1 as UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UpstreamError$1 as UpstreamError, boundedResponseText, coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, memoryCache, resolveEnvironment, unavailableReasonForError, workersCache };
|
package/dist/server/feed.d.ts
CHANGED
|
@@ -3,11 +3,10 @@ import { StationClimatology } from "../contract-climatology.js";
|
|
|
3
3
|
import { SpeedThresholds } from "../derive.js";
|
|
4
4
|
import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
|
|
5
5
|
import { StationConfig, StationConfigInput } from "./config.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
type
|
|
10
|
-
type LoadStationFeedOptions = {
|
|
6
|
+
export declare const DEFAULT_HISTORY_HOURS = 6;
|
|
7
|
+
export type StationsResolver = (request?: Request) => Promise<StationConfigInput[]> | StationConfigInput[];
|
|
8
|
+
export type StationsInput = StationConfigInput[] | StationsResolver;
|
|
9
|
+
export type LoadStationFeedOptions = {
|
|
11
10
|
stations: StationsInput;
|
|
12
11
|
primaryStationId?: string;
|
|
13
12
|
historyHours?: number;
|
|
@@ -15,16 +14,16 @@ type LoadStationFeedOptions = {
|
|
|
15
14
|
environment?: ServerEnvironment;
|
|
16
15
|
request?: Request;
|
|
17
16
|
};
|
|
18
|
-
type LoadStationCurrentOptions = LoadStationFeedOptions & {
|
|
17
|
+
export type LoadStationCurrentOptions = LoadStationFeedOptions & {
|
|
19
18
|
stationId: string;
|
|
20
19
|
};
|
|
21
|
-
declare class UnknownStationError extends Error {
|
|
20
|
+
export declare class UnknownStationError extends Error {
|
|
22
21
|
constructor(stationId: string);
|
|
23
22
|
}
|
|
24
|
-
declare class StationLiveUnsupportedError extends Error {
|
|
23
|
+
export declare class StationLiveUnsupportedError extends Error {
|
|
25
24
|
constructor(stationId: string);
|
|
26
25
|
}
|
|
27
|
-
type OpenStationLiveOptions = {
|
|
26
|
+
export type OpenStationLiveOptions = {
|
|
28
27
|
stations: StationsInput;
|
|
29
28
|
stationId: string;
|
|
30
29
|
environment?: ServerEnvironment;
|
|
@@ -38,11 +37,11 @@ type OpenStationLiveOptions = {
|
|
|
38
37
|
* failures reject with the upstream error. One call is one upstream
|
|
39
38
|
* connection.
|
|
40
39
|
*/
|
|
41
|
-
declare function openStationLive(options: OpenStationLiveOptions): Promise<ReadableStream<StationLiveFrame>>;
|
|
42
|
-
declare class StationHistoryUnsupportedError extends Error {
|
|
40
|
+
export declare function openStationLive(options: OpenStationLiveOptions): Promise<ReadableStream<StationLiveFrame>>;
|
|
41
|
+
export declare class StationHistoryUnsupportedError extends Error {
|
|
43
42
|
constructor(stationId: string);
|
|
44
43
|
}
|
|
45
|
-
type LoadStationHistoryOptions = {
|
|
44
|
+
export type LoadStationHistoryOptions = {
|
|
46
45
|
stations: StationsInput;
|
|
47
46
|
stationId: string;
|
|
48
47
|
fromMs: number;
|
|
@@ -57,11 +56,11 @@ type LoadStationHistoryOptions = {
|
|
|
57
56
|
* vendor keeps no reachable archive — and stations whose config failed
|
|
58
57
|
* validation — throw StationHistoryUnsupportedError.
|
|
59
58
|
*/
|
|
60
|
-
declare function loadStationHistory(options: LoadStationHistoryOptions): Promise<StationHistory>;
|
|
61
|
-
declare class StationClimatologyUnsupportedError extends Error {
|
|
59
|
+
export declare function loadStationHistory(options: LoadStationHistoryOptions): Promise<StationHistory>;
|
|
60
|
+
export declare class StationClimatologyUnsupportedError extends Error {
|
|
62
61
|
constructor(stationId: string);
|
|
63
62
|
}
|
|
64
|
-
type LoadStationClimatologyOptions = {
|
|
63
|
+
export type LoadStationClimatologyOptions = {
|
|
65
64
|
stations: StationsInput;
|
|
66
65
|
stationId: string;
|
|
67
66
|
/** The consumer's speed-band bounds — a judgment parameter, no default. */
|
|
@@ -78,14 +77,13 @@ type LoadStationClimatologyOptions = {
|
|
|
78
77
|
* archive — and stations whose config failed validation — throw
|
|
79
78
|
* StationClimatologyUnsupportedError.
|
|
80
79
|
*/
|
|
81
|
-
declare function loadStationClimatology(options: LoadStationClimatologyOptions): Promise<StationClimatology>;
|
|
82
|
-
declare function loadStationFeed(options: LoadStationFeedOptions): Promise<StationFeed>;
|
|
83
|
-
declare function loadStationCurrent(options: LoadStationCurrentOptions): Promise<StationCurrent>;
|
|
80
|
+
export declare function loadStationClimatology(options: LoadStationClimatologyOptions): Promise<StationClimatology>;
|
|
81
|
+
export declare function loadStationFeed(options: LoadStationFeedOptions): Promise<StationFeed>;
|
|
82
|
+
export declare function loadStationCurrent(options: LoadStationCurrentOptions): Promise<StationCurrent>;
|
|
84
83
|
type AssembledStation = {
|
|
85
84
|
config: StationConfig;
|
|
86
85
|
} | {
|
|
87
86
|
degraded: Station;
|
|
88
87
|
};
|
|
89
|
-
declare function assembleStations(candidates: StationConfigInput[], environment: ResolvedEnvironment): AssembledStation[];
|
|
90
|
-
|
|
91
|
-
export { DEFAULT_HISTORY_HOURS, LoadStationClimatologyOptions, LoadStationCurrentOptions, LoadStationFeedOptions, LoadStationHistoryOptions, OpenStationLiveOptions, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, StationsInput, StationsResolver, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive };
|
|
88
|
+
export declare function assembleStations(candidates: StationConfigInput[], environment: ResolvedEnvironment): AssembledStation[];
|
|
89
|
+
export {};
|
package/dist/server/feed.js
CHANGED
|
@@ -7,7 +7,7 @@ import { loadTempestStation } from "./adapters/tempest.js";
|
|
|
7
7
|
import { loadWindnerdHistory, loadWindnerdStation } from "./adapters/windnerd.js";
|
|
8
8
|
import { loadWindnerdClimatology } from "./adapters/windnerd-climatology.js";
|
|
9
9
|
import { openWindnerdLive } from "./adapters/windnerd-live.js";
|
|
10
|
-
|
|
10
|
+
// src/server/feed.ts
|
|
11
11
|
const DEFAULT_HISTORY_HOURS = 6;
|
|
12
12
|
var UnknownStationError = class extends Error {
|
|
13
13
|
constructor(stationId) {
|
|
@@ -306,5 +306,4 @@ function neverThrewButDid(config, environment, error) {
|
|
|
306
306
|
});
|
|
307
307
|
return unavailableStation(configFallbackMeta(config), "contract_break");
|
|
308
308
|
}
|
|
309
|
-
//#endregion
|
|
310
309
|
export { DEFAULT_HISTORY_HOURS, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive };
|
package/dist/server/handler.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SpeedThresholds } from "../derive.js";
|
|
2
2
|
import { ServerEnvironment } from "./environment.js";
|
|
3
3
|
import { StationsInput } from "./feed.js";
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type StationFeedHandlerOptions = {
|
|
4
|
+
export type StationFeedHandlerRoute = "feed" | "current" | "live" | "climatology" | "history";
|
|
5
|
+
export type StationFeedHandlerOptions = {
|
|
7
6
|
stations: StationsInput;
|
|
8
7
|
primaryStationId?: string;
|
|
9
8
|
maxHistoryHours?: number;
|
|
@@ -21,7 +20,5 @@ type StationFeedHandlerOptions = {
|
|
|
21
20
|
};
|
|
22
21
|
environment?: ServerEnvironment;
|
|
23
22
|
};
|
|
24
|
-
type StationFeedHandler = (request: Request) => Promise<Response>;
|
|
25
|
-
declare function createStationFeedHandler(options: StationFeedHandlerOptions): StationFeedHandler;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { StationFeedHandler, StationFeedHandlerOptions, StationFeedHandlerRoute, createStationFeedHandler };
|
|
23
|
+
export type StationFeedHandler = (request: Request) => Promise<Response>;
|
|
24
|
+
export declare function createStationFeedHandler(options: StationFeedHandlerOptions): StationFeedHandler;
|