@docbrasil/api-systemmanager 1.1.70 → 1.1.72

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 (82) hide show
  1. package/api/user/dashboard.js +93 -7
  2. package/dist/bundle.cjs +93 -7
  3. package/dist/bundle.mjs +1 -1
  4. package/doc/api.md +49 -7
  5. package/docs/Admin.html +1 -1
  6. package/docs/AdminDocuments.html +1 -1
  7. package/docs/AdminForm.html +1 -1
  8. package/docs/AdminLists.html +1 -1
  9. package/docs/AdminMessage.html +1 -1
  10. package/docs/AdminNotification.html +1 -1
  11. package/docs/AdminPlugin.html +1 -1
  12. package/docs/AdminPolicy.html +1 -1
  13. package/docs/AdminProcesses.html +1 -1
  14. package/docs/AdminTask.html +1 -1
  15. package/docs/AdminUser.html +1 -1
  16. package/docs/Application.html +1 -1
  17. package/docs/Chart.html +1 -1
  18. package/docs/Dashboard.html +74 -12
  19. package/docs/Datasource.html +1 -1
  20. package/docs/Dispatch.html +1 -1
  21. package/docs/Documents.html +1 -1
  22. package/docs/External.html +1 -1
  23. package/docs/GeoLocation.html +1 -1
  24. package/docs/Help.html +1 -1
  25. package/docs/Kanban.html +1 -1
  26. package/docs/Login.html +1 -1
  27. package/docs/MyTasks.html +1 -1
  28. package/docs/MyndAI.html +1 -1
  29. package/docs/Notification.html +1 -1
  30. package/docs/Organization.html +1 -1
  31. package/docs/Page.html +1 -1
  32. package/docs/Process.html +1 -1
  33. package/docs/Register.html +1 -1
  34. package/docs/Report.html +529 -0
  35. package/docs/Session.html +1 -1
  36. package/docs/Settings.html +1 -1
  37. package/docs/Task.html +1 -1
  38. package/docs/TaskAvailable.html +1 -1
  39. package/docs/Updates.html +1 -1
  40. package/docs/User.html +1 -1
  41. package/docs/Users.html +1 -1
  42. package/docs/admin_doctypes.js.html +1 -1
  43. package/docs/admin_document.js.html +1 -1
  44. package/docs/admin_form.js.html +1 -1
  45. package/docs/admin_index.js.html +1 -1
  46. package/docs/admin_list.js.html +1 -1
  47. package/docs/admin_message.js.html +1 -1
  48. package/docs/admin_notification.js.html +1 -1
  49. package/docs/admin_organization.js.html +1 -1
  50. package/docs/admin_plugin.js.html +1 -1
  51. package/docs/admin_policy.js.html +1 -1
  52. package/docs/admin_processes.js.html +1 -1
  53. package/docs/admin_task.js.html +1 -1
  54. package/docs/admin_user.js.html +1 -1
  55. package/docs/ai.js.html +1 -1
  56. package/docs/dispatch.js.html +1 -1
  57. package/docs/external.js.html +1 -1
  58. package/docs/general_geoLocation.js.html +1 -1
  59. package/docs/general_index.js.html +1 -1
  60. package/docs/index.html +1 -1
  61. package/docs/login.js.html +1 -1
  62. package/docs/session.js.html +1 -1
  63. package/docs/user_application.js.html +1 -1
  64. package/docs/user_dashboard.js.html +94 -8
  65. package/docs/user_datasource.js.html +1 -1
  66. package/docs/user_document.js.html +1 -1
  67. package/docs/user_help.js.html +1 -1
  68. package/docs/user_index.js.html +1 -1
  69. package/docs/user_kanban.js.html +1 -1
  70. package/docs/user_my_tasks.js.html +1 -1
  71. package/docs/user_notification.js.html +1 -1
  72. package/docs/user_organization.js.html +1 -1
  73. package/docs/user_page.js.html +1 -1
  74. package/docs/user_process.js.html +1 -1
  75. package/docs/user_register.js.html +1 -1
  76. package/docs/user_settings.js.html +1 -1
  77. package/docs/user_task.js.html +1 -1
  78. package/docs/user_task_available.js.html +1 -1
  79. package/docs/user_updates.js.html +1 -1
  80. package/docs/user_user.js.html +1 -1
  81. package/docs/utils_promises.js.html +1 -1
  82. package/package.json +1 -1
