@docbrasil/api-systemmanager 1.0.97 → 1.0.98

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 (59) hide show
  1. package/api/admin/doctypes.js +76 -76
  2. package/api/admin/document.js +332 -332
  3. package/api/admin/form.js +151 -151
  4. package/api/admin/index.js +46 -46
  5. package/api/admin/list.js +133 -133
  6. package/api/admin/message.js +194 -194
  7. package/api/admin/notification.js +233 -233
  8. package/api/admin/organization.js +124 -124
  9. package/api/admin/plugin.js +116 -116
  10. package/api/admin/policy.js +78 -78
  11. package/api/admin/processes.js +370 -370
  12. package/api/admin/task.js +125 -125
  13. package/api/admin/user.js +185 -185
  14. package/api/dispatch.js +101 -101
  15. package/api/external.js +86 -0
  16. package/api/general/geoLocation.js +88 -88
  17. package/api/general/index.js +23 -23
  18. package/api/login.js +267 -267
  19. package/api/session.js +85 -85
  20. package/api/user/datasource.js +144 -144
  21. package/api/user/document.js +730 -730
  22. package/api/user/index.js +39 -39
  23. package/api/user/notification.js +101 -101
  24. package/api/user/organization.js +230 -230
  25. package/api/user/process.js +191 -191
  26. package/api/user/register.js +205 -205
  27. package/api/user/task.js +201 -202
  28. package/api/user/task_available.js +135 -135
  29. package/api/user/user.js +287 -287
  30. package/api/utils/cypher.js +37 -37
  31. package/api/utils/promises.js +118 -118
  32. package/bundleRollup.js +158 -158
  33. package/dist/bundle.cjs +4878 -4876
  34. package/dist/bundle.mjs +1 -1
  35. package/doc/api.md +2453 -2453
  36. package/doc.md +653 -653
  37. package/helper/boom.js +487 -487
  38. package/helper/cryptojs.js +6067 -6067
  39. package/index.js +87 -85
  40. package/package-lock.json +4635 -4635
  41. package/package.json +68 -68
  42. package/readme.md +25 -25
  43. package/tests/admin/document.spec.js +45 -45
  44. package/tests/admin/form.spec.js +74 -74
  45. package/tests/admin/list.spec.js +86 -86
  46. package/tests/admin/message.js +92 -92
  47. package/tests/admin/notification.spec.js +174 -174
  48. package/tests/admin/pluginspec..js +71 -71
  49. package/tests/admin/policy.spec.js +71 -71
  50. package/tests/admin/processes.spec.js +119 -119
  51. package/tests/admin/users.spec.js +127 -127
  52. package/tests/documents.spec.js +164 -164
  53. package/tests/login.spec.js +91 -91
  54. package/tests/session.spec..js +58 -58
  55. package/tests/user/documents.js +164 -164
  56. package/tests/user/organization.js +122 -122
  57. package/tests/user/process.js +71 -71
  58. package/tests/user/task_available.js +75 -75
  59. package/tests/user/user.js +88 -88
