@atmosx/event-product-parser 2.0.15 → 3.0.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 (116) hide show
  1. package/README.md +4 -237
  2. package/dist/cjs/index.cjs +2233 -3100
  3. package/dist/esm/index.mjs +2233 -3103
  4. package/package.json +3 -3
  5. package/src/@building/building.clean.ts +30 -0
  6. package/src/@building/building.create.ts +42 -0
  7. package/src/@building/building.enhance.ts +56 -0
  8. package/src/@building/building.geometry.ts +42 -0
  9. package/src/@building/building.headers.ts +37 -0
  10. package/src/@building/building.office.ts +43 -0
  11. package/src/@building/building.polygon.ts +71 -0
  12. package/src/@building/building.properties.ts +89 -0
  13. package/src/@building/building.signature.ts +78 -0
  14. package/src/@building/building.tags.ts +24 -0
  15. package/src/@building/building.tracking.ts +68 -0
  16. package/src/@building/building.validate.ts +132 -0
  17. package/src/@core/core.callback.ts +39 -0
  18. package/src/@core/core.getEvents.ts +25 -0
  19. package/src/@core/core.getNodes.ts +25 -0
  20. package/src/@core/core.listener.ts +24 -0
  21. package/src/@core/core.setNode.ts +81 -0
  22. package/src/@core/core.start.ts +54 -0
  23. package/src/@core/core.stop.ts +32 -0
  24. package/src/@dictionaries/dictionaries.betterEventNames.ts +85 -0
  25. package/src/@dictionaries/dictionaries.eventActions.ts +28 -0
  26. package/src/@dictionaries/{awips.ts → dictionaries.eventAwipAbreviations.ts} +12 -6
  27. package/src/@dictionaries/dictionaries.eventCancelMessages.ts +29 -0
  28. package/src/@dictionaries/dictionaries.eventCauses.ts +36 -0
  29. package/src/@dictionaries/dictionaries.eventProducts.ts +25 -0
  30. package/src/@dictionaries/dictionaries.eventRecords.ts +25 -0
  31. package/src/@dictionaries/dictionaries.eventSeverity.ts +27 -0
  32. package/src/@dictionaries/dictionaries.eventStatus.ts +31 -0
  33. package/src/@dictionaries/{signatures.ts → dictionaries.eventTags.ts} +13 -68
  34. package/src/@dictionaries/dictionaries.eventTypes.ts +82 -0
  35. package/src/@dictionaries/dictionaries.eventsOffshore.ts +31 -0
  36. package/src/@dictionaries/dictionaries.hailStrings.ts +31 -0
  37. package/src/@dictionaries/{icao.ts → dictionaries.officeICAOs.ts} +13 -6
  38. package/src/@dictionaries/dictionaries.regExp.ts +28 -0
  39. package/src/@dictionaries/dictionaries.shapefileLinks.ts +36 -0
  40. package/src/@dictionaries/dictionaries.statusCorrelationText.ts +40 -0
  41. package/src/@dictionaries/dictionaries.test_signatures.ts +23 -0
  42. package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +68 -0
  43. package/src/@events/events.api.ts +113 -0
  44. package/src/@events/events.text.ts +79 -0
  45. package/src/@events/events.ugc.ts +83 -0
  46. package/src/@events/events.vtec.ts +87 -0
  47. package/src/@manager/manager.mkEvent.ts +79 -0
  48. package/src/@manager/manager.rmEvent.ts +44 -0
  49. package/src/@manager/manager.setHash.ts +37 -0
  50. package/src/@manager/manager.updateNodes.ts +51 -0
  51. package/src/@modules/@database/database.cache.ts +48 -0
  52. package/src/@modules/@database/database.init.ts +45 -0
  53. package/src/@modules/@database/database.shapefiles.ts +97 -0
  54. package/src/@modules/@database/database.stanza.ts +47 -0
  55. package/src/@modules/@stanza/stanza.getAwipsType.ts +46 -0
  56. package/src/@modules/@stanza/stanza.validate.ts +50 -0
  57. package/src/@modules/@utilities/utilities.createHttp.ts +75 -0
  58. package/src/@modules/@utilities/utilities.getFormattedTime.ts +43 -0
  59. package/src/@modules/@utilities/utilities.getSettings.ts +25 -0
  60. package/src/@modules/@utilities/utilities.getShapeNearestPoint.ts +114 -0
  61. package/src/@modules/@utilities/utilities.setCronSchedule.ts +38 -0
  62. package/src/@modules/@utilities/utilities.setEventEmit.ts +41 -0
  63. package/src/@modules/@utilities/utilities.setListener.ts +30 -0
  64. package/src/@modules/@utilities/utilities.setSettings.ts +42 -0
  65. package/src/@modules/@utilities/utilities.setSleep.ts +33 -0
  66. package/src/@modules/@utilities/utilities.setTimeoutAction.ts +59 -0
  67. package/src/@modules/@utilities/utilities.setWarning.ts +34 -0
  68. package/src/@modules/@xmpp/xmpp.xDeploy.ts +58 -0
  69. package/src/@modules/@xmpp/xmpp.xError.ts +38 -0
  70. package/src/@modules/@xmpp/xmpp.xOffline.ts +38 -0
  71. package/src/@modules/@xmpp/xmpp.xOnline.ts +61 -0
  72. package/src/@modules/@xmpp/xmpp.xReconnect.ts +59 -0
  73. package/src/@modules/@xmpp/xmpp.xStanza.ts +63 -0
  74. package/src/@parsers/@hvtec/hvtec.extract.ts +40 -0
  75. package/src/@parsers/@pvtec/pvtec.expires.ts +26 -0
  76. package/src/@parsers/@pvtec/pvtec.extract.ts +50 -0
  77. package/src/@parsers/@text/text.getDescriptionFromProduct.ts +53 -0
  78. package/src/@parsers/@text/text.getPolygonFromProduct.ts +32 -0
  79. package/src/@parsers/@text/text.getTextFromProduct.ts +43 -0
  80. package/src/@parsers/@text/text.getXML.ts +61 -0
  81. package/src/@parsers/@ugc/ugc.coordinates.ts +110 -0
  82. package/src/@parsers/@ugc/ugc.expiry.ts +32 -0
  83. package/src/@parsers/@ugc/ugc.extract.ts +37 -0
  84. package/src/@parsers/@ugc/ugc.header.ts +30 -0
  85. package/src/@parsers/@ugc/ugc.locations.ts +29 -0
  86. package/src/@parsers/@ugc/ugc.zones.ts +52 -0
  87. package/src/@types/type.event.ts +67 -0
  88. package/src/@types/type.properties.ts +75 -0
  89. package/src/@types/types.attributes.ts +28 -0
  90. package/src/@types/types.compiled.ts +35 -0
  91. package/src/@types/types.hash.ts +24 -0
  92. package/src/@types/types.hvtec.ts +25 -0
  93. package/src/@types/types.pvtec.ts +29 -0
  94. package/src/@types/types.settings.ts +71 -0
  95. package/src/@types/types.stanza.ts +37 -0
  96. package/src/@types/types.ugc.ts +24 -0
  97. package/src/bootstrap.ts +82 -164
  98. package/src/index.ts +48 -216
  99. package/test.js +65 -49
  100. package/src/@dictionaries/events.ts +0 -168
  101. package/src/@parsers/@events/api.ts +0 -146
  102. package/src/@parsers/@events/cap.ts +0 -123
  103. package/src/@parsers/@events/text.ts +0 -104
  104. package/src/@parsers/@events/ugc.ts +0 -107
  105. package/src/@parsers/@events/vtec.ts +0 -76
  106. package/src/@parsers/events.ts +0 -392
  107. package/src/@parsers/hvtec.ts +0 -46
  108. package/src/@parsers/pvtec.ts +0 -72
  109. package/src/@parsers/stanza.ts +0 -97
  110. package/src/@parsers/text.ts +0 -165
  111. package/src/@parsers/ugc.ts +0 -247
  112. package/src/@submodules/database.ts +0 -200
  113. package/src/@submodules/eas.ts +0 -490
  114. package/src/@submodules/utils.ts +0 -184
  115. package/src/@submodules/xmpp.ts +0 -142
  116. package/src/types.ts +0 -259
