@stackfactor/client-api 1.1.128 → 1.1.129
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/lib/{actionNotifications.js → actionNotifications.ts} +18 -6
- package/lib/{address.js → address.ts} +3 -2
- package/lib/{aiAssistant.js → aiAssistant.ts} +58 -25
- package/lib/{avatar.js → avatar.ts} +10 -4
- package/lib/axiosClient.ts +92 -0
- package/lib/{config.js → config.ts} +19 -6
- package/lib/{constants.js → constants.ts} +6 -41
- package/lib/{dashboard.js → dashboard.ts} +17 -7
- package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +57 -23
- package/lib/{groups.js → groups.ts} +67 -26
- package/lib/{integration.js → integration.ts} +100 -43
- package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +25 -8
- package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
- package/lib/{learningContent.js → learningContent.ts} +127 -66
- package/lib/{learningPath.js → learningPath.ts} +56 -29
- package/lib/{logger.js → logger.ts} +17 -5
- package/lib/{microSkillsQuizes.js → microSkillsQuizes.ts} +15 -6
- package/lib/{quotas.js → quotas.ts} +10 -5
- package/lib/{role.js → role.ts} +114 -66
- package/lib/{roleTemplate.js → roleTemplate.ts} +63 -28
- package/lib/{security.js → security.ts} +14 -10
- package/lib/{skill.js → skill.ts} +119 -82
- package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +39 -17
- package/lib/skillAssessments.ts +192 -0
- package/lib/{skillTemplate.js → skillTemplate.ts} +70 -39
- package/lib/{talentTransfromation.js → talentTransfromation.ts} +21 -15
- package/lib/{teams.js → teams.ts} +71 -27
- package/lib/{tenants.js → tenants.ts} +16 -7
- package/lib/{trainingPlans.js → trainingPlans.ts} +96 -59
- package/lib/{trainingPlansProficiencyLevels.js → trainingPlansProficiencyLevels.ts} +29 -23
- package/lib/{userInformation.js → userInformation.ts} +25 -12
- package/lib/{users.js → users.ts} +172 -154
- package/lib/{utils.js → utils.ts} +6 -6
- package/package.json +3 -1
- package/lib/axiosClient.js +0 -82
- package/lib/skillAssessmentTestingSession.js +0 -147
- /package/{exports.js → exports.ts} +0 -0
- /package/{index.js → index.ts} +0 -0
|
@@ -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 {
|
|
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(
|
|
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 {
|
|
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(
|
|
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 {
|
|
64
|
-
* @param {
|
|
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(
|
|
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 {
|
|
92
|
-
* @param {
|
|
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(
|
|
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 {
|
|
120
|
-
* @param {
|
|
121
|
-
* @param {
|
|
122
|
-
* @param {
|
|
123
|
-
* @param {
|
|
124
|
-
* @param {
|
|
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(
|
|
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 {
|
|
169
|
-
* @param {
|
|
170
|
-
* @param {
|
|
171
|
-
* @param {
|
|
172
|
-
* @param {
|
|
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 = (
|
|
176
|
-
|
|
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 {
|
|
208
|
-
* @param {
|
|
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(
|
|
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 {
|
|
233
|
-
* @param {
|
|
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(
|
|
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 {
|
|
258
|
-
* @returns {Promise}
|
|
262
|
+
* @param {string} token Authorization token
|
|
263
|
+
* @returns {Promise<object>}
|
|
259
264
|
*/
|
|
260
|
-
const getAPITokens = (token) => {
|
|
261
|
-
return new Promise(
|
|
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 {
|
|
278
|
-
* @param {
|
|
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(
|
|
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 {
|
|
303
|
-
* @param {
|
|
304
|
-
* @param {
|
|
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(
|
|
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 {
|
|
328
|
-
* @param {
|
|
329
|
-
* @param {
|
|
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(
|
|
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 {
|
|
354
|
-
* @param {
|
|
355
|
-
* @param {
|
|
356
|
-
* @param {
|
|
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(
|
|
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 {
|
|
383
|
-
* @param {
|
|
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(
|
|
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 {
|
|
406
|
-
* @param {
|
|
407
|
-
* @param {
|
|
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(
|
|
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 {
|
|
431
|
-
* @returns {Promise}
|
|
435
|
+
* @param {string} token Authorization token
|
|
436
|
+
* @returns {Promise<object>}
|
|
432
437
|
*/
|
|
433
|
-
const logout = (token) => {
|
|
434
|
-
return new Promise(
|
|
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 {
|
|
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(
|
|
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 {
|
|
476
|
-
* @param {
|
|
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(
|
|
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 {
|
|
504
|
-
* @param {
|
|
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(
|
|
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 {
|
|
529
|
-
* @param {
|
|
530
|
-
* @param {
|
|
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(
|
|
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 {
|
|
554
|
-
* @param {
|
|
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(
|
|
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 {
|
|
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(
|
|
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 {
|
|
606
|
-
* @param {
|
|
607
|
-
* @param {
|
|
608
|
-
* @param {
|
|
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(
|
|
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 {
|
|
633
|
-
* @param {
|
|
634
|
-
* @param {
|
|
635
|
-
* @param {
|
|
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 = (
|
|
639
|
-
|
|
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}
|
|
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 = (
|
|
670
|
-
|
|
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 = (
|
|
700
|
-
|
|
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 = (
|
|
729
|
-
|
|
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
|
|
51
|
+
let value = object[key];
|
|
52
52
|
let hasProperties = value && Object.keys(value).length > 0;
|
|
53
53
|
if (value === null) {
|
|
54
|
-
delete object[key
|
|
54
|
+
delete object[key];
|
|
55
55
|
} else if (typeof value !== "string" && hasProperties) {
|
|
56
56
|
removeNullProperties(value);
|
|
57
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackfactor/client-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.129",
|
|
4
4
|
"description": "Node.js library for the StackFactor API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -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
|
}
|