@stackfactor/client-api 1.1.133 → 1.1.135
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 +4 -3
- package/declarations/axios.d.ts +1 -0
- package/declarations/html2plaintext.d.ts +1 -0
- package/dist/actionNotifications.d.ts +7 -0
- package/dist/actionNotifications.d.ts.map +1 -0
- package/dist/actionNotifications.js +9 -10
- package/dist/actionNotifications.js.map +1 -0
- package/dist/address.d.ts +5 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.js +5 -6
- package/dist/address.js.map +1 -0
- package/dist/aiAssistant.d.ts +9 -0
- package/dist/aiAssistant.d.ts.map +1 -0
- package/dist/aiAssistant.js +16 -17
- package/dist/aiAssistant.js.map +1 -0
- package/dist/avatar.d.ts +5 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +4 -5
- package/dist/avatar.js.map +1 -0
- package/dist/axiosClient.d.ts +32 -0
- package/dist/axiosClient.d.ts.map +1 -0
- package/dist/axiosClient.js +17 -27
- package/dist/axiosClient.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +9 -10
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +70 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -7
- package/dist/constants.js.map +1 -0
- package/dist/dashboard.d.ts +7 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +9 -10
- package/dist/dashboard.js.map +1 -0
- package/dist/departmentTrainingPlans.d.ts +13 -0
- package/dist/departmentTrainingPlans.d.ts.map +1 -0
- package/dist/departmentTrainingPlans.js +16 -17
- package/dist/departmentTrainingPlans.js.map +1 -0
- package/dist/groups.d.ts +16 -0
- package/dist/groups.d.ts.map +1 -0
- package/dist/groups.js +27 -28
- package/dist/groups.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -17
- package/dist/index.js.map +1 -0
- package/dist/integration.d.ts +95 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +62 -69
- package/dist/integration.js.map +1 -0
- package/dist/integrationConfiguration.d.ts +7 -0
- package/dist/integrationConfiguration.d.ts.map +1 -0
- package/dist/integrationConfiguration.js +10 -11
- package/dist/integrationConfiguration.js.map +1 -0
- package/dist/integrations/contentGenerator.d.ts +27 -0
- package/dist/integrations/contentGenerator.d.ts.map +1 -0
- package/dist/integrations/contentGenerator.js +12 -16
- package/dist/integrations/contentGenerator.js.map +1 -0
- package/dist/learningContent.d.ts +19 -0
- package/dist/learningContent.d.ts.map +1 -0
- package/dist/learningContent.js +30 -31
- package/dist/learningContent.js.map +1 -0
- package/dist/learningPath.d.ts +12 -0
- package/dist/learningPath.d.ts.map +1 -0
- package/dist/learningPath.js +19 -20
- package/dist/learningPath.js.map +1 -0
- package/dist/logger.d.ts +6 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +8 -9
- package/dist/logger.js.map +1 -0
- package/dist/microSkillsQuizes.d.ts +6 -0
- package/dist/microSkillsQuizes.d.ts.map +1 -0
- package/dist/microSkillsQuizes.js +8 -9
- package/dist/microSkillsQuizes.js.map +1 -0
- package/dist/quotas.d.ts +6 -0
- package/dist/quotas.d.ts.map +1 -0
- package/dist/quotas.js +7 -8
- package/dist/quotas.js.map +1 -0
- package/dist/role.d.ts +18 -0
- package/dist/role.d.ts.map +1 -0
- package/dist/role.js +32 -33
- package/dist/role.js.map +1 -0
- package/dist/roleTemplate.d.ts +13 -0
- package/dist/roleTemplate.d.ts.map +1 -0
- package/dist/roleTemplate.js +22 -23
- package/dist/roleTemplate.js.map +1 -0
- package/dist/security.d.ts +8 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +11 -12
- package/dist/security.js.map +1 -0
- package/dist/skill.d.ts +22 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +40 -41
- package/dist/skill.js.map +1 -0
- package/dist/skillAssessmentTestingSession.d.ts +10 -0
- package/dist/skillAssessmentTestingSession.d.ts.map +1 -0
- package/dist/skillAssessmentTestingSession.js +15 -16
- package/dist/skillAssessmentTestingSession.js.map +1 -0
- package/dist/skillAssessments.d.ts +10 -0
- package/dist/skillAssessments.d.ts.map +1 -0
- package/dist/skillAssessments.js +15 -16
- package/dist/skillAssessments.js.map +1 -0
- package/dist/skillTemplate.d.ts +15 -0
- package/dist/skillTemplate.d.ts.map +1 -0
- package/dist/skillTemplate.js +26 -27
- package/dist/skillTemplate.js.map +1 -0
- package/dist/talentTransfromation.d.ts +8 -0
- package/dist/talentTransfromation.d.ts.map +1 -0
- package/dist/talentTransfromation.js +11 -12
- package/dist/talentTransfromation.js.map +1 -0
- package/dist/teams.d.ts +15 -0
- package/dist/teams.d.ts.map +1 -0
- package/dist/teams.js +25 -26
- package/dist/teams.js.map +1 -0
- package/dist/tenants.d.ts +6 -0
- package/dist/tenants.d.ts.map +1 -0
- package/dist/tenants.js +7 -8
- package/dist/tenants.js.map +1 -0
- package/dist/trainingPlans.d.ts +16 -0
- package/dist/trainingPlans.d.ts.map +1 -0
- package/dist/trainingPlans.js +19 -20
- package/dist/trainingPlans.js.map +1 -0
- package/dist/trainingPlansProficiencyLevels.d.ts +8 -0
- package/dist/trainingPlansProficiencyLevels.d.ts.map +1 -0
- package/dist/trainingPlansProficiencyLevels.js +9 -10
- package/dist/trainingPlansProficiencyLevels.js.map +1 -0
- package/dist/userInformation.d.ts +7 -0
- package/dist/userInformation.d.ts.map +1 -0
- package/dist/userInformation.js +9 -10
- package/dist/userInformation.js.map +1 -0
- package/dist/users.d.ts +31 -0
- package/dist/users.d.ts.map +1 -0
- package/dist/users.js +37 -39
- package/dist/users.js.map +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +8 -21
- package/dist/utils.js.map +1 -0
- package/package.json +15 -14
- package/src/lib/actionNotifications.ts +11 -10
- package/src/lib/address.ts +5 -4
- package/src/lib/aiAssistant.ts +25 -24
- package/src/lib/avatar.ts +4 -3
- package/src/lib/axiosClient.ts +22 -9
- package/src/lib/config.ts +11 -10
- package/src/lib/dashboard.ts +11 -10
- package/src/lib/departmentTrainingPlans.ts +29 -32
- package/src/lib/groups.ts +38 -37
- package/src/lib/index.ts +85 -1
- package/src/lib/integration.ts +56 -55
- package/src/lib/integrationConfiguration.ts +15 -14
- package/src/lib/integrations/contentGenerator.ts +10 -9
- package/src/lib/learningContent.ts +56 -55
- package/src/lib/learningPath.ts +32 -31
- package/src/lib/logger.ts +9 -8
- package/src/lib/microSkillsQuizes.ts +11 -10
- package/src/lib/quotas.ts +10 -9
- package/src/lib/role.ts +56 -55
- package/src/lib/roleTemplate.ts +37 -36
- package/src/lib/security.ts +14 -13
- package/src/lib/skill.ts +72 -71
- package/src/lib/skillAssessmentTestingSession.ts +25 -24
- package/src/lib/skillAssessments.ts +25 -24
- package/src/lib/skillTemplate.ts +45 -44
- package/src/lib/talentTransfromation.ts +15 -14
- package/src/lib/teams.ts +35 -34
- package/src/lib/tenants.ts +10 -9
- package/src/lib/trainingPlans.ts +37 -36
- package/src/lib/trainingPlansProficiencyLevels.ts +14 -13
- package/src/lib/userInformation.ts +13 -12
- package/src/lib/users.ts +72 -72
- package/src/lib/utils.ts +7 -16
- package/tsconfig.json +16 -5
- package/dist/exports.js +0 -77
- package/index.d.ts +0 -1
- package/src/lib/exports.ts +0 -85
package/src/lib/aiAssistant.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
import { client } from "./axiosClient";
|
|
2
3
|
|
|
3
4
|
interface AskQuestionData {
|
|
4
5
|
conversationId: string;
|
|
@@ -25,7 +26,7 @@ interface StartConversationData {
|
|
|
25
26
|
* @param {String} question
|
|
26
27
|
* @param {String} updatedContext
|
|
27
28
|
* @param {String} token Authorization token
|
|
28
|
-
* @returns {Promise<
|
|
29
|
+
* @returns {Promise<object>}
|
|
29
30
|
*/
|
|
30
31
|
const askQuestion = (
|
|
31
32
|
conversationId: string,
|
|
@@ -34,12 +35,12 @@ const askQuestion = (
|
|
|
34
35
|
token: string
|
|
35
36
|
): Promise<object> => {
|
|
36
37
|
return new Promise((resolve, reject) => {
|
|
37
|
-
|
|
38
|
+
const data: AskQuestionData = {
|
|
38
39
|
conversationId: conversationId,
|
|
39
40
|
question: question,
|
|
40
41
|
updatedContext: updatedContext,
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
+
const confirmationRequest = client.post(
|
|
43
44
|
"/api/v1/aiassistant/askquestion",
|
|
44
45
|
data,
|
|
45
46
|
{
|
|
@@ -47,10 +48,10 @@ const askQuestion = (
|
|
|
47
48
|
}
|
|
48
49
|
);
|
|
49
50
|
confirmationRequest
|
|
50
|
-
.then((response) => {
|
|
51
|
+
.then((response : AxiosResponse) => {
|
|
51
52
|
resolve(response.data);
|
|
52
53
|
})
|
|
53
|
-
.catch((error) => {
|
|
54
|
+
.catch((error : AxiosError) => {
|
|
54
55
|
reject(error);
|
|
55
56
|
});
|
|
56
57
|
});
|
|
@@ -60,17 +61,17 @@ const askQuestion = (
|
|
|
60
61
|
* End conversation with the AI
|
|
61
62
|
* @param {String} conversationId
|
|
62
63
|
* @param {String} token Authorization token
|
|
63
|
-
* @returns {Promise<
|
|
64
|
+
* @returns {Promise<object>}
|
|
64
65
|
*/
|
|
65
66
|
const endConversation = (
|
|
66
67
|
conversationId: string,
|
|
67
68
|
token: string
|
|
68
69
|
): Promise<object> => {
|
|
69
70
|
return new Promise((resolve, reject) => {
|
|
70
|
-
|
|
71
|
+
const data: EndConversationData = {
|
|
71
72
|
conversationId: conversationId,
|
|
72
73
|
};
|
|
73
|
-
|
|
74
|
+
const confirmationRequest = client.post(
|
|
74
75
|
"/api/v1/aiassistant/endconversation",
|
|
75
76
|
data,
|
|
76
77
|
{
|
|
@@ -78,10 +79,10 @@ const endConversation = (
|
|
|
78
79
|
}
|
|
79
80
|
);
|
|
80
81
|
confirmationRequest
|
|
81
|
-
.then((response) => {
|
|
82
|
+
.then((response : AxiosResponse) => {
|
|
82
83
|
resolve(response.data);
|
|
83
84
|
})
|
|
84
|
-
.catch((error) => {
|
|
85
|
+
.catch((error : AxiosError) => {
|
|
85
86
|
reject(error);
|
|
86
87
|
});
|
|
87
88
|
});
|
|
@@ -91,24 +92,24 @@ const endConversation = (
|
|
|
91
92
|
* Get conversation by elementId
|
|
92
93
|
* @param {String} elementId
|
|
93
94
|
* @param {String} token
|
|
94
|
-
* @returns {Promise<
|
|
95
|
+
* @returns {Promise<object>}
|
|
95
96
|
*/
|
|
96
97
|
const getConversationByElementId = (
|
|
97
98
|
elementId: string,
|
|
98
99
|
token: string
|
|
99
100
|
): Promise<object> => {
|
|
100
101
|
return new Promise((resolve, reject) => {
|
|
101
|
-
|
|
102
|
+
const confirmationRequest = client.get(
|
|
102
103
|
`/api/v1/aiassistant/getconversation/${elementId}`,
|
|
103
104
|
{
|
|
104
105
|
headers: { authorization: token },
|
|
105
106
|
}
|
|
106
107
|
);
|
|
107
108
|
confirmationRequest
|
|
108
|
-
.then((response) => {
|
|
109
|
+
.then((response : AxiosResponse) => {
|
|
109
110
|
resolve(response.data);
|
|
110
111
|
})
|
|
111
|
-
.catch((error) => {
|
|
112
|
+
.catch((error : AxiosError) => {
|
|
112
113
|
reject(error);
|
|
113
114
|
});
|
|
114
115
|
});
|
|
@@ -118,24 +119,24 @@ const getConversationByElementId = (
|
|
|
118
119
|
* Get the voice assistant URL
|
|
119
120
|
* @param {String} language
|
|
120
121
|
* @param {String} token
|
|
121
|
-
* @returns {Promise<
|
|
122
|
+
* @returns {Promise<object>}
|
|
122
123
|
*/
|
|
123
124
|
const getVoiceAssistantUrl = (
|
|
124
125
|
language: string,
|
|
125
126
|
token: string
|
|
126
127
|
): Promise<object> => {
|
|
127
128
|
return new Promise((resolve, reject) => {
|
|
128
|
-
|
|
129
|
+
const confirmationRequest = client.get(
|
|
129
130
|
`/api/v1/aiassistant/getvoiceassistanturl/${language}`,
|
|
130
131
|
{
|
|
131
132
|
headers: { authorization: token },
|
|
132
133
|
}
|
|
133
134
|
);
|
|
134
135
|
confirmationRequest
|
|
135
|
-
.then((response) => {
|
|
136
|
+
.then((response : AxiosResponse) => {
|
|
136
137
|
resolve(response.data);
|
|
137
138
|
})
|
|
138
|
-
.catch((error) => {
|
|
139
|
+
.catch((error : AxiosError) => {
|
|
139
140
|
reject(error);
|
|
140
141
|
});
|
|
141
142
|
});
|
|
@@ -149,7 +150,7 @@ const getVoiceAssistantUrl = (
|
|
|
149
150
|
* @param {Boolean} autoContextRefresh
|
|
150
151
|
* @param {String} token
|
|
151
152
|
* @param {String} conversationId Optional
|
|
152
|
-
* @returns {Promise<
|
|
153
|
+
* @returns {Promise<object>}
|
|
153
154
|
*/
|
|
154
155
|
const startConversation = (
|
|
155
156
|
elementId: string,
|
|
@@ -161,7 +162,7 @@ const startConversation = (
|
|
|
161
162
|
conversationId: string | null = null
|
|
162
163
|
): Promise<object> => {
|
|
163
164
|
return new Promise((resolve, reject) => {
|
|
164
|
-
|
|
165
|
+
const data: StartConversationData = {
|
|
165
166
|
autoContextRefresh: autoContextRefresh,
|
|
166
167
|
context: context,
|
|
167
168
|
question: question,
|
|
@@ -171,7 +172,7 @@ const startConversation = (
|
|
|
171
172
|
if (conversationId) {
|
|
172
173
|
data.conversationId = conversationId;
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
const confirmationRequest = client.post(
|
|
175
176
|
"/api/v1/aiassistant/startconversation",
|
|
176
177
|
data,
|
|
177
178
|
{
|
|
@@ -179,10 +180,10 @@ const startConversation = (
|
|
|
179
180
|
}
|
|
180
181
|
);
|
|
181
182
|
confirmationRequest
|
|
182
|
-
.then((response) => {
|
|
183
|
+
.then((response : AxiosResponse) => {
|
|
183
184
|
resolve(response.data);
|
|
184
185
|
})
|
|
185
|
-
.catch((error) => {
|
|
186
|
+
.catch((error : AxiosError) => {
|
|
186
187
|
reject(error);
|
|
187
188
|
});
|
|
188
189
|
});
|
package/src/lib/avatar.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
import { client } from "./axiosClient";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Get avatar for an elementId
|
|
@@ -17,7 +18,7 @@ const getAvatar = (
|
|
|
17
18
|
token: string
|
|
18
19
|
): Promise<Blob> => {
|
|
19
20
|
return new Promise((resolve, reject) => {
|
|
20
|
-
|
|
21
|
+
const confirmationRequest = client.get(
|
|
21
22
|
`/api/v1/avatar/getavatar/${elementId}/${type}/${width}/${height}`,
|
|
22
23
|
{
|
|
23
24
|
headers: {
|
|
@@ -27,7 +28,7 @@ const getAvatar = (
|
|
|
27
28
|
}
|
|
28
29
|
);
|
|
29
30
|
confirmationRequest
|
|
30
|
-
.then((response) => {
|
|
31
|
+
.then((response : AxiosResponse) => {
|
|
31
32
|
resolve(response.data);
|
|
32
33
|
})
|
|
33
34
|
.catch(() => {
|
package/src/lib/axiosClient.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import axios, { AxiosError } from "axios";
|
|
2
|
-
import { RESPONSE_TYPE } from "./constants
|
|
3
|
-
import utils from "./utils
|
|
1
|
+
import axios, { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
import { RESPONSE_TYPE } from "./constants";
|
|
3
|
+
import utils from "./utils";
|
|
4
|
+
|
|
5
|
+
interface ErrorResponse {
|
|
6
|
+
msg: string;
|
|
7
|
+
param: string;
|
|
8
|
+
value: string;
|
|
9
|
+
toString: () => string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface CustomAxiosResponse extends AxiosResponse {
|
|
13
|
+
errors?: ErrorResponse[];
|
|
14
|
+
toString: () => string;
|
|
15
|
+
}
|
|
4
16
|
|
|
5
17
|
const baseUrl = utils.getBaseUrl();
|
|
6
18
|
|
|
@@ -18,21 +30,22 @@ const errorToString = (error: AxiosError): string => {
|
|
|
18
30
|
if (error != null) {
|
|
19
31
|
if (error.response?.data) {
|
|
20
32
|
let asString = "";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
const responseData = error.response.data as CustomAxiosResponse;
|
|
34
|
+
if (Array.isArray(responseData.errors)) {
|
|
35
|
+
responseData.errors.forEach(
|
|
36
|
+
(item: ErrorResponse, index: number) => {
|
|
24
37
|
asString += `${index > 0 ? ", " : ""} ${item.msg} param ${
|
|
25
38
|
item.param
|
|
26
39
|
} ${item.value ? `value ${item.value.toString()}` : ""}`;
|
|
27
40
|
}
|
|
28
41
|
);
|
|
29
42
|
return asString;
|
|
30
|
-
} else if (
|
|
31
|
-
return (
|
|
43
|
+
} else if (responseData.errors) {
|
|
44
|
+
return JSON.stringify(responseData.errors);
|
|
32
45
|
} else if (error.response.statusText) {
|
|
33
46
|
return error.response.statusText.toString();
|
|
34
47
|
} else {
|
|
35
|
-
return
|
|
48
|
+
return responseData.toString();
|
|
36
49
|
}
|
|
37
50
|
} else {
|
|
38
51
|
return error.message ? error.message : "Unknown error";
|
package/src/lib/config.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
import { client } from "./axiosClient";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Get the specified configuration by Id. It returns a promise
|
|
5
6
|
* @param {String} id - the id of the configuration element
|
|
6
7
|
* @param {String} authToken - Authorization token
|
|
7
|
-
* @returns {Promise<
|
|
8
|
+
* @returns {Promise<object>}
|
|
8
9
|
*/
|
|
9
10
|
const getConfigurationById = (
|
|
10
11
|
id: string,
|
|
@@ -16,10 +17,10 @@ const getConfigurationById = (
|
|
|
16
17
|
{ headers: { authorization: authToken } }
|
|
17
18
|
);
|
|
18
19
|
getConfigInformationRequest
|
|
19
|
-
.then((response) => {
|
|
20
|
+
.then((response : AxiosResponse) => {
|
|
20
21
|
resolve(response.data);
|
|
21
22
|
})
|
|
22
|
-
.catch((error) => {
|
|
23
|
+
.catch((error : AxiosError) => {
|
|
23
24
|
reject(error);
|
|
24
25
|
});
|
|
25
26
|
});
|
|
@@ -29,7 +30,7 @@ const getConfigurationById = (
|
|
|
29
30
|
* Get the specified configuration by type. It returns a promise
|
|
30
31
|
* @param {String} type - the id of the configuration element
|
|
31
32
|
* @param {String} authToken - Authorization token
|
|
32
|
-
* @returns {Promise<
|
|
33
|
+
* @returns {Promise<object>}
|
|
33
34
|
*/
|
|
34
35
|
const getConfigurationByType = (
|
|
35
36
|
type: string,
|
|
@@ -41,10 +42,10 @@ const getConfigurationByType = (
|
|
|
41
42
|
{ headers: { authorization: authToken } }
|
|
42
43
|
);
|
|
43
44
|
getConfigInformationRequest
|
|
44
|
-
.then((response) => {
|
|
45
|
+
.then((response : AxiosResponse) => {
|
|
45
46
|
resolve(response.data);
|
|
46
47
|
})
|
|
47
|
-
.catch((error) => {
|
|
48
|
+
.catch((error : AxiosError) => {
|
|
48
49
|
reject(error);
|
|
49
50
|
});
|
|
50
51
|
});
|
|
@@ -55,7 +56,7 @@ const getConfigurationByType = (
|
|
|
55
56
|
* @param {String} id - the id of the configuration element
|
|
56
57
|
* @param {Object} data - the object containing the updated configuration element
|
|
57
58
|
* @param {String} authToken - Authorization token
|
|
58
|
-
* @returns {Promise<
|
|
59
|
+
* @returns {Promise<object>}
|
|
59
60
|
*/
|
|
60
61
|
const setConfigurationById = (
|
|
61
62
|
id: string,
|
|
@@ -69,10 +70,10 @@ const setConfigurationById = (
|
|
|
69
70
|
{ headers: { authorization: authToken } }
|
|
70
71
|
);
|
|
71
72
|
getConfigInformationRequest
|
|
72
|
-
.then((response) => {
|
|
73
|
+
.then((response : AxiosResponse) => {
|
|
73
74
|
resolve(response.data);
|
|
74
75
|
})
|
|
75
|
-
.catch((error) => {
|
|
76
|
+
.catch((error : AxiosError) => {
|
|
76
77
|
reject(error);
|
|
77
78
|
});
|
|
78
79
|
});
|
package/src/lib/dashboard.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
import { client } from "./axiosClient";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Add a card to the dashboard
|
|
@@ -6,7 +7,7 @@ import { client } from "./axiosClient.js";
|
|
|
6
7
|
* @param {Number} position - The position on the dashboard
|
|
7
8
|
* @param {Object} data - The card settings data
|
|
8
9
|
* @param {String} authToken - Authorization token
|
|
9
|
-
* @returns {Promise<
|
|
10
|
+
* @returns {Promise<object>}
|
|
10
11
|
*/
|
|
11
12
|
const addCardToDashboard = (
|
|
12
13
|
id: string,
|
|
@@ -25,10 +26,10 @@ const addCardToDashboard = (
|
|
|
25
26
|
{ headers: { authorization: authToken } }
|
|
26
27
|
);
|
|
27
28
|
request
|
|
28
|
-
.then((response) => {
|
|
29
|
+
.then((response : AxiosResponse) => {
|
|
29
30
|
resolve(response.data);
|
|
30
31
|
})
|
|
31
|
-
.catch((error) => {
|
|
32
|
+
.catch((error : AxiosError) => {
|
|
32
33
|
reject(error);
|
|
33
34
|
});
|
|
34
35
|
});
|
|
@@ -37,7 +38,7 @@ const addCardToDashboard = (
|
|
|
37
38
|
/**
|
|
38
39
|
* Get the list of the cards from the dashboard
|
|
39
40
|
* @param {String} authToken - Authorization token
|
|
40
|
-
* @returns {Promise<
|
|
41
|
+
* @returns {Promise<object>}
|
|
41
42
|
*/
|
|
42
43
|
const getDashboardCardsList = (authToken: string): Promise<object> => {
|
|
43
44
|
return new Promise((resolve, reject) => {
|
|
@@ -45,10 +46,10 @@ const getDashboardCardsList = (authToken: string): Promise<object> => {
|
|
|
45
46
|
headers: { authorization: authToken },
|
|
46
47
|
});
|
|
47
48
|
request
|
|
48
|
-
.then((response) => {
|
|
49
|
+
.then((response : AxiosResponse) => {
|
|
49
50
|
resolve(response.data);
|
|
50
51
|
})
|
|
51
|
-
.catch((error) => {
|
|
52
|
+
.catch((error : AxiosError) => {
|
|
52
53
|
reject(error);
|
|
53
54
|
});
|
|
54
55
|
});
|
|
@@ -58,7 +59,7 @@ const getDashboardCardsList = (authToken: string): Promise<object> => {
|
|
|
58
59
|
* Remove a card from the dashboard
|
|
59
60
|
* @param {String} id - the id of the configuration element
|
|
60
61
|
* @param {String} authToken - Authorization token
|
|
61
|
-
* @returns {Promise<
|
|
62
|
+
* @returns {Promise<object>}
|
|
62
63
|
*/
|
|
63
64
|
const removeCardFromDashboard = (
|
|
64
65
|
id: string,
|
|
@@ -72,10 +73,10 @@ const removeCardFromDashboard = (
|
|
|
72
73
|
},
|
|
73
74
|
});
|
|
74
75
|
request
|
|
75
|
-
.then((response) => {
|
|
76
|
+
.then((response : AxiosResponse) => {
|
|
76
77
|
resolve(response.data);
|
|
77
78
|
})
|
|
78
|
-
.catch((error) => {
|
|
79
|
+
.catch((error : AxiosError) => {
|
|
79
80
|
reject(error);
|
|
80
81
|
});
|
|
81
82
|
});
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
import { client } from "./axiosClient";
|
|
2
3
|
|
|
3
4
|
interface Activity {
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface Filter {
|
|
8
|
-
// Define the structure of a filter object here
|
|
5
|
+
_id: string;
|
|
9
6
|
}
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -15,13 +12,13 @@ interface Filter {
|
|
|
15
12
|
* @param {String} skill
|
|
16
13
|
* @param {Array<Activity>} activities
|
|
17
14
|
* @param {String} token Authorization token
|
|
18
|
-
* @returns {Promise<
|
|
15
|
+
* @returns {Promise<object>}
|
|
19
16
|
*/
|
|
20
17
|
const createDepartmentTrainingPlan = (
|
|
21
18
|
name: string,
|
|
22
19
|
summary: string,
|
|
23
20
|
skill: string,
|
|
24
|
-
activities: Activity
|
|
21
|
+
activities: Array<Activity>,
|
|
25
22
|
token: string
|
|
26
23
|
): Promise<object> => {
|
|
27
24
|
return new Promise((resolve, reject) => {
|
|
@@ -31,7 +28,7 @@ const createDepartmentTrainingPlan = (
|
|
|
31
28
|
skill: skill || "",
|
|
32
29
|
activities: activities || [],
|
|
33
30
|
};
|
|
34
|
-
|
|
31
|
+
const confirmationRequest = client.put(
|
|
35
32
|
"api/v1/departmentTrainingPlans",
|
|
36
33
|
requestData,
|
|
37
34
|
{
|
|
@@ -39,10 +36,10 @@ const createDepartmentTrainingPlan = (
|
|
|
39
36
|
}
|
|
40
37
|
);
|
|
41
38
|
confirmationRequest
|
|
42
|
-
.then((response) => {
|
|
39
|
+
.then((response : AxiosResponse) => {
|
|
43
40
|
resolve(response.data);
|
|
44
41
|
})
|
|
45
|
-
.catch((error) => {
|
|
42
|
+
.catch((error : AxiosError) => {
|
|
46
43
|
reject(error);
|
|
47
44
|
});
|
|
48
45
|
});
|
|
@@ -52,7 +49,7 @@ const createDepartmentTrainingPlan = (
|
|
|
52
49
|
* Delete department training plan
|
|
53
50
|
* @param {String} id The id of the template to be deleted
|
|
54
51
|
* @param {String} token Authorization token
|
|
55
|
-
* @returns {Promise<
|
|
52
|
+
* @returns {Promise<object>}
|
|
56
53
|
*/
|
|
57
54
|
const deleteDepartmentTrainingPlan = (
|
|
58
55
|
id: string,
|
|
@@ -66,10 +63,10 @@ const deleteDepartmentTrainingPlan = (
|
|
|
66
63
|
},
|
|
67
64
|
});
|
|
68
65
|
request
|
|
69
|
-
.then((response) => {
|
|
66
|
+
.then((response : AxiosResponse) => {
|
|
70
67
|
resolve(response.data);
|
|
71
68
|
})
|
|
72
|
-
.catch((error) => {
|
|
69
|
+
.catch((error : AxiosError) => {
|
|
73
70
|
reject(error);
|
|
74
71
|
});
|
|
75
72
|
});
|
|
@@ -80,7 +77,7 @@ const deleteDepartmentTrainingPlan = (
|
|
|
80
77
|
* @param {Number} id The id of the plan
|
|
81
78
|
* @param {String} version The version of the plan
|
|
82
79
|
* @param {String} token Authorization token
|
|
83
|
-
* @returns {Promise<
|
|
80
|
+
* @returns {Promise<object>}
|
|
84
81
|
*/
|
|
85
82
|
const getDepartmentTrainingPlanInformationById = (
|
|
86
83
|
id: number,
|
|
@@ -88,17 +85,17 @@ const getDepartmentTrainingPlanInformationById = (
|
|
|
88
85
|
token: string
|
|
89
86
|
): Promise<object> => {
|
|
90
87
|
return new Promise((resolve, reject) => {
|
|
91
|
-
|
|
88
|
+
const confirmationRequest = client.get(
|
|
92
89
|
`api/v1/departmenttrainingplans/${id}/${version}`,
|
|
93
90
|
{
|
|
94
91
|
headers: { authorization: token },
|
|
95
92
|
}
|
|
96
93
|
);
|
|
97
94
|
confirmationRequest
|
|
98
|
-
.then((response) => {
|
|
95
|
+
.then((response : AxiosResponse) => {
|
|
99
96
|
resolve(response.data);
|
|
100
97
|
})
|
|
101
|
-
.catch((error) => {
|
|
98
|
+
.catch((error : AxiosError) => {
|
|
102
99
|
reject(error);
|
|
103
100
|
});
|
|
104
101
|
});
|
|
@@ -106,13 +103,13 @@ const getDepartmentTrainingPlanInformationById = (
|
|
|
106
103
|
|
|
107
104
|
/**
|
|
108
105
|
* Get department training plan list
|
|
109
|
-
* @param {
|
|
106
|
+
* @param {String} filter The filter used to select the plan
|
|
110
107
|
* @param {String} version The version of the plan
|
|
111
108
|
* @param {String} token Authorization token
|
|
112
|
-
* @returns {Promise<
|
|
109
|
+
* @returns {Promise<object>}
|
|
113
110
|
*/
|
|
114
111
|
const getDepartmentTrainingPlanList = (
|
|
115
|
-
filter:
|
|
112
|
+
filter: string,
|
|
116
113
|
version: string,
|
|
117
114
|
token: string
|
|
118
115
|
): Promise<object> => {
|
|
@@ -121,7 +118,7 @@ const getDepartmentTrainingPlanList = (
|
|
|
121
118
|
filter: filter || "",
|
|
122
119
|
version: version,
|
|
123
120
|
};
|
|
124
|
-
|
|
121
|
+
const confirmationRequest = client.post(
|
|
125
122
|
`api/v1/departmenttrainingplans`,
|
|
126
123
|
requestData,
|
|
127
124
|
{
|
|
@@ -129,10 +126,10 @@ const getDepartmentTrainingPlanList = (
|
|
|
129
126
|
}
|
|
130
127
|
);
|
|
131
128
|
confirmationRequest
|
|
132
|
-
.then((response) => {
|
|
129
|
+
.then((response : AxiosResponse) => {
|
|
133
130
|
resolve(response.data);
|
|
134
131
|
})
|
|
135
|
-
.catch((error) => {
|
|
132
|
+
.catch((error : AxiosError) => {
|
|
136
133
|
reject(error);
|
|
137
134
|
});
|
|
138
135
|
});
|
|
@@ -142,14 +139,14 @@ const getDepartmentTrainingPlanList = (
|
|
|
142
139
|
* Publish department training plan
|
|
143
140
|
* @param {number} id The id of the plan to be published
|
|
144
141
|
* @param {String} token Authorization token
|
|
145
|
-
* @returns {Promise<
|
|
142
|
+
* @returns {Promise<object>}
|
|
146
143
|
*/
|
|
147
144
|
const publishDepartmentTrainingPlan = (
|
|
148
145
|
id: number,
|
|
149
146
|
token: string
|
|
150
147
|
): Promise<object> => {
|
|
151
148
|
return new Promise((resolve, reject) => {
|
|
152
|
-
|
|
149
|
+
const confirmationRequest = client.post(
|
|
153
150
|
`api/v1/departmenttrainingplans/publish/${id}`,
|
|
154
151
|
{},
|
|
155
152
|
{
|
|
@@ -157,10 +154,10 @@ const publishDepartmentTrainingPlan = (
|
|
|
157
154
|
}
|
|
158
155
|
);
|
|
159
156
|
confirmationRequest
|
|
160
|
-
.then((response) => {
|
|
157
|
+
.then((response : AxiosResponse) => {
|
|
161
158
|
resolve(response.data);
|
|
162
159
|
})
|
|
163
|
-
.catch((error) => {
|
|
160
|
+
.catch((error : AxiosError) => {
|
|
164
161
|
reject(error);
|
|
165
162
|
});
|
|
166
163
|
});
|
|
@@ -171,7 +168,7 @@ const publishDepartmentTrainingPlan = (
|
|
|
171
168
|
* @param {String} id The id of the plan to be updated
|
|
172
169
|
* @param {Object} data Data used to update the plan
|
|
173
170
|
* @param {String} token Authorization token
|
|
174
|
-
* @returns {Promise<
|
|
171
|
+
* @returns {Promise<object>}
|
|
175
172
|
*/
|
|
176
173
|
const setDepartmentTrainingPlanInformation = (
|
|
177
174
|
id: string,
|
|
@@ -182,7 +179,7 @@ const setDepartmentTrainingPlanInformation = (
|
|
|
182
179
|
const requestData = {
|
|
183
180
|
data: data,
|
|
184
181
|
};
|
|
185
|
-
|
|
182
|
+
const confirmationRequest = client.post(
|
|
186
183
|
`api/v1/departmenttrainingplans/${id}`,
|
|
187
184
|
requestData,
|
|
188
185
|
{
|
|
@@ -190,10 +187,10 @@ const setDepartmentTrainingPlanInformation = (
|
|
|
190
187
|
}
|
|
191
188
|
);
|
|
192
189
|
confirmationRequest
|
|
193
|
-
.then((response) => {
|
|
190
|
+
.then((response : AxiosResponse) => {
|
|
194
191
|
resolve(response.data);
|
|
195
192
|
})
|
|
196
|
-
.catch((error) => {
|
|
193
|
+
.catch((error : AxiosError) => {
|
|
197
194
|
reject(error);
|
|
198
195
|
});
|
|
199
196
|
});
|