@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,487 @@
|
|
|
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/processes.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/processes.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 processes, permission admin
|
|
94
|
+
* @class
|
|
95
|
+
*/
|
|
96
|
+
class AdminProcesses {
|
|
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
|
+
self._operatorsType = ['string', 'date', 'datetime', 'idcard', 'orgidcard', 'number', 'currency'];
|
|
107
|
+
self._operatorOfString = ['=', '*', '*=', '=*', '*?', '~'];
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @description Operator of string, format is: DD/MM/YYY -> Exemple: 22/10/2000
|
|
111
|
+
* @type {string[]}
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
self._operatorOfDate = ['=', '>', '>=', '<', '<=', '...'];
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @description Operator of string, format is: DD/MM/YYY HH:mm -> Exemple: 22/10/2000 14:32
|
|
118
|
+
* @type {string[]}
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
self._operatorOfDateTime = ['=', '>', '>=', '<', '<=', '...'];
|
|
122
|
+
self._operatorOfIdCard = ['=', '*', '*=', '=*'];
|
|
123
|
+
self._operatorOfOrgICard = ['=', '*', '*=', '=*'];
|
|
124
|
+
self._operatorOfNumber = ['=', '>', '>=', '<', '<='];
|
|
125
|
+
self._operatorOfCurrency = ['=', '>', '>=', '<', '<='];
|
|
126
|
+
|
|
127
|
+
self.allOperators = new Set([
|
|
128
|
+
...self._operatorOfString, ...self._operatorOfDate, ...self._operatorOfDateTime,
|
|
129
|
+
...self._operatorOfIdCard, ...self._operatorOfOrgICard, ...self._operatorOfNumber,
|
|
130
|
+
...self._operatorOfCurrency
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
self._status = ['FINISHED', 'NOT_FINISHED'];
|
|
134
|
+
|
|
135
|
+
//
|
|
136
|
+
// SCHEMAS
|
|
137
|
+
//
|
|
138
|
+
self._schemaOrgId = Joi.string().required().label('Organization id'),
|
|
139
|
+
|
|
140
|
+
self._schemaProcessId = Joi.object({
|
|
141
|
+
value: Joi.array().items(Joi.string()).min(1).label('Numbers of processId'),
|
|
142
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
143
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
144
|
+
name: Joi.string().default('processId').label('Propertie name'),
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
self._schemaProtocol = Joi.object({
|
|
148
|
+
value: Joi.string().required().label('Number of protocol'),
|
|
149
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
150
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
self._schemaHistoryBegin = Joi.object({
|
|
154
|
+
value: Joi.string().required().label('History begin'),
|
|
155
|
+
type: Joi.string().default('date').valid(...self._operatorsType).label('Operation type'),
|
|
156
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
self._schemaHistoryEnd = Joi.object({
|
|
160
|
+
value: Joi.string().required().label('History end'),
|
|
161
|
+
type: Joi.string().default('date').valid(...self._operatorsType).label('Operation type'),
|
|
162
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
self._schemaStatus = Joi.object({
|
|
166
|
+
value: Joi.string().default('FINISHED').valid(self._status.toString()).label('Process Status'),
|
|
167
|
+
type: Joi.string().default('string').valid('string').label('Operation type'),
|
|
168
|
+
oper: Joi.string().default('=').valid('=').label('Type of condition'),
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
self._schemaOrgProcessId = Joi.object({
|
|
172
|
+
value: Joi.string().required().label('Organization process id'),
|
|
173
|
+
type: Joi.string().default('string').valid('string').label('Operation type'),
|
|
174
|
+
oper: Joi.string().default('=').valid('=').label('Type of condition'),
|
|
175
|
+
}).required().label('Organization process id');
|
|
176
|
+
|
|
177
|
+
self._schemaFormData = Joi.array().items(
|
|
178
|
+
Joi.object({
|
|
179
|
+
value: Joi.string().required().label('Text to search'),
|
|
180
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
181
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
182
|
+
name: Joi.string().required().label('Property name'),
|
|
183
|
+
})
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
self._schemaAdvFormData = Joi.array().items(
|
|
187
|
+
Joi.object({
|
|
188
|
+
value: Joi.any().required().label('Value to search'),
|
|
189
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
190
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
191
|
+
name: Joi.string().required().label('Property name'),
|
|
192
|
+
})
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
self._schemaProcessProperties = Joi.array().items(
|
|
196
|
+
Joi.object({
|
|
197
|
+
value: Joi.any().required().label('Value to search'),
|
|
198
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
199
|
+
oper: Joi.string().default('=').label('Type of condition'),
|
|
200
|
+
name: Joi.string().required().label('Property name'),
|
|
201
|
+
})
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
self._schemaInitParams = Joi.array().items(
|
|
205
|
+
Joi.object({
|
|
206
|
+
value: Joi.any().required().label('Value to search'),
|
|
207
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
208
|
+
oper: Joi.string().default('=').label('Type of condition'),
|
|
209
|
+
name: Joi.string().required().label('Property name'),
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
self._schemaParticipants = Joi.object({
|
|
214
|
+
value: Joi.array().items(
|
|
215
|
+
Joi.string().label('Value to search')
|
|
216
|
+
),
|
|
217
|
+
type: Joi.string().default('string').valid('string').label('Operation type'),
|
|
218
|
+
oper: Joi.string().default('=').valid('=').label('Type of condition'),
|
|
219
|
+
name: Joi.string().required().label('Process participant group'),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
self._schemaProcessParticipantsGroup = Joi.object({
|
|
223
|
+
value: Joi.string().label('Value to search'),
|
|
224
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
225
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
226
|
+
name: Joi.string().required().label('Process participant group'),
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
self._schemaUserId = Joi.object({
|
|
230
|
+
value: Joi.string().label('Value to search'),
|
|
231
|
+
type: Joi.string().default('string').valid('string').label('Operation type'),
|
|
232
|
+
oper: Joi.string().default('=').valid('=').label('Type of condition'),
|
|
233
|
+
name: Joi.string().required().label('User id'),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
self._schemaUserGroups = Joi.object({
|
|
237
|
+
value: Joi.array().items(
|
|
238
|
+
Joi.string().label('Value to search')
|
|
239
|
+
),
|
|
240
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
241
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
242
|
+
name: Joi.string().required().label('User groups'),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
self._schemaUserName = Joi.object({
|
|
246
|
+
value: Joi.string().label('Value to search'),
|
|
247
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
248
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
249
|
+
name: Joi.string().required().label('User name'),
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
self._schemaUserDepartment = Joi.object({
|
|
253
|
+
value: Joi.string().label('Value to search'),
|
|
254
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
255
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
256
|
+
name: Joi.string().required().label('User department'),
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
self._schemaUserSubDepartment = Joi.object({
|
|
260
|
+
value: Joi.string().label('Value to search'),
|
|
261
|
+
type: Joi.string().default('string').valid(...self._operatorsType).label('Operation type'),
|
|
262
|
+
oper: Joi.string().default('=').valid(...self.allOperators).label('Type of condition'),
|
|
263
|
+
name: Joi.string().required().label('User sub department'),
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
self._schemaNp = Joi.number().default(0).label('Enable or disable pagination'); // 1 disable pagination, 0 enable pagination
|
|
267
|
+
|
|
268
|
+
self._schemaPj = Joi.array().items(
|
|
269
|
+
Joi.string().label('Value to projection')
|
|
270
|
+
).default([
|
|
271
|
+
'processId', 'orgId', 'protocol', 'historyBegin', 'historyEnd', 'status',
|
|
272
|
+
'orgProcessId', 'processProperties', 'userId', 'userName', 'initParams'
|
|
273
|
+
]);
|
|
274
|
+
|
|
275
|
+
self._schemaSort = Joi.object().label('Sort data');
|
|
276
|
+
self._schemaPerPage = Joi.number().default(20).label('Item per page');
|
|
277
|
+
self._schemaPage = Joi.number().default(1).label('Start page in pagination');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
282
|
+
* @description Get the return data and check for errors
|
|
283
|
+
* @param {object} retData Response HTTP
|
|
284
|
+
* @return {*}
|
|
285
|
+
* @private
|
|
286
|
+
*/
|
|
287
|
+
_returnData(retData, def = {}) {
|
|
288
|
+
if (retData.status !== 200) {
|
|
289
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
290
|
+
} else {
|
|
291
|
+
return _.get(retData, 'data', def);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
297
|
+
* @description Set header with new session
|
|
298
|
+
* @param {string} session Session, token JWT
|
|
299
|
+
* @return {object} header with new session
|
|
300
|
+
* @private
|
|
301
|
+
*/
|
|
302
|
+
_setHeader(session) {
|
|
303
|
+
return {
|
|
304
|
+
headers: {
|
|
305
|
+
authorization: session,
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @author Thiago Anselmo <thiagoo.anselmoo@gmail.com>
|
|
312
|
+
* @description Mount query string to send in URL
|
|
313
|
+
* @param {object} params Params to mount query string
|
|
314
|
+
* @private
|
|
315
|
+
* @example
|
|
316
|
+
*
|
|
317
|
+
* const params = {name: 'Thiago', lastname: 'anselmo'};
|
|
318
|
+
* self._mountQueryString(params);
|
|
319
|
+
* // output name=Thiago&lastname=anselmo
|
|
320
|
+
*/
|
|
321
|
+
async _mountQueryString(params) {
|
|
322
|
+
try {
|
|
323
|
+
const allowTypeForQueryString = ['string', 'boolean', 'number'];
|
|
324
|
+
|
|
325
|
+
Joi.assert(params, Joi.object(), 'Params to mount query string');
|
|
326
|
+
|
|
327
|
+
params = Object.keys(params).reduce((newParams, field) => {
|
|
328
|
+
const fieldData = params[field];
|
|
329
|
+
return _.isArray(fieldData) || _.isObject(fieldData)
|
|
330
|
+
? {...newParams, [field]: JSON.stringify(fieldData)}
|
|
331
|
+
: {...newParams, [field]: fieldData}
|
|
332
|
+
}, {});
|
|
333
|
+
|
|
334
|
+
const queryString = Object.entries(params)
|
|
335
|
+
.map(filter => filter.join('='))
|
|
336
|
+
.join('&');
|
|
337
|
+
|
|
338
|
+
return queryString;
|
|
339
|
+
} catch (ex) {
|
|
340
|
+
throw ex;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* @see https://confluence.external-share.com/content/7450b014-52c6-4d9e-b30e-a062b57453b5/17104899/17694721/532545537
|
|
346
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
347
|
+
* @description Advanced search of processes, check documentation, to verify all params, pass to method search
|
|
348
|
+
* @return {Promise}
|
|
349
|
+
* @public
|
|
350
|
+
* @async
|
|
351
|
+
* @example
|
|
352
|
+
*
|
|
353
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
354
|
+
* const api = new API();
|
|
355
|
+
* const params = {
|
|
356
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
357
|
+
* ...
|
|
358
|
+
* ...
|
|
359
|
+
* ...
|
|
360
|
+
* };
|
|
361
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
362
|
+
* await api.admin.processes.search(params, session);
|
|
363
|
+
*/
|
|
364
|
+
async search(params, session) {
|
|
365
|
+
const self = this;
|
|
366
|
+
|
|
367
|
+
try {
|
|
368
|
+
const paramsAfterValidation = Joi.attempt(params,
|
|
369
|
+
Joi.object({
|
|
370
|
+
orgId: self._schemaOrgId,
|
|
371
|
+
processId: self._schemaProcessId,
|
|
372
|
+
protocol: self._schemaProtocol,
|
|
373
|
+
historyBegin: self._schemaHistoryBegin,
|
|
374
|
+
historyEnd: self._schemaHistoryEnd,
|
|
375
|
+
status: self._schemaStatus,
|
|
376
|
+
orgProcessId: self._schemaOrgProcessId,
|
|
377
|
+
formData: self._schemaFormData,
|
|
378
|
+
advFormData: self._schemaAdvFormData,
|
|
379
|
+
processProperties: self._schemaProcessProperties,
|
|
380
|
+
initParams: self._schemaInitParams,
|
|
381
|
+
participants: self._schemaParticipants,
|
|
382
|
+
processParticipantsGroup: self._schemaProcessParticipantsGroup,
|
|
383
|
+
userId: self._schemaUserId,
|
|
384
|
+
userGroups: self._schemaUserGroups,
|
|
385
|
+
userName: self._schemaUserName,
|
|
386
|
+
userDepartment: self._schemaUserDepartment,
|
|
387
|
+
userSubDepartment: self._schemaUserSubDepartment,
|
|
388
|
+
np: self._schemaNp,
|
|
389
|
+
pj: self._schemaPj,
|
|
390
|
+
s: self._schemaSort,
|
|
391
|
+
p: self._schemaPerPage,
|
|
392
|
+
i: self._schemaPage
|
|
393
|
+
}).options({abortEarly: false, stripUnknown: true})
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
const setParams = {...paramsAfterValidation, pj: paramsAfterValidation.pj.toString()};
|
|
397
|
+
const {orgId, ...payload} = setParams;
|
|
398
|
+
const queryString = JSON.stringify(payload);
|
|
399
|
+
|
|
400
|
+
const apiCall = self._client.get(`/admin/organizations/${orgId}/processes/search?query=${queryString}`, self._setHeader(session));
|
|
401
|
+
return self._returnData(await apiCall);
|
|
402
|
+
} catch (ex) {
|
|
403
|
+
throw ex;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
409
|
+
* @description Advanced search of process in elastic search ussing system manager
|
|
410
|
+
* @param {!object} params - Params to search document
|
|
411
|
+
* @param {!string} params.orgProcessId - Document id (_id database) of the process
|
|
412
|
+
* @param {!object} params.query - Query to search in elastic search
|
|
413
|
+
* @param {!string} session Session, token JWT
|
|
414
|
+
* @return {Promise}
|
|
415
|
+
* @public
|
|
416
|
+
* @async
|
|
417
|
+
* @example
|
|
418
|
+
*
|
|
419
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
420
|
+
* const api = new API();
|
|
421
|
+
* const params = {
|
|
422
|
+
* orgProcessId: '5edd11c46b6ce9729c2c297c',
|
|
423
|
+
* query: {
|
|
424
|
+
* "_source": "processData.properties.processProperties",
|
|
425
|
+
* "query": {
|
|
426
|
+
* "term": {
|
|
427
|
+
* "initParams.email.keyword": {
|
|
428
|
+
* "value": "clintes001@gmail.com"
|
|
429
|
+
* }
|
|
430
|
+
* }
|
|
431
|
+
* }
|
|
432
|
+
* }
|
|
433
|
+
* }
|
|
434
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
435
|
+
* await api.admin.processes.advancedSearch(params, session);
|
|
436
|
+
*/
|
|
437
|
+
async advancedSearch(params, session) {
|
|
438
|
+
const self = this;
|
|
439
|
+
|
|
440
|
+
try {
|
|
441
|
+
Joi.assert(params, Joi.object().required(), 'Params to search document');
|
|
442
|
+
Joi.assert(params.orgProcessId, Joi.string().required(), 'Document id (_id database) of the process');
|
|
443
|
+
Joi.assert(params.query, Joi.object().required(), 'eQuery, query to search document in elastic search');
|
|
444
|
+
Joi.assert(session, Joi.string().required(), 'Session is token JWT');
|
|
445
|
+
|
|
446
|
+
const {orgProcessId, query} = params;
|
|
447
|
+
const payload = {orgProcessId, query};
|
|
448
|
+
|
|
449
|
+
const apiCall = self._client.post(`/admin/processes/search`, payload, self._setHeader(session));
|
|
450
|
+
return self._returnData(await apiCall);
|
|
451
|
+
} catch (ex) {
|
|
452
|
+
throw ex;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export default AdminProcesses;
|
|
458
|
+
</code></pre>
|
|
459
|
+
</article>
|
|
460
|
+
</section>
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
</div>
|
|
466
|
+
|
|
467
|
+
<footer class="footer">
|
|
468
|
+
<div class="content has-text-centered">
|
|
469
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
470
|
+
<p class="sidebar-created-by">
|
|
471
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
472
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
473
|
+
</p>
|
|
474
|
+
</div>
|
|
475
|
+
</footer>
|
|
476
|
+
|
|
477
|
+
</div>
|
|
478
|
+
<div id="side-nav" class="side-nav">
|
|
479
|
+
</div>
|
|
480
|
+
</div>
|
|
481
|
+
<script src="scripts/app.min.js"></script>
|
|
482
|
+
<script>PR.prettyPrint();</script>
|
|
483
|
+
<script src="scripts/linenumber.js"> </script>
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
</body>
|
|
487
|
+
</html>
|