-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TriG documents not being PUT-able #773
Conversation
d7aa118
to
da8f5a0
Compare
The reason the integration tests failed is because it also needs to be added in https://github.com/solid/community-server/blob/main/templates/config/filesystem.json . The templates for dynamic pods don't fully make use of the new configuration setup yet so there's some duplication there. |
da8f5a0
to
e494d31
Compare
Amended the commit with all suggested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, let's get the duplication out though. Can be a new issue as far as I'm concerned.
public constructor( | ||
base: string, | ||
rootFilepath: string, | ||
overrideTypes: Record<string, string> = { acl: TEXT_TURTLE, meta: TEXT_TURTLE, trig: APPLICATION_TRIG }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop the default here—or leave it as it was.
The rationale is the following.
This class is expected to perform a "perfect" mapping from extensions to MIME types, with the (sole) exception of Solid-specific MIME types. So acl
and meta
are special in the sense that they do not exist outside of the Solid world. In contract, trig
exists outside of Solid; it's basically a "bug" in mime-types
(can we PR?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs it uses the db here and they accept PRs https://github.com/jshttp/mime-db
application/trig
is a content-type they recognize as existing, but it does not have an official extension associated with it in the db is the issue, as it does not have any in the official databases this library makes use of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I maybe wonder whether we want to rename overrideTypes
into customTypes
perhaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, | ||
{ | ||
"SubdomainExtensionBasedMapper:_overrideTypes_key": "trig", | ||
"SubdomainExtensionBasedMapper:_overrideTypes_value": "application/trig" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps comment that this is a bug/omission in mime-types
? (see below)
@@ -36,7 +36,7 @@ export class SubdomainExtensionBasedMapper extends ExtensionBasedMapper { | |||
private readonly baseParts: { scheme: string; rest: string }; | |||
|
|||
public constructor(base: string, rootFilepath: string, baseSubdomain = 'www', | |||
overrideTypes = { acl: TEXT_TURTLE, meta: TEXT_TURTLE }) { | |||
overrideTypes: Record<string, string> = { acl: TEXT_TURTLE, meta: TEXT_TURTLE, trig: APPLICATION_TRIG }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely do not like this duplication here. Let's export this object from ./../util/ContentTypes
?
Then I also have no objection for using it as the default in ExtensionBasedMapper
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also just remove the default values from the constructor actually since they're in the config anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but the problem is that these values need to be encoded multiple times in config.
config/util/identifiers/suffix.json
Outdated
"ExtensionBasedMapper:_overrideTypes_key": "trig", | ||
"ExtensionBasedMapper:_overrideTypes_value": "application/trig" | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's me wishing that the object could be reused across subdomain.json
and suffix.json
, but I understand why that is currently not possible. Future idea for Components.js to have generic key/value props?
So I guess this PR can just be replaced with a version bump of |
I have pinged jshttp/mime-db#238 |
I do like the genericness of the solution though; would still keep it and its tests, just not the |
Might need the override system in any case; |
A new version of the MIME library has been released, so we can adjust this PR. Note that I'd still like to keep the option of having overrides. |
@rubensworks But feel free to pass this on to anyone else; just so we have a champion to bring this to v1.0.0. |
Since mime-db is updated, the scope of this PR doesn't really align with my use case anymore, so not sure when I'll be able to look into this. |
Sure |
The mime-types library also has to be updated to use the updated version of mime-db. Or we can use the mime-db dependency directly and implement the wanted behaviour ourselves. |
Just a package-lock upgrade is fine with me. |
4424375
to
6589c13
Compare
I have updated the commit. Now it is no longer necessary to set the defaults custom types in the config. Trig is still in there since mime-types hardcodes its dependency in the package.json: https://github.com/jshttp/mime-types/blob/2.1.31/package.json#L17 . We can leave this open until that gets updated, is only a small change afterwards. Using both |
src/util/ContentTypes.ts
Outdated
@@ -11,3 +12,6 @@ export const TEXT_TURTLE = 'text/turtle'; | |||
export const INTERNAL_ALL = 'internal/*'; | |||
export const INTERNAL_QUADS = 'internal/quads'; | |||
export const INTERNAL_ERROR = 'internal/error'; | |||
|
|||
// Trig can be removed once the mime-types library is updated with the latest mime-db version | |||
export const DEFAULT_CUSTOM_TYPES = { acl: TEXT_TURTLE, meta: TEXT_TURTLE, trig: APPLICATION_TRIG }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps separate by newlines for easier access?
@joachimvh FYI, It looks like mime-types has been updated to 2.1.32, which includes the new mime-db. Edit: created a PR for it in #882 |
A temporary fix until a more generic solution is implemented (#768).