@atmosx/event-product-parser 3.0.621 → 3.1.0

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 (200) hide show
  1. package/.github/CHANGELOGS.md +52 -0
  2. package/.github/CODE_OF_CONDUCT.md +24 -1
  3. package/.github/CONTRIBUTING.md +22 -3
  4. package/.github/FUNDING.yaml +3 -0
  5. package/.github/LICENSE +24 -1
  6. package/.github/SECURITY.md +25 -6
  7. package/.github/docs/chapters/general-configurations.md +109 -0
  8. package/.github/docs/chapters/sources-and-attributes.md +219 -0
  9. package/README.md +56 -146
  10. package/dist/index.cjs +25333 -0
  11. package/package.json +17 -11
  12. package/pnpm-workspace.yaml +4 -0
  13. package/src/bootstrap.ts +67 -52
  14. package/src/components/audio/GenerateAudioMessage.ts +149 -0
  15. package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
  16. package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
  17. package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
  18. package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
  19. package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
  20. package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
  21. package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
  22. package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
  23. package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
  24. package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
  25. package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
  26. package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
  27. package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
  28. package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
  29. package/src/components/database/CreateQuery.ts +39 -0
  30. package/src/components/database/InitializeDatabase.ts +71 -0
  31. package/src/components/database/imports/Boundaires.ts +168 -0
  32. package/src/{@modules/@database/ImportBroadcastify.ts → components/database/imports/Broadcastify.ts} +15 -25
  33. package/src/components/database/imports/Census.ts +87 -0
  34. package/src/{@modules/@database/ImportShapefiles.ts → components/database/imports/Shapefiles.ts} +24 -27
  35. package/src/{@modules/@database/ImportStanza.ts → components/database/imports/Stanza.ts} +15 -19
  36. package/src/components/events/CreateEvents.ts +88 -0
  37. package/src/components/events/FilterEvents.ts +149 -0
  38. package/src/{@building/CreateEvent.ts → components/events/ProcessStanza.ts} +22 -24
  39. package/src/components/events/RemoveEvents.ts +74 -0
  40. package/src/{@building → components/events/components}/GetCleanedEvent.ts +2 -2
  41. package/src/{@building → components/events/components}/GetEventAttachments.ts +14 -12
  42. package/src/components/events/components/GetEventDirection.ts +28 -0
  43. package/src/{@building → components/events/components}/GetEventEnhancedName.ts +5 -8
  44. package/src/{@building → components/events/components}/GetEventGeometry.ts +19 -13
  45. package/src/{@building → components/events/components}/GetEventHeader.ts +13 -13
  46. package/src/components/events/components/GetEventMerged.ts +51 -0
  47. package/src/{@building → components/events/components}/GetEventNodes.ts +22 -20
  48. package/src/{@building → components/events/components}/GetEventOffice.ts +13 -13
  49. package/src/components/events/components/GetEventPopulation.ts +58 -0
  50. package/src/components/events/components/GetEventProperties.ts +106 -0
  51. package/src/{@building → components/events/components}/GetEventSignature.ts +9 -9
  52. package/src/{@building → components/events/components}/GetEventTags.ts +3 -3
  53. package/src/components/events/components/GetEventTheme.ts +26 -0
  54. package/src/components/events/components/GetEventTracking.ts +64 -0
  55. package/src/{@modules/@database → components/events/utilities}/GetCachedEvents.ts +18 -15
  56. package/src/{@manager → components/events/utilities}/SetHash.ts +18 -13
  57. package/src/{@manager → components/events/utilities}/UpdateEvents.ts +12 -12
  58. package/src/{@manager → components/events/utilities}/UpdateNode.ts +14 -14
  59. package/src/{@parsers/@text → components/formatting}/GetEmbededText.ts +14 -8
  60. package/src/{@parsers/@text → components/formatting}/GetStringText.ts +15 -11
  61. package/src/{@modules/@utilities → components/geometry}/GetShapeNearestPoint.ts +24 -19
  62. package/src/components/geometry/GetUnionPolygon.ts +36 -0
  63. package/src/components/images/GenerateGraphic.ts +242 -0
  64. package/src/components/images/components/CreateRectangle.ts +22 -0
  65. package/src/components/images/components/CreateText.ts +22 -0
  66. package/src/components/images/modules/CreateSVG.ts +37 -0
  67. package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
  68. package/src/components/images/modules/GetGeographicalCities.ts +58 -0
  69. package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
  70. package/src/components/images/modules/GetGeometryBounds.ts +82 -0
  71. package/src/components/images/modules/GetParsedBoundary.ts +58 -0
  72. package/src/components/images/modules/GetSVGPath.ts +53 -0
  73. package/src/components/images/modules/NormalizePolygon.ts +57 -0
  74. package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +16 -17
  75. package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
  76. package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
  77. package/src/components/utilities/EmitThread.ts +97 -0
  78. package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
  79. package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
  80. package/src/components/utilities/QueueManager.ts +70 -0
  81. package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +13 -13
  82. package/src/components/utilities/SetEventEmit.ts +42 -0
  83. package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
  84. package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +5 -5
  85. package/src/components/utilities/SetTimeoutAction.ts +64 -0
  86. package/src/components/utilities/SetWarning.ts +47 -0
  87. package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +20 -20
  88. package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
  89. package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
  90. package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
  91. package/src/components/xmpp/ReconnectXMPP.ts +64 -0
  92. package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +26 -26
  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 +4 -3
  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 +133 -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 +37 -36
  119. package/src/{@core → exports}/ClearEvents.ts +9 -9
  120. package/src/{@core → exports}/GetEvents.ts +4 -4
  121. package/src/exports/GetNearestCity.ts +45 -0
  122. package/src/{@core → exports}/GetNodes.ts +4 -4
  123. package/src/{@core → exports}/GetRandomEvent.ts +4 -4
  124. package/src/{@core → exports}/GetVersion.ts +4 -4
  125. package/src/exports/ManualEvent.ts +55 -0
  126. package/src/{@core → exports}/QueryStanza.ts +12 -11
  127. package/src/exports/SetNode.ts +100 -0
  128. package/src/{@core → exports}/StartService.ts +23 -22
  129. package/src/{@core → exports}/StopService.ts +10 -10
  130. package/src/index.ts +57 -37
  131. package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +7 -7
  132. package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
  133. package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
  134. package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
  135. package/src/parsers/ugc/GetCache.ts +24 -0
  136. package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
  137. package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
  138. package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
  139. package/src/parsers/ugc/GetZonePolygon.ts +73 -0
  140. package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
  141. package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
  142. package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
  143. package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
  144. package/src/{@parsers/@pvtec → parsers/vtec}/VTECExtract.ts +17 -17
  145. package/src/tasks/CreateTasks.ts +116 -0
  146. package/src/tasks/TaskGenerateJSON.ts +34 -0
  147. package/src/tasks/TaskGenerateText.ts +34 -0
  148. package/src/tasks/TaskSendNTFY.ts +96 -0
  149. package/src/tasks/TaskSendWebhook.ts +107 -0
  150. package/src/{@types → types/event}/Attributes.ts +2 -3
  151. package/src/{@types → types/event}/Event.ts +8 -7
  152. package/src/{@types → types/event}/HVTEC.ts +2 -2
  153. package/src/{@types → types/event}/Properties.ts +17 -3
  154. package/src/{@types → types/event}/Stanza.ts +2 -2
  155. package/src/{@types → types/event}/VTEC.ts +8 -8
  156. package/src/{@types → types/standard}/Actions.ts +3 -3
  157. package/src/{@types → types/standard}/Hash.ts +5 -5
  158. package/src/{@modules/@utilities/GetSettings.ts → types/standard/Nodes.ts} +15 -7
  159. package/src/{@types → types/standard}/Settings.ts +19 -12
  160. package/src/{@types → types/standard}/StanzaCompiled.ts +15 -15
  161. package/src/{@types → types/standard}/UGC.ts +5 -5
  162. package/tools/build.js +32 -0
  163. package/tsconfig.json +32 -1
  164. package/.github/SUPPORTED_EVENTS.md +0 -370
  165. package/.github/docs/docs-functions.md +0 -30
  166. package/.github/docs/docs-general-configurations.md +0 -209
  167. package/.github/docs/docs-integrations.md +0 -37
  168. package/.github/docs/docs-listeners.md +0 -28
  169. package/.github/docs/docs-source-configuration.md +0 -218
  170. package/.github/docs/docs-technical.md +0 -50
  171. package/.github/logo.png +0 -0
  172. package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
  173. package/.github/samples/SAMPLE_GEOJSON.json +0 -204
  174. package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +0 -119
  175. package/dist/cjs/index.cjs +0 -8005
  176. package/dist/esm/index.mjs +0 -7985
  177. package/src/@building/GetEventProperties.ts +0 -96
  178. package/src/@building/GetEventTracking.ts +0 -68
  179. package/src/@core/ManualEvent.ts +0 -56
  180. package/src/@core/SetNode.ts +0 -81
  181. package/src/@events/ParseAPI.ts +0 -117
  182. package/src/@manager/MakeEvents.ts +0 -106
  183. package/src/@manager/RemoveEvent.ts +0 -70
  184. package/src/@manager/Tasks.ts +0 -246
  185. package/src/@manager/ValidateEvents.ts +0 -142
  186. package/src/@modules/@database/InitializeDatabase.ts +0 -59
  187. package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
  188. package/src/@modules/@utilities/GetFormattedTime.ts +0 -43
  189. package/src/@modules/@utilities/SetCronSchedule.ts +0 -94
  190. package/src/@modules/@utilities/SetEventEmit.ts +0 -41
  191. package/src/@modules/@utilities/SetListener.ts +0 -30
  192. package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
  193. package/src/@modules/@utilities/SetWarning.ts +0 -34
  194. package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
  195. package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
  196. package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
  197. package/src/@parsers/@text/GetXML.ts +0 -61
  198. package/src/@parsers/@ugc/GetCache.ts +0 -24
  199. package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
  200. package/tsup.config.ts +0 -16
