diff --git a/index.html b/index.html index b0b2ee8..d8fe179 100644 --- a/index.html +++ b/index.html @@ -1275,7 +1275,70 @@

The InteractionOutput interface

-

Using {{InteractionInput}} and {{InteractionOutput}}

+ +
+

The ActionInteractionOutput interface

+

+ Belongs to the WoT Consumer conformance class. + An {{ActionInteractionOutput}} object is always created by a consumer implementation + and exposes functionality to interact with long running (asynchronous) actions.
+ Note: a synchronous action MAY not offer any additional sensible interaction beyond the ones from {{InteractionOutput}}. +

+

+ This interface exposes an action status object. Its implementation + will allow cancelling asynchronous actions and report the status of a long running action. +

+
+      enum ActionStatus {
+        "running",
+        "success",
+        "error"
+      };
+      
+      [SecureContext, Exposed=(Window,Worker)]
+      interface ActionInteractionOutput : InteractionOutput {
+        readonly attribute object? error;
+        Promise<ActionStatus> status();
+        Promise<undefined> cancel();
+      };
+    
+

+ The error property represents a possible error, initially `null`. +

+

+ +

+

+ Should we allow pause/resume also? TD has no notion of it. +

+

The status() function

+ Reports the status of an Action (one of running, success or error) or rejects on error. The method MUST run the following steps: +
    +
  1. + Return a {{Promise}} |promise:Promise| and execute the next steps + [=in parallel=]. +
  2. +
  3. + TODO +
  4. +
+
+

The cancel() function

+ Cancels a running WoT Action or rejects on error. The method MUST run the following steps: +
    +
  1. + Return a {{Promise}} |promise:Promise| and execute the next steps + [=in parallel=]. +
  2. +
  3. + TODO ... applicable when the state is running +
  4. +
+
+ +
+ +

Using {{InteractionInput}}, {{InteractionOutput}} and {{ActionInteractionOutput}}

As illustrated in the next pictures, the {{InteractionOutput}} interface is used every time implementations provide data to scripts, while @@ -1323,7 +1386,7 @@

The InteractionOutput interface

When a {{ConsumedThing}} invokes an Action, it provides the parameters as {{InteractionInput}} and receives the output of the - Action as an {{InteractionOutput}} object. + Action as an {{ActionInteractionOutput}} object.

An {{ExposedThing}} @@ -1386,7 +1449,7 @@

The ConsumedThing interface

/*Promise<undefined> writeAllProperties( PropertyWriteMap valueMap, optional InteractionOptions options = {});*/ - Promise<InteractionOutput> invokeAction(DOMString actionName, + Promise<ActionInteractionOutput> invokeAction(DOMString actionName, optional InteractionInput params = {}, optional InteractionOptions options = {}); Promise<Subscription> observeProperty(DOMString name, diff --git a/typescript/scripting-api/index.d.ts b/typescript/scripting-api/index.d.ts index 06a3fad..8d0e9d6 100644 --- a/typescript/scripting-api/index.d.ts +++ b/typescript/scripting-api/index.d.ts @@ -88,6 +88,14 @@ declare namespace WoT { value(): Promise; } + export enum ActionStatus { "running", "success", "error" } + + export interface ActionInteractionOutput extends InteractionOutput { + error?: Error; + status(): Promise + cancel(): Promise + } + export interface Subscription { active:boolean, stop(options?: InteractionOptions):Promise @@ -140,9 +148,9 @@ declare namespace WoT { * 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. + * as an ActionInteractionOutput object, or rejects with an error. */ - invokeAction(actionName: string, params?: InteractionInput, options?: InteractionOptions): Promise; + invokeAction(actionName: string, params?: InteractionInput, options?: InteractionOptions): Promise; /** * Makes a request for Property value change notifications.