@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
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
|
-
import { UPSTREAM_FAILURE_REASONS
|
|
2
|
-
|
|
3
|
-
type FeedCache = {
|
|
1
|
+
import { UPSTREAM_FAILURE_REASONS, UpstreamError, UpstreamErrorReason, UpstreamFailureReason, unavailableReasonForError } from "@azohra/meteo.core";
|
|
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, UpstreamError, type UpstreamErrorReason, type UpstreamFailureReason, unavailableReasonForError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UPSTREAM_FAILURE_REASONS
|
|
2
|
-
|
|
1
|
+
import { UPSTREAM_FAILURE_REASONS, UpstreamError, unavailableReasonForError } from "@azohra/meteo.core";
|
|
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;
|
|
@@ -108,15 +108,15 @@ async function loadUpstreamText(environment, request) {
|
|
|
108
108
|
signal: AbortSignal.timeout(request.timeoutMs ?? 4e3)
|
|
109
109
|
});
|
|
110
110
|
} catch (error) {
|
|
111
|
-
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) throw new UpstreamError
|
|
112
|
-
throw new UpstreamError
|
|
111
|
+
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) throw new UpstreamError(`${request.subject} timed out`, "timeout");
|
|
112
|
+
throw new UpstreamError(`${request.subject} could not be reached: ${error instanceof Error ? error.message : String(error)}`);
|
|
113
113
|
}
|
|
114
114
|
if (!response.ok) {
|
|
115
115
|
try {
|
|
116
116
|
await response.body?.cancel();
|
|
117
117
|
} catch {}
|
|
118
|
-
if (response.status === 429) throw new UpstreamError
|
|
119
|
-
throw new UpstreamError
|
|
118
|
+
if (response.status === 429) throw new UpstreamError(`${request.subject} is rate limiting requests`, "rate_limited");
|
|
119
|
+
throw new UpstreamError(`${request.subject} returned ${response.status}`);
|
|
120
120
|
}
|
|
121
121
|
const text = await boundedResponseText(response, request.limitBytes ?? 524288, request.subject);
|
|
122
122
|
await environment.cache.put(request.cacheKey, text, request.cacheTtlSeconds);
|
|
@@ -141,8 +141,8 @@ async function fetchUpstreamStream(environment, request) {
|
|
|
141
141
|
});
|
|
142
142
|
} catch (error) {
|
|
143
143
|
if (request.signal?.aborted) throw error;
|
|
144
|
-
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) throw new UpstreamError
|
|
145
|
-
throw new UpstreamError
|
|
144
|
+
if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) throw new UpstreamError(`${request.subject} timed out`, "timeout");
|
|
145
|
+
throw new UpstreamError(`${request.subject} could not be reached: ${error instanceof Error ? error.message : String(error)}`);
|
|
146
146
|
} finally {
|
|
147
147
|
clearTimeout(connectTimer);
|
|
148
148
|
}
|
|
@@ -150,15 +150,15 @@ async function fetchUpstreamStream(environment, request) {
|
|
|
150
150
|
try {
|
|
151
151
|
await response.body?.cancel();
|
|
152
152
|
} catch {}
|
|
153
|
-
if (response.status === 429) throw new UpstreamError
|
|
154
|
-
throw new UpstreamError
|
|
153
|
+
if (response.status === 429) throw new UpstreamError(`${request.subject} is rate limiting requests`, "rate_limited");
|
|
154
|
+
throw new UpstreamError(`${request.subject} returned ${response.status}`);
|
|
155
155
|
}
|
|
156
|
-
if (!response.body) throw new UpstreamError
|
|
156
|
+
if (!response.body) throw new UpstreamError(`${request.subject} returned no body`);
|
|
157
157
|
return response;
|
|
158
158
|
}
|
|
159
159
|
async function boundedResponseText(response, limitBytes, subject) {
|
|
160
160
|
const reader = response.body?.getReader();
|
|
161
|
-
if (!reader) throw new UpstreamError
|
|
161
|
+
if (!reader) throw new UpstreamError(`${subject} returned no body`);
|
|
162
162
|
const decoder = new TextDecoder();
|
|
163
163
|
let result = "";
|
|
164
164
|
let totalBytes = 0;
|
|
@@ -168,7 +168,7 @@ async function boundedResponseText(response, limitBytes, subject) {
|
|
|
168
168
|
totalBytes += value.byteLength;
|
|
169
169
|
if (totalBytes > limitBytes) {
|
|
170
170
|
await reader.cancel();
|
|
171
|
-
throw new UpstreamError
|
|
171
|
+
throw new UpstreamError(`${subject} exceeded the response limit`);
|
|
172
172
|
}
|
|
173
173
|
result += decoder.decode(value, { stream: true });
|
|
174
174
|
}
|
|
@@ -184,5 +184,4 @@ function logUpstreamFailure(environment, message, error, detail = {}) {
|
|
|
184
184
|
}
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
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 };
|
|
187
|
+
export { DEFAULT_USER_AGENT, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UpstreamError, boundedResponseText, coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, memoryCache, resolveEnvironment, unavailableReasonForError, workersCache };
|
package/dist/server/feed.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Station, StationCurrent, StationFeed, StationHistory, StationLiveFrame } from "../contract.js";
|
|
2
2
|
import { StationClimatology } from "../contract-climatology.js";
|
|
3
3
|
import { SpeedThresholds } from "../derive.js";
|
|
4
|
-
import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
|
|
5
4
|
import { StationConfig, StationConfigInput } from "./config.js";
|
|
6
|
-
|
|
7
|
-
declare const DEFAULT_HISTORY_HOURS = 6;
|
|
8
|
-
type StationsResolver = (request?: Request) => Promise<StationConfigInput[]> | StationConfigInput[];
|
|
9
|
-
type StationsInput = StationConfigInput[] | StationsResolver;
|
|
10
|
-
type LoadStationFeedOptions = {
|
|
5
|
+
import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
|
|
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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { stationSchema, unavailableStation } from "../contract.js";
|
|
2
|
-
import { logUpstreamFailure, resolveEnvironment, unavailableReasonForError } from "./environment.js";
|
|
3
|
-
import { stationConfigSchema } from "./config.js";
|
|
4
2
|
import { loadCampbellStation } from "./adapters/campbell.js";
|
|
5
3
|
import { loadEcowittStation } from "./adapters/ecowitt.js";
|
|
6
4
|
import { loadTempestStation } from "./adapters/tempest.js";
|
|
7
5
|
import { loadWindnerdHistory, loadWindnerdStation } from "./adapters/windnerd.js";
|
|
8
6
|
import { loadWindnerdClimatology } from "./adapters/windnerd-climatology.js";
|
|
9
7
|
import { openWindnerdLive } from "./adapters/windnerd-live.js";
|
|
10
|
-
|
|
8
|
+
import { stationConfigSchema } from "./config.js";
|
|
9
|
+
import { logUpstreamFailure, resolveEnvironment, unavailableReasonForError } from "./environment.js";
|
|
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
|
-
import { ServerEnvironment } from "./environment.js";
|
|
3
2
|
import { StationsInput } from "./feed.js";
|
|
4
|
-
|
|
5
|
-
type StationFeedHandlerRoute = "feed" | "current" | "live" | "climatology" | "history";
|
|
6
|
-
type StationFeedHandlerOptions = {
|
|
3
|
+
import { ServerEnvironment } from "./environment.js";
|
|
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;
|
package/dist/server/handler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolveEnvironment, unavailableReasonForError } from "./environment.js";
|
|
2
1
|
import { StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive } from "./feed.js";
|
|
2
|
+
import { resolveEnvironment, unavailableReasonForError } from "./environment.js";
|
|
3
3
|
import { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse } from "./live.js";
|
|
4
|
-
|
|
4
|
+
// src/server/handler.ts
|
|
5
5
|
const CLIMATOLOGY_CACHE_SECONDS = 21600;
|
|
6
6
|
const HISTORY_PAST_CACHE_SECONDS = 86400;
|
|
7
7
|
const HISTORY_LIVE_CACHE_SECONDS = 60;
|
|
@@ -182,7 +182,7 @@ function createStationFeedHandler(options) {
|
|
|
182
182
|
};
|
|
183
183
|
if (route === "feed") {
|
|
184
184
|
const feed = await loadStationFeed(loadOptions);
|
|
185
|
-
const maxAge = feed.stations.length === 0 ? 60 : feed.stations.reduce((least, station) => Math.min(least, station.recommendedPollSeconds),
|
|
185
|
+
const maxAge = feed.stations.length === 0 ? 60 : feed.stations.reduce((least, station) => Math.min(least, station.recommendedPollSeconds), 1e400);
|
|
186
186
|
const headers = {
|
|
187
187
|
"Cache-Control": cacheControlFor("feed", maxAge),
|
|
188
188
|
ETag: weakEtag({
|
|
@@ -244,5 +244,4 @@ function etagMatches(ifNoneMatch, etag) {
|
|
|
244
244
|
const bare = (tag) => tag.startsWith("W/") ? tag.slice(2) : tag;
|
|
245
245
|
return ifNoneMatch.split(",").some((candidate) => bare(candidate.trim()) === bare(etag));
|
|
246
246
|
}
|
|
247
|
-
//#endregion
|
|
248
247
|
export { createStationFeedHandler };
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { ConnectivityServiceState, StationConnectivity } from "../connectivity.js";
|
|
2
2
|
import { ServerEnvironment } from "./environment.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const hologramConnectivityConfigSchema: z.ZodObject<{
|
|
4
|
+
export declare const HOLOGRAM_API_BASE = "https://dashboard.hologram.io/api/1";
|
|
5
|
+
export declare const TRIAL_HOLOGRAM_CACHE_TTL_SECONDS = 300;
|
|
6
|
+
export declare const hologramConnectivityConfigSchema: z.ZodObject<{
|
|
8
7
|
apiKey: z.ZodString;
|
|
9
8
|
deviceId: z.ZodNumber;
|
|
10
9
|
}, z.core.$strict>;
|
|
11
|
-
type HologramConnectivityConfig = z.output<typeof hologramConnectivityConfigSchema>;
|
|
12
|
-
type HologramConnectivityOptions = {
|
|
10
|
+
export type HologramConnectivityConfig = z.output<typeof hologramConnectivityConfigSchema>;
|
|
11
|
+
export type HologramConnectivityOptions = {
|
|
13
12
|
environment?: ServerEnvironment;
|
|
14
13
|
cacheTtlSeconds?: number;
|
|
15
14
|
apiBase?: string;
|
|
16
15
|
};
|
|
17
|
-
declare function hologramTimeToIso(value: string | null | undefined): string | null;
|
|
18
|
-
declare function hologramServiceState(state: string | null | undefined): ConnectivityServiceState;
|
|
19
|
-
declare function parseHologramConnectivity(value: string, expectedDeviceId: number, checkedAt: string): StationConnectivity;
|
|
20
|
-
declare function loadHologramConnectivity(config: HologramConnectivityConfig, options?: HologramConnectivityOptions): Promise<StationConnectivity>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { HOLOGRAM_API_BASE, HologramConnectivityConfig, HologramConnectivityOptions, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadHologramConnectivity, parseHologramConnectivity };
|
|
16
|
+
export declare function hologramTimeToIso(value: string | null | undefined): string | null;
|
|
17
|
+
export declare function hologramServiceState(state: string | null | undefined): ConnectivityServiceState;
|
|
18
|
+
export declare function parseHologramConnectivity(value: string, expectedDeviceId: number, checkedAt: string): StationConnectivity;
|
|
19
|
+
export declare function loadHologramConnectivity(config: HologramConnectivityConfig, options?: HologramConnectivityOptions): Promise<StationConnectivity>;
|
package/dist/server/hologram.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fetchUpstreamText, resolveEnvironment } from "./environment.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { UpstreamError } from "@azohra/meteo.core";
|
|
4
|
-
|
|
4
|
+
// src/server/hologram.ts
|
|
5
5
|
const HOLOGRAM_API_BASE = "https://dashboard.hologram.io/api/1";
|
|
6
6
|
const TRIAL_HOLOGRAM_CACHE_TTL_SECONDS = 300;
|
|
7
7
|
const hologramConnectivityConfigSchema = z.strictObject({
|
|
@@ -110,5 +110,4 @@ async function loadHologramConnectivity(config, options = {}) {
|
|
|
110
110
|
headers: { Authorization: `Basic ${btoa(`apikey:${config.apiKey}`)}` }
|
|
111
111
|
}), config.deviceId, environment.now().toISOString());
|
|
112
112
|
}
|
|
113
|
-
//#endregion
|
|
114
113
|
export { HOLOGRAM_API_BASE, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadHologramConnectivity, parseHologramConnectivity };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WINDNERD_RECORD_PERIODS_MINUTES, WindnerdRecordPeriodMinutes, normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
2
1
|
import { DEFAULT_USER_AGENT, FeedCache, LogEvent, LogEventCode, ResolvedEnvironment, ServerEnvironment, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UpstreamError, UpstreamErrorReason, UpstreamFailureReason, UpstreamStreamRequest, UpstreamTextRequest, boundedResponseText, coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, memoryCache, resolveEnvironment, unavailableReasonForError, workersCache } from "./environment.js";
|
|
3
2
|
import { CampbellStationConfig, CustomStationConfig, CustomStationContext, CustomStationIdentity, CustomStationLoader, EcowittStationConfig, StationConfig, StationConfigInput, TempestStationConfig, WindnerdStationConfig, campbellStationConfigSchema, customStationConfigSchema, ecowittStationConfigSchema, parseStationConfig, stationConfigSchema, tempestStationConfigSchema, windnerdStationConfigSchema } from "./config.js";
|
|
4
3
|
import { StationAdapter, StationAdapterContext, StationAdapterDefinition, StationAdapterMode, StationAdapterOptions, StationAdapterResult, defineStationAdapter } from "./adapter.js";
|
|
@@ -8,6 +7,7 @@ import { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse } from "./live.js";
|
|
|
8
7
|
import { WindnerdLiveOptions, openWindnerdLive } from "./adapters/windnerd-live.js";
|
|
9
8
|
import { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, WindnerdClimatologyOptions, loadWindnerdClimatology } from "./adapters/windnerd-climatology.js";
|
|
10
9
|
import { 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 } from "./adapters/windnerd.js";
|
|
10
|
+
import { WINDNERD_RECORD_PERIODS_MINUTES, WindnerdRecordPeriodMinutes, normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
11
11
|
import { HOLOGRAM_API_BASE, HologramConnectivityConfig, HologramConnectivityOptions, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadHologramConnectivity, parseHologramConnectivity } from "./hologram.js";
|
|
12
12
|
import { TempestAdapterOptions, TempestObservation, loadTempestStation, parseTempestWind } from "./adapters/tempest.js";
|
|
13
13
|
import { EcowittAdapterOptions, EcowittObservation, loadEcowittStation, parseEcowittRealTime } from "./adapters/ecowitt.js";
|
package/dist/server/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { WINDNERD_RECORD_PERIODS_MINUTES, normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
2
1
|
import { DEFAULT_USER_AGENT, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UpstreamError, boundedResponseText, coalesceUpstreamLoad, fetchUpstreamStream, fetchUpstreamText, logUpstreamFailure, memoryCache, resolveEnvironment, unavailableReasonForError, workersCache } from "./environment.js";
|
|
3
2
|
import { campbellStationConfigSchema, customStationConfigSchema, ecowittStationConfigSchema, parseStationConfig, stationConfigSchema, tempestStationConfigSchema, windnerdStationConfigSchema } from "./config.js";
|
|
4
|
-
import { CAMPBELL_FIELD_CONTRACTS, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable } from "./adapters/campbell.js";
|
|
5
|
-
import { loadEcowittStation, parseEcowittRealTime } from "./adapters/ecowitt.js";
|
|
6
|
-
import { loadTempestStation, parseTempestWind } from "./adapters/tempest.js";
|
|
7
|
-
import { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, loadWindnerdHistory, loadWindnerdStation, parseStandardTimeOffset, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl } from "./adapters/windnerd.js";
|
|
8
|
-
import { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, loadWindnerdClimatology } from "./adapters/windnerd-climatology.js";
|
|
9
|
-
import { openWindnerdLive } from "./adapters/windnerd-live.js";
|
|
10
|
-
import { DEFAULT_HISTORY_HOURS, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive } from "./feed.js";
|
|
11
3
|
import { defineStationAdapter } from "./adapter.js";
|
|
12
|
-
import {
|
|
4
|
+
import { DEFAULT_HISTORY_HOURS, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive } from "./feed.js";
|
|
13
5
|
import { createStationFeedHandler } from "./handler.js";
|
|
6
|
+
import { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse } from "./live.js";
|
|
7
|
+
import { openWindnerdLive } from "./adapters/windnerd-live.js";
|
|
8
|
+
import { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, loadWindnerdClimatology } from "./adapters/windnerd-climatology.js";
|
|
9
|
+
import { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, loadWindnerdHistory, loadWindnerdStation, parseStandardTimeOffset, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl } from "./adapters/windnerd.js";
|
|
10
|
+
import { WINDNERD_RECORD_PERIODS_MINUTES, normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js";
|
|
14
11
|
import { HOLOGRAM_API_BASE, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadHologramConnectivity, parseHologramConnectivity } from "./hologram.js";
|
|
12
|
+
import { loadTempestStation, parseTempestWind } from "./adapters/tempest.js";
|
|
13
|
+
import { loadEcowittStation, parseEcowittRealTime } from "./adapters/ecowitt.js";
|
|
14
|
+
import { CAMPBELL_FIELD_CONTRACTS, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable } from "./adapters/campbell.js";
|
|
15
15
|
export { CAMPBELL_FIELD_CONTRACTS, CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, DEFAULT_HISTORY_HOURS, DEFAULT_USER_AGENT, HOLOGRAM_API_BASE, STATION_LIVE_SSE_HEADERS, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UnknownStationError, UpstreamError, WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WINDNERD_RECORD_PERIODS_MINUTES, assembleStations, boundedResponseText, campbellStationConfigSchema, coalesceUpstreamLoad, createStationFeedHandler, customStationConfigSchema, defineStationAdapter, ecowittStationConfigSchema, encodeStationLiveSse, fetchUpstreamStream, fetchUpstreamText, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadCampbellCurrent, loadCampbellStation, loadEcowittStation, loadHologramConnectivity, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, loadTempestStation, loadWindnerdClimatology, loadWindnerdHistory, loadWindnerdStation, logUpstreamFailure, memoryCache, naiveLocalToIso, normalizeWindnerdStationKey, openStationLive, openWindnerdLive, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable, parseEcowittRealTime, parseHologramConnectivity, parseStandardTimeOffset, parseStationConfig, parseTempestWind, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, resolveEnvironment, stationConfigSchema, tempestStationConfigSchema, unavailableReasonForError, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl, windnerdStationConfigSchema, windnerdStationUrl, workersCache };
|
package/dist/server/live.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StationLiveFrame } from "../contract.js";
|
|
2
|
-
|
|
3
|
-
declare const STATION_LIVE_SSE_HEADERS: {
|
|
2
|
+
export declare const STATION_LIVE_SSE_HEADERS: {
|
|
4
3
|
readonly "Content-Type": "text/event-stream; charset=utf-8";
|
|
5
4
|
readonly "Cache-Control": "no-cache, no-store";
|
|
6
5
|
readonly "X-Accel-Buffering": "no";
|
|
@@ -10,6 +9,4 @@ declare const STATION_LIVE_SSE_HEADERS: {
|
|
|
10
9
|
* vendor open call (openWindnerdLive) is the seam a host uses to serve live
|
|
11
10
|
* data through its own route or fan-out infrastructure.
|
|
12
11
|
*/
|
|
13
|
-
declare function encodeStationLiveSse(frames: ReadableStream<StationLiveFrame>): ReadableStream<Uint8Array>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse };
|
|
12
|
+
export declare function encodeStationLiveSse(frames: ReadableStream<StationLiveFrame>): ReadableStream<Uint8Array>;
|
package/dist/server/live.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/server/live.ts
|
|
2
2
|
const STATION_LIVE_SSE_HEADERS = {
|
|
3
3
|
"Content-Type": "text/event-stream; charset=utf-8",
|
|
4
4
|
"Cache-Control": "no-cache, no-store",
|
|
@@ -15,5 +15,4 @@ function encodeStationLiveSse(frames) {
|
|
|
15
15
|
controller.enqueue(encoder.encode(`data: ${JSON.stringify(frame)}\n\n`));
|
|
16
16
|
} }));
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse };
|
package/dist/sse.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/sse.ts
|
|
2
2
|
const DEFAULT_MAX_EVENT_BYTES = 262144;
|
|
3
3
|
async function* sseEvents(body, options = {}) {
|
|
4
4
|
const maxEventBytes = options.maxEventBytes ?? 262144;
|
|
@@ -52,5 +52,4 @@ async function* sseEvents(body, options = {}) {
|
|
|
52
52
|
await reader.cancel().catch(() => void 0);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
//#endregion
|
|
56
55
|
export { DEFAULT_MAX_EVENT_BYTES, sseEvents };
|
package/dist/strings.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UnavailableReason } from "./contract.js";
|
|
2
2
|
import { CompassPoint, FreshnessStatus, SpeedUnit } from "./derive.js";
|
|
3
|
-
|
|
4
|
-
type StationStrings = {
|
|
3
|
+
export type StationStrings = {
|
|
5
4
|
averageLabel: string;
|
|
6
5
|
avgLabel: string;
|
|
7
6
|
calm: string;
|
|
@@ -112,8 +111,8 @@ type StationStrings = {
|
|
|
112
111
|
trend: (stationName: string, seriesName: string) => string;
|
|
113
112
|
};
|
|
114
113
|
};
|
|
115
|
-
declare const defaultStrings: StationStrings;
|
|
116
|
-
type StationStringOverrides = Partial<Omit<StationStrings, "compassSpoken" | "updated" | "freshness" | "reasons" | "speedUnits" | "table" | "air" | "aria"> & {
|
|
114
|
+
export declare const defaultStrings: StationStrings;
|
|
115
|
+
export type StationStringOverrides = Partial<Omit<StationStrings, "compassSpoken" | "updated" | "freshness" | "reasons" | "speedUnits" | "table" | "air" | "aria"> & {
|
|
117
116
|
compassSpoken: Partial<StationStrings["compassSpoken"]>;
|
|
118
117
|
updated: Partial<StationStrings["updated"]>;
|
|
119
118
|
freshness: Partial<StationStrings["freshness"]>;
|
|
@@ -123,10 +122,8 @@ type StationStringOverrides = Partial<Omit<StationStrings, "compassSpoken" | "up
|
|
|
123
122
|
air: Partial<StationStrings["air"]>;
|
|
124
123
|
aria: Partial<StationStrings["aria"]>;
|
|
125
124
|
}>;
|
|
126
|
-
declare function resolveStrings(overrides?: StationStringOverrides): StationStrings;
|
|
127
|
-
declare function mergeStringOverrides(outer: StationStringOverrides | undefined, inner: StationStringOverrides | undefined): StationStringOverrides | undefined;
|
|
128
|
-
type FormatTime = (date: Date) => string;
|
|
129
|
-
declare function defaultFormatTime(date: Date): string;
|
|
130
|
-
declare function localeFormatTime(locale: string): FormatTime;
|
|
131
|
-
//#endregion
|
|
132
|
-
export { FormatTime, StationStringOverrides, StationStrings, defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings };
|
|
125
|
+
export declare function resolveStrings(overrides?: StationStringOverrides): StationStrings;
|
|
126
|
+
export declare function mergeStringOverrides(outer: StationStringOverrides | undefined, inner: StationStringOverrides | undefined): StationStringOverrides | undefined;
|
|
127
|
+
export type FormatTime = (date: Date) => string;
|
|
128
|
+
export declare function defaultFormatTime(date: Date): string;
|
|
129
|
+
export declare function localeFormatTime(locale: string): FormatTime;
|
package/dist/strings.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { speedUnitLabel } from "./derive.js";
|
|
2
|
-
|
|
2
|
+
// src/strings.ts
|
|
3
3
|
const defaultStrings = {
|
|
4
4
|
averageLabel: "Average",
|
|
5
5
|
avgLabel: "avg",
|
|
@@ -247,5 +247,4 @@ function localeFormatTime(locale) {
|
|
|
247
247
|
}
|
|
248
248
|
return format;
|
|
249
249
|
}
|
|
250
|
-
//#endregion
|
|
251
250
|
export { defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings };
|
package/dist/windnerd.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare function
|
|
5
|
-
declare function windnerdStationUrl(stationKey: string): string;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { WINDNERD_RECORD_PERIODS_MINUTES, WindnerdRecordPeriodMinutes, normalizeWindnerdStationKey, windnerdStationUrl };
|
|
1
|
+
export declare const WINDNERD_RECORD_PERIODS_MINUTES: readonly [1, 5, 10, 15, 30, 60, 180, 360];
|
|
2
|
+
export type WindnerdRecordPeriodMinutes = (typeof WINDNERD_RECORD_PERIODS_MINUTES)[number];
|
|
3
|
+
export declare function normalizeWindnerdStationKey(value: string | null | undefined): string | null;
|
|
4
|
+
export declare function windnerdStationUrl(stationKey: string): string;
|
package/dist/windnerd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/windnerd.ts
|
|
2
2
|
const WINDNERD_HOST = "windnerd.net";
|
|
3
3
|
const WINDNERD_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
4
4
|
const WINDNERD_RECORD_PERIODS_MINUTES = [
|
|
@@ -31,5 +31,4 @@ function windnerdStationUrl(stationKey) {
|
|
|
31
31
|
if (!WINDNERD_KEY.test(stationKey)) throw new Error("Invalid WindNerd station key.");
|
|
32
32
|
return `https://${WINDNERD_HOST}/en/${stationKey}`;
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { WINDNERD_RECORD_PERIODS_MINUTES, normalizeWindnerdStationKey, windnerdStationUrl };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azohra/meteo.station",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Live weather-station reading and display. A wire contract, provider adapters, a polling client, a Node server, and byte-identical React and custom-element display bindings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"weather-station",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"./package.json": "./package.json"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@azohra/meteo.core": "0.3.
|
|
66
|
+
"@azohra/meteo.core": "0.3.2",
|
|
67
67
|
"zod": "^4.6.7"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
@@ -75,15 +75,15 @@
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@testing-library/react": "^16.
|
|
79
|
-
"@types/node": "^22.
|
|
80
|
-
"@types/react": "^19.
|
|
81
|
-
"@types/react-dom": "^19.
|
|
82
|
-
"jsdom": "^
|
|
83
|
-
"react": "^19.
|
|
84
|
-
"react-dom": "^19.
|
|
78
|
+
"@testing-library/react": "^16.3.3",
|
|
79
|
+
"@types/node": "^22.20.5",
|
|
80
|
+
"@types/react": "^19.3.0",
|
|
81
|
+
"@types/react-dom": "^19.3.0",
|
|
82
|
+
"jsdom": "^31.0.1",
|
|
83
|
+
"react": "^19.3.1",
|
|
84
|
+
"react-dom": "^19.3.1",
|
|
85
85
|
"typescript": "^7.0.2",
|
|
86
|
-
"vitest": "^
|
|
86
|
+
"vitest": "^5.0.5"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": ">=22"
|