@docbrasil/api-systemmanager 1.0.87 → 1.0.89

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 (57) 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/general/geoLocation.js +88 -88
  16. package/api/general/index.js +22 -22
  17. package/api/login.js +267 -267
  18. package/api/session.js +85 -85
  19. package/api/user/datasource.js +144 -144
  20. package/api/user/document.js +730 -687
  21. package/api/user/index.js +39 -39
  22. package/api/user/notification.js +101 -101
  23. package/api/user/organization.js +230 -230
  24. package/api/user/process.js +191 -191
  25. package/api/user/register.js +205 -205
  26. package/api/user/task.js +201 -201
  27. package/api/user/task_available.js +135 -135
  28. package/api/user/user.js +287 -287
  29. package/api/utils/cypher.js +37 -37
  30. package/api/utils/promises.js +118 -118
  31. package/bundleRollup.js +158 -158
  32. package/dist/bundle.cjs +4875 -4832
  33. package/dist/bundle.mjs +1 -1
  34. package/doc/api.md +372 -666
  35. package/doc.md +653 -653
  36. package/helper/boom.js +487 -487
  37. package/helper/cryptojs.js +6067 -6067
  38. package/index.js +85 -85
  39. package/package-lock.json +4635 -4635
  40. package/package.json +68 -67
  41. package/readme.md +25 -25
  42. package/tests/admin/document.spec.js +45 -45
  43. package/tests/admin/form.spec.js +74 -74
  44. package/tests/admin/list.spec.js +86 -86
  45. package/tests/admin/message.js +92 -92
  46. package/tests/admin/notification.spec.js +174 -174
  47. package/tests/admin/pluginspec..js +71 -71
  48. package/tests/admin/policy.spec.js +71 -71
  49. package/tests/admin/processes.spec.js +119 -119
  50. package/tests/admin/users.spec.js +127 -127
  51. package/tests/documents.spec.js +164 -164
  52. package/tests/login.spec.js +91 -91
  53. package/tests/session.spec..js +58 -58
  54. package/tests/user/documents.js +164 -164
  55. package/tests/user/organization.js +122 -122
  56. package/tests/user/process.js +71 -71
  57. package/tests/user/user.js +88 -88
