@docbrasil/api-systemmanager 1.1.23 → 1.1.25

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 (78) hide show
  1. package/api/user/dashboard.js +150 -0
  2. package/api/user/index.js +2 -0
  3. package/dist/bundle.cjs +146 -0
  4. package/dist/bundle.mjs +1 -1
  5. package/doc/api.md +59 -0
  6. package/docs/Admin.html +1 -1
  7. package/docs/AdminDocuments.html +1 -1
  8. package/docs/AdminForm.html +1 -1
  9. package/docs/AdminLists.html +1 -1
  10. package/docs/AdminMessage.html +1 -1
  11. package/docs/AdminNotification.html +1 -1
  12. package/docs/AdminPlugin.html +1 -1
  13. package/docs/AdminPolicy.html +1 -1
  14. package/docs/AdminProcesses.html +1 -1
  15. package/docs/AdminTask.html +1 -1
  16. package/docs/AdminUser.html +1 -1
  17. package/docs/Application.html +1 -1
  18. package/docs/Chart.html +528 -0
  19. package/docs/Dashboard.html +349 -0
  20. package/docs/Datasource.html +1 -1
  21. package/docs/Dispatch.html +1 -1
  22. package/docs/Documents.html +1 -1
  23. package/docs/External.html +1 -1
  24. package/docs/GeoLocation.html +1 -1
  25. package/docs/Help.html +1 -1
  26. package/docs/Login.html +1 -1
  27. package/docs/MyTasks.html +1 -1
  28. package/docs/Notification.html +1 -1
  29. package/docs/Organization.html +1 -1
  30. package/docs/Page.html +1 -1
  31. package/docs/Process.html +1 -1
  32. package/docs/Register.html +1 -1
  33. package/docs/Session.html +1 -1
  34. package/docs/Settings.html +1 -1
  35. package/docs/Task.html +1 -1
  36. package/docs/TaskAvailable.html +1 -1
  37. package/docs/Updates.html +1 -1
  38. package/docs/User.html +1 -1
  39. package/docs/Users.html +2 -2
  40. package/docs/admin_doctypes.js.html +1 -1
  41. package/docs/admin_document.js.html +1 -1
  42. package/docs/admin_form.js.html +1 -1
  43. package/docs/admin_index.js.html +1 -1
  44. package/docs/admin_list.js.html +1 -1
  45. package/docs/admin_message.js.html +1 -1
  46. package/docs/admin_notification.js.html +1 -1
  47. package/docs/admin_organization.js.html +1 -1
  48. package/docs/admin_plugin.js.html +1 -1
  49. package/docs/admin_policy.js.html +1 -1
  50. package/docs/admin_processes.js.html +1 -1
  51. package/docs/admin_task.js.html +1 -1
  52. package/docs/admin_user.js.html +1 -1
  53. package/docs/dispatch.js.html +1 -1
  54. package/docs/external.js.html +1 -1
  55. package/docs/general_geoLocation.js.html +1 -1
  56. package/docs/general_index.js.html +1 -1
  57. package/docs/index.html +1 -1
  58. package/docs/login.js.html +1 -1
  59. package/docs/session.js.html +1 -1
  60. package/docs/user_application.js.html +1 -1
  61. package/docs/user_dashboard.js.html +267 -0
  62. package/docs/user_datasource.js.html +1 -1
  63. package/docs/user_document.js.html +1 -1
  64. package/docs/user_help.js.html +1 -1
  65. package/docs/user_index.js.html +3 -1
  66. package/docs/user_my_tasks.js.html +1 -1
  67. package/docs/user_notification.js.html +1 -1
  68. package/docs/user_organization.js.html +1 -1
  69. package/docs/user_page.js.html +1 -1
  70. package/docs/user_process.js.html +1 -1
  71. package/docs/user_register.js.html +1 -1
  72. package/docs/user_settings.js.html +1 -1
  73. package/docs/user_task.js.html +1 -1
  74. package/docs/user_task_available.js.html +1 -1
  75. package/docs/user_updates.js.html +1 -1
  76. package/docs/user_user.js.html +1 -1
  77. package/docs/utils_promises.js.html +1 -1
  78. package/package.json +1 -1
