mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: support inrupt coding standards
This commit is contained in:
8
src/ldp/http/BinaryRepresentation.ts
Normal file
8
src/ldp/http/BinaryRepresentation.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Representation } from './Representation';
|
||||
|
||||
/**
|
||||
* A representation containing binary data.
|
||||
*/
|
||||
export interface BinaryRepresentation extends Representation {
|
||||
dataType: 'binary';
|
||||
}
|
||||
9
src/ldp/http/NamedRepresentation.ts
Normal file
9
src/ldp/http/NamedRepresentation.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Representation } from './Representation';
|
||||
import { ResourceIdentifier } from './ResourceIdentifier';
|
||||
|
||||
export interface NamedRepresentation extends Representation {
|
||||
/**
|
||||
* The identifier of this representation.
|
||||
*/
|
||||
identifier?: ResourceIdentifier;
|
||||
}
|
||||
4
src/ldp/http/Patch.ts
Normal file
4
src/ldp/http/Patch.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Represents the changes needed for a PATCH request.
|
||||
*/
|
||||
export interface Patch {}
|
||||
8
src/ldp/http/QuadRepresentation.ts
Normal file
8
src/ldp/http/QuadRepresentation.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Representation } from './Representation';
|
||||
|
||||
/**
|
||||
* A representation containing quads as data.
|
||||
*/
|
||||
export interface QuadRepresentation extends Representation {
|
||||
dataType: 'quad';
|
||||
}
|
||||
20
src/ldp/http/Representation.ts
Normal file
20
src/ldp/http/Representation.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Readable } from 'stream';
|
||||
import { RepresentationMetadata } from './RepresentationMetadata';
|
||||
|
||||
/**
|
||||
* A representation of a resource.
|
||||
*/
|
||||
export interface Representation {
|
||||
/**
|
||||
* The corresponding metadata.
|
||||
*/
|
||||
metadata: RepresentationMetadata;
|
||||
/**
|
||||
* The raw data stream for this representation.
|
||||
*/
|
||||
data: Readable;
|
||||
/**
|
||||
* The data type of the contents in the data stream.
|
||||
*/
|
||||
dataType: string;
|
||||
}
|
||||
35
src/ldp/http/RepresentationMetadata.ts
Normal file
35
src/ldp/http/RepresentationMetadata.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Contains metadata relevant to a representation.
|
||||
*/
|
||||
import { Quad } from 'rdf-js';
|
||||
|
||||
export interface RepresentationMetadata {
|
||||
/**
|
||||
* All metadata triples of the resource.
|
||||
*/
|
||||
raw: Quad[];
|
||||
/**
|
||||
* The metadata profiles.
|
||||
*/
|
||||
profiles: string[];
|
||||
/**
|
||||
* Optional size of the representation.
|
||||
*/
|
||||
byteSize?: number;
|
||||
/**
|
||||
* Optional content type of the representation.
|
||||
*/
|
||||
contentType?: string;
|
||||
/**
|
||||
* Optional encoding of the representation.
|
||||
*/
|
||||
encoding?: string;
|
||||
/**
|
||||
* Optional language of the representation.
|
||||
*/
|
||||
language?: string;
|
||||
/**
|
||||
* Optional timestamp of the representation.
|
||||
*/
|
||||
dateTime?: Date;
|
||||
}
|
||||
4
src/ldp/http/RepresentationPreferences.ts
Normal file
4
src/ldp/http/RepresentationPreferences.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Contains the preferences of which kind of representation is requested.
|
||||
*/
|
||||
export interface RepresentationPreferences {}
|
||||
4
src/ldp/http/ResourceIdentifier.ts
Normal file
4
src/ldp/http/ResourceIdentifier.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* The unique identifier of a resource.
|
||||
*/
|
||||
export interface ResourceIdentifier {}
|
||||
25
src/ldp/operations/Operation.ts
Normal file
25
src/ldp/operations/Operation.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Representation } from '../http/Representation';
|
||||
import { RepresentationPreferences } from '../http/RepresentationPreferences';
|
||||
import { ResourceIdentifier } from '../http/ResourceIdentifier';
|
||||
|
||||
/**
|
||||
* A single REST operation.
|
||||
*/
|
||||
export interface Operation {
|
||||
/**
|
||||
* The HTTP method (GET/POST/PUT/PATCH/DELETE/etc.).
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Identifier of the target.
|
||||
*/
|
||||
target: ResourceIdentifier;
|
||||
/**
|
||||
* Representation preferences of the response. Will be empty if there are none.
|
||||
*/
|
||||
preferences: RepresentationPreferences;
|
||||
/**
|
||||
* Optional representation of the body.
|
||||
*/
|
||||
body?: Representation;
|
||||
}
|
||||
21
src/ldp/operations/OperationHandler.ts
Normal file
21
src/ldp/operations/OperationHandler.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Operation } from './Operation';
|
||||
|
||||
/**
|
||||
* Handler for a specific operation type.
|
||||
*/
|
||||
export interface OperationHandler {
|
||||
/**
|
||||
* Checks if the handler supports the given operation.
|
||||
* @param operation - The input operation.
|
||||
*
|
||||
* @returns A promise resolving to a boolean indicating if this handler supports the operation.
|
||||
*/
|
||||
canHandle: (operation: Operation) => Promise<boolean>;
|
||||
/**
|
||||
* Handles the given operation.
|
||||
* @param operation - The input operation.
|
||||
*
|
||||
* @returns A promise resolving when the operation is handled.
|
||||
*/
|
||||
handle: (operation: Operation) => Promise<void>;
|
||||
}
|
||||
Reference in New Issue
Block a user