Skip to content

Commit 6f5d0a8

Browse files
committed
[Fix_#873] Rename output.from and output.to
output.from is renamed as output.as output.to is renamed as export.as Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
1 parent 8c92c23 commit 6f5d0a8

File tree

4 files changed

+49
-11
lines changed

4 files changed

+49
-11
lines changed

ctk/features/data-flow.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Feature: Data Flow
4444
endpoint:
4545
uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables
4646
output:
47-
from: .id #filters the output of the http call, using only the id of the returned object
47+
as: .id #filters the output of the http call, using only the id of the returned object
4848
"""
4949
And given the workflow input is:
5050
"""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: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ do:
176176
- getAvailablePets:
177177
call: getAvailablePets
178178
output:
179-
from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }"
179+
as: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }"
180180
- submitMatchesByMail:
181181
call: http
182182
with:
@@ -234,6 +234,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
234234
|:--|:---:|:---:|:---|
235235
| input | [`input`](#input) | `no` | An object used to customize the task's input and to document its schema, if any. |
236236
| output | [`output`](#output) | `no` | An object used to customize the task's output and to document its schema, if any. |
237+
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
237238
| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. |
238239
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.<br>*If not set, defaults to `continue`.* |
239240

@@ -558,7 +559,7 @@ do:
558559
with:
559560
type: com.fake.petclinic.pets.checkup.completed.v2
560561
output:
561-
to: '.pets + [{ "id": $pet.id }]'
562+
as: '.pets + [{ "id": $pet.id }]'
562563
```
563564

564565
#### Listen
@@ -1416,6 +1417,36 @@ from:
14161417
to: '.petList += [ . ]'
14171418
```
14181419

1420+
### Export
1421+
1422+
Certain task needs to set the context of the workflow using the task output for later usage. User set the content of the context through a runtime expression. The result of the expression is the new value of the context. If user want to merge the new data into the current context, he might do that using `$context` variable.
1423+
1424+
Optionally, the context can have a predefined schema.
1425+
1426+
1427+
#### Properties
1428+
1429+
| Property | Type | Required | Description |
1430+
|----------|:----:|:--------:|-------------|
1431+
| 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.* |
1432+
| as | `string`<br>`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to set the context value. |
1433+
1434+
#### Examples
1435+
1436+
Assuming the output of the task is a json object (not primitive, not array)
1437+
Merge into the current context the output of the task.
1438+
1439+
```yaml
1440+
as: '$context+=.'
1441+
```
1442+
1443+
Replace the context with the output of the task.
1444+
1445+
```yaml
1446+
as: .
1447+
```
1448+
1449+
14191450
### Schema
14201451

14211452
Describes a data schema.

examples/accumulate-room-readings.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ do:
1717
roomId:
1818
from: .roomid
1919
output:
20-
from: .data.reading
20+
as: .data.reading
2121
- with:
2222
source: https://my.home.com/sensor
2323
type: my.home.sensors.humidity
2424
correlate:
2525
roomId:
2626
from: .roomid
2727
output:
28-
from: .data.reading
28+
as: .data.reading
2929
as: readings
3030
- logReading:
3131
for:

schema/workflow.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -816,13 +816,20 @@ $defs:
816816
schema:
817817
$ref: '#/$defs/schema'
818818
description: The schema used to describe and validate the output of the workflow or task.
819-
from:
819+
as:
820820
type: string
821821
description: A runtime expression, if any, used to mutate and/or filter the output of the workflow or task.
822-
to:
823-
type: string
824-
description: A runtime expression, if any, used to output data to the current context.
825822
description: Configures the output of a workflow or task.
823+
export:
824+
type: object
825+
properties:
826+
schema:
827+
$ref: '#/$defs/schema'
828+
description: The schema used to describe and validate the workflow context.
829+
as:
830+
type: string
831+
description: A runtime expression, if any, used to set the context with output data.
832+
description: Set the content of the context.
826833
retryPolicy:
827834
type: object
828835
properties:

0 commit comments

Comments
 (0)