@docbrasil/api-systemmanager 1.1.26 → 1.1.28

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.
@@ -81,6 +81,46 @@ class Chart {
81
81
  throw ex;
82
82
  }
83
83
  }
84
+
85
+ /**
86
+ * @author Myndware <augusto.pissarra@myndware.com>
87
+ * @description Get the question data from a chart data
88
+ * @param {object} params Params to get helps from topic
89
+ * @param {object} params.orgId The organization id of the question
90
+ * @param {object} params.processId The process id of the question
91
+ * @param {object} params.path The path of the question so we can retrieve it
92
+ * @param {string} session Session, token JWT
93
+ * @returns {promise} data the question data
94
+ * @public
95
+ * @example
96
+ *
97
+ * const API = require('@docbrasil/api-systemmanager');
98
+ * const api = new API();
99
+ * const params = {
100
+ * orgId: '637e7523f555fabdfb1ed7b6',
101
+ * processId: '123e7523f555fabdfb1ed7c6',
102
+ * path: 'Checklist.Group Name.Field Name'
103
+ * };
104
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
105
+ * await api.user.dashboard.chart.getQuestion(params, session);
106
+ */
107
+ async getQuestion(params, session) {
108
+ const self = this;
109
+
110
+ try {
111
+ Joi.assert(params, Joi.object().required(), 'Params to helps from a topic');
112
+ Joi.assert(params.orgId, Joi.string().required(), 'The organization id of the question');
113
+ Joi.assert(params.processId, Joi.string().required(), 'The process id of the question');
114
+ Joi.assert(params.path, Joi.string().required(), 'The path of the field of the question');
115
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
116
+
117
+ const apiCall = self._client.post(`/organizations/dashboard/chart/question/data`, params, self._setHeader(session));
118
+
119
+ return self._returnData(await apiCall);
120
+ } catch (ex) {
121
+ throw ex;
122
+ }
123
+ }
84
124
  }
85
125
 
86
126
  /**
@@ -865,18 +865,18 @@ class Documents {
865
865
  */
866
866
  async exportWmsExcelForAllPages(params, session) {
867
867
  const self = this;
868
-
868
+
869
869
  try {
870
870
  Joi.assert(params, Joi.object().required(), 'Params to export Wms Excel for all pages');
871
871
  Joi.assert(params.query, Joi.object().required(), 'The query for the export Wms Excel for all pages');
872
872
  Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
873
873
  Joi.assert(session, Joi.string().required(), 'Session token JWT');
874
-
874
+
875
875
  const {query, orgId} = params;
876
876
  const searchParams = new URLSearchParams(query);
877
877
  const queryString = searchParams.toString();
878
878
  const apiCall = self._client.get(`/organizations/${orgId}/documents/wms/export/excel?${queryString}`, self._setHeader(session));
879
-
879
+
880
880
  return self._returnData(await apiCall);
881
881
  } catch (ex) {
882
882
  throw ex;
@@ -926,13 +926,57 @@ class Documents {
926
926
  const {query, orgId, data} = params;
927
927
  const searchParams = new URLSearchParams(query);
928
928
  const queryString = searchParams.toString();
929
-
929
+
930
930
  const apiCall = self._client.post(`/organizations/${orgId}/documents/download/attachments?${queryString}`, data, self._setHeader(session));
931
931
  return self._returnData(await apiCall);
932
932
  } catch (ex) {
933
933
  throw ex;
934
934
  }
935
935
  }
936
+
937
+ /**
938
+ * @author Myndware <augusto.pissarra@myndware.com>
939
+ * @description Method to search documents direct on MongoDB (use carefully and only in cases you need to access direct data
940
+ * @param {object} params Params to search the documents
941
+ * @param {object} params.query Search documents query
942
+ * @param {object} params.orgId Organization id (_id database)
943
+ * @param {string} session Session, token JWT
944
+ * @returns {promise} returned data from the search
945
+ * @returns {number} count the count of items searched
946
+ * @returns {array<object>} items the items returned from search
947
+ * @returns {number} took the number of documents taken
948
+ * @returns {number} totalCount the total count of all documents
949
+ * @public
950
+ * @example
951
+ *
952
+ * const API = require('@docbrasil/api-systemmanager');
953
+ * const api = new API();
954
+ * const params = {
955
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
956
+ * orgId: '55e4a3bd6be6b45210833fae',
957
+ * };
958
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
959
+ * const retSearch = await api.user.document.searchDocumentsMongo(params, session);
960
+ */
961
+ async searchDocumentsMongo(params, session) {
962
+ const self = this;
963
+
964
+ try {
965
+ Joi.assert(params, Joi.object().required(), 'Params to search the documents');
966
+ Joi.assert(params.query, Joi.object().required(), 'The query for the search documents');
967
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
968
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
969
+
970
+ const {query, orgId} = params;
971
+ const searchParams = new URLSearchParams(query);
972
+ const queryString = searchParams.toString();
973
+ const apiCall = self._client.get(`/organizations/${orgId}/documents/search/direct?${queryString}`, self._setHeader(session));
974
+
975
+ return self._returnData(await apiCall);
976
+ } catch (ex) {
977
+ throw ex;
978
+ }
979
+ }
936
980
  }
937
981
 
938
982
  export default Documents;
