Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sage-client

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sage-client - npm Package Compare versions

Comparing version 1.1.4 to 1.2.0

src/operators/bound-join.js

5

bin/sage-client.js

@@ -33,3 +33,3 @@ #!/usr/bin/env node

// const JSONFormatter = require('../src/formatters/json-formatter.js')
const XMLFormatter = require('sparql-engine/src/formatters/xml-formatter.js')
// const XMLFormatter = require('sparql-engine/src/formatters/xml-formatter.js')
//

@@ -77,5 +77,6 @@ // const mimetypes = {

// TODO change to: const iterator = client.execute(query, program.type)
if (program.type === 'xml') {
/* if (program.type === 'xml') {
iterator = new XMLFormatter(iterator)
}
*/

@@ -82,0 +83,0 @@ iterator.on('error', error => {

{
"name": "sage-client",
"version": "1.1.4",
"version": "1.2.0",
"description": "Javascript client for SaGe interfaces",

@@ -34,7 +34,6 @@ "main": "./src/lib.js",

"dependencies": {
"asynciterator": "^2.0.0",
"commander": "^2.15.1",
"lodash": "^4.17.5",
"request": "^2.85.0",
"sparql-engine": "^0.2.1",
"sparql-engine": "^0.3.2",
"xml": "^1.0.1"

@@ -41,0 +40,0 @@ },

2

src/client.js

@@ -73,3 +73,3 @@ /* file : client.js

this._builder.bgpExecutor = new SageBGPExecutor(this._dataset)
this._builder.serviceExecutor = new SageServiceExecutor(this._builder, this._dataset)
this._builder.serviceExecutor = new SageServiceExecutor(this._dataset)
// prepare execution options

@@ -76,0 +76,0 @@ this._options = {

@@ -27,4 +27,4 @@ /* file : sage-bgp-executor.js

const { BGPExecutor } = require('sparql-engine').executors
const BindJoinOperator = require('../operators/bindjoin-operator.js')
const { BGPExecutor } = require('sparql-engine')
const boundJoin = require('../operators/bound-join.js')

@@ -39,6 +39,3 @@ /**

_execute (source, graph, patterns, options, isJoinIdentity) {
if (isJoinIdentity) {
return super._execute(source, graph, patterns, options, true)
}
return new BindJoinOperator(source, patterns, graph, options)
return boundJoin(source, patterns, graph, options)
}

@@ -45,0 +42,0 @@ }

@@ -27,3 +27,3 @@ /* file : sage-service-executor.js

const { ServiceExecutor } = require('sparql-engine').executors
const { ServiceExecutor } = require('sparql-engine')
const SageGraph = require('../sage-graph.js')

@@ -39,4 +39,4 @@ const { cloneDeep } = require('lodash')

class SageServiceExecutor extends ServiceExecutor {
constructor (builder, dataset) {
super(builder)
constructor (dataset) {
super()
this._dataset = dataset

@@ -58,3 +58,3 @@ }

}
return this._builder._buildQueryPlan(subquery, opts, source)
return this.builder._buildQueryPlan(subquery, opts, source)
}

@@ -61,0 +61,0 @@ }

@@ -27,81 +27,35 @@ /* file : sage-operator.js

const { BufferedIterator } = require('asynciterator')
const { Observable } = require('rxjs')
const { BindingBase } = require('sparql-engine')
/**
* A SageOperator is an iterator over the evaluation of a BGP against a NLJ/BGP interface
* @extends BufferedIterator
* @memberof Operators
* @author Thomas Minier
*/
class SageOperator extends BufferedIterator {
/**
* Constructor
* @memberof Operators
* @param {Object[]} bgp - BGP to evaluate
* @param {SageRequestClient} sageClient - HTTP client used to query a Sage server
* @param {Object[]} optionals - Optional BGPs to evaluate
* @param {Object[]} filters - Set of filters to evaluate
*/
constructor (bgp, sageClient, options) {
super()
this._options = options
for (var i = 0; i < bgp.length; i++) {
var tp = bgp[i]
for (var variable in tp) {
if (tp[variable].startsWith('_:')) {
var newVar = '?' + tp[variable].slice(2)
tp[variable] = newVar
if (this._options.artificials != null) {
this._options.artificials.push(newVar)
} else {
this._options.artificials = []
this._options.artificials.push(newVar)
}
}
async function query (observer, type, bgp, sageClient, options) {
let hasNext = true
let next = null
while (hasNext) {
try {
const body = await sageClient.query(type, bgp, next)
body.bindings
.forEach(b => observer.next(BindingBase.fromObject(b)))
hasNext = body.hasNext
if (hasNext) {
next = body.next
}
} catch (e) {
hasNext = false
observer.error(e)
}
this._bgp = bgp
this._next = null
this._bufferedValues = []
this._sageClient = sageClient
}
}
_flush (done) {
if (this._bufferedValues.length > 0) {
this._bufferedValues.forEach(b => this._push(b))
}
done()
}
_read (count, done) {
// try to find values previously downloaded
while (count > 0 && this._bufferedValues.length > 0) {
this._push(this._bufferedValues.shift())
count--
}
// fetch more values from the server
if (count <= 0) {
done()
} else {
this._sageClient.query('bgp', this._bgp, this._next)
.then(body => {
this._bufferedValues = body.bindings.slice(0)
if (body.next) {
this._next = body.next
this._read(count, done)
} else {
this.close()
done()
}
})
.catch(err => {
this.emit('error', err)
this.close()
done()
})
}
}
/**
* Constructor
* @param {Object[]} bgp - BGP to evaluate
* @param {SageRequestClient} sageClient - HTTP client used to query a Sage server
*/
module.exports = function (bgp, type, sageClient, options) {
return new Observable(observer => {
query(observer, type, bgp, sageClient, options)
.then(() => observer.complete())
.catch(err => observer.error(err))
})
}
module.exports = SageOperator

@@ -48,7 +48,7 @@ /* file : sage-graph.js

evalBGP (bgp, options) {
return new SageOperator(bgp, this._httpClient, options)
return SageOperator(bgp, 'bgp', this._httpClient, options)
}
evalUnion (patterns, nextLink = null) {
return this._httpClient.query('union', patterns, nextLink)
evalUnion (patterns, options) {
return SageOperator(patterns, 'union', this._httpClient, options)
}

@@ -55,0 +55,0 @@ }

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc