@docbrasil/api-systemmanager 1.0.50 → 1.0.54
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/document.js +2 -2
- package/api/user/organization.js +0 -10
- package/api/utils/promises.js +2 -2
- package/bundleRollup.js +3 -3
- package/dist/bundle.cjs +45 -12
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +261 -9
- package/package.json +6 -6
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/document.js
CHANGED
|
@@ -499,7 +499,7 @@ class Documents {
|
|
|
499
499
|
/**
|
|
500
500
|
* Uploads the file
|
|
501
501
|
* @param {object} params Params to upload document
|
|
502
|
-
* @param {
|
|
502
|
+
* @param {buffer} params.content The content of the file (Buffer)
|
|
503
503
|
* @param {string} params.signedUrl The signed URL
|
|
504
504
|
* @param {string} params.type The file mime type
|
|
505
505
|
* @return {Promise<boolean>} True if success
|
|
@@ -522,7 +522,7 @@ class Documents {
|
|
|
522
522
|
async uploadSignedDocument(params) {
|
|
523
523
|
const { content, signedUrl, type } = params;
|
|
524
524
|
Joi.assert(params, Joi.object().required());
|
|
525
|
-
Joi.assert(params.content, Joi.
|
|
525
|
+
Joi.assert(params.content, Joi.required());
|
|
526
526
|
Joi.assert(params.signedUrl, Joi.string().required());
|
|
527
527
|
Joi.assert(params.type, Joi.string().required());
|
|
528
528
|
|
package/api/user/organization.js
CHANGED
|
@@ -174,16 +174,6 @@ class Organization {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
178
|
-
* @description Call URL internal
|
|
179
|
-
* @param {!object} params Params to call fectch (URL internal)
|
|
180
|
-
* @param {!string} params.url URL to call
|
|
181
|
-
* @param {!string} [params.method=POST] Fetch Method
|
|
182
|
-
* @param {string} params.payload Payload to send
|
|
183
|
-
* @returns {promise}
|
|
184
|
-
* @public
|
|
185
|
-
* @async
|
|
186
|
-
/**
|
|
187
177
|
* @author Thiago Anselmo <thiagoo.anselmoo@gmail.com>
|
|
188
178
|
* @description Call URL internal, need auth JWT (session)
|
|
189
179
|
* @param {!object} params Params to call fectch (URL internal)
|
package/api/utils/promises.js
CHANGED
package/bundleRollup.js
CHANGED
|
@@ -107,13 +107,13 @@ class BuildRollup {
|
|
|
107
107
|
|
|
108
108
|
try {
|
|
109
109
|
const bundle = await rollup.rollup(config.entry);
|
|
110
|
-
self.log('Bundle
|
|
110
|
+
self.log('Bundle generated');
|
|
111
111
|
|
|
112
112
|
await bundle.write(config.output);
|
|
113
|
-
self.log('Bundle
|
|
113
|
+
self.log('Bundle writen');
|
|
114
114
|
|
|
115
115
|
await bundle.close();
|
|
116
|
-
self.log('Bundle
|
|
116
|
+
self.log('Bundle finished\n');
|
|
117
117
|
|
|
118
118
|
} catch (ex) {
|
|
119
119
|
throw ex;
|
package/dist/bundle.cjs
CHANGED
|
@@ -1020,7 +1020,7 @@ class Documents {
|
|
|
1020
1020
|
/**
|
|
1021
1021
|
* Uploads the file
|
|
1022
1022
|
* @param {object} params Params to upload document
|
|
1023
|
-
* @param {
|
|
1023
|
+
* @param {buffer} params.content The content of the file (Buffer)
|
|
1024
1024
|
* @param {string} params.signedUrl The signed URL
|
|
1025
1025
|
* @param {string} params.type The file mime type
|
|
1026
1026
|
* @return {Promise<boolean>} True if success
|
|
@@ -1043,7 +1043,7 @@ class Documents {
|
|
|
1043
1043
|
async uploadSignedDocument(params) {
|
|
1044
1044
|
const { content, signedUrl, type } = params;
|
|
1045
1045
|
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
1046
|
-
Joi__default["default"].assert(params.content, Joi__default["default"].
|
|
1046
|
+
Joi__default["default"].assert(params.content, Joi__default["default"].required());
|
|
1047
1047
|
Joi__default["default"].assert(params.signedUrl, Joi__default["default"].string().required());
|
|
1048
1048
|
Joi__default["default"].assert(params.type, Joi__default["default"].string().required());
|
|
1049
1049
|
|
|
@@ -1232,16 +1232,6 @@ class Organization {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
1234
|
/**
|
|
1235
|
-
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
1236
|
-
* @description Call URL internal
|
|
1237
|
-
* @param {!object} params Params to call fectch (URL internal)
|
|
1238
|
-
* @param {!string} params.url URL to call
|
|
1239
|
-
* @param {!string} [params.method=POST] Fetch Method
|
|
1240
|
-
* @param {string} params.payload Payload to send
|
|
1241
|
-
* @returns {promise}
|
|
1242
|
-
* @public
|
|
1243
|
-
* @async
|
|
1244
|
-
/**
|
|
1245
1235
|
* @author Thiago Anselmo <thiagoo.anselmoo@gmail.com>
|
|
1246
1236
|
* @description Call URL internal, need auth JWT (session)
|
|
1247
1237
|
* @param {!object} params Params to call fectch (URL internal)
|
|
@@ -9034,6 +9024,49 @@ class AdminDocuments {
|
|
|
9034
9024
|
return self._returnData(await apiCall);
|
|
9035
9025
|
}
|
|
9036
9026
|
|
|
9027
|
+
/**
|
|
9028
|
+
*
|
|
9029
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9030
|
+
* @description Get the content of a document
|
|
9031
|
+
* @param {object} params Params to request signed url
|
|
9032
|
+
* @param {string} params.docId The unique id of the document
|
|
9033
|
+
* @param {string} params.page The page, from 0, or 'all' if all pages (the full content)
|
|
9034
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
9035
|
+
* @return {Promise<object>} data the document content
|
|
9036
|
+
* @return {string} data._id the _id of the document
|
|
9037
|
+
* @return {string} data.content all the pages or if asked by page, just one page, the one requested
|
|
9038
|
+
* @return {string} data.content.TextOverlay the overlay text if requested
|
|
9039
|
+
* @return {string} data.content.ParsedText the page text content
|
|
9040
|
+
* @return {number} data.total the total number of pages
|
|
9041
|
+
* @public
|
|
9042
|
+
* @async
|
|
9043
|
+
* @example
|
|
9044
|
+
*
|
|
9045
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9046
|
+
* const api = new API();
|
|
9047
|
+
* const params - {
|
|
9048
|
+
* page: '0',
|
|
9049
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
9050
|
+
* };
|
|
9051
|
+
* const apiKey: '...';
|
|
9052
|
+
* await api.admin.document.getContent(params, apiKey);
|
|
9053
|
+
*/
|
|
9054
|
+
async getContent(params = {}, apiKey) {
|
|
9055
|
+
|
|
9056
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
9057
|
+
Joi__default["default"].assert(params.content, Joi__default["default"].string().required());
|
|
9058
|
+
Joi__default["default"].assert(params.docId, Joi__default["default"].string().required());
|
|
9059
|
+
Joi__default["default"].assert(params.page, Joi__default["default"].string().required());
|
|
9060
|
+
Joi__default["default"].assert(apiKey, Joi__default["default"].string().required());
|
|
9061
|
+
|
|
9062
|
+
const self = this;
|
|
9063
|
+
const { page, docId } = params;
|
|
9064
|
+
const url = `/api/documents/${docId}/content/${page}?apiKey=${apiKey}`;
|
|
9065
|
+
const apiCall = self._client
|
|
9066
|
+
.get(url);
|
|
9067
|
+
return self._returnData(await apiCall);
|
|
9068
|
+
}
|
|
9069
|
+
|
|
9037
9070
|
}
|
|
9038
9071
|
|
|
9039
9072
|
/**
|