Documentation should be done

This commit is contained in:
Daniel Kluge
2023-11-02 18:29:04 +01:00
parent 591cf6662b
commit 819a0b1a72
21 changed files with 571 additions and 29 deletions
+129
View File
@@ -15,6 +15,9 @@
},
"devDependencies": {
"@types/express": "^4.17.20",
"typedoc": "^0.25.3",
"typedoc-plugin-extras": "^3.0.0",
"typedoc-plugin-rename-defaults": "^0.7.0",
"typescript": "^5.2.2"
}
},
@@ -29,6 +32,9 @@
"devDependencies": {
"@types/node": "^20.8.2",
"@types/uuid": "^9.0.6",
"typedoc": "^0.25.3",
"typedoc-plugin-extras": "^3.0.0",
"typedoc-plugin-rename-defaults": "^0.7.0",
"typescript": "^5.2.2"
}
},
@@ -172,6 +178,12 @@
"node": ">= 0.6"
}
},
"node_modules/ansi-sequence-parser": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz",
"integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==",
"dev": true
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
@@ -317,6 +329,18 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/camelcase": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-8.0.0.tgz",
"integrity": "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==",
"dev": true,
"engines": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/commist": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/commist/-/commist-3.2.0.tgz",
@@ -837,6 +861,12 @@
"url": "https://opencollective.com/js-sdsl"
}
},
"node_modules/jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
"integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
"dev": true
},
"node_modules/lru-cache": {
"version": "7.18.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
@@ -845,6 +875,24 @@
"node": ">=12"
}
},
"node_modules/lunr": {
"version": "2.3.9",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
"dev": true
},
"node_modules/marked": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",
"integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==",
"dev": true,
"bin": {
"marked": "bin/marked.js"
},
"engines": {
"node": ">= 12"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -1188,6 +1236,18 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"node_modules/shiki": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.5.tgz",
"integrity": "sha512-1gCAYOcmCFONmErGTrS1fjzJLA7MGZmKzrBNX7apqSwhyITJg2O102uFzXUeBxNnEkDA9vHIKLyeKq0V083vIw==",
"dev": true,
"dependencies": {
"ansi-sequence-parser": "^1.1.0",
"jsonc-parser": "^3.2.0",
"vscode-oniguruma": "^1.7.0",
"vscode-textmate": "^8.0.0"
}
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
@@ -1274,6 +1334,63 @@
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
},
"node_modules/typedoc": {
"version": "0.25.3",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.3.tgz",
"integrity": "sha512-Ow8Bo7uY1Lwy7GTmphRIMEo6IOZ+yYUyrc8n5KXIZg1svpqhZSWgni2ZrDhe+wLosFS8yswowUzljTAV/3jmWw==",
"dev": true,
"dependencies": {
"lunr": "^2.3.9",
"marked": "^4.3.0",
"minimatch": "^9.0.3",
"shiki": "^0.14.1"
},
"bin": {
"typedoc": "bin/typedoc"
},
"engines": {
"node": ">= 16"
},
"peerDependencies": {
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x"
}
},
"node_modules/typedoc-plugin-extras": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/typedoc-plugin-extras/-/typedoc-plugin-extras-3.0.0.tgz",
"integrity": "sha512-eiAe3qtm2WbV5owdncpt0zHZPqsNZH2mzNGILPd4zqrvEZie3Et9es4cpGZ+8lHO/SI0pVKwsAj7IuMxPNOdYg==",
"dev": true,
"peerDependencies": {
"typedoc": "0.25.x"
}
},
"node_modules/typedoc-plugin-rename-defaults": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/typedoc-plugin-rename-defaults/-/typedoc-plugin-rename-defaults-0.7.0.tgz",
"integrity": "sha512-NudSQ1o/XLHNF9c4y7LzIZxfE9ltz09yCDklBPJpP5VMRvuBpYGIbQ0ZgmPz+EIV8vPx9Z/OyKwzp4HT2vDtfg==",
"dev": true,
"dependencies": {
"camelcase": "^8.0.0"
},
"peerDependencies": {
"typedoc": "0.22.x || 0.23.x || 0.24.x || 0.25.x"
}
},
"node_modules/typedoc/node_modules/minimatch": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz",
"integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==",
"dev": true,
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
@@ -1321,6 +1438,18 @@
"node": ">= 0.8"
}
},
"node_modules/vscode-oniguruma": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
"integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==",
"dev": true
},
"node_modules/vscode-textmate": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
"integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==",
"dev": true
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+4
View File
@@ -5,6 +5,7 @@
"main": "dist/index.js",
"scripts": {
"build": "npx tsc",
"docs": "npx typedoc",
"start": "node dist/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -31,6 +32,9 @@
"license": "ISC",
"devDependencies": {
"@types/express": "^4.17.20",
"typedoc": "^0.25.3",
"typedoc-plugin-extras": "^3.0.0",
"typedoc-plugin-rename-defaults": "^0.7.0",
"typescript": "^5.2.2"
},
"dependencies": {
+14
View File
@@ -3,6 +3,20 @@ import { MultiMessageBroker, FileImporter } from "aas-multimessagebroker";
import HTTPInterfaceServer from "./modules/httpInterfaceServer";
import MQTTConnector from "./modules/mqttConnector";
/**
* This is an example of how to use the MultiMessageBroker.
* It creates a sample interface and connector and registers them to the broker, then starts it.
*
* @remarks
* In this package a {@link HTTPInterfaceServer} is used to serve the Asset Administration Shell API interface.
* To connect to the asset a {@link MQTTConnector} was created.
* The asset is a Python script located outside of this repository which sends the current timestamp as two parameters.
* The AAS-Package is defined in the file ../owntest.json.
* It was created using the {@link https://github.com/admin-shell-io/aasx-package-explorer|aasx-package-explorer}.
*
* @packageDocumentation
*/
// First we need to import the AAS Package
// It was created using the aasx-package-explorer (https://github.com/admin-shell-io/aasx-package-explorer)
const aas = FileImporter.readAASByPath("../owntest.json");
+22 -2
View File
@@ -18,8 +18,20 @@ export type Config = {
* @see {@link aas-multimessagebroker#AbstractInterfaceServer|AbstractInterfaceServer}
*/
export default class HTTPInterfaceServer extends AbstractInterfaceServer<Config> {
public static serverInterfaceName: string = "HTTPInterfaceServer";
public static supportsSubscriptions: boolean = false; // TODO, longpolling?
/**
* Server name
* @override
* @readonly
* @alpha
*/
public static readonly serverInterfaceName: string = "HTTPInterfaceServer";
/**
* Whether the server supports subscriptions
* @override
* @readonly
* @alpha
*/
public static readonly supportsSubscriptions: boolean = false; // TODO, longpolling?
/**
* This is the {@link express#Express|express app}.
@@ -39,6 +51,8 @@ export default class HTTPInterfaceServer extends AbstractInterfaceServer<Config>
*
* @remarks
* This is called before the server is started.
* @override
* @public
*/
public prepare(): void {
this.app.use(express.json());
@@ -47,6 +61,8 @@ export default class HTTPInterfaceServer extends AbstractInterfaceServer<Config>
/**
* This should start the server.
* @override
* @public
*/
public run(): void {
this.server = this.app.listen(this.config.bindPort, this.config.bindAddress, () => {
@@ -56,6 +72,8 @@ export default class HTTPInterfaceServer extends AbstractInterfaceServer<Config>
/**
* This should stop the server.
* @override
* @public
*/
public stop(): void {
if (this.server && this.server.close) this.server.close();
@@ -63,6 +81,8 @@ export default class HTTPInterfaceServer extends AbstractInterfaceServer<Config>
/**
* This should call notify all observers
* @override
* @public
*/
public notify(event: any): void {
this.observers.forEach(observer => {
+50 -2
View File
@@ -11,9 +11,35 @@ import type { AASCoreTypes } from "aas-multimessagebroker";
* @see {@link aas-multimessagebroker#AbstractConnectionObject|AbstractConnectionObject}
*/
export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClientOptions> {
/**
* A name for your connector. Not used yet.
* @override
* @public
* @readonly
* @alpha
*/
public static readonly connectorName: string = "MQTT Connector";
/**
* The protocol(s) your connector supports. Absolutely critical so the broker knows which connector to use.
* @override
* @public
*/
public static readonly uriProtocol: string[] = ["mqtt", "mqtts"];
/**
* The type of connection your connector uses. Either "ON_DEMAND" or "PERMANENT".
* @override
* @public
* @readonly
* @alpha
*/
public static readonly connectionType: "ON_DEMAND" | "PERMANENT" = "PERMANENT";
/**
* Whether your connector supports subscriptions.
* @override
* @public
* @readonly
* @alpha
*/
public static readonly supportsSubscriptions: boolean = true;
/**
@@ -26,13 +52,15 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
*/
private readonly messageStore: Record<string, any> = {};
/**
* This should connect the Connector to the asset.
*
* @remarks For async connections like HTTP you can just return true and do the connection on demand.
* @remarks
* For async connections like HTTP you can just return true and do the connection on demand.
*
* @returns Whether the connection was successful.
* @override
* @public
*/
public connect(): boolean {
if (!this.client) this.client = mqtt.connect(this.endpointMetadata.base, this.connectionParameter);
@@ -51,6 +79,8 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
/**
* This should disconnect the Connector from the asset (if it even is connected).
* @override
* @public
*/
public disconnect(): void {
if (this.client) this.client.end();
@@ -65,6 +95,8 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
*
* @param prop Property
* @returns Value of property casted to the type it says it should be.
* @override
* @public
*/
public readProperty(prop: AASCoreTypes.Property): any {
const cc = this.mapper.get(prop);
@@ -94,6 +126,8 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
* @param prop Property
* @param value Value
* @returns Whether the write was successful.
* @override
* @public
*/
public writeProperty(prop: AASCoreTypes.Property, value: any): boolean {
const cc = this.mapper.get(prop);
@@ -112,6 +146,8 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
* @param prop Property
* @param callback Callback on change
* @returns Whether the observer was created successfully.
* @override
* @public
*/
public observeProperty(prop: AASCoreTypes.Property, callback: (value: any) => void): boolean {
const cc = this.mapper.get(prop);
@@ -130,6 +166,9 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
* @param args Arguments
*
* @returns Return value of action.
* @override
* @public
* @alpha
*/
public callActionSync(action: AASCoreTypes.Operation, args: Record<string, any>): any {
// TODO
@@ -144,6 +183,9 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
* @param args Arguments
*
* @returns Handle (uuid) for the result or null if it fails.
* @override
* @public
* @alpha
*/
public callActionAsync(action: AASCoreTypes.Operation, args: Record<string, any>): string | null {
// TODO
@@ -157,6 +199,9 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
* @param event Event
* @param callback Callback onEvent
* @returns Whether the subscription was successful.
* @override
* @public
* @alpha
*/
public subscribeEvent(event: AASCoreTypes.BasicEventElement, callback: (event: AASCoreTypes.BasicEventElement) => void): boolean {
// TODO
@@ -168,6 +213,9 @@ export default class MQTTConnector extends AbstractConnectionObject<mqtt.IClient
/**
* Unsubscribe from an event.
* @param event Event
* @override
* @public
* @alpha
*/
public unsubscribeEvent(event: AASCoreTypes.BasicEventElement): void {
// TODO
+1 -1
View File
@@ -51,7 +51,7 @@
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
+9
View File
@@ -0,0 +1,9 @@
{
"$schema": "https://typedoc.org/schema.json",
"entryPoints": ["./src/index.ts"],
"out": "docs",
"plugin": ["typedoc-plugin-extras", "typedoc-plugin-rename-defaults"],
"footerLastModified": true,
"footerTypedocVersion": true,
"customTitle": "Multimessagebroker Usage Example"
}