@atmosx/event-product-parser 3.0.62 → 3.0.75

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 (179) hide show
  1. package/.github/docs/docs-functions.md +1 -1
  2. package/.github/docs/docs-general-configurations.md +1 -11
  3. package/.github/docs/docs-integrations.md +3 -2
  4. package/README.md +10 -8
  5. package/dist/cjs/index.cjs +24482 -7207
  6. package/dist/esm/index.mjs +24275 -7003
  7. package/package.json +56 -47
  8. package/pnpm-workspace.yaml +4 -0
  9. package/src/bootstrap.ts +65 -48
  10. package/src/{@building → building}/CreateEvent.ts +22 -24
  11. package/src/{@building → building}/GetCleanedEvent.ts +2 -2
  12. package/src/{@building → building}/GetEventAttachments.ts +14 -12
  13. package/src/building/GetEventDirection.ts +28 -0
  14. package/src/{@building → building}/GetEventEnhancedName.ts +5 -8
  15. package/src/{@building → building}/GetEventGeometry.ts +19 -13
  16. package/src/{@building → building}/GetEventHeader.ts +13 -13
  17. package/src/{@building → building}/GetEventNodes.ts +22 -20
  18. package/src/{@building → building}/GetEventOffice.ts +13 -13
  19. package/src/building/GetEventPopulation.ts +58 -0
  20. package/src/building/GetEventProperties.ts +106 -0
  21. package/src/{@building → building}/GetEventSignature.ts +9 -9
  22. package/src/{@building → building}/GetEventTags.ts +3 -3
  23. package/src/building/GetEventTheme.ts +26 -0
  24. package/src/building/GetEventTracking.ts +64 -0
  25. package/src/components/audio/GenerateAudioMessage.ts +149 -0
  26. package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
  27. package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
  28. package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
  29. package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
  30. package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
  31. package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
  32. package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
  33. package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
  34. package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
  35. package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
  36. package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
  37. package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
  38. package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
  39. package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
  40. package/src/{@modules/@utilities/SetWarning.ts → components/database/CreateQuery.ts} +18 -13
  41. package/src/{@modules/@database → components/database}/GetCachedEvents.ts +18 -15
  42. package/src/components/database/ImportBoundaries.ts +168 -0
  43. package/src/{@modules/@database → components/database}/ImportBroadcastify.ts +14 -24
  44. package/src/components/database/ImportCities.ts +87 -0
  45. package/src/{@modules/@database → components/database}/ImportShapefiles.ts +23 -26
  46. package/src/{@modules/@database → components/database}/ImportStanza.ts +15 -19
  47. package/src/components/database/InitializeDatabase.ts +71 -0
  48. package/src/components/images/GenerateGraphic.ts +242 -0
  49. package/src/components/images/components/CreateRectangle.ts +22 -0
  50. package/src/components/images/components/CreateText.ts +22 -0
  51. package/src/components/images/modules/CreateSVG.ts +37 -0
  52. package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
  53. package/src/components/images/modules/GetGeographicalCities.ts +58 -0
  54. package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
  55. package/src/components/images/modules/GetGeometryBounds.ts +82 -0
  56. package/src/components/images/modules/GetParsedBoundary.ts +58 -0
  57. package/src/components/images/modules/GetSVGPath.ts +53 -0
  58. package/src/components/images/modules/NormalizePolygon.ts +57 -0
  59. package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +16 -17
  60. package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
  61. package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
  62. package/src/{@parsers/@text → components/utilities}/GetEmbededText.ts +8 -6
  63. package/src/{@modules/@utilities → components/utilities}/GetFormattedTime.ts +2 -2
  64. package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
  65. package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
  66. package/src/{@modules/@utilities → components/utilities}/GetShapeNearestPoint.ts +24 -19
  67. package/src/{@parsers/@text → components/utilities}/GetStringText.ts +9 -9
  68. package/src/components/utilities/GetUnionPolygon.ts +36 -0
  69. package/src/components/utilities/QueueManager.ts +70 -0
  70. package/src/components/utilities/SetCronSchedule.ts +106 -0
  71. package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +12 -12
  72. package/src/components/utilities/SetEventEmit.ts +42 -0
  73. package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
  74. package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +5 -5
  75. package/src/components/utilities/SetTimeoutAction.ts +64 -0
  76. package/src/components/utilities/SetWarning.ts +47 -0
  77. package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +20 -20
  78. package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
  79. package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
  80. package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
  81. package/src/components/xmpp/ReconnectXMPP.ts +64 -0
  82. package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +25 -25
  83. package/src/{@core → core}/ClearEvents.ts +9 -9
  84. package/src/{@core → core}/GetEvents.ts +4 -4
  85. package/src/{@core → core}/GetNodes.ts +4 -4
  86. package/src/{@core → core}/GetRandomEvent.ts +4 -4
  87. package/src/{@core → core}/GetVersion.ts +4 -4
  88. package/src/{@core → core}/ManualEvent.ts +23 -24
  89. package/src/{@core → core}/QueryStanza.ts +12 -11
  90. package/src/core/SetNode.ts +87 -0
  91. package/src/{@core → core}/StartService.ts +21 -20
  92. package/src/{@core → core}/StopService.ts +10 -10
  93. package/src/{@enums → enums}/AWIPS.ts +2 -2
  94. package/src/{@enums → enums}/Actions.ts +2 -2
  95. package/src/{@enums → enums}/Cancellation.ts +2 -2
  96. package/src/{@enums → enums}/Causes.ts +2 -2
  97. package/src/{@enums → enums}/Correlations.ts +2 -2
  98. package/src/{@enums → enums}/Enhanced.ts +4 -3
  99. package/src/{@enums → enums}/Events.ts +2 -2
  100. package/src/{@enums → enums}/Expressions.ts +3 -3
  101. package/src/{@enums → enums}/GlobalFilter.ts +2 -2
  102. package/src/{@enums → enums}/Hail.ts +2 -2
  103. package/src/{@enums → enums}/ICAO.ts +2 -2
  104. package/src/{@enums → enums}/Matches.ts +8 -3
  105. package/src/{@enums → enums}/Products.ts +2 -2
  106. package/src/{@enums → enums}/Records.ts +2 -2
  107. package/src/{@enums → enums}/Severity.ts +2 -2
  108. package/src/{@enums → enums}/Shapefiles.ts +2 -2
  109. package/src/{@enums → enums}/States.ts +68 -4
  110. package/src/{@enums → enums}/Status.ts +2 -2
  111. package/src/{@enums → enums}/Strings.ts +2 -2
  112. package/src/{@enums → enums}/Tags.ts +9 -4
  113. package/src/{@enums → enums}/Testing.ts +2 -2
  114. package/src/enums/Themes.ts +70 -0
  115. package/src/events/ParseAPI.ts +133 -0
  116. package/src/{@events → events}/ParseText.ts +24 -22
  117. package/src/{@events → events}/ParseUGC.ts +27 -26
  118. package/src/{@events → events}/ParseVTEC.ts +38 -37
  119. package/src/index.ts +57 -37
  120. package/src/{@manager → manager}/MakeEvents.ts +38 -47
  121. package/src/manager/RemoveEvent.ts +74 -0
  122. package/src/{@manager → manager}/SetHash.ts +18 -13
  123. package/src/{@manager → manager}/UpdateEvents.ts +12 -12
  124. package/src/{@manager → manager}/UpdateNode.ts +14 -14
  125. package/src/{@manager → manager}/ValidateEvents.ts +55 -45
  126. package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +11 -11
  127. package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
  128. package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
  129. package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
  130. package/src/parsers/ugc/GetCache.ts +24 -0
  131. package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
  132. package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
  133. package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
  134. package/src/parsers/ugc/GetZonePolygon.ts +73 -0
  135. package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
  136. package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
  137. package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
  138. package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
  139. package/src/parsers/vtec/VTECExtract.ts +49 -0
  140. package/src/{@types → static}/Attributes.ts +2 -3
  141. package/src/{@types → static}/Event.ts +8 -7
  142. package/src/{@types → static}/Properties.ts +17 -3
  143. package/src/{@types → static}/Stanza.ts +2 -2
  144. package/src/tasks/CreateTasks.ts +116 -0
  145. package/src/tasks/TaskGenerateJSON.ts +34 -0
  146. package/src/tasks/TaskGenerateText.ts +34 -0
  147. package/src/tasks/TaskSendNTFY.ts +95 -0
  148. package/src/tasks/TaskSendWebhook.ts +107 -0
  149. package/src/{@types → types}/Actions.ts +3 -3
  150. package/src/{@types → types}/HVTEC.ts +6 -6
  151. package/src/{@types → types}/Hash.ts +5 -5
  152. package/src/types/Nodes.ts +29 -0
  153. package/src/{@types → types}/Settings.ts +17 -8
  154. package/src/{@types → types}/StanzaCompiled.ts +15 -15
  155. package/src/{@types → types}/UGC.ts +5 -5
  156. package/src/{@modules/@utilities/GetSettings.ts → types/VTEC.ts} +12 -7
  157. package/tools/build.js +47 -0
  158. package/tsconfig.json +28 -1
  159. package/src/@building/GetEventProperties.ts +0 -96
  160. package/src/@building/GetEventTracking.ts +0 -68
  161. package/src/@core/SetNode.ts +0 -81
  162. package/src/@events/ParseAPI.ts +0 -117
  163. package/src/@manager/RemoveEvent.ts +0 -70
  164. package/src/@manager/Tasks.ts +0 -246
  165. package/src/@modules/@database/InitializeDatabase.ts +0 -59
  166. package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
  167. package/src/@modules/@utilities/SetCronSchedule.ts +0 -94
  168. package/src/@modules/@utilities/SetEventEmit.ts +0 -41
  169. package/src/@modules/@utilities/SetListener.ts +0 -30
  170. package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
  171. package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
  172. package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
  173. package/src/@parsers/@pvtec/VTECExtract.ts +0 -49
  174. package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
  175. package/src/@parsers/@text/GetXML.ts +0 -61
  176. package/src/@parsers/@ugc/GetCache.ts +0 -24
  177. package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
  178. package/src/@types/VTEC.ts +0 -30
  179. package/tsup.config.ts +0 -16
