atmosx-nwws-parser 1.0.20232 → 1.0.20234

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 (40) hide show
  1. package/dist/cjs/bootstrap.cjs +1 -0
  2. package/dist/cjs/database.cjs +1 -0
  3. package/dist/cjs/eas.cjs +26 -13
  4. package/dist/cjs/helper.cjs +29 -14
  5. package/dist/cjs/parsers/events.cjs +26 -13
  6. package/dist/cjs/parsers/stanza.cjs +1 -0
  7. package/dist/cjs/parsers/text.cjs +1 -0
  8. package/dist/cjs/parsers/types/api.cjs +26 -13
  9. package/dist/cjs/parsers/types/cap.cjs +26 -13
  10. package/dist/cjs/parsers/types/text.cjs +26 -13
  11. package/dist/cjs/parsers/types/ugc.cjs +26 -13
  12. package/dist/cjs/parsers/types/vtec.cjs +26 -13
  13. package/dist/cjs/parsers/ugc.cjs +1 -0
  14. package/dist/cjs/parsers/vtec.cjs +1 -0
  15. package/dist/cjs/utils.cjs +26 -13
  16. package/dist/cjs/xmpp.cjs +26 -13
  17. package/dist/esm/bootstrap.mjs +1 -0
  18. package/dist/esm/database.mjs +1 -0
  19. package/dist/esm/eas.mjs +26 -13
  20. package/dist/esm/helper.mjs +29 -14
  21. package/dist/esm/parsers/events.mjs +26 -13
  22. package/dist/esm/parsers/stanza.mjs +1 -0
  23. package/dist/esm/parsers/text.mjs +1 -0
  24. package/dist/esm/parsers/types/api.mjs +26 -13
  25. package/dist/esm/parsers/types/cap.mjs +26 -13
  26. package/dist/esm/parsers/types/text.mjs +26 -13
  27. package/dist/esm/parsers/types/ugc.mjs +26 -13
  28. package/dist/esm/parsers/types/vtec.mjs +26 -13
  29. package/dist/esm/parsers/ugc.mjs +1 -0
  30. package/dist/esm/parsers/vtec.mjs +1 -0
  31. package/dist/esm/utils.mjs +26 -13
  32. package/dist/esm/xmpp.mjs +26 -13
  33. package/package.json +1 -1
  34. package/src/bootstrap.ts +1 -0
  35. package/src/helper.ts +1 -1
  36. package/src/parsers/events.ts +6 -5
  37. package/src/parsers/types/api.ts +7 -1
  38. package/src/parsers/types/cap.ts +7 -1
  39. package/src/types.ts +1 -0
  40. package/src/utils.ts +3 -3
