@atmosx/event-product-parser 3.0.41 → 3.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -320,6 +320,15 @@ const nodes = getNodes()
320
320
  console.log(nodes)
321
321
  ```
322
322
 
323
+ ### Function `query`
324
+ Queries the event cache (datbase) for specific events based on text.
325
+ ```ts
326
+ import { query } from "@atmosx/event-product-parser"
327
+ query({search: "Tornado Warning", limit: 3}).then(results => {
328
+ console.log(results)
329
+ })
330
+ ````
331
+
323
332
  ### Function `setEasTone`
324
333
  Fetches an EAS audio message for an event (Simulated)
325
334
  ```ts
@@ -10497,6 +10497,7 @@ __export(index_exports, {
10497
10497
  getEvents: () => getEvents,
10498
10498
  getNodes: () => getNodes,
10499
10499
  getRandomEvent: () => getRandomEvent,
10500
+ query: () => query,
10500
10501
  setEasTone: () => setEasTone,
10501
10502
  setNode: () => setNode,
10502
10503
  setSettings: () => setSettings,
@@ -10509,7 +10510,7 @@ module.exports = __toCommonJS(index_exports);
10509
10510
  var import_path = __toESM(require("path"));
10510
10511
  var import_node_events = require("events");
10511
10512
  var bootstrap = {
10512
- version: `3.0.41`,
10513
+ version: `3.0.42`,
10513
10514
  isReady: true,
10514
10515
  ratelimits: {},
10515
10516
  session_xmpp: null,
@@ -14322,7 +14323,7 @@ var officeICAOs = {
14322
14323
  // src/@building/building.office.ts
14323
14324
  var getEventOffice = (options) => {
14324
14325
  var _a, _b, _c, _d, _e, _f, _g;
14325
- const office = options.pVtec != null ? (_b = (_a = options.pVtec) == null ? void 0 : _a.tracking) == null ? void 0 : _b.split(`-`)[0] : (_e = (_c = options.attributes) == null ? void 0 : _c.cccc) != null ? _e : options.organization != null ? Array.isArray(options.organization) ? (_d = options.organization) == null ? void 0 : _d[0] : options.organization : null;
14326
+ const office = options.pVtec != null ? (_b = (_a = options.pVtec) == null ? void 0 : _a.tracking) == null ? void 0 : _b.split(`.`)[0] : (_e = (_c = options.attributes) == null ? void 0 : _c.cccc) != null ? _e : options.organization != null ? Array.isArray(options.organization) ? (_d = options.organization) == null ? void 0 : _d[0] : options.organization : null;
14326
14327
  const name = (_g = (_f = officeICAOs) == null ? void 0 : _f[office]) != null ? _g : null;
14327
14328
  return { office, name };
14328
14329
  };
@@ -14413,7 +14414,7 @@ var properties = (options) => {
14413
14414
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
14414
14415
  const organization = (_b = (_a = options.message.match(regExp.wmo)) == null ? void 0 : _a[0]) != null ? _b : null;
14415
14416
  const polygons = getPolygonFromProduct(options.message);
14416
- return {
14417
+ const properties2 = {
14417
14418
  locations: (_e = (_d = (_c = options == null ? void 0 : options.ugc) == null ? void 0 : _c.locations) == null ? void 0 : _d.join(`; `)) != null ? _e : null,
14418
14419
  description: getDescriptionFromProduct({ message: options.message, handle: (_g = (_f = options == null ? void 0 : options.pVtec) == null ? void 0 : _f.vtec) != null ? _g : null }),
14419
14420
  attributes: options.attributes,
@@ -14459,6 +14460,10 @@ var properties = (options) => {
14459
14460
  pds_watch: getTextFromProduct({ message: options.message, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`
14460
14461
  }
14461
14462
  };
14463
+ if (isNaN(Number(properties2.watch_parameters.watch_number))) {
14464
+ properties2.watch_parameters.watch_number = null;
14465
+ }
14466
+ return properties2;
14462
14467
  };
14463
14468
 
14464
14469
  // src/@building/building.headers.ts
