@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.
@@ -271,6 +271,40 @@ class Documents {
271
271
  }
272
272
  }
273
273
 
274
+ /**
275
+ * @author Myndware <augusto.pissarra@myndware.com>
276
+ * @description Updates a document
277
+ * @param {array<string>} ids array of document _id
278
+ * @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
279
+ * @param {string} session Session, token JWT
280
+ * @return {Promise}
281
+ * @public
282
+ * @async
283
+ * @example
284
+ *
285
+ * const API = require('@docbrasil/api-systemmanager');
286
+ * const api = new API();
287
+ * const params = { ... };
288
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
289
+ * await api.user.document.findByIdsAndUpdate(['5edf9f8ee896b817e45b8dad'], params, session);
290
+ */
291
+ async findByIdsAndUpdate(ids, params, session) {
292
+ const self = this;
293
+ try {
294
+ Joi.assert(ids, Joi.array().required().error(new Error('ids is required')));
295
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
296
+ Joi.assert(session, Joi.string().required().error(new Error('session is required')));
297
+ const { areaId, orgId } = params;
298
+ params.ids = ids;
299
+ const apiCall = self._client
300
+ .put(`/organizations/${orgId}/areas/${areaId}/documents/batch`, params, self._setHeader(session));
301
+
302
+ return self._returnData(await apiCall);
303
+ } catch (ex) {
304
+ throw ex;
305
+ }
306
+ }
307
+
274
308
  /**
275
309
  * @author Myndware <augusto.pissarra@myndware.com>
276
310
  * @description Updates a document.
@@ -507,6 +507,7 @@ class Kanban {
507
507
  * @param {string} params.flowId - The id of the organization process step flowId
508
508
  * @param {Array} params.statusList - The status list with new order
509
509
  * @param {Object} params.statusList[] - Status object configuration
510
+ * @param {string} params.statusList[].guid - The guid of the status (the id)
510
511
  * @param {string} params.statusList[].value - The title of the status
511
512
  * @param {boolean} params.statusList[].expanded - If the status column is expanded or not
512
513
  * @param {string} params.statusList[].color - The hexadecimal color code for the status
@@ -569,6 +570,91 @@ class Kanban {
569
570
  throw ex;
570
571
  }
571
572
  }
573
+
574
+ /**
575
+ * @author Myndware <augusto.pissarra@myndware.com>
576
+ * @description Starts a new task in the Kanban board for a specific organization process
577
+ * @description It will create the task, set the new order for all tasks (if you send them) and return the the task
578
+ * @description The new task is the full object of the task, like when you search the task
579
+ * @param {Object} params - Parameters object
580
+ * @param {string} params.orgId - Organization id (_id database)
581
+ * @param {string} params.orgProcessName - The name of the organization process
582
+ * @param {string} params.title - The title of the new task
583
+ * @param {string} params.status - The status id of the new task
584
+ * @param {Array} [params.tags] - Array of tag ids for the new task (optional)
585
+ * @param {Array} [params.tasks] - The task ids, in their current order, of each task inside the same status (optional)
586
+ * @param {string} session - Session, token JWT
587
+ * @returns {promise} Promise that resolves to operation status
588
+ * @returns {Object} returns.data - The response data containing:
589
+ * @returns {boolean} returns.data.success - Indicates if the operation was successful
590
+ * @returns {string} [returns.data.task] - The created task and its properties
591
+ * @returns {string} [returns.data.error] - Error message if operation failed
592
+ * @public
593
+ * @example
594
+ *
595
+ * const API = require('@docbrasil/api-systemmanager');
596
+ * const api = new API();
597
+ * const params = {
598
+ * orgId: '55e4a3bd6be6b45210833fae',
599
+ * orgProcessName: 'employee-onboarding',
600
+ * title: 'Complete employee documentation',
601
+ * status: '507f1f77bcf86cd799439014',
602
+ * tags: ['507f1f77bcf86cd799439015', '507f1f77bcf86cd799439016'],
603
+ * tasks: ['507f1f77bcf86cd799439011', '507f1f77bcf86cd799439012']
604
+ * };
605
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
606
+ * const result = await api.user.kanban.startTask(params, session);
607
+ *
608
+ * Expected response structure (success):
609
+ * {
610
+ * success: true,
611
+ * task: { _id: '507f1f77bcf86cd799439013', ... }
612
+ * }
613
+ *
614
+ * Expected response structure (error):
615
+ * {
616
+ * success: false,
617
+ * error: "Organization process not found"
618
+ * }
619
+ */
620
+ async startTask(params, session) {
621
+ const self = this;
622
+
623
+ try {
624
+ Joi.assert(params, Joi.object().required(), 'Params to start task');
625
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
626
+ Joi.assert(params.orgProcessName, Joi.string().required(), 'The name of the organization process');
627
+ Joi.assert(params.title, Joi.string().required(), 'The title of the new task');
628
+ Joi.assert(params.status, Joi.string().required(), 'The status id of the new task');
629
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
630
+
631
+ const {
632
+ orgId,
633
+ orgProcessName,
634
+ title,
635
+ status,
636
+ tags = [],
637
+ tasks = []
638
+ } = params;
639
+
640
+ // Build API endpoint for starting a new task
641
+ const endpoint = `/organization/${orgId}/kanban/${orgProcessName}/tasks`;
642
+
643
+ const payload = {
644
+ title,
645
+ status,
646
+ tags,
647
+ tasks
648
+ };
649
+
650
+ const apiCall = self._client
651
+ .put(endpoint, payload, self._setHeader(session));
652
+
653
+ return self._returnData(await apiCall);
654
+ } catch (ex) {
655
+ throw ex;
656
+ }
657
+ }
572
658
  }
