@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.
- package/.github/docs/docs-functions.md +1 -1
- package/.github/docs/docs-general-configurations.md +1 -1
- package/.github/docs/docs-integrations.md +1 -1
- package/.github/docs/docs-listeners.md +1 -1
- package/.github/docs/docs-source-configuration.md +1 -1
- package/.github/docs/docs-technical.md +1 -1
- package/README.md +7 -5
- package/dist/cjs/index.cjs +21216 -6908
- package/dist/esm/index.mjs +21207 -6900
- package/package.json +49 -47
- package/pnpm-workspace.yaml +4 -0
- package/src/@building/CreateEvent.ts +20 -22
- package/src/@building/GetEventAttachments.ts +8 -8
- package/src/@building/GetEventEnhancedName.ts +2 -4
- package/src/@building/GetEventGeometry.ts +5 -5
- package/src/@building/GetEventHeader.ts +11 -11
- package/src/@building/GetEventNodes.ts +12 -12
- package/src/@building/GetEventOffice.ts +11 -11
- package/src/@building/GetEventProperties.ts +60 -55
- package/src/@building/GetEventSignature.ts +7 -7
- package/src/@building/GetEventTags.ts +1 -1
- package/src/@building/GetEventTracking.ts +28 -32
- package/src/@core/ClearEvents.ts +7 -7
- package/src/@core/CreateListener.ts +2 -2
- package/src/@core/GetEvents.ts +2 -2
- package/src/@core/GetNodes.ts +2 -2
- package/src/@core/GetRandomEvent.ts +2 -2
- package/src/@core/GetVersion.ts +2 -2
- package/src/@core/ManualEvent.ts +20 -21
- package/src/@core/QueryStanza.ts +7 -7
- package/src/@core/SetNode.ts +32 -26
- package/src/@core/StartService.ts +18 -18
- package/src/@core/StopService.ts +8 -8
- package/src/@enums/Expressions.ts +1 -1
- package/src/@enums/Tags.ts +1 -1
- package/src/@events/ParseAPI.ts +44 -39
- package/src/@events/ParseText.ts +19 -19
- package/src/@events/ParseUGC.ts +21 -21
- package/src/@events/ParseVTEC.ts +32 -33
- package/src/@manager/MakeEvents.ts +33 -30
- package/src/@manager/RemoveEvent.ts +38 -34
- package/src/@manager/SetHash.ts +16 -11
- package/src/@manager/UpdateEvents.ts +10 -10
- package/src/@manager/UpdateNode.ts +13 -13
- package/src/@manager/ValidateEvents.ts +36 -37
- package/src/@modules/@database/GetCachedEvents.ts +10 -12
- package/src/@modules/@database/ImportBroadcastify.ts +12 -13
- package/src/@modules/@database/ImportShapefiles.ts +17 -18
- package/src/@modules/@database/ImportStanza.ts +11 -11
- package/src/@modules/@database/InitializeDatabase.ts +16 -16
- package/src/@modules/@eas/GenerateEASMessage.ts +53 -47
- package/src/@modules/@eas/GetPCM16.ts +11 -6
- package/src/@modules/@eas/GetSampledPCM16.ts +12 -6
- package/src/@modules/@eas/GetTTS.ts +12 -7
- package/src/@modules/@eas/GetWavPCM16.ts +5 -5
- package/src/@modules/@eas/SetAFSK.ts +11 -6
- package/src/@modules/@eas/SetAttentionTone.ts +9 -4
- package/src/@modules/@eas/SetNoise.ts +10 -5
- package/src/@modules/@eas/SetRadioEffect.ts +10 -5
- package/src/@modules/@eas/SetSameHeader.ts +20 -12
- package/src/@modules/@stanza/GetAwipsType.ts +14 -15
- package/src/@modules/@stanza/ValidateStanza.ts +25 -13
- package/src/@modules/@utilities/CreateHttp.ts +24 -24
- package/src/@modules/@utilities/GetMatched.ts +8 -3
- package/src/@modules/@utilities/GetSettings.ts +3 -3
- package/src/@modules/@utilities/GetShapeNearestPoint.ts +22 -17
- package/src/@modules/@utilities/QueueManager.ts +70 -0
- package/src/@modules/@utilities/SetCronSchedule.ts +20 -20
- package/src/@modules/@utilities/SetDebug.ts +10 -10
- package/src/@modules/@utilities/SetEventEmit.ts +15 -15
- package/src/@modules/@utilities/SetListener.ts +6 -6
- package/src/@modules/@utilities/SetSettings.ts +5 -5
- package/src/@modules/@utilities/SetSleep.ts +3 -3
- package/src/@modules/@utilities/SetTimeoutAction.ts +25 -25
- package/src/@modules/@utilities/SetWarning.ts +8 -8
- package/src/@modules/@xmpp/DeployXMPP.ts +16 -16
- package/src/@modules/@xmpp/ErrorXMPP.ts +4 -4
- package/src/@modules/@xmpp/OfflineXMPP.ts +11 -11
- package/src/@modules/@xmpp/OnlineXMPP.ts +16 -16
- package/src/@modules/@xmpp/ReconnectXMPP.ts +27 -27
- package/src/@modules/@xmpp/StanzaXMPP.ts +23 -23
- package/src/@parsers/@hvtec/HVExtract.ts +9 -9
- package/src/@parsers/@text/GetDescriptionFromProduct.ts +18 -19
- package/src/@parsers/@text/GetEmbededText.ts +3 -3
- package/src/@parsers/@text/GetStringText.ts +6 -6
- package/src/@parsers/@text/GetTextFromProduct.ts +10 -10
- package/src/@parsers/@text/GetXML.ts +5 -5
- package/src/@parsers/@ugc/GetCache.ts +2 -2
- package/src/@parsers/@ugc/{GetUGCHeader.ts → GetHeader.ts} +2 -2
- package/src/@parsers/@ugc/GetLocations.ts +5 -5
- package/src/@parsers/@ugc/GetZonePolygon.ts +10 -10
- package/src/@parsers/@ugc/GetZones.ts +1 -1
- package/src/@parsers/@ugc/SetCache.ts +11 -6
- package/src/@parsers/@ugc/UGCExtract.ts +10 -10
- package/src/@parsers/{@pvtec → @vtec}/VTECExtract.ts +19 -19
- package/src/@tasks/CreateTasks.ts +110 -0
- package/src/@tasks/TaskGenerateAudio.ts +34 -0
- package/src/@tasks/TaskGenerateJSON.ts +34 -0
- package/src/@tasks/TaskGenerateText.ts +34 -0
- package/src/@tasks/TaskSendNTFY.ts +91 -0
- package/src/@tasks/TaskSendWebhook.ts +100 -0
- package/src/@types/HVTEC.ts +4 -4
- package/src/@types/Hash.ts +3 -3
- package/src/@types/Settings.ts +1 -1
- package/src/@types/StanzaCompiled.ts +13 -13
- package/src/@types/UGC.ts +3 -3
- package/src/@types/VTEC.ts +10 -10
- package/src/{@types → @types-lower}/Event.ts +4 -4
- package/src/{@types → @types-lower}/Properties.ts +2 -1
- package/src/{@types → @types-lower}/Stanza.ts +1 -1
- package/src/bootstrap.ts +26 -26
- package/src/index.ts +30 -27
- package/tools/build.js +45 -0
- package/tsconfig.json +21 -1
- package/src/@manager/Tasks.ts +0 -246
- package/tsup.config.ts +0 -16
- /package/src/@parsers/{@pvtec → @vtec}/GetExpiry.ts +0 -0
- /package/src/{@types → @types-lower}/Attributes.ts +0 -0
package/src/@events/ParseText.ts
CHANGED
|
@@ -17,42 +17,42 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeAttributes } from "
|
|
21
|
-
import { TypeStanzaCompiled } from "
|
|
22
|
-
import { EnumMatches } from "
|
|
23
|
-
import {
|
|
24
|
-
import { GetEventProperties } from "
|
|
25
|
-
import { GetEventHeader } from "
|
|
26
|
-
import { GetEventTracking } from "
|
|
27
|
-
import { SetDebug } from "
|
|
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 (
|
|
30
|
-
const getMessages =
|
|
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 =
|
|
38
|
-
const props = GetEventProperties({ message, attributes })
|
|
39
|
-
const header = GetEventHeader({
|
|
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[
|
|
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 =
|
|
49
|
-
if (!
|
|
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
|
-
|
|
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({
|
|
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({
|
|
86
|
+
SetDebug({ Title: `ParseText`, Message: `${Math.round(performance.now() - tick)}ms` })
|
|
87
87
|
}
|
|
88
88
|
}
|
package/src/@events/ParseUGC.ts
CHANGED
|
@@ -17,47 +17,47 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeAttributes } from "
|
|
21
|
-
import { TypeStanzaCompiled } from "
|
|
22
|
-
import { EnumMatches } from "
|
|
23
|
-
import {
|
|
24
|
-
import { ugcExtract } from "
|
|
25
|
-
import { GetEventProperties } from "
|
|
26
|
-
import { GetEventHeader } from "
|
|
27
|
-
import { GetEventTracking } from "
|
|
28
|
-
import { SetDebug } from "
|
|
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 (
|
|
31
|
-
const getMessages =
|
|
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 =
|
|
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,
|
|
42
|
+
const props = GetEventProperties({ Message: message, Attributes: attributes, UGC: ugc })
|
|
43
43
|
const issued = new Date(attributes.issue)
|
|
44
|
-
const expires = new Date(ugc.
|
|
45
|
-
const header = GetEventHeader({
|
|
46
|
-
const matches = EnumMatches[
|
|
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 =
|
|
53
|
-
if (!
|
|
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
|
-
|
|
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({
|
|
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({
|
|
91
|
+
SetDebug({ Title: `ParseUGC`, Message: `${Math.round(performance.now() - tick)}ms` })
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|
package/src/@events/ParseVTEC.ts
CHANGED
|
@@ -17,70 +17,69 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeAttributes } from "
|
|
21
|
-
import { TypeStanzaCompiled } from "
|
|
22
|
-
import {
|
|
23
|
-
import { TypeHVTEC } from "
|
|
24
|
-
import {
|
|
25
|
-
import { VTECExtract } from "
|
|
26
|
-
import { HVExtract } from "
|
|
27
|
-
import { ugcExtract } from "
|
|
28
|
-
import { GetEventProperties } from "
|
|
29
|
-
import { GetEventHeader } from "
|
|
30
|
-
import { GetEventTracking } from "
|
|
31
|
-
import { SetDebug } from "
|
|
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 (
|
|
34
|
-
const getMessages =
|
|
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 =
|
|
42
|
-
const
|
|
43
|
-
const
|
|
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 (
|
|
46
|
-
for (const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
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.
|
|
52
|
-
|
|
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:
|
|
60
|
-
parent:
|
|
61
|
-
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.
|
|
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({
|
|
67
|
+
tracking: GetEventTracking({ Type: `VTEC`, Stanza, Attributes: attributes, Properties: props, VTEC: vtec }),
|
|
69
68
|
header: header,
|
|
70
|
-
vtec:
|
|
71
|
-
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:
|
|
76
|
+
status: vtec.Status
|
|
78
77
|
}
|
|
79
78
|
]
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
})
|
|
83
|
-
SetDebug({
|
|
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 "
|
|
21
|
-
import { TypeSettings } from "
|
|
22
|
-
import { EnumGlobalFilter } from "
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { UpdateNode } from "
|
|
27
|
-
import { SetEventEmit } from "
|
|
28
|
-
import { SetTimeoutAction } from "
|
|
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 =
|
|
33
|
+
const settings = Bootstrap.Settings as TypeSettings;
|
|
33
34
|
if (events.length === 0) return
|
|
34
|
-
|
|
35
|
-
const 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 =
|
|
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({
|
|
54
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
Event: `onEventStatus`,
|
|
59
|
+
Metadata: {
|
|
60
|
+
Type: getFeature ? `Updated` : `New`,
|
|
61
|
+
Event: event
|
|
60
62
|
},
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
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 "
|
|
21
|
-
import { EnumStrings } from "
|
|
22
|
-
import {
|
|
23
|
-
import { SetEventEmit } from "
|
|
24
|
-
import { SetTimeoutAction } from "
|
|
25
|
-
import {
|
|
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 (
|
|
29
|
-
const gTracking =
|
|
30
|
-
const isTrackingEventLogged =
|
|
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 =
|
|
36
|
+
const isStatement = Event.properties.status_metadata.is_statement;
|
|
33
37
|
|
|
34
38
|
if (isTrackingEventLogged) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 =
|
|
40
|
-
.replace(`{SENDER}`,
|
|
41
|
-
.replace(`{EVENT}`,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
description:
|
|
46
|
-
issued:
|
|
47
|
-
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
|
-
|
|
51
|
-
.splice(
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
Event: `onEventStatus`,
|
|
62
|
+
Metadata: { type: `Removed`, event: Event },
|
|
63
|
+
Message: `[Removed] ${Event.properties.event} (${Event.properties.status}) (${gTracking})`
|
|
60
64
|
})
|
|
61
|
-
|
|
65
|
+
CreateTasks([Event])
|
|
62
66
|
}
|
|
63
|
-
SetTimeoutAction({
|
|
67
|
+
SetTimeoutAction({ Identifier: gTracking, Expire: true })
|
|
64
68
|
}
|
|
65
69
|
SetEventEmit({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
Event: `onEventCache`,
|
|
71
|
+
Metadata: Bootstrap.Cache.Events,
|
|
72
|
+
Limited: true
|
|
69
73
|
})
|
|
70
74
|
}
|
package/src/@manager/SetHash.ts
CHANGED
|
@@ -17,20 +17,25 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import { TypeHash } from "
|
|
22
|
-
import {
|
|
20
|
+
import { TypeEvent } from "types-lower/Event"
|
|
21
|
+
import { TypeHash } from "types/Hash"
|
|
22
|
+
import { Bootstrap } from "@bootstrap"
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
35
|
-
|
|
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 "
|
|
21
|
-
import {
|
|
22
|
-
import { SetEventEmit } from "
|
|
23
|
-
import { RemoveEvent } from "
|
|
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 (
|
|
26
|
-
const events =
|
|
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({
|
|
30
|
-
await RemoveEvent(event, true)
|
|
29
|
+
SetEventEmit({ Event: `onExpiredProduct`, Metadata: event })
|
|
30
|
+
await RemoveEvent({ Event: event, IsTimeBasedExpiration: true })
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
if (!
|
|
34
|
-
if (
|
|
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 "
|
|
21
|
-
import {
|
|
22
|
-
import { GetEventNodes } from "
|
|
23
|
-
import { SetEventEmit } from "
|
|
24
|
-
|
|
25
|
-
export const UpdateNode = async (
|
|
26
|
-
const events =
|
|
27
|
-
const ttl =
|
|
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 =
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
Event: `onNodeUpdate`,
|
|
56
|
+
Metadata: {
|
|
57
|
+
Type: `global-update`,
|
|
58
|
+
Updated: total
|
|
59
59
|
},
|
|
60
60
|
})
|
|
61
61
|
}
|