@docbrasil/api-systemmanager 1.1.64 → 1.1.66

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/docs/Kanban.html CHANGED
@@ -1404,6 +1404,528 @@ Expected response structure (error):
1404
1404
 
1405
1405
 
1406
1406
 
1407
+ </div>
1408
+
1409
+ <div class="member">
1410
+
1411
+
1412
+
1413
+ <h4 class="name" id="startTask">
1414
+ <a class="href-link" href="#startTask">#</a>
1415
+
1416
+
1417
+ <span class='tag'>async</span>
1418
+
1419
+
1420
+ <span class="code-name">
1421
+
1422
+ startTask<span class="signature">(params, session)</span><span class="type-signature"> &rarr; {promise|Object|boolean|string|string}</span>
1423
+
1424
+ </span>
1425
+ </h4>
1426
+
1427
+
1428
+
1429
+
1430
+ <div class="description">
1431
+ The new task is the full object of the task, like when you search the task
1432
+ </div>
1433
+
1434
+
1435
+
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+
1442
+
1443
+ <h5>Parameters:</h5>
1444
+
1445
+ <div class="table-container">
1446
+ <table class="params table">
1447
+ <thead>
1448
+ <tr>
1449
+
1450
+ <th>Name</th>
1451
+
1452
+
1453
+ <th>Type</th>
1454
+
1455
+
1456
+ <th>Attributes</th>
1457
+
1458
+
1459
+
1460
+
1461
+ <th class="last">Description</th>
1462
+ </tr>
1463
+ </thead>
1464
+
1465
+ <tbody>
1466
+
1467
+
1468
+
1469
+ <tr class="deep-level-0">
1470
+
1471
+ <td class="name"><code>params</code></td>
1472
+
1473
+
1474
+ <td class="type">
1475
+
1476
+
1477
+ <code class="param-type">Object</code>
1478
+
1479
+
1480
+
1481
+ </td>
1482
+
1483
+
1484
+ <td class="attributes">
1485
+
1486
+
1487
+
1488
+
1489
+
1490
+ </td>
1491
+
1492
+
1493
+
1494
+
1495
+ <td class="description last">Parameters object</td>
1496
+ </tr>
1497
+
1498
+
1499
+
1500
+
1501
+ <tr class="deep-level-1">
1502
+
1503
+ <td class="name"><code>orgId</code></td>
1504
+
1505
+
1506
+ <td class="type">
1507
+
1508
+
1509
+ <code class="param-type">string</code>
1510
+
1511
+
1512
+
1513
+ </td>
1514
+
1515
+
1516
+ <td class="attributes">
1517
+
1518
+
1519
+
1520
+
1521
+
1522
+ </td>
1523
+
1524
+
1525
+
1526
+
1527
+ <td class="description last">Organization id (_id database)</td>
1528
+ </tr>
1529
+
1530
+
1531
+
1532
+ <tr class="deep-level-1">
1533
+
1534
+ <td class="name"><code>orgProcessName</code></td>
1535
+
1536
+
1537
+ <td class="type">
1538
+
1539
+
1540
+ <code class="param-type">string</code>
1541
+
1542
+
1543
+
1544
+ </td>
1545
+
1546
+
1547
+ <td class="attributes">
1548
+
1549
+
1550
+
1551
+
1552
+
1553
+ </td>
1554
+
1555
+
1556
+
1557
+
1558
+ <td class="description last">The name of the organization process</td>
1559
+ </tr>
1560
+
1561
+
1562
+
1563
+ <tr class="deep-level-1">
1564
+
1565
+ <td class="name"><code>title</code></td>
1566
+
1567
+
1568
+ <td class="type">
1569
+
1570
+
1571
+ <code class="param-type">string</code>
1572
+
1573
+
1574
+
1575
+ </td>
1576
+
1577
+
1578
+ <td class="attributes">
1579
+
1580
+
1581
+
1582
+
1583
+
1584
+ </td>
1585
+
1586
+
1587
+
1588
+
1589
+ <td class="description last">The title of the new task</td>
1590
+ </tr>
1591
+
1592
+
1593
+
1594
+ <tr class="deep-level-1">
1595
+
1596
+ <td class="name"><code>status</code></td>
1597
+
1598
+
1599
+ <td class="type">
1600
+
1601
+
1602
+ <code class="param-type">string</code>
1603
+
1604
+
1605
+
1606
+ </td>
1607
+
1608
+
1609
+ <td class="attributes">
1610
+
1611
+
1612
+
1613
+
1614
+
1615
+ </td>
1616
+
1617
+
1618
+
1619
+
1620
+ <td class="description last">The status id of the new task</td>
1621
+ </tr>
1622
+
1623
+
1624
+
1625
+ <tr class="deep-level-1">
1626
+
1627
+ <td class="name"><code>tags</code></td>
1628
+
1629
+
1630
+ <td class="type">
1631
+
1632
+
1633
+ <code class="param-type">Array</code>
1634
+
1635
+
1636
+
1637
+ </td>
1638
+
1639
+
1640
+ <td class="attributes">
1641
+
1642
+ &lt;optional><br>
1643
+
1644
+
1645
+
1646
+
1647
+
1648
+ </td>
1649
+
1650
+
1651
+
1652
+
1653
+ <td class="description last">Array of tag ids for the new task (optional)</td>
1654
+ </tr>
1655
+
1656
+
1657
+
1658
+ <tr class="deep-level-1">
1659
+
1660
+ <td class="name"><code>tasks</code></td>
1661
+
1662
+
1663
+ <td class="type">
1664
+
1665
+
1666
+ <code class="param-type">Array</code>
1667
+
1668
+
1669
+
1670
+ </td>
1671
+
1672
+
1673
+ <td class="attributes">
1674
+
1675
+ &lt;optional><br>
1676
+
1677
+
1678
+
1679
+
1680
+
1681
+ </td>
1682
+
1683
+
1684
+
1685
+
1686
+ <td class="description last">The task ids, in their current order, of each task inside the same status (optional)</td>
1687
+ </tr>
1688
+
1689
+
1690
+
1691
+
1692
+
1693
+
1694
+
1695
+ <tr class="deep-level-0">
1696
+
1697
+ <td class="name"><code>session</code></td>
1698
+
1699
+
1700
+ <td class="type">
1701
+
1702
+
1703
+ <code class="param-type">string</code>
1704
+
1705
+
1706
+
1707
+ </td>
1708
+
1709
+
1710
+ <td class="attributes">
1711
+
1712
+
1713
+
1714
+
1715
+
1716
+ </td>
1717
+
1718
+
1719
+
1720
+
1721
+ <td class="description last">Session, token JWT</td>
1722
+ </tr>
1723
+
1724
+
1725
+
1726
+ </tbody>
1727
+ </table>
1728
+ </div>
1729
+
1730
+
1731
+
1732
+
1733
+
1734
+ <dl class="details">
1735
+
1736
+
1737
+
1738
+
1739
+
1740
+
1741
+
1742
+
1743
+
1744
+
1745
+
1746
+
1747
+
1748
+
1749
+
1750
+
1751
+
1752
+
1753
+ <dt class="tag-author">Author:</dt>
1754
+ <dd class="tag-author">
1755
+ <ul>
1756
+ <li><a href="mailto:augusto.pissarra@myndware.com">Myndware</a></li>
1757
+ </ul>
1758
+ </dd>
1759
+
1760
+
1761
+
1762
+
1763
+
1764
+
1765
+
1766
+
1767
+
1768
+
1769
+
1770
+
1771
+
1772
+
1773
+ <p class="tag-source">
1774
+ <a href="user_kanban.js.html" class="button">View Source</a>
1775
+ <span>
1776
+ <a href="user_kanban.js.html">user/kanban.js</a>, <a href="user_kanban.js.html#line620">line 620</a>
1777
+ </span>
1778
+ </p>
1779
+
1780
+ </dl>
1781
+
1782
+
1783
+
1784
+
1785
+
1786
+
1787
+
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+
1794
+
1795
+
1796
+
1797
+
1798
+
1799
+ <div class='columns method-parameter'>
1800
+ <div class="column is-2"><label>Returns:</label></div>
1801
+ <div class="column is-10">
1802
+
1803
+
1804
+
1805
+ <div class="columns">
1806
+
1807
+ <div class='param-desc column is-7'>Promise that resolves to operation status</div>
1808
+
1809
+
1810
+ <div class='column is-5 has-text-left'>
1811
+ <label>Type: </label>
1812
+
1813
+ <code class="param-type">promise</code>
1814
+
1815
+
1816
+ </div>
1817
+
1818
+ </div>
1819
+
1820
+
1821
+
1822
+
1823
+ <div class="columns">
1824
+
1825
+ <div class='param-desc column is-7'>returns.data - The response data containing:</div>
1826
+
1827
+
1828
+ <div class='column is-5 has-text-left'>
1829
+ <label>Type: </label>
1830
+
1831
+ <code class="param-type">Object</code>
1832
+
1833
+
1834
+ </div>
1835
+
1836
+ </div>
1837
+
1838
+
1839
+
1840
+
1841
+ <div class="columns">
1842
+
1843
+ <div class='param-desc column is-7'>returns.data.success - Indicates if the operation was successful</div>
1844
+
1845
+
1846
+ <div class='column is-5 has-text-left'>
1847
+ <label>Type: </label>
1848
+
1849
+ <code class="param-type">boolean</code>
1850
+
1851
+
1852
+ </div>
1853
+
1854
+ </div>
1855
+
1856
+
1857
+
1858
+
1859
+ <div class="columns">
1860
+
1861
+ <div class='param-desc column is-7'>[returns.data.task] - The created task and its properties</div>
1862
+
1863
+
1864
+ <div class='column is-5 has-text-left'>
1865
+ <label>Type: </label>
1866
+
1867
+ <code class="param-type">string</code>
1868
+
1869
+
1870
+ </div>
1871
+
1872
+ </div>
1873
+
1874
+
1875
+
1876
+
1877
+ <div class="columns">
1878
+
1879
+ <div class='param-desc column is-7'>[returns.data.error] - Error message if operation failed</div>
1880
+
1881
+
1882
+ <div class='column is-5 has-text-left'>
1883
+ <label>Type: </label>
1884
+
1885
+ <code class="param-type">string</code>
1886
+
1887
+
1888
+ </div>
1889
+
1890
+ </div>
1891
+
1892
+
1893
+ </div>
1894
+ </div>
1895
+
1896
+
1897
+
1898
+
1899
+ <h5>Example</h5>
1900
+
1901
+
1902
+ <pre class="prettyprint"><code>const API = require('@docbrasil/api-systemmanager');
1903
+ const api = new API();
1904
+ const params = {
1905
+ orgId: '55e4a3bd6be6b45210833fae',
1906
+ orgProcessName: 'employee-onboarding',
1907
+ title: 'Complete employee documentation',
1908
+ status: '507f1f77bcf86cd799439014',
1909
+ tags: ['507f1f77bcf86cd799439015', '507f1f77bcf86cd799439016'],
1910
+ tasks: ['507f1f77bcf86cd799439011', '507f1f77bcf86cd799439012']
1911
+ };
1912
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1913
+ const result = await api.user.kanban.startTask(params, session);
1914
+
1915
+ Expected response structure (success):
1916
+ {
1917
+ success: true,
1918
+ task: { _id: '507f1f77bcf86cd799439013', ... }
1919
+ }
1920
+
1921
+ Expected response structure (error):
1922
+ {
1923
+ success: false,
1924
+ error: "Organization process not found"
1925
+ }</code></pre>
1926
+
1927
+
1928
+
1407
1929
  </div>
