@stackfactor/client-api 1.1.11 → 1.1.12-9.2
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/.eslintrc.json +13 -0
- package/{exports.js → exports.ts} +14 -0
- package/index.ts +1 -0
- package/lib/{actionNotifications.js → actionNotifications.ts} +21 -11
- package/lib/{address.js → address.ts} +4 -5
- package/lib/aiAssistant.ts +197 -0
- package/lib/avatar.ts +41 -0
- package/lib/axiosClient.ts +92 -0
- package/lib/{config.js → config.ts} +20 -9
- package/lib/{constants.js → constants.ts} +11 -41
- package/lib/{dashboard.js → dashboard.ts} +19 -10
- package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +63 -32
- package/lib/{groups.js → groups.ts} +68 -29
- package/lib/{integration.js → integration.ts} +103 -47
- package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +27 -22
- package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
- package/lib/{learningContent.js → learningContent.ts} +218 -62
- package/lib/{learningPath.js → learningPath.ts} +57 -30
- package/lib/{logger.js → logger.ts} +18 -8
- package/lib/microSkillsQuizes.ts +70 -0
- package/lib/quotas.ts +59 -0
- package/lib/{role.js → role.ts} +117 -69
- package/lib/{roleTemplate.js → roleTemplate.ts} +65 -30
- package/lib/security.ts +99 -0
- package/lib/{skill.js → skill.ts} +125 -87
- package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +63 -16
- package/lib/skillAssessments.ts +192 -0
- package/lib/{skillTemplate.js → skillTemplate.ts} +73 -42
- package/lib/talentTransfromation.ts +126 -0
- package/lib/{teams.js → teams.ts} +73 -38
- package/lib/{tenants.js → tenants.ts} +17 -10
- package/lib/{trainingPlans.js → trainingPlans.ts} +159 -56
- package/lib/trainingPlansProficiencyLevels.ts +132 -0
- package/lib/{userInformation.js → userInformation.ts} +27 -26
- package/lib/{users.js → users.ts} +239 -140
- package/lib/utils.ts +64 -0
- package/package.json +12 -1
- package/index.js +0 -3
- package/lib/axiosClient.js +0 -85
- package/lib/skillAssessmentTestingSession.js +0 -148
- package/lib/utils.js +0 -48
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get responses for a microskill quiz
|
|
5
|
+
* @param {String} learningContentId
|
|
6
|
+
* @param {String} microSkillId
|
|
7
|
+
* @param {String} token
|
|
8
|
+
* @returns {Promise<Object>}
|
|
9
|
+
*/
|
|
10
|
+
const getResponses = (
|
|
11
|
+
learningContentId: string,
|
|
12
|
+
microSkillId: string,
|
|
13
|
+
token: string
|
|
14
|
+
): Promise<object> => {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
let confirmationRequest = client.get(
|
|
17
|
+
`api/v1/microskillsresponses/${learningContentId}/${microSkillId}`,
|
|
18
|
+
{
|
|
19
|
+
headers: { authorization: token },
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
confirmationRequest
|
|
23
|
+
.then((response) => {
|
|
24
|
+
resolve(response.data);
|
|
25
|
+
})
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
reject(error);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Save responses for a microskill quiz
|
|
34
|
+
* @param {String} learningContentId
|
|
35
|
+
* @param {String} microSkillId
|
|
36
|
+
* @param {Array<Object>} responses
|
|
37
|
+
* @param {String} token Authorization token
|
|
38
|
+
* @returns {Promise<Object>}
|
|
39
|
+
*/
|
|
40
|
+
const saveResponses = (
|
|
41
|
+
learningContentId: string,
|
|
42
|
+
microSkillId: string,
|
|
43
|
+
responses: object[],
|
|
44
|
+
token: string
|
|
45
|
+
): Promise<object> => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
let data = {
|
|
48
|
+
responses: responses,
|
|
49
|
+
};
|
|
50
|
+
let confirmationRequest = client.post(
|
|
51
|
+
`api/v1/microskillsresponses/${learningContentId}/${microSkillId}`,
|
|
52
|
+
data,
|
|
53
|
+
{
|
|
54
|
+
headers: { authorization: token },
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
confirmationRequest
|
|
58
|
+
.then((response) => {
|
|
59
|
+
resolve(response.data);
|
|
60
|
+
})
|
|
61
|
+
.catch((error) => {
|
|
62
|
+
reject(error);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default {
|
|
68
|
+
getResponses,
|
|
69
|
+
saveResponses,
|
|
70
|
+
};
|
package/lib/quotas.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the current quota for the user and tenant
|
|
5
|
+
* @param {String} token
|
|
6
|
+
* @returns {Promise<Object>}
|
|
7
|
+
*/
|
|
8
|
+
const getAllQuota = (token: string): Promise<object> => {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
let confirmationRequest = client.get(`/api/v1/quotas/getallquota`, {
|
|
11
|
+
headers: { authorization: token },
|
|
12
|
+
});
|
|
13
|
+
confirmationRequest
|
|
14
|
+
.then((response) => {
|
|
15
|
+
resolve(response.data);
|
|
16
|
+
})
|
|
17
|
+
.catch((error) => {
|
|
18
|
+
reject(error);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Increase quota utilization
|
|
25
|
+
* @param {String} quotaId
|
|
26
|
+
* @param {Number} value
|
|
27
|
+
* @param {String} token
|
|
28
|
+
* @returns {Promise<Object>}
|
|
29
|
+
*/
|
|
30
|
+
const increaseQuotaUtilization = (
|
|
31
|
+
quotaId: string,
|
|
32
|
+
value: number,
|
|
33
|
+
token: string
|
|
34
|
+
): Promise<object> => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
let confirmationRequest = client.post(
|
|
37
|
+
`/api/v1/quotas/increaseutilization`,
|
|
38
|
+
{
|
|
39
|
+
id: quotaId,
|
|
40
|
+
value: value,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
headers: { authorization: token },
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
confirmationRequest
|
|
47
|
+
.then((response) => {
|
|
48
|
+
resolve(response.data);
|
|
49
|
+
})
|
|
50
|
+
.catch((error) => {
|
|
51
|
+
reject(error);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
getAllQuota,
|
|
58
|
+
increaseQuotaUtilization,
|
|
59
|
+
};
|
package/lib/{role.js → role.ts}
RENAMED
|
@@ -4,10 +4,10 @@ import { client } from "./axiosClient.js";
|
|
|
4
4
|
* Create role and set information
|
|
5
5
|
* @param {Object} data
|
|
6
6
|
* @param {String} token Authorization token
|
|
7
|
-
* @returns {Promise}
|
|
7
|
+
* @returns {Promise<Object>}
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
return new Promise(
|
|
9
|
+
const createRole = (data: object, token: string): Promise<object> => {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
11
|
let confirmationRequest = client.put(
|
|
12
12
|
"api/v1/roles",
|
|
13
13
|
{ data: data },
|
|
@@ -30,13 +30,29 @@ export const createRole = (data, token) => {
|
|
|
30
30
|
* @param {String} templateId
|
|
31
31
|
* @param {Object} data
|
|
32
32
|
* @param {String} token Authorization token
|
|
33
|
-
* @returns {Promise}
|
|
33
|
+
* @returns {Promise<Object>}
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const createRoleFromTemplate = (
|
|
36
|
+
templateId: string,
|
|
37
|
+
data: object,
|
|
38
|
+
token: string
|
|
39
|
+
): Promise<object> => {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const requestData: {
|
|
42
|
+
includeDeleted: boolean;
|
|
43
|
+
includeDetailedInformation: boolean;
|
|
44
|
+
namesOnly: boolean;
|
|
45
|
+
returnDefaultIfVersionNotAvailable: boolean;
|
|
46
|
+
version: string;
|
|
47
|
+
filter?: object;
|
|
48
|
+
templateId: string;
|
|
49
|
+
} = {
|
|
38
50
|
templateId: templateId,
|
|
39
|
-
|
|
51
|
+
includeDeleted: false,
|
|
52
|
+
includeDetailedInformation: false,
|
|
53
|
+
namesOnly: false,
|
|
54
|
+
returnDefaultIfVersionNotAvailable: false,
|
|
55
|
+
version: "1.0",
|
|
40
56
|
};
|
|
41
57
|
let confirmationRequest = client.put(
|
|
42
58
|
"api/v1/roles/createfromtemplate/",
|
|
@@ -60,11 +76,15 @@ export const createRoleFromTemplate = (templateId, data, token) => {
|
|
|
60
76
|
* @param {String} id The id of the role to be deleted
|
|
61
77
|
* @param {String} comments The comments included with the deletion
|
|
62
78
|
* @param {String} token Authorization token
|
|
63
|
-
* @returns {Promise}
|
|
79
|
+
* @returns {Promise<Object>}
|
|
64
80
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
const deleteRole = (
|
|
82
|
+
id: string,
|
|
83
|
+
comments: string,
|
|
84
|
+
token: string
|
|
85
|
+
): Promise<object> => {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const data: { id: string, comments?: string } = {
|
|
68
88
|
id: id,
|
|
69
89
|
};
|
|
70
90
|
if (comments) data.comments = comments;
|
|
@@ -86,10 +106,10 @@ export const deleteRole = (id, comments, token) => {
|
|
|
86
106
|
* Discard the role draft changes
|
|
87
107
|
* @param {String} id The id of the role to be deleted
|
|
88
108
|
* @param {String} token Authorization token
|
|
89
|
-
* @returns {Promise}
|
|
109
|
+
* @returns {Promise<Object>}
|
|
90
110
|
*/
|
|
91
|
-
|
|
92
|
-
return new Promise(
|
|
111
|
+
const discardRoleChanges = (id: string, token: string): Promise<object> => {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
93
113
|
const data = {};
|
|
94
114
|
const request = client.get(`api/v1/roles/discard/${id}`, {
|
|
95
115
|
headers: { authorization: token },
|
|
@@ -108,15 +128,14 @@ export const discardRoleChanges = (id, token) => {
|
|
|
108
128
|
/**
|
|
109
129
|
* Get the list of imported role templates
|
|
110
130
|
* @param {String} token
|
|
111
|
-
* @returns {Promise}
|
|
131
|
+
* @returns {Promise<Object>}
|
|
112
132
|
*/
|
|
113
|
-
|
|
114
|
-
return new Promise(
|
|
133
|
+
const getImportedRoleTemplates = (token: string): Promise<object> => {
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
115
135
|
const request = client.get(`api/v1/roles/getimportedroletemplates`, {
|
|
116
136
|
headers: { authorization: token },
|
|
117
137
|
});
|
|
118
138
|
request
|
|
119
|
-
|
|
120
139
|
.then((response) => {
|
|
121
140
|
resolve(response.data);
|
|
122
141
|
})
|
|
@@ -132,15 +151,15 @@ export const getImportedRoleTemplates = (token) => {
|
|
|
132
151
|
* @param {String} version The version to be retrieved
|
|
133
152
|
* @param {Boolean} returnNullIfVersionNotFound Return null if the version is not found
|
|
134
153
|
* @param {String} token Authorization token
|
|
135
|
-
* @returns {Promise}
|
|
154
|
+
* @returns {Promise<Object>}
|
|
136
155
|
*/
|
|
137
|
-
|
|
138
|
-
id,
|
|
139
|
-
version,
|
|
140
|
-
returnNullIfVersionNotFound,
|
|
141
|
-
token
|
|
142
|
-
) => {
|
|
143
|
-
return new Promise(
|
|
156
|
+
const getRoleInformationById = (
|
|
157
|
+
id: number,
|
|
158
|
+
version: string,
|
|
159
|
+
returnNullIfVersionNotFound: boolean,
|
|
160
|
+
token: string
|
|
161
|
+
): Promise<object> => {
|
|
162
|
+
return new Promise((resolve, reject) => {
|
|
144
163
|
let confirmationRequest = client.get(
|
|
145
164
|
`api/v1/roles/role/${id}/${version}/${returnNullIfVersionNotFound}`,
|
|
146
165
|
{
|
|
@@ -166,19 +185,26 @@ export const getRoleInformationById = (
|
|
|
166
185
|
* @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
|
|
167
186
|
* @param {Boolean} namesOnly Return only the names of the roles
|
|
168
187
|
* @param {String} token Authorization token
|
|
169
|
-
* @returns {Promise}
|
|
188
|
+
* @returns {Promise<Object>}
|
|
170
189
|
*/
|
|
171
|
-
|
|
172
|
-
filter,
|
|
173
|
-
version,
|
|
174
|
-
includeDeleted,
|
|
175
|
-
includeDetailedInformation,
|
|
176
|
-
returnDefaultIfVersionNotAvailable,
|
|
177
|
-
namesOnly,
|
|
178
|
-
token
|
|
179
|
-
) => {
|
|
180
|
-
return new Promise(
|
|
181
|
-
const requestData
|
|
190
|
+
const getRolesList = (
|
|
191
|
+
filter: object,
|
|
192
|
+
version: string,
|
|
193
|
+
includeDeleted: boolean,
|
|
194
|
+
includeDetailedInformation: boolean,
|
|
195
|
+
returnDefaultIfVersionNotAvailable: boolean,
|
|
196
|
+
namesOnly: boolean,
|
|
197
|
+
token: string
|
|
198
|
+
): Promise<object> => {
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
const requestData: {
|
|
201
|
+
includeDeleted: boolean;
|
|
202
|
+
includeDetailedInformation: boolean;
|
|
203
|
+
namesOnly: boolean;
|
|
204
|
+
returnDefaultIfVersionNotAvailable: boolean;
|
|
205
|
+
version: string;
|
|
206
|
+
filter?: object;
|
|
207
|
+
} = {
|
|
182
208
|
includeDeleted: includeDeleted,
|
|
183
209
|
includeDetailedInformation: includeDetailedInformation,
|
|
184
210
|
namesOnly: namesOnly,
|
|
@@ -203,10 +229,10 @@ export const getRolesList = (
|
|
|
203
229
|
* Get role template updates
|
|
204
230
|
* @param {String} id The role id
|
|
205
231
|
* @param {String} token
|
|
206
|
-
* @returns {Promise}
|
|
232
|
+
* @returns {Promise<Object>}
|
|
207
233
|
*/
|
|
208
|
-
|
|
209
|
-
return new Promise(
|
|
234
|
+
const getRoleTemplateUpdates = (id: string, token: string): Promise<object> => {
|
|
235
|
+
return new Promise((resolve, reject) => {
|
|
210
236
|
let confirmationRequest = client.get(
|
|
211
237
|
`api/v1/roles/getroletemplateupdates/${id}`,
|
|
212
238
|
{
|
|
@@ -225,14 +251,18 @@ export const getRoleTemplateUpdates = (id, token) => {
|
|
|
225
251
|
|
|
226
252
|
/**
|
|
227
253
|
* Import role templates
|
|
228
|
-
* @param {Array<
|
|
254
|
+
* @param {Array<Object>} data The list of role templates to be imported
|
|
229
255
|
* @param {String} token
|
|
230
|
-
* @returns {Promise}
|
|
256
|
+
* @returns {Promise<Object>}
|
|
231
257
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
258
|
+
const importRoleTemplates = (
|
|
259
|
+
data: object[],
|
|
260
|
+
token: string
|
|
261
|
+
): Promise<object> => {
|
|
262
|
+
return new Promise((resolve, reject) => {
|
|
263
|
+
const requestData: { roles: object[]; jobDescription: string; userid?: string } = {
|
|
264
|
+
roles: data,
|
|
265
|
+
jobDescription: "default job description", // Add a default job description or pass it as a parameter
|
|
236
266
|
};
|
|
237
267
|
let confirmationRequest = client.post(
|
|
238
268
|
`api/v1/roles/importRoleTemplates`,
|
|
@@ -242,7 +272,6 @@ export const importRoleTemplates = (data, token) => {
|
|
|
242
272
|
}
|
|
243
273
|
);
|
|
244
274
|
confirmationRequest
|
|
245
|
-
|
|
246
275
|
.then((response) => {
|
|
247
276
|
resolve(response.data);
|
|
248
277
|
})
|
|
@@ -257,11 +286,15 @@ export const importRoleTemplates = (data, token) => {
|
|
|
257
286
|
* @param {number} id The id of the role to be published
|
|
258
287
|
* @param {String} comments The comments to be include with the request
|
|
259
288
|
* @param {String} token Authorization token
|
|
260
|
-
* @returns {Promise}
|
|
289
|
+
* @returns {Promise<Object>}
|
|
261
290
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
291
|
+
const publishRole = (
|
|
292
|
+
id: number,
|
|
293
|
+
comments: string,
|
|
294
|
+
token: string
|
|
295
|
+
): Promise<object> => {
|
|
296
|
+
return new Promise((resolve, reject) => {
|
|
297
|
+
let data: { comments?: string } = {};
|
|
265
298
|
if (comments) data.comments = comments;
|
|
266
299
|
let confirmationRequest = client.post(`api/v1/roles/publish/${id}`, data, {
|
|
267
300
|
headers: { authorization: token },
|
|
@@ -281,10 +314,14 @@ export const publishRole = (id, comments, token) => {
|
|
|
281
314
|
* @param {String} id The id of the role to be updated
|
|
282
315
|
* @param {Object} data Data used to update the role
|
|
283
316
|
* @param {String} token Authorization token
|
|
284
|
-
* @returns {Promise}
|
|
317
|
+
* @returns {Promise<Object>}
|
|
285
318
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
319
|
+
const setRoleInformation = (
|
|
320
|
+
id: string,
|
|
321
|
+
data: object,
|
|
322
|
+
token: string
|
|
323
|
+
): Promise<object> => {
|
|
324
|
+
return new Promise((resolve, reject) => {
|
|
288
325
|
const requestData = {
|
|
289
326
|
data: data,
|
|
290
327
|
id: id,
|
|
@@ -307,10 +344,14 @@ export const setRoleInformation = (id, data, token) => {
|
|
|
307
344
|
* @param {String} id The id of the role to be updated
|
|
308
345
|
* @param {Object} data Data used to update the role
|
|
309
346
|
* @param {String} token Authorization token
|
|
310
|
-
* @returns {Promise}
|
|
347
|
+
* @returns {Promise<Object>}
|
|
311
348
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
349
|
+
const setRoleInformationFromTemplate = (
|
|
350
|
+
id: string,
|
|
351
|
+
data: object,
|
|
352
|
+
token: string
|
|
353
|
+
): Promise<object> => {
|
|
354
|
+
return new Promise((resolve, reject) => {
|
|
314
355
|
const requestData = {
|
|
315
356
|
data: data,
|
|
316
357
|
id: id,
|
|
@@ -338,11 +379,16 @@ export const setRoleInformationFromTemplate = (id, data, token) => {
|
|
|
338
379
|
* @param {Array<Object>} roles The list of roles to be assigned to the user
|
|
339
380
|
* @param {String} jobDescription The job description to be assigned to the user
|
|
340
381
|
* @param {String} token Authorization token
|
|
341
|
-
* @returns {Promise}
|
|
382
|
+
* @returns {Promise<Object>}
|
|
342
383
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
384
|
+
const setUserRoles = (
|
|
385
|
+
id: string,
|
|
386
|
+
roles: object[],
|
|
387
|
+
jobDescription: string,
|
|
388
|
+
token: string
|
|
389
|
+
): Promise<object> => {
|
|
390
|
+
return new Promise((resolve, reject) => {
|
|
391
|
+
const requestData: { roles: object[]; jobDescription: string; userid?: string } = {
|
|
346
392
|
roles: roles,
|
|
347
393
|
jobDescription: jobDescription,
|
|
348
394
|
};
|
|
@@ -365,10 +411,14 @@ export const setUserRoles = (id, roles, jobDescription, token) => {
|
|
|
365
411
|
* @param {String} id The id of the role to be updated
|
|
366
412
|
* @param {Boolean} watch Set to true or false
|
|
367
413
|
* @param {String} token Authorization token
|
|
368
|
-
* @returns {Promise}
|
|
414
|
+
* @returns {Promise<Object>}
|
|
369
415
|
*/
|
|
370
|
-
|
|
371
|
-
|
|
416
|
+
const watchRole = (
|
|
417
|
+
id: string,
|
|
418
|
+
watch: boolean,
|
|
419
|
+
token: string
|
|
420
|
+
): Promise<object> => {
|
|
421
|
+
return new Promise((resolve, reject) => {
|
|
372
422
|
const requestData = {
|
|
373
423
|
id: id,
|
|
374
424
|
watch: watch,
|
|
@@ -386,7 +436,7 @@ export const watchRole = (id, watch, token) => {
|
|
|
386
436
|
});
|
|
387
437
|
};
|
|
388
438
|
|
|
389
|
-
|
|
439
|
+
export default {
|
|
390
440
|
createRole,
|
|
391
441
|
createRoleFromTemplate,
|
|
392
442
|
deleteRole,
|
|
@@ -402,5 +452,3 @@ const role = {
|
|
|
402
452
|
setUserRoles,
|
|
403
453
|
watchRole,
|
|
404
454
|
};
|
|
405
|
-
|
|
406
|
-
export default role;
|
|
@@ -4,9 +4,10 @@ import { client } from "./axiosClient.js";
|
|
|
4
4
|
* Create role template and set information
|
|
5
5
|
* @param {Object} data
|
|
6
6
|
* @param {String} token Authorization token
|
|
7
|
+
* @returns {Promise<Object>}
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
return new Promise(
|
|
9
|
+
const createRoleTemplate = (data: object, token: string): Promise<object> => {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
10
11
|
const requestData = {
|
|
11
12
|
data: data,
|
|
12
13
|
};
|
|
@@ -28,10 +29,15 @@ export const createRoleTemplate = (data, token) => {
|
|
|
28
29
|
* @param {String} id The id of the template to be deleted
|
|
29
30
|
* @param {String} comments The comments included with the deletion
|
|
30
31
|
* @param {String} token Authorization token
|
|
32
|
+
* @returns {Promise<Object>}
|
|
31
33
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const deleteRoleTemplate = (
|
|
35
|
+
id: string,
|
|
36
|
+
comments: string,
|
|
37
|
+
token: string
|
|
38
|
+
): Promise<object> => {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const data: { id: string, comments?: string } = {
|
|
35
41
|
id: id,
|
|
36
42
|
};
|
|
37
43
|
if (comments) data.comments = comments;
|
|
@@ -53,9 +59,13 @@ export const deleteRoleTemplate = (id, comments, token) => {
|
|
|
53
59
|
* Discard the role template draft changes
|
|
54
60
|
* @param {String} id The id of the role template to be deleted
|
|
55
61
|
* @param {String} token Authorization token
|
|
62
|
+
* @returns {Promise<Object>}
|
|
56
63
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
const discardRoleTemplateChanges = (
|
|
65
|
+
id: string,
|
|
66
|
+
token: string
|
|
67
|
+
): Promise<object> => {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
59
69
|
const data = {};
|
|
60
70
|
const request = client.get(`api/v1/roletemplates/discard/${id}`, {
|
|
61
71
|
headers: { authorization: token },
|
|
@@ -74,10 +84,16 @@ export const discardRoleTemplateChanges = (id, token) => {
|
|
|
74
84
|
/**
|
|
75
85
|
* Get role template information
|
|
76
86
|
* @param {String} id The id of the template
|
|
87
|
+
* @param {String} version The version of the template
|
|
77
88
|
* @param {String} token Authorization token
|
|
89
|
+
* @returns {Promise<Object>}
|
|
78
90
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
const getRoleTemplateInformationById = (
|
|
92
|
+
id: string,
|
|
93
|
+
version: string,
|
|
94
|
+
token: string
|
|
95
|
+
): Promise<object> => {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
81
97
|
let confirmationRequest = client.get(
|
|
82
98
|
`api/v1/roletemplates/${id}/${version}`,
|
|
83
99
|
{
|
|
@@ -101,16 +117,17 @@ export const getRoleTemplateInformationById = (id, version, token) => {
|
|
|
101
117
|
* @param {Boolean} includeDeleted When true it will return the deleted records as well
|
|
102
118
|
* @param {Boolean} namesOnly When true it will return only the names of the templates
|
|
103
119
|
* @param {String} token Authorization token
|
|
120
|
+
* @returns {Promise<Object>}
|
|
104
121
|
*/
|
|
105
|
-
|
|
106
|
-
filter,
|
|
107
|
-
version,
|
|
108
|
-
includeDeleted,
|
|
109
|
-
namesOnly,
|
|
110
|
-
token
|
|
111
|
-
) => {
|
|
112
|
-
return new Promise(
|
|
113
|
-
const requestData = {
|
|
122
|
+
const getRoleTemplateList = (
|
|
123
|
+
filter: string[],
|
|
124
|
+
version: string,
|
|
125
|
+
includeDeleted: boolean,
|
|
126
|
+
namesOnly: boolean,
|
|
127
|
+
token: string
|
|
128
|
+
): Promise<object> => {
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
const requestData: { includeDeleted: boolean; namesOnly: boolean; version: string; filter?: string[] } = {
|
|
114
131
|
includeDeleted: includeDeleted,
|
|
115
132
|
namesOnly: namesOnly,
|
|
116
133
|
version: version,
|
|
@@ -134,10 +151,15 @@ export const getRoleTemplateList = (
|
|
|
134
151
|
* @param {number} id The id of the template to be published
|
|
135
152
|
* @param {String} comments The comments to be include with the request
|
|
136
153
|
* @param {String} token Authorization token
|
|
154
|
+
* @returns {Promise<Object>}
|
|
137
155
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
156
|
+
const publishTemplate = (
|
|
157
|
+
id: number,
|
|
158
|
+
comments: string,
|
|
159
|
+
token: string
|
|
160
|
+
): Promise<object> => {
|
|
161
|
+
return new Promise((resolve, reject) => {
|
|
162
|
+
let data: { comments?: string } = {};
|
|
141
163
|
if (comments) data.comments = comments;
|
|
142
164
|
let confirmationRequest = client.post(
|
|
143
165
|
`api/v1/roletemplates/publish/${id}`,
|
|
@@ -161,9 +183,14 @@ export const publishTemplate = (id, comments, token) => {
|
|
|
161
183
|
* @param {String} id The id of the template to be updated
|
|
162
184
|
* @param {Object} data Data used to update the template
|
|
163
185
|
* @param {String} token Authorization token
|
|
186
|
+
* @returns {Promise<Object>}
|
|
164
187
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
188
|
+
const setTemplateInformation = (
|
|
189
|
+
id: string,
|
|
190
|
+
data: object,
|
|
191
|
+
token: string
|
|
192
|
+
): Promise<object> => {
|
|
193
|
+
return new Promise((resolve, reject) => {
|
|
167
194
|
const requestData = {
|
|
168
195
|
data: data,
|
|
169
196
|
id: id,
|
|
@@ -190,9 +217,14 @@ export const setTemplateInformation = (id, data, token) => {
|
|
|
190
217
|
* @param {String} id The id of the template to be updated
|
|
191
218
|
* @param {Object} tags Updated template tags
|
|
192
219
|
* @param {String} token Authorization token
|
|
220
|
+
* @returns {Promise<Object>}
|
|
193
221
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
222
|
+
const setTemplateTags = (
|
|
223
|
+
id: string,
|
|
224
|
+
tags: object,
|
|
225
|
+
token: string
|
|
226
|
+
): Promise<object> => {
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
196
228
|
const requestData = {
|
|
197
229
|
tags: tags,
|
|
198
230
|
id: id,
|
|
@@ -219,9 +251,14 @@ export const setTemplateTags = (id, tags, token) => {
|
|
|
219
251
|
* @param {String} id The id of the skill to be updated
|
|
220
252
|
* @param {Boolean} watch Set to true or false
|
|
221
253
|
* @param {String} token Authorization token
|
|
254
|
+
* @returns {Promise<Object>}
|
|
222
255
|
*/
|
|
223
|
-
|
|
224
|
-
|
|
256
|
+
const watchRoleTemplate = (
|
|
257
|
+
id: string,
|
|
258
|
+
watch: boolean,
|
|
259
|
+
token: string
|
|
260
|
+
): Promise<object> => {
|
|
261
|
+
return new Promise((resolve, reject) => {
|
|
225
262
|
const requestData = {
|
|
226
263
|
id: id,
|
|
227
264
|
watch: watch,
|
|
@@ -243,7 +280,7 @@ export const watchRoleTemplate = (id, watch, token) => {
|
|
|
243
280
|
});
|
|
244
281
|
};
|
|
245
282
|
|
|
246
|
-
|
|
283
|
+
export default {
|
|
247
284
|
createRoleTemplate,
|
|
248
285
|
deleteRoleTemplate,
|
|
249
286
|
discardRoleTemplateChanges,
|
|
@@ -254,5 +291,3 @@ const roleTemplate = {
|
|
|
254
291
|
setTemplateTags,
|
|
255
292
|
watchRoleTemplate,
|
|
256
293
|
};
|
|
257
|
-
|
|
258
|
-
export default roleTemplate;
|