@docbrasil/api-systemmanager 1.0.105 → 1.0.107

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/api/external.js CHANGED
@@ -124,6 +124,52 @@ class External {
124
124
  }
125
125
  }
126
126
 
127
+ /**
128
+ * @author CloudBrasil <abernardo.br@gmail.com>
129
+ * @description Handles the execution of an external form
130
+ * @param {string} authorization a legal authorization
131
+ * @param {object} params the parameters to handle the execution of an external form
132
+ * @param {array<object>} params.payload the payload of the external form. It should represent the form groups of the external form
133
+ * @param {string} params.payload.name the name of the group
134
+ * @param {array<object>} params.payload.fields the fields that belong to each group
135
+ * @param {*|{}} params.payload.fields.value besides all the data inside a field, it should have the value of the the field
136
+ * @returns {Promise<boolean>} true|false if success
137
+ * @public
138
+ * @async
139
+ * @example
140
+ *
141
+ * const API = require('@docbrasil/api-systemmanager');
142
+ * const api = new API();
143
+ * const authorization = '...';
144
+ * const params = {
145
+ * payload: [
146
+ * {
147
+ * name: 'My Group One',
148
+ * fields: [
149
+ * {}
150
+ * ]
151
+ * }
152
+ * ]
153
+ * };
154
+ * const success = await api.external.handle(params, authorization);
155
+ */
156
+ async handle(params, authorization) {
157
+ const self = this;
158
+
159
+ try {
160
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
161
+ Joi.assert(params.payload, Joi.array().required().error(new Error('form payload is required')));
162
+ Joi.assert(authorization, Joi.string().required().error(new Error('authorization is required')));
163
+
164
+ const apiCall = self._client
165
+ .put('/external/forms', params, self._setHeader(authorization));
166
+
167
+ return self._returnData(await apiCall);
168
+ } catch (ex) {
169
+ throw ex;
170
+ }
171
+ }
172
+
127
173
  }
128
174
 
129
175
  export default External;
@@ -186,6 +186,50 @@ class Process {
186
186
  throw ex;
187
187
  }
188
188
  }
189
+
190
+ /**
191
+ * @author CloudBrasil <abernardo.br@gmail.com>
192
+ * @description Method to search processes
193
+ * @param {object} params Params to search processes
194
+ * @param {object} params.query Search process query
195
+ * @param {object} params.orgId Organization id (_id database)
196
+ * @param {string} session Session, token JWT
197
+ * @returns {promise} returned data from the search
198
+ * @returns {number} count the count of items searched
199
+ * @returns {array<object>} items the items returned from search
200
+ * @returns {number} page the page of the search (on pagination), zero indexed
201
+ * @returns {number} perPage how many items per page
202
+ * @public
203
+ * @example
204
+ *
205
+ * const API = require('@docbrasil/api-systemmanager');
206
+ * const api = new API();
207
+ * const params = {
208
+ * query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
209
+ * orgId: '55e4a3bd6be6b45210833fae',
210
+ * };
211
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
212
+ * const retSearch = await api.user.process.find(params, session);
213
+ */
214
+ async find(params, session) {
215
+ const self = this;
216
+
217
+ try {
218
+ Joi.assert(params, Joi.object().required(), 'Params to search processes');
219
+ Joi.assert(params.query, Joi.object().required(), 'The query for the search');
220
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
221
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
222
+
223
+ const {query, orgId} = params;
224
+ const queryString = JSON.stringify(query);
225
+ const apiCall = self._client
226
+ .post(`/organizations/${orgId}/process/advsearch?query=${queryString}`, {}, self._setHeader(session));
227
+
228
+ return self._returnData(await apiCall);
229
+ } catch (ex) {
230
+ throw ex;
231
+ }
232
+ }
189
233
  }
190
234
 
191
235
  export default Process;