@@ -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,38 +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/Attributes"
21
- import { EnumAWIPS } from "../../@enums/AWIPS"
20
+ import { TypeAttributes } from "TypesEvent/Attributes"
21
+ import { EnumAWIPS } from "@Enums/AWIPS"
22
22
 
23
23
  interface GetAwipsTypeOptions {
24
- attributes: TypeAttributes
24
+ Attributes: TypeAttributes
25
25
  }
26
26
 
27
27
  interface GetAwipsTypeResponse {
28
- type: string
29
- prefix: string
30
- discovered: boolean
28
+ Type: string
29
+ Prefix: string
30
+ Discovered: boolean
31
31
  }
32
32
 
33
- export const GetAwipsType = (options: GetAwipsTypeOptions): GetAwipsTypeResponse => {
34
- const attributes = options.attributes;
35
- if (!attributes.awipsid) {
33
+ export const GetAwipsType = ({ Attributes }: GetAwipsTypeOptions): GetAwipsTypeResponse => {
34
+ if (!Attributes.awipsid) {
36
35
  return {
37
- type: null,
38
- prefix: null,
39
- discovered: false
36
+ Type: null,
37
+ Prefix: null,
38
+ Discovered: false
40
39
  }
41
40
  }
42
41
  for (const [prefix, type] of Object.entries(EnumAWIPS)) {
43
- if (attributes.awipsid.startsWith(prefix)) {
44
- return { type, prefix, discovered: true }
42
+ if (Attributes.awipsid.startsWith(prefix)) {
43
+ return { Type: type, Prefix: prefix, Discovered: true }
45
44
  }
46
45
  }
47
- return { type: options.attributes.awipsid, prefix: options.attributes.awipsid, discovered: false }
46
+ return { Type: Attributes.awipsid, Prefix: Attributes.awipsid, Discovered: false }
48
47
  }
@@ -11,40 +11,52 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeStanza } from "../../@types/Stanza"
21
- import { TypeStanzaCompiled } from "../../@types/StanzaCompiled"
22
- import { EnumExpressions } from "../../@enums/Expressions"
23
- import { GetAwipsType } from "./GetAwipsType"
20
+ import { TypeStanza } from "TypesEvent/Stanza"
21
+ import { TypeStanzaCompiled } from "TypesStandard/StanzaCompiled"
22
+ import { EnumExpressions } from "@Enums/Expressions"
23
+ import { GetAwipsType } from "@Stanza/GetAwipsType"
24
24
 
25
25
  interface ValidateStanzaOptions {
26
- stanza: TypeStanza
26
+ Stanza: TypeStanza
27
27
  }
28
28
 
29
- export const ValidateStanza = (options: ValidateStanzaOptions): TypeStanzaCompiled => {
30
- if (options.stanza.is(`message`)) {
31
- const cb = options.stanza.getChild(`x`) as TypeStanza;
29
+ export const ValidateStanza = ({ Stanza }: ValidateStanzaOptions): TypeStanzaCompiled => {
30
+ if (Stanza.is(`message`)) {
31
+ const cb = Stanza.getChild(`x`) as TypeStanza;
32
32
  if (cb && cb.children) {
33
33
  const message = unescape(cb.children[0]);
34
34
  const attributes = cb.attrs;
35
35
  if (attributes.awipsid && attributes.awipsid.length > 1) {
36
36
  const isCapEvent = message.includes(`<?xml`);
37
37
  const isCapAreaDescription = message.includes(`<areaDesc>`)
38
- const isVTEC = message.match(EnumExpressions.pvtec) != null;
38
+ const isVTEC = message.match(EnumExpressions.vtec) != null;
39
39
  const isUGC = message.match(EnumExpressions.ugc1) != null;
40
- const getType = GetAwipsType({ attributes: attributes})
41
- if (getType.type != null) {
40
+ const getType = GetAwipsType({ Attributes: attributes})
41
+ if (getType.Type != null) {
42
42
  return {
43
- message, attributes, isCapEvent, isVTEC, isUGC, isCapAreaDescription, isIgnored: false, isNWWS: true, getType
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
+ }
44
56
  }
45
57
  }
46
58
  }
47
59
  }
48
60
  }
49
- return { isIgnored: true}
61
+ return { Ignored: true}
50
62
  }
@@ -11,34 +11,34 @@
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
  interface CreateHttpOptions {
21
- url: string
22
- headers?: any
23
- timeout?: number
24
- auth?: {
25
- username: string
26
- password: string
21
+ URL: string
22
+ Headers?: any
23
+ Timeout?: number
24
+ Auth?: {
25
+ Username: string
26
+ Password: string
27
27
  }
28
- method?: `GET` | `POST` | `PUT` | `DELETE`
29
- body?: any;
30
- formData?: any;
28
+ Method?: `GET` | `POST` | `PUT` | `DELETE`
29
+ Body?: any;
30
+ Form?: any;
31
31
  }
32
32
 
33
- export const CreateHttp = async (options: CreateHttpOptions): Promise<any> => {
33
+ export const CreateHttp = async ({ URL, Headers, Timeout, Auth, Method, Body, Form }: CreateHttpOptions): Promise<any> => {
34
34
  const requestOptions: RequestInit = {
35
- method: options.method ?? "GET",
36
- headers: options.headers ?? {
35
+ method: Method ?? "GET",
36
+ headers: Headers ?? {
37
37
  "User-Agent": "AtmosphericX",
38
38
  "Accept": "application/geo+json, text/plain, */*; q=0.9",
39
39
  "Accept-Language": "en-US,en;q=0.9",
40
40
  },
41
- signal: AbortSignal.timeout(options.timeout ?? 10_000),
41
+ signal: AbortSignal.timeout(Timeout ?? 10_000),
42
42
  redirect: "follow"
43
43
  };
44
44
 
@@ -47,8 +47,8 @@ export const CreateHttp = async (options: CreateHttpOptions): Promise<any> => {
47
47
  return { error: error, options: requestOptions, status, message };
48
48
  }
49
49
 
50
- if (options?.auth) {
51
- const authString = `${options.auth.username}:${options.auth.password}`;
50
+ if (Auth) {
51
+ const authString = `${Auth.Username}:${Auth.Password}`;
52
52
  const encodedAuth = Buffer.from(authString).toString("base64");
53
53
  requestOptions.headers = {
54
54
  ...requestOptions.headers,
@@ -56,20 +56,20 @@ export const CreateHttp = async (options: CreateHttpOptions): Promise<any> => {
56
56
  };
57
57
  }
58
58
 
59
- if (options?.formData) {
60
- requestOptions.body = options.formData;
61
- } else if (options?.body != undefined) {
59
+ if (Form) {
60
+ requestOptions.body = Form;
61
+ } else if (Body != undefined) {
62
62
  requestOptions.body =
63
- options.body instanceof FormData
64
- ? options.body
65
- : typeof options.body === "string"
66
- ? options.body
67
- : JSON.stringify(options.body);
63
+ Body instanceof FormData
64
+ ? Body
65
+ : typeof Body === "string"
66
+ ? Body
67
+ : JSON.stringify(Body);
68
68
  }
69
69
 
70
70
  try {
71
71
  const response = await fetch(
72
- options?.url ?? `https://api.weather.gov/alerts/active`,
72
+ URL ?? `https://api.weather.gov/alerts/active`,
73
73
  requestOptions
74
74
  )
75
75
  const body = await response.text();
@@ -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
+
21
+ import { TypeSettings } from "TypesStandard/Settings"
22
+ import { ReconnectXMPP } from "@XMPP/ReconnectXMPP"
23
+ import { Bootstrap } from "@Bootstrap"
24
+ import { CreateHttp } from "@Utilities/CreateHttp"
25
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
26
+ import { ProcessStanza } from "@Builder/ProcessStanza"
27
+ import { readdirSync, unlinkSync, statSync, rmdirSync, existsSync } from "fs"
28
+ import { join } from "path"
29
+
30
+ export const EmitThread = async (): Promise<void> => {
31
+ const settings = Bootstrap.Settings as TypeSettings;
32
+ const TTL = settings.GlobalSettings.ArchiveSettings.TTL
33
+ const TTLCUT = Date.now() - TTL * 1000;
34
+
35
+ const walk = (dir: string, deleteFolder = false): void => {
36
+ if (!existsSync(dir)) return;
37
+ const entries = readdirSync(dir, { withFileTypes: true });
38
+ for (const entry of entries) {
39
+ const fullPath = join(dir, entry.name);
40
+ if (entry.isDirectory()) {
41
+ walk(fullPath, deleteFolder);
42
+ continue;
43
+ }
44
+ const stats = statSync(fullPath);
45
+ if (stats.mtime.getTime() < TTLCUT) {
46
+ try { unlinkSync(fullPath); } catch (err) {}
47
+ }
48
+ }
49
+ if (deleteFolder) {
50
+ try {
51
+ if (readdirSync(dir).length === 0 && statSync(dir).mtime.getTime() < (Date.now() - 3600000)) { rmdirSync(dir); }
52
+ if (readdirSync(dir).length === 0 && statSync(dir).mtime.getTime() < TTLCUT) { rmdirSync(dir); }
53
+ } catch (err) {}
54
+ }
55
+ }
56
+
57
+ walk(settings.GlobalSettings.ArchiveSettings.TextDirectory, true)
58
+ walk(settings.GlobalSettings.ArchiveSettings.AudioDirectory, true)
59
+ walk(settings.GlobalSettings.ArchiveSettings.JSONDirectory, true)
60
+ walk(settings.GlobalSettings.ArchiveSettings.ImageDirectory, true)
61
+
62
+ if (settings.EnableWireService) {
63
+ if (settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.Enabled) {
64
+ void ReconnectXMPP(settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval)
65
+ }
66
+ } else {
67
+ const response = await CreateHttp({
68
+ URL: settings.NationalWeatherServiceSettings.EventsEndpoint,
69
+ Headers: {
70
+ "User-Agent": "@atmosx/event-product-parser"
71
+ }
72
+ })
73
+ if (response.error) {
74
+ return SetEventEmit({
75
+ Event: `onServiceStatus`,
76
+ Metadata: {
77
+ type: "fetch-api",
78
+ message: `Failed to fetch latest events from National Weather Service API - ${response.message}`,
79
+ data: {},
80
+ error: true
81
+ },
82
+ })
83
+ }
84
+ SetEventEmit({
85
+ Event: `onServiceStatus`,
86
+ Metadata: {
87
+ Message: `Fetched latest events from National Weather Service API`,
88
+ Data: {},
89
+ Type: "fetch-api",
90
+ Error: false
91
+ },
92
+ })
93
+ await ProcessStanza({ Message: response.message, NWWS: false })
94
+ }
95
+ }
96
+
97
+
@@ -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
  */
@@ -11,17 +11,22 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- export const GetMatched = (strings: string[], string: string): boolean => {
21
- const isMatched = strings.some(pattern => {
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 => {
22
27
  if (!pattern) return false;
23
28
  const lowerP = pattern.toLowerCase();
24
- const lowerS = string.toLowerCase()
29
+ const lowerS = String.toLowerCase()
25
30
  if (lowerP === "*" || lowerP === lowerS) return true;
26
31
  if (lowerP.includes("*")) {
27
32
  const regex = "^" + lowerP.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$";
@@ -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
+ }
@@ -11,27 +11,27 @@
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"
20
+ import { TypeSettings } from "TypesStandard/Settings"
21
+ import { Bootstrap } from "@Bootstrap"
22
22
 
23
23
  interface SetDebugOptions {
24
- title?: string
25
- message: string
24
+ Title?: string
25
+ Message: string
26
26
  }
27
27
 
28
- export const SetDebug = (options: SetDebugOptions): void => {
29
- const settings = bootstrap.settings as TypeSettings;
30
- bootstrap.listener.emit(`debug`, {
31
- message: options.message,
32
- function: options.title ?? `debug`,
28
+ export const SetDebug = ({ Title, Message }: SetDebugOptions): void => {
29
+ const settings = Bootstrap.Settings as TypeSettings;
30
+ Bootstrap.Listener.emit(`debug`, {
31
+ message: Message,
32
+ function: Title ?? `debug`,
33
33
  })
34
- if (settings.EnableDebugging) {
35
- console.log(`[${bootstrap.ansi_colors.BLUE}${options.title ?? `debug`}${bootstrap.ansi_colors.RESET}] ${options.message}`)
34
+ if (settings.DeveloperMode) {
35
+ console.log(`[${Bootstrap.Colors.Blue}${Title ?? `debug`}${Bootstrap.Colors.Reset}] ${Message}`)
36
36
  }
37
37
  }
@@ -0,0 +1,42 @@
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 { Bootstrap } from "@Bootstrap"
21
+ import { SetTimeoutAction } from "@Utilities/SetTimeoutAction"
22
+ import { SetWarning } from "@Utilities/SetWarning"
23
+
24
+ interface SetEventEmitOptions {
25
+ Event: string
26
+ Metadata: any
27
+ Message?: string
28
+ Limited?: boolean
29
+ Tree?: string[]
30
+ }
31
+
32
+ export const SetEventEmit = ({ Event, Metadata, Message, Limited, Tree }: SetEventEmitOptions): void => {
33
+ if (Limited) {
34
+ const isTimeout = SetTimeoutAction({ Identifier: `event.${Event}`, AddTime: true, Max: 1, Interval: 1 })
35
+ if (isTimeout.Limited) return;
36
+ }
37
+ Bootstrap.Listener.emit(Event, Metadata)
38
+ if (Event != `log`) { Bootstrap.Listener.emit(`*`, {event: Event, data: Metadata}) }
39
+ if (Message) {
40
+ SetWarning({ Message: Message, Tree: Tree })
41
+ }
42
+ }
@@ -11,17 +11,17 @@
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"
20
+ import { TypeSettings } from "TypesStandard/Settings"
21
+ import { Bootstrap } from "@Bootstrap"
22
22
 
23
- export const SetSettings = (newSettings: TypeSettings): TypeSettings => {
24
- const settings = bootstrap.settings as Record<string, unknown>;
23
+ export const SetSettings = (imported: TypeSettings): TypeSettings => {
24
+ const settings = Bootstrap.Settings as Record<string, unknown>;
25
25
  const merge = (target: Record<string, unknown>, source: Record<string, unknown>) => {
26
26
  for (const key in source) {
27
27
  if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
@@ -37,6 +37,6 @@ export const SetSettings = (newSettings: TypeSettings): TypeSettings => {
37
37
  }
38
38
  }
39
39
  };
40
- merge(settings, newSettings as Record<string, unknown>);
40
+ merge(settings, imported as Record<string, unknown>);
41
41
  return settings as TypeSettings;
42
42
  }