@azohra/meteo.station 0.1.1 → 0.1.3

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 (47) hide show
  1. package/dist/client/index.d.ts +2 -1
  2. package/dist/client/index.js +2 -1
  3. package/dist/client/live.d.ts +37 -0
  4. package/dist/client/live.js +241 -0
  5. package/dist/client/stores.d.ts +1 -0
  6. package/dist/client/stores.js +41 -6
  7. package/dist/contract.d.ts +237 -1
  8. package/dist/contract.js +57 -3
  9. package/dist/endpoints.d.ts +2 -1
  10. package/dist/endpoints.js +4 -1
  11. package/dist/geometry.d.ts +4 -1
  12. package/dist/index.d.ts +5 -4
  13. package/dist/index.js +5 -4
  14. package/dist/react/hooks/useStation.d.ts +1 -0
  15. package/dist/react/hooks/useStation.js +25 -5
  16. package/dist/react/hooks/useStationLive.d.ts +20 -0
  17. package/dist/react/hooks/useStationLive.js +33 -0
  18. package/dist/react/index.d.ts +2 -1
  19. package/dist/react/index.js +2 -1
  20. package/dist/samples.d.ts +20 -0
  21. package/dist/samples.js +88 -0
  22. package/dist/server/adapter.d.ts +3 -1
  23. package/dist/server/adapter.js +3 -1
  24. package/dist/server/adapters/windnerd-live.d.ts +21 -0
  25. package/dist/server/adapters/windnerd-live.js +179 -0
  26. package/dist/server/adapters/windnerd.d.ts +36 -5
  27. package/dist/server/adapters/windnerd.js +177 -15
  28. package/dist/server/config.d.ts +2 -0
  29. package/dist/server/config.js +2 -1
  30. package/dist/server/environment.d.ts +25 -5
  31. package/dist/server/environment.js +65 -21
  32. package/dist/server/feed.d.ts +20 -2
  33. package/dist/server/feed.js +28 -1
  34. package/dist/server/handler.d.ts +1 -1
  35. package/dist/server/handler.js +37 -3
  36. package/dist/server/index.d.ts +6 -4
  37. package/dist/server/index.js +6 -4
  38. package/dist/server/live.d.ts +15 -0
  39. package/dist/server/live.js +19 -0
  40. package/dist/sse.js +56 -0
  41. package/package.json +1 -1
  42. package/schema/README.md +1 -1
  43. package/schema/example-feed.json +26 -1
  44. package/schema/example-live.json +74 -0
  45. package/schema/stationcurrent.schema.json +115 -0
  46. package/schema/stationfeed.schema.json +115 -0
  47. package/schema/stationlive.schema.json +868 -0