@@ -884,6 +884,7 @@ var cache = {
884
884
  var settings = {
885
885
  database: path.join(process.cwd(), "shapefiles.db"),
886
886
  isNWWS: true,
887
+ catchUnhandledExceptions: false,
887
888
  NoaaWeatherWireService: {
888
889
  clientReconnections: {
889
890
  canReconnect: true,
@@ -904,6 +904,7 @@ var cache = {
904
904
  var settings = {
905
905
  database: path.join(process.cwd(), "shapefiles.db"),
906
906
  isNWWS: true,
907
+ catchUnhandledExceptions: false,
907
908
  NoaaWeatherWireService: {
908
909
  clientReconnections: {
909
910
  canReconnect: true,
package/dist/cjs/eas.cjs CHANGED
@@ -933,6 +933,7 @@ var cache = {
933
933
  var settings = {
934
934
  database: path.join(process.cwd(), "shapefiles.db"),
935
935
  isNWWS: true,
936
+ catchUnhandledExceptions: false,
936
937
  NoaaWeatherWireService: {
937
938
  clientReconnections: {
938
939
  canReconnect: true,
@@ -1700,7 +1701,13 @@ var CapAlerts = class {
1700
1701
  discussion_wind_intensity: `N/A`,
1701
1702
  discussion_hail_intensity: `N/A`
1702
1703
  },
1703
- geometry: extracted.polygon ? { type: `Polygon`, coordinates: extracted.polygon.split(` `).map((coord) => coord.split(`,`).map((num) => parseFloat(num))) } : null
1704
+ geometry: extracted.polygon ? {
1705
+ type: `Polygon`,
1706
+ coordinates: extracted.polygon.split(` `).map((coord) => {
1707
+ const [lon, lat] = coord.split(`,`).map((num) => parseFloat(num));
1708
+ return [lat, lon];
1709
+ })
1710
+ } : null
1704
1711
  }
1705
1712
  });
1706
1713
  }
@@ -1727,7 +1734,7 @@ var APIAlerts = class {
1727
1734
  }
1728
1735
  static event(validated) {
1729
1736
  return __async(this, null, function* () {
1730
- 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;
1737
+ 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;
1731
1738
  let processed = [];
1732
1739
  const messages = Object.values(JSON.parse(validated.message).features);
1733
1740
  for (let feature of messages) {
@@ -1777,7 +1784,13 @@ var APIAlerts = class {
1777
1784
  peakWindGust: `N/A`,
1778
1785
  peakHailSize: `N/A`
1779
1786
  },
1780
- geometry: (_ca = feature == null ? void 0 : feature.geometry) != null ? _ca : null
1787
+ 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) ? {
1788
+ type: ((_fa = feature == null ? void 0 : feature.geometry) == null ? void 0 : _fa.type) || "Polygon",
1789
+ 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) => {
1790
+ const [lon, lat] = Array.isArray(coord) ? coord : [0, 0];
1791
+ return [lat, lon];
1792
+ })
1793
+ } : null
1781
1794
  }
1782
1795
  });
1783
1796
  }
@@ -1918,16 +1931,17 @@ var EventParser = class {
1918
1931
  }
1919
1932
  }
1920
1933
  const filtered = events2.filter((alert) => {
1921
- var _a2, _b2, _c2, _d2;
1934
+ var _a2, _b2, _d2, _e2;
1922
1935
  const originalEvent = alert;
1923
1936
  const props = originalEvent == null ? void 0 : originalEvent.properties;
1924
1937
  const ugcs = (_b2 = (_a2 = props == null ? void 0 : props.geocode) == null ? void 0 : _a2.UGC) != null ? _b2 : [];
1938
+ const _c2 = originalEvent, { performance: performance2, header } = _c2, eventWithoutPerformance = __objRest(_c2, ["performance", "header"]);
1925
1939
  if (bools == null ? void 0 : bools.betterEventParsing) {
1926
1940
  const { eventName, tags } = this.enhanceEvent(originalEvent);
1927
1941
  originalEvent.properties.event = eventName;
1928
1942
  originalEvent.properties.tags = tags;
1929
1943
  }
1930
- const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_c2 = props.parent) == null ? void 0 : _c2.toLowerCase() : (_d2 = props.event) == null ? void 0 : _d2.toLowerCase();
1944
+ const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_d2 = props.parent) == null ? void 0 : _d2.toLowerCase() : (_e2 = props.event) == null ? void 0 : _e2.toLowerCase();
1931
1945
  const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
1932
1946
  for (const key in sets) {
1933
1947
  const setting = sets[key];
@@ -1946,17 +1960,15 @@ var EventParser = class {
1946
1960
  if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
1947
1961
  }
1948
1962
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
1949
- originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true && bools.checkExpired : false;
1950
- originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true && bools.checkExpired : false;
1951
- originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true && bools.checkExpired : false;
1952
- const _e2 = originalEvent, { performance: performance2, header } = _e2, eventWithoutPerformance = __objRest(_e2, ["performance", "header"]);
1963
+ originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true : false;
1964
+ originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true : false;
1965
+ originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true : false;
1953
1966
  originalEvent.hash = packages.crypto.createHash("md5").update(JSON.stringify(eventWithoutPerformance)).digest("hex");
1954
1967
  if (props.description) {
1955
1968
  const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
1956
- if (detectedPhrase && bools.checkExpired) {
1969
+ if (detectedPhrase) {
1957
1970
  originalEvent.properties.action_type = "Cancel";
1958
1971
  originalEvent.properties.is_cancelled = true;
1959
- return false;
1960
1972
  }
1961
1973
  }
1962
1974
  if (originalEvent.vtec) {
@@ -1966,6 +1978,7 @@ var EventParser = class {
1966
1978
  return false;
1967
1979
  }
1968
1980
  }
1981
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
1969
1982
  cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
1970
1983
  return true;
1971
1984
  });
@@ -2330,8 +2343,8 @@ var Utils = class {
2330
2343
  * @static
2331
2344
  */
2332
2345
  static detectUncaughtExceptions() {
2333
- if (process.listeners("uncaughtException").some((l) => l.name === "uncaughtExceptionHandler")) return;
2334
- process.on(`uncaughtException`, (error) => {
2346
+ if (cache.events.listenerCount("uncaughtException") > 0) return;
2347
+ cache.events.on("uncaughtException", (error) => {
2335
2348
  cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
2336
2349
  });
2337
2350
  }
@@ -941,6 +941,7 @@ var cache = {
941
941
  var settings = {
942
942
  database: path.join(process.cwd(), "shapefiles.db"),
943
943
  isNWWS: true,
944
+ catchUnhandledExceptions: false,
944
945
  NoaaWeatherWireService: {
945
946
  clientReconnections: {
946
947
  canReconnect: true,
@@ -1711,7 +1712,13 @@ var CapAlerts = class {
1711
1712
  discussion_wind_intensity: `N/A`,
1712
1713
  discussion_hail_intensity: `N/A`
1713
1714
  },
1714
- 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
1715
1722
  }
1716
1723
  });
1717
1724
  }
@@ -1738,7 +1745,7 @@ var APIAlerts = class {
1738
1745
  }
1739
1746
  static event(validated) {
1740
1747
  return __async(this, null, function* () {
1741
- 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;
1742
1749
  let processed = [];
1743
1750
  const messages = Object.values(JSON.parse(validated.message).features);
1744
1751
  for (let feature of messages) {
@@ -1788,7 +1795,13 @@ var APIAlerts = class {
1788
1795
  peakWindGust: `N/A`,
1789
1796
  peakHailSize: `N/A`
1790
1797
  },
1791
- 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 [lat, lon];
1803
+ })
1804
+ } : null
1792
1805
  }
1793
1806
  });
1794
1807
  }
@@ -2342,16 +2355,17 @@ var EventParser = class {
2342
2355
  }
2343
2356
  }
2344
2357
  const filtered = events2.filter((alert) => {
2345
- var _a2, _b2, _c2, _d2;
2358
+ var _a2, _b2, _d2, _e2;
2346
2359
  const originalEvent = alert;
2347
2360
  const props = originalEvent == null ? void 0 : originalEvent.properties;
2348
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"]);
2349
2363
  if (bools == null ? void 0 : bools.betterEventParsing) {
2350
2364
  const { eventName, tags } = this.enhanceEvent(originalEvent);
2351
2365
  originalEvent.properties.event = eventName;
2352
2366
  originalEvent.properties.tags = tags;
2353
2367
  }
2354
- 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();
2355
2369
  const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
2356
2370
  for (const key in sets) {
2357
2371
  const setting = sets[key];
@@ -2370,17 +2384,15 @@ var EventParser = class {
2370
2384
  if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
2371
2385
  }
2372
2386
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
2373
- originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true && bools.checkExpired : false;
2374
- originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true && bools.checkExpired : false;
2375
- originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true && bools.checkExpired : false;
2376
- const _e2 = originalEvent, { performance: performance2, header } = _e2, eventWithoutPerformance = __objRest(_e2, ["performance", "header"]);
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;
2377
2390
  originalEvent.hash = packages.crypto.createHash("md5").update(JSON.stringify(eventWithoutPerformance)).digest("hex");
2378
2391
  if (props.description) {
2379
2392
  const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
2380
- if (detectedPhrase && bools.checkExpired) {
2393
+ if (detectedPhrase) {
2381
2394
  originalEvent.properties.action_type = "Cancel";
2382
2395
  originalEvent.properties.is_cancelled = true;
2383
- return false;
2384
2396
  }
2385
2397
  }
2386
2398
  if (originalEvent.vtec) {
@@ -2390,6 +2402,7 @@ var EventParser = class {
2390
2402
  return false;
2391
2403
  }
2392
2404
  }
2405
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
2393
2406
  cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
2394
2407
  return true;
2395
2408
  });
@@ -2754,8 +2767,8 @@ var Utils = class {
2754
2767
  * @static
2755
2768
  */
2756
2769
  static detectUncaughtExceptions() {
2757
- if (process.listeners("uncaughtException").some((l) => l.name === "uncaughtExceptionHandler")) return;
2758
- process.on(`uncaughtException`, (error) => {
2770
+ if (cache.events.listenerCount("uncaughtException") > 0) return;
2771
+ cache.events.on("uncaughtException", (error) => {
2759
2772
  cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
2760
2773
  });
2761
2774
  }
@@ -2978,7 +2991,9 @@ var AlertManager = class {
2978
2991
  return Promise.resolve();
2979
2992
  }
2980
2993
  this.setSettings(metadata);
2981
- utils_default.detectUncaughtExceptions();
2994
+ if (settings.catchUnhandledExceptions) {
2995
+ utils_default.detectUncaughtExceptions();
2996
+ }
2982
2997
  const settings2 = settings;
2983
2998
  this.isNoaaWeatherWireService = settings.isNWWS;
2984
2999
  cache.isReady = false;
@@ -933,6 +933,7 @@ var cache = {
933
933
  var settings = {
934
934
  database: path.join(process.cwd(), "shapefiles.db"),
935
935
  isNWWS: true,
936
+ catchUnhandledExceptions: false,
936
937
  NoaaWeatherWireService: {
937
938
  clientReconnections: {
938
939
  canReconnect: true,
@@ -1598,7 +1599,13 @@ var CapAlerts = class {
1598
1599
  discussion_wind_intensity: `N/A`,
1599
1600
  discussion_hail_intensity: `N/A`
1600
1601
  },
1601
- geometry: extracted.polygon ? { type: `Polygon`, coordinates: extracted.polygon.split(` `).map((coord) => coord.split(`,`).map((num) => parseFloat(num))) } : null
1602
+ geometry: extracted.polygon ? {
1603
+ type: `Polygon`,
1604
+ coordinates: extracted.polygon.split(` `).map((coord) => {
1605
+ const [lon, lat] = coord.split(`,`).map((num) => parseFloat(num));
1606
+ return [lat, lon];
1607
+ })
1608
+ } : null
1602
1609
  }
1603
1610
  });
1604
1611
  }
@@ -1625,7 +1632,7 @@ var APIAlerts = class {
1625
1632
  }
1626
1633
  static event(validated) {
1627
1634
  return __async(this, null, function* () {
1628
- 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;
1635
+ 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;
1629
1636
  let processed = [];
1630
1637
  const messages = Object.values(JSON.parse(validated.message).features);
1631
1638
  for (let feature of messages) {
@@ -1675,7 +1682,13 @@ var APIAlerts = class {
1675
1682
  peakWindGust: `N/A`,
1676
1683
  peakHailSize: `N/A`
1677
1684
  },
1678
- geometry: (_ca = feature == null ? void 0 : feature.geometry) != null ? _ca : null
1685
+ 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) ? {
1686
+ type: ((_fa = feature == null ? void 0 : feature.geometry) == null ? void 0 : _fa.type) || "Polygon",
1687
+ 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) => {
1688
+ const [lon, lat] = Array.isArray(coord) ? coord : [0, 0];
1689
+ return [lat, lon];
1690
+ })
1691
+ } : null
1679
1692
  }
1680
1693
  });
1681
1694
  }
@@ -2062,8 +2075,8 @@ var Utils = class {
2062
2075
  * @static
2063
2076
  */
2064
2077
  static detectUncaughtExceptions() {
2065
- if (process.listeners("uncaughtException").some((l) => l.name === "uncaughtExceptionHandler")) return;
2066
- process.on(`uncaughtException`, (error) => {
2078
+ if (cache.events.listenerCount("uncaughtException") > 0) return;
2079
+ cache.events.on("uncaughtException", (error) => {
2067
2080
  cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
2068
2081
  });
2069
2082
  }
@@ -2725,16 +2738,17 @@ var EventParser = class {
2725
2738
  }
2726
2739
  }
2727
2740
  const filtered = events2.filter((alert) => {
2728
- var _a2, _b2, _c2, _d2;
2741
+ var _a2, _b2, _d2, _e2;
2729
2742
  const originalEvent = alert;
2730
2743
  const props = originalEvent == null ? void 0 : originalEvent.properties;
2731
2744
  const ugcs = (_b2 = (_a2 = props == null ? void 0 : props.geocode) == null ? void 0 : _a2.UGC) != null ? _b2 : [];
2745
+ const _c2 = originalEvent, { performance: performance2, header } = _c2, eventWithoutPerformance = __objRest(_c2, ["performance", "header"]);
2732
2746
  if (bools == null ? void 0 : bools.betterEventParsing) {
2733
2747
  const { eventName, tags } = this.enhanceEvent(originalEvent);
2734
2748
  originalEvent.properties.event = eventName;
2735
2749
  originalEvent.properties.tags = tags;
2736
2750
  }
2737
- const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_c2 = props.parent) == null ? void 0 : _c2.toLowerCase() : (_d2 = props.event) == null ? void 0 : _d2.toLowerCase();
2751
+ const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_d2 = props.parent) == null ? void 0 : _d2.toLowerCase() : (_e2 = props.event) == null ? void 0 : _e2.toLowerCase();
2738
2752
  const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
2739
2753
  for (const key in sets) {
2740
2754
  const setting = sets[key];
@@ -2753,17 +2767,15 @@ var EventParser = class {
2753
2767
  if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
2754
2768
  }
2755
2769
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
2756
- originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true && bools.checkExpired : false;
2757
- originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true && bools.checkExpired : false;
2758
- originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true && bools.checkExpired : false;
2759
- const _e2 = originalEvent, { performance: performance2, header } = _e2, eventWithoutPerformance = __objRest(_e2, ["performance", "header"]);
2770
+ originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true : false;
2771
+ originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true : false;
2772
+ originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true : false;
2760
2773
  originalEvent.hash = packages.crypto.createHash("md5").update(JSON.stringify(eventWithoutPerformance)).digest("hex");
2761
2774
  if (props.description) {
2762
2775
  const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
2763
- if (detectedPhrase && bools.checkExpired) {
2776
+ if (detectedPhrase) {
2764
2777
  originalEvent.properties.action_type = "Cancel";
2765
2778
  originalEvent.properties.is_cancelled = true;
2766
- return false;
2767
2779
  }
2768
2780
  }
2769
2781
  if (originalEvent.vtec) {
@@ -2773,6 +2785,7 @@ var EventParser = class {
2773
2785
  return false;
2774
2786
  }
2775
2787
  }
2788
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
2776
2789
  cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
2777
2790
  return true;
2778
2791
  });
@@ -884,6 +884,7 @@ var cache = {
884
884
  var settings = {
885
885
  database: path.join(process.cwd(), "shapefiles.db"),
886
886
  isNWWS: true,
887
+ catchUnhandledExceptions: false,
887
888
  NoaaWeatherWireService: {
888
889
  clientReconnections: {
889
890
  canReconnect: true,
@@ -867,6 +867,7 @@ var cache = {
867
867
  var settings = {
868
868
  database: path.join(process.cwd(), "shapefiles.db"),
869
869
  isNWWS: true,
870
+ catchUnhandledExceptions: false,
870
871
  NoaaWeatherWireService: {
871
872
  clientReconnections: {
872
873
  canReconnect: true,
@@ -933,6 +933,7 @@ var cache = {
933
933
  var settings = {
934
934
  database: path.join(process.cwd(), "shapefiles.db"),
935
935
  isNWWS: true,
936
+ catchUnhandledExceptions: false,
936
937
  NoaaWeatherWireService: {
937
938
  clientReconnections: {
938
939
  canReconnect: true,
@@ -1598,7 +1599,13 @@ var CapAlerts = class {
1598
1599
  discussion_wind_intensity: `N/A`,
1599
1600
  discussion_hail_intensity: `N/A`
1600
1601
  },
1601
- geometry: extracted.polygon ? { type: `Polygon`, coordinates: extracted.polygon.split(` `).map((coord) => coord.split(`,`).map((num) => parseFloat(num))) } : null
1602
+ geometry: extracted.polygon ? {
1603
+ type: `Polygon`,
1604
+ coordinates: extracted.polygon.split(` `).map((coord) => {
1605
+ const [lon, lat] = coord.split(`,`).map((num) => parseFloat(num));
1606
+ return [lat, lon];
1607
+ })
1608
+ } : null
1602
1609
  }
1603
1610
  });
1604
1611
  }
@@ -1985,8 +1992,8 @@ var Utils = class {
1985
1992
  * @static
1986
1993
  */
1987
1994
  static detectUncaughtExceptions() {
1988
- if (process.listeners("uncaughtException").some((l) => l.name === "uncaughtExceptionHandler")) return;
1989
- process.on(`uncaughtException`, (error) => {
1995
+ if (cache.events.listenerCount("uncaughtException") > 0) return;
1996
+ cache.events.on("uncaughtException", (error) => {
1990
1997
  cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
1991
1998
  });
1992
1999
  }
@@ -2648,16 +2655,17 @@ var EventParser = class {
2648
2655
  }
2649
2656
  }
2650
2657
  const filtered = events2.filter((alert) => {
2651
- var _a2, _b2, _c2, _d2;
2658
+ var _a2, _b2, _d2, _e2;
2652
2659
  const originalEvent = alert;
2653
2660
  const props = originalEvent == null ? void 0 : originalEvent.properties;
2654
2661
  const ugcs = (_b2 = (_a2 = props == null ? void 0 : props.geocode) == null ? void 0 : _a2.UGC) != null ? _b2 : [];
2662
+ const _c2 = originalEvent, { performance: performance2, header } = _c2, eventWithoutPerformance = __objRest(_c2, ["performance", "header"]);
2655
2663
  if (bools == null ? void 0 : bools.betterEventParsing) {
2656
2664
  const { eventName, tags } = this.enhanceEvent(originalEvent);
2657
2665
  originalEvent.properties.event = eventName;
2658
2666
  originalEvent.properties.tags = tags;
2659
2667
  }
2660
- const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_c2 = props.parent) == null ? void 0 : _c2.toLowerCase() : (_d2 = props.event) == null ? void 0 : _d2.toLowerCase();
2668
+ const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_d2 = props.parent) == null ? void 0 : _d2.toLowerCase() : (_e2 = props.event) == null ? void 0 : _e2.toLowerCase();
2661
2669
  const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
2662
2670
  for (const key in sets) {
2663
2671
  const setting = sets[key];
@@ -2676,17 +2684,15 @@ var EventParser = class {
2676
2684
  if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
2677
2685
  }
2678
2686
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
2679
- originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true && bools.checkExpired : false;
2680
- originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true && bools.checkExpired : false;
2681
- originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true && bools.checkExpired : false;
2682
- const _e2 = originalEvent, { performance: performance2, header } = _e2, eventWithoutPerformance = __objRest(_e2, ["performance", "header"]);
2687
+ originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true : false;
2688
+ originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true : false;
2689
+ originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true : false;
2683
2690
  originalEvent.hash = packages.crypto.createHash("md5").update(JSON.stringify(eventWithoutPerformance)).digest("hex");
2684
2691
  if (props.description) {
2685
2692
  const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
2686
- if (detectedPhrase && bools.checkExpired) {
2693
+ if (detectedPhrase) {
2687
2694
  originalEvent.properties.action_type = "Cancel";
2688
2695
  originalEvent.properties.is_cancelled = true;
2689
- return false;
2690
2696
  }
2691
2697
  }
2692
2698
  if (originalEvent.vtec) {
@@ -2696,6 +2702,7 @@ var EventParser = class {
2696
2702
  return false;
2697
2703
  }
2698
2704
  }
2705
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
2699
2706
  cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
2700
2707
  return true;
2701
2708
  });
@@ -2802,7 +2809,7 @@ var APIAlerts = class {
2802
2809
  }
2803
2810
  static event(validated) {
2804
2811
  return __async(this, null, function* () {
2805
- 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;
2812
+ 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;
2806
2813
  let processed = [];
2807
2814
  const messages = Object.values(JSON.parse(validated.message).features);
2808
2815
  for (let feature of messages) {
@@ -2852,7 +2859,13 @@ var APIAlerts = class {
2852
2859
  peakWindGust: `N/A`,
2853
2860
  peakHailSize: `N/A`
2854
2861
  },
2855
- geometry: (_ca = feature == null ? void 0 : feature.geometry) != null ? _ca : null
2862
+ 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) ? {
2863
+ type: ((_fa = feature == null ? void 0 : feature.geometry) == null ? void 0 : _fa.type) || "Polygon",
2864
+ 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) => {
2865
+ const [lon, lat] = Array.isArray(coord) ? coord : [0, 0];
2866
+ return [lat, lon];
2867
+ })
2868
+ } : null
2856
2869
  }
2857
2870
  });
2858
2871
  }
@@ -933,6 +933,7 @@ var cache = {
933
933
  var settings = {
934
934
  database: path.join(process.cwd(), "shapefiles.db"),
935
935
  isNWWS: true,
936
+ catchUnhandledExceptions: false,
936
937
  NoaaWeatherWireService: {
937
938
  clientReconnections: {
938
939
  canReconnect: true,
@@ -1540,7 +1541,7 @@ var APIAlerts = class {
1540
1541
  }
1541
1542
  static event(validated) {
1542
1543
  return __async(this, null, function* () {
1543
- 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;
1544
+ 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;
1544
1545
  let processed = [];
1545
1546
  const messages = Object.values(JSON.parse(validated.message).features);
1546
1547
  for (let feature of messages) {
@@ -1590,7 +1591,13 @@ var APIAlerts = class {
1590
1591
  peakWindGust: `N/A`,
1591
1592
  peakHailSize: `N/A`
1592
1593
  },
1593
- geometry: (_ca = feature == null ? void 0 : feature.geometry) != null ? _ca : null
1594
+ 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) ? {
1595
+ type: ((_fa = feature == null ? void 0 : feature.geometry) == null ? void 0 : _fa.type) || "Polygon",
1596
+ 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) => {
1597
+ const [lon, lat] = Array.isArray(coord) ? coord : [0, 0];
1598
+ return [lat, lon];
1599
+ })
1600
+ } : null
1594
1601
  }
1595
1602
  });
1596
1603
  }
@@ -1977,8 +1984,8 @@ var Utils = class {
1977
1984
  * @static
1978
1985
  */
1979
1986
  static detectUncaughtExceptions() {
1980
- if (process.listeners("uncaughtException").some((l) => l.name === "uncaughtExceptionHandler")) return;
1981
- process.on(`uncaughtException`, (error) => {
1987
+ if (cache.events.listenerCount("uncaughtException") > 0) return;
1988
+ cache.events.on("uncaughtException", (error) => {
1982
1989
  cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
1983
1990
  });
1984
1991
  }
@@ -2640,16 +2647,17 @@ var EventParser = class {
2640
2647
  }
2641
2648
  }
2642
2649
  const filtered = events2.filter((alert) => {
2643
- var _a2, _b2, _c2, _d2;
2650
+ var _a2, _b2, _d2, _e2;
2644
2651
  const originalEvent = alert;
2645
2652
  const props = originalEvent == null ? void 0 : originalEvent.properties;
2646
2653
  const ugcs = (_b2 = (_a2 = props == null ? void 0 : props.geocode) == null ? void 0 : _a2.UGC) != null ? _b2 : [];
2654
+ const _c2 = originalEvent, { performance: performance2, header } = _c2, eventWithoutPerformance = __objRest(_c2, ["performance", "header"]);
2647
2655
  if (bools == null ? void 0 : bools.betterEventParsing) {
2648
2656
  const { eventName, tags } = this.enhanceEvent(originalEvent);
2649
2657
  originalEvent.properties.event = eventName;
2650
2658
  originalEvent.properties.tags = tags;
2651
2659
  }
2652
- const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_c2 = props.parent) == null ? void 0 : _c2.toLowerCase() : (_d2 = props.event) == null ? void 0 : _d2.toLowerCase();
2660
+ const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (_d2 = props.parent) == null ? void 0 : _d2.toLowerCase() : (_e2 = props.event) == null ? void 0 : _e2.toLowerCase();
2653
2661
  const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
2654
2662
  for (const key in sets) {
2655
2663
  const setting = sets[key];
@@ -2668,17 +2676,15 @@ var EventParser = class {
2668
2676
  if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
2669
2677
  }
2670
2678
  originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
2671
- originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true && bools.checkExpired : false;
2672
- originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true && bools.checkExpired : false;
2673
- originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true && bools.checkExpired : false;
2674
- const _e2 = originalEvent, { performance: performance2, header } = _e2, eventWithoutPerformance = __objRest(_e2, ["performance", "header"]);
2679
+ originalEvent.properties.is_updated = statusCorrelation ? statusCorrelation.update == true : false;
2680
+ originalEvent.properties.is_issued = statusCorrelation ? statusCorrelation.new == true : false;
2681
+ originalEvent.properties.is_cancelled = statusCorrelation ? statusCorrelation.cancel == true : false;
2675
2682
  originalEvent.hash = packages.crypto.createHash("md5").update(JSON.stringify(eventWithoutPerformance)).digest("hex");
2676
2683
  if (props.description) {
2677
2684
  const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
2678
- if (detectedPhrase && bools.checkExpired) {
2685
+ if (detectedPhrase) {
2679
2686
  originalEvent.properties.action_type = "Cancel";
2680
2687
  originalEvent.properties.is_cancelled = true;
2681
- return false;
2682
2688
  }
2683
2689
  }
2684
2690
  if (originalEvent.vtec) {
@@ -2688,6 +2694,7 @@ var EventParser = class {
2688
2694
  return false;
2689
2695
  }
2690
2696
  }
2697
+ if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
2691
2698
  cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
2692
2699
  return true;
2693
2700
  });
@@ -2852,7 +2859,13 @@ var CapAlerts = class {
2852
2859
  discussion_wind_intensity: `N/A`,
2853
2860
  discussion_hail_intensity: `N/A`
2854
2861
  },
2855
- geometry: extracted.polygon ? { type: `Polygon`, coordinates: extracted.polygon.split(` `).map((coord) => coord.split(`,`).map((num) => parseFloat(num))) } : null
2862
+ geometry: extracted.polygon ? {
2863
+ type: `Polygon`,
2864
+ coordinates: extracted.polygon.split(` `).map((coord) => {
2865
+ const [lon, lat] = coord.split(`,`).map((num) => parseFloat(num));
2866
+ return [lat, lon];
2867
+ })
2868
+ } : null
2856
2869
  }
2857
2870
  });
2858
2871
  }