@atmosx/event-product-parser 3.0.4 → 3.0.42
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/README.md +9 -0
- package/dist/cjs/index.cjs +75 -57
- package/dist/esm/index.mjs +74 -57
- package/dist/index.d.mts +28 -3
- package/dist/index.d.ts +28 -3
- package/package.json +1 -1
- package/src/@building/building.office.ts +1 -1
- package/src/@building/building.properties.ts +5 -1
- package/src/@building/building.signature.ts +1 -1
- package/src/@building/building.tracking.ts +7 -7
- package/src/@building/building.validate.ts +1 -3
- package/src/@core/core.query.ts +39 -0
- package/src/@core/core.setNode.ts +2 -2
- package/src/@core/core.start.ts +1 -1
- package/src/@dictionaries/dictionaries.officeICAOs.ts +2 -0
- package/src/{@modules/@utilities/utilities.createWebhook.ts → @manager/manager.createWebhook.ts} +12 -10
- package/src/@manager/manager.mkEvent.ts +5 -12
- package/src/@manager/manager.setHash.ts +1 -1
- package/src/@manager/manager.updateWebhooks.ts +1 -2
- package/src/@modules/@utilities/utilities.setTimeoutAction.ts +1 -1
- package/src/@modules/@xmpp/xmpp.xReconnect.ts +1 -1
- package/src/@parsers/@pvtec/pvtec.extract.ts +1 -1
- package/src/@parsers/@ugc/ugc.coordinates.ts +2 -2
- package/src/bootstrap.ts +1 -1
- package/src/index.ts +3 -2
package/README.md
CHANGED
|
@@ -320,6 +320,15 @@ const nodes = getNodes()
|
|
|
320
320
|
console.log(nodes)
|
|
321
321
|
```
|
|
322
322
|
|
|
323
|
+
### Function `query`
|
|
324
|
+
Queries the event cache (datbase) for specific events based on text.
|
|
325
|
+
```ts
|
|
326
|
+
import { query } from "@atmosx/event-product-parser"
|
|
327
|
+
query({search: "Tornado Warning", limit: 3}).then(results => {
|
|
328
|
+
console.log(results)
|
|
329
|
+
})
|
|
330
|
+
````
|
|
331
|
+
|
|
323
332
|
### Function `setEasTone`
|
|
324
333
|
Fetches an EAS audio message for an event (Simulated)
|
|
325
334
|
```ts
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -10497,6 +10497,7 @@ __export(index_exports, {
|
|
|
10497
10497
|
getEvents: () => getEvents,
|
|
10498
10498
|
getNodes: () => getNodes,
|
|
10499
10499
|
getRandomEvent: () => getRandomEvent,
|
|
10500
|
+
query: () => query,
|
|
10500
10501
|
setEasTone: () => setEasTone,
|
|
10501
10502
|
setNode: () => setNode,
|
|
10502
10503
|
setSettings: () => setSettings,
|
|
@@ -10509,7 +10510,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
10509
10510
|
var import_path = __toESM(require("path"));
|
|
10510
10511
|
var import_node_events = require("events");
|
|
10511
10512
|
var bootstrap = {
|
|
10512
|
-
version: `3.0.
|
|
10513
|
+
version: `3.0.42`,
|
|
10513
10514
|
isReady: true,
|
|
10514
10515
|
ratelimits: {},
|
|
10515
10516
|
session_xmpp: null,
|
|
@@ -10623,6 +10624,7 @@ var getSettings = () => {
|
|
|
10623
10624
|
// src/@parsers/@ugc/ugc.coordinates.ts
|
|
10624
10625
|
var import_polygon_clipping = require("polygon-clipping");
|
|
10625
10626
|
var getZonePolygon = (options) => {
|
|
10627
|
+
var _a, _b;
|
|
10626
10628
|
const list = [...new Set(options.zones.map((z) => z.trim()))].filter((z) => z === "XX000" ? false : true);
|
|
10627
10629
|
if (list.length === 0) return null;
|
|
10628
10630
|
const placeholders = list.map(() => "?").join(",");
|
|
@@ -10658,7 +10660,7 @@ var getZonePolygon = (options) => {
|
|
|
10658
10660
|
}
|
|
10659
10661
|
if (!bestPoly || bestPoly.length === 0) return null;
|
|
10660
10662
|
const outerRing = bestPoly[0];
|
|
10661
|
-
const skip = Math.max(1, parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10)
|
|
10663
|
+
const skip = Math.max(1, (_a = parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10)) != null ? _a : 1);
|
|
10662
10664
|
let skipped = outerRing.filter((_, idx) => idx % skip === 0);
|
|
10663
10665
|
if (skipped.length < 4) {
|
|
10664
10666
|
skipped = outerRing.slice();
|
|
@@ -10677,7 +10679,7 @@ var getZonePolygon = (options) => {
|
|
|
10677
10679
|
}
|
|
10678
10680
|
}
|
|
10679
10681
|
if (multi.length === 0) return null;
|
|
10680
|
-
const skip = Math.max(1, parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10)
|
|
10682
|
+
const skip = Math.max(1, (_b = parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10)) != null ? _b : 1);
|
|
10681
10683
|
if (skip > 1) {
|
|
10682
10684
|
for (let p = 0; p < multi.length; p++) {
|
|
10683
10685
|
for (let r = 0; r < multi[p].length; r++) {
|
|
@@ -10734,7 +10736,7 @@ var getCleanedEvent = (event) => {
|
|
|
10734
10736
|
|
|
10735
10737
|
// src/@modules/@utilities/utilities.setTimeoutAction.ts
|
|
10736
10738
|
var setTimeoutAction = (options) => {
|
|
10737
|
-
var _a, _b;
|
|
10739
|
+
var _a, _b, _c;
|
|
10738
10740
|
let target = (_b = (_a = bootstrap) == null ? void 0 : _a.ratelimits) == null ? void 0 : _b[options == null ? void 0 : options.identifier];
|
|
10739
10741
|
if (!target) {
|
|
10740
10742
|
bootstrap.ratelimits[options == null ? void 0 : options.identifier] = [];
|
|
@@ -10746,7 +10748,7 @@ var setTimeoutAction = (options) => {
|
|
|
10746
10748
|
}
|
|
10747
10749
|
const oldestTimestamp = target == null ? void 0 : target[0];
|
|
10748
10750
|
const getWait = oldestTimestamp ? Math.ceil((options == null ? void 0 : options.interval) * 1e3 - (Date.now() - oldestTimestamp)) : 0;
|
|
10749
|
-
const max = (options == null ? void 0 : options.max)
|
|
10751
|
+
const max = (_c = options == null ? void 0 : options.max) != null ? _c : 1;
|
|
10750
10752
|
if ((target == null ? void 0 : target.length) >= max && getWait > 0) {
|
|
10751
10753
|
return {
|
|
10752
10754
|
limited: true,
|
|
@@ -14078,6 +14080,7 @@ var getTextFromProduct = (options) => {
|
|
|
14078
14080
|
|
|
14079
14081
|
// src/@dictionaries/dictionaries.officeICAOs.ts
|
|
14080
14082
|
var officeICAOs = {
|
|
14083
|
+
"KLUB": "Lubbock, TX",
|
|
14081
14084
|
"KLCH": "Lake Charles, LA",
|
|
14082
14085
|
"TSTL": "St. Louis, MO",
|
|
14083
14086
|
"PABC": "Bethel, AK",
|
|
@@ -14313,14 +14316,15 @@ var officeICAOs = {
|
|
|
14313
14316
|
"KCAR": "Caribou, ME",
|
|
14314
14317
|
"KMFR": "Medford, OR",
|
|
14315
14318
|
"PGUM": "Guam, GU",
|
|
14319
|
+
"PACR": "Cordova, AK",
|
|
14316
14320
|
"PAJK": "Juneau, AK"
|
|
14317
14321
|
};
|
|
14318
14322
|
|
|
14319
14323
|
// src/@building/building.office.ts
|
|
14320
14324
|
var getEventOffice = (options) => {
|
|
14321
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14322
|
-
const office = options.pVtec != null ? (_b = (_a = options.pVtec) == null ? void 0 : _a.tracking) == null ? void 0 : _b.split(
|
|
14323
|
-
const name = (
|
|
14325
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
14326
|
+
const office = options.pVtec != null ? (_b = (_a = options.pVtec) == null ? void 0 : _a.tracking) == null ? void 0 : _b.split(`.`)[0] : (_e = (_c = options.attributes) == null ? void 0 : _c.cccc) != null ? _e : options.organization != null ? Array.isArray(options.organization) ? (_d = options.organization) == null ? void 0 : _d[0] : options.organization : null;
|
|
14327
|
+
const name = (_g = (_f = officeICAOs) == null ? void 0 : _f[office]) != null ? _g : null;
|
|
14324
14328
|
return { office, name };
|
|
14325
14329
|
};
|
|
14326
14330
|
|
|
@@ -14410,7 +14414,7 @@ var properties = (options) => {
|
|
|
14410
14414
|
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;
|
|
14411
14415
|
const organization = (_b = (_a = options.message.match(regExp.wmo)) == null ? void 0 : _a[0]) != null ? _b : null;
|
|
14412
14416
|
const polygons = getPolygonFromProduct(options.message);
|
|
14413
|
-
|
|
14417
|
+
const properties2 = {
|
|
14414
14418
|
locations: (_e = (_d = (_c = options == null ? void 0 : options.ugc) == null ? void 0 : _c.locations) == null ? void 0 : _d.join(`; `)) != null ? _e : null,
|
|
14415
14419
|
description: getDescriptionFromProduct({ message: options.message, handle: (_g = (_f = options == null ? void 0 : options.pVtec) == null ? void 0 : _f.vtec) != null ? _g : null }),
|
|
14416
14420
|
attributes: options.attributes,
|
|
@@ -14456,6 +14460,10 @@ var properties = (options) => {
|
|
|
14456
14460
|
pds_watch: getTextFromProduct({ message: options.message, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`
|
|
14457
14461
|
}
|
|
14458
14462
|
};
|
|
14463
|
+
if (isNaN(Number(properties2.watch_parameters.watch_number))) {
|
|
14464
|
+
properties2.watch_parameters.watch_number = null;
|
|
14465
|
+
}
|
|
14466
|
+
return properties2;
|
|
14459
14467
|
};
|
|
14460
14468
|
|
|
14461
14469
|
// src/@building/building.headers.ts
|
|
@@ -14489,16 +14497,16 @@ var eventsMatchText = {
|
|
|
14489
14497
|
// src/@building/building.tracking.ts
|
|
14490
14498
|
var getEventTracking = (options) => {
|
|
14491
14499
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
14492
|
-
const
|
|
14500
|
+
const properties2 = options.properties;
|
|
14493
14501
|
const attributes = options.attributes;
|
|
14494
14502
|
const stanza = options.stanza;
|
|
14495
14503
|
const vtec2 = options.vtec;
|
|
14496
14504
|
if (options.type === `RAW`) {
|
|
14497
|
-
const getWatchNumber = (_a =
|
|
14505
|
+
const getWatchNumber = (_a = properties2.watch_parameters.watch_number) != null ? _a : null;
|
|
14498
14506
|
if (getWatchNumber) {
|
|
14499
|
-
return `${
|
|
14507
|
+
return `${properties2.geocode.office.office}.${stanza.getType.prefix}.A.${getWatchNumber}`;
|
|
14500
14508
|
}
|
|
14501
|
-
return `${
|
|
14509
|
+
return `${properties2.geocode.office.office}.${attributes.ttaaii}.${(_b = attributes.id.slice(-4).replace(`.`, ``)) != null ? _b : "0"}`;
|
|
14502
14510
|
}
|
|
14503
14511
|
if (options.type === `VTEC`) {
|
|
14504
14512
|
return vtec2.tracking;
|
|
@@ -14507,16 +14515,16 @@ var getEventTracking = (options) => {
|
|
|
14507
14515
|
if (options.vtec) {
|
|
14508
14516
|
const vtecValue = Array.isArray(options.vtec) ? options.vtec[0] : options.vtec;
|
|
14509
14517
|
const splitPVTEC = vtecValue.split(".");
|
|
14510
|
-
return `${splitPVTEC[2]}
|
|
14518
|
+
return `${splitPVTEC[2]}.${splitPVTEC[3]}.${splitPVTEC[4]}.${splitPVTEC[5]}`;
|
|
14511
14519
|
}
|
|
14512
14520
|
const wmoMatch = (_d = (_c = options.organization) == null ? void 0 : _c.wmoidentifier) == null ? void 0 : _d.match(/([A-Z]{4}\d{2})\s+([A-Z]{4})/);
|
|
14513
14521
|
const station = (_e = wmoMatch == null ? void 0 : wmoMatch[2]) != null ? _e : "N/A";
|
|
14514
14522
|
if (options.organization.featureId) {
|
|
14515
14523
|
const idMatch = options.organization.featureId.match(/([a-f0-9]+)\.(\d+)\.(\d+)$/);
|
|
14516
|
-
return `${station}
|
|
14524
|
+
return `${station}.${(_f = idMatch == null ? void 0 : idMatch[1]) != null ? _f : "N/A"}`;
|
|
14517
14525
|
}
|
|
14518
14526
|
const id2 = (_g = wmoMatch == null ? void 0 : wmoMatch[1]) != null ? _g : "N/A";
|
|
14519
|
-
return `${station}
|
|
14527
|
+
return `${station}.${id2}`;
|
|
14520
14528
|
}
|
|
14521
14529
|
};
|
|
14522
14530
|
|
|
@@ -14712,8 +14720,8 @@ var getEventSignature = (event) => {
|
|
|
14712
14720
|
const getProduct = (_f = (_e = vtec2 == null ? void 0 : vtec2.vtec) == null ? void 0 : _e.split(`.`)[0]) == null ? void 0 : _f.replace(`/`, ``);
|
|
14713
14721
|
const isTestProduct = eventProducts[getProduct] == `Test Product`;
|
|
14714
14722
|
if (isTestProduct || testSignatures.some((sig) => {
|
|
14715
|
-
var _a2, _b2, _c2;
|
|
14716
|
-
return ((_a2 = properties2.description) == null ? void 0 : _a2.toLowerCase().includes(sig.toLowerCase()))
|
|
14723
|
+
var _a2, _b2, _c2, _d2;
|
|
14724
|
+
return (_d2 = (_a2 = properties2.description) == null ? void 0 : _a2.toLowerCase().includes(sig.toLowerCase())) != null ? _d2 : (_c2 = (_b2 = properties2 == null ? void 0 : properties2.parameters) == null ? void 0 : _b2.instructions) == null ? void 0 : _c2.toLowerCase().includes(sig.toLowerCase());
|
|
14717
14725
|
})) {
|
|
14718
14726
|
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_test: true });
|
|
14719
14727
|
}
|
|
@@ -14725,7 +14733,7 @@ var getEventSignature = (event) => {
|
|
|
14725
14733
|
};
|
|
14726
14734
|
|
|
14727
14735
|
// src/@manager/manager.setHash.ts
|
|
14728
|
-
var setHash = (event, entry) =>
|
|
14736
|
+
var setHash = (event, entry) => {
|
|
14729
14737
|
if (entry) {
|
|
14730
14738
|
entry.hashes.push(event.properties.metadata.hash);
|
|
14731
14739
|
entry.expires = event.properties.expires;
|
|
@@ -14736,7 +14744,7 @@ var setHash = (event, entry) => __async(null, null, function* () {
|
|
|
14736
14744
|
expires: event.properties.expires
|
|
14737
14745
|
});
|
|
14738
14746
|
}
|
|
14739
|
-
}
|
|
14747
|
+
};
|
|
14740
14748
|
|
|
14741
14749
|
// src/@modules/@utilities/utilities.createHttp.ts
|
|
14742
14750
|
var import_request = __toESM(require("request"));
|
|
@@ -14796,15 +14804,15 @@ var createHttp = (options) => __async(null, null, function* () {
|
|
|
14796
14804
|
});
|
|
14797
14805
|
});
|
|
14798
14806
|
|
|
14799
|
-
// src/@
|
|
14807
|
+
// src/@manager/manager.createWebhook.ts
|
|
14800
14808
|
var import_form_data = __toESM(require_form_data());
|
|
14801
14809
|
var createWebhook = (options) => __async(null, null, function* () {
|
|
14802
|
-
var _a, _b, _c, _d;
|
|
14810
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14803
14811
|
const event = options.event.properties;
|
|
14804
14812
|
const settings = options.webhook;
|
|
14805
14813
|
let body = [
|
|
14806
14814
|
event.locations ? `**Locations**: ${event.locations.slice(0, 100)}` : null,
|
|
14807
|
-
event.issued ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime() / 1e3)}:R>` : null,
|
|
14815
|
+
event.issued && event.status != `Expired` ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime() / 1e3)}:R>` : null,
|
|
14808
14816
|
event.expires && event.status != `Statement` ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime() / 1e3)}:R>` : null,
|
|
14809
14817
|
(() => {
|
|
14810
14818
|
var _a2, _b2;
|
|
@@ -14817,7 +14825,7 @@ var createWebhook = (options) => __async(null, null, function* () {
|
|
|
14817
14825
|
var _a2, _b2;
|
|
14818
14826
|
const val = (_a2 = event.parameters.estimated_hail_size) != null ? _a2 : null;
|
|
14819
14827
|
const th = (_b2 = event.parameters.hail_threat) != null ? _b2 : null;
|
|
14820
|
-
return val
|
|
14828
|
+
return (val != null ? val : th) ? `**Hail Threat**: ${val} ${th ? `(${th})` : ""}` : null;
|
|
14821
14829
|
})(),
|
|
14822
14830
|
event.parameters.damage_threat ? `**Damage Threat**: ${event.parameters.damage_threat}` : null,
|
|
14823
14831
|
event.parameters.flood_threat ? `**Flood Threat**: ${event.parameters.flood_threat}` : null,
|
|
@@ -14838,14 +14846,19 @@ var createWebhook = (options) => __async(null, null, function* () {
|
|
|
14838
14846
|
event.watch_parameters.max_tops_x100feet ? `**Max Tops (x100 feet)**: ${event.watch_parameters.max_tops_x100feet}` : null,
|
|
14839
14847
|
((_a = event.parameters.tags) == null ? void 0 : _a.length) > 0 ? `**Tags**: ${event.parameters.tags.join(", ")}` : null,
|
|
14840
14848
|
(() => {
|
|
14841
|
-
var _a2, _b2, _c2, _d2,
|
|
14849
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
14842
14850
|
const val = (_c2 = (_b2 = (_a2 = event.geocode) == null ? void 0 : _a2.office) == null ? void 0 : _b2.name) != null ? _c2 : `N/A`;
|
|
14843
|
-
const th = (
|
|
14844
|
-
return val
|
|
14851
|
+
const th = (_f2 = (_e2 = (_d2 = event.geocode) == null ? void 0 : _d2.office) == null ? void 0 : _e2.office) != null ? _f2 : null;
|
|
14852
|
+
return (val != null ? val : th) ? `**Sender**: ${val} ${th ? `(${th})` : ""}` : null;
|
|
14845
14853
|
})(),
|
|
14846
14854
|
((_b = event.metadata) == null ? void 0 : _b.tracking) ? `**Tracking**: ${event.metadata.tracking}` : null,
|
|
14855
|
+
((_c = event.metadata.history) == null ? void 0 : _c.length) > 0 ? `**Logs**: ${event.metadata.history.length}` : null,
|
|
14847
14856
|
(() => {
|
|
14848
|
-
|
|
14857
|
+
var _a2;
|
|
14858
|
+
if (event.status == `Expired`) {
|
|
14859
|
+
return null;
|
|
14860
|
+
}
|
|
14861
|
+
const desc = ((_a2 = event.description) != null ? _a2 : "").split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
|
|
14849
14862
|
return desc ? "```\n" + desc + "\n```" : null;
|
|
14850
14863
|
})()
|
|
14851
14864
|
].filter(Boolean).join("\n");
|
|
@@ -14855,7 +14868,7 @@ var createWebhook = (options) => __async(null, null, function* () {
|
|
|
14855
14868
|
}
|
|
14856
14869
|
if (body.length > 1900) {
|
|
14857
14870
|
body = body.substring(0, 1900) + "\n\n[Message truncated due to length]";
|
|
14858
|
-
const blocks = (body.match(/```/g)
|
|
14871
|
+
const blocks = ((_d = body.match(/```/g)) != null ? _d : []).length;
|
|
14859
14872
|
if (blocks % 2 !== 0) body += "```";
|
|
14860
14873
|
}
|
|
14861
14874
|
const form = new import_form_data.default();
|
|
@@ -14867,8 +14880,8 @@ var createWebhook = (options) => __async(null, null, function* () {
|
|
|
14867
14880
|
footer: { text: settings.title }
|
|
14868
14881
|
};
|
|
14869
14882
|
form.append("payload_json", JSON.stringify({
|
|
14870
|
-
username: (
|
|
14871
|
-
content: (
|
|
14883
|
+
username: (_e = settings.title) != null ? _e : "AtmosphericX",
|
|
14884
|
+
content: (_f = settings.message) != null ? _f : "",
|
|
14872
14885
|
embeds: [embed]
|
|
14873
14886
|
}));
|
|
14874
14887
|
if (settings.upload) {
|
|
@@ -15080,22 +15093,16 @@ var updateNode = (selectedEvent) => __async(null, null, function* () {
|
|
|
15080
15093
|
|
|
15081
15094
|
// src/@manager/manager.mkEvent.ts
|
|
15082
15095
|
var mkEvent = (event) => __async(null, null, function* () {
|
|
15083
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w
|
|
15096
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
15084
15097
|
const settings = bootstrap.settings;
|
|
15085
15098
|
const features = bootstrap.cache.events.features;
|
|
15086
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
15087
|
-
for (const f of features) {
|
|
15088
|
-
const key = (_b = (_a = f == null ? void 0 : f.properties) == null ? void 0 : _a.metadata) == null ? void 0 : _b.tracking;
|
|
15089
|
-
if (!key) continue;
|
|
15090
|
-
map2.set(key, f);
|
|
15091
|
-
}
|
|
15092
15099
|
const getHash = event.properties.metadata.hash;
|
|
15093
15100
|
const getTracking = event.properties.metadata.tracking;
|
|
15094
|
-
const isEntry = (
|
|
15095
|
-
const isHashed = (
|
|
15096
|
-
const getFeature =
|
|
15101
|
+
const isEntry = (_a = bootstrap.cache.hashes) == null ? void 0 : _a.find((hash) => hash.tracking === getTracking);
|
|
15102
|
+
const isHashed = (_c = (_b = isEntry == null ? void 0 : isEntry.hashes) == null ? void 0 : _b.includes(getHash)) != null ? _c : false;
|
|
15103
|
+
const getFeature = features.find((feature) => feature.properties.metadata.tracking === getTracking);
|
|
15097
15104
|
if (isHashed || event.properties.status_metadata.is_expired) return;
|
|
15098
|
-
|
|
15105
|
+
setHash(event, isEntry);
|
|
15099
15106
|
const isFilteredLocation = yield updateNode(event).then(() => event.properties.metadata.filtered_proximity);
|
|
15100
15107
|
if (!isFilteredLocation && settings.GlobalSettings.EventFiltering.NodeLocationFiltering) {
|
|
15101
15108
|
return;
|
|
@@ -15112,22 +15119,22 @@ var mkEvent = (event) => __async(null, null, function* () {
|
|
|
15112
15119
|
if (event.properties.status_metadata.is_issued || event.properties.status_metadata.is_updated) {
|
|
15113
15120
|
if (getFeature) {
|
|
15114
15121
|
const getIndex = features.indexOf(getFeature);
|
|
15115
|
-
const cHistory = (
|
|
15116
|
-
const cLocations = (
|
|
15117
|
-
const cUgc = (
|
|
15118
|
-
const iHistory = (
|
|
15119
|
-
const iLocations = (
|
|
15120
|
-
const iUgc = (
|
|
15121
|
-
const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i);
|
|
15122
|
+
const cHistory = (_f = (_e = (_d = getFeature == null ? void 0 : getFeature.properties) == null ? void 0 : _d.metadata) == null ? void 0 : _e.history) != null ? _f : [];
|
|
15123
|
+
const cLocations = (_i = (_h = (_g = getFeature == null ? void 0 : getFeature.properties) == null ? void 0 : _g.locations) == null ? void 0 : _h.split(";").map((l) => l.trim())) != null ? _i : [];
|
|
15124
|
+
const cUgc = (_l = (_k = (_j = getFeature == null ? void 0 : getFeature.properties) == null ? void 0 : _j.geocode) == null ? void 0 : _k.ugc) != null ? _l : [];
|
|
15125
|
+
const iHistory = (_o = (_n = (_m = event.properties) == null ? void 0 : _m.metadata) == null ? void 0 : _n.history) != null ? _o : [];
|
|
15126
|
+
const iLocations = (_r = (_q = (_p = event.properties) == null ? void 0 : _p.locations) == null ? void 0 : _q.split(";").map((l) => l.trim())) != null ? _r : [];
|
|
15127
|
+
const iUgc = (_u = (_t = (_s = event.properties) == null ? void 0 : _s.geocode) == null ? void 0 : _t.ugc) != null ? _u : [];
|
|
15128
|
+
const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i).filter((v, i, a) => a.findIndex((h) => h.description === v.description && h.issued === v.issued) === i);
|
|
15122
15129
|
const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join("; ");
|
|
15123
15130
|
const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
|
|
15124
15131
|
bootstrap.cache.events.features[getIndex] = __spreadProps(__spreadValues({}, event), {
|
|
15125
15132
|
properties: __spreadProps(__spreadValues({}, event.properties), {
|
|
15126
|
-
metadata: __spreadProps(__spreadValues({}, (
|
|
15133
|
+
metadata: __spreadProps(__spreadValues({}, (_v = event == null ? void 0 : event.properties) == null ? void 0 : _v.metadata), {
|
|
15127
15134
|
history: mHistory
|
|
15128
15135
|
}),
|
|
15129
15136
|
locations: mLocations,
|
|
15130
|
-
geocode: __spreadProps(__spreadValues({}, (
|
|
15137
|
+
geocode: __spreadProps(__spreadValues({}, (_w = event == null ? void 0 : event.properties) == null ? void 0 : _w.geocode), {
|
|
15131
15138
|
ugc: mUgc
|
|
15132
15139
|
})
|
|
15133
15140
|
})
|
|
@@ -15200,7 +15207,7 @@ var validateEvents = (events) => __async(null, null, function* () {
|
|
|
15200
15207
|
delete filteredProperties.metadata.ms;
|
|
15201
15208
|
}
|
|
15202
15209
|
filteredProperties.metadata = (_a2 = filteredProperties.metadata) != null ? _a2 : {};
|
|
15203
|
-
|
|
15210
|
+
properties2.metadata.hash = (0, import_crypto.createHash)("sha256").update(JSON.stringify(filteredProperties)).digest("hex");
|
|
15204
15211
|
setEventEmit({ event: `onProductType${enhancedEventName.replace(/\s+/g, "")}`, metadata: define2 });
|
|
15205
15212
|
if (properties2.status_metadata.is_test) {
|
|
15206
15213
|
setEventEmit({ event: `onTestProduct`, metadata: define2 });
|
|
@@ -15587,7 +15594,7 @@ var pvExtract = (message) => {
|
|
|
15587
15594
|
vtecs.push({
|
|
15588
15595
|
vtec: vtec2,
|
|
15589
15596
|
product: eventProducts[sub[0]],
|
|
15590
|
-
tracking: `${sub[2]}
|
|
15597
|
+
tracking: `${sub[2]}.${sub[3]}.${sub[4]}.${sub[5]}`,
|
|
15591
15598
|
event: `${eventTypes[sub[3]]} ${eventActions[sub[4]]}`,
|
|
15592
15599
|
status: eventStatus[sub[1]],
|
|
15593
15600
|
organization: (_d = (_c = message.match(regExp.wmo)) == null ? void 0 : _c[0]) != null ? _d : null,
|
|
@@ -16050,7 +16057,7 @@ var xReconnect = (interval) => __async(null, null, function* () {
|
|
|
16050
16057
|
const settings = bootstrap.settings;
|
|
16051
16058
|
const lastStanza = Date.now() - bootstrap.cache.lastStanza;
|
|
16052
16059
|
if (interval < 15) {
|
|
16053
|
-
setWarning({ message: `Reconnection
|
|
16060
|
+
setWarning({ message: `Reconnection interval of ${interval} seconds is too low, setting to 15 seconds` });
|
|
16054
16061
|
interval = 15;
|
|
16055
16062
|
bootstrap.settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval = 15;
|
|
16056
16063
|
}
|
|
@@ -16167,7 +16174,7 @@ var startService = (configurations) => __async(null, null, function* () {
|
|
|
16167
16174
|
yield setCronSchedule();
|
|
16168
16175
|
let scheduleInterval = !settings.EnableWireService ? settings.NationalWeatherServiceSettings.CallbackInterval : 1;
|
|
16169
16176
|
if (!settings.EnableWireService && scheduleInterval < 15) {
|
|
16170
|
-
setWarning({ message: `Schedule
|
|
16177
|
+
setWarning({ message: `Schedule interval of ${scheduleInterval} seconds is too low, setting to 15 seconds` });
|
|
16171
16178
|
bootstrap.settings.NationalWeatherServiceSettings.CallbackInterval = 15;
|
|
16172
16179
|
scheduleInterval = 15;
|
|
16173
16180
|
}
|
|
@@ -16652,6 +16659,16 @@ var getRandomEvent = () => {
|
|
|
16652
16659
|
return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)];
|
|
16653
16660
|
};
|
|
16654
16661
|
|
|
16662
|
+
// src/@core/core.query.ts
|
|
16663
|
+
var query = (options) => __async(null, null, function* () {
|
|
16664
|
+
var _a;
|
|
16665
|
+
const get = yield bootstrap.database.prepare(
|
|
16666
|
+
`SELECT * FROM stanzas WHERE stanza LIKE ? LIMIT ?`
|
|
16667
|
+
).all(`%${options.search}%`, (_a = options.max) != null ? _a : 100);
|
|
16668
|
+
const events = get.map((row) => JSON.parse(row.stanza));
|
|
16669
|
+
return events;
|
|
16670
|
+
});
|
|
16671
|
+
|
|
16655
16672
|
// src/@core/core.clearEvents.ts
|
|
16656
16673
|
var clearEvents = () => {
|
|
16657
16674
|
bootstrap.cache.events.features = [];
|
|
@@ -16674,7 +16691,7 @@ var Manager = class {
|
|
|
16674
16691
|
}
|
|
16675
16692
|
trycatch() {
|
|
16676
16693
|
process.on("uncaughtException", (err) => {
|
|
16677
|
-
var _a;
|
|
16694
|
+
var _a, _b;
|
|
16678
16695
|
const ignored = ["ETIMEDOUT", "ECONNRESET", "EHOSTUNREACH", "ENOTFOUND", "ECONNREFUSED", "EPIPE", "EADDRINUSE", "EALREADY", "EACCES", "EAGAIN", "EHOSTDOWN", "STARTTLS_FAILURE"];
|
|
16679
16696
|
if (ignored.includes(err == null ? void 0 : err.code)) {
|
|
16680
16697
|
setEventEmit({
|
|
@@ -16688,7 +16705,7 @@ var Manager = class {
|
|
|
16688
16705
|
});
|
|
16689
16706
|
return;
|
|
16690
16707
|
}
|
|
16691
|
-
setWarning({ message: `Uncaught Exception: ${err instanceof Error ? err.stack
|
|
16708
|
+
setWarning({ message: `Uncaught Exception: ${err instanceof Error ? (_b = err.stack) != null ? _b : err.message : String(err)}` });
|
|
16692
16709
|
});
|
|
16693
16710
|
}
|
|
16694
16711
|
};
|
|
@@ -16702,6 +16719,7 @@ var index_default = Manager;
|
|
|
16702
16719
|
getEvents,
|
|
16703
16720
|
getNodes,
|
|
16704
16721
|
getRandomEvent,
|
|
16722
|
+
query,
|
|
16705
16723
|
setEasTone,
|
|
16706
16724
|
setNode,
|
|
16707
16725
|
setSettings,
|