@atmosx/event-product-parser 3.0.0 → 3.0.2

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 (121) hide show
  1. package/README.md +307 -5
  2. package/dist/cjs/index.cjs +10253 -262
  3. package/dist/esm/index.mjs +10250 -262
  4. package/dist/index.d.mts +238 -0
  5. package/dist/index.d.ts +238 -0
  6. package/package.json +4 -3
  7. package/src/@building/building.clean.ts +1 -1
  8. package/src/@building/building.create.ts +1 -1
  9. package/src/@building/building.enhance.ts +1 -1
  10. package/src/@building/building.geometry.ts +7 -1
  11. package/src/@building/building.headers.ts +1 -1
  12. package/src/@building/building.office.ts +1 -1
  13. package/src/@building/building.polygon.ts +1 -1
  14. package/src/@building/building.properties.ts +1 -1
  15. package/src/@building/building.signature.ts +11 -27
  16. package/src/@building/building.tags.ts +1 -1
  17. package/src/@building/building.tracking.ts +1 -1
  18. package/src/@building/building.validate.ts +19 -4
  19. package/src/@core/{core.callback.ts → core.clearEvents.ts} +9 -16
  20. package/src/@core/{core.listener.ts → core.createListener.ts} +2 -2
  21. package/src/@core/core.getEvents.ts +1 -1
  22. package/src/@core/core.getNodes.ts +1 -1
  23. package/src/@core/core.getRandomEvent.ts +25 -0
  24. package/src/@core/core.getVersion.ts +25 -0
  25. package/src/@core/core.setNode.ts +2 -2
  26. package/src/@core/core.start.ts +12 -5
  27. package/src/@core/core.stop.ts +1 -1
  28. package/src/@dictionaries/dictionaries.betterEventNames.ts +5 -1
  29. package/src/@dictionaries/dictionaries.eventActions.ts +1 -1
  30. package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +2 -2
  31. package/src/@dictionaries/dictionaries.eventCancelMessages.ts +2 -1
  32. package/src/@dictionaries/dictionaries.eventCauses.ts +1 -1
  33. package/src/@dictionaries/dictionaries.eventProducts.ts +1 -1
  34. package/src/@dictionaries/dictionaries.eventRecords.ts +1 -1
  35. package/src/@dictionaries/dictionaries.eventSeverity.ts +1 -1
  36. package/src/@dictionaries/dictionaries.eventStatus.ts +1 -1
  37. package/src/@dictionaries/dictionaries.eventTags.ts +1 -1
  38. package/src/@dictionaries/dictionaries.eventTypes.ts +1 -1
  39. package/src/@dictionaries/dictionaries.eventsOffshore.ts +1 -1
  40. package/src/@dictionaries/dictionaries.hailStrings.ts +3 -1
  41. package/src/@dictionaries/dictionaries.officeICAOs.ts +1 -1
  42. package/src/@dictionaries/dictionaries.regExp.ts +1 -1
  43. package/src/@dictionaries/dictionaries.shapefileLinks.ts +1 -1
  44. package/src/@dictionaries/dictionaries.statusCorrelationText.ts +14 -12
  45. package/src/@dictionaries/{dictionaries.test_signatures.ts → dictionaries.testSignatures.ts} +3 -2
  46. package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +1 -1
  47. package/src/@events/events.api.ts +1 -1
  48. package/src/@events/events.text.ts +5 -3
  49. package/src/@events/events.ugc.ts +3 -3
  50. package/src/@events/events.vtec.ts +5 -5
  51. package/src/@manager/manager.mkEvent.ts +54 -38
  52. package/src/@manager/manager.rmEvent.ts +6 -1
  53. package/src/@manager/manager.setHash.ts +2 -2
  54. package/src/@manager/manager.updateEvents.ts +35 -0
  55. package/src/@manager/manager.updateNodes.ts +10 -6
  56. package/src/@manager/manager.updateWebhooks.ts +50 -0
  57. package/src/@modules/@database/database.cache.ts +1 -1
  58. package/src/@modules/@database/database.init.ts +1 -1
  59. package/src/@modules/@database/database.shapefiles.ts +2 -3
  60. package/src/@modules/@database/database.stanza.ts +2 -1
  61. package/src/@modules/@eas/eas.getFloatPCM16.ts +29 -0
  62. package/src/@modules/@eas/eas.getMergedPCM16.ts +32 -0
  63. package/src/@modules/@eas/eas.getPCM16.ts +52 -0
  64. package/src/@modules/@eas/eas.getPCMToFloat.ts +26 -0
  65. package/src/@modules/@eas/eas.getSampledPCM16.ts +36 -0
  66. package/src/@modules/@eas/eas.getWavPCM16.ts +52 -0
  67. package/src/@modules/@eas/eas.setAFSK.ts +52 -0
  68. package/src/@modules/@eas/eas.setAsciiToBits.ts +32 -0
  69. package/src/@modules/@eas/eas.setAttentionTone.ts +40 -0
  70. package/src/@modules/@eas/eas.setEasTone.ts +137 -0
  71. package/src/@modules/@eas/eas.setNoise.ts +31 -0
  72. package/src/@modules/@eas/eas.setRadioEffect.ts +49 -0
  73. package/src/@modules/@eas/eas.setSameHeader.ts +45 -0
  74. package/src/@modules/@stanza/stanza.getAwipsType.ts +1 -1
  75. package/src/@modules/@stanza/stanza.validate.ts +1 -1
  76. package/src/@modules/@utilities/utilities.createHttp.ts +17 -7
  77. package/src/@modules/@utilities/utilities.createWebhook.ts +100 -0
  78. package/src/@modules/@utilities/utilities.getFormattedTime.ts +1 -1
  79. package/src/@modules/@utilities/utilities.getSettings.ts +1 -1
  80. package/src/@modules/@utilities/utilities.getShapeNearestPoint.ts +1 -1
  81. package/src/@modules/@utilities/utilities.setCronSchedule.ts +31 -4
  82. package/src/@modules/@utilities/utilities.setEventEmit.ts +1 -1
  83. package/src/@modules/@utilities/utilities.setListener.ts +3 -3
  84. package/src/@modules/@utilities/utilities.setSettings.ts +1 -1
  85. package/src/@modules/@utilities/utilities.setSleep.ts +3 -3
  86. package/src/@modules/@utilities/utilities.setTimeoutAction.ts +4 -4
  87. package/src/@modules/@utilities/utilities.setWarning.ts +3 -3
  88. package/src/@modules/@xmpp/xmpp.xDeploy.ts +2 -2
  89. package/src/@modules/@xmpp/xmpp.xError.ts +1 -10
  90. package/src/@modules/@xmpp/xmpp.xOffline.ts +2 -2
  91. package/src/@modules/@xmpp/xmpp.xOnline.ts +3 -19
  92. package/src/@modules/@xmpp/xmpp.xReconnect.ts +7 -2
  93. package/src/@modules/@xmpp/xmpp.xStanza.ts +3 -3
  94. package/src/@parsers/@hvtec/hvtec.extract.ts +1 -1
  95. package/src/@parsers/@pvtec/pvtec.expires.ts +1 -1
  96. package/src/@parsers/@pvtec/pvtec.extract.ts +3 -4
  97. package/src/@parsers/@text/text.getDescriptionFromProduct.ts +1 -1
  98. package/src/@parsers/@text/text.getPolygonFromProduct.ts +1 -1
  99. package/src/@parsers/@text/text.getTextFromProduct.ts +1 -1
  100. package/src/@parsers/@text/text.getXML.ts +1 -1
  101. package/src/@parsers/@ugc/ugc.coordinates.ts +1 -1
  102. package/src/@parsers/@ugc/ugc.expiry.ts +1 -1
  103. package/src/@parsers/@ugc/ugc.extract.ts +1 -1
  104. package/src/@parsers/@ugc/ugc.header.ts +1 -1
  105. package/src/@parsers/@ugc/ugc.locations.ts +1 -1
  106. package/src/@parsers/@ugc/ugc.zones.ts +1 -1
  107. package/src/@types/type.event.ts +13 -12
  108. package/src/@types/type.properties.ts +1 -1
  109. package/src/@types/types.attributes.ts +1 -1
  110. package/src/@types/types.compiled.ts +1 -1
  111. package/src/@types/types.hash.ts +1 -1
  112. package/src/@types/types.hvtec.ts +1 -1
  113. package/src/@types/types.pvtec.ts +2 -1
  114. package/src/@types/types.settings.ts +10 -5
  115. package/src/@types/types.stanza.ts +1 -1
  116. package/src/@types/types.ugc.ts +1 -1
  117. package/src/@types/types.webhook.ts +26 -0
  118. package/src/bootstrap.ts +7 -4
  119. package/src/index.ts +14 -14
  120. package/test.js +29 -18
  121. package/tsup.config.ts +1 -0
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -40,8 +40,8 @@ export const vtec = async (stanza: TypeStanzaCompiled): Promise<void> => {
40
40
  for (const message of getMessages) {
41
41
  const tick = performance.now();
42
42
  const attributes = stanza?.attributes as TypeAttributes
43
- const pVtec = await pvExtract(message) as TypePVTEC[];
44
- const hVtec = await hvExtract(message) as TypeHVTEC[];
43
+ const pVtec = pvExtract(message) as TypePVTEC[];
44
+ const hVtec = hvExtract(message) as TypeHVTEC[];
45
45
  const ugc = await ugcExtract(message)
46
46
  if (pVtec != null && ugc != null ) {
47
47
  for (const pv of pVtec) {
@@ -61,14 +61,14 @@ export const vtec = async (stanza: TypeStanzaCompiled): Promise<void> => {
61
61
  parent: pv.event,
62
62
  status: pv.status,
63
63
  issued: (!isNaN(issued.getTime())) ? issued.toISOString() : new Date().toISOString(),
64
- expires: (!isNaN(expires.getTime())) ? expires.toISOString() : new Date(Date.now() + 60 * 60 * 1000).toISOString(),
64
+ expires: (!isNaN(expires.getTime())) ? expires.toISOString() : ugc.expires ?? new Date(issued.getTime() + 60 * 60 * 1000).toISOString(),
65
65
  ...props,
66
66
  metadata: {
67
67
  ms: performance.now() - tick,
68
68
  source: `events.vtec`,
69
69
  tracking: getEventTracking({ type: `VTEC`, stanza, attributes, properties: props, vtec }),
70
70
  header: header,
71
- vtec: pv.vtec,
71
+ vtec: pv,
72
72
  hvtec: hVtec,
73
73
  history: [
74
74
  {
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -21,17 +21,32 @@ import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
21
21
  import { TypeEvent } from "../@types/type.event";
22
22
  import { bootstrap } from "../bootstrap"
23
23
  import { setHash } from "./manager.setHash";
24
+ import { updateWebhooks } from "./manager.updateWebhooks";
25
+ import { updateNode } from "./manager.updateNodes";
26
+ import { TypeSettings } from "../@types/types.settings";
24
27
 
25
28
  export const mkEvent = async (event: TypeEvent): Promise<void> => {
29
+ const settings = bootstrap.settings as TypeSettings;
26
30
  const features = bootstrap.cache.events.features;
27
- const featureMap: Map<string, typeof features[0]> = new Map();
31
+ const map = new Map<string, typeof features[0]>();
32
+
33
+ for (const f of features) {
34
+ const key = f?.properties?.metadata?.tracking;
35
+ if (!key) continue;
36
+ map.set(key, f);
37
+ }
38
+
28
39
  const getHash = event.properties.metadata.hash;
29
40
  const getTracking = event.properties.metadata.tracking;
30
- features.forEach(f => f?.properties?.metadata?.tracking && featureMap.set(f?.properties?.metadata?.tracking, f));
31
41
  const isEntry = bootstrap.cache.hashes?.find(hash => hash.tracking === getTracking)
32
42
  const isHashed = isEntry?.hashes?.includes(getHash) ?? false;
33
- const getFeature = featureMap.get(getTracking);
43
+ const getFeature = map.get(getTracking);
44
+
34
45
  if (isHashed || event.properties.status_metadata.is_expired) return
46
+ await setHash(event, isEntry)
47
+ const isFilteredLocation = await updateNode(event).then(() => event.properties.metadata.filtered_proximity);
48
+ if (!isFilteredLocation && settings.GlobalSettings.EventFiltering.NodeLocationFiltering) { return }
49
+
35
50
  setEventEmit({
36
51
  event: `onEventStatus`,
37
52
  metadata: {
@@ -40,40 +55,41 @@ export const mkEvent = async (event: TypeEvent): Promise<void> => {
40
55
  },
41
56
  message: `[${getFeature ? 'Updated' : 'New'}] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
42
57
  })
43
- setHash(event, isEntry)
44
- if (event.properties.status_metadata.is_issued || event.properties.status_metadata.is_updated) {
45
- if (getFeature) {
46
- const getIndex = features.indexOf(getFeature);
47
- const cHistory = getFeature?.properties?.metadata?.history ?? [];
48
- const cLocations = getFeature?.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
49
- const cUgc = getFeature?.properties?.geocode?.ugc ?? [];
50
-
51
- const iHistory = event.properties?.metadata?.history ?? [];
52
- const iLocations = event.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
53
- const iUgc = event.properties?.geocode?.ugc ?? [];
54
-
55
- const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i);
56
- const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join('; ');
57
- const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
58
-
59
- bootstrap.cache.events.features[getIndex] = {
60
- ...event,
61
- properties: {
62
- ...event.properties,
63
- metadata: {
64
- ...event?.properties?.metadata,
65
- history: mHistory
66
- },
67
- locations: mLocations,
68
- geocode: {
69
- ...event?.properties?.geocode,
70
- ugc: mUgc
71
- },
72
- }
73
- };
74
- } else {
75
- features.push(event)
76
- featureMap.set(getTracking, event)
58
+ if (settings.GlobalSettings.EventManagement) {
59
+ if (event.properties.status_metadata.is_issued || event.properties.status_metadata.is_updated) {
60
+ if (getFeature) {
61
+ const getIndex = features.indexOf(getFeature);
62
+ const cHistory = getFeature?.properties?.metadata?.history ?? [];
63
+ const cLocations = getFeature?.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
64
+ const cUgc = getFeature?.properties?.geocode?.ugc ?? [];
65
+
66
+ const iHistory = event.properties?.metadata?.history ?? [];
67
+ const iLocations = event.properties?.locations?.split(";").map((l: string) => l.trim()) ?? [];
68
+ const iUgc = event.properties?.geocode?.ugc ?? [];
69
+
70
+ const mHistory = [...cHistory, ...iHistory].filter((v, i, a) => a.indexOf(v) === i);
71
+ const mLocations = [...cLocations, ...iLocations].filter((v, i, a) => a.indexOf(v) === i).join('; ');
72
+ const mUgc = [...cUgc, ...iUgc].filter((v, i, a) => a.indexOf(v) === i);
73
+
74
+ bootstrap.cache.events.features[getIndex] = {
75
+ ...event,
76
+ properties: {
77
+ ...event.properties,
78
+ metadata: {
79
+ ...event?.properties?.metadata,
80
+ history: mHistory
81
+ },
82
+ locations: mLocations,
83
+ geocode: {
84
+ ...event?.properties?.geocode,
85
+ ugc: mUgc
86
+ },
87
+ }
88
+ };
89
+ } else {
90
+ features.push(event)
91
+ }
77
92
  }
78
93
  }
94
+ updateWebhooks(event)
79
95
  }
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -20,9 +20,13 @@
20
20
  import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
21
21
  import { TypeEvent } from "../@types/type.event";
22
22
  import { bootstrap } from "../bootstrap"
23
+ import { updateWebhooks } from "./manager.updateWebhooks";
23
24
 
24
25
  export const rmEvent = (event: TypeEvent): void => {
25
26
  const getEvent = bootstrap.cache.events.features.find(f => f?.properties?.metadata?.tracking === event?.properties?.metadata?.tracking);
27
+ const cachedStatus = event.properties.status;
28
+ event.properties.expires = new Date().toISOString();
29
+ event.properties.status = `Expired`;
26
30
  if (getEvent) {
27
31
  setEventEmit({
28
32
  event: `onEventStatus`,
@@ -33,6 +37,7 @@ export const rmEvent = (event: TypeEvent): void => {
33
37
  message: `[Removed] ${event.properties.event} (${event.properties.status}) (${event.properties.metadata.tracking})`
34
38
  })
35
39
  setEventEmit({ event: `onExpiredProduct`, metadata: event })
40
+ if (cachedStatus != `Statement`) updateWebhooks(event)
36
41
  bootstrap.cache.events.features.splice(bootstrap.cache.events.features.indexOf(getEvent), 1);
37
42
  bootstrap.cache.hashes = bootstrap.cache.hashes.filter(hash => hash.tracking !== event.properties.metadata.tracking);
38
43
  }
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -22,7 +22,7 @@ import { TypeHash } from "../@types/types.hash"
22
22
  import { bootstrap } from "../bootstrap"
23
23
 
24
24
 
25
- export const setHash = (event: TypeEvent, entry: TypeHash): void => {
25
+ export const setHash = async (event: TypeEvent, entry: TypeHash): Promise<void> => {
26
26
  if (entry) {
27
27
  entry.hashes.push(event.properties.metadata.hash);
28
28
  entry.expires = event.properties.expires;
@@ -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 { getFormattedTime } from "../@modules/@utilities/utilities.getFormattedTime";
21
+ import { TypeEvent } from "../@types/type.event";
22
+ import { bootstrap } from "../bootstrap"
23
+ import { rmEvent } from "./manager.rmEvent";
24
+
25
+
26
+ export const updateEvents = async (selectedEvent?: TypeEvent): Promise<void> => {
27
+ const events = bootstrap.cache.events.features;
28
+ async function update(evt: TypeEvent) {
29
+ if (new Date(evt.properties.expires) < new Date()) {
30
+ rmEvent(evt);
31
+ }
32
+ }
33
+ if (!selectedEvent) { await Promise.all(events.map(async (evt) => { await update(evt) })) }
34
+ if (selectedEvent) { await update(selectedEvent) }
35
+ }
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -19,15 +19,17 @@
19
19
 
20
20
  import { getEventNodes } from "../@building/building.polygon";
21
21
  import { setEventEmit } from "../@modules/@utilities/utilities.setEventEmit";
22
+ import { TypeEvent } from "../@types/type.event";
22
23
  import { bootstrap } from "../bootstrap"
23
24
 
24
25
 
25
- export const updateNodes = async (): Promise<void> => {
26
+ export const updateNode = async (selectedEvent?: TypeEvent): Promise<void> => {
26
27
  const events = bootstrap.cache.events.features;
27
28
  const ttl = bootstrap.settings.GlobalSettings.NodeTTL * 1e3;
28
29
  let total = 0;
29
- await Promise.all(events.map(async (evt) => {
30
- const lastUpdate = evt?.properties?.metadata?.nodes_updated ?? null;
30
+
31
+ async function update(evt: TypeEvent) {
32
+ const lastUpdate = evt?.properties?.metadata?.updated ?? null;
31
33
  if (lastUpdate != null && (Date.now() - lastUpdate) < ttl) {
32
34
  return evt;
33
35
  }
@@ -37,8 +39,10 @@ export const updateNodes = async (): Promise<void> => {
37
39
  }
38
40
  evt.properties.metadata.nodes = node.nodes
39
41
  evt.properties.metadata.filtered_proximity = node.filtered
40
- evt.properties.metadata.nodes_updated = node.updated
41
- }))
42
+ evt.properties.metadata.updated = node.updated
43
+ }
44
+ if (!selectedEvent) { await Promise.all(events.map(async (evt) => { await update(evt) })) }
45
+ if (selectedEvent) { await update(selectedEvent) }
42
46
  if (total > 0) {
43
47
  setEventEmit({
44
48
  event: `onNodeUpdate`,
@@ -0,0 +1,50 @@
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 { createWebhook } from "../@modules/@utilities/utilities.createWebhook";
21
+ import { TypeEvent } from "../@types/type.event";
22
+ import { TypeWebhook } from "../@types/types.webhook";
23
+ import { bootstrap } from "../bootstrap"
24
+
25
+
26
+ export const updateWebhooks = async (event: TypeEvent): Promise<void> => {
27
+ const settings = bootstrap.settings;
28
+ const webhooks = settings.WebhookSettings as TypeWebhook[];
29
+ const eventName = event.properties.event;
30
+ for (const socket of webhooks) {
31
+ const events = socket.events;
32
+ if (!events || events.length === 0) {
33
+ await createWebhook({ webhook: socket, event });
34
+ continue;
35
+ }
36
+ const matched = events.some(pattern => {
37
+ if (!pattern) return false;
38
+ if (pattern === "*" || pattern === eventName) return true;
39
+ if (pattern.includes("*")) {
40
+ const regex = "^" +
41
+ pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$";
42
+ return new RegExp(regex).test(eventName);
43
+ }
44
+ return false;
45
+ });
46
+ if (matched) {
47
+ await createWebhook({ webhook: socket, event });
48
+ }
49
+ }
50
+ };
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -49,10 +49,9 @@ export const importShapefiles = async (): Promise<void> => {
49
49
  const data = await content.files[file].async(`nodebuffer`)
50
50
  const output = resolve(directory, `${shapefile?.name ?? ``}_${shapefile?.id ?? ``}${extname(file)}`)
51
51
  fs.writeFileSync(output, data)
52
- setWarning({ message: `Successfully downloaded and extracted ${file}` })
53
52
  }
54
53
  }
55
- const filepath = resolve(__dirname, '../../shapefiles', shapefile.name + '_' + shapefile.id);
54
+ const filepath = resolve(__dirname, '../../shapefiles', shapefile.name + '_' + shapefile.id)
56
55
  const { features } = await read(
57
56
  filepath,
58
57
  filepath,
@@ -8,7 +8,7 @@
8
8
  | |
9
9
  |_|
10
10
 
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, Everwatch1, & CJ Ziegler)
11
+ Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
14
  Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
@@ -26,6 +26,7 @@ import { TypeStanzaCompiled } from '../../@types/types.compiled';
26
26
  export const importStanza = async (stanza: TypeStanzaCompiled): Promise<void> => {
27
27
  const settings = bootstrap.settings as TypeSettings;
28
28
  try {
29
+ if (!settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) { return }
29
30
  bootstrap.database
30
31
  .prepare(`INSERT OR IGNORE INTO stanzas (type, stanza, issued) VALUES (?, ?, ?)`)
31
32
  .run(stanza.getType.type, JSON.stringify(stanza), stanza.attributes.issue)
@@ -0,0 +1,29 @@
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
+
21
+ export const getFloatPCM16 = (float32: Float32Array): Int16Array => {
22
+ const out = new Int16Array(float32.length);
23
+ for (let i = 0; i < float32.length; i++) {
24
+ let v = Math.max(-1, Math.min(1, float32[i]));
25
+ out[i] = Math.round(v * 32767);
26
+ }
27
+ return out;
28
+ }
29
+
@@ -0,0 +1,32 @@
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
+
21
+ export const getMergedPCM16 = (arrays: Int16Array[]): Int16Array => {
22
+ let total = 0;
23
+ for (const a of arrays) total += a.length;
24
+ const out = new Int16Array(total);
25
+ let o = 0;
26
+ for (const a of arrays) {
27
+ out.set(a, o);
28
+ o += a.length;
29
+ }
30
+ return out;
31
+ }
32
+
@@ -0,0 +1,52 @@
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
+
21
+ export const getPCM16 = (samples: Record<string, number>[], sampleRate: number): Buffer => {
22
+ let o = 0;
23
+ const bytesPerSample = 2;
24
+ const blockAlign = 1 * bytesPerSample;
25
+ const byteRate = sampleRate * blockAlign;
26
+ const subchunk2Size = samples.length * bytesPerSample;
27
+ const chunkSize = 36 + subchunk2Size;
28
+ const buffer = Buffer.alloc(44 + subchunk2Size);
29
+
30
+ buffer.write("RIFF", o); o += 4;
31
+ buffer.writeUInt32LE(chunkSize, o); o += 4;
32
+ buffer.write("WAVE", o); o += 4;
33
+
34
+ buffer.write("fmt ", o); o += 4;
35
+ buffer.writeUInt32LE(16, o); o += 4;
36
+ buffer.writeUInt16LE(1, o); o += 2;
37
+ buffer.writeUInt16LE(1, o); o += 2;
38
+ buffer.writeUInt32LE(sampleRate, o); o += 4;
39
+ buffer.writeUInt32LE(byteRate, o); o += 4;
40
+ buffer.writeUInt16LE(blockAlign, o); o += 2;
41
+ buffer.writeUInt16LE(16, o); o += 2;
42
+
43
+ buffer.write("data", o); o += 4;
44
+ buffer.writeUInt32LE(subchunk2Size, o); o += 4;
45
+
46
+ for (let i = 0; i < samples.length; i++, o += 2) {
47
+ buffer.writeInt16LE(samples[i].value, o);
48
+ }
49
+ return buffer;
50
+ }
51
+
52
+
@@ -0,0 +1,26 @@
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
+
21
+ export const getPCMToFloat = (int16: Int16Array): Float32Array => {
22
+ const out = new Float32Array(int16.length);
23
+ for (let i = 0; i < int16.length; i++) out[i] = int16[i] / 32768;
24
+ return out;
25
+ }
26
+
@@ -0,0 +1,36 @@
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
+
21
+ export const getSampledPCM16 = (int16: Int16Array, originalRate: number, targetRate: number): Int16Array => {
22
+ if (originalRate === targetRate) return int16;
23
+ const ratio = targetRate / originalRate;
24
+ const outLen = Math.max(1, Math.round(int16.length * ratio));
25
+ const out = new Int16Array(outLen);
26
+ for (let i = 0; i < outLen; i++) {
27
+ const pos = i / ratio;
28
+ const i0 = Math.floor(pos);
29
+ const i1 = Math.min(i0 + 1, int16.length - 1);
30
+ const frac = pos - i0;
31
+ const v = int16[i0] * (1 - frac) + int16[i1] * frac;
32
+ out[i] = Math.round(v);
33
+ }
34
+ return out;
35
+ }
36
+
@@ -0,0 +1,52 @@
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
+
21
+ interface getWavPCM16Response {
22
+ samples: Int16Array
23
+ sampleRate: number
24
+ channels: number
25
+ bitsPerSample: number
26
+ }
27
+
28
+ export const getWavPCM16 = (buffer: Buffer): getWavPCM16Response => {
29
+ if (buffer.toString("ascii", 0, 4) !== "RIFF" || buffer.toString("ascii", 8, 12) !== "WAVE") { return null; }
30
+ let fmt = null;
31
+ let data = null;
32
+ let i = 12;
33
+ while (i + 8 <= buffer.length) {
34
+ const id = buffer.toString("ascii", i, i + 4);
35
+ const size = buffer.readUInt32LE(i + 4);
36
+ const start = i + 8;
37
+ const end = start + size;
38
+ if (id === "fmt ") fmt = buffer.slice(start, end);
39
+ if (id === "data") data = buffer.slice(start, end);
40
+ i = end + (size % 2);
41
+ }
42
+ if (!fmt || !data) return null;
43
+ const audioFormat = fmt.readUInt16LE(0);
44
+ const channels = fmt.readUInt16LE(2);
45
+ const sampleRate = fmt.readUInt32LE(4);
46
+ const bitsPerSample = fmt.readUInt16LE(14);
47
+ if (audioFormat !== 1 || bitsPerSample !== 16 || channels !== 1) { return null; }
48
+ const samples = new Int16Array(data.buffer, data.byteOffset, data.length / 2);
49
+ return { samples: new Int16Array(samples), sampleRate, channels, bitsPerSample };
50
+ }
51
+
52
+