@atmosx/event-product-parser 3.0.1 → 3.0.2
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 +8 -0
- package/dist/cjs/index.cjs +69 -29
- package/dist/esm/index.mjs +68 -29
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/package.json +1 -1
- package/src/@building/building.signature.ts +2 -1
- package/src/@core/core.clearEvents.ts +32 -0
- package/src/@core/{core.listener.ts → core.createListener.ts} +1 -1
- package/src/@core/core.start.ts +4 -2
- package/src/@dictionaries/dictionaries.statusCorrelationText.ts +13 -11
- package/src/@events/events.text.ts +4 -2
- package/src/@events/events.ugc.ts +2 -2
- package/src/@manager/manager.rmEvent.ts +4 -1
- package/src/@manager/manager.updateEvents.ts +35 -0
- package/src/@types/type.event.ts +1 -0
- package/src/bootstrap.ts +1 -1
- package/src/index.ts +5 -4
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ const Client = new Manager({
|
|
|
66
66
|
DisableGeometryParsing: false,
|
|
67
67
|
UseShapefileCoordinates: true,
|
|
68
68
|
SPCWatchesOnly: true,
|
|
69
|
+
ShapefileSkipPoints: 0,
|
|
69
70
|
NodeTTL: 60,
|
|
70
71
|
NodeMinDistance: 120,
|
|
71
72
|
EventFiltering: {
|
|
@@ -132,6 +133,7 @@ const Client = new Manager({
|
|
|
132
133
|
- **DisableGeometryParsing**: Disable automatically appending GeoJSON geometry data to the events to save on memory consumption.
|
|
133
134
|
- **UseShapefileCoordinates**: Whether to use the shapefile database to obtain the coordinates for events with specified UGC zones.
|
|
134
135
|
- **SPCWatchesOnly**: Whether to only listen for SPC watches only (TOR/SVR) (If using the API, this is ignored).
|
|
136
|
+
- **ShapefileSkipPoints**: When using the shapefile database to obtain coordinates, you can choose to skip a certain amount of points to reduce the number of coordinates for large events. (Ex. If an event has 1000 coordinates and you set this to `2`, it will only use every other coordinate, therefore using 500 coordinates instead of 1000).
|
|
135
137
|
- **NodeTTL**: How often nodes should be checked per event. (Tracking/Filtering)
|
|
136
138
|
- **NodeMinDistance**: The minimum distance to filter events from the node (Miles)
|
|
137
139
|
- **ListeningEvents**: Events you'd like to listen for. If this array is left empty, it will listen for **ALL** events and products.
|
|
@@ -290,6 +292,12 @@ const events = getEvents() // Returns in GeoJSON (Similar to the onEventCache li
|
|
|
290
292
|
console.log(events)
|
|
291
293
|
```
|
|
292
294
|
|
|
295
|
+
### Function `clearEvents`
|
|
296
|
+
Clears the event cache of all events.
|
|
297
|
+
```ts
|
|
298
|
+
import { clearEvents } from "@atmosx/event-product-parser"
|
|
299
|
+
clearEvents() // Clears the event cache of all events.
|
|
300
|
+
```
|
|
293
301
|
|
|
294
302
|
### Function `getNodes`
|
|
295
303
|
Fetches the list of tracking nodes from the parser.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -10490,6 +10490,7 @@ var require_form_data = __commonJS({
|
|
|
10490
10490
|
var index_exports = {};
|
|
10491
10491
|
__export(index_exports, {
|
|
10492
10492
|
Manager: () => Manager,
|
|
10493
|
+
clearEvents: () => clearEvents,
|
|
10493
10494
|
default: () => index_default,
|
|
10494
10495
|
getCleanedEvent: () => getCleanedEvent,
|
|
10495
10496
|
getEventGeometry: () => getEventGeometry,
|
|
@@ -10508,7 +10509,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
10508
10509
|
var import_path = __toESM(require("path"));
|
|
10509
10510
|
var import_node_events = require("events");
|
|
10510
10511
|
var bootstrap = {
|
|
10511
|
-
version: `3.0.
|
|
10512
|
+
version: `3.0.2`,
|
|
10512
10513
|
isReady: true,
|
|
10513
10514
|
ratelimits: {},
|
|
10514
10515
|
session_xmpp: null,
|
|
@@ -10790,8 +10791,8 @@ var setListener = (options) => {
|
|
|
10790
10791
|
};
|
|
10791
10792
|
};
|
|
10792
10793
|
|
|
10793
|
-
// src/@core/core.
|
|
10794
|
-
var
|
|
10794
|
+
// src/@core/core.createListener.ts
|
|
10795
|
+
var createListener = (event, callback) => {
|
|
10795
10796
|
setListener({ event, callback });
|
|
10796
10797
|
};
|
|
10797
10798
|
|
|
@@ -10901,14 +10902,14 @@ function Deferred() {
|
|
|
10901
10902
|
function procedure(entity, stanza = null, handler) {
|
|
10902
10903
|
return new Promise((resolve6, reject) => {
|
|
10903
10904
|
function onError(err) {
|
|
10904
|
-
entity.removeListener("nonza",
|
|
10905
|
+
entity.removeListener("nonza", listener2);
|
|
10905
10906
|
reject(err);
|
|
10906
10907
|
}
|
|
10907
10908
|
function done(...args) {
|
|
10908
|
-
entity.removeListener("nonza",
|
|
10909
|
+
entity.removeListener("nonza", listener2);
|
|
10909
10910
|
resolve6(...args);
|
|
10910
10911
|
}
|
|
10911
|
-
function
|
|
10912
|
+
function listener2(element) {
|
|
10912
10913
|
return __async(this, null, function* () {
|
|
10913
10914
|
try {
|
|
10914
10915
|
yield handler(element, done);
|
|
@@ -10918,7 +10919,7 @@ function procedure(entity, stanza = null, handler) {
|
|
|
10918
10919
|
});
|
|
10919
10920
|
}
|
|
10920
10921
|
stanza && entity.send(stanza).catch(onError);
|
|
10921
|
-
entity.on("nonza",
|
|
10922
|
+
entity.on("nonza", listener2);
|
|
10922
10923
|
});
|
|
10923
10924
|
}
|
|
10924
10925
|
|
|
@@ -12062,7 +12063,7 @@ var OutgoingContext = class extends Context {
|
|
|
12062
12063
|
};
|
|
12063
12064
|
|
|
12064
12065
|
// node_modules/@xmpp/middleware/index.js
|
|
12065
|
-
function
|
|
12066
|
+
function listener(entity, middleware2, Context2) {
|
|
12066
12067
|
return (stanza) => {
|
|
12067
12068
|
const ctx = new Context2(entity, stanza);
|
|
12068
12069
|
return (0, import_koa_compose.default)(middleware2)(ctx);
|
|
@@ -12076,8 +12077,8 @@ function errorHandler(entity) {
|
|
|
12076
12077
|
function middleware({ entity }) {
|
|
12077
12078
|
const incoming = [errorHandler(entity)];
|
|
12078
12079
|
const outgoing = [];
|
|
12079
|
-
const incomingListener =
|
|
12080
|
-
const outgoingListener =
|
|
12080
|
+
const incomingListener = listener(entity, incoming, IncomingContext);
|
|
12081
|
+
const outgoingListener = listener(entity, outgoing, OutgoingContext);
|
|
12081
12082
|
entity.on("element", incomingListener);
|
|
12082
12083
|
entity.on("send", outgoingListener);
|
|
12083
12084
|
return {
|
|
@@ -14608,17 +14609,18 @@ var getEventEnhancedName = (event) => {
|
|
|
14608
14609
|
|
|
14609
14610
|
// src/@dictionaries/dictionaries.statusCorrelationText.ts
|
|
14610
14611
|
var statusCorrelationText = [
|
|
14611
|
-
{ type: "
|
|
14612
|
-
{ type: "
|
|
14613
|
-
{ type: "
|
|
14614
|
-
{ type: "
|
|
14615
|
-
{ type: "
|
|
14616
|
-
{ type: "
|
|
14617
|
-
{ type: "
|
|
14618
|
-
{ type: "
|
|
14619
|
-
{ type: "
|
|
14620
|
-
{ type: "
|
|
14621
|
-
{ type: "
|
|
14612
|
+
{ type: "Statement", name: "Statement", isCancel: false, isUpdate: false, isIssued: true, isStatement: true },
|
|
14613
|
+
{ type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14614
|
+
{ type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
|
|
14615
|
+
{ type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false },
|
|
14616
|
+
{ type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14617
|
+
{ type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
|
|
14618
|
+
{ type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false },
|
|
14619
|
+
{ type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14620
|
+
{ type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14621
|
+
{ type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14622
|
+
{ type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
|
|
14623
|
+
{ type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false, isStatement: false }
|
|
14622
14624
|
];
|
|
14623
14625
|
|
|
14624
14626
|
// src/@dictionaries/dictionaries.eventCancelMessages.ts
|
|
@@ -14678,7 +14680,7 @@ var getEventSignature = (event) => {
|
|
|
14678
14680
|
}
|
|
14679
14681
|
if (status) {
|
|
14680
14682
|
properties2.status = (_d = status.name) != null ? _d : properties2.status;
|
|
14681
|
-
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel });
|
|
14683
|
+
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel, is_statement: !!status.isStatement });
|
|
14682
14684
|
}
|
|
14683
14685
|
if (csig) {
|
|
14684
14686
|
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_expired: true });
|
|
@@ -15106,6 +15108,9 @@ var rmEvent = (event) => {
|
|
|
15106
15108
|
var _a, _b, _c, _d;
|
|
15107
15109
|
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);
|
|
15108
15110
|
});
|
|
15111
|
+
const cachedStatus = event.properties.status;
|
|
15112
|
+
event.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
|
|
15113
|
+
event.properties.status = `Expired`;
|
|
15109
15114
|
if (getEvent) {
|
|
15110
15115
|
setEventEmit({
|
|
15111
15116
|
event: `onEventStatus`,
|
|
@@ -15116,7 +15121,7 @@ var rmEvent = (event) => {
|
|
|
15116
15121
|
message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
|
|
15117
15122
|
});
|
|
15118
15123
|
setEventEmit({ event: `onExpiredProduct`, metadata: event });
|
|
15119
|
-
updateWebhooks(event);
|
|
15124
|
+
if (cachedStatus != `Statement`) updateWebhooks(event);
|
|
15120
15125
|
bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
|
|
15121
15126
|
bootstrap.cache.hashes = bootstrap.cache.hashes.filter((hash) => hash.tracking !== event.properties.metadata.tracking);
|
|
15122
15127
|
}
|
|
@@ -15256,8 +15261,10 @@ var text = (stanza) => __async(null, null, function* () {
|
|
|
15256
15261
|
const issued = new Date(attributes.issue);
|
|
15257
15262
|
const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1e3);
|
|
15258
15263
|
let event = Object.keys(eventsOffshore).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
|
|
15264
|
+
let isStatement = false;
|
|
15259
15265
|
if (!event) {
|
|
15260
15266
|
event = stanza.getType.type.split(`-`).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `);
|
|
15267
|
+
isStatement = true;
|
|
15261
15268
|
}
|
|
15262
15269
|
processed.push({
|
|
15263
15270
|
type: `Feature`,
|
|
@@ -15268,9 +15275,9 @@ var text = (stanza) => __async(null, null, function* () {
|
|
|
15268
15275
|
properties: __spreadProps(__spreadValues({
|
|
15269
15276
|
event,
|
|
15270
15277
|
parent: event,
|
|
15271
|
-
status: `Issued`,
|
|
15278
|
+
status: isStatement ? `Statement` : `Issued`,
|
|
15272
15279
|
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15273
|
-
expires: !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15280
|
+
expires: isStatement ? new Date(issued.getTime() + 5 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15274
15281
|
}, props), {
|
|
15275
15282
|
metadata: {
|
|
15276
15283
|
ms: performance.now() - tick,
|
|
@@ -15387,7 +15394,7 @@ var ugc = (stanza) => __async(null, null, function* () {
|
|
|
15387
15394
|
if (ugc2 != null) {
|
|
15388
15395
|
const props = properties({ message, attributes, ugc: ugc2 });
|
|
15389
15396
|
const issued = new Date(attributes.issue);
|
|
15390
|
-
const expires = new Date(
|
|
15397
|
+
const expires = new Date(ugc2.expires).toISOString();
|
|
15391
15398
|
const header = getEventHeader({ properties: props, getType: stanza.getType });
|
|
15392
15399
|
let event = Object.keys(eventsOffshore).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
|
|
15393
15400
|
if (!event) {
|
|
@@ -15404,7 +15411,7 @@ var ugc = (stanza) => __async(null, null, function* () {
|
|
|
15404
15411
|
parent: event,
|
|
15405
15412
|
status: `Issued`,
|
|
15406
15413
|
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15407
|
-
expires: !isNaN(expires.getTime()) ? expires
|
|
15414
|
+
expires: !isNaN(new Date(ugc2.expires).getTime()) ? expires : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15408
15415
|
}, props), {
|
|
15409
15416
|
metadata: {
|
|
15410
15417
|
ms: performance.now() - tick,
|
|
@@ -16079,6 +16086,26 @@ var setCronSchedule = () => __async(null, null, function* () {
|
|
|
16079
16086
|
}
|
|
16080
16087
|
});
|
|
16081
16088
|
|
|
16089
|
+
// src/@manager/manager.updateEvents.ts
|
|
16090
|
+
var updateEvents = (selectedEvent) => __async(null, null, function* () {
|
|
16091
|
+
const events = bootstrap.cache.events.features;
|
|
16092
|
+
function update(evt) {
|
|
16093
|
+
return __async(this, null, function* () {
|
|
16094
|
+
if (new Date(evt.properties.expires) < /* @__PURE__ */ new Date()) {
|
|
16095
|
+
rmEvent(evt);
|
|
16096
|
+
}
|
|
16097
|
+
});
|
|
16098
|
+
}
|
|
16099
|
+
if (!selectedEvent) {
|
|
16100
|
+
yield Promise.all(events.map((evt) => __async(null, null, function* () {
|
|
16101
|
+
yield update(evt);
|
|
16102
|
+
})));
|
|
16103
|
+
}
|
|
16104
|
+
if (selectedEvent) {
|
|
16105
|
+
yield update(selectedEvent);
|
|
16106
|
+
}
|
|
16107
|
+
});
|
|
16108
|
+
|
|
16082
16109
|
// src/@core/core.start.ts
|
|
16083
16110
|
var import_croner = require("croner");
|
|
16084
16111
|
var startService = (settings) => __async(null, null, function* () {
|
|
@@ -16106,8 +16133,9 @@ var startService = (settings) => __async(null, null, function* () {
|
|
|
16106
16133
|
bootstrap.cron = new import_croner.Cron(`*/${scheduleInterval} * * * * *`, () => __async(null, null, function* () {
|
|
16107
16134
|
yield setCronSchedule();
|
|
16108
16135
|
}));
|
|
16109
|
-
bootstrap.cron = new import_croner.Cron(
|
|
16136
|
+
bootstrap.cron = new import_croner.Cron(`* * * * * *`, () => __async(null, null, function* () {
|
|
16110
16137
|
yield updateNode();
|
|
16138
|
+
yield updateEvents();
|
|
16111
16139
|
}));
|
|
16112
16140
|
});
|
|
16113
16141
|
|
|
@@ -16583,6 +16611,17 @@ var getRandomEvent = () => {
|
|
|
16583
16611
|
return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)];
|
|
16584
16612
|
};
|
|
16585
16613
|
|
|
16614
|
+
// src/@core/core.clearEvents.ts
|
|
16615
|
+
var clearEvents = () => {
|
|
16616
|
+
bootstrap.cache.events.features = [];
|
|
16617
|
+
bootstrap.cache.hashes = [];
|
|
16618
|
+
setEventEmit({
|
|
16619
|
+
event: `onEventCache`,
|
|
16620
|
+
metadata: bootstrap.cache.events,
|
|
16621
|
+
message: `Manually cleared event cache.`
|
|
16622
|
+
});
|
|
16623
|
+
};
|
|
16624
|
+
|
|
16586
16625
|
// src/index.ts
|
|
16587
16626
|
var Manager = class {
|
|
16588
16627
|
constructor(settings) {
|
|
@@ -16590,7 +16629,7 @@ var Manager = class {
|
|
|
16590
16629
|
startService(settings);
|
|
16591
16630
|
}
|
|
16592
16631
|
on(event, callback) {
|
|
16593
|
-
|
|
16632
|
+
createListener(event, callback);
|
|
16594
16633
|
}
|
|
16595
16634
|
trycatch() {
|
|
16596
16635
|
process.on("uncaughtException", (err) => {
|
|
@@ -16616,6 +16655,7 @@ var index_default = Manager;
|
|
|
16616
16655
|
// Annotate the CommonJS export names for ESM import in node:
|
|
16617
16656
|
0 && (module.exports = {
|
|
16618
16657
|
Manager,
|
|
16658
|
+
clearEvents,
|
|
16619
16659
|
getCleanedEvent,
|
|
16620
16660
|
getEventGeometry,
|
|
16621
16661
|
getEvents,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -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.
|
|
10494
|
+
version: `3.0.2`,
|
|
10495
10495
|
isReady: true,
|
|
10496
10496
|
ratelimits: {},
|
|
10497
10497
|
session_xmpp: null,
|
|
@@ -10773,8 +10773,8 @@ var setListener = (options) => {
|
|
|
10773
10773
|
};
|
|
10774
10774
|
};
|
|
10775
10775
|
|
|
10776
|
-
// src/@core/core.
|
|
10777
|
-
var
|
|
10776
|
+
// src/@core/core.createListener.ts
|
|
10777
|
+
var createListener = (event, callback) => {
|
|
10778
10778
|
setListener({ event, callback });
|
|
10779
10779
|
};
|
|
10780
10780
|
|
|
@@ -10884,14 +10884,14 @@ function Deferred() {
|
|
|
10884
10884
|
function procedure(entity, stanza = null, handler) {
|
|
10885
10885
|
return new Promise((resolve6, reject) => {
|
|
10886
10886
|
function onError(err) {
|
|
10887
|
-
entity.removeListener("nonza",
|
|
10887
|
+
entity.removeListener("nonza", listener2);
|
|
10888
10888
|
reject(err);
|
|
10889
10889
|
}
|
|
10890
10890
|
function done(...args) {
|
|
10891
|
-
entity.removeListener("nonza",
|
|
10891
|
+
entity.removeListener("nonza", listener2);
|
|
10892
10892
|
resolve6(...args);
|
|
10893
10893
|
}
|
|
10894
|
-
function
|
|
10894
|
+
function listener2(element) {
|
|
10895
10895
|
return __async(this, null, function* () {
|
|
10896
10896
|
try {
|
|
10897
10897
|
yield handler(element, done);
|
|
@@ -10901,7 +10901,7 @@ function procedure(entity, stanza = null, handler) {
|
|
|
10901
10901
|
});
|
|
10902
10902
|
}
|
|
10903
10903
|
stanza && entity.send(stanza).catch(onError);
|
|
10904
|
-
entity.on("nonza",
|
|
10904
|
+
entity.on("nonza", listener2);
|
|
10905
10905
|
});
|
|
10906
10906
|
}
|
|
10907
10907
|
|
|
@@ -12045,7 +12045,7 @@ var OutgoingContext = class extends Context {
|
|
|
12045
12045
|
};
|
|
12046
12046
|
|
|
12047
12047
|
// node_modules/@xmpp/middleware/index.js
|
|
12048
|
-
function
|
|
12048
|
+
function listener(entity, middleware2, Context2) {
|
|
12049
12049
|
return (stanza) => {
|
|
12050
12050
|
const ctx = new Context2(entity, stanza);
|
|
12051
12051
|
return (0, import_koa_compose.default)(middleware2)(ctx);
|
|
@@ -12059,8 +12059,8 @@ function errorHandler(entity) {
|
|
|
12059
12059
|
function middleware({ entity }) {
|
|
12060
12060
|
const incoming = [errorHandler(entity)];
|
|
12061
12061
|
const outgoing = [];
|
|
12062
|
-
const incomingListener =
|
|
12063
|
-
const outgoingListener =
|
|
12062
|
+
const incomingListener = listener(entity, incoming, IncomingContext);
|
|
12063
|
+
const outgoingListener = listener(entity, outgoing, OutgoingContext);
|
|
12064
12064
|
entity.on("element", incomingListener);
|
|
12065
12065
|
entity.on("send", outgoingListener);
|
|
12066
12066
|
return {
|
|
@@ -14591,17 +14591,18 @@ var getEventEnhancedName = (event) => {
|
|
|
14591
14591
|
|
|
14592
14592
|
// src/@dictionaries/dictionaries.statusCorrelationText.ts
|
|
14593
14593
|
var statusCorrelationText = [
|
|
14594
|
-
{ type: "
|
|
14595
|
-
{ type: "
|
|
14596
|
-
{ type: "
|
|
14597
|
-
{ type: "
|
|
14598
|
-
{ type: "
|
|
14599
|
-
{ type: "
|
|
14600
|
-
{ type: "
|
|
14601
|
-
{ type: "
|
|
14602
|
-
{ type: "
|
|
14603
|
-
{ type: "
|
|
14604
|
-
{ type: "
|
|
14594
|
+
{ type: "Statement", name: "Statement", isCancel: false, isUpdate: false, isIssued: true, isStatement: true },
|
|
14595
|
+
{ type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14596
|
+
{ type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
|
|
14597
|
+
{ type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false },
|
|
14598
|
+
{ type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14599
|
+
{ type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
|
|
14600
|
+
{ type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false },
|
|
14601
|
+
{ type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14602
|
+
{ type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14603
|
+
{ type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false, isStatement: false },
|
|
14604
|
+
{ type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false },
|
|
14605
|
+
{ type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false, isStatement: false }
|
|
14605
14606
|
];
|
|
14606
14607
|
|
|
14607
14608
|
// src/@dictionaries/dictionaries.eventCancelMessages.ts
|
|
@@ -14661,7 +14662,7 @@ var getEventSignature = (event) => {
|
|
|
14661
14662
|
}
|
|
14662
14663
|
if (status) {
|
|
14663
14664
|
properties2.status = (_d = status.name) != null ? _d : properties2.status;
|
|
14664
|
-
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel });
|
|
14665
|
+
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel, is_statement: !!status.isStatement });
|
|
14665
14666
|
}
|
|
14666
14667
|
if (csig) {
|
|
14667
14668
|
properties2.status_metadata = __spreadProps(__spreadValues({}, properties2.status_metadata), { is_expired: true });
|
|
@@ -15089,6 +15090,9 @@ var rmEvent = (event) => {
|
|
|
15089
15090
|
var _a, _b, _c, _d;
|
|
15090
15091
|
return ((_b = (_a = f == null ? void 0 : f.properties) == null ? void 0 : _a.metadata) == null ? void 0 : _b.tracking) === ((_d = (_c = event == null ? void 0 : event.properties) == null ? void 0 : _c.metadata) == null ? void 0 : _d.tracking);
|
|
15091
15092
|
});
|
|
15093
|
+
const cachedStatus = event.properties.status;
|
|
15094
|
+
event.properties.expires = (/* @__PURE__ */ new Date()).toISOString();
|
|
15095
|
+
event.properties.status = `Expired`;
|
|
15092
15096
|
if (getEvent) {
|
|
15093
15097
|
setEventEmit({
|
|
15094
15098
|
event: `onEventStatus`,
|
|
@@ -15099,7 +15103,7 @@ var rmEvent = (event) => {
|
|
|
15099
15103
|
message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
|
|
15100
15104
|
});
|
|
15101
15105
|
setEventEmit({ event: `onExpiredProduct`, metadata: event });
|
|
15102
|
-
updateWebhooks(event);
|
|
15106
|
+
if (cachedStatus != `Statement`) updateWebhooks(event);
|
|
15103
15107
|
bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
|
|
15104
15108
|
bootstrap.cache.hashes = bootstrap.cache.hashes.filter((hash) => hash.tracking !== event.properties.metadata.tracking);
|
|
15105
15109
|
}
|
|
@@ -15239,8 +15243,10 @@ var text = (stanza) => __async(null, null, function* () {
|
|
|
15239
15243
|
const issued = new Date(attributes.issue);
|
|
15240
15244
|
const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1e3);
|
|
15241
15245
|
let event = Object.keys(eventsOffshore).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
|
|
15246
|
+
let isStatement = false;
|
|
15242
15247
|
if (!event) {
|
|
15243
15248
|
event = stanza.getType.type.split(`-`).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `);
|
|
15249
|
+
isStatement = true;
|
|
15244
15250
|
}
|
|
15245
15251
|
processed.push({
|
|
15246
15252
|
type: `Feature`,
|
|
@@ -15251,9 +15257,9 @@ var text = (stanza) => __async(null, null, function* () {
|
|
|
15251
15257
|
properties: __spreadProps(__spreadValues({
|
|
15252
15258
|
event,
|
|
15253
15259
|
parent: event,
|
|
15254
|
-
status: `Issued`,
|
|
15260
|
+
status: isStatement ? `Statement` : `Issued`,
|
|
15255
15261
|
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15256
|
-
expires: !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15262
|
+
expires: isStatement ? new Date(issued.getTime() + 5 * 1e3).toISOString() : !isNaN(expires.getTime()) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15257
15263
|
}, props), {
|
|
15258
15264
|
metadata: {
|
|
15259
15265
|
ms: performance.now() - tick,
|
|
@@ -15370,7 +15376,7 @@ var ugc = (stanza) => __async(null, null, function* () {
|
|
|
15370
15376
|
if (ugc2 != null) {
|
|
15371
15377
|
const props = properties({ message, attributes, ugc: ugc2 });
|
|
15372
15378
|
const issued = new Date(attributes.issue);
|
|
15373
|
-
const expires = new Date(
|
|
15379
|
+
const expires = new Date(ugc2.expires).toISOString();
|
|
15374
15380
|
const header = getEventHeader({ properties: props, getType: stanza.getType });
|
|
15375
15381
|
let event = Object.keys(eventsOffshore).find((event2) => message.toLowerCase().includes(event2.toLowerCase()));
|
|
15376
15382
|
if (!event) {
|
|
@@ -15387,7 +15393,7 @@ var ugc = (stanza) => __async(null, null, function* () {
|
|
|
15387
15393
|
parent: event,
|
|
15388
15394
|
status: `Issued`,
|
|
15389
15395
|
issued: !isNaN(issued.getTime()) ? issued.toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
15390
|
-
expires: !isNaN(expires.getTime()) ? expires
|
|
15396
|
+
expires: !isNaN(new Date(ugc2.expires).getTime()) ? expires : new Date(Date.now() + 60 * 60 * 1e3).toISOString()
|
|
15391
15397
|
}, props), {
|
|
15392
15398
|
metadata: {
|
|
15393
15399
|
ms: performance.now() - tick,
|
|
@@ -16062,6 +16068,26 @@ var setCronSchedule = () => __async(null, null, function* () {
|
|
|
16062
16068
|
}
|
|
16063
16069
|
});
|
|
16064
16070
|
|
|
16071
|
+
// src/@manager/manager.updateEvents.ts
|
|
16072
|
+
var updateEvents = (selectedEvent) => __async(null, null, function* () {
|
|
16073
|
+
const events = bootstrap.cache.events.features;
|
|
16074
|
+
function update(evt) {
|
|
16075
|
+
return __async(this, null, function* () {
|
|
16076
|
+
if (new Date(evt.properties.expires) < /* @__PURE__ */ new Date()) {
|
|
16077
|
+
rmEvent(evt);
|
|
16078
|
+
}
|
|
16079
|
+
});
|
|
16080
|
+
}
|
|
16081
|
+
if (!selectedEvent) {
|
|
16082
|
+
yield Promise.all(events.map((evt) => __async(null, null, function* () {
|
|
16083
|
+
yield update(evt);
|
|
16084
|
+
})));
|
|
16085
|
+
}
|
|
16086
|
+
if (selectedEvent) {
|
|
16087
|
+
yield update(selectedEvent);
|
|
16088
|
+
}
|
|
16089
|
+
});
|
|
16090
|
+
|
|
16065
16091
|
// src/@core/core.start.ts
|
|
16066
16092
|
import { Cron } from "croner";
|
|
16067
16093
|
var startService = (settings) => __async(null, null, function* () {
|
|
@@ -16089,8 +16115,9 @@ var startService = (settings) => __async(null, null, function* () {
|
|
|
16089
16115
|
bootstrap.cron = new Cron(`*/${scheduleInterval} * * * * *`, () => __async(null, null, function* () {
|
|
16090
16116
|
yield setCronSchedule();
|
|
16091
16117
|
}));
|
|
16092
|
-
bootstrap.cron = new Cron(
|
|
16118
|
+
bootstrap.cron = new Cron(`* * * * * *`, () => __async(null, null, function* () {
|
|
16093
16119
|
yield updateNode();
|
|
16120
|
+
yield updateEvents();
|
|
16094
16121
|
}));
|
|
16095
16122
|
});
|
|
16096
16123
|
|
|
@@ -16566,6 +16593,17 @@ var getRandomEvent = () => {
|
|
|
16566
16593
|
return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)];
|
|
16567
16594
|
};
|
|
16568
16595
|
|
|
16596
|
+
// src/@core/core.clearEvents.ts
|
|
16597
|
+
var clearEvents = () => {
|
|
16598
|
+
bootstrap.cache.events.features = [];
|
|
16599
|
+
bootstrap.cache.hashes = [];
|
|
16600
|
+
setEventEmit({
|
|
16601
|
+
event: `onEventCache`,
|
|
16602
|
+
metadata: bootstrap.cache.events,
|
|
16603
|
+
message: `Manually cleared event cache.`
|
|
16604
|
+
});
|
|
16605
|
+
};
|
|
16606
|
+
|
|
16569
16607
|
// src/index.ts
|
|
16570
16608
|
var Manager = class {
|
|
16571
16609
|
constructor(settings) {
|
|
@@ -16573,7 +16611,7 @@ var Manager = class {
|
|
|
16573
16611
|
startService(settings);
|
|
16574
16612
|
}
|
|
16575
16613
|
on(event, callback) {
|
|
16576
|
-
|
|
16614
|
+
createListener(event, callback);
|
|
16577
16615
|
}
|
|
16578
16616
|
trycatch() {
|
|
16579
16617
|
process.on("uncaughtException", (err) => {
|
|
@@ -16598,6 +16636,7 @@ var Manager = class {
|
|
|
16598
16636
|
var index_default = Manager;
|
|
16599
16637
|
export {
|
|
16600
16638
|
Manager,
|
|
16639
|
+
clearEvents,
|
|
16601
16640
|
index_default as default,
|
|
16602
16641
|
getCleanedEvent,
|
|
16603
16642
|
getEventGeometry,
|
package/dist/index.d.mts
CHANGED
|
@@ -164,6 +164,7 @@ type TypeEvent = {
|
|
|
164
164
|
is_updated?: boolean;
|
|
165
165
|
is_expired?: boolean;
|
|
166
166
|
is_test?: boolean;
|
|
167
|
+
is_statement?: boolean;
|
|
167
168
|
};
|
|
168
169
|
metadata: {
|
|
169
170
|
ms: number;
|
|
@@ -226,10 +227,12 @@ declare const getNodes: () => any;
|
|
|
226
227
|
|
|
227
228
|
declare const getRandomEvent: () => any;
|
|
228
229
|
|
|
230
|
+
declare const clearEvents: () => void;
|
|
231
|
+
|
|
229
232
|
declare class Manager {
|
|
230
233
|
constructor(settings: TypeSettings);
|
|
231
234
|
on(event: string, callback: () => void): void;
|
|
232
235
|
trycatch(): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
|
-
export { Manager, type TypeEvent, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
|
|
238
|
+
export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
|
package/dist/index.d.ts
CHANGED
|
@@ -164,6 +164,7 @@ type TypeEvent = {
|
|
|
164
164
|
is_updated?: boolean;
|
|
165
165
|
is_expired?: boolean;
|
|
166
166
|
is_test?: boolean;
|
|
167
|
+
is_statement?: boolean;
|
|
167
168
|
};
|
|
168
169
|
metadata: {
|
|
169
170
|
ms: number;
|
|
@@ -226,10 +227,12 @@ declare const getNodes: () => any;
|
|
|
226
227
|
|
|
227
228
|
declare const getRandomEvent: () => any;
|
|
228
229
|
|
|
230
|
+
declare const clearEvents: () => void;
|
|
231
|
+
|
|
229
232
|
declare class Manager {
|
|
230
233
|
constructor(settings: TypeSettings);
|
|
231
234
|
on(event: string, callback: () => void): void;
|
|
232
235
|
trycatch(): void;
|
|
233
236
|
}
|
|
234
237
|
|
|
235
|
-
export { Manager, type TypeEvent, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
|
|
238
|
+
export { Manager, type TypeEvent, clearEvents, Manager as default, getCleanedEvent, getEventGeometry, getEvents, getNodes, getRandomEvent, setEasTone, setNode, setSettings, startService, stopService };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atmosx/event-product-parser",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "NOAA Weather Wire & NWS API Parser - Built for standalone and Project AtmosphericX Integration.",
|
|
5
5
|
"main": "dist/cjs/index.cjs",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -39,11 +39,12 @@ export const getEventSignature = (event: TypeEvent): TypeEvent => {
|
|
|
39
39
|
|
|
40
40
|
if (status) {
|
|
41
41
|
properties.status = status.name ?? properties.status;
|
|
42
|
-
properties.status_metadata = { ...properties.status_metadata, is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel };
|
|
42
|
+
properties.status_metadata = { ...properties.status_metadata, is_updated: !!status.isUpdate, is_issued: !!status.isIssued, is_expired: !!status.isCancel, is_statement: !!status.isStatement };
|
|
43
43
|
}
|
|
44
44
|
if (csig) {
|
|
45
45
|
properties.status_metadata = { ...properties.status_metadata, is_expired: true };
|
|
46
46
|
}
|
|
47
|
+
|
|
47
48
|
const getProduct = vtec?.vtec?.split(`.`)[0]?.replace(`/`, ``)
|
|
48
49
|
const isTestProduct = eventProducts[getProduct] == `Test Product`
|
|
49
50
|
if (isTestProduct || testSignatures.some(sig => properties.description?.toLowerCase().includes(sig.toLowerCase()) || properties?.parameters?.instructions?.toLowerCase().includes(sig.toLowerCase()))) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ _ _ __ __
|
|
3
|
+
/\ | | | | (_) \ \ / /
|
|
4
|
+
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
+
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
+
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
+
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
+
| |
|
|
9
|
+
|_|
|
|
10
|
+
|
|
11
|
+
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
+
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
+
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
+
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Internal Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { bootstrap } from "../bootstrap";
|
|
21
|
+
import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export const clearEvents = (): void => {
|
|
25
|
+
bootstrap.cache.events.features = [];
|
|
26
|
+
bootstrap.cache.hashes = [];
|
|
27
|
+
setEventEmit({
|
|
28
|
+
event: `onEventCache`,
|
|
29
|
+
metadata: bootstrap.cache.events,
|
|
30
|
+
message: `Manually cleared event cache.`
|
|
31
|
+
})
|
|
32
|
+
}
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
import { setListener } from "../@modules/@utilities/utilities.setListener";
|
|
21
21
|
|
|
22
|
-
export const
|
|
22
|
+
export const createListener = (event: string, callback: () => void) => {
|
|
23
23
|
setListener({event, callback})
|
|
24
24
|
}
|
package/src/@core/core.start.ts
CHANGED
|
@@ -25,8 +25,9 @@ import { xDeploy } from "../@modules/@xmpp/xmpp.xDeploy"
|
|
|
25
25
|
import { initializeDatabase } from "../@modules/@database/database.init";
|
|
26
26
|
import { getCachedEvents } from "../@modules/@database/database.cache";
|
|
27
27
|
import { setCronSchedule } from "../@modules/@utilities/utilities.setCronSchedule";
|
|
28
|
-
import { Cron } from "croner";
|
|
29
28
|
import { updateNode } from "../@manager/manager.updateNodes";
|
|
29
|
+
import { updateEvents } from "../@manager/manager.updateEvents";
|
|
30
|
+
import { Cron } from "croner";
|
|
30
31
|
|
|
31
32
|
export const startService = async (settings: TypeSettings): Promise<void> => {
|
|
32
33
|
if (!bootstrap.isReady) {
|
|
@@ -53,7 +54,8 @@ export const startService = async (settings: TypeSettings): Promise<void> => {
|
|
|
53
54
|
bootstrap.cron = new Cron(`*/${scheduleInterval} * * * * *`, async () => {
|
|
54
55
|
await setCronSchedule();
|
|
55
56
|
})
|
|
56
|
-
bootstrap.cron = new Cron(
|
|
57
|
+
bootstrap.cron = new Cron(`* * * * * *`, async () => {
|
|
57
58
|
await updateNode();
|
|
59
|
+
await updateEvents();
|
|
58
60
|
})
|
|
59
61
|
}
|
|
@@ -23,18 +23,20 @@ type TypeCorrelations = {
|
|
|
23
23
|
isCancel: boolean
|
|
24
24
|
isUpdate: boolean
|
|
25
25
|
isIssued: boolean
|
|
26
|
+
isStatement: boolean
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export const statusCorrelationText: TypeCorrelations[] = [
|
|
29
|
-
{type: "
|
|
30
|
-
{type: "
|
|
31
|
-
{type: "
|
|
32
|
-
{type: "
|
|
33
|
-
{type: "
|
|
34
|
-
{type: "
|
|
35
|
-
{type: "
|
|
36
|
-
{type: "
|
|
37
|
-
{type: "
|
|
38
|
-
{type: "
|
|
39
|
-
{type: "
|
|
30
|
+
{type: "Statement", name: "Statement", isCancel: false, isUpdate: false, isIssued: true, isStatement: true},
|
|
31
|
+
{type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
|
|
32
|
+
{type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false},
|
|
33
|
+
{type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false},
|
|
34
|
+
{type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
|
|
35
|
+
{type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false, isStatement: false},
|
|
36
|
+
{type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true, isStatement: false},
|
|
37
|
+
{type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
|
|
38
|
+
{type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
|
|
39
|
+
{type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
|
|
40
|
+
{type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false, isStatement: false},
|
|
41
|
+
{type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false, isStatement: false},
|
|
40
42
|
]
|
|
@@ -41,8 +41,10 @@ export const text = async (stanza: TypeStanzaCompiled): Promise<void> => {
|
|
|
41
41
|
const issued = new Date(attributes.issue)
|
|
42
42
|
const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1000)
|
|
43
43
|
let event = Object.keys(eventsOffshore).find(event => message.toLowerCase().includes(event.toLowerCase()));
|
|
44
|
+
let isStatement = false;
|
|
44
45
|
if (!event) {
|
|
45
46
|
event = stanza.getType.type.split(`-`).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `)
|
|
47
|
+
isStatement = true;
|
|
46
48
|
}
|
|
47
49
|
processed.push({
|
|
48
50
|
type: `Feature`,
|
|
@@ -53,9 +55,9 @@ export const text = async (stanza: TypeStanzaCompiled): Promise<void> => {
|
|
|
53
55
|
properties: {
|
|
54
56
|
event: event,
|
|
55
57
|
parent: event,
|
|
56
|
-
status: `Issued`,
|
|
58
|
+
status: isStatement ? `Statement` : `Issued`,
|
|
57
59
|
issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
|
|
58
|
-
expires: (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
|
|
60
|
+
expires: isStatement ? new Date(issued.getTime() + 5 * 1000).toISOString() : (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
|
|
59
61
|
...props,
|
|
60
62
|
metadata: {
|
|
61
63
|
ms: performance.now() - tick,
|
|
@@ -41,7 +41,7 @@ export const ugc = async (stanza: TypeStanzaCompiled): Promise<void> => {
|
|
|
41
41
|
if (ugc != null ) {
|
|
42
42
|
const props = properties({ message, attributes, ugc: ugc })
|
|
43
43
|
const issued = new Date(attributes.issue)
|
|
44
|
-
const expires = new Date(
|
|
44
|
+
const expires = new Date(ugc.expires).toISOString()
|
|
45
45
|
const header = getEventHeader({properties: props, getType: stanza.getType })
|
|
46
46
|
let event = Object.keys(eventsOffshore).find(event => message.toLowerCase().includes(event.toLowerCase()));
|
|
47
47
|
if (!event) {
|
|
@@ -58,7 +58,7 @@ export const ugc = async (stanza: TypeStanzaCompiled): Promise<void> => {
|
|
|
58
58
|
parent: event,
|
|
59
59
|
status: `Issued`,
|
|
60
60
|
issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
|
|
61
|
-
expires: (!isNaN(expires.getTime())) ? expires
|
|
61
|
+
expires: (!isNaN(new Date(ugc.expires).getTime())) ? expires : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
|
|
62
62
|
...props,
|
|
63
63
|
metadata: {
|
|
64
64
|
ms: performance.now() - tick,
|
|
@@ -24,6 +24,9 @@ import { updateWebhooks } from "./manager.updateWebhooks";
|
|
|
24
24
|
|
|
25
25
|
export const rmEvent = (event: TypeEvent): void => {
|
|
26
26
|
const getEvent = bootstrap.cache.events.features.find(f => f?.properties?.metadata?.tracking === event?.properties?.metadata?.tracking);
|
|
27
|
+
const cachedStatus = event.properties.status;
|
|
28
|
+
event.properties.expires = new Date().toISOString();
|
|
29
|
+
event.properties.status = `Expired`;
|
|
27
30
|
if (getEvent) {
|
|
28
31
|
setEventEmit({
|
|
29
32
|
event: `onEventStatus`,
|
|
@@ -34,7 +37,7 @@ export const rmEvent = (event: TypeEvent): void => {
|
|
|
34
37
|
message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
|
|
35
38
|
})
|
|
36
39
|
setEventEmit({ event: `onExpiredProduct`, metadata: event })
|
|
37
|
-
updateWebhooks(event)
|
|
40
|
+
if (cachedStatus != `Statement`) updateWebhooks(event)
|
|
38
41
|
bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
|
|
39
42
|
bootstrap.cache.hashes = bootstrap.cache.hashes.filter(hash => hash.tracking !== event.properties.metadata.tracking);
|
|
40
43
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { getFormattedTime } from "../@modules/@utilities/utilities.getFormattedTime";
|
|
21
|
+
import { TypeEvent } from "../@types/type.event";
|
|
22
|
+
import { bootstrap } from "../bootstrap"
|
|
23
|
+
import { rmEvent } from "./manager.rmEvent";
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export const updateEvents = async (selectedEvent?: TypeEvent): Promise<void> => {
|
|
27
|
+
const events = bootstrap.cache.events.features;
|
|
28
|
+
async function update(evt: TypeEvent) {
|
|
29
|
+
if (new Date(evt.properties.expires) < new Date()) {
|
|
30
|
+
rmEvent(evt);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (!selectedEvent) { await Promise.all(events.map(async (evt) => { await update(evt) })) }
|
|
34
|
+
if (selectedEvent) { await update(selectedEvent) }
|
|
35
|
+
}
|
package/src/@types/type.event.ts
CHANGED
package/src/bootstrap.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { getEventGeometry } from "./@building/building.geometry";
|
|
|
23
23
|
import { getCleanedEvent } from "./@building/building.clean"
|
|
24
24
|
import { setEventEmit } from './@modules/@utilities/utilities.setEventEmit';
|
|
25
25
|
import { setWarning } from './@modules/@utilities/utilities.setWarning';
|
|
26
|
-
import {
|
|
26
|
+
import { createListener } from "./@core/core.createListener"
|
|
27
27
|
import { startService } from "./@core/core.start"
|
|
28
28
|
import { stopService } from "./@core/core.stop"
|
|
29
29
|
import { setEasTone } from './@modules/@eas/eas.setEasTone';
|
|
@@ -31,12 +31,13 @@ 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 { clearEvents } from './@core/core.clearEvents';
|
|
34
35
|
|
|
35
36
|
export class Manager {
|
|
36
37
|
constructor(settings: TypeSettings) { this.trycatch(); startService(settings) }
|
|
37
38
|
|
|
38
39
|
on(event: string, callback: () => void) {
|
|
39
|
-
|
|
40
|
+
createListener(event, callback)
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
trycatch() {
|
|
@@ -62,8 +63,8 @@ export class Manager {
|
|
|
62
63
|
export default Manager;
|
|
63
64
|
export type { TypeEvent } from './@types/type.event';
|
|
64
65
|
export {
|
|
65
|
-
setSettings, getEventGeometry,
|
|
66
|
-
getCleanedEvent, stopService,
|
|
66
|
+
setSettings, getEventGeometry,
|
|
67
|
+
getCleanedEvent, stopService, clearEvents,
|
|
67
68
|
startService, setNode, getRandomEvent,
|
|
68
69
|
getEvents, getNodes, setEasTone
|
|
69
70
|
}
|