@stackfactor/client-api 1.1.137 → 1.1.139

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 (306) hide show
  1. package/package.json +4 -4
  2. package/src/lib/actionNotifications.ts +3 -9
  3. package/src/lib/address.ts +1 -3
  4. package/src/lib/aiAssistant.ts +5 -13
  5. package/src/lib/avatar.ts +1 -5
  6. package/src/lib/axiosClient.ts +6 -14
  7. package/src/lib/config.ts +3 -9
  8. package/src/lib/constants.ts +4 -11
  9. package/src/lib/dashboard.ts +3 -9
  10. package/src/lib/departmentTrainingPlans.ts +6 -17
  11. package/src/lib/groups.ts +12 -27
  12. package/src/lib/integration.ts +0 -14
  13. package/src/lib/integrationConfiguration.ts +3 -9
  14. package/src/lib/integrations/contentGenerator.ts +0 -3
  15. package/src/lib/learningContent.ts +15 -33
  16. package/src/lib/learningPath.ts +8 -19
  17. package/src/lib/logger.ts +2 -4
  18. package/src/lib/microSkillsQuizes.ts +2 -7
  19. package/src/lib/quotas.ts +2 -7
  20. package/src/lib/role.ts +14 -31
  21. package/src/lib/roleTemplate.ts +10 -22
  22. package/src/lib/security.ts +4 -11
  23. package/src/lib/skill.ts +19 -40
  24. package/src/lib/skillAssessmentTestingSession.ts +6 -15
  25. package/src/lib/skillAssessments.ts +6 -15
  26. package/src/lib/skillTemplate.ts +11 -25
  27. package/src/lib/talentTransfromation.ts +5 -12
  28. package/src/lib/teams.ts +11 -25
  29. package/src/lib/tenants.ts +2 -4
  30. package/src/lib/trainingPlans.ts +13 -28
  31. package/src/lib/trainingPlansProficiencyLevels.ts +4 -13
  32. package/src/lib/userInformation.ts +4 -10
  33. package/src/lib/users.ts +27 -57
  34. package/src/lib/utils.ts +2 -6
  35. package/dist/cjs/actionNotifications.d.ts +0 -7
  36. package/dist/cjs/actionNotifications.d.ts.map +0 -1
  37. package/dist/cjs/actionNotifications.js +0 -74
  38. package/dist/cjs/actionNotifications.js.map +0 -1
  39. package/dist/cjs/address.d.ts +0 -5
  40. package/dist/cjs/address.d.ts.map +0 -1
  41. package/dist/cjs/address.js +0 -23
  42. package/dist/cjs/address.js.map +0 -1
  43. package/dist/cjs/aiAssistant.d.ts +0 -9
  44. package/dist/cjs/aiAssistant.d.ts.map +0 -1
  45. package/dist/cjs/aiAssistant.js +0 -136
  46. package/dist/cjs/aiAssistant.js.map +0 -1
  47. package/dist/cjs/avatar.d.ts +0 -5
  48. package/dist/cjs/avatar.d.ts.map +0 -1
  49. package/dist/cjs/avatar.js +0 -33
  50. package/dist/cjs/avatar.js.map +0 -1
  51. package/dist/cjs/axiosClient.d.ts +0 -32
  52. package/dist/cjs/axiosClient.d.ts.map +0 -1
  53. package/dist/cjs/axiosClient.js +0 -91
  54. package/dist/cjs/axiosClient.js.map +0 -1
  55. package/dist/cjs/config.d.ts +0 -7
  56. package/dist/cjs/config.d.ts.map +0 -1
  57. package/dist/cjs/config.js +0 -64
  58. package/dist/cjs/config.js.map +0 -1
  59. package/dist/cjs/constants.d.ts +0 -70
  60. package/dist/cjs/constants.d.ts.map +0 -1
  61. package/dist/cjs/constants.js +0 -95
  62. package/dist/cjs/constants.js.map +0 -1
  63. package/dist/cjs/dashboard.d.ts +0 -7
  64. package/dist/cjs/dashboard.d.ts.map +0 -1
  65. package/dist/cjs/dashboard.js +0 -75
  66. package/dist/cjs/dashboard.js.map +0 -1
  67. package/dist/cjs/departmentTrainingPlans.d.ts +0 -13
  68. package/dist/cjs/departmentTrainingPlans.d.ts.map +0 -1
  69. package/dist/cjs/departmentTrainingPlans.js +0 -155
  70. package/dist/cjs/departmentTrainingPlans.js.map +0 -1
  71. package/dist/cjs/groups.d.ts +0 -16
  72. package/dist/cjs/groups.d.ts.map +0 -1
  73. package/dist/cjs/groups.js +0 -274
  74. package/dist/cjs/groups.js.map +0 -1
  75. package/dist/cjs/index.d.ts +0 -33
  76. package/dist/cjs/index.d.ts.map +0 -1
  77. package/dist/cjs/index.js +0 -78
  78. package/dist/cjs/index.js.map +0 -1
  79. package/dist/cjs/integration.d.ts +0 -95
  80. package/dist/cjs/integration.d.ts.map +0 -1
  81. package/dist/cjs/integration.js +0 -329
  82. package/dist/cjs/integration.js.map +0 -1
  83. package/dist/cjs/integrationConfiguration.d.ts +0 -7
  84. package/dist/cjs/integrationConfiguration.d.ts.map +0 -1
  85. package/dist/cjs/integrationConfiguration.js +0 -87
  86. package/dist/cjs/integrationConfiguration.js.map +0 -1
  87. package/dist/cjs/integrations/contentGenerator.d.ts +0 -27
  88. package/dist/cjs/integrations/contentGenerator.d.ts.map +0 -1
  89. package/dist/cjs/integrations/contentGenerator.js +0 -71
  90. package/dist/cjs/integrations/contentGenerator.js.map +0 -1
  91. package/dist/cjs/learningContent.d.ts +0 -19
  92. package/dist/cjs/learningContent.d.ts.map +0 -1
  93. package/dist/cjs/learningContent.js +0 -395
  94. package/dist/cjs/learningContent.js.map +0 -1
  95. package/dist/cjs/learningPath.d.ts +0 -12
  96. package/dist/cjs/learningPath.d.ts.map +0 -1
  97. package/dist/cjs/learningPath.js +0 -206
  98. package/dist/cjs/learningPath.js.map +0 -1
  99. package/dist/cjs/logger.d.ts +0 -6
  100. package/dist/cjs/logger.d.ts.map +0 -1
  101. package/dist/cjs/logger.js +0 -58
  102. package/dist/cjs/logger.js.map +0 -1
  103. package/dist/cjs/microSkillsQuizes.d.ts +0 -6
  104. package/dist/cjs/microSkillsQuizes.d.ts.map +0 -1
  105. package/dist/cjs/microSkillsQuizes.js +0 -54
  106. package/dist/cjs/microSkillsQuizes.js.map +0 -1
  107. package/dist/cjs/quotas.d.ts +0 -6
  108. package/dist/cjs/quotas.d.ts.map +0 -1
  109. package/dist/cjs/quotas.js +0 -51
  110. package/dist/cjs/quotas.js.map +0 -1
  111. package/dist/cjs/role.d.ts +0 -18
  112. package/dist/cjs/role.d.ts.map +0 -1
  113. package/dist/cjs/role.js +0 -364
  114. package/dist/cjs/role.js.map +0 -1
  115. package/dist/cjs/roleTemplate.d.ts +0 -13
  116. package/dist/cjs/roleTemplate.d.ts.map +0 -1
  117. package/dist/cjs/roleTemplate.js +0 -237
  118. package/dist/cjs/roleTemplate.js.map +0 -1
  119. package/dist/cjs/security.d.ts +0 -8
  120. package/dist/cjs/security.d.ts.map +0 -1
  121. package/dist/cjs/security.js +0 -80
  122. package/dist/cjs/security.js.map +0 -1
  123. package/dist/cjs/skill.d.ts +0 -22
  124. package/dist/cjs/skill.d.ts.map +0 -1
  125. package/dist/cjs/skill.js +0 -441
  126. package/dist/cjs/skill.js.map +0 -1
  127. package/dist/cjs/skillAssessmentTestingSession.d.ts +0 -10
  128. package/dist/cjs/skillAssessmentTestingSession.d.ts.map +0 -1
  129. package/dist/cjs/skillAssessmentTestingSession.js +0 -157
  130. package/dist/cjs/skillAssessmentTestingSession.js.map +0 -1
  131. package/dist/cjs/skillAssessments.d.ts +0 -10
  132. package/dist/cjs/skillAssessments.d.ts.map +0 -1
  133. package/dist/cjs/skillAssessments.js +0 -157
  134. package/dist/cjs/skillAssessments.js.map +0 -1
  135. package/dist/cjs/skillTemplate.d.ts +0 -15
  136. package/dist/cjs/skillTemplate.d.ts.map +0 -1
  137. package/dist/cjs/skillTemplate.js +0 -282
  138. package/dist/cjs/skillTemplate.js.map +0 -1
  139. package/dist/cjs/talentTransfromation.d.ts +0 -8
  140. package/dist/cjs/talentTransfromation.d.ts.map +0 -1
  141. package/dist/cjs/talentTransfromation.js +0 -101
  142. package/dist/cjs/talentTransfromation.js.map +0 -1
  143. package/dist/cjs/teams.d.ts +0 -15
  144. package/dist/cjs/teams.d.ts.map +0 -1
  145. package/dist/cjs/teams.js +0 -253
  146. package/dist/cjs/teams.js.map +0 -1
  147. package/dist/cjs/tenants.d.ts +0 -6
  148. package/dist/cjs/tenants.d.ts.map +0 -1
  149. package/dist/cjs/tenants.js +0 -53
  150. package/dist/cjs/tenants.js.map +0 -1
  151. package/dist/cjs/trainingPlans.d.ts +0 -16
  152. package/dist/cjs/trainingPlans.d.ts.map +0 -1
  153. package/dist/cjs/trainingPlans.js +0 -310
  154. package/dist/cjs/trainingPlans.js.map +0 -1
  155. package/dist/cjs/trainingPlansProficiencyLevels.d.ts +0 -8
  156. package/dist/cjs/trainingPlansProficiencyLevels.d.ts.map +0 -1
  157. package/dist/cjs/trainingPlansProficiencyLevels.js +0 -99
  158. package/dist/cjs/trainingPlansProficiencyLevels.js.map +0 -1
  159. package/dist/cjs/userInformation.d.ts +0 -7
  160. package/dist/cjs/userInformation.d.ts.map +0 -1
  161. package/dist/cjs/userInformation.js +0 -82
  162. package/dist/cjs/userInformation.js.map +0 -1
  163. package/dist/cjs/users.d.ts +0 -31
  164. package/dist/cjs/users.d.ts.map +0 -1
  165. package/dist/cjs/users.js +0 -695
  166. package/dist/cjs/users.js.map +0 -1
  167. package/dist/cjs/utils.d.ts +0 -8
  168. package/dist/cjs/utils.d.ts.map +0 -1
  169. package/dist/cjs/utils.js +0 -57
  170. package/dist/cjs/utils.js.map +0 -1
  171. package/dist/esm/actionNotifications.d.ts +0 -7
  172. package/dist/esm/actionNotifications.d.ts.map +0 -1
  173. package/dist/esm/actionNotifications.js +0 -72
  174. package/dist/esm/actionNotifications.js.map +0 -1
  175. package/dist/esm/address.d.ts +0 -5
  176. package/dist/esm/address.d.ts.map +0 -1
  177. package/dist/esm/address.js +0 -21
  178. package/dist/esm/address.js.map +0 -1
  179. package/dist/esm/aiAssistant.d.ts +0 -9
  180. package/dist/esm/aiAssistant.d.ts.map +0 -1
  181. package/dist/esm/aiAssistant.js +0 -133
  182. package/dist/esm/aiAssistant.js.map +0 -1
  183. package/dist/esm/avatar.d.ts +0 -5
  184. package/dist/esm/avatar.d.ts.map +0 -1
  185. package/dist/esm/avatar.js +0 -31
  186. package/dist/esm/avatar.js.map +0 -1
  187. package/dist/esm/axiosClient.d.ts +0 -32
  188. package/dist/esm/axiosClient.d.ts.map +0 -1
  189. package/dist/esm/axiosClient.js +0 -79
  190. package/dist/esm/axiosClient.js.map +0 -1
  191. package/dist/esm/config.d.ts +0 -7
  192. package/dist/esm/config.d.ts.map +0 -1
  193. package/dist/esm/config.js +0 -62
  194. package/dist/esm/config.js.map +0 -1
  195. package/dist/esm/constants.d.ts +0 -70
  196. package/dist/esm/constants.d.ts.map +0 -1
  197. package/dist/esm/constants.js +0 -89
  198. package/dist/esm/constants.js.map +0 -1
  199. package/dist/esm/dashboard.d.ts +0 -7
  200. package/dist/esm/dashboard.d.ts.map +0 -1
  201. package/dist/esm/dashboard.js +0 -73
  202. package/dist/esm/dashboard.js.map +0 -1
  203. package/dist/esm/departmentTrainingPlans.d.ts +0 -13
  204. package/dist/esm/departmentTrainingPlans.d.ts.map +0 -1
  205. package/dist/esm/departmentTrainingPlans.js +0 -153
  206. package/dist/esm/departmentTrainingPlans.js.map +0 -1
  207. package/dist/esm/groups.d.ts +0 -16
  208. package/dist/esm/groups.d.ts.map +0 -1
  209. package/dist/esm/groups.js +0 -272
  210. package/dist/esm/groups.js.map +0 -1
  211. package/dist/esm/index.d.ts +0 -33
  212. package/dist/esm/index.d.ts.map +0 -1
  213. package/dist/esm/index.js +0 -33
  214. package/dist/esm/index.js.map +0 -1
  215. package/dist/esm/integration.d.ts +0 -95
  216. package/dist/esm/integration.d.ts.map +0 -1
  217. package/dist/esm/integration.js +0 -312
  218. package/dist/esm/integration.js.map +0 -1
  219. package/dist/esm/integrationConfiguration.d.ts +0 -7
  220. package/dist/esm/integrationConfiguration.d.ts.map +0 -1
  221. package/dist/esm/integrationConfiguration.js +0 -85
  222. package/dist/esm/integrationConfiguration.js.map +0 -1
  223. package/dist/esm/integrations/contentGenerator.d.ts +0 -27
  224. package/dist/esm/integrations/contentGenerator.d.ts.map +0 -1
  225. package/dist/esm/integrations/contentGenerator.js +0 -66
  226. package/dist/esm/integrations/contentGenerator.js.map +0 -1
  227. package/dist/esm/learningContent.d.ts +0 -19
  228. package/dist/esm/learningContent.d.ts.map +0 -1
  229. package/dist/esm/learningContent.js +0 -393
  230. package/dist/esm/learningContent.js.map +0 -1
  231. package/dist/esm/learningPath.d.ts +0 -12
  232. package/dist/esm/learningPath.d.ts.map +0 -1
  233. package/dist/esm/learningPath.js +0 -204
  234. package/dist/esm/learningPath.js.map +0 -1
  235. package/dist/esm/logger.d.ts +0 -6
  236. package/dist/esm/logger.d.ts.map +0 -1
  237. package/dist/esm/logger.js +0 -56
  238. package/dist/esm/logger.js.map +0 -1
  239. package/dist/esm/microSkillsQuizes.d.ts +0 -6
  240. package/dist/esm/microSkillsQuizes.d.ts.map +0 -1
  241. package/dist/esm/microSkillsQuizes.js +0 -52
  242. package/dist/esm/microSkillsQuizes.js.map +0 -1
  243. package/dist/esm/quotas.d.ts +0 -6
  244. package/dist/esm/quotas.d.ts.map +0 -1
  245. package/dist/esm/quotas.js +0 -49
  246. package/dist/esm/quotas.js.map +0 -1
  247. package/dist/esm/role.d.ts +0 -18
  248. package/dist/esm/role.d.ts.map +0 -1
  249. package/dist/esm/role.js +0 -362
  250. package/dist/esm/role.js.map +0 -1
  251. package/dist/esm/roleTemplate.d.ts +0 -13
  252. package/dist/esm/roleTemplate.d.ts.map +0 -1
  253. package/dist/esm/roleTemplate.js +0 -235
  254. package/dist/esm/roleTemplate.js.map +0 -1
  255. package/dist/esm/security.d.ts +0 -8
  256. package/dist/esm/security.d.ts.map +0 -1
  257. package/dist/esm/security.js +0 -78
  258. package/dist/esm/security.js.map +0 -1
  259. package/dist/esm/skill.d.ts +0 -22
  260. package/dist/esm/skill.d.ts.map +0 -1
  261. package/dist/esm/skill.js +0 -438
  262. package/dist/esm/skill.js.map +0 -1
  263. package/dist/esm/skillAssessmentTestingSession.d.ts +0 -10
  264. package/dist/esm/skillAssessmentTestingSession.d.ts.map +0 -1
  265. package/dist/esm/skillAssessmentTestingSession.js +0 -155
  266. package/dist/esm/skillAssessmentTestingSession.js.map +0 -1
  267. package/dist/esm/skillAssessments.d.ts +0 -10
  268. package/dist/esm/skillAssessments.d.ts.map +0 -1
  269. package/dist/esm/skillAssessments.js +0 -155
  270. package/dist/esm/skillAssessments.js.map +0 -1
  271. package/dist/esm/skillTemplate.d.ts +0 -15
  272. package/dist/esm/skillTemplate.d.ts.map +0 -1
  273. package/dist/esm/skillTemplate.js +0 -280
  274. package/dist/esm/skillTemplate.js.map +0 -1
  275. package/dist/esm/talentTransfromation.d.ts +0 -8
  276. package/dist/esm/talentTransfromation.d.ts.map +0 -1
  277. package/dist/esm/talentTransfromation.js +0 -99
  278. package/dist/esm/talentTransfromation.js.map +0 -1
  279. package/dist/esm/teams.d.ts +0 -15
  280. package/dist/esm/teams.d.ts.map +0 -1
  281. package/dist/esm/teams.js +0 -251
  282. package/dist/esm/teams.js.map +0 -1
  283. package/dist/esm/tenants.d.ts +0 -6
  284. package/dist/esm/tenants.d.ts.map +0 -1
  285. package/dist/esm/tenants.js +0 -51
  286. package/dist/esm/tenants.js.map +0 -1
  287. package/dist/esm/trainingPlans.d.ts +0 -16
  288. package/dist/esm/trainingPlans.d.ts.map +0 -1
  289. package/dist/esm/trainingPlans.js +0 -307
  290. package/dist/esm/trainingPlans.js.map +0 -1
  291. package/dist/esm/trainingPlansProficiencyLevels.d.ts +0 -8
  292. package/dist/esm/trainingPlansProficiencyLevels.d.ts.map +0 -1
  293. package/dist/esm/trainingPlansProficiencyLevels.js +0 -97
  294. package/dist/esm/trainingPlansProficiencyLevels.js.map +0 -1
  295. package/dist/esm/userInformation.d.ts +0 -7
  296. package/dist/esm/userInformation.d.ts.map +0 -1
  297. package/dist/esm/userInformation.js +0 -80
  298. package/dist/esm/userInformation.js.map +0 -1
  299. package/dist/esm/users.d.ts +0 -31
  300. package/dist/esm/users.d.ts.map +0 -1
  301. package/dist/esm/users.js +0 -692
  302. package/dist/esm/users.js.map +0 -1
  303. package/dist/esm/utils.d.ts +0 -8
  304. package/dist/esm/utils.d.ts.map +0 -1
  305. package/dist/esm/utils.js +0 -52
  306. package/dist/esm/utils.js.map +0 -1