package/api/dispatch.js CHANGED
@@ -1,101 +1,101 @@
1
- import _ from 'lodash';
2
- import Joi from 'joi';
3
- import Axios from 'axios';
4
-
5
- /**
6
- * @class Api dispatch manager
7
- */
8
- class Dispatch {
9
-
10
- constructor(options) {
11
-
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 = Axios.create({baseURL: self.parent.options.uri});
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
- throw 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
- * Get the URL context
52
- * @param url {string} Full url
53
- * @param session {session} Session, token JWT
54
- * @return {Promise<object>} The full data context of the URL
55
- * @public
56
- * @async
57
- * @example
58
- *
59
- * const API = require('@docbrasil/api-systemmanager');
60
- * const api = new API();
61
- * const retContext = await api.dispatch.getContext('http://myndware.io/login/myorg);
62
- *
63
- */
64
- async getContext(url, session = null) {
65
- Joi.assert(url, Joi.string().required());
66
-
67
- if(url.includes('?')) {
68
- url = `${url}&json=true`;
69
- } else {
70
- url = `${url}?json=true`;
71
- }
72
-
73
- const self = this;
74
- const header = session ? self._setHeader(session) : {};
75
- const apiCall = self._client.get(url, header);
76
- return self._returnData(await apiCall);
77
- }
78
-
79
- /**
80
- * @author CloudBrasil <abernardo.br@gmail.com>
81
- * @description Get client Axios
82
- * @return {promise} return client axios
83
- * @public
84
- * @async
85
- * @example
86
- *
87
- * const API = require('@docbrasil/api-systemmanager');
88
- * const api = new API();
89
- * await api.dispatch.getClient();
90
- */
91
- getClient() {
92
- try {
93
- const self = this;
94
- return self._client;
95
- } catch (ex) {
96
- return ex;
97
- }
98
- }
99
- }
100
-
101
- export default Dispatch;
1
+ import _ from 'lodash';
2
+ import Joi from 'joi';
3
+ import Axios from 'axios';
4
+
5
+ /**
6
+ * @class Api dispatch manager
7
+ */
8
+ class Dispatch {
9
+
10
+ constructor(options) {
11
+
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 = Axios.create({baseURL: self.parent.options.uri});
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
+ throw 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
+ * Get the URL context
52
+ * @param url {string} Full url
53
+ * @param session {session} Session, token JWT
54
+ * @return {Promise<object>} The full data context of the URL
55
+ * @public
56
+ * @async
57
+ * @example
58
+ *
59
+ * const API = require('@docbrasil/api-systemmanager');
60
+ * const api = new API();
61
+ * const retContext = await api.dispatch.getContext('http://myndware.io/login/myorg);
62
+ *
63
+ */
64
+ async getContext(url, session = null) {
65
+ Joi.assert(url, Joi.string().required());
66
+
67
+ if(url.includes('?')) {
68
+ url = `${url}&json=true`;
69
+ } else {
70
+ url = `${url}?json=true`;
71
+ }
72
+
73
+ const self = this;
74
+ const header = session ? self._setHeader(session) : {};
75
+ const apiCall = self._client.get(url, header);
76
+ return self._returnData(await apiCall);
77
+ }
78
+
79
+ /**
80
+ * @author CloudBrasil <abernardo.br@gmail.com>
81
+ * @description Get client Axios
82
+ * @return {promise} return client axios
83
+ * @public
84
+ * @async
85
+ * @example
86
+ *
87
+ * const API = require('@docbrasil/api-systemmanager');
88
+ * const api = new API();
89
+ * await api.dispatch.getClient();
90
+ */
91
+ getClient() {
92
+ try {
93
+ const self = this;
94
+ return self._client;
95
+ } catch (ex) {
96
+ return ex;
97
+ }
98
+ }
99
+ }
100
+
101
+ export default Dispatch;
@@ -1,88 +1,88 @@
1
- import _ from 'lodash';
2
- import Boom from '@hapi/boom';
3
- import Joi from 'joi';
4
-
5
- /**
6
- * General Class for user, permission organization
7
- * @class
8
- */
9
- class GeoLocation {
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 CloudBrasil <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 geo location of the address
53
- * @param {!object} params - Params to get geo location
54
- * @param {!string} params.address - The address to get the location for
55
- * @param {!string} params.apiKey - The Organization API Key
56
- * @return {Promise}
57
- * @public
58
- * @async
59
- * @example
60
- *
61
- * const API = require('@docbrasil/api-systemmanager');
62
- * const api = new API();
63
- * const params = {
64
- * address: 'Rua Sud Menucci, 615 - Vila Camilopolis, Santo André - SP',
65
- * apiKey: 'AIzaSyC7gJFOkuT-Mel3WZbX5uKuJ1USqLVkGnY',
66
- * };
67
- * await api.general.geo.location(params);
68
- */
69
- async location(params, session) {
70
- const self = this;
71
-
72
- try {
73
- Joi.assert(params, Joi.object().required());
74
- Joi.assert(params.address, Joi.string().required(), 'The address to get the location for');
75
- Joi.assert(params.apiKey, Joi.string().required(), 'The Organization API Key');
76
-
77
- const {address, apiKey} = params;
78
- const query = `address=${address}&apiKey=${apiKey}`;
79
-
80
- const apiCall = self._client.get(`/location/geo?${query}`);
81
- return self._returnData(await apiCall);
82
- } catch (ex) {
83
- throw ex;
84
- }
85
- }
86
- }
87
-
88
- export default GeoLocation;
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+
5
+ /**
6
+ * General Class for user, permission organization
7
+ * @class
8
+ */
9
+ class GeoLocation {
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 CloudBrasil <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 geo location of the address
53
+ * @param {!object} params - Params to get geo location
54
+ * @param {!string} params.address - The address to get the location for
55
+ * @param {!string} params.apiKey - The Organization API Key
56
+ * @return {Promise}
57
+ * @public
58
+ * @async
59
+ * @example
60
+ *
61
+ * const API = require('@docbrasil/api-systemmanager');
62
+ * const api = new API();
63
+ * const params = {
64
+ * address: 'Rua Sud Menucci, 615 - Vila Camilopolis, Santo André - SP',
65
+ * apiKey: 'AIzaSyC7gJFOkuT-Mel3WZbX5uKuJ1USqLVkGnY',
66
+ * };
67
+ * await api.general.geo.location(params);
68
+ */
69
+ async location(params, session) {
70
+ const self = this;
71
+
72
+ try {
73
+ Joi.assert(params, Joi.object().required());
74
+ Joi.assert(params.address, Joi.string().required(), 'The address to get the location for');
75
+ Joi.assert(params.apiKey, Joi.string().required(), 'The Organization API Key');
76
+
77
+ const {address, apiKey} = params;
78
+ const query = `address=${address}&apiKey=${apiKey}`;
79
+
80
+ const apiCall = self._client.get(`/location/geo?${query}`);
81
+ return self._returnData(await apiCall);
82
+ } catch (ex) {
83
+ throw ex;
84
+ }
85
+ }
86
+ }
87
+
88
+ export default GeoLocation;
@@ -1,23 +1,23 @@
1
- import Joi from 'joi';
2
- import Geo from './geoLocation';
3
-
4
- /**
5
- * @class API request, user permission level
6
- */
7
- class Users {
8
- /**
9
- * @author CloudBrasil <abernardo.br@gmail.com>
10
- * @constructor
11
- * @param {object} options Params of the constructor
12
- * @param {object} options.parent This of the pararent
13
- */
14
- constructor(options) {
15
- Joi.assert(options, Joi.object().required());
16
- Joi.assert(options.parent, Joi.object().required());
17
-
18
- const self = this;
19
- self.geo = new Geo(options);
20
- }
21
- }
22
-
1
+ import Joi from 'joi';
2
+ import Geo from './geoLocation';
3
+
4
+ /**
5
+ * @class API request, user permission level
6
+ */
7
+ class Users {
8
+ /**
9
+ * @author CloudBrasil <abernardo.br@gmail.com>
10
+ * @constructor
11
+ * @param {object} options Params of the constructor
12
+ * @param {object} options.parent This of the pararent
13
+ */
14
+ constructor(options) {
15
+ Joi.assert(options, Joi.object().required());
16
+ Joi.assert(options.parent, Joi.object().required());
17
+
18
+ const self = this;
19
+ self.geo = new Geo(options);
20
+ }
21
+ }
22
+
23
23
  export default Users;