@atmosx/event-product-parser 3.0.62 → 3.0.622

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 (92) hide show
  1. package/README.md +6 -4
  2. package/dist/cjs/index.cjs +21171 -6858
  3. package/dist/esm/index.mjs +21270 -6957
  4. package/package.json +49 -47
  5. package/pnpm-workspace.yaml +3 -0
  6. package/src/@building/CreateEvent.ts +10 -12
  7. package/src/@building/GetEventAttachments.ts +5 -5
  8. package/src/@building/GetEventEnhancedName.ts +2 -4
  9. package/src/@building/GetEventGeometry.ts +4 -4
  10. package/src/@building/GetEventHeader.ts +2 -2
  11. package/src/@building/GetEventNodes.ts +8 -8
  12. package/src/@building/GetEventOffice.ts +3 -3
  13. package/src/@building/GetEventProperties.ts +16 -11
  14. package/src/@building/GetEventSignature.ts +6 -6
  15. package/src/@building/GetEventTags.ts +1 -1
  16. package/src/@building/GetEventTracking.ts +4 -4
  17. package/src/@core/ClearEvents.ts +2 -2
  18. package/src/@core/CreateListener.ts +1 -1
  19. package/src/@core/GetEvents.ts +1 -1
  20. package/src/@core/GetNodes.ts +1 -1
  21. package/src/@core/GetRandomEvent.ts +1 -1
  22. package/src/@core/GetVersion.ts +1 -1
  23. package/src/@core/ManualEvent.ts +3 -4
  24. package/src/@core/QueryStanza.ts +2 -2
  25. package/src/@core/SetNode.ts +9 -3
  26. package/src/@core/StartService.ts +11 -11
  27. package/src/@core/StopService.ts +1 -1
  28. package/src/@enums/Tags.ts +1 -1
  29. package/src/@events/ParseAPI.ts +15 -10
  30. package/src/@events/ParseText.ts +8 -8
  31. package/src/@events/ParseUGC.ts +9 -9
  32. package/src/@events/ParseVTEC.ts +12 -12
  33. package/src/@manager/MakeEvents.ts +20 -17
  34. package/src/@manager/RemoveEvent.ts +8 -8
  35. package/src/@manager/SetHash.ts +3 -3
  36. package/src/@manager/UpdateEvents.ts +4 -4
  37. package/src/@manager/UpdateNode.ts +4 -4
  38. package/src/@manager/ValidateEvents.ts +13 -14
  39. package/src/@modules/@database/GetCachedEvents.ts +6 -7
  40. package/src/@modules/@database/ImportBroadcastify.ts +3 -3
  41. package/src/@modules/@database/ImportShapefiles.ts +11 -11
  42. package/src/@modules/@database/ImportStanza.ts +4 -4
  43. package/src/@modules/@database/InitializeDatabase.ts +6 -6
  44. package/src/@modules/@eas/GenerateEASMessage.ts +26 -18
  45. package/src/@modules/@eas/GetTTS.ts +2 -2
  46. package/src/@modules/@eas/SetNoise.ts +2 -2
  47. package/src/@modules/@eas/SetRadioEffect.ts +2 -2
  48. package/src/@modules/@eas/SetSameHeader.ts +3 -3
  49. package/src/@modules/@stanza/GetAwipsType.ts +2 -2
  50. package/src/@modules/@stanza/ValidateStanza.ts +4 -4
  51. package/src/@modules/@utilities/GetSettings.ts +2 -2
  52. package/src/@modules/@utilities/QueueManager.ts +71 -0
  53. package/src/@modules/@utilities/SetCronSchedule.ts +8 -8
  54. package/src/@modules/@utilities/SetDebug.ts +2 -2
  55. package/src/@modules/@utilities/SetEventEmit.ts +3 -3
  56. package/src/@modules/@utilities/SetListener.ts +1 -1
  57. package/src/@modules/@utilities/SetSettings.ts +2 -2
  58. package/src/@modules/@utilities/SetTimeoutAction.ts +1 -1
  59. package/src/@modules/@utilities/SetWarning.ts +2 -2
  60. package/src/@modules/@xmpp/DeployXMPP.ts +8 -8
  61. package/src/@modules/@xmpp/ErrorXMPP.ts +1 -1
  62. package/src/@modules/@xmpp/OfflineXMPP.ts +2 -2
  63. package/src/@modules/@xmpp/OnlineXMPP.ts +3 -3
  64. package/src/@modules/@xmpp/ReconnectXMPP.ts +4 -4
  65. package/src/@modules/@xmpp/StanzaXMPP.ts +6 -6
  66. package/src/@parsers/@hvtec/HVExtract.ts +5 -5
  67. package/src/@parsers/@pvtec/VTECExtract.ts +7 -7
  68. package/src/@parsers/@text/GetDescriptionFromProduct.ts +1 -1
  69. package/src/@parsers/@text/GetEmbededText.ts +3 -3
  70. package/src/@parsers/@text/GetStringText.ts +5 -5
  71. package/src/@parsers/@ugc/GetCache.ts +1 -1
  72. package/src/@parsers/@ugc/GetLocations.ts +3 -3
  73. package/src/@parsers/@ugc/GetUGCHeader.ts +1 -1
  74. package/src/@parsers/@ugc/GetZonePolygon.ts +2 -2
  75. package/src/@parsers/@ugc/SetCache.ts +1 -1
  76. package/src/@parsers/@ugc/UGCExtract.ts +5 -5
  77. package/src/@tasks/CreateTasks.ts +110 -0
  78. package/src/@tasks/TaskGenerateAudio.ts +35 -0
  79. package/src/@tasks/TaskGenerateJSON.ts +35 -0
  80. package/src/@tasks/TaskGenerateText.ts +35 -0
  81. package/src/@tasks/TaskSendNTFY.ts +93 -0
  82. package/src/@tasks/TaskSendWebhook.ts +101 -0
  83. package/src/@types/Event.ts +3 -3
  84. package/src/@types/Properties.ts +2 -1
  85. package/src/@types/Settings.ts +1 -1
  86. package/src/@types/StanzaCompiled.ts +1 -1
  87. package/src/bootstrap.ts +3 -3
  88. package/src/index.ts +21 -19
  89. package/tools/build.js +45 -0
  90. package/tsconfig.json +20 -1
  91. package/src/@manager/Tasks.ts +0 -246
  92. package/tsup.config.ts +0 -16
