@atmosx/event-product-parser 2.0.16 → 3.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.
Files changed (136) hide show
  1. package/README.md +248 -187
  2. package/dist/cjs/index.cjs +12218 -3139
  3. package/dist/esm/index.mjs +12401 -3327
  4. package/dist/index.d.mts +235 -0
  5. package/dist/index.d.ts +235 -0
  6. package/package.json +6 -4
  7. package/src/@building/building.clean.ts +30 -0
  8. package/src/@building/building.create.ts +42 -0
  9. package/src/@building/building.enhance.ts +56 -0
  10. package/src/@building/building.geometry.ts +48 -0
  11. package/src/@building/building.headers.ts +37 -0
  12. package/src/@building/building.office.ts +43 -0
  13. package/src/@building/building.polygon.ts +71 -0
  14. package/src/@building/building.properties.ts +89 -0
  15. package/src/@building/building.signature.ts +61 -0
  16. package/src/@building/building.tags.ts +24 -0
  17. package/src/@building/building.tracking.ts +68 -0
  18. package/src/@building/building.validate.ts +147 -0
  19. package/src/@core/core.getEvents.ts +25 -0
  20. package/src/@core/core.getNodes.ts +25 -0
  21. package/src/@core/core.getRandomEvent.ts +25 -0
  22. package/src/@core/core.getVersion.ts +25 -0
  23. package/src/@core/core.listener.ts +24 -0
  24. package/src/@core/core.setNode.ts +81 -0
  25. package/src/@core/core.start.ts +59 -0
  26. package/src/@core/core.stop.ts +32 -0
  27. package/src/@dictionaries/dictionaries.betterEventNames.ts +89 -0
  28. package/src/@dictionaries/dictionaries.eventActions.ts +28 -0
  29. package/src/@dictionaries/{awips.ts → dictionaries.eventAwipAbreviations.ts} +13 -7
  30. package/src/@dictionaries/dictionaries.eventCancelMessages.ts +30 -0
  31. package/src/@dictionaries/dictionaries.eventCauses.ts +36 -0
  32. package/src/@dictionaries/dictionaries.eventProducts.ts +25 -0
  33. package/src/@dictionaries/dictionaries.eventRecords.ts +25 -0
  34. package/src/@dictionaries/dictionaries.eventSeverity.ts +27 -0
  35. package/src/@dictionaries/dictionaries.eventStatus.ts +31 -0
  36. package/src/@dictionaries/{signatures.ts → dictionaries.eventTags.ts} +13 -68
  37. package/src/@dictionaries/dictionaries.eventTypes.ts +82 -0
  38. package/src/@dictionaries/dictionaries.eventsOffshore.ts +31 -0
  39. package/src/@dictionaries/dictionaries.hailStrings.ts +33 -0
  40. package/src/@dictionaries/{icao.ts → dictionaries.officeICAOs.ts} +13 -6
  41. package/src/@dictionaries/dictionaries.regExp.ts +28 -0
  42. package/src/@dictionaries/dictionaries.shapefileLinks.ts +36 -0
  43. package/src/@dictionaries/dictionaries.statusCorrelationText.ts +40 -0
  44. package/src/@dictionaries/dictionaries.testSignatures.ts +24 -0
  45. package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +68 -0
  46. package/src/@events/events.api.ts +113 -0
  47. package/src/@events/events.text.ts +79 -0
  48. package/src/@events/events.ugc.ts +83 -0
  49. package/src/@events/events.vtec.ts +87 -0
  50. package/src/@manager/manager.mkEvent.ts +95 -0
  51. package/src/@manager/manager.rmEvent.ts +46 -0
  52. package/src/@manager/manager.setHash.ts +37 -0
  53. package/src/@manager/manager.updateNodes.ts +55 -0
  54. package/src/@manager/manager.updateWebhooks.ts +50 -0
  55. package/src/@modules/@database/database.cache.ts +48 -0
  56. package/src/@modules/@database/database.init.ts +45 -0
  57. package/src/@modules/@database/database.shapefiles.ts +96 -0
  58. package/src/@modules/@database/database.stanza.ts +48 -0
  59. package/src/@modules/@eas/eas.getFloatPCM16.ts +29 -0
  60. package/src/@modules/@eas/eas.getMergedPCM16.ts +32 -0
  61. package/src/@modules/@eas/eas.getPCM16.ts +52 -0
  62. package/src/@modules/@eas/eas.getPCMToFloat.ts +26 -0
  63. package/src/@modules/@eas/eas.getSampledPCM16.ts +36 -0
  64. package/src/@modules/@eas/eas.getWavPCM16.ts +52 -0
  65. package/src/@modules/@eas/eas.setAFSK.ts +52 -0
  66. package/src/@modules/@eas/eas.setAsciiToBits.ts +32 -0
  67. package/src/@modules/@eas/eas.setAttentionTone.ts +40 -0
  68. package/src/@modules/@eas/eas.setEasTone.ts +137 -0
  69. package/src/@modules/@eas/eas.setNoise.ts +31 -0
  70. package/src/@modules/@eas/eas.setRadioEffect.ts +49 -0
  71. package/src/@modules/@eas/eas.setSameHeader.ts +45 -0
  72. package/src/@modules/@stanza/stanza.getAwipsType.ts +46 -0
  73. package/src/@modules/@stanza/stanza.validate.ts +50 -0
  74. package/src/@modules/@utilities/utilities.createHttp.ts +85 -0
  75. package/src/@modules/@utilities/utilities.createWebhook.ts +100 -0
  76. package/src/@modules/@utilities/utilities.getFormattedTime.ts +43 -0
  77. package/src/@modules/@utilities/utilities.getSettings.ts +25 -0
  78. package/src/@modules/@utilities/utilities.getShapeNearestPoint.ts +114 -0
  79. package/src/@modules/@utilities/utilities.setCronSchedule.ts +65 -0
  80. package/src/@modules/@utilities/utilities.setEventEmit.ts +41 -0
  81. package/src/@modules/@utilities/utilities.setListener.ts +30 -0
  82. package/src/@modules/@utilities/utilities.setSettings.ts +42 -0
  83. package/src/@modules/@utilities/utilities.setSleep.ts +33 -0
  84. package/src/@modules/@utilities/utilities.setTimeoutAction.ts +59 -0
  85. package/src/@modules/@utilities/utilities.setWarning.ts +34 -0
  86. package/src/@modules/@xmpp/xmpp.xDeploy.ts +58 -0
  87. package/src/@modules/@xmpp/xmpp.xError.ts +29 -0
  88. package/src/@modules/@xmpp/xmpp.xOffline.ts +38 -0
  89. package/src/@modules/@xmpp/xmpp.xOnline.ts +45 -0
  90. package/src/@modules/@xmpp/xmpp.xReconnect.ts +64 -0
  91. package/src/@modules/@xmpp/xmpp.xStanza.ts +63 -0
  92. package/src/@parsers/@hvtec/hvtec.extract.ts +40 -0
  93. package/src/@parsers/@pvtec/pvtec.expires.ts +26 -0
  94. package/src/@parsers/@pvtec/pvtec.extract.ts +49 -0
  95. package/src/@parsers/@text/text.getDescriptionFromProduct.ts +53 -0
  96. package/src/@parsers/@text/text.getPolygonFromProduct.ts +32 -0
  97. package/src/@parsers/@text/text.getTextFromProduct.ts +43 -0
  98. package/src/@parsers/@text/text.getXML.ts +61 -0
  99. package/src/@parsers/@ugc/ugc.coordinates.ts +110 -0
  100. package/src/@parsers/@ugc/ugc.expiry.ts +32 -0
  101. package/src/@parsers/@ugc/ugc.extract.ts +37 -0
  102. package/src/@parsers/@ugc/ugc.header.ts +30 -0
  103. package/src/@parsers/@ugc/ugc.locations.ts +29 -0
  104. package/src/@parsers/@ugc/ugc.zones.ts +52 -0
  105. package/src/@types/type.event.ts +67 -0
  106. package/src/@types/type.properties.ts +75 -0
  107. package/src/@types/types.attributes.ts +28 -0
  108. package/src/@types/types.compiled.ts +35 -0
  109. package/src/@types/types.hash.ts +24 -0
  110. package/src/@types/types.hvtec.ts +25 -0
  111. package/src/@types/types.pvtec.ts +30 -0
  112. package/src/@types/types.settings.ts +76 -0
  113. package/src/@types/types.stanza.ts +37 -0
  114. package/src/@types/types.ugc.ts +24 -0
  115. package/src/@types/types.webhook.ts +26 -0
  116. package/src/bootstrap.ts +85 -163
  117. package/src/index.ts +47 -216
  118. package/test.js +78 -51
  119. package/tsup.config.ts +1 -0
  120. package/src/@dictionaries/events.ts +0 -168
  121. package/src/@parsers/@events/api.ts +0 -146
  122. package/src/@parsers/@events/cap.ts +0 -123
  123. package/src/@parsers/@events/text.ts +0 -104
  124. package/src/@parsers/@events/ugc.ts +0 -107
  125. package/src/@parsers/@events/vtec.ts +0 -76
  126. package/src/@parsers/events.ts +0 -392
  127. package/src/@parsers/hvtec.ts +0 -46
  128. package/src/@parsers/pvtec.ts +0 -72
  129. package/src/@parsers/stanza.ts +0 -97
  130. package/src/@parsers/text.ts +0 -165
  131. package/src/@parsers/ugc.ts +0 -247
  132. package/src/@submodules/database.ts +0 -201
  133. package/src/@submodules/eas.ts +0 -490
  134. package/src/@submodules/utils.ts +0 -191
  135. package/src/@submodules/xmpp.ts +0 -142
  136. package/src/types.ts +0 -259
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
- <h1 style='font-size: 65px'; align="center">🌪️ AtmosphericX - Event Product Parser ⚠️</h1>
1
+ # Project AtmosphericX - Event Product Parser (v3.0.0)
2
+
2
3
  <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
