@docbrasil/api-systemmanager 1.0.89 → 1.0.91

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 (57) 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/general/geoLocation.js +88 -88
  16. package/api/general/index.js +22 -22
  17. package/api/login.js +267 -267
  18. package/api/session.js +85 -85
  19. package/api/user/datasource.js +144 -144
  20. package/api/user/document.js +730 -730
  21. package/api/user/index.js +39 -39
  22. package/api/user/notification.js +101 -101
  23. package/api/user/organization.js +230 -230
  24. package/api/user/process.js +191 -191
  25. package/api/user/register.js +205 -205
  26. package/api/user/task.js +201 -201
  27. package/api/user/task_available.js +135 -135
  28. package/api/user/user.js +287 -287
  29. package/api/utils/cypher.js +37 -37
  30. package/api/utils/promises.js +118 -118
  31. package/bundleRollup.js +158 -158
  32. package/dist/bundle.cjs +4875 -4875
  33. package/dist/bundle.mjs +1 -1
  34. package/doc/api.md +674 -336
  35. package/doc.md +653 -653
  36. package/helper/boom.js +487 -487
  37. package/helper/cryptojs.js +6067 -6067
  38. package/index.js +85 -85
  39. package/package-lock.json +4635 -4635
  40. package/package.json +68 -68
  41. package/readme.md +25 -25
  42. package/tests/admin/document.spec.js +45 -45
  43. package/tests/admin/form.spec.js +74 -74
  44. package/tests/admin/list.spec.js +86 -86
  45. package/tests/admin/message.js +92 -92
  46. package/tests/admin/notification.spec.js +174 -174
  47. package/tests/admin/pluginspec..js +71 -71
  48. package/tests/admin/policy.spec.js +71 -71
  49. package/tests/admin/processes.spec.js +119 -119
  50. package/tests/admin/users.spec.js +127 -127
  51. package/tests/documents.spec.js +164 -164
  52. package/tests/login.spec.js +91 -91
  53. package/tests/session.spec..js +58 -58
  54. package/tests/user/documents.js +164 -164
  55. package/tests/user/organization.js +122 -122
  56. package/tests/user/process.js +71 -71
  57. package/tests/user/user.js +88 -88
