Skip to content

[Fix_#873] Rename output.from and output.to #892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ctk/features/data-flow.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,15 +74,15 @@ 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:
method: get
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:
Expand Down
33 changes: 31 additions & 2 deletions dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
+ [Retry](#retry)
+ [Input](#input)
+ [Output](#output)
+ [Export] (#export)
+ [Timeout](#timeout)
+ [Duration](#duration)
+ [HTTP Response](#http-response)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.<br>*If not set, defaults to `continue`.* |

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.<br>*Included to handle the non frequent case in which the context has a known format.* |
| as | `string`<br>`object` | `no` | A runtime expression, if any, used to export the output data to the context. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link is missing on runtime expression -> [runtime expression](#runtime-expressions)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that particular link is missed everywhere, maybe should be fixed with a different PR?


#### 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.
Expand Down
4 changes: 2 additions & 2 deletions examples/accumulate-room-readings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ do:
roomId:
from: .roomid
output:
from: .data.reading
as: .data.reading
- with:
source: https://my.home.com/sensor
type: my.home.sensors.humidity
correlate:
roomId:
from: .roomid
output:
from: .data.reading
as: .data.reading
as: readings
- logReading:
for:
Expand Down
15 changes: 11 additions & 4 deletions schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading