@stackfactor/client-api 1.1.11 → 1.1.12-9.2

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 (41) hide show
  1. package/.eslintrc.json +13 -0
  2. package/{exports.js → exports.ts} +14 -0
  3. package/index.ts +1 -0
  4. package/lib/{actionNotifications.js → actionNotifications.ts} +21 -11
  5. package/lib/{address.js → address.ts} +4 -5
  6. package/lib/aiAssistant.ts +197 -0
  7. package/lib/avatar.ts +41 -0
  8. package/lib/axiosClient.ts +92 -0
  9. package/lib/{config.js → config.ts} +20 -9
  10. package/lib/{constants.js → constants.ts} +11 -41
  11. package/lib/{dashboard.js → dashboard.ts} +19 -10
  12. package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +63 -32
  13. package/lib/{groups.js → groups.ts} +68 -29
  14. package/lib/{integration.js → integration.ts} +103 -47
  15. package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +27 -22
  16. package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
  17. package/lib/{learningContent.js → learningContent.ts} +218 -62
  18. package/lib/{learningPath.js → learningPath.ts} +57 -30
  19. package/lib/{logger.js → logger.ts} +18 -8
  20. package/lib/microSkillsQuizes.ts +70 -0
  21. package/lib/quotas.ts +59 -0
  22. package/lib/{role.js → role.ts} +117 -69
  23. package/lib/{roleTemplate.js → roleTemplate.ts} +65 -30
  24. package/lib/security.ts +99 -0
  25. package/lib/{skill.js → skill.ts} +125 -87
  26. package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +63 -16
  27. package/lib/skillAssessments.ts +192 -0
  28. package/lib/{skillTemplate.js → skillTemplate.ts} +73 -42
  29. package/lib/talentTransfromation.ts +126 -0
  30. package/lib/{teams.js → teams.ts} +73 -38
  31. package/lib/{tenants.js → tenants.ts} +17 -10
  32. package/lib/{trainingPlans.js → trainingPlans.ts} +159 -56
  33. package/lib/trainingPlansProficiencyLevels.ts +132 -0
  34. package/lib/{userInformation.js → userInformation.ts} +27 -26
  35. package/lib/{users.js → users.ts} +239 -140
  36. package/lib/utils.ts +64 -0
  37. package/package.json +12 -1
  38. package/index.js +0 -3
  39. package/lib/axiosClient.js +0 -85
  40. package/lib/skillAssessmentTestingSession.js +0 -148
  41. package/lib/utils.js +0 -48
@@ -1,12 +1,15 @@
1
+ /* eslint-disable no-undef */
1
2
  import { client } from "./axiosClient.js";
2
3
 
3
4
  /**
4
5
  * Add a new API Token
6
+ * @param {string} name Name of the token
5
7
  * @param {Date} expiration Expiration date of the token
6
- * @param {String} authToken Authorization token
8
+ * @param {string} token Authorization token
9
+ * @returns {Promise<object>}
7
10
  */
