@docbrasil/api-systemmanager 1.0.97 → 1.0.98

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 (59) hide show
  1. package/api/admin/doctypes.js +76 -76
  2. package/api/admin/document.js +332 -332
  3. package/api/admin/form.js +151 -151
  4. package/api/admin/index.js +46 -46
  5. package/api/admin/list.js +133 -133
  6. package/api/admin/message.js +194 -194
  7. package/api/admin/notification.js +233 -233
  8. package/api/admin/organization.js +124 -124
  9. package/api/admin/plugin.js +116 -116
  10. package/api/admin/policy.js +78 -78
  11. package/api/admin/processes.js +370 -370
  12. package/api/admin/task.js +125 -125
  13. package/api/admin/user.js +185 -185
  14. package/api/dispatch.js +101 -101
  15. package/api/external.js +86 -0
  16. package/api/general/geoLocation.js +88 -88
  17. package/api/general/index.js +23 -23
  18. package/api/login.js +267 -267
  19. package/api/session.js +85 -85
  20. package/api/user/datasource.js +144 -144
  21. package/api/user/document.js +730 -730
  22. package/api/user/index.js +39 -39
  23. package/api/user/notification.js +101 -101
  24. package/api/user/organization.js +230 -230
  25. package/api/user/process.js +191 -191
  26. package/api/user/register.js +205 -205
  27. package/api/user/task.js +201 -202
  28. package/api/user/task_available.js +135 -135
  29. package/api/user/user.js +287 -287
  30. package/api/utils/cypher.js +37 -37
  31. package/api/utils/promises.js +118 -118
  32. package/bundleRollup.js +158 -158
  33. package/dist/bundle.cjs +4878 -4876
  34. package/dist/bundle.mjs +1 -1
  35. package/doc/api.md +2453 -2453
  36. package/doc.md +653 -653
  37. package/helper/boom.js +487 -487
  38. package/helper/cryptojs.js +6067 -6067
  39. package/index.js +87 -85
  40. package/package-lock.json +4635 -4635
  41. package/package.json +68 -68
  42. package/readme.md +25 -25
  43. package/tests/admin/document.spec.js +45 -45
  44. package/tests/admin/form.spec.js +74 -74
  45. package/tests/admin/list.spec.js +86 -86
  46. package/tests/admin/message.js +92 -92
  47. package/tests/admin/notification.spec.js +174 -174
  48. package/tests/admin/pluginspec..js +71 -71
  49. package/tests/admin/policy.spec.js +71 -71
  50. package/tests/admin/processes.spec.js +119 -119
  51. package/tests/admin/users.spec.js +127 -127
  52. package/tests/documents.spec.js +164 -164
  53. package/tests/login.spec.js +91 -91
  54. package/tests/session.spec..js +58 -58
  55. package/tests/user/documents.js +164 -164
  56. package/tests/user/organization.js +122 -122
  57. package/tests/user/process.js +71 -71
  58. package/tests/user/task_available.js +75 -75
  59. package/tests/user/user.js +88 -88