@@ -1,191 +1,191 @@
1
- import _ from 'lodash';
2
- import Boom from '@hapi/boom';
3
- import Joi from 'joi';
4
-
5
- /**
6
- * Class for process, permission user
7
- * @class
8
- */
9
- class Process {
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 CloudBrasil <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 Set header for a bigger payload
53
- * @param {string} session Session, token JWT
54
- * @return {object} header with new session
55
- * @private
56
- */
57
- _setMaxContentHeader(session) {
58
- return {
59
- headers: {
60
- authorization: session
61
- },
62
- maxContentLength: Infinity,
63
- maxBodyLength: Infinity
64
- };
65
- }
66
-
67
- /**
68
- * @author CloudBrasil <abernardo.br@gmail.com>
69
- * @description Start process
70
- * @param {object} params Params to start process
71
- * @param {string} params.processId Process id (_id database);
72
- * @param {string} params.orgId Organization id (_id database);
73
- * @param {object} [params.payload={}] Start process with data
74
- * @param {string} session Session, token JWT
75
- * @return {Promise}
76
- * @public
77
- * @async
78
- * @example
79
- *
80
- * const API = require('@docbrasil/api-systemmanager');
81
- * const api = new API();
82
- * const params = {
83
- * processId: '5dadd01dc4af3941d42f8c5c',
84
- * orgId: '5edd11c46b6ce9729c2c297c',
85
- * payload: {}
86
- * }
87
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
88
- * await api.user.process.start(params, session);
89
- */
90
- async start(params, session) {
91
- const self = this;
92
-
93
- try {
94
- Joi.assert(params, Joi.object().required());
95
- Joi.assert(params.processId, Joi.string().required());
96
- Joi.assert(params.orgId, Joi.string().required());
97
- Joi.assert(params.payload, Joi.object());
98
- Joi.assert(session, Joi.string().required());
99
-
100
- const {processId, orgId, payload = {}} = params;
101
- const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self._setMaxContentHeader(session));
102
- return self._returnData(await apiCall);
103
- } catch (ex) {
104
- throw ex;
105
- }
106
- }
107
-
108
- /**
109
- * @author CloudBrasil <abernardo.br@gmail.com>
110
- * @description Get process properties of process
111
- * @param {object} params Params to get process properties
112
- * @param {string} params.processId Process id (_id database);
113
- * @param {string} params.orgId Organization id (_id database);
114
- * @param {string} session Session, token JWT
115
- * @return {Promise}
116
- * @public
117
- * @async
118
- * @example
119
- *
120
- * const API = require('@docbrasil/api-systemmanager');
121
- * const api = new API();
122
- * const params = {
123
- * processId: '5dadd01dc4af3941d42f8c5c',
124
- * orgId: '5edd11c46b6ce9729c2c297c',
125
- * }
126
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
127
- * await api.user.process.getProcessProperties(params, session);
128
- */
129
- async getProcessProperties(params, session) {
130
- const self = this;
131
-
132
- try {
133
- Joi.assert(params, Joi.object().required());
134
- Joi.assert(params.processId, Joi.string().required());
135
- Joi.assert(params.orgId, Joi.string().required());
136
- Joi.assert(session, Joi.string().required());
137
-
138
- const {processId, orgId} = params;
139
- const apiCall = self._client.get(`/organizations/${orgId}/process/${processId}/properties`, self._setHeader(session));
140
- return self._returnData(await apiCall);
141
- } catch (ex) {
142
- throw ex;
143
- }
144
- }
145
-
146
- /**
147
- * @author CloudBrasil <abernardo.br@gmail.com>
148
- * @description Get the search info of a organization process
149
- * @param {object} params Params to get search info
150
- * @param {string} params.orgProcessId The id of an organization process (_id database);
151
- * @param {string} params.orgId Organization id (_id database);
152
- * @param {string} session Session, token JWT
153
- * @return {Promise} the search info result
154
- * @return {string} name the name of the organization process
155
- * @return {object} processIndexFields the list of fields to index
156
- * @return {object} processParticipantsGroup the permissions in this organization process
157
- * @return {object} stepsProperties the organization process steps properties
158
- * @return {string} _id the same organization id
159
- * @
160
- * @public
161
- * @async
162
- * @example
163
- *
164
- * const API = require('@docbrasil/api-systemmanager');
165
- * const api = new API();
166
- * const params = {
167
- * orgProcessId: '5dadd01dc4af3941d42f8c67',
168
- * orgId: '5edd11c46b6ce9729c2c297c',
169
- * }
170
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
171
- * const retSearchInfo = await api.user.process.getOrgProcessSearchInfo(params, session);
172
- */
173
- async getOrgProcessSearchInfo(params, session) {
174
- const self = this;
175
-
176
- try {
177
- Joi.assert(params, Joi.object().required());
178
- Joi.assert(params.orgProcessId, Joi.string().required());
179
- Joi.assert(params.orgId, Joi.string().required());
180
- Joi.assert(session, Joi.string().required());
181
-
182
- const {orgProcessId, orgId} = params;
183
- const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/search/info`, self._setHeader(session));
184
- return self._returnData(await apiCall);
185
- } catch (ex) {
186
- throw ex;
187
- }
188
- }
189
- }
190
-
191
- export default Process;
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+
5
+ /**
6
+ * Class for process, permission user
7
+ * @class
8
+ */
9
+ class Process {
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 CloudBrasil <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 Set header for a bigger payload
53
+ * @param {string} session Session, token JWT
54
+ * @return {object} header with new session
55
+ * @private
56
+ */
57
+ _setMaxContentHeader(session) {
58
+ return {
59
+ headers: {
60
+ authorization: session
61
+ },
62
+ maxContentLength: Infinity,
63
+ maxBodyLength: Infinity
64
+ };
65
+ }
66
+
67
+ /**
68
+ * @author CloudBrasil <abernardo.br@gmail.com>
69
+ * @description Start process
70
+ * @param {object} params Params to start process
71
+ * @param {string} params.processId Process id (_id database);
72
+ * @param {string} params.orgId Organization id (_id database);
73
+ * @param {object} [params.payload={}] Start process with data
74
+ * @param {string} session Session, token JWT
75
+ * @return {Promise}
76
+ * @public
77
+ * @async
78
+ * @example
79
+ *
80
+ * const API = require('@docbrasil/api-systemmanager');
81
+ * const api = new API();
82
+ * const params = {
83
+ * processId: '5dadd01dc4af3941d42f8c5c',
84
+ * orgId: '5edd11c46b6ce9729c2c297c',
85
+ * payload: {}
86
+ * }
87
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
88
+ * await api.user.process.start(params, session);
89
+ */
90
+ async start(params, session) {
91
+ const self = this;
92
+
93
+ try {
94
+ Joi.assert(params, Joi.object().required());
95
+ Joi.assert(params.processId, Joi.string().required());
96
+ Joi.assert(params.orgId, Joi.string().required());
97
+ Joi.assert(params.payload, Joi.object());
98
+ Joi.assert(session, Joi.string().required());
99
+
100
+ const {processId, orgId, payload = {}} = params;
101
+ const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self._setMaxContentHeader(session));
102
+ return self._returnData(await apiCall);
103
+ } catch (ex) {
104
+ throw ex;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * @author CloudBrasil <abernardo.br@gmail.com>
110
+ * @description Get process properties of process
111
+ * @param {object} params Params to get process properties
112
+ * @param {string} params.processId Process id (_id database);
113
+ * @param {string} params.orgId Organization id (_id database);
114
+ * @param {string} session Session, token JWT
115
+ * @return {Promise}
116
+ * @public
117
+ * @async
118
+ * @example
119
+ *
120
+ * const API = require('@docbrasil/api-systemmanager');
121
+ * const api = new API();
122
+ * const params = {
123
+ * processId: '5dadd01dc4af3941d42f8c5c',
124
+ * orgId: '5edd11c46b6ce9729c2c297c',
125
+ * }
126
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
127
+ * await api.user.process.getProcessProperties(params, session);
128
+ */
129
+ async getProcessProperties(params, session) {
130
+ const self = this;
131
+
132
+ try {
133
+ Joi.assert(params, Joi.object().required());
134
+ Joi.assert(params.processId, Joi.string().required());
135
+ Joi.assert(params.orgId, Joi.string().required());
136
+ Joi.assert(session, Joi.string().required());
137
+
138
+ const {processId, orgId} = params;
139
+ const apiCall = self._client.get(`/organizations/${orgId}/process/${processId}/properties`, self._setHeader(session));
140
+ return self._returnData(await apiCall);
141
+ } catch (ex) {
142
+ throw ex;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * @author CloudBrasil <abernardo.br@gmail.com>
148
+ * @description Get the search info of a organization process
149
+ * @param {object} params Params to get search info
150
+ * @param {string} params.orgProcessId The id of an organization process (_id database);
151
+ * @param {string} params.orgId Organization id (_id database);
152
+ * @param {string} session Session, token JWT
153
+ * @return {Promise} the search info result
154
+ * @return {string} name the name of the organization process
155
+ * @return {object} processIndexFields the list of fields to index
156
+ * @return {object} processParticipantsGroup the permissions in this organization process
157
+ * @return {object} stepsProperties the organization process steps properties
158
+ * @return {string} _id the same organization id
159
+ * @
160
+ * @public
161
+ * @async
162
+ * @example
163
+ *
164
+ * const API = require('@docbrasil/api-systemmanager');
165
+ * const api = new API();
166
+ * const params = {
167
+ * orgProcessId: '5dadd01dc4af3941d42f8c67',
168
+ * orgId: '5edd11c46b6ce9729c2c297c',
169
+ * }
170
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
171
+ * const retSearchInfo = await api.user.process.getOrgProcessSearchInfo(params, session);
172
+ */
173
+ async getOrgProcessSearchInfo(params, session) {
174
+ const self = this;
175
+
176
+ try {
177
+ Joi.assert(params, Joi.object().required());
178
+ Joi.assert(params.orgProcessId, Joi.string().required());
179
+ Joi.assert(params.orgId, Joi.string().required());
180
+ Joi.assert(session, Joi.string().required());
181
+
182
+ const {orgProcessId, orgId} = params;
183
+ const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/search/info`, self._setHeader(session));
184
+ return self._returnData(await apiCall);
185
+ } catch (ex) {
186
+ throw ex;
187
+ }
188
+ }
189
+ }
190
+
191
+ export default Process;