@oslo-flanders/core 0.0.1-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 (67) hide show
  1. package/README.md +75 -0
  2. package/index.js +34 -0
  3. package/lib/ServiceIdentifier.d.ts +7 -0
  4. package/lib/ServiceIdentifier.js +15 -0
  5. package/lib/ServiceIdentifier.js.map +1 -0
  6. package/lib/ServiceIdentifier.ts +10 -0
  7. package/lib/enums/PropertyTypes.d.ts +5 -0
  8. package/lib/enums/PropertyTypes.js +10 -0
  9. package/lib/enums/PropertyTypes.js.map +1 -0
  10. package/lib/enums/PropertyTypes.ts +5 -0
  11. package/lib/enums/Scope.d.ts +6 -0
  12. package/lib/enums/Scope.js +11 -0
  13. package/lib/enums/Scope.js.map +1 -0
  14. package/lib/enums/Scope.ts +6 -0
  15. package/lib/interfaces/AppRunner.d.ts +15 -0
  16. package/lib/interfaces/AppRunner.js +15 -0
  17. package/lib/interfaces/AppRunner.js.map +1 -0
  18. package/lib/interfaces/AppRunner.ts +25 -0
  19. package/lib/interfaces/IConfiguration.d.ts +7 -0
  20. package/lib/interfaces/IConfiguration.js +3 -0
  21. package/lib/interfaces/IConfiguration.js.map +1 -0
  22. package/lib/interfaces/IConfiguration.ts +8 -0
  23. package/lib/interfaces/IConversionService.d.ts +10 -0
  24. package/lib/interfaces/IConversionService.js +3 -0
  25. package/lib/interfaces/IConversionService.js.map +1 -0
  26. package/lib/interfaces/IConversionService.ts +11 -0
  27. package/lib/interfaces/IGenerationService.d.ts +8 -0
  28. package/lib/interfaces/IGenerationService.js +3 -0
  29. package/lib/interfaces/IGenerationService.js.map +1 -0
  30. package/lib/interfaces/IGenerationService.ts +9 -0
  31. package/lib/interfaces/IOutputHandler.d.ts +7 -0
  32. package/lib/interfaces/IOutputHandler.js +3 -0
  33. package/lib/interfaces/IOutputHandler.js.map +1 -0
  34. package/lib/interfaces/IOutputHandler.ts +8 -0
  35. package/lib/logging/LogLevel.d.ts +5 -0
  36. package/lib/logging/LogLevel.js +5 -0
  37. package/lib/logging/LogLevel.js.map +1 -0
  38. package/lib/logging/LogLevel.ts +6 -0
  39. package/lib/logging/Logger.d.ts +19 -0
  40. package/lib/logging/Logger.js +35 -0
  41. package/lib/logging/Logger.js.map +1 -0
  42. package/lib/logging/Logger.ts +41 -0
  43. package/lib/logging/VoidLogger.d.ts +7 -0
  44. package/lib/logging/VoidLogger.js +28 -0
  45. package/lib/logging/VoidLogger.js.map +1 -0
  46. package/lib/logging/VoidLogger.ts +15 -0
  47. package/lib/logging/WinstonLogger.d.ts +7 -0
  48. package/lib/logging/WinstonLogger.js +39 -0
  49. package/lib/logging/WinstonLogger.js.map +1 -0
  50. package/lib/logging/WinstonLogger.ts +33 -0
  51. package/lib/utils/N3StoreFunctions.d.ts +136 -0
  52. package/lib/utils/N3StoreFunctions.js +257 -0
  53. package/lib/utils/N3StoreFunctions.js.map +1 -0
  54. package/lib/utils/N3StoreFunctions.ts +268 -0
  55. package/lib/utils/fetchFileOrUrl.d.ts +2 -0
  56. package/lib/utils/fetchFileOrUrl.js +23 -0
  57. package/lib/utils/fetchFileOrUrl.js.map +1 -0
  58. package/lib/utils/fetchFileOrUrl.ts +19 -0
  59. package/lib/utils/namespaces.d.ts +24 -0
  60. package/lib/utils/namespaces.js +36 -0
  61. package/lib/utils/namespaces.js.map +1 -0
  62. package/lib/utils/namespaces.ts +41 -0
  63. package/lib/utils/uniqueId.d.ts +1 -0
  64. package/lib/utils/uniqueId.js +14 -0
  65. package/lib/utils/uniqueId.js.map +1 -0
  66. package/lib/utils/uniqueId.ts +11 -0
  67. package/package.json +56 -0
