@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,129 @@
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 { TypeStanzaCompiled } from "Types/StanzaCompiled"
21
+ import { TypeVTEC } from "Types/VTEC"
22
+ import { EnumICAO } from "@Enums/ICAO"
23
+ import { Bootstrap } from "@Bootstrap"
24
+ import { GetEventTracking } from "@Building/GetEventTracking"
25
+ import { VTECExtract } from "@ParsingVTEC/VTECExtract"
26
+ import { GetEventTags } from "@Building/GetEventTags"
27
+ import { GetEventTheme } from "@Building/GetEventTheme"
28
+ import { GetEventDirection } from "@Building/GetEventDirection"
29
+ import { GetTextFromProduct } from "@ParsingText/GetTextFromProduct"
30
+ import { SetDebug } from "@Utilities/SetDebug"
31
+
32
+ export const ParseAPI = async (Stanza: TypeStanzaCompiled): Promise<void> => {
33
+ const messages = Object.values(JSON.parse(Stanza.Message).features) as any;
34
+ for (const feature of messages) {
35
+ const tick = performance.now();
36
+ const VTEC = VTECExtract(feature?.properties?.parameters?.VTEC?.[0]) ?? null as TypeVTEC[]
37
+ Bootstrap.Cache.Parsed.push({
38
+ type: `Feature`,
39
+ geometry: {
40
+ type: `Polygon`,
41
+ coordinates: []
42
+ },
43
+ properties: {
44
+ event: feature?.properties?.event ?? null,
45
+ parent: feature?.properties?.event ?? null,
46
+ status: feature?.properties?.messageType ?? null,
47
+ issued: feature?.properties?.sent ? new Date(feature?.properties?.sent).toISOString() : null,
48
+ expires: feature?.properties?.expires ? new Date(feature?.properties?.expires).toISOString() : null,
49
+ locations: feature?.properties?.areaDesc ?? null,
50
+ locations_array: feature?.properties?.areaDesc ? feature?.properties?.areaDesc.split('; ') : [],
51
+ regions: [...new Set(
52
+ feature?.properties?.geocode?.UGC?.map((ugc: string) => ugc.match(/^([A-Z]{2})[CZ](\d{3})$/)?.[1])
53
+ .filter(Boolean) ?? []
54
+ )] as string[],
55
+ regions_string: (() => {
56
+ const abbrs = [...new Set(feature?.properties?.geocode?.UGC?.map((l: string) => l.match(/^([A-Z]{2})[CZ](\d{3})$/)?.[1]).filter(Boolean) ?? [])];
57
+ return abbrs.length ? abbrs.join(`-`) : null;
58
+ })(),
59
+ description: feature?.properties?.description ?? null,
60
+ attributes: feature?.properties?.attributes ?? {},
61
+ theme: GetEventTheme(feature?.properties?.event),
62
+ geocode: {
63
+ office: {
64
+ office: VTEC ? VTEC?.[0]?.Tracking.split(`.`)[0] : null,
65
+ name: EnumICAO[VTEC ? VTEC?.[0]?.Tracking.split(`.`)[0] : null] ?? null,
66
+ },
67
+ organization: feature?.properties?.parameters?.WMOidentifier?.[0],
68
+ ugc: feature?.properties?.geocode?.UGC ?? [],
69
+ polygon: feature?.geometry?.coordinates.length > 0 ? Buffer.from(JSON.stringify([feature?.geometry?.coordinates[0]])).toString('base64') : null,
70
+ polygon_generated: feature?.geometry?.coordinates.length > 0 ? true : false,
71
+ },
72
+ parameters: {
73
+ tags: GetEventTags(feature?.properties?.description),
74
+ instructions: feature?.properties?.instruction ?? null,
75
+ source: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`SOURCE...`], Removal: [`.`]}) ?? null,
76
+ hazards: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`HAZARD...`], Removal: [`.`]}) ?? null,
77
+ impacts: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`IMPACT...`], Removal: [`.`]}) ?? null,
78
+ estimated_hail_size: feature?.properties?.parameters?.maxHailSize?.[0] ?? null,
79
+ estimated_wind_gusts: feature?.properties?.parameters?.maxWindGust?.[0] ?? null,
80
+ direction: GetEventDirection(feature?.properties?.description) ?? null,
81
+ damage_threat: feature?.properties?.parameters?.thunderstormDamageThreat?.[0] ?? null,
82
+ tornado_threat: feature?.properties?.parameters?.tornadoDetection?.[0] ?? null,
83
+ flood_threat: feature?.properties?.parameters?.flashFloodDamageThreat?.[0] ?? null,
84
+ wind_threat: feature?.properties?.parameters?.windThreat?.[0] ?? null,
85
+ hail_threat: feature?.properties?.parameters?.hailThreat?.[0] ?? null,
86
+ },
87
+ discussion_parameters: {
88
+ discussion_number: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`Mesoscale Discussion `], Removal: [`Mesoscale Discussion`, `Number`, `...`] })?.toString()?.padStart(4, "0") ?? null,
89
+ discussion_concerning: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`Concerning...`] }) ?? null,
90
+ discussion_max_tornado: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`MOST PROBABLE PEAK TORNADO INTENSITY...`] }) ?? null,
91
+ discussion_max_hail: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`MOST PROBABLE PEAK HAIL SIZE...`] }) ?? null,
92
+ discussion_max_wind: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`MOST PROBABLE PEAK WIND GUST...`] }) ?? null,
93
+ discussion_watch_issuance: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`Probability of Watch Issuance...`], Removal: [`percent`]}) ?? null,
94
+ },
95
+ watch_parameters: {
96
+ watch_number: (VTEC?.[0]?.Watch) && (GetTextFromProduct({ Message: feature?.properties?.description, Find: [`ITIES FOR`, `UPDATE FOR`, `Watch Number `], Removal: [`%`, `<`, `:`] })?.replace(/(WT|WS|)/g, '')?.trim()?.toString()?.padStart(4, "0") ?? VTEC?.[0]?.Tracking?.slice(-4)?.toString()?.padStart(4, "0") ?? null),
97
+ watch_type: feature?.properties?.description.includes(`TORNADO WATCH`) ? `Tornado` : feature?.properties?.description.includes(`SEVERE`) ? `Severe` : null,
98
+ additional_tornadoes_probability: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`PROB OF 2 OR MORE TORNADOES`], Removal: [`%`, `<`, `:`] }) ?? null,
99
+ strong_tornadoes_probability: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`PROB OF 1 OR MORE STRONG /EF2-EF5/ TORNADOES`], Removal: [`%`, `<`, `:`] }) ?? null,
100
+ severe_wind_probability: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`PROB OF 10 OR MORE SEVERE WIND EVENTS`], Removal: [`%`, `<`, `:`] }) ?? null,
101
+ severe_hail_probability: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`PROB OF 10 OR MORE SEVERE HAIL EVENTS`], Removal: [`%`, `<`, `:`] }) ?? null,
102
+ hail_2in_probability: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`PROB OF 1 OR MORE HAIL EVENTS >= 2 INCHES`], Removal: [`%`, `<`, `:`] }) ?? null,
103
+ combined_hail_wind_probability: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`PROB OF 6 OR MORE COMBINED SEVERE HAIL/WIND EVENTS`], Removal: [`%`, `<`, `:`] }) ?? null,
104
+ max_hail_in: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`MAX HAIL /INCHES/`], Removal: [`%`, `<`, `:`] }) ?? null,
105
+ max_wind_surface: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`MAX WIND GUSTS SURFACE /KNOTS/`], Removal: [`%`, `<`, `:`] }) ?? null,
106
+ max_tops_x100feet: GetTextFromProduct({ Message: feature?.properties?.description, Find: [`MAX TOPS /X 100 FEET/`], Removal: [`%`, `<`, `:`] }) ?? null,
107
+ pds_watch: (GetTextFromProduct({ Message: feature?.properties?.description, Find: [`PARTICULARLY DANGEROUS SITUATION`], Removal: [`%`, `<`, `:`] }) === `YES`)
108
+ },
109
+ metadata: {
110
+ ms: performance.now() - tick,
111
+ source: `events.api`,
112
+ tracking: GetEventTracking({ Type: `API`, WMO: { Identifier: feature?.properties?.parameters?.WMOidentifier?.[0], ID: feature?.id}, VTEC: VTEC?.[0]}),
113
+ header: `ZCZC-ATMOSX-${feature?.properties?.parameters?.WMOidentifier}`,
114
+ vtec: VTEC?.[0],
115
+ hvtec: null,
116
+ raw: feature?.properties?.description,
117
+ history: [
118
+ {
119
+ description: feature?.properties?.description,
120
+ issued: feature?.properties?.sent ? new Date(feature?.properties?.sent).toISOString() : null,
121
+ status: feature?.properties?.messageType ?? null,
122
+ }
123
+ ]
124
+ }
125
+ }
126
+ })
127
+ SetDebug({ Title: `ParseAPI`, Message: `${Math.round(performance.now() - tick)}ms` })
128
+ }
129
+ }
@@ -11,51 +11,52 @@
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 { TypeAttributes } from "../@types/Attributes";
21
- import { TypeStanzaCompiled } from "../@types/StanzaCompiled"
22
- import { EnumMatches } from "../@enums/Matches";
23
- import { bootstrap } from "../bootstrap";
24
- import { GetEventProperties } from "../@building/GetEventProperties";
25
- import { GetEventHeader } from "../@building/GetEventHeader";
26
- import { GetEventTracking } from "../@building/GetEventTracking";
27
- import { SetDebug } from "../@modules/@utilities/SetDebug";
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
+ import { TypeStanzaCompiled } from "Types/StanzaCompiled"
22
+ import { EnumMatches } from "@Enums/Matches"
23
+ import { Bootstrap } from "@Bootstrap"
24
+ import { GetEventProperties } from "@Building/GetEventProperties"
25
+ import { GetEventHeader } from "@Building/GetEventHeader"
26
+ import { GetEventTracking } from "@Building/GetEventTracking"
27
+ import { GetEventTheme } from "@Building/GetEventTheme"
28
+ import { SetDebug } from "@Utilities/SetDebug"
28
29
 
