@oslo-flanders/core 0.0.4-alpha.0 → 0.0.6-alpha.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -75
  3. package/index.d.ts +22 -20
  4. package/index.js +38 -36
  5. package/lib/ServiceIdentifier.d.ts +7 -7
  6. package/lib/ServiceIdentifier.js +14 -14
  7. package/lib/enums/PropertyTypes.d.ts +5 -5
  8. package/lib/enums/PropertyTypes.js +9 -9
  9. package/lib/enums/Scope.d.ts +6 -6
  10. package/lib/enums/Scope.js +10 -10
  11. package/lib/interfaces/AppRunner.d.ts +19 -19
  12. package/lib/interfaces/AppRunner.js +26 -26
  13. package/lib/interfaces/IConfiguration.d.ts +7 -7
  14. package/lib/interfaces/IConfiguration.js +2 -2
  15. package/lib/interfaces/IOutputHandler.d.ts +7 -7
  16. package/lib/interfaces/IOutputHandler.js +2 -2
  17. package/lib/interfaces/IService.d.ts +11 -11
  18. package/lib/interfaces/IService.js +2 -2
  19. package/lib/logging/LogLevel.d.ts +5 -5
  20. package/lib/logging/LogLevel.js +4 -4
  21. package/lib/logging/LogUtil.d.ts +4 -4
  22. package/lib/logging/LogUtil.js +16 -16
  23. package/lib/logging/Logger.d.ts +20 -20
  24. package/lib/logging/Logger.js +35 -35
  25. package/lib/logging/LoggerFactory.d.ts +11 -11
  26. package/lib/logging/LoggerFactory.js +2 -2
  27. package/lib/logging/VoidLogger.d.ts +7 -7
  28. package/lib/logging/VoidLogger.js +27 -27
  29. package/lib/logging/VoidLoggerFactory.d.ts +9 -9
  30. package/lib/logging/VoidLoggerFactory.js +16 -16
  31. package/lib/logging/WinstonLogger.d.ts +8 -8
  32. package/lib/logging/WinstonLogger.js +30 -30
  33. package/lib/logging/WinstonLoggerFactory.d.ts +10 -10
  34. package/lib/logging/WinstonLoggerFactory.js +23 -23
  35. package/lib/store/QuadStore.d.ts +165 -180
  36. package/lib/store/QuadStore.js +305 -329
  37. package/lib/utils/fetchFileOrUrl.d.ts +2 -2
  38. package/lib/utils/fetchFileOrUrl.js +22 -22
  39. package/lib/utils/namespaces.d.ts +24 -24
  40. package/lib/utils/namespaces.js +34 -35
  41. package/lib/utils/storeUtils.d.ts +8 -0
  42. package/lib/utils/storeUtils.js +85 -0
  43. package/lib/utils/uniqueId.d.ts +1 -1
  44. package/lib/utils/uniqueId.js +13 -13
  45. package/package.json +11 -3
