@faubulous/mentor-rdf 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +56 -57
- package/dist/index.js.map +3 -3
- package/dist/rdf/utils.d.ts +7 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2603,13 +2603,13 @@ var DefaultGraph = class {
|
|
|
2603
2603
|
}
|
|
2604
2604
|
};
|
|
2605
2605
|
var Quad = class {
|
|
2606
|
-
constructor(subject, predicate, object,
|
|
2606
|
+
constructor(subject, predicate, object, graph) {
|
|
2607
2607
|
this.termType = "Quad";
|
|
2608
2608
|
this.value = "";
|
|
2609
2609
|
this.subject = subject;
|
|
2610
2610
|
this.predicate = predicate;
|
|
2611
2611
|
this.object = object;
|
|
2612
|
-
this.graph =
|
|
2612
|
+
this.graph = graph ?? new DefaultGraph();
|
|
2613
2613
|
}
|
|
2614
2614
|
equals(other) {
|
|
2615
2615
|
if (other?.termType !== this.termType) {
|
|
@@ -2673,8 +2673,8 @@ var DataFactory = class {
|
|
|
2673
2673
|
* @param graph The graph of the quad (defaults to the default graph).
|
|
2674
2674
|
* @returns A new Quad instance.
|
|
2675
2675
|
*/
|
|
2676
|
-
quad(subject, predicate, object,
|
|
2677
|
-
return new Quad(subject, predicate, object,
|
|
2676
|
+
quad(subject, predicate, object, graph) {
|
|
2677
|
+
return new Quad(subject, predicate, object, graph);
|
|
2678
2678
|
}
|
|
2679
2679
|
/**
|
|
2680
2680
|
* Creates a copy of an existing term.
|
|
@@ -4127,17 +4127,17 @@ var DatasetView = class _DatasetView {
|
|
|
4127
4127
|
}
|
|
4128
4128
|
const scope = [];
|
|
4129
4129
|
const seen = /* @__PURE__ */ new Set();
|
|
4130
|
-
const push = (
|
|
4131
|
-
const key =
|
|
4130
|
+
const push = (graph) => {
|
|
4131
|
+
const key = graph.termType + ":" + graph.value;
|
|
4132
4132
|
if (!seen.has(key)) {
|
|
4133
4133
|
seen.add(key);
|
|
4134
|
-
scope.push(
|
|
4134
|
+
scope.push(graph);
|
|
4135
4135
|
}
|
|
4136
4136
|
};
|
|
4137
|
-
for (const
|
|
4138
|
-
push(
|
|
4139
|
-
if (options.includeInferred !== false && store.reasoner &&
|
|
4140
|
-
push(store.dataFactory.namedNode(store.reasoner.targetUriGenerator.getGraphUri(
|
|
4137
|
+
for (const graph of graphs) {
|
|
4138
|
+
push(graph);
|
|
4139
|
+
if (options.includeInferred !== false && store.reasoner && graph.termType === "NamedNode") {
|
|
4140
|
+
push(store.dataFactory.namedNode(store.reasoner.targetUriGenerator.getGraphUri(graph.value)));
|
|
4141
4141
|
}
|
|
4142
4142
|
}
|
|
4143
4143
|
return scope;
|
|
@@ -4154,8 +4154,8 @@ var DatasetView = class _DatasetView {
|
|
|
4154
4154
|
if (this._scope === void 0) {
|
|
4155
4155
|
n = this._store.countQuads(this._s, this._p, this._o, null);
|
|
4156
4156
|
} else {
|
|
4157
|
-
for (const
|
|
4158
|
-
n += this._store.countQuads(this._s, this._p, this._o,
|
|
4157
|
+
for (const graph of this._scope) {
|
|
4158
|
+
n += this._store.countQuads(this._s, this._p, this._o, graph);
|
|
4159
4159
|
}
|
|
4160
4160
|
}
|
|
4161
4161
|
this._cachedSize = n;
|
|
@@ -4191,7 +4191,7 @@ var DatasetView = class _DatasetView {
|
|
|
4191
4191
|
if (this._o && !this._o.equals(quad5.object)) {
|
|
4192
4192
|
return false;
|
|
4193
4193
|
}
|
|
4194
|
-
if (this._scope !== void 0 && !this._scope.some((
|
|
4194
|
+
if (this._scope !== void 0 && !this._scope.some((graph) => graph.equals(quad5.graph))) {
|
|
4195
4195
|
return false;
|
|
4196
4196
|
}
|
|
4197
4197
|
return this._store.has(quad5);
|
|
@@ -4206,14 +4206,14 @@ var DatasetView = class _DatasetView {
|
|
|
4206
4206
|
* @param graph The optional graph.
|
|
4207
4207
|
* @returns A new read-only dataset view of the matching quads.
|
|
4208
4208
|
*/
|
|
4209
|
-
match(subject, predicate, object,
|
|
4209
|
+
match(subject, predicate, object, graph) {
|
|
4210
4210
|
const s = _DatasetView._intersectTerm(this._s, subject);
|
|
4211
4211
|
const p = _DatasetView._intersectTerm(this._p, predicate);
|
|
4212
4212
|
const o = _DatasetView._intersectTerm(this._o, object);
|
|
4213
4213
|
let scope = this._scope;
|
|
4214
|
-
if (
|
|
4215
|
-
if (scope === void 0 || scope.some((g) => g.equals(
|
|
4216
|
-
scope = [
|
|
4214
|
+
if (graph != null) {
|
|
4215
|
+
if (scope === void 0 || scope.some((g) => g.equals(graph))) {
|
|
4216
|
+
scope = [graph];
|
|
4217
4217
|
} else {
|
|
4218
4218
|
scope = [];
|
|
4219
4219
|
}
|
|
@@ -4249,8 +4249,8 @@ var DatasetView = class _DatasetView {
|
|
|
4249
4249
|
if (this._scope === void 0) {
|
|
4250
4250
|
yield* this._store.matchQuads(this._s, this._p, this._o, null);
|
|
4251
4251
|
} else {
|
|
4252
|
-
for (const
|
|
4253
|
-
yield* this._store.matchQuads(this._s, this._p, this._o,
|
|
4252
|
+
for (const graph of this._scope) {
|
|
4253
|
+
yield* this._store.matchQuads(this._s, this._p, this._o, graph);
|
|
4254
4254
|
}
|
|
4255
4255
|
}
|
|
4256
4256
|
}
|
|
@@ -4632,11 +4632,11 @@ var ReasonerBase = class {
|
|
|
4632
4632
|
throw new Error(`Invalid value for targetUriGenerator: ${targetUriGenerator}`);
|
|
4633
4633
|
}
|
|
4634
4634
|
}
|
|
4635
|
-
getGraphNode(
|
|
4636
|
-
if (typeof
|
|
4637
|
-
return namedNode5(
|
|
4635
|
+
getGraphNode(graph) {
|
|
4636
|
+
if (typeof graph === "string") {
|
|
4637
|
+
return namedNode5(graph);
|
|
4638
4638
|
} else {
|
|
4639
|
-
return
|
|
4639
|
+
return graph;
|
|
4640
4640
|
}
|
|
4641
4641
|
}
|
|
4642
4642
|
isW3CNode(term) {
|
|
@@ -4678,9 +4678,9 @@ var ReasonerBase = class {
|
|
|
4678
4678
|
* @param object An object URI or null to match any object.
|
|
4679
4679
|
* @todo Refactor and merge with the same method in the Mentor RDF Store class.
|
|
4680
4680
|
*/
|
|
4681
|
-
*match(
|
|
4682
|
-
if (
|
|
4683
|
-
yield* this.store.match(subject, predicate, object,
|
|
4681
|
+
*match(graph, subject, predicate, object) {
|
|
4682
|
+
if (graph !== void 0) {
|
|
4683
|
+
yield* this.store.match(subject, predicate, object, graph);
|
|
4684
4684
|
} else {
|
|
4685
4685
|
yield* this.store.match(subject, predicate, object);
|
|
4686
4686
|
}
|
|
@@ -9384,11 +9384,9 @@ xsd:usignedByte a rdfs:Datatype ;
|
|
|
9384
9384
|
// src/rdf/store.ts
|
|
9385
9385
|
import { RdfStore as RdfStore2 } from "rdf-stores";
|
|
9386
9386
|
import { RdfXmlParser } from "rdfxml-streaming-parser";
|
|
9387
|
-
import { graph, serialize } from "rdflib";
|
|
9388
9387
|
|
|
9389
9388
|
// src/rdf/utils.ts
|
|
9390
|
-
|
|
9391
|
-
var toRdflibTerm = (term) => {
|
|
9389
|
+
var toRdflibTerm = (term, rdflib) => {
|
|
9392
9390
|
switch (term.termType) {
|
|
9393
9391
|
case "NamedNode":
|
|
9394
9392
|
return rdflib.namedNode(term.value);
|
|
@@ -9543,18 +9541,18 @@ var Store = class {
|
|
|
9543
9541
|
* Indicates if a graph holds at least one triple, without reading more than one.
|
|
9544
9542
|
* @param graph The graph term, or its URI with an empty string for the default graph.
|
|
9545
9543
|
*/
|
|
9546
|
-
_hasTriples(
|
|
9547
|
-
return !this._store.readQuads(null, null, null, this._getGraphTerm(
|
|
9544
|
+
_hasTriples(graph) {
|
|
9545
|
+
return !this._store.readQuads(null, null, null, this._getGraphTerm(graph)).next().done;
|
|
9548
9546
|
}
|
|
9549
9547
|
/**
|
|
9550
9548
|
* Resolves a graph URI to its term; an empty string denotes the default graph.
|
|
9551
9549
|
* @param graph The graph term or URI.
|
|
9552
9550
|
*/
|
|
9553
|
-
_getGraphTerm(
|
|
9554
|
-
if (typeof
|
|
9555
|
-
return
|
|
9551
|
+
_getGraphTerm(graph) {
|
|
9552
|
+
if (typeof graph !== "string") {
|
|
9553
|
+
return graph;
|
|
9556
9554
|
}
|
|
9557
|
-
return
|
|
9555
|
+
return graph === "" ? this.dataFactory.defaultGraph() : this.dataFactory.namedNode(graph);
|
|
9558
9556
|
}
|
|
9559
9557
|
/**
|
|
9560
9558
|
* Load a set of triples into the store.
|
|
@@ -9587,17 +9585,17 @@ var Store = class {
|
|
|
9587
9585
|
));
|
|
9588
9586
|
}
|
|
9589
9587
|
_loadQuads(quads, graphUri, executeInference = true, clearGraph = true, onQuad) {
|
|
9590
|
-
const
|
|
9588
|
+
const graph = this.dataFactory.namedNode(graphUri.replace("\\", "/"));
|
|
9591
9589
|
if (clearGraph) {
|
|
9592
9590
|
this.deleteGraphs([graphUri], true);
|
|
9593
9591
|
}
|
|
9594
9592
|
for (let q of quads) {
|
|
9595
|
-
this._ds.add(this.dataFactory.quad(q.subject, q.predicate, q.object,
|
|
9593
|
+
this._ds.add(this.dataFactory.quad(q.subject, q.predicate, q.object, graph));
|
|
9596
9594
|
if (onQuad) {
|
|
9597
9595
|
onQuad(q);
|
|
9598
9596
|
}
|
|
9599
9597
|
}
|
|
9600
|
-
this._touchGraph(
|
|
9598
|
+
this._touchGraph(graph.value);
|
|
9601
9599
|
if (this.reasoner && executeInference) {
|
|
9602
9600
|
this._expand(graphUri);
|
|
9603
9601
|
}
|
|
@@ -9703,15 +9701,16 @@ var Store = class {
|
|
|
9703
9701
|
* @returns A string serialization of the triples in the graph in the specified format.
|
|
9704
9702
|
*/
|
|
9705
9703
|
async serializeGraph(sourceGraphUri, targetFormat = "text/turtle", targetGraphUri, prefixes) {
|
|
9704
|
+
const rdflib = await import("rdflib");
|
|
9706
9705
|
return new Promise((resolve, reject) => {
|
|
9707
9706
|
const sourceGraph = this.dataFactory.namedNode(sourceGraphUri);
|
|
9708
9707
|
const targetGraph = targetGraphUri ? this.dataFactory.namedNode(targetGraphUri) : void 0;
|
|
9709
|
-
const store = graph();
|
|
9710
|
-
const g = targetGraph ? toRdflibTerm(targetGraph) : void 0;
|
|
9708
|
+
const store = rdflib.graph();
|
|
9709
|
+
const g = targetGraph ? toRdflibTerm(targetGraph, rdflib) : void 0;
|
|
9711
9710
|
for (const q of this._store.readQuads(null, null, null, sourceGraph)) {
|
|
9712
|
-
const s = toRdflibTerm(q.subject);
|
|
9713
|
-
const p = toRdflibTerm(q.predicate);
|
|
9714
|
-
const o = toRdflibTerm(q.object);
|
|
9711
|
+
const s = toRdflibTerm(q.subject, rdflib);
|
|
9712
|
+
const p = toRdflibTerm(q.predicate, rdflib);
|
|
9713
|
+
const o = toRdflibTerm(q.object, rdflib);
|
|
9715
9714
|
store.add(s, p, o, g);
|
|
9716
9715
|
}
|
|
9717
9716
|
const callback = (error, result) => {
|
|
@@ -9721,7 +9720,7 @@ var Store = class {
|
|
|
9721
9720
|
resolve(result ?? "");
|
|
9722
9721
|
}
|
|
9723
9722
|
};
|
|
9724
|
-
serialize(null, store, null, targetFormat, callback, prefixes);
|
|
9723
|
+
rdflib.serialize(null, store, null, targetFormat, callback, prefixes);
|
|
9725
9724
|
});
|
|
9726
9725
|
}
|
|
9727
9726
|
/**
|
|
@@ -9813,8 +9812,8 @@ var Store = class {
|
|
|
9813
9812
|
* @param object The optional object.
|
|
9814
9813
|
* @param graph The optional graph.
|
|
9815
9814
|
*/
|
|
9816
|
-
countQuads(subject, predicate, object,
|
|
9817
|
-
return this._store.countQuads(subject, predicate, object,
|
|
9815
|
+
countQuads(subject, predicate, object, graph) {
|
|
9816
|
+
return this._store.countQuads(subject, predicate, object, graph);
|
|
9818
9817
|
}
|
|
9819
9818
|
/**
|
|
9820
9819
|
* Returns a lazy, read-only dataset view of the quads matching the given pattern.
|
|
@@ -9828,12 +9827,12 @@ var Store = class {
|
|
|
9828
9827
|
* @param graph The optional graph.
|
|
9829
9828
|
* @returns A read-only dataset view of the matching quads.
|
|
9830
9829
|
*/
|
|
9831
|
-
match(subject, predicate, object,
|
|
9830
|
+
match(subject, predicate, object, graph) {
|
|
9832
9831
|
return new DatasetView(this, {
|
|
9833
9832
|
subject: subject ?? null,
|
|
9834
9833
|
predicate: predicate ?? null,
|
|
9835
9834
|
object: object ?? null,
|
|
9836
|
-
graphs:
|
|
9835
|
+
graphs: graph != null ? [graph] : void 0,
|
|
9837
9836
|
includeInferred: false
|
|
9838
9837
|
});
|
|
9839
9838
|
}
|
|
@@ -9845,8 +9844,8 @@ var Store = class {
|
|
|
9845
9844
|
* @param object The optional object.
|
|
9846
9845
|
* @param graph The optional graph.
|
|
9847
9846
|
*/
|
|
9848
|
-
*matchQuads(subject, predicate, object,
|
|
9849
|
-
yield* this._store.readQuads(subject, predicate, object,
|
|
9847
|
+
*matchQuads(subject, predicate, object, graph) {
|
|
9848
|
+
yield* this._store.readQuads(subject, predicate, object, graph);
|
|
9850
9849
|
}
|
|
9851
9850
|
/**
|
|
9852
9851
|
* Get an RDF/JS `Source` interface for the store that streams matching quads.
|
|
@@ -9855,7 +9854,7 @@ var Store = class {
|
|
|
9855
9854
|
*/
|
|
9856
9855
|
asSource() {
|
|
9857
9856
|
return {
|
|
9858
|
-
match: (subject, predicate, object,
|
|
9857
|
+
match: (subject, predicate, object, graph) => this._store.match(subject, predicate, object, graph)
|
|
9859
9858
|
};
|
|
9860
9859
|
}
|
|
9861
9860
|
/**
|
|
@@ -9876,10 +9875,10 @@ var Store = class {
|
|
|
9876
9875
|
const o = object;
|
|
9877
9876
|
if (graphUris !== void 0) {
|
|
9878
9877
|
const graphs = Array.isArray(graphUris) ? graphUris : [graphUris];
|
|
9879
|
-
for (const
|
|
9880
|
-
yield* this._store.readQuads(s, p, o,
|
|
9878
|
+
for (const graph of graphs.map((g) => this.dataFactory.namedNode(g))) {
|
|
9879
|
+
yield* this._store.readQuads(s, p, o, graph);
|
|
9881
9880
|
if (includeInferred !== false && this.reasoner) {
|
|
9882
|
-
const inferenceGraphUri = this.reasoner.targetUriGenerator.getGraphUri(
|
|
9881
|
+
const inferenceGraphUri = this.reasoner.targetUriGenerator.getGraphUri(graph.value);
|
|
9883
9882
|
const inferenceGraph = this.dataFactory.namedNode(inferenceGraphUri);
|
|
9884
9883
|
yield* this._store.readQuads(s, p, o, inferenceGraph);
|
|
9885
9884
|
}
|
|
@@ -9934,7 +9933,7 @@ var Store = class {
|
|
|
9934
9933
|
};
|
|
9935
9934
|
|
|
9936
9935
|
// src/rdf/vocabulary-repository.ts
|
|
9937
|
-
var { namedNode:
|
|
9936
|
+
var { namedNode: namedNode7 } = dataFactory;
|
|
9938
9937
|
var VocabularyRepository = class extends ShapeRepository {
|
|
9939
9938
|
/**
|
|
9940
9939
|
* Get all concept schemes in the repository.
|
|
@@ -10001,7 +10000,7 @@ var VocabularyRepository = class extends ShapeRepository {
|
|
|
10001
10000
|
* @returns The version of the ontology, or undefined if it is not found.
|
|
10002
10001
|
*/
|
|
10003
10002
|
getOntologyVersionInfo(graphUris, ontologyUri) {
|
|
10004
|
-
const s =
|
|
10003
|
+
const s = namedNode7(ontologyUri);
|
|
10005
10004
|
for (const q of this.store.matchAll(graphUris, s, owl.versionInfo, null)) {
|
|
10006
10005
|
const match = q.object.value.match(/(\d{4}[\/-]\d{2}[\/-]\d{2})/);
|
|
10007
10006
|
if (match && match.length > 1) {
|