Starting to use WoT stuff to make AID better
This commit is contained in:
@@ -27,22 +27,78 @@ export type InterfaceMetadata = {
|
|||||||
events: InterfaceEvent[];
|
events: InterfaceEvent[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
So here are some changes to the original spec:
|
||||||
|
IMO it is really redundant to have so many attributes for our property in the AID.
|
||||||
|
These attributes like min and max should be set on the actual attribute, not in the AID.
|
||||||
|
The AID should only contain the information about the endpoint and the type
|
||||||
|
(because the answer from the asset needs to be casted).
|
||||||
|
The WoT spec also has way less information for the elements and their forms.
|
||||||
|
Also their forms are using all the same interface (which is a good idea).
|
||||||
|
Multiple forms (like for read and write) can be added to the same property.
|
||||||
|
|
||||||
|
And last but not least: maybe we want some kind of transformation for the data.
|
||||||
|
Like if the answer we're looking for is part of a JSON object, we can use a JSONPath to get the value.
|
||||||
|
That does not seem to be included in the WoT so maybe add it to the AID?
|
||||||
|
|
||||||
|
As the WoT currently focuses on HTTP, CoAP and MQTT, and the AID focuses on HTTP, MQTT and Modbus
|
||||||
|
we focus on HTTP and MQTT for now.
|
||||||
|
It should be pretty easy to extend this.
|
||||||
|
|
||||||
|
So let's derive some of this from the WoT and see what we can achieve.
|
||||||
|
*/
|
||||||
|
|
||||||
export type InterfaceProperty = {
|
export type InterfaceProperty = {
|
||||||
title?: string;
|
title?: string;
|
||||||
observable?: boolean;
|
observable?: boolean;
|
||||||
forms: InterfacePropertyForm;
|
forms: InterfacePropertyForm;
|
||||||
type?: string;
|
type?: string;
|
||||||
enum?: string[];
|
// enum?: string[];
|
||||||
const?: any;
|
const?: any;
|
||||||
default?: any;
|
default?: any;
|
||||||
// unit?: string;
|
// unit?: string;
|
||||||
minimum?: number; // TODO muss das gecapped werden?
|
// minimum?: number; // TODO muss das gecapped werden?
|
||||||
maximum?: number;
|
// maximum?: number;
|
||||||
minLength?: number;
|
// minLength?: number;
|
||||||
maxLength?: number;
|
// maxLength?: number;
|
||||||
// items?: any[];
|
// items?: any[];
|
||||||
minItems?: number;
|
// minItems?: number;
|
||||||
maxItems?: number;
|
// maxItems?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
type FormOp = "readproperty" |
|
||||||
|
"writeproperty" |
|
||||||
|
"observeproperty" |
|
||||||
|
"unobserveproperty" |
|
||||||
|
"invokeaction" |
|
||||||
|
"subscribeevent" |
|
||||||
|
"unsubscribeevent" |
|
||||||
|
"readallproperties" |
|
||||||
|
"writeallproperties" |
|
||||||
|
"readmultipleproperties" |
|
||||||
|
"writemultipleproperties";
|
||||||
|
|
||||||
|
type FormOpHTTP = "readproperty" |
|
||||||
|
"writeproperty" |
|
||||||
|
"invokeaction" |
|
||||||
|
"readallproperties" |
|
||||||
|
"writeallproperties" |
|
||||||
|
"readmultipleproperties" |
|
||||||
|
"writemultipleproperties";
|
||||||
|
|
||||||
|
type IForm = {
|
||||||
|
href: string;
|
||||||
|
op: FormOp;
|
||||||
|
contentType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type IFormHTTP = IForm & {
|
||||||
|
"htv:methodName": "GET" | "PUT" | "POST" | "DELETE" | "PATCH";
|
||||||
|
"htv:headers": {
|
||||||
|
"htv:fieldName": string;
|
||||||
|
"htv:fieldValue": string;
|
||||||
|
}[];
|
||||||
|
op: FormOpHTTP;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InterfacePropertyForm = InterfacePropertyFormHTTP | InterfacePropertyFormMQTT | InterfacePropertyFormModbus;
|
export type InterfacePropertyForm = InterfacePropertyFormHTTP | InterfacePropertyFormMQTT | InterfacePropertyFormModbus;
|
||||||
@@ -79,7 +135,23 @@ type InterfacePropertyFormMQTT = InterfacePropertyFormBase & {
|
|||||||
|
|
||||||
/** @alpha */
|
/** @alpha */
|
||||||
export type InterfaceAction = {
|
export type InterfaceAction = {
|
||||||
// TODO
|
title: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type InterfaceActionBase = {
|
||||||
|
title: string;
|
||||||
|
type: string;
|
||||||
|
const?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type InterfaceActionSync = {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type InterfaceActionAsync = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @alpha */
|
/** @alpha */
|
||||||
|
|||||||
Reference in New Issue
Block a user