@atmosx/event-product-parser 3.0.62 → 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 (112) hide show
  1. package/README.md +6 -4
  2. package/dist/cjs/index.cjs +21216 -6908
  3. package/dist/esm/index.mjs +21207 -6900
  4. package/package.json +49 -47
  5. package/pnpm-workspace.yaml +4 -0
  6. package/src/@building/CreateEvent.ts +20 -22
  7. package/src/@building/GetEventAttachments.ts +8 -8
  8. package/src/@building/GetEventEnhancedName.ts +2 -4
  9. package/src/@building/GetEventGeometry.ts +5 -5
  10. package/src/@building/GetEventHeader.ts +11 -11
  11. package/src/@building/GetEventNodes.ts +12 -12
  12. package/src/@building/GetEventOffice.ts +11 -11
  13. package/src/@building/GetEventProperties.ts +60 -55
  14. package/src/@building/GetEventSignature.ts +7 -7
  15. package/src/@building/GetEventTags.ts +1 -1
  16. package/src/@building/GetEventTracking.ts +28 -32
  17. package/src/@core/ClearEvents.ts +7 -7
  18. package/src/@core/CreateListener.ts +2 -2
  19. package/src/@core/GetEvents.ts +2 -2
  20. package/src/@core/GetNodes.ts +2 -2
  21. package/src/@core/GetRandomEvent.ts +2 -2
  22. package/src/@core/GetVersion.ts +2 -2
  23. package/src/@core/ManualEvent.ts +20 -21
  24. package/src/@core/QueryStanza.ts +7 -7
  25. package/src/@core/SetNode.ts +32 -26
  26. package/src/@core/StartService.ts +18 -18
  27. package/src/@core/StopService.ts +8 -8
  28. package/src/@enums/Expressions.ts +1 -1
  29. package/src/@enums/Tags.ts +1 -1
  30. package/src/@events/ParseAPI.ts +44 -39
  31. package/src/@events/ParseText.ts +19 -19
  32. package/src/@events/ParseUGC.ts +21 -21
  33. package/src/@events/ParseVTEC.ts +32 -33
  34. package/src/@manager/MakeEvents.ts +33 -30
  35. package/src/@manager/RemoveEvent.ts +38 -34
  36. package/src/@manager/SetHash.ts +16 -11
  37. package/src/@manager/UpdateEvents.ts +10 -10
  38. package/src/@manager/UpdateNode.ts +13 -13
  39. package/src/@manager/ValidateEvents.ts +36 -37
  40. package/src/@modules/@database/GetCachedEvents.ts +10 -12
  41. package/src/@modules/@database/ImportBroadcastify.ts +12 -13
  42. package/src/@modules/@database/ImportShapefiles.ts +17 -18
  43. package/src/@modules/@database/ImportStanza.ts +11 -11
  44. package/src/@modules/@database/InitializeDatabase.ts +16 -16
  45. package/src/@modules/@eas/GenerateEASMessage.ts +53 -47
  46. package/src/@modules/@eas/GetPCM16.ts +11 -6
  47. package/src/@modules/@eas/GetSampledPCM16.ts +12 -6
  48. package/src/@modules/@eas/GetTTS.ts +12 -7
  49. package/src/@modules/@eas/GetWavPCM16.ts +5 -5
  50. package/src/@modules/@eas/SetAFSK.ts +11 -6
  51. package/src/@modules/@eas/SetAttentionTone.ts +9 -4
  52. package/src/@modules/@eas/SetNoise.ts +10 -5
  53. package/src/@modules/@eas/SetRadioEffect.ts +10 -5
  54. package/src/@modules/@eas/SetSameHeader.ts +20 -12
  55. package/src/@modules/@stanza/GetAwipsType.ts +14 -15
  56. package/src/@modules/@stanza/ValidateStanza.ts +25 -13
  57. package/src/@modules/@utilities/CreateHttp.ts +24 -24
  58. package/src/@modules/@utilities/GetMatched.ts +8 -3
  59. package/src/@modules/@utilities/GetSettings.ts +3 -3
  60. package/src/@modules/@utilities/GetShapeNearestPoint.ts +22 -17
  61. package/src/@modules/@utilities/QueueManager.ts +70 -0
  62. package/src/@modules/@utilities/SetCronSchedule.ts +20 -20
  63. package/src/@modules/@utilities/SetDebug.ts +10 -10
  64. package/src/@modules/@utilities/SetEventEmit.ts +15 -15
  65. package/src/@modules/@utilities/SetListener.ts +6 -6
  66. package/src/@modules/@utilities/SetSettings.ts +5 -5
  67. package/src/@modules/@utilities/SetSleep.ts +3 -3
  68. package/src/@modules/@utilities/SetTimeoutAction.ts +25 -25
  69. package/src/@modules/@utilities/SetWarning.ts +8 -8
  70. package/src/@modules/@xmpp/DeployXMPP.ts +16 -16
  71. package/src/@modules/@xmpp/ErrorXMPP.ts +4 -4
  72. package/src/@modules/@xmpp/OfflineXMPP.ts +11 -11
  73. package/src/@modules/@xmpp/OnlineXMPP.ts +16 -16
  74. package/src/@modules/@xmpp/ReconnectXMPP.ts +27 -27
  75. package/src/@modules/@xmpp/StanzaXMPP.ts +23 -23
  76. package/src/@parsers/@hvtec/HVExtract.ts +9 -9
  77. package/src/@parsers/@text/GetDescriptionFromProduct.ts +18 -19
  78. package/src/@parsers/@text/GetEmbededText.ts +3 -3
  79. package/src/@parsers/@text/GetStringText.ts +6 -6
  80. package/src/@parsers/@text/GetTextFromProduct.ts +10 -10
  81. package/src/@parsers/@text/GetXML.ts +5 -5
  82. package/src/@parsers/@ugc/GetCache.ts +2 -2
  83. package/src/@parsers/@ugc/{GetUGCHeader.ts → GetHeader.ts} +2 -2
  84. package/src/@parsers/@ugc/GetLocations.ts +5 -5
  85. package/src/@parsers/@ugc/GetZonePolygon.ts +10 -10
  86. package/src/@parsers/@ugc/GetZones.ts +1 -1
  87. package/src/@parsers/@ugc/SetCache.ts +11 -6
  88. package/src/@parsers/@ugc/UGCExtract.ts +10 -10
  89. package/src/@parsers/{@pvtec → @vtec}/VTECExtract.ts +19 -19
  90. package/src/@tasks/CreateTasks.ts +110 -0
  91. package/src/@tasks/TaskGenerateAudio.ts +34 -0
  92. package/src/@tasks/TaskGenerateJSON.ts +34 -0
  93. package/src/@tasks/TaskGenerateText.ts +34 -0
  94. package/src/@tasks/TaskSendNTFY.ts +91 -0
  95. package/src/@tasks/TaskSendWebhook.ts +100 -0
  96. package/src/@types/HVTEC.ts +4 -4
  97. package/src/@types/Hash.ts +3 -3
  98. package/src/@types/Settings.ts +1 -1
  99. package/src/@types/StanzaCompiled.ts +13 -13
  100. package/src/@types/UGC.ts +3 -3
  101. package/src/@types/VTEC.ts +10 -10
  102. package/src/{@types → @types-lower}/Event.ts +4 -4
  103. package/src/{@types → @types-lower}/Properties.ts +2 -1
  104. package/src/{@types → @types-lower}/Stanza.ts +1 -1
  105. package/src/bootstrap.ts +26 -26
  106. package/src/index.ts +30 -27
  107. package/tools/build.js +45 -0
  108. package/tsconfig.json +21 -1
  109. package/src/@manager/Tasks.ts +0 -246
  110. package/tsup.config.ts +0 -16
  111. /package/src/@parsers/{@pvtec → @vtec}/GetExpiry.ts +0 -0
  112. /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
