@docbrasil/api-systemmanager 1.1.27 → 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.
@@ -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
  /**