@stackfactor/client-api 1.0.31 → 1.0.33
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 +0 -2
- package/lib/actionNotifications.js +202 -226
- package/lib/address.js +21 -27
- package/lib/axiosClient.js +58 -64
- package/lib/config.js +62 -66
- package/lib/dashboard.js +64 -68
- package/lib/departmentTrainingPlans.js +159 -153
- package/lib/groups.js +266 -291
- package/lib/integration.js +307 -312
- package/lib/integrationConfiguration.js +96 -90
- package/lib/integrations/contentGenerator.js +71 -74
- package/lib/learningContent.js +239 -240
- package/lib/logger.js +51 -56
- package/lib/role.js +238 -245
- package/lib/roleTemplate.js +247 -255
- package/lib/skill.js +299 -311
- package/lib/skillAssessmentTestingSession.js +132 -137
- package/lib/skillAssessments.js +125 -129
- package/lib/skillTemplate.js +250 -255
- package/lib/teams.js +261 -257
- package/lib/tenants.js +48 -52
- package/lib/trainingPlanTemplate.js +203 -202
- package/lib/trainingPlans.js +249 -251
- package/lib/userInformation.js +97 -85
- package/lib/users.js +557 -555
- package/lib/utils.js +38 -42
- package/package.json +1 -1
- package/lib/templates.js +0 -148
package/lib/utils.js
CHANGED
|
@@ -1,48 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
2
|
// Load environment variables from .env file
|
|
3
3
|
dotenv.config();
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns the backend base API URL
|
|
19
|
-
* @returns {String}
|
|
20
|
-
*/
|
|
21
|
-
getBaseUrl: () => {
|
|
22
|
-
if (!process.env.NODE_ENV || process.env.NODE_ENV === "production") {
|
|
23
|
-
return "https://api.stackfactor.io/";
|
|
24
|
-
} else {
|
|
25
|
-
return "http://localhost:3100/";
|
|
26
|
-
}
|
|
27
|
-
},
|
|
5
|
+
/**
|
|
6
|
+
* Convert object to array
|
|
7
|
+
* @param {Object} data
|
|
8
|
+
* @returns {Array}
|
|
9
|
+
*/
|
|
10
|
+
export const objectToArray = (data) => {
|
|
11
|
+
if (typeof data === "object") {
|
|
12
|
+
return [...data];
|
|
13
|
+
} else throw new Error("Invalid type");
|
|
14
|
+
};
|
|
28
15
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
delete object[key.toString()];
|
|
40
|
-
} else if (typeof value !== "string" && hasProperties) {
|
|
41
|
-
removeNullProperties(value);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return object;
|
|
45
|
-
},
|
|
16
|
+
/**
|
|
17
|
+
* Returns the backend base API URL
|
|
18
|
+
* @returns {String}
|
|
19
|
+
*/
|
|
20
|
+
export const getBaseUrl = () => {
|
|
21
|
+
if (!process.env.NODE_ENV || process.env.NODE_ENV === "production") {
|
|
22
|
+
return "https://api.stackfactor.io/";
|
|
23
|
+
} else {
|
|
24
|
+
return "http://localhost:3100/";
|
|
25
|
+
}
|
|
46
26
|
};
|
|
47
27
|
|
|
48
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Remove null properties
|
|
30
|
+
* @param {Object} object
|
|
31
|
+
* @returns {Object}
|
|
32
|
+
*/
|
|
33
|
+
export const removeNullProperties = (object) => {
|
|
34
|
+
Object.keys(object).forEach((key) => {
|
|
35
|
+
let value = object[key.toString()];
|
|
36
|
+
let hasProperties = value && Object.keys(value).length > 0;
|
|
37
|
+
if (value === null) {
|
|
38
|
+
delete object[key.toString()];
|
|
39
|
+
} else if (typeof value !== "string" && hasProperties) {
|
|
40
|
+
removeNullProperties(value);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return object;
|
|
44
|
+
};
|
package/package.json
CHANGED
package/lib/templates.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { axios } from "./axiosClient";
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
axios: axios,
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create template and set information
|
|
8
|
-
* @param {Object} data New template data information
|
|
9
|
-
* @param {String} token Authorization token
|
|
10
|
-
*/
|
|
11
|
-
createTemplate: (data, token) => {
|
|
12
|
-
return new Promise(function (resolve, reject) {
|
|
13
|
-
const requestData = {
|
|
14
|
-
data: data,
|
|
15
|
-
};
|
|
16
|
-
let confirmationRequest = axios.put("api/v1/templates", requestData, {
|
|
17
|
-
headers: { authorization: token },
|
|
18
|
-
});
|
|
19
|
-
confirmationRequest
|
|
20
|
-
.then((response) => {
|
|
21
|
-
resolve(response.data);
|
|
22
|
-
})
|
|
23
|
-
.catch((error) => {
|
|
24
|
-
reject(error);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Delete template
|
|
31
|
-
* @param {number} id The id of the template to be deleted
|
|
32
|
-
* @param {String} token Authorization token
|
|
33
|
-
*/
|
|
34
|
-
deleteTemplate: (id, token) => {
|
|
35
|
-
return new Promise(function (resolve, reject) {
|
|
36
|
-
const requestData = {
|
|
37
|
-
id: id,
|
|
38
|
-
};
|
|
39
|
-
let confirmationRequest = axios.delete(`api/v1/templates/`, {
|
|
40
|
-
headers: { authorization: token },
|
|
41
|
-
data: requestData,
|
|
42
|
-
});
|
|
43
|
-
confirmationRequest
|
|
44
|
-
.then((response) => {
|
|
45
|
-
resolve(response);
|
|
46
|
-
})
|
|
47
|
-
.catch((error) => {
|
|
48
|
-
reject(error);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Get template information
|
|
55
|
-
* @param {number} id The id of the template
|
|
56
|
-
* @param {String} token Authorization token
|
|
57
|
-
*/
|
|
58
|
-
getTemplateInformationById: (id, version, token) => {
|
|
59
|
-
return new Promise(function (resolve, reject) {
|
|
60
|
-
let confirmationRequest = axios.get(`api/v1/templates/${id}/${version}`, {
|
|
61
|
-
headers: { authorization: token },
|
|
62
|
-
});
|
|
63
|
-
confirmationRequest
|
|
64
|
-
.then((response) => {
|
|
65
|
-
resolve(response.data);
|
|
66
|
-
})
|
|
67
|
-
.catch((error) => {
|
|
68
|
-
reject(error);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get template information
|
|
75
|
-
* @param {Object} filter The filter used to select the template
|
|
76
|
-
* @param {String} token Authorization token
|
|
77
|
-
*/
|
|
78
|
-
getTemplateList: (filter, version, token) => {
|
|
79
|
-
return new Promise(function (resolve, reject) {
|
|
80
|
-
const requestData = {
|
|
81
|
-
filter: filter ? filter : "",
|
|
82
|
-
version: version,
|
|
83
|
-
};
|
|
84
|
-
let confirmationRequest = axios.post(`api/v1/templates`, requestData, {
|
|
85
|
-
headers: { authorization: token },
|
|
86
|
-
});
|
|
87
|
-
confirmationRequest
|
|
88
|
-
.then((response) => {
|
|
89
|
-
resolve(response.data);
|
|
90
|
-
})
|
|
91
|
-
.catch((error) => {
|
|
92
|
-
reject(error);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Publish template
|
|
99
|
-
* @param {number} id The id of the template to be published
|
|
100
|
-
* @param {String} token Authorization token
|
|
101
|
-
*/
|
|
102
|
-
publishTemplate: (id, token) => {
|
|
103
|
-
return new Promise(function (resolve, reject) {
|
|
104
|
-
let confirmationRequest = axios.post(
|
|
105
|
-
`api/v1/templates/publish/${id}`,
|
|
106
|
-
{},
|
|
107
|
-
{
|
|
108
|
-
headers: { authorization: token },
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
confirmationRequest
|
|
112
|
-
.then((response) => {
|
|
113
|
-
resolve(response.data);
|
|
114
|
-
})
|
|
115
|
-
.catch((error) => {
|
|
116
|
-
reject(error);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Set template profile information
|
|
123
|
-
* @param {String} id The id of the template to be updated
|
|
124
|
-
* @param {Object} data Data used to update the template
|
|
125
|
-
* @param {String} token Authorization token
|
|
126
|
-
*/
|
|
127
|
-
setTemplateInformation: (id, data, token) => {
|
|
128
|
-
return new Promise(function (resolve, reject) {
|
|
129
|
-
const requestData = {
|
|
130
|
-
data: data,
|
|
131
|
-
};
|
|
132
|
-
let confirmationRequest = axios.post(
|
|
133
|
-
`api/v1/templates/${id}`,
|
|
134
|
-
requestData,
|
|
135
|
-
{
|
|
136
|
-
headers: { authorization: token },
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
confirmationRequest
|
|
140
|
-
.then((response) => {
|
|
141
|
-
resolve(response.data);
|
|
142
|
-
})
|
|
143
|
-
.catch((error) => {
|
|
144
|
-
reject(error);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
},
|
|
148
|
-
};
|