29
- export const ParseText = async (stanza: TypeStanzaCompiled): Promise<void> => {
30
- const getMessages = stanza?.message
30
+ export const ParseText = async (Stanza: TypeStanzaCompiled): Promise<void> => {
31
+ const getMessages = Stanza?.Message
31
32
  ?.split(/(?=\$\$)/g)
32
33
  ?.map(message => message.trim())
33
34
  ?.filter(message => message && message !== "$$");
34
35
  if (!getMessages || getMessages?.length == 0 ) return;
35
36
  for (const message of getMessages) {
36
37
  const tick = performance.now();
37
- const attributes = stanza?.attributes as TypeAttributes
38
- const props = GetEventProperties({ message, attributes })
39
- const header = GetEventHeader({properties: props, getType: stanza.getType})
38
+ const attributes = Stanza?.Attributes as TypeAttributes
39
+ const props = GetEventProperties({ Message: message, Attributes: attributes })
40
+ const header = GetEventHeader({ Properties: props, VTEC: null, Type: Stanza.Type })
40
41
  const issued = new Date(attributes.issue)
41
42
  const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1000)
42
- const matches = EnumMatches[stanza.getType.prefix]?.find(match => match.match.test(message.toUpperCase()));
43
+ const matches = EnumMatches[Stanza.Type.Prefix]?.find(match => match.match.test(message.toUpperCase()));
43
44
 
44
45
  let event = matches?.label;
45
46
  let isStatement = matches?.statement ?? false;
46
47
 
47
48
  if (!event) {
48
- event = stanza.getType.type;
49
- if (!stanza.getType.discovered) {
49
+ event = Stanza.Type.Type;
50
+ if (!Stanza.Type.Discovered) {
50
51
  event += ` (AWIPSID)`
51
52
  }
52
53
  isStatement = true;
53
54
  }
54
55
 
55
- bootstrap.cache.processed.push({
56
+ Bootstrap.Cache.Parsed.push({
56
57
  type: `Feature`,
57
58
  geometry: {
58
- type: `Point`,
59
+ type: `Polygon`,
59
60
  coordinates: []
60
61
  },
61
62
  properties: {
@@ -64,11 +65,12 @@ export const ParseText = async (stanza: TypeStanzaCompiled): Promise<void> => {
64
65
  status: isStatement ? `Statement` : `Issued`,
65
66
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
66
67
  expires: isStatement ? new Date(issued.getTime() + 120 * 1000).toISOString() : (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
68
+ theme: GetEventTheme(event),
67
69
  ...props,
68
70
  metadata: {
69
71
  ms: performance.now() - tick,
70
72
  source: `events.text`,
71
- tracking: GetEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
73
+ tracking: GetEventTracking({ Type: `RAW`, Stanza, Attributes: attributes, Properties: props }),
72
74
  header: header,
73
75
  vtec: null,
74
76
  hvtec: null,
@@ -83,6 +85,6 @@ export const ParseText = async (stanza: TypeStanzaCompiled): Promise<void> => {
83
85
  }
84
86
  }
85
87
  })
86
- SetDebug({ title: `ParseText`, message: `${Math.round(performance.now() - tick)}ms` })
88
+ SetDebug({ Title: `ParseText`, Message: `${Math.round(performance.now() - tick)}ms` })
87
89
  }
88
90
  }
@@ -11,56 +11,56 @@
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 { TypeAttributes } from "../@types/Attributes";
21
- import { TypeStanzaCompiled } from "../@types/StanzaCompiled"
22
- import { EnumMatches } from "../@enums/Matches";
23
- import { bootstrap } from "../bootstrap";
24
- import { ugcExtract } from "../@parsers/@ugc/UGCExtract";
25
- import { GetEventProperties } from "../@building/GetEventProperties";
26
- import { GetEventHeader } from "../@building/GetEventHeader";
27
- import { GetEventTracking } from "../@building/GetEventTracking";
28
- import { SetDebug } from "../@modules/@utilities/SetDebug";
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
+ import { TypeStanzaCompiled } from "Types/StanzaCompiled"
22
+ import { EnumMatches } from "@Enums/Matches"
23
+ import { Bootstrap } from "@Bootstrap"
24
+ import { UGCExtract } from "@ParsingUGC/UGCExtract"
25
+ import { GetEventProperties } from "@Building/GetEventProperties"
26
+ import { GetEventHeader } from "@Building/GetEventHeader"
27
+ import { GetEventTracking } from "@Building/GetEventTracking"
28
+ import { GetEventTheme } from "@Building/GetEventTheme"
29
+ import { SetDebug } from "@Utilities/SetDebug"
29
30
 
30
- export const ParseUGC = async (stanza: TypeStanzaCompiled): Promise<void> => {
31
- const getMessages = stanza?.message
31
+ export const ParseUGC = async (Stanza: TypeStanzaCompiled): Promise<void> => {
32
+ const getMessages = Stanza?.Message
32
33
  ?.split(/(?=\$\$)/g)
33
34
  ?.map(message => message.trim())
34
35
  ?.filter(message => message && message !== "$$");
35
36
  if (!getMessages || getMessages?.length == 0 ) return;
36
37
  for (const message of getMessages) {
37
38
  const tick = performance.now();
38
- const attributes = stanza?.attributes as TypeAttributes
39
- const ugc = await ugcExtract(message)
39
+ const attributes = Stanza?.Attributes as TypeAttributes
40
+ const ugc = await UGCExtract(message)
40
41
 
41
42
  if (ugc != null ) {
42
- const props = GetEventProperties({ message, attributes, ugc: ugc })
43
+ const props = GetEventProperties({ Message: message, Attributes: attributes, UGC: ugc })
43
44
  const issued = new Date(attributes.issue)
44
- const expires = new Date(ugc.expires)
45
- const header = GetEventHeader({properties: props, getType: stanza.getType })
46
- const matches = EnumMatches[stanza.getType.prefix]?.find(match => match.match.test(message.toUpperCase()));
45
+ const expires = new Date(ugc.Expires)
46
+ const header = GetEventHeader({ Properties: props, VTEC: null, Type: Stanza.Type })
47
+ const matches = EnumMatches[Stanza.Type.Prefix]?.find(match => match.match.test(message.toUpperCase()));
47
48
 
48
49
  let event = matches?.label;
49
50
  let isStatement = matches?.statement ?? false;
50
51
 
51
52
  if (!event) {
52
- event = stanza.getType.type;
53
- if (!stanza.getType.discovered) {
53
+ event = Stanza.Type.Type;
54
+ if (!Stanza.Type.Discovered) {
54
55
  event += ` (AWIPSID)`
55
56
  }
56
57
  isStatement = true;
57
-
58
58
  }
59
59
 
60
- bootstrap.cache.processed.push({
60
+ Bootstrap.Cache.Parsed.push({
61
61
  type: `Feature`,
62
62
  geometry: {
63
- type: `Point`,
63
+ type: `Polygon`,
64
64
  coordinates: []
65
65
  },
66
66
  properties: {
@@ -69,11 +69,12 @@ export const ParseUGC = async (stanza: TypeStanzaCompiled): Promise<void> => {
69
69
  status: isStatement ? `Statement` : `Issued`,
70
70
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
71
71
  expires: isStatement ? new Date(issued.getTime() + 120 * 1000).toISOString() : (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
72
+ theme: GetEventTheme(event),
72
73
  ...props,
73
74
  metadata: {
74
75
  ms: performance.now() - tick,
75
76
  source: `events.ugc`,
76
- tracking: GetEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
77
+ tracking: GetEventTracking({ Type: `RAW`, Stanza, Attributes: attributes, Properties: props }),
77
78
  header: header,
78
79
  vtec: null,
79
80
  hvtec: null,
@@ -88,7 +89,7 @@ export const ParseUGC = async (stanza: TypeStanzaCompiled): Promise<void> => {
88
89
  }
89
90
  }
90
91
  })
91
- SetDebug({ title: `ParseUGC`, message: `${Math.round(performance.now() - tick)}ms` })
92
+ SetDebug({ Title: `ParseUGC`, Message: `${Math.round(performance.now() - tick)}ms` })
92
93
  }
93
94
  }
94
95
  }
@@ -11,76 +11,77 @@
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 { TypeAttributes } from "../@types/Attributes";
21
- import { TypeStanzaCompiled } from "../@types/StanzaCompiled"
22
- import { TypePVTEC } from "../@types/VTEC";
23
- import { TypeHVTEC } from "../@types/HVTEC";
24
- import { bootstrap } from "../bootstrap";
25
- import { VTECExtract } from "../@parsers/@pvtec/VTECExtract";
26
- import { HVExtract } from "../@parsers/@hvtec/HVExtract";
27
- import { ugcExtract } from "../@parsers/@ugc/UGCExtract";
28
- import { GetEventProperties } from "../@building/GetEventProperties";
29
- import { GetEventHeader } from "../@building/GetEventHeader";
30
- import { GetEventTracking } from "../@building/GetEventTracking";
31
- import { SetDebug } from "../@modules/@utilities/SetDebug";
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
+ import { TypeStanzaCompiled } from "Types/StanzaCompiled"
22
+ import { TypeVTEC } from "Types/VTEC"
23
+ import { TypeHVTEC } from "Types/HVTEC"
24
+ import { Bootstrap } from "@Bootstrap"
25
+ import { VTECExtract } from "@ParsingVTEC/VTECExtract"
26
+ import { HVExtract } from "@ParsingHVTEC/HVExtract"
27
+ import { UGCExtract } from "@ParsingUGC/UGCExtract"
28
+ import { GetEventProperties } from "@Building/GetEventProperties"
29
+ import { GetEventHeader } from "@Building/GetEventHeader"
30
+ import { GetEventTracking } from "@Building/GetEventTracking"
31
+ import { GetEventTheme } from "@Building/GetEventTheme"
32
+ import { SetDebug } from "@Utilities/SetDebug"
32
33
 
33
- export const ParseVTEC = async (stanza: TypeStanzaCompiled): Promise<void> => {
34
- const getMessages = stanza?.message
34
+ export const ParseVTEC = async (Stanza: TypeStanzaCompiled): Promise<void> => {
35
+ const getMessages = Stanza?.Message
35
36
  ?.split(/(?=\$\$)/g)
36
37
  ?.map(message => message.trim())
37
38
  ?.filter(message => message && message !== "$$");
38
39
  if (!getMessages || getMessages?.length == 0 ) return;
39
40
  for (const message of getMessages) {
40
41
  const tick = performance.now();
41
- const attributes = stanza?.attributes as TypeAttributes
42
- const pVtec = VTECExtract(message) as TypePVTEC[];
43
- const hVtec = HVExtract(message) as TypeHVTEC[];
44
- const ugc = await ugcExtract(message)
45
- if (pVtec != null && ugc != null ) {
46
- for (const pv of pVtec) {
47
- const vtec = pv;
48
- const props = GetEventProperties({ message, attributes, ugc, pVtec: vtec })
49
- const header = GetEventHeader({properties: props, getType: stanza.getType, vtec: vtec})
42
+ const attributes = Stanza?.Attributes as TypeAttributes
43
+ const VTEC = VTECExtract(message) as TypeVTEC[];
44
+ const hVTEC = HVExtract(message) as TypeHVTEC[];
45
+ const ugc = await UGCExtract(message)
46
+ if (VTEC != null && ugc != null ) {
47
+ for (const vtec of VTEC) {
48
+ const props = GetEventProperties({ Message: message, Attributes: attributes, UGC: ugc, VTEC: vtec })
49
+ const header = GetEventHeader({ Properties: props, VTEC: vtec, Type: Stanza.Type })
50
50
  const issued = new Date(attributes.issue)?? new Date()
51
- const expires = new Date(vtec.expires)
52
- bootstrap.cache.processed.push({
51
+ const expires = new Date(vtec.Expires)
52
+ Bootstrap.Cache.Parsed.push({
53
53
  type: `Feature`,
54
54
  geometry: {
55
- type: `Point`,
55
+ type: `Polygon`,
56
56
  coordinates: []
57
57
  },
58
58
  properties: {
59
- event: pv.event,
60
- parent: pv.event,
61
- status: pv.status,
59
+ event: vtec.Event,
60
+ parent: vtec.Event,
61
+ status: vtec.Status,
62
62
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
63
- expires: (!isNaN(expires.getTime())) ? expires.toISOString() : ugc.expires ?? new Date(issued.getTime() + 60 * 60 * 1000).toISOString(),
63
+ expires: (!isNaN(expires.getTime())) ? expires.toISOString() : ugc.Expires ?? new Date(issued.getTime() + 60 * 60 * 1000).toISOString(),
64
+ theme: GetEventTheme(vtec.Event),
64
65
  ...props,
65
66
  metadata: {
66
67
  ms: performance.now() - tick,
67
68
  source: `events.vtec`,
68
- tracking: GetEventTracking({ type: `VTEC`, stanza, attributes, properties: props, vtec }),
69
+ tracking: GetEventTracking({ Type: `VTEC`, Stanza, Attributes: attributes, Properties: props, VTEC: vtec }),
69
70
  header: header,
70
- vtec: pv,
71
- hvtec: hVtec,
71
+ vtec: vtec,
72
+ hvtec: hVTEC,
72
73
  raw: message,
73
74
  history: [
74
75
  {
75
76
  description: props.description,
76
77
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
77
- status: pv.status
78
+ status: vtec.Status
78
79
  }
79
80
  ]
80
81
  }
81
82
  }
82
83
  })
83
- SetDebug({ title: `ParseVTEC`, message: `${Math.round(performance.now() - tick)}ms` })
84
+ SetDebug({ Title: `ParseVTEC`, Message: `${Math.round(performance.now() - tick)}ms` })
84
85
  }
85
86
  }
86
87
  }
package/src/index.ts CHANGED
@@ -11,64 +11,84 @@
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 { TypeSettings } from './@types/Settings'
21
- import { SetSettings } from "./@modules/@utilities/SetSettings"
22
- import { GetEventGeometry } from "./@building/GetEventGeometry";
23
- import { GetCleanedEvent } from "./@building/GetCleanedEvent"
24
- import { SetEventEmit } from './@modules/@utilities/SetEventEmit';
25
- import { SetWarning } from './@modules/@utilities/SetWarning';
26
- import { CreateListener } from "./@core/CreateListener"
27
- import { StartService } from "./@core/StartService"
28
- import { StopService } from "./@core/StopService"
29
- import { GenerateEASMessage } from './@modules/@eas/GenerateEASMessage';
30
- import { SetNode } from "./@core/SetNode"
31
- import { GetEvents } from "./@core/GetEvents"
32
- import { GetNodes } from "./@core/GetNodes"
33
- import { ManualEvent } from "./@core/ManualEvent"
34
- import { GetRandomEvent } from './@core/GetRandomEvent';
35
- import { QueryStanza } from './@core/QueryStanza';
36
- import { ClearEvents } from './@core/ClearEvents';
20
+ import { TypeSettings } from "Types/Settings"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { GetEventGeometry } from "@Building/GetEventGeometry"
23
+ import { GetCleanedEvent } from "@Building/GetCleanedEvent"
24
+ import { SetSettings } from "@Utilities/SetSettings"
25
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
26
+ import { SetWarning } from "@Utilities/SetWarning"
27
+ import { GenerateAudioMessage } from "@Audio/GenerateAudioMessage"
28
+ import { GenerateGraphic } from "@Image/GenerateGraphic"
29
+ import { SetNode } from "@Core/SetNode"
30
+ import { GetEvents } from "@Core/GetEvents"
31
+ import { GetNodes } from "@Core/GetNodes"
32
+ import { ManualEvent } from "@Core/ManualEvent"
33
+ import { GetRandomEvent } from "@Core/GetRandomEvent"
34
+ import { QueryStanza } from "@Core/QueryStanza"
35
+ import { ClearEvents } from "@Core/ClearEvents"
36
+ import { StartService } from "@Core/StartService"
37
+ import { StopService } from "@Core/StopService"
38
+ import { GetVersion } from "@Core/GetVersion"
39
+
37
40
 
38
41
  export class Manager {
39
- constructor(settings: TypeSettings) { this.trycatch(); StartService(settings) }
42
+ public constructor(settings: TypeSettings) {
43
+ this.ErrorHandler(); StartService(settings)
44
+ }
40
45
 
41
- on(event: string, callback: () => void) {
42
- CreateListener(event, callback)
46
+ public on(event: string, callback: () => void) {
47
+ Bootstrap.Listener.on(event, callback)
48
+ return () => { void Bootstrap.Listener.off(event, callback) };
43
49
  }
44
50
 
45
- trycatch() {
46
- process.on('uncaughtException', (err: any) => {
47
- const ignored = ['ETIMEDOUT', 'ECONNRESET', 'EHOSTUNREACH', 'ENOTFOUND', 'ECONNREFUSED', 'EPIPE', 'EADDRINUSE', 'EALREADY', 'EACCES', 'EAGAIN', 'EHOSTDOWN', 'STARTTLS_FAILURE'];
48
- if (ignored.includes(err?.code)) {
51
+ private ErrorHandler() {
52
+ process.on('uncaughtException', (error: any) => {
53
+ const _IGNORED = [
54
+ 'ETIMEDOUT',
55
+ 'ECONNRESET',
56
+ 'EHOSTUNREACH',
57
+ 'ENOTFOUND',
58
+ 'ECONNREFUSED',
59
+ 'EPIPE',
60
+ 'EADDRINUSE',
61
+ 'EALREADY',
62
+ 'EACCES',
63
+ 'EAGAIN',
64
+ 'EHOSTDOWN',
65
+ 'STARTTLS_FAILURE'
66
+ ];
67
+ if (_IGNORED.includes(error?.code)) {
49
68
  SetEventEmit({
50
- event: `onServiceStatus`,
51
- metadata: {
52
- message: `Ignored Critical Error: ${err?.code ?? 'Unknown error code'}. This may indicate a connection issue. Attempting to continue...`,
53
- data: {},
54
- type: `error`,
55
- error: true
69
+ Event: `onServiceStatus`,
70
+ Metadata: {
71
+ Message: `Ignored Critical Error: ${error?.code ?? 'Unknown error code'}. This may indicate a connection issue. Attempting to continue...`,
72
+ Data: {},
73
+ Type: `error`,
74
+ Error: true
56
75
  }
57
76
  })
58
- return;
59
77
  }
60
- SetWarning({message: `Uncaught Exception: ${err instanceof Error ? err.stack ?? err.message : String(err)}`})
78
+ console.log(`Uncaught Exception: ${error instanceof Error ? error.stack ?? error.message : String(error)}`);
79
+ SetWarning({Message: `Uncaught Exception: ${error instanceof Error ? error.stack ?? error.message : String(error)}`})
61
80
  })
62
81
  }
63
82
  }
64
83
 
65
84
  export default Manager;
66
- export type { TypeEvent } from './@types/Event';
85
+ export type { TypeEvent } from "StaticTypes/Event"
67
86
  export {
68
87
  SetSettings, GetEventGeometry, ManualEvent,
69
88
  GetCleanedEvent, StopService, ClearEvents,
70
- StartService, SetNode, GetRandomEvent,
71
- GetEvents, GetNodes, GenerateEASMessage, QueryStanza
89
+ StartService, SetNode, GetRandomEvent, GetVersion,
90
+ GetEvents, GetNodes, GenerateAudioMessage, GenerateGraphic,
91
+ QueryStanza
72
92
  }
73
93
 
74
94