@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,218 @@
|
|
|
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> dispatch.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>dispatch.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 Joi from 'joi';
|
|
90
|
+
import Axios from 'axios';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @class Api dispatch manager
|
|
94
|
+
*/
|
|
95
|
+
class Dispatch {
|
|
96
|
+
|
|
97
|
+
constructor(options) {
|
|
98
|
+
|
|
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 = Axios.create({baseURL: self.parent.options.uri});
|
|
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
|
+
* Get the URL context
|
|
139
|
+
* @param url {string} Full url
|
|
140
|
+
* @param session {session} Session, token JWT
|
|
141
|
+
* @return {Promise<object>} The full data context of the URL
|
|
142
|
+
* @public
|
|
143
|
+
* @async
|
|
144
|
+
* @example
|
|
145
|
+
*
|
|
146
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
147
|
+
* const api = new API();
|
|
148
|
+
* const retContext = await api.dispatch.getContext('http://myndware.io/login/myorg);
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
async getContext(url, session = null) {
|
|
152
|
+
Joi.assert(url, Joi.string().required());
|
|
153
|
+
|
|
154
|
+
if(url.includes('?')) {
|
|
155
|
+
url = `${url}&json=true`;
|
|
156
|
+
} else {
|
|
157
|
+
url = `${url}?json=true`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const self = this;
|
|
161
|
+
const header = session ? self._setHeader(session) : {};
|
|
162
|
+
const apiCall = self._client.get(url, header);
|
|
163
|
+
return self._returnData(await apiCall);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
168
|
+
* @description Get client Axios
|
|
169
|
+
* @return {promise} return client axios
|
|
170
|
+
* @public
|
|
171
|
+
* @async
|
|
172
|
+
* @example
|
|
173
|
+
*
|
|
174
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
175
|
+
* const api = new API();
|
|
176
|
+
* await api.dispatch.getClient();
|
|
177
|
+
*/
|
|
178
|
+
getClient() {
|
|
179
|
+
try {
|
|
180
|
+
const self = this;
|
|
181
|
+
return self._client;
|
|
182
|
+
} catch (ex) {
|
|
183
|
+
return ex;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export default Dispatch;
|
|
189
|
+
</code></pre>
|
|
190
|
+
</article>
|
|
191
|
+
</section>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<footer class="footer">
|
|
199
|
+
<div class="content has-text-centered">
|
|
200
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
201
|
+
<p class="sidebar-created-by">
|
|
202
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
203
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
204
|
+
</p>
|
|
205
|
+
</div>
|
|
206
|
+
</footer>
|
|
207
|
+
|
|
208
|
+
</div>
|
|
209
|
+
<div id="side-nav" class="side-nav">
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
<script src="scripts/app.min.js"></script>
|
|
213
|
+
<script>PR.prettyPrint();</script>
|
|
214
|
+
<script src="scripts/linenumber.js"> </script>
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
</body>
|
|
218
|
+
</html>
|
|
@@ -0,0 +1,333 @@
|
|
|
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> external.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>external.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
|
+
* Class for documents, permission user
|
|
94
|
+
* @class
|
|
95
|
+
*/
|
|
96
|
+
class External {
|
|
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(authorization) {
|
|
130
|
+
return {
|
|
131
|
+
headers: {
|
|
132
|
+
authorization,
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
139
|
+
* @description Create new document
|
|
140
|
+
* @param {object} params Object for add new document
|
|
141
|
+
* @param {string} params.id Organization form id
|
|
142
|
+
* @return {Promise<object>} data
|
|
143
|
+
* @return {string} _id the id of the form
|
|
144
|
+
* @return {string} orgId the organization id of the form
|
|
145
|
+
* @return {string} authorization the unique token registered internally by the system for all the next calls to the external form APIs
|
|
146
|
+
* The authorization is unique and is ONLY valid for this session.
|
|
147
|
+
* @return {array<object>} groups the form groups to render
|
|
148
|
+
* @public
|
|
149
|
+
* @async
|
|
150
|
+
* @example
|
|
151
|
+
*
|
|
152
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
153
|
+
* const api = new API();
|
|
154
|
+
* const params = {
|
|
155
|
+
* id: '611e679741cc63168c26d7ee'
|
|
156
|
+
* };
|
|
157
|
+
* const retForm = await api.external.context(params);
|
|
158
|
+
*/
|
|
159
|
+
async context(params) {
|
|
160
|
+
const self = this;
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
164
|
+
Joi.assert(params.id, Joi.string().required().error(new Error('organization form id is required')));
|
|
165
|
+
|
|
166
|
+
const { id } = params;
|
|
167
|
+
const apiCall = self._client
|
|
168
|
+
.get(`/component/external/forms/${id}`);
|
|
169
|
+
|
|
170
|
+
return self._returnData(await apiCall);
|
|
171
|
+
} catch (ex) {
|
|
172
|
+
throw ex;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
178
|
+
* @description Get an upload signed url, so it will be possible to upload documents temporarily during the use of the external form
|
|
179
|
+
* @param {string} mime the mime type of the document
|
|
180
|
+
* @param {string} authorization a legal authorization
|
|
181
|
+
* @returns {Promise<object>} doc
|
|
182
|
+
* @returns {string} doc.mime the original mime type of the document
|
|
183
|
+
* @returns {string} doc.signedUrl the signed url to upload the document
|
|
184
|
+
* @returns {string} doc.filename the filename of the uploaded file
|
|
185
|
+
* @returns {string} doc.extension the extension of the filename, obtained from the mime type
|
|
186
|
+
* @public
|
|
187
|
+
* @async
|
|
188
|
+
* @example
|
|
189
|
+
*
|
|
190
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
191
|
+
* const api = new API();
|
|
192
|
+
* const authorization = '...';
|
|
193
|
+
* const doc = {
|
|
194
|
+
* mime: 'application/pdf'
|
|
195
|
+
* };
|
|
196
|
+
* const retDoc = await api.external.getUploadDocumentSignedUrl(doc, authorization);
|
|
197
|
+
*/
|
|
198
|
+
async getUploadDocumentSignedUrl(mime, authorization) {
|
|
199
|
+
const self = this;
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
Joi.assert(mime, Joi.string().required().error(new Error('mime type is required')));
|
|
203
|
+
Joi.assert(authorization, Joi.string().required().error(new Error('authorization is required')));
|
|
204
|
+
|
|
205
|
+
const apiCall = self._client
|
|
206
|
+
.get(`/external/forms/upload/signedurl?mime=${encodeURIComponent(mime)}`, self._setHeader(authorization));
|
|
207
|
+
|
|
208
|
+
return self._returnData(await apiCall);
|
|
209
|
+
} catch (ex) {
|
|
210
|
+
throw ex;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
216
|
+
* @description Get an upload signed url, for many documents. So it will be possible to upload documents temporarily during the use of the external form
|
|
217
|
+
* @param {array<object>} docs the list of documents
|
|
218
|
+
* @param {string} docs.mime the mime type of the document
|
|
219
|
+
* @param {string} authorization a legal authorization
|
|
220
|
+
* @returns {Promise<array>} docs
|
|
221
|
+
* @returns {string} docs.mime the original mime type of the document
|
|
222
|
+
* @returns {string} docs.signedUrl the signed url to upload the document
|
|
223
|
+
* @returns {string} docs.filename the filename of the uploaded file
|
|
224
|
+
* @returns {string} docs.extension the extension of the filename, obtained from the mime type
|
|
225
|
+
* @public
|
|
226
|
+
* @async
|
|
227
|
+
* @example
|
|
228
|
+
*
|
|
229
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
230
|
+
* const api = new API();
|
|
231
|
+
* const authorization = '...';
|
|
232
|
+
* const docs = [
|
|
233
|
+
* {
|
|
234
|
+
* mime: 'application/pdf'
|
|
235
|
+
* }
|
|
236
|
+
* ];
|
|
237
|
+
* const retDocs = await api.external.getUploadDocumentsSignedUrl(docs, authorization);
|
|
238
|
+
*/
|
|
239
|
+
async getUploadDocumentsSignedUrl(docs, authorization) {
|
|
240
|
+
const self = this;
|
|
241
|
+
|
|
242
|
+
try {
|
|
243
|
+
Joi.assert(docs, Joi.array().required().error(new Error('docs is required')));
|
|
244
|
+
Joi.assert(authorization, Joi.string().required().error(new Error('authorization is required')));
|
|
245
|
+
|
|
246
|
+
const apiCall = self._client
|
|
247
|
+
.post(`/external/forms/upload/signedurls`, docs, self._setHeader(authorization));
|
|
248
|
+
|
|
249
|
+
return self._returnData(await apiCall);
|
|
250
|
+
} catch (ex) {
|
|
251
|
+
throw ex;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
257
|
+
* @description Handles the execution of an external form
|
|
258
|
+
* @param {string} authorization a legal authorization
|
|
259
|
+
* @param {object} params the parameters to handle the execution of an external form
|
|
260
|
+
* @param {array<object>} params.payload the payload of the external form. It should represent the form groups of the external form
|
|
261
|
+
* @param {string} params.payload.name the name of the group
|
|
262
|
+
* @param {array<object>} params.payload.fields the fields that belong to each group
|
|
263
|
+
* @param {*|{}} params.payload.fields.value besides all the data inside a field, it should have the value of the the field
|
|
264
|
+
* @returns {Promise<boolean>} true|false if success
|
|
265
|
+
* @public
|
|
266
|
+
* @async
|
|
267
|
+
* @example
|
|
268
|
+
*
|
|
269
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
270
|
+
* const api = new API();
|
|
271
|
+
* const authorization = '...';
|
|
272
|
+
* const params = {
|
|
273
|
+
* payload: [
|
|
274
|
+
* {
|
|
275
|
+
* name: 'My Group One',
|
|
276
|
+
* fields: [
|
|
277
|
+
* {}
|
|
278
|
+
* ]
|
|
279
|
+
* }
|
|
280
|
+
* ]
|
|
281
|
+
* };
|
|
282
|
+
* const success = await api.external.handle(params, authorization);
|
|
283
|
+
*/
|
|
284
|
+
async handle(params, authorization) {
|
|
285
|
+
const self = this;
|
|
286
|
+
|
|
287
|
+
try {
|
|
288
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
289
|
+
Joi.assert(params.payload, Joi.array().required().error(new Error('form payload is required')));
|
|
290
|
+
Joi.assert(authorization, Joi.string().required().error(new Error('authorization is required')));
|
|
291
|
+
|
|
292
|
+
const apiCall = self._client
|
|
293
|
+
.put('/external/forms', params, self._setHeader(authorization));
|
|
294
|
+
|
|
295
|
+
return self._returnData(await apiCall);
|
|
296
|
+
} catch (ex) {
|
|
297
|
+
throw ex;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export default External;
|
|
304
|
+
</code></pre>
|
|
305
|
+
</article>
|
|
306
|
+
</section>
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
<footer class="footer">
|
|
314
|
+
<div class="content has-text-centered">
|
|
315
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
316
|
+
<p class="sidebar-created-by">
|
|
317
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
318
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
319
|
+
</p>
|
|
320
|
+
</div>
|
|
321
|
+
</footer>
|
|
322
|
+
|
|
323
|
+
</div>
|
|
324
|
+
<div id="side-nav" class="side-nav">
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
<script src="scripts/app.min.js"></script>
|
|
328
|
+
<script>PR.prettyPrint();</script>
|
|
329
|
+
<script src="scripts/linenumber.js"> </script>
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
</body>
|
|
333
|
+
</html>
|