Skip to content

Commit a7c233d

Browse files
committed
Merge branch 'canary' into rc
2 parents 0d25ffd + 93b8a55 commit a7c233d

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

lib/const.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ module.exports = Object.freeze({
3838
GET_CSV: 'get_csv',
3939
UPDATE_CSV: 'update_csv',
4040
DELETE_CSV: 'delete_csv',
41-
MESSAGE: 'message'
41+
MESSAGE: 'message',
42+
INFO: 'info'
4243
})

lib/dispatchRequest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function DispatchRequest(url, action, payload, local_auth, remote_auth = null) {
8686
case CONST.READ_ORGANIZATION:
8787
case CONST.CONNECT:
8888
case CONST.GET_CSV:
89+
case CONST.INFO:
8990
if (payload) {
9091
const ext = UTILS.URIEncodePayload(payload)
9192
if (ext) url += `?${ext}`

lib/woqlClient.js

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,17 @@ WOQLClient.prototype.insertTriples = function(gtype, gid, turtle, commit_msg) {
394394
}
395395

396396
/**
397-
* Inserts a csv into the specified path
397+
* Inserts a csv from a specified path
398398
*
399-
* @param {array} csv_path is an array of csv file names
400-
* @param {string} commitMsg Textual message describing the reason for the update
399+
* @param {array} csv_path is an array of csv file names with file path
400+
* @param {string} commit_msg Textual message describing the reason for the update
401401
* @param {string} gtype type of graph |instance|schema|inference|
402402
* @param {string} gid TerminusDB Graph ID to update, main is the default value
403403
* @return {Promise} An API success message
404404
*/
405-
WOQLClient.prototype.insertCSV = function(csv_path, commitMsg, gtype, gid) {
406-
if (commitMsg && csv_path) {
407-
let commit = this.generateCommitInfo(commitMsg)
405+
WOQLClient.prototype.insertCSV = function(csv_path, commit_msg, gtype, gid) {
406+
if (commit_msg && csv_path) {
407+
let commit = this.generateCommitInfo(commit_msg)
408408
const formData = new FormData();
409409
csv_path.map((item)=>{
410410
if(typeof(item.name)=="string"){
@@ -429,17 +429,17 @@ WOQLClient.prototype.insertCSV = function(csv_path, commitMsg, gtype, gid) {
429429
* Updates the contents of the specified path with a csv, creating the appropriate
430430
* diff object as the commit.
431431
*
432-
* @param {array} csvPaths Array csvs to upload
433-
* @param {string} commitMsg Textual message describing the reason for the update
432+
* @param {array} csv_path Array csvs to upload
433+
* @param {string} commit_msg Textual message describing the reason for the update
434434
* @param {string} gtype type of graph |instance|schema|inference|
435435
* @param {string} gid TerminusDB Graph ID to update, main is the default value
436436
* @return {Promise} An API success message
437437
*/
438-
WOQLClient.prototype.updateCSV = function(csv, commitMsg, gtype, gid) {
439-
if (commitMsg && csv) {
440-
let commit = this.generateCommitInfo(commitMsg)
438+
WOQLClient.prototype.updateCSV = function(csv_path, commit_msg, gtype, gid) {
439+
if (commit_msg && csv_path) {
440+
let commit = this.generateCommitInfo(commit_msg)
441441
const formData = new FormData();
442-
csv.map((item)=>{
442+
csv_path.map((item)=>{
443443
formData.append(item.fileToBeUpdated, item.updateWith)
444444
})
445445
formData.append('payload', JSON.stringify(commit))
@@ -454,23 +454,22 @@ WOQLClient.prototype.updateCSV = function(csv, commitMsg, gtype, gid) {
454454
/**
455455
* Retrieves the contents of the specified graph as a CSV
456456
*
457-
* @param {string} csvName Name of csv to dump from the specified database to extract
458-
* @param {string} csvDirectory CSV output directory path. (defaults to current directory).
457+
* @param {string} csv_name Name of csv to dump from the specified database to extract
459458
* @param {string} download flag to download csv file
460459
* @param {string} gtype Type of graph (instance|schema|inference)
461460
* @param {string} gid identifier.
462461
* @return {Promise} An API success message
463462
*
464463
*/
465-
WOQLClient.prototype.getCSV = function(csvName, download, gtype, gid) {
464+
WOQLClient.prototype.getCSV = function(csv_name, download, gtype, gid) {
466465
let options = {}, filePath
467-
options.name=csvName;
466+
options.name=csv_name;
468467
return this.dispatch(CONST.GET_CSV, this.connectionConfig.csvURL(gtype, gid), options).then(results => {
469468
if (download) {
470469
const url=window.URL.createObjectURL(new Blob([results]));
471470
const link=document.createElement('a');
472471
link.href = url;
473-
link.setAttribute('download', csvName);
472+
link.setAttribute('download', csv_name);
474473
document.body.appendChild(link);
475474
link.click();
476475
}
@@ -481,17 +480,15 @@ WOQLClient.prototype.getCSV = function(csvName, download, gtype, gid) {
481480
/**
482481
* Deletes a csv into the specified path
483482
*
484-
* @param {array} csvName is an array of csv file names
485-
* @param {string} commitMsg Textual message describing the reason for the delete
486-
* @param {string} gtype type of graph |instance|schema|inference|
487-
* @param {string} gid TerminusDB Graph ID to update, main is the default value
483+
* @param {array} csv_name is an array of csv file names
484+
* @param {string} commit_msg Textual message describing the reason for the delete
488485
* @return {Promise} An API success message
489486
*/
490-
WOQLClient.prototype.deleteCSV = function(csvName, commitMsg, gtype, gid) {
491-
if (commitMsg && csvName) {
492-
let commit = this.generateCommitInfo(commitMsg)
487+
WOQLClient.prototype.deleteCSV = function(csv_name, commit_msg) {
488+
if (commit_msg && csv_name) {
489+
let commit = this.generateCommitInfo(commit_msg)
493490
let options = {}, filePath
494-
options.name=csvName;
491+
options.name=csv_name;
495492
options.commit_info=commit.commit_info
496493
return this.dispatch(CONST.DELETE_CSV, this.connectionConfig.csvURL(), options).then(results => {
497494
return results;
@@ -510,6 +507,17 @@ WOQLClient.prototype.message = function(message) {
510507
})
511508
}
512509

510+
/**
511+
* gets terminusdb server info
512+
* @param {string} msg - textual string
513+
*/
514+
WOQLClient.prototype.info = function() {
515+
const url = this.api() + 'info'
516+
return this.dispatch(CONST.INFO, url).then(response => {
517+
return response
518+
})
519+
}
520+
513521

514522
/**
515523
* Executes a WOQL query on the specified database and returns the results

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"author": "kevin@terminusdb.com",
2020
"license": "Apache-2.0",
2121
"dependencies": {
22-
"axios": "^0.19.2",
23-
"documentation": "^13.0.2"
22+
"axios": "^0.19.2"
2423
},
2524
"devDependencies": {
25+
"documentation": "^13.0.2",
2626
"@babel/core": "^7.8.4",
2727
"@babel/preset-env": "^7.8.4",
2828
"@babel/register": "^7.8.3",

0 commit comments

Comments
 (0)