@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
@@ -1,246 +0,0 @@
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 { TypeSettings } from "../@types/Settings";
21
- import { TypeEvent } from "../@types/Event";
22
- import { TypeActions } from "../@types/Actions";
23
- import { bootstrap } from "../bootstrap"
24
- import { GenerateEASMessage } from "../@modules/@eas/GenerateEASMessage"
25
- import { SetTimeoutAction } from "../@modules/@utilities/SetTimeoutAction";
26
- import { GetEmebedText } from "../@parsers/@text/GetEmbededText";
27
- import { GetStringText } from "../@parsers/@text/GetStringText";
28
- import { GetCleanedEvent } from "../@building/GetCleanedEvent"
29
- import { CreateHttp } from "../@modules/@utilities/CreateHttp";
30
- import { SetDebug } from "../@modules/@utilities/SetDebug";
31
- import { GetMatched } from "../@modules/@utilities/GetMatched";
32
- import { mkdir, writeFile, readFile, appendFile } from "fs/promises";
33
-
34
- export const Tasks = async (events: TypeEvent[]): Promise<void> => {
35
- const tick = performance.now()
36
- const settings = bootstrap.settings as TypeSettings;
37
- const notifyServer = settings.NotifyServer;
38
- const actions = settings.ActionSettings as TypeActions[];
39
- for (const event of events) {
40
- const properties = event.properties;
41
- const hasActions = Array.isArray(actions) && actions.length > 0;
42
- if (!hasActions) {
43
- SetDebug({ title: `Tasks`, message: `${Math.round(performance.now() - tick)}ms` });
44
- return;
45
- }
46
- const metadata = {
47
- text: null,
48
- eas: null,
49
- json: null,
50
- name: properties.event,
51
- status: properties.status,
52
- description: properties.description,
53
- tracking: properties.metadata.tracking,
54
- header: properties.metadata.header,
55
- raw: properties.metadata.raw,
56
- expired: properties.status_metadata.is_expired,
57
- attachments: properties.metadata.attachments
58
- }
59
-
60
- const archiveSettings = settings.GlobalSettings?.ArchiveSettings;
61
- const textArchiveDir = archiveSettings?.TextDirectory;
62
- const jsonArchiveDir = archiveSettings?.JSONDirectory;
63
- const eventBaseName = `${metadata.name}_${metadata.tracking}`;
64
- const easTitle = `${metadata.name}_${metadata.status}_${metadata.tracking}`;
65
- const cleanedEventText = JSON.stringify(GetCleanedEvent(event), null, 2);
66
- const stringText = GetStringText(event);
67
- const embedText = GetEmebedText(event);
68
-
69
- for (const action of actions) {
70
- const events = action?.Events;
71
- const webhook = action?.Webhook;
72
- const notify = action?.NotificationServer;
73
- const uploads = action?.Uploads
74
- const isMatched = GetMatched(events ?? [], metadata.name)
75
-
76
- if (events?.length == 0 || isMatched) {
77
- const t = performance.now()
78
-
79
- if (uploads?.EAS && !metadata.eas) {
80
- metadata.eas = await GenerateEASMessage({
81
- title: easTitle,
82
- message: metadata.description,
83
- header: metadata.header
84
- });
85
- SetDebug({
86
- title: "Tasks/EAS",
87
- message: `${Math.round(performance.now() - t)}ms`
88
- });
89
- }
90
-
91
- if (uploads?.TEXT && metadata.text === null) {
92
- const t = performance.now()
93
- if (textArchiveDir) {
94
- const file = (`${textArchiveDir}/${eventBaseName}.txt`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
95
- await mkdir(textArchiveDir, { recursive: true });
96
- await appendFile(file, `${"\n".repeat(7)}${metadata.raw}`);
97
- SetDebug({
98
- title: "Tasks/TEXT",
99
- message: `${Math.round(performance.now() - t)}ms`
100
- });
101
- }
102
- metadata.text = metadata.raw;
103
- }
104
-
105
- if (uploads?.JSON && metadata.json === null) {
106
- const t = performance.now()
107
- if (jsonArchiveDir) {
108
- const file = (`${jsonArchiveDir}/${eventBaseName}.json`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
109
- await mkdir(jsonArchiveDir, { recursive: true });
110
- await writeFile(file, cleanedEventText);
111
- SetDebug({
112
- title: "Tasks/JSON",
113
- message: `${Math.round(performance.now() - t)}ms`
114
- });
115
- }
116
- metadata.json = cleanedEventText;
117
- }
118
-
119
- if (notifyServer?.Enabled && notify?.Enabled && notify?.Topic) {
120
- let buttons = [];
121
- const t = performance.now()
122
- const auth = notifyServer?.Credentials?.Username && notifyServer?.Credentials?.Password ? { username: notifyServer?.Credentials?.Username, password: notifyServer?.Credentials?.Password } : undefined;
123
- const image = metadata.attachments?.find(a => a.name === "Image: Graphic");
124
-
125
-
126
- if (notifyServer?.MediaStorage?.EAS) {
127
- if (metadata.eas) {
128
- buttons.push({
129
- "action": "view",
130
- "label": "Listen",
131
- "url": `${notifyServer?.MediaStorage?.EAS}/${metadata.name}_${metadata.status}_${metadata.tracking}.wav`,
132
- })
133
- }
134
- }
135
- if (metadata.json) {
136
- buttons.push({
137
- "action": "view",
138
- "label": "View JSON",
139
- "url": `${notifyServer?.MediaStorage?.JSON}/${metadata.name}_${metadata.tracking}.json`,
140
- })
141
- }
142
- if (metadata.text) {
143
- buttons.push({
144
- "action": "view",
145
- "label": "View Text",
146
- "url": `${notifyServer?.MediaStorage?.TEXT}/${metadata.name}_${metadata.tracking}.txt`,
147
- })
148
- }
149
- if (image) {
150
- buttons.push({
151
- "action": "view",
152
- "label": "View Image",
153
- "url": image.link,
154
- })
155
- }
156
- await CreateHttp({
157
- url: `${notifyServer?.Server?.replace(/\/$/, "")}/${notify.Topic}`,
158
- timeout: 15_000,
159
- method: "PUT",
160
- ...(auth && { auth }),
161
- headers: {
162
- "Title": `${metadata.name} (${metadata.status})`,
163
- "Tags": properties.parameters.tags?.join(",") ?? "N/A",
164
- "Priority": notify?.Priority ?? "5",
165
- ... (buttons.length > 0 && { "Actions": JSON.stringify(buttons) }),
166
- },
167
- body: stringText
168
- })
169
- SetDebug({
170
- title: "Tasks/NTFY",
171
- message: `${Math.round(performance.now() - t)}ms`
172
- });
173
- }
174
-
175
- if (webhook?.Enabled && webhook?.Destination) {
176
- const t = performance.now()
177
- const isRatelimited = SetTimeoutAction({ identifier: webhook.Destination, interval: (webhook.Ratelimit ?? 2) * 2, max: (webhook.Ratelimit ?? 2), addTime: true })
178
- const form = new FormData();
179
- const embed = {
180
- title: `${metadata.name} (${metadata.status})`,
181
- description: embedText,
182
- fields: [],
183
- color: 16711680,
184
- timestamp: new Date().toISOString(),
185
- footer: { text: webhook.Title ?? `AtmosphericX` }
186
- };
187
-
188
- if (isRatelimited.limited) { return }
189
-
190
-
191
- if (metadata.description && !metadata.expired) {
192
- const description = metadata.description.length > 900
193
- ? metadata.description.substring(0, 900) + "\n\n[Message truncated due to length]"
194
- : metadata.description;
195
- embed.fields.push({
196
- name: "Description",
197
- value: description ? '```' + '\n' + description.split('\n').map(l => l.trim()).filter(Boolean).join('\n') + '\n' + '```' : ""
198
- });
199
- }
200
-
201
-
202
- if (metadata.attachments?.length > 0) {
203
- const attachments = metadata.attachments.slice(0, 5);
204
- embed.fields.push({
205
- name: "Attachments",
206
- value: attachments.map(attachment => `- [${attachment.name.length > 45 ? attachment.name.substring(0, 45) + '...' : attachment.name}](${attachment.link})`).join('\n')
207
- });
208
- }
209
-
210
- if (uploads?.TEXT) {
211
- form.append("fUpload", new Blob([Buffer.from(metadata.text)], {type: "application/text"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.txt`)
212
- }
213
-
214
- if (uploads?.JSON) {
215
- form.append("fUpload2", new Blob([Buffer.from(metadata.json)], {type: "application/json"}), `${properties.event}_${properties.status}_${properties.metadata.tracking}.json`)
216
- }
217
-
218
- if (uploads?.EAS) {
219
- if (metadata.eas) {
220
- const file = await readFile(metadata.eas);
221
- form.append("fEas", new Blob([Buffer.from(file)], { type: "audio/mpeg" }), `${properties.event}_${properties.status}_${properties.metadata.tracking}_eas.mp3`)
222
- }
223
- }
224
-
225
- form.append("payload_json", JSON.stringify({
226
- username: webhook.Title ?? "AtmosphericX",
227
- content: webhook.Message ?? "",
228
- embeds: [embed]
229
- }));
230
-
231
- await CreateHttp({
232
- url: webhook.Destination,
233
- timeout: 15e3,
234
- method: `POST`,
235
- body: form
236
- })
237
- SetDebug({
238
- title: "Tasks/Webhook",
239
- message: `${Math.round(performance.now() - t)}ms`
240
- });
241
- }
242
- }
243
- }
244
- }
245
- SetDebug({ title: `Tasks`, message: `${Math.round(performance.now() - tick)}ms` })
246
- }
package/tsup.config.ts DELETED
@@ -1,16 +0,0 @@
1
- import { defineConfig } from 'tsup'
2
-
3
- export default defineConfig({
4
- entry: ['src/index.ts'],
5
- outDir: 'dist',
6
- format: ['esm', 'cjs'],
7
- dts: false,
8
- noExternal: ["@xmpp/client", "@xmpp/sasl", "@xmpp/sasl-plain"],
9
- clean: true,
10
- outExtension({ format }) {
11
- return { js: format === 'esm' ? '.mjs' : '.cjs' }
12
- },
13
- esbuildOptions(options, context) {
14
- options.outdir = `dist/${context.format}`
15
- },
16
- })
File without changes
File without changes