@atmosx/event-product-parser 2.0.16 → 3.0.1

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 (136) hide show
  1. package/README.md +248 -187
  2. package/dist/cjs/index.cjs +12218 -3139
  3. package/dist/esm/index.mjs +12401 -3327
  4. package/dist/index.d.mts +235 -0
  5. package/dist/index.d.ts +235 -0
  6. package/package.json +6 -4
  7. package/src/@building/building.clean.ts +30 -0
  8. package/src/@building/building.create.ts +42 -0
  9. package/src/@building/building.enhance.ts +56 -0
  10. package/src/@building/building.geometry.ts +48 -0
  11. package/src/@building/building.headers.ts +37 -0
  12. package/src/@building/building.office.ts +43 -0
  13. package/src/@building/building.polygon.ts +71 -0
  14. package/src/@building/building.properties.ts +89 -0
  15. package/src/@building/building.signature.ts +61 -0
  16. package/src/@building/building.tags.ts +24 -0
  17. package/src/@building/building.tracking.ts +68 -0
  18. package/src/@building/building.validate.ts +147 -0
  19. package/src/@core/core.getEvents.ts +25 -0
  20. package/src/@core/core.getNodes.ts +25 -0
  21. package/src/@core/core.getRandomEvent.ts +25 -0
  22. package/src/@core/core.getVersion.ts +25 -0
  23. package/src/@core/core.listener.ts +24 -0
  24. package/src/@core/core.setNode.ts +81 -0
  25. package/src/@core/core.start.ts +59 -0
  26. package/src/@core/core.stop.ts +32 -0
  27. package/src/@dictionaries/dictionaries.betterEventNames.ts +89 -0
  28. package/src/@dictionaries/dictionaries.eventActions.ts +28 -0
  29. package/src/@dictionaries/{awips.ts → dictionaries.eventAwipAbreviations.ts} +13 -7
  30. package/src/@dictionaries/dictionaries.eventCancelMessages.ts +30 -0
  31. package/src/@dictionaries/dictionaries.eventCauses.ts +36 -0
  32. package/src/@dictionaries/dictionaries.eventProducts.ts +25 -0
  33. package/src/@dictionaries/dictionaries.eventRecords.ts +25 -0
  34. package/src/@dictionaries/dictionaries.eventSeverity.ts +27 -0
  35. package/src/@dictionaries/dictionaries.eventStatus.ts +31 -0
  36. package/src/@dictionaries/{signatures.ts → dictionaries.eventTags.ts} +13 -68
  37. package/src/@dictionaries/dictionaries.eventTypes.ts +82 -0
  38. package/src/@dictionaries/dictionaries.eventsOffshore.ts +31 -0
  39. package/src/@dictionaries/dictionaries.hailStrings.ts +33 -0
  40. package/src/@dictionaries/{icao.ts → dictionaries.officeICAOs.ts} +13 -6
  41. package/src/@dictionaries/dictionaries.regExp.ts +28 -0
  42. package/src/@dictionaries/dictionaries.shapefileLinks.ts +36 -0
  43. package/src/@dictionaries/dictionaries.statusCorrelationText.ts +40 -0
  44. package/src/@dictionaries/dictionaries.testSignatures.ts +24 -0
  45. package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +68 -0
  46. package/src/@events/events.api.ts +113 -0
  47. package/src/@events/events.text.ts +79 -0
  48. package/src/@events/events.ugc.ts +83 -0
  49. package/src/@events/events.vtec.ts +87 -0
  50. package/src/@manager/manager.mkEvent.ts +95 -0
  51. package/src/@manager/manager.rmEvent.ts +46 -0
  52. package/src/@manager/manager.setHash.ts +37 -0
  53. package/src/@manager/manager.updateNodes.ts +55 -0
  54. package/src/@manager/manager.updateWebhooks.ts +50 -0
  55. package/src/@modules/@database/database.cache.ts +48 -0
  56. package/src/@modules/@database/database.init.ts +45 -0
  57. package/src/@modules/@database/database.shapefiles.ts +96 -0
  58. package/src/@modules/@database/database.stanza.ts +48 -0
  59. package/src/@modules/@eas/eas.getFloatPCM16.ts +29 -0
  60. package/src/@modules/@eas/eas.getMergedPCM16.ts +32 -0
  61. package/src/@modules/@eas/eas.getPCM16.ts +52 -0
  62. package/src/@modules/@eas/eas.getPCMToFloat.ts +26 -0
  63. package/src/@modules/@eas/eas.getSampledPCM16.ts +36 -0
  64. package/src/@modules/@eas/eas.getWavPCM16.ts +52 -0
  65. package/src/@modules/@eas/eas.setAFSK.ts +52 -0
  66. package/src/@modules/@eas/eas.setAsciiToBits.ts +32 -0
  67. package/src/@modules/@eas/eas.setAttentionTone.ts +40 -0
  68. package/src/@modules/@eas/eas.setEasTone.ts +137 -0
  69. package/src/@modules/@eas/eas.setNoise.ts +31 -0
  70. package/src/@modules/@eas/eas.setRadioEffect.ts +49 -0
  71. package/src/@modules/@eas/eas.setSameHeader.ts +45 -0
  72. package/src/@modules/@stanza/stanza.getAwipsType.ts +46 -0
  73. package/src/@modules/@stanza/stanza.validate.ts +50 -0
  74. package/src/@modules/@utilities/utilities.createHttp.ts +85 -0
  75. package/src/@modules/@utilities/utilities.createWebhook.ts +100 -0
  76. package/src/@modules/@utilities/utilities.getFormattedTime.ts +43 -0
  77. package/src/@modules/@utilities/utilities.getSettings.ts +25 -0
  78. package/src/@modules/@utilities/utilities.getShapeNearestPoint.ts +114 -0
  79. package/src/@modules/@utilities/utilities.setCronSchedule.ts +65 -0
  80. package/src/@modules/@utilities/utilities.setEventEmit.ts +41 -0
  81. package/src/@modules/@utilities/utilities.setListener.ts +30 -0
  82. package/src/@modules/@utilities/utilities.setSettings.ts +42 -0
  83. package/src/@modules/@utilities/utilities.setSleep.ts +33 -0
  84. package/src/@modules/@utilities/utilities.setTimeoutAction.ts +59 -0
  85. package/src/@modules/@utilities/utilities.setWarning.ts +34 -0
  86. package/src/@modules/@xmpp/xmpp.xDeploy.ts +58 -0
  87. package/src/@modules/@xmpp/xmpp.xError.ts +29 -0
  88. package/src/@modules/@xmpp/xmpp.xOffline.ts +38 -0
  89. package/src/@modules/@xmpp/xmpp.xOnline.ts +45 -0
  90. package/src/@modules/@xmpp/xmpp.xReconnect.ts +64 -0
  91. package/src/@modules/@xmpp/xmpp.xStanza.ts +63 -0
  92. package/src/@parsers/@hvtec/hvtec.extract.ts +40 -0
  93. package/src/@parsers/@pvtec/pvtec.expires.ts +26 -0
  94. package/src/@parsers/@pvtec/pvtec.extract.ts +49 -0
  95. package/src/@parsers/@text/text.getDescriptionFromProduct.ts +53 -0
  96. package/src/@parsers/@text/text.getPolygonFromProduct.ts +32 -0
  97. package/src/@parsers/@text/text.getTextFromProduct.ts +43 -0
  98. package/src/@parsers/@text/text.getXML.ts +61 -0
  99. package/src/@parsers/@ugc/ugc.coordinates.ts +110 -0
  100. package/src/@parsers/@ugc/ugc.expiry.ts +32 -0
  101. package/src/@parsers/@ugc/ugc.extract.ts +37 -0
  102. package/src/@parsers/@ugc/ugc.header.ts +30 -0
  103. package/src/@parsers/@ugc/ugc.locations.ts +29 -0
  104. package/src/@parsers/@ugc/ugc.zones.ts +52 -0
  105. package/src/@types/type.event.ts +67 -0
  106. package/src/@types/type.properties.ts +75 -0
  107. package/src/@types/types.attributes.ts +28 -0
  108. package/src/@types/types.compiled.ts +35 -0
  109. package/src/@types/types.hash.ts +24 -0
  110. package/src/@types/types.hvtec.ts +25 -0
  111. package/src/@types/types.pvtec.ts +30 -0
  112. package/src/@types/types.settings.ts +76 -0
  113. package/src/@types/types.stanza.ts +37 -0
  114. package/src/@types/types.ugc.ts +24 -0
  115. package/src/@types/types.webhook.ts +26 -0
  116. package/src/bootstrap.ts +85 -163
  117. package/src/index.ts +47 -216
  118. package/test.js +78 -51
  119. package/tsup.config.ts +1 -0
  120. package/src/@dictionaries/events.ts +0 -168
  121. package/src/@parsers/@events/api.ts +0 -146
  122. package/src/@parsers/@events/cap.ts +0 -123
  123. package/src/@parsers/@events/text.ts +0 -104
  124. package/src/@parsers/@events/ugc.ts +0 -107
  125. package/src/@parsers/@events/vtec.ts +0 -76
  126. package/src/@parsers/events.ts +0 -392
  127. package/src/@parsers/hvtec.ts +0 -46
  128. package/src/@parsers/pvtec.ts +0 -72
  129. package/src/@parsers/stanza.ts +0 -97
  130. package/src/@parsers/text.ts +0 -165
  131. package/src/@parsers/ugc.ts +0 -247
  132. package/src/@submodules/database.ts +0 -201
  133. package/src/@submodules/eas.ts +0 -490
  134. package/src/@submodules/utils.ts +0 -191
  135. package/src/@submodules/xmpp.ts +0 -142
  136. package/src/types.ts +0 -259
