@atmosx/event-product-parser 3.0.52 → 3.0.54

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.
@@ -1104,7 +1104,7 @@ var require_main3 = __commonJS({
1104
1104
  import path from "path";
1105
1105
  import { EventEmitter } from "events";
1106
1106
  var bootstrap = {
1107
- version: `3.0.52`,
1107
+ version: `3.0.54`,
1108
1108
  isReady: true,
1109
1109
  ratelimits: {},
1110
1110
  session_xmpp: null,
@@ -1168,6 +1168,15 @@ var bootstrap = {
1168
1168
  BroadcastifyDatabase: `https://scriptkitty.cafe/ftp/@atmosphericx/assets/broadcastify.json`,
1169
1169
  BroadcastifyTags: [`Ham`, `Air`, `Fire`, `Public Safety`, `Weather`, `EMS`, `Police`, `Rail`]
1170
1170
  },
1171
+ NotifyServer: {
1172
+ Enabled: false,
1173
+ Server: `https://ntfy.sh`,
1174
+ Attachments: null,
1175
+ Credentials: {
1176
+ Username: null,
1177
+ Password: null
1178
+ }
1179
+ },
1171
1180
  ListenerSettings: [],
1172
1181
  GlobalSettings: {
1173
1182
  EventManagement: true,
@@ -4503,9 +4512,9 @@ var dict_awips = {
4503
4512
  SVR: `severe-thunderstorm-warning`,
4504
4513
  SVS: `severe-weather-statement`,
4505
4514
  SWOMCD: `mesoscale-discussion`,
4506
- SWODY1: `SPC-day-1-outlook`,
4507
- SWODY2: `SPC-day-2-outlook`,
4508
- SWODY3: `SPC-day-3-outlook`,
4515
+ SWODY1: `storm-prediction-center-day-1-outlook`,
4516
+ SWODY2: `storm-prediction-center-day-2-outlook`,
4517
+ SWODY3: `storm-prediction-center-day-3-outlook`,
4509
4518
  SWS: `state-weather-summary`,
4510
4519
  SYN: `regional-weather-synopsis`,
4511
4520
  TAF: `terminal-aerodrome-forecast`,
@@ -6395,8 +6404,8 @@ var setEasTone = (options) => __async(null, null, function* () {
6395
6404
  return outTTS;
6396
6405
  });
6397
6406
 
6398
- // src/@parsers/@text/text.getEmbed.ts
6399
- var getEmebed = (event) => {
6407
+ // src/@parsers/@text/text.getEmbedText.ts
6408
+ var getEmebedText = (event) => {
6400
6409
  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, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na;
6401
6410
  const line = (label, value, condition = true) => condition && value ? `${label} ${value}` : null;
6402
6411
  const isStatement = event.properties.status_metadata.is_statement;
@@ -6433,6 +6442,42 @@ var getEmebed = (event) => {
6433
6442
  ].filter(Boolean).join("\n");
6434
6443
  };
6435
6444
 
6445
+ // src/@parsers/@text/text.getStringText.ts
6446
+ var getStringText = (event) => {
6447
+ 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, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da;
6448
+ const line = (label, value, condition = true) => condition && value ? `${label} ${value}` : null;
6449
+ const isStatement = event.properties.status_metadata.is_statement;
6450
+ const isExpired = event.properties.status_metadata.is_expired;
6451
+ return [
6452
+ line(`Locations:`, (_b = (_a = event == null ? void 0 : event.properties) == null ? void 0 : _a.locations) == null ? void 0 : _b.slice(0, 100)),
6453
+ line(`Issued:`, new Date(event.properties.issued).toUTCString(), !isExpired),
6454
+ line(`Expires:`, new Date(event.properties.expires).toUTCString(), !isStatement),
6455
+ line(`Damage Threat:`, (_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.parameters) == null ? void 0 : _d.damage_threat, !isExpired),
6456
+ line(`Flood Threat:`, (_f = (_e = event == null ? void 0 : event.properties) == null ? void 0 : _e.parameters) == null ? void 0 : _f.flood_threat, !isExpired),
6457
+ line(`Tornado Threat:`, (_h = (_g = event == null ? void 0 : event.properties) == null ? void 0 : _g.parameters) == null ? void 0 : _h.tornado_threat, !isExpired),
6458
+ line(`Estimated Wind Gusts:`, `${(_j = (_i = event == null ? void 0 : event.properties) == null ? void 0 : _i.parameters) == null ? void 0 : _j.estimated_wind_gusts} ${((_l = (_k = event == null ? void 0 : event.properties) == null ? void 0 : _k.parameters) == null ? void 0 : _l.wind_threat) ? ` (${(_n = (_m = event == null ? void 0 : event.properties) == null ? void 0 : _m.parameters) == null ? void 0 : _n.wind_threat})` : ""}`, !isExpired && ((_p = (_o = event == null ? void 0 : event.properties) == null ? void 0 : _o.parameters) == null ? void 0 : _p.estimated_wind_gusts) != null),
6459
+ line(`Estimated Hail Size:`, `${(_r = (_q = event == null ? void 0 : event.properties) == null ? void 0 : _q.parameters) == null ? void 0 : _r.estimated_hail_size} ${((_t = (_s = event == null ? void 0 : event.properties) == null ? void 0 : _s.parameters) == null ? void 0 : _t.hail_threat) ? ` (${(_v = (_u = event == null ? void 0 : event.properties) == null ? void 0 : _u.parameters) == null ? void 0 : _v.hail_threat})` : ""}`, !isExpired && ((_x = (_w = event == null ? void 0 : event.properties) == null ? void 0 : _w.parameters) == null ? void 0 : _x.estimated_hail_size) != null),
6460
+ line(`Discussion:`, (_z = (_y = event == null ? void 0 : event.properties) == null ? void 0 : _y.discussion_parameters) == null ? void 0 : _z.discussion_number, !isExpired),
6461
+ line(`Concern:`, (_B = (_A = event == null ? void 0 : event.properties) == null ? void 0 : _A.discussion_parameters) == null ? void 0 : _B.discussion_concerning, !isExpired),
6462
+ line(`SPC Max Tornado Threat:`, (_D = (_C = event == null ? void 0 : event.properties) == null ? void 0 : _C.discussion_parameters) == null ? void 0 : _D.discussion_max_tornado, !isExpired),
6463
+ line(`SPC Max Hail Threat:`, (_F = (_E = event == null ? void 0 : event.properties) == null ? void 0 : _E.discussion_parameters) == null ? void 0 : _F.discussion_max_hail, !isExpired),
6464
+ line(`SPC Max Wind Threat:`, (_H = (_G = event == null ? void 0 : event.properties) == null ? void 0 : _G.discussion_parameters) == null ? void 0 : _H.discussion_max_wind, !isExpired),
6465
+ line(`SPC Watch Issuance Probability:`, ((_J = (_I = event == null ? void 0 : event.properties) == null ? void 0 : _I.discussion_parameters) == null ? void 0 : _J.discussion_watch_issuance) ? `${(_L = (_K = event == null ? void 0 : event.properties) == null ? void 0 : _K.discussion_parameters) == null ? void 0 : _L.discussion_watch_issuance}%` : null, !isExpired),
6466
+ line(`Watch Number:`, (_N = (_M = event == null ? void 0 : event.properties) == null ? void 0 : _M.watch_parameters) == null ? void 0 : _N.watch_number, !isExpired),
6467
+ line(`Strong Tornadoes Probability:`, ((_P = (_O = event == null ? void 0 : event.properties) == null ? void 0 : _O.watch_parameters) == null ? void 0 : _P.strong_tornadoes_probability) ? `${(_R = (_Q = event == null ? void 0 : event.properties) == null ? void 0 : _Q.watch_parameters) == null ? void 0 : _R.strong_tornadoes_probability}%` : null, !isExpired),
6468
+ line(`Additional Tornadoes Probability:`, ((_T = (_S = event == null ? void 0 : event.properties) == null ? void 0 : _S.watch_parameters) == null ? void 0 : _T.additional_tornadoes_probability) ? `${(_V = (_U = event == null ? void 0 : event.properties) == null ? void 0 : _U.watch_parameters) == null ? void 0 : _V.additional_tornadoes_probability}%` : null, !isExpired),
6469
+ line(`Combined Hail/Wind Probability:`, ((_X = (_W = event == null ? void 0 : event.properties) == null ? void 0 : _W.watch_parameters) == null ? void 0 : _X.combined_hail_wind_probability) ? `${(_Z = (_Y = event == null ? void 0 : event.properties) == null ? void 0 : _Y.watch_parameters) == null ? void 0 : _Z.combined_hail_wind_probability}%` : null, !isExpired),
6470
+ line(`Severe Hail Probability:`, ((_$ = (__ = event == null ? void 0 : event.properties) == null ? void 0 : __.watch_parameters) == null ? void 0 : _$.severe_hail_probability) ? `${(_ba = (_aa = event == null ? void 0 : event.properties) == null ? void 0 : _aa.watch_parameters) == null ? void 0 : _ba.severe_hail_probability}%` : null, !isExpired),
6471
+ line(`Hail >2in Probability:`, ((_da = (_ca = event == null ? void 0 : event.properties) == null ? void 0 : _ca.watch_parameters) == null ? void 0 : _da.hail_2in_probability) ? `${(_fa = (_ea = event == null ? void 0 : event.properties) == null ? void 0 : _ea.watch_parameters) == null ? void 0 : _fa.hail_2in_probability}%` : null, !isExpired),
6472
+ line(`Max Hail Inches:`, (_ha = (_ga = event == null ? void 0 : event.properties) == null ? void 0 : _ga.watch_parameters) == null ? void 0 : _ha.max_hail_in, !isExpired),
6473
+ line(`Severe Wind Probability:`, ((_ja = (_ia = event == null ? void 0 : event.properties) == null ? void 0 : _ia.watch_parameters) == null ? void 0 : _ja.severe_wind_probability) ? `${(_la = (_ka = event == null ? void 0 : event.properties) == null ? void 0 : _ka.watch_parameters) == null ? void 0 : _la.severe_wind_probability}%` : null, !isExpired),
6474
+ line(`Max Surface Wind:`, (_na = (_ma = event == null ? void 0 : event.properties) == null ? void 0 : _ma.watch_parameters) == null ? void 0 : _na.max_wind_surface, !isExpired),
6475
+ line(`Max Tops (x100 feet):`, (_pa = (_oa = event == null ? void 0 : event.properties) == null ? void 0 : _oa.watch_parameters) == null ? void 0 : _pa.max_tops_x100feet, !isExpired),
6476
+ line(`Sender:`, ((_sa = (_ra = (_qa = event == null ? void 0 : event.properties) == null ? void 0 : _qa.geocode) == null ? void 0 : _ra.office) == null ? void 0 : _sa.name) ? `${(_va = (_ua = (_ta = event == null ? void 0 : event.properties) == null ? void 0 : _ta.geocode) == null ? void 0 : _ua.office) == null ? void 0 : _va.name} (${(_ya = (_xa = (_wa = event == null ? void 0 : event.properties) == null ? void 0 : _wa.geocode) == null ? void 0 : _xa.office) == null ? void 0 : _ya.office})` : (_Ba = (_Aa = (_za = event == null ? void 0 : event.properties) == null ? void 0 : _za.geocode) == null ? void 0 : _Aa.office) == null ? void 0 : _Ba.office),
6477
+ line(`Tracking:`, (_Da = (_Ca = event == null ? void 0 : event.properties) == null ? void 0 : _Ca.metadata) == null ? void 0 : _Da.tracking)
6478
+ ].filter(Boolean).join("\n");
6479
+ };
6480
+
6436
6481
  // src/@modules/@utilities/utilities.createHttp.ts
6437
6482
  var createHttp = (options) => __async(null, null, function* () {
6438
6483
  var _a, _b, _c, _d;
@@ -6449,6 +6494,13 @@ var createHttp = (options) => __async(null, null, function* () {
6449
6494
  const returnHttp = function(error, status, message) {
6450
6495
  return { error, options: requestOptions, status, message };
6451
6496
  };
6497
+ if (options == null ? void 0 : options.auth) {
6498
+ const authString = `${options.auth.username}:${options.auth.password}`;
6499
+ const encodedAuth = Buffer.from(authString).toString("base64");
6500
+ requestOptions.headers = __spreadProps(__spreadValues({}, requestOptions.headers), {
6501
+ "Authorization": `Basic ${encodedAuth}`
6502
+ });
6503
+ }
6452
6504
  if (options == null ? void 0 : options.formData) {
6453
6505
  requestOptions.body = options.formData;
6454
6506
  } else if ((options == null ? void 0 : options.body) != void 0) {
@@ -6488,7 +6540,7 @@ var getMatched = (strings, string) => {
6488
6540
  // src/@manager/manager.updateListener.ts
6489
6541
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3, readFileSync as readFileSync2, appendFileSync } from "fs";
6490
6542
  var updateListener = (event) => __async(null, null, function* () {
6491
- var _a, _b, _c, _d, _e, _f;
6543
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
6492
6544
  const tick = performance.now();
6493
6545
  const settings = bootstrap.settings;
6494
6546
  const listeners2 = settings.ListenerSettings;
@@ -6507,19 +6559,20 @@ var updateListener = (event) => __async(null, null, function* () {
6507
6559
  attachments: properties2.metadata.attachments
6508
6560
  };
6509
6561
  for (const listener2 of listeners2) {
6510
- const events = listener2 == null ? void 0 : listener2.events;
6511
- const webhook = listener2 == null ? void 0 : listener2.webhook;
6512
- const uploads = listener2 == null ? void 0 : listener2.uploads;
6562
+ const events = listener2 == null ? void 0 : listener2.Events;
6563
+ const webhook = listener2 == null ? void 0 : listener2.Webhook;
6564
+ const notify = listener2 == null ? void 0 : listener2.NotificationServer;
6565
+ const uploads = listener2 == null ? void 0 : listener2.Uploads;
6513
6566
  const isMatched = getMatched(events != null ? events : [], metadata.name);
6514
6567
  if ((events == null ? void 0 : events.length) == 0 || isMatched) {
6515
- if (uploads == null ? void 0 : uploads.eas) {
6568
+ if (uploads == null ? void 0 : uploads.EAS) {
6516
6569
  metadata.eas = yield setEasTone({
6517
6570
  title: `${metadata.name}_${metadata.status}_${metadata.tracking}`,
6518
6571
  message: metadata.description,
6519
6572
  header: metadata.header
6520
6573
  });
6521
6574
  }
6522
- if (uploads == null ? void 0 : uploads.file) {
6575
+ if (uploads == null ? void 0 : uploads.File) {
6523
6576
  const fDestination = settings.GlobalSettings.ArchiveSettings.TextDirectory;
6524
6577
  if (fDestination) {
6525
6578
  const file = `${fDestination}/${metadata.name}_${metadata.status}_${metadata.tracking}.txt`.replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
@@ -6534,7 +6587,7 @@ var updateListener = (event) => __async(null, null, function* () {
6534
6587
  }
6535
6588
  metadata.file = metadata.raw;
6536
6589
  }
6537
- if (uploads == null ? void 0 : uploads.event) {
6590
+ if (uploads == null ? void 0 : uploads.JSON) {
6538
6591
  const eDestination = settings.GlobalSettings.ArchiveSettings.EventDirectory;
6539
6592
  if (eDestination) {
6540
6593
  const file = `${eDestination}/${metadata.name}_${metadata.status}_${metadata.tracking}.json`.replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
@@ -6545,16 +6598,34 @@ var updateListener = (event) => __async(null, null, function* () {
6545
6598
  }
6546
6599
  metadata.json = JSON.stringify(getCleanedEvent(event), null, 2);
6547
6600
  }
6548
- if ((webhook == null ? void 0 : webhook.enabled) && (webhook == null ? void 0 : webhook.destination)) {
6549
- const isRatelimited = setTimeoutAction({ identifier: webhook.destination, interval: ((_a = webhook.ratelimit) != null ? _a : 2) * 2, max: (_b = webhook.ratelimit) != null ? _b : 2, addTime: true });
6601
+ if (((_a = settings == null ? void 0 : settings.NotifyServer) == null ? void 0 : _a.Enabled) && (notify == null ? void 0 : notify.Enabled) && (notify == null ? void 0 : notify.Topic)) {
6602
+ const server = settings == null ? void 0 : settings.NotifyServer;
6603
+ const auth = ((_b = server == null ? void 0 : server.Credentials) == null ? void 0 : _b.Username) && ((_c = server == null ? void 0 : server.Credentials) == null ? void 0 : _c.Password) ? { username: (_e = (_d = settings == null ? void 0 : settings.NotifyServer) == null ? void 0 : _d.Credentials) == null ? void 0 : _e.Username, password: (_f = server == null ? void 0 : server.Credentials) == null ? void 0 : _f.Password } : void 0;
6604
+ const attachment = metadata.eas && (server == null ? void 0 : server.Attachments) ? `${server == null ? void 0 : server.Attachments}/${metadata.name}_${metadata.status}_${metadata.tracking}.wav` : void 0;
6605
+ yield createHttp(__spreadProps(__spreadValues({
6606
+ url: `${(_g = server == null ? void 0 : server.Server) == null ? void 0 : _g.replace(/\/$/, "")}/${(_h = listener2 == null ? void 0 : listener2.NotificationServer) == null ? void 0 : _h.Topic}`,
6607
+ timeout: 15e3,
6608
+ method: "POST"
6609
+ }, auth && { auth }), {
6610
+ headers: __spreadValues({
6611
+ "Title": `${metadata.name} (${metadata.status})`,
6612
+ "Tags": (_j = (_i = properties2.parameters.tags) == null ? void 0 : _i.join(",")) != null ? _j : "N/A",
6613
+ "Expires": new Date(properties2.expires).getTime(),
6614
+ "Priority": (notify == null ? void 0 : notify.Priority) ? notify.Priority.toString() : "5"
6615
+ }, attachment && { "Attach": attachment }),
6616
+ body: getStringText(event)
6617
+ }));
6618
+ }
6619
+ if ((webhook == null ? void 0 : webhook.Enabled) && (webhook == null ? void 0 : webhook.Destination)) {
6620
+ const isRatelimited = setTimeoutAction({ identifier: webhook.Destination, interval: ((_k = webhook.Ratelimit) != null ? _k : 2) * 2, max: (_l = webhook.Ratelimit) != null ? _l : 2, addTime: true });
6550
6621
  const form = new FormData();
6551
6622
  const embed = {
6552
6623
  title: `${metadata.name} (${metadata.status})`,
6553
- description: getEmebed(event),
6624
+ description: getEmebedText(event),
6554
6625
  fields: [],
6555
6626
  color: 16711680,
6556
6627
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6557
- footer: { text: (_c = webhook.title) != null ? _c : `AtmosphericX` }
6628
+ footer: { text: (_m = webhook.Title) != null ? _m : `AtmosphericX` }
6558
6629
  };
6559
6630
  if (isRatelimited.limited) {
6560
6631
  return;
@@ -6568,32 +6639,32 @@ var updateListener = (event) => __async(null, null, function* () {
6568
6639
  value: metadata.description ? "```\n" + metadata.description.split("\n").map((l) => l.trim()).filter(Boolean).join("\n") + "\n```" : ""
6569
6640
  });
6570
6641
  }
6571
- if (((_d = metadata.attachments) == null ? void 0 : _d.length) > 0) {
6642
+ if (((_n = metadata.attachments) == null ? void 0 : _n.length) > 0) {
6572
6643
  metadata.attachments = metadata.attachments.slice(0, 5);
6573
6644
  embed.fields.push({
6574
6645
  name: "Attachments",
6575
6646
  value: metadata.attachments.map((attachment) => `- [${attachment.name.length > 45 ? attachment.name.substring(0, 45) + "..." : attachment.name}](${attachment.link})`).join("\n")
6576
6647
  });
6577
6648
  }
6578
- if (uploads == null ? void 0 : uploads.file) {
6649
+ if (uploads == null ? void 0 : uploads.File) {
6579
6650
  form.append("fUpload", new Blob([Buffer.from(metadata.file)], { type: "application/text" }), `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.txt`);
6580
6651
  }
6581
- if (uploads == null ? void 0 : uploads.event) {
6652
+ if (uploads == null ? void 0 : uploads.JSON) {
6582
6653
  form.append("fUpload2", new Blob([Buffer.from(metadata.json)], { type: "application/json" }), `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.json`);
6583
6654
  }
6584
- if (uploads == null ? void 0 : uploads.eas) {
6655
+ if (uploads == null ? void 0 : uploads.EAS) {
6585
6656
  if (metadata.eas) {
6586
6657
  const file = readFileSync2(metadata.eas);
6587
6658
  form.append("fEas", new Blob([Buffer.from(file)], { type: "audio/mpeg" }), `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}_eas.mp3`);
6588
6659
  }
6589
6660
  }
6590
6661
  form.append("payload_json", JSON.stringify({
6591
- username: (_e = webhook.title) != null ? _e : "AtmosphericX",
6592
- content: (_f = webhook.message) != null ? _f : "",
6662
+ username: (_o = webhook.Title) != null ? _o : "AtmosphericX",
6663
+ content: (_p = webhook.Message) != null ? _p : "",
6593
6664
  embeds: [embed]
6594
6665
  }));
6595
6666
  yield createHttp({
6596
- url: webhook.destination,
6667
+ url: webhook.Destination,
6597
6668
  timeout: 15e3,
6598
6669
  method: `POST`,
6599
6670
  body: form
@@ -6832,16 +6903,17 @@ var mkEvent = (event) => __async(null, null, function* () {
6832
6903
 
6833
6904
  // src/@manager/manager.rmEvent.ts
6834
6905
  var rmEvent = (event) => __async(null, null, function* () {
6835
- const getEvent = bootstrap.cache.events.features.find((f) => {
6906
+ const gSelect = event;
6907
+ const gEvent = bootstrap.cache.events.features.find((f) => {
6836
6908
  var _a, _b, _c, _d;
6837
6909
  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);
6838
6910
  });
6839
- const cachedStatus = event.properties.status;
6840
- event.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
6841
- event.properties.status = `Expired`;
6842
- event.properties.status_metadata.is_expired = true;
6843
- if (getEvent) {
6844
- if (!event.properties.status_metadata.is_statement) {
6911
+ const gStatement = event.properties.status_metadata.is_statement;
6912
+ gSelect.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
6913
+ gSelect.properties.status = `Expired`;
6914
+ gSelect.properties.status_metadata.is_expired = true;
6915
+ if (gEvent) {
6916
+ if (!gStatement) {
6845
6917
  setEventEmit({
6846
6918
  event: `onEventStatus`,
6847
6919
  metadata: {
@@ -6852,10 +6924,10 @@ var rmEvent = (event) => __async(null, null, function* () {
6852
6924
  });
6853
6925
  setEventEmit({ event: `onExpiredProduct`, metadata: event });
6854
6926
  }
6855
- if (cachedStatus != `Statement`) yield updateListener(event);
6856
- bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
6927
+ bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(gEvent), 1);
6857
6928
  bootstrap.cache.hashes = bootstrap.cache.hashes.filter((hash) => hash.tracking !== event.properties.metadata.tracking);
6858
6929
  setTimeoutAction({ identifier: event.properties.metadata.tracking, expire: true });
6930
+ if (!gStatement) yield updateListener(gSelect);
6859
6931
  }
6860
6932
  setEventEmit({
6861
6933
  event: `onEventCache`,
@@ -6942,9 +7014,9 @@ var getEventAttachments = (event) => {
6942
7014
  const watchNumber = (_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.watch_parameters) == null ? void 0 : _d.watch_number;
6943
7015
  const locations = (_e = event == null ? void 0 : event.properties) == null ? void 0 : _e.locations_array;
6944
7016
  const events = [
6945
- { target: "SPC Day 1 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day1otlk_${issuanceTime}.png` },
6946
- { target: "SPC Day 2 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day2otlk.png` },
6947
- { target: "SPC Day 3 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day3otlk.png` },
7017
+ { target: "Storm Prediction Center Day 1 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day1otlk_${issuanceTime}.png` },
7018
+ { target: "Storm Prediction Center Day 2 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day2otlk.png` },
7019
+ { target: "Storm Prediction Center Day 3 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day3otlk.png` },
6948
7020
  { target: "Mesoscale Discussion", attachment: `https://www.spc.noaa.gov/products/md/mcd${spcNumber}.png` },
6949
7021
  { target: "Tornado Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` },
6950
7022
  { target: "PDS Tornado Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmosx/event-product-parser",
3
- "version": "3.0.52",
3
+ "version": "3.0.54",
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",
@@ -43,9 +43,9 @@ export const getEventAttachments = (event: TypeEvent): GetEventAttachmentsRespon
43
43
  const watchNumber = event?.properties?.watch_parameters?.watch_number;
44
44
  const locations = event?.properties?.locations_array;
45
45
  const events = [
46
- { target: "SPC Day 1 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day1otlk_${issuanceTime}.png` },
47
- { target: "SPC Day 2 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day2otlk.png` },
48
- { target: "SPC Day 3 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day3otlk.png` },
46
+ { target: "Storm Prediction Center Day 1 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day1otlk_${issuanceTime}.png` },
47
+ { target: "Storm Prediction Center Day 2 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day2otlk.png` },
48
+ { target: "Storm Prediction Center Day 3 Outlook", attachment: `https://www.spc.noaa.gov/products/outlook/day3otlk.png` },
49
49
  { target: "Mesoscale Discussion", attachment: `https://www.spc.noaa.gov/products/md/mcd${spcNumber}.png` },
50
50
  { target: "Tornado Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` },
51
51
  { target: "PDS Tornado Watch", attachment: `https://www.spc.noaa.gov/products/watch/ww${watchNumber}_radar_big.gif` },
@@ -296,9 +296,9 @@ export const dict_awips: Record<string, string> = {
296
296
  SVR: `severe-thunderstorm-warning`,
297
297
  SVS: `severe-weather-statement`,
298
298
  SWOMCD: `mesoscale-discussion`,
299
- SWODY1: `SPC-day-1-outlook`,
300
- SWODY2: `SPC-day-2-outlook`,
301
- SWODY3: `SPC-day-3-outlook`,
299
+ SWODY1: `storm-prediction-center-day-1-outlook`,
300
+ SWODY2: `storm-prediction-center-day-2-outlook`,
301
+ SWODY3: `storm-prediction-center-day-3-outlook`,
302
302
  SWS: `state-weather-summary`,
303
303
  SYN: `regional-weather-synopsis`,
304
304
  TAF: `terminal-aerodrome-forecast`,
@@ -24,15 +24,16 @@ import { setTimeoutAction } from "../@modules/@utilities/utilities.setTimeoutAct
24
24
  import { updateListener } from "./manager.updateListener";
25
25
 
26
26
  export const rmEvent = async (event: TypeEvent): Promise<void> => {
27
- const getEvent = bootstrap.cache.events.features.find(f => f?.properties?.metadata?.tracking === event?.properties?.metadata?.tracking);
28
- const cachedStatus = event.properties.status;
27
+ const gSelect = event;
28
+ const gEvent = bootstrap.cache.events.features.find(f => f?.properties?.metadata?.tracking === event?.properties?.metadata?.tracking);
29
+ const gStatement = event.properties.status_metadata.is_statement
29
30
 
30
- event.properties.expires = new Date().toISOString();
31
- event.properties.status = `Expired`;
32
- event.properties.status_metadata.is_expired = true;
31
+ gSelect.properties.expires = new Date().toISOString();
32
+ gSelect.properties.status = `Expired`;
33
+ gSelect.properties.status_metadata.is_expired = true;
33
34
 
34
- if (getEvent) {
35
- if (!event.properties.status_metadata.is_statement) {
35
+ if (gEvent) {
36
+ if (!gStatement) {
36
37
  setEventEmit({
37
38
  event: `onEventStatus`,
38
39
  metadata: {
@@ -43,10 +44,11 @@ export const rmEvent = async (event: TypeEvent): Promise<void> => {
43
44
  })
44
45
  setEventEmit({ event: `onExpiredProduct`, metadata: event })
45
46
  }
46
- if (cachedStatus != `Statement`) await updateListener(event)
47
- bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
47
+
48
+ bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(gEvent), 1);
48
49
  bootstrap.cache.hashes = bootstrap.cache.hashes.filter(hash => hash.tracking !== event.properties.metadata.tracking);
49
50
  setTimeoutAction({ identifier: event.properties.metadata.tracking, expire: true })
51
+ if (!gStatement) await updateListener(gSelect)
50
52
  }
51
53
 
52
54
  setEventEmit({
@@ -22,7 +22,8 @@ import { TypeListener } from "../@types/type.listener";
22
22
  import { bootstrap } from "../bootstrap"
23
23
  import { setEasTone } from "../@modules/@eas/eas.setEasTone"
24
24
  import { setTimeoutAction } from "../@modules/@utilities/utilities.setTimeoutAction";
25
- import { getEmebed } from "../@parsers/@text/text.getEmbed";
25
+ import { getEmebedText } from "../@parsers/@text/text.getEmbedText";
26
+ import { getStringText } from "../@parsers/@text/text.getStringText";
26
27
  import { getCleanedEvent } from "../@building/building.clean"
27
28
  import { createHttp } from "../@modules/@utilities/utilities.createHttp";
28
29
  import { setDebug } from "../@modules/@utilities/utilities.setDebug";
@@ -49,13 +50,14 @@ export const updateListener = async (event: TypeEvent): Promise<void> => {
49
50
  }
50
51
 
51
52
  for (const listener of listeners) {
52
- const events = listener?.events;
53
- const webhook = listener?.webhook;
54
- const uploads = listener?.uploads
53
+ const events = listener?.Events;
54
+ const webhook = listener?.Webhook;
55
+ const notify = listener?.NotificationServer;
56
+ const uploads = listener?.Uploads
55
57
  const isMatched = getMatched(events ?? [], metadata.name)
56
58
 
57
59
  if (events?.length == 0 || isMatched) {
58
- if (uploads?.eas) {
60
+ if (uploads?.EAS) {
59
61
  metadata.eas = await setEasTone({
60
62
  title: `${metadata.name}_${metadata.status}_${metadata.tracking}`,
61
63
  message: metadata.description,
@@ -63,7 +65,7 @@ export const updateListener = async (event: TypeEvent): Promise<void> => {
63
65
  });
64
66
  }
65
67
 
66
- if (uploads?.file) {
68
+ if (uploads?.File) {
67
69
  const fDestination = settings.GlobalSettings.ArchiveSettings.TextDirectory;
68
70
  if (fDestination) {
69
71
  const file = (`${fDestination}/${metadata.name}_${metadata.status}_${metadata.tracking}.txt`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
@@ -77,7 +79,7 @@ export const updateListener = async (event: TypeEvent): Promise<void> => {
77
79
  metadata.file = metadata.raw;
78
80
  }
79
81
 
80
- if (uploads?.event) {
82
+ if (uploads?.JSON) {
81
83
  const eDestination = settings.GlobalSettings.ArchiveSettings.EventDirectory;
82
84
  if (eDestination) {
83
85
  const file = (`${eDestination}/${metadata.name}_${metadata.status}_${metadata.tracking}.json`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
@@ -87,16 +89,36 @@ export const updateListener = async (event: TypeEvent): Promise<void> => {
87
89
  metadata.json = JSON.stringify(getCleanedEvent(event), null, 2);
88
90
  }
89
91
 
90
- if (webhook?.enabled && webhook?.destination) {
91
- const isRatelimited = setTimeoutAction({ identifier: webhook.destination, interval: (webhook.ratelimit ?? 2) * 2, max: (webhook.ratelimit ?? 2), addTime: true })
92
+ if (settings?.NotifyServer?.Enabled && notify?.Enabled && notify?.Topic) {
93
+ const server = settings?.NotifyServer;
94
+ const auth = server?.Credentials?.Username && server?.Credentials?.Password ? { username: settings?.NotifyServer?.Credentials?.Username, password: server?.Credentials?.Password } : undefined;
95
+ const attachment = metadata.eas && server?.Attachments ? `${server?.Attachments}/${metadata.name}_${metadata.status}_${metadata.tracking}.wav` : undefined;
96
+ await createHttp({
97
+ url: `${server?.Server?.replace(/\/$/, "")}/${listener?.NotificationServer?.Topic}`,
98
+ timeout: 15_000,
99
+ method: "POST",
100
+ ...(auth && { auth }),
101
+ headers: {
102
+ "Title": `${metadata.name} (${metadata.status})`,
103
+ "Tags": properties.parameters.tags?.join(",") ?? "N/A",
104
+ "Expires": new Date(properties.expires).getTime(),
105
+ "Priority": notify?.Priority ? notify.Priority.toString() : "5",
106
+ ... (attachment && { "Attach": attachment }),
107
+ },
108
+ body: getStringText(event)
109
+ })
110
+ }
111
+
112
+ if (webhook?.Enabled && webhook?.Destination) {
113
+ const isRatelimited = setTimeoutAction({ identifier: webhook.Destination, interval: (webhook.Ratelimit ?? 2) * 2, max: (webhook.Ratelimit ?? 2), addTime: true })
92
114
  const form = new FormData();
93
115
  const embed = {
94
116
  title: `${metadata.name} (${metadata.status})`,
95
- description: getEmebed(event),
117
+ description: getEmebedText(event),
96
118
  fields: [],
97
119
  color: 16711680,
98
120
  timestamp: new Date().toISOString(),
99
- footer: { text: webhook.title ?? `AtmosphericX` }
121
+ footer: { text: webhook.Title ?? `AtmosphericX` }
100
122
  };
101
123
 
102
124
  if (isRatelimited.limited) { return }
@@ -121,15 +143,15 @@ export const updateListener = async (event: TypeEvent): Promise<void> => {
121
143
  });
122
144
  }
123
145
 
124
- if (uploads?.file) {
146
+ if (uploads?.File) {
125
147
  form.append("fUpload", new Blob([Buffer.from(metadata.file)], {type: "application/text"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.txt`)
126
148
  }
127
149
 
128
- if (uploads?.event) {
150
+ if (uploads?.JSON) {
129
151
  form.append("fUpload2", new Blob([Buffer.from(metadata.json)], {type: "application/json"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.json`)
130
152
  }
131
153
 
132
- if (uploads?.eas) {
154
+ if (uploads?.EAS) {
133
155
  if (metadata.eas) {
134
156
  const file = readFileSync(metadata.eas)
135
157
  form.append("fEas", new Blob([Buffer.from(file)], { type: "audio/mpeg" }), `${properties.event}_${properties.status}_${properties.metadata.tracking}_eas.mp3`)
@@ -137,13 +159,13 @@ export const updateListener = async (event: TypeEvent): Promise<void> => {
137
159
  }
138
160
 
139
161
  form.append("payload_json", JSON.stringify({
140
- username: webhook.title ?? "AtmosphericX",
141
- content: webhook.message ?? "",
162
+ username: webhook.Title ?? "AtmosphericX",
163
+ content: webhook.Message ?? "",
142
164
  embeds: [embed]
143
165
  }));
144
166
 
145
167
  await createHttp({
146
- url: webhook.destination,
168
+ url: webhook.Destination,
147
169
  timeout: 15e3,
148
170
  method: `POST`,
149
171
  body: form
@@ -21,6 +21,10 @@ interface CreateHttpOptions {
21
21
  url: string
22
22
  headers?: any
23
23
  timeout?: number
24
+ auth?: {
25
+ username: string
26
+ password: string
27
+ }
24
28
  method?: `GET` | `POST` | `PUT` | `DELETE`
25
29
  body?: any;
26
30
  formData?: any;
@@ -43,6 +47,15 @@ export const createHttp = async (options: CreateHttpOptions): Promise<any> => {
43
47
  return { error: error, options: requestOptions, status, message };
44
48
  }
45
49
 
50
+ if (options?.auth) {
51
+ const authString = `${options.auth.username}:${options.auth.password}`;
52
+ const encodedAuth = Buffer.from(authString).toString("base64");
53
+ requestOptions.headers = {
54
+ ...requestOptions.headers,
55
+ "Authorization": `Basic ${encodedAuth}`
56
+ };
57
+ }
58
+
46
59
  if (options?.formData) {
47
60
  requestOptions.body = options.formData;
48
61
  } else if (options?.body != undefined) {
@@ -19,7 +19,7 @@
19
19
 
20
20
  import { TypeEvent } from "../../@types/type.event"
21
21
 
22
- export const getEmebed = (event: TypeEvent): string => {
22
+ export const getEmebedText = (event: TypeEvent): string => {
23
23
  const line = (label: string, value: unknown, condition = true) => condition && value ? `${label} ${value}` : null;
24
24
  const isStatement = event.properties.status_metadata.is_statement;
25
25
  const isExpired = event.properties.status_metadata.is_expired;
@@ -0,0 +1,54 @@
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 { TypeEvent } from "../../@types/type.event"
21
+
22
+ export const getStringText = (event: TypeEvent): string => {
23
+ const line = (label: string, value: unknown, condition = true) => condition && value ? `${label} ${value}` : null;
24
+ const isStatement = event.properties.status_metadata.is_statement;
25
+ const isExpired = event.properties.status_metadata.is_expired;
26
+ return [
27
+ line(`Locations:`, event?.properties?.locations?.slice(0, 100)),
28
+ line(`Issued:`, new Date(event.properties.issued).toUTCString(), !isExpired),
29
+ line(`Expires:`, new Date(event.properties.expires).toUTCString(), !isStatement),
30
+ line(`Damage Threat:`, event?.properties?.parameters?.damage_threat, !isExpired),
31
+ line(`Flood Threat:`, event?.properties?.parameters?.flood_threat, !isExpired),
32
+ line(`Tornado Threat:`, event?.properties?.parameters?.tornado_threat, !isExpired),
33
+ line(`Estimated Wind Gusts:`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
34
+ line(`Estimated Hail Size:`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
35
+ line(`Discussion:`, event?.properties?.discussion_parameters?.discussion_number, !isExpired),
36
+ line(`Concern:`, event?.properties?.discussion_parameters?.discussion_concerning, !isExpired),
37
+ line(`SPC Max Tornado Threat:`, event?.properties?.discussion_parameters?.discussion_max_tornado, !isExpired),
38
+ line(`SPC Max Hail Threat:`, event?.properties?.discussion_parameters?.discussion_max_hail, !isExpired),
39
+ line(`SPC Max Wind Threat:`, event?.properties?.discussion_parameters?.discussion_max_wind, !isExpired),
40
+ line(`SPC Watch Issuance Probability:`, event?.properties?.discussion_parameters?.discussion_watch_issuance ? `${event?.properties?.discussion_parameters?.discussion_watch_issuance}%` : null, !isExpired),
41
+ line(`Watch Number:`, event?.properties?.watch_parameters?.watch_number, !isExpired),
42
+ line(`Strong Tornadoes Probability:`, event?.properties?.watch_parameters?.strong_tornadoes_probability ? `${event?.properties?.watch_parameters?.strong_tornadoes_probability}%` : null, !isExpired),
43
+ line(`Additional Tornadoes Probability:`, event?.properties?.watch_parameters?.additional_tornadoes_probability ? `${event?.properties?.watch_parameters?.additional_tornadoes_probability}%` : null, !isExpired),
44
+ line(`Combined Hail/Wind Probability:`, event?.properties?.watch_parameters?.combined_hail_wind_probability ? `${event?.properties?.watch_parameters?.combined_hail_wind_probability}%` : null, !isExpired),
45
+ line(`Severe Hail Probability:`, event?.properties?.watch_parameters?.severe_hail_probability ? `${event?.properties?.watch_parameters?.severe_hail_probability}%` : null, !isExpired),
46
+ line(`Hail >2in Probability:`, event?.properties?.watch_parameters?.hail_2in_probability ? `${event?.properties?.watch_parameters?.hail_2in_probability}%` : null, !isExpired),
47
+ line(`Max Hail Inches:`, event?.properties?.watch_parameters?.max_hail_in, !isExpired),
48
+ line(`Severe Wind Probability:`, event?.properties?.watch_parameters?.severe_wind_probability ? `${event?.properties?.watch_parameters?.severe_wind_probability}%` : null, !isExpired),
49
+ line(`Max Surface Wind:`, event?.properties?.watch_parameters?.max_wind_surface, !isExpired),
50
+ line(`Max Tops (x100 feet):`, event?.properties?.watch_parameters?.max_tops_x100feet, !isExpired),
51
+ line(`Sender:`, event?.properties?.geocode?.office?.name ? `${event?.properties?.geocode?.office?.name} (${event?.properties?.geocode?.office?.office})` : event?.properties?.geocode?.office?.office),
52
+ line(`Tracking:`, event?.properties?.metadata?.tracking),
53
+ ].filter(Boolean).join('\n');
54
+ }
@@ -18,15 +18,21 @@
18
18
  */
19
19
 
20
20
  export type TypeListener = {
21
- events: string[]
22
- webhook?: {
23
- enabled: boolean
24
- destination: string
25
- ratelimit: number
26
- title: string
27
- message: string
21
+ Events: string[]
22
+ Webhook?: {
23
+ Enabled: boolean
24
+ Destination: string
25
+ Ratelimit: number
26
+ Title: string
27
+ Message: string
28
28
  }
29
- uploads?: {
30
- file?: boolean, eas?: boolean, event?: boolean
29
+ NotificationServer?: {
30
+ Enabled: boolean
31
+ Topic: string
32
+ Priority?: 1 | 2 | 3 | 4 | 5 | void
31
33
  }
34
+ Uploads?: {
35
+ File?: boolean, EAS?: boolean, JSON?: boolean
36
+ }
37
+
32
38
  }
@@ -54,6 +54,15 @@ export type TypeSettings = {
54
54
  BroadcastifyDatabase: string
55
55
  BroadcastifyTags: string[]
56
56
  },
57
+ NotifyServer: {
58
+ Enabled: boolean
59
+ Server: string
60
+ Attachments?: string
61
+ Credentials?: {
62
+ Username: string | void
63
+ Password: string | void
64
+ }
65
+ }
57
66
  GlobalSettings: {
58
67
  EventManagement: boolean
59
68
  BetterEventNames: boolean