mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Rework ResourceStore to return extra info
* feat: change return types in ResourceStore.ts
* feat: change return types in BaseResourceStore.ts
* feat: change return types in LockingResourceStore.ts
* feat: change return types in RoutingResourceStore.ts
* feat: change return types in MonitoringStore.ts
* feat: change return types in PassthroughStore.ts
* feat: change return types in ReadOnlyStore.ts
* feat: change return types in PatchHandler.ts
* feat: change return types in PatchingStore.ts
* feat: change return types in RepresentationPatchHandler.ts
* feat: create createResourceIdentifier() function for convenience
* feat: adapt PostOperationHandler.ts to new typing
* feat: change return types in RepresentationConvertingStore.ts
* feat: adapt DataAccessorBasedStore.ts implementation to new typings
* feat: adapt UnsecureWebSocketsProtocol.ts to new typing
* chore: add temporary comments
* fix: return correct Location header on POST request with slug
* fix: npm run lint command needs more packages
* fix: linting errors
* chore: revert ed9952b
* test: adapt PostOperationHandler tests
* test: adapt UnsecureWebSocketsProtocol tests
* test: adapt DataAccessorBasedStore tests
* fix: linting errors
* feat: emit specific created, deleted, updated events in MonitoringStore
* test: adapt RepresentationPatchHandler tests
* fix: revert UnsecureWebSocketsProtocol changes
* feat: emit extra parameter on changed
* test: adapt MonitoringStore tests
* fix: linting errors
* test: add test to MonitorStore.test for coverage
* fix: linting error
* chore: update doc in ResourceStore.ts
* test: improve MonitoringStore tests
* chore: update RELEASE_NOTES.md
* chore: add extra info about the MonitoringStore to documentation/resource-store.md
* chore: Update RELEASE_NOTES.md
Co-authored-by: Anton Wiklund <ixuz07@gmail.com>
* chore: Update documentation/resource-store.md
Co-authored-by: Anton Wiklund <ixuz07@gmail.com>
* chore: very small changes
* chore: simplify metadata creation
* fix: DataAccessorBasedStore improvement and bugfix
* chore: improve resource-store.md
* chore: adapt MonitoringStore event names, update docs and apply code suggestion
* chore: use ResourceStoreResponse type
* fix: typo
* chore: rename ResourceStoreResponse type to ChangeMap
* chore: adapt .gitignore to name change
Co-authored-by: Anton Wiklund <ixuz07@gmail.com>
This commit is contained in:
@@ -2,8 +2,10 @@ import { getLoggerFor } from '../../logging/LogUtil';
|
||||
import type { ResourceStore } from '../../storage/ResourceStore';
|
||||
import { BadRequestHttpError } from '../../util/errors/BadRequestHttpError';
|
||||
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
|
||||
import { AS, SOLID_AS } from '../../util/Vocabularies';
|
||||
import { CreatedResponseDescription } from '../output/response/CreatedResponseDescription';
|
||||
import type { ResponseDescription } from '../output/response/ResponseDescription';
|
||||
import { createResourceIdentifier } from '../representation/ResourceIdentifier';
|
||||
import type { OperationHandlerInput } from './OperationHandler';
|
||||
import { OperationHandler } from './OperationHandler';
|
||||
|
||||
@@ -35,7 +37,10 @@ export class PostOperationHandler extends OperationHandler {
|
||||
this.logger.warn('POST requests require the Content-Type header to be set');
|
||||
throw new BadRequestHttpError('POST requests require the Content-Type header to be set');
|
||||
}
|
||||
const identifier = await this.store.addResource(operation.target, operation.body, operation.conditions);
|
||||
return new CreatedResponseDescription(identifier);
|
||||
const result = await this.store.addResource(operation.target, operation.body, operation.conditions);
|
||||
const createdIdentifier = Object.entries(result).find(
|
||||
([ , value ]): boolean => value.get(SOLID_AS.terms.Activity)?.value === AS.Create,
|
||||
)![0];
|
||||
return new CreatedResponseDescription(createResourceIdentifier(createdIdentifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,15 @@ export interface ResourceIdentifier {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the object is a `ResourceIdentifier`.
|
||||
* Determines whether the object is a {@link ResourceIdentifier}.
|
||||
*/
|
||||
export function isResourceIdentifier(object: any): object is ResourceIdentifier {
|
||||
return object && (typeof object.path === 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory function creating a {@link ResourceIdentifier} for convenience.
|
||||
*/
|
||||
export function createResourceIdentifier(resourcePath: string): ResourceIdentifier {
|
||||
return { path: resourcePath };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user