@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
@@ -0,0 +1,53 @@
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 { NormalizePolygon } from "@Image/modules/NormalizePolygon"
21
+
22
+ interface GenerateEventPolygonsOptions {
23
+ Polygons: GeoJSON.Polygon | GeoJSON.MultiPolygon | null
24
+ IPath: (feature: GeoJSON.Feature) => string | null
25
+ Map: boolean
26
+ Settings: {
27
+ BorderColor: string
28
+ BorderWidth: number
29
+ FillColor: string
30
+ FillOpacity: number
31
+ }
32
+ }
33
+
34
+ export const GetSVGPath = ({ Polygons, IPath, Settings, Map }: GenerateEventPolygonsOptions): string => {
35
+ if (!Polygons) return
36
+ const feature: GeoJSON.Feature = {
37
+ type: `Feature`,
38
+ properties: {},
39
+ geometry: !Map ? NormalizePolygon(Polygons) : Polygons,
40
+ };
41
+ const d = IPath(feature);
42
+ if (!d) return ``;
43
+ return `<path
44
+ d="${d}"
45
+ fill="${Settings.FillColor}"
46
+ fill-opacity="${Settings.FillOpacity}"
47
+ fill-rule="evenodd"
48
+ stroke="${Settings.BorderColor}"
49
+ stroke-width="${Settings.BorderWidth}"
50
+ stroke-linejoin="round"
51
+ stroke-linecap="round"
52
+ />`;
53
+ };
@@ -0,0 +1,57 @@
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 { geoArea } from "d3-geo";
21
+
22
+ export const NormalizeD3Polygon = (geometry: GeoJSON.Polygon | GeoJSON.MultiPolygon): GeoJSON.Polygon | GeoJSON.MultiPolygon => {
23
+ const area = geoArea(geometry);
24
+ if (area > 2 * Math.PI) {
25
+ if (geometry.type === `Polygon`) {
26
+ return {
27
+ type: `Polygon`,
28
+ coordinates: geometry.coordinates.map(ring => ring.slice().reverse())
29
+ };
30
+ }
31
+ return {
32
+ type: `MultiPolygon`,
33
+ coordinates: geometry.coordinates.map(polygon => polygon.map(ring => ring.slice().reverse()))
34
+ };
35
+ }
36
+ return geometry;
37
+ };
38
+
39
+ export const NormalizePolygon = (geometry: GeoJSON.Geometry): GeoJSON.Geometry => {
40
+ if (geometry.type !== `Polygon` && geometry.type !== `MultiPolygon`) {
41
+ return geometry;
42
+ }
43
+ const reverseRing = (ring: number[][]) => {
44
+ const reversed = ring.slice().reverse();
45
+ return reversed;
46
+ };
47
+ if (geometry.type === `Polygon`) {
48
+ return {
49
+ type: `Polygon`,
50
+ coordinates: geometry.coordinates.map((ring, index) => index === 0 ? reverseRing(ring) : ring.slice().reverse())
51
+ };
52
+ }
53
+ return {
54
+ type: `MultiPolygon`,
55
+ coordinates: geometry.coordinates.map(polygon => polygon.map((ring, index) => index === 0 ? reverseRing(ring) : ring.slice().reverse()))
56
+ };
57
+ }
@@ -11,36 +11,37 @@
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/types.attributes"
21
- import { eventAwipAbreviations } from "../../@dictionaries/dictionaries.eventAwipAbreviations"
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
+ import { EnumAWIPS } from "@Enums/AWIPS"
22
22
 
