@atmosx/event-product-parser 3.0.3 → 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.
Files changed (162) hide show
  1. package/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
  2. package/.github/README.md +163 -0
  3. package/.github/SUPPORTED_EVENTS.md +370 -0
  4. package/.github/docs/docs-functions.md +30 -0
  5. package/.github/docs/docs-general-configurations.md +209 -0
  6. package/.github/docs/docs-integrations.md +37 -0
  7. package/.github/docs/docs-listeners.md +28 -0
  8. package/.github/docs/docs-source-configuration.md +218 -0
  9. package/.github/docs/docs-technical.md +50 -0
  10. package/.github/logo.png +0 -0
  11. package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
  12. package/.github/samples/SAMPLE_GEOJSON.json +204 -0
  13. package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
  14. package/dist/cjs/index.cjs +4681 -13425
  15. package/dist/esm/index.mjs +3163 -11909
  16. package/package.json +4 -8
  17. package/src/@building/{building.create.ts → CreateEvent.ts} +25 -11
  18. package/src/@building/{building.clean.ts → GetCleanedEvent.ts} +2 -2
  19. package/src/@building/GetEventAttachments.ts +86 -0
  20. package/src/@building/{building.enhance.ts → GetEventEnhancedName.ts} +11 -12
  21. package/src/@building/{building.geometry.ts → GetEventGeometry.ts} +7 -7
  22. package/src/@building/{building.headers.ts → GetEventHeader.ts} +3 -3
  23. package/src/@building/{building.polygon.ts → GetEventNodes.ts} +13 -11
  24. package/src/@building/{building.office.ts → GetEventOffice.ts} +6 -6
  25. package/src/@building/GetEventProperties.ts +96 -0
  26. package/src/@building/{building.signature.ts → GetEventSignature.ts} +14 -15
  27. package/src/@building/{building.tags.ts → GetEventTags.ts} +9 -4
  28. package/src/@building/{building.tracking.ts → GetEventTracking.ts} +15 -15
  29. package/src/@building/{building.validate.ts → ValidateEvents.ts} +67 -60
  30. package/src/@core/{core.clearEvents.ts → ClearEvents.ts} +3 -4
  31. package/src/@core/{core.createListener.ts → CreateListener.ts} +3 -3
  32. package/src/@core/{core.getEvents.ts → GetEvents.ts} +1 -2
  33. package/src/@core/{core.getNodes.ts → GetNodes.ts} +1 -2
  34. package/src/@core/{core.getRandomEvent.ts → GetRandomEvent.ts} +1 -2
  35. package/src/@core/{core.getVersion.ts → GetVersion.ts} +1 -2
  36. package/src/@core/ManualEvent.ts +56 -0
  37. package/src/@core/QueryStanza.ts +39 -0
  38. package/src/@core/{core.setNode.ts → SetNode.ts} +8 -8
  39. package/src/@core/{core.start.ts → StartService.ts} +21 -21
  40. package/src/@core/{core.stop.ts → StopService.ts} +1 -1
  41. package/src/@enums/AWIPS.ts +366 -0
  42. package/src/{@dictionaries/dictionaries.eventActions.ts → @enums/Actions.ts} +1 -1
  43. package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → @enums/Cancellation.ts} +2 -1
  44. package/src/{@dictionaries/dictionaries.eventCauses.ts → @enums/Causes.ts} +1 -1
  45. package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → @enums/Correlations.ts} +1 -1
  46. package/src/@enums/Enhanced.ts +70 -0
  47. package/src/{@dictionaries/dictionaries.eventTypes.ts → @enums/Events.ts} +1 -1
  48. package/src/{@dictionaries/dictionaries.regExp.ts → @enums/Expressions.ts} +2 -1
  49. package/src/@enums/GlobalFilter.ts +24 -0
  50. package/src/{@dictionaries/dictionaries.hailStrings.ts → @enums/Hail.ts} +7 -2
  51. package/src/{@dictionaries/dictionaries.officeICAOs.ts → @enums/ICAO.ts} +3 -1
  52. package/src/@enums/Matches.ts +55 -0
  53. package/src/{@dictionaries/dictionaries.eventProducts.ts → @enums/Products.ts} +1 -1
  54. package/src/{@dictionaries/dictionaries.eventRecords.ts → @enums/Records.ts} +1 -1
  55. package/src/{@dictionaries/dictionaries.eventSeverity.ts → @enums/Severity.ts} +1 -1
  56. package/src/{@dictionaries/dictionaries.shapefileLinks.ts → @enums/Shapefiles.ts} +1 -1
  57. package/src/@enums/States.ts +72 -0
  58. package/src/{@dictionaries/dictionaries.eventStatus.ts → @enums/Status.ts} +1 -1
  59. package/src/@enums/Strings.ts +22 -0
  60. package/src/@enums/Tags.ts +167 -0
  61. package/src/{@dictionaries/dictionaries.testSignatures.ts → @enums/Testing.ts} +3 -2
  62. package/src/@events/{events.api.ts → ParseAPI.ts} +42 -38
  63. package/src/@events/{events.text.ts → ParseText.ts} +25 -18
  64. package/src/@events/{events.ugc.ts → ParseUGC.ts} +28 -19
  65. package/src/@events/{events.vtec.ts → ParseVTEC.ts} +21 -21
  66. package/src/@manager/CreateActions.ts +213 -0
  67. package/src/@manager/{manager.mkEvent.ts → MakeEvent.ts} +34 -30
  68. package/src/@manager/RemoveEvent.ts +70 -0
  69. package/src/@manager/{manager.setHash.ts → SetHash.ts} +8 -9
  70. package/src/@manager/{manager.updateEvents.ts → UpdateEvents.ts} +9 -9
  71. package/src/@manager/{manager.updateNodes.ts → UpdateNode.ts} +24 -17
  72. package/src/@modules/@database/{database.cache.ts → GetCachedEvents.ts} +10 -8
  73. package/src/@modules/@database/ImportBroadcastify.ts +70 -0
  74. package/src/@modules/@database/{database.shapefiles.ts → ImportShapefiles.ts} +17 -20
  75. package/src/@modules/@database/{database.stanza.ts → ImportStanza.ts} +5 -6
  76. package/src/@modules/@database/{database.init.ts → InitializeDatabase.ts} +25 -11
  77. package/src/@modules/@eas/GenerateEASMessage.ts +144 -0
  78. package/src/@modules/@eas/GetCleanDescription.ts +91 -0
  79. package/src/@modules/@eas/{eas.getFloatPCM16.ts → GetFloatPCM16.ts} +1 -1
  80. package/src/@modules/@eas/{eas.getMergedPCM16.ts → GetMergedPCM16.ts} +1 -1
  81. package/src/@modules/@eas/{eas.getPCM16.ts → GetPCM16.ts} +1 -1
  82. package/src/@modules/@eas/{eas.getPCMToFloat.ts → GetPCMToFloat.ts} +1 -1
  83. package/src/@modules/@eas/{eas.getSampledPCM16.ts → GetSampledPCM16.ts} +1 -1
  84. package/src/@modules/@eas/GetTTS.ts +54 -0
  85. package/src/@modules/@eas/{eas.getWavPCM16.ts → GetWavPCM16.ts} +1 -1
  86. package/src/@modules/@eas/{eas.setAFSK.ts → SetAFSK.ts} +1 -2
  87. package/src/@modules/@eas/{eas.setAsciiToBits.ts → SetAsciiToBits.ts} +1 -2
  88. package/src/@modules/@eas/{eas.setAttentionTone.ts → SetAttentionTone.ts} +1 -1
  89. package/src/@modules/@eas/{eas.setNoise.ts → SetNoise.ts} +6 -5
  90. package/src/@modules/@eas/{eas.setRadioEffect.ts → SetRadioEffect.ts} +6 -5
  91. package/src/@modules/@eas/{eas.setSameHeader.ts → SetSameHeader.ts} +7 -8
  92. package/src/@modules/@stanza/{stanza.getAwipsType.ts → GetAwipsType.ts} +11 -9
  93. package/src/@modules/@stanza/{stanza.validate.ts → ValidateStanza.ts} +9 -9
  94. package/src/@modules/@utilities/CreateHttp.ts +83 -0
  95. package/src/@modules/@utilities/{utilities.getFormattedTime.ts → GetFormattedTime.ts} +1 -1
  96. package/src/@modules/@utilities/GetLatestIssuance.ts +32 -0
  97. package/src/@modules/@utilities/GetMatched.ts +33 -0
  98. package/src/@modules/@utilities/{utilities.getSettings.ts → GetSettings.ts} +2 -2
  99. package/src/@modules/@utilities/{utilities.getShapeNearestPoint.ts → GetShapeNearestPoint.ts} +1 -1
  100. package/src/@modules/@utilities/{utilities.setCronSchedule.ts → SetCronSchedule.ts} +41 -12
  101. package/src/{@types/types.webhook.ts → @modules/@utilities/SetDebug.ts} +16 -6
  102. package/src/@modules/@utilities/{utilities.setEventEmit.ts → SetEventEmit.ts} +5 -5
  103. package/src/@modules/@utilities/{utilities.setListener.ts → SetListener.ts} +1 -1
  104. package/src/@modules/@utilities/{utilities.setSettings.ts → SetSettings.ts} +2 -2
  105. package/src/@modules/@utilities/{utilities.setSleep.ts → SetSleep.ts} +1 -1
  106. package/src/@modules/@utilities/{utilities.setTimeoutAction.ts → SetTimeoutAction.ts} +8 -3
  107. package/src/@modules/@utilities/{utilities.setWarning.ts → SetWarning.ts} +4 -4
  108. package/src/@modules/@xmpp/{xmpp.xDeploy.ts → DeployXMPP.ts} +13 -14
  109. package/src/@modules/@xmpp/{xmpp.xError.ts → ErrorXMPP.ts} +1 -3
  110. package/src/@modules/@xmpp/{xmpp.xOffline.ts → OfflineXMPP.ts} +3 -4
  111. package/src/@modules/@xmpp/{xmpp.xOnline.ts → OnlineXMPP.ts} +6 -5
  112. package/src/@modules/@xmpp/{xmpp.xReconnect.ts → ReconnectXMPP.ts} +8 -8
  113. package/src/@modules/@xmpp/{xmpp.xStanza.ts → StanzaXMPP.ts} +11 -11
  114. package/src/@parsers/@hvtec/{hvtec.extract.ts → HVExtract.ts} +10 -10
  115. package/src/@parsers/@pvtec/{pvtec.expires.ts → GetExpiry.ts} +1 -1
  116. package/src/@parsers/@pvtec/{pvtec.extract.ts → VTECExtract.ts} +17 -17
  117. package/src/@parsers/@text/{text.getDescriptionFromProduct.ts → GetDescriptionFromProduct.ts} +12 -5
  118. package/src/@parsers/@text/GetEmbededText.ts +56 -0
  119. package/src/@parsers/@text/{text.getPolygonFromProduct.ts → GetPolygonFromProduct.ts} +31 -10
  120. package/src/@parsers/@text/GetStringText.ts +58 -0
  121. package/src/@parsers/@text/{text.getTextFromProduct.ts → GetTextFromProduct.ts} +1 -1
  122. package/src/@parsers/@text/{text.getXML.ts → GetXML.ts} +1 -1
  123. package/src/@parsers/@ugc/GetCache.ts +24 -0
  124. package/src/@parsers/@ugc/{ugc.expiry.ts → GetExpiry.ts} +1 -1
  125. package/src/@parsers/@ugc/{ugc.locations.ts → GetLocations.ts} +35 -7
  126. package/src/@parsers/@ugc/{ugc.header.ts → GetUGCHeader.ts} +3 -3
  127. package/src/@parsers/@ugc/{ugc.coordinates.ts → GetZonePolygon.ts} +4 -3
  128. package/src/@parsers/@ugc/SetCache.ts +28 -0
  129. package/src/@parsers/@ugc/{ugc.extract.ts → UGCExtract.ts} +6 -6
  130. package/src/@types/Actions.ts +37 -0
  131. package/src/@types/{type.event.ts → Event.ts} +7 -5
  132. package/src/@types/{type.properties.ts → Properties.ts} +11 -8
  133. package/src/@types/{types.settings.ts → Settings.ts} +31 -7
  134. package/src/@types/{types.compiled.ts → StanzaCompiled.ts} +2 -1
  135. package/src/bootstrap.ts +33 -9
  136. package/src/index.ts +28 -26
  137. package/tsup.config.ts +1 -1
  138. package/README.md +0 -339
  139. package/dist/index.d.mts +0 -239
  140. package/dist/index.d.ts +0 -239
  141. package/src/@building/building.properties.ts +0 -89
  142. package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
  143. package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
  144. package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
  145. package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
  146. package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
  147. package/src/@manager/manager.rmEvent.ts +0 -49
  148. package/src/@manager/manager.updateWebhooks.ts +0 -50
  149. package/src/@modules/@eas/eas.setEasTone.ts +0 -137
  150. package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
  151. package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
  152. package/test.js +0 -91
  153. /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
  154. /package/{LICENSE → .github/LICENSE} +0 -0
  155. /package/{SECURITY.md → .github/SECURITY.md} +0 -0
  156. /package/src/@parsers/@ugc/{ugc.zones.ts → GetZones.ts} +0 -0
  157. /package/src/@types/{types.attributes.ts → Attributes.ts} +0 -0
  158. /package/src/@types/{types.hvtec.ts → HVTEC.ts} +0 -0
  159. /package/src/@types/{types.hash.ts → Hash.ts} +0 -0
  160. /package/src/@types/{types.stanza.ts → Stanza.ts} +0 -0
  161. /package/src/@types/{types.ugc.ts → UGC.ts} +0 -0
  162. /package/src/@types/{types.pvtec.ts → VTEC.ts} +0 -0
