mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Make URI constants consistent
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Representation } from '../../ldp/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../ldp/representation/RepresentationMetadata';
|
||||
import { RepresentationPreferences } from '../../ldp/representation/RepresentationPreferences';
|
||||
import { MA_CONTENT_TYPE } from '../../util/MetadataTypes';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { matchingMediaType } from '../../util/Util';
|
||||
import { RepresentationConverterArgs } from './RepresentationConverter';
|
||||
import { TypedRepresentationConverter } from './TypedRepresentationConverter';
|
||||
@@ -53,7 +53,7 @@ export class ChainedConverter extends TypedRepresentationConverter {
|
||||
const idx = this.converters.length - 1;
|
||||
const lastChain = await this.getMatchingType(this.converters[idx - 1], this.converters[idx]);
|
||||
const oldMeta = input.representation.metadata;
|
||||
const metadata = new RepresentationMetadata(oldMeta, { [MA_CONTENT_TYPE]: lastChain });
|
||||
const metadata = new RepresentationMetadata(oldMeta, { [CONTENT_TYPE]: lastChain });
|
||||
const representation: Representation = { ...input.representation, metadata };
|
||||
await this.last.canHandle({ ...input, representation });
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Representation } from '../../ldp/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../ldp/representation/RepresentationMetadata';
|
||||
import { RepresentationPreferences } from '../../ldp/representation/RepresentationPreferences';
|
||||
import { INTERNAL_QUADS } from '../../util/ContentTypes';
|
||||
import { MA_CONTENT_TYPE } from '../../util/MetadataTypes';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { checkRequest, matchingTypes } from './ConversionUtil';
|
||||
import { RepresentationConverterArgs } from './RepresentationConverter';
|
||||
import { TypedRepresentationConverter } from './TypedRepresentationConverter';
|
||||
@@ -31,7 +31,7 @@ export class QuadToRdfConverter extends TypedRepresentationConverter {
|
||||
|
||||
private async quadsToRdf(quads: Representation, preferences: RepresentationPreferences): Promise<Representation> {
|
||||
const contentType = matchingTypes(preferences, await rdfSerializer.getContentTypes())[0].value;
|
||||
const metadata = new RepresentationMetadata(quads.metadata, { [MA_CONTENT_TYPE]: contentType });
|
||||
const metadata = new RepresentationMetadata(quads.metadata, { [CONTENT_TYPE]: contentType });
|
||||
return {
|
||||
binary: true,
|
||||
data: rdfSerializer.serialize(quads.data, { contentType }) as Readable,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { StreamWriter } from 'n3';
|
||||
import { Representation } from '../../ldp/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../ldp/representation/RepresentationMetadata';
|
||||
import { INTERNAL_QUADS, TEXT_TURTLE } from '../../util/ContentTypes';
|
||||
import { MA_CONTENT_TYPE } from '../../util/MetadataTypes';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { checkRequest } from './ConversionUtil';
|
||||
import { RepresentationConverter, RepresentationConverterArgs } from './RepresentationConverter';
|
||||
|
||||
@@ -19,7 +19,7 @@ export class QuadToTurtleConverter extends RepresentationConverter {
|
||||
}
|
||||
|
||||
private quadsToTurtle(quads: Representation): Representation {
|
||||
const metadata = new RepresentationMetadata(quads.metadata, { [MA_CONTENT_TYPE]: TEXT_TURTLE });
|
||||
const metadata = new RepresentationMetadata(quads.metadata, { [CONTENT_TYPE]: TEXT_TURTLE });
|
||||
return {
|
||||
binary: true,
|
||||
data: quads.data.pipe(new StreamWriter({ format: TEXT_TURTLE })),
|
||||
|
||||
@@ -3,7 +3,7 @@ import rdfParser from 'rdf-parse';
|
||||
import { Representation } from '../../ldp/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../ldp/representation/RepresentationMetadata';
|
||||
import { INTERNAL_QUADS } from '../../util/ContentTypes';
|
||||
import { MA_CONTENT_TYPE } from '../../util/MetadataTypes';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { pipeStreamsAndErrors } from '../../util/Util';
|
||||
import { checkRequest } from './ConversionUtil';
|
||||
import { RepresentationConverterArgs } from './RepresentationConverter';
|
||||
@@ -30,7 +30,7 @@ export class RdfToQuadConverter extends TypedRepresentationConverter {
|
||||
}
|
||||
|
||||
private rdfToQuads(representation: Representation, baseIRI: string): Representation {
|
||||
const metadata = new RepresentationMetadata(representation.metadata, { [MA_CONTENT_TYPE]: INTERNAL_QUADS });
|
||||
const metadata = new RepresentationMetadata(representation.metadata, { [CONTENT_TYPE]: INTERNAL_QUADS });
|
||||
const rawQuads = rdfParser.parse(representation.data, {
|
||||
contentType: representation.metadata.contentType!,
|
||||
baseIRI,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Representation } from '../../ldp/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../ldp/representation/RepresentationMetadata';
|
||||
import { TEXT_TURTLE, INTERNAL_QUADS } from '../../util/ContentTypes';
|
||||
import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError';
|
||||
import { MA_CONTENT_TYPE } from '../../util/MetadataTypes';
|
||||
import { CONTENT_TYPE } from '../../util/UriConstants';
|
||||
import { checkRequest } from './ConversionUtil';
|
||||
import { RepresentationConverter, RepresentationConverterArgs } from './RepresentationConverter';
|
||||
|
||||
@@ -21,7 +21,7 @@ export class TurtleToQuadConverter extends RepresentationConverter {
|
||||
}
|
||||
|
||||
private turtleToQuads(turtle: Representation, baseIRI: string): Representation {
|
||||
const metadata = new RepresentationMetadata(turtle.metadata, { [MA_CONTENT_TYPE]: INTERNAL_QUADS });
|
||||
const metadata = new RepresentationMetadata(turtle.metadata, { [CONTENT_TYPE]: INTERNAL_QUADS });
|
||||
|
||||
// Catch parsing errors and emit correct error
|
||||
// Node 10 requires both writableObjectMode and readableObjectMode
|
||||
|
||||
Reference in New Issue
Block a user