Skip to content

Commit 9f422f5

Browse files
Merge branch 'main' into matthias-pichler/invalid-do-switch-894
2 parents 50b93c2 + 7eb87a8 commit 9f422f5

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

ctk/features/data-flow.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Feature: Data Flow
4646
endpoint:
4747
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
4848
output:
49-
from: .id #filters the output of the http call, using only the id of the returned object
49+
as: .id #filters the output of the http call, using only the id of the returned object
5050
"""
5151
And given the workflow input is:
5252
"""yaml
@@ -74,15 +74,15 @@ Feature: Data Flow
7474
endpoint:
7575
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
7676
output:
77-
from: .id
77+
as: .id
7878
- getPetById2:
7979
call: http
8080
with:
8181
method: get
8282
endpoint:
8383
uri: https://petstore.swagger.io/v2/pet/2
8484
output:
85-
from: '{ ids: [ $input, .id ] }'
85+
as: '{ ids: [ $input, .id ] }'
8686
"""
8787
When the workflow is executed
8888
Then the workflow should complete with output:

dsl-reference.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
+ [Retry](#retry)
4545
+ [Input](#input)
4646
+ [Output](#output)
47+
+ [Export] (#export)
4748
+ [Timeout](#timeout)
4849
+ [Duration](#duration)
4950
+ [HTTP Response](#http-response)
@@ -183,7 +184,7 @@ do:
183184
- getAvailablePets:
184185
call: getAvailablePets
185186
output:
186-
from: "$input + { availablePets: [.[] | select(.category.name == \"dog\" and (.tags[] | .breed == $input.order.breed))] }"
187+
as: "$input + { availablePets: [.[] | select(.category.name == \"dog\" and (.tags[] | .breed == $input.order.breed))] }"
187188
- submitMatchesByMail:
188189
call: http
189190
with:
@@ -241,6 +242,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
241242
|:--|:---:|:---:|:---|
242243
| input | [`input`](#input) | `no` | An object used to customize the task's input and to document its schema, if any. |
243244
| output | [`output`](#output) | `no` | An object used to customize the task's output and to document its schema, if any. |
245+
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
244246
| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. |
245247
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.<br>*If not set, defaults to `continue`.* |
246248

@@ -572,7 +574,7 @@ do:
572574
with:
573575
type: com.fake.petclinic.pets.checkup.completed.v2
574576
output:
575-
to: '.pets + [{ "id": $pet.id }]'
577+
as: '.pets + [{ "id": $pet.id }]'
576578
```
577579

578580
#### Listen
@@ -1490,6 +1492,33 @@ from:
14901492
to: '.petList += [ . ]'
14911493
```
14921494

1495+
### Export
1496+
1497+
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.
1498+
1499+
Optionally, the context might have an associated schema.
1500+
1501+
#### Properties
1502+
1503+
| Property | Type | Required | Description |
1504+
|----------|:----:|:--------:|-------------|
1505+
| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate context.<br>*Included to handle the non frequent case in which the context has a known format.* |
1506+
| as | `string`<br>`object` | `no` | A runtime expression, if any, used to export the output data to the context. |
1507+
1508+
#### Examples
1509+
1510+
Merge the task output into the current context.
1511+
1512+
```yaml
1513+
as: '.+$output'
1514+
```
1515+
1516+
Replace the context with the task output.
1517+
1518+
```yaml
1519+
as: $output
1520+
```
1521+
14931522
### Schema
14941523

14951524
Describes a data schema.

examples/accumulate-room-readings.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ do:
1515
roomId:
1616
from: .roomid
1717
output:
18-
from: .data.reading
18+
as: .data.reading
1919
- with:
2020
source: https://my.home.com/sensor
2121
type: my.home.sensors.humidity
2222
correlate:
2323
roomId:
2424
from: .roomid
2525
output:
26-
from: .data.reading
26+
as: .data.reading
2727
- logReading:
2828
for:
2929
each: reading

schema/workflow.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,13 +858,20 @@ $defs:
858858
schema:
859859
$ref: '#/$defs/schema'
860860
description: The schema used to describe and validate the output of the workflow or task.
861-
from:
861+
as:
862862
type: string
863863
description: A runtime expression, if any, used to mutate and/or filter the output of the workflow or task.
864-
to:
865-
type: string
866-
description: A runtime expression, if any, used to output data to the current context.
867864
description: Configures the output of a workflow or task.
865+
export:
866+
type: object
867+
properties:
868+
schema:
869+
$ref: '#/$defs/schema'
870+
description: The schema used to describe and validate the workflow context.
871+
as:
872+
type: string
873+
description: A runtime expression, if any, used to export the output data to the context.
874+
description: Set the content of the context.
868875
retryPolicy:
869876
type: object
870877
properties:

0 commit comments

Comments
 (0)