@saber-usa/node-common 1.7.28 → 1.7.31
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/package.json +2 -2
- package/src/transform.js +13 -1
- package/src/udl.js +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saber-usa/node-common",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.31",
|
|
4
4
|
"description": "Common node functions for Saber",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "Saber USA",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@aws-sdk/client-s3": "^3.
|
|
26
|
+
"@aws-sdk/client-s3": "^3.1086.0",
|
|
27
27
|
"date-fns": "^4.4.0",
|
|
28
28
|
"lodash": "4.18.1",
|
|
29
29
|
"mathjs": "^15.2.0",
|
package/src/transform.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
|
+
import {isDefined} from "./utils.js";
|
|
2
3
|
|
|
3
4
|
const transformObjectKeys = (transform, object, deep = true) => _.cond([
|
|
4
5
|
[
|
|
@@ -32,4 +33,15 @@ const pascalCaseObjectKeys = (transformItem, deep) => transformObjectKeys(
|
|
|
32
33
|
deep,
|
|
33
34
|
);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
// Write a true SQL NULL instead of the *string* "null" (JSON.stringify(null) === "null")
|
|
37
|
+
// when a value is absent, so nullable JSON/TEXT columns stay unambiguously empty.
|
|
38
|
+
const jsonOrNull = (value) => (isDefined(value) ? JSON.stringify(value) : null);
|
|
39
|
+
|
|
40
|
+
// As jsonOrNull, but additionally rejects non-array values (e.g. a provider returning the
|
|
41
|
+
// string "OTHER" in place of a real array), coercing them to null rather than serializing them.
|
|
42
|
+
const jsonArrayOrNull = (value) => (Array.isArray(value) ? JSON.stringify(value) : null);
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
transformObjectKeys, lowerCaseObjectKeys, pascalCaseObjectKeys, pascalCase,
|
|
46
|
+
jsonOrNull, jsonArrayOrNull,
|
|
47
|
+
};
|
package/src/udl.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
raDecToGeodetic,
|
|
11
11
|
estimateSlantRange,
|
|
12
12
|
} from "./astro.js";
|
|
13
|
-
import {lowerCaseObjectKeys} from "./transform.js";
|
|
13
|
+
import {lowerCaseObjectKeys, jsonArrayOrNull} from "./transform.js";
|
|
14
14
|
import {isDefined} from "./utils.js";
|
|
15
15
|
import _ from "lodash";
|
|
16
16
|
|
|
@@ -335,7 +335,7 @@ const udlToNpsState = (udlRow) => {
|
|
|
335
335
|
const Xvel = _.get(udlRow, "xvel", null); // kilometers/second
|
|
336
336
|
const Yvel = _.get(udlRow, "yvel", null);
|
|
337
337
|
const Zvel = _.get(udlRow, "zvel", null);
|
|
338
|
-
const
|
|
338
|
+
const rawCov = _.get(udlRow, "cov", null );
|
|
339
339
|
const covRefFrame = _.get(udlRow, "covReferenceFrame", null );
|
|
340
340
|
let keplerians = {a: null, e: null, i: null, raan: null, w: null, f: null};
|
|
341
341
|
|
|
@@ -368,7 +368,10 @@ const udlToNpsState = (udlRow) => {
|
|
|
368
368
|
Xvel: Xvel,
|
|
369
369
|
Yvel: Yvel,
|
|
370
370
|
Zvel: Zvel,
|
|
371
|
-
|
|
371
|
+
// Guard against providers returning a non-array `cov` (e.g. the string "null" or
|
|
372
|
+
// "OTHER" in place of a real covariance matrix), and write a true SQL NULL rather
|
|
373
|
+
// than the string "null" when there is no covariance at all.
|
|
374
|
+
Covariance: jsonArrayOrNull(rawCov),
|
|
372
375
|
CovarianceRefFrame: covRefFrame,
|
|
373
376
|
SemiMajorAxis: keplerians.a,
|
|
374
377
|
Eccentricity: keplerians.e,
|