The JSON-LD Framing algorithm accepts a frame that we have been supplying by default to consumers of this library. This PR fixes issue with the default frame so that it is more generic.
It turns out that the default frame fails to serialize Docmaps that have only one step to date, because Framing is designed for both filtering and shaping. The keys in a frame can be supplied iwth values to "select" on. By providing shape information in the steps' next-step and previous-step sub-frames, we implicitly tell the framing algorithm to "only match Steps if they have one of these keys" because otherwise the frame for "hasStep" finds no matches. There is no way to specify subframes but "allow zero matching properties".
However, we can circumvent this limitation by disabling requireAll, which allows matching if ANY property is present and matching, while still enforcing the shaping-related rules when those keys are there. This we match on properties all steps are guaranteed to have. The only such property is @id (even though this should be a blank node id).
Related Issues
List any issues that are related to this pull request, such as bug reports or feature requests.
Checklist
[x] I have tested these changes locally and they work as expected.
[x] I have added or updated tests to cover any new functionality or bug fixes.
[x] I have updated the documentation to reflect any changes or additions to the project.
Description
The JSON-LD Framing algorithm accepts a frame that we have been supplying by default to consumers of this library. This PR fixes issue with the default frame so that it is more generic.
It turns out that the default frame fails to serialize Docmaps that have only one step to date, because Framing is designed for both filtering and shaping. The keys in a frame can be supplied iwth values to "select" on. By providing shape information in the steps'
next-step
andprevious-step
sub-frames, we implicitly tell the framing algorithm to "only match Steps if they have one of these keys" because otherwise the frame for "hasStep" finds no matches. There is no way to specify subframes but "allow zero matching properties".However, we can circumvent this limitation by disabling
requireAll
, which allows matching if ANY property is present and matching, while still enforcing the shaping-related rules when those keys are there. This we match on properties all steps are guaranteed to have. The only such property is@id
(even though this should be a blank node id).Related Issues
List any issues that are related to this pull request, such as bug reports or feature requests.
Checklist
Additional Information
see info about
@requireAll
. It is unclear what the default value is so I specify it manually asfalse
.the
omitEmpty
is probably a good thing anyway and makes thefromNullable
usages unnecessary.