@docbrasil/api-systemmanager 1.0.88 → 1.0.90
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/admin/doctypes.js +76 -76
- package/api/admin/document.js +332 -332
- package/api/admin/form.js +151 -151
- package/api/admin/index.js +46 -46
- package/api/admin/list.js +133 -133
- package/api/admin/message.js +194 -194
- package/api/admin/notification.js +233 -233
- package/api/admin/organization.js +124 -124
- package/api/admin/plugin.js +116 -116
- package/api/admin/policy.js +78 -78
- package/api/admin/processes.js +370 -370
- package/api/admin/task.js +125 -125
- package/api/admin/user.js +185 -185
- package/api/dispatch.js +101 -101
- package/api/general/geoLocation.js +88 -88
- package/api/general/index.js +22 -22
- package/api/login.js +267 -267
- package/api/session.js +85 -85
- package/api/user/datasource.js +144 -144
- package/api/user/document.js +730 -731
- package/api/user/index.js +39 -39
- package/api/user/notification.js +101 -101
- package/api/user/organization.js +230 -230
- package/api/user/process.js +191 -191
- package/api/user/register.js +205 -205
- package/api/user/task.js +201 -201
- package/api/user/task_available.js +135 -135
- package/api/user/user.js +287 -287
- package/api/utils/cypher.js +37 -37
- package/api/utils/promises.js +118 -118
- package/bundleRollup.js +158 -158
- package/dist/bundle.cjs +4875 -4876
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +674 -336
- package/doc.md +653 -653
- package/helper/boom.js +487 -487
- package/helper/cryptojs.js +6067 -6067
- package/index.js +85 -85
- package/package-lock.json +4635 -4635
- package/package.json +68 -68
- package/readme.md +25 -25
- package/tests/admin/document.spec.js +45 -45
- package/tests/admin/form.spec.js +74 -74
- package/tests/admin/list.spec.js +86 -86
- package/tests/admin/message.js +92 -92
- package/tests/admin/notification.spec.js +174 -174
- package/tests/admin/pluginspec..js +71 -71
- package/tests/admin/policy.spec.js +71 -71
- package/tests/admin/processes.spec.js +119 -119
- package/tests/admin/users.spec.js +127 -127
- package/tests/documents.spec.js +164 -164
- package/tests/login.spec.js +91 -91
- package/tests/session.spec..js +58 -58
- package/tests/user/documents.js +164 -164
- package/tests/user/organization.js +122 -122
- package/tests/user/process.js +71 -71
- 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 = encodeURIComponent(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 get task');
|
|
120
|
-
Joi.assert(params.taskId, Joi.object().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 = encodeURIComponent(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 get task');
|
|
120
|
+
Joi.assert(params.taskId, Joi.object().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;
|