@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.
@@ -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
- const requestOptions = {
35
- url: options.url ?? `https://api.weather.gov/alerts/active`,
36
- headers: options.headers ?? {
37
- "User-Agent": "AtmosphericX",
38
- "Accept": "application/geo+json, text/plain, */*; q=0.9",
39
- "Accept-Language": "en-US,en;q=0.9"
40
- },
41
- method: options.method ?? `GET`,
42
- timeout: options.timeout ?? 10e3,
43
- proxy: options.proxy ?? null,
44
- maxRedirects: 1,
45
- };
46
- if (options.formData) {
47
- requestOptions['formData'] = options.formData;
48
- } else if (options.body) {
49
- requestOptions['body'] = options.body;
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
- if (response.statusCode < 200 || response.statusCode >= 300) {
62
- return resolve({
63
- error: true,
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: `HTTP Status Code ${response.statusCode ?? `Unknown Status Code`} (${body})`
67
- })
68
- }
69
- if (body == undefined || body == null) {
70
- return resolve({
71
- error: true,
72
- options: requestOptions,
73
- status: response.statusCode ?? -1,
74
- message: `Empty Response Body`
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
  }
@@ -63,7 +63,7 @@ export type TypeEvent = {
63
63
  issued: string
64
64
  status: string
65
65
  }[]
66
- attachments?: string[]
66
+ attachments?: { name: string; link: string }[]
67
67
  raw: string
68
68
  }
69
69
  } & BaseTypeEventProperties
@@ -27,6 +27,6 @@ export type TypeListener = {
27
27
  message: string
28
28
  }
29
29
  uploads?: {
30
- file?: boolean, eas?: boolean
30
+ file?: boolean, eas?: boolean, event?: boolean
31
31
  }
32
32
  }
@@ -21,6 +21,7 @@ import { TypeAttributes } from "./type.attributes";
21
21
 
22
22
  export type TypeEventProperties = {
23
23
  locations: string
24
+ locations_array: string[]
24
25
  description: string
25
26
  attributes?: TypeAttributes
26
27
  geocode: {
@@ -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.46`,
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, setSettings, getSettings, getListener } = require(`../dist/cjs/index.cjs`)
1
+ const { Manager } = require(`../dist/cjs/index.cjs`)
2
2
 
3
- const NOAAWeatherWireService = new Manager({
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
+ })