package/src/index.ts CHANGED
@@ -11,64 +11,84 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from './@types/Settings'
21
- import { SetSettings } from "./@modules/@utilities/SetSettings"
22
- import { GetEventGeometry } from "./@building/GetEventGeometry";
23
- import { GetCleanedEvent } from "./@building/GetCleanedEvent"
24
- import { SetEventEmit } from './@modules/@utilities/SetEventEmit';
25
- import { SetWarning } from './@modules/@utilities/SetWarning';
26
- import { CreateListener } from "./@core/CreateListener"
27
- import { StartService } from "./@core/StartService"
28
- import { StopService } from "./@core/StopService"
29
- import { GenerateEASMessage } from './@modules/@eas/GenerateEASMessage';
30
- import { SetNode } from "./@core/SetNode"
31
- import { GetEvents } from "./@core/GetEvents"
32
- import { GetNodes } from "./@core/GetNodes"
33
- import { ManualEvent } from "./@core/ManualEvent"
34
- import { GetRandomEvent } from './@core/GetRandomEvent';
35
- import { QueryStanza } from './@core/QueryStanza';
36
- import { ClearEvents } from './@core/ClearEvents';
20
+ import { TypeSettings } from "Types/Settings"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { GetEventGeometry } from "@Building/GetEventGeometry"
23
+ import { GetCleanedEvent } from "@Building/GetCleanedEvent"
24
+ import { SetSettings } from "@Utilities/SetSettings"
25
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
26
+ import { SetWarning } from "@Utilities/SetWarning"
27
+ import { GenerateAudioMessage } from "@Audio/GenerateAudioMessage"
28
+ import { GenerateGraphic } from "@Image/GenerateGraphic"
29
+ import { SetNode } from "@Core/SetNode"
30
+ import { GetEvents } from "@Core/GetEvents"
31
+ import { GetNodes } from "@Core/GetNodes"
32
+ import { ManualEvent } from "@Core/ManualEvent"
33
+ import { GetRandomEvent } from "@Core/GetRandomEvent"
34
+ import { QueryStanza } from "@Core/QueryStanza"
35
+ import { ClearEvents } from "@Core/ClearEvents"
36
+ import { StartService } from "@Core/StartService"
37
+ import { StopService } from "@Core/StopService"
38
+ import { GetVersion } from "@Core/GetVersion"
39
+
37
40
 
