@stackfactor/client-api 1.1.128 → 1.1.130
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.ts +85 -0
- package/index.ts +1 -0
- package/lib/{actionNotifications.js → actionNotifications.ts} +18 -6
- package/lib/{address.js → address.ts} +3 -2
- package/lib/{aiAssistant.js → aiAssistant.ts} +58 -25
- package/lib/{avatar.js → avatar.ts} +10 -4
- package/lib/axiosClient.ts +92 -0
- package/lib/{config.js → config.ts} +19 -6
- package/lib/{constants.js → constants.ts} +6 -41
- package/lib/{dashboard.js → dashboard.ts} +17 -7
- package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +57 -23
- package/lib/{groups.js → groups.ts} +67 -26
- package/lib/{integration.js → integration.ts} +100 -43
- package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +25 -8
- package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
- package/lib/{learningContent.js → learningContent.ts} +127 -66
- package/lib/{learningPath.js → learningPath.ts} +56 -29
- package/lib/{logger.js → logger.ts} +17 -5
- package/lib/{microSkillsQuizes.js → microSkillsQuizes.ts} +15 -6
- package/lib/{quotas.js → quotas.ts} +10 -5
- package/lib/{role.js → role.ts} +114 -66
- package/lib/{roleTemplate.js → roleTemplate.ts} +63 -28
- package/lib/{security.js → security.ts} +14 -10
- package/lib/{skill.js → skill.ts} +119 -82
- package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +39 -17
- package/lib/skillAssessments.ts +192 -0
- package/lib/{skillTemplate.js → skillTemplate.ts} +70 -39
- package/lib/{talentTransfromation.js → talentTransfromation.ts} +21 -15
- package/lib/{teams.js → teams.ts} +71 -27
- package/lib/{tenants.js → tenants.ts} +16 -7
- package/lib/{trainingPlans.js → trainingPlans.ts} +96 -59
- package/lib/{trainingPlansProficiencyLevels.js → trainingPlansProficiencyLevels.ts} +29 -23
- package/lib/{userInformation.js → userInformation.ts} +25 -12
- package/lib/{users.js → users.ts} +172 -154
- package/lib/{utils.js → utils.ts} +6 -6
- package/package.json +8 -6
- package/exports.js +0 -85
- package/index.js +0 -1
- package/lib/axiosClient.js +0 -82
- package/lib/skillAssessmentTestingSession.js +0 -147
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import { client } from "./axiosClient.js";
|
|
2
2
|
|
|
3
|
+
interface Activity {
|
|
4
|
+
// Define the structure of an activity object here
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Filter {
|
|
8
|
+
// Define the structure of a filter object here
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
/**
|
|
4
12
|
* Create department training plan and set information
|
|
5
13
|
* @param {String} name
|
|
6
14
|
* @param {String} summary
|
|
7
|
-
* @param {
|
|
15
|
+
* @param {String} skill
|
|
16
|
+
* @param {Array<Activity>} activities
|
|
8
17
|
* @param {String} token Authorization token
|
|
18
|
+
* @returns {Promise<Object>}
|
|
9
19
|
*/
|
|
10
20
|
const createDepartmentTrainingPlan = (
|
|
11
|
-
name,
|
|
12
|
-
summary,
|
|
13
|
-
skill,
|
|
14
|
-
activities,
|
|
15
|
-
token
|
|
16
|
-
) => {
|
|
17
|
-
return new Promise(
|
|
21
|
+
name: string,
|
|
22
|
+
summary: string,
|
|
23
|
+
skill: string,
|
|
24
|
+
activities: Activity[],
|
|
25
|
+
token: string
|
|
26
|
+
): Promise<object> => {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
18
28
|
const requestData = {
|
|
19
29
|
name: name || "",
|
|
20
30
|
summary: summary || "",
|
|
@@ -42,12 +52,15 @@ const createDepartmentTrainingPlan = (
|
|
|
42
52
|
* Delete department training plan
|
|
43
53
|
* @param {String} id The id of the template to be deleted
|
|
44
54
|
* @param {String} token Authorization token
|
|
55
|
+
* @returns {Promise<Object>}
|
|
45
56
|
*/
|
|
46
|
-
const deleteDepartmentTrainingPlan = (
|
|
47
|
-
|
|
57
|
+
const deleteDepartmentTrainingPlan = (
|
|
58
|
+
id: string,
|
|
59
|
+
token: string
|
|
60
|
+
): Promise<object> => {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
48
62
|
const request = client.delete(`api/v1/departmenttrainingplans/`, {
|
|
49
63
|
headers: { authorization: token },
|
|
50
|
-
|
|
51
64
|
data: {
|
|
52
65
|
id: id,
|
|
53
66
|
},
|
|
@@ -63,12 +76,18 @@ const deleteDepartmentTrainingPlan = (id, token) => {
|
|
|
63
76
|
};
|
|
64
77
|
|
|
65
78
|
/**
|
|
66
|
-
* Get department
|
|
79
|
+
* Get department training plan information
|
|
67
80
|
* @param {Number} id The id of the plan
|
|
81
|
+
* @param {String} version The version of the plan
|
|
68
82
|
* @param {String} token Authorization token
|
|
83
|
+
* @returns {Promise<Object>}
|
|
69
84
|
*/
|
|
70
|
-
const getDepartmentTrainingPlanInformationById = (
|
|
71
|
-
|
|
85
|
+
const getDepartmentTrainingPlanInformationById = (
|
|
86
|
+
id: number,
|
|
87
|
+
version: string,
|
|
88
|
+
token: string
|
|
89
|
+
): Promise<object> => {
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
72
91
|
let confirmationRequest = client.get(
|
|
73
92
|
`api/v1/departmenttrainingplans/${id}/${version}`,
|
|
74
93
|
{
|
|
@@ -87,11 +106,17 @@ const getDepartmentTrainingPlanInformationById = (id, version, token) => {
|
|
|
87
106
|
|
|
88
107
|
/**
|
|
89
108
|
* Get department training plan list
|
|
90
|
-
* @param {
|
|
109
|
+
* @param {Filter} filter The filter used to select the plan
|
|
110
|
+
* @param {String} version The version of the plan
|
|
91
111
|
* @param {String} token Authorization token
|
|
112
|
+
* @returns {Promise<Object>}
|
|
92
113
|
*/
|
|
93
|
-
const getDepartmentTrainingPlanList = (
|
|
94
|
-
|
|
114
|
+
const getDepartmentTrainingPlanList = (
|
|
115
|
+
filter: Filter,
|
|
116
|
+
version: string,
|
|
117
|
+
token: string
|
|
118
|
+
): Promise<object> => {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
95
120
|
const requestData = {
|
|
96
121
|
filter: filter || "",
|
|
97
122
|
version: version,
|
|
@@ -117,9 +142,13 @@ const getDepartmentTrainingPlanList = (filter, version, token) => {
|
|
|
117
142
|
* Publish department training plan
|
|
118
143
|
* @param {number} id The id of the plan to be published
|
|
119
144
|
* @param {String} token Authorization token
|
|
145
|
+
* @returns {Promise<Object>}
|
|
120
146
|
*/
|
|
121
|
-
const publishDepartmentTrainingPlan = (
|
|
122
|
-
|
|
147
|
+
const publishDepartmentTrainingPlan = (
|
|
148
|
+
id: number,
|
|
149
|
+
token: string
|
|
150
|
+
): Promise<object> => {
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
123
152
|
let confirmationRequest = client.post(
|
|
124
153
|
`api/v1/departmenttrainingplans/publish/${id}`,
|
|
125
154
|
{},
|
|
@@ -142,9 +171,14 @@ const publishDepartmentTrainingPlan = (id, token) => {
|
|
|
142
171
|
* @param {String} id The id of the plan to be updated
|
|
143
172
|
* @param {Object} data Data used to update the plan
|
|
144
173
|
* @param {String} token Authorization token
|
|
174
|
+
* @returns {Promise<Object>}
|
|
145
175
|
*/
|
|
146
|
-
const setDepartmentTrainingPlanInformation = (
|
|
147
|
-
|
|
176
|
+
const setDepartmentTrainingPlanInformation = (
|
|
177
|
+
id: string,
|
|
178
|
+
data: object,
|
|
179
|
+
token: string
|
|
180
|
+
): Promise<object> => {
|
|
181
|
+
return new Promise((resolve, reject) => {
|
|
148
182
|
const requestData = {
|
|
149
183
|
data: data,
|
|
150
184
|
};
|
|
@@ -165,7 +199,7 @@ const setDepartmentTrainingPlanInformation = (id, data, token) => {
|
|
|
165
199
|
});
|
|
166
200
|
};
|
|
167
201
|
|
|
168
|
-
const
|
|
202
|
+
const departmentTrainingPlans = {
|
|
169
203
|
createDepartmentTrainingPlan,
|
|
170
204
|
deleteDepartmentTrainingPlan,
|
|
171
205
|
getDepartmentTrainingPlanInformationById,
|
|
@@ -174,4 +208,4 @@ const departmentTraingPlans = {
|
|
|
174
208
|
setDepartmentTrainingPlanInformation,
|
|
175
209
|
};
|
|
176
210
|
|
|
177
|
-
export default
|
|
211
|
+
export default departmentTrainingPlans;
|
|
@@ -5,9 +5,14 @@ import { client } from "./axiosClient.js";
|
|
|
5
5
|
* @param {String} groupId The group Id
|
|
6
6
|
* @param {Array<String>} permissions The permissions to be added
|
|
7
7
|
* @param {String} authToken - Authentication token
|
|
8
|
+
* @returns {Promise<Object>}
|
|
8
9
|
*/
|
|
9
|
-
const addPermissionsToGroup = (
|
|
10
|
-
|
|
10
|
+
const addPermissionsToGroup = (
|
|
11
|
+
groupId: string,
|
|
12
|
+
permissions: string[],
|
|
13
|
+
authToken: string
|
|
14
|
+
): Promise<object> => {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
11
16
|
const request = client.post(
|
|
12
17
|
`api/v1/groups/permissions/add`,
|
|
13
18
|
{
|
|
@@ -31,9 +36,14 @@ const addPermissionsToGroup = (groupId, permissions, authToken) => {
|
|
|
31
36
|
* @param {String} groupId The group Id
|
|
32
37
|
* @param {Array<String>} users The users to be added
|
|
33
38
|
* @param {String} authToken - Authentication token
|
|
39
|
+
* @returns {Promise<Object>}
|
|
34
40
|
*/
|
|
35
|
-
const addUsersToGroup = (
|
|
36
|
-
|
|
41
|
+
const addUsersToGroup = (
|
|
42
|
+
groupId: string,
|
|
43
|
+
users: string[],
|
|
44
|
+
authToken: string
|
|
45
|
+
): Promise<object> => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
37
47
|
const request = client.post(
|
|
38
48
|
`api/v1/groups/users/add`,
|
|
39
49
|
{
|
|
@@ -57,9 +67,14 @@ const addUsersToGroup = (groupId, users, authToken) => {
|
|
|
57
67
|
* @param {String} name The name of the group
|
|
58
68
|
* @param {String} description The description of the group
|
|
59
69
|
* @param {String} authToken The authorization token
|
|
70
|
+
* @returns {Promise<Object>}
|
|
60
71
|
*/
|
|
61
|
-
const createGroup = (
|
|
62
|
-
|
|
72
|
+
const createGroup = (
|
|
73
|
+
name: string,
|
|
74
|
+
description: string,
|
|
75
|
+
authToken: string
|
|
76
|
+
): Promise<object> => {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
63
78
|
const request = client.post(
|
|
64
79
|
`api/v1/groups/group`,
|
|
65
80
|
{
|
|
@@ -83,9 +98,14 @@ const createGroup = (name, description, authToken) => {
|
|
|
83
98
|
* @param {String} groupId The group to be deleted
|
|
84
99
|
* @param {String} defaultGroupId The default group all the users will be moved to
|
|
85
100
|
* @param {String} authToken The authentication token
|
|
101
|
+
* @returns {Promise<Object>}
|
|
86
102
|
*/
|
|
87
|
-
const deleteGroup = (
|
|
88
|
-
|
|
103
|
+
const deleteGroup = (
|
|
104
|
+
groupId: string,
|
|
105
|
+
defaultGroupId: string,
|
|
106
|
+
authToken: string
|
|
107
|
+
): Promise<object> => {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
89
109
|
const request = client.delete(`api/v1/groups/delete`, {
|
|
90
110
|
headers: { authorization: authToken },
|
|
91
111
|
data: {
|
|
@@ -106,9 +126,10 @@ const deleteGroup = (groupId, defaultGroupId, authToken) => {
|
|
|
106
126
|
/**
|
|
107
127
|
* Get all permissions
|
|
108
128
|
* @param {String} authToken The authentication token
|
|
129
|
+
* @returns {Promise<Object>}
|
|
109
130
|
*/
|
|
110
|
-
const getAllPermissions = (authToken) => {
|
|
111
|
-
return new Promise(
|
|
131
|
+
const getAllPermissions = (authToken: string): Promise<object> => {
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
112
133
|
const request = client.get(`api/v1/groups/permissions/getAllPermissions`, {
|
|
113
134
|
headers: { authorization: authToken },
|
|
114
135
|
});
|
|
@@ -126,9 +147,10 @@ const getAllPermissions = (authToken) => {
|
|
|
126
147
|
* Get group by Id
|
|
127
148
|
* @param {String} groupId The group Id
|
|
128
149
|
* @param {String} authToken The authentication token
|
|
150
|
+
* @returns {Promise<Object>}
|
|
129
151
|
*/
|
|
130
|
-
const getGroupById = (groupId, authToken) => {
|
|
131
|
-
return new Promise(
|
|
152
|
+
const getGroupById = (groupId: string, authToken: string): Promise<object> => {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
132
154
|
const request = client.get(`api/v1/groups/group/${groupId}`, {
|
|
133
155
|
headers: { authorization: authToken },
|
|
134
156
|
});
|
|
@@ -145,9 +167,10 @@ const getGroupById = (groupId, authToken) => {
|
|
|
145
167
|
/**
|
|
146
168
|
* Get groups for current tenant
|
|
147
169
|
* @param {String} authToken The authentication token
|
|
170
|
+
* @returns {Promise<Object>}
|
|
148
171
|
*/
|
|
149
|
-
const getGroups = (authToken) => {
|
|
150
|
-
return new Promise(
|
|
172
|
+
const getGroups = (authToken: string): Promise<object> => {
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
151
174
|
const request = client.get(`api/v1/groups/`, {
|
|
152
175
|
headers: { authorization: authToken },
|
|
153
176
|
});
|
|
@@ -164,9 +187,10 @@ const getGroups = (authToken) => {
|
|
|
164
187
|
/**
|
|
165
188
|
* Get current user permissions
|
|
166
189
|
* @param {String} authToken The authentication token
|
|
190
|
+
* @returns {Promise<Object>}
|
|
167
191
|
*/
|
|
168
|
-
const getUserPermissions = (authToken) => {
|
|
169
|
-
return new Promise(
|
|
192
|
+
const getUserPermissions = (authToken: string): Promise<object> => {
|
|
193
|
+
return new Promise((resolve, reject) => {
|
|
170
194
|
const request = client.get(`api/v1/groups/users/getuserpermissions`, {
|
|
171
195
|
headers: { authorization: authToken },
|
|
172
196
|
});
|
|
@@ -185,9 +209,14 @@ const getUserPermissions = (authToken) => {
|
|
|
185
209
|
* @param {String} groupId The group Id
|
|
186
210
|
* @param {Array<String>} permissions The permissions to be removed from the group
|
|
187
211
|
* @param {String} authToken The authentication token
|
|
212
|
+
* @returns {Promise<Object>}
|
|
188
213
|
*/
|
|
189
|
-
const removePermissionsFromGroup = (
|
|
190
|
-
|
|
214
|
+
const removePermissionsFromGroup = (
|
|
215
|
+
groupId: string,
|
|
216
|
+
permissions: string[],
|
|
217
|
+
authToken: string
|
|
218
|
+
): Promise<object> => {
|
|
219
|
+
return new Promise((resolve, reject) => {
|
|
191
220
|
const request = client.post(
|
|
192
221
|
`api/v1/groups/permissions/remove/`,
|
|
193
222
|
{
|
|
@@ -211,9 +240,14 @@ const removePermissionsFromGroup = (groupId, permissions, authToken) => {
|
|
|
211
240
|
* @param {String} groupId The group Id
|
|
212
241
|
* @param {Array<String>} users The users to be removed from the group
|
|
213
242
|
* @param {String} authToken The authentication token
|
|
243
|
+
* @returns {Promise<Object>}
|
|
214
244
|
*/
|
|
215
|
-
const removeUsersFromGroup = (
|
|
216
|
-
|
|
245
|
+
const removeUsersFromGroup = (
|
|
246
|
+
groupId: string,
|
|
247
|
+
users: string[],
|
|
248
|
+
authToken: string
|
|
249
|
+
): Promise<object> => {
|
|
250
|
+
return new Promise((resolve, reject) => {
|
|
217
251
|
const request = client.post(
|
|
218
252
|
`api/v1/groups/users/remove/`,
|
|
219
253
|
{
|
|
@@ -232,13 +266,14 @@ const removeUsersFromGroup = (groupId, users, authToken) => {
|
|
|
232
266
|
});
|
|
233
267
|
};
|
|
234
268
|
|
|
235
|
-
|
|
236
|
-
* Set group as
|
|
269
|
+
/**
|
|
270
|
+
* Set group as default
|
|
237
271
|
* @param {String} groupId The group Id
|
|
238
272
|
* @param {String} authToken The authentication token
|
|
273
|
+
* @returns {Promise<Object>}
|
|
239
274
|
*/
|
|
240
|
-
const setDefault = (groupId, authToken) => {
|
|
241
|
-
return new Promise(
|
|
275
|
+
const setDefault = (groupId: string, authToken: string): Promise<object> => {
|
|
276
|
+
return new Promise((resolve, reject) => {
|
|
242
277
|
const request = client.put(
|
|
243
278
|
`api/v1/groups/setDefault/`,
|
|
244
279
|
{
|
|
@@ -262,9 +297,15 @@ const setDefault = (groupId, authToken) => {
|
|
|
262
297
|
* @param {String} name The updated name of the group
|
|
263
298
|
* @param {String} description The updated description of the group
|
|
264
299
|
* @param {String} authToken The authentication token
|
|
300
|
+
* @returns {Promise<Object>}
|
|
265
301
|
*/
|
|
266
|
-
const updateGroup = (
|
|
267
|
-
|
|
302
|
+
const updateGroup = (
|
|
303
|
+
groupId: string,
|
|
304
|
+
name: string,
|
|
305
|
+
description: string,
|
|
306
|
+
authToken: string
|
|
307
|
+
): Promise<object> => {
|
|
308
|
+
return new Promise((resolve, reject) => {
|
|
268
309
|
const request = client.patch(
|
|
269
310
|
`api/v1/groups/group/`,
|
|
270
311
|
{
|
|
@@ -3,14 +3,42 @@ import axiosLib from "axios";
|
|
|
3
3
|
import htmlParser from "node-html-parser";
|
|
4
4
|
import htmlToText from "html2plaintext";
|
|
5
5
|
|
|
6
|
+
interface IntegrationData {
|
|
7
|
+
data: object;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface IntegrationFilter {
|
|
11
|
+
filter?: string[];
|
|
12
|
+
type?: string;
|
|
13
|
+
version: string;
|
|
14
|
+
includeSupportedCapabilities: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ContentInformation {
|
|
18
|
+
url: string;
|
|
19
|
+
verb: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ContentInformationResponse {
|
|
23
|
+
description: string;
|
|
24
|
+
duration: number;
|
|
25
|
+
icon: string;
|
|
26
|
+
title: string;
|
|
27
|
+
type: number;
|
|
28
|
+
internal: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
6
31
|
/**
|
|
7
32
|
* Create integration and set information
|
|
8
33
|
* @param {Object} data The new integration information
|
|
9
34
|
* @param {String} token Authorization token
|
|
10
35
|
*/
|
|
11
|
-
export const createIntegration = (
|
|
12
|
-
|
|
13
|
-
|
|
36
|
+
export const createIntegration = (
|
|
37
|
+
data: object,
|
|
38
|
+
token: string
|
|
39
|
+
): Promise<object> => {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const requestData: IntegrationData = {
|
|
14
42
|
data: data,
|
|
15
43
|
};
|
|
16
44
|
let confirmationRequest = client.put("api/v1/integrations/", requestData, {
|
|
@@ -31,8 +59,11 @@ export const createIntegration = (data, token) => {
|
|
|
31
59
|
* @param {String} id The id of the integration to be deleted
|
|
32
60
|
* @param {String} token Authorization token
|
|
33
61
|
*/
|
|
34
|
-
export const deleteIntegration = (
|
|
35
|
-
|
|
62
|
+
export const deleteIntegration = (
|
|
63
|
+
id: string,
|
|
64
|
+
token: string
|
|
65
|
+
): Promise<object> => {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
36
67
|
const request = client.delete(`api/v1/integrations/`, {
|
|
37
68
|
headers: { authorization: token },
|
|
38
69
|
data: {
|
|
@@ -54,8 +85,11 @@ export const deleteIntegration = (id, token) => {
|
|
|
54
85
|
* @param {String} id The id of the role template to be deleted
|
|
55
86
|
* @param {String} token Authorization token
|
|
56
87
|
*/
|
|
57
|
-
export const discardIntegrationChanges = (
|
|
58
|
-
|
|
88
|
+
export const discardIntegrationChanges = (
|
|
89
|
+
id: string,
|
|
90
|
+
token: string
|
|
91
|
+
): Promise<object> => {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
59
93
|
const data = {};
|
|
60
94
|
const request = client.get(`api/v1/integrations/discard/${id}`, {
|
|
61
95
|
headers: { authorization: token },
|
|
@@ -77,8 +111,12 @@ export const discardIntegrationChanges = (id, token) => {
|
|
|
77
111
|
* @param {String} version The version of the integration to be received
|
|
78
112
|
* @param {String} token Authorization token
|
|
79
113
|
*/
|
|
80
|
-
export const getIntegrationInformationById = (
|
|
81
|
-
|
|
114
|
+
export const getIntegrationInformationById = (
|
|
115
|
+
id: string,
|
|
116
|
+
version: string,
|
|
117
|
+
token: string
|
|
118
|
+
): Promise<object> => {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
82
120
|
let confirmationRequest = client.get(
|
|
83
121
|
`api/v1/integrations/${id}/${version}`,
|
|
84
122
|
{
|
|
@@ -104,14 +142,14 @@ export const getIntegrationInformationById = (id, version, token) => {
|
|
|
104
142
|
* @param {String} token Authorization token
|
|
105
143
|
*/
|
|
106
144
|
export const getIntegrationsList = (
|
|
107
|
-
filter,
|
|
108
|
-
type,
|
|
109
|
-
version,
|
|
110
|
-
includeSupportedCapabilities,
|
|
111
|
-
token
|
|
112
|
-
) => {
|
|
113
|
-
return new Promise(
|
|
114
|
-
const requestData = {
|
|
145
|
+
filter: string[],
|
|
146
|
+
type: string,
|
|
147
|
+
version: string,
|
|
148
|
+
includeSupportedCapabilities: boolean,
|
|
149
|
+
token: string
|
|
150
|
+
): Promise<object> => {
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
const requestData: IntegrationFilter = {
|
|
115
153
|
includeSupportedCapabilities: includeSupportedCapabilities,
|
|
116
154
|
version: version,
|
|
117
155
|
};
|
|
@@ -136,9 +174,13 @@ export const getIntegrationsList = (
|
|
|
136
174
|
* @param {String} verb The verb
|
|
137
175
|
* @param {String} token Authorization token
|
|
138
176
|
*/
|
|
139
|
-
export const getContentInformationByUrl = (
|
|
140
|
-
|
|
141
|
-
|
|
177
|
+
export const getContentInformationByUrl = (
|
|
178
|
+
url: string,
|
|
179
|
+
verb: string,
|
|
180
|
+
token: string
|
|
181
|
+
): Promise<object> => {
|
|
182
|
+
return new Promise((resolve, reject) => {
|
|
183
|
+
const requestData: ContentInformation = {
|
|
142
184
|
url: url,
|
|
143
185
|
verb: verb,
|
|
144
186
|
};
|
|
@@ -162,10 +204,12 @@ export const getContentInformationByUrl = (url, verb, token) => {
|
|
|
162
204
|
/**
|
|
163
205
|
* Get content information by url from the browser instead of the backend
|
|
164
206
|
* @param {String} url
|
|
165
|
-
* @returns {
|
|
207
|
+
* @returns {Promise<ContentInformationResponse>}
|
|
166
208
|
*/
|
|
167
|
-
export const getContentInformationByUrlFromBrowser = (
|
|
168
|
-
|
|
209
|
+
export const getContentInformationByUrlFromBrowser = (
|
|
210
|
+
url: string
|
|
211
|
+
): Promise<ContentInformationResponse> => {
|
|
212
|
+
return new Promise((resolve, reject) => {
|
|
169
213
|
let domain = new URL(url);
|
|
170
214
|
let instance = axiosLib.create({
|
|
171
215
|
baseURL: domain.origin,
|
|
@@ -175,7 +219,7 @@ export const getContentInformationByUrlFromBrowser = (url) => {
|
|
|
175
219
|
"Access-Control-Allow-Origin": "*",
|
|
176
220
|
"Access-Control-Allow-Headers":
|
|
177
221
|
"Authorization, Origin, X-Requested-With, Content-Type, Accept",
|
|
178
|
-
|
|
222
|
+
Accept:
|
|
179
223
|
"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
224
|
"Accept-Encoding": "gzip, deflate, br",
|
|
181
225
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
@@ -185,14 +229,14 @@ export const getContentInformationByUrlFromBrowser = (url) => {
|
|
|
185
229
|
confirmationRequest
|
|
186
230
|
.then((response) => {
|
|
187
231
|
//get the reading time
|
|
188
|
-
const getReadingTime = (text) => {
|
|
232
|
+
const getReadingTime = (text: string): number => {
|
|
189
233
|
const wpm = 225;
|
|
190
234
|
const words = text.trim().split(/\s+/).length;
|
|
191
235
|
return Math.ceil(words / wpm);
|
|
192
236
|
};
|
|
193
237
|
|
|
194
|
-
let document = htmlParser.parse(response.
|
|
195
|
-
let duration = getReadingTime(htmlToText(response.
|
|
238
|
+
let document = htmlParser.parse(response.data);
|
|
239
|
+
let duration = getReadingTime(htmlToText(response.data));
|
|
196
240
|
let titleTag = document.querySelector("title");
|
|
197
241
|
let title = titleTag ? titleTag.rawText : "";
|
|
198
242
|
let description = "";
|
|
@@ -204,13 +248,14 @@ export const getContentInformationByUrlFromBrowser = (url) => {
|
|
|
204
248
|
const descriptionChildNodes = descriptionParentNode.childNodes;
|
|
205
249
|
if (descriptionChildNodes) {
|
|
206
250
|
const descriptionRawAttr = descriptionChildNodes.find((item) =>
|
|
207
|
-
item.rawAttrs.includes("description")
|
|
251
|
+
(item as any).rawAttrs.includes("description")
|
|
208
252
|
);
|
|
209
253
|
if (descriptionRawAttr) {
|
|
210
|
-
const descriptionContent =
|
|
211
|
-
descriptionRawAttr
|
|
212
|
-
|
|
213
|
-
)
|
|
254
|
+
const descriptionContent = (
|
|
255
|
+
descriptionRawAttr as any
|
|
256
|
+
).rawAttrs.substring(
|
|
257
|
+
(descriptionRawAttr as any).rawAttrs.indexOf("content=") + 9
|
|
258
|
+
);
|
|
214
259
|
description = descriptionContent.substring(
|
|
215
260
|
0,
|
|
216
261
|
descriptionContent.length - 1
|
|
@@ -238,12 +283,14 @@ export const getContentInformationByUrlFromBrowser = (url) => {
|
|
|
238
283
|
|
|
239
284
|
/**
|
|
240
285
|
* Get enabled content providers
|
|
241
|
-
* @param {String}
|
|
242
|
-
* @param {String} verb The verb
|
|
286
|
+
* @param {String} userId
|
|
243
287
|
* @param {String} token Authorization token
|
|
244
288
|
*/
|
|
245
|
-
export const getEnabledContentProviders = (
|
|
246
|
-
|
|
289
|
+
export const getEnabledContentProviders = (
|
|
290
|
+
userId: string,
|
|
291
|
+
token: string
|
|
292
|
+
): Promise<object> => {
|
|
293
|
+
return new Promise((resolve, reject) => {
|
|
247
294
|
let confirmationRequest = client.get(
|
|
248
295
|
`api/v1/contentproviders/getenabledcontentproviders/${userId}`,
|
|
249
296
|
{
|
|
@@ -265,8 +312,11 @@ export const getEnabledContentProviders = (userId, token) => {
|
|
|
265
312
|
* @param {String} id The id of the integration to be published
|
|
266
313
|
* @param {String} token Authorization token
|
|
267
314
|
*/
|
|
268
|
-
export const publishIntegration = (
|
|
269
|
-
|
|
315
|
+
export const publishIntegration = (
|
|
316
|
+
id: string,
|
|
317
|
+
token: string
|
|
318
|
+
): Promise<object> => {
|
|
319
|
+
return new Promise((resolve, reject) => {
|
|
270
320
|
let confirmationRequest = client.post(
|
|
271
321
|
`api/v1/integrations/publish/${id}`,
|
|
272
322
|
{},
|
|
@@ -290,9 +340,13 @@ export const publishIntegration = (id, token) => {
|
|
|
290
340
|
* @param {Object} data Data used to update the integration
|
|
291
341
|
* @param {String} token Authorization token
|
|
292
342
|
*/
|
|
293
|
-
export const setIntegrationInformation = (
|
|
294
|
-
|
|
295
|
-
|
|
343
|
+
export const setIntegrationInformation = (
|
|
344
|
+
id: string,
|
|
345
|
+
data: object,
|
|
346
|
+
token: string
|
|
347
|
+
): Promise<object> => {
|
|
348
|
+
return new Promise((resolve, reject) => {
|
|
349
|
+
const requestData: IntegrationData = {
|
|
296
350
|
data: data,
|
|
297
351
|
};
|
|
298
352
|
let confirmationRequest = client.post(
|
|
@@ -317,8 +371,11 @@ export const setIntegrationInformation = (id, data, token) => {
|
|
|
317
371
|
* @param {String} id The id of the integration to be set as default
|
|
318
372
|
* @param {String} token Authorization token
|
|
319
373
|
*/
|
|
320
|
-
export const setDefaultIntegration = (
|
|
321
|
-
|
|
374
|
+
export const setDefaultIntegration = (
|
|
375
|
+
id: string,
|
|
376
|
+
token: string
|
|
377
|
+
): Promise<object> => {
|
|
378
|
+
return new Promise((resolve, reject) => {
|
|
322
379
|
let confirmationRequest = client.post(
|
|
323
380
|
`api/v1/integrations/${id}/default`,
|
|
324
381
|
"",
|
|
@@ -5,10 +5,15 @@ import { client } from "./axiosClient.js";
|
|
|
5
5
|
* @param {Array<String>} ids
|
|
6
6
|
* @param {Number} type
|
|
7
7
|
* @param {String} token Authorization token
|
|
8
|
+
* @returns {Promise<Object>}
|
|
8
9
|
*/
|
|
9
|
-
const getIntegrationsConfiguration = (
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const getIntegrationsConfiguration = (
|
|
11
|
+
ids: string[],
|
|
12
|
+
type: number,
|
|
13
|
+
token: string
|
|
14
|
+
): Promise<object> => {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
let requestData: { type: number; ids?: string[] } = { type: type };
|
|
12
17
|
if (ids) requestData.ids = ids;
|
|
13
18
|
let confirmationRequest = client.post(
|
|
14
19
|
"api/v1/integrationsconfiguration",
|
|
@@ -29,13 +34,19 @@ const getIntegrationsConfiguration = (ids, type, token) => {
|
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
36
|
* Save integration configuration
|
|
32
|
-
* @param {String} id The id of the integration
|
|
37
|
+
* @param {String} id The id of the integration configuration to be updated
|
|
33
38
|
* @param {Number} type The type of configuration
|
|
34
39
|
* @param {Object} configuration Data used to update the integration configuration
|
|
35
40
|
* @param {String} token Authorization token
|
|
41
|
+
* @returns {Promise<Object>}
|
|
36
42
|
*/
|
|
37
|
-
const saveIntegrationConfiguration = (
|
|
38
|
-
|
|
43
|
+
const saveIntegrationConfiguration = (
|
|
44
|
+
id: string,
|
|
45
|
+
type: number,
|
|
46
|
+
configuration: object,
|
|
47
|
+
token: string
|
|
48
|
+
): Promise<object> => {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
39
50
|
const requestData = {
|
|
40
51
|
id: id,
|
|
41
52
|
configuration: configuration,
|
|
@@ -64,9 +75,15 @@ const saveIntegrationConfiguration = (id, type, configuration, token) => {
|
|
|
64
75
|
* @param {String} type The type of configuration
|
|
65
76
|
* @param {Object} configuration Configuration to be tested
|
|
66
77
|
* @param {String} token Authorization token
|
|
78
|
+
* @returns {Promise<Object>}
|
|
67
79
|
*/
|
|
68
|
-
const testIntegrationConfiguration = (
|
|
69
|
-
|
|
80
|
+
const testIntegrationConfiguration = (
|
|
81
|
+
id: string,
|
|
82
|
+
type: string,
|
|
83
|
+
configuration: object,
|
|
84
|
+
token: string
|
|
85
|
+
): Promise<object> => {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
70
87
|
const requestData = {
|
|
71
88
|
id: id,
|
|
72
89
|
configuration: configuration,
|