@stackfactor/client-api 1.1.134 → 1.1.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/.eslintrc.json +4 -3
  2. package/declarations/axios.d.ts +1 -0
  3. package/declarations/html2plaintext.d.ts +1 -0
  4. package/dist/actionNotifications.d.ts +7 -0
  5. package/dist/actionNotifications.d.ts.map +1 -0
  6. package/dist/actionNotifications.js +9 -10
  7. package/dist/actionNotifications.js.map +1 -0
  8. package/dist/address.d.ts +5 -0
  9. package/dist/address.d.ts.map +1 -0
  10. package/dist/address.js +5 -6
  11. package/dist/address.js.map +1 -0
  12. package/dist/aiAssistant.d.ts +9 -0
  13. package/dist/aiAssistant.d.ts.map +1 -0
  14. package/dist/aiAssistant.js +16 -17
  15. package/dist/aiAssistant.js.map +1 -0
  16. package/dist/avatar.d.ts +5 -0
  17. package/dist/avatar.d.ts.map +1 -0
  18. package/dist/avatar.js +4 -5
  19. package/dist/avatar.js.map +1 -0
  20. package/dist/axiosClient.d.ts +32 -0
  21. package/dist/axiosClient.d.ts.map +1 -0
  22. package/dist/axiosClient.js +17 -27
  23. package/dist/axiosClient.js.map +1 -0
  24. package/dist/config.d.ts +7 -0
  25. package/dist/config.d.ts.map +1 -0
  26. package/dist/config.js +9 -10
  27. package/dist/config.js.map +1 -0
  28. package/dist/constants.d.ts +70 -0
  29. package/dist/constants.d.ts.map +1 -0
  30. package/dist/constants.js +2 -7
  31. package/dist/constants.js.map +1 -0
  32. package/dist/dashboard.d.ts +7 -0
  33. package/dist/dashboard.d.ts.map +1 -0
  34. package/dist/dashboard.js +9 -10
  35. package/dist/dashboard.js.map +1 -0
  36. package/dist/departmentTrainingPlans.d.ts +13 -0
  37. package/dist/departmentTrainingPlans.d.ts.map +1 -0
  38. package/dist/departmentTrainingPlans.js +16 -17
  39. package/dist/departmentTrainingPlans.js.map +1 -0
  40. package/dist/groups.d.ts +16 -0
  41. package/dist/groups.d.ts.map +1 -0
  42. package/dist/groups.js +27 -28
  43. package/dist/groups.js.map +1 -0
  44. package/dist/index.d.ts +34 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +34 -77
  47. package/dist/index.js.map +1 -0
  48. package/dist/integration.d.ts +95 -0
  49. package/dist/integration.d.ts.map +1 -0
  50. package/dist/integration.js +62 -69
  51. package/dist/integration.js.map +1 -0
  52. package/dist/integrationConfiguration.d.ts +7 -0
  53. package/dist/integrationConfiguration.d.ts.map +1 -0
  54. package/dist/integrationConfiguration.js +10 -11
  55. package/dist/integrationConfiguration.js.map +1 -0
  56. package/dist/integrations/contentGenerator.d.ts +27 -0
  57. package/dist/integrations/contentGenerator.d.ts.map +1 -0
  58. package/dist/integrations/contentGenerator.js +12 -16
  59. package/dist/integrations/contentGenerator.js.map +1 -0
  60. package/dist/learningContent.d.ts +19 -0
  61. package/dist/learningContent.d.ts.map +1 -0
  62. package/dist/learningContent.js +30 -31
  63. package/dist/learningContent.js.map +1 -0
  64. package/dist/learningPath.d.ts +12 -0
  65. package/dist/learningPath.d.ts.map +1 -0
  66. package/dist/learningPath.js +19 -20
  67. package/dist/learningPath.js.map +1 -0
  68. package/dist/logger.d.ts +6 -0
  69. package/dist/logger.d.ts.map +1 -0
  70. package/dist/logger.js +8 -9
  71. package/dist/logger.js.map +1 -0
  72. package/dist/microSkillsQuizes.d.ts +6 -0
  73. package/dist/microSkillsQuizes.d.ts.map +1 -0
  74. package/dist/microSkillsQuizes.js +8 -9
  75. package/dist/microSkillsQuizes.js.map +1 -0
  76. package/dist/quotas.d.ts +6 -0
  77. package/dist/quotas.d.ts.map +1 -0
  78. package/dist/quotas.js +7 -8
  79. package/dist/quotas.js.map +1 -0
  80. package/dist/role.d.ts +18 -0
  81. package/dist/role.d.ts.map +1 -0
  82. package/dist/role.js +32 -33
  83. package/dist/role.js.map +1 -0
  84. package/dist/roleTemplate.d.ts +13 -0
  85. package/dist/roleTemplate.d.ts.map +1 -0
  86. package/dist/roleTemplate.js +22 -23
  87. package/dist/roleTemplate.js.map +1 -0
  88. package/dist/security.d.ts +8 -0
  89. package/dist/security.d.ts.map +1 -0
  90. package/dist/security.js +11 -12
  91. package/dist/security.js.map +1 -0
  92. package/dist/skill.d.ts +22 -0
  93. package/dist/skill.d.ts.map +1 -0
  94. package/dist/skill.js +40 -41
  95. package/dist/skill.js.map +1 -0
  96. package/dist/skillAssessmentTestingSession.d.ts +10 -0
  97. package/dist/skillAssessmentTestingSession.d.ts.map +1 -0
  98. package/dist/skillAssessmentTestingSession.js +15 -16
  99. package/dist/skillAssessmentTestingSession.js.map +1 -0
  100. package/dist/skillAssessments.d.ts +10 -0
  101. package/dist/skillAssessments.d.ts.map +1 -0
  102. package/dist/skillAssessments.js +15 -16
  103. package/dist/skillAssessments.js.map +1 -0
  104. package/dist/skillTemplate.d.ts +15 -0
  105. package/dist/skillTemplate.d.ts.map +1 -0
  106. package/dist/skillTemplate.js +26 -27
  107. package/dist/skillTemplate.js.map +1 -0
  108. package/dist/talentTransfromation.d.ts +8 -0
  109. package/dist/talentTransfromation.d.ts.map +1 -0
  110. package/dist/talentTransfromation.js +11 -12
  111. package/dist/talentTransfromation.js.map +1 -0
  112. package/dist/teams.d.ts +15 -0
  113. package/dist/teams.d.ts.map +1 -0
  114. package/dist/teams.js +25 -26
  115. package/dist/teams.js.map +1 -0
  116. package/dist/tenants.d.ts +6 -0
  117. package/dist/tenants.d.ts.map +1 -0
  118. package/dist/tenants.js +7 -8
  119. package/dist/tenants.js.map +1 -0
  120. package/dist/trainingPlans.d.ts +16 -0
  121. package/dist/trainingPlans.d.ts.map +1 -0
  122. package/dist/trainingPlans.js +19 -20
  123. package/dist/trainingPlans.js.map +1 -0
  124. package/dist/trainingPlansProficiencyLevels.d.ts +8 -0
  125. package/dist/trainingPlansProficiencyLevels.d.ts.map +1 -0
  126. package/dist/trainingPlansProficiencyLevels.js +9 -10
  127. package/dist/trainingPlansProficiencyLevels.js.map +1 -0
  128. package/dist/userInformation.d.ts +7 -0
  129. package/dist/userInformation.d.ts.map +1 -0
  130. package/dist/userInformation.js +9 -10
  131. package/dist/userInformation.js.map +1 -0
  132. package/dist/users.d.ts +31 -0
  133. package/dist/users.d.ts.map +1 -0
  134. package/dist/users.js +37 -39
  135. package/dist/users.js.map +1 -0
  136. package/dist/utils.d.ts +8 -0
  137. package/dist/utils.d.ts.map +1 -0
  138. package/dist/utils.js +8 -21
  139. package/dist/utils.js.map +1 -0
  140. package/package.json +15 -14
  141. package/src/lib/actionNotifications.ts +10 -9
  142. package/src/lib/address.ts +4 -3
  143. package/src/lib/aiAssistant.ts +24 -23
  144. package/src/lib/avatar.ts +3 -2
  145. package/src/lib/axiosClient.ts +20 -7
  146. package/src/lib/config.ts +10 -9
  147. package/src/lib/dashboard.ts +10 -9
  148. package/src/lib/departmentTrainingPlans.ts +28 -31
  149. package/src/lib/groups.ts +37 -36
  150. package/src/lib/integration.ts +55 -54
  151. package/src/lib/integrationConfiguration.ts +14 -13
  152. package/src/lib/integrations/contentGenerator.ts +9 -8
  153. package/src/lib/learningContent.ts +55 -54
  154. package/src/lib/learningPath.ts +31 -30
  155. package/src/lib/logger.ts +8 -7
  156. package/src/lib/microSkillsQuizes.ts +10 -9
  157. package/src/lib/quotas.ts +9 -8
  158. package/src/lib/role.ts +55 -54
  159. package/src/lib/roleTemplate.ts +36 -35
  160. package/src/lib/security.ts +13 -12
  161. package/src/lib/skill.ts +71 -70
  162. package/src/lib/skillAssessmentTestingSession.ts +24 -23
  163. package/src/lib/skillAssessments.ts +24 -23
  164. package/src/lib/skillTemplate.ts +44 -43
  165. package/src/lib/talentTransfromation.ts +14 -13
  166. package/src/lib/teams.ts +34 -33
  167. package/src/lib/tenants.ts +9 -8
  168. package/src/lib/trainingPlans.ts +36 -35
  169. package/src/lib/trainingPlansProficiencyLevels.ts +13 -12
  170. package/src/lib/userInformation.ts +12 -11
  171. package/src/lib/users.ts +71 -71
  172. package/src/lib/utils.ts +7 -16
  173. package/tsconfig.json +16 -5
  174. package/dist/exports.js +0 -77
  175. package/index.d.ts +0 -1
