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

sparqlalgebrajs

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sparqlalgebrajs - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

18

lib/algebra.d.ts

@@ -38,6 +38,3 @@ import * as rdfjs from "rdf-js";

COMPOSITE_UPDATE: string;
INSERT_DATA: string;
DELETE_DATA: string;
DELETE_INSERT: string;
DELETE_WHERE: string;
LOAD: string;

@@ -244,19 +241,8 @@ CLEAR: string;

}
export interface InsertData extends Update {
type: 'insertdata';
quads: Pattern[];
}
export interface DeleteData extends Update {
type: 'deletedata';
quads: Pattern[];
}
export interface DeleteInsert extends Update, Single {
export interface DeleteInsert extends Update {
type: 'deleteinsert';
delete?: Pattern[];
insert?: Pattern[];
where?: Operation;
}
export interface DeleteWhere extends Update {
type: 'deletewhere';
patterns: Pattern[];
}
export interface UpdateGraph extends Update {

@@ -263,0 +249,0 @@ silent?: boolean;

@@ -39,6 +39,3 @@ "use strict";

COMPOSITE_UPDATE: 'compositeupdate',
INSERT_DATA: 'insertdata',
DELETE_DATA: 'deletedata',
DELETE_INSERT: 'deleteinsert',
DELETE_WHERE: 'deletewhere',
LOAD: 'load',

@@ -45,0 +42,0 @@ CLEAR: 'clear',

5

lib/factory.d.ts

@@ -48,6 +48,3 @@ import * as A from './algebra';

createCompositeUpdate(updates: A.Update[]): A.CompositeUpdate;
createInsertData(quads: A.Pattern[]): A.InsertData;
createDeleteData(quads: A.Pattern[]): A.DeleteData;
createDeleteInsert(input: A.Operation, deleteQuads?: A.Pattern[], insertQuads?: A.Pattern[]): A.DeleteInsert;
createDeleteWhere(patterns: A.Pattern[]): A.DeleteWhere;
createDeleteInsert(deleteQuads?: A.Pattern[], insertQuads?: A.Pattern[], where?: A.Operation): A.DeleteInsert;
createLoad(source: RDF.NamedNode, destination?: RDF.NamedNode, silent?: boolean): A.Load;

@@ -54,0 +51,0 @@ createClear(source: 'DEFAULT' | 'NAMED' | 'ALL' | RDF.NamedNode, silent?: boolean): A.Clear;

@@ -79,6 +79,4 @@ "use strict";

createCompositeUpdate(updates) { return { type: 'compositeupdate', updates }; }
createInsertData(quads) { return { type: 'insertdata', quads }; }
createDeleteData(quads) { return { type: 'deletedata', quads }; }
createDeleteInsert(input, deleteQuads, insertQuads) {
const result = { type: 'deleteinsert', input };
createDeleteInsert(deleteQuads, insertQuads, where) {
const result = { type: 'deleteinsert' };
if (deleteQuads)

@@ -88,5 +86,6 @@ result.delete = deleteQuads;

result.insert = insertQuads;
if (where)
result.where = where;
return result;
}
createDeleteWhere(patterns) { return { type: 'deletewhere', patterns }; }
createLoad(source, destination, silent) {

@@ -93,0 +92,0 @@ const result = { type: 'load', source };

@@ -62,6 +62,3 @@ "use strict";

case types.COMPOSITE_UPDATE: return translateCompositeUpdate(op);
case types.INSERT_DATA: return translateInsertData(op);
case types.DELETE_DATA: return translateDeleteData(op);
case types.DELETE_INSERT: return translateDeleteInsert(op);
case types.DELETE_WHERE: return translateDeleteWhere(op);
case types.LOAD: return translateLoad(op);

@@ -567,15 +564,7 @@ case types.CLEAR: return translateClear(op);

}
function translateInsertData(op) {
const updates = [{ updateType: 'insert', insert: convertUpdatePatterns(op.quads) }];
return { prefixes: {}, type: 'update', updates };
}
function translateDeleteData(op) {
const updates = [{ updateType: 'delete', delete: convertUpdatePatterns(op.quads) }];
return { prefixes: {}, type: 'update', updates };
}
function translateDeleteInsert(op) {
let where = op.input;
let where = op.where;
let using = undefined;
if (op.input.type === types.FROM) {
let from = op.input;
if (where && where.type === types.FROM) {
let from = op.where;
where = from.input;

@@ -592,3 +581,3 @@ using = { default: from.default, named: from.named };

// corresponds to empty array in SPARQL.js
if (where.type === types.BGP && where.patterns.length === 0)
if (!where || (where.type === types.BGP && where.patterns.length === 0))
updates[0].where = [];

@@ -613,8 +602,20 @@ else {

}
// not really necessary but can give cleaner looking queries
if (!op.delete && !op.where) {
updates[0].updateType = 'insert';
delete updates[0].delete;
delete updates[0].where;
}
else if (!op.insert && !op.where) {
delete updates[0].insert;
delete updates[0].where;
if (op.delete.some(pattern => pattern.subject.termType === 'Variable' ||
pattern.predicate.termType === 'Variable' ||
pattern.object.termType === 'Variable'))
updates[0].updateType = 'deletewhere';
else
updates[0].updateType = 'delete';
}
return { prefixes: {}, type: 'update', updates };
}
function translateDeleteWhere(op) {
const updates = [{ updateType: 'deletewhere', delete: convertUpdatePatterns(op.patterns) }];
return { prefixes: {}, type: 'update', updates };
}
function translateLoad(op) {

@@ -689,3 +690,3 @@ const updates = [{ type: 'load', silent: Boolean(op.silent), source: op.source }];

// UPDATE operations with Patterns handle graphs a bit differently
if ([types.INSERT_DATA, types.DELETE_DATA, types.DELETE_INSERT, types.DELETE_WHERE].includes(op.type))
if (op.type === types.DELETE_INSERT)
return op;

@@ -692,0 +693,0 @@ if ((op.type === types.PATTERN || op.type === types.PATH) && op.graph) {

@@ -528,3 +528,3 @@ "use strict";

insertTriples = util_1.default.flatten(thingy.insert.map(input => translateUpdateTriplesBlock(input, thingy.graph)));
if (thingy.where) {
if (thingy.where && thingy.where.length > 0) {
where = translateGroupGraphPattern({ type: 'group', patterns: thingy.where });

@@ -537,10 +537,3 @@ if (thingy.using)

}
if (thingy.updateType === 'insertdelete')
return factory.createDeleteInsert(where, deleteTriples.length > 0 ? deleteTriples.map(translateQuad) : undefined, insertTriples.length > 0 ? insertTriples.map(translateQuad) : undefined);
if (thingy.updateType === 'deletewhere')
return factory.createDeleteWhere(deleteTriples.map(translateQuad));
if (thingy.updateType === 'delete')
return factory.createDeleteData(deleteTriples.map(translateQuad));
if (thingy.updateType === 'insert')
return factory.createInsertData(insertTriples.map(translateQuad));
return factory.createDeleteInsert(deleteTriples.length > 0 ? deleteTriples.map(translateQuad) : undefined, insertTriples.length > 0 ? insertTriples.map(translateQuad) : undefined, where);
}

@@ -547,0 +540,0 @@ // for now, UPDATE parsing will always return quads and have no GRAPH elements

@@ -247,10 +247,2 @@ "use strict";

break;
case algebra_1.types.INSERT_DATA:
const id = result;
id.quads.forEach(pattern => recurseOp(pattern));
break;
case algebra_1.types.DELETE_DATA:
const dd = result;
dd.quads.forEach(pattern => recurseOp(pattern));
break;
case algebra_1.types.DELETE_INSERT:

@@ -262,8 +254,5 @@ const di = result;

di.insert.forEach(pattern => recurseOp(pattern));
recurseOp(di.input);
if (di.where)
recurseOp(di.where);
break;
case algebra_1.types.DELETE_WHERE:
const dw = result;
dw.patterns.forEach(pattern => recurseOp(pattern));
break;
// all of these only have graph IDs as values

@@ -398,15 +387,5 @@ case algebra_1.types.LOAD: break;

return factory.createCompositeUpdate(cu.updates.map(mapOp));
case algebra_1.types.INSERT_DATA:
const id = result;
return factory.createInsertData(id.quads.map(mapOp));
break;
case algebra_1.types.DELETE_DATA:
const dd = result;
return factory.createDeleteData(dd.quads.map(mapOp));
case algebra_1.types.DELETE_INSERT:
const di = result;
return factory.createDeleteInsert(mapOp(di.input), di.delete ? di.delete.map(mapOp) : undefined, di.insert ? di.insert.map(mapOp) : undefined);
case algebra_1.types.DELETE_WHERE:
const dw = result;
return factory.createDeleteWhere(dw.patterns.map(mapOp));
return factory.createDeleteInsert(di.delete ? di.delete.map(mapOp) : undefined, di.insert ? di.insert.map(mapOp) : undefined, di.where ? mapOp(di.where) : undefined);
case algebra_1.types.LOAD:

@@ -413,0 +392,0 @@ const load = result;

{
"name": "sparqlalgebrajs",
"version": "2.3.0",
"version": "2.3.1",
"description": "Convert SPARQL to SPARQL algebra",

@@ -5,0 +5,0 @@ "author": "Joachim Van Herwegen",

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