Skip to content

Commit b492429

Browse files
committed
review call
1 parent 456e274 commit b492429

File tree

2 files changed

+45
-142
lines changed

2 files changed

+45
-142
lines changed

lib/woql.js

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,64 +1396,7 @@ WOQL.link = function(subject, predicate, object, graphRef) {
13961396
return new WOQLQuery().link(subject, predicate, object, graphRef)
13971397
}
13981398

1399-
/**
1400-
* @param {WOQLClient} woqlClient - an WoqlClient instance
1401-
* @param {string} propId - property id
1402-
* @param {string} classId - the enum class id
1403-
* @param {string} classLabel - the enum class label
1404-
* @param {string} [classDesc] - the enum class description
1405-
* @param {string} [schemaGraph] - the resource identifier of a schema graph. The Default value id schema/main
1406-
* @returns {WOQLQuery} - A WOQLQuery which contains the Create Enum Class Statement
1407-
*/
1408-
WOQL.makeEnum = function(woqlClient, propId, classId, classLabel, classDesc, schemaGraph) {
1409-
return new WOQLQuery().makeEnum(woqlClient, prop, classId, classLabel, classDesc, schemaGraph)
1410-
}
1411-
1412-
/**
1413-
* Generates a class representing a choice list - an enumerated list of specific options
1414-
* @param {string} classId - the enum class id
1415-
* @param {string} classLabel - the enum class label
1416-
* @param {string} classDesc - the enum class description
1417-
* @param {array} choices - an list of permitted values [[id,label,comment],[id,label,comment]]
1418-
* @param {string} [schemaGraph] - the resource identifier of a schema graph. The Default value id schema/main
1419-
* @param {string} [parent] - the id of a class that this class inherits from (e.g. scm:Enumerated)
1420-
* @returns {WOQLQuery} - A WOQLQuery which contains the Generate Enum/Choice Class Statement
1421-
*/
1422-
1423-
WOQL.generateChoiceList = function(classId, classLabel, classDesc, choices, schemaGraph, parent) {
1424-
return new WOQLQuery().generateChoiceList(
1425-
classId,
1426-
classLabel,
1427-
classDesc,
1428-
choices,
1429-
schemaGraph,
1430-
parent,
1431-
)
1432-
}
14331399

1434-
/**
1435-
* update or create an enumeration class. You have to add at least one permitted values in the list
1436-
* @param {string} classId - the enum class id
1437-
* @param {string} classLabel - the enum class label
1438-
* @param {string} classDesc - the enum class description
1439-
* @param {array} choices - an list of permitted values [[id,label,comment],[id,label,comment]]
1440-
* @param {string} [schemaGraph] - the resource identifier of a schema graph. The Default value id schema/main
1441-
* @returns {WOQLQuery} - A WOQLQuery which contains the Update Enum/Choice Class Statement
1442-
*/
1443-
WOQL.updateChoiceList = function(classId, classLabel, classDesc, choices, schemaGraph) {
1444-
return new WOQLQuery().updateChoiceList(classId, classLabel, classDesc, choices, schemaGraph)
1445-
}
1446-
1447-
/**
1448-
* delete the enum list for a specific enumeration class, but not the class
1449-
* @param {string} classId - the enum class name
1450-
* @param {string} [schemaGraph] - the resource identifier of a schema graph. The Default value id schema/main
1451-
* @returns {WOQLQuery} - A WOQLQuery which contains the Delete Choice List Statement
1452-
*/
1453-
1454-
WOQL.deleteChoiceList = function(classId, schemaGraph) {
1455-
return new WOQLQuery().deleteChoiceList(classId, schemaGraph)
1456-
}
14571400

