Skip to content

Feat/shape support - #1000

Closed
woutslabbinck wants to merge 105 commits into
CommunitySolidServer:versions/6.0.0from
woutslabbinck:feat/shape-support
Closed

woutslabbinck wants to merge 105 commits into
CommunitySolidServer:versions/6.0.0from
woutslabbinck:feat/shape-support

Conversation

@woutslabbinck

Copy link
Copy Markdown
Member

No description provided.

@woutslabbinck
woutslabbinck changed the base branch from main to versions/2.0.0 October 14, 2021 09:59
@RubenVerborgh

Copy link
Copy Markdown
Member

1000 🥳

Allows advertising the shapes to which resources should conform in a given container
@jvherweg
jvherweg changed the base branch from versions/2.0.0 to versions/2.1.0 October 18, 2021 08:16
@woutslabbinck woutslabbinck linked an issue Aug 18, 2022 that may be closed by this pull request
4 tasks
@woutslabbinck woutslabbinck self-assigned this Aug 18, 2022
@woutslabbinck
woutslabbinck marked this pull request as ready for review August 18, 2022 12:29
@woutslabbinck
woutslabbinck requested a review from jvherweg August 18, 2022 12:29
@jvherweg

Copy link
Copy Markdown
Member

@woutslabbinck can you link to the specifications/documents/whatevers that are relevant for this PR?

@woutslabbinck

Copy link
Copy Markdown
Member Author

LDP servers MUST publish any constraints on LDP clients’ ability to create or update LDPRs, by adding a Link header with an appropriate context URI, a link relation of http://www.w3.org/ns/ldp#constrainedBy, and a target URI identifying a set of constraints [RFC5988], to all responses to requests that fail due to violation of those constraints. For example, a server that refuses resource creation requests via HTTP PUT, POST, or PATCH would return this Link header on its 4xx responses to such requests. The same Link header MAY be provided on other responses. LDP neither defines nor constrains the representation of the link's target resource. Natural language constraint documents are therefore permitted, although machine-readable ones facilitate better client interactions. The appropriate context URI can vary based on the request's semantics and method; unless the response is otherwise constrained, the default (the effective request URI) SHOULD be used.

  • And then there is SHACL, which is being used to define the shape.
  • There is also a check targetClassCheck in the code that checks if there is at least a part of a new resource that can be validated by the given shape

@RubenVerborgh

Copy link
Copy Markdown
Member

[After an offline discussion with @joachimvh]

Great work!

I think this code is a good candidate for an external module, given that server-side validation is not part of the spec yet, and that this code only adds things but does not need to make any changes.

However, then I'd want a good CI setup for such an external module, ensuring that integrations are tested with every CSS commit (or at least daily on the latest main and version branches).

Another good candidate for an external module is the quota system.

@jvherweg

Copy link
Copy Markdown
Member

However, then I'd want a good CI setup for such an external module, ensuring that integrations are tested with every CSS commit (or at least daily on the latest main and version branches).

That is a nice idea actually for all external modules we host ourselves here (which currently only is the example module), although I'm not sure if you can track commits from a different repository?

@RubenVerborgh

Copy link
Copy Markdown
Member

track commits from a different repository?

Maybe not, but this repository can ping other repositories on commit!

Or we could run an external modules test suite on our CI.

@jvherweg

Copy link
Copy Markdown
Member

@RubenVerborgh probably a good time to decide on npm naming convention for other packages we release from the CommunitySolidServer organization. CSS is in @solid, but we might want something different for the external modules we release?

However, then I'd want a good CI setup for such an external module, ensuring that integrations are tested with every CSS commit (or at least daily on the latest main and version branches).

Talking about npm releases, this also makes this a bit more difficult. The external module is simply going to depend on the npm package of CSS, which is currently 5.0.0. Any commits that happen here are not going to impact automated tests on the external module. Or the CI there would have to replace its standard CSS dependency by cloning CSS, doing an install, and moving the dist folder (or doing npm link) which might end up being quite ugly.

Additionally, in the case of version branches the tests might fail if we change the config structure, but there is nothing the external module can do about that, since it can only make the necessary changes once there is an npm release of that version. Unless it also has a different branch for the next release already to track those changes.

@RubenVerborgh

Copy link
Copy Markdown
Member

CSS is in @solid, but we might want something different for the external modules we release?

https://www.npmjs.com/org/community-solid-server

The external module is simply going to depend on the npm package of CSS

peerDependency

impact automated tests on the external module

npm install CommunitySolidServer/CommunitySolidServer#main

That's quite feasible.

@jeswr

jeswr commented Nov 21, 2022 •

Copy link
Copy Markdown
Contributor

@woutslabbinck - Would it be much work to add support for .shaclc files using https://www.npmjs.com/package/shaclc-parse?

@woutslabbinck

Copy link
Copy Markdown
Member Author

@jeswr I retrieve the SHACL shape files by calling fetchDataset from FetchUtil.

export async function fetchDataset(url: string): Promise<Representation> {
// Try content negotiation to parse quads from the URL
return (async(): Promise<Representation> => {
try {
const quadStream = (await rdfDereferencer.dereference(url)).data;
const quadArray = await arrayifyStream<Quad>(quadStream);
return new BasicRepresentation(quadArray, { path: url }, INTERNAL_QUADS, false);
} catch (error: unknown) {
throw new BadRequestHttpError(`Could not parse resource at URL (${url})! ${createErrorMessage(error)}`);
}
})();
}

This utility function uses the library rdf-dereference to parse the quads and return them in a streaming way.

Which means that if can put your package as a part of rdf-dereference, it would work without a problem without touching the code.

@jvherweg

Copy link
Copy Markdown
Member

@jvherweg jvherweg closed this Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for SHACL shape constraints

5 participants