@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.
Files changed (40) hide show
  1. package/exports.ts +85 -0
  2. package/index.ts +1 -0
  3. package/lib/{actionNotifications.js → actionNotifications.ts} +18 -6
  4. package/lib/{address.js → address.ts} +3 -2
  5. package/lib/{aiAssistant.js → aiAssistant.ts} +58 -25
  6. package/lib/{avatar.js → avatar.ts} +10 -4
  7. package/lib/axiosClient.ts +92 -0
  8. package/lib/{config.js → config.ts} +19 -6
  9. package/lib/{constants.js → constants.ts} +6 -41
  10. package/lib/{dashboard.js → dashboard.ts} +17 -7
  11. package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +57 -23
  12. package/lib/{groups.js → groups.ts} +67 -26
  13. package/lib/{integration.js → integration.ts} +100 -43
  14. package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +25 -8
  15. package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
  16. package/lib/{learningContent.js → learningContent.ts} +127 -66
  17. package/lib/{learningPath.js → learningPath.ts} +56 -29
  18. package/lib/{logger.js → logger.ts} +17 -5
  19. package/lib/{microSkillsQuizes.js → microSkillsQuizes.ts} +15 -6
  20. package/lib/{quotas.js → quotas.ts} +10 -5
  21. package/lib/{role.js → role.ts} +114 -66
  22. package/lib/{roleTemplate.js → roleTemplate.ts} +63 -28
  23. package/lib/{security.js → security.ts} +14 -10
  24. package/lib/{skill.js → skill.ts} +119 -82
  25. package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +39 -17
  26. package/lib/skillAssessments.ts +192 -0
  27. package/lib/{skillTemplate.js → skillTemplate.ts} +70 -39
  28. package/lib/{talentTransfromation.js → talentTransfromation.ts} +21 -15
  29. package/lib/{teams.js → teams.ts} +71 -27
  30. package/lib/{tenants.js → tenants.ts} +16 -7
  31. package/lib/{trainingPlans.js → trainingPlans.ts} +96 -59
  32. package/lib/{trainingPlansProficiencyLevels.js → trainingPlansProficiencyLevels.ts} +29 -23
  33. package/lib/{userInformation.js → userInformation.ts} +25 -12
  34. package/lib/{users.js → users.ts} +172 -154
  35. package/lib/{utils.js → utils.ts} +6 -6
  36. package/package.json +8 -6
  37. package/exports.js +0 -85
  38. package/index.js +0 -1
  39. package/lib/axiosClient.js +0 -82
  40. package/lib/skillAssessmentTestingSession.js +0 -147
@@ -3,12 +3,13 @@ import { client } from "./axiosClient.js";
3
3
 
4
4
  /**
5
5
  * Add a new API Token
6
+ * @param {string} name Name of the token
6
7
  * @param {Date} expiration Expiration date of the token
7
- * @param {String} token Authorization token
8
- * @returns {Promise}
8
+ * @param {string} token Authorization token
9
+ * @returns {Promise<object>}
9
10
  */
