@docbrasil/api-systemmanager 1.0.56 → 1.0.59
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/login.js +31 -0
- package/api/user/process.js +18 -1
- package/dist/bundle.cjs +91 -1
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +522 -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/login.js
CHANGED
|
@@ -231,6 +231,37 @@ class Login {
|
|
|
231
231
|
throw ex;
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
237
|
+
* @description Recover the password
|
|
238
|
+
* @param {string} username The username or email
|
|
239
|
+
* @return {promise<object>}} data
|
|
240
|
+
* @return {boolean} data.success true|false
|
|
241
|
+
* @public
|
|
242
|
+
* @async
|
|
243
|
+
* @example
|
|
244
|
+
*
|
|
245
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
246
|
+
*
|
|
247
|
+
* // Params of the instance
|
|
248
|
+
* const params = {...}
|
|
249
|
+
* const api = new API(params);
|
|
250
|
+
* const { success } = await api.login.recover('myusername');
|
|
251
|
+
*/
|
|
252
|
+
async recover(username) {
|
|
253
|
+
const self = this;
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
Joi.assert(username, Joi.string().required());
|
|
257
|
+
|
|
258
|
+
const url = `users/${username}/sendResetEmail`;
|
|
259
|
+
const apiCall = self._client.get(url);
|
|
260
|
+
return self._returnData(await apiCall);
|
|
261
|
+
} catch (ex) {
|
|
262
|
+
throw ex;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
234
265
|
}
|
|
235
266
|
|
|
236
267
|
export default Login;
|
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
|
@@ -420,6 +420,37 @@ class Login {
|
|
|
420
420
|
throw ex;
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
426
|
+
* @description Recover the password
|
|
427
|
+
* @param {string} username The username or email
|
|
428
|
+
* @return {promise<object>}} data
|
|
429
|
+
* @return {boolean} data.success true|false
|
|
430
|
+
* @public
|
|
431
|
+
* @async
|
|
432
|
+
* @example
|
|
433
|
+
*
|
|
434
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
435
|
+
*
|
|
436
|
+
* // Params of the instance
|
|
437
|
+
* const params = {...}
|
|
438
|
+
* const api = new API(params);
|
|
439
|
+
* const { success } = await api.login.recover('myusername');
|
|
440
|
+
*/
|
|
441
|
+
async recover(username) {
|
|
442
|
+
const self = this;
|
|
443
|
+
|
|
444
|
+
try {
|
|
445
|
+
Joi__default["default"].assert(username, Joi__default["default"].string().required());
|
|
446
|
+
|
|
447
|
+
const url = `users/${username}/sendResetEmail`;
|
|
448
|
+
const apiCall = self._client.get(url);
|
|
449
|
+
return self._returnData(await apiCall);
|
|
450
|
+
} catch (ex) {
|
|
451
|
+
throw ex;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
423
454
|
}
|
|
424
455
|
|
|
425
456
|
/**
|
|
@@ -1330,6 +1361,23 @@ class Process {
|
|
|
1330
1361
|
};
|
|
1331
1362
|
}
|
|
1332
1363
|
|
|
1364
|
+
/**
|
|
1365
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1366
|
+
* @description Set header for a bigger payload
|
|
1367
|
+
* @param {string} session Session, token JWT
|
|
1368
|
+
* @return {object} header with new session
|
|
1369
|
+
* @private
|
|
1370
|
+
*/
|
|
1371
|
+
_setMaxContentHeader(session) {
|
|
1372
|
+
return {
|
|
1373
|
+
headers: {
|
|
1374
|
+
authorization: session,
|
|
1375
|
+
maxContentLength: Infinity,
|
|
1376
|
+
maxBodyLength: Infinity
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1333
1381
|
/**
|
|
1334
1382
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1335
1383
|
* @description Start process
|
|
@@ -1364,7 +1412,7 @@ class Process {
|
|
|
1364
1412
|
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
1365
1413
|
|
|
1366
1414
|
const {processId, orgId, payload = {}} = params;
|
|
1367
|
-
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self.
|
|
1415
|
+
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}`, payload, self._setMaxContentHeader(session));
|
|
1368
1416
|
return self._returnData(await apiCall);
|
|
1369
1417
|
} catch (ex) {
|
|
1370
1418
|
throw ex;
|
|
@@ -9024,6 +9072,48 @@ class AdminDocuments {
|
|
|
9024
9072
|
return self._returnData(await apiCall);
|
|
9025
9073
|
}
|
|
9026
9074
|
|
|
9075
|
+
/**
|
|
9076
|
+
*
|
|
9077
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9078
|
+
* @description Get the content of a document
|
|
9079
|
+
* @param {object} params Params to request signed url
|
|
9080
|
+
* @param {string} params.docId The unique id of the document
|
|
9081
|
+
* @param {string} params.page The page, from 0, or 'all' if all pages (the full content)
|
|
9082
|
+
* @param {string} apiKey Api Key as permission to use this functionality
|
|
9083
|
+
* @return {Promise<object>} data the document content
|
|
9084
|
+
* @return {string} data._id the _id of the document
|
|
9085
|
+
* @return {string} data.content all the pages or if asked by page, just one page, the one requested
|
|
9086
|
+
* @return {string} data.content.TextOverlay the overlay text if requested
|
|
9087
|
+
* @return {string} data.content.ParsedText the page text content
|
|
9088
|
+
* @return {number} data.total the total number of pages
|
|
9089
|
+
* @public
|
|
9090
|
+
* @async
|
|
9091
|
+
* @example
|
|
9092
|
+
*
|
|
9093
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9094
|
+
* const api = new API();
|
|
9095
|
+
* const params - {
|
|
9096
|
+
* page: '0',
|
|
9097
|
+
* docId: '5dadd01dc4af3941d42f8c5c'
|
|
9098
|
+
* };
|
|
9099
|
+
* const apiKey: '...';
|
|
9100
|
+
* await api.admin.document.getContent(params, apiKey);
|
|
9101
|
+
*/
|
|
9102
|
+
async getContent(params = {}, apiKey) {
|
|
9103
|
+
|
|
9104
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
9105
|
+
Joi__default["default"].assert(params.docId, Joi__default["default"].string().required());
|
|
9106
|
+
Joi__default["default"].assert(params.page, Joi__default["default"].string().required());
|
|
9107
|
+
Joi__default["default"].assert(apiKey, Joi__default["default"].string().required());
|
|
9108
|
+
|
|
9109
|
+
const self = this;
|
|
9110
|
+
const { page, docId } = params;
|
|
9111
|
+
const url = `/api/documents/${docId}/content/${page}?apiKey=${apiKey}`;
|
|
9112
|
+
const apiCall = self._client
|
|
9113
|
+
.get(url);
|
|
9114
|
+
return self._returnData(await apiCall);
|
|
9115
|
+
}
|
|
9116
|
+
|
|
9027
9117
|
}
|
|
9028
9118
|
|
|
9029
9119
|
/**
|