@docbrasil/api-systemmanager 1.0.112 → 1.0.113
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/process.js +41 -0
- package/dist/bundle.cjs +41 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +74 -0
- package/docs/AdminUser.html +420 -0
- package/docs/Process.html +1272 -217
- package/docs/admin_user.js.html +65 -3
- package/docs/user_process.js.html +156 -0
- package/package.json +1 -1
package/docs/admin_user.js.html
CHANGED
|
@@ -113,7 +113,7 @@ class AdminUser {
|
|
|
113
113
|
*/
|
|
114
114
|
_returnData(retData, def = {}) {
|
|
115
115
|
if (retData.status !== 200) {
|
|
116
|
-
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
116
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'));
|
|
117
117
|
} else {
|
|
118
118
|
return _.get(retData, 'data', def);
|
|
119
119
|
}
|
|
@@ -198,7 +198,7 @@ class AdminUser {
|
|
|
198
198
|
Joi.assert(params.newPassword, Joi.string().required());
|
|
199
199
|
Joi.assert(session, Joi.string().required());
|
|
200
200
|
|
|
201
|
-
const {userId, ...payload} = params;
|
|
201
|
+
const { userId, ...payload } = params;
|
|
202
202
|
const apiCall = self.client.put(`/admin/users/${userId}/password`, payload, self._setHeader(session));
|
|
203
203
|
return self._returnData(await apiCall);
|
|
204
204
|
} catch (ex) {
|
|
@@ -228,7 +228,7 @@ class AdminUser {
|
|
|
228
228
|
Joi.assert(email, Joi.string().email().required());
|
|
229
229
|
Joi.assert(session, Joi.string().required());
|
|
230
230
|
|
|
231
|
-
const payload = {email};
|
|
231
|
+
const payload = { email };
|
|
232
232
|
const apiCall = self.client.post(`/admin/users/email/exist`, payload, self._setHeader(session));
|
|
233
233
|
return self._returnData(await apiCall);
|
|
234
234
|
} catch (ex) {
|
|
@@ -267,6 +267,68 @@ class AdminUser {
|
|
|
267
267
|
throw ex;
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @description Request GUID to change the password
|
|
273
|
+
* @param {string} email - User email
|
|
274
|
+
* @returns {Promise<*>}
|
|
275
|
+
* @async
|
|
276
|
+
* @public
|
|
277
|
+
* @example
|
|
278
|
+
*
|
|
279
|
+
* const payload = {
|
|
280
|
+
* email: 'maria@gmail.com'
|
|
281
|
+
* };
|
|
282
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
283
|
+
*/
|
|
284
|
+
async getChangePasswordGuid(email, session) {
|
|
285
|
+
const self = this;
|
|
286
|
+
|
|
287
|
+
try {
|
|
288
|
+
Joi.assert(email, Joi.string().required(), 'User email');
|
|
289
|
+
Joi.assert(session, Joi.string().required(), 'Session user admin');
|
|
290
|
+
|
|
291
|
+
const payload = { email };
|
|
292
|
+
const apiCall = self.client.post('/admin/users/change/password', payload, self._setHeader(session));
|
|
293
|
+
|
|
294
|
+
return self._returnData(await apiCall);
|
|
295
|
+
} catch (ex) {
|
|
296
|
+
throw ex;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @description Change password guid
|
|
302
|
+
* @param {object} Payload - Payload to change password
|
|
303
|
+
* @param {string} Payload.guid - GUID
|
|
304
|
+
* @param {string} Payload.newPassword - New password
|
|
305
|
+
* @returns {Promise<*>}
|
|
306
|
+
* @async
|
|
307
|
+
* @public
|
|
308
|
+
* @example
|
|
309
|
+
*
|
|
310
|
+
* const payload = {
|
|
311
|
+
* guid: '5b3c049c-4861-4353-a423-5e3f14242642',
|
|
312
|
+
* newPassword: '123456789'
|
|
313
|
+
* };
|
|
314
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
315
|
+
*/
|
|
316
|
+
async changePasswordGuid(payload, session) {
|
|
317
|
+
const self = this;
|
|
318
|
+
|
|
319
|
+
try {
|
|
320
|
+
Joi.assert(payload, Joi.object().required(), 'Payload to change password');
|
|
321
|
+
Joi.assert(payload.guid, Joi.string().required(), 'GUID');
|
|
322
|
+
Joi.assert(payload.newPassword, Joi.string().required(), 'New password');
|
|
323
|
+
Joi.assert(session, Joi.string().required(), 'Session user admin');
|
|
324
|
+
|
|
325
|
+
const apiCall = self.client.put('/admin/users/change/password', payload, self._setHeader(session));
|
|
326
|
+
|
|
327
|
+
return self._returnData(await apiCall);
|
|
328
|
+
} catch (ex) {
|
|
329
|
+
throw ex;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
270
332
|
}
|
|
271
333
|
|
|
272
334
|
export default AdminUser;
|
|
@@ -317,6 +317,162 @@ class Process {
|
|
|
317
317
|
throw ex;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
323
|
+
* @description Method to remove process
|
|
324
|
+
* @param {object} params Params to remove process
|
|
325
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
326
|
+
* @param {object} params.processId Process id (_id database)
|
|
327
|
+
* @param {string} session Session, token JWT
|
|
328
|
+
* @public
|
|
329
|
+
* @example
|
|
330
|
+
*
|
|
331
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
332
|
+
* const api = new API();
|
|
333
|
+
* const params = {
|
|
334
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
335
|
+
* processId: '55e4a3bd6be6b45210833fae'
|
|
336
|
+
* };
|
|
337
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
338
|
+
* const retSearch = await api.user.process.remove(params, session);
|
|
339
|
+
*/
|
|
340
|
+
async remove(params, session) {
|
|
341
|
+
const self = this;
|
|
342
|
+
|
|
343
|
+
try {
|
|
344
|
+
Joi.assert(params, Joi.object().required(), 'Params to remove the process');
|
|
345
|
+
Joi.assert(params.processId, Joi.string().required(), 'Process id (_id database)');
|
|
346
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
347
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
348
|
+
|
|
349
|
+
const {processId, orgId} = params;
|
|
350
|
+
|
|
351
|
+
const apiCall = self._client.delete(`/organizations/${orgId}/process/${processId}`, self._setHeader(session));
|
|
352
|
+
return self._returnData(await apiCall);
|
|
353
|
+
} catch (ex) {
|
|
354
|
+
throw ex;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
360
|
+
* @description Method to export status data
|
|
361
|
+
* @param {object} params Params to export status data
|
|
362
|
+
* @param {object} params.query Search process query
|
|
363
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
364
|
+
* @param {string} session Session, token JWT
|
|
365
|
+
* @public
|
|
366
|
+
* @example
|
|
367
|
+
*
|
|
368
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
369
|
+
* const api = new API();
|
|
370
|
+
* const params = {
|
|
371
|
+
* query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
|
|
372
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
373
|
+
* };
|
|
374
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
375
|
+
* const retSearch = await api.user.process.exportStatusData(params, session);
|
|
376
|
+
*/
|
|
377
|
+
async exportStatusData(params, session) {
|
|
378
|
+
const self = this;
|
|
379
|
+
|
|
380
|
+
try {
|
|
381
|
+
Joi.assert(params, Joi.object().required(), 'Params to export status data');
|
|
382
|
+
Joi.assert(params.query, Joi.object().required(), 'The query for the search');
|
|
383
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
384
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
385
|
+
|
|
386
|
+
const {query, orgId} = params;
|
|
387
|
+
const queryString = JSON.stringify(query);
|
|
388
|
+
const apiCall = self._client
|
|
389
|
+
.get(`/organizations/${orgId}/process/export/status/data?query=${queryString}`, self._setHeader(session));
|
|
390
|
+
|
|
391
|
+
return self._returnData(await apiCall);
|
|
392
|
+
} catch (ex) {
|
|
393
|
+
throw ex;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
399
|
+
* @description Method to export process data
|
|
400
|
+
* @param {object} params Params to export process data
|
|
401
|
+
* @param {object} params.query Search process query
|
|
402
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
403
|
+
* @param {string} session Session, token JWT
|
|
404
|
+
* @public
|
|
405
|
+
* @example
|
|
406
|
+
*
|
|
407
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
408
|
+
* const api = new API();
|
|
409
|
+
* const params = {
|
|
410
|
+
* query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
|
|
411
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
412
|
+
* };
|
|
413
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
414
|
+
* const retSearch = await api.user.process.exportProcessData(params, session);
|
|
415
|
+
*/
|
|
416
|
+
async exportProcessData(params, session) {
|
|
417
|
+
const self = this;
|
|
418
|
+
|
|
419
|
+
try {
|
|
420
|
+
Joi.assert(params, Joi.object().required(), 'Params to export process data');
|
|
421
|
+
Joi.assert(params.query, Joi.object().required(), 'The query for the search');
|
|
422
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
423
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
424
|
+
|
|
425
|
+
const {query, orgId} = params;
|
|
426
|
+
const queryString = JSON.stringify(query);
|
|
427
|
+
const apiCall = self._client
|
|
428
|
+
.get(`/organizations/${orgId}/process/export/collect/data?query=${queryString}`, self._setHeader(session));
|
|
429
|
+
|
|
430
|
+
return self._returnData(await apiCall);
|
|
431
|
+
} catch (ex) {
|
|
432
|
+
throw ex;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
438
|
+
* @description Method to get Process Docs
|
|
439
|
+
* @param {object} params Params to get process docs
|
|
440
|
+
* @param {string} params.orgProcessId Organization Process Id
|
|
441
|
+
* @param {string} params.processId Process Id
|
|
442
|
+
* @param {string} params.orgId Organization id (_id database)
|
|
443
|
+
* @param {string} session Session, token JWT
|
|
444
|
+
* @returns {promise} returned data from the get process docs
|
|
445
|
+
* @returns {array<object>} Docs returned from process
|
|
446
|
+
* @public
|
|
447
|
+
* @example
|
|
448
|
+
*
|
|
449
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
450
|
+
* const api = new API();
|
|
451
|
+
* const params = {
|
|
452
|
+
* orgProcessId: '55e4a3bd6be6b45210833fae',
|
|
453
|
+
* processId: '55e4a3bd6be6b45210833fae',
|
|
454
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
455
|
+
* };
|
|
456
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
457
|
+
* const retSearch = await api.user.process.processDocs(params, session);
|
|
458
|
+
*/
|
|
459
|
+
async processDocs(params, session) {
|
|
460
|
+
const self = this;
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
Joi.assert(params, Joi.object().required(), 'Params to get process docs');
|
|
464
|
+
Joi.assert(params.orgProcessId, Joi.string().required(), 'Organization Process Id');
|
|
465
|
+
Joi.assert(params.processId, Joi.string().required(), 'Process Id');
|
|
466
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
467
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
468
|
+
|
|
469
|
+
const {orgProcessId, processId, orgId} = params;
|
|
470
|
+
const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/process/${processId}/documents`, self._setHeader(session));
|
|
471
|
+
return self._returnData(await apiCall);
|
|
472
|
+
} catch (ex) {
|
|
473
|
+
throw ex;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
320
476
|
}
|
|
321
477
|
|
|
322
478
|
export default Process;
|
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.0.
|
|
4
|
+
"version": "1.0.113",
|
|
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",
|