@@ -0,0 +1,82 @@
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 eventTypes: Record<string, string> = {
21
+ "AF": "Ashfall",
22
+ "AS": "Air Stagnation",
23
+ "BH": "Beach Hazard",
24
+ "BW": "Brisk Wind",
25
+ "BZ": "Blizzard",
26
+ "CF": "Coastal Flood",
27
+ "DF": "Debris Flow",
28
+ "DS": "Dust Storm",
29
+ "EC": "Extreme Cold",
30
+ "EH": "Excessive Heat",
31
+ "XH": "Extreme Heat",
32
+ "EW": "Extreme Wind",
33
+ "FA": "Areal Flood",
34
+ "FF": "Flash Flood",
35
+ "FG": "Dense Fog",
36
+ "FL": "Flood",
37
+ "FR": "Frost",
38
+ "FW": "Fire Weather",
39
+ "FZ": "Freeze",
40
+ "GL": "Gale",
41
+ "HF": "Hurricane Force Wind",
42
+ "HT": "Heat",
43
+ "HU": "Hurricane",
44
+ "HW": "High Wind",
45
+ "HY": "Hydrologic",
46
+ "HZ": "Hard Freeze",
47
+ "IS": "Ice Storm",
48
+ "LE": "Lake Effect Snow",
49
+ "LO": "Low Water",
50
+ "LS": "Lakeshore Flood",
51
+ "LW": "Lake Wind",
52
+ "MA": "Special Marine",
53
+ "EQ": "Earthquake",
54
+ "MF": "Dense Fog",
55
+ "MH": "Ashfall",
56
+ "MS": "Dense Smoke",
57
+ "RB": "Small Craft for Rough Bar",
58
+ "RP": "Rip Current Risk",
59
+ "SC": "Small Craft",
60
+ "SE": "Hazardous Seas",
61
+ "SI": "Small Craft for Winds",
62
+ "SM": "Dense Smoke",
63
+ "SQ": "Snow Squall",
64
+ "SR": "Storm",
65
+ "SS": "Storm Surge",
66
+ "SU": "High Surf",
67
+ "SV": "Severe Thunderstorm",
68
+ "SW": "Small Craft for Hazardous Seas",
69
+ "TO": "Tornado",
70
+ "TR": "Tropical Storm",
71
+ "TS": "Tsunami",
72
+ "TY": "Typhoon",
73
+ "SP": "Special Weather",
74
+ "UP": "Heavy Freezing Spray",
75
+ "WC": "Wind Chill",
76
+ "WI": "Wind",
77
+ "WS": "Winter Storm",
78
+ "WW": "Winter Weather",
79
+ "ZF": "Freezing Fog",
80
+ "ZR": "Freezing Rain",
81
+ "ZY": "Freezing Spray"
82
+ };
@@ -0,0 +1,31 @@
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 eventsOffshore: Record<string, string> = {
21
+ "Special Weather Statement": "Special Weather Statement",
22
+ "Hurricane Warning": "Hurricane Warning",
23
+ "Hurricane Force Wind Warning": "Hurricane Force Wind Warning",
24
+ "Hurricane Watch": "Hurricane Watch",
25
+ "Tropical Storm Warning": "Tropical Storm Warning",
26
+ "Tropical Storm Watch": "Tropical Storm Watch",
27
+ "High Wind Warning": "High Wind Warning",
28
+ "Gale Warning": "Gale Warning",
29
+ "Small Craft Advisory": "Small Craft Advisory",
30
+ "Small Craft Warning": "Small Craft Warning",
31
+ };
@@ -0,0 +1,33 @@
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 hailStrings: Record<string, string> = {
21
+ ".75": "Penny",
22
+ ".88": "Nickel",
23
+ "0.75": "Penny",
24
+ "0.88": "Nickel",
25
+ "1.00": "Quarter",
26
+ "1.25": "Half Dollar",
27
+ "1.50": "Ping Pong Ball",
28
+ "1.75": "Golf Ball",
29
+ "2.00": "Hen Egg",
30
+ "2.50": "Tennis Ball",
31
+ "2.75": "Baseball",
32
+ "4.00": "CD/DVD"
33
+ }
@@ -1,17 +1,23 @@
1
1
  /*
2
- _ _ __ __
2
+ _ _ _ __ __
3
3
  /\ | | | | (_) \ \ / /
4
4
  / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| "_ ` _ \ / _ \/ __| "_ \| "_ \ / _ \ "__| |/ __| > <
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
6
  / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
7
  /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
8
+ | |
9
9
  |_|
10
-
11
- Written by: KiyoWx (k3yomi)
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
+
12
18
  */
