@stackfactor/client-api 1.1.15-8.1 → 1.1.16

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 (304) hide show
  1. package/exports.js +71 -0
  2. package/index.js +3 -0
  3. package/lib/actionNotifications.js +82 -0
  4. package/lib/address.js +27 -0
  5. package/lib/aiAssistant.js +139 -0
  6. package/lib/axiosClient.js +85 -0
  7. package/lib/config.js +74 -0
  8. package/lib/constants.js +127 -0
  9. package/lib/dashboard.js +79 -0
  10. package/lib/departmentTrainingPlans.js +180 -0
  11. package/lib/groups.js +302 -0
  12. package/lib/integration.js +352 -0
  13. package/lib/integrationConfiguration.js +108 -0
  14. package/lib/integrations/contentGenerator.js +79 -0
  15. package/lib/learningContent.js +383 -0
  16. package/lib/learningPath.js +220 -0
  17. package/lib/logger.js +60 -0
  18. package/lib/role.js +406 -0
  19. package/lib/roleTemplate.js +258 -0
  20. package/lib/skill.js +514 -0
  21. package/lib/skillAssessmentTestingSession.js +148 -0
  22. package/lib/skillAssessments.js +145 -0
  23. package/lib/skillTemplate.js +318 -0
  24. package/lib/teams.js +294 -0
  25. package/lib/tenants.js +57 -0
  26. package/lib/trainingPlans.js +279 -0
  27. package/lib/userInformation.js +109 -0
  28. package/lib/users.js +695 -0
  29. package/lib/utils.js +48 -0
  30. package/package.json +10 -31
  31. package/declarations/axios.d.ts +0 -1
  32. package/declarations/html2plaintext.d.ts +0 -1
  33. package/dist/cjs/actionNotifications.d.ts +0 -24
  34. package/dist/cjs/actionNotifications.d.ts.map +0 -1
  35. package/dist/cjs/actionNotifications.js +0 -73
  36. package/dist/cjs/actionNotifications.js.map +0 -1
  37. package/dist/cjs/address.d.ts +0 -8
  38. package/dist/cjs/address.d.ts.map +0 -1
  39. package/dist/cjs/address.js +0 -24
  40. package/dist/cjs/address.js.map +0 -1
  41. package/dist/cjs/aiAssistant.d.ts +0 -42
  42. package/dist/cjs/aiAssistant.d.ts.map +0 -1
  43. package/dist/cjs/aiAssistant.js +0 -135
  44. package/dist/cjs/aiAssistant.js.map +0 -1
  45. package/dist/cjs/avatar.d.ts +0 -11
  46. package/dist/cjs/avatar.d.ts.map +0 -1
  47. package/dist/cjs/avatar.js +0 -32
  48. package/dist/cjs/avatar.js.map +0 -1
  49. package/dist/cjs/axiosClient.d.ts +0 -31
  50. package/dist/cjs/axiosClient.d.ts.map +0 -1
  51. package/dist/cjs/axiosClient.js +0 -126
  52. package/dist/cjs/axiosClient.js.map +0 -1
  53. package/dist/cjs/config.d.ts +0 -23
  54. package/dist/cjs/config.d.ts.map +0 -1
  55. package/dist/cjs/config.js +0 -63
  56. package/dist/cjs/config.js.map +0 -1
  57. package/dist/cjs/constants.d.ts +0 -69
  58. package/dist/cjs/constants.d.ts.map +0 -1
  59. package/dist/cjs/constants.js +0 -91
  60. package/dist/cjs/constants.js.map +0 -1
  61. package/dist/cjs/dashboard.d.ts +0 -23
  62. package/dist/cjs/dashboard.d.ts.map +0 -1
  63. package/dist/cjs/dashboard.js +0 -74
  64. package/dist/cjs/dashboard.js.map +0 -1
  65. package/dist/cjs/departmentTrainingPlans.d.ts +0 -53
  66. package/dist/cjs/departmentTrainingPlans.d.ts.map +0 -1
  67. package/dist/cjs/departmentTrainingPlans.js +0 -153
  68. package/dist/cjs/departmentTrainingPlans.js.map +0 -1
  69. package/dist/cjs/groups.d.ts +0 -90
  70. package/dist/cjs/groups.d.ts.map +0 -1
  71. package/dist/cjs/groups.js +0 -273
  72. package/dist/cjs/groups.js.map +0 -1
  73. package/dist/cjs/index.d.ts +0 -33
  74. package/dist/cjs/index.d.ts.map +0 -1
  75. package/dist/cjs/index.js +0 -77
  76. package/dist/cjs/index.js.map +0 -1
  77. package/dist/cjs/integration.d.ts +0 -82
  78. package/dist/cjs/integration.d.ts.map +0 -1
  79. package/dist/cjs/integration.js +0 -316
  80. package/dist/cjs/integration.js.map +0 -1
  81. package/dist/cjs/integrationConfiguration.d.ts +0 -27
  82. package/dist/cjs/integrationConfiguration.d.ts.map +0 -1
  83. package/dist/cjs/integrationConfiguration.js +0 -86
  84. package/dist/cjs/integrationConfiguration.js.map +0 -1
  85. package/dist/cjs/integrations/contentGenerator.d.ts +0 -22
  86. package/dist/cjs/integrations/contentGenerator.d.ts.map +0 -1
  87. package/dist/cjs/integrations/contentGenerator.js +0 -69
  88. package/dist/cjs/integrations/contentGenerator.js.map +0 -1
  89. package/dist/cjs/learningContent.d.ts +0 -153
  90. package/dist/cjs/learningContent.d.ts.map +0 -1
  91. package/dist/cjs/learningContent.js +0 -474
  92. package/dist/cjs/learningContent.js.map +0 -1
  93. package/dist/cjs/learningPath.d.ts +0 -64
  94. package/dist/cjs/learningPath.d.ts.map +0 -1
  95. package/dist/cjs/learningPath.js +0 -205
  96. package/dist/cjs/learningPath.js.map +0 -1
  97. package/dist/cjs/logger.d.ts +0 -19
  98. package/dist/cjs/logger.d.ts.map +0 -1
  99. package/dist/cjs/logger.js +0 -60
  100. package/dist/cjs/logger.js.map +0 -1
  101. package/dist/cjs/microSkillsQuizes.d.ts +0 -18
  102. package/dist/cjs/microSkillsQuizes.d.ts.map +0 -1
  103. package/dist/cjs/microSkillsQuizes.js +0 -53
  104. package/dist/cjs/microSkillsQuizes.js.map +0 -1
  105. package/dist/cjs/quotas.d.ts +0 -15
  106. package/dist/cjs/quotas.d.ts.map +0 -1
  107. package/dist/cjs/quotas.js +0 -50
  108. package/dist/cjs/quotas.js.map +0 -1
  109. package/dist/cjs/role.d.ts +0 -113
  110. package/dist/cjs/role.d.ts.map +0 -1
  111. package/dist/cjs/role.js +0 -363
  112. package/dist/cjs/role.js.map +0 -1
  113. package/dist/cjs/roleTemplate.d.ts +0 -73
  114. package/dist/cjs/roleTemplate.d.ts.map +0 -1
  115. package/dist/cjs/roleTemplate.js +0 -236
  116. package/dist/cjs/roleTemplate.js.map +0 -1
  117. package/dist/cjs/security.d.ts +0 -27
  118. package/dist/cjs/security.d.ts.map +0 -1
  119. package/dist/cjs/security.js +0 -79
  120. package/dist/cjs/security.js.map +0 -1
  121. package/dist/cjs/skill.d.ts +0 -141
  122. package/dist/cjs/skill.d.ts.map +0 -1
  123. package/dist/cjs/skill.js +0 -440
  124. package/dist/cjs/skill.js.map +0 -1
  125. package/dist/cjs/skillAssessmentTestingSession.d.ts +0 -85
  126. package/dist/cjs/skillAssessmentTestingSession.d.ts.map +0 -1
  127. package/dist/cjs/skillAssessmentTestingSession.js +0 -276
  128. package/dist/cjs/skillAssessmentTestingSession.js.map +0 -1
  129. package/dist/cjs/skillAssessments.d.ts +0 -49
  130. package/dist/cjs/skillAssessments.d.ts.map +0 -1
  131. package/dist/cjs/skillAssessments.js +0 -156
  132. package/dist/cjs/skillAssessments.js.map +0 -1
  133. package/dist/cjs/skillTemplate.d.ts +0 -87
  134. package/dist/cjs/skillTemplate.d.ts.map +0 -1
  135. package/dist/cjs/skillTemplate.js +0 -281
  136. package/dist/cjs/skillTemplate.js.map +0 -1
  137. package/dist/cjs/talentTransfromation.d.ts +0 -29
  138. package/dist/cjs/talentTransfromation.d.ts.map +0 -1
  139. package/dist/cjs/talentTransfromation.js +0 -100
  140. package/dist/cjs/talentTransfromation.js.map +0 -1
  141. package/dist/cjs/teams.d.ts +0 -85
  142. package/dist/cjs/teams.d.ts.map +0 -1
  143. package/dist/cjs/teams.js +0 -252
  144. package/dist/cjs/teams.js.map +0 -1
  145. package/dist/cjs/tenants.d.ts +0 -16
  146. package/dist/cjs/tenants.d.ts.map +0 -1
  147. package/dist/cjs/tenants.js +0 -55
  148. package/dist/cjs/tenants.js.map +0 -1
  149. package/dist/cjs/trainingPlans.d.ts +0 -92
  150. package/dist/cjs/trainingPlans.d.ts.map +0 -1
  151. package/dist/cjs/trainingPlans.js +0 -309
  152. package/dist/cjs/trainingPlans.js.map +0 -1
  153. package/dist/cjs/trainingPlansProficiencyLevels.d.ts +0 -32
  154. package/dist/cjs/trainingPlansProficiencyLevels.d.ts.map +0 -1
  155. package/dist/cjs/trainingPlansProficiencyLevels.js +0 -97
  156. package/dist/cjs/trainingPlansProficiencyLevels.js.map +0 -1
  157. package/dist/cjs/userInformation.d.ts +0 -29
  158. package/dist/cjs/userInformation.d.ts.map +0 -1
  159. package/dist/cjs/userInformation.js +0 -81
  160. package/dist/cjs/userInformation.js.map +0 -1
  161. package/dist/cjs/users.d.ts +0 -206
  162. package/dist/cjs/users.d.ts.map +0 -1
  163. package/dist/cjs/users.js +0 -694
  164. package/dist/cjs/users.js.map +0 -1
  165. package/dist/cjs/utils.d.ts +0 -14
  166. package/dist/cjs/utils.d.ts.map +0 -1
  167. package/dist/cjs/utils.js +0 -58
  168. package/dist/cjs/utils.js.map +0 -1
  169. package/dist/esm/actionNotifications.d.ts +0 -24
  170. package/dist/esm/actionNotifications.d.ts.map +0 -1
  171. package/dist/esm/actionNotifications.js +0 -67
  172. package/dist/esm/actionNotifications.js.map +0 -1
  173. package/dist/esm/address.d.ts +0 -8
  174. package/dist/esm/address.d.ts.map +0 -1
  175. package/dist/esm/address.js +0 -20
  176. package/dist/esm/address.js.map +0 -1
  177. package/dist/esm/aiAssistant.d.ts +0 -42
  178. package/dist/esm/aiAssistant.d.ts.map +0 -1
  179. package/dist/esm/aiAssistant.js +0 -126
  180. package/dist/esm/aiAssistant.js.map +0 -1
  181. package/dist/esm/avatar.d.ts +0 -11
  182. package/dist/esm/avatar.d.ts.map +0 -1
  183. package/dist/esm/avatar.js +0 -28
  184. package/dist/esm/avatar.js.map +0 -1
  185. package/dist/esm/axiosClient.d.ts +0 -31
  186. package/dist/esm/axiosClient.d.ts.map +0 -1
  187. package/dist/esm/axiosClient.js +0 -81
  188. package/dist/esm/axiosClient.js.map +0 -1
  189. package/dist/esm/config.d.ts +0 -23
  190. package/dist/esm/config.d.ts.map +0 -1
  191. package/dist/esm/config.js +0 -57
  192. package/dist/esm/config.js.map +0 -1
  193. package/dist/esm/constants.d.ts +0 -69
  194. package/dist/esm/constants.d.ts.map +0 -1
  195. package/dist/esm/constants.js +0 -88
  196. package/dist/esm/constants.js.map +0 -1
  197. package/dist/esm/dashboard.d.ts +0 -23
  198. package/dist/esm/dashboard.d.ts.map +0 -1
  199. package/dist/esm/dashboard.js +0 -68
  200. package/dist/esm/dashboard.js.map +0 -1
  201. package/dist/esm/departmentTrainingPlans.d.ts +0 -53
  202. package/dist/esm/departmentTrainingPlans.d.ts.map +0 -1
  203. package/dist/esm/departmentTrainingPlans.js +0 -144
  204. package/dist/esm/departmentTrainingPlans.js.map +0 -1
  205. package/dist/esm/groups.d.ts +0 -90
  206. package/dist/esm/groups.d.ts.map +0 -1
  207. package/dist/esm/groups.js +0 -258
  208. package/dist/esm/groups.js.map +0 -1
  209. package/dist/esm/index.d.ts +0 -33
  210. package/dist/esm/index.d.ts.map +0 -1
  211. package/dist/esm/index.js +0 -33
  212. package/dist/esm/index.js.map +0 -1
  213. package/dist/esm/integration.d.ts +0 -82
  214. package/dist/esm/integration.d.ts.map +0 -1
  215. package/dist/esm/integration.js +0 -299
  216. package/dist/esm/integration.js.map +0 -1
  217. package/dist/esm/integrationConfiguration.d.ts +0 -27
  218. package/dist/esm/integrationConfiguration.d.ts.map +0 -1
  219. package/dist/esm/integrationConfiguration.js +0 -80
  220. package/dist/esm/integrationConfiguration.js.map +0 -1
  221. package/dist/esm/integrations/contentGenerator.d.ts +0 -22
  222. package/dist/esm/integrations/contentGenerator.d.ts.map +0 -1
  223. package/dist/esm/integrations/contentGenerator.js +0 -64
  224. package/dist/esm/integrations/contentGenerator.js.map +0 -1
  225. package/dist/esm/learningContent.d.ts +0 -153
  226. package/dist/esm/learningContent.d.ts.map +0 -1
  227. package/dist/esm/learningContent.js +0 -453
  228. package/dist/esm/learningContent.js.map +0 -1
  229. package/dist/esm/learningPath.d.ts +0 -64
  230. package/dist/esm/learningPath.d.ts.map +0 -1
  231. package/dist/esm/learningPath.js +0 -194
  232. package/dist/esm/learningPath.js.map +0 -1
  233. package/dist/esm/logger.d.ts +0 -19
  234. package/dist/esm/logger.d.ts.map +0 -1
  235. package/dist/esm/logger.js +0 -55
  236. package/dist/esm/logger.js.map +0 -1
  237. package/dist/esm/microSkillsQuizes.d.ts +0 -18
  238. package/dist/esm/microSkillsQuizes.d.ts.map +0 -1
  239. package/dist/esm/microSkillsQuizes.js +0 -48
  240. package/dist/esm/microSkillsQuizes.js.map +0 -1
  241. package/dist/esm/quotas.d.ts +0 -15
  242. package/dist/esm/quotas.d.ts.map +0 -1
  243. package/dist/esm/quotas.js +0 -45
  244. package/dist/esm/quotas.js.map +0 -1
  245. package/dist/esm/role.d.ts +0 -113
  246. package/dist/esm/role.d.ts.map +0 -1
  247. package/dist/esm/role.js +0 -346
  248. package/dist/esm/role.js.map +0 -1
  249. package/dist/esm/roleTemplate.d.ts +0 -73
  250. package/dist/esm/roleTemplate.d.ts.map +0 -1
  251. package/dist/esm/roleTemplate.js +0 -224
  252. package/dist/esm/roleTemplate.js.map +0 -1
  253. package/dist/esm/security.d.ts +0 -27
  254. package/dist/esm/security.d.ts.map +0 -1
  255. package/dist/esm/security.js +0 -72
  256. package/dist/esm/security.js.map +0 -1
  257. package/dist/esm/skill.d.ts +0 -141
  258. package/dist/esm/skill.d.ts.map +0 -1
  259. package/dist/esm/skill.js +0 -418
  260. package/dist/esm/skill.js.map +0 -1
  261. package/dist/esm/skillAssessmentTestingSession.d.ts +0 -85
  262. package/dist/esm/skillAssessmentTestingSession.d.ts.map +0 -1
  263. package/dist/esm/skillAssessmentTestingSession.js +0 -261
  264. package/dist/esm/skillAssessmentTestingSession.js.map +0 -1
  265. package/dist/esm/skillAssessments.d.ts +0 -49
  266. package/dist/esm/skillAssessments.d.ts.map +0 -1
  267. package/dist/esm/skillAssessments.js +0 -147
  268. package/dist/esm/skillAssessments.js.map +0 -1
  269. package/dist/esm/skillTemplate.d.ts +0 -87
  270. package/dist/esm/skillTemplate.d.ts.map +0 -1
  271. package/dist/esm/skillTemplate.js +0 -267
  272. package/dist/esm/skillTemplate.js.map +0 -1
  273. package/dist/esm/talentTransfromation.d.ts +0 -29
  274. package/dist/esm/talentTransfromation.d.ts.map +0 -1
  275. package/dist/esm/talentTransfromation.js +0 -93
  276. package/dist/esm/talentTransfromation.js.map +0 -1
  277. package/dist/esm/teams.d.ts +0 -85
  278. package/dist/esm/teams.d.ts.map +0 -1
  279. package/dist/esm/teams.js +0 -238
  280. package/dist/esm/teams.js.map +0 -1
  281. package/dist/esm/tenants.d.ts +0 -16
  282. package/dist/esm/tenants.d.ts.map +0 -1
  283. package/dist/esm/tenants.js +0 -50
  284. package/dist/esm/tenants.js.map +0 -1
  285. package/dist/esm/trainingPlans.d.ts +0 -92
  286. package/dist/esm/trainingPlans.d.ts.map +0 -1
  287. package/dist/esm/trainingPlans.js +0 -293
  288. package/dist/esm/trainingPlans.js.map +0 -1
  289. package/dist/esm/trainingPlansProficiencyLevels.d.ts +0 -32
  290. package/dist/esm/trainingPlansProficiencyLevels.d.ts.map +0 -1
  291. package/dist/esm/trainingPlansProficiencyLevels.js +0 -90
  292. package/dist/esm/trainingPlansProficiencyLevels.js.map +0 -1
  293. package/dist/esm/userInformation.d.ts +0 -29
  294. package/dist/esm/userInformation.d.ts.map +0 -1
  295. package/dist/esm/userInformation.js +0 -75
  296. package/dist/esm/userInformation.js.map +0 -1
  297. package/dist/esm/users.d.ts +0 -206
  298. package/dist/esm/users.d.ts.map +0 -1
  299. package/dist/esm/users.js +0 -663
  300. package/dist/esm/users.js.map +0 -1
  301. package/dist/esm/utils.d.ts +0 -14
  302. package/dist/esm/utils.d.ts.map +0 -1
  303. package/dist/esm/utils.js +0 -50
  304. package/dist/esm/utils.js.map +0 -1