@@ -14492,16 +14497,16 @@ var eventsMatchText = {
14492
14497
  // src/@building/building.tracking.ts
14493
14498
  var getEventTracking = (options) => {
14494
14499
  var _a, _b, _c, _d, _e, _f, _g;
14495
- const proprties = options.properties;
14500
+ const properties2 = options.properties;
14496
14501
  const attributes = options.attributes;
14497
14502
  const stanza = options.stanza;
14498
14503
  const vtec2 = options.vtec;
14499
14504
  if (options.type === `RAW`) {
14500
- const getWatchNumber = (_a = proprties.watch_parameters.watch_number) != null ? _a : null;
14505
+ const getWatchNumber = (_a = properties2.watch_parameters.watch_number) != null ? _a : null;
14501
14506
  if (getWatchNumber) {
14502
- return `${proprties.geocode.office.office}.${stanza.getType.prefix}.A.${getWatchNumber}`;
14507
+ return `${properties2.geocode.office.office}.${stanza.getType.prefix}.A.${getWatchNumber}`;
14503
14508
  }
14504
- return `${proprties.geocode.office.office}.${attributes.ttaaii}.${(_b = attributes.id.slice(-4).replace(`.`, ``)) != null ? _b : "0"}`;
14509
+ return `${properties2.geocode.office.office}.${attributes.ttaaii}.${(_b = attributes.id.slice(-4).replace(`.`, ``)) != null ? _b : "0"}`;
14505
14510
  }
14506
14511
  if (options.type === `VTEC`) {
14507
14512
  return vtec2.tracking;
@@ -14807,7 +14812,7 @@ var createWebhook = (options) => __async(null, null, function* () {
14807
14812
  const settings = options.webhook;
14808
14813
  let body = [
14809
14814
  event.locations ? `**Locations**: ${event.locations.slice(0, 100)}` : null,
14810
- event.issued ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime() / 1e3)}:R>` : null,
14815
+ event.issued && event.status != `Expired` ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime() / 1e3)}:R>` : null,
14811
14816
  event.expires && event.status != `Statement` ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime() / 1e3)}:R>` : null,
14812
14817
  (() => {
14813
14818
  var _a2, _b2;
@@ -14847,10 +14852,10 @@ var createWebhook = (options) => __async(null, null, function* () {
14847
14852
  return (val != null ? val : th) ? `**Sender**: ${val} ${th ? `(${th})` : ""}` : null;
14848
14853
  })(),
14849
14854
  ((_b = event.metadata) == null ? void 0 : _b.tracking) ? `**Tracking**: ${event.metadata.tracking}` : null,
14850
- ((_c = event.metadata.history) == null ? void 0 : _c.length) > 0 ? `**Updates**: ${event.metadata.history.length}` : null,
14855
+ ((_c = event.metadata.history) == null ? void 0 : _c.length) > 0 ? `**Logs**: ${event.metadata.history.length}` : null,
14851
14856
  (() => {
14852
14857
  var _a2;
14853
- if (event.status == `expires`) {
14858
+ if (event.status == `Expired`) {
14854
14859
  return null;
14855
14860
  }
14856
14861
  const desc = ((_a2 = event.description) != null ? _a2 : "").split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
@@ -15120,7 +15125,7 @@ var mkEvent = (event) => __async(null, null, function* () {
15120
15125
  const iHistory = (_o = (_n = (_m = event.properties) == null ? void 0 : _m.metadata) == null ? void 0 : _n.history) != null ? _o : [];
15121
15126
  const iLocations = (_r = (_q = (_p = event.properties) == null ? void 0 : _p.locations) == null ? void 0 : _q.split(";").map((l) => l.trim())) != null ? _r : [];
15122
15127
  const iUgc = (_u = (_t = (_s = event.properties) == null ? void 0 : _s.geocode) == null ? void 0 : _t.ugc) != null ? _u : [];
15123
- const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i);
15128
+ const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i).filter((v, i, a) => a.findIndex((h) => h.description === v.description && h.issued === v.issued) === i);
15124
15129
  const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join("; ");
15125
15130
  const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
15126
15131
  bootstrap.cache.events.features[getIndex] = __spreadProps(__spreadValues({}, event), {
@@ -16654,6 +16659,16 @@ var getRandomEvent = () => {
16654
16659
  return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)];
16655
16660
  };
16656
16661
 
16662
+ // src/@core/core.query.ts
16663
+ var query = (options) => __async(null, null, function* () {
16664
+ var _a;
16665
+ const get = yield bootstrap.database.prepare(
16666
+ `SELECT * FROM stanzas WHERE stanza LIKE ? LIMIT ?`
16667
+ ).all(`%${options.search}%`, (_a = options.max) != null ? _a : 100);
16668
+ const events = get.map((row) => JSON.parse(row.stanza));
16669
+ return events;
16670
+ });
16671
+
16657
16672
  // src/@core/core.clearEvents.ts
16658
16673
  var clearEvents = () => {
16659
16674
  bootstrap.cache.events.features = [];
@@ -16704,6 +16719,7 @@ var index_default = Manager;
16704
16719
  getEvents,
16705
16720
  getNodes,
16706
16721
  getRandomEvent,
16722
+ query,
16707
16723
  setEasTone,
16708
16724
  setNode,
16709
16725
  setSettings,
@@ -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.41`,
10494
+ version: `3.0.42`,
10495
10495
  isReady: true,
10496
10496
  ratelimits: {},
10497
10497
  session_xmpp: null,
@@ -14304,7 +14304,7 @@ var officeICAOs = {
14304
14304
  // src/@building/building.office.ts
14305
14305
  var getEventOffice = (options) => {
14306
14306
  var _a, _b, _c, _d, _e, _f, _g;
14307
- const office = options.pVtec != null ? (_b = (_a = options.pVtec) == null ? void 0 : _a.tracking) == null ? void 0 : _b.split(`-`)[0] : (_e = (_c = options.attributes) == null ? void 0 : _c.cccc) != null ? _e : options.organization != null ? Array.isArray(options.organization) ? (_d = options.organization) == null ? void 0 : _d[0] : options.organization : null;
14307
+ const office = options.pVtec != null ? (_b = (_a = options.pVtec) == null ? void 0 : _a.tracking) == null ? void 0 : _b.split(`.`)[0] : (_e = (_c = options.attributes) == null ? void 0 : _c.cccc) != null ? _e : options.organization != null ? Array.isArray(options.organization) ? (_d = options.organization) == null ? void 0 : _d[0] : options.organization : null;
14308
14308
  const name = (_g = (_f = officeICAOs) == null ? void 0 : _f[office]) != null ? _g : null;
14309
14309
  return { office, name };
14310
14310
  };
@@ -14395,7 +14395,7 @@ var properties = (options) => {
14395
14395
  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;
14396
14396
  const organization = (_b = (_a = options.message.match(regExp.wmo)) == null ? void 0 : _a[0]) != null ? _b : null;
14397
14397
  const polygons = getPolygonFromProduct(options.message);
14398
- return {
14398
+ const properties2 = {
14399
14399
  locations: (_e = (_d = (_c = options == null ? void 0 : options.ugc) == null ? void 0 : _c.locations) == null ? void 0 : _d.join(`; `)) != null ? _e : null,
14400
14400
  description: getDescriptionFromProduct({ message: options.message, handle: (_g = (_f = options == null ? void 0 : options.pVtec) == null ? void 0 : _f.vtec) != null ? _g : null }),
14401
14401
  attributes: options.attributes,
@@ -14441,6 +14441,10 @@ var properties = (options) => {
14441
14441
  pds_watch: getTextFromProduct({ message: options.message, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`
14442
14442
  }
14443
14443
  };
14444
+ if (isNaN(Number(properties2.watch_parameters.watch_number))) {
14445
+ properties2.watch_parameters.watch_number = null;
14446
+ }
14447
+ return properties2;
14444
14448
  };
14445
14449
 
14446
14450
  // src/@building/building.headers.ts
@@ -14474,16 +14478,16 @@ var eventsMatchText = {
14474
14478
  // src/@building/building.tracking.ts
14475
14479
  var getEventTracking = (options) => {
14476
14480
  var _a, _b, _c, _d, _e, _f, _g;
14477
- const proprties = options.properties;
14481
+ const properties2 = options.properties;
14478
14482
  const attributes = options.attributes;
14479
14483
  const stanza = options.stanza;
14480
14484
  const vtec2 = options.vtec;
14481
14485
  if (options.type === `RAW`) {
14482
- const getWatchNumber = (_a = proprties.watch_parameters.watch_number) != null ? _a : null;
14486
+ const getWatchNumber = (_a = properties2.watch_parameters.watch_number) != null ? _a : null;
14483
14487
  if (getWatchNumber) {
14484
- return `${proprties.geocode.office.office}.${stanza.getType.prefix}.A.${getWatchNumber}`;
14488
+ return `${properties2.geocode.office.office}.${stanza.getType.prefix}.A.${getWatchNumber}`;
14485
14489
  }
14486
- return `${proprties.geocode.office.office}.${attributes.ttaaii}.${(_b = attributes.id.slice(-4).replace(`.`, ``)) != null ? _b : "0"}`;
14490
+ return `${properties2.geocode.office.office}.${attributes.ttaaii}.${(_b = attributes.id.slice(-4).replace(`.`, ``)) != null ? _b : "0"}`;
14487
14491
  }
14488
14492
  if (options.type === `VTEC`) {
14489
14493
  return vtec2.tracking;
@@ -14789,7 +14793,7 @@ var createWebhook = (options) => __async(null, null, function* () {
14789
14793
  const settings = options.webhook;
14790
14794
  let body = [
14791
14795
  event.locations ? `**Locations**: ${event.locations.slice(0, 100)}` : null,
14792
- event.issued ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime() / 1e3)}:R>` : null,
14796
+ event.issued && event.status != `Expired` ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime() / 1e3)}:R>` : null,
14793
14797
  event.expires && event.status != `Statement` ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime() / 1e3)}:R>` : null,
14794
14798
  (() => {
14795
14799
  var _a2, _b2;
@@ -14829,10 +14833,10 @@ var createWebhook = (options) => __async(null, null, function* () {
14829
14833
  return (val != null ? val : th) ? `**Sender**: ${val} ${th ? `(${th})` : ""}` : null;
14830
14834
  })(),
14831
14835
  ((_b = event.metadata) == null ? void 0 : _b.tracking) ? `**Tracking**: ${event.metadata.tracking}` : null,
14832
- ((_c = event.metadata.history) == null ? void 0 : _c.length) > 0 ? `**Updates**: ${event.metadata.history.length}` : null,
14836
+ ((_c = event.metadata.history) == null ? void 0 : _c.length) > 0 ? `**Logs**: ${event.metadata.history.length}` : null,
14833
14837
  (() => {
14834
14838
  var _a2;
14835
- if (event.status == `expires`) {
14839
+ if (event.status == `Expired`) {
14836
14840
  return null;
14837
14841
  }
14838
14842
  const desc = ((_a2 = event.description) != null ? _a2 : "").split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
@@ -15102,7 +15106,7 @@ var mkEvent = (event) => __async(null, null, function* () {
15102
15106
  const iHistory = (_o = (_n = (_m = event.properties) == null ? void 0 : _m.metadata) == null ? void 0 : _n.history) != null ? _o : [];
15103
15107
  const iLocations = (_r = (_q = (_p = event.properties) == null ? void 0 : _p.locations) == null ? void 0 : _q.split(";").map((l) => l.trim())) != null ? _r : [];
15104
15108
  const iUgc = (_u = (_t = (_s = event.properties) == null ? void 0 : _s.geocode) == null ? void 0 : _t.ugc) != null ? _u : [];
15105
- const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i);
15109
+ const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i).filter((v, i, a) => a.findIndex((h) => h.description === v.description && h.issued === v.issued) === i);
15106
15110
  const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join("; ");
15107
15111
  const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
15108
15112
  bootstrap.cache.events.features[getIndex] = __spreadProps(__spreadValues({}, event), {
@@ -16636,6 +16640,16 @@ var getRandomEvent = () => {
16636
16640
  return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)];
16637
16641
  };
16638
16642
 
16643
+ // src/@core/core.query.ts
16644
+ var query = (options) => __async(null, null, function* () {
16645
+ var _a;
16646
+ const get = yield bootstrap.database.prepare(
16647
+ `SELECT * FROM stanzas WHERE stanza LIKE ? LIMIT ?`
16648
+ ).all(`%${options.search}%`, (_a = options.max) != null ? _a : 100);
16649
+ const events = get.map((row) => JSON.parse(row.stanza));
16650
+ return events;
16651
+ });
16652
+
16639
16653
  // src/@core/core.clearEvents.ts
16640
16654
  var clearEvents = () => {
16641
16655
  bootstrap.cache.events.features = [];
@@ -16686,6 +16700,7 @@ export {
16686
16700
  getEvents,
16687
16701
  getNodes,
16688
16702
  getRandomEvent,
16703
+ query,
16689
16704
  setEasTone,
16690
16705
  setNode,
16691
16706
  setSettings,
package/dist/index.d.mts CHANGED
@@ -212,7 +212,7 @@ interface GenerateEASOptions {
212
212
  }
213
213
  declare const setEasTone: (options: GenerateEASOptions) => Promise<string>;
214
214
 
215
- interface GetAddChaserOptions {
215
+ interface GetNodeOptions {
216
216
  identifier: string;
217
217
  delete?: boolean;
218
218
  coordinates: {
@@ -220,7 +220,7 @@ interface GetAddChaserOptions {
220
220
  latitude: number;
221
221
  };
222
222
  }
223
- declare const setNode: (options: GetAddChaserOptions) => void;
223
+ declare const setNode: (options: GetNodeOptions) => void;
224
224
 
225
225
  declare const getEvents: () => any;
226
226
 
@@ -228,6 +228,31 @@ declare const getNodes: () => any;
228
228
 
229
229
  declare const getRandomEvent: () => any;
230
230
 
231
+ type TypeStanza = {
232
+ getChild(arg0: string): unknown;
233
+ is(arg0: string): unknown;
234
+ name: string;
235
+ parent: TypeStanza | null;
236
+ children: any;
237
+ attrs: {
238
+ xmlns: string;
239
+ id: string;
240
+ issue: string;
241
+ ttaaii: string;
242
+ cccc: string;
243
+ awipsid: string;
244
+ from: string;
245
+ to: string;
246
+ type: string;
247
+ };
248
+ };
249
+
250
+ interface QueryOptions {
251
+ search: string;
252
+ max?: number;
253
+ }
254
+ declare const query: (options: QueryOptions) => Promise<TypeStanza[]>;
255
+
231
256
  declare const clearEvents: () => void;
232
257
 
233
258
  declare class Manager {
@@ -236,4 +261,4 @@ declare class Manager {
236
261
  trycatch(): void;
237
262
  }
238
263
 
239
- export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
264
+ export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, query, setEasTone, setNode, setSettings, startService, stopService };
package/dist/index.d.ts CHANGED
@@ -212,7 +212,7 @@ interface GenerateEASOptions {
212
212
  }
213
213
  declare const setEasTone: (options: GenerateEASOptions) => Promise<string>;
214
214
 
215
- interface GetAddChaserOptions {
215
+ interface GetNodeOptions {
216
216
  identifier: string;
217
217
  delete?: boolean;
218
218
  coordinates: {
@@ -220,7 +220,7 @@ interface GetAddChaserOptions {
220
220
  latitude: number;
221
221
  };
222
222
  }
223
- declare const setNode: (options: GetAddChaserOptions) => void;
223
+ declare const setNode: (options: GetNodeOptions) => void;
224
224
 
225
225
  declare const getEvents: () => any;
226
226
 
@@ -228,6 +228,31 @@ declare const getNodes: () => any;
228
228
 
229
229
  declare const getRandomEvent: () => any;
230
230
 
231
+ type TypeStanza = {
232
+ getChild(arg0: string): unknown;
233
+ is(arg0: string): unknown;
234
+ name: string;
235
+ parent: TypeStanza | null;
236
+ children: any;
237
+ attrs: {
238
+ xmlns: string;
239
+ id: string;
240
+ issue: string;
241
+ ttaaii: string;
242
+ cccc: string;
243
+ awipsid: string;
244
+ from: string;
245
+ to: string;
246
+ type: string;
247
+ };
248
+ };
249
+
250
+ interface QueryOptions {
251
+ search: string;
252
+ max?: number;
253
+ }
254
+ declare const query: (options: QueryOptions) => Promise<TypeStanza[]>;
255
+
231
256
  declare const clearEvents: () => void;
232
257
 
233
258
  declare class Manager {
@@ -236,4 +261,4 @@ declare class Manager {
236
261
  trycatch(): void;
237
262
  }
238
263
 
239
- export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
264
+ export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, query, 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.41",
3
+ "version": "3.0.42",
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",
@@ -34,7 +34,7 @@ interface GetOfficeResponse {
34
34
 
35
35
  export const getEventOffice = (options: GetOfficeOptions): GetOfficeResponse => {
36
36
  const office = options.pVtec != null
37
- ? options.pVtec?.tracking?.split(`-`)[0] : (options.attributes?.cccc ??
37
+ ? options.pVtec?.tracking?.split(`.`)[0] : (options.attributes?.cccc ??
38
38
  (options.organization != null ?
39
39
  (Array.isArray(options.organization) ? options.organization?.[0] : options.organization)
40
40
  : null));
@@ -40,7 +40,7 @@ interface GetPropertiesOptions {
40
40
  export const properties = (options: GetPropertiesOptions): TypeEventProperties => {
41
41
  const organization = options.message.match(regExp.wmo)?.[0] ?? null
42
42
  const polygons = getPolygonFromProduct(options.message)
43
- return {
43
+ const properties = {
44
44
  locations: options?.ugc?.locations?.join(`; `) ?? null,
45
45
  description: getDescriptionFromProduct({ message: options.message, handle: options?.pVtec?.vtec ?? null }),
46
46
  attributes: options.attributes,
@@ -86,4 +86,8 @@ export const properties = (options: GetPropertiesOptions): TypeEventProperties =
86
86
  pds_watch: (getTextFromProduct({ message: options.message, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`)
87
87
  }
88
88
  }
89
+ if (isNaN(Number(properties.watch_parameters.watch_number))) {
90
+ properties.watch_parameters.watch_number = null
91
+ }
92
+ return properties;
89
93
  }
@@ -35,16 +35,16 @@ interface GetTrackingOptions {
35
35
  }
36
36
 
37
37
  export const getEventTracking = (options: GetTrackingOptions): string => {
38
- const proprties = options.properties
38
+ const properties = options.properties
39
39
  const attributes = options.attributes
40
40
  const stanza = options.stanza
41
41
  const vtec = options.vtec
42
42
  if (options.type === `RAW`) {
43
- const getWatchNumber = proprties.watch_parameters.watch_number ?? null
43
+ const getWatchNumber = properties.watch_parameters.watch_number ?? null
44
44
  if (getWatchNumber) {
45
- return `${proprties.geocode.office.office}.${stanza.getType.prefix}.A.${getWatchNumber}`
45
+ return `${properties.geocode.office.office}.${stanza.getType.prefix}.A.${getWatchNumber}`
46
46
  }
47
- return `${proprties.geocode.office.office}.${attributes.ttaaii}.${attributes.id.slice(-4).replace(`.`, ``) ?? '0'}`
47
+ return `${properties.geocode.office.office}.${attributes.ttaaii}.${attributes.id.slice(-4).replace(`.`, ``) ?? '0'}`
48
48
  }
49
49
  if (options.type === `VTEC`) {
50
50
  return vtec.tracking;
@@ -0,0 +1,39 @@
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 { TypeStanza } from "../@types/types.stanza";
21
+ import { bootstrap } from "../bootstrap";
22
+
23
+ interface QueryOptions {
24
+ search: string
25
+ max?: number
26
+ }
27
+
28
+ type RowQuery = {
29
+ rowid: number
30
+ stanza: string
31
+ }
32
+
33
+ export const query = async (options: QueryOptions): Promise<TypeStanza[]> => {
34
+ const get = await bootstrap.database.prepare(
35
+ `SELECT * FROM stanzas WHERE stanza LIKE ? LIMIT ?`)
36
+ .all(`%${options.search}%`, options.max ?? 100) as RowQuery[];
37
+ const events = get.map((row) => JSON.parse(row.stanza));
38
+ return events as TypeStanza[];
39
+ }
@@ -21,13 +21,13 @@ import { bootstrap } from "../bootstrap";
21
21
  import { setWarning } from "../@modules/@utilities/utilities.setWarning"
22
22
  import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
23
23
 
24
- interface GetAddChaserOptions {
24
+ interface GetNodeOptions {
25
25
  identifier: string
26
26
  delete?: boolean
27
27
  coordinates: { longitude: number; latitude: number }
28
28
  }
29
29
 
30
- export const setNode = (options: GetAddChaserOptions) => {
30
+ export const setNode = (options: GetNodeOptions) => {
31
31
  const nodes = bootstrap.cache.nodes.features;
32
32
  const exists = nodes.find((node) => node.properties.identifier === options.identifier);
33
33
  if (options.delete) {
@@ -35,7 +35,7 @@ export const createWebhook = async (options: CreateWebhookOptions): Promise<void
35
35
 
36
36
  let body = [
37
37
  event.locations ? `**Locations**: ${event.locations.slice(0,100)}` : null,
38
- event.issued ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime()/1000)}:R>` : null,
38
+ event.issued && event.status != `Expired` ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime()/1000)}:R>` : null,
39
39
  event.expires && event.status != `Statement` ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime()/1000)}:R>` : null,
40
40
  (() => {
41
41
  const val = event.parameters.estimated_wind_gusts ?? null
@@ -72,9 +72,9 @@ export const createWebhook = async (options: CreateWebhookOptions): Promise<void
72
72
  return (val ?? th) ? `**Sender**: ${val} ${th ? `(${th})` : ''}` : null;
73
73
  })(),
74
74
  event.metadata?.tracking ? `**Tracking**: ${event.metadata.tracking}` : null,
75
- event.metadata.history?.length > 0 ? `**Updates**: ${event.metadata.history.length}` : null,
75
+ event.metadata.history?.length > 0 ? `**Logs**: ${event.metadata.history.length}` : null,
76
76
  (() => {
77
- if (event.status == `expires`) { return null }
77
+ if (event.status == `Expired`) { return null }
78
78
  const desc = (event.description ?? '').split('\n').map(l => l.trim()).filter(Boolean).join('\n');
79
79
  return desc ? '```' + '\n' + desc + '\n' + '```' : null;
80
80
  })(),
@@ -36,6 +36,7 @@ export const mkEvent = async (event: TypeEvent): Promise<void> => {
36
36
  const getFeature = features.find(feature => feature.properties.metadata.tracking === getTracking);
37
37
  if (isHashed || event.properties.status_metadata.is_expired) return
38
38
  setHash(event, isEntry)
39
+
39
40
  const isFilteredLocation = await updateNode(event).then(() => event.properties.metadata.filtered_proximity);
40
41
  if (!isFilteredLocation && settings.GlobalSettings.EventFiltering.NodeLocationFiltering) { return }
41
42
 
@@ -59,7 +60,7 @@ export const mkEvent = async (event: TypeEvent): Promise<void> => {
59
60
  const iLocations = event.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
60
61
  const iUgc = event.properties?.geocode?.ugc ?? [];
61
62
 
62
- const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i);
63
+ const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i).filter((v, i, a) => a.findIndex(h => h.description === v.description && h.issued === v.issued) === i);
63
64
  const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join('; ');
64
65
  const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
65
66
 
@@ -22,7 +22,6 @@ import { TypeEvent } from "../@types/type.event";
22
22
  import { TypeWebhook } from "../@types/types.webhook";
23
23
  import { bootstrap } from "../bootstrap"
24
24
 
25
-
26
25
  export const updateWebhooks = async (event: TypeEvent): Promise<void> => {
27
26
  const settings = bootstrap.settings;
28
27
  const webhooks = settings.WebhookSettings as TypeWebhook[];
package/src/bootstrap.ts CHANGED
@@ -21,7 +21,7 @@ import path from 'path'
21
21
  import { EventEmitter } from 'node:events';
22
22
 
23
23
  export const bootstrap = {
24
- version: `3.0.41`,
24
+ version: `3.0.42`,
25
25
  isReady: true,
26
26
  ratelimits: {},
27
27
  session_xmpp: null,
package/src/index.ts CHANGED
@@ -31,6 +31,7 @@ import { setNode } from "./@core/core.setNode"
31
31
  import { getEvents } from "./@core/core.getEvents"
32
32
  import { getNodes } from "./@core/core.getNodes"
33
33
  import { getRandomEvent } from './@core/core.getRandomEvent';
34
+ import { query } from './@core/core.query';
34
35
  import { clearEvents } from './@core/core.clearEvents';
35
36
 
36
37
  export class Manager {
@@ -66,7 +67,7 @@ export {
66
67
  setSettings, getEventGeometry,
67
68
  getCleanedEvent, stopService, clearEvents,
68
69
  startService, setNode, getRandomEvent,
69
- getEvents, getNodes, setEasTone
70
+ getEvents, getNodes, setEasTone, query
70
71
  }
71
72
 
72
73