@faubulous/mentor-rdf 0.2.55 → 0.3.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 +6 -6
- package/dist/rdf/class-repository.d.ts +31 -14
- package/dist/rdf/concept-repository.d.ts +8 -8
- package/dist/rdf/individual-repository.d.ts +4 -4
- package/dist/rdf/property-repository.d.ts +18 -9
- package/dist/rdf/shape-repository.d.ts +9 -9
- package/dist/rdf/vocabulary-repository.d.ts +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1209,7 +1209,7 @@ eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexp
|
|
|
1209
1209
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1210
1210
|
|
|
1211
1211
|
"use strict";
|
|
1212
|
-
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ClassRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst concept_repository_1 = __webpack_require__(/*! ./concept-repository */ \"./src/rdf/concept-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving classes from graphs.\n */\nclass ClassRepository extends concept_repository_1.ConceptRepository {\n constructor(store) { super(store); }\n /**\n * Get all classes in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all classes in the repository.\n */\n getClasses(graphUris, options) {\n const result = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.rdfs.Class, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n }\n return Array.from(result);\n }\n /**\n * Get the super classes of a given class.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @param options Optional query parameters.\n * @returns An array of super classes of the given class, an empty array if the class has no super classes.\n */\n getSuperClasses(graphUris, subjectUri, options) {\n const result = new Set();\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdfs.subClassOf, null, options?.includeInferred)) {\n if (!this.skip(graphUris, q.object, options)) {\n result.add(q.object.value);\n }\n }\n return Array.from(result);\n }\n /**\n * Get the first discovered path from a given class to a root class.\n * @param subjectUri URI of a class.\n * @returns A string array containing the first path that is found from the given class to a root class.\n */\n getRootClassPath(graphUris, subjectUri, options) {\n return this._getRootClassPath(graphUris, subjectUri, [], new Set(), options);\n }\n /**\n * Recursively find the first path from a given class to a root class.\n * @param subjectUri URI of a class.\n * @param path The current class path.\n * @param backtrack Set of URIs that have already been visited.\n * @returns The first path that is found from the given class to a root class.\n */\n _getRootClassPath(graphUris, subjectUri, path, backtrack, options) {\n const superClasses = this.getSuperClasses(graphUris, subjectUri, options);\n for (let o of superClasses.filter(o => !backtrack.has(o))) {\n return this._getRootClassPath(graphUris, o, [...path, o], backtrack, options);\n }\n return path;\n }\n /**\n * Indicate if there are sub classes of a given class.\n * @param subjectUri URI of a class.\n * @returns true if the class has sub classes, false otherwise.\n */\n hasSubClasses(graphUris, subjectUri, options) {\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subClassOf, o)) {\n if (!this.skip(graphUris, q.subject, options)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get the sub classes of a given class or all root classes.\n * @param subjectUri URI of a class or undefined to get all root classes.\n * @returns An array of sub classes of the given class, an empty array if the class has no sub classes.\n */\n getSubClasses(graphUris, subjectUri, options) {\n if (subjectUri) {\n const result = new Set();\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subClassOf, o, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n }\n return Array.from(result);\n }\n else {\n return this.getRootClasses(graphUris, options);\n }\n }\n /**\n * Recursively traverse all sub classes of a given class and invoke a callback.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param superClass The super class to start the traversal from.\n * @param callback A function to call for each sub class. If the function returns `false`, the traversal stops.\n * @param options Optional query parameters.\n * @param visited A set of visited URIs.\n * @returns `true` if the traversal was completed, `false` if it was stopped by the callback.\n */\n _traverseSubClasses(graphUris, superClass, callback, options, visited = new Set()) {\n // Enumerate all sub classes of the given super class.\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subClassOf, superClass, options?.includeInferred)) {\n // If it is not skipped and has not been visited yet, we call the callback function.\n if (!this.skip(graphUris, q.subject, options) && !visited.has(q.subject.value)) {\n visited.add(q.subject.value);\n // If the callback returns false, we stop the traversal.\n if (callback(q.subject)) {\n this._traverseSubClasses(graphUris, q.subject, callback, options, visited);\n }\n else {\n return false;\n }\n }\n }\n return true;\n }\n /**\n * Get all sub classes of a given class, including indirect sub classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @param options Optional query parameters.\n * @returns An array of all sub classes of the given class.\n */\n getAllSubClasses(graphUris, subjectUri, options) {\n const result = new Set();\n this._traverseSubClasses(graphUris, namedNode(subjectUri), s => { result.add(s.value); return true; }, options);\n return Array.from(result);\n }\n /**\n * Indicate if there are instances of a given class or any of its sub classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param typeUri URI of the class.\n * @param options Optional query parameters.\n * @returns `true` if the class has instances, `false` otherwise.\n */\n hasSubjectsOfType(graphUris, typeUri, options) {\n // TODO: Optimize implementation.\n return this.getSubjectsOfType(graphUris, typeUri, options).length > 0;\n }\n /**\n * Get all subjects of a given class in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param typeUri URI of the class.\n * @param options Optional query parameters.\n * @returns A list of all shapes in the repository.\n */\n getSubjectsOfType(graphUris, typeUri, options) {\n const result = new Set();\n if (options?.includeSubTypes === false) {\n // 1. Get all subclasses of the given type from the repository -> ClassRepository.\n const subclasses = new Set(this.getAllSubClasses(graphUris, typeUri));\n // 2. Then get all triples that have a rdf:type predicate.\n // a) if the object matches the given type, add it to the result.\n // b) if the object is a subclass of the given type, remove it from the result.\n const filtered = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, null, options?.includeInferred)) {\n if (q.object.value == typeUri && !this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n else if (subclasses.has(q.object.value)) {\n filtered.add(q.subject.value);\n }\n }\n return Array.from(result).filter(x => !filtered.has(x));\n }\n else {\n // TODO: This does not explicitly check the sub classes. Implement a unit test.\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, namedNode(typeUri), options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n }\n return Array.from(result);\n }\n }\n /**\n * Indicate if a given class is direct or indirect (inferred) sub class of another class.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of the sub class.\n * @param classUri URI of the super class.\n * @param options Optional query parameters.\n * @returns `true` if the class is a sub class of the other class, false otherwise.\n */\n isSubClassOf(graphUris, subjectUri, classUri, options) {\n return this.getRootClassPath(graphUris, subjectUri, options).includes(classUri);\n }\n /**\n * Indicate if a given class is the intersection of classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @returns `true` if the class is the intersection of classes, `false` otherwise.\n */\n isIntersectionOfClasses(graphUris, subjectUri) {\n const s = namedNode(subjectUri);\n if (this._isIntersectionOfClasses(graphUris, s)) {\n return true;\n }\n // Note: The intersection must be defined in the original graphs, so inference is not required.\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentClass, null, false)) {\n if (this._isIntersectionOfClasses(graphUris, q.object)) {\n return true;\n }\n }\n return false;\n }\n _isIntersectionOfClasses(graphUris, subject) {\n if (subject.termType === \"BlankNode\" || subject.termType === \"NamedNode\") {\n for (let _ of this.store.matchAll(graphUris, subject, ontologies_1.owl.intersectionOf, null, false)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Indicate if a given class is a (disjoint) union of classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @returns `true` if the class is a (disjoint) union of classes, `false` otherwise.\n */\n isUnionOfClasses(graphUris, subjectUri) {\n const s = namedNode(subjectUri);\n if (this._isUnionOfClasses(graphUris, s)) {\n return true;\n }\n // Note: The union must be defined in the original graphs, so inference is not required.\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentClass, null, false)) {\n if (this._isUnionOfClasses(graphUris, q.object)) {\n return true;\n }\n }\n return false;\n }\n _isUnionOfClasses(graphUris, subject) {\n if (subject.termType === \"BlankNode\" || subject.termType === \"NamedNode\") {\n for (let _ of this.store.matchAll(graphUris, subject, ontologies_1.owl.unionOf, null, false)) {\n return true;\n }\n for (let _ of this.store.matchAll(graphUris, subject, ontologies_1.owl.disjointUnionOf, null, false)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get all classes from the repository that have no super classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns An array of root classes in the repository.\n */\n getRootClasses(graphUris, options) {\n const result = new Set();\n const classes = new Set(this.getClasses(graphUris, options));\n for (let c of classes) {\n let hasSuperClass = false;\n for (let q of this.store.matchAll(graphUris, namedNode(c), ontologies_1.rdfs.subClassOf, null, options?.includeInferred)) {\n const includeReferenced = options?.includeReferenced ?? false;\n const skip = this.skip(graphUris, q.object, options);\n // Do not skip the super property if it is only referenced and the includeReferenced option is set.\n if (q.object.termType != \"NamedNode\" || skip && (!includeReferenced || includeReferenced && this.hasSubject(graphUris, q.object.value))) {\n continue;\n }\n hasSuperClass = true;\n // If we have a super property that is not in the list of properties and not excluded by the options, we add it to the result.\n if (!classes.has(q.object.value)) {\n result.add(q.object.value);\n }\n break;\n }\n if (!hasSuperClass) {\n result.add(c);\n }\n }\n return Array.from(result);\n }\n /**\n * Indicate if there is an equivalent class of a given class.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @param options Optional query parameters.\n * @returns `true` if the class has an equivalent class, `false` otherwise.\n */\n hasEquivalentClass(graphUris, subjectUri, options) {\n const s = namedNode(subjectUri);\n // The OWL resoner will assert the equivalent class relationship in both directions.\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentClass, null, options?.includeInferred)) {\n return true;\n }\n return false;\n }\n /**\n * Indicate if a given class has at least one individual defined for it or for one of its sub classes.\n * @param graphUris Graph URIs to search in, undefined for the default graph.\n * @param classUri URI of a class.\n * @param options Optional query parameters.\n * @returns `true` if the class has individuals, `false` otherwise.\n */\n hasIndividuals(graphUris, classUri, options) {\n const s = namedNode(classUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, s, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n return true;\n }\n }\n for (let c of this.getSubClasses(graphUris, classUri, options)) {\n if (this.hasIndividuals(graphUris, c)) {\n return true;\n }\n }\n return false;\n }\n}\nexports.ClassRepository = ClassRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/class-repository.ts?\n}");
|
|
1212
|
+
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ClassRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst concept_repository_1 = __webpack_require__(/*! ./concept-repository */ \"./src/rdf/concept-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving classes from graphs.\n */\nclass ClassRepository extends concept_repository_1.ConceptRepository {\n constructor(store) { super(store); }\n /**\n * Get all classes in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns An iterator of all classes in the repository.\n */\n *getClasses(graphUris, options) {\n const yielded = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.rdfs.Class, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options) && !yielded.has(q.subject.value)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n /**\n * Get the super classes of a given class.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @param options Optional query parameters.\n * @returns An iterator of super classes of the given class.\n */\n *getSuperClasses(graphUris, subjectUri, options) {\n const yielded = new Set();\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdfs.subClassOf, null, options?.includeInferred)) {\n if (!this.skip(graphUris, q.object, options) && !yielded.has(q.object.value)) {\n yielded.add(q.object.value);\n yield q.object.value;\n }\n }\n }\n /**\n * Get the first discovered path from a given class to a root class.\n * @param subjectUri URI of a class.\n * @returns An iterator containing the first path that is found from the given class to a root class.\n */\n *getRootClassPath(graphUris, subjectUri, options) {\n const path = this._getRootClassPath(graphUris, subjectUri, [], new Set(), options);\n yield* path;\n }\n /**\n * Recursively find the first path from a given class to a root class.\n * @param subjectUri URI of a class.\n * @param path The current class path.\n * @param backtrack Set of URIs that have already been visited.\n * @returns The first path that is found from the given class to a root class.\n */\n _getRootClassPath(graphUris, subjectUri, path, backtrack, options) {\n for (let o of this.getSuperClasses(graphUris, subjectUri, options)) {\n if (!backtrack.has(o)) {\n backtrack.add(o);\n return this._getRootClassPath(graphUris, o, [...path, o], backtrack, options);\n }\n }\n return path;\n }\n /**\n * Indicate if there are sub classes of a given class.\n * @param subjectUri URI of a class.\n * @returns true if the class has sub classes, false otherwise.\n */\n hasSubClasses(graphUris, subjectUri, options) {\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subClassOf, o)) {\n if (!this.skip(graphUris, q.subject, options)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get the sub classes of a given class or all root classes.\n * @param subjectUri URI of a class or undefined to get all root classes.\n * @returns An iterator of sub classes of the given class, or root classes if no subject is provided.\n */\n *getSubClasses(graphUris, subjectUri, options) {\n if (subjectUri) {\n const yielded = new Set();\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subClassOf, o, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options) && !yielded.has(q.subject.value)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n else {\n yield* this.getRootClasses(graphUris, options);\n }\n }\n /**\n * Recursively traverse all sub classes of a given class and invoke a callback.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param superClass The super class to start the traversal from.\n * @param callback A function to call for each sub class. If the function returns `false`, the traversal stops.\n * @param options Optional query parameters.\n * @param visited A set of visited URIs.\n * @returns `true` if the traversal was completed, `false` if it was stopped by the callback.\n */\n _traverseSubClasses(graphUris, superClass, callback, options, visited = new Set()) {\n // Enumerate all sub classes of the given super class.\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subClassOf, superClass, options?.includeInferred)) {\n // If it is not skipped and has not been visited yet, we call the callback function.\n if (!this.skip(graphUris, q.subject, options) && !visited.has(q.subject.value)) {\n visited.add(q.subject.value);\n // If the callback returns false, we stop the traversal.\n if (callback(q.subject)) {\n this._traverseSubClasses(graphUris, q.subject, callback, options, visited);\n }\n else {\n return false;\n }\n }\n }\n return true;\n }\n /**\n * Get all sub classes of a given class, including indirect sub classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @param options Optional query parameters.\n * @returns An iterator of all sub classes of the given class.\n */\n *getAllSubClasses(graphUris, subjectUri, options) {\n const visited = new Set();\n yield* this._traverseSubClassesGenerator(graphUris, namedNode(subjectUri), options, visited);\n }\n /**\n * Recursively traverse all sub classes of a given class and yield them.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param superClass The super class to start the traversal from.\n * @param options Optional query parameters.\n * @param visited A set of visited URIs.\n */\n *_traverseSubClassesGenerator(graphUris, superClass, options, visited = new Set()) {\n // Enumerate all sub classes of the given super class.\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subClassOf, superClass, options?.includeInferred)) {\n // If it is not skipped and has not been visited yet, we yield it and recurse.\n if (!this.skip(graphUris, q.subject, options) && !visited.has(q.subject.value)) {\n visited.add(q.subject.value);\n yield q.subject.value;\n yield* this._traverseSubClassesGenerator(graphUris, q.subject, options, visited);\n }\n }\n }\n /**\n * Indicate if there are instances of a given class or any of its sub classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param typeUri URI of the class.\n * @param options Optional query parameters.\n * @returns `true` if the class has instances, `false` otherwise.\n */\n hasSubjectsOfType(graphUris, typeUri, options) {\n const iterator = this.getSubjectsOfType(graphUris, typeUri, options).next();\n return !iterator.done;\n }\n /**\n * Get all subjects of a given class in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param typeUri URI of the class.\n * @param options Optional query parameters.\n * @returns An iterator of all subjects of the given class.\n */\n *getSubjectsOfType(graphUris, typeUri, options) {\n if (options?.includeSubTypes === false) {\n // 1. Get all subclasses of the given type from the repository -> ClassRepository.\n const subclasses = new Set(this.getAllSubClasses(graphUris, typeUri));\n // 2. Then get all triples that have a rdf:type predicate.\n // a) if the object matches the given type, add it to the result.\n // b) if the object is a subclass of the given type, track it for filtering.\n const result = new Set();\n const filtered = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, null, options?.includeInferred)) {\n if (q.object.value == typeUri && !this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n else if (subclasses.has(q.object.value)) {\n filtered.add(q.subject.value);\n }\n }\n // Yield only items that are not filtered\n for (const item of result) {\n if (!filtered.has(item)) {\n yield item;\n }\n }\n }\n else {\n // TODO: This does not explicitly check the sub classes. Implement a unit test.\n const yielded = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, namedNode(typeUri), options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options) && !yielded.has(q.subject.value)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n }\n /**\n * Indicate if a given class is direct or indirect (inferred) sub class of another class.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of the sub class.\n * @param classUri URI of the super class.\n * @param options Optional query parameters.\n * @returns `true` if the class is a sub class of the other class, false otherwise.\n */\n isSubClassOf(graphUris, subjectUri, classUri, options) {\n for (const pathClass of this.getRootClassPath(graphUris, subjectUri, options)) {\n if (pathClass === classUri) {\n return true;\n }\n }\n return false;\n }\n /**\n * Indicate if a given class is the intersection of classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @returns `true` if the class is the intersection of classes, `false` otherwise.\n */\n isIntersectionOfClasses(graphUris, subjectUri) {\n const s = namedNode(subjectUri);\n if (this._isIntersectionOfClasses(graphUris, s)) {\n return true;\n }\n // Note: The intersection must be defined in the original graphs, so inference is not required.\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentClass, null, false)) {\n if (this._isIntersectionOfClasses(graphUris, q.object)) {\n return true;\n }\n }\n return false;\n }\n _isIntersectionOfClasses(graphUris, subject) {\n if (subject.termType === \"BlankNode\" || subject.termType === \"NamedNode\") {\n for (let _ of this.store.matchAll(graphUris, subject, ontologies_1.owl.intersectionOf, null, false)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Indicate if a given class is a (disjoint) union of classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @returns `true` if the class is a (disjoint) union of classes, `false` otherwise.\n */\n isUnionOfClasses(graphUris, subjectUri) {\n const s = namedNode(subjectUri);\n if (this._isUnionOfClasses(graphUris, s)) {\n return true;\n }\n // Note: The union must be defined in the original graphs, so inference is not required.\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentClass, null, false)) {\n if (this._isUnionOfClasses(graphUris, q.object)) {\n return true;\n }\n }\n return false;\n }\n _isUnionOfClasses(graphUris, subject) {\n if (subject.termType === \"BlankNode\" || subject.termType === \"NamedNode\") {\n for (let _ of this.store.matchAll(graphUris, subject, ontologies_1.owl.unionOf, null, false)) {\n return true;\n }\n for (let _ of this.store.matchAll(graphUris, subject, ontologies_1.owl.disjointUnionOf, null, false)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get all classes from the repository that have no super classes.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns An iterator of root classes in the repository.\n */\n *getRootClasses(graphUris, options) {\n const yielded = new Set();\n const classes = new Set(this.getClasses(graphUris, options));\n for (let c of classes) {\n let hasSuperClass = false;\n for (let q of this.store.matchAll(graphUris, namedNode(c), ontologies_1.rdfs.subClassOf, null, options?.includeInferred)) {\n const includeReferenced = options?.includeReferenced ?? false;\n const skip = this.skip(graphUris, q.object, options);\n // Do not skip the super class if it is only referenced and the includeReferenced option is set.\n if (q.object.termType != \"NamedNode\" || skip && (!includeReferenced || includeReferenced && this.hasSubject(graphUris, q.object.value))) {\n continue;\n }\n // We have at least one super class that is not the class itself.\n hasSuperClass = q.object.value != q.subject.value;\n // If we have a super class that is not in the list of c and not excluded by the options, we add it to the result.\n if (!classes.has(q.object.value) && !yielded.has(q.object.value)) {\n yielded.add(q.object.value);\n yield q.object.value;\n }\n break;\n }\n if (!hasSuperClass && !yielded.has(c)) {\n yielded.add(c);\n yield c;\n }\n }\n }\n /**\n * Indicate if there is an equivalent class of a given class.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of a class.\n * @param options Optional query parameters.\n * @returns `true` if the class has an equivalent class, `false` otherwise.\n */\n hasEquivalentClass(graphUris, subjectUri, options) {\n const s = namedNode(subjectUri);\n // The OWL resoner will assert the equivalent class relationship in both directions.\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentClass, null, options?.includeInferred)) {\n return true;\n }\n return false;\n }\n /**\n * Indicate if a given class has at least one individual defined for it or for one of its sub classes.\n * @param graphUris Graph URIs to search in, undefined for the default graph.\n * @param classUri URI of a class.\n * @param options Optional query parameters.\n * @returns `true` if the class has individuals, `false` otherwise.\n */\n hasIndividuals(graphUris, classUri, options) {\n return this._hasIndividuals(new Set(), graphUris, classUri, options);\n }\n /**\n * Internal method to check for individuals with cycle detection.\n * @param graphUris Graph URIs to search in, undefined for the default graph.\n * @param classUri URI of a class.\n * @param options Optional query parameters.\n * @param backtrack Set of already visited class URIs to prevent cycles.\n * @returns `true` if the class has individuals, `false` otherwise.\n */\n _hasIndividuals(backtrack, graphUris, classUri, options) {\n // Prevent infinite recursion by checking if we've already visited this class\n if (backtrack.has(classUri)) {\n return false;\n }\n backtrack.add(classUri);\n const s = namedNode(classUri);\n // Check for direct individuals of this class\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, s, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n return true;\n }\n }\n // Check subclasses recursively with cycle detection\n for (let c of this.getSubClasses(graphUris, classUri, options)) {\n if (this._hasIndividuals(backtrack, graphUris, c, options)) {\n return true;\n }\n }\n return false;\n }\n}\nexports.ClassRepository = ClassRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/class-repository.ts?\n}");
|
|
1213
1213
|
|
|
1214
1214
|
/***/ }),
|
|
1215
1215
|
|
|
@@ -1220,7 +1220,7 @@ eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexp
|
|
|
1220
1220
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1221
1221
|
|
|
1222
1222
|
"use strict";
|
|
1223
|
-
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ConceptRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst resource_repository_1 = __webpack_require__(/*! ./resource-repository */ \"./src/rdf/resource-repository.ts\");\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nclass ConceptRepository extends resource_repository_1.ResourceRepository {\n /**\n * Get all concepts.\n * @param graphUris URIs of the graphs to search for concepts.\n * @returns A list of URIs of all concepts.\n */\n getConcepts(graphUris) {\n const result = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.Concept)) {\n const s = q.subject;\n result.add(s.value);\n }\n return Array.from(result);\n }\n /**\n * Get all concept schemes.\n * @param graphUris URIs of the graphs to search for concepts.\n * @returns A list of URIs of all concepts.\n */\n getConceptSchemes(graphUris) {\n const result = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme)) {\n const s = q.subject;\n result.add(s.value);\n }\n return Array.from(result);\n }\n /**\n * Get all collections.\n * @param graphUris URI of the graphs to search for collections.\n * @returns A list of URIs of all collections.\n */\n getCollections(graphUris) {\n const result = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.Collection)) {\n const s = q.subject;\n result.add(s.value);\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.OrderedCollection)) {\n const s = q.subject;\n result.add(s.value);\n }\n return Array.from(result);\n }\n /**\n * Get the members of a collection. This includes both `skos:member` and `skos:memberList` properties.\n * @param graphUris URI of the graphs to search for collections.\n * @param collectionUri URI of a collection.\n * @returns An array of URIs of the members of the collection.\n */\n getCollectionMembers(graphUris, collectionUri) {\n const s = n3.DataFactory.namedNode(collectionUri);\n let result = [];\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.member, null)) {\n result.push(q.object.value);\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.memberList, null)) {\n result = [...result, ...this.store.getListItems(graphUris, q.object.value)];\n }\n return result;\n }\n /**\n * Get the members of a collection. This includes both `skos:member` and `skos:memberList` properties.\n * @param graphUris URI of the graphs to search for collections.\n * @param collectionUri URI of a collection.\n * @returns An array of URIs of the members of the collection.\n */\n hasCollectionMembers(graphUris, collectionUri) {\n const s = n3.DataFactory.namedNode(collectionUri);\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.skos.member, null)) {\n return true;\n }\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.skos.memberList, null)) {\n return true;\n }\n return false;\n }\n /**\n * Indicates whether a collection is an ordered collection.\n * @param graphUris URI of the graphs to search for collections.\n * @param collectionUri URI of a collection.\n * @returns `true` if the collection is an ordered collection, `false` otherwise.\n */\n isOrderedCollection(graphUris, collectionUri) {\n const s = n3.DataFactory.namedNode(collectionUri);\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.skos.OrderedCollection)) {\n return true;\n }\n return false;\n }\n /**\n * Get all broader concepts of a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept scheme.\n */\n getBroaderConcepts(graphUris, subjectUri) {\n const result = new Set();\n const s = n3.DataFactory.namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.hasTopConcept, s)) {\n const s = q.subject;\n result.add(s.value);\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.narrower, s)) {\n const s = q.subject;\n result.add(s.value);\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.topConceptOf, null)) {\n const o = q.object;\n result.add(o.value);\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.broader, null)) {\n const o = q.object;\n result.add(o.value);\n }\n return Array.from(result);\n }\n /**\n * Indicates whether a concept has broader concepts.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n */\n hasBroaderConcepts(graphUris, subjectUri) {\n return this.getBroaderConcepts(graphUris, subjectUri).length > 0;\n }\n /**\n * Get all narrower concepts of a concept or top concepts of a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept or concept scheme.\n */\n getNarrowerConcepts(graphUris, subjectUri) {\n if (subjectUri) {\n const result = new Set();\n const s = n3.DataFactory.namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.hasTopConcept, null)) {\n const o = q.object;\n result.add(o.value);\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.narrower, null)) {\n const o = q.object;\n result.add(o.value);\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.topConceptOf, s)) {\n const s = q.subject;\n result.add(s.value);\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.broader, s)) {\n const s = q.subject;\n result.add(s.value);\n }\n return Array.from(result);\n }\n else {\n return this.getConceptSchemes(graphUris);\n }\n }\n /**\n * Indicates whether a concept has narrower concepts.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n */\n hasNarrowerConcepts(graphUris, subjectUri) {\n return this.getNarrowerConcepts(graphUris, subjectUri).length > 0;\n }\n /**\n * Indicates whether a concept is a narrower concept of another concept.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n * @param broaderUri URI of a broader concept.\n * @returns `true` if the concept is a narrower concept of the broader concept, `false` otherwise.\n */\n isNarrowerConceptOf(graphUris, subjectUri, broaderUri) {\n return this.getConceptSchemePath(graphUris, subjectUri).includes(broaderUri);\n }\n /**\n * Indicates whether a subject is a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a subject.\n * @returns `true` if the subject is a concept scheme, `false` otherwise.\n */\n isConceptScheme(graphUris, subjectUri) {\n if (subjectUri) {\n const s = n3.DataFactory.namedNode(subjectUri);\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get all broader concepts up to and including a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n */\n getConceptSchemePath(graphUris, subjectUri) {\n return this._getConceptSchemePath(graphUris, subjectUri, [], new Set());\n }\n /**\n * Recursively find the first path from a given class to a root class.\n * @param subjectUri URI of a class.\n * @param path The current class path.\n * @param backtrack Set of URIs that have already been visited.\n * @returns The first path that is found from the given class to a root class.\n */\n _getConceptSchemePath(graphUris, subjectUri, path, backtrack) {\n const broaderConcepts = this.getBroaderConcepts(graphUris, subjectUri);\n for (let o of broaderConcepts.filter(o => !backtrack.has(o))) {\n return this._getConceptSchemePath(graphUris, o, [...path, o], backtrack);\n }\n return path;\n }\n}\nexports.ConceptRepository = ConceptRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/concept-repository.ts?\n}");
|
|
1223
|
+
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ConceptRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst resource_repository_1 = __webpack_require__(/*! ./resource-repository */ \"./src/rdf/resource-repository.ts\");\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nclass ConceptRepository extends resource_repository_1.ResourceRepository {\n /**\n * Get all concepts.\n * @param graphUris URIs of the graphs to search for concepts.\n * @returns An iterator of URIs of all concepts.\n */\n *getConcepts(graphUris) {\n const yielded = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.Concept)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n }\n /**\n * Get all concept schemes.\n * @param graphUris URIs of the graphs to search for concepts.\n * @returns An iterator of URIs of all concept schemes.\n */\n *getConceptSchemes(graphUris) {\n const yielded = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n }\n /**\n * Get all collections.\n * @param graphUris URI of the graphs to search for collections.\n * @returns An iterator of URIs of all collections.\n */\n *getCollections(graphUris) {\n const yielded = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.Collection)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.OrderedCollection)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n }\n /**\n * Get the members of a collection. This includes both `skos:member` and `skos:memberList` properties.\n * @param graphUris URI of the graphs to search for collections.\n * @param collectionUri URI of a collection.\n * @returns An array of URIs of the members of the collection.\n */\n getCollectionMembers(graphUris, collectionUri) {\n const s = n3.DataFactory.namedNode(collectionUri);\n let result = [];\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.member, null)) {\n result.push(q.object.value);\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.memberList, null)) {\n result = [...result, ...this.store.getListItems(graphUris, q.object.value)];\n }\n return result;\n }\n /**\n * Get the members of a collection. This includes both `skos:member` and `skos:memberList` properties.\n * @param graphUris URI of the graphs to search for collections.\n * @param collectionUri URI of a collection.\n * @returns An array of URIs of the members of the collection.\n */\n hasCollectionMembers(graphUris, collectionUri) {\n const s = n3.DataFactory.namedNode(collectionUri);\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.skos.member, null)) {\n return true;\n }\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.skos.memberList, null)) {\n return true;\n }\n return false;\n }\n /**\n * Indicates whether a collection is an ordered collection.\n * @param graphUris URI of the graphs to search for collections.\n * @param collectionUri URI of a collection.\n * @returns `true` if the collection is an ordered collection, `false` otherwise.\n */\n isOrderedCollection(graphUris, collectionUri) {\n const s = n3.DataFactory.namedNode(collectionUri);\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.skos.OrderedCollection)) {\n return true;\n }\n return false;\n }\n /**\n * Get all broader concepts of a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept scheme.\n */\n *getBroaderConcepts(graphUris, subjectUri) {\n const yielded = new Set();\n const s = n3.DataFactory.namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.hasTopConcept, s)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.narrower, s)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.topConceptOf, null)) {\n const o = q.object;\n if (!yielded.has(o.value)) {\n yielded.add(o.value);\n yield o.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.broader, null)) {\n const o = q.object;\n if (!yielded.has(o.value)) {\n yielded.add(o.value);\n yield o.value;\n }\n }\n }\n /**\n * Indicates whether a concept has broader concepts.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n */\n hasBroaderConcepts(graphUris, subjectUri) {\n for (const _ of this.getBroaderConcepts(graphUris, subjectUri)) {\n return true;\n }\n return false;\n }\n /**\n * Get all narrower concepts of a concept or top concepts of a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept or concept scheme.\n */\n *getNarrowerConcepts(graphUris, subjectUri) {\n if (subjectUri) {\n const yielded = new Set();\n const s = n3.DataFactory.namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.hasTopConcept, null)) {\n const o = q.object;\n if (!yielded.has(o.value)) {\n yielded.add(o.value);\n yield o.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.skos.narrower, null)) {\n const o = q.object;\n if (!yielded.has(o.value)) {\n yielded.add(o.value);\n yield o.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.topConceptOf, s)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.skos.broader, s)) {\n const s = q.subject;\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n }\n else {\n yield* this.getConceptSchemes(graphUris);\n }\n }\n /**\n * Indicates whether a concept has narrower concepts.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n */\n hasNarrowerConcepts(graphUris, subjectUri) {\n for (const _ of this.getNarrowerConcepts(graphUris, subjectUri)) {\n return true;\n }\n return false;\n }\n /**\n * Indicates whether a concept is a narrower concept of another concept.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n * @param broaderUri URI of a broader concept.\n * @returns `true` if the concept is a narrower concept of the broader concept, `false` otherwise.\n */\n isNarrowerConceptOf(graphUris, subjectUri, broaderUri) {\n return this.getConceptSchemePath(graphUris, subjectUri).includes(broaderUri);\n }\n /**\n * Indicates whether a subject is a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a subject.\n * @returns `true` if the subject is a concept scheme, `false` otherwise.\n */\n isConceptScheme(graphUris, subjectUri) {\n if (subjectUri) {\n const s = n3.DataFactory.namedNode(subjectUri);\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get all broader concepts up to and including a concept scheme.\n * @param graphUris URIs of the graphs to search for concepts.\n * @param subjectUri URI of a concept.\n */\n getConceptSchemePath(graphUris, subjectUri) {\n return this._getConceptSchemePath(graphUris, subjectUri, [], new Set());\n }\n /**\n * Recursively find the first path from a given class to a root class.\n * @param subjectUri URI of a class.\n * @param path The current class path.\n * @param backtrack Set of URIs that have already been visited.\n * @returns The first path that is found from the given class to a root class.\n */\n _getConceptSchemePath(graphUris, subjectUri, path, backtrack) {\n const broaderConcepts = [...this.getBroaderConcepts(graphUris, subjectUri)];\n for (let o of broaderConcepts.filter(o => !backtrack.has(o))) {\n return this._getConceptSchemePath(graphUris, o, [...path, o], backtrack);\n }\n return path;\n }\n}\nexports.ConceptRepository = ConceptRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/concept-repository.ts?\n}");
|
|
1224
1224
|
|
|
1225
1225
|
/***/ }),
|
|
1226
1226
|
|
|
@@ -1242,7 +1242,7 @@ eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexp
|
|
|
1242
1242
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1243
1243
|
|
|
1244
1244
|
"use strict";
|
|
1245
|
-
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.IndividualRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst property_repository_1 = __webpack_require__(/*! ./property-repository */ \"./src/rdf/property-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving classes from graphs.\n */\nclass IndividualRepository extends property_repository_1.PropertyRepository {\n constructor(store) { super(store); }\n /**\n * Get all classes that have instances or all types of a specific individual.\n * @param graphUris The graph URIs to search.\n * @param subjectUri The URI of a subject for which to get the types (optional).\n * @param options Options for retrieving the individuals.\n * @returns
|
|
1245
|
+
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.IndividualRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst property_repository_1 = __webpack_require__(/*! ./property-repository */ \"./src/rdf/property-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving classes from graphs.\n */\nclass IndividualRepository extends property_repository_1.PropertyRepository {\n constructor(store) { super(store); }\n /**\n * Get all classes that have instances or all types of a specific individual.\n * @param graphUris The graph URIs to search.\n * @param subjectUri The URI of a subject for which to get the types (optional).\n * @param options Options for retrieving the individuals.\n * @returns An iterator of all individual types, or all types of a specific individual.\n */\n *getIndividualTypes(graphUris, subjectUri, options) {\n const yielded = new Set();\n const subject = subjectUri ? namedNode(subjectUri) : null;\n for (const q of this.store.matchAll(graphUris, subject, ontologies_1.rdf.type, ontologies_1.owl.NamedIndividual)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n // Note: We do not include inferred types here.\n for (const p of this.store.matchAll(graphUris, q.subject, ontologies_1.rdf.type, null, false)) {\n if (p.object.equals(ontologies_1.owl.NamedIndividual)) {\n continue;\n }\n if (!yielded.has(p.object.value)) {\n yielded.add(p.object.value);\n yield p.object.value;\n }\n }\n }\n }\n /**\n * Get all individuals in the repository.\n * @param typeUri The type of the individuals to get.\n * @param options Options for retrieving the individuals.\n * @returns An iterator of all individuals in the repository.\n */\n *getIndividuals(graphUris, typeUri, options) {\n const yielded = new Set();\n for (const q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.owl.NamedIndividual)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n if (!typeUri || this.isInstanceOfType(graphUris, q.subject.value, typeUri)) {\n if (!yielded.has(q.subject.value)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n }\n /**\n * Indicate if the subject is an instance of the type, or of one of its super types.\n * @param subjectUri URI of the subject.\n * @param typeUri URI of the type to check.\n * @returns true if the subject is an instance of the type, or of one of its super types.\n */\n isInstanceOfType(graphUris, subjectUri, typeUri) {\n const subject = namedNode(subjectUri);\n const type = namedNode(typeUri);\n for (const q of this.store.matchAll(graphUris, subject, ontologies_1.rdf.type, null)) {\n const o = q.object;\n if (o.termType != \"NamedNode\") {\n continue;\n }\n if (o.equals(type) || this.isSubClassOf(graphUris, o.value, type.value)) {\n return true;\n }\n }\n return false;\n }\n}\nexports.IndividualRepository = IndividualRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/individual-repository.ts?\n}");
|
|
1246
1246
|
|
|
1247
1247
|
/***/ }),
|
|
1248
1248
|
|
|
@@ -1308,7 +1308,7 @@ eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexp
|
|
|
1308
1308
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1309
1309
|
|
|
1310
1310
|
"use strict";
|
|
1311
|
-
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.PropertyRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst class_repository_1 = __webpack_require__(/*! ./class-repository */ \"./src/rdf/class-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving properties from graphs.\n */\nclass PropertyRepository extends class_repository_1.ClassRepository {\n constructor(store) {\n super(store);\n /**\n * The predicate used to indicate the domain of a property.\n */\n this.domainPredicate = ontologies_1.rdfs.domain;\n /**\n * The predicate used to indicate the range of a property.\n */\n this.rangePredicate = ontologies_1.rdfs.range;\n }\n /**\n * Get all properties in the repository.\n * @param options Optional options for retrieving properties.\n * @returns A list of all properties in the repository.\n */\n getProperties(graphUris, options) {\n const result = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.rdf.Property, options?.includeInferred)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n result.add(q.subject.value);\n }\n return Array.from(result);\n }\n /**\n * Get properties of a given type.\n * @param typeUri URI of a property type.\n * @param includeInferred Indicate if properties of a more specific type should be included in the result.\n * @returns A list of properties of the given type.\n */\n getRootPropertiesOfType(graphUris, typeUri, options) {\n const result = new Set();\n const type = namedNode(typeUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, type, options?.includeInferred)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n let hasSuperProperty = false;\n for (let q2 of this.store.matchAll(graphUris, q.subject, ontologies_1.rdfs.subPropertyOf, null, options?.includeInferred)) {\n // Note: We have not skipped the property so it is relevant for our result. However, if we want \n // to include referenced properties, then we include the referenced super property instead of the\n // current one.\n if (options?.includeReferenced && !this.hasSubject(graphUris, q2.object.value)) {\n // We must assume that the referenced super property is of the same type as the given type or a super type of it.\n result.add(q2.object.value);\n }\n else if (this.skip(graphUris, q2.object, options)) {\n // If the super property is skipped, then we ignore it.\n continue;\n }\n hasSuperProperty = true;\n break;\n }\n if (hasSuperProperty) {\n continue;\n }\n if (typeUri === ontologies_1.RDF.Property && options?.includeInferred === false) {\n // In the case of rdf:Property, we do not want to include properties that have a more specific type.\n const t = Array.from(this.store.matchAll(graphUris, q.subject, ontologies_1.rdf.type, null, options?.includeInferred)).map(q => q.object.value);\n if (new Set(t).size == 1) {\n result.add(q.subject.value);\n }\n }\n else {\n result.add(q.subject.value);\n }\n }\n return Array.from(result);\n }\n /**\n * Get the super properties of a given property.\n * @param subjectUri URI of a property.\n * @param options Optional options for retrieving properties.\n * @returns An array of super properties of the given property, an empty array if the property has no super properties.\n */\n getSuperProperties(graphUris, subjectUri, options) {\n const result = [];\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdfs.subPropertyOf, null, options?.includeInferred)) {\n if (this.skip(graphUris, q.object, options)) {\n continue;\n }\n result.push(q.object.value);\n }\n return result;\n }\n /**\n * Recursively find the first path from a given property to a root property.\n * @param subjectUri URI of a property.\n * @param path The current property path.\n * @param backtrack Set of URIs that have already been visited.\n * @param options Optional options for retrieving properties.\n * @returns The first path that is found from the given property to a root class.\n */\n _getRootPropertyPath(graphUris, subjectUri, path, backtrack, options) {\n const superClasses = this.getSuperProperties(graphUris, subjectUri, options);\n for (let o of superClasses.filter(o => !backtrack.has(o))) {\n return this._getRootPropertyPath(graphUris, o, [...path, o], backtrack, options);\n }\n return path;\n }\n /**\n * Get the first discovered path from a given property to a root property.\n * @param subjectUri URI of a property.\n * @param options Optional options for retrieving properties.\n * @returns A string array containing the first path that is found from the given property to a root property.\n */\n getRootPropertiesPath(graphUris, subjectUri, options) {\n return this._getRootPropertyPath(graphUris, subjectUri, [], new Set(), options);\n }\n /**\n * Indicate if there are sub properties of a given property.\n * @param subjectUri URI of a property.\n * @param options Optional options for retrieving properties.\n * @returns true if the property has sub properties, false otherwise.\n */\n hasSubProperties(graphUris, subjectUri, options) {\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subPropertyOf, o, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get the sub properties of a given property or all root properties.\n * @param subjectUri URI of a property or undefined to get all root properties.\n * @param options Optional options for retrieving properties.\n * @returns An array of sub properties of the given property, an empty array if the property has no sub properties.\n */\n getSubProperties(graphUris, subjectUri, options) {\n if (subjectUri) {\n const result = new Set();\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subPropertyOf, o, options?.includeInferred)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n result.add(q.subject.value);\n }\n return Array.from(result);\n }\n else {\n return this.getRootProperties(graphUris, options);\n }\n }\n /**\n * Get all properties from the repository that have no super properties.\n * @param options Optional options for retrieving properties.\n * @returns An array of root properties in the repository.\n */\n getRootProperties(graphUris, options) {\n const result = new Set();\n const properties = new Set(this.getProperties(graphUris, options));\n for (let p of properties) {\n let hasSuperProperty = false;\n for (let q of this.store.matchAll(graphUris, namedNode(p), ontologies_1.rdfs.subPropertyOf, null, options?.includeInferred)) {\n const includeReferenced = options?.includeReferenced ?? false;\n const skip = this.skip(graphUris, q.object, options);\n // Do not skip the super property if it is only referenced and the includeReferenced option is set.\n if (q.object.termType != \"NamedNode\" || skip && (!includeReferenced || includeReferenced && this.hasSubject(graphUris, q.object.value))) {\n continue;\n }\n hasSuperProperty = true;\n // If we have a super property that is not in the list of properties and not excluded by the options, we add it to the result.\n if (!properties.has(q.object.value)) {\n result.add(q.object.value);\n }\n break;\n }\n if (!hasSuperProperty) {\n result.add(p);\n }\n }\n return Array.from(result);\n }\n /**\n * Indicate if there is an equivalent property of a given property.\n * @param propertyUri URI of a property.\n * @returns true if the property has an equivalent property, false otherwise.\n */\n hasEquivalentProperty(graphUris, propertyUri) {\n const s = namedNode(propertyUri);\n // The OWL resoner will assert the equivalent class relationship in both directions.\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentProperty, null)) {\n return true;\n }\n return false;\n }\n /**\n * Get the domain of a given property.\n * @param propertyUri URI of a property.\n * @returns The URI of the domain of the given property. If no domain is specified, rdfs:Resource is returned.\n */\n getDomain(graphUris, propertyUri) {\n const s = namedNode(propertyUri);\n for (let q of this.store.matchAll(graphUris, s, this.domainPredicate, null)) {\n return q.object.value;\n }\n return ontologies_1.rdfs.Resource.value;\n }\n /**\n * Get the range of a given property.\n * @param propertyUri URI of a property.\n * @returns The URI of the range of the given property. If no range is specified, `undefined` is returned.\n */\n getRange(graphUris, propertyUri) {\n const s = namedNode(propertyUri);\n for (let q of this.store.matchAll(graphUris, s, this.rangePredicate, null)) {\n return q.object.value;\n }\n return undefined;\n }\n /**\n * Get all asserted and inferred property types.\n * @param graphUris The URI of the graph or an array of graphs to search for property types.\n * @param options Optional options for retrieving properties.\n * @returns A list of all property types in the repository.\n */\n getPropertyTypes(graphUris, options) {\n const result = new Set();\n const properties = this.getProperties(graphUris, options).map(p => namedNode(p));\n for (let p of properties) {\n const types = new Set(Array.from(this.store.matchAll(graphUris, p, ontologies_1.rdf.type, null, false)).map(t => t.object.value));\n if (types.size > 0) {\n for (let t of types) {\n // Do not assert rdf:Property for properties that have multiple types.\n if (t !== ontologies_1.RDF.Property || types.size == 1) {\n result.add(t);\n }\n }\n }\n else {\n // If there are no asserted types, we need to infer rdf:Property.\n result.add(ontologies_1.RDF.Property);\n }\n }\n return Array.from(result);\n }\n}\nexports.PropertyRepository = PropertyRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/property-repository.ts?\n}");
|
|
1311
|
+
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.PropertyRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst class_repository_1 = __webpack_require__(/*! ./class-repository */ \"./src/rdf/class-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving properties from graphs.\n */\nclass PropertyRepository extends class_repository_1.ClassRepository {\n constructor(store) {\n super(store);\n /**\n * The predicate used to indicate the domain of a property.\n */\n this.domainPredicate = ontologies_1.rdfs.domain;\n /**\n * The predicate used to indicate the range of a property.\n */\n this.rangePredicate = ontologies_1.rdfs.range;\n }\n /**\n * Get all properties in the repository.\n * @param options Optional options for retrieving properties.\n * @returns A list of all properties in the repository.\n */\n *getProperties(graphUris, options) {\n const yielded = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.rdf.Property, options?.includeInferred)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n if (!yielded.has(q.subject.value)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n /**\n * Get properties of a given type.\n * @param typeUri URI of a property type.\n * @param includeInferred Indicate if properties of a more specific type should be included in the result.\n * @returns An iterator of properties of the given type.\n */\n *getRootPropertiesOfType(graphUris, typeUri, options) {\n const yielded = new Set();\n const type = namedNode(typeUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, type, options?.includeInferred)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n let hasSuperProperty = false;\n let referencedSuperProperty = null;\n for (let q2 of this.store.matchAll(graphUris, q.subject, ontologies_1.rdfs.subPropertyOf, null, options?.includeInferred)) {\n // Note: We have not skipped the property so it is relevant for our result. However, if we want \n // to include referenced properties, then we include the referenced super property instead of the\n // current one.\n if (options?.includeReferenced && !this.hasSubject(graphUris, q2.object.value)) {\n // We must assume that the referenced super property is of the same type as the given type or a super type of it.\n referencedSuperProperty = q2.object.value;\n }\n else if (this.skip(graphUris, q2.object, options)) {\n // If the super property is skipped, then we ignore it.\n continue;\n }\n hasSuperProperty = true;\n break;\n }\n // Yield referenced super property if applicable\n if (referencedSuperProperty && !yielded.has(referencedSuperProperty)) {\n yielded.add(referencedSuperProperty);\n yield referencedSuperProperty;\n }\n if (hasSuperProperty) {\n continue;\n }\n let shouldYield = false;\n if (typeUri === ontologies_1.RDF.Property && options?.includeInferred === false) {\n // In the case of rdf:Property, we do not want to include properties that have a more specific type.\n const t = Array.from(this.store.matchAll(graphUris, q.subject, ontologies_1.rdf.type, null, options?.includeInferred)).map(q => q.object.value);\n if (new Set(t).size == 1) {\n shouldYield = true;\n }\n }\n else {\n shouldYield = true;\n }\n if (shouldYield && !yielded.has(q.subject.value)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n /**\n * Get the super properties of a given property.\n * @param subjectUri URI of a property.\n * @param options Optional options for retrieving properties.\n * @returns An array of super properties of the given property, an empty array if the property has no super properties.\n */\n *getSuperProperties(graphUris, subjectUri, options) {\n const yielded = new Set();\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdfs.subPropertyOf, null, options?.includeInferred)) {\n if (this.skip(graphUris, q.object, options)) {\n continue;\n }\n if (!yielded.has(q.object.value)) {\n yield q.object.value;\n }\n yielded.add(q.object.value);\n }\n }\n /**\n * Recursively find the first path from a given property to a root property.\n * @param subjectUri URI of a property.\n * @param path The current property path.\n * @param backtrack Set of URIs that have already been visited.\n * @param options Optional options for retrieving properties.\n * @returns The first path that is found from the given property to a root class.\n */\n _getRootPropertyPath(graphUris, subjectUri, path, backtrack, options) {\n const superClasses = [...this.getSuperProperties(graphUris, subjectUri, options)];\n for (let o of superClasses.filter(o => !backtrack.has(o))) {\n backtrack.add(o);\n return this._getRootPropertyPath(graphUris, o, [...path, o], backtrack, options);\n }\n return path;\n }\n /**\n * Get the first discovered path from a given property to a root property.\n * @param subjectUri URI of a property.\n * @param options Optional options for retrieving properties.\n * @returns A string array containing the first path that is found from the given property to a root property.\n */\n getRootPropertiesPath(graphUris, subjectUri, options) {\n return this._getRootPropertyPath(graphUris, subjectUri, [], new Set(), options);\n }\n /**\n * Indicate if a given property is direct or indirect (inferred) sub property of another property.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri URI of the sub property.\n * @param classUri URI of the super property.\n * @param options Optional query parameters.\n * @returns `true` if the property is a sub property of the other property, false otherwise.\n */\n isSubPropertyOf(graphUris, subjectUri, classUri, options) {\n return this.getRootPropertiesPath(graphUris, subjectUri, options).includes(classUri);\n }\n /**\n * Indicate if there are sub properties of a given property.\n * @param subjectUri URI of a property.\n * @param options Optional options for retrieving properties.\n * @returns true if the property has sub properties, false otherwise.\n */\n hasSubProperties(graphUris, subjectUri, options) {\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subPropertyOf, o, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Get the sub properties of a given property or all root properties.\n * @param subjectUri URI of a property or undefined to get all root properties.\n * @param options Optional options for retrieving properties.\n * @returns An array of sub properties of the given property, an empty array if the property has no sub properties.\n */\n *getSubProperties(graphUris, subjectUri, options) {\n if (subjectUri) {\n const yielded = new Set();\n const o = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.subPropertyOf, o, options?.includeInferred)) {\n if (this.skip(graphUris, q.subject, options)) {\n continue;\n }\n if (!yielded.has(q.subject.value)) {\n yield q.subject.value;\n }\n yielded.add(q.subject.value);\n }\n }\n else {\n yield* this.getRootProperties(graphUris, options);\n }\n }\n /**\n * Get all properties from the repository that have no super properties.\n * @param options Optional options for retrieving properties.\n * @returns An iterator of root properties in the repository.\n */\n *getRootProperties(graphUris, options) {\n const yielded = new Set();\n const properties = new Set(this.getProperties(graphUris, options));\n for (let p of properties) {\n let hasSuperProperty = false;\n for (let q of this.store.matchAll(graphUris, namedNode(p), ontologies_1.rdfs.subPropertyOf, null, options?.includeInferred)) {\n const includeReferenced = options?.includeReferenced ?? false;\n const skip = this.skip(graphUris, q.object, options);\n // Do not skip the super property if it is only referenced and the includeReferenced option is set.\n if (q.object.termType != \"NamedNode\" || skip && (!includeReferenced || includeReferenced && this.hasSubject(graphUris, q.object.value))) {\n continue;\n }\n // We have at least one super property that is not the property itself.\n hasSuperProperty = q.object.value != q.subject.value;\n // If we have a super property that is not in the list of properties and not excluded by the options, we add it to the result.\n if (!properties.has(q.object.value) && !yielded.has(q.object.value)) {\n yielded.add(q.object.value);\n yield q.object.value;\n }\n break;\n }\n if (!hasSuperProperty && !yielded.has(p)) {\n yielded.add(p);\n yield p;\n }\n }\n }\n /**\n * Indicate if there is an equivalent property of a given property.\n * @param propertyUri URI of a property.\n * @returns true if the property has an equivalent property, false otherwise.\n */\n hasEquivalentProperty(graphUris, propertyUri) {\n const s = namedNode(propertyUri);\n // The OWL resoner will assert the equivalent class relationship in both directions.\n for (let _ of this.store.matchAll(graphUris, s, ontologies_1.owl.equivalentProperty, null)) {\n return true;\n }\n return false;\n }\n /**\n * Get the domain of a given property.\n * @param propertyUri URI of a property.\n * @returns The URI of the domain of the given property. If no domain is specified, rdfs:Resource is returned.\n */\n getDomain(graphUris, propertyUri) {\n const s = namedNode(propertyUri);\n for (let q of this.store.matchAll(graphUris, s, this.domainPredicate, null)) {\n return q.object.value;\n }\n return ontologies_1.rdfs.Resource.value;\n }\n /**\n * Get the range of a given property.\n * @param propertyUri URI of a property.\n * @returns The URI of the range of the given property. If no range is specified, `undefined` is returned.\n */\n getRange(graphUris, propertyUri) {\n const s = namedNode(propertyUri);\n for (let q of this.store.matchAll(graphUris, s, this.rangePredicate, null)) {\n return q.object.value;\n }\n return undefined;\n }\n /**\n * Get all asserted and inferred property types.\n * @param graphUris The URI of the graph or an array of graphs to search for property types.\n * @param options Optional options for retrieving properties.\n * @returns An iterator of all property types in the repository.\n */\n *getPropertyTypes(graphUris, options) {\n const yielded = new Set();\n for (let property of this.getProperties(graphUris, options)) {\n const p = namedNode(property);\n const types = new Set(Array.from(this.store.matchAll(graphUris, p, ontologies_1.rdf.type, null, false)).map(t => t.object.value));\n if (types.size > 0) {\n for (let t of types) {\n // Do not assert rdf:Property for properties that have multiple types.\n if ((t !== ontologies_1.RDF.Property || types.size == 1) && !yielded.has(t)) {\n yielded.add(t);\n yield t;\n }\n }\n }\n else {\n // If there are no asserted types, we need to infer rdf:Property.\n if (!yielded.has(ontologies_1.RDF.Property)) {\n yielded.add(ontologies_1.RDF.Property);\n yield ontologies_1.RDF.Property;\n }\n }\n }\n }\n}\nexports.PropertyRepository = PropertyRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/property-repository.ts?\n}");
|
|
1312
1312
|
|
|
1313
1313
|
/***/ }),
|
|
1314
1314
|
|
|
@@ -1385,7 +1385,7 @@ eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexp
|
|
|
1385
1385
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1386
1386
|
|
|
1387
1387
|
"use strict";
|
|
1388
|
-
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ShapeRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst individual_repository_1 = __webpack_require__(/*! ./individual-repository */ \"./src/rdf/individual-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving SHACL shapes from graphs.\n */\nclass ShapeRepository extends individual_repository_1.IndividualRepository {\n constructor(store) { super(store); }\n /**\n * Get all shapes in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all shapes in the repository.\n */\n getShapes(graphUris, subjectUri, options) {\n const result = new Set();\n if (!subjectUri) {\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.Shape, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n }\n }\n else {\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.sh.Shape, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.targetClass, s, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, s, options?.includeInferred)) {\n if (!this.skip(graphUris, q.subject, options)) {\n result.add(q.subject.value);\n }\n }\n }\n return Array.from(result);\n }\n /**\n * Get all shape types in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all shape types in the repository.\n */\n getShapeTypes(graphUris, options) {\n const result = new Set();\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.NodeShape)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n result.add(ontologies_1.SH.NodeShape);\n break;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.PropertyShape)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n result.add(ontologies_1.SH.PropertyShape);\n break;\n }\n }\n return Array.from(result);\n }\n /**\n * Get all validator types in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all shape types in the repository.\n */\n getValidatorTypes(graphUris, options) {\n const result = new Set();\n // Get all validators in the repository, including the inferred ones.\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.Validator, options?.includeInferred)) {\n result.add(ontologies_1.SH.Validator);\n }\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.JSValidator, false)) {\n result.add(ontologies_1.SH.JSValidator);\n }\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.SPARQLAskValidator, false)) {\n result.add(ontologies_1.SH.SPARQLAskValidator);\n }\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.SPARQLSelectValidator, false)) {\n result.add(ontologies_1.SH.SPARQLSelectValidator);\n }\n return Array.from(result);\n }\n /**\n * Get all target classes, nodes or properties of a given shape in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param shape The URI or blank id of the shape.\n * @param options Optional query parameters.\n * @returns A list of all targeted reesources in the repository.\n */\n getShapeTargets(graphUris, shape, options) {\n const result = new Set();\n // Add the shape definition itself if it is a class.\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.rdf.type, ontologies_1.rdfs.Class, true)) {\n result.add(q.subject.value);\n }\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.sh.targetClass, null, options?.includeInferred)) {\n result.add(q.object.value);\n }\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.sh.targetNode, null, options?.includeInferred)) {\n result.add(q.object.value);\n }\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.sh.path, null, options?.includeInferred)) {\n result.add(q.object.value);\n }\n return Array.from(result);\n }\n /**\n * Indicate if there are shapes for a subject in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns `true` if there are shapes for the subject, `false` otherwise.\n */\n hasShapes(graphUris, subjectUri, options) {\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.sh.Shape)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n return true;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.targetClass, s)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n return true;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, s)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n return true;\n }\n }\n return false;\n }\n /**\n * Indicate if there validators defined in the vocabulary.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all validators in the repository.\n */\n hasValidators(graphUris, options) {\n return this.hasSubjectsOfType(graphUris, ontologies_1.SH.Validator, options);\n }\n /**\n * Get all validators in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all validators in the repository.\n */\n getValidators(graphUris, options) {\n return this.getSubjectsOfType(graphUris, ontologies_1.SH.Validator, options);\n }\n /**\n * Indicate if there are rules in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns `true` if there are rules for the subject, `false` otherwise.\n */\n hasRules(graphUris, options) {\n return this.hasSubjectsOfType(graphUris, ontologies_1.SH.Rule, options);\n }\n /**\n * Get all rules in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all rules in the repository.\n */\n getRules(graphUris, options) {\n return this.getSubjectsOfType(graphUris, ontologies_1.SH.Rule, options);\n }\n /**\n * Get the SHACL datatype of a given property.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns A datatype URI on success, `xsd:anyURI` otherwise.\n */\n getDatatype(graphUris, subjectUri, options) {\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, namedNode(subjectUri), options?.includeInferred)) {\n for (let x of this.store.matchAll(graphUris, q.subject, ontologies_1.sh.datatype, null, options?.includeInferred)) {\n return x.object.value;\n }\n }\n }\n /**\n * Get the SHACL cardinality constraints of a given property.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns An object with the minimum and maximum cardinalities; values are `-1` if not found.\n */\n getCardinalites(graphUris, subjectUri, options) {\n let minCount = -1;\n let maxCount = -1;\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, namedNode(subjectUri), options?.includeInferred)) {\n for (let x of this.store.matchAll(graphUris, q.subject, ontologies_1.sh.minCount, null, options?.includeInferred)) {\n minCount = parseInt(x.object.value);\n break;\n }\n for (let x of this.store.matchAll(graphUris, q.subject, ontologies_1.sh.maxCount, null, options?.includeInferred)) {\n maxCount = parseInt(x.object.value);\n break;\n }\n }\n return { minCount, maxCount };\n }\n /**\n * Get the RDF property path representation of the given SHACL property path. This method parses the SHACL property path and\n * returns the RDF property path as a combination of nodes and strings.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subject The URI or blank id of the node referred to by sh:path.\n * @param options Optional query parameters.\n * @returns A flattened list of all path components, either as URIs or as strings.\n */\n getPropertyPathTokens(graphUris, subject) {\n const visitedNodes = new Set();\n /**\n * Parse the given subject node and return the path components.\n * @param subject The currently parsed focus node.\n * @param level The nesting level of the current path.\n * @param separator The separator to use to separate path components.\n * @param i The index of the current node in a list.\n * @returns The sub path of the current node.\n */\n const parse = (subject, level, separator = '/', i = 0) => {\n if (visitedNodes.has(subject.value)) {\n return [];\n }\n visitedNodes.add(subject.value);\n if (subject.termType === 'NamedNode') {\n // If we have a terminal node, we add it to the path.\n return [subject];\n }\n else {\n // Determine if we are looking at an item in a collection.\n const first = this.store.matchAll(graphUris, subject, ontologies_1.rdf.first, null, false).next().value;\n if (first) {\n // Note: We increase the nesting level as nested nodes in paths need to be wrapped in parentheses.\n const path = parse(first.object, level + 1);\n const rest = this.store.matchAll(graphUris, subject, ontologies_1.rdf.rest, null, false).next().value;\n if (rest && rest.object.value !== ontologies_1.rdf.nil.id) {\n // The first item of the list sees the complete recursively parsed sub path.\n const tail = parse(rest.object, level, separator, i + 1);\n // If there is no tail we return the current item's path.\n if (tail.length === 0) {\n return path;\n }\n // For nested paths, we wrap the path in parentheses if it contains more than one item.\n if (i === 0 && level > 0) {\n return ['(', ...path, separator, ...tail, ')'];\n }\n else {\n return [...path, separator, ...tail];\n }\n }\n return path;\n }\n else {\n // Blank nodes that are not lists contain SHACL path predicates.\n for (let q of this.store.matchAll(graphUris, subject, null, null, false)) {\n switch (q.predicate.value) {\n case ontologies_1.sh.inversePath.id: {\n return ['^', ...parse(q.object, level)];\n }\n case ontologies_1.sh.zeroOrOnePath.id: {\n return [...parse(q.object, level), '?'];\n }\n case ontologies_1.sh.zeroOrMorePath.id: {\n return [...parse(q.object, level), '*'];\n }\n case ontologies_1.sh.oneOrMorePath.id: {\n return [...parse(q.object, level), '+'];\n }\n case ontologies_1.sh.alternativePath.id: {\n return parse(q.object, level, '|');\n }\n default:\n throw new Error(`Unsupported path predicate: ${q.predicate.value}`);\n }\n }\n throw new Error(`Unsupported path subject: ${subject}`);\n }\n }\n };\n return parse(subject, 0);\n }\n}\nexports.ShapeRepository = ShapeRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/shape-repository.ts?\n}");
|
|
1388
|
+
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ShapeRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst individual_repository_1 = __webpack_require__(/*! ./individual-repository */ \"./src/rdf/individual-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving SHACL shapes from graphs.\n */\nclass ShapeRepository extends individual_repository_1.IndividualRepository {\n constructor(store) { super(store); }\n /**\n * Get all shapes in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns An iterable of all shapes in the repository.\n */\n *getShapes(graphUris, subjectUri, options) {\n const yielded = new Set();\n if (!subjectUri) {\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.Shape, options?.includeInferred)) {\n if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n else {\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.sh.Shape, options?.includeInferred)) {\n if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.targetClass, s, options?.includeInferred)) {\n if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, s, options?.includeInferred)) {\n if (!yielded.has(q.subject.value) && !this.skip(graphUris, q.subject, options)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n }\n }\n /**\n * Get all shape types in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all shape types in the repository.\n */\n *getShapeTypes(graphUris, options) {\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.NodeShape)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n yield ontologies_1.SH.NodeShape;\n break;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.PropertyShape)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n yield ontologies_1.SH.PropertyShape;\n break;\n }\n }\n }\n /**\n * Get all validator types in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns An iterable of all shape types in the repository.\n */\n *getValidatorTypes(graphUris, options) {\n // Get all validators in the repository, including the inferred ones.\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.Validator, options?.includeInferred)) {\n yield ontologies_1.SH.Validator;\n }\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.JSValidator, false)) {\n yield ontologies_1.SH.JSValidator;\n }\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.SPARQLAskValidator, false)) {\n yield ontologies_1.SH.SPARQLAskValidator;\n }\n if (this.store.any(graphUris, null, ontologies_1.rdf.type, ontologies_1.sh.SPARQLSelectValidator, false)) {\n yield ontologies_1.SH.SPARQLSelectValidator;\n }\n }\n /**\n * Get all target classes, nodes or properties of a given shape in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param shape The URI or blank id of the shape.\n * @param options Optional query parameters.\n * @returns An iterable of all targeted resources in the repository.\n */\n *getShapeTargets(graphUris, shape, options) {\n const yielded = new Set();\n // Add the shape definition itself if it is a class.\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.rdf.type, ontologies_1.rdfs.Class, true)) {\n if (!yielded.has(q.subject.value)) {\n yielded.add(q.subject.value);\n yield q.subject.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.sh.targetClass, null, options?.includeInferred)) {\n if (!yielded.has(q.object.value)) {\n yielded.add(q.object.value);\n yield q.object.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.sh.targetNode, null, options?.includeInferred)) {\n if (!yielded.has(q.object.value)) {\n yielded.add(q.object.value);\n yield q.object.value;\n }\n }\n for (let q of this.store.matchAll(graphUris, shape, ontologies_1.sh.path, null, options?.includeInferred)) {\n if (!yielded.has(q.object.value)) {\n yielded.add(q.object.value);\n yield q.object.value;\n }\n }\n }\n /**\n * Indicate if there are shapes for a subject in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns `true` if there are shapes for the subject, `false` otherwise.\n */\n hasShapes(graphUris, subjectUri, options) {\n const s = namedNode(subjectUri);\n for (let q of this.store.matchAll(graphUris, s, ontologies_1.rdf.type, ontologies_1.sh.Shape)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n return true;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.targetClass, s)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n return true;\n }\n }\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, s)) {\n if (!this.skip(graphUris, q.subject, options, { includeBlankNodes: true })) {\n return true;\n }\n }\n return false;\n }\n /**\n * Indicate if there validators defined in the vocabulary.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all validators in the repository.\n */\n hasValidators(graphUris, options) {\n return this.hasSubjectsOfType(graphUris, ontologies_1.SH.Validator, options);\n }\n /**\n * Get all validators in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all validators in the repository.\n */\n *getValidators(graphUris, options) {\n yield* this.getSubjectsOfType(graphUris, ontologies_1.SH.Validator, options);\n }\n /**\n * Indicate if there are rules in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns `true` if there are rules for the subject, `false` otherwise.\n */\n hasRules(graphUris, options) {\n return this.hasSubjectsOfType(graphUris, ontologies_1.SH.Rule, options);\n }\n /**\n * Get all rules in the repository.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param options Optional query parameters.\n * @returns A list of all rules in the repository.\n */\n *getRules(graphUris, options) {\n yield* this.getSubjectsOfType(graphUris, ontologies_1.SH.Rule, options);\n }\n /**\n * Get the SHACL datatype of a given property.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns A datatype URI on success, `xsd:anyURI` otherwise.\n */\n getDatatype(graphUris, subjectUri, options) {\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, namedNode(subjectUri), options?.includeInferred)) {\n for (let x of this.store.matchAll(graphUris, q.subject, ontologies_1.sh.datatype, null, options?.includeInferred)) {\n return x.object.value;\n }\n }\n }\n /**\n * Get the SHACL cardinality constraints of a given property.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subjectUri The URI of the subject.\n * @param options Optional query parameters.\n * @returns An object with the minimum and maximum cardinalities; values are `-1` if not found.\n */\n getCardinalites(graphUris, subjectUri, options) {\n let minCount = -1;\n let maxCount = -1;\n for (let q of this.store.matchAll(graphUris, null, ontologies_1.sh.path, namedNode(subjectUri), options?.includeInferred)) {\n for (let x of this.store.matchAll(graphUris, q.subject, ontologies_1.sh.minCount, null, options?.includeInferred)) {\n minCount = parseInt(x.object.value);\n break;\n }\n for (let x of this.store.matchAll(graphUris, q.subject, ontologies_1.sh.maxCount, null, options?.includeInferred)) {\n maxCount = parseInt(x.object.value);\n break;\n }\n }\n return { minCount, maxCount };\n }\n /**\n * Get the RDF property path representation of the given SHACL property path. This method parses the SHACL property path and\n * returns the RDF property path as a combination of nodes and strings.\n * @param graphUris URIs of the graphs to search, `undefined` for the default graph.\n * @param subject The URI or blank id of the node referred to by sh:path.\n * @param options Optional query parameters.\n * @returns A flattened list of all path components, either as URIs or as strings.\n */\n getPropertyPathTokens(graphUris, subject) {\n const visitedNodes = new Set();\n /**\n * Parse the given subject node and return the path components.\n * @param subject The currently parsed focus node.\n * @param level The nesting level of the current path.\n * @param separator The separator to use to separate path components.\n * @param i The index of the current node in a list.\n * @returns The sub path of the current node.\n */\n const parse = (subject, level, separator = '/', i = 0) => {\n if (visitedNodes.has(subject.value)) {\n return [];\n }\n visitedNodes.add(subject.value);\n if (subject.termType === 'NamedNode') {\n // If we have a terminal node, we add it to the path.\n return [subject];\n }\n else {\n // Determine if we are looking at an item in a collection.\n const first = this.store.matchAll(graphUris, subject, ontologies_1.rdf.first, null, false).next().value;\n if (first) {\n // Note: We increase the nesting level as nested nodes in paths need to be wrapped in parentheses.\n const path = parse(first.object, level + 1);\n const rest = this.store.matchAll(graphUris, subject, ontologies_1.rdf.rest, null, false).next().value;\n if (rest && rest.object.value !== ontologies_1.rdf.nil.id) {\n // The first item of the list sees the complete recursively parsed sub path.\n const tail = parse(rest.object, level, separator, i + 1);\n // If there is no tail we return the current item's path.\n if (tail.length === 0) {\n return path;\n }\n // For nested paths, we wrap the path in parentheses if it contains more than one item.\n if (i === 0 && level > 0) {\n return ['(', ...path, separator, ...tail, ')'];\n }\n else {\n return [...path, separator, ...tail];\n }\n }\n return path;\n }\n else {\n // Blank nodes that are not lists contain SHACL path predicates.\n for (let q of this.store.matchAll(graphUris, subject, null, null, false)) {\n switch (q.predicate.value) {\n case ontologies_1.sh.inversePath.id: {\n return ['^', ...parse(q.object, level)];\n }\n case ontologies_1.sh.zeroOrOnePath.id: {\n return [...parse(q.object, level), '?'];\n }\n case ontologies_1.sh.zeroOrMorePath.id: {\n return [...parse(q.object, level), '*'];\n }\n case ontologies_1.sh.oneOrMorePath.id: {\n return [...parse(q.object, level), '+'];\n }\n case ontologies_1.sh.alternativePath.id: {\n return parse(q.object, level, '|');\n }\n default:\n throw new Error(`Unsupported path predicate: ${q.predicate.value}`);\n }\n }\n throw new Error(`Unsupported path subject: ${subject}`);\n }\n }\n };\n return parse(subject, 0);\n }\n}\nexports.ShapeRepository = ShapeRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/shape-repository.ts?\n}");
|
|
1389
1389
|
|
|
1390
1390
|
/***/ }),
|
|
1391
1391
|
|
|
@@ -1418,7 +1418,7 @@ eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexp
|
|
|
1418
1418
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1419
1419
|
|
|
1420
1420
|
"use strict";
|
|
1421
|
-
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.VocabularyRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst uri_1 = __webpack_require__(/*! ./uri */ \"./src/rdf/uri.ts\");\nconst shape_repository_1 = __webpack_require__(/*! ./shape-repository */ \"./src/rdf/shape-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving ontologies and ontology concepts from graphs.\n */\nclass VocabularyRepository extends shape_repository_1.ShapeRepository {\n /**\n * Get all concept schemes in the repository.\n * @param graphUris URIs of the graphs to search.\n * @returns
|
|
1421
|
+
eval("{\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.VocabularyRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst uri_1 = __webpack_require__(/*! ./uri */ \"./src/rdf/uri.ts\");\nconst shape_repository_1 = __webpack_require__(/*! ./shape-repository */ \"./src/rdf/shape-repository.ts\");\nconst { namedNode } = n3.DataFactory;\n/**\n * A repository for retrieving ontologies and ontology concepts from graphs.\n */\nclass VocabularyRepository extends shape_repository_1.ShapeRepository {\n /**\n * Get all concept schemes in the repository.\n * @param graphUris URIs of the graphs to search.\n * @returns An iterator of all concept schemes in the repository.\n */\n *getConceptSchemes(graphUris) {\n const yielded = new Set();\n for (const q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme)) {\n const s = q.subject;\n if (s.termType != \"NamedNode\") {\n continue;\n }\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n }\n /**\n * Indicates whether the repository contains any concept schemes.\n * @param graphUris URIs of the graphs to search.\n * @returns `true` if the repository contains any concept schemes, `false` otherwise.\n */\n hasConceptSchemes(graphUris) {\n for (const _ of this.getConceptSchemes(graphUris)) {\n return true;\n }\n return false;\n }\n /**\n * Get all ontologies in the repository.\n * @param graphUris URIs of the graphs to search.\n * @returns An iterator of all ontologies in the repository.\n */\n *getOntologies(graphUris) {\n const yielded = new Set();\n for (const q of this.store.matchAll(graphUris, null, ontologies_1.rdf.type, ontologies_1.owl.Ontology)) {\n const s = q.subject;\n if (s.termType != \"NamedNode\") {\n continue;\n }\n if (!yielded.has(s.value)) {\n yielded.add(s.value);\n yield s.value;\n }\n }\n }\n /**\n * Indicates whether the repository contains any ontology headers.\n * @param graphUris URIs of the graphs to search.\n * @returns `true` if the repository contains any ontology headers, `false` otherwise.\n */\n hasOntologies(graphUris) {\n for (const _ of this.getOntologies(graphUris)) {\n return true;\n }\n return false;\n }\n /**\n * Get the version (owl:versionInfo) of an ontology. If the version is a date, it is returned as a string in the format \"YYYY-MM-DD\".\n * @param graphUris URIs of the graphs to search.\n * @param ontologyUri URI of the ontology.\n * @returns The version of the ontology, or undefined if it is not found.\n */\n getOntologyVersionInfo(graphUris, ontologyUri) {\n const s = namedNode(ontologyUri);\n for (const q of this.store.matchAll(graphUris, s, ontologies_1.owl.versionInfo, null)) {\n // If the version is a date, return it in the format \"YYYY-MM-DD\".\n const match = q.object.value.match(/(\\d{4}[\\/-]\\d{2}[\\/-]\\d{2})/);\n if (match && match.length > 1) {\n return new Date(match[1]).toISOString().substring(0, 10);\n }\n else {\n return q.object.value;\n }\n }\n }\n /**\n * Get the sources of definitions for a given graph. These are ontology definitions\n * or the objects of `rdfs:isDefinedBy` triples. If the rdfs:isDefinedBy object can be\n * matched with an ontology definition, the ontology URI is returned.\n * @param graphUris URIs of the graphs to search.\n * @returns An iterator of sources of definitions for the given graph.\n */\n *getDefinitionSources(graphUris, includeOntologies = false) {\n const yielded = new Set();\n // Load all ontologies in the graph in a normalized form.\n const ontologies = {};\n // Store the normalized versions of the ontology URI so that we can detect \n // equality even if different namespace seperators ('#' and '/') are used.\n for (let o of this.getOntologies(graphUris)) {\n const uri = uri_1.Uri.getNormalizedUri(o);\n ontologies[uri] = o;\n }\n for (const q of this.store.matchAll(graphUris, null, ontologies_1.rdfs.isDefinedBy, null)) {\n const s = q.subject;\n const o = q.object;\n if (s.termType != \"NamedNode\" || o.termType != \"NamedNode\") {\n continue;\n }\n // Do not include ontologies in the list of sources. However, if there are other\n // terms defined by the object it will be included by subsequent iterations.\n const s_ = uri_1.Uri.getNormalizedUri(s.value);\n const o_ = uri_1.Uri.getNormalizedUri(o.value);\n let isOntology = s_ in ontologies;\n if (!isOntology || includeOntologies) {\n let sourceValue;\n if (o_ in ontologies) {\n sourceValue = ontologies[o_];\n }\n else {\n sourceValue = o.value;\n }\n if (!yielded.has(sourceValue)) {\n yielded.add(sourceValue);\n yield sourceValue;\n }\n }\n }\n }\n}\nexports.VocabularyRepository = VocabularyRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/vocabulary-repository.ts?\n}");
|
|
1422
1422
|
|
|
1423
1423
|
/***/ })
|
|
1424
1424
|
|
|
@@ -10,23 +10,23 @@ export declare class ClassRepository extends ConceptRepository {
|
|
|
10
10
|
* Get all classes in the repository.
|
|
11
11
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
12
12
|
* @param options Optional query parameters.
|
|
13
|
-
* @returns
|
|
13
|
+
* @returns An iterator of all classes in the repository.
|
|
14
14
|
*/
|
|
15
|
-
getClasses(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): string
|
|
15
|
+
getClasses(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
16
16
|
/**
|
|
17
17
|
* Get the super classes of a given class.
|
|
18
18
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
19
19
|
* @param subjectUri URI of a class.
|
|
20
20
|
* @param options Optional query parameters.
|
|
21
|
-
* @returns An
|
|
21
|
+
* @returns An iterator of super classes of the given class.
|
|
22
22
|
*/
|
|
23
|
-
getSuperClasses(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): string
|
|
23
|
+
getSuperClasses(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Get the first discovered path from a given class to a root class.
|
|
26
26
|
* @param subjectUri URI of a class.
|
|
27
|
-
* @returns
|
|
27
|
+
* @returns An iterator containing the first path that is found from the given class to a root class.
|
|
28
28
|
*/
|
|
29
|
-
getRootClassPath(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): string
|
|
29
|
+
getRootClassPath(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
30
30
|
/**
|
|
31
31
|
* Recursively find the first path from a given class to a root class.
|
|
32
32
|
* @param subjectUri URI of a class.
|
|
@@ -44,9 +44,9 @@ export declare class ClassRepository extends ConceptRepository {
|
|
|
44
44
|
/**
|
|
45
45
|
* Get the sub classes of a given class or all root classes.
|
|
46
46
|
* @param subjectUri URI of a class or undefined to get all root classes.
|
|
47
|
-
* @returns An
|
|
47
|
+
* @returns An iterator of sub classes of the given class, or root classes if no subject is provided.
|
|
48
48
|
*/
|
|
49
|
-
getSubClasses(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): string
|
|
49
|
+
getSubClasses(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
50
50
|
/**
|
|
51
51
|
* Recursively traverse all sub classes of a given class and invoke a callback.
|
|
52
52
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
@@ -62,9 +62,17 @@ export declare class ClassRepository extends ConceptRepository {
|
|
|
62
62
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
63
63
|
* @param subjectUri URI of a class.
|
|
64
64
|
* @param options Optional query parameters.
|
|
65
|
-
* @returns An
|
|
65
|
+
* @returns An iterator of all sub classes of the given class.
|
|
66
66
|
*/
|
|
67
|
-
getAllSubClasses(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): string
|
|
67
|
+
getAllSubClasses(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Recursively traverse all sub classes of a given class and yield them.
|
|
70
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
71
|
+
* @param superClass The super class to start the traversal from.
|
|
72
|
+
* @param options Optional query parameters.
|
|
73
|
+
* @param visited A set of visited URIs.
|
|
74
|
+
*/
|
|
75
|
+
private _traverseSubClassesGenerator;
|
|
68
76
|
/**
|
|
69
77
|
* Indicate if there are instances of a given class or any of its sub classes.
|
|
70
78
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
@@ -78,9 +86,9 @@ export declare class ClassRepository extends ConceptRepository {
|
|
|
78
86
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
79
87
|
* @param typeUri URI of the class.
|
|
80
88
|
* @param options Optional query parameters.
|
|
81
|
-
* @returns
|
|
89
|
+
* @returns An iterator of all subjects of the given class.
|
|
82
90
|
*/
|
|
83
|
-
getSubjectsOfType(graphUris: string | string[] | undefined, typeUri: string, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): string
|
|
91
|
+
getSubjectsOfType(graphUris: string | string[] | undefined, typeUri: string, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): IterableIterator<string>;
|
|
84
92
|
/**
|
|
85
93
|
* Indicate if a given class is direct or indirect (inferred) sub class of another class.
|
|
86
94
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
@@ -110,9 +118,9 @@ export declare class ClassRepository extends ConceptRepository {
|
|
|
110
118
|
* Get all classes from the repository that have no super classes.
|
|
111
119
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
112
120
|
* @param options Optional query parameters.
|
|
113
|
-
* @returns An
|
|
121
|
+
* @returns An iterator of root classes in the repository.
|
|
114
122
|
*/
|
|
115
|
-
getRootClasses(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): string
|
|
123
|
+
getRootClasses(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
116
124
|
/**
|
|
117
125
|
* Indicate if there is an equivalent class of a given class.
|
|
118
126
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
@@ -129,4 +137,13 @@ export declare class ClassRepository extends ConceptRepository {
|
|
|
129
137
|
* @returns `true` if the class has individuals, `false` otherwise.
|
|
130
138
|
*/
|
|
131
139
|
hasIndividuals(graphUris: string | string[] | undefined, classUri: string, options?: DefinitionQueryOptions): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Internal method to check for individuals with cycle detection.
|
|
142
|
+
* @param graphUris Graph URIs to search in, undefined for the default graph.
|
|
143
|
+
* @param classUri URI of a class.
|
|
144
|
+
* @param options Optional query parameters.
|
|
145
|
+
* @param backtrack Set of already visited class URIs to prevent cycles.
|
|
146
|
+
* @returns `true` if the class has individuals, `false` otherwise.
|
|
147
|
+
*/
|
|
148
|
+
private _hasIndividuals;
|
|
132
149
|
}
|
|
@@ -3,21 +3,21 @@ export declare class ConceptRepository extends ResourceRepository {
|
|
|
3
3
|
/**
|
|
4
4
|
* Get all concepts.
|
|
5
5
|
* @param graphUris URIs of the graphs to search for concepts.
|
|
6
|
-
* @returns
|
|
6
|
+
* @returns An iterator of URIs of all concepts.
|
|
7
7
|
*/
|
|
8
|
-
getConcepts(graphUris: string | string[] | undefined): string
|
|
8
|
+
getConcepts(graphUris: string | string[] | undefined): IterableIterator<string>;
|
|
9
9
|
/**
|
|
10
10
|
* Get all concept schemes.
|
|
11
11
|
* @param graphUris URIs of the graphs to search for concepts.
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns An iterator of URIs of all concept schemes.
|
|
13
13
|
*/
|
|
14
|
-
getConceptSchemes(graphUris: string | string[] | undefined): string
|
|
14
|
+
getConceptSchemes(graphUris: string | string[] | undefined): IterableIterator<string>;
|
|
15
15
|
/**
|
|
16
16
|
* Get all collections.
|
|
17
17
|
* @param graphUris URI of the graphs to search for collections.
|
|
18
|
-
* @returns
|
|
18
|
+
* @returns An iterator of URIs of all collections.
|
|
19
19
|
*/
|
|
20
|
-
getCollections(graphUris: string | string[] | undefined): string
|
|
20
|
+
getCollections(graphUris: string | string[] | undefined): IterableIterator<string>;
|
|
21
21
|
/**
|
|
22
22
|
* Get the members of a collection. This includes both `skos:member` and `skos:memberList` properties.
|
|
23
23
|
* @param graphUris URI of the graphs to search for collections.
|
|
@@ -44,7 +44,7 @@ export declare class ConceptRepository extends ResourceRepository {
|
|
|
44
44
|
* @param graphUris URIs of the graphs to search for concepts.
|
|
45
45
|
* @param subjectUri URI of a concept scheme.
|
|
46
46
|
*/
|
|
47
|
-
getBroaderConcepts(graphUris: string | string[] | undefined, subjectUri: string): string
|
|
47
|
+
getBroaderConcepts(graphUris: string | string[] | undefined, subjectUri: string): IterableIterator<string>;
|
|
48
48
|
/**
|
|
49
49
|
* Indicates whether a concept has broader concepts.
|
|
50
50
|
* @param graphUris URIs of the graphs to search for concepts.
|
|
@@ -56,7 +56,7 @@ export declare class ConceptRepository extends ResourceRepository {
|
|
|
56
56
|
* @param graphUris URIs of the graphs to search for concepts.
|
|
57
57
|
* @param subjectUri URI of a concept or concept scheme.
|
|
58
58
|
*/
|
|
59
|
-
getNarrowerConcepts(graphUris: string | string[] | undefined, subjectUri?: string): string
|
|
59
|
+
getNarrowerConcepts(graphUris: string | string[] | undefined, subjectUri?: string): IterableIterator<string>;
|
|
60
60
|
/**
|
|
61
61
|
* Indicates whether a concept has narrower concepts.
|
|
62
62
|
* @param graphUris URIs of the graphs to search for concepts.
|
|
@@ -11,16 +11,16 @@ export declare class IndividualRepository extends PropertyRepository {
|
|
|
11
11
|
* @param graphUris The graph URIs to search.
|
|
12
12
|
* @param subjectUri The URI of a subject for which to get the types (optional).
|
|
13
13
|
* @param options Options for retrieving the individuals.
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns An iterator of all individual types, or all types of a specific individual.
|
|
15
15
|
*/
|
|
16
|
-
getIndividualTypes(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): string
|
|
16
|
+
getIndividualTypes(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
17
17
|
/**
|
|
18
18
|
* Get all individuals in the repository.
|
|
19
19
|
* @param typeUri The type of the individuals to get.
|
|
20
20
|
* @param options Options for retrieving the individuals.
|
|
21
|
-
* @returns
|
|
21
|
+
* @returns An iterator of all individuals in the repository.
|
|
22
22
|
*/
|
|
23
|
-
getIndividuals(graphUris: string | string[] | undefined, typeUri?: string, options?: DefinitionQueryOptions): string
|
|
23
|
+
getIndividuals(graphUris: string | string[] | undefined, typeUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Indicate if the subject is an instance of the type, or of one of its super types.
|
|
26
26
|
* @param subjectUri URI of the subject.
|
|
@@ -20,21 +20,21 @@ export declare class PropertyRepository extends ClassRepository {
|
|
|
20
20
|
* @param options Optional options for retrieving properties.
|
|
21
21
|
* @returns A list of all properties in the repository.
|
|
22
22
|
*/
|
|
23
|
-
getProperties(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): string
|
|
23
|
+
getProperties(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Get properties of a given type.
|
|
26
26
|
* @param typeUri URI of a property type.
|
|
27
27
|
* @param includeInferred Indicate if properties of a more specific type should be included in the result.
|
|
28
|
-
* @returns
|
|
28
|
+
* @returns An iterator of properties of the given type.
|
|
29
29
|
*/
|
|
30
|
-
getRootPropertiesOfType(graphUris: string | string[] | undefined, typeUri: string, options?: DefinitionQueryOptions): string
|
|
30
|
+
getRootPropertiesOfType(graphUris: string | string[] | undefined, typeUri: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
31
31
|
/**
|
|
32
32
|
* Get the super properties of a given property.
|
|
33
33
|
* @param subjectUri URI of a property.
|
|
34
34
|
* @param options Optional options for retrieving properties.
|
|
35
35
|
* @returns An array of super properties of the given property, an empty array if the property has no super properties.
|
|
36
36
|
*/
|
|
37
|
-
getSuperProperties(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): string
|
|
37
|
+
getSuperProperties(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
38
38
|
/**
|
|
39
39
|
* Recursively find the first path from a given property to a root property.
|
|
40
40
|
* @param subjectUri URI of a property.
|
|
@@ -51,6 +51,15 @@ export declare class PropertyRepository extends ClassRepository {
|
|
|
51
51
|
* @returns A string array containing the first path that is found from the given property to a root property.
|
|
52
52
|
*/
|
|
53
53
|
getRootPropertiesPath(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Indicate if a given property is direct or indirect (inferred) sub property of another property.
|
|
56
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
57
|
+
* @param subjectUri URI of the sub property.
|
|
58
|
+
* @param classUri URI of the super property.
|
|
59
|
+
* @param options Optional query parameters.
|
|
60
|
+
* @returns `true` if the property is a sub property of the other property, false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
isSubPropertyOf(graphUris: string | string[] | undefined, subjectUri: string, classUri: string, options?: DefinitionQueryOptions): boolean;
|
|
54
63
|
/**
|
|
55
64
|
* Indicate if there are sub properties of a given property.
|
|
56
65
|
* @param subjectUri URI of a property.
|
|
@@ -64,13 +73,13 @@ export declare class PropertyRepository extends ClassRepository {
|
|
|
64
73
|
* @param options Optional options for retrieving properties.
|
|
65
74
|
* @returns An array of sub properties of the given property, an empty array if the property has no sub properties.
|
|
66
75
|
*/
|
|
67
|
-
getSubProperties(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): string
|
|
76
|
+
getSubProperties(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
68
77
|
/**
|
|
69
78
|
* Get all properties from the repository that have no super properties.
|
|
70
79
|
* @param options Optional options for retrieving properties.
|
|
71
|
-
* @returns An
|
|
80
|
+
* @returns An iterator of root properties in the repository.
|
|
72
81
|
*/
|
|
73
|
-
getRootProperties(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): string
|
|
82
|
+
getRootProperties(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
74
83
|
/**
|
|
75
84
|
* Indicate if there is an equivalent property of a given property.
|
|
76
85
|
* @param propertyUri URI of a property.
|
|
@@ -93,7 +102,7 @@ export declare class PropertyRepository extends ClassRepository {
|
|
|
93
102
|
* Get all asserted and inferred property types.
|
|
94
103
|
* @param graphUris The URI of the graph or an array of graphs to search for property types.
|
|
95
104
|
* @param options Optional options for retrieving properties.
|
|
96
|
-
* @returns
|
|
105
|
+
* @returns An iterator of all property types in the repository.
|
|
97
106
|
*/
|
|
98
|
-
getPropertyTypes(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): string
|
|
107
|
+
getPropertyTypes(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
99
108
|
}
|
|
@@ -11,31 +11,31 @@ export declare class ShapeRepository extends IndividualRepository {
|
|
|
11
11
|
* Get all shapes in the repository.
|
|
12
12
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
13
13
|
* @param options Optional query parameters.
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns An iterable of all shapes in the repository.
|
|
15
15
|
*/
|
|
16
|
-
getShapes(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): string
|
|
16
|
+
getShapes(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
17
17
|
/**
|
|
18
18
|
* Get all shape types in the repository.
|
|
19
19
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
20
20
|
* @param options Optional query parameters.
|
|
21
21
|
* @returns A list of all shape types in the repository.
|
|
22
22
|
*/
|
|
23
|
-
getShapeTypes(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): string
|
|
23
|
+
getShapeTypes(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Get all validator types in the repository.
|
|
26
26
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
27
27
|
* @param options Optional query parameters.
|
|
28
|
-
* @returns
|
|
28
|
+
* @returns An iterable of all shape types in the repository.
|
|
29
29
|
*/
|
|
30
|
-
getValidatorTypes(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): string
|
|
30
|
+
getValidatorTypes(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
31
31
|
/**
|
|
32
32
|
* Get all target classes, nodes or properties of a given shape in the repository.
|
|
33
33
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
34
34
|
* @param shape The URI or blank id of the shape.
|
|
35
35
|
* @param options Optional query parameters.
|
|
36
|
-
* @returns
|
|
36
|
+
* @returns An iterable of all targeted resources in the repository.
|
|
37
37
|
*/
|
|
38
|
-
getShapeTargets(graphUris: string | string[] | undefined, shape: Quad_Subject, options?: DefinitionQueryOptions): string
|
|
38
|
+
getShapeTargets(graphUris: string | string[] | undefined, shape: Quad_Subject, options?: DefinitionQueryOptions): IterableIterator<string>;
|
|
39
39
|
/**
|
|
40
40
|
* Indicate if there are shapes for a subject in the repository.
|
|
41
41
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
@@ -57,7 +57,7 @@ export declare class ShapeRepository extends IndividualRepository {
|
|
|
57
57
|
* @param options Optional query parameters.
|
|
58
58
|
* @returns A list of all validators in the repository.
|
|
59
59
|
*/
|
|
60
|
-
getValidators(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): string
|
|
60
|
+
getValidators(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): IterableIterator<string>;
|
|
61
61
|
/**
|
|
62
62
|
* Indicate if there are rules in the repository.
|
|
63
63
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
@@ -72,7 +72,7 @@ export declare class ShapeRepository extends IndividualRepository {
|
|
|
72
72
|
* @param options Optional query parameters.
|
|
73
73
|
* @returns A list of all rules in the repository.
|
|
74
74
|
*/
|
|
75
|
-
getRules(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): string
|
|
75
|
+
getRules(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): IterableIterator<string>;
|
|
76
76
|
/**
|
|
77
77
|
* Get the SHACL datatype of a given property.
|
|
78
78
|
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
@@ -6,9 +6,9 @@ export declare class VocabularyRepository extends ShapeRepository {
|
|
|
6
6
|
/**
|
|
7
7
|
* Get all concept schemes in the repository.
|
|
8
8
|
* @param graphUris URIs of the graphs to search.
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns An iterator of all concept schemes in the repository.
|
|
10
10
|
*/
|
|
11
|
-
getConceptSchemes(graphUris: string | string[] | undefined): string
|
|
11
|
+
getConceptSchemes(graphUris: string | string[] | undefined): IterableIterator<string>;
|
|
12
12
|
/**
|
|
13
13
|
* Indicates whether the repository contains any concept schemes.
|
|
14
14
|
* @param graphUris URIs of the graphs to search.
|
|
@@ -18,9 +18,9 @@ export declare class VocabularyRepository extends ShapeRepository {
|
|
|
18
18
|
/**
|
|
19
19
|
* Get all ontologies in the repository.
|
|
20
20
|
* @param graphUris URIs of the graphs to search.
|
|
21
|
-
* @returns
|
|
21
|
+
* @returns An iterator of all ontologies in the repository.
|
|
22
22
|
*/
|
|
23
|
-
getOntologies(graphUris: string | string[] | undefined): string
|
|
23
|
+
getOntologies(graphUris: string | string[] | undefined): IterableIterator<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Indicates whether the repository contains any ontology headers.
|
|
26
26
|
* @param graphUris URIs of the graphs to search.
|
|
@@ -39,7 +39,7 @@ export declare class VocabularyRepository extends ShapeRepository {
|
|
|
39
39
|
* or the objects of `rdfs:isDefinedBy` triples. If the rdfs:isDefinedBy object can be
|
|
40
40
|
* matched with an ontology definition, the ontology URI is returned.
|
|
41
41
|
* @param graphUris URIs of the graphs to search.
|
|
42
|
-
* @returns
|
|
42
|
+
* @returns An iterator of sources of definitions for the given graph.
|
|
43
43
|
*/
|
|
44
|
-
getDefinitionSources(graphUris: string | string[] | undefined, includeOntologies?: boolean): string
|
|
44
|
+
getDefinitionSources(graphUris: string | string[] | undefined, includeOntologies?: boolean): IterableIterator<string>;
|
|
45
45
|
}
|