@docbrasil/api-systemmanager 1.0.93 → 1.0.94
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 +23 -23
- 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 -730
- 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 -4875
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +336 -674
- 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/task_available.js +75 -75
- package/tests/user/user.js +88 -88
package/api/admin/doctypes.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import Boom from '@hapi/boom';
|
|
3
|
-
import Joi from 'joi';
|
|
4
|
-
|
|
5
|
-
class AdminDocTypes {
|
|
6
|
-
constructor(options) {
|
|
7
|
-
Joi.assert(options, Joi.object().required());
|
|
8
|
-
Joi.assert(options.parent, Joi.object().required());
|
|
9
|
-
|
|
10
|
-
const self = this;
|
|
11
|
-
self.parent = options.parent;
|
|
12
|
-
self._client = self.parent.dispatch.getClient();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
17
|
-
* @description Get the return data and check for errors
|
|
18
|
-
* @param {object} retData Response HTTP
|
|
19
|
-
* @return {*}
|
|
20
|
-
* @private
|
|
21
|
-
*/
|
|
22
|
-
_returnData(retData, def = {}) {
|
|
23
|
-
if (retData.status !== 200) {
|
|
24
|
-
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
25
|
-
} else {
|
|
26
|
-
return _.get(retData, 'data', def);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
32
|
-
* @description Set header with new session
|
|
33
|
-
* @param {string} session Session, token JWT
|
|
34
|
-
* @return {object} header with new session
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
_setHeader(session) {
|
|
38
|
-
return {
|
|
39
|
-
headers: {
|
|
40
|
-
authorization: session,
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
47
|
-
* @description Request profile by userId
|
|
48
|
-
* @param {object} params The params
|
|
49
|
-
* @param {string} params.id The organization document type id (_id database)
|
|
50
|
-
* @param {string} params.orgId The organization id (_id database)
|
|
51
|
-
* @param {string} session The JWT token
|
|
52
|
-
* @return {Promise<object>} The document
|
|
53
|
-
* @public
|
|
54
|
-
* @async
|
|
55
|
-
* @example
|
|
56
|
-
*
|
|
57
|
-
* const API = require('@docbrasil/api-systemmanager');
|
|
58
|
-
* const api = new API();
|
|
59
|
-
* const id = '55e4a3bd6be6b45210833fae';
|
|
60
|
-
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
61
|
-
* const retDocType = await api.admin.doctypes.findById(id, session);
|
|
62
|
-
*/
|
|
63
|
-
async findById(params, session) {
|
|
64
|
-
const self = this;
|
|
65
|
-
Joi.assert(params, Joi.object().required());
|
|
66
|
-
Joi.assert(params.id, Joi.string().required());
|
|
67
|
-
Joi.assert(params.orgId, Joi.string().required());
|
|
68
|
-
Joi.assert(session, Joi.string().required());
|
|
69
|
-
|
|
70
|
-
const {id, orgId} = params;
|
|
71
|
-
const apiCall = self._client.get(`/admin/organizations/${orgId}/orgdoctypes/${id}`, self._setHeader(session));
|
|
72
|
-
return self._returnData(await apiCall);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default AdminDocTypes;
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
class AdminDocTypes {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
Joi.assert(options, Joi.object().required());
|
|
8
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
9
|
+
|
|
10
|
+
const self = this;
|
|
11
|
+
self.parent = options.parent;
|
|
12
|
+
self._client = self.parent.dispatch.getClient();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
17
|
+
* @description Get the return data and check for errors
|
|
18
|
+
* @param {object} retData Response HTTP
|
|
19
|
+
* @return {*}
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
_returnData(retData, def = {}) {
|
|
23
|
+
if (retData.status !== 200) {
|
|
24
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
25
|
+
} else {
|
|
26
|
+
return _.get(retData, 'data', def);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
32
|
+
* @description Set header with new session
|
|
33
|
+
* @param {string} session Session, token JWT
|
|
34
|
+
* @return {object} header with new session
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
_setHeader(session) {
|
|
38
|
+
return {
|
|
39
|
+
headers: {
|
|
40
|
+
authorization: session,
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
47
|
+
* @description Request profile by userId
|
|
48
|
+
* @param {object} params The params
|
|
49
|
+
* @param {string} params.id The organization document type id (_id database)
|
|
50
|
+
* @param {string} params.orgId The organization id (_id database)
|
|
51
|
+
* @param {string} session The JWT token
|
|
52
|
+
* @return {Promise<object>} The document
|
|
53
|
+
* @public
|
|
54
|
+
* @async
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
58
|
+
* const api = new API();
|
|
59
|
+
* const id = '55e4a3bd6be6b45210833fae';
|
|
60
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
61
|
+
* const retDocType = await api.admin.doctypes.findById(id, session);
|
|
62
|
+
*/
|
|
63
|
+
async findById(params, session) {
|
|
64
|
+
const self = this;
|
|
65
|
+
Joi.assert(params, Joi.object().required());
|
|
66
|
+
Joi.assert(params.id, Joi.string().required());
|
|
67
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
68
|
+
Joi.assert(session, Joi.string().required());
|
|
69
|
+
|
|
70
|
+
const {id, orgId} = params;
|
|
71
|
+
const apiCall = self._client.get(`/admin/organizations/${orgId}/orgdoctypes/${id}`, self._setHeader(session));
|
|
72
|
+
return self._returnData(await apiCall);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default AdminDocTypes;
|