@azohra/meteo.station 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/client/climatology.d.ts +27 -0
  2. package/dist/client/climatology.js +83 -0
  3. package/dist/client/history.d.ts +47 -0
  4. package/dist/client/history.js +112 -0
  5. package/dist/client/index.d.ts +3 -1
  6. package/dist/client/index.js +3 -1
  7. package/dist/client/live.js +15 -0
  8. package/dist/climatology.d.ts +66 -0
  9. package/dist/climatology.js +230 -0
  10. package/dist/contract-climatology.d.ts +73 -0
  11. package/dist/contract-climatology.js +52 -0
  12. package/dist/contract.d.ts +234 -1
  13. package/dist/contract.js +52 -4
  14. package/dist/derive.d.ts +23 -1
  15. package/dist/derive.js +43 -4
  16. package/dist/display.d.ts +4 -0
  17. package/dist/display.js +2 -1
  18. package/dist/elements/elements/AirExtremesElement.d.ts +8 -0
  19. package/dist/elements/elements/AirExtremesElement.js +33 -0
  20. package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +15 -0
  21. package/dist/elements/elements/ClimatologyDailyPatternElement.js +84 -0
  22. package/dist/elements/elements/ClimatologyRoseElement.d.ts +14 -0
  23. package/dist/elements/elements/ClimatologyRoseElement.js +51 -0
  24. package/dist/elements/elements/CompassFanElement.d.ts +14 -0
  25. package/dist/elements/elements/CompassFanElement.js +92 -0
  26. package/dist/elements/elements/DailyPatternElement.d.ts +1 -0
  27. package/dist/elements/elements/DailyPatternElement.js +24 -16
  28. package/dist/elements/elements/DialElement.js +14 -3
  29. package/dist/elements/elements/FavorableShareElement.d.ts +14 -0
  30. package/dist/elements/elements/FavorableShareElement.js +47 -0
  31. package/dist/elements/elements/RecentSummariesElement.d.ts +14 -0
  32. package/dist/elements/elements/RecentSummariesElement.js +54 -0
  33. package/dist/elements/elements/StationFeedElement.d.ts +3 -0
  34. package/dist/elements/elements/StationFeedElement.js +13 -2
  35. package/dist/elements/elements/WindHistoryChartElement.js +20 -7
  36. package/dist/elements/elements/WindRoseElement.d.ts +1 -3
  37. package/dist/elements/elements/WindRoseElement.js +60 -62
  38. package/dist/elements/elements/atoms.js +3 -3
  39. package/dist/elements/index.d.ts +13 -1
  40. package/dist/elements/index.js +15 -3
  41. package/dist/elements/lib/ambient.d.ts +2 -0
  42. package/dist/elements/lib/attributes.js +24 -1
  43. package/dist/elements/lib/base.d.ts +3 -0
  44. package/dist/elements/lib/base.js +14 -2
  45. package/dist/endpoints.d.ts +7 -1
  46. package/dist/endpoints.js +13 -1
  47. package/dist/geometry.d.ts +23 -4
  48. package/dist/geometry.js +44 -13
  49. package/dist/index.d.ts +8 -6
  50. package/dist/index.js +8 -6
  51. package/dist/instruments.d.ts +7 -5
  52. package/dist/instruments.js +20 -7
  53. package/dist/merge-current.js +2 -1
  54. package/dist/react/components/AirExtremes.d.ts +16 -0
  55. package/dist/react/components/AirExtremes.js +38 -0
  56. package/dist/react/components/ClimatologyDailyPattern.d.ts +20 -0
  57. package/dist/react/components/ClimatologyDailyPattern.js +59 -0
  58. package/dist/react/components/ClimatologyRose.d.ts +18 -0
  59. package/dist/react/components/ClimatologyRose.js +45 -0
  60. package/dist/react/components/CompassFan.d.ts +17 -0
  61. package/dist/react/components/CompassFan.js +93 -0
  62. package/dist/react/components/DailyPattern.d.ts +4 -1
  63. package/dist/react/components/DailyPattern.js +15 -8
  64. package/dist/react/components/Dial.d.ts +3 -1
  65. package/dist/react/components/Dial.js +13 -2
  66. package/dist/react/components/FavorableShare.d.ts +14 -0
  67. package/dist/react/components/FavorableShare.js +43 -0
  68. package/dist/react/components/RecentSummaries.d.ts +18 -0
  69. package/dist/react/components/RecentSummaries.js +64 -0
  70. package/dist/react/components/StationFeedProvider.d.ts +4 -1
  71. package/dist/react/components/StationFeedProvider.js +5 -3
  72. package/dist/react/components/WindHistoryChart.d.ts +6 -1
  73. package/dist/react/components/WindHistoryChart.js +20 -5
  74. package/dist/react/components/WindRose.d.ts +4 -2
  75. package/dist/react/components/WindRose.js +80 -71
  76. package/dist/react/components/WindSampleStrip.d.ts +3 -1
  77. package/dist/react/components/WindSampleStrip.js +8 -5
  78. package/dist/react/components/atoms.d.ts +4 -1
  79. package/dist/react/components/atoms.js +6 -3
  80. package/dist/react/hooks/useStationClimatology.d.ts +18 -0
  81. package/dist/react/hooks/useStationClimatology.js +25 -0
  82. package/dist/react/index.d.ts +10 -3
  83. package/dist/react/index.js +9 -2
  84. package/dist/scene/air-extremes.d.ts +2 -0
  85. package/dist/scene/air-extremes.js +42 -0
  86. package/dist/scene/atoms.d.ts +2 -1
  87. package/dist/scene/atoms.js +6 -4
  88. package/dist/scene/climatology-pattern.d.ts +6 -0
  89. package/dist/scene/climatology-pattern.js +35 -0
  90. package/dist/scene/climatology-rose.d.ts +5 -0
  91. package/dist/scene/climatology-rose.js +49 -0
  92. package/dist/scene/compass-fan.d.ts +3 -0
  93. package/dist/scene/compass-fan.js +115 -0
  94. package/dist/scene/daily-pattern.d.ts +1 -0
  95. package/dist/scene/daily-pattern.js +21 -7
  96. package/dist/scene/dial.d.ts +1 -0
  97. package/dist/scene/dial.js +16 -3
  98. package/dist/scene/favorable-share.d.ts +3 -0
  99. package/dist/scene/favorable-share.js +41 -0
  100. package/dist/scene/index.d.ts +9 -3
  101. package/dist/scene/recent-summaries.d.ts +4 -0
  102. package/dist/scene/recent-summaries.js +75 -0
  103. package/dist/scene/rose.d.ts +2 -1
  104. package/dist/scene/rose.js +18 -3
  105. package/dist/scene/sample-strip.d.ts +1 -0
  106. package/dist/scene/sample-strip.js +1 -1
  107. package/dist/scene/trend.js +2 -7
  108. package/dist/scene/wind-history.d.ts +1 -0
  109. package/dist/scene/wind-history.js +4 -3
  110. package/dist/scene/wind-plot.d.ts +1 -0
  111. package/dist/scene/wind-plot.js +44 -9
  112. package/dist/server/adapter.d.ts +2 -1
  113. package/dist/server/adapter.js +2 -1
  114. package/dist/server/adapters/windnerd-climatology.d.ts +30 -0
  115. package/dist/server/adapters/windnerd-climatology.js +82 -0
  116. package/dist/server/adapters/windnerd-live.d.ts +5 -8
  117. package/dist/server/adapters/windnerd-live.js +26 -21
  118. package/dist/server/adapters/windnerd.d.ts +31 -4
  119. package/dist/server/adapters/windnerd.js +196 -19
  120. package/dist/server/environment.d.ts +4 -10
  121. package/dist/server/environment.js +4 -10
  122. package/dist/server/feed.d.ts +44 -2
  123. package/dist/server/feed.js +63 -2
  124. package/dist/server/handler.d.ts +11 -1
  125. package/dist/server/handler.js +83 -2
  126. package/dist/server/index.d.ts +4 -3
  127. package/dist/server/index.js +4 -3
  128. package/dist/strings.d.ts +13 -1
  129. package/dist/strings.js +13 -1
  130. package/package.json +2 -2
  131. package/schema/example-climatology.json +86 -0
  132. package/schema/example-history.json +38 -0
  133. package/schema/stationclimatology.schema.json +221 -0
  134. package/schema/stationcurrent.schema.json +173 -0
  135. package/schema/stationfeed.schema.json +173 -0
  136. package/schema/stationhistory.schema.json +186 -0
  137. package/schema/stationlive.schema.json +202 -0
  138. package/styles.css +232 -19