package/dist/bundle.cjs CHANGED
@@ -1417,18 +1417,18 @@ class Documents {
1417
1417
  */
1418
1418
  async exportWmsExcelForAllPages(params, session) {
1419
1419
  const self = this;
1420
-
1420
+
1421
1421
  try {
1422
1422
  Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to export Wms Excel for all pages');
1423
1423
  Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the export Wms Excel for all pages');
1424
1424
  Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1425
1425
  Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1426
-
1426
+
1427
1427
  const {query, orgId} = params;
1428
1428
  const searchParams = new URLSearchParams(query);
1429
1429
  const queryString = searchParams.toString();
1430
1430
  const apiCall = self._client.get(`/organizations/${orgId}/documents/wms/export/excel?${queryString}`, self._setHeader(session));
1431
-
1431
+
1432
1432
  return self._returnData(await apiCall);
1433
1433
  } catch (ex) {
1434
1434
  throw ex;
@@ -1478,13 +1478,57 @@ class Documents {
1478
1478
  const {query, orgId, data} = params;
1479
1479
  const searchParams = new URLSearchParams(query);
1480
1480
  const queryString = searchParams.toString();
1481
-
1481
+
1482
1482
  const apiCall = self._client.post(`/organizations/${orgId}/documents/download/attachments?${queryString}`, data, self._setHeader(session));
1483
1483
  return self._returnData(await apiCall);
1484
1484
  } catch (ex) {
1485
1485
  throw ex;
1486
1486
  }
1487
1487
  }
1488
+
1489
+ /**
1490
+ * @author Myndware <augusto.pissarra@myndware.com>
1491
+ * @description Method to search documents direct on MongoDB (use carefully and only in cases you need to access direct data
1492
+ * @param {object} params Params to search the documents
1493
+ * @param {object} params.query Search documents query
1494
+ * @param {object} params.orgId Organization id (_id database)
1495
+ * @param {string} session Session, token JWT
1496
+ * @returns {promise} returned data from the search
1497
+ * @returns {number} count the count of items searched
1498
+ * @returns {array<object>} items the items returned from search
1499
+ * @returns {number} took the number of documents taken
1500
+ * @returns {number} totalCount the total count of all documents
1501
+ * @public
1502
+ * @example
1503
+ *
1504
+ * const API = require('@docbrasil/api-systemmanager');
1505
+ * const api = new API();
1506
+ * const params = {
1507
+ * query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1508
+ * orgId: '55e4a3bd6be6b45210833fae',
1509
+ * };
1510
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1511
+ * const retSearch = await api.user.document.searchDocumentsMongo(params, session);
1512
+ */
1513
+ async searchDocumentsMongo(params, session) {
1514
+ const self = this;
1515
+
1516
+ try {
1517
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to search the documents');
1518
+ Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the search documents');
1519
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1520
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1521
+
1522
+ const {query, orgId} = params;
1523
+ const searchParams = new URLSearchParams(query);
1524
+ const queryString = searchParams.toString();
1525
+ const apiCall = self._client.get(`/organizations/${orgId}/documents/search/direct?${queryString}`, self._setHeader(session));
1526
+
1527
+ return self._returnData(await apiCall);
1528
+ } catch (ex) {
1529
+ throw ex;
1530
+ }
1531
+ }
1488
1532
  }
1489
1533
 
1490
1534
  /**
@@ -11212,6 +11256,46 @@ class Chart {
11212
11256
  throw ex;
11213
11257
  }
11214
11258
  }
11259
+
11260
+ /**
11261
+ * @author Myndware <augusto.pissarra@myndware.com>
11262
+ * @description Get the question data from a chart data
11263
+ * @param {object} params Params to get helps from topic
11264
+ * @param {object} params.orgId The organization id of the question
11265
+ * @param {object} params.processId The process id of the question
11266
+ * @param {object} params.path The path of the question so we can retrieve it
11267
+ * @param {string} session Session, token JWT
11268
+ * @returns {promise} data the question data
11269
+ * @public
11270
+ * @example
11271
+ *
11272
+ * const API = require('@docbrasil/api-systemmanager');
11273
+ * const api = new API();
11274
+ * const params = {
11275
+ * orgId: '637e7523f555fabdfb1ed7b6',
11276
+ * processId: '123e7523f555fabdfb1ed7c6',
11277
+ * path: 'Checklist.Group Name.Field Name'
11278
+ * };
11279
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11280
+ * await api.user.dashboard.chart.getQuestion(params, session);
11281
+ */
11282
+ async getQuestion(params, session) {
11283
+ const self = this;
11284
+
11285
+ try {
11286
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to helps from a topic');
11287
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'The organization id of the question');
11288
+ Joi__default["default"].assert(params.processId, Joi__default["default"].string().required(), 'The process id of the question');
11289
+ Joi__default["default"].assert(params.path, Joi__default["default"].string().required(), 'The path of the field of the question');
11290
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
11291
+
11292
+ const apiCall = self._client.post(`/organizations/dashboard/chart/question/data`, params, self._setHeader(session));
11293
+
11294
+ return self._returnData(await apiCall);
11295
+ } catch (ex) {
11296
+ throw ex;
11297
+ }
11298
+ }
11215
11299
  }
11216
11300
 
11217
11301
  /**