@docbrasil/api-systemmanager 1.1.0 → 1.1.1
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/user/application.js +87 -0
- package/api/user/index.js +2 -0
- package/api/user/page.js +93 -0
- package/dist/bundle.cjs +1 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +95 -0
- package/docs/Admin.html +1 -1
- package/docs/AdminDocuments.html +1 -1
- package/docs/AdminForm.html +1 -1
- package/docs/AdminLists.html +1 -1
- package/docs/AdminMessage.html +1 -1
- package/docs/AdminNotification.html +1 -1
- package/docs/AdminPlugin.html +1 -1
- package/docs/AdminPolicy.html +1 -1
- package/docs/AdminProcesses.html +1 -1
- package/docs/AdminTask.html +1 -1
- package/docs/AdminUser.html +224 -6
- package/docs/Application.html +505 -0
- package/docs/Datasource.html +1 -1
- package/docs/Dispatch.html +1 -1
- package/docs/Documents.html +1 -1
- package/docs/External.html +1 -1
- package/docs/GeoLocation.html +1 -1
- package/docs/Help.html +674 -0
- package/docs/Login.html +1 -1
- package/docs/Notification.html +831 -1
- package/docs/Organization.html +1 -1
- package/docs/Page.html +553 -0
- package/docs/Process.html +1 -1
- package/docs/Register.html +1 -1
- package/docs/Session.html +1 -1
- package/docs/Task.html +1 -1
- package/docs/TaskAvailable.html +1 -1
- package/docs/Updates.html +428 -0
- package/docs/User.html +1 -1
- package/docs/Users.html +2 -2
- package/docs/admin_doctypes.js.html +1 -1
- package/docs/admin_document.js.html +1 -1
- package/docs/admin_form.js.html +1 -1
- package/docs/admin_index.js.html +1 -1
- package/docs/admin_list.js.html +1 -1
- package/docs/admin_message.js.html +1 -1
- package/docs/admin_notification.js.html +1 -1
- package/docs/admin_organization.js.html +1 -1
- package/docs/admin_plugin.js.html +1 -1
- package/docs/admin_policy.js.html +1 -1
- package/docs/admin_processes.js.html +1 -1
- package/docs/admin_task.js.html +1 -1
- package/docs/admin_user.js.html +31 -1
- package/docs/dispatch.js.html +1 -1
- package/docs/external.js.html +1 -1
- package/docs/general_geoLocation.js.html +1 -1
- package/docs/general_index.js.html +1 -1
- package/docs/index.html +1 -1
- package/docs/login.js.html +1 -1
- package/docs/session.js.html +1 -1
- package/docs/user_application.js.html +204 -0
- package/docs/user_datasource.js.html +1 -1
- package/docs/user_document.js.html +1 -1
- package/docs/user_help.js.html +230 -0
- package/docs/user_index.js.html +7 -1
- package/docs/user_notification.js.html +125 -1
- package/docs/user_organization.js.html +1 -1
- package/docs/user_page.js.html +210 -0
- package/docs/user_process.js.html +1 -1
- package/docs/user_register.js.html +1 -1
- package/docs/user_task.js.html +1 -1
- package/docs/user_task_available.js.html +1 -1
- package/docs/user_updates.js.html +195 -0
- package/docs/user_user.js.html +1 -1
- package/docs/utils_promises.js.html +1 -1
- package/package.json +1 -1
- package/yarn-error.log +4554 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class for Applications, permission user
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class Application {
|
|
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 Get the available applications for this user in this organizations
|
|
53
|
+
* @param {object} params Params to get task
|
|
54
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
55
|
+
* @param {string} session Session, token JWT
|
|
56
|
+
* @returns {promise}
|
|
57
|
+
* @public
|
|
58
|
+
* @example
|
|
59
|
+
*
|
|
60
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
61
|
+
* const api = new API();
|
|
62
|
+
* const params = {
|
|
63
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
64
|
+
* };
|
|
65
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
66
|
+
* await api.user.application.list(params, session);
|
|
67
|
+
*/
|
|
68
|
+
async list(params, session) {
|
|
69
|
+
const self = this;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
73
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
74
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
75
|
+
|
|
76
|
+
const { orgId} = params;
|
|
77
|
+
const apiCall = self._client
|
|
78
|
+
.get(`/organizations/${orgId}/applications`, self._setHeader(session));
|
|
79
|
+
|
|
80
|
+
return self._returnData(await apiCall);
|
|
81
|
+
} catch (ex) {
|
|
82
|
+
throw ex;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default Application;
|
package/api/user/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import Notification from './notification.js';
|
|
|
11
11
|
import Updates from './updates.js';
|
|
12
12
|
import Help from './help.js';
|
|
13
13
|
import Datasource from './datasource.js';
|
|
14
|
+
import Application from './notification.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @class API request, user permission level
|
|
@@ -37,6 +38,7 @@ class Users {
|
|
|
37
38
|
self.notification = new Notification(options);
|
|
38
39
|
self.updates = new Updates(options);
|
|
39
40
|
self.help = new Help(options);
|
|
41
|
+
self.application = new Application(options);
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
|
package/api/user/page.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class for Pages, permission user
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class Page {
|
|
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 Get the available page for an application inside an organization
|
|
53
|
+
* @param {object} params Params to get task
|
|
54
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
55
|
+
* @param {object} params.appId application id (_id database)
|
|
56
|
+
* @param {object} params.pageId page id (_id database)
|
|
57
|
+
* @param {string} session Session, token JWT
|
|
58
|
+
* @returns {promise}
|
|
59
|
+
* @public
|
|
60
|
+
* @example
|
|
61
|
+
*
|
|
62
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
63
|
+
* const api = new API();
|
|
64
|
+
* const params = {
|
|
65
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
66
|
+
* appId: '57e4a3bd6be6b45210833fa7',
|
|
67
|
+
* pageId: '57e4a3bd6be6b45210833fab'
|
|
68
|
+
* };
|
|
69
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
70
|
+
* await api.user.application.page.get(params, session);
|
|
71
|
+
*/
|
|
72
|
+
async get(params, session) {
|
|
73
|
+
const self = this;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
77
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
78
|
+
Joi.assert(params.appId, Joi.string().required(), 'Organization id (_id database)');
|
|
79
|
+
Joi.assert(params.pageId, Joi.string().required(), 'Organization id (_id database)');
|
|
80
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
81
|
+
|
|
82
|
+
const { orgId, appId, pageId} = params;
|
|
83
|
+
const apiCall = self._client
|
|
84
|
+
.get(`/organizations/${orgId}/applications/${appId}/page/${pageId}`, self._setHeader(session));
|
|
85
|
+
|
|
86
|
+
return self._returnData(await apiCall);
|
|
87
|
+
} catch (ex) {
|
|
88
|
+
throw ex;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default Page;
|
package/dist/bundle.cjs
CHANGED
|
@@ -10049,6 +10049,7 @@ class Users {
|
|
|
10049
10049
|
self.notification = new Notification(options);
|
|
10050
10050
|
self.updates = new Updates(options);
|
|
10051
10051
|
self.help = new Help(options);
|
|
10052
|
+
self.application = new Notification(options);
|
|
10052
10053
|
}
|
|
10053
10054
|
}
|
|
10054
10055
|
|