@docbrasil/api-systemmanager 1.0.98 → 1.0.99
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/external.js +1 -1
- package/dist/bundle.cjs +82 -3
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
package/api/external.js
CHANGED
package/dist/bundle.cjs
CHANGED
|
@@ -559,7 +559,7 @@ class Users$1 {
|
|
|
559
559
|
* Class for documents, permission user
|
|
560
560
|
* @class
|
|
561
561
|
*/
|
|
562
|
-
class Documents
|
|
562
|
+
class Documents {
|
|
563
563
|
|
|
564
564
|
constructor(options) {
|
|
565
565
|
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
@@ -9481,7 +9481,7 @@ class Users {
|
|
|
9481
9481
|
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
9482
9482
|
|
|
9483
9483
|
const self = this;
|
|
9484
|
-
self.document = new Documents
|
|
9484
|
+
self.document = new Documents(options);
|
|
9485
9485
|
self.datasource = new Datasource(options);
|
|
9486
9486
|
self.organization = new Organization$1(options);
|
|
9487
9487
|
self.process = new Process(options);
|
|
@@ -11578,7 +11578,86 @@ class Admin {
|
|
|
11578
11578
|
}
|
|
11579
11579
|
}
|
|
11580
11580
|
|
|
11581
|
-
|
|
11581
|
+
/**
|
|
11582
|
+
* Class for documents, permission user
|
|
11583
|
+
* @class
|
|
11584
|
+
*/
|
|
11585
|
+
class External {
|
|
11586
|
+
|
|
11587
|
+
constructor(options) {
|
|
11588
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
11589
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
11590
|
+
|
|
11591
|
+
const self = this;
|
|
11592
|
+
self.parent = options.parent;
|
|
11593
|
+
self._client = self.parent.dispatch.getClient();
|
|
11594
|
+
}
|
|
11595
|
+
|
|
11596
|
+
/**
|
|
11597
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
11598
|
+
* @description Get the return data and check for errors
|
|
11599
|
+
* @param {object} retData Response HTTP
|
|
11600
|
+
* @return {*}
|
|
11601
|
+
* @private
|
|
11602
|
+
*/
|
|
11603
|
+
_returnData(retData, def = {}) {
|
|
11604
|
+
if (retData.status !== 200) {
|
|
11605
|
+
throw Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
11606
|
+
} else {
|
|
11607
|
+
return ___default["default"].get(retData, 'data', def);
|
|
11608
|
+
}
|
|
11609
|
+
}
|
|
11610
|
+
|
|
11611
|
+
/**
|
|
11612
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
11613
|
+
* @description Set header with new session
|
|
11614
|
+
* @param {string} session Session, token JWT
|
|
11615
|
+
* @return {object} header with new session
|
|
11616
|
+
* @private
|
|
11617
|
+
*/
|
|
11618
|
+
_setHeader(session) {
|
|
11619
|
+
return {
|
|
11620
|
+
headers: {
|
|
11621
|
+
authorization: session,
|
|
11622
|
+
}
|
|
11623
|
+
};
|
|
11624
|
+
}
|
|
11625
|
+
|
|
11626
|
+
/**
|
|
11627
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
11628
|
+
* @description Create new document
|
|
11629
|
+
* @param {object} params Object for add new document
|
|
11630
|
+
* @param {string} params.id Organization form id
|
|
11631
|
+
* @return {Promise<object>}
|
|
11632
|
+
* @public
|
|
11633
|
+
* @async
|
|
11634
|
+
* @example
|
|
11635
|
+
*
|
|
11636
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
11637
|
+
* const api = new API();
|
|
11638
|
+
* const params = {
|
|
11639
|
+
* id: 'cloundbrasil'
|
|
11640
|
+
* };
|
|
11641
|
+
* const retForm = await api.external.context(params);
|
|
11642
|
+
*/
|
|
11643
|
+
async context(params) {
|
|
11644
|
+
const self = this;
|
|
11645
|
+
|
|
11646
|
+
try {
|
|
11647
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
11648
|
+
Joi__default["default"].assert(params.id, Joi__default["default"].string().required().error(new Error('organization form id is required')));
|
|
11649
|
+
|
|
11650
|
+
const { id } = params;
|
|
11651
|
+
const apiCall = self._client
|
|
11652
|
+
.get(`/component/external/forms/${id}`);
|
|
11653
|
+
|
|
11654
|
+
return self._returnData(await apiCall);
|
|
11655
|
+
} catch (ex) {
|
|
11656
|
+
throw ex;
|
|
11657
|
+
}
|
|
11658
|
+
}
|
|
11659
|
+
|
|
11660
|
+
}
|
|
11582
11661
|
|
|
11583
11662
|
/**
|
|
11584
11663
|
* Class API
|