@stackfactor/client-api 1.1.15-8.1 → 1.1.15
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 +131 -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
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { client, errorToString } from "./axiosClient.js";
|
|
2
|
+
import axiosLib from "axios";
|
|
3
|
+
import htmlParser from "node-html-parser";
|
|
4
|
+
import htmlToText from "html2plaintext";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create integration and set information
|
|
8
|
+
* @param {Object} data The new integration information
|
|
9
|
+
* @param {String} token Authorization token
|
|
10
|
+
*/
|
|
11
|
+
export const createIntegration = (data, token) => {
|
|
12
|
+
return new Promise(function (resolve, reject) {
|
|
13
|
+
const requestData = {
|
|
14
|
+
data: data,
|
|
15
|
+
};
|
|
16
|
+
let confirmationRequest = client.put("api/v1/integrations/", requestData, {
|
|
17
|
+
headers: { authorization: token },
|
|
18
|
+
});
|
|
19
|
+
confirmationRequest
|
|
20
|
+
.then((response) => {
|
|
21
|
+
resolve(response.data);
|
|
22
|
+
})
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
reject(error);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Delete integration
|
|
31
|
+
* @param {String} id The id of the integration to be deleted
|
|
32
|
+
* @param {String} token Authorization token
|
|
33
|
+
*/
|
|
34
|
+
export const deleteIntegration = (id, token) => {
|
|
35
|
+
return new Promise(function (resolve, reject) {
|
|
36
|
+
const request = client.delete(`api/v1/integrations/`, {
|
|
37
|
+
headers: { authorization: token },
|
|
38
|
+
data: {
|
|
39
|
+
id: id,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
request
|
|
43
|
+
.then((response) => {
|
|
44
|
+
resolve(response.data);
|
|
45
|
+
})
|
|
46
|
+
.catch((error) => {
|
|
47
|
+
reject(error);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Discard the integration draft changes
|
|
54
|
+
* @param {String} id The id of the role template to be deleted
|
|
55
|
+
* @param {String} token Authorization token
|
|
56
|
+
*/
|
|
57
|
+
export const discardIntegrationChanges = (id, token) => {
|
|
58
|
+
return new Promise(function (resolve, reject) {
|
|
59
|
+
const data = {};
|
|
60
|
+
const request = client.get(`api/v1/integrations/discard/${id}`, {
|
|
61
|
+
headers: { authorization: token },
|
|
62
|
+
data: data,
|
|
63
|
+
});
|
|
64
|
+
request
|
|
65
|
+
.then((response) => {
|
|
66
|
+
resolve(response.data);
|
|
67
|
+
})
|
|
68
|
+
.catch((error) => {
|
|
69
|
+
reject(error);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get integration information
|
|
76
|
+
* @param {String} id The id of the integration
|
|
77
|
+
* @param {String} version The version of the integration to be received
|
|
78
|
+
* @param {String} token Authorization token
|
|
79
|
+
*/
|
|
80
|
+
export const getIntegrationInformationById = (id, version, token) => {
|
|
81
|
+
return new Promise(function (resolve, reject) {
|
|
82
|
+
let confirmationRequest = client.get(
|
|
83
|
+
`api/v1/integrations/${id}/${version}`,
|
|
84
|
+
{
|
|
85
|
+
headers: { authorization: token },
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
confirmationRequest
|
|
89
|
+
.then((response) => {
|
|
90
|
+
resolve(response.data);
|
|
91
|
+
})
|
|
92
|
+
.catch((error) => {
|
|
93
|
+
reject(error);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get integrations list
|
|
100
|
+
* @param {Array<String>} filter The filter used to select the integration
|
|
101
|
+
* @param {String} type The type of the integration
|
|
102
|
+
* @param {String} version The version to be retrieved
|
|
103
|
+
* @param {Boolean} includeSupportedCapabilities If true, the supported capabilities will be included in the response
|
|
104
|
+
* @param {String} token Authorization token
|
|
105
|
+
*/
|
|
106
|
+
export const getIntegrationsList = (
|
|
107
|
+
filter,
|
|
108
|
+
type,
|
|
109
|
+
version,
|
|
110
|
+
includeSupportedCapabilities,
|
|
111
|
+
token
|
|
112
|
+
) => {
|
|
113
|
+
return new Promise(function (resolve, reject) {
|
|
114
|
+
const requestData = {
|
|
115
|
+
includeSupportedCapabilities: includeSupportedCapabilities,
|
|
116
|
+
version: version,
|
|
117
|
+
};
|
|
118
|
+
if (filter) requestData.filter = filter;
|
|
119
|
+
if (type) requestData.type = type;
|
|
120
|
+
let confirmationRequest = client.post(`api/v1/integrations`, requestData, {
|
|
121
|
+
headers: { authorization: token },
|
|
122
|
+
});
|
|
123
|
+
confirmationRequest
|
|
124
|
+
.then((response) => {
|
|
125
|
+
resolve(response.data);
|
|
126
|
+
})
|
|
127
|
+
.catch((error) => {
|
|
128
|
+
reject(error);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get content information by Url
|
|
135
|
+
* @param {String} url The training url
|
|
136
|
+
* @param {String} verb The verb
|
|
137
|
+
* @param {String} token Authorization token
|
|
138
|
+
*/
|
|
139
|
+
export const getContentInformationByUrl = (url, verb, token) => {
|
|
140
|
+
return new Promise(function (resolve, reject) {
|
|
141
|
+
const requestData = {
|
|
142
|
+
url: url,
|
|
143
|
+
verb: verb,
|
|
144
|
+
};
|
|
145
|
+
let confirmationRequest = client.post(
|
|
146
|
+
`api/v1/contentproviders/getcontentinformationbyurl`,
|
|
147
|
+
requestData,
|
|
148
|
+
{
|
|
149
|
+
headers: { authorization: token },
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
confirmationRequest
|
|
153
|
+
.then((response) => {
|
|
154
|
+
resolve(response.data);
|
|
155
|
+
})
|
|
156
|
+
.catch((error) => {
|
|
157
|
+
reject(error);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Get content information by url from the browser instead of the backend
|
|
164
|
+
* @param {String} url
|
|
165
|
+
* @returns {Object}
|
|
166
|
+
*/
|
|
167
|
+
export const getContentInformationByUrlFromBrowser = (url) => {
|
|
168
|
+
return new Promise(function (resolve, reject) {
|
|
169
|
+
let domain = new URL(url);
|
|
170
|
+
let instance = axiosLib.create({
|
|
171
|
+
baseURL: domain.origin,
|
|
172
|
+
});
|
|
173
|
+
let confirmationRequest = instance.get(domain.pathname, {
|
|
174
|
+
headers: {
|
|
175
|
+
"Access-Control-Allow-Origin": "*",
|
|
176
|
+
"Access-Control-Allow-Headers":
|
|
177
|
+
"Authorization, Origin, X-Requested-With, Content-Type, Accept",
|
|
178
|
+
Accept:
|
|
179
|
+
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
180
|
+
"Accept-Encoding": "gzip, deflate, br",
|
|
181
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
182
|
+
"User-Agent": "Mozilla/5.0",
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
confirmationRequest
|
|
186
|
+
.then((response) => {
|
|
187
|
+
//get the reading time
|
|
188
|
+
const getReadingTime = (text) => {
|
|
189
|
+
const wpm = 225;
|
|
190
|
+
const words = text.trim().split(/\s+/).length;
|
|
191
|
+
return Math.ceil(words / wpm);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
let document = htmlParser.parse(response.responseText);
|
|
195
|
+
let duration = getReadingTime(htmlToText(response.responseText));
|
|
196
|
+
let title = document.querySelector("title")?.rawText;
|
|
197
|
+
let description = "";
|
|
198
|
+
const descriptionEl = document.querySelector("meta");
|
|
199
|
+
try {
|
|
200
|
+
if (descriptionEl) {
|
|
201
|
+
const descriptionParentNode = descriptionEl.parentNode;
|
|
202
|
+
if (descriptionParentNode) {
|
|
203
|
+
const descriptionChildNodes = descriptionParentNode.childNodes;
|
|
204
|
+
if (descriptionChildNodes) {
|
|
205
|
+
const descriptionRawAttr = descriptionChildNodes.find((item) =>
|
|
206
|
+
item.rawAttrs.includes("description")
|
|
207
|
+
);
|
|
208
|
+
if (descriptionRawAttr) {
|
|
209
|
+
const descriptionContent =
|
|
210
|
+
descriptionRawAttr.rawAttrs.substring(
|
|
211
|
+
descriptionRawAttr.rawAttrs.indexOf("content=") + 9
|
|
212
|
+
);
|
|
213
|
+
description = descriptionContent.substring(
|
|
214
|
+
0,
|
|
215
|
+
descriptionContent.length - 1
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} finally {
|
|
222
|
+
resolve({
|
|
223
|
+
description: description,
|
|
224
|
+
duration: duration,
|
|
225
|
+
icon: `http://www.google.com/s2/favicons?sz=128&domain_url=${pathArray[2]}`,
|
|
226
|
+
title: title ? title.trim() : url,
|
|
227
|
+
type: 0,
|
|
228
|
+
internal: true,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
.catch((error) => {
|
|
233
|
+
reject(new Error(errorToString(error)));
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Get enabled content providers
|
|
240
|
+
* @param {String} userid
|
|
241
|
+
* @param {String} verb The verb
|
|
242
|
+
* @param {String} token Authorization token
|
|
243
|
+
*/
|
|
244
|
+
export const getEnabledContentProviders = (userId, token) => {
|
|
245
|
+
return new Promise(function (resolve, reject) {
|
|
246
|
+
let confirmationRequest = client.get(
|
|
247
|
+
`api/v1/contentproviders/getenabledcontentproviders/${userId}`,
|
|
248
|
+
{
|
|
249
|
+
headers: { authorization: token },
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
confirmationRequest
|
|
253
|
+
.then((response) => {
|
|
254
|
+
resolve(response.data);
|
|
255
|
+
})
|
|
256
|
+
.catch((error) => {
|
|
257
|
+
reject(error);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Publish integration
|
|
264
|
+
* @param {String} id The id of the integration to be published
|
|
265
|
+
* @param {String} token Authorization token
|
|
266
|
+
*/
|
|
267
|
+
export const publishIntegration = (id, token) => {
|
|
268
|
+
return new Promise(function (resolve, reject) {
|
|
269
|
+
let confirmationRequest = client.post(
|
|
270
|
+
`api/v1/integrations/publish/${id}`,
|
|
271
|
+
{},
|
|
272
|
+
{
|
|
273
|
+
headers: { authorization: token },
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
confirmationRequest
|
|
277
|
+
.then((response) => {
|
|
278
|
+
resolve(response.data);
|
|
279
|
+
})
|
|
280
|
+
.catch((error) => {
|
|
281
|
+
reject(error);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Set integration information
|
|
288
|
+
* @param {String} id The id of the integration to be updated
|
|
289
|
+
* @param {Object} data Data used to update the integration
|
|
290
|
+
* @param {String} token Authorization token
|
|
291
|
+
*/
|
|
292
|
+
export const setIntegrationInformation = (id, data, token) => {
|
|
293
|
+
return new Promise(function (resolve, reject) {
|
|
294
|
+
const requestData = {
|
|
295
|
+
data: data,
|
|
296
|
+
};
|
|
297
|
+
let confirmationRequest = client.post(
|
|
298
|
+
`api/v1/integrations/${id}`,
|
|
299
|
+
requestData,
|
|
300
|
+
{
|
|
301
|
+
headers: { authorization: token },
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
confirmationRequest
|
|
305
|
+
.then((response) => {
|
|
306
|
+
resolve(response.data);
|
|
307
|
+
})
|
|
308
|
+
.catch((error) => {
|
|
309
|
+
reject(error);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Set default integration
|
|
316
|
+
* @param {String} id The id of the integration to be set as default
|
|
317
|
+
* @param {String} token Authorization token
|
|
318
|
+
*/
|
|
319
|
+
export const setDefaultIntegration = (id, token) => {
|
|
320
|
+
return new Promise(function (resolve, reject) {
|
|
321
|
+
let confirmationRequest = client.post(
|
|
322
|
+
`api/v1/integrations/${id}/default`,
|
|
323
|
+
"",
|
|
324
|
+
{
|
|
325
|
+
headers: { authorization: token },
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
confirmationRequest
|
|
329
|
+
.then((response) => {
|
|
330
|
+
resolve(response.data);
|
|
331
|
+
})
|
|
332
|
+
.catch((error) => {
|
|
333
|
+
reject(error);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const integration = {
|
|
339
|
+
createIntegration,
|
|
340
|
+
deleteIntegration,
|
|
341
|
+
discardIntegrationChanges,
|
|
342
|
+
getContentInformationByUrl,
|
|
343
|
+
getContentInformationByUrlFromBrowser,
|
|
344
|
+
getEnabledContentProviders,
|
|
345
|
+
getIntegrationInformationById,
|
|
346
|
+
getIntegrationsList,
|
|
347
|
+
publishIntegration,
|
|
348
|
+
setDefaultIntegration,
|
|
349
|
+
setIntegrationInformation,
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
export default integration;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { client } from "./axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the integration configuration
|
|
5
|
+
* @param {Array<String>} ids
|
|
6
|
+
* @param {Number} type
|
|
7
|
+
* @param {String} token Authorization token
|
|
8
|
+
*/
|
|
9
|
+
export const getIntegrationsConfiguration = (ids, type, token) => {
|
|
10
|
+
return new Promise(function (resolve, reject) {
|
|
11
|
+
let requestData = { type: type };
|
|
12
|
+
if (ids) requestData.ids = ids;
|
|
13
|
+
let confirmationRequest = client.post(
|
|
14
|
+
"api/v1/integrationsconfiguration",
|
|
15
|
+
requestData,
|
|
16
|
+
{
|
|
17
|
+
headers: { authorization: token },
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
confirmationRequest
|
|
21
|
+
.then((response) => {
|
|
22
|
+
resolve(response.data);
|
|
23
|
+
})
|
|
24
|
+
.catch((error) => {
|
|
25
|
+
reject(error);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Save integration configuration
|
|
32
|
+
* @param {String} id The id of the integration configurationto be updated
|
|
33
|
+
* @param {Number} type The type of configuration
|
|
34
|
+
* @param {Object} configuration Data used to update the integration configuration
|
|
35
|
+
* @param {String} token Authorization token
|
|
36
|
+
*/
|
|
37
|
+
export const saveIntegrationConfiguration = (
|
|
38
|
+
id,
|
|
39
|
+
type,
|
|
40
|
+
configuration,
|
|
41
|
+
token
|
|
42
|
+
) => {
|
|
43
|
+
return new Promise(function (resolve, reject) {
|
|
44
|
+
const requestData = {
|
|
45
|
+
id: id,
|
|
46
|
+
configuration: configuration,
|
|
47
|
+
type: type,
|
|
48
|
+
};
|
|
49
|
+
let confirmationRequest = client.put(
|
|
50
|
+
`api/v1/integrationsconfiguration`,
|
|
51
|
+
requestData,
|
|
52
|
+
{
|
|
53
|
+
headers: { authorization: token },
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
confirmationRequest
|
|
57
|
+
.then((response) => {
|
|
58
|
+
resolve(response.data);
|
|
59
|
+
})
|
|
60
|
+
.catch((error) => {
|
|
61
|
+
reject(error);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Test integration configuration
|
|
68
|
+
* @param {String} id The id of the integration to be updated
|
|
69
|
+
* @param {String} type The type of configuration
|
|
70
|
+
* @param {Object} configuration Configuration to be tested
|
|
71
|
+
* @param {String} token Authorization token
|
|
72
|
+
*/
|
|
73
|
+
export const testIntegrationConfiguration = (
|
|
74
|
+
id,
|
|
75
|
+
type,
|
|
76
|
+
configuration,
|
|
77
|
+
token
|
|
78
|
+
) => {
|
|
79
|
+
return new Promise(function (resolve, reject) {
|
|
80
|
+
const requestData = {
|
|
81
|
+
id: id,
|
|
82
|
+
configuration: configuration,
|
|
83
|
+
type: type,
|
|
84
|
+
};
|
|
85
|
+
let confirmationRequest = client.post(
|
|
86
|
+
`api/v1/integrationsconfiguration/testConfiguration`,
|
|
87
|
+
requestData,
|
|
88
|
+
{
|
|
89
|
+
headers: { authorization: token },
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
confirmationRequest
|
|
93
|
+
.then((response) => {
|
|
94
|
+
resolve(response.data);
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
reject(error);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const integrationConfiguration = {
|
|
103
|
+
getIntegrationsConfiguration,
|
|
104
|
+
saveIntegrationConfiguration,
|
|
105
|
+
testIntegrationConfiguration,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export default integrationConfiguration;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { client } from "../axiosClient.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate content
|
|
5
|
+
* @param {Array<String>} data
|
|
6
|
+
* @param {String} contentType
|
|
7
|
+
* @param {String} integrationId
|
|
8
|
+
* @param {String} token
|
|
9
|
+
* @returns {Object}
|
|
10
|
+
*/
|
|
11
|
+
export const generateContent = (data, contentType, integrationId, token) => {
|
|
12
|
+
return new Promise(function (resolve, reject) {
|
|
13
|
+
let data_ = {
|
|
14
|
+
data: data,
|
|
15
|
+
contentType: contentType,
|
|
16
|
+
};
|
|
17
|
+
if (integrationId) data.integrationId = integrationId;
|
|
18
|
+
const request = client.post(`api/v1/contentgenerators/generate`, data_, {
|
|
19
|
+
headers: { authorization: token },
|
|
20
|
+
});
|
|
21
|
+
request
|
|
22
|
+
.then((response) => {
|
|
23
|
+
resolve(response.data);
|
|
24
|
+
})
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
reject(error);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generate content aync
|
|
33
|
+
* @param {String} id
|
|
34
|
+
* @param {Object} data
|
|
35
|
+
* @param {String} contentType
|
|
36
|
+
* @param {String} elementType
|
|
37
|
+
* @param {String} integrationId
|
|
38
|
+
* @param {String} comments
|
|
39
|
+
* @param {String} token
|
|
40
|
+
* @returns {Object}
|
|
41
|
+
*/
|
|
42
|
+
export const generateContentAsync = (
|
|
43
|
+
id,
|
|
44
|
+
data,
|
|
45
|
+
contentType,
|
|
46
|
+
elementType,
|
|
47
|
+
integrationId,
|
|
48
|
+
comments,
|
|
49
|
+
token
|
|
50
|
+
) => {
|
|
51
|
+
return new Promise(function (resolve, reject) {
|
|
52
|
+
let data_ = {
|
|
53
|
+
data: data,
|
|
54
|
+
comments: comments,
|
|
55
|
+
contentType: contentType,
|
|
56
|
+
elementType: elementType,
|
|
57
|
+
id: id,
|
|
58
|
+
};
|
|
59
|
+
if (integrationId) data_.integrationId = integrationId;
|
|
60
|
+
const request = client.post(
|
|
61
|
+
`api/v1/contentgenerators/generateasync`,
|
|
62
|
+
data_,
|
|
63
|
+
{
|
|
64
|
+
headers: { authorization: token },
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
request
|
|
68
|
+
.then((response) => {
|
|
69
|
+
resolve(response.data);
|
|
70
|
+
})
|
|
71
|
+
.catch((error) => {
|
|
72
|
+
reject(error);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const contentGenerator = { generateContent, generateContentAsync };
|
|
78
|
+
|
|
79
|
+
export default contentGenerator;
|