diff --git a/lib/algebra.ts b/lib/algebra.ts index 40f4f90..738502e 100644 --- a/lib/algebra.ts +++ b/lib/algebra.ts @@ -87,11 +87,11 @@ export interface BaseOperation export interface Paths extends BaseOperation { type : types.PATHS; + start: IriTerm ; + via: IriTerm; + end: IriTerm ; shortest?: boolean; cyclic?: boolean; - start?: rdfjs.Variable | IriTerm; - via?: rdfjs.Variable | IriTerm; - end?: rdfjs.Variable | IriTerm; maxlength?: number } diff --git a/lib/factory.ts b/lib/factory.ts index 184e142..dc95459 100644 --- a/lib/factory.ts +++ b/lib/factory.ts @@ -2,7 +2,7 @@ import * as A from './algebra'; import * as RDF from '@rdfjs/types'; import { DataFactory } from 'rdf-data-factory'; import { stringToTerm } from "rdf-string"; -import { Wildcard } from 'sparqljs-nrt'; +import { IriTerm, Wildcard } from 'sparqljs-nrt'; export default class Factory { @@ -22,15 +22,15 @@ export default class Factory result.variable = variable; return result; } - createPaths(shortest?: boolean, cyclic?: boolean, start?: RDF.Variable | RDF.NamedNode, via?: RDF.Variable | RDF.NamedNode, end?: RDF.Variable | RDF.NamedNode, maxlength?: number): A.Paths { + createPaths(start: IriTerm , via: IriTerm, end: IriTerm , shortest?: boolean, cyclic?: boolean, maxlength?: number): A.Paths { return { type: A.types.PATHS, - shortest, - cyclic, start, via, end, - maxlength + maxlength, + shortest, + cyclic, }; } createBgp (patterns: A.Pattern[]): A.Bgp { return { type: A.types.BGP, patterns }; } diff --git a/lib/sparql.ts b/lib/sparql.ts index 7aad450..08de4e4 100644 --- a/lib/sparql.ts +++ b/lib/sparql.ts @@ -119,12 +119,12 @@ function translatePaths(op: Algebra.Paths): PathsQuery { return { type: 'query', queryType: 'PATHS', + start: op.start , + via: op.via , + end: op.end , prefixes: {}, shortest: op.shortest || false, cyclic: op.cyclic || false, - start: op.start ? op.start as Variable : undefined, - via: op.via ? op.via as Variable : undefined, - end: op.end ? op.end as Variable : undefined, maxlength: op.maxlength || undefined, }; } diff --git a/lib/sparqlAlgebra.ts b/lib/sparqlAlgebra.ts index 6026c01..928c209 100644 --- a/lib/sparqlAlgebra.ts +++ b/lib/sparqlAlgebra.ts @@ -259,11 +259,11 @@ function inScopeVariables(thingy: SparqlQuery | Pattern | PropertyPath | RDF.Ter } function translatePathsQuery(sparql: PathsQuery): Algebra.Operation { return factory.createPaths( + sparql.start, + sparql.via, + sparql.end, sparql.shortest, sparql.cyclic, - sparql.start ? sparql.start as RDF.Variable | RDF.NamedNode : undefined, - sparql.via ? sparql.via as RDF.Variable | RDF.NamedNode : undefined, - sparql.end ? sparql.end as RDF.Variable | RDF.NamedNode : undefined, sparql.maxlength ); } diff --git a/lib/util.ts b/lib/util.ts index 4af8f3c..916222e 100644 --- a/lib/util.ts +++ b/lib/util.ts @@ -183,6 +183,8 @@ export default class Util switch (result.type) { + case types.PATHS: + break case types.ALT: result.input.map(recurseOp); break; @@ -353,11 +355,11 @@ export default class Util } if (result.type === types.PATHS) { result = factory.createPaths( + result.start, + result.via , + result.end, result.shortest, result.cyclic, - result.start ? result.start as RDF.Variable | RDF.NamedNode : undefined, - result.via ? result.via as RDF.Variable | RDF.NamedNode : undefined, - result.end ? result.end as RDF.Variable | RDF.NamedNode : undefined, result.maxlength ); } diff --git a/package-lock.json b/package-lock.json index fbace9d..2605e44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "sparqlalgebrajs", - "version": "4.3.7", + "name": "sparqlalgebrajs-nrt", + "version": "1.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "sparqlalgebrajs", - "version": "4.3.7", + "name": "sparqlalgebrajs-nrt", + "version": "1.0.2", "license": "MIT", "dependencies": { "@rdfjs/types": "*", @@ -18,10 +18,10 @@ "rdf-string": "^1.6.0", "rdf-terms": "^1.10.0", "sparqlalgebrajs": "^4.3.7", - "sparqljs-nrt": "^1.0.8" + "sparqljs-nrt": "^1.1.2" }, "bin": { - "sparqlalgebrajs": "bin/sparqlalgebrajs.js" + "sparqlalgebrajs-nrt": "bin/sparqlalgebrajs.js" }, "devDependencies": { "@tsconfig/node12": "^12.0.0", @@ -3491,12 +3491,11 @@ } }, "node_modules/sparqljs-nrt": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/sparqljs-nrt/-/sparqljs-nrt-1.0.8.tgz", - "integrity": "sha512-EF5Z4XjClrrROGF7cgEuPiZJNsdQbJZeAQ9NLG2ymwkYM47BgXRe3pkH1+AlXKzFW6Q4WVOAGA1O+P3o/O2y0A==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sparqljs-nrt/-/sparqljs-nrt-1.1.2.tgz", + "integrity": "sha512-ZcTZ4qLJ77hByndKtzQ3rLFhZgLMUHI9dJrfiV0JzKJ1Zsu2QG5x8ddpzNK/r+bpBTOfJmfmylELZq8KNuKceA==", "dependencies": { - "rdf-data-factory": "^1.1.2", - "sparqljs-nrt": "^1.0.8" + "rdf-data-factory": "^1.1.2" }, "bin": { "sparqljs": "bin/sparql-to-json" @@ -6653,12 +6652,11 @@ } }, "sparqljs-nrt": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/sparqljs-nrt/-/sparqljs-nrt-1.0.8.tgz", - "integrity": "sha512-EF5Z4XjClrrROGF7cgEuPiZJNsdQbJZeAQ9NLG2ymwkYM47BgXRe3pkH1+AlXKzFW6Q4WVOAGA1O+P3o/O2y0A==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sparqljs-nrt/-/sparqljs-nrt-1.1.2.tgz", + "integrity": "sha512-ZcTZ4qLJ77hByndKtzQ3rLFhZgLMUHI9dJrfiV0JzKJ1Zsu2QG5x8ddpzNK/r+bpBTOfJmfmylELZq8KNuKceA==", "requires": { - "rdf-data-factory": "^1.1.2", - "sparqljs-nrt": "^1.0.8" + "rdf-data-factory": "^1.1.2" } }, "spawn-sync": { diff --git a/package.json b/package.json index 825bf8d..febc92c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "sparqlalgebrajs", - "version": "4.3.7", + "name": "sparqlalgebrajs-nrt", + "version": "1.0.3", "description": "Convert SPARQL to SPARQL algebra", "author": "Joachim Van Herwegen", "license": "MIT", @@ -24,7 +24,7 @@ "rdf-string": "^1.6.0", "rdf-terms": "^1.10.0", "sparqlalgebrajs": "^4.3.7", - "sparqljs-nrt": "^1.0.8" + "sparqljs-nrt": "^1.1.3" }, "devDependencies": { "@tsconfig/node12": "^12.0.0",