@stackfactor/client-api 1.1.128 → 1.1.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/{actionNotifications.js → actionNotifications.ts} +18 -6
  2. package/lib/{address.js → address.ts} +3 -2
  3. package/lib/{aiAssistant.js → aiAssistant.ts} +58 -25
  4. package/lib/{avatar.js → avatar.ts} +10 -4
  5. package/lib/axiosClient.ts +92 -0
  6. package/lib/{config.js → config.ts} +19 -6
  7. package/lib/{constants.js → constants.ts} +6 -41
  8. package/lib/{dashboard.js → dashboard.ts} +17 -7
  9. package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +57 -23
  10. package/lib/{groups.js → groups.ts} +67 -26
  11. package/lib/{integration.js → integration.ts} +100 -43
  12. package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +25 -8
  13. package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
  14. package/lib/{learningContent.js → learningContent.ts} +127 -66
  15. package/lib/{learningPath.js → learningPath.ts} +56 -29
  16. package/lib/{logger.js → logger.ts} +17 -5
  17. package/lib/{microSkillsQuizes.js → microSkillsQuizes.ts} +15 -6
  18. package/lib/{quotas.js → quotas.ts} +10 -5
  19. package/lib/{role.js → role.ts} +114 -66
  20. package/lib/{roleTemplate.js → roleTemplate.ts} +63 -28
  21. package/lib/{security.js → security.ts} +14 -10
  22. package/lib/{skill.js → skill.ts} +119 -82
  23. package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +39 -17
  24. package/lib/skillAssessments.ts +192 -0
  25. package/lib/{skillTemplate.js → skillTemplate.ts} +70 -39
  26. package/lib/{talentTransfromation.js → talentTransfromation.ts} +21 -15
  27. package/lib/{teams.js → teams.ts} +71 -27
  28. package/lib/{tenants.js → tenants.ts} +16 -7
  29. package/lib/{trainingPlans.js → trainingPlans.ts} +96 -59
  30. package/lib/{trainingPlansProficiencyLevels.js → trainingPlansProficiencyLevels.ts} +29 -23
  31. package/lib/{userInformation.js → userInformation.ts} +25 -12
  32. package/lib/{users.js → users.ts} +172 -154
  33. package/lib/{utils.js → utils.ts} +6 -6
  34. package/package.json +3 -1
  35. package/lib/axiosClient.js +0 -82
  36. package/lib/skillAssessmentTestingSession.js +0 -147
  37. /package/{exports.js → exports.ts} +0 -0
  38. /package/{index.js → index.ts} +0 -0
@@ -3,9 +3,10 @@ import { client } from "./axiosClient.js";
3
3
  /**
4
4
  * Get all permissions
5
5
  * @param {String} token The authentication token
6
+ * @returns {Promise<Object>}
6
7
  */