14581401
/**
14591402
* Called to load Terminus Predefined libraries:

lib/woqlClient.js

Lines changed: 45 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -372,67 +372,14 @@ WOQLClient.prototype.deleteDatabase = function(dbId, orgId, force) {
372372
this.organization(orgIdValue)
373373
let payload = force ? {force: true} : null
374374
if (dbId && this.db(dbId)) {
375-
return this.dispatch(CONST.DATABASE, this.connectionConfig.dbURL(), payload)
375+
return this.dispatch(CONST.DELETE, this.connectionConfig.dbURL(), payload)
376376
}
377377
let errmsg = `Delete database parameter error - you must specify a valid database id - ${dbId} is invalid`
378378
return Promise.reject(
379-
new Error(ErrorMessage.getInvalidParameterMessage(CONST.DATABASE, errmsg)),
379+
new Error(ErrorMessage.getInvalidParameterMessage(CONST.DELETE, errmsg)),
380380
)
381381
}
382382

383-
/**
384-
* Creates a new named graph within a TerminusDB database
385-
* @param {typedef.GraphType} graphType - type of graph
386-
* @param {string} graphId - id of the graph to be created
387-
* @param {string} commitMsg - a message describing the reason for the change that will be written into the commit log
388-
* @returns {Promise} A promise that returns the call response object, or an Error if rejected.
389-
* @example
390-
* client.createGraph("schema", "alt", "Adding new schema graph")
391-
*/
392-
//TO BE REMOVED
393-
WOQLClient.prototype.createGraph = function(graphType, graphId, commitMsg) {
394-
if (
395-
graphType &&
396-
['inference', 'schema', 'instance'].indexOf(graphType) !== -1 &&
397-
graphId &&
398-
commitMsg
399-
) {
400-
let commit = this.generateCommitInfo(commitMsg)
401-
return this.dispatch(
402-
CONST.CREATE_GRAPH,
403-
this.connectionConfig.graphURL(graphType, graphId),
404-
commit,
405-
)
406-
}
407-
let errmsg = `Create graph parameter error - you must specify a valid type (inference, instance, schema), graph id and commit message`
408-
return Promise.reject(
409-
new Error(ErrorMessage.getInvalidParameterMessage(CONST.CREATE_GRAPH, errmsg)),
410-
)
411-
}
412-
413-
/**
414-
* Deletes a graph from a TerminusDB database
415-
* @param {typedef.GraphType} graphType - type of graph
416-
* @param {string} graphId - local id of graph
417-
* @param {string} commitMsg - a message describing the reason for the change that will be written into the commit log
418-
* @returns {Promise} A promise that returns the call response object, or an Error if rejected.
419-
* @example
420-
* client.deleteGraph("schema", "alt", "Deleting alt schema graph")
421-
*/
422-
WOQLClient.prototype.deleteGraph = function(graphType, graphId, commitMsg) {
423-
if (graphType && ['inference', 'schema', 'instance'].indexOf(graphType) != -1 && graphId) {
424-
let commit = this.generateCommitInfo(commitMsg)
425-
return this.dispatch(
426-
CONST.GRAPH,
427-
this.connectionConfig.graphURL(graphType, graphType),
428-
commit,
429-
)
430-
}
431-
let errmsg = `Delete graph parameter error - you must specify a valid type (inference, instance, schema), graph id and commit message`
432-
return Promise.reject(
433-
new Error(ErrorMessage.getInvalidParameterMessage(CONST.GRAPH, errmsg)),
434-
)
435-
}
436383

437384
/**
438385
* Retrieve the contents of a graph within a TerminusDB as triples, encoded in the turtle (ttl) format
@@ -871,24 +818,34 @@ WOQLClient.prototype.dispatch = function(action, apiUrl, payload) {
871818
),
872819
),
873820
)
874-
}//I have to do a call to get the jwt token
875-
/*if(this.connectionConfig.tokenParameter){
821+
}
822+
//I have to review this I don't want a call everytime
823+
if(this.connectionConfig.tokenParameter){
876824
const param = this.connectionConfig.tokenParameter
877-
await axios.post(param.url,param.options).then(result=>result.data).then(data=>{
825+
axios.post(param.url,param.options).then(result=>result.data).then(data=>{
878826
if(data.access_token){
879827
console.log("ACCESS_TOKEN",data.access_token)
880828
this.localAuth({"key":data.access_token,"type":"jwt"})
881829
}
830+
return DispatchRequest(
831+
apiUrl,
832+
action,
833+
payload,
834+
this.localAuth(),
835+
this.remoteAuth(),
836+
this.customHeaders(),
837+
)
882838
})
883-
}*/
884-
return DispatchRequest(
885-
apiUrl,
886-
action,
887-
payload,
888-
this.localAuth(),
889-
this.remoteAuth(),
890-
this.customHeaders(),
891-
)
839+
}else{
840+
return DispatchRequest(
841+
apiUrl,
842+
action,
843+
payload,
844+
this.localAuth(),
845+
this.remoteAuth(),
846+
this.customHeaders(),
847+
)
848+
}
892849

893850
}
894851

@@ -1318,34 +1275,37 @@ WOQLClient.prototype.getEnums = function(dbId){
13181275
* @param {string} [dbId]
13191276
* @returns
13201277
*/
1321-
/*WOQLClient.prototype.getClassDocuments = async function(dbId){
1278+
WOQLClient.prototype.getClassDocuments = function(dbId){
13221279
const params = {'graph_type':"schema","as_list":true,"type":"sys:Class"}
1323-
const result = await this.getDocument(params,dbId)
1324-
let documents=[]
1325-
if(result){
1280+
return this.getDocument(params,dbId).then(result=>{
1281+
let documents=[]
1282+
if(result){
13261283
documents = result.filter(item => !item['@subdocument'] && !item['@abstract'])
1327-
}
1328-
return documents
1329-
}*/
1284+
}
1285+
return documents
1286+
})
1287+
}
13301288

13311289
/**
13321290
*
13331291
* @param {*} dbId
13341292
* @returns
13351293
*/
1336-
/*WOQLClient.prototype.getBranches = async function(dbId){
1294+
WOQLClient.prototype.getBranches = function(dbId){
13371295
const params={type:'Branch','as_list':true}
13381296
const branch = this.checkout()
1339-
const result = await this.getDocument(params,dbId,"_commits")
1297+
return this.getDocument(params,dbId,"_commits").then(result=>{
1298+
const branchesObj = {}
1299+
if(result){
1300+
result.forEach(item=>{
1301+
branchesObj[item.name]=item
1302+
})
1303+
}
1304+
this.checkout(branch)
1305+
return branchesObj
1306+
})
13401307
//reset branch
1341-
const branchesObj = {}
1342-
if(result){
1343-
result.forEach(item=>{
1344-
branchesObj[item.name]=item
1345-
})
1346-
}
1347-
this.checkout(branch)
1348-
return branchesObj
1349-
}*/
1308+
1309+
}
13501310

13511311
module.exports = WOQLClient

0 commit comments

Comments
 (0)