@stackfactor/client-api 1.1.140 → 1.1.141

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