package/api/user/index.js CHANGED
@@ -1,39 +1,39 @@
1
- import _ from 'lodash';
2
- import Joi from 'joi';
3
-
4
- import Document from './document.js';
5
- import Organization from './organization.js';
6
- import Process from './process.js';
7
- import Task from './task.js';
8
- import User from './user.js';
9
- import Register from './register.js';
10
- import Notification from './notification.js';
11
- import Datasource from './datasource.js';
12
-
13
- /**
14
- * @class API request, user permission level
15
- */
16
- class Users {
17
- /**
18
- * @author CloudBrasil <abernardo.br@gmail.com>
19
- * @constructor
20
- * @param {object} options Params of the constructor
21
- * @param {object} options.parent This of the pararent
22
- */
23
- constructor(options) {
24
- Joi.assert(options, Joi.object().required());
25
- Joi.assert(options.parent, Joi.object().required());
26
-
27
- const self = this;
28
- self.document = new Document(options);
29
- self.datasource = new Datasource(options);
30
- self.organization = new Organization(options);
31
- self.process = new Process(options);
32
- self.task = new Task(options);
33
- self.user = self.profile = new User(options);
34
- self.register = new Register(options);
35
- self.notification = new Notification(options);
36
- }
37
- }
38
-
39
- export default Users;
1
+ import _ from 'lodash';
2
+ import Joi from 'joi';
3
+
4
+ import Document from './document.js';
5
+ import Organization from './organization.js';
6
+ import Process from './process.js';
7
+ import Task from './task.js';
8
+ import User from './user.js';
9
+ import Register from './register.js';
10
+ import Notification from './notification.js';
11
+ import Datasource from './datasource.js';
12
+
13
+ /**
14
+ * @class API request, user permission level
15
+ */
16
+ class Users {
17
+ /**
18
+ * @author CloudBrasil <abernardo.br@gmail.com>
19
+ * @constructor
20
+ * @param {object} options Params of the constructor
21
+ * @param {object} options.parent This of the pararent
22
+ */
23
+ constructor(options) {
24
+ Joi.assert(options, Joi.object().required());
25
+ Joi.assert(options.parent, Joi.object().required());
26
+
27
+ const self = this;
28
+ self.document = new Document(options);
29
+ self.datasource = new Datasource(options);
30
+ self.organization = new Organization(options);
31
+ self.process = new Process(options);
32
+ self.task = new Task(options);
33
+ self.user = self.profile = new User(options);
34
+ self.register = new Register(options);
35
+ self.notification = new Notification(options);
36
+ }
37
+ }
38
+
39
+ export default Users;
@@ -1,101 +1,101 @@
1
- import _ from 'lodash';
2
- import Boom from '@hapi/boom';
3
- import Joi from 'joi';
4
-
5
- /**
6
- * Class for user registration in a user
7
- * @class
8
- */
9
- class Notification {
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
- * Notification token types
52
- * @return {{FCM_CAPACITOR: string, FCM_WEB: string}}
53
- */
54
- get tokenTypes () {
55
- return {
56
- FCM_WEB: 'FCM_WEB',
57
- FCM_CAPACITOR: 'FCM_CAPACITOR'
58
- };
59
- }
60
-
61
- /**
62
- * @author CloudBrasil <abernardo.br@gmail.com>
63
- * @description Method to add a notification token
64
- * @param {object} params Params to add notification token
65
- * @param {string} params.token The token
66
- * @param {object} params.type The token type
67
- * @param {string} session Is token JWT of user NOT allow SU
68
- * @returns {promise<object>} data
69
- * @returns {boolean} data._id the id of the added token
70
- * @public
71
- * @example
72
- *
73
- * const API = require('@docbrasil/api-systemmanager');
74
- * const api = new API();
75
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
76
- * const params = {
77
- * token: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
78
- * type: 'FCM_WEB'
79
- * };
80
- * const retData = await api.user.notification.addToken(params, session);
81
- */
82
- async addToken(params = {}, session) {
83
- const self = this;
84
-
85
- try {
86
- Joi.assert(params, Joi.object().required(), 'Params to get task');
87
- Joi.assert(params.token, Joi.string().required(), 'Token is required');
88
- Joi.assert(params.type, Joi.string().required(), ' The token type');
89
-
90
- const apiCall = self._client
91
- .put(`/users/notifications/token`, params, self._setHeader(session));
92
-
93
- const retData = self._returnData(await apiCall);
94
- return retData;
95
- } catch (ex) {
96
- throw ex;
97
- }
98
- }
99
- }
100
-
101
- export default Notification;
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+
5
+ /**
6
+ * Class for user registration in a user
7
+ * @class
8
+ */
9
+ class Notification {
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
+ * Notification token types
52
+ * @return {{FCM_CAPACITOR: string, FCM_WEB: string}}
53
+ */
54
+ get tokenTypes () {
55
+ return {
56
+ FCM_WEB: 'FCM_WEB',
57
+ FCM_CAPACITOR: 'FCM_CAPACITOR'
58
+ };
59
+ }
60
+
61
+ /**
62
+ * @author CloudBrasil <abernardo.br@gmail.com>
63
+ * @description Method to add a notification token
64
+ * @param {object} params Params to add notification token
65
+ * @param {string} params.token The token
66
+ * @param {object} params.type The token type
67
+ * @param {string} session Is token JWT of user NOT allow SU
68
+ * @returns {promise<object>} data
69
+ * @returns {boolean} data._id the id of the added token
70
+ * @public
71
+ * @example
72
+ *
73
+ * const API = require('@docbrasil/api-systemmanager');
74
+ * const api = new API();
75
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
76
+ * const params = {
77
+ * token: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
78
+ * type: 'FCM_WEB'
79
+ * };
80
+ * const retData = await api.user.notification.addToken(params, session);
81
+ */
82
+ async addToken(params = {}, session) {
83
+ const self = this;
84
+
85
+ try {
86
+ Joi.assert(params, Joi.object().required(), 'Params to get task');
87
+ Joi.assert(params.token, Joi.string().required(), 'Token is required');
88
+ Joi.assert(params.type, Joi.string().required(), ' The token type');
89
+
90
+ const apiCall = self._client
91
+ .put(`/users/notifications/token`, params, self._setHeader(session));
92
+
93
+ const retData = self._returnData(await apiCall);
94
+ return retData;
95
+ } catch (ex) {
96
+ throw ex;
97
+ }
98
+ }
99
+ }
100
+
101
+ export default Notification;