@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
@@ -1,59 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { bootstrap } from "../../bootstrap"
21
-
22
- interface SetTimeoutActionOptions {
23
- identifier: string
24
- addTime?: boolean
25
- max?: number
26
- interval: number
27
- }
28
-
29
- type SetTimeoutActionResponse = {
30
- limited: boolean
31
- remaining?: number
32
- response?: string
33
- }
34
-
35
- export const setTimeoutAction = (options: SetTimeoutActionOptions): SetTimeoutActionResponse => {
36
- let target = bootstrap?.ratelimits?.[options?.identifier];
37
- if (!target) {
38
- bootstrap.ratelimits[options?.identifier] = [];
39
- target = bootstrap.ratelimits[options?.identifier];
40
- }
41
- if (target?.length > 0) {
42
- bootstrap.ratelimits[options?.identifier] = target.filter((ts: number) => Date.now() - ts < options?.interval * 1000);
43
- target = bootstrap.ratelimits[options?.identifier];
44
- }
45
-
46
- const oldestTimestamp = target?.[0];
47
- const getWait = oldestTimestamp ? Math.ceil((options?.interval * 1000) - (Date.now() - oldestTimestamp)) : 0;
48
- const max = options?.max || 1;
49
-
50
- if (target?.length >= max && getWait > 0) {
51
- return {
52
- limited: true,
53
- remaining: getWait,
54
- response: `You are being rate limited, please wait ${(getWait / 1e3).toFixed(1)} second(s) before performing this action again.`
55
- }
56
- }
57
- bootstrap.ratelimits[options?.identifier].push(Date.now());
58
- return { limited: false };
59
- }
@@ -1,38 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { bootstrap } from "../../bootstrap";
21
- import { setEventEmit } from "../@utilities/utilities.setEventEmit";
22
- import { setWarning } from "../@utilities/utilities.setWarning";
23
-
24
- export const xOffline = () => {
25
- bootstrap.session_xmpp.on(`offline`, async () => {
26
- bootstrap.cache.isConnected = false;
27
- bootstrap.cache.sigHault = true;
28
- setEventEmit({
29
- event: `onServiceStatus`,
30
- metadata: {
31
- message: `Client has gone offline`,
32
- data: {},
33
- type: `offline`,
34
- error: true
35
- },
36
- })
37
- })
38
- }
@@ -1,64 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { TypeSettings } from "../../@types/types.settings";
21
- import { bootstrap } from "../../bootstrap"
22
- import { setEventEmit } from "../@utilities/utilities.setEventEmit";
23
- import { setWarning } from "../@utilities/utilities.setWarning";
24
-
25
- export const xReconnect = async (interval: number): Promise<void> => {
26
- const settings = bootstrap.settings as TypeSettings;
27
- const lastStanza = Date.now() - bootstrap.cache.lastStanza
28
- if (interval < 15) {
29
- setWarning({ message: `Reconnection Interval of ${interval} seconds is too low, setting to 15 seconds` })
30
- interval = 15;
31
- bootstrap.settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval = 15;
32
- }
33
- const reconnectThreshold = interval * 1e3
34
- if ((!bootstrap.cache.isConnected && !bootstrap.cache.sigHault) || !bootstrap.session_xmpp) {
35
- return;
36
- }
37
- if (lastStanza > reconnectThreshold) {
38
- if (!bootstrap.cache.isReconnecting) {
39
- bootstrap.cache.isReconnecting = true;
40
- bootstrap.cache.isConnected = false;
41
- bootstrap.cache.tReconnects += 1;
42
- try {
43
- setEventEmit({
44
- event: `onServiceStatus`,
45
- metadata: {
46
- message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
47
- data: {
48
- last_stanza: lastStanza,
49
- nickname: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
50
- },
51
- type: `reconnect`,
52
- error: true
53
- },
54
- })
55
- await bootstrap.session_xmpp.stop().catch(() => {});
56
- await bootstrap.session_xmpp.start().catch(() => {});
57
- } catch (error) {
58
- setWarning({ message: `XMPP Reconnect Failed - ${(error as Error).message}` })
59
- } finally {
60
- bootstrap.cache.isReconnecting = false;
61
- }
62
- }
63
- }
64
- }
@@ -1,63 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { TypeStanza } from "../../@types/types.stanza";
21
- import { bootstrap } from "../../bootstrap";
22
- import { validate } from "../@stanza/stanza.validate";
23
- import { createEvent } from "../../@building/building.create";
24
- import { importStanza } from "../@database/database.stanza";
25
- import { setEventEmit } from "../@utilities/utilities.setEventEmit";
26
-
27
- export const xStanza = () => {
28
- bootstrap.session_xmpp.on(`stanza`, async (stanza: TypeStanza) => {
29
- const msgFrom = stanza?.attrs?.from ?? ``
30
- const msgType = stanza?.attrs?.type ?? ``
31
- setEventEmit({
32
- event: `onServiceStatus`,
33
- metadata: {
34
- message: stanza,
35
- from: msgFrom,
36
- type: `stanza`
37
- },
38
- })
39
- bootstrap.cache.lastStanza = Date.now();
40
- if (stanza.is(`message`)) {
41
- const result = validate({ stanza });
42
- const isSkippable = result.isIgnored ||
43
- (result.isCapEvent) ||
44
- (result.isCapEvent && !result.isCapAreaDescription)
45
- if (isSkippable) { return; }
46
- await createEvent(result);
47
- await importStanza(result);
48
- }
49
- if (stanza.is(`presence`) && msgFrom.startsWith('nwws@conference.nwws-oi.weather.gov/')) {
50
- const getOccupant = msgFrom.split(`/`).slice(1).join(`/`)
51
- const getAvailability = msgType === `unavailable`
52
- setEventEmit({
53
- event: `onServiceStatus`,
54
- metadata: {
55
- message: `Occupant ${getOccupant} has ${getAvailability ? `left` : `joined`} the room`,
56
- data: {},
57
- type: `occupant`,
58
- error: false
59
- },
60
- })
61
- }
62
- })
63
- }
@@ -1,49 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { TypePVTEC } from "../../@types/types.pvtec";
21
- import { regExp } from "../../@dictionaries/dictionaries.regExp";
22
- import { eventProducts } from "../../@dictionaries/dictionaries.eventProducts";
23
- import { eventTypes } from "../../@dictionaries/dictionaries.eventTypes";
24
- import { eventActions } from "../../@dictionaries/dictionaries.eventActions";
25
- import { eventStatus } from "../../@dictionaries/dictionaries.eventStatus";
26
- import { getExpiry } from "./pvtec.expires";
27
-
28
- export const pvExtract = (message: string): TypePVTEC[] | null => {
29
- const getVTECs = message.match(regExp.pvtec) ?? [];
30
- const vtecs: TypePVTEC[] = [];
31
- for (const vtec of getVTECs) {
32
- const sub = vtec.split(`.`);
33
- if (sub?.length < 7) continue;
34
- const dates = sub[6]?.split(`-`);
35
- vtecs.push({
36
- vtec: vtec,
37
- product: eventProducts[sub[0]],
38
- tracking: `${sub[2]}-${sub[3]}-${sub[4]}-${sub[5]}`,
39
- event: `${eventTypes[sub[3]]} ${eventActions[sub[4]]}`,
40
- status: eventStatus[sub[1]],
41
- organization: message.match(regExp.wmo)?.[0] ?? null,
42
- expires: getExpiry(dates),
43
- is_watch: (sub[4] == `A` || sub[4] == `Y`) && (sub[3] == `TO` || sub[3] == `SV`),
44
- prediction_center: sub[2] == `KWNS`
45
- ? true : false
46
- })
47
- }
48
- return vtecs.length > 0 ? vtecs : null;
49
- }
@@ -1,53 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { regExp } from "../../@dictionaries/dictionaries.regExp";
21
-
22
- interface GetDescriptionFromProductOptions {
23
- message: string
24
- handle?: string
25
- }
26
-
27
- export const getDescriptionFromProduct = (options: GetDescriptionFromProductOptions): string => {
28
- let message = options.message;
29
- const dates = Array.from(message.matchAll(regExp.dateline));
30
- if (dates.length) {
31
- const lastMatch = dates[dates.length - 1][0];
32
- const sIndx = message.lastIndexOf(lastMatch);
33
- if (sIndx !== -1) {
34
- const endIndx = message.indexOf('&&', sIndx);
35
- message = message.substring(sIndx + lastMatch.length, endIndx !== -1 ? endIndx : undefined).trimStart();
36
- if (message.startsWith('/')) message = message.slice(1).trimStart();
37
- if (options.handle && message.includes(options.handle)) {
38
- const handleIdx = message.indexOf(options.handle);
39
- message = message.substring(handleIdx + options.handle.length).trimStart();
40
- if (message.startsWith('/')) message = message.slice(1).trimStart();
41
- }
42
- }
43
- } else if (options.handle) {
44
- const handleIndx = message.indexOf(options.handle);
45
- if (handleIndx !== -1) {
46
- let afterHandle = message.substring(handleIndx + options.handle.length).trimStart();
47
- if (afterHandle.startsWith('/')) afterHandle = afterHandle.slice(1).trimStart();
48
- const latEnd = afterHandle.indexOf('&&')
49
- message = latEnd !== -1 ? afterHandle.substring(0, latEnd).trim() : afterHandle.trim();
50
- }
51
- }
52
- return message.trim();
53
- }
@@ -1,32 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- export const getPolygonFromProduct = (message: string): number[][] => {
21
- const coordinates: [number, number][] = [];
22
- const match = message.match(/LAT\.{3}LON\s+([\d\s]+)/i);
23
- if (!match || !match[1]) return coordinates;
24
- const coordStrings = match[1].replace(/\n/g, ' ').trim().split(/\s+/);
25
- for (let i = 0; i < coordStrings.length - 1; i += 2) {
26
- const lat = parseFloat(coordStrings[i]) / 100;
27
- const lon = -parseFloat(coordStrings[i + 1]) / 100;
28
- if (!isNaN(lat) && !isNaN(lon)) { coordinates.push([lon, lat]); }
29
- }
30
- if (coordinates.length > 2) { coordinates.push(coordinates[0]); }
31
- return coordinates;
32
- }
@@ -1,61 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- interface GetXMLOptions {
21
- message: string
22
- targets: string[]
23
- }
24
-
25
- export const getXML = (options: GetXMLOptions): Record<string, string> => {
26
- const extracted: Record<string, any> = {};
27
- const findValueByKey = (obj: any, searchKey: string) => {
28
- const results = [];
29
- if (obj === null || typeof obj !== 'object') {
30
- return results;
31
- }
32
- const searchKeyLower = searchKey.toLowerCase();
33
- for (const key in obj) {
34
- if (obj.hasOwnProperty(key) && key.toLowerCase() === searchKeyLower) {
35
- results.push(obj[key]);
36
- }
37
- }
38
- if (Array.isArray(obj)) {
39
- for (const item of obj) {
40
- if (item.valueName && item.valueName.toLowerCase() === searchKeyLower && item.value !== undefined) {
41
- results.push(item.value);
42
- }
43
- const nestedResults = findValueByKey(item, searchKey);
44
- results.push(...nestedResults);
45
- }
46
- }
47
- for (const key in obj) {
48
- if (obj.hasOwnProperty(key)) {
49
- const nestedResults = findValueByKey(obj[key], searchKey);
50
- results.push(...nestedResults);
51
- }
52
- }
53
- return results;
54
- };
55
- for (const key of options.targets) {
56
- const values = findValueByKey(options.message, key);
57
- const uniqueValues = [...new Set(values)];
58
- extracted[key] = uniqueValues.length === 0 ? null : (uniqueValues.length === 1 ? uniqueValues[0] : uniqueValues);
59
- }
60
- return extracted;
61
- }
@@ -1,110 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
- import { union } from "polygon-clipping";
20
- import { bootstrap } from "../../bootstrap";
21
-
22
- interface CoordinatesOptions {
23
- zones: string[]
24
- isUnion: boolean
25
- }
26
-
27
- interface CoordinatesResponse {
28
- type: `Polygon` | `MultiPolygon`
29
- coordinates: any[]
30
- }
31
-
32
- export const getZonePolygon = (options: CoordinatesOptions): CoordinatesResponse | null => {
33
- const list = [...new Set(options.zones.map(z => z.trim()))].filter(z => z === 'XX000' ? false : true);
34
- if (list.length === 0) return null;
35
-
36
- const placeholders = list.map(() => "?").join(",");
37
- const rows = bootstrap.database
38
- .prepare(`SELECT geometry FROM shapefiles WHERE id IN (${placeholders})`)
39
- .all(...list);
40
- const polygons: any[] = [];
41
- for (const row of rows) {
42
- if (!row?.geometry) continue;
43
- const geom = JSON.parse(row.geometry);
44
- if (geom?.type === "Polygon") {
45
- polygons.push(geom.coordinates);
46
- }
47
- }
48
-
49
- if (polygons.length === 0) return null;
50
-
51
- if (options.isUnion) {
52
- const unionFn = union as (...polys: any[]) => any;
53
- const mergedCoords = unionFn(...polygons);
54
- if (!mergedCoords || mergedCoords.length === 0) return null;
55
- let maxArea = -1;
56
- let bestPoly: any[] = [];
57
- for (const poly of mergedCoords) {
58
- const outerRing = poly[0];
59
- let area = 0;
60
- for (let i = 0; i < outerRing.length - 1; i++) {
61
- const [x1, y1] = outerRing[i];
62
- const [x2, y2] = outerRing[i + 1];
63
- area += x1 * y2 - x2 * y1;
64
- }
65
- area = Math.abs(area / 2);
66
- if (area > maxArea) {
67
- maxArea = area;
68
- bestPoly = poly;
69
- }
70
- }
71
- if (!bestPoly || bestPoly.length === 0) return null;
72
- const outerRing = bestPoly[0];
73
- const skip = Math.max(1, parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10) || 1);
74
- let skipped = outerRing.filter((_: any, idx: number) => idx % skip === 0);
75
- if (skipped.length < 4) {
76
- skipped = outerRing.slice();
77
- }
78
- const first = skipped[0];
79
- const last = skipped[skipped.length - 1];
80
- if (!first || !last || first[0] !== last[0] || first[1] !== last[1]) {
81
- skipped.push([first[0], first[1]]);
82
- }
83
- return {type: "Polygon", coordinates: [skipped]};
84
- } else {
85
- const multi: any[] = [];
86
- for (const polyCoords of polygons) {
87
- if (Array.isArray(polyCoords) && Array.isArray(polyCoords[0])) {
88
- multi.push(polyCoords);
89
- }
90
- }
91
- if (multi.length === 0) return null;
92
- const skip = Math.max(1, parseInt(String(bootstrap.settings.GlobalSettings.ShapefileSkipPoints), 10) || 1);
93
- if (skip > 1) {
94
- for (let p = 0; p < multi.length; p++) {
95
- for (let r = 0; r < multi[p].length; r++) {
96
- const ring = multi[p][r];
97
- let reduced = ring.filter((_: any, i: number) => i % skip === 0);
98
- if (reduced.length < 4) reduced = ring.slice();
99
- const first = reduced[0];
100
- const last = reduced[reduced.length - 1];
101
- if ( first && last && (first[0] !== last[0] || first[1] !== last[1])) {
102
- reduced.push([first[0], first[1]]);
103
- }
104
- multi[p][r] = reduced;
105
- }
106
- }
107
- }
108
- return {type: "MultiPolygon", coordinates: multi};
109
- }
110
- }
@@ -1,29 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { bootstrap } from "../../bootstrap";
21
-
22
- export const getLocations = async (zones: string[]): Promise<string[]> => {
23
- const sites = Array.from(new Set(zones));
24
- const placeholders = sites.map(() => '?').join(',');
25
- const rows = await bootstrap.database
26
- .prepare(`SELECT id, location FROM shapefiles WHERE id IN (${placeholders})`)
27
- .all(...sites)
28
- return rows.map((row: any) => row.location).sort();
29
- }
@@ -1,30 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- export type TypePVTEC = {
21
- vtec: string
22
- product: string
23
- tracking: string
24
- event: string
25
- status: string
26
- organization: string
27
- expires: string
28
- is_watch: boolean
29
- prediction_center: boolean
30
- }
@@ -1,27 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- export type TypeWebhook = {
21
- webhook: string
22
- title: string
23
- message: string
24
- upload: boolean
25
- rate: number
26
- events: string[]
27
- }