@@ -0,0 +1,150 @@
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+
5
+ /**
6
+ * Class user access to charts
7
+ * @class
8
+ */
9
+ class Chart {
10
+ constructor(options) {
11
+ Joi.assert(options, Joi.object().required());
12
+ Joi.assert(options.parent, Joi.object().required());
13
+
14
+ const self = this;
15
+ self.parent = options.parent;
16
+ self._client = self.parent.dispatch.getClient();
17
+ }
18
+
19
+ /**
20
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
21
+ * @description Get the return data and check for errors
22
+ * @param {object} retData Response HTTP
23
+ * @return {*}
24
+ * @private
25
+ */
26
+ _returnData(retData, def = {}) {
27
+ if (retData.status !== 200) {
28
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
29
+ } else {
30
+ return _.get(retData, 'data', def);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * @author Myndware <augusto.pissarra@myndware.com>
36
+ * @description Set header with new session
37
+ * @param {string} session Session, token JWT
38
+ * @return {object} header with new session
39
+ * @private
40
+ */
41
+ _setHeader(session) {
42
+ return {
43
+ headers: {
44
+ authorization: session,
45
+ }
46
+ };
47
+ }
48
+
49
+ /**
50
+ * @author Myndware <augusto.pissarra@myndware.com>
51
+ * @description Get the data for a chart
52
+ * @param {object} params Params to get helps from topic
53
+ * @param {object} params.type Type of the chart data
54
+ * @param {object} params.query The query if any
55
+ * @param {string} session Session, token JWT
56
+ * @returns {promise}
57
+ * @public
58
+ * @example
59
+ *
60
+ * const API = require('@docbrasil/api-systemmanager');
61
+ * const api = new API();
62
+ * const params = {
63
+ * type: 'heatmap_data'
64
+ * };
65
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
66
+ * await api.user.dashboard.chart.getData(params, session);
67
+ */
68
+ async getData(params, session) {
69
+ const self = this;
70
+
71
+ try {
72
+ Joi.assert(params, Joi.object().required(), 'Params to helps from a topic');
73
+ Joi.assert(params.type, Joi.string().required(), 'Type of graph');
74
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
75
+
76
+ const { type, query = {} } = params;
77
+ const apiCall = self._client.post(`/organizations/dashboard/chart/data/${type}`, query, self._setHeader(session));
78
+
79
+ return self._returnData(await apiCall);
80
+ } catch (ex) {
81
+ throw ex;
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Class user access to dashboards
88
+ * @class
89
+ */
90
+ class Dashboard {
91
+
92
+ constructor(options) {
93
+ Joi.assert(options, Joi.object().required());
94
+ Joi.assert(options.parent, Joi.object().required());
95
+
96
+ const self = this;
97
+ self.parent = options.parent;
98
+ self._client = self.parent.dispatch.getClient();
99
+ self._chart = new Chart(options);
100
+ }
101
+
102
+ /**
103
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
104
+ * @description Get the return data and check for errors
105
+ * @param {object} retData Response HTTP
106
+ * @return {*}
107
+ * @private
108
+ */
109
+ _returnData(retData, def = {}) {
110
+ if (retData.status !== 200) {
111
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
112
+ } else {
113
+ return _.get(retData, 'data', def);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * @author Myndware <augusto.pissarra@myndware.com>
119
+ * @description Set header with new session
120
+ * @param {string} session Session, token JWT
121
+ * @return {object} header with new session
122
+ * @private
123
+ */
124
+ _setHeader(session) {
125
+ return {
126
+ headers: {
127
+ authorization: session,
128
+ }
129
+ };
130
+ }
131
+
132
+ /**
133
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
134
+ * @description return the chart
135
+ * @public
136
+ * @async
137
+ * @example
138
+ *
139
+ * const API = require('@docbrasil/api-systemmanager');
140
+ * const api = new API();
141
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
142
+ * await api.user.help.getTopics({}, session);
143
+ */
144
+ get chart() {
145
+ const self = this;
146
+ return self._chart;
147
+ }
148
+ }
149
+
150
+ export default Dashboard;
package/api/user/index.js CHANGED
@@ -13,6 +13,7 @@ import Help from './help.js';
13
13
  import Datasource from './datasource.js';
14
14
  import Application from './application.js';
15
15
  import Settings from './settings.js';
16
+ import Dashboard from './dashboard.js';
16
17
 
17
18
  /**
18
19
  * @class API request, user permission level
@@ -41,6 +42,7 @@ class Users {
41
42
  self.updates = new Updates(options);
42
43
  self.help = new Help(options);
43
44
  self.application = new Application(options);
45
+ self.dashboard = new Dashboard(options);
44
46
  }
45
47
  }
46
48
 
package/dist/bundle.cjs CHANGED
@@ -11002,6 +11002,151 @@ class Settings {
11002
11002
  }
11003
11003
  }
11004
11004
 
11005
+ /**
11006
+ * Class user access to charts
11007
+ * @class
11008
+ */
11009
+ class Chart {
11010
+ constructor(options) {
11011
+ Joi__default["default"].assert(options, Joi__default["default"].object().required());
11012
+ Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
11013
+
11014
+ const self = this;
11015
+ self.parent = options.parent;
11016
+ self._client = self.parent.dispatch.getClient();
11017
+ }
11018
+
11019
+ /**
11020
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11021
+ * @description Get the return data and check for errors
11022
+ * @param {object} retData Response HTTP
11023
+ * @return {*}
11024
+ * @private
11025
+ */
11026
+ _returnData(retData, def = {}) {
11027
+ if (retData.status !== 200) {
11028
+ return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
11029
+ } else {
11030
+ return ___default["default"].get(retData, 'data', def);
11031
+ }
11032
+ }
11033
+
11034
+ /**
11035
+ * @author Myndware <augusto.pissarra@myndware.com>
11036
+ * @description Set header with new session
11037
+ * @param {string} session Session, token JWT
11038
+ * @return {object} header with new session
11039
+ * @private
11040
+ */
11041
+ _setHeader(session) {
11042
+ return {
11043
+ headers: {
11044
+ authorization: session,
11045
+ }
11046
+ };
11047
+ }
11048
+
11049
+ /**
11050
+ * @author Myndware <augusto.pissarra@myndware.com>
11051
+ * @description Get the data for a chart
11052
+ * @param {object} params Params to get helps from topic
11053
+ * @param {object} params.type Type of the chart data
11054
+ * @param {object} params.query The query if any
11055
+ * @param {string} session Session, token JWT
11056
+ * @returns {promise}
11057
+ * @public
11058
+ * @example
11059
+ *
11060
+ * const API = require('@docbrasil/api-systemmanager');
11061
+ * const api = new API();
11062
+ * const params = {
11063
+ * type: 'heatmap_data'
11064
+ * };
11065
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11066
+ * await api.user.dashboard.chart.getData(params, session);
11067
+ */
11068
+ async getData(params, session) {
11069
+ const self = this;
11070
+
11071
+ try {
11072
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to helps from a topic');
11073
+ Joi__default["default"].assert(params.type, Joi__default["default"].string().required(), 'Type of graph');
11074
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
11075
+
11076
+ const { type, query = {} } = params;
11077
+ const apiCall = self._client.post(`/organizations/dashboard/chart/data/${type}`, query, self._setHeader(session));
11078
+
11079
+ return self._returnData(await apiCall);
11080
+ } catch (ex) {
11081
+ throw ex;
11082
+ }
11083
+ }
11084
+ }
11085
+
11086
+ /**
11087
+ * Class user access to dashboards
11088
+ * @class
11089
+ */
11090
+ class Dashboard {
11091
+
11092
+ constructor(options) {
11093
+ Joi__default["default"].assert(options, Joi__default["default"].object().required());
11094
+ Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
11095
+
11096
+ const self = this;
11097
+ self.parent = options.parent;
11098
+ self._client = self.parent.dispatch.getClient();
11099
+ self._chart = new Chart(options);
11100
+ }
11101
+
11102
+ /**
11103
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11104
+ * @description Get the return data and check for errors
11105
+ * @param {object} retData Response HTTP
11106
+ * @return {*}
11107
+ * @private
11108
+ */
11109
+ _returnData(retData, def = {}) {
11110
+ if (retData.status !== 200) {
11111
+ return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
11112
+ } else {
11113
+ return ___default["default"].get(retData, 'data', def);
11114
+ }
11115
+ }
11116
+
11117
+ /**
11118
+ * @author Myndware <augusto.pissarra@myndware.com>
11119
+ * @description Set header with new session
11120
+ * @param {string} session Session, token JWT
11121
+ * @return {object} header with new session
11122
+ * @private
11123
+ */
11124
+ _setHeader(session) {
11125
+ return {
11126
+ headers: {
11127
+ authorization: session,
11128
+ }
11129
+ };
11130
+ }
11131
+
11132
+ /**
11133
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11134
+ * @description return the chart
11135
+ * @public
11136
+ * @async
11137
+ * @example
11138
+ *
11139
+ * const API = require('@docbrasil/api-systemmanager');
11140
+ * const api = new API();
11141
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11142
+ * await api.user.help.getTopics({}, session);
11143
+ */
11144
+ get chart() {
11145
+ const self = this;
11146
+ return self._chart;
11147
+ }
11148
+ }
11149
+
11005
11150
  /**
11006
11151
  * @class API request, user permission level
11007
11152
  */
@@ -11029,6 +11174,7 @@ class Users {
11029
11174
  self.updates = new Updates(options);
11030
11175
  self.help = new Help(options);
11031
11176
  self.application = new Application(options);
11177
+ self.dashboard = new Dashboard(options);
11032
11178
  }
11033
11179
  }
11034
11180