@atmosx/event-product-parser 3.0.46 → 3.0.47
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/README.md +12 -1
- package/dist/cjs/index.cjs +381 -206
- package/dist/esm/index.mjs +381 -206
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/package.json +1 -1
- package/src/@building/building.attachments.ts +47 -6
- package/src/@building/building.properties.ts +1 -0
- package/src/@building/building.signature.ts +1 -1
- package/src/@core/core.createEvent.ts +1 -0
- package/src/@dictionaries/dictionaries.cancellation.ts +1 -0
- package/src/@dictionaries/dictionaries.expressions.ts +1 -0
- package/src/@dictionaries/dictionaries.states.ts +72 -0
- package/src/@events/events.api.ts +1 -0
- package/src/@manager/manager.updateListener.ts +105 -66
- package/src/@modules/@database/database.broadcastify.ts +67 -0
- package/src/@modules/@database/database.init.ts +14 -1
- package/src/@modules/@database/database.shapefiles.ts +1 -4
- package/src/@modules/@utilities/utilities.createHttp.ts +56 -47
- package/src/@modules/@utilities/utilities.setCronSchedule.ts +1 -0
- package/src/@modules/@xmpp/xmpp.xReconnect.ts +1 -1
- package/src/@parsers/@text/text.getEmbed.ts +0 -2
- package/src/@types/type.event.ts +1 -1
- package/src/@types/type.listener.ts +1 -1
- package/src/@types/type.properties.ts +1 -0
- package/src/@types/type.settings.ts +7 -1
- package/src/bootstrap.ts +7 -1
- package/test.js +12 -4
- /package/src/@dictionaries/{dictionaries.test.ts → dictionaries.testing.ts} +0 -0
|
@@ -31,55 +31,64 @@ interface CreateHttpOptions {
|
|
|
31
31
|
|
|
32
32
|
export const createHttp = async (options: CreateHttpOptions): Promise<any> => {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
request(requestOptions, (error, response, body) => {
|
|
53
|
-
if (error) {
|
|
54
|
-
return resolve({
|
|
55
|
-
error: true,
|
|
56
|
-
options: requestOptions,
|
|
57
|
-
status: -1,
|
|
58
|
-
message: error.message ?? `Unknown Error`
|
|
59
|
-
})
|
|
34
|
+
try {
|
|
35
|
+
const requestOptions = {
|
|
36
|
+
url: options.url ?? `https://api.weather.gov/alerts/active`,
|
|
37
|
+
headers: options.headers ?? {
|
|
38
|
+
"User-Agent": "AtmosphericX",
|
|
39
|
+
"Accept": "application/geo+json, text/plain, */*; q=0.9",
|
|
40
|
+
"Accept-Language": "en-US,en;q=0.9"
|
|
41
|
+
},
|
|
42
|
+
method: options.method ?? `GET`,
|
|
43
|
+
timeout: options.timeout ?? 10e3,
|
|
44
|
+
proxy: options.proxy ?? null,
|
|
45
|
+
maxRedirects: 1,
|
|
46
|
+
};
|
|
47
|
+
if (options.formData) {
|
|
48
|
+
requestOptions['formData'] = options.formData;
|
|
49
|
+
} else if (options.body) {
|
|
50
|
+
requestOptions['body'] = options.body;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
|
|
53
|
+
request(requestOptions, (error, response, body) => {
|
|
54
|
+
if (error) {
|
|
55
|
+
return resolve({
|
|
56
|
+
error: true,
|
|
57
|
+
options: requestOptions,
|
|
58
|
+
status: -1,
|
|
59
|
+
message: error.message ?? `Unknown Error`
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
63
|
+
return resolve({
|
|
64
|
+
error: true,
|
|
65
|
+
options: requestOptions,
|
|
66
|
+
status: response.statusCode ?? -1,
|
|
67
|
+
message: `HTTP Status Code ${response.statusCode ?? `Unknown Status Code`} (${body})`
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
if (body == undefined || body == null) {
|
|
71
|
+
return resolve({
|
|
72
|
+
error: true,
|
|
73
|
+
options: requestOptions,
|
|
74
|
+
status: response.statusCode ?? -1,
|
|
75
|
+
message: `Empty Response Body`
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
resolve({
|
|
79
|
+
error: false,
|
|
64
80
|
options: requestOptions,
|
|
65
81
|
status: response.statusCode ?? -1,
|
|
66
|
-
message:
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
resolve({
|
|
78
|
-
error: false,
|
|
79
|
-
options: requestOptions,
|
|
80
|
-
status: response.statusCode ?? -1,
|
|
81
|
-
message: body
|
|
82
|
-
})
|
|
83
|
-
})
|
|
82
|
+
message: body
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return resolve({
|
|
87
|
+
error: true,
|
|
88
|
+
options: {},
|
|
89
|
+
status: -1,
|
|
90
|
+
message: error.message ?? `Unknown Error`
|
|
91
|
+
})
|
|
92
|
+
}
|
|
84
93
|
})
|
|
85
94
|
}
|
|
@@ -52,6 +52,7 @@ export const setCronSchedule = async (): Promise<void> => {
|
|
|
52
52
|
};
|
|
53
53
|
walk(settings.GlobalSettings.ArchiveSettings.TextDirectory)
|
|
54
54
|
walk(settings.GlobalSettings.ArchiveSettings.EasDirectory)
|
|
55
|
+
walk(settings.GlobalSettings.ArchiveSettings.EventDirectory)
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
|
|
@@ -50,7 +50,7 @@ export const xReconnect = async (interval: number): Promise<void> => {
|
|
|
50
50
|
},
|
|
51
51
|
type: `reconnect`,
|
|
52
52
|
error: true
|
|
53
|
-
},
|
|
53
|
+
}, message: `Attempting to reconnect to XMPP Service (Reconnect Attempt ${bootstrap.cache.tReconnects})`,
|
|
54
54
|
})
|
|
55
55
|
await bootstrap.session_xmpp.stop().catch(() => {});
|
|
56
56
|
await bootstrap.session_xmpp.start().catch(() => {});
|
|
@@ -54,7 +54,5 @@ export const getEmebed = (event: TypeEvent): string => {
|
|
|
54
54
|
line(`**Sender:**`, event?.properties?.geocode?.office?.name ? `${event?.properties?.geocode?.office?.name} (${event?.properties?.geocode?.office?.office})` : event?.properties?.geocode?.office?.office),
|
|
55
55
|
line(`**Tracking:**`, event?.properties?.metadata?.tracking),
|
|
56
56
|
line(`**Logs:**`, event?.properties?.metadata?.history?.length > 0 ? event?.properties?.metadata?.history.length : null),
|
|
57
|
-
line(``, event?.properties?.metadata?.attachments?.length > 0 ? `**Attachments:** ${event?.properties?.metadata?.attachments.map(attachment => `[Attachment #${event?.properties?.metadata?.attachments.indexOf(attachment) + 1}](${attachment})`).join(' | ')}` : null),
|
|
58
|
-
line(``, event?.properties?.description ? '```' + '\n' + event?.properties?.description.split('\n').map(l => l.trim()).filter(Boolean).join('\n') + '\n' + '```' : null, !isExpired),
|
|
59
57
|
].filter(Boolean).join('\n');
|
|
60
58
|
}
|
package/src/@types/type.event.ts
CHANGED
|
@@ -48,6 +48,11 @@ export type TypeSettings = {
|
|
|
48
48
|
CallbackInterval: number
|
|
49
49
|
EventsEndpoint: string
|
|
50
50
|
}
|
|
51
|
+
BroadcastifySettings: {
|
|
52
|
+
BroadcastifyAttachments: boolean
|
|
53
|
+
BroadcastifyDatabase: string
|
|
54
|
+
BroadcastifyTags: string[]
|
|
55
|
+
},
|
|
51
56
|
GlobalSettings: {
|
|
52
57
|
EventManagement: boolean
|
|
53
58
|
BetterEventNames: boolean
|
|
@@ -69,7 +74,8 @@ export type TypeSettings = {
|
|
|
69
74
|
IgnoreTestProducts: boolean
|
|
70
75
|
},
|
|
71
76
|
ArchiveSettings: {
|
|
72
|
-
TTL: number
|
|
77
|
+
TTL: number
|
|
78
|
+
EventDirectory: string
|
|
73
79
|
TextDirectory: string
|
|
74
80
|
EasDirectory: string
|
|
75
81
|
EasToneout: string
|
package/src/bootstrap.ts
CHANGED
|
@@ -21,7 +21,7 @@ import path from 'path'
|
|
|
21
21
|
import { EventEmitter } from 'node:events';
|
|
22
22
|
|
|
23
23
|
export const bootstrap = {
|
|
24
|
-
version: `3.0.
|
|
24
|
+
version: `3.0.47`,
|
|
25
25
|
isReady: true,
|
|
26
26
|
ratelimits: {},
|
|
27
27
|
session_xmpp: null,
|
|
@@ -72,6 +72,11 @@ export const bootstrap = {
|
|
|
72
72
|
CallbackInterval: 15,
|
|
73
73
|
EventsEndpoint: `https://api.weather.gov/alerts/active`,
|
|
74
74
|
},
|
|
75
|
+
BroadcastifySettings: {
|
|
76
|
+
BroadcastifyAttachments: true,
|
|
77
|
+
BroadcastifyDatabase: `https://scriptkitty.cafe/ftp/@atmosphericx/assets/broadcastify.json`,
|
|
78
|
+
BroadcastifyTags: [`Ham`, `Air`, `Fire`, `Public Safety`, `Weather`, `EMS`, `Police`, `Rail`]
|
|
79
|
+
},
|
|
75
80
|
ListenerSettings: [],
|
|
76
81
|
GlobalSettings: {
|
|
77
82
|
EventManagement: true,
|
|
@@ -94,6 +99,7 @@ export const bootstrap = {
|
|
|
94
99
|
},
|
|
95
100
|
ArchiveSettings: {
|
|
96
101
|
TTL: 60,
|
|
102
|
+
EventDirectory: null,
|
|
97
103
|
TextDirectory: null,
|
|
98
104
|
EasDirectory: null,
|
|
99
105
|
EasToneout: null
|
package/test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { Manager
|
|
1
|
+
const { Manager } = require(`../dist/cjs/index.cjs`)
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const Client = new Manager({
|
|
4
4
|
Database: `shapefiles.db`,
|
|
5
5
|
EnableWireService: false,
|
|
6
6
|
EnableJournal: true,
|
|
@@ -29,6 +29,10 @@ const NOAAWeatherWireService = new Manager({
|
|
|
29
29
|
CallbackInterval: 30,
|
|
30
30
|
EventsEndpoint: `https://api.weather.gov/alerts/active`,
|
|
31
31
|
},
|
|
32
|
+
BroadcastifySettings: {
|
|
33
|
+
BroadcastifyAttachments: true,
|
|
34
|
+
BroadcastifyTags: [`Public Safety`, `Amateur Radio`, `Other`, `Rail`, `Aviation`, `Marine`, `Disaster Event`, `Special Event`]
|
|
35
|
+
},
|
|
32
36
|
ListenerSettings: [
|
|
33
37
|
{
|
|
34
38
|
events: [`*Thunderstorm Warning*`, `* Watch`],
|
|
@@ -41,15 +45,18 @@ const NOAAWeatherWireService = new Manager({
|
|
|
41
45
|
},
|
|
42
46
|
uploads: {
|
|
43
47
|
eas: true,
|
|
44
|
-
file: true
|
|
48
|
+
file: true,
|
|
49
|
+
event: true
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
],
|
|
48
53
|
GlobalSettings: {
|
|
54
|
+
EventManagement: true,
|
|
49
55
|
BetterEventNames: true,
|
|
50
56
|
DisableGeometryParsing: false,
|
|
51
57
|
UseShapefileCoordinates: true,
|
|
52
58
|
SPCWatchesOnly: true,
|
|
59
|
+
ShapefileSkipPoints: 0,
|
|
53
60
|
NodeTTL: 60,
|
|
54
61
|
NodeMinDistance: 120,
|
|
55
62
|
EventFiltering: {
|
|
@@ -83,9 +90,10 @@ const NOAAWeatherWireService = new Manager({
|
|
|
83
90
|
},
|
|
84
91
|
ArchiveSettings: {
|
|
85
92
|
TTL: 600,
|
|
93
|
+
EventDirectory: `Storage/EventProducts`,
|
|
86
94
|
TextDirectory: `Storage/TextProducts`,
|
|
87
95
|
EasDirectory: `Storage/EasScenarios`,
|
|
88
96
|
EasToneout: `tone.wav`,
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
|
-
})
|
|
99
|
+
})
|
|
File without changes
|