4
  <div align="center" style="border: none;">
6
5
  <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/AtmosphericX/event-product-parser">
7
6
  <img alt="GitHub forks" src="https://img.shields.io/github/forks/AtmosphericX/event-product-parser">
@@ -10,243 +9,308 @@
10
9
  </div>
11
10
  </div>
12
11
 
12
+ ## What is `@atmosx/event-product-parser`
13
+ This repository contains the primary function to obtain, parse, cache, and deliver products and events from the National Weather Service. There are two primary sources to obtain these products. By default, the repository uses the **National Weather Service API**. However, there is **FULL** support for **NOAA Weather Wire Service (Open Interface)**. 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 without having to use external APIs from other sources / parsers. If you wish to access data without programming, consider using our end user project, which leverages this parser and provides an easy-to-use interface for tracking weather alerts. See [Documentation](https://atmosphericx.scriptkitty.cafe).
14
+
13
15
  ## Installation (NPM)
14
16
  ```bash
15
- npm install @atmosx/event-product-parser@latest
17
+ npm install @atmosx/event-product-parser
16
18
  ```
17
19
 
18
- ## Example Usage
19
- ```javascript
20
- const { AlertManager } = require('@atmosx/product-parser'); // CJS
21
- import { AlertManager } from '@atmosx/product-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,
20
+ ## Configurations & Usage
21
+ ```ts
22
+ const { Manager } = require(`@atmosx/event-product-parser`) // CJS Importing
23
+ import { Manager } from '@atmosx/event-product-parser' // EJS Importing
24
+
25
+ const Client = new Manager({
26
+ Database: `shapefiles.db`,
27
+ EnableWireService: false,
28
+ EnableJournal: true,
29
+ NOAAWeatherWireServiceSettings: {
30
+ ReconnectionSettings: {
31
+ Enabled: true,
32
+ ReconnectionInterval: 60,
31
33
  },
32
- credentials: {
33
- username: `username_here`,
34
- password: `password_here`,
35
- nickname: "AtmosphericX Parser",
34
+ CredentialSettings: {
35
+ Username: `username`,
36
+ Password: `password`,
37
+ Nickname: "nickname (@atmosx/event-product-parser/3.0)",
36
38
  },
37
- cache: {
38
- enabled: false,
39
- max_db_history: 5000,
40
- max_db_cache_size: 1000,
39
+ CacheSettings: {
40
+ Enabled: true,
41
+ MaxDatabaseHistory: 5000,
42
+ MaxRetentionHistory: 555,
41
43
  },
42
- preferences: {
43
- disable_ugc: false,
44
- disable_vtec: false,
45
- disable_text: false,
46
- cap_only: false,
44
+ StanzaSettings: {
45
+ DisableUGC: false,
46
+ DisableVTEC: false,
47
+ DisableText: false,
47
48
  }
48
49
  },
49
- national_weather_service_settings: {
50
- interval: 15,
51
- endpoint: `https://api.weather.gov/alerts/active`,
50
+ NationalWeatherServiceSettings: {
51
+ CallbackInterval: 30,
52
+ EventsEndpoint: `https://api.weather.gov/alerts/active`,
52
53
  },
53
- global_settings: {
54
- parent_events_only: true,
55
- better_event_parsing: true,
56
- shapefile_coordinates: false,
57
- shapefile_skip: 10,
58
- filtering: {
59
- events: [`Severe Thunderstorm Warning`],
60
- filtered_icao: [`KLOT`],
61
- ignored_icao: [],
62
- ignored_events: [`Xx`, `Test Message`],
63
- ugc_filter: [],
64
- state_filter: [],
65
- check_expired: true,
66
- ignore_test_products: true,
54
+ WebhookSettings: [
55
+ {
56
+ webhook: "https://discord.com/api/webhooks/XXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
57
+ title: "AtmosphericX - (@atmosx/event-product-parser)",
58
+ message: ``,
59
+ events: [`Severe Thunderstorm Warning`, `Radar Indicated Tornado Warning`, `*Warning`, `*Thunderstorm*`],
60
+ rate: 5,
61
+ }
62
+ ],
63
+ GlobalSettings: {
64
+ EventManagement: true,
65
+ BetterEventNames: true,
66
+ DisableGeometryParsing: false,
67
+ UseShapefileCoordinates: true,
68
+ SPCWatchesOnly: true,
69
+ NodeTTL: 60,
70
+ NodeMinDistance: 120,
71
+ EventFiltering: {
72
+ ListeningEvents: [
73
+ "Tornado Emergency", "PDS Tornado Warning", "Tornado Warning",
74
+ "Confirmed Tornado Warning", "Radar Indicated Tornado Warning",
75
+ "Special Marine Warning (TPROB)", "PDS Tornado Watch", "Tornado Watch",
76
+ "EDS Severe Thunderstorm Warning (TPROB)", "EDS Severe Thunderstorm Warning",
77
+ "Destructive Severe Thunderstorm Warning (TPROB)", "Destructive Severe Thunderstorm Warning",
78
+ "Considerable Severe Thunderstorm Warning (TPROB)", "Considerable Severe Thunderstorm Warning",
79
+ "Severe Thunderstorm Warning (TPROB)", "Severe Thunderstorm Warning",
80
+ "Severe Thunderstorm Watch",
81
+ "Flash Flood Emergency", "Flash Flood Warning",
82
+ "Flash Flood Watch",
83
+ "Tsunami Warning", "Tsunami Watch",
84
+ "Tsunami Advisory", "Special Marine Warning",
85
+ "Earthquake Warning",
86
+ "Hurricane Warning", "Hurricane Watch",
87
+ "Tropical Storm Warning",
88
+ "Winter Storm Warning", "Blizzard Warning",
89
+ "Ice Storm Warning", "Snow Squall Warning",
90
+ "Winter Weather Advisory", "Extreme Cold Watch"
91
+ ],
92
+ ListeningICAO: [],
93
+ IgnoredICAO: [],
94
+ IgnoredEvents: [],
95
+ ListeningUGC: [],
96
+ ListeningStates: [],
97
+ NodeLocationFiltering: false,
98
+ IgnoreTestProducts: true,
67
99
  },
68
- eas_settings: {
69
- directory: null,
70
- intro_wav: null,
100
+ EASSettings: {
101
+ ArchiveDirectory: null,
102
+ IntroWavFile: null,
71
103
  }
72
- },
104
+ }
73
105
  })
74
106
  ```
107
+ ### General Settings
108
+ - **Database**: The database file name and location, please make sure to include the `.db` extension.
109
+ - **EnableWireService**: Whether to enable `NOAA Weather Wire Service` within the parser. This requires credentials from [NOAA Weather Wire Service](https://www.weather.gov/nwws/).
110
+ - **EnableJournal**: Whether to output logs without requiring event `listeners`.
111
+
112
+ ### NOAAWeatherWireServiceSettings
113
+ - **ReconnectionSettings**: When the XMPP client gets disconnected or has an error, choose to reconnect to the service again. This contains a reconnection check interval.
114
+ - **CredentialSettings**: The username (nickname) and password that is required for using `NOAA Weather Wire Service`.
115
+ - **CacheSettings**: The ability to use the cache system so when you relaunch the parser, it will have a event retention history of all the stanzas collected.
116
+ - **StanzaSettings**: Modify what type of products metadata you'd like to receive. (UGC, VTEC, RawText)
117
+
118
+ ### NationalWeatherServiceSettings
119
+ - **CallbackInterval**: The interval at which the parser will check for new alerts from the National Weather Service API.
120
+ - **EventsEndpoint**: The URL that directs to the API.
121
+
122
+ ### WebhookSettings
123
+ - **webhook**: The URL of the webhook you want to send messages to.
124
+ - **title**: The title of the message you want to send.
125
+ - **message**: The message content you want to send. You can use placeholders like `<@&role_id>` to mention roles in Discord.
126
+ - **events**: An array of event types that will trigger the webhook when they are received by the parser. If this array is empty, the webhook will be triggered for all events.
127
+ - **rate**: The rate limit in seconds for how often the webhook can be triggered. This is to prevent spamming the webhook with too many messages in a short period of time.
128
+
129
+ ### GlobalSettings
130
+ - **EventManagement**: Whether to enable the event management system which includes filtering, tracking nodes, and custom messages.
131
+ - **BetterEventNames**: Changes events to a more specific version depending on parameters, message types, etc. `(Ex. "Tornado Warning" -> "Observed Tornado Warning")`
132
+ - **DisableGeometryParsing**: Disable automatically appending GeoJSON geometry data to the events to save on memory consumption.
133
+ - **UseShapefileCoordinates**: Whether to use the shapefile database to obtain the coordinates for events with specified UGC zones.
134
+ - **SPCWatchesOnly**: Whether to only listen for SPC watches only (TOR/SVR) (If using the API, this is ignored).
135
+ - **NodeTTL**: How often nodes should be checked per event. (Tracking/Filtering)
136
+ - **NodeMinDistance**: The minimum distance to filter events from the node (Miles)
137
+ - **ListeningEvents**: Events you'd like to listen for. If this array is left empty, it will listen for **ALL** events and products.
138
+ - **ListeningICAO**: ICAO codes for the weather stations you'd like to listen for. Filtering all events that do not contain the codes. `(Ex. ["KLOT", "TORD"])`
139
+ - **IgnoredICAO**: Ignored ICAO codes `(Ex. ["KWNS"])`
140
+ - **IgnoredEvents**: Ignored events / products.
141
+ - **ListeningUGC**: Zones you'd like to listen to `(Ex. ["ILZ001"])`
142
+ - **ListeningStates**: States you'd like to listen to `(Ex. ["IL"])`
143
+ - **NodeLocationFiltering**: If you want tracking nodes to filter out events based on radius. (Miles)\
144
+ - **IgnoreTextProducts**: If you want to ignore test products and events.
145
+ - **ArchiveDirectory**: The directory you'd like to store generated EAS audio files.
146
+ - **IntroWavFile**: The PCM16 bit WAV audio file to append to the EAS message.
147
+
75
148
 
76
- ## NOAA Weather Wire Service (Getting Started)
77
- To use the NOAA Weather Wire Service (NWWS). You would need to obtain credentials from the National Weather Service. Follow these steps:
78
- 1. Visit the [NOAA NWWS Registration Page](https://www.weather.gov/nwws/nwws_oi_request).
79
- 2. Fill out the registration form with the required information.
80
- 3. Submit the form and wait for approval. You will receive your NWWS credentials via email.
81
149
 
82
150
  ## Events and Listeners
83
- > All events are in GeoJSON.
84
-
85
- ### Event `onEvents`
86
- Triggered when a batch of new alerts are received and processed.
87
- ```javascript
88
- parser.on(`onEvents`, (alerts) => {
89
- console.log(`Received ${alerts.length} new alerts.`);
90
- alerts.forEach(alert => {
91
- console.log(`${alert.properties.event} for ${alert.properties.locations}`);
92
- });
93
- });
151
+
152
+ ### Event `onServiceStatus`
153
+ Triggers when an update to the XMPP / API service status occurs.
154
+ ```ts
155
+ Client.on(`onServiceStatus`, (xmpp) => {
156
+ /*
157
+ message: string
158
+ data: object
159
+ type: string
160
+ error: boolean
161
+ */
162
+ })
94
163
  ```
95
- Alternatively, you can listen for single alert events using `onSevereThunderstormWarning` or `onTornadoWarning`, etc.
96
- ```javascript
97
- parser.on(`onTornadoWarning`, (alert) => {
98
- console.log(`Tornado Warning issued for ${alert.properties.locations}`);
99
- });
164
+
165
+ ### Event `onTestProduct`
166
+ Triggers when a event is labeled as a **test message**. See [`types.event.ts`](./src/@types/type.event.ts) for properties.
167
+ ```ts
168
+ Client.on(`onTestProduct`, (product: TypeEvent) => {})
100
169
  ```
101
170
 
102
- ### Event `onReconnection`
103
- Triggered when the parser attempts to reconnect to the NWWS service.
104
- ```javascript
105
- parser.on(`onReconnection`, (data) => {
106
- console.log(`Reconnection attempt #${data.reconnects}`);
107
- });
171
+ ### Event `onExpiredProduct`
172
+ Triggers when a event is cancelled, expired, or terminated. See [`types.event.ts`](./src/@types/type.event.ts) for properties.
173
+ ```ts
174
+ Client.on(`onExpiredProduct`, (product: TypeEvent) => {})
108
175
  ```
109
176
 
110
- ### Event `onConnection`
111
- Triggered when the parser successfully connects to the NWWS service.
112
- ```javascript
113
- parser.on(`onConnection`, (nickname) => {
114
- console.log(`Connected to NWWS service as ${nickname}`);
115
- });
177
+ ### Event `onProductType`
178
+ Supports all events and product, simply append the event name to the end like `onProductTypeRadarIndicatedTornadoWarning` and you will receive the event in the listener.
179
+ This listener returns [`types.event.ts`](./src/@types/type.event.ts).
180
+ ```ts
181
+ Client.on(`onProductTypeRadarIndicatedTornadoWarning`, (product: TypeEvent) => {})
116
182
  ```
117
183
 
118
- ### Event `onOccupant`
119
- Triggered when a new occupant is detected on the NWWS XMPP service.
120
- ```javascript
121
- parser.on(`onOccupant`, (data) => {
122
- console.log(`New occupant detected: ${data.occupant}`);
123
- });
184
+ ### Event `onFilteredEvent`, `onIgnoredEvent`, `onFilteredICAO`, `onIgnoredICAO`, `onFilteredUGC`, `onFilteredState`
185
+ These events all support [`types.event.ts`](./src/@types/type.event.ts) and are used to filter out events and products based on your settings.
186
+ ```ts
187
+ Client.on(`onFilteredEvent`, (product: TypeEvent) => {})
124
188
  ```
125
189
 
126
- ### Event `onMessage`
127
- Triggered when a stanza message is validated and received from the XMPP client.
128
- ```javascript
129
- parser.on(`onMessage`, (data) => {
130
- console.log(`Message received from ${data.from}: ${data.message}`);
131
- });
190
+ ### Event `onEventCache`
191
+ When all events in a batch have finished processing, a cache update will trigger allowing you to get a copy of all registered events in a listener. (**GeoJSON**)
192
+ ```ts
193
+ Client.on(`onEventCache`, (cache) => {})
132
194
  ```
133
195
 
134
- ### Event `onTest`
135
- Triggered when a test message comes in. Ex: Test Tsunami Warning
136
- ```javascript
137
- parser.on(`onTest`, (alert) => {
138
- console.log(`Test alert received for ${alert.properties.locations}`);
139
- });
196
+ ### Event `onNodeAdd`, `onNodeUpdate`, `onNodeDelete`
197
+ Triggers when a tracking node gets added, updated, or deleted.
198
+ ```ts
199
+ Client.on(`onNodeAdd`, (cache) => {
200
+ /*
201
+ type: string
202
+ node: object
203
+ */
204
+ })
140
205
  ```
141
206
 
142
- ### Event `onExpired`
143
- Triggered when an alert expires.
144
- ```javascript
145
- parser.on(`onExpired`, (alert) => {
146
- console.log(`Alert expired for ${alert.properties.event} for locations of ${alert.properties.locations}`);
147
- });
207
+ ### Event `onStormPredictionWatch`, `onNonStormPredictionWatch`
208
+ Triggers when a SPC watch gets added, updated, or cancelled. This will also add a custom message if using jorunal or the `log` listener.
209
+ ```ts
210
+ Client.on(`onProductTypeRadarIndicatedTornadoWarning`, (product: TypeEvent) => {})
148
211
  ```
149
212
 
150
- ### Event `onFilteredEvent` / `onIgnoredEvent`
151
- Triggered when an alert is filtered out.
152
- ```javascript
153
- parser.on(`onFilteredEvent`, (alert) => {
154
- console.log(`Alert filtered for ${alert.properties.event}`);
155
- });
156
- parser.on(`onIgnoredEvent`, (alert) => {
157
- console.log(`Alert ignored for ${alert.properties.event}`);
158
- });
213
+ ### Event `onEventStatus`
214
+ Triggers when a single event gets added, updated, or cancelled. This will also add a custom message if using jorunal or the `log` listener.
215
+ ```ts
216
+ Client.on(`onEventStatus`, (cache) => {
217
+ /*
218
+ type: string
219
+ event: <TypeEvent>
220
+ */
221
+ })
159
222
  ```
160
223
 
161
- ### Event `onFilteredICAO` / (`onIgnoredICAO`)
162
- Triggered when an alert is filtered out based on its ICAO code.
163
- ```javascript
164
- parser.on(`onFilteredICAO`, (alert) => {
165
- console.log(`Alert filtered for ${alert.properties.event}`);
166
- });
167
- parser.on(`onIgnoredICAO`, (alert) => {
168
- console.log(`Alert ignored for ${alert.properties.event}`);
169
- });
224
+ ### Function `setSettings`
225
+ Allows you to dynamically update parser settings without restarting the service.
226
+ ```ts
227
+ import { setSettings } from "@atmosx/event-product-parser"
228
+ setSettings({
229
+ Database: `NewDatabaseFile.db`
230
+ })
170
231
  ```
171
232
 
172
- ### Event `onFilteredUGC`
173
- Triggered when an alert is filtered out based on its UGC zone.
174
- ```javascript
175
- parser.on(`onFilteredUGC`, (alert) => {
176
- console.log(`Alert filtered for ${alert.properties.event}`);
177
- });
233
+ ### Function `getEventGeometry`
234
+ Fetches the `events` geometry (GeoJSON) coordinates table.
235
+ ```ts
236
+ import { getEventGeometry } from "@atmosx/event-product-parser"
237
+ const event = {...}
238
+ const geometry = await getEventGeometry(event); // Returns GeoJSON
178
239
  ```
179
240
 
180
- ### Event `onFilteredState`
181
- Triggered when an alert is filtered out based on its state (Abbreviation)
182
- ```javascript
183
- parser.on(`onFilteredState`, (alert) => {
184
- console.log(`Alert filtered for ${alert.properties.event}`);
185
- });
241
+ ### Function `getRandomEvent`
242
+ Fetches a random event from the cache
243
+ ```ts
244
+ import { getRandomEvent } from "@atmosx/event-product-parser"
245
+ const event = getRandomEvent(event); // Returns GeoJSON of an event.
186
246
  ```
187
247
 
188
- ### Event `log`
189
- Triggered for logging purposes, providing log level and message.
190
- ```javascript
191
- parser.on(`log`, (message) => {
192
- console.log(data.message);
193
- });
248
+ ### Function `getVersion`
249
+ Returns the current version of the parser.
250
+ ```ts
251
+ import { getVersion } from "@atmosx/event-product-parser"
252
+ const version = getVersion(); // Returns the current version of the parser.
194
253
  ```
195
254
 
196
- ## Callbacks and Functions
197
255
 
198
- ### Function `setDisplayName(name)`
199
- Sets the display name for the XMPP client. This requires reconnection to take effect.
200
- ```javascript
201
- parser.setDisplayName(`My Weather Parser`);
256
+ ### Function `getCleanedEvent`
257
+ Removed any `NULL` values from the event itself. Therefore cleaning it up from any properties that are `NULL`.
258
+ ```ts
259
+ import { getCleanedEvent } from "@atmosx/event-product-parser"
260
+ const event = {...}
261
+ const cleanedEvent = await getCleanedEvent(event); // Returns cleaned event object.
202
262
  ```
203
263
 
204
- ### Function `createEasAudio(description, header)`
205
- 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.
206
- If you are running linux, festival is required to use this or it will error out.
207
- ```javascript
208
- parser.createEasAudio(`This is a test alert`, `EAS Header Info`);
209
- ```
210
264
 
211
- ### Function `getAllAlertTypes()`
212
- Returns an array of all supported alert types by the parser.
213
- ```javascript
214
- const alertTypes = parser.getAllAlertTypes();
215
- console.log(alertTypes);
265
+ ### Function `startService`
266
+ Starts the event product parser service.
267
+ ```ts
268
+ import { startService } from "@atmosx/event-product-parser"
269
+ startService()
216
270
  ```
217
271
 
218
- ### Function `getEventPolygon(event)`
219
- Retrieves the geographical polygon for a given event based on its generated geocode and UGC zones. (Returns in GeoJSON format)
220
- ```javascript
221
- const polygon = await parser.getEventPolygon(event);
222
- console.log(polygon);
272
+
273
+ ### Function `setNode`
274
+ Sets up a tracking node using an identifier, longitude, and latitude values.
275
+ ```ts
276
+ import { setNode } from "@atmosx/event-product-parser"
277
+ setNode({
278
+ identifier: `TestNode`,
279
+ coordinates: {longitude: -122.4194, latitude: 37.7749},
280
+ delete: false
281
+ })
223
282
  ```
224
283
 
225
- ### Function `searchStanzaDatabase(query)`
226
- Searches the internal stanza database for messages matching the provided query.
227
- ```javascript
228
- const results = parser.searchStanzaDatabase(`Tornado Warning`);
229
- console.log(results);
284
+
285
+ ### Function `getEvents`
286
+ Fetches the list of events from the parser.
287
+ ```ts
288
+ import { getEvents } from "@atmosx/event-product-parser"
289
+ const events = getEvents() // Returns in GeoJSON (Similar to the onEventCache listener)
290
+ console.log(events)
230
291
  ```
231
292
 
232
- ### Function `setSettings({})`
233
- Dynamically updates the parser settings. Accepts the same configuration object as the constructor.
234
- ```javascript
235
- parser.setSettings({
236
- global_settings: {
237
- filtering: {
238
- ignored_icao: [`KXYZ`],
239
- }
240
- }
241
- });
293
+
294
+ ### Function `getNodes`
295
+ Fetches the list of tracking nodes from the parser.
296
+ ```ts
297
+ import { getNodes } from "@atmosx/event-product-parser"
298
+ const nodes = getNodes()
299
+ console.log(nodes)
242
300
  ```
243
301
 
244
- ### Function `stop()`
245
- Stops the parser and disconnects from the NWWS service.
246
- ```javascript
247
- parser.stop();
302
+ ### Function `setEasTone`
303
+ Fetches an EAS audio message for an event (Simulated)
304
+ ```ts
305
+ import { setEasTone } from "@atmosx/event-product-parser"
306
+ const event = {...}
307
+ await setEasTone(event.properties.description, event.properties.metadata.header)
248
308
  ```
249
309
 
310
+ ## Performance Recommendations
311
+ - Enable cache retention
312
+ - Disable geometry parsing if GeoJSON is unnecessary.
313
+
250
314
  ## References
251
315
  [NOAA NWWS Information](https://www.weather.gov/nwws/) |
252
316
  [NWS API Documentation](https://www.weather.gov/documentation/services-web-api) |
@@ -263,6 +327,3 @@ parser.stop();
263
327
 
264
328
  ## Acknowledgements
265
329
  - [k3yomi](https://github.com/k3yomi)
266
- - Lead developer @ AtmosphericX and maintainer of this module.
267
- - [StarflightWx](https://x.com/starflightVR)
268
- - For testing and providing feedback (Co-Developer and Spotter @ AtmosphericX)