lincd-cli 0.1.6 → 0.1.7
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/defaults/app/index.html +12 -0
- package/defaults/app/package.json +30 -0
- package/defaults/app/src/App.tsx +5 -0
- package/defaults/app/src/index.tsx +10 -0
- package/defaults/create_migration.ts +3 -3
- package/defaults/defaultModule/Index.scss +16 -16
- package/defaults/defaultModule/Index.tsx +26 -19
- package/defaults/defaultModule/data.json +54 -54
- package/defaults/defaultModule/defaultOntology.json +21 -21
- package/defaults/defaultModule/index.ts +12 -8
- package/defaults/defaultModule/ontology.ts +12 -9
- package/defaults/index.ts +13 -9
- package/defaults/module/src/components/ExampleComponent.tsx +10 -14
- package/defaults/module/src/data/example-ontology.json +18 -18
- package/defaults/module/src/module.ts +3 -8
- package/defaults/module/src/ontologies/example-ontology.ts +8 -10
- package/defaults/module/src/shapes/ExampleShapeClass.ts +20 -21
- package/defaults/ontology.ts +11 -8
- package/defaults/site/package.json +38 -38
- package/lib/cli.js +187 -109
- package/lib/config-grunt.js +34 -30
- package/lib/config-webpack.js +7 -6
- package/lib/index.js +5 -1
- package/lib/plugins/declaration-plugin.js +9 -9
- package/lib/plugins/externalise-modules.js +13 -13
- package/lib/plugins/watch-run.js +1 -1
- package/lib/utils.js +5 -1
- package/package.json +8 -6
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="stylesheet" type="text/css" href="./dist/${app_name}.css">
|
|
6
|
+
<title>${app_name}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script src="./dist/${app_name}.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "${app_name}",
|
|
3
|
+
"displayName": "${app_name}",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "",
|
|
6
|
+
"lincd": true,
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"types": "dist/${app_name}.d.ts",
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "npm exec lincd build",
|
|
13
|
+
"dev": "npm exec lincd dev",
|
|
14
|
+
"prepublishOnly": "npm exec lincd build production",
|
|
15
|
+
"postpublish": "npm exec lincd publish"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"lincd",
|
|
19
|
+
"linked data",
|
|
20
|
+
"interoperable",
|
|
21
|
+
"semantic web",
|
|
22
|
+
"web3"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"lincd": "^0.2"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"lincd-cli": "^0.1"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {createRoot} from 'react-dom/client';
|
|
3
|
+
import {App} from './App';
|
|
4
|
+
|
|
5
|
+
declare var document;
|
|
6
|
+
if (typeof document !== 'undefined') {
|
|
7
|
+
const container = document.getElementById('root');
|
|
8
|
+
const root = createRoot(container!);
|
|
9
|
+
root.render(<App></App>);
|
|
10
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
.Index {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
width: 80%;
|
|
3
|
+
max-width: 44rem;
|
|
4
|
+
padding: 7rem 4rem 3rem;
|
|
5
|
+
margin: 58px auto !important;
|
|
6
|
+
box-shadow: 0px 0px 36px #50625055;
|
|
7
|
+
border-radius: 10px;
|
|
8
|
+
font-family: monospace;
|
|
9
|
+
font-size: 15px;
|
|
10
|
+
background: url(https://www.dacore.org/img/logo@2x.png) top right no-repeat;
|
|
11
|
+
background-size: 240px;
|
|
12
|
+
background-position-y: 26px;
|
|
13
|
+
background-position-x: center;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
code {
|
|
16
|
+
padding: 2px 4px;
|
|
17
|
+
background-color: #eee;
|
|
18
|
+
}
|
|
19
19
|
}
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import {React,ReactComponent} from "@dacore/core/lib/shapes/ReactComponent";
|
|
2
|
-
import {UriResource} from "@dacore/core/lib/models";
|
|
3
|
-
import ${projectName} from "../ontologies/${projectName}";
|
|
1
|
+
import { React,ReactComponent } from "@dacore/core/lib/shapes/ReactComponent";
|
|
2
|
+
import { UriResource } from "@dacore/core/lib/models";
|
|
4
3
|
import "./Index.scss";
|
|
5
4
|
import style from "./Index.scss.json";
|
|
5
|
+
import ${projectName} from "../ontologies/${projectName}";
|
|
6
|
+
|
|
6
7
|
export default class Index extends ReactComponent<any,any>
|
|
7
8
|
{
|
|
8
|
-
|
|
9
|
+
static viewType: UriResource = ${projectName}
|
|
10
|
+
.
|
|
11
|
+
Index;
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
render()
|
|
14
|
+
{
|
|
15
|
+
return <div className={style.Index}>
|
|
16
|
+
<hr />
|
|
17
|
+
<p>Welcome to your new LINCD setup!</p>
|
|
18
|
+
<p>
|
|
19
|
+
To start coding:
|
|
20
|
+
<ul>
|
|
21
|
+
<li>Go to <code>/modules/${browserTitle}</code> and run <code>yarn lincd dev</code> to start developing your
|
|
22
|
+
module
|
|
23
|
+
</li>
|
|
24
|
+
<li>Open <code>modules/${browserTitle}/src/views/Index.tsx</code> to edit this page.</li>
|
|
25
|
+
<li>For pages rendered on the initial page request you currently have to restart the server and refresh the
|
|
26
|
+
page to see the results (for others you can simply refresh)
|
|
27
|
+
</li>
|
|
28
|
+
</ul>
|
|
29
|
+
</p>
|
|
30
|
+
</div>;
|
|
31
|
+
}
|
|
25
32
|
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
2
|
+
"@context": {
|
|
3
|
+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
4
|
+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
|
5
|
+
"module": "http://data.dacore.org/ontologies/module/",
|
|
6
|
+
"core": "http://data.dacore.org/ontologies/core/",
|
|
7
|
+
"oc": "http://data.dacore.org/ontologies/oc/",
|
|
8
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
9
|
+
"router": "http://data.dacore.org/ontologies/router/",
|
|
10
|
+
"node-core": "http://data.dacore.org/ontologies/node-core/",
|
|
11
|
+
"mysite": "http://data.mysite.com/ontology/mysite/",
|
|
12
|
+
"admin": "http://data.dacore.org/ontologies/admin/",
|
|
13
|
+
"html": "http://data.dacore.org/ontologies/html/"
|
|
14
|
+
},
|
|
15
|
+
"@graph": [
|
|
16
|
+
{
|
|
17
|
+
"@id": "${defaultModuleUri}",
|
|
18
|
+
"@type": "module:Module",
|
|
19
|
+
"module:maintainsOntology": {
|
|
20
|
+
"@id": "${defaultOntologyUri}"
|
|
21
|
+
},
|
|
22
|
+
"module:npmPath": "@dacore/${projectName}",
|
|
23
|
+
"rdfs:label": "${projectName}"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"@id": "${uriBase}/moduledatastore/${projectName}",
|
|
27
|
+
"@type": "node-core:ModuleDataStore",
|
|
28
|
+
"module:module": {
|
|
29
|
+
"@id": "${defaultModuleUri}"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"@id": "${uriBase}/route//",
|
|
34
|
+
"@type": "router:Route",
|
|
35
|
+
"core:viewType": {
|
|
36
|
+
"@id": "${defaultOntologyUri}Index"
|
|
37
|
+
},
|
|
38
|
+
"router:exact": {
|
|
39
|
+
"@type": "xsd:boolean",
|
|
40
|
+
"@value": "true"
|
|
41
|
+
},
|
|
42
|
+
"router:path": "/"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"@id": "${uriBase}/route//console",
|
|
46
|
+
"@type": "router:Route",
|
|
47
|
+
"core:viewType": {
|
|
48
|
+
"@id": "admin:AdminOverview"
|
|
49
|
+
},
|
|
50
|
+
"router:layout": {
|
|
51
|
+
"@id": "admin:AdminOverview"
|
|
52
|
+
},
|
|
53
|
+
"router:path": "/console"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
56
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
"@context": {
|
|
3
|
+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
4
|
+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
|
5
|
+
"core": "http://data.dacore.org/ontologies/core/",
|
|
6
|
+
"${projectName}": "${defaultOntologyUri}"
|
|
7
|
+
},
|
|
8
|
+
"@graph": [
|
|
9
|
+
{
|
|
10
|
+
"@id": "${defaultOntologyUri}",
|
|
11
|
+
"@type": "http://www.w3.org/2002/07/owl#Ontology",
|
|
12
|
+
"core:suggestedPrefix": "${projectName}"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"@id": "${projectName}:Index",
|
|
16
|
+
"@type": "core:ViewType",
|
|
17
|
+
"rdfs:isDefinedBy": {
|
|
18
|
+
"@id": "${defaultOntologyUri}"
|
|
19
|
+
},
|
|
20
|
+
"rdfs:label": "Index"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
23
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {Core} from "@dacore/core/lib/shapes/Core";
|
|
2
|
-
import {UriResource} from "@dacore/core/lib/models";
|
|
3
|
-
import {JSONLD} from "@dacore/core/lib/utils/JSONLD";
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
1
|
+
import { Core } from "@dacore/core/lib/shapes/Core";
|
|
2
|
+
import { UriResource } from "@dacore/core/lib/models";
|
|
3
|
+
import { JSONLD } from "@dacore/core/lib/utils/JSONLD";
|
|
4
|
+
import * as Index from "./views/Index";
|
|
5
|
+
import * as ${underscore_ontology_name} from
|
|
6
|
+
|
|
7
|
+
"./ontologies/${ontology_name}";
|
|
6
8
|
|
|
7
9
|
declare var require: any;
|
|
8
|
-
var _dataPromise = JSONLD.parse(require(
|
|
10
|
+
var _dataPromise = JSONLD.parse(require("../data/data.json"),true,true) as Promise<any>;
|
|
9
11
|
|
|
10
12
|
var moduleResource: UriResource = UriResource.getOrCreate("${uri_base}/module/${module_name}");
|
|
11
|
-
Core.app().registerModule("${module_name}",this,moduleResource,_dataPromise,[${underscore_ontology_name}._parsePromise
|
|
12
|
-
|
|
13
|
+
Core.app().registerModule("${module_name}",this,moduleResource,_dataPromise,[${underscore_ontology_name}._parsePromise
|
|
14
|
+
])
|
|
15
|
+
;
|
|
16
|
+
export {${underscore_ontology_name},Index };
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {UriResource} from "@dacore/core/lib/models";
|
|
1
|
+
import { UriResource } from "@dacore/core/lib/models";
|
|
2
|
+
import { JSONLD } from "@dacore/core/lib/utils/JSONLD";
|
|
2
3
|
|
|
3
|
-
declare var require:any;
|
|
4
|
-
import {JSONLD} from "@dacore/core/lib/utils/JSONLD";
|
|
5
|
-
var base:string = "${uri_base}/ontology/${ontology_name}/";
|
|
6
|
-
export var _ontologyResource:UriResource = UriResource.getOrCreate(base);
|
|
4
|
+
declare var require: any;
|
|
7
5
|
|
|
8
|
-
var
|
|
9
|
-
export var
|
|
6
|
+
var base: string = "${uri_base}/ontology/${ontology_name}/";
|
|
7
|
+
export var _ontologyResource: UriResource = UriResource.getOrCreate(base);
|
|
8
|
+
|
|
9
|
+
var json = require("../../data/ontologies/${ontology_name}.json");
|
|
10
|
+
export var _parsePromise: [UriResource,Promise<any>] = [_ontologyResource,JSONLD.parse(json,true,true) as Promise<any>];
|
|
10
11
|
|
|
11
12
|
//add your ontology resources here
|
|
12
|
-
export var Index:UriResource = UriResource.getOrCreate(base+"Index");
|
|
13
|
+
export var Index: UriResource = UriResource.getOrCreate(base + "Index");
|
|
13
14
|
|
|
14
15
|
//make sure every node is also exported here
|
|
15
|
-
var ${camel_ontology_name}
|
|
16
|
+
var ${camel_ontology_name} =;
|
|
17
|
+
{Index;}
|
|
18
|
+
;
|
|
16
19
|
export default ${camel_ontology_name};
|
package/defaults/index.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {Core} from "@dacore/core/lib/shapes/Core";
|
|
2
|
-
import {UriResource} from "@dacore/core/lib/models";
|
|
3
|
-
import {JSONLD} from "@dacore/core/lib/utils/JSONLD";
|
|
4
|
-
import * as ${underscore_ontology_name} from
|
|
1
|
+
import { Core } from "@dacore/core/lib/shapes/Core";
|
|
2
|
+
import { UriResource } from "@dacore/core/lib/models";
|
|
3
|
+
import { JSONLD } from "@dacore/core/lib/utils/JSONLD";
|
|
4
|
+
import * as ${underscore_ontology_name} from
|
|
5
|
+
|
|
6
|
+
"./ontologies/${ontology_name}";
|
|
5
7
|
//import * as viewName from "./views/viewName"
|
|
6
8
|
//import * as typeName from "./shapes/typeName"
|
|
7
9
|
|
|
8
|
-
declare var require:any;
|
|
9
|
-
var _dataPromise = JSONLD.parse(require(
|
|
10
|
+
declare var require: any;
|
|
11
|
+
var _dataPromise = JSONLD.parse(require("../data/data.json"),true,true) as Promise<any>;
|
|
10
12
|
|
|
11
|
-
var moduleResource:UriResource = UriResource.getOrCreate("${uri_base}/module/${module_name}");
|
|
12
|
-
Core.app().registerModule("${module_name}",this,moduleResource,_dataPromise,[${underscore_ontology_name}._parsePromise
|
|
13
|
-
|
|
13
|
+
var moduleResource: UriResource = UriResource.getOrCreate("${uri_base}/module/${module_name}");
|
|
14
|
+
Core.app().registerModule("${module_name}",this,moduleResource,_dataPromise,[${underscore_ontology_name}._parsePromise
|
|
15
|
+
])
|
|
16
|
+
;
|
|
17
|
+
export {${underscore_ontology_name} };
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {ReactComponent} from
|
|
3
|
-
import {ExampleShapeClass} from
|
|
4
|
-
import {linkedComponent} from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReactComponent } from "lincd/lib/shapes/ReactComponent";
|
|
3
|
+
import { ExampleShapeClass } from "../shapes/ExampleShapeClass";
|
|
4
|
+
import { linkedComponent } from "../module";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* By linking this component to a Shape class (a class that extends Shape) you ensure this.source will be an instance of that class
|
|
8
8
|
*/
|
|
9
9
|
@linkedComponent(ExampleShapeClass)
|
|
10
10
|
//for correct typings, please provide the same class as third type parameter of ReactComponent, after property & state interfaces
|
|
11
|
-
export class ExampleComponent extends ReactComponent<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ExampleShapeClass
|
|
15
|
-
> {
|
|
16
|
-
render() {
|
|
17
|
-
let exampleInstance = this.source;
|
|
11
|
+
export class ExampleComponent extends ReactComponent<any, any, ExampleShapeClass> {
|
|
12
|
+
render() {
|
|
13
|
+
let exampleInstance = this.sourceShape;
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
//get the name of this item from the graph
|
|
16
|
+
return <h1>Hello {exampleInstance.name}!</h1>;
|
|
17
|
+
}
|
|
22
18
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
"@context": {
|
|
3
|
+
"dc": "http://purl.org/dc/elements/1.1/",
|
|
4
|
+
"owl": "http://www.w3.org/2002/07/owl#",
|
|
5
|
+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
6
|
+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
|
7
|
+
"test": "http://www.example.com/"
|
|
8
|
+
},
|
|
9
|
+
"@graph": [
|
|
10
|
+
{
|
|
11
|
+
"@id": "example:ExampleClass",
|
|
12
|
+
"@type": "rdfs:Class",
|
|
13
|
+
"rdfs:comment": "This is an example class. You can remove or rename it",
|
|
14
|
+
"rdfs:isDefinedBy": {
|
|
15
|
+
"@id": "example:"
|
|
16
|
+
},
|
|
17
|
+
"rdfs:label": "Example Class"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
20
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import {linkedModule} from 'lincd/lib/utils/Module';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
linkedUtil,
|
|
6
|
-
linkedOntology,
|
|
7
|
-
registerModuleExport,
|
|
8
|
-
moduleExports,
|
|
9
|
-
} = linkedModule('${module_name}');
|
|
2
|
+
|
|
3
|
+
export const {linkedComponent, linkedShape, linkedUtil, linkedOntology, registerModuleExport, moduleExports} =
|
|
4
|
+
linkedModule('${module_name}');
|
|
@@ -2,11 +2,13 @@ import {NamedNode} from 'lincd/lib/models';
|
|
|
2
2
|
import {JSONLD} from 'lincd-jsonld/lib/JSONLD';
|
|
3
3
|
import {createNameSpace} from 'lincd/lib/utils/NameSpace';
|
|
4
4
|
import {linkedOntology} from '../module';
|
|
5
|
+
//finally, we pass on all the exports, plus the namespace, prefix and data loading function
|
|
6
|
+
// as we register this ontology in the LINCD tree
|
|
7
|
+
import * as _this from './example-ontology';
|
|
5
8
|
|
|
9
|
+
let dataFile = '../data/example-ontology.json';
|
|
6
10
|
export var loadData = () => {
|
|
7
|
-
|
|
8
|
-
JSONLD.parse(data),
|
|
9
|
-
);
|
|
11
|
+
return import(dataFile).then((data) => JSONLD.parse(data));
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export var ns = createNameSpace('${uri_base}');
|
|
@@ -20,14 +22,10 @@ export var ExampleClass: NamedNode = ns('ExampleClass');
|
|
|
20
22
|
export var exampleName: NamedNode = ns('exampleName');
|
|
21
23
|
|
|
22
24
|
export const exampleOntology = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
ExampleClass,
|
|
26
|
+
exampleName,
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
//finally, we pass on all the exports, plus the namespace, prefix and data loading function
|
|
28
|
-
// as we register this ontology in the LINCD tree
|
|
29
|
-
import * as _this from './example-ontology';
|
|
30
|
-
|
|
31
29
|
//as third parameter, provide a prefix (string) that can be used to refer to the full ontology URL.
|
|
32
30
|
//for example: 'schema' refers to https://www.schema.org/
|
|
33
|
-
linkedOntology(_this, ns, 'exampl', loadData);
|
|
31
|
+
linkedOntology(_this, ns, 'exampl', loadData, dataFile);
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import {Shape} from 'lincd/lib/shapes/Shape';
|
|
2
|
-
import {NamedNode} from 'lincd/lib/models';
|
|
2
|
+
import {Literal, NamedNode} from 'lincd/lib/models';
|
|
3
3
|
import {linkedShape} from '../module';
|
|
4
4
|
import {literalProperty} from 'lincd/lib/utils/ShapeDecorators';
|
|
5
|
-
import {Literal} from 'lincd/lib/models';
|
|
6
|
-
import {schema} from 'lincd-schema/lib/ontologies/schema';
|
|
7
5
|
import {exampleOntology} from '../ontologies/example-ontology';
|
|
8
6
|
|
|
9
7
|
@linkedShape
|
|
10
8
|
export class ExampleShapeClass extends Shape {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
/**
|
|
10
|
+
* indicates that instances of this shape need to have this rdf.type
|
|
11
|
+
*/
|
|
12
|
+
static targetClass: NamedNode = exampleOntology.ExampleClass;
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
/**
|
|
15
|
+
* instances of this shape need to have exactly one value defined for the given property
|
|
16
|
+
*/
|
|
17
|
+
@literalProperty({
|
|
18
|
+
path: exampleOntology.exampleName,
|
|
19
|
+
required: true,
|
|
20
|
+
maxCount: 1,
|
|
21
|
+
})
|
|
22
|
+
get name() {
|
|
23
|
+
return this.getValue(exampleOntology.exampleName);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set name(val: string) {
|
|
27
|
+
this.overwrite(exampleOntology.exampleName, new Literal(val));
|
|
28
|
+
}
|
|
30
29
|
}
|
package/defaults/ontology.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {UriResource} from "@dacore/core/lib/models";
|
|
1
|
+
import { UriResource } from "@dacore/core/lib/models";
|
|
2
|
+
import { JSONLD } from "@dacore/core/lib/utils/JSONLD";
|
|
2
3
|
|
|
3
|
-
declare var require:any;
|
|
4
|
-
import {JSONLD} from "@dacore/core/lib/utils/JSONLD";
|
|
5
|
-
var base:string = "${uri_base}/ontology/${ontology_name}/";
|
|
6
|
-
export var _ontologyResource:UriResource = UriResource.getOrCreate(base);
|
|
4
|
+
declare var require: any;
|
|
7
5
|
|
|
8
|
-
var
|
|
9
|
-
export var
|
|
6
|
+
var base: string = "${uri_base}/ontology/${ontology_name}/";
|
|
7
|
+
export var _ontologyResource: UriResource = UriResource.getOrCreate(base);
|
|
8
|
+
|
|
9
|
+
var json = require("../../data/ontologies/${ontology_name}.json");
|
|
10
|
+
export var _parsePromise: [UriResource,Promise<any>] = [_ontologyResource,JSONLD.parse(json,true,true) as Promise<any>];
|
|
10
11
|
|
|
11
12
|
//add your ontology resources here
|
|
12
13
|
// export var node:UriResource = UriResource.getOrCreate(base+"node");
|
|
13
14
|
|
|
14
15
|
//make sure every node is also exported here
|
|
15
|
-
var ${camel_ontology_name}
|
|
16
|
+
var ${camel_ontology_name} =;
|
|
17
|
+
{}
|
|
18
|
+
;
|
|
16
19
|
export default ${camel_ontology_name};
|