@docbrasil/api-systemmanager 1.0.89 → 1.0.91
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/api/admin/doctypes.js +76 -76
- package/api/admin/document.js +332 -332
- package/api/admin/form.js +151 -151
- package/api/admin/index.js +46 -46
- package/api/admin/list.js +133 -133
- package/api/admin/message.js +194 -194
- package/api/admin/notification.js +233 -233
- package/api/admin/organization.js +124 -124
- package/api/admin/plugin.js +116 -116
- package/api/admin/policy.js +78 -78
- package/api/admin/processes.js +370 -370
- package/api/admin/task.js +125 -125
- package/api/admin/user.js +185 -185
- package/api/dispatch.js +101 -101
- package/api/general/geoLocation.js +88 -88
- package/api/general/index.js +22 -22
- package/api/login.js +267 -267
- package/api/session.js +85 -85
- package/api/user/datasource.js +144 -144
- package/api/user/document.js +730 -730
- package/api/user/index.js +39 -39
- package/api/user/notification.js +101 -101
- package/api/user/organization.js +230 -230
- package/api/user/process.js +191 -191
- package/api/user/register.js +205 -205
- package/api/user/task.js +201 -201
- package/api/user/task_available.js +135 -135
- package/api/user/user.js +287 -287
- package/api/utils/cypher.js +37 -37
- package/api/utils/promises.js +118 -118
- package/bundleRollup.js +158 -158
- package/dist/bundle.cjs +4875 -4875
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +674 -336
- package/doc.md +653 -653
- package/helper/boom.js +487 -487
- package/helper/cryptojs.js +6067 -6067
- package/index.js +85 -85
- package/package-lock.json +4635 -4635
- package/package.json +68 -68
- package/readme.md +25 -25
- package/tests/admin/document.spec.js +45 -45
- package/tests/admin/form.spec.js +74 -74
- package/tests/admin/list.spec.js +86 -86
- package/tests/admin/message.js +92 -92
- package/tests/admin/notification.spec.js +174 -174
- package/tests/admin/pluginspec..js +71 -71
- package/tests/admin/policy.spec.js +71 -71
- package/tests/admin/processes.spec.js +119 -119
- package/tests/admin/users.spec.js +127 -127
- package/tests/documents.spec.js +164 -164
- package/tests/login.spec.js +91 -91
- package/tests/session.spec..js +58 -58
- package/tests/user/documents.js +164 -164
- package/tests/user/organization.js +122 -122
- package/tests/user/process.js +71 -71
- package/tests/user/user.js +88 -88
package/api/session.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import Joi from 'joi';
|
|
3
|
-
import Boom from '@hapi/boom';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @class Session manager of the API
|
|
7
|
-
*/
|
|
8
|
-
class Session {
|
|
9
|
-
|
|
10
|
-
constructor(options) {
|
|
11
|
-
Joi.assert(options, Joi.object().required());
|
|
12
|
-
Joi.assert(options.parent, Joi.object().required());
|
|
13
|
-
|
|
14
|
-
const self = this;
|
|
15
|
-
self._session;
|
|
16
|
-
self._userData;
|
|
17
|
-
|
|
18
|
-
self.parent = options.parent;
|
|
19
|
-
self._client = self.parent.dispatch.getClient();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
24
|
-
* @description Get the return data and check for errors
|
|
25
|
-
* @param {object} retData Response HTTP
|
|
26
|
-
* @return {*}
|
|
27
|
-
* @private
|
|
28
|
-
*/
|
|
29
|
-
_returnData(retData, def = {}) {
|
|
30
|
-
if (retData.status !== 200) {
|
|
31
|
-
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
32
|
-
} else {
|
|
33
|
-
return _.get(retData, 'data', def);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
39
|
-
* @description Set header with new session
|
|
40
|
-
* @param {string} session Session, token JWT
|
|
41
|
-
* @return {object} header with new session
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
_setHeader(session) {
|
|
45
|
-
return {
|
|
46
|
-
headers: {
|
|
47
|
-
authorization: session,
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @description Show information for session, thus validating the session (Valid token JWT)
|
|
54
|
-
* @param {string} sessionId The user session (JWT Token)
|
|
55
|
-
* @param {string} suSessionId=sessionId Given a JWT Token of a SU (SuperAdmin), allow to check session for another user.
|
|
56
|
-
* @return {Promise}
|
|
57
|
-
* @public
|
|
58
|
-
* @async
|
|
59
|
-
* @example
|
|
60
|
-
*
|
|
61
|
-
* const API = require('@docbrasil/api-systemmanager');
|
|
62
|
-
* const api = new API();
|
|
63
|
-
* const sessionId = 'eyJhbFVBBiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
64
|
-
* const suSessionId = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
65
|
-
* await api.session.information(sessionId, suSessionId);
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
async information(sessionId, suSessionId = null) {
|
|
69
|
-
const self = this;
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
Joi.assert(sessionId, Joi.string().required());
|
|
73
|
-
|
|
74
|
-
// if not provided, just use the same sessionId
|
|
75
|
-
suSessionId = suSessionId || sessionId;
|
|
76
|
-
|
|
77
|
-
const apiCall = self._client.get(`session?token=${sessionId}`, self._setHeader(suSessionId));
|
|
78
|
-
return self._returnData(await apiCall);
|
|
79
|
-
} catch (ex) {
|
|
80
|
-
throw ex;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default Session;
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Joi from 'joi';
|
|
3
|
+
import Boom from '@hapi/boom';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @class Session manager of the API
|
|
7
|
+
*/
|
|
8
|
+
class Session {
|
|
9
|
+
|
|
10
|
+
constructor(options) {
|
|
11
|
+
Joi.assert(options, Joi.object().required());
|
|
12
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
13
|
+
|
|
14
|
+
const self = this;
|
|
15
|
+
self._session;
|
|
16
|
+
self._userData;
|
|
17
|
+
|
|
18
|
+
self.parent = options.parent;
|
|
19
|
+
self._client = self.parent.dispatch.getClient();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
24
|
+
* @description Get the return data and check for errors
|
|
25
|
+
* @param {object} retData Response HTTP
|
|
26
|
+
* @return {*}
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
_returnData(retData, def = {}) {
|
|
30
|
+
if (retData.status !== 200) {
|
|
31
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
32
|
+
} else {
|
|
33
|
+
return _.get(retData, 'data', def);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
39
|
+
* @description Set header with new session
|
|
40
|
+
* @param {string} session Session, token JWT
|
|
41
|
+
* @return {object} header with new session
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
_setHeader(session) {
|
|
45
|
+
return {
|
|
46
|
+
headers: {
|
|
47
|
+
authorization: session,
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @description Show information for session, thus validating the session (Valid token JWT)
|
|
54
|
+
* @param {string} sessionId The user session (JWT Token)
|
|
55
|
+
* @param {string} suSessionId=sessionId Given a JWT Token of a SU (SuperAdmin), allow to check session for another user.
|
|
56
|
+
* @return {Promise}
|
|
57
|
+
* @public
|
|
58
|
+
* @async
|
|
59
|
+
* @example
|
|
60
|
+
*
|
|
61
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
62
|
+
* const api = new API();
|
|
63
|
+
* const sessionId = 'eyJhbFVBBiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
64
|
+
* const suSessionId = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
65
|
+
* await api.session.information(sessionId, suSessionId);
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
async information(sessionId, suSessionId = null) {
|
|
69
|
+
const self = this;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
Joi.assert(sessionId, Joi.string().required());
|
|
73
|
+
|
|
74
|
+
// if not provided, just use the same sessionId
|
|
75
|
+
suSessionId = suSessionId || sessionId;
|
|
76
|
+
|
|
77
|
+
const apiCall = self._client.get(`session?token=${sessionId}`, self._setHeader(suSessionId));
|
|
78
|
+
return self._returnData(await apiCall);
|
|
79
|
+
} catch (ex) {
|
|
80
|
+
throw ex;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default Session;
|
package/api/user/datasource.js
CHANGED
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import Boom from '@hapi/boom';
|
|
3
|
-
import Joi from 'joi';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Class for user datasource access, to be used with when creating new documents
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
|
-
class Datasource {
|
|
10
|
-
|
|
11
|
-
constructor(options) {
|
|
12
|
-
Joi.assert(options, Joi.object().required());
|
|
13
|
-
Joi.assert(options.parent, Joi.object().required());
|
|
14
|
-
|
|
15
|
-
const self = this;
|
|
16
|
-
self.parent = options.parent;
|
|
17
|
-
self._client = self.parent.dispatch.getClient();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
22
|
-
* @description Get the return data and check for errors
|
|
23
|
-
* @param {object} retData Response HTTP
|
|
24
|
-
* @return {*}
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
_returnData(retData, def = {}) {
|
|
28
|
-
if (retData.status !== 200) {
|
|
29
|
-
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
30
|
-
} else {
|
|
31
|
-
return _.get(retData, 'data', def);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
37
|
-
* @description Set header with new session
|
|
38
|
-
* @param {string} session Session, token JWT
|
|
39
|
-
* @return {object} header with new session
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
_setHeader(session) {
|
|
43
|
-
return {
|
|
44
|
-
headers: {
|
|
45
|
-
authorization: session,
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
_cleanIdCard(idcard = '') {
|
|
51
|
-
return idcard.replace(/\D+/g,'');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
56
|
-
* @description Method to get autocomplete data from a datasource
|
|
57
|
-
* @param {object} params Params to add notification token
|
|
58
|
-
* @param {string} params.orgId The user organization _id
|
|
59
|
-
* @param {array<object>} params.dataSources The document type data sources information
|
|
60
|
-
* @param {string} params.dataSources._id The document type data sources _id
|
|
61
|
-
* @param {array<object>} params.dataSources.fields The document type data sources list of fields
|
|
62
|
-
* @param {array<object>} params.documents The document list
|
|
63
|
-
* @param {string} params.documents._id The document _id
|
|
64
|
-
* @param {string} session Is token JWT of user NOT allow SU
|
|
65
|
-
* @returns {promise<array>} docs The returned documents field with autocomplete
|
|
66
|
-
* @returns {string} docs._id the _id of the document
|
|
67
|
-
* @returns {object} data.docTypeFieldsData the field values
|
|
68
|
-
* @public
|
|
69
|
-
* @example
|
|
70
|
-
*
|
|
71
|
-
* const API = require('@docbrasil/api-systemmanager');
|
|
72
|
-
* const api = new API();
|
|
73
|
-
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
74
|
-
* const params = {
|
|
75
|
-
* orgId: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
|
|
76
|
-
* dataSources: [{}],
|
|
77
|
-
* documents: [{}]
|
|
78
|
-
* };
|
|
79
|
-
* const retData = await api.user.datasource.autocomplete(params, session);
|
|
80
|
-
*/
|
|
81
|
-
async autocomplete(params = {}, session) {
|
|
82
|
-
const self = this;
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
86
|
-
Joi.assert(params.orgId, Joi.string().required(), 'The organization _id is required');
|
|
87
|
-
Joi.assert(params.dataSources, Joi.array().required(), 'Datasources is required');
|
|
88
|
-
Joi.assert(params.documents, Joi.array().required(), ' Documents is required');
|
|
89
|
-
|
|
90
|
-
const {
|
|
91
|
-
documents = [],
|
|
92
|
-
dataSources = [],
|
|
93
|
-
orgId
|
|
94
|
-
} = params;
|
|
95
|
-
const aDocs = [];
|
|
96
|
-
|
|
97
|
-
for(const doc of documents) {
|
|
98
|
-
const newDoc = { guid: doc._id, dataSources: [] };
|
|
99
|
-
for(const dataSource of dataSources) {
|
|
100
|
-
const clonedDataSource = { _id: dataSource._id, fields: [] };
|
|
101
|
-
const dataSourceFields = dataSource?.fields || [];
|
|
102
|
-
for(const field of dataSourceFields) {
|
|
103
|
-
const newField = {
|
|
104
|
-
associatedFieldName: field.associatedFieldName,
|
|
105
|
-
type: field.type,
|
|
106
|
-
isPK: field.isPK,
|
|
107
|
-
name: field.name
|
|
108
|
-
};
|
|
109
|
-
if(field.isPK) {
|
|
110
|
-
newField.value = _.get(doc, `docTypeFieldsData.${field.associatedFieldName}`);
|
|
111
|
-
if(newField.type === 'Número Inteiro') {
|
|
112
|
-
newField.value = parseInt(newField.value, 10);
|
|
113
|
-
} else if(newField.type === 'Número Duplo') {
|
|
114
|
-
newField.value = parseFloat(newField.value);
|
|
115
|
-
} else if(newField.type === 'CPF') {
|
|
116
|
-
newField.value = self._cleanIdCard(newField.value);
|
|
117
|
-
} else if(newField.type === 'CNPJ') {
|
|
118
|
-
newField.value = self._cleanIdCard(newField.value);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if(_.get(newField, 'value.docTypeFieldsData.docTypeFieldsData')) {
|
|
122
|
-
delete newField.value.docTypeFieldsData.docTypeFieldsData;
|
|
123
|
-
}
|
|
124
|
-
clonedDataSource.fields.push(newField);
|
|
125
|
-
}
|
|
126
|
-
newDoc.dataSources.push(clonedDataSource);
|
|
127
|
-
}
|
|
128
|
-
aDocs.push(newDoc);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const url = `/organizations/${orgId}/documents/datasources/autocomplete`;
|
|
132
|
-
const dataParams = { docs: aDocs };
|
|
133
|
-
const apiCall = self._client
|
|
134
|
-
.post(url, dataParams, self._setHeader(session));
|
|
135
|
-
|
|
136
|
-
const retData = self._returnData(await apiCall);
|
|
137
|
-
return retData;
|
|
138
|
-
} catch (ex) {
|
|
139
|
-
throw ex;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export default Datasource;
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class for user datasource access, to be used with when creating new documents
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class Datasource {
|
|
10
|
+
|
|
11
|
+
constructor(options) {
|
|
12
|
+
Joi.assert(options, Joi.object().required());
|
|
13
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
14
|
+
|
|
15
|
+
const self = this;
|
|
16
|
+
self.parent = options.parent;
|
|
17
|
+
self._client = self.parent.dispatch.getClient();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
22
|
+
* @description Get the return data and check for errors
|
|
23
|
+
* @param {object} retData Response HTTP
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
_returnData(retData, def = {}) {
|
|
28
|
+
if (retData.status !== 200) {
|
|
29
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
30
|
+
} else {
|
|
31
|
+
return _.get(retData, 'data', def);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
37
|
+
* @description Set header with new session
|
|
38
|
+
* @param {string} session Session, token JWT
|
|
39
|
+
* @return {object} header with new session
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
_setHeader(session) {
|
|
43
|
+
return {
|
|
44
|
+
headers: {
|
|
45
|
+
authorization: session,
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_cleanIdCard(idcard = '') {
|
|
51
|
+
return idcard.replace(/\D+/g,'');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
56
|
+
* @description Method to get autocomplete data from a datasource
|
|
57
|
+
* @param {object} params Params to add notification token
|
|
58
|
+
* @param {string} params.orgId The user organization _id
|
|
59
|
+
* @param {array<object>} params.dataSources The document type data sources information
|
|
60
|
+
* @param {string} params.dataSources._id The document type data sources _id
|
|
61
|
+
* @param {array<object>} params.dataSources.fields The document type data sources list of fields
|
|
62
|
+
* @param {array<object>} params.documents The document list
|
|
63
|
+
* @param {string} params.documents._id The document _id
|
|
64
|
+
* @param {string} session Is token JWT of user NOT allow SU
|
|
65
|
+
* @returns {promise<array>} docs The returned documents field with autocomplete
|
|
66
|
+
* @returns {string} docs._id the _id of the document
|
|
67
|
+
* @returns {object} data.docTypeFieldsData the field values
|
|
68
|
+
* @public
|
|
69
|
+
* @example
|
|
70
|
+
*
|
|
71
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
72
|
+
* const api = new API();
|
|
73
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
74
|
+
* const params = {
|
|
75
|
+
* orgId: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
|
|
76
|
+
* dataSources: [{}],
|
|
77
|
+
* documents: [{}]
|
|
78
|
+
* };
|
|
79
|
+
* const retData = await api.user.datasource.autocomplete(params, session);
|
|
80
|
+
*/
|
|
81
|
+
async autocomplete(params = {}, session) {
|
|
82
|
+
const self = this;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
86
|
+
Joi.assert(params.orgId, Joi.string().required(), 'The organization _id is required');
|
|
87
|
+
Joi.assert(params.dataSources, Joi.array().required(), 'Datasources is required');
|
|
88
|
+
Joi.assert(params.documents, Joi.array().required(), ' Documents is required');
|
|
89
|
+
|
|
90
|
+
const {
|
|
91
|
+
documents = [],
|
|
92
|
+
dataSources = [],
|
|
93
|
+
orgId
|
|
94
|
+
} = params;
|
|
95
|
+
const aDocs = [];
|
|
96
|
+
|
|
97
|
+
for(const doc of documents) {
|
|
98
|
+
const newDoc = { guid: doc._id, dataSources: [] };
|
|
99
|
+
for(const dataSource of dataSources) {
|
|
100
|
+
const clonedDataSource = { _id: dataSource._id, fields: [] };
|
|
101
|
+
const dataSourceFields = dataSource?.fields || [];
|
|
102
|
+
for(const field of dataSourceFields) {
|
|
103
|
+
const newField = {
|
|
104
|
+
associatedFieldName: field.associatedFieldName,
|
|
105
|
+
type: field.type,
|
|
106
|
+
isPK: field.isPK,
|
|
107
|
+
name: field.name
|
|
108
|
+
};
|
|
109
|
+
if(field.isPK) {
|
|
110
|
+
newField.value = _.get(doc, `docTypeFieldsData.${field.associatedFieldName}`);
|
|
111
|
+
if(newField.type === 'Número Inteiro') {
|
|
112
|
+
newField.value = parseInt(newField.value, 10);
|
|
113
|
+
} else if(newField.type === 'Número Duplo') {
|
|
114
|
+
newField.value = parseFloat(newField.value);
|
|
115
|
+
} else if(newField.type === 'CPF') {
|
|
116
|
+
newField.value = self._cleanIdCard(newField.value);
|
|
117
|
+
} else if(newField.type === 'CNPJ') {
|
|
118
|
+
newField.value = self._cleanIdCard(newField.value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if(_.get(newField, 'value.docTypeFieldsData.docTypeFieldsData')) {
|
|
122
|
+
delete newField.value.docTypeFieldsData.docTypeFieldsData;
|
|
123
|
+
}
|
|
124
|
+
clonedDataSource.fields.push(newField);
|
|
125
|
+
}
|
|
126
|
+
newDoc.dataSources.push(clonedDataSource);
|
|
127
|
+
}
|
|
128
|
+
aDocs.push(newDoc);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const url = `/organizations/${orgId}/documents/datasources/autocomplete`;
|
|
132
|
+
const dataParams = { docs: aDocs };
|
|
133
|
+
const apiCall = self._client
|
|
134
|
+
.post(url, dataParams, self._setHeader(session));
|
|
135
|
+
|
|
136
|
+
const retData = self._returnData(await apiCall);
|
|
137
|
+
return retData;
|
|
138
|
+
} catch (ex) {
|
|
139
|
+
throw ex;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export default Datasource;
|