@cumulus/common 21.3.1 → 21.3.2-testlerna.0

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/env.d.ts CHANGED
@@ -1,11 +1,4 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- /// <reference types="node" />
6
- /// <reference types="node" />
7
- /// <reference types="node" />
8
- /// <reference types="node" />
9
- /// <reference types="node" />
10
3
  export declare const getRequiredEnvVar: (name: string, env?: NodeJS.ProcessEnv) => string;
11
4
  //# sourceMappingURL=env.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulus/common",
3
- "version": "21.3.1",
3
+ "version": "21.3.2-testlerna.0",
4
4
  "description": "Common utilities used across tasks",
5
5
  "keywords": [
6
6
  "GIBS",
@@ -28,7 +28,7 @@
28
28
  "test": "../../node_modules/.bin/ava",
29
29
  "test:ci": "../../scripts/run_package_ci_unit.sh",
30
30
  "test:coverage": "../../node_modules/.bin/nyc npm test",
31
- "prepare": "npm run tsc",
31
+ "build": "npm run tsc",
32
32
  "tsc": "../../node_modules/.bin/tsc",
33
33
  "tsc:listEmittedFiles": "../../node_modules/.bin/tsc --listEmittedFiles",
34
34
  "watch-test": "../../node_modules/.bin/tsc-watch --onsuccess 'npm test'",
@@ -44,11 +44,11 @@
44
44
  "author": "Cumulus Authors",
45
45
  "license": "Apache-2.0",
46
46
  "dependencies": {
47
- "@aws-sdk/client-s3": "^3.621.0",
48
- "@aws-sdk/signature-v4-crt": "^3.621.0",
49
- "@cumulus/aws-client": "21.3.1",
50
- "@cumulus/errors": "21.3.1",
51
- "@cumulus/logger": "21.3.1",
47
+ "@aws-sdk/client-s3": "^3.993.0",
48
+ "@aws-sdk/signature-v4-crt": "^3.993.0",
49
+ "@cumulus/aws-client": "21.3.2-testlerna.0",
50
+ "@cumulus/errors": "21.3.2-testlerna.0",
51
+ "@cumulus/logger": "21.3.2-testlerna.0",
52
52
  "ajv": "^6.12.3",
53
53
  "follow-redirects": "^1.2.4",
54
54
  "fs-extra": "^5.0.0",
@@ -62,12 +62,12 @@
62
62
  "parseurl": "^1.3.3",
63
63
  "randexp": "^0.5.3",
64
64
  "url-join": "^4.0.0",
65
- "uuid": "^3.2.1"
65
+ "uuid": "^8.2.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/fs-extra": "^5.0.0",
69
69
  "@types/node-forge": "^0.9.5",
70
70
  "@types/url-join": "^4.0.0"
71
71
  },
72
- "gitHead": "ba5c9b04fa1181fecbb97149fb4c01a92000ebb4"
72
+ "gitHead": "ef6577b6caec96a20df8ccff293a9436db32a482"
73
73
  }
package/test-utils.d.ts CHANGED
@@ -1,12 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- /// <reference types="node" />
6
- /// <reference types="node" />
7
- /// <reference types="node" />
8
- /// <reference types="node" />
9
- /// <reference types="node" />
10
3
  import { ExecutionContext } from 'ava';
11
4
  export { readJsonFile as readJsonFixture } from './FileUtils';
12
5
  export declare const inTestMode: (env?: NodeJS.ProcessEnv) => boolean;
package/util.d.ts CHANGED
@@ -42,7 +42,7 @@ export declare const removeNilProperties: <T extends object>(obj: T) => { [P in
42
42
  * @kind function
43
43
  */
44
44
  export declare const isOneOf: import("lodash").CurriedFunction2<unknown[], unknown, boolean>;
45
- export declare const returnNullOrUndefinedOrDate: (dateVal: string | number | null | undefined) => Date | null | undefined;
45
+ export declare const returnNullOrUndefinedOrDate: (dateVal: string | Date | number | null | undefined) => Date | null | undefined;
46
46
  /**
47
47
  * This is from https://github.com/siberiacancode/lodash-omitdeep/blob/main/src/omitDeepBy/omitDeepBy.ts
48
48
  * That repo uses outdated lodash packages.
@@ -68,5 +68,13 @@ interface OmitDeepBy {
68
68
  <T extends object>(object: T | null | undefined, predicate: ValueKeyIteratee<T[keyof T]>): PartialObject<T>;
69
69
  }
70
70
  export declare const omitDeepBy: OmitDeepBy;
71
+ /**
72
+ * Safely parses a value if it is a JSON string resulting in an Object or Array.
73
+ * Returns the parsed collection or the original input.
74
+ *
75
+ * @param val
76
+ * @returns
77
+ */
78
+ export declare const parseIfJson: (val: unknown) => any;
71
79
  export {};
72
80
  //# sourceMappingURL=util.d.ts.map
package/util.js CHANGED
@@ -31,10 +31,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.omitDeepBy = exports.returnNullOrUndefinedOrDate = exports.isOneOf = exports.removeNilProperties = exports.deprecate = void 0;
34
+ exports.parseIfJson = exports.omitDeepBy = exports.returnNullOrUndefinedOrDate = exports.isOneOf = exports.removeNilProperties = exports.deprecate = void 0;
35
35
  const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
36
36
  const curry_1 = __importDefault(require("lodash/curry"));
37
37
  const isNil_1 = __importDefault(require("lodash/isNil"));
38
+ const isObject_1 = __importDefault(require("lodash/isObject"));
39
+ const isString_1 = __importDefault(require("lodash/isString"));
38
40
  const omitBy_1 = __importDefault(require("lodash/omitBy"));
39
41
  const log = __importStar(require("./log"));
40
42
  /**
@@ -107,4 +109,23 @@ const omitDeepBy = (object, cb) => {
107
109
  return omitByDeepByOnOwnProps(object);
108
110
  };
109
111
  exports.omitDeepBy = omitDeepBy;
112
+ /**
113
+ * Safely parses a value if it is a JSON string resulting in an Object or Array.
114
+ * Returns the parsed collection or the original input.
115
+ *
116
+ * @param val
117
+ * @returns
118
+ */
119
+ const parseIfJson = (val) => {
120
+ if (!(0, isString_1.default)(val))
121
+ return val;
122
+ try {
123
+ const result = JSON.parse(val);
124
+ return (0, isObject_1.default)(result) ? result : val;
125
+ }
126
+ catch (e) {
127
+ return val;
128
+ }
129
+ };
130
+ exports.parseIfJson = parseIfJson;
110
131
  //# sourceMappingURL=util.js.map