Skip to content

Commit 5dbaf12

Browse files
Merge branch 'dev' of https://github.com/terminusdb/terminus-client into dev
2 parents 4f28ad4 + 429e20e commit 5dbaf12

File tree

10 files changed

+83
-27
lines changed

10 files changed

+83
-27
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
before_script:
22
- |
3-
if [[ $TRAVIS_BRANCH == 'clientBuild' && $TRAVIS_COMMIT_MESSAGE == *"[run deploy]"* ]]; then
3+
if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_COMMIT_MESSAGE == *"[run deploy]"* ]]; then
44
echo "__INCREMENT_VERSION_NUMBER__"
55
export PACKAGE_VERSION=$(npm version patch)
66
npm install -g documentation
@@ -20,7 +20,8 @@ after_script:
2020

2121
branches:
2222
only:
23-
- clientBuild
23+
- master
24+
- dev
2425

2526
before_deploy:
2627
- |
@@ -41,7 +42,7 @@ deploy:
4142
keep_history: true
4243
script: bash public_pages.sh
4344
on:
44-
branch: clientBuild
45+
branch: master
4546
condition: $TRAVIS_COMMIT_MESSAGE == *"[run deploy]"*
4647
- provider: releases
4748
target_commitish : $LAST_HASH
@@ -50,7 +51,7 @@ deploy:
5051
skip_cleanup: true
5152
overwrite: true
5253
on:
53-
branch: clientBuild
54+
branch: master
5455
condition: $TRAVIS_COMMIT_MESSAGE == *"[run deploy]"*
5556
- provider: npm
5657
registry: "https://registry.npmjs.org/"
@@ -61,5 +62,5 @@ deploy:
6162
keep_history: true
6263
auth_method: "authToken"
6364
on:
64-
branch : clientBuild
65+
branch : master
6566
condition: $TRAVIS_COMMIT_MESSAGE == *"[run deploy]"*

