@docbrasil/api-systemmanager 1.0.121 → 1.1.0-test
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/user.js +30 -0
- package/api/user/index.js +2 -0
- package/dist/bundle.cjs +139 -0
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
- package/.project +0 -11
- package/package-lock.json +0 -4635
package/api/admin/user.js
CHANGED
|
@@ -78,6 +78,36 @@ class AdminUser {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
83
|
+
* @description Request profile by userId
|
|
84
|
+
* @param {string} userIds Users identifier (_id database)
|
|
85
|
+
* @param {string} apiKey Api to use to search users
|
|
86
|
+
* @return {Promise}
|
|
87
|
+
* @public
|
|
88
|
+
* @async
|
|
89
|
+
* @example
|
|
90
|
+
*
|
|
91
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
92
|
+
* const api = new API();
|
|
93
|
+
* const userIds = ['55e4a3bd6be6b45210833fae', '55e4a3bd6be6b45210833fae'];
|
|
94
|
+
* const apiKey = 'c9bbd652-d112-454e-8595-f1669f49dde0';
|
|
95
|
+
* await api.admin.user.findByIds(userIds, apiKey);
|
|
96
|
+
*/
|
|
97
|
+
async findByIds(userIds, apiKey) {
|
|
98
|
+
const self = this;
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
Joi.assert(userIds, Joi.array().items(Joi.string()).required(), 'Users identifier (_id database)');
|
|
102
|
+
Joi.assert(apiKey, Joi.string().required(), 'Api to use to search users');
|
|
103
|
+
|
|
104
|
+
const apiCall = self.client.post(`/api/users?apiKey=${apiKey}`, { userIds });
|
|
105
|
+
return self._returnData(await apiCall);
|
|
106
|
+
} catch (ex) {
|
|
107
|
+
throw ex;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
81
111
|
/**
|
|
82
112
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
83
113
|
* @description Update password by userId
|
package/api/user/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import User from './user.js';
|
|
|
9
9
|
import Register from './register.js';
|
|
10
10
|
import Notification from './notification.js';
|
|
11
11
|
import Updates from './updates.js';
|
|
12
|
+
import Help from './help.js';
|
|
12
13
|
import Datasource from './datasource.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -35,6 +36,7 @@ class Users {
|
|
|
35
36
|
self.register = new Register(options);
|
|
36
37
|
self.notification = new Notification(options);
|
|
37
38
|
self.updates = new Updates(options);
|
|
39
|
+
self.help = new Help(options);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
package/dist/bundle.cjs
CHANGED
|
@@ -9777,6 +9777,114 @@ class Updates {
|
|
|
9777
9777
|
|
|
9778
9778
|
}
|
|
9779
9779
|
|
|
9780
|
+
/**
|
|
9781
|
+
* Class for user registration in a user
|
|
9782
|
+
* @class
|
|
9783
|
+
*/
|
|
9784
|
+
class Help {
|
|
9785
|
+
|
|
9786
|
+
constructor(options) {
|
|
9787
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
9788
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
9789
|
+
|
|
9790
|
+
const self = this;
|
|
9791
|
+
self.parent = options.parent;
|
|
9792
|
+
self._client = self.parent.dispatch.getClient();
|
|
9793
|
+
}
|
|
9794
|
+
|
|
9795
|
+
/**
|
|
9796
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9797
|
+
* @description Get the return data and check for errors
|
|
9798
|
+
* @param {object} retData Response HTTP
|
|
9799
|
+
* @return {*}
|
|
9800
|
+
* @private
|
|
9801
|
+
*/
|
|
9802
|
+
_returnData(retData, def = {}) {
|
|
9803
|
+
if (retData.status !== 200) {
|
|
9804
|
+
return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
9805
|
+
} else {
|
|
9806
|
+
return ___default["default"].get(retData, 'data', def);
|
|
9807
|
+
}
|
|
9808
|
+
}
|
|
9809
|
+
|
|
9810
|
+
/**
|
|
9811
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9812
|
+
* @description Set header with new session
|
|
9813
|
+
* @param {string} session Session, token JWT
|
|
9814
|
+
* @return {object} header with new session
|
|
9815
|
+
* @private
|
|
9816
|
+
*/
|
|
9817
|
+
_setHeader(session) {
|
|
9818
|
+
return {
|
|
9819
|
+
headers: {
|
|
9820
|
+
authorization: session,
|
|
9821
|
+
}
|
|
9822
|
+
};
|
|
9823
|
+
}
|
|
9824
|
+
|
|
9825
|
+
/**
|
|
9826
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9827
|
+
* @description get heps topics
|
|
9828
|
+
* @param {string} session JWT token
|
|
9829
|
+
* @public
|
|
9830
|
+
* @async
|
|
9831
|
+
* @example
|
|
9832
|
+
*
|
|
9833
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9834
|
+
* const api = new API();
|
|
9835
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9836
|
+
* await api.user.help.getTopics(session);
|
|
9837
|
+
*/
|
|
9838
|
+
async getTopics(session) {
|
|
9839
|
+
const self = this;
|
|
9840
|
+
|
|
9841
|
+
try {
|
|
9842
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'SM session (JWT) to call API');
|
|
9843
|
+
|
|
9844
|
+
const apiCall = self._client.get('/help/topics', self._setHeader(session));
|
|
9845
|
+
return self._returnData(await apiCall);
|
|
9846
|
+
} catch (ex) {
|
|
9847
|
+
throw ex;
|
|
9848
|
+
}
|
|
9849
|
+
}
|
|
9850
|
+
|
|
9851
|
+
/**
|
|
9852
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9853
|
+
* @description Method to find helps from a topic
|
|
9854
|
+
* @param {object} params Params to get helps from topic
|
|
9855
|
+
* @param {object} params.id Topic id (_id database)
|
|
9856
|
+
* @param {string} session Session, token JWT
|
|
9857
|
+
* @returns {promise}
|
|
9858
|
+
* @public
|
|
9859
|
+
* @example
|
|
9860
|
+
*
|
|
9861
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9862
|
+
* const api = new API();
|
|
9863
|
+
* const params = {
|
|
9864
|
+
* id: '5dadd01dc4af3941d42f8c5c'
|
|
9865
|
+
* };
|
|
9866
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9867
|
+
* await api.user.help.get(params, session);
|
|
9868
|
+
*/
|
|
9869
|
+
async get(params, session) {
|
|
9870
|
+
const self = this;
|
|
9871
|
+
|
|
9872
|
+
try {
|
|
9873
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to helps from a topic');
|
|
9874
|
+
Joi__default["default"].assert(params.id, Joi__default["default"].string().required(), 'Topic id (_id database)');
|
|
9875
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
9876
|
+
|
|
9877
|
+
const {id} = params;
|
|
9878
|
+
const apiCall = self._client.get(`/help/topic/${id}`, self._setHeader(session));
|
|
9879
|
+
|
|
9880
|
+
return self._returnData(await apiCall);
|
|
9881
|
+
} catch (ex) {
|
|
9882
|
+
throw ex;
|
|
9883
|
+
}
|
|
9884
|
+
}
|
|
9885
|
+
|
|
9886
|
+
}
|
|
9887
|
+
|
|
9780
9888
|
/**
|
|
9781
9889
|
* Class for user datasource access, to be used with when creating new documents
|
|
9782
9890
|
* @class
|
|
@@ -9940,6 +10048,7 @@ class Users {
|
|
|
9940
10048
|
self.register = new Register(options);
|
|
9941
10049
|
self.notification = new Notification(options);
|
|
9942
10050
|
self.updates = new Updates(options);
|
|
10051
|
+
self.help = new Help(options);
|
|
9943
10052
|
}
|
|
9944
10053
|
}
|
|
9945
10054
|
|
|
@@ -11152,6 +11261,36 @@ class AdminUser {
|
|
|
11152
11261
|
}
|
|
11153
11262
|
}
|
|
11154
11263
|
|
|
11264
|
+
/**
|
|
11265
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
11266
|
+
* @description Request profile by userId
|
|
11267
|
+
* @param {string} userIds Users identifier (_id database)
|
|
11268
|
+
* @param {string} apiKey Api to use to search users
|
|
11269
|
+
* @return {Promise}
|
|
11270
|
+
* @public
|
|
11271
|
+
* @async
|
|
11272
|
+
* @example
|
|
11273
|
+
*
|
|
11274
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
11275
|
+
* const api = new API();
|
|
11276
|
+
* const userIds = ['55e4a3bd6be6b45210833fae', '55e4a3bd6be6b45210833fae'];
|
|
11277
|
+
* const apiKey = 'c9bbd652-d112-454e-8595-f1669f49dde0';
|
|
11278
|
+
* await api.admin.user.findByIds(userIds, apiKey);
|
|
11279
|
+
*/
|
|
11280
|
+
async findByIds(userIds, apiKey) {
|
|
11281
|
+
const self = this;
|
|
11282
|
+
|
|
11283
|
+
try {
|
|
11284
|
+
Joi__default["default"].assert(userIds, Joi__default["default"].array().items(Joi__default["default"].string()).required(), 'Users identifier (_id database)');
|
|
11285
|
+
Joi__default["default"].assert(apiKey, Joi__default["default"].string().required(), 'Api to use to search users');
|
|
11286
|
+
|
|
11287
|
+
const apiCall = self.client.post(`/api/users?apiKey=${apiKey}`, { userIds });
|
|
11288
|
+
return self._returnData(await apiCall);
|
|
11289
|
+
} catch (ex) {
|
|
11290
|
+
throw ex;
|
|
11291
|
+
}
|
|
11292
|
+
}
|
|
11293
|
+
|
|
11155
11294
|
/**
|
|
11156
11295
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
11157
11296
|
* @description Update password by userId
|