38
41
  export class Manager {
39
- constructor(settings: TypeSettings) { this.trycatch(); StartService(settings) }
42
+ public constructor(settings: TypeSettings) {
43
+ this.ErrorHandler(); StartService(settings)
44
+ }
40
45
 
41
- on(event: string, callback: () => void) {
42
- CreateListener(event, callback)
46
+ public on(event: string, callback: () => void) {
47
+ Bootstrap.Listener.on(event, callback)
48
+ return () => { void Bootstrap.Listener.off(event, callback) };
43
49
  }
44
50
 
45
- trycatch() {
46
- process.on('uncaughtException', (err: any) => {
47
- const ignored = ['ETIMEDOUT', 'ECONNRESET', 'EHOSTUNREACH', 'ENOTFOUND', 'ECONNREFUSED', 'EPIPE', 'EADDRINUSE', 'EALREADY', 'EACCES', 'EAGAIN', 'EHOSTDOWN', 'STARTTLS_FAILURE'];
48
- if (ignored.includes(err?.code)) {
51
+ private ErrorHandler() {
52
+ process.on('uncaughtException', (error: any) => {
53
+ const _IGNORED = [
54
+ 'ETIMEDOUT',
55
+ 'ECONNRESET',
56
+ 'EHOSTUNREACH',
57
+ 'ENOTFOUND',
58
+ 'ECONNREFUSED',
59
+ 'EPIPE',
60
+ 'EADDRINUSE',
61
+ 'EALREADY',
62
+ 'EACCES',
63
+ 'EAGAIN',
64
+ 'EHOSTDOWN',
65
+ 'STARTTLS_FAILURE'
66
+ ];
67
+ if (_IGNORED.includes(error?.code)) {
49
68
  SetEventEmit({
50
- event: `onServiceStatus`,
51
- metadata: {
52
- message: `Ignored Critical Error: ${err?.code ?? 'Unknown error code'}. This may indicate a connection issue. Attempting to continue...`,
53
- data: {},
54
- type: `error`,
55
- error: true
69
+ Event: `onServiceStatus`,
70
+ Metadata: {
71
+ Message: `Ignored Critical Error: ${error?.code ?? 'Unknown error code'}. This may indicate a connection issue. Attempting to continue...`,
72
+ Data: {},
73
+ Type: `error`,
74
+ Error: true
56
75
  }
57
76
  })
58
- return;
59
77
  }
60
- SetWarning({message: `Uncaught Exception: ${err instanceof Error ? err.stack ?? err.message : String(err)}`})
78
+ console.log(`Uncaught Exception: ${error instanceof Error ? error.stack ?? error.message : String(error)}`);
79
+ SetWarning({Message: `Uncaught Exception: ${error instanceof Error ? error.stack ?? error.message : String(error)}`})
61
80
  })
62
81
  }
63
82
  }
64
83
 
65
84
  export default Manager;
66
- export type { TypeEvent } from './@types/Event';
85
+ export type { TypeEvent } from "StaticTypes/Event"
67
86
  export {
68
87
  SetSettings, GetEventGeometry, ManualEvent,
69
88
  GetCleanedEvent, StopService, ClearEvents,
70
- StartService, SetNode, GetRandomEvent,
71
- GetEvents, GetNodes, GenerateEASMessage, QueryStanza
89
+ StartService, SetNode, GetRandomEvent, GetVersion,
90
+ GetEvents, GetNodes, GenerateAudioMessage, GenerateGraphic,
91
+ QueryStanza
72
92
  }
73
93
 
74
94
 
@@ -11,54 +11,57 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { TypeSettings } from "../@types/Settings";
22
- import { EnumGlobalFilter } from "../@enums/GlobalFilter";
23
- import { bootstrap } from "../bootstrap"
24
- import { SetHash } from "./SetHash";
25
- import { Tasks } from "./Tasks";
26
- import { UpdateNode } from "./UpdateNode";
27
- import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
28
- import { SetTimeoutAction } from "../@modules/@utilities/SetTimeoutAction";
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeSettings } from "Types/Settings"
22
+ import { EnumGlobalFilter } from "@Enums/GlobalFilter"
23
+ import { Bootstrap } from "@Bootstrap"
24
+ import { CreateTasks } from "@Tasks/CreateTasks"
25
+ import { SetHash } from "@Manager/SetHash"
26
+ import { UpdateNode } from "@Manager/UpdateNode"
27
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
28
+ import { SetTimeoutAction } from "@Utilities/SetTimeoutAction"
29
+ import { GetStringText } from "@Utilities/GetStringText"
29
30
 
30
31
  export const MakeEvents = async (events: TypeEvent[]): Promise<void> => {
31
- let tasked = [];
32
- const settings = bootstrap.settings as TypeSettings;
32
+ let tasked = [] as TypeEvent[];
33
+ const settings = Bootstrap.Settings as TypeSettings;
33
34
  if (events.length === 0) return
34
- for (const event of events) {
35
- const features = bootstrap.cache.events.features;
35
+ await Promise.all(events.map(async event => {
36
+ const features = Bootstrap.Cache.Events.features;
36
37
  const getHash = event.properties.metadata.hash;
37
38
  const getTracking = event.properties.metadata.tracking;
38
- const isEntry = bootstrap.cache.hashes?.find(hash => hash.tracking === getTracking)
39
- const isHashed = isEntry?.hashes?.includes(getHash) ?? false;
39
+ const isEntry = Bootstrap.Cache.Hashes?.find(hash => hash.Tracking === getTracking)
40
+ const isHashed = isEntry?.Hashes?.includes(getHash) ?? false;
40
41
  const isNodeFiltering = settings.GlobalSettings.EventFiltering.NodeLocationFiltering
42
+ const getNodes = Bootstrap.Cache.Nodes.features;
41
43
  const getFeature = features.find(feature => feature.properties.metadata.tracking === getTracking);
42
-
44
+
43
45
  if (isHashed || event.properties.status_metadata.is_expired) return
44
- SetHash(event, isEntry)
45
-
46
- if (isNodeFiltering) {
47
- await UpdateNode(event);
46
+ SetHash({ Event: event, Entry: isEntry })
47
+ await UpdateNode(event);
48
+ if (isNodeFiltering && getNodes.length > 0) {
48
49
  if (!event.properties.metadata.filtered_proximity && !EnumGlobalFilter.includes(event.properties.event.toLowerCase())) {
49
50
  return
50
51
  }
51
52
  }
52
53
 
53
- const isRatelimited = SetTimeoutAction({ identifier: getTracking, interval: 1, max: 1, addTime: true })
54
- if (!isRatelimited.limited) {
54
+ const isRatelimited = SetTimeoutAction({ Identifier: getTracking, Interval: 1, Max: 1, AddTime: true })
55
+ const isLocal = event.properties.metadata.filtered_proximity ? `[LOCAL] ` : ``;
56
+ if (!isRatelimited.Limited) {
55
57
  SetEventEmit({
56
- event: `onEventStatus`,
57
- metadata: {
58
- type: getFeature ? `Updated` : `New`,
59
- event: event
58
+ Event: `onEventStatus`,
59
+ Metadata: {
60
+ Type: getFeature ? `Updated` : `New`,
61
+ Event: event
60
62
  },
61
- message: `[${getFeature ? 'Updated' : 'New'}] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
63
+ Tree: Bootstrap.Settings.EnhancedEventJournaling ? GetStringText(event).split('\n').filter(line => line.trim() !== '') : [],
64
+ Message: `${isLocal}[${getFeature ? 'Updated' : 'New'}] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
62
65
  })
63
66
  }
64
67
 
@@ -67,18 +70,10 @@ export const MakeEvents = async (events: TypeEvent[]): Promise<void> => {
67
70
  if (getFeature) {
68
71
  const getIndex = features.indexOf(getFeature);
69
72
  const cHistory = getFeature?.properties?.metadata?.history ?? [];
70
- const cLocations = getFeature?.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
71
- const cUgc = getFeature?.properties?.geocode?.ugc ?? [];
72
-
73
73
  const iHistory = event.properties?.metadata?.history ?? [];
74
- const iLocations = event.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
75
- const iUgc = event.properties?.geocode?.ugc ?? [];
76
-
77
74
  const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i).filter((v, i, a) => a.findIndex(h => h.description === v.description && h.issued === v.issued) === i);
78
- const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join('; ');
79
- const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
80
75
 
81
- bootstrap.cache.events.features[getIndex] = {
76
+ Bootstrap.Cache.Events.features[getIndex] = {
82
77
  ...event,
83
78
  properties: {
84
79
  ...event.properties,
@@ -86,21 +81,17 @@ export const MakeEvents = async (events: TypeEvent[]): Promise<void> => {
86
81
  ...event?.properties?.metadata,
87
82
  history: mHistory
88
83
  },
89
- locations: mLocations,
90
- geocode: {
91
- ...event?.properties?.geocode,
92
- ugc: mUgc
93
- },
94
84
  }
95
85
  };
96
- tasked.push(bootstrap.cache.events.features[getIndex])
86
+
87
+ tasked.push(Bootstrap.Cache.Events.features[getIndex])
97
88
  } else {
98
89
  features.push(event);
99
90
  tasked.push(event)
100
91
  }
101
92
  }
102
93
  }
103
- }
104
- await Tasks(tasked)
105
- SetEventEmit({ event: `onEventCache`, metadata: bootstrap.cache.events, limited: true })
94
+ }))
95
+ SetEventEmit({ Event: `onEventCache`, Metadata: Bootstrap.Cache.Events, Limited: true })
96
+ return await CreateTasks(tasked)
106
97
  }
@@ -0,0 +1,74 @@
1
+ /*
2
+ _ _ _ __ __
3
+ /\ | | | | (_) \ \ / /
4
+ / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
+ / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
+ / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
+ /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
+ | |
9
+ |_|
10
+
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
+ Discord: https://atmosphericx-discord.scriptkitty.cafe
13
+ Ko-Fi: https://ko-fi.com/k3yomi
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Independent Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { EnumStrings } from "@Enums/Strings"
22
+ import { Bootstrap } from "@Bootstrap"
23
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
24
+ import { SetTimeoutAction } from "@Utilities/SetTimeoutAction"
25
+ import { CreateTasks } from "@Tasks/CreateTasks"
26
+
27
+ interface RemoveEventOptions {
28
+ Event: TypeEvent
29
+ IsTimeBasedExpiration: boolean
30
+ }
31
+
32
+ export const RemoveEvent = async ({ Event, IsTimeBasedExpiration }: RemoveEventOptions):Promise<void> => {
33
+ const gTracking = Event.properties.metadata.tracking;
34
+ const isTrackingEventLogged = Bootstrap.Cache.Events.features
35
+ .find(f => f?.properties?.metadata?.tracking === gTracking);
36
+ const isStatement = Event.properties.status_metadata.is_statement;
37
+
38
+ if (isTrackingEventLogged) {
39
+ Event.properties.expires = new Date().toISOString();
40
+ Event.properties.status = `Expired`;
41
+ Event.properties.status_metadata.is_expired = true;
42
+
43
+ const description = IsTimeBasedExpiration ? EnumStrings.cancellation
44
+ .replace(`{SENDER}`, Event.properties.geocode.office.name)
45
+ .replace(`{EVENT}`, Event.properties.event) : Event.properties.description
46
+ Event.properties.description = description;
47
+ Event.properties.metadata.raw = IsTimeBasedExpiration ? description : Event.properties.metadata.raw;
48
+ Event.properties.metadata.history.push({
49
+ description: IsTimeBasedExpiration ? description : Event.properties.description,
50
+ issued: Event.properties.expires,
51
+ status: Event.properties.status
52
+ })
53
+
54
+ Bootstrap.Cache.Events.features
55
+ .splice(Bootstrap.Cache.Events.features.indexOf(isTrackingEventLogged), 1);
56
+ Bootstrap.Cache.Hashes = Bootstrap.Cache.Hashes
57
+ .filter(hash => hash.Tracking !== gTracking);
58
+
59
+ if (!isStatement) {
60
+ SetEventEmit({
61
+ Event: `onEventStatus`,
62
+ Metadata: { type: `Removed`, event: Event },
63
+ Message: `[Removed] ${Event.properties.event} (${Event.properties.status}) (${gTracking})`
64
+ })
65
+ CreateTasks([Event])
66
+ }
67
+ SetTimeoutAction({ Identifier: gTracking, Expire: true })
68
+ }
69
+ SetEventEmit({
70
+ Event: `onEventCache`,
71
+ Metadata: Bootstrap.Cache.Events,
72
+ Limited: true
73
+ })
74
+ }
@@ -11,26 +11,31 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { TypeHash } from "../@types/Hash"
22
- import { bootstrap } from "../bootstrap"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeHash } from "Types/Hash"
22
+ import { Bootstrap } from "@Bootstrap"
23
23
 
24
- export const SetHash = (event: TypeEvent, entry: TypeHash): void => {
25
- if (!entry) {
26
- bootstrap.cache.hashes.push({
27
- tracking: event.properties.metadata.tracking,
28
- hashes: [event.properties.metadata.hash],
29
- expires: event.properties.expires
24
+ interface SetHashOptions {
25
+ Event: TypeEvent
26
+ Entry: TypeHash
27
+ }
28
+
29
+ export const SetHash = ({ Event, Entry }: SetHashOptions): void => {
30
+ if (!Entry) {
31
+ Bootstrap.Cache.Hashes.push({
32
+ Tracking: Event.properties.metadata.tracking,
33
+ Hashes: [Event.properties.metadata.hash],
34
+ Expires: Event.properties.expires
30
35
  });
31
36
  return;
32
37
  }
33
38
 
34
- entry.hashes.push(event.properties.metadata.hash);
35
- entry.expires = event.properties.expires;
39
+ Entry.Hashes.push(Event.properties.metadata.hash);
40
+ Entry.Expires = Event.properties.expires;
36
41
  }
@@ -11,25 +11,25 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { bootstrap } from "../bootstrap"
22
- import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
23
- import { RemoveEvent } from "./RemoveEvent";
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
23
+ import { RemoveEvent } from "@Manager/RemoveEvent"
24
24
 
25
- export const UpdateEvents = async (selectedEvent?: TypeEvent): Promise<void> => {
26
- const events = bootstrap.cache.events.features;
25
+ export const UpdateEvents = async (selected?: TypeEvent): Promise<void> => {
26
+ const events = Bootstrap.Cache.Events.features;
27
27
  async function update(event: TypeEvent) {
28
28
  if (new Date(event.properties.expires) < new Date()) {
29
- SetEventEmit({ event: `onExpiredProduct`, metadata: event })
30
- await RemoveEvent(event, true)
29
+ SetEventEmit({ Event: `onExpiredProduct`, Metadata: event })
30
+ await RemoveEvent({ Event: event, IsTimeBasedExpiration: true })
31
31
  }
32
32
  }
33
- if (!selectedEvent) { await Promise.all(events.map(async (event) => { await update(event) })) }
34
- if (selectedEvent) { await update(selectedEvent) }
33
+ if (!selected) { await Promise.all(events.map(async (event) => { await update(event) })) }
34
+ if (selected) { await update(selected) }
35
35
  }
@@ -11,23 +11,23 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { bootstrap } from "../bootstrap"
22
- import { GetEventNodes } from "../@building/GetEventNodes";
23
- import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { GetEventNodes } from "@Building/GetEventNodes"
23
+ import { SetEventEmit } from "@Utilities/SetEventEmit"
24
24
 
25
- export const UpdateNode = async (selectedEvent?: TypeEvent): Promise<void> => {
26
- const events = bootstrap.cache.events.features;
27
- const ttl = bootstrap.settings.GlobalSettings.NodeTTL * 1e3;
25
+ export const UpdateNode = async (selected?: TypeEvent): Promise<void> => {
26
+ const events = Bootstrap.Cache.Events.features;
27
+ const ttl = Bootstrap.Settings.GlobalSettings.NodeTTL * 1e3;
28
28
  let total = 0;
29
29
 
30
- const TTLEvents = selectedEvent ? [selectedEvent] : events.filter((evt) => {
30
+ const TTLEvents = selected ? [selected] : events.filter((evt) => {
31
31
  const lastUpdate = evt?.properties?.metadata?.updated ?? null;
32
32
  return lastUpdate == null || (Date.now() - lastUpdate) >= ttl;
33
33
  });
@@ -52,10 +52,10 @@ export const UpdateNode = async (selectedEvent?: TypeEvent): Promise<void> => {
52
52
 
53
53
  if (total > 0) {
54
54
  SetEventEmit({
55
- event: `onNodeUpdate`,
56
- metadata: {
57
- type: `global-update`,
58
- updated: total
55
+ Event: `onNodeUpdate`,
56
+ Metadata: {
57
+ Type: `global-update`,
58
+ Updated: total
59
59
  },
60
60
  })
61
61
  }