@docbrasil/api-systemmanager 1.0.100 → 1.0.101
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 +43 -3
- package/dist/bundle.cjs +43 -3
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
package/api/external.js
CHANGED
|
@@ -39,10 +39,10 @@ class External {
|
|
|
39
39
|
* @return {object} header with new session
|
|
40
40
|
* @private
|
|
41
41
|
*/
|
|
42
|
-
_setHeader(
|
|
42
|
+
_setHeader(responseToken) {
|
|
43
43
|
return {
|
|
44
44
|
headers: {
|
|
45
|
-
|
|
45
|
+
responseToken,
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
}
|
|
@@ -65,7 +65,7 @@ class External {
|
|
|
65
65
|
* const API = require('@docbrasil/api-systemmanager');
|
|
66
66
|
* const api = new API();
|
|
67
67
|
* const params = {
|
|
68
|
-
* id: '
|
|
68
|
+
* id: '611e679741cc63168c26d7ee'
|
|
69
69
|
* };
|
|
70
70
|
* const retForm = await api.external.context(params);
|
|
71
71
|
*/
|
|
@@ -86,6 +86,46 @@ class External {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
91
|
+
* @description Get an upload signed url, so it will be possible to upload documents temporarily during the use of the external form
|
|
92
|
+
* @param {object} doc the document we are doing the upload to the temporary area
|
|
93
|
+
* @param {string} doc.mime the mime type of the document
|
|
94
|
+
* @param {string} responseToken a legal responseToken
|
|
95
|
+
* @returns {Promise<object>} doc
|
|
96
|
+
* @returns {string} doc.mime the original mime type of the document
|
|
97
|
+
* @returns {string} doc.signedUrl the signed url to upload the document
|
|
98
|
+
* @returns {string} doc.filename the filename of the uploaded file
|
|
99
|
+
* @returns {string} doc.extension the extension of the filename, obtained from the mime type
|
|
100
|
+
* @public
|
|
101
|
+
* @async
|
|
102
|
+
* @example
|
|
103
|
+
*
|
|
104
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
105
|
+
* const api = new API();
|
|
106
|
+
* const responseToken = '...';
|
|
107
|
+
* const doc = {
|
|
108
|
+
* mime: 'application/pdf'
|
|
109
|
+
* };
|
|
110
|
+
* const retDoc = await api.external.getUploadDocumentSignedUrl(doc, responseToken);
|
|
111
|
+
*/
|
|
112
|
+
async getUploadDocumentSignedUrl(doc, responseToken) {
|
|
113
|
+
const self = this;
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
Joi.assert(doc, Joi.object().required().error(new Error('doc is required')));
|
|
117
|
+
Joi.assert(doc.mime, Joi.string().required().error(new Error('mime type is required')));
|
|
118
|
+
Joi.assert(responseToken, Joi.string().required().error(new Error('responseToken is required')));
|
|
119
|
+
|
|
120
|
+
const apiCall = self._client
|
|
121
|
+
.post('/external/forms/upload/signedurl', { doc }, self._setHeader(responseToken));
|
|
122
|
+
|
|
123
|
+
return self._returnData(await apiCall);
|
|
124
|
+
} catch (ex) {
|
|
125
|
+
throw ex;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
89
129
|
}
|
|
90
130
|
|
|
91
131
|
export default External;
|
package/dist/bundle.cjs
CHANGED
|
@@ -11615,10 +11615,10 @@ class External {
|
|
|
11615
11615
|
* @return {object} header with new session
|
|
11616
11616
|
* @private
|
|
11617
11617
|
*/
|
|
11618
|
-
_setHeader(
|
|
11618
|
+
_setHeader(responseToken) {
|
|
11619
11619
|
return {
|
|
11620
11620
|
headers: {
|
|
11621
|
-
|
|
11621
|
+
responseToken,
|
|
11622
11622
|
}
|
|
11623
11623
|
};
|
|
11624
11624
|
}
|
|
@@ -11641,7 +11641,7 @@ class External {
|
|
|
11641
11641
|
* const API = require('@docbrasil/api-systemmanager');
|
|
11642
11642
|
* const api = new API();
|
|
11643
11643
|
* const params = {
|
|
11644
|
-
* id: '
|
|
11644
|
+
* id: '611e679741cc63168c26d7ee'
|
|
11645
11645
|
* };
|
|
11646
11646
|
* const retForm = await api.external.context(params);
|
|
11647
11647
|
*/
|
|
@@ -11662,6 +11662,46 @@ class External {
|
|
|
11662
11662
|
}
|
|
11663
11663
|
}
|
|
11664
11664
|
|
|
11665
|
+
/**
|
|
11666
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
11667
|
+
* @description Get an upload signed url, so it will be possible to upload documents temporarily during the use of the external form
|
|
11668
|
+
* @param {object} doc the document we are doing the upload to the temporary area
|
|
11669
|
+
* @param {string} doc.mime the mime type of the document
|
|
11670
|
+
* @param {string} responseToken a legal responseToken
|
|
11671
|
+
* @returns {Promise<object>} doc
|
|
11672
|
+
* @returns {string} doc.mime the original mime type of the document
|
|
11673
|
+
* @returns {string} doc.signedUrl the signed url to upload the document
|
|
11674
|
+
* @returns {string} doc.filename the filename of the uploaded file
|
|
11675
|
+
* @returns {string} doc.extension the extension of the filename, obtained from the mime type
|
|
11676
|
+
* @public
|
|
11677
|
+
* @async
|
|
11678
|
+
* @example
|
|
11679
|
+
*
|
|
11680
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
11681
|
+
* const api = new API();
|
|
11682
|
+
* const responseToken = '...';
|
|
11683
|
+
* const doc = {
|
|
11684
|
+
* mime: 'application/pdf'
|
|
11685
|
+
* };
|
|
11686
|
+
* const retDoc = await api.external.getUploadDocumentSignedUrl(doc, responseToken);
|
|
11687
|
+
*/
|
|
11688
|
+
async getUploadDocumentSignedUrl(doc, responseToken) {
|
|
11689
|
+
const self = this;
|
|
11690
|
+
|
|
11691
|
+
try {
|
|
11692
|
+
Joi__default["default"].assert(doc, Joi__default["default"].object().required().error(new Error('doc is required')));
|
|
11693
|
+
Joi__default["default"].assert(doc.mime, Joi__default["default"].string().required().error(new Error('mime type is required')));
|
|
11694
|
+
Joi__default["default"].assert(responseToken, Joi__default["default"].string().required().error(new Error('responseToken is required')));
|
|
11695
|
+
|
|
11696
|
+
const apiCall = self._client
|
|
11697
|
+
.post('/external/forms/upload/signedurl', { doc }, self._setHeader(responseToken));
|
|
11698
|
+
|
|
11699
|
+
return self._returnData(await apiCall);
|
|
11700
|
+
} catch (ex) {
|
|
11701
|
+
throw ex;
|
|
11702
|
+
}
|
|
11703
|
+
}
|
|
11704
|
+
|
|
11665
11705
|
}
|
|
11666
11706
|
|
|
11667
11707
|
/**
|