@@ -123,6 +123,88 @@ class Chart {
123
123
  }
124
124
  }
125
125
 
126
+ /**
127
+ * Class user access to reports
128
+ * @class
129
+ */
130
+ class Report {
131
+ constructor(options) {
132
+ Joi.assert(options, Joi.object().required());
133
+ Joi.assert(options.parent, Joi.object().required());
134
+
135
+ const self = this;
136
+ self.parent = options.parent;
137
+ self._client = self.parent.dispatch.getClient();
138
+ }
139
+
140
+ /**
141
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
142
+ * @description Get the return data and check for errors
143
+ * @param {object} retData Response HTTP
144
+ * @return {*}
145
+ * @private
146
+ */
147
+ _returnData(retData, def = {}) {
148
+ if (retData.status !== 200) {
149
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
150
+ } else {
151
+ return _.get(retData, 'data', def);
152
+ }
153
+ }
154
+
155
+ /**
156
+ * @author Myndware <augusto.pissarra@myndware.com>
157
+ * @description Set header with new session
158
+ * @param {string} session Session, token JWT
159
+ * @return {object} header with new session
160
+ * @private
161
+ */
162
+ _setHeader(session) {
163
+ return {
164
+ headers: {
165
+ Authorization: session,
166
+ }
167
+ };
168
+ }
169
+
170
+ /**
171
+ * @author Myndware <augusto.pissarra@myndware.com>
172
+ * @description Get the data for a report
173
+ * @param {object} params Params to get helps from topic
174
+ * @param {object} params.type Type of the report data
175
+ * @param {object} params.query The query if any (to search documents)
176
+ * @param {string} session Session, token JWT
177
+ * @returns {promise}
178
+ * @public
179
+ * @example
180
+ *
181
+ * const API = require('@docbrasil/api-systemmanager');
182
+ * const api = new API();
183
+ * const params = {
184
+ * type: '[REPORTS] Myndie:vat_data',
185
+ * query: { ... } // the last query to search documents
186
+ * };
187
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
188
+ * await api.user.dashboard.report.getData(params, session);
189
+ */
190
+ async getData(params, session) {
191
+ const self = this;
192
+
193
+ try {
194
+ Joi.assert(params, Joi.object().required(), 'Params to helps from a topic');
195
+ Joi.assert(params.type, Joi.string().required(), 'Type of graph');
196
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
197
+
198
+ const { type, query = {} } = params;
199
+ const apiCall = self._client.post(`/organizations/dashboard/report/data/${type}`, query, self._setHeader(session));
200
+
201
+ return self._returnData(await apiCall);
202
+ } catch (ex) {
203
+ throw ex;
204
+ }
205
+ }
206
+ }
207
+
126
208
  /**
127
209
  * Class user access to dashboards
128
210
  * @class
@@ -137,6 +219,7 @@ class Dashboard {
137
219
  self.parent = options.parent;
138
220
  self._client = self.parent.dispatch.getClient();
139
221
  self._chart = new Chart(options);
222
+ self._report = new Report(options);
140
223
  }
141
224
 
142
225
  /**
@@ -173,18 +256,21 @@ class Dashboard {
173
256
  * @author Augusto Pissarra <abernardo.br@gmail.com>
174
257
  * @description return the chart
175
258
  * @public
176
- * @async
177
- * @example
178
- *
179
- * const API = require('@docbrasil/api-systemmanager');
180
- * const api = new API();
181
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
182
- * await api.user.help.getTopics({}, session);
183
259
  */
184
260
  get chart() {
185
261
  const self = this;
186
262
  return self._chart;
187
263
  }
264
+
265
+ /**
266
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
267
+ * @description return the report
268
+ * @public
269
+ */
270
+ get report() {
271
+ const self = this;
272
+ return self._report;
273
+ }
188
274
  }
189
275
 
190
276
  export default Dashboard;
package/dist/bundle.cjs CHANGED
@@ -11869,6 +11869,88 @@ class Chart {
11869
11869
  }
