@semapps/ontologies 1.1.4 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/{findNamespace.js → findNamespace.ts} +7 -3
- package/actions/{findPrefix.js → findPrefix.ts} +8 -4
- package/actions/{get.js → get.ts} +8 -2
- package/actions/getPrefixes.ts +16 -0
- package/actions/getRdfPrefixes.ts +15 -0
- package/actions/list.ts +11 -0
- package/actions/{prefixToUri.js → prefixToUri.ts} +8 -3
- package/actions/{register.js → register.ts} +11 -3
- package/dist/actions/findNamespace.d.ts +8 -0
- package/dist/actions/findNamespace.js +19 -0
- package/dist/actions/findNamespace.js.map +1 -0
- package/dist/actions/findPrefix.d.ts +8 -0
- package/dist/actions/findPrefix.js +23 -0
- package/dist/actions/findPrefix.js.map +1 -0
- package/dist/actions/get.d.ts +20 -0
- package/dist/actions/get.js +34 -0
- package/dist/actions/get.js.map +1 -0
- package/dist/actions/getPrefixes.d.ts +8 -0
- package/dist/actions/getPrefixes.js +12 -0
- package/dist/actions/getPrefixes.js.map +1 -0
- package/dist/actions/getRdfPrefixes.d.ts +6 -0
- package/dist/actions/getRdfPrefixes.js +13 -0
- package/dist/actions/getRdfPrefixes.js.map +1 -0
- package/dist/actions/list.d.ts +6 -0
- package/dist/actions/list.js +9 -0
- package/dist/actions/list.js.map +1 -0
- package/dist/actions/prefixToUri.d.ts +9 -0
- package/dist/actions/prefixToUri.js +27 -0
- package/dist/actions/prefixToUri.js.map +1 -0
- package/dist/actions/register.d.ts +28 -0
- package/dist/actions/register.js +59 -0
- package/dist/actions/register.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/ontologies/core/acl.json +28 -0
- package/dist/ontologies/core/as.json +6 -0
- package/dist/ontologies/core/cred.json +22 -0
- package/dist/ontologies/core/dc.json +19 -0
- package/dist/ontologies/core/did.json +19 -0
- package/dist/ontologies/core/foaf.json +4 -0
- package/dist/ontologies/core/index.d.ts +16 -0
- package/dist/ontologies/core/index.js +17 -0
- package/dist/ontologies/core/index.js.map +1 -0
- package/dist/ontologies/core/ldp.json +4 -0
- package/dist/ontologies/core/rdf.json +4 -0
- package/dist/ontologies/core/rdfs.json +7 -0
- package/dist/ontologies/core/sec.json +88 -0
- package/dist/ontologies/core/semapps.json +12 -0
- package/dist/ontologies/core/skos.json +4 -0
- package/dist/ontologies/core/vcard.json +15 -0
- package/dist/ontologies/core/void.json +23 -0
- package/dist/ontologies/core/xsd.json +4 -0
- package/dist/ontologies/custom/index.d.ts +10 -0
- package/dist/ontologies/custom/index.js +11 -0
- package/dist/ontologies/custom/index.js.map +1 -0
- package/dist/ontologies/custom/mp.json +4 -0
- package/dist/ontologies/custom/oasis.json +4 -0
- package/dist/ontologies/custom/og.json +13 -0
- package/dist/ontologies/custom/pair.json +329 -0
- package/dist/ontologies/custom/petr.json +4 -0
- package/dist/ontologies/custom/schema.json +4 -0
- package/dist/ontologies/custom/skos.json +13 -0
- package/dist/ontologies/custom/syreen.json +43 -0
- package/dist/ontologies/custom/tutor.json +26 -0
- package/dist/ontologies/solid/apods.json +82 -0
- package/dist/ontologies/solid/index.d.ts +7 -0
- package/dist/ontologies/solid/index.js +8 -0
- package/dist/ontologies/solid/index.js.map +1 -0
- package/dist/ontologies/solid/interop.json +124 -0
- package/dist/ontologies/solid/notify.json +62 -0
- package/dist/ontologies/solid/oidc.json +22 -0
- package/dist/ontologies/solid/pim.json +15 -0
- package/dist/ontologies/solid/solid.json +27 -0
- package/dist/service.d.ts +108 -0
- package/dist/service.js +56 -0
- package/dist/service.js.map +1 -0
- package/dist/sub-services/registry.d.ts +32 -0
- package/dist/sub-services/registry.js +52 -0
- package/dist/sub-services/registry.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +15 -0
- package/dist/utils.js.map +1 -0
- package/index.ts +9 -0
- package/ontologies/core/index.ts +34 -0
- package/ontologies/custom/index.ts +11 -0
- package/ontologies/solid/apods.json +3 -0
- package/ontologies/solid/index.ts +8 -0
- package/package.json +16 -5
- package/{service.js → service.ts} +25 -13
- package/sub-services/registry.ts +66 -0
- package/tsconfig.json +10 -0
- package/{utils.js → utils.ts} +3 -7
- package/actions/getPrefixes.js +0 -12
- package/actions/getRdfPrefixes.js +0 -11
- package/actions/list.js +0 -7
- package/index.js +0 -16
- package/ontologies/core/index.js +0 -17
- package/ontologies/custom/index.js +0 -11
- package/ontologies/solid/index.js +0 -8
- package/sub-services/registry.js +0 -44
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import DbService from 'moleculer-db';
|
|
2
|
+
import { TripleStoreAdapter } from '@semapps/triplestore';
|
|
3
|
+
const OntologiesRegistrySchema = {
|
|
4
|
+
name: 'ontologies.registry',
|
|
5
|
+
mixins: [DbService],
|
|
6
|
+
adapter: new TripleStoreAdapter({ type: 'Ontology', dataset: 'settings' }),
|
|
7
|
+
settings: {
|
|
8
|
+
idField: '@id'
|
|
9
|
+
},
|
|
10
|
+
actions: {
|
|
11
|
+
getByPrefix: {
|
|
12
|
+
async handler(ctx) {
|
|
13
|
+
const { prefix } = ctx.params;
|
|
14
|
+
const [ontology] = await this._find(ctx, { query: { prefix } });
|
|
15
|
+
return ontology && { prefix: ontology.prefix, namespace: ontology.namespace };
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
getByNamespace: {
|
|
19
|
+
async handler(ctx) {
|
|
20
|
+
const { namespace } = ctx.params;
|
|
21
|
+
const [ontology] = await this._find(ctx, { query: { namespace } });
|
|
22
|
+
return ontology && { prefix: ontology.prefix, namespace: ontology.namespace };
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
list: {
|
|
26
|
+
async handler(ctx) {
|
|
27
|
+
const ontologies = await this._list(ctx, {});
|
|
28
|
+
return ontologies.rows.map(({ prefix, namespace }) => ({ prefix, namespace }));
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
updateOrCreate: {
|
|
32
|
+
async handler(ctx) {
|
|
33
|
+
const { prefix, namespace } = ctx.params;
|
|
34
|
+
const ontology = await this.actions.getByPrefix({ prefix }, { parentCtx: ctx });
|
|
35
|
+
if (ontology) {
|
|
36
|
+
await this._update(ctx, {
|
|
37
|
+
'@id': ontology['@id'],
|
|
38
|
+
namespace
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
await this._create(ctx, {
|
|
43
|
+
prefix,
|
|
44
|
+
namespace
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export default OntologiesRegistrySchema;
|
|
52
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../sub-services/registry.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,MAAM,wBAAwB,GAAG;IAC/B,IAAI,EAAE,qBAA8B;IACpC,MAAM,EAAE,CAAC,SAAS,CAAC;IACnB,OAAO,EAAE,IAAI,kBAAkB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IAC1E,QAAQ,EAAE;QACR,OAAO,EAAE,KAAK;KACf;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,KAAK,CAAC,OAAO,CAAC,GAAG;gBACf,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;gBAC9B,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;gBAChE,OAAO,QAAQ,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;YAChF,CAAC;SACF;QAED,cAAc,EAAE;YACd,KAAK,CAAC,OAAO,CAAC,GAAG;gBACf,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;gBACjC,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;gBACnE,OAAO,QAAQ,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;YAChF,CAAC;SACF;QAED,IAAI,EAAE;YACJ,KAAK,CAAC,OAAO,CAAC,GAAG;gBACf,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAO,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YACtF,CAAC;SACF;QAED,cAAc,EAAE;YACd,KAAK,CAAC,OAAO,CAAC,GAAG;gBACf,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;gBAEzC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;gBAEhF,IAAI,QAAQ,EAAE,CAAC;oBACb,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;wBACtB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC;wBACtB,SAAS;qBACV,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;wBACtB,MAAM;wBACN,SAAS;qBACV,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF;KACF;CACsB,CAAC;AAE1B,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../index.ts","../service.ts","../utils.ts"],"errors":true,"version":"5.9.2"}
|
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const arrayOf = (value) => {
|
|
2
|
+
// If the field is null-ish, we suppose there are no values.
|
|
3
|
+
if (value === null || value === undefined) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
// Return as is.
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
// Single value is made an array.
|
|
11
|
+
return [value];
|
|
12
|
+
};
|
|
13
|
+
const isURL = (value) => (typeof value === 'string' || value instanceof String) && value.startsWith('http');
|
|
14
|
+
export { arrayOf, isURL };
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../utils.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;IAC7B,4DAA4D;IAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,gBAAgB;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,iCAAiC;IACjC,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import OntologiesService from './service.ts';
|
|
2
|
+
import OntologiesRegistryService from './sub-services/registry.ts';
|
|
3
|
+
|
|
4
|
+
export { OntologiesService, OntologiesRegistryService };
|
|
5
|
+
|
|
6
|
+
export * from './ontologies/core/index.ts';
|
|
7
|
+
export * from './ontologies/solid/index.ts';
|
|
8
|
+
export * from './ontologies/custom/index.ts';
|
|
9
|
+
export { skos } from './ontologies/core/index.ts';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import acl from './acl.json' with { type: 'json' };
|
|
2
|
+
import as from './as.json' with { type: 'json' };
|
|
3
|
+
import cred from './cred.json' with { type: 'json' };
|
|
4
|
+
import dc from './dc.json' with { type: 'json' };
|
|
5
|
+
import did from './did.json' with { type: 'json' };
|
|
6
|
+
import foaf from './foaf.json' with { type: 'json' };
|
|
7
|
+
import ldp from './ldp.json' with { type: 'json' };
|
|
8
|
+
import rdf from './rdf.json' with { type: 'json' };
|
|
9
|
+
import rdfs from './rdfs.json' with { type: 'json' };
|
|
10
|
+
import sec from './sec.json' with { type: 'json' };
|
|
11
|
+
import semapps from './semapps.json' with { type: 'json' };
|
|
12
|
+
import skos from './skos.json' with { type: 'json' };
|
|
13
|
+
import vcard from './vcard.json' with { type: 'json' };
|
|
14
|
+
import voidOntology from './void.json' with { type: 'json' };
|
|
15
|
+
import xsd from './xsd.json' with { type: 'json' };
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
acl,
|
|
19
|
+
as,
|
|
20
|
+
cred,
|
|
21
|
+
dc,
|
|
22
|
+
did,
|
|
23
|
+
foaf,
|
|
24
|
+
ldp,
|
|
25
|
+
rdf,
|
|
26
|
+
rdfs,
|
|
27
|
+
sec,
|
|
28
|
+
semapps,
|
|
29
|
+
skos,
|
|
30
|
+
vcard,
|
|
31
|
+
voidOntology as void,
|
|
32
|
+
xsd,
|
|
33
|
+
voidOntology
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import mp from './mp.json' with { type: 'json' };
|
|
2
|
+
import oasis from './oasis.json' with { type: 'json' };
|
|
3
|
+
import og from './og.json' with { type: 'json' };
|
|
4
|
+
import pair from './pair.json' with { type: 'json' };
|
|
5
|
+
import petr from './petr.json' with { type: 'json' };
|
|
6
|
+
import schema from './schema.json' with { type: 'json' };
|
|
7
|
+
import skos from './skos.json' with { type: 'json' };
|
|
8
|
+
import syreen from './syreen.json' with { type: 'json' };
|
|
9
|
+
import tutor from './tutor.json' with { type: 'json' };
|
|
10
|
+
|
|
11
|
+
export { mp, oasis, og, pair, petr, schema, skos, syreen, tutor };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import apods from './apods.json' with { type: 'json' };
|
|
2
|
+
import interop from './interop.json' with { type: 'json' };
|
|
3
|
+
import notify from './notify.json' with { type: 'json' };
|
|
4
|
+
import oidc from './oidc.json' with { type: 'json' };
|
|
5
|
+
import pim from './pim.json' with { type: 'json' };
|
|
6
|
+
import solid from './solid.json' with { type: 'json' };
|
|
7
|
+
|
|
8
|
+
export { apods, interop, notify, oidc, pim, solid };
|
package/package.json
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semapps/ontologies",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "SemApps ontologies",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Virtual Assembly",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@semapps/triplestore": "1.1
|
|
8
|
+
"@semapps/triplestore": "1.2.1",
|
|
9
9
|
"moleculer-db": "^0.8.16",
|
|
10
10
|
"node-fetch": "^2.6.6"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
|
-
"access": "public"
|
|
13
|
+
"access": "public",
|
|
14
|
+
"main": "./dist/index.js"
|
|
14
15
|
},
|
|
15
16
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
17
|
+
"node": ">=22.10.0"
|
|
17
18
|
},
|
|
18
|
-
"
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"moleculer": "^0.14.35"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"prepack": "node ../../scripts/switch-main-to-publish.js .",
|
|
26
|
+
"postpack": "node ../../scripts/revert-main-from-publish.js ."
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "4bbaa429345b47a365411baed1d163581ae03d9e",
|
|
29
|
+
"xDevMain": "./index.ts"
|
|
19
30
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { TripleStoreAdapter } from '@semapps/triplestore';
|
|
2
|
+
import type { ServiceSchema } from 'moleculer';
|
|
3
|
+
import OntologiesRegistryService from './sub-services/registry.ts';
|
|
4
|
+
import findPrefixAction from './actions/findPrefix.ts';
|
|
5
|
+
import findNamespaceAction from './actions/findNamespace.ts';
|
|
6
|
+
import getAction from './actions/get.ts';
|
|
7
|
+
import getPrefixesAction from './actions/getPrefixes.ts';
|
|
8
|
+
import getRdfPrefixesAction from './actions/getRdfPrefixes.ts';
|
|
9
|
+
import listAction from './actions/list.ts';
|
|
10
|
+
import prefixToUriAction from './actions/prefixToUri.ts';
|
|
11
|
+
import registerAction from './actions/register.ts';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
name: 'ontologies',
|
|
13
|
+
const OntologiesSchema = {
|
|
14
|
+
name: 'ontologies' as const,
|
|
14
15
|
settings: {
|
|
15
16
|
ontologies: [],
|
|
16
17
|
persistRegistry: false,
|
|
@@ -19,6 +20,7 @@ module.exports = {
|
|
|
19
20
|
async created() {
|
|
20
21
|
const { persistRegistry, settingsDataset } = this.settings;
|
|
21
22
|
if (persistRegistry) {
|
|
23
|
+
// @ts-expect-error TS(2345): Argument of type '{ mixins: { name: "ontologies.re... Remove this comment to see the full error message
|
|
22
24
|
this.broker.createService({
|
|
23
25
|
mixins: [OntologiesRegistryService],
|
|
24
26
|
adapter: new TripleStoreAdapter({ type: 'Ontology', dataset: settingsDataset })
|
|
@@ -51,4 +53,14 @@ module.exports = {
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
|
-
};
|
|
56
|
+
} satisfies ServiceSchema;
|
|
57
|
+
|
|
58
|
+
export default OntologiesSchema;
|
|
59
|
+
|
|
60
|
+
declare global {
|
|
61
|
+
export namespace Moleculer {
|
|
62
|
+
export interface AllServices {
|
|
63
|
+
[OntologiesSchema.name]: typeof OntologiesSchema;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import DbService from 'moleculer-db';
|
|
2
|
+
import { TripleStoreAdapter } from '@semapps/triplestore';
|
|
3
|
+
import type { ServiceSchema } from 'moleculer';
|
|
4
|
+
|
|
5
|
+
const OntologiesRegistrySchema = {
|
|
6
|
+
name: 'ontologies.registry' as const,
|
|
7
|
+
mixins: [DbService],
|
|
8
|
+
adapter: new TripleStoreAdapter({ type: 'Ontology', dataset: 'settings' }),
|
|
9
|
+
settings: {
|
|
10
|
+
idField: '@id'
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
getByPrefix: {
|
|
14
|
+
async handler(ctx) {
|
|
15
|
+
const { prefix } = ctx.params;
|
|
16
|
+
const [ontology] = await this._find(ctx, { query: { prefix } });
|
|
17
|
+
return ontology && { prefix: ontology.prefix, namespace: ontology.namespace };
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
getByNamespace: {
|
|
22
|
+
async handler(ctx) {
|
|
23
|
+
const { namespace } = ctx.params;
|
|
24
|
+
const [ontology] = await this._find(ctx, { query: { namespace } });
|
|
25
|
+
return ontology && { prefix: ontology.prefix, namespace: ontology.namespace };
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
list: {
|
|
30
|
+
async handler(ctx) {
|
|
31
|
+
const ontologies = await this._list(ctx, {});
|
|
32
|
+
return ontologies.rows.map(({ prefix, namespace }: any) => ({ prefix, namespace }));
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
updateOrCreate: {
|
|
37
|
+
async handler(ctx) {
|
|
38
|
+
const { prefix, namespace } = ctx.params;
|
|
39
|
+
|
|
40
|
+
const ontology = await this.actions.getByPrefix({ prefix }, { parentCtx: ctx });
|
|
41
|
+
|
|
42
|
+
if (ontology) {
|
|
43
|
+
await this._update(ctx, {
|
|
44
|
+
'@id': ontology['@id'],
|
|
45
|
+
namespace
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
await this._create(ctx, {
|
|
49
|
+
prefix,
|
|
50
|
+
namespace
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} satisfies ServiceSchema;
|
|
57
|
+
|
|
58
|
+
export default OntologiesRegistrySchema;
|
|
59
|
+
|
|
60
|
+
declare global {
|
|
61
|
+
export namespace Moleculer {
|
|
62
|
+
export interface AllServices {
|
|
63
|
+
[OntologiesRegistrySchema.name]: typeof OntologiesRegistrySchema;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
package/tsconfig.json
ADDED
package/{utils.js → utils.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const arrayOf = value => {
|
|
1
|
+
const arrayOf = (value: any) => {
|
|
2
2
|
// If the field is null-ish, we suppose there are no values.
|
|
3
3
|
if (value === null || value === undefined) {
|
|
4
4
|
return [];
|
|
@@ -11,9 +11,5 @@ const arrayOf = value => {
|
|
|
11
11
|
return [value];
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const isURL = value => (typeof value === 'string' || value instanceof String) && value.startsWith('http');
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
arrayOf,
|
|
18
|
-
isURL
|
|
19
|
-
};
|
|
14
|
+
const isURL = (value: any) => (typeof value === 'string' || value instanceof String) && value.startsWith('http');
|
|
15
|
+
export { arrayOf, isURL };
|
package/actions/getPrefixes.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
visibility: 'public',
|
|
3
|
-
cache: true,
|
|
4
|
-
async handler(ctx) {
|
|
5
|
-
const ontologies = await this.actions.list({}, { parentCtx: ctx });
|
|
6
|
-
return Object.fromEntries(
|
|
7
|
-
ontologies
|
|
8
|
-
.sort((a, b) => (a.prefix < b.prefix ? -1 : a.prefix > b.prefix ? 1 : 0))
|
|
9
|
-
.map(ontology => [ontology.prefix, ontology.namespace])
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
visibility: 'public',
|
|
3
|
-
cache: true,
|
|
4
|
-
async handler(ctx) {
|
|
5
|
-
const ontologies = await this.actions.list({}, { parentCtx: ctx });
|
|
6
|
-
return ontologies
|
|
7
|
-
.sort((a, b) => (a.prefix < b.prefix ? -1 : a.prefix > b.prefix ? 1 : 0))
|
|
8
|
-
.map(ontology => `PREFIX ${ontology.prefix}: <${ontology.namespace}>`)
|
|
9
|
-
.join('\n');
|
|
10
|
-
}
|
|
11
|
-
};
|
package/actions/list.js
DELETED
package/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const OntologiesService = require('./service');
|
|
2
|
-
const OntologiesRegistryService = require('./sub-services/registry');
|
|
3
|
-
const coreOntologies = require('./ontologies/core');
|
|
4
|
-
const customOntologies = require('./ontologies/custom');
|
|
5
|
-
const solidOntologies = require('./ontologies/solid');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
OntologiesService,
|
|
9
|
-
OntologiesRegistryService,
|
|
10
|
-
coreOntologies: Object.values(coreOntologies),
|
|
11
|
-
solidOntologies: Object.values(solidOntologies),
|
|
12
|
-
customOntologies: Object.values(customOntologies),
|
|
13
|
-
...coreOntologies,
|
|
14
|
-
...solidOntologies,
|
|
15
|
-
...customOntologies
|
|
16
|
-
};
|
package/ontologies/core/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
acl: require('./acl.json'),
|
|
3
|
-
as: require('./as.json'),
|
|
4
|
-
cred: require('./cred.json'),
|
|
5
|
-
dc: require('./dc.json'),
|
|
6
|
-
did: require('./did.json'),
|
|
7
|
-
foaf: require('./foaf.json'),
|
|
8
|
-
ldp: require('./ldp.json'),
|
|
9
|
-
rdf: require('./rdf.json'),
|
|
10
|
-
rdfs: require('./rdfs.json'),
|
|
11
|
-
sec: require('./sec.json'),
|
|
12
|
-
semapps: require('./semapps.json'),
|
|
13
|
-
skos: require('./skos.json'),
|
|
14
|
-
vcard: require('./vcard.json'),
|
|
15
|
-
void: require('./void.json'),
|
|
16
|
-
xsd: require('./xsd.json')
|
|
17
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
mp: require('./mp.json'),
|
|
3
|
-
oasis: require('./oasis.json'),
|
|
4
|
-
og: require('./og.json'),
|
|
5
|
-
pair: require('./pair.json'),
|
|
6
|
-
petr: require('./petr.json'),
|
|
7
|
-
schema: require('./schema.json'),
|
|
8
|
-
skos: require('./skos.json'),
|
|
9
|
-
syreen: require('./syreen.json'),
|
|
10
|
-
tutor: require('./tutor.json')
|
|
11
|
-
};
|
package/sub-services/registry.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const DbService = require('moleculer-db');
|
|
2
|
-
const { TripleStoreAdapter } = require('@semapps/triplestore');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
name: 'ontologies.registry',
|
|
6
|
-
mixins: [DbService],
|
|
7
|
-
adapter: new TripleStoreAdapter({ type: 'Ontology', dataset: 'settings' }),
|
|
8
|
-
settings: {
|
|
9
|
-
idField: '@id'
|
|
10
|
-
},
|
|
11
|
-
actions: {
|
|
12
|
-
async getByPrefix(ctx) {
|
|
13
|
-
const { prefix } = ctx.params;
|
|
14
|
-
const [ontology] = await this._find(ctx, { query: { prefix } });
|
|
15
|
-
return ontology && { prefix: ontology.prefix, namespace: ontology.namespace };
|
|
16
|
-
},
|
|
17
|
-
async getByNamespace(ctx) {
|
|
18
|
-
const { namespace } = ctx.params;
|
|
19
|
-
const [ontology] = await this._find(ctx, { query: { namespace } });
|
|
20
|
-
return ontology && { prefix: ontology.prefix, namespace: ontology.namespace };
|
|
21
|
-
},
|
|
22
|
-
async list(ctx) {
|
|
23
|
-
const ontologies = await this._list(ctx, {});
|
|
24
|
-
return ontologies.rows.map(({ prefix, namespace }) => ({ prefix, namespace }));
|
|
25
|
-
},
|
|
26
|
-
async updateOrCreate(ctx) {
|
|
27
|
-
const { prefix, namespace } = ctx.params;
|
|
28
|
-
|
|
29
|
-
const ontology = await this.actions.getByPrefix({ prefix }, { parentCtx: ctx });
|
|
30
|
-
|
|
31
|
-
if (ontology) {
|
|
32
|
-
await this._update(ctx, {
|
|
33
|
-
'@id': ontology['@id'],
|
|
34
|
-
namespace
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
await this._create(ctx, {
|
|
38
|
-
prefix,
|
|
39
|
-
namespace
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|