@saber-usa/node-common 1.7.7-alpha.1 → 1.7.7
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 +41 -41
- package/package.json +52 -52
- package/src/FrameConverter.js +1121 -1121
- package/src/LLA.js +179 -179
- package/src/LaunchNominalClass.js +753 -753
- package/src/NodeVector3D.js +71 -71
- package/src/OrbitUtils.js +309 -309
- package/src/PropagateUtils.js +100 -100
- package/src/ShadowGEOCalculator.js +203 -203
- package/src/TimeConverter.js +309 -309
- package/src/astro.js +3301 -3301
- package/src/ballisticPropagator.js +1037 -1037
- package/src/checkNetwork.cjs +20 -20
- package/src/constants.js +37 -37
- package/src/fixDate.js +62 -62
- package/src/index.js +47 -47
- package/src/launchNominal.js +208 -208
- package/src/loggerFactory.cjs +98 -98
- package/src/s3.js +59 -59
- package/src/transform.js +35 -35
- package/src/udl.js +116 -116
- package/src/utils.js +406 -406
package/src/checkNetwork.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const _ = require("lodash");
|
|
2
|
-
const {resolve4} = require("dns").promises;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const checkRecord = (hostName) => resolve4(hostName).
|
|
6
|
-
then((addresss) => !_.isEmpty(addresss)).
|
|
7
|
-
catch(_.stubFalse);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module.exports.checkRecord = checkRecord;
|
|
11
|
-
module.exports.checkNetwork = (domains) => Promise.all(
|
|
12
|
-
_.map(
|
|
13
|
-
domains,
|
|
14
|
-
(hostName) => checkRecord(hostName).
|
|
15
|
-
then((found) => found
|
|
16
|
-
? hostName
|
|
17
|
-
: null,
|
|
18
|
-
),
|
|
19
|
-
),
|
|
20
|
-
).then((resolved) => _.flow(_.compact, _.first)(resolved) || null);
|
|
1
|
+
const _ = require("lodash");
|
|
2
|
+
const {resolve4} = require("dns").promises;
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const checkRecord = (hostName) => resolve4(hostName).
|
|
6
|
+
then((addresss) => !_.isEmpty(addresss)).
|
|
7
|
+
catch(_.stubFalse);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module.exports.checkRecord = checkRecord;
|
|
11
|
+
module.exports.checkNetwork = (domains) => Promise.all(
|
|
12
|
+
_.map(
|
|
13
|
+
domains,
|
|
14
|
+
(hostName) => checkRecord(hostName).
|
|
15
|
+
then((found) => found
|
|
16
|
+
? hostName
|
|
17
|
+
: null,
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
).then((resolved) => _.flow(_.compact, _.first)(resolved) || null);
|
package/src/constants.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export const DEG2RAD = Math.PI / 180;
|
|
2
|
-
export const RAD2DEG = 180 / Math.PI;
|
|
3
|
-
export const SEC2RAD = Math.PI / (180.0 * 3600.0); // seconds to radians conversion
|
|
4
|
-
export const ARCSEC2RAD = 1 / (3600 * 180 / Math.PI); // arcseconds to radians conversion (1 arcsec = 1/3600 deg = 1/3600 * π/180 rad)
|
|
5
|
-
export const MILLIS_PER_DAY = 24 * 60 * 60 * 1000; // Number of milliseconds in a day
|
|
6
|
-
|
|
7
|
-
export const SUN_RADIUS_KM = 695701.0; // Sun radius in kilometers
|
|
8
|
-
export const AU_KM = 149597870.7; // Astronomical Unit in kilometers
|
|
9
|
-
|
|
10
|
-
export const MU = 3.986004418e5; // km³/s² WGS-84 Earth Mu
|
|
11
|
-
export const MU_GRS80 = 3.986004415e5; // km³/s² Earth Mu in GRS-80
|
|
12
|
-
export const MU_SI = 3.986004415e14; // m³/s² Earth Mu in SI units, GRS-80
|
|
13
|
-
export const GRAV_CONST = 6.6743e-11; // N⋅m2⋅kg−2
|
|
14
|
-
export const EARTH_MASS = 5.97219e24; // kg
|
|
15
|
-
export const WGS72_EARTH_EQUATORIAL_RADIUS_KM = 6378.135; // in km. Use this when calculations are done with SGP4 which uses WGS72 assumptions.
|
|
16
|
-
export const WGS84_EARTH_EQUATORIAL_RADIUS_KM = 6378.137; // in km. Use this for general calculations.
|
|
17
|
-
export const EARTH_RADIUS_KM = 6378.135; // still in use for backwards compatibility with old code. Has been removed from nps, ingest, node-common. TODO: refactor from all other js projects using node-common.
|
|
18
|
-
export const GEO_ALTITUDE_KM = 35786; // Km
|
|
19
|
-
|
|
20
|
-
export const REGIMES = {
|
|
21
|
-
Undetermined: 1,
|
|
22
|
-
Leo: 2,
|
|
23
|
-
Heo: 4,
|
|
24
|
-
GeoInclined: 8,
|
|
25
|
-
Meo: 16,
|
|
26
|
-
Molniya: 32,
|
|
27
|
-
Sso: 64,
|
|
28
|
-
Polar: 128,
|
|
29
|
-
GeoStationary: 256,
|
|
30
|
-
GeoDrifter: 512,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const ERROR_CODES = {
|
|
34
|
-
INVALID_TIME_INPUT: "Invalid time input",
|
|
35
|
-
INVALID_SATELLITE_RECORD: "Invalid satellite record",
|
|
36
|
-
INVALID_PROPAGATE_OUTPUT: "Invalid propagate output",
|
|
37
|
-
};
|
|
1
|
+
export const DEG2RAD = Math.PI / 180;
|
|
2
|
+
export const RAD2DEG = 180 / Math.PI;
|
|
3
|
+
export const SEC2RAD = Math.PI / (180.0 * 3600.0); // seconds to radians conversion
|
|
4
|
+
export const ARCSEC2RAD = 1 / (3600 * 180 / Math.PI); // arcseconds to radians conversion (1 arcsec = 1/3600 deg = 1/3600 * π/180 rad)
|
|
5
|
+
export const MILLIS_PER_DAY = 24 * 60 * 60 * 1000; // Number of milliseconds in a day
|
|
6
|
+
|
|
7
|
+
export const SUN_RADIUS_KM = 695701.0; // Sun radius in kilometers
|
|
8
|
+
export const AU_KM = 149597870.7; // Astronomical Unit in kilometers
|
|
9
|
+
|
|
10
|
+
export const MU = 3.986004418e5; // km³/s² WGS-84 Earth Mu
|
|
11
|
+
export const MU_GRS80 = 3.986004415e5; // km³/s² Earth Mu in GRS-80
|
|
12
|
+
export const MU_SI = 3.986004415e14; // m³/s² Earth Mu in SI units, GRS-80
|
|
13
|
+
export const GRAV_CONST = 6.6743e-11; // N⋅m2⋅kg−2
|
|
14
|
+
export const EARTH_MASS = 5.97219e24; // kg
|
|
15
|
+
export const WGS72_EARTH_EQUATORIAL_RADIUS_KM = 6378.135; // in km. Use this when calculations are done with SGP4 which uses WGS72 assumptions.
|
|
16
|
+
export const WGS84_EARTH_EQUATORIAL_RADIUS_KM = 6378.137; // in km. Use this for general calculations.
|
|
17
|
+
export const EARTH_RADIUS_KM = 6378.135; // still in use for backwards compatibility with old code. Has been removed from nps, ingest, node-common. TODO: refactor from all other js projects using node-common.
|
|
18
|
+
export const GEO_ALTITUDE_KM = 35786; // Km
|
|
19
|
+
|
|
20
|
+
export const REGIMES = {
|
|
21
|
+
Undetermined: 1,
|
|
22
|
+
Leo: 2,
|
|
23
|
+
Heo: 4,
|
|
24
|
+
GeoInclined: 8,
|
|
25
|
+
Meo: 16,
|
|
26
|
+
Molniya: 32,
|
|
27
|
+
Sso: 64,
|
|
28
|
+
Polar: 128,
|
|
29
|
+
GeoStationary: 256,
|
|
30
|
+
GeoDrifter: 512,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const ERROR_CODES = {
|
|
34
|
+
INVALID_TIME_INPUT: "Invalid time input",
|
|
35
|
+
INVALID_SATELLITE_RECORD: "Invalid satellite record",
|
|
36
|
+
INVALID_PROPAGATE_OUTPUT: "Invalid propagate output",
|
|
37
|
+
};
|
package/src/fixDate.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import {isValid, parseISO, format} from "date-fns";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Formats a date how MySQL wants it.
|
|
5
|
-
* Note: We chop off the timezone, otherwise the date-fns converts it into your local timezone, when we want UTC
|
|
6
|
-
* @param {string} date in ISO format used by the UDL
|
|
7
|
-
* @return {string} date formatted for MySQL
|
|
8
|
-
*/
|
|
9
|
-
export const fixDate = (date) => date && isValid(parseISO(date.toString()))
|
|
10
|
-
? format(parseISO(date.toString().replace("Z", "")), "yyyy-MM-dd HH:mm:ss")
|
|
11
|
-
: null;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Converts a Javascript date into a MySQL formatted date string
|
|
15
|
-
* @param {Date} date
|
|
16
|
-
* @return {string} Mysql formatted date string
|
|
17
|
-
*/
|
|
18
|
-
export const dateToMySqlDate
|
|
19
|
-
= (date) => new Date(date).toISOString().slice(0, 19).replace("T", " ");
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Converts string, int, or Date input into a Date. Adds Z to end of string if not present
|
|
23
|
-
* @param {*} date
|
|
24
|
-
* @return {Date} date
|
|
25
|
-
*/
|
|
26
|
-
export const parseDate = (date) => {
|
|
27
|
-
const corrected = (typeof date !== "string" || date.endsWith("Z")) ? date : (date+"Z");
|
|
28
|
-
return new Date(corrected);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Checks if MySql date-time, if so appends UTC timezone and convets to JS date-time object.
|
|
33
|
-
* If not, assumes timezone is specified in date-time string and converts to JS date-time object.
|
|
34
|
-
* @param {String} dt date time string
|
|
35
|
-
* @return {Date} Date object in UTC
|
|
36
|
-
*/
|
|
37
|
-
export const dtStrtoJsDt = (dt) => {
|
|
38
|
-
if (isSqlDate(dt)) {
|
|
39
|
-
// MySql date-time format
|
|
40
|
-
return mySqlDateToJs(dt);
|
|
41
|
-
}
|
|
42
|
-
return new Date(dt);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/** Converts MySql date-time to JS date-time
|
|
46
|
-
* @param {String} dt MySql date-time format must be yyyy-mm-dd hh:mm:ss
|
|
47
|
-
* @return {Date} JS date-time
|
|
48
|
-
*/
|
|
49
|
-
export const mySqlDateToJs = (dt) => {
|
|
50
|
-
// check the date is in MySQL format
|
|
51
|
-
if (isSqlDate(dt)) {
|
|
52
|
-
return new Date(dt+"Z");
|
|
53
|
-
} else {
|
|
54
|
-
throw new Error("Invalid MySql date format");
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/** Checks if a Date is a valid mySQL date, with microseconds precision (i.e. up to 6 digits).
|
|
59
|
-
* @param {String} dt The date string to test
|
|
60
|
-
* @return {Boolean} True if is SQL date, false otherwise
|
|
61
|
-
*/
|
|
62
|
-
export const isSqlDate = (dt) => dt.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d{1,6})?$/);
|
|
1
|
+
import {isValid, parseISO, format} from "date-fns";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Formats a date how MySQL wants it.
|
|
5
|
+
* Note: We chop off the timezone, otherwise the date-fns converts it into your local timezone, when we want UTC
|
|
6
|
+
* @param {string} date in ISO format used by the UDL
|
|
7
|
+
* @return {string} date formatted for MySQL
|
|
8
|
+
*/
|
|
9
|
+
export const fixDate = (date) => date && isValid(parseISO(date.toString()))
|
|
10
|
+
? format(parseISO(date.toString().replace("Z", "")), "yyyy-MM-dd HH:mm:ss")
|
|
11
|
+
: null;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Converts a Javascript date into a MySQL formatted date string
|
|
15
|
+
* @param {Date} date
|
|
16
|
+
* @return {string} Mysql formatted date string
|
|
17
|
+
*/
|
|
18
|
+
export const dateToMySqlDate
|
|
19
|
+
= (date) => new Date(date).toISOString().slice(0, 19).replace("T", " ");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Converts string, int, or Date input into a Date. Adds Z to end of string if not present
|
|
23
|
+
* @param {*} date
|
|
24
|
+
* @return {Date} date
|
|
25
|
+
*/
|
|
26
|
+
export const parseDate = (date) => {
|
|
27
|
+
const corrected = (typeof date !== "string" || date.endsWith("Z")) ? date : (date+"Z");
|
|
28
|
+
return new Date(corrected);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Checks if MySql date-time, if so appends UTC timezone and convets to JS date-time object.
|
|
33
|
+
* If not, assumes timezone is specified in date-time string and converts to JS date-time object.
|
|
34
|
+
* @param {String} dt date time string
|
|
35
|
+
* @return {Date} Date object in UTC
|
|
36
|
+
*/
|
|
37
|
+
export const dtStrtoJsDt = (dt) => {
|
|
38
|
+
if (isSqlDate(dt)) {
|
|
39
|
+
// MySql date-time format
|
|
40
|
+
return mySqlDateToJs(dt);
|
|
41
|
+
}
|
|
42
|
+
return new Date(dt);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Converts MySql date-time to JS date-time
|
|
46
|
+
* @param {String} dt MySql date-time format must be yyyy-mm-dd hh:mm:ss
|
|
47
|
+
* @return {Date} JS date-time
|
|
48
|
+
*/
|
|
49
|
+
export const mySqlDateToJs = (dt) => {
|
|
50
|
+
// check the date is in MySQL format
|
|
51
|
+
if (isSqlDate(dt)) {
|
|
52
|
+
return new Date(dt+"Z");
|
|
53
|
+
} else {
|
|
54
|
+
throw new Error("Invalid MySql date format");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Checks if a Date is a valid mySQL date, with microseconds precision (i.e. up to 6 digits).
|
|
59
|
+
* @param {String} dt The date string to test
|
|
60
|
+
* @return {Boolean} True if is SQL date, false otherwise
|
|
61
|
+
*/
|
|
62
|
+
export const isSqlDate = (dt) => dt.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d{1,6})?$/);
|
package/src/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
// Proper ES module barrel file
|
|
2
|
-
export * from "./loggerFactory.cjs";
|
|
3
|
-
export * from "./transform.js";
|
|
4
|
-
export * from "./checkNetwork.cjs";
|
|
5
|
-
export * from "./fixDate.js";
|
|
6
|
-
export * from "./astro.js";
|
|
7
|
-
export * from "./launchNominal.js";
|
|
8
|
-
export * from "./LaunchNominalClass.js";
|
|
9
|
-
export * from "./OrbitUtils.js";
|
|
10
|
-
export * from "./PropagateUtils.js";
|
|
11
|
-
export * from "./ballisticPropagator.js";
|
|
12
|
-
export * from "./NodeVector3D.js";
|
|
13
|
-
|
|
14
|
-
// UDL exports are grouped; re-export individually and as namespace if needed
|
|
15
|
-
import * as udl from "./udl.js";
|
|
16
|
-
export * from "./udl.js";
|
|
17
|
-
export {udl};
|
|
18
|
-
|
|
19
|
-
// Optional default aggregate similar to old CommonJS shape
|
|
20
|
-
import * as loggerFactoryNS from "./loggerFactory.cjs";
|
|
21
|
-
import * as transformNS from "./transform.js";
|
|
22
|
-
import * as checkNetworkNS from "./checkNetwork.cjs";
|
|
23
|
-
import * as fixDateNS from "./fixDate.js";
|
|
24
|
-
import * as astroNS from "./astro.js";
|
|
25
|
-
import * as launchNominalNS from "./launchNominal.js";
|
|
26
|
-
import * as LaunchNominalClassNS from "./LaunchNominalClass.js";
|
|
27
|
-
import * as OrbitUtilsNS from "./OrbitUtils.js";
|
|
28
|
-
import * as PropagateUtilsNS from "./PropagateUtils.js";
|
|
29
|
-
import * as ballisticPropagatorNS from "./ballisticPropagator.js";
|
|
30
|
-
import * as NodeVector3DNS from "./NodeVector3D.js";
|
|
31
|
-
|
|
32
|
-
const aggregate = {
|
|
33
|
-
...loggerFactoryNS,
|
|
34
|
-
...transformNS,
|
|
35
|
-
...checkNetworkNS,
|
|
36
|
-
...fixDateNS,
|
|
37
|
-
...astroNS,
|
|
38
|
-
...launchNominalNS,
|
|
39
|
-
...LaunchNominalClassNS,
|
|
40
|
-
...OrbitUtilsNS,
|
|
41
|
-
...PropagateUtilsNS,
|
|
42
|
-
...ballisticPropagatorNS,
|
|
43
|
-
...NodeVector3DNS,
|
|
44
|
-
udl,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default aggregate;
|
|
1
|
+
// Proper ES module barrel file
|
|
2
|
+
export * from "./loggerFactory.cjs";
|
|
3
|
+
export * from "./transform.js";
|
|
4
|
+
export * from "./checkNetwork.cjs";
|
|
5
|
+
export * from "./fixDate.js";
|
|
6
|
+
export * from "./astro.js";
|
|
7
|
+
export * from "./launchNominal.js";
|
|
8
|
+
export * from "./LaunchNominalClass.js";
|
|
9
|
+
export * from "./OrbitUtils.js";
|
|
10
|
+
export * from "./PropagateUtils.js";
|
|
11
|
+
export * from "./ballisticPropagator.js";
|
|
12
|
+
export * from "./NodeVector3D.js";
|
|
13
|
+
|
|
14
|
+
// UDL exports are grouped; re-export individually and as namespace if needed
|
|
15
|
+
import * as udl from "./udl.js";
|
|
16
|
+
export * from "./udl.js";
|
|
17
|
+
export {udl};
|
|
18
|
+
|
|
19
|
+
// Optional default aggregate similar to old CommonJS shape
|
|
20
|
+
import * as loggerFactoryNS from "./loggerFactory.cjs";
|
|
21
|
+
import * as transformNS from "./transform.js";
|
|
22
|
+
import * as checkNetworkNS from "./checkNetwork.cjs";
|
|
23
|
+
import * as fixDateNS from "./fixDate.js";
|
|
24
|
+
import * as astroNS from "./astro.js";
|
|
25
|
+
import * as launchNominalNS from "./launchNominal.js";
|
|
26
|
+
import * as LaunchNominalClassNS from "./LaunchNominalClass.js";
|
|
27
|
+
import * as OrbitUtilsNS from "./OrbitUtils.js";
|
|
28
|
+
import * as PropagateUtilsNS from "./PropagateUtils.js";
|
|
29
|
+
import * as ballisticPropagatorNS from "./ballisticPropagator.js";
|
|
30
|
+
import * as NodeVector3DNS from "./NodeVector3D.js";
|
|
31
|
+
|
|
32
|
+
const aggregate = {
|
|
33
|
+
...loggerFactoryNS,
|
|
34
|
+
...transformNS,
|
|
35
|
+
...checkNetworkNS,
|
|
36
|
+
...fixDateNS,
|
|
37
|
+
...astroNS,
|
|
38
|
+
...launchNominalNS,
|
|
39
|
+
...LaunchNominalClassNS,
|
|
40
|
+
...OrbitUtilsNS,
|
|
41
|
+
...PropagateUtilsNS,
|
|
42
|
+
...ballisticPropagatorNS,
|
|
43
|
+
...NodeVector3DNS,
|
|
44
|
+
udl,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default aggregate;
|