Description
Here are some comments I had after going through the repository.
package.json
I don't think it's necessary to have the project version be the same as the CSS version it supports, although you can of course. But if you ever want to do a major release of this package while CSS has not changed version there is no way to do it correctly. The supported CSS version can always be deduced from the package.json dependencies.
The repository
field is wrong.
Folder structure
I was confused at first that both the config and src folders have the same structure as those in CSS as I thought it implied you were replacing files/configs from CSS. Might be a bit overkil to have such deep folder nesting for 2-3 files.
Documentation
There are some minor grammar issues here and there so would suggest a re-read. Would also advise to not use "obviously" in your text to not make your readers feel stupid 😉.
ShapeValidator.ts
Is missing tsdoc for the class and parameters. The other classes could also use some more documentation.
ShaclValidator.ts
noShapePresent
should be a constant outside of the class, or probably just removed since it only occurs once.
canHandle
should throw an HttpError
(probably NotImplementedHttpError).
let representationData;
should have a type
Why does an InternalServerError
imply that you are trying to create containers in a constrained container? How does the conversion process trigger this since that shouldn't create anything? Even if this happens, the check should be more specific, e.g. checking the contents of the error.
error instanceof NotImplementedHttpError
-> NotImplementedHttpError.isInstance
. This gets around certain components.js edge case issues.
Skipping on auxiliary files should happen in the canHandle
, not after cloning, since cloning is expensive.
No need to impkement handleSafe
yourself in this case as the canHandle
call is negligible. The way it is currently done is also wrong, this is how it's supposed to work: https://github.com/CommunitySolidServer/CommunitySolidServer/blob/da99ff30f63b673ea272fc918c69c9ff4a5c0401/src/util/handlers/AsyncHandler.ts#L38-L41
shape-validator-component/src/storage/validators/ShaclValidator.ts
Lines 108 to 111 in 3f60a0a
Can be
if (targetClasses.some(targetClass => dataStore.countQuads(null, null, targetClass, null) > 0) {
.
shape-validator-component/src/storage/validators/ShaclValidator.ts
Lines 112 to 113 in 3f60a0a
Not sure why there is a string in a string there.
ShapeValidationStore.ts
The fact that this class takes so many inputs makes me think that it might be doing too much. Also the fact that the setRepresentation
call is 2 completely separate things (which should be separate function calls). It actually feels like the entire metadata part should not be here. We already have a place where we validate metadata that is being changed, this would be a better fit there. Perhaps CSS would need a more generic way to add classes that validate PATCH results.
Ordering of the calls should be changed so no unneccessary actions are done. No need to calculate current representation and shapes if newShapes.length > 1. Similarly, no need to do any work if newShapes.length === 0.
shape-validator-component/src/storage/ShapeValidationStore.ts
Lines 85 to 86 in 3f60a0a
How do you trigger this because this feels like it should be fixed in CSS?
Only the getRepresentation
call should be in the try/catch that prevents the NotFoundHttpError
. Although preferably we can just prevent this situation from happening as mentioned above.