@@ -0,0 +1,42 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypeSettings } from '../../@types/types.settings'
21
+ import { bootstrap } from "../../bootstrap"
22
+
23
+ export const setSettings = (newSettings: TypeSettings): TypeSettings => {
24
+ const settings = bootstrap.settings as Record<string, unknown>;
25
+ const merge = (target: Record<string, unknown>, source: Record<string, unknown>) => {
26
+ for (const key in source) {
27
+ if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
28
+ const srcVal = source[key];
29
+ const tgtVal = target[key];
30
+ if (srcVal && typeof srcVal === 'object' && !Array.isArray(srcVal)) {
31
+ if (!tgtVal || typeof tgtVal !== 'object' || Array.isArray(tgtVal)) {
32
+ target[key] = {};
33
+ }
34
+ merge(target[key] as Record<string, unknown>, srcVal as Record<string, unknown>);
35
+ } else {
36
+ target[key] = srcVal;
37
+ }
38
+ }
39
+ };
40
+ merge(settings, newSettings as Record<string, unknown>);
41
+ return settings as TypeSettings;
42
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & 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
+
21
+ interface ImportOptions {
22
+ timeout: number
23
+ }
24
+
25
+ export const setSleep = async (options: ImportOptions): Promise<void> => {
26
+ return new Promise((resolve) => {
27
+ setTimeout(() => {
28
+ resolve();
29
+ }, options.timeout);
30
+ });
31
+ }
32
+
33
+
@@ -0,0 +1,59 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { bootstrap } from "../../bootstrap"
21
+
22
+ interface ImportOptions {
23
+ identifier: string
24
+ addTime?: boolean
25
+ max?: number
26
+ interval: number
27
+ }
28
+
29
+ type ExportOptions = {
30
+ limited: boolean
31
+ remaining?: number
32
+ response?: string
33
+ }
34
+
35
+ export const setTimeoutAction = (options: ImportOptions): ExportOptions => {
36
+ let target = bootstrap?.ratelimits?.[options?.identifier];
37
+ if (!target) {
38
+ bootstrap.ratelimits[options?.identifier] = [];
39
+ target = bootstrap.ratelimits[options?.identifier];
40
+ }
41
+ if (target?.length > 0) {
42
+ bootstrap.ratelimits[options?.identifier] = target.filter((ts: number) => Date.now() - ts < options?.interval * 1000);
43
+ target = bootstrap.ratelimits[options?.identifier];
44
+ }
45
+
46
+ const oldestTimestamp = target?.[0];
47
+ const getWait = oldestTimestamp ? Math.ceil((options?.interval * 1000) - (Date.now() - oldestTimestamp)) : 0;
48
+ const max = options?.max || 1;
49
+
50
+ if (target?.length >= max && getWait > 0) {
51
+ return {
52
+ limited: true,
53
+ remaining: getWait,
54
+ response: `You are being rate limited, please wait ${(getWait / 1e3).toFixed(1)} second(s) before performing this action again.`
55
+ }
56
+ }
57
+ bootstrap.ratelimits[options?.identifier].push(Date.now());
58
+ return { limited: false };
59
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { bootstrap } from "../../bootstrap"
21
+ import { TypeSettings } from "../../@types/types.settings";
22
+
23
+ interface ImportOptions {
24
+ title?: string
25
+ message: string
26
+ }
27
+
28
+ export const setWarning = (options: ImportOptions): void => {
29
+ const settings = bootstrap.settings as TypeSettings;
30
+ bootstrap.listener.emit(`log`, `${options.title ?? `[${bootstrap.ansi_colors.YELLOW}ATMOSX-PARSER${bootstrap.ansi_colors.RESET}]`} ${options.message}`)
31
+ if (settings.EnableJournal) {
32
+ console.log(`${options.title ?? `[${bootstrap.ansi_colors.YELLOW}ATMOSX-PARSER${bootstrap.ansi_colors.RESET}]`} ${options.message}`)
33
+ }
34
+ }
@@ -0,0 +1,58 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & 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 { client } from '@xmpp/client';
21
+ import { TypeSettings } from "../../@types/types.settings";
22
+ import { bootstrap } from "../../bootstrap"
23
+ import { setWarning } from "../@utilities/utilities.setWarning";
24
+ import { xOnline } from "./xmpp.xOnline";
25
+ import { xOffline } from "./xmpp.xOffline";
26
+ import { xError } from "./xmpp.xError";
27
+ import { xStanza } from "./xmpp.xStanza";
28
+ import { setEventEmit } from '../@utilities/utilities.setEventEmit';
29
+
30
+ export const xDeploy = async (): Promise<void> => {
31
+ let session;
32
+ const settings = bootstrap.settings as TypeSettings
33
+ settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
34
+ ??= settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username;
35
+ session = bootstrap.session_xmpp = client({
36
+ service: 'xmpp://nwws-oi.weather.gov',
37
+ domain: 'nwws-oi.weather.gov',
38
+ username: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username,
39
+ password: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Password
40
+ })
41
+ try {
42
+ await xOffline();
43
+ await xError();
44
+ await xStanza();
45
+ await xOnline();
46
+ await session.start()
47
+ } catch (error) {
48
+ setEventEmit({
49
+ event: `onXMPPStatus`,
50
+ metadata: {
51
+ message: `Error occured while starting XMPP Session: ${error}`,
52
+ data: {},
53
+ type: `error`,
54
+ error: true
55
+ },
56
+ })
57
+ }
58
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { bootstrap } from "../../bootstrap";
21
+ import { setEventEmit } from "../@utilities/utilities.setEventEmit";
22
+ import { setWarning } from "../@utilities/utilities.setWarning";
23
+
24
+ export const xError = () => {
25
+ bootstrap.session_xmpp.on(`error`, async (error: Error) => {
26
+ bootstrap.cache.isConnected = false;
27
+ bootstrap.cache.sigHault = true;
28
+ setEventEmit({
29
+ event: `onXMPPStatus`,
30
+ metadata: {
31
+ message: `Client has recieved an error`,
32
+ data: {},
33
+ type: `error`,
34
+ error: true
35
+ },
36
+ })
37
+ })
38
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { bootstrap } from "../../bootstrap";
21
+ import { setEventEmit } from "../@utilities/utilities.setEventEmit";
22
+ import { setWarning } from "../@utilities/utilities.setWarning";
23
+
24
+ export const xOffline = () => {
25
+ bootstrap.session_xmpp.on(`offline`, async () => {
26
+ bootstrap.cache.isConnected = false;
27
+ bootstrap.cache.sigHault = true;
28
+ setEventEmit({
29
+ event: `onXMPPStatus`,
30
+ metadata: {
31
+ message: `Client has gone offline`,
32
+ data: {},
33
+ type: `offline`,
34
+ error: true
35
+ },
36
+ })
37
+ })
38
+ }
@@ -0,0 +1,61 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+ import { xml } from '@xmpp/client'
20
+ import { bootstrap } from "../../bootstrap";
21
+ import { setSleep } from "../@utilities/utilities.setSleep";
22
+ import { setEventEmit } from '../@utilities/utilities.setEventEmit';
23
+
24
+ export const xOnline = () => {
25
+ const settings = bootstrap.settings;
26
+ bootstrap.session_xmpp.on(`online`, async (address: string) => {
27
+ const tick = Date.now();
28
+ if (bootstrap.cache.lastConnect && tick - bootstrap.cache.lastConnect > 10e3) {
29
+ bootstrap.cache.sigHault = true;
30
+ setEventEmit({
31
+ event: `onXMPPStatus`,
32
+ metadata: {
33
+ message: `The XMPP Client is attempting to reconnect too fast, this may be due to network instability and this reconnect request has been throttled. We will attempt to reconnect when all connections have been killed`,
34
+ data: {},
35
+ type: `offline`,
36
+ error: true
37
+ },
38
+ })
39
+ await setSleep({timeout: 2e3})
40
+ bootstrap.session_xmpp.stop().catch(() => {});
41
+ return;
42
+ }
43
+ bootstrap.cache.sigHault = false;
44
+ bootstrap.cache.isConnected = true;
45
+ bootstrap.cache.lastConnect = tick;
46
+ const nickname = settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname;
47
+ bootstrap.session_xmpp.send(xml('presence', {
48
+ to: `nwws@conference.nwws-oi.weather.gov/${nickname}`,
49
+ xmlns: 'http://jabber.org/protocol/muc',
50
+ }))
51
+ setEventEmit({
52
+ event: `onXMPPStatus`,
53
+ metadata: {
54
+ message: `Succesfully connected to NOAA Weather Wire Service as "${nickname}"`,
55
+ data: {},
56
+ type: `online`,
57
+ error: false
58
+ },
59
+ })
60
+ })
61
+ }
@@ -0,0 +1,59 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypeSettings } from "../../@types/types.settings";
21
+ import { bootstrap } from "../../bootstrap"
22
+ import { setEventEmit } from "../@utilities/utilities.setEventEmit";
23
+ import { setWarning } from "../@utilities/utilities.setWarning";
24
+
25
+ export const xReconnect = async (interval: number): Promise<void> => {
26
+ const settings = bootstrap.settings as TypeSettings;
27
+ const lastStanza = Date.now() - bootstrap.cache.lastStanza
28
+ const reconnectThreshold = interval * 1e3
29
+ if ((!bootstrap.cache.isConnected && !bootstrap.cache.sigHault) || !bootstrap.session_xmpp) {
30
+ return;
31
+ }
32
+ if (lastStanza > reconnectThreshold) {
33
+ if (!bootstrap.cache.isReconnecting) {
34
+ bootstrap.cache.isReconnecting = true;
35
+ bootstrap.cache.isConnected = false;
36
+ bootstrap.cache.tReconnects += 1;
37
+ try {
38
+ setEventEmit({
39
+ event: `onXMPPStatus`,
40
+ metadata: {
41
+ message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
42
+ data: {
43
+ last_stanza: lastStanza,
44
+ nickname: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
45
+ },
46
+ type: `reconnect`,
47
+ error: true
48
+ },
49
+ })
50
+ await bootstrap.session_xmpp.stop().catch(() => {});
51
+ await bootstrap.session_xmpp.start().catch(() => {});
52
+ } catch (error) {
53
+ setWarning({ message: `XMPP Reconnect Failed - ${(error as Error).message}` })
54
+ } finally {
55
+ bootstrap.cache.isReconnecting = false;
56
+ }
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypeStanza } from "../../@types/types.stanza";
21
+ import { bootstrap } from "../../bootstrap";
22
+ import { validate } from "../@stanza/stanza.validate";
23
+ import { createEvent } from "../../@building/building.create";
24
+ import { importStanza } from "../@database/database.stanza";
25
+ import { setEventEmit } from "../@utilities/utilities.setEventEmit";
26
+
27
+ export const xStanza = () => {
28
+ bootstrap.session_xmpp.on(`stanza`, async (stanza: TypeStanza) => {
29
+ const msgFrom = stanza?.attrs?.from ?? ``
30
+ const msgType = stanza?.attrs?.type ?? ``
31
+ setEventEmit({
32
+ event: `onXMPPStatus`,
33
+ metadata: {
34
+ message: stanza,
35
+ from: msgFrom,
36
+ type: `stanza`
37
+ },
38
+ })
39
+ bootstrap.cache.lastStanza = Date.now();
40
+ if (stanza.is(`message`)) {
41
+ const result = validate({ stanza });
42
+ const isSkippable = result.isIgnored ||
43
+ (result.isCapEvent) ||
44
+ (result.isCapEvent && !result.isCapAreaDescription)
45
+ if (isSkippable) { return; }
46
+ await createEvent(result);
47
+ await importStanza(result);
48
+ }
49
+ if (stanza.is(`presence`) && msgFrom.startsWith('nwws@conference.nwws-oi.weather.gov/')) {
50
+ const getOccupant = msgFrom.split(`/`).slice(1).join(`/`)
51
+ const getAvailability = msgType === `unavailable`
52
+ setEventEmit({
53
+ event: `onXMPPStatus`,
54
+ metadata: {
55
+ message: `Occupant ${getOccupant} has ${getAvailability ? `left` : `joined`} the room`,
56
+ data: {},
57
+ type: `occupant`,
58
+ error: false
59
+ },
60
+ })
61
+ }
62
+ })
63
+ }
@@ -0,0 +1,40 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & 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 { TypeHVTEC } from "../../@types/types.hvtec";
21
+ import { eventCauses } from "../../@dictionaries/dictionaries.eventCauses";
22
+ import { eventRecords } from "../../@dictionaries/dictionaries.eventRecords";
23
+ import { regExp } from "../../@dictionaries/dictionaries.regExp";
24
+ import { eventSeverity } from "../../@dictionaries/dictionaries.eventSeverity";
25
+
26
+ export const hvExtract = (message: string): TypeHVTEC[] | null => {
27
+ const getHVTECs = message.match(regExp.hvtec) ?? [];
28
+ const vtecs: TypeHVTEC[] = [];
29
+ for (const vtec of getHVTECs) {
30
+ const sub = vtec.split(`.`);
31
+ if (sub.length < 7) continue;
32
+ vtecs.push({
33
+ hvtec: vtec,
34
+ severity: eventSeverity[sub[1]],
35
+ cause: eventCauses[sub[2]],
36
+ record: eventRecords[sub[6]]
37
+ })
38
+ }
39
+ return vtecs.length > 0 ? vtecs : null;
40
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & 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 getExpiry = (dates: string[]): string => {
21
+ if (dates?.[1] == `000000T0000Z`) return 'Invalid Date Format'
22
+ const expires = `${new Date().getFullYear().toString().substring(0, 2)}${dates[1].substring(0, 2)}-${dates[1].substring(2, 4)}-${dates[1].substring(4, 6)}T${dates[1].substring(7, 9)}:${dates[1].substring(9, 11)}:00`;
23
+ const local = new Date(new Date(expires).getTime() - 4 * 60 * 60000);
24
+ const pad = (n: number) => n.toString().padStart(2, '0');
25
+ return `${local.getFullYear()}-${pad(local.getMonth() + 1)}-${pad(local.getDate())}T${pad(local.getHours())}:${pad(local.getMinutes())}:00.000-04:00`;
26
+ }
@@ -0,0 +1,50 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Internal Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypePVTEC } from "../../@types/types.pvtec";
21
+ import { regExp } from "../../@dictionaries/dictionaries.regExp";
22
+ import { eventProducts } from "../../@dictionaries/dictionaries.eventProducts";
23
+ import { eventTypes } from "../../@dictionaries/dictionaries.eventTypes";
24
+ import { eventActions } from "../../@dictionaries/dictionaries.eventActions";
25
+ import { eventStatus } from "../../@dictionaries/dictionaries.eventStatus";
26
+ import { getExpiry } from "./pvtec.expires";
27
+
28
+ export const pvExtract = (message: string): TypePVTEC[] | null => {
29
+ const getVTECs = message.match(regExp.pvtec) ?? [];
30
+ const vtecs: TypePVTEC[] = [];
31
+ for (const vtec of getVTECs) {
32
+ const sub = vtec.split(`.`);
33
+ if (sub?.length < 7) continue;
34
+ const dates = sub[6]?.split(`-`);
35
+ vtecs.push({
36
+ vtec: vtec,
37
+ product: eventProducts[sub[0]],
38
+ tracking: `${sub[2]}-${sub[3]}-${sub[4]}-${sub[5]}`,
39
+ event: `${eventTypes[sub[3]]} ${eventActions[sub[4]]}`,
40
+ status: eventStatus[sub[1]],
41
+ organization: message.match(regExp.wmo)?.[0] ?? null,
42
+ expires: getExpiry(dates),
43
+ prediction_center:
44
+ (sub[4] == `A` || sub[4] == `Y`) &&
45
+ (sub[3] == `TO` || sub[3] == `SV`)
46
+ ? true : false
47
+ })
48
+ }
49
+ return vtecs.length > 0 ? vtecs : null;
50
+ }