1408
1930
 
1409
1931
  <div class="member">
@@ -2015,6 +2537,29 @@ Expected response structure (error):
2015
2537
 
2016
2538
 
2017
2539
 
2540
+ <tr class="deep-level-1">
2541
+
2542
+ <td class="name"><code>statusList[].guid</code></td>
2543
+
2544
+
2545
+ <td class="type">
2546
+
2547
+
2548
+ <code class="param-type">string</code>
2549
+
2550
+
2551
+
2552
+ </td>
2553
+
2554
+
2555
+
2556
+
2557
+
2558
+ <td class="description last">The guid of the status (the id)</td>
2559
+ </tr>
2560
+
2561
+
2562
+
2018
2563
  <tr class="deep-level-1">
2019
2564
 
2020
2565
  <td class="name"><code>statusList[].value</code></td>
@@ -2161,7 +2706,7 @@ Expected response structure (error):
2161
2706
  <p class="tag-source">
2162
2707
  <a href="user_kanban.js.html" class="button">View Source</a>
2163
2708
  <span>
2164
- <a href="user_kanban.js.html">user/kanban.js</a>, <a href="user_kanban.js.html#line548">line 548</a>
2709
+ <a href="user_kanban.js.html">user/kanban.js</a>, <a href="user_kanban.js.html#line549">line 549</a>
2165
2710
  </span>
