@docbrasil/api-systemmanager 1.1.22 → 1.1.23

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/admin/form.js CHANGED
@@ -47,6 +47,32 @@ class AdminForm {
47
47
  };
48
48
  }
49
49
 
50
+ /**
51
+ * @author Myndware <augusto.pissarra@myndware.com>
52
+ * @description Get the types for forms
53
+ * @return {Promise}
54
+ * @public
55
+ * @async
56
+ * @example
57
+ *
58
+ * const API = require('@docbrasil/api-systemmanager');
59
+ * const api = new API();
60
+ * const params = {
61
+ * id: '55e4a3bd6be6b45210833fae',
62
+ * orgId: '5edd11c46b6ce9729c2c297c',
63
+ * };
64
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
65
+ * await api.admin.form.findById(params, session);
66
+ */
67
+ get types() {
68
+ return {
69
+ BUSINESS: 1,
70
+ ADVANCED: 2,
71
+ CHECKLIST: 3,
72
+ EXTERNAL: 4
73
+ };
74
+ }
75
+
50
76
  /**
51
77
  * @author Myndware <augusto.pissarra@myndware.com>
52
78
  * @description Get advance form by ID
@@ -122,7 +148,6 @@ class AdminForm {
122
148
  Joi.assert(params.sort, Joi.object(), 'Sort fields for');
123
149
  Joi.assert(session, Joi.string().required(), 'Session, token JWT');
124
150
 
125
- const FORM_ADVANCED = 2;
126
151
  const PROJECTION_DEFAULT = {_id: 1, name: 1};
127
152
  const SORT_DEFAULT = {name: 1};
128
153
 
@@ -130,7 +155,7 @@ class AdminForm {
130
155
  orgId,
131
156
  page = 1,
132
157
  perPage = 200,
133
- type = FORM_ADVANCED,
158
+ type = self.types.ADVANCED,
134
159
  project = PROJECTION_DEFAULT,
135
160
  sort = SORT_DEFAULT
136
161
  } = params;
package/api/admin/user.js CHANGED
@@ -272,6 +272,61 @@ class AdminUser {
272
272
  throw ex;
273
273
  }
274
274
  }
275
+
276
+ /**
277
+ * @author Myndware <augusto.pissarra@myndware.com>
278
+ * @description Request signed url url to put or get
279
+ * @param {object} params - Params to get form list
280
+ * @param {number} params.page=1 - Page of pagination
281
+ * @param {number} params.perPage=200 - Items per page
282
+ * @param {object} params.project={_id: 1, name: 1} - Fields to project
283
+ * @param {object} params.sort={name: 1} - Sort fields
284
+ * @param {string} session - Session, token JWT
285
+ * @return {Promise}
286
+ * @public
287
+ * @async
288
+ * @example
289
+ *
290
+ * const API = require('@docbrasil/api-systemmanager');
291
+ * const api = new API();
292
+ * const params - {
293
+ * project: {_id: 1, name: 1, orgId: 1, orgIds: 1},
294
+ * };
295
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
296
+ * await api.user.form.getUserList(params, session);
297
+ */
298
+ async getUserList(params, session) {
299
+ const self = this;
300
+
301
+ try {
302
+ Joi.assert(params, Joi.object().required(), 'Params to get form list');
303
+ Joi.assert(params.page, Joi.number(), 'Page of pagination');
304
+ Joi.assert(params.perPage, Joi.number(), 'Items per page');
305
+ Joi.assert(params.project, Joi.object(), 'Fields to project');
306
+ Joi.assert(params.sort, Joi.object(), 'Sort fields for');
307
+ Joi.assert(session, Joi.string().required(), 'Session, token JWT');
308
+
309
+ const PROJECTION_DEFAULT = {_id: 1, name: 1};
310
+ const SORT_DEFAULT = {name: 1};
311
+
312
+ const {
313
+ page = 1,
314
+ perPage = 200,
315
+ project = PROJECTION_DEFAULT,
316
+ sort = SORT_DEFAULT
317
+ } = params;
318
+
319
+ const payloadToSend = {$project: project, sort};
320
+
321
+ const apiCall = self._client
322
+ .post(`/admin/users?page=${page}&perPage=${perPage}`, payloadToSend, self._setHeader(session));
323
+
324
+ return self._returnData(await apiCall);
325
+
326
+ } catch (ex) {
327
+ throw ex;
328
+ }
329
+ }
275
330
  }
276
331
 
277
332
  export default AdminUser;
