Merge branch 'main' into versions/next-major

This commit is contained in:
Joachim Van Herwegen
2023-07-25 09:43:15 +02:00
39 changed files with 801 additions and 242 deletions

View File

@@ -1,6 +1,7 @@
import { OkResponseDescription } from '../../http/output/response/OkResponseDescription';
import type { ResponseDescription } from '../../http/output/response/ResponseDescription';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
import type { ResourceStore } from '../../storage/ResourceStore';
import { INTERNAL_QUADS } from '../../util/ContentTypes';
import { MethodNotAllowedHttpError } from '../../util/errors/MethodNotAllowedHttpError';
@@ -32,7 +33,7 @@ export class StorageDescriptionHandler extends OperationHttpHandler {
if (method !== 'GET') {
throw new MethodNotAllowedHttpError([ method ], `Only GET requests can target the storage description.`);
}
const container = { path: ensureTrailingSlash(target.path.slice(0, -this.path.length)) };
const container = this.getStorageIdentifier(target);
const representation = await this.store.getRepresentation(container, {});
representation.data.destroy();
if (!representation.metadata.has(RDF.terms.type, PIM.terms.Storage)) {
@@ -43,10 +44,17 @@ export class StorageDescriptionHandler extends OperationHttpHandler {
}
public async handle({ operation: { target }}: OperationHttpHandlerInput): Promise<ResponseDescription> {
const quads = await this.describer.handle(target);
const quads = await this.describer.handle(this.getStorageIdentifier(target));
const representation = new BasicRepresentation(quads, INTERNAL_QUADS);
return new OkResponseDescription(representation.metadata, representation.data);
}
/**
* Determine the identifier of the root storage based on the identifier of the root storage description resource.
*/
protected getStorageIdentifier(descriptionIdentifier: ResourceIdentifier): ResourceIdentifier {
return { path: ensureTrailingSlash(descriptionIdentifier.path.slice(0, -this.path.length)) };
}
}

View File

@@ -14,7 +14,7 @@ export interface WebhookChannel2023 extends NotificationChannel {
/**
* The "WebHookChannel2023" type.
*/
type: typeof NOTIFY.WebHookChannel2023;
type: typeof NOTIFY.WebhookChannel2023;
/**
* Where the notifications have to be sent.
*/
@@ -22,7 +22,7 @@ export interface WebhookChannel2023 extends NotificationChannel {
}
export function isWebHook2023Channel(channel: NotificationChannel): channel is WebhookChannel2023 {
return channel.type === NOTIFY.WebHookChannel2023;
return channel.type === NOTIFY.WebhookChannel2023;
}
/**
@@ -47,7 +47,7 @@ export class WebhookChannel2023Type extends BaseChannelType {
*/
public constructor(route: InteractionRoute, webIdRoute: InteractionRoute, stateHandler: StateHandler,
features?: string[]) {
super(NOTIFY.terms.WebHookChannel2023,
super(NOTIFY.terms.WebhookChannel2023,
route,
features,
[{ path: NOTIFY.sendTo, minCount: 1, maxCount: 1 }]);
@@ -62,7 +62,7 @@ export class WebhookChannel2023Type extends BaseChannelType {
return {
...channel,
type: NOTIFY.WebHookChannel2023,
type: NOTIFY.WebhookChannel2023,
sendTo: sendTo.value,
};
}