@atmosx/event-product-parser 3.0.4 → 3.0.6
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/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
- package/.github/README.md +163 -0
- package/.github/SUPPORTED_EVENTS.md +370 -0
- package/.github/docs/docs-functions.md +30 -0
- package/.github/docs/docs-general-configurations.md +209 -0
- package/.github/docs/docs-integrations.md +37 -0
- package/.github/docs/docs-listeners.md +28 -0
- package/.github/docs/docs-source-configuration.md +218 -0
- package/.github/docs/docs-technical.md +50 -0
- package/.github/logo.png +0 -0
- package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
- package/.github/samples/SAMPLE_GEOJSON.json +204 -0
- package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
- package/dist/cjs/index.cjs +4677 -13422
- package/dist/esm/index.mjs +3159 -11906
- package/package.json +3 -9
- package/src/@building/{building.create.ts → CreateEvent.ts} +25 -11
- package/src/@building/{building.clean.ts → GetCleanedEvent.ts} +2 -2
- package/src/@building/GetEventAttachments.ts +86 -0
- package/src/@building/{building.enhance.ts → GetEventEnhancedName.ts} +11 -12
- package/src/@building/{building.geometry.ts → GetEventGeometry.ts} +7 -7
- package/src/@building/{building.headers.ts → GetEventHeader.ts} +3 -3
- package/src/@building/{building.polygon.ts → GetEventNodes.ts} +13 -11
- package/src/@building/{building.office.ts → GetEventOffice.ts} +6 -6
- package/src/@building/GetEventProperties.ts +96 -0
- package/src/@building/{building.signature.ts → GetEventSignature.ts} +14 -15
- package/src/@building/{building.tags.ts → GetEventTags.ts} +9 -4
- package/src/@building/{building.tracking.ts → GetEventTracking.ts} +15 -15
- package/src/@building/{building.validate.ts → ValidateEvents.ts} +67 -60
- package/src/@core/{core.clearEvents.ts → ClearEvents.ts} +3 -4
- package/src/@core/{core.createListener.ts → CreateListener.ts} +3 -3
- package/src/@core/{core.getEvents.ts → GetEvents.ts} +1 -2
- package/src/@core/{core.getNodes.ts → GetNodes.ts} +1 -2
- package/src/@core/{core.getRandomEvent.ts → GetRandomEvent.ts} +1 -2
- package/src/@core/{core.getVersion.ts → GetVersion.ts} +1 -2
- package/src/@core/ManualEvent.ts +56 -0
- package/src/@core/QueryStanza.ts +39 -0
- package/src/@core/{core.setNode.ts → SetNode.ts} +8 -8
- package/src/@core/{core.start.ts → StartService.ts} +21 -21
- package/src/@core/{core.stop.ts → StopService.ts} +1 -1
- package/src/@enums/AWIPS.ts +366 -0
- package/src/{@dictionaries/dictionaries.eventActions.ts → @enums/Actions.ts} +1 -1
- package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → @enums/Cancellation.ts} +2 -1
- package/src/{@dictionaries/dictionaries.eventCauses.ts → @enums/Causes.ts} +1 -1
- package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → @enums/Correlations.ts} +1 -1
- package/src/@enums/Enhanced.ts +70 -0
- package/src/{@dictionaries/dictionaries.eventTypes.ts → @enums/Events.ts} +1 -1
- package/src/{@dictionaries/dictionaries.regExp.ts → @enums/Expressions.ts} +2 -1
- package/src/@enums/GlobalFilter.ts +24 -0
- package/src/{@dictionaries/dictionaries.hailStrings.ts → @enums/Hail.ts} +7 -2
- package/src/{@dictionaries/dictionaries.officeICAOs.ts → @enums/ICAO.ts} +3 -1
- package/src/@enums/Matches.ts +55 -0
- package/src/{@dictionaries/dictionaries.eventProducts.ts → @enums/Products.ts} +1 -1
- package/src/{@dictionaries/dictionaries.eventRecords.ts → @enums/Records.ts} +1 -1
- package/src/{@dictionaries/dictionaries.eventSeverity.ts → @enums/Severity.ts} +1 -1
- package/src/{@dictionaries/dictionaries.shapefileLinks.ts → @enums/Shapefiles.ts} +1 -1
- package/src/@enums/States.ts +72 -0
- package/src/{@dictionaries/dictionaries.eventStatus.ts → @enums/Status.ts} +1 -1
- package/src/@enums/Strings.ts +22 -0
- package/src/@enums/Tags.ts +167 -0
- package/src/{@dictionaries/dictionaries.testSignatures.ts → @enums/Testing.ts} +3 -2
- package/src/@events/{events.api.ts → ParseAPI.ts} +42 -38
- package/src/@events/{events.text.ts → ParseText.ts} +25 -18
- package/src/@events/{events.ugc.ts → ParseUGC.ts} +28 -19
- package/src/@events/{events.vtec.ts → ParseVTEC.ts} +21 -21
- package/src/@manager/CreateActions.ts +213 -0
- package/src/@manager/{manager.mkEvent.ts → MakeEvent.ts} +34 -31
- package/src/@manager/RemoveEvent.ts +70 -0
- package/src/@manager/{manager.setHash.ts → SetHash.ts} +8 -9
- package/src/@manager/{manager.updateEvents.ts → UpdateEvents.ts} +9 -9
- package/src/@manager/{manager.updateNodes.ts → UpdateNode.ts} +24 -17
- package/src/@modules/@database/{database.cache.ts → GetCachedEvents.ts} +10 -8
- package/src/@modules/@database/ImportBroadcastify.ts +70 -0
- package/src/@modules/@database/{database.shapefiles.ts → ImportShapefiles.ts} +17 -20
- package/src/@modules/@database/{database.stanza.ts → ImportStanza.ts} +5 -6
- package/src/@modules/@database/{database.init.ts → InitializeDatabase.ts} +25 -11
- package/src/@modules/@eas/GenerateEASMessage.ts +144 -0
- package/src/@modules/@eas/GetCleanDescription.ts +91 -0
- package/src/@modules/@eas/{eas.getFloatPCM16.ts → GetFloatPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.getMergedPCM16.ts → GetMergedPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.getPCM16.ts → GetPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.getPCMToFloat.ts → GetPCMToFloat.ts} +1 -1
- package/src/@modules/@eas/{eas.getSampledPCM16.ts → GetSampledPCM16.ts} +1 -1
- package/src/@modules/@eas/GetTTS.ts +54 -0
- package/src/@modules/@eas/{eas.getWavPCM16.ts → GetWavPCM16.ts} +1 -1
- package/src/@modules/@eas/{eas.setAFSK.ts → SetAFSK.ts} +1 -2
- package/src/@modules/@eas/{eas.setAsciiToBits.ts → SetAsciiToBits.ts} +1 -2
- package/src/@modules/@eas/{eas.setAttentionTone.ts → SetAttentionTone.ts} +1 -1
- package/src/@modules/@eas/{eas.setNoise.ts → SetNoise.ts} +6 -5
- package/src/@modules/@eas/{eas.setRadioEffect.ts → SetRadioEffect.ts} +6 -5
- package/src/@modules/@eas/{eas.setSameHeader.ts → SetSameHeader.ts} +7 -8
- package/src/@modules/@stanza/{stanza.getAwipsType.ts → GetAwipsType.ts} +11 -9
- package/src/@modules/@stanza/{stanza.validate.ts → ValidateStanza.ts} +9 -9
- package/src/@modules/@utilities/CreateHttp.ts +83 -0
- package/src/@modules/@utilities/{utilities.getFormattedTime.ts → GetFormattedTime.ts} +1 -1
- package/src/@modules/@utilities/GetLatestIssuance.ts +32 -0
- package/src/@modules/@utilities/GetMatched.ts +33 -0
- package/src/@modules/@utilities/{utilities.getSettings.ts → GetSettings.ts} +2 -2
- package/src/@modules/@utilities/{utilities.getShapeNearestPoint.ts → GetShapeNearestPoint.ts} +1 -1
- package/src/@modules/@utilities/{utilities.setCronSchedule.ts → SetCronSchedule.ts} +41 -12
- package/src/{@types/types.webhook.ts → @modules/@utilities/SetDebug.ts} +16 -6
- package/src/@modules/@utilities/{utilities.setEventEmit.ts → SetEventEmit.ts} +5 -5
- package/src/@modules/@utilities/{utilities.setListener.ts → SetListener.ts} +1 -1
- package/src/@modules/@utilities/{utilities.setSettings.ts → SetSettings.ts} +2 -2
- package/src/@modules/@utilities/{utilities.setSleep.ts → SetSleep.ts} +1 -1
- package/src/@modules/@utilities/{utilities.setTimeoutAction.ts → SetTimeoutAction.ts} +8 -3
- package/src/@modules/@utilities/{utilities.setWarning.ts → SetWarning.ts} +2 -2
- package/src/@modules/@xmpp/{xmpp.xDeploy.ts → DeployXMPP.ts} +13 -14
- package/src/@modules/@xmpp/{xmpp.xError.ts → ErrorXMPP.ts} +1 -3
- package/src/@modules/@xmpp/{xmpp.xOffline.ts → OfflineXMPP.ts} +3 -4
- package/src/@modules/@xmpp/{xmpp.xOnline.ts → OnlineXMPP.ts} +6 -5
- package/src/@modules/@xmpp/{xmpp.xReconnect.ts → ReconnectXMPP.ts} +8 -8
- package/src/@modules/@xmpp/{xmpp.xStanza.ts → StanzaXMPP.ts} +11 -11
- package/src/@parsers/@hvtec/{hvtec.extract.ts → HVExtract.ts} +10 -10
- package/src/@parsers/@pvtec/{pvtec.expires.ts → GetExpiry.ts} +1 -1
- package/src/@parsers/@pvtec/{pvtec.extract.ts → VTECExtract.ts} +17 -17
- package/src/@parsers/@text/{text.getDescriptionFromProduct.ts → GetDescriptionFromProduct.ts} +12 -5
- package/src/@parsers/@text/GetEmbededText.ts +56 -0
- package/src/@parsers/@text/{text.getPolygonFromProduct.ts → GetPolygonFromProduct.ts} +31 -10
- package/src/@parsers/@text/GetStringText.ts +58 -0
- package/src/@parsers/@text/{text.getTextFromProduct.ts → GetTextFromProduct.ts} +1 -1
- package/src/@parsers/@text/{text.getXML.ts → GetXML.ts} +1 -1
- package/src/@parsers/@ugc/GetCache.ts +24 -0
- package/src/@parsers/@ugc/{ugc.expiry.ts → GetExpiry.ts} +1 -1
- package/src/@parsers/@ugc/{ugc.locations.ts → GetLocations.ts} +35 -7
- package/src/@parsers/@ugc/{ugc.header.ts → GetUGCHeader.ts} +3 -3
- package/src/@parsers/@ugc/{ugc.coordinates.ts → GetZonePolygon.ts} +4 -3
- package/src/@parsers/@ugc/SetCache.ts +28 -0
- package/src/@parsers/@ugc/{ugc.extract.ts → UGCExtract.ts} +6 -6
- package/src/@types/Actions.ts +37 -0
- package/src/@types/{type.event.ts → Event.ts} +7 -5
- package/src/@types/{type.properties.ts → Properties.ts} +11 -8
- package/src/@types/{types.settings.ts → Settings.ts} +31 -7
- package/src/@types/{types.compiled.ts → StanzaCompiled.ts} +2 -1
- package/src/bootstrap.ts +33 -9
- package/src/index.ts +26 -24
- package/tsup.config.ts +1 -1
- package/README.md +0 -349
- package/dist/index.d.mts +0 -239
- package/dist/index.d.ts +0 -239
- package/src/@building/building.properties.ts +0 -89
- package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
- package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
- package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
- package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
- package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
- package/src/@manager/manager.rmEvent.ts +0 -49
- package/src/@manager/manager.updateWebhooks.ts +0 -50
- package/src/@modules/@eas/eas.setEasTone.ts +0 -137
- package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
- package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
- package/test.js +0 -91
- /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
- /package/{LICENSE → .github/LICENSE} +0 -0
- /package/{SECURITY.md → .github/SECURITY.md} +0 -0
- /package/src/@parsers/@ugc/{ugc.zones.ts → GetZones.ts} +0 -0
- /package/src/@types/{types.attributes.ts → Attributes.ts} +0 -0
- /package/src/@types/{types.hvtec.ts → HVTEC.ts} +0 -0
- /package/src/@types/{types.hash.ts → Hash.ts} +0 -0
- /package/src/@types/{types.stanza.ts → Stanza.ts} +0 -0
- /package/src/@types/{types.ugc.ts → UGC.ts} +0 -0
- /package/src/@types/{types.pvtec.ts → VTEC.ts} +0 -0
|
@@ -1,137 +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/types.settings";
|
|
21
|
-
import { transcribedMessageReplacements } from "../../@dictionaries/dictionaries.transcribedMessageReplacements";
|
|
22
|
-
import { bootstrap } from "../../bootstrap";
|
|
23
|
-
import { setSleep } from "../@utilities/utilities.setSleep"
|
|
24
|
-
import { getWavPCM16 } from "./eas.getWavPCM16";
|
|
25
|
-
import { getSampledPCM16 } from "./eas.getSampledPCM16";
|
|
26
|
-
import { setRadioEffect } from "./eas.setRadioEffect";
|
|
27
|
-
import { setSameHeader } from "./eas.setSameHeader";
|
|
28
|
-
import { setAttentionTone } from "./eas.setAttentionTone";
|
|
29
|
-
import { getMergedPCM16 } from "./eas.getMergedPCM16";
|
|
30
|
-
import { setNoise } from "./eas.setNoise";
|
|
31
|
-
import { getPCM16 } from "./eas.getPCM16";
|
|
32
|
-
import { join } from 'path'
|
|
33
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from 'fs'
|
|
34
|
-
import { execSync } from 'child_process'
|
|
35
|
-
import { platform } from 'os'
|
|
36
|
-
import { setWarning } from "../@utilities/utilities.setWarning";
|
|
37
|
-
import say from 'say'
|
|
38
|
-
|
|
39
|
-
interface GenerateEASOptions {
|
|
40
|
-
message: string
|
|
41
|
-
header: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const setEasTone = async (options: GenerateEASOptions): Promise<string> => {
|
|
45
|
-
const settings = bootstrap.settings as TypeSettings;
|
|
46
|
-
const directory = settings.GlobalSettings.EASSettings.ArchiveDirectory;
|
|
47
|
-
const prefix = settings.GlobalSettings.EASSettings.IntroWavFile;
|
|
48
|
-
let message = options.message;
|
|
49
|
-
let header = options.header;
|
|
50
|
-
let buffTTS: Buffer;
|
|
51
|
-
let buffRadio: any;
|
|
52
|
-
let buffFull: any[] = [];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const tmpTTS = join(directory, `/temp/${Math.random().toString(36).substring(2, 15)}-${header.replace(/[^a-zA-Z0-9]/g, '')}.wav`)
|
|
56
|
-
const outTTS = join(directory, `/output/${Math.random().toString(36).substring(2, 15)}-${header.replace(/[^a-zA-Z0-9]/g, '')}.wav`)
|
|
57
|
-
const vTTS = process.platform === `win32` ? `Microsoft David Desktop` : `en-US-GuyNerual`;
|
|
58
|
-
const vPlatform = platform();
|
|
59
|
-
|
|
60
|
-
if (!existsSync(directory)) {
|
|
61
|
-
mkdirSync(directory, { recursive: true });
|
|
62
|
-
}
|
|
63
|
-
if (!existsSync(join(directory, `/temp`))) {
|
|
64
|
-
mkdirSync(join(directory, `/temp`), { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
if (!existsSync(join(directory, `/output`))) {
|
|
67
|
-
mkdirSync(join(directory, `/output`), { recursive: true });
|
|
68
|
-
}
|
|
69
|
-
for (const {regex, replacement} of transcribedMessageReplacements) {
|
|
70
|
-
message = message.replace(regex, replacement)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (vPlatform != `win32`) {
|
|
74
|
-
setWarning({
|
|
75
|
-
title: `EAS`,
|
|
76
|
-
message: `Generation isn't supported with this OS. Please wait for further updates before trying again`
|
|
77
|
-
})
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
say.export(message, vTTS, 1.0, tmpTTS)
|
|
82
|
-
while (!existsSync(tmpTTS) || (buffTTS = readFileSync(tmpTTS)).length == 0) {
|
|
83
|
-
await setSleep({timeout: 25});
|
|
84
|
-
}
|
|
85
|
-
const vWav = getWavPCM16(buffTTS);
|
|
86
|
-
const vSamples = getSampledPCM16(vWav.samples, vWav.sampleRate, 8000)
|
|
87
|
-
const vRadio = setRadioEffect(vSamples, 8000)
|
|
88
|
-
|
|
89
|
-
if (existsSync(prefix)) {
|
|
90
|
-
let tBuffer = readFileSync(prefix);
|
|
91
|
-
let tWav = getWavPCM16(tBuffer);
|
|
92
|
-
|
|
93
|
-
if (tWav == null) {
|
|
94
|
-
try {
|
|
95
|
-
const converted = join(directory, `/temp/${Math.random().toString(36).substring(2, 15)}.converted.wav`)
|
|
96
|
-
execSync(`ffmpeg -y -i "${prefix}" -ar 8000 -ac 1 -sample_fmt s16 "${converted}"`, { stdio: 'ignore' })
|
|
97
|
-
if (existsSync(converted)) {
|
|
98
|
-
tBuffer = readFileSync(converted)
|
|
99
|
-
tWav = getWavPCM16(tBuffer)
|
|
100
|
-
try { unlinkSync(converted) } catch {}
|
|
101
|
-
}
|
|
102
|
-
} catch (e) {}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (tWav == null) {
|
|
106
|
-
setWarning({ title: `EAS`, message: `Intro tone isn't a valid .WAV file or isn't in PCM 16-bit format. Converted attempt failed; please convert it then try again.` })
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const tSamples = (tWav.sampleRate != 8000 ? getSampledPCM16(tWav.samples, tWav.sampleRate, 8000) : tWav.samples)
|
|
111
|
-
buffRadio = setRadioEffect(tSamples, 8000)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
buffFull = buffRadio != null ? [buffRadio, new Int16Array(Math.floor(0.5 * 8000))] : [];
|
|
115
|
-
buffFull.push(
|
|
116
|
-
setSameHeader(header, 3, 8000, {
|
|
117
|
-
preMarkSec: 1.1,
|
|
118
|
-
gapSec: 0.5,
|
|
119
|
-
}),
|
|
120
|
-
new Int16Array(Math.floor(0.5 * 8000)),
|
|
121
|
-
setAttentionTone(8, 8000),
|
|
122
|
-
new Int16Array(Math.floor(0.5 * 8000)),
|
|
123
|
-
vRadio
|
|
124
|
-
)
|
|
125
|
-
for (let i = 0; i < 3; i++) {
|
|
126
|
-
buffFull.push(setSameHeader(header, 1, 8000, { preMarkSec: 0.5, gapSec: 0.1 }))
|
|
127
|
-
buffFull.push(new Int16Array(Math.floor(0.5 * 8000)));
|
|
128
|
-
}
|
|
129
|
-
const aSamples = getMergedPCM16(buffFull);
|
|
130
|
-
const aFinal = setNoise(aSamples, 0.002);
|
|
131
|
-
const aBuffer = getPCM16(Array.from(aFinal).map(v => ({ value: v })), 8000);
|
|
132
|
-
writeFileSync(outTTS, aBuffer)
|
|
133
|
-
try{unlinkSync(tmpTTS)} catch {}
|
|
134
|
-
return outTTS;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
@@ -1,85 +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 request from 'request'
|
|
21
|
-
|
|
22
|
-
interface CreateHttpOptions {
|
|
23
|
-
proxy?: string
|
|
24
|
-
url: string
|
|
25
|
-
headers?: any
|
|
26
|
-
timeout?: number
|
|
27
|
-
method?: `GET` | `POST` | `PUT` | `DELETE`
|
|
28
|
-
body?: any;
|
|
29
|
-
formData?: any;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const createHttp = async (options: CreateHttpOptions): Promise<any> => {
|
|
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
|
-
})
|
|
60
|
-
}
|
|
61
|
-
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
62
|
-
return resolve({
|
|
63
|
-
error: true,
|
|
64
|
-
options: requestOptions,
|
|
65
|
-
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
|
-
})
|
|
84
|
-
})
|
|
85
|
-
}
|
|
@@ -1,115 +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 { TypeEvent } from "../../@types/type.event";
|
|
21
|
-
import { setTimeoutAction } from "./utilities.setTimeoutAction"
|
|
22
|
-
import { createHttp } from "./utilities.createHttp"
|
|
23
|
-
import { TypeWebhook } from "../../@types/types.webhook";
|
|
24
|
-
import { getCleanedEvent } from "../../@building/building.clean";
|
|
25
|
-
import FormData from "form-data";
|
|
26
|
-
|
|
27
|
-
interface CreateWebhookOptions {
|
|
28
|
-
webhook: TypeWebhook
|
|
29
|
-
event: TypeEvent
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const createWebhook = async (options: CreateWebhookOptions): Promise<void> => {
|
|
33
|
-
const event = options.event.properties;
|
|
34
|
-
const settings = options.webhook;
|
|
35
|
-
|
|
36
|
-
let body = [
|
|
37
|
-
event.locations ? `**Locations**: ${event.locations.slice(0,100)}` : null,
|
|
38
|
-
event.issued ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime()/1000)}:R>` : null,
|
|
39
|
-
event.expires && event.status != `Statement` ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime()/1000)}:R>` : null,
|
|
40
|
-
(() => {
|
|
41
|
-
const val = event.parameters.estimated_wind_gusts ?? null
|
|
42
|
-
const th = event.parameters.wind_threat ?? null
|
|
43
|
-
const combined = [val, th].filter(Boolean).join(' ');
|
|
44
|
-
return combined ? `**Wind Gusts**: ${val} ${th ? `(${th})` : ''}` : null;
|
|
45
|
-
})(),
|
|
46
|
-
(() => {
|
|
47
|
-
const val = event.parameters.estimated_hail_size ?? null
|
|
48
|
-
const th = event.parameters.hail_threat ?? null
|
|
49
|
-
return (val || th) ? `**Hail Threat**: ${val} ${th ? `(${th})` : ''}` : null;
|
|
50
|
-
})(),
|
|
51
|
-
event.parameters.damage_threat ? `**Damage Threat**: ${event.parameters.damage_threat}` : null,
|
|
52
|
-
event.parameters.flood_threat ? `**Flood Threat**: ${event.parameters.flood_threat}` : null,
|
|
53
|
-
event.parameters.tornado_threat ? `**Tornado Threat**: ${event.parameters.tornado_threat}` : null,
|
|
54
|
-
event.spc_parameters.spc_max_tornado ? `**Max Tornado Threat**: ${event.spc_parameters.spc_max_tornado}` : null,
|
|
55
|
-
event.spc_parameters.spc_max_hail ? `**Max Hail Threat**: ${event.spc_parameters.spc_max_hail}` : null,
|
|
56
|
-
event.spc_parameters.spc_max_wind ? `**Max Wind Threat**: ${event.spc_parameters.spc_max_wind}` : null,
|
|
57
|
-
event.spc_parameters.spc_watch_issuance ? `**Watch Issuance**: ${event.spc_parameters.spc_watch_issuance}%` : null,
|
|
58
|
-
event.watch_parameters.watch_number ? `**Watch Number**: ${event.watch_parameters.watch_number}` : null,
|
|
59
|
-
event.watch_parameters.strong_tornadoes_probability ? `**Strong Tornadoes Probability**: ${event.watch_parameters.strong_tornadoes_probability}%` : null,
|
|
60
|
-
event.watch_parameters.additional_tornadoes_probability ? `**Additional Tornadoes Probability**: ${event.watch_parameters.additional_tornadoes_probability}%` : null,
|
|
61
|
-
event.watch_parameters.combined_hail_wind_probability ? `**Combined Hail/Wind Probability**: ${event.watch_parameters.combined_hail_wind_probability}%` : null,
|
|
62
|
-
event.watch_parameters.severe_hail_probability ? `**Severe Hail Probability**: ${event.watch_parameters.severe_hail_probability}%` : null,
|
|
63
|
-
event.watch_parameters.hail_2in_probability ? `**Hail ≥2in Probability**: ${event.watch_parameters.hail_2in_probability}%` : null,
|
|
64
|
-
event.watch_parameters.max_hail_in ? `**Max Hail Inches**: ${event.watch_parameters.max_hail_in}` : null,
|
|
65
|
-
event.watch_parameters.severe_wind_probability ? `**Severe Wind Probability**: ${event.watch_parameters.severe_wind_probability}%` : null,
|
|
66
|
-
event.watch_parameters.max_wind_surface ? `**Max Surface Wind**: ${event.watch_parameters.max_wind_surface}` : null,
|
|
67
|
-
event.watch_parameters.max_tops_x100feet ? `**Max Tops (x100 feet)**: ${event.watch_parameters.max_tops_x100feet}` : null,
|
|
68
|
-
(event.parameters.tags?.length > 0) ? `**Tags**: ${event.parameters.tags.join(', ')}` : null,
|
|
69
|
-
(() => {
|
|
70
|
-
const val = event.geocode?.office?.name ?? `N/A`
|
|
71
|
-
const th = event.geocode?.office?.office ?? null
|
|
72
|
-
return (val || th) ? `**Sender**: ${val} ${th ? `(${th})` : ''}` : null;
|
|
73
|
-
})(),
|
|
74
|
-
event.metadata?.tracking ? `**Tracking**: ${event.metadata.tracking}` : null,
|
|
75
|
-
(() => {
|
|
76
|
-
const desc = (event.description || '').split('\n').map(l => l.trim()).filter(Boolean).join('\n');
|
|
77
|
-
return desc ? '```' + '\n' + desc + '\n' + '```' : null;
|
|
78
|
-
})(),
|
|
79
|
-
].filter(Boolean).join('\n');
|
|
80
|
-
|
|
81
|
-
const isLimited = setTimeoutAction({ identifier: options.webhook.webhook, interval: options.webhook.rate, max: options.webhook.rate, addTime: true })
|
|
82
|
-
if (isLimited.limited) { return }
|
|
83
|
-
|
|
84
|
-
if (body.length > 1900) {
|
|
85
|
-
body = body.substring(0, 1900) + "\n\n[Message truncated due to length]";
|
|
86
|
-
const blocks = (body.match(/```/g) || []).length;
|
|
87
|
-
if (blocks % 2 !== 0) body += "```";
|
|
88
|
-
}
|
|
89
|
-
const form = new FormData();
|
|
90
|
-
const embed = {
|
|
91
|
-
title: `${event.event} (${event.status})`,
|
|
92
|
-
description: body,
|
|
93
|
-
color: 16711680,
|
|
94
|
-
timestamp: new Date().toISOString(),
|
|
95
|
-
footer: { text: settings.title }
|
|
96
|
-
};
|
|
97
|
-
form.append("payload_json", JSON.stringify({
|
|
98
|
-
username: settings.title ?? "AtmosphericX",
|
|
99
|
-
content: settings.message ?? "",
|
|
100
|
-
embeds: [embed]
|
|
101
|
-
}));
|
|
102
|
-
if (settings.upload) {
|
|
103
|
-
form.append("file", Buffer.from(JSON.stringify((getCleanedEvent(event)), null, 2)), {
|
|
104
|
-
filename: `${event.event}_${event.status}_${event.metadata.tracking}.json`,
|
|
105
|
-
contentType: "application/json"
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
await createHttp({
|
|
109
|
-
url: settings.webhook,
|
|
110
|
-
timeout: 2000,
|
|
111
|
-
method: `POST`,
|
|
112
|
-
headers: form.getHeaders(),
|
|
113
|
-
body: form
|
|
114
|
-
})
|
|
115
|
-
}
|
package/test.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const { Manager, setSettings, getSettings, getListener } = require(`../dist/cjs/index.cjs`)
|
|
2
|
-
|
|
3
|
-
const NOAAWeatherWireService = new Manager({
|
|
4
|
-
Database: `shapefile-manager.db`,
|
|
5
|
-
EnableWireService: false,
|
|
6
|
-
EnableJournal: true,
|
|
7
|
-
NOAAWeatherWireServiceSettings: {
|
|
8
|
-
ReconnectionSettings: {
|
|
9
|
-
Enabled: true,
|
|
10
|
-
ReconnectionInterval: 60,
|
|
11
|
-
},
|
|
12
|
-
CredentialSettings: {
|
|
13
|
-
Username: `username`,
|
|
14
|
-
Password: `password`,
|
|
15
|
-
Nickname: "nickname (@atmosx/event-product-parser/3.0)",
|
|
16
|
-
},
|
|
17
|
-
CacheSettings: {
|
|
18
|
-
Enabled: true,
|
|
19
|
-
MaxDatabaseHistory: 5000,
|
|
20
|
-
MaxRetentionHistory: 555,
|
|
21
|
-
},
|
|
22
|
-
StanzaSettings: {
|
|
23
|
-
DisableUGC: false,
|
|
24
|
-
DisableVTEC: false,
|
|
25
|
-
DisableText: false,
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
NationalWeatherServiceSettings: {
|
|
29
|
-
CallbackInterval: 30,
|
|
30
|
-
EventsEndpoint: `https://api.weather.gov/alerts/active`,
|
|
31
|
-
},
|
|
32
|
-
WebhookSettings: [
|
|
33
|
-
{
|
|
34
|
-
webhook: "https://discord.com/api/webhooks/XXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
|
35
|
-
title: "AtmosphericX - (Severe Weather Events)",
|
|
36
|
-
message: `<@user_id>`,
|
|
37
|
-
upload: true,
|
|
38
|
-
events: [`Severe Thunderstorm Warning`, `Radar Indicated Tornado Warning`],
|
|
39
|
-
rate: 1,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
webhook: "https://discord.com/api/webhooks/XXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
|
43
|
-
title: "AtmosphericX - (All Events)",
|
|
44
|
-
message: `<@user_id>`,
|
|
45
|
-
upload: false,
|
|
46
|
-
events: [],
|
|
47
|
-
rate: 5,
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
GlobalSettings: {
|
|
51
|
-
BetterEventNames: true,
|
|
52
|
-
DisableGeometryParsing: false,
|
|
53
|
-
UseShapefileCoordinates: true,
|
|
54
|
-
SPCWatchesOnly: true,
|
|
55
|
-
NodeTTL: 60,
|
|
56
|
-
NodeMinDistance: 120,
|
|
57
|
-
EventFiltering: {
|
|
58
|
-
ListeningEvents: [
|
|
59
|
-
"Tornado Emergency", "PDS Tornado Warning", "Tornado Warning",
|
|
60
|
-
"Confirmed Tornado Warning", "Radar Indicated Tornado Warning",
|
|
61
|
-
"Special Marine Warning (TPROB)", "PDS Tornado Watch", "Tornado Watch",
|
|
62
|
-
"EDS Severe Thunderstorm Warning (TPROB)", "EDS Severe Thunderstorm Warning",
|
|
63
|
-
"Destructive Severe Thunderstorm Warning (TPROB)", "Destructive Severe Thunderstorm Warning",
|
|
64
|
-
"Considerable Severe Thunderstorm Warning (TPROB)", "Considerable Severe Thunderstorm Warning",
|
|
65
|
-
"Severe Thunderstorm Warning (TPROB)", "Severe Thunderstorm Warning",
|
|
66
|
-
"Severe Thunderstorm Watch",
|
|
67
|
-
"Flash Flood Emergency", "Flash Flood Warning",
|
|
68
|
-
"Flash Flood Watch",
|
|
69
|
-
"Tsunami Warning", "Tsunami Watch",
|
|
70
|
-
"Tsunami Advisory", "Special Marine Warning",
|
|
71
|
-
"Earthquake Warning",
|
|
72
|
-
"Hurricane Warning", "Hurricane Watch",
|
|
73
|
-
"Tropical Storm Warning",
|
|
74
|
-
"Winter Storm Warning", "Blizzard Warning",
|
|
75
|
-
"Ice Storm Warning", "Snow Squall Warning",
|
|
76
|
-
"Winter Weather Advisory", "Extreme Cold Watch"
|
|
77
|
-
],
|
|
78
|
-
ListeningICAO: [],
|
|
79
|
-
IgnoredICAO: [],
|
|
80
|
-
IgnoredEvents: [],
|
|
81
|
-
ListeningUGC: [],
|
|
82
|
-
ListeningStates: [],
|
|
83
|
-
NodeLocationFiltering: false,
|
|
84
|
-
IgnoreTestProducts: true,
|
|
85
|
-
},
|
|
86
|
-
EASSettings: {
|
|
87
|
-
ArchiveDirectory: null,
|
|
88
|
-
IntroWavFile: null,
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|