@atmosx/event-product-parser 3.0.53 → 3.0.55

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.53`,
1107
+ version: `3.0.55`,
1108
1108
  isReady: true,
1109
1109
  ratelimits: {},
1110
1110
  session_xmpp: null,
@@ -1358,6 +1358,7 @@ var setTimeoutAction = (options) => {
1358
1358
  }
1359
1359
  if (options == null ? void 0 : options.expire) {
1360
1360
  delete bootstrap.ratelimits[options == null ? void 0 : options.identifier];
1361
+ return { limited: false };
1361
1362
  }
1362
1363
  if ((target == null ? void 0 : target.length) > 0) {
1363
1364
  bootstrap.ratelimits[options == null ? void 0 : options.identifier] = target.filter((ts) => Date.now() - ts < (options == null ? void 0 : options.interval) * 1e3);
@@ -5795,6 +5796,9 @@ var dict_enhanced = {
5795
5796
  "Considerable Severe Thunderstorm Warning (TPROB)": { damage: `CONSIDERABLE`, tornado: `POSSIBLE` },
5796
5797
  "Considerable Severe Thunderstorm Warning": { damage: `CONSIDERABLE` },
5797
5798
  "Severe Thunderstorm Warning (TPROB)": { tornado: `POSSIBLE` }
5799
+ },
5800
+ "Special Weather Statement": {
5801
+ "Convective Special Weather Statement": { description: "strong thunderstorm" }
5798
5802
  }
5799
5803
  };
5800
5804
 
@@ -6404,8 +6408,8 @@ var setEasTone = (options) => __async(null, null, function* () {
6404
6408
  return outTTS;
6405
6409
  });
6406
6410
 
6407
- // src/@parsers/@text/text.getEmbed.ts
6408
- var getEmebed = (event) => {
6411
+ // src/@parsers/@text/text.getEmbedText.ts
6412
+ var getEmebedText = (event) => {
6409
6413
  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;
6410
6414
  const line = (label, value, condition = true) => condition && value ? `${label} ${value}` : null;
6411
6415
  const isStatement = event.properties.status_metadata.is_statement;
@@ -6442,8 +6446,8 @@ var getEmebed = (event) => {
6442
6446
  ].filter(Boolean).join("\n");
6443
6447
  };
6444
6448
 
6445
- // src/@parsers/@text/text.getRaw.ts
6446
- var getRaw = (event) => {
6449
+ // src/@parsers/@text/text.getStringText.ts
6450
+ var getStringText = (event) => {
6447
6451
  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
6452
  const line = (label, value, condition = true) => condition && value ? `${label} ${value}` : null;
6449
6453
  const isStatement = event.properties.status_metadata.is_statement;
@@ -6540,7 +6544,7 @@ var getMatched = (strings, string) => {
6540
6544
  // src/@manager/manager.updateListener.ts
6541
6545
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3, readFileSync as readFileSync2, appendFileSync } from "fs";
6542
6546
  var updateListener = (event) => __async(null, null, function* () {
6543
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
6547
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
6544
6548
  const tick = performance.now();
6545
6549
  const settings = bootstrap.settings;
6546
6550
  const listeners2 = settings.ListenerSettings;
@@ -6559,37 +6563,39 @@ var updateListener = (event) => __async(null, null, function* () {
6559
6563
  attachments: properties2.metadata.attachments
6560
6564
  };
6561
6565
  for (const listener2 of listeners2) {
6562
- const events = listener2 == null ? void 0 : listener2.events;
6563
- const webhook = listener2 == null ? void 0 : listener2.webhook;
6564
- const uploads = listener2 == null ? void 0 : listener2.uploads;
6566
+ const events = listener2 == null ? void 0 : listener2.Events;
6567
+ const webhook = listener2 == null ? void 0 : listener2.Webhook;
6568
+ const notify = listener2 == null ? void 0 : listener2.NotificationServer;
6569
+ const uploads = listener2 == null ? void 0 : listener2.Uploads;
6565
6570
  const isMatched = getMatched(events != null ? events : [], metadata.name);
6566
6571
  if ((events == null ? void 0 : events.length) == 0 || isMatched) {
6567
- if (uploads == null ? void 0 : uploads.eas) {
6572
+ if (uploads == null ? void 0 : uploads.EAS) {
6568
6573
  metadata.eas = yield setEasTone({
6569
6574
  title: `${metadata.name}_${metadata.status}_${metadata.tracking}`,
6570
6575
  message: metadata.description,
6571
6576
  header: metadata.header
6572
6577
  });
6573
6578
  }
6574
- if (uploads == null ? void 0 : uploads.file) {
6579
+ if (uploads == null ? void 0 : uploads.File) {
6575
6580
  const fDestination = settings.GlobalSettings.ArchiveSettings.TextDirectory;
6576
6581
  if (fDestination) {
6577
- const file = `${fDestination}/${metadata.name}_${metadata.status}_${metadata.tracking}.txt`.replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
6582
+ const file = `${fDestination}/${metadata.name}_${metadata.tracking}.txt`.replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
6578
6583
  if (!existsSync2(fDestination)) {
6579
6584
  mkdirSync2(fDestination, { recursive: true });
6580
6585
  }
6581
6586
  if (existsSync2(file)) {
6582
- appendFileSync(file, metadata.raw);
6587
+ appendFileSync(file, `${`
6588
+ `.repeat(10)}${metadata.raw}`);
6583
6589
  } else {
6584
6590
  writeFileSync3(file, metadata.raw);
6585
6591
  }
6586
6592
  }
6587
6593
  metadata.file = metadata.raw;
6588
6594
  }
6589
- if (uploads == null ? void 0 : uploads.event) {
6595
+ if (uploads == null ? void 0 : uploads.JSON) {
6590
6596
  const eDestination = settings.GlobalSettings.ArchiveSettings.EventDirectory;
6591
6597
  if (eDestination) {
6592
- const file = `${eDestination}/${metadata.name}_${metadata.status}_${metadata.tracking}.json`.replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
6598
+ const file = `${eDestination}/${metadata.name}_${metadata.tracking}.json`.replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
6593
6599
  if (!existsSync2(eDestination)) {
6594
6600
  mkdirSync2(eDestination, { recursive: true });
6595
6601
  }
@@ -6597,37 +6603,37 @@ var updateListener = (event) => __async(null, null, function* () {
6597
6603
  }
6598
6604
  metadata.json = JSON.stringify(getCleanedEvent(event), null, 2);
6599
6605
  }
6600
- if (settings.NotifyServer.Enabled && ((_a = listener2 == null ? void 0 : listener2.notify) == null ? void 0 : _a.enabled) && ((_b = listener2 == null ? void 0 : listener2.notify) == null ? void 0 : _b.topic)) {
6601
- const auth = ((_c = settings.NotifyServer.Credentials) == null ? void 0 : _c.Username) && ((_d = settings.NotifyServer.Credentials) == null ? void 0 : _d.Password) ? {
6602
- username: settings.NotifyServer.Credentials.Username,
6603
- password: settings.NotifyServer.Credentials.Password
6604
- } : void 0;
6605
- const attachment = metadata.eas && settings.NotifyServer.Attachments ? `${settings.NotifyServer.Attachments}/${metadata.name}_${metadata.status}_${metadata.tracking}.wav` : null;
6606
- yield createHttp(__spreadProps(__spreadValues({
6607
- url: `${settings.NotifyServer.Server.replace(/\/$/, "")}/${(_e = listener2 == null ? void 0 : listener2.notify) == null ? void 0 : _e.topic}`,
6608
- timeout: 15e3,
6609
- method: "POST"
6610
- }, auth && { auth }), {
6611
- headers: __spreadProps(__spreadValues({
6612
- "Title": `${metadata.name} (${metadata.status})`,
6613
- "Tags": (_g = (_f = properties2.parameters.tags) == null ? void 0 : _f.join(",")) != null ? _g : "N/A"
6614
- }, attachment && { "Attach": attachment }), {
6615
- "Priority": "max",
6616
- "Sound": "siren"
6617
- }),
6618
- body: getRaw(event)
6619
- }));
6606
+ 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)) {
6607
+ const server = settings == null ? void 0 : settings.NotifyServer;
6608
+ 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;
6609
+ 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;
6610
+ const isRatelimited = setTimeoutAction({ identifier: metadata.tracking + `notify.server`, interval: 1, max: 1, addTime: true });
6611
+ if (!isRatelimited.limited) {
6612
+ yield createHttp(__spreadProps(__spreadValues({
6613
+ 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}`,
6614
+ timeout: 15e3,
6615
+ method: "POST"
6616
+ }, auth && { auth }), {
6617
+ headers: __spreadValues({
6618
+ "Title": `${metadata.name} (${metadata.status})`,
6619
+ "Tags": (_j = (_i = properties2.parameters.tags) == null ? void 0 : _i.join(",")) != null ? _j : "N/A",
6620
+ "Expires": new Date(properties2.expires).getTime(),
6621
+ "Priority": (notify == null ? void 0 : notify.Priority) ? notify.Priority.toString() : "5"
6622
+ }, attachment && { "Attach": attachment }),
6623
+ body: getStringText(event)
6624
+ }));
6625
+ }
6620
6626
  }
