@coasys/ad4m / Exports / SHACLShape
Class: SHACLShape
SHACL Node Shape Defines constraints for instances of a class
Table of contents
Constructors
Properties
Methods
- addParentShape
- addProperty
- setConstructorActions
- setDestructorActions
- toJSON
- toLinks
- toTurtle
- fromJSON
- fromLinks
Constructors
constructor
• new SHACLShape(targetClassOrShapeUri, targetClass?)
Create a new SHACL Shape
Parameters
| Name | Type | Description |
|---|---|---|
targetClassOrShapeUri | string | If one argument: the target class (shape URI auto-derived as {class}Shape) If two arguments: first is shape URI, second is target class |
targetClass? | string | Optional target class when first arg is shape URI |
Defined in
shacl/SHACLShape.ts:208 (opens in a new tab)
Properties
constructor_actions
• Optional constructor_actions: AD4MAction[]
AD4M-specific: Constructor actions for creating instances
Defined in
shacl/SHACLShape.ts:194 (opens in a new tab)
destructor_actions
• Optional destructor_actions: AD4MAction[]
AD4M-specific: Destructor actions for removing instances
Defined in
shacl/SHACLShape.ts:197 (opens in a new tab)
nodeShapeUri
• nodeShapeUri: string
URI of this shape (e.g., recipe:RecipeShape)
Defined in
shacl/SHACLShape.ts:185 (opens in a new tab)
parentShapes
• parentShapes: string[]
Parent shape URIs for model inheritance (sh:node references)
Defined in
shacl/SHACLShape.ts:200 (opens in a new tab)
properties
• properties: SHACLPropertyShape[]
Property constraints
Defined in
shacl/SHACLShape.ts:191 (opens in a new tab)
targetClass
• Optional targetClass: string
Target class this shape applies to (e.g., recipe:Recipe)
Defined in
shacl/SHACLShape.ts:188 (opens in a new tab)
Methods
addParentShape
▸ addParentShape(parentShapeUri): void
Add a parent shape reference (sh:node) for model inheritance. When a
Parameters
| Name | Type |
|---|---|
parentShapeUri | string |
Returns
void
Model
class extends another @Model, the child shape references the parent shape so SHACL validators can walk the class hierarchy.
Defined in
shacl/SHACLShape.ts:231 (opens in a new tab)
addProperty
▸ addProperty(prop): void
Add a property constraint to this shape
Parameters
| Name | Type |
|---|---|
prop | SHACLPropertyShape |
Returns
void
Defined in
shacl/SHACLShape.ts:240 (opens in a new tab)
setConstructorActions
▸ setConstructorActions(actions): void
Set constructor actions for this shape
Parameters
| Name | Type |
|---|---|
actions | AD4MAction[] |
Returns
void
Defined in
shacl/SHACLShape.ts:247 (opens in a new tab)
setDestructorActions
▸ setDestructorActions(actions): void
Set destructor actions for this shape
Parameters
| Name | Type |
|---|---|
actions | AD4MAction[] |
Returns
void
Defined in
shacl/SHACLShape.ts:254 (opens in a new tab)
toJSON
▸ toJSON(): object
Convert the shape to a JSON-serializable object. Useful for passing to addSdna() as shaclJson parameter.
Returns
object
JSON-serializable object representing the shape
Defined in
shacl/SHACLShape.ts:790 (opens in a new tab)
toLinks
▸ toLinks(): Link[]
Serialize shape to AD4M Links (RDF triples) Stores the shape as a graph of links in a Perspective
Returns
Link[]
Defined in
shacl/SHACLShape.ts:340 (opens in a new tab)
toTurtle
▸ toTurtle(): string
Serialize shape to Turtle (RDF) format
Returns
string
Defined in
shacl/SHACLShape.ts:261 (opens in a new tab)
fromJSON
▸ Static fromJSON(json): SHACLShape
Create a shape from a JSON object (inverse of toJSON)
Parameters
| Name | Type |
|---|---|
json | any |
Returns
Defined in
shacl/SHACLShape.ts:824 (opens in a new tab)
fromLinks
▸ Static fromLinks(links, shapeUri): SHACLShape
Reconstruct shape from AD4M Links
Parameters
| Name | Type |
|---|---|
links | Link[] |
shapeUri | string |