@docbrasil/api-systemmanager 1.1.1 → 1.1.3
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/.project +11 -0
- package/api/user/application.js +2 -0
- package/api/user/index.js +1 -1
- package/dist/bundle.cjs +172 -1
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
- package/yarn-error.log +0 -4554
package/.project
ADDED
package/api/user/application.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import Boom from '@hapi/boom';
|
|
3
3
|
import Joi from 'joi';
|
|
4
|
+
import Page from './page.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Class for Applications, permission user
|
|
@@ -15,6 +16,7 @@ class Application {
|
|
|
15
16
|
const self = this;
|
|
16
17
|
self.parent = options.parent;
|
|
17
18
|
self._client = self.parent.dispatch.getClient();
|
|
19
|
+
self.page = new Page(options);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
package/api/user/index.js
CHANGED
|
@@ -11,7 +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 './
|
|
14
|
+
import Application from './application.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @class API request, user permission level
|
package/dist/bundle.cjs
CHANGED
|
@@ -10024,6 +10024,177 @@ class Datasource {
|
|
|
10024
10024
|
}
|
|
10025
10025
|
}
|
|
10026
10026
|
|
|
10027
|
+
/**
|
|
10028
|
+
* Class for Pages, permission user
|
|
10029
|
+
* @class
|
|
10030
|
+
*/
|
|
10031
|
+
class Page {
|
|
10032
|
+
|
|
10033
|
+
constructor(options) {
|
|
10034
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
10035
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
10036
|
+
|
|
10037
|
+
const self = this;
|
|
10038
|
+
self.parent = options.parent;
|
|
10039
|
+
self._client = self.parent.dispatch.getClient();
|
|
10040
|
+
}
|
|
10041
|
+
|
|
10042
|
+
/**
|
|
10043
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
10044
|
+
* @description Get the return data and check for errors
|
|
10045
|
+
* @param {object} retData Response HTTP
|
|
10046
|
+
* @return {*}
|
|
10047
|
+
* @private
|
|
10048
|
+
*/
|
|
10049
|
+
_returnData(retData, def = {}) {
|
|
10050
|
+
if (retData.status !== 200) {
|
|
10051
|
+
return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
10052
|
+
} else {
|
|
10053
|
+
return ___default["default"].get(retData, 'data', def);
|
|
10054
|
+
}
|
|
10055
|
+
}
|
|
10056
|
+
|
|
10057
|
+
/**
|
|
10058
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
10059
|
+
* @description Set header with new session
|
|
10060
|
+
* @param {string} session Session, token JWT
|
|
10061
|
+
* @return {object} header with new session
|
|
10062
|
+
* @private
|
|
10063
|
+
*/
|
|
10064
|
+
_setHeader(session) {
|
|
10065
|
+
return {
|
|
10066
|
+
headers: {
|
|
10067
|
+
authorization: session,
|
|
10068
|
+
}
|
|
10069
|
+
};
|
|
10070
|
+
}
|
|
10071
|
+
|
|
10072
|
+
/**
|
|
10073
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
10074
|
+
* @description Get the available page for an application inside an organization
|
|
10075
|
+
* @param {object} params Params to get task
|
|
10076
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
10077
|
+
* @param {object} params.appId application id (_id database)
|
|
10078
|
+
* @param {object} params.pageId page id (_id database)
|
|
10079
|
+
* @param {string} session Session, token JWT
|
|
10080
|
+
* @returns {promise}
|
|
10081
|
+
* @public
|
|
10082
|
+
* @example
|
|
10083
|
+
*
|
|
10084
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
10085
|
+
* const api = new API();
|
|
10086
|
+
* const params = {
|
|
10087
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
10088
|
+
* appId: '57e4a3bd6be6b45210833fa7',
|
|
10089
|
+
* pageId: '57e4a3bd6be6b45210833fab'
|
|
10090
|
+
* };
|
|
10091
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
10092
|
+
* await api.user.application.page.get(params, session);
|
|
10093
|
+
*/
|
|
10094
|
+
async get(params, session) {
|
|
10095
|
+
const self = this;
|
|
10096
|
+
|
|
10097
|
+
try {
|
|
10098
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
|
|
10099
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
10100
|
+
Joi__default["default"].assert(params.appId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
10101
|
+
Joi__default["default"].assert(params.pageId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
10102
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
10103
|
+
|
|
10104
|
+
const { orgId, appId, pageId} = params;
|
|
10105
|
+
const apiCall = self._client
|
|
10106
|
+
.get(`/organizations/${orgId}/applications/${appId}/page/${pageId}`, self._setHeader(session));
|
|
10107
|
+
|
|
10108
|
+
return self._returnData(await apiCall);
|
|
10109
|
+
} catch (ex) {
|
|
10110
|
+
throw ex;
|
|
10111
|
+
}
|
|
10112
|
+
}
|
|
10113
|
+
}
|
|
10114
|
+
|
|
10115
|
+
/**
|
|
10116
|
+
* Class for Applications, permission user
|
|
10117
|
+
* @class
|
|
10118
|
+
*/
|
|
10119
|
+
class Application {
|
|
10120
|
+
|
|
10121
|
+
constructor(options) {
|
|
10122
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
10123
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
10124
|
+
|
|
10125
|
+
const self = this;
|
|
10126
|
+
self.parent = options.parent;
|
|
10127
|
+
self._client = self.parent.dispatch.getClient();
|
|
10128
|
+
self.page = new Page(options);
|
|
10129
|
+
}
|
|
10130
|
+
|
|
10131
|
+
/**
|
|
10132
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
10133
|
+
* @description Get the return data and check for errors
|
|
10134
|
+
* @param {object} retData Response HTTP
|
|
10135
|
+
* @return {*}
|
|
10136
|
+
* @private
|
|
10137
|
+
*/
|
|
10138
|
+
_returnData(retData, def = {}) {
|
|
10139
|
+
if (retData.status !== 200) {
|
|
10140
|
+
return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
10141
|
+
} else {
|
|
10142
|
+
return ___default["default"].get(retData, 'data', def);
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10145
|
+
|
|
10146
|
+
/**
|
|
10147
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
10148
|
+
* @description Set header with new session
|
|
10149
|
+
* @param {string} session Session, token JWT
|
|
10150
|
+
* @return {object} header with new session
|
|
10151
|
+
* @private
|
|
10152
|
+
*/
|
|
10153
|
+
_setHeader(session) {
|
|
10154
|
+
return {
|
|
10155
|
+
headers: {
|
|
10156
|
+
authorization: session,
|
|
10157
|
+
}
|
|
10158
|
+
};
|
|
10159
|
+
}
|
|
10160
|
+
|
|
10161
|
+
/**
|
|
10162
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
10163
|
+
* @description Get the available applications for this user in this organizations
|
|
10164
|
+
* @param {object} params Params to get task
|
|
10165
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
10166
|
+
* @param {string} session Session, token JWT
|
|
10167
|
+
* @returns {promise}
|
|
10168
|
+
* @public
|
|
10169
|
+
* @example
|
|
10170
|
+
*
|
|
10171
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
10172
|
+
* const api = new API();
|
|
10173
|
+
* const params = {
|
|
10174
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
10175
|
+
* };
|
|
10176
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
10177
|
+
* await api.user.application.list(params, session);
|
|
10178
|
+
*/
|
|
10179
|
+
async list(params, session) {
|
|
10180
|
+
const self = this;
|
|
10181
|
+
|
|
10182
|
+
try {
|
|
10183
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
|
|
10184
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
10185
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
10186
|
+
|
|
10187
|
+
const { orgId} = params;
|
|
10188
|
+
const apiCall = self._client
|
|
10189
|
+
.get(`/organizations/${orgId}/applications`, self._setHeader(session));
|
|
10190
|
+
|
|
10191
|
+
return self._returnData(await apiCall);
|
|
10192
|
+
} catch (ex) {
|
|
10193
|
+
throw ex;
|
|
10194
|
+
}
|
|
10195
|
+
}
|
|
10196
|
+
}
|
|
10197
|
+
|
|
10027
10198
|
/**
|
|
10028
10199
|
* @class API request, user permission level
|
|
10029
10200
|
*/
|
|
@@ -10049,7 +10220,7 @@ class Users {
|
|
|
10049
10220
|
self.notification = new Notification(options);
|
|
10050
10221
|
self.updates = new Updates(options);
|
|
10051
10222
|
self.help = new Help(options);
|
|
10052
|
-
self.application = new
|
|
10223
|
+
self.application = new Application(options);
|
|
10053
10224
|
}
|
|
10054
10225
|
}
|
|
10055
10226
|
|