mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Add BaseResourceStore.
This commit is contained in:
@@ -153,6 +153,7 @@ export * from './storage/routing/RouterRule';
|
||||
|
||||
// Storage
|
||||
export * from './storage/AtomicResourceStore';
|
||||
export * from './storage/BaseResourceStore';
|
||||
export * from './storage/Conditions';
|
||||
export * from './storage/DataAccessorBasedStore';
|
||||
export * from './storage/LockingResourceStore';
|
||||
|
||||
36
src/storage/BaseResourceStore.ts
Normal file
36
src/storage/BaseResourceStore.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { Patch } from '../ldp/http/Patch';
|
||||
import type { Representation } from '../ldp/representation/Representation';
|
||||
import type { RepresentationPreferences } from '../ldp/representation/RepresentationPreferences';
|
||||
import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
|
||||
import { NotImplementedHttpError } from '../util/errors/NotImplementedHttpError';
|
||||
import type { Conditions } from './Conditions';
|
||||
import type { ResourceStore } from './ResourceStore';
|
||||
|
||||
/**
|
||||
* Base implementation of ResourceStore for implementers of custom stores.
|
||||
*/
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
export class BaseResourceStore implements ResourceStore {
|
||||
public async addResource(container: ResourceIdentifier, representation: Representation,
|
||||
conditions?: Conditions): Promise<ResourceIdentifier> {
|
||||
throw new NotImplementedHttpError();
|
||||
}
|
||||
|
||||
public async deleteResource(identifier: ResourceIdentifier, conditions?: Conditions): Promise<void> {
|
||||
throw new NotImplementedHttpError();
|
||||
}
|
||||
|
||||
public async getRepresentation(identifier: ResourceIdentifier, preferences: RepresentationPreferences,
|
||||
conditions?: Conditions): Promise<Representation> {
|
||||
throw new NotImplementedHttpError();
|
||||
}
|
||||
|
||||
public async modifyResource(identifier: ResourceIdentifier, patch: Patch, conditions?: Conditions): Promise<void> {
|
||||
throw new NotImplementedHttpError();
|
||||
}
|
||||
|
||||
public async setRepresentation(identifier: ResourceIdentifier, representation: Representation,
|
||||
conditions?: Conditions): Promise<void> {
|
||||
throw new NotImplementedHttpError();
|
||||
}
|
||||
}
|
||||
27
test/unit/storage/BaseResourceStore.test.ts
Normal file
27
test/unit/storage/BaseResourceStore.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { BaseResourceStore } from '../../../src/storage/BaseResourceStore';
|
||||
import { NotImplementedHttpError } from '../../../src/util/errors/NotImplementedHttpError';
|
||||
|
||||
const any: any = {};
|
||||
|
||||
describe('A BaseResourceStore', (): void => {
|
||||
const store = new BaseResourceStore();
|
||||
it('errors on getRepresentation.', async(): Promise<void> => {
|
||||
await expect(store.getRepresentation(any, any)).rejects.toThrow(NotImplementedHttpError);
|
||||
});
|
||||
|
||||
it('errors on addResource.', async(): Promise<void> => {
|
||||
await expect(store.addResource(any, any)).rejects.toThrow(NotImplementedHttpError);
|
||||
});
|
||||
|
||||
it('errors on setRepresentation.', async(): Promise<void> => {
|
||||
await expect(store.setRepresentation(any, any)).rejects.toThrow(NotImplementedHttpError);
|
||||
});
|
||||
|
||||
it('errors on deleteResource.', async(): Promise<void> => {
|
||||
await expect(store.deleteResource(any, any)).rejects.toThrow(NotImplementedHttpError);
|
||||
});
|
||||
|
||||
it('errors on modifyResource.', async(): Promise<void> => {
|
||||
await expect(store.modifyResource(any, any)).rejects.toThrow(NotImplementedHttpError);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user