Skip to content

Commit daaaff2

Browse files
Merge pull request #131 from terminusdb/getDatabases
fixes update_triple variable name bug
2 parents 7f9de89 + c751ed4 commit daaaff2

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

lib/accessControl.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,4 +580,86 @@ AccessControl.prototype.updateUserRole = function (userId, capabilityId, scope,
580580
});
581581
};
582582

583+
/**
584+
* Get all the access request list for a specify organization
585+
* @param {string} [orgName] - The organization name.
586+
* @return {Promise} A promise that returns the call response object, or an Error if rejected.
587+
* @example
588+
* accessControl.accessRequestsList().then(result=>{
589+
* console.log(result)
590+
* })
591+
*
592+
*/
593+
AccessControl.prototype.accessRequestsList = function (orgName) {
594+
if (!orgName && !this.defaultOrganization) {
595+
return Promise.reject(
596+
new Error(
597+
ErrorMessage.getInvalidParameterMessage(
598+
'GET',
599+
'Please provide a organization name',
600+
),
601+
),
602+
);
603+
}
604+
const org = orgName || this.defaultOrganization;
605+
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/access_requests`, CONST.GET);
606+
};
607+
608+
/**
609+
* Get all the access request list for a specify organization
610+
* @param {string} [email] - the user email.
611+
* @param {string} [affiliation] - the user affiliation, company, university etc..
612+
* @param {string} [note] - the message for the team admin
613+
* @param {string} [orgName] - The organization name.
614+
* @return {Promise} A promise that returns the call response object, or an Error if rejected.
615+
* @example
616+
* accessControl.sendAccessRequest("[email protected]",
617+
* "my_company",
618+
* "please add me to your team"
619+
* ).then(result=>{
620+
* console.log(result)
621+
* })
622+
*
623+
*/
624+
AccessControl.prototype.sendAccessRequest = function (email, affiliation, note, orgName) {
625+
if (!orgName && !this.defaultOrganization) {
626+
return Promise.reject(
627+
new Error(
628+
ErrorMessage.getInvalidParameterMessage(
629+
'POST',
630+
'Please provide a organization name',
631+
),
632+
),
633+
);
634+
}
635+
const payload = { email, affiliation, note };
636+
const org = orgName || this.defaultOrganization;
637+
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/access_requests`, CONST.POST, payload);
638+
};
639+
640+
/**
641+
* Delete an access request to join your team, only an admin user can delete it
642+
* @param {string} [orgName] - The organization name.
643+
* @return {Promise} A promise that returns the call response object, or an Error if rejected.
644+
* @example
645+
* accessControl.deleteAccessRequest("djjdshhsuuwewueueuiHYHYYW.......").then(result=>{
646+
* console.log(result)
647+
* })
648+
*
649+
*/
650+
AccessControl.prototype.deleteAccessRequest = function (acceId, orgName) {
651+
if (!orgName && !this.defaultOrganization) {
652+
return Promise.reject(
653+
new Error(
654+
ErrorMessage.getInvalidParameterMessage(
655+
'POST',
656+
'Please provide a organization name',
657+
),
658+
),
659+
);
660+
}
661+
const org = orgName || this.defaultOrganization;
662+
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/access_requests/${acceId}`, CONST.DELETE);
663+
};
664+
583665
module.exports = AccessControl;

lib/query/woqlBuilder.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ WOQLQuery.prototype.iri = function (s) {
6363
};
6464

6565
WOQLQuery.prototype.update_triple = function (subject, predicate, new_object, old_object) {
66-
old_object = old_object || 'v:AnyObject';
66+
const tmp_name = old_object || `v:AnyObject__${Date.now()}`;
6767
return this.and(
6868
new WOQLQuery().opt(
6969
new WOQLQuery()
70-
.triple(subject, predicate, old_object)
71-
.delete_triple(subject, predicate, old_object)
70+
.triple(subject, predicate, tmp_name)
71+
.delete_triple(subject, predicate, tmp_name)
7272
.not()
7373
.triple(subject, predicate, new_object),
7474
),
@@ -88,11 +88,12 @@ WOQLQuery.prototype.update_triple = function (subject, predicate, new_object, ol
8888
*/
8989

9090
WOQLQuery.prototype.update_quad = function (subject, predicate, new_object, graph) {
91+
const tmp_name = `v:AnyObject__${Date.now()}`;
9192
return this.and(
9293
new WOQLQuery().opt(
9394
new WOQLQuery()
94-
.quad(subject, predicate, 'v:AnyObject', graph)
95-
.delete_quad(subject, predicate, 'v:AnyObject', graph)
95+
.quad(subject, predicate, tmp_name, graph)
96+
.delete_quad(subject, predicate, tmp_name, graph)
9697
.not()
9798
.quad(subject, predicate, new_object, graph),
9899
),

0 commit comments

Comments
 (0)