@docbrasil/api-systemmanager 1.0.107 → 1.0.109
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/.github/workflows/static.yml +43 -0
- package/api/external.js +41 -0
- package/dist/bundle.cjs +41 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +382 -0
- package/docs/Admin.html +336 -0
- package/docs/AdminDocuments.html +2235 -0
- package/docs/AdminForm.html +934 -0
- package/docs/AdminLists.html +895 -0
- package/docs/AdminMessage.html +1490 -0
- package/docs/AdminNotification.html +1636 -0
- package/docs/AdminPlugin.html +696 -0
- package/docs/AdminPolicy.html +451 -0
- package/docs/AdminProcesses.html +692 -0
- package/docs/AdminTask.html +740 -0
- package/docs/AdminUser.html +1203 -0
- package/docs/Datasource.html +660 -0
- package/docs/Dispatch.html +624 -0
- package/docs/Documents.html +4875 -0
- package/docs/External.html +1497 -0
- package/docs/GeoLocation.html +503 -0
- package/docs/Login.html +1839 -0
- package/docs/Notification.html +625 -0
- package/docs/Organization.html +2767 -0
- package/docs/Process.html +1598 -0
- package/docs/Register.html +1604 -0
- package/docs/Session.html +482 -0
- package/docs/Task.html +1394 -0
- package/docs/TaskAvailable.html +893 -0
- package/docs/User.html +2002 -0
- package/docs/Users.html +569 -0
- package/docs/admin_doctypes.js.html +193 -0
- package/docs/admin_document.js.html +449 -0
- package/docs/admin_form.js.html +268 -0
- package/docs/admin_index.js.html +163 -0
- package/docs/admin_list.js.html +250 -0
- package/docs/admin_message.js.html +311 -0
- package/docs/admin_notification.js.html +350 -0
- package/docs/admin_organization.js.html +241 -0
- package/docs/admin_plugin.js.html +233 -0
- package/docs/admin_policy.js.html +195 -0
- package/docs/admin_processes.js.html +487 -0
- package/docs/admin_task.js.html +242 -0
- package/docs/admin_user.js.html +302 -0
- package/docs/dispatch.js.html +218 -0
- package/docs/external.js.html +333 -0
- package/docs/general_geoLocation.js.html +205 -0
- package/docs/general_index.js.html +140 -0
- package/docs/index.html +129 -0
- package/docs/login.js.html +384 -0
- package/docs/scripts/app.min.js +1 -0
- package/docs/scripts/linenumber.js +26 -0
- package/docs/scripts/search.js +39 -0
- package/docs/session.js.html +202 -0
- package/docs/styles/app.min.css +1 -0
- package/docs/styles/iframe.css +13 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/docs/styles/reset.css +44 -0
- package/docs/user_datasource.js.html +261 -0
- package/docs/user_document.js.html +847 -0
- package/docs/user_index.js.html +156 -0
- package/docs/user_notification.js.html +218 -0
- package/docs/user_organization.js.html +347 -0
- package/docs/user_process.js.html +352 -0
- package/docs/user_register.js.html +322 -0
- package/docs/user_task.js.html +319 -0
- package/docs/user_task_available.js.html +252 -0
- package/docs/user_user.js.html +404 -0
- package/docs/utils_promises.js.html +235 -0
- package/package.json +7 -4
- package/readme.md +7 -8
- package/doc.md +0 -653
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
<html lang="en">
|
|
5
|
+
|
|
6
|
+
<head>
|
|
7
|
+
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title> admin/form.js</title>
|
|
11
|
+
|
|
12
|
+
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
|
13
|
+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
|
14
|
+
<script src="./build/entry.js"></script>
|
|
15
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
16
|
+
<!--[if lt IE 9]>
|
|
17
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
18
|
+
<![endif]-->
|
|
19
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
|
20
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
|
21
|
+
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
|
22
|
+
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
|
23
|
+
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
|
24
|
+
<link type="text/css" rel="stylesheet" href="">
|
|
25
|
+
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<body class="layout small-header">
|
|
33
|
+
<div id="stickyNavbarOverlay"></div>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<div class="top-nav">
|
|
37
|
+
<div class="inner">
|
|
38
|
+
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
|
39
|
+
<span aria-hidden="true"></span>
|
|
40
|
+
<span aria-hidden="true"></span>
|
|
41
|
+
<span aria-hidden="true"></span>
|
|
42
|
+
</a>
|
|
43
|
+
<div class="logo">
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
<div class="menu">
|
|
48
|
+
|
|
49
|
+
<div class="navigation">
|
|
50
|
+
<a
|
|
51
|
+
href="index.html"
|
|
52
|
+
class="link"
|
|
53
|
+
>
|
|
54
|
+
Documentation
|
|
55
|
+
</a>
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div id="main">
|
|
64
|
+
<div
|
|
65
|
+
class="sidebar "
|
|
66
|
+
id="sidebarNav"
|
|
67
|
+
>
|
|
68
|
+
|
|
69
|
+
<nav>
|
|
70
|
+
|
|
71
|
+
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="Admin.html">Admin</a></li><li><a href="AdminDocuments.html">AdminDocuments</a></li><li><a href="AdminForm.html">AdminForm</a></li><li><a href="AdminLists.html">AdminLists</a></li><li><a href="AdminMessage.html">AdminMessage</a></li><li><a href="AdminNotification.html">AdminNotification</a></li><li><a href="AdminPlugin.html">AdminPlugin</a></li><li><a href="AdminPolicy.html">AdminPolicy</a></li><li><a href="AdminProcesses.html">AdminProcesses</a></li><li><a href="AdminTask.html">AdminTask</a></li><li><a href="AdminUser.html">AdminUser</a></li><li><a href="Datasource.html">Datasource</a></li><li><a href="Dispatch.html">Dispatch</a></li><li><a href="Documents.html">Documents</a></li><li><a href="External.html">External</a></li><li><a href="GeoLocation.html">GeoLocation</a></li><li><a href="Login.html">Login</a></li><li><a href="Notification.html">Notification</a></li><li><a href="Organization.html">Organization</a></li><li><a href="Process.html">Process</a></li><li><a href="Register.html">Register</a></li><li><a href="Session.html">Session</a></li><li><a href="Task.html">Task</a></li><li><a href="TaskAvailable.html">TaskAvailable</a></li><li><a href="User.html">User</a></li><li><a href="Users.html">Users</a></li></ul></div>
|
|
72
|
+
|
|
73
|
+
</nav>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="core" id="main-content-wrapper">
|
|
76
|
+
<div class="content">
|
|
77
|
+
<header class="page-title">
|
|
78
|
+
<p>Source</p>
|
|
79
|
+
<h1>admin/form.js</h1>
|
|
80
|
+
</header>
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<section>
|
|
87
|
+
<article>
|
|
88
|
+
<pre class="prettyprint source linenums"><code>import _ from 'lodash';
|
|
89
|
+
import Boom from '@hapi/boom';
|
|
90
|
+
import Joi from 'joi';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Admin Class for forms, permission admin
|
|
94
|
+
* @class
|
|
95
|
+
*/
|
|
96
|
+
class AdminForm {
|
|
97
|
+
|
|
98
|
+
constructor(options) {
|
|
99
|
+
Joi.assert(options, Joi.object().required());
|
|
100
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
101
|
+
|
|
102
|
+
const self = this;
|
|
103
|
+
self.parent = options.parent;
|
|
104
|
+
self._client = self.parent.dispatch.getClient();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
109
|
+
* @description Get the return data and check for errors
|
|
110
|
+
* @param {object} retData Response HTTP
|
|
111
|
+
* @return {*}
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
_returnData(retData, def = {}) {
|
|
115
|
+
if (retData.status !== 200) {
|
|
116
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
117
|
+
} else {
|
|
118
|
+
return _.get(retData, 'data', def);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
124
|
+
* @description Set header with new session
|
|
125
|
+
* @param {string} session Session, token JWT
|
|
126
|
+
* @return {object} header with new session
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
_setHeader(session) {
|
|
130
|
+
return {
|
|
131
|
+
headers: {
|
|
132
|
+
authorization: session,
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
139
|
+
* @description Get advance form by ID
|
|
140
|
+
* @param {object} params Params to find form by id
|
|
141
|
+
* @param {string} params.id Formulary Id (_id database)
|
|
142
|
+
* @param {string} params.orgId Organization Id (_id database)
|
|
143
|
+
* @param {string} session Session, token JWT
|
|
144
|
+
* @return {Promise}
|
|
145
|
+
* @public
|
|
146
|
+
* @async
|
|
147
|
+
* @example
|
|
148
|
+
*
|
|
149
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
150
|
+
* const api = new API();
|
|
151
|
+
* const params = {
|
|
152
|
+
* id: '55e4a3bd6be6b45210833fae',
|
|
153
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
154
|
+
* };
|
|
155
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
156
|
+
* await api.admin.form.findById(params, session);
|
|
157
|
+
*/
|
|
158
|
+
async findById(params, session) {
|
|
159
|
+
const self = this;
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
Joi.assert(params, Joi.object().required());
|
|
163
|
+
Joi.assert(params.id, Joi.string().required());
|
|
164
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
165
|
+
Joi.assert(session, Joi.string().required());
|
|
166
|
+
|
|
167
|
+
const {id, orgId} = params;
|
|
168
|
+
const apiCall = self._client.get(`/admin/organizations/${orgId}/orgforms/${id}/form`, self._setHeader(session));
|
|
169
|
+
return self._returnData(await apiCall);
|
|
170
|
+
} catch (ex) {
|
|
171
|
+
throw ex;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
177
|
+
* @description Request signed url url to put or get
|
|
178
|
+
* @param {object} params - Params to get form list
|
|
179
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
180
|
+
* @param {number} params.page=1 - Page of pagination
|
|
181
|
+
* @param {number} params.perPage=200 - Items per page
|
|
182
|
+
* @param {object} params.type=2 - Form type (1 to Business or 2 to Advanced)
|
|
183
|
+
* @param {object} params.project={_id: 1, name: 1} - Fields to project
|
|
184
|
+
* @param {object} params.sort={name: 1} - Sort fields
|
|
185
|
+
* @param {string} session - Session, token JWT
|
|
186
|
+
* @return {Promise}
|
|
187
|
+
* @public
|
|
188
|
+
* @async
|
|
189
|
+
* @example
|
|
190
|
+
*
|
|
191
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
192
|
+
* const api = new API();
|
|
193
|
+
* const params - {
|
|
194
|
+
* orgId: '5dadd01dc4af3941d42f8c5c',
|
|
195
|
+
* };
|
|
196
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
197
|
+
* await api.user.form.getFormList(params, session);
|
|
198
|
+
*/
|
|
199
|
+
async getFormList(params, session) {
|
|
200
|
+
const self = this;
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
Joi.assert(params, Joi.object().required(), 'Params to get form list');
|
|
204
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
205
|
+
Joi.assert(params.page, Joi.number(), 'Page of pagination');
|
|
206
|
+
Joi.assert(params.perPage, Joi.number(), 'Items per page');
|
|
207
|
+
Joi.assert(params.type, Joi.number(), 'Form type (1 to Business or 2 to Advanced)');
|
|
208
|
+
Joi.assert(params.project, Joi.object(), 'Fields to project');
|
|
209
|
+
Joi.assert(params.sort, Joi.object(), 'Sort fields for');
|
|
210
|
+
Joi.assert(session, Joi.string().required(), 'Session, token JWT');
|
|
211
|
+
|
|
212
|
+
const FORM_ADVANCED = 2;
|
|
213
|
+
const PROJECTION_DEFAULT = {_id: 1, name: 1};
|
|
214
|
+
const SORT_DEFAULT = {name: 1};
|
|
215
|
+
|
|
216
|
+
const {
|
|
217
|
+
orgId,
|
|
218
|
+
page = 1,
|
|
219
|
+
perPage = 200,
|
|
220
|
+
type = FORM_ADVANCED,
|
|
221
|
+
project = PROJECTION_DEFAULT,
|
|
222
|
+
sort = SORT_DEFAULT
|
|
223
|
+
} = params;
|
|
224
|
+
|
|
225
|
+
const payloadToSend = { orgId, type, $project: project, sort };
|
|
226
|
+
|
|
227
|
+
const apiCall = self._client
|
|
228
|
+
.post(`/admin/organizations/${orgId}/orgforms?page=${page}&perPage=${perPage}`, payloadToSend, self._setHeader(session));
|
|
229
|
+
|
|
230
|
+
return self._returnData(await apiCall);
|
|
231
|
+
|
|
232
|
+
} catch (ex) {
|
|
233
|
+
throw ex;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default AdminForm;
|
|
239
|
+
</code></pre>
|
|
240
|
+
</article>
|
|
241
|
+
</section>
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<footer class="footer">
|
|
249
|
+
<div class="content has-text-centered">
|
|
250
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
251
|
+
<p class="sidebar-created-by">
|
|
252
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
253
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
254
|
+
</p>
|
|
255
|
+
</div>
|
|
256
|
+
</footer>
|
|
257
|
+
|
|
258
|
+
</div>
|
|
259
|
+
<div id="side-nav" class="side-nav">
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
<script src="scripts/app.min.js"></script>
|
|
263
|
+
<script>PR.prettyPrint();</script>
|
|
264
|
+
<script src="scripts/linenumber.js"> </script>
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
</body>
|
|
268
|
+
</html>
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
<html lang="en">
|
|
5
|
+
|
|
6
|
+
<head>
|
|
7
|
+
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title> admin/index.js</title>
|
|
11
|
+
|
|
12
|
+
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
|
13
|
+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
|
14
|
+
<script src="./build/entry.js"></script>
|
|
15
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
16
|
+
<!--[if lt IE 9]>
|
|
17
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
18
|
+
<![endif]-->
|
|
19
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
|
20
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
|
21
|
+
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
|
22
|
+
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
|
23
|
+
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
|
24
|
+
<link type="text/css" rel="stylesheet" href="">
|
|
25
|
+
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<body class="layout small-header">
|
|
33
|
+
<div id="stickyNavbarOverlay"></div>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<div class="top-nav">
|
|
37
|
+
<div class="inner">
|
|
38
|
+
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
|
39
|
+
<span aria-hidden="true"></span>
|
|
40
|
+
<span aria-hidden="true"></span>
|
|
41
|
+
<span aria-hidden="true"></span>
|
|
42
|
+
</a>
|
|
43
|
+
<div class="logo">
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
<div class="menu">
|
|
48
|
+
|
|
49
|
+
<div class="navigation">
|
|
50
|
+
<a
|
|
51
|
+
href="index.html"
|
|
52
|
+
class="link"
|
|
53
|
+
>
|
|
54
|
+
Documentation
|
|
55
|
+
</a>
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div id="main">
|
|
64
|
+
<div
|
|
65
|
+
class="sidebar "
|
|
66
|
+
id="sidebarNav"
|
|
67
|
+
>
|
|
68
|
+
|
|
69
|
+
<nav>
|
|
70
|
+
|
|
71
|
+
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="Admin.html">Admin</a></li><li><a href="AdminDocuments.html">AdminDocuments</a></li><li><a href="AdminForm.html">AdminForm</a></li><li><a href="AdminLists.html">AdminLists</a></li><li><a href="AdminMessage.html">AdminMessage</a></li><li><a href="AdminNotification.html">AdminNotification</a></li><li><a href="AdminPlugin.html">AdminPlugin</a></li><li><a href="AdminPolicy.html">AdminPolicy</a></li><li><a href="AdminProcesses.html">AdminProcesses</a></li><li><a href="AdminTask.html">AdminTask</a></li><li><a href="AdminUser.html">AdminUser</a></li><li><a href="Datasource.html">Datasource</a></li><li><a href="Dispatch.html">Dispatch</a></li><li><a href="Documents.html">Documents</a></li><li><a href="External.html">External</a></li><li><a href="GeoLocation.html">GeoLocation</a></li><li><a href="Login.html">Login</a></li><li><a href="Notification.html">Notification</a></li><li><a href="Organization.html">Organization</a></li><li><a href="Process.html">Process</a></li><li><a href="Register.html">Register</a></li><li><a href="Session.html">Session</a></li><li><a href="Task.html">Task</a></li><li><a href="TaskAvailable.html">TaskAvailable</a></li><li><a href="User.html">User</a></li><li><a href="Users.html">Users</a></li></ul></div>
|
|
72
|
+
|
|
73
|
+
</nav>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="core" id="main-content-wrapper">
|
|
76
|
+
<div class="content">
|
|
77
|
+
<header class="page-title">
|
|
78
|
+
<p>Source</p>
|
|
79
|
+
<h1>admin/index.js</h1>
|
|
80
|
+
</header>
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<section>
|
|
87
|
+
<article>
|
|
88
|
+
<pre class="prettyprint source linenums"><code>import Joi from 'joi';
|
|
89
|
+
|
|
90
|
+
import AdminDocument from './document.js';
|
|
91
|
+
import AdminForm from './form.js';
|
|
92
|
+
import AdminNotification from './notification.js';
|
|
93
|
+
import AdminList from './list.js';
|
|
94
|
+
import AdminPlugin from './plugin.js';
|
|
95
|
+
import AdminPolicy from './policy.js';
|
|
96
|
+
import AdminTask from './task.js';
|
|
97
|
+
import AdminUser from './user.js';
|
|
98
|
+
import AdminProcesses from './processes.js';
|
|
99
|
+
import AdminMessage from './message.js';
|
|
100
|
+
import AdminDocTypes from './doctypes.js';
|
|
101
|
+
import AdminOrganizations from './organization.js';
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @class API request, admin permission level
|
|
105
|
+
*/
|
|
106
|
+
class Admin {
|
|
107
|
+
/**
|
|
108
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
109
|
+
* @constructor
|
|
110
|
+
* @param {object} options Params of the constructor
|
|
111
|
+
* @param {object} options.parent This of the pararent
|
|
112
|
+
*/
|
|
113
|
+
constructor(options) {
|
|
114
|
+
Joi.assert(options, Joi.object().required());
|
|
115
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
116
|
+
|
|
117
|
+
const self = this;
|
|
118
|
+
self.doctypes = new AdminDocTypes(options);
|
|
119
|
+
self.document = new AdminDocument(options);
|
|
120
|
+
self.form = new AdminForm(options);
|
|
121
|
+
self.list = new AdminList(options);
|
|
122
|
+
self.message = new AdminMessage(options);
|
|
123
|
+
self.organizations = new AdminOrganizations(options);
|
|
124
|
+
self.notification = new AdminNotification(options);
|
|
125
|
+
self.plugin = new AdminPlugin(options);
|
|
126
|
+
self.policy = new AdminPolicy(options);
|
|
127
|
+
self.processes = new AdminProcesses(options);
|
|
128
|
+
self.task = new AdminTask(options);
|
|
129
|
+
self.user = new AdminUser(options);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default Admin;
|
|
134
|
+
</code></pre>
|
|
135
|
+
</article>
|
|
136
|
+
</section>
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<footer class="footer">
|
|
144
|
+
<div class="content has-text-centered">
|
|
145
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
146
|
+
<p class="sidebar-created-by">
|
|
147
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
148
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
149
|
+
</p>
|
|
150
|
+
</div>
|
|
151
|
+
</footer>
|
|
152
|
+
|
|
153
|
+
</div>
|
|
154
|
+
<div id="side-nav" class="side-nav">
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
<script src="scripts/app.min.js"></script>
|
|
158
|
+
<script>PR.prettyPrint();</script>
|
|
159
|
+
<script src="scripts/linenumber.js"> </script>
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
</body>
|
|
163
|
+
</html>
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
<html lang="en">
|
|
5
|
+
|
|
6
|
+
<head>
|
|
7
|
+
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title> admin/list.js</title>
|
|
11
|
+
|
|
12
|
+
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
|
13
|
+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
|
14
|
+
<script src="./build/entry.js"></script>
|
|
15
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
16
|
+
<!--[if lt IE 9]>
|
|
17
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
18
|
+
<![endif]-->
|
|
19
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
|
20
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
|
21
|
+
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
|
22
|
+
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
|
23
|
+
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
|
24
|
+
<link type="text/css" rel="stylesheet" href="">
|
|
25
|
+
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<body class="layout small-header">
|
|
33
|
+
<div id="stickyNavbarOverlay"></div>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<div class="top-nav">
|
|
37
|
+
<div class="inner">
|
|
38
|
+
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
|
39
|
+
<span aria-hidden="true"></span>
|
|
40
|
+
<span aria-hidden="true"></span>
|
|
41
|
+
<span aria-hidden="true"></span>
|
|
42
|
+
</a>
|
|
43
|
+
<div class="logo">
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
<div class="menu">
|
|
48
|
+
|
|
49
|
+
<div class="navigation">
|
|
50
|
+
<a
|
|
51
|
+
href="index.html"
|
|
52
|
+
class="link"
|
|
53
|
+
>
|
|
54
|
+
Documentation
|
|
55
|
+
</a>
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div id="main">
|
|
64
|
+
<div
|
|
65
|
+
class="sidebar "
|
|
66
|
+
id="sidebarNav"
|
|
67
|
+
>
|
|
68
|
+
|
|
69
|
+
<nav>
|
|
70
|
+
|
|
71
|
+
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="Admin.html">Admin</a></li><li><a href="AdminDocuments.html">AdminDocuments</a></li><li><a href="AdminForm.html">AdminForm</a></li><li><a href="AdminLists.html">AdminLists</a></li><li><a href="AdminMessage.html">AdminMessage</a></li><li><a href="AdminNotification.html">AdminNotification</a></li><li><a href="AdminPlugin.html">AdminPlugin</a></li><li><a href="AdminPolicy.html">AdminPolicy</a></li><li><a href="AdminProcesses.html">AdminProcesses</a></li><li><a href="AdminTask.html">AdminTask</a></li><li><a href="AdminUser.html">AdminUser</a></li><li><a href="Datasource.html">Datasource</a></li><li><a href="Dispatch.html">Dispatch</a></li><li><a href="Documents.html">Documents</a></li><li><a href="External.html">External</a></li><li><a href="GeoLocation.html">GeoLocation</a></li><li><a href="Login.html">Login</a></li><li><a href="Notification.html">Notification</a></li><li><a href="Organization.html">Organization</a></li><li><a href="Process.html">Process</a></li><li><a href="Register.html">Register</a></li><li><a href="Session.html">Session</a></li><li><a href="Task.html">Task</a></li><li><a href="TaskAvailable.html">TaskAvailable</a></li><li><a href="User.html">User</a></li><li><a href="Users.html">Users</a></li></ul></div>
|
|
72
|
+
|
|
73
|
+
</nav>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="core" id="main-content-wrapper">
|
|
76
|
+
<div class="content">
|
|
77
|
+
<header class="page-title">
|
|
78
|
+
<p>Source</p>
|
|
79
|
+
<h1>admin/list.js</h1>
|
|
80
|
+
</header>
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
<section>
|
|
87
|
+
<article>
|
|
88
|
+
<pre class="prettyprint source linenums"><code>import _ from 'lodash';
|
|
89
|
+
import Boom from '@hapi/boom';
|
|
90
|
+
import Joi from 'joi';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Admin Class for lists, permission admin
|
|
94
|
+
* @class
|
|
95
|
+
*/
|
|
96
|
+
class AdminLists {
|
|
97
|
+
|
|
98
|
+
constructor(options) {
|
|
99
|
+
Joi.assert(options, Joi.object().required());
|
|
100
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
101
|
+
|
|
102
|
+
const self = this;
|
|
103
|
+
self.parent = options.parent;
|
|
104
|
+
self._client = self.parent.dispatch.getClient();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
109
|
+
* @description Get the return data and check for errors
|
|
110
|
+
* @param {object} retData Response HTTP
|
|
111
|
+
* @return {*}
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
_returnData(retData, def = {}) {
|
|
115
|
+
if (retData.status !== 200) {
|
|
116
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
117
|
+
} else {
|
|
118
|
+
return _.get(retData, 'data', def);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
124
|
+
* @description Set header with new session
|
|
125
|
+
* @param {string} session Session, token JWT
|
|
126
|
+
* @return {object} header with new session
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
_setHeader(session) {
|
|
130
|
+
return {
|
|
131
|
+
headers: {
|
|
132
|
+
authorization: session,
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
139
|
+
* @description Get list by ID
|
|
140
|
+
* @param {object} params Params to find list by id
|
|
141
|
+
* @param {string} params.id List Id (_id database)
|
|
142
|
+
* @param {string} params.orgId Organization Id (_id database)
|
|
143
|
+
* @param {string} session Session, token JWT
|
|
144
|
+
* @return {Promise}
|
|
145
|
+
* @public
|
|
146
|
+
* @async
|
|
147
|
+
* @example
|
|
148
|
+
*
|
|
149
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
150
|
+
* const api = new API();
|
|
151
|
+
* const params = {
|
|
152
|
+
* id: '55e4a3bd6be6b45210833fae',
|
|
153
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
154
|
+
* };
|
|
155
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
156
|
+
* await api.admin.list.findById(params, session);
|
|
157
|
+
*/
|
|
158
|
+
async findById(params, session) {
|
|
159
|
+
const self = this;
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
Joi.assert(params, Joi.object().required());
|
|
163
|
+
Joi.assert(params.id, Joi.string().required());
|
|
164
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
165
|
+
Joi.assert(session, Joi.string().required());
|
|
166
|
+
|
|
167
|
+
const {id, orgId} = params;
|
|
168
|
+
const apiCall = self._client.get(`/admin/organizations/${orgId}/orgtags/${id}`, self._setHeader(session));
|
|
169
|
+
return self._returnData(await apiCall);
|
|
170
|
+
} catch (ex) {
|
|
171
|
+
throw ex;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
177
|
+
* @description Get all lists
|
|
178
|
+
* @param {object} params={} Params to pagination and orgId
|
|
179
|
+
* @param {number} [params.page=0] Current page to pagination
|
|
180
|
+
* @param {number} [params.perPage=200] Qnt itens per page
|
|
181
|
+
* @param {string} params.orgId Organization Id (_id database)
|
|
182
|
+
* @param {string} session Session, token JWT
|
|
183
|
+
* @return {Promise}
|
|
184
|
+
* @public
|
|
185
|
+
* @async
|
|
186
|
+
* @example
|
|
187
|
+
*
|
|
188
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
189
|
+
* const api = new API();
|
|
190
|
+
* const params = {
|
|
191
|
+
* orgId: '55e4a3bd6be6b45210833fae'
|
|
192
|
+
* };
|
|
193
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
194
|
+
* await api.admin.list.find(params, session);
|
|
195
|
+
*/
|
|
196
|
+
async find(params = {}, session) {
|
|
197
|
+
const self = this;
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
|
|
201
|
+
Joi.assert(params, Joi.object());
|
|
202
|
+
Joi.assert(params.page, Joi.number());
|
|
203
|
+
Joi.assert(params.perPage, Joi.number());
|
|
204
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
205
|
+
Joi.assert(session, Joi.string().required());
|
|
206
|
+
|
|
207
|
+
const orgId = _.get(params, 'orgId');
|
|
208
|
+
const page = _.get(params, 'page', 0);
|
|
209
|
+
const perPage = _.get(params, 'perPage', 200);
|
|
210
|
+
const apiCall = self._client
|
|
211
|
+
.post(`/admin/organizations/${orgId}/orgtags?page=${page}&perPage=${perPage}`, {}, self._setHeader(session));
|
|
212
|
+
|
|
213
|
+
return self._returnData(await apiCall);
|
|
214
|
+
} catch (ex) {
|
|
215
|
+
throw ex;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export default AdminLists;
|
|
221
|
+
</code></pre>
|
|
222
|
+
</article>
|
|
223
|
+
</section>
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<footer class="footer">
|
|
231
|
+
<div class="content has-text-centered">
|
|
232
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
233
|
+
<p class="sidebar-created-by">
|
|
234
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
235
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
236
|
+
</p>
|
|
237
|
+
</div>
|
|
238
|
+
</footer>
|
|
239
|
+
|
|
240
|
+
</div>
|
|
241
|
+
<div id="side-nav" class="side-nav">
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
<script src="scripts/app.min.js"></script>
|
|
245
|
+
<script>PR.prettyPrint();</script>
|
|
246
|
+
<script src="scripts/linenumber.js"> </script>
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
</body>
|
|
250
|
+
</html>
|