@@ -0,0 +1,352 @@
1
+ import { client, errorToString } from "./axiosClient.js";
2
+ import axiosLib from "axios";
3
+ import htmlParser from "node-html-parser";
4
+ import htmlToText from "html2plaintext";
5
+
6
+ /**
7
+ * Create integration and set information
8
+ * @param {Object} data The new integration information
9
+ * @param {String} token Authorization token
10
+ */
11
+ export const createIntegration = (data, token) => {
12
+ return new Promise(function (resolve, reject) {
13
+ const requestData = {
14
+ data: data,
15
+ };
16
+ let confirmationRequest = client.put("api/v1/integrations/", requestData, {
17
+ headers: { authorization: token },
18
+ });
19
+ confirmationRequest
20
+ .then((response) => {
21
+ resolve(response.data);
22
+ })
23
+ .catch((error) => {
24
+ reject(error);
25
+ });
26
+ });
27
+ };
28
+
29
+ /**
30
+ * Delete integration
31
+ * @param {String} id The id of the integration to be deleted
32
+ * @param {String} token Authorization token
33
+ */
34
+ export const deleteIntegration = (id, token) => {
35
+ return new Promise(function (resolve, reject) {
36
+ const request = client.delete(`api/v1/integrations/`, {
37
+ headers: { authorization: token },
38
+ data: {
39
+ id: id,
40
+ },
41
+ });
42
+ request
43
+ .then((response) => {
44
+ resolve(response.data);
45
+ })
46
+ .catch((error) => {
47
+ reject(error);
48
+ });
49
+ });
50
+ };
51
+
52
+ /**
53
+ * Discard the integration draft changes
54
+ * @param {String} id The id of the role template to be deleted
55
+ * @param {String} token Authorization token
56
+ */
57
+ export const discardIntegrationChanges = (id, token) => {
58
+ return new Promise(function (resolve, reject) {
59
+ const data = {};
60
+ const request = client.get(`api/v1/integrations/discard/${id}`, {
61
+ headers: { authorization: token },
62
+ data: data,
63
+ });
64
+ request
65
+ .then((response) => {
66
+ resolve(response.data);
67
+ })
68
+ .catch((error) => {
69
+ reject(error);
70
+ });
71
+ });
72
+ };
73
+
74
+ /**
75
+ * Get integration information
76
+ * @param {String} id The id of the integration
77
+ * @param {String} version The version of the integration to be received
78
+ * @param {String} token Authorization token
79
+ */
80
+ export const getIntegrationInformationById = (id, version, token) => {
81
+ return new Promise(function (resolve, reject) {
82
+ let confirmationRequest = client.get(
83
+ `api/v1/integrations/${id}/${version}`,
84
+ {
85
+ headers: { authorization: token },
86
+ }
87
+ );
88
+ confirmationRequest
89
+ .then((response) => {
90
+ resolve(response.data);
91
+ })
92
+ .catch((error) => {
93
+ reject(error);
94
+ });
95
+ });
96
+ };
97
+
98
+ /**
99
+ * Get integrations list
100
+ * @param {Array<String>} filter The filter used to select the integration
101
+ * @param {String} type The type of the integration
102
+ * @param {String} version The version to be retrieved
103
+ * @param {Boolean} includeSupportedCapabilities If true, the supported capabilities will be included in the response
104
+ * @param {String} token Authorization token
105
+ */
106
+ export const getIntegrationsList = (
107
+ filter,
108
+ type,
109
+ version,
110
+ includeSupportedCapabilities,
111
+ token
112
+ ) => {
113
+ return new Promise(function (resolve, reject) {
114
+ const requestData = {
115
+ includeSupportedCapabilities: includeSupportedCapabilities,
116
+ version: version,
117
+ };
118
+ if (filter) requestData.filter = filter;
119
+ if (type) requestData.type = type;
120
+ let confirmationRequest = client.post(`api/v1/integrations`, requestData, {
121
+ headers: { authorization: token },
122
+ });
123
+ confirmationRequest
124
+ .then((response) => {
125
+ resolve(response.data);
126
+ })
127
+ .catch((error) => {
128
+ reject(error);
129
+ });
130
+ });
131
+ };
132
+
133
+ /**
134
+ * Get content information by Url
135
+ * @param {String} url The training url
136
+ * @param {String} verb The verb
137
+ * @param {String} token Authorization token
138
+ */
139
+ export const getContentInformationByUrl = (url, verb, token) => {
140
+ return new Promise(function (resolve, reject) {
141
+ const requestData = {
142
+ url: url,
143
+ verb: verb,
144
+ };
145
+ let confirmationRequest = client.post(
146
+ `api/v1/contentproviders/getcontentinformationbyurl`,
147
+ requestData,
148
+ {
149
+ headers: { authorization: token },
150
+ }
151
+ );
152
+ confirmationRequest
153
+ .then((response) => {
154
+ resolve(response.data);
155
+ })
156
+ .catch((error) => {
157
+ reject(error);
158
+ });
159
+ });
160
+ };
161
+
162
+ /**
163
+ * Get content information by url from the browser instead of the backend
164
+ * @param {String} url
165
+ * @returns {Object}
166
+ */
167
+ export const getContentInformationByUrlFromBrowser = (url) => {
168
+ return new Promise(function (resolve, reject) {
169
+ let domain = new URL(url);
170
+ let instance = axiosLib.create({
171
+ baseURL: domain.origin,
172
+ });
173
+ let confirmationRequest = instance.get(domain.pathname, {
174
+ headers: {
175
+ "Access-Control-Allow-Origin": "*",
176
+ "Access-Control-Allow-Headers":
177
+ "Authorization, Origin, X-Requested-With, Content-Type, Accept",
178
+ Accept:
179
+ "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
180
+ "Accept-Encoding": "gzip, deflate, br",
181
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
182
+ "User-Agent": "Mozilla/5.0",
183
+ },
184
+ });
185
+ confirmationRequest
186
+ .then((response) => {
187
+ //get the reading time
188
+ const getReadingTime = (text) => {
189
+ const wpm = 225;
190
+ const words = text.trim().split(/\s+/).length;
191
+ return Math.ceil(words / wpm);
192
+ };
193
+
194
+ let document = htmlParser.parse(response.responseText);
195
+ let duration = getReadingTime(htmlToText(response.responseText));
196
+ let title = document.querySelector("title")?.rawText;
197
+ let description = "";
198
+ const descriptionEl = document.querySelector("meta");
199
+ try {
200
+ if (descriptionEl) {
201
+ const descriptionParentNode = descriptionEl.parentNode;
202
+ if (descriptionParentNode) {
203
+ const descriptionChildNodes = descriptionParentNode.childNodes;
204
+ if (descriptionChildNodes) {
205
+ const descriptionRawAttr = descriptionChildNodes.find((item) =>
206
+ item.rawAttrs.includes("description")
207
+ );
208
+ if (descriptionRawAttr) {
209
+ const descriptionContent =
210
+ descriptionRawAttr.rawAttrs.substring(
211
+ descriptionRawAttr.rawAttrs.indexOf("content=") + 9
212
+ );
213
+ description = descriptionContent.substring(
214
+ 0,
215
+ descriptionContent.length - 1
216
+ );
217
+ }
218
+ }
219
+ }
220
+ }
221
+ } finally {
222
+ resolve({
223
+ description: description,
224
+ duration: duration,
225
+ icon: `http://www.google.com/s2/favicons?sz=128&domain_url=${pathArray[2]}`,
226
+ title: title ? title.trim() : url,
227
+ type: 0,
228
+ internal: true,
229
+ });
230
+ }
231
+ })
232
+ .catch((error) => {
233
+ reject(new Error(errorToString(error)));
234
+ });
235
+ });
236
+ };
237
+
238
+ /**
239
+ * Get enabled content providers
240
+ * @param {String} userid
241
+ * @param {String} verb The verb
242
+ * @param {String} token Authorization token
243
+ */
244
+ export const getEnabledContentProviders = (userId, token) => {
245
+ return new Promise(function (resolve, reject) {
246
+ let confirmationRequest = client.get(
247
+ `api/v1/contentproviders/getenabledcontentproviders/${userId}`,
248
+ {
249
+ headers: { authorization: token },
250
+ }
251
+ );
252
+ confirmationRequest
253
+ .then((response) => {
254
+ resolve(response.data);
255
+ })
256
+ .catch((error) => {
257
+ reject(error);
258
+ });
259
+ });
260
+ };
261
+
262
+ /**
263
+ * Publish integration
264
+ * @param {String} id The id of the integration to be published
265
+ * @param {String} token Authorization token
266
+ */
267
+ export const publishIntegration = (id, token) => {
268
+ return new Promise(function (resolve, reject) {
269
+ let confirmationRequest = client.post(
270
+ `api/v1/integrations/publish/${id}`,
271
+ {},
272
+ {
273
+ headers: { authorization: token },
274
+ }
275
+ );
276
+ confirmationRequest
277
+ .then((response) => {
278
+ resolve(response.data);
279
+ })
280
+ .catch((error) => {
281
+ reject(error);
282
+ });
283
+ });
284
+ };
285
+
286
+ /**
287
+ * Set integration information
288
+ * @param {String} id The id of the integration to be updated
289
+ * @param {Object} data Data used to update the integration
290
+ * @param {String} token Authorization token
291
+ */
292
+ export const setIntegrationInformation = (id, data, token) => {
293
+ return new Promise(function (resolve, reject) {
294
+ const requestData = {
295
+ data: data,
296
+ };
297
+ let confirmationRequest = client.post(
298
+ `api/v1/integrations/${id}`,
299
+ requestData,
300
+ {
301
+ headers: { authorization: token },
302
+ }
303
+ );
304
+ confirmationRequest
305
+ .then((response) => {
306
+ resolve(response.data);
307
+ })
308
+ .catch((error) => {
309
+ reject(error);
310
+ });
311
+ });
312
+ };
313
+
314
+ /**
315
+ * Set default integration
316
+ * @param {String} id The id of the integration to be set as default
317
+ * @param {String} token Authorization token
318
+ */
319
+ export const setDefaultIntegration = (id, token) => {
320
+ return new Promise(function (resolve, reject) {
321
+ let confirmationRequest = client.post(
322
+ `api/v1/integrations/${id}/default`,
323
+ "",
324
+ {
325
+ headers: { authorization: token },
326
+ }
327
+ );
328
+ confirmationRequest
329
+ .then((response) => {
330
+ resolve(response.data);
331
+ })
332
+ .catch((error) => {
333
+ reject(error);
334
+ });
335
+ });
336
+ };
337
+
338
+ const integration = {
339
+ createIntegration,
340
+ deleteIntegration,
341
+ discardIntegrationChanges,
342
+ getContentInformationByUrl,
343
+ getContentInformationByUrlFromBrowser,
344
+ getEnabledContentProviders,
345
+ getIntegrationInformationById,
346
+ getIntegrationsList,
347
+ publishIntegration,
348
+ setDefaultIntegration,
349
+ setIntegrationInformation,
350
+ };
351
+
352
+ export default integration;
@@ -0,0 +1,108 @@
1
+ import { client } from "./axiosClient.js";
2
+
3
+ /**
4
+ * Get the integration configuration
5
+ * @param {Array<String>} ids
6
+ * @param {Number} type
7
+ * @param {String} token Authorization token
8
+ */
9
+ export const getIntegrationsConfiguration = (ids, type, token) => {
10
+ return new Promise(function (resolve, reject) {
11
+ let requestData = { type: type };
12
+ if (ids) requestData.ids = ids;
13
+ let confirmationRequest = client.post(
14
+ "api/v1/integrationsconfiguration",
15
+ requestData,
16
+ {
17
+ headers: { authorization: token },
18
+ }
19
+ );
20
+ confirmationRequest
21
+ .then((response) => {
22
+ resolve(response.data);
23
+ })
24
+ .catch((error) => {
25
+ reject(error);
26
+ });
27
+ });
28
+ };
29
+
30
+ /**
31
+ * Save integration configuration
32
+ * @param {String} id The id of the integration configurationto be updated
33
+ * @param {Number} type The type of configuration
34
+ * @param {Object} configuration Data used to update the integration configuration
35
+ * @param {String} token Authorization token
36
+ */
37
+ export const saveIntegrationConfiguration = (
38
+ id,
39
+ type,
40
+ configuration,
41
+ token
42
+ ) => {
43
+ return new Promise(function (resolve, reject) {
44
+ const requestData = {
45
+ id: id,
46
+ configuration: configuration,
47
+ type: type,
48
+ };
49
+ let confirmationRequest = client.put(
50
+ `api/v1/integrationsconfiguration`,
51
+ requestData,
52
+ {
53
+ headers: { authorization: token },
54
+ }
55
+ );
56
+ confirmationRequest
57
+ .then((response) => {
58
+ resolve(response.data);
59
+ })
60
+ .catch((error) => {
61
+ reject(error);
62
+ });
63
+ });
64
+ };
65
+
66
+ /**
67
+ * Test integration configuration
68
+ * @param {String} id The id of the integration to be updated
69
+ * @param {String} type The type of configuration
70
+ * @param {Object} configuration Configuration to be tested
71
+ * @param {String} token Authorization token
72
+ */
73
+ export const testIntegrationConfiguration = (
74
+ id,
75
+ type,
76
+ configuration,
77
+ token
78
+ ) => {
79
+ return new Promise(function (resolve, reject) {
80
+ const requestData = {
81
+ id: id,
82
+ configuration: configuration,
83
+ type: type,
84
+ };
85
+ let confirmationRequest = client.post(
86
+ `api/v1/integrationsconfiguration/testConfiguration`,
87
+ requestData,
88
+ {
89
+ headers: { authorization: token },
90
+ }
91
+ );
92
+ confirmationRequest
93
+ .then((response) => {
94
+ resolve(response.data);
95
+ })
96
+ .catch((error) => {
97
+ reject(error);
98
+ });
99
+ });
100
+ };
101
+
102
+ const integrationConfiguration = {
103
+ getIntegrationsConfiguration,
104
+ saveIntegrationConfiguration,
105
+ testIntegrationConfiguration,
106
+ };
107
+
108
+ export default integrationConfiguration;
@@ -0,0 +1,79 @@
1
+ import { client } from "../axiosClient.js";
2
+
3
+ /**
4
+ * Generate content
5
+ * @param {Array<String>} data
6
+ * @param {String} contentType
7
+ * @param {String} integrationId
8
+ * @param {String} token
9
+ * @returns {Object}
10
+ */
11
+ export const generateContent = (data, contentType, integrationId, token) => {
12
+ return new Promise(function (resolve, reject) {
13
+ let data_ = {
14
+ data: data,
15
+ contentType: contentType,
16
+ };
17
+ if (integrationId) data.integrationId = integrationId;
18
+ const request = client.post(`api/v1/contentgenerators/generate`, data_, {
19
+ headers: { authorization: token },
20
+ });
21
+ request
22
+ .then((response) => {
23
+ resolve(response.data);
24
+ })
25
+ .catch((error) => {
26
+ reject(error);
27
+ });
28
+ });
29
+ };
30
+
31
+ /**
32
+ * Generate content aync
33
+ * @param {String} id
34
+ * @param {Object} data
35
+ * @param {String} contentType
36
+ * @param {String} elementType
37
+ * @param {String} integrationId
38
+ * @param {String} comments
39
+ * @param {String} token
40
+ * @returns {Object}
41
+ */
42
+ export const generateContentAsync = (
43
+ id,
44
+ data,
45
+ contentType,
46
+ elementType,
47
+ integrationId,
48
+ comments,
49
+ token
50
+ ) => {
51
+ return new Promise(function (resolve, reject) {
52
+ let data_ = {
53
+ data: data,
54
+ comments: comments,
55
+ contentType: contentType,
56
+ elementType: elementType,
57
+ id: id,
58
+ };
59
+ if (integrationId) data_.integrationId = integrationId;
60
+ const request = client.post(
61
+ `api/v1/contentgenerators/generateasync`,
62
+ data_,
63
+ {
64
+ headers: { authorization: token },
65
+ }
66
+ );
67
+ request
68
+ .then((response) => {
69
+ resolve(response.data);
70
+ })
71
+ .catch((error) => {
72
+ reject(error);
73
+ });
74
+ });
75
+ };
76
+
77
+ const contentGenerator = { generateContent, generateContentAsync };
78
+
79
+ export default contentGenerator;