@saber-usa/node-common 1.7.29 → 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 +5 -6
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
|
|
|
@@ -336,10 +336,6 @@ const udlToNpsState = (udlRow) => {
|
|
|
336
336
|
const Yvel = _.get(udlRow, "yvel", null);
|
|
337
337
|
const Zvel = _.get(udlRow, "zvel", null);
|
|
338
338
|
const rawCov = _.get(udlRow, "cov", null );
|
|
339
|
-
// Guard against providers returning a non-array `cov` (e.g. the string "null" or "OTHER"
|
|
340
|
-
// in place of a real covariance matrix). Only ever serialize a real array or null, so the
|
|
341
|
-
// Covariance column always holds valid JSON that downstream JSON-array parsers can read.
|
|
342
|
-
const cov = Array.isArray(rawCov) ? rawCov : null;
|
|
343
339
|
const covRefFrame = _.get(udlRow, "covReferenceFrame", null );
|
|
344
340
|
let keplerians = {a: null, e: null, i: null, raan: null, w: null, f: null};
|
|
345
341
|
|
|
@@ -372,7 +368,10 @@ const udlToNpsState = (udlRow) => {
|
|
|
372
368
|
Xvel: Xvel,
|
|
373
369
|
Yvel: Yvel,
|
|
374
370
|
Zvel: Zvel,
|
|
375
|
-
|
|
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),
|
|
376
375
|
CovarianceRefFrame: covRefFrame,
|
|
377
376
|
SemiMajorAxis: keplerians.a,
|
|
378
377
|
Eccentricity: keplerians.e,
|