@atmosx/event-product-parser 3.0.61 → 3.0.63

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 (118) hide show
  1. package/.github/docs/docs-functions.md +1 -1
  2. package/.github/docs/docs-general-configurations.md +1 -1
  3. package/.github/docs/docs-integrations.md +1 -1
  4. package/.github/docs/docs-listeners.md +1 -1
  5. package/.github/docs/docs-source-configuration.md +1 -1
  6. package/.github/docs/docs-technical.md +1 -1
  7. package/README.md +7 -5
  8. package/dist/cjs/index.cjs +21216 -6908
  9. package/dist/esm/index.mjs +21207 -6900
  10. package/package.json +49 -47
  11. package/pnpm-workspace.yaml +4 -0
  12. package/src/@building/CreateEvent.ts +20 -22
  13. package/src/@building/GetEventAttachments.ts +8 -8
  14. package/src/@building/GetEventEnhancedName.ts +2 -4
  15. package/src/@building/GetEventGeometry.ts +5 -5
  16. package/src/@building/GetEventHeader.ts +11 -11
  17. package/src/@building/GetEventNodes.ts +12 -12
  18. package/src/@building/GetEventOffice.ts +11 -11
  19. package/src/@building/GetEventProperties.ts +60 -55
  20. package/src/@building/GetEventSignature.ts +7 -7
  21. package/src/@building/GetEventTags.ts +1 -1
  22. package/src/@building/GetEventTracking.ts +28 -32
  23. package/src/@core/ClearEvents.ts +7 -7
  24. package/src/@core/CreateListener.ts +2 -2
  25. package/src/@core/GetEvents.ts +2 -2
  26. package/src/@core/GetNodes.ts +2 -2
  27. package/src/@core/GetRandomEvent.ts +2 -2
  28. package/src/@core/GetVersion.ts +2 -2
  29. package/src/@core/ManualEvent.ts +20 -21
  30. package/src/@core/QueryStanza.ts +7 -7
  31. package/src/@core/SetNode.ts +32 -26
  32. package/src/@core/StartService.ts +18 -18
  33. package/src/@core/StopService.ts +8 -8
  34. package/src/@enums/Expressions.ts +1 -1
  35. package/src/@enums/Tags.ts +1 -1
  36. package/src/@events/ParseAPI.ts +44 -39
  37. package/src/@events/ParseText.ts +19 -19
  38. package/src/@events/ParseUGC.ts +21 -21
  39. package/src/@events/ParseVTEC.ts +32 -33
  40. package/src/@manager/MakeEvents.ts +33 -30
  41. package/src/@manager/RemoveEvent.ts +38 -34
  42. package/src/@manager/SetHash.ts +16 -11
  43. package/src/@manager/UpdateEvents.ts +10 -10
  44. package/src/@manager/UpdateNode.ts +13 -13
  45. package/src/@manager/ValidateEvents.ts +36 -37
  46. package/src/@modules/@database/GetCachedEvents.ts +10 -12
  47. package/src/@modules/@database/ImportBroadcastify.ts +12 -13
  48. package/src/@modules/@database/ImportShapefiles.ts +17 -18
  49. package/src/@modules/@database/ImportStanza.ts +11 -11
  50. package/src/@modules/@database/InitializeDatabase.ts +16 -16
  51. package/src/@modules/@eas/GenerateEASMessage.ts +53 -47
  52. package/src/@modules/@eas/GetPCM16.ts +11 -6
  53. package/src/@modules/@eas/GetSampledPCM16.ts +12 -6
  54. package/src/@modules/@eas/GetTTS.ts +12 -7
  55. package/src/@modules/@eas/GetWavPCM16.ts +5 -5
  56. package/src/@modules/@eas/SetAFSK.ts +11 -6
  57. package/src/@modules/@eas/SetAttentionTone.ts +9 -4
  58. package/src/@modules/@eas/SetNoise.ts +10 -5
  59. package/src/@modules/@eas/SetRadioEffect.ts +10 -5
  60. package/src/@modules/@eas/SetSameHeader.ts +20 -12
  61. package/src/@modules/@stanza/GetAwipsType.ts +14 -15
  62. package/src/@modules/@stanza/ValidateStanza.ts +25 -13
  63. package/src/@modules/@utilities/CreateHttp.ts +24 -24
  64. package/src/@modules/@utilities/GetMatched.ts +8 -3
  65. package/src/@modules/@utilities/GetSettings.ts +3 -3
  66. package/src/@modules/@utilities/GetShapeNearestPoint.ts +22 -17
  67. package/src/@modules/@utilities/QueueManager.ts +70 -0
  68. package/src/@modules/@utilities/SetCronSchedule.ts +20 -20
  69. package/src/@modules/@utilities/SetDebug.ts +10 -10
  70. package/src/@modules/@utilities/SetEventEmit.ts +15 -15
  71. package/src/@modules/@utilities/SetListener.ts +6 -6
  72. package/src/@modules/@utilities/SetSettings.ts +5 -5
  73. package/src/@modules/@utilities/SetSleep.ts +3 -3
  74. package/src/@modules/@utilities/SetTimeoutAction.ts +25 -25
  75. package/src/@modules/@utilities/SetWarning.ts +8 -8
  76. package/src/@modules/@xmpp/DeployXMPP.ts +16 -16
  77. package/src/@modules/@xmpp/ErrorXMPP.ts +4 -4
  78. package/src/@modules/@xmpp/OfflineXMPP.ts +11 -11
  79. package/src/@modules/@xmpp/OnlineXMPP.ts +16 -16
  80. package/src/@modules/@xmpp/ReconnectXMPP.ts +27 -27
  81. package/src/@modules/@xmpp/StanzaXMPP.ts +23 -23
  82. package/src/@parsers/@hvtec/HVExtract.ts +9 -9
  83. package/src/@parsers/@text/GetDescriptionFromProduct.ts +18 -19
  84. package/src/@parsers/@text/GetEmbededText.ts +3 -3
  85. package/src/@parsers/@text/GetStringText.ts +6 -6
  86. package/src/@parsers/@text/GetTextFromProduct.ts +10 -10
  87. package/src/@parsers/@text/GetXML.ts +5 -5
  88. package/src/@parsers/@ugc/GetCache.ts +2 -2
  89. package/src/@parsers/@ugc/{GetUGCHeader.ts → GetHeader.ts} +2 -2
  90. package/src/@parsers/@ugc/GetLocations.ts +5 -5
  91. package/src/@parsers/@ugc/GetZonePolygon.ts +10 -10
  92. package/src/@parsers/@ugc/GetZones.ts +1 -1
  93. package/src/@parsers/@ugc/SetCache.ts +11 -6
  94. package/src/@parsers/@ugc/UGCExtract.ts +10 -10
  95. package/src/@parsers/{@pvtec → @vtec}/VTECExtract.ts +19 -19
  96. package/src/@tasks/CreateTasks.ts +110 -0
  97. package/src/@tasks/TaskGenerateAudio.ts +34 -0
  98. package/src/@tasks/TaskGenerateJSON.ts +34 -0
  99. package/src/@tasks/TaskGenerateText.ts +34 -0
  100. package/src/@tasks/TaskSendNTFY.ts +91 -0
  101. package/src/@tasks/TaskSendWebhook.ts +100 -0
  102. package/src/@types/HVTEC.ts +4 -4
  103. package/src/@types/Hash.ts +3 -3
  104. package/src/@types/Settings.ts +1 -1
  105. package/src/@types/StanzaCompiled.ts +13 -13
  106. package/src/@types/UGC.ts +3 -3
  107. package/src/@types/VTEC.ts +10 -10
  108. package/src/{@types → @types-lower}/Event.ts +4 -4
  109. package/src/{@types → @types-lower}/Properties.ts +2 -1
  110. package/src/{@types → @types-lower}/Stanza.ts +1 -1
  111. package/src/bootstrap.ts +26 -26
  112. package/src/index.ts +30 -27
  113. package/tools/build.js +45 -0
  114. package/tsconfig.json +21 -1
  115. package/src/@manager/Tasks.ts +0 -246
  116. package/tsup.config.ts +0 -16
  117. /package/src/@parsers/{@pvtec → @vtec}/GetExpiry.ts +0 -0
  118. /package/src/{@types → @types-lower}/Attributes.ts +0 -0
