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

@rmlio/yarrrml-parser

Package Overview
Dependencies
Maintainers
0
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rmlio/yarrrml-parser - npm Package Compare versions

Comparing version 1.6.2 to 1.7.1

release.sh

18

CHANGELOG.md

@@ -10,2 +10,18 @@ # Changelog

## [1.7.1] - 2024-09-17
### Changed
- CI improvements: local deployment script.
## [1.7.0] - 2024-09-17
### Added
- Keys to generate [IncRML](https://www.semantic-web-journal.org/content/incrml-incremental-knowledge-graph-construction-heterogeneous-data-sources).
### Changed
- IDLab functions prefix (`idlab-fn`) now resolves to `https://w3id.org/imec/idlab/function#` instead the old IRI `http://example.com/idlab/function/`
### Fixed
- Shortkeys for targets only work for targets specified on document level.
## [1.6.2] - 2024-02-16

@@ -341,2 +357,4 @@

[1.7.1]: https://github.com/RMLio/yarrrml-parser/compare/v1.7.0...v1.7.1
[1.7.0]: https://github.com/RMLio/yarrrml-parser/compare/v1.6.2...v1.7.0
[1.6.2]: https://github.com/RMLio/yarrrml-parser/compare/v1.6.1...v1.6.2

@@ -343,0 +361,0 @@ [1.6.1]: https://github.com/RMLio/yarrrml-parser/compare/v1.6.0...v1.6.1

2

lib/abstract-generator.js

@@ -942,3 +942,3 @@ /**

convertEqualToIDLabEqual(fn) {
fn.function = 'http://example.com/idlab/function/equal';
fn.function = 'https://w3id.org/imec/idlab/function#equal';

@@ -945,0 +945,0 @@ fn.parameters.forEach(pm => {

@@ -27,5 +27,15 @@ /**

const idlabfn = 'http://example.com/idlab/function/';
const idlabfn = 'https://w3id.org/imec/idlab/function#';
// map function names used in code to function id's
const fnMap = new Map();
fnMap.set('createtrue', idlabfn + 'explicitCreate');
fnMap.set('createfalse', idlabfn + 'implicitCreate');
fnMap.set('updatetrue', idlabfn + 'explicitUpdate');
fnMap.set('updatefalse', idlabfn + 'implicitUpdate');
fnMap.set('deletetrue', idlabfn + 'explicitDelete');
fnMap.set('deletefalse', idlabfn + 'implicitDelete');
function expand(input) {

@@ -41,3 +51,3 @@ const output = {};

expandTargetsInDocument(output);
rewriteLDESes(output);
expandChangeDetections(output);
return output;

@@ -75,7 +85,2 @@ }

if (typeof mapping.subjects === 'string') {
if (mapping.subjects.endsWith('~ldes')) {
mapping.subjects = mapping.subjects.slice(0, -5)
Logger.debug('LDES annotation found');
mapping.subjects = expandLDES(mapping.subjects);
}
mapping.subjects = [mapping.subjects]

@@ -85,3 +90,2 @@ } else if (Array.isArray(mapping.subjects)) {

if (typeof mapping.subjects[i] === 'object') {
mapping.subjects[i] = expandLDES(mapping.subjects[i])
expandFunction(mapping.subjects[i]);

@@ -154,2 +158,3 @@

mapping.subjects.forEach(subject => {
replaceAll('targets', subject)
if (subject.targets) {

@@ -181,2 +186,3 @@ if (Array.isArray(subject.targets)) {

po.predicates.forEach((p) => {
replaceAll('targets', p);
if (p.targets) {

@@ -204,2 +210,3 @@ if (Array.isArray(p.targets)) {

po.objects.forEach((o) => {
replaceAll('targets', o);
if (o.targets) {

@@ -222,17 +229,18 @@ if (Array.isArray(o.targets)) {

if (o.language && o.language.targets) {
if (Array.isArray(o.language.targets)) {
for (let i = 0; i < o.language.targets.length; i++) {
const target = o.language.targets[i];
if (Array.isArray(target)) {
o.language.targets[i] = convertArrayTargetInObject(target);
if (o.language) {
replaceAll('targets', o.language);
if (o.language && o.language.targets) {
if (Array.isArray(o.language.targets)) {
for (let i = 0; i < o.language.targets.length; i++) {
const target = o.language.targets[i];
if (Array.isArray(target)) {
o.language.targets[i] = convertArrayTargetInObject(target);
}
}
} else if (typeof o.language.targets === 'string') {
o.language.targets = [o.language.targets]
} else {
Logger.error(`object language "${JSON.stringify(o.language, null, 2)}": no (valid) target is defined.`);
}
}
else if (typeof o.language.targets === 'string') {
o.language.targets = [o.language.targets]
}
else {
Logger.error(`object language "${JSON.stringify(o.language, null, 2)}": no (valid) target is defined.`);
}
}

@@ -248,2 +256,3 @@ });

mapping.graphs.forEach((g) => {
replaceAll('targets', g);
if (g.targets) {

@@ -330,9 +339,11 @@ if (Array.isArray(g.targets)) {

mapping.predicateobjects.forEach(po => {
expandGraphs(po);
});
if (mapping.predicateobjects.length !== 0) {
mapping.predicateobjects.forEach(po => {
expandGraphs(po);
});
expandPredicates(mapping.predicateobjects);
expandObjects(mapping.predicateobjects, mappingKey);
expandConditionsOfPOs(mapping.predicateobjects);
expandPredicates(mapping.predicateobjects);
expandObjects(mapping.predicateobjects, mappingKey);
expandConditionsOfPOs(mapping.predicateobjects);
}
} else {

@@ -744,216 +755,378 @@ Logger.error(`mapping "${mappingKey}": no pos are defined.`);

function expandLDES(subject) {
let ldes = {};
if (subject !== undefined) {
if (typeof subject === 'string') {
ldes.memberSubject = subject;
subject = {
value: subject,
};
} else if (typeof subject === 'object' && subject !== null) {
if (subject.ldes !== undefined) {
if (subject.ldes !== null) {
ldes = subject.ldes;
}
ldes.memberSubject = subject.value
} else {
// there is no LDES
return subject;
}
function expandChangeDetections (document) {
if (document.mappings !== undefined && document.mappings !== null) {
// This will store versions of the original mappings
// possibly copied and modified by change detection operators
let newMappings = {};
const mappings = Object.keys(document.mappings);
for (let i = 0; i < mappings.length; i++) {
const mappingKey = mappings[i];
// merge the mappings resulting from the change detection
newMappings = {...newMappings, ...processChangeDetection(document, mappingKey)};
}
} else {
// no subject, no LDES
return subject;
document.mappings = newMappings;
}
}
// the 'shape' key is just copied...
function processChangeDetection(document, mappingKey) {
let newMappings = {};
const mapping = document.mappings[mappingKey];
if (mapping) {
if (mapping && mapping.changeDetection) { // ...then we have some InRML stuff here!
const changeDetection = mapping.changeDetection;
if (ldes.id === undefined || ldes.id === null) {
ldes.id = 'http://example.org/eventstream';
}
// loop over operations
Object.keys(changeDetection).forEach(operation_name => {
Logger.debug(`Found change detection operation "${operation_name}"`);
let operation = changeDetection[operation_name];
let isExplicit = operation.explicit || operation.explicit === undefined || operation.explicit === null;
Logger.debug(` operation type explicit? ${isExplicit}`);
// TODO: watchedProperties: allow shortcut watchedProperties: <property str> ?
if (ldes.watchedProperties === undefined) {
ldes.watchedProperties = [];
} else {
// just check if it's an array
if (!Array.isArray(ldes.watchedProperties)) {
Logger.error('LDES `watchedProperties` must be an array.');
}
}
// clone the original mapping; make changes to the clone.
let newMapping = structuredClone(mapping);
delete newMapping.changeDetection
// TODO: versionOfPath: allow shortcut versionOfPath: <predicate> ?
if (ldes.versionOfPath !== undefined && ldes.versionOfPath !== null) {
if (operation_name === 'delete') {
// check if there are PO mappingAdds
const poAddDefined = operation.mappingAdd !== undefined && (operation.mappingAdd.po !== undefined || operation.mappingAdd.predicateobjects !== undefined);
let newVersionOfPath = {};
if (Array.isArray(ldes.versionOfPath)) {
if (ldes.versionOfPath.length === 0) {
newVersionOfPath.predicate = 'http://purl.org/dc/terms/isVersionOf';
newVersionOfPath.object = ldes.memberSubject;
if (!newVersionOfPath.object.endsWith('~iri')) {
newVersionOfPath.object += '~iri';
// delete all PO mappings except the ones with predicate `rdf:type`
let newPOMappings = [];
if (!poAddDefined) {
for (const poMapping of newMapping.predicateobjects) {
let newPO = {};
for (const predicate of poMapping.predicates) {
if (predicate === 'a' || predicate === 'rdf:type' || predicate === 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') {
newPO.predicates = [predicate];
newPO.objects = poMapping.objects;
newPOMappings.push(newPO);
break;
}
}
}
}
newMapping.predicateobjects = newPOMappings;
}
} else if (ldes.versionOfPath.length === 1) {
newVersionOfPath.predicate = ldes.versionOfPath[0];
// fill in member subject for now, check if predicate exists later on
newVersionOfPath.object = ldes.memberSubject;
if (!newVersionOfPath.object.endsWith('~iri')) {
newVersionOfPath.object += '~iri';
// process the things to be removed from the mapping
if (operation.mappingRemove) {
processMappingRemove(document, newMapping, operation.mappingRemove);
}
} else if (ldes.versionOfPath.length === 2) {
newVersionOfPath.predicate = ldes.versionOfPath[0];
newVersionOfPath.object = ldes.versionOfPath[1];
if (!newVersionOfPath.object.endsWith('~iri')) {
newVersionOfPath.object += '~iri';
// process the things to be added to the mapping
if (operation.mappingAdd) {
processMappingAdd(document, newMapping, operation.mappingAdd);
}
} else {
Logger.error('LDES `versionOfPath` must be an array of maximum two strings.');
}
for (const subjectIndex in newMapping.subjects) {
let mappingSubject = newMapping.subjects[subjectIndex];
// extract targets, if any
const targets = mappingSubject.targets;
if (targets !== undefined) {
delete mappingSubject.targets;
}
let value;
if (typeof mappingSubject === 'string') {
value = mappingSubject;
} else if (mappingSubject.value) {
value = mappingSubject.value;
} else { // it must be a function
value = mappingSubject;
}
// build change detection function (for each subject)
const functionName = fnMap.get(operation_name + isExplicit);
let parameters = [
{
parameter: idlabfn + 'iri',
value: value,
from: 'subject',
type: 'iri',
}
];
if (functionName === idlabfn + 'implicitUpdate' && operation.watchedProperties) {
const wpArray = typeof operation.watchedProperties === 'string' ? [operation.watchedProperties] : operation.watchedProperties;
const wpString = _toWatchedPropertiesString(wpArray);
parameters.push({
parameter: idlabfn + 'watchedProperty',
value: wpString,
from: 'subject',
type: 'literal'
});
}
// replace original subject with this function
let newSubject = {
function: functionName,
parameters: parameters,
type: 'iri'
}
if (targets !== undefined) {
newSubject.targets = targets;
}
newMapping.subjects[subjectIndex] = newSubject;
}
// add the new mapping to the list of new mappings
newMappings[mappingKey + '-' + operation_name] = newMapping;
});
} else {
Logger.error('LDES `versionOfPath` must be an array.');
newMappings[mappingKey] = mapping;
}
const expandedpos = expandPredicateAndObject(newVersionOfPath.predicate, newVersionOfPath.object);
newVersionOfPath.predicate = expandedpos[0];
newVersionOfPath.object = expandedpos[1];
ldes.versionOfPath = newVersionOfPath;
} else {
ldes.versionOfPath = null;
}
return newMappings;
}
// TODO: timestampPath: allow shortcut timestampPath: <predicate> ?
if (ldes.timestampPath !== undefined && ldes.timestampPath !== null) {
let newTimestampPath = {};
if (Array.isArray(ldes.timestampPath)) {
if (ldes.timestampPath.length >= 1) {
newTimestampPath.predicate = ldes.timestampPath[0];
newTimestampPath.object = null;
newTimestampPath.oDataType = null;
// TODO the predicate and object have to be present as predicateobject mapping; check later?
if (ldes.timestampPath.length >= 2) {
newTimestampPath.object = ldes.timestampPath[1];
// TODO: add predicateobjectmapping if not exists
if (ldes.timestampPath.length === 3) {
newTimestampPath.oDataType = ldes.timestampPath[2];
function processMappingRemove(document, mapping, mappingRemove) {
processMappingChange(document, mapping, mappingRemove, false);
}
function mappingRemoveForKey (document, mapping, mappingRemove, mappingKey) {
// normalize: convert a string into an array of one string
const removeValues = typeof (mappingRemove[mappingKey]) === 'string' ? [mappingRemove[mappingKey]] : mappingRemove[mappingKey];
let newObjects = [];
// Only iterate if it's iterable
for (const removeValue of removeValues) {
// Iterate over the mapping's [sources or graphs] (called 'objects' from now on) and adjust.
// Note that inlining a referred object is important because other mappings may also refer to that object!
for (let object of mapping[mappingKey]) {
if (typeof object === 'string') {
// is 'removeValue' the object name by coincidence?
if (object !== removeValue) {
if (document[mappingKey] !== undefined && document[mappingKey] !== null) {
// it's a reference! so make it inline and process as if it's inline.
// Find the referred object, if any.
const referredObject = document[mappingKey][object];
if (referredObject !== undefined && referredObject !== null) {
object = structuredClone(referredObject);
delete object[removeValue];
// Inline referred object (= replace reference with copy of original)
newObjects.push(object);
}
} else {
Logger.error('LDES `timestampPath` must be an array of maximum three strings.');
// it's not a reference, so don't remove
newObjects.push(object);
}
}
} // else remove!
} else {
Logger.error('LDES `timestampPath` must be an array of minimum one string.');
delete object[removeValue];
// Inline referred object (= replace reference with copy of original)
newObjects.push(object);
}
} else {
Logger.error('LDES timestampPath must be an array.');
}
const expandedpos = expandPredicateAndObject(newTimestampPath.predicate, newTimestampPath.object);
newTimestampPath.predicate = expandedpos[0];
newTimestampPath.object = expandedpos[1];
ldes.timestampPath = newTimestampPath;
} else {
ldes.timestampPath = null;
}
return newObjects;
}
if (ldes.memberIDFunction !== undefined && ldes.memberIDFunction !== null) {
expandFunction(ldes.memberIDFunction);
function mappingRemovePO(mapping, mappingRemove) {
// remove every matching combination of predicates and objects
if (mappingRemove.predicateobjects.length === 0) {
delete mapping.predicateobjects;
} else {
// use the default generateUniqueIRI function, so prepare parameters
const watchedPropertiesStr = _toWatchedPropertiesString(ldes.watchedProperties);
ldes.memberIDFunction = {
function: idlabfn + 'generateUniqueIRI',
parameters: [
{
parameter: idlabfn + 'iri',
value: ldes.memberSubject,
from: 'subject',
type: 'iri',
},
{
parameter: idlabfn + 'watchedProperty',
value: watchedPropertiesStr,
from: 'subject',
type: 'literal'
for (const poArr of mappingRemove.predicateobjects) {
const predicates = poArr.predicates;
const objects = poArr.objects;
for (const predicate of predicates) {
const predicateId = getId(predicate);
for (const object of objects) {
const objId = getId(object);
removePOMapping(predicateId, objId, mapping);
}
],
};
}
}
}
}
if (ldes.shape === undefined) {
ldes.shape = null;
function getId(termMap) {
// an term mapping gets identified by a `value` or a `function` or ....
let id;
if (typeof termMap === 'string') {
id = termMap;
} else if (Object.hasOwn(termMap, 'value')) {
id = termMap.value;
} else if (Object.hasOwn(termMap, 'function')) {
id = termMap.function;
} else if (Object.hasOwn(termMap, 'access')) {
id = termMap.access;
}
subject.ldes = ldes;
return subject;
return id;
}
/**
* This rewrites the mappings so that LDES specific triples can be generated
* according to the CURRENT implementation in RMLMapper. If that implementation changes,
* and it will, then this function definitely needs to change.
* (see https://dylanvanassche.be/assets/pdf/eswc2022-rml-ldes.pdf)
* @param document the YARRRML document to rewrite LDES stuff for.
* Given a predicate and an object ID, search for corresponding PO mappings and remove them.
* @param idOfPredicateToRemove
* @param idOfObjectToRemove
* @param mapping
*/
function rewriteLDESes(document) {
if (document.mappings !== undefined && document.mappings !== null) {
for (let mapping of Object.values(document.mappings)) {
for (let subject of mapping.subjects) {
if (subject.ldes !== null && subject.ldes !== undefined) {
const ldes = subject.ldes;
if (subject.targets !== null && subject.targets !== undefined) {
for (let target of subject.targets) {
// if the target is of type string, then it's a reference to a target definition
let realTarget = typeof target === 'string' ? document.targets[target] : target;
// make the target an LDES target!
realTarget.ldes = {
id: ldes.id,
versionOfPath: ldes.versionOfPath,
timestampPath: ldes.timestampPath,
shape: ldes.shape
};
}
function removePOMapping(idOfPredicateToRemove, idOfObjectToRemove, mapping) {
let newPOMapping = [];
// check / add LDES-related predicate-object mappings for versionOfPath
if (ldes.versionOfPath !== null) {
// check if predicate & object mappings exist. If not, add them.
addLDESSpecificPredicateObjects(ldes.versionOfPath.predicate, ldes.versionOfPath.object, mapping.predicateobjects);
}
for (const poArr of mapping.predicateobjects) {
for (const predicate of poArr.predicates) {
for (const object of poArr.objects) {
const predicateId = getId(predicate);
const objectId = getId(object);
if (predicateId !== idOfPredicateToRemove || objectId !== idOfObjectToRemove) {
predicates = [predicate];
objects = [object];
newPOMapping.push({predicates, objects});
}
}
}
}
// check / add LDES-related predicate-object mappings for timestampPath
if (ldes.timestampPath !== null) {
// check if predicate & object mappings exist. If not, add them.
addLDESSpecificPredicateObjects(ldes.timestampPath.predicate, ldes.timestampPath.object, mapping.predicateobjects);
}
// replace the new PO mapping in the original mapping, or delete if empty:
if (newPOMapping.length > 0) {
mapping.predicateobjects = newPOMapping;
} else {
delete mapping.predicateobjects;
}
}
// remove ldes properties object from subject
delete subject.ldes;
function mappingRemoveSubjects(mapping, mappingRemove) {
let mappingRemoveSubjects = new Set(mappingRemove.subjects);
// replace the subject with the LDES member id function
subject.function = ldes.memberIDFunction.function;
subject.parameters = ldes.memberIDFunction.parameters;
delete subject.value;
// in a first iteration, we remove targets defined in mappingRemove (if any)
for (const subject of mappingRemoveSubjects) {
const subjectId = getId(subject);
if (subjectId === undefined) {
// then there's probably a sub-key we want to remove from all subjects.
if (Object.hasOwn(subject, 'targets')) {
for (let mappingSubject of mapping.subjects) { // subjects still to process
delete mappingSubject.targets;
}
mappingRemoveSubjects.delete(subject);
}
}
}
} else { // If there are no targets, we have to add an LDES target!
// TODO: for the current implementation of LDES in RML, there HAS to be a target.
// This will change in the upcoming new implementation
Logger.error('The current RML LDES generation mappings require a target at subject mapping level. ' +
'This will change in the future.');
}
if (mappingRemoveSubjects.size > 0) {
// in a second iteration, keep only the subjects that are specified in mappingRemove (if any)
let newSubjects = [];
for (const subject of mappingRemoveSubjects) {
const subjectId = getId(subject);
for (const mappingSubject of mapping.subjects) {
const mappingSubjectId = getId(mappingSubject);
if (subjectId !== mappingSubjectId) {
newSubjects.push(mappingSubject);
}
}
}
// replace the new subject mapping in the original mapping, or delete if empty:
if (newSubjects.length > 0) {
mapping.subjects = newSubjects;
} else {
delete mapping.subjects;
}
}
}
function processMappingAdd(document, mapping, mappingAdd) {
processMappingChange(document, mapping, mappingAdd, true);
}
function addLDESSpecificPredicateObjects(predicate, object, predicateobjects) {
let found = false;
for (let predicateobject of predicateobjects) {
for (let i = 0; i < predicateobject.predicates.length; i++) {
// if the predicate exists, the object must be the same if the given object is not null
if (predicateobject.predicates[i] === predicate) {
found = true;
if (object !== null && predicateobject.objects[i] !== object) {
const objectToUse = predicateobject.objects[i];
Logger.warn(`The versionOf or timestampPath predicate ${predicate} expects an object mapping ${object}, but is ${objectToUse}. Using the existing ${objectToUse}.`);
function processMappingChange(document, mapping, mappingAddOrRemove, isAdd) {
const mappingKey = isAdd ? 'mappingAdd' : 'mappingRemove';
replaceAll('sources', mappingAddOrRemove);
if (mappingAddOrRemove.sources !== undefined && mappingAddOrRemove.sources !== null) {
expandSourcesInMapping(mappingAddOrRemove, mappingKey);
mapping.sources = isAdd ? mappingAddForKey(document, mapping, mappingAddOrRemove, 'sources')
: mappingRemoveForKey(document, mapping, mappingAddOrRemove, 'sources');
if (mapping.sources.length === 0) {
delete mapping.sources;
}
}
replaceAll('subjects', mappingAddOrRemove);
if (mappingAddOrRemove.subjects !== undefined && mappingAddOrRemove.subjects !== null) {
expandSubjects(mappingAddOrRemove, mappingKey);
expandTargetsInMapping(mappingAddOrRemove);
if (isAdd) {
mapping.subjects = mappingAddForKey(document, mapping, mappingAddOrRemove, 'subjects');
} else {
mappingRemoveSubjects(mapping, mappingAddOrRemove);
}
}
replaceAll('graphs', mappingAddOrRemove);
if (mappingAddOrRemove.graphs !== undefined && mappingAddOrRemove.graphs !== null) {
expandGraphs(mappingAddOrRemove);
mapping.graphs = isAdd ? mappingAddForKey(document, mapping, mappingAddOrRemove, 'graphs')
: mappingRemoveForKey(document, mapping, mappingAddOrRemove, 'graphs');
if (mapping.graphs.length === 0) {
delete mapping.graphs;
}
}
replaceAll('predicateobjects', mappingAddOrRemove);
if (mappingAddOrRemove.predicateobjects !== undefined && mappingAddOrRemove.predicateobjects !== null) {
expandPredicateObjects(mappingAddOrRemove, mappingKey);
if (isAdd) {
mapping.predicateobjects = addPOMappings(mapping, mappingAddOrRemove.predicateobjects);
} else {
mappingRemovePO(mapping, mappingAddOrRemove);
}
}
}
function mappingAddForKey(document, mapping, mappingAdd, mappingKey) {
// normalize: convert a string into an array of one string
const addValues = typeof (mappingAdd[mappingKey]) === 'string' ? [mappingAdd[mappingKey]] : mappingAdd[mappingKey];
let newObjects = Object.hasOwn(mapping, mappingKey)? structuredClone(mapping[mappingKey]) : [];
// in a first iteration: add all necessary sources (if any)
for (const addValue of addValues) {
if (typeof addValue === 'string' && document[mappingKey] !== undefined && document[mappingKey] != null) {
// it's a reference
const referredObject = document[mappingKey][addValue];
if (referredObject !== undefined && referredObject !== null) {
newObjects.push(structuredClone(referredObject));
}
} else {
const objectId = getId(addValue);
if (objectId !== undefined) {
newObjects.push(addValue);
}
}
}
// in a second iteration: add sub-keys (if any)
for (const addValue of addValues) {
if (typeof addValue === 'object') {
const objectId = getId(addValue);
if (objectId === undefined) {
// the sub-keys need to be added to all sources
for (let objectIndex in newObjects) {
let object = newObjects[objectIndex];
if (typeof object === 'string') {
// if object is a string, then should be a reference to an object. Inline it first
if (document[mappingKey] !== undefined && document[mappingKey] != null) {
// it IS a reference!
const referredObject = document[mappingKey][object];
if (referredObject !== undefined && referredObject !== null) {
object = structuredClone(referredObject);
newObjects[objectIndex] = object;
}
} else if (mappingKey === 'subjects') {
// for subjects, a string is a shortcut to the `value` sub-key of a `subject` object.
// so now we create a subject object.
object = { value: object};
}
}
for (const key of Object.keys(addValue)) {
object[key] = addValue[key];
}
newObjects[objectIndex] = object;
}

@@ -963,11 +1136,22 @@ }

}
if (!found) {
predicateobjects.push({
predicates: [predicate],
objects: [object]
});
return newObjects;
}
function addPOMappings(mapping, newPOMappings) {
let newPOs = []
if (mapping.predicateobjects) {
// Just add, without checking anything.
// in the ideal world, this could be optimized by merging PO maps wherever possible.
newPOs = structuredClone(mapping.predicateobjects);
for (const newPOMapping of newPOMappings) {
newPOs.push(newPOMapping);
}
} else {
newPOs = newPOMappings;
}
return newPOs;
}
// helper function to put LDES watched properties into one string to pass to generateUniqueIRI function
// helper function to put watched properties into one string to pass to generateUniqueIRI function
function _toWatchedPropertiesString(watchedPropertiesArray) {

@@ -1001,17 +1185,2 @@ let resultStr = '';

function expandPredicateAndObject(predicate, object) {
const predicateobjects = [{
predicates: [predicate],
objects: [object]
}];
expandPredicates(predicateobjects);
if (object !== null) {
expandObjects(predicateobjects);
return [predicateobjects[0].predicates[0], predicateobjects[0].objects[0]];
} else {
return [predicateobjects[0].predicates[0], null];
}
}
module.exports = expand;

@@ -6,3 +6,3 @@ // initialize (common) prefixes and namespaces from prefix.cc

_namespaces['comp'] = 'http://semweb.mmlab.be/ns/rml-compression#';
_namespaces['idlab-fn'] = 'http://example.com/idlab/function/';
_namespaces['idlab-fn'] = 'https://w3id.org/imec/idlab/function#';
_namespaces['rml'] = 'http://semweb.mmlab.be/ns/rml#'; // this one is the only official one for now, but prefix.cc returns the wrong one.

@@ -9,0 +9,0 @@ _namespaces['rmlt'] = 'http://semweb.mmlab.be/ns/rml-target#';

@@ -710,3 +710,3 @@ /**

namedNode(namespaces.rdf + 'type'),
namedNode(namespaces.ldes + 'EventStreamTarget'),
namedNode(namespaces.rmlt + 'EventStreamTarget'),
));

@@ -717,21 +717,39 @@

tSubject,
namedNode(namespaces.ldes + 'baseIRI'),
namedNode(namespaces.rmlt + 'ldesBaseIRI'),
namedNode(AbstractGenerator.expandPrefix(target.ldes.id)),
));
// Add the SHACL shape. While, according to the LDES spec it is optional,
// the current RMLMapper implementation requires it.
const shaclshape = target.ldes.shape ? AbstractGenerator.expandPrefix(target.ldes.shape) : 'http://example.org/shape.shacl';
// add the optional ldesGenerateImmutableIRI
const generateImmutableIRI = (target.ldes.generateImmutableIRI !== null && target.ldes.generateImmutableIRI !== undefined) ? target.ldes.generateImmutableIRI : false;
if (target.ldes.generateImmutableIRI) {
this.quads.push(quad(
tSubject,
namedNode(namespaces.rmlt + 'ldesGenerateImmutableIRI'),
literal(generateImmutableIRI, 'boolean'),
));
}
// add the ldes:EventStream object
const eventStreamSubject = namedNode(this.baseIRI + this.getUniqueID('eventStream'));
this.quads.push(quad(
tSubject,
namedNode(namespaces.tree + 'shape'),
namedNode(shaclshape),
namedNode(namespaces.rmlt + 'ldes'),
eventStreamSubject,
));
// add the timestampPath
// Add the optional SHACL shape.
if (target.ldes.shape) {
this.quads.push(quad(
eventStreamSubject,
namedNode(namespaces.tree + 'shape'),
namedNode(AbstractGenerator.expandPrefix(target.ldes.shape)),
));
}
// add the optional timestampPath
if (target.ldes.timestampPath) {
this.quads.push(quad(
tSubject,
eventStreamSubject,
namedNode(namespaces.ldes + 'timestampPath'),
namedNode(AbstractGenerator.expandPrefix(target.ldes.timestampPath.predicate)),
namedNode(AbstractGenerator.expandPrefix(target.ldes.timestampPath)),
));

@@ -743,5 +761,5 @@ }

this.quads.push(quad(
tSubject,
eventStreamSubject,
namedNode(namespaces.ldes + 'versionOfPath'),
namedNode(AbstractGenerator.expandPrefix(target.ldes.versionOfPath.predicate)),
namedNode(AbstractGenerator.expandPrefix(target.ldes.versionOfPath)),
));

@@ -748,0 +766,0 @@ }

@@ -22,3 +22,3 @@ /**

});
});

@@ -342,3 +342,3 @@ it.skip('works for dbpedia', function () {

workMultipleInputFiles(['multiple-input-files/mapping-1.yarrrml', 'multiple-input-files/mapping-2.yarrrml'],
'multiple-input-files/mapping.rml.ttl', done, {includeMetadata: false});
'multiple-input-files/mapping.rml.ttl', done, {includeMetadata: false});
});

@@ -366,3 +366,3 @@

doTestCase('external-references/5', options);
});
});

@@ -414,33 +414,29 @@ describe('authors', function () {

describe('LDES', () => {
it('works for watched properties, only if `Temperature` changes', function (done) {
work('ldes/03-watched-properties-one/mapping.yaml', 'ldes/03-watched-properties-one/mapping.rml.ttl', done, {includeMetadata: false});
describe('IncRML-LDES', () => {
describe('Test cases', () => {
it('works for RMLLDES0001a base', function (done) {
work('incrml-ldes/test-cases/RMLLDES0001a/base.yarrrml.yaml', 'incrml-ldes/test-cases/RMLLDES0001a/base.rml.ttl', done, {includeMetadata: false});
});
it('works for RMLLDES0001e base', function (done) {
work('incrml-ldes/test-cases/RMLLDES0001e/base.yarrrml.yaml', 'incrml-ldes/test-cases/RMLLDES0001e/base.rml.ttl', done, {includeMetadata: false});
});
it('works for RMLLDES0002e base', function (done) {
work('incrml-ldes/test-cases/RMLLDES0002e/base.yarrrml.yaml', 'incrml-ldes/test-cases/RMLLDES0002e/base.rml.ttl', done, {includeMetadata: false});
});
it('works for RMLLDES0002e change', function (done) {
work('incrml-ldes/test-cases/RMLLDES0002e/change.yarrrml.yaml', 'incrml-ldes/test-cases/RMLLDES0002e/change.rml.ttl', done, {includeMetadata: false});
});
});
it('works for watched properties, if `Timestamp` changes, i.e. every reading', function (done) {
work('ldes/03-watched-properties-timestamp/mapping.yaml', 'ldes/03-watched-properties-timestamp/mapping.rml.ttl', done, {includeMetadata: false});
describe('Original tests', () => {
it('all watched properties', function (done) {
work('incrml-ldes/original-ldes/all-properties/mapping.yarrrml.yaml', 'incrml-ldes/original-ldes/all-properties/mapping.rml.ttl', done, {includeMetadata: false});
});
it('watch for temperature change', function (done) {
work('incrml-ldes/original-ldes/new-member-on-temperature-change/mapping.yarrrml.yaml', 'incrml-ldes/original-ldes/new-member-on-temperature-change/mapping.rml.ttl', done, {includeMetadata: false});
});
it('watch for timestamp change', function (done) {
work('incrml-ldes/original-ldes/new-member-on-timestamp-change/mapping.yarrrml.yaml', 'incrml-ldes/original-ldes/new-member-on-timestamp-change/mapping.rml.ttl', done, {includeMetadata: false});
});
});
it('works for an empty versionOfPath', function (done) {
work('ldes/04-mapping-empty-version-of-path/mapping.yaml', 'ldes/04-mapping-empty-version-of-path/mapping.rml.ttl', done, {includeMetadata: false});
});
it('works for an versionOfPath with a predicate that doesn\'t occur in predicate-object mappings', function (done) {
work('ldes/05-version-of-path-single-predicate-no-po-mapping/mapping.yaml', 'ldes/05-version-of-path-single-predicate-no-po-mapping/mapping.rml.ttl', done, {includeMetadata: false});
});
it('works for a custom versionOfPath', function (done) {
work('ldes/06-custom-version-of-path/mapping.yaml', 'ldes/06-custom-version-of-path/mapping.rml.ttl', done, {includeMetadata: false});
});
it('works for a custom timestampPath using predicate that occurs in the predicate-objecgt mappings', function (done) {
work('ldes/07-timestamp-path-predicate-only/mapping.yaml', 'ldes/07-timestamp-path-predicate-only/mapping.rml.ttl', done, {includeMetadata: false});
});
it('works for a custom timestampPath using predicate and object not in the predicate-objecgt mappings', function (done) {
work('ldes/07-timestamp-path-predicate-only/mapping.yaml', 'ldes/07-timestamp-path-predicate-only/mapping.rml.ttl', done, {includeMetadata: false});
});
it('works for a custom LDES ID', function (done) {
work('ldes/09-custom-ldes-id/mapping.yaml', 'ldes/09-custom-ldes-id/mapping.rml.ttl', done, {includeMetadata: false});
});
it('works for all LDES properties but `memberIDFunction`', function (done) {
work('ldes/all-properties-but-memberIDFunction/mapping.yaml', 'ldes/all-properties-but-memberIDFunction/mapping.rml.ttl', done, {includeMetadata: false});
});
it('works for LDES without properties', function (done) {
work('ldes/no-properties/mapping.yaml', 'ldes/no-properties/mapping.rml.ttl', done, {includeMetadata: false});
});
});

@@ -447,0 +443,0 @@

@@ -71,3 +71,3 @@ const { canonicalize } = require("./tools");

:pomexec_000 rr:objectMap :omexec_000.
:omexec_000 rr:constant "http://example.com/idlab/function/equal";
:omexec_000 rr:constant "https://w3id.org/imec/idlab/function#equal";
rr:termType rr:IRI.

@@ -171,3 +171,3 @@ :fn_000 rr:predicateObjectMap :pom_002.

:omexec_000 rr:constant "http://example.com/idlab/function/equal" ;
:omexec_000 rr:constant "https://w3id.org/imec/idlab/function#equal" ;
rr:termType rr:IRI .

@@ -199,2 +199,2 @@

`;
`;
{
"name": "@rmlio/yarrrml-parser",
"version": "1.6.2",
"version": "1.7.1",
"description": "Parse YARRRML descriptions into RML RDF statements",

@@ -5,0 +5,0 @@ "main": "lib/yarrrml2rml.js",

# Releases
1. Open the list of CI/CD pipelines here: https://gitlab.ilabt.imec.be/yarrrml/yarrrml-parser/-/pipelines/
2. Under the stages column, pick the latest pipeline and click on '>>'.
3. A tab will under '>>' will be shown with 'Create Release', click on it (not on the play button)
Make a release by running the `release.sh` script as followed:
![Manually create release](./figures/step1.png)
`./release.sh $TAG`
5. A new page is shown with a Key-Value entry box. Enter the following:
- Key: `RELEASE_TAG_NAME`
- Value: `1.2.3` (for releasing v1.2.3)
6. Press the 'Trigger this action manually' button
For example (v1.0.0):
![Trigger CI release](./figures/step2.png)
`./release.sh 1.0.0`

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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