@stackfactor/client-api 1.0.32 → 1.0.34
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 +1 -1
- 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 +2 -1
- package/lib/templates.js +0 -148
package/lib/trainingPlans.js
CHANGED
|
@@ -1,267 +1,265 @@
|
|
|
1
|
-
import
|
|
1
|
+
import axios from "./axiosClient";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Create training plan and set information
|
|
5
|
+
* @param {Object} data
|
|
6
|
+
* @param {Number} type
|
|
7
|
+
* @param {Boolean} saveAsDraft Save as draft flag
|
|
8
|
+
* @param {String} token Authorization token
|
|
9
|
+
*/
|
|
10
|
+
export const createTrainingPlan = (data, type, saveAsDraft, token) => {
|
|
11
|
+
return new Promise(function (resolve, reject) {
|
|
12
|
+
const requestData = {
|
|
13
|
+
data: {
|
|
14
|
+
...data,
|
|
15
|
+
},
|
|
16
|
+
saveAsDraft,
|
|
17
|
+
type,
|
|
18
|
+
};
|
|
19
|
+
let confirmationRequest = axios.put("api/v1/trainingplans", requestData, {
|
|
20
|
+
headers: { authorization: token },
|
|
21
|
+
});
|
|
22
|
+
confirmationRequest
|
|
23
|
+
.then((response) => {
|
|
24
|
+
resolve(response.data);
|
|
25
|
+
})
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
reject(error);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
5
31
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Delete training plan
|
|
34
|
+
* @param {String} id The id of the training plan to be deleted
|
|
35
|
+
* @param {String} comment The comment for approver
|
|
36
|
+
* @param {String} token Authorization token
|
|
37
|
+
*/
|
|
38
|
+
export const deleteTrainingPlan = (id, comment, token) => {
|
|
39
|
+
return new Promise(function (resolve, reject) {
|
|
40
|
+
const data = {
|
|
41
|
+
id: id,
|
|
42
|
+
};
|
|
43
|
+
if (comment) data.comment = comment;
|
|
44
|
+
const request = axios.delete(`api/v1/trainingplans/`, {
|
|
45
|
+
headers: { authorization: token },
|
|
46
|
+
data: data,
|
|
47
|
+
});
|
|
48
|
+
request
|
|
49
|
+
.then((response) => {
|
|
50
|
+
resolve(response.data);
|
|
51
|
+
})
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
reject(error);
|
|
24
54
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Discard the training plan draft changes
|
|
60
|
+
* @param {String} id The id of the training plan to be deleted
|
|
61
|
+
* @param {String} token Authorization token
|
|
62
|
+
*/
|
|
63
|
+
export const discardTrainingPlanChanges = (id, token) => {
|
|
64
|
+
return new Promise(function (resolve, reject) {
|
|
65
|
+
const request = axios.get(`api/v1/trainingplans/discard/${id}`, {
|
|
66
|
+
headers: { authorization: token },
|
|
32
67
|
});
|
|
33
|
-
|
|
68
|
+
request
|
|
69
|
+
.then((response) => {
|
|
70
|
+
resolve(response.data);
|
|
71
|
+
})
|
|
72
|
+
.catch((error) => {
|
|
73
|
+
reject(error);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
34
77
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Create a new baselie
|
|
80
|
+
* @param {String} id The Id of the plan for which a new baseline is to be generated
|
|
81
|
+
* @param {Object} data The data
|
|
82
|
+
* @param {Boolean} returnMinimized If set to true just high level plan baseline information will be returned
|
|
83
|
+
* @param {Boolean} saveBaseline If set to true it will save the baseline
|
|
84
|
+
* @param {String} token Authorization token
|
|
85
|
+
*/
|
|
86
|
+
export const generateNewBaseline = (
|
|
87
|
+
id,
|
|
88
|
+
data,
|
|
89
|
+
returnMinimized,
|
|
90
|
+
saveBaseline,
|
|
91
|
+
token
|
|
92
|
+
) => {
|
|
93
|
+
return new Promise(function (resolve, reject) {
|
|
94
|
+
const requestData = {
|
|
95
|
+
data: data,
|
|
96
|
+
returnMinimized: returnMinimized,
|
|
97
|
+
saveBaseline: saveBaseline,
|
|
98
|
+
};
|
|
99
|
+
if (id) requestData.id = id;
|
|
100
|
+
let confirmationRequest = axios.post(
|
|
101
|
+
"api/v1/trainingplans/generatenewbaseline",
|
|
102
|
+
requestData,
|
|
103
|
+
{
|
|
48
104
|
headers: { authorization: token },
|
|
49
|
-
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
confirmationRequest
|
|
108
|
+
.then((response) => {
|
|
109
|
+
resolve(response.data);
|
|
110
|
+
})
|
|
111
|
+
.catch((error) => {
|
|
112
|
+
reject(error);
|
|
50
113
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
resolve(response.data);
|
|
54
|
-
})
|
|
55
|
-
.catch((error) => {
|
|
56
|
-
reject(error);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
},
|
|
114
|
+
});
|
|
115
|
+
};
|
|
60
116
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Get traing plan information
|
|
119
|
+
* @param {String} id The id of the training plan
|
|
120
|
+
* @param {String} token Authorization token
|
|
121
|
+
*/
|
|
122
|
+
export const getTrainingPlanById = (id, version, token) => {
|
|
123
|
+
return new Promise(function (resolve, reject) {
|
|
124
|
+
let confirmationRequest = axios.get(
|
|
125
|
+
`api/v1/trainingplans/${id}/${version}`,
|
|
126
|
+
{
|
|
69
127
|
headers: { authorization: token },
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
confirmationRequest
|
|
131
|
+
.then((response) => {
|
|
132
|
+
resolve(response.data);
|
|
133
|
+
})
|
|
134
|
+
.catch((error) => {
|
|
135
|
+
reject(error);
|
|
70
136
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
resolve(response.data);
|
|
74
|
-
})
|
|
75
|
-
.catch((error) => {
|
|
76
|
-
reject(error);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Create a new baselie
|
|
83
|
-
* @param {String} id The Id of the plan for which a new baseline is to be generated
|
|
84
|
-
* @param {Object} data The data
|
|
85
|
-
* @param {Boolean} returnMinimized If set to true just high level plan baseline information will be returned
|
|
86
|
-
* @param {Boolean} saveBaseline If set to true it will save the baseline
|
|
87
|
-
* @param {String} token Authorization token
|
|
88
|
-
*/
|
|
89
|
-
generateNewBaseline: (id, data, returnMinimized, saveBaseline, token) => {
|
|
90
|
-
return new Promise(function (resolve, reject) {
|
|
91
|
-
const requestData = {
|
|
92
|
-
data: data,
|
|
93
|
-
returnMinimized: returnMinimized,
|
|
94
|
-
saveBaseline: saveBaseline,
|
|
95
|
-
};
|
|
96
|
-
if (id) requestData.id = id;
|
|
97
|
-
let confirmationRequest = axios.post(
|
|
98
|
-
"api/v1/trainingplans/generatenewbaseline",
|
|
99
|
-
requestData,
|
|
100
|
-
{
|
|
101
|
-
headers: { authorization: token },
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
confirmationRequest
|
|
105
|
-
.then((response) => {
|
|
106
|
-
resolve(response.data);
|
|
107
|
-
})
|
|
108
|
-
.catch((error) => {
|
|
109
|
-
reject(error);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get traing plan information
|
|
116
|
-
* @param {String} id The id of the training plan
|
|
117
|
-
* @param {String} token Authorization token
|
|
118
|
-
*/
|
|
119
|
-
getTrainingPlanById: (id, version, token) => {
|
|
120
|
-
return new Promise(function (resolve, reject) {
|
|
121
|
-
let confirmationRequest = axios.get(
|
|
122
|
-
`api/v1/trainingplans/${id}/${version}`,
|
|
123
|
-
{
|
|
124
|
-
headers: { authorization: token },
|
|
125
|
-
}
|
|
126
|
-
);
|
|
127
|
-
confirmationRequest
|
|
128
|
-
.then((response) => {
|
|
129
|
-
resolve(response.data);
|
|
130
|
-
})
|
|
131
|
-
.catch((error) => {
|
|
132
|
-
reject(error);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
},
|
|
137
|
+
});
|
|
138
|
+
};
|
|
136
139
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
requestData,
|
|
170
|
-
{
|
|
171
|
-
headers: { authorization: token },
|
|
172
|
-
}
|
|
173
|
-
);
|
|
174
|
-
confirmationRequest
|
|
175
|
-
.then((response) => {
|
|
176
|
-
resolve(response.data);
|
|
177
|
-
})
|
|
178
|
-
.catch((error) => {
|
|
179
|
-
reject(error);
|
|
180
|
-
});
|
|
140
|
+
/**
|
|
141
|
+
* Get training plans list
|
|
142
|
+
* @param {Array<ObjectId>} users The list of users for which the plans should be loaded
|
|
143
|
+
* @param {Array<Number>} types The types of plans to be loaded
|
|
144
|
+
* @param {String} version The version of the document to be retrieved
|
|
145
|
+
* @param {Array<String>} fields The fields to be selected
|
|
146
|
+
* @param {Boolean} includeDeleted If set true it will return deleted plans too
|
|
147
|
+
* @param {Boolean} returnDefaultIfVersionNotAvailable If set to true it will load the draft information if the plan was never published
|
|
148
|
+
* @param {String} token Authorization token
|
|
149
|
+
*/
|
|
150
|
+
export const getListOfTrainingPlans = (
|
|
151
|
+
users,
|
|
152
|
+
types,
|
|
153
|
+
version,
|
|
154
|
+
fields,
|
|
155
|
+
includeDeleted,
|
|
156
|
+
includeDetailedInformation,
|
|
157
|
+
returnDefaultIfVersionNotAvailable,
|
|
158
|
+
token
|
|
159
|
+
) => {
|
|
160
|
+
return new Promise(function (resolve, reject) {
|
|
161
|
+
const requestData = {
|
|
162
|
+
version: version,
|
|
163
|
+
includeDeleted: includeDeleted,
|
|
164
|
+
includeDetailedInformation: includeDetailedInformation,
|
|
165
|
+
returnDefaultIfVersionNotAvailable: returnDefaultIfVersionNotAvailable,
|
|
166
|
+
};
|
|
167
|
+
if (fields) requestData.fields = fields;
|
|
168
|
+
if (types) requestData.types = types;
|
|
169
|
+
if (users) requestData.users = users;
|
|
170
|
+
let confirmationRequest = axios.post(`api/v1/trainingplans`, requestData, {
|
|
171
|
+
headers: { authorization: token },
|
|
181
172
|
});
|
|
182
|
-
|
|
173
|
+
confirmationRequest
|
|
174
|
+
.then((response) => {
|
|
175
|
+
resolve(response.data);
|
|
176
|
+
})
|
|
177
|
+
.catch((error) => {
|
|
178
|
+
reject(error);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
183
182
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Publish training plan
|
|
185
|
+
* @param {String} id The id of the template to be published
|
|
186
|
+
* @param {String} comment The comment to be include with the request
|
|
187
|
+
* @param {String} token Authorization token
|
|
188
|
+
*/
|
|
189
|
+
export const publishTrainingPlan = (id, comment, token) => {
|
|
190
|
+
return new Promise(function (resolve, reject) {
|
|
191
|
+
let data = {};
|
|
192
|
+
if (comment) data.comment = comment;
|
|
193
|
+
let confirmationRequest = axios.post(
|
|
194
|
+
`api/v1/trainingplans/publish/${id}`,
|
|
195
|
+
data,
|
|
196
|
+
{
|
|
197
|
+
headers: { authorization: token },
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
confirmationRequest
|
|
201
|
+
.then((response) => {
|
|
202
|
+
resolve(response.data);
|
|
203
|
+
})
|
|
204
|
+
.catch((error) => {
|
|
205
|
+
reject(error);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
};
|
|
210
209
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Update training plan
|
|
212
|
+
* @param {String} id The ID of the training plan
|
|
213
|
+
* @param {Object} data The updated data
|
|
214
|
+
* @param {String} token Authorization token
|
|
215
|
+
*/
|
|
216
|
+
export const updateTrainingPlan = (planId, data, saveAsDraft, token) => {
|
|
217
|
+
return new Promise(function (resolve, reject) {
|
|
218
|
+
const requestData = {
|
|
219
|
+
data: data,
|
|
220
|
+
id: planId,
|
|
221
|
+
saveAsDraft,
|
|
222
|
+
};
|
|
223
|
+
let confirmationRequest = axios.put(
|
|
224
|
+
`api/v1/trainingplans/update/${planId}`,
|
|
225
|
+
requestData,
|
|
226
|
+
{
|
|
227
|
+
headers: { authorization: token },
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
confirmationRequest
|
|
231
|
+
.then((response) => {
|
|
232
|
+
resolve(response.data);
|
|
233
|
+
})
|
|
234
|
+
.catch((error) => {
|
|
235
|
+
reject(error);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
240
239
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
},
|
|
240
|
+
/**
|
|
241
|
+
* Update a task
|
|
242
|
+
* @param {String} planId
|
|
243
|
+
* @param {Object} data Ordered array of objects containing the activity Id and the new status
|
|
244
|
+
* @param {Function} successCallBack
|
|
245
|
+
* @param {Function} failCallBack
|
|
246
|
+
* @returns {Object} An object containing the task information
|
|
247
|
+
*/
|
|
248
|
+
export const updateActivities = (planId, data, token) => {
|
|
249
|
+
return new Promise(function (resolve, reject) {
|
|
250
|
+
let confirmationRequest = axios.post(
|
|
251
|
+
`api/v1/trainingplans/${planId}/activities`,
|
|
252
|
+
data,
|
|
253
|
+
{
|
|
254
|
+
headers: { authorization: token },
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
confirmationRequest
|
|
258
|
+
.then(() => {
|
|
259
|
+
resolve();
|
|
260
|
+
})
|
|
261
|
+
.catch((error) => {
|
|
262
|
+
reject(error);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
267
265
|
};
|