@faubulous/mentor-rdf 0.2.4 → 0.2.5

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.
@@ -8,4 +8,11 @@ export declare class OntologyRepository extends IndividualRepository {
8
8
  * @returns A list of all ontologies in the repository.
9
9
  */
10
10
  getOntologies(graphUris: string | string[]): string[];
11
+ /**
12
+ * 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".
13
+ * @param graphUris URIs of the graphs to search.
14
+ * @param ontologyUri URI of the ontology.
15
+ * @returns The version of the ontology, or undefined if it is not found.
16
+ */
17
+ getOntologyVersionInfo(graphUris: string | string[], ontologyUri: string): string | undefined;
11
18
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OntologyRepository = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const n3 = tslib_1.__importStar(require("n3"));
4
6
  const ontologies_1 = require("../ontologies");
5
7
  const individual_repository_1 = require("./individual-repository");
6
8
  /**
@@ -22,6 +24,25 @@ class OntologyRepository extends individual_repository_1.IndividualRepository {
22
24
  }
23
25
  return Array.from(result);
24
26
  }
27
+ /**
28
+ * 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".
29
+ * @param graphUris URIs of the graphs to search.
30
+ * @param ontologyUri URI of the ontology.
31
+ * @returns The version of the ontology, or undefined if it is not found.
32
+ */
33
+ getOntologyVersionInfo(graphUris, ontologyUri) {
34
+ const s = new n3.NamedNode(ontologyUri);
35
+ for (const q of this.store.match(graphUris, s, ontologies_1.owl.versionInfo, null)) {
36
+ // If the version is a date, return it in the format "YYYY-MM-DD".
37
+ const match = q.object.value.match(/(\d{4}[\/-]\d{2}[\/-]\d{2})/);
38
+ if (match && match.length > 1) {
39
+ return new Date(match[1]).toISOString().substring(0, 10);
40
+ }
41
+ else {
42
+ return q.object.value;
43
+ }
44
+ }
45
+ }
25
46
  }
26
47
  exports.OntologyRepository = OntologyRepository;
27
48
  //# sourceMappingURL=ontology-repository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ontology-repository.js","sourceRoot":"","sources":["../../src/rdf/ontology-repository.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,mEAA+D;AAE/D;;GAEG;AACH,MAAa,kBAAmB,SAAQ,4CAAoB;IACxD;;;OAGG;IACI,aAAa,CAAC,SAA4B;QAC7C,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,gBAAG,CAAC,QAAQ,CAAC,EAAE;YACvE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAEpB,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,EAAE;gBAC3B,SAAS;aACZ;YAED,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACvB;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;CACJ;AApBD,gDAoBC"}
1
+ {"version":3,"file":"ontology-repository.js","sourceRoot":"","sources":["../../src/rdf/ontology-repository.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,8CAAyC;AACzC,mEAA+D;AAE/D;;GAEG;AACH,MAAa,kBAAmB,SAAQ,4CAAoB;IACxD;;;OAGG;IACI,aAAa,CAAC,SAA4B;QAC7C,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,gBAAG,CAAC,QAAQ,CAAC,EAAE;YACvE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAEpB,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,EAAE;gBAC3B,SAAS;aACZ;YAED,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACvB;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,sBAAsB,CAAC,SAA4B,EAAE,WAAmB;QAC3E,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAExC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,gBAAG,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE;YACnE,kEAAkE;YAClE,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;YAElE,IAAG,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC1B,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;aAC5D;iBAAM;gBACH,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aACzB;SACJ;IACL,CAAC;CACJ;AAzCD,gDAyCC"}
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "ontology",
11
11
  "vocabulary"
12
12
  ],
13
- "version": "0.2.4",
13
+ "version": "0.2.5",
14
14
  "private": false,
15
15
  "author": {
16
16
  "name": "Sebastian Faubel"