23
- interface ValidateOptions {
24
- attributes: TypeAttributes
23
+ interface GetAwipsTypeOptions {
24
+ Attributes: TypeAttributes
25
25
  }
26
26
 
27
- interface ValidiateResponse {
28
- type: string
29
- prefix: string
27
+ interface GetAwipsTypeResponse {
28
+ Type: string
29
+ Prefix: string
30
+ Discovered: boolean
30
31
  }
31
32
 
32
- export const getAwipsType = (options: ValidateOptions): ValidiateResponse => {
33
- const attributes = options.attributes;
34
- if (!attributes.awipsid) {
33
+ export const GetAwipsType = ({ Attributes }: GetAwipsTypeOptions): GetAwipsTypeResponse => {
34
+ if (!Attributes.awipsid) {
35
35
  return {
36
- type: null,
37
- prefix: null
36
+ Type: null,
37
+ Prefix: null,
38
+ Discovered: false
38
39
  }
39
40
  }
40
- for (const [prefix, type] of Object.entries(eventAwipAbreviations)) {
41
- if (attributes.awipsid.startsWith(prefix)) {
42
- return { type, prefix }
41
+ for (const [prefix, type] of Object.entries(EnumAWIPS)) {
42
+ if (Attributes.awipsid.startsWith(prefix)) {
43
+ return { Type: type, Prefix: prefix, Discovered: true }
43
44
  }
44
45
  }
45
- return { type: null, prefix: null }
46
+ return { Type: Attributes.awipsid, Prefix: Attributes.awipsid, Discovered: false }
46
47
  }
@@ -0,0 +1,62 @@
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 { TypeStanza } from "StaticTypes/Stanza"
21
+ import { TypeStanzaCompiled } from "Types/StanzaCompiled"
22
+ import { EnumExpressions } from "@Enums/Expressions"
23
+ import { GetAwipsType } from "@Stanza/GetAwipsType"
24
+
25
+ interface ValidateStanzaOptions {
26
+ Stanza: TypeStanza
27
+ }
28
+
29
+ export const ValidateStanza = ({ Stanza }: ValidateStanzaOptions): TypeStanzaCompiled => {
30
+ if (Stanza.is(`message`)) {
31
+ const cb = Stanza.getChild(`x`) as TypeStanza;
32
+ if (cb && cb.children) {
33
+ const message = unescape(cb.children[0]);
34
+ const attributes = cb.attrs;
35
+ if (attributes.awipsid && attributes.awipsid.length > 1) {
36
+ const isCapEvent = message.includes(`<?xml`);
37
+ const isCapAreaDescription = message.includes(`<areaDesc>`)
38
+ const isVTEC = message.match(EnumExpressions.vtec) != null;
39
+ const isUGC = message.match(EnumExpressions.ugc1) != null;
40
+ const getType = GetAwipsType({ Attributes: attributes})
41
+ if (getType.Type != null) {
42
+ return {
43
+ Message: message,
44
+ Attributes: attributes,
45
+ CapEvent: isCapEvent,
46
+ VTEC: isVTEC,
47
+ UGC: isUGC,
48
+ CapAreaDescription: isCapAreaDescription,
49
+ Ignored: false,
50
+ NWWS: true,
51
+ Type: {
52
+ Type: getType.Type,
53
+ Prefix: getType.Prefix,
54
+ Discovered: getType.Discovered
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return { Ignored: true}
62
+ }
@@ -0,0 +1,83 @@
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
+ interface CreateHttpOptions {
21
+ URL: string
22
+ Headers?: any
23
+ Timeout?: number
24
+ Auth?: {
25
+ Username: string
26
+ Password: string
27
+ }
28
+ Method?: `GET` | `POST` | `PUT` | `DELETE`
29
+ Body?: any;
30
+ Form?: any;
31
+ }
32
+
33
+ export const CreateHttp = async ({ URL, Headers, Timeout, Auth, Method, Body, Form }: CreateHttpOptions): Promise<any> => {
34
+ const requestOptions: RequestInit = {
35
+ method: Method ?? "GET",
36
+ headers: Headers ?? {
37
+ "User-Agent": "AtmosphericX",
38
+ "Accept": "application/geo+json, text/plain, */*; q=0.9",
39
+ "Accept-Language": "en-US,en;q=0.9",
40
+ },
41
+ signal: AbortSignal.timeout(Timeout ?? 10_000),
42
+ redirect: "follow"
43
+ };
44
+
45
+
46
+ const returnHttp = function(error: boolean,status: number, message: string) {
47
+ return { error: error, options: requestOptions, status, message };
48
+ }
49
+
50
+ if (Auth) {
51
+ const authString = `${Auth.Username}:${Auth.Password}`;
52
+ const encodedAuth = Buffer.from(authString).toString("base64");
53
+ requestOptions.headers = {
54
+ ...requestOptions.headers,
55
+ "Authorization": `Basic ${encodedAuth}`
56
+ };
57
+ }
58
+
59
+ if (Form) {
60
+ requestOptions.body = Form;
61
+ } else if (Body != undefined) {
62
+ requestOptions.body =
63
+ Body instanceof FormData
64
+ ? Body
65
+ : typeof Body === "string"
66
+ ? Body
67
+ : JSON.stringify(Body);
68
+ }
69
+
70
+ try {
71
+ const response = await fetch(
72
+ URL ?? `https://api.weather.gov/alerts/active`,
73
+ requestOptions
74
+ )
75
+ const body = await response.text();
76
+ if (!response.ok) {
77
+ return returnHttp(true, response.status, `HTTP Status Code ${response.status} (${response.statusText})`)
78
+ }
79
+ return returnHttp(false, response.status, body)
80
+ } catch (error) {
81
+ return returnHttp(true, 500, `Internal Server Error: ${error}`)
82
+ }
83
+ }
@@ -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
 
21
- export const getFormattedTime = (date: string): string => {
21
+ export const GetFormattedTime = (date: string): string => {
22
22
  const now = Date.now();
23
23
  const then = typeof date === "number" ? date : new Date(date).getTime()
24
24
  const seconds = Math.floor((now - then) / 1000);
@@ -0,0 +1,32 @@
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
+
21
+ export const GetLatestIssuance = (): string => {
22
+ const now = new Date();
23
+ const current = now.getUTCHours() * 100 + now.getUTCMinutes();
24
+ const issuances = [100, 600, 1300, 1630, 2000];
25
+ let latest = issuances[0];
26
+ for (const issuance of issuances) {
27
+ if (current >= issuance) {
28
+ latest = issuance;
29
+ }
30
+ }
31
+ return latest.toString().padStart(4, "0");
32
+ }
@@ -0,0 +1,38 @@
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
+ interface GetMatchedOptions {
21
+ Strings: string[]
22
+ String: string
23
+ }
24
+
25
+ export const GetMatched = ({ Strings, String }: GetMatchedOptions): boolean => {
26
+ const isMatched = Strings.some(pattern => {
27
+ if (!pattern) return false;
28
+ const lowerP = pattern.toLowerCase();
29
+ const lowerS = String.toLowerCase()
30
+ if (lowerP === "*" || lowerP === lowerS) return true;
31
+ if (lowerP.includes("*")) {
32
+ const regex = "^" + lowerP.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$";
33
+ return new RegExp(regex).test(lowerS);
34
+ }
35
+ return false;
36
+ });
37
+ return isMatched;
38
+ }
@@ -11,23 +11,28 @@
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
+ interface GetShapeNearestPointOptions {
21
+ Coordinates: number[][]
22
+ Point: [number, number]
23
+ }
24
+
20
25
  interface GetShapeNearestPointResponse {
21
- proximity: boolean
22
- point: [number, number]
23
- distance: number | null
24
- distanceKm?: number | null
25
- distanceMeters?: number | null
26
+ Proximity: boolean
27
+ Point: [number, number]
28
+ Distance: number | null
29
+ DistanceKm?: number | null
30
+ DistanceMeters?: number | null
26
31
  }
27
32
 
28
- export const getShapeNearestPoint = (coordinates: number[][], point: [number, number]): GetShapeNearestPointResponse => {
29
- if (!coordinates || !point) {
30
- return { proximity: false, point: [0, 0], distance: null }
33
+ export const GetShapeNearestPoint = ({ Coordinates, Point }: GetShapeNearestPointOptions): GetShapeNearestPointResponse => {
34
+ if (!Coordinates || !Point) {
35
+ return { Proximity: false, Point: [0, 0], Distance: null }
31
36
  }
32
37
  const normalize = (coords: any): any[] => {
33
38
  if (!Array.isArray(coords)) return [];
@@ -43,10 +48,10 @@ export const getShapeNearestPoint = (coordinates: number[][], point: [number, nu
43
48
  }
44
49
  return [];
45
50
  }
46
- const polys = normalize(coordinates);
47
- if (polys.length === 0) return { proximity: false, point: [0, 0], distance: null };
48
- const lon = point[0];
49
- const lat = point[1];
51
+ const polys = normalize(Coordinates);
52
+ if (polys.length === 0) return { Proximity: false, Point: [0, 0], Distance: null };
53
+ const lon = Point[0];
54
+ const lat = Point[1];
50
55
  const pointInRing = (pt: [number, number], ring: number[][]): boolean => {
51
56
  let x = pt[0], y = pt[1];
52
57
  let inside = false;
@@ -76,13 +81,13 @@ export const getShapeNearestPoint = (coordinates: number[][], point: [number, nu
76
81
  for (const poly of polys) {
77
82
  const outer = poly[0];
78
83
  const holes = poly.slice(1);
79
- if (pointInRing(point, outer)) {
84
+ if (pointInRing(Point, outer)) {
80
85
  let inHole = false;
81
86
  for (const hole of holes) {
82
- if (pointInRing(point, hole)) { inHole = true; break; }
87
+ if (pointInRing(Point, hole)) { inHole = true; break; }
83
88
  }
84
89
  if (!inHole) {
85
- return { proximity: true, point, distance: 0 };
90
+ return { Proximity: true, Point, Distance: 0 };
86
91
  }
87
92
  }
88
93
  for (const ring of poly) {
@@ -105,10 +110,10 @@ export const getShapeNearestPoint = (coordinates: number[][], point: [number, nu
105
110
  }
106
111
  }
107
112
  if (!isFinite(minDistance) || closestPoint == null) {
108
- return { proximity: false, point: [0,0], distance: null };
113
+ return { Proximity: false, Point: [0,0], Distance: null };
109
114
  }
110
115
  const distanceMiles = minDistance;
111
116
  const distanceKm = Number((distanceMiles * 1.609344).toFixed(3));
112
117
  const distanceMeters = Math.round(distanceKm * 1000);
113
- return { proximity: distanceMiles === 0, point: closestPoint, distance: distanceMiles, distanceKm, distanceMeters };
118
+ return { Proximity: distanceMiles === 0, Point: closestPoint, Distance: distanceMiles, DistanceKm: distanceKm, DistanceMeters: distanceMeters };
114
119
  }
@@ -0,0 +1,36 @@
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 { union } from "polygon-clipping";
21
+
22
+ interface GetUnionPolygonOptions {
23
+ Polygons: number[][][][] | null;
24
+ }
25
+
26
+ export const GetUnionPolygon = ({ Polygons }: GetUnionPolygonOptions): GeoJSON.MultiPolygon | null => {
27
+ if (!Polygons || Polygons.length === 0) {
28
+ return null;
29
+ }
30
+ const unionFn = union as unknown as (...polygons: number[][][][]) => number[][][][];
31
+ const unioned = unionFn(...Polygons)
32
+ return {
33
+ type: `MultiPolygon`,
34
+ coordinates: unioned
35
+ }
36
+ };
@@ -0,0 +1,70 @@
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
+ export type QueueTask = () => Promise<void>;
20
+
21
+ export interface QueueManagerOptions {
22
+ Concurrency?: number;
23
+ Error?: (error: unknown) => void;
24
+ }
25
+
26
+ export class QueueManager {
27
+ private readonly queue: QueueTask[] = [];
28
+ private readonly concurrency: number;
29
+ private readonly onError: (error: unknown) => void;
30
+
31
+ private running = 0;
32
+ private draining = false;
33
+
34
+ public constructor({ Concurrency, Error }: QueueManagerOptions = {}) {
35
+ this.concurrency = Concurrency ?? 1;
36
+ this.onError = Error ?? ((error) => {
37
+ console.error("[QueueManager] Task failed:", error);
38
+ });
39
+ }
40
+
41
+ public enqueue(task: QueueTask): void {
42
+ this.queue.push(task);
43
+ this.drain();
44
+ }
45
+
46
+ private drain(): void {
47
+ if (this.draining) { return; }
48
+ this.draining = true;
49
+ while (this.running < this.concurrency && this.queue.length > 0) {
50
+ const task = this.queue.shift();
51
+ if (!task) { continue; }
52
+ this.running++;
53
+ void this.execute(task);
54
+ }
55
+ this.draining = false;
56
+ }
57
+
58
+ private async execute(task: QueueTask): Promise<void> {
59
+ try {
60
+ await task();
61
+ } catch (error) {
62
+ try {
63
+ this.onError(error);
64
+ } catch (handlerError) {}
65
+ } finally {
66
+ this.running--;
67
+ this.drain();
68
+ }
69
+ }
70
+ }