@docbrasil/api-systemmanager 1.1.63 → 1.1.65

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.
@@ -216,6 +216,70 @@ class Kanban {
216
216
  }
217
217
  }
218
218
 
219
+ /**
220
+ * @author Myndware <augusto.pissarra@myndware.com>
221
+ * @description Updates the tasks order and status
222
+ * @param {Object} params - Parameters object
223
+ * @param {string} params.orgId - Organization id (_id database)
224
+ * @param {Array} params.tasks - Array of task objects containing taskId and order
225
+ * @param {string} params.tasks[].taskId - The unique identifier of the task to update
226
+ * @param {number} params.tasks[].order - The new order position for the task
227
+ * @param {string} params.tasks[].status - The status of the task
228
+ * @param {string} session - Session, token JWT
229
+ * @returns {promise} Promise that resolves to operation status
230
+ * @returns {Object} returns.data - The response data containing:
231
+ * @returns {boolean} returns.data.success - Indicates if the operation was successful
232
+ * @returns {string} [returns.data.error] - Error message if operation failed
233
+ * @public
234
+ * @example
235
+ *
236
+ * const API = require('@docbrasil/api-systemmanager');
237
+ * const api = new API();
238
+ * const params = {
239
+ * orgId: '55e4a3bd6be6b45210833fae',
240
+ * tasks: [
241
+ * { taskId: '507f1f77bcf86cd799439011', order: 0, status: '507f1f77bcf86cd799439012' },
242
+ * { taskId: '507f1f77bcf86cd799439012', order: 1, status: '507f1f77bcf86cd799439012' },
243
+ * { taskId: '507f1f77bcf86cd799439013', order: 0, status: '507f1f77bcf86cd799439013' }
244
+ * ]
245
+ * };
246
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
247
+ * const result = await api.user.kanban.updateTasksOrder(params, session);
248
+ *
249
+ * Expected response structure (success):
250
+ * {
251
+ * success: true
252
+ * }
253
+ *
254
+ * Expected response structure (error):
255
+ * {
256
+ * success: false,
257
+ * error: "One or more tasks not found"
258
+ * }
259
+ */
260
+ async update(params, session) {
261
+ const self = this;
262
+
263
+ try {
264
+ Joi.assert(params, Joi.object().required(), 'Params to update tasks order');
265
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
266
+ Joi.assert(params.tasks, Joi.array().required(), 'Array of task objects containing taskId and order');
267
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
268
+
269
+ const { orgId, tasks } = params;
270
+
271
+ // Build API endpoint for updating multiple tasks order
272
+ const endpoint = `/organization/${orgId}/kanban/tasks`;
273
+
274
+ const apiCall = self._client
275
+ .put(endpoint, { tasks }, self._setHeader(session));
276
+
277
+ return self._returnData(await apiCall);
278
+ } catch (ex) {
279
+ throw ex;
280
+ }
281
+ }
282
+
219
283
  /**
220
284
  * @author Myndware <augusto.pissarra@myndware.com>
221
285
  * @description Updates the order of a task in its status column on the Kanban board
@@ -530,6 +594,7 @@ class Kanban {
530
594
  * @param {string} params.flowId - The id of the organization process step flowId
531
595
  * @param {Array} params.statusList - The status list with new order
532
596
  * @param {Object} params.statusList[] - Status object configuration
597
+ * @param {string} params.statusList[].guid - The guid of the status (the id)
533
598
  * @param {string} params.statusList[].value - The title of the status
534
599
  * @param {boolean} params.statusList[].expanded - If the status column is expanded or not
535
600
  * @param {string} params.statusList[].color - The hexadecimal color code for the status
@@ -592,6 +657,89 @@ class Kanban {
592
657
  throw ex;
593
658
  }
594
659
  }
660
+
661
+ /**
662
+ * @author Myndware <augusto.pissarra@myndware.com>
663
+ * @description Starts a new task in the Kanban board for a specific organization process
664
+ * @param {Object} params - Parameters object
665
+ * @param {string} params.orgId - Organization id (_id database)
666
+ * @param {string} params.orgProcessName - The name of the organization process
667
+ * @param {string} params.title - The title of the new task
668
+ * @param {string} params.status - The status id of the new task
669
+ * @param {Array} [params.tags] - Array of tag ids for the new task (optional)
670
+ * @param {Array} [params.tasks] - The task ids of each task inside the same status (optional)
671
+ * @param {string} session - Session, token JWT
672
+ * @returns {promise} Promise that resolves to operation status
673
+ * @returns {Object} returns.data - The response data containing:
674
+ * @returns {boolean} returns.data.success - Indicates if the operation was successful
675
+ * @returns {string} [returns.data.taskId] - The ID of the newly created task
676
+ * @returns {string} [returns.data.error] - Error message if operation failed
677
+ * @public
678
+ * @example
679
+ *
680
+ * const API = require('@docbrasil/api-systemmanager');
681
+ * const api = new API();
682
+ * const params = {
683
+ * orgId: '55e4a3bd6be6b45210833fae',
684
+ * orgProcessName: 'employee-onboarding',
685
+ * title: 'Complete employee documentation',
686
+ * status: '507f1f77bcf86cd799439014',
687
+ * tags: ['507f1f77bcf86cd799439015', '507f1f77bcf86cd799439016'],
688
+ * tasks: ['507f1f77bcf86cd799439011', '507f1f77bcf86cd799439012']
689
+ * };
690
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
691
+ * const result = await api.user.kanban.startTask(params, session);
692
+ *
693
+ * Expected response structure (success):
694
+ * {
695
+ * success: true,
696
+ * taskId: '507f1f77bcf86cd799439013'
697
+ * }
698
+ *
699
+ * Expected response structure (error):
700
+ * {
701
+ * success: false,
702
+ * error: "Organization process not found"
703
+ * }
704
+ */
705
+ async startTask(params, session) {
706
+ const self = this;
707
+
708
+ try {
709
+ Joi.assert(params, Joi.object().required(), 'Params to start task');
710
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
711
+ Joi.assert(params.orgProcessName, Joi.string().required(), 'The name of the organization process');
712
+ Joi.assert(params.title, Joi.string().required(), 'The title of the new task');
713
+ Joi.assert(params.status, Joi.string().required(), 'The status id of the new task');
714
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
715
+
716
+ const {
717
+ orgId,
718
+ orgProcessName,
719
+ title,
720
+ status,
721
+ tags = [],
722
+ tasks = []
723
+ } = params;
724
+
725
+ // Build API endpoint for starting a new task
726
+ const endpoint = `/organization/${orgId}/kanban/${orgProcessName}/tasks`;
727
+
728
+ const payload = {
729
+ title,
730
+ status,
731
+ tags,
732
+ tasks
733
+ };
734
+
735
+ const apiCall = self._client
736
+ .put(endpoint, payload, self._setHeader(session));
737
+
738
+ return self._returnData(await apiCall);
739
+ } catch (ex) {
740
+ throw ex;
741
+ }
742
+ }
595
743
  }
596
744
 
597
745
  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.63",
4
+ "version": "1.1.65",
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",