atmosx-nwws-parser 1.0.2023 → 1.0.2211

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 (76) hide show
  1. package/README.md +199 -3
  2. package/dist/cjs/index.cjs +3664 -0
  3. package/dist/esm/index.mjs +3622 -0
  4. package/package.json +5 -3
  5. package/src/bootstrap.ts +65 -48
  6. package/src/database.ts +98 -48
  7. package/src/dictionaries/events.ts +33 -0
  8. package/src/dictionaries/signatures.ts +50 -45
  9. package/src/eas.ts +146 -81
  10. package/src/index.ts +203 -0
  11. package/src/parsers/events/api.ts +142 -0
  12. package/src/parsers/events/cap.ts +129 -0
  13. package/src/parsers/events/text.ts +104 -0
  14. package/src/parsers/events/ugc.ts +107 -0
  15. package/src/parsers/events/vtec.ts +76 -0
  16. package/src/parsers/events.ts +211 -165
  17. package/src/parsers/hvtec.ts +46 -0
  18. package/src/parsers/{vtec.ts → pvtec.ts} +32 -27
  19. package/src/parsers/stanza.ts +70 -41
  20. package/src/parsers/text.ts +44 -45
  21. package/src/parsers/ugc.ts +130 -82
  22. package/src/types.ts +230 -170
  23. package/src/utils.ts +142 -99
  24. package/src/xmpp.ts +86 -65
  25. package/test.js +65 -1
  26. package/tsup.config.ts +10 -7
  27. package/dist/cjs/bootstrap.cjs +0 -1000
  28. package/dist/cjs/database.cjs +0 -1105
  29. package/dist/cjs/dictionaries/awips.cjs +0 -370
  30. package/dist/cjs/dictionaries/events.cjs +0 -139
  31. package/dist/cjs/dictionaries/icao.cjs +0 -265
  32. package/dist/cjs/dictionaries/offshore.cjs +0 -40
  33. package/dist/cjs/dictionaries/signatures.cjs +0 -132
  34. package/dist/cjs/eas.cjs +0 -2867
  35. package/dist/cjs/helper.cjs +0 -3029
  36. package/dist/cjs/parsers/events.cjs +0 -2867
  37. package/dist/cjs/parsers/stanza.cjs +0 -1099
  38. package/dist/cjs/parsers/text.cjs +0 -1133
  39. package/dist/cjs/parsers/types/api.cjs +0 -2867
  40. package/dist/cjs/parsers/types/cap.cjs +0 -2867
  41. package/dist/cjs/parsers/types/text.cjs +0 -2867
  42. package/dist/cjs/parsers/types/ugc.cjs +0 -2867
  43. package/dist/cjs/parsers/types/vtec.cjs +0 -2867
  44. package/dist/cjs/parsers/ugc.cjs +0 -1130
  45. package/dist/cjs/parsers/vtec.cjs +0 -1051
  46. package/dist/cjs/types.cjs +0 -17
  47. package/dist/cjs/utils.cjs +0 -2867
  48. package/dist/cjs/xmpp.cjs +0 -2867
  49. package/dist/esm/bootstrap.mjs +0 -963
  50. package/dist/esm/database.mjs +0 -1070
  51. package/dist/esm/dictionaries/awips.mjs +0 -346
  52. package/dist/esm/dictionaries/events.mjs +0 -111
  53. package/dist/esm/dictionaries/icao.mjs +0 -241
  54. package/dist/esm/dictionaries/offshore.mjs +0 -16
  55. package/dist/esm/dictionaries/signatures.mjs +0 -106
  56. package/dist/esm/eas.mjs +0 -2834
  57. package/dist/esm/helper.mjs +0 -2988
  58. package/dist/esm/parsers/events.mjs +0 -2834
  59. package/dist/esm/parsers/stanza.mjs +0 -1063
  60. package/dist/esm/parsers/text.mjs +0 -1097
  61. package/dist/esm/parsers/types/api.mjs +0 -2834
  62. package/dist/esm/parsers/types/cap.mjs +0 -2834
  63. package/dist/esm/parsers/types/text.mjs +0 -2834
  64. package/dist/esm/parsers/types/ugc.mjs +0 -2834
  65. package/dist/esm/parsers/types/vtec.mjs +0 -2834
  66. package/dist/esm/parsers/ugc.mjs +0 -1095
  67. package/dist/esm/parsers/vtec.mjs +0 -1016
  68. package/dist/esm/types.mjs +0 -0
  69. package/dist/esm/utils.mjs +0 -2834
  70. package/dist/esm/xmpp.mjs +0 -2834
  71. package/src/helper.ts +0 -167
  72. package/src/parsers/types/api.ts +0 -94
  73. package/src/parsers/types/cap.ts +0 -89
  74. package/src/parsers/types/text.ts +0 -54
  75. package/src/parsers/types/ugc.ts +0 -85
  76. package/src/parsers/types/vtec.ts +0 -60
