wot-typescript-definitions
Advanced tools
Comparing version
107
index.d.ts
@@ -75,12 +75,9 @@ export as namespace WoT; | ||
/** The ThingTemplate dictionary contains properties to initialize a Thing */ | ||
export interface ThingTemplate { | ||
/** The name attribute represents the user given name of the Thing */ | ||
name: string; | ||
/** additional @types to "Thing" */ | ||
semanticTypes?: SemanticType[]; | ||
/** metadata fields in TD root (same level as 'name') */ | ||
metadata?: SemanticMetadata[]; | ||
/** A dictionary that provides the semantic types and semantic metadata. */ | ||
export interface SemanticAnnotations { | ||
semanticTypes?: [SemanticType]; | ||
metadata?: [SemanticMetadata]; | ||
} | ||
/** Represents a semantic type annotation, containing a name and a context. */ | ||
@@ -102,2 +99,10 @@ export interface SemanticType { | ||
/** The ThingTemplate dictionary contains properties to initialize a Thing */ | ||
export interface ThingTemplate extends SemanticAnnotations { | ||
/** The name attribute represents the user given name of the Thing */ | ||
name: string; | ||
} | ||
/** The ConsumedThing interface is a client API for sending requests to servers in order to retrieve or update properties, invoke Actions, and observe properties, Actions and Events. */ | ||
@@ -143,12 +148,15 @@ export interface ConsumedThing { | ||
*/ | ||
export declare type ValueType = USVString; | ||
export declare type DataSchema = USVString; | ||
// FIXME all XyzInit classes get changed to Xyz | ||
/** Represents the Thing Property description. */ | ||
export interface ThingPropertyInit { | ||
export interface ThingPropertyInit extends SemanticAnnotations { | ||
/** The name attribute provides the Property name. */ | ||
name: string; | ||
/** The type attribute provides the description of the data. */ | ||
type: ValueType; | ||
type: DataSchema; | ||
/** The intial value. */ | ||
initValue: any; | ||
value: any; | ||
/** Indicates whether property is writable. */ | ||
@@ -158,40 +166,30 @@ writable?: boolean; // = false; | ||
observable?: boolean; // = false; | ||
/** Semantic types (additional @types to "Property"). */ | ||
semanticTypes?: [SemanticType]; | ||
/** metadata fields in Property root (same level as 'name') */ | ||
metadata?: SemanticMetadata[]; | ||
/** On read callback */ | ||
onRead?(oldValue: any): Promise<any>; | ||
/** On write callback */ | ||
onWrite?(oldValue: any, newValue: any): void; | ||
// /** On read callback */ | ||
// onRead?(oldValue: any): Promise<any>; | ||
// /** On write callback */ | ||
// onWrite?(oldValue: any, newValue: any): void; | ||
} | ||
/** The ThingActionInit dictionary describes the arguments and the return value. */ | ||
export interface ThingActionInit { | ||
export interface ThingActionInit extends SemanticAnnotations { | ||
/** The name attribute provides the Action name. */ | ||
name: string; | ||
/** The inputTypes attribute provides the description of the input arguments. */ | ||
inputType: ValueType; | ||
/** The outputType attribute provides the description of the returned data. */ | ||
outputType: ValueType; | ||
/** The action attribute provides a function that defines the Action. */ | ||
action: Function; | ||
/** The semanticTypes attribute provides a list of semantic type annotations (e.g. labels, classifications etc) relevant to the Action, represented as SemanticType dictionaries. */ | ||
semanticTypes?: [SemanticType]; | ||
/** metadata fields in Action root (same level as 'name') */ | ||
metadata?: SemanticMetadata[]; | ||
/** The inputDataDescription attribute provides the description of the input arguments (argument list is represented by an object). If missing, it means the action does not accept arguments. */ | ||
inputDataDescription?: DataSchema; | ||
/** The outputDataDescription attribute provides the description of the returned data. If missing, it means the action does not return data. */ | ||
outputDataDescription?: DataSchema; | ||
// /** The action attribute provides a function that defines the Action. */ | ||
// action: Function; | ||
} | ||
export interface ThingEventInit { | ||
export interface ThingEventInit extends SemanticAnnotations { | ||
/** The name attribute represents the event name. */ | ||
name: string; | ||
/** The type attribute provides the description of the data. */ | ||
type: ValueType; | ||
/** The semanticTypes attribute represent a list of semantic type annotations attached to the event. */ | ||
semanticTypes?: [SemanticType]; | ||
/** metadata fields in Event root (same level as 'name') */ | ||
metadata?: SemanticMetadata[]; | ||
dataDescription?: DataSchema; | ||
} | ||
export interface ExposedThing extends ConsumedThing { | ||
// define how to expose and run the Thing | ||
@@ -214,4 +212,4 @@ /** Start serving external requests for the Thing. */ | ||
// define Thing Description modifiers | ||
/** | ||
@@ -246,2 +244,35 @@ * Adds a Property defined by the argument and updates the Thing Description | ||
removeEvent(eventName: string): ExposedThing | ||
// define request handlers | ||
/** | ||
* Takes a actionName as an optional string argument, and an action argument of type ActionHandler. Sets the handler function for the specified Action matched by actionName if actionName is specified, otherwise sets it for any action. Throws on error. Returns a reference to the same object for supporting chaining. | ||
* | ||
* @param action | ||
* @param actionName | ||
*/ | ||
setActionHandler(action: ActionHandler, actionName? : string) : ExposedThing; | ||
/** | ||
* Takes a propertyName as an optional string argument, and a readHandler argument of type PropertyReadHandler. Sets the handler function for reading the specified Property matched by propertyName if propertyName is specified, otherwise sets it for reading any property. Throws on error. Returns a reference to the same object for supporting chaining. | ||
* | ||
* @param readHandler | ||
* @param propertyName | ||
*/ | ||
setPropertyReadHandler(readHandler: PropertyReadHandler, propertyName? : string) : ExposedThing; | ||
/** | ||
* Takes a propertyName as an optional string argument, and a writeHandler argument of type PropertyWriteHandler. Sets the handler function for writing the specified Property matched by propertyName if the propertyName is specified, otherwise sets it for writing any properties. Throws on error. Returns a reference to the same object for supporting chaining. | ||
* | ||
* @param write | ||
* @param propertyName | ||
*/ | ||
setPropertyWriteHandler(writeHandler: PropertyWriteHandler, propertyName? : string) : ExposedThing; | ||
} | ||
export declare type ActionHandler = (parameters: any) => Promise<any>; | ||
export declare type PropertyReadHandler = () => Promise<any>; | ||
export declare type PropertyWriteHandler = (value: any) => Promise<void>; |
{ | ||
"name": "wot-typescript-definitions", | ||
"version": "0.4.0-SNAPSHOT.9", | ||
"version": "0.4.0-SNAPSHOT.10", | ||
"description": "Typescript definitions for the WoT scripting API", | ||
@@ -5,0 +5,0 @@ "main": "index.d.ts", |
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
14282
12.32%230
9%