@docbrasil/api-systemmanager 1.1.22 → 1.1.24
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 +27 -2
- package/api/admin/user.js +55 -0
- package/api/user/dashboard.js +150 -0
- package/api/user/index.js +2 -0
- package/api/user/user.js +0 -1
- package/dist/bundle.cjs +87 -5
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +108 -1
- package/docs/Admin.html +1 -1
- package/docs/AdminDocuments.html +1 -1
- package/docs/AdminForm.html +104 -3
- package/docs/AdminLists.html +1 -1
- package/docs/AdminMessage.html +1 -1
- package/docs/AdminNotification.html +1 -1
- package/docs/AdminPlugin.html +1 -1
- package/docs/AdminPolicy.html +1 -1
- package/docs/AdminProcesses.html +1 -1
- package/docs/AdminTask.html +1 -1
- package/docs/AdminUser.html +350 -1
- package/docs/Application.html +1 -1
- package/docs/Chart.html +528 -0
- package/docs/Dashboard.html +349 -0
- package/docs/Datasource.html +1 -1
- package/docs/Dispatch.html +1 -1
- package/docs/Documents.html +1 -1
- package/docs/External.html +1 -1
- package/docs/GeoLocation.html +1 -1
- package/docs/Help.html +1 -1
- package/docs/Login.html +1 -1
- package/docs/MyTasks.html +1 -1
- package/docs/Notification.html +1 -1
- package/docs/Organization.html +1 -1
- package/docs/Page.html +1 -1
- package/docs/Process.html +1 -1
- package/docs/Register.html +1 -1
- package/docs/Session.html +1 -1
- package/docs/Settings.html +1 -1
- package/docs/Task.html +1 -1
- package/docs/TaskAvailable.html +1 -1
- package/docs/Updates.html +1 -1
- package/docs/User.html +4 -31
- package/docs/Users.html +2 -2
- package/docs/admin_doctypes.js.html +1 -1
- package/docs/admin_document.js.html +1 -1
- package/docs/admin_form.js.html +28 -3
- package/docs/admin_index.js.html +1 -1
- package/docs/admin_list.js.html +1 -1
- package/docs/admin_message.js.html +1 -1
- package/docs/admin_notification.js.html +1 -1
- package/docs/admin_organization.js.html +1 -1
- package/docs/admin_plugin.js.html +1 -1
- package/docs/admin_policy.js.html +1 -1
- package/docs/admin_processes.js.html +1 -1
- package/docs/admin_task.js.html +1 -1
- package/docs/admin_user.js.html +56 -1
- package/docs/dispatch.js.html +1 -1
- package/docs/external.js.html +1 -1
- package/docs/general_geoLocation.js.html +1 -1
- package/docs/general_index.js.html +1 -1
- package/docs/index.html +1 -1
- package/docs/login.js.html +1 -1
- package/docs/session.js.html +1 -1
- package/docs/user_application.js.html +1 -1
- package/docs/user_dashboard.js.html +267 -0
- package/docs/user_datasource.js.html +1 -1
- package/docs/user_document.js.html +1 -1
- package/docs/user_help.js.html +1 -1
- package/docs/user_index.js.html +3 -1
- package/docs/user_my_tasks.js.html +1 -1
- package/docs/user_notification.js.html +1 -1
- package/docs/user_organization.js.html +1 -1
- package/docs/user_page.js.html +1 -1
- package/docs/user_process.js.html +1 -1
- package/docs/user_register.js.html +1 -1
- package/docs/user_settings.js.html +1 -1
- package/docs/user_task.js.html +1 -1
- package/docs/user_task_available.js.html +1 -1
- package/docs/user_updates.js.html +1 -1
- package/docs/user_user.js.html +1 -2
- package/docs/utils_promises.js.html +1 -1
- package/package.json +1 -1
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 =
|
|
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;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class user access to charts
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class Chart {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
Joi.assert(options, Joi.object().required());
|
|
12
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
13
|
+
|
|
14
|
+
const self = this;
|
|
15
|
+
self.parent = options.parent;
|
|
16
|
+
self._client = self.parent.dispatch.getClient();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
21
|
+
* @description Get the return data and check for errors
|
|
22
|
+
* @param {object} retData Response HTTP
|
|
23
|
+
* @return {*}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
_returnData(retData, def = {}) {
|
|
27
|
+
if (retData.status !== 200) {
|
|
28
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
29
|
+
} else {
|
|
30
|
+
return _.get(retData, 'data', def);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
36
|
+
* @description Set header with new session
|
|
37
|
+
* @param {string} session Session, token JWT
|
|
38
|
+
* @return {object} header with new session
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
_setHeader(session) {
|
|
42
|
+
return {
|
|
43
|
+
headers: {
|
|
44
|
+
authorization: session,
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
51
|
+
* @description Get the data for a chart
|
|
52
|
+
* @param {object} params Params to get helps from topic
|
|
53
|
+
* @param {object} params.type Type of the chart data
|
|
54
|
+
* @param {object} params.query The query if any
|
|
55
|
+
* @param {string} session Session, token JWT
|
|
56
|
+
* @returns {promise}
|
|
57
|
+
* @public
|
|
58
|
+
* @example
|
|
59
|
+
*
|
|
60
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
61
|
+
* const api = new API();
|
|
62
|
+
* const params = {
|
|
63
|
+
* type: 'heatmap_data'
|
|
64
|
+
* };
|
|
65
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
66
|
+
* await api.user.dashboard.chart.getData(params, session);
|
|
67
|
+
*/
|
|
68
|
+
async getData(params, session) {
|
|
69
|
+
const self = this;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
Joi.assert(params, Joi.object().required(), 'Params to helps from a topic');
|
|
73
|
+
Joi.assert(params.type, Joi.string().required(), 'Type of graph');
|
|
74
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
75
|
+
|
|
76
|
+
const { type, query = {} } = params;
|
|
77
|
+
const apiCall = self._client.post(`/organizations/dashboard/chart/data/${type}`, query, self._setHeader(session));
|
|
78
|
+
|
|
79
|
+
return self._returnData(await apiCall);
|
|
80
|
+
} catch (ex) {
|
|
81
|
+
throw ex;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Class user access to dashboards
|
|
88
|
+
* @class
|
|
89
|
+
*/
|
|
90
|
+
class Dashboard {
|
|
91
|
+
|
|
92
|
+
constructor(options) {
|
|
93
|
+
Joi.assert(options, Joi.object().required());
|
|
94
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
95
|
+
|
|
96
|
+
const self = this;
|
|
97
|
+
self.parent = options.parent;
|
|
98
|
+
self._client = self.parent.dispatch.getClient();
|
|
99
|
+
self._chart = new Chart(options);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
104
|
+
* @description Get the return data and check for errors
|
|
105
|
+
* @param {object} retData Response HTTP
|
|
106
|
+
* @return {*}
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
_returnData(retData, def = {}) {
|
|
110
|
+
if (retData.status !== 200) {
|
|
111
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
112
|
+
} else {
|
|
113
|
+
return _.get(retData, 'data', def);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
119
|
+
* @description Set header with new session
|
|
120
|
+
* @param {string} session Session, token JWT
|
|
121
|
+
* @return {object} header with new session
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
_setHeader(session) {
|
|
125
|
+
return {
|
|
126
|
+
headers: {
|
|
127
|
+
authorization: session,
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
134
|
+
* @description return the chart
|
|
135
|
+
* @public
|
|
136
|
+
* @async
|
|
137
|
+
* @example
|
|
138
|
+
*
|
|
139
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
140
|
+
* const api = new API();
|
|
141
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
142
|
+
* await api.user.help.getTopics({}, session);
|
|
143
|
+
*/
|
|
144
|
+
get chart() {
|
|
145
|
+
const self = this;
|
|
146
|
+
return self._chart;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default Help;
|
package/api/user/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import Help from './help.js';
|
|
|
13
13
|
import Datasource from './datasource.js';
|
|
14
14
|
import Application from './application.js';
|
|
15
15
|
import Settings from './settings.js';
|
|
16
|
+
import Dashboard from './dashboard.js';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* @class API request, user permission level
|
|
@@ -41,6 +42,7 @@ class Users {
|
|
|
41
42
|
self.updates = new Updates(options);
|
|
42
43
|
self.help = new Help(options);
|
|
43
44
|
self.application = new Application(options);
|
|
45
|
+
self.dashboard = new Dashboard(options);
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
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
|
|
@@ -10447,7 +10446,7 @@ class Updates {
|
|
|
10447
10446
|
* Class for user registration in a user
|
|
10448
10447
|
* @class
|
|
10449
10448
|
*/
|
|
10450
|
-
class Help {
|
|
10449
|
+
class Help$1 {
|
|
10451
10450
|
|
|
10452
10451
|
constructor(options) {
|
|
10453
10452
|
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
@@ -11003,6 +11002,8 @@ class Settings {
|
|
|
11003
11002
|
}
|
|
11004
11003
|
}
|
|
11005
11004
|
|
|
11005
|
+
var Dashboard = Help;
|
|
11006
|
+
|
|
11006
11007
|
/**
|
|
11007
11008
|
* @class API request, user permission level
|
|
11008
11009
|
*/
|
|
@@ -11028,8 +11029,9 @@ class Users {
|
|
|
11028
11029
|
self.register = new Register(options);
|
|
11029
11030
|
self.notification = new Notification(options);
|
|
11030
11031
|
self.updates = new Updates(options);
|
|
11031
|
-
self.help = new Help(options);
|
|
11032
|
+
self.help = new Help$1(options);
|
|
11032
11033
|
self.application = new Application(options);
|
|
11034
|
+
self.dashboard = new Dashboard(options);
|
|
11033
11035
|
}
|
|
11034
11036
|
}
|
|
11035
11037
|
|
|
@@ -11405,6 +11407,32 @@ class AdminForm {
|
|
|
11405
11407
|
};
|
|
11406
11408
|
}
|
|
11407
11409
|
|
|
11410
|
+
/**
|
|
11411
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
11412
|
+
* @description Get the types for forms
|
|
11413
|
+
* @return {Promise}
|
|
11414
|
+
* @public
|
|
11415
|
+
* @async
|
|
11416
|
+
* @example
|
|
11417
|
+
*
|
|
11418
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
11419
|
+
* const api = new API();
|
|
11420
|
+
* const params = {
|
|
11421
|
+
* id: '55e4a3bd6be6b45210833fae',
|
|
11422
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
11423
|
+
* };
|
|
11424
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
11425
|
+
* await api.admin.form.findById(params, session);
|
|
11426
|
+
*/
|
|
11427
|
+
get types() {
|
|
11428
|
+
return {
|
|
11429
|
+
BUSINESS: 1,
|
|
11430
|
+
ADVANCED: 2,
|
|
11431
|
+
CHECKLIST: 3,
|
|
11432
|
+
EXTERNAL: 4
|
|
11433
|
+
};
|
|
11434
|
+
}
|
|
11435
|
+
|
|
11408
11436
|
/**
|
|
11409
11437
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
11410
11438
|
* @description Get advance form by ID
|
|
@@ -11480,7 +11508,6 @@ class AdminForm {
|
|
|
11480
11508
|
Joi__default["default"].assert(params.sort, Joi__default["default"].object(), 'Sort fields for');
|
|
11481
11509
|
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session, token JWT');
|
|
11482
11510
|
|
|
11483
|
-
const FORM_ADVANCED = 2;
|
|
11484
11511
|
const PROJECTION_DEFAULT = {_id: 1, name: 1};
|
|
11485
11512
|
const SORT_DEFAULT = {name: 1};
|
|
11486
11513
|
|
|
@@ -11488,7 +11515,7 @@ class AdminForm {
|
|
|
11488
11515
|
orgId,
|
|
11489
11516
|
page = 1,
|
|
11490
11517
|
perPage = 200,
|
|
11491
|
-
type =
|
|
11518
|
+
type = self.types.ADVANCED,
|
|
11492
11519
|
project = PROJECTION_DEFAULT,
|
|
11493
11520
|
sort = SORT_DEFAULT
|
|
11494
11521
|
} = params;
|
|
@@ -12436,6 +12463,61 @@ class AdminUser {
|
|
|
12436
12463
|
throw ex;
|
|
12437
12464
|
}
|
|
12438
12465
|
}
|
|
12466
|
+
|
|
12467
|
+
/**
|
|
12468
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
12469
|
+
* @description Request signed url url to put or get
|
|
12470
|
+
* @param {object} params - Params to get form list
|
|
12471
|
+
* @param {number} params.page=1 - Page of pagination
|
|
12472
|
+
* @param {number} params.perPage=200 - Items per page
|
|
12473
|
+
* @param {object} params.project={_id: 1, name: 1} - Fields to project
|
|
12474
|
+
* @param {object} params.sort={name: 1} - Sort fields
|
|
12475
|
+
* @param {string} session - Session, token JWT
|
|
12476
|
+
* @return {Promise}
|
|
12477
|
+
* @public
|
|
12478
|
+
* @async
|
|
12479
|
+
* @example
|
|
12480
|
+
*
|
|
12481
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
12482
|
+
* const api = new API();
|
|
12483
|
+
* const params - {
|
|
12484
|
+
* project: {_id: 1, name: 1, orgId: 1, orgIds: 1},
|
|
12485
|
+
* };
|
|
12486
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
12487
|
+
* await api.user.form.getUserList(params, session);
|
|
12488
|
+
*/
|
|
12489
|
+
async getUserList(params, session) {
|
|
12490
|
+
const self = this;
|
|
12491
|
+
|
|
12492
|
+
try {
|
|
12493
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get form list');
|
|
12494
|
+
Joi__default["default"].assert(params.page, Joi__default["default"].number(), 'Page of pagination');
|
|
12495
|
+
Joi__default["default"].assert(params.perPage, Joi__default["default"].number(), 'Items per page');
|
|
12496
|
+
Joi__default["default"].assert(params.project, Joi__default["default"].object(), 'Fields to project');
|
|
12497
|
+
Joi__default["default"].assert(params.sort, Joi__default["default"].object(), 'Sort fields for');
|
|
12498
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session, token JWT');
|
|
12499
|
+
|
|
12500
|
+
const PROJECTION_DEFAULT = {_id: 1, name: 1};
|
|
12501
|
+
const SORT_DEFAULT = {name: 1};
|
|
12502
|
+
|
|
12503
|
+
const {
|
|
12504
|
+
page = 1,
|
|
12505
|
+
perPage = 200,
|
|
12506
|
+
project = PROJECTION_DEFAULT,
|
|
12507
|
+
sort = SORT_DEFAULT
|
|
12508
|
+
} = params;
|
|
12509
|
+
|
|
12510
|
+
const payloadToSend = {$project: project, sort};
|
|
12511
|
+
|
|
12512
|
+
const apiCall = self._client
|
|
12513
|
+
.post(`/admin/users?page=${page}&perPage=${perPage}`, payloadToSend, self._setHeader(session));
|
|
12514
|
+
|
|
12515
|
+
return self._returnData(await apiCall);
|
|
12516
|
+
|
|
12517
|
+
} catch (ex) {
|
|
12518
|
+
throw ex;
|
|
12519
|
+
}
|
|
12520
|
+
}
|
|
12439
12521
|
}
|
|
12440
12522
|
|
|
12441
12523
|
/**
|