package/README.md CHANGED
@@ -1,6 +1,202 @@
1
- # AtmosphericX - NOAA Weather Wire & NWS API Parser
1
+ <h1 style='font-size: 65px'; align="center">🌪️ AtmosphericX - NOAA Wire + API Parser ⚠️</h1>
2
+ <div align="center">
3
+ <p align = "center">This repository contains the primary parser for AtmosphericX's NOAA Weather Wire Service (NWWS) and National Weather Service (NWS) API. It is designed to handle real-time weather alerts and messages from the National Weather Service, using both XMPP (NWWS) and direct API access (Slower). This parser is intended for developers who want to integrate real-time weather alerts, watches, warnings, and forecast data from the NWS seamlessly into their applications or services. It is not recommended for users without basic programming knowledge. If you wish to access NOAA weather data without programming, consider using our end-user project, which leverages this parser and provides an easy-to-use interface for tracking weather alerts.</small></p>
4
+ <p align = "center">Documentation written by @k3yomi</p>
5
+ <div align="center" style="border: none;">
6
+ <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/k3yomi/atmosx-nwws-parser">
7
+ <img alt="GitHub forks" src="https://img.shields.io/github/forks/k3yomi/atmosx-nwws-parser">
8
+ <img alt="GitHub issues" src="https://img.shields.io/github/issues/k3yomi/atmosx-nwws-parser">
9
+ <img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/k3yomi/atmosx-nwws-parser">
10
+ </div>
11
+ </div>
2
12
 
13
+ ## Installation (NPM)
14
+ ```bash
15
+ npm install atmosx-nwws-parser
16
+ ```
3
17
 
