@docbrasil/api-systemmanager 1.1.67 → 1.1.69

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.
@@ -270,7 +270,6 @@ class AdminDocuments {
270
270
  * const { signedUrl, imageType } = await api.admin.document.signedUrl(params, apiKey);
271
271
  */
272
272
  async signedUrl(params = {}, apiKey) {
273
-
274
273
  Joi.assert(params, Joi.object().required());
275
274
  Joi.assert(params.methodType, Joi.string().required());
276
275
  Joi.assert(params.docId, Joi.string().required());
@@ -308,7 +307,6 @@ class AdminDocuments {
308
307
  * await api.admin.document.updateContent(params, apiKey);
309
308
  */
310
309
  async updateContent(params = {}, apiKey) {
311
-
312
310
  Joi.assert(params, Joi.object().required());
313
311
  Joi.assert(params.content, Joi.string().required());
314
312
  Joi.assert(params.docId, Joi.string().required());
@@ -355,7 +353,6 @@ class AdminDocuments {
355
353
  * await api.admin.document.updateContent(params, apiKey);
356
354
  */
357
355
  async updateAI(params = {}, apiKey) {
358
-
359
356
  Joi.assert(params, Joi.object().required());
360
357
  Joi.assert(params.docId, Joi.string().required());
361
358
  Joi.assert(apiKey, Joi.string().required());
@@ -400,7 +397,6 @@ class AdminDocuments {
400
397
  * await api.admin.document.getContent(params, apiKey);
401
398
  */
402
399
  async getContent(params = {}, apiKey) {
403
-
404
400
  Joi.assert(params, Joi.object().required());
405
401
  Joi.assert(params.docId, Joi.string().required());
406
402
  Joi.assert(params.page, Joi.string().required());
@@ -414,6 +410,39 @@ class AdminDocuments {
414
410
  return self._returnData(await apiCall);
415
411
  }
416
412
 
413
+ /**
414
+ *
415
+ * @author Myndware <augusto.pissarra@myndware.com>
416
+ * @description Get the data of a document
417
+ * @param {object} params Params to request signed url
418
+ * @param {string} params.id The unique id of the document
419
+ * @param {string} apiKey Api Key as permission to use this functionality
420
+ * @return {Promise<object>} data the document data
421
+ * @public
422
+ * @async
423
+ * @example
424
+ *
425
+ * const API = require('@docbrasil/api-systemmanager');
426
+ * const api = new API();
427
+ * const params - {
428
+ * id: '5dadd01dc4af3941d42f8c5c'
429
+ * };
430
+ * const apiKey: '...';
431
+ * await api.admin.document.getDocumentData(params, apiKey);
432
+ */
433
+ async getDocumentData(params = {}, apiKey) {
434
+ Joi.assert(params, Joi.object().required());
435
+ Joi.assert(params.id, Joi.string().required());
436
+ Joi.assert(apiKey, Joi.string().required());
437
+
438
+ const self = this;
439
+ const { id } = params;
440
+ const url = `/api/documents/${id}?apiKey=${apiKey}`;
441
+ const apiCall = self._client
442
+ .get(url);
443
+ return self._returnData(await apiCall);
444
+ }
445
+
417
446
  }
418
447
 
419
448
  export default AdminDocuments;
@@ -640,6 +640,47 @@ class Process {
640
640
  throw ex;
641
641
  }
642
642
  }
643
+
644
+ /**
645
+ * @author Myndware <augusto.pissarra@myndware.com>
646
+ * @description Get step history of a process flow
647
+ * @param {object} params Params to get step history
648
+ * @param {string} params.orgId Organization id (_id database);
649
+ * @param {string} params.processId Process id (_id database);
650
+ * @param {string} params.flowId Flow id;
651
+ * @param {string} session Session, token JWT
652
+ * @return {Promise<Array>} Array of step history entries
653
+ * @public
654
+ * @async
655
+ * @example
656
+ *
657
+ * const API = require('@docbrasil/api-systemmanager');
658
+ * const api = new API();
659
+ * const params = {
660
+ * orgId: '5edd11c46b6ce9729c2c297c',
661
+ * processId: '5dadd01dc4af3941d42f8c5c',
662
+ * flowId: 'Task_18v1xx7'
663
+ * }
664
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
665
+ * const stepHistory = await api.user.process.getStepHistory(params, session);
666
+ */
667
+ async getStepHistory(params, session) {
668
+ const self = this;
669
+
670
+ try {
671
+ Joi.assert(params, Joi.object().required());
672
+ Joi.assert(params.orgId, Joi.string().required());
673
+ Joi.assert(params.processId, Joi.string().required());
674
+ Joi.assert(params.flowId, Joi.string().required());
675
+ Joi.assert(session, Joi.string().required());
676
+
677
+ const {orgId, processId, flowId} = params;
678
+ const apiCall = self._client.get(`/organizations/${orgId}/process/${processId}/flow/${flowId}/history`, self._setHeader(session));
679
+ return self._returnData(await apiCall, []);
680
+ } catch (ex) {
681
+ throw ex;
682
+ }
683
+ }
643
684
  }
644
685
 
645
686
  export default Process;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docbrasil/api-systemmanager",
3
3
  "description": "Module API System Manager",
4
- "version": "1.1.67",
4
+ "version": "1.1.69",
5
5
  "scripts": {
6
6
  "htmldoc": "rm -rf docs && jsdoc api/** -d docs -t ./node_modules/better-docs",
7
7
  "doc": "rm -rf doc && mkdir doc && jsdoc2md api/**/* api/* > doc/api.md",