@docbrasil/api-systemmanager 1.1.0 → 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.
Files changed (73) hide show
  1. package/.project +11 -0
  2. package/api/user/application.js +89 -0
  3. package/api/user/index.js +2 -0
  4. package/api/user/page.js +93 -0
  5. package/dist/bundle.cjs +172 -0
  6. package/dist/bundle.mjs +1 -1
  7. package/doc/api.md +95 -0
  8. package/docs/Admin.html +1 -1
  9. package/docs/AdminDocuments.html +1 -1
  10. package/docs/AdminForm.html +1 -1
  11. package/docs/AdminLists.html +1 -1
  12. package/docs/AdminMessage.html +1 -1
  13. package/docs/AdminNotification.html +1 -1
  14. package/docs/AdminPlugin.html +1 -1
  15. package/docs/AdminPolicy.html +1 -1
  16. package/docs/AdminProcesses.html +1 -1
  17. package/docs/AdminTask.html +1 -1
  18. package/docs/AdminUser.html +224 -6
  19. package/docs/Application.html +505 -0
  20. package/docs/Datasource.html +1 -1
  21. package/docs/Dispatch.html +1 -1
  22. package/docs/Documents.html +1 -1
  23. package/docs/External.html +1 -1
  24. package/docs/GeoLocation.html +1 -1
  25. package/docs/Help.html +674 -0
  26. package/docs/Login.html +1 -1
  27. package/docs/Notification.html +831 -1
  28. package/docs/Organization.html +1 -1
  29. package/docs/Page.html +553 -0
  30. package/docs/Process.html +1 -1
  31. package/docs/Register.html +1 -1
  32. package/docs/Session.html +1 -1
  33. package/docs/Task.html +1 -1
  34. package/docs/TaskAvailable.html +1 -1
  35. package/docs/Updates.html +428 -0
  36. package/docs/User.html +1 -1
  37. package/docs/Users.html +2 -2
  38. package/docs/admin_doctypes.js.html +1 -1
  39. package/docs/admin_document.js.html +1 -1
  40. package/docs/admin_form.js.html +1 -1
  41. package/docs/admin_index.js.html +1 -1
  42. package/docs/admin_list.js.html +1 -1
  43. package/docs/admin_message.js.html +1 -1
  44. package/docs/admin_notification.js.html +1 -1
  45. package/docs/admin_organization.js.html +1 -1
  46. package/docs/admin_plugin.js.html +1 -1
  47. package/docs/admin_policy.js.html +1 -1
  48. package/docs/admin_processes.js.html +1 -1
  49. package/docs/admin_task.js.html +1 -1
  50. package/docs/admin_user.js.html +31 -1
  51. package/docs/dispatch.js.html +1 -1
  52. package/docs/external.js.html +1 -1
  53. package/docs/general_geoLocation.js.html +1 -1
  54. package/docs/general_index.js.html +1 -1
  55. package/docs/index.html +1 -1
  56. package/docs/login.js.html +1 -1
  57. package/docs/session.js.html +1 -1
  58. package/docs/user_application.js.html +204 -0
  59. package/docs/user_datasource.js.html +1 -1
  60. package/docs/user_document.js.html +1 -1
  61. package/docs/user_help.js.html +230 -0
  62. package/docs/user_index.js.html +7 -1
  63. package/docs/user_notification.js.html +125 -1
  64. package/docs/user_organization.js.html +1 -1
  65. package/docs/user_page.js.html +210 -0
  66. package/docs/user_process.js.html +1 -1
  67. package/docs/user_register.js.html +1 -1
  68. package/docs/user_task.js.html +1 -1
  69. package/docs/user_task_available.js.html +1 -1
  70. package/docs/user_updates.js.html +195 -0
  71. package/docs/user_user.js.html +1 -1
  72. package/docs/utils_promises.js.html +1 -1
  73. package/package.json +1 -1
package/.project ADDED
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>api-systemmanager</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ </buildSpec>
9
+ <natures>
10
+ </natures>
11
+ </projectDescription>
@@ -0,0 +1,89 @@
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+ import Page from './page.js';
5
+
6
+ /**
7
+ * Class for Applications, permission user
8
+ * @class
9
+ */
10
+ class Application {
11
+
12
+ constructor(options) {
13
+ Joi.assert(options, Joi.object().required());
14
+ Joi.assert(options.parent, Joi.object().required());
15
+
16
+ const self = this;
17
+ self.parent = options.parent;
18
+ self._client = self.parent.dispatch.getClient();
19
+ self.page = new Page(options);
20
+ }
21
+
22
+ /**
23
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
24
+ * @description Get the return data and check for errors
25
+ * @param {object} retData Response HTTP
26
+ * @return {*}
27
+ * @private
28
+ */
29
+ _returnData(retData, def = {}) {
30
+ if (retData.status !== 200) {
31
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
32
+ } else {
33
+ return _.get(retData, 'data', def);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * @author CloudBrasil <abernardo.br@gmail.com>
39
+ * @description Set header with new session
40
+ * @param {string} session Session, token JWT
41
+ * @return {object} header with new session
42
+ * @private
43
+ */
44
+ _setHeader(session) {
45
+ return {
46
+ headers: {
47
+ authorization: session,
48
+ }
49
+ };
50
+ }
51
+
52
+ /**
53
+ * @author CloudBrasil <abernardo.br@gmail.com>
54
+ * @description Get the available applications for this user in this organizations
55
+ * @param {object} params Params to get task
56
+ * @param {object} params.orgId Organization 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
+ * };
67
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
68
+ * await api.user.application.list(params, session);
69
+ */
70
+ async list(params, session) {
71
+ const self = this;
72
+
73
+ try {
74
+ Joi.assert(params, Joi.object().required(), 'Params to get task');
75
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
76
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
77
+
78
+ const { orgId} = params;
79
+ const apiCall = self._client
80
+ .get(`/organizations/${orgId}/applications`, self._setHeader(session));
81
+
82
+ return self._returnData(await apiCall);
83
+ } catch (ex) {
84
+ throw ex;
85
+ }
86
+ }
87
+ }
88
+
89
+ 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 './application.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
 
@@ -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
@@ -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,6 +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);
10223
+ self.application = new Application(options);
10052
10224
  }
10053
10225
  }
10054
10226