@stackfactor/client-api 1.1.12-9.2 → 1.1.12

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