mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: add documentation for many classes where it was missing
This commit is contained in:
parent
39853b0bd0
commit
fe11f4b1ce
@ -2,6 +2,9 @@ import { Credentials } from './Credentials';
|
||||
import { CredentialsExtractor } from './CredentialsExtractor';
|
||||
import { HttpRequest } from '../server/HttpRequest';
|
||||
|
||||
/**
|
||||
* Credentials extractor which simply interprets the contents of the Authorization header as a webID.
|
||||
*/
|
||||
export class SimpleCredentialsExtractor extends CredentialsExtractor {
|
||||
public async canHandle(): Promise<void> {
|
||||
return undefined;
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { UnsupportedHttpError } from '../util/errors/UnsupportedHttpError';
|
||||
import { Authorizer, AuthorizerArgs } from './Authorizer';
|
||||
|
||||
/**
|
||||
* Authorizer which allows all access independent of the identifier and requested permissions.
|
||||
*/
|
||||
export class SimpleAuthorizer extends Authorizer {
|
||||
public async canHandle(input: AuthorizerArgs): Promise<void> {
|
||||
if (!input.identifier || !input.permissions) {
|
||||
|
@ -2,4 +2,7 @@ import { AsyncHandler } from '../../util/AsyncHandler';
|
||||
import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { Representation } from '../representation/Representation';
|
||||
|
||||
/**
|
||||
* Parses the body of an incoming {@link HttpRequest} and converts it to a {@link Representation}.
|
||||
*/
|
||||
export abstract class BodyParser extends AsyncHandler<HttpRequest, Representation> {}
|
||||
|
@ -2,4 +2,7 @@ import { AsyncHandler } from '../../util/AsyncHandler';
|
||||
import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { RepresentationPreferences } from '../representation/RepresentationPreferences';
|
||||
|
||||
/**
|
||||
* Creates {@link RepresentationPreferences} based on the incoming HTTP headers in a {@link HttpRequest}.
|
||||
*/
|
||||
export abstract class PreferenceParser extends AsyncHandler<HttpRequest, RepresentationPreferences> {}
|
||||
|
@ -5,6 +5,10 @@ import { RepresentationMetadata } from '../representation/RepresentationMetadata
|
||||
import { StreamParser } from 'n3';
|
||||
import { UnsupportedMediaTypeHttpError } from '../../util/errors/UnsupportedMediaTypeHttpError';
|
||||
|
||||
/**
|
||||
* Parses the incoming {@link HttpRequest} if there is no body or if it contains turtle (or similar) RDF data.
|
||||
* Naively parses the content-type header to determine the body type.
|
||||
*/
|
||||
export class SimpleBodyParser extends BodyParser {
|
||||
private static readonly contentTypes = [
|
||||
'application/n-quads',
|
||||
|
@ -3,6 +3,10 @@ import { PreferenceParser } from './PreferenceParser';
|
||||
import { RepresentationPreference } from '../representation/RepresentationPreference';
|
||||
import { RepresentationPreferences } from '../representation/RepresentationPreferences';
|
||||
|
||||
/**
|
||||
* Extracts preferences from the accept-* headers from an incoming {@link HttpRequest}.
|
||||
* Parsing of header strings is done naively.
|
||||
*/
|
||||
export class SimplePreferenceParser extends PreferenceParser {
|
||||
public constructor() {
|
||||
super();
|
||||
|
@ -14,6 +14,10 @@ export interface SimpleRequestParserArgs {
|
||||
bodyParser: BodyParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@link Operation} from an incoming {@link HttpRequest} by aggregating the results
|
||||
* of a {@link TargetExtractor}, {@link PreferenceParser}, and {@link BodyParser}.
|
||||
*/
|
||||
export class SimpleRequestParser extends RequestParser {
|
||||
private readonly targetExtractor: TargetExtractor;
|
||||
private readonly preferenceParser: PreferenceParser;
|
||||
|
@ -4,6 +4,9 @@ import { ResponseDescription } from '../operations/ResponseDescription';
|
||||
import { ResponseWriter } from './ResponseWriter';
|
||||
import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError';
|
||||
|
||||
/**
|
||||
* Writes to an {@link HttpResponse} based on the incoming {@link ResponseDescription} or error.
|
||||
*/
|
||||
export class SimpleResponseWriter extends ResponseWriter {
|
||||
public async canHandle(input: { response: HttpResponse; description?: ResponseDescription; error?: Error }): Promise<void> {
|
||||
if (!input.description && !input.error) {
|
||||
|
@ -2,6 +2,10 @@ import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { ResourceIdentifier } from '../representation/ResourceIdentifier';
|
||||
import { TargetExtractor } from './TargetExtractor';
|
||||
|
||||
/**
|
||||
* Extracts an identifier from an incoming {@link HttpRequest}.
|
||||
* Simply takes the input URl without any parsing/cleaning.
|
||||
*/
|
||||
export class SimpleTargetExtractor extends TargetExtractor {
|
||||
public async canHandle(input: HttpRequest): Promise<void> {
|
||||
if (!input.url) {
|
||||
|
@ -2,4 +2,7 @@ import { AsyncHandler } from '../../util/AsyncHandler';
|
||||
import { HttpRequest } from '../../server/HttpRequest';
|
||||
import { ResourceIdentifier } from '../representation/ResourceIdentifier';
|
||||
|
||||
/**
|
||||
* Extracts a {@link ResourceIdentifier} from an incoming {@link HttpRequest}.
|
||||
*/
|
||||
export abstract class TargetExtractor extends AsyncHandler<HttpRequest, ResourceIdentifier> {}
|
||||
|
@ -4,6 +4,10 @@ import { ResourceStore } from '../../storage/ResourceStore';
|
||||
import { ResponseDescription } from './ResponseDescription';
|
||||
import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError';
|
||||
|
||||
/**
|
||||
* Handles DELETE {@link Operation}s.
|
||||
* Calls the deleteResource function from a {@link ResourceStore}.
|
||||
*/
|
||||
export class SimpleDeleteOperationHandler extends OperationHandler {
|
||||
private readonly store: ResourceStore;
|
||||
|
||||
|
@ -4,6 +4,10 @@ import { ResourceStore } from '../../storage/ResourceStore';
|
||||
import { ResponseDescription } from './ResponseDescription';
|
||||
import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError';
|
||||
|
||||
/**
|
||||
* Handles GET {@link Operation}s.
|
||||
* Calls the getRepresentation function from a {@link ResourceStore}.
|
||||
*/
|
||||
export class SimpleGetOperationHandler extends OperationHandler {
|
||||
private readonly store: ResourceStore;
|
||||
|
||||
|
@ -4,6 +4,10 @@ import { ResourceStore } from '../../storage/ResourceStore';
|
||||
import { ResponseDescription } from './ResponseDescription';
|
||||
import { UnsupportedHttpError } from '../../util/errors/UnsupportedHttpError';
|
||||
|
||||
/**
|
||||
* Handles POST {@link Operation}s.
|
||||
* Calls the addResource function from a {@link ResourceStore}.
|
||||
*/
|
||||
export class SimplePostOperationHandler extends OperationHandler {
|
||||
private readonly store: ResourceStore;
|
||||
|
||||
|
@ -2,6 +2,9 @@ import { Operation } from '../operations/Operation';
|
||||
import { PermissionSet } from './PermissionSet';
|
||||
import { PermissionsExtractor } from './PermissionsExtractor';
|
||||
|
||||
/**
|
||||
* Makes some simplified assumption based on the {@link Operation} method to generate a {@link PermissionSet}.
|
||||
*/
|
||||
export class SimplePermissionsExtractor extends PermissionsExtractor {
|
||||
public async canHandle(): Promise<void> {
|
||||
return undefined;
|
||||
|
@ -1,6 +1,9 @@
|
||||
import { Representation } from './Representation';
|
||||
import { ResourceIdentifier } from './ResourceIdentifier';
|
||||
|
||||
/**
|
||||
* A {@link Representation} with an identifier.
|
||||
*/
|
||||
export interface NamedRepresentation extends Representation {
|
||||
/**
|
||||
* The identifier of this representation.
|
||||
|
@ -3,6 +3,9 @@
|
||||
*/
|
||||
import { Quad } from 'rdf-js';
|
||||
|
||||
/**
|
||||
* Metadata corresponding to a {@link Representation}.
|
||||
*/
|
||||
export interface RepresentationMetadata {
|
||||
/**
|
||||
* All metadata triples of the resource.
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { HttpError } from './HttpError';
|
||||
|
||||
/**
|
||||
* An error thrown when no data was found for the requested identifier.
|
||||
*/
|
||||
export class NotFoundHttpError extends HttpError {
|
||||
public constructor(message?: string) {
|
||||
super(404, 'NotFoundHttpError', message);
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { HttpError } from './HttpError';
|
||||
|
||||
/**
|
||||
* An error thrown when the media type of incoming data is not supported by a parser.
|
||||
*/
|
||||
export class UnsupportedMediaTypeHttpError extends HttpError {
|
||||
public constructor(message?: string) {
|
||||
super(415, 'UnsupportedHttpError', message);
|
||||
super(415, 'UnsupportedMediaTypeHttpError', message);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user