@oslo-flanders/core 0.0.9-alpha.0 → 0.0.11-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.
- package/index.d.ts +21 -0
- package/index.js +44 -0
- package/lib/ServiceIdentifier.d.ts +7 -0
- package/lib/ServiceIdentifier.js +15 -0
- package/lib/enums/PropertyTypes.d.ts +5 -0
- package/lib/enums/PropertyTypes.js +10 -0
- package/lib/enums/Scope.d.ts +6 -0
- package/lib/enums/Scope.js +11 -0
- package/lib/interfaces/AppRunner.d.ts +19 -0
- package/lib/interfaces/AppRunner.js +27 -0
- package/lib/interfaces/IConfiguration.d.ts +7 -0
- package/lib/interfaces/IConfiguration.js +3 -0
- package/lib/interfaces/IOutputHandler.d.ts +7 -0
- package/lib/interfaces/IOutputHandler.js +3 -0
- package/lib/interfaces/IService.d.ts +11 -0
- package/lib/interfaces/IService.js +3 -0
- package/lib/logging/LogLevel.d.ts +5 -0
- package/lib/logging/LogLevel.js +5 -0
- package/lib/logging/LogUtil.d.ts +4 -0
- package/lib/logging/LogUtil.js +17 -0
- package/lib/logging/Logger.d.ts +20 -0
- package/lib/logging/Logger.js +36 -0
- package/lib/logging/LoggerFactory.d.ts +11 -0
- package/lib/logging/LoggerFactory.js +3 -0
- package/lib/logging/VoidLogger.d.ts +7 -0
- package/lib/logging/VoidLogger.js +28 -0
- package/lib/logging/VoidLoggerFactory.d.ts +9 -0
- package/lib/logging/VoidLoggerFactory.js +17 -0
- package/lib/logging/WinstonLogger.d.ts +8 -0
- package/lib/logging/WinstonLogger.js +31 -0
- package/lib/logging/WinstonLoggerFactory.d.ts +10 -0
- package/lib/logging/WinstonLoggerFactory.js +24 -0
- package/lib/store/QuadStore.d.ts +165 -0
- package/lib/store/QuadStore.js +306 -0
- package/lib/utils/fetchFileOrUrl.d.ts +2 -0
- package/lib/utils/fetchFileOrUrl.js +23 -0
- package/lib/utils/namespaces.d.ts +24 -0
- package/lib/utils/namespaces.js +35 -0
- package/lib/utils/storeUtils.d.ts +10 -0
- package/lib/utils/storeUtils.js +95 -0
- package/lib/utils/uniqueId.d.ts +1 -0
- package/lib/utils/uniqueId.js +14 -0
- package/package.json +3 -3
package/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export * from '@oslo-core/lib/interfaces/AppRunner';
|
|
3
|
+
export * from '@oslo-core/lib/interfaces/IConfiguration';
|
|
4
|
+
export * from '@oslo-core/lib/interfaces/IOutputHandler';
|
|
5
|
+
export * from '@oslo-core/lib/interfaces/IService';
|
|
6
|
+
export * from '@oslo-core/lib/utils/fetchFileOrUrl';
|
|
7
|
+
export * from '@oslo-core/lib/utils/namespaces';
|
|
8
|
+
export * from '@oslo-core/lib/utils/uniqueId';
|
|
9
|
+
export * from '@oslo-core/lib/store/QuadStore';
|
|
10
|
+
export * from '@oslo-core/lib/ServiceIdentifier';
|
|
11
|
+
export * from '@oslo-core/lib/enums/Scope';
|
|
12
|
+
export * from '@oslo-core/lib/enums/PropertyTypes';
|
|
13
|
+
export * from '@oslo-core/lib/logging/LogLevel';
|
|
14
|
+
export * from '@oslo-core/lib/logging/Logger';
|
|
15
|
+
export * from '@oslo-core/lib/logging/VoidLogger';
|
|
16
|
+
export * from '@oslo-core/lib/logging/WinstonLogger';
|
|
17
|
+
export * from '@oslo-core/lib/logging/LogUtil';
|
|
18
|
+
export * from '@oslo-core/lib/logging/LoggerFactory';
|
|
19
|
+
export * from '@oslo-core/lib/logging/VoidLoggerFactory';
|
|
20
|
+
export * from '@oslo-core/lib/logging/WinstonLoggerFactory';
|
|
21
|
+
export * from '@oslo-core/lib/utils/storeUtils';
|
package/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
require("reflect-metadata");
|
|
18
|
+
// Extra manually added alias was required for nested NPM packages:
|
|
19
|
+
// https://github.com/ilearnio/module-alias?tab=readme-ov-file#using-within-another-npm-package
|
|
20
|
+
const moduleAlias = require('module-alias');
|
|
21
|
+
moduleAlias.addAliases({
|
|
22
|
+
'@oslo-core': `${__dirname}`,
|
|
23
|
+
});
|
|
24
|
+
__exportStar(require("@oslo-core/lib/interfaces/AppRunner"), exports);
|
|
25
|
+
__exportStar(require("@oslo-core/lib/interfaces/IConfiguration"), exports);
|
|
26
|
+
__exportStar(require("@oslo-core/lib/interfaces/IOutputHandler"), exports);
|
|
27
|
+
__exportStar(require("@oslo-core/lib/interfaces/IService"), exports);
|
|
28
|
+
__exportStar(require("@oslo-core/lib/utils/fetchFileOrUrl"), exports);
|
|
29
|
+
__exportStar(require("@oslo-core/lib/utils/namespaces"), exports);
|
|
30
|
+
__exportStar(require("@oslo-core/lib/utils/uniqueId"), exports);
|
|
31
|
+
__exportStar(require("@oslo-core/lib/store/QuadStore"), exports);
|
|
32
|
+
__exportStar(require("@oslo-core/lib/ServiceIdentifier"), exports);
|
|
33
|
+
__exportStar(require("@oslo-core/lib/enums/Scope"), exports);
|
|
34
|
+
__exportStar(require("@oslo-core/lib/enums/PropertyTypes"), exports);
|
|
35
|
+
__exportStar(require("@oslo-core/lib/logging/LogLevel"), exports);
|
|
36
|
+
__exportStar(require("@oslo-core/lib/logging/Logger"), exports);
|
|
37
|
+
__exportStar(require("@oslo-core/lib/logging/VoidLogger"), exports);
|
|
38
|
+
__exportStar(require("@oslo-core/lib/logging/WinstonLogger"), exports);
|
|
39
|
+
__exportStar(require("@oslo-core/lib/logging/LogUtil"), exports);
|
|
40
|
+
__exportStar(require("@oslo-core/lib/logging/LoggerFactory"), exports);
|
|
41
|
+
__exportStar(require("@oslo-core/lib/logging/VoidLoggerFactory"), exports);
|
|
42
|
+
__exportStar(require("@oslo-core/lib/logging/WinstonLoggerFactory"), exports);
|
|
43
|
+
__exportStar(require("@oslo-core/lib/utils/storeUtils"), exports);
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceIdentifier = void 0;
|
|
4
|
+
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
|
6
|
+
// This must be a class, because it must be possible to extend it in implementations
|
|
7
|
+
class ServiceIdentifier {
|
|
8
|
+
}
|
|
9
|
+
exports.ServiceIdentifier = ServiceIdentifier;
|
|
10
|
+
ServiceIdentifier.Service = Symbol.for('Service');
|
|
11
|
+
ServiceIdentifier.Configuration = Symbol.for('Configuration');
|
|
12
|
+
ServiceIdentifier.OutputHandler = Symbol.for('OutputHandler');
|
|
13
|
+
ServiceIdentifier.Logger = Symbol.for('Logger');
|
|
14
|
+
ServiceIdentifier.QuadStore = Symbol.for('QuadStore');
|
|
15
|
+
//# sourceMappingURL=ServiceIdentifier.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyType = void 0;
|
|
4
|
+
var PropertyType;
|
|
5
|
+
(function (PropertyType) {
|
|
6
|
+
PropertyType["DataTypeProperty"] = "http://www.w3.org/2002/07/owl#DatatypeProperty";
|
|
7
|
+
PropertyType["ObjectProperty"] = "http://www.w3.org/2002/07/owl#ObjectProperty";
|
|
8
|
+
PropertyType["Property"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property";
|
|
9
|
+
})(PropertyType = exports.PropertyType || (exports.PropertyType = {}));
|
|
10
|
+
//# sourceMappingURL=PropertyTypes.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare enum Scope {
|
|
2
|
+
InPackage = "https://data.vlaanderen.be/id/concept/scope/InPackage",
|
|
3
|
+
InPublicationEnvironment = "https://data.vlaanderen.be/id/concept/scope/InPublicationEnvironment",
|
|
4
|
+
External = "https://data.vlaanderen.be/id/concept/scope/External",
|
|
5
|
+
Undefined = "https://data.vlaanderen.be/id/concept/scope/Undefined"
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scope = void 0;
|
|
4
|
+
var Scope;
|
|
5
|
+
(function (Scope) {
|
|
6
|
+
Scope["InPackage"] = "https://data.vlaanderen.be/id/concept/scope/InPackage";
|
|
7
|
+
Scope["InPublicationEnvironment"] = "https://data.vlaanderen.be/id/concept/scope/InPublicationEnvironment";
|
|
8
|
+
Scope["External"] = "https://data.vlaanderen.be/id/concept/scope/External";
|
|
9
|
+
Scope["Undefined"] = "https://data.vlaanderen.be/id/concept/scope/Undefined";
|
|
10
|
+
})(Scope = exports.Scope || (exports.Scope = {}));
|
|
11
|
+
//# sourceMappingURL=Scope.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Container } from 'inversify';
|
|
3
|
+
import type { IConfiguration } from '@oslo-core/lib/interfaces/IConfiguration';
|
|
4
|
+
import type { IService } from '@oslo-core/lib/interfaces/IService';
|
|
5
|
+
export type CliArgv = string[];
|
|
6
|
+
export type YargsParams = {
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
_: (string | number)[];
|
|
9
|
+
$0: string;
|
|
10
|
+
} | {
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
_: (string | number)[];
|
|
13
|
+
$0: string;
|
|
14
|
+
};
|
|
15
|
+
export declare abstract class AppRunner<T extends IService, K extends IConfiguration> {
|
|
16
|
+
runCliSync(process: NodeJS.Process): void;
|
|
17
|
+
abstract runCli(argv: CliArgv): Promise<void>;
|
|
18
|
+
startApp(params: YargsParams, container: Container): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppRunner = void 0;
|
|
4
|
+
const process_1 = require("process");
|
|
5
|
+
const LogUtil_1 = require("@oslo-core/lib/logging/LogUtil");
|
|
6
|
+
const ServiceIdentifier_1 = require("@oslo-core/lib/ServiceIdentifier");
|
|
7
|
+
class AppRunner {
|
|
8
|
+
runCliSync(process) {
|
|
9
|
+
this.runCli(process.argv).catch((error) => {
|
|
10
|
+
process_1.stderr.write(error.message);
|
|
11
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async startApp(params, container) {
|
|
16
|
+
const configuration = container.get(ServiceIdentifier_1.ServiceIdentifier.Configuration);
|
|
17
|
+
await configuration.createFromCli(params);
|
|
18
|
+
(0, LogUtil_1.setLoggerFactory)(params);
|
|
19
|
+
container.bind(ServiceIdentifier_1.ServiceIdentifier.Logger).toDynamicValue(() => (0, LogUtil_1.createLogger)()).inSingletonScope();
|
|
20
|
+
const service = container.get(ServiceIdentifier_1.ServiceIdentifier.Service);
|
|
21
|
+
service.init()
|
|
22
|
+
.then(() => service.run())
|
|
23
|
+
.catch(error => console.error(error));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.AppRunner = AppRunner;
|
|
27
|
+
//# sourceMappingURL=AppRunner.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IConfiguration } from '@oslo-core/lib/interfaces/IConfiguration';
|
|
2
|
+
import type { Logger } from '@oslo-core/lib/logging/Logger';
|
|
3
|
+
/**
|
|
4
|
+
* Interface that must be implemented by conversion of generation services
|
|
5
|
+
*/
|
|
6
|
+
export interface IService {
|
|
7
|
+
logger: Logger;
|
|
8
|
+
configuration: IConfiguration;
|
|
9
|
+
init: () => Promise<void>;
|
|
10
|
+
run: () => Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setLoggerFactory = exports.createLogger = void 0;
|
|
4
|
+
const VoidLoggerFactory_1 = require("@oslo-core/lib/logging/VoidLoggerFactory");
|
|
5
|
+
const WinstonLoggerFactory_1 = require("@oslo-core/lib/logging/WinstonLoggerFactory");
|
|
6
|
+
let loggerFactory = new VoidLoggerFactory_1.VoidLoggerFactory();
|
|
7
|
+
function createLogger() {
|
|
8
|
+
return loggerFactory.createLogger();
|
|
9
|
+
}
|
|
10
|
+
exports.createLogger = createLogger;
|
|
11
|
+
function setLoggerFactory(params) {
|
|
12
|
+
if (!params.silent) {
|
|
13
|
+
loggerFactory = new WinstonLoggerFactory_1.WinstonLoggerFactory(params.logLevel);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.setLoggerFactory = setLoggerFactory;
|
|
17
|
+
//# sourceMappingURL=LogUtil.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { LogLevel } from '@oslo-core/lib/logging/LogLevel';
|
|
3
|
+
export interface Logger {
|
|
4
|
+
log: (level: LogLevel, message: string) => Logger;
|
|
5
|
+
error: (message: string) => Logger;
|
|
6
|
+
warn: (message: string) => Logger;
|
|
7
|
+
info: (message: string) => Logger;
|
|
8
|
+
verbose: (message: string) => Logger;
|
|
9
|
+
debug: (message: string) => Logger;
|
|
10
|
+
silly: (message: string) => Logger;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class BaseLogger implements Logger {
|
|
13
|
+
abstract log(level: LogLevel, message: string): Logger;
|
|
14
|
+
error(message: string): Logger;
|
|
15
|
+
warn(message: string): Logger;
|
|
16
|
+
info(message: string): Logger;
|
|
17
|
+
verbose(message: string): Logger;
|
|
18
|
+
debug(message: string): Logger;
|
|
19
|
+
silly(message: string): Logger;
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BaseLogger = void 0;
|
|
10
|
+
require("reflect-metadata");
|
|
11
|
+
const inversify_1 = require("inversify");
|
|
12
|
+
let BaseLogger = class BaseLogger {
|
|
13
|
+
error(message) {
|
|
14
|
+
return this.log('error', message);
|
|
15
|
+
}
|
|
16
|
+
warn(message) {
|
|
17
|
+
return this.log('warn', message);
|
|
18
|
+
}
|
|
19
|
+
info(message) {
|
|
20
|
+
return this.log('info', message);
|
|
21
|
+
}
|
|
22
|
+
verbose(message) {
|
|
23
|
+
return this.log('verbose', message);
|
|
24
|
+
}
|
|
25
|
+
debug(message) {
|
|
26
|
+
return this.log('debug', message);
|
|
27
|
+
}
|
|
28
|
+
silly(message) {
|
|
29
|
+
return this.log('silly', message);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
BaseLogger = __decorate([
|
|
33
|
+
(0, inversify_1.injectable)()
|
|
34
|
+
], BaseLogger);
|
|
35
|
+
exports.BaseLogger = BaseLogger;
|
|
36
|
+
//# sourceMappingURL=Logger.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Logger } from '@oslo-core/lib/logging/Logger';
|
|
2
|
+
/**
|
|
3
|
+
* Instantiates new logger instances.
|
|
4
|
+
*/
|
|
5
|
+
export interface LoggerFactory {
|
|
6
|
+
/**
|
|
7
|
+
* Create a logger instance for the given label.
|
|
8
|
+
* @param label - A label that is used to identify the given logger.
|
|
9
|
+
*/
|
|
10
|
+
createLogger: (label?: string) => Logger;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Logger } from '@oslo-core/lib/logging/Logger';
|
|
2
|
+
import { BaseLogger } from '@oslo-core/lib/logging/Logger';
|
|
3
|
+
import type { LogLevel } from '@oslo-core/lib/logging/LogLevel';
|
|
4
|
+
export declare class VoidLogger extends BaseLogger {
|
|
5
|
+
constructor();
|
|
6
|
+
log(level: LogLevel, message: string): Logger;
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VoidLogger = void 0;
|
|
13
|
+
const inversify_1 = require("inversify");
|
|
14
|
+
const Logger_1 = require("@oslo-core/lib/logging/Logger");
|
|
15
|
+
let VoidLogger = class VoidLogger extends Logger_1.BaseLogger {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
log(level, message) {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
VoidLogger = __decorate([
|
|
24
|
+
(0, inversify_1.injectable)(),
|
|
25
|
+
__metadata("design:paramtypes", [])
|
|
26
|
+
], VoidLogger);
|
|
27
|
+
exports.VoidLogger = VoidLogger;
|
|
28
|
+
//# sourceMappingURL=VoidLogger.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LoggerFactory } from '@oslo-core/lib/logging/LoggerFactory';
|
|
2
|
+
import { VoidLogger } from '@oslo-core/lib/logging/VoidLogger';
|
|
3
|
+
/**
|
|
4
|
+
* A factory that always returns {@link VoidLogger}, which does nothing on log messages.
|
|
5
|
+
*/
|
|
6
|
+
export declare class VoidLoggerFactory implements LoggerFactory {
|
|
7
|
+
private readonly logger;
|
|
8
|
+
createLogger(label?: string): VoidLogger;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoidLoggerFactory = void 0;
|
|
4
|
+
const VoidLogger_1 = require("@oslo-core/lib/logging/VoidLogger");
|
|
5
|
+
/**
|
|
6
|
+
* A factory that always returns {@link VoidLogger}, which does nothing on log messages.
|
|
7
|
+
*/
|
|
8
|
+
class VoidLoggerFactory {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.logger = new VoidLogger_1.VoidLogger();
|
|
11
|
+
}
|
|
12
|
+
createLogger(label) {
|
|
13
|
+
return this.logger;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.VoidLoggerFactory = VoidLoggerFactory;
|
|
17
|
+
//# sourceMappingURL=VoidLoggerFactory.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Logger as WinstonInnerLogger } from 'winston';
|
|
2
|
+
import { BaseLogger } from '@oslo-core/lib/logging/Logger';
|
|
3
|
+
import type { LogLevel } from '@oslo-core/lib/logging/LogLevel';
|
|
4
|
+
export declare class WinstonLogger extends BaseLogger {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(logger: WinstonInnerLogger);
|
|
7
|
+
log(level: LogLevel, message: string): this;
|
|
8
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WinstonLogger = void 0;
|
|
13
|
+
const inversify_1 = require("inversify");
|
|
14
|
+
const winston_1 = require("winston");
|
|
15
|
+
const Logger_1 = require("@oslo-core/lib/logging/Logger");
|
|
16
|
+
let WinstonLogger = class WinstonLogger extends Logger_1.BaseLogger {
|
|
17
|
+
constructor(logger) {
|
|
18
|
+
super();
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
}
|
|
21
|
+
log(level, message) {
|
|
22
|
+
this.logger.log(level, message);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
WinstonLogger = __decorate([
|
|
27
|
+
(0, inversify_1.injectable)(),
|
|
28
|
+
__metadata("design:paramtypes", [winston_1.Logger])
|
|
29
|
+
], WinstonLogger);
|
|
30
|
+
exports.WinstonLogger = WinstonLogger;
|
|
31
|
+
//# sourceMappingURL=WinstonLogger.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as Transport from 'winston-transport';
|
|
2
|
+
import type { Logger } from '@oslo-core/lib/logging/Logger';
|
|
3
|
+
import type { LoggerFactory } from '@oslo-core/lib/logging/LoggerFactory';
|
|
4
|
+
import type { LogLevel } from '@oslo-core/lib/logging/LogLevel';
|
|
5
|
+
export declare class WinstonLoggerFactory implements LoggerFactory {
|
|
6
|
+
private readonly level;
|
|
7
|
+
constructor(level: LogLevel);
|
|
8
|
+
createLogger(label?: string): Logger;
|
|
9
|
+
protected createTransports(): Transport[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WinstonLoggerFactory = void 0;
|
|
4
|
+
const winston_1 = require("winston");
|
|
5
|
+
const WinstonLogger_1 = require("@oslo-core/lib/logging/WinstonLogger");
|
|
6
|
+
const { combine, colorize, printf } = winston_1.format;
|
|
7
|
+
const messageFormat = printf(({ level, message, messageTimestamp }) => `${new Date(Date.now()).toISOString()} ${level}: ${message}`);
|
|
8
|
+
class WinstonLoggerFactory {
|
|
9
|
+
constructor(level) {
|
|
10
|
+
this.level = level;
|
|
11
|
+
}
|
|
12
|
+
createLogger(label) {
|
|
13
|
+
return new WinstonLogger_1.WinstonLogger((0, winston_1.createLogger)({
|
|
14
|
+
level: this.level,
|
|
15
|
+
transports: this.createTransports(),
|
|
16
|
+
format: combine(colorize(), messageFormat),
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
createTransports() {
|
|
20
|
+
return [new winston_1.transports.Console()];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.WinstonLoggerFactory = WinstonLoggerFactory;
|
|
24
|
+
//# sourceMappingURL=WinstonLoggerFactory.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type * as RDF from '@rdfjs/types';
|
|
2
|
+
export declare class QuadStore {
|
|
3
|
+
private readonly store;
|
|
4
|
+
constructor();
|
|
5
|
+
addQuads(quads: RDF.Quad[]): void;
|
|
6
|
+
addQuad(quad: RDF.Quad): void;
|
|
7
|
+
addQuadsFromFile(file: string): Promise<void>;
|
|
8
|
+
findQuads(subject: RDF.Term | null, predicate: RDF.Term | null, object: RDF.Term | null, graph?: RDF.Term | null): RDF.Quad[];
|
|
9
|
+
findQuad(subject: RDF.Term | null, predicate: RDF.Term | null, object: RDF.Term | null, graph?: RDF.Term | null): RDF.Quad | undefined;
|
|
10
|
+
findSubjects(predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term | null): RDF.Term[];
|
|
11
|
+
findSubject(predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term | null): RDF.Term | undefined;
|
|
12
|
+
findObjects(subject: RDF.Term, predicate: RDF.Term, graph?: RDF.Term | null): RDF.Term[];
|
|
13
|
+
findObject(subject: RDF.Term, predicate: RDF.Term, graph?: RDF.Term | null): RDF.Term | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Finds the subject where predicate is 'rdf:type' and object 'oslo:Package'
|
|
16
|
+
* @returns a RDF.NamedNode or undefined
|
|
17
|
+
*/
|
|
18
|
+
getPackageId(): RDF.NamedNode | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:Class'
|
|
21
|
+
* @returns an array of RDF.NamedNodes
|
|
22
|
+
*/
|
|
23
|
+
getClassIds(graph?: RDF.Term | null): RDF.NamedNode[];
|
|
24
|
+
/**
|
|
25
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:DatatypeProperty'
|
|
26
|
+
* @returns an array of RDF.NamedNodes
|
|
27
|
+
*/
|
|
28
|
+
getDatatypePropertyIds(graph?: RDF.Term | null): RDF.NamedNode[];
|
|
29
|
+
/**
|
|
30
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:ObjectProperty'
|
|
31
|
+
* @returns an array of RDF.NamedNodes
|
|
32
|
+
*/
|
|
33
|
+
getObjectPropertyIds(graph?: RDF.Term | null): RDF.NamedNode[];
|
|
34
|
+
/**
|
|
35
|
+
* For a given subject, the quad store is queried to find the assigned URI
|
|
36
|
+
* @param subject The subject for which the assigned URI is to be retrieved
|
|
37
|
+
* @param store The quad store
|
|
38
|
+
* @returns An RDF.NamedNode or undefined if not found
|
|
39
|
+
*/
|
|
40
|
+
getAssignedUri(subject: RDF.Term, graph?: RDF.Term | null): RDF.NamedNode | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Find all quads with a label predicate (vocLabel, apLabel and diagramLabel) for a given subject
|
|
43
|
+
* @param subject The RDF.Term to find the labels for
|
|
44
|
+
* @param store A N3 quad store
|
|
45
|
+
* @returns An array of RDF.Quads
|
|
46
|
+
*/
|
|
47
|
+
getLabels(subject: RDF.Term, graph?: RDF.Term | null): RDF.Quad[];
|
|
48
|
+
/**
|
|
49
|
+
* Finds the oslo:vocLabel whose language tag matches the given language
|
|
50
|
+
* @param subject The RDF.Term to find the oslo:vocLabel for
|
|
51
|
+
* @param store A N3 quad store
|
|
52
|
+
* @param language A language tag
|
|
53
|
+
* @returns An RDF.Literal or undefined if not found
|
|
54
|
+
*/
|
|
55
|
+
getVocLabel(subject: RDF.Term, language?: string, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Finds the oslo:apLabel whose language tag matches the given language
|
|
58
|
+
* @param subject The RDF.Term to find the oslo:apLabel for
|
|
59
|
+
* @param store A N3 quad store
|
|
60
|
+
* @param language A language tag
|
|
61
|
+
* @returns An RDF.Literal or undefined if not found
|
|
62
|
+
*/
|
|
63
|
+
getApLabel(subject: RDF.Term, language?: string, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Finds the oslo:diagramLabel for a given subject
|
|
66
|
+
* @param subject The RDF.Term to find the oslo:diagramLabel for
|
|
67
|
+
* @param store A N3 quad store
|
|
68
|
+
* @param language A language tag
|
|
69
|
+
* @returns An RDF.Literal or undefined if not found
|
|
70
|
+
*/
|
|
71
|
+
getDiagramLabel(subject: RDF.Term, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Find all definitions for a given subject
|
|
74
|
+
* @param subject The RDF.Term to find the definitions for
|
|
75
|
+
* @param store A N3 quad store
|
|
76
|
+
* @returns An array of RDF.Literals
|
|
77
|
+
*/
|
|
78
|
+
getDefinitions(subject: RDF.Term, graph?: RDF.Term | null): RDF.Quad[];
|
|
79
|
+
/**
|
|
80
|
+
* Finds the oslo:vocDefinition whose language tag matches the given language
|
|
81
|
+
* @param subject The RDF.Term to find the oslo:vocDefinition for
|
|
82
|
+
* @param store A N3 quad store
|
|
83
|
+
* @param language A language tag
|
|
84
|
+
* @returns An RDF.Literal or undefined if not found
|
|
85
|
+
*/
|
|
86
|
+
getVocDefinition(subject: RDF.Term, language?: string, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Finds the oslo:apDefinition whose language tag matches the given language
|
|
89
|
+
* @param subject The RDF.Term to find the oslo:apDefinition for
|
|
90
|
+
* @param store A N3 quad store
|
|
91
|
+
* @param language A language tag
|
|
92
|
+
* @returns An RDF.Literal or undefined if not found
|
|
93
|
+
*/
|
|
94
|
+
getApDefinition(subject: RDF.Term, language?: string, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Finds the rdfs:range of a given RDF.Term
|
|
97
|
+
* @param subject The RDF.Term to find the range of
|
|
98
|
+
* @param store A N3 quad store
|
|
99
|
+
* @returns An RDF.Term or undefined if not found
|
|
100
|
+
*/
|
|
101
|
+
getRange(subject: RDF.Term, graph?: RDF.Term | null): RDF.NamedNode | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Finds the rdfs:domain of a given RDF.Term
|
|
104
|
+
* @param subject The RDF.Term to find the domain of
|
|
105
|
+
* @param store A N3 quad store
|
|
106
|
+
* @returns An RDF.Term or undefined if not found
|
|
107
|
+
*/
|
|
108
|
+
getDomain(subject: RDF.Term, graph?: RDF.Term | null): RDF.NamedNode | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Finds all the usageNotes (voc and ap) of a given RDF.Term
|
|
111
|
+
* @param subject The RDF.Term to find the usage notes for
|
|
112
|
+
* @param store A N3 quad store
|
|
113
|
+
* @returns An array of RDF.Literals
|
|
114
|
+
*/
|
|
115
|
+
getUsageNotes(subject: RDF.Term, graph?: RDF.Term | null): RDF.Quad[];
|
|
116
|
+
/**
|
|
117
|
+
* Finds the oslo:vocUsageNote of which the language tag matches the given language
|
|
118
|
+
* @param subject The RDF.Term to find the vocabulary usage note for
|
|
119
|
+
* @param store A N3 quad store
|
|
120
|
+
* @param language A language tag
|
|
121
|
+
* @returns An RDF.Literal or undefined if not found
|
|
122
|
+
*/
|
|
123
|
+
getVocUsageNote(subject: RDF.Term, language?: string, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Finds the oslo:apUsageNote of which the language tag matches the given language
|
|
126
|
+
* @param subject The RDF.Term to find the application profile usage note for
|
|
127
|
+
* @param store A N3 quad store
|
|
128
|
+
* @param language A language tag
|
|
129
|
+
* @returns An RDF.Literal or undefined if not found
|
|
130
|
+
*/
|
|
131
|
+
getApUsageNote(subject: RDF.Term, language?: string, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Finds the example:scope of a given subject
|
|
134
|
+
* @param subject The RDF.Term to find the scope for
|
|
135
|
+
* @returns An RDF.NamedNode or undefined if not found
|
|
136
|
+
*/
|
|
137
|
+
getScope(subject: RDF.Term, graph?: RDF.Term | null): RDF.NamedNode | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Finds the shacl:minCardinality for a given subject
|
|
140
|
+
* @param subject The RDF.Term to find the shacl:minCardinaly for
|
|
141
|
+
* @returns An RDF.Literal or undefined if not found
|
|
142
|
+
*/
|
|
143
|
+
getMinCardinality(subject: RDF.Term, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Finds the shacl:maxCardinality for a given subject
|
|
146
|
+
* @param subject The RDF.Term to find the shacl:maxCardinaly for
|
|
147
|
+
* @returns An RDF.Literal or undefined if not found
|
|
148
|
+
*/
|
|
149
|
+
getMaxCardinality(subject: RDF.Term, graph?: RDF.Term | null): RDF.Literal | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Finds all the rdfs:subClassOf of a given RDF.Term
|
|
152
|
+
* @param subject the RDF.Term to find the parents of
|
|
153
|
+
* @param store A N3 quad store
|
|
154
|
+
* @returns An array of RDF.Terms
|
|
155
|
+
*/
|
|
156
|
+
getParentsOfClass(subject: RDF.Term, graph?: RDF.Term | null): RDF.NamedNode[];
|
|
157
|
+
/**
|
|
158
|
+
* Finds the rdfs:subPropertyOf of a given RDF.Term
|
|
159
|
+
* @param subject The RDF.Term to find the parent of
|
|
160
|
+
* @param store A N3 quad store
|
|
161
|
+
* @returns An RDF.Term or undefined if not found
|
|
162
|
+
*/
|
|
163
|
+
getParentOfProperty(subject: RDF.Term, graph?: RDF.Term | null): RDF.NamedNode | undefined;
|
|
164
|
+
getCodelist(subject: RDF.Term, graph?: RDF.Term | null): RDF.NamedNode | undefined;
|
|
165
|
+
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.QuadStore = void 0;
|
|
39
|
+
const inversify_1 = require("inversify");
|
|
40
|
+
const N3 = __importStar(require("n3"));
|
|
41
|
+
const rdf_parse_1 = __importDefault(require("rdf-parse"));
|
|
42
|
+
const fetchFileOrUrl_1 = require("@oslo-core/lib/utils/fetchFileOrUrl");
|
|
43
|
+
const namespaces_1 = require("@oslo-core/lib/utils/namespaces");
|
|
44
|
+
let QuadStore = class QuadStore {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.store = new N3.Store();
|
|
47
|
+
}
|
|
48
|
+
addQuads(quads) {
|
|
49
|
+
this.store.addQuads(quads);
|
|
50
|
+
}
|
|
51
|
+
addQuad(quad) {
|
|
52
|
+
this.store.addQuad(quad);
|
|
53
|
+
}
|
|
54
|
+
async addQuadsFromFile(file) {
|
|
55
|
+
const buffer = await (0, fetchFileOrUrl_1.fetchFileOrUrl)(file);
|
|
56
|
+
const textStream = require('streamify-string')(buffer.toString());
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
rdf_parse_1.default
|
|
59
|
+
.parse(textStream, { path: file })
|
|
60
|
+
.on('data', (quad) => this.store.addQuad(quad))
|
|
61
|
+
.on('error', (error) => reject(error))
|
|
62
|
+
.on('end', () => resolve());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
findQuads(subject, predicate, object, graph = null) {
|
|
66
|
+
return this.store.getQuads(subject, predicate, object, graph);
|
|
67
|
+
}
|
|
68
|
+
findQuad(subject, predicate, object, graph = null) {
|
|
69
|
+
return this.findQuads(subject, predicate, object, graph).shift();
|
|
70
|
+
}
|
|
71
|
+
findSubjects(predicate, object, graph = null) {
|
|
72
|
+
return this.store.getSubjects(predicate, object, graph);
|
|
73
|
+
}
|
|
74
|
+
findSubject(predicate, object, graph = null) {
|
|
75
|
+
return this.findSubjects(predicate, object, graph).shift();
|
|
76
|
+
}
|
|
77
|
+
findObjects(subject, predicate, graph = null) {
|
|
78
|
+
return this.store.getObjects(subject, predicate, graph);
|
|
79
|
+
}
|
|
80
|
+
findObject(subject, predicate, graph = null) {
|
|
81
|
+
return this.findObjects(subject, predicate, graph).shift();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Finds the subject where predicate is 'rdf:type' and object 'oslo:Package'
|
|
85
|
+
* @returns a RDF.NamedNode or undefined
|
|
86
|
+
*/
|
|
87
|
+
getPackageId() {
|
|
88
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.oslo('Package'), null).shift());
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:Class'
|
|
92
|
+
* @returns an array of RDF.NamedNodes
|
|
93
|
+
*/
|
|
94
|
+
getClassIds(graph = null) {
|
|
95
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('Class'), graph));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:DatatypeProperty'
|
|
99
|
+
* @returns an array of RDF.NamedNodes
|
|
100
|
+
*/
|
|
101
|
+
getDatatypePropertyIds(graph = null) {
|
|
102
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('DatatypeProperty'), graph));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Finds all subjects where predicate is 'rdf:type' and object 'owl:ObjectProperty'
|
|
106
|
+
* @returns an array of RDF.NamedNodes
|
|
107
|
+
*/
|
|
108
|
+
getObjectPropertyIds(graph = null) {
|
|
109
|
+
return (this.store.getSubjects(namespaces_1.ns.rdf('type'), namespaces_1.ns.owl('ObjectProperty'), graph));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* For a given subject, the quad store is queried to find the assigned URI
|
|
113
|
+
* @param subject The subject for which the assigned URI is to be retrieved
|
|
114
|
+
* @param store The quad store
|
|
115
|
+
* @returns An RDF.NamedNode or undefined if not found
|
|
116
|
+
*/
|
|
117
|
+
getAssignedUri(subject, graph = null) {
|
|
118
|
+
return (this.store.getObjects(subject, namespaces_1.ns.oslo('assignedURI'), graph).shift());
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Find all quads with a label predicate (vocLabel, apLabel and diagramLabel) for a given subject
|
|
122
|
+
* @param subject The RDF.Term to find the labels for
|
|
123
|
+
* @param store A N3 quad store
|
|
124
|
+
* @returns An array of RDF.Quads
|
|
125
|
+
*/
|
|
126
|
+
getLabels(subject, graph = null) {
|
|
127
|
+
const vocLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('vocLabel'), null, graph);
|
|
128
|
+
const apLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('apLabel'), null, graph);
|
|
129
|
+
const diagramLabel = this.store.getQuads(subject, namespaces_1.ns.oslo('diagramLabel'), null, graph);
|
|
130
|
+
return vocLabel.concat(apLabel).concat(diagramLabel);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Finds the oslo:vocLabel whose language tag matches the given language
|
|
134
|
+
* @param subject The RDF.Term to find the oslo:vocLabel for
|
|
135
|
+
* @param store A N3 quad store
|
|
136
|
+
* @param language A language tag
|
|
137
|
+
* @returns An RDF.Literal or undefined if not found
|
|
138
|
+
*/
|
|
139
|
+
getVocLabel(subject, language, graph = null) {
|
|
140
|
+
var _a;
|
|
141
|
+
return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocLabel')) &&
|
|
142
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Finds the oslo:apLabel whose language tag matches the given language
|
|
146
|
+
* @param subject The RDF.Term to find the oslo:apLabel for
|
|
147
|
+
* @param store A N3 quad store
|
|
148
|
+
* @param language A language tag
|
|
149
|
+
* @returns An RDF.Literal or undefined if not found
|
|
150
|
+
*/
|
|
151
|
+
getApLabel(subject, language, graph = null) {
|
|
152
|
+
var _a;
|
|
153
|
+
return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apLabel')) &&
|
|
154
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Finds the oslo:diagramLabel for a given subject
|
|
158
|
+
* @param subject The RDF.Term to find the oslo:diagramLabel for
|
|
159
|
+
* @param store A N3 quad store
|
|
160
|
+
* @param language A language tag
|
|
161
|
+
* @returns An RDF.Literal or undefined if not found
|
|
162
|
+
*/
|
|
163
|
+
getDiagramLabel(subject, graph = null) {
|
|
164
|
+
var _a;
|
|
165
|
+
return (_a = this.getLabels(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('diagramLabel')))) === null || _a === void 0 ? void 0 : _a.object;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Find all definitions for a given subject
|
|
169
|
+
* @param subject The RDF.Term to find the definitions for
|
|
170
|
+
* @param store A N3 quad store
|
|
171
|
+
* @returns An array of RDF.Literals
|
|
172
|
+
*/
|
|
173
|
+
getDefinitions(subject, graph = null) {
|
|
174
|
+
const vocDefinitions = this.store.getQuads(subject, namespaces_1.ns.oslo('vocDefinition'), null, graph);
|
|
175
|
+
const apDefinitions = this.store.getQuads(subject, namespaces_1.ns.oslo('apDefinition'), null, graph);
|
|
176
|
+
return vocDefinitions.concat(apDefinitions);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Finds the oslo:vocDefinition whose language tag matches the given language
|
|
180
|
+
* @param subject The RDF.Term to find the oslo:vocDefinition for
|
|
181
|
+
* @param store A N3 quad store
|
|
182
|
+
* @param language A language tag
|
|
183
|
+
* @returns An RDF.Literal or undefined if not found
|
|
184
|
+
*/
|
|
185
|
+
getVocDefinition(subject, language, graph = null) {
|
|
186
|
+
var _a;
|
|
187
|
+
return (_a = this.getDefinitions(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocDefinition')) &&
|
|
188
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Finds the oslo:apDefinition whose language tag matches the given language
|
|
192
|
+
* @param subject The RDF.Term to find the oslo:apDefinition for
|
|
193
|
+
* @param store A N3 quad store
|
|
194
|
+
* @param language A language tag
|
|
195
|
+
* @returns An RDF.Literal or undefined if not found
|
|
196
|
+
*/
|
|
197
|
+
getApDefinition(subject, language, graph = null) {
|
|
198
|
+
var _a;
|
|
199
|
+
return (_a = this.getDefinitions(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apDefinition')) &&
|
|
200
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Finds the rdfs:range of a given RDF.Term
|
|
204
|
+
* @param subject The RDF.Term to find the range of
|
|
205
|
+
* @param store A N3 quad store
|
|
206
|
+
* @returns An RDF.Term or undefined if not found
|
|
207
|
+
*/
|
|
208
|
+
getRange(subject, graph = null) {
|
|
209
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('range'), graph).shift());
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Finds the rdfs:domain of a given RDF.Term
|
|
213
|
+
* @param subject The RDF.Term to find the domain of
|
|
214
|
+
* @param store A N3 quad store
|
|
215
|
+
* @returns An RDF.Term or undefined if not found
|
|
216
|
+
*/
|
|
217
|
+
getDomain(subject, graph = null) {
|
|
218
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('domain'), graph).shift());
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Finds all the usageNotes (voc and ap) of a given RDF.Term
|
|
222
|
+
* @param subject The RDF.Term to find the usage notes for
|
|
223
|
+
* @param store A N3 quad store
|
|
224
|
+
* @returns An array of RDF.Literals
|
|
225
|
+
*/
|
|
226
|
+
getUsageNotes(subject, graph = null) {
|
|
227
|
+
const vocUsageNotes = this.store.getQuads(subject, namespaces_1.ns.oslo('vocUsageNote'), null, graph);
|
|
228
|
+
const apUsageNotes = this.store.getQuads(subject, namespaces_1.ns.oslo('apUsageNote'), null, graph);
|
|
229
|
+
return vocUsageNotes.concat(apUsageNotes);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Finds the oslo:vocUsageNote of which the language tag matches the given language
|
|
233
|
+
* @param subject The RDF.Term to find the vocabulary usage note for
|
|
234
|
+
* @param store A N3 quad store
|
|
235
|
+
* @param language A language tag
|
|
236
|
+
* @returns An RDF.Literal or undefined if not found
|
|
237
|
+
*/
|
|
238
|
+
getVocUsageNote(subject, language, graph = null) {
|
|
239
|
+
var _a;
|
|
240
|
+
return (_a = this.getUsageNotes(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('vocUsageNote')) &&
|
|
241
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Finds the oslo:apUsageNote of which the language tag matches the given language
|
|
245
|
+
* @param subject The RDF.Term to find the application profile usage note for
|
|
246
|
+
* @param store A N3 quad store
|
|
247
|
+
* @param language A language tag
|
|
248
|
+
* @returns An RDF.Literal or undefined if not found
|
|
249
|
+
*/
|
|
250
|
+
getApUsageNote(subject, language, graph = null) {
|
|
251
|
+
var _a;
|
|
252
|
+
return (_a = this.getUsageNotes(subject, graph).find((x) => x.predicate.equals(namespaces_1.ns.oslo('apUsageNote')) &&
|
|
253
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Finds the example:scope of a given subject
|
|
257
|
+
* @param subject The RDF.Term to find the scope for
|
|
258
|
+
* @returns An RDF.NamedNode or undefined if not found
|
|
259
|
+
*/
|
|
260
|
+
getScope(subject, graph = null) {
|
|
261
|
+
return (this.store.getObjects(subject, namespaces_1.ns.oslo('scope'), graph).shift());
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Finds the shacl:minCardinality for a given subject
|
|
265
|
+
* @param subject The RDF.Term to find the shacl:minCardinaly for
|
|
266
|
+
* @returns An RDF.Literal or undefined if not found
|
|
267
|
+
*/
|
|
268
|
+
getMinCardinality(subject, graph = null) {
|
|
269
|
+
return (this.store.getObjects(subject, namespaces_1.ns.shacl('minCount'), graph).shift());
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Finds the shacl:maxCardinality for a given subject
|
|
273
|
+
* @param subject The RDF.Term to find the shacl:maxCardinaly for
|
|
274
|
+
* @returns An RDF.Literal or undefined if not found
|
|
275
|
+
*/
|
|
276
|
+
getMaxCardinality(subject, graph = null) {
|
|
277
|
+
return (this.store.getObjects(subject, namespaces_1.ns.shacl('maxCount'), graph).shift());
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Finds all the rdfs:subClassOf of a given RDF.Term
|
|
281
|
+
* @param subject the RDF.Term to find the parents of
|
|
282
|
+
* @param store A N3 quad store
|
|
283
|
+
* @returns An array of RDF.Terms
|
|
284
|
+
*/
|
|
285
|
+
getParentsOfClass(subject, graph = null) {
|
|
286
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('subClassOf'), graph));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Finds the rdfs:subPropertyOf of a given RDF.Term
|
|
290
|
+
* @param subject The RDF.Term to find the parent of
|
|
291
|
+
* @param store A N3 quad store
|
|
292
|
+
* @returns An RDF.Term or undefined if not found
|
|
293
|
+
*/
|
|
294
|
+
getParentOfProperty(subject, graph = null) {
|
|
295
|
+
return (this.store.getObjects(subject, namespaces_1.ns.rdfs('subPropertyOf'), graph).shift());
|
|
296
|
+
}
|
|
297
|
+
getCodelist(subject, graph = null) {
|
|
298
|
+
return (this.store.getObjects(subject, namespaces_1.ns.oslo('codelist'), graph).shift());
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
QuadStore = __decorate([
|
|
302
|
+
(0, inversify_1.injectable)(),
|
|
303
|
+
__metadata("design:paramtypes", [])
|
|
304
|
+
], QuadStore);
|
|
305
|
+
exports.QuadStore = QuadStore;
|
|
306
|
+
//# sourceMappingURL=QuadStore.js.map
|
|
@@ -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,24 @@
|
|
|
1
|
+
declare enum Prefixes {
|
|
2
|
+
adms = "http://www.w3.org/ns/adms#",
|
|
3
|
+
dcat = "http://www.w3.org/ns/dcat#",
|
|
4
|
+
dcterms = "http://purl.org/dc/terms/",
|
|
5
|
+
foaf = "http://xmlns.com/foaf/0.1/",
|
|
6
|
+
owl = "http://www.w3.org/2002/07/owl#",
|
|
7
|
+
vlaanderen = "https://data.vlaanderen.be/ns/",
|
|
8
|
+
void = "http://rdfs.org/ns/void#",
|
|
9
|
+
rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
10
|
+
rdfs = "http://www.w3.org/2000/01/rdf-schema#",
|
|
11
|
+
qb = "http://purl.org/linked-data/cube#",
|
|
12
|
+
skos = "http://www.w3.org/2004/02/skos/core#",
|
|
13
|
+
xsd = "http://www.w3.org/2001/XMLSchema#",
|
|
14
|
+
person = "http://www.w3.org/ns/person#",
|
|
15
|
+
vann = "http://purl.org/vocab/vann/",
|
|
16
|
+
shacl = "http://w3.org/ns/shacl#",
|
|
17
|
+
prov = "http://www.w3.org/ns/prov#",
|
|
18
|
+
oslo = "https://implementatie.data.vlaanderen.be/ns/oslo-toolchain#"
|
|
19
|
+
}
|
|
20
|
+
export type Namespace = {
|
|
21
|
+
[T in keyof typeof Prefixes]: Function;
|
|
22
|
+
};
|
|
23
|
+
export declare const ns: Namespace;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
var Prefixes;
|
|
7
|
+
(function (Prefixes) {
|
|
8
|
+
Prefixes["adms"] = "http://www.w3.org/ns/adms#";
|
|
9
|
+
Prefixes["dcat"] = "http://www.w3.org/ns/dcat#";
|
|
10
|
+
Prefixes["dcterms"] = "http://purl.org/dc/terms/";
|
|
11
|
+
Prefixes["foaf"] = "http://xmlns.com/foaf/0.1/";
|
|
12
|
+
Prefixes["owl"] = "http://www.w3.org/2002/07/owl#";
|
|
13
|
+
Prefixes["vlaanderen"] = "https://data.vlaanderen.be/ns/";
|
|
14
|
+
Prefixes["void"] = "http://rdfs.org/ns/void#";
|
|
15
|
+
Prefixes["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
|
16
|
+
Prefixes["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";
|
|
17
|
+
Prefixes["qb"] = "http://purl.org/linked-data/cube#";
|
|
18
|
+
Prefixes["skos"] = "http://www.w3.org/2004/02/skos/core#";
|
|
19
|
+
Prefixes["xsd"] = "http://www.w3.org/2001/XMLSchema#";
|
|
20
|
+
Prefixes["person"] = "http://www.w3.org/ns/person#";
|
|
21
|
+
Prefixes["vann"] = "http://purl.org/vocab/vann/";
|
|
22
|
+
Prefixes["shacl"] = "http://w3.org/ns/shacl#";
|
|
23
|
+
Prefixes["prov"] = "http://www.w3.org/ns/prov#";
|
|
24
|
+
Prefixes["oslo"] = "https://implementatie.data.vlaanderen.be/ns/oslo-toolchain#";
|
|
25
|
+
})(Prefixes || (Prefixes = {}));
|
|
26
|
+
const vocab = () => {
|
|
27
|
+
const namespaces = {};
|
|
28
|
+
for (const prefix in Prefixes) {
|
|
29
|
+
const expansion = Prefixes[prefix];
|
|
30
|
+
namespaces[prefix] = (localName = '') => factory.namedNode(expansion + localName);
|
|
31
|
+
}
|
|
32
|
+
return namespaces;
|
|
33
|
+
};
|
|
34
|
+
exports.ns = vocab();
|
|
35
|
+
//# sourceMappingURL=namespaces.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as RDF from '@rdfjs/types';
|
|
2
|
+
import type { QuadStore } from '@oslo-core/lib/store/QuadStore';
|
|
3
|
+
export declare function getApplicationProfileLabel(subject: RDF.Term, store: QuadStore, language?: string | null): RDF.Literal | undefined;
|
|
4
|
+
export declare function getVocabularyLabel(subject: RDF.Term, store: QuadStore, language?: string | null): RDF.Literal | undefined;
|
|
5
|
+
export declare function getApplicationProfileDefinition(subject: RDF.Term, store: QuadStore, language?: string | null): RDF.Literal | undefined;
|
|
6
|
+
export declare function getVocabularyDefinition(subject: RDF.Term, store: QuadStore, language?: string | null): RDF.Literal | undefined;
|
|
7
|
+
export declare function getApplicationProfileUsageNote(subject: RDF.Term, store: QuadStore, language?: string | null): RDF.Literal | undefined;
|
|
8
|
+
export declare function getVocabularyUsageNote(subject: RDF.Term, store: QuadStore, language?: string | null): RDF.Literal | undefined;
|
|
9
|
+
export declare function getMinCount(subject: RDF.Term, store: QuadStore): string | undefined;
|
|
10
|
+
export declare function getMaxCount(subject: RDF.Term, store: QuadStore): string | undefined;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMaxCount = exports.getMinCount = exports.getVocabularyUsageNote = exports.getApplicationProfileUsageNote = exports.getVocabularyDefinition = exports.getApplicationProfileDefinition = exports.getVocabularyLabel = exports.getApplicationProfileLabel = void 0;
|
|
4
|
+
const namespaces_1 = require("@oslo-core/lib/utils/namespaces");
|
|
5
|
+
function getApplicationProfileLabel(subject, store, language = null) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
const labels = store.getLabels(subject);
|
|
8
|
+
if (labels.some(x => x.predicate.equals(namespaces_1.ns.oslo('apLabel')))) {
|
|
9
|
+
return (_a = labels
|
|
10
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('apLabel')) &&
|
|
11
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
12
|
+
}
|
|
13
|
+
if (labels.some(x => x.predicate.equals(namespaces_1.ns.oslo('vocLabel')))) {
|
|
14
|
+
return (_b = labels.find(x => x.predicate.equals(namespaces_1.ns.oslo('vocLabel')) &&
|
|
15
|
+
x.object.language === (language || ''))) === null || _b === void 0 ? void 0 : _b.object;
|
|
16
|
+
}
|
|
17
|
+
return (_c = labels.find(x => x.predicate.equals(namespaces_1.ns.oslo('diagramLabel')))) === null || _c === void 0 ? void 0 : _c.object;
|
|
18
|
+
}
|
|
19
|
+
exports.getApplicationProfileLabel = getApplicationProfileLabel;
|
|
20
|
+
function getVocabularyLabel(subject, store, language = null) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const labels = store.getLabels(subject);
|
|
23
|
+
if (labels.some(x => x.predicate.equals(namespaces_1.ns.oslo('vocLabel')))) {
|
|
24
|
+
return (_a = labels
|
|
25
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('vocLabel')) &&
|
|
26
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
27
|
+
}
|
|
28
|
+
return (_b = labels.find(x => x.predicate.equals(namespaces_1.ns.oslo('diagramLabel')))) === null || _b === void 0 ? void 0 : _b.object;
|
|
29
|
+
}
|
|
30
|
+
exports.getVocabularyLabel = getVocabularyLabel;
|
|
31
|
+
function getApplicationProfileDefinition(subject, store, language = null) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const definitions = store.getDefinitions(subject);
|
|
34
|
+
if (definitions.some(x => x.predicate.equals(namespaces_1.ns.oslo('apDefinition')))) {
|
|
35
|
+
return (_a = definitions
|
|
36
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('apDefinition')) &&
|
|
37
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
38
|
+
}
|
|
39
|
+
if (definitions.some(x => x.predicate.equals(namespaces_1.ns.oslo('vocDefinition')))) {
|
|
40
|
+
return (_b = definitions
|
|
41
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('vocDefinition')) &&
|
|
42
|
+
x.object.language === (language || ''))) === null || _b === void 0 ? void 0 : _b.object;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
exports.getApplicationProfileDefinition = getApplicationProfileDefinition;
|
|
47
|
+
function getVocabularyDefinition(subject, store, language = null) {
|
|
48
|
+
var _a;
|
|
49
|
+
const definitions = store.getDefinitions(subject);
|
|
50
|
+
if (definitions.some(x => x.predicate.equals(namespaces_1.ns.oslo('vocDefinition')))) {
|
|
51
|
+
return (_a = definitions
|
|
52
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('vocDefinition')) &&
|
|
53
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
exports.getVocabularyDefinition = getVocabularyDefinition;
|
|
58
|
+
function getApplicationProfileUsageNote(subject, store, language = null) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const usageNotes = store.getUsageNotes(subject);
|
|
61
|
+
if (usageNotes.some(x => x.predicate.equals(namespaces_1.ns.oslo('apUsageNote')))) {
|
|
62
|
+
return (_a = usageNotes
|
|
63
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('apUsageNote')) &&
|
|
64
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
65
|
+
}
|
|
66
|
+
if (usageNotes.some(x => x.predicate.equals(namespaces_1.ns.oslo('vocUsageNote')))) {
|
|
67
|
+
return (_b = usageNotes
|
|
68
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('vocUsageNote')) &&
|
|
69
|
+
x.object.language === (language || ''))) === null || _b === void 0 ? void 0 : _b.object;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
exports.getApplicationProfileUsageNote = getApplicationProfileUsageNote;
|
|
74
|
+
function getVocabularyUsageNote(subject, store, language = null) {
|
|
75
|
+
var _a;
|
|
76
|
+
const usageNotes = store.getUsageNotes(subject);
|
|
77
|
+
if (usageNotes.some(x => x.predicate.equals(namespaces_1.ns.oslo('vocUsageNote')))) {
|
|
78
|
+
return (_a = usageNotes
|
|
79
|
+
.find(x => x.predicate.equals(namespaces_1.ns.oslo('vocUsageNote')) &&
|
|
80
|
+
x.object.language === (language || ''))) === null || _a === void 0 ? void 0 : _a.object;
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
exports.getVocabularyUsageNote = getVocabularyUsageNote;
|
|
85
|
+
function getMinCount(subject, store) {
|
|
86
|
+
var _a;
|
|
87
|
+
return (_a = store.findObject(subject, namespaces_1.ns.shacl('minCount'))) === null || _a === void 0 ? void 0 : _a.value;
|
|
88
|
+
}
|
|
89
|
+
exports.getMinCount = getMinCount;
|
|
90
|
+
function getMaxCount(subject, store) {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = store.findObject(subject, namespaces_1.ns.shacl('maxCount'))) === null || _a === void 0 ? void 0 : _a.value;
|
|
93
|
+
}
|
|
94
|
+
exports.getMaxCount = getMaxCount;
|
|
95
|
+
//# sourceMappingURL=storeUtils.js.map
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslo-flanders/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11-alpha.0",
|
|
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",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"_moduleAliases": {
|
|
10
|
-
"@oslo-core": "./
|
|
10
|
+
"@oslo-core": "./"
|
|
11
11
|
},
|
|
12
12
|
"directories": {
|
|
13
13
|
"lib": "lib"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
],
|
|
44
44
|
"testEnvironment": "node",
|
|
45
45
|
"moduleNameMapper": {
|
|
46
|
-
"^@oslo-core/(.*)$": "<rootDir
|
|
46
|
+
"^@oslo-core/(.*)$": "<rootDir>/$1"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|