atmosx-nwws-parser 1.0.18 → 1.0.22
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/README.md +183 -64
- package/dist/cjs/index.cjs +3799 -0
- package/dist/esm/index.mjs +3757 -0
- package/package.json +49 -29
- package/src/bootstrap.ts +196 -0
- package/src/database.ts +148 -0
- package/src/dictionaries/awips.ts +342 -0
- package/src/dictionaries/events.ts +142 -0
- package/src/dictionaries/icao.ts +237 -0
- package/src/dictionaries/offshore.ts +12 -0
- package/src/dictionaries/signatures.ts +107 -0
- package/src/eas.ts +493 -0
- package/src/index.ts +229 -0
- package/src/parsers/events/api.ts +151 -0
- package/src/parsers/events/cap.ts +138 -0
- package/src/parsers/events/text.ts +106 -0
- package/src/parsers/events/ugc.ts +109 -0
- package/src/parsers/events/vtec.ts +78 -0
- package/src/parsers/events.ts +367 -0
- package/src/parsers/hvtec.ts +46 -0
- package/src/parsers/pvtec.ts +71 -0
- package/src/parsers/stanza.ts +132 -0
- package/src/parsers/text.ts +166 -0
- package/src/parsers/ugc.ts +197 -0
- package/src/types.ts +251 -0
- package/src/utils.ts +314 -0
- package/src/xmpp.ts +144 -0
- package/test.js +61 -32
- package/tsconfig.json +14 -0
- package/tsup.config.ts +14 -0
- package/bootstrap.js +0 -111
- package/index.js +0 -261
- package/src/events.js +0 -336
- package/src/stanza.js +0 -103
- package/src/text.js +0 -108
- package/src/ugc.js +0 -115
- package/src/vtec.js +0 -89
package/README.md
CHANGED
|
@@ -1,89 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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>
|
|
12
|
+
|
|
13
|
+
## Installation (NPM)
|
|
9
14
|
```bash
|
|
10
15
|
npm install atmosx-nwws-parser
|
|
11
16
|
```
|
|
12
17
|
|
|
13
|
-
## Usage
|
|
14
|
-
```
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
## Example Usage
|
|
19
|
+
```javascript
|
|
20
|
+
const { AlertManager } = require('atmosx-nwws-parser'); // CJS
|
|
21
|
+
import { AlertManager } from 'atmosx-nwws-parser'; // ESM
|
|
22
|
+
|
|
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
|
+
}
|
|
30
49
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
national_weather_service_settings: {
|
|
51
|
+
interval: 15,
|
|
52
|
+
endpoint: `https://api.weather.gov/alerts/active`,
|
|
34
53
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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_text_products: true,
|
|
68
|
+
location: {
|
|
69
|
+
unit: `miles`
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
eas_settings: {
|
|
73
|
+
directory: null,
|
|
74
|
+
intro_wav: null,
|
|
75
|
+
}
|
|
39
76
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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}`);
|
|
46
103
|
});
|
|
47
104
|
```
|
|
48
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
|
+
```
|
|
49
113
|
|
|
50
|
-
|
|
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
|
+
```
|
|
51
121
|
|
|
52
|
-
|
|
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
|
+
```
|
|
53
129
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Client.onEvent(`onReconnect`, (service: Object) => {});
|
|
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
|
+
```
|
|
62
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
|
+
});
|
|
63
144
|
```
|
|
64
145
|
|
|
65
|
-
##
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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`);
|
|
70
152
|
```
|
|
71
153
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
154
|
+
### Function `setCurrentLocation(name, {latitude, longitude})`
|
|
155
|
+
Sets the current location for the parser, which can be used for location-based filtering.
|
|
156
|
+
```javascript
|
|
157
|
+
parser.setCurrentLocation(`My Location`, {34.05, -118.25 });
|
|
75
158
|
```
|
|
76
159
|
|
|
77
|
-
|
|
78
|
-
|
|
160
|
+
### Function `createEasAudio(description, header)`
|
|
161
|
+
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.
|
|
162
|
+
```javascript
|
|
163
|
+
parser.createEasAudio(`This is a test alert`, `EAS Header Info`);
|
|
164
|
+
```
|
|
79
165
|
|
|
80
|
-
|
|
166
|
+
### Function `getAllAlertTypes()`
|
|
167
|
+
Returns an array of all supported alert types by the parser.
|
|
168
|
+
```javascript
|
|
169
|
+
const alertTypes = parser.getAllAlertTypes();
|
|
170
|
+
console.log(alertTypes);
|
|
171
|
+
```
|
|
81
172
|
|
|
82
|
-
|
|
173
|
+
### Function `searchStanzaDatabase(query)`
|
|
174
|
+
Searches the internal stanza database for messages matching the provided query.
|
|
175
|
+
```javascript
|
|
176
|
+
const results = parser.searchStanzaDatabase(`Tornado Warning`);
|
|
177
|
+
console.log(results);
|
|
178
|
+
```
|
|
83
179
|
|
|
84
|
-
|
|
180
|
+
### Function `setSettings({})`
|
|
181
|
+
Dynamically updates the parser settings. Accepts the same configuration object as the constructor.
|
|
182
|
+
```javascript
|
|
183
|
+
parser.setSettings({
|
|
184
|
+
global_settings: {
|
|
185
|
+
filtering: {
|
|
186
|
+
ignored_icao: [`KXYZ`],
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
```
|
|
85
191
|
|
|
86
|
-
|
|
192
|
+
### Function `stop()`
|
|
193
|
+
Stops the parser and disconnects from the NWWS service.
|
|
194
|
+
```javascript
|
|
195
|
+
parser.stop();
|
|
196
|
+
```
|
|
87
197
|
|
|
88
|
-
##
|
|
89
|
-
|
|
198
|
+
## References
|
|
199
|
+
- [NOAA NWWS Information](https://www.weather.gov/nwws/)
|
|
200
|
+
- [NWS API Documentation](https://www.weather.gov/documentation/services-web-api)
|
|
201
|
+
- [XMPP Protocol](https://xmpp.org/about/technology-overview/)
|
|
202
|
+
- [AtmosphericX](https://github.com/k3yomi/AtmosphericX)
|
|
203
|
+
|
|
204
|
+
## Acknowledgements
|
|
205
|
+
- [k3yomi](https://github.com/k3yomi)
|
|
206
|
+
- Lead developer @ AtmosphericX and maintainer of this module.
|
|
207
|
+
- [StarflightWx](https://x.com/starflightVR)
|
|
208
|
+
- For testing and providing feedback (Co-Developer and Spotter @ AtmosphericX)
|