@atmosx/event-product-parser 3.0.1 → 3.0.3

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.
@@ -10491,7 +10491,7 @@ var require_form_data = __commonJS({
10491
10491
  import path from "path";
10492
10492
  import { EventEmitter } from "events";
10493
10493
  var bootstrap = {
10494
- version: `3.0.1`,
10494
+ version: `3.0.3`,
10495
10495
  isReady: true,
10496
10496
  ratelimits: {},
10497
10497
  session_xmpp: null,
@@ -10773,8 +10773,8 @@ var setListener = (options) => {
10773
10773
  };
10774
10774
  };
10775
10775
 
10776
- // src/@core/core.listener.ts
10777
- var listener = (event, callback) => {
10776
+ // src/@core/core.createListener.ts
10777
+ var createListener = (event, callback) => {
10778
10778
  setListener({ event, callback });
10779
10779
  };
10780
10780
 
@@ -10884,14 +10884,14 @@ function Deferred() {
10884
10884
  function procedure(entity, stanza = null, handler) {
10885
10885
  return new Promise((resolve6, reject) => {
10886
10886
  function onError(err) {
10887
- entity.removeListener("nonza", listener3);
10887
+ entity.removeListener("nonza", listener2);
10888
10888
  reject(err);
10889
10889
  }
10890
10890
  function done(...args) {
10891
- entity.removeListener("nonza", listener3);
10891
+ entity.removeListener("nonza", listener2);
10892
10892
  resolve6(...args);
10893
10893
  }
10894
- function listener3(element) {
10894
+ function listener2(element) {
10895
10895
  return __async(this, null, function* () {
10896
10896
  try {
10897
10897
  yield handler(element, done);
@@ -10901,7 +10901,7 @@ function procedure(entity, stanza = null, handler) {
10901
10901
  });
10902
10902
  }
10903
10903
  stanza && entity.send(stanza).catch(onError);
10904
- entity.on("nonza", listener3);
10904
+ entity.on("nonza", listener2);
10905
10905
  });
10906
10906
  }
10907
10907
 
@@ -12045,7 +12045,7 @@ var OutgoingContext = class extends Context {
12045
12045
  };
12046
12046
 
12047
12047
  // node_modules/@xmpp/middleware/index.js
12048
- function listener2(entity, middleware2, Context2) {
12048
+ function listener(entity, middleware2, Context2) {
12049
12049
  return (stanza) => {
12050
12050
  const ctx = new Context2(entity, stanza);
12051
12051
  return (0, import_koa_compose.default)(middleware2)(ctx);
@@ -12059,8 +12059,8 @@ function errorHandler(entity) {
12059
12059
  function middleware({ entity }) {
12060
12060
  const incoming = [errorHandler(entity)];
12061
12061
  const outgoing = [];
12062
- const incomingListener = listener2(entity, incoming, IncomingContext);
12063
- const outgoingListener = listener2(entity, outgoing, OutgoingContext);
12062
+ const incomingListener = listener(entity, incoming, IncomingContext);
12063
+ const outgoingListener = listener(entity, outgoing, OutgoingContext);
12064
12064
  entity.on("element", incomingListener);
12065
12065
  entity.on("send", outgoingListener);
12066
12066
  return {
@@ -14370,7 +14370,16 @@ var eventTags = {
14370
14370
  "SLOW DOWN AND ALLOW EXTRA TIME": "Slow Down and Allow Extra Time",
14371
14371
  "SHOULD EXERCISE CAUTION": "Should Exercise Caution",
14372
14372
  "LAKE EFFECT SNOW EXPECTED": "Lake Effect Snow Expected",
14373
- "MODERATE LAKE EFFECT SNOWFALL RATES AND BLOWING SNOW": "Moderate Lake Effect Snowfall and Blowing Snow"
14373
+ "MODERATE LAKE EFFECT SNOWFALL RATES AND BLOWING SNOW": "Moderate Lake Effect Snowfall and Blowing Snow",
14374
+ "NO TSUNAMI THREAT": "No Active Tsunami Threat",
14375
+ "NO SIGNIFICANT TSUNAMI THREAT": "No Significant Tsunami Threat",
14376
+ "NO TSUNAMI IMPACTS ARE EXPECTED": "No Tsunami Impacts Expected",
14377
+ "A TSUNAMI THREAT EXISTS": "Tsunami Threat Exists",
14378
+ "TSUNAMI THREAT": "Active Tsunami Threat",
14379
+ "HEAT ILLNESSES": "Can cause heat illness",
14380
+ "WATCH POSSIBLE": "Watch Possible",
14381
+ "INTENSIFYING": "Intensifying",
14382
+ "CAPABLE OF PRODUCING A LANDSPOUT": "Landspout Possible"
14374
14383
  };
14375
14384
 
14376
14385
  // src/@building/building.tags.ts
@@ -14440,8 +14449,8 @@ var getEventHeader = (options) => {
14440
14449
  return `ZCZC-ATMOSX-${options.getType.prefix}-${ugc2}-${(_b = vtec2 == null ? void 0 : vtec2.status) != null ? _b : `Issued`}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").split(".")[0]}-${(_c = properties2.geocode.office.office) != null ? _c : `KWNS`}`;
14441
14450
  };
14442
14451
 
14443
- // src/@dictionaries/dictionaries.eventsOffshore.ts
14444
- var eventsOffshore = {
14452
+ // src/@dictionaries/dictionaries.eventsMatchText.ts
14453
+ var eventsMatchText = {
14445
14454
  "Special Weather Statement": "Special Weather Statement",
14446
14455
  "Hurricane Warning": "Hurricane Warning",
14447
14456
  "Hurricane Force Wind Warning": "Hurricane Force Wind Warning",
@@ -14451,7 +14460,12 @@ var eventsOffshore = {
14451
14460
  "High Wind Warning": "High Wind Warning",
14452
14461
  "Gale Warning": "Gale Warning",
14453
14462
  "Small Craft Advisory": "Small Craft Advisory",
14454
- "Small Craft Warning": "Small Craft Warning"
14463
+ "Small Craft Warning": "Small Craft Warning",
14464
+ "Tsunami Warning": "Tsunami Warning",
14465
+ "Tsunami Watch": "Tsunami Watch",
14466
+ "Tsunami Advisory": "Tsunami Advisory",
14467
+ "Tsunami Information Statement": "Tsunami Information Statement",
14468
+ "Subscribers:": "National Weather Service Policy"
14455
14469
  };
14456
14470
 
14457
14471
  // src/@building/building.tracking.ts
@@ -14510,6 +14524,16 @@ var betterEventNames = {
14510
14524
  },
14511
14525
  "Radar Indicated Tornado Warning": {}
14512
14526
  },
14527
+ "Blizzard Warning": {
14528
+ "PDS Blizzard Warning": {
14529
+ description: "particularly dangerous situation"
14530
+ }
14531
+ },
14532
+ "Ice Storm Warning": {
14533
+ "PDS Ice Storm Warning": {
14534
+ description: "particularly dangerous situation"
14535
+ }
14536
+ },
14513
14537
  "Special Marine Warning": {
14514
14538
  "Special Marine Warning (TPROB)": {
14515
14539
  tornado: `POSSIBLE`
@@ -14591,17 +14615,18 @@ var getEventEnhancedName = (event) => {
14591
14615
 
14592
14616
  // src/@dictionaries/dictionaries.statusCorrelationText.ts
14593
14617
  var statusCorrelationText = [
14594
- { type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false },
14595
- { type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false },
14596
- { type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true },
14597
- { type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false },
14598
- { type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false },
14599
- { type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true },
14600
- { type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false },
14601
- { type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false },
14602
- { type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false },
14603
- { type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false },
14604
- { type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false }
14618
+ { type: "Statement", name: "Statement", isCancel: false, isUpdate: false, isIssued: true, isStatement: true },
14619
+ { type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
14620
+ { type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
14621
+ { type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false },
14622
+ { type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
14623
+ { type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
14624
+ { type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false },
14625
+ { type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
14626
+ { type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
14627
+ { type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
14628
+ { type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
14629
+ { type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false, isStatement: false }
14605
14630
  ];
14606
14631
 
14607
14632
  // src/@dictionaries/dictionaries.eventCancelMessages.ts
@@ -14661,7 +14686,7 @@ var getEventSignature = (event) => {
14661
14686
  }
14662
14687
  if (status) {
14663
14688
  properties2.status = (_d = status.name) != null ? _d : properties2.status;
14664
- properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel });
14689
+ properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel, is_statement: !!status.isStatement });
14665
14690
  }
14666
14691
  if (csig) {
14667
14692
  properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_expired: true });
@@ -14756,13 +14781,13 @@ var createHttp = (options) => __async(null, null, function* () {
14756
14781
  // src/@modules/@utilities/utilities.createWebhook.ts
14757
14782
  var import_form_data = __toESM(require_form_data());
14758
14783
  var createWebhook = (options) => __async(null, null, function* () {
14759
- var _a, _b, _c, _d, _e, _f, _g, _h;
14784
+ var _a, _b, _c, _d;
14760
14785
  const event = options.event.properties;
14761
14786
  const settings = options.webhook;
14762
14787
  let body = [
14763
14788
  event.locations ? `**Locations**: ${event.locations.slice(0, 100)}` : null,
14764
14789
  event.issued ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime() / 1e3)}:R>` : null,
14765
- event.expires ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime() / 1e3)}:R>` : null,
14790
+ event.expires && event.status != `Statement` ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime() / 1e3)}:R>` : null,
14766
14791
  (() => {
14767
14792
  var _a2, _b2;
14768
14793
  const val = (_a2 = event.parameters.estimated_wind_gusts) != null ? _a2 : null;
@@ -14779,16 +14804,28 @@ var createWebhook = (options) => __async(null, null, function* () {
14779
14804
  event.parameters.damage_threat ? `**Damage Threat**: ${event.parameters.damage_threat}` : null,
14780
14805
  event.parameters.flood_threat ? `**Flood Threat**: ${event.parameters.flood_threat}` : null,
14781
14806
  event.parameters.tornado_threat ? `**Tornado Threat**: ${event.parameters.tornado_threat}` : null,
14807
+ event.spc_parameters.spc_max_tornado ? `**Max Tornado Threat**: ${event.spc_parameters.spc_max_tornado}` : null,
14808
+ event.spc_parameters.spc_max_hail ? `**Max Hail Threat**: ${event.spc_parameters.spc_max_hail}` : null,
14809
+ event.spc_parameters.spc_max_wind ? `**Max Wind Threat**: ${event.spc_parameters.spc_max_wind}` : null,
14810
+ event.spc_parameters.spc_watch_issuance ? `**Watch Issuance**: ${event.spc_parameters.spc_watch_issuance}%` : null,
14811
+ event.watch_parameters.watch_number ? `**Watch Number**: ${event.watch_parameters.watch_number}` : null,
14812
+ event.watch_parameters.strong_tornadoes_probability ? `**Strong Tornadoes Probability**: ${event.watch_parameters.strong_tornadoes_probability}%` : null,
14813
+ event.watch_parameters.additional_tornadoes_probability ? `**Additional Tornadoes Probability**: ${event.watch_parameters.additional_tornadoes_probability}%` : null,
14814
+ event.watch_parameters.combined_hail_wind_probability ? `**Combined Hail/Wind Probability**: ${event.watch_parameters.combined_hail_wind_probability}%` : null,
14815
+ event.watch_parameters.severe_hail_probability ? `**Severe Hail Probability**: ${event.watch_parameters.severe_hail_probability}%` : null,
14816
+ event.watch_parameters.hail_2in_probability ? `**Hail \u22652in Probability**: ${event.watch_parameters.hail_2in_probability}%` : null,
14817
+ event.watch_parameters.max_hail_in ? `**Max Hail Inches**: ${event.watch_parameters.max_hail_in}` : null,
14818
+ event.watch_parameters.severe_wind_probability ? `**Severe Wind Probability**: ${event.watch_parameters.severe_wind_probability}%` : null,
14819
+ event.watch_parameters.max_wind_surface ? `**Max Surface Wind**: ${event.watch_parameters.max_wind_surface}` : null,
14820
+ event.watch_parameters.max_tops_x100feet ? `**Max Tops (x100 feet)**: ${event.watch_parameters.max_tops_x100feet}` : null,
14782
14821
  ((_a = event.parameters.tags) == null ? void 0 : _a.length) > 0 ? `**Tags**: ${event.parameters.tags.join(", ")}` : null,
14783
14822
  (() => {
14784
- var _a2, _b2, _c2, _d2, _e2, _f2;
14823
+ var _a2, _b2, _c2, _d2, _e, _f;
14785
14824
  const val = (_c2 = (_b2 = (_a2 = event.geocode) == null ? void 0 : _a2.office) == null ? void 0 : _b2.name) != null ? _c2 : `N/A`;
14786
- const th = (_f2 = (_e2 = (_d2 = event.geocode) == null ? void 0 : _d2.office) == null ? void 0 : _e2.office) != null ? _f2 : null;
14825
+ const th = (_f = (_e = (_d2 = event.geocode) == null ? void 0 : _d2.office) == null ? void 0 : _e.office) != null ? _f : null;
14787
14826
  return val || th ? `**Sender**: ${val} ${th ? `(${th})` : ""}` : null;
14788
14827
  })(),
14789
14828
  ((_b = event.metadata) == null ? void 0 : _b.tracking) ? `**Tracking**: ${event.metadata.tracking}` : null,
14790
- ((_d = (_c = event.metadata) == null ? void 0 : _c.vtec) == null ? void 0 : _d.vtec) ? `**VTEC**: ${(_e = event.metadata.vtec) == null ? void 0 : _e.vtec}` : null,
14791
- ((_f = event.metadata) == null ? void 0 : _f.filtered_proximity) != null ? `**Currently in polygon (Node)**: ${event.metadata.filtered_proximity ? "Yes" : "No"}` : null,
14792
14829
  (() => {
14793
14830
  const desc = (event.description || "").split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
14794
14831
  return desc ? "```\n" + desc + "\n```" : null;
@@ -14812,14 +14849,16 @@ var createWebhook = (options) => __async(null, null, function* () {
14812
14849
  footer: { text: settings.title }
14813
14850
  };
14814
14851
  form.append("payload_json", JSON.stringify({
14815
- username: (_g = settings.title) != null ? _g : "AtmosphericX",
14816
- content: (_h = settings.message) != null ? _h : "",
14852
+ username: (_c = settings.title) != null ? _c : "AtmosphericX",
14853
+ content: (_d = settings.message) != null ? _d : "",
14817
14854
  embeds: [embed]
14818
14855
  }));
14819
- form.append("file", Buffer.from(JSON.stringify({ type: "FeatureCollection", features: [getCleanedEvent(options.event)] }, null, 2)), {
14820
- filename: `${event.event}_${event.status}_${event.metadata.tracking}.json`,
14821
- contentType: "application/json"
14822
- });
14856
+ if (settings.upload) {
14857
+ form.append("file", Buffer.from(JSON.stringify(getCleanedEvent(event), null, 2)), {
14858
+ filename: `${event.event}_${event.status}_${event.metadata.tracking}.json`,
14859
+ contentType: "application/json"
14860
+ });
14861
+ }
14823
14862
  yield createHttp({
14824
14863
  url: settings.webhook,
14825
14864
  timeout: 2e3,
@@ -15089,6 +15128,9 @@ var rmEvent = (event) => {
15089
15128
  var _a, _b, _c, _d;
15090
15129
  return ((_b = (_a = f == null ? void 0 : f.properties) == null ? void 0 : _a.metadata) == null ? void 0 : _b.tracking) === ((_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.metadata) == null ? void 0 : _d.tracking);
15091
15130
  });
15131
+ const cachedStatus = event.properties.status;
15132
+ event.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
15133
+ event.properties.status = `Expired`;
15092
15134
  if (getEvent) {
15093
15135
  setEventEmit({
15094
15136
  event: `onEventStatus`,
@@ -15099,7 +15141,7 @@ var rmEvent = (event) => {
15099
15141
  message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
15100
15142
  });
15101
15143
  setEventEmit({ event: `onExpiredProduct`, metadata: event });
15102
- updateWebhooks(event);
15144
+ if (cachedStatus != `Statement`) updateWebhooks(event);
15103
15145
  bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
15104
15146
  bootstrap.cache.hashes = bootstrap.cache.hashes.filter((hash) => hash.tracking !== event.properties.metadata.tracking);
15105
15147
  }
@@ -15238,9 +15280,11 @@ var text = (stanza) => __async(null, null, function* () {
15238
15280
  const header = getEventHeader({ properties: props, getType: stanza.getType });
15239
15281
  const issued = new Date(attributes.issue);
15240
15282
  const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1e3);
15241
- let event = Object.keys(eventsOffshore).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
15283
+ let event = Object.keys(eventsMatchText).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
15284
+ let isStatement = false;
15242
15285
  if (!event) {
15243
15286
  event = stanza.getType.type.split(`-`).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `);
15287
+ isStatement = true;
15244
15288
  }
15245
15289
  processed.push({
15246
15290
  type: `Feature`,
@@ -15251,9 +15295,9 @@ var text = (stanza) => __async(null, null, function* () {
15251
15295
  properties: __spreadProps(__spreadValues({
15252
15296
  event,
15253
15297
  parent: event,
15254
- status: `Issued`,
15298
+ status: isStatement ? `Statement` : `Issued`,
15255
15299
  issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
15256
- expires: !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
15300
+ expires: isStatement ? new Date(issued.getTime() + 120 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
15257
15301
  }, props), {
15258
15302
  metadata: {
15259
15303
  ms: performance.now() - tick,
@@ -15370,11 +15414,13 @@ var ugc = (stanza) => __async(null, null, function* () {
15370
15414
  if (ugc2 != null) {
15371
15415
  const props = properties({ message, attributes, ugc: ugc2 });
15372
15416
  const issued = new Date(attributes.issue);
15373
- const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1e3);
15417
+ const expires = new Date(ugc2.expires);
15374
15418
  const header = getEventHeader({ properties: props, getType: stanza.getType });
15375
- let event = Object.keys(eventsOffshore).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
15419
+ let event = Object.keys(eventsMatchText).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
15420
+ let isStatement = false;
15376
15421
  if (!event) {
15377
15422
  event = stanza.getType.type.split(`-`).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `);
15423
+ isStatement = true;
15378
15424
  }
15379
15425
  processed.push({
15380
15426
  type: `Feature`,
@@ -15385,9 +15431,9 @@ var ugc = (stanza) => __async(null, null, function* () {
15385
15431
  properties: __spreadProps(__spreadValues({
15386
15432
  event,
15387
15433
  parent: event,
15388
- status: `Issued`,
15434
+ status: isStatement ? `Statement` : `Issued`,
15389
15435
  issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
15390
- expires: !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
15436
+ expires: isStatement ? new Date(issued.getTime() + 120 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
15391
15437
  }, props), {
15392
15438
  metadata: {
15393
15439
  ms: performance.now() - tick,
@@ -16062,6 +16108,26 @@ var setCronSchedule = () => __async(null, null, function* () {
16062
16108
  }
16063
16109
  });
16064
16110
 
16111
+ // src/@manager/manager.updateEvents.ts
16112
+ var updateEvents = (selectedEvent) => __async(null, null, function* () {
16113
+ const events = bootstrap.cache.events.features;
16114
+ function update(evt) {
16115
+ return __async(this, null, function* () {
16116
+ if (new Date(evt.properties.expires) < /* @__PURE__ */ new Date()) {
16117
+ rmEvent(evt);
16118
+ }
16119
+ });
16120
+ }
16121
+ if (!selectedEvent) {
16122
+ yield Promise.all(events.map((evt) => __async(null, null, function* () {
16123
+ yield update(evt);
16124
+ })));
16125
+ }
16126
+ if (selectedEvent) {
16127
+ yield update(selectedEvent);
16128
+ }
16129
+ });
16130
+
16065
16131
  // src/@core/core.start.ts
16066
16132
  import { Cron } from "croner";
16067
16133
  var startService = (settings) => __async(null, null, function* () {
@@ -16089,8 +16155,9 @@ var startService = (settings) => __async(null, null, function* () {
16089
16155
  bootstrap.cron = new Cron(`*/${scheduleInterval} * * * * *`, () => __async(null, null, function* () {
16090
16156
  yield setCronSchedule();
16091
16157
  }));
16092
- bootstrap.cron = new Cron(`*/1 * * * * *`, () => __async(null, null, function* () {
16158
+ bootstrap.cron = new Cron(`* * * * * *`, () => __async(null, null, function* () {
16093
16159
  yield updateNode();
16160
+ yield updateEvents();
16094
16161
  }));
16095
16162
  });
16096
16163
 
@@ -16566,6 +16633,17 @@ var getRandomEvent = () => {
16566
16633
  return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)];
16567
16634
  };
16568
16635
 
16636
+ // src/@core/core.clearEvents.ts
16637
+ var clearEvents = () => {
16638
+ bootstrap.cache.events.features = [];
16639
+ bootstrap.cache.hashes = [];
16640
+ setEventEmit({
16641
+ event: `onEventCache`,
16642
+ metadata: bootstrap.cache.events,
16643
+ message: `Manually cleared event cache.`
16644
+ });
16645
+ };
16646
+
16569
16647
  // src/index.ts
16570
16648
  var Manager = class {
16571
16649
  constructor(settings) {
@@ -16573,7 +16651,7 @@ var Manager = class {
16573
16651
  startService(settings);
16574
16652
  }
16575
16653
  on(event, callback) {
16576
- listener(event, callback);
16654
+ createListener(event, callback);
16577
16655
  }
16578
16656
  trycatch() {
16579
16657
  process.on("uncaughtException", (err) => {
@@ -16598,6 +16676,7 @@ var Manager = class {
16598
16676
  var index_default = Manager;
16599
16677
  export {
16600
16678
  Manager,
16679
+ clearEvents,
16601
16680
  index_default as default,
16602
16681
  getCleanedEvent,
16603
16682
  getEventGeometry,
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ type TypeWebhook = {
2
2
  webhook: string;
3
3
  title: string;
4
4
  message: string;
5
+ upload: boolean;
5
6
  rate: number;
6
7
  events: string[];
7
8
  };
@@ -164,6 +165,7 @@ type TypeEvent = {
164
165
  is_updated?: boolean;
165
166
  is_expired?: boolean;
166
167
  is_test?: boolean;
168
+ is_statement?: boolean;
167
169
  };
168
170
  metadata: {
169
171
  ms: number;
@@ -226,10 +228,12 @@ declare const getNodes: () => any;
226
228
 
227
229
  declare const getRandomEvent: () => any;
228
230
 
231
+ declare const clearEvents: () => void;
232
+
229
233
  declare class Manager {
230
234
  constructor(settings: TypeSettings);
231
235
  on(event: string, callback: () => void): void;
232
236
  trycatch(): void;
233
237
  }
234
238
 
235
- export { Manager, type TypeEvent, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
239
+ export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ type TypeWebhook = {
2
2
  webhook: string;
3
3
  title: string;
4
4
  message: string;
5
+ upload: boolean;
5
6
  rate: number;
6
7
  events: string[];
7
8
  };
@@ -164,6 +165,7 @@ type TypeEvent = {
164
165
  is_updated?: boolean;
165
166
  is_expired?: boolean;
166
167
  is_test?: boolean;
168
+ is_statement?: boolean;
167
169
  };
168
170
  metadata: {
169
171
  ms: number;
@@ -226,10 +228,12 @@ declare const getNodes: () => any;
226
228
 
227
229
  declare const getRandomEvent: () => any;
228
230
 
231
+ declare const clearEvents: () => void;
232
+
229
233
  declare class Manager {
230
234
  constructor(settings: TypeSettings);
231
235
  on(event: string, callback: () => void): void;
232
236
  trycatch(): void;
233
237
  }
234
238
 
235
- export { Manager, type TypeEvent, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
239
+ export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmosx/event-product-parser",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "NOAA Weather Wire & NWS API Parser - Built for standalone and Project AtmosphericX Integration.",
5
5
  "main": "dist/cjs/index.cjs",
6
6
  "module": "dist/esm/index.mjs",
@@ -39,11 +39,12 @@ export const getEventSignature = (event: TypeEvent): TypeEvent => {
39
39
 
40
40
  if (status) {
41
41
  properties.status = status.name ?? properties.status;
42
- properties.status_metadata = { ...properties.status_metadata, is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel };
42
+ properties.status_metadata = { ...properties.status_metadata, is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel, is_statement: !!status.isStatement };
43
43
  }
44
44
  if (csig) {
45
45
  properties.status_metadata = { ...properties.status_metadata, is_expired: true };
46
46
  }
47
+
47
48
  const getProduct = vtec?.vtec?.split(`.`)[0]?.replace(`/`, ``)
48
49
  const isTestProduct = eventProducts[getProduct] == `Test Product`
49
50
  if (isTestProduct || testSignatures.some(sig => properties.description?.toLowerCase().includes(sig.toLowerCase()) || properties?.parameters?.instructions?.toLowerCase().includes(sig.toLowerCase()))) {
@@ -0,0 +1,32 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { bootstrap } from "../bootstrap";
21
+ import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
22
+
23
+
24
+ export const clearEvents = (): void => {
25
+ bootstrap.cache.events.features = [];
26
+ bootstrap.cache.hashes = [];
27
+ setEventEmit({
28
+ event: `onEventCache`,
29
+ metadata: bootstrap.cache.events,
30
+ message: `Manually cleared event cache.`
31
+ })
32
+ }
@@ -19,6 +19,6 @@
19
19
 
20
20
  import { setListener } from "../@modules/@utilities/utilities.setListener";
21
21
 
22
- export const listener = (event: string, callback: () => void) => {
22
+ export const createListener = (event: string, callback: () => void) => {
23
23
  setListener({event, callback})
24
24
  }
@@ -25,8 +25,9 @@ import { xDeploy } from "../@modules/@xmpp/xmpp.xDeploy"
25
25
  import { initializeDatabase } from "../@modules/@database/database.init";
26
26
  import { getCachedEvents } from "../@modules/@database/database.cache";
27
27
  import { setCronSchedule } from "../@modules/@utilities/utilities.setCronSchedule";
28
- import { Cron } from "croner";
29
28
  import { updateNode } from "../@manager/manager.updateNodes";
29
+ import { updateEvents } from "../@manager/manager.updateEvents";
30
+ import { Cron } from "croner";
30
31
 
31
32
  export const startService = async (settings: TypeSettings): Promise<void> => {
32
33
  if (!bootstrap.isReady) {
@@ -53,7 +54,8 @@ export const startService = async (settings: TypeSettings): Promise<void> => {
53
54
  bootstrap.cron = new Cron(`*/${scheduleInterval} * * * * *`, async () => {
54
55
  await setCronSchedule();
55
56
  })
56
- bootstrap.cron = new Cron(`*/1 * * * * *`, async () => {
57
+ bootstrap.cron = new Cron(`* * * * * *`, async () => {
57
58
  await updateNode();
59
+ await updateEvents();
58
60
  })
59
61
  }
@@ -42,6 +42,16 @@ export const betterEventNames: Record<string, Record<string, EnhancedEventType>>
42
42
  },
43
43
  "Radar Indicated Tornado Warning": { },
44
44
  },
45
+ "Blizzard Warning": {
46
+ "PDS Blizzard Warning": {
47
+ description: "particularly dangerous situation",
48
+ },
49
+ },
50
+ "Ice Storm Warning": {
51
+ "PDS Ice Storm Warning": {
52
+ description: "particularly dangerous situation",
53
+ },
54
+ },
45
55
  "Special Marine Warning": {
46
56
  "Special Marine Warning (TPROB)": {
47
57
  tornado: `POSSIBLE`
@@ -81,4 +81,13 @@ export const eventTags: Record<string, string> = {
81
81
  "SHOULD EXERCISE CAUTION": "Should Exercise Caution",
82
82
  "LAKE EFFECT SNOW EXPECTED": "Lake Effect Snow Expected",
83
83
  "MODERATE LAKE EFFECT SNOWFALL RATES AND BLOWING SNOW": "Moderate Lake Effect Snowfall and Blowing Snow",
84
+ "NO TSUNAMI THREAT": "No Active Tsunami Threat",
85
+ "NO SIGNIFICANT TSUNAMI THREAT": "No Significant Tsunami Threat",
86
+ "NO TSUNAMI IMPACTS ARE EXPECTED": "No Tsunami Impacts Expected",
87
+ "A TSUNAMI THREAT EXISTS": "Tsunami Threat Exists",
88
+ "TSUNAMI THREAT": "Active Tsunami Threat",
89
+ "HEAT ILLNESSES": "Can cause heat illness",
90
+ "WATCH POSSIBLE": "Watch Possible",
91
+ "INTENSIFYING": "Intensifying",
92
+ "CAPABLE OF PRODUCING A LANDSPOUT": "Landspout Possible",
84
93
  }
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- export const eventsOffshore: Record<string, string> = {
20
+ export const eventsMatchText: Record<string, string> = {
21
21
  "Special Weather Statement": "Special Weather Statement",
22
22
  "Hurricane Warning": "Hurricane Warning",
23
23
  "Hurricane Force Wind Warning": "Hurricane Force Wind Warning",
@@ -28,4 +28,9 @@ export const eventsOffshore: Record<string, string> = {
28
28
  "Gale Warning": "Gale Warning",
29
29
  "Small Craft Advisory": "Small Craft Advisory",
30
30
  "Small Craft Warning": "Small Craft Warning",
31
+ "Tsunami Warning": "Tsunami Warning",
32
+ "Tsunami Watch": "Tsunami Watch",
33
+ "Tsunami Advisory": "Tsunami Advisory",
34
+ "Tsunami Information Statement": "Tsunami Information Statement",
35
+ "Subscribers:": "National Weather Service Policy",
31
36
  };
@@ -23,18 +23,20 @@ type TypeCorrelations = {
23
23
  isCancel: boolean
24
24
  isUpdate: boolean
25
25
  isIssued: boolean
26
+ isStatement: boolean
26
27
  }
27
28
 
28
29
  export const statusCorrelationText: TypeCorrelations[] = [
29
- {type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false},
30
- {type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false},
31
- {type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true},
32
- {type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false},
33
- {type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false},
34
- {type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true},
35
- {type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false},
36
- {type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false},
37
- {type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false},
38
- {type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false},
39
- {type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false},
30
+ {type: "Statement", name: "Statement", isCancel: false, isUpdate: false, isIssued: true, isStatement: true},
31
+ {type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
32
+ {type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false},
33
+ {type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false},
34
+ {type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
35
+ {type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false, isStatement: false},
36
+ {type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false},
37
+ {type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
38
+ {type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
39
+ {type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
40
+ {type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false},
41
+ {type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
40
42
  ]
@@ -22,7 +22,7 @@ import { TypeStanzaCompiled } from "../@types/types.compiled"
22
22
  import { TypeEvent } from "../@types/type.event";
23
23
  import { properties } from "../@building/building.properties";
24
24
  import { getEventHeader } from "../@building/building.headers";
25
- import { eventsOffshore } from "../@dictionaries/dictionaries.eventsOffshore";
25
+ import { eventsMatchText } from "../@dictionaries/dictionaries.eventsMatchText";
26
26
  import { getEventTracking } from "../@building/building.tracking";
27
27
  import { validateEvents } from "../@building/building.validate";
28
28
 
@@ -40,9 +40,11 @@ export const text = async (stanza: TypeStanzaCompiled): Promise<void> => {
40
40
  const header = getEventHeader({properties: props, getType: stanza.getType})
41
41
  const issued = new Date(attributes.issue)
42
42
  const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1000)
43
- let event = Object.keys(eventsOffshore).find(event => message.toLowerCase().includes(event.toLowerCase()));
43
+ let event = Object.keys(eventsMatchText).find(event => message.toLowerCase().includes(event.toLowerCase()));
44
+ let isStatement = false;
44
45
  if (!event) {
45
46
  event = stanza.getType.type.split(`-`).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `)
47
+ isStatement = true;
46
48
  }
47
49
  processed.push({
48
50
  type: `Feature`,
@@ -53,9 +55,9 @@ export const text = async (stanza: TypeStanzaCompiled): Promise<void> => {
53
55
  properties: {
54
56
  event: event,
55
57
  parent: event,
56
- status: `Issued`,
58
+ status: isStatement ? `Statement` : `Issued`,
57
59
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
58
- expires: (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
60
+ expires: isStatement ? new Date(issued.getTime() + 120 * 1000).toISOString() : (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
59
61
  ...props,
60
62
  metadata: {
61
63
  ms: performance.now() - tick,