4
- This repository contains the parsing of both NOAA Weather Wire Service and National Weather Service. It is designed to handle real time weather alerts and messages from the National Weather Service using XMPP. If you do not know basic programming, this parser is not for you. It is intended for developers who want to integrate alerts from NOAA Weather Wire easily into their applications or services without hassle. If you wish to use NWWS without programming, feel free to use our project where most of this code was used - AtmosphericX.
18
+ ## Example Usage
19
+ ```javascript
20
+ const { AlertManager } = require('atmosx-nwws-parser'); // CJS
21
+ import { AlertManager } from 'atmosx-nwws-parser'; // ESM
5
22
 
6
- TODO: Complete later...
23
+ const parser = new AlertManager({
24
+ database: `shapefiles.db`,
25
+ is_wire: true,
26
+ journal: true,
27
+ noaa_weather_wire_service_settings: {
28
+ reconnection_settings: {
29
+ enabled: true,
30
+ interval: 60,
31
+ },
32
+ credentials: {
33
+ username: `username_here`,
34
+ password: `password_here`,
35
+ nickname: "AtmosphericX Parser",
36
+ },
37
+ cache: {
38
+ enabled: true,
39
+ max_file_size: 5,
40
+ max_db_history: 5000,
41
+ directory: `meow`,
42
+ },
43
+ preferences: {
44
+ disable_ugc: false,
45
+ disable_vtec: false,
46
+ disable_text: false,
47
+ cap_only: false,
48
+ }
49
+ },
50
+ national_weather_service_settings: {
51
+ interval: 15,
52
+ endpoint: `https://api.weather.gov/alerts/active`,
53
+ },
54
+ global_settings: {
55
+ parent_events_only: true,
56
+ better_event_parsing: true,
57
+ shapefile_coordinates: false,
58
+ shapefile_skip: 10,
59
+ filtering: {
60
+ events: [`Severe Thunderstorm Warning`],
61
+ filtered_icao: [],
62
+ ignored_icao: [`KWNS`],
63
+ ignored_events: [`Xx`, `Test Message`],
64
+ ugc_filter: [],
65
+ state_filter: [],
66
+ check_expired: true,
67
+ ignore_test_products: true,
68
+ location: {
69
+ unit: `miles`
70
+ },
71
+ },
72
+ eas_settings: {
73
+ directory: null,
74
+ intro_wav: null,
75
+ }
76
+ },
77
+ })
78
+ ```
79
+
80
+ ## NOAA Weather Wire Service (Getting Started)
81
+ To use the NOAA Weather Wire Service (NWWS). You would need to obtain credentials from the National Weather Service. Follow these steps:
82
+ 1. Visit the [NOAA NWWS Registration Page](https://www.weather.gov/nwws/nwws_oi_request).
83
+ 2. Fill out the registration form with the required information.
84
+ 3. Submit the form and wait for approval. You will receive your NWWS credentials via email.
85
+
86
+ ## Events and Listeners
87
+ > All events are in GeoJSON.
88
+
89
+ ### Event `onEvents`
90
+ Triggered when a batch of new alerts are received and processed.
91
+ ```javascript
92
+ parser.on(`onEvents`, (alerts) => {
93
+ console.log(`Received ${alerts.length} new alerts.`);
94
+ alerts.forEach(alert => {
95
+ console.log(`${alert.properties.event} for ${alert.properties.locations}`);
96
+ });
97
+ });
98
+ ```
99
+ Alternatively, you can listen for single alert events using `onSevereThunderstormWarning` or `onTornadoWarning`, etc.
100
+ ```javascript
101
+ parser.on(`onTornadoWarning`, (alert) => {
102
+ console.log(`Tornado Warning issued for ${alert.properties.locations}`);
103
+ });
104
+ ```
105
+
106
+ ### Event `onReconnection`
107
+ Triggered when the parser attempts to reconnect to the NWWS service.
108
+ ```javascript
109
+ parser.on(`onReconnection`, (data) => {
110
+ console.log(`Reconnection attempt #${data.reconnects}`);
111
+ });
112
+ ```
113
+
114
+ ### Event `onConnection`
115
+ Triggered when the parser successfully connects to the NWWS service.
116
+ ```javascript
117
+ parser.on(`onConnection`, (nickname) => {
118
+ console.log(`Connected to NWWS service as ${nickname}`);
119
+ });
120
+ ```
121
+
122
+ ### Event `onOccupant`
123
+ Triggered when a new occupant is detected on the NWWS XMPP service.
124
+ ```javascript
125
+ parser.on(`onOccupant`, (data) => {
126
+ console.log(`New occupant detected: ${data.occupant}`);
127
+ });
128
+ ```
129
+
130
+ ### Event `onMessage`
131
+ Triggered when a stanza message is validated and received from the XMPP client.
132
+ ```javascript
133
+ parser.on(`onMessage`, (data) => {
134
+ console.log(`Message received from ${data.from}: ${data.message}`);
135
+ });
136
+ ```
137
+
138
+ ### Event `log`
139
+ Triggered for logging purposes, providing log level and message.
140
+ ```javascript
141
+ parser.on(`log`, (message) => {
142
+ console.log(data.message);
143
+ });
144
+ ```
145
+
146
+ ## Callbacks and Functions
147
+
148
+ ### Function `setDisplayName(name)`
149
+ Sets the display name for the XMPP client. This requires reconnection to take effect.
150
+ ```javascript
151
+ parser.setDisplayName(`My Weather Parser`);
152
+ ```
153
+
154
+ ### Function `createEasAudio(description, header)`
155
+ Generates an EAS audio file based on the provided description and header. Audio file will be located based on settings provided in the global_settings.eas_settings object.
156
+ ```javascript
157
+ parser.createEasAudio(`This is a test alert`, `EAS Header Info`);
158
+ ```
159
+
160
+ ### Function `getAllAlertTypes()`
161
+ Returns an array of all supported alert types by the parser.
162
+ ```javascript
163
+ const alertTypes = parser.getAllAlertTypes();
164
+ console.log(alertTypes);
165
+ ```
166
+
167
+ ### Function `searchStanzaDatabase(query)`
168
+ Searches the internal stanza database for messages matching the provided query.
169
+ ```javascript
170
+ const results = parser.searchStanzaDatabase(`Tornado Warning`);
171
+ console.log(results);
172
+ ```
173
+
174
+ ### Function `setSettings({})`
175
+ Dynamically updates the parser settings. Accepts the same configuration object as the constructor.
176
+ ```javascript
177
+ parser.setSettings({
178
+ global_settings: {
179
+ filtering: {
180
+ ignored_icao: [`KXYZ`],
181
+ }
182
+ }
183
+ });
184
+ ```
185
+
186
+ ### Function `stop()`
187
+ Stops the parser and disconnects from the NWWS service.
188
+ ```javascript
189
+ parser.stop();
190
+ ```
191
+
192
+ ## References
193
+ - [NOAA NWWS Information](https://www.weather.gov/nwws/)
194
+ - [NWS API Documentation](https://www.weather.gov/documentation/services-web-api)
195
+ - [XMPP Protocol](https://xmpp.org/about/technology-overview/)
196
+ - [AtmosphericX](https://github.com/k3yomi/AtmosphericX)
197
+
198
+ ## Acknowledgements
199
+ - [k3yomi](https://github.com/k3yomi)
200
+ - Lead developer @ AtmosphericX and maintainer of this module.
201
+ - [StarflightWx](https://x.com/starflightVR)
202
+ - For testing and providing feedback (Co-Developer and Spotter @ AtmosphericX)