@atmosx/event-product-parser 3.0.4 → 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 (212) hide show
  1. package/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
  2. package/.github/SUPPORTED_EVENTS.md +370 -0
  3. package/.github/docs/docs-functions.md +30 -0
  4. package/.github/docs/docs-general-configurations.md +199 -0
  5. package/.github/docs/docs-integrations.md +38 -0
  6. package/.github/docs/docs-listeners.md +28 -0
  7. package/.github/docs/docs-source-configuration.md +218 -0
  8. package/.github/docs/docs-technical.md +50 -0
  9. package/.github/logo.png +0 -0
  10. package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
  11. package/.github/samples/SAMPLE_GEOJSON.json +204 -0
  12. package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
  13. package/README.md +157 -337
  14. package/dist/cjs/index.cjs +24125 -15815
  15. package/dist/esm/index.mjs +24144 -15839
  16. package/package.json +56 -53
  17. package/pnpm-workspace.yaml +4 -0
  18. package/src/bootstrap.ts +83 -43
  19. package/src/building/CreateEvent.ts +54 -0
  20. package/src/{@building/building.clean.ts → building/GetCleanedEvent.ts} +4 -4
  21. package/src/building/GetEventAttachments.ts +88 -0
  22. package/src/building/GetEventDirection.ts +28 -0
  23. package/src/{@building/building.enhance.ts → building/GetEventEnhancedName.ts} +13 -17
  24. package/src/{@building/building.geometry.ts → building/GetEventGeometry.ts} +19 -13
  25. package/src/{@building/building.headers.ts → building/GetEventHeader.ts} +13 -13
  26. package/src/{@building/building.polygon.ts → building/GetEventNodes.ts} +26 -22
  27. package/src/{@building/building.office.ts → building/GetEventOffice.ts} +14 -14
  28. package/src/building/GetEventProperties.ts +105 -0
  29. package/src/{@building/building.signature.ts → building/GetEventSignature.ts} +16 -17
  30. package/src/{@core/core.createListener.ts → building/GetEventTags.ts} +11 -6
  31. package/src/building/GetEventTheme.ts +26 -0
  32. package/src/building/GetEventTracking.ts +64 -0
  33. package/src/components/audio/GenerateAudioMessage.ts +149 -0
  34. package/src/components/audio/components/GetCleanDescription.ts +91 -0
  35. package/src/{@modules/@eas/eas.getFloatPCM16.ts → components/audio/components/GetFloatPCM16.ts} +3 -3
  36. package/src/{@modules/@eas/eas.getMergedPCM16.ts → components/audio/components/GetMergedPCM16.ts} +3 -3
  37. package/src/{@modules/@eas/eas.getPCM16.ts → components/audio/components/GetPCM16.ts} +13 -8
  38. package/src/{@modules/@eas/eas.getPCMToFloat.ts → components/audio/components/GetPCMToFloat.ts} +3 -3
  39. package/src/{@modules/@eas/eas.getSampledPCM16.ts → components/audio/components/GetSampledPCM16.ts} +14 -8
  40. package/src/components/audio/components/GetTTS.ts +61 -0
  41. package/src/{@modules/@eas/eas.getWavPCM16.ts → components/audio/components/GetWavPCM16.ts} +8 -8
  42. package/src/{@modules/@eas/eas.setAFSK.ts → components/audio/components/SetAFSK.ts} +12 -8
  43. package/src/{@modules/@eas/eas.setAsciiToBits.ts → components/audio/components/SetAsciiToBits.ts} +3 -4
  44. package/src/{@modules/@eas/eas.setAttentionTone.ts → components/audio/components/SetAttentionTone.ts} +11 -6
  45. package/src/{@modules/@eas/eas.setNoise.ts → components/audio/components/SetNoise.ts} +14 -8
  46. package/src/{@modules/@eas/eas.setRadioEffect.ts → components/audio/components/SetRadioEffect.ts} +14 -8
  47. package/src/{@modules/@eas/eas.setSameHeader.ts → components/audio/components/SetSameHeader.ts} +22 -15
  48. package/src/{@modules/@utilities/utilities.setWarning.ts → components/database/CreateQuery.ts} +18 -13
  49. package/src/{@modules/@database/database.cache.ts → components/database/GetCachedEvents.ts} +19 -14
  50. package/src/components/database/ImportBoundaries.ts +168 -0
  51. package/src/components/database/ImportBroadcastify.ts +60 -0
  52. package/src/components/database/ImportCities.ts +87 -0
  53. package/src/{@modules/@database/database.shapefiles.ts → components/database/ImportShapefiles.ts} +31 -37
  54. package/src/components/database/ImportStanza.ts +43 -0
  55. package/src/components/database/InitializeDatabase.ts +71 -0
  56. package/src/components/images/GenerateGraphic.ts +234 -0
  57. package/src/components/images/components/CreateRectangle.ts +22 -0
  58. package/src/components/images/components/CreateText.ts +22 -0
  59. package/src/components/images/modules/CreateSVG.ts +37 -0
  60. package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
  61. package/src/components/images/modules/GetGeographicalCities.ts +58 -0
  62. package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
  63. package/src/components/images/modules/GetGeometryBounds.ts +82 -0
  64. package/src/components/images/modules/GetParsedBoundary.ts +58 -0
  65. package/src/components/images/modules/GetSVGPath.ts +53 -0
  66. package/src/components/images/modules/NormalizePolygon.ts +57 -0
  67. package/src/{@modules/@stanza/stanza.getAwipsType.ts → components/stanza/GetAwipsType.ts} +19 -18
  68. package/src/components/stanza/ValidateStanza.ts +62 -0
  69. package/src/components/utilities/CreateHttp.ts +83 -0
  70. package/src/{@modules/@utilities/utilities.getFormattedTime.ts → components/utilities/GetFormattedTime.ts} +3 -3
  71. package/src/components/utilities/GetLatestIssuance.ts +32 -0
  72. package/src/components/utilities/GetMatched.ts +38 -0
  73. package/src/{@modules/@utilities/utilities.getShapeNearestPoint.ts → components/utilities/GetShapeNearestPoint.ts} +24 -19
  74. package/src/components/utilities/GetUnionPolygon.ts +36 -0
  75. package/src/components/utilities/QueueManager.ts +70 -0
  76. package/src/components/utilities/SetCronSchedule.ts +98 -0
  77. package/src/{@core/core.clearEvents.ts → components/utilities/SetDebug.ts} +17 -12
  78. package/src/components/utilities/SetEventEmit.ts +42 -0
  79. package/src/{@modules/@utilities/utilities.setSettings.ts → components/utilities/SetSettings.ts} +7 -7
  80. package/src/{@modules/@utilities/utilities.setSleep.ts → components/utilities/SetSleep.ts} +5 -5
  81. package/src/components/utilities/SetTimeoutAction.ts +64 -0
  82. package/src/components/utilities/SetWarning.ts +47 -0
  83. package/src/{@modules/@xmpp/xmpp.xDeploy.ts → components/xmpp/DeployXMPP.ts} +26 -27
  84. package/src/components/xmpp/ErrorXMPP.ts +27 -0
  85. package/src/{@modules/@xmpp/xmpp.xError.ts → components/xmpp/OfflineXMPP.ts} +17 -9
  86. package/src/{@modules/@xmpp/xmpp.xOnline.ts → components/xmpp/OnlineXMPP.ts} +21 -20
  87. package/src/components/xmpp/ReconnectXMPP.ts +64 -0
  88. package/src/components/xmpp/StanzaXMPP.ts +63 -0
  89. package/src/{@building/building.tags.ts → core/ClearEvents.ts} +12 -5
  90. package/src/{@core/core.getVersion.ts → core/GetEvents.ts} +5 -6
  91. package/src/core/GetNodes.ts +24 -0
  92. package/src/{@core/core.getNodes.ts → core/GetRandomEvent.ts} +5 -6
  93. package/src/core/GetVersion.ts +24 -0
  94. package/src/core/ManualEvent.ts +55 -0
  95. package/src/core/QueryStanza.ts +40 -0
  96. package/src/core/SetNode.ts +87 -0
  97. package/src/core/StartService.ts +62 -0
  98. package/src/core/StopService.ts +32 -0
  99. package/src/enums/AWIPS.ts +366 -0
  100. package/src/{@dictionaries/dictionaries.eventActions.ts → enums/Actions.ts} +3 -3
  101. package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → enums/Cancellation.ts} +4 -3
  102. package/src/{@dictionaries/dictionaries.eventCauses.ts → enums/Causes.ts} +3 -3
  103. package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → enums/Correlations.ts} +3 -3
  104. package/src/enums/Enhanced.ts +70 -0
  105. package/src/{@dictionaries/dictionaries.eventTypes.ts → enums/Events.ts} +3 -3
  106. package/src/{@dictionaries/dictionaries.regExp.ts → enums/Expressions.ts} +5 -4
  107. package/src/{@core/core.getEvents.ts → enums/GlobalFilter.ts} +7 -8
  108. package/src/{@dictionaries/dictionaries.hailStrings.ts → enums/Hail.ts} +9 -4
  109. package/src/{@dictionaries/dictionaries.officeICAOs.ts → enums/ICAO.ts} +5 -3
  110. package/src/enums/Matches.ts +60 -0
  111. package/src/{@dictionaries/dictionaries.eventProducts.ts → enums/Products.ts} +3 -3
  112. package/src/{@dictionaries/dictionaries.eventRecords.ts → enums/Records.ts} +3 -3
  113. package/src/{@dictionaries/dictionaries.eventSeverity.ts → enums/Severity.ts} +3 -3
  114. package/src/{@dictionaries/dictionaries.shapefileLinks.ts → enums/Shapefiles.ts} +3 -3
  115. package/src/enums/States.ts +136 -0
  116. package/src/{@dictionaries/dictionaries.eventStatus.ts → enums/Status.ts} +3 -3
  117. package/src/enums/Strings.ts +22 -0
  118. package/src/enums/Tags.ts +172 -0
  119. package/src/{@dictionaries/dictionaries.testSignatures.ts → enums/Testing.ts} +5 -4
  120. package/src/enums/Themes.ts +70 -0
  121. package/src/events/ParseAPI.ts +129 -0
  122. package/src/{@events/events.text.ts → events/ParseText.ts} +32 -23
  123. package/src/{@events/events.ugc.ts → events/ParseUGC.ts} +36 -26
  124. package/src/events/ParseVTEC.ts +88 -0
  125. package/src/index.ts +60 -38
  126. package/src/manager/MakeEvents.ts +110 -0
  127. package/src/manager/RemoveEvent.ts +74 -0
  128. package/src/{@manager/manager.setHash.ts → manager/SetHash.ts} +19 -15
  129. package/src/manager/UpdateEvents.ts +35 -0
  130. package/src/manager/UpdateNode.ts +62 -0
  131. package/src/manager/ValidateEvents.ts +144 -0
  132. package/src/{@parsers/@hvtec/hvtec.extract.ts → parsers/hvtec/HVExtract.ts} +13 -13
  133. package/src/parsers/text/GetDescriptionFromProduct.ts +59 -0
  134. package/src/parsers/text/GetEmbededText.ts +57 -0
  135. package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
  136. package/src/parsers/text/GetStringText.ts +58 -0
  137. package/src/{@parsers/@text/text.getTextFromProduct.ts → parsers/text/GetTextFromProduct.ts} +12 -12
  138. package/src/parsers/ugc/GetCache.ts +24 -0
  139. package/src/{@parsers/@ugc/ugc.expiry.ts → parsers/ugc/GetExpiry.ts} +3 -3
  140. package/src/{@parsers/@ugc/ugc.header.ts → parsers/ugc/GetHeader.ts} +6 -6
  141. package/src/parsers/ugc/GetLocations.ts +57 -0
  142. package/src/parsers/ugc/GetZonePolygon.ts +73 -0
  143. package/src/{@parsers/@ugc/ugc.zones.ts → parsers/ugc/GetZones.ts} +3 -3
  144. package/src/{@modules/@utilities/utilities.setListener.ts → parsers/ugc/SetCache.ts} +13 -10
  145. package/src/{@parsers/@ugc/ugc.extract.ts → parsers/ugc/UGCExtract.ts} +15 -15
  146. package/src/{@parsers/@pvtec/pvtec.expires.ts → parsers/vtec/GetExpiry.ts} +3 -3
  147. package/src/parsers/vtec/VTECExtract.ts +49 -0
  148. package/src/{@types/types.attributes.ts → static/Attributes.ts} +2 -3
  149. package/src/{@types/type.event.ts → static/Event.ts} +11 -8
  150. package/src/{@types/type.properties.ts → static/Properties.ts} +17 -10
  151. package/src/{@types/types.stanza.ts → static/Stanza.ts} +2 -2
  152. package/src/tasks/CreateTasks.ts +123 -0
  153. package/src/{@core/core.stop.ts → tasks/TaskGenerateJSON.ts} +14 -12
  154. package/src/tasks/TaskGenerateText.ts +34 -0
  155. package/src/tasks/TaskSendNTFY.ts +97 -0
  156. package/src/tasks/TaskSendWebhook.ts +107 -0
  157. package/src/types/Actions.ts +37 -0
  158. package/src/{@types/types.hvtec.ts → types/HVTEC.ts} +6 -6
  159. package/src/{@types/types.hash.ts → types/Hash.ts} +5 -5
  160. package/src/types/Nodes.ts +29 -0
  161. package/src/{@types/types.settings.ts → types/Settings.ts} +42 -10
  162. package/src/{@types/types.compiled.ts → types/StanzaCompiled.ts} +15 -14
  163. package/src/{@types/types.ugc.ts → types/UGC.ts} +5 -5
  164. package/src/{@modules/@utilities/utilities.getSettings.ts → types/VTEC.ts} +12 -7
  165. package/tools/build.js +47 -0
  166. package/tsconfig.json +28 -1
  167. package/dist/index.d.mts +0 -239
  168. package/dist/index.d.ts +0 -239
  169. package/src/@building/building.create.ts +0 -42
  170. package/src/@building/building.properties.ts +0 -89
  171. package/src/@building/building.tracking.ts +0 -68
  172. package/src/@building/building.validate.ts +0 -147
  173. package/src/@core/core.getRandomEvent.ts +0 -25
  174. package/src/@core/core.setNode.ts +0 -81
  175. package/src/@core/core.start.ts +0 -61
  176. package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
  177. package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
  178. package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
  179. package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
  180. package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
  181. package/src/@events/events.api.ts +0 -113
  182. package/src/@events/events.vtec.ts +0 -87
  183. package/src/@manager/manager.mkEvent.ts +0 -96
  184. package/src/@manager/manager.rmEvent.ts +0 -49
  185. package/src/@manager/manager.updateEvents.ts +0 -35
  186. package/src/@manager/manager.updateNodes.ts +0 -55
  187. package/src/@manager/manager.updateWebhooks.ts +0 -50
  188. package/src/@modules/@database/database.init.ts +0 -45
  189. package/src/@modules/@database/database.stanza.ts +0 -48
  190. package/src/@modules/@eas/eas.setEasTone.ts +0 -137
  191. package/src/@modules/@stanza/stanza.validate.ts +0 -50
  192. package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
  193. package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
  194. package/src/@modules/@utilities/utilities.setCronSchedule.ts +0 -65
  195. package/src/@modules/@utilities/utilities.setEventEmit.ts +0 -41
  196. package/src/@modules/@utilities/utilities.setTimeoutAction.ts +0 -59
  197. package/src/@modules/@xmpp/xmpp.xOffline.ts +0 -38
  198. package/src/@modules/@xmpp/xmpp.xReconnect.ts +0 -64
  199. package/src/@modules/@xmpp/xmpp.xStanza.ts +0 -63
  200. package/src/@parsers/@pvtec/pvtec.extract.ts +0 -49
  201. package/src/@parsers/@text/text.getDescriptionFromProduct.ts +0 -53
  202. package/src/@parsers/@text/text.getPolygonFromProduct.ts +0 -32
  203. package/src/@parsers/@text/text.getXML.ts +0 -61
  204. package/src/@parsers/@ugc/ugc.coordinates.ts +0 -110
  205. package/src/@parsers/@ugc/ugc.locations.ts +0 -29
  206. package/src/@types/types.pvtec.ts +0 -30
  207. package/src/@types/types.webhook.ts +0 -27
  208. package/test.js +0 -91
  209. package/tsup.config.ts +0 -16
  210. /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
  211. /package/{LICENSE → .github/LICENSE} +0 -0
  212. /package/{SECURITY.md → .github/SECURITY.md} +0 -0