6621
- if ((webhook == null ? void 0 : webhook.enabled) && (webhook == null ? void 0 : webhook.destination)) {
6622
- const isRatelimited = setTimeoutAction({ identifier: webhook.destination, interval: ((_h = webhook.ratelimit) != null ? _h : 2) * 2, max: (_i = webhook.ratelimit) != null ? _i : 2, addTime: true });
6627
+ if ((webhook == null ? void 0 : webhook.Enabled) && (webhook == null ? void 0 : webhook.Destination)) {
6628
+ const isRatelimited = setTimeoutAction({ identifier: webhook.Destination, interval: ((_k = webhook.Ratelimit) != null ? _k : 2) * 2, max: (_l = webhook.Ratelimit) != null ? _l : 2, addTime: true });
6623
6629
  const form = new FormData();
6624
6630
  const embed = {
6625
6631
  title: `${metadata.name} (${metadata.status})`,
6626
- description: getEmebed(event),
6632
+ description: getEmebedText(event),
6627
6633
  fields: [],
6628
6634
  color: 16711680,
6629
6635
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6630
- footer: { text: (_j = webhook.title) != null ? _j : `AtmosphericX` }
6636
+ footer: { text: (_m = webhook.Title) != null ? _m : `AtmosphericX` }
6631
6637
  };
6632
6638
  if (isRatelimited.limited) {
6633
6639
  return;
@@ -6641,32 +6647,32 @@ var updateListener = (event) => __async(null, null, function* () {
6641
6647
  value: metadata.description ? "```\n" + metadata.description.split("\n").map((l) => l.trim()).filter(Boolean).join("\n") + "\n```" : ""
6642
6648
  });
6643
6649
  }
6644
- if (((_k = metadata.attachments) == null ? void 0 : _k.length) > 0) {
6650
+ if (((_n = metadata.attachments) == null ? void 0 : _n.length) > 0) {
6645
6651
  metadata.attachments = metadata.attachments.slice(0, 5);
6646
6652
  embed.fields.push({
6647
6653
  name: "Attachments",
6648
6654
  value: metadata.attachments.map((attachment) => `- [${attachment.name.length > 45 ? attachment.name.substring(0, 45) + "..." : attachment.name}](${attachment.link})`).join("\n")
6649
6655
  });
6650
6656
  }
6651
- if (uploads == null ? void 0 : uploads.file) {
6657
+ if (uploads == null ? void 0 : uploads.File) {
6652
6658
  form.append("fUpload", new Blob([Buffer.from(metadata.file)], { type: "application/text" }), `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.txt`);
6653
6659
  }
6654
- if (uploads == null ? void 0 : uploads.event) {
6660
+ if (uploads == null ? void 0 : uploads.JSON) {
6655
6661
  form.append("fUpload2", new Blob([Buffer.from(metadata.json)], { type: "application/json" }), `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}.json`);
6656
6662
  }
6657
- if (uploads == null ? void 0 : uploads.eas) {
6663
+ if (uploads == null ? void 0 : uploads.EAS) {
6658
6664
  if (metadata.eas) {
6659
6665
  const file = readFileSync2(metadata.eas);
6660
6666
  form.append("fEas", new Blob([Buffer.from(file)], { type: "audio/mpeg" }), `${properties2.event}_${properties2.status}_${properties2.metadata.tracking}_eas.mp3`);
6661
6667
  }
6662
6668
  }
6663
6669
  form.append("payload_json", JSON.stringify({
6664
- username: (_l = webhook.title) != null ? _l : "AtmosphericX",
6665
- content: (_m = webhook.message) != null ? _m : "",
6670
+ username: (_o = webhook.Title) != null ? _o : "AtmosphericX",
6671
+ content: (_p = webhook.Message) != null ? _p : "",
6666
6672
  embeds: [embed]
6667
6673
  }));
6668
6674
  yield createHttp({
6669
- url: webhook.destination,
6675
+ url: webhook.Destination,
6670
6676
  timeout: 15e3,
6671
6677
  method: `POST`,
6672
6678
  body: form
@@ -6903,32 +6909,42 @@ var mkEvent = (event) => __async(null, null, function* () {
6903
6909
  }
6904
6910
  });
6905
6911
 
6912
+ // src/@dictionaries/dictionaries.strings.ts
6913
+ var dict_strings = {
6914
+ cancellation: `{EVENT} has been allowed to expire. This product is no longer in effect.`
6915
+ };
6916
+
6906
6917
  // src/@manager/manager.rmEvent.ts
6907
- var rmEvent = (event) => __async(null, null, function* () {
6908
- const getEvent = bootstrap.cache.events.features.find((f) => {
6909
- var _a, _b, _c, _d;
6910
- 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);
6918
+ var rmEvent = (event, isTimeBasedExpiration) => __async(null, null, function* () {
6919
+ const gTracking = event.properties.metadata.tracking;
6920
+ const isTrackingEventLogged = bootstrap.cache.events.features.find((f) => {
6921
+ var _a, _b;
6922
+ return ((_b = (_a = f == null ? void 0 : f.properties) == null ? void 0 : _a.metadata) == null ? void 0 : _b.tracking) === gTracking;
6911
6923
  });
6912
- const cachedStatus = event.properties.status;
6913
- event.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
6914
- event.properties.status = `Expired`;
6915
- event.properties.status_metadata.is_expired = true;
6916
- if (getEvent) {
6917
- if (!event.properties.status_metadata.is_statement) {
6924
+ const isStatement = event.properties.status_metadata.is_statement;
6925
+ if (isTrackingEventLogged) {
6926
+ event.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
6927
+ event.properties.status = `Expired`;
6928
+ event.properties.status_metadata.is_expired = true;
6929
+ const description = isTimeBasedExpiration ? dict_strings.cancellation.replace(`{SENDER}`, event.properties.geocode.office.name).replace(`{EVENT}`, event.properties.event) : event.properties.metadata.raw;
6930
+ event.properties.description = event.properties.metadata.raw = description;
6931
+ event.properties.metadata.history.push({
6932
+ description,
6933
+ issued: event.properties.expires,
6934
+ status: event.properties.status
6935
+ });
6936
+ bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(isTrackingEventLogged), 1);
6937
+ bootstrap.cache.hashes = bootstrap.cache.hashes.filter((hash) => hash.tracking !== gTracking);
6938
+ if (!isStatement) {
6918
6939
  setEventEmit({
6919
6940
  event: `onEventStatus`,
6920
- metadata: {
6921
- type: `Removed`,
6922
- event
6923
- },
6924
- message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
6941
+ metadata: { type: `Removed`, event },
6942
+ message: `[Removed] ${event.properties.event} (${event.properties.status}) (${gTracking})`
6925
6943
  });
6926
- setEventEmit({ event: `onExpiredProduct`, metadata: event });
6944
+ yield updateListener(event);
6927
6945
  }
6928
- if (cachedStatus != `Statement`) yield updateListener(event);
6929
- bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
6930
- bootstrap.cache.hashes = bootstrap.cache.hashes.filter((hash) => hash.tracking !== event.properties.metadata.tracking);
6931
- setTimeoutAction({ identifier: event.properties.metadata.tracking, expire: true });
6946
+ setTimeoutAction({ identifier: gTracking, expire: true });
6947
+ setTimeoutAction({ identifier: gTracking + `notify.server`, expire: true });
6932
6948
  }
6933
6949
  setEventEmit({
6934
6950
  event: `onEventCache`,
@@ -7081,7 +7097,7 @@ var validateEvents = (events) => __async(null, null, function* () {
7081
7097
  }
7082
7098
  if (properties2.status_metadata.is_expired) {
7083
7099
  setEventEmit({ event: `onExpiredProduct`, metadata: define2 });
7084
- rmEvent(define2);
7100
+ rmEvent(define2, false);
7085
7101
  return true;
7086
7102
  }
7087
7103
  if (((_b = (_a = properties2.metadata) == null ? void 0 : _a.vtec) == null ? void 0 : _b.is_watch) && properties2.metadata.source != `events.api`) {
@@ -7143,18 +7159,19 @@ var validateEvents = (events) => __async(null, null, function* () {
7143
7159
  return false;
7144
7160
  };
7145
7161
  const filtering = events.filter((event) => {
7146
- var _a;
7147
7162
  bootstrap.cache.processed = bootstrap.cache.processed.filter((e) => e !== event);
7148
7163
  const define2 = getEventSignature(event);
7164
+ const pre = __spreadProps(__spreadValues({}, define2), { properties: __spreadProps(__spreadValues({}, define2.properties), { metadata: __spreadValues({}, define2.properties.metadata) }) });
7149
7165
  const properties2 = define2.properties;
7150
- (_a = properties2 == null ? void 0 : properties2.metadata) == null ? true : delete _a.ms;
7166
+ delete pre.properties.metadata.ms;
7167
+ delete pre.properties.metadata.header;
7151
7168
  const enhanced = properties2.event = getEventEnhancedName(event);
7152
7169
  const filtered = isFiltered(define2);
7153
7170
  if (!filtered) {
7154
7171
  event.geometry = !(bools == null ? void 0 : bools.DisableGeometryParsing) ? getEventGeometry(event) : null;
7155
7172
  properties2.metadata.attachments = getEventAttachments(event);
7156
7173
  }
7157
- properties2.metadata.hash = createHash("sha256").update(JSON.stringify(properties2)).digest("hex");
7174
+ properties2.metadata.hash = createHash("sha256").update(JSON.stringify(pre)).digest("hex");
7158
7175
  setEventEmit({ event: `onProductType${enhanced.replace(/\s+/g, "")}`, metadata: define2 });
7159
7176
  return !filtered;
7160
7177
  });
@@ -7590,16 +7607,17 @@ var setCronSchedule = () => __async(null, null, function* () {
7590
7607
  // src/@manager/manager.updateEvents.ts
7591
7608
  var updateEvents = (selectedEvent) => __async(null, null, function* () {
7592
7609
  const events = bootstrap.cache.events.features;
7593
- function update(evt) {
7610
+ function update(event) {
7594
7611
  return __async(this, null, function* () {
7595
- if (new Date(evt.properties.expires) < /* @__PURE__ */ new Date()) {
7596
- yield rmEvent(evt);
7612
+ if (new Date(event.properties.expires) < /* @__PURE__ */ new Date()) {
7613
+ setEventEmit({ event: `onExpiredProduct`, metadata: event });
7614
+ yield rmEvent(event, true);
7597
7615
  }
7598
7616
  });
7599
7617
  }
7600
7618
  if (!selectedEvent) {
7601
- yield Promise.all(events.map((evt) => __async(null, null, function* () {
7602
- yield update(evt);
7619
+ yield Promise.all(events.map((event) => __async(null, null, function* () {
7620
+ yield update(event);
7603
7621
  })));
7604
7622
  }
7605
7623
  if (selectedEvent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmosx/event-product-parser",
3
- "version": "3.0.53",
3
+ "version": "3.0.55",
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",
@@ -57,7 +57,7 @@ export const validateEvents = async (events: TypeEvent[]): Promise<void> => {
57
57
 
58
58
  if (properties.status_metadata.is_expired) {
59
59
  setEventEmit({ event: `onExpiredProduct`, metadata: define })
60
- rmEvent(define)
60
+ rmEvent(define, false)
61
61
  return true;
62
62
  }
63
63
 
@@ -124,14 +124,16 @@ export const validateEvents = async (events: TypeEvent[]): Promise<void> => {
124
124
  const filtering = events.filter((event: TypeEvent) => {
125
125
  bootstrap.cache.processed = bootstrap.cache.processed.filter((e) => e !== event);
126
126
  const define = getEventSignature(event) as TypeEvent;
127
- const properties = define.properties; delete properties?.metadata?.ms;
127
+ // make a copy of the define object with properites so we can delete values to make hash
128
+ const pre = {...define,properties: {...define.properties, metadata: {...define.properties.metadata }}};
129
+ const properties = define.properties; delete pre.properties.metadata.ms; delete pre.properties.metadata.header;
128
130
  const enhanced = properties.event = getEventEnhancedName(event)
129
131
  const filtered = isFiltered(define)
130
132
  if (!filtered) {
131
133
  event.geometry = !bools?.DisableGeometryParsing ? getEventGeometry(event) : null;
132
134
  properties.metadata.attachments = getEventAttachments(event)
133
135
  }
134
- properties.metadata.hash = createHash("sha256").update(JSON.stringify(properties)).digest("hex")
136
+ properties.metadata.hash = createHash("sha256").update(JSON.stringify(pre)).digest("hex")
135
137
  setEventEmit({ event: `onProductType${enhanced.replace(/\s+/g, '')}`, metadata: define });
136
138
  return !filtered
137
139
  })
@@ -64,4 +64,7 @@ export const dict_enhanced: Record<string, Record<string, EnhancedEventType>> =
64
64
  "Considerable Severe Thunderstorm Warning": { damage: `CONSIDERABLE` },
65
65
  "Severe Thunderstorm Warning (TPROB)": { tornado: `POSSIBLE` },
66
66
  },
67
+ "Special Weather Statement": {
68
+ "Convective Special Weather Statement": { description: "strong thunderstorm" },
69
+ }
67
70
  }
@@ -0,0 +1,22 @@
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
+ export const dict_strings: Record<string, string> = {
21
+ cancellation: `{EVENT} has been allowed to expire. This product is no longer in effect.`,
22
+ }
@@ -18,37 +18,52 @@
18
18
  */
19
19
 
20
20
  import { TypeEvent } from "../@types/type.event";
21
+ import { dict_strings } from "../@dictionaries/dictionaries.strings";
21
22
  import { bootstrap } from "../bootstrap"
22
23
  import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
23
24
  import { setTimeoutAction } from "../@modules/@utilities/utilities.setTimeoutAction";
24
25
  import { updateListener } from "./manager.updateListener";
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;
29
27
 
30
- event.properties.expires = new Date().toISOString();
31
- event.properties.status = `Expired`;
32
- event.properties.status_metadata.is_expired = true;
28
+ export const rmEvent = async (event: TypeEvent, isTimeBasedExpiration: boolean):Promise<void> => {
29
+ const gTracking = event.properties.metadata.tracking;
30
+ const isTrackingEventLogged = bootstrap.cache.events.features
31
+ .find(f => f?.properties?.metadata?.tracking === gTracking);
32
+ const isStatement = event.properties.status_metadata.is_statement;
33
33
 
34
- if (getEvent) {
35
- if (!event.properties.status_metadata.is_statement) {
34
+ if (isTrackingEventLogged) {
35
+ event.properties.expires = new Date().toISOString();
36
+ event.properties.status = `Expired`;
37
+ event.properties.status_metadata.is_expired = true;
38
+
39
+
40
+ const description = isTimeBasedExpiration ? dict_strings.cancellation
41
+ .replace(`{SENDER}`, event.properties.geocode.office.name)
42
+ .replace(`{EVENT}`, event.properties.event) : event.properties.metadata.raw;
43
+ event.properties.description = event.properties.metadata.raw = description;
44
+ event.properties.metadata.history.push({
45
+ description: description,
46
+ issued: event.properties.expires,
47
+ status: event.properties.status
48
+ })
49
+
50
+
51
+ bootstrap.cache.events.features
52
+ .splice(bootstrap.cache.events.features.indexOf(isTrackingEventLogged), 1);
53
+ bootstrap.cache.hashes = bootstrap.cache.hashes
54
+ .filter(hash => hash.tracking !== gTracking);
55
+
56
+ if (!isStatement) {
36
57
  setEventEmit({
37
58
  event: `onEventStatus`,
38
- metadata: {
39
- type: `Removed`,
40
- event: event
41
- },
42
- message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
59
+ metadata: { type: `Removed`, event: event },
60
+ message: `[Removed] ${event.properties.event} (${event.properties.status}) (${gTracking})`
43
61
  })
44
- setEventEmit({ event: `onExpiredProduct`, metadata: event })
62
+ await updateListener(event)
45
63
  }
46
- if (cachedStatus != `Statement`) await updateListener(event)
47
- bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
48
- bootstrap.cache.hashes = bootstrap.cache.hashes.filter(hash => hash.tracking !== event.properties.metadata.tracking);
49
- setTimeoutAction({ identifier: event.properties.metadata.tracking, expire: true })
64
+ setTimeoutAction({ identifier: gTracking, expire: true })
65
+ setTimeoutAction({ identifier: gTracking + `notify.server`, expire: true })
50
66
  }
51
-
52
67
  setEventEmit({
53
68
  event: `onEventCache`,
54
69
  metadata: bootstrap.cache.events,
@@ -19,15 +19,17 @@
19
19
 
20
20
  import { TypeEvent } from "../@types/type.event";
21
21
  import { bootstrap } from "../bootstrap"
22
+ import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
22
23
  import { rmEvent } from "./manager.rmEvent";
23
24
 
24
25
  export const updateEvents = async (selectedEvent?: TypeEvent): Promise<void> => {
25
26
  const events = bootstrap.cache.events.features;
26
- async function update(evt: TypeEvent) {
27
- if (new Date(evt.properties.expires) < new Date()) {
28
- await rmEvent(evt);
27
+ async function update(event: TypeEvent) {
28
+ if (new Date(event.properties.expires) < new Date()) {
29
+ setEventEmit({ event: `onExpiredProduct`, metadata: event })
30
+ await rmEvent(event, true)
29
31
  }
30
32
  }
31
- if (!selectedEvent) { await Promise.all(events.map(async (evt) => { await update(evt) })) }
33
+ if (!selectedEvent) { await Promise.all(events.map(async (event) => { await update(event) })) }
32
34
  if (selectedEvent) { await update(selectedEvent) }
33
35
  }