@docbrasil/api-systemmanager 1.1.15 → 1.1.16
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/user/document.js +7 -5
- package/dist/bundle.cjs +7 -5
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +1 -1
- package/docs/Documents.html +9 -9
- package/docs/MyTasks.html +1252 -148
- package/docs/user_document.js.html +7 -5
- package/docs/user_my_tasks.js.html +161 -2
- package/package.json +1 -1
- package/.project +0 -11
|
@@ -374,13 +374,14 @@ class Documents {
|
|
|
374
374
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
375
375
|
* await api.user.document.findById('5edf9f8ee896b817e45b8dad', session);
|
|
376
376
|
*/
|
|
377
|
-
async findById(
|
|
377
|
+
async findById(params, session) {
|
|
378
378
|
const self = this;
|
|
379
379
|
try {
|
|
380
|
-
Joi.assert(params._id, Joi.string().required().error(new Error('_id is required')));
|
|
381
380
|
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
381
|
+
Joi.assert(params.id, Joi.string().required().error(new Error('id is required')));
|
|
382
|
+
Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
|
|
382
383
|
Joi.assert(session, Joi.string().required().error(new Error('session is required')));
|
|
383
|
-
const {
|
|
384
|
+
const {id, orgId} = params;
|
|
384
385
|
const apiCall = self._client
|
|
385
386
|
.get(`/organizations/${orgId}/documents/${id}/data/DOC`, params, self._setHeader(session));
|
|
386
387
|
|
|
@@ -503,7 +504,7 @@ class Documents {
|
|
|
503
504
|
* const api = new API();
|
|
504
505
|
* const params - {
|
|
505
506
|
* docId: '5dadd01dc4af3941d42f8c5c',
|
|
506
|
-
*
|
|
507
|
+
* orgId '5df7f19618430c89a41a19d2',
|
|
507
508
|
* };
|
|
508
509
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
509
510
|
* await api.user.document.findByIdAndRemove(params, session);
|
|
@@ -879,7 +880,8 @@ class Documents {
|
|
|
879
880
|
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
880
881
|
|
|
881
882
|
const {query, orgId} = params;
|
|
882
|
-
const
|
|
883
|
+
const params = new URLSearchParams(query);
|
|
884
|
+
const queryString = params.toString();
|
|
883
885
|
const apiCall = self._client.get(`/organizations/${orgId}/documents/search?${queryString}`, self._setHeader(session));
|
|
884
886
|
|
|
885
887
|
return self._returnData(await apiCall);
|
|
@@ -339,7 +339,7 @@ class MyTasks {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
/**
|
|
343
343
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
344
344
|
* @description Add Multi Task User
|
|
345
345
|
* @param {object} params Params for adding multi task user
|
|
@@ -362,7 +362,7 @@ class MyTasks {
|
|
|
362
362
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
363
363
|
* await api.user.task.mytasks.addMultiTaskUser(params, session);
|
|
364
364
|
*/
|
|
365
|
-
|
|
365
|
+
async addMultiTaskUser(params, session) {
|
|
366
366
|
const self = this;
|
|
367
367
|
|
|
368
368
|
try {
|
|
@@ -379,7 +379,166 @@ class MyTasks {
|
|
|
379
379
|
} catch (ex) {
|
|
380
380
|
throw ex;
|
|
381
381
|
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
386
|
+
* @description Method to get assign task users
|
|
387
|
+
* @param {object} params Params to get task
|
|
388
|
+
* @param {object} params.taskId Task id (_id database)
|
|
389
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
390
|
+
* @param {string} session Session, token JWT
|
|
391
|
+
* @returns {promise}
|
|
392
|
+
* @public
|
|
393
|
+
* @example
|
|
394
|
+
*
|
|
395
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
396
|
+
* const api = new API();
|
|
397
|
+
* const params = {
|
|
398
|
+
* taskId: '5df7f19618430c89a41a19d2',
|
|
399
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
400
|
+
* };
|
|
401
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
402
|
+
* await api.user.task.mytasks.getAssignTaskUsers(params, session);
|
|
403
|
+
*/
|
|
404
|
+
async getAssignTaskUsers(params, session) {
|
|
405
|
+
const self = this;
|
|
406
|
+
|
|
407
|
+
try {
|
|
408
|
+
Joi.assert(params, Joi.object().required(), 'Params to get assign task users');
|
|
409
|
+
Joi.assert(params.taskId, Joi.string().required(), ' Task id (_id database)');
|
|
410
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
411
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
412
|
+
|
|
413
|
+
const {taskId, orgId} = params;
|
|
414
|
+
const apiCall = self._client
|
|
415
|
+
.get(`/organizations/${orgId}/users/tasks/${taskId}/assign`, self._setHeader(session));
|
|
416
|
+
|
|
417
|
+
return self._returnData(await apiCall);
|
|
418
|
+
} catch (ex) {
|
|
419
|
+
throw ex;
|
|
382
420
|
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
425
|
+
* @description Assign Task user
|
|
426
|
+
* @param {object} params The params to assign task to user
|
|
427
|
+
* @param {string} params.orgName Organization Name
|
|
428
|
+
* @param {string} params.userId User id that will be assigned the task
|
|
429
|
+
* @param {string} params.taskId Task Id
|
|
430
|
+
* @param {string} session Is token JWT of user
|
|
431
|
+
* @return {Promise}
|
|
432
|
+
* @public
|
|
433
|
+
* @async
|
|
434
|
+
* @example
|
|
435
|
+
*
|
|
436
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
437
|
+
* const api = new API();
|
|
438
|
+
* const params = {
|
|
439
|
+
* orgName: 'pinkbrain',
|
|
440
|
+
* userId: '646386c9583e04a131adc894',
|
|
441
|
+
* taskId: '646386c9583e04a131adc895'
|
|
442
|
+
* };
|
|
443
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
444
|
+
* await api.user.task.mytasks.assignTaskUser(params, session);
|
|
445
|
+
*/
|
|
446
|
+
async assignTaskUsers(params, session) {
|
|
447
|
+
const self = this;
|
|
448
|
+
|
|
449
|
+
try {
|
|
450
|
+
Joi.assert(params, Joi.object().required());
|
|
451
|
+
Joi.assert(params.orgName, Joi.string().required());
|
|
452
|
+
Joi.assert(params.userId, Joi.string().required());
|
|
453
|
+
Joi.assert(params.taskId, Joi.string().required());
|
|
454
|
+
Joi.assert(session, Joi.string().required());
|
|
455
|
+
|
|
456
|
+
const {taskId, userId, orgName} = params;
|
|
457
|
+
|
|
458
|
+
const apiCall = self._client.put(`/organizations/${orgName}/users/tasks/${taskId}/assign/${userId}`, {}, self._setHeader(session));
|
|
459
|
+
return self._returnData(await apiCall);
|
|
460
|
+
} catch (ex) {
|
|
461
|
+
throw ex;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
467
|
+
* @description Unclaim task
|
|
468
|
+
* @param {object} params The params to unclaim task
|
|
469
|
+
* @param {string} params.orgName Organization Name
|
|
470
|
+
* @param {string} params.taskId Task Id
|
|
471
|
+
* @param {string} session Is token JWT of user
|
|
472
|
+
* @return {Promise}
|
|
473
|
+
* @public
|
|
474
|
+
* @async
|
|
475
|
+
* @example
|
|
476
|
+
*
|
|
477
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
478
|
+
* const api = new API();
|
|
479
|
+
* const params = {
|
|
480
|
+
* orgName: 'pinkbrain',
|
|
481
|
+
* taskId: '646386c9583e04a131adc895'
|
|
482
|
+
* };
|
|
483
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
484
|
+
* await api.user.task.mytasks.unclaim(params, session);
|
|
485
|
+
*/
|
|
486
|
+
async unclaim(params, session) {
|
|
487
|
+
const self = this;
|
|
488
|
+
|
|
489
|
+
try {
|
|
490
|
+
Joi.assert(params, Joi.object().required());
|
|
491
|
+
Joi.assert(params.orgName, Joi.string().required());
|
|
492
|
+
Joi.assert(params.taskId, Joi.string().required());
|
|
493
|
+
Joi.assert(session, Joi.string().required());
|
|
494
|
+
|
|
495
|
+
const {taskId, orgName} = params;
|
|
496
|
+
|
|
497
|
+
const apiCall = self._client.put(`/organizations/${orgName}/users/tasks/${taskId}/unclaim`, {}, self._setHeader(session));
|
|
498
|
+
return self._returnData(await apiCall);
|
|
499
|
+
} catch (ex) {
|
|
500
|
+
throw ex;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
506
|
+
* @description Escalate task
|
|
507
|
+
* @param {object} params The params to escalate task
|
|
508
|
+
* @param {string} params.orgName Organization Name
|
|
509
|
+
* @param {string} params.taskId Task Id
|
|
510
|
+
* @param {string} session Is token JWT of user
|
|
511
|
+
* @return {Promise}
|
|
512
|
+
* @public
|
|
513
|
+
* @async
|
|
514
|
+
* @example
|
|
515
|
+
*
|
|
516
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
517
|
+
* const api = new API();
|
|
518
|
+
* const params = {
|
|
519
|
+
* orgName: 'pinkbrain',
|
|
520
|
+
* taskId: '646386c9583e04a131adc895'
|
|
521
|
+
* };
|
|
522
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
523
|
+
* await api.user.task.mytasks.escalate(params, session);
|
|
524
|
+
*/
|
|
525
|
+
async escalate(params, session) {
|
|
526
|
+
const self = this;
|
|
527
|
+
|
|
528
|
+
try {
|
|
529
|
+
Joi.assert(params, Joi.object().required());
|
|
530
|
+
Joi.assert(params.orgName, Joi.string().required());
|
|
531
|
+
Joi.assert(params.taskId, Joi.string().required());
|
|
532
|
+
Joi.assert(session, Joi.string().required());
|
|
533
|
+
|
|
534
|
+
const {taskId, orgName} = params;
|
|
535
|
+
|
|
536
|
+
const apiCall = self._client.put(`/organizations/${orgName}/users/tasks/${taskId}/escalate`, {}, self._setHeader(session));
|
|
537
|
+
return self._returnData(await apiCall);
|
|
538
|
+
} catch (ex) {
|
|
539
|
+
throw ex;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
383
542
|
}
|
|
384
543
|
|
|
385
544
|
export default MyTasks;
|
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.
|
|
4
|
+
"version": "1.1.16",
|
|
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",
|