Skip to content

Commit 32ed5cd

Browse files
committed
version bump to 8.0.4
1 parent d838fef commit 32ed5cd

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

index.cjs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,12 @@ function generateMissingIdsForBlankNodes(nquadsArray) {
493493
}
494494
return term; // Return IRI or Literal unchanged
495495
}
496-
496+
const unsupportedNquads = [];
497497
const updatedNquads = parser.parse(nquadsArray.join("")).map((quad) => {
498+
// Check if BlankNodes are parsed as graphs
499+
if (quad.graph.termType === "BlankNode") {
500+
unsupportedNquads.push(writer.quadToString(quad.object, quad.predicate, quad.object, quad.graph));
501+
}
498502
// Replace blank nodes in the quad
499503
const updatedQuad = N3.DataFactory.quad(
500504
replaceBlankNode(quad.subject),
@@ -506,6 +510,24 @@ function generateMissingIdsForBlankNodes(nquadsArray) {
506510
return updatedQuad;
507511
});
508512

513+
if (unsupportedNquads.length > 0) {
514+
throw new Error(`
515+
------------------------------------------------------------------------------------------------
516+
Unsupported JSON-LD input detected
517+
518+
After parsing the JSON-LD input, the parser detected creation of new named graphs.
519+
The DKG does not support custom named graphs.
520+
521+
Problematic Quads:
522+
${unsupportedNquads.map((q, i) => ` ${i + 1}. ${q}`).join("\n")}
523+
524+
Full Parsed N-Quads Array:
525+
${nquadsArray.join('\n')}
526+
Parsing failed due to presence of unnamed (blank node) graphs. Please ensure all graphs in the input JSON-LD have proper named IRIs.
527+
`
528+
);
529+
}
530+
509531
return writer.quadsToString(updatedNquads).trimEnd().split("\n");
510532
}
511533

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "assertion-tools",
3-
"version": "8.0.3",
3+
"version": "8.0.4",
44
"description": "Common assertion tools used in ot-node and dkg.js",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)