@@ -1,330 +1,306 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __metadata = (this && this.__metadata) || function (k, v) {
32
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.QuadStore = void 0;
39
- const inversify_1 = require("inversify");
40
- const N3 = __importStar(require("n3"));
41
- const rdf_parse_1 = __importDefault(require("rdf-parse"));
42
- const fetchFileOrUrl_1 = require("../utils/fetchFileOrUrl");
43
- const namespaces_1 = require("../utils/namespaces");
44
- let QuadStore = class QuadStore {
45
- constructor() {
46
- this.store = new N3.Store();
47
- }
48
- addQuads(quads) {
49
- this.store.addQuads(quads);
50
- }
51
- addQuad(quad) {
52
- this.store.addQuad(quad);
53
- }
54
- async addQuadsFromFile(file) {
55
- const buffer = await (0, fetchFileOrUrl_1.fetchFileOrUrl)(file);
56
- const textStream = require('streamify-string')(buffer.toString());
57
- return new Promise((resolve, reject) => {
58
- rdf_parse_1.default.parse(textStream, { path: file })
59
- .on('data', (quad) => this.store.addQuad(quad))
60
- .on('error', (error) => reject(error))
61
- .on('end', () => resolve());
62
- });
63
- }
64
- findQuads(subject, predicate, object) {
65
- return this.store.getQuads(subject, predicate, object, null);
66
- }
67
- findQuad(subject, predicate, object) {
68
- return this.findQuads(subject, predicate, object).shift();
69
- }
70
- findSubjects(predicate, object) {
71
- return this.store.getSubjects(predicate, object, null);
72
- }
73
- findSubject(predicate, object) {
74
- return this.findSubjects(predicate, object).shift();
75
- }
76
- findObjects(subject, predicate) {
77
- return this.store.getObjects(subject, predicate, null);
78
- }
79
- findObject(subject, predicate) {
80
- return this.findObjects(subject, predicate).shift();
81
- }
82
- /**
83
- * Finds the subject where predicate is 'rdf:type' and object 'example:Package'
84
- * @returns a RDF.NamedNode or undefined
85
- */
86
- getPackageId() {
87
- return this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.example('Package'), null).shift();
88
- }
89
- /**
90
- * Finds all subjects where predicate is 'rdf:type' and object 'owl:Class'
91
- * @returns an array of RDF.NamedNodes
92
- */
93
- getClassIds() {
94
- return this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('Class'), null);
95
- }
96
- /**
97
- * Finds all subjects where predicate is 'rdf:type' and object 'owl:DatatypeProperty'
98
- * @returns an array of RDF.NamedNodes
99
- */
100
- getDatatypePropertyIds() {
101
- return this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('DatatypeProperty'), null);
102
- }
103
- /**
104
- * Finds all subjects where predicate is 'rdf:type' and object 'owl:ObjectProperty'
105
- * @returns an array of RDF.NamedNodes
106
- */
107
- getObjectPropertyIds() {
108
- return this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('ObjectProperty'), null);
109
- }
110
- /**
111
- * For a given subject, the quad store is queried to find the assigned URI
112
- * @param subject The subject for which the assigned URI is to be retrieved
113
- * @param store The quad store
114
- * @returns An RDF.NamedNode or undefined if not found
115
- */
116
- getAssignedUri(subject) {
117
- return this.store.getObjects(subject, namespaces_1.ns.example('assignedUri'), null).shift();
118
- }
119
- /**
120
- * Find all rdfs:labels for a given subject
121
- * @param subject The RDF.Term to find the rdfs:labels for
122
- * @param store A N3 quad store
123
- * @returns An array of RDF.Literals
124
- */
125
- getLabels(subject) {
126
- return this.store.getObjects(subject, namespaces_1.ns.rdfs('label'), null);
127
- }
128
- /**
129
- * Finds the rdfs:label whose language tag matches the given language
130
- * @param subject The RDF.Term to find the rdfs:label for
131
- * @param store A N3 quad store
132
- * @param language A language tag
133
- * @returns An RDF.Literal or undefined if not found
134
- */
135
- getLabel(subject, language) {
136
- return this.getLabels(subject).find(x => x.language === (language || ''));
137
- }
138
- /**
139
- * Find all rdfs:comments for a given subject
140
- * @param subject The RDF.Term to find the rdfs:comments for
141
- * @param store A N3 quad store
142
- * @returns An array of RDF.Literals
143
- */
144
- getDefinitions(subject) {
145
- return this.store.getObjects(subject, namespaces_1.ns.rdfs('comment'), null);
146
- }
147
- /**
148
- * Finds the rdfs:comment whose language tag matches the given language
149
- * @param subject The RDF.Term to find the rdfs:comment for
150
- * @param store A N3 quad store
151
- * @param language A language tag
152
- * @returns An RDF.Literal or undefined if not found
153
- */
154
- getDefinition(subject, language) {
155
- return this.getDefinitions(subject).find(x => x.language === (language || ''));
156
- }
157
- /**
158
- * Finds the rdfs:range of a given RDF.Term
159
- * @param subject The RDF.Term to find the range of
160
- * @param store A N3 quad store
161
- * @returns An RDF.Term or undefined if not found
162
- */
163
- getRange(subject) {
164
- return this.store.getObjects(subject, namespaces_1.ns.rdfs('range'), null).shift();
165
- }
166
- /**
167
- * Finds the rdfs:domain of a given RDF.Term
168
- * @param subject The RDF.Term to find the domain of
169
- * @param store A N3 quad store
170
- * @returns An RDF.Term or undefined if not found
171
- */
172
- getDomain(subject) {
173
- return this.store.getObjects(subject, namespaces_1.ns.rdfs('domain'), null).shift();
174
- }
175
- /**
176
- * Finds all the vann:usageNotes of a given RDF.Term
177
- * @param subject The RDF.Term to find the usage notes for
178
- * @param store A N3 quad store
179
- * @returns An array of RDF.Literals
180
- */
181
- getUsageNotes(subject) {
182
- return this.store.getObjects(subject, namespaces_1.ns.vann('usageNote'), null);
183
- }
184
- /**
185
- * Finds the vann:usageNote of which the language tag matches the given language
186
- * @param subject The RDF.Term to find the usage note for
187
- * @param store A N3 quad store
188
- * @param language A language tag
189
- * @returns An RDF.Literal or undefined if not found
190
- */
191
- getUsageNote(subject, language) {
192
- return this.getUsageNotes(subject).find(x => x.language === (language || ''));
193
- }
194
- /**
195
- * Finds the example:scope of a given subject
196
- * @param subject The RDF.Term to find the scope for
197
- * @returns An RDF.NamedNode or undefined if not found
198
- */
199
- getScope(subject) {
200
- return this.store.getObjects(subject, namespaces_1.ns.example('scope'), null).shift();
201
- }
202
- /**
203
- * Finds the shacl:minCardinality for a given subject
204
- * @param subject The RDF.Term to find the shacl:minCardinaly for
205
- * @returns An RDF.Literal or undefined if not found
206
- */
207
- getMinCardinality(subject) {
208
- return this.store.getObjects(subject, namespaces_1.ns.shacl('minCount'), null).shift();
209
- }
210
- /**
211
- * Finds the shacl:maxCardinality for a given subject
212
- * @param subject The RDF.Term to find the shacl:maxCardinaly for
213
- * @returns An RDF.Literal or undefined if not found
214
- */
215
- getMaxCardinality(subject) {
216
- return this.store.getObjects(subject, namespaces_1.ns.shacl('maxCount'), null).shift();
217
- }
218
- /**
219
- * Finds all the rdfs:subClassOf of a given RDF.Term
220
- * @param subject the RDF.Term to find the parents of
221
- * @param store A N3 quad store
222
- * @returns An array of RDF.Terms
223
- */
224
- getParentsOfClass(subject) {
225
- return this.store.getObjects(subject, namespaces_1.ns.rdfs('subClassOf'), null);
226
- }
227
- /**
228
- * Finds the rdfs:subPropertyOf of a given RDF.Term
229
- * @param subject The RDF.Term to find the parent of
230
- * @param store A N3 quad store
231
- * @returns An RDF.Term or undefined if not found
232
- */
233
- getParentOfProperty(subject) {
234
- return this.store.getObjects(subject, namespaces_1.ns.rdfs('subPropertyOf'), null).shift();
235
- }
236
- /**
237
- * Find the subject of the statement that matches the given subject, predicate and object
238
- * @param statementSubject The subject to match the statement subject
239
- * @param statementPredicate The predicate to match the statement predicate
240
- * @param statementObject The object to match the statement object
241
- * @param store An N3 quad store
242
- * @returns an RDF.Term or undefined if none found
243
- */
244
- getTargetStatementId(statementSubject, statementPredicate, statementObject) {
245
- const statementIds = this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.rdf('Statement'), null);
246
- const statementSubjectPredicateSubjects = this.store.getSubjects(namespaces_1.ns.rdf('subject'), statementSubject, null);
247
- const statementPredicatePredicateSubjects = this.store.getSubjects(namespaces_1.ns.rdf('predicate'), statementPredicate, null);
248
- const statementObjectPredicateSubjects = this.store.getSubjects(namespaces_1.ns.rdf('object'), statementObject, null);
249
- const targetIds = statementIds
250
- .filter(x => statementSubjectPredicateSubjects.some(y => y.value === x.value))
251
- .filter(x => statementPredicatePredicateSubjects.some(y => y.value === x.value))
252
- .filter(x => statementObjectPredicateSubjects.some(y => y.value === x.value));
253
- if (targetIds.length > 1) {
254
- throw new Error(`Found multiple statements with subject "${statementSubject.value}", predicate "${statementPredicate.value}" and object "${statementObject.value}".`);
255
- }
256
- return targetIds.shift();
257
- }
258
- /**
259
- * Finds the assigned URI in rdf:Statements
260
- * @param subject The statement subject
261
- * @param predicate The statement predicate
262
- * @param object The statement object for which the assigned URI must be found
263
- * @param store A N3 quad store
264
- * @returns An RDF.Term or undefined if not found
265
- */
266
- getAssignedUriViaStatements(subject, predicate, object) {
267
- const statementId = this.getTargetStatementId(subject, predicate, object);
268
- if (!statementId) {
269
- return undefined;
270
- }
271
- return this.getAssignedUri(statementId);
272
- }
273
- /**
274
- * Finds the rdfs:label for an RDF.Term in rdf:Statements
275
- * @param subject The statement subject
276
- * @param predicate The statement predicate
277
- * @param object The statement object for which the label must be found
278
- * @param store A N3 quad store
279
- * @param language A language tag
280
- * @returns An RDF.Literal or undefined if not found
281
- */
282
- getLabelViaStatements(subject, predicate, object, language) {
283
- const statementId = this.getTargetStatementId(subject, predicate, object);
284
- if (!statementId) {
285
- return undefined;
286
- }
287
- const label = this.getLabel(statementId, language);
288
- return label || this.getLabel(statementId);
289
- }
290
- /**
291
- * Finds the rdfs:comment for an RDF.Term in rdf:Statements
292
- * @param subject The statement subject
293
- * @param predicate The statement predicate
294
- * @param object The statement object for which the definition must be found
295
- * @param store A N3 quad store
296
- * @param language A language tag
297
- * @returns An RDF.Literal or undefined if not found
298
- */
299
- getDefinitionViaStatements(subject, predicate, object, language) {
300
- const statementId = this.getTargetStatementId(subject, predicate, object);
301
- if (!statementId) {
302
- return undefined;
303
- }
304
- const definition = this.getDefinition(statementId, language);
305
- return definition || this.getDefinition(statementId);
306
- }
307
- /**
308
- * Finds the vann:usageNote for an RDF.Term in rdf:Statements
309
- * @param subject The statement subject
310
- * @param predicate The statement predicate
311
- * @param object The statement object for which the usage note must be found
312
- * @param store A N3 quad store
313
- * @param language A language tag
314
- * @returns An RDF.Literal or undefined if not found
315
- */
316
- getUsageNoteViaStatements(subject, predicate, object, language) {
317
- const statementId = this.getTargetStatementId(subject, predicate, object);
318
- if (!statementId) {
319
- return undefined;
320
- }
321
- const usageNote = this.getUsageNote(statementId, language);
322
- return usageNote || this.getUsageNote(statementId);
323
- }
324
- };
325
- QuadStore = __decorate([
326
- (0, inversify_1.injectable)(),
327
- __metadata("design:paramtypes", [])
328
- ], QuadStore);
329
- exports.QuadStore = QuadStore;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.QuadStore = void 0;
39
+ const inversify_1 = require("inversify");
40
+ const N3 = __importStar(require("n3"));
41
+ const rdf_parse_1 = __importDefault(require("rdf-parse"));
42
+ const fetchFileOrUrl_1 = require("@oslo-core/utils/fetchFileOrUrl");
43
+ const namespaces_1 = require("@oslo-core/utils/namespaces");
44
+ let QuadStore = class QuadStore {
45
+ constructor() {
46
+ this.store = new N3.Store();
47
+ }
48
+ addQuads(quads) {
49
+ this.store.addQuads(quads);
50
+ }
51
+ addQuad(quad) {
52
+ this.store.addQuad(quad);
53
+ }
54
+ async addQuadsFromFile(file) {
55
+ const buffer = await (0, fetchFileOrUrl_1.fetchFileOrUrl)(file);
56
+ const textStream = require('streamify-string')(buffer.toString());
57
+ return new Promise((resolve, reject) => {
58
+ rdf_parse_1.default
59
+ .parse(textStream, { path: file })
60
+ .on('data', (quad) => this.store.addQuad(quad))
61
+ .on('error', (error) => reject(error))
62
+ .on('end', () => resolve());
63
+ });
64
+ }
65
+ findQuads(subject, predicate, object, graph = null) {
66
+ return this.store.getQuads(subject, predicate, object, graph);
67
+ }
68
+ findQuad(subject, predicate, object, graph = null) {
69
+ return this.findQuads(subject, predicate, object, graph).shift();
70
+ }
71
+ findSubjects(predicate, object, graph = null) {
72
+ return this.store.getSubjects(predicate, object, graph);
73
+ }
74
+ findSubject(predicate, object, graph = null) {
75
+ return this.findSubjects(predicate, object, graph).shift();
76
+ }
77
+ findObjects(subject, predicate, graph = null) {
78
+ return this.store.getObjects(subject, predicate, graph);
79
+ }
80
+ findObject(subject, predicate, graph = null) {
81
+ return this.findObjects(subject, predicate, graph).shift();
82
+ }
83
+ /**
84
+ * Finds the subject where predicate is 'rdf:type' and object 'oslo:Package'
85
+ * @returns a RDF.NamedNode or undefined
86
+ */
87
+ getPackageId() {
88
+ return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.oslo('Package'), null).shift());
89
+ }
90
+ /**
91
+ * Finds all subjects where predicate is 'rdf:type' and object 'owl:Class'
92
+ * @returns an array of RDF.NamedNodes
93
+ */
94
+ getClassIds(graph = null) {
95
+ return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('Class'), graph));
96
+ }
97
+ /**
98
+ * Finds all subjects where predicate is 'rdf:type' and object 'owl:DatatypeProperty'
99
+ * @returns an array of RDF.NamedNodes
100
+ */
101
+ getDatatypePropertyIds(graph = null) {
102
+ return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('DatatypeProperty'), graph));
103
+ }
104
+ /**
105
+ * Finds all subjects where predicate is 'rdf:type' and object 'owl:ObjectProperty'
106
+ * @returns an array of RDF.NamedNodes
107
+ */
108
+ getObjectPropertyIds(graph = null) {
109
+ return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('ObjectProperty'), graph));
110
+ }
111
+ /**
112
+ * For a given subject, the quad store is queried to find the assigned URI
113
+ * @param subject The subject for which the assigned URI is to be retrieved
114
+ * @param store The quad store
115
+ * @returns An RDF.NamedNode or undefined if not found
116
+ */
117
+ getAssignedUri(subject, graph = null) {
118
+ return (this.store.getObjects(subject, namespaces_1.ns.oslo('assignedURI'), graph).shift());
119
+ }
120
+ /**
121
+ * Find all quads with a label predicate (vocLabel, apLabel and diagramLabel) for a given subject
122
+ * @param subject The RDF.Term to find the labels for
123
+ * @param store A N3 quad store
124
+ * @returns An array of RDF.Quads
125
+ */
126
+ getLabels(subject, graph = null) {
127
+ const vocLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('vocLabel'), null, graph);
128
+ const apLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('apLabel'), null, graph);
129
+ const diagramLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('diagramLabel'), null, graph);
130
+ return vocLabel.concat(apLabel).concat(diagramLabel);
131
+ }
132
+ /**
133
+ * Finds the oslo:vocLabel whose language tag matches the given language
134
+ * @param subject The RDF.Term to find the oslo:vocLabel for
135
+ * @param store A N3 quad store
136
+ * @param language A language tag
137
+ * @returns An RDF.Literal or undefined if not found
138
+ */
139
+ getVocLabel(subject, language, graph = null) {
140
+ var _a;
141
+ return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocLabel')) &&
142
+ x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
143
+ }
144
+ /**
145
+ * Finds the oslo:apLabel whose language tag matches the given language
146
+ * @param subject The RDF.Term to find the oslo:apLabel for
147
+ * @param store A N3 quad store
148
+ * @param language A language tag
149
+ * @returns An RDF.Literal or undefined if not found
150
+ */
151
+ getApLabel(subject, language, graph = null) {
152
+ var _a;
153
+ return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apLabel')) &&
154
+ x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
155
+ }
156
+ /**
157
+ * Finds the oslo:diagramLabel for a given subject
158
+ * @param subject The RDF.Term to find the oslo:diagramLabel for
159
+ * @param store A N3 quad store
160
+ * @param language A language tag
161
+ * @returns An RDF.Literal or undefined if not found
162
+ */
163
+ getDiagramLabel(subject, graph = null) {
164
+ var _a;
165
+ return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('diagramLabel')))) === null || _a === void 0 ? void 0 : _a.object;
166
+ }
167
+ /**
168
+ * Find all definitions for a given subject
169
+ * @param subject The RDF.Term to find the definitions for
170
+ * @param store A N3 quad store
171
+ * @returns An array of RDF.Literals
172
+ */
173
+ getDefinitions(subject, graph = null) {
174
+ const vocDefinitions = this.store.getQuads(subject, namespaces_1.ns.oslo('vocDefinition'), null, graph);
175
+ const apDefinitions = this.store.getQuads(subject, namespaces_1.ns.oslo('apDefinition'), null, graph);
176
+ return vocDefinitions.concat(apDefinitions);
177
+ }
178
+ /**
179
+ * Finds the oslo:vocDefinition whose language tag matches the given language
180
+ * @param subject The RDF.Term to find the oslo:vocDefinition for
181
+ * @param store A N3 quad store
182
+ * @param language A language tag
183
+ * @returns An RDF.Literal or undefined if not found
184
+ */
185
+ getVocDefinition(subject, language, graph = null) {
186
+ var _a;
187
+ return (_a = this.getDefinitions(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocDefinition')) &&
188
+ x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
189
+ }
190
+ /**
191
+ * Finds the oslo:apDefinition whose language tag matches the given language
192
+ * @param subject The RDF.Term to find the oslo:apDefinition for
193
+ * @param store A N3 quad store
194
+ * @param language A language tag
195
+ * @returns An RDF.Literal or undefined if not found
196
+ */
197
+ getApDefinition(subject, language, graph = null) {
198
+ var _a;
199
+ return (_a = this.getDefinitions(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apDefinition')) &&
200
+ x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
201
+ }
202
+ /**
203
+ * Finds the rdfs:range of a given RDF.Term
204
+ * @param subject The RDF.Term to find the range of
205
+ * @param store A N3 quad store
206
+ * @returns An RDF.Term or undefined if not found
207
+ */
208
+ getRange(subject, graph = null) {
209
+ return (this.store.getObjects(subject, namespaces_1.ns.rdfs('range'), graph).shift());
210
+ }
211
+ /**
212
+ * Finds the rdfs:domain of a given RDF.Term
213
+ * @param subject The RDF.Term to find the domain of
214
+ * @param store A N3 quad store
215
+ * @returns An RDF.Term or undefined if not found
216
+ */
217
+ getDomain(subject, graph = null) {
218
+ return (this.store.getObjects(subject, namespaces_1.ns.rdfs('domain'), graph).shift());
219
+ }
220
+ /**
221
+ * Finds all the usageNotes (voc and ap) of a given RDF.Term
222
+ * @param subject The RDF.Term to find the usage notes for
223
+ * @param store A N3 quad store
224
+ * @returns An array of RDF.Literals
225
+ */
226
+ getUsageNotes(subject, graph = null) {
227
+ const vocUsageNotes = this.store.getQuads(subject, namespaces_1.ns.oslo('vocUsageNote'), null, graph);
228
+ const apUsageNotes = this.store.getQuads(subject, namespaces_1.ns.oslo('apUsageNote'), null, graph);
229
+ return vocUsageNotes.concat(apUsageNotes);
230
+ }
231
+ /**
232
+ * Finds the oslo:vocUsageNote of which the language tag matches the given language
233
+ * @param subject The RDF.Term to find the vocabulary usage note for
234
+ * @param store A N3 quad store
235
+ * @param language A language tag
236
+ * @returns An RDF.Literal or undefined if not found
237
+ */
238
+ getVocUsageNote(subject, language, graph = null) {
239
+ var _a;
240
+ return (_a = this.getUsageNotes(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocUsageNote')) &&
241
+ x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
242
+ }
243
+ /**
244
+ * Finds the oslo:apUsageNote of which the language tag matches the given language
245
+ * @param subject The RDF.Term to find the application profile usage note for
246
+ * @param store A N3 quad store
247
+ * @param language A language tag
248
+ * @returns An RDF.Literal or undefined if not found
249
+ */
250
+ getApUsageNote(subject, language, graph = null) {
251
+ var _a;
252
+ return (_a = this.getUsageNotes(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apUsageNote')) &&
253
+ x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
254
+ }
255
+ /**
256
+ * Finds the example:scope of a given subject
257
+ * @param subject The RDF.Term to find the scope for
258
+ * @returns An RDF.NamedNode or undefined if not found
259
+ */
260
+ getScope(subject, graph = null) {
261
+ return (this.store.getObjects(subject, namespaces_1.ns.oslo('scope'), graph).shift());
262
+ }
263
+ /**
264
+ * Finds the shacl:minCardinality for a given subject
265
+ * @param subject The RDF.Term to find the shacl:minCardinaly for
266
+ * @returns An RDF.Literal or undefined if not found
267
+ */
268
+ getMinCardinality(subject, graph = null) {
269
+ return (this.store.getObjects(subject, namespaces_1.ns.shacl('minCount'), graph).shift());
270
+ }
271
+ /**
272
+ * Finds the shacl:maxCardinality for a given subject
273
+ * @param subject The RDF.Term to find the shacl:maxCardinaly for
274
+ * @returns An RDF.Literal or undefined if not found
275
+ */
276
+ getMaxCardinality(subject, graph = null) {
277
+ return (this.store.getObjects(subject, namespaces_1.ns.shacl('maxCount'), graph).shift());
278
+ }
279
+ /**
280
+ * Finds all the rdfs:subClassOf of a given RDF.Term
281
+ * @param subject the RDF.Term to find the parents of
282
+ * @param store A N3 quad store
283
+ * @returns An array of RDF.Terms
284
+ */
285
+ getParentsOfClass(subject, graph = null) {
286
+ return (this.store.getObjects(subject, namespaces_1.ns.rdfs('subClassOf'), graph));
287
+ }
288
+ /**
289
+ * Finds the rdfs:subPropertyOf of a given RDF.Term
290
+ * @param subject The RDF.Term to find the parent of
291
+ * @param store A N3 quad store
292
+ * @returns An RDF.Term or undefined if not found
293
+ */
294
+ getParentOfProperty(subject, graph = null) {
295
+ return (this.store.getObjects(subject, namespaces_1.ns.rdfs('subPropertyOf'), graph).shift());
296
+ }
297
+ getCodelist(subject, graph = null) {
298
+ return (this.store.getObjects(subject, namespaces_1.ns.oslo('codelist'), graph).shift());
299
+ }
300
+ };
301
+ QuadStore = __decorate([
302
+ (0, inversify_1.injectable)(),
303
+ __metadata("design:paramtypes", [])
304
+ ], QuadStore);
305
+ exports.QuadStore = QuadStore;
330
306
  //# sourceMappingURL=QuadStore.js.map