@docbrasil/api-systemmanager 1.1.24 → 1.1.26

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.
package/.project ADDED
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>api-systemmanager</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ </buildSpec>
9
+ <natures>
10
+ </natures>
11
+ </projectDescription>
@@ -147,4 +147,4 @@ class Dashboard {
147
147
  }
148
148
  }
149
149
 
150
- export default Help;
150
+ export default Dashboard;
@@ -802,6 +802,137 @@ class Documents {
802
802
  throw ex;
803
803
  }
804
804
  }
805
+
806
+ /**
807
+ * @author Myndware <augusto.pissarra@myndware.com>
808
+ * @description Method to export excel for all pages
809
+ * @param {object} params Params to export excel for all pages
810
+ * @param {object} params.query Export excel for all pages query
811
+ * @param {object} params.orgId Organization id (_id database)
812
+ * @param {string} session Session, token JWT
813
+ * @returns {promise} returned data from the export excel for all pages
814
+ * @public
815
+ * @example
816
+ *
817
+ * const API = require('@docbrasil/api-systemmanager');
818
+ * const api = new API();
819
+ * const params = {
820
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
821
+ * orgId: '55e4a3bd6be6b45210833fae',
822
+ * };
823
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
824
+ * const retSearch = await api.user.document.exportExcelForAllPages(params, session);
825
+ */
826
+ async exportExcelForAllPages(params, session) {
827
+ const self = this;
828
+
829
+ try {
830
+ Joi.assert(params, Joi.object().required(), 'Params to export excel for all pages');
831
+ Joi.assert(params.query, Joi.object().required(), 'The query for the export excel for all pages');
832
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
833
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
834
+
835
+ const {query, orgId} = params;
836
+ const searchParams = new URLSearchParams(query);
837
+ const queryString = searchParams.toString();
838
+ const apiCall = self._client.get(`/organizations/${orgId}/documents/export/excel?${queryString}`, self._setHeader(session));
839
+
840
+ return self._returnData(await apiCall);
841
+ } catch (ex) {
842
+ throw ex;
843
+ }
844
+ }
845
+
846
+ /**
847
+ * @author Myndware <augusto.pissarra@myndware.com>
848
+ * @description Method to export Wms Excel for all pages
849
+ * @param {object} params Params to export Wms Excel for all pages
850
+ * @param {object} params.query export Wms Excel for all pages query
851
+ * @param {object} params.orgId Organization id (_id database)
852
+ * @param {string} session Session, token JWT
853
+ * @returns {promise} returned data from the export Wms Excel for all pages
854
+ * @public
855
+ * @example
856
+ *
857
+ * const API = require('@docbrasil/api-systemmanager');
858
+ * const api = new API();
859
+ * const params = {
860
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
861
+ * orgId: '55e4a3bd6be6b45210833fae',
862
+ * };
863
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
864
+ * const retSearch = await api.user.document.exportWmsExcelForAllPages(params, session);
865
+ */
866
+ async exportWmsExcelForAllPages(params, session) {
867
+ const self = this;
868
+
869
+ try {
870
+ Joi.assert(params, Joi.object().required(), 'Params to export Wms Excel for all pages');
871
+ Joi.assert(params.query, Joi.object().required(), 'The query for the export Wms Excel for all pages');
872
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
873
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
874
+
875
+ const {query, orgId} = params;
876
+ const searchParams = new URLSearchParams(query);
877
+ const queryString = searchParams.toString();
878
+ const apiCall = self._client.get(`/organizations/${orgId}/documents/wms/export/excel?${queryString}`, self._setHeader(session));
879
+
880
+ return self._returnData(await apiCall);
881
+ } catch (ex) {
882
+ throw ex;
883
+ }
884
+ }
885
+
886
+ /**
887
+ * @author Myndware <augusto.pissarra@myndware.com>
888
+ * @description Method to perform download complete for all pages
889
+ * @param {object} params Params to perform download complete for all pages
890
+ * @param {object} params.data data to be send to download
891
+ * @param {object} params.query perform download complete for all pages query
892
+ * @param {object} params.orgId Organization id (_id database)
893
+ * @param {string} session Session, token JWT
894
+ * @returns {promise} returned data from the perform download complete for all pages
895
+ * @public
896
+ * @example
897
+ *
898
+ * const API = require('@docbrasil/api-systemmanager');
899
+ * const api = new API();
900
+ * const params = {
901
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
902
+ * orgId: '55e4a3bd6be6b45210833fae',
903
+ * data: {
904
+ * destAws = {
905
+ destAwsKey: '',
906
+ destAwsSecret: '',
907
+ destAwsBucket: '',
908
+ destAwsRegion: ''
909
+ },
910
+ maxFileSize: ''
911
+ * }
912
+ * };
913
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
914
+ * const retSearch = await api.user.document.performDownloadComplete(params, session);
915
+ */
916
+ async performDownloadComplete(params, session) {
917
+ const self = this;
918
+
919
+ Joi.assert(params, Joi.object().required(), 'Params to perform download complete for all pages');
920
+ Joi.assert(params.data, Joi.object().required(), 'The data for the perform download complete for all pages');
921
+ Joi.assert(params.query, Joi.object().required(), 'The query for the perform download complete for all pages');
922
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
923
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
924
+
925
+ try {
926
+ const {query, orgId, data} = params;
927
+ const searchParams = new URLSearchParams(query);
928
+ const queryString = searchParams.toString();
929
+
930
+ const apiCall = self._client.post(`/organizations/${orgId}/documents/download/attachments?${queryString}`, data, self._setHeader(session));
931
+ return self._returnData(await apiCall);
932
+ } catch (ex) {
933
+ throw ex;
934
+ }
935
+ }
805
936
  }
