@atmosx/event-product-parser 3.0.47 → 3.0.51

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 (59) hide show
  1. package/README.md +48 -21
  2. package/dist/cjs/index.cjs +5841 -15199
  3. package/dist/esm/index.mjs +5827 -15185
  4. package/package.json +5 -6
  5. package/src/@building/building.attachments.ts +6 -6
  6. package/src/@building/building.create.ts +19 -5
  7. package/src/@building/building.enhance.ts +1 -1
  8. package/src/@building/building.geometry.ts +1 -1
  9. package/src/@building/building.polygon.ts +1 -2
  10. package/src/@building/building.signature.ts +0 -1
  11. package/src/@building/building.tracking.ts +4 -4
  12. package/src/@building/building.validate.ts +11 -6
  13. package/src/@core/core.clearEvents.ts +0 -1
  14. package/src/@core/core.createEvent.ts +0 -1
  15. package/src/@core/core.getEvents.ts +0 -1
  16. package/src/@core/core.getNodes.ts +0 -1
  17. package/src/@core/core.getRandomEvent.ts +0 -1
  18. package/src/@core/core.getVersion.ts +0 -1
  19. package/src/@dictionaries/dictionaries.awips.ts +3 -3
  20. package/src/@events/events.api.ts +7 -9
  21. package/src/@events/events.text.ts +5 -6
  22. package/src/@events/events.ugc.ts +5 -5
  23. package/src/@events/events.vtec.ts +4 -5
  24. package/src/@manager/manager.mkEvent.ts +17 -12
  25. package/src/@manager/manager.rmEvent.ts +5 -3
  26. package/src/@manager/manager.setHash.ts +0 -1
  27. package/src/@manager/manager.updateEvents.ts +1 -3
  28. package/src/@manager/manager.updateListener.ts +23 -31
  29. package/src/@manager/manager.updateNodes.ts +2 -3
  30. package/src/@modules/@database/database.cache.ts +6 -4
  31. package/src/@modules/@database/database.init.ts +5 -4
  32. package/src/@modules/@database/database.shapefiles.ts +11 -11
  33. package/src/@modules/@database/database.stanza.ts +2 -3
  34. package/src/@modules/@eas/eas.setAFSK.ts +0 -1
  35. package/src/@modules/@eas/eas.setAsciiToBits.ts +0 -1
  36. package/src/@modules/@eas/eas.setEasTone.ts +6 -2
  37. package/src/@modules/@eas/eas.setNoise.ts +1 -0
  38. package/src/@modules/@eas/eas.setRadioEffect.ts +1 -0
  39. package/src/@modules/@eas/eas.setSameHeader.ts +0 -1
  40. package/src/@modules/@utilities/utilities.createHttp.ts +40 -64
  41. package/src/@modules/@utilities/utilities.getMatched.ts +33 -0
  42. package/src/@modules/@utilities/utilities.setCronSchedule.ts +1 -1
  43. package/src/@modules/@utilities/utilities.setDebug.ts +38 -0
  44. package/src/@modules/@utilities/utilities.setTimeoutAction.ts +5 -1
  45. package/src/@modules/@xmpp/xmpp.xDeploy.ts +1 -2
  46. package/src/@modules/@xmpp/xmpp.xError.ts +0 -2
  47. package/src/@modules/@xmpp/xmpp.xOffline.ts +0 -1
  48. package/src/@modules/@xmpp/xmpp.xOnline.ts +2 -2
  49. package/src/@parsers/@text/text.getEmbed.ts +0 -2
  50. package/src/@parsers/@ugc/ugc.coordinates.ts +2 -1
  51. package/src/@parsers/@ugc/ugc.getCache.ts +24 -0
  52. package/src/@parsers/@ugc/ugc.locations.ts +35 -7
  53. package/src/@parsers/@ugc/ugc.setCache.ts +28 -0
  54. package/src/@types/type.settings.ts +1 -0
  55. package/src/bootstrap.ts +4 -1
  56. package/test.js +15 -21
  57. package/tsup.config.ts +1 -1
  58. package/dist/index.d.mts +0 -299
  59. package/dist/index.d.ts +0 -299
@@ -16,8 +16,9 @@
16
16
  Internal Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
