@faubulous/mentor-rdf 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +446 -285
- package/dist/index.js.map +4 -4
- package/dist/rdf/data-factory.d.ts +16 -0
- package/dist/rdf/rdf-data-factory.d.ts +7 -0
- package/dist/rdf/resource-repository.d.ts +69 -1
- package/dist/rdf/tests/helpers.d.ts +8 -0
- package/package.json +3 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as rdfjs from "@rdfjs/types";
|
|
2
2
|
/**
|
|
3
3
|
* An RDF/JS compliant NamedNode implementation.
|
|
4
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
5
|
+
* removed in the next major version.
|
|
4
6
|
*/
|
|
5
7
|
export declare class NamedNode implements rdfjs.NamedNode {
|
|
6
8
|
readonly termType: "NamedNode";
|
|
@@ -10,6 +12,8 @@ export declare class NamedNode implements rdfjs.NamedNode {
|
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* An RDF/JS compliant BlankNode implementation.
|
|
15
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
16
|
+
* removed in the next major version.
|
|
13
17
|
*/
|
|
14
18
|
export declare class BlankNode implements rdfjs.BlankNode {
|
|
15
19
|
readonly termType: "BlankNode";
|
|
@@ -19,6 +23,8 @@ export declare class BlankNode implements rdfjs.BlankNode {
|
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* An RDF/JS compliant Literal implementation.
|
|
26
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
27
|
+
* removed in the next major version.
|
|
22
28
|
*/
|
|
23
29
|
export declare class Literal implements rdfjs.Literal {
|
|
24
30
|
readonly termType: "Literal";
|
|
@@ -30,6 +36,8 @@ export declare class Literal implements rdfjs.Literal {
|
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
38
|
* An RDF/JS compliant Variable implementation.
|
|
39
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
40
|
+
* removed in the next major version.
|
|
33
41
|
*/
|
|
34
42
|
export declare class Variable implements rdfjs.Variable {
|
|
35
43
|
readonly termType: "Variable";
|
|
@@ -39,6 +47,8 @@ export declare class Variable implements rdfjs.Variable {
|
|
|
39
47
|
}
|
|
40
48
|
/**
|
|
41
49
|
* An RDF/JS compliant DefaultGraph implementation (singleton).
|
|
50
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
51
|
+
* removed in the next major version.
|
|
42
52
|
*/
|
|
43
53
|
export declare class DefaultGraph implements rdfjs.DefaultGraph {
|
|
44
54
|
readonly termType: "DefaultGraph";
|
|
@@ -47,6 +57,8 @@ export declare class DefaultGraph implements rdfjs.DefaultGraph {
|
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
59
|
* An RDF/JS compliant Quad implementation.
|
|
60
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
61
|
+
* removed in the next major version.
|
|
50
62
|
*/
|
|
51
63
|
export declare class Quad implements rdfjs.Quad {
|
|
52
64
|
readonly termType: "Quad";
|
|
@@ -65,6 +77,8 @@ export declare class Quad implements rdfjs.Quad {
|
|
|
65
77
|
* and quads according to the RDF/JS specification.
|
|
66
78
|
*
|
|
67
79
|
* @see https://rdf.js.org/data-model-spec/
|
|
80
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
81
|
+
* removed in the next major version.
|
|
68
82
|
*/
|
|
69
83
|
export declare class DataFactory implements rdfjs.DataFactory<rdfjs.Quad, rdfjs.Quad> {
|
|
70
84
|
blankNodeCounter: number;
|
|
@@ -127,5 +141,7 @@ export declare class DataFactory implements rdfjs.DataFactory<rdfjs.Quad, rdfjs.
|
|
|
127
141
|
}
|
|
128
142
|
/**
|
|
129
143
|
* A default DataFactory instance for convenient use.
|
|
144
|
+
* @deprecated Use `rdf-data-factory`, which the store and the Mentor parsers use. This will be
|
|
145
|
+
* removed in the next major version.
|
|
130
146
|
*/
|
|
131
147
|
export declare const dataFactory: DataFactory;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataFactory } from 'rdf-data-factory';
|
|
2
|
+
/**
|
|
3
|
+
* The RDF/JS data factory mentor-rdf creates its terms with. It is the factory of
|
|
4
|
+
* `rdf-data-factory`, which the store (rdf-stores), the Mentor parsers and serializers use as
|
|
5
|
+
* well, so the terms of mentor-rdf compare equal to those of the store.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RdfDataFactory: DataFactory<import("quadstore", { with: { "resolution-mode": "import" } }).Quad>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Quad_Subject, Quad_Object } from "@rdfjs/types";
|
|
1
|
+
import { NamedNode, Quad_Subject, Quad_Object } from "@rdfjs/types";
|
|
2
2
|
import { Store } from "./store";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for matching triples in the store.
|
|
@@ -140,4 +140,72 @@ export declare class ResourceRepository {
|
|
|
140
140
|
* @param graphUris URIs of the graphs to search.
|
|
141
141
|
*/
|
|
142
142
|
getMostFrequentLanguageTag(graphUris: string | string[] | undefined): string | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Get the hierarchy relations of a predicate such as `rdfs:subClassOf`, read in a single pass.
|
|
145
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
146
|
+
* @param predicate The hierarchy predicate, e.g. `rdfs:subClassOf` or `rdfs:subPropertyOf`.
|
|
147
|
+
* @param options Optional query parameters.
|
|
148
|
+
* @returns A map from a node, named or blank, to its named parents, excluding the node itself.
|
|
149
|
+
*/
|
|
150
|
+
protected getParentMap(graphUris: string | string[] | undefined, predicate: NamedNode, options?: QueryOptions): Map<string, string[]>;
|
|
151
|
+
/**
|
|
152
|
+
* Get the root nodes of a hierarchy such as the class or the property hierarchy. A member with no
|
|
153
|
+
* visible parent is a root. A parent that is not one of the document's own nodes is referenced:
|
|
154
|
+
* the roots are then the top nodes of its chains of parents, as far as the graphs state them.
|
|
155
|
+
* @param members The nodes whose roots are wanted, e.g. the classes of the document.
|
|
156
|
+
* @param parents The parents of every node, see {@link getParentMap}.
|
|
157
|
+
* @param isOwn Whether a node belongs to the document; a chain that reaches one has no top of its own.
|
|
158
|
+
* @param isVisible Whether a parent is shown in the hierarchy at all.
|
|
159
|
+
* @param canBeRoot Whether a node is listed as a root, be it a member without visible parents or the top of a referenced chain.
|
|
160
|
+
* @returns An iterator of the root nodes.
|
|
161
|
+
*/
|
|
162
|
+
protected getHierarchyRoots(members: Iterable<string>, parents: Map<string, string[]>, isOwn: (iri: string) => boolean, isVisible: (iri: string) => boolean, canBeRoot?: (iri: string) => boolean): IterableIterator<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Get the top nodes of the chains of parents of a referenced node.
|
|
165
|
+
* @param iri URI of a referenced node.
|
|
166
|
+
* @param getParents A function returning the visible parents of a node.
|
|
167
|
+
* @param isOwn Whether a node belongs to the document; a chain that reaches one has no top of its own.
|
|
168
|
+
* @param finished The referenced nodes whose top nodes were already yielded.
|
|
169
|
+
* @param path The nodes on the current chain, to stop at cycles.
|
|
170
|
+
* @returns An iterator of the top nodes not yielded for another chain before.
|
|
171
|
+
*/
|
|
172
|
+
private _getTopNodes;
|
|
173
|
+
/**
|
|
174
|
+
* Indicate if a node is only referenced by the document: it is included if referenced terms
|
|
175
|
+
* are included, and it is not defined by another ontology of the document. Annotations or a
|
|
176
|
+
* declaration of a term from another vocabulary do not define it.
|
|
177
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
178
|
+
* @param node A node.
|
|
179
|
+
* @param options Optional query parameters.
|
|
180
|
+
* @param ontologies The other ontologies in the graphs, see {@link getOtherOntologiesOnce}.
|
|
181
|
+
* @returns `true` if the node is a referenced named node, `false` otherwise.
|
|
182
|
+
*/
|
|
183
|
+
protected isReferenced(graphUris: string | string[] | undefined, node: Quad_Subject | Quad_Object, options: DefinitionQueryOptions | undefined, ontologies: () => string[]): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Indicate if a node is a referenced term with one of the document's own terms below it in a
|
|
186
|
+
* hierarchy, so that the hierarchy from a referenced root down to the document is not broken.
|
|
187
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
188
|
+
* @param node A node.
|
|
189
|
+
* @param predicate The hierarchy predicate, e.g. `rdfs:subClassOf` or `rdfs:subPropertyOf`.
|
|
190
|
+
* @param options Optional query parameters.
|
|
191
|
+
* @param ontologies The other ontologies in the graphs, see {@link getOtherOntologiesOnce}.
|
|
192
|
+
* @param visited The nodes already visited, to stop at cycles.
|
|
193
|
+
* @returns `true` if a term of the document is a direct or indirect child of the node.
|
|
194
|
+
*/
|
|
195
|
+
protected isReferencedAbove(graphUris: string | string[] | undefined, node: Quad_Subject, predicate: NamedNode, options: DefinitionQueryOptions | undefined, ontologies: () => string[], visited?: Set<string>): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Get an accessor for the other ontologies in the graphs that queries them on its first call
|
|
198
|
+
* only, as most queries never need them.
|
|
199
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
200
|
+
* @param options Optional query parameters.
|
|
201
|
+
* @returns A function returning the URIs of the other ontologies, see {@link _getOtherOntologies}.
|
|
202
|
+
*/
|
|
203
|
+
protected getOtherOntologiesOnce(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): () => string[];
|
|
204
|
+
/**
|
|
205
|
+
* Get the ontologies declared in the graphs other than the one the options select with `definedBy`.
|
|
206
|
+
* @param graphUris URIs of the graphs to search, `undefined` for the default graph.
|
|
207
|
+
* @param options Optional query parameters.
|
|
208
|
+
* @returns The URIs of the other ontologies, or none if the options select no ontology.
|
|
209
|
+
*/
|
|
210
|
+
private _getOtherOntologies;
|
|
143
211
|
}
|
|
@@ -21,6 +21,14 @@ export declare function readFile(filePath: string): Promise<string>;
|
|
|
21
21
|
* @returns A promise that resolves to the URI of the graph that was loaded.
|
|
22
22
|
*/
|
|
23
23
|
export declare function loadFile(store: Store, filePath: string, graphUri?: string, onQuad?: (quad: rdfjs.Quad) => void): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Get the ids the store gives the blank nodes of a Turtle file loaded into a graph, in the order
|
|
26
|
+
* their tokens are written: the id of the first `[` or `(` comes first.
|
|
27
|
+
* @param filePath Path to a Turtle file.
|
|
28
|
+
* @param graphUri The URI of the graph the file is loaded into.
|
|
29
|
+
* @returns The blank node ids.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getBlankNodeIds(filePath: string, graphUri: string): Promise<string[]>;
|
|
24
32
|
/**
|
|
25
33
|
* Create a RDF triple store from a string.
|
|
26
34
|
* @param filePath Path to a file containing RDF triples in Turtle or N3 format.
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"ontology",
|
|
11
11
|
"vocabulary"
|
|
12
12
|
],
|
|
13
|
-
"version": "2.
|
|
13
|
+
"version": "2.7.0",
|
|
14
14
|
"private": false,
|
|
15
15
|
"author": {
|
|
16
16
|
"name": "Sebastian Faubel"
|
|
@@ -84,9 +84,10 @@
|
|
|
84
84
|
"parse-url": "^11.1.0"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@faubulous/mentor-rdf-parsers": "^2.
|
|
87
|
+
"@faubulous/mentor-rdf-parsers": "^2.3.0",
|
|
88
88
|
"memory-level": "^3.1.0",
|
|
89
89
|
"quadstore": "^15.4.1",
|
|
90
|
+
"rdf-data-factory": "^2.1.0",
|
|
90
91
|
"rdf-stores": "^2.8.0",
|
|
91
92
|
"rdflib": "^2.4.1",
|
|
92
93
|
"rdfxml-streaming-parser": "^3.3.0",
|