806
937
 
807
938
  export default Documents;
package/dist/bundle.cjs CHANGED
@@ -1354,6 +1354,137 @@ class Documents {
1354
1354
  throw ex;
1355
1355
  }
1356
1356
  }
1357
+
1358
+ /**
1359
+ * @author Myndware <augusto.pissarra@myndware.com>
1360
+ * @description Method to export excel for all pages
1361
+ * @param {object} params Params to export excel for all pages
1362
+ * @param {object} params.query Export excel for all pages query
1363
+ * @param {object} params.orgId Organization id (_id database)
1364
+ * @param {string} session Session, token JWT
1365
+ * @returns {promise} returned data from the export excel for all pages
1366
+ * @public
1367
+ * @example
1368
+ *
1369
+ * const API = require('@docbrasil/api-systemmanager');
1370
+ * const api = new API();
1371
+ * const params = {
1372
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1373
+ * orgId: '55e4a3bd6be6b45210833fae',
1374
+ * };
1375
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1376
+ * const retSearch = await api.user.document.exportExcelForAllPages(params, session);
1377
+ */
1378
+ async exportExcelForAllPages(params, session) {
1379
+ const self = this;
1380
+
1381
+ try {
1382
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to export excel for all pages');
1383
+ Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the export excel for all pages');
1384
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1385
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1386
+
1387
+ const {query, orgId} = params;
1388
+ const searchParams = new URLSearchParams(query);
1389
+ const queryString = searchParams.toString();
1390
+ const apiCall = self._client.get(`/organizations/${orgId}/documents/export/excel?${queryString}`, self._setHeader(session));
1391
+
1392
+ return self._returnData(await apiCall);
1393
+ } catch (ex) {
1394
+ throw ex;
1395
+ }
1396
+ }
1397
+
1398
+ /**
1399
+ * @author Myndware <augusto.pissarra@myndware.com>
1400
+ * @description Method to export Wms Excel for all pages
1401
+ * @param {object} params Params to export Wms Excel for all pages
1402
+ * @param {object} params.query export Wms Excel for all pages query
1403
+ * @param {object} params.orgId Organization id (_id database)
1404
+ * @param {string} session Session, token JWT
1405
+ * @returns {promise} returned data from the export Wms Excel for all pages
1406
+ * @public
1407
+ * @example
1408
+ *
1409
+ * const API = require('@docbrasil/api-systemmanager');
1410
+ * const api = new API();
1411
+ * const params = {
1412
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1413
+ * orgId: '55e4a3bd6be6b45210833fae',
1414
+ * };
1415
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1416
+ * const retSearch = await api.user.document.exportWmsExcelForAllPages(params, session);
1417
+ */
1418
+ async exportWmsExcelForAllPages(params, session) {
1419
+ const self = this;
1420
+
1421
+ try {
1422
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to export Wms Excel for all pages');
1423
+ Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the export Wms Excel for all pages');
1424
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1425
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1426
+
1427
+ const {query, orgId} = params;
1428
+ const searchParams = new URLSearchParams(query);
1429
+ const queryString = searchParams.toString();
1430
+ const apiCall = self._client.get(`/organizations/${orgId}/documents/wms/export/excel?${queryString}`, self._setHeader(session));
1431
+
1432
+ return self._returnData(await apiCall);
1433
+ } catch (ex) {
1434
+ throw ex;
1435
+ }
1436
+ }
1437
+
1438
+ /**
1439
+ * @author Myndware <augusto.pissarra@myndware.com>
1440
+ * @description Method to perform download complete for all pages
1441
+ * @param {object} params Params to perform download complete for all pages
1442
+ * @param {object} params.data data to be send to download
1443
+ * @param {object} params.query perform download complete for all pages query
1444
+ * @param {object} params.orgId Organization id (_id database)
1445
+ * @param {string} session Session, token JWT
1446
+ * @returns {promise} returned data from the perform download complete for all pages
1447
+ * @public
1448
+ * @example
1449
+ *
1450
+ * const API = require('@docbrasil/api-systemmanager');
1451
+ * const api = new API();
1452
+ * const params = {
1453
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1454
+ * orgId: '55e4a3bd6be6b45210833fae',
1455
+ * data: {
1456
+ * destAws = {
1457
+ destAwsKey: '',
1458
+ destAwsSecret: '',
1459
+ destAwsBucket: '',
1460
+ destAwsRegion: ''
1461
+ },
1462
+ maxFileSize: ''
1463
+ * }
1464
+ * };
1465
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1466
+ * const retSearch = await api.user.document.performDownloadComplete(params, session);
1467
+ */
1468
+ async performDownloadComplete(params, session) {
1469
+ const self = this;
1470
+
1471
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to perform download complete for all pages');
1472
+ Joi__default["default"].assert(params.data, Joi__default["default"].object().required(), 'The data for the perform download complete for all pages');
1473
+ Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the perform download complete for all pages');
1474
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1475
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1476
+
1477
+ try {
1478
+ const {query, orgId, data} = params;
1479
+ const searchParams = new URLSearchParams(query);
1480
+ const queryString = searchParams.toString();
1481
+
1482
+ const apiCall = self._client.post(`/organizations/${orgId}/documents/download/attachments?${queryString}`, data, self._setHeader(session));
1483
+ return self._returnData(await apiCall);
1484
+ } catch (ex) {
1485
+ throw ex;
1486
+ }
1487
+ }
1357
1488
  }
