mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Convert data from ResourceStore based on preferences
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { Conditions } from './Conditions';
|
||||
import { PassthroughStore } from './PassthroughStore';
|
||||
import { Patch } from '../ldp/http/Patch';
|
||||
import { PatchHandler } from './patch/PatchHandler';
|
||||
import { Representation } from '../ldp/representation/Representation';
|
||||
import { RepresentationPreferences } from '../ldp/representation/RepresentationPreferences';
|
||||
import { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
|
||||
import { ResourceStore } from './ResourceStore';
|
||||
|
||||
@@ -11,34 +10,14 @@ import { ResourceStore } from './ResourceStore';
|
||||
* If the original store supports the {@link Patch}, behaviour will be identical,
|
||||
* otherwise one of the {@link PatchHandler}s supporting the given Patch will be called instead.
|
||||
*/
|
||||
export class PatchingStore implements ResourceStore {
|
||||
private readonly source: ResourceStore;
|
||||
export class PatchingStore extends PassthroughStore {
|
||||
private readonly patcher: PatchHandler;
|
||||
|
||||
public constructor(source: ResourceStore, patcher: PatchHandler) {
|
||||
this.source = source;
|
||||
super(source);
|
||||
this.patcher = patcher;
|
||||
}
|
||||
|
||||
public async addResource(container: ResourceIdentifier, representation: Representation,
|
||||
conditions?: Conditions): Promise<ResourceIdentifier> {
|
||||
return this.source.addResource(container, representation, conditions);
|
||||
}
|
||||
|
||||
public async deleteResource(identifier: ResourceIdentifier, conditions?: Conditions): Promise<void> {
|
||||
return this.source.deleteResource(identifier, conditions);
|
||||
}
|
||||
|
||||
public async getRepresentation(identifier: ResourceIdentifier, preferences: RepresentationPreferences,
|
||||
conditions?: Conditions): Promise<Representation> {
|
||||
return this.source.getRepresentation(identifier, preferences, conditions);
|
||||
}
|
||||
|
||||
public async setRepresentation(identifier: ResourceIdentifier, representation: Representation,
|
||||
conditions?: Conditions): Promise<void> {
|
||||
return this.source.setRepresentation(identifier, representation, conditions);
|
||||
}
|
||||
|
||||
public async modifyResource(identifier: ResourceIdentifier, patch: Patch, conditions?: Conditions): Promise<void> {
|
||||
try {
|
||||
return await this.source.modifyResource(identifier, patch, conditions);
|
||||
|
||||
Reference in New Issue
Block a user