@@ -0,0 +1,868 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://meteo.azohra.com/schema/stationlive.schema.json",
4
+ "title": "StationLiveFrame",
5
+ "description": "One frame per SSE data event on the /live stream. init seeds a full station document; samples and reading update it; unavailable is terminal — the stream closes after it.",
6
+ "oneOf": [
7
+ {
8
+ "type": "object",
9
+ "properties": {
10
+ "type": {
11
+ "type": "string",
12
+ "const": "init"
13
+ },
14
+ "schemaVersion": {
15
+ "type": "number",
16
+ "const": 2
17
+ },
18
+ "servedAt": {
19
+ "type": "string",
20
+ "format": "date-time"
21
+ },
22
+ "station": {
23
+ "$ref": "#/$defs/Station"
24
+ }
25
+ },
26
+ "required": [
27
+ "type",
28
+ "schemaVersion",
29
+ "servedAt",
30
+ "station"
31
+ ]
32
+ },
33
+ {
34
+ "type": "object",
35
+ "properties": {
36
+ "type": {
37
+ "type": "string",
38
+ "const": "samples"
39
+ },
40
+ "stationId": {
41
+ "type": "string",
42
+ "minLength": 1
43
+ },
44
+ "samples": {
45
+ "$ref": "#/$defs/LiveSamples"
46
+ }
47
+ },
48
+ "required": [
49
+ "type",
50
+ "stationId",
51
+ "samples"
52
+ ]
53
+ },
54
+ {
55
+ "type": "object",
56
+ "properties": {
57
+ "type": {
58
+ "type": "string",
59
+ "const": "reading"
60
+ },
61
+ "stationId": {
62
+ "type": "string",
63
+ "minLength": 1
64
+ },
65
+ "servedAt": {
66
+ "type": "string",
67
+ "format": "date-time"
68
+ },
69
+ "reading": {
70
+ "$ref": "#/$defs/Reading"
71
+ },
72
+ "telemetry": {
73
+ "anyOf": [
74
+ {
75
+ "$ref": "#/$defs/StationTelemetry"
76
+ },
77
+ {
78
+ "type": "null"
79
+ }
80
+ ]
81
+ }
82
+ },
83
+ "required": [
84
+ "type",
85
+ "stationId",
86
+ "servedAt",
87
+ "reading",
88
+ "telemetry"
89
+ ]
90
+ },
91
+ {
92
+ "type": "object",
93
+ "properties": {
94
+ "type": {
95
+ "type": "string",
96
+ "const": "ping"
97
+ },
98
+ "servedAt": {
99
+ "type": "string",
100
+ "format": "date-time"
101
+ }
102
+ },
103
+ "required": [
104
+ "type",
105
+ "servedAt"
106
+ ]
107
+ },
108
+ {
109
+ "type": "object",
110
+ "properties": {
111
+ "type": {
112
+ "type": "string",
113
+ "const": "unavailable"
114
+ },
115
+ "stationId": {
116
+ "type": "string",
117
+ "minLength": 1
118
+ },
119
+ "reason": {
120
+ "type": "string",
121
+ "enum": [
122
+ "upstream_error",
123
+ "timeout",
124
+ "rate_limited",
125
+ "contract_break",
126
+ "not_configured"
127
+ ]
128
+ }
129
+ },
130
+ "required": [
131
+ "type",
132
+ "stationId",
133
+ "reason"
134
+ ]
135
+ }
136
+ ],
137
+ "$defs": {
138
+ "Station": {
139
+ "oneOf": [
140
+ {
141
+ "type": "object",
142
+ "properties": {
143
+ "id": {
144
+ "type": "string",
145
+ "minLength": 1
146
+ },
147
+ "name": {
148
+ "type": "string",
149
+ "minLength": 1
150
+ },
151
+ "sourceLabel": {
152
+ "type": "string"
153
+ },
154
+ "pageUrl": {
155
+ "anyOf": [
156
+ {
157
+ "type": "string"
158
+ },
159
+ {
160
+ "type": "null"
161
+ }
162
+ ]
163
+ },
164
+ "latitude": {
165
+ "anyOf": [
166
+ {
167
+ "type": "number",
168
+ "minimum": -90,
169
+ "maximum": 90
170
+ },
171
+ {
172
+ "type": "null"
173
+ }
174
+ ]
175
+ },
176
+ "longitude": {
177
+ "anyOf": [
178
+ {
179
+ "type": "number",
180
+ "minimum": -180,
181
+ "exclusiveMaximum": 180
182
+ },
183
+ {
184
+ "type": "null"
185
+ }
186
+ ]
187
+ },
188
+ "timeZone": {
189
+ "anyOf": [
190
+ {
191
+ "type": "string",
192
+ "minLength": 1
193
+ },
194
+ {
195
+ "type": "null"
196
+ }
197
+ ]
198
+ },
199
+ "elevationM": {
200
+ "anyOf": [
201
+ {
202
+ "type": "number"
203
+ },
204
+ {
205
+ "type": "null"
206
+ }
207
+ ]
208
+ },
209
+ "capabilities": {
210
+ "$ref": "#/$defs/StationCapabilities"
211
+ },
212
+ "samplingWindowSeconds": {
213
+ "anyOf": [
214
+ {
215
+ "type": "number",
216
+ "exclusiveMinimum": 0
217
+ },
218
+ {
219
+ "type": "null"
220
+ }
221
+ ]
222
+ },
223
+ "recommendedPollSeconds": {
224
+ "type": "number",
225
+ "exclusiveMinimum": 0
226
+ },
227
+ "status": {
228
+ "type": "string",
229
+ "const": "ok"
230
+ },
231
+ "reading": {
232
+ "$ref": "#/$defs/Reading"
233
+ },
234
+ "history": {
235
+ "anyOf": [
236
+ {
237
+ "$ref": "#/$defs/History"
238
+ },
239
+ {
240
+ "type": "null"
241
+ }
242
+ ]
243
+ },
244
+ "telemetry": {
245
+ "anyOf": [
246
+ {
247
+ "$ref": "#/$defs/StationTelemetry"
248
+ },
249
+ {
250
+ "type": "null"
251
+ }
252
+ ]
253
+ },
254
+ "samples": {
255
+ "anyOf": [
256
+ {
257
+ "$ref": "#/$defs/LiveSamples"
258
+ },
259
+ {
260
+ "type": "null"
261
+ }
262
+ ]
263
+ }
264
+ },
265
+ "required": [
266
+ "id",
267
+ "name",
268
+ "sourceLabel",
269
+ "pageUrl",
270
+ "latitude",
271
+ "longitude",
272
+ "timeZone",
273
+ "elevationM",
274
+ "capabilities",
275
+ "samplingWindowSeconds",
276
+ "recommendedPollSeconds",
277
+ "status",
278
+ "reading",
279
+ "history"
280
+ ]
281
+ },
282
+ {
283
+ "type": "object",
284
+ "properties": {
285
+ "id": {
286
+ "type": "string",
287
+ "minLength": 1
288
+ },
289
+ "name": {
290
+ "type": "string",
291
+ "minLength": 1
292
+ },
293
+ "sourceLabel": {
294
+ "type": "string"
295
+ },
296
+ "pageUrl": {
297
+ "anyOf": [
298
+ {
299
+ "type": "string"
300
+ },
301
+ {
302
+ "type": "null"
303
+ }
304
+ ]
305
+ },
306
+ "latitude": {
307
+ "anyOf": [
308
+ {
309
+ "type": "number",
310
+ "minimum": -90,
311
+ "maximum": 90
312
+ },
313
+ {
314
+ "type": "null"
315
+ }
316
+ ]
317
+ },
318
+ "longitude": {
319
+ "anyOf": [
320
+ {
321
+ "type": "number",
322
+ "minimum": -180,
323
+ "exclusiveMaximum": 180
324
+ },
325
+ {
326
+ "type": "null"
327
+ }
328
+ ]
329
+ },
330
+ "timeZone": {
331
+ "anyOf": [
332
+ {
333
+ "type": "string",
334
+ "minLength": 1
335
+ },
336
+ {
337
+ "type": "null"
338
+ }
339
+ ]
340
+ },
341
+ "elevationM": {
342
+ "anyOf": [
343
+ {
344
+ "type": "number"
345
+ },
346
+ {
347
+ "type": "null"
348
+ }
349
+ ]
350
+ },
351
+ "capabilities": {
352
+ "$ref": "#/$defs/StationCapabilities"
353
+ },
354
+ "samplingWindowSeconds": {
355
+ "anyOf": [
356
+ {
357
+ "type": "number",
358
+ "exclusiveMinimum": 0
359
+ },
360
+ {
361
+ "type": "null"
362
+ }
363
+ ]
364
+ },
365
+ "recommendedPollSeconds": {
366
+ "type": "number",
367
+ "exclusiveMinimum": 0
368
+ },
369
+ "status": {
370
+ "type": "string",
371
+ "const": "unavailable"
372
+ },
373
+ "reason": {
374
+ "type": "string",
375
+ "enum": [
376
+ "upstream_error",
377
+ "timeout",
378
+ "rate_limited",
379
+ "contract_break",
380
+ "not_configured"
381
+ ]
382
+ },
383
+ "reading": {
384
+ "type": "null"
385
+ },
386
+ "history": {
387
+ "type": "null"
388
+ }
389
+ },
390
+ "required": [
391
+ "id",
392
+ "name",
393
+ "sourceLabel",
394
+ "pageUrl",
395
+ "latitude",
396
+ "longitude",
397
+ "timeZone",
398
+ "elevationM",
399
+ "capabilities",
400
+ "samplingWindowSeconds",
401
+ "recommendedPollSeconds",
402
+ "status",
403
+ "reason",
404
+ "reading",
405
+ "history"
406
+ ]
407
+ }
408
+ ]
409
+ },
410
+ "StationCapabilities": {
411
+ "type": "object",
412
+ "properties": {
413
+ "gustLull": {
414
+ "type": "boolean"
415
+ },
416
+ "temperature": {
417
+ "type": "boolean"
418
+ },
419
+ "conditions": {
420
+ "type": "boolean"
421
+ },
422
+ "history": {
423
+ "type": "boolean"
424
+ },
425
+ "live": {
426
+ "description": "The station has a live sample stream; absent or null reads as false.",
427
+ "anyOf": [
428
+ {
429
+ "type": "boolean"
430
+ },
431
+ {
432
+ "type": "null"
433
+ }
434
+ ]
435
+ },
436
+ "battery": {
437
+ "description": "The station reports battery telemetry; absent or null reads as false.",
438
+ "anyOf": [
439
+ {
440
+ "type": "boolean"
441
+ },
442
+ {
443
+ "type": "null"
444
+ }
445
+ ]
446
+ }
447
+ },
448
+ "required": [
449
+ "gustLull",
450
+ "temperature",
451
+ "conditions",
452
+ "history"
453
+ ],
454
+ "description": "Declared from what the hardware carries, never inferred from data. Capabilities gate client UI structure; a dark sensor keeps its structure and reports null."
455
+ },
456
+ "Reading": {
457
+ "type": "object",
458
+ "properties": {
459
+ "observedAt": {
460
+ "type": "string",
461
+ "format": "date-time"
462
+ },
463
+ "windAvgMps": {
464
+ "type": "number",
465
+ "minimum": 0,
466
+ "description": "Wind speed in m/s, averaged over samplingWindowSeconds. Absence is null, never zero."
467
+ },
468
+ "windDirectionDeg": {
469
+ "anyOf": [
470
+ {
471
+ "type": "number",
472
+ "minimum": 0,
473
+ "exclusiveMaximum": 360
474
+ },
475
+ {
476
+ "type": "null"
477
+ }
478
+ ],
479
+ "description": "Bearing the wind blows FROM, degrees [0, 360). null exactly when calm (windAvgMps below the WMO 0.5 m/s threshold) — calm carries no direction; a null on a blowing reading is a dead vane."
480
+ },
481
+ "windGustMps": {
482
+ "anyOf": [
483
+ {
484
+ "type": "number",
485
+ "minimum": 0
486
+ },
487
+ {
488
+ "type": "null"
489
+ }
490
+ ],
491
+ "description": "Peak m/s within the sampling window; null ≠ zero."
492
+ },
493
+ "windLullMps": {
494
+ "anyOf": [
495
+ {
496
+ "type": "number",
497
+ "minimum": 0
498
+ },
499
+ {
500
+ "type": "null"
501
+ }
502
+ ],
503
+ "description": "Minimum m/s within the sampling window; null ≠ zero."
504
+ },
505
+ "temperatureC": {
506
+ "anyOf": [
507
+ {
508
+ "type": "number"
509
+ },
510
+ {
511
+ "type": "null"
512
+ }
513
+ ]
514
+ },
515
+ "windChillC": {
516
+ "anyOf": [
517
+ {
518
+ "type": "number"
519
+ },
520
+ {
521
+ "type": "null"
522
+ }
523
+ ]
524
+ },
525
+ "conditions": {
526
+ "anyOf": [
527
+ {
528
+ "$ref": "#/$defs/AirConditions"
529
+ },
530
+ {
531
+ "type": "null"
532
+ }
533
+ ]
534
+ }
535
+ },
536
+ "required": [
537
+ "observedAt",
538
+ "windAvgMps",
539
+ "windDirectionDeg",
540
+ "windGustMps",
541
+ "windLullMps",
542
+ "temperatureC",
543
+ "windChillC",
544
+ "conditions"
545
+ ]
546
+ },
547
+ "AirConditions": {
548
+ "type": "object",
549
+ "properties": {
550
+ "dewPointC": {
551
+ "anyOf": [
552
+ {
553
+ "type": "number"
554
+ },
555
+ {
556
+ "type": "null"
557
+ }
558
+ ]
559
+ },
560
+ "lastLightningStrikeAt": {
561
+ "anyOf": [
562
+ {
563
+ "type": "string",
564
+ "format": "date-time"
565
+ },
566
+ {
567
+ "type": "null"
568
+ }
569
+ ]
570
+ },
571
+ "lastLightningStrikeDistanceKm": {
572
+ "anyOf": [
573
+ {
574
+ "type": "number"
575
+ },
576
+ {
577
+ "type": "null"
578
+ }
579
+ ]
580
+ },
581
+ "lightningStrikeCountLastHour": {
582
+ "anyOf": [
583
+ {
584
+ "type": "number"
585
+ },
586
+ {
587
+ "type": "null"
588
+ }
589
+ ]
590
+ },
591
+ "precipitationMinutesToday": {
592
+ "anyOf": [
593
+ {
594
+ "type": "number"
595
+ },
596
+ {
597
+ "type": "null"
598
+ }
599
+ ]
600
+ },
601
+ "precipitationRateMmPerHour": {
602
+ "anyOf": [
603
+ {
604
+ "type": "number"
605
+ },
606
+ {
607
+ "type": "null"
608
+ }
609
+ ]
610
+ },
611
+ "precipitationTodayMm": {
612
+ "anyOf": [
613
+ {
614
+ "type": "number"
615
+ },
616
+ {
617
+ "type": "null"
618
+ }
619
+ ]
620
+ },
621
+ "pressureTrend": {
622
+ "anyOf": [
623
+ {
624
+ "type": "string",
625
+ "enum": [
626
+ "falling",
627
+ "rising",
628
+ "steady",
629
+ "unknown"
630
+ ]
631
+ },
632
+ {
633
+ "type": "null"
634
+ }
635
+ ]
636
+ },
637
+ "relativeHumidityPercent": {
638
+ "anyOf": [
639
+ {
640
+ "type": "number"
641
+ },
642
+ {
643
+ "type": "null"
644
+ }
645
+ ]
646
+ },
647
+ "seaLevelPressureHpa": {
648
+ "anyOf": [
649
+ {
650
+ "type": "number"
651
+ },
652
+ {
653
+ "type": "null"
654
+ }
655
+ ]
656
+ },
657
+ "solarRadiationWm2": {
658
+ "anyOf": [
659
+ {
660
+ "type": "number"
661
+ },
662
+ {
663
+ "type": "null"
664
+ }
665
+ ]
666
+ },
667
+ "uvIndex": {
668
+ "anyOf": [
669
+ {
670
+ "type": "number",
671
+ "minimum": 0
672
+ },
673
+ {
674
+ "type": "null"
675
+ }
676
+ ]
677
+ }
678
+ },
679
+ "required": [
680
+ "dewPointC",
681
+ "lastLightningStrikeAt",
682
+ "lastLightningStrikeDistanceKm",
683
+ "lightningStrikeCountLastHour",
684
+ "precipitationMinutesToday",
685
+ "precipitationRateMmPerHour",
686
+ "precipitationTodayMm",
687
+ "pressureTrend",
688
+ "relativeHumidityPercent",
689
+ "seaLevelPressureHpa",
690
+ "solarRadiationWm2",
691
+ "uvIndex"
692
+ ],
693
+ "description": "Extended air data. null means 'not reported here' — it does not distinguish a missing sensor from a dark one; the station-level conditions capability gates whether a client allocates UI structure."
694
+ },
695
+ "History": {
696
+ "type": "object",
697
+ "properties": {
698
+ "periodMinutes": {
699
+ "type": "number",
700
+ "exclusiveMinimum": 0,
701
+ "description": "Minutes each point covers. Wind run, vane thinning, and dropout detection are functions of it."
702
+ },
703
+ "points": {
704
+ "type": "array",
705
+ "items": {
706
+ "$ref": "#/$defs/HistoryPoint"
707
+ },
708
+ "description": "A dropout is an ABSENT record, never a zeroed one — gaps carry no points."
709
+ }
710
+ },
711
+ "required": [
712
+ "periodMinutes",
713
+ "points"
714
+ ]
715
+ },
716
+ "HistoryPoint": {
717
+ "type": "object",
718
+ "properties": {
719
+ "observedAt": {
720
+ "type": "string",
721
+ "format": "date-time"
722
+ },
723
+ "windAvgMps": {
724
+ "type": "number",
725
+ "minimum": 0,
726
+ "description": "Mean m/s over the record's period."
727
+ },
728
+ "windGustMps": {
729
+ "anyOf": [
730
+ {
731
+ "type": "number",
732
+ "minimum": 0
733
+ },
734
+ {
735
+ "type": "null"
736
+ }
737
+ ]
738
+ },
739
+ "windLullMps": {
740
+ "anyOf": [
741
+ {
742
+ "type": "number",
743
+ "minimum": 0
744
+ },
745
+ {
746
+ "type": "null"
747
+ }
748
+ ]
749
+ },
750
+ "windDirectionDeg": {
751
+ "anyOf": [
752
+ {
753
+ "type": "number",
754
+ "minimum": 0,
755
+ "exclusiveMaximum": 360
756
+ },
757
+ {
758
+ "type": "null"
759
+ }
760
+ ],
761
+ "description": "Degrees FROM; null exactly when the period was calm (below 0.5 m/s)."
762
+ },
763
+ "temperatureC": {
764
+ "anyOf": [
765
+ {
766
+ "type": "number"
767
+ },
768
+ {
769
+ "type": "null"
770
+ }
771
+ ]
772
+ },
773
+ "seaLevelPressureHpa": {
774
+ "anyOf": [
775
+ {
776
+ "type": "number",
777
+ "exclusiveMinimum": 0
778
+ },
779
+ {
780
+ "type": "null"
781
+ }
782
+ ]
783
+ }
784
+ },
785
+ "required": [
786
+ "observedAt",
787
+ "windAvgMps",
788
+ "windGustMps",
789
+ "windLullMps",
790
+ "windDirectionDeg",
791
+ "temperatureC"
792
+ ]
793
+ },
794
+ "StationTelemetry": {
795
+ "type": "object",
796
+ "properties": {
797
+ "batteryVoltage": {
798
+ "anyOf": [
799
+ {
800
+ "type": "number"
801
+ },
802
+ {
803
+ "type": "null"
804
+ }
805
+ ],
806
+ "description": "Station supply volts. null means 'not reported here', never a dead battery."
807
+ }
808
+ },
809
+ "required": [
810
+ "batteryVoltage"
811
+ ],
812
+ "description": "Device telemetry. The station-level battery capability gates whether a client allocates UI structure; a dark sensor keeps its structure and reports null."
813
+ },
814
+ "LiveSamples": {
815
+ "type": "object",
816
+ "properties": {
817
+ "intervalSeconds": {
818
+ "type": "number",
819
+ "exclusiveMinimum": 0,
820
+ "description": "Seconds between samples."
821
+ },
822
+ "points": {
823
+ "type": "array",
824
+ "items": {
825
+ "$ref": "#/$defs/LiveSample"
826
+ },
827
+ "description": "Oldest first. A dropout is an ABSENT sample, never a zeroed one."
828
+ }
829
+ },
830
+ "required": [
831
+ "intervalSeconds",
832
+ "points"
833
+ ]
834
+ },
835
+ "LiveSample": {
836
+ "type": "object",
837
+ "properties": {
838
+ "observedAt": {
839
+ "type": "string",
840
+ "format": "date-time"
841
+ },
842
+ "windMps": {
843
+ "type": "number",
844
+ "minimum": 0,
845
+ "description": "Instantaneous m/s — a single anemometer sample, not a period mean."
846
+ },
847
+ "windDirectionDeg": {
848
+ "anyOf": [
849
+ {
850
+ "type": "number",
851
+ "minimum": 0,
852
+ "exclusiveMaximum": 360
853
+ },
854
+ {
855
+ "type": "null"
856
+ }
857
+ ],
858
+ "description": "Degrees FROM; null exactly when calm (below 0.5 m/s)."
859
+ }
860
+ },
861
+ "required": [
862
+ "observedAt",
863
+ "windMps",
864
+ "windDirectionDeg"
865
+ ]
866
+ }
867
+ }
868
+ }