adding comments

This commit is contained in:
Martin Karkowski 2022-01-19 08:25:23 +01:00
parent ba9f7e5c17
commit 469e6601ba
2 changed files with 123 additions and 1 deletions

View File

@ -1,9 +1,11 @@
/** /**
* @module communication
* @author Martin Karkowski * @author Martin Karkowski
* @email m.karkowski@zema.de * @email m.karkowski@zema.de
* @create date 2021-08-04 15:30:10 * @create date 2021-08-04 15:30:10
* @modify date 2022-01-10 16:01:15 * @modify date 2022-01-10 16:01:15
* @desc [description] * @desc [description]
*
*/ */
export { Bridge } from "./bridge"; export { Bridge } from "./bridge";

View File

@ -6,6 +6,9 @@
* @desc [description] * @desc [description]
*/ */
/**
* Valid Descriptor types
*/
export type INopeDescriptorSchemaBaseTypes = export type INopeDescriptorSchemaBaseTypes =
| "string" | "string"
| "number" | "number"
@ -15,13 +18,77 @@ export type INopeDescriptorSchemaBaseTypes =
| "boolean" | "boolean"
| "null" | "null"
| "function"; | "function";
/**
* A (JSON-Schema and) Nope-Descriptor allows to use multiple types.
* Therefore this type uses some additonal types. Alternativly, a reference
* **`$ref`** can be used to describe some data. Therefore the schema
* must be availalbe on the reference.
*/
export type INopeDescriptorSchemaTypes = export type INopeDescriptorSchemaTypes =
| INopeDescriptorSchemaBaseTypes | INopeDescriptorSchemaBaseTypes
| Array<INopeDescriptorSchemaBaseTypes> | Array<INopeDescriptorSchemaBaseTypes>
| { $ref: string }; | { $ref: string };
/** /**
* Generic Descriptor of an Version. * # INopeDescriptor
*
* A generic descriptor of data or a function. This descriptors will be used to describe `NoPE` data-points or functions. The Descriptor is based on **JSON-Schemas** (see [here](https://json-schema.org/) for more details).
*
*
* ## Describing data
*
* A valid example - *describing some data* - is given below (in the form of `JSON`-data). This example matches a **JSON-Schema**: *
*
* ```json
* {
* "title": "Person",
* "type": "object",
* "properties": {
* "firstName": {
* "type": "string",
* "description": "The person's first name."
* },
* "lastName": {
* "type": "string",
* "description": "The person's last name."
* },
* "age": {
* "description": "Age in years which must be equal to or greater than zero.",
* "type": "integer",
* "minimum": 0
* }
* }
* }
* ```
* ## Describing functions
*
* A valid example - *describing a function* - is given below (in the form of `JSON`-data):
*
* ```json
* {
* "type": "function",
* "description": "A Sample Function",
* "inputs": [
* {
* "name": "parameter_01",
* "description": "The first Parameter of the Function",
* "schema": {
* "type":"string",
* "maxLength": 10
* }
* },
* {
* "name": "parameter_02",
* "description": "The second Parameter of the Function. This is optional",
* "optional": true,
* "schema": {
* "type":"boolean"
* }
* }
* ]
* }
* ```
* *
* @export * @export
* @interface INopeDescriptor * @interface INopeDescriptor
@ -89,8 +156,16 @@ export interface INopeDescriptor {
// String Validation // String Validation
///////////////////////////////////////////////// /////////////////////////////////////////////////
/**
* Max length of the string.
*/
maxLength?: number; maxLength?: number;
/**
* Min length of the string.
*/
minLength?: number; minLength?: number;
/** /**
* This is a regex string that the value must * This is a regex string that the value must
* conform to * conform to
@ -102,8 +177,20 @@ export interface INopeDescriptor {
///////////////////////////////////////////////// /////////////////////////////////////////////////
additionalItems?: boolean | INopeDescriptor; additionalItems?: boolean | INopeDescriptor;
items?: INopeDescriptor | INopeDescriptor[]; items?: INopeDescriptor | INopeDescriptor[];
/**
* max. amount of items, the array is allwoed to contain.
*/
maxItems?: number; maxItems?: number;
/**
* min. amount of items, the array must contain.
*/
minItems?: number; minItems?: number;
/**
* Flag, to define, that every item in the array must be unique.
*/
uniqueItems?: boolean; uniqueItems?: boolean;
///////////////////////////////////////////////// /////////////////////////////////////////////////
@ -181,14 +268,47 @@ export interface INopeDescriptor {
*/ */
not?: INopeDescriptor; not?: INopeDescriptor;
/**
* Data-Field, which must be filled out, if we are describing a function. This will describe the entire data of the inputs.
*/
inputs?: Array<INopeDescriptorFunctionParameter>; inputs?: Array<INopeDescriptorFunctionParameter>;
/**
* The Return (output) of a function. This must be provided if the type is set to ***function*** {@link INopeDescriptor.type}
*/
outputs?: Array<INopeDescriptorFunctionParameter> | INopeDescriptor; outputs?: Array<INopeDescriptorFunctionParameter> | INopeDescriptor;
} }
/**
* Helper, to describe a Function Parameter
*/
export interface INopeDescriptorFunctionParameter { export interface INopeDescriptorFunctionParameter {
/**
* Name, which is used in the function header
*
* @type {string}
* @memberof INopeDescriptorFunctionParameter
*/
name: string; name: string;
/**
* Description of the parameter. Similar to a comment, describing a parameter
*
* @type {string}
* @memberof INopeDescriptorFunctionParameter
*/
description?: string; description?: string;
/**
* Flag, showing whether the parameter is *optional* or not.
*
* @type {boolean}
* @memberof INopeDescriptorFunctionParameter
*/
optional?: boolean; optional?: boolean;
/**
* The Schema used to describe the parameter. see {@link INopeDescriptor}
*
* @type {INopeDescriptor}
* @memberof INopeDescriptorFunctionParameter
*/
schema: INopeDescriptor; schema: INopeDescriptor;
} }