atmosx-nwws-parser 1.0.202 → 1.0.203

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 (57) hide show
  1. package/dist/cjs/{helper.cjs → index.cjs} +65 -34
  2. package/dist/esm/{helper.mjs → index.mjs} +61 -30
  3. package/package.json +1 -1
  4. package/src/bootstrap.ts +1 -0
  5. package/src/dictionaries/events.ts +12 -12
  6. package/src/{helper.ts → index.ts} +1 -1
  7. package/src/parsers/events.ts +7 -2
  8. package/src/parsers/types/api.ts +8 -2
  9. package/src/parsers/types/cap.ts +8 -2
  10. package/src/parsers/types/text.ts +1 -1
  11. package/src/parsers/types/ugc.ts +1 -1
  12. package/src/parsers/types/vtec.ts +1 -1
  13. package/src/types.ts +1 -0
  14. package/src/utils.ts +3 -3
  15. package/tsup.config.ts +10 -7
  16. package/dist/cjs/bootstrap.cjs +0 -1000
  17. package/dist/cjs/database.cjs +0 -1105
  18. package/dist/cjs/dictionaries/awips.cjs +0 -370
  19. package/dist/cjs/dictionaries/events.cjs +0 -139
  20. package/dist/cjs/dictionaries/icao.cjs +0 -265
  21. package/dist/cjs/dictionaries/offshore.cjs +0 -40
  22. package/dist/cjs/dictionaries/signatures.cjs +0 -132
  23. package/dist/cjs/eas.cjs +0 -2851
  24. package/dist/cjs/parsers/events.cjs +0 -2851
  25. package/dist/cjs/parsers/stanza.cjs +0 -1099
  26. package/dist/cjs/parsers/text.cjs +0 -1133
  27. package/dist/cjs/parsers/types/api.cjs +0 -2851
  28. package/dist/cjs/parsers/types/cap.cjs +0 -2851
  29. package/dist/cjs/parsers/types/text.cjs +0 -2851
  30. package/dist/cjs/parsers/types/ugc.cjs +0 -2851
  31. package/dist/cjs/parsers/types/vtec.cjs +0 -2851
  32. package/dist/cjs/parsers/ugc.cjs +0 -1130
  33. package/dist/cjs/parsers/vtec.cjs +0 -1051
  34. package/dist/cjs/types.cjs +0 -17
  35. package/dist/cjs/utils.cjs +0 -2851
  36. package/dist/cjs/xmpp.cjs +0 -2851
  37. package/dist/esm/bootstrap.mjs +0 -963
  38. package/dist/esm/database.mjs +0 -1070
  39. package/dist/esm/dictionaries/awips.mjs +0 -346
  40. package/dist/esm/dictionaries/events.mjs +0 -111
  41. package/dist/esm/dictionaries/icao.mjs +0 -241
  42. package/dist/esm/dictionaries/offshore.mjs +0 -16
  43. package/dist/esm/dictionaries/signatures.mjs +0 -106
  44. package/dist/esm/eas.mjs +0 -2818
  45. package/dist/esm/parsers/events.mjs +0 -2818
  46. package/dist/esm/parsers/stanza.mjs +0 -1063
  47. package/dist/esm/parsers/text.mjs +0 -1097
  48. package/dist/esm/parsers/types/api.mjs +0 -2818
  49. package/dist/esm/parsers/types/cap.mjs +0 -2818
  50. package/dist/esm/parsers/types/text.mjs +0 -2818
  51. package/dist/esm/parsers/types/ugc.mjs +0 -2818
  52. package/dist/esm/parsers/types/vtec.mjs +0 -2818
  53. package/dist/esm/parsers/ugc.mjs +0 -1095
  54. package/dist/esm/parsers/vtec.mjs +0 -1016
  55. package/dist/esm/types.mjs +0 -0
  56. package/dist/esm/utils.mjs +0 -2818
  57. package/dist/esm/xmpp.mjs +0 -2818
@@ -21,6 +21,18 @@ var __spreadValues = (a, b) => {
21
21
  return a;
22
22
  };
23
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
24
36
  var __export = (target, all) => {
25
37
  for (var name in all)
26
38
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -63,9 +75,9 @@ var __async = (__this, __arguments, generator) => {
63
75
  });
64
76
  };
65
77
 
