@comunica/actor-query-operation-construct 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +22 -0
- package/lib/BindingsToQuadsIterator.js.map +1 -1
- package/package.json +9 -9
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
|
|
4
|
+
Comunica Association and Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindingsToQuadsIterator.js","sourceRoot":"","sources":["BindingsToQuadsIterator.ts"],"names":[],"mappings":";;;AAGA,iDAAsE;AACtE,uDAA+C;AAC/C,yCAAqC;
|
|
1
|
+
{"version":3,"file":"BindingsToQuadsIterator.js","sourceRoot":"","sources":["BindingsToQuadsIterator.ts"],"names":[],"mappings":";;;AAGA,iDAAsE;AACtE,uDAA+C;AAC/C,yCAAqC;AAErC,MAAM,EAAE,GAAG,IAAI,8BAAW,EAAE,CAAC;AAE7B;;;;;GAKG;AACH,MAAa,uBAAwB,SAAQ,sCAA0C;IAKrF,YAAmB,QAAwB,EAAE,cAA8B,EAAE,kBAAkB,GAAG,IAAI;QACpG,KAAK,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAkB,EAAE,IAAc;QACvD,IAAI,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE;YAChC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAC3B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAkB,EAAE,OAAqB;QAC9D,IAAI;YACF,OAAO,IAAA,oBAAQ,EAAY,OAAO,EAAE,IAAI,CAAC,EAAE;gBACzC,MAAM,SAAS,GAAG,uBAAuB,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACnE,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;iBACjC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC,CAAC;SACJ;QAAC,MAAM;YACN,aAAa;SACd;IACH,CAA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'@rdfjs/types';\nimport type { AsyncIterator } from 'asynciterator';\nimport { ArrayIterator, MultiTransformIterator } from 'asynciterator';\nimport { DataFactory } from 'rdf-data-factory';\nimport { mapTerms } from 'rdf-terms';\n\nconst DF = new DataFactory();\n\n/**\n * Transforms a bindings stream into a quad stream given a quad template.\n *\n * This conforms to the SPARQL 1.1 spec on constructing triples:\n * https://www.w3.org/TR/sparql11-query/#rConstructTriples\n */\nexport class BindingsToQuadsIterator extends MultiTransformIterator<Bindings, RDF.Quad> {\n protected readonly template: RDF.BaseQuad[];\n protected readonly localizeBlankNodes: boolean;\n protected blankNodeCounter: number;\n\n public constructor(template: RDF.BaseQuad[], bindingsStream: BindingsStream, localizeBlankNodes = true) {\n super(bindingsStream, { autoStart: false });\n this.template = template;\n this.localizeBlankNodes = localizeBlankNodes;\n this.blankNodeCounter = 0;\n }\n\n /**\n * Bind the given term.\n * If the term is a variable and the variable is bound in the bindings object,\n * return the bindings value.\n * If the term is a variable and the variable is not bound in the bindings object,\n * a falsy value is returned..\n * Otherwise, the term itself is returned.\n * @param {Bindings} bindings A bindings object.\n * @param {RDF.Term} term An RDF term.\n * @return {RDF.Term} If the given term is not a variable, the term itself is returned.\n * If the given term is a variable, then the bound term is returned,\n * or a falsy value if it did not exist in the bindings.\n */\n public static bindTerm(bindings: Bindings, term: RDF.Term): RDF.Term | undefined {\n if (term.termType === 'Variable') {\n return bindings.get(term);\n }\n return term;\n }\n\n /**\n * Bind the given quad pattern.\n * If one of the terms was a variable AND is not bound in the bindings,\n * a falsy value will be returned.\n * @param {Bindings} bindings A bindings object.\n * @param {RDF.Quad} pattern An RDF quad.\n * @return {RDF.Quad} A bound RDF quad or undefined.\n */\n public static bindQuad(bindings: Bindings, pattern: RDF.BaseQuad): RDF.Quad | undefined {\n try {\n return mapTerms(<RDF.Quad> pattern, term => {\n const boundTerm = BindingsToQuadsIterator.bindTerm(bindings, term);\n if (!boundTerm) {\n throw new Error('Unbound term');\n }\n return boundTerm;\n });\n } catch {\n // Do nothing\n }\n }\n\n /**\n * Convert a blank node to a unique blank node in the given context.\n * If the given term is not a blank node, the term itself will be returned.\n * @param blankNodeCounter A counter value for the blank node.\n * @param {RDF.Term} term The term that should be localized.\n * @return {RDF.Term} A term.\n */\n public static localizeBlankNode(blankNodeCounter: number,\n term: RDF.Term): RDF.Term {\n if (term.termType === 'BlankNode') {\n return DF.blankNode(`${term.value}${blankNodeCounter}`);\n }\n return term;\n }\n\n /**\n * Convert the given quad to a quad that only contains unique blank nodes.\n * @param blankNodeCounter A counter value for the blank node.\n * @param {RDF.BaseQuad} pattern The pattern that should be localized.\n * @return {RDF.BaseQuad} A quad.\n */\n public static localizeQuad(blankNodeCounter: number,\n pattern: RDF.BaseQuad): RDF.BaseQuad {\n return mapTerms(pattern, term => BindingsToQuadsIterator.localizeBlankNode(blankNodeCounter, term));\n }\n\n /**\n * Convert the given template to a list of quads based on the given bindings.\n * @param {Bindings} bindings A bindings object.\n * @param {RDF.Quad[]} template A list of quad patterns.\n * @param blankNodeCounter A counter value for the blank node.\n * @return {RDF.Quad[]} A list of quads.\n */\n public bindTemplate(bindings: Bindings, template: RDF.BaseQuad[], blankNodeCounter: number): RDF.Quad[] {\n let quads: RDF.BaseQuad[] = <RDF.BaseQuad[]> template\n // Bind variables to bound terms\n .map(x => BindingsToQuadsIterator.bindQuad.bind(null, bindings)(x))\n // Remove quads that contained unbound terms, i.e., variables.\n .filter(Boolean);\n if (this.localizeBlankNodes) {\n // Make sure the multiple instantiations of the template contain different blank nodes, as required by SPARQL 1.1.\n quads = quads.map(BindingsToQuadsIterator.localizeQuad.bind(null, blankNodeCounter));\n }\n return <RDF.Quad[]> quads;\n }\n\n public _createTransformer(bindings: Bindings): AsyncIterator<RDF.Quad> {\n return new ArrayIterator(this.bindTemplate(\n bindings, this.template, this.blankNodeCounter++,\n ));\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-operation-construct",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "A construct query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,20 +32,20 @@
|
|
|
32
32
|
"lib/**/*.js.map"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@comunica/bus-query-operation": "^2.5.
|
|
36
|
-
"@comunica/context-entries": "^2.5.
|
|
37
|
-
"@comunica/core": "^2.5.
|
|
38
|
-
"@comunica/types": "^2.5.
|
|
35
|
+
"@comunica/bus-query-operation": "^2.5.1",
|
|
36
|
+
"@comunica/context-entries": "^2.5.1",
|
|
37
|
+
"@comunica/core": "^2.5.1",
|
|
38
|
+
"@comunica/types": "^2.5.1",
|
|
39
39
|
"@rdfjs/types": "*",
|
|
40
40
|
"asynciterator": "^3.8.0",
|
|
41
|
-
"rdf-data-factory": "^1.
|
|
42
|
-
"rdf-terms": "^1.
|
|
43
|
-
"sparqlalgebrajs": "^4.0.
|
|
41
|
+
"rdf-data-factory": "^1.1.1",
|
|
42
|
+
"rdf-terms": "^1.9.1",
|
|
43
|
+
"sparqlalgebrajs": "^4.0.5"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "npm run build:ts && npm run build:components",
|
|
47
47
|
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
48
48
|
"build:components": "componentsjs-generator"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "d64e87fad4a616224c210c2d22b38f6f9b00e1ea"
|
|
51
51
|
}
|