@stackfactor/client-api 1.1.15-8.1 → 1.1.16
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/exports.js +71 -0
- package/index.js +3 -0
- package/lib/actionNotifications.js +82 -0
- package/lib/address.js +27 -0
- package/lib/aiAssistant.js +139 -0
- package/lib/axiosClient.js +85 -0
- package/lib/config.js +74 -0
- package/lib/constants.js +127 -0
- package/lib/dashboard.js +79 -0
- package/lib/departmentTrainingPlans.js +180 -0
- package/lib/groups.js +302 -0
- package/lib/integration.js +352 -0
- package/lib/integrationConfiguration.js +108 -0
- package/lib/integrations/contentGenerator.js +79 -0
- package/lib/learningContent.js +383 -0
- package/lib/learningPath.js +220 -0
- package/lib/logger.js +60 -0
- package/lib/role.js +406 -0
- package/lib/roleTemplate.js +258 -0
- package/lib/skill.js +514 -0
- package/lib/skillAssessmentTestingSession.js +148 -0
- package/lib/skillAssessments.js +145 -0
- package/lib/skillTemplate.js +318 -0
- package/lib/teams.js +294 -0
- package/lib/tenants.js +57 -0
- package/lib/trainingPlans.js +279 -0
- package/lib/userInformation.js +109 -0
- package/lib/users.js +695 -0
- package/lib/utils.js +48 -0
- package/package.json +10 -31
- package/declarations/axios.d.ts +0 -1
- package/declarations/html2plaintext.d.ts +0 -1
- package/dist/cjs/actionNotifications.d.ts +0 -24
- package/dist/cjs/actionNotifications.d.ts.map +0 -1
- package/dist/cjs/actionNotifications.js +0 -73
- package/dist/cjs/actionNotifications.js.map +0 -1
- package/dist/cjs/address.d.ts +0 -8
- package/dist/cjs/address.d.ts.map +0 -1
- package/dist/cjs/address.js +0 -24
- package/dist/cjs/address.js.map +0 -1
- package/dist/cjs/aiAssistant.d.ts +0 -42
- package/dist/cjs/aiAssistant.d.ts.map +0 -1
- package/dist/cjs/aiAssistant.js +0 -135
- package/dist/cjs/aiAssistant.js.map +0 -1
- package/dist/cjs/avatar.d.ts +0 -11
- package/dist/cjs/avatar.d.ts.map +0 -1
- package/dist/cjs/avatar.js +0 -32
- package/dist/cjs/avatar.js.map +0 -1
- package/dist/cjs/axiosClient.d.ts +0 -31
- package/dist/cjs/axiosClient.d.ts.map +0 -1
- package/dist/cjs/axiosClient.js +0 -126
- package/dist/cjs/axiosClient.js.map +0 -1
- package/dist/cjs/config.d.ts +0 -23
- package/dist/cjs/config.d.ts.map +0 -1
- package/dist/cjs/config.js +0 -63
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/constants.d.ts +0 -69
- package/dist/cjs/constants.d.ts.map +0 -1
- package/dist/cjs/constants.js +0 -91
- package/dist/cjs/constants.js.map +0 -1
- package/dist/cjs/dashboard.d.ts +0 -23
- package/dist/cjs/dashboard.d.ts.map +0 -1
- package/dist/cjs/dashboard.js +0 -74
- package/dist/cjs/dashboard.js.map +0 -1
- package/dist/cjs/departmentTrainingPlans.d.ts +0 -53
- package/dist/cjs/departmentTrainingPlans.d.ts.map +0 -1
- package/dist/cjs/departmentTrainingPlans.js +0 -153
- package/dist/cjs/departmentTrainingPlans.js.map +0 -1
- package/dist/cjs/groups.d.ts +0 -90
- package/dist/cjs/groups.d.ts.map +0 -1
- package/dist/cjs/groups.js +0 -273
- package/dist/cjs/groups.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -33
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -77
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/integration.d.ts +0 -82
- package/dist/cjs/integration.d.ts.map +0 -1
- package/dist/cjs/integration.js +0 -316
- package/dist/cjs/integration.js.map +0 -1
- package/dist/cjs/integrationConfiguration.d.ts +0 -27
- package/dist/cjs/integrationConfiguration.d.ts.map +0 -1
- package/dist/cjs/integrationConfiguration.js +0 -86
- package/dist/cjs/integrationConfiguration.js.map +0 -1
- package/dist/cjs/integrations/contentGenerator.d.ts +0 -22
- package/dist/cjs/integrations/contentGenerator.d.ts.map +0 -1
- package/dist/cjs/integrations/contentGenerator.js +0 -69
- package/dist/cjs/integrations/contentGenerator.js.map +0 -1
- package/dist/cjs/learningContent.d.ts +0 -153
- package/dist/cjs/learningContent.d.ts.map +0 -1
- package/dist/cjs/learningContent.js +0 -474
- package/dist/cjs/learningContent.js.map +0 -1
- package/dist/cjs/learningPath.d.ts +0 -64
- package/dist/cjs/learningPath.d.ts.map +0 -1
- package/dist/cjs/learningPath.js +0 -205
- package/dist/cjs/learningPath.js.map +0 -1
- package/dist/cjs/logger.d.ts +0 -19
- package/dist/cjs/logger.d.ts.map +0 -1
- package/dist/cjs/logger.js +0 -60
- package/dist/cjs/logger.js.map +0 -1
- package/dist/cjs/microSkillsQuizes.d.ts +0 -18
- package/dist/cjs/microSkillsQuizes.d.ts.map +0 -1
- package/dist/cjs/microSkillsQuizes.js +0 -53
- package/dist/cjs/microSkillsQuizes.js.map +0 -1
- package/dist/cjs/quotas.d.ts +0 -15
- package/dist/cjs/quotas.d.ts.map +0 -1
- package/dist/cjs/quotas.js +0 -50
- package/dist/cjs/quotas.js.map +0 -1
- package/dist/cjs/role.d.ts +0 -113
- package/dist/cjs/role.d.ts.map +0 -1
- package/dist/cjs/role.js +0 -363
- package/dist/cjs/role.js.map +0 -1
- package/dist/cjs/roleTemplate.d.ts +0 -73
- package/dist/cjs/roleTemplate.d.ts.map +0 -1
- package/dist/cjs/roleTemplate.js +0 -236
- package/dist/cjs/roleTemplate.js.map +0 -1
- package/dist/cjs/security.d.ts +0 -27
- package/dist/cjs/security.d.ts.map +0 -1
- package/dist/cjs/security.js +0 -79
- package/dist/cjs/security.js.map +0 -1
- package/dist/cjs/skill.d.ts +0 -141
- package/dist/cjs/skill.d.ts.map +0 -1
- package/dist/cjs/skill.js +0 -440
- package/dist/cjs/skill.js.map +0 -1
- package/dist/cjs/skillAssessmentTestingSession.d.ts +0 -85
- package/dist/cjs/skillAssessmentTestingSession.d.ts.map +0 -1
- package/dist/cjs/skillAssessmentTestingSession.js +0 -276
- package/dist/cjs/skillAssessmentTestingSession.js.map +0 -1
- package/dist/cjs/skillAssessments.d.ts +0 -49
- package/dist/cjs/skillAssessments.d.ts.map +0 -1
- package/dist/cjs/skillAssessments.js +0 -156
- package/dist/cjs/skillAssessments.js.map +0 -1
- package/dist/cjs/skillTemplate.d.ts +0 -87
- package/dist/cjs/skillTemplate.d.ts.map +0 -1
- package/dist/cjs/skillTemplate.js +0 -281
- package/dist/cjs/skillTemplate.js.map +0 -1
- package/dist/cjs/talentTransfromation.d.ts +0 -29
- package/dist/cjs/talentTransfromation.d.ts.map +0 -1
- package/dist/cjs/talentTransfromation.js +0 -100
- package/dist/cjs/talentTransfromation.js.map +0 -1
- package/dist/cjs/teams.d.ts +0 -85
- package/dist/cjs/teams.d.ts.map +0 -1
- package/dist/cjs/teams.js +0 -252
- package/dist/cjs/teams.js.map +0 -1
- package/dist/cjs/tenants.d.ts +0 -16
- package/dist/cjs/tenants.d.ts.map +0 -1
- package/dist/cjs/tenants.js +0 -55
- package/dist/cjs/tenants.js.map +0 -1
- package/dist/cjs/trainingPlans.d.ts +0 -92
- package/dist/cjs/trainingPlans.d.ts.map +0 -1
- package/dist/cjs/trainingPlans.js +0 -309
- package/dist/cjs/trainingPlans.js.map +0 -1
- package/dist/cjs/trainingPlansProficiencyLevels.d.ts +0 -32
- package/dist/cjs/trainingPlansProficiencyLevels.d.ts.map +0 -1
- package/dist/cjs/trainingPlansProficiencyLevels.js +0 -97
- package/dist/cjs/trainingPlansProficiencyLevels.js.map +0 -1
- package/dist/cjs/userInformation.d.ts +0 -29
- package/dist/cjs/userInformation.d.ts.map +0 -1
- package/dist/cjs/userInformation.js +0 -81
- package/dist/cjs/userInformation.js.map +0 -1
- package/dist/cjs/users.d.ts +0 -206
- package/dist/cjs/users.d.ts.map +0 -1
- package/dist/cjs/users.js +0 -694
- package/dist/cjs/users.js.map +0 -1
- package/dist/cjs/utils.d.ts +0 -14
- package/dist/cjs/utils.d.ts.map +0 -1
- package/dist/cjs/utils.js +0 -58
- package/dist/cjs/utils.js.map +0 -1
- package/dist/esm/actionNotifications.d.ts +0 -24
- package/dist/esm/actionNotifications.d.ts.map +0 -1
- package/dist/esm/actionNotifications.js +0 -67
- package/dist/esm/actionNotifications.js.map +0 -1
- package/dist/esm/address.d.ts +0 -8
- package/dist/esm/address.d.ts.map +0 -1
- package/dist/esm/address.js +0 -20
- package/dist/esm/address.js.map +0 -1
- package/dist/esm/aiAssistant.d.ts +0 -42
- package/dist/esm/aiAssistant.d.ts.map +0 -1
- package/dist/esm/aiAssistant.js +0 -126
- package/dist/esm/aiAssistant.js.map +0 -1
- package/dist/esm/avatar.d.ts +0 -11
- package/dist/esm/avatar.d.ts.map +0 -1
- package/dist/esm/avatar.js +0 -28
- package/dist/esm/avatar.js.map +0 -1
- package/dist/esm/axiosClient.d.ts +0 -31
- package/dist/esm/axiosClient.d.ts.map +0 -1
- package/dist/esm/axiosClient.js +0 -81
- package/dist/esm/axiosClient.js.map +0 -1
- package/dist/esm/config.d.ts +0 -23
- package/dist/esm/config.d.ts.map +0 -1
- package/dist/esm/config.js +0 -57
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/constants.d.ts +0 -69
- package/dist/esm/constants.d.ts.map +0 -1
- package/dist/esm/constants.js +0 -88
- package/dist/esm/constants.js.map +0 -1
- package/dist/esm/dashboard.d.ts +0 -23
- package/dist/esm/dashboard.d.ts.map +0 -1
- package/dist/esm/dashboard.js +0 -68
- package/dist/esm/dashboard.js.map +0 -1
- package/dist/esm/departmentTrainingPlans.d.ts +0 -53
- package/dist/esm/departmentTrainingPlans.d.ts.map +0 -1
- package/dist/esm/departmentTrainingPlans.js +0 -144
- package/dist/esm/departmentTrainingPlans.js.map +0 -1
- package/dist/esm/groups.d.ts +0 -90
- package/dist/esm/groups.d.ts.map +0 -1
- package/dist/esm/groups.js +0 -258
- package/dist/esm/groups.js.map +0 -1
- package/dist/esm/index.d.ts +0 -33
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -33
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/integration.d.ts +0 -82
- package/dist/esm/integration.d.ts.map +0 -1
- package/dist/esm/integration.js +0 -299
- package/dist/esm/integration.js.map +0 -1
- package/dist/esm/integrationConfiguration.d.ts +0 -27
- package/dist/esm/integrationConfiguration.d.ts.map +0 -1
- package/dist/esm/integrationConfiguration.js +0 -80
- package/dist/esm/integrationConfiguration.js.map +0 -1
- package/dist/esm/integrations/contentGenerator.d.ts +0 -22
- package/dist/esm/integrations/contentGenerator.d.ts.map +0 -1
- package/dist/esm/integrations/contentGenerator.js +0 -64
- package/dist/esm/integrations/contentGenerator.js.map +0 -1
- package/dist/esm/learningContent.d.ts +0 -153
- package/dist/esm/learningContent.d.ts.map +0 -1
- package/dist/esm/learningContent.js +0 -453
- package/dist/esm/learningContent.js.map +0 -1
- package/dist/esm/learningPath.d.ts +0 -64
- package/dist/esm/learningPath.d.ts.map +0 -1
- package/dist/esm/learningPath.js +0 -194
- package/dist/esm/learningPath.js.map +0 -1
- package/dist/esm/logger.d.ts +0 -19
- package/dist/esm/logger.d.ts.map +0 -1
- package/dist/esm/logger.js +0 -55
- package/dist/esm/logger.js.map +0 -1
- package/dist/esm/microSkillsQuizes.d.ts +0 -18
- package/dist/esm/microSkillsQuizes.d.ts.map +0 -1
- package/dist/esm/microSkillsQuizes.js +0 -48
- package/dist/esm/microSkillsQuizes.js.map +0 -1
- package/dist/esm/quotas.d.ts +0 -15
- package/dist/esm/quotas.d.ts.map +0 -1
- package/dist/esm/quotas.js +0 -45
- package/dist/esm/quotas.js.map +0 -1
- package/dist/esm/role.d.ts +0 -113
- package/dist/esm/role.d.ts.map +0 -1
- package/dist/esm/role.js +0 -346
- package/dist/esm/role.js.map +0 -1
- package/dist/esm/roleTemplate.d.ts +0 -73
- package/dist/esm/roleTemplate.d.ts.map +0 -1
- package/dist/esm/roleTemplate.js +0 -224
- package/dist/esm/roleTemplate.js.map +0 -1
- package/dist/esm/security.d.ts +0 -27
- package/dist/esm/security.d.ts.map +0 -1
- package/dist/esm/security.js +0 -72
- package/dist/esm/security.js.map +0 -1
- package/dist/esm/skill.d.ts +0 -141
- package/dist/esm/skill.d.ts.map +0 -1
- package/dist/esm/skill.js +0 -418
- package/dist/esm/skill.js.map +0 -1
- package/dist/esm/skillAssessmentTestingSession.d.ts +0 -85
- package/dist/esm/skillAssessmentTestingSession.d.ts.map +0 -1
- package/dist/esm/skillAssessmentTestingSession.js +0 -261
- package/dist/esm/skillAssessmentTestingSession.js.map +0 -1
- package/dist/esm/skillAssessments.d.ts +0 -49
- package/dist/esm/skillAssessments.d.ts.map +0 -1
- package/dist/esm/skillAssessments.js +0 -147
- package/dist/esm/skillAssessments.js.map +0 -1
- package/dist/esm/skillTemplate.d.ts +0 -87
- package/dist/esm/skillTemplate.d.ts.map +0 -1
- package/dist/esm/skillTemplate.js +0 -267
- package/dist/esm/skillTemplate.js.map +0 -1
- package/dist/esm/talentTransfromation.d.ts +0 -29
- package/dist/esm/talentTransfromation.d.ts.map +0 -1
- package/dist/esm/talentTransfromation.js +0 -93
- package/dist/esm/talentTransfromation.js.map +0 -1
- package/dist/esm/teams.d.ts +0 -85
- package/dist/esm/teams.d.ts.map +0 -1
- package/dist/esm/teams.js +0 -238
- package/dist/esm/teams.js.map +0 -1
- package/dist/esm/tenants.d.ts +0 -16
- package/dist/esm/tenants.d.ts.map +0 -1
- package/dist/esm/tenants.js +0 -50
- package/dist/esm/tenants.js.map +0 -1
- package/dist/esm/trainingPlans.d.ts +0 -92
- package/dist/esm/trainingPlans.d.ts.map +0 -1
- package/dist/esm/trainingPlans.js +0 -293
- package/dist/esm/trainingPlans.js.map +0 -1
- package/dist/esm/trainingPlansProficiencyLevels.d.ts +0 -32
- package/dist/esm/trainingPlansProficiencyLevels.d.ts.map +0 -1
- package/dist/esm/trainingPlansProficiencyLevels.js +0 -90
- package/dist/esm/trainingPlansProficiencyLevels.js.map +0 -1
- package/dist/esm/userInformation.d.ts +0 -29
- package/dist/esm/userInformation.d.ts.map +0 -1
- package/dist/esm/userInformation.js +0 -75
- package/dist/esm/userInformation.js.map +0 -1
- package/dist/esm/users.d.ts +0 -206
- package/dist/esm/users.d.ts.map +0 -1
- package/dist/esm/users.js +0 -663
- package/dist/esm/users.js.map +0 -1
- package/dist/esm/utils.d.ts +0 -14
- package/dist/esm/utils.d.ts.map +0 -1
- package/dist/esm/utils.js +0 -50
- package/dist/esm/utils.js.map +0 -1
package/exports.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import actionNotifications from "./lib/actionNotifications.js";
|
|
2
|
+
import {
|
|
3
|
+
client,
|
|
4
|
+
errorToString,
|
|
5
|
+
getErrorInformation,
|
|
6
|
+
getErrorType,
|
|
7
|
+
shouldReturnError,
|
|
8
|
+
} from "./lib/axiosClient.js";
|
|
9
|
+
import address from "./lib/address.js";
|
|
10
|
+
import config from "./lib/config.js";
|
|
11
|
+
import {
|
|
12
|
+
DOCUMENT_VERSION,
|
|
13
|
+
PERMISSIONS,
|
|
14
|
+
PERMISSION_DESCRIPTIONS,
|
|
15
|
+
RESPONSE_TYPE,
|
|
16
|
+
} from "./lib/constants.js";
|
|
17
|
+
import contentGenerator from "./lib/integrations/contentGenerator.js";
|
|
18
|
+
import dashboard from "./lib/dashboard.js";
|
|
19
|
+
import departmentTraingPlans from "./lib/departmentTrainingPlans.js";
|
|
20
|
+
import integration from "./lib/integration.js";
|
|
21
|
+
import integrationConfiguration from "./lib/integrationConfiguration.js";
|
|
22
|
+
import groups from "./lib/groups.js";
|
|
23
|
+
import learningContent from "./lib/learningContent.js";
|
|
24
|
+
import learningPath from "./lib/learningPath.js";
|
|
25
|
+
import logger from "./lib/logger.js";
|
|
26
|
+
import role from "./lib/role.js";
|
|
27
|
+
import roleTemplate from "./lib/roleTemplate.js";
|
|
28
|
+
import skill from "./lib/skill.js";
|
|
29
|
+
import skillAssessment from "./lib/skillAssessments.js";
|
|
30
|
+
import skillAssessmentTestingSession from "./lib/skillAssessmentTestingSession.js";
|
|
31
|
+
import skillTemplate from "./lib/skillTemplate.js";
|
|
32
|
+
import team from "./lib/teams.js";
|
|
33
|
+
import tenant from "./lib/tenants.js";
|
|
34
|
+
import trainingPlan from "./lib/trainingPlans.js";
|
|
35
|
+
import userInformation from "./lib/userInformation.js";
|
|
36
|
+
import users from "./lib/users.js";
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
actionNotifications,
|
|
40
|
+
address,
|
|
41
|
+
client,
|
|
42
|
+
config,
|
|
43
|
+
contentGenerator,
|
|
44
|
+
dashboard,
|
|
45
|
+
errorToString,
|
|
46
|
+
getErrorInformation,
|
|
47
|
+
getErrorType,
|
|
48
|
+
DOCUMENT_VERSION,
|
|
49
|
+
integration,
|
|
50
|
+
integrationConfiguration,
|
|
51
|
+
departmentTraingPlans,
|
|
52
|
+
groups,
|
|
53
|
+
learningContent,
|
|
54
|
+
learningPath,
|
|
55
|
+
logger,
|
|
56
|
+
PERMISSIONS,
|
|
57
|
+
PERMISSION_DESCRIPTIONS,
|
|
58
|
+
RESPONSE_TYPE,
|
|
59
|
+
role,
|
|
60
|
+
roleTemplate,
|
|
61
|
+
shouldReturnError,
|
|
62
|
+
skill,
|
|
63
|
+
skillAssessment,
|
|
64
|
+
skillAssessmentTestingSession,
|
|
65
|
+
skillTemplate,
|
|
66
|
+
team,
|
|
67
|
+
tenant,
|
|
68
|
+
trainingPlan,
|
|
69
|
+
userInformation,
|
|
70
|
+
users,
|
|
71
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get all permissions
|
|
5
|
+
* @param {String} authToken The authentication token
|
|
6
|
+
*/
|
|
7
|
+
export const getAllUserNotifications = (authToken) => {
|
|
8
|
+
return new Promise(function (resolve, reject) {
|
|
9
|
+
const request = client.get(`api/v1/actionnotifications`, {
|
|
10
|
+
headers: { authorization: authToken },
|
|
11
|
+
});
|
|
12
|
+
request
|
|
13
|
+
.then((response) => {
|
|
14
|
+
resolve(response.data);
|
|
15
|
+
})
|
|
16
|
+
.catch((error) => {
|
|
17
|
+
reject(error);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Mark notifications as open or viewed
|
|
24
|
+
* @param {Array<String>} ids The id of the notifications to be marked
|
|
25
|
+
* @param {String} status The new status
|
|
26
|
+
* @param {String} authToken The authentication token
|
|
27
|
+
*/
|
|
28
|
+
export const markNotifications = (ids, status, authToken) => {
|
|
29
|
+
return new Promise(function (resolve, reject) {
|
|
30
|
+
const request = client.put(
|
|
31
|
+
`api/v1/actionnotifications/mark`,
|
|
32
|
+
{
|
|
33
|
+
ids: ids,
|
|
34
|
+
status: status,
|
|
35
|
+
},
|
|
36
|
+
{ headers: { authorization: authToken } }
|
|
37
|
+
);
|
|
38
|
+
request
|
|
39
|
+
.then((response) => {
|
|
40
|
+
resolve(response.data);
|
|
41
|
+
})
|
|
42
|
+
.catch((error) => {
|
|
43
|
+
reject(error);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Process a notification
|
|
50
|
+
* @param {String} id The notification id
|
|
51
|
+
* @param {String} action The action to be executed
|
|
52
|
+
* @param {String} comments The comments to be saved in the notification
|
|
53
|
+
* @param {String} authToken The authentication token
|
|
54
|
+
*/
|
|
55
|
+
export const processNotification = (id, action, comments, authToken) => {
|
|
56
|
+
return new Promise(function (resolve, reject) {
|
|
57
|
+
const request = client.put(
|
|
58
|
+
`api/v1/actionnotifications/process`,
|
|
59
|
+
{
|
|
60
|
+
id: id,
|
|
61
|
+
action: action,
|
|
62
|
+
comments: comments,
|
|
63
|
+
},
|
|
64
|
+
{ headers: { authorization: authToken } }
|
|
65
|
+
);
|
|
66
|
+
request
|
|
67
|
+
.then((response) => {
|
|
68
|
+
resolve(response.data);
|
|
69
|
+
})
|
|
70
|
+
.catch((error) => {
|
|
71
|
+
reject(error);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const actionNotifications = {
|
|
77
|
+
getAllUserNotifications,
|
|
78
|
+
markNotifications,
|
|
79
|
+
processNotification,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default actionNotifications;
|
package/lib/address.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validate Address
|
|
5
|
+
* @param {String} input - the address in raw format
|
|
6
|
+
* @param {String} authToken - Authorization token
|
|
7
|
+
*/
|
|
8
|
+
export const autoComplete = (input, authToken) => {
|
|
9
|
+
return new Promise(function (resolve, reject) {
|
|
10
|
+
const getAddressesRequest = client.post(
|
|
11
|
+
`api/v1/address/autocomplete/`,
|
|
12
|
+
{ input: input },
|
|
13
|
+
{ headers: { authorization: authToken } }
|
|
14
|
+
);
|
|
15
|
+
getAddressesRequest
|
|
16
|
+
.then((response) => {
|
|
17
|
+
resolve(response.data);
|
|
18
|
+
})
|
|
19
|
+
.catch((error) => {
|
|
20
|
+
reject(error);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const address = { autoComplete };
|
|
26
|
+
|
|
27
|
+
export default address;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ask Question to the AI
|
|
5
|
+
* @param {String} conversationId
|
|
6
|
+
* @param {String} question
|
|
7
|
+
* @param {String} updatedContext
|
|
8
|
+
* @param {String} token Authorization token
|
|
9
|
+
* @returns {Promise}
|
|
10
|
+
*/
|
|
11
|
+
export const askQuestion = (
|
|
12
|
+
conversationId,
|
|
13
|
+
question,
|
|
14
|
+
updatedContext,
|
|
15
|
+
token
|
|
16
|
+
) => {
|
|
17
|
+
return new Promise(function (resolve, reject) {
|
|
18
|
+
let data = {
|
|
19
|
+
conversationId: conversationId,
|
|
20
|
+
question: question,
|
|
21
|
+
updatedContext: updatedContext,
|
|
22
|
+
};
|
|
23
|
+
let confirmationRequest = client.post(
|
|
24
|
+
"/api/v1/aiasistant/askquestion",
|
|
25
|
+
{ data: data },
|
|
26
|
+
{
|
|
27
|
+
headers: { authorization: token },
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
confirmationRequest
|
|
31
|
+
.then((response) => {
|
|
32
|
+
resolve(response.data);
|
|
33
|
+
})
|
|
34
|
+
.catch((error) => {
|
|
35
|
+
reject(error);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* End conversation with the AI
|
|
42
|
+
* @param {String} conversationId
|
|
43
|
+
* @param {String} token Authorization token
|
|
44
|
+
* @returns {Promise}
|
|
45
|
+
*/
|
|
46
|
+
export const endConversation = (conversationId, token) => {
|
|
47
|
+
return new Promise(function (resolve, reject) {
|
|
48
|
+
let data = {
|
|
49
|
+
conversationId: conversationId,
|
|
50
|
+
};
|
|
51
|
+
let confirmationRequest = client.post(
|
|
52
|
+
"/api/v1/aiasistant/endconversation",
|
|
53
|
+
{ data: data },
|
|
54
|
+
{
|
|
55
|
+
headers: { authorization: token },
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
confirmationRequest
|
|
59
|
+
.then((response) => {
|
|
60
|
+
resolve(response.data);
|
|
61
|
+
})
|
|
62
|
+
.catch((error) => {
|
|
63
|
+
reject(error);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get conversation by elementId
|
|
70
|
+
* @param {String} elementId
|
|
71
|
+
* @param {String} token
|
|
72
|
+
* @returns {Promise}
|
|
73
|
+
*/
|
|
74
|
+
const getConversationByElementId = (elementId, token) => {
|
|
75
|
+
return new Promise(function (resolve, reject) {
|
|
76
|
+
let confirmationRequest = client.get(
|
|
77
|
+
`/api/v1/aiasistant/conversation/${elementId}/${userId}`,
|
|
78
|
+
{
|
|
79
|
+
headers: { authorization: token },
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
confirmationRequest
|
|
83
|
+
.then((response) => {
|
|
84
|
+
resolve(response.data);
|
|
85
|
+
})
|
|
86
|
+
.catch((error) => {
|
|
87
|
+
reject(error);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Start conversation with the AI
|
|
94
|
+
* @param {String} elementId
|
|
95
|
+
* @param {String} elementType
|
|
96
|
+
* @param {String} context
|
|
97
|
+
* @param {Boolean} autoContextRefresh
|
|
98
|
+
* @param {String} token
|
|
99
|
+
* @returns {Promise}
|
|
100
|
+
*/
|
|
101
|
+
const startConversation = (
|
|
102
|
+
elementId,
|
|
103
|
+
elementType,
|
|
104
|
+
context,
|
|
105
|
+
autoContextRefresh,
|
|
106
|
+
token
|
|
107
|
+
) => {
|
|
108
|
+
return new Promise(function (resolve, reject) {
|
|
109
|
+
let data = {
|
|
110
|
+
autoContextRefresh: autoContextRefresh,
|
|
111
|
+
context: context,
|
|
112
|
+
elementId: elementId,
|
|
113
|
+
elementType: elementType,
|
|
114
|
+
};
|
|
115
|
+
let confirmationRequest = client.post(
|
|
116
|
+
"/api/v1/aiasistant/startconversation",
|
|
117
|
+
{ data: data },
|
|
118
|
+
{
|
|
119
|
+
headers: { authorization: token },
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
confirmationRequest
|
|
123
|
+
.then((response) => {
|
|
124
|
+
resolve(response.data);
|
|
125
|
+
})
|
|
126
|
+
.catch((error) => {
|
|
127
|
+
reject(error);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const aiAssistant = {
|
|
133
|
+
askQuestion,
|
|
134
|
+
endConversation,
|
|
135
|
+
getConversationByElementId,
|
|
136
|
+
startConversation,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default aiAssistant;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { RESPONSE_TYPE } from "./constants.js";
|
|
3
|
+
import https from "https";
|
|
4
|
+
import utils from "./utils.js";
|
|
5
|
+
|
|
6
|
+
const baseUrl = utils.getBaseUrl();
|
|
7
|
+
|
|
8
|
+
const client = axios.create({
|
|
9
|
+
baseURL: baseUrl,
|
|
10
|
+
httpsAgent: new https.Agent({
|
|
11
|
+
rejectUnauthorized: false,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns the error as a string
|
|
17
|
+
* @param {Object} error
|
|
18
|
+
*/
|
|
19
|
+
const errorToString = (error) => {
|
|
20
|
+
if (error != null) {
|
|
21
|
+
if (error?.response?.data) {
|
|
22
|
+
let asString = "";
|
|
23
|
+
if (Array.isArray(error.response.data.errors)) {
|
|
24
|
+
error.response.data.errors.forEach((item, index) => {
|
|
25
|
+
asString += `${index > 0 ? ", " : ""} ${item.msg} param ${
|
|
26
|
+
item.param
|
|
27
|
+
} ${item.value ? `value ${item.value.toString()}` : ""}`;
|
|
28
|
+
});
|
|
29
|
+
return asString;
|
|
30
|
+
} else if (error.response.data.error) {
|
|
31
|
+
return error.response.data.error.toString();
|
|
32
|
+
} else if (error.response.statusText) {
|
|
33
|
+
return error.response.statusText.toString();
|
|
34
|
+
} else {
|
|
35
|
+
return error.response.data.toString();
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
return error.message ? error.message : "Unknown error";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns the code of the error as a number
|
|
45
|
+
* @param {Object} error
|
|
46
|
+
* @returns {Number} The error code
|
|
47
|
+
*/
|
|
48
|
+
const getErrorType = (error) => {
|
|
49
|
+
if (error?.response?.status) {
|
|
50
|
+
return error.response.status;
|
|
51
|
+
} else return RESPONSE_TYPE.SERVICE_UNAVAILABLE;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Return the error information to include just the status and the message
|
|
56
|
+
* @param {Object} error
|
|
57
|
+
* @returns Object
|
|
58
|
+
*/
|
|
59
|
+
const getErrorInformation = (error) => {
|
|
60
|
+
return {
|
|
61
|
+
status: getErrorType(error),
|
|
62
|
+
message: errorToString(error),
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns true if an exception should be handled to the business and presentation layer
|
|
68
|
+
* @param {Boolean} returnAllExceptions - If set true all exceptions will be passed
|
|
69
|
+
* @param {Object} error - The error returned by the server
|
|
70
|
+
*/
|
|
71
|
+
const shouldReturnError = (returnAllExceptions, error) => {
|
|
72
|
+
if (getErrorType(error) === RESPONSE_TYPE.UNAUTHORIZED) {
|
|
73
|
+
return returnAllExceptions;
|
|
74
|
+
} else {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
client,
|
|
81
|
+
errorToString,
|
|
82
|
+
getErrorType,
|
|
83
|
+
getErrorInformation,
|
|
84
|
+
shouldReturnError,
|
|
85
|
+
};
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the specified configuration by Id. It returns a promise
|
|
5
|
+
* @param {String} id - the id of the configuration element
|
|
6
|
+
* @param {String} authToken - Authorization token
|
|
7
|
+
*/
|
|
8
|
+
export const getConfigurationById = (id, authToken) => {
|
|
9
|
+
return new Promise(function (resolve, reject) {
|
|
10
|
+
const getConfigInformationRequest = client.get(
|
|
11
|
+
`api/v1/configurations/configuration/id/${id}`,
|
|
12
|
+
{ headers: { authorization: authToken } }
|
|
13
|
+
);
|
|
14
|
+
getConfigInformationRequest
|
|
15
|
+
.then((response) => {
|
|
16
|
+
resolve(response.data);
|
|
17
|
+
})
|
|
18
|
+
.catch((error) => {
|
|
19
|
+
reject(error);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the specified configuration by type. It returns a promise
|
|
26
|
+
* @param {String} type - the id of the configuration element
|
|
27
|
+
* @param {String} authToken - Authorization token
|
|
28
|
+
*/
|
|
29
|
+
export const getConfigurationByType = (type, authToken) => {
|
|
30
|
+
return new Promise(function (resolve, reject) {
|
|
31
|
+
const getConfigInformationRequest = client.get(
|
|
32
|
+
`api/v1/configurations/configuration/type/${type}`,
|
|
33
|
+
{ headers: { authorization: authToken } }
|
|
34
|
+
);
|
|
35
|
+
getConfigInformationRequest
|
|
36
|
+
.then((response) => {
|
|
37
|
+
resolve(response.data);
|
|
38
|
+
})
|
|
39
|
+
.catch((error) => {
|
|
40
|
+
reject(error);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set the specified configuration by Id. It returns a promise
|
|
47
|
+
* @param {String} id - the id of the configuration element
|
|
48
|
+
* @param {Object} data - the object containing the updated configuration element
|
|
49
|
+
* @param {String} authToken - Authorization token
|
|
50
|
+
*/
|
|
51
|
+
export const setConfigurationById = (id, data, authToken) => {
|
|
52
|
+
return new Promise(function (resolve, reject) {
|
|
53
|
+
const getConfigInformationRequest = client.post(
|
|
54
|
+
`api/v1/configurations/configuration/${id}`,
|
|
55
|
+
{ data: data },
|
|
56
|
+
{ headers: { authorization: authToken } }
|
|
57
|
+
);
|
|
58
|
+
getConfigInformationRequest
|
|
59
|
+
.then((response) => {
|
|
60
|
+
resolve(response.data);
|
|
61
|
+
})
|
|
62
|
+
.catch((error) => {
|
|
63
|
+
reject(error);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const config = {
|
|
69
|
+
getConfigurationById,
|
|
70
|
+
getConfigurationByType,
|
|
71
|
+
setConfigurationById,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default config;
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const DOCUMENT_VERSION = {
|
|
2
|
+
DRAFT: "draft",
|
|
3
|
+
PUBLISHED: "published",
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
const RESPONSE_TYPE = {
|
|
7
|
+
//The requested resource corresponds to any one of a set of representations, each with its own specific location.
|
|
8
|
+
MULTIPLE_CHOICES: 300,
|
|
9
|
+
//The resource has moved permanently. Please refer to the documentation.
|
|
10
|
+
MOVED_PERMANENTLY: 301,
|
|
11
|
+
//The resource has moved temporarily. Please refer to the documentation.
|
|
12
|
+
FOUND: 302,
|
|
13
|
+
//The resource can be found under a different URI.
|
|
14
|
+
SEE_OTHER: 303,
|
|
15
|
+
//The resource is available and not modified.
|
|
16
|
+
NOT_MODIFIED: 304,
|
|
17
|
+
//The requested resource must be accessed through the proxy given by the Location field.
|
|
18
|
+
USE_PROXY: 305,
|
|
19
|
+
//The resource resides temporarily under a different URI.
|
|
20
|
+
TEMPORARY_REDIRECT: 307,
|
|
21
|
+
//Invalid syntax for this request was provided.
|
|
22
|
+
BAD_REQUEST: 400,
|
|
23
|
+
//You are unauthorized to access the requested resource. Please log in.
|
|
24
|
+
UNAUTHORIZED: 401,
|
|
25
|
+
//Your account is not authorized to access the requested resource.
|
|
26
|
+
FORBIDDEN: 403,
|
|
27
|
+
//We could not find the resource you requested. Please refer to the documentation for the list of resources.
|
|
28
|
+
NOT_FOUND: 404,
|
|
29
|
+
//This method type is not currently supported.
|
|
30
|
+
METHOD_NOT_ALLOWED: 405,
|
|
31
|
+
//Acceptance header is invalid for this endpoint resource.
|
|
32
|
+
NOT_ACCEPTABLE: 406,
|
|
33
|
+
//Authentication with proxy is required.
|
|
34
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
35
|
+
//Client did not produce a request within the time that the server was prepared to wait.
|
|
36
|
+
REQUEST_TIMEOUT: 408,
|
|
37
|
+
//The request could not be completed due to a conflict with the current state of the resource.
|
|
38
|
+
CONFLICT: 409,
|
|
39
|
+
//The requested resource is no longer available and has been permanently removed.
|
|
40
|
+
GONE: 410,
|
|
41
|
+
//Length of the content is required, please include it with the request.
|
|
42
|
+
LENGTH_REQUIRED: 411,
|
|
43
|
+
//The request did not match the pre-conditions of the requested resource.
|
|
44
|
+
PRECONDITION_FAILED: 412,
|
|
45
|
+
//The request entity is larger than the server is willing or able to process.
|
|
46
|
+
REQUEST_ENTITY_TOO_LARGE: 413,
|
|
47
|
+
//The request URI is longer than the server is willing to interpret.
|
|
48
|
+
REQUEST_URI_TOO_LONG: 414,
|
|
49
|
+
//The requested resource does not support the media type provided.
|
|
50
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
51
|
+
//The requested range for the resource is not available.
|
|
52
|
+
REQUESTED_RANGE_NOT_SATISFIABLE: 416,
|
|
53
|
+
//Unable to meet the expectation given in the Expect request header.
|
|
54
|
+
EXPECTATION_FAILED: 417,
|
|
55
|
+
//The requested resource is missing required arguments.
|
|
56
|
+
MISSING_ARGUMENTS: 419,
|
|
57
|
+
//The requested resource does not support one or more of the given parameters.
|
|
58
|
+
INVALID_ARGUMENTS: 420,
|
|
59
|
+
//The request was well-formed but was unable to be followed due to semantic errors.
|
|
60
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
61
|
+
//Unexpected internal server error.
|
|
62
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
63
|
+
//The requested resource is recognized but not implemented.
|
|
64
|
+
NOT_IMPLEMENTED: 501,
|
|
65
|
+
//Invalid response received when acting as a proxy or gateway.
|
|
66
|
+
BAD_GATEWAY: 502,
|
|
67
|
+
//The server is currently unavailable.
|
|
68
|
+
SERVICE_UNAVAILABLE: 503,
|
|
69
|
+
//Did not receive a timely response from upstream server while acting as a gateway or proxy.
|
|
70
|
+
GATEWAY_TIMEOUT: 504,
|
|
71
|
+
//The HTTP protocol version used in the request message is not supported.
|
|
72
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
73
|
+
//A failure occurred during initialization of services. API will be unavailable.
|
|
74
|
+
INITIALIZATION_FAILURE: 550,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const PERMISSIONS = {
|
|
78
|
+
ACCESS_TO_CONTENT_GENERATORS: "651d81d626fb9aafa4077520",
|
|
79
|
+
ADMIN_AUTHOR_CONTENT: "5ea3d1152839450e16e72bba",
|
|
80
|
+
ADMIN_PROMOTE_CONTENT: "5ea3d10bea252025c8ec351b",
|
|
81
|
+
ADMIN_MANAGE_CONTENT_PROVIDERS: "61970935cee185acf08111f6",
|
|
82
|
+
AUTHOR_CONTENT: "5fac210560e43de7c6b4a208",
|
|
83
|
+
BETA_TESTER: "5fac210b6c8f874bd7137b97",
|
|
84
|
+
MANAGE_BILLING: "5e1570cd03f676213bfdcd08",
|
|
85
|
+
MANAGE_CONTENT_PROVIDERS: "5f0fa12f16a720fde58ea820",
|
|
86
|
+
MANAGE_GROUPS: "5dd612fe59e518ac87b8cf8e",
|
|
87
|
+
MANAGE_LEARNING_CONTENT: "64f54d20b7e49e10c779b4a6",
|
|
88
|
+
MANAGE_LEARNING_PATHS: "5dd61305a73c68b44c3f0827",
|
|
89
|
+
MANAGE_ORGANIZATION_INFORMATION: "5dd612d5338ea9a6ae6326da",
|
|
90
|
+
MANAGE_OWN_PROFILE_INFORMATION_AUTO_APP: "5fac210e7e6539d37a897c94",
|
|
91
|
+
MANAGE_OWN_PROFILE_SKIP_ASSESSMENT: "650fadb23956a2154ac890ac",
|
|
92
|
+
MANAGE_OWN_SKILL_SET_AUTO_APPROVE: "5fac21164351c6727a34cd4e",
|
|
93
|
+
MANAGE_SETTINGS: "5e1570e087d836dc77888a5f",
|
|
94
|
+
MANAGE_TEAM_INFORMATION_AUTO_APPROVE: "5fac211e6c8f874bd7137b98",
|
|
95
|
+
MANAGE_TEAMS: "5dd61314afc2455a89b1a37b",
|
|
96
|
+
MANAGE_USERS: "5dd612e40f0bc559c41a2b29",
|
|
97
|
+
PROMOTE_CONTENT: "5fac2126427ce31f8a92c0cb",
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const PERMISSION_DESCRIPTIONS = {
|
|
101
|
+
"5ea3d1152839450e16e72bba": "Author content",
|
|
102
|
+
"5ea3d10bea252025c8ec351b": "Promote content",
|
|
103
|
+
"61970935cee185acf08111f6": "Manage content providers",
|
|
104
|
+
"5fac210560e43de7c6b4a208": "Author content",
|
|
105
|
+
"5e1570cd03f676213bfdcd08": "Manage billing",
|
|
106
|
+
"5f0fa12f16a720fde58ea820": "Manage content providers",
|
|
107
|
+
"5dd612fe59e518ac87b8cf8e": "Manage groups",
|
|
108
|
+
"64f54d20b7e49e10c779b4a6": "Manage learning content",
|
|
109
|
+
"5dd61305a73c68b44c3f0827": "Manage learning paths",
|
|
110
|
+
"5dd612d5338ea9a6ae6326da": "Manage organization information",
|
|
111
|
+
"5fac210e7e6539d37a897c94": "Auto approve own profile information updates",
|
|
112
|
+
"650fadb23956a2154ac890ac":
|
|
113
|
+
"Skip assessment when updating own profile information",
|
|
114
|
+
"5fac21164351c6727a34cd4e": "Auto approve own skill set updates",
|
|
115
|
+
"5e1570e087d836dc77888a5f": "Manage settings",
|
|
116
|
+
"5fac211e6c8f874bd7137b98": "Auto approve own team information updates",
|
|
117
|
+
"5dd61314afc2455a89b1a37b": "Manage teams",
|
|
118
|
+
"5dd612e40f0bc559c41a2b29": "Manage users",
|
|
119
|
+
"5fac2126427ce31f8a92c0cb": "Promote content",
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
DOCUMENT_VERSION,
|
|
124
|
+
PERMISSIONS,
|
|
125
|
+
PERMISSION_DESCRIPTIONS,
|
|
126
|
+
RESPONSE_TYPE,
|
|
127
|
+
};
|
package/lib/dashboard.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Add a card to the dashboard
|
|
5
|
+
* @param {String} id - the id of the card to be added to the dashboard
|
|
6
|
+
* @param {Number} position - The position on the dashboard
|
|
7
|
+
* @param {Object} data - The card settings data
|
|
8
|
+
* @param {String} authToken - Authorization token
|
|
9
|
+
*/
|
|
10
|
+
export const addCardToDashboard = (id, position, data, authToken) => {
|
|
11
|
+
return new Promise(function (resolve, reject) {
|
|
12
|
+
const request = client.put(
|
|
13
|
+
`/api/v1/dashboard/card`,
|
|
14
|
+
{
|
|
15
|
+
id: id,
|
|
16
|
+
position: position,
|
|
17
|
+
data: data ? data : {},
|
|
18
|
+
},
|
|
19
|
+
{ headers: { authorization: authToken } }
|
|
20
|
+
);
|
|
21
|
+
request
|
|
22
|
+
.then((response) => {
|
|
23
|
+
resolve(response.data);
|
|
24
|
+
})
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
reject(error);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the list of the cards from the dashboard
|
|
33
|
+
* @param {String} authToken - Authorization token
|
|
34
|
+
*/
|
|
35
|
+
export const getDashboardCardsList = (authToken) => {
|
|
36
|
+
return new Promise(function (resolve, reject) {
|
|
37
|
+
const request = client.get(`/api/v1/dashboard/card`, {
|
|
38
|
+
headers: { authorization: authToken },
|
|
39
|
+
});
|
|
40
|
+
request
|
|
41
|
+
.then((response) => {
|
|
42
|
+
resolve(response.data);
|
|
43
|
+
})
|
|
44
|
+
.catch((error) => {
|
|
45
|
+
reject(error);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Remove a card from the dashboard
|
|
52
|
+
* @param {String} id - the id of the configuration element
|
|
53
|
+
* @param {String} authToken - Authorization token
|
|
54
|
+
*/
|
|
55
|
+
export const removeCardFromDashboard = (id, authToken) => {
|
|
56
|
+
return new Promise(function (resolve, reject) {
|
|
57
|
+
const request = client.delete(`/api/v1/dashboard/card`, {
|
|
58
|
+
headers: { authorization: authToken },
|
|
59
|
+
data: {
|
|
60
|
+
id: id,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
request
|
|
64
|
+
.then((response) => {
|
|
65
|
+
resolve(response.data);
|
|
66
|
+
})
|
|
67
|
+
.catch((error) => {
|
|
68
|
+
reject(error);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const dashboard = {
|
|
74
|
+
addCardToDashboard,
|
|
75
|
+
getDashboardCardsList,
|
|
76
|
+
removeCardFromDashboard,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default dashboard;
|