@stackfactor/client-api 1.0.40 → 1.0.42

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/index.js CHANGED
@@ -1,32 +1,32 @@
1
- import actionNotifications from "./lib/actionNotifications";
1
+ import actionNotifications from "./lib/actionNotifications.js";
2
2
  import axios, {
3
3
  errorToString,
4
4
  getErrorType,
5
5
  shouldReturnError,
6
- } from "./lib/axiosClient";
7
- import address from "./lib/address";
8
- import config from "./lib/config";
9
- import constants from "./lib/constants";
10
- import contentGenerator from "./lib/integrations/contentGenerator";
11
- import dashboard from "./lib/dashboard";
12
- import departmentTraingPlans from "./lib/departmentTrainingPlans";
13
- import integration from "./lib/integration";
14
- import integrationConfiguration from "./lib/integrationConfiguration";
15
- import groups from "./lib/groups";
16
- import learningContent from "./lib/learningContent";
17
- import logger from "./lib/logger";
18
- import role from "./lib/role";
19
- import roleTemplate from "./lib/roleTemplate";
20
- import skill from "./lib/skill";
21
- import skillAssessment from "./lib/skillAssessments";
22
- import skillAssessmentTestingSession from "./lib/skillAssessmentTestingSession";
23
- import skillTemplate from "./lib/skillTemplate";
24
- import team from "./lib/teams";
25
- import tenant from "./lib/tenants";
26
- import trainingPlanTemplate from "./lib/trainingPlanTemplate";
27
- import trainingPlan from "./lib/trainingPlans";
28
- import userInformation from "./lib/userInformation";
29
- import users from "./lib/users";
6
+ } from "./lib/axiosClient.js";
7
+ import address from "./lib/address.js";
8
+ import config from "./lib/config.js";
9
+ import constants from "./lib/constants.js";
10
+ import contentGenerator from "./lib/integrations/contentGenerator.js";
11
+ import dashboard from "./lib/dashboard.js";
12
+ import departmentTraingPlans from "./lib/departmentTrainingPlans.js";
13
+ import integration from "./lib/integration.js";
14
+ import integrationConfiguration from "./lib/integrationConfiguration.js";
15
+ import groups from "./lib/groups.js";
16
+ import learningContent from "./lib/learningContent.js";
17
+ import logger from "./lib/logger.js";
18
+ import role from "./lib/role.js";
19
+ import roleTemplate from "./lib/roleTemplate.js";
20
+ import skill from "./lib/skill.js";
21
+ import skillAssessment from "./lib/skillAssessments.js";
22
+ import skillAssessmentTestingSession from "./lib/skillAssessmentTestingSession.js";
23
+ import skillTemplate from "./lib/skillTemplate.js";
24
+ import team from "./lib/teams.js";
25
+ import tenant from "./lib/tenants.js";
26
+ import trainingPlanTemplate from "./lib/trainingPlanTemplate.js";
27
+ import trainingPlan from "./lib/trainingPlans.js";
28
+ import userInformation from "./lib/userInformation.js";
29
+ import users from "./lib/users.js";
30
30
 