package/api/user/task.js CHANGED
@@ -124,6 +124,7 @@ class Task {
124
124
  async findByIdAndUpdate(params, session) {
125
125
  const self = this;
126
126
 
127
+
127
128
  try {
128
129
  Joi.assert(params, Joi.object().required());
129
130
  Joi.assert(params.userId, Joi.string().required(), 'User id (_id database)');
@@ -51,7 +51,7 @@ class TaskAvailable {
51
51
  * @author CloudBrasil <abernardo.br@gmail.com>
52
52
  * @description Method to find available tasks for a user
53
53
  * @param {object} params Params to get task
54
- * @param {object} params.query Search process query
54
+ * @param {object} params.query Search available tasks query
55
55
  * @param {object} params.orgId Organization id (_id database)
56
56
  * @param {string} session Session, token JWT
57
57
  * @returns {promise} returned data from the search
package/dist/bundle.cjs CHANGED
@@ -1687,6 +1687,50 @@ class Process {
1687
1687
  throw ex;
1688
1688
  }
1689
1689
  }
1690
+
1691
+ /**
1692
+ * @author CloudBrasil <abernardo.br@gmail.com>
1693
+ * @description Method to search processes
1694
+ * @param {object} params Params to search processes
1695
+ * @param {object} params.query Search process query
1696
+ * @param {object} params.orgId Organization id (_id database)
1697
+ * @param {string} session Session, token JWT
1698
+ * @returns {promise} returned data from the search
1699
+ * @returns {number} count the count of items searched
1700
+ * @returns {array<object>} items the items returned from search
1701
+ * @returns {number} page the page of the search (on pagination), zero indexed
1702
+ * @returns {number} perPage how many items per page
1703
+ * @public
1704
+ * @example
1705
+ *
1706
+ * const API = require('@docbrasil/api-systemmanager');
1707
+ * const api = new API();
1708
+ * const params = {
1709
+ * query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
1710
+ * orgId: '55e4a3bd6be6b45210833fae',
1711
+ * };
1712
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1713
+ * const retSearch = await api.user.process.find(params, session);
1714
+ */
1715
+ async find(params, session) {
1716
+ const self = this;
1717
+
1718
+ try {
1719
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to search processes');
1720
+ Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the search');
1721
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1722
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1723
+
1724
+ const {query, orgId} = params;
1725
+ const queryString = JSON.stringify(query);
1726
+ const apiCall = self._client
1727
+ .post(`/organizations/${orgId}/process/advsearch?query=${queryString}`, {}, self._setHeader(session));
1728
+
1729
+ return self._returnData(await apiCall);
1730
+ } catch (ex) {
1731
+ throw ex;
1732
+ }
1733
+ }
1690
1734
  }
1691
1735
 
1692
1736
  /**
@@ -1738,7 +1782,7 @@ class TaskAvailable {
1738
1782
  * @author CloudBrasil <abernardo.br@gmail.com>
1739
1783
  * @description Method to find available tasks for a user
1740
1784
  * @param {object} params Params to get task
1741
- * @param {object} params.query Search process query
1785
+ * @param {object} params.query Search available tasks query
1742
1786
  * @param {object} params.orgId Organization id (_id database)
1743
1787
  * @param {string} session Session, token JWT
1744
1788
  * @returns {promise} returned data from the search
@@ -1940,6 +1984,7 @@ class Task {
1940
1984
  async findByIdAndUpdate(params, session) {
1941
1985
  const self = this;
1942
1986
 
1987
+
1943
1988
  try {
1944
1989
  Joi__default["default"].assert(params, Joi__default["default"].object().required());
1945
1990
  Joi__default["default"].assert(params.userId, Joi__default["default"].string().required(), 'User id (_id database)');
@@ -11700,6 +11745,52 @@ class External {
11700
11745
  }
11701
11746
  }
11702
11747
 
11748
+ /**
11749
+ * @author CloudBrasil <abernardo.br@gmail.com>
11750
+ * @description Handles the execution of an external form
11751
+ * @param {string} authorization a legal authorization
11752
+ * @param {object} params the parameters to handle the execution of an external form
11753
+ * @param {array<object>} params.payload the payload of the external form. It should represent the form groups of the external form
11754
+ * @param {string} params.payload.name the name of the group
11755
+ * @param {array<object>} params.payload.fields the fields that belong to each group
11756
+ * @param {*|{}} params.payload.fields.value besides all the data inside a field, it should have the value of the the field
11757
+ * @returns {Promise<boolean>} true|false if success
11758
+ * @public
11759
+ * @async
11760
+ * @example
11761
+ *
11762
+ * const API = require('@docbrasil/api-systemmanager');
11763
+ * const api = new API();
11764
+ * const authorization = '...';
11765
+ * const params = {
11766
+ * payload: [
11767
+ * {
11768
+ * name: 'My Group One',
11769
+ * fields: [
11770
+ * {}
11771
+ * ]
11772
+ * }
11773
+ * ]
11774
+ * };
11775
+ * const success = await api.external.handle(params, authorization);
11776
+ */
11777
+ async handle(params, authorization) {
11778
+ const self = this;
11779
+
11780
+ try {
11781
+ Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
11782
+ Joi__default["default"].assert(params.payload, Joi__default["default"].array().required().error(new Error('form payload is required')));
11783
+ Joi__default["default"].assert(authorization, Joi__default["default"].string().required().error(new Error('authorization is required')));
11784
+
11785
+ const apiCall = self._client
11786
+ .put('/external/forms', params, self._setHeader(authorization));
11787
+
11788
+ return self._returnData(await apiCall);
11789
+ } catch (ex) {
11790
+ throw ex;
11791
+ }
11792
+ }
11793
+
11703
11794
  }
11704
11795
 
11705
11796
  /**