package/dist/esm/users.js DELETED
@@ -1,692 +0,0 @@
1
- import { client } from "./axiosClient";
2
- /**
3
- * Add a new API Token
4
- * @param {string} name Name of the token
5
- * @param {Date} expiration Expiration date of the token
6
- * @param {string} token Authorization token
7
- * @returns {Promise<object>}
8
- */
9
- const addAPIToken = (name, expiration, token) => {
10
- return new Promise((resolve, reject) => {
11
- const requestData = {
12
- name: name,
13
- expiration: expiration,
14
- };
15
- const addTokenRequest = client.post(`api/v1/users/addapitoken`, requestData, {
16
- headers: { authorization: token },
17
- });
18
- addTokenRequest
19
- .then((result) => {
20
- if (result != null) {
21
- resolve(result.data);
22
- }
23
- else {
24
- reject(process.env.ERROR_INVALID_INFORMATION);
25
- }
26
- })
27
- .catch((error) => {
28
- reject(error);
29
- });
30
- });
31
- };
32
- /**
33
- * Confirm email address
34
- * @param {string} validationCode The code was provided to the user in advance by email
35
- * @returns {Promise<void>}
36
- */
37
- const confirmEmailAddress = (validationCode) => {
38
- return new Promise((resolve, reject) => {
39
- const requestData = {
40
- validationCode: validationCode,
41
- };
42
- const confirmationRequest = client.post("api/v1/users/confirmEmail", requestData);
43
- confirmationRequest
44
- .then(() => {
45
- resolve();
46
- })
47
- .catch((error) => {
48
- reject(error);
49
- });
50
- });
51
- };
52
- /**
53
- * Confirm phone number
54
- * @param {string} validationCode The code was provided to the user in advance by email
55
- * @param {string} token Authorization token
56
- * @returns {Promise<object>}
57
- */
58
- const confirmPhone = (validationCode, token) => {
59
- return new Promise((resolve, reject) => {
60
- const requestData = {
61
- validationCode: validationCode,
62
- };
63
- const confirmationRequest = client.post("api/v1/users/confirmPhone", requestData, {
64
- headers: { authorization: token },
65
- });
66
- confirmationRequest
67
- .then((response) => {
68
- resolve(response.data);
69
- })
70
- .catch((error) => {
71
- reject(error);
72
- });
73
- });
74
- };
75
- /**
76
- * Generate confirmation code
77
- * @param {string} phoneNumber Send confirmation code to the phone number
78
- * @param {string} token Authorization token
79
- * @returns {Promise<object>}
80
- */
81
- const confirmPhoneGenerateCode = (phoneNumber, token) => {
82
- return new Promise((resolve, reject) => {
83
- const requestData = {
84
- phoneNumber: phoneNumber,
85
- };
86
- const confirmationRequest = client.post("api/v1/users/confirmPhoneGenerateCode", requestData, {
87
- headers: { authorization: token },
88
- });
89
- confirmationRequest
90
- .then((response) => {
91
- resolve(response.data);
92
- })
93
- .catch((error) => {
94
- reject(error);
95
- });
96
- });
97
- };
98
- /**
99
- * Create a new account (tenant). It returns a promise
100
- * @param {string} email User's email address
101
- * @param {string} firstName User's first name
102
- * @param {string} lastName User's last name
103
- * @param {string} password User's password
104
- * @param {string} subSite Subsite where the new account will be created
105
- * @param {string} inviteCode Invitation code received in advance from one of the account owners
106
- * @returns {Promise<object>}
107
- */
108
- const createAccount = (email, firstName, lastName, password, subSite, inviteCode) => {
109
- return new Promise((resolve, reject) => {
110
- if (email.trim() === "" ||
111
- firstName.trim() === "" ||
112
- lastName.trim() === "" ||
113
- password.trim() === "" ||
114
- subSite.trim() === "" ||
115
- inviteCode.trim() === "") {
116
- reject(process.env.ERROR_EMPTY_FIELDS);
117
- }
118
- else {
119
- const signupData = {
120
- email: email,
121
- firstName: firstName,
122
- inviteCode: inviteCode,
123
- lastName: lastName,
124
- password: password,
125
- subSite: subSite,
126
- };
127
- const request = client.post("api/v1/users/createAccount", signupData);
128
- request
129
- .then((result) => {
130
- resolve(result.data.user);
131
- })
132
- .catch((error) => {
133
- reject(error);
134
- });
135
- }
136
- });
137
- };
138
- /**
139
- * Create a new user account. It returns a promise
140
- * @param {string} email User's email address
141
- * @param {string} firstName User's first name
142
- * @param {string} lastName User's last name
143
- * @param {string} password User's password
144
- * @param {string} token Invitation token provided to the user
145
- * @returns {Promise<object>}
146
- */
147
- const createUserAccount = (email, firstName, lastName, password, token) => {
148
- return new Promise((resolve, reject) => {
149
- if (email.trim() === "" ||
150
- firstName.trim() === "" ||
151
- lastName.trim() === "" ||
152
- password.trim() === "" ||
153
- token.trim() === "") {
154
- reject(process.env.ERROR_EMPTY_FIELDS);
155
- }
156
- else {
157
- const signupData = {
158
- email: email,
159
- firstName: firstName,
160
- lastName: lastName,
161
- password: password,
162
- token: token,
163
- };
164
- const request = client.post("api/v1/users/createUser", signupData);
165
- request
166
- .then((result) => {
167
- resolve(result.data.user);
168
- })
169
- .catch((error) => {
170
- reject(error);
171
- });
172
- }
173
- });
174
- };
175
- /**
176
- * Delete an existing API token
177
- * @param {string} token Expiration date of the token
178
- * @param {string} authToken Authorization token
179
- * @returns {Promise<string>}
180
- */
181
- const deleteAPIToken = (token, authToken) => {
182
- return new Promise((resolve, reject) => {
183
- const deleteTokenRequest = client.delete(`api/v1/users/user/token`, {
184
- headers: { authorization: authToken },
185
- data: {
186
- token: token,
187
- },
188
- });
189
- deleteTokenRequest
190
- .then(() => {
191
- resolve(token);
192
- })
193
- .catch((error) => {
194
- reject(error);
195
- });
196
- });
197
- };
198
- /**
199
- * Delete existing users
200
- * @param {string[]} userIds The ID of the users to be deleted
201
- * @param {string} token Authorization token
202
- * @returns {Promise<object>}
203
- */
204
- const deleteUsers = (userIds, token) => {
205
- return new Promise((resolve, reject) => {
206
- const deleteTokenRequest = client.delete(`api/v1/users/`, {
207
- headers: { authorization: token },
208
- data: {
209
- userIds: userIds,
210
- },
211
- });
212
- deleteTokenRequest
213
- .then((response) => {
214
- resolve(response.data);
215
- })
216
- .catch((error) => {
217
- reject(error);
218
- });
219
- });
220
- };
221
- /**
222
- * Get all the API tokens
223
- * @param {string} token Authorization token
224
- * @returns {Promise<object>}
225
- */
226
- const getAPITokens = (token) => {
227
- return new Promise((resolve, reject) => {
228
- const getTokensRequest = client.get(`api/v1/users/getapitokens`, {
229
- headers: { authorization: token },
230
- });
231
- getTokensRequest
232
- .then((result) => {
233
- resolve(result.data);
234
- })
235
- .catch((error) => {
236
- reject(error);
237
- });
238
- });
239
- };
240
- /**
241
- * Get the specified user account by Id. It returns a promise
242
- * @param {string} id Id of the user for which information is being requested
243
- * @param {string} token Authorization token
244
- * @returns {Promise<object>}
245
- */
246
- const getUserById = (id, token) => {
247
- return new Promise((resolve, reject) => {
248
- const getUserInformationRequest = client.get(`api/v1/users/user/${id}`, {
249
- headers: { authorization: token },
250
- });
251
- getUserInformationRequest
252
- .then((result) => {
253
- if (result != null) {
254
- resolve(result.data.user);
255
- }
256
- else {
257
- reject(process.env.ERROR_INVALID_INFORMATION);
258
- }
259
- })
260
- .catch((error) => {
261
- reject(error);
262
- });
263
- });
264
- };
265
- /**
266
- * Get user information
267
- * @param {string} userId User Id
268
- * @param {string} category User information category
269
- * @param {string} token Authorization token
270
- * @returns {Promise<object>}
271
- */
272
- const getUserInformation = (userId, category, token) => {
273
- return new Promise((resolve, reject) => {
274
- const confirmationRequest = client.get(`api/v1/users/user/${userId || 0}/${category || "*"}`, {
275
- headers: { authorization: token },
276
- });
277
- confirmationRequest
278
- .then((response) => {
279
- resolve(response.data);
280
- })
281
- .catch((error) => {
282
- reject(error);
283
- });
284
- });
285
- };
286
- /**
287
- * Get the list of users
288
- * @param {object} filter Filter to select the users. Ex: {firstName : "John"}
289
- * @param {string[]} fields Fields to be loaded. Ex: ["firstName"]
290
- * @param {string} token Authorization token
291
- * @returns {Promise<object>}
292
- */
293
- const getUsers = (filter, fields, token) => {
294
- return new Promise((resolve, reject) => {
295
- const requestData = {
296
- filter: filter,
297
- fields: fields,
298
- };
299
- const confirmationRequest = client.post(`api/v1/users/`, requestData, {
300
- headers: { authorization: token },
301
- });
302
- confirmationRequest
303
- .then((response) => {
304
- resolve(response.data);
305
- })
306
- .catch((error) => {
307
- reject(error);
308
- });
309
- });
310
- };
311
- /**
312
- * Invite other users to join the same account
313
- * @param {string[]} invitees List of emails of the invitees
314
- * @param {string} groupId The group the user should be added to
315
- * @param {string} teamId The team the user should be added to
316
- * @param {string} authToken Authorization token
317
- * @returns {Promise<object>}
318
- */
319
- const inviteUsers = (invitees, groupId, teamId, authToken) => {
320
- return new Promise((resolve, reject) => {
321
- const requestData = {
322
- invitees: invitees,
323
- groupId: groupId,
324
- teamId: teamId,
325
- token: authToken,
326
- };
327
- const request = client.post("api/v1/users/invite", requestData, {
328
- headers: { authorization: authToken },
329
- });
330
- request
331
- .then((response) => {
332
- resolve(response.data);
333
- })
334
- .catch((error) => {
335
- reject(error);
336
- });
337
- });
338
- };
339
- /**
340
- * Login using email and password. It returns a promise
341
- * @param {string} email User's email address
342
- * @param {string} password User's password
343
- * @returns {Promise<object>}
344
- */
345
- const login = (email, password) => {
346
- return new Promise((resolve, reject) => {
347
- const requestData = {
348
- email: email,
349
- password: password,
350
- };
351
- const request = client.post("api/v1/auth/login", requestData);
352
- request
353
- .then((response) => {
354
- resolve(response.data);
355
- })
356
- .catch((error) => {
357
- reject(error);
358
- });
359
- });
360
- };
361
- /**
362
- * Login callback after authentication to exchange the code token for authentication and refresh tokens
363
- * @param {string} code
364
- * @param {string} codeVerifier
365
- * @param {string} redirectUri
366
- * @returns {Promise<object>}
367
- */
368
- const loginExchangeKeys = (code, codeVerifier, redirectUri) => {
369
- return new Promise((resolve, reject) => {
370
- const requestData = {
371
- code: code,
372
- codeVerifier: codeVerifier,
373
- redirectUri: redirectUri,
374
- };
375
- const request = client.post("api/v1/auth/loginexchangekeys", requestData);
376
- request
377
- .then((response) => {
378
- resolve(response.data);
379
- })
380
- .catch((error) => {
381
- reject(error);
382
- });
383
- });
384
- };
385
- /**
386
- * Logout from the server. It returns a promise
387
- * @param {string} token Authorization token
388
- * @returns {Promise<object>}
389
- */
390
- const logout = (token) => {
391
- return new Promise((resolve, reject) => {
392
- const request = client.post("api/v1/auth/logout", {}, {
393
- headers: { authorization: token },
394
- });
395
- request
396
- .then((response) => {
397
- resolve(response.data);
398
- })
399
- .catch((error) => {
400
- reject(error);
401
- });
402
- });
403
- };
404
- /**
405
- * Checks the current auth token and maintain it alive. It returns a promise. In case the token is invalid
406
- * a new token can be restablished using login
407
- * @param {string} refreshToken User's auth token to be refreshed
408
- * @returns {Promise<object>}
409
- */
410
- const refreshToken = (refreshToken) => {
411
- return new Promise((resolve, reject) => {
412
- const request = client.post("api/v1/auth/refreshToken", {
413
- refreshToken: refreshToken,
414
- });
415
- request
416
- .then((response) => {
417
- resolve(response.data);
418
- })
419
- .catch((error) => {
420
- reject(error);
421
- });
422
- });
423
- };
424
- /**
425
- * Remove an existing API token
426
- * @param {string} id The ID of the token to be removed
427
- * @param {string} authToken Authorization token
428
- * @returns {Promise<string>}
429
- */
430
- const removeAPIToken = (id, authToken) => {
431
- return new Promise((resolve, reject) => {
432
- const requestData = {
433
- id: id,
434
- };
435
- const removeTokenRequest = client.post(`api/v1/users/removeapitoken`, requestData, {
436
- headers: { authorization: authToken },
437
- });
438
- removeTokenRequest
439
- .then(() => {
440
- resolve(id);
441
- })
442
- .catch((error) => {
443
- reject(error);
444
- });
445
- });
446
- };
447
- /**
448
- * Resend invitation emails
449
- * @param {string[]} invitees List of emails of the invitees
450
- * @param {string} authToken Authorization token
451
- * @returns {Promise<object>}
452
- */
453
- const resendInvitationEmails = (invitees, authToken) => {
454
- return new Promise((resolve, reject) => {
455
- const requestData = {
456
- invitees: invitees,
457
- token: authToken,
458
- };
459
- const request = client.post("api/v1/users/resendinvite", requestData, {
460
- headers: { authorization: authToken },
461
- });
462
- request
463
- .then((response) => {
464
- resolve(response.data);
465
- })
466
- .catch((error) => {
467
- reject(error);
468
- });
469
- });
470
- };
471
- /**
472
- * Reset the password. It returns a promise
473
- * @param {string} code Code provided to the user by email
474
- * @param {string} email User's email address
475
- * @param {string} password User's new password
476
- * @returns {Promise<object>}
477
- */
478
- const resetPassword = (email, code, password) => {
479
- return new Promise((resolve, reject) => {
480
- const postData = {
481
- email: email,
482
- code: code,
483
- password: password,
484
- };
485
- const request = client.post("api/v1/users/resetpassword", postData);
486
- request
487
- .then((response) => {
488
- resolve(response.data);
489
- })
490
- .catch((error) => {
491
- reject(error);
492
- });
493
- });
494
- };
495
- /**
496
- * Send email confirmation code
497
- * @param {string} email
498
- * @param {string} token
499
- * @returns {Promise<object>}
500
- */
501
- const sendEmailConfirmationCode = (email, token) => {
502
- return new Promise((resolve, reject) => {
503
- const postData = {
504
- email: email,
505
- };
506
- const request = client.post("api/v1/users/sendemailconfirmationcode", postData, {
507
- headers: { authorization: token },
508
- });
509
- request
510
- .then((response) => {
511
- resolve(response.data);
512
- })
513
- .catch((error) => {
514
- reject(error);
515
- });
516
- });
517
- };
518
- /**
519
- * Send an email to the user indicated by the email address to reset the password. It returns a promise
520
- * @param {string} email Email of the user who needs to reset the password
521
- * @returns {Promise<object>}
522
- */
523
- const sendPasswordResetNotification = (email) => {
524
- return new Promise((resolve, reject) => {
525
- const postData = {
526
- email: email,
527
- };
528
- const request = client.post("api/v1/users/sendpasswordresetnotification", postData);
529
- request
530
- .then((response) => {
531
- resolve(response.data);
532
- })
533
- .catch((error) => {
534
- reject(error);
535
- });
536
- });
537
- };
538
- /**
539
- * Set user profile information
540
- * @param {string} userId User Id
541
- * @param {string} category User information category
542
- * @param {object} data New or updated user data information
543
- * @param {string} token Authorization token
544
- * @returns {Promise<object>}
545
- */
546
- const setUserInformation = (userId, category, data, token) => {
547
- return new Promise((resolve, reject) => {
548
- const requestData = {
549
- data: category ? { [category]: data } : data,
550
- userId: userId,
551
- };
552
- const confirmationRequest = client.post("api/v1/users/user", requestData, {
553
- headers: { authorization: token },
554
- });
555
- confirmationRequest
556
- .then((response) => {
557
- resolve(response.data);
558
- })
559
- .catch((error) => {
560
- reject(error);
561
- });
562
- });
563
- };
564
- /**
565
- * Update user email
566
- * @param {string} email The new email address
567
- * @param {string} verificationCode The verification code
568
- * @param {string} password The current password
569
- * @param {string} token Authorization token
570
- * @returns {Promise<object>}
571
- */
572
- const updateUserEmail = (email, verificationCode, password, token) => {
573
- return new Promise((resolve, reject) => {
574
- const requestData = {
575
- email: email,
576
- verificationCode: verificationCode,
577
- password: password,
578
- };
579
- const confirmationRequest = client.post("api/v1/users/updateemail", requestData, {
580
- headers: { authorization: token },
581
- });
582
- confirmationRequest
583
- .then((response) => {
584
- resolve(response.data);
585
- })
586
- .catch((error) => {
587
- reject(error);
588
- });
589
- });
590
- };
591
- /**
592
- * Update user groups
593
- * @param {String} userId The id of the user
594
- * @param {Array<String>} groups The id of the groups the user should belong to
595
- * @param {String} token Authorization token
596
- * @returns {Promise<object>}
597
- */
598
- const updateUserGroups = (userId, groups, token) => {
599
- return new Promise((resolve, reject) => {
600
- const requestData = {
601
- userId: userId,
602
- groups: groups || [],
603
- };
604
- const confirmationRequest = client.post("api/v1/users/user/updategroups", requestData, {
605
- headers: { authorization: token },
606
- });
607
- confirmationRequest
608
- .then(() => {
609
- resolve(requestData);
610
- })
611
- .catch((error) => {
612
- reject(error);
613
- });
614
- });
615
- };
616
- /**
617
- * Update user password
618
- * @param {String} password The current password
619
- * @param {String} newPassword The new password
620
- * @param {String} token Authorization token
621
- * @returns {Promise<object>}
622
- */
623
- const updateUserPassword = (password, newPassword, token) => {
624
- return new Promise((resolve, reject) => {
625
- const requestData = {
626
- password: password,
627
- newPassword: newPassword,
628
- };
629
- const confirmationRequest = client.post("api/v1/users/updatepassword", requestData, {
630
- headers: { authorization: token },
631
- });
632
- confirmationRequest
633
- .then((response) => {
634
- resolve(response.data);
635
- })
636
- .catch((error) => {
637
- reject(error);
638
- });
639
- });
640
- };
641
- /**
642
- * Validate reset password code. It returns a promise
643
- * @param {String} email User's email address
644
- * @param {String} code Provided reset code
645
- * @returns {Promise<object>}
646
- */
647
- const validateResetPasswordCode = (email, code) => {
648
- return new Promise((resolve, reject) => {
649
- const postData = {
650
- email: email,
651
- code: code,
652
- };
653
- const request = client.post("api/v1/users/validateresetpasswordcode", postData);
654
- request
655
- .then((response) => {
656
- resolve(response.data);
657
- })
658
- .catch((error) => {
659
- reject(error);
660
- });
661
- });
662
- };
663
- export default {
664
- addAPIToken,
665
- confirmEmailAddress,
666
- confirmPhone,
667
- confirmPhoneGenerateCode,
668
- createAccount,
669
- createUserAccount,
670
- deleteAPIToken,
671
- deleteUsers,
672
- getAPITokens,
673
- getUserById,
674
- getUserInformation,
675
- getUsers,
676
- inviteUsers,
677
- login,
678
- loginExchangeKeys,
679
- logout,
680
- refreshToken,
681
- removeAPIToken,
682
- resendInvitationEmails,
683
- resetPassword,
684
- sendEmailConfirmationCode,
685
- sendPasswordResetNotification,
686
- setUserInformation,
687
- updateUserEmail,
688
- updateUserGroups,
689
- updateUserPassword,
690
- validateResetPasswordCode,
691
- };
692
- //# sourceMappingURL=users.js.map