31
31
  export default {
32
32
  actionNotifications: actionNotifications,
@@ -1,4 +1,4 @@
1
- import axios from "./axiosClient";
1
+ import { client } from "./axiosClient";
2
2
 
3
3
  /**
4
4
  * Get all permissions
@@ -6,7 +6,7 @@ import axios from "./axiosClient";
6
6
  */
7
7
  export const getAllUserNotifications = (authToken) => {
8
8
  return new Promise(function (resolve, reject) {
9
- const request = axios.get(`api/v1/actionnotifications`, {
9
+ const request = client.get(`api/v1/actionnotifications`, {
10
10
  headers: { authorization: authToken },
11
11
  });
12
12
  request
@@ -27,7 +27,7 @@ export const getAllUserNotifications = (authToken) => {
27
27
  */
28
28
  export const markNotifications = (ids, status, authToken) => {
29
29
  return new Promise(function (resolve, reject) {
30
- const request = axios.put(
30
+ const request = client.put(
31
31
  `api/v1/actionnotifications/mark`,
32
32
  {
33
33
  ids: ids,
@@ -54,7 +54,7 @@ export const markNotifications = (ids, status, authToken) => {
54
54
  */
55
55
  export const processNotification = (id, action, comment, authToken) => {
56
56
  return new Promise(function (resolve, reject) {
57
- const request = axios.put(
57
+ const request = client.put(
58
58
  `api/v1/actionnotifications/process`,
59
59
  {
60
60
  id: id,
@@ -73,144 +73,8 @@ export const processNotification = (id, action, comment, authToken) => {
73
73
  });
74
74
  };
75
75
 
76
- /**
77
- * Get groups for current tenant
78
- * @param {String} authToken The authentication token
79
- */
80
- export const getGroups = (authToken) => {
81
- return new Promise(function (resolve, reject) {
82
- const request = axios.get(`api/v1/groups/`, {
83
- headers: { authorization: authToken },
84
- });
85
- request
86
- .then((response) => {
87
- resolve(response.data);
88
- })
89
- .catch((error) => {
90
- reject(error);
91
- });
92
- });
93
- };
94
-
95
- /**
96
- * Get current user permissions
97
- * @param {String} authToken The authentication token
98
- */
99
- export const getUserPermissions = (authToken) => {
100
- return new Promise(function (resolve, reject) {
101
- const request = axios.get(`api/v1/groups/users/getuserpermissions`, {
102
- headers: { authorization: authToken },
103
- });
104
- request
105
- .then((response) => {
106
- resolve(response.data);
107
- })
108
- .catch((error) => {
109
- reject(error);
110
- });
111
- });
112
- };
113
-
114
- /**
115
- * Remove permissions from group
116
- * @param {String} groupId The group Id
117
- * @param {Array<String>} permissions The permissions to be removed from the group
118
- * @param {String} authToken The authentication token
119
- */
120
- export const removePermissionsFromGroup = (groupId, permissions, authToken) => {
121
- return new Promise(function (resolve, reject) {
122
- const request = axios.post(
123
- `api/v1/groups/permissions/remove/`,
124
- {
125
- groupId: groupId,
126
- permissions: permissions,
127
- },
128
- { headers: { authorization: authToken } }
129
- );
130
- request
131
- .then((response) => {
132
- resolve(response.data);
133
- })
134
- .catch((error) => {
135
- reject(error);
136
- });
137
- });
138
- };
139
-
140
- /**
141
- * Remove users from group
142
- * @param {String} groupId The group Id
143
- * @param {Array<String>} users The users to be removed from the group
144
- * @param {String} authToken The authentication token
145
- */
146
- export const removeUsersFromGroup = (groupId, users, authToken) => {
147
- return new Promise(function (resolve, reject) {
148
- const request = axios.post(
149
- `api/v1/groups/users/remove/`,
150
- {
151
- groupId: groupId,
152
- users: users,
153
- },
154
- { headers: { authorization: authToken } }
155
- );
156
- request
157
- .then((response) => {
158
- resolve(response.data);
159
- })
160
- .catch((error) => {
161
- reject(error);
162
- });
163
- });
164
- };
165
-
166
- /*
167
- * Set group as defualt
168
- * @param {String} groupId The group Id
169
- * @param {String} authToken The authentication token
170
- */
171
- export const setDefault = (groupId, authToken) => {
172
- return new Promise(function (resolve, reject) {
173
- const request = axios.put(
174
- `api/v1/groups/setDefault/`,
175
- {
176
- id: groupId,
177
- },
178
- { headers: { authorization: authToken } }
179
- );
180
- request
181
- .then((response) => {
182
- resolve(response.data);
183
- })
184
- .catch((error) => {
185
- reject(error);
186
- });
187
- });
188
- };
189
-
190
- /**
191
- * Update group
192
- * @param {String} groupId The group Id
193
- * @param {string} name The updated name of the group
194
- * @param {string} description The updated description of the group
195
- * @param {String} authToken The authentication token
196
- */
197
- export const updateGroup = (groupId, name, description, authToken) => {
198
- return new Promise(function (resolve, reject) {
199
- const request = axios.patch(
200
- `api/v1/groups/group/`,
201
- {
202
- id: groupId,
203
- name: name,
204
- description: description,
205
- },
206
- { headers: { authorization: authToken } }
207
- );
208
- request
209
- .then((response) => {
210
- resolve(response.data);
211
- })
212
- .catch((error) => {
213
- reject(error);
214
- });
215
- });
76
+ export default {
77
+ getAllUserNotifications,
78
+ markNotifications,
79
+ processNotification,
216
80
  };
package/lib/address.js CHANGED
@@ -1,4 +1,4 @@
1
- import axios from "./axiosClient";
1
+ import { client } from "./axiosClient";
2
2
 
3
3
  /**
4
4
  * Validate Address
@@ -7,7 +7,7 @@ import axios from "./axiosClient";
7
7
  */
8
8
  export const autoComplete = (input, authToken) => {
9
9
  return new Promise(function (resolve, reject) {
10
- const getAddressesRequest = axios.post(
10
+ const getAddressesRequest = client.post(
11
11
  `api/v1/address/autocomplete/`,
12
12
  { input: input },
13
13
  { headers: { authorization: authToken } }
@@ -21,3 +21,7 @@ export const autoComplete = (input, authToken) => {
21
21
  });
22
22
  });
23
23
  };
24
+
25
+ export default {
26
+ autoComplete: autoComplete,
27
+ };
@@ -1,10 +1,10 @@
1
- import client from "axios";
1
+ import axios from "axios";
2
2
  import https from "https";
3
3
  import utils from "./utils";
4
4
 
5
5
  const baseUrl = utils.getBaseUrl();
6
6
 
7
- export default client.create({
7
+ export const client = axios.create({
8
8
  baseURL: baseUrl,
9
9
  httpsAgent: new https.Agent({
10
10
  rejectUnauthorized: false,
@@ -74,3 +74,11 @@ export const shouldReturnError = (returnAllExceptions, error) => {
74
74
  return true;
75
75
  }
76
76
  };
77
+
78
+ export default {
79
+ client: client,
80
+ errorToString: errorToString,
81
+ getErrorType: getErrorType,
82
+ getErrorInformation: getErrorInformation,
83
+ shouldReturnError: shouldReturnError,
84
+ };
package/lib/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import axios from "./axiosClient";
1
+ import { client } from "./axiosClient";
2
2
 
3
3
  /**
4
4
  * Get the specified configuration by Id. It returns a promise
@@ -7,7 +7,7 @@ import axios from "./axiosClient";
7
7
  */
8
8
  export const getConfigurationById = (id, authToken) => {
9
9
  return new Promise(function (resolve, reject) {
10
- const getConfigInformationRequest = axios.get(
10
+ const getConfigInformationRequest = client.get(
11
11
  `api/v1/configurations/configuration/id/${id}`,
12
12
  { headers: { authorization: authToken } }
13
13
  );
@@ -28,7 +28,7 @@ export const getConfigurationById = (id, authToken) => {
28
28
  */
29
29
  export const getConfigurationByType = (type, authToken) => {
30
30
  return new Promise(function (resolve, reject) {
31
- const getConfigInformationRequest = axios.get(
31
+ const getConfigInformationRequest = client.get(
32
32
  `api/v1/configurations/configuration/type/${type}`,
33
33
  { headers: { authorization: authToken } }
34
34
  );
@@ -50,7 +50,7 @@ export const getConfigurationByType = (type, authToken) => {
50
50
  */
51
51
  export const setConfigurationById = (id, data, authToken) => {
52
52
  return new Promise(function (resolve, reject) {
53
- const getConfigInformationRequest = axios.post(
53
+ const getConfigInformationRequest = client.post(
54
54
  `api/v1/configurations/configuration/${id}`,
55
55
  { data: data },
56
56
  { headers: { authorization: authToken } }
@@ -64,3 +64,9 @@ export const setConfigurationById = (id, data, authToken) => {
64
64
  });
65
65
  });
66
66
  };
67
+
68
+ export default {
69
+ getConfigurationById: getConfigurationById,
70
+ getConfigurationByType: getConfigurationByType,
71
+ setConfigurationById: setConfigurationById,
72
+ };
package/lib/constants.js CHANGED
@@ -93,7 +93,7 @@ const PERMISSIONS = {
93
93
  MANAGE_PLAN_TEMPLATES: "5dd61305a73c68b44c3f0827",
94
94
  };
95
95
 
96
- module.exports = {
96
+ export default {
97
97
  DOCUMENT_VERSION: DOCUMENT_VERSION,
98
98
  PERMISSIONS: PERMISSIONS,
99
99
  RESPONSE_TYPE: RESPONSE_TYPE,
package/lib/dashboard.js CHANGED
@@ -1,4 +1,4 @@
1
- import axios from "./axiosClient";
1
+ import { client } from "./axiosClient";
2
2
 
3
3
  /**
4
4
  * Add a card to the dashboard
@@ -9,7 +9,7 @@ import axios from "./axiosClient";
9
9
  */
10
10
  export const addCardToDashboard = (id, position, data, authToken) => {
11
11
  return new Promise(function (resolve, reject) {
12
- const request = axios.put(
12
+ const request = client.put(
13
13
  `/api/v1/dashboard/card`,
14
14
  {
15
15
  id: id,
@@ -34,7 +34,7 @@ export const addCardToDashboard = (id, position, data, authToken) => {
34
34
  */
35
35
  export const getDashboardCardsList = (authToken) => {
36
36
  return new Promise(function (resolve, reject) {
37
- const request = axios.get(`/api/v1/dashboard/card`, {
37
+ const request = client.get(`/api/v1/dashboard/card`, {
38
38
  headers: { authorization: authToken },
39
39
  });
40
40
  request
@@ -54,7 +54,7 @@ export const getDashboardCardsList = (authToken) => {
54
54
  */
55
55
  export const removeCardFromDashboard = (id, authToken) => {
56
56
  return new Promise(function (resolve, reject) {
57
- const request = axios.delete(`/api/v1/dashboard/card`, {
57
+ const request = client.delete(`/api/v1/dashboard/card`, {
58
58
  headers: { authorization: authToken },
59
59
  data: {
60
60
  id: id,
@@ -69,3 +69,9 @@ export const removeCardFromDashboard = (id, authToken) => {
69
69
  });
70
70
  });
71
71
  };
72
+
73
+ export default {
74
+ addCardToDashboard: addCardToDashboard,
75
+ getDashboardCardsList: getDashboardCardsList,
76
+ removeCardFromDashboard: removeCardFromDashboard,
77
+ };
@@ -1,4 +1,4 @@
1
- import axios from "./axiosClient";
1
+ import { client } from "./axiosClient";
2
2
 
3
3
  /**
4
4
  * Create training plan template and set information
@@ -21,7 +21,7 @@ export const createDepartmentTrainingPlan = (
21
21
  skill: skill ? skill : "",
22
22
  activities: activities ? activities : [],
23
23
  };
24
- let confirmationRequest = axios.put(
24
+ let confirmationRequest = client.put(
25
25
  "api/v1/departmentTrainingPlans",
26
26
  requestData,
27
27
  {
@@ -45,7 +45,7 @@ export const createDepartmentTrainingPlan = (
45
45
  */
46
46
  export const deleteDepartmentTrainingPlan = (id, token) => {
47
47
  return new Promise(function (resolve, reject) {
48
- const request = axios.delete(`api/v1/departmenttrainingplans/`, {
48
+ const request = client.delete(`api/v1/departmenttrainingplans/`, {
49
49
  headers: { authorization: token },
50
50
  data: {
51
51
  id: id,
@@ -72,7 +72,7 @@ export const getDepartmentTrainingPlanInformationById = (
72
72
  token
73
73
  ) => {
74
74
  return new Promise(function (resolve, reject) {
75
- let confirmationRequest = axios.get(
75
+ let confirmationRequest = client.get(
76
76
  `api/v1/departmenttrainingplans/${id}/${version}`,
77
77
  {
78
78
  headers: { authorization: token },
@@ -99,7 +99,7 @@ export const getDepartmentTrainingPlanList = (filter, version, token) => {
99
99
  filter: filter ? filter : "",
100
100
  version: version,
101
101
  };
102
- let confirmationRequest = axios.post(
102
+ let confirmationRequest = client.post(
103
103
  `api/v1/departmenttrainingplans`,
104
104
  requestData,
105
105
  {
@@ -123,7 +123,7 @@ export const getDepartmentTrainingPlanList = (filter, version, token) => {
123
123
  */
124
124
  export const publishDepartmentTrainingPlan = (id, token) => {
125
125
  return new Promise(function (resolve, reject) {
126
- let confirmationRequest = axios.post(
126
+ let confirmationRequest = client.post(
127
127
  `api/v1/departmenttrainingplans/publish/${id}`,
128
128
  {},
129
129
  {
@@ -151,7 +151,7 @@ export const setDepartmentTrainingPlanInformation = (id, data, token) => {
151
151
  const requestData = {
152
152
  data: data,
153
153
  };
154
- let confirmationRequest = axios.post(
154
+ let confirmationRequest = client.post(
155
155
  `api/v1/departmenttrainingplans/${id}`,
156
156
  requestData,
157
157
  {
@@ -167,3 +167,13 @@ export const setDepartmentTrainingPlanInformation = (id, data, token) => {
167
167
  });
168
168
  });
169
169
  };
170
+
171
+ export default {
172
+ createDepartmentTrainingPlan: createDepartmentTrainingPlan,
173
+ deleteDepartmentTrainingPlan: deleteDepartmentTrainingPlan,
174
+ getDepartmentTrainingPlanInformationById:
175
+ getDepartmentTrainingPlanInformationById,
176
+ getDepartmentTrainingPlanList: getDepartmentTrainingPlanList,
177
+ publishDepartmentTrainingPlan: publishDepartmentTrainingPlan,
178
+ setDepartmentTrainingPlanInformation: setDepartmentTrainingPlanInformation,
179
+ };
package/lib/groups.js CHANGED
@@ -1,4 +1,4 @@
1
- import axios from "./axiosClient";
1
+ import { client } from "./axiosClient";
2
2
 
3
3
  /**
4
4
  * Add permissions to group
@@ -8,7 +8,7 @@ import axios from "./axiosClient";
8
8
  */
9
9
  export const addPermissionsToGroup = (groupId, permissions, authToken) => {
10
10
  return new Promise(function (resolve, reject) {
11
- const request = axios.post(
11
+ const request = client.post(
12
12
  `api/v1/groups/permissions/add`,
13
13
  {
14
14
  groupId: groupId,
@@ -34,7 +34,7 @@ export const addPermissionsToGroup = (groupId, permissions, authToken) => {
34
34
  */
35
35
  export const addUsersToGroup = (groupId, users, authToken) => {
36
36
  return new Promise(function (resolve, reject) {
37
- const request = axios.post(
37
+ const request = client.post(
38
38
  `api/v1/groups/users/add`,
39
39
  {
40
40
  groupId: groupId,
@@ -60,7 +60,7 @@ export const addUsersToGroup = (groupId, users, authToken) => {
60
60
  */
61
61
  export const createGroup = (name, description, authToken) => {
62
62
  return new Promise(function (resolve, reject) {
63
- const request = axios.post(
63
+ const request = client.post(
64
64
  `api/v1/groups/group`,
65
65
  {
66
66
  name: name,
@@ -86,7 +86,7 @@ export const createGroup = (name, description, authToken) => {
86
86
  */
87
87
  export const deleteGroup = (groupId, defaultGroupId, authToken) => {
88
88
  return new Promise(function (resolve, reject) {
89
- const request = axios.delete(`api/v1/groups/delete`, {
89
+ const request = client.delete(`api/v1/groups/delete`, {
90
90
  headers: { authorization: authToken },
91
91
  data: {
92
92
  id: groupId,
@@ -109,7 +109,7 @@ export const deleteGroup = (groupId, defaultGroupId, authToken) => {
109
109
  */
110
110
  export const getAllPermissions = (authToken) => {
111
111
  return new Promise(function (resolve, reject) {
112
- const request = axios.get(`api/v1/groups/permissions/getAllPermissions`, {
112
+ const request = client.get(`api/v1/groups/permissions/getAllPermissions`, {
113
113
  headers: { authorization: authToken },
114
114
  });
115
115
  request
@@ -129,7 +129,7 @@ export const getAllPermissions = (authToken) => {
129
129
  */
130
130
  export const getGroupById = (groupId, authToken) => {
131
131
  return new Promise(function (resolve, reject) {
132
- const request = axios.get(`api/v1/groups/group/${groupId}`, {
132
+ const request = client.get(`api/v1/groups/group/${groupId}`, {
133
133
  headers: { authorization: authToken },
134
134
  });
135
135
  request
@@ -148,7 +148,7 @@ export const getGroupById = (groupId, authToken) => {
148
148
  */
149
149
  export const getGroups = (authToken) => {
150
150
  return new Promise(function (resolve, reject) {
151
- const request = axios.get(`api/v1/groups/`, {
151
+ const request = client.get(`api/v1/groups/`, {
152
152
  headers: { authorization: authToken },
153
153
  });
154
154
  request
@@ -167,7 +167,7 @@ export const getGroups = (authToken) => {
167
167
  */
168
168
  export const getUserPermissions = (authToken) => {
169
169
  return new Promise(function (resolve, reject) {
170
- const request = axios.get(`api/v1/groups/users/getuserpermissions`, {
170
+ const request = client.get(`api/v1/groups/users/getuserpermissions`, {
171
171
  headers: { authorization: authToken },
172
172
  });
173
173
  request
@@ -188,7 +188,7 @@ export const getUserPermissions = (authToken) => {
188
188
  */
189
189
  export const removePermissionsFromGroup = (groupId, permissions, authToken) => {
190
190
  return new Promise(function (resolve, reject) {
191
- const request = axios.post(
191
+ const request = client.post(
192
192
  `api/v1/groups/permissions/remove/`,
193
193
  {
194
194
  groupId: groupId,
@@ -214,7 +214,7 @@ export const removePermissionsFromGroup = (groupId, permissions, authToken) => {
214
214
  */
215
215
  export const removeUsersFromGroup = (groupId, users, authToken) => {
216
216
  return new Promise(function (resolve, reject) {
217
- const request = axios.post(
217
+ const request = client.post(
218
218
  `api/v1/groups/users/remove/`,
219
219
  {
220
220
  groupId: groupId,
@@ -239,7 +239,7 @@ export const removeUsersFromGroup = (groupId, users, authToken) => {
239
239
  */
240
240
  export const setDefault = (groupId, authToken) => {
241
241
  return new Promise(function (resolve, reject) {
242
- const request = axios.put(
242
+ const request = client.put(
243
243
  `api/v1/groups/setDefault/`,
244
244
  {
245
245
  id: groupId,
@@ -265,7 +265,7 @@ export const setDefault = (groupId, authToken) => {
265
265
  */
266
266
  export const updateGroup = (groupId, name, description, authToken) => {
267
267
  return new Promise(function (resolve, reject) {
268
- const request = axios.patch(
268
+ const request = client.patch(
269
269
  `api/v1/groups/group/`,
270
270
  {
271
271
  id: groupId,
@@ -283,3 +283,18 @@ export const updateGroup = (groupId, name, description, authToken) => {
283
283
  });
284
284
  });
285
285
  };
286
+
287
+ export default {
288
+ addPermissionsToGroup: addPermissionsToGroup,
289
+ addUsersToGroup: addUsersToGroup,
290
+ createGroup: createGroup,
291
+ deleteGroup: deleteGroup,
292
+ getAllPermissions: getAllPermissions,
293
+ getGroupById: getGroupById,
294
+ getGroups: getGroups,
295
+ getUserPermissions: getUserPermissions,
296
+ removePermissionsFromGroup: removePermissionsFromGroup,
297
+ removeUsersFromGroup: removeUsersFromGroup,
298
+ setDefault: setDefault,
299
+ updateGroup: updateGroup,
300
+ };