package/api/user/user.js CHANGED
@@ -289,7 +289,6 @@ class User {
289
289
  * @param {object} query={} The query, if any, to add to the JWT token
290
290
  * @param {array<string>} query.orgIds An array of orgIds that we want to filter by
291
291
  * @param {array<string>} query.orgProcessIds An array of orgProcessId that we want to filter by
292
- * @param {array<string>} query.tags An array of org processes tags that we want to filter by
293
292
  * @param {date} query.startDate The start date in ISO format that we want to filter by
294
293
  * @param {date} query.endDate The start date in ISO format that we want to filter by
295
294
  * @param {string} session Is token JWT of user NOT allow SU
package/dist/bundle.cjs CHANGED
@@ -3121,7 +3121,6 @@ class User {
3121
3121
  * @param {object} query={} The query, if any, to add to the JWT token
3122
3122
  * @param {array<string>} query.orgIds An array of orgIds that we want to filter by
3123
3123
  * @param {array<string>} query.orgProcessIds An array of orgProcessId that we want to filter by
3124
- * @param {array<string>} query.tags An array of org processes tags that we want to filter by
3125
3124
  * @param {date} query.startDate The start date in ISO format that we want to filter by
3126
3125
  * @param {date} query.endDate The start date in ISO format that we want to filter by
3127
3126
  * @param {string} session Is token JWT of user NOT allow SU
@@ -11405,6 +11404,32 @@ class AdminForm {
11405
11404
  };
11406
11405
  }
11407
11406
 
11407
+ /**
11408
+ * @author Myndware <augusto.pissarra@myndware.com>
11409
+ * @description Get the types for forms
11410
+ * @return {Promise}
11411
+ * @public
11412
+ * @async
11413
+ * @example
11414
+ *
11415
+ * const API = require('@docbrasil/api-systemmanager');
11416
+ * const api = new API();
11417
+ * const params = {
11418
+ * id: '55e4a3bd6be6b45210833fae',
11419
+ * orgId: '5edd11c46b6ce9729c2c297c',
11420
+ * };
11421
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11422
+ * await api.admin.form.findById(params, session);
11423
+ */
11424
+ get types() {
11425
+ return {
11426
+ BUSINESS: 1,
11427
+ ADVANCED: 2,
11428
+ CHECKLIST: 3,
11429
+ EXTERNAL: 4
11430
+ };
11431
+ }
11432
+
11408
11433
  /**
11409
11434
  * @author Myndware <augusto.pissarra@myndware.com>
11410
11435
  * @description Get advance form by ID
@@ -11480,7 +11505,6 @@ class AdminForm {
11480
11505
  Joi__default["default"].assert(params.sort, Joi__default["default"].object(), 'Sort fields for');
11481
11506
  Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session, token JWT');
11482
11507
 
11483
- const FORM_ADVANCED = 2;
11484
11508
  const PROJECTION_DEFAULT = {_id: 1, name: 1};
11485
11509
  const SORT_DEFAULT = {name: 1};
11486
11510
 
@@ -11488,7 +11512,7 @@ class AdminForm {
11488
11512
  orgId,
11489
11513
  page = 1,
11490
11514
  perPage = 200,
11491
- type = FORM_ADVANCED,
11515
+ type = self.types.ADVANCED,
11492
11516
  project = PROJECTION_DEFAULT,
11493
11517
  sort = SORT_DEFAULT
11494
11518
  } = params;
@@ -12436,6 +12460,61 @@ class AdminUser {
12436
12460
  throw ex;
12437
12461
  }
12438
12462
  }
12463
+
12464
+ /**
12465
+ * @author Myndware <augusto.pissarra@myndware.com>
12466
+ * @description Request signed url url to put or get
12467
+ * @param {object} params - Params to get form list
12468
+ * @param {number} params.page=1 - Page of pagination
12469
+ * @param {number} params.perPage=200 - Items per page
12470
+ * @param {object} params.project={_id: 1, name: 1} - Fields to project
12471
+ * @param {object} params.sort={name: 1} - Sort fields
12472
+ * @param {string} session - Session, token JWT
12473
+ * @return {Promise}
12474
+ * @public
12475
+ * @async
12476
+ * @example
12477
+ *
12478
+ * const API = require('@docbrasil/api-systemmanager');
12479
+ * const api = new API();
12480
+ * const params - {
12481
+ * project: {_id: 1, name: 1, orgId: 1, orgIds: 1},
12482
+ * };
12483
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
12484
+ * await api.user.form.getUserList(params, session);
12485
+ */
12486
+ async getUserList(params, session) {
12487
+ const self = this;
12488
+
12489
+ try {
12490
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get form list');
12491
+ Joi__default["default"].assert(params.page, Joi__default["default"].number(), 'Page of pagination');
12492
+ Joi__default["default"].assert(params.perPage, Joi__default["default"].number(), 'Items per page');
12493
+ Joi__default["default"].assert(params.project, Joi__default["default"].object(), 'Fields to project');
12494
+ Joi__default["default"].assert(params.sort, Joi__default["default"].object(), 'Sort fields for');
12495
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session, token JWT');
12496
+
12497
+ const PROJECTION_DEFAULT = {_id: 1, name: 1};
12498
+ const SORT_DEFAULT = {name: 1};
12499
+
12500
+ const {
12501
+ page = 1,
12502
+ perPage = 200,
12503
+ project = PROJECTION_DEFAULT,
12504
+ sort = SORT_DEFAULT
12505
+ } = params;
12506
+
12507
+ const payloadToSend = {$project: project, sort};
12508
+
12509
+ const apiCall = self._client
12510
+ .post(`/admin/users?page=${page}&perPage=${perPage}`, payloadToSend, self._setHeader(session));
12511
+
12512
+ return self._returnData(await apiCall);
12513
+
12514
+ } catch (ex) {
12515
+ throw ex;
12516
+ }
12517
+ }
12439
12518
  }
12440
12519
 
12441
12520
  /**