- import { union } from "polygon-clipping";
19
+
20
20
  import { bootstrap } from "../../bootstrap";
21
+ import { union } from "polygon-clipping";
21
22
 
22
23
  interface CoordinatesOptions {
23
24
  zones: string[]
@@ -0,0 +1,24 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { bootstrap } from "../../bootstrap";
21
+
22
+ export const getCache = (key: string) => {
23
+ return bootstrap.cache.ugc.get(key);
24
+ };
@@ -18,12 +18,40 @@
18
18
  */
19
19
 
20
20
  import { bootstrap } from "../../bootstrap";
21
+ import { getCache } from "./ugc.getCache";
22
+ import { setCache } from "./ugc.setCache";
21
23
 
22
24
  export const getLocations = async (zones: string[]): Promise<string[]> => {
23
- const sites = Array.from(new Set(zones));
24
- const placeholders = sites.map(() => '?').join(',');
25
- const rows = await bootstrap.database
26
- .prepare(`SELECT id, location FROM shapefiles WHERE id IN (${placeholders})`)
27
- .all(...sites)
28
- return rows.map((row: any) => row.location).sort();
29
- }
25
+ const uniqueZones = Array.from(new Set(zones));
26
+
27
+ const results: string[] = [];
28
+ const missing: string[] = [];
29
+
30
+ for (let i = 0; i < uniqueZones.length; i++) {
31
+ const zone = uniqueZones[i];
32
+ const cached = getCache(zone);
33
+
34
+ if (cached) {
35
+ for (let j = 0; j < cached.length; j++) {
36
+ results.push(cached[j]);
37
+ }
38
+ } else {
39
+ missing.push(zone);
40
+ }
41
+ }
42
+
43
+ if (missing.length > 0) {
44
+ const rows = await bootstrap.database
45
+ .prepare(
46
+ `SELECT id, location FROM shapefiles WHERE id IN (${missing.map(() => '?').join(',')})`
47
+ )
48
+ .all(...missing);
49
+
50
+ for (let i = 0; i < rows.length; i++) {
51
+ const r = rows[i] as any;
52
+ setCache(r.id, [r.location]);
53
+ results.push(r.location);
54
+ }
55
+ }
56
+ return results;
57
+ };
@@ -0,0 +1,28 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { bootstrap } from "../../bootstrap";
21
+
22
+ export const setCache = (key: string, value: string[]) => {
23
+ if (bootstrap.cache.ugc.size >= 5000) {
24
+ const firstKey = bootstrap.cache.ugc.keys().next().value;
25
+ bootstrap.cache.ugc.delete(firstKey);
26
+ }
27
+ bootstrap.cache.ugc.set(key, value);
28
+ };
@@ -23,6 +23,7 @@ export type TypeSettings = {
23
23
  Database: string
24
24
  EnableWireService: boolean
25
25
  EnableJournal: boolean
26
+ EnableDebugging: boolean
26
27
  NOAAWeatherWireServiceSettings: {
27
28
  ReconnectionSettings: {
28
29
  Enabled: boolean
package/src/bootstrap.ts CHANGED
@@ -21,7 +21,7 @@ import path from 'path'
21
21
  import { EventEmitter } from 'node:events';
22
22
 
23
23
  export const bootstrap = {
24
- version: `3.0.47`,
24
+ version: `3.0.51`,
25
25
  isReady: true,
26
26
  ratelimits: {},
27
27
  session_xmpp: null,
@@ -42,10 +42,13 @@ export const bootstrap = {
42
42
  events: {type: "FeatureCollection", features: []},
43
43
  nodes: {type: "FeatureCollection", features: []},
44
44
  hashes: [],
45
+ processed: [],
46
+ ugc: new Map<string, string[]>()
45
47
  },
46
48
  settings: {
47
49
  Database: path.join(process.cwd(), 'shapefiles.db'),
48
50
  EnableWireService: true,
51
+ EnableDebugging: false,
49
52
  EnableJournal: true,
50
53
  NOAAWeatherWireServiceSettings: {
51
54
  ReconnectionSettings: {
package/test.js CHANGED
@@ -4,6 +4,7 @@ const Client = new Manager({
4
4
  Database: `shapefiles.db`,
5
5
  EnableWireService: false,
6
6
  EnableJournal: true,
7
+ EnableDebugging: false,
7
8
  NOAAWeatherWireServiceSettings: {
8
9
  ReconnectionSettings: {
9
10
  Enabled: true,
@@ -61,30 +62,23 @@ const Client = new Manager({
61
62
  NodeMinDistance: 120,
62
63
  EventFiltering: {
63
64
  ListeningEvents: [
64
- "Tornado Emergency", "PDS Tornado Warning", "Tornado Warning",
65
- "Confirmed Tornado Warning", "Radar Indicated Tornado Warning",
66
- "Special Marine Warning (TPROB)", "PDS Tornado Watch", "Tornado Watch",
67
- "EDS Severe Thunderstorm Warning (TPROB)", "EDS Severe Thunderstorm Warning",
68
- "Destructive Severe Thunderstorm Warning (TPROB)", "Destructive Severe Thunderstorm Warning",
69
- "Considerable Severe Thunderstorm Warning (TPROB)", "Considerable Severe Thunderstorm Warning",
70
- "Severe Thunderstorm Warning (TPROB)", "Severe Thunderstorm Warning",
71
- "Severe Thunderstorm Watch",
72
- "Flash Flood Emergency", "Flash Flood Warning",
73
- "Flash Flood Watch",
74
- "Tsunami Warning", "Tsunami Watch",
75
- "Tsunami Advisory", "Special Marine Warning",
76
- "Earthquake Warning",
77
- "Hurricane Warning", "Hurricane Watch",
78
- "Tropical Storm Warning",
79
- "Winter Storm Warning", "Blizzard Warning",
80
- "Ice Storm Warning", "Snow Squall Warning",
81
- "Winter Weather Advisory", "Extreme Cold Watch"
65
+ "*Severe Thunderstorm Warning*",
66
+ "*Blizzard*", "*Ice Storm*", "*Winter Storm*", "*Snow Squall*",
67
+ "Tornado Emergency", "*Tornado Warning*",
68
+ "Special Weather Statement", "Marine Weather Statement",
69
+ "*Tsunami*", "*Hurricane*", "*Tropical Storm*", "*Special Marine*",
70
+ "*Flash Flood Warning*", "*Flash Flood Watch*", "*Flash Flood Advisory*",
71
+ "Mesoscale Discussion",
72
+ "SPC Day 1 Outlook", "SPC Day 2 Outlook", "SPC Day 3 Outlook",
73
+ "PDS Tornado Watch", "Tornado Watch", "Severe Thunderstorm Watch", "Flash Flood Watch", "PDS Severe Thunderstorm Watch",
74
+ "*Administrative*", "National Weather Service Policy",
75
+ "Fire Weather Warning", "Fire Weather Watch", "Fire Weather Advisory",
82
76
  ],
83
- ListeningICAO: [],
77
+ ListeningICAO: [`KLOT`],
84
78
  IgnoredICAO: [],
85
79
  IgnoredEvents: [],
86
- ListeningUGC: [],
87
- ListeningStates: [],
80
+ ListeningUGC: [`WIC001`],
81
+ ListeningStates: [`MO`, `IA`],
88
82
  NodeLocationFiltering: false,
89
83
  IgnoreTestProducts: true,
90
84
  },
package/tsup.config.ts CHANGED
@@ -4,7 +4,7 @@ export default defineConfig({
4
4
  entry: ['src/index.ts'],
5
5
  outDir: 'dist',
6
6
  format: ['esm', 'cjs'],
7
- dts: true,
7
+ dts: false,
8
8
  noExternal: ["@xmpp/client", "@xmpp/sasl", "@xmpp/sasl-plain"],
9
9
  clean: true,
10
10
  outExtension({ format }) {
package/dist/index.d.mts DELETED
@@ -1,299 +0,0 @@
1
- type TypeListener = {
2
- events: string[];
3
- webhook?: {
4
- enabled: boolean;
5
- destination: string;
6
- ratelimit: number;
7
- title: string;
8
- message: string;
9
- };
10
- uploads?: {
11
- file?: boolean;
12
- eas?: boolean;
13
- event?: boolean;
14
- };
15
- };
16
-
17
- type TypeSettings = {
18
- Database: string;
19
- EnableWireService: boolean;
20
- EnableJournal: boolean;
21
- NOAAWeatherWireServiceSettings: {
22
- ReconnectionSettings: {
23
- Enabled: boolean;
24
- ReconnectionInterval: number;
25
- };
26
- CredentialSettings: {
27
- Username: string | void;
28
- Password: string | void;
29
- Nickname: string | void;
30
- };
31
- CacheSettings: {
32
- Enabled: boolean;
33
- MaxDatabaseHistory: number;
34
- MaxRetentionHistory: number;
35
- };
36
- StanzaSettings: {
37
- DisableUGC: boolean;
38
- DisableVTEC: boolean;
39
- DisableText: boolean;
40
- };
41
- };
42
- NationalWeatherServiceSettings: {
43
- CallbackInterval: number;
44
- EventsEndpoint: string;
45
- };
46
- BroadcastifySettings: {
47
- BroadcastifyAttachments: boolean;
48
- BroadcastifyDatabase: string;
49
- BroadcastifyTags: string[];
50
- };
51
- GlobalSettings: {
52
- EventManagement: boolean;
53
- BetterEventNames: boolean;
54
- DisableGeometryParsing: boolean;
55
- UseShapefileCoordinates: boolean;
56
- SPCWatchesOnly: boolean;
57
- ShapefileSkipPoints: number;
58
- NodeTTL: number;
59
- NodeMinDistance: number;
60
- ListenerSettings?: TypeListener[];
61
- EventFiltering: {
62
- ListeningEvents: string[];
63
- ListeningICAO: string[];
64
- ListeningUGC: string[];
65
- ListeningStates: string[];
66
- IgnoredICAO: string[];
67
- IgnoredEvents: string[];
68
- NodeLocationFiltering: boolean;
69
- IgnoreTestProducts: boolean;
70
- };
71
- ArchiveSettings: {
72
- TTL: number;
73
- EventDirectory: string;
74
- TextDirectory: string;
75
- EasDirectory: string;
76
- EasToneout: string;
77
- };
78
- };
79
- };
80
-
81
- declare const setSettings: (newSettings: TypeSettings) => TypeSettings;
82
-
83
- type TypeAttributes = {
84
- xmlns: string;
85
- id: string;
86
- issue: string;
87
- ttaaii: string;
88
- cccc: string;
89
- awipsid: string;
90
- };
91
-
92
- type TypeEventProperties = {
93
- locations: string;
94
- locations_array: string[];
95
- description: string;
96
- attributes?: TypeAttributes;
97
- geocode: {
98
- office: {
99
- name: string;
100
- office: string;
101
- };
102
- organization: string;
103
- ugc: string[];
104
- polygon: string;
105
- polygon_generated: boolean;
106
- };
107
- parameters?: {
108
- tags: string[];
109
- instructions: string;
110
- source: string;
111
- hazards: string;
112
- impacts: string;
113
- estimated_hail_size: string;
114
- estimated_wind_gusts: string;
115
- damage_threat: string;
116
- tornado_threat: string;
117
- flood_threat: string;
118
- wind_threat: string;
119
- hail_threat: string;
120
- max_hail_inches?: string;
121
- max_wind_gusts_surface_knots?: string;
122
- max_tops_x100feet?: string;
123
- mean_storm_motion_vector?: string;
124
- particularly_dangerous_situation?: string;
125
- };
126
- watch_parameters?: {
127
- watch_number: string;
128
- watch_type: string;
129
- additional_tornadoes_probability: string;
130
- strong_tornadoes_probability: string;
131
- severe_wind_probability: string;
132
- severe_hail_probability: string;
133
- hail_2in_probability: string;
134
- combined_hail_wind_probability: string;
135
- max_hail_in: string;
136
- max_wind_surface: string;
137
- max_tops_x100feet: string;
138
- pds_watch: boolean;
139
- };
140
- discussion_parameters?: {
141
- discussion_number: string;
142
- discussion_concerning: string;
143
- discussion_max_tornado: string;
144
- discussion_max_hail: string;
145
- discussion_max_wind: string;
146
- discussion_watch_issuance: string;
147
- };
148
- };
149
-
150
- type TypeHVTEC = {
151
- hvtec: string;
152
- severity: string;
153
- cause: string;
154
- record: string;
155
- };
156
-
157
- type TypePVTEC = {
158
- vtec: string;
159
- product: string;
160
- tracking: string;
161
- event: string;
162
- status: string;
163
- organization: string;
164
- expires: string;
165
- is_watch: boolean;
166
- prediction_center: boolean;
167
- };
168
-
169
- type TypeEvent = {
170
- type: string;
171
- geometry: {
172
- type: string;
173
- coordinates: number[][];
174
- };
175
- properties: {
176
- event: string;
177
- parent: string;
178
- status: string;
179
- issued: string;
180
- expires: string;
181
- status_metadata?: {
182
- is_issued?: boolean;
183
- is_updated?: boolean;
184
- is_expired?: boolean;
185
- is_test?: boolean;
186
- is_statement?: boolean;
187
- };
188
- metadata: {
189
- ms: number;
190
- source: string;
191
- tracking: string;
192
- hash?: string;
193
- header: string;
194
- vtec?: TypePVTEC | null;
195
- hvtec?: TypeHVTEC[] | null;
196
- nodes?: {
197
- id?: string | number;
198
- coordinates: [number, number];
199
- nearest: [number, number];
200
- miles: number | null;
201
- kilometers: number | null;
202
- proximity: boolean;
203
- }[];
204
- filtered_proximity?: boolean;
205
- updated?: number;
206
- history: {
207
- description: string;
208
- issued: string;
209
- status: string;
210
- }[];
211
- attachments?: {
212
- name: string;
213
- link: string;
214
- }[];
215
- raw: string;
216
- };
217
- } & TypeEventProperties;
218
- };
219
-
220
- interface GetGeometryResponse {
221
- type: `Polygon` | `MultiPolygon`;
222
- coordinates: any[];
223
- }
224
- declare const getEventGeometry: (event: TypeEvent) => Promise<GetGeometryResponse>;
225
-
226
- declare const getCleanedEvent: <T extends Record<string, any>>(event: T) => T;
227
-
228
- declare const startService: (configurations: TypeSettings) => Promise<void>;
229
-
230
- declare const stopService: () => Promise<void>;
231
-
232
- interface GenerateEASOptions {
233
- message: string;
234
- header: string;
235
- title: string;
236
- }
237
- declare const setEasTone: (options: GenerateEASOptions) => Promise<string>;
238
-
239
- interface GetNodeOptions {
240
- identifier: string;
241
- delete?: boolean;
242
- coordinates: {
243
- longitude: number;
244
- latitude: number;
245
- };
246
- }
247
- declare const setNode: (options: GetNodeOptions) => void;
248
-
249
- declare const getEvents: () => any;
250
-
251
- declare const getNodes: () => any;
252
-
253
- interface CreateEventOptions {
254
- event: string;
255
- status: string;
256
- issued: Date;
257
- expires: Date;
258
- locations: string;
259
- description: string;
260
- coordinates: number[][];
261
- }
262
- declare const createEvent: (options: CreateEventOptions) => void;
263
-
264
- declare const getRandomEvent: () => any;
265
-
266
- type TypeStanza = {
267
- getChild(arg0: string): unknown;
268
- is(arg0: string): unknown;
269
- name: string;
270
- parent: TypeStanza | null;
271
- children: any;
272
- attrs: {
273
- xmlns: string;
274
- id: string;
275
- issue: string;
276
- ttaaii: string;
277
- cccc: string;
278
- awipsid: string;
279
- from: string;
280
- to: string;
281
- type: string;
282
- };
283
- };
284
-
285
- interface QueryOptions {
286
- search: string;
287
- max?: number;
288
- }
289
- declare const query: (options: QueryOptions) => Promise<TypeStanza[]>;
290
-
291
- declare const clearEvents: () => void;
292
-
293
- declare class Manager {
294
- constructor(settings: TypeSettings);
295
- on(event: string, callback: () => void): void;
296
- trycatch(): void;
297
- }
298
-
299
- export { Manager, type TypeEvent, clearEvents, createEvent, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, query, setEasTone, setNode, setSettings, startService, stopService };