Repository navigation
Resource store router - #283
Conversation
|
LinkedSoftwareDependencies/Components-Generator.js#43 was a lot more work than I anticipated, but it's done now. {
"@id": "urn:solid-server:default:RegexRouterRule",
"@type": "RegexRouterRule",
"RegexRouterRule:_base": {
"@id": "urn:solid-server:default:variable:base"
},
"RegexRouterRule:_storeMap": [
{
"RegexRouterRule:_storeMap_key": "abc",
"RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:ResourceStore1" }
},
{
"RegexRouterRule:_storeMap_key": "def",
"RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:ResourceStore2" }
}
]
}I've included a commit to bump the generator version. (FYI, JSON-LD 1.1 may have some features that could simplify this |
|
Thanks! |
RubenVerborgh
left a comment
There was a problem hiding this comment.
Good stuff, I just find ConvertingRouterRule weirdly scoped, but not a showstopper.
| super(); | ||
| this.base = trimTrailingSlashes(base); | ||
| this.regexes = Object.keys(storeMap).map((regex): RegexEntry => | ||
| ({ regex: new RegExp(regex, 'u'), store: storeMap[regex] })); |
There was a problem hiding this comment.
Yeah, we don't know the right regex options, so definitely want an actual map.
I do see the appeal of it being JSON-configurable, but that should IMHO be the fallback.
There was a problem hiding this comment.
Problem is that we then won't be able to configure this class in Components.js, which is needed for this one.
There was a problem hiding this comment.
I get that; so I'd still have the JSON-configurable version as a fallback, but also make sure that we can properly construct if we want to.
So:
public constructor(base: string, storeMap: Map<RegExp, String> | { [regex: string]: ResourceStore }) {
...
if (!isMap(storeMap)))
storeMap = toRegexMap(storeMap);
There was a problem hiding this comment.
Components.js generator doesn't like this though, since it can't convert the first part (or because it's a union).
There was a problem hiding this comment.
Ah ok, but that should be filed as a Components.js issue then, and marked as a todo the code (or as an issue on this repo).
We can't have Components.js influence our design; and if it does, we should annotate.
There was a problem hiding this comment.
This might get quite ugly though. The union type is already quite verbose, and I don't think there's a way for components.js to directly support this so it might need special annotations not helping the situation. But I'll leave that comment up to @rubensworks
There was a problem hiding this comment.
OK, thanks; just document this as an issue/todo somewhere and we can move on for now.
75974be to
ab6da6c
Compare
ab6da6c to
988ddbc
Compare
Replaces #79 due to new branch.
Resolves #195 and #59 (together with #279) .
Both routers are quite generic. Since there are many ways you would want to check the contents of a path I just made it accept regexes as input for that router. For the converting router, in practice it's probably mostly going to be converting to Quads, but any type is supported.
Travis build is going to fail because LinkedSoftwareDependencies/Components-Generator.js#43 . Depending on how urgent this component is needed and the timing of this PR acceptance, I might leave out the path router until that issue is fixed.