@atmosx/event-product-parser 3.0.4 → 3.0.6
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/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
- package/.github/README.md +163 -0
- package/.github/SUPPORTED_EVENTS.md +370 -0
- package/.github/docs/docs-functions.md +30 -0
- package/.github/docs/docs-general-configurations.md +209 -0
- package/.github/docs/docs-integrations.md +37 -0
- package/.github/docs/docs-listeners.md +28 -0
- package/.github/docs/docs-source-configuration.md +218 -0
- package/.github/docs/docs-technical.md +50 -0
- package/.github/logo.png +0 -0
- package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
- package/.github/samples/SAMPLE_GEOJSON.json +204 -0
- package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
- package/dist/cjs/index.cjs +4677 -13422
- package/dist/esm/index.mjs +3159 -11906
- package/package.json +3 -9
- package/src/@building/{building.create.ts → CreateEvent.ts} +25 -11
- package/src/@building/{building.clean.ts → GetCleanedEvent.ts} +2 -2
- package/src/@building/GetEventAttachments.ts +86 -0
- package/src/@building/{building.enhance.ts → GetEventEnhancedName.ts} +11 -12
- package/src/@building/{building.geometry.ts → GetEventGeometry.ts} +7 -7
- package/src/@building/{building.headers.ts → GetEventHeader.ts} +3 -3
- package/src/@building/{building.polygon.ts → GetEventNodes.ts} +13 -11
- package/src/@building/{building.office.ts → GetEventOffice.ts} +6 -6
- package/src/@building/GetEventProperties.ts +96 -0
- package/src/@building/{building.signature.ts → GetEventSignature.ts} +14 -15
- package/src/@building/{building.tags.ts → GetEventTags.ts} +9 -4
- package/src/@building/{building.tracking.ts → GetEventTracking.ts} +15 -15
- package/src/@building/{building.validate.ts → ValidateEvents.ts} +67 -60
- package/src/@core/{core.clearEvents.ts → ClearEvents.ts} +3 -4
- package/src/@core/{core.createListener.ts → CreateListener.ts} +3 -3
- package/src/@core/{core.getEvents.ts → GetEvents.ts} +1 -2
- package/src/@core/{core.getNodes.ts → GetNodes.ts} +1 -2
- package/src/@core/{core.getRandomEvent.ts → GetRandomEvent.ts} +1 -2
- package/src/@core/{core.getVersion.ts → GetVersion.ts} +1 -2
- package/src/@core/ManualEvent.ts +56 -0
- package/src/@core/QueryStanza.ts +39 -0
- package/src/@core/{core.setNode.ts → SetNode.ts} +8 -8
- package/src/@core/{core.start.ts → StartService.ts} +21 -21
- package/src/@core/{core.stop.ts → StopService.ts} +1 -1
- package/src/@enums/AWIPS.ts +366 -0
- package/src/{@dictionaries/dictionaries.eventActions.ts → @enums/Actions.ts} +1 -1
- package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → @enums/Cancellation.ts} +2 -1
- package/src/{@dictionaries/dictionaries.eventCauses.ts → @enums/Causes.ts} +1 -1
- package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → @enums/Correlations.ts} +1 -1
- package/src/@enums/Enhanced.ts +70 -0
- package/src/{@dictionaries/dictionaries.eventTypes.ts → @enums/Events.ts} +1 -1
- package/src/{@dictionaries/dictionaries.regExp.ts → @enums/Expressions.ts} +2 -1
- package/src/@enums/GlobalFilter.ts +24 -0
- package/src/{@dictionaries/dictionaries.hailStrings.ts → @enums/Hail.ts} +7 -2
- package/src/{@dictionaries/dictionaries.officeICAOs.ts → @enums/ICAO.ts} +3 -1
- package/src/@enums/Matches.ts +55 -0
- package/src/{@dictionaries/dictionaries.eventProducts.ts → @enums/Products.ts} +1 -1
- package/src/{@dictionaries/dictionaries.eventRecords.ts → @enums/Records.ts} +1 -1
- package/src/{@dictionaries/dictionaries.eventSeverity.ts → @enums/Severity.ts} +1 -1
- package/src/{@dictionaries/dictionaries.shapefileLinks.ts → @enums/Shapefiles.ts} +1 -1
- package/src/@enums/States.ts +72 -0
- package/src/{@dictionaries/dictionaries.eventStatus.ts → @enums/Status.ts} +1 -1
- package/src/@enums/Strings.ts +22 -0
- package/src/@enums/Tags.ts +167 -0
- package/src/{@dictionaries/dictionaries.testSignatures.ts → @enums/Testing.ts} +3 -2
- package/src/@events/{events.api.ts → ParseAPI.ts} +42 -38
- package/src/@events/{events.text.ts → ParseText.ts} +25 -18
- package/src/@events/{events.ugc.ts → ParseUGC.ts} +28 -19
- package/src/@events/{events.vtec.ts → ParseVTEC.ts} +21 -21
- package/src/@manager/CreateActions.ts +213 -0
- package/src/@manager/{manager.mkEvent.ts → MakeEvent.ts} +34 -31
- package/src/@manager/RemoveEvent.ts +70 -0
- package/src/@manager/{manager.setHash.ts → SetHash.ts} +8 -9
- package/src/@manager/{manager.updateEvents.ts → UpdateEvents.ts} +9 -9
- package/src/@manager/{manager.updateNodes.ts → UpdateNode.ts} +24 -17
- package/src/@modules/@database/{database.cache.ts → GetCachedEvents.ts} +10 -8
- package/src/@modules/@database/ImportBroadcastify.ts +70 -0
- package/src/@modules/@database/{database.shapefiles.ts → ImportShapefiles.ts} +17 -20
- package/src/@modules/@database/{database.stanza.ts → ImportStanza.ts} +5 -6
- package/src/@modules/@database/{database.init.ts → InitializeDatabase.ts} +25 -11
- package/src/@modules/@eas/GenerateEASMessage.ts +144 -0
- package/src/@modules/@eas/GetCleanDescription.ts +91 -0
- package/src/@modules/@eas/{eas.getFloatPCM16.ts → GetFloatPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.getMergedPCM16.ts → GetMergedPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.getPCM16.ts → GetPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.getPCMToFloat.ts → GetPCMToFloat.ts} +1 -1
- package/src/@modules/@eas/{eas.getSampledPCM16.ts → GetSampledPCM16.ts} +1 -1
- package/src/@modules/@eas/GetTTS.ts +54 -0
- package/src/@modules/@eas/{eas.getWavPCM16.ts → GetWavPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.setAFSK.ts → SetAFSK.ts} +1 -2
- package/src/@modules/@eas/{eas.setAsciiToBits.ts → SetAsciiToBits.ts} +1 -2
- package/src/@modules/@eas/{eas.setAttentionTone.ts → SetAttentionTone.ts} +1 -1
- package/src/@modules/@eas/{eas.setNoise.ts → SetNoise.ts} +6 -5
- package/src/@modules/@eas/{eas.setRadioEffect.ts → SetRadioEffect.ts} +6 -5
- package/src/@modules/@eas/{eas.setSameHeader.ts → SetSameHeader.ts} +7 -8
- package/src/@modules/@stanza/{stanza.getAwipsType.ts → GetAwipsType.ts} +11 -9
- package/src/@modules/@stanza/{stanza.validate.ts → ValidateStanza.ts} +9 -9
- package/src/@modules/@utilities/CreateHttp.ts +83 -0
- package/src/@modules/@utilities/{utilities.getFormattedTime.ts → GetFormattedTime.ts} +1 -1
- package/src/@modules/@utilities/GetLatestIssuance.ts +32 -0
- package/src/@modules/@utilities/GetMatched.ts +33 -0
- package/src/@modules/@utilities/{utilities.getSettings.ts → GetSettings.ts} +2 -2
- package/src/@modules/@utilities/{utilities.getShapeNearestPoint.ts → GetShapeNearestPoint.ts} +1 -1
- package/src/@modules/@utilities/{utilities.setCronSchedule.ts → SetCronSchedule.ts} +41 -12
- package/src/{@types/types.webhook.ts → @modules/@utilities/SetDebug.ts} +16 -6
- package/src/@modules/@utilities/{utilities.setEventEmit.ts → SetEventEmit.ts} +5 -5
- package/src/@modules/@utilities/{utilities.setListener.ts → SetListener.ts} +1 -1
- package/src/@modules/@utilities/{utilities.setSettings.ts → SetSettings.ts} +2 -2
- package/src/@modules/@utilities/{utilities.setSleep.ts → SetSleep.ts} +1 -1
- package/src/@modules/@utilities/{utilities.setTimeoutAction.ts → SetTimeoutAction.ts} +8 -3
- package/src/@modules/@utilities/{utilities.setWarning.ts → SetWarning.ts} +2 -2
- package/src/@modules/@xmpp/{xmpp.xDeploy.ts → DeployXMPP.ts} +13 -14
- package/src/@modules/@xmpp/{xmpp.xError.ts → ErrorXMPP.ts} +1 -3
- package/src/@modules/@xmpp/{xmpp.xOffline.ts → OfflineXMPP.ts} +3 -4
- package/src/@modules/@xmpp/{xmpp.xOnline.ts → OnlineXMPP.ts} +6 -5
- package/src/@modules/@xmpp/{xmpp.xReconnect.ts → ReconnectXMPP.ts} +8 -8
- package/src/@modules/@xmpp/{xmpp.xStanza.ts → StanzaXMPP.ts} +11 -11
- package/src/@parsers/@hvtec/{hvtec.extract.ts → HVExtract.ts} +10 -10
- package/src/@parsers/@pvtec/{pvtec.expires.ts → GetExpiry.ts} +1 -1
- package/src/@parsers/@pvtec/{pvtec.extract.ts → VTECExtract.ts} +17 -17
- package/src/@parsers/@text/{text.getDescriptionFromProduct.ts → GetDescriptionFromProduct.ts} +12 -5
- package/src/@parsers/@text/GetEmbededText.ts +56 -0
- package/src/@parsers/@text/{text.getPolygonFromProduct.ts → GetPolygonFromProduct.ts} +31 -10
- package/src/@parsers/@text/GetStringText.ts +58 -0
- package/src/@parsers/@text/{text.getTextFromProduct.ts → GetTextFromProduct.ts} +1 -1
- package/src/@parsers/@text/{text.getXML.ts → GetXML.ts} +1 -1
- package/src/@parsers/@ugc/GetCache.ts +24 -0
- package/src/@parsers/@ugc/{ugc.expiry.ts → GetExpiry.ts} +1 -1
- package/src/@parsers/@ugc/{ugc.locations.ts → GetLocations.ts} +35 -7
- package/src/@parsers/@ugc/{ugc.header.ts → GetUGCHeader.ts} +3 -3
- package/src/@parsers/@ugc/{ugc.coordinates.ts → GetZonePolygon.ts} +4 -3
- package/src/@parsers/@ugc/SetCache.ts +28 -0
- package/src/@parsers/@ugc/{ugc.extract.ts → UGCExtract.ts} +6 -6
- package/src/@types/Actions.ts +37 -0
- package/src/@types/{type.event.ts → Event.ts} +7 -5
- package/src/@types/{type.properties.ts → Properties.ts} +11 -8
- package/src/@types/{types.settings.ts → Settings.ts} +31 -7
- package/src/@types/{types.compiled.ts → StanzaCompiled.ts} +2 -1
- package/src/bootstrap.ts +33 -9
- package/src/index.ts +26 -24
- package/tsup.config.ts +1 -1
- package/README.md +0 -349
- package/dist/index.d.mts +0 -239
- package/dist/index.d.ts +0 -239
- package/src/@building/building.properties.ts +0 -89
- package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
- package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
- package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
- package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
- package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
- package/src/@manager/manager.rmEvent.ts +0 -49
- package/src/@manager/manager.updateWebhooks.ts +0 -50
- package/src/@modules/@eas/eas.setEasTone.ts +0 -137
- package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
- package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
- package/test.js +0 -91
- /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
- /package/{LICENSE → .github/LICENSE} +0 -0
- /package/{SECURITY.md → .github/SECURITY.md} +0 -0
- /package/src/@parsers/@ugc/{ugc.zones.ts → GetZones.ts} +0 -0
- /package/src/@types/{types.attributes.ts → Attributes.ts} +0 -0
- /package/src/@types/{types.hvtec.ts → HVTEC.ts} +0 -0
- /package/src/@types/{types.hash.ts → Hash.ts} +0 -0
- /package/src/@types/{types.stanza.ts → Stanza.ts} +0 -0
- /package/src/@types/{types.ugc.ts → UGC.ts} +0 -0
- /package/src/@types/{types.pvtec.ts → VTEC.ts} +0 -0
|
@@ -17,20 +17,23 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { TypeSettings } from "../@types/types.settings";
|
|
20
|
+
import { TypeEvent } from "../@types/Event";
|
|
21
|
+
import { TypeSettings } from "../@types/Settings";
|
|
23
22
|
import { bootstrap } from "../bootstrap"
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
23
|
+
import { GetEventEnhancedName } from "./GetEventEnhancedName";
|
|
24
|
+
import { GetEventSignature } from "./GetEventSignature"
|
|
25
|
+
import { MakeEvent } from "../@manager/MakeEvent";
|
|
26
|
+
import { RemoveEvent } from "../@manager/RemoveEvent";
|
|
27
|
+
import { GetEventAttachments } from "./GetEventAttachments";
|
|
28
|
+
import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
|
|
29
|
+
import { SetDebug } from "../@modules/@utilities/SetDebug";
|
|
30
|
+
import { GetMatched } from "../@modules/@utilities/GetMatched";
|
|
31
|
+
import { GetEventGeometry } from "./GetEventGeometry";
|
|
32
|
+
import { createHash } from "crypto"
|
|
31
33
|
|
|
32
|
-
export const
|
|
33
|
-
|
|
34
|
+
export const ValidateEvents = async (events: TypeEvent[]): Promise<void> => {
|
|
35
|
+
const tick = performance.now();
|
|
36
|
+
if (events.length === 0) return
|
|
34
37
|
const configurations = bootstrap.settings as TypeSettings
|
|
35
38
|
const sets = {} as Record<string, Set<string>>;
|
|
36
39
|
const bools = {} as Record<string, boolean>;
|
|
@@ -40,108 +43,112 @@ export const validateEvents = async (events: TypeEvent[]): Promise<void> => {
|
|
|
40
43
|
if (Array.isArray(setting)) { sets[key] = new Set(setting.map(item => item.toLowerCase())); }
|
|
41
44
|
if (typeof setting === 'boolean') { bools[key] = setting; }
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
|
|
47
|
+
const isFiltered = (define: TypeEvent): boolean => {
|
|
45
48
|
const properties = define.properties;
|
|
46
49
|
const zones = properties.geocode.ugc;
|
|
47
50
|
const icao = properties.geocode.office.office
|
|
48
|
-
|
|
49
|
-
const filteredProperties = JSON.parse(JSON.stringify(properties)) as typeof properties;
|
|
50
|
-
if (filteredProperties?.metadata && 'ms' in filteredProperties.metadata) {
|
|
51
|
-
delete filteredProperties.metadata.ms;
|
|
52
|
-
}
|
|
53
|
-
filteredProperties.metadata = filteredProperties.metadata ?? {} as any;
|
|
54
|
-
filteredProperties.metadata.hash = createHash("sha256").update(JSON.stringify(filteredProperties)).digest("hex")
|
|
55
|
-
|
|
56
|
-
setEventEmit({ event: `onProductType${enhancedEventName.replace(/\s+/g, '')}`, metadata: define });
|
|
57
|
-
|
|
51
|
+
|
|
58
52
|
if (properties.status_metadata.is_test) {
|
|
59
|
-
|
|
60
|
-
if (bools?.IgnoreTestProducts) return
|
|
53
|
+
SetEventEmit({ event: `onTestProduct`, metadata: define })
|
|
54
|
+
if (bools?.IgnoreTestProducts) return true;
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
if (properties.status_metadata.is_expired) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
58
|
+
SetEventEmit({ event: `onExpiredProduct`, metadata: define })
|
|
59
|
+
RemoveEvent(define, false)
|
|
60
|
+
return true;
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
if (properties.metadata?.vtec?.is_watch) {
|
|
63
|
+
if (properties.metadata?.vtec?.is_watch && properties.metadata.source != `events.api`) {
|
|
70
64
|
const isSPC = properties.metadata?.vtec?.prediction_center;
|
|
71
|
-
|
|
65
|
+
SetEventEmit({ event: isSPC ? `onStormPredictionWatch` : `onNonStormPredictionWatch`, metadata: define })
|
|
72
66
|
if (bools?.SPCWatchesOnly && !isSPC) {
|
|
73
|
-
return
|
|
67
|
+
return true;
|
|
74
68
|
}
|
|
75
69
|
if ((!bools?.SPCWatchesOnly) && isSPC) {
|
|
76
|
-
return
|
|
70
|
+
return true
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
|
-
|
|
80
73
|
|
|
81
74
|
for (const key in sets) {
|
|
82
75
|
const setting = sets[key]
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
const values = [...setting];
|
|
77
|
+
if (key === 'ListeningEvents' && setting.size > 0 && !GetMatched(values, define.properties.event)) {
|
|
78
|
+
SetEventEmit({
|
|
85
79
|
event: `onFilteredEvent`,
|
|
86
80
|
metadata: define
|
|
87
81
|
});
|
|
88
|
-
return
|
|
82
|
+
return true
|
|
89
83
|
}
|
|
90
|
-
if (key === 'IgnoredEvents' && setting.size > 0 &&
|
|
91
|
-
|
|
84
|
+
if (key === 'IgnoredEvents' && setting.size > 0 && GetMatched(values, define.properties.event)) {
|
|
85
|
+
SetEventEmit({
|
|
92
86
|
event: `onIgnoredEvent`,
|
|
93
87
|
metadata: define
|
|
94
88
|
});
|
|
95
|
-
return
|
|
89
|
+
return true
|
|
96
90
|
}
|
|
97
91
|
if (key === 'ListeningICAO' && setting.size > 0 && icao != null && !setting.has(icao.toLowerCase())) {
|
|
98
|
-
|
|
92
|
+
SetEventEmit({
|
|
99
93
|
event: `onFilteredICAO`,
|
|
100
94
|
metadata: define
|
|
101
95
|
});
|
|
102
|
-
return
|
|
96
|
+
return true
|
|
103
97
|
}
|
|
104
98
|
if (key === 'IgnoredICAO' && setting.size > 0 && icao != null && setting.has(icao.toLowerCase())) {
|
|
105
|
-
|
|
99
|
+
SetEventEmit({
|
|
106
100
|
event: `onIgnoredICAO`,
|
|
107
101
|
metadata: define
|
|
108
102
|
});
|
|
109
|
-
return
|
|
103
|
+
return true
|
|
110
104
|
}
|
|
111
105
|
if (key === 'ListeningUGC' && setting.size > 0 && zones.length > 0 && !zones.some((ugc: string) => setting.has(ugc.toLowerCase()))) {
|
|
112
|
-
|
|
106
|
+
SetEventEmit({
|
|
113
107
|
event: `onFilteredUGC`,
|
|
114
108
|
metadata: define
|
|
115
109
|
});
|
|
116
|
-
return
|
|
110
|
+
return true
|
|
117
111
|
}
|
|
118
112
|
if (key === 'ListeningStates' && setting.size > 0 && zones.length > 0 && !zones.some((ugc: string) => setting.has(ugc.substring(0, 2).toLowerCase()))) {
|
|
119
|
-
|
|
113
|
+
SetEventEmit({
|
|
120
114
|
event: `onFilteredState`,
|
|
121
115
|
metadata: define
|
|
122
116
|
});
|
|
123
|
-
return
|
|
117
|
+
return true
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
|
-
return
|
|
127
|
-
}
|
|
120
|
+
return false
|
|
121
|
+
}
|
|
128
122
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
const filtering = events.filter((event: TypeEvent) => {
|
|
124
|
+
bootstrap.cache.processed = bootstrap.cache.processed.filter((e) => e !== event);
|
|
125
|
+
const define = GetEventSignature(event) as TypeEvent;
|
|
126
|
+
const pre = {...define,properties: {...define.properties, metadata: {...define.properties.metadata }}};
|
|
127
|
+
const properties = define.properties; delete pre.properties.metadata.ms; delete pre.properties.metadata.header;
|
|
128
|
+
const enhanced = properties.event = GetEventEnhancedName(event)
|
|
129
|
+
const filtered = isFiltered(define)
|
|
130
|
+
if (!filtered) {
|
|
131
|
+
event.geometry = !bools?.DisableGeometryParsing ? GetEventGeometry(event) : null;
|
|
132
|
+
properties.metadata.attachments = GetEventAttachments(event)
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
properties.metadata.hash = createHash("sha256").update(JSON.stringify(pre)).digest("hex")
|
|
135
|
+
SetEventEmit({ event: `onProductType${enhanced.replace(/\s+/g, '')}`, metadata: define });
|
|
136
|
+
return !filtered
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
SetDebug({ title: `ValidateEvents (PRE) (${filtering.length}/${events.length})`, message: `${Math.round(performance.now() - tick)}ms` })
|
|
135
140
|
|
|
136
|
-
if (
|
|
137
|
-
for (const event of
|
|
138
|
-
await
|
|
141
|
+
if (filtering.length > 0) {
|
|
142
|
+
for (const event of filtering) {
|
|
143
|
+
await MakeEvent(event)
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
|
|
146
|
+
|
|
147
|
+
SetEventEmit({
|
|
143
148
|
event: `onEventCache`,
|
|
144
149
|
metadata: bootstrap.cache.events,
|
|
145
150
|
limited: true
|
|
146
151
|
})
|
|
152
|
+
|
|
153
|
+
SetDebug({ title: `ValidateEvents (${filtering.length}/${events.length})`, message: `${Math.round(performance.now() - tick)}ms` })
|
|
147
154
|
}
|
|
@@ -18,13 +18,12 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { bootstrap } from "../bootstrap";
|
|
21
|
-
import {
|
|
21
|
+
import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
export const clearEvents = (): void => {
|
|
23
|
+
export const ClearEvents = (): void => {
|
|
25
24
|
bootstrap.cache.events.features = [];
|
|
26
25
|
bootstrap.cache.hashes = [];
|
|
27
|
-
|
|
26
|
+
SetEventEmit({
|
|
28
27
|
event: `onEventCache`,
|
|
29
28
|
metadata: bootstrap.cache.events,
|
|
30
29
|
message: `Manually cleared event cache.`
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { SetListener } from "../@modules/@utilities/SetListener";
|
|
21
21
|
|
|
22
|
-
export const
|
|
23
|
-
|
|
22
|
+
export const CreateListener = (event: string, callback: () => void) => {
|
|
23
|
+
SetListener({event, callback})
|
|
24
24
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { TypeAttributes } from "../@types/Attributes";
|
|
21
|
+
import { EnumExpressions } from "../@enums/Expressions"
|
|
22
|
+
import { GetAwipsType } from "../@modules/@stanza/GetAwipsType";
|
|
23
|
+
import { CreateEvent } from "../@building/CreateEvent";
|
|
24
|
+
|
|
25
|
+
interface CreateEventOptions {
|
|
26
|
+
message: string
|
|
27
|
+
awipsid?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ManualEvent = async (options: CreateEventOptions): Promise<void> => {
|
|
31
|
+
const isCapEvent = options.message.includes(`<?xml`);
|
|
32
|
+
const isCapAreaDescription = options.message.includes(`<areaDesc>`)
|
|
33
|
+
const isVTEC = options.message.match(EnumExpressions.pvtec) != null;
|
|
34
|
+
const isUGC = options.message.match(EnumExpressions.ugc1) != null;
|
|
35
|
+
const attributes = {
|
|
36
|
+
"xmlns": "@atmosx/event-product-parser",
|
|
37
|
+
"id": "manual_processor.0000",
|
|
38
|
+
"issue": new Date().toISOString(),
|
|
39
|
+
"ttaaii": "XXXXX",
|
|
40
|
+
"cccc": "XXX",
|
|
41
|
+
"awipsid": options.awipsid ?? "XXXXXX",
|
|
42
|
+
}
|
|
43
|
+
const getType = GetAwipsType({ attributes })
|
|
44
|
+
const result = {
|
|
45
|
+
message: options.message,
|
|
46
|
+
attributes,
|
|
47
|
+
isCapEvent,
|
|
48
|
+
isVTEC,
|
|
49
|
+
isUGC,
|
|
50
|
+
isCapAreaDescription,
|
|
51
|
+
isIgnored: false,
|
|
52
|
+
isNWWS: true,
|
|
53
|
+
getType
|
|
54
|
+
}
|
|
55
|
+
await CreateEvent(result);
|
|
56
|
+
}
|
|
@@ -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/Stanza";
|
|
21
|
+
import { bootstrap } from "../bootstrap";
|
|
22
|
+
|
|
23
|
+
interface QueryStanzaOptions {
|
|
24
|
+
search: string
|
|
25
|
+
max?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type QueryStanza = {
|
|
29
|
+
rowid: number
|
|
30
|
+
stanza: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const QueryStanza = async (options: QueryStanzaOptions): 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 QueryStanza[];
|
|
37
|
+
const events = get.map((row) => JSON.parse(row.stanza));
|
|
38
|
+
return events as TypeStanza[];
|
|
39
|
+
}
|
|
@@ -18,23 +18,23 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { bootstrap } from "../bootstrap";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { SetWarning } from "../@modules/@utilities/SetWarning"
|
|
22
|
+
import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
|
|
23
23
|
|
|
24
|
-
interface
|
|
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
|
|
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) {
|
|
34
34
|
if (exists) {
|
|
35
35
|
const index = nodes.indexOf(exists);
|
|
36
36
|
nodes.splice(index, 1);
|
|
37
|
-
return
|
|
37
|
+
return SetEventEmit({
|
|
38
38
|
event: `onNodeDelete`,
|
|
39
39
|
metadata: {
|
|
40
40
|
type: `node-delete`,
|
|
@@ -42,7 +42,7 @@ export const setNode = (options: GetAddChaserOptions) => {
|
|
|
42
42
|
}
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return SetWarning({ message: `Node with identifier '${options.identifier}' not found.` })
|
|
46
46
|
}
|
|
47
47
|
if (exists) {
|
|
48
48
|
const index = nodes.indexOf(exists);
|
|
@@ -53,7 +53,7 @@ export const setNode = (options: GetAddChaserOptions) => {
|
|
|
53
53
|
coordinates: [options.coordinates.longitude, options.coordinates.latitude]
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
return
|
|
56
|
+
return SetEventEmit({
|
|
57
57
|
event: `onNodeUpdate`,
|
|
58
58
|
metadata: {
|
|
59
59
|
type: `node-update`,
|
|
@@ -71,7 +71,7 @@ export const setNode = (options: GetAddChaserOptions) => {
|
|
|
71
71
|
identifier: options.identifier
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
-
return
|
|
74
|
+
return SetEventEmit({
|
|
75
75
|
event: `onNodeAdd`,
|
|
76
76
|
metadata: {
|
|
77
77
|
type: `node-add`,
|
|
@@ -17,45 +17,45 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeSettings } from "../@types/
|
|
20
|
+
import { TypeSettings } from "../@types/Settings";
|
|
21
21
|
import { bootstrap } from "../bootstrap";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
22
|
+
import { SetWarning } from "../@modules/@utilities/SetWarning"
|
|
23
|
+
import { SetSettings } from "../@modules/@utilities/SetSettings"
|
|
24
|
+
import { DeployXMPP } from "../@modules/@xmpp/DeployXMPP"
|
|
25
|
+
import { InitializeDatabase } from "../@modules/@database/InitializeDatabase";
|
|
26
|
+
import { GetCachedEvents } from "../@modules/@database/GetCachedEvents";
|
|
27
|
+
import { SetCronSchedule } from "../@modules/@utilities/SetCronSchedule";
|
|
28
|
+
import { UpdateNode } from "../@manager/UpdateNode";
|
|
29
|
+
import { UpdateEvents } from "../@manager/UpdateEvents";
|
|
30
30
|
import { Cron } from "croner";
|
|
31
31
|
|
|
32
|
-
export const
|
|
32
|
+
export const StartService = async (configurations: TypeSettings): Promise<void> => {
|
|
33
33
|
if (!bootstrap.isReady) {
|
|
34
|
-
return
|
|
34
|
+
return SetWarning({
|
|
35
35
|
message: `You can not create another instance without shutting down the current one first, please make sure to call the stop() method first!`
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
|
-
const settings =
|
|
38
|
+
const settings = SetSettings(configurations);
|
|
39
39
|
bootstrap.isReady = true;
|
|
40
|
-
await
|
|
40
|
+
await InitializeDatabase();
|
|
41
41
|
if (settings.EnableWireService) {
|
|
42
42
|
(async () => {
|
|
43
|
-
await
|
|
44
|
-
await
|
|
43
|
+
await GetCachedEvents();
|
|
44
|
+
await DeployXMPP()
|
|
45
45
|
})();
|
|
46
46
|
}
|
|
47
|
-
await
|
|
47
|
+
await SetCronSchedule()
|
|
48
48
|
let scheduleInterval = !settings.EnableWireService ? settings.NationalWeatherServiceSettings.CallbackInterval : 1;
|
|
49
49
|
if (!settings.EnableWireService && scheduleInterval < 15) {
|
|
50
|
-
|
|
50
|
+
SetWarning({ message: `Schedule interval of ${scheduleInterval} seconds is too low, setting to 15 seconds` })
|
|
51
51
|
bootstrap.settings.NationalWeatherServiceSettings.CallbackInterval = 15;
|
|
52
52
|
scheduleInterval = 15;
|
|
53
53
|
}
|
|
54
54
|
bootstrap.cron = new Cron(`*/${scheduleInterval} * * * * *`, async () => {
|
|
55
|
-
await
|
|
55
|
+
await SetCronSchedule();
|
|
56
56
|
})
|
|
57
|
-
bootstrap.cron = new Cron(`* * * * * *`, async () => {
|
|
58
|
-
await
|
|
59
|
-
await
|
|
57
|
+
bootstrap.cron = new Cron(`* * * * * *`, async () => {
|
|
58
|
+
await UpdateNode();
|
|
59
|
+
await UpdateEvents();
|
|
60
60
|
})
|
|
61
61
|
}
|