@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,111 @@
|
|
|
1
|
+
/* JSDoc prettify.js theme */
|
|
2
|
+
|
|
3
|
+
/* plain text */
|
|
4
|
+
.pln {
|
|
5
|
+
color: #000000;
|
|
6
|
+
font-weight: normal;
|
|
7
|
+
font-style: normal;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* string content */
|
|
11
|
+
.str {
|
|
12
|
+
color: #006400;
|
|
13
|
+
font-weight: normal;
|
|
14
|
+
font-style: normal;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* a keyword */
|
|
18
|
+
.kwd {
|
|
19
|
+
color: #000000;
|
|
20
|
+
font-weight: bold;
|
|
21
|
+
font-style: normal;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* a comment */
|
|
25
|
+
.com {
|
|
26
|
+
font-weight: normal;
|
|
27
|
+
font-style: italic;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* a type name */
|
|
31
|
+
.typ {
|
|
32
|
+
color: #000000;
|
|
33
|
+
font-weight: normal;
|
|
34
|
+
font-style: normal;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* a literal value */
|
|
38
|
+
.lit {
|
|
39
|
+
color: #006400;
|
|
40
|
+
font-weight: normal;
|
|
41
|
+
font-style: normal;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* punctuation */
|
|
45
|
+
.pun {
|
|
46
|
+
color: #000000;
|
|
47
|
+
font-weight: bold;
|
|
48
|
+
font-style: normal;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* lisp open bracket */
|
|
52
|
+
.opn {
|
|
53
|
+
color: #000000;
|
|
54
|
+
font-weight: bold;
|
|
55
|
+
font-style: normal;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* lisp close bracket */
|
|
59
|
+
.clo {
|
|
60
|
+
color: #000000;
|
|
61
|
+
font-weight: bold;
|
|
62
|
+
font-style: normal;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* a markup tag name */
|
|
66
|
+
.tag {
|
|
67
|
+
color: #006400;
|
|
68
|
+
font-weight: normal;
|
|
69
|
+
font-style: normal;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* a markup attribute name */
|
|
73
|
+
.atn {
|
|
74
|
+
color: #006400;
|
|
75
|
+
font-weight: normal;
|
|
76
|
+
font-style: normal;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* a markup attribute value */
|
|
80
|
+
.atv {
|
|
81
|
+
color: #006400;
|
|
82
|
+
font-weight: normal;
|
|
83
|
+
font-style: normal;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* a declaration */
|
|
87
|
+
.dec {
|
|
88
|
+
color: #000000;
|
|
89
|
+
font-weight: bold;
|
|
90
|
+
font-style: normal;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* a variable name */
|
|
94
|
+
.var {
|
|
95
|
+
color: #000000;
|
|
96
|
+
font-weight: normal;
|
|
97
|
+
font-style: normal;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* a function name */
|
|
101
|
+
.fun {
|
|
102
|
+
color: #000000;
|
|
103
|
+
font-weight: bold;
|
|
104
|
+
font-style: normal;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Specify class=linenums on a pre to get line numbering */
|
|
108
|
+
ol.linenums {
|
|
109
|
+
margin-top: 0;
|
|
110
|
+
margin-bottom: 0;
|
|
111
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* Tomorrow Theme */
|
|
2
|
+
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
|
3
|
+
/* Pretty printing styles. Used with prettify.js. */
|
|
4
|
+
/* SPAN elements with the classes below are added by prettyprint. */
|
|
5
|
+
/* plain text */
|
|
6
|
+
.pln {
|
|
7
|
+
color: #4d4d4c; }
|
|
8
|
+
|
|
9
|
+
@media screen {
|
|
10
|
+
/* string content */
|
|
11
|
+
.str {
|
|
12
|
+
color: #718c00; }
|
|
13
|
+
|
|
14
|
+
/* a keyword */
|
|
15
|
+
.kwd {
|
|
16
|
+
color: #8959a8; }
|
|
17
|
+
|
|
18
|
+
/* a comment */
|
|
19
|
+
.com {
|
|
20
|
+
color: #8e908c; }
|
|
21
|
+
|
|
22
|
+
/* a type name */
|
|
23
|
+
.typ {
|
|
24
|
+
color: #4271ae; }
|
|
25
|
+
|
|
26
|
+
/* a literal value */
|
|
27
|
+
.lit {
|
|
28
|
+
color: #f5871f; }
|
|
29
|
+
|
|
30
|
+
/* punctuation */
|
|
31
|
+
.pun {
|
|
32
|
+
color: #4d4d4c; }
|
|
33
|
+
|
|
34
|
+
/* lisp open bracket */
|
|
35
|
+
.opn {
|
|
36
|
+
color: #4d4d4c; }
|
|
37
|
+
|
|
38
|
+
/* lisp close bracket */
|
|
39
|
+
.clo {
|
|
40
|
+
color: #4d4d4c; }
|
|
41
|
+
|
|
42
|
+
/* a markup tag name */
|
|
43
|
+
.tag {
|
|
44
|
+
color: #c82829; }
|
|
45
|
+
|
|
46
|
+
/* a markup attribute name */
|
|
47
|
+
.atn {
|
|
48
|
+
color: #f5871f; }
|
|
49
|
+
|
|
50
|
+
/* a markup attribute value */
|
|
51
|
+
.atv {
|
|
52
|
+
color: #3e999f; }
|
|
53
|
+
|
|
54
|
+
/* a declaration */
|
|
55
|
+
.dec {
|
|
56
|
+
color: #f5871f; }
|
|
57
|
+
|
|
58
|
+
/* a variable name */
|
|
59
|
+
.var {
|
|
60
|
+
color: #c82829; }
|
|
61
|
+
|
|
62
|
+
/* a function name */
|
|
63
|
+
.fun {
|
|
64
|
+
color: #4271ae; } }
|
|
65
|
+
/* Use higher contrast and text-weight for printable form. */
|
|
66
|
+
@media print, projection {
|
|
67
|
+
.str {
|
|
68
|
+
color: #060; }
|
|
69
|
+
|
|
70
|
+
.kwd {
|
|
71
|
+
color: #006;
|
|
72
|
+
font-weight: bold; }
|
|
73
|
+
|
|
74
|
+
.com {
|
|
75
|
+
color: #600;
|
|
76
|
+
font-style: italic; }
|
|
77
|
+
|
|
78
|
+
.typ {
|
|
79
|
+
color: #404;
|
|
80
|
+
font-weight: bold; }
|
|
81
|
+
|
|
82
|
+
.lit {
|
|
83
|
+
color: #044; }
|
|
84
|
+
|
|
85
|
+
.pun, .opn, .clo {
|
|
86
|
+
color: #440; }
|
|
87
|
+
|
|
88
|
+
.tag {
|
|
89
|
+
color: #006;
|
|
90
|
+
font-weight: bold; }
|
|
91
|
+
|
|
92
|
+
.atn {
|
|
93
|
+
color: #404; }
|
|
94
|
+
|
|
95
|
+
.atv {
|
|
96
|
+
color: #060; } }
|
|
97
|
+
/* Style */
|
|
98
|
+
/*
|
|
99
|
+
pre.prettyprint {
|
|
100
|
+
background: white;
|
|
101
|
+
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
|
102
|
+
font-size: 12px;
|
|
103
|
+
line-height: 1.5;
|
|
104
|
+
border: 1px solid #ccc;
|
|
105
|
+
padding: 10px; }
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/* Specify class=linenums on a pre to get line numbering */
|
|
109
|
+
ol.linenums {
|
|
110
|
+
margin-top: 0;
|
|
111
|
+
margin-bottom: 0; }
|
|
112
|
+
|
|
113
|
+
/* IE indents via margin-left */
|
|
114
|
+
li.L0,
|
|
115
|
+
li.L1,
|
|
116
|
+
li.L2,
|
|
117
|
+
li.L3,
|
|
118
|
+
li.L4,
|
|
119
|
+
li.L5,
|
|
120
|
+
li.L6,
|
|
121
|
+
li.L7,
|
|
122
|
+
li.L8,
|
|
123
|
+
li.L9 {
|
|
124
|
+
/* */ }
|
|
125
|
+
|
|
126
|
+
/* Alternate shading for lines */
|
|
127
|
+
li.L1,
|
|
128
|
+
li.L3,
|
|
129
|
+
li.L5,
|
|
130
|
+
li.L7,
|
|
131
|
+
li.L9 {
|
|
132
|
+
/* */ }
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* reset css */
|
|
2
|
+
html, body, div, span, applet, object, iframe,
|
|
3
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
4
|
+
a, abbr, acronym, address, big, cite, code,
|
|
5
|
+
del, dfn, em, img, ins, kbd, q, s, samp,
|
|
6
|
+
small, strike, strong, sub, sup, tt, var,
|
|
7
|
+
b, u, i, center,
|
|
8
|
+
dl, dt, dd, ol, ul, li,
|
|
9
|
+
fieldset, form, label, legend,
|
|
10
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
|
11
|
+
article, aside, canvas, details, embed,
|
|
12
|
+
figure, figcaption, footer, header, hgroup,
|
|
13
|
+
menu, nav, output, ruby, section, summary,
|
|
14
|
+
time, mark, audio, video {
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
border: 0;
|
|
18
|
+
font-size: 100%;
|
|
19
|
+
font: inherit;
|
|
20
|
+
vertical-align: baseline;
|
|
21
|
+
}
|
|
22
|
+
/* HTML5 display-role reset for older browsers */
|
|
23
|
+
article, aside, details, figcaption, figure,
|
|
24
|
+
footer, header, hgroup, menu, nav, section {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
body {
|
|
28
|
+
line-height: 1;
|
|
29
|
+
}
|
|
30
|
+
ol, ul {
|
|
31
|
+
list-style: none;
|
|
32
|
+
}
|
|
33
|
+
blockquote, q {
|
|
34
|
+
quotes: none;
|
|
35
|
+
}
|
|
36
|
+
blockquote:before, blockquote:after,
|
|
37
|
+
q:before, q:after {
|
|
38
|
+
content: '';
|
|
39
|
+
content: none;
|
|
40
|
+
}
|
|
41
|
+
table {
|
|
42
|
+
border-collapse: collapse;
|
|
43
|
+
border-spacing: 0;
|
|
44
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
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> user/datasource.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>user/datasource.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 user datasource access, to be used with when creating new documents
|
|
94
|
+
* @class
|
|
95
|
+
*/
|
|
96
|
+
class Datasource {
|
|
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
|
+
_cleanIdCard(idcard = '') {
|
|
138
|
+
return idcard.replace(/\D+/g,'');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
143
|
+
* @description Method to get autocomplete data from a datasource
|
|
144
|
+
* @param {object} params Params to add notification token
|
|
145
|
+
* @param {string} params.orgId The user organization _id
|
|
146
|
+
* @param {array<object>} params.dataSources The document type data sources information
|
|
147
|
+
* @param {string} params.dataSources._id The document type data sources _id
|
|
148
|
+
* @param {array<object>} params.dataSources.fields The document type data sources list of fields
|
|
149
|
+
* @param {array<object>} params.documents The document list
|
|
150
|
+
* @param {string} params.documents._id The document _id
|
|
151
|
+
* @param {string} session Is token JWT of user NOT allow SU
|
|
152
|
+
* @returns {promise<array>} docs The returned documents field with autocomplete
|
|
153
|
+
* @returns {string} docs._id the _id of the document
|
|
154
|
+
* @returns {object} data.docTypeFieldsData the field values
|
|
155
|
+
* @public
|
|
156
|
+
* @example
|
|
157
|
+
*
|
|
158
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
159
|
+
* const api = new API();
|
|
160
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
161
|
+
* const params = {
|
|
162
|
+
* orgId: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
|
|
163
|
+
* dataSources: [{}],
|
|
164
|
+
* documents: [{}]
|
|
165
|
+
* };
|
|
166
|
+
* const retData = await api.user.datasource.autocomplete(params, session);
|
|
167
|
+
*/
|
|
168
|
+
async autocomplete(params = {}, session) {
|
|
169
|
+
const self = this;
|
|
170
|
+
|
|
171
|
+
try {
|
|
172
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
173
|
+
Joi.assert(params.orgId, Joi.string().required(), 'The organization _id is required');
|
|
174
|
+
Joi.assert(params.dataSources, Joi.array().required(), 'Datasources is required');
|
|
175
|
+
Joi.assert(params.documents, Joi.array().required(), ' Documents is required');
|
|
176
|
+
|
|
177
|
+
const {
|
|
178
|
+
documents = [],
|
|
179
|
+
dataSources = [],
|
|
180
|
+
orgId
|
|
181
|
+
} = params;
|
|
182
|
+
const aDocs = [];
|
|
183
|
+
|
|
184
|
+
for(const doc of documents) {
|
|
185
|
+
const newDoc = { guid: doc._id, dataSources: [] };
|
|
186
|
+
for(const dataSource of dataSources) {
|
|
187
|
+
const clonedDataSource = { _id: dataSource._id, fields: [] };
|
|
188
|
+
const dataSourceFields = dataSource?.fields || [];
|
|
189
|
+
for(const field of dataSourceFields) {
|
|
190
|
+
const newField = {
|
|
191
|
+
associatedFieldName: field.associatedFieldName,
|
|
192
|
+
type: field.type,
|
|
193
|
+
isPK: field.isPK,
|
|
194
|
+
name: field.name
|
|
195
|
+
};
|
|
196
|
+
if(field.isPK) {
|
|
197
|
+
newField.value = _.get(doc, `docTypeFieldsData.${field.associatedFieldName}`);
|
|
198
|
+
if(newField.type === 'Número Inteiro') {
|
|
199
|
+
newField.value = parseInt(newField.value, 10);
|
|
200
|
+
} else if(newField.type === 'Número Duplo') {
|
|
201
|
+
newField.value = parseFloat(newField.value);
|
|
202
|
+
} else if(newField.type === 'CPF') {
|
|
203
|
+
newField.value = self._cleanIdCard(newField.value);
|
|
204
|
+
} else if(newField.type === 'CNPJ') {
|
|
205
|
+
newField.value = self._cleanIdCard(newField.value);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if(_.get(newField, 'value.docTypeFieldsData.docTypeFieldsData')) {
|
|
209
|
+
delete newField.value.docTypeFieldsData.docTypeFieldsData;
|
|
210
|
+
}
|
|
211
|
+
clonedDataSource.fields.push(newField);
|
|
212
|
+
}
|
|
213
|
+
newDoc.dataSources.push(clonedDataSource);
|
|
214
|
+
}
|
|
215
|
+
aDocs.push(newDoc);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const url = `/organizations/${orgId}/documents/datasources/autocomplete`;
|
|
219
|
+
const dataParams = { docs: aDocs };
|
|
220
|
+
const apiCall = self._client
|
|
221
|
+
.post(url, dataParams, self._setHeader(session));
|
|
222
|
+
|
|
223
|
+
const retData = self._returnData(await apiCall);
|
|
224
|
+
return retData;
|
|
225
|
+
} catch (ex) {
|
|
226
|
+
throw ex;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default Datasource;
|
|
232
|
+
</code></pre>
|
|
233
|
+
</article>
|
|
234
|
+
</section>
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<footer class="footer">
|
|
242
|
+
<div class="content has-text-centered">
|
|
243
|
+
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
|
|
244
|
+
<p class="sidebar-created-by">
|
|
245
|
+
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
|
246
|
+
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
|
247
|
+
</p>
|
|
248
|
+
</div>
|
|
249
|
+
</footer>
|
|
250
|
+
|
|
251
|
+
</div>
|
|
252
|
+
<div id="side-nav" class="side-nav">
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
<script src="scripts/app.min.js"></script>
|
|
256
|
+
<script>PR.prettyPrint();</script>
|
|
257
|
+
<script src="scripts/linenumber.js"> </script>
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
</body>
|
|
261
|
+
</html>
|