@@ -1,135 +1,135 @@
1
- import _ from 'lodash';
2
- import Boom from '@hapi/boom';
3
- import Joi from 'joi';
4
-
5
- /**
6
- * Class for available tasks, permission user
7
- * @class
8
- */
9
- class TaskAvailable {
10
-
11
- constructor(options) {
12
- Joi.assert(options, Joi.object().required());
13
- Joi.assert(options.parent, Joi.object().required());
14
-
15
- const self = this;
16
- self.parent = options.parent;
17
- self._client = self.parent.dispatch.getClient();
18
- }
19
-
20
- /**
21
- * @author Augusto Pissarra <abernardo.br@gmail.com>
22
- * @description Get the return data and check for errors
23
- * @param {object} retData Response HTTP
24
- * @return {*}
25
- * @private
26
- */
27
- _returnData(retData, def = {}) {
28
- if (retData.status !== 200) {
29
- return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
30
- } else {
31
- return _.get(retData, 'data', def);
32
- }
33
- }
34
-
35
- /**
36
- * @author CloudBrasil <abernardo.br@gmail.com>
37
- * @description Set header with new session
38
- * @param {string} session Session, token JWT
39
- * @return {object} header with new session
40
- * @private
41
- */
42
- _setHeader(session) {
43
- return {
44
- headers: {
45
- authorization: session,
46
- }
47
- };
48
- }
49
-
50
- /**
51
- * @author CloudBrasil <abernardo.br@gmail.com>
52
- * @description Method to find available tasks for a user
53
- * @param {object} params Params to get task
54
- * @param {object} params.query Search process query
55
- * @param {object} params.orgId Organization id (_id database)
56
- * @param {string} session Session, token JWT
57
- * @returns {promise} returned data from the search
58
- * @returns {number} count the count of items searched
59
- * @returns {array<object>} items the items returned from search
60
- * @returns {number} page the page of the search (on pagination), zero indexed
61
- * @returns {number} perPage how many items per page
62
- * @public
63
- * @example
64
- *
65
- * const API = require('@docbrasil/api-systemmanager');
66
- * const api = new API();
67
- * const params = {
68
- * query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
69
- * orgId: '55e4a3bd6be6b45210833fae',
70
- * };
71
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
72
- * const retSearch = await api.user.task.available.find(params, session);
73
- */
74
- async find(params, session) {
75
- const self = this;
76
-
77
- try {
78
- Joi.assert(params, Joi.object().required(), 'Params to get task');
79
- Joi.assert(params.query, Joi.object().required(), 'The query for the search');
80
- Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
81
- Joi.assert(session, Joi.string().required(), 'Session token JWT');
82
-
83
- const {query, orgId} = params;
84
- const queryString = JSON.stringify(query);
85
- const apiCall = self._client
86
- .post(`/organizations/${orgId}/users/tasks/groups/advsearch?query=${queryString}`, {}, self._setHeader(session));
87
-
88
- return self._returnData(await apiCall);
89
- } catch (ex) {
90
- throw ex;
91
- }
92
- }
93
-
94
- /**
95
- * @author CloudBrasil <abernardo.br@gmail.com>
96
- * @description Method for a user to claim an available task
97
- * @param {object} params Params to get task
98
- * @param {object} params.taskId the task id to claim
99
- * @param {object} params.orgname Organization slug (short name of the orgnization)
100
- * @param {string} session Session, token JWT
101
- * @returns {promise} returned data from the method call
102
- * @returns {boolean} success true|false if the method was successful
103
- * @public
104
- * @example
105
- *
106
- * const API = require('@docbrasil/api-systemmanager');
107
- * const api = new API();
108
- * const params = {
109
- * taskId: '55e4a3bd6be6b45210833f67',
110
- * orgname: 'acme',
111
- * };
112
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
113
- * const success = await api.user.task.available.claim(params, session);
114
- */
115
- async claim(params, session) {
116
- const self = this;
117
-
118
- try {
119
- Joi.assert(params, Joi.object().required(), 'Params to claim the task');
120
- Joi.assert(params.taskId, Joi.string().required(), 'The task id to claim');
121
- Joi.assert(params.orgname, Joi.string().required(), 'The slug of the organization');
122
- Joi.assert(session, Joi.string().required(), 'Session token JWT');
123
-
124
- const {taskId, orgname} = params;
125
- const apiCall = self._client
126
- .put(`/organizations/${orgname}/users/tasks/${taskId}/claim`, {}, self._setHeader(session));
127
-
128
- return self._returnData(await apiCall);
129
- } catch (ex) {
130
- throw ex;
131
- }
132
- }
133
- }
134
-
135
- export default TaskAvailable;
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+
5
+ /**
6
+ * Class for available tasks, permission user
7
+ * @class
8
+ */
9
+ class TaskAvailable {
10
+
11
+ constructor(options) {
12
+ Joi.assert(options, Joi.object().required());
13
+ Joi.assert(options.parent, Joi.object().required());
14
+
15
+ const self = this;
16
+ self.parent = options.parent;
17
+ self._client = self.parent.dispatch.getClient();
18
+ }
19
+
20
+ /**
21
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
22
+ * @description Get the return data and check for errors
23
+ * @param {object} retData Response HTTP
24
+ * @return {*}
25
+ * @private
26
+ */
27
+ _returnData(retData, def = {}) {
28
+ if (retData.status !== 200) {
29
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
30
+ } else {
31
+ return _.get(retData, 'data', def);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @author CloudBrasil <abernardo.br@gmail.com>
37
+ * @description Set header with new session
38
+ * @param {string} session Session, token JWT
39
+ * @return {object} header with new session
40
+ * @private
41
+ */
42
+ _setHeader(session) {
43
+ return {
44
+ headers: {
45
+ authorization: session,
46
+ }
47
+ };
48
+ }
49
+
50
+ /**
51
+ * @author CloudBrasil <abernardo.br@gmail.com>
52
+ * @description Method to find available tasks for a user
53
+ * @param {object} params Params to get task
54
+ * @param {object} params.query Search process query
55
+ * @param {object} params.orgId Organization id (_id database)
56
+ * @param {string} session Session, token JWT
57
+ * @returns {promise} returned data from the search
58
+ * @returns {number} count the count of items searched
59
+ * @returns {array<object>} items the items returned from search
60
+ * @returns {number} page the page of the search (on pagination), zero indexed
61
+ * @returns {number} perPage how many items per page
62
+ * @public
63
+ * @example
64
+ *
65
+ * const API = require('@docbrasil/api-systemmanager');
66
+ * const api = new API();
67
+ * const params = {
68
+ * query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
69
+ * orgId: '55e4a3bd6be6b45210833fae',
70
+ * };
71
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
72
+ * const retSearch = await api.user.task.available.find(params, session);
73
+ */
74
+ async find(params, session) {
75
+ const self = this;
76
+
77
+ try {
78
+ Joi.assert(params, Joi.object().required(), 'Params to get task');
79
+ Joi.assert(params.query, Joi.object().required(), 'The query for the search');
80
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
81
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
82
+
83
+ const {query, orgId} = params;
84
+ const queryString = JSON.stringify(query);
85
+ const apiCall = self._client
86
+ .post(`/organizations/${orgId}/users/tasks/groups/advsearch?query=${queryString}`, {}, self._setHeader(session));
87
+
88
+ return self._returnData(await apiCall);
89
+ } catch (ex) {
90
+ throw ex;
91
+ }
92
+ }
93
+
94
+ /**
95
+ * @author CloudBrasil <abernardo.br@gmail.com>
96
+ * @description Method for a user to claim an available task
97
+ * @param {object} params Params to get task
98
+ * @param {object} params.taskId the task id to claim
99
+ * @param {object} params.orgname Organization slug (short name of the orgnization)
100
+ * @param {string} session Session, token JWT
101
+ * @returns {promise} returned data from the method call
102
+ * @returns {boolean} success true|false if the method was successful
103
+ * @public
104
+ * @example
105
+ *
106
+ * const API = require('@docbrasil/api-systemmanager');
107
+ * const api = new API();
108
+ * const params = {
109
+ * taskId: '55e4a3bd6be6b45210833f67',
110
+ * orgname: 'acme',
111
+ * };
112
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
113
+ * const success = await api.user.task.available.claim(params, session);
114
+ */
115
+ async claim(params, session) {
116
+ const self = this;
117
+
118
+ try {
119
+ Joi.assert(params, Joi.object().required(), 'Params to claim the task');
120
+ Joi.assert(params.taskId, Joi.string().required(), 'The task id to claim');
121
+ Joi.assert(params.orgname, Joi.string().required(), 'The slug of the organization');
122
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
123
+
124
+ const {taskId, orgname} = params;
125
+ const apiCall = self._client
126
+ .put(`/organizations/${orgname}/users/tasks/${taskId}/claim`, {}, self._setHeader(session));
127
+
128
+ return self._returnData(await apiCall);
129
+ } catch (ex) {
130
+ throw ex;
131
+ }
132
+ }
133
+ }
134
+
135
+ export default TaskAvailable;