@@ -18,17 +18,17 @@
18
18
 
19
19
  */
20
20
 
21
- import { TypeSettings } from "../../@types/Settings";
22
- import { ReconnectXMPP } from "../@xmpp/ReconnectXMPP"
23
- import { bootstrap } from "../../bootstrap";
24
- import { CreateHttp } from "./CreateHttp";
25
- import { CreateEvent } from "../../@building/CreateEvent";
26
- import { SetEventEmit } from "./SetEventEmit";
27
- import { readdirSync, unlinkSync, statSync, existsSync } from "fs";
28
- import { join } from "path";
21
+ import { TypeSettings } from "types/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 { CreateEvent } from "@building/CreateEvent"
27
+ import { readdirSync, unlinkSync, statSync, existsSync } from "fs"
28
+ import { join } from "path"
29
29
 
30
30
  export const SetCronSchedule = async (): Promise<void> => {
31
- const settings = bootstrap.settings as TypeSettings;
31
+ const settings = Bootstrap.Settings as TypeSettings;
32
32
 
33
33
  const TTL = settings.GlobalSettings.ArchiveSettings.TTL
34
34
  const TTLCUT = Date.now() - TTL * 1000;
@@ -62,15 +62,15 @@ export const SetCronSchedule = async (): Promise<void> => {
62
62
  }
63
63
  } else {
64
64
  const response = await CreateHttp({
65
- url: settings.NationalWeatherServiceSettings.EventsEndpoint,
66
- headers: {
65
+ URL: settings.NationalWeatherServiceSettings.EventsEndpoint,
66
+ Headers: {
67
67
  "User-Agent": "@atmosx/event-product-parser"
68
68
  }
69
69
  })
70
70
  if (response.error) {
71
71
  return SetEventEmit({
72
- event: `onServiceStatus`,
73
- metadata: {
72
+ Event: `onServiceStatus`,
73
+ Metadata: {
74
74
  type: "fetch-api",
75
75
  message: `Failed to fetch latest events from National Weather Service API - ${response.message}`,
76
76
  data: {},
@@ -79,15 +79,15 @@ export const SetCronSchedule = async (): Promise<void> => {
79
79
  })
80
80
  }
81
81
  SetEventEmit({
82
- event: `onServiceStatus`,
83
- metadata: {
84
- message: `Fetched latest events from National Weather Service API`,
85
- data: {},
86
- type: "fetch-api",
87
- error: false
82
+ Event: `onServiceStatus`,
83
+ Metadata: {
84
+ Message: `Fetched latest events from National Weather Service API`,
85
+ Data: {},
86
+ Type: "fetch-api",
87
+ Error: false
88
88
  },
89
89
  })
90
- await CreateEvent({ message: response.message, isNWWS: false })
90
+ await CreateEvent({ Message: response.message, NWWS: false })
91
91
  }
92
92
  }
93
93
 
@@ -17,21 +17,21 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from "../../@types/Settings";
21
- import { bootstrap } from "../../bootstrap"
20
+ import { TypeSettings } from "types/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
34
  if (settings.EnableDebugging) {
35
- console.log(`[${bootstrap.ansi_colors.BLUE}${options.title ?? `debug`}${bootstrap.ansi_colors.RESET}] ${options.message}`)
35
+ console.log(`[${Bootstrap.Colors.Blue}${Title ?? `debug`}${Bootstrap.Colors.Reset}] ${Message}`)
36
36
  }
37
37
  }
@@ -17,25 +17,25 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
21
- import { SetTimeoutAction } from "./SetTimeoutAction";
22
- import { SetWarning } from "./SetWarning";
20
+ import { Bootstrap } from "@bootstrap"
21
+ import { SetTimeoutAction } from "@utilities/SetTimeoutAction"
22
+ import { SetWarning } from "@utilities/SetWarning"
23
23
 
24
24
  interface SetEventEmitOptions {
25
- event: string
26
- metadata: any
27
- message?: string
28
- limited?: boolean
25
+ Event: string
26
+ Metadata: any
27
+ Message?: string
28
+ Limited?: boolean
29
29
  }
30
30
 
31
- export const SetEventEmit = (options: SetEventEmitOptions): void => {
32
- if (options.limited) {
33
- const isTimeout = SetTimeoutAction({ identifier: `event.${options.event}`, addTime: true, max: 1, interval: 1 })
34
- if (isTimeout.limited) return;
31
+ export const SetEventEmit = ({ Event, Metadata, Message, Limited }: SetEventEmitOptions): void => {
32
+ if (Limited) {
33
+ const isTimeout = SetTimeoutAction({ Identifier: `event.${Event}`, AddTime: true, Max: 1, Interval: 1 })
34
+ if (isTimeout.Limited) return;
35
35
  }
36
- bootstrap.listener.emit(options.event, options.metadata)
37
- if (options.event != `log`) { bootstrap.listener.emit(`*`, {event: options.event, data: options.metadata}) }
38
- if (options.message) {
39
- SetWarning({ message: options.message })
36
+ Bootstrap.Listener.emit(Event, Metadata)
37
+ if (Event != `log`) { Bootstrap.Listener.emit(`*`, {event: Event, data: Metadata}) }
38
+ if (Message) {
39
+ SetWarning({ Message: Message })
40
40
  }
41
41
  }
@@ -17,14 +17,14 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
20
+ import { Bootstrap } from "@bootstrap"
21
21
 
22
22
  interface SetListenerOptions {
23
- event: string,
24
- callback: () => void
23
+ Event: string,
24
+ Callback: () => void
25
25
  }
26
26
 
27
- export const SetListener = (options: SetListenerOptions): (() => void) => {
28
- bootstrap.listener.on(options.event, options.callback)
29
- return () => { void bootstrap.listener.off(options.event, options.callback) };
27
+ export const SetListener = ({ Event, Callback }: SetListenerOptions): (() => void) => {
28
+ Bootstrap.Listener.on(Event, Callback)
29
+ return () => { void Bootstrap.Listener.off(Event, Callback) };
30
30
  }
@@ -17,11 +17,11 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from '../../@types/Settings'
21
- import { bootstrap } from "../../bootstrap"
20
+ import { TypeSettings } from "types/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
  }
@@ -19,14 +19,14 @@
19
19
  */
20
20
 
21
21
  interface SetSleepOptions {
22
- timeout: number
22
+ Timeout: number
23
23
  }
24
24
 
25
- export const SetSleep = async (options: SetSleepOptions): Promise<void> => {
25
+ export const SetSleep = async ({ Timeout }: SetSleepOptions): Promise<void> => {
26
26
  return new Promise((resolve) => {
27
27
  setTimeout(() => {
28
28
  resolve();
29
- }, options.timeout);
29
+ }, Timeout);
30
30
  });
31
31
  }
32
32
 
@@ -17,48 +17,48 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
20
+ import { Bootstrap } from "@bootstrap"
21
21
 
22
22
  interface SetTimeoutActionOptions {
23
- identifier: string
24
- addTime?: boolean
25
- max?: number
26
- interval?: number
27
- expire?: boolean
23
+ Identifier: string
24
+ AddTime?: boolean
25
+ Max?: number
26
+ Interval?: number
27
+ Expire?: boolean
28
28
  }
29
29
 
30
30
  type SetTimeoutActionResponse = {
31
- limited: boolean
32
- remaining?: number
33
- response?: string
31
+ Limited: boolean
32
+ Remaining?: number
33
+ Response?: string
34
34
  }
35
35
 
36
- export const SetTimeoutAction = (options: SetTimeoutActionOptions): SetTimeoutActionResponse => {
37
- let target = bootstrap?.ratelimits?.[options?.identifier];
36
+ export const SetTimeoutAction = ({ Identifier, AddTime, Max, Interval, Expire }: SetTimeoutActionOptions): SetTimeoutActionResponse => {
37
+ let target = Bootstrap?.Ratelimits?.[Identifier];
38
38
  if (!target) {
39
- bootstrap.ratelimits[options?.identifier] = [];
40
- target = bootstrap.ratelimits[options?.identifier];
39
+ Bootstrap.Ratelimits[Identifier] = [];
40
+ target = Bootstrap.Ratelimits[Identifier];
41
41
  }
42
- if (options?.expire) {
43
- delete bootstrap.ratelimits[options?.identifier];
44
- return { limited: false };
42
+ if (Expire) {
43
+ delete Bootstrap.Ratelimits[Identifier];
44
+ return { Limited: false };
45
45
  }
46
46
  if (target?.length > 0) {
47
- bootstrap.ratelimits[options?.identifier] = target.filter((ts: number) => Date.now() - ts < options?.interval * 1000);
48
- target = bootstrap.ratelimits[options?.identifier];
47
+ Bootstrap.Ratelimits[Identifier] = target.filter((ts: number) => Date.now() - ts < Interval * 1000);
48
+ target = Bootstrap.Ratelimits[Identifier];
49
49
  }
50
50
 
51
51
  const oldestTimestamp = target?.[0];
52
- const getWait = oldestTimestamp ? Math.ceil((options?.interval * 1000) - (Date.now() - oldestTimestamp)) : 0;
53
- const max = options?.max ?? 1;
52
+ const getWait = oldestTimestamp ? Math.ceil((Interval * 1000) - (Date.now() - oldestTimestamp)) : 0;
53
+ const max = Max ?? 1;
54
54
 
55
55
  if (target?.length >= max && getWait > 0) {
56
56
  return {
57
- limited: true,
58
- remaining: getWait,
59
- response: `You are being rate limited, please wait ${(getWait / 1e3).toFixed(1)} second(s) before performing this action again.`
57
+ Limited: true,
58
+ Remaining: getWait,
59
+ Response: `You are being rate limited, please wait ${(getWait / 1e3).toFixed(1)} second(s) before performing this action again.`
60
60
  }
61
61
  }
62
- bootstrap.ratelimits[options?.identifier].push(Date.now());
63
- return { limited: false };
62
+ Bootstrap.Ratelimits[Identifier].push(Date.now());
63
+ return { Limited: false };
64
64
  }
@@ -17,18 +17,18 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
21
- import { TypeSettings } from "../../@types/Settings";
20
+ import { Bootstrap } from "@bootstrap"
21
+ import { TypeSettings } from "types/Settings"
22
22
 
23
23
  interface SetWarningOptions {
24
- title?: string
25
- message: string
24
+ Title?: string
25
+ Message: string
26
26
  }
27
27
 
28
- export const SetWarning = (options: SetWarningOptions): void => {
29
- const settings = bootstrap.settings as TypeSettings;
30
- bootstrap.listener.emit(`log`, `${options.title ?? `[${bootstrap.ansi_colors.YELLOW}@atmosx/product-parser${bootstrap.ansi_colors.RESET}]`} ${options.message}`)
28
+ export const SetWarning = ({ Title, Message }: SetWarningOptions): void => {
29
+ const settings = Bootstrap.Settings as TypeSettings;
30
+ Bootstrap.Listener.emit(`log`, `${Title ?? `[${Bootstrap.Colors.Yellow}@atmosx/product-parser${Bootstrap.Colors.Reset}]`} ${Message}`)
31
31
  if (settings.EnableJournal) {
32
- console.log(`${options.title ?? `[${bootstrap.ansi_colors.YELLOW}@atmosx/product-parser${bootstrap.ansi_colors.RESET}]`} ${options.message}`)
32
+ console.log(`${Title ?? `[${Bootstrap.Colors.Yellow}@atmosx/product-parser${Bootstrap.Colors.Reset}]`} ${Message}`)
33
33
  }
34
34
  }
@@ -17,21 +17,21 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from "../../@types/Settings";
21
- import { bootstrap } from "../../bootstrap"
22
- import { OnlineXMPP } from "./OnlineXMPP";
23
- import { OfflineXMPP } from "./OfflineXMPP";
24
- import { ErrorXMPP } from "./ErrorXMPP";
25
- import { StanzaXMPP } from "./StanzaXMPP";
26
- import { SetEventEmit } from '../@utilities/SetEventEmit';
27
- import { client } from '@xmpp/client';
20
+ import { TypeSettings } from "types/Settings"
21
+ import { Bootstrap } from "@bootstrap"
22
+ import { OnlineXMPP } from "@xmpp/OnlineXMPP"
23
+ import { OfflineXMPP } from "@xmpp/OfflineXMPP"
24
+ import { ErrorXMPP } from "@xmpp/ErrorXMPP"
25
+ import { StanzaXMPP } from "@xmpp/StanzaXMPP"
26
+ import { SetEventEmit } from "@utilities/SetEventEmit"
27
+ import { client } from "@xmpp/client"
28
28
 
29
29
  export const DeployXMPP = async (): Promise<void> => {
30
30
  let session;
31
- const settings = bootstrap.settings as TypeSettings
31
+ const settings = Bootstrap.Settings as TypeSettings
32
32
  settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
33
33
  ??= settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username;
34
- session = bootstrap.session_xmpp = client({
34
+ session = Bootstrap.Session = client({
35
35
  service: 'xmpp://nwws-oi.weather.gov',
36
36
  domain: 'nwws-oi.weather.gov',
37
37
  username: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Username,
@@ -45,12 +45,12 @@ export const DeployXMPP = async (): Promise<void> => {
45
45
  await session.start()
46
46
  } catch (error) {
47
47
  SetEventEmit({
48
- event: `onServiceStatus`,
49
- metadata: {
50
- message: `Error occured while starting XMPP Session: ${error}`,
51
- data: {},
52
- type: `error`,
53
- error: true
48
+ Event: `onServiceStatus`,
49
+ Metadata: {
50
+ Message: `Error occured while starting XMPP Session: ${error}`,
51
+ Data: {},
52
+ Type: `error`,
53
+ Error: true
54
54
  },
55
55
  })
56
56
  }
@@ -17,11 +17,11 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
20
+ import { Bootstrap } from "@bootstrap"
21
21
 
22
22
  export const ErrorXMPP = () => {
23
- bootstrap.session_xmpp.on(`error`, async (error: Error) => {
24
- bootstrap.cache.isConnected = false;
25
- bootstrap.cache.sigHault = true;
23
+ Bootstrap.Session.on(`error`, async () => {
24
+ Bootstrap.Cache.Connected = false;
25
+ Bootstrap.Cache.Hault = true;
26
26
  })
27
27
  }
@@ -17,20 +17,20 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
21
- import { SetEventEmit } from "../@utilities/SetEventEmit";
20
+ import { Bootstrap } from "@bootstrap"
21
+ import { SetEventEmit } from "@utilities/SetEventEmit"
22
22
 
23
23
  export const OfflineXMPP = () => {
24
- bootstrap.session_xmpp.on(`offline`, async () => {
25
- bootstrap.cache.isConnected = false;
26
- bootstrap.cache.sigHault = true;
24
+ Bootstrap.Session.on(`offline`, async () => {
25
+ Bootstrap.Cache.Connected = false;
26
+ Bootstrap.Cache.Hault = true;
27
27
  SetEventEmit({
28
- event: `onServiceStatus`,
29
- metadata: {
30
- message: `Client has gone offline`,
31
- data: {},
32
- type: `offline`,
33
- error: true
28
+ Event: `onServiceStatus`,
29
+ Metadata: {
30
+ Message: `Client has gone offline`,
31
+ Data: {},
32
+ Type: `offline`,
33
+ Error: true
34
34
  },
35
35
  })
36
36
  })
@@ -17,30 +17,30 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
21
- import { SetEventEmit } from '../@utilities/SetEventEmit';
22
- import { xml } from '@xmpp/client'
20
+ import { Bootstrap } from "@bootstrap"
21
+ import { SetEventEmit } from "@utilities/SetEventEmit"
22
+ import { xml } from "@xmpp/client"
23
23
 
24
24
  export const OnlineXMPP = () => {
25
- const settings = bootstrap.settings;
26
- bootstrap.session_xmpp.on(`online`, async (address: string) => {
27
- bootstrap.cache.sigHault = false;
28
- bootstrap.cache.isConnected = true;
29
- bootstrap.cache.tReconnects = 0;
25
+ const settings = Bootstrap.Settings;
26
+ Bootstrap.Session.on(`online`, async () => {
27
+ Bootstrap.Cache.Hault = false;
28
+ Bootstrap.Cache.Connected = true;
29
+ Bootstrap.Cache.TotalReconnects = 0;
30
30
  const nickname = settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname;
31
- bootstrap.session_xmpp.send(xml('presence', {
31
+ Bootstrap.Session.send(xml('presence', {
32
32
  to: `nwws@conference.nwws-oi.weather.gov/${nickname}`,
33
33
  xmlns: 'http://jabber.org/protocol/muc',
34
34
  }))
35
35
  SetEventEmit({
36
- event: `onServiceStatus`,
37
- metadata: {
38
- message: `Succesfully connected to NOAA Weather Wire Service as "${nickname}"`,
39
- data: {},
40
- type: `online`,
41
- error: false
36
+ Event: `onServiceStatus`,
37
+ Metadata: {
38
+ Message: `Succesfully connected to NOAA Weather Wire Service as "${nickname}"`,
39
+ Data: {},
40
+ Type: `online`,
41
+ Error: false
42
42
  },
43
- message: `Succesfully connected to NOAA Weather Wire Service as "${nickname}"`,
43
+ Message: `Succesfully connected to NOAA Weather Wire Service as "${nickname}"`,
44
44
  })
45
45
  })
46
46
  }
@@ -17,47 +17,47 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from "../../@types/Settings";
21
- import { bootstrap } from "../../bootstrap"
22
- import { SetEventEmit } from "../@utilities/SetEventEmit";
23
- import { SetWarning } from "../@utilities/SetWarning";
20
+ import { TypeSettings } from "types/Settings"
21
+ import { Bootstrap } from "@bootstrap"
22
+ import { SetEventEmit } from "@utilities/SetEventEmit"
23
+ import { SetWarning } from "@utilities/SetWarning"
24
24
 
25
25
  export const ReconnectXMPP = async (interval: number): Promise<void> => {
26
- const settings = bootstrap.settings as TypeSettings;
27
- const lastStanza = Date.now() - bootstrap.cache.lastStanza
26
+ const settings = Bootstrap.Settings as TypeSettings;
27
+ const last = Date.now() - Bootstrap.Cache.LastStanzaTime
28
28
  if (interval < 15) {
29
- SetWarning({ message: `Reconnection interval of ${interval} seconds is too low, setting to 15 seconds` })
29
+ SetWarning({ Message: `Reconnection interval of ${interval} seconds is too low, setting to 15 seconds` })
30
30
  interval = 15;
31
- bootstrap.settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval = 15;
31
+ Bootstrap.Settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval = 15;
32
32
  }
33
33
  const reconnectThreshold = interval * 1e3
34
- if ((!bootstrap.cache.isConnected && !bootstrap.cache.sigHault) || !bootstrap.session_xmpp) {
34
+ if ((!Bootstrap.Cache.Connected && !Bootstrap.Cache.Hault) || !Bootstrap.Session) {
35
35
  return;
36
36
  }
37
- if (lastStanza > reconnectThreshold) {
38
- if (!bootstrap.cache.isReconnecting) {
39
- bootstrap.cache.isReconnecting = true;
40
- bootstrap.cache.isConnected = false;
41
- bootstrap.cache.tReconnects += 1;
37
+ if (last > reconnectThreshold) {
38
+ if (!Bootstrap.Cache.Reconnecting) {
39
+ Bootstrap.Cache.Reconnecting = true;
40
+ Bootstrap.Cache.Connected = false;
41
+ Bootstrap.Cache.TotalReconnects += 1;
42
42
  try {
43
43
  SetEventEmit({
44
- event: `onServiceStatus`,
45
- metadata: {
46
- message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
47
- data: {
48
- last_stanza: lastStanza,
49
- nickname: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
44
+ Event: `onServiceStatus`,
45
+ Metadata: {
46
+ Message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${Bootstrap.Cache.TotalReconnects})`,
47
+ Data: {
48
+ Last: last,
49
+ Nickname: settings.NOAAWeatherWireServiceSettings.CredentialSettings.Nickname
50
50
  },
51
- type: `reconnect`,
52
- error: true
53
- }, message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
51
+ Type: `reconnect`,
52
+ Error: true
53
+ }, Message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${Bootstrap.Cache.TotalReconnects})`,
54
54
  })
55
- await bootstrap.session_xmpp.stop().catch(() => {});
56
- await bootstrap.session_xmpp.start().catch(() => {});
55
+ await Bootstrap.Session.stop().catch(() => {});
56
+ await Bootstrap.Session.start().catch(() => {});
57
57
  } catch (error) {
58
- SetWarning({ message: `XMPP Reconnect Failed - ${(error as Error).message}` })
58
+ SetWarning({ Message: `XMPP Reconnect Failed - ${(error as Error).message}` })
59
59
  } finally {
60
- bootstrap.cache.isReconnecting = false;
60
+ Bootstrap.Cache.Reconnecting = false;
61
61
  }
62
62
  }
63
63
  }
@@ -17,31 +17,31 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeStanza } from "../../@types/Stanza";
21
- import { bootstrap } from "../../bootstrap";
22
- import { ValidateStanza } from "../@stanza/ValidateStanza";
23
- import { CreateEvent } from "../../@building/CreateEvent";
24
- import { ImportStanza } from "../@database/ImportStanza";
25
- import { SetEventEmit } from "../@utilities/SetEventEmit";
20
+ import { TypeStanza } from "types-lower/Stanza"
21
+ import { Bootstrap } from "@bootstrap"
22
+ import { ValidateStanza } from "@stanza/ValidateStanza"
23
+ import { CreateEvent } from "@building/CreateEvent"
24
+ import { ImportStanza } from "@database/ImportStanza"
25
+ import { SetEventEmit } from "@utilities/SetEventEmit"
26
26
 
27
27
  export const StanzaXMPP = () => {
28
- bootstrap.session_xmpp.on(`stanza`, async (stanza: TypeStanza) => {
28
+ Bootstrap.Session.on(`stanza`, async (stanza: TypeStanza) => {
29
29
  const msgFrom = stanza?.attrs?.from ?? ``
30
30
  const msgType = stanza?.attrs?.type ?? ``
31
31
  SetEventEmit({
32
- event: `onServiceStatus`,
33
- metadata: {
34
- message: stanza,
35
- from: msgFrom,
36
- type: `stanza`
32
+ Event: `onServiceStatus`,
33
+ Metadata: {
34
+ Message: stanza,
35
+ From: msgFrom,
36
+ Type: `stanza`
37
37
  },
38
38
  })
39
- bootstrap.cache.lastStanza = Date.now();
39
+ Bootstrap.Cache.LastStanzaTime = Date.now();
40
40
  if (stanza.is(`message`)) {
41
- const result = ValidateStanza({ stanza });
42
- const isSkippable = result.isIgnored ||
43
- (result.isCapEvent) ||
44
- (result.isCapEvent && !result.isCapAreaDescription)
41
+ const result = ValidateStanza({ Stanza: stanza });
42
+ const isSkippable = result.Ignored ||
43
+ (result.CapEvent) ||
44
+ (result.CapEvent && !result.CapAreaDescription)
45
45
  if (isSkippable) { return; }
46
46
  await CreateEvent(result);
47
47
  await ImportStanza(result);
@@ -50,12 +50,12 @@ export const StanzaXMPP = () => {
50
50
  const getOccupant = msgFrom.split(`/`).slice(1).join(`/`)
51
51
  const getAvailability = msgType === `unavailable`
52
52
  SetEventEmit({
53
- event: `onServiceStatus`,
54
- metadata: {
55
- message: `Occupant ${getOccupant} has ${getAvailability ? `left` : `joined`} the room`,
56
- data: {},
57
- type: `occupant`,
58
- error: false
53
+ Event: `onServiceStatus`,
54
+ Metadata: {
55
+ Message: `Occupant ${getOccupant} has ${getAvailability ? `left` : `joined`} the room`,
56
+ Data: {},
57
+ Type: `occupant`,
58
+ Error: false
59
59
  },
60
60
  })
61
61
  }
@@ -17,11 +17,11 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeHVTEC } from "../../@types/HVTEC";
21
- import { EnumCauses } from "../../@enums/Causes";
22
- import { EnumRecords } from "../../@enums/Records";
23
- import { EnumExpressions } from "../../@enums/Expressions";
24
- import { EnumSeverity } from "../../@enums/Severity";
20
+ import { TypeHVTEC } from "types/HVTEC"
21
+ import { EnumCauses } from "@enums/Causes"
22
+ import { EnumRecords } from "@enums/Records"
23
+ import { EnumExpressions } from "@enums/Expressions"
24
+ import { EnumSeverity } from "@enums/Severity"
25
25
 
26
26
  export const HVExtract = (message: string): TypeHVTEC[] | null => {
27
27
  const getHVTECs = message.match(EnumExpressions.hvtec) ?? [];
@@ -30,10 +30,10 @@ export const HVExtract = (message: string): TypeHVTEC[] | null => {
30
30
  const sub = vtec.split(`.`);
31
31
  if (sub.length < 7) continue;
32
32
  vtecs.push({
33
- hvtec: vtec,
34
- severity: EnumSeverity[sub[1]],
35
- cause: EnumCauses[sub[2]],
36
- record: EnumRecords[sub[6]]
33
+ HVTEC: vtec,
34
+ Severity: EnumSeverity[sub[1]],
35
+ Cause: EnumCauses[sub[2]],
36
+ Record: EnumRecords[sub[6]]
37
37
  })
38
38
  }
39
39
  return vtecs.length > 0 ? vtecs : null;