@@ -17,20 +17,23 @@
17
17
 
18
18
  */
19
19
 
20
- import { createHash } from "crypto"
21
- import { TypeEvent } from "../@types/type.event";
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 { getEventEnhancedName } from "./building.enhance";
25
- import { getEventSignature } from "./building.signature"
26
- import { mkEvent } from "../@manager/manager.mkEvent";
27
- import { rmEvent } from "../@manager/manager.rmEvent";
28
- import { getEventGeometry } from "./building.geometry";
29
- import { updateNode } from "../@manager/manager.updateNodes";
30
- import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
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 validateEvents = async (events: TypeEvent[]): Promise<void> => {
33
- if (events.length === 0) return;
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
- const filterd = events.filter((event: TypeEvent) => {
44
- const define = getEventSignature(event) as TypeEvent;
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
- const enhancedEventName = properties.event = getEventEnhancedName(event)
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
- setEventEmit({ event: `onTestProduct`, metadata: define })
60
- if (bools?.IgnoreTestProducts) return false;
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
- setEventEmit({ event: `onExpiredProduct`, metadata: define })
65
- rmEvent(define)
66
- return false;
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
- setEventEmit({ event: isSPC ? `onStormPredictionWatch` : `onNonStormPredictionWatch`, metadata: define })
65
+ SetEventEmit({ event: isSPC ? `onStormPredictionWatch` : `onNonStormPredictionWatch`, metadata: define })
72
66
  if (bools?.SPCWatchesOnly && !isSPC) {
73
- return false;
67
+ return true;
74
68
  }
75
69
  if ((!bools?.SPCWatchesOnly) && isSPC) {
76
- return false
70
+ return true
77
71
  }
78
72
  }
79
-
80
73
 
81
74
  for (const key in sets) {
82
75
  const setting = sets[key]
83
- if (key === 'ListeningEvents' && setting.size > 0 && !setting.has(define.properties.event.toLowerCase())) {
84
- setEventEmit({
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 false
82
+ return true
89
83
  }
90
- if (key === 'IgnoredEvents' && setting.size > 0 && setting.has(define.properties.event.toLowerCase())) {
91
- setEventEmit({
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 false
89
+ return true
96
90
  }
97
91
  if (key === 'ListeningICAO' && setting.size > 0 && icao != null && !setting.has(icao.toLowerCase())) {
98
- setEventEmit({
92
+ SetEventEmit({
99
93
  event: `onFilteredICAO`,
100
94
  metadata: define
101
95
  });
102
- return false
96
+ return true
103
97
  }
104
98
  if (key === 'IgnoredICAO' && setting.size > 0 && icao != null && setting.has(icao.toLowerCase())) {
105
- setEventEmit({
99
+ SetEventEmit({
106
100
  event: `onIgnoredICAO`,
107
101
  metadata: define
108
102
  });
109
- return false
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
- setEventEmit({
106
+ SetEventEmit({
113
107
  event: `onFilteredUGC`,
114
108
  metadata: define
115
109
  });
116
- return false
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
- setEventEmit({
113
+ SetEventEmit({
120
114
  event: `onFilteredState`,
121
115
  metadata: define
122
116
  });
123
- return false
117
+ return true
124
118
  }
125
119
  }
126
- return true;
127
- })
120
+ return false
121
+ }
128
122
 
129
-
130
- if (!configurations?.GlobalSettings?.DisableGeometryParsing) {
131
- for (const event of filterd) {
132
- event.geometry = await getEventGeometry(event)
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 (filterd.length > 0) {
137
- for (const event of filterd) {
138
- await mkEvent(event)
141
+ if (filtering.length > 0) {
142
+ for (const event of filtering) {
143
+ await MakeEvent(event)
139
144
  }
140
145
  }
141
- await updateNode()
142
- setEventEmit({
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 { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
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
- setEventEmit({
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 { setListener } from "../@modules/@utilities/utilities.setListener";
20
+ import { SetListener } from "../@modules/@utilities/SetListener";
21
21
 
22
- export const createListener = (event: string, callback: () => void) => {
23
- setListener({event, callback})
22
+ export const CreateListener = (event: string, callback: () => void) => {
23
+ SetListener({event, callback})
24
24
  }
@@ -19,7 +19,6 @@
19
19
 
20
20
  import { bootstrap } from "../bootstrap";
21
21
 
22
-
23
- export const getEvents = (): any => {
22
+ export const GetEvents = (): any => {
24
23
  return bootstrap.cache.events
25
24
  }
@@ -19,7 +19,6 @@
19
19
 
20
20
  import { bootstrap } from "../bootstrap";
21
21
 
22
-
23
- export const getNodes = (): any => {
22
+ export const GetNodes = (): any => {
24
23
  return bootstrap.cache.nodes
25
24
  }
@@ -19,7 +19,6 @@
19
19
 
20
20
  import { bootstrap } from "../bootstrap";
21
21
 
22
-
23
- export const getRandomEvent = (): any => {
22
+ export const GetRandomEvent = (): any => {
24
23
  return bootstrap.cache.events.features[Math.floor(Math.random() * bootstrap.cache.events.features.length)]
25
24
  }
@@ -19,7 +19,6 @@
19
19
 
20
20
  import { bootstrap } from "../bootstrap";
21
21
 
22
-
23
- export const getVersion = (): any => {
22
+ export const GetVersion = (): any => {
24
23
  return bootstrap.version
25
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 { setWarning } from "../@modules/@utilities/utilities.setWarning"
22
- import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
21
+ import { SetWarning } from "../@modules/@utilities/SetWarning"
22
+ import { SetEventEmit } from "../@modules/@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) {
34
34
  if (exists) {
35
35
  const index = nodes.indexOf(exists);
36
36
  nodes.splice(index, 1);
37
- return setEventEmit({
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 setWarning({ message: `Node with identifier '${options.identifier}' not found.` })
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 setEventEmit({
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 setEventEmit({
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/types.settings";
20
+ import { TypeSettings } from "../@types/Settings";
21
21
  import { bootstrap } from "../bootstrap";
22
- import { setWarning } from "../@modules/@utilities/utilities.setWarning"
23
- import { setSettings } from "../@modules/@utilities/utilities.setSettings"
24
- import { xDeploy } from "../@modules/@xmpp/xmpp.xDeploy"
25
- import { initializeDatabase } from "../@modules/@database/database.init";
26
- import { getCachedEvents } from "../@modules/@database/database.cache";
27
- import { setCronSchedule } from "../@modules/@utilities/utilities.setCronSchedule";
28
- import { updateNode } from "../@manager/manager.updateNodes";
29
- import { updateEvents } from "../@manager/manager.updateEvents";
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 startService = async (settings: TypeSettings): Promise<void> => {
32
+ export const StartService = async (configurations: TypeSettings): Promise<void> => {
33
33
  if (!bootstrap.isReady) {
34
- return setWarning({
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
- setSettings(settings);
38
+ const settings = SetSettings(configurations);
39
39
  bootstrap.isReady = true;
40
- await initializeDatabase();
40
+ await InitializeDatabase();
41
41
  if (settings.EnableWireService) {
42
42
  (async () => {
43
- await getCachedEvents();
44
- await xDeploy()
43
+ await GetCachedEvents();
44
+ await DeployXMPP()
45
45
  })();
46
46
  }
47
- await setCronSchedule()
47
+ await SetCronSchedule()
48
48
  let scheduleInterval = !settings.EnableWireService ? settings.NationalWeatherServiceSettings.CallbackInterval : 1;
49
49
  if (!settings.EnableWireService && scheduleInterval < 15) {
50
- setWarning({ message: `Schedule Interval of ${scheduleInterval} seconds is too low, setting to 15 seconds` })
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 setCronSchedule();
55
+ await SetCronSchedule();
56
56
  })
57
- bootstrap.cron = new Cron(`* * * * * *`, async () => {
58
- await updateNode();
59
- await updateEvents();
57
+ bootstrap.cron = new Cron(`* * * * * *`, async () => {
58
+ await UpdateNode();
59
+ await UpdateEvents();
60
60
  })
61
61
  }
@@ -19,7 +19,7 @@
19
19
 
20
20
  import { bootstrap } from "../bootstrap";
21
21
 
22
- export const stopService = async (): Promise<void> => {
22
+ export const StopService = async (): Promise<void> => {
23
23
  if (bootstrap.isReady) {
24
24
  bootstrap.isReady = false;
25
25
  if (bootstrap.session_xmpp) {