Skip to content

Commit 08fd425

Browse files
committed
Merge branch 'dev' of https://github.com/terminusdb/terminus-client into dev
2 parents f1c2661 + 75dab26 commit 08fd425

34 files changed

+1939
-3178
lines changed

lib/connectionConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ ConnectionConfig.prototype.apiURL = function() {
119119
* @returns {string | boolean}
120120
*/
121121
ConnectionConfig.prototype.db = function() {
122+
if(!this.dbid) throw new Error('Invalid database name');
122123
return this.dbid
123124
}
124125

@@ -358,7 +359,7 @@ ConnectionConfig.prototype.organizationURL = function(orgId, action) {
358359
* @returns {string}
359360
*/
360361
ConnectionConfig.prototype.rolesURL = function() {
361-
return `${this.apiURL()}roles`
362+
return `${this.apiURL()}role`
362363
}
363364

364365
/**

lib/query/woqlBuilder.js

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ WOQLQuery.prototype.literal = function(s, t) {
5757

5858
WOQLQuery.prototype.iri = function(s) {
5959
return {
60-
'@type': 'woql:Node',
61-
'woql:node': s,
60+
'@type': 'NodeValue',
61+
'node': s,
6262
}
6363
}
6464

@@ -130,7 +130,7 @@ WOQLQuery.prototype.property = function(proId, type_or_value) {
130130
let part = this.findLastSubject(this.cursor)
131131
let g = false
132132
let gpart
133-
if (part) gpart = part['woql:graph_filter'] || part['woql:graph']
133+
if (part) gpart = part['graph_filter'] || part['graph']
134134
if (gpart) g = gpart['@value']
135135
let nprop = new WOQLQuery()
136136
.add_property(proId, type_or_value, g)
@@ -144,31 +144,29 @@ WOQLQuery.prototype.property = function(proId, type_or_value) {
144144

145145
WOQLQuery.prototype.node = function(node, type) {
146146
type = type || false
147-
if (type == 'add_quad') type = 'AddQuad'
148-
else if (type == 'delete_quad') type = 'DeleteQuad'
147+
if (type == 'add_quad') type = 'AddTriple'
148+
else if (type == 'delete_quad') type = 'DeleteTriple'
149149
else if (type == 'add_triple') type = 'AddTriple'
150150
else if (type == 'delete_triple') type = 'DeleteTriple'
151-
else if (type == 'quad') type = 'Quad'
151+
else if (type == 'quad') type = 'Triple'
152152
else if (type == 'triple') type = 'Triple'
153-
if (type && type.indexOf(':') == -1) type = 'woql:' + type
153+
if (type && type.indexOf(':') == -1) type = type
154154
let ctxt = {subject: node}
155155
if (type) ctxt.action = type
156156
this._set_context(ctxt)
157157
return this
158158
}
159159

160160
WOQLQuery.prototype.insert = function(id, type, refGraph) {
161-
type = this.cleanType(type, true)
162161
refGraph = refGraph || (this.triple_builder_context ? this.triple_builder_context.graph : false)
163162
if (refGraph) {
164-
return this.add_quad(id, 'type', type, refGraph)
163+
return this.add_quad(id, 'rdf:type', '@schema:'+type, refGraph)
165164
}
166-
return this.add_triple(id, 'type', type)
165+
return this.add_triple(id, 'rdf:type', '@schema:'+type)
167166
}
168167

169168
WOQLQuery.prototype.insert_data = function(data, refGraph) {
170169
if (data.type && data.id) {
171-
type = this.cleanType(data.type, true)
172170
this.insert(data.id, type, refGraph)
173171
if (data.label) {
174172
this.label(data.label)
@@ -224,7 +222,6 @@ WOQLQuery.prototype.graph = function(g) {
224222
}
225223

226224
WOQLQuery.prototype.domain = function(d) {
227-
d = this.cleanClass(d)
228225
return this._add_partial(false, 'rdfs:domain', d)
229226
}
230227
/**
@@ -258,7 +255,7 @@ WOQLQuery.prototype.description = function(c, lang) {
258255
*/
259256
WOQLQuery.prototype.parent = function(...parentList) {
260257
for (var i = 0; i < parentList.length; i++) {
261-
var pn = this.cleanClass(parentList[i])
258+
var pn = parentList[i]
262259
this._add_partial(false, 'rdfs:subClassOf', pn)
263260
}
264261
return this
@@ -290,24 +287,24 @@ WOQLQuery.prototype._add_partial = function(s, p, o, g) {
290287
//if the last subject is a cardinality restriction quad
291288
//I'm looking for the last property
292289
if (
293-
lastsubj['woql:predicate'] &&
294-
lastsubj['woql:predicate']['woql:node'] &&
295-
lastsubj['woql:predicate']['woql:node'].indexOf('Cardinality') > -1
290+
lastsubj['predicate'] &&
291+
lastsubj['predicate']['node'] &&
292+
lastsubj['predicate']['node'].indexOf('Cardinality') > -1
296293
) {
297294
lastsubj = this.findLastProperty(this.cursor)
298295
}
299-
if (lastsubj && !s) s = lastsubj['woql:subject']
296+
if (lastsubj && !s) s = lastsubj['subject']
300297
let t = ctxt.action || lastsubj['@type']
301298
if (!g) {
302-
const gobj = lastsubj['woql:graph_filter'] || lastsubj['woql:graph']
303-
g = gobj ? gobj['@value'] : 'schema/main'
299+
const gobj = lastsubj['graph_filter'] || lastsubj['graph']
300+
g = gobj ? gobj['@value'] : 'schema'
304301
}
305-
if (t == 'woql:AddTriple') this.and(new WOQLQuery().add_triple(s, p, o))
306-
else if (t == 'woql:DeleteTriple') this.and(new WOQLQuery().delete_triple(s, p, o))
307-
else if (t == 'woql:AddQuad') this.and(new WOQLQuery().add_quad(s, p, o, g))
308-
else if (t == 'woql:DeleteQuad') this.and(new WOQLQuery().delete_quad(s, p, o, g))
309-
else if (t == 'woql:Quad') this.and(new WOQLQuery().quad(s, p, o, g))
310-
else this.and(new WOQLQuery().triple(s, p, o))
302+
if (t == 'AddTriple') this.and(new WOQLQuery().add_quad(s, p, o,g))
303+
else if (t == 'DeleteTriple') this.and(new WOQLQuery().delete_quad(s, p, o,g))
304+
else if (t == 'AddTriple') this.and(new WOQLQuery().add_quad(s, p, o, g))
305+
else if (t == 'DeleteTriple') this.and(new WOQLQuery().delete_quad(s, p, o, g))
306+
else if (t == 'Triple') this.and(new WOQLQuery().quad(s, p, o, g))
307+
else this.and(new WOQLQuery().quad(s, p, o, g))
311308
return this
312309
}
313310

@@ -318,7 +315,7 @@ WOQLQuery.prototype._add_partial = function(s, p, o, g) {
318315
WOQLQuery.prototype._adding_class = function(string_only) {
319316
if (this.triple_builder_context) {
320317
let x = this.triple_builder_context['adding_class']
321-
if (x && string_only && typeof x == 'object') return x['woql:node']
318+
if (x && string_only && typeof x == 'object') return x['node']
322319
return x
323320
}
324321
return false
@@ -346,14 +343,14 @@ WOQLQuery.prototype._set_context = function(ctxt) {
346343
* used to find the class that a property cardinality restriction is applied to
347344
*/
348345
WOQLQuery.prototype._get_object = function(s, p) {
349-
if (this.cursor['@type'] == 'woql:And') {
350-
for (var i = 0; i < this.cursor['woql:query_list'].length; i++) {
351-
let subq = this.cursor['woql:query_list'][i]['woql:query']
346+
if (this.cursor['@type'] == 'And') {
347+
for (var i = 0; i < this.cursor['query_list'].length; i++) {
348+
let subq = this.cursor['query_list'][i]['query']
352349
if (
353-
this._same_entry(subq['woql:subject'], s) &&
354-
this._same_entry(subq['woql:predicate'], p)
350+
this._same_entry(subq['subject'], s) &&
351+
this._same_entry(subq['predicate'], p)
355352
)
356-
return subq['woql:object']
353+
return subq['object']
357354
}
358355
}
359356
return false
@@ -385,9 +382,9 @@ WOQLQuery.prototype._same_entry = function(a, b) {
385382
* @returns {string|boolean}
386383
*/
387384
WOQLQuery.prototype._string_matches_object = function(str, node) {
388-
if (node['woql:node']) return str == node['woql:node']
385+
if (node['node']) return str == node['node']
389386
if (node['@value']) return str == node['@value']
390-
if (node['woql:variable_name']) return str == 'v:' + node['woql:variable_name']['@value']
387+
if (node['variable_name']) return str == 'v:' + node['variable_name']['@value']
391388
return false
392389
}
393390

@@ -405,14 +402,14 @@ WOQLQuery.prototype._card = function(cardValue, which) {
405402
let subject = ctxt.subject
406403
let graph = ctxt.graph
407404
let lastsubj = this.findLastProperty(this.cursor)
408-
if (lastsubj && !subject) subject = lastsubj['woql:subject']
405+
if (lastsubj && !subject) subject = lastsubj['subject']
409406
if (typeof subject === 'object') {
410-
if (subject['woql:node']) subject = subject['woql:node']
407+
if (subject['node']) subject = subject['node']
411408
else return this
412409
}
413410

414411
if (lastsubj && !graph) {
415-
const gobj = lastsubj['woql:graph_filter'] || lastsubj['woql:graph']
412+
const gobj = lastsubj['graph_filter'] || lastsubj['graph']
416413
graph = gobj ? gobj['@value'] : false
417414
}
418415
let cardId = subject + '_' + which + '_' + cardValue

0 commit comments

Comments
 (0)