@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
@@ -17,42 +17,42 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeAttributes } from "../@types/Attributes";
21
- import { TypeStanzaCompiled } from "../@types/StanzaCompiled"
22
- import { EnumMatches } from "../@enums/Matches";
23
- import { bootstrap } from "../bootstrap";
24
- import { GetEventProperties } from "../@building/GetEventProperties";
25
- import { GetEventHeader } from "../@building/GetEventHeader";
26
- import { GetEventTracking } from "../@building/GetEventTracking";
27
- import { SetDebug } from "../@modules/@utilities/SetDebug";
20
+ import { TypeAttributes } from "types-lower/Attributes"
21
+ import { TypeStanzaCompiled } from "types/StanzaCompiled"
22
+ import { EnumMatches } from "@enums/Matches"
23
+ import { Bootstrap } from "@bootstrap"
24
+ import { GetEventProperties } from "@building/GetEventProperties"
25
+ import { GetEventHeader } from "@building/GetEventHeader"
26
+ import { GetEventTracking } from "@building/GetEventTracking"
27
+ import { SetDebug } from "@utilities/SetDebug"
28
28
 
29
- export const ParseText = async (stanza: TypeStanzaCompiled): Promise<void> => {
30
- const getMessages = stanza?.message
29
+ export const ParseText = async (Stanza: TypeStanzaCompiled): Promise<void> => {
30
+ const getMessages = Stanza?.Message
31
31
  ?.split(/(?=\$\$)/g)
32
32
  ?.map(message => message.trim())
33
33
  ?.filter(message => message && message !== "$$");
34
34
  if (!getMessages || getMessages?.length == 0 ) return;
35
35
  for (const message of getMessages) {
36
36
  const tick = performance.now();
37
- const attributes = stanza?.attributes as TypeAttributes
38
- const props = GetEventProperties({ message, attributes })
39
- const header = GetEventHeader({properties: props, getType: stanza.getType})
37
+ const attributes = Stanza?.Attributes as TypeAttributes
38
+ const props = GetEventProperties({ Message: message, Attributes: attributes })
39
+ const header = GetEventHeader({ Properties: props, VTEC: null, Type: Stanza.Type })
40
40
  const issued = new Date(attributes.issue)
41
41
  const expires = new Date(issued.getTime() + 12 * 60 * 60 * 1000)
42
- const matches = EnumMatches[stanza.getType.prefix]?.find(match => match.match.test(message.toUpperCase()));
42
+ const matches = EnumMatches[Stanza.Type.Prefix]?.find(match => match.match.test(message.toUpperCase()));
43
43
 
44
44
  let event = matches?.label;
45
45
  let isStatement = matches?.statement ?? false;
46
46
 
47
47
  if (!event) {
48
- event = stanza.getType.type;
49
- if (!stanza.getType.discovered) {
48
+ event = Stanza.Type.Type;
49
+ if (!Stanza.Type.Discovered) {
50
50
  event += ` (AWIPSID)`
51
51
  }
52
52
  isStatement = true;
53
53
  }
54
54
 
55
- bootstrap.cache.processed.push({
55
+ Bootstrap.Cache.Parsed.push({
56
56
  type: `Feature`,
57
57
  geometry: {
58
58
  type: `Point`,
@@ -68,7 +68,7 @@ export const ParseText = async (stanza: TypeStanzaCompiled): Promise<void> => {
68
68
  metadata: {
69
69
  ms: performance.now() - tick,
70
70
  source: `events.text`,
71
- tracking: GetEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
71
+ tracking: GetEventTracking({ Type: `RAW`, Stanza, Attributes: attributes, Properties: props }),
72
72
  header: header,
73
73
  vtec: null,
74
74
  hvtec: null,
@@ -83,6 +83,6 @@ export const ParseText = async (stanza: TypeStanzaCompiled): Promise<void> => {
83
83
  }
84
84
  }
85
85
  })
86
- SetDebug({ title: `ParseText`, message: `${Math.round(performance.now() - tick)}ms` })
86
+ SetDebug({ Title: `ParseText`, Message: `${Math.round(performance.now() - tick)}ms` })
87
87
  }
88
88
  }
@@ -17,47 +17,47 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeAttributes } from "../@types/Attributes";
21
- import { TypeStanzaCompiled } from "../@types/StanzaCompiled"
22
- import { EnumMatches } from "../@enums/Matches";
23
- import { bootstrap } from "../bootstrap";
24
- import { ugcExtract } from "../@parsers/@ugc/UGCExtract";
25
- import { GetEventProperties } from "../@building/GetEventProperties";
26
- import { GetEventHeader } from "../@building/GetEventHeader";
27
- import { GetEventTracking } from "../@building/GetEventTracking";
28
- import { SetDebug } from "../@modules/@utilities/SetDebug";
20
+ import { TypeAttributes } from "types-lower/Attributes"
21
+ import { TypeStanzaCompiled } from "types/StanzaCompiled"
22
+ import { EnumMatches } from "@enums/Matches"
23
+ import { Bootstrap } from "@bootstrap"
24
+ import { ugcExtract } from "@parsers/ugc/UGCExtract"
25
+ import { GetEventProperties } from "@building/GetEventProperties"
26
+ import { GetEventHeader } from "@building/GetEventHeader"
27
+ import { GetEventTracking } from "@building/GetEventTracking"
28
+ import { SetDebug } from "@utilities/SetDebug"
29
29
 
30
- export const ParseUGC = async (stanza: TypeStanzaCompiled): Promise<void> => {
31
- const getMessages = stanza?.message
30
+ export const ParseUGC = async (Stanza: TypeStanzaCompiled): Promise<void> => {
31
+ const getMessages = Stanza?.Message
32
32
  ?.split(/(?=\$\$)/g)
33
33
  ?.map(message => message.trim())
34
34
  ?.filter(message => message && message !== "$$");
35
35
  if (!getMessages || getMessages?.length == 0 ) return;
36
36
  for (const message of getMessages) {
37
37
  const tick = performance.now();
38
- const attributes = stanza?.attributes as TypeAttributes
38
+ const attributes = Stanza?.Attributes as TypeAttributes
39
39
  const ugc = await ugcExtract(message)
40
40
 
41
41
  if (ugc != null ) {
42
- const props = GetEventProperties({ message, attributes, ugc: ugc })
42
+ const props = GetEventProperties({ Message: message, Attributes: attributes, UGC: ugc })
43
43
  const issued = new Date(attributes.issue)
44
- const expires = new Date(ugc.expires)
45
- const header = GetEventHeader({properties: props, getType: stanza.getType })
46
- const matches = EnumMatches[stanza.getType.prefix]?.find(match => match.match.test(message.toUpperCase()));
44
+ const expires = new Date(ugc.Expires)
45
+ const header = GetEventHeader({ Properties: props, VTEC: null, Type: Stanza.Type })
46
+ const matches = EnumMatches[Stanza.Type.Prefix]?.find(match => match.match.test(message.toUpperCase()));
47
47
 
48
48
  let event = matches?.label;
49
49
  let isStatement = matches?.statement ?? false;
50
50
 
51
51
  if (!event) {
52
- event = stanza.getType.type;
53
- if (!stanza.getType.discovered) {
52
+ event = Stanza.Type.Type;
53
+ if (!Stanza.Type.Discovered) {
54
54
  event += ` (AWIPSID)`
55
55
  }
56
56
  isStatement = true;
57
57
 
58
58
  }
59
59
 
60
- bootstrap.cache.processed.push({
60
+ Bootstrap.Cache.Parsed.push({
61
61
  type: `Feature`,
62
62
  geometry: {
63
63
  type: `Point`,
@@ -73,7 +73,7 @@ export const ParseUGC = async (stanza: TypeStanzaCompiled): Promise<void> => {
73
73
  metadata: {
74
74
  ms: performance.now() - tick,
75
75
  source: `events.ugc`,
76
- tracking: GetEventTracking({ type: `RAW`, stanza, attributes, properties: props }),
76
+ tracking: GetEventTracking({ Type: `RAW`, Stanza, Attributes: attributes, Properties: props }),
77
77
  header: header,
78
78
  vtec: null,
79
79
  hvtec: null,
@@ -88,7 +88,7 @@ export const ParseUGC = async (stanza: TypeStanzaCompiled): Promise<void> => {
88
88
  }
89
89
  }
90
90
  })
91
- SetDebug({ title: `ParseUGC`, message: `${Math.round(performance.now() - tick)}ms` })
91
+ SetDebug({ Title: `ParseUGC`, Message: `${Math.round(performance.now() - tick)}ms` })
92
92
  }
93
93
  }
94
94
  }
@@ -17,70 +17,69 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeAttributes } from "../@types/Attributes";
21
- import { TypeStanzaCompiled } from "../@types/StanzaCompiled"
22
- import { TypePVTEC } from "../@types/VTEC";
23
- import { TypeHVTEC } from "../@types/HVTEC";
24
- import { bootstrap } from "../bootstrap";
25
- import { VTECExtract } from "../@parsers/@pvtec/VTECExtract";
26
- import { HVExtract } from "../@parsers/@hvtec/HVExtract";
27
- import { ugcExtract } from "../@parsers/@ugc/UGCExtract";
28
- import { GetEventProperties } from "../@building/GetEventProperties";
29
- import { GetEventHeader } from "../@building/GetEventHeader";
30
- import { GetEventTracking } from "../@building/GetEventTracking";
31
- import { SetDebug } from "../@modules/@utilities/SetDebug";
20
+ import { TypeAttributes } from "types-lower/Attributes"
21
+ import { TypeStanzaCompiled } from "types/StanzaCompiled"
22
+ import { TypeVTEC } from "types/VTEC"
23
+ import { TypeHVTEC } from "types/HVTEC"
24
+ import { Bootstrap } from "@bootstrap"
25
+ import { VTECExtract } from "@parsers/vtec/VTECExtract"
26
+ import { HVExtract } from "@parsers/hvtec/HVExtract"
27
+ import { ugcExtract } from "@parsers/ugc/UGCExtract"
28
+ import { GetEventProperties } from "@building/GetEventProperties"
29
+ import { GetEventHeader } from "@building/GetEventHeader"
30
+ import { GetEventTracking } from "@building/GetEventTracking"
31
+ import { SetDebug } from "@utilities/SetDebug"
32
32
 
33
- export const ParseVTEC = async (stanza: TypeStanzaCompiled): Promise<void> => {
34
- const getMessages = stanza?.message
33
+ export const ParseVTEC = async (Stanza: TypeStanzaCompiled): Promise<void> => {
34
+ const getMessages = Stanza?.Message
35
35
  ?.split(/(?=\$\$)/g)
36
36
  ?.map(message => message.trim())
37
37
  ?.filter(message => message && message !== "$$");
38
38
  if (!getMessages || getMessages?.length == 0 ) return;
39
39
  for (const message of getMessages) {
40
40
  const tick = performance.now();
41
- const attributes = stanza?.attributes as TypeAttributes
42
- const pVtec = VTECExtract(message) as TypePVTEC[];
43
- const hVtec = HVExtract(message) as TypeHVTEC[];
41
+ const attributes = Stanza?.Attributes as TypeAttributes
42
+ const VTEC = VTECExtract(message) as TypeVTEC[];
43
+ const hVTEC = HVExtract(message) as TypeHVTEC[];
44
44
  const ugc = await ugcExtract(message)
45
- if (pVtec != null && ugc != null ) {
46
- for (const pv of pVtec) {
47
- const vtec = pv;
48
- const props = GetEventProperties({ message, attributes, ugc, pVtec: vtec })
49
- const header = GetEventHeader({properties: props, getType: stanza.getType, vtec: vtec})
45
+ if (VTEC != null && ugc != null ) {
46
+ for (const vtec of VTEC) {
47
+ const props = GetEventProperties({ Message: message, Attributes: attributes, UGC: ugc, VTEC: vtec })
48
+ const header = GetEventHeader({ Properties: props, VTEC: vtec, Type: Stanza.Type })
50
49
  const issued = new Date(attributes.issue)?? new Date()
51
- const expires = new Date(vtec.expires)
52
- bootstrap.cache.processed.push({
50
+ const expires = new Date(vtec.Expires)
51
+ Bootstrap.Cache.Parsed.push({
53
52
  type: `Feature`,
54
53
  geometry: {
55
54
  type: `Point`,
56
55
  coordinates: []
57
56
  },
58
57
  properties: {
59
- event: pv.event,
60
- parent: pv.event,
61
- status: pv.status,
58
+ event: vtec.Event,
59
+ parent: vtec.Event,
60
+ status: vtec.Status,
62
61
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
63
- expires: (!isNaN(expires.getTime())) ? expires.toISOString() : ugc.expires ?? new Date(issued.getTime() + 60 * 60 * 1000).toISOString(),
62
+ expires: (!isNaN(expires.getTime())) ? expires.toISOString() : ugc.Expires ?? new Date(issued.getTime() + 60 * 60 * 1000).toISOString(),
64
63
  ...props,
65
64
  metadata: {
66
65
  ms: performance.now() - tick,
67
66
  source: `events.vtec`,
68
- tracking: GetEventTracking({ type: `VTEC`, stanza, attributes, properties: props, vtec }),
67
+ tracking: GetEventTracking({ Type: `VTEC`, Stanza, Attributes: attributes, Properties: props, VTEC: vtec }),
69
68
  header: header,
70
- vtec: pv,
71
- hvtec: hVtec,
69
+ vtec: vtec,
70
+ hvtec: hVTEC,
72
71
  raw: message,
73
72
  history: [
74
73
  {
75
74
  description: props.description,
76
75
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
77
- status: pv.status
76
+ status: vtec.Status
78
77
  }
79
78
  ]
80
79
  }
81
80
  }
82
81
  })
83
- SetDebug({ title: `ParseVTEC`, message: `${Math.round(performance.now() - tick)}ms` })
82
+ SetDebug({ Title: `ParseVTEC`, Message: `${Math.round(performance.now() - tick)}ms` })
84
83
  }
85
84
  }
86
85
  }
@@ -17,48 +17,50 @@
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 "types-lower/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
+
29
30
 
30
31
  export const MakeEvents = async (events: TypeEvent[]): Promise<void> => {
31
32
  let tasked = [];
32
- const settings = bootstrap.settings as TypeSettings;
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 isEntry = Bootstrap.Cache.Hashes?.find(hash => hash.tracking === getTracking)
39
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
+ Message: `${isLocal}[${getFeature ? 'Updated' : 'New'}] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
62
64
  })
63
65
  }
64
66
 
@@ -78,7 +80,7 @@ export const MakeEvents = async (events: TypeEvent[]): Promise<void> => {
78
80
  const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join('; ');
79
81
  const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
80
82
 
81
- bootstrap.cache.events.features[getIndex] = {
83
+ Bootstrap.Cache.Events.features[getIndex] = {
82
84
  ...event,
83
85
  properties: {
84
86
  ...event.properties,
@@ -93,14 +95,15 @@ export const MakeEvents = async (events: TypeEvent[]): Promise<void> => {
93
95
  },
94
96
  }
95
97
  };
96
- tasked.push(bootstrap.cache.events.features[getIndex])
98
+
99
+ tasked.push(Bootstrap.Cache.Events.features[getIndex])
97
100
  } else {
98
101
  features.push(event);
99
102
  tasked.push(event)
100
103
  }
101
104
  }
102
105
  }
103
- }
104
- await Tasks(tasked)
105
- SetEventEmit({ event: `onEventCache`, metadata: bootstrap.cache.events, limited: true })
106
+ }))
107
+ SetEventEmit({ Event: `onEventCache`, Metadata: Bootstrap.Cache.Events, Limited: true })
108
+ return await CreateTasks(tasked)
106
109
  }
@@ -17,54 +17,58 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../@types/Event";
21
- import { EnumStrings } from "../@enums/Strings";
22
- import { bootstrap } from "../bootstrap"
23
- import { SetEventEmit } from "../@modules/@utilities/SetEventEmit";
24
- import { SetTimeoutAction } from "../@modules/@utilities/SetTimeoutAction";
25
- import { Tasks } from "./Tasks";
20
+ import { TypeEvent } from "types-lower/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
26
 
27
+ interface RemoveEventOptions {
28
+ Event: TypeEvent
29
+ IsTimeBasedExpiration: boolean
30
+ }
27
31
 
28
- export const RemoveEvent = async (event: TypeEvent, isTimeBasedExpiration: boolean):Promise<void> => {
29
- const gTracking = event.properties.metadata.tracking;
30
- const isTrackingEventLogged = bootstrap.cache.events.features
32
+ export const RemoveEvent = async ({ Event, IsTimeBasedExpiration }: RemoveEventOptions):Promise<void> => {
33
+ const gTracking = Event.properties.metadata.tracking;
34
+ const isTrackingEventLogged = Bootstrap.Cache.Events.features
31
35
  .find(f => f?.properties?.metadata?.tracking === gTracking);
32
- const isStatement = event.properties.status_metadata.is_statement;
36
+ const isStatement = Event.properties.status_metadata.is_statement;
33
37
 
34
38
  if (isTrackingEventLogged) {
35
- event.properties.expires = new Date().toISOString();
36
- event.properties.status = `Expired`;
37
- event.properties.status_metadata.is_expired = true;
39
+ Event.properties.expires = new Date().toISOString();
40
+ Event.properties.status = `Expired`;
41
+ Event.properties.status_metadata.is_expired = true;
38
42
 
39
- const description = isTimeBasedExpiration ? EnumStrings.cancellation
40
- .replace(`{SENDER}`, event.properties.geocode.office.name)
41
- .replace(`{EVENT}`, event.properties.event) : event.properties.description
42
- event.properties.description = description;
43
- event.properties.metadata.raw = isTimeBasedExpiration ? description : event.properties.metadata.raw;
44
- event.properties.metadata.history.push({
45
- description: isTimeBasedExpiration ? description : event.properties.description,
46
- issued: event.properties.expires,
47
- status: event.properties.status
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
48
52
  })
49
-
50
- bootstrap.cache.events.features
51
- .splice(bootstrap.cache.events.features.indexOf(isTrackingEventLogged), 1);
52
- bootstrap.cache.hashes = bootstrap.cache.hashes
53
+
54
+ Bootstrap.Cache.Events.features
55
+ .splice(Bootstrap.Cache.Events.features.indexOf(isTrackingEventLogged), 1);
56
+ Bootstrap.Cache.Hashes = Bootstrap.Cache.Hashes
53
57
  .filter(hash => hash.tracking !== gTracking);
54
58
 
55
59
  if (!isStatement) {
56
60
  SetEventEmit({
57
- event: `onEventStatus`,
58
- metadata: { type: `Removed`, event: event },
59
- message: `[Removed] ${event.properties.event} (${event.properties.status}) (${gTracking})`
61
+ Event: `onEventStatus`,
62
+ Metadata: { type: `Removed`, event: Event },
63
+ Message: `[Removed] ${Event.properties.event} (${Event.properties.status}) (${gTracking})`
60
64
  })
61
- await Tasks([event])
65
+ CreateTasks([Event])
62
66
  }
63
- SetTimeoutAction({ identifier: gTracking, expire: true })
67
+ SetTimeoutAction({ Identifier: gTracking, Expire: true })
64
68
  }
65
69
  SetEventEmit({
66
- event: `onEventCache`,
67
- metadata: bootstrap.cache.events,
68
- limited: true
70
+ Event: `onEventCache`,
71
+ Metadata: Bootstrap.Cache.Events,
72
+ Limited: true
69
73
  })
70
74
  }
@@ -17,20 +17,25 @@
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 "types-lower/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
  }
@@ -17,19 +17,19 @@
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 "types-lower/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
  }
@@ -17,17 +17,17 @@
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";
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;
20
+ import { TypeEvent } from "types-lower/Event"
21
+ import { Bootstrap } from "@bootstrap"
22
+ import { GetEventNodes } from "@building/GetEventNodes"
23
+ import { SetEventEmit } from "@utilities/SetEventEmit"
24
+
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
  }