lib/connectionConfig.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ConnectionConfig.prototype.schemaURL = function () {
8484

8585
/**
8686
* @param {String} inputStr - the URL of a Terminus DB base install or schema endpoint
87-
* @param {Object} [context] optional json-ld context
87+
* @param {Object} [context] optional json-ld context
8888
* sets the connection to point at the query api URL
8989
*/
9090
ConnectionConfig.prototype.setQueryURL = function (inputStr, context) {
@@ -102,9 +102,11 @@ ConnectionConfig.prototype.queryURL = function () {
102102
return `${this.dbURL()}/woql`;
103103
};
104104

105+
106+
105107
/**
106108
* @param {String} inputStr - the URL of a Terminus DB base install or frame endpoint
107-
* @param {Object} [context] optional json-ld context
109+
* @param {Object} [context] optional json-ld context
108110
* sets the connection to point at the class frame api URL
109111
*/
110112
ConnectionConfig.prototype.setClassFrameURL = function (inputStr, context) {
@@ -124,7 +126,7 @@ ConnectionConfig.prototype.frameURL = function () {
124126

125127
/**
126128
* @param {String} inputStr - the URL of a Terminus DB base install or document endpoint
127-
* @param {Object} [context] optional json-ld context
129+
* @param {Object} [context] optional json-ld context
128130
* sets the connection to point at the document api URL
129131
*/
130132
ConnectionConfig.prototype.setDocument = function (inputStr, context) {

lib/const.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = Object.freeze({
1111
UPDATE_DOCUMENT: 'update_document',
1212
CLASS_FRAME: 'class_frame',
1313
WOQL_SELECT: 'woql_select',
14+
TERMINUS_MESSAGE: 'terminus_message',
1415
GET_DOCUMENT: 'get_document',
1516
DELETE_DATABASE: 'delete_database',
1617
DELETE_DOCUMENT: 'delete_document',

lib/dispatchRequest.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ErrorMessage = require('./errorMessage');
66

77

88
/**
9-
* base 64 encodes a string using either the btoa implementation if available or the Buffer object.
9+
* base 64 encodes a string using either the btoa implementation if available or the Buffer object.
1010
* @param {String} str string to be base 64 encoded
1111
*/
1212
function btoaImplementation(str) {
@@ -21,7 +21,7 @@ function btoaImplementation(str) {
2121
/**
2222
* @file Dispatch Request
2323
* @license Apache Version 2
24-
* @description Functions for dispatching API requests via the axios library.
24+
* @description Functions for dispatching API requests via the axios library.
2525
* @param {String} url API endpoint URL
2626
* @param {String} action API action
2727
* @param {Object} payload data to be transmitted to endpoint
@@ -59,6 +59,7 @@ function DispatchRequest(url, action, payload) {
5959
case CONST.UPDATE_SCHEMA:
6060
case CONST.CREATE_DOCUMENT:
6161
case CONST.UPDATE_DOCUMENT:
62+
case CONST.TERMINUS_MESSAGE:
6263
case CONST.WOQL_UPDATE:
6364
options.headers = options.headers ? options.headers : {};
6465
options.headers['Content-Type'] = 'application/json';
@@ -86,7 +87,7 @@ function DispatchRequest(url, action, payload) {
8687
if(err.response && err.response.data){
8788
e.data = err.response.data;
8889
}
89-
throw e;
90+
throw e;
9091
});
9192
}
9293
}

lib/viewer/graphConfig.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,29 @@ WOQLGraphConfig.prototype.selected_grows = function(v){
7373
return this.bigsel;
7474
}
7575

76-
WOQLGraphConfig.prototype.width = function(v){
77-
if(typeof v != "undefined"){
78-
this.gwidth = v;
76+
/**
77+
* no parameter get the graph width or
78+
* set the graph width and return the WOQLGraphConfig
79+
* @param {size} Number
80+
*/
81+
82+
WOQLGraphConfig.prototype.width = function(size){
83+
if(typeof size != "undefined"){
84+
this.gwidth = size;
7985
return this;
8086
}
8187
return this.gwidth;
8288
}
8389

84-
WOQLGraphConfig.prototype.height = function(v){
85-
if(typeof v != "undefined"){
86-
this.gheight = v;
90+
/**
91+
* no parameter get the graph height or
92+
* set the graph height and return the WOQLGraphConfig
93+
* @param {size} Number
94+
*/
95+
96+
WOQLGraphConfig.prototype.height = function(size){
97+
if(typeof size != "undefined"){
98+
this.gheight = size;
8799
return this;
88100
}
89101
return this.gheight;

lib/woql.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ WOQL.with = function(graph, source, query){ return new WOQLQuery().with(graph, s
219219
* @param {string} vari - Target
220220
* @return {object} WOQLQuery
221221
*/
222-
WOQL.as = function(map, vari){ return new WOQLQuery().as(map, vari); }
222+
WOQL.as = function(map, vari, ty){ return new WOQLQuery().as(map, vari, ty); }
223223

224224
/**
225225
* Provides details of a remote data source in a JSON format that includes a URL property
@@ -1529,7 +1529,7 @@ WOQLQuery.prototype.boxDatatype = function(datatype, label, descr, graph, prefix
15291529
}
15301530

15311531

1532-
WOQLQuery.prototype.as = function(a, b){
1532+
WOQLQuery.prototype.as = function(a, b, c){
15331533
if(!a) return;
15341534
if(!this.asArray){
15351535
this.asArray = true;
@@ -1538,7 +1538,12 @@ WOQLQuery.prototype.as = function(a, b){
15381538
if(b){
15391539
b = (b.indexOf(":") == -1 ? "v:" + b : b);
15401540
var val = (typeof a == "object" ? a : { "@value" : a});
1541-
this.query.push({as: [val, b]});
1541+
1542+
if(c){
1543+
this.query.push({as: [val, b, c]});
1544+
}else{
1545+
this.query.push({as: [val, b]});
1546+
}
15421547
}
15431548
else {
15441549
a = (a.indexOf(":") == -1 ? "v:" + a : a);

lib/woqlClient.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const UTILS = require('./utils.js');
1313
* Simple Javascript Client for accessing the Terminus DB API
1414
* Constructor - takes an option json list of connection parameters
1515
* @param {Object} params a json object containing connection parameters
16-
* which can be:
16+
* which can be:
1717
* params.server URL of server to connect to
1818
* params.dbid ID of database to connect to
1919
* params.docid = ID of document to load;
@@ -319,12 +319,31 @@ WOQLClient.prototype.update = function (qurl, woql, opts) {
319319
);
320320
}
321321
const fileList = opts ? opts.fileList : {};
322+
323+
//var formData = new FormData();
324+
//formData.set('file', file);
325+
322326
let q = {'terminus:query' : JSON.stringify(woql), ...fileList};
323327

324328
q = this.addOptionsToWOQL(q, opts);
325329
return this.dispatch(this.connectionConfig.queryURL(), CONST.WOQL_UPDATE, q);
326330
};
327331

332+
/**
333+
* Executes a WOQL query on the server which keeps log of messages
334+
*
335+
* the first argument (payload) will include the message
336+
* the third argument (opts) is an options json - opts.key is an optional API key
337+
*/
338+
WOQLClient.prototype.serverLog = function (payload, opts) {
339+
let endpoint = this.connectionConfig.server + "message";
340+
let q = {'@type' : "terminus:APIUpdate", "terminus:message" : payload};
341+
342+
q = this.addOptionsToWOQL(q, opts);
343+
return this.dispatch(endpoint, CONST.TERMINUS_MESSAGE, q);
344+
};
345+
346+
328347
/**
329348
* Retrieves a WOQL query on the specified database which updates the state and returns the results
330349
*
@@ -351,7 +370,7 @@ WOQLClient.prototype.getClassFrame = function (cfurl, cls, opts) {
351370

352371
/**
353372
* Adds a key to the passed woql query if it is present in the opts json
354-
*
373+
*
355374
*/
356375
WOQLClient.prototype.addOptionsToWOQL = function (woql, opts) {
357376
if (opts && opts.key) {
@@ -368,7 +387,7 @@ WOQLClient.prototype.addOptionsToDocument = function (doc, opts) {
368387
const pdoc = {};
369388
pdoc['@context'] = doc['@context'];
370389
// add blank node prefix as document base url
371-
if (pdoc['@context'] && doc['@id']) {
390+
if (pdoc['@context'] && doc['@id']) {
372391
pdoc['@context']._ = `${doc['@id']}/`;
373392
}
374393
if (opts && opts['terminus:encoding'] && opts['terminus:encoding'] === 'terminus:turtle') {
@@ -407,7 +426,7 @@ WOQLClient.prototype.addKeyToPayload = function (payload, url) {
407426

408427
/**
409428
* Document updates include the URL in both the endpoint and the document itself
410-
* This ensures that they are the same by using the endpoint URL as the authoritative version
429+
* This ensures that they are the same by using the endpoint URL as the authoritative version
411430
* and copying it into the embedded document ID
412431
*/
413432
WOQLClient.prototype.makeDocumentConsistentWithURL = function (doc, dburl) {
@@ -429,7 +448,7 @@ WOQLClient.prototype.dispatch = function (url, action, payload) {
429448
};
430449

431450
/**
432-
* If the use_fetch switch is set, the browser's built in fetch will be used rather than the npm axios module
451+
* If the use_fetch switch is set, the browser's built in fetch will be used rather than the npm axios module
433452
*/
434453
WOQLClient.prototype.dispatchFetch = function (url, action, payload) {
435454
const api = {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@terminusdb/terminus-client",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "TerminusDB client library",
55
"main": "index.js",
66
"directories": {

test/woql.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,21 @@ describe('woql queries', function () {
347347

348348
})
349349

350+
it('check the join method',function(){
351+
352+
const woqlObject=WOQL.join(["v:A_obj", "v:B_obj"], ", ", "v:output");
353+
const jsonObj={
354+
'join': [
355+
[ 'v:A_obj', 'v:B_obj' ],
356+
{ '@value': ', ', '@type': 'xsd:string' },
357+
'v:output'
358+
]
359+
};
360+
361+
expect(woqlObject.json()).to.eql(jsonObj);
362+
363+
})
364+
350365
it('check the split method',function(){
351366

352367
const woqlObject=WOQL.split("A, B, C", ", ", "v:list_obj");

0 commit comments

Comments
 (0)