@@ -24,7 +24,7 @@ const WOQLQuery = require('./query/woqlBuilder')
24
24
* client.db("test")
25
25
* client.checkout("dev")
26
26
* 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
28
28
* //organization / database / repository / branch / ref it is currently attached to
29
29
*/
30
30
@@ -35,6 +35,10 @@ function WOQLClient(serverUrl, params) {
35
35
this . connection = new ConnectionCapabilities ( )
36
36
}
37
37
38
+ WOQLClient . prototype . reqUID = function ( reqUID ) {
39
+ if ( reqUID ) this . _reqUID = reqUID
40
+ else return this . _reqUID
41
+ }
38
42
39
43
WOQLClient . CONST = CONST
40
44
@@ -870,7 +874,14 @@ WOQLClient.prototype.dispatch = function(action, apiUrl, payload) {
870
874
) ,
871
875
)
872
876
}
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
+ )
874
885
}
875
886
876
887
/**
@@ -985,7 +996,6 @@ WOQLClient.prototype.getClassFrame = function(docType) {
985
996
*/
986
997
987
998
WOQLClient . prototype . getDatabase = function ( ) {
988
- //console.log('___DB__URL__', this.connectionConfig.dbURL())
989
999
return this . dispatch ( CONST . READ_DATABASE , this . connectionConfig . dbURL ( ) )
990
1000
}
991
1001
@@ -1122,13 +1132,17 @@ WOQLClient.prototype.createOrganization = function(orgId, orgDoc) {
1122
1132
}
1123
1133
1124
1134
/**
1125
- * Gets all the information about the given organization
1135
+ * Gets all the information about the given organization
1126
1136
* @param {string } orgId - the organization id
1137
+ * @param {string } [action] - set an action like recommendations | invitations | collaborators
1127
1138
* @returns {Promise } A promise that returns the call response object, or an Error if rejected.
1128
1139
*/
1129
1140
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
+ )
1132
1146
}
1133
1147
1134
1148
/**
@@ -1176,23 +1190,20 @@ WOQLClient.prototype.deleteOrganization = function(orgId) {
1176
1190
}
1177
1191
1178
1192
/**
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
1180
1197
* @param {string } [orgId] - the organization id
1181
1198
* @param {string } [dbId] - the dbId
1182
1199
* @returns {Promise } A promise that returns the call response object, or an Error if rejected.
1183
1200
*/
1184
1201
WOQLClient . 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 } `
1194
1205
}
1195
- return this . dispatch ( CONST . GET_ROLES , this . connectionConfig . rolesURL ( ) , payload )
1206
+ return this . dispatch ( CONST . GET_ROLES , roleURL )
1196
1207
}
1197
1208
1198
1209
/**
0 commit comments