@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.
- package/.github/docs/docs-functions.md +1 -1
- package/.github/docs/docs-general-configurations.md +1 -11
- package/.github/docs/docs-integrations.md +3 -2
- package/README.md +10 -8
- package/dist/cjs/index.cjs +24482 -7207
- package/dist/esm/index.mjs +24275 -7003
- package/package.json +56 -47
- package/pnpm-workspace.yaml +4 -0
- package/src/bootstrap.ts +65 -48
- package/src/{@building → building}/CreateEvent.ts +22 -24
- package/src/{@building → building}/GetCleanedEvent.ts +2 -2
- package/src/{@building → building}/GetEventAttachments.ts +14 -12
- package/src/building/GetEventDirection.ts +28 -0
- package/src/{@building → building}/GetEventEnhancedName.ts +5 -8
- package/src/{@building → building}/GetEventGeometry.ts +19 -13
- package/src/{@building → building}/GetEventHeader.ts +13 -13
- package/src/{@building → building}/GetEventNodes.ts +22 -20
- package/src/{@building → building}/GetEventOffice.ts +13 -13
- package/src/building/GetEventPopulation.ts +58 -0
- package/src/building/GetEventProperties.ts +106 -0
- package/src/{@building → building}/GetEventSignature.ts +9 -9
- package/src/{@building → building}/GetEventTags.ts +3 -3
- package/src/building/GetEventTheme.ts +26 -0
- package/src/building/GetEventTracking.ts +64 -0
- package/src/components/audio/GenerateAudioMessage.ts +149 -0
- package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
- package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
- package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
- package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
- package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
- package/src/{@modules/@utilities/SetWarning.ts → components/database/CreateQuery.ts} +18 -13
- package/src/{@modules/@database → components/database}/GetCachedEvents.ts +18 -15
- package/src/components/database/ImportBoundaries.ts +168 -0
- package/src/{@modules/@database → components/database}/ImportBroadcastify.ts +14 -24
- package/src/components/database/ImportCities.ts +87 -0
- package/src/{@modules/@database → components/database}/ImportShapefiles.ts +23 -26
- package/src/{@modules/@database → components/database}/ImportStanza.ts +15 -19
- package/src/components/database/InitializeDatabase.ts +71 -0
- package/src/components/images/GenerateGraphic.ts +242 -0
- package/src/components/images/components/CreateRectangle.ts +22 -0
- package/src/components/images/components/CreateText.ts +22 -0
- package/src/components/images/modules/CreateSVG.ts +37 -0
- package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
- package/src/components/images/modules/GetGeographicalCities.ts +58 -0
- package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
- package/src/components/images/modules/GetGeometryBounds.ts +82 -0
- package/src/components/images/modules/GetParsedBoundary.ts +58 -0
- package/src/components/images/modules/GetSVGPath.ts +53 -0
- package/src/components/images/modules/NormalizePolygon.ts +57 -0
- package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +16 -17
- package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
- package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
- package/src/{@parsers/@text → components/utilities}/GetEmbededText.ts +8 -6
- package/src/{@modules/@utilities → components/utilities}/GetFormattedTime.ts +2 -2
- package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
- package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
- package/src/{@modules/@utilities → components/utilities}/GetShapeNearestPoint.ts +24 -19
- package/src/{@parsers/@text → components/utilities}/GetStringText.ts +9 -9
- package/src/components/utilities/GetUnionPolygon.ts +36 -0
- package/src/components/utilities/QueueManager.ts +70 -0
- package/src/components/utilities/SetCronSchedule.ts +106 -0
- package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +12 -12
- package/src/components/utilities/SetEventEmit.ts +42 -0
- package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
- package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +5 -5
- package/src/components/utilities/SetTimeoutAction.ts +64 -0
- package/src/components/utilities/SetWarning.ts +47 -0
- package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +20 -20
- package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
- package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
- package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
- package/src/components/xmpp/ReconnectXMPP.ts +64 -0
- package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +25 -25
- package/src/{@core → core}/ClearEvents.ts +9 -9
- package/src/{@core → core}/GetEvents.ts +4 -4
- package/src/{@core → core}/GetNodes.ts +4 -4
- package/src/{@core → core}/GetRandomEvent.ts +4 -4
- package/src/{@core → core}/GetVersion.ts +4 -4
- package/src/{@core → core}/ManualEvent.ts +23 -24
- package/src/{@core → core}/QueryStanza.ts +12 -11
- package/src/core/SetNode.ts +87 -0
- package/src/{@core → core}/StartService.ts +21 -20
- package/src/{@core → core}/StopService.ts +10 -10
- package/src/{@enums → enums}/AWIPS.ts +2 -2
- package/src/{@enums → enums}/Actions.ts +2 -2
- package/src/{@enums → enums}/Cancellation.ts +2 -2
- package/src/{@enums → enums}/Causes.ts +2 -2
- package/src/{@enums → enums}/Correlations.ts +2 -2
- package/src/{@enums → enums}/Enhanced.ts +4 -3
- package/src/{@enums → enums}/Events.ts +2 -2
- package/src/{@enums → enums}/Expressions.ts +3 -3
- package/src/{@enums → enums}/GlobalFilter.ts +2 -2
- package/src/{@enums → enums}/Hail.ts +2 -2
- package/src/{@enums → enums}/ICAO.ts +2 -2
- package/src/{@enums → enums}/Matches.ts +8 -3
- package/src/{@enums → enums}/Products.ts +2 -2
- package/src/{@enums → enums}/Records.ts +2 -2
- package/src/{@enums → enums}/Severity.ts +2 -2
- package/src/{@enums → enums}/Shapefiles.ts +2 -2
- package/src/{@enums → enums}/States.ts +68 -4
- package/src/{@enums → enums}/Status.ts +2 -2
- package/src/{@enums → enums}/Strings.ts +2 -2
- package/src/{@enums → enums}/Tags.ts +9 -4
- package/src/{@enums → enums}/Testing.ts +2 -2
- package/src/enums/Themes.ts +70 -0
- package/src/events/ParseAPI.ts +133 -0
- package/src/{@events → events}/ParseText.ts +24 -22
- package/src/{@events → events}/ParseUGC.ts +27 -26
- package/src/{@events → events}/ParseVTEC.ts +38 -37
- package/src/index.ts +57 -37
- package/src/{@manager → manager}/MakeEvents.ts +38 -47
- package/src/manager/RemoveEvent.ts +74 -0
- package/src/{@manager → manager}/SetHash.ts +18 -13
- package/src/{@manager → manager}/UpdateEvents.ts +12 -12
- package/src/{@manager → manager}/UpdateNode.ts +14 -14
- package/src/{@manager → manager}/ValidateEvents.ts +55 -45
- package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +11 -11
- package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
- package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
- package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
- package/src/parsers/ugc/GetCache.ts +24 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
- package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
- package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
- package/src/parsers/ugc/GetZonePolygon.ts +73 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
- package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
- package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
- package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
- package/src/parsers/vtec/VTECExtract.ts +49 -0
- package/src/{@types → static}/Attributes.ts +2 -3
- package/src/{@types → static}/Event.ts +8 -7
- package/src/{@types → static}/Properties.ts +17 -3
- package/src/{@types → static}/Stanza.ts +2 -2
- package/src/tasks/CreateTasks.ts +116 -0
- package/src/tasks/TaskGenerateJSON.ts +34 -0
- package/src/tasks/TaskGenerateText.ts +34 -0
- package/src/tasks/TaskSendNTFY.ts +95 -0
- package/src/tasks/TaskSendWebhook.ts +107 -0
- package/src/{@types → types}/Actions.ts +3 -3
- package/src/{@types → types}/HVTEC.ts +6 -6
- package/src/{@types → types}/Hash.ts +5 -5
- package/src/types/Nodes.ts +29 -0
- package/src/{@types → types}/Settings.ts +17 -8
- package/src/{@types → types}/StanzaCompiled.ts +15 -15
- package/src/{@types → types}/UGC.ts +5 -5
- package/src/{@modules/@utilities/GetSettings.ts → types/VTEC.ts} +12 -7
- package/tools/build.js +47 -0
- package/tsconfig.json +28 -1
- package/src/@building/GetEventProperties.ts +0 -96
- package/src/@building/GetEventTracking.ts +0 -68
- package/src/@core/SetNode.ts +0 -81
- package/src/@events/ParseAPI.ts +0 -117
- package/src/@manager/RemoveEvent.ts +0 -70
- package/src/@manager/Tasks.ts +0 -246
- package/src/@modules/@database/InitializeDatabase.ts +0 -59
- package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
- package/src/@modules/@utilities/SetCronSchedule.ts +0 -94
- package/src/@modules/@utilities/SetEventEmit.ts +0 -41
- package/src/@modules/@utilities/SetListener.ts +0 -30
- package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
- package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
- package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
- package/src/@parsers/@pvtec/VTECExtract.ts +0 -49
- package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
- package/src/@parsers/@text/GetXML.ts +0 -61
- package/src/@parsers/@ugc/GetCache.ts +0 -24
- package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
- package/src/@types/VTEC.ts +0 -30
- 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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeSettings } from
|
|
21
|
-
import {
|
|
22
|
-
import { GetEventGeometry } from "
|
|
23
|
-
import { GetCleanedEvent } from "
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
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) {
|
|
42
|
+
public constructor(settings: TypeSettings) {
|
|
43
|
+
this.ErrorHandler(); StartService(settings)
|
|
44
|
+
}
|
|
40
45
|
|
|
41
|
-
on(event: string, callback: () => void) {
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
process.on('uncaughtException', (
|
|
47
|
-
const
|
|
48
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
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 "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 =
|
|
32
|
+
let tasked = [] as TypeEvent[];
|
|
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 isHashed = isEntry?.
|
|
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({
|
|
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
|
+
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import { TypeHash } from "
|
|
22
|
-
import {
|
|
20
|
+
import { TypeEvent } from "StaticTypes/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
|
}
|
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import {
|
|
22
|
-
import { SetEventEmit } from "
|
|
23
|
-
import { RemoveEvent } from "
|
|
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 (
|
|
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
|
}
|
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import {
|
|
22
|
-
import { GetEventNodes } from "
|
|
23
|
-
import { SetEventEmit } from "
|
|
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 (
|
|
26
|
-
const events =
|
|
27
|
-
const ttl =
|
|
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
|
}
|