Skip to content

Commit 3dc2b20

Browse files
committed
docs: add README.md
1 parent 14ff226 commit 3dc2b20

File tree

2 files changed

+91
-2
lines changed

2 files changed

+91
-2
lines changed

README.md

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
# Shape validation module
22

3+
This repository contains an external component that can be injected into the [Community Solid Server](https://github.com/CommunitySolidServer/CommunitySolidServer/) (CSS).
4+
It allows to constrain an [`ldp:Container`](https://www.w3.org/TR/ldp/) to only have resources that conform to a given shape.
5+
6+
Instructions on how to constrain a given container can be found [here](documentation/constrained-containers.md).
7+
8+
## Running the server
9+
10+
Clone this repository, then install the packages
11+
```sh
12+
npm i
13+
```
14+
To run the server with your current folder as storage, use:
15+
```sh
16+
npm run start
17+
```
18+
19+
Configurations for in-memory storage and file storage without setup are also provided.
20+
21+
## Feedback and questions
22+
23+
Do not hesitate to [report a bug](https://github.com/woutslabbinck/shape-validator-component/issues).
24+
25+
Further questions can also be asked to [Wout Slabbinck](mailto:[email protected]) (developer and maintainer of this repository).
26+
327
## TODOs
428

529
- [x] make https://github.com/woutslabbinck/community-server/tree/feat/shape-support work in this directory
630
- [x] override link header attempt
731
- [x] make the tests work
832
- [x] unit
933
- [x] integration
10-
- [ ] add README.md
11-
- [ ] check everything at https://trello.com/c/JzMVInXw/81-shape-support-pr-after-metadata-editing
34+
- [x] add README.md
35+
- [ ] move to CSS organization
1236
- [ ] ask feedback Joachim (zal pas na Januari zijn)
1337
- [ ] publish op npm: https://www.npmjs.com/org/community-solid-server
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Constrained containers
2+
3+
In CSS, it is possible to have containers where all its resources conform to a given [SHACL](https://www.w3.org/TR/shacl/) shape.
4+
Providing shape validation ensures that applications can then rely on the fact that
5+
the structure of the graph in the resources are valid.
6+
7+
## Constrained containers in practice
8+
9+
### Making a container constrained by a shape
10+
11+
A container can be made shape constrained by editing its description resource.
12+
A triple of the form `?container ldp:constrainedBy ?shape .` must be added,
13+
where `?container` is the URL of the container being made constrained and `?shape` is the URL of the SHACL shape.
14+
15+
A precondition for making a container constrained is that the container must not contain any resource at initialisation of making it shape constrained.
16+
Furthermore, it is only possible to initialise one shape resource per container.
17+
18+
### Discovery of a constrained container
19+
20+
Exposing that a container is constrained by shape is done through advertising a Link Header
21+
with `"rel"` `http://www.w3.org/ns/ldp#constrainedBy` as is defined in [LDP](https://www.w3.org/TR/ldp/) 4.2.1.6.
22+
23+
## Impact of constraining a container
24+
25+
Obviously, only resources can be created that conform to the constraints on a constrained container.
26+
However, some additional restrictions are enforced by the server on that container:
27+
28+
* It is not possible to add any non-RDF resources.
29+
* Creating containers within this constrained container is not allowed.
30+
* Requests that results into a resource where no targetClasses from the shape are present are prohibited and will thus produce an error.
31+
32+
## Example of a workflow on how to constrain a container
33+
34+
In this example, we want to constrain a container `http://localhost:3000/container/` with a SHACL shape.
35+
36+
We have started the CSS with the default configuration and have already created a container at `http://localhost:3000/container/`
37+
and added a SHACL shape at `http://localhost:3000/shape`.
38+
39+
We make the container constrained by adding the constraint to the description resource of the container.
40+
41+
```shell
42+
curl -X PATCH 'http://localhost:3000/container/.meta' \
43+
-H 'Content-Type: text/n3' \
44+
--data-raw '@prefix solid: <http://www.w3.org/ns/solid/terms#>.
45+
<> a solid:InsertDeletePatch;
46+
solid:inserts { <http://localhost:3000/container/> <http://www.w3.org/ns/ldp#constrainedBy> <http://localhost:3000/shape>. }.'
47+
```
48+
49+
After this update, we can verify that the container is indeed constrained with a shape by
50+
performing a `HEAD` request to container.
51+
52+
```curl
53+
curl --head http://localhost:3000/container/
54+
```
55+
which will produce a response with at least this header:
56+
57+
```HTTP
58+
Link: <http://localhost:3000/shape>; rel="http://www.w3.org/ns/ldp#constrainedBy"
59+
```
60+
61+
The container is now indeed constrained by the shape.
62+
This means that all the resources that will be added in this container are conform to the shape.
63+
64+
In this example, we used a SHACL shape that was stored on the server.
65+
However, we can use any SHACL shape that can be fetched on the web via HTTP.

0 commit comments

Comments
 (0)