🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

wot-typescript-definitions

Package Overview
Dependencies
Maintainers
4
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wot-typescript-definitions - npm Package Compare versions

Comparing version

to
0.8.0-SNAPSHOT.1

151

index.d.ts

@@ -84,2 +84,14 @@ export as namespace WoT;

export declare type DataSchemaValue = any;
export declare type InteractionInput = (ReadableStream | DataSchemaValue);
export interface InteractionOutput {
data?: ReadableStream;
dataUsed: boolean;
form?: Form;
schema?: DataSchema;
arrayBuffer(): Promise<ArrayBuffer>;
value(): Promise<any>;
}
/**

@@ -89,16 +101,80 @@ * The ConsumedThing interface instance represents a client API to operate a Thing.

export interface ConsumedThing {
readProperty(propertyName: string, options?: InteractionOptions): Promise<InteractionData>;
readAllProperties(options?: InteractionOptions): Promise<PropertyValueMap>;
readMultipleProperties(propertyNames: string[], options?: InteractionOptions): Promise<PropertyValueMap>;
writeProperty(propertyName: string, value: any, options?: InteractionOptions): Promise<void>;
writeMultipleProperties(valueMap: PropertyValueMap, options?: InteractionOptions): Promise<void>;
/**
* Reads a Property value.
* Takes as arguments propertyName and optionally options.
* It returns a Promise that resolves with a Property value represented as an
* InteractionOutput object or rejects on error.
*/
readProperty(propertyName: string, options?: InteractionOptions): Promise<InteractionOutput>;
invokeAction(actionName: string, params?: any, options?: InteractionOptions): Promise<any>;
/**
* Reads all properties of the Thing with one or multiple requests.
* Takes options as optional argument.
* It returns a Promise that resolves with a PropertyMap object that
* maps keys from Property names to values.
*/
readAllProperties(options?: InteractionOptions): Promise<PropertyMap>;
/**
* Reads multiple Property values with one or multiple requests.
* Takes as arguments propertyNames and optionally options.
* It returns a Promise that resolves with a PropertyMap object that
* maps keys from propertyNames to values
*/
readMultipleProperties(propertyNames: string[], options?: InteractionOptions): Promise<PropertyMap>;
/**
* Writes a single Property.
* Takes as arguments propertyName, value and optionally options.
* It returns a Promise that resolves on success and rejects on failure.
*/
writeProperty(propertyName: string, value: InteractionInput, options?: InteractionOptions): Promise<void>;
/**
* Writes a multiple Property values with one request.
* Takes as arguments properties - as an object with keys being Property names
* and values as Property values - and optionally options.
* It returns a Promise that resolves on success and rejects on failure.
*/
writeMultipleProperties(valueMap: PropertyMap, options?: InteractionOptions): Promise<void>;
/**
* Makes a request for invoking an Action and return the result.
* Takes as arguments actionName, optionally params and optionally options.
* It returns a Promise that resolves with the result of the Action represented
* as an InteractionOutput object, or rejects with an error.
*/
invokeAction(actionName: string, params?: InteractionInput, options?: InteractionOptions): Promise<InteractionOutput>;
/**
* Makes a request for Property value change notifications.
* Takes as arguments propertyName, listener and optionally options.
* It returns a Promise that resolves on success and rejects on failure.
*/
observeProperty(name: string, listener: WotListener, options?: InteractionOptions): Promise<void>;
/**
* Makes a request for Property value change notifications.
* Takes as arguments propertyName, listener and optionally options.
* It returns a Promise that resolves on success and rejects on failure.
*/
unobserveProperty(name: string): Promise<void>;
/**
* Makes a request for subscribing to Event notifications.
* Takes as arguments eventName, listener and optionally options.
* It returns a Promise to signal success or failure.
*/
subscribeEvent(name: string, listener: WotListener, options?: InteractionOptions): Promise<void>;
/**
* Makes a request for unsubscribing from Event notifications.
* Takes as arguments eventName and optionally options.
* It returns a Promise to signal success or failure.
*/
unsubscribeEvent(name: string): Promise<void>;
/**
* Returns the the object that represents the Thing Description.
*/
getThingDescription(): ThingDescription;

@@ -110,7 +186,8 @@ }

uriVariables?: object;
data?: any;
}
export declare type PropertyValueMap = object | { [key: string]: any; };
export declare type PropertyMap = object | { [key: string]: any; };
export declare type WotListener = (data: any) => void;
export declare type WotListener = (data: InteractionOutput) => void;

@@ -160,2 +237,20 @@ export interface InteractionData {

/**
* Takes as arguments name and handler.
* Sets the service handler that defines what to do when a request is received for
* observing the specified Property matched by name.
* Throws on error.
* Returns a reference to the same object for supporting chaining.
*/
setPropertyObserveHandler(name: string, handler: PropertyReadHandler): ExposedThing;
/**
* Takes as arguments name and handler.
* Sets the service handler that defines what to do when a request is received for
* unobserving the specified Property matched by name.
* Throws on error.
* Returns a reference to the same object for supporting chaining.
*/
setPropertyUnobserveHandler(name: string, handler: PropertyReadHandler): ExposedThing;
/**
* Takes name as string argument and handler as argument of type ActionHandler.

@@ -168,3 +263,33 @@ * Sets the handler function for the specified Action matched by name.

emitEvent(name: string, data: any): void;
/**
* Takes as arguments name and handler.
* Sets the handler function that defines what to do when a subscription request
* is received for the specified Event matched by name.
* Throws on error.
* Returns a reference to the same object for supporting chaining.
*/
setEventSubscribeHandler(name: string, handler: EventSubscriptionHandler): ExposedThing;
/**
* Takes as arguments name and handler.
* Sets the handler function that defines what to do when the specified Event
* matched by name is unsubscribed from.
* Throws on error.
* Returns a reference to the same object for supporting chaining.
*/
setEventUnsubscribeHandler(name: string, handler: EventSubscriptionHandler): ExposedThing;
/**
* Takes as arguments name and eventHandler.
* Sets the event handler function for the specified Event matched by name.
* Throws on error.
* Returns a reference to the same object for supporting chaining.
*/
setEventHandler(name: string, handler: EventListenerHandler): ExposedThing;
/**
* Takes as arguments name denoting an Event name and data.
* Triggers emitting the Event with the given data.
*/
emitEvent(name: string, data: InteractionInput): void;
}

@@ -174,4 +299,8 @@

export declare type PropertyWriteHandler = (value: any, options?: InteractionOptions) => Promise<any>;
export declare type PropertyWriteHandler = (value: InteractionOutput, options?: InteractionOptions) => Promise<any>;
export declare type ActionHandler = (params: any, options?: InteractionOptions) => Promise<any>;
export declare type ActionHandler = (params: InteractionOutput, options?: InteractionOptions) => Promise<InteractionInput>;
export declare type EventSubscriptionHandler = (options?: InteractionOptions) => Promise<void>;
export declare type EventListenerHandler = () => Promise<InteractionInput>;

6

package.json
{
"name": "wot-typescript-definitions",
"version": "0.7.4-SNAPSHOT.1",
"version": "0.8.0-SNAPSHOT.1",
"description": "TypeScript definitions for the W3C WoT Scripting API",

@@ -22,5 +22,3 @@ "author": "W3C Web of Things Working Group",

"types": "index.d.ts",
"dependencies": {
"rxjs": "5.4.3"
},
"dependencies": {},
"scripts": {

@@ -27,0 +25,0 @@ "test": "echo \"Error: no test specified\" && exit 1"