@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
|
@@ -0,0 +1,91 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Internal Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { TypeEvent } from "types-lower/Event"
|
|
21
|
+
import { Bootstrap } from "@bootstrap"
|
|
22
|
+
import { CreateHttp } from "@utilities/CreateHttp";
|
|
23
|
+
import { SetDebug } from "@utilities/SetDebug";
|
|
24
|
+
|
|
25
|
+
interface TaskSendNTFYOptions {
|
|
26
|
+
Event: TypeEvent;
|
|
27
|
+
Toggles?: {
|
|
28
|
+
EAS?: boolean;
|
|
29
|
+
Json?: boolean;
|
|
30
|
+
Text?: boolean;
|
|
31
|
+
},
|
|
32
|
+
Priority: string | number;
|
|
33
|
+
Body: string;
|
|
34
|
+
Topic: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const TaskSendNTFY = async function({ Event, Toggles, Priority, Body, Topic }: TaskSendNTFYOptions): Promise<void> {
|
|
38
|
+
const { properties } = Event;
|
|
39
|
+
|
|
40
|
+
const configurations = Bootstrap.Settings.NotifyServer;
|
|
41
|
+
const authentication = configurations?.Credentials?.Username && configurations?.Credentials?.Password ? {
|
|
42
|
+
Username: configurations.Credentials.Username,
|
|
43
|
+
Password: configurations.Credentials.Password
|
|
44
|
+
} : undefined;
|
|
45
|
+
const image = properties.metadata.attachments?.find(a => a.name === "Image: Graphic");
|
|
46
|
+
|
|
47
|
+
const buttons = [
|
|
48
|
+
...(Toggles?.EAS && configurations?.MediaStorage?.EAS ? [{
|
|
49
|
+
"action": "view",
|
|
50
|
+
"label": "Listen",
|
|
51
|
+
"url": `${configurations.MediaStorage.EAS}/${properties.event}_${properties.metadata.tracking}.wav`,
|
|
52
|
+
}] : []),
|
|
53
|
+
...(Toggles?.Text && configurations?.MediaStorage?.TEXT ? [{
|
|
54
|
+
"action": "view",
|
|
55
|
+
"label": "View Text",
|
|
56
|
+
"url": `${configurations.MediaStorage.TEXT}/${properties.event}_${properties.metadata.tracking}.txt`,
|
|
57
|
+
}] : []),
|
|
58
|
+
...(image ? [{
|
|
59
|
+
"action": "view",
|
|
60
|
+
"label": "View Image",
|
|
61
|
+
"url": image.link,
|
|
62
|
+
}] : []),
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const headers = {
|
|
66
|
+
"Title": `${properties.event} (${properties.status})`,
|
|
67
|
+
"Tags": properties.parameters.tags?.join(",") ?? "N/A",
|
|
68
|
+
"Priority": Priority ?? "5",
|
|
69
|
+
...(buttons.length > 0 && { "Actions": JSON.stringify(buttons) }),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const post = async (topic: string) => {
|
|
73
|
+
const response = await CreateHttp({
|
|
74
|
+
URL: `${configurations?.Server?.replace(/\/$/, "")}/${topic}`,
|
|
75
|
+
Timeout: 15_000,
|
|
76
|
+
Method: "PUT",
|
|
77
|
+
...(authentication && { Auth: authentication }),
|
|
78
|
+
Headers: headers,
|
|
79
|
+
Body: Body
|
|
80
|
+
})
|
|
81
|
+
if (response.error) {
|
|
82
|
+
SetDebug({ Title: `Tasks/NTFY`, Message: `Failed to send notification to topic "${topic}": ${response.message}` })
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const topics = [
|
|
86
|
+
Topic,
|
|
87
|
+
...(properties.metadata.filtered_proximity ? [`${Topic}-LOCAL`] : []),
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
await Promise.all([...new Set(topics)].map(post));
|
|
91
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Internal Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { TypeEvent } from "types-lower/Event"
|
|
21
|
+
import { CreateHttp } from "@utilities/CreateHttp";
|
|
22
|
+
import { SetTimeoutAction } from "@utilities/SetTimeoutAction";
|
|
23
|
+
import { GetEmebedText } from "@parsers/text/GetEmbededText";
|
|
24
|
+
import { parentPort } from "worker_threads"
|
|
25
|
+
import { readFile } from "fs/promises"
|
|
26
|
+
|
|
27
|
+
interface TaskSendWebhookOptions {
|
|
28
|
+
Event: TypeEvent;
|
|
29
|
+
Webhook: {
|
|
30
|
+
Enabled: boolean;
|
|
31
|
+
Destination: string;
|
|
32
|
+
Message: string;
|
|
33
|
+
Title: string;
|
|
34
|
+
Ratelimit: number;
|
|
35
|
+
};
|
|
36
|
+
Attachments: {
|
|
37
|
+
Text?: string;
|
|
38
|
+
EAS?: string;
|
|
39
|
+
Json?: string;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const TaskSendWebhook = async function({ Event, Webhook, Attachments }: TaskSendWebhookOptions): Promise<void> {
|
|
44
|
+
const { properties } = Event;
|
|
45
|
+
const isRatelimited = SetTimeoutAction({
|
|
46
|
+
Identifier: Webhook.Destination,
|
|
47
|
+
Interval: (Webhook.Ratelimit ?? 2) * 2,
|
|
48
|
+
Max: (Webhook.Ratelimit ?? 2),
|
|
49
|
+
AddTime: true
|
|
50
|
+
})
|
|
51
|
+
if (isRatelimited.Limited) { return }
|
|
52
|
+
const newForm = new FormData();
|
|
53
|
+
const newEmbed = {
|
|
54
|
+
title: `${properties.event} (${properties.status})`,
|
|
55
|
+
description: GetEmebedText(Event),
|
|
56
|
+
fields: [],
|
|
57
|
+
color: 16711680,
|
|
58
|
+
timestamp: new Date().toISOString(),
|
|
59
|
+
footer: { text: Webhook.Title ?? `AtmosphericX` }
|
|
60
|
+
};
|
|
61
|
+
if (properties.description && !properties.status_metadata.is_expired) {
|
|
62
|
+
const description = properties.description.length > 900
|
|
63
|
+
? properties.description.substring(0, 900) + "\n\n[Message truncated due to length]"
|
|
64
|
+
: properties.description;
|
|
65
|
+
newEmbed.fields.push({
|
|
66
|
+
name: "Description",
|
|
67
|
+
value: description ? '```' + '\n' + description.split('\n').map(l => l.trim()).filter(Boolean).join('\n') + '\n' + '```' : ""
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (properties.metadata.attachments?.length > 0) {
|
|
71
|
+
const attachments = properties.metadata.attachments.slice(0, 5);
|
|
72
|
+
newEmbed.fields.push({
|
|
73
|
+
name: "Attachments",
|
|
74
|
+
value: attachments.map(attachment => `- [${attachment.name.length > 45 ? attachment.name.substring(0, 45) + '...' : attachment.name}](${attachment.link})`).join('\n')
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (Attachments?.Text) {
|
|
78
|
+
newForm.append("fUpload", new Blob([Buffer.from(Attachments.Text)], {type: "application/text"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.txt`)
|
|
79
|
+
}
|
|
80
|
+
if (Attachments?.Json) {
|
|
81
|
+
newForm.append("fUpload2", new Blob([Buffer.from(Attachments.Json)], {type: "application/json"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.json`)
|
|
82
|
+
}
|
|
83
|
+
if (Attachments?.EAS) {
|
|
84
|
+
const file = await readFile(Attachments.EAS);
|
|
85
|
+
newForm.append("fUpload3", new Blob([Buffer.from(file)], {type: "application/wav"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.wav`)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
newForm.append("payload_json", JSON.stringify({
|
|
89
|
+
username: Webhook.Title ?? `AtmosphericX`,
|
|
90
|
+
content: Webhook.Message ?? "",
|
|
91
|
+
embeds: [newEmbed]
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
await CreateHttp({
|
|
95
|
+
URL: Webhook.Destination,
|
|
96
|
+
Timeout: 15e3,
|
|
97
|
+
Method: `POST`,
|
|
98
|
+
Body: newForm
|
|
99
|
+
})
|
|
100
|
+
}
|
package/src/@types/HVTEC.ts
CHANGED
package/src/@types/Hash.ts
CHANGED
package/src/@types/Settings.ts
CHANGED
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeAttributes } from "
|
|
20
|
+
import { TypeAttributes } from "types-lower/Attributes"
|
|
21
21
|
|
|
22
22
|
export type TypeStanzaCompiled = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
Message?: string
|
|
24
|
+
Attributes?: TypeAttributes
|
|
25
|
+
CapEvent?: boolean
|
|
26
|
+
VTEC?: boolean
|
|
27
|
+
UGC?: boolean
|
|
28
|
+
CapAreaDescription?: boolean
|
|
29
|
+
Ignored?: boolean
|
|
30
|
+
NWWS?: boolean
|
|
31
|
+
Type?: {
|
|
32
|
+
Type: string
|
|
33
|
+
Prefix: string
|
|
34
|
+
Discovered: boolean
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/@types/UGC.ts
CHANGED
package/src/@types/VTEC.ts
CHANGED
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
export type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
export type TypeVTEC = {
|
|
21
|
+
Raw: string
|
|
22
|
+
ProductType: string
|
|
23
|
+
Tracking: string
|
|
24
|
+
Event: string
|
|
25
|
+
Status: string
|
|
26
|
+
WMO: string
|
|
27
|
+
Expires: string
|
|
28
|
+
Watch: boolean
|
|
29
|
+
PredictionCenter: boolean
|
|
30
30
|
}
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEventProperties as BaseTypeEventProperties } from "./Properties"
|
|
21
|
-
import { TypeHVTEC } from "
|
|
22
|
-
import {
|
|
20
|
+
import { TypeEventProperties as BaseTypeEventProperties } from "./Properties"
|
|
21
|
+
import { TypeHVTEC } from "types/HVTEC"
|
|
22
|
+
import { TypeVTEC } from "types/VTEC"
|
|
23
23
|
|
|
24
24
|
export type TypeEvent = {
|
|
25
25
|
type: string
|
|
@@ -46,7 +46,7 @@ export type TypeEvent = {
|
|
|
46
46
|
tracking: string
|
|
47
47
|
hash?: string
|
|
48
48
|
header: string
|
|
49
|
-
vtec?:
|
|
49
|
+
vtec?: TypeVTEC | null
|
|
50
50
|
hvtec?: TypeHVTEC[] | null
|
|
51
51
|
nodes?: {
|
|
52
52
|
id?: string | number
|
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeAttributes } from "./Attributes"
|
|
20
|
+
import { TypeAttributes } from "./Attributes"
|
|
21
21
|
|
|
22
22
|
export type TypeEventProperties = {
|
|
23
23
|
locations: string
|
|
24
24
|
locations_array: string[]
|
|
25
|
+
location_states: string[]
|
|
25
26
|
description: string
|
|
26
27
|
attributes?: TypeAttributes
|
|
27
28
|
geocode: {
|
package/src/bootstrap.ts
CHANGED
|
@@ -17,35 +17,35 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import path from
|
|
21
|
-
import { EventEmitter } from
|
|
20
|
+
import path from "path"
|
|
21
|
+
import { EventEmitter } from "node:events"
|
|
22
22
|
|
|
23
|
-
export const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
export const Bootstrap = {
|
|
24
|
+
Version: `3.0.63`,
|
|
25
|
+
Ready: true,
|
|
26
|
+
Ratelimits: {},
|
|
27
|
+
Session: null,
|
|
28
|
+
Database: null,
|
|
29
|
+
Job: null,
|
|
30
|
+
Listener: new EventEmitter(),
|
|
31
|
+
Colors: {
|
|
32
|
+
Red: `\x1b[31m`, Green: `\x1b[32m`, Yellow: `\x1b[33m`,
|
|
33
|
+
Blue: `\x1b[34m`, Magenta: `\x1b[35m`, Cyan: `\x1b[36m`,
|
|
34
|
+
White: `\x1b[37m`, Reset: `\x1b[0m`
|
|
35
35
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
Cache: {
|
|
37
|
+
LastStanzaTime: null,
|
|
38
|
+
Connected: false,
|
|
39
|
+
Reconnecting: false,
|
|
40
|
+
TotalReconnects: 0,
|
|
41
|
+
Hault: false,
|
|
42
|
+
Events: {type: "FeatureCollection", features: []},
|
|
43
|
+
Nodes: {type: "FeatureCollection", features: []},
|
|
44
|
+
Hashes: [],
|
|
45
|
+
Parsed: [],
|
|
46
|
+
UGC: new Map<string, string[]>()
|
|
47
47
|
},
|
|
48
|
-
|
|
48
|
+
Settings: {
|
|
49
49
|
Database: path.join(process.cwd(), 'shapefiles.db'),
|
|
50
50
|
EnableWireService: false,
|
|
51
51
|
EnableDebugging: false,
|
package/src/index.ts
CHANGED
|
@@ -17,26 +17,29 @@
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeSettings } from
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { SetEventEmit } from
|
|
25
|
-
import { SetWarning } from
|
|
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 { GetEventGeometry } from "@building/GetEventGeometry"
|
|
22
|
+
import { GetCleanedEvent } from "@building/GetCleanedEvent"
|
|
23
|
+
import { SetSettings } from "@utilities/SetSettings"
|
|
24
|
+
import { SetEventEmit } from "@utilities/SetEventEmit"
|
|
25
|
+
import { SetWarning } from "@utilities/SetWarning"
|
|
26
|
+
import { GenerateEASMessage } from "@eas/GenerateEASMessage"
|
|
27
|
+
import { SetNode } from "@core/SetNode"
|
|
28
|
+
import { GetEvents } from "@core/GetEvents"
|
|
29
|
+
import { GetNodes } from "@core/GetNodes"
|
|
30
|
+
import { ManualEvent } from "@core/ManualEvent"
|
|
31
|
+
import { GetRandomEvent } from "@core/GetRandomEvent"
|
|
32
|
+
import { QueryStanza } from "@core/QueryStanza"
|
|
33
|
+
import { ClearEvents } from "@core/ClearEvents"
|
|
34
|
+
import { CreateListener } from "@core/CreateListener"
|
|
35
|
+
import { StartService } from "@core/StartService"
|
|
36
|
+
import { StopService } from "@core/StopService"
|
|
37
|
+
import { GetVersion } from "@core/GetVersion"
|
|
37
38
|
|
|
38
39
|
export class Manager {
|
|
39
|
-
constructor(settings: TypeSettings) {
|
|
40
|
+
public constructor(settings: TypeSettings) {
|
|
41
|
+
this.trycatch(); StartService(settings)
|
|
42
|
+
}
|
|
40
43
|
|
|
41
44
|
on(event: string, callback: () => void) {
|
|
42
45
|
CreateListener(event, callback)
|
|
@@ -47,27 +50,27 @@ export class Manager {
|
|
|
47
50
|
const ignored = ['ETIMEDOUT', 'ECONNRESET', 'EHOSTUNREACH', 'ENOTFOUND', 'ECONNREFUSED', 'EPIPE', 'EADDRINUSE', 'EALREADY', 'EACCES', 'EAGAIN', 'EHOSTDOWN', 'STARTTLS_FAILURE'];
|
|
48
51
|
if (ignored.includes(err?.code)) {
|
|
49
52
|
SetEventEmit({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
Event: `onServiceStatus`,
|
|
54
|
+
Metadata: {
|
|
55
|
+
Message: `Ignored Critical Error: ${err?.code ?? 'Unknown error code'}. This may indicate a connection issue. Attempting to continue...`,
|
|
56
|
+
Data: {},
|
|
57
|
+
Type: `error`,
|
|
58
|
+
Error: true
|
|
56
59
|
}
|
|
57
60
|
})
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
60
|
-
SetWarning({
|
|
63
|
+
SetWarning({Message: `Uncaught Exception: ${err instanceof Error ? err.stack ?? err.message : String(err)}`})
|
|
61
64
|
})
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
export default Manager;
|
|
66
|
-
export type { TypeEvent } from
|
|
69
|
+
export type { TypeEvent } from "./@types-lower/Event"
|
|
67
70
|
export {
|
|
68
71
|
SetSettings, GetEventGeometry, ManualEvent,
|
|
69
72
|
GetCleanedEvent, StopService, ClearEvents,
|
|
70
|
-
StartService, SetNode, GetRandomEvent,
|
|
73
|
+
StartService, SetNode, GetRandomEvent, GetVersion,
|
|
71
74
|
GetEvents, GetNodes, GenerateEASMessage, QueryStanza
|
|
72
75
|
}
|
|
73
76
|
|
package/tools/build.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { spawn } = require("child_process");
|
|
2
|
+
const watch = process.argv.includes("--watch");
|
|
3
|
+
|
|
4
|
+
const commands = [
|
|
5
|
+
{
|
|
6
|
+
name: "esm",
|
|
7
|
+
args: [
|
|
8
|
+
"--bundle",
|
|
9
|
+
"--platform=node",
|
|
10
|
+
"--target=node22",
|
|
11
|
+
"--format=esm",
|
|
12
|
+
"--external:better-sqlite3",
|
|
13
|
+
"--out-extension:.js=.mjs",
|
|
14
|
+
"--outdir=dist/esm",
|
|
15
|
+
...(watch ? ["--watch"] : []),
|
|
16
|
+
"./src/index.ts",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "cjs",
|
|
21
|
+
args: [
|
|
22
|
+
"--bundle",
|
|
23
|
+
"--platform=node",
|
|
24
|
+
"--target=node22",
|
|
25
|
+
"--format=cjs",
|
|
26
|
+
"--external:better-sqlite3",
|
|
27
|
+
"--out-extension:.js=.cjs",
|
|
28
|
+
"--outdir=dist/cjs",
|
|
29
|
+
...(watch ? ["--watch"] : []),
|
|
30
|
+
"./src/index.ts",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
function runBuild({ name, args }) {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const proc = spawn("esbuild", args, {
|
|
38
|
+
shell: true,
|
|
39
|
+
stdio: "inherit",
|
|
40
|
+
});
|
|
41
|
+
proc.on("error", reject);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Promise.all(commands.map(runBuild)).catch((err) => { console.error(err); process.exit(1); });
|
package/tsconfig.json
CHANGED
|
@@ -8,7 +8,27 @@
|
|
|
8
8
|
"declarationDir": "dist/types",
|
|
9
9
|
"esModuleInterop": true,
|
|
10
10
|
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"skipLibCheck": true
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"paths": {
|
|
13
|
+
"@parsers/hvtec/*": ["./src/@parsers/@hvtec/*"],
|
|
14
|
+
"@parsers/vtec/*": ["./src/@parsers/@vtec/*"],
|
|
15
|
+
"@parsers/ugc/*": ["./src/@parsers/@ugc/*"],
|
|
16
|
+
"@parsers/text/*": ["./src/@parsers/@text/*"],
|
|
17
|
+
"@database/*": ["./src/@modules/@database/*"],
|
|
18
|
+
"@eas/*": ["./src/@modules/@eas/*"],
|
|
19
|
+
"@stanza/*": ["./src/@modules/@stanza/*"],
|
|
20
|
+
"@utilities/*": ["./src/@modules/@utilities/*"],
|
|
21
|
+
"@xmpp/*": ["./src/@modules/@xmpp/*"],
|
|
22
|
+
"@manager/*": ["./src/@manager/*"],
|
|
23
|
+
"@tasks/*": ["./src/@tasks/*"],
|
|
24
|
+
"@events/*": ["./src/@events/*"],
|
|
25
|
+
"@enums/*": ["./src/@enums/*"],
|
|
26
|
+
"@core/*": ["./src/@core/*"],
|
|
27
|
+
"@building/*": ["./src/@building/*"],
|
|
28
|
+
"types/*": ["./src/@types/*"],
|
|
29
|
+
"types-lower/*": ["./src/@types-lower/*"],
|
|
30
|
+
"@bootstrap": ["./src/bootstrap.ts"],
|
|
31
|
+
}
|
|
12
32
|
},
|
|
13
33
|
"include": ["src"]
|
|
14
34
|
}
|