@@ -48,11 +48,8 @@ type UpstreamTextRequest = {
48
48
  * in-flight load. The load owns its own cache fill; this only deduplicates.
49
49
  */
50
50
  declare function coalesceUpstreamLoad(cache: FeedCache, key: string, load: () => Promise<string>): Promise<string>;
51
- /**
52
- * The one road to an upstream document: cache lookup, bounded fetch under a
53
- * timeout, cache fill. Concurrent misses on the same (cache instance,
54
- * cacheKey) coalesce onto a single in-flight load.
55
- */
51
+ /** Cache lookup, bounded fetch under a timeout, cache fill. Concurrent
52
+ * misses on one (cache instance, cacheKey) coalesce onto a single load. */
56
53
  declare function fetchUpstreamText(environment: ResolvedEnvironment, request: UpstreamTextRequest): Promise<string>;
57
54
  type UpstreamStreamRequest = {
58
55
  url: string | URL;
@@ -63,11 +60,8 @@ type UpstreamStreamRequest = {
63
60
  signal?: AbortSignal;
64
61
  };
65
62
  declare const UPSTREAM_CONNECT_TIMEOUT_MS = 10000;
66
- /**
67
- * The road to a long-lived upstream body. No cache and no byte cap — the
68
- * consumer bounds its own buffering — and never coalesced: every caller owns
69
- * its connection and tears it down through its signal.
70
- */
63
+ /** Long-lived upstream body: no cache, no byte cap, never coalesced —
64
+ * the caller owns the connection and tears it down through its signal. */
71
65
  declare function fetchUpstreamStream(environment: ResolvedEnvironment, request: UpstreamStreamRequest): Promise<Response>;
72
66
  declare function boundedResponseText(response: Response, limitBytes: number, subject: string): Promise<string>;
73
67
  declare function logUpstreamFailure(environment: ResolvedEnvironment, message: string, error: unknown, detail?: Record<string, unknown>): void;
@@ -87,11 +87,8 @@ function coalesceUpstreamLoad(cache, key, load) {
87
87
  pending.set(key, loading);
88
88
  return loading;
89
89
  }
90
- /**
91
- * The one road to an upstream document: cache lookup, bounded fetch under a
92
- * timeout, cache fill. Concurrent misses on the same (cache instance,
93
- * cacheKey) coalesce onto a single in-flight load.
94
- */
90
+ /** Cache lookup, bounded fetch under a timeout, cache fill. Concurrent
91
+ * misses on one (cache instance, cacheKey) coalesce onto a single load. */
95
92
  async function fetchUpstreamText(environment, request) {
96
93
  const cached = await environment.cache.get(request.cacheKey);
97
94
  if (cached != null) return cached;
@@ -126,11 +123,8 @@ async function loadUpstreamText(environment, request) {
126
123
  return text;
127
124
  }
128
125
  const UPSTREAM_CONNECT_TIMEOUT_MS = 1e4;
129
- /**
130
- * The road to a long-lived upstream body. No cache and no byte cap — the
131
- * consumer bounds its own buffering — and never coalesced: every caller owns
132
- * its connection and tears it down through its signal.
133
- */
126
+ /** Long-lived upstream body: no cache, no byte cap, never coalesced —
127
+ * the caller owns the connection and tears it down through its signal. */
134
128
  async function fetchUpstreamStream(environment, request) {
135
129
  const connect = new AbortController();
136
130
  const connectTimer = setTimeout(() => connect.abort(), request.connectTimeoutMs ?? 1e4);
@@ -1,4 +1,6 @@
1
- import { Station, StationCurrent, StationFeed, StationLiveFrame } from "../contract.js";
1
+ import { Station, StationCurrent, StationFeed, StationHistory, StationLiveFrame } from "../contract.js";
2
+ import { StationClimatology } from "../contract-climatology.js";
3
+ import { SpeedThresholds } from "../derive.js";
2
4
  import { ResolvedEnvironment, ServerEnvironment } from "./environment.js";
3
5
  import { StationConfig, StationConfigInput } from "./config.js";
4
6
  //#region src/server/feed.d.ts
@@ -37,6 +39,46 @@ type OpenStationLiveOptions = {
37
39
  * connection.
38
40
  */
39
41
  declare function openStationLive(options: OpenStationLiveOptions): Promise<ReadableStream<StationLiveFrame>>;
42
+ declare class StationHistoryUnsupportedError extends Error {
43
+ constructor(stationId: string);
44
+ }
45
+ type LoadStationHistoryOptions = {
46
+ stations: StationsInput;
47
+ stationId: string;
48
+ fromMs: number;
49
+ toMs: number;
50
+ periodMinutes: number;
51
+ environment?: ServerEnvironment;
52
+ request?: Request;
53
+ };
54
+ /**
55
+ * Loads one requested archive window for one configured station — the
56
+ * pan/zoom road. Unknown ids throw UnknownStationError; stations whose
57
+ * vendor keeps no reachable archive — and stations whose config failed
58
+ * validation — throw StationHistoryUnsupportedError.
59
+ */
60
+ declare function loadStationHistory(options: LoadStationHistoryOptions): Promise<StationHistory>;
61
+ declare class StationClimatologyUnsupportedError extends Error {
62
+ constructor(stationId: string);
63
+ }
64
+ type LoadStationClimatologyOptions = {
65
+ stations: StationsInput;
66
+ stationId: string;
67
+ /** The consumer's speed-band bounds — a judgment parameter, no default. */
68
+ thresholds: SpeedThresholds;
69
+ years?: number;
70
+ sectorCount?: number;
71
+ slotMinutes?: number;
72
+ environment?: ServerEnvironment;
73
+ request?: Request;
74
+ };
75
+ /**
76
+ * Builds the climatology document for one configured station. Unknown ids
77
+ * throw UnknownStationError; stations whose vendor keeps no reachable
78
+ * archive — and stations whose config failed validation — throw
79
+ * StationClimatologyUnsupportedError.
80
+ */
81
+ declare function loadStationClimatology(options: LoadStationClimatologyOptions): Promise<StationClimatology>;
40
82
  declare function loadStationFeed(options: LoadStationFeedOptions): Promise<StationFeed>;
41
83
  declare function loadStationCurrent(options: LoadStationCurrentOptions): Promise<StationCurrent>;
42
84
  type AssembledStation = {
@@ -46,4 +88,4 @@ type AssembledStation = {
46
88
  };
47
89
  declare function assembleStations(candidates: StationConfigInput[], environment: ResolvedEnvironment): AssembledStation[];
48
90
  //#endregion
49
- export { DEFAULT_HISTORY_HOURS, LoadStationCurrentOptions, LoadStationFeedOptions, OpenStationLiveOptions, StationLiveUnsupportedError, StationsInput, StationsResolver, UnknownStationError, assembleStations, loadStationCurrent, loadStationFeed, openStationLive };
91
+ export { DEFAULT_HISTORY_HOURS, LoadStationClimatologyOptions, LoadStationCurrentOptions, LoadStationFeedOptions, LoadStationHistoryOptions, OpenStationLiveOptions, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, StationsInput, StationsResolver, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive };
@@ -4,7 +4,8 @@ import { stationConfigSchema } from "./config.js";
4
4
  import { loadCampbellStation } from "./adapters/campbell.js";
5
5
  import { loadEcowittStation } from "./adapters/ecowitt.js";
6
6
  import { loadTempestStation } from "./adapters/tempest.js";
7
- import { loadWindnerdStation } from "./adapters/windnerd.js";
7
+ import { loadWindnerdHistory, loadWindnerdStation } from "./adapters/windnerd.js";
8
+ import { loadWindnerdClimatology } from "./adapters/windnerd-climatology.js";
8
9
  import { openWindnerdLive } from "./adapters/windnerd-live.js";
9
10
  //#region src/server/feed.ts
10
11
  const DEFAULT_HISTORY_HOURS = 6;
@@ -40,6 +41,66 @@ async function openStationLive(options) {
40
41
  signal: options.signal
41
42
  });
42
43
  }
44
+ var StationHistoryUnsupportedError = class extends Error {
45
+ constructor(stationId) {
46
+ super(`station "${stationId}" has no browsable archive`);
47
+ this.name = "StationHistoryUnsupportedError";
48
+ }
49
+ };
50
+ /**
51
+ * Loads one requested archive window for one configured station — the
52
+ * pan/zoom road. Unknown ids throw UnknownStationError; stations whose
53
+ * vendor keeps no reachable archive — and stations whose config failed
54
+ * validation — throw StationHistoryUnsupportedError.
55
+ */
56
+ async function loadStationHistory(options) {
57
+ const environment = resolveEnvironment(options.environment);
58
+ const entry = assembleStations(await resolveStations({
59
+ stations: options.stations,
60
+ request: options.request
61
+ }, environment), environment).find((candidate) => ("config" in candidate ? candidate.config.id : candidate.degraded.id) === options.stationId);
62
+ if (!entry) throw new UnknownStationError(options.stationId);
63
+ if ("degraded" in entry || entry.config.vendor !== "windnerd") throw new StationHistoryUnsupportedError(options.stationId);
64
+ const history = await loadWindnerdHistory(entry.config, {
65
+ fromMs: options.fromMs,
66
+ toMs: options.toMs,
67
+ periodMinutes: options.periodMinutes
68
+ }, { environment });
69
+ return {
70
+ schemaVersion: 2,
71
+ servedAt: environment.now().toISOString(),
72
+ stationId: options.stationId,
73
+ history
74
+ };
75
+ }
76
+ var StationClimatologyUnsupportedError = class extends Error {
77
+ constructor(stationId) {
78
+ super(`station "${stationId}" has no climatology archive`);
79
+ this.name = "StationClimatologyUnsupportedError";
80
+ }
81
+ };
82
+ /**
83
+ * Builds the climatology document for one configured station. Unknown ids
84
+ * throw UnknownStationError; stations whose vendor keeps no reachable
85
+ * archive — and stations whose config failed validation — throw
86
+ * StationClimatologyUnsupportedError.
87
+ */
88
+ async function loadStationClimatology(options) {
89
+ const environment = resolveEnvironment(options.environment);
90
+ const entry = assembleStations(await resolveStations({
91
+ stations: options.stations,
92
+ request: options.request
93
+ }, environment), environment).find((candidate) => ("config" in candidate ? candidate.config.id : candidate.degraded.id) === options.stationId);
94
+ if (!entry) throw new UnknownStationError(options.stationId);
95
+ if ("degraded" in entry || entry.config.vendor !== "windnerd") throw new StationClimatologyUnsupportedError(options.stationId);
96
+ return loadWindnerdClimatology(entry.config, {
97
+ thresholds: options.thresholds,
98
+ years: options.years,
99
+ sectorCount: options.sectorCount,
100
+ slotMinutes: options.slotMinutes,
101
+ environment
102
+ });
103
+ }
43
104
  async function loadStationFeed(options) {
44
105
  const environment = resolveEnvironment(options.environment);
45
106
  const assembled = assembleStations(await resolveStations(options, environment), environment);
@@ -246,4 +307,4 @@ function neverThrewButDid(config, environment, error) {
246
307
  return unavailableStation(configFallbackMeta(config), "contract_break");
247
308
  }
248
309
  //#endregion
249
- export { DEFAULT_HISTORY_HOURS, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationCurrent, loadStationFeed, openStationLive };
310
+ export { DEFAULT_HISTORY_HOURS, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive };
@@ -1,7 +1,8 @@
1
+ import { SpeedThresholds } from "../derive.js";
1
2
  import { ServerEnvironment } from "./environment.js";
2
3
  import { StationsInput } from "./feed.js";
3
4
  //#region src/server/handler.d.ts
4
- type StationFeedHandlerRoute = "feed" | "current" | "live";
5
+ type StationFeedHandlerRoute = "feed" | "current" | "live" | "climatology" | "history";
5
6
  type StationFeedHandlerOptions = {
6
7
  stations: StationsInput;
7
8
  primaryStationId?: string;
@@ -9,6 +10,15 @@ type StationFeedHandlerOptions = {
9
10
  basePath?: string;
10
11
  cors?: boolean | string;
11
12
  cacheControl?: string | ((route: StationFeedHandlerRoute, maxAgeSeconds: number) => string);
13
+ /** Mounting the /climatology route is the host's judgment call: the
14
+ * thresholds that bin every stack come from here, no default. Absent,
15
+ * the route answers 404. */
16
+ climatology?: {
17
+ thresholds: SpeedThresholds;
18
+ years?: number;
19
+ sectorCount?: number;
20
+ slotMinutes?: number;
21
+ };
12
22
  environment?: ServerEnvironment;
13
23
  };
14
24
  type StationFeedHandler = (request: Request) => Promise<Response>;
@@ -1,7 +1,11 @@
1
1
  import { resolveEnvironment, unavailableReasonForError } from "./environment.js";
2
- import { StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationCurrent, loadStationFeed, openStationLive } from "./feed.js";
2
+ import { StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive } from "./feed.js";
3
3
  import { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse } from "./live.js";
4
4
  //#region src/server/handler.ts
5
+ const CLIMATOLOGY_CACHE_SECONDS = 21600;
6
+ const HISTORY_PAST_CACHE_SECONDS = 86400;
7
+ const HISTORY_LIVE_CACHE_SECONDS = 60;
8
+ const HISTORY_MAX_POINTS = 4e3;
5
9
  const ALLOWED_METHODS = "GET, HEAD, OPTIONS";
6
10
  function createStationFeedHandler(options) {
7
11
  const environment = resolveEnvironment(options.environment);
@@ -54,8 +58,85 @@ function createStationFeedHandler(options) {
54
58
  });
55
59
  const url = new URL(request.url);
56
60
  const pathname = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
57
- const route = basePath != null ? pathname === `${basePath}/feed` ? "feed" : pathname === `${basePath}/current` ? "current" : pathname === `${basePath}/live` ? "live" : null : pathname.endsWith("/feed") ? "feed" : pathname.endsWith("/current") ? "current" : pathname.endsWith("/live") ? "live" : null;
61
+ const route = basePath != null ? pathname === `${basePath}/feed` ? "feed" : pathname === `${basePath}/current` ? "current" : pathname === `${basePath}/live` ? "live" : pathname === `${basePath}/climatology` ? "climatology" : pathname === `${basePath}/history` ? "history" : null : pathname.endsWith("/feed") ? "feed" : pathname.endsWith("/current") ? "current" : pathname.endsWith("/live") ? "live" : pathname.endsWith("/climatology") ? "climatology" : pathname.endsWith("/history") ? "history" : null;
58
62
  if (!route) return respond({ error: "not found" }, 404);
63
+ if (route === "history") {
64
+ const stationId = url.searchParams.get("station");
65
+ if (!stationId) return respond({ error: "missing station parameter" }, 400);
66
+ const fromMs = Date.parse(url.searchParams.get("from") ?? "");
67
+ const toMs = Date.parse(url.searchParams.get("to") ?? "");
68
+ const periodMinutes = Number(url.searchParams.get("period"));
69
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || fromMs >= toMs) return respond({ error: "invalid window: from and to must be ISO times, from < to" }, 400);
70
+ if (!Number.isFinite(periodMinutes) || periodMinutes <= 0) return respond({ error: "invalid period: expected positive minutes" }, 400);
71
+ if ((toMs - fromMs) / (periodMinutes * 6e4) > HISTORY_MAX_POINTS) return respond({ error: `window too fine: over ${HISTORY_MAX_POINTS} points — widen the period` }, 400);
72
+ let document;
73
+ try {
74
+ document = await loadStationHistory({
75
+ stations: options.stations,
76
+ stationId,
77
+ fromMs,
78
+ toMs,
79
+ periodMinutes,
80
+ environment: options.environment,
81
+ request
82
+ });
83
+ } catch (error) {
84
+ if (error instanceof UnknownStationError) return respond({ error: "unknown station" }, 404);
85
+ if (error instanceof StationHistoryUnsupportedError) return respond({ error: "station has no browsable archive" }, 404);
86
+ if (error instanceof Error && error.message.includes("periodMinutes")) return respond({ error: error.message }, 400);
87
+ return respond({
88
+ error: "history unavailable",
89
+ reason: unavailableReasonForError(error)
90
+ }, 502);
91
+ }
92
+ const headers = {
93
+ "Cache-Control": cacheControlFor("history", toMs <= Date.now() ? HISTORY_PAST_CACHE_SECONDS : HISTORY_LIVE_CACHE_SECONDS),
94
+ ETag: weakEtag({
95
+ schemaVersion: document.schemaVersion,
96
+ stationId: document.stationId,
97
+ history: document.history
98
+ })
99
+ };
100
+ if (etagMatches(request.headers.get("If-None-Match"), headers.ETag)) return notModified(headers);
101
+ return respond(document, 200, headers);
102
+ }
103
+ if (route === "climatology") {
104
+ if (options.climatology == null) return respond({ error: "climatology not configured" }, 404);
105
+ const stationId = url.searchParams.get("station");
106
+ if (!stationId) return respond({ error: "missing station parameter" }, 400);
107
+ let document;
108
+ try {
109
+ document = await loadStationClimatology({
110
+ stations: options.stations,
111
+ stationId,
112
+ thresholds: options.climatology.thresholds,
113
+ years: options.climatology.years,
114
+ sectorCount: options.climatology.sectorCount,
115
+ slotMinutes: options.climatology.slotMinutes,
116
+ environment: options.environment,
117
+ request
118
+ });
119
+ } catch (error) {
120
+ if (error instanceof UnknownStationError) return respond({ error: "unknown station" }, 404);
121
+ if (error instanceof StationClimatologyUnsupportedError) return respond({ error: "station has no climatology archive" }, 404);
122
+ return respond({
123
+ error: "climatology unavailable",
124
+ reason: unavailableReasonForError(error)
125
+ }, 502);
126
+ }
127
+ const headers = {
128
+ "Cache-Control": cacheControlFor("climatology", CLIMATOLOGY_CACHE_SECONDS),
129
+ ETag: weakEtag({
130
+ schemaVersion: document.schemaVersion,
131
+ stationId: document.stationId,
132
+ thresholdsMps: document.thresholdsMps,
133
+ years: document.years,
134
+ cells: document.cells
135
+ })
136
+ };
137
+ if (etagMatches(request.headers.get("If-None-Match"), headers.ETag)) return notModified(headers);
138
+ return respond(document, 200, headers);
139
+ }
59
140
  if (route === "live") {
60
141
  const stationId = url.searchParams.get("station");
61
142
  if (!stationId) return respond({ error: "missing station parameter" }, 400);
@@ -2,13 +2,14 @@ import { normalizeWindnerdStationKey, windnerdStationUrl } from "../windnerd.js"
2
2
  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
3
  import { CampbellStationConfig, CustomStationConfig, CustomStationContext, CustomStationIdentity, CustomStationLoader, EcowittStationConfig, StationConfig, StationConfigInput, TempestStationConfig, WindnerdStationConfig, campbellStationConfigSchema, customStationConfigSchema, ecowittStationConfigSchema, parseStationConfig, stationConfigSchema, tempestStationConfigSchema, windnerdStationConfigSchema } from "./config.js";
4
4
  import { StationAdapter, StationAdapterContext, StationAdapterDefinition, StationAdapterMode, StationAdapterOptions, StationAdapterResult, defineStationAdapter } from "./adapter.js";
5
- import { DEFAULT_HISTORY_HOURS, LoadStationCurrentOptions, LoadStationFeedOptions, OpenStationLiveOptions, StationLiveUnsupportedError, StationsInput, StationsResolver, UnknownStationError, assembleStations, loadStationCurrent, loadStationFeed, openStationLive } from "./feed.js";
5
+ import { DEFAULT_HISTORY_HOURS, LoadStationClimatologyOptions, LoadStationCurrentOptions, LoadStationFeedOptions, LoadStationHistoryOptions, OpenStationLiveOptions, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, StationsInput, StationsResolver, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive } from "./feed.js";
6
6
  import { StationFeedHandler, StationFeedHandlerOptions, StationFeedHandlerRoute, createStationFeedHandler } from "./handler.js";
7
7
  import { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse } from "./live.js";
8
8
  import { WindnerdLiveOptions, openWindnerdLive } from "./adapters/windnerd-live.js";
9
- import { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WindnerdAdapterOptions, WindnerdLiveDigest, WindnerdLiveInit, WindnerdLiveSampleRecord, WindnerdRecords, loadWindnerdStation, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveSampleRecords, parseWindnerdRecords, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl } from "./adapters/windnerd.js";
9
+ import { CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, WindnerdClimatologyOptions, loadWindnerdClimatology } from "./adapters/windnerd-climatology.js";
10
+ import { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WINDNERD_RECORD_PERIODS_MINUTES, WindnerdAdapterOptions, WindnerdHistoryQuery, WindnerdLiveDigest, WindnerdLiveInit, WindnerdLiveLocation, WindnerdLiveSampleRecord, WindnerdRecordPeriodMinutes, WindnerdRecords, loadWindnerdHistory, loadWindnerdStation, parseStandardTimeOffset, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveLocation, parseWindnerdLiveSampleRecords, parseWindnerdRecentSummaries, parseWindnerdRecords, windnerdEnrichedMeta, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl } from "./adapters/windnerd.js";
10
11
  import { HOLOGRAM_API_BASE, HologramConnectivityConfig, HologramConnectivityOptions, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadHologramConnectivity, parseHologramConnectivity } from "./hologram.js";
11
12
  import { TempestAdapterOptions, TempestObservation, loadTempestStation, parseTempestWind } from "./adapters/tempest.js";
12
13
  import { EcowittAdapterOptions, EcowittObservation, loadEcowittStation, parseEcowittRealTime } from "./adapters/ecowitt.js";
13
14
  import { CAMPBELL_FIELD_CONTRACTS, CampbellAdapterOptions, CampbellTable, CampbellTableExpectation, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable } from "./adapters/campbell.js";
14
- export { CAMPBELL_FIELD_CONTRACTS, type CampbellAdapterOptions, CampbellStationConfig, type CampbellTable, type CampbellTableExpectation, CustomStationConfig, CustomStationContext, CustomStationIdentity, CustomStationLoader, DEFAULT_HISTORY_HOURS, DEFAULT_USER_AGENT, type EcowittAdapterOptions, type EcowittObservation, EcowittStationConfig, FeedCache, HOLOGRAM_API_BASE, type HologramConnectivityConfig, type HologramConnectivityOptions, LoadStationCurrentOptions, LoadStationFeedOptions, LogEvent, LogEventCode, OpenStationLiveOptions, ResolvedEnvironment, STATION_LIVE_SSE_HEADERS, ServerEnvironment, StationAdapter, StationAdapterContext, StationAdapterDefinition, StationAdapterMode, StationAdapterOptions, StationAdapterResult, StationConfig, StationConfigInput, StationFeedHandler, StationFeedHandlerOptions, StationFeedHandlerRoute, StationLiveUnsupportedError, StationsInput, StationsResolver, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, type TempestAdapterOptions, type TempestObservation, TempestStationConfig, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UnknownStationError, UpstreamError, type UpstreamErrorReason, type UpstreamFailureReason, UpstreamStreamRequest, UpstreamTextRequest, WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, type WindnerdAdapterOptions, type WindnerdLiveDigest, type WindnerdLiveInit, type WindnerdLiveOptions, type WindnerdLiveSampleRecord, type WindnerdRecords, WindnerdStationConfig, assembleStations, boundedResponseText, campbellStationConfigSchema, coalesceUpstreamLoad, createStationFeedHandler, customStationConfigSchema, defineStationAdapter, ecowittStationConfigSchema, encodeStationLiveSse, fetchUpstreamStream, fetchUpstreamText, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadCampbellCurrent, loadCampbellStation, loadEcowittStation, loadHologramConnectivity, loadStationCurrent, loadStationFeed, loadTempestStation, loadWindnerdStation, logUpstreamFailure, memoryCache, naiveLocalToIso, normalizeWindnerdStationKey, openStationLive, openWindnerdLive, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable, parseEcowittRealTime, parseHologramConnectivity, parseStationConfig, parseTempestWind, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveSampleRecords, parseWindnerdRecords, resolveEnvironment, stationConfigSchema, tempestStationConfigSchema, unavailableReasonForError, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl, windnerdStationConfigSchema, windnerdStationUrl, workersCache };
15
+ export { CAMPBELL_FIELD_CONTRACTS, CLIMATOLOGY_DEFAULT_SECTOR_COUNT, CLIMATOLOGY_DEFAULT_YEARS, CLIMATOLOGY_RECORD_PERIOD_MINUTES, type CampbellAdapterOptions, CampbellStationConfig, type CampbellTable, type CampbellTableExpectation, CustomStationConfig, CustomStationContext, CustomStationIdentity, CustomStationLoader, DEFAULT_HISTORY_HOURS, DEFAULT_USER_AGENT, type EcowittAdapterOptions, type EcowittObservation, EcowittStationConfig, FeedCache, HOLOGRAM_API_BASE, type HologramConnectivityConfig, type HologramConnectivityOptions, LoadStationClimatologyOptions, LoadStationCurrentOptions, LoadStationFeedOptions, LoadStationHistoryOptions, LogEvent, LogEventCode, OpenStationLiveOptions, ResolvedEnvironment, STATION_LIVE_SSE_HEADERS, ServerEnvironment, StationAdapter, StationAdapterContext, StationAdapterDefinition, StationAdapterMode, StationAdapterOptions, StationAdapterResult, StationClimatologyUnsupportedError, StationConfig, StationConfigInput, StationFeedHandler, StationFeedHandlerOptions, StationFeedHandlerRoute, StationHistoryUnsupportedError, StationLiveUnsupportedError, StationsInput, StationsResolver, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, type TempestAdapterOptions, type TempestObservation, TempestStationConfig, UPSTREAM_CONNECT_TIMEOUT_MS, UPSTREAM_FAILURE_REASONS, UPSTREAM_FETCH_TIMEOUT_MS, UPSTREAM_RESPONSE_LIMIT_BYTES, UnknownStationError, UpstreamError, type UpstreamErrorReason, type UpstreamFailureReason, UpstreamStreamRequest, UpstreamTextRequest, WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WINDNERD_RECORD_PERIODS_MINUTES, type WindnerdAdapterOptions, type WindnerdClimatologyOptions, type WindnerdHistoryQuery, type WindnerdLiveDigest, type WindnerdLiveInit, type WindnerdLiveLocation, type WindnerdLiveOptions, type WindnerdLiveSampleRecord, type WindnerdRecordPeriodMinutes, type WindnerdRecords, WindnerdStationConfig, 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 };
@@ -4,11 +4,12 @@ import { campbellStationConfigSchema, customStationConfigSchema, ecowittStationC
4
4
  import { CAMPBELL_FIELD_CONTRACTS, loadCampbellCurrent, loadCampbellStation, naiveLocalToIso, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable } from "./adapters/campbell.js";
5
5
  import { loadEcowittStation, parseEcowittRealTime } from "./adapters/ecowitt.js";
6
6
  import { loadTempestStation, parseTempestWind } from "./adapters/tempest.js";
7
- import { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, loadWindnerdStation, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveSampleRecords, parseWindnerdRecords, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl } from "./adapters/windnerd.js";
7
+ import { WINDNERD_LIVE_SAMPLE_INTERVAL_SECONDS, WINDNERD_RECORD_PERIODS_MINUTES, 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";
8
9
  import { openWindnerdLive } from "./adapters/windnerd-live.js";
9
- import { DEFAULT_HISTORY_HOURS, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationCurrent, loadStationFeed, openStationLive } from "./feed.js";
10
+ import { DEFAULT_HISTORY_HOURS, StationClimatologyUnsupportedError, StationHistoryUnsupportedError, StationLiveUnsupportedError, UnknownStationError, assembleStations, loadStationClimatology, loadStationCurrent, loadStationFeed, loadStationHistory, openStationLive } from "./feed.js";
10
11
  import { defineStationAdapter } from "./adapter.js";
11
12
  import { STATION_LIVE_SSE_HEADERS, encodeStationLiveSse } from "./live.js";
12
13
  import { createStationFeedHandler } from "./handler.js";
13
14
  import { HOLOGRAM_API_BASE, TRIAL_HOLOGRAM_CACHE_TTL_SECONDS, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadHologramConnectivity, parseHologramConnectivity } from "./hologram.js";
14
- export { CAMPBELL_FIELD_CONTRACTS, DEFAULT_HISTORY_HOURS, DEFAULT_USER_AGENT, HOLOGRAM_API_BASE, STATION_LIVE_SSE_HEADERS, 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, assembleStations, boundedResponseText, campbellStationConfigSchema, coalesceUpstreamLoad, createStationFeedHandler, customStationConfigSchema, defineStationAdapter, ecowittStationConfigSchema, encodeStationLiveSse, fetchUpstreamStream, fetchUpstreamText, hologramConnectivityConfigSchema, hologramServiceState, hologramTimeToIso, loadCampbellCurrent, loadCampbellStation, loadEcowittStation, loadHologramConnectivity, loadStationCurrent, loadStationFeed, loadTempestStation, loadWindnerdStation, logUpstreamFailure, memoryCache, naiveLocalToIso, normalizeWindnerdStationKey, openStationLive, openWindnerdLive, parseCampbellCurrent, parseCampbellHistory, parseCampbellTable, parseEcowittRealTime, parseHologramConnectivity, parseStationConfig, parseTempestWind, parseWindnerdLiveDigest, parseWindnerdLiveInit, parseWindnerdLiveSampleRecords, parseWindnerdRecords, resolveEnvironment, stationConfigSchema, tempestStationConfigSchema, unavailableReasonForError, windnerdHistoryPoints, windnerdLiveReading, windnerdLiveSamples, windnerdLiveStreamUrl, windnerdStationConfigSchema, windnerdStationUrl, workersCache };
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/strings.d.ts CHANGED
@@ -27,8 +27,14 @@ type StationStrings = {
27
27
  elevation: (metres: number) => string;
28
28
  percentCalm: (percent: number) => string;
29
29
  percentShare: (percent: number) => string;
30
+ favorableLabel: string;
31
+ percentFavorable: (percent: number) => string;
32
+ noClimatology: string;
33
+ recentWindowLabel: (windowMinutes: number) => string;
34
+ lastNightLowLabel: string;
35
+ pressureDeltaLabel: (windowHours: number) => string;
30
36
  dailyPatternSamples: (sampleCount: number) => string;
31
- dailyPatternCoverage: (sampleCount: number, expectedCount: number) => string;
37
+ dailyPatternCoverage: (sampleCount: number, coveragePercent: number) => string;
32
38
  compassSpoken: Record<CompassPoint, string>;
33
39
  updated: {
34
40
  justNow: string;
@@ -89,11 +95,17 @@ type StationStrings = {
89
95
  dailyPattern: (stationName: string) => string;
90
96
  dailyPatternGeneric: string;
91
97
  direction: (spoken: string, deg: number) => string;
98
+ favorable: string;
99
+ unfavorable: string;
100
+ favorableShare: (stationName: string) => string;
92
101
  readout: (stationName: string) => string;
93
102
  rose: (stationName: string) => string;
94
103
  roseFavorable: (sectors: string) => string;
95
104
  roseGeneric: string;
96
105
  sampleStrip: (stationName: string) => string;
106
+ compassFan: (stationName: string) => string;
107
+ recentSummaries: (stationName: string) => string;
108
+ airExtremes: (stationName: string) => string;
97
109
  sparkline: (stationName: string) => string;
98
110
  strip: (stationName: string) => string;
99
111
  summary: (endedAtFormatted: string) => string;
package/dist/strings.js CHANGED
@@ -26,8 +26,14 @@ const defaultStrings = {
26
26
  elevation: (metres) => `${metres} m`,
27
27
  percentCalm: (percent) => `${percent}% calm`,
28
28
  percentShare: (percent) => `${percent}%`,
29
+ favorableLabel: "Favorable",
30
+ percentFavorable: (percent) => `${percent}% favorable`,
31
+ noClimatology: "No climatology available",
32
+ recentWindowLabel: (windowMinutes) => windowMinutes % 60 === 0 && windowMinutes >= 60 ? `Last ${windowMinutes / 60} h` : `Last ${windowMinutes} min`,
33
+ lastNightLowLabel: "Last night low",
34
+ pressureDeltaLabel: (windowHours) => `Pressure ${windowHours} h`,
29
35
  dailyPatternSamples: (sampleCount) => `${sampleCount} samples`,
30
- dailyPatternCoverage: (sampleCount, expectedCount) => `${sampleCount} samples · ${Math.round(sampleCount / Math.max(1, expectedCount) * 100)}%`,
36
+ dailyPatternCoverage: (sampleCount, coveragePercent) => `${sampleCount} samples · ${coveragePercent}%`,
31
37
  compassSpoken: {
32
38
  N: "north",
33
39
  NNE: "north-northeast",
@@ -120,11 +126,17 @@ const defaultStrings = {
120
126
  dailyPattern: (stationName) => `Typical day at ${stationName}, averaged across the full history`,
121
127
  dailyPatternGeneric: "Typical day, averaged across the full history",
122
128
  direction: (spoken, deg) => `from ${spoken}, ${deg} degrees`,
129
+ favorable: "a favorable direction",
130
+ unfavorable: "an unfavorable direction",
131
+ favorableShare: (stationName) => `Share of the non-calm wind at ${stationName} from a favorable direction`,
123
132
  readout: (stationName) => `Inspected reading at ${stationName}`,
124
133
  rose: (stationName) => `Wind direction distribution at ${stationName}`,
125
134
  roseFavorable: (sectors) => `The outer ring marks favorable directions: from ${sectors}.`,
126
135
  roseGeneric: "Wind direction distribution",
127
136
  sampleStrip: (stationName) => `Live wind at ${stationName}: each point is a single sample, and the vanes below point where the wind blew to.`,
137
+ compassFan: (stationName) => `Live compass at ${stationName}: the solid needle is the newest sample, the faint fan every sample of the window — a tight fan means steady direction.`,
138
+ recentSummaries: (stationName) => `Recent step summaries at ${stationName}`,
139
+ airExtremes: (stationName) => `Air extremes at ${stationName}`,
128
140
  sparkline: (stationName) => `six hours of wind at ${stationName}`,
129
141
  strip: (stationName) => `Latest reading at ${stationName}`,
130
142
  summary: (endedAtFormatted) => `Summary of the period ending ${endedAtFormatted}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azohra/meteo.station",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "The station capability of meteo by Azohra: live weather-station reading, derivation, and display - the wire contract, provider adapters, a polling client, a Node server, and React and custom-element display bindings.",
5
5
  "keywords": [
6
6
  "weather-station",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "zod": "^4.0.0",
67
- "@azohra/meteo.core": "0.1.1"
67
+ "@azohra/meteo.core": "0.2.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.0.0 || ^19.0.0"
@@ -0,0 +1,86 @@
1
+ {
2
+ "$comment": "Example @azohra/meteo.station climatology document. Validates against stationclimatology.schema.json; readers must ignore unknown keys (this one included). Cells nothing ever fell into are absent, never zero-filled; sums re-aggregate losslessly under any month/season/slot filter.",
3
+ "schemaVersion": 1,
4
+ "servedAt": "2026-08-05T22:13:00.000Z",
5
+ "stationId": "bluff",
6
+ "sectorCount": 16,
7
+ "slotMinutes": 180,
8
+ "thresholdsMps": [
9
+ 3.3333333333333335,
10
+ 5.555555555555555,
11
+ 7.777777777777778
12
+ ],
13
+ "utcOffsetMinutes": -480,
14
+ "years": [
15
+ {
16
+ "year": 2025,
17
+ "sampleCount": 2496,
18
+ "expectedCount": 2920
19
+ },
20
+ {
21
+ "year": 2026,
22
+ "sampleCount": 1704,
23
+ "expectedCount": 1736
24
+ }
25
+ ],
26
+ "cells": [
27
+ {
28
+ "month": 7,
29
+ "slot": 4,
30
+ "sampleCount": 58,
31
+ "calmCount": 11,
32
+ "sectors": [
33
+ {
34
+ "sector": 12,
35
+ "count": 31,
36
+ "uSum": 148.2033,
37
+ "vSum": -42.1188,
38
+ "speedSumMps": 167.4,
39
+ "bandCounts": [
40
+ 4,
41
+ 9,
42
+ 12,
43
+ 6
44
+ ],
45
+ "maxGustMps": 11.8
46
+ },
47
+ {
48
+ "sector": 13,
49
+ "count": 16,
50
+ "uSum": 61.077,
51
+ "vSum": -33.9414,
52
+ "speedSumMps": 72.1,
53
+ "bandCounts": [
54
+ 3,
55
+ 6,
56
+ 5,
57
+ 2
58
+ ],
59
+ "maxGustMps": 9.4
60
+ }
61
+ ]
62
+ },
63
+ {
64
+ "month": 7,
65
+ "slot": 5,
66
+ "sampleCount": 49,
67
+ "calmCount": 20,
68
+ "sectors": [
69
+ {
70
+ "sector": 12,
71
+ "count": 29,
72
+ "uSum": 101.9385,
73
+ "vSum": -28.9704,
74
+ "speedSumMps": 114.9,
75
+ "bandCounts": [
76
+ 8,
77
+ 11,
78
+ 8,
79
+ 2
80
+ ],
81
+ "maxGustMps": 10.2
82
+ }
83
+ ]
84
+ }
85
+ ]
86
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "$comment": "Example @azohra/meteo.station history-window document. Validates against stationhistory.schema.json; readers must ignore unknown keys (this one included).",
3
+ "schemaVersion": 2,
4
+ "servedAt": "2026-08-05T22:13:00.000Z",
5
+ "stationId": "bluff",
6
+ "history": {
7
+ "periodMinutes": 1,
8
+ "points": [
9
+ {
10
+ "observedAt": "2026-08-05T22:10:45.000Z",
11
+ "windAvgMps": 1.7,
12
+ "windGustMps": 2.2,
13
+ "windLullMps": 1.1,
14
+ "windDirectionDeg": 300,
15
+ "temperatureC": 20.2,
16
+ "seaLevelPressureHpa": 1007.7
17
+ },
18
+ {
19
+ "observedAt": "2026-08-05T22:11:45.000Z",
20
+ "windAvgMps": 3.3,
21
+ "windGustMps": 5.8,
22
+ "windLullMps": 1.9,
23
+ "windDirectionDeg": 310,
24
+ "temperatureC": null,
25
+ "seaLevelPressureHpa": null
26
+ },
27
+ {
28
+ "observedAt": "2026-08-05T22:12:45.000Z",
29
+ "windAvgMps": 2.5,
30
+ "windGustMps": 3.9,
31
+ "windLullMps": 1.7,
32
+ "windDirectionDeg": 290,
33
+ "temperatureC": 22.6,
34
+ "seaLevelPressureHpa": 1006.1
35
+ }
36
+ ]
37
+ }
38
+ }