@@ -1,3 +1,4 @@
1
+ import { AxiosError, AxiosResponse } from "axios";
1
2
  import { client } from "./axiosClient";
2
3
 
3
4
  /**
@@ -6,7 +7,7 @@ import { client } from "./axiosClient";
6
7
  * @param {String} property
7
8
  * @param {Object} data
8
9
  * @param {String} token Authorization token
9
- * @returns {Promise<Object>}
10
+ * @returns {Promise<object>}
10
11
  */
11
12
  const addEntryToArrayBusinessProperty = (
12
13
  userId: string,
@@ -18,7 +19,7 @@ const addEntryToArrayBusinessProperty = (
18
19
  const requestData = {
19
20
  data: data,
20
21
  };
21
- let confirmationRequest = client.post(
22
+ const confirmationRequest = client.post(
22
23
  `api/v1/user/arrayproperty/${userId}/${property}`,
23
24
  requestData,
24
25
  {
@@ -26,10 +27,10 @@ const addEntryToArrayBusinessProperty = (
26
27
  }
27
28
  );
28
29
  confirmationRequest
29
- .then((response) => {
30
+ .then((response : AxiosResponse) => {
30
31
  resolve(response.data);
31
32
  })
32
- .catch((error) => {
33
+ .catch((error : AxiosError) => {
33
34
  reject(error);
34
35
  });
35
36
  });
@@ -41,7 +42,7 @@ const addEntryToArrayBusinessProperty = (
41
42
  * @param {String} property
42
43
  * @param {String} id
43
44
  * @param {String} token Authorization token
44
- * @returns {Promise<Object>}
45
+ * @returns {Promise<object>}
45
46
  */
46
47
  const removeEntryFromArrayBusinessProperty = (
47
48
  userId: string,
@@ -57,10 +58,10 @@ const removeEntryFromArrayBusinessProperty = (
57
58
  }
58
59
  );
59
60
  confirmationRequest
60
- .then((response) => {
61
+ .then((response : AxiosResponse) => {
61
62
  resolve(response.data);
62
63
  })
63
- .catch((error) => {
64
+ .catch((error : AxiosError) => {
64
65
  reject(error);
65
66
  });
66
67
  });
@@ -73,7 +74,7 @@ const removeEntryFromArrayBusinessProperty = (
73
74
  * @param {String} id
74
75
  * @param {Object} data
75
76
  * @param {String} token Authorization token
76
- * @returns {Promise<Object>}
77
+ * @returns {Promise<object>}
77
78
  */
78
79
  const updateEntryfromArrayBusinessProperty = (
79
80
  userId: string,
@@ -86,7 +87,7 @@ const updateEntryfromArrayBusinessProperty = (
86
87
  const requestData = {
87
88
  data: data,
88
89
  };
89
- let confirmationRequest = client.patch(
90
+ const confirmationRequest = client.patch(
90
91
  `api/v1/user/arrayproperty/${userId}/${property}/${id}`,
91
92
  requestData,
92
93
  {
@@ -94,10 +95,10 @@ const updateEntryfromArrayBusinessProperty = (
94
95
  }
95
96
  );
96
97
  confirmationRequest
97
- .then((response) => {
98
+ .then((response : AxiosResponse) => {
98
99
  resolve(response.data);
99
100
  })
100
- .catch((error) => {
101
+ .catch((error : AxiosError) => {
101
102
  reject(error);
102
103
  });
103
104
  });
package/src/lib/users.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint-disable no-undef */
1
+ import { AxiosResponse, AxiosError } from "axios";
2
2
  import { client } from "./axiosClient";
3
3
 
4
4
  /**
@@ -29,7 +29,7 @@ const addAPIToken = (name: string, expiration: Date, token: string): Promise<obj
29
29
  reject(process.env.ERROR_INVALID_INFORMATION);
30
30
  }
31
31
  })
32
- .catch((error) => {
32
+ .catch((error : AxiosError) => {
33
33
  reject(error);
34
34
  });
35
35
  });
@@ -53,7 +53,7 @@ const confirmEmailAddress = (validationCode: string): Promise<void> => {
53
53
  .then(() => {
54
54
  resolve();
55
55
  })
56
- .catch((error) => {
56
+ .catch((error : AxiosError) => {
57
57
  reject(error);
58
58
  });
59
59
  });
@@ -78,10 +78,10 @@ const confirmPhone = (validationCode: string, token: string): Promise<object> =>
78
78
  }
79
79
  );
80
80
  confirmationRequest
81
- .then((response) => {
81
+ .then((response : AxiosResponse) => {
82
82
  resolve(response.data);
83
83
  })
84
- .catch((error) => {
84
+ .catch((error : AxiosError) => {
85
85
  reject(error);
86
86
  });
87
87
  });
@@ -106,10 +106,10 @@ const confirmPhoneGenerateCode = (phoneNumber: string, token: string): Promise<o
106
106
  }
107
107
  );
108
108
  confirmationRequest
109
- .then((response) => {
109
+ .then((response : AxiosResponse) => {
110
110
  resolve(response.data);
111
111
  })
112
- .catch((error) => {
112
+ .catch((error : AxiosError) => {
113
113
  reject(error);
114
114
  });
115
115
  });
@@ -152,12 +152,12 @@ const createAccount = (
152
152
  password: password,
153
153
  subSite: subSite,
154
154
  };
155
- let request = client.post("api/v1/users/createAccount", signupData);
155
+ const request = client.post("api/v1/users/createAccount", signupData);
156
156
  request
157
157
  .then((result) => {
158
158
  resolve(result.data.user);
159
159
  })
160
- .catch((error) => {
160
+ .catch((error : AxiosError) => {
161
161
  reject(error);
162
162
  });
163
163
  }
@@ -197,12 +197,12 @@ const createUserAccount = (
197
197
  password: password,
198
198
  token: token,
199
199
  };
200
- let request = client.post("api/v1/users/createUser", signupData);
200
+ const request = client.post("api/v1/users/createUser", signupData);
201
201
  request
202
202
  .then((result) => {
203
203
  resolve(result.data.user);
204
204
  })
205
- .catch((error) => {
205
+ .catch((error : AxiosError) => {
206
206
  reject(error);
207
207
  });
208
208
  }
@@ -227,7 +227,7 @@ const deleteAPIToken = (token: string, authToken: string): Promise<string> => {
227
227
  .then(() => {
228
228
  resolve(token);
229
229
  })
230
- .catch((error) => {
230
+ .catch((error : AxiosError) => {
231
231
  reject(error);
232
232
  });
233
233
  });
@@ -248,10 +248,10 @@ const deleteUsers = (userIds: string[], token: string): Promise<object> => {
248
248
  },
249
249
  });
250
250
  deleteTokenRequest
251
- .then((response) => {
251
+ .then((response : AxiosResponse) => {
252
252
  resolve(response.data);
253
253
  })
254
- .catch((error) => {
254
+ .catch((error : AxiosError) => {
255
255
  reject(error);
256
256
  });
257
257
  });
@@ -271,7 +271,7 @@ const getAPITokens = (token: string): Promise<object> => {
271
271
  .then((result) => {
272
272
  resolve(result.data);
273
273
  })
274
- .catch((error) => {
274
+ .catch((error : AxiosError) => {
275
275
  reject(error);
276
276
  });
277
277
  });
@@ -296,7 +296,7 @@ const getUserById = (id: string, token: string): Promise<object> => {
296
296
  reject(process.env.ERROR_INVALID_INFORMATION);
297
297
  }
298
298
  })
299
- .catch((error) => {
299
+ .catch((error : AxiosError) => {
300
300
  reject(error);
301
301
  });
302
302
  });
@@ -311,17 +311,17 @@ const getUserById = (id: string, token: string): Promise<object> => {
311
311
  */
312
312
  const getUserInformation = (userId: string, category: string, token: string): Promise<object> => {
313
313
  return new Promise((resolve, reject) => {
314
- let confirmationRequest = client.get(
314
+ const confirmationRequest = client.get(
315
315
  `api/v1/users/user/${userId || 0}/${category || "*"}`,
316
316
  {
317
317
  headers: { authorization: token },
318
318
  }
319
319
  );
320
320
  confirmationRequest
321
- .then((response) => {
321
+ .then((response : AxiosResponse) => {
322
322
  resolve(response.data);
323
323
  })
324
- .catch((error) => {
324
+ .catch((error : AxiosError) => {
325
325
  reject(error);
326
326
  });
327
327
  });
@@ -340,14 +340,14 @@ const getUsers = (filter: object, fields: string[], token: string): Promise<obje
340
340
  filter: filter,
341
341
  fields: fields,
342
342
  };
343
- let confirmationRequest = client.post(`api/v1/users/`, requestData, {
343
+ const confirmationRequest = client.post(`api/v1/users/`, requestData, {
344
344
  headers: { authorization: token },
345
345
  });
346
346
  confirmationRequest
347
- .then((response) => {
347
+ .then((response : AxiosResponse) => {
348
348
  resolve(response.data);
349
349
  })
350
- .catch((error) => {
350
+ .catch((error : AxiosError) => {
351
351
  reject(error);
352
352
  });
353
353
  });
@@ -369,14 +369,14 @@ const inviteUsers = (invitees: string[], groupId: string, teamId: string, authTo
369
369
  teamId: teamId,
370
370
  token: authToken,
371
371
  };
372
- let request = client.post("api/v1/users/invite", requestData, {
372
+ const request = client.post("api/v1/users/invite", requestData, {
373
373
  headers: { authorization: authToken },
374
374
  });
375
375
  request
376
- .then((response) => {
376
+ .then((response : AxiosResponse) => {
377
377
  resolve(response.data);
378
378
  })
379
- .catch((error) => {
379
+ .catch((error : AxiosError) => {
380
380
  reject(error);
381
381
  });
382
382
  });
@@ -394,12 +394,12 @@ const login = (email: string, password: string): Promise<object> => {
394
394
  email: email,
395
395
  password: password,
396
396
  };
397
- let request = client.post("api/v1/auth/login", requestData);
397
+ const request = client.post("api/v1/auth/login", requestData);
398
398
  request
399
- .then((response) => {
399
+ .then((response : AxiosResponse) => {
400
400
  resolve(response.data);
401
401
  })
402
- .catch((error) => {
402
+ .catch((error : AxiosError) => {
403
403
  reject(error);
404
404
  });
405
405
  });
@@ -419,12 +419,12 @@ const loginExchangeKeys = (code: string, codeVerifier: string, redirectUri: stri
419
419
  codeVerifier: codeVerifier,
420
420
  redirectUri: redirectUri,
421
421
  };
422
- let request = client.post("api/v1/auth/loginexchangekeys", requestData);
422
+ const request = client.post("api/v1/auth/loginexchangekeys", requestData);
423
423
  request
424
- .then((response) => {
424
+ .then((response : AxiosResponse) => {
425
425
  resolve(response.data);
426
426
  })
427
- .catch((error) => {
427
+ .catch((error : AxiosError) => {
428
428
  reject(error);
429
429
  });
430
430
  });
@@ -437,7 +437,7 @@ const loginExchangeKeys = (code: string, codeVerifier: string, redirectUri: stri
437
437
  */
438
438
  const logout = (token: string): Promise<object> => {
439
439
  return new Promise((resolve, reject) => {
440
- let request = client.post(
440
+ const request = client.post(
441
441
  "api/v1/auth/logout",
442
442
  {},
443
443
  {
@@ -445,10 +445,10 @@ const logout = (token: string): Promise<object> => {
445
445
  }
446
446
  );
447
447
  request
448
- .then((response) => {
448
+ .then((response : AxiosResponse) => {
449
449
  resolve(response.data);
450
450
  })
451
- .catch((error) => {
451
+ .catch((error : AxiosError) => {
452
452
  reject(error);
453
453
  });
454
454
  });
@@ -462,14 +462,14 @@ const logout = (token: string): Promise<object> => {
462
462
  */
463
463
  const refreshToken = (refreshToken: string): Promise<object> => {
464
464
  return new Promise((resolve, reject) => {
465
- let request = client.post("api/v1/auth/refreshToken", {
465
+ const request = client.post("api/v1/auth/refreshToken", {
466
466
  refreshToken: refreshToken,
467
467
  });
468
468
  request
469
- .then((response) => {
469
+ .then((response : AxiosResponse) => {
470
470
  resolve(response.data);
471
471
  })
472
- .catch((error) => {
472
+ .catch((error : AxiosError) => {
473
473
  reject(error);
474
474
  });
475
475
  });
@@ -497,7 +497,7 @@ const removeAPIToken = (id: string, authToken: string): Promise<string> => {
497
497
  .then(() => {
498
498
  resolve(id);
499
499
  })
500
- .catch((error) => {
500
+ .catch((error : AxiosError) => {
501
501
  reject(error);
502
502
  });
503
503
  });
@@ -515,14 +515,14 @@ const resendInvitationEmails = (invitees: string[], authToken: string): Promise<
515
515
  invitees: invitees,
516
516
  token: authToken,
517
517
  };
518
- let request = client.post("api/v1/users/resendinvite", requestData, {
518
+ const request = client.post("api/v1/users/resendinvite", requestData, {
519
519
  headers: { authorization: authToken },
520
520
  });
521
521
  request
522
- .then((response) => {
522
+ .then((response : AxiosResponse) => {
523
523
  resolve(response.data);
524
524
  })
525
- .catch((error) => {
525
+ .catch((error : AxiosError) => {
526
526
  reject(error);
527
527
  });
528
528
  });
@@ -537,17 +537,17 @@ const resendInvitationEmails = (invitees: string[], authToken: string): Promise<
537
537
  */
538
538
  const resetPassword = (email: string, code: string, password: string): Promise<object> => {
539
539
  return new Promise((resolve, reject) => {
540
- let postData = {
540
+ const postData = {
541
541
  email: email,
542
542
  code: code,
543
543
  password: password,
544
544
  };
545
- let request = client.post("api/v1/users/resetpassword", postData);
545
+ const request = client.post("api/v1/users/resetpassword", postData);
546
546
  request
547
- .then((response) => {
547
+ .then((response : AxiosResponse) => {
548
548
  resolve(response.data);
549
549
  })
550
- .catch((error) => {
550
+ .catch((error : AxiosError) => {
551
551
  reject(error);
552
552
  });
553
553
  });
@@ -561,10 +561,10 @@ const resetPassword = (email: string, code: string, password: string): Promise<o
561
561
  */
562
562
  const sendEmailConfirmationCode = (email: string, token: string): Promise<object> => {
563
563
  return new Promise((resolve, reject) => {
564
- let postData = {
564
+ const postData = {
565
565
  email: email,
566
566
  };
567
- let request = client.post(
567
+ const request = client.post(
568
568
  "api/v1/users/sendemailconfirmationcode",
569
569
  postData,
570
570
  {
@@ -572,10 +572,10 @@ const sendEmailConfirmationCode = (email: string, token: string): Promise<object
572
572
  }
573
573
  );
574
574
  request
575
- .then((response) => {
575
+ .then((response : AxiosResponse) => {
576
576
  resolve(response.data);
577
577
  })
578
- .catch((error) => {
578
+ .catch((error : AxiosError) => {
579
579
  reject(error);
580
580
  });
581
581
  });
@@ -588,18 +588,18 @@ const sendEmailConfirmationCode = (email: string, token: string): Promise<object
588
588
  */
589
589
  const sendPasswordResetNotification = (email: string): Promise<object> => {
590
590
  return new Promise((resolve, reject) => {
591
- let postData = {
591
+ const postData = {
592
592
  email: email,
593
593
  };
594
- let request = client.post(
594
+ const request = client.post(
595
595
  "api/v1/users/sendpasswordresetnotification",
596
596
  postData
597
597
  );
598
598
  request
599
- .then((response) => {
599
+ .then((response : AxiosResponse) => {
600
600
  resolve(response.data);
601
601
  })
602
- .catch((error) => {
602
+ .catch((error : AxiosError) => {
603
603
  reject(error);
604
604
  });
605
605
  });
@@ -619,14 +619,14 @@ const setUserInformation = (userId: string, category: string, data: object, toke
619
619
  data: category ? { [category]: data } : data,
620
620
  userId: userId,
621
621
  };
622
- let confirmationRequest = client.post("api/v1/users/user", requestData, {
622
+ const confirmationRequest = client.post("api/v1/users/user", requestData, {
623
623
  headers: { authorization: token },
624
624
  });
625
625
  confirmationRequest
626
- .then((response) => {
626
+ .then((response: AxiosResponse) => {
627
627
  resolve(response.data);
628
628
  })
629
- .catch((error) => {
629
+ .catch((error: AxiosError) => {
630
630
  reject(error);
631
631
  });
632
632
  });
@@ -652,7 +652,7 @@ const updateUserEmail = (
652
652
  verificationCode: verificationCode,
653
653
  password: password,
654
654
  };
655
- let confirmationRequest = client.post(
655
+ const confirmationRequest = client.post(
656
656
  "api/v1/users/updateemail",
657
657
  requestData,
658
658
  {
@@ -660,10 +660,10 @@ const updateUserEmail = (
660
660
  }
661
661
  );
662
662
  confirmationRequest
663
- .then((response) => {
663
+ .then((response : AxiosResponse) => {
664
664
  resolve(response.data);
665
665
  })
666
- .catch((error) => {
666
+ .catch((error : AxiosError) => {
667
667
  reject(error);
668
668
  });
669
669
  });
@@ -674,7 +674,7 @@ const updateUserEmail = (
674
674
  * @param {String} userId The id of the user
675
675
  * @param {Array<String>} groups The id of the groups the user should belong to
676
676
  * @param {String} token Authorization token
677
- * @returns {Promise<Object>}
677
+ * @returns {Promise<object>}
678
678
  */
679
679
  const updateUserGroups = (
680
680
  userId: string,
@@ -686,7 +686,7 @@ const updateUserGroups = (
686
686
  userId: userId,
687
687
  groups: groups || [],
688
688
  };
689
- let confirmationRequest = client.post(
689
+ const confirmationRequest = client.post(
690
690
  "api/v1/users/user/updategroups",
691
691
  requestData,
692
692
  {
@@ -697,7 +697,7 @@ const updateUserGroups = (
697
697
  .then(() => {
698
698
  resolve(requestData);
699
699
  })
700
- .catch((error) => {
700
+ .catch((error : AxiosError) => {
701
701
  reject(error);
702
702
  });
703
703
  });
@@ -708,7 +708,7 @@ const updateUserGroups = (
708
708
  * @param {String} password The current password
709
709
  * @param {String} newPassword The new password
710
710
  * @param {String} token Authorization token
711
- * @returns {Promise<Object>}
711
+ * @returns {Promise<object>}
712
712
  */
713
713
  const updateUserPassword = (
714
714
  password: string,
@@ -720,7 +720,7 @@ const updateUserPassword = (
720
720
  password: password,
721
721
  newPassword: newPassword,
722
722
  };
723
- let confirmationRequest = client.post(
723
+ const confirmationRequest = client.post(
724
724
  "api/v1/users/updatepassword",
725
725
  requestData,
726
726
  {
@@ -728,10 +728,10 @@ const updateUserPassword = (
728
728
  }
729
729
  );
730
730
  confirmationRequest
731
- .then((response) => {
731
+ .then((response : AxiosResponse) => {
732
732
  resolve(response.data);
733
733
  })
734
- .catch((error) => {
734
+ .catch((error : AxiosError) => {
735
735
  reject(error);
736
736
  });
737
737
  });
@@ -741,23 +741,23 @@ const updateUserPassword = (
741
741
  * Validate reset password code. It returns a promise
742
742
  * @param {String} email User's email address
743
743
  * @param {String} code Provided reset code
744
- * @returns {Promise<Object>}
744
+ * @returns {Promise<object>}
745
745
  */
746
746
  const validateResetPasswordCode = (
747
747
  email: string,
748
748
  code: string
749
749
  ): Promise<object> => {
750
750
  return new Promise((resolve, reject) => {
751
- let postData = {
751
+ const postData = {
752
752
  email: email,
753
753
  code: code,
754
754
  };
755
- let request = client.post("api/v1/users/validateresetpasswordcode", postData);
755
+ const request = client.post("api/v1/users/validateresetpasswordcode", postData);
756
756
  request
757
- .then((response) => {
757
+ .then((response : AxiosResponse) => {
758
758
  resolve(response.data);
759
759
  })
760
- .catch((error) => {
760
+ .catch((error : AxiosError) => {
761
761
  reject(error);
762
762
  });
763
763
  });
package/src/lib/utils.ts CHANGED
@@ -1,18 +1,8 @@
1
- /* eslint-disable no-undef */
2
- //import dotenv from "dotenv";
1
+ import dotenv from "dotenv";
3
2
  // Load environment variables from .env file
4
- //dotenv.config();
3
+ dotenv.config();
4
+
5
5
 
6
- /**
7
- * Convert object to array
8
- * @param {Object} data
9
- * @returns {Array}
10
- */
11
- const objectToArray = (data: object): any[] => {
12
- if (typeof data === "object") {
13
- return [...Object.values(data)];
14
- } else throw new Error("Invalid type");
15
- };
16
6
 
17
7
  /**
18
8
  * Returns the backend base API URL
@@ -46,10 +36,11 @@ const getBaseUrl = (): string => {
46
36
  * @param {Object} object
47
37
  * @returns {Object}
48
38
  */
39
+ /* eslint-disable @typescript-eslint/no-explicit-any */
49
40
  const removeNullProperties = (object: { [key: string]: any }): object => {
50
41
  Object.keys(object).forEach((key) => {
51
- let value = object[key];
52
- let hasProperties = value && Object.keys(value).length > 0;
42
+ const value = object[key];
43
+ const hasProperties = value && Object.keys(value).length > 0;
53
44
  if (value === null) {
54
45
  delete object[key];
55
46
  } else if (typeof value !== "string" && hasProperties) {
@@ -59,6 +50,6 @@ const removeNullProperties = (object: { [key: string]: any }): object => {
59
50
  return object;
60
51
  };
61
52
 
62
- const utils = { getBaseUrl, objectToArray, removeNullProperties };
53
+ const utils = { getBaseUrl, removeNullProperties };
63
54
 
64
55
  export default utils;
package/tsconfig.json CHANGED
@@ -1,12 +1,23 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES6",
4
- "module": "commonjs",
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
5
6
  "strict": true,
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "sourceMap": true,
11
+ "outDir": "dist",
6
12
  "esModuleInterop": true,
7
13
  "skipLibCheck": true,
8
- "forceConsistentCasingInFileNames": true,
9
- "outDir": "./dist"
14
+ "resolveJsonModule": true,
15
+ "typeRoots": [
16
+ "./node_modules/@types/axios",
17
+ "./node_modules/@types/node",
18
+ "./declarations"
19
+ ]
10
20
  },
11
- "include": ["src/**/*", "index.d.ts"]
21
+ "include": ["src", "index.d.ts"],
22
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
12
23
  }