@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,193 @@
|
|
|
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/doctypes.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/doctypes.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
|
+
class AdminDocTypes {
|
|
93
|
+
constructor(options) {
|
|
94
|
+
Joi.assert(options, Joi.object().required());
|
|
95
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
96
|
+
|
|
97
|
+
const self = this;
|
|
98
|
+
self.parent = options.parent;
|
|
99
|
+
self._client = self.parent.dispatch.getClient();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
104
|
+
* @description Get the return data and check for errors
|
|
105
|
+
* @param {object} retData Response HTTP
|
|
106
|
+
* @return {*}
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
_returnData(retData, def = {}) {
|
|
110
|
+
if (retData.status !== 200) {
|
|
111
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
112
|
+
} else {
|
|
113
|
+
return _.get(retData, 'data', def);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
119
|
+
* @description Set header with new session
|
|
120
|
+
* @param {string} session Session, token JWT
|
|
121
|
+
* @return {object} header with new session
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
_setHeader(session) {
|
|
125
|
+
return {
|
|
126
|
+
headers: {
|
|
127
|
+
authorization: session,
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
134
|
+
* @description Request profile by userId
|
|
135
|
+
* @param {object} params The params
|
|
136
|
+
* @param {string} params.id The organization document type id (_id database)
|
|
137
|
+
* @param {string} params.orgId The organization id (_id database)
|
|
138
|
+
* @param {string} session The JWT token
|
|
139
|
+
* @return {Promise<object>} The document
|
|
140
|
+
* @public
|
|
141
|
+
* @async
|
|
142
|
+
* @example
|
|
143
|
+
*
|
|
144
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
145
|
+
* const api = new API();
|
|
146
|
+
* const id = '55e4a3bd6be6b45210833fae';
|
|
147
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
148
|
+
* const retDocType = await api.admin.doctypes.findById(id, session);
|
|
149
|
+
*/
|
|
150
|
+
async findById(params, session) {
|
|
151
|
+
const self = this;
|
|
152
|
+
Joi.assert(params, Joi.object().required());
|
|
153
|
+
Joi.assert(params.id, Joi.string().required());
|
|
154
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
155
|
+
Joi.assert(session, Joi.string().required());
|
|
156
|
+
|
|
157
|
+
const {id, orgId} = params;
|
|
158
|
+
const apiCall = self._client.get(`/admin/organizations/${orgId}/orgdoctypes/${id}`, self._setHeader(session));
|
|
159
|
+
return self._returnData(await apiCall);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export default AdminDocTypes;
|
|
164
|
+
</code></pre>
|
|
165
|
+
</article>
|
|
166
|
+
</section>
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<footer class="footer">
|
|
174
|
+
<div class="content has-text-centered">
|
|
175
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
176
|
+
<p class="sidebar-created-by">
|
|
177
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
178
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
179
|
+
</p>
|
|
180
|
+
</div>
|
|
181
|
+
</footer>
|
|
182
|
+
|
|
183
|
+
</div>
|
|
184
|
+
<div id="side-nav" class="side-nav">
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
<script src="scripts/app.min.js"></script>
|
|
188
|
+
<script>PR.prettyPrint();</script>
|
|
189
|
+
<script src="scripts/linenumber.js"> </script>
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
</body>
|
|
193
|
+
</html>
|
|
@@ -0,0 +1,449 @@
|
|
|
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/document.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/document.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 documents, permission admin
|
|
94
|
+
* @class
|
|
95
|
+
*/
|
|
96
|
+
class AdminDocuments {
|
|
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
|
+
throw 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 Advanced search of document in elastic search ussing system manager
|
|
140
|
+
* @param {!object} params - Params to search document
|
|
141
|
+
* @param {!string} params.docId - Document id (_id database)
|
|
142
|
+
* @param {!object} params.query - Query to search in elastic search
|
|
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
|
+
* docId: '5edd11c46b6ce9729c2c297c',
|
|
153
|
+
* query: {
|
|
154
|
+
* "query": {
|
|
155
|
+
* "bool": {
|
|
156
|
+
* "minimum_should_match": 1,
|
|
157
|
+
* "should": [
|
|
158
|
+
* {
|
|
159
|
+
* "match": {
|
|
160
|
+
* "locationText.keyword": {
|
|
161
|
+
* "query": "sao pau"
|
|
162
|
+
* }
|
|
163
|
+
* }
|
|
164
|
+
* },
|
|
165
|
+
* {
|
|
166
|
+
* "wildcard": {
|
|
167
|
+
* "locationText.normalized": "*sao pau*"
|
|
168
|
+
* }
|
|
169
|
+
* }
|
|
170
|
+
* ]
|
|
171
|
+
* }
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
175
|
+
* await api.admin.document.advancedSearch(params, session);
|
|
176
|
+
*/
|
|
177
|
+
async advancedSearch(params, session) {
|
|
178
|
+
const self = this;
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
Joi.assert(params, Joi.object().required(), 'Params to search document');
|
|
182
|
+
Joi.assert(params.docId, Joi.string().required(), 'Document ID');
|
|
183
|
+
Joi.assert(params.query, Joi.object().required(), 'eQuery, query to search document in elastic search');
|
|
184
|
+
Joi.assert(session, Joi.string().required(), 'Session is token JWT');
|
|
185
|
+
|
|
186
|
+
const {docId: docTypeId, query} = params;
|
|
187
|
+
const payload = {docTypeId, query};
|
|
188
|
+
|
|
189
|
+
const apiCall = self._client.post(`/admin/documents/search`, payload, self._setHeader(session));
|
|
190
|
+
return self._returnData(await apiCall);
|
|
191
|
+
} catch (ex) {
|
|
192
|
+
throw ex;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
198
|
+
* @description Get document by id
|
|
199
|
+
* @param {object} params - Params to get document by id
|
|
200
|
+
* @param {string} params.docId - Document id (_id database)
|
|
201
|
+
* @param {string} params.orgId - Organization id (_id database)
|
|
202
|
+
* @param {string} session Session, token JWT
|
|
203
|
+
* @return {Promise}
|
|
204
|
+
* @public
|
|
205
|
+
* @async
|
|
206
|
+
* @example
|
|
207
|
+
*
|
|
208
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
209
|
+
* const api = new API();
|
|
210
|
+
* const params = {
|
|
211
|
+
* docId: '5edd11c46b6ce9729c2c297c',
|
|
212
|
+
* orgId: '55e4a3bd6be6b45210833fae'
|
|
213
|
+
* };
|
|
214
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
215
|
+
* await api.admin.document.findById(params, session);
|
|
216
|
+
*/
|
|
217
|
+
async findById(params, session) {
|
|
218
|
+
const self = this;
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
Joi.assert(params, Joi.object().required(), 'Params to get document by id');
|
|
222
|
+
Joi.assert(params.docId, Joi.string().required(), 'Document id (_id database)');
|
|
223
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
224
|
+
Joi.assert(session, Joi.string().required(), 'Session is token JWT');
|
|
225
|
+
|
|
226
|
+
const {docId, orgId} = params;
|
|
227
|
+
const apiCall = self._client.get(`/admin/organizations/${orgId}/documents/${docId}`, self._setHeader(session));
|
|
228
|
+
return self._returnData(await apiCall);
|
|
229
|
+
} catch (ex) {
|
|
230
|
+
throw ex;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
*
|
|
236
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
237
|
+
* @description Request signed url url to put or get
|
|
238
|
+
* @param {object} params Params to request signed url
|
|
239
|
+
* @param {string} params.methodType Method type HTTP get or put
|
|
240
|
+
* @param {string} params.docId The unique id of the document
|
|
241
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
242
|
+
* @return {Promise<object>} doc Returned document data with the signed url
|
|
243
|
+
* @return {string} doc.docId Document id
|
|
244
|
+
* @return {string} doc.name The name of the document, which is the fileName
|
|
245
|
+
* @return {string} doc.areaId docAreaId of the document
|
|
246
|
+
* @return {string} doc.type the document mimi type
|
|
247
|
+
* @return {string} doc.signedUrl the signed URL to upload
|
|
248
|
+
* @public
|
|
249
|
+
* @async
|
|
250
|
+
* @example
|
|
251
|
+
*
|
|
252
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
253
|
+
* const api = new API();
|
|
254
|
+
* const params - {
|
|
255
|
+
* methodType: 'put',
|
|
256
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
257
|
+
* };
|
|
258
|
+
* const apiKey: '...';
|
|
259
|
+
* const { docId, name, areaId, type, signedUrl } = await api.admin.document.signedUrl(params, apiKey);
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
*
|
|
263
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
264
|
+
* const api = new API();
|
|
265
|
+
* const params - {
|
|
266
|
+
* methodType: 'get',
|
|
267
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
268
|
+
* };
|
|
269
|
+
* const apiKey: '...';
|
|
270
|
+
* const { signedUrl, imageType } = await api.admin.document.signedUrl(params, apiKey);
|
|
271
|
+
*/
|
|
272
|
+
async signedUrl(params = {}, apiKey) {
|
|
273
|
+
|
|
274
|
+
Joi.assert(params, Joi.object().required());
|
|
275
|
+
Joi.assert(params.methodType, Joi.string().required());
|
|
276
|
+
Joi.assert(params.docId, Joi.string().required());
|
|
277
|
+
Joi.assert(apiKey, Joi.string().required());
|
|
278
|
+
|
|
279
|
+
const self = this;
|
|
280
|
+
const { methodType, docId } = params;
|
|
281
|
+
const url = `/api/documents/signedurl?apiKey=${apiKey}&methodType=${methodType}&docId=${docId}`;
|
|
282
|
+
const apiCall = self._client
|
|
283
|
+
.get(url);
|
|
284
|
+
|
|
285
|
+
return self._returnData(await apiCall);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
291
|
+
* @description Update a document content
|
|
292
|
+
* @param {object} params Params to request signed url
|
|
293
|
+
* @param {string} params.content The content text
|
|
294
|
+
* @param {string} params.docId The unique id of the document
|
|
295
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
296
|
+
* @return {Promise<object>} doc Returned document data with the signed url
|
|
297
|
+
* @public
|
|
298
|
+
* @async
|
|
299
|
+
* @example
|
|
300
|
+
*
|
|
301
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
302
|
+
* const api = new API();
|
|
303
|
+
* const params - {
|
|
304
|
+
* content: 'some text...',
|
|
305
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
306
|
+
* };
|
|
307
|
+
* const apiKey: '...';
|
|
308
|
+
* await api.admin.document.updateContent(params, apiKey);
|
|
309
|
+
*/
|
|
310
|
+
async updateContent(params = {}, apiKey) {
|
|
311
|
+
|
|
312
|
+
Joi.assert(params, Joi.object().required());
|
|
313
|
+
Joi.assert(params.content, Joi.string().required());
|
|
314
|
+
Joi.assert(params.docId, Joi.string().required());
|
|
315
|
+
Joi.assert(apiKey, Joi.string().required());
|
|
316
|
+
|
|
317
|
+
const self = this;
|
|
318
|
+
const { content, docId } = params;
|
|
319
|
+
const url = `/api/documents/${docId}/content?apiKey=${apiKey}`;
|
|
320
|
+
const data = { content };
|
|
321
|
+
const apiCall = self._client
|
|
322
|
+
.put(url, data, {
|
|
323
|
+
maxContentLength: Infinity,
|
|
324
|
+
maxBodyLength: Infinity
|
|
325
|
+
});
|
|
326
|
+
return self._returnData(await apiCall);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
*
|
|
331
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
332
|
+
* @description Update a document content
|
|
333
|
+
* @param {object} params Params to request signed url
|
|
334
|
+
* @param {string} params.content The content text
|
|
335
|
+
* @param {string} params.docId The unique id of the document
|
|
336
|
+
* @param {string} params.searchablePDFURL The searchable PDF Url
|
|
337
|
+
* @param {object} params.overlay The overlay information
|
|
338
|
+
* @param {array} params.entities The list of entities extracted from the text
|
|
339
|
+
* @param {object} params.language The language detected
|
|
340
|
+
* @param {string} params.language.name The language name detected
|
|
341
|
+
* @param {string} params.language.confidence The confidence that it is the language
|
|
342
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
343
|
+
* @return {Promise<object>} doc Returned document data with the signed url
|
|
344
|
+
* @public
|
|
345
|
+
* @async
|
|
346
|
+
* @example
|
|
347
|
+
*
|
|
348
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
349
|
+
* const api = new API();
|
|
350
|
+
* const params - {
|
|
351
|
+
* content: 'some text...',
|
|
352
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
353
|
+
* };
|
|
354
|
+
* const apiKey: '...';
|
|
355
|
+
* await api.admin.document.updateContent(params, apiKey);
|
|
356
|
+
*/
|
|
357
|
+
async updateAI(params = {}, apiKey) {
|
|
358
|
+
|
|
359
|
+
Joi.assert(params, Joi.object().required());
|
|
360
|
+
Joi.assert(params.docId, Joi.string().required());
|
|
361
|
+
Joi.assert(apiKey, Joi.string().required());
|
|
362
|
+
|
|
363
|
+
const self = this;
|
|
364
|
+
const { docId } = params;
|
|
365
|
+
delete params.docId;
|
|
366
|
+
const url = `/api/documents/${docId}/ai?apiKey=${apiKey}`;
|
|
367
|
+
const apiCall = self._client
|
|
368
|
+
.put(url, params, {
|
|
369
|
+
maxContentLength: Infinity,
|
|
370
|
+
maxBodyLength: Infinity
|
|
371
|
+
});
|
|
372
|
+
return self._returnData(await apiCall);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
*
|
|
377
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
378
|
+
* @description Get the content of a document
|
|
379
|
+
* @param {object} params Params to request signed url
|
|
380
|
+
* @param {string} params.docId The unique id of the document
|
|
381
|
+
* @param {string} params.page The page, from 0, or 'all' if all pages (the full content)
|
|
382
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
383
|
+
* @return {Promise<object>} data the document content
|
|
384
|
+
* @return {string} data._id the _id of the document
|
|
385
|
+
* @return {string} data.content all the pages or if asked by page, just one page, the one requested
|
|
386
|
+
* @return {string} data.content.TextOverlay the overlay text if requested
|
|
387
|
+
* @return {string} data.content.ParsedText the page text content
|
|
388
|
+
* @return {number} data.total the total number of pages
|
|
389
|
+
* @public
|
|
390
|
+
* @async
|
|
391
|
+
* @example
|
|
392
|
+
*
|
|
393
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
394
|
+
* const api = new API();
|
|
395
|
+
* const params - {
|
|
396
|
+
* page: '0',
|
|
397
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
398
|
+
* };
|
|
399
|
+
* const apiKey: '...';
|
|
400
|
+
* await api.admin.document.getContent(params, apiKey);
|
|
401
|
+
*/
|
|
402
|
+
async getContent(params = {}, apiKey) {
|
|
403
|
+
|
|
404
|
+
Joi.assert(params, Joi.object().required());
|
|
405
|
+
Joi.assert(params.docId, Joi.string().required());
|
|
406
|
+
Joi.assert(params.page, Joi.string().required());
|
|
407
|
+
Joi.assert(apiKey, Joi.string().required());
|
|
408
|
+
|
|
409
|
+
const self = this;
|
|
410
|
+
const { page, docId } = params;
|
|
411
|
+
const url = `/api/documents/${docId}/content/${page}?apiKey=${apiKey}`;
|
|
412
|
+
const apiCall = self._client
|
|
413
|
+
.get(url);
|
|
414
|
+
return self._returnData(await apiCall);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export default AdminDocuments;
|
|
420
|
+
</code></pre>
|
|
421
|
+
</article>
|
|
422
|
+
</section>
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
<footer class="footer">
|
|
430
|
+
<div class="content has-text-centered">
|
|
431
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
432
|
+
<p class="sidebar-created-by">
|
|
433
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
434
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
435
|
+
</p>
|
|
436
|
+
</div>
|
|
437
|
+
</footer>
|
|
438
|
+
|
|
439
|
+
</div>
|
|
440
|
+
<div id="side-nav" class="side-nav">
|
|
441
|
+
</div>
|
|
442
|
+
</div>
|
|
443
|
+
<script src="scripts/app.min.js"></script>
|
|
444
|
+
<script>PR.prettyPrint();</script>
|
|
445
|
+
<script src="scripts/linenumber.js"> </script>
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
</body>
|
|
449
|
+
</html>
|