@oslo-flanders/core 1.1.0 → 1.1.1
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/lib/constants/prefixes.js +43 -7
- package/lib/types/SplitUri.d.ts +5 -0
- package/lib/types/SplitUri.js +3 -0
- package/lib/utils/namespaces.d.ts +18 -11
- package/lib/utils/namespaces.js +18 -11
- package/lib/utils/uri.d.ts +2 -0
- package/lib/utils/uri.js +35 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -40,5 +40,6 @@ __exportStar(require("./lib/logging/WinstonLoggerFactory"), exports);
|
|
|
40
40
|
__exportStar(require("./lib/utils/storeUtils"), exports);
|
|
41
41
|
__exportStar(require("./lib/utils/fileSystem"), exports);
|
|
42
42
|
__exportStar(require("./lib/utils/strings"), exports);
|
|
43
|
+
__exportStar(require("./lib/utils/uri"), exports);
|
|
43
44
|
__exportStar(require("./lib/constants/prefixes"), exports);
|
|
44
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,8 +7,11 @@ exports.getPrefixes = void 0;
|
|
|
7
7
|
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
8
8
|
const core_1 = require("@oslo-flanders/core");
|
|
9
9
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
10
|
-
const PREFIX_CC_URL = '
|
|
10
|
+
const PREFIX_CC_URL = 'http://prefix.cc/context';
|
|
11
|
+
let cachedPrefixes;
|
|
11
12
|
async function getPrefixes() {
|
|
13
|
+
if (cachedPrefixes)
|
|
14
|
+
return cachedPrefixes;
|
|
12
15
|
const url = PREFIX_CC_URL;
|
|
13
16
|
try {
|
|
14
17
|
const response = await (0, node_fetch_1.default)(url);
|
|
@@ -17,7 +20,8 @@ async function getPrefixes() {
|
|
|
17
20
|
}
|
|
18
21
|
const data = (await response.json());
|
|
19
22
|
if (data['@context']) {
|
|
20
|
-
|
|
23
|
+
cachedPrefixes = fixPrefixes(data['@context']);
|
|
24
|
+
return cachedPrefixes;
|
|
21
25
|
}
|
|
22
26
|
throw new Error('Invalid context format received from prefix.cc');
|
|
23
27
|
}
|
|
@@ -25,16 +29,48 @@ async function getPrefixes() {
|
|
|
25
29
|
console.warn(`Error fetching prefixes: ${String(error)}`);
|
|
26
30
|
// Fallback to a minimal set of prefixes if the fetch fails
|
|
27
31
|
return {
|
|
28
|
-
|
|
32
|
+
adms: core_1.ns.adms('').value,
|
|
33
|
+
cpov: core_1.ns.cpov('').value,
|
|
34
|
+
dcat: core_1.ns.dcat('').value,
|
|
35
|
+
dcatap: core_1.ns.dcatap('').value,
|
|
36
|
+
dct: core_1.ns.dcterms('').value,
|
|
37
|
+
dcterms: core_1.ns.dcterms('').value,
|
|
38
|
+
foaf: core_1.ns.foaf('').value,
|
|
39
|
+
generiek: core_1.ns.generiek('').value,
|
|
40
|
+
geodcatap: core_1.ns.geodcatap('').value,
|
|
41
|
+
locn: core_1.ns.locn('').value,
|
|
42
|
+
mdcat: core_1.ns.mdcat('').value,
|
|
43
|
+
mobilitydcatap: core_1.ns.mobilitydcatap('').value,
|
|
44
|
+
oslo: core_1.ns.oslo('').value,
|
|
45
|
+
owl: core_1.ns.owl('').value,
|
|
46
|
+
person: core_1.ns.person('').value,
|
|
47
|
+
prov: core_1.ns.prov('').value,
|
|
48
|
+
qb: core_1.ns.qb('').value,
|
|
29
49
|
rdf: core_1.ns.rdf('').value,
|
|
30
50
|
rdfs: core_1.ns.rdfs('').value,
|
|
31
|
-
|
|
51
|
+
schema: core_1.ns.schema('').value,
|
|
52
|
+
shacl: core_1.ns.shacl('').value,
|
|
53
|
+
skos: core_1.ns.skos('').value,
|
|
54
|
+
time: core_1.ns.time('').value,
|
|
55
|
+
vann: core_1.ns.vann('').value,
|
|
56
|
+
vcard: core_1.ns.vcard('').value,
|
|
57
|
+
vl: core_1.ns.vl('').value,
|
|
58
|
+
vlaanderen: core_1.ns.vlaanderen('').value,
|
|
59
|
+
void: core_1.ns.void('').value,
|
|
32
60
|
xsd: core_1.ns.xsd('').value,
|
|
33
|
-
cpov: core_1.ns.cpov('').value,
|
|
34
|
-
locn: core_1.ns.locn('').value,
|
|
35
61
|
};
|
|
36
62
|
}
|
|
37
63
|
}
|
|
38
64
|
exports.getPrefixes = getPrefixes;
|
|
39
|
-
|
|
65
|
+
function fixPrefixes(records) {
|
|
66
|
+
// Profile mobilityDCAT-AP is incorrectly mapped to mdcat in prefix.cc
|
|
67
|
+
records.mdcat = core_1.ns.mdcat('').value;
|
|
68
|
+
records.mobilitydcatap = core_1.ns.mobilitydcatap('').value;
|
|
69
|
+
// Missing value
|
|
70
|
+
records.generiek = core_1.ns.generiek('').value;
|
|
71
|
+
// Profile GeoDCAT-AP is incorrectly defined in prefix.cc as "geodcat"
|
|
72
|
+
delete records.geodcat;
|
|
73
|
+
records.geodcatap = core_1.ns.geodcatap('').value;
|
|
74
|
+
return records;
|
|
75
|
+
}
|
|
40
76
|
//# sourceMappingURL=prefixes.js.map
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
declare enum Prefixes {
|
|
2
2
|
adms = "http://www.w3.org/ns/adms#",
|
|
3
|
+
cpov = "http://data.europa.eu/m8g/",
|
|
3
4
|
dcat = "http://www.w3.org/ns/dcat#",
|
|
4
5
|
dcterms = "http://purl.org/dc/terms/",
|
|
5
6
|
foaf = "http://xmlns.com/foaf/0.1/",
|
|
7
|
+
generiek = "http://data.vlaanderen.be/ns/generiek#",
|
|
8
|
+
geodcatap = "http://data.europa.eu/930/",
|
|
9
|
+
locn = "http://www.w3.org/ns/locn#",
|
|
10
|
+
mdcat = "https://data.vlaanderen.be/ns/metadata-dcat#",
|
|
11
|
+
mobilitydcatap = "https://w3id.org/mobilitydcat-ap#",
|
|
12
|
+
oslo = "https://implementatie.data.vlaanderen.be/ns/oslo-toolchain#",
|
|
6
13
|
owl = "http://www.w3.org/2002/07/owl#",
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
person = "http://www.w3.org/ns/person#",
|
|
15
|
+
prov = "http://www.w3.org/ns/prov#",
|
|
16
|
+
qb = "http://purl.org/linked-data/cube#",
|
|
9
17
|
rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
10
18
|
rdfs = "http://www.w3.org/2000/01/rdf-schema#",
|
|
11
|
-
|
|
19
|
+
schema = "https://schema.org/",
|
|
20
|
+
shacl = "http://www.w3.org/ns/shacl#",
|
|
12
21
|
skos = "http://www.w3.org/2004/02/skos/core#",
|
|
13
|
-
|
|
14
|
-
person = "http://www.w3.org/ns/person#",
|
|
22
|
+
time = "http://www.w3.org/2006/time#",
|
|
15
23
|
vann = "http://purl.org/vocab/vann/",
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
oslo = "https://implementatie.data.vlaanderen.be/ns/oslo-toolchain#",
|
|
24
|
+
vcard = "http://www.w3.org/2006/vcard/ns#",
|
|
25
|
+
dcatap = "http://data.europa.eu/r5r/",
|
|
19
26
|
vl = "https://data.vlaanderen.be/ns/shacl#",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
vlaanderen = "https://data.vlaanderen.be/ns/",
|
|
28
|
+
void = "http://rdfs.org/ns/void#",
|
|
29
|
+
xsd = "http://www.w3.org/2001/XMLSchema#"
|
|
23
30
|
}
|
|
24
31
|
export type Namespace = {
|
|
25
32
|
[T in keyof typeof Prefixes]: Function;
|
package/lib/utils/namespaces.js
CHANGED
|
@@ -6,26 +6,33 @@ const factory = new rdf_data_factory_1.DataFactory();
|
|
|
6
6
|
var Prefixes;
|
|
7
7
|
(function (Prefixes) {
|
|
8
8
|
Prefixes["adms"] = "http://www.w3.org/ns/adms#";
|
|
9
|
+
Prefixes["cpov"] = "http://data.europa.eu/m8g/";
|
|
9
10
|
Prefixes["dcat"] = "http://www.w3.org/ns/dcat#";
|
|
10
11
|
Prefixes["dcterms"] = "http://purl.org/dc/terms/";
|
|
11
12
|
Prefixes["foaf"] = "http://xmlns.com/foaf/0.1/";
|
|
13
|
+
Prefixes["generiek"] = "http://data.vlaanderen.be/ns/generiek#";
|
|
14
|
+
Prefixes["geodcatap"] = "http://data.europa.eu/930/";
|
|
15
|
+
Prefixes["locn"] = "http://www.w3.org/ns/locn#";
|
|
16
|
+
Prefixes["mdcat"] = "https://data.vlaanderen.be/ns/metadata-dcat#";
|
|
17
|
+
Prefixes["mobilitydcatap"] = "https://w3id.org/mobilitydcat-ap#";
|
|
18
|
+
Prefixes["oslo"] = "https://implementatie.data.vlaanderen.be/ns/oslo-toolchain#";
|
|
12
19
|
Prefixes["owl"] = "http://www.w3.org/2002/07/owl#";
|
|
13
|
-
Prefixes["
|
|
14
|
-
Prefixes["
|
|
20
|
+
Prefixes["person"] = "http://www.w3.org/ns/person#";
|
|
21
|
+
Prefixes["prov"] = "http://www.w3.org/ns/prov#";
|
|
22
|
+
Prefixes["qb"] = "http://purl.org/linked-data/cube#";
|
|
15
23
|
Prefixes["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
|
16
24
|
Prefixes["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";
|
|
17
|
-
Prefixes["
|
|
25
|
+
Prefixes["schema"] = "https://schema.org/";
|
|
26
|
+
Prefixes["shacl"] = "http://www.w3.org/ns/shacl#";
|
|
18
27
|
Prefixes["skos"] = "http://www.w3.org/2004/02/skos/core#";
|
|
19
|
-
Prefixes["
|
|
20
|
-
Prefixes["person"] = "http://www.w3.org/ns/person#";
|
|
28
|
+
Prefixes["time"] = "http://www.w3.org/2006/time#";
|
|
21
29
|
Prefixes["vann"] = "http://purl.org/vocab/vann/";
|
|
22
|
-
Prefixes["
|
|
23
|
-
Prefixes["
|
|
24
|
-
Prefixes["oslo"] = "https://implementatie.data.vlaanderen.be/ns/oslo-toolchain#";
|
|
30
|
+
Prefixes["vcard"] = "http://www.w3.org/2006/vcard/ns#";
|
|
31
|
+
Prefixes["dcatap"] = "http://data.europa.eu/r5r/";
|
|
25
32
|
Prefixes["vl"] = "https://data.vlaanderen.be/ns/shacl#";
|
|
26
|
-
Prefixes["
|
|
27
|
-
Prefixes["
|
|
28
|
-
Prefixes["
|
|
33
|
+
Prefixes["vlaanderen"] = "https://data.vlaanderen.be/ns/";
|
|
34
|
+
Prefixes["void"] = "http://rdfs.org/ns/void#";
|
|
35
|
+
Prefixes["xsd"] = "http://www.w3.org/2001/XMLSchema#";
|
|
29
36
|
})(Prefixes || (Prefixes = {}));
|
|
30
37
|
const vocab = () => {
|
|
31
38
|
const namespaces = {};
|
package/lib/utils/uri.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitUri = void 0;
|
|
4
|
+
const prefixes_1 = require("../constants/prefixes");
|
|
5
|
+
async function splitUri(uri) {
|
|
6
|
+
/* Extract prefix and element by finding the last occurrence of # or / */
|
|
7
|
+
const hashIndex = uri.lastIndexOf('#');
|
|
8
|
+
const slashIndex = uri.lastIndexOf('/');
|
|
9
|
+
const splitIndex = Math.max(hashIndex, slashIndex);
|
|
10
|
+
if (splitIndex > 0) {
|
|
11
|
+
const prefixUri = uri.slice(0, Math.max(0, splitIndex + 1));
|
|
12
|
+
const element = uri.replace(prefixUri, '');
|
|
13
|
+
const prefixes = await (0, prefixes_1.getPrefixes)();
|
|
14
|
+
let prefixLabel;
|
|
15
|
+
for (const [label, puri] of Object.entries(prefixes)) {
|
|
16
|
+
if (puri === prefixUri) {
|
|
17
|
+
prefixLabel = label;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/* No known prefix found for URI */
|
|
22
|
+
if (!prefixLabel) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
prefix: prefixLabel,
|
|
27
|
+
uri: prefixUri,
|
|
28
|
+
element,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/* Splitting failed */
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
exports.splitUri = splitUri;
|
|
35
|
+
//# sourceMappingURL=uri.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslo-flanders/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Core interfaces and utilities",
|
|
5
5
|
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
|
|
6
6
|
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-core#readme",
|