@oslo-flanders/core 1.0.14 → 1.0.16
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/lib/interfaces/AppRunner.d.ts +1 -0
- package/lib/interfaces/AppRunner.js +18 -3
- package/lib/store/QuadStore.d.ts +12 -0
- package/lib/store/QuadStore.js +24 -0
- package/lib/types/splitUri.d.ts +6 -0
- package/lib/types/splitUri.js +35 -0
- package/lib/utils/quadSort.d.ts +8 -0
- package/lib/utils/quadSort.js +17 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ export type YargsParams = {
|
|
|
13
13
|
$0: string;
|
|
14
14
|
};
|
|
15
15
|
export declare abstract class AppRunner<T extends IService, K extends IConfiguration> {
|
|
16
|
+
protected createYargsInstance(argv: string[]): any;
|
|
16
17
|
runCliSync(process: NodeJS.Process): void;
|
|
17
18
|
abstract runCli(argv: CliArgv): Promise<void>;
|
|
18
19
|
startApp(params: YargsParams, container: Container): Promise<void>;
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.AppRunner = void 0;
|
|
4
7
|
const process_1 = require("process");
|
|
5
8
|
const LogUtil_1 = require("../logging/LogUtil");
|
|
6
9
|
const ServiceIdentifier_1 = require("../ServiceIdentifier");
|
|
10
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
7
11
|
class AppRunner {
|
|
12
|
+
createYargsInstance(argv) {
|
|
13
|
+
return (0, yargs_1.default)(argv)
|
|
14
|
+
.parserConfiguration({
|
|
15
|
+
'duplicate-arguments-array': false,
|
|
16
|
+
})
|
|
17
|
+
.usage('node ./bin/runner.js [args]');
|
|
18
|
+
}
|
|
8
19
|
runCliSync(process) {
|
|
9
20
|
this.runCli(process.argv).catch((error) => {
|
|
10
21
|
process_1.stderr.write(error.message);
|
|
@@ -16,11 +27,15 @@ class AppRunner {
|
|
|
16
27
|
const configuration = container.get(ServiceIdentifier_1.ServiceIdentifier.Configuration);
|
|
17
28
|
await configuration.createFromCli(params);
|
|
18
29
|
(0, LogUtil_1.setLoggerFactory)(params);
|
|
19
|
-
container
|
|
30
|
+
container
|
|
31
|
+
.bind(ServiceIdentifier_1.ServiceIdentifier.Logger)
|
|
32
|
+
.toDynamicValue(() => (0, LogUtil_1.createLogger)())
|
|
33
|
+
.inSingletonScope();
|
|
20
34
|
const service = container.get(ServiceIdentifier_1.ServiceIdentifier.Service);
|
|
21
|
-
service
|
|
35
|
+
service
|
|
36
|
+
.init()
|
|
22
37
|
.then(() => service.run())
|
|
23
|
-
.catch(error => console.error(error));
|
|
38
|
+
.catch((error) => console.error(error));
|
|
24
39
|
}
|
|
25
40
|
}
|
|
26
41
|
exports.AppRunner = AppRunner;
|
package/lib/store/QuadStore.d.ts
CHANGED
|
@@ -226,4 +226,16 @@ export declare class QuadStore {
|
|
|
226
226
|
* @param graph The RDF.Term of the named graph
|
|
227
227
|
*/
|
|
228
228
|
getChildAttribute(subject: RDF.Term, graph?: RDF.Term | null): RDF.Term | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Check if class is abstract
|
|
231
|
+
* @param subject The RDF.Term to determine if it is an abstract class
|
|
232
|
+
* @param graph The RDF.Term of the named graph
|
|
233
|
+
*/
|
|
234
|
+
isAbstractClass(subject: RDF.Term, graph?: RDF.Term | null): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Check if class is root object
|
|
237
|
+
* @param subject The RDF.Term to determine if it is an root object
|
|
238
|
+
* @param graph The RDF.Term of the named graph
|
|
239
|
+
*/
|
|
240
|
+
isRootClass(subject: RDF.Term, graph?: RDF.Term | null): boolean;
|
|
229
241
|
}
|
package/lib/store/QuadStore.js
CHANGED
|
@@ -389,6 +389,30 @@ let QuadStore = class QuadStore {
|
|
|
389
389
|
getChildAttribute(subject, graph = null) {
|
|
390
390
|
return (this.findObject(subject, namespaces_1.ns.oslo('childAttribute')));
|
|
391
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Check if class is abstract
|
|
394
|
+
* @param subject The RDF.Term to determine if it is an abstract class
|
|
395
|
+
* @param graph The RDF.Term of the named graph
|
|
396
|
+
*/
|
|
397
|
+
isAbstractClass(subject, graph = null) {
|
|
398
|
+
const types = this.findObjects(subject, namespaces_1.ns.rdf('type'));
|
|
399
|
+
for (const t of types)
|
|
400
|
+
if (t.value === namespaces_1.ns.oslo('AbstractClass').value)
|
|
401
|
+
return true;
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Check if class is root object
|
|
406
|
+
* @param subject The RDF.Term to determine if it is an root object
|
|
407
|
+
* @param graph The RDF.Term of the named graph
|
|
408
|
+
*/
|
|
409
|
+
isRootClass(subject, graph = null) {
|
|
410
|
+
const types = this.findObjects(subject, namespaces_1.ns.rdf('type'));
|
|
411
|
+
for (const t of types)
|
|
412
|
+
if (t.value === namespaces_1.ns.oslo('RootClass').value)
|
|
413
|
+
return true;
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
392
416
|
};
|
|
393
417
|
QuadStore = __decorate([
|
|
394
418
|
(0, inversify_1.injectable)(),
|
|
@@ -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=splitUri.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as RDF from '@rdfjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Sort function used on an array of quads. First sorts named nodes alphabetically, then blank nodes alphabetically.
|
|
4
|
+
* @param quadA An RDF.Quad
|
|
5
|
+
* @param quadB An RDF.Quad
|
|
6
|
+
* @returns a number
|
|
7
|
+
*/
|
|
8
|
+
export declare const quadSort: (quadA: RDF.Quad, quadB: RDF.Quad) => number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quadSort = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sort function used on an array of quads. First sorts named nodes alphabetically, then blank nodes alphabetically.
|
|
6
|
+
* @param quadA An RDF.Quad
|
|
7
|
+
* @param quadB An RDF.Quad
|
|
8
|
+
* @returns a number
|
|
9
|
+
*/
|
|
10
|
+
const quadSort = (quadA, quadB) => {
|
|
11
|
+
if (quadA.subject.termType === quadB.subject.termType) {
|
|
12
|
+
return quadA.subject.value.localeCompare(quadB.subject.value);
|
|
13
|
+
}
|
|
14
|
+
return quadA.subject.termType === 'BlankNode' ? 1 : -1;
|
|
15
|
+
};
|
|
16
|
+
exports.quadSort = quadSort;
|
|
17
|
+
//# sourceMappingURL=quadSort.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslo-flanders/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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",
|