@faubulous/mentor-rdf 0.2.49 → 0.2.50

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 (154) hide show
  1. package/out/index.d.ts +0 -0
  2. package/out/index.js +1 -1
  3. package/out/ontologies/index.d.ts +0 -0
  4. package/out/ontologies/owl.d.ts +0 -0
  5. package/out/ontologies/rdf.d.ts +0 -0
  6. package/out/ontologies/rdfa.d.ts +0 -0
  7. package/out/ontologies/rdfs.d.ts +0 -0
  8. package/out/ontologies/sh.d.ts +0 -0
  9. package/out/ontologies/skos-xl.d.ts +0 -0
  10. package/out/ontologies/skos.d.ts +0 -0
  11. package/out/ontologies/src.d.ts +0 -0
  12. package/out/ontologies/xsd.d.ts +0 -0
  13. package/out/rdf/class-repository.d.ts +0 -0
  14. package/out/rdf/concept-repository.d.ts +0 -0
  15. package/out/rdf/index.d.ts +0 -0
  16. package/out/rdf/individual-repository.d.ts +0 -0
  17. package/out/rdf/parsers/rdf-syntax.d.ts +0 -0
  18. package/out/rdf/parsers/sparql-syntax-parser.d.ts +0 -0
  19. package/out/rdf/parsers/syntax-parser.d.ts +0 -0
  20. package/out/rdf/parsers/trig-syntax-parser.d.ts +0 -0
  21. package/out/rdf/parsers/turtle-syntax-parser.d.ts +0 -0
  22. package/out/rdf/property-repository.d.ts +0 -0
  23. package/out/rdf/reasoners/owl-reasoner.d.ts +0 -0
  24. package/out/rdf/reasoners/rdfs-reasoner.d.ts +0 -0
  25. package/out/rdf/reasoners/reasoner.d.ts +0 -0
  26. package/out/rdf/reasoners/shacl-reasoner.d.ts +0 -0
  27. package/out/rdf/reasoners/skos-reasoner.d.ts +0 -0
  28. package/out/rdf/resource-repository.d.ts +31 -15
  29. package/out/rdf/shape-repository.d.ts +0 -0
  30. package/out/rdf/store.d.ts +0 -0
  31. package/out/rdf/uri.d.ts +0 -0
  32. package/out/rdf/vocabulary-repository.d.ts +0 -0
  33. package/package.json +66 -66
  34. package/out/index.js.map +0 -1
  35. package/out/ontologies/index.js +0 -44
  36. package/out/ontologies/index.js.map +0 -1
  37. package/out/ontologies/owl.js +0 -322
  38. package/out/ontologies/owl.js.map +0 -1
  39. package/out/ontologies/rdf.js +0 -102
  40. package/out/ontologies/rdf.js.map +0 -1
  41. package/out/ontologies/rdfa.js +0 -56
  42. package/out/ontologies/rdfa.js.map +0 -1
  43. package/out/ontologies/rdfs.js +0 -76
  44. package/out/ontologies/rdfs.js.map +0 -1
  45. package/out/ontologies/sh.js +0 -822
  46. package/out/ontologies/sh.js.map +0 -1
  47. package/out/ontologies/skos-xl.js +0 -40
  48. package/out/ontologies/skos-xl.js.map +0 -1
  49. package/out/ontologies/skos.js +0 -144
  50. package/out/ontologies/skos.js.map +0 -1
  51. package/out/ontologies/src.js +0 -3016
  52. package/out/ontologies/src.js.map +0 -1
  53. package/out/ontologies/xsd.js +0 -108
  54. package/out/ontologies/xsd.js.map +0 -1
  55. package/out/rdf/class-repository.js +0 -324
  56. package/out/rdf/class-repository.js.map +0 -1
  57. package/out/rdf/concept-repository.js +0 -220
  58. package/out/rdf/concept-repository.js.map +0 -1
  59. package/out/rdf/index.js +0 -18
  60. package/out/rdf/index.js.map +0 -1
  61. package/out/rdf/individual-repository.js +0 -77
  62. package/out/rdf/individual-repository.js.map +0 -1
  63. package/out/rdf/parsers/rdf-syntax.js +0 -19
  64. package/out/rdf/parsers/rdf-syntax.js.map +0 -1
  65. package/out/rdf/parsers/sparql-syntax-parser.js +0 -61
  66. package/out/rdf/parsers/sparql-syntax-parser.js.map +0 -1
  67. package/out/rdf/parsers/syntax-parser.js +0 -3
  68. package/out/rdf/parsers/syntax-parser.js.map +0 -1
  69. package/out/rdf/parsers/trig-syntax-parser.js +0 -30
  70. package/out/rdf/parsers/trig-syntax-parser.js.map +0 -1
  71. package/out/rdf/parsers/turtle-syntax-parser.js +0 -30
  72. package/out/rdf/parsers/turtle-syntax-parser.js.map +0 -1
  73. package/out/rdf/property-repository.js +0 -257
  74. package/out/rdf/property-repository.js.map +0 -1
  75. package/out/rdf/reasoners/owl-reasoner.js +0 -218
  76. package/out/rdf/reasoners/owl-reasoner.js.map +0 -1
  77. package/out/rdf/reasoners/rdfs-reasoner.js +0 -144
  78. package/out/rdf/reasoners/rdfs-reasoner.js.map +0 -1
  79. package/out/rdf/reasoners/reasoner.js +0 -106
  80. package/out/rdf/reasoners/reasoner.js.map +0 -1
  81. package/out/rdf/reasoners/shacl-reasoner.js +0 -170
  82. package/out/rdf/reasoners/shacl-reasoner.js.map +0 -1
  83. package/out/rdf/reasoners/skos-reasoner.js +0 -109
  84. package/out/rdf/reasoners/skos-reasoner.js.map +0 -1
  85. package/out/rdf/resource-repository.js +0 -136
  86. package/out/rdf/resource-repository.js.map +0 -1
  87. package/out/rdf/shape-repository.js +0 -298
  88. package/out/rdf/shape-repository.js.map +0 -1
  89. package/out/rdf/store.js +0 -240
  90. package/out/rdf/store.js.map +0 -1
  91. package/out/rdf/tests/helpers.d.ts +0 -39
  92. package/out/rdf/tests/helpers.js +0 -85
  93. package/out/rdf/tests/helpers.js.map +0 -1
  94. package/out/rdf/tests/vocabularies/bfo.d.ts +0 -413
  95. package/out/rdf/tests/vocabularies/bfo.js +0 -418
  96. package/out/rdf/tests/vocabularies/bfo.js.map +0 -1
  97. package/out/rdf/tests/vocabularies/cidoc-crm.d.ts +0 -2101
  98. package/out/rdf/tests/vocabularies/cidoc-crm.js +0 -2106
  99. package/out/rdf/tests/vocabularies/cidoc-crm.js.map +0 -1
  100. package/out/rdf/tests/vocabularies/emmo.d.ts +0 -5525
  101. package/out/rdf/tests/vocabularies/emmo.js +0 -5530
  102. package/out/rdf/tests/vocabularies/emmo.js.map +0 -1
  103. package/out/rdf/tests/vocabularies/fibo-agents.d.ts +0 -17
  104. package/out/rdf/tests/vocabularies/fibo-agents.js +0 -22
  105. package/out/rdf/tests/vocabularies/fibo-agents.js.map +0 -1
  106. package/out/rdf/tests/vocabularies/fibo-organization.d.ts +0 -69
  107. package/out/rdf/tests/vocabularies/fibo-organization.js +0 -74
  108. package/out/rdf/tests/vocabularies/fibo-organization.js.map +0 -1
  109. package/out/rdf/tests/vocabularies/gist.d.ts +0 -1071
  110. package/out/rdf/tests/vocabularies/gist.js +0 -1076
  111. package/out/rdf/tests/vocabularies/gist.js.map +0 -1
  112. package/out/rdf/tests/vocabularies/index.d.ts +0 -17
  113. package/out/rdf/tests/vocabularies/index.js +0 -90
  114. package/out/rdf/tests/vocabularies/index.js.map +0 -1
  115. package/out/rdf/tests/vocabularies/lob.d.ts +0 -5669
  116. package/out/rdf/tests/vocabularies/lob.js +0 -5674
  117. package/out/rdf/tests/vocabularies/lob.js.map +0 -1
  118. package/out/rdf/tests/vocabularies/multi.d.ts +0 -29
  119. package/out/rdf/tests/vocabularies/multi.js +0 -34
  120. package/out/rdf/tests/vocabularies/multi.js.map +0 -1
  121. package/out/rdf/tests/vocabularies/org.d.ts +0 -193
  122. package/out/rdf/tests/vocabularies/org.js +0 -198
  123. package/out/rdf/tests/vocabularies/org.js.map +0 -1
  124. package/out/rdf/tests/vocabularies/owl.d.ts +0 -317
  125. package/out/rdf/tests/vocabularies/owl.js +0 -322
  126. package/out/rdf/tests/vocabularies/owl.js.map +0 -1
  127. package/out/rdf/tests/vocabularies/prov-o.d.ts +0 -391
  128. package/out/rdf/tests/vocabularies/prov-o.js +0 -396
  129. package/out/rdf/tests/vocabularies/prov-o.js.map +0 -1
  130. package/out/rdf/tests/vocabularies/schema-nq.d.ts +0 -12079
  131. package/out/rdf/tests/vocabularies/schema-nq.js +0 -12084
  132. package/out/rdf/tests/vocabularies/schema-nq.js.map +0 -1
  133. package/out/rdf/tests/vocabularies/schema-nt.d.ts +0 -12079
  134. package/out/rdf/tests/vocabularies/schema-nt.js +0 -12084
  135. package/out/rdf/tests/vocabularies/schema-nt.js.map +0 -1
  136. package/out/rdf/tests/vocabularies/schema.d.ts +0 -12079
  137. package/out/rdf/tests/vocabularies/schema.js +0 -12084
  138. package/out/rdf/tests/vocabularies/schema.js.map +0 -1
  139. package/out/rdf/tests/vocabularies/shapes.d.ts +0 -53
  140. package/out/rdf/tests/vocabularies/shapes.js +0 -58
  141. package/out/rdf/tests/vocabularies/shapes.js.map +0 -1
  142. package/out/rdf/tests/vocabularies/skos.d.ts +0 -139
  143. package/out/rdf/tests/vocabularies/skos.js +0 -144
  144. package/out/rdf/tests/vocabularies/skos.js.map +0 -1
  145. package/out/rdf/tests/vocabularies/unesco.d.ts +0 -10517
  146. package/out/rdf/tests/vocabularies/unesco.js +0 -10522
  147. package/out/rdf/tests/vocabularies/unesco.js.map +0 -1
  148. package/out/rdf/uri.js +0 -84
  149. package/out/rdf/uri.js.map +0 -1
  150. package/out/rdf/vocabulary-generator.d.ts +0 -86
  151. package/out/rdf/vocabulary-generator.js +0 -294
  152. package/out/rdf/vocabulary-generator.js.map +0 -1
  153. package/out/rdf/vocabulary-repository.js +0 -121
  154. package/out/rdf/vocabulary-repository.js.map +0 -1