@@ -0,0 +1,268 @@
1
+ import type * as RDF from '@rdfjs/types';
2
+ import * as N3 from 'n3';
3
+ import rdfParser from 'rdf-parse';
4
+ import { fetchFileOrUrl } from './fetchFileOrUrl';
5
+ import { ns } from './namespaces';
6
+
7
+ /**
8
+ * Given a local file, it is parsed and added to an in-memory quad store
9
+ * @param fileOrUrl Local path of the input file
10
+ * @returns A N3 quad store
11
+ */
12
+ export async function createN3Store(file: string): Promise<N3.Store> {
13
+ const store = new N3.Store();
14
+ const buffer = await fetchFileOrUrl(file);
15
+ const textStream = require('streamify-string')(buffer.toString());
16
+
17
+ return new Promise<N3.Store>((resolve, reject) => {
18
+ rdfParser.parse(textStream, { path: file })
19
+ .on('data', (quad: RDF.Quad) => store.addQuad(quad))
20
+ .on('error', (error: unknown) => reject(error))
21
+ .on('end', () => resolve(store));
22
+ });
23
+ }
24
+
25
+ /**
26
+ * Find the subject of the statement that matches the given subject, predicate and object
27
+ * @param statementSubject The subject to match the statement subject
28
+ * @param statementPredicate The predicate to match the statement predicate
29
+ * @param statementObject The object to match the statement object
30
+ * @param store An N3 quad store
31
+ * @returns an RDF.Term or undefined if none found
32
+ */
33
+ export function getTargetStatementId(
34
+ statementSubject: RDF.Term,
35
+ statementPredicate: RDF.Term,
36
+ statementObject: RDF.Term,
37
+ store: N3.Store,
38
+ ): RDF.Term | undefined {
39
+ const statementIds = store.getSubjects(ns.rdf('type'), ns.rdf('Statement'), null);
40
+ const statementSubjectPredicateSubjects = store.getSubjects(ns.rdf('subject'), statementSubject, null);
41
+ const statementPredicatePredicateSubjects = store.getSubjects(ns.rdf('predicate'), statementPredicate, null);
42
+ const statementObjectPredicateSubjects = store.getSubjects(ns.rdf('object'), statementObject, null);
43
+
44
+ const targetIds = statementIds
45
+ .filter(x => statementSubjectPredicateSubjects.some(y => y.value === x.value))
46
+ .filter(x => statementPredicatePredicateSubjects.some(y => y.value === x.value))
47
+ .filter(x => statementObjectPredicateSubjects.some(y => y.value === x.value));
48
+
49
+ if (targetIds.length > 1) {
50
+ throw new Error(`Found multiple statements with subject "${statementSubject.value}", predicate "${statementPredicate.value}" and object "${statementObject.value}".`);
51
+ }
52
+
53
+ return targetIds.shift();
54
+ }
55
+
56
+ /**
57
+ * For a given subject, the quad store is queried to find the assigned URI
58
+ * @param subject The subject for which the assigned URI is to be retrieved
59
+ * @param store The quad store
60
+ * @returns An RDF.NamedNode or undefined if not found
61
+ */
62
+ export function getAssignedUri(subject: RDF.Term, store: N3.Store): RDF.Term | undefined {
63
+ return store.getObjects(subject, ns.example('assignedUri'), null).shift();
64
+ }
65
+
66
+ /**
67
+ * Finds the assigned URI in rdf:Statements
68
+ * @param subject The statement subject
69
+ * @param predicate The statement predicate
70
+ * @param object The statement object for which the assigned URI must be found
71
+ * @param store A N3 quad store
72
+ * @returns An RDF.Term or undefined if not found
73
+ */
74
+ export function getAssignedUriViaStatements(
75
+ subject: RDF.Term,
76
+ predicate: RDF.Term,
77
+ object: RDF.Term,
78
+ store: N3.Store,
79
+ ): RDF.Term | undefined {
80
+ const statementId = getTargetStatementId(subject, predicate, object, store);
81
+
82
+ if (!statementId) {
83
+ return undefined;
84
+ }
85
+
86
+ return getAssignedUri(statementId, store);
87
+ }
88
+
89
+ /**
90
+ * Find all rdfs:labels for a given subject
91
+ * @param subject The RDF.Term to find the rdfs:labels for
92
+ * @param store A N3 quad store
93
+ * @returns An array of RDF.Literals
94
+ */
95
+ export function getLabels(subject: RDF.Term, store: N3.Store): RDF.Literal[] {
96
+ return <RDF.Literal[]>store.getObjects(subject, ns.rdfs('label'), null);
97
+ }
98
+
99
+ /**
100
+ * Finds the rdfs:label whose language tag matches the given language
101
+ * @param subject The RDF.Term to find the rdfs:label for
102
+ * @param store A N3 quad store
103
+ * @param language A language tag
104
+ * @returns An RDF.Literal or undefined if not found
105
+ */
106
+ export function getLabel(subject: RDF.Term, store: N3.Store, language?: string): RDF.Literal | undefined {
107
+ return getLabels(subject, store).find(x => x.language === (language || ''));
108
+ }
109
+
110
+ /**
111
+ * Finds the rdfs:label for an RDF.Term in rdf:Statements
112
+ * @param subject The statement subject
113
+ * @param predicate The statement predicate
114
+ * @param object The statement object for which the label must be found
115
+ * @param store A N3 quad store
116
+ * @param language A language tag
117
+ * @returns An RDF.Literal or undefined if not found
118
+ */
119
+ export function getLabelViaStatements(
120
+ subject: RDF.Term,
121
+ predicate: RDF.Term,
122
+ object: RDF.Term,
123
+ store: N3.Store,
124
+ language: string,
125
+ ): RDF.Literal | undefined {
126
+ const statementId = getTargetStatementId(subject, predicate, object, store);
127
+
128
+ if (!statementId) {
129
+ return undefined;
130
+ }
131
+
132
+ const label = getLabel(statementId, store, language);
133
+ return label || getLabel(statementId, store);
134
+ }
135
+
136
+ /**
137
+ * Find all rdfs:comments for a given subject
138
+ * @param subject The RDF.Term to find the rdfs:comments for
139
+ * @param store A N3 quad store
140
+ * @returns An array of RDF.Literals
141
+ */
142
+ export function getDefinitions(subject: RDF.Term, store: N3.Store): RDF.Literal[] {
143
+ return <RDF.Literal[]>store.getObjects(subject, ns.rdfs('comment'), null);
144
+ }
145
+
146
+ /**
147
+ * Finds the rdfs:comment whose language tag matches the given language
148
+ * @param subject The RDF.Term to find the rdfs:comment for
149
+ * @param store A N3 quad store
150
+ * @param language A language tag
151
+ * @returns An RDF.Literal or undefined if not found
152
+ */
153
+ export function getDefinition(subject: RDF.Term, store: N3.Store, language?: string): RDF.Literal | undefined {
154
+ return getDefinitions(subject, store).find(x => x.language === (language || ''));
155
+ }
156
+
157
+ /**
158
+ * Finds the rdfs:comment for an RDF.Term in rdf:Statements
159
+ * @param subject The statement subject
160
+ * @param predicate The statement predicate
161
+ * @param object The statement object for which the definition must be found
162
+ * @param store A N3 quad store
163
+ * @param language A language tag
164
+ * @returns An RDF.Literal or undefined if not found
165
+ */
166
+ export function getDefinitionViaStatements(
167
+ subject: RDF.Term,
168
+ predicate: RDF.Term,
169
+ object: RDF.Term,
170
+ store: N3.Store,
171
+ language: string,
172
+ ): RDF.Literal | undefined {
173
+ const statementId = getTargetStatementId(subject, predicate, object, store);
174
+
175
+ if (!statementId) {
176
+ return undefined;
177
+ }
178
+
179
+ const definition = getDefinition(statementId, store, language);
180
+ return definition || getDefinition(statementId, store);
181
+ }
182
+
183
+ /**
184
+ * Finds all the rdfs:subClassOf of a given RDF.Term
185
+ * @param subject the RDF.Term to find the parents of
186
+ * @param store A N3 quad store
187
+ * @returns An array of RDF.Terms
188
+ */
189
+ export function getParentsOfClass(subject: RDF.Term, store: N3.Store): RDF.Term[] {
190
+ return store.getObjects(subject, ns.rdfs('subClassOf'), null);
191
+ }
192
+
193
+ /**
194
+ * Finds the rdfs:subPropertyOf of a given RDF.Term
195
+ * @param subject The RDF.Term to find the parent of
196
+ * @param store A N3 quad store
197
+ * @returns An RDF.Term or undefined if not found
198
+ */
199
+ export function getParentOfProperty(subject: RDF.Term, store: N3.Store): RDF.Term | undefined {
200
+ return store.getObjects(subject, ns.rdfs('subPropertyOf'), null).shift();
201
+ }
202
+
203
+ /**
204
+ * Finds the rdfs:range of a given RDF.Term
205
+ * @param subject The RDF.Term to find the range of
206
+ * @param store A N3 quad store
207
+ * @returns An RDF.Term or undefined if not found
208
+ */
209
+ export function getRange(subject: RDF.Term, store: N3.Store): RDF.Term | undefined {
210
+ return store.getObjects(subject, ns.rdfs('range'), null).shift();
211
+ }
212
+
213
+ /**
214
+ * Finds the rdfs:domain of a given RDF.Term
215
+ * @param subject The RDF.Term to find the domain of
216
+ * @param store A N3 quad store
217
+ * @returns An RDF.Term or undefined if not found
218
+ */
219
+ export function getDomain(subject: RDF.Term, store: N3.Store): RDF.Term | undefined {
220
+ return store.getObjects(subject, ns.rdfs('domain'), null).shift();
221
+ }
222
+
223
+ /**
224
+ * Finds all the vann:usageNotes of a given RDF.Term
225
+ * @param subject The RDF.Term to find the usage notes for
226
+ * @param store A N3 quad store
227
+ * @returns An array of RDF.Literals
228
+ */
229
+ export function getUsageNotes(subject: RDF.Term, store: N3.Store): RDF.Literal[] {
230
+ return <RDF.Literal[]>store.getObjects(subject, ns.vann('usageNote'), null);
231
+ }
232
+
233
+ /**
234
+ * Finds the vann:usageNote of which the language tag matches the given language
235
+ * @param subject The RDF.Term to find the usage note for
236
+ * @param store A N3 quad store
237
+ * @param language A language tag
238
+ * @returns An RDF.Literal or undefined if not found
239
+ */
240
+ export function getUsageNote(subject: RDF.Term, store: N3.Store, language?: string): RDF.Literal | undefined {
241
+ return getUsageNotes(subject, store).find(x => x.language === (language || ''));
242
+ }
243
+
244
+ /**
245
+ * Finds the vann:usageNote for an RDF.Term in rdf:Statements
246
+ * @param subject The statement subject
247
+ * @param predicate The statement predicate
248
+ * @param object The statement object for which the usage note must be found
249
+ * @param store A N3 quad store
250
+ * @param language A language tag
251
+ * @returns An RDF.Literal or undefined if not found
252
+ */
253
+ export function getUsageNoteViaStatements(
254
+ subject: RDF.Term,
255
+ predicate: RDF.Term,
256
+ object: RDF.Term,
257
+ store: N3.Store,
258
+ language: string,
259
+ ): RDF.Literal | undefined {
260
+ const statementId = getTargetStatementId(subject, predicate, object, store);
261
+
262
+ if (!statementId) {
263
+ return undefined;
264
+ }
265
+
266
+ const usageNote = getUsageNote(statementId, store, language);
267
+ return usageNote || getUsageNote(statementId, store);
268
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function fetchFileOrUrl(file: string): Promise<Buffer>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchFileOrUrl = void 0;
7
+ const fs_1 = require("fs");
8
+ const promises_1 = require("fs/promises");
9
+ const node_fetch_1 = __importDefault(require("node-fetch"));
10
+ async function fetchFileOrUrl(file) {
11
+ if (file.startsWith('http://') || file.startsWith('https://')) {
12
+ return (await (0, node_fetch_1.default)(file)).buffer();
13
+ }
14
+ if (file.startsWith('file://')) {
15
+ file = file.slice(7);
16
+ }
17
+ if (!(0, fs_1.existsSync)(file) || !(await (0, promises_1.stat)(file)).isFile()) {
18
+ throw new Error(`Path does not refer to a valid file: ${file}`);
19
+ }
20
+ return (0, promises_1.readFile)(file);
21
+ }
22
+ exports.fetchFileOrUrl = fetchFileOrUrl;
23
+ //# sourceMappingURL=fetchFileOrUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchFileOrUrl.js","sourceRoot":"","sources":["fetchFileOrUrl.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgC;AAChC,0CAA6C;AAC7C,4DAA+B;AAExB,KAAK,UAAU,cAAc,CAAC,IAAY;IAC/C,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC7D,OAAO,CAAC,MAAM,IAAA,oBAAK,EAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACrC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC9B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtB;IAED,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAA,eAAI,EAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE;QACrD,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;KACjE;IAED,OAAO,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAdD,wCAcC","sourcesContent":["import { existsSync } from 'fs';\r\nimport { readFile, stat } from 'fs/promises';\r\nimport fetch from 'node-fetch';\r\n\r\nexport async function fetchFileOrUrl(file: string): Promise<Buffer> {\r\n if (file.startsWith('http://') || file.startsWith('https://')) {\r\n return (await fetch(file)).buffer();\r\n }\r\n\r\n if (file.startsWith('file://')) {\r\n file = file.slice(7);\r\n }\r\n\r\n if (!existsSync(file) || !(await stat(file)).isFile()) {\r\n throw new Error(`Path does not refer to a valid file: ${file}`);\r\n }\r\n\r\n return readFile(file);\r\n}\r\n"]}
@@ -0,0 +1,19 @@
1
+ import { existsSync } from 'fs';
2
+ import { readFile, stat } from 'fs/promises';
3
+ import fetch from 'node-fetch';
4
+
5
+ export async function fetchFileOrUrl(file: string): Promise<Buffer> {
6
+ if (file.startsWith('http://') || file.startsWith('https://')) {
7
+ return (await fetch(file)).buffer();
8
+ }
9
+
10
+ if (file.startsWith('file://')) {
11
+ file = file.slice(7);
12
+ }
13
+
14
+ if (!existsSync(file) || !(await stat(file)).isFile()) {
15
+ throw new Error(`Path does not refer to a valid file: ${file}`);
16
+ }
17
+
18
+ return readFile(file);
19
+ }
@@ -0,0 +1,24 @@
1
+ declare enum Prefixes {
2
+ example = "http://example.org/",
3
+ adms = "http://www.w3.org/ns/adms#",
4
+ dcat = "http://www.w3.org/ns/dcat#",
5
+ dcterms = "http://purl.org/dc/terms/",
6
+ foaf = "http://xmlns.com/foaf/0.1/",
7
+ owl = "http://www.w3.org/2002/07/owl#",
8
+ vlaanderen = "https://data.vlaanderen.be/ns/",
9
+ void = "http://rdfs.org/ns/void#",
10
+ rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
11
+ rdfs = "http://www.w3.org/2000/01/rdf-schema#",
12
+ qb = "http://purl.org/linked-data/cube#",
13
+ skos = "http://www.w3.org/2004/02/skos/core#",
14
+ xsd = "http://www.w3.org/2001/XMLSchema#",
15
+ person = "http://www.w3.org/ns/person#",
16
+ vann = "http://purl.org/vocab/vann/",
17
+ shacl = "http://w3.org/ns/shacl#",
18
+ prov = "http://www.w3.org/ns/prov#"
19
+ }
20
+ export declare type Namespace = {
21
+ [T in keyof typeof Prefixes]: Function;
22
+ };
23
+ export declare const ns: Namespace;
24
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ns = void 0;
4
+ const rdf_data_factory_1 = require("rdf-data-factory");
5
+ const factory = new rdf_data_factory_1.DataFactory();
6
+ // TODO: remove example.org from prefixes
7
+ var Prefixes;
8
+ (function (Prefixes) {
9
+ Prefixes["example"] = "http://example.org/";
10
+ Prefixes["adms"] = "http://www.w3.org/ns/adms#";
11
+ Prefixes["dcat"] = "http://www.w3.org/ns/dcat#";
12
+ Prefixes["dcterms"] = "http://purl.org/dc/terms/";
13
+ Prefixes["foaf"] = "http://xmlns.com/foaf/0.1/";
14
+ Prefixes["owl"] = "http://www.w3.org/2002/07/owl#";
15
+ Prefixes["vlaanderen"] = "https://data.vlaanderen.be/ns/";
16
+ Prefixes["void"] = "http://rdfs.org/ns/void#";
17
+ Prefixes["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
18
+ Prefixes["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";
19
+ Prefixes["qb"] = "http://purl.org/linked-data/cube#";
20
+ Prefixes["skos"] = "http://www.w3.org/2004/02/skos/core#";
21
+ Prefixes["xsd"] = "http://www.w3.org/2001/XMLSchema#";
22
+ Prefixes["person"] = "http://www.w3.org/ns/person#";
23
+ Prefixes["vann"] = "http://purl.org/vocab/vann/";
24
+ Prefixes["shacl"] = "http://w3.org/ns/shacl#";
25
+ Prefixes["prov"] = "http://www.w3.org/ns/prov#";
26
+ })(Prefixes || (Prefixes = {}));
27
+ const vocab = () => {
28
+ const namespaces = {};
29
+ for (const prefix in Prefixes) {
30
+ const expansion = Prefixes[prefix];
31
+ namespaces[prefix] = (localName = '') => factory.namedNode(expansion + localName);
32
+ }
33
+ return namespaces;
34
+ };
35
+ exports.ns = vocab();
36
+ //# sourceMappingURL=namespaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaces.js","sourceRoot":"","sources":["namespaces.ts"],"names":[],"mappings":";;;AAAA,uDAA+C;AAE/C,MAAM,OAAO,GAAG,IAAI,8BAAW,EAAE,CAAC;AAElC,yCAAyC;AACzC,IAAK,QAkBJ;AAlBD,WAAK,QAAQ;IACX,2CAA+B,CAAA;IAC/B,+CAAmC,CAAA;IACnC,+CAAmC,CAAA;IACnC,iDAAqC,CAAA;IACrC,+CAAmC,CAAA;IACnC,kDAAsC,CAAA;IACtC,yDAA6C,CAAA;IAC7C,6CAAiC,CAAA;IACjC,+DAAmD,CAAA;IACnD,0DAA8C,CAAA;IAC9C,oDAAwC,CAAA;IACxC,yDAA6C,CAAA;IAC7C,qDAAyC,CAAA;IACzC,mDAAuC,CAAA;IACvC,gDAAoC,CAAA;IACpC,6CAAiC,CAAA;IACjC,+CAAmC,CAAA;AACrC,CAAC,EAlBI,QAAQ,KAAR,QAAQ,QAkBZ;AAOD,MAAM,KAAK,GAAG,GAAc,EAAE;IAC5B,MAAM,UAAU,GAAQ,EAAE,CAAC;IAC3B,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE;QAC7B,MAAM,SAAS,GAAiB,QAAS,CAAC,MAAM,CAAC,CAAC;QAClD,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;KACnF;IAED,OAAkB,UAAU,CAAC;AAC/B,CAAC,CAAC;AAEW,QAAA,EAAE,GAAG,KAAK,EAAE,CAAC","sourcesContent":["import { DataFactory } from 'rdf-data-factory';\r\n\r\nconst factory = new DataFactory();\r\n\r\n// TODO: remove example.org from prefixes\r\nenum Prefixes {\r\n example = 'http://example.org/',\r\n adms = 'http://www.w3.org/ns/adms#',\r\n dcat = 'http://www.w3.org/ns/dcat#',\r\n dcterms = 'http://purl.org/dc/terms/',\r\n foaf = 'http://xmlns.com/foaf/0.1/',\r\n owl = 'http://www.w3.org/2002/07/owl#',\r\n vlaanderen = 'https://data.vlaanderen.be/ns/',\r\n void = 'http://rdfs.org/ns/void#',\r\n rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\r\n rdfs = 'http://www.w3.org/2000/01/rdf-schema#',\r\n qb = 'http://purl.org/linked-data/cube#',\r\n skos = 'http://www.w3.org/2004/02/skos/core#',\r\n xsd = 'http://www.w3.org/2001/XMLSchema#',\r\n person = 'http://www.w3.org/ns/person#',\r\n vann = 'http://purl.org/vocab/vann/',\r\n shacl = 'http://w3.org/ns/shacl#',\r\n prov = 'http://www.w3.org/ns/prov#'\r\n}\r\n\r\nexport type Namespace = {\r\n // eslint-disable-next-line @typescript-eslint/ban-types\r\n [T in keyof typeof Prefixes]: Function;\r\n};\r\n\r\nconst vocab = (): Namespace => {\r\n const namespaces: any = {};\r\n for (const prefix in Prefixes) {\r\n const expansion = <string>(<any>Prefixes)[prefix];\r\n namespaces[prefix] = (localName = '') => factory.namedNode(expansion + localName);\r\n }\r\n\r\n return <Namespace>namespaces;\r\n};\r\n\r\nexport const ns = vocab();\r\n"]}
@@ -0,0 +1,41 @@
1
+ import { DataFactory } from 'rdf-data-factory';
2
+
3
+ const factory = new DataFactory();
4
+
5
+ // TODO: remove example.org from prefixes
6
+ enum Prefixes {
7
+ example = 'http://example.org/',
8
+ adms = 'http://www.w3.org/ns/adms#',
9
+ dcat = 'http://www.w3.org/ns/dcat#',
10
+ dcterms = 'http://purl.org/dc/terms/',
11
+ foaf = 'http://xmlns.com/foaf/0.1/',
12
+ owl = 'http://www.w3.org/2002/07/owl#',
13
+ vlaanderen = 'https://data.vlaanderen.be/ns/',
14
+ void = 'http://rdfs.org/ns/void#',
15
+ rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
16
+ rdfs = 'http://www.w3.org/2000/01/rdf-schema#',
17
+ qb = 'http://purl.org/linked-data/cube#',
18
+ skos = 'http://www.w3.org/2004/02/skos/core#',
19
+ xsd = 'http://www.w3.org/2001/XMLSchema#',
20
+ person = 'http://www.w3.org/ns/person#',
21
+ vann = 'http://purl.org/vocab/vann/',
22
+ shacl = 'http://w3.org/ns/shacl#',
23
+ prov = 'http://www.w3.org/ns/prov#'
24
+ }
25
+
26
+ export type Namespace = {
27
+ // eslint-disable-next-line @typescript-eslint/ban-types
28
+ [T in keyof typeof Prefixes]: Function;
29
+ };
30
+
31
+ const vocab = (): Namespace => {
32
+ const namespaces: any = {};
33
+ for (const prefix in Prefixes) {
34
+ const expansion = <string>(<any>Prefixes)[prefix];
35
+ namespaces[prefix] = (localName = '') => factory.namedNode(expansion + localName);
36
+ }
37
+
38
+ return <Namespace>namespaces;
39
+ };
40
+
41
+ export const ns = vocab();
@@ -0,0 +1 @@
1
+ export declare function uniqueId(guid: string, label: string, id: number): string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uniqueId = void 0;
4
+ const crypto_js_1 = require("crypto-js");
5
+ function uniqueId(guid, label, id) {
6
+ const object = {
7
+ guid,
8
+ label,
9
+ id,
10
+ };
11
+ return (0, crypto_js_1.SHA256)(JSON.stringify(object)).toString();
12
+ }
13
+ exports.uniqueId = uniqueId;
14
+ //# sourceMappingURL=uniqueId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniqueId.js","sourceRoot":"","sources":["uniqueId.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AAEnC,SAAgB,QAAQ,CAAC,IAAY,EAAE,KAAa,EAAE,EAAU;IAC9D,MAAM,MAAM,GAAG;QACb,IAAI;QACJ,KAAK;QACL,EAAE;KACH,CAAC;IAEF,OAAO,IAAA,kBAAM,EAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnD,CAAC;AARD,4BAQC","sourcesContent":["import { SHA256 } from 'crypto-js';\r\n\r\nexport function uniqueId(guid: string, label: string, id: number): string {\r\n const object = {\r\n guid,\r\n label,\r\n id,\r\n };\r\n\r\n return SHA256(JSON.stringify(object)).toString();\r\n}\r\n"]}
@@ -0,0 +1,11 @@
1
+ import { SHA256 } from 'crypto-js';
2
+
3
+ export function uniqueId(guid: string, label: string, id: number): string {
4
+ const object = {
5
+ guid,
6
+ label,
7
+ id,
8
+ };
9
+
10
+ return SHA256(JSON.stringify(object)).toString();
11
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@oslo-flanders/core",
3
+ "version": "0.0.1-alpha.0",
4
+ "description": "Core interfaces and utilities",
5
+ "author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
6
+ "homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-core#readme",
7
+ "license": "MIT",
8
+ "main": "index.js",
9
+ "directories": {
10
+ "lib": "lib"
11
+ },
12
+ "files": [
13
+ "lib"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Informatievlaanderen/OSLO-UML-Transformer.git"
18
+ },
19
+ "jest": {
20
+ "runner": "groups",
21
+ "transform": {
22
+ "^.+\\.ts$": "ts-jest"
23
+ },
24
+ "testRegex": "/test/.*.test.ts$",
25
+ "moduleFileExtensions": [
26
+ "ts",
27
+ "js"
28
+ ],
29
+ "collectCoverage": true,
30
+ "coveragePathIgnorePatterns": [
31
+ "/node_modules/",
32
+ "index.js",
33
+ "test/data/*",
34
+ "lib/utils/namespaces.ts"
35
+ ],
36
+ "testEnvironment": "node"
37
+ },
38
+ "scripts": {
39
+ "build": "npm run build:ts",
40
+ "build:ts": "tsc",
41
+ "test:unit": "node \"../../node_modules/jest/bin/jest.js\" --group=unit"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/Informatievlaanderen/OSLO-UML-Transformer/issues"
45
+ },
46
+ "dependencies": {
47
+ "rdf-parse": "^2.1.1",
48
+ "streamify-string": "^1.0.1",
49
+ "winston": "^3.8.2"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node-fetch": "^2.6.2",
53
+ "@types/streamify-string": "^1.0.0",
54
+ "@types/tmp": "^0.2.3"
55
+ }
56
+ }