10
- const addAPIToken = (name, expiration, token) => {
11
- return new Promise(function (resolve, reject) {
11
+ const addAPIToken = (name: string, expiration: Date, token: string): Promise<object> => {
12
+ return new Promise((resolve, reject) => {
12
13
  const requestData = {
13
14
  name: name,
14
15
  expiration: expiration,
@@ -36,11 +37,11 @@ const addAPIToken = (name, expiration, token) => {
36
37
 
37
38
  /**
38
39
  * Confirm email address
39
- * @param {String} validationCode The code was provided to the user in advance by email
40
- * @returns {Promise}
40
+ * @param {string} validationCode The code was provided to the user in advance by email
41
+ * @returns {Promise<void>}
41
42
  */
42
- const confirmEmailAddress = (validationCode) => {
43
- return new Promise(function (resolve, reject) {
43
+ const confirmEmailAddress = (validationCode: string): Promise<void> => {
44
+ return new Promise((resolve, reject) => {
44
45
  const requestData = {
45
46
  validationCode: validationCode,
46
47
  };
@@ -60,12 +61,12 @@ const confirmEmailAddress = (validationCode) => {
60
61
 
61
62
  /**
62
63
  * Confirm phone number
63
- * @param {String} validationCode The code was provided to the user in advance by email
64
- * @param {String} token Authorization token
65
- * @returns {Promise}
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>}
66
67
  */
67
- const confirmPhone = (validationCode, token) => {
68
- return new Promise(function (resolve, reject) {
68
+ const confirmPhone = (validationCode: string, token: string): Promise<object> => {
69
+ return new Promise((resolve, reject) => {
69
70
  const requestData = {
70
71
  validationCode: validationCode,
71
72
  };
@@ -88,12 +89,12 @@ const confirmPhone = (validationCode, token) => {
88
89
 
89
90
  /**
90
91
  * Generate confirmation code
91
- * @param {String} phoneNumber Send confirmation code to the phone number
92
- * @param {String} token Authorization token
93
- * @returns {Promise}
92
+ * @param {string} phoneNumber Send confirmation code to the phone number
93
+ * @param {string} token Authorization token
94
+ * @returns {Promise<object>}
94
95
  */
95
- const confirmPhoneGenerateCode = (phoneNumber, token) => {
96
- return new Promise(function (resolve, reject) {
96
+ const confirmPhoneGenerateCode = (phoneNumber: string, token: string): Promise<object> => {
97
+ return new Promise((resolve, reject) => {
97
98
  const requestData = {
98
99
  phoneNumber: phoneNumber,
99
100
  };
@@ -116,23 +117,23 @@ const confirmPhoneGenerateCode = (phoneNumber, token) => {
116
117
 
117
118
  /**
118
119
  * Create a new account (tenant). It returns a promise
119
- * @param {String} email User's email address
120
- * @param {String} firstName User's first name
121
- * @param {String} lastName User's last name
122
- * @param {String} password User's password
123
- * @param {String} subSite Subsite where the new account will be created
124
- * @param {String} inviteCode Invitation code received in advance from one of the account owners
125
- * @returns {Promise}
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>}
126
127
  */
127
128
  const createAccount = (
128
- email,
129
- firstName,
130
- lastName,
131
- password,
132
- subSite,
133
- inviteCode
134
- ) => {
135
- return new Promise(function (resolve, reject) {
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) => {
136
137
  if (
137
138
  email.trim() === "" ||
138
139
  firstName.trim() === "" ||
@@ -165,15 +166,21 @@ const createAccount = (
165
166
 
166
167
  /**
167
168
  * Create a new user account. It returns a promise
168
- * @param {String} email User's email address
169
- * @param {String} firstName User's first name
170
- * @param {String} lastName User's last name
171
- * @param {String} password User's password
172
- * @param {String} token Invitation token provided to the user
173
- * @returns {Promise}
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>}
174
175
  */
175
- const createUserAccount = (email, firstName, lastName, password, token) => {
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,15 +211,14 @@ const createUserAccount = (email, firstName, lastName, password, token) => {
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
209
- * @returns {Promise}
214
+ * @param {string} token Expiration date of the token
215
+ * @param {string} authToken Authorization token
216
+ * @returns {Promise<string>}
210
217
  */
211
- const deleteAPIToken = (token, authToken) => {
212
- return new Promise(function (resolve, reject) {
218
+ const deleteAPIToken = (token: string, authToken: string): Promise<string> => {
219
+ return new Promise((resolve, reject) => {
213
220
  const deleteTokenRequest = client.delete(`api/v1/users/user/token`, {
214
221
  headers: { authorization: authToken },
215
-
216
222
  data: {
217
223
  token: token,
218
224
  },
@@ -229,15 +235,14 @@ const deleteAPIToken = (token, authToken) => {
229
235
 
230
236
  /**
231
237
  * Delete existing users
232
- * @param {Array<String>} userIds The ID of the users to be deleted
233
- * @param {String} token Authorization token
234
- * @returns {Promise}
238
+ * @param {string[]} userIds The ID of the users to be deleted
239
+ * @param {string} token Authorization token
240
+ * @returns {Promise<object>}
235
241
  */
236
- const deleteUsers = (userIds, token) => {
237
- return new Promise(function (resolve, reject) {
242
+ const deleteUsers = (userIds: string[], token: string): Promise<object> => {
243
+ return new Promise((resolve, reject) => {
238
244
  const deleteTokenRequest = client.delete(`api/v1/users/`, {
239
245
  headers: { authorization: token },
240
-
241
246
  data: {
242
247
  userIds: userIds,
243
248
  },
@@ -254,11 +259,11 @@ const deleteUsers = (userIds, token) => {
254
259
 
255
260
  /**
256
261
  * Get all the API tokens
257
- * @param {String} token Authorization token
258
- * @returns {Promise}
262
+ * @param {string} token Authorization token
263
+ * @returns {Promise<object>}
259
264
  */
260
- const getAPITokens = (token) => {
261
- return new Promise(function (resolve, reject) {
265
+ const getAPITokens = (token: string): Promise<object> => {
266
+ return new Promise((resolve, reject) => {
262
267
  const getTokensRequest = client.get(`api/v1/users/getapitokens`, {
263
268
  headers: { authorization: token },
264
269
  });
@@ -274,12 +279,12 @@ const getAPITokens = (token) => {
274
279
 
275
280
  /**
276
281
  * Get the specified user account by Id. It returns a promise
277
- * @param {String} id Id of the user for which information is being requested
278
- * @param {String} token Authorization token
279
- * @returns {Promise}
282
+ * @param {string} id Id of the user for which information is being requested
283
+ * @param {string} token Authorization token
284
+ * @returns {Promise<object>}
280
285
  */
281
- const getUserById = (id, token) => {
282
- return new Promise(function (resolve, reject) {
286
+ const getUserById = (id: string, token: string): Promise<object> => {
287
+ return new Promise((resolve, reject) => {
283
288
  const getUserInformationRequest = client.get(`api/v1/users/user/${id}`, {
284
289
  headers: { authorization: token },
285
290
  });
@@ -299,13 +304,13 @@ const getUserById = (id, token) => {
299
304
 
300
305
  /**
301
306
  * Get user information
302
- * @param {String} userId User Id
303
- * @param {String} category User information category
304
- * @param {String} token Authorization token
305
- * @returns {Promise}
307
+ * @param {string} userId User Id
308
+ * @param {string} category User information category
309
+ * @param {string} token Authorization token
310
+ * @returns {Promise<object>}
306
311
  */
307
- const getUserInformation = (userId, category, token) => {
308
- return new Promise(function (resolve, reject) {
312
+ const getUserInformation = (userId: string, category: string, token: string): Promise<object> => {
313
+ return new Promise((resolve, reject) => {
309
314
  let confirmationRequest = client.get(
310
315
  `api/v1/users/user/${userId || 0}/${category || "*"}`,
311
316
  {
@@ -324,13 +329,13 @@ const getUserInformation = (userId, category, token) => {
324
329
 
325
330
  /**
326
331
  * Get the list of users
327
- * @param {Object} filter Filter to select the users. Ex: {firstName : "John"}
328
- * @param {Array} fields Fields to be loaded. Ex: ["firstName"]
329
- * @param {String} token Authorization token
330
- * @returns {Promise}
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>}
331
336
  */
332
- const getUsers = (filter, fields, token) => {
333
- return new Promise(function (resolve, reject) {
337
+ const getUsers = (filter: object, fields: string[], token: string): Promise<object> => {
338
+ return new Promise((resolve, reject) => {
334
339
  const requestData = {
335
340
  filter: filter,
336
341
  fields: fields,
@@ -350,14 +355,14 @@ const getUsers = (filter, fields, token) => {
350
355
 
351
356
  /**
352
357
  * Invite other users to join the same account
353
- * @param {Array<String>} invitees List of emails of the invitees
354
- * @param {String} groupId The group the user should be added to
355
- * @param {String} teamId The team the user should be added to
356
- * @param {String} token Authorization token
357
- * @returns {Promise}
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>}
358
363
  */
359
- const inviteUsers = (invitees, groupId, teamId, authToken) => {
360
- 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) => {
361
366
  const requestData = {
362
367
  invitees: invitees,
363
368
  groupId: groupId,
@@ -379,12 +384,12 @@ const inviteUsers = (invitees, groupId, teamId, authToken) => {
379
384
 
380
385
  /**
381
386
  * Login using email and password. It returns a promise
382
- * @param {String} email User's email address
383
- * @param {String} password User's password
384
- * @returns {Promise}
387
+ * @param {string} email User's email address
388
+ * @param {string} password User's password
389
+ * @returns {Promise<object>}
385
390
  */
386
- const login = (email, password) => {
387
- return new Promise(function (resolve, reject) {
391
+ const login = (email: string, password: string): Promise<object> => {
392
+ return new Promise((resolve, reject) => {
388
393
  const requestData = {
389
394
  email: email,
390
395
  password: password,
@@ -402,13 +407,13 @@ const login = (email, password) => {
402
407
 
403
408
  /**
404
409
  * Login callback after authentication to exchange the code token for authentication and refresh tokens
405
- * @param {String} code
406
- * @param {String} codeVerifier
407
- * @param {String} redirectUri
408
- * @returns {Promise}
410
+ * @param {string} code
411
+ * @param {string} codeVerifier
412
+ * @param {string} redirectUri
413
+ * @returns {Promise<object>}
409
414
  */
410
- const loginExchangeKeys = (code, codeVerifier, redirectUri) => {
411
- return new Promise(function (resolve, reject) {
415
+ const loginExchangeKeys = (code: string, codeVerifier: string, redirectUri: string): Promise<object> => {
416
+ return new Promise((resolve, reject) => {
412
417
  const requestData = {
413
418
  code: code,
414
419
  codeVerifier: codeVerifier,
@@ -427,11 +432,11 @@ const loginExchangeKeys = (code, codeVerifier, redirectUri) => {
427
432
 
428
433
  /**
429
434
  * Logout from the server. It returns a promise
430
- * @param {String} token Authorization token
431
- * @returns {Promise}
435
+ * @param {string} token Authorization token
436
+ * @returns {Promise<object>}
432
437
  */
433
- const logout = (token) => {
434
- return new Promise(function (resolve, reject) {
438
+ const logout = (token: string): Promise<object> => {
439
+ return new Promise((resolve, reject) => {
435
440
  let request = client.post(
436
441
  "api/v1/auth/logout",
437
442
  {},
@@ -452,11 +457,11 @@ const logout = (token) => {
452
457
  /**
453
458
  * Checks the current auth token and maintain it alive. It returns a promise. In case the token is invalid
454
459
  * a new token can be restablished using login
455
- * @param {String} token User's auth token to be refreshed
456
- * @returns {Promise}
460
+ * @param {string} refreshToken User's auth token to be refreshed
461
+ * @returns {Promise<object>}
457
462
  */
458
- const refreshToken = (refreshToken) => {
459
- return new Promise(function (resolve, reject) {
463
+ const refreshToken = (refreshToken: string): Promise<object> => {
464
+ return new Promise((resolve, reject) => {
460
465
  let request = client.post("api/v1/auth/refreshToken", {
461
466
  refreshToken: refreshToken,
462
467
  });
@@ -472,12 +477,12 @@ const refreshToken = (refreshToken) => {
472
477
 
473
478
  /**
474
479
  * Remove an existing API token
475
- * @param {String} id The ID of the token to be removed
476
- * @param {String} authToken Authorization token
477
- * @returns {Promise}
480
+ * @param {string} id The ID of the token to be removed
481
+ * @param {string} authToken Authorization token
482
+ * @returns {Promise<string>}
478
483
  */
479
- const removeAPIToken = (id, authToken) => {
480
- return new Promise(function (resolve, reject) {
484
+ const removeAPIToken = (id: string, authToken: string): Promise<string> => {
485
+ return new Promise((resolve, reject) => {
481
486
  const requestData = {
482
487
  id: id,
483
488
  };
@@ -500,12 +505,12 @@ const removeAPIToken = (id, authToken) => {
500
505
 
501
506
  /**
502
507
  * Resend invitation emails
503
- * @param {Array<String>} invitees List of emails of the invitees
504
- * @param {String} token Authorization token
505
- * @returns {Promise}
508
+ * @param {string[]} invitees List of emails of the invitees
509
+ * @param {string} authToken Authorization token
510
+ * @returns {Promise<object>}
506
511
  */
507
- const resendInvitationEmails = (invitees, authToken) => {
508
- return new Promise(function (resolve, reject) {
512
+ const resendInvitationEmails = (invitees: string[], authToken: string): Promise<object> => {
513
+ return new Promise((resolve, reject) => {
509
514
  const requestData = {
510
515
  invitees: invitees,
511
516
  token: authToken,
@@ -525,13 +530,13 @@ const resendInvitationEmails = (invitees, authToken) => {
525
530
 
526
531
  /**
527
532
  * Reset the password. It returns a promise
528
- * @param {String} code Code provided to the user by email
529
- * @param {String} email User's email address
530
- * @param {String} password User's new password
531
- * @returns {Promise}
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>}
532
537
  */
533
- const resetPassword = (email, code, password) => {
534
- return new Promise(function (resolve, reject) {
538
+ const resetPassword = (email: string, code: string, password: string): Promise<object> => {
539
+ return new Promise((resolve, reject) => {
535
540
  let postData = {
536
541
  email: email,
537
542
  code: code,
@@ -550,12 +555,12 @@ const resetPassword = (email, code, password) => {
550
555
 
551
556
  /**
552
557
  * Send email confirmation code
553
- * @param {String} email
554
- * @param {String} token
555
- * @returns
558
+ * @param {string} email
559
+ * @param {string} token
560
+ * @returns {Promise<object>}
556
561
  */
557
- const sendEmailConfirmationCode = (email, token) => {
558
- return new Promise(function (resolve, reject) {
562
+ const sendEmailConfirmationCode = (email: string, token: string): Promise<object> => {
563
+ return new Promise((resolve, reject) => {
559
564
  let postData = {
560
565
  email: email,
561
566
  };
@@ -578,11 +583,11 @@ const sendEmailConfirmationCode = (email, token) => {
578
583
 
579
584
  /**
580
585
  * Send an email to the user indicated by the email address to reset the password. It returns a promise
581
- * @param {String} email Email of the user who needs to reset the password
582
- * @returns {Promise}
586
+ * @param {string} email Email of the user who needs to reset the password
587
+ * @returns {Promise<object>}
583
588
  */
584
- const sendPasswordResetNotification = (email) => {
585
- return new Promise(function (resolve, reject) {
589
+ const sendPasswordResetNotification = (email: string): Promise<object> => {
590
+ return new Promise((resolve, reject) => {
586
591
  let postData = {
587
592
  email: email,
588
593
  };
@@ -602,14 +607,14 @@ const sendPasswordResetNotification = (email) => {
602
607
 
603
608
  /**
604
609
  * Set user profile information
605
- * @param {String} userId User Id
606
- * @param {String} category User information category
607
- * @param {String} data New or updated user data information
608
- * @param {Object} token Authorization token
609
- * @returns {Promise}
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>}
610
615
  */
611
- const setUserInformation = (userId, category, data, token) => {
612
- 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) => {
613
618
  const requestData = {
614
619
  data: category ? { [category]: data } : data,
615
620
  userId: userId,
@@ -629,14 +634,19 @@ const setUserInformation = (userId, category, data, token) => {
629
634
 
630
635
  /**
631
636
  * Update user email
632
- * @param {String} email The new email address
633
- * @param {String} verificationCode The verification code
634
- * @param {String} password The current password
635
- * @param {String} token Authorization token
636
- * @returns {Promise}
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>}
637
642
  */
638
- const updateUserEmail = (email, verificationCode, password, token) => {
639
- 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) => {
640
650
  const requestData = {
641
651
  email: email,
642
652
  verificationCode: verificationCode,
@@ -661,13 +671,17 @@ const updateUserEmail = (email, verificationCode, password, token) => {
661
671
 
662
672
  /**
663
673
  * Update user groups
664
- * @param {String} userIds The id of the user
674
+ * @param {String} userId The id of the user
665
675
  * @param {Array<String>} groups The id of the groups the user should belong to
666
676
  * @param {String} token Authorization token
667
- * @returns {Promise}
677
+ * @returns {Promise<Object>}
668
678
  */
669
- const updateUserGroups = (userId, groups, token) => {
670
- 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) => {
671
685
  const requestData = {
672
686
  userId: userId,
673
687
  groups: groups || [],
@@ -694,10 +708,14 @@ const updateUserGroups = (userId, groups, token) => {
694
708
  * @param {String} password The current password
695
709
  * @param {String} newPassword The new password
696
710
  * @param {String} token Authorization token
697
- * @returns {Promise}
711
+ * @returns {Promise<Object>}
698
712
  */
699
- const updateUserPassword = (password, newPassword, token) => {
700
- 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) => {
701
719
  const requestData = {
702
720
  password: password,
703
721
  newPassword: newPassword,
@@ -723,18 +741,18 @@ const updateUserPassword = (password, newPassword, token) => {
723
741
  * Validate reset password code. It returns a promise
724
742
  * @param {String} email User's email address
725
743
  * @param {String} code Provided reset code
726
- * @returns {Promise}
744
+ * @returns {Promise<Object>}
727
745
  */
728
- const validateResetPasswordCode = (email, code) => {
729
- return new Promise(function (resolve, reject) {
746
+ const validateResetPasswordCode = (
747
+ email: string,
748
+ code: string
749
+ ): Promise<object> => {
750
+ return new Promise((resolve, reject) => {
730
751
  let postData = {
731
752
  email: email,
732
753
  code: code,
733
754
  };
734
- let request = client.post(
735
- "api/v1/users/validateresetpasswordcode",
736
- postData
737
- );
755
+ let request = client.post("api/v1/users/validateresetpasswordcode", postData);
738
756
  request
739
757
  .then((response) => {
740
758
  resolve(response.data);
@@ -773,4 +791,4 @@ export default {
773
791
  updateUserGroups,
774
792
  updateUserPassword,
775
793
  validateResetPasswordCode,
776
- };
794
+ };
@@ -8,9 +8,9 @@
8
8
  * @param {Object} data
9
9
  * @returns {Array}
10
10
  */
11
- const objectToArray = (data) => {
11
+ const objectToArray = (data: object): any[] => {
12
12
  if (typeof data === "object") {
13
- return [...data];
13
+ return [...Object.values(data)];
14
14
  } else throw new Error("Invalid type");
15
15
  };
16
16
 
@@ -18,7 +18,7 @@ const objectToArray = (data) => {
18
18
  * Returns the backend base API URL
19
19
  * @returns {String}
20
20
  */
21
- const getBaseUrl = () => {
21
+ const getBaseUrl = (): string => {
22
22
  if (process.env.REACT_APP_BACKEND_URL) {
23
23
  return process.env.REACT_APP_BACKEND_URL;
24
24
  } else {
@@ -46,12 +46,12 @@ const getBaseUrl = () => {
46
46
  * @param {Object} object
47
47
  * @returns {Object}
48
48
  */
49
- const removeNullProperties = (object) => {
49
+ const removeNullProperties = (object: { [key: string]: any }): object => {
50
50
  Object.keys(object).forEach((key) => {
51
- let value = object[key.toString()];
51
+ let value = object[key];
52
52
  let hasProperties = value && Object.keys(value).length > 0;
53
53
  if (value === null) {
54
- delete object[key.toString()];
54
+ delete object[key];
55
55
  } else if (typeof value !== "string" && hasProperties) {
56
56
  removeNullProperties(value);
57
57
  }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.1.128",
3
+ "version": "1.1.130",
4
4
  "description": "Node.js library for the StackFactor API",
5
- "main": "index.js",
5
+ "main": "index.ts",
6
6
  "exports": {
7
7
  ".": {
8
- "require": "./index.js",
9
- "import": "./index.js",
10
- "default": "./index.js"
8
+ "require": "./index.ts",
9
+ "import": "./index.ts",
10
+ "default": "./index.ts"
11
11
  }
12
12
  },
13
13
  "type": "module",
14
14
  "scripts": {
15
- "lint": "eslint lib/**/*.js",
15
+ "lint": "eslint lib/**/*.ts",
16
16
  "test": "echo \"Error: no test specified\" && exit 1"
17
17
  },
18
18
  "repository": {
@@ -33,6 +33,8 @@
33
33
  "node-html-parser": "^6.1.5"
34
34
  },
35
35
  "devDependencies": {
36
+ "@types/axios": "^0.14.4",
37
+ "@types/node": "^22.13.5",
36
38
  "eslint": "^8.57.0",
37
39
  "eslint-plugin-react": "^7.34.0"
38
40
  }