@@ -24,7 +24,7 @@ const WOQLQuery = require('./query/woqlBuilder')
2424 * client.db("test")
2525 * client.checkout("dev")
2626 * const turtle = await client.getTriples("schema", "main")
27- * //The client has an internal state which defines what
27+ * //The client has an internal state which defines what
2828 * //organization / database / repository / branch / ref it is currently attached to
2929 */
3030
@@ -35,6 +35,10 @@ function WOQLClient(serverUrl, params) {
3535 this . connection = new ConnectionCapabilities ( )
3636}
3737
38+ WOQLClient . prototype . reqUID = function ( reqUID ) {
39+ if ( reqUID ) this . _reqUID = reqUID
40+ else return this . _reqUID
41+ }
3842
3943WOQLClient . CONST = CONST
4044
@@ -870,7 +874,14 @@ WOQLClient.prototype.dispatch = function(action, apiUrl, payload) {
870874 ) ,
871875 )
872876 }
873- return DispatchRequest ( apiUrl , action , payload , this . localAuth ( ) , this . remoteAuth ( ) )
877+ return DispatchRequest (
878+ apiUrl ,
879+ action ,
880+ payload ,
881+ this . localAuth ( ) ,
882+ this . remoteAuth ( ) ,
883+ this . reqUID ( ) ,
884+ )
874885}
875886
876887/**
@@ -985,7 +996,6 @@ WOQLClient.prototype.getClassFrame = function(docType) {
985996 */
986997
987998WOQLClient . prototype . getDatabase = function ( ) {
988- //console.log('___DB__URL__', this.connectionConfig.dbURL())
989999 return this . dispatch ( CONST . READ_DATABASE , this . connectionConfig . dbURL ( ) )
9901000}
9911001
@@ -1122,13 +1132,17 @@ WOQLClient.prototype.createOrganization = function(orgId, orgDoc) {
11221132}
11231133
11241134/**
1125- * Gets all the information about the given organization
1135+ * Gets all the information about the given organization
11261136 * @param {string } orgId - the organization id
1137+ * @param {string } [action] - set an action like recommendations | invitations | collaborators
11271138 * @returns {Promise } A promise that returns the call response object, or an Error if rejected.
11281139 */
11291140
1130- WOQLClient . prototype . getOrganization = function ( orgId ) {
1131- return this . dispatch ( CONST . READ_ORGANIZATION , this . connectionConfig . organizationURL ( orgId ) )
1141+ WOQLClient . prototype . getOrganization = function ( orgId , action ) {
1142+ return this . dispatch (
1143+ CONST . READ_ORGANIZATION ,
1144+ this . connectionConfig . organizationURL ( orgId , action ) ,
1145+ )
11321146}
11331147
11341148/**
@@ -1176,23 +1190,20 @@ WOQLClient.prototype.deleteOrganization = function(orgId) {
11761190}
11771191
11781192/**
1179- * @param {string } userId - the user id
1193+ * get all the user roles (for the current logged user)
1194+ * or the user roles for a specific database and user
1195+ * (the logged used need to have the permission to see the roles info for another user)
1196+ * @param {string } [userId] - the user id
11801197 * @param {string } [orgId] - the organization id
11811198 * @param {string } [dbId] - the dbId
11821199 * @returns {Promise } A promise that returns the call response object, or an Error if rejected.
11831200 */
11841201WOQLClient . prototype . getRoles = function ( userId , orgId , dbId ) {
1185- let payload = { }
1186- if ( userId ) {
1187- payload [ 'agent_name' ] = userId
1188- }
1189- if ( dbId ) {
1190- payload [ 'database_name' ] = dbId
1191- }
1192- if ( orgId ) {
1193- payload [ 'organization_name' ] = orgId
1202+ let roleURL = this . connectionConfig . rolesURL ( )
1203+ if ( userId && orgId && dbId ) {
1204+ roleURL = `${ roleURL } /${ userId } /${ orgId } /${ dbId } `
11941205 }
1195- return this . dispatch ( CONST . GET_ROLES , this . connectionConfig . rolesURL ( ) , payload )
1206+ return this . dispatch ( CONST . GET_ROLES , roleURL )
11961207}
11971208
11981209/**
0 commit comments