@@ -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 */
356375WOQLClient . 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 */
413432WOQLClient . 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 */
434453WOQLClient . prototype . dispatchFetch = function ( url , action , payload ) {
435454 const api = {
0 commit comments