@@ -11,18 +11,22 @@
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";
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
21
 
22
+
22
23
  export type TypeEventProperties = {
23
24
  locations: string
25
+ locations_array: string[]
26
+ regions: string[]
27
+ regions_string: string
24
28
  description: string
25
- attributes: TypeAttributes
29
+ attributes?: TypeAttributes
26
30
  geocode: {
27
31
  office: {
28
32
  name: string
@@ -33,7 +37,7 @@ export type TypeEventProperties = {
33
37
  polygon: string
34
38
  polygon_generated: boolean
35
39
  }
36
- parameters: {
40
+ parameters?: {
37
41
  tags: string[]
38
42
  instructions: string
39
43
  source: string
@@ -41,6 +45,7 @@ export type TypeEventProperties = {
41
45
  impacts: string
42
46
  estimated_hail_size: string
43
47
  estimated_wind_gusts: string
48
+ direction: string
44
49
  damage_threat: string
45
50
  tornado_threat: string
46
51
  flood_threat: string
@@ -66,10 +71,12 @@ export type TypeEventProperties = {
66
71
  max_tops_x100feet: string
67
72
  pds_watch: boolean
68
73
  }
69
- spc_parameters: {
70
- spc_max_tornado: string
71
- spc_max_hail: string
72
- spc_max_wind: string
73
- spc_watch_issuance: string
74
+ discussion_parameters?: {
75
+ discussion_number: string
76
+ discussion_concerning: string
77
+ discussion_max_tornado: string
78
+ discussion_max_hail: string
79
+ discussion_max_wind: string
80
+ discussion_watch_issuance: string
74
81
  }
75
82
  }
@@ -11,9 +11,9 @@
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
 
@@ -0,0 +1,123 @@
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
+ import { TypeSettings } from "Types/Settings"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeActions } from "Types/Actions"
22
+ import { Bootstrap } from "@Bootstrap"
23
+ import { SetDebug } from "@Utilities/SetDebug"
24
+ import { GetMatched } from "@Utilities/GetMatched"
25
+ import { GetStringText } from "@ParsingText/GetStringText"
26
+ import { GetCleanedEvent } from "@Building/GetCleanedEvent"
27
+ import { GenerateAudioMessage } from "@Audio/GenerateAudioMessage"
28
+ import { TaskGenerateText } from "@Tasks/TaskGenerateText"
29
+ import { TaskGenerateJSON } from "@Tasks/TaskGenerateJSON"
30
+ import { TaskSendNTFY } from "@Tasks/TaskSendNTFY"
31
+ import { TaskSendWebhook } from "@Tasks/TaskSendWebhook"
32
+ import { GenerateGraphic } from "@Image/GenerateGraphic"
33
+ import { QueueManager } from "@Utilities/QueueManager"
34
+
35
+ const Webhooks = new QueueManager({ Concurrency: 1 });
36
+ const NTFY = new QueueManager({ Concurrency: 5 });
37
+
38
+ export const CreateTasks = async (events: TypeEvent[]): Promise<void> => {
39
+ const tick = performance.now()
40
+ const settings = Bootstrap.Settings as TypeSettings;
41
+ const { ActionSettings, GlobalSettings, NotifyServer } = settings;
42
+ const actions = ActionSettings as TypeActions[];
43
+ for (const event of events) {
44
+ const { properties } = event;
45
+ const isActioning = Array.isArray(actions) && actions.length > 0;
46
+ if (!isActioning) { continue }
47
+
48
+ for (const action of actions) {
49
+ const { Events, Webhook, NotificationServer, Uploads } = action;
50
+ const isValidAction = GetMatched({ Strings: Events, String: properties.event });
51
+
52
+ if ((Events.length == 0 || isValidAction)) {
53
+ const a = performance.now();
54
+ const [audio, text, json, image] = await Promise.all([
55
+ Uploads?.AUDIO && GlobalSettings?.ArchiveSettings?.AudioDirectory ? GenerateAudioMessage({
56
+ Directory: GlobalSettings?.ArchiveSettings?.AudioDirectory + `/${properties?.regions_string ?? `MC`}`,
57
+ Title: (`${properties.event}_${properties.metadata.tracking}`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim(),
58
+ Message: properties.description,
59
+ Header: properties.metadata.header
60
+ }).then((result) => { return result; }) : Promise.resolve(null),
61
+
62
+ Uploads?.TEXT && GlobalSettings?.ArchiveSettings?.TextDirectory ? TaskGenerateText({
63
+ String: properties.metadata.raw,
64
+ Directory: GlobalSettings?.ArchiveSettings?.TextDirectory + `/${properties?.regions_string ?? `MC`}`,
65
+ Filename: (`${properties.event}_${properties.metadata.tracking}.txt`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim()
66
+ }).then((result) => { return result; }) : Promise.resolve(null),
67
+
68
+ Uploads?.JSON && GlobalSettings?.ArchiveSettings?.JSONDirectory ? TaskGenerateJSON({
69
+ String: JSON.stringify(GetCleanedEvent(event), null, 2),
70
+ Directory: GlobalSettings?.ArchiveSettings?.JSONDirectory + `/${properties?.regions_string ?? `MC`}`,
71
+ Filename: (`${properties.event}_${properties.metadata.tracking}.json`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim()
72
+ }).then((result) => { return result; }) : Promise.resolve(null),
73
+
74
+ Uploads?.IMAGE && GlobalSettings?.ArchiveSettings?.ImageDirectory ? GenerateGraphic({
75
+ Event: event,
76
+ File: {
77
+ Directory: GlobalSettings?.ArchiveSettings?.ImageDirectory + `/${properties?.regions_string ?? `MC`}`,
78
+ Name: (`${properties.event}_${properties.metadata.tracking}.png`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim()
79
+ }
80
+ }).then((result) => { return result; }) : Promise.resolve(null)
81
+ ]);
82
+
83
+
84
+ SetDebug({ Title: `Tasks/Generative`, Message: `${Math.round(performance.now() - a)}ms` })
85
+
86
+ const b = performance.now();
87
+ await Promise.all([
88
+ NotificationServer?.Enabled && NotifyServer?.Enabled && NotificationServer?.Topic ? NTFY.enqueue(() => TaskSendNTFY({
89
+ Event: event,
90
+ Toggles: {
91
+ Audio: Uploads?.AUDIO,
92
+ Json: Uploads?.JSON,
93
+ Text: Uploads?.TEXT,
94
+ Image: Uploads?.IMAGE
95
+ },
96
+ Priority: NotificationServer?.Priority ?? 5,
97
+ Body: GetStringText(event),
98
+ Topic: NotificationServer?.Topic
99
+ })) : Promise.resolve(null),
100
+ Webhook?.Enabled && Webhook?.Destination ? Webhooks.enqueue(() => TaskSendWebhook({
101
+ Event: event,
102
+ Webhook: {
103
+ Enabled: Webhook?.Enabled,
104
+ Destination: Webhook?.Destination,
105
+ Message: Webhook?.Message,
106
+ Title: Webhook?.Title,
107
+ Ratelimit: Webhook?.Ratelimit
108
+ },
109
+ Attachments: {
110
+ Image: image,
111
+ Text: text,
112
+ Audio: audio,
113
+ Json: json
114
+ }
115
+ })) : Promise.resolve(null)
116
+ ]);
117
+ SetDebug({ Title: `Tasks/Send`, Message: `${Math.round(performance.now() - b)}ms` })
118
+ }
119
+ }
120
+ SetDebug({ Title: `Tasks/CompletedEventTask`, Message: `${Math.round(performance.now() - tick)}ms` })
121
+ }
122
+ SetDebug({ Title: `Tasks/Global`, Message: `${Math.round(performance.now() - tick)}ms` })
123
+ }
@@ -11,22 +11,24 @@
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 { bootstrap } from "../bootstrap";
20
+ import { mkdir, writeFile } from "fs/promises"
21
21
 
22
- export const stopService = async (): Promise<void> => {
23
- if (bootstrap.isReady) {
24
- bootstrap.isReady = false;
25
- if (bootstrap.session_xmpp) {
26
- try { await bootstrap.session_xmpp.stop(); } catch {}
27
- bootstrap.cache.isConnected = false;
28
- bootstrap.cache.sigHault = true;
29
- bootstrap.session_xmpp = null;
30
- }
22
+ interface TaskGenerateJSONOptions {
23
+ String: string;
24
+ Directory: string;
25
+ Filename: string;
26
+ }
27
+
28
+ export const TaskGenerateJSON = async function({ String, Directory, Filename }: TaskGenerateJSONOptions): Promise<string> {
29
+ if (Directory) {
30
+ await mkdir(Directory, { recursive: true });
31
+ await writeFile(Directory + "/" + Filename, `${String}${"\n".repeat(5)}`);
31
32
  }
33
+ return String;
32
34
  }
@@ -0,0 +1,34 @@
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 { mkdir, appendFile } from "fs/promises"
21
+
22
+ interface TaskGenerateTextOptions {
23
+ String: string;
24
+ Directory: string;
25
+ Filename: string;
26
+ }
27
+
28
+ export const TaskGenerateText = async function({ String, Directory, Filename }: TaskGenerateTextOptions): Promise<string> {
29
+ if (Directory) {
30
+ await mkdir(Directory, { recursive: true });
31
+ await appendFile(Directory + "/" + Filename, `${String}${"\n".repeat(5)}`);
32
+ }
33
+ return String;
34
+ }
@@ -0,0 +1,97 @@
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 { Bootstrap } from "@Bootstrap"
22
+ import { CreateHttp } from "@Utilities/CreateHttp";
23
+ import { SetDebug } from "@Utilities/SetDebug";
24
+
25
+ interface TaskSendNTFYOptions {
26
+ Event: TypeEvent
27
+ Toggles?: {
28
+ Audio?: boolean
29
+ Json?: boolean
30
+ Text?: boolean
31
+ Image?: boolean
32
+ },
33
+ Priority: string | number
34
+ Body: string
35
+ Topic: string
36
+ }
37
+
38
+ export const TaskSendNTFY = async function({ Event, Toggles, Priority, Body, Topic }: TaskSendNTFYOptions): Promise<void> {
39
+ const { properties } = Event;
40
+
41
+ const configurations = Bootstrap.Settings.NotifyServer;
42
+ const authentication = configurations?.Credentials?.Username && configurations?.Credentials?.Password ? {
43
+ Username: configurations.Credentials.Username,
44
+ Password: configurations.Credentials.Password
45
+ } : undefined;
46
+
47
+ const image = properties?.metadata?.attachments?.find(a => a.name === "Image: Graphic")
48
+ ?? (Toggles?.Image && configurations?.MediaStorage?.IMAGE
49
+ ? { link: `${configurations?.MediaStorage?.IMAGE}/${properties.regions_string}//${properties?.event}_${properties?.metadata?.tracking}.png`
50
+ } : undefined);
51
+
52
+ const buttons = [
53
+ ...(Toggles?.Audio && configurations?.MediaStorage?.AUDIO ? [{
54
+ "action": "view",
55
+ "label": "Listen",
56
+ "url": `${configurations.MediaStorage.AUDIO}/${properties.regions_string}/${properties.event}_${properties.metadata.tracking}.wav`,
57
+ }] : []),
58
+ ...(Toggles?.Text && configurations?.MediaStorage?.TEXT ? [{
59
+ "action": "view",
60
+ "label": "View Text",
61
+ "url": `${configurations.MediaStorage.TEXT}/${properties.regions_string}/${properties.event}_${properties.metadata.tracking}.txt`,
62
+ }] : []),
63
+ ...(image ? [{
64
+ "action": "view",
65
+ "label": "View Image",
66
+ "url": image.link,
67
+ }] : []),
68
+ ];
69
+
70
+ const headers = {
71
+ "Title": `${properties.event} (${properties.status})`,
72
+ "Tags": properties.parameters.tags?.join(",") ?? "N/A",
73
+ "Priority": Priority ?? "5",
74
+ ...(buttons.length > 0 && { "Actions": JSON.stringify(buttons) }),
75
+ };
76
+
77
+ const post = async (topic: string) => {
78
+ const response = await CreateHttp({
79
+ URL: `${configurations?.Server?.replace(/\/$/, "")}/${topic}`,
80
+ Timeout: 15_000,
81
+ Method: "PUT",
82
+ ...(authentication && { Auth: authentication }),
83
+ Headers: headers,
84
+ Body: Body
85
+ })
86
+ if (response.error) {
87
+ SetDebug({ Title: `Tasks/NTFY`, Message: `Failed to send notification to topic "${topic}": ${response.message}` })
88
+ }
89
+ }
90
+
91
+ const topics = [
92
+ Topic,
93
+ ...(properties.metadata.filtered_proximity ? [`${Topic}-LOCAL`] : []),
94
+ ];
95
+
96
+ await Promise.all([...new Set(topics)].map(post));
97
+ }
@@ -0,0 +1,107 @@
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 { CreateHttp } from "@Utilities/CreateHttp";
22
+ import { SetTimeoutAction } from "@Utilities/SetTimeoutAction";
23
+ import { GetEmbededText } from "@ParsingText/GetEmbededText";
24
+ import { readFile } from "fs/promises"
25
+
26
+ interface TaskSendWebhookOptions {
27
+ Event: TypeEvent;
28
+ Webhook: {
29
+ Enabled: boolean;
30
+ Destination: string;
31
+ Message: string;
32
+ Title: string;
33
+ Ratelimit: number;
34
+ };
35
+ Attachments: {
36
+ Image?: string;
37
+ Text?: string;
38
+ Audio?: string;
39
+ Json?: string;
40
+ }
41
+ }
42
+
43
+ export const TaskSendWebhook = async function({ Event, Webhook, Attachments }: TaskSendWebhookOptions): Promise<void> {
44
+ const { properties } = Event;
45
+ const isRatelimited = SetTimeoutAction({
46
+ Identifier: Webhook.Destination,
47
+ Interval: (Webhook.Ratelimit ?? 2) * 2,
48
+ Max: (Webhook.Ratelimit ?? 2),
49
+ AddTime: true
50
+ })
51
+ if (isRatelimited.Limited) { return }
52
+ const newForm = new FormData();
53
+ const newEmbed = {
54
+ title: `${properties.event} (${properties.status})`,
55
+ description: GetEmbededText(Event),
56
+ fields: [] as { name: string, value: string }[],
57
+ color: 16711680,
58
+ thumbnail: Attachments?.Image ? { url: `attachment://${properties.event}_${properties.status}_${properties.metadata.tracking}.png` } : undefined,
59
+ timestamp: new Date().toISOString(),
60
+ footer: { text: Webhook.Title ?? `AtmosphericX` }
61
+ };
62
+ if (properties.description && !properties.status_metadata.is_expired) {
63
+ const description = properties.description.length > 900
64
+ ? properties.description.substring(0, 900) + "\n\n[Message truncated due to length]"
65
+ : properties.description;
66
+ newEmbed.fields.push({
67
+ name: "Description",
68
+ value: description ? '```' + '\n' + description.split('\n').map(l => l.trim()).filter(Boolean).join('\n') + '\n' + '```' : ""
69
+ });
70
+ }
71
+ if (properties.metadata.attachments?.length > 0) {
72
+ const attachments = properties.metadata.attachments.slice(0, 5);
73
+ newEmbed.fields.push({
74
+ name: "Attachments",
75
+ value: attachments.map(attachment => `- [${attachment.name.length > 45 ? attachment.name.substring(0, 45) + '...' : attachment.name}](${attachment.link})`).join('\n')
76
+ });
77
+ }
78
+
79
+ if (Attachments?.Image) {
80
+ const file = await readFile(Attachments.Image);
81
+ newForm.append("attachmentImage", new Blob([Buffer.from(file)], {type: "image/png"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.png`)
82
+ }
83
+
84
+ if (Attachments?.Text) {
85
+ newForm.append("attachmentText", new Blob([Buffer.from(Attachments.Text)], {type: "application/text"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.txt`)
86
+ }
87
+ if (Attachments?.Json) {
88
+ newForm.append("attachmentJson", new Blob([Buffer.from(Attachments.Json)], {type: "application/json"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.json`)
89
+ }
90
+ if (Attachments?.Audio) {
91
+ const file = await readFile(Attachments.Audio);
92
+ newForm.append("attachmentAudio", new Blob([Buffer.from(file)], {type: "application/wav"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.wav`)
93
+ }
94
+
95
+ newForm.append("payload_json", JSON.stringify({
96
+ username: Webhook.Title ?? `AtmosphericX`,
97
+ content: Webhook.Message ?? "",
98
+ embeds: [newEmbed]
99
+ }));
100
+
101
+ await CreateHttp({
102
+ URL: Webhook.Destination,
103
+ Timeout: 15e3,
104
+ Method: `POST`,
105
+ Body: newForm
106
+ })
107
+ }
@@ -0,0 +1,37 @@
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
+ export type TypeActions = {
21
+ Events: string[]
22
+ Webhook?: {
23
+ Enabled: boolean
24
+ Destination: string
25
+ Ratelimit: number
26
+ Title: string
27
+ Message: string
28
+ }
29
+ NotificationServer?: {
30
+ Enabled: boolean
31
+ Topic: string
32
+ Priority?: string | number
33
+ }
34
+ Uploads?: {
35
+ TEXT?: boolean, AUDIO?: boolean, JSON?: boolean, IMAGE?: boolean
36
+ }
37
+ }
@@ -11,15 +11,15 @@
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
20
  export type TypeHVTEC = {
21
- hvtec: string
22
- severity: string
23
- cause: string
24
- record: string
21
+ HVTEC: string
22
+ Severity: string
23
+ Cause: string
24
+ Record: string
25
25
  }
@@ -11,14 +11,14 @@
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
20
  export type TypeHash = {
21
- tracking: string
22
- hashes: string[]
23
- expires: string
21
+ Tracking: string
22
+ Hashes: string[]
23
+ Expires: string
24
24
  }
@@ -0,0 +1,29 @@
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
+ export type TypeNode = {
21
+ type: string
22
+ geometry: {
23
+ type: string
24
+ coordinates: number[]
25
+ }
26
+ properties: {
27
+ identifier: string
28
+ }
29
+ }