8
- export const addAPIToken = (name, expiration, authToken) => {
9
- return new Promise(function (resolve, reject) {
11
+ const addAPIToken = (name: string, expiration: Date, token: string): Promise<object> => {
12
+ return new Promise((resolve, reject) => {
10
13
  const requestData = {
11
14
  name: name,
12
15
  expiration: expiration,
@@ -15,7 +18,7 @@ export const addAPIToken = (name, expiration, authToken) => {
15
18
  `api/v1/users/addapitoken`,
16
19
  requestData,
17
20
  {
18
- headers: { authorization: authToken },
21
+ headers: { authorization: token },
19
22
  }
20
23
  );
21
24
  addTokenRequest
@@ -34,10 +37,11 @@ export const addAPIToken = (name, expiration, authToken) => {
34
37
 
35
38
  /**
36
39
  * Confirm email address
37
- * @param {String} validationCode The code was provided to the user in advance by email
40
+ * @param {string} validationCode The code was provided to the user in advance by email
41
+ * @returns {Promise<void>}
38
42
  */
39
- export const confirmEmailAddress = (validationCode) => {
40
- return new Promise(function (resolve, reject) {
43
+ const confirmEmailAddress = (validationCode: string): Promise<void> => {
44
+ return new Promise((resolve, reject) => {
41
45
  const requestData = {
42
46
  validationCode: validationCode,
43
47
  };
@@ -57,11 +61,12 @@ export const confirmEmailAddress = (validationCode) => {
57
61
 
58
62
  /**
59
63
  * Confirm phone number
60
- * @param {String} validationCode The code was provided to the user in advance by email
61
- * @param {String} authToken Authorization token
64
+ * @param {string} validationCode The code was provided to the user in advance by email
65
+ * @param {string} token Authorization token
66
+ * @returns {Promise<object>}
62
67
  */
63
- export const confirmPhone = (validationCode, authToken) => {
64
- return new Promise(function (resolve, reject) {
68
+ const confirmPhone = (validationCode: string, token: string): Promise<object> => {
69
+ return new Promise((resolve, reject) => {
65
70
  const requestData = {
66
71
  validationCode: validationCode,
67
72
  };
@@ -69,7 +74,7 @@ export const confirmPhone = (validationCode, authToken) => {
69
74
  "api/v1/users/confirmPhone",
70
75
  requestData,
71
76
  {
72
- headers: { authorization: authToken },
77
+ headers: { authorization: token },
73
78
  }
74
79
  );
75
80
  confirmationRequest
@@ -84,11 +89,12 @@ export const confirmPhone = (validationCode, authToken) => {
84
89
 
85
90
  /**
86
91
  * Generate confirmation code
87
- * @param {String} phoneNumber Send confirmation code to the phone number
88
- * @param {String} authToken Authorization token
92
+ * @param {string} phoneNumber Send confirmation code to the phone number
93
+ * @param {string} token Authorization token
94
+ * @returns {Promise<object>}
89
95
  */
90
- export const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
91
- return new Promise(function (resolve, reject) {
96
+ const confirmPhoneGenerateCode = (phoneNumber: string, token: string): Promise<object> => {
97
+ return new Promise((resolve, reject) => {
92
98
  const requestData = {
93
99
  phoneNumber: phoneNumber,
94
100
  };
@@ -96,7 +102,7 @@ export const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
96
102
  "api/v1/users/confirmPhoneGenerateCode",
97
103
  requestData,
98
104
  {
99
- headers: { authorization: authToken },
105
+ headers: { authorization: token },
100
106
  }
101
107
  );
102
108
  confirmationRequest
@@ -111,23 +117,23 @@ export const confirmPhoneGenerateCode = (phoneNumber, authToken) => {
111
117
 
112
118
  /**
113
119
  * Create a new account (tenant). It returns a promise
114
- * @param {String} email User's email address
115
- * @param {String} firstName User's first name
116
- * @param {String} lastName User's last name
117
- * @param {String} password User's password
118
- * @param {String} subSite Subsite where the new account will be created
119
- * @param {String} inviteCode Invitation code received in advance from one of the account owners
120
- * @param
120
+ * @param {string} email User's email address
121
+ * @param {string} firstName User's first name
122
+ * @param {string} lastName User's last name
123
+ * @param {string} password User's password
124
+ * @param {string} subSite Subsite where the new account will be created
125
+ * @param {string} inviteCode Invitation code received in advance from one of the account owners
126
+ * @returns {Promise<object>}
121
127
  */
122
- export const createAccount = (
123
- email,
124
- firstName,
125
- lastName,
126
- password,
127
- subSite,
128
- inviteCode
129
- ) => {
130
- return new Promise(function (resolve, reject) {
128
+ const createAccount = (
129
+ email: string,
130
+ firstName: string,
131
+ lastName: string,
132
+ password: string,
133
+ subSite: string,
134
+ inviteCode: string
135
+ ): Promise<object> => {
136
+ return new Promise((resolve, reject) => {
131
137
  if (
132
138
  email.trim() === "" ||
133
139
  firstName.trim() === "" ||
@@ -160,20 +166,21 @@ export const createAccount = (
160
166
 
161
167
  /**
162
168
  * Create a new user account. It returns a promise
163
- * @param {String} email User's email address
164
- * @param {String} firstName User's first name
165
- * @param {String} lastName User's last name
166
- * @param {String} password User's password
167
- * @param {String} token Invitation token provided to the user
169
+ * @param {string} email User's email address
170
+ * @param {string} firstName User's first name
171
+ * @param {string} lastName User's last name
172
+ * @param {string} password User's password
173
+ * @param {string} token Invitation token provided to the user
174
+ * @returns {Promise<object>}
168
175
  */
169
- export const createUserAccount = (
170
- email,
171
- firstName,
172
- lastName,
173
- password,
174
- token
175
- ) => {
176
- return new Promise(function (resolve, reject) {
176
+ const createUserAccount = (
177
+ email: string,
178
+ firstName: string,
179
+ lastName: string,
180
+ password: string,
181
+ token: string
182
+ ): Promise<object> => {
183
+ return new Promise((resolve, reject) => {
177
184
  if (
178
185
  email.trim() === "" ||
179
186
  firstName.trim() === "" ||
@@ -204,11 +211,12 @@ export const createUserAccount = (
204
211
 
205
212
  /**
206
213
  * Delete an existing API token
207
- * @param {String} token Expiration date of the token
208
- * @param {String} authToken Authorization token
214
+ * @param {string} token Expiration date of the token
215
+ * @param {string} authToken Authorization token
216
+ * @returns {Promise<string>}
209
217
  */
210
- export const deleteAPIToken = (token, authToken) => {
211
- return new Promise(function (resolve, reject) {
218
+ const deleteAPIToken = (token: string, authToken: string): Promise<string> => {
219
+ return new Promise((resolve, reject) => {
212
220
  const deleteTokenRequest = client.delete(`api/v1/users/user/token`, {
213
221
  headers: { authorization: authToken },
214
222
  data: {
@@ -227,13 +235,14 @@ export const deleteAPIToken = (token, authToken) => {
227
235
 
228
236
  /**
229
237
  * Delete existing users
230
- * @param {Array<String>} userIds The ID of the users to be deleted
231
- * @param {String} authToken Authorization token
238
+ * @param {string[]} userIds The ID of the users to be deleted
239
+ * @param {string} token Authorization token
240
+ * @returns {Promise<object>}
232
241
  */
233
- export const deleteUsers = (userIds, authToken) => {
234
- return new Promise(function (resolve, reject) {
242
+ const deleteUsers = (userIds: string[], token: string): Promise<object> => {
243
+ return new Promise((resolve, reject) => {
235
244
  const deleteTokenRequest = client.delete(`api/v1/users/`, {
236
- headers: { authorization: authToken },
245
+ headers: { authorization: token },
237
246
  data: {
238
247
  userIds: userIds,
239
248
  },
@@ -250,12 +259,13 @@ export const deleteUsers = (userIds, authToken) => {
250
259
 
251
260
  /**
252
261
  * Get all the API tokens
253
- * @param {String} authToken Authorization token
262
+ * @param {string} token Authorization token
263
+ * @returns {Promise<object>}
254
264
  */
255
- export const getAPITokens = (authToken) => {
256
- return new Promise(function (resolve, reject) {
265
+ const getAPITokens = (token: string): Promise<object> => {
266
+ return new Promise((resolve, reject) => {
257
267
  const getTokensRequest = client.get(`api/v1/users/getapitokens`, {
258
- headers: { authorization: authToken },
268
+ headers: { authorization: token },
259
269
  });
260
270
  getTokensRequest
261
271
  .then((result) => {
@@ -269,11 +279,15 @@ export const getAPITokens = (authToken) => {
269
279
 
270
280
  /**
271
281
  * Get the specified user account by Id. It returns a promise
272
- * @param {String} id Id of the user for which information is being requested
282
+ * @param {string} id Id of the user for which information is being requested
283
+ * @param {string} token Authorization token
284
+ * @returns {Promise<object>}
273
285
  */
274
- export const getUserById = (id) => {
275
- return new Promise(function (resolve, reject) {
276
- const getUserInformationRequest = client.get(`api/v1/users/user/${id}`);
286
+ const getUserById = (id: string, token: string): Promise<object> => {
287
+ return new Promise((resolve, reject) => {
288
+ const getUserInformationRequest = client.get(`api/v1/users/user/${id}`, {
289
+ headers: { authorization: token },
290
+ });
277
291
  getUserInformationRequest
278
292
  .then((result) => {
279
293
  if (result != null) {
@@ -290,14 +304,15 @@ export const getUserById = (id) => {
290
304
 
291
305
  /**
292
306
  * Get user information
293
- * @param {String} userId User Id
294
- * @param {String} category User information category
295
- * @param {String} token Authorization token
307
+ * @param {string} userId User Id
308
+ * @param {string} category User information category
309
+ * @param {string} token Authorization token
310
+ * @returns {Promise<object>}
296
311
  */
297
- export const getUserInformation = (userId, category, token) => {
298
- return new Promise(function (resolve, reject) {
312
+ const getUserInformation = (userId: string, category: string, token: string): Promise<object> => {
313
+ return new Promise((resolve, reject) => {
299
314
  let confirmationRequest = client.get(
300
- `api/v1/users/user/${userId ? userId : 0}/${category ? category : "*"}`,
315
+ `api/v1/users/user/${userId || 0}/${category || "*"}`,
301
316
  {
302
317
  headers: { authorization: token },
303
318
  }
@@ -314,12 +329,13 @@ export const getUserInformation = (userId, category, token) => {
314
329
 
315
330
  /**
316
331
  * Get the list of users
317
- * @param {Object} filter Filter to select the users. Ex: {firstName : "John"}
318
- * @param {Array} fields Fields to be loaded. Ex: ["firstName"]
319
- * @param {String} token Authorization token
332
+ * @param {object} filter Filter to select the users. Ex: {firstName : "John"}
333
+ * @param {string[]} fields Fields to be loaded. Ex: ["firstName"]
334
+ * @param {string} token Authorization token
335
+ * @returns {Promise<object>}
320
336
  */
321
- export const getUsers = (filter, fields, token) => {
322
- return new Promise(function (resolve, reject) {
337
+ const getUsers = (filter: object, fields: string[], token: string): Promise<object> => {
338
+ return new Promise((resolve, reject) => {
323
339
  const requestData = {
324
340
  filter: filter,
325
341
  fields: fields,
@@ -339,13 +355,14 @@ export const getUsers = (filter, fields, token) => {
339
355
 
340
356
  /**
341
357
  * Invite other users to join the same account
342
- * @param {Array<String>} invitees List of emails of the invitees
343
- * @param {String} groupId The group the user should be added to
344
- * @param {String} teamId The team the user should be added to
345
- * @param {String} token Authorization token
358
+ * @param {string[]} invitees List of emails of the invitees
359
+ * @param {string} groupId The group the user should be added to
360
+ * @param {string} teamId The team the user should be added to
361
+ * @param {string} authToken Authorization token
362
+ * @returns {Promise<object>}
346
363
  */
347
- export const inviteUsers = (invitees, groupId, teamId, authToken) => {
348
- return new Promise(function (resolve, reject) {
364
+ const inviteUsers = (invitees: string[], groupId: string, teamId: string, authToken: string): Promise<object> => {
365
+ return new Promise((resolve, reject) => {
349
366
  const requestData = {
350
367
  invitees: invitees,
351
368
  groupId: groupId,
@@ -367,16 +384,15 @@ export const inviteUsers = (invitees, groupId, teamId, authToken) => {
367
384
 
368
385
  /**
369
386
  * Login using email and password. It returns a promise
370
- * @param {String} email User's email address
371
- * @param {String} password User's password
372
- * @param {boolean} rememberMe Set to true if the user wants his account to be saved on the current machine
387
+ * @param {string} email User's email address
388
+ * @param {string} password User's password
389
+ * @returns {Promise<object>}
373
390
  */
374
- export const login = (email, password, rememberMe) => {
375
- return new Promise(function (resolve, reject) {
391
+ const login = (email: string, password: string): Promise<object> => {
392
+ return new Promise((resolve, reject) => {
376
393
  const requestData = {
377
394
  email: email,
378
395
  password: password,
379
- rememberMe: rememberMe,
380
396
  };
381
397
  let request = client.post("api/v1/auth/login", requestData);
382
398
  request
@@ -390,15 +406,44 @@ export const login = (email, password, rememberMe) => {
390
406
  };
391
407
 
392
408
  /**
393
- * Logout from the server. It returns a promise
394
- * @param {String} token Authorization token
409
+ * Login callback after authentication to exchange the code token for authentication and refresh tokens
410
+ * @param {string} code
411
+ * @param {string} codeVerifier
412
+ * @param {string} redirectUri
413
+ * @returns {Promise<object>}
395
414
  */
396
- export const logout = (token) => {
397
- return new Promise(function (resolve, reject) {
398
- const options = {
399
- headers: { authorization: token },
415
+ const loginExchangeKeys = (code: string, codeVerifier: string, redirectUri: string): Promise<object> => {
416
+ return new Promise((resolve, reject) => {
417
+ const requestData = {
418
+ code: code,
419
+ codeVerifier: codeVerifier,
420
+ redirectUri: redirectUri,
400
421
  };
401
- let request = client.post("api/v1/auth/logout", {}, options);
422
+ let request = client.post("api/v1/auth/loginexchangekeys", requestData);
423
+ request
424
+ .then((response) => {
425
+ resolve(response.data);
426
+ })
427
+ .catch((error) => {
428
+ reject(error);
429
+ });
430
+ });
431
+ };
432
+
433
+ /**
434
+ * Logout from the server. It returns a promise
435
+ * @param {string} token Authorization token
436
+ * @returns {Promise<object>}
437
+ */
438
+ const logout = (token: string): Promise<object> => {
439
+ return new Promise((resolve, reject) => {
440
+ let request = client.post(
441
+ "api/v1/auth/logout",
442
+ {},
443
+ {
444
+ headers: { authorization: token },
445
+ }
446
+ );
402
447
  request
403
448
  .then((response) => {
404
449
  resolve(response.data);
@@ -412,12 +457,14 @@ export const logout = (token) => {
412
457
  /**
413
458
  * Checks the current auth token and maintain it alive. It returns a promise. In case the token is invalid
414
459
  * a new token can be restablished using login
415
- * @param {String} token User's auth token to be refreshed
460
+ * @param {string} refreshToken User's auth token to be refreshed
461
+ * @returns {Promise<object>}
416
462
  */
417
- export const refreshToken = (token) => {
418
- return new Promise(function (resolve, reject) {
419
- let options = { headers: { Authorization: token } };
420
- let request = client.post("api/v1/auth/refreshToken", {}, options);
463
+ const refreshToken = (refreshToken: string): Promise<object> => {
464
+ return new Promise((resolve, reject) => {
465
+ let request = client.post("api/v1/auth/refreshToken", {
466
+ refreshToken: refreshToken,
467
+ });
421
468
  request
422
469
  .then((response) => {
423
470
  resolve(response.data);
@@ -430,11 +477,12 @@ export const refreshToken = (token) => {
430
477
 
431
478
  /**
432
479
  * Remove an existing API token
433
- * @param {String} id The ID of the token to be removed
434
- * @param {String} authToken Authorization token
480
+ * @param {string} id The ID of the token to be removed
481
+ * @param {string} authToken Authorization token
482
+ * @returns {Promise<string>}
435
483
  */
436
- export const removeAPIToken = (id, authToken) => {
437
- return new Promise(function (resolve, reject) {
484
+ const removeAPIToken = (id: string, authToken: string): Promise<string> => {
485
+ return new Promise((resolve, reject) => {
438
486
  const requestData = {
439
487
  id: id,
440
488
  };
@@ -457,11 +505,12 @@ export const removeAPIToken = (id, authToken) => {
457
505
 
458
506
  /**
459
507
  * Resend invitation emails
460
- * @param {Array<String>} invitees List of emails of the invitees
461
- * @param {String} token Authorization token
508
+ * @param {string[]} invitees List of emails of the invitees
509
+ * @param {string} authToken Authorization token
510
+ * @returns {Promise<object>}
462
511
  */
463
- export const resendInvitationEmails = (invitees, authToken) => {
464
- return new Promise(function (resolve, reject) {
512
+ const resendInvitationEmails = (invitees: string[], authToken: string): Promise<object> => {
513
+ return new Promise((resolve, reject) => {
465
514
  const requestData = {
466
515
  invitees: invitees,
467
516
  token: authToken,
@@ -481,12 +530,13 @@ export const resendInvitationEmails = (invitees, authToken) => {
481
530
 
482
531
  /**
483
532
  * Reset the password. It returns a promise
484
- * @param {String} code Code provided to the user by email
485
- * @param {String} email User's email address
486
- * @param {String} password User's new password
533
+ * @param {string} code Code provided to the user by email
534
+ * @param {string} email User's email address
535
+ * @param {string} password User's new password
536
+ * @returns {Promise<object>}
487
537
  */
488
- export const resetPassword = (email, code, password) => {
489
- return new Promise(function (resolve, reject) {
538
+ const resetPassword = (email: string, code: string, password: string): Promise<object> => {
539
+ return new Promise((resolve, reject) => {
490
540
  let postData = {
491
541
  email: email,
492
542
  code: code,
@@ -503,12 +553,41 @@ export const resetPassword = (email, code, password) => {
503
553
  });
504
554
  };
505
555
 
556
+ /**
557
+ * Send email confirmation code
558
+ * @param {string} email
559
+ * @param {string} token
560
+ * @returns {Promise<object>}
561
+ */
562
+ const sendEmailConfirmationCode = (email: string, token: string): Promise<object> => {
563
+ return new Promise((resolve, reject) => {
564
+ let postData = {
565
+ email: email,
566
+ };
567
+ let request = client.post(
568
+ "api/v1/users/sendemailconfirmationcode",
569
+ postData,
570
+ {
571
+ headers: { authorization: token },
572
+ }
573
+ );
574
+ request
575
+ .then((response) => {
576
+ resolve(response.data);
577
+ })
578
+ .catch((error) => {
579
+ reject(error);
580
+ });
581
+ });
582
+ };
583
+
506
584
  /**
507
585
  * Send an email to the user indicated by the email address to reset the password. It returns a promise
508
- * @param {String} email Email of the user who needs to reset the password
586
+ * @param {string} email Email of the user who needs to reset the password
587
+ * @returns {Promise<object>}
509
588
  */
510
- export const sendPasswordResetNotification = (email) => {
511
- return new Promise(function (resolve, reject) {
589
+ const sendPasswordResetNotification = (email: string): Promise<object> => {
590
+ return new Promise((resolve, reject) => {
512
591
  let postData = {
513
592
  email: email,
514
593
  };
@@ -528,13 +607,14 @@ export const sendPasswordResetNotification = (email) => {
528
607
 
529
608
  /**
530
609
  * Set user profile information
531
- * @param {String} userId User Id
532
- * @param {String} category User information category
533
- * @param {String} data New or updated user data information
534
- * @param {Object} token Authorization token
610
+ * @param {string} userId User Id
611
+ * @param {string} category User information category
612
+ * @param {object} data New or updated user data information
613
+ * @param {string} token Authorization token
614
+ * @returns {Promise<object>}
535
615
  */
536
- export const setUserInformation = (userId, category, data, token) => {
537
- return new Promise(function (resolve, reject) {
616
+ const setUserInformation = (userId: string, category: string, data: object, token: string): Promise<object> => {
617
+ return new Promise((resolve, reject) => {
538
618
  const requestData = {
539
619
  data: category ? { [category]: data } : data,
540
620
  userId: userId,
@@ -554,14 +634,22 @@ export const setUserInformation = (userId, category, data, token) => {
554
634
 
555
635
  /**
556
636
  * Update user email
557
- * @param {String} email The new email address
558
- * @param {String} password The current password
559
- * @param {String} token Authorization token
637
+ * @param {string} email The new email address
638
+ * @param {string} verificationCode The verification code
639
+ * @param {string} password The current password
640
+ * @param {string} token Authorization token
641
+ * @returns {Promise<object>}
560
642
  */
561
- export const updateUserEmail = (email, password, token) => {
562
- return new Promise(function (resolve, reject) {
643
+ const updateUserEmail = (
644
+ email: string,
645
+ verificationCode: string,
646
+ password: string,
647
+ token: string
648
+ ): Promise<object> => {
649
+ return new Promise((resolve, reject) => {
563
650
  const requestData = {
564
651
  email: email,
652
+ verificationCode: verificationCode,
565
653
  password: password,
566
654
  };
567
655
  let confirmationRequest = client.post(
@@ -583,12 +671,17 @@ export const updateUserEmail = (email, password, token) => {
583
671
 
584
672
  /**
585
673
  * Update user groups
586
- * @param {String} userIds The id of the user
674
+ * @param {String} userId The id of the user
587
675
  * @param {Array<String>} groups The id of the groups the user should belong to
588
676
  * @param {String} token Authorization token
677
+ * @returns {Promise<Object>}
589
678
  */
590
- export const updateUserGroups = (userId, groups, token) => {
591
- return new Promise(function (resolve, reject) {
679
+ const updateUserGroups = (
680
+ userId: string,
681
+ groups: string[],
682
+ token: string
683
+ ): Promise<object> => {
684
+ return new Promise((resolve, reject) => {
592
685
  const requestData = {
593
686
  userId: userId,
594
687
  groups: groups || [],
@@ -615,9 +708,14 @@ export const updateUserGroups = (userId, groups, token) => {
615
708
  * @param {String} password The current password
616
709
  * @param {String} newPassword The new password
617
710
  * @param {String} token Authorization token
711
+ * @returns {Promise<Object>}
618
712
  */
619
- export const updateUserPassword = (password, newPassword, token) => {
620
- return new Promise(function (resolve, reject) {
713
+ const updateUserPassword = (
714
+ password: string,
715
+ newPassword: string,
716
+ token: string
717
+ ): Promise<object> => {
718
+ return new Promise((resolve, reject) => {
621
719
  const requestData = {
622
720
  password: password,
623
721
  newPassword: newPassword,
@@ -643,17 +741,18 @@ export const updateUserPassword = (password, newPassword, token) => {
643
741
  * Validate reset password code. It returns a promise
644
742
  * @param {String} email User's email address
645
743
  * @param {String} code Provided reset code
744
+ * @returns {Promise<Object>}
646
745
  */
647
- export const validateResetPasswordCode = (email, code) => {
648
- return new Promise(function (resolve, reject) {
746
+ const validateResetPasswordCode = (
747
+ email: string,
748
+ code: string
749
+ ): Promise<object> => {
750
+ return new Promise((resolve, reject) => {
649
751
  let postData = {
650
752
  email: email,
651
753
  code: code,
652
754
  };
653
- let request = client.post(
654
- "api/v1/users/validateresetpasswordcode",
655
- postData
656
- );
755
+ let request = client.post("api/v1/users/validateresetpasswordcode", postData);
657
756
  request
658
757
  .then((response) => {
659
758
  resolve(response.data);
@@ -664,7 +763,7 @@ export const validateResetPasswordCode = (email, code) => {
664
763
  });
665
764
  };
666
765
 
667
- const users = {
766
+ export default {
668
767
  addAPIToken,
669
768
  confirmEmailAddress,
670
769
  confirmPhone,
@@ -679,17 +778,17 @@ const users = {
679
778
  getUsers,
680
779
  inviteUsers,
681
780
  login,
781
+ loginExchangeKeys,
682
782
  logout,
683
783
  refreshToken,
684
784
  removeAPIToken,
685
785
  resendInvitationEmails,
686
786
  resetPassword,
787
+ sendEmailConfirmationCode,
687
788
  sendPasswordResetNotification,
688
789
  setUserInformation,
689
790
  updateUserEmail,
690
791
  updateUserGroups,
691
792
  updateUserPassword,
692
793
  validateResetPasswordCode,
693
- };
694
-
695
- export default users;
794
+ };