573
659
 
574
660
  export default Kanban;
package/dist/bundle.cjs CHANGED
@@ -925,6 +925,40 @@ class Documents {
925
925
  }
926
926
  }
927
927
 
928
+ /**
929
+ * @author Myndware <augusto.pissarra@myndware.com>
930
+ * @description Updates a document
931
+ * @param {array<string>} ids array of document _id
932
+ * @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
933
+ * @param {string} session Session, token JWT
934
+ * @return {Promise}
935
+ * @public
936
+ * @async
937
+ * @example
938
+ *
939
+ * const API = require('@docbrasil/api-systemmanager');
940
+ * const api = new API();
941
+ * const params = { ... };
942
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
943
+ * await api.user.document.findByIdsAndUpdate(['5edf9f8ee896b817e45b8dad'], params, session);
944
+ */
945
+ async findByIdsAndUpdate(ids, params, session) {
946
+ const self = this;
947
+ try {
948
+ Joi__default["default"].assert(ids, Joi__default["default"].array().required().error(new Error('ids is required')));
949
+ Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
950
+ Joi__default["default"].assert(session, Joi__default["default"].string().required().error(new Error('session is required')));
951
+ const { areaId, orgId } = params;
952
+ params.ids = ids;
953
+ const apiCall = self._client
954
+ .put(`/organizations/${orgId}/areas/${areaId}/documents/batch`, params, self._setHeader(session));
955
+
956
+ return self._returnData(await apiCall);
957
+ } catch (ex) {
958
+ throw ex;
959
+ }
960
+ }
961
+
928
962
  /**
929
963
  * @author Myndware <augusto.pissarra@myndware.com>
930
964
  * @description Updates a document.
@@ -12280,6 +12314,7 @@ class Kanban {
12280
12314
  * @param {string} params.flowId - The id of the organization process step flowId
12281
12315
  * @param {Array} params.statusList - The status list with new order
12282
12316
  * @param {Object} params.statusList[] - Status object configuration
12317
+ * @param {string} params.statusList[].guid - The guid of the status (the id)
12283
12318
  * @param {string} params.statusList[].value - The title of the status
12284
12319
  * @param {boolean} params.statusList[].expanded - If the status column is expanded or not
12285
12320
  * @param {string} params.statusList[].color - The hexadecimal color code for the status
@@ -12342,6 +12377,91 @@ class Kanban {
12342
12377
  throw ex;
12343
12378
  }
12344
12379
  }
12380
+
12381
+ /**
12382
+ * @author Myndware <augusto.pissarra@myndware.com>
12383
+ * @description Starts a new task in the Kanban board for a specific organization process
12384
+ * @description It will create the task, set the new order for all tasks (if you send them) and return the the task
12385
+ * @description The new task is the full object of the task, like when you search the task
12386
+ * @param {Object} params - Parameters object
12387
+ * @param {string} params.orgId - Organization id (_id database)
12388
+ * @param {string} params.orgProcessName - The name of the organization process
12389
+ * @param {string} params.title - The title of the new task
12390
+ * @param {string} params.status - The status id of the new task
12391
+ * @param {Array} [params.tags] - Array of tag ids for the new task (optional)
12392
+ * @param {Array} [params.tasks] - The task ids, in their current order, of each task inside the same status (optional)
12393
+ * @param {string} session - Session, token JWT
12394
+ * @returns {promise} Promise that resolves to operation status
12395
+ * @returns {Object} returns.data - The response data containing:
12396
+ * @returns {boolean} returns.data.success - Indicates if the operation was successful
12397
+ * @returns {string} [returns.data.task] - The created task and its properties
12398
+ * @returns {string} [returns.data.error] - Error message if operation failed
12399
+ * @public
12400
+ * @example
12401
+ *
12402
+ * const API = require('@docbrasil/api-systemmanager');
12403
+ * const api = new API();
12404
+ * const params = {
12405
+ * orgId: '55e4a3bd6be6b45210833fae',
12406
+ * orgProcessName: 'employee-onboarding',
12407
+ * title: 'Complete employee documentation',
12408
+ * status: '507f1f77bcf86cd799439014',
12409
+ * tags: ['507f1f77bcf86cd799439015', '507f1f77bcf86cd799439016'],
12410
+ * tasks: ['507f1f77bcf86cd799439011', '507f1f77bcf86cd799439012']
12411
+ * };
12412
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
12413
+ * const result = await api.user.kanban.startTask(params, session);
12414
+ *
12415
+ * Expected response structure (success):
12416
+ * {
12417
+ * success: true,
12418
+ * task: { _id: '507f1f77bcf86cd799439013', ... }
12419
+ * }
12420
+ *
12421
+ * Expected response structure (error):
12422
+ * {
12423
+ * success: false,
12424
+ * error: "Organization process not found"
12425
+ * }
12426
+ */
12427
+ async startTask(params, session) {
12428
+ const self = this;
12429
+
12430
+ try {
12431
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to start task');
12432
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
12433
+ Joi__default["default"].assert(params.orgProcessName, Joi__default["default"].string().required(), 'The name of the organization process');
12434
+ Joi__default["default"].assert(params.title, Joi__default["default"].string().required(), 'The title of the new task');
12435
+ Joi__default["default"].assert(params.status, Joi__default["default"].string().required(), 'The status id of the new task');
12436
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
12437
+
12438
+ const {
12439
+ orgId,
12440
+ orgProcessName,
12441
+ title,
12442
+ status,
12443
+ tags = [],
12444
+ tasks = []
12445
+ } = params;
12446
+
12447
+ // Build API endpoint for starting a new task
12448
+ const endpoint = `/organization/${orgId}/kanban/${orgProcessName}/tasks`;
12449
+
12450
+ const payload = {
12451
+ title,
12452
+ status,
12453
+ tags,
12454
+ tasks
12455
+ };
12456
+
12457
+ const apiCall = self._client
12458
+ .put(endpoint, payload, self._setHeader(session));
12459
+
12460
+ return self._returnData(await apiCall);
12461
+ } catch (ex) {
12462
+ throw ex;
12463
+ }
12464
+ }
12345
12465
  }
12346
12466
 
12347
12467
  /**