@oslo-flanders/core 1.0.10 → 1.0.11

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 CHANGED
@@ -22,3 +22,6 @@ export * from './lib/logging/LoggerFactory';
22
22
  export * from './lib/logging/VoidLoggerFactory';
23
23
  export * from './lib/logging/WinstonLoggerFactory';
24
24
  export * from './lib/utils/storeUtils';
25
+ export * from './lib/utils/fileSystem';
26
+ export * from './lib/utils/strings';
27
+ export * from './lib/constants/prefixes';
package/index.js CHANGED
@@ -38,4 +38,7 @@ __exportStar(require("./lib/logging/LoggerFactory"), exports);
38
38
  __exportStar(require("./lib/logging/VoidLoggerFactory"), exports);
39
39
  __exportStar(require("./lib/logging/WinstonLoggerFactory"), exports);
40
40
  __exportStar(require("./lib/utils/storeUtils"), exports);
41
+ __exportStar(require("./lib/utils/fileSystem"), exports);
42
+ __exportStar(require("./lib/utils/strings"), exports);
43
+ __exportStar(require("./lib/constants/prefixes"), exports);
41
44
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export declare function getPrefixes(): Promise<Record<string, string>>;
@@ -0,0 +1,36 @@
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.getPrefixes = void 0;
7
+ const core_1 = require("@oslo-flanders/core");
8
+ const node_fetch_1 = __importDefault(require("node-fetch"));
9
+ const PREFIX_CC_URL = 'https://prefix.cc/context';
10
+ async function getPrefixes() {
11
+ const url = PREFIX_CC_URL;
12
+ try {
13
+ const response = await (0, node_fetch_1.default)(url);
14
+ if (!response.ok) {
15
+ throw new Error(`Failed to fetch prefixes: ${response.statusText}`);
16
+ }
17
+ const data = await response.json();
18
+ if (data['@context']) {
19
+ return data['@context'];
20
+ }
21
+ throw new Error('Invalid context format received from prefix.cc');
22
+ }
23
+ catch (error) {
24
+ console.error(`Error fetching prefixes: ${String(error)}`);
25
+ // Fallback to a minimal set of prefixes if the fetch fails
26
+ return {
27
+ skos: core_1.ns.skos(''),
28
+ rdf: core_1.ns.rdf(''),
29
+ rdfs: core_1.ns.rdfs(''),
30
+ dct: core_1.ns.dcterms(''),
31
+ xsd: core_1.ns.xsd(''),
32
+ };
33
+ }
34
+ }
35
+ exports.getPrefixes = getPrefixes;
36
+ //# sourceMappingURL=prefixes.js.map
@@ -0,0 +1 @@
1
+ export declare function ensureOutputDirectory(directory: string): void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // eslint-disable-next-line eslint-comments/disable-enable-pair
3
+ /* eslint-disable no-sync */
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ensureOutputDirectory = void 0;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ function ensureOutputDirectory(directory) {
11
+ if (!fs_1.default.existsSync(directory)) {
12
+ fs_1.default.mkdirSync(directory);
13
+ }
14
+ }
15
+ exports.ensureOutputDirectory = ensureOutputDirectory;
16
+ //# sourceMappingURL=fileSystem.js.map
@@ -8,3 +8,4 @@ export declare function getApplicationProfileUsageNote(subject: RDF.Term, store:
8
8
  export declare function getVocabularyUsageNote(subject: RDF.Term, store: QuadStore, language?: string | null): RDF.Literal | undefined;
9
9
  export declare function getMinCount(subject: RDF.Term, store: QuadStore): string | undefined;
10
10
  export declare function getMaxCount(subject: RDF.Term, store: QuadStore): string | undefined;
11
+ export declare function findAllAttributes(subject: RDF.Term, attributeIds: RDF.Term[], store: QuadStore): RDF.Term[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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;
3
+ exports.findAllAttributes = exports.getMaxCount = exports.getMinCount = exports.getVocabularyUsageNote = exports.getApplicationProfileUsageNote = exports.getVocabularyDefinition = exports.getApplicationProfileDefinition = exports.getVocabularyLabel = exports.getApplicationProfileLabel = void 0;
4
4
  const namespaces_1 = require("./namespaces");
5
5
  function getApplicationProfileLabel(subject, store, language = null) {
6
6
  var _a, _b, _c;
@@ -92,4 +92,16 @@ function getMaxCount(subject, store) {
92
92
  return (_a = store.findObject(subject, namespaces_1.ns.shacl('maxCount'))) === null || _a === void 0 ? void 0 : _a.value;
93
93
  }
94
94
  exports.getMaxCount = getMaxCount;
95
+ function findAllAttributes(subject, attributeIds, store) {
96
+ const parentIds = store.findObjects(subject, namespaces_1.ns.rdfs('subClassOf'));
97
+ attributeIds = [
98
+ ...attributeIds,
99
+ ...store.findSubjects(namespaces_1.ns.rdfs('domain'), subject),
100
+ ];
101
+ for (const parentId of parentIds) {
102
+ attributeIds = findAllAttributes(parentId, attributeIds, store);
103
+ }
104
+ return attributeIds;
105
+ }
106
+ exports.findAllAttributes = findAllAttributes;
95
107
  //# sourceMappingURL=storeUtils.js.map
@@ -0,0 +1,2 @@
1
+ export declare function toPascalCase(text: string): string;
2
+ export declare function toCamelCase(text: string): string;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toCamelCase = exports.toPascalCase = void 0;
4
+ function removeCaret(text) {
5
+ return text.replace(/^\^/u, '');
6
+ }
7
+ function toPascalCase(text) {
8
+ return removeCaret(text)
9
+ .replace(/(?:^\w|[A-Z]|\b\w)/gu, (word, index) => word.toUpperCase())
10
+ .replace(/\s+/gu, '');
11
+ }
12
+ exports.toPascalCase = toPascalCase;
13
+ function toCamelCase(text) {
14
+ return removeCaret(text)
15
+ .replace(/(?:^\w|[A-Z]|\b\w)/gu, (word, index) => index === 0 ? word.toLowerCase() : word.toUpperCase())
16
+ .replace(/\s+/gu, '');
17
+ }
18
+ exports.toCamelCase = toCamelCase;
19
+ //# sourceMappingURL=strings.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslo-flanders/core",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
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",
@@ -33,10 +33,10 @@
33
33
  "crypto-js": "^4.1.1",
34
34
  "inversify": "^6.0.1",
35
35
  "n3": "^1.16.2",
36
- "node-fetch": "^2.6.7",
37
36
  "rdf-data-factory": "^1.1.1",
38
37
  "rdf-parse": "^2.1.1",
39
38
  "reflect-metadata": "^0.1.13",
39
+ "node-fetch": "^2.6.7",
40
40
  "streamify-string": "^1.0.1",
41
41
  "winston": "^3.8.2",
42
42
  "winston-transport": "^4.5.0"