This reference guide lists all the available methods for accessing nodes while developing assertions.
All assertion models start with a step. A step
is a global object that forms the basis of an assertion model, and allows you to access execution data from your capsule through your story.
A step
object has the following properties:
Property | Type | Value |
---|---|---|
currentNode | object | A PlanNode that points to the node your step is currently on in the execution graph. |
dialogs | array | One or more Dialog elements. |
isInterrupted | boolean | true if an action in your step is interrupted. |
PlanNode
objects are the main class of nodes you will be using to traverse through the execution graph with your assertions. A PlanNode
has a number of interface definitions and methods you can use to access other nodes and edges in the execution graph, as well as the metadata of that node.
A PlanNode
object has the following properties:
Property | Type | Value |
---|---|---|
capsuleId | string | Capsule ID of the PlanNode , including the organization namespace. |
capsuleVersion | string | Capsule version of the PlanNode . |
dialogs | array | Dialog elements executed by the PlanNode . |
functions | array | Function elements executed by the PlanNode . |
incomingEdges | array | Edges (PlanEdge ) entering the PlanNode . For example, if PlanNode is an action, PlanEdge[] would contain inputs for that action. |
isGoal | boolean | true if the PlanNode is the goal. |
isRecoveryGoal | boolean | true if the PlanNode is a recovery goal. |
layouts | array | Layout elements called by the PlanNode . |
outgoingEdges | array | Edges (PlanEdge ) leaving the PlanNode . For example, if PlanNode is an action, PlanEdge[] would contain outputs for that action. |
predecessors | array | PlanNode elements that are parents of the current PlanNode . |
qualifiedType | string | Qualified type of the PlanNode . |
results | array | Results the PlanNode returns, if any. |
resultsPending | boolean | true if there are pending results from the PlanNode . |
actionStatus | string | Current action status of the PlanNode . |
successors | array | PlanNode elements that are children of the current PlanNode . |
type | object | PlanNodeType of the PlanNode . |
typeName | string | Type name of the specified PlanNode . |
Several PlanNode
properties return parts of the node's fully qualified type, which consists of the capsule version, capsule ID (organization namespace and capsule name), and the relevant model.
1.2.3-viv.foo.Bar
viv.foo
1.2.3
viv.foo.Bar
Bar
A PlanNode
object has the following methods:
► find(predicate: function
, direction?: FindDirection, neighbors?: boolean
): IterableIterator
.PlanNode
Find the PlanNode
objects based on the function
passed. You can also specify the direction to search.
Parameters:
Parameter | Type | Description |
---|---|---|
predicate | function | Name of the function that you want to find. |
direction | FindDirection | Direction that you want to search. Default: FindDirection.all . |
neighbors | Boolean | Determines if you want to search within the immediate neighbors. Default: false . |
Returns: IterableIterator.PlanNode
Consider the following example, which is equivalent to currentNode.getAllNodesByType('action')
:
const iterable = currentNode.find((node) => node.type === 'action')
const actions = Array.from(iterable)
The following example finds all concepts that have at least one dialog:
const iterable = currentNode.find((node) => node.dialogs.length > 0 && node.type === 'concept')
const conceptsWithDialog = Array.from(iterable)
► find(predicate: function
, direction?: FindDirection, neighbors?: boolean
): IterableIterator.PlanNode
Find the PlanNode
's predecessors and/or successors based on the function
passed. You can also specify the direction to search.
Parameters:
Parameter | Type | Description |
---|---|---|
predicate | function | Name of the function that you want to find |
direction | FindDirection | Direction that you want to search. Default: FindDirection.all |
neighbors | Boolean | Determines if you want to search within the immediate neighbors. Default: false |
Returns: IterableIterator.PlanNode
► findPredecessors(predicate: function
): IterableIterator.PlanNode
Find the predecessors of specified PlanNode
based on the function passed.
Parameters:
Parameter | Type | Description |
---|---|---|
predicate | function | Name of the function that you want to find |
Returns: IterableIterator.PlanNode
► findSuccessors(predicate: function
): IterableIterator
.PlanNode
Find the successor PlanNode
based on the function specified.
Parameters:
Parameter | Type | Description |
---|---|---|
predicate | function | Name of the function that you want to find |
Returns: IterableIterator.PlanNode
► getAllNodesByType(type: PlanNodeType): PlanNode[]
Return a PlanNode
array based on the type specified.
Parameters:
Parameter | Type | Description |
---|---|---|
type | PlanNodeType | Type of PlanNode you want to find |
Returns: PlanNode
► getAllNodesByTypeId(qualifiedTypeId: string
): PlanNode[]
Return a PlanNode
array specified by the action type ID.
Parameters:
Parameter | Type | Description |
---|---|---|
qualifiedTypeId | String | Fully qualified name of an action ID |
Returns: PlanNode
► getEdgeBetween(node: PlanNode
): PlanEdge
Return the edges between your current node and the specified PlanNode
.
Parameters:
Parameter | Type | Description |
---|---|---|
node | PlanNode | Neighbor node to current node that you want to find the edge between |
Returns: PlanEdge
Describes the PlanNode
type. The type can be one of the following:
Determines the direction to do a search. The following values are accepted:
all
: Search both directions.predecessors
: Search all nodes or edges preceeding current node.successors
: Search all nodes or edges proceeding current node.The Dialog
object represents the dialog events that happen in your execution graph.
A Dialog
object has the following properties:
Property | Type | Value |
---|---|---|
binding | string | The values of particular properties of concepts in templates. (Optional) |
capsuleId | string | The fully qualified capsule ID. (Optional) |
components | array | Dialog components. (Optional; see note) |
filePath | string | Full local file path of the dialog file. (Optional) |
mode | string | The dialog event mode. |
template | string | The dialog template being used for the message, if any. (Optional) |
text | string | The text being output by the dialog. |
It's possible for a component
to nest more component
objects.
The JavaScript functions being executed by the current step.
A Function
object has the following properties:
Property | Type | Value |
---|---|---|
path | string | Relative path name of function being passed by the action. |
status | string | Current status of the function. |
capsuleId | string | The fully qualified capsule ID. |
actionId | string | The fully qualified action type (for example, viv.gratuity.calculate ). |
requests | object | Map of web requests and responses. See below. (Optional) |
id | string | Identifier of a function web request. |
FunctionWebRequest | object | Request object passed to a web service. |
FunctionWebResponse | object | Response object received from a web service. |
The requests
property maps id
values to FunctionWebRequest
and FunctionWebResponse
objects with the following structure:
requests: { [_id_: string]: { _req_: FunctionWebRequest, _res_: FunctionWebResponse } }
The FunctionWebRequest
can include information such as the method and URL passed to the request. The FunctionWebResponse
can include information such as the duration of the request, cached information, and HTTP status code. The specific values depend on the web service.
The Layout
object represents layouts in your execution graph.
A Layout
object has the following properties:
Property | Type | Value |
---|---|---|
conceptId | string | Identifier of the concept being used in the layout. |
id | string | Unique identifier of the layout. |
isDeferred | boolean | true if the layout has been deferred from being generated. |
layout | object | The JsonLayout object that represents the layout. |
mode | string | The layout mode, one of summary , details , input , or confirmation . (Optional) |
ref | string | Execution reference identifier. |
sortId | string | The identifier of the sort being used in the layout. |
PlanEdge
objects represent the edges in your execution graph. All edges are either incomingEdges or outgoingEdges of a given PlanNode
.
Note that one node's incomingEdge
can be another node's outgoingEdge
. Consider the following execution graph:
For the VALUE
node, the outgoingEdge
is the geo.LocalityName
of "Mountain View". This same edge is an incomingEdge
, as an input for the search function geo.FindLocality
. Be aware that the node you call an edge for will affect the output information.
A JSON object representing the HTML for the layout. Any child in this JSON tree can also be a Dialog component.
A JsonLayout
object has the following properties:
Property | Type | Value |
---|---|---|
JsonElement | object | Interface representing the HTML content sections of a layout, namely header and content elements. Can contain Attribute , Type , and Children properties. |
Attribute | string | Attributes of the parent HTML element. |
Type | string | Tag name of the main HTML elements (for example, div ). |
Children | mixed | Child elements of the given JsonElement . Children can be a single JsonElement , a JsonElement[] array, or a dialog fragment. |
formBindings | array | Associated bindings in form layouts. (Optional) |
style | string | Style being used in the layout. (Optional) |
submitRequired | boolean | true if a submit is required to access this layout. |
type | string | Layout type, either layout or text . |