@faubulous/mentor-rdf 2.6.1 → 2.7.0
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 +218 -214
- package/dist/index.js.map +4 -4
- package/dist/rdf/data-factory.d.ts +16 -0
- package/dist/rdf/rdf-data-factory.d.ts +7 -0
- package/dist/rdf/tests/helpers.d.ts +8 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -111,194 +111,12 @@ var Uri = class _Uri {
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
// src/rdf/data-factory.ts
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.termType = "NamedNode";
|
|
118
|
-
this.value = value;
|
|
119
|
-
}
|
|
120
|
-
equals(other) {
|
|
121
|
-
return other?.termType === this.termType && other.value === this.value;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var BlankNode = class {
|
|
125
|
-
constructor(value) {
|
|
126
|
-
this.termType = "BlankNode";
|
|
127
|
-
this.value = value;
|
|
128
|
-
}
|
|
129
|
-
equals(other) {
|
|
130
|
-
return other?.termType === this.termType && other.value === this.value;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
var Literal = class {
|
|
134
|
-
constructor(value, languageOrDatatype) {
|
|
135
|
-
this.termType = "Literal";
|
|
136
|
-
this.value = value;
|
|
137
|
-
if (typeof languageOrDatatype === "string") {
|
|
138
|
-
this.language = languageOrDatatype.toLowerCase();
|
|
139
|
-
this.datatype = new NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
|
|
140
|
-
} else if (languageOrDatatype) {
|
|
141
|
-
this.language = "";
|
|
142
|
-
this.datatype = languageOrDatatype;
|
|
143
|
-
} else {
|
|
144
|
-
this.language = "";
|
|
145
|
-
this.datatype = new NamedNode("http://www.w3.org/2001/XMLSchema#string");
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
equals(other) {
|
|
149
|
-
if (other?.termType !== this.termType) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
const otherLiteral = other;
|
|
153
|
-
return this.value === otherLiteral.value && this.language === otherLiteral.language && this.datatype.equals(otherLiteral.datatype);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
var Variable = class {
|
|
157
|
-
constructor(value) {
|
|
158
|
-
this.termType = "Variable";
|
|
159
|
-
this.value = value;
|
|
160
|
-
}
|
|
161
|
-
equals(other) {
|
|
162
|
-
return other?.termType === this.termType && other.value === this.value;
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
var DefaultGraph = class {
|
|
166
|
-
constructor() {
|
|
167
|
-
this.termType = "DefaultGraph";
|
|
168
|
-
this.value = "";
|
|
169
|
-
}
|
|
170
|
-
equals(other) {
|
|
171
|
-
return other?.termType === this.termType;
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
var Quad = class {
|
|
175
|
-
constructor(subject, predicate, object, graph) {
|
|
176
|
-
this.termType = "Quad";
|
|
177
|
-
this.value = "";
|
|
178
|
-
this.subject = subject;
|
|
179
|
-
this.predicate = predicate;
|
|
180
|
-
this.object = object;
|
|
181
|
-
this.graph = graph ?? new DefaultGraph();
|
|
182
|
-
}
|
|
183
|
-
equals(other) {
|
|
184
|
-
if (other?.termType !== this.termType) {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
const otherQuad = other;
|
|
188
|
-
return this.subject.equals(otherQuad.subject) && this.predicate.equals(otherQuad.predicate) && this.object.equals(otherQuad.object) && this.graph.equals(otherQuad.graph);
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
var defaultGraphInstance = new DefaultGraph();
|
|
192
|
-
var DataFactory = class {
|
|
193
|
-
constructor() {
|
|
194
|
-
this.blankNodeCounter = 0;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Creates a new named node with the given IRI.
|
|
198
|
-
* @param value The IRI of the named node.
|
|
199
|
-
* @returns A new NamedNode instance.
|
|
200
|
-
*/
|
|
201
|
-
namedNode(value) {
|
|
202
|
-
return new NamedNode(value);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Creates a new blank node with the given identifier.
|
|
206
|
-
* If no identifier is provided, a unique one will be generated.
|
|
207
|
-
* @param value Optional blank node identifier.
|
|
208
|
-
* @returns A new BlankNode instance.
|
|
209
|
-
*/
|
|
210
|
-
blankNode(value) {
|
|
211
|
-
return new BlankNode(value ?? `b${++this.blankNodeCounter}`);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Creates a new literal with the given value and optional language tag or datatype.
|
|
215
|
-
* @param value The lexical value of the literal.
|
|
216
|
-
* @param languageOrDatatype Either a language tag (string) or a datatype (NamedNode).
|
|
217
|
-
* @returns A new Literal instance.
|
|
218
|
-
*/
|
|
219
|
-
literal(value, languageOrDatatype) {
|
|
220
|
-
return new Literal(value, languageOrDatatype);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Creates a new variable with the given name.
|
|
224
|
-
* @param value The name of the variable (without the leading '?').
|
|
225
|
-
* @returns A new Variable instance.
|
|
226
|
-
*/
|
|
227
|
-
variable(value) {
|
|
228
|
-
return new Variable(value);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Returns the singleton default graph instance.
|
|
232
|
-
* @returns The default graph instance.
|
|
233
|
-
*/
|
|
234
|
-
defaultGraph() {
|
|
235
|
-
return defaultGraphInstance;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Creates a new quad with the given subject, predicate, object, and optional graph.
|
|
239
|
-
* @param subject The subject of the quad.
|
|
240
|
-
* @param predicate The predicate of the quad.
|
|
241
|
-
* @param object The object of the quad.
|
|
242
|
-
* @param graph The graph of the quad (defaults to the default graph).
|
|
243
|
-
* @returns A new Quad instance.
|
|
244
|
-
*/
|
|
245
|
-
quad(subject, predicate, object, graph) {
|
|
246
|
-
return new Quad(subject, predicate, object, graph);
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Creates a copy of an existing term.
|
|
250
|
-
* @param original The term to copy.
|
|
251
|
-
* @returns A new term instance with the same value.
|
|
252
|
-
*/
|
|
253
|
-
fromTerm(original) {
|
|
254
|
-
switch (original.termType) {
|
|
255
|
-
case "NamedNode":
|
|
256
|
-
return this.namedNode(original.value);
|
|
257
|
-
case "BlankNode":
|
|
258
|
-
return this.blankNode(original.value);
|
|
259
|
-
case "Literal": {
|
|
260
|
-
const literal = original;
|
|
261
|
-
if (literal.language) {
|
|
262
|
-
return this.literal(literal.value, literal.language);
|
|
263
|
-
}
|
|
264
|
-
return this.literal(literal.value, this.fromTerm(literal.datatype));
|
|
265
|
-
}
|
|
266
|
-
case "Variable":
|
|
267
|
-
return this.variable(original.value);
|
|
268
|
-
case "DefaultGraph":
|
|
269
|
-
return this.defaultGraph();
|
|
270
|
-
case "Quad": {
|
|
271
|
-
const quad5 = original;
|
|
272
|
-
return this.fromQuad(quad5);
|
|
273
|
-
}
|
|
274
|
-
default:
|
|
275
|
-
throw new Error(`Unknown term type: ${original.termType}`);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Creates a copy of an existing quad.
|
|
280
|
-
* @param original The quad to copy.
|
|
281
|
-
* @returns A new quad instance with the same values.
|
|
282
|
-
*/
|
|
283
|
-
fromQuad(original) {
|
|
284
|
-
return this.quad(
|
|
285
|
-
this.fromTerm(original.subject),
|
|
286
|
-
this.fromTerm(original.predicate),
|
|
287
|
-
this.fromTerm(original.object),
|
|
288
|
-
this.fromTerm(original.graph)
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Resets the blank node counter. Useful for testing.
|
|
293
|
-
*/
|
|
294
|
-
resetBlankNodeCounter() {
|
|
295
|
-
this.blankNodeCounter = 0;
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
var dataFactory = new DataFactory();
|
|
114
|
+
// src/rdf/rdf-data-factory.ts
|
|
115
|
+
import { DataFactory } from "rdf-data-factory";
|
|
116
|
+
var RdfDataFactory = new DataFactory();
|
|
299
117
|
|
|
300
118
|
// src/rdf/resource-repository.ts
|
|
301
|
-
var { namedNode, blankNode } =
|
|
119
|
+
var { namedNode, blankNode } = RdfDataFactory;
|
|
302
120
|
var ResourceRepository = class {
|
|
303
121
|
constructor(store) {
|
|
304
122
|
this.store = store;
|
|
@@ -723,7 +541,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
723
541
|
* @returns `true` if the resource is in a concept scheme, `false` otherwise.
|
|
724
542
|
*/
|
|
725
543
|
hasConceptScheme(graphUris, subjectUri) {
|
|
726
|
-
const s =
|
|
544
|
+
const s = RdfDataFactory.namedNode(subjectUri);
|
|
727
545
|
for (let _ of this.store.matchAll(graphUris, s, skos.inScheme, null)) {
|
|
728
546
|
return true;
|
|
729
547
|
}
|
|
@@ -737,8 +555,8 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
737
555
|
* @returns `true` if the resource is in the given concept scheme, `false` otherwise.
|
|
738
556
|
*/
|
|
739
557
|
isInScheme(graphUris, subjectUri, schemeUri) {
|
|
740
|
-
const s =
|
|
741
|
-
const o =
|
|
558
|
+
const s = RdfDataFactory.namedNode(subjectUri);
|
|
559
|
+
const o = RdfDataFactory.namedNode(schemeUri);
|
|
742
560
|
for (let _ of this.store.matchAll(graphUris, s, skos.inScheme, o)) {
|
|
743
561
|
return true;
|
|
744
562
|
}
|
|
@@ -760,8 +578,8 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
760
578
|
if (this.isInScheme(graphUris, subjectUri, schemeUri)) {
|
|
761
579
|
return true;
|
|
762
580
|
}
|
|
763
|
-
const s =
|
|
764
|
-
const o =
|
|
581
|
+
const s = RdfDataFactory.namedNode(subjectUri);
|
|
582
|
+
const o = RdfDataFactory.namedNode(schemeUri);
|
|
765
583
|
for (let _ of this.store.matchAll(graphUris, s, skos.topConceptOf, o)) {
|
|
766
584
|
return true;
|
|
767
585
|
}
|
|
@@ -796,7 +614,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
796
614
|
*/
|
|
797
615
|
*getConceptsOfScheme(graphUris, schemeUri) {
|
|
798
616
|
const yielded = /* @__PURE__ */ new Set();
|
|
799
|
-
const o =
|
|
617
|
+
const o = RdfDataFactory.namedNode(schemeUri);
|
|
800
618
|
for (let predicate of [skos.inScheme, skos.topConceptOf]) {
|
|
801
619
|
for (let q of this.store.matchAll(graphUris, null, predicate, o)) {
|
|
802
620
|
const s = q.subject.value;
|
|
@@ -824,7 +642,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
824
642
|
*/
|
|
825
643
|
*getTopConcepts(graphUris, schemeUri) {
|
|
826
644
|
const yielded = /* @__PURE__ */ new Set();
|
|
827
|
-
const s =
|
|
645
|
+
const s = RdfDataFactory.namedNode(schemeUri);
|
|
828
646
|
for (let q of this.store.matchAll(graphUris, s, skos.hasTopConcept, null)) {
|
|
829
647
|
const o = q.object;
|
|
830
648
|
if (!yielded.has(o.value)) {
|
|
@@ -1058,7 +876,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1058
876
|
* @returns An array of URIs of the members of the collection.
|
|
1059
877
|
*/
|
|
1060
878
|
getCollectionMembers(graphUris, collectionUri) {
|
|
1061
|
-
const s =
|
|
879
|
+
const s = RdfDataFactory.namedNode(collectionUri);
|
|
1062
880
|
let result = [];
|
|
1063
881
|
for (let q of this.store.matchAll(graphUris, s, skos.member, null)) {
|
|
1064
882
|
result.push(q.object.value);
|
|
@@ -1075,7 +893,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1075
893
|
* @returns An array of URIs of the members of the collection.
|
|
1076
894
|
*/
|
|
1077
895
|
hasCollectionMembers(graphUris, collectionUri) {
|
|
1078
|
-
const s =
|
|
896
|
+
const s = RdfDataFactory.namedNode(collectionUri);
|
|
1079
897
|
for (let _ of this.store.matchAll(graphUris, s, skos.member, null)) {
|
|
1080
898
|
return true;
|
|
1081
899
|
}
|
|
@@ -1091,7 +909,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1091
909
|
* @returns `true` if the collection is an ordered collection, `false` otherwise.
|
|
1092
910
|
*/
|
|
1093
911
|
isOrderedCollection(graphUris, collectionUri) {
|
|
1094
|
-
const s =
|
|
912
|
+
const s = RdfDataFactory.namedNode(collectionUri);
|
|
1095
913
|
for (let _ of this.store.matchAll(graphUris, s, rdf.type, skos.OrderedCollection)) {
|
|
1096
914
|
return true;
|
|
1097
915
|
}
|
|
@@ -1105,7 +923,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1105
923
|
*/
|
|
1106
924
|
isCollection(graphUris, subjectUri) {
|
|
1107
925
|
if (subjectUri) {
|
|
1108
|
-
const s =
|
|
926
|
+
const s = RdfDataFactory.namedNode(subjectUri);
|
|
1109
927
|
for (let _ of this.store.matchAll(graphUris, s, rdf.type, skos.Collection)) {
|
|
1110
928
|
return true;
|
|
1111
929
|
}
|
|
@@ -1128,7 +946,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1128
946
|
*/
|
|
1129
947
|
*getSuperCollections(graphUris, subjectUri) {
|
|
1130
948
|
const yielded = /* @__PURE__ */ new Set();
|
|
1131
|
-
const o =
|
|
949
|
+
const o = RdfDataFactory.namedNode(subjectUri);
|
|
1132
950
|
for (let q of this.store.matchAll(graphUris, null, skos.member, o)) {
|
|
1133
951
|
const s = q.subject;
|
|
1134
952
|
if (!yielded.has(s.value) && this.isCollection(graphUris, s.value)) {
|
|
@@ -1155,7 +973,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1155
973
|
* @returns An iterator of URIs of the collections that reference the subject in a member list.
|
|
1156
974
|
*/
|
|
1157
975
|
*_getMemberListContainers(graphUris, subjectUri) {
|
|
1158
|
-
const o =
|
|
976
|
+
const o = RdfDataFactory.namedNode(subjectUri);
|
|
1159
977
|
const visited = /* @__PURE__ */ new Set();
|
|
1160
978
|
const listNodes = [];
|
|
1161
979
|
for (let q of this.store.matchAll(graphUris, null, rdf.first, o)) {
|
|
@@ -1210,7 +1028,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1210
1028
|
if (yielded.has(m) || !this.isCollection(graphUris, m)) {
|
|
1211
1029
|
continue;
|
|
1212
1030
|
}
|
|
1213
|
-
if (this._skipCollection(graphUris,
|
|
1031
|
+
if (this._skipCollection(graphUris, RdfDataFactory.namedNode(m), options)) {
|
|
1214
1032
|
continue;
|
|
1215
1033
|
}
|
|
1216
1034
|
yielded.add(m);
|
|
@@ -1332,7 +1150,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1332
1150
|
*/
|
|
1333
1151
|
*getBroaderConcepts(graphUris, subjectUri) {
|
|
1334
1152
|
const yielded = /* @__PURE__ */ new Set();
|
|
1335
|
-
const s =
|
|
1153
|
+
const s = RdfDataFactory.namedNode(subjectUri);
|
|
1336
1154
|
for (let q of this.store.matchAll(graphUris, null, skos.hasTopConcept, s)) {
|
|
1337
1155
|
const s2 = q.subject;
|
|
1338
1156
|
if (!yielded.has(s2.value)) {
|
|
@@ -1393,7 +1211,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1393
1211
|
return;
|
|
1394
1212
|
}
|
|
1395
1213
|
const yielded = /* @__PURE__ */ new Set();
|
|
1396
|
-
const s =
|
|
1214
|
+
const s = RdfDataFactory.namedNode(subjectUri);
|
|
1397
1215
|
const scheme = options?.inScheme;
|
|
1398
1216
|
for (let q of this.store.matchAll(graphUris, s, skos.hasTopConcept, null)) {
|
|
1399
1217
|
const o = q.object;
|
|
@@ -1457,7 +1275,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1457
1275
|
*/
|
|
1458
1276
|
isConceptScheme(graphUris, subjectUri) {
|
|
1459
1277
|
if (subjectUri) {
|
|
1460
|
-
const s =
|
|
1278
|
+
const s = RdfDataFactory.namedNode(subjectUri);
|
|
1461
1279
|
for (let _ of this.store.matchAll(graphUris, s, rdf.type, skos.ConceptScheme)) {
|
|
1462
1280
|
return true;
|
|
1463
1281
|
}
|
|
@@ -1491,7 +1309,7 @@ var ConceptRepository = class extends ResourceRepository {
|
|
|
1491
1309
|
};
|
|
1492
1310
|
|
|
1493
1311
|
// src/rdf/class-repository.ts
|
|
1494
|
-
var { namedNode: namedNode2 } =
|
|
1312
|
+
var { namedNode: namedNode2 } = RdfDataFactory;
|
|
1495
1313
|
var ClassRepository = class extends ConceptRepository {
|
|
1496
1314
|
constructor(store) {
|
|
1497
1315
|
super(store);
|
|
@@ -1833,6 +1651,192 @@ var ClassRepository = class extends ConceptRepository {
|
|
|
1833
1651
|
}
|
|
1834
1652
|
};
|
|
1835
1653
|
|
|
1654
|
+
// src/rdf/data-factory.ts
|
|
1655
|
+
var NamedNode = class {
|
|
1656
|
+
constructor(value) {
|
|
1657
|
+
this.termType = "NamedNode";
|
|
1658
|
+
this.value = value;
|
|
1659
|
+
}
|
|
1660
|
+
equals(other) {
|
|
1661
|
+
return other?.termType === this.termType && other.value === this.value;
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
var BlankNode = class {
|
|
1665
|
+
constructor(value) {
|
|
1666
|
+
this.termType = "BlankNode";
|
|
1667
|
+
this.value = value;
|
|
1668
|
+
}
|
|
1669
|
+
equals(other) {
|
|
1670
|
+
return other?.termType === this.termType && other.value === this.value;
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
var Literal = class {
|
|
1674
|
+
constructor(value, languageOrDatatype) {
|
|
1675
|
+
this.termType = "Literal";
|
|
1676
|
+
this.value = value;
|
|
1677
|
+
if (typeof languageOrDatatype === "string") {
|
|
1678
|
+
this.language = languageOrDatatype.toLowerCase();
|
|
1679
|
+
this.datatype = new NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
|
|
1680
|
+
} else if (languageOrDatatype) {
|
|
1681
|
+
this.language = "";
|
|
1682
|
+
this.datatype = languageOrDatatype;
|
|
1683
|
+
} else {
|
|
1684
|
+
this.language = "";
|
|
1685
|
+
this.datatype = new NamedNode("http://www.w3.org/2001/XMLSchema#string");
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
equals(other) {
|
|
1689
|
+
if (other?.termType !== this.termType) {
|
|
1690
|
+
return false;
|
|
1691
|
+
}
|
|
1692
|
+
const otherLiteral = other;
|
|
1693
|
+
return this.value === otherLiteral.value && this.language === otherLiteral.language && this.datatype.equals(otherLiteral.datatype);
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
var Variable = class {
|
|
1697
|
+
constructor(value) {
|
|
1698
|
+
this.termType = "Variable";
|
|
1699
|
+
this.value = value;
|
|
1700
|
+
}
|
|
1701
|
+
equals(other) {
|
|
1702
|
+
return other?.termType === this.termType && other.value === this.value;
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
var DefaultGraph = class {
|
|
1706
|
+
constructor() {
|
|
1707
|
+
this.termType = "DefaultGraph";
|
|
1708
|
+
this.value = "";
|
|
1709
|
+
}
|
|
1710
|
+
equals(other) {
|
|
1711
|
+
return other?.termType === this.termType;
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
var Quad = class {
|
|
1715
|
+
constructor(subject, predicate, object, graph) {
|
|
1716
|
+
this.termType = "Quad";
|
|
1717
|
+
this.value = "";
|
|
1718
|
+
this.subject = subject;
|
|
1719
|
+
this.predicate = predicate;
|
|
1720
|
+
this.object = object;
|
|
1721
|
+
this.graph = graph ?? new DefaultGraph();
|
|
1722
|
+
}
|
|
1723
|
+
equals(other) {
|
|
1724
|
+
if (other?.termType !== this.termType) {
|
|
1725
|
+
return false;
|
|
1726
|
+
}
|
|
1727
|
+
const otherQuad = other;
|
|
1728
|
+
return this.subject.equals(otherQuad.subject) && this.predicate.equals(otherQuad.predicate) && this.object.equals(otherQuad.object) && this.graph.equals(otherQuad.graph);
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
var defaultGraphInstance = new DefaultGraph();
|
|
1732
|
+
var DataFactory2 = class {
|
|
1733
|
+
constructor() {
|
|
1734
|
+
this.blankNodeCounter = 0;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Creates a new named node with the given IRI.
|
|
1738
|
+
* @param value The IRI of the named node.
|
|
1739
|
+
* @returns A new NamedNode instance.
|
|
1740
|
+
*/
|
|
1741
|
+
namedNode(value) {
|
|
1742
|
+
return new NamedNode(value);
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Creates a new blank node with the given identifier.
|
|
1746
|
+
* If no identifier is provided, a unique one will be generated.
|
|
1747
|
+
* @param value Optional blank node identifier.
|
|
1748
|
+
* @returns A new BlankNode instance.
|
|
1749
|
+
*/
|
|
1750
|
+
blankNode(value) {
|
|
1751
|
+
return new BlankNode(value ?? `b${++this.blankNodeCounter}`);
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Creates a new literal with the given value and optional language tag or datatype.
|
|
1755
|
+
* @param value The lexical value of the literal.
|
|
1756
|
+
* @param languageOrDatatype Either a language tag (string) or a datatype (NamedNode).
|
|
1757
|
+
* @returns A new Literal instance.
|
|
1758
|
+
*/
|
|
1759
|
+
literal(value, languageOrDatatype) {
|
|
1760
|
+
return new Literal(value, languageOrDatatype);
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Creates a new variable with the given name.
|
|
1764
|
+
* @param value The name of the variable (without the leading '?').
|
|
1765
|
+
* @returns A new Variable instance.
|
|
1766
|
+
*/
|
|
1767
|
+
variable(value) {
|
|
1768
|
+
return new Variable(value);
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Returns the singleton default graph instance.
|
|
1772
|
+
* @returns The default graph instance.
|
|
1773
|
+
*/
|
|
1774
|
+
defaultGraph() {
|
|
1775
|
+
return defaultGraphInstance;
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Creates a new quad with the given subject, predicate, object, and optional graph.
|
|
1779
|
+
* @param subject The subject of the quad.
|
|
1780
|
+
* @param predicate The predicate of the quad.
|
|
1781
|
+
* @param object The object of the quad.
|
|
1782
|
+
* @param graph The graph of the quad (defaults to the default graph).
|
|
1783
|
+
* @returns A new Quad instance.
|
|
1784
|
+
*/
|
|
1785
|
+
quad(subject, predicate, object, graph) {
|
|
1786
|
+
return new Quad(subject, predicate, object, graph);
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Creates a copy of an existing term.
|
|
1790
|
+
* @param original The term to copy.
|
|
1791
|
+
* @returns A new term instance with the same value.
|
|
1792
|
+
*/
|
|
1793
|
+
fromTerm(original) {
|
|
1794
|
+
switch (original.termType) {
|
|
1795
|
+
case "NamedNode":
|
|
1796
|
+
return this.namedNode(original.value);
|
|
1797
|
+
case "BlankNode":
|
|
1798
|
+
return this.blankNode(original.value);
|
|
1799
|
+
case "Literal": {
|
|
1800
|
+
const literal = original;
|
|
1801
|
+
if (literal.language) {
|
|
1802
|
+
return this.literal(literal.value, literal.language);
|
|
1803
|
+
}
|
|
1804
|
+
return this.literal(literal.value, this.fromTerm(literal.datatype));
|
|
1805
|
+
}
|
|
1806
|
+
case "Variable":
|
|
1807
|
+
return this.variable(original.value);
|
|
1808
|
+
case "DefaultGraph":
|
|
1809
|
+
return this.defaultGraph();
|
|
1810
|
+
case "Quad": {
|
|
1811
|
+
const quad5 = original;
|
|
1812
|
+
return this.fromQuad(quad5);
|
|
1813
|
+
}
|
|
1814
|
+
default:
|
|
1815
|
+
throw new Error(`Unknown term type: ${original.termType}`);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Creates a copy of an existing quad.
|
|
1820
|
+
* @param original The quad to copy.
|
|
1821
|
+
* @returns A new quad instance with the same values.
|
|
1822
|
+
*/
|
|
1823
|
+
fromQuad(original) {
|
|
1824
|
+
return this.quad(
|
|
1825
|
+
this.fromTerm(original.subject),
|
|
1826
|
+
this.fromTerm(original.predicate),
|
|
1827
|
+
this.fromTerm(original.object),
|
|
1828
|
+
this.fromTerm(original.graph)
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Resets the blank node counter. Useful for testing.
|
|
1833
|
+
*/
|
|
1834
|
+
resetBlankNodeCounter() {
|
|
1835
|
+
this.blankNodeCounter = 0;
|
|
1836
|
+
}
|
|
1837
|
+
};
|
|
1838
|
+
var dataFactory = new DataFactory2();
|
|
1839
|
+
|
|
1836
1840
|
// src/rdf/dataset-view.ts
|
|
1837
1841
|
var DatasetView = class _DatasetView {
|
|
1838
1842
|
constructor(store, options = {}) {
|
|
@@ -2008,7 +2012,7 @@ var DatasetView = class _DatasetView {
|
|
|
2008
2012
|
};
|
|
2009
2013
|
|
|
2010
2014
|
// src/rdf/property-repository.ts
|
|
2011
|
-
var { namedNode: namedNode3 } =
|
|
2015
|
+
var { namedNode: namedNode3 } = RdfDataFactory;
|
|
2012
2016
|
var PropertyRepository = class extends ClassRepository {
|
|
2013
2017
|
constructor(store) {
|
|
2014
2018
|
super(store);
|
|
@@ -2280,7 +2284,7 @@ var PropertyRepository = class extends ClassRepository {
|
|
|
2280
2284
|
};
|
|
2281
2285
|
|
|
2282
2286
|
// src/rdf/individual-repository.ts
|
|
2283
|
-
var { namedNode: namedNode4 } =
|
|
2287
|
+
var { namedNode: namedNode4 } = RdfDataFactory;
|
|
2284
2288
|
var IndividualRepository = class extends PropertyRepository {
|
|
2285
2289
|
constructor(store) {
|
|
2286
2290
|
super(store);
|
|
@@ -2357,7 +2361,7 @@ var IndividualRepository = class extends PropertyRepository {
|
|
|
2357
2361
|
|
|
2358
2362
|
// src/rdf/reasoners/reasoner.ts
|
|
2359
2363
|
import { RdfStore } from "rdf-stores";
|
|
2360
|
-
var { namedNode: namedNode5, blankNode: blankNode2 } =
|
|
2364
|
+
var { namedNode: namedNode5, blankNode: blankNode2 } = RdfDataFactory;
|
|
2361
2365
|
var DefaultInferenceGraphHandler = class {
|
|
2362
2366
|
getGraphUri(uri) {
|
|
2363
2367
|
const u = typeof uri === "string" ? uri : uri.value;
|
|
@@ -2463,7 +2467,7 @@ var ReasonerBase = class {
|
|
|
2463
2467
|
};
|
|
2464
2468
|
|
|
2465
2469
|
// src/rdf/reasoners/skos-reasoner.ts
|
|
2466
|
-
var { quad } =
|
|
2470
|
+
var { quad } = RdfDataFactory;
|
|
2467
2471
|
var SkosReasoner = class extends ReasonerBase {
|
|
2468
2472
|
constructor(targetUriGenerator = new DefaultInferenceGraphHandler()) {
|
|
2469
2473
|
super(targetUriGenerator);
|
|
@@ -2585,7 +2589,7 @@ var SkosReasoner = class extends ReasonerBase {
|
|
|
2585
2589
|
};
|
|
2586
2590
|
|
|
2587
2591
|
// src/rdf/reasoners/rdfs-reasoner.ts
|
|
2588
|
-
var { quad: quad2 } =
|
|
2592
|
+
var { quad: quad2 } = RdfDataFactory;
|
|
2589
2593
|
var RdfsReasoner = class extends SkosReasoner {
|
|
2590
2594
|
constructor(targetUriGenerator = new DefaultInferenceGraphHandler()) {
|
|
2591
2595
|
super(targetUriGenerator);
|
|
@@ -2819,7 +2823,7 @@ var RdfsReasoner = class extends SkosReasoner {
|
|
|
2819
2823
|
};
|
|
2820
2824
|
|
|
2821
2825
|
// src/rdf/reasoners/shacl-reasoner.ts
|
|
2822
|
-
var { quad: quad3 } =
|
|
2826
|
+
var { quad: quad3 } = RdfDataFactory;
|
|
2823
2827
|
var ShaclReasoner = class extends RdfsReasoner {
|
|
2824
2828
|
constructor(targetUriGenerator = new DefaultInferenceGraphHandler()) {
|
|
2825
2829
|
super(targetUriGenerator);
|
|
@@ -2981,7 +2985,7 @@ var ShaclReasoner = class extends RdfsReasoner {
|
|
|
2981
2985
|
};
|
|
2982
2986
|
|
|
2983
2987
|
// src/rdf/reasoners/owl-reasoner.ts
|
|
2984
|
-
var { quad: quad4 } =
|
|
2988
|
+
var { quad: quad4 } = RdfDataFactory;
|
|
2985
2989
|
var OwlReasoner = class extends ShaclReasoner {
|
|
2986
2990
|
constructor(targetUriGenerator = new DefaultInferenceGraphHandler()) {
|
|
2987
2991
|
super(targetUriGenerator);
|
|
@@ -3165,7 +3169,7 @@ var OwlReasoner = class extends ShaclReasoner {
|
|
|
3165
3169
|
};
|
|
3166
3170
|
|
|
3167
3171
|
// src/rdf/shape-repository.ts
|
|
3168
|
-
var { namedNode: namedNode6 } =
|
|
3172
|
+
var { namedNode: namedNode6 } = RdfDataFactory;
|
|
3169
3173
|
var ShapeRepository = class extends IndividualRepository {
|
|
3170
3174
|
constructor(store) {
|
|
3171
3175
|
super(store);
|
|
@@ -7954,7 +7958,7 @@ var Store = class {
|
|
|
7954
7958
|
};
|
|
7955
7959
|
|
|
7956
7960
|
// src/rdf/vocabulary-repository.ts
|
|
7957
|
-
var { namedNode: namedNode7 } =
|
|
7961
|
+
var { namedNode: namedNode7 } = RdfDataFactory;
|
|
7958
7962
|
var VocabularyRepository = class extends ShapeRepository {
|
|
7959
7963
|
/**
|
|
7960
7964
|
* Get all concept schemes in the repository.
|
|
@@ -8073,7 +8077,7 @@ export {
|
|
|
8073
8077
|
BlankNode,
|
|
8074
8078
|
ClassRepository,
|
|
8075
8079
|
DCAT,
|
|
8076
|
-
DataFactory,
|
|
8080
|
+
DataFactory2 as DataFactory,
|
|
8077
8081
|
DatasetView,
|
|
8078
8082
|
DefaultGraph,
|
|
8079
8083
|
DefaultInferenceGraphHandler,
|