Skip to content

Commit 2d72403

Browse files
committed
review docjs
1 parent b866594 commit 2d72403

15 files changed

+2041
-1181
lines changed

.vscode/launch.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"configurations": [
3+
{
4+
"type": "pwa-chrome",
5+
"name": "http://localhost:3005",
6+
"request": "launch",
7+
"url": "http://localhost:3005"
8+
}
9+
]
10+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"compile-hero.disable-compile-files-on-did-save-code": false
3+
}

index.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1-
21
module.exports = {
3-
WOQLClient:require('./lib/woqlClient'),
4-
UTILS:require('./lib/utils'),
5-
View:require('./lib/viewer/woqlView'),
6-
WOQL:require('./lib/woql'),
7-
WOQLResult:require('./lib/viewer/woqlResult'),
8-
WOQLTable:require('./lib/viewer/woqlTable'),
9-
WOQLGraph:require('./lib/viewer/woqlGraph'),
10-
axiosInstance:require('./lib/axiosInstance')
11-
};
2+
/**
3+
* @type {typeof import('./lib/woqlClient')}
4+
*/
5+
WOQLClient: require('./lib/woqlClient'),
6+
/**
7+
* @type {typeof import('./lib/utils')}
8+
*/
9+
UTILS: require('./lib/utils'),
10+
/**
11+
* @type {typeof import('./lib/woqlView')}
12+
*/
13+
View: require('./lib/viewer/woqlView'),
14+
/**
15+
* @type {typeof import('./lib/woql')}
16+
*/
17+
WOQL: require('./lib/woql'),
18+
/**
19+
* @type {typeof import('./lib/viewer/woqlResult')}
20+
*/
21+
WOQLResult: require('./lib/viewer/woqlResult'),
22+
/**
23+
* @type {typeof import('./lib/viewer/woqlTable')}
24+
*/
25+
WOQLTable: require('./lib/viewer/woqlTable'),
26+
/**
27+
* @type {typeof import('./lib/viewer/woqlGraph')}
28+
*/
29+
WOQLGraph: require('./lib/viewer/woqlGraph'),
30+
/**
31+
* @type {typeof import('./lib/axiosInstance')}
32+
*/
33+
axiosInstance: require('./lib/axiosInstance'),
34+
}

lib/connectionCapabilities.js

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ const UTILS = require("./utils")
66
/**
77
* @file Connection Capabilities
88
* @license Apache Version 2
9+
* @constructor
910
* @description Object which helps manage the capabilities available for a given TerminusDB connection
1011
* Creates an entry in the connection registry for the server
1112
* and all the databases that the client has access to
1213
* maps the input authorties to a per-db array for internal storage and easy
1314
* access control checks
14-
* @param {String} key API key
1515
*/
1616
function ConnectionCapabilities() {
1717
this.clear()
@@ -30,39 +30,66 @@ ConnectionCapabilities.prototype.clear = function() {
3030

3131
/**
3232
* @param {object} capabilities the JSON object returned by the connect API call
33-
* it is a system:User object with a system:role predicate which points at an array of roles
33+
* @returns {object} it is a system:User object with a system:role predicate which points at an array of roles
3434
*/
35-
ConnectionCapabilities.prototype.setCapabilities = function(connectjson) {
35+
ConnectionCapabilities.prototype.setCapabilities = function(capabilities) {
3636
this.clear()
3737
this.databases = false
38-
if(connectjson['@context']) this._load_connection_context(connectjson['@context'])
39-
this.user = this._extract_user_info(connectjson)
38+
if(capabilities['@context']) this._load_connection_context(capabilities['@context'])
39+
this.user = this._extract_user_info(capabilities)
4040
this._extract_database_organizations() //find the organization which owns the db
4141
return this.user
4242
}
4343

44-
ConnectionCapabilities.prototype.get_user = function() {
44+
/*
45+
* @returns {object}
46+
*/
47+
//ConnectionCapabilities.prototype.get_user = function() {
48+
ConnectionCapabilities.prototype.getUserObj = function() {
49+
//console.log("___USER___OBJ",this.user)
4550
return this.user
4651
}
47-
52+
//getDatabases
53+
/*
54+
* @returns {string|boolean}
55+
*/
4856
ConnectionCapabilities.prototype.author = function() {
4957
if (this.user && this.user.author) return this.user.author
5058
return false
5159
}
5260

53-
ConnectionCapabilities.prototype.get_databases = function() {
61+
62+
/**
63+
* @description get the database details list for the get capabilities call
64+
* @returns {array}
65+
*/
66+
//KEVIN
67+
//ConnectionCapabilities.prototype.get_databases = function() {
68+
ConnectionCapabilities.prototype.getDatabaseList = function() {
5469
if(!this.databases) this.databases = this._databases_from_dbdocs()
5570
return this.databases
5671
}
57-
58-
ConnectionCapabilities.prototype.set_databases = function(newdbs) {
59-
this.databases = newdbs
72+
/**
73+
* @description set the newDBList form the get capabilities result
74+
* @param {array} newDBList
75+
*/
76+
//KEVIN
77+
ConnectionCapabilities.prototype.setDatabaseList = function(newDBList) {
78+
//ConnectionCapabilities.prototype.set_databases = function(newDBList) {
79+
this.databases = newDBList
6080
}
6181

62-
ConnectionCapabilities.prototype.get_database = function(dbid, orgid) {
82+
/**
83+
* @description Gets the database's details
84+
* @param {?string} dbId
85+
* @param {?string} orgId
86+
* @returns {object}
87+
*/
88+
//ConnectionCapabilities.prototype.get_database = function(dbId, orgId) {
89+
ConnectionCapabilities.prototype.getDatabaseObj = function(dbId, orgId) {
6390
if(!this.databases) this.databases = this._databases_from_dbdocs()
6491
for(var i = 0; i<this.databases.length; i++){
65-
if(this.databases[i].id == dbid && this.databases[i].organization == orgid){
92+
if(this.databases[i].id === dbId && this.databases[i].organization === orgId){
6693
return this.databases[i]
6794
}
6895
}
@@ -139,7 +166,7 @@ ConnectionCapabilities.prototype.actions_permitted = function(actions, resnames)
139166
}
140167

141168
ConnectionCapabilities.prototype.buildContextsFromPrefixes = function(){
142-
let dbs = this.get_databases()
169+
let dbs = this.getDatabaseList()
143170
for(var i = 0; i<dbs.length; i++){
144171
dbs[i].jsonld_context = _jsonld_context_from_prefixes(dbs[i].prefix_pairs)
145172
}
@@ -171,7 +198,7 @@ ConnectionCapabilities.prototype.getContextForOutboundQuery = function(woql, dbi
171198
else {
172199
if(this._is_system_db(dbid)) ob = this.getSystemContext()
173200
else {
174-
let dbrec = this.get_database(dbid, orgid)
201+
let dbrec = this.getDatabaseObj(dbid, orgid)
175202
let jcon = (dbrec && dbrec.jsonld_context ? dbrec.jsonld_context : this.jsonld_context)
176203
for (var k in jcon) {
177204
//if (k != 'doc') ob[k] = jcon[k]

0 commit comments

Comments
 (0)