13
19
 
14
- export const icaos: Record<string, string> = {
20
+ export const officeICAOs: Record<string, string> = {
15
21
  "KLCH": "Lake Charles, LA",
16
22
  "TSTL": "St. Louis, MO",
17
23
  "PABC": "Bethel, AK",
@@ -19,6 +25,7 @@ export const icaos: Record<string, string> = {
19
25
  "KEPZ": "El Paso, TX",
20
26
  "KCYS": "Cheyenne, WY",
21
27
  "KJKL": "Jackson, KY",
28
+ "KWNS": "Storm Prediction Center",
22
29
  "KPAH": "Paducah, KY",
23
30
  "KEMX": "Tucson, AZ",
24
31
  "KMHX": "Morehead City, NC",
@@ -0,0 +1,28 @@
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 regExp: { [key: string]: RegExp } = {
21
+ pvtec: new RegExp(`[OTEX].(NEW|CON|EXT|EXA|EXB|UPG|CAN|EXP|COR|ROU).[A-Z]{4}.[A-Z]{2}.[WAYSFON].[0-9]{4}.[0-9]{6}T[0-9]{4}Z-[0-9]{6}T[0-9]{4}Z`, "g"),
22
+ hvtec: new RegExp(`[a-zA-Z0-9]{4}.[A-Z0-9].[A-Z]{2}.[0-9]{6}T[0-9]{4}Z.[0-9]{6}T[0-9]{4}Z.[0-9]{6}T[0-9]{4}Z.[A-Z]{2}`, "imu"),
23
+ wmo: new RegExp(`[A-Z0-9]{6}\\s[A-Z]{4}\\s\\d{6}`, "imu"),
24
+ ugc1: new RegExp(`(\\w{2}[CZ](\\d{3}((-|>)\\s?(\\n\\n)?))+)`, "imu"),
25
+ ugc2: new RegExp(`(\\d{6}(-|>)\\s?(\\n\\n)?)`, "imu"),
26
+ ugc3: new RegExp(`(\\d{6})(?=-|$)`, "imu"),
27
+ dateline: new RegExp(`\\d{3,4}\\s*(AM|PM)?\\s*[A-Z]{2,4}\\s+[A-Z]{3,}\\s+[A-Z]{3,}\\s+\\d{1,2}\\s+\\d{4}`, "gim"),
28
+ }
@@ -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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ interface ShapefilesResponse {
21
+ name: string
22
+ id: string
23
+ link: string
24
+ }
25
+
26
+ export const shapefileLinks: ShapefilesResponse[] = [
27
+ {name: "us_counties", id: "C", link: "https://www.weather.gov/source/gis/Shapefiles/County/c_16ap26.zip"},
28
+ {name: "us_states_territories", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/County/s_16ap26.zip"},
29
+ {name: "fire_weather_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/fz16ap26.zip"},
30
+ {name: "costal_marine_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/mz16ap26.zip"},
31
+ {name: "offshore_marine_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/oz16ap26.zip"},
32
+ {name: "public_forecast_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/z_16ap26.zip"},
33
+ {name: "county_warning_areas", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/w_16ap26.zip"},
34
+ {name: "river_forecast_boundaries", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/Misc/rf05mr24.zip"},
35
+ {name: "high_seas_marine_zones", id: "Z", link: "https://www.weather.gov/source/gis/Shapefiles/WSOM/hz17fe26.zip"}
36
+ ]
@@ -0,0 +1,40 @@
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
+ type TypeCorrelations = {
21
+ type: string
22
+ name: string
23
+ isCancel: boolean
24
+ isUpdate: boolean
25
+ isIssued: boolean
26
+ }
27
+
28
+ export const statusCorrelationText: TypeCorrelations[] = [
29
+ {type: "Update", name: "Updated", isCancel: false, isUpdate: true, isIssued: false},
30
+ {type: "Cancel", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false},
31
+ {type: "Alert", name: "Issued", isCancel: false, isUpdate: false, isIssued: true},
32
+ {type: "Updated", name: "Updated", isCancel: false, isUpdate: true, isIssued: false},
33
+ {type: "Expired", name: "Expired", isCancel: true, isUpdate: false, isIssued: false},
34
+ {type: "Issued", name: "Issued", isCancel: false, isUpdate: false, isIssued: true},
35
+ {type: "Extended", name: "Extended", isCancel: false, isUpdate: true, isIssued: false},
36
+ {type: "Correction", name: "Correction", isCancel: false, isUpdate: true, isIssued: false},
37
+ {type: "Upgraded", name: "Upgraded", isCancel: false, isUpdate: true, isIssued: false},
38
+ {type: "Cancelled", name: "Cancelled", isCancel: true, isUpdate: false, isIssued: false},
39
+ {type: "Routine", name: "Routine", isCancel: false, isUpdate: true, isIssued: false},
40
+ ]
@@ -0,0 +1,24 @@
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 testSignatures: string[] = [
21
+ `This is a test message`,
22
+ `Monitoring message only.`,
23
+ `THIS_MESSAGE_IS_FOR_TEST_PURPOSES_ONLY`
24
+ ]
@@ -0,0 +1,68 @@
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 transcribedMessageReplacements: { regex: RegExp, replacement: string }[] = [
21
+ { regex: /\*/g, replacement: "" },
22
+ { regex: /\.{3,}/g, replacement: "" },
23
+ { regex: /\bUTC\b/g, replacement: 'Coordinated Universal Time' },
24
+ { regex: /\bGMT\b/g, replacement: 'Greenwich Mean Time' },
25
+ { regex: /\bEST\b(?!\w)/g, replacement: 'Eastern Standard Time' },
26
+ { regex: /\bEDT\b(?!\w)/g, replacement: 'Eastern Daylight Time' },
27
+ { regex: /\bCST\b(?!\w)/g, replacement: 'Central Standard Time' },
28
+ { regex: /\bCDT\b(?!\w)/g, replacement: 'Central Daylight Time' },
29
+ { regex: /\bMST\b(?!\w)/g, replacement: 'Mountain Standard Time' },
30
+ { regex: /\bMDT\b(?!\w)/g, replacement: 'Mountain Daylight Time' },
31
+ { regex: /\bPST\b(?!\w)/g, replacement: 'Pacific Standard Time' },
32
+ { regex: /\bPDT\b(?!\w)/g, replacement: 'Pacific Daylight Time' },
33
+ { regex: /\bAKST\b(?!\w)/g, replacement: 'Alaska Standard Time' },
34
+ { regex: /\bAKDT\b(?!\w)/g, replacement: 'Alaska Daylight Time' },
35
+ { regex: /\bHST\b(?!\w)/g, replacement: 'Hawaii Standard Time' },
36
+ { regex: /\bHDT\b(?!\w)/g, replacement: 'Hawaii Daylight Time' },
37
+ { regex: /\bmph\b(?!\w)/g, replacement: 'miles per hour' },
38
+ { regex: /\bkm\/h\b(?!\w)/g, replacement: 'kilometers per hour' },
39
+ { regex: /\bkmh\b(?!\w)/g, replacement: 'kilometers per hour' },
40
+ { regex: /\bkt\b(?!\w)/g, replacement: 'knots' },
41
+ { regex: /\bNE\b(?!\w)/g, replacement: 'northeast' },
42
+ { regex: /\bNW\b(?!\w)/g, replacement: 'northwest' },
43
+ { regex: /\bSE\b(?!\w)/g, replacement: 'southeast' },
44
+ { regex: /\bSW\b(?!\w)/g, replacement: 'southwest' },
45
+ { regex: /\bNM\b(?!\w)/g, replacement: 'nautical miles' },
46
+ { regex: /\bdeg\b(?!\w)/g, replacement: 'degrees' },
47
+ { regex: /\btstm\b(?!\w)/g, replacement: 'thunderstorm' },
48
+ { regex: /\bmm\b(?!\w)/g, replacement: 'millimeters' },
49
+ { regex: /\bcm\b(?!\w)/g, replacement: 'centimeters' },
50
+ { regex: /\bin.\b(?!\w)/g, replacement: 'inches' },
51
+ { regex: /\bft\b(?!\w)/g, replacement: 'feet' },
52
+ { regex: /\bmi\b(?!\w)/g, replacement: 'miles' },
53
+ { regex: /\bhr\b(?!\w)/g, replacement: 'hour' },
54
+ { regex: /\bhourly\b(?!\w)/g, replacement: 'per hour' },
55
+ { regex: /\bkg\b(?!\w)/g, replacement: 'kilograms' },
56
+ { regex: /\bg\/kg\b(?!\w)/g, replacement: 'grams per kilogram' },
57
+ { regex: /\bmb\b(?!\w)/g, replacement: 'millibars' },
58
+ { regex: /\bhPa\b(?!\w)/g, replacement: 'hectopascals' },
59
+ { regex: /\bPa\b(?!\w)/g, replacement: 'pascals' },
60
+ { regex: /\bKPa\b(?!\w)/g, replacement: 'kilopascals' },
61
+ { regex: /\bC\/hr\b(?!\w)/g, replacement: 'degrees Celsius per hour' },
62
+ { regex: /\bF\/hr\b(?!\w)/g, replacement: 'degrees Fahrenheit per hour' },
63
+ { regex: /\bC\/min\b(?!\w)/g, replacement: 'degrees Celsius per minute' },
64
+ { regex: /\bF\/min\b(?!\w)/g, replacement: 'degrees Fahrenheit per minute' },
65
+ { regex: /\bC\b(?!\w)/g, replacement: 'degrees Celsius' },
66
+ { regex: /\bF\b(?!\w)/g, replacement: 'degrees Fahrenheit' },
67
+ ];
68
+
@@ -0,0 +1,113 @@
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 { TypeStanzaCompiled } from "../@types/types.compiled"
21
+ import { TypeEvent } from "../@types/type.event";
22
+ import { getEventTracking } from "../@building/building.tracking";
23
+ import { validateEvents } from "../@building/building.validate";
24
+ import { getEventOffice } from "../@building/building.office";
25
+ import { getEventTags } from "../@building/building.tags";
26
+ import { getTextFromProduct } from "../@parsers/@text/text.getTextFromProduct";
27
+ import { officeICAOs } from "../@dictionaries/dictionaries.officeICAOs";
28
+
29
+ export const api = async (stanza: TypeStanzaCompiled): Promise<void> => {
30
+ let processed: TypeEvent[] = [];
31
+ const messages = Object.values(JSON.parse(stanza.message).features) as any;
32
+ for (const feature of messages) {
33
+ const tick = performance.now();
34
+ const pVtec = feature?.properties?.parameters?.VTEC?.[0] ?? null
35
+ processed.push({
36
+ type: `Feature`,
37
+ geometry: {
38
+ type: `Point`,
39
+ coordinates: []
40
+ },
41
+ properties: {
42
+ event: feature?.properties?.event ?? null,
43
+ parent: feature?.properties?.event ?? null,
44
+ status: feature?.properties?.messageType ?? null,
45
+ issued: feature?.properties?.sent ? new Date(feature?.properties?.sent).toISOString() : null,
46
+ expires: feature?.properties?.expires ? new Date(feature?.properties?.expires).toISOString() : null,
47
+ locations: feature?.properties?.areaDesc ?? null,
48
+ description: feature?.properties?.description ?? null,
49
+ attributes: feature?.properties?.attributes ?? {},
50
+ geocode: {
51
+ office: {
52
+ office: pVtec ? pVtec.split(`.`)[2] : null,
53
+ name: officeICAOs[pVtec ? pVtec.split(`.`)[2] : null] ?? null,
54
+ },
55
+ organization: feature?.properties?.parameters?.WMOidentifier?.[0],
56
+ ugc: feature?.properties?.geocode?.UGC ?? [],
57
+ polygon: feature?.geometry?.coordinates.length > 0 ? Buffer.from(JSON.stringify([feature?.geometry?.coordinates[0]])).toString('base64') : null,
58
+ polygon_generated: feature?.geometry?.coordinates.length > 0 ? true : false,
59
+ },
60
+ parameters: {
61
+ tags: getEventTags(feature?.properties?.description),
62
+ instructions: feature?.properties?.instruction ?? null,
63
+ source: getTextFromProduct({ message: feature?.properties?.description, find: [`SOURCE...`], removal: [`.`]}) ?? null,
64
+ hazards: getTextFromProduct({ message: feature?.properties?.description, find: [`HAZARD...`], removal: [`.`]}) ?? null,
65
+ impacts: getTextFromProduct({ message: feature?.properties?.description, find: [`IMPACT...`], removal: [`.`]}) ?? null,
66
+ estimated_hail_size: feature?.properties?.parameters?.maxHailSize?.[0] ?? null,
67
+ estimated_wind_gusts: feature?.properties?.parameters?.maxWindGust?.[0] ?? null,
68
+ damage_threat: feature?.properties?.parameters?.thunderstormDamageThreat?.[0] ?? null,
69
+ tornado_threat: feature?.properties?.parameters?.tornadoDetection?.[0] ?? null,
70
+ flood_threat: feature?.properties?.parameters?.floodDetection?.[0] ?? null,
71
+ wind_threat: feature?.properties?.parameters?.windThreat?.[0] ?? null,
72
+ hail_threat: feature?.properties?.parameters?.hailThreat?.[0] ?? null,
73
+ },
74
+ spc_parameters: {
75
+ spc_max_tornado: getTextFromProduct({ message: feature?.properties?.description, find: [`MOST PROBABLE PEAK TORNADO INTENSITY...`] }) ?? null,
76
+ spc_max_hail: getTextFromProduct({ message: feature?.properties?.description, find: [`MOST PROBABLE PEAK HAIL SIZE...`] }) ?? null,
77
+ spc_max_wind: getTextFromProduct({ message: feature?.properties?.description, find: [`MOST PROBABLE PEAK WIND GUST...`] }) ?? null,
78
+ spc_watch_issuance: getTextFromProduct({ message: feature?.properties?.description, find: [`Probability of Watch Issuance...`], removal: [`percent`]}) ?? null,
79
+ },
80
+ watch_parameters: {
81
+ watch_number: getTextFromProduct({ message: feature?.properties?.description, find: [`ITIES FOR`, `UPDATE FOR`, `Watch Number `], removal: [`%`, `<`, `:`] })?.replace(/(WT|WS|)/g, '')?.trim() ?? null,
82
+ watch_type: feature?.properties?.description.includes(`TORNADO WATCH`) ? `Tornado` : feature?.properties?.description.includes(`SEVERE`) ? `Severe` : null,
83
+ additional_tornadoes_probability: getTextFromProduct({ message: feature?.properties?.description, find: [`PROB OF 2 OR MORE TORNADOES`], removal: [`%`, `<`, `:`] }) ?? null,
84
+ strong_tornadoes_probability: getTextFromProduct({ message: feature?.properties?.description, find: [`PROB OF 1 OR MORE STRONG /EF2-EF5/ TORNADOES`], removal: [`%`, `<`, `:`] }) ?? null,
85
+ severe_wind_probability: getTextFromProduct({ message: feature?.properties?.description, find: [`PROB OF 10 OR MORE SEVERE WIND EVENTS`], removal: [`%`, `<`, `:`] }) ?? null,
86
+ severe_hail_probability: getTextFromProduct({ message: feature?.properties?.description, find: [`PROB OF 10 OR MORE SEVERE HAIL EVENTS`], removal: [`%`, `<`, `:`] }) ?? null,
87
+ hail_2in_probability: getTextFromProduct({ message: feature?.properties?.description, find: [`PROB OF 1 OR MORE HAIL EVENTS >= 2 INCHES`], removal: [`%`, `<`, `:`] }) ?? null,
88
+ combined_hail_wind_probability: getTextFromProduct({ message: feature?.properties?.description, find: [`PROB OF 6 OR MORE COMBINED SEVERE HAIL/WIND EVENTS`], removal: [`%`, `<`, `:`] }) ?? null,
89
+ max_hail_in: getTextFromProduct({ message: feature?.properties?.description, find: [`MAX HAIL /INCHES/`], removal: [`%`, `<`, `:`] }) ?? null,
90
+ max_wind_surface: getTextFromProduct({ message: feature?.properties?.description, find: [`MAX WIND GUSTS SURFACE /KNOTS/`], removal: [`%`, `<`, `:`] }) ?? null,
91
+ max_tops_x100feet: getTextFromProduct({ message: feature?.properties?.description, find: [`MAX TOPS /X 100 FEET/`], removal: [`%`, `<`, `:`] }) ?? null,
92
+ pds_watch: (getTextFromProduct({ message: feature?.properties?.description, find: [`PARTICULARLY DANGEROUS SITUATION`], removal: [`%`, `<`, `:`] }) === `YES`)
93
+ },
94
+ metadata: {
95
+ ms: performance.now() - tick,
96
+ source: `events.api`,
97
+ tracking: getEventTracking({ type: `API`, organization: { wmoidentifier: feature?.properties?.parameters?.WMOidentifier?.[0], featureId: feature?.id}, vtec: pVtec}),
98
+ header: `ZCZC-ATMOSX-${feature?.properties?.parameters?.WMOidentifier}`,
99
+ vtec: pVtec,
100
+ hvtec: null,
101
+ history: [
102
+ {
103
+ description: feature?.properties?.description,
104
+ issued: feature?.properties?.sent ? new Date(feature?.properties?.sent).toISOString() : null,
105
+ status: feature?.properties?.messageType ?? null,
106
+ }
107
+ ]
108
+ }
109
+ }
110
+ })
111
+ }
112
+ validateEvents(processed)
113
+ }
@@ -0,0 +1,79 @@
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 { TypeAttributes } from "../@types/types.attributes";
21
+ import { TypeStanzaCompiled } from "../@types/types.compiled"
22
+ import { TypeEvent } from "../@types/type.event";
23
+ import { properties } from "../@building/building.properties";
24
+ import { getEventHeader } from "../@building/building.headers";
25
+ import { eventsOffshore } from "../@dictionaries/dictionaries.eventsOffshore";
26
+ import { getEventTracking } from "../@building/building.tracking";
27
+ import { validateEvents } from "../@building/building.validate";
28
+
29
+ export const text = async (stanza: TypeStanzaCompiled): Promise<void> => {
30
+ let processed: TypeEvent[] = [];
31
+ const getMessages = stanza?.message
32
+ ?.split(/(?=\$\$)/g)
33
+ ?.map(message => message.trim())
34
+ ?.filter(message => message && message !== "$$");
35
+ if (!getMessages || getMessages?.length == 0 ) return;
36
+ for (const message of getMessages) {
37
+ const tick = performance.now();
38
+ const attributes = stanza?.attributes as TypeAttributes
39
+ const props = properties({ message, attributes })
40
+ const header = getEventHeader({properties: props, getType: stanza.getType})
41
+ const issued = new Date(attributes.issue)
42
+ const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1000)
43
+ let event = Object.keys(eventsOffshore).find(event => message.toLowerCase().includes(event.toLowerCase()));
44
+ if (!event) {
45
+ event = stanza.getType.type.split(`-`).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(` `)
46
+ }
47
+ processed.push({
48
+ type: `Feature`,
49
+ geometry: {
50
+ type: `Point`,
51
+ coordinates: []
52
+ },
53
+ properties: {
54
+ event: event,
55
+ parent: event,
56
+ status: `Issued`,
57
+ issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
58
+ expires: (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
59
+ ...props,
60
+ metadata: {
61
+ ms: performance.now() - tick,
62
+ source: `events.text`,
63
+ tracking: getEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
64
+ header: header,
65
+ vtec: null,
66
+ hvtec: null,
67
+ history: [
68
+ {
69
+ description: props.description,
70
+ issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
71
+ status: `Issued`,
72
+ }
73
+ ]
74
+ }
75
+ }
76
+ })
77
+ }
78
+ validateEvents(processed)
79
+ }