@docbrasil/api-systemmanager 1.1.88 → 1.1.90
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/ai/sessions.js +83 -0
- package/api/user/process.js +377 -249
- package/dist/bundle.cjs +447 -236
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +137 -10
- package/docs/AISession.html +761 -215
- package/docs/Process.html +665 -68
- package/docs/ai_sessions.js.html +83 -0
- package/docs/user_process.js.html +377 -249
- package/package.json +1 -1
package/dist/bundle.cjs
CHANGED
|
@@ -2343,119 +2343,209 @@ class Process {
|
|
|
2343
2343
|
}
|
|
2344
2344
|
}
|
|
2345
2345
|
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2346
|
+
/**
|
|
2347
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2348
|
+
* @description Method to export status data
|
|
2349
|
+
* @param {object} params Params to export status data
|
|
2350
|
+
* @param {object} params.query Search process query
|
|
2351
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
2352
|
+
* @param {string} session Session, token JWT
|
|
2353
|
+
* @public
|
|
2354
|
+
* @example
|
|
2355
|
+
*
|
|
2356
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2357
|
+
* const api = new API();
|
|
2358
|
+
* const params = {
|
|
2359
|
+
* query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
|
|
2360
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
2361
|
+
* };
|
|
2362
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2363
|
+
* const retSearch = await api.user.process.exportStatusData(params, session);
|
|
2364
|
+
*/
|
|
2365
|
+
async exportStatusData(params, session) {
|
|
2366
|
+
const self = this;
|
|
2367
2367
|
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2368
|
+
try {
|
|
2369
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to export status data');
|
|
2370
|
+
Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the search');
|
|
2371
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
2372
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2373
2373
|
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2374
|
+
const {query, orgId} = params;
|
|
2375
|
+
const queryString = JSON.stringify(query);
|
|
2376
|
+
const apiCall = self._client
|
|
2377
|
+
.get(`/organizations/${orgId}/process/export/status/data?query=${queryString}`, self._setHeader(session));
|
|
2378
2378
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
}
|
|
2379
|
+
return self._returnData(await apiCall);
|
|
2380
|
+
} catch (ex) {
|
|
2381
|
+
throw ex;
|
|
2383
2382
|
}
|
|
2383
|
+
}
|
|
2384
2384
|
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2385
|
+
/**
|
|
2386
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2387
|
+
* @description Method to export process data
|
|
2388
|
+
* @param {object} params Params to export process data
|
|
2389
|
+
* @param {object} params.query Search process query
|
|
2390
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
2391
|
+
* @param {string} session Session, token JWT
|
|
2392
|
+
* @public
|
|
2393
|
+
* @example
|
|
2394
|
+
*
|
|
2395
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2396
|
+
* const api = new API();
|
|
2397
|
+
* const params = {
|
|
2398
|
+
* query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
|
|
2399
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
2400
|
+
* };
|
|
2401
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2402
|
+
* const retSearch = await api.user.process.exportProcessData(params, session);
|
|
2403
|
+
*/
|
|
2404
|
+
async exportProcessData(params, session) {
|
|
2405
|
+
const self = this;
|
|
2406
2406
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2407
|
+
try {
|
|
2408
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to export process data');
|
|
2409
|
+
Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), 'The query for the search');
|
|
2410
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
2411
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2412
2412
|
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2413
|
+
const {query, orgId} = params;
|
|
2414
|
+
const queryString = JSON.stringify(query);
|
|
2415
|
+
const apiCall = self._client
|
|
2416
|
+
.get(`/organizations/${orgId}/process/export/collect/data?query=${queryString}`, self._setHeader(session));
|
|
2417
2417
|
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
}
|
|
2418
|
+
return self._returnData(await apiCall);
|
|
2419
|
+
} catch (ex) {
|
|
2420
|
+
throw ex;
|
|
2422
2421
|
}
|
|
2422
|
+
}
|
|
2423
2423
|
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2424
|
+
/**
|
|
2425
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2426
|
+
* @description Method to get Process Docs
|
|
2427
|
+
* @param {object} params Params to get process docs
|
|
2428
|
+
* @param {string} params.orgProcessId Organization Process Id
|
|
2429
|
+
* @param {string} params.processId Process Id
|
|
2430
|
+
* @param {string} params.orgId Organization id (_id database)
|
|
2431
|
+
* @param {string} session Session, token JWT
|
|
2432
|
+
* @returns {promise} returned data from the get process docs
|
|
2433
|
+
* @returns {array<object>} Docs returned from process
|
|
2434
|
+
* @public
|
|
2435
|
+
* @example
|
|
2436
|
+
*
|
|
2437
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2438
|
+
* const api = new API();
|
|
2439
|
+
* const params = {
|
|
2440
|
+
* orgProcessId: '55e4a3bd6be6b45210833fae',
|
|
2441
|
+
* processId: '55e4a3bd6be6b45210833fae',
|
|
2442
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
2443
|
+
* };
|
|
2444
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2445
|
+
* const retSearch = await api.user.process.processDocs(params, session);
|
|
2446
|
+
*/
|
|
2447
2447
|
async processDocs(params, session) {
|
|
2448
|
+
const self = this;
|
|
2449
|
+
|
|
2450
|
+
try {
|
|
2451
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get process docs');
|
|
2452
|
+
Joi__default["default"].assert(params.orgProcessId, Joi__default["default"].string().required(), 'Organization Process Id');
|
|
2453
|
+
Joi__default["default"].assert(params.processId, Joi__default["default"].string().required(), 'Process Id');
|
|
2454
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
2455
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2456
|
+
|
|
2457
|
+
const {orgProcessId, processId, orgId} = params;
|
|
2458
|
+
const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/process/${processId}/documents`, self._setHeader(session));
|
|
2459
|
+
return self._returnData(await apiCall);
|
|
2460
|
+
} catch (ex) {
|
|
2461
|
+
throw ex;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
/**
|
|
2466
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2467
|
+
* @description Method to download the process documents
|
|
2468
|
+
* @param {object} params Params to download the process documents
|
|
2469
|
+
* @param {string} params.orgId Organization id (_id database)
|
|
2470
|
+
* @param {string} params.type Document Type
|
|
2471
|
+
* @param {array} params.docIds Documents Ids
|
|
2472
|
+
* @param {string} params.footer Documents Footer
|
|
2473
|
+
* @param {string} session Session, token JWT
|
|
2474
|
+
* @returns {promise} returned data from the search
|
|
2475
|
+
* @public
|
|
2476
|
+
* @example
|
|
2477
|
+
*
|
|
2478
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2479
|
+
* const api = new API();
|
|
2480
|
+
* const params = {
|
|
2481
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
2482
|
+
* type: 'Docs',
|
|
2483
|
+
* docIds: ['55e4a3bd6be6b45210833fae'],
|
|
2484
|
+
* footer: 'Documento - {page} de {pages}'
|
|
2485
|
+
* };
|
|
2486
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2487
|
+
* const result = await api.user.process.downloadDocs(params, session);
|
|
2488
|
+
*/
|
|
2489
|
+
async downloadDocs(params, session) {
|
|
2490
|
+
const self = this;
|
|
2491
|
+
|
|
2492
|
+
try {
|
|
2493
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to download the process documents');
|
|
2494
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
2495
|
+
Joi__default["default"].assert(params.type, Joi__default["default"].string().required(), 'Document Type');
|
|
2496
|
+
Joi__default["default"].assert(params.docIds, Joi__default["default"].array().required(), 'Document Ids');
|
|
2497
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2498
|
+
|
|
2499
|
+
const {orgId, type, docIds, footer} = params;
|
|
2500
|
+
const data = {
|
|
2501
|
+
docIds
|
|
2502
|
+
};
|
|
2503
|
+
|
|
2504
|
+
if (footer) {
|
|
2505
|
+
data.footer = footer;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
const apiCall = self._client
|
|
2509
|
+
.post(`/organizations/${orgId}/documents/download/${type}`, data, self._setHeader(session));
|
|
2510
|
+
|
|
2511
|
+
return self._returnData(await apiCall);
|
|
2512
|
+
} catch (ex) {
|
|
2513
|
+
throw ex;
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
/**
|
|
2518
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2519
|
+
* @description Get DocType properties of process
|
|
2520
|
+
* @param {object} params Params to get document DocType
|
|
2521
|
+
* @param {string} params.docTypeId Document DocTypeId id (_id database);
|
|
2522
|
+
* @param {string} params.orgId Organization id (_id database);
|
|
2523
|
+
* @param {string} session Session, token JWT
|
|
2524
|
+
* @return {Promise}
|
|
2525
|
+
* @public
|
|
2526
|
+
* @async
|
|
2527
|
+
* @example
|
|
2528
|
+
*
|
|
2529
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2530
|
+
* const api = new API();
|
|
2531
|
+
* const params = {
|
|
2532
|
+
* docTypeId: '5dadd01dc4af3941d42f8c5c',
|
|
2533
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2534
|
+
* }
|
|
2535
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2536
|
+
* await api.user.process.getOrgDocTypes(params, session);
|
|
2537
|
+
*/
|
|
2538
|
+
async getOrgDocTypes(params, session) {
|
|
2448
2539
|
const self = this;
|
|
2449
2540
|
|
|
2450
2541
|
try {
|
|
2451
|
-
Joi__default["default"].assert(params, Joi__default["default"].object().required()
|
|
2452
|
-
Joi__default["default"].assert(params.
|
|
2453
|
-
Joi__default["default"].assert(params.
|
|
2454
|
-
Joi__default["default"].assert(
|
|
2455
|
-
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2542
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
2543
|
+
Joi__default["default"].assert(params.docTypeId, Joi__default["default"].string().required());
|
|
2544
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required());
|
|
2545
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
2456
2546
|
|
|
2457
|
-
const {
|
|
2458
|
-
const apiCall = self._client.get(`/organizations/${orgId}/
|
|
2547
|
+
const {docTypeId, orgId} = params;
|
|
2548
|
+
const apiCall = self._client.get(`/organizations/${orgId}/doctype/${docTypeId}`, self._setHeader(session));
|
|
2459
2549
|
return self._returnData(await apiCall);
|
|
2460
2550
|
} catch (ex) {
|
|
2461
2551
|
throw ex;
|
|
@@ -2463,65 +2553,115 @@ class Process {
|
|
|
2463
2553
|
}
|
|
2464
2554
|
|
|
2465
2555
|
/**
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
* };
|
|
2486
|
-
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2487
|
-
* const result = await api.user.process.downloadDocs(params, session);
|
|
2488
|
-
*/
|
|
2489
|
-
async downloadDocs(params, session) {
|
|
2556
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2557
|
+
* @description Get Org Groups
|
|
2558
|
+
* @param {object} params Params to get Org Groups
|
|
2559
|
+
* @param {string} params.orgId Organization id (_id database);
|
|
2560
|
+
* @param {string} session Session, token JWT
|
|
2561
|
+
* @return {Promise}
|
|
2562
|
+
* @public
|
|
2563
|
+
* @async
|
|
2564
|
+
* @example
|
|
2565
|
+
*
|
|
2566
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2567
|
+
* const api = new API();
|
|
2568
|
+
* const params = {
|
|
2569
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2570
|
+
* }
|
|
2571
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2572
|
+
* await api.user.process.getOrgGroups(params, session);
|
|
2573
|
+
*/
|
|
2574
|
+
async getOrgGroups(params, session) {
|
|
2490
2575
|
const self = this;
|
|
2491
2576
|
|
|
2492
2577
|
try {
|
|
2493
|
-
Joi__default["default"].assert(params, Joi__default["default"].object().required()
|
|
2494
|
-
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required()
|
|
2495
|
-
Joi__default["default"].assert(
|
|
2496
|
-
Joi__default["default"].assert(params.docIds, Joi__default["default"].array().required(), 'Document Ids');
|
|
2497
|
-
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2578
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
2579
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required());
|
|
2580
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
2498
2581
|
|
|
2499
|
-
const {orgId
|
|
2500
|
-
const
|
|
2501
|
-
|
|
2502
|
-
|
|
2582
|
+
const {orgId} = params;
|
|
2583
|
+
const apiCall = self._client.get(`/organizations/${orgId}/groups`, self._setHeader(session));
|
|
2584
|
+
return self._returnData(await apiCall);
|
|
2585
|
+
} catch (ex) {
|
|
2586
|
+
throw ex;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2503
2589
|
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2590
|
+
/**
|
|
2591
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2592
|
+
* @description Get Org Users
|
|
2593
|
+
* @param {object} params Params to get Org Users
|
|
2594
|
+
* @param {string} params.orgId Organization id (_id database);
|
|
2595
|
+
* @param {array} params.userIds UserIds
|
|
2596
|
+
* @param {string} session Session, token JWT
|
|
2597
|
+
* @return {Promise}
|
|
2598
|
+
* @public
|
|
2599
|
+
* @async
|
|
2600
|
+
* @example
|
|
2601
|
+
*
|
|
2602
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2603
|
+
* const api = new API();
|
|
2604
|
+
* const params = {
|
|
2605
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2606
|
+
* userIds: []
|
|
2607
|
+
* }
|
|
2608
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2609
|
+
* await api.user.process.getOrgUsers(params, session);
|
|
2610
|
+
*/
|
|
2611
|
+
async getOrgUsers(params, session) {
|
|
2612
|
+
const self = this;
|
|
2507
2613
|
|
|
2508
|
-
|
|
2509
|
-
|
|
2614
|
+
try {
|
|
2615
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
2616
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required());
|
|
2617
|
+
Joi__default["default"].assert(params.userIds, Joi__default["default"].array().required());
|
|
2618
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
2510
2619
|
|
|
2620
|
+
const {orgId, userIds} = params;
|
|
2621
|
+
let queryString = '';
|
|
2622
|
+
if(!___default["default"].isEmpty(userIds)) {
|
|
2623
|
+
queryString = `?userIds=${JSON.stringify(userIds)}&{"sort":{"name":1}}`;
|
|
2624
|
+
}
|
|
2625
|
+
const apiCall = self._client.get(`/admin/organizations/${orgId}/orgusers${queryString}`, self._setHeader(session));
|
|
2511
2626
|
return self._returnData(await apiCall);
|
|
2512
2627
|
} catch (ex) {
|
|
2513
2628
|
throw ex;
|
|
2514
2629
|
}
|
|
2515
2630
|
}
|
|
2516
2631
|
|
|
2632
|
+
/**
|
|
2633
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2634
|
+
* @description Get step history of a process flow
|
|
2635
|
+
* @param {object} params Params to get step history
|
|
2636
|
+
* @param {string} params.orgId Organization id (_id database);
|
|
2637
|
+
* @param {string} params.processId Process id (_id database);
|
|
2638
|
+
* @param {string} params.flowId Flow id;
|
|
2639
|
+
* @param {string} session Session, token JWT
|
|
2640
|
+
* @return {Promise<Array>} Array of step history entries
|
|
2641
|
+
* @public
|
|
2642
|
+
* @async
|
|
2643
|
+
* @example
|
|
2644
|
+
*
|
|
2645
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
2646
|
+
* const api = new API();
|
|
2647
|
+
* const params = {
|
|
2648
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2649
|
+
* processId: '5dadd01dc4af3941d42f8c5c',
|
|
2650
|
+
* flowId: 'Task_18v1xx7'
|
|
2651
|
+
* }
|
|
2652
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2653
|
+
* const stepHistory = await api.user.process.getStepHistory(params, session);
|
|
2654
|
+
*/
|
|
2517
2655
|
/**
|
|
2518
2656
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2519
|
-
* @description
|
|
2520
|
-
*
|
|
2521
|
-
* @param {
|
|
2657
|
+
* @description Restart a finished process from a specific flow step. Resets the process completion state
|
|
2658
|
+
* and triggers re-execution from the specified flow name.
|
|
2659
|
+
* @param {object} params Params to restart the process
|
|
2660
|
+
* @param {string} params.processId Process id (_id database);
|
|
2522
2661
|
* @param {string} params.orgId Organization id (_id database);
|
|
2662
|
+
* @param {string} params.flowName The flow name of the step to restart from;
|
|
2523
2663
|
* @param {string} session Session, token JWT
|
|
2524
|
-
* @return {Promise}
|
|
2664
|
+
* @return {Promise<object>} { response: 'OK' } on success
|
|
2525
2665
|
* @public
|
|
2526
2666
|
* @async
|
|
2527
2667
|
* @example
|
|
@@ -2529,36 +2669,41 @@ class Process {
|
|
|
2529
2669
|
* const API = require('@docbrasil/api-systemmanager');
|
|
2530
2670
|
* const api = new API();
|
|
2531
2671
|
* const params = {
|
|
2532
|
-
*
|
|
2672
|
+
* processId: '5dadd01dc4af3941d42f8c5c',
|
|
2533
2673
|
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2534
|
-
*
|
|
2674
|
+
* flowName: 'Task_1'
|
|
2675
|
+
* };
|
|
2535
2676
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2536
|
-
* await api.user.process.
|
|
2677
|
+
* await api.user.process.restart(params, session);
|
|
2537
2678
|
*/
|
|
2538
|
-
|
|
2539
|
-
|
|
2679
|
+
async restart(params, session) {
|
|
2680
|
+
const self = this;
|
|
2540
2681
|
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2682
|
+
try {
|
|
2683
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to restart the process');
|
|
2684
|
+
Joi__default["default"].assert(params.processId, Joi__default["default"].string().required(), 'Process id (_id database)');
|
|
2685
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
2686
|
+
Joi__default["default"].assert(params.flowName, Joi__default["default"].string().required(), 'Flow name of the step');
|
|
2687
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2546
2688
|
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
}
|
|
2689
|
+
const {processId, orgId, flowName} = params;
|
|
2690
|
+
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}/restart/${flowName}`, {}, self._setHeader(session));
|
|
2691
|
+
return self._returnData(await apiCall);
|
|
2692
|
+
} catch (ex) {
|
|
2693
|
+
throw ex;
|
|
2553
2694
|
}
|
|
2695
|
+
}
|
|
2554
2696
|
|
|
2555
|
-
|
|
2697
|
+
/**
|
|
2556
2698
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2557
|
-
* @description
|
|
2558
|
-
*
|
|
2699
|
+
* @description Re-execute a specific flow step in a running process. Unlike restart, this does not
|
|
2700
|
+
* reset the process completion state. Task creation is deferred to the BPMN engine via RabbitMQ.
|
|
2701
|
+
* @param {object} params Params to re-execute the process step
|
|
2702
|
+
* @param {string} params.processId Process id (_id database);
|
|
2559
2703
|
* @param {string} params.orgId Organization id (_id database);
|
|
2704
|
+
* @param {string} params.flowName The flow name of the step to re-execute;
|
|
2560
2705
|
* @param {string} session Session, token JWT
|
|
2561
|
-
* @return {Promise}
|
|
2706
|
+
* @return {Promise<object>} { response: 'OK' } on success
|
|
2562
2707
|
* @public
|
|
2563
2708
|
* @async
|
|
2564
2709
|
* @example
|
|
@@ -2566,35 +2711,42 @@ class Process {
|
|
|
2566
2711
|
* const API = require('@docbrasil/api-systemmanager');
|
|
2567
2712
|
* const api = new API();
|
|
2568
2713
|
* const params = {
|
|
2714
|
+
* processId: '5dadd01dc4af3941d42f8c5c',
|
|
2569
2715
|
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2570
|
-
*
|
|
2716
|
+
* flowName: 'Task_1'
|
|
2717
|
+
* };
|
|
2571
2718
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2572
|
-
* await api.user.process.
|
|
2719
|
+
* await api.user.process.reexecute(params, session);
|
|
2573
2720
|
*/
|
|
2574
|
-
|
|
2575
|
-
|
|
2721
|
+
async reexecute(params, session) {
|
|
2722
|
+
const self = this;
|
|
2576
2723
|
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2724
|
+
try {
|
|
2725
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to re-execute the process step');
|
|
2726
|
+
Joi__default["default"].assert(params.processId, Joi__default["default"].string().required(), 'Process id (_id database)');
|
|
2727
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
2728
|
+
Joi__default["default"].assert(params.flowName, Joi__default["default"].string().required(), 'Flow name of the step');
|
|
2729
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2581
2730
|
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
}
|
|
2731
|
+
const {processId, orgId, flowName} = params;
|
|
2732
|
+
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}/reexecute/${flowName}`, {}, self._setHeader(session));
|
|
2733
|
+
return self._returnData(await apiCall);
|
|
2734
|
+
} catch (ex) {
|
|
2735
|
+
throw ex;
|
|
2588
2736
|
}
|
|
2737
|
+
}
|
|
2589
2738
|
|
|
2590
|
-
|
|
2739
|
+
/**
|
|
2591
2740
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
2592
|
-
* @description
|
|
2593
|
-
*
|
|
2741
|
+
* @description Re-execute a specific user task step in a running process, creating a new task
|
|
2742
|
+
* synchronously with optional userId reassignment. For non-group tasks, the task is reassigned
|
|
2743
|
+
* to the current logged-in user. For group tasks, the original assignment is preserved.
|
|
2744
|
+
* @param {object} params Params to re-execute the task
|
|
2745
|
+
* @param {string} params.processId Process id (_id database);
|
|
2594
2746
|
* @param {string} params.orgId Organization id (_id database);
|
|
2595
|
-
* @param {
|
|
2747
|
+
* @param {string} params.flowName The flow name of the user task step to re-execute;
|
|
2596
2748
|
* @param {string} session Session, token JWT
|
|
2597
|
-
* @return {Promise}
|
|
2749
|
+
* @return {Promise<object>} { response: 'OK', taskId } on success
|
|
2598
2750
|
* @public
|
|
2599
2751
|
* @async
|
|
2600
2752
|
* @example
|
|
@@ -2602,73 +2754,49 @@ class Process {
|
|
|
2602
2754
|
* const API = require('@docbrasil/api-systemmanager');
|
|
2603
2755
|
* const api = new API();
|
|
2604
2756
|
* const params = {
|
|
2757
|
+
* processId: '5dadd01dc4af3941d42f8c5c',
|
|
2605
2758
|
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2606
|
-
*
|
|
2607
|
-
* }
|
|
2759
|
+
* flowName: 'Task_1'
|
|
2760
|
+
* };
|
|
2608
2761
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2609
|
-
* await api.user.process.
|
|
2762
|
+
* const result = await api.user.process.reexecuteTask(params, session);
|
|
2763
|
+
* console.log(result.taskId);
|
|
2610
2764
|
*/
|
|
2611
|
-
|
|
2612
|
-
|
|
2765
|
+
async reexecuteTask(params, session) {
|
|
2766
|
+
const self = this;
|
|
2613
2767
|
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2768
|
+
try {
|
|
2769
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to re-execute the task');
|
|
2770
|
+
Joi__default["default"].assert(params.processId, Joi__default["default"].string().required(), 'Process id (_id database)');
|
|
2771
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
2772
|
+
Joi__default["default"].assert(params.flowName, Joi__default["default"].string().required(), 'Flow name of the user task step');
|
|
2773
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
2619
2774
|
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
const apiCall = self._client.get(`/admin/organizations/${orgId}/orgusers${queryString}`, self._setHeader(session));
|
|
2626
|
-
return self._returnData(await apiCall);
|
|
2627
|
-
} catch (ex) {
|
|
2628
|
-
throw ex;
|
|
2629
|
-
}
|
|
2775
|
+
const {processId, orgId, flowName} = params;
|
|
2776
|
+
const apiCall = self._client.put(`/organizations/${orgId}/process/${processId}/reexecutetask/${flowName}`, {}, self._setHeader(session));
|
|
2777
|
+
return self._returnData(await apiCall);
|
|
2778
|
+
} catch (ex) {
|
|
2779
|
+
throw ex;
|
|
2630
2780
|
}
|
|
2781
|
+
}
|
|
2631
2782
|
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
* @description Get step history of a process flow
|
|
2635
|
-
* @param {object} params Params to get step history
|
|
2636
|
-
* @param {string} params.orgId Organization id (_id database);
|
|
2637
|
-
* @param {string} params.processId Process id (_id database);
|
|
2638
|
-
* @param {string} params.flowId Flow id;
|
|
2639
|
-
* @param {string} session Session, token JWT
|
|
2640
|
-
* @return {Promise<Array>} Array of step history entries
|
|
2641
|
-
* @public
|
|
2642
|
-
* @async
|
|
2643
|
-
* @example
|
|
2644
|
-
*
|
|
2645
|
-
* const API = require('@docbrasil/api-systemmanager');
|
|
2646
|
-
* const api = new API();
|
|
2647
|
-
* const params = {
|
|
2648
|
-
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
2649
|
-
* processId: '5dadd01dc4af3941d42f8c5c',
|
|
2650
|
-
* flowId: 'Task_18v1xx7'
|
|
2651
|
-
* }
|
|
2652
|
-
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2653
|
-
* const stepHistory = await api.user.process.getStepHistory(params, session);
|
|
2654
|
-
*/
|
|
2655
|
-
async getStepHistory(params, session) {
|
|
2656
|
-
const self = this;
|
|
2783
|
+
async getStepHistory(params, session) {
|
|
2784
|
+
const self = this;
|
|
2657
2785
|
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2786
|
+
try {
|
|
2787
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
2788
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required());
|
|
2789
|
+
Joi__default["default"].assert(params.processId, Joi__default["default"].string().required());
|
|
2790
|
+
Joi__default["default"].assert(params.flowId, Joi__default["default"].string().required());
|
|
2791
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
2664
2792
|
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
}
|
|
2793
|
+
const {orgId, processId, flowId} = params;
|
|
2794
|
+
const apiCall = self._client.get(`/organizations/${orgId}/process/${processId}/flow/${flowId}/history`, self._setHeader(session));
|
|
2795
|
+
return self._returnData(await apiCall, []);
|
|
2796
|
+
} catch (ex) {
|
|
2797
|
+
throw ex;
|
|
2671
2798
|
}
|
|
2799
|
+
}
|
|
2672
2800
|
}
|
|
2673
2801
|
|
|
2674
2802
|
/**
|
|
@@ -16409,6 +16537,89 @@ class AISession {
|
|
|
16409
16537
|
throw ex;
|
|
16410
16538
|
}
|
|
16411
16539
|
}
|
|
16540
|
+
/**
|
|
16541
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
16542
|
+
* @description Add documents to an existing agent session.
|
|
16543
|
+
* The agent will handle the documentIds accordingly.
|
|
16544
|
+
* @param {object} params Parameters
|
|
16545
|
+
* @param {string} params.sessionId The session ID
|
|
16546
|
+
* @param {array<string>} params.documentIds Array of document IDs to add
|
|
16547
|
+
* @param {string} authorization Authorization token
|
|
16548
|
+
* @return {Promise<object>} data The result from the agent
|
|
16549
|
+
* @public
|
|
16550
|
+
* @async
|
|
16551
|
+
* @example
|
|
16552
|
+
*
|
|
16553
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
16554
|
+
* const api = new API();
|
|
16555
|
+
* const authorization = '...';
|
|
16556
|
+
* const params = {
|
|
16557
|
+
* sessionId: 'session-abc-123',
|
|
16558
|
+
* documentIds: ['doc-123', 'doc-456']
|
|
16559
|
+
* };
|
|
16560
|
+
* const retData = await api.ai.sessions.addDocuments(params, authorization);
|
|
16561
|
+
*/
|
|
16562
|
+
async addDocuments(params, authorization) {
|
|
16563
|
+
const self = this;
|
|
16564
|
+
|
|
16565
|
+
try {
|
|
16566
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
16567
|
+
Joi__default["default"].assert(params.sessionId, Joi__default["default"].string().required().error(new Error('sessionId is required')));
|
|
16568
|
+
Joi__default["default"].assert(params.documentIds, Joi__default["default"].array().items(Joi__default["default"].string()).min(1).required().error(new Error('documentIds is required and must be a non-empty array')));
|
|
16569
|
+
|
|
16570
|
+
const { sessionId, documentIds } = params;
|
|
16571
|
+
|
|
16572
|
+
const client = self.parent.dispatch.getAkamaiClient();
|
|
16573
|
+
const apiCall = client
|
|
16574
|
+
.post(`/agents/${sessionId}/documents/add`, { documentIds }, self._setHeader(authorization));
|
|
16575
|
+
|
|
16576
|
+
return self._returnData(await apiCall);
|
|
16577
|
+
} catch (ex) {
|
|
16578
|
+
throw ex;
|
|
16579
|
+
}
|
|
16580
|
+
}
|
|
16581
|
+
|
|
16582
|
+
/**
|
|
16583
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
16584
|
+
* @description Remove documents from an existing agent session.
|
|
16585
|
+
* The agent will handle the documentIds accordingly.
|
|
16586
|
+
* @param {object} params Parameters
|
|
16587
|
+
* @param {string} params.sessionId The session ID
|
|
16588
|
+
* @param {array<string>} params.documentIds Array of document IDs to remove
|
|
16589
|
+
* @param {string} authorization Authorization token
|
|
16590
|
+
* @return {Promise<object>} data The result from the agent
|
|
16591
|
+
* @public
|
|
16592
|
+
* @async
|
|
16593
|
+
* @example
|
|
16594
|
+
*
|
|
16595
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
16596
|
+
* const api = new API();
|
|
16597
|
+
* const authorization = '...';
|
|
16598
|
+
* const params = {
|
|
16599
|
+
* sessionId: 'session-abc-123',
|
|
16600
|
+
* documentIds: ['doc-123', 'doc-456']
|
|
16601
|
+
* };
|
|
16602
|
+
* const retData = await api.ai.sessions.removeDocuments(params, authorization);
|
|
16603
|
+
*/
|
|
16604
|
+
async removeDocuments(params, authorization) {
|
|
16605
|
+
const self = this;
|
|
16606
|
+
|
|
16607
|
+
try {
|
|
16608
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
16609
|
+
Joi__default["default"].assert(params.sessionId, Joi__default["default"].string().required().error(new Error('sessionId is required')));
|
|
16610
|
+
Joi__default["default"].assert(params.documentIds, Joi__default["default"].array().items(Joi__default["default"].string()).min(1).required().error(new Error('documentIds is required and must be a non-empty array')));
|
|
16611
|
+
|
|
16612
|
+
const { sessionId, documentIds } = params;
|
|
16613
|
+
|
|
16614
|
+
const client = self.parent.dispatch.getAkamaiClient();
|
|
16615
|
+
const apiCall = client
|
|
16616
|
+
.post(`/agents/${sessionId}/documents/remove`, { documentIds }, self._setHeader(authorization));
|
|
16617
|
+
|
|
16618
|
+
return self._returnData(await apiCall);
|
|
16619
|
+
} catch (ex) {
|
|
16620
|
+
throw ex;
|
|
16621
|
+
}
|
|
16622
|
+
}
|
|
16412
16623
|
}
|
|
16413
16624
|
|
|
16414
16625
|
/**
|