7
- const getAllUserNotifications = (token) => {
8
- return new Promise(function (resolve, reject) {
8
+ const getAllUserNotifications = (token: string): Promise<object> => {
9
+ return new Promise((resolve, reject) => {
9
10
  const request = client.get(`api/v1/actionnotifications`, {
10
11
  headers: { authorization: token },
11
12
  });
@@ -24,9 +25,14 @@ const getAllUserNotifications = (token) => {
24
25
  * @param {Array<String>} ids The id of the notifications to be marked
25
26
  * @param {String} status The new status
26
27
  * @param {String} authToken The authentication token
28
+ * @returns {Promise<Object>}
27
29
  */
28
- const markNotifications = (ids, status, authToken) => {
29
- return new Promise(function (resolve, reject) {
30
+ const markNotifications = (
31
+ ids: string[],
32
+ status: string,
33
+ authToken: string
34
+ ): Promise<object> => {
35
+ return new Promise((resolve, reject) => {
30
36
  const request = client.put(
31
37
  `api/v1/actionnotifications/mark`,
32
38
  {
@@ -51,9 +57,15 @@ const markNotifications = (ids, status, authToken) => {
51
57
  * @param {String} action The action to be executed
52
58
  * @param {String} comments The comments to be saved in the notification
53
59
  * @param {String} authToken The authentication token
60
+ * @returns {Promise<Object>}
54
61
  */
55
- const processNotification = (id, action, comments, authToken) => {
56
- return new Promise(function (resolve, reject) {
62
+ const processNotification = (
63
+ id: string,
64
+ action: string,
65
+ comments: string,
66
+ authToken: string
67
+ ): Promise<object> => {
68
+ return new Promise((resolve, reject) => {
57
69
  const request = client.put(
58
70
  `api/v1/actionnotifications/process`,
59
71
  {
@@ -4,9 +4,10 @@ import { client } from "./axiosClient.js";
4
4
  * Validate Address
5
5
  * @param {String} input - the address in raw format
6
6
  * @param {String} authToken - Authorization token
7
+ * @returns {Promise<Object>}
7
8
  */
8
- const autoComplete = (input, authToken) => {
9
- return new Promise(function (resolve, reject) {
9
+ const autoComplete = (input: string, authToken: string): Promise<object> => {
10
+ return new Promise((resolve, reject) => {
10
11
  const getAddressesRequest = client.post(
11
12
  `api/v1/address/autocomplete/`,
12
13
  { input: input },
@@ -1,16 +1,40 @@
1
1
  import { client } from "./axiosClient.js";
2
2
 
3
+ interface AskQuestionData {
4
+ conversationId: string;
5
+ question: string;
6
+ updatedContext: string;
7
+ }
8
+
9
+ interface EndConversationData {
10
+ conversationId: string;
11
+ }
12
+
13
+ interface StartConversationData {
14
+ autoContextRefresh: boolean;
15
+ context: string;
16
+ question: string;
17
+ elementId: string;
18
+ elementType: string;
19
+ conversationId?: string | null;
20
+ }
21
+
3
22
  /**
4
23
  * Ask Question to the AI
5
24
  * @param {String} conversationId
6
25
  * @param {String} question
7
26
  * @param {String} updatedContext
8
27
  * @param {String} token Authorization token
9
- * @returns {Promise}
28
+ * @returns {Promise<Object>}
10
29
  */
11
- const askQuestion = (conversationId, question, updatedContext, token) => {
12
- return new Promise(function (resolve, reject) {
13
- let data = {
30
+ const askQuestion = (
31
+ conversationId: string,
32
+ question: string,
33
+ updatedContext: string,
34
+ token: string
35
+ ): Promise<object> => {
36
+ return new Promise((resolve, reject) => {
37
+ let data: AskQuestionData = {
14
38
  conversationId: conversationId,
15
39
  question: question,
16
40
  updatedContext: updatedContext,
@@ -36,11 +60,14 @@ const askQuestion = (conversationId, question, updatedContext, token) => {
36
60
  * End conversation with the AI
37
61
  * @param {String} conversationId
38
62
  * @param {String} token Authorization token
39
- * @returns {Promise}
63
+ * @returns {Promise<Object>}
40
64
  */
41
- const endConversation = (conversationId, token) => {
42
- return new Promise(function (resolve, reject) {
43
- let data = {
65
+ const endConversation = (
66
+ conversationId: string,
67
+ token: string
68
+ ): Promise<object> => {
69
+ return new Promise((resolve, reject) => {
70
+ let data: EndConversationData = {
44
71
  conversationId: conversationId,
45
72
  };
46
73
  let confirmationRequest = client.post(
@@ -64,10 +91,13 @@ const endConversation = (conversationId, token) => {
64
91
  * Get conversation by elementId
65
92
  * @param {String} elementId
66
93
  * @param {String} token
67
- * @returns {Promise}
94
+ * @returns {Promise<Object>}
68
95
  */
69
- const getConversationByElementId = (elementId, token) => {
70
- return new Promise(function (resolve, reject) {
96
+ const getConversationByElementId = (
97
+ elementId: string,
98
+ token: string
99
+ ): Promise<object> => {
100
+ return new Promise((resolve, reject) => {
71
101
  let confirmationRequest = client.get(
72
102
  `/api/v1/aiassistant/getconversation/${elementId}`,
73
103
  {
@@ -88,10 +118,13 @@ const getConversationByElementId = (elementId, token) => {
88
118
  * Get the voice assistant URL
89
119
  * @param {String} language
90
120
  * @param {String} token
91
- * @returns {Promise}
121
+ * @returns {Promise<Object>}
92
122
  */
93
- const getVoiceAssistantUrl = (language, token) => {
94
- return new Promise(function (resolve, reject) {
123
+ const getVoiceAssistantUrl = (
124
+ language: string,
125
+ token: string
126
+ ): Promise<object> => {
127
+ return new Promise((resolve, reject) => {
95
128
  let confirmationRequest = client.get(
96
129
  `/api/v1/aiassistant/getvoiceassistanturl/${language}`,
97
130
  {
@@ -116,19 +149,19 @@ const getVoiceAssistantUrl = (language, token) => {
116
149
  * @param {Boolean} autoContextRefresh
117
150
  * @param {String} token
118
151
  * @param {String} conversationId Optional
119
- * @returns {Promise}
152
+ * @returns {Promise<Object>}
120
153
  */
121
154
  const startConversation = (
122
- elementId,
123
- elementType,
124
- question,
125
- context,
126
- autoContextRefresh,
127
- token,
128
- conversationId = null
129
- ) => {
130
- return new Promise(function (resolve, reject) {
131
- let data = {
155
+ elementId: string,
156
+ elementType: string,
157
+ question: string,
158
+ context: string,
159
+ autoContextRefresh: boolean,
160
+ token: string,
161
+ conversationId: string | null = null
162
+ ): Promise<object> => {
163
+ return new Promise((resolve, reject) => {
164
+ let data: StartConversationData = {
132
165
  autoContextRefresh: autoContextRefresh,
133
166
  context: context,
134
167
  question: question,
@@ -7,10 +7,16 @@ import { client } from "./axiosClient.js";
7
7
  * @param {Number} width
8
8
  * @param {Number} height
9
9
  * @param {String} token
10
- * @returns {Promise}
10
+ * @returns {Promise<Blob>}
11
11
  */
12
- const getAvatar = (elementId, type, width, height, token) => {
13
- return new Promise(function (resolve, reject) {
12
+ const getAvatar = (
13
+ elementId: string,
14
+ type: string,
15
+ width: number,
16
+ height: number,
17
+ token: string
18
+ ): Promise<Blob> => {
19
+ return new Promise((resolve, reject) => {
14
20
  let confirmationRequest = client.get(
15
21
  `/api/v1/avatar/getavatar/${elementId}/${type}/${width}/${height}`,
16
22
  {
@@ -22,7 +28,7 @@ const getAvatar = (elementId, type, width, height, token) => {
22
28
  );
23
29
  confirmationRequest
24
30
  .then((response) => {
25
- resolve(response);
31
+ resolve(response.data);
26
32
  })
27
33
  .catch(() => {
28
34
  reject("Error getting avatar");
@@ -0,0 +1,92 @@
1
+ import axios, { AxiosError } from "axios";
2
+ import { RESPONSE_TYPE } from "./constants.js";
3
+ import utils from "./utils.js";
4
+
5
+ const baseUrl = utils.getBaseUrl();
6
+
7
+ const client = axios.create({
8
+ baseURL: baseUrl,
9
+ withCredentials: true,
10
+ });
11
+
12
+ /**
13
+ * Returns the error as a string
14
+ * @param {AxiosError} error
15
+ * @returns {string}
16
+ */
17
+ const errorToString = (error: AxiosError): string => {
18
+ if (error != null) {
19
+ if (error.response?.data) {
20
+ let asString = "";
21
+ if (Array.isArray((error.response.data as any).errors)) {
22
+ (error.response.data as any).errors.forEach(
23
+ (item: any, index: number) => {
24
+ asString += `${index > 0 ? ", " : ""} ${item.msg} param ${
25
+ item.param
26
+ } ${item.value ? `value ${item.value.toString()}` : ""}`;
27
+ }
28
+ );
29
+ return asString;
30
+ } else if ((error.response.data as any).error) {
31
+ return (error.response.data as any).error.toString();
32
+ } else if (error.response.statusText) {
33
+ return error.response.statusText.toString();
34
+ } else {
35
+ return (error.response.data as any).toString();
36
+ }
37
+ } else {
38
+ return error.message ? error.message : "Unknown error";
39
+ }
40
+ }
41
+ return "Unknown error";
42
+ };
43
+
44
+ /**
45
+ * Returns the code of the error as a number
46
+ * @param {AxiosError} error
47
+ * @returns {number} The error code
48
+ */
49
+ const getErrorType = (error: AxiosError): number => {
50
+ if (error.response?.status) {
51
+ return error.response.status;
52
+ } else return RESPONSE_TYPE.SERVICE_UNAVAILABLE;
53
+ };
54
+
55
+ /**
56
+ * Return the error information to include just the status and the message
57
+ * @param {AxiosError} error
58
+ * @returns {Object}
59
+ */
60
+ const getErrorInformation = (
61
+ error: AxiosError
62
+ ): { status: number; message: string } => {
63
+ return {
64
+ status: getErrorType(error),
65
+ message: errorToString(error),
66
+ };
67
+ };
68
+
69
+ /**
70
+ * Returns true if an exception should be handled to the business and presentation layer
71
+ * @param {boolean} returnAllExceptions - If set true all exceptions will be passed
72
+ * @param {AxiosError} error - The error returned by the server
73
+ * @returns {boolean}
74
+ */
75
+ const shouldReturnError = (
76
+ returnAllExceptions: boolean,
77
+ error: AxiosError
78
+ ): boolean => {
79
+ if (getErrorType(error) === RESPONSE_TYPE.UNAUTHORIZED) {
80
+ return returnAllExceptions;
81
+ } else {
82
+ return true;
83
+ }
84
+ };
85
+
86
+ export {
87
+ client,
88
+ errorToString,
89
+ getErrorType,
90
+ getErrorInformation,
91
+ shouldReturnError,
92
+ };
@@ -4,9 +4,13 @@ import { client } from "./axiosClient.js";
4
4
  * Get the specified configuration by Id. It returns a promise
5
5
  * @param {String} id - the id of the configuration element
6
6
  * @param {String} authToken - Authorization token
7
+ * @returns {Promise<Object>}
7
8
  */
8
- const getConfigurationById = (id, authToken) => {
9
- return new Promise(function (resolve, reject) {
9
+ const getConfigurationById = (
10
+ id: string,
11
+ authToken: string
12
+ ): Promise<object> => {
13
+ return new Promise((resolve, reject) => {
10
14
  const getConfigInformationRequest = client.get(
11
15
  `api/v1/configurations/configuration/id/${id}`,
12
16
  { headers: { authorization: authToken } }
@@ -25,9 +29,13 @@ const getConfigurationById = (id, authToken) => {
25
29
  * Get the specified configuration by type. It returns a promise
26
30
  * @param {String} type - the id of the configuration element
27
31
  * @param {String} authToken - Authorization token
32
+ * @returns {Promise<Object>}
28
33
  */
29
- const getConfigurationByType = (type, authToken) => {
30
- return new Promise(function (resolve, reject) {
34
+ const getConfigurationByType = (
35
+ type: string,
36
+ authToken: string
37
+ ): Promise<object> => {
38
+ return new Promise((resolve, reject) => {
31
39
  const getConfigInformationRequest = client.get(
32
40
  `api/v1/configurations/configuration/type/${type}`,
33
41
  { headers: { authorization: authToken } }
@@ -47,9 +55,14 @@ const getConfigurationByType = (type, authToken) => {
47
55
  * @param {String} id - the id of the configuration element
48
56
  * @param {Object} data - the object containing the updated configuration element
49
57
  * @param {String} authToken - Authorization token
58
+ * @returns {Promise<Object>}
50
59
  */
51
- const setConfigurationById = (id, data, authToken) => {
52
- return new Promise(function (resolve, reject) {
60
+ const setConfigurationById = (
61
+ id: string,
62
+ data: object,
63
+ authToken: string
64
+ ): Promise<object> => {
65
+ return new Promise((resolve, reject) => {
53
66
  const getConfigInformationRequest = client.post(
54
67
  `api/v1/configurations/configuration/${id}`,
55
68
  { data: data },
@@ -1,78 +1,44 @@
1
1
  const DOCUMENT_VERSION = {
2
2
  DRAFT: "draft",
3
3
  PUBLISHED: "published",
4
- };
4
+ } as const;
5
5
 
6
6
  const RESPONSE_TYPE = {
7
- //The requested resource corresponds to any one of a set of representations, each with its own specific location.
8
7
  MULTIPLE_CHOICES: 300,
9
- //The resource has moved permanently. Please refer to the documentation.
10
8
  MOVED_PERMANENTLY: 301,
11
- //The resource has moved temporarily. Please refer to the documentation.
12
9
  FOUND: 302,
13
- //The resource can be found under a different URI.
14
10
  SEE_OTHER: 303,
15
- //The resource is available and not modified.
16
11
  NOT_MODIFIED: 304,
17
- //The requested resource must be accessed through the proxy given by the Location field.
18
12
  USE_PROXY: 305,
19
- //The resource resides temporarily under a different URI.
20
13
  TEMPORARY_REDIRECT: 307,
21
- //Invalid syntax for this request was provided.
22
14
  BAD_REQUEST: 400,
23
- //You are unauthorized to access the requested resource. Please log in.
24
15
  UNAUTHORIZED: 401,
25
- //Your account is not authorized to access the requested resource.
26
16
  FORBIDDEN: 403,
27
- //We could not find the resource you requested. Please refer to the documentation for the list of resources.
28
17
  NOT_FOUND: 404,
29
- //This method type is not currently supported.
30
18
  METHOD_NOT_ALLOWED: 405,
31
- //Acceptance header is invalid for this endpoint resource.
32
19
  NOT_ACCEPTABLE: 406,
33
- //Authentication with proxy is required.
34
20
  PROXY_AUTHENTICATION_REQUIRED: 407,
35
- //Client did not produce a request within the time that the server was prepared to wait.
36
21
  REQUEST_TIMEOUT: 408,
37
- //The request could not be completed due to a conflict with the current state of the resource.
38
22
  CONFLICT: 409,
39
- //The requested resource is no longer available and has been permanently removed.
40
23
  GONE: 410,
41
- //Length of the content is required, please include it with the request.
42
24
  LENGTH_REQUIRED: 411,
43
- //The request did not match the pre-conditions of the requested resource.
44
25
  PRECONDITION_FAILED: 412,
45
- //The request entity is larger than the server is willing or able to process.
46
26
  REQUEST_ENTITY_TOO_LARGE: 413,
47
- //The request URI is longer than the server is willing to interpret.
48
27
  REQUEST_URI_TOO_LONG: 414,
49
- //The requested resource does not support the media type provided.
50
28
  UNSUPPORTED_MEDIA_TYPE: 415,
51
- //The requested range for the resource is not available.
52
29
  REQUESTED_RANGE_NOT_SATISFIABLE: 416,
53
- //Unable to meet the expectation given in the Expect request header.
54
30
  EXPECTATION_FAILED: 417,
55
- //The requested resource is missing required arguments.
56
31
  MISSING_ARGUMENTS: 419,
57
- //The requested resource does not support one or more of the given parameters.
58
32
  INVALID_ARGUMENTS: 420,
59
- //The request was well-formed but was unable to be followed due to semantic errors.
60
33
  UNPROCESSABLE_ENTITY: 422,
61
- //Unexpected internal server error.
62
34
  INTERNAL_SERVER_ERROR: 500,
63
- //The requested resource is recognized but not implemented.
64
35
  NOT_IMPLEMENTED: 501,
65
- //Invalid response received when acting as a proxy or gateway.
66
36
  BAD_GATEWAY: 502,
67
- //The server is currently unavailable.
68
37
  SERVICE_UNAVAILABLE: 503,
69
- //Did not receive a timely response from upstream server while acting as a gateway or proxy.
70
38
  GATEWAY_TIMEOUT: 504,
71
- //The HTTP protocol version used in the request message is not supported.
72
39
  HTTP_VERSION_NOT_SUPPORTED: 505,
73
- //A failure occurred during initialization of services. API will be unavailable.
74
40
  INITIALIZATION_FAILURE: 550,
75
- };
41
+ } as const;
76
42
 
77
43
  const PERMISSIONS = {
78
44
  ACCESS_TO_CONTENT_GENERATORS: "651d81d626fb9aafa4077520",
@@ -98,9 +64,9 @@ const PERMISSIONS = {
98
64
  MANAGE_USERS: "5dd612e40f0bc559c41a2b29",
99
65
  PROMOTE_CONTENT: "5fac2126427ce31f8a92c0cb",
100
66
  TALENT_TRANSFORMATION_CHAMPION: "5fac210f7e6539d37a897c95",
101
- };
67
+ } as const;
102
68
 
103
- const PERMISSION_DESCRIPTIONS = {
69
+ const PERMISSION_DESCRIPTIONS: { [key: string]: string } = {
104
70
  "5ea3d1152839450e16e72bba": "Author content",
105
71
  "5ea3d10bea252025c8ec351b": "Promote content",
106
72
  "61970935cee185acf08111f6": "Manage content providers",
@@ -113,8 +79,7 @@ const PERMISSION_DESCRIPTIONS = {
113
79
  "5dd61305a73c68b44c3f0827": "Manage learning paths",
114
80
  "5dd612d5338ea9a6ae6326da": "Manage organization information",
115
81
  "5fac210e7e6539d37a897c94": "Auto approve own profile information updates",
116
- "650fadb23956a2154ac890ac":
117
- "Skip assessment when updating own profile information",
82
+ "650fadb23956a2154ac890ac": "Skip assessment when updating own profile information",
118
83
  "5fac21164351c6727a34cd4e": "Auto approve own skill set updates",
119
84
  "66ff566a911d938bc00618bf": "Manage security",
120
85
  "5e1570e087d836dc77888a5f": "Manage settings",
@@ -129,4 +94,4 @@ export {
129
94
  PERMISSIONS,
130
95
  PERMISSION_DESCRIPTIONS,
131
96
  RESPONSE_TYPE,
132
- };
97
+ };
@@ -6,9 +6,15 @@ import { client } from "./axiosClient.js";
6
6
  * @param {Number} position - The position on the dashboard
7
7
  * @param {Object} data - The card settings data
8
8
  * @param {String} authToken - Authorization token
9
+ * @returns {Promise<Object>}
9
10
  */
10
- const addCardToDashboard = (id, position, data, authToken) => {
11
- return new Promise(function (resolve, reject) {
11
+ const addCardToDashboard = (
12
+ id: string,
13
+ position: number,
14
+ data: object,
15
+ authToken: string
16
+ ): Promise<object> => {
17
+ return new Promise((resolve, reject) => {
12
18
  const request = client.put(
13
19
  `/api/v1/dashboard/card`,
14
20
  {
@@ -31,9 +37,10 @@ const addCardToDashboard = (id, position, data, authToken) => {
31
37
  /**
32
38
  * Get the list of the cards from the dashboard
33
39
  * @param {String} authToken - Authorization token
40
+ * @returns {Promise<Object>}
34
41
  */
35
- const getDashboardCardsList = (authToken) => {
36
- return new Promise(function (resolve, reject) {
42
+ const getDashboardCardsList = (authToken: string): Promise<object> => {
43
+ return new Promise((resolve, reject) => {
37
44
  const request = client.get(`/api/v1/dashboard/card`, {
38
45
  headers: { authorization: authToken },
39
46
  });
@@ -51,12 +58,15 @@ const getDashboardCardsList = (authToken) => {
51
58
  * Remove a card from the dashboard
52
59
  * @param {String} id - the id of the configuration element
53
60
  * @param {String} authToken - Authorization token
61
+ * @returns {Promise<Object>}
54
62
  */
55
- const removeCardFromDashboard = (id, authToken) => {
56
- return new Promise(function (resolve, reject) {
63
+ const removeCardFromDashboard = (
64
+ id: string,
65
+ authToken: string
66
+ ): Promise<object> => {
67
+ return new Promise((resolve, reject) => {
57
68
  const request = client.delete(`/api/v1/dashboard/card`, {
58
69
  headers: { authorization: authToken },
59
-
60
70
  data: {
61
71
  id: id,
62
72
  },
@@ -1,20 +1,30 @@
1
1
  import { client } from "./axiosClient.js";
2
2
 
3
+ interface Activity {
4
+ // Define the structure of an activity object here
5
+ }
6
+
7
+ interface Filter {
8
+ // Define the structure of a filter object here
9
+ }
10
+
3
11
  /**
4
12
  * Create department training plan and set information
5
13
  * @param {String} name
6
14
  * @param {String} summary
7
- * @param {Array<Object>} activities
15
+ * @param {String} skill
16
+ * @param {Array<Activity>} activities
8
17
  * @param {String} token Authorization token
18
+ * @returns {Promise<Object>}
9
19
  */
10
20
  const createDepartmentTrainingPlan = (
11
- name,
12
- summary,
13
- skill,
14
- activities,
15
- token
16
- ) => {
17
- return new Promise(function (resolve, reject) {
21
+ name: string,
22
+ summary: string,
23
+ skill: string,
24
+ activities: Activity[],
25
+ token: string
26
+ ): Promise<object> => {
27
+ return new Promise((resolve, reject) => {
18
28
  const requestData = {
19
29
  name: name || "",
20
30
  summary: summary || "",
@@ -42,12 +52,15 @@ const createDepartmentTrainingPlan = (
42
52
  * Delete department training plan
43
53
  * @param {String} id The id of the template to be deleted
44
54
  * @param {String} token Authorization token
55
+ * @returns {Promise<Object>}
45
56
  */
46
- const deleteDepartmentTrainingPlan = (id, token) => {
47
- return new Promise(function (resolve, reject) {
57
+ const deleteDepartmentTrainingPlan = (
58
+ id: string,
59
+ token: string
60
+ ): Promise<object> => {
61
+ return new Promise((resolve, reject) => {
48
62
  const request = client.delete(`api/v1/departmenttrainingplans/`, {
49
63
  headers: { authorization: token },
50
-
51
64
  data: {
52
65
  id: id,
53
66
  },
@@ -63,12 +76,18 @@ const deleteDepartmentTrainingPlan = (id, token) => {
63
76
  };
64
77
 
65
78
  /**
66
- * Get department traing plan information
79
+ * Get department training plan information
67
80
  * @param {Number} id The id of the plan
81
+ * @param {String} version The version of the plan
68
82
  * @param {String} token Authorization token
83
+ * @returns {Promise<Object>}
69
84
  */
70
- const getDepartmentTrainingPlanInformationById = (id, version, token) => {
71
- return new Promise(function (resolve, reject) {
85
+ const getDepartmentTrainingPlanInformationById = (
86
+ id: number,
87
+ version: string,
88
+ token: string
89
+ ): Promise<object> => {
90
+ return new Promise((resolve, reject) => {
72
91
  let confirmationRequest = client.get(
73
92
  `api/v1/departmenttrainingplans/${id}/${version}`,
74
93
  {
@@ -87,11 +106,17 @@ const getDepartmentTrainingPlanInformationById = (id, version, token) => {
87
106
 
88
107
  /**
89
108
  * Get department training plan list
90
- * @param {Object} filter The filter used to select the plan
109
+ * @param {Filter} filter The filter used to select the plan
110
+ * @param {String} version The version of the plan
91
111
  * @param {String} token Authorization token
112
+ * @returns {Promise<Object>}
92
113
  */
93
- const getDepartmentTrainingPlanList = (filter, version, token) => {
94
- return new Promise(function (resolve, reject) {
114
+ const getDepartmentTrainingPlanList = (
115
+ filter: Filter,
116
+ version: string,
117
+ token: string
118
+ ): Promise<object> => {
119
+ return new Promise((resolve, reject) => {
95
120
  const requestData = {
96
121
  filter: filter || "",
97
122
  version: version,
@@ -117,9 +142,13 @@ const getDepartmentTrainingPlanList = (filter, version, token) => {
117
142
  * Publish department training plan
118
143
  * @param {number} id The id of the plan to be published
119
144
  * @param {String} token Authorization token
145
+ * @returns {Promise<Object>}
120
146
  */
121
- const publishDepartmentTrainingPlan = (id, token) => {
122
- return new Promise(function (resolve, reject) {
147
+ const publishDepartmentTrainingPlan = (
148
+ id: number,
149
+ token: string
150
+ ): Promise<object> => {
151
+ return new Promise((resolve, reject) => {
123
152
  let confirmationRequest = client.post(
124
153
  `api/v1/departmenttrainingplans/publish/${id}`,
125
154
  {},
@@ -142,9 +171,14 @@ const publishDepartmentTrainingPlan = (id, token) => {
142
171
  * @param {String} id The id of the plan to be updated
143
172
  * @param {Object} data Data used to update the plan
144
173
  * @param {String} token Authorization token
174
+ * @returns {Promise<Object>}
145
175
  */
146
- const setDepartmentTrainingPlanInformation = (id, data, token) => {
147
- return new Promise(function (resolve, reject) {
176
+ const setDepartmentTrainingPlanInformation = (
177
+ id: string,
178
+ data: object,
179
+ token: string
180
+ ): Promise<object> => {
181
+ return new Promise((resolve, reject) => {
148
182
  const requestData = {
149
183
  data: data,
150
184
  };
@@ -165,7 +199,7 @@ const setDepartmentTrainingPlanInformation = (id, data, token) => {
165
199
  });
166
200
  };
167
201
 
168
- const departmentTraingPlans = {
202
+ const departmentTrainingPlans = {
169
203
  createDepartmentTrainingPlan,
170
204
  deleteDepartmentTrainingPlan,
171
205
  getDepartmentTrainingPlanInformationById,
@@ -174,4 +208,4 @@ const departmentTraingPlans = {
174
208
  setDepartmentTrainingPlanInformation,
175
209
  };
176
210
 
177
- export default departmentTraingPlans;
211
+ export default departmentTrainingPlans;