1358
1489
 
1359
1490
  /**
@@ -10446,7 +10577,7 @@ class Updates {
10446
10577
  * Class for user registration in a user
10447
10578
  * @class
10448
10579
  */
10449
- class Help$1 {
10580
+ class Help {
10450
10581
 
10451
10582
  constructor(options) {
10452
10583
  Joi__default["default"].assert(options, Joi__default["default"].object().required());
@@ -11002,7 +11133,150 @@ class Settings {
11002
11133
  }
11003
11134
  }
11004
11135
 
11005
- var Dashboard = Help;
11136
+ /**
11137
+ * Class user access to charts
11138
+ * @class
11139
+ */
11140
+ class Chart {
11141
+ constructor(options) {
11142
+ Joi__default["default"].assert(options, Joi__default["default"].object().required());
11143
+ Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
11144
+
11145
+ const self = this;
11146
+ self.parent = options.parent;
11147
+ self._client = self.parent.dispatch.getClient();
11148
+ }
11149
+
11150
+ /**
11151
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11152
+ * @description Get the return data and check for errors
11153
+ * @param {object} retData Response HTTP
11154
+ * @return {*}
11155
+ * @private
11156
+ */
11157
+ _returnData(retData, def = {}) {
11158
+ if (retData.status !== 200) {
11159
+ return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
11160
+ } else {
11161
+ return ___default["default"].get(retData, 'data', def);
11162
+ }
11163
+ }
11164
+
11165
+ /**
11166
+ * @author Myndware <augusto.pissarra@myndware.com>
11167
+ * @description Set header with new session
11168
+ * @param {string} session Session, token JWT
11169
+ * @return {object} header with new session
11170
+ * @private
11171
+ */
11172
+ _setHeader(session) {
11173
+ return {
11174
+ headers: {
11175
+ authorization: session,
11176
+ }
11177
+ };
11178
+ }
11179
+
11180
+ /**
11181
+ * @author Myndware <augusto.pissarra@myndware.com>
11182
+ * @description Get the data for a chart
11183
+ * @param {object} params Params to get helps from topic
11184
+ * @param {object} params.type Type of the chart data
11185
+ * @param {object} params.query The query if any
11186
+ * @param {string} session Session, token JWT
11187
+ * @returns {promise}
11188
+ * @public
11189
+ * @example
11190
+ *
11191
+ * const API = require('@docbrasil/api-systemmanager');
11192
+ * const api = new API();
11193
+ * const params = {
11194
+ * type: 'heatmap_data'
11195
+ * };
11196
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11197
+ * await api.user.dashboard.chart.getData(params, session);
11198
+ */
11199
+ async getData(params, session) {
11200
+ const self = this;
11201
+
11202
+ try {
11203
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to helps from a topic');
11204
+ Joi__default["default"].assert(params.type, Joi__default["default"].string().required(), 'Type of graph');
11205
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
11206
+
11207
+ const { type, query = {} } = params;
11208
+ const apiCall = self._client.post(`/organizations/dashboard/chart/data/${type}`, query, self._setHeader(session));
11209
+
11210
+ return self._returnData(await apiCall);
11211
+ } catch (ex) {
11212
+ throw ex;
11213
+ }
11214
+ }
11215
+ }
11216
+
11217
+ /**
11218
+ * Class user access to dashboards
11219
+ * @class
11220
+ */
11221
+ class Dashboard {
11222
+
11223
+ constructor(options) {
11224
+ Joi__default["default"].assert(options, Joi__default["default"].object().required());
11225
+ Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
11226
+
11227
+ const self = this;
11228
+ self.parent = options.parent;
11229
+ self._client = self.parent.dispatch.getClient();
11230
+ self._chart = new Chart(options);
11231
+ }
11232
+
11233
+ /**
11234
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11235
+ * @description Get the return data and check for errors
11236
+ * @param {object} retData Response HTTP
11237
+ * @return {*}
11238
+ * @private
11239
+ */
11240
+ _returnData(retData, def = {}) {
11241
+ if (retData.status !== 200) {
11242
+ return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
11243
+ } else {
11244
+ return ___default["default"].get(retData, 'data', def);
11245
+ }
11246
+ }
11247
+
11248
+ /**
11249
+ * @author Myndware <augusto.pissarra@myndware.com>
11250
+ * @description Set header with new session
11251
+ * @param {string} session Session, token JWT
11252
+ * @return {object} header with new session
11253
+ * @private
11254
+ */
11255
+ _setHeader(session) {
11256
+ return {
11257
+ headers: {
11258
+ authorization: session,
11259
+ }
11260
+ };
11261
+ }
11262
+
11263
+ /**
11264
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11265
+ * @description return the chart
11266
+ * @public
11267
+ * @async
11268
+ * @example
11269
+ *
11270
+ * const API = require('@docbrasil/api-systemmanager');
11271
+ * const api = new API();
11272
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11273
+ * await api.user.help.getTopics({}, session);
11274
+ */
11275
+ get chart() {
11276
+ const self = this;
11277
+ return self._chart;
11278
+ }
11279
+ }
11006
11280
 
11007
11281
  /**
11008
11282
  * @class API request, user permission level
@@ -11029,7 +11303,7 @@ class Users {
11029
11303
  self.register = new Register(options);
11030
11304
  self.notification = new Notification(options);
11031
11305
  self.updates = new Updates(options);
11032
- self.help = new Help$1(options);
11306
+ self.help = new Help(options);
11033
11307
  self.application = new Application(options);
11034
11308
  self.dashboard = new Dashboard(options);
11035
11309
  }