2166
2711
  </p>
2167
2712
 
@@ -358,6 +358,40 @@ class Documents {
358
358
  }
359
359
  }
360
360
 
361
+ /**
362
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
363
+ * @description Updates a document
364
+ * @param {array&lt;string>} ids array of document _id
365
+ * @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
366
+ * @param {string} session Session, token JWT
367
+ * @return {Promise}
368
+ * @public
369
+ * @async
370
+ * @example
371
+ *
372
+ * const API = require('@docbrasil/api-systemmanager');
373
+ * const api = new API();
374
+ * const params = { ... };
375
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
376
+ * await api.user.document.findByIdsAndUpdate(['5edf9f8ee896b817e45b8dad'], params, session);
377
+ */
378
+ async findByIdsAndUpdate(ids, params, session) {
379
+ const self = this;
380
+ try {
381
+ Joi.assert(ids, Joi.array().required().error(new Error('ids is required')));
382
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
383
+ Joi.assert(session, Joi.string().required().error(new Error('session is required')));
384
+ const { areaId, orgId } = params;
385
+ params.ids = ids;
386
+ const apiCall = self._client
387
+ .put(`/organizations/${orgId}/areas/${areaId}/documents/batch`, params, self._setHeader(session));
388
+
389
+ return self._returnData(await apiCall);
390
+ } catch (ex) {
391
+ throw ex;
392
+ }
393
+ }
394
+
361
395
  /**
362
396
  * @author Myndware &lt;augusto.pissarra@myndware.com>
363
397
  * @description Updates a document.
@@ -594,6 +594,7 @@ class Kanban {
594
594
  * @param {string} params.flowId - The id of the organization process step flowId
595
595
  * @param {Array} params.statusList - The status list with new order
596
596
  * @param {Object} params.statusList[] - Status object configuration
597
+ * @param {string} params.statusList[].guid - The guid of the status (the id)
597
598
  * @param {string} params.statusList[].value - The title of the status
598
599
  * @param {boolean} params.statusList[].expanded - If the status column is expanded or not
599
600
  * @param {string} params.statusList[].color - The hexadecimal color code for the status
@@ -656,6 +657,91 @@ class Kanban {
656
657
  throw ex;
657
658
  }
658
659
  }
660
+
661
+ /**
662
+ * @author Myndware &lt;augusto.pissarra@myndware.com>
663
+ * @description Starts a new task in the Kanban board for a specific organization process
664
+ * @description It will create the task, set the new order for all tasks (if you send them) and return the the task
665
+ * @description The new task is the full object of the task, like when you search the task
666
+ * @param {Object} params - Parameters object
667
+ * @param {string} params.orgId - Organization id (_id database)
668
+ * @param {string} params.orgProcessName - The name of the organization process
669
+ * @param {string} params.title - The title of the new task
670
+ * @param {string} params.status - The status id of the new task
671
+ * @param {Array} [params.tags] - Array of tag ids for the new task (optional)
672
+ * @param {Array} [params.tasks] - The task ids, in their current order, of each task inside the same status (optional)
673
+ * @param {string} session - Session, token JWT
674
+ * @returns {promise} Promise that resolves to operation status
675
+ * @returns {Object} returns.data - The response data containing:
676
+ * @returns {boolean} returns.data.success - Indicates if the operation was successful
677
+ * @returns {string} [returns.data.task] - The created task and its properties
678
+ * @returns {string} [returns.data.error] - Error message if operation failed
679
+ * @public
680
+ * @example
681
+ *
682
+ * const API = require('@docbrasil/api-systemmanager');
683
+ * const api = new API();
684
+ * const params = {
685
+ * orgId: '55e4a3bd6be6b45210833fae',
686
+ * orgProcessName: 'employee-onboarding',
687
+ * title: 'Complete employee documentation',
688
+ * status: '507f1f77bcf86cd799439014',
689
+ * tags: ['507f1f77bcf86cd799439015', '507f1f77bcf86cd799439016'],
690
+ * tasks: ['507f1f77bcf86cd799439011', '507f1f77bcf86cd799439012']
691
+ * };
692
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
693
+ * const result = await api.user.kanban.startTask(params, session);
694
+ *
695
+ * Expected response structure (success):
696
+ * {
697
+ * success: true,
698
+ * task: { _id: '507f1f77bcf86cd799439013', ... }
699
+ * }
700
+ *
701
+ * Expected response structure (error):
702
+ * {
703
+ * success: false,
704
+ * error: "Organization process not found"
705
+ * }
706
+ */
707
+ async startTask(params, session) {
708
+ const self = this;
709
+
710
+ try {
711
+ Joi.assert(params, Joi.object().required(), 'Params to start task');
712
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
713
+ Joi.assert(params.orgProcessName, Joi.string().required(), 'The name of the organization process');
714
+ Joi.assert(params.title, Joi.string().required(), 'The title of the new task');
715
+ Joi.assert(params.status, Joi.string().required(), 'The status id of the new task');
716
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
717
+
718
+ const {
719
+ orgId,
720
+ orgProcessName,
721
+ title,
722
+ status,
723
+ tags = [],
724
+ tasks = []
725
+ } = params;
726
+
727
+ // Build API endpoint for starting a new task
728
+ const endpoint = `/organization/${orgId}/kanban/${orgProcessName}/tasks`;
729
+
730
+ const payload = {
731
+ title,
732
+ status,
733
+ tags,
734
+ tasks
735
+ };
736
+
737
+ const apiCall = self._client
738
+ .put(endpoint, payload, self._setHeader(session));
739
+
740
+ return self._returnData(await apiCall);
741
+ } catch (ex) {
742
+ throw ex;
743
+ }
744
+ }
659
745
  }
660
746
 
661
747
  export default Kanban;
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.64",
4
+ "version": "1.1.66",
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",