@stackfactor/client-api 1.0.8 → 1.0.10

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/index.js CHANGED
@@ -4,7 +4,7 @@ const config = require("./lib/config");
4
4
  const constants = require("./lib/constants");
5
5
  const integration = require("./lib/integration");
6
6
  const integrationsConfiguration = require("./lib/integrationConfiguration");
7
- const departmentTraiingPlans = require("./lib/departmentTraiingPlans");
7
+ const departmentTraingPlans = require("./lib/departmentTrainingPlans");
8
8
  const groups = require("./lib/groups");
9
9
  const role = require("./lib/role");
10
10
  const roleTemplate = require("./lib/roleTemplate");
@@ -29,7 +29,7 @@ module.exports = {
29
29
  DOCUMENT_VERSION: constants.DOCUMENT_VERSION,
30
30
  integration,
31
31
  integrationsConfiguration,
32
- departmentTraiingPlans,
32
+ departmentTraingPlans,
33
33
  groups,
34
34
  RESONSE_TYPE: constants.RESONSE_TYPE,
35
35
  role,
package/lib/axios.js CHANGED
@@ -35,7 +35,7 @@ module.exports = {
35
35
  return error.response.data.toString();
36
36
  }
37
37
  } else {
38
- return error.message ? error.message : JSON.stringify(error.toString());
38
+ return error.message ? error.message : "Unknown error";
39
39
  }
40
40
  }
41
41
  },
package/lib/users.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { axios } = require("./axios");
2
- import { removeNullProperties } from "../components/Utils";
2
+ const { removeNullProperties } = require("./utils");
3
3
 
4
4
  module.exports = {
5
5
  axios: axios,
package/lib/utils.js CHANGED
@@ -1,6 +1,8 @@
1
1
  const utils = {
2
2
  /**
3
3
  * Convert object to array
4
+ * @param {Object} data
5
+ * @returns {Array}
4
6
  */
5
7
  objectToArray: (data) => {
6
8
  if (typeof data === "object") {
@@ -10,6 +12,7 @@ const utils = {
10
12
 
11
13
  /**
12
14
  * Returns the backend base API URL
15
+ * @returns {String}
13
16
  */
14
17
  getBaseUrl: () => {
15
18
  if (!process.env.NODE_ENV || process.env.NODE_ENV === "production") {
@@ -18,6 +21,24 @@ const utils = {
18
21
  return "http://localhost:3100/";
19
22
  }
20
23
  },
24
+
25
+ /**
26
+ * Remove null properties
27
+ * @param {Object} object
28
+ * @returns {Object}
29
+ */
30
+ removeNullProperties: (object) => {
31
+ Object.keys(object).forEach((key) => {
32
+ let value = object[key.toString()];
33
+ let hasProperties = value && Object.keys(value).length > 0;
34
+ if (value === null) {
35
+ delete object[key.toString()];
36
+ } else if (typeof value !== "string" && hasProperties) {
37
+ removeNullProperties(value);
38
+ }
39
+ });
40
+ return object;
41
+ },
21
42
  };
22
43
 
23
44
  module.exports = utils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Node.js library for the StackFactor API",
5
5
  "main": "index.js",
6
6
  "exports": {