package/out/rdf/uri.js DELETED
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Uri = void 0;
4
- /**
5
- * A helper class for working with URI string.
6
- */
7
- class Uri {
8
- /**
9
- * Get the portion of a URI after the first occurance of '#' or the last occurance of '/'.
10
- * @param uri A URI.
11
- * @returns The label portion of the URI.
12
- */
13
- static getUriLabel(uri) {
14
- let u = uri;
15
- let n = u.indexOf('?');
16
- if (n > -1) {
17
- u = uri.substring(0, n);
18
- }
19
- // If we have namespace URI, return the label of the document or folder.
20
- if (u.endsWith('/') || u.endsWith('#')) {
21
- u = u.substring(0, u.length - 1);
22
- }
23
- let ns = Uri.getNamespaceUri(u);
24
- return ns.length < u.length ? u.replace(ns, "") : undefined;
25
- }
26
- /**
27
- * Get the portion of a URI after the first occurance of '#' or the last occurance of '/'.
28
- * @param uri A URI.
29
- * @returns The namespace portion of the URI.
30
- */
31
- static getNamespaceUri(uri) {
32
- // Remove any query strings from the URI.
33
- let u = uri;
34
- let n = u.indexOf('?');
35
- if (n > -1) {
36
- u = uri.substring(0, n);
37
- }
38
- // Find the first occurance of '#' and return the substring up to that point.
39
- n = u.indexOf('#');
40
- if (n > -1) {
41
- return u.substring(0, n + 1);
42
- }
43
- // Find the last occurance of '/' and return the substring up to that point.
44
- n = u.lastIndexOf('/');
45
- // Only return the substring if it is not the 'http://' or 'https://' protocol.
46
- if (n > 8) {
47
- return u.substring(0, n + 1);
48
- }
49
- else {
50
- return u + "/";
51
- }
52
- }
53
- /**
54
- * Get a transformed version of the URI that can be used as a JSON identifier which only contains letters, numbers and dots.
55
- * @param uri A URI.
56
- * @returns A transformed version which only contains letters, numbers and dots.
57
- */
58
- static toJsonId(uri) {
59
- let u = uri.split('//')[1];
60
- if (u) {
61
- u = u.replace(/[^a-zA-Z0-9]/g, '.');
62
- return u.endsWith('.') ? u.slice(0, -1) : u;
63
- }
64
- else {
65
- return undefined;
66
- }
67
- }
68
- /**
69
- * Get a normalized version of the URI which removes any trailing slashes or hashes.
70
- * @param uri A URI.
71
- * @returns A normalized URI.
72
- */
73
- static getNormalizedUri(uri) {
74
- let u = uri.split('?')[0];
75
- if (u.endsWith('/') || u.endsWith('#')) {
76
- return u.substring(0, u.length - 1);
77
- }
78
- else {
79
- return u;
80
- }
81
- }
82
- }
83
- exports.Uri = Uri;
84
- //# sourceMappingURL=uri.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uri.js","sourceRoot":"","sources":["../../src/rdf/uri.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,GAAG;IACZ;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,GAAW;QAC1B,IAAI,CAAC,GAAG,GAAG,CAAC;QACZ,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEvB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACT,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAA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AAO,CAAC,GAAG,GAAG,CAAC;QACnB,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAW;QACvB,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAE3B,IAAI,CAAC,EAAE,CAAC;YACJ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;YAEpC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACJ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAW;QAC/B,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1B,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;CACJ;AAvFD,kBAuFC"}
@@ -1,86 +0,0 @@
1
- /**
2
- * A generator for TypeScript vocabulary files.
3
- */
4
- export declare class VocabularyGenerator {
5
- /**
6
- * The supported RDF file extensions.
7
- */
8
- private readonly _supportedExtensions;
9
- /**
10
- * The predicates that are used to describe a subject.
11
- */
12
- private readonly _descriptionPredicates;
13
- /**
14
- * Get a valid TypeScript identifier from a string.
15
- * @param str The filename to generate a prefix from.
16
- * @returns A valid TypeScript identifier.
17
- */
18
- private _getTypescriptIdentifier;
19
- /**
20
- * Get the subject of a quad as a named node.
21
- * @param quad A quad.
22
- * @returns A named node if the given quad describes a subject, otherwise undefined.
23
- */
24
- private _getNamedSubject;
25
- /**
26
- * Get the description of a subject from a quad, if any.
27
- * @param quad A quad.
28
- * @returns A literal if the given quad describes a subject, otherwise undefined.
29
- */
30
- private _getDescription;
31
- /**
32
- * Parse the label of a URI.
33
- * @param subject A URI.
34
- * @returns The label of the URI.
35
- */
36
- private _getLabel;
37
- /**
38
- * Write a namespace to a TypeScript file.
39
- * @param stream A writable stream to the target file.
40
- * @param prefix Namespace prefix of the vocabulary.
41
- * @param namespaceUri URI of the namespace.
42
- */
43
- private _writeNamespace;
44
- /**
45
- * Write a vocabulary to a TypeScript file given a function for serializing the URI of a subject.
46
- * @param stream A writable stream to the target file.
47
- * @param prefix Namespace prefix of the vocabulary.
48
- * @param subjects URIs of the subjects to serialize.
49
- * @param value A function that serializes a URI.
50
- */
51
- private _writeVocabulary;
52
- /**
53
- * Get the most used namespace of the given subjects.
54
- * @param subjects URIs of the subjects.
55
- * @returns The most common namespace of the subjects.
56
- */
57
- private _getVocabularyNamespace;
58
- /**
59
- * Serialize a vocabulary to a TypeScript file.
60
- * @param outputStream A writable stream to the target file.
61
- * @param prefix Namespace prefix of the vocabulary.
62
- * @param subjects URIs of the subjects to serialize.
63
- */
64
- private _serialize;
65
- /**
66
- * Create an index.ts file for the given modules.
67
- * @param path Directory of the index.ts file.
68
- * @param modules Array of modules to export.
69
- */
70
- private _serializeIndex;
71
- private _writeSourceIndex;
72
- /**
73
- * Parse a single RDF file and generate a TypeScript vocabulary file.
74
- * @param path Path of the RDF file to parse.
75
- * @returns Path of the generated TypeScript file.
76
- */
77
- parseFile(path: string): Promise<string>;
78
- /**
79
- * Generate TypeScript vocabulary files for all RDF files in the given directory.
80
- * @param path Path of the directory to parse.
81
- * @param createIndex Indicate if an index.ts file should be created.
82
- * @param createSourceIndex Indicate if a src.ts file should be created.
83
- * @returns An array of paths to the generated files.
84
- */
85
- parseDirectory(path: string, createIndex?: boolean, createSourceIndex?: boolean): Promise<string[]>;
86
- }
@@ -1,294 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VocabularyGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("fs"));
6
- const n3 = tslib_1.__importStar(require("n3"));
7
- const path_1 = require("path");
8
- const uri_1 = require("./uri");
9
- /**
10
- * A generator for TypeScript vocabulary files.
11
- */
12
- class VocabularyGenerator {
13
- constructor() {
14
- /**
15
- * The supported RDF file extensions.
16
- */
17
- this._supportedExtensions = new Set([
18
- ".ttl",
19
- ".trig",
20
- ".n3",
21
- ".nt",
22
- ".nq"
23
- ]);
24
- /**
25
- * The predicates that are used to describe a subject.
26
- */
27
- this._descriptionPredicates = new Set([
28
- "http://www.w3.org/2000/01/rdf-schema#comment",
29
- "http://www.w3.org/2004/02/skos/core#definition",
30
- "http://www.w3.org/2004/02/skos/core#scopeNote",
31
- ]);
32
- }
33
- /**
34
- * Get a valid TypeScript identifier from a string.
35
- * @param str The filename to generate a prefix from.
36
- * @returns A valid TypeScript identifier.
37
- */
38
- _getTypescriptIdentifier(str) {
39
- return str.replace(/[^a-zA-Z0-9_]/g, '_');
40
- }
41
- /**
42
- * Get the subject of a quad as a named node.
43
- * @param quad A quad.
44
- * @returns A named node if the given quad describes a subject, otherwise undefined.
45
- */
46
- _getNamedSubject(quad) {
47
- if (quad.subject.termType == "NamedNode") {
48
- return quad.subject.value;
49
- }
50
- else {
51
- return undefined;
52
- }
53
- }
54
- /**
55
- * Get the description of a subject from a quad, if any.
56
- * @param quad A quad.
57
- * @returns A literal if the given quad describes a subject, otherwise undefined.
58
- */
59
- _getDescription(quad) {
60
- if (this._descriptionPredicates.has(quad.predicate.value)) {
61
- return quad.object;
62
- }
63
- }
64
- /**
65
- * Parse the label of a URI.
66
- * @param subject A URI.
67
- * @returns The label of the URI.
68
- */
69
- _getLabel(subject) {
70
- let result = undefined;
71
- let n = subject.lastIndexOf('#');
72
- if (n > 0) {
73
- result = subject.slice(n + 1);
74
- }
75
- else {
76
- n = subject.lastIndexOf('/');
77
- if (n > 0) {
78
- result = subject.slice(n + 1);
79
- }
80
- }
81
- if (result && /^\d/.test(result)) {
82
- result = '_' + result;
83
- }
84
- return result;
85
- }
86
- /**
87
- * Write a namespace to a TypeScript file.
88
- * @param stream A writable stream to the target file.
89
- * @param prefix Namespace prefix of the vocabulary.
90
- * @param namespaceUri URI of the namespace.
91
- */
92
- _writeNamespace(stream, prefix, namespaceUri, value = s => s) {
93
- stream.write(`/** Namespace URI of the ${prefix} vocabulary. */\n`);
94
- stream.write(`export const _${prefix} = ${value(namespaceUri)};\n\n`);
95
- }
96
- /**
97
- * Write a vocabulary to a TypeScript file given a function for serializing the URI of a subject.
98
- * @param stream A writable stream to the target file.
99
- * @param prefix Namespace prefix of the vocabulary.
100
- * @param subjects URIs of the subjects to serialize.
101
- * @param value A function that serializes a URI.
102
- */
103
- _writeVocabulary(stream, prefix, subjects, value) {
104
- stream.write(`export const ${prefix} = {`);
105
- for (var s of Object.keys(subjects).filter(s => s).sort()) {
106
- var definitions = subjects[s];
107
- var comment = definitions.find(l => l.language == "en");
108
- if (!comment) {
109
- comment = definitions.find(l => !l.language);
110
- }
111
- var label = this._getLabel(s);
112
- if (!label) {
113
- continue;
114
- }
115
- if (comment) {
116
- stream.write(`\n\t/** ${comment.value} */`);
117
- }
118
- label = this._getTypescriptIdentifier(label);
119
- stream.write(`\n\t'${label}': ${value(s)},`);
120
- }
121
- stream.write(`\n}`);
122
- }
123
- /**
124
- * Get the most used namespace of the given subjects.
125
- * @param subjects URIs of the subjects.
126
- * @returns The most common namespace of the subjects.
127
- */
128
- _getVocabularyNamespace(subjects) {
129
- let namespaces = {};
130
- for (let s of subjects) {
131
- let ns = uri_1.Uri.getNamespaceUri(s);
132
- if (!namespaces[ns]) {
133
- namespaces[ns] = 0;
134
- }
135
- namespaces[ns] += 1;
136
- }
137
- return Object.keys(namespaces).sort((a, b) => namespaces[b] - namespaces[a])[0];
138
- }
139
- /**
140
- * Serialize a vocabulary to a TypeScript file.
141
- * @param outputStream A writable stream to the target file.
142
- * @param prefix Namespace prefix of the vocabulary.
143
- * @param subjects URIs of the subjects to serialize.
144
- */
145
- _serialize(inputStream, outputStream, prefix, subjects) {
146
- outputStream.write(`import * as n3 from "n3";\n\n`);
147
- const ns = this._getVocabularyNamespace(Object.keys(subjects));
148
- if (!ns) {
149
- throw new Error("Unable to determine the vocabulary namespace.");
150
- }
151
- const p = this._getTypescriptIdentifier(prefix);
152
- this._writeNamespace(outputStream, p.toUpperCase(), ns, ns => `'${ns}'`);
153
- this._writeVocabulary(outputStream, p.toUpperCase(), subjects, s => `'${s}'`);
154
- outputStream.write(`\n\n`);
155
- this._writeNamespace(outputStream, p.toLowerCase(), ns, ns => `new n3.NamedNode('${ns}')`);
156
- this._writeVocabulary(outputStream, p.toLowerCase(), subjects, s => `new n3.NamedNode('${s}')`);
157
- }
158
- /**
159
- * Create an index.ts file for the given modules.
160
- * @param path Directory of the index.ts file.
161
- * @param modules Array of modules to export.
162
- */
163
- _serializeIndex(path, modules) {
164
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
165
- return new Promise((resolve, reject) => {
166
- let data = '';
167
- for (let m of modules.map(x => (0, path_1.basename)(x))) {
168
- let name = (0, path_1.parse)(m).name;
169
- let id = this._getTypescriptIdentifier(name);
170
- data += `export { ${id.toUpperCase()}, _${id.toUpperCase()}, ${id.toLowerCase()}, _${id.toLowerCase()} } from './${name}';\n`;
171
- }
172
- const file = (0, path_1.join)(path, "index.ts");
173
- const stream = fs.createWriteStream(file);
174
- stream.write(data, "utf8", (error) => {
175
- if (error) {
176
- fs.unlinkSync(file);
177
- reject(error);
178
- }
179
- else {
180
- stream.end(() => resolve());
181
- }
182
- });
183
- });
184
- });
185
- }
186
- _writeSourceIndex(path) {
187
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
188
- return new Promise((resolve, reject) => {
189
- // Note: We append the raw source to an index file so the store can
190
- // read it into a stream without needing file system access. However, we
191
- // append the raw source file that is not exported by the index.ts file
192
- // to avoid breaking anything when the source file is corrupt for some reason.
193
- let data = '';
194
- for (let file of fs.readdirSync(path)) {
195
- const ext = (0, path_1.extname)(file);
196
- if (this._supportedExtensions.has(ext)) {
197
- const prefix = this._getTypescriptIdentifier((0, path_1.parse)(file).name);
198
- let content = fs.readFileSync((0, path_1.join)(path, file)).toString();
199
- content = content.replace(/\\"/g, "'");
200
- data += `export const ${prefix} = \``;
201
- data += content;
202
- data += '`;\n\n';
203
- }
204
- }
205
- const file = (0, path_1.join)(path, "src.ts");
206
- const stream = fs.createWriteStream(file);
207
- stream.write(data, "utf8", (error) => {
208
- if (error) {
209
- fs.unlinkSync(file);
210
- reject(error);
211
- }
212
- else {
213
- stream.end(() => resolve());
214
- }
215
- });
216
- });
217
- });
218
- }
219
- /**
220
- * Parse a single RDF file and generate a TypeScript vocabulary file.
221
- * @param path Path of the RDF file to parse.
222
- * @returns Path of the generated TypeScript file.
223
- */
224
- parseFile(path) {
225
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
226
- return new Promise((resolve, reject) => {
227
- const directory = (0, path_1.dirname)(path);
228
- const prefix = (0, path_1.parse)(path).name;
229
- const result = (0, path_1.join)(directory, prefix + '.ts');
230
- const input = fs.createReadStream(path);
231
- const output = fs.createWriteStream(result);
232
- const subjects = {};
233
- new n3.Parser().parse(input, (error, quad, done) => {
234
- if (quad) {
235
- const s = this._getNamedSubject(quad);
236
- if (s) {
237
- // If the key is not yet in the dictionary, add it.
238
- if (!subjects[s]) {
239
- subjects[s] = [];
240
- }
241
- const o = this._getDescription(quad);
242
- // If there is a description, add it to the array.
243
- if (o) {
244
- subjects[s].push(o);
245
- }
246
- }
247
- }
248
- else if (error) {
249
- input.close();
250
- output.close();
251
- fs.unlinkSync(result);
252
- reject(error);
253
- }
254
- else if (done) {
255
- console.log(`Writing ${result}..`);
256
- this._serialize(input, output, prefix, subjects);
257
- input.close();
258
- output.close();
259
- resolve(result);
260
- }
261
- });
262
- });
263
- });
264
- }
265
- /**
266
- * Generate TypeScript vocabulary files for all RDF files in the given directory.
267
- * @param path Path of the directory to parse.
268
- * @param createIndex Indicate if an index.ts file should be created.
269
- * @param createSourceIndex Indicate if a src.ts file should be created.
270
- * @returns An array of paths to the generated files.
271
- */
272
- parseDirectory(path_2) {
273
- return tslib_1.__awaiter(this, arguments, void 0, function* (path, createIndex = false, createSourceIndex = false) {
274
- const result = [];
275
- for (let file of fs.readdirSync(path)) {
276
- const ext = (0, path_1.extname)(file);
277
- if (this._supportedExtensions.has(ext)) {
278
- const f = yield this.parseFile((0, path_1.join)(path, file));
279
- result.push(f);
280
- }
281
- }
282
- ;
283
- if (createIndex) {
284
- yield this._serializeIndex(path, result);
285
- }
286
- if (createSourceIndex) {
287
- yield this._writeSourceIndex(path);
288
- }
289
- return result;
290
- });
291
- }
292
- }
293
- exports.VocabularyGenerator = VocabularyGenerator;
294
- //# sourceMappingURL=vocabulary-generator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vocabulary-generator.js","sourceRoot":"","sources":["../../src/rdf/vocabulary-generator.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,+CAAyB;AACzB,+BAA+D;AAE/D,+BAA4B;AAE5B;;GAEG;AACH,MAAa,mBAAmB;IAAhC;QACI;;WAEG;QACc,yBAAoB,GAAG,IAAI,GAAG,CAAS;YACpD,MAAM;YACN,OAAO;YACP,KAAK;YACL,KAAK;YACL,KAAK;SACR,CAAC,CAAC;QAEH;;WAEG;QACc,2BAAsB,GAAG,IAAI,GAAG,CAAS;YACtD,8CAA8C;YAC9C,gDAAgD;YAChD,+CAA+C;SAClD,CAAC,CAAC;IAuTP,CAAC;IArTG;;;;OAIG;IACK,wBAAwB,CAAC,GAAW;QACxC,OAAO,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAC9C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IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oBAEjD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACnB,CAAC;YACL,CAAC;YAAA,CAAC;YAEF,IAAI,WAAW,EAAE,CAAC;gBACd,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC7C,CAAC;YAED,IAAI,iBAAiB,EAAE,CAAC;gBACpB,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;KAAA;CACJ;AA1UD,kDA0UC"}
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VocabularyRepository = void 0;
4
- const tslib_1 = require("tslib");
5
- const n3 = tslib_1.__importStar(require("n3"));
6
- const ontologies_1 = require("../ontologies");
7
- const uri_1 = require("./uri");
8
- const shape_repository_1 = require("./shape-repository");
9
- /**
10
- * A repository for retrieving ontologies and ontology concepts from graphs.
11
- */
12
- class VocabularyRepository extends shape_repository_1.ShapeRepository {
13
- /**
14
- * Get all concept schemes in the repository.
15
- * @param graphUris URIs of the graphs to search.
16
- * @returns A list of all concept schemes in the repository.
17
- */
18
- getConceptSchemes(graphUris) {
19
- const result = new Set();
20
- for (const q of this.store.match(graphUris, null, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme)) {
21
- const s = q.subject;
22
- if (s.termType != "NamedNode") {
23
- continue;
24
- }
25
- result.add(s.value);
26
- }
27
- return Array.from(result);
28
- }
29
- /**
30
- * Indicates whether the repository contains any concept schemes.
31
- * @param graphUris URIs of the graphs to search.
32
- * @returns `true` if the repository contains any concept schemes, `false` otherwise.
33
- */
34
- hasConceptSchemes(graphUris) {
35
- return this.getConceptSchemes(graphUris).length > 0;
36
- }
37
- /**
38
- * Get all ontologies in the repository.
39
- * @param graphUris URIs of the graphs to search.
40
- * @returns A list of all ontologies in the repository.
41
- */
42
- getOntologies(graphUris) {
43
- const result = new Set();
44
- for (const q of this.store.match(graphUris, null, ontologies_1.rdf.type, ontologies_1.owl.Ontology)) {
45
- const s = q.subject;
46
- if (s.termType != "NamedNode") {
47
- continue;
48
- }
49
- result.add(s.value);
50
- }
51
- return Array.from(result);
52
- }
53
- /**
54
- * Indicates whether the repository contains any ontology headers.
55
- * @param graphUris URIs of the graphs to search.
56
- * @returns `true` if the repository contains any ontology headers, `false` otherwise.
57
- */
58
- hasOntologies(graphUris) {
59
- return this.getOntologies(graphUris).length > 0;
60
- }
61
- /**
62
- * 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".
63
- * @param graphUris URIs of the graphs to search.
64
- * @param ontologyUri URI of the ontology.
65
- * @returns The version of the ontology, or undefined if it is not found.
66
- */
67
- getOntologyVersionInfo(graphUris, ontologyUri) {
68
- const s = new n3.NamedNode(ontologyUri);
69
- for (const q of this.store.match(graphUris, s, ontologies_1.owl.versionInfo, null)) {
70
- // If the version is a date, return it in the format "YYYY-MM-DD".
71
- const match = q.object.value.match(/(\d{4}[\/-]\d{2}[\/-]\d{2})/);
72
- if (match && match.length > 1) {
73
- return new Date(match[1]).toISOString().substring(0, 10);
74
- }
75
- else {
76
- return q.object.value;
77
- }
78
- }
79
- }
80
- /**
81
- * Get the sources of definitions for a given graph. These are ontology definitions
82
- * or the objects of `rdfs:isDefinedBy` triples. If the rdfs:isDefinedBy object can be
83
- * matched with an ontology definition, the ontology URI is returned.
84
- * @param graphUris URIs of the graphs to search.
85
- * @returns A list of sources of definitions for the given graph.
86
- */
87
- getDefinitionSources(graphUris, includeOntologies = false) {
88
- const result = new Set();
89
- // Load all ontologies in the graph in a normalized form.
90
- const ontologies = {};
91
- // Store the normalized versions of the ontology URI so that we can detect
92
- // equality even if different namespace seperators ('#' and '/') are used.
93
- for (let o of this.getOntologies(graphUris)) {
94
- const uri = uri_1.Uri.getNormalizedUri(o);
95
- ontologies[uri] = o;
96
- }
97
- for (const q of this.store.match(graphUris, null, ontologies_1.rdfs.isDefinedBy, null)) {
98
- const s = q.subject;
99
- const o = q.object;
100
- if (s.termType != "NamedNode" || o.termType != "NamedNode") {
101
- continue;
102
- }
103
- // Do not include ontologies in the list of sources. However, if there are other
104
- // terms defined by the object it will be included by subsequent iterations.
105
- const s_ = uri_1.Uri.getNormalizedUri(s.value);
106
- const o_ = uri_1.Uri.getNormalizedUri(o.value);
107
- let isOntology = s_ in ontologies;
108
- if (!isOntology || includeOntologies) {
109
- if (o_ in ontologies) {
110
- result.add(ontologies[o_]);
111
- }
112
- else {
113
- result.add(o.value);
114
- }
115
- }
116
- }
117
- return Array.from(result);
118
- }
119
- }
120
- exports.VocabularyRepository = VocabularyRepository;
121
- //# sourceMappingURL=vocabulary-repository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vocabulary-repository.js","sourceRoot":"","sources":["../../src/rdf/vocabulary-repository.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,8CAAqD;AACrD,+BAA4B;AAC5B,yDAAqD;AAErD;;GAEG;AACH,MAAa,oBAAqB,SAAQ,kCAAe;IACrD;;;;OAIG;IACI,iBAAiB,CAAC,SAAwC;QAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,gBAAG,CAAC,IAAI,EAAE,iBAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YAC9E,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAEpB,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,EAAE,CAAC;gBAC5B,SAAS;YACb,CAAC;YAED,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IAC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