Skip to content

Commit 7eb87a8

Browse files
authored
Merge pull request #892 from fjtirado/Fix_#873
[Fix_#873] Rename output.from and output.to
2 parents 8c92c23 + 0420577 commit 7eb87a8

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
@@ -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: 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)
@@ -176,7 +177,7 @@ do:
176177
- getAvailablePets:
177178
call: getAvailablePets
178179
output:
179-
from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }"
180+
as: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }"
180181
- submitMatchesByMail:
181182
call: http
182183
with:
@@ -234,6 +235,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
234235
|:--|:---:|:---:|:---|
235236
| input | [`input`](#input) | `no` | An object used to customize the task's input and to document its schema, if any. |
236237
| output | [`output`](#output) | `no` | An object used to customize the task's output and to document its schema, if any. |
238+
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
237239
| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. |
238240
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.<br>*If not set, defaults to `continue`.* |
239241

@@ -558,7 +560,7 @@ do:
558560
with:
559561
type: com.fake.petclinic.pets.checkup.completed.v2
560562
output:
561-
to: '.pets + [{ "id": $pet.id }]'
563+
as: '.pets + [{ "id": $pet.id }]'
562564
```
563565

564566
#### Listen
@@ -1416,6 +1418,33 @@ from:
14161418
to: '.petList += [ . ]'
14171419
```
14181420

1421+
### Export
1422+
1423+
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.
1424+
1425+
Optionally, the context might have an associated schema.
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, if any, used to export the output data to the context. |
1433+
1434+
#### Examples
1435+
1436+
Merge the task output into the current context.
1437+
1438+
```yaml
1439+
as: '.+$output'
1440+
```
1441+
1442+
Replace the context with the task output.
1443+
1444+
```yaml
1445+
as: $output
1446+
```
1447+
14191448
### Schema
14201449

14211450
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 export the output data to the context.
832+
description: Set the content of the context.
826833
retryPolicy:
827834
type: object
828835
properties:

0 commit comments

Comments
 (0)