refactor: split api into api, api-cli & api-plugin

This commit is contained in:
2023-06-02 16:41:25 +02:00
parent 495a63977c
commit b21833de40
205 changed files with 1981 additions and 1492 deletions

View File

@@ -15,7 +15,6 @@
/**
* A generic error that can be returned by the backend if somethings fails during the processing of a request
*
* @validatable
*/
export interface SCErrorResponse extends Error {
@@ -41,7 +40,6 @@ export abstract class SCError implements SCErrorResponse {
/**
* Instatiate an SCError
*
* @param name Name of the error
* @param message Message of the error
* @param statusCode HTTP status code to return this error with

View File

@@ -17,7 +17,6 @@ import {SCError} from '../error.js';
/**
* An error that is returned, when an internal server error occurred
*
* @validatable
*/
export class SCInternalServerErrorResponse extends SCError {
@@ -28,7 +27,6 @@ export class SCInternalServerErrorResponse extends SCError {
/**
* Create a SCInternalServerErrorResponse
*
* @param error Internal server error
* @param stack Set to true if a stack trace should be created
* and the internal server error should be displayed to the client

View File

@@ -17,13 +17,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned, when the used HTTP method is not allowed on the requested route
*
* @validatable
*/
export class SCMethodNotAllowedErrorResponse extends SCError {
/**
* Create a SCMethodNotAllowedErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {

View File

@@ -17,13 +17,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned when the requested route or resource was not found
*
* @validatable
*/
export class SCNotFoundErrorResponse extends SCError {
/**
* Create a SCNotFoundErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {

View File

@@ -18,13 +18,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned when the request is in the right format, but contains parameters that are invalid or not
* acceptable.
*
* @validatable
*/
export class SCParametersNotAcceptable extends SCError {
/**
* Create a ParametersNotAcceptable
*
* @param message contains more details to what you did wrong
* @param stack Set to true if a stack trace should be created
*/

View File

@@ -20,7 +20,6 @@ import {SCPluginMetaData} from '../routes/plugin-register.js';
* An error that is returned when a plugin with the same name is already registered, to prevent two copies of a plugin
* running at the same time.
* This usually indicates that there is more than one instance a plugin running.
*
* @validatable
*/
export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
@@ -32,7 +31,6 @@ export class SCPluginAlreadyRegisteredErrorResponse extends SCError {
/**
* Create a SCPluginAlreadyRegisteredError
*
* @param message Provide further information why an already registered plugin matches the one we want to register
* @param plugin Provides meta data of a registered plugin, which is in a conflict with the plugin we want to register
* @param stack Set to true if a stack trace should be created

View File

@@ -17,13 +17,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned whenever there is an unexpected error while creating a plugin
*
* @validatable
*/
export class SCPluginRegisteringFailedErrorResponse extends SCError {
/**
* Create a PluginRegisteringFailedError
*
* @param message Describes what went wrong wile registering the plugin
* @param stack Set to true if a stack trace should be created
*/

View File

@@ -17,13 +17,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned, when the request body is too large.
*
* @validatable
*/
export class SCRequestBodyTooLargeErrorResponse extends SCError {
/**
* Create a SCRequestBodyTooLargeErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {

View File

@@ -17,13 +17,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned whenever there is a syntax error
*
* @validatable
*/
export class SCSyntaxErrorResponse extends SCError {
/**
* Create a SyntaxError
*
* @param message Describes the syntax error
* @param stack Set to true if a stack trace should be created
*/

View File

@@ -17,13 +17,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned, when to many request are submitted at once
*
* @validatable
*/
export class SCTooManyRequestsErrorResponse extends SCError {
/**
* Create a SCTooManyRequestsErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {

View File

@@ -17,13 +17,11 @@ import {SCError} from '../error.js';
/**
* An error that is returned when the content type of the request is not supported
*
* @validatable
*/
export class SCUnsupportedMediaTypeErrorResponse extends SCError {
/**
* Create a SCUnsupportedMediaTypeErrorResponse
*
* @param stack Set to true if a stack trace should be created
*/
constructor(stack?: boolean) {

View File

@@ -18,7 +18,6 @@ import {SCError} from '../error.js';
/**
* An error that is returned when the validation of a request fails
*
* @validatable
*/
export class SCValidationErrorResponse extends SCError {
@@ -29,7 +28,6 @@ export class SCValidationErrorResponse extends SCError {
/**
* Create a SCValidationErrorResponse
*
* @param errors List of validation errors
* @param stack Set to true if a stack trace should be created
*/

View File

@@ -125,7 +125,6 @@ export abstract class SCAbstractRoute implements SCRoute {
/**
* Get "compiled" URL path
*
* @param parameters Parameters to compile URL path with
*/
public getUrlPath(parameters: SCMap<string> = {}): string {

View File

@@ -29,7 +29,6 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
/**
* Request to check the availability of books
*
* @validatable
*/
export type SCBookAvailabilityRequest = SCBookAvailabilityRequestByIsbn | SCBookAvailabilityRequestByUuid;
@@ -56,7 +55,6 @@ export interface SCBookAvailabilityRequestByUuid {
/**
* List of availabilities of a book
*
* @validatable
*/
export type SCBookAvailabilityResponse = Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;

View File

@@ -25,14 +25,12 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
/**
* Request to add a thing to a bulk
*
* @validatable
*/
export type SCBulkAddRequest = SCThings;
/**
* Response to a request to add a thing to a bulk
*
* @validatable
*/
export interface SCBulkAddResponse {}

View File

@@ -24,14 +24,12 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
/**
* Request to change the bulk state to done (close the bulk process)
*
* @validatable
*/
export interface SCBulkDoneRequest {}
/**
* Response to a request to change the state of a bulk to done
*
* @validatable
*/
export interface SCBulkDoneResponse {}

View File

@@ -28,7 +28,6 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
* A bulk request
*
* Parameters to be sent to request a new bulk.
*
* @validatable
*/
export type SCBulkRequest = SCBulkParameters;
@@ -62,7 +61,6 @@ export interface SCBulkParameters {
/**
* Requested Bulk from backend
*
* @validatable
*/
export interface SCBulkResponse extends SCBulkParameters {

View File

@@ -24,7 +24,6 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
/**
* User feedback
*
* @validatable
*/
export interface SCFeedbackRequest extends SCMessage {
@@ -36,7 +35,6 @@ export interface SCFeedbackRequest extends SCMessage {
/**
* A response to a feedback request
*
* @validatable
*/
export interface SCFeedbackResponse {}

View File

@@ -26,14 +26,12 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
/**
* Index request
*
* @validatable
*/
export interface SCIndexRequest {}
/**
* A response to an index request
*
* @validatable
*/
export interface SCIndexResponse {

View File

@@ -26,7 +26,6 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
/**
* Plugin register request
*
* @validatable
*/
export type SCPluginRegisterRequest = SCPluginAdd | SCPluginRemove;
@@ -93,7 +92,6 @@ export interface SCPluginMetaData {
/**
* Plugin register response
*
* @validatable
*/
export interface SCPluginRegisterResponse {

View File

@@ -27,7 +27,6 @@ import {SCValidationErrorResponse} from '../errors/validation.js';
* User rating from the app
* Plugin needs to define its own rating request to hit the target rating system.
* That request should extend this one and contain timestamp and other needed data.
*
* @validatable
*/
export interface SCRatingRequest {
@@ -49,7 +48,6 @@ export interface SCRatingRequest {
/**
* A response to a rating request
*
* @validatable
*/
export interface SCRatingResponse {}

View File

@@ -31,7 +31,6 @@ import {SCSearchResult} from '../search/result.js';
* This is a map of [[SCSearchRequest]]s indexed by name.
*
* **CAUTION: This is limited to an amount of queries. Currently this limit is 5.**
*
* @validatable
*/
export type SCMultiSearchRequest = SCMap<SCSearchQuery>;
@@ -40,7 +39,6 @@ export type SCMultiSearchRequest = SCMap<SCSearchQuery>;
* A multi search response
*
* This is a map of [[SCSearchResponse]]s indexed by name
*
* @validatable
*/
export type SCMultiSearchResponse = SCMap<SCSearchResult>;

View File

@@ -25,14 +25,12 @@ import {SCSearchResult} from '../search/result.js';
/**
* A search request
*
* @validatable
*/
export type SCSearchRequest = SCSearchQuery;
/**
* A search response
*
* @validatable
*/
export type SCSearchResponse = SCSearchResult;

View File

@@ -25,14 +25,12 @@ import {SCAbstractRoute, SCRouteHttpVerbs} from '../route.js';
/**
* Request to update an existing thing
*
* @validatable
*/
export type SCThingUpdateRequest = SCThings;
/**
* Response for an entity update request
*
* @validatable
*/
export interface SCThingUpdateResponse {}

View File

@@ -19,7 +19,6 @@ import {SCSearchAbstractFilter, SCSearchAbstractFilterArguments} from '../filter
* A date range filter
*
* Filter for documents with a date field that satisfies the given constraints
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_date_format_in_range_queries
*/
export interface SCSearchDateRangeFilter extends SCSearchAbstractFilter<SCDateRangeFilterArguments> {
@@ -33,7 +32,6 @@ export interface SCSearchDateRangeFilter extends SCSearchAbstractFilter<SCDateRa
* A distance filter
*
* Filter for documents with a numeric field that satisfies the given constraints
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#query-dsl-range-query
*/
export interface SCSearchNumericRangeFilter extends SCSearchAbstractFilter<SCNumericRangeFilterArguments> {
@@ -47,20 +45,17 @@ export interface SCSearchNumericRangeFilter extends SCSearchAbstractFilter<SCNum
* Additional arguments for date range filters
*
* Filter uses a plain string to allow for date math expressions
*
* @see https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/date-math-expressions.html
*/
export interface SCDateRangeFilterArguments extends SCRangeFilterArguments<string> {
/**
* Optional date format specifier
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_date_format_in_range_queries
*/
format?: string;
/**
* Optional timezone specifier
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#_time_zone_in_range_queries
*/
timeZone?: string;
@@ -73,7 +68,6 @@ export type SCNumericRangeFilterArguments = SCRangeFilterArguments<number>;
/**
* Additional arguments for range filters
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-range-query.html#query-dsl-range-query
*/
export interface SCRangeFilterArguments<T> extends SCSearchAbstractFilterArguments {