@atmosx/event-product-parser 3.0.6 → 3.0.7

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 (181) hide show
  1. package/.github/docs/docs-functions.md +2 -2
  2. package/.github/docs/docs-general-configurations.md +2 -12
  3. package/.github/docs/docs-integrations.md +4 -3
  4. package/.github/docs/docs-listeners.md +1 -1
  5. package/.github/docs/docs-source-configuration.md +1 -1
  6. package/.github/docs/docs-technical.md +1 -1
  7. package/{.github/README.md → README.md} +15 -9
  8. package/dist/cjs/index.cjs +24073 -7018
  9. package/dist/esm/index.mjs +24035 -6983
  10. package/package.json +56 -47
  11. package/pnpm-workspace.yaml +4 -0
  12. package/src/bootstrap.ts +64 -48
  13. package/src/{@building → building}/CreateEvent.ts +22 -24
  14. package/src/{@building → building}/GetCleanedEvent.ts +2 -2
  15. package/src/{@building → building}/GetEventAttachments.ts +14 -12
  16. package/src/building/GetEventDirection.ts +28 -0
  17. package/src/{@building → building}/GetEventEnhancedName.ts +5 -8
  18. package/src/{@building → building}/GetEventGeometry.ts +19 -13
  19. package/src/{@building → building}/GetEventHeader.ts +13 -13
  20. package/src/{@building → building}/GetEventNodes.ts +21 -19
  21. package/src/{@building → building}/GetEventOffice.ts +13 -13
  22. package/src/building/GetEventProperties.ts +105 -0
  23. package/src/{@building → building}/GetEventSignature.ts +9 -9
  24. package/src/{@building → building}/GetEventTags.ts +3 -3
  25. package/src/building/GetEventTheme.ts +26 -0
  26. package/src/building/GetEventTracking.ts +64 -0
  27. package/src/components/audio/GenerateAudioMessage.ts +149 -0
  28. package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
  29. package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
  30. package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
  31. package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
  32. package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
  33. package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
  34. package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
  35. package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
  36. package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
  37. package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
  38. package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
  39. package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
  40. package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
  41. package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
  42. package/src/{@modules/@utilities/SetWarning.ts → components/database/CreateQuery.ts} +18 -13
  43. package/src/{@modules/@database → components/database}/GetCachedEvents.ts +18 -15
  44. package/src/components/database/ImportBoundaries.ts +168 -0
  45. package/src/{@modules/@database → components/database}/ImportBroadcastify.ts +14 -24
  46. package/src/components/database/ImportCities.ts +87 -0
  47. package/src/{@modules/@database → components/database}/ImportShapefiles.ts +23 -26
  48. package/src/{@modules/@database → components/database}/ImportStanza.ts +15 -19
  49. package/src/components/database/InitializeDatabase.ts +71 -0
  50. package/src/components/images/GenerateGraphic.ts +234 -0
  51. package/src/components/images/components/CreateRectangle.ts +22 -0
  52. package/src/components/images/components/CreateText.ts +22 -0
  53. package/src/components/images/modules/CreateSVG.ts +37 -0
  54. package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
  55. package/src/components/images/modules/GetGeographicalCities.ts +58 -0
  56. package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
  57. package/src/components/images/modules/GetGeometryBounds.ts +82 -0
  58. package/src/components/images/modules/GetParsedBoundary.ts +58 -0
  59. package/src/components/images/modules/GetSVGPath.ts +53 -0
  60. package/src/components/images/modules/NormalizePolygon.ts +57 -0
  61. package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +16 -17
  62. package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
  63. package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
  64. package/src/{@modules/@utilities → components/utilities}/GetFormattedTime.ts +2 -2
  65. package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
  66. package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
  67. package/src/{@modules/@utilities → components/utilities}/GetShapeNearestPoint.ts +24 -19
  68. package/src/components/utilities/GetUnionPolygon.ts +36 -0
  69. package/src/components/utilities/QueueManager.ts +70 -0
  70. package/src/{@modules/@utilities → components/utilities}/SetCronSchedule.ts +29 -25
  71. package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +12 -12
  72. package/src/components/utilities/SetEventEmit.ts +42 -0
  73. package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
  74. package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +5 -5
  75. package/src/components/utilities/SetTimeoutAction.ts +64 -0
  76. package/src/components/utilities/SetWarning.ts +47 -0
  77. package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +20 -20
  78. package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
  79. package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
  80. package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
  81. package/src/components/xmpp/ReconnectXMPP.ts +64 -0
  82. package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +25 -25
  83. package/src/{@core → core}/ClearEvents.ts +9 -9
  84. package/src/{@core → core}/GetEvents.ts +4 -4
  85. package/src/{@core → core}/GetNodes.ts +4 -4
  86. package/src/{@core → core}/GetRandomEvent.ts +4 -4
  87. package/src/{@core → core}/GetVersion.ts +4 -4
  88. package/src/{@core → core}/ManualEvent.ts +23 -24
  89. package/src/{@core → core}/QueryStanza.ts +12 -11
  90. package/src/core/SetNode.ts +87 -0
  91. package/src/{@core → core}/StartService.ts +21 -20
  92. package/src/{@core → core}/StopService.ts +10 -10
  93. package/src/{@enums → enums}/AWIPS.ts +2 -2
  94. package/src/{@enums → enums}/Actions.ts +2 -2
  95. package/src/{@enums → enums}/Cancellation.ts +2 -2
  96. package/src/{@enums → enums}/Causes.ts +2 -2
  97. package/src/{@enums → enums}/Correlations.ts +2 -2
  98. package/src/{@enums → enums}/Enhanced.ts +2 -2
  99. package/src/{@enums → enums}/Events.ts +2 -2
  100. package/src/{@enums → enums}/Expressions.ts +3 -3
  101. package/src/{@enums → enums}/GlobalFilter.ts +2 -2
  102. package/src/{@enums → enums}/Hail.ts +2 -2
  103. package/src/{@enums → enums}/ICAO.ts +2 -2
  104. package/src/{@enums → enums}/Matches.ts +8 -3
  105. package/src/{@enums → enums}/Products.ts +2 -2
  106. package/src/{@enums → enums}/Records.ts +2 -2
  107. package/src/{@enums → enums}/Severity.ts +2 -2
  108. package/src/{@enums → enums}/Shapefiles.ts +2 -2
  109. package/src/{@enums → enums}/States.ts +68 -4
  110. package/src/{@enums → enums}/Status.ts +2 -2
  111. package/src/{@enums → enums}/Strings.ts +2 -2
  112. package/src/{@enums → enums}/Tags.ts +9 -4
  113. package/src/{@enums → enums}/Testing.ts +2 -2
  114. package/src/enums/Themes.ts +70 -0
  115. package/src/events/ParseAPI.ts +129 -0
  116. package/src/{@events → events}/ParseText.ts +24 -22
  117. package/src/{@events → events}/ParseUGC.ts +27 -26
  118. package/src/{@events → events}/ParseVTEC.ts +38 -37
  119. package/src/index.ts +57 -37
  120. package/src/manager/MakeEvents.ts +110 -0
  121. package/src/manager/RemoveEvent.ts +74 -0
  122. package/src/{@manager → manager}/SetHash.ts +18 -13
  123. package/src/{@manager → manager}/UpdateEvents.ts +12 -12
  124. package/src/{@manager → manager}/UpdateNode.ts +14 -14
  125. package/src/{@building → manager}/ValidateEvents.ts +47 -57
  126. package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +11 -11
  127. package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
  128. package/src/{@parsers/@text → parsers/text}/GetEmbededText.ts +7 -6
  129. package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
  130. package/src/{@parsers/@text → parsers/text}/GetStringText.ts +9 -9
  131. package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
  132. package/src/parsers/ugc/GetCache.ts +24 -0
  133. package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
  134. package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
  135. package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
  136. package/src/parsers/ugc/GetZonePolygon.ts +73 -0
  137. package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
  138. package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
  139. package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
  140. package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
  141. package/src/parsers/vtec/VTECExtract.ts +49 -0
  142. package/src/{@types → static}/Attributes.ts +2 -3
  143. package/src/{@types → static}/Event.ts +8 -7
  144. package/src/{@types → static}/Properties.ts +7 -3
  145. package/src/{@types → static}/Stanza.ts +2 -2
  146. package/src/tasks/CreateTasks.ts +123 -0
  147. package/src/tasks/TaskGenerateJSON.ts +34 -0
  148. package/src/tasks/TaskGenerateText.ts +34 -0
  149. package/src/tasks/TaskSendNTFY.ts +97 -0
  150. package/src/tasks/TaskSendWebhook.ts +107 -0
  151. package/src/{@types → types}/Actions.ts +3 -3
  152. package/src/{@types → types}/HVTEC.ts +6 -6
  153. package/src/{@types → types}/Hash.ts +5 -5
  154. package/src/types/Nodes.ts +29 -0
  155. package/src/{@types → types}/Settings.ts +16 -8
  156. package/src/{@types → types}/StanzaCompiled.ts +15 -15
  157. package/src/{@types → types}/UGC.ts +5 -5
  158. package/src/{@modules/@utilities/GetSettings.ts → types/VTEC.ts} +12 -7
  159. package/tools/build.js +47 -0
  160. package/tsconfig.json +28 -1
  161. package/src/@building/GetEventProperties.ts +0 -96
  162. package/src/@building/GetEventTracking.ts +0 -68
  163. package/src/@core/SetNode.ts +0 -81
  164. package/src/@events/ParseAPI.ts +0 -117
  165. package/src/@manager/CreateActions.ts +0 -213
  166. package/src/@manager/MakeEvent.ts +0 -99
  167. package/src/@manager/RemoveEvent.ts +0 -70
  168. package/src/@modules/@database/InitializeDatabase.ts +0 -59
  169. package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
  170. package/src/@modules/@utilities/SetEventEmit.ts +0 -41
  171. package/src/@modules/@utilities/SetListener.ts +0 -30
  172. package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
  173. package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
  174. package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
  175. package/src/@parsers/@pvtec/VTECExtract.ts +0 -49
  176. package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
  177. package/src/@parsers/@text/GetXML.ts +0 -61
  178. package/src/@parsers/@ugc/GetCache.ts +0 -24
  179. package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
  180. package/src/@types/VTEC.ts +0 -30
  181. package/tsup.config.ts +0 -16
@@ -0,0 +1,110 @@
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: https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Independent Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeSettings } from "Types/Settings"
22
+ import { EnumGlobalFilter } from "@Enums/GlobalFilter"
23
+ import { Bootstrap } from "@Bootstrap"
24
+ import { CreateTasks } from "@Tasks/CreateTasks"
25
+ import { SetHash } from "@Manager/SetHash"
26
+ import { UpdateNode } from "@Manager/UpdateNode"
27
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
28
+ import { SetTimeoutAction } from "@Utilities/SetTimeoutAction"
29
+ import { GetStringText } from "@ParsingText/GetStringText"
30
+
31
+ export const MakeEvents = async (events: TypeEvent[]): Promise<void> => {
32
+ let tasked = [] as TypeEvent[];
33
+ const settings = Bootstrap.Settings as TypeSettings;
34
+ if (events.length === 0) return
35
+ await Promise.all(events.map(async event => {
36
+ const features = Bootstrap.Cache.Events.features;
37
+ const getHash = event.properties.metadata.hash;
38
+ const getTracking = event.properties.metadata.tracking;
39
+ const isEntry = Bootstrap.Cache.Hashes?.find(hash => hash.Tracking === getTracking)
40
+ const isHashed = isEntry?.Hashes?.includes(getHash) ?? false;
41
+ const isNodeFiltering = settings.GlobalSettings.EventFiltering.NodeLocationFiltering
42
+ const getNodes = Bootstrap.Cache.Nodes.features;
43
+ const getFeature = features.find(feature => feature.properties.metadata.tracking === getTracking);
44
+
45
+ if (isHashed || event.properties.status_metadata.is_expired) return
46
+ SetHash({ Event: event, Entry: isEntry })
47
+ await UpdateNode(event);
48
+ if (isNodeFiltering && getNodes.length > 0) {
49
+ if (!event.properties.metadata.filtered_proximity && !EnumGlobalFilter.includes(event.properties.event.toLowerCase())) {
50
+ return
51
+ }
52
+ }
53
+
54
+ const isRatelimited = SetTimeoutAction({ Identifier: getTracking, Interval: 1, Max: 1, AddTime: true })
55
+ const isLocal = event.properties.metadata.filtered_proximity ? `[LOCAL] ` : ``;
56
+ if (!isRatelimited.Limited) {
57
+ SetEventEmit({
58
+ Event: `onEventStatus`,
59
+ Metadata: {
60
+ Type: getFeature ? `Updated` : `New`,
61
+ Event: event
62
+ },
63
+ Tree: Bootstrap.Settings.EnhancedEventJournaling ? GetStringText(event).split('\n').filter(line => line.trim() !== '') : [],
64
+ Message: `${isLocal}[${getFeature ? 'Updated' : 'New'}] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
65
+ })
66
+ }
67
+
68
+ if (settings.GlobalSettings.EventManagement) {
69
+ if (event.properties.status_metadata.is_issued || event.properties.status_metadata.is_updated) {
70
+ if (getFeature) {
71
+ const getIndex = features.indexOf(getFeature);
72
+ const cHistory = getFeature?.properties?.metadata?.history ?? [];
73
+ const cLocations = getFeature?.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
74
+ const cUgc = getFeature?.properties?.geocode?.ugc ?? [];
75
+
76
+ const iHistory = event.properties?.metadata?.history ?? [];
77
+ const iLocations = event.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
78
+ const iUgc = event.properties?.geocode?.ugc ?? [];
79
+
80
+ const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i).filter((v, i, a) => a.findIndex(h => h.description === v.description && h.issued === v.issued) === i);
81
+ const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join('; ');
82
+ const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
83
+
84
+ Bootstrap.Cache.Events.features[getIndex] = {
85
+ ...event,
86
+ properties: {
87
+ ...event.properties,
88
+ metadata: {
89
+ ...event?.properties?.metadata,
90
+ history: mHistory
91
+ },
92
+ locations: mLocations,
93
+ geocode: {
94
+ ...event?.properties?.geocode,
95
+ ugc: mUgc
96
+ },
97
+ }
98
+ };
99
+
100
+ tasked.push(Bootstrap.Cache.Events.features[getIndex])
101
+ } else {
102
+ features.push(event);
103
+ tasked.push(event)
104
+ }
105
+ }
106
+ }
107
+ }))
108
+ SetEventEmit({ Event: `onEventCache`, Metadata: Bootstrap.Cache.Events, Limited: true })
109
+ return await CreateTasks(tasked)
110
+ }
@@ -0,0 +1,74 @@
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: https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Independent Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { EnumStrings } from "@Enums/Strings"
22
+ import { Bootstrap } from "@Bootstrap"
23
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
24
+ import { SetTimeoutAction } from "@Utilities/SetTimeoutAction"
25
+ import { CreateTasks } from "@Tasks/CreateTasks"
26
+
27
+ interface RemoveEventOptions {
28
+ Event: TypeEvent
29
+ IsTimeBasedExpiration: boolean
30
+ }
31
+
32
+ export const RemoveEvent = async ({ Event, IsTimeBasedExpiration }: RemoveEventOptions):Promise<void> => {
33
+ const gTracking = Event.properties.metadata.tracking;
34
+ const isTrackingEventLogged = Bootstrap.Cache.Events.features
35
+ .find(f => f?.properties?.metadata?.tracking === gTracking);
36
+ const isStatement = Event.properties.status_metadata.is_statement;
37
+
38
+ if (isTrackingEventLogged) {
39
+ Event.properties.expires = new Date().toISOString();
40
+ Event.properties.status = `Expired`;
41
+ Event.properties.status_metadata.is_expired = true;
42
+
43
+ const description = IsTimeBasedExpiration ? EnumStrings.cancellation
44
+ .replace(`{SENDER}`, Event.properties.geocode.office.name)
45
+ .replace(`{EVENT}`, Event.properties.event) : Event.properties.description
46
+ Event.properties.description = description;
47
+ Event.properties.metadata.raw = IsTimeBasedExpiration ? description : Event.properties.metadata.raw;
48
+ Event.properties.metadata.history.push({
49
+ description: IsTimeBasedExpiration ? description : Event.properties.description,
50
+ issued: Event.properties.expires,
51
+ status: Event.properties.status
52
+ })
53
+
54
+ Bootstrap.Cache.Events.features
55
+ .splice(Bootstrap.Cache.Events.features.indexOf(isTrackingEventLogged), 1);
56
+ Bootstrap.Cache.Hashes = Bootstrap.Cache.Hashes
57
+ .filter(hash => hash.Tracking !== gTracking);
58
+
59
+ if (!isStatement) {
60
+ SetEventEmit({
61
+ Event: `onEventStatus`,
62
+ Metadata: { type: `Removed`, event: Event },
63
+ Message: `[Removed] ${Event.properties.event} (${Event.properties.status}) (${gTracking})`
64
+ })
65
+ CreateTasks([Event])
66
+ }
67
+ SetTimeoutAction({ Identifier: gTracking, Expire: true })
68
+ }
69
+ SetEventEmit({
70
+ Event: `onEventCache`,
71
+ Metadata: Bootstrap.Cache.Events,
72
+ Limited: true
73
+ })
74
+ }
@@ -11,26 +11,31 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { TypeHash } from "../@types/Hash"
22
- import { bootstrap } from "../bootstrap"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeHash } from "Types/Hash"
22
+ import { Bootstrap } from "@Bootstrap"
23
23
 
24
- export const SetHash = (event: TypeEvent, entry: TypeHash): void => {
25
- if (!entry) {
26
- bootstrap.cache.hashes.push({
27
- tracking: event.properties.metadata.tracking,
28
- hashes: [event.properties.metadata.hash],
29
- expires: event.properties.expires
24
+ interface SetHashOptions {
25
+ Event: TypeEvent
26
+ Entry: TypeHash
27
+ }
28
+
29
+ export const SetHash = ({ Event, Entry }: SetHashOptions): void => {
30
+ if (!Entry) {
31
+ Bootstrap.Cache.Hashes.push({
32
+ Tracking: Event.properties.metadata.tracking,
33
+ Hashes: [Event.properties.metadata.hash],
34
+ Expires: Event.properties.expires
30
35
  });
31
36
  return;
32
37
  }
33
38
 
34
- entry.hashes.push(event.properties.metadata.hash);
35
- entry.expires = event.properties.expires;
39
+ Entry.Hashes.push(Event.properties.metadata.hash);
40
+ Entry.Expires = Event.properties.expires;
36
41
  }
@@ -11,25 +11,25 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { bootstrap } from "../bootstrap"
22
- import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
23
- import { RemoveEvent } from "./RemoveEvent";
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
23
+ import { RemoveEvent } from "@Manager/RemoveEvent"
24
24
 
25
- export const UpdateEvents = async (selectedEvent?: TypeEvent): Promise<void> => {
26
- const events = bootstrap.cache.events.features;
25
+ export const UpdateEvents = async (selected?: TypeEvent): Promise<void> => {
26
+ const events = Bootstrap.Cache.Events.features;
27
27
  async function update(event: TypeEvent) {
28
28
  if (new Date(event.properties.expires) < new Date()) {
29
- SetEventEmit({ event: `onExpiredProduct`, metadata: event })
30
- await RemoveEvent(event, true)
29
+ SetEventEmit({ Event: `onExpiredProduct`, Metadata: event })
30
+ await RemoveEvent({ Event: event, IsTimeBasedExpiration: true })
31
31
  }
32
32
  }
33
- if (!selectedEvent) { await Promise.all(events.map(async (event) => { await update(event) })) }
34
- if (selectedEvent) { await update(selectedEvent) }
33
+ if (!selected) { await Promise.all(events.map(async (event) => { await update(event) })) }
34
+ if (selected) { await update(selected) }
35
35
  }
@@ -11,23 +11,23 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { bootstrap } from "../bootstrap"
22
- import { GetEventNodes } from "../@building/GetEventNodes";
23
- import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { GetEventNodes } from "@Building/GetEventNodes"
23
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
24
24
 
25
- export const UpdateNode = async (selectedEvent?: TypeEvent): Promise<void> => {
26
- const events = bootstrap.cache.events.features;
27
- const ttl = bootstrap.settings.GlobalSettings.NodeTTL * 1e3;
25
+ export const UpdateNode = async (selected?: TypeEvent): Promise<void> => {
26
+ const events = Bootstrap.Cache.Events.features;
27
+ const ttl = Bootstrap.Settings.GlobalSettings.NodeTTL * 1e3;
28
28
  let total = 0;
29
29
 
30
- const TTLEvents = selectedEvent ? [selectedEvent] : events.filter((evt) => {
30
+ const TTLEvents = selected ? [selected] : events.filter((evt) => {
31
31
  const lastUpdate = evt?.properties?.metadata?.updated ?? null;
32
32
  return lastUpdate == null || (Date.now() - lastUpdate) >= ttl;
33
33
  });
@@ -52,10 +52,10 @@ export const UpdateNode = async (selectedEvent?: TypeEvent): Promise<void> => {
52
52
 
53
53
  if (total > 0) {
54
54
  SetEventEmit({
55
- event: `onNodeUpdate`,
56
- metadata: {
57
- type: `global-update`,
58
- updated: total
55
+ Event: `onNodeUpdate`,
56
+ Metadata: {
57
+ Type: `global-update`,
58
+ Updated: total
59
59
  },
60
60
  })
61
61
  }
@@ -11,58 +11,61 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { TypeSettings } from "../@types/Settings";
22
- import { bootstrap } from "../bootstrap"
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";
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeSettings } from "Types/Settings"
22
+ import { Bootstrap } from "@Bootstrap"
23
+ import { GetEventEnhancedName } from "@Building/GetEventEnhancedName"
24
+ import { GetEventSignature } from "@Building/GetEventSignature"
25
+ import { MakeEvents } from "@Manager/MakeEvents"
26
+ import { RemoveEvent } from "@Manager/RemoveEvent"
27
+ import { GetEventAttachments } from "@Building/GetEventAttachments"
28
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
29
+ import { SetDebug } from "@Utilities/SetDebug"
30
+ import { GetMatched } from "@Utilities/GetMatched"
31
+ import { GetEventGeometry } from "@Building/GetEventGeometry"
32
32
  import { createHash } from "crypto"
33
33
 
34
34
  export const ValidateEvents = async (events: TypeEvent[]): Promise<void> => {
35
35
  const tick = performance.now();
36
36
  if (events.length === 0) return
37
- const configurations = bootstrap.settings as TypeSettings
37
+ const configurations = Bootstrap.Settings as TypeSettings
38
38
  const sets = {} as Record<string, Set<string>>;
39
39
  const bools = {} as Record<string, boolean>;
40
40
  const megered = {...configurations.GlobalSettings, ...configurations.GlobalSettings.EventFiltering}
41
41
  for (const key in megered) {
42
- const setting = megered[key];
43
- if (Array.isArray(setting)) { sets[key] = new Set(setting.map(item => item.toLowerCase())); }
44
- if (typeof setting === 'boolean') { bools[key] = setting; }
42
+ const setting = megered[key as keyof typeof megered]
43
+ if (Array.isArray(setting)) {
44
+ (sets as Record<string, any>)[key] = new Set(setting.map(item => String(item).toLowerCase()));
45
+ }
46
+ if (typeof setting === 'boolean') {
47
+ (bools as Record<string, any>)[key] = setting;
48
+ }
45
49
  }
46
-
47
50
  const isFiltered = (define: TypeEvent): boolean => {
48
51
  const properties = define.properties;
49
52
  const zones = properties.geocode.ugc;
50
53
  const icao = properties.geocode.office.office
51
54
 
52
55
  if (properties.status_metadata.is_test) {
53
- SetEventEmit({ event: `onTestProduct`, metadata: define })
56
+ SetEventEmit({ Event: `onTestProduct`, Metadata: define })
54
57
  if (bools?.IgnoreTestProducts) return true;
55
58
  }
56
59
 
57
60
  if (properties.status_metadata.is_expired) {
58
- SetEventEmit({ event: `onExpiredProduct`, metadata: define })
59
- RemoveEvent(define, false)
61
+ SetEventEmit({ Event: `onExpiredProduct`, Metadata: define })
62
+ RemoveEvent({ Event: define, IsTimeBasedExpiration: false })
60
63
  return true;
61
64
  }
62
65
 
63
- if (properties.metadata?.vtec?.is_watch && properties.metadata.source != `events.api`) {
64
- const isSPC = properties.metadata?.vtec?.prediction_center;
65
- SetEventEmit({ event: isSPC ? `onStormPredictionWatch` : `onNonStormPredictionWatch`, metadata: define })
66
+ if (properties.metadata?.vtec?.Watch && properties.metadata.source != `events.api`) {
67
+ const isSPC = properties.metadata?.vtec?.PredictionCenter;
68
+ SetEventEmit({ Event: isSPC ? `onStormPredictionWatch` : `onNonStormPredictionWatch`, Metadata: define })
66
69
  if (bools?.SPCWatchesOnly && !isSPC) {
67
70
  return true;
68
71
  }
@@ -74,45 +77,45 @@ export const ValidateEvents = async (events: TypeEvent[]): Promise<void> => {
74
77
  for (const key in sets) {
75
78
  const setting = sets[key]
76
79
  const values = [...setting];
77
- if (key === 'ListeningEvents' && setting.size > 0 && !GetMatched(values, define.properties.event)) {
80
+ if (key === 'ListeningEvents' && setting.size > 0 && !GetMatched({ Strings: values, String: define.properties.event })) {
78
81
  SetEventEmit({
79
- event: `onFilteredEvent`,
80
- metadata: define
82
+ Event: `onFilteredEvent`,
83
+ Metadata: define
81
84
  });
82
85
  return true
83
86
  }
84
- if (key === 'IgnoredEvents' && setting.size > 0 && GetMatched(values, define.properties.event)) {
87
+ if (key === 'IgnoredEvents' && setting.size > 0 && GetMatched({ Strings: values, String: define.properties.event })) {
85
88
  SetEventEmit({
86
- event: `onIgnoredEvent`,
87
- metadata: define
89
+ Event: `onIgnoredEvent`,
90
+ Metadata: define
88
91
  });
89
92
  return true
90
93
  }
91
94
  if (key === 'ListeningICAO' && setting.size > 0 && icao != null && !setting.has(icao.toLowerCase())) {
92
95
  SetEventEmit({
93
- event: `onFilteredICAO`,
94
- metadata: define
96
+ Event: `onFilteredICAO`,
97
+ Metadata: define
95
98
  });
96
99
  return true
97
100
  }
98
101
  if (key === 'IgnoredICAO' && setting.size > 0 && icao != null && setting.has(icao.toLowerCase())) {
99
102
  SetEventEmit({
100
- event: `onIgnoredICAO`,
101
- metadata: define
103
+ Event: `onIgnoredICAO`,
104
+ Metadata: define
102
105
  });
103
106
  return true
104
107
  }
105
108
  if (key === 'ListeningUGC' && setting.size > 0 && zones.length > 0 && !zones.some((ugc: string) => setting.has(ugc.toLowerCase()))) {
106
109
  SetEventEmit({
107
- event: `onFilteredUGC`,
108
- metadata: define
110
+ Event: `onFilteredUGC`,
111
+ Metadata: define
109
112
  });
110
113
  return true
111
114
  }
112
115
  if (key === 'ListeningStates' && setting.size > 0 && zones.length > 0 && !zones.some((ugc: string) => setting.has(ugc.substring(0, 2).toLowerCase()))) {
113
116
  SetEventEmit({
114
- event: `onFilteredState`,
115
- metadata: define
117
+ Event: `onFilteredState`,
118
+ Metadata: define
116
119
  });
117
120
  return true
118
121
  }
@@ -121,34 +124,21 @@ export const ValidateEvents = async (events: TypeEvent[]): Promise<void> => {
121
124
  }
122
125
 
123
126
  const filtering = events.filter((event: TypeEvent) => {
124
- bootstrap.cache.processed = bootstrap.cache.processed.filter((e) => e !== event);
127
+ Bootstrap.Cache.Parsed = Bootstrap.Cache.Parsed.filter((e) => e !== event);
125
128
  const define = GetEventSignature(event) as TypeEvent;
126
129
  const pre = {...define,properties: {...define.properties, metadata: {...define.properties.metadata }}};
127
130
  const properties = define.properties; delete pre.properties.metadata.ms; delete pre.properties.metadata.header;
128
131
  const enhanced = properties.event = GetEventEnhancedName(event)
129
132
  const filtered = isFiltered(define)
130
133
  if (!filtered) {
131
- event.geometry = !bools?.DisableGeometryParsing ? GetEventGeometry(event) : null;
134
+ event.geometry = !bools?.DisableGeometryParsing ? GetEventGeometry({ Event: event }) : null;
132
135
  properties.metadata.attachments = GetEventAttachments(event)
133
136
  }
134
137
  properties.metadata.hash = createHash("sha256").update(JSON.stringify(pre)).digest("hex")
135
- SetEventEmit({ event: `onProductType${enhanced.replace(/\s+/g, '')}`, metadata: define });
138
+ SetEventEmit({ Event: `onProductType${enhanced.replace(/\s+/g, '')}`, Metadata: define });
136
139
  return !filtered
137
140
  })
138
141
 
139
- SetDebug({ title: `ValidateEvents (PRE) (${filtering.length}/${events.length})`, message: `${Math.round(performance.now() - tick)}ms` })
140
-
141
- if (filtering.length > 0) {
142
- for (const event of filtering) {
143
- await MakeEvent(event)
144
- }
145
- }
146
-
147
- SetEventEmit({
148
- event: `onEventCache`,
149
- metadata: bootstrap.cache.events,
150
- limited: true
151
- })
152
-
153
- SetDebug({ title: `ValidateEvents (${filtering.length}/${events.length})`, message: `${Math.round(performance.now() - tick)}ms` })
142
+ SetDebug({ Title: `ValidateEvents (${filtering.length}/${events.length})`, Message: `${Math.round(performance.now() - tick)}ms` })
143
+ await MakeEvents(filtering)
154
144
  }
@@ -11,17 +11,17 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeHVTEC } from "../../@types/HVTEC";
21
- import { EnumCauses } from "../../@enums/Causes";
22
- import { EnumRecords } from "../../@enums/Records";
23
- import { EnumExpressions } from "../../@enums/Expressions";
24
- import { EnumSeverity } from "../../@enums/Severity";
20
+ import { TypeHVTEC } from "Types/HVTEC"
21
+ import { EnumCauses } from "@Enums/Causes"
22
+ import { EnumRecords } from "@Enums/Records"
23
+ import { EnumExpressions } from "@Enums/Expressions"
24
+ import { EnumSeverity } from "@Enums/Severity"
25
25
 
26
26
  export const HVExtract = (message: string): TypeHVTEC[] | null => {
27
27
  const getHVTECs = message.match(EnumExpressions.hvtec) ?? [];
@@ -30,10 +30,10 @@ export const HVExtract = (message: string): TypeHVTEC[] | null => {
30
30
  const sub = vtec.split(`.`);
31
31
  if (sub.length < 7) continue;
32
32
  vtecs.push({
33
- hvtec: vtec,
34
- severity: EnumSeverity[sub[1]],
35
- cause: EnumCauses[sub[2]],
36
- record: EnumRecords[sub[6]]
33
+ HVTEC: vtec,
34
+ Severity: EnumSeverity[sub[1]],
35
+ Cause: EnumCauses[sub[2]],
36
+ Record: EnumRecords[sub[6]]
37
37
  })
38
38
  }
39
39
  return vtecs.length > 0 ? vtecs : null;
@@ -11,21 +11,20 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { EnumExpressions } from "../../@enums/Expressions";
20
+ import { EnumExpressions } from "@Enums/Expressions"
21
21
 
22
22
  interface GetDescriptionFromProductOptions {
23
- message: string
24
- handle?: string
23
+ Message: string
24
+ Handle?: string
25
25
  }
26
26
 
27
- export const GetDescriptionFromProduct = (options: GetDescriptionFromProductOptions): string => {
28
- let message = options.message;
27
+ export const GetDescriptionFromProduct = ({ Message, Handle }: GetDescriptionFromProductOptions): string => {
29
28
  const predefinedEndMarkers = ['&&', 'LAT...'];
30
29
  const getEndIndex = (text: string, fromIndex = 0): number => {
31
30
  const indices = predefinedEndMarkers
@@ -33,28 +32,28 @@ export const GetDescriptionFromProduct = (options: GetDescriptionFromProductOpti
33
32
  .filter((idx) => idx !== -1);
34
33
  return indices.length ? Math.min(...indices) : -1;
35
34
  };
36
- const dates = Array.from(message.matchAll(EnumExpressions.dateline));
35
+ const dates = Array.from(Message.matchAll(EnumExpressions.dateline));
37
36
  if (dates.length) {
38
37
  const lastMatch = dates[dates.length - 1][0];
39
- const sIndx = message.lastIndexOf(lastMatch);
38
+ const sIndx = Message.lastIndexOf(lastMatch);
40
39
  if (sIndx !== -1) {
41
- const endIndx = getEndIndex(message, sIndx);
42
- message = message.substring(sIndx + lastMatch.length, endIndx !== -1 ? endIndx : undefined).trimStart();
43
- if (message.startsWith('/')) message = message.slice(1).trimStart();
44
- if (options.handle && message.includes(options.handle)) {
45
- const handleIdx = message.indexOf(options.handle);
46
- message = message.substring(handleIdx + options.handle.length).trimStart();
47
- if (message.startsWith('/')) message = message.slice(1).trimStart();
40
+ const endIndx = getEndIndex(Message, sIndx);
41
+ Message = Message.substring(sIndx + lastMatch.length, endIndx !== -1 ? endIndx : undefined).trimStart();
42
+ if (Message.startsWith('/')) Message = Message.slice(1).trimStart();
43
+ if (Handle && Message.includes(Handle)) {
44
+ const handleIdx = Message.indexOf(Handle);
45
+ Message = Message.substring(handleIdx + Handle.length).trimStart();
46
+ if (Message.startsWith('/')) Message = Message.slice(1).trimStart();
48
47
  }
49
48
  }
50
- } else if (options.handle) {
51
- const handleIndx = message.indexOf(options.handle);
49
+ } else if (Handle) {
50
+ const handleIndx = Message.indexOf(Handle);
52
51
  if (handleIndx !== -1) {
53
- let afterHandle = message.substring(handleIndx + options.handle.length).trimStart();
52
+ let afterHandle = Message.substring(handleIndx + Handle.length).trimStart();
54
53
  if (afterHandle.startsWith('/')) afterHandle = afterHandle.slice(1).trimStart();
55
54
  const latEnd = getEndIndex(afterHandle);
56
- message = latEnd !== -1 ? afterHandle.substring(0, latEnd).trim() : afterHandle.trim();
55
+ Message = latEnd !== -1 ? afterHandle.substring(0, latEnd).trim() : afterHandle.trim();
57
56
  }
58
57
  }
59
- return message.trim();
58
+ return Message.trim();
60
59
  }