66
- // src/helper.ts
67
- var helper_exports = {};
68
- __export(helper_exports, {
78
+ // src/index.ts
79
+ var index_exports = {};
80
+ __export(index_exports, {
69
81
  AlertManager: () => AlertManager,
70
82
  Database: () => database_default,
71
83
  EAS: () => eas_default,
@@ -74,10 +86,10 @@ __export(helper_exports, {
74
86
  TextParser: () => text_default,
75
87
  UGCParser: () => ugc_default,
76
88
  VtecParser: () => vtec_default,
77
- default: () => helper_default,
89
+ default: () => index_default,
78
90
  types: () => types_exports
79
91
  });
80
- module.exports = __toCommonJS(helper_exports);
92
+ module.exports = __toCommonJS(index_exports);
81
93
 
82
94
  // src/bootstrap.ts
83
95
  var fs = __toESM(require("fs"));
@@ -185,17 +197,17 @@ var TYPES = {
185
197
  "X": "Experimental Product (Non-Operational)"
186
198
  };
187
199
  var STATUS_CORRELATIONS = [
188
- { type: "Update", forward: "Updated", cancel: false },
189
- { type: "Cancel", forward: "Cancelled", cancel: true },
190
- { type: "Alert", forward: "Issued", cancel: false },
191
- { type: "Updated", forward: "Updated", cancel: false },
192
- { type: "Expired", forward: "Expired", cancel: true },
193
- { type: "Issued", forward: "Issued", cancel: false },
194
- { type: "Extended", forward: "Updated", cancel: false },
195
- { type: "Correction", forward: "Updated", cancel: false },
196
- { type: "Upgraded", forward: "Upgraded", cancel: false },
197
- { type: "Cancelled", forward: "Cancelled", cancel: true },
198
- { type: "Routine", forward: "Routine", cancel: false }
200
+ { type: "Update", forward: "Updated", cancel: false, update: true, new: false },
201
+ { type: "Cancel", forward: "Cancelled", cancel: true, update: false, new: false },
202
+ { type: "Alert", forward: "Issued", cancel: false, update: false, new: true },
203
+ { type: "Updated", forward: "Updated", cancel: false, update: true, new: false },
204
+ { type: "Expired", forward: "Expired", cancel: true, update: false, new: false },
205
+ { type: "Issued", forward: "Issued", cancel: false, update: false, new: true },
206
+ { type: "Extended", forward: "Updated", cancel: false, update: true, new: false },
207
+ { type: "Correction", forward: "Updated", cancel: false, update: true, new: false },
208
+ { type: "Upgraded", forward: "Upgraded", cancel: false, update: true, new: false },
209
+ { type: "Cancelled", forward: "Cancelled", cancel: true, update: false, new: false },
210
+ { type: "Routine", forward: "Routine", cancel: false, update: true, new: false }
199
211
  ];
200
212
 
201
213
  // src/dictionaries/offshore.ts
@@ -929,6 +941,7 @@ var cache = {
929
941
  var settings = {
930
942
  database: path.join(process.cwd(), "shapefiles.db"),
931
943
  isNWWS: true,
944
+ catchUnhandledExceptions: false,
932
945
  NoaaWeatherWireService: {
933
946
  clientReconnections: {
934
947
  canReconnect: true,
@@ -1504,7 +1517,7 @@ var VTECAlerts = class {
1504
1517
  const getBaseProperties = yield events_default.getBaseProperties(message, validated, getUGC, vtec);
1505
1518
  const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties, vtec);
1506
1519
  processed.push({
1507
- preformance: performance.now() - tick,
1520
+ performance: performance.now() - tick,
1508
1521
  tracking: vtec.tracking,
1509
1522
  header: getHeader,
1510
1523
  vtec: vtec.raw,
@@ -1572,7 +1585,7 @@ var UGCAlerts = class {
1572
1585
  const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
1573
1586
  const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
1574
1587
  processed.push({
1575
- preformance: performance.now() - tick,
1588
+ performance: performance.now() - tick,
1576
1589
  tracking: this.getTracking(getBaseProperties, getUGC.zones),
1577
1590
  header: getHeader,
1578
1591
  vtec: `N/A`,
@@ -1610,7 +1623,7 @@ var UGCAlerts2 = class {
1610
1623
  const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
1611
1624
  const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
1612
1625
  processed.push({
1613
- preformance: performance.now() - tick,
1626
+ performance: performance.now() - tick,
1614
1627
  tracking: this.getTracking(getBaseProperties),
1615
1628
  header: getHeader,
1616
1629
  vtec: `N/A`,
@@ -1668,7 +1681,7 @@ var CapAlerts = class {
1668
1681
  const getHeader = events_default.getHeader(__spreadValues({}, validated.attributes));
1669
1682
  const getSource = text_default.textProductToString(extracted.description, `SOURCE...`, [`.`]) || `N/A`;
1670
1683
  processed.push({
1671
- preformance: performance.now() - tick,
1684
+ performance: performance.now() - tick,
1672
1685
  tracking: this.getTracking(extracted),
1673
1686
  header: getHeader,
1674
1687
  vtec: extracted.vtec || `N/A`,
@@ -1699,7 +1712,13 @@ var CapAlerts = class {
1699
1712
  discussion_wind_intensity: `N/A`,
1700
1713
  discussion_hail_intensity: `N/A`
1701
1714
  },
1702
- geometry: extracted.polygon ? { type: `Polygon`, coordinates: extracted.polygon.split(` `).map((coord) => coord.split(`,`).map((num) => parseFloat(num))) } : null
1715
+ geometry: extracted.polygon ? {
1716
+ type: `Polygon`,
1717
+ coordinates: extracted.polygon.split(` `).map((coord) => {
1718
+ const [lon, lat] = coord.split(`,`).map((num) => parseFloat(num));
1719
+ return [lat, lon];
1720
+ })
1721
+ } : null
1703
1722
  }
1704
1723
  });
1705
1724
  }
@@ -1726,7 +1745,7 @@ var APIAlerts = class {
1726
1745
  }
1727
1746
  static event(validated) {
1728
1747
  return __async(this, null, function* () {
1729
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca;
1748
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia;
1730
1749
  let processed = [];
1731
1750
  const messages = Object.values(JSON.parse(validated.message).features);
1732
1751
  for (let feature of messages) {
@@ -1741,7 +1760,7 @@ var APIAlerts = class {
1741
1760
  const getSource = text_default.textProductToString(getDescription, `SOURCE...`, [`.`]) || `N/A`;
1742
1761
  const getOffice = this.getICAO(getVTEC || ``);
1743
1762
  processed.push({
1744
- preformance: performance.now() - tick,
1763
+ performance: performance.now() - tick,
1745
1764
  tracking: this.getTracking({ vtec: getVTEC, wmoidentifier: getWmo, ugc: getUgc ? getUgc.join(`,`) : null }),
1746
1765
  header: getHeader,
1747
1766
  vtec: getVTEC || `N/A`,
@@ -1776,7 +1795,13 @@ var APIAlerts = class {
1776
1795
  peakWindGust: `N/A`,
1777
1796
  peakHailSize: `N/A`
1778
1797
  },
1779
- geometry: (_ca = feature == null ? void 0 : feature.geometry) != null ? _ca : null
1798
+ geometry: ((_ea = (_da = (_ca = feature == null ? void 0 : feature.geometry) == null ? void 0 : _ca.coordinates) == null ? void 0 : _da[0]) == null ? void 0 : _ea.length) ? {
1799
+ type: ((_fa = feature == null ? void 0 : feature.geometry) == null ? void 0 : _fa.type) || "Polygon",
1800
+ coordinates: (_ia = (_ha = (_ga = feature == null ? void 0 : feature.geometry) == null ? void 0 : _ga.coordinates) == null ? void 0 : _ha[0]) == null ? void 0 : _ia.map((coord) => {
1801
+ const [lon, lat] = Array.isArray(coord) ? coord : [0, 0];
1802
+ return [lon, lat];
1803
+ })
1804
+ } : null
1780
1805
  }
1781
1806
  });
1782
1807
  }
@@ -2330,16 +2355,17 @@ var EventParser = class {
2330
2355
  }
2331
2356
  }
2332
2357
  const filtered = events2.filter((alert) => {
2333
- var _a2, _b2, _c2, _d2;
2358
+ var _a2, _b2, _d2, _e2;
2334
2359
  const originalEvent = alert;
2335
2360
  const props = originalEvent == null ? void 0 : originalEvent.properties;
2336
2361
  const ugcs = (_b2 = (_a2 = props == null ? void 0 : props.geocode) == null ? void 0 : _a2.UGC) != null ? _b2 : [];
2362
+ const _c2 = originalEvent, { performance: performance2, header } = _c2, eventWithoutPerformance = __objRest(_c2, ["performance", "header"]);
2337
2363
  if (bools == null ? void 0 : bools.betterEventParsing) {
2338
2364
  const { eventName, tags } = this.enhanceEvent(originalEvent);
2339
2365
  originalEvent.properties.event = eventName;
2340
2366
  originalEvent.properties.tags = tags;
2341
2367
  }
2342
- const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_c2 = props.parent) == null ? void 0 : _c2.toLowerCase() : (_d2 = props.event) == null ? void 0 : _d2.toLowerCase();
2368
+ const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_d2 = props.parent) == null ? void 0 : _d2.toLowerCase() : (_e2 = props.event) == null ? void 0 : _e2.toLowerCase();
2343
2369
  const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
2344
2370
  for (const key in sets) {
2345
2371
  const setting = sets[key];
@@ -2358,13 +2384,15 @@ var EventParser = class {
2358
2384
  if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
2359
2385
  }
2360
2386
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
2361
- originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true && bools.checkExpired : false;
2387
+ originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true : false;
2388
+ originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true : false;
2389
+ originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true : false;
2390
+ originalEvent.hash = packages.crypto.createHash("md5").update(JSON.stringify(eventWithoutPerformance)).digest("hex");
2362
2391
  if (props.description) {
2363
2392
  const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
2364
- if (detectedPhrase && bools.checkExpired) {
2393
+ if (detectedPhrase) {
2365
2394
  originalEvent.properties.action_type = "Cancel";
2366
2395
  originalEvent.properties.is_cancelled = true;
2367
- return false;
2368
2396
  }
2369
2397
  }
2370
2398
  if (originalEvent.vtec) {
@@ -2374,6 +2402,7 @@ var EventParser = class {
2374
2402
  return false;
2375
2403
  }
2376
2404
  }
2405
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
2377
2406
  cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
2378
2407
  return true;
2379
2408
  });
@@ -2738,8 +2767,8 @@ var Utils = class {
2738
2767
  * @static
2739
2768
  */
2740
2769
  static detectUncaughtExceptions() {
2741
- if (process.listeners("uncaughtException").some((l) => l.name === "uncaughtExceptionHandler")) return;
2742
- process.on(`uncaughtException`, (error) => {
2770
+ if (cache.events.listenerCount("uncaughtException") > 0) return;
2771
+ cache.events.on("uncaughtException", (error) => {
2743
2772
  cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
2744
2773
  });
2745
2774
  }
@@ -2857,7 +2886,7 @@ var Utils = class {
2857
2886
  };
2858
2887
  var utils_default = Utils;
2859
2888
 
2860
- // src/helper.ts
2889
+ // src/index.ts
2861
2890
  var AlertManager = class {
2862
2891
  constructor(metadata) {
2863
2892
  this.start(metadata);
@@ -2962,7 +2991,9 @@ var AlertManager = class {
2962
2991
  return Promise.resolve();
2963
2992
  }
2964
2993
  this.setSettings(metadata);
2965
- utils_default.detectUncaughtExceptions();
2994
+ if (settings.catchUnhandledExceptions) {
2995
+ utils_default.detectUncaughtExceptions();
2996
+ }
2966
2997
  const settings2 = settings;
2967
2998
  this.isNoaaWeatherWireService = settings.isNWWS;
2968
2999
  cache.isReady = false;
@@ -2998,7 +3029,7 @@ var AlertManager = class {
2998
3029
  });
2999
3030
  }
3000
3031
  };
3001
- var helper_default = AlertManager;
3032
+ var index_default = AlertManager;
3002
3033
  // Annotate the CommonJS export names for ESM import in node:
3003
3034
  0 && (module.exports = {
3004
3035
  AlertManager,
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
20
32
  var __async = (__this, __arguments, generator) => {
21
33
  return new Promise((resolve, reject) => {
22
34
  var fulfilled = (value) => {
@@ -144,17 +156,17 @@ var TYPES = {
144
156
  "X": "Experimental Product (Non-Operational)"
145
157
  };
146
158
  var STATUS_CORRELATIONS = [
147
- { type: "Update", forward: "Updated", cancel: false },
148
- { type: "Cancel", forward: "Cancelled", cancel: true },
149
- { type: "Alert", forward: "Issued", cancel: false },
150
- { type: "Updated", forward: "Updated", cancel: false },
151
- { type: "Expired", forward: "Expired", cancel: true },
152
- { type: "Issued", forward: "Issued", cancel: false },
153
- { type: "Extended", forward: "Updated", cancel: false },
154
- { type: "Correction", forward: "Updated", cancel: false },
155
- { type: "Upgraded", forward: "Upgraded", cancel: false },
156
- { type: "Cancelled", forward: "Cancelled", cancel: true },
157
- { type: "Routine", forward: "Routine", cancel: false }
159
+ { type: "Update", forward: "Updated", cancel: false, update: true, new: false },
160
+ { type: "Cancel", forward: "Cancelled", cancel: true, update: false, new: false },
161
+ { type: "Alert", forward: "Issued", cancel: false, update: false, new: true },
162
+ { type: "Updated", forward: "Updated", cancel: false, update: true, new: false },
163
+ { type: "Expired", forward: "Expired", cancel: true, update: false, new: false },
164
+ { type: "Issued", forward: "Issued", cancel: false, update: false, new: true },
165
+ { type: "Extended", forward: "Updated", cancel: false, update: true, new: false },
166
+ { type: "Correction", forward: "Updated", cancel: false, update: true, new: false },
167
+ { type: "Upgraded", forward: "Upgraded", cancel: false, update: true, new: false },
168
+ { type: "Cancelled", forward: "Cancelled", cancel: true, update: false, new: false },
169
+ { type: "Routine", forward: "Routine", cancel: false, update: true, new: false }
158
170
  ];
159
171
 
160
172
  // src/dictionaries/offshore.ts
@@ -888,6 +900,7 @@ var cache = {
888
900
  var settings = {
889
901
  database: path.join(process.cwd(), "shapefiles.db"),
890
902
  isNWWS: true,
903
+ catchUnhandledExceptions: false,
891
904
  NoaaWeatherWireService: {
892
905
  clientReconnections: {
893
906
  canReconnect: true,
@@ -1463,7 +1476,7 @@ var VTECAlerts = class {
1463
1476
  const getBaseProperties = yield events_default.getBaseProperties(message, validated, getUGC, vtec);
1464
1477
  const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties, vtec);
1465
1478
  processed.push({
1466
- preformance: performance.now() - tick,
1479
+ performance: performance.now() - tick,
1467
1480
  tracking: vtec.tracking,
1468
1481
  header: getHeader,
1469
1482
  vtec: vtec.raw,
@@ -1531,7 +1544,7 @@ var UGCAlerts = class {
1531
1544
  const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
1532
1545
  const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
1533
1546
  processed.push({
1534
- preformance: performance.now() - tick,
1547
+ performance: performance.now() - tick,
1535
1548
  tracking: this.getTracking(getBaseProperties, getUGC.zones),
1536
1549
  header: getHeader,
1537
1550
  vtec: `N/A`,
@@ -1569,7 +1582,7 @@ var UGCAlerts2 = class {
1569
1582
  const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
1570
1583
  const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
1571
1584
  processed.push({
1572
- preformance: performance.now() - tick,
1585
+ performance: performance.now() - tick,
1573
1586
  tracking: this.getTracking(getBaseProperties),
1574
1587
  header: getHeader,
1575
1588
  vtec: `N/A`,
@@ -1627,7 +1640,7 @@ var CapAlerts = class {
1627
1640
  const getHeader = events_default.getHeader(__spreadValues({}, validated.attributes));
1628
1641
  const getSource = text_default.textProductToString(extracted.description, `SOURCE...`, [`.`]) || `N/A`;
1629
1642
  processed.push({
1630
- preformance: performance.now() - tick,
1643
+ performance: performance.now() - tick,
1631
1644
  tracking: this.getTracking(extracted),
1632
1645
  header: getHeader,
1633
1646
  vtec: extracted.vtec || `N/A`,
@@ -1658,7 +1671,13 @@ var CapAlerts = class {
1658
1671
  discussion_wind_intensity: `N/A`,
1659
1672
  discussion_hail_intensity: `N/A`
1660
1673
  },
1661
- geometry: extracted.polygon ? { type: `Polygon`, coordinates: extracted.polygon.split(` `).map((coord) => coord.split(`,`).map((num) => parseFloat(num))) } : null
1674
+ geometry: extracted.polygon ? {
1675
+ type: `Polygon`,
1676
+ coordinates: extracted.polygon.split(` `).map((coord) => {
1677
+ const [lon, lat] = coord.split(`,`).map((num) => parseFloat(num));
1678
+ return [lat, lon];
1679
+ })
1680
+ } : null
1662
1681
  }
1663
1682
  });
1664
1683
  }
@@ -1685,7 +1704,7 @@ var APIAlerts = class {
1685
1704
  }
1686
1705
  static event(validated) {
1687
1706
  return __async(this, null, function* () {
1688
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca;
1707
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia;
1689
1708
  let processed = [];
1690
1709
  const messages = Object.values(JSON.parse(validated.message).features);
1691
1710
  for (let feature of messages) {
@@ -1700,7 +1719,7 @@ var APIAlerts = class {
1700
1719
  const getSource = text_default.textProductToString(getDescription, `SOURCE...`, [`.`]) || `N/A`;
1701
1720
  const getOffice = this.getICAO(getVTEC || ``);
1702
1721
  processed.push({
1703
- preformance: performance.now() - tick,
1722
+ performance: performance.now() - tick,
1704
1723
  tracking: this.getTracking({ vtec: getVTEC, wmoidentifier: getWmo, ugc: getUgc ? getUgc.join(`,`) : null }),
1705
1724
  header: getHeader,
1706
1725
  vtec: getVTEC || `N/A`,
@@ -1735,7 +1754,13 @@ var APIAlerts = class {
1735
1754
  peakWindGust: `N/A`,
1736
1755
  peakHailSize: `N/A`
1737
1756
  },
1738
- geometry: (_ca = feature == null ? void 0 : feature.geometry) != null ? _ca : null
1757
+ geometry: ((_ea = (_da = (_ca = feature == null ? void 0 : feature.geometry) == null ? void 0 : _ca.coordinates) == null ? void 0 : _da[0]) == null ? void 0 : _ea.length) ? {
1758
+ type: ((_fa = feature == null ? void 0 : feature.geometry) == null ? void 0 : _fa.type) || "Polygon",
1759
+ coordinates: (_ia = (_ha = (_ga = feature == null ? void 0 : feature.geometry) == null ? void 0 : _ga.coordinates) == null ? void 0 : _ha[0]) == null ? void 0 : _ia.map((coord) => {
1760
+ const [lon, lat] = Array.isArray(coord) ? coord : [0, 0];
1761
+ return [lon, lat];
1762
+ })
1763
+ } : null
1739
1764
  }
1740
1765
  });
1741
1766
  }
@@ -2289,16 +2314,17 @@ var EventParser = class {
2289
2314
  }
2290
2315
  }
2291
2316
  const filtered = events2.filter((alert) => {
2292
- var _a2, _b2, _c2, _d2;
2317
+ var _a2, _b2, _d2, _e2;
2293
2318
  const originalEvent = alert;
2294
2319
  const props = originalEvent == null ? void 0 : originalEvent.properties;
2295
2320
  const ugcs = (_b2 = (_a2 = props == null ? void 0 : props.geocode) == null ? void 0 : _a2.UGC) != null ? _b2 : [];
2321
+ const _c2 = originalEvent, { performance: performance2, header } = _c2, eventWithoutPerformance = __objRest(_c2, ["performance", "header"]);
2296
2322
  if (bools == null ? void 0 : bools.betterEventParsing) {
2297
2323
  const { eventName, tags } = this.enhanceEvent(originalEvent);
2298
2324
  originalEvent.properties.event = eventName;
2299
2325
  originalEvent.properties.tags = tags;
2300
2326
  }
2301
- const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_c2 = props.parent) == null ? void 0 : _c2.toLowerCase() : (_d2 = props.event) == null ? void 0 : _d2.toLowerCase();
2327
+ const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_d2 = props.parent) == null ? void 0 : _d2.toLowerCase() : (_e2 = props.event) == null ? void 0 : _e2.toLowerCase();
2302
2328
  const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
2303
2329
  for (const key in sets) {
2304
2330
  const setting = sets[key];
@@ -2317,13 +2343,15 @@ var EventParser = class {
2317
2343
  if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
2318
2344
  }
2319
2345
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
2320
- originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true && bools.checkExpired : false;
2346
+ originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true : false;
2347
+ originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true : false;
2348
+ originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true : false;
2349
+ originalEvent.hash = packages.crypto.createHash("md5").update(JSON.stringify(eventWithoutPerformance)).digest("hex");
2321
2350
  if (props.description) {
2322
2351
  const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
2323
- if (detectedPhrase && bools.checkExpired) {
2352
+ if (detectedPhrase) {
2324
2353
  originalEvent.properties.action_type = "Cancel";
2325
2354
  originalEvent.properties.is_cancelled = true;
2326
- return false;
2327
2355
  }
2328
2356
  }
2329
2357
  if (originalEvent.vtec) {
@@ -2333,6 +2361,7 @@ var EventParser = class {
2333
2361
  return false;
2334
2362
  }
2335
2363
  }
2364
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
2336
2365
  cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
2337
2366
  return true;
2338
2367
  });
@@ -2697,8 +2726,8 @@ var Utils = class {
2697
2726
  * @static
2698
2727
  */
2699
2728
  static detectUncaughtExceptions() {
2700
- if (process.listeners("uncaughtException").some((l) => l.name === "uncaughtExceptionHandler")) return;
2701
- process.on(`uncaughtException`, (error) => {
2729
+ if (cache.events.listenerCount("uncaughtException") > 0) return;
2730
+ cache.events.on("uncaughtException", (error) => {
2702
2731
  cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
2703
2732
  });
2704
2733
  }
@@ -2816,7 +2845,7 @@ var Utils = class {
2816
2845
  };
2817
2846
  var utils_default = Utils;
2818
2847
 
2819
- // src/helper.ts
2848
+ // src/index.ts
2820
2849
  var AlertManager = class {
2821
2850
  constructor(metadata) {
2822
2851
  this.start(metadata);
@@ -2921,7 +2950,9 @@ var AlertManager = class {
2921
2950
  return Promise.resolve();
2922
2951
  }
2923
2952
  this.setSettings(metadata);
2924
- utils_default.detectUncaughtExceptions();
2953
+ if (settings.catchUnhandledExceptions) {
2954
+ utils_default.detectUncaughtExceptions();
2955
+ }
2925
2956
  const settings2 = settings;
2926
2957
  this.isNoaaWeatherWireService = settings.isNWWS;
2927
2958
  cache.isReady = false;
@@ -2957,7 +2988,7 @@ var AlertManager = class {
2957
2988
  });
2958
2989
  }
2959
2990
  };
2960
- var helper_default = AlertManager;
2991
+ var index_default = AlertManager;
2961
2992
  export {
2962
2993
  AlertManager,
2963
2994
  database_default as Database,
@@ -2967,6 +2998,6 @@ export {
2967
2998
  text_default as TextParser,
2968
2999
  ugc_default as UGCParser,
2969
3000
  vtec_default as VtecParser,
2970
- helper_default as default,
3001
+ index_default as default,
2971
3002
  types_exports as types
2972
3003
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atmosx-nwws-parser",
3
- "version": "1.0.202",
3
+ "version": "1.0.203",
4
4
  "description": "NOAA Weather Wire Parser - Built for standalone and Project AtmosphericX Integration.",
5
5
  "main": "dist/cjs/helper.cjs",
6
6
  "repository": {
package/src/bootstrap.ts CHANGED
@@ -66,6 +66,7 @@ export const cache = {
66
66
  export const settings = {
67
67
  database: path.join(process.cwd(), 'shapefiles.db'),
68
68
  isNWWS: true,
69
+ catchUnhandledExceptions: false,
69
70
  NoaaWeatherWireService: {
70
71
  clientReconnections: {
71
72
  canReconnect: true,
@@ -92,18 +92,18 @@ export const TYPES: Record<string, string> = {
92
92
  "X": "Experimental Product (Non-Operational)",
93
93
  }
94
94
 
95
- export const STATUS_CORRELATIONS: {type: string, forward: string, cancel: boolean}[] = [
96
- {type: "Update", forward: "Updated", cancel: false},
97
- {type: "Cancel", forward: "Cancelled", cancel: true},
98
- {type: "Alert", forward: "Issued", cancel: false},
99
- {type: "Updated", forward: "Updated", cancel: false},
100
- {type: "Expired", forward: "Expired", cancel: true},
101
- {type: "Issued", forward: "Issued", cancel: false},
102
- {type: "Extended", forward: "Updated", cancel: false},
103
- {type: "Correction", forward: "Updated", cancel: false},
104
- {type: "Upgraded", forward: "Upgraded", cancel: false},
105
- {type: "Cancelled", forward: "Cancelled", cancel: true},
106
- {type: "Routine", forward: "Routine", cancel: false},
95
+ export const STATUS_CORRELATIONS: {type: string, forward: string, cancel: boolean, update: boolean, new: boolean}[] = [
96
+ {type: "Update", forward: "Updated", cancel: false, update: true, new: false},
97
+ {type: "Cancel", forward: "Cancelled", cancel: true, update: false, new: false},
98
+ {type: "Alert", forward: "Issued", cancel: false, update: false, new: true},
99
+ {type: "Updated", forward: "Updated", cancel: false, update: true, new: false},
100
+ {type: "Expired", forward: "Expired", cancel: true, update: false, new: false},
101
+ {type: "Issued", forward: "Issued", cancel: false, update: false, new: true},
102
+ {type: "Extended", forward: "Updated", cancel: false, update: true, new: false},
103
+ {type: "Correction", forward: "Updated", cancel: false, update: true, new: false},
104
+ {type: "Upgraded", forward: "Upgraded", cancel: false, update: true, new: false},
105
+ {type: "Cancelled", forward: "Cancelled", cancel: true, update: false, new: false},
106
+ {type: "Routine", forward: "Routine", cancel: false, update: true, new: false},
107
107
  ]
108
108
 
109
109
 
@@ -128,7 +128,7 @@ export class AlertManager {
128
128
  return Promise.resolve();
129
129
  }
130
130
  this.setSettings(metadata);
131
- Utils.detectUncaughtExceptions();
131
+ if (loader.settings.catchUnhandledExceptions) { Utils.detectUncaughtExceptions(); }
132
132
  const settings = loader.settings as types.ClientSettings;
133
133
  this.isNoaaWeatherWireService = loader.settings.isNWWS
134
134
  loader.cache.isReady = false;
@@ -158,6 +158,7 @@ export class EventParser {
158
158
  const originalEvent = alert
159
159
  const props = originalEvent?.properties;
160
160
  const ugcs = props?.geocode?.UGC ?? [];
161
+ const { performance, header, ...eventWithoutPerformance } = originalEvent;
161
162
  if (bools?.betterEventParsing) {
162
163
  const { eventName, tags } = this.enhanceEvent(originalEvent);
163
164
  originalEvent.properties.event = eventName;
@@ -180,16 +181,20 @@ export class EventParser {
180
181
  if (key === 'checkExpired' && setting && new Date(props?.expires).getTime() < new Date().getTime()) return false;
181
182
  }
182
183
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
183
- originalEvent.properties.is_cancelled = statusCorrelation ? (statusCorrelation.cancel == true && bools.checkExpired) : false;
184
+ originalEvent.properties.is_updated = statusCorrelation ? (statusCorrelation.update == true) : false;
185
+ originalEvent.properties.is_issued = statusCorrelation ? (statusCorrelation.new == true) : false;
186
+ originalEvent.properties.is_cancelled = statusCorrelation ? (statusCorrelation.cancel == true) : false;
187
+ originalEvent.hash = loader.packages.crypto.createHash('md5').update(JSON.stringify(eventWithoutPerformance)).digest('hex');
184
188
  if (props.description) {
185
189
  const detectedPhrase = loader.definitions.cancelSignatures.find(sig => props.description.toLowerCase().includes(sig.toLowerCase()));
186
- if (detectedPhrase && bools.checkExpired) { originalEvent.properties.action_type = 'Cancel'; originalEvent.properties.is_cancelled = true; return false; }
190
+ if (detectedPhrase) { originalEvent.properties.action_type = 'Cancel'; originalEvent.properties.is_cancelled = true; }
187
191
  }
188
192
  if (originalEvent.vtec) {
189
193
  const getType = originalEvent.vtec.split(`.`)[0];
190
194
  const isTestProduct = loader.definitions.productTypes[getType] == `Test Product`
191
195
  if (isTestProduct) { return false; }
192
196
  }
197
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
193
198
  loader.cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, '')}`)
194
199
  return true;
195
200
  })
@@ -48,7 +48,7 @@ export class APIAlerts {
48
48
  const getSource = TextParser.textProductToString(getDescription, `SOURCE...`, [`.`]) || `N/A`;
49
49
  const getOffice = this.getICAO(getVTEC || ``);
50
50
  processed.push({
51
- preformance: performance.now() - tick,
51
+ performance: performance.now() - tick,
52
52
  tracking: this.getTracking({ vtec: getVTEC, wmoidentifier: getWmo, ugc: getUgc ? getUgc.join(`,`) : null }),
53
53
  header: getHeader,
54
54
  vtec: getVTEC || `N/A`,
@@ -83,7 +83,13 @@ export class APIAlerts {
83
83
  peakWindGust: `N/A`,
84
84
  peakHailSize: `N/A`,
85
85
  },
86
- geometry: feature?.geometry ?? null,
86
+ geometry: feature?.geometry?.coordinates?.[0]?.length ? {
87
+ type: feature?.geometry?.type || 'Polygon',
88
+ coordinates: feature?.geometry?.coordinates?.[0]?.map((coord: number) => {
89
+ const [lon, lat] = Array.isArray(coord) ? coord : [0, 0];
90
+ return [lon, lat];
91
+ })
92
+ } : null
87
93
  }
88
94
  })
89
95
  }
@@ -47,7 +47,7 @@ export class CapAlerts {
47
47
  const getHeader = EventParser.getHeader({ ...validated.attributes,} as types.TypeAttributes);
48
48
  const getSource = TextParser.textProductToString(extracted.description, `SOURCE...`, [`.`]) || `N/A`;
49
49
  processed.push({
50
- preformance: performance.now() - tick,
50
+ performance: performance.now() - tick,
51
51
  tracking: this.getTracking(extracted),
52
52
  header: getHeader,
53
53
  vtec: extracted.vtec || `N/A`,
@@ -78,7 +78,13 @@ export class CapAlerts {
78
78
  discussion_wind_intensity: `N/A`,
79
79
  discussion_hail_intensity: `N/A`,
80
80
  },
81
- geometry: extracted.polygon ? { type: `Polygon`, coordinates: extracted.polygon.split(` `).map((coord: string) => coord.split(`,`).map((num: string) => parseFloat(num))) } : null,
81
+ geometry: extracted.polygon ? {
82
+ type: `Polygon`,
83
+ coordinates: extracted.polygon.split(` `).map((coord: string) => {
84
+ const [lon, lat] = coord.split(`,`).map((num: string) => parseFloat(num));
85
+ return [lat, lon];
86
+ })
87
+ } : null,
82
88
  }
83
89
  })
84
90
  }
@@ -39,7 +39,7 @@ export class UGCAlerts {
39
39
  const getHeader = EventParser.getHeader({ ...validated.attributes, ...getBaseProperties.attributes } as types.TypeAttributes, getBaseProperties);
40
40
  const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
41
41
  processed.push({
42
- preformance: performance.now() - tick,
42
+ performance: performance.now() - tick,
43
43
  tracking: this.getTracking(getBaseProperties),
44
44
  header: getHeader,
45
45
  vtec: `N/A`,
@@ -69,7 +69,7 @@ export class UGCAlerts {
69
69
  const getHeader = EventParser.getHeader({ ...validated.attributes, ...getBaseProperties.attributes } as types.TypeAttributes, getBaseProperties);
70
70
  const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
71
71
  processed.push({
72
- preformance: performance.now() - tick,
72
+ performance: performance.now() - tick,
73
73
  tracking: this.getTracking(getBaseProperties, getUGC.zones),
74
74
  header: getHeader,
75
75
  vtec: `N/A`,
@@ -43,7 +43,7 @@ export class VTECAlerts {
43
43
  const getBaseProperties = await EventParser.getBaseProperties(message, validated, getUGC, vtec) as types.BaseProperties;
44
44
  const getHeader = EventParser.getHeader({ ...validated.attributes, ...getBaseProperties.attributes } as types.TypeAttributes, getBaseProperties, vtec);
45
45
  processed.push({
46
- preformance: performance.now() - tick,
46
+ performance: performance.now() - tick,
47
47
  tracking: vtec.tracking,
48
48
  header: getHeader,
49
49
  vtec: vtec.raw,