Skip to content

Commit

Permalink
[add] DASH vocabulary
Browse files Browse the repository at this point in the history
  • Loading branch information
amivanoff committed Sep 30, 2024
1 parent b36cea0 commit 694112e
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 163 deletions.
10 changes: 9 additions & 1 deletion src/ObjectProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ export interface JSONSchema7LDProperty extends JSONSchema7 {
*/
'@id'?: string | undefined;
'@type'?: string | undefined;
order?: number | undefined; // SHACL Shapes

// SHACL Shapes properties
order?: number | undefined;

// DASH properties
propertyRole?: string | undefined;
editor?: string | undefined;
viewer?: string | undefined;
singleLine?: boolean;

// permissions extension
valueModifiability?: string | undefined; // user or non -- system
Expand Down
14 changes: 8 additions & 6 deletions src/ObjectProviderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ function propertyShapeToJsonSchemaProperty(
const shapePropKey = propertyNameShapeToSchema(shapePropUri);
schemaProps[shapePropKey] = {};
let schemaProp: JSONSchema7LDPropertyDefinition = schemaProps[shapePropKey];
//labels
//label conversion
if (shapeProp.name) schemaProp.title = shapeProp.name;
if (shapeProp.description) schemaProp.description = shapeProp.description;
if (shapeProp.order) schemaProp.order = shapeProp.order;
//modifiability
if (shapeProp.shapeModifiability) schemaProp.shapeModifiability = shapeProp.shapeModifiability;
//if (shapeProp.valueModifiability) schemaProp.valueModifiability = shapeProp.valueModifiability;
Object.keys(shapeProp)
.filter(
(k) => !['@id', '@type', 'name', 'path', 'datatype', 'class', 'nodeKind', 'minCount', 'maxCount'].includes(k),
)
.forEach((fk: any) => ((schemaProp as JsObject)[fk] = shapeProp[fk]));
//cardinality
if (shapeProp.maxCount === undefined || shapeProp.maxCount > 1) {
schemaProp.type = 'array';
Expand All @@ -97,6 +97,8 @@ function propertyShapeToJsonSchemaProperty(
schemaReqs.push(shapePropKey);
}
}
//element default value
if (shapeProp.defaultValue) schemaProp.default = shapeProp.defaultValue;
//element type
if (shapeProp.datatype) {
if (shapeProp.datatype === 'xsd:dateTime') {
Expand Down
6 changes: 6 additions & 0 deletions src/models/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ export const rootModelInitialState: TMstRepositorySnapshotIn = {
rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
xsd: 'http://www.w3.org/2001/XMLSchema#',
owl: 'http://www.w3.org/2002/07/owl#',
// shapes
sh: 'http://www.w3.org/ns/shacl#',
dash: 'http://datashapes.org/dash#',
// rdf4j-specific
sesame: 'http://www.openrdf.org/schema/sesame#', //rdf4j DirectType Inferencer sesame:directSubClassOf
rdf4j: 'http://rdf4j.org/schema/rdf4j#', //rdf4j Default Graph rdf4j:nil, rdf4j:SHACLShapeGraph
// library constant IRIs
aldkg: 'https://agentlab.eu/ns/ldkg#',
},
},
Expand Down
46 changes: 46 additions & 0 deletions src/schema/ArtifactShapeSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ export const ArtifactShapeSchema: JSONSchema7LD = {
},
title: {
type: 'string',
propertyRole: 'dash:LabelRole',
singleLine: true,
},
description: {
type: 'string',
propertyRole: 'dash:DescriptionRole',
},
property: {
type: 'array',
Expand All @@ -82,6 +85,7 @@ export const ArtifactShapeSchema: JSONSchema7LD = {
},
iconReference: {
type: 'object',
propertyRole: 'dash:IconRole',
},
},
required: ['@id', 'targetClass' /*, 'property'*/], // arrays should be required
Expand Down Expand Up @@ -132,6 +136,24 @@ export const PropertyShapeSchema: JSONSchema7LD = {
'@id': 'sh:maxCount',
'@type': 'xsd:integer',
},
// DASH properties
propertyRole: {
'@id': 'dash:propertyRole',
'@type': '@id',
},
editor: {
'@id': 'dash:editor',
'@type': '@id',
},
viewer: {
'@id': 'dash:viewer',
'@type': '@id',
},
singleLine: {
'@id': 'dash:singleLine',
'@type': 'xsd:boolean',
},
//permissions extension
shapeModifiability: 'rm:shapeModifiability',
valueModifiability: 'rm:valueModifiability',
},
Expand All @@ -148,10 +170,13 @@ export const PropertyShapeSchema: JSONSchema7LD = {
name: {
title: 'Name',
type: 'string',
propertyRole: 'dash:LabelRole',
singleLine: true,
},
description: {
title: 'Description',
type: 'string',
propertyRole: 'dash:DescriptionRole',
},
path: {
title: 'path',
Expand Down Expand Up @@ -183,6 +208,27 @@ export const PropertyShapeSchema: JSONSchema7LD = {
title: 'Max Count',
type: 'integer',
},
// DASH properties
propertyRole: {
type: 'string',
format: 'iri',
title: 'Property Role',
},
editor: {
type: 'string',
format: 'iri',
title: 'Editor',
},
viewer: {
type: 'string',
format: 'iri',
title: 'Viewer',
},
singleLine: {
type: 'boolean',
title: 'Single Line',
},
//permissions extension
shapeModifiability: {
type: 'string',
},
Expand Down
Loading

0 comments on commit 694112e

Please sign in to comment.