@@ -17,9 +17,9 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
21
- import { SetTimeoutAction } from "./SetTimeoutAction";
22
- import { SetWarning } from "./SetWarning";
20
+ import { bootstrap } from "@bootstrap"
21
+ import { SetTimeoutAction } from "@utilities/SetTimeoutAction"
22
+ import { SetWarning } from "@utilities/SetWarning"
23
23
 
24
24
  interface SetEventEmitOptions {
25
25
  event: string
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
20
+ import { bootstrap } from "@bootstrap"
21
21
 
22
22
  interface SetListenerOptions {
23
23
  event: string,
@@ -17,8 +17,8 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from '../../@types/Settings'
21
- import { bootstrap } from "../../bootstrap"
20
+ import { TypeSettings } from "types/Settings"
21
+ import { bootstrap } from "@bootstrap"
22
22
 
23
23
  export const SetSettings = (newSettings: TypeSettings): TypeSettings => {
24
24
  const settings = bootstrap.settings as Record<string, unknown>;
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
20
+ import { bootstrap } from "@bootstrap"
21
21
 
22
22
  interface SetTimeoutActionOptions {
23
23
  identifier: string
@@ -17,8 +17,8 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
21
- import { TypeSettings } from "../../@types/Settings";
20
+ import { bootstrap } from "@bootstrap"
21
+ import { TypeSettings } from "types/Settings"
22
22
 
23
23
  interface SetWarningOptions {
24
24
  title?: string
@@ -17,14 +17,14 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from "../../@types/Settings";
21
- import { bootstrap } from "../../bootstrap"
22
- import { OnlineXMPP } from "./OnlineXMPP";
23
- import { OfflineXMPP } from "./OfflineXMPP";
24
- import { ErrorXMPP } from "./ErrorXMPP";
25
- import { StanzaXMPP } from "./StanzaXMPP";
26
- import { SetEventEmit } from '../@utilities/SetEventEmit';
27
- import { client } from '@xmpp/client';
20
+ import { TypeSettings } from "types/Settings"
21
+ import { bootstrap } from "@bootstrap"
22
+ import { OnlineXMPP } from "@xmpp/OnlineXMPP"
23
+ import { OfflineXMPP } from "@xmpp/OfflineXMPP"
24
+ import { ErrorXMPP } from "@xmpp/ErrorXMPP"
25
+ import { StanzaXMPP } from "@xmpp/StanzaXMPP"
26
+ import { SetEventEmit } from "@utilities/SetEventEmit"
27
+ import { client } from "@xmpp/client"
28
28
 
29
29
  export const DeployXMPP = async (): Promise<void> => {
30
30
  let session;
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
20
+ import { bootstrap } from "@bootstrap"
21
21
 
22
22
  export const ErrorXMPP = () => {
23
23
  bootstrap.session_xmpp.on(`error`, async (error: Error) => {
@@ -17,8 +17,8 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
21
- import { SetEventEmit } from "../@utilities/SetEventEmit";
20
+ import { bootstrap } from "@bootstrap"
21
+ import { SetEventEmit } from "@utilities/SetEventEmit"
22
22
 
23
23
  export const OfflineXMPP = () => {
24
24
  bootstrap.session_xmpp.on(`offline`, async () => {
@@ -17,9 +17,9 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
21
- import { SetEventEmit } from '../@utilities/SetEventEmit';
22
- import { xml } from '@xmpp/client'
20
+ import { bootstrap } from "@bootstrap"
21
+ import { SetEventEmit } from "@utilities/SetEventEmit"
22
+ import { xml } from "@xmpp/client"
23
23
 
24
24
  export const OnlineXMPP = () => {
25
25
  const settings = bootstrap.settings;
@@ -17,10 +17,10 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeSettings } from "../../@types/Settings";
21
- import { bootstrap } from "../../bootstrap"
22
- import { SetEventEmit } from "../@utilities/SetEventEmit";
23
- import { SetWarning } from "../@utilities/SetWarning";
20
+ import { TypeSettings } from "types/Settings"
21
+ import { bootstrap } from "@bootstrap"
22
+ import { SetEventEmit } from "@utilities/SetEventEmit"
23
+ import { SetWarning } from "@utilities/SetWarning"
24
24
 
25
25
  export const ReconnectXMPP = async (interval: number): Promise<void> => {
26
26
  const settings = bootstrap.settings as TypeSettings;
@@ -17,12 +17,12 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeStanza } from "../../@types/Stanza";
21
- import { bootstrap } from "../../bootstrap";
22
- import { ValidateStanza } from "../@stanza/ValidateStanza";
23
- import { CreateEvent } from "../../@building/CreateEvent";
24
- import { ImportStanza } from "../@database/ImportStanza";
25
- import { SetEventEmit } from "../@utilities/SetEventEmit";
20
+ import { TypeStanza } from "types/Stanza"
21
+ import { bootstrap } from "@bootstrap"
22
+ import { ValidateStanza } from "@stanza/ValidateStanza"
23
+ import { CreateEvent } from "@building/CreateEvent"
24
+ import { ImportStanza } from "@database/ImportStanza"
25
+ import { SetEventEmit } from "@utilities/SetEventEmit"
26
26
 
27
27
  export const StanzaXMPP = () => {
28
28
  bootstrap.session_xmpp.on(`stanza`, async (stanza: TypeStanza) => {
@@ -17,11 +17,11 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeHVTEC } from "../../@types/HVTEC";
21
- import { EnumCauses } from "../../@enums/Causes";
22
- import { EnumRecords } from "../../@enums/Records";
23
- import { EnumExpressions } from "../../@enums/Expressions";
24
- import { EnumSeverity } from "../../@enums/Severity";
20
+ import { TypeHVTEC } from "types/HVTEC"
21
+ import { EnumCauses } from "@enums/Causes"
22
+ import { EnumRecords } from "@enums/Records"
23
+ import { EnumExpressions } from "@enums/Expressions"
24
+ import { EnumSeverity } from "@enums/Severity"
25
25
 
26
26
  export const HVExtract = (message: string): TypeHVTEC[] | null => {
27
27
  const getHVTECs = message.match(EnumExpressions.hvtec) ?? [];
@@ -17,13 +17,13 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypePVTEC } from "../../@types/VTEC";
21
- import { EnumExpressions } from "../../@enums/Expressions";
22
- import { EnumProducts } from "../../@enums/Products";
23
- import { EnumEvents } from "../../@enums/Events";
24
- import { EnumActions } from "../../@enums/Actions";
25
- import { EnumStatus } from "../../@enums/Status";
26
- import { GetExpiry } from "./GetExpiry";
20
+ import { TypePVTEC } from "types/VTEC"
21
+ import { EnumExpressions } from "@enums/Expressions"
22
+ import { EnumProducts } from "@enums/Products"
23
+ import { EnumEvents } from "@enums/Events"
24
+ import { EnumActions } from "@enums/Actions"
25
+ import { EnumStatus } from "@enums/Status"
26
+ import { GetExpiry } from "@parsers/pvtec/GetExpiry"
27
27
 
28
28
  export const VTECExtract = (message: string): TypePVTEC[] | null => {
29
29
  if (!message) return null;
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { EnumExpressions } from "../../@enums/Expressions";
20
+ import { EnumExpressions } from "@enums/Expressions"
21
21
 
22
22
  interface GetDescriptionFromProductOptions {
23
23
  message: string
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../../@types/Event"
20
+ import { TypeEvent } from "types/Event"
21
21
 
22
22
  export const GetEmebedText = (event: TypeEvent): string => {
23
23
  const line = (label: string, value: unknown, condition = true) => condition && value ? `${label} ${value}` : null;
@@ -30,8 +30,8 @@ export const GetEmebedText = (event: TypeEvent): string => {
30
30
  line(`**Damage Threat:**`, event?.properties?.parameters?.damage_threat, !isExpired),
31
31
  line(`**Flood Threat:**`, event?.properties?.parameters?.flood_threat, !isExpired),
32
32
  line(`**Tornado Threat:**`, event?.properties?.parameters?.tornado_threat, !isExpired),
33
- line(`**Estimated Wind Gusts:**`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
34
- line(`**Estimated Hail Size:**`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
33
+ line(`**Wind Gusts:**`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
34
+ line(`**Hail Size:**`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
35
35
  line(`**Discussion:**`, event?.properties?.discussion_parameters?.discussion_number, !isExpired),
36
36
  line(`**Concern:**`, event?.properties?.discussion_parameters?.discussion_concerning, !isExpired),
37
37
  line(`**SPC Max Tornado Threat:**`, event?.properties?.discussion_parameters?.discussion_max_tornado, !isExpired),
@@ -17,9 +17,9 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeEvent } from "../../@types/Event"
21
- import { TypeSettings } from "../../@types/Settings";
22
- import { bootstrap } from "../../bootstrap";
20
+ import { TypeEvent } from "types/Event"
21
+ import { TypeSettings } from "types/Settings"
22
+ import { bootstrap } from "@bootstrap"
23
23
 
24
24
  export const GetStringText = (event: TypeEvent): string => {
25
25
  const settings = bootstrap.settings as TypeSettings;
@@ -34,8 +34,8 @@ export const GetStringText = (event: TypeEvent): string => {
34
34
  line(`Damage Threat:`, event?.properties?.parameters?.damage_threat, !isExpired),
35
35
  line(`Flood Threat:`, event?.properties?.parameters?.flood_threat, !isExpired),
36
36
  line(`Tornado Threat:`, event?.properties?.parameters?.tornado_threat, !isExpired),
37
- line(`Estimated Wind Gusts:`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
38
- line(`Estimated Hail Size:`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
37
+ line(`Wind Gusts:`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
38
+ line(`Hail Size:`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
39
39
  line(`Discussion:`, event?.properties?.discussion_parameters?.discussion_number, !isExpired),
40
40
  line(`Concern:`, event?.properties?.discussion_parameters?.discussion_concerning, !isExpired),
41
41
  line(`SPC Max Tornado Threat:`, event?.properties?.discussion_parameters?.discussion_max_tornado, !isExpired),
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
20
+ import { bootstrap } from "@bootstrap"
21
21
 
22
22
  export const getCache = (key: string) => {
23
23
  return bootstrap.cache.ugc.get(key);
@@ -17,9 +17,9 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
21
- import { getCache } from "./GetCache";
22
- import { setCache } from "./SetCache";
20
+ import { bootstrap } from "@bootstrap"
21
+ import { getCache } from "@parsers/ugc/GetCache"
22
+ import { setCache } from "@parsers/ugc/SetCache"
23
23
 
24
24
  export const getLocations = async (zones: string[]): Promise<string[]> => {
25
25
  const uniqueZones = Array.from(new Set(zones));
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { EnumExpressions } from "../../@enums/Expressions"
20
+ import { EnumExpressions } from "@enums/Expressions"
21
21
 
22
22
  export const getUGCHeader = (message: string): string | null => {
23
23
  const start = message.search(EnumExpressions.ugc1)
@@ -17,8 +17,8 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap"
21
- import { union } from "polygon-clipping";
20
+ import { bootstrap } from "@bootstrap"
21
+ import { union } from "polygon-clipping"
22
22
 
23
23
  interface CoordinatesOptions {
24
24
  zones: string[]
@@ -17,7 +17,7 @@
17
17
 
18
18
  */
19
19
 
20
- import { bootstrap } from "../../bootstrap";
20
+ import { bootstrap } from "@bootstrap"
21
21
 
22
22
  export const setCache = (key: string, value: string[]) => {
23
23
  if (bootstrap.cache.ugc.size >= 5000) {
@@ -17,11 +17,11 @@
17
17
 
18
18
  */
19
19
 
20
- import { TypeUGC } from "../../@types/UGC";
21
- import { getUGCHeader } from "./GetUGCHeader"
22
- import { getZones } from "./GetZones";
23
- import { GetExpiry } from './GetExpiry';
24
- import { getLocations } from "./GetLocations";
20
+ import { TypeUGC } from "types/UGC"
21
+ import { getUGCHeader } from "@parsers/ugc/GetUGCHeader"
22
+ import { getZones } from "@parsers/ugc/GetZones"
23
+ import { GetExpiry } from "@parsers/ugc/GetExpiry"
24
+ import { getLocations } from "@parsers/ugc/GetLocations"
25
25
 
26
26
  export const ugcExtract = async (message: string): Promise<TypeUGC> => {
27
27
  const head = getUGCHeader(message);
@@ -0,0 +1,110 @@
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
+ import { TypeSettings } from "types/Settings"
20
+ import { TypeEvent } from "types/Event"
21
+ import { TypeActions } from "types/Actions"
22
+ import { bootstrap } from "@bootstrap"
23
+ import { SetDebug } from "@utilities/SetDebug"
24
+ import { GetMatched } from "@utilities/GetMatched"
25
+ import { GetStringText } from "@parsers/text/GetStringText"
26
+ import { GetCleanedEvent } from "@building/GetCleanedEvent"
27
+ import { TaskGenerateAudio } from "@tasks/TaskGenerateAudio"
28
+ import { TaskGenerateText } from "@tasks/TaskGenerateText"
29
+ import { TaskGenerateJSON } from "@tasks/TaskGenerateJSON"
30
+ import { TaskSendNTFY } from "@tasks/TaskSendNTFY"
31
+ import { TaskSendWebhook } from "@tasks/TaskSendWebhook"
32
+ import { QueueManager } from "@utilities/QueueManager"
33
+
34
+ const Webhooks = new QueueManager({ concurrency: 1 });
35
+ const NTFY = new QueueManager({ concurrency: 5 });
36
+
37
+ export const CreateTasks = async (events: TypeEvent[]): Promise<void> => {
38
+ const tick = performance.now()
39
+ const settings = bootstrap.settings as TypeSettings;
40
+ const { ActionSettings, GlobalSettings, NotifyServer } = settings;
41
+ const actions = ActionSettings as TypeActions[];
42
+
43
+ for (const event of events) {
44
+ const { properties } = event;
45
+ const isActioning = Array.isArray(actions) && actions.length > 0;
46
+ if (!isActioning) { continue }
47
+
48
+ for (const action of actions) {
49
+ const { Events, Webhook, NotificationServer, Uploads } = action;
50
+ const isValidAction = GetMatched(Events, properties.event)
51
+ if ((Events.length == 0 || isValidAction)) {
52
+ const a = performance.now();
53
+ const [eas, text, json] = await Promise.all([
54
+ Uploads?.EAS ? TaskGenerateAudio({
55
+ filename: (`${properties.event}_${properties.metadata.tracking}`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim(),
56
+ description: properties.description,
57
+ header: properties.metadata.header
58
+ }).then((result) => { return result; }) : Promise.resolve(null),
59
+
60
+ Uploads?.TEXT ? TaskGenerateText({
61
+ string: properties.metadata.raw,
62
+ directory: GlobalSettings?.ArchiveSettings?.TextDirectory,
63
+ filename: (`${properties.event}_${properties.metadata.tracking}.txt`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim()
64
+ }).then((result) => { return result; }) : Promise.resolve(null),
65
+
66
+ Uploads?.JSON ? TaskGenerateJSON({
67
+ string: JSON.stringify(GetCleanedEvent(event), null, 2),
68
+ directory: GlobalSettings?.ArchiveSettings?.JSONDirectory,
69
+ filename: (`${properties.event}_${properties.metadata.tracking}.json`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim()
70
+ }).then((result) => { return result; }) : Promise.resolve(null),
71
+ ]);
72
+
73
+ SetDebug({ title: `Tasks/Generative`, message: `${Math.round(performance.now() - a)}ms` })
74
+
75
+ const b = performance.now();
76
+ await Promise.all([
77
+ NotificationServer?.Enabled && NotifyServer?.Enabled && NotificationServer?.Topic ? NTFY.enqueue(() => TaskSendNTFY({
78
+ event: event,
79
+ toggles: {
80
+ eas: Uploads?.EAS,
81
+ json: Uploads?.JSON,
82
+ text: Uploads?.TEXT
83
+ },
84
+ priority: NotificationServer?.Priority ?? 5,
85
+ body: GetStringText(event),
86
+ topic: NotificationServer?.Topic
87
+ })) : Promise.resolve(null),
88
+ Webhook?.Enabled && Webhook?.Destination ? Webhooks.enqueue(() => TaskSendWebhook({
89
+ event: event,
90
+ webhook: {
91
+ enabled: Webhook?.Enabled,
92
+ destination: Webhook?.Destination,
93
+ message: Webhook?.Message,
94
+ title: Webhook?.Title,
95
+ ratelimit: Webhook?.Ratelimit
96
+ },
97
+ attachments: {
98
+ text: text,
99
+ eas: eas,
100
+ json: json
101
+ }
102
+ })) : Promise.resolve(null)
103
+ ]);
104
+ SetDebug({ title: `Tasks/Send`, message: `${Math.round(performance.now() - b)}ms` })
105
+ }
106
+ }
107
+ SetDebug({ title: `Tasks/CompletedEventTask`, message: `${Math.round(performance.now() - tick)}ms` })
108
+ }
109
+ SetDebug({ title: `Tasks/Global`, message: `${Math.round(performance.now() - tick)}ms` })
110
+ }
@@ -0,0 +1,35 @@
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 { GenerateEASMessage } from "@eas/GenerateEASMessage"
21
+
22
+ interface TaskGenerateAudioOptions {
23
+ filename: string;
24
+ description: string;
25
+ header: string;
26
+ }
27
+
28
+ export const TaskGenerateAudio = async function(options: TaskGenerateAudioOptions): Promise<string> {
29
+ const { filename, description, header } = options;
30
+ return await GenerateEASMessage({
31
+ title: filename,
32
+ message: description,
33
+ header: header
34
+ });
35
+ }
@@ -0,0 +1,35 @@
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 { mkdir, writeFile } from "fs/promises"
21
+
22
+ interface TaskGenerateJSONOptions {
23
+ string: string;
24
+ directory: string;
25
+ filename: string;
26
+ }
27
+
28
+ export const TaskGenerateJSON = async function(options: TaskGenerateJSONOptions): Promise<string> {
29
+ const { string, directory, filename } = options;
30
+ if (directory) {
31
+ await mkdir(directory, { recursive: true });
32
+ await writeFile(directory + "/" + filename, `${string}${"\n".repeat(5)}`);
33
+ }
34
+ return string;
35
+ }
@@ -0,0 +1,35 @@
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 { mkdir, appendFile } from "fs/promises"
21
+
22
+ interface TaskGenerateText {
23
+ string: string;
24
+ directory: string;
25
+ filename: string;
26
+ }
27
+
28
+ export const TaskGenerateText = async function(options: TaskGenerateText): Promise<string> {
29
+ const { string, directory, filename } = options;
30
+ if (directory) {
31
+ await mkdir(directory, { recursive: true });
32
+ await appendFile(directory + "/" + filename, `${string}${"\n".repeat(5)}`);
33
+ }
34
+ return string;
35
+ }
@@ -0,0 +1,93 @@
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/Event"
21
+ import { bootstrap } from "@bootstrap"
22
+ import { CreateHttp } from "@utilities/CreateHttp";
23
+ import { SetDebug } from "@utilities/SetDebug";
24
+ import { SetTimeoutAction } from "@utilities/SetTimeoutAction";
25
+
26
+ interface TaskSendNTFYOptions {
27
+ event: TypeEvent;
28
+ toggles?: {
29
+ eas?: boolean;
30
+ json?: boolean;
31
+ text?: boolean;
32
+ },
33
+ priority: string | number;
34
+ body: string;
35
+ topic: string;
36
+ }
37
+
38
+ export const TaskSendNTFY = async function(options: TaskSendNTFYOptions): Promise<void> {
39
+ const { event, toggles, priority, body, topic } = options;
40
+ const { properties } = event;
41
+
42
+ const configurations = bootstrap.settings.NotifyServer;
43
+ const authentication = configurations?.Credentials?.Username && configurations?.Credentials?.Password ? {
44
+ username: configurations.Credentials.Username,
45
+ password: configurations.Credentials.Password
46
+ } : undefined;
47
+ const image = properties.metadata.attachments?.find(a => a.name === "Image: Graphic");
48
+
49
+ const buttons = [
50
+ ...(toggles?.eas && configurations?.MediaStorage?.EAS ? [{
51
+ "action": "view",
52
+ "label": "Listen",
53
+ "url": `${configurations.MediaStorage.EAS}/${properties.event}_${properties.metadata.tracking}.wav`,
54
+ }] : []),
55
+ ...(toggles?.text && configurations?.MediaStorage?.TEXT ? [{
56
+ "action": "view",
57
+ "label": "View Text",
58
+ "url": `${configurations.MediaStorage.TEXT}/${properties.event}_${properties.metadata.tracking}.txt`,
59
+ }] : []),
60
+ ...(image ? [{
61
+ "action": "view",
62
+ "label": "View Image",
63
+ "url": image.link,
64
+ }] : []),
65
+ ];
66
+
67
+ const headers = {
68
+ "Title": `${properties.event} (${properties.status})`,
69
+ "Tags": properties.parameters.tags?.join(",") ?? "N/A",
70
+ "Priority": priority ?? "5",
71
+ ...(buttons.length > 0 && { "Actions": JSON.stringify(buttons) }),
72
+ };
73
+
74
+ const post = async (topic: string) => {
75
+ const response = await CreateHttp({
76
+ url: `${configurations?.Server?.replace(/\/$/, "")}/${topic}`,
77
+ timeout: 15_000,
78
+ method: "PUT",
79
+ ...(authentication && { auth: authentication }),
80
+ headers,
81
+ body
82
+ })
83
+ if (response.error) {
84
+ SetDebug({ title: `Tasks/NTFY`, message: `Failed to send notification to topic "${topic}": ${response.message}` })
85
+ }
86
+ }
87
+ const topics = [
88
+ topic,
89
+ ...(properties.metadata.filtered_proximity ? [`${topic}-LOCAL`] : []),
90
+ ];
91
+
92
+ await Promise.all([...new Set(topics)].map(post));
93
+ }