@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,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
+ }
@@ -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, writeFile } from "fs/promises"
21
+
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)}`);
32
+ }
33
+ return String;
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
+ }
@@ -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
 
@@ -32,6 +32,6 @@ export type TypeActions = {
32
32
  Priority?: string | number
33
33
  }
34
34
  Uploads?: {
35
- TEXT?: boolean, EAS?: boolean, JSON?: boolean
35
+ TEXT?: boolean, AUDIO?: boolean, JSON?: boolean, IMAGE?: boolean
36
36
  }
37
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
+ }
@@ -11,18 +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 { TypeActions } from "./Actions"
20
+ import { TypeActions } from "Types/Actions"
21
21
 
22
22
  type TypeTimezones = string | "CST" | "CDT" | "MDT" | "MST" | "EST" | "EDT" | "HST" | "HDT" | "PDT" | "UTC"
23
23
 
24
24
  export type TypeSettings = {
25
+ Timezone?: TypeTimezones
25
26
  Database: string
27
+ DebugDisableAllEvents: boolean
26
28
  EnableWireService: boolean
27
29
  EnableJournal: boolean
28
30
  EnableDebugging: boolean
@@ -56,14 +58,18 @@ export type TypeSettings = {
56
58
  BroadcastifyDatabase: string
57
59
  BroadcastifyTags: string[]
58
60
  },
61
+ BoundarySettings: {
62
+ BoundaryDatabase: string
63
+ CityDatabase: string
64
+ },
59
65
  NotifyServer: {
60
66
  Enabled: boolean
61
67
  Server: string
62
- Timezone?: TypeTimezones
63
68
  MediaStorage: {
64
69
  TEXT?: string
65
70
  JSON?: string
66
- EAS?: string
71
+ AUDIO?: string
72
+ IMAGE?: string
67
73
  }
68
74
  Credentials?: {
69
75
  Username: string | void
@@ -76,7 +82,6 @@ export type TypeSettings = {
76
82
  DisableGeometryParsing: boolean
77
83
  UseShapefileCoordinates: boolean
78
84
  SPCWatchesOnly: boolean
79
- ShapefileSkipPoints: number
80
85
  NodeTTL: number
81
86
  NodeMaxDistance: number
82
87
  EventFiltering: {
@@ -89,12 +94,15 @@ export type TypeSettings = {
89
94
  NodeLocationFiltering: boolean
90
95
  IgnoreTestProducts: boolean
91
96
  },
97
+ Themes: { Event: string, RGB: string }[]
92
98
  ArchiveSettings: {
93
99
  TTL: number
100
+ ImageDirectory: string
94
101
  JSONDirectory: string
95
102
  TextDirectory: string
96
- EasDirectory: string
97
- EasToneout: string
103
+ AudioDirectory: string
104
+ Logo: string
105
+ AudioToneout: string
98
106
  }
99
107
  }
100
108
  }
@@ -11,26 +11,26 @@
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 "./Attributes"
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
21
 
22
22
  export type TypeStanzaCompiled = {
23
- message?: string
24
- attributes?: TypeAttributes
25
- isCapEvent?: boolean
26
- isVTEC?: boolean
27
- isUGC?: boolean
28
- isCapAreaDescription?: boolean
29
- isIgnored?: boolean
30
- isNWWS?: boolean
31
- getType?: {
32
- type: string
33
- prefix: string
34
- discovered: boolean
23
+ Message?: string
24
+ Attributes?: TypeAttributes
25
+ CapEvent?: boolean
26
+ VTEC?: boolean
27
+ UGC?: boolean
28
+ CapAreaDescription?: boolean
29
+ Ignored?: boolean
30
+ NWWS?: boolean
31
+ Type?: {
32
+ Type: string
33
+ Prefix: string
34
+ Discovered: boolean
35
35
  }
36
36
  }
@@ -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 TypeUGC = {
21
- zones: string[]
22
- locations: string[]
23
- expires: string
21
+ Zones: string[]
22
+ Locations: string[]
23
+ Expires: string
24
24
  }
@@ -11,15 +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 { TypeSettings } from '../../@types/Settings'
21
- import { bootstrap } from "../../bootstrap"
22
-
23
- export const GetSettings = (): TypeSettings => {
24
- return bootstrap.settings;
20
+ export type TypeVTEC = {
21
+ Raw: string
22
+ ProductType: string
23
+ Tracking: string
24
+ Event: string
25
+ Status: string
26
+ WMO: string
27
+ Expires: string
28
+ Watch: boolean
29
+ PredictionCenter: boolean
25
30
  }