refactor: Streamline RepresentationMetadata interface

This commit is contained in:
Joachim Van Herwegen
2020-09-08 09:43:30 +02:00
parent 76319ba360
commit 8d3979372b
36 changed files with 416 additions and 230 deletions

View File

@@ -1,7 +1,6 @@
import { Representation } from '../ldp/representation/Representation';
import { RepresentationPreferences } from '../ldp/representation/RepresentationPreferences';
import { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
import { CONTENT_TYPE } from '../util/MetadataTypes';
import { matchingMediaType } from '../util/Util';
import { Conditions } from './Conditions';
import { RepresentationConverter } from './conversion/RepresentationConverter';
@@ -38,12 +37,12 @@ export class RepresentationConvertingStore<T extends ResourceStore = ResourceSto
if (!preferences.type) {
return true;
}
const contentType = representation.metadata.get(CONTENT_TYPE);
const { contentType } = representation.metadata;
return Boolean(
contentType &&
preferences.type.some((type): boolean =>
type.weight > 0 &&
matchingMediaType(type.value, contentType.value)),
matchingMediaType(type.value, contentType)),
);
}
}