11870
11870
  }
11871
11871
 
11872
+ /**
11873
+ * Class user access to reports
11874
+ * @class
11875
+ */
11876
+ class Report {
11877
+ constructor(options) {
11878
+ Joi__default["default"].assert(options, Joi__default["default"].object().required());
11879
+ Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
11880
+
11881
+ const self = this;
11882
+ self.parent = options.parent;
11883
+ self._client = self.parent.dispatch.getClient();
11884
+ }
11885
+
11886
+ /**
11887
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11888
+ * @description Get the return data and check for errors
11889
+ * @param {object} retData Response HTTP
11890
+ * @return {*}
11891
+ * @private
11892
+ */
11893
+ _returnData(retData, def = {}) {
11894
+ if (retData.status !== 200) {
11895
+ return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
11896
+ } else {
11897
+ return ___default["default"].get(retData, 'data', def);
11898
+ }
11899
+ }
11900
+
11901
+ /**
11902
+ * @author Myndware <augusto.pissarra@myndware.com>
11903
+ * @description Set header with new session
11904
+ * @param {string} session Session, token JWT
11905
+ * @return {object} header with new session
11906
+ * @private
11907
+ */
11908
+ _setHeader(session) {
11909
+ return {
11910
+ headers: {
11911
+ Authorization: session,
11912
+ }
11913
+ };
11914
+ }
11915
+
11916
+ /**
11917
+ * @author Myndware <augusto.pissarra@myndware.com>
11918
+ * @description Get the data for a report
11919
+ * @param {object} params Params to get helps from topic
11920
+ * @param {object} params.type Type of the report data
11921
+ * @param {object} params.query The query if any (to search documents)
11922
+ * @param {string} session Session, token JWT
11923
+ * @returns {promise}
11924
+ * @public
11925
+ * @example
11926
+ *
11927
+ * const API = require('@docbrasil/api-systemmanager');
11928
+ * const api = new API();
11929
+ * const params = {
11930
+ * type: '[REPORTS] Myndie:vat_data',
11931
+ * query: { ... } // the last query to search documents
11932
+ * };
11933
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11934
+ * await api.user.dashboard.report.getData(params, session);
11935
+ */
11936
+ async getData(params, session) {
11937
+ const self = this;
11938
+
11939
+ try {
11940
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to helps from a topic');
11941
+ Joi__default["default"].assert(params.type, Joi__default["default"].string().required(), 'Type of graph');
11942
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
11943
+
11944
+ const { type, query = {} } = params;
11945
+ const apiCall = self._client.post(`/organizations/dashboard/report/data/${type}`, query, self._setHeader(session));
11946
+
11947
+ return self._returnData(await apiCall);
11948
+ } catch (ex) {
11949
+ throw ex;
11950
+ }
11951
+ }
11952
+ }
11953
+
11872
11954
  /**
11873
11955
  * Class user access to dashboards
11874
11956
  * @class
@@ -11883,6 +11965,7 @@ class Dashboard {
11883
11965
  self.parent = options.parent;
11884
11966
  self._client = self.parent.dispatch.getClient();
11885
11967
  self._chart = new Chart(options);
11968
+ self._report = new Report(options);
11886
11969
  }
11887
11970
 
11888
11971
  /**
@@ -11919,18 +12002,21 @@ class Dashboard {
11919
12002
  * @author Augusto Pissarra <abernardo.br@gmail.com>
11920
12003
  * @description return the chart
11921
12004
  * @public
11922
- * @async
11923
- * @example
11924
- *
11925
- * const API = require('@docbrasil/api-systemmanager');
11926
- * const api = new API();
11927
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11928
- * await api.user.help.getTopics({}, session);
11929
12005
  */
11930
12006
  get chart() {
11931
12007
  const self = this;
11932
12008
  return self._chart;
11933
12009
  }
12010
+
12011
+ /**
12012
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
12013
+ * @description return the report
12014
+ * @public
12015
+ */
12016
+ get report() {
12017
+ const self = this;
12018
+ return self._report;
12019
+ }
11934
12020
  }
11935
12021
 
11936
12022
  /**