diff --git a/ctk/features/data-flow.feature b/ctk/features/data-flow.feature
index 6c92e081..36e6af10 100644
--- a/ctk/features/data-flow.feature
+++ b/ctk/features/data-flow.feature
@@ -44,7 +44,7 @@ Feature: Data Flow
endpoint:
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
output:
- from: .id #filters the output of the http call, using only the id of the returned object
+ as: .id #filters the output of the http call, using only the id of the returned object
"""
And given the workflow input is:
"""yaml
@@ -74,7 +74,7 @@ Feature: Data Flow
endpoint:
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
output:
- from: .id
+ as: .id
- getPetById2:
call: http
with:
@@ -82,7 +82,7 @@ Feature: Data Flow
endpoint:
uri: https://petstore.swagger.io/v2/pet/2
output:
- from: '{ ids: [ $input, .id ] }'
+ as: '{ ids: [ $input, .id ] }'
"""
When the workflow is executed
Then the workflow should complete with output:
diff --git a/dsl-reference.md b/dsl-reference.md
index 5631d019..f1b9ec59 100644
--- a/dsl-reference.md
+++ b/dsl-reference.md
@@ -44,6 +44,7 @@
+ [Retry](#retry)
+ [Input](#input)
+ [Output](#output)
+ + [Export] (#export)
+ [Timeout](#timeout)
+ [Duration](#duration)
+ [HTTP Response](#http-response)
@@ -176,7 +177,7 @@ do:
- getAvailablePets:
call: getAvailablePets
output:
- from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }"
+ as: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }"
- submitMatchesByMail:
call: http
with:
@@ -234,6 +235,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
|:--|:---:|:---:|:---|
| input | [`input`](#input) | `no` | An object used to customize the task's input and to document its schema, if any. |
| output | [`output`](#output) | `no` | An object used to customize the task's output and to document its schema, if any. |
+| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. |
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.
*If not set, defaults to `continue`.* |
@@ -558,7 +560,7 @@ do:
with:
type: com.fake.petclinic.pets.checkup.completed.v2
output:
- to: '.pets + [{ "id": $pet.id }]'
+ as: '.pets + [{ "id": $pet.id }]'
```
#### Listen
@@ -1416,6 +1418,33 @@ from:
to: '.petList += [ . ]'
```
+### Export
+
+Certain task needs to set the workflow context to save the task output for later usage. Users set the content of the context through a runtime expression. The result of the expression is the new value of the context. The expression is evaluated against the existing context.
+
+Optionally, the context might have an associated schema.
+
+#### Properties
+
+| Property | Type | Required | Description |
+|----------|:----:|:--------:|-------------|
+| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate context.
*Included to handle the non frequent case in which the context has a known format.* |
+| as | `string`
`object` | `no` | A runtime expression, if any, used to export the output data to the context. |
+
+#### Examples
+
+Merge the task output into the current context.
+
+```yaml
+as: '.+$output'
+```
+
+Replace the context with the task output.
+
+```yaml
+as: $output
+```
+
### Schema
Describes a data schema.
diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml
index 5b322b07..f4f8e678 100644
--- a/examples/accumulate-room-readings.yaml
+++ b/examples/accumulate-room-readings.yaml
@@ -17,7 +17,7 @@ do:
roomId:
from: .roomid
output:
- from: .data.reading
+ as: .data.reading
- with:
source: https://my.home.com/sensor
type: my.home.sensors.humidity
@@ -25,7 +25,7 @@ do:
roomId:
from: .roomid
output:
- from: .data.reading
+ as: .data.reading
as: readings
- logReading:
for:
diff --git a/schema/workflow.yaml b/schema/workflow.yaml
index d83a7b45..2f97f1f1 100644
--- a/schema/workflow.yaml
+++ b/schema/workflow.yaml
@@ -816,13 +816,20 @@ $defs:
schema:
$ref: '#/$defs/schema'
description: The schema used to describe and validate the output of the workflow or task.
- from:
+ as:
type: string
description: A runtime expression, if any, used to mutate and/or filter the output of the workflow or task.
- to:
- type: string
- description: A runtime expression, if any, used to output data to the current context.
description: Configures the output of a workflow or task.
+ export:
+ type: object
+ properties:
+ schema:
+ $ref: '#/$defs/schema'
+ description: The schema used to describe and validate the workflow context.
+ as:
+ type: string
+ description: A runtime expression, if any, used to export the output data to the context.
+ description: Set the content of the context.
retryPolicy:
type: object
properties: