@faubulous/mentor-rdf 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { ResourceRepository } from "./resource-repository";
1
+ import { DefinitionQueryOptions, ResourceRepository } from "./resource-repository";
2
2
  export declare class ConceptRepository extends ResourceRepository {
3
3
  /**
4
4
  * Get all concepts.
@@ -15,9 +15,120 @@ export declare class ConceptRepository extends ResourceRepository {
15
15
  /**
16
16
  * Get all collections.
17
17
  * @param graphUris URI of the graphs to search for collections.
18
+ * @param options Optional query parameters.
18
19
  * @returns An iterator of URIs of all collections.
19
20
  */
20
- getCollections(graphUris: string | string[] | undefined): IterableIterator<string>;
21
+ getCollections(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
22
+ /**
23
+ * Indicate if a collection should be excluded from a query result.
24
+ *
25
+ * Note: In contrast to other resource types, blank nodes and referenced collections are
26
+ * included by default so that the result is unchanged when no options are provided.
27
+ * @param graphUris URI of the graphs to search for collections.
28
+ * @param subject The collection to test.
29
+ * @param options Optional query parameters.
30
+ * @returns `true` if the collection should be excluded, `false` otherwise.
31
+ */
32
+ private _skipCollection;
33
+ /**
34
+ * Indicate if a resource is associated with any concept scheme via `skos:inScheme`.
35
+ * @param graphUris URIs of the graphs to search for concepts.
36
+ * @param subjectUri URI of a resource.
37
+ * @returns `true` if the resource is in a concept scheme, `false` otherwise.
38
+ */
39
+ hasConceptScheme(graphUris: string | string[] | undefined, subjectUri: string): boolean;
40
+ /**
41
+ * Indicate if a resource is associated with a given concept scheme via `skos:inScheme`.
42
+ * @param graphUris URIs of the graphs to search for concepts.
43
+ * @param subjectUri URI of a resource.
44
+ * @param schemeUri URI of a concept scheme.
45
+ * @returns `true` if the resource is in the given concept scheme, `false` otherwise.
46
+ */
47
+ isInScheme(graphUris: string | string[] | undefined, subjectUri: string, schemeUri: string): boolean;
48
+ /**
49
+ * Indicate if a concept is explicitly associated with a given concept scheme, either via
50
+ * `skos:inScheme` or via `skos:topConceptOf`.
51
+ *
52
+ * Note: The `skos:broader` and `skos:narrower` relations are *not* taken into account, because
53
+ * they may cross the boundaries of a concept scheme. Use {@link getAllConceptsInScheme} to get
54
+ * the concepts that are displayed below a concept scheme.
55
+ * @param graphUris URIs of the graphs to search for concepts.
56
+ * @param subjectUri URI of a concept.
57
+ * @param schemeUri URI of a concept scheme.
58
+ * @returns `true` if the concept is associated with the concept scheme, `false` otherwise.
59
+ */
60
+ isConceptOfScheme(graphUris: string | string[] | undefined, subjectUri: string, schemeUri: string): boolean;
61
+ /**
62
+ * Indicate if a concept can be displayed below a given concept scheme.
63
+ *
64
+ * Concepts that are not associated with any concept scheme belong to every concept scheme they
65
+ * can be reached from, so that they are not hidden in vocabularies that only annotate their top
66
+ * concepts with `skos:inScheme`.
67
+ * @param graphUris URIs of the graphs to search for concepts.
68
+ * @param subjectUri URI of a concept.
69
+ * @param schemeUri URI of a concept scheme.
70
+ * @returns `true` if the concept can be displayed below the concept scheme, `false` otherwise.
71
+ */
72
+ private _isVisibleInScheme;
73
+ /**
74
+ * Get the concepts that are explicitly associated with a concept scheme, either via
75
+ * `skos:inScheme` or via `skos:topConceptOf`.
76
+ * @param graphUris URIs of the graphs to search for concepts.
77
+ * @param schemeUri URI of a concept scheme.
78
+ * @returns An iterator of URIs of the concepts of the concept scheme.
79
+ */
80
+ getConceptsOfScheme(graphUris: string | string[] | undefined, schemeUri: string): IterableIterator<string>;
81
+ /**
82
+ * Get the top concepts of a concept scheme.
83
+ *
84
+ * In addition to the concepts that are explicitly designated as top concepts via
85
+ * `skos:hasTopConcept` or `skos:topConceptOf`, this returns the concepts of the scheme that have
86
+ * no broader concept *within the same scheme*. Without the latter, concepts whose `skos:broader`
87
+ * property refers to a concept of another scheme would not be displayed below the scheme that
88
+ * they are associated with.
89
+ *
90
+ * Note: A concept that is its own broader concept is not excluded, so that recursive definitions
91
+ * do not remove it from the list of top concepts.
92
+ * @param graphUris URIs of the graphs to search for concepts.
93
+ * @param schemeUri URI of a concept scheme.
94
+ * @returns An iterator of URIs of the top concepts of the concept scheme.
95
+ */
96
+ getTopConcepts(graphUris: string | string[] | undefined, schemeUri: string): IterableIterator<string>;
97
+ /**
98
+ * Get the concepts of a concept scheme that have a broader concept within the same scheme.
99
+ *
100
+ * The hierarchical relations are enumerated once and matched against the set of concepts of the
101
+ * scheme, which is considerably cheaper than querying the broader concepts of every single
102
+ * concept of the scheme.
103
+ * @param graphUris URIs of the graphs to search for concepts.
104
+ * @param concepts Set of the concepts that are associated with the concept scheme.
105
+ * @returns A set of URIs of the concepts that are nested below another concept of the scheme.
106
+ */
107
+ private _nestedConceptsOfScheme;
108
+ /**
109
+ * Get all concepts that are displayed below a concept scheme, including indirectly narrower ones.
110
+ *
111
+ * The traversal starts at the {@link getTopConcepts} of the scheme and follows the narrower
112
+ * concepts that can be displayed below the scheme, so the result is exactly the set of concepts
113
+ * that a hierarchical view of the scheme can reach.
114
+ *
115
+ * Note: The hierarchical relations of the graphs are indexed once per call instead of querying
116
+ * the narrower concepts of every single concept, which is an order of magnitude faster on large
117
+ * thesauri. Prefer {@link getConceptsOfScheme} when the *associated* concepts are sufficient.
118
+ * @param graphUris URIs of the graphs to search for concepts.
119
+ * @param schemeUri URI of a concept scheme.
120
+ * @returns An iterator of URIs of all concepts below the concept scheme.
121
+ */
122
+ getAllConceptsInScheme(graphUris: string | string[] | undefined, schemeUri: string): IterableIterator<string>;
123
+ /**
124
+ * Index the narrower concept relations of the given graphs.
125
+ *
126
+ * All four hierarchical relations are enumerated once, which is considerably cheaper than
127
+ * querying {@link getNarrowerConcepts} for every concept of a large thesaurus.
128
+ * @param graphUris URIs of the graphs to search for concepts.
129
+ * @returns A map of concept URIs to the URIs of their narrower concepts.
130
+ */
131
+ private _getNarrowerConceptIndex;
21
132
  /**
22
133
  * Get the members of a collection. This includes both `skos:member` and `skos:memberList` properties.
23
134
  * @param graphUris URI of the graphs to search for collections.
@@ -39,6 +150,113 @@ export declare class ConceptRepository extends ResourceRepository {
39
150
  * @returns `true` if the collection is an ordered collection, `false` otherwise.
40
151
  */
41
152
  isOrderedCollection(graphUris: string | string[] | undefined, collectionUri: string): boolean;
153
+ /**
154
+ * Indicates whether a subject is a collection.
155
+ * @param graphUris URI of the graphs to search for collections.
156
+ * @param subjectUri URI of a subject.
157
+ * @returns `true` if the subject is a `skos:Collection` or a `skos:OrderedCollection`, `false` otherwise.
158
+ */
159
+ isCollection(graphUris: string | string[] | undefined, subjectUri: string): boolean;
160
+ /**
161
+ * Get the collections that have a given subject as a member. This includes both `skos:member`
162
+ * and `skos:memberList` properties.
163
+ *
164
+ * Note: A collection that is a member of itself is returned as its own super collection, which
165
+ * is consistent with {@link getBroaderConcepts}. Use {@link hasSuperCollections} to test whether
166
+ * a collection is a member of *another* collection.
167
+ * @param graphUris URI of the graphs to search for collections.
168
+ * @param subjectUri URI of a collection or concept.
169
+ * @returns An iterator of URIs of the collections that contain the subject.
170
+ */
171
+ getSuperCollections(graphUris: string | string[] | undefined, subjectUri: string): IterableIterator<string>;
172
+ /**
173
+ * Get the collections that reference a given subject in an ordered member list.
174
+ *
175
+ * Starting from the list nodes that have the subject as their first item, the `rdf:rest` chain
176
+ * is traversed *backwards* towards the head of the list, and every visited list node is tested
177
+ * for being the object of a `skos:memberList` property. This is considerably cheaper than
178
+ * expanding all member lists in the graph, and it also resolves collections that share a list.
179
+ * @param graphUris URI of the graphs to search for collections.
180
+ * @param subjectUri URI of a collection or concept.
181
+ * @returns An iterator of URIs of the collections that reference the subject in a member list.
182
+ */
183
+ private _getMemberListContainers;
184
+ /**
185
+ * Indicates whether a collection is a member of another collection.
186
+ *
187
+ * Note: A collection that is a member of itself is *not* considered to have a super collection,
188
+ * so that recursive definitions do not remove it from the list of root collections.
189
+ * @param graphUris URI of the graphs to search for collections.
190
+ * @param subjectUri URI of a collection.
191
+ * @returns `true` if the collection is a member of another collection, `false` otherwise.
192
+ */
193
+ hasSuperCollections(graphUris: string | string[] | undefined, subjectUri: string): boolean;
194
+ /**
195
+ * Get the members of a collection that are collections themselves, or all root collections.
196
+ *
197
+ * The order of the members of a `skos:OrderedCollection` is preserved.
198
+ * @param graphUris URI of the graphs to search for collections.
199
+ * @param subjectUri URI of a collection or `undefined` to get all root collections.
200
+ * @param options Optional query parameters.
201
+ * @returns An iterator of URIs of the nested collections of the given collection, or of the root collections if no subject is provided.
202
+ */
203
+ getSubCollections(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>;
204
+ /**
205
+ * Indicates whether a collection has members that are collections themselves.
206
+ * @param graphUris URI of the graphs to search for collections.
207
+ * @param subjectUri URI of a collection.
208
+ * @param options Optional query parameters.
209
+ * @returns `true` if the collection has nested collections, `false` otherwise.
210
+ */
211
+ hasSubCollections(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): boolean;
212
+ /**
213
+ * Get all collections that are not a member of another collection.
214
+ *
215
+ * Every collection returned by {@link getCollections} is either returned by this method, or is
216
+ * reachable from one of the returned collections via {@link getSubCollections}. If a group of
217
+ * collections is only reachable through a membership cycle, the first collection of that group
218
+ * is returned as a root collection so that no collection is lost.
219
+ *
220
+ * Note: Collections that are identified by a blank node cannot be queried for their members and
221
+ * are therefore always returned as root collections.
222
+ * @param graphUris URI of the graphs to search for collections.
223
+ * @param options Optional query parameters.
224
+ * @returns An iterator of URIs of the root collections.
225
+ */
226
+ getRootCollections(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>;
227
+ /**
228
+ * Mark all collections that can be reached from a given collection through nested collections.
229
+ *
230
+ * The traversal uses the same criteria as {@link getSubCollections} so that the marked
231
+ * collections are exactly the collections that are visible below the given collection. Since
232
+ * the set of reachable collections is shared between all calls, the members of a collection are
233
+ * enumerated at most once per {@link getRootCollections} call.
234
+ * @param graphUris URI of the graphs to search for collections.
235
+ * @param subjectUri URI of the collection to start the traversal from.
236
+ * @param collections Set of all collections that are in the scope of the query.
237
+ * @param reachable Set of collections that have already been reached.
238
+ */
239
+ private _markReachableCollections;
240
+ /**
241
+ * Get the first discovered path from a given collection to a root collection.
242
+ *
243
+ * The path does not contain the given collection and is ordered from the closest super
244
+ * collection to the root collection. If the collection is part of a membership cycle, the path
245
+ * ends at the last collection that has not been visited yet and does not reach a root collection.
246
+ * @param graphUris URI of the graphs to search for collections.
247
+ * @param subjectUri URI of a collection.
248
+ * @returns The first path that is found from the given collection to a root collection.
249
+ */
250
+ getRootCollectionPath(graphUris: string | string[] | undefined, subjectUri: string): string[];
251
+ /**
252
+ * Recursively find the first path from a given collection to a root collection.
253
+ * @param graphUris URI of the graphs to search for collections.
254
+ * @param subjectUri URI of a collection.
255
+ * @param path The current collection path.
256
+ * @param backtrack Set of URIs that have already been visited.
257
+ * @returns The first path that is found from the given collection to a root collection.
258
+ */
259
+ private _getRootCollectionPath;
42
260
  /**
43
261
  * Get all broader concepts of a concept scheme.
44
262
  * @param graphUris URIs of the graphs to search for concepts.
@@ -52,11 +270,16 @@ export declare class ConceptRepository extends ResourceRepository {
52
270
  */
53
271
  hasBroaderConcepts(graphUris: string | string[] | undefined, subjectUri: string): boolean;
54
272
  /**
55
- * Get all narrower concepts of a concept or top concepts of a concept scheme.
273
+ * Get all narrower concepts of a concept or the top concepts of a concept scheme.
274
+ *
275
+ * If the subject is a concept scheme, the {@link getTopConcepts} of that scheme are returned. If
276
+ * the `inScheme` option is set, only concepts that can be displayed below that concept scheme are
277
+ * returned, which excludes concepts that are associated with a *different* scheme.
56
278
  * @param graphUris URIs of the graphs to search for concepts.
57
- * @param subjectUri URI of a concept or concept scheme.
279
+ * @param subjectUri URI of a concept or concept scheme, or `undefined` to get all concept schemes.
280
+ * @param options Optional query parameters.
58
281
  */
59
- getNarrowerConcepts(graphUris: string | string[] | undefined, subjectUri?: string): IterableIterator<string>;
282
+ getNarrowerConcepts(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>;
60
283
  /**
61
284
  * Indicates whether a concept has narrower concepts.
62
285
  * @param graphUris URIs of the graphs to search for concepts.
@@ -30,6 +30,11 @@ export interface DefinitionQueryOptions extends QueryOptions {
30
30
  * Indicate if blank nodes should be included in the result (default: false).
31
31
  */
32
32
  includeBlankNodes?: boolean;
33
+ /**
34
+ * URI of the concept scheme the resources must be associated with via `skos:inScheme`.
35
+ * If `null`, returns only resources that have no `skos:inScheme` property.
36
+ */
37
+ inScheme?: string | null;
33
38
  }
34
39
  /**
35
40
  * Parameters for store queries that support filtering on the type of resource.
@@ -163,6 +163,13 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
163
163
  * @returns An array of URIs of the items in the list.
164
164
  */
165
165
  getListItems(graphUris: string | string[] | undefined, listUri: string): string[];
166
+ /**
167
+ * Recursively collect the items of an ordered list.
168
+ * @param graphUris Optional graph URI or array of graph URIs to query.
169
+ * @param subject The list node to collect the items from.
170
+ * @param visited Set of list nodes that have already been visited.
171
+ * @returns An array of the items in the list.
172
+ */
166
173
  private _getListItems;
167
174
  /**
168
175
  * Returns the exact cardinality of the quads matching the pattern.
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "ontology",
11
11
  "vocabulary"
12
12
  ],
13
- "version": "2.1.0",
13
+ "version": "2.1.2",
14
14
  "private": false,
15
15
  "author": {
16
16
  "name": "Sebastian Faubel"