@atmosx/event-product-parser 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +269 -0
- package/dist/cjs/index.cjs +7554 -0
- package/dist/esm/index.mjs +7542 -0
- package/dist/index.d.mts +1024 -0
- package/dist/index.d.ts +1024 -0
- package/package.json +55 -0
- package/src/@dictionaries/awips.ts +358 -0
- package/src/@dictionaries/events.ts +168 -0
- package/src/@dictionaries/icao.ts +250 -0
- package/src/@dictionaries/signatures.ts +139 -0
- package/src/@parsers/@events/api.ts +146 -0
- package/src/@parsers/@events/cap.ts +123 -0
- package/src/@parsers/@events/text.ts +104 -0
- package/src/@parsers/@events/ugc.ts +107 -0
- package/src/@parsers/@events/vtec.ts +76 -0
- package/src/@parsers/events.ts +392 -0
- package/src/@parsers/hvtec.ts +46 -0
- package/src/@parsers/pvtec.ts +72 -0
- package/src/@parsers/stanza.ts +97 -0
- package/src/@parsers/text.ts +165 -0
- package/src/@parsers/ugc.ts +247 -0
- package/src/@submodules/database.ts +162 -0
- package/src/@submodules/eas.ts +490 -0
- package/src/@submodules/utils.ts +222 -0
- package/src/@submodules/xmpp.ts +142 -0
- package/src/bootstrap.ts +190 -0
- package/src/index.ts +218 -0
- package/src/types.ts +259 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2026 k3yomi
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to use,
|
|
5
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
6
|
+
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
2. The author of the software must be credited in all copies or substantial portions of the Software, including but not limited to documentation, README files, and source code comments.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
12
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
13
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
14
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
15
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
17
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
<h1 style='font-size: 65px'; align="center">🌪️ AtmosphericX - Event Product 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/AtmosphericX/event-product-parser">
|
|
7
|
+
<img alt="GitHub forks" src="https://img.shields.io/github/forks/AtmosphericX/event-product-parser">
|
|
8
|
+
<img alt="GitHub issues" src="https://img.shields.io/github/issues/AtmosphericX/event-product-parser">
|
|
9
|
+
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/AtmosphericX/event-product-parser">
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Installation (NPM)
|
|
14
|
+
```bash
|
|
15
|
+
npm install @atmosx/event-product-parser@latest # Latest
|
|
16
|
+
npm install @atmosx/event-product-parser@beta # Beta
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Example Usage
|
|
20
|
+
```javascript
|
|
21
|
+
const { AlertManager } = require('@atmosx/product-parser'); // CJS
|
|
22
|
+
import { AlertManager } from '@atmosx/product-parser'; // ESM
|
|
23
|
+
|
|
24
|
+
const parser = new AlertManager({
|
|
25
|
+
database: `shapefiles.db`,
|
|
26
|
+
is_wire: true,
|
|
27
|
+
journal: true,
|
|
28
|
+
noaa_weather_wire_service_settings: {
|
|
29
|
+
reconnection_settings: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
interval: 60,
|
|
32
|
+
},
|
|
33
|
+
credentials: {
|
|
34
|
+
username: `username_here`,
|
|
35
|
+
password: `password_here`,
|
|
36
|
+
nickname: "AtmosphericX Parser",
|
|
37
|
+
},
|
|
38
|
+
cache: {
|
|
39
|
+
enabled: false,
|
|
40
|
+
max_db_history: 5000,
|
|
41
|
+
max_db_cache_size: 1000,
|
|
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: [`KLOT`],
|
|
62
|
+
ignored_icao: [],
|
|
63
|
+
ignored_events: [`Xx`, `Test Message`],
|
|
64
|
+
ugc_filter: [],
|
|
65
|
+
state_filter: [],
|
|
66
|
+
check_expired: true,
|
|
67
|
+
ignore_test_products: true,
|
|
68
|
+
},
|
|
69
|
+
eas_settings: {
|
|
70
|
+
directory: null,
|
|
71
|
+
intro_wav: null,
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## NOAA Weather Wire Service (Getting Started)
|
|
78
|
+
To use the NOAA Weather Wire Service (NWWS). You would need to obtain credentials from the National Weather Service. Follow these steps:
|
|
79
|
+
1. Visit the [NOAA NWWS Registration Page](https://www.weather.gov/nwws/nwws_oi_request).
|
|
80
|
+
2. Fill out the registration form with the required information.
|
|
81
|
+
3. Submit the form and wait for approval. You will receive your NWWS credentials via email.
|
|
82
|
+
|
|
83
|
+
## Events and Listeners
|
|
84
|
+
> All events are in GeoJSON.
|
|
85
|
+
|
|
86
|
+
### Event `onEvents`
|
|
87
|
+
Triggered when a batch of new alerts are received and processed.
|
|
88
|
+
```javascript
|
|
89
|
+
parser.on(`onEvents`, (alerts) => {
|
|
90
|
+
console.log(`Received ${alerts.length} new alerts.`);
|
|
91
|
+
alerts.forEach(alert => {
|
|
92
|
+
console.log(`${alert.properties.event} for ${alert.properties.locations}`);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
Alternatively, you can listen for single alert events using `onSevereThunderstormWarning` or `onTornadoWarning`, etc.
|
|
97
|
+
```javascript
|
|
98
|
+
parser.on(`onTornadoWarning`, (alert) => {
|
|
99
|
+
console.log(`Tornado Warning issued for ${alert.properties.locations}`);
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Event `onReconnection`
|
|
104
|
+
Triggered when the parser attempts to reconnect to the NWWS service.
|
|
105
|
+
```javascript
|
|
106
|
+
parser.on(`onReconnection`, (data) => {
|
|
107
|
+
console.log(`Reconnection attempt #${data.reconnects}`);
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Event `onConnection`
|
|
112
|
+
Triggered when the parser successfully connects to the NWWS service.
|
|
113
|
+
```javascript
|
|
114
|
+
parser.on(`onConnection`, (nickname) => {
|
|
115
|
+
console.log(`Connected to NWWS service as ${nickname}`);
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Event `onOccupant`
|
|
120
|
+
Triggered when a new occupant is detected on the NWWS XMPP service.
|
|
121
|
+
```javascript
|
|
122
|
+
parser.on(`onOccupant`, (data) => {
|
|
123
|
+
console.log(`New occupant detected: ${data.occupant}`);
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Event `onMessage`
|
|
128
|
+
Triggered when a stanza message is validated and received from the XMPP client.
|
|
129
|
+
```javascript
|
|
130
|
+
parser.on(`onMessage`, (data) => {
|
|
131
|
+
console.log(`Message received from ${data.from}: ${data.message}`);
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Event `onTest`
|
|
136
|
+
Triggered when a test message comes in. Ex: Test Tsunami Warning
|
|
137
|
+
```javascript
|
|
138
|
+
parser.on(`onTest`, (alert) => {
|
|
139
|
+
console.log(`Test alert received for ${alert.properties.locations}`);
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Event `onExpired`
|
|
144
|
+
Triggered when an alert expires.
|
|
145
|
+
```javascript
|
|
146
|
+
parser.on(`onExpired`, (alert) => {
|
|
147
|
+
console.log(`Alert expired for ${alert.properties.event} for locations of ${alert.properties.locations}`);
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Event `onFilteredEvent` / `onIgnoredEvent`
|
|
152
|
+
Triggered when an alert is filtered out.
|
|
153
|
+
```javascript
|
|
154
|
+
parser.on(`onFilteredEvent`, (alert) => {
|
|
155
|
+
console.log(`Alert filtered for ${alert.properties.event}`);
|
|
156
|
+
});
|
|
157
|
+
parser.on(`onIgnoredEvent`, (alert) => {
|
|
158
|
+
console.log(`Alert ignored for ${alert.properties.event}`);
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Event `onFilteredICAO` / (`onIgnoredICAO`)
|
|
163
|
+
Triggered when an alert is filtered out based on its ICAO code.
|
|
164
|
+
```javascript
|
|
165
|
+
parser.on(`onFilteredICAO`, (alert) => {
|
|
166
|
+
console.log(`Alert filtered for ${alert.properties.event}`);
|
|
167
|
+
});
|
|
168
|
+
parser.on(`onIgnoredICAO`, (alert) => {
|
|
169
|
+
console.log(`Alert ignored for ${alert.properties.event}`);
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Event `onFilteredUGC`
|
|
174
|
+
Triggered when an alert is filtered out based on its UGC zone.
|
|
175
|
+
```javascript
|
|
176
|
+
parser.on(`onFilteredUGC`, (alert) => {
|
|
177
|
+
console.log(`Alert filtered for ${alert.properties.event}`);
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Event `onFilteredState`
|
|
182
|
+
Triggered when an alert is filtered out based on its state (Abbreviation)
|
|
183
|
+
```javascript
|
|
184
|
+
parser.on(`onFilteredState`, (alert) => {
|
|
185
|
+
console.log(`Alert filtered for ${alert.properties.event}`);
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Event `log`
|
|
190
|
+
Triggered for logging purposes, providing log level and message.
|
|
191
|
+
```javascript
|
|
192
|
+
parser.on(`log`, (message) => {
|
|
193
|
+
console.log(data.message);
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Callbacks and Functions
|
|
198
|
+
|
|
199
|
+
### Function `setDisplayName(name)`
|
|
200
|
+
Sets the display name for the XMPP client. This requires reconnection to take effect.
|
|
201
|
+
```javascript
|
|
202
|
+
parser.setDisplayName(`My Weather Parser`);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Function `createEasAudio(description, header)`
|
|
206
|
+
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.
|
|
207
|
+
If you are running linux, festival is required to use this or it will error out.
|
|
208
|
+
```javascript
|
|
209
|
+
parser.createEasAudio(`This is a test alert`, `EAS Header Info`);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Function `getAllAlertTypes()`
|
|
213
|
+
Returns an array of all supported alert types by the parser.
|
|
214
|
+
```javascript
|
|
215
|
+
const alertTypes = parser.getAllAlertTypes();
|
|
216
|
+
console.log(alertTypes);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Function `getEventPolygon(event)`
|
|
220
|
+
Retrieves the geographical polygon for a given event based on its generated geocode and UGC zones. (Returns in GeoJSON format)
|
|
221
|
+
```javascript
|
|
222
|
+
const polygon = await parser.getEventPolygon(event);
|
|
223
|
+
console.log(polygon);
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Function `searchStanzaDatabase(query)`
|
|
227
|
+
Searches the internal stanza database for messages matching the provided query.
|
|
228
|
+
```javascript
|
|
229
|
+
const results = parser.searchStanzaDatabase(`Tornado Warning`);
|
|
230
|
+
console.log(results);
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Function `setSettings({})`
|
|
234
|
+
Dynamically updates the parser settings. Accepts the same configuration object as the constructor.
|
|
235
|
+
```javascript
|
|
236
|
+
parser.setSettings({
|
|
237
|
+
global_settings: {
|
|
238
|
+
filtering: {
|
|
239
|
+
ignored_icao: [`KXYZ`],
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Function `stop()`
|
|
246
|
+
Stops the parser and disconnects from the NWWS service.
|
|
247
|
+
```javascript
|
|
248
|
+
parser.stop();
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## References
|
|
252
|
+
[NOAA NWWS Information](https://www.weather.gov/nwws/) |
|
|
253
|
+
[NWS API Documentation](https://www.weather.gov/documentation/services-web-api) |
|
|
254
|
+
[XMPP Protocol](https://xmpp.org/about/technology-overview/) |
|
|
255
|
+
[AtmosphericX](https://github.com/k3yomi/AtmosphericX) |\
|
|
256
|
+
[Documentation](https://atmosphericx.scriptkitty.cafe/documentation) |
|
|
257
|
+
[Discord Server](https://atmosphericx-discord.scriptkitty.cafe) |
|
|
258
|
+
[Project Board](https://github.com/users/AtmosphericX/projects/2) |\
|
|
259
|
+
[Code of Conduct](/CODE_OF_CONDUCT.md) |
|
|
260
|
+
[Contributing](/CONTRIBUTING.md) |
|
|
261
|
+
[License](/LICENSE) |
|
|
262
|
+
[Security](/SECURITY.md) |
|
|
263
|
+
[Changelogs](/CHANGELOGS.md) |
|
|
264
|
+
|
|
265
|
+
## Acknowledgements
|
|
266
|
+
- [k3yomi](https://github.com/k3yomi)
|
|
267
|
+
- Lead developer @ AtmosphericX and maintainer of this module.
|
|
268
|
+
- [StarflightWx](https://x.com/starflightVR)
|
|
269
|
+
- For testing and providing feedback (Co-Developer and Spotter @ AtmosphericX)
|