+ }
@@ -18,8 +18,8 @@
18
18
  */
19
19
 
20
20
  export type TypeHVTEC = {
21
- hvtec: string
22
- severity: string
23
- cause: string
24
- record: string
21
+ HVTEC: string
22
+ Severity: string
23
+ Cause: string
24
+ Record: string
25
25
  }
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  export type TypeHash = {
21
- tracking: string
22
- hashes: string[]
23
- expires: string
21
+ Tracking: string
22
+ Hashes: string[]
23
+ Expires: string
24
24
  }
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeActions } from "./Actions"
20
+ import { TypeActions } from "types/Actions"
21
21
 
22
22
  type TypeTimezones = string | "CST" | "CDT" | "MDT" | "MST" | "EST" | "EDT" | "HST" | "HDT" | "PDT" | "UTC"
23
23
 
@@ -17,20 +17,20 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeAttributes } from "./Attributes"
20
+ import { TypeAttributes } from "types-lower/Attributes"
21
21
 
22
22
  export type TypeStanzaCompiled = {
23
- message?: string
24
- attributes?: TypeAttributes
25
- isCapEvent?: boolean
26
- isVTEC?: boolean
27
- isUGC?: boolean
28
- isCapAreaDescription?: boolean
29
- isIgnored?: boolean
30
- isNWWS?: boolean
31
- getType?: {
32
- type: string
33
- prefix: string
34
- discovered: boolean
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
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  export type TypeUGC = {
21
- zones: string[]
22
- locations: string[]
23
- expires: string
21
+ Zones: string[]
22
+ Locations: string[]
23
+ Expires: string
24
24
  }
@@ -17,14 +17,14 @@
17
17
 
18
18
  */
19
19
 
20
- export type TypePVTEC = {
21
- vtec: string
22
- product: string
23
- tracking: string
24
- event: string
25
- status: string
26
- organization: string
27
- expires: string
28
- is_watch: boolean
29
- prediction_center: boolean
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 "./HVTEC";
22
- import { TypePVTEC } from "./VTEC";
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?: TypePVTEC | null
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: {
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- export type TypeStanza = {
20
+ export type TypeStanza = { // This should be the only thing that isn't touched
21
21
  getChild(arg0: string): unknown
22
22
  is(arg0: string): unknown
23
23
  name: string
package/src/bootstrap.ts CHANGED
@@ -17,35 +17,35 @@
17
17
 
18
18
  */
19
19
 
20
- import path from 'path'
21
- import { EventEmitter } from 'node:events';
20
+ import path from "path"
21
+ import { EventEmitter } from "node:events"
22
22
 
23
- export const bootstrap = {
24
- version: `3.0.61`,
25
- isReady: true,
26
- ratelimits: {},
27
- session_xmpp: null,
28
- database: null,
29
- cron: null,
30
- listener: new EventEmitter(),
31
- ansi_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`
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
- cache: {
37
- lastStanza: null,
38
- isConnected: false,
39
- isReconnecting: false,
40
- tReconnects: 0,
41
- sigHault: false,
42
- events: {type: "FeatureCollection", features: []},
43
- nodes: {type: "FeatureCollection", features: []},
44
- hashes: [],
45
- processed: [],
46
- ugc: new Map<string, string[]>()
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
- settings: {
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 './@types/Settings'
21
- import { SetSettings } from "./@modules/@utilities/SetSettings"
22
- import { GetEventGeometry } from "./@building/GetEventGeometry";
23
- import { GetCleanedEvent } from "./@building/GetCleanedEvent"
24
- import { SetEventEmit } from './@modules/@utilities/SetEventEmit';
25
- import { SetWarning } from './@modules/@utilities/SetWarning';
26
- import { CreateListener } from "./@core/CreateListener"
27
- import { StartService } from "./@core/StartService"
28
- import { StopService } from "./@core/StopService"
29
- import { GenerateEASMessage } from './@modules/@eas/GenerateEASMessage';
30
- import { SetNode } from "./@core/SetNode"
31
- import { GetEvents } from "./@core/GetEvents"
32
- import { GetNodes } from "./@core/GetNodes"
33
- import { ManualEvent } from "./@core/ManualEvent"
34
- import { GetRandomEvent } from './@core/GetRandomEvent';
35
- import { QueryStanza } from './@core/QueryStanza';
36
- import { ClearEvents } from './@core/ClearEvents';
20
+ import { TypeSettings } from "types/Settings"
21
+ import { 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) { this.trycatch(); StartService(settings) }
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
- event: `onServiceStatus`,
51
- metadata: {
52
- message: `Ignored Critical Error: ${err?.code ?? 'Unknown error code'}. This may indicate a connection issue. Attempting to continue...`,
53
- data: {},
54
- type: `error`,
55
- error: true
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({message: `Uncaught Exception: ${err instanceof Error ? err.stack ?? err.message : String(err)}`})
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 './@types/Event';
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
  }