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

@comunica/bus-query-operation

Package Overview
Dependencies
Maintainers
5
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@comunica/bus-query-operation - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

9

lib/Bindings.d.ts

@@ -20,5 +20,8 @@ import type { BindingsFactory } from '@comunica/bindings-factory';

* Materialize the given operation (recursively) with the given bindings.
* Essentially, all variables in the given operation will be replaced
* Essentially, the variables in the given operation
* which don't appear in the projection operation will be replaced
* by the terms bound to the variables in the given bindings.
* @param {Algebra.Operation} operation SPARQL algebra operation.
* And the variables that appear in the projection operation
* will be added to a new values operation.
* @param {Bindings} bindings A bindings object.

@@ -28,3 +31,4 @@ * @param bindingsFactory The bindings factory.

* @param options.strictTargetVariables If target variable bindings (such as on SELECT or BIND) should not be allowed.
* @param options.bindFilter If filter expressions should be materialized
* @param options.bindFilter If filter expressions should be materialized.
* @param options.originalBindings The bindings object as it was at the top level call of materializeOperation.
* @return Algebra.Operation A new operation materialized with the given bindings.

@@ -35,2 +39,3 @@ */

bindFilter?: boolean;
originalBindings?: Bindings;
}): Algebra.Operation;

@@ -37,5 +37,8 @@ "use strict";

* Materialize the given operation (recursively) with the given bindings.
* Essentially, all variables in the given operation will be replaced
* Essentially, the variables in the given operation
* which don't appear in the projection operation will be replaced
* by the terms bound to the variables in the given bindings.
* @param {Algebra.Operation} operation SPARQL algebra operation.
* And the variables that appear in the projection operation
* will be added to a new values operation.
* @param {Bindings} bindings A bindings object.

@@ -45,3 +48,4 @@ * @param bindingsFactory The bindings factory.

* @param options.strictTargetVariables If target variable bindings (such as on SELECT or BIND) should not be allowed.
* @param options.bindFilter If filter expressions should be materialized
* @param options.bindFilter If filter expressions should be materialized.
* @param options.originalBindings The bindings object as it was at the top level call of materializeOperation.
* @return Algebra.Operation A new operation materialized with the given bindings.

@@ -53,2 +57,3 @@ */

bindFilter: 'bindFilter' in options ? options.bindFilter : true,
originalBindings: 'originalBindings' in options ? options.originalBindings : bindings,
};

@@ -115,3 +120,3 @@ return sparqlalgebrajs_1.Util.mapOperation(operation, {

// If strictTargetVariables is true, we throw if the project target variable is attempted to be bound.
// Otherwise, we just filter out the bound variables.
// Otherwise, we make a values clause out of the target variable and its value in InitialBindings.
if (options.strictTargetVariables) {

@@ -128,18 +133,47 @@ for (const variable of op.variables) {

}
const variables = op.variables.filter(variable => !bindings.has(variable));
// Only include projected variables in the sub-bindings that will be passed down recursively.
// If we don't do this, we may be binding variables that may have the same label, but are not considered equal.
const subBindings = bindingsFactory.bindings(op.variables.map((variable) => {
const binding = bindings.get(variable);
if (binding) {
return [variable, binding];
// Only include non-projected variables in the bindings that will be passed down recursively.
// This will result in non-projected variables being replaced with their InitialBindings values.
for (const bindingKey of bindings.keys()) {
for (const curVariable of op.variables) {
if (curVariable.equals(bindingKey)) {
bindings = bindings.delete(bindingKey);
break;
}
}
// eslint-disable-next-line no-useless-return,array-callback-return
return;
}).filter(Boolean));
}
// Find projected variables which are present in the originalBindings.
// This will result in projected variables being handled via a values clause.
const values = createValuesFromBindings(factory, options.originalBindings, op.variables);
let recursionResult = materializeOperation(op.input, bindings, bindingsFactory, options);
if (values.length > 0) {
recursionResult = factory.createJoin([...values, recursionResult]);
}
return {
recurse: false,
result: factory.createProject(materializeOperation(op.input, subBindings, bindingsFactory, options), variables),
result: factory.createProject(recursionResult, op.variables),
};
},
filter(op, factory) {
const originalBindings = options.originalBindings;
if (op.expression.expressionType !== 'operator' || originalBindings.size === 0) {
return {
recurse: false,
result: op,
};
}
// Make a values clause using all the variables from originalBindings.
const values = createValuesFromBindings(factory, originalBindings);
// Recursively materialize the filter expression
const recursionResultExpression = materializeOperation(op.expression, bindings, bindingsFactory, options);
// Recursively materialize the filter input
let recursionResultInput = materializeOperation(op.input, bindings, bindingsFactory, options);
if (values.length > 0) {
recursionResultInput = factory.createJoin([...values, recursionResultInput]);
}
return {
// Recursion already taken care of above.
recurse: false,
result: factory.createFilter(recursionResultInput, recursionResultExpression),
};
},
values(op, factory) {

@@ -235,2 +269,21 @@ // Materialize a values operation.

exports.materializeOperation = materializeOperation;
/**
* Make a values operation containing the values that are present in `bindings` for variables present in `variables`.
* If no `variables` argument is given, this method returns a values operation
* containing every binding from `bindings`.
* @param {Factory} factory The Factory used to create the values operation.
* @param {Bindings} bindings A bindings object.
* @param {Variable[]} variables A list of variables.
* @returns Algebra.Values A new values operation the given bindings.
*/
function createValuesFromBindings(factory, bindings, variables) {
const values = [];
for (const [variable, binding] of bindings) {
if (!variables || variables.some(v => v.equals(variable))) {
const newBinding = { [(0, rdf_string_1.termToString)(variable)]: binding };
values.push(factory.createValues([variable], [newBinding]));
}
}
return values;
}
//# sourceMappingURL=Bindings.js.map
{
"name": "@comunica/bus-query-operation",
"version": "3.2.0",
"version": "3.2.1",
"description": "A comunica bus for query-operation events.",

@@ -39,8 +39,8 @@ "lsd:module": true,

"dependencies": {
"@comunica/bindings-factory": "^3.2.0",
"@comunica/context-entries": "^3.2.0",
"@comunica/core": "^3.2.0",
"@comunica/bindings-factory": "^3.2.1",
"@comunica/context-entries": "^3.2.1",
"@comunica/core": "^3.2.1",
"@comunica/data-factory": "^3.1.0",
"@comunica/metadata": "^3.2.0",
"@comunica/types": "^3.2.0",
"@comunica/metadata": "^3.2.1",
"@comunica/types": "^3.2.1",
"@rdfjs/types": "*",

@@ -51,5 +51,5 @@ "asynciterator": "^3.9.0",

"rdf-terms": "^1.11.0",
"sparqlalgebrajs": "^4.3.3"
"sparqlalgebrajs": "^4.3.7"
},
"gitHead": "87baf2afed021a254859e64b92f34d9b51c6a7db"
"gitHead": "f558377c3cefbd1606c51ede80440b862e7dda4f"
}

Sorry, the diff of this file is not supported yet

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