atmosx-nwws-parser 1.0.201 → 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.
- package/dist/cjs/{helper.cjs → index.cjs} +75 -39
- package/dist/esm/{helper.mjs → index.mjs} +69 -34
- package/package.json +1 -1
- package/src/bootstrap.ts +1 -0
- package/src/dictionaries/events.ts +12 -12
- package/src/{helper.ts → index.ts} +5 -5
- package/src/parsers/events.ts +7 -2
- package/src/parsers/types/api.ts +8 -2
- package/src/parsers/types/cap.ts +8 -2
- package/src/parsers/types/text.ts +1 -1
- package/src/parsers/types/ugc.ts +1 -1
- package/src/parsers/types/vtec.ts +1 -1
- package/src/types.ts +1 -0
- package/src/utils.ts +3 -3
- package/tsup.config.ts +10 -7
- package/dist/cjs/bootstrap.cjs +0 -1000
- package/dist/cjs/database.cjs +0 -1105
- package/dist/cjs/dictionaries/awips.cjs +0 -370
- package/dist/cjs/dictionaries/events.cjs +0 -139
- package/dist/cjs/dictionaries/icao.cjs +0 -265
- package/dist/cjs/dictionaries/offshore.cjs +0 -40
- package/dist/cjs/dictionaries/signatures.cjs +0 -132
- package/dist/cjs/eas.cjs +0 -2851
- package/dist/cjs/parsers/events.cjs +0 -2851
- package/dist/cjs/parsers/stanza.cjs +0 -1099
- package/dist/cjs/parsers/text.cjs +0 -1133
- package/dist/cjs/parsers/types/api.cjs +0 -2851
- package/dist/cjs/parsers/types/cap.cjs +0 -2851
- package/dist/cjs/parsers/types/text.cjs +0 -2851
- package/dist/cjs/parsers/types/ugc.cjs +0 -2851
- package/dist/cjs/parsers/types/vtec.cjs +0 -2851
- package/dist/cjs/parsers/ugc.cjs +0 -1130
- package/dist/cjs/parsers/vtec.cjs +0 -1051
- package/dist/cjs/types.cjs +0 -17
- package/dist/cjs/utils.cjs +0 -2851
- package/dist/cjs/xmpp.cjs +0 -2851
- package/dist/esm/bootstrap.mjs +0 -963
- package/dist/esm/database.mjs +0 -1070
- package/dist/esm/dictionaries/awips.mjs +0 -346
- package/dist/esm/dictionaries/events.mjs +0 -111
- package/dist/esm/dictionaries/icao.mjs +0 -241
- package/dist/esm/dictionaries/offshore.mjs +0 -16
- package/dist/esm/dictionaries/signatures.mjs +0 -106
- package/dist/esm/eas.mjs +0 -2818
- package/dist/esm/parsers/events.mjs +0 -2818
- package/dist/esm/parsers/stanza.mjs +0 -1063
- package/dist/esm/parsers/text.mjs +0 -1097
- package/dist/esm/parsers/types/api.mjs +0 -2818
- package/dist/esm/parsers/types/cap.mjs +0 -2818
- package/dist/esm/parsers/types/text.mjs +0 -2818
- package/dist/esm/parsers/types/ugc.mjs +0 -2818
- package/dist/esm/parsers/types/vtec.mjs +0 -2818
- package/dist/esm/parsers/ugc.mjs +0 -1095
- package/dist/esm/parsers/vtec.mjs +0 -1016
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/utils.mjs +0 -2818
- 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/
|
|
67
|
-
var
|
|
68
|
-
__export(
|
|
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,9 +86,10 @@ __export(helper_exports, {
|
|
|
74
86
|
TextParser: () => text_default,
|
|
75
87
|
UGCParser: () => ugc_default,
|
|
76
88
|
VtecParser: () => vtec_default,
|
|
77
|
-
default: () =>
|
|
89
|
+
default: () => index_default,
|
|
90
|
+
types: () => types_exports
|
|
78
91
|
});
|
|
79
|
-
module.exports = __toCommonJS(
|
|
92
|
+
module.exports = __toCommonJS(index_exports);
|
|
80
93
|
|
|
81
94
|
// src/bootstrap.ts
|
|
82
95
|
var fs = __toESM(require("fs"));
|
|
@@ -184,17 +197,17 @@ var TYPES = {
|
|
|
184
197
|
"X": "Experimental Product (Non-Operational)"
|
|
185
198
|
};
|
|
186
199
|
var STATUS_CORRELATIONS = [
|
|
187
|
-
{ type: "Update", forward: "Updated", cancel: false },
|
|
188
|
-
{ type: "Cancel", forward: "Cancelled", cancel: true },
|
|
189
|
-
{ type: "Alert", forward: "Issued", cancel: false },
|
|
190
|
-
{ type: "Updated", forward: "Updated", cancel: false },
|
|
191
|
-
{ type: "Expired", forward: "Expired", cancel: true },
|
|
192
|
-
{ type: "Issued", forward: "Issued", cancel: false },
|
|
193
|
-
{ type: "Extended", forward: "Updated", cancel: false },
|
|
194
|
-
{ type: "Correction", forward: "Updated", cancel: false },
|
|
195
|
-
{ type: "Upgraded", forward: "Upgraded", cancel: false },
|
|
196
|
-
{ type: "Cancelled", forward: "Cancelled", cancel: true },
|
|
197
|
-
{ 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 }
|
|
198
211
|
];
|
|
199
212
|
|
|
200
213
|
// src/dictionaries/offshore.ts
|
|
@@ -928,6 +941,7 @@ var cache = {
|
|
|
928
941
|
var settings = {
|
|
929
942
|
database: path.join(process.cwd(), "shapefiles.db"),
|
|
930
943
|
isNWWS: true,
|
|
944
|
+
catchUnhandledExceptions: false,
|
|
931
945
|
NoaaWeatherWireService: {
|
|
932
946
|
clientReconnections: {
|
|
933
947
|
canReconnect: true,
|
|
@@ -1036,6 +1050,9 @@ var definitions = {
|
|
|
1036
1050
|
}
|
|
1037
1051
|
};
|
|
1038
1052
|
|
|
1053
|
+
// src/types.ts
|
|
1054
|
+
var types_exports = {};
|
|
1055
|
+
|
|
1039
1056
|
// src/parsers/stanza.ts
|
|
1040
1057
|
var StanzaParser = class {
|
|
1041
1058
|
/**
|
|
@@ -1500,7 +1517,7 @@ var VTECAlerts = class {
|
|
|
1500
1517
|
const getBaseProperties = yield events_default.getBaseProperties(message, validated, getUGC, vtec);
|
|
1501
1518
|
const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties, vtec);
|
|
1502
1519
|
processed.push({
|
|
1503
|
-
|
|
1520
|
+
performance: performance.now() - tick,
|
|
1504
1521
|
tracking: vtec.tracking,
|
|
1505
1522
|
header: getHeader,
|
|
1506
1523
|
vtec: vtec.raw,
|
|
@@ -1568,7 +1585,7 @@ var UGCAlerts = class {
|
|
|
1568
1585
|
const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
|
|
1569
1586
|
const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
|
|
1570
1587
|
processed.push({
|
|
1571
|
-
|
|
1588
|
+
performance: performance.now() - tick,
|
|
1572
1589
|
tracking: this.getTracking(getBaseProperties, getUGC.zones),
|
|
1573
1590
|
header: getHeader,
|
|
1574
1591
|
vtec: `N/A`,
|
|
@@ -1606,7 +1623,7 @@ var UGCAlerts2 = class {
|
|
|
1606
1623
|
const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
|
|
1607
1624
|
const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
|
|
1608
1625
|
processed.push({
|
|
1609
|
-
|
|
1626
|
+
performance: performance.now() - tick,
|
|
1610
1627
|
tracking: this.getTracking(getBaseProperties),
|
|
1611
1628
|
header: getHeader,
|
|
1612
1629
|
vtec: `N/A`,
|
|
@@ -1664,7 +1681,7 @@ var CapAlerts = class {
|
|
|
1664
1681
|
const getHeader = events_default.getHeader(__spreadValues({}, validated.attributes));
|
|
1665
1682
|
const getSource = text_default.textProductToString(extracted.description, `SOURCE...`, [`.`]) || `N/A`;
|
|
1666
1683
|
processed.push({
|
|
1667
|
-
|
|
1684
|
+
performance: performance.now() - tick,
|
|
1668
1685
|
tracking: this.getTracking(extracted),
|
|
1669
1686
|
header: getHeader,
|
|
1670
1687
|
vtec: extracted.vtec || `N/A`,
|
|
@@ -1695,7 +1712,13 @@ var CapAlerts = class {
|
|
|
1695
1712
|
discussion_wind_intensity: `N/A`,
|
|
1696
1713
|
discussion_hail_intensity: `N/A`
|
|
1697
1714
|
},
|
|
1698
|
-
geometry: extracted.polygon ? {
|
|
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
|
|
1699
1722
|
}
|
|
1700
1723
|
});
|
|
1701
1724
|
}
|
|
@@ -1722,7 +1745,7 @@ var APIAlerts = class {
|
|
|
1722
1745
|
}
|
|
1723
1746
|
static event(validated) {
|
|
1724
1747
|
return __async(this, null, function* () {
|
|
1725
|
-
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;
|
|
1726
1749
|
let processed = [];
|
|
1727
1750
|
const messages = Object.values(JSON.parse(validated.message).features);
|
|
1728
1751
|
for (let feature of messages) {
|
|
@@ -1737,7 +1760,7 @@ var APIAlerts = class {
|
|
|
1737
1760
|
const getSource = text_default.textProductToString(getDescription, `SOURCE...`, [`.`]) || `N/A`;
|
|
1738
1761
|
const getOffice = this.getICAO(getVTEC || ``);
|
|
1739
1762
|
processed.push({
|
|
1740
|
-
|
|
1763
|
+
performance: performance.now() - tick,
|
|
1741
1764
|
tracking: this.getTracking({ vtec: getVTEC, wmoidentifier: getWmo, ugc: getUgc ? getUgc.join(`,`) : null }),
|
|
1742
1765
|
header: getHeader,
|
|
1743
1766
|
vtec: getVTEC || `N/A`,
|
|
@@ -1772,7 +1795,13 @@ var APIAlerts = class {
|
|
|
1772
1795
|
peakWindGust: `N/A`,
|
|
1773
1796
|
peakHailSize: `N/A`
|
|
1774
1797
|
},
|
|
1775
|
-
geometry: (_ca = feature == null ? void 0 : feature.geometry)
|
|
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
|
|
1776
1805
|
}
|
|
1777
1806
|
});
|
|
1778
1807
|
}
|
|
@@ -2326,16 +2355,17 @@ var EventParser = class {
|
|
|
2326
2355
|
}
|
|
2327
2356
|
}
|
|
2328
2357
|
const filtered = events2.filter((alert) => {
|
|
2329
|
-
var _a2, _b2,
|
|
2358
|
+
var _a2, _b2, _d2, _e2;
|
|
2330
2359
|
const originalEvent = alert;
|
|
2331
2360
|
const props = originalEvent == null ? void 0 : originalEvent.properties;
|
|
2332
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"]);
|
|
2333
2363
|
if (bools == null ? void 0 : bools.betterEventParsing) {
|
|
2334
2364
|
const { eventName, tags } = this.enhanceEvent(originalEvent);
|
|
2335
2365
|
originalEvent.properties.event = eventName;
|
|
2336
2366
|
originalEvent.properties.tags = tags;
|
|
2337
2367
|
}
|
|
2338
|
-
const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (
|
|
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();
|
|
2339
2369
|
const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
|
|
2340
2370
|
for (const key in sets) {
|
|
2341
2371
|
const setting = sets[key];
|
|
@@ -2354,13 +2384,15 @@ var EventParser = class {
|
|
|
2354
2384
|
if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
|
|
2355
2385
|
}
|
|
2356
2386
|
originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
|
|
2357
|
-
originalEvent.properties.
|
|
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");
|
|
2358
2391
|
if (props.description) {
|
|
2359
2392
|
const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
|
|
2360
|
-
if (detectedPhrase
|
|
2393
|
+
if (detectedPhrase) {
|
|
2361
2394
|
originalEvent.properties.action_type = "Cancel";
|
|
2362
2395
|
originalEvent.properties.is_cancelled = true;
|
|
2363
|
-
return false;
|
|
2364
2396
|
}
|
|
2365
2397
|
}
|
|
2366
2398
|
if (originalEvent.vtec) {
|
|
@@ -2370,6 +2402,7 @@ var EventParser = class {
|
|
|
2370
2402
|
return false;
|
|
2371
2403
|
}
|
|
2372
2404
|
}
|
|
2405
|
+
if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
|
|
2373
2406
|
cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
|
|
2374
2407
|
return true;
|
|
2375
2408
|
});
|
|
@@ -2734,8 +2767,8 @@ var Utils = class {
|
|
|
2734
2767
|
* @static
|
|
2735
2768
|
*/
|
|
2736
2769
|
static detectUncaughtExceptions() {
|
|
2737
|
-
if (
|
|
2738
|
-
|
|
2770
|
+
if (cache.events.listenerCount("uncaughtException") > 0) return;
|
|
2771
|
+
cache.events.on("uncaughtException", (error) => {
|
|
2739
2772
|
cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
|
|
2740
2773
|
});
|
|
2741
2774
|
}
|
|
@@ -2853,9 +2886,9 @@ var Utils = class {
|
|
|
2853
2886
|
};
|
|
2854
2887
|
var utils_default = Utils;
|
|
2855
2888
|
|
|
2856
|
-
// src/
|
|
2889
|
+
// src/index.ts
|
|
2857
2890
|
var AlertManager = class {
|
|
2858
|
-
constructor(metadata
|
|
2891
|
+
constructor(metadata) {
|
|
2859
2892
|
this.start(metadata);
|
|
2860
2893
|
}
|
|
2861
2894
|
/**
|
|
@@ -2951,14 +2984,16 @@ var AlertManager = class {
|
|
|
2951
2984
|
* @param {Record<string, string>} [metadata={}]
|
|
2952
2985
|
* @returns {Promise<void>}
|
|
2953
2986
|
*/
|
|
2954
|
-
start() {
|
|
2955
|
-
return __async(this,
|
|
2987
|
+
start(metadata) {
|
|
2988
|
+
return __async(this, null, function* () {
|
|
2956
2989
|
if (!cache.isReady) {
|
|
2957
2990
|
console.log(definitions.messages.not_ready);
|
|
2958
2991
|
return Promise.resolve();
|
|
2959
2992
|
}
|
|
2960
|
-
|
|
2961
|
-
|
|
2993
|
+
this.setSettings(metadata);
|
|
2994
|
+
if (settings.catchUnhandledExceptions) {
|
|
2995
|
+
utils_default.detectUncaughtExceptions();
|
|
2996
|
+
}
|
|
2962
2997
|
const settings2 = settings;
|
|
2963
2998
|
this.isNoaaWeatherWireService = settings.isNWWS;
|
|
2964
2999
|
cache.isReady = false;
|
|
@@ -2994,7 +3029,7 @@ var AlertManager = class {
|
|
|
2994
3029
|
});
|
|
2995
3030
|
}
|
|
2996
3031
|
};
|
|
2997
|
-
var
|
|
3032
|
+
var index_default = AlertManager;
|
|
2998
3033
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2999
3034
|
0 && (module.exports = {
|
|
3000
3035
|
AlertManager,
|
|
@@ -3004,5 +3039,6 @@ var helper_default = AlertManager;
|
|
|
3004
3039
|
StanzaParser,
|
|
3005
3040
|
TextParser,
|
|
3006
3041
|
UGCParser,
|
|
3007
|
-
VtecParser
|
|
3042
|
+
VtecParser,
|
|
3043
|
+
types
|
|
3008
3044
|
});
|
|
@@ -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,
|
|
@@ -996,6 +1009,9 @@ var definitions = {
|
|
|
996
1009
|
}
|
|
997
1010
|
};
|
|
998
1011
|
|
|
1012
|
+
// src/types.ts
|
|
1013
|
+
var types_exports = {};
|
|
1014
|
+
|
|
999
1015
|
// src/parsers/stanza.ts
|
|
1000
1016
|
var StanzaParser = class {
|
|
1001
1017
|
/**
|
|
@@ -1460,7 +1476,7 @@ var VTECAlerts = class {
|
|
|
1460
1476
|
const getBaseProperties = yield events_default.getBaseProperties(message, validated, getUGC, vtec);
|
|
1461
1477
|
const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties, vtec);
|
|
1462
1478
|
processed.push({
|
|
1463
|
-
|
|
1479
|
+
performance: performance.now() - tick,
|
|
1464
1480
|
tracking: vtec.tracking,
|
|
1465
1481
|
header: getHeader,
|
|
1466
1482
|
vtec: vtec.raw,
|
|
@@ -1528,7 +1544,7 @@ var UGCAlerts = class {
|
|
|
1528
1544
|
const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
|
|
1529
1545
|
const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
|
|
1530
1546
|
processed.push({
|
|
1531
|
-
|
|
1547
|
+
performance: performance.now() - tick,
|
|
1532
1548
|
tracking: this.getTracking(getBaseProperties, getUGC.zones),
|
|
1533
1549
|
header: getHeader,
|
|
1534
1550
|
vtec: `N/A`,
|
|
@@ -1566,7 +1582,7 @@ var UGCAlerts2 = class {
|
|
|
1566
1582
|
const getHeader = events_default.getHeader(__spreadValues(__spreadValues({}, validated.attributes), getBaseProperties.attributes), getBaseProperties);
|
|
1567
1583
|
const getEvent = this.getEvent(message, getBaseProperties.attributes.getAwip);
|
|
1568
1584
|
processed.push({
|
|
1569
|
-
|
|
1585
|
+
performance: performance.now() - tick,
|
|
1570
1586
|
tracking: this.getTracking(getBaseProperties),
|
|
1571
1587
|
header: getHeader,
|
|
1572
1588
|
vtec: `N/A`,
|
|
@@ -1624,7 +1640,7 @@ var CapAlerts = class {
|
|
|
1624
1640
|
const getHeader = events_default.getHeader(__spreadValues({}, validated.attributes));
|
|
1625
1641
|
const getSource = text_default.textProductToString(extracted.description, `SOURCE...`, [`.`]) || `N/A`;
|
|
1626
1642
|
processed.push({
|
|
1627
|
-
|
|
1643
|
+
performance: performance.now() - tick,
|
|
1628
1644
|
tracking: this.getTracking(extracted),
|
|
1629
1645
|
header: getHeader,
|
|
1630
1646
|
vtec: extracted.vtec || `N/A`,
|
|
@@ -1655,7 +1671,13 @@ var CapAlerts = class {
|
|
|
1655
1671
|
discussion_wind_intensity: `N/A`,
|
|
1656
1672
|
discussion_hail_intensity: `N/A`
|
|
1657
1673
|
},
|
|
1658
|
-
geometry: extracted.polygon ? {
|
|
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
|
|
1659
1681
|
}
|
|
1660
1682
|
});
|
|
1661
1683
|
}
|
|
@@ -1682,7 +1704,7 @@ var APIAlerts = class {
|
|
|
1682
1704
|
}
|
|
1683
1705
|
static event(validated) {
|
|
1684
1706
|
return __async(this, null, function* () {
|
|
1685
|
-
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;
|
|
1686
1708
|
let processed = [];
|
|
1687
1709
|
const messages = Object.values(JSON.parse(validated.message).features);
|
|
1688
1710
|
for (let feature of messages) {
|
|
@@ -1697,7 +1719,7 @@ var APIAlerts = class {
|
|
|
1697
1719
|
const getSource = text_default.textProductToString(getDescription, `SOURCE...`, [`.`]) || `N/A`;
|
|
1698
1720
|
const getOffice = this.getICAO(getVTEC || ``);
|
|
1699
1721
|
processed.push({
|
|
1700
|
-
|
|
1722
|
+
performance: performance.now() - tick,
|
|
1701
1723
|
tracking: this.getTracking({ vtec: getVTEC, wmoidentifier: getWmo, ugc: getUgc ? getUgc.join(`,`) : null }),
|
|
1702
1724
|
header: getHeader,
|
|
1703
1725
|
vtec: getVTEC || `N/A`,
|
|
@@ -1732,7 +1754,13 @@ var APIAlerts = class {
|
|
|
1732
1754
|
peakWindGust: `N/A`,
|
|
1733
1755
|
peakHailSize: `N/A`
|
|
1734
1756
|
},
|
|
1735
|
-
geometry: (_ca = feature == null ? void 0 : feature.geometry)
|
|
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
|
|
1736
1764
|
}
|
|
1737
1765
|
});
|
|
1738
1766
|
}
|
|
@@ -2286,16 +2314,17 @@ var EventParser = class {
|
|
|
2286
2314
|
}
|
|
2287
2315
|
}
|
|
2288
2316
|
const filtered = events2.filter((alert) => {
|
|
2289
|
-
var _a2, _b2,
|
|
2317
|
+
var _a2, _b2, _d2, _e2;
|
|
2290
2318
|
const originalEvent = alert;
|
|
2291
2319
|
const props = originalEvent == null ? void 0 : originalEvent.properties;
|
|
2292
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"]);
|
|
2293
2322
|
if (bools == null ? void 0 : bools.betterEventParsing) {
|
|
2294
2323
|
const { eventName, tags } = this.enhanceEvent(originalEvent);
|
|
2295
2324
|
originalEvent.properties.event = eventName;
|
|
2296
2325
|
originalEvent.properties.tags = tags;
|
|
2297
2326
|
}
|
|
2298
|
-
const eventCheck = (bools == null ? void 0 : bools.useParentEvents) ? (
|
|
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();
|
|
2299
2328
|
const statusCorrelation = definitions.correlations.find((c) => c.type === originalEvent.properties.action_type);
|
|
2300
2329
|
for (const key in sets) {
|
|
2301
2330
|
const setting = sets[key];
|
|
@@ -2314,13 +2343,15 @@ var EventParser = class {
|
|
|
2314
2343
|
if (key === "checkExpired" && setting && new Date(props == null ? void 0 : props.expires).getTime() < (/* @__PURE__ */ new Date()).getTime()) return false;
|
|
2315
2344
|
}
|
|
2316
2345
|
originalEvent.properties.action_type = statusCorrelation ? statusCorrelation.forward : originalEvent.properties.action_type;
|
|
2317
|
-
originalEvent.properties.
|
|
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");
|
|
2318
2350
|
if (props.description) {
|
|
2319
2351
|
const detectedPhrase = definitions.cancelSignatures.find((sig) => props.description.toLowerCase().includes(sig.toLowerCase()));
|
|
2320
|
-
if (detectedPhrase
|
|
2352
|
+
if (detectedPhrase) {
|
|
2321
2353
|
originalEvent.properties.action_type = "Cancel";
|
|
2322
2354
|
originalEvent.properties.is_cancelled = true;
|
|
2323
|
-
return false;
|
|
2324
2355
|
}
|
|
2325
2356
|
}
|
|
2326
2357
|
if (originalEvent.vtec) {
|
|
@@ -2330,6 +2361,7 @@ var EventParser = class {
|
|
|
2330
2361
|
return false;
|
|
2331
2362
|
}
|
|
2332
2363
|
}
|
|
2364
|
+
if (bools.checkExpired && originalEvent.properties.is_cancelled == true) return false;
|
|
2333
2365
|
cache.events.emit(`on${originalEvent.properties.parent.replace(/\s+/g, "")}`);
|
|
2334
2366
|
return true;
|
|
2335
2367
|
});
|
|
@@ -2694,8 +2726,8 @@ var Utils = class {
|
|
|
2694
2726
|
* @static
|
|
2695
2727
|
*/
|
|
2696
2728
|
static detectUncaughtExceptions() {
|
|
2697
|
-
if (
|
|
2698
|
-
|
|
2729
|
+
if (cache.events.listenerCount("uncaughtException") > 0) return;
|
|
2730
|
+
cache.events.on("uncaughtException", (error) => {
|
|
2699
2731
|
cache.events.emit(`onError`, { message: `Uncaught Exception: ${error.message}`, code: `error-uncaught-exception`, stack: error.stack });
|
|
2700
2732
|
});
|
|
2701
2733
|
}
|
|
@@ -2813,9 +2845,9 @@ var Utils = class {
|
|
|
2813
2845
|
};
|
|
2814
2846
|
var utils_default = Utils;
|
|
2815
2847
|
|
|
2816
|
-
// src/
|
|
2848
|
+
// src/index.ts
|
|
2817
2849
|
var AlertManager = class {
|
|
2818
|
-
constructor(metadata
|
|
2850
|
+
constructor(metadata) {
|
|
2819
2851
|
this.start(metadata);
|
|
2820
2852
|
}
|
|
2821
2853
|
/**
|
|
@@ -2911,14 +2943,16 @@ var AlertManager = class {
|
|
|
2911
2943
|
* @param {Record<string, string>} [metadata={}]
|
|
2912
2944
|
* @returns {Promise<void>}
|
|
2913
2945
|
*/
|
|
2914
|
-
start() {
|
|
2915
|
-
return __async(this,
|
|
2946
|
+
start(metadata) {
|
|
2947
|
+
return __async(this, null, function* () {
|
|
2916
2948
|
if (!cache.isReady) {
|
|
2917
2949
|
console.log(definitions.messages.not_ready);
|
|
2918
2950
|
return Promise.resolve();
|
|
2919
2951
|
}
|
|
2920
|
-
|
|
2921
|
-
|
|
2952
|
+
this.setSettings(metadata);
|
|
2953
|
+
if (settings.catchUnhandledExceptions) {
|
|
2954
|
+
utils_default.detectUncaughtExceptions();
|
|
2955
|
+
}
|
|
2922
2956
|
const settings2 = settings;
|
|
2923
2957
|
this.isNoaaWeatherWireService = settings.isNWWS;
|
|
2924
2958
|
cache.isReady = false;
|
|
@@ -2954,7 +2988,7 @@ var AlertManager = class {
|
|
|
2954
2988
|
});
|
|
2955
2989
|
}
|
|
2956
2990
|
};
|
|
2957
|
-
var
|
|
2991
|
+
var index_default = AlertManager;
|
|
2958
2992
|
export {
|
|
2959
2993
|
AlertManager,
|
|
2960
2994
|
database_default as Database,
|
|
@@ -2964,5 +2998,6 @@ export {
|
|
|
2964
2998
|
text_default as TextParser,
|
|
2965
2999
|
ugc_default as UGCParser,
|
|
2966
3000
|
vtec_default as VtecParser,
|
|
2967
|
-
|
|
3001
|
+
index_default as default,
|
|
3002
|
+
types_exports as types
|
|
2968
3003
|
};
|
package/package.json
CHANGED
package/src/bootstrap.ts
CHANGED
|
@@ -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
|
|
|
@@ -26,7 +26,7 @@ import UGCParser from './parsers/ugc';
|
|
|
26
26
|
|
|
27
27
|
export class AlertManager {
|
|
28
28
|
isNoaaWeatherWireService: boolean
|
|
29
|
-
constructor(metadata:
|
|
29
|
+
constructor(metadata: types.ClientSettings) { this.start(metadata) }
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* setDisplayName allows you to set or update the nickname of the client for identification purposes.
|
|
@@ -122,13 +122,13 @@ export class AlertManager {
|
|
|
122
122
|
* @param {Record<string, string>} [metadata={}]
|
|
123
123
|
* @returns {Promise<void>}
|
|
124
124
|
*/
|
|
125
|
-
public async start(metadata:
|
|
125
|
+
public async start(metadata: types.ClientSettings): Promise<void> {
|
|
126
126
|
if (!loader.cache.isReady) {
|
|
127
127
|
console.log(loader.definitions.messages.not_ready);
|
|
128
128
|
return Promise.resolve();
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
Utils.detectUncaughtExceptions();
|
|
130
|
+
this.setSettings(metadata);
|
|
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;
|
|
@@ -164,4 +164,4 @@ export class AlertManager {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
export default AlertManager;
|
|
167
|
-
export { StanzaParser, EventParser, TextParser, VtecParser, UGCParser, EAS, Database };
|
|
167
|
+
export { StanzaParser, EventParser, TextParser, VtecParser, UGCParser, EAS, Database, types };
|
package/src/parsers/events.ts
CHANGED
|
@@ -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.
|
|
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
|
|
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
|
})
|