@docbrasil/api-systemmanager 1.0.56 → 1.0.57
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/document.js +42 -0
- package/api/user/process.js +18 -1
- package/dist/bundle.cjs +60 -1
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +498 -0
- package/package.json +1 -1
package/api/admin/document.js
CHANGED
|
@@ -285,6 +285,48 @@ class AdminDocuments {
|
|
|
285
285
|
return self._returnData(await apiCall);
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
291
|
+
* @description Get the content of a document
|
|
292
|
+
* @param {object} params Params to request signed url
|
|
293
|
+
* @param {string} params.docId The unique id of the document
|
|
294
|
+
* @param {string} params.page The page, from 0, or 'all' if all pages (the full content)
|
|
295
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
296
|
+
* @return {Promise<object>} data the document content
|
|
297
|
+
* @return {string} data._id the _id of the document
|
|
298
|
+
* @return {string} data.content all the pages or if asked by page, just one page, the one requested
|
|
299
|
+
* @return {string} data.content.TextOverlay the overlay text if requested
|
|
300
|
+
* @return {string} data.content.ParsedText the page text content
|
|
301
|
+
* @return {number} data.total the total number of pages
|
|
302
|
+
* @public
|
|
303
|
+
* @async
|
|
304
|
+
* @example
|
|
305
|
+
*
|
|
306
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
307
|
+
* const api = new API();
|
|
308
|
+
* const params - {
|
|
309
|
+
* page: '0',
|
|
310
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
311
|
+
* };
|
|
312
|
+
* const apiKey: '...';
|
|
313
|
+
* await api.admin.document.getContent(params, apiKey);
|
|
314
|
+
*/
|
|
315
|
+
async getContent(params = {}, apiKey) {
|
|
316
|
+
|
|
317
|
+
Joi.assert(params, Joi.object().required());
|
|
318
|
+
Joi.assert(params.docId, Joi.string().required());
|
|
319
|
+
Joi.assert(params.page, Joi.string().required());
|
|
320
|
+
Joi.assert(apiKey, Joi.string().required());
|
|
321
|
+
|
|
322
|
+
const self = this;
|
|
323
|
+
const { page, docId } = params;
|
|
324
|
+
const url = `/api/documents/${docId}/content/${page}?apiKey=${apiKey}`;
|
|
325
|
+
const apiCall = self._client
|
|
326
|
+
.get(url);
|
|
327
|
+
return self._returnData(await apiCall);
|
|
328
|
+
}
|
|
329
|
+
|
|
288
330
|
}
|
|
289
331
|
|
|
290
332
|
export default AdminDocuments;
|
package/api/user/process.js
CHANGED
|
@@ -47,6 +47,23 @@ class Process {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
52
|
+
* @description Set header for a bigger payload
|
|
53
|
+
* @param {string} session Session, token JWT
|
|
54
|
+
* @return {object} header with new session
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
_setMaxContentHeader(session) {
|
|
58
|
+
return {
|
|
59
|
+
headers: {
|
|
60
|
+
authorization: session,
|
|
61
|
+
maxContentLength: Infinity,
|
|
62
|
+
maxBodyLength: Infinity
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
50
67
|
/**
|
|
51
68
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
52
69
|
* @description Start process
|
|
@@ -81,7 +98,7 @@ class Process {
|
|
|
81
98
|
Joi.assert(session, Joi.string().required());
|
|
82
99
|
|
|
83
100
|
const {processId, orgId, payload = {}} = params;
|
|
84
|
-
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self.
|
|
101
|
+
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self._setMaxContentHeader(session));
|
|
85
102
|
return self._returnData(await apiCall);
|
|
86
103
|
} catch (ex) {
|
|
87
104
|
throw ex;
|
package/dist/bundle.cjs
CHANGED
|
@@ -1330,6 +1330,23 @@ class Process {
|
|
|
1330
1330
|
};
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
|
+
/**
|
|
1334
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1335
|
+
* @description Set header for a bigger payload
|
|
1336
|
+
* @param {string} session Session, token JWT
|
|
1337
|
+
* @return {object} header with new session
|
|
1338
|
+
* @private
|
|
1339
|
+
*/
|
|
1340
|
+
_setMaxContentHeader(session) {
|
|
1341
|
+
return {
|
|
1342
|
+
headers: {
|
|
1343
|
+
authorization: session,
|
|
1344
|
+
maxContentLength: Infinity,
|
|
1345
|
+
maxBodyLength: Infinity
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1333
1350
|
/**
|
|
1334
1351
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1335
1352
|
* @description Start process
|
|
@@ -1364,7 +1381,7 @@ class Process {
|
|
|
1364
1381
|
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
1365
1382
|
|
|
1366
1383
|
const {processId, orgId, payload = {}} = params;
|
|
1367
|
-
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self.
|
|
1384
|
+
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self._setMaxContentHeader(session));
|
|
1368
1385
|
return self._returnData(await apiCall);
|
|
1369
1386
|
} catch (ex) {
|
|
1370
1387
|
throw ex;
|
|
@@ -9024,6 +9041,48 @@ class AdminDocuments {
|
|
|
9024
9041
|
return self._returnData(await apiCall);
|
|
9025
9042
|
}
|
|
9026
9043
|
|
|
9044
|
+
/**
|
|
9045
|
+
*
|
|
9046
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9047
|
+
* @description Get the content of a document
|
|
9048
|
+
* @param {object} params Params to request signed url
|
|
9049
|
+
* @param {string} params.docId The unique id of the document
|
|
9050
|
+
* @param {string} params.page The page, from 0, or 'all' if all pages (the full content)
|
|
9051
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
9052
|
+
* @return {Promise<object>} data the document content
|
|
9053
|
+
* @return {string} data._id the _id of the document
|
|
9054
|
+
* @return {string} data.content all the pages or if asked by page, just one page, the one requested
|
|
9055
|
+
* @return {string} data.content.TextOverlay the overlay text if requested
|
|
9056
|
+
* @return {string} data.content.ParsedText the page text content
|
|
9057
|
+
* @return {number} data.total the total number of pages
|
|
9058
|
+
* @public
|
|
9059
|
+
* @async
|
|
9060
|
+
* @example
|
|
9061
|
+
*
|
|
9062
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9063
|
+
* const api = new API();
|
|
9064
|
+
* const params - {
|
|
9065
|
+
* page: '0',
|
|
9066
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
9067
|
+
* };
|
|
9068
|
+
* const apiKey: '...';
|
|
9069
|
+
* await api.admin.document.getContent(params, apiKey);
|
|
9070
|
+
*/
|
|
9071
|
+
async getContent(params = {}, apiKey) {
|
|
9072
|
+
|
|
9073
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
9074
|
+
Joi__default["default"].assert(params.docId, Joi__default["default"].string().required());
|
|
9075
|
+
Joi__default["default"].assert(params.page, Joi__default["default"].string().required());
|
|
9076
|
+
Joi__default["default"].assert(apiKey, Joi__default["default"].string().required());
|
|
9077
|
+
|
|
9078
|
+
const self = this;
|
|
9079
|
+
const { page, docId } = params;
|
|
9080
|
+
const url = `/api/documents/${docId}/content/${page}?apiKey=${apiKey}`;
|
|
9081
|
+
const apiCall = self._client
|
|
9082
|
+
.get(url);
|
|
9083
|
+
return self._returnData(await apiCall);
|
|
9084
|
+
}
|
|
9085
|
+
|
|
9027
9086
|
}
|
|
9028
9087
|
|
|
9029
9088
|
/**
|