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

@rmlio/rmlmapper-java-wrapper

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rmlio/rmlmapper-java-wrapper - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

test/tc08/data/student.csv

7

CHANGELOG.md

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

## [2.0.3] - 2022-02-22
### Fixed
- Support data source files that in are not in the root folder
## [2.0.2] - 2021-08-31

@@ -15,2 +20,3 @@

- Bug causing invalid paths in RML on windows
- Better error handling when stderr is non-empty but also doesn't contain errors

@@ -94,2 +100,3 @@ ## [2.0.1] - 2021-07-02

[2.0.3]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.2...v2.0.3
[2.0.2]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.1...v2.0.2

@@ -96,0 +103,0 @@ [2.0.1]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.0...v2.0.1

@@ -223,2 +223,18 @@ /**

});
it('Data source in subdirectory', async () => {
// GIVEN a wrapper and a simple CSV mapping generating one quad
const wrapper = new RMLMapperWrapper(rmlmapperPath, tempFolderPath, true);
const rml = fs.readFileSync('./test/tc08/mapping.ttl', 'utf-8');
const sources = {
'./data/student.csv': fs.readFileSync('./test/tc08/data/student.csv', 'utf-8')
};
// WHEN generating the quads without the metadata and expected the results to by an array of quads
const result = await wrapper.execute(rml, {sources, generateMetadata: false, asQuads: true});
// THEN the mapping should succeed and the output should match one of the file
const expected = await strToQuads(fs.readFileSync('./test/tc01/output.nq', 'utf-8'));
assert.ok(isomorphic(result.output, expected));
});
});

27

lib/wrapper.js

@@ -14,2 +14,3 @@ /**

const {strToQuads} = require('./utils');
const { v4: uuidv4 } = require('uuid');

@@ -80,2 +81,3 @@ const sourceFilePrefix = 'data-';

if (options.sources) {
this._sanitizeSources(options.sources);
await this._saveSources(options.sources, sourceDirPrefix);

@@ -94,3 +96,4 @@ }

fno: options.fno,
targetDirPrefix
targetDirPrefix,
sources: options.sources
});

@@ -105,3 +108,3 @@ resolve(result)

async _executeCLI(options) {
let {rml, sourceDirPrefix, processDir, logFile, serialization, asQuads, generateMetadata, fno, targetDirPrefix} = options;
let {rml, sourceDirPrefix, sources, processDir, logFile, serialization, asQuads, generateMetadata, fno, targetDirPrefix} = options;
const mappingFile = this._fixPath(path.join(processDir, 'mapping.rml.ttl'));

@@ -113,3 +116,3 @@ let functionsFile;

const targetFiles = result.targetFiles;
const rmlStr = await this._setSourcesInRMLRules(rml, sourceDirPrefix);
const rmlStr = await this._setSourcesInRMLRules(rml, sourceDirPrefix, sources);

@@ -254,5 +257,5 @@ await fs.writeFile(mappingFile, rmlStr);

if (sources[names[index]]) {
if (typeof sources[names[index]] === 'string') {
if (typeof sources[names[index]].data === 'string') {
try {
await fs.writeFile(prefix + names[index], sources[names[index]]);
await fs.writeFile(prefix + sources[names[index]].path, sources[names[index]].data);
done();

@@ -301,3 +304,3 @@ } catch (err) {

*/
async _setSourcesInRMLRules(rmlQuads, prefix) {
async _setSourcesInRMLRules(rmlQuads, prefix, sources) {
return new Promise((resolve, reject) => {

@@ -310,3 +313,3 @@ const adjustedRMLQuads = [];

if (rmlQuad.predicate.value === 'http://semweb.mmlab.be/ns/rml#source' && rmlQuad.object.termType === 'Literal') {
adjustedQuad = newQuad(rmlQuad.subject, rmlQuad.predicate, literal(prefix + rmlQuad.object.value));
adjustedQuad = newQuad(rmlQuad.subject, rmlQuad.predicate, literal(prefix + sources[rmlQuad.object.value].path));
}

@@ -397,4 +400,14 @@

_sanitizeSources(sources) {
const filePaths = Object.keys(sources);
filePaths.forEach(filePath => {
sources[filePath] = {
data: sources[filePath],
path: uuidv4() + '-' + path.basename(filePath)
};
});
}
}
module.exports = RMLMapperWrapper;
{
"name": "@rmlio/rmlmapper-java-wrapper",
"version": "2.0.2",
"version": "2.0.3",
"description": "A JavaScript wrapper around the Java RMLMapper.",

@@ -20,3 +20,4 @@ "main": "index.js",

"n3": "^1.9.0",
"rdf-isomorphic": "^1.1.0"
"rdf-isomorphic": "^1.1.0",
"uuid": "^8.3.2"
},

@@ -23,0 +24,0 @@ "devDependencies": {

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