refactor: add plugin meta data interface

Closes #67
This commit is contained in:
Jovan Krunić
2019-05-16 15:22:57 +02:00
parent bac09ffebc
commit bff6079f60

View File

@@ -29,40 +29,27 @@ import {
*
* @validatable
*/
export type SCPluginRegisterRequest = AddPlugin | RemovePlugin;
interface AddPlugin {
export type SCPluginRegisterRequest = SCPluginAdd | SCPluginRemove;
/**
* Plugin request for adding a plugin registration to the backend
*/
export interface SCPluginAdd {
/**
* The desired action, so whether the plugin should be added or removed
*/
action: 'add';
/**
* The address of the plugin
* Plugin information needed for its registration
*/
address: string;
/**
* The name of the plugin
* Just for debugging purposes, to more easily identify conflicts.
*/
name: string;
/**
* How the requests of the plugin looks like, a JSON schema for validation
*/
pluginRequestSchema: Schema;
/**
* How the responses of the plugin looks like, a JSON schema for validation
*/
pluginResponseSchema: Schema;
/**
* The desired route, for example /feedback.
*/
route: string;
plugin: SCPluginMetaData;
}
interface RemovePlugin {
/**
* Plugin request for removing a plugin registration from the backend
*/
export interface SCPluginRemove {
/**
* The desired action, so whether the plugin should be added or removed
*/
@@ -74,6 +61,36 @@ interface RemovePlugin {
route: string;
}
/**
* Plugin meta data - contains needed information for a plugin registration
*/
export interface SCPluginMetaData {
/**
* The address of the plugin, to which the backend routes the requests
*/
address: string;
/**
* The name of the plugin (for debugging purposes, to more easily identify conflicts)
*/
name: string;
/**
* How the requests of the plugin looks like, a JSON schema for validation
*/
requestSchema: Schema;
/**
* How the responses of the plugin looks like, a JSON schema for validation
*/
responseSchema: Schema;
/**
* The desired route, for example /feedback.
*/
route: string;
}
/**
* Route to register plugins
*/
@@ -85,7 +102,6 @@ export class SCPluginRegisterRoute extends SCAbstractRoute {
SCMethodNotAllowedErrorResponse,
SCParametersNotAcceptable,
SCPluginAlreadyRegisteredErrorResponse,
SCPluginRouteAlreadyRegisteredErrorResponse,
SCPluginRegisteringFailedErrorResponse,
SCPluginRouteAlreadyRegisteredErrorResponse,
SCRequestBodyTooLargeErrorResponse,