Skip to content

Commit 0ea6dcb

Browse files
Merge branch 'main' into runtime-arg
2 parents 5961814 + 538a0a6 commit 0ea6dcb

File tree

4 files changed

+96
-26
lines changed

4 files changed

+96
-26
lines changed

dsl-reference.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
+ [Duration](#duration)
5151
+ [HTTP Response](#http-response)
5252
+ [HTTP Request](#http-request)
53+
+ [URI Template](#uri-template)
5354

5455
## Abstract
5556

@@ -83,7 +84,7 @@ Documents the workflow definition.
8384
| dsl | `string` | `yes` | The version of the DSL used to define the workflow. |
8485
| namespace | `string` | `yes` | The workflow's namespace.<br> |
8586
| name | `string` | `yes` | The workflow's name.<br> |
86-
| version | `string` | `yes` | The workflow's [semantic version]
87+
| version | `string` | `yes` | The workflow's [semantic version](https://semver.org/) |
8788
| title | `string` | `no` | The workflow's title. |
8889
| summary | `string` | `no` | The workflow's Markdown summary. |
8990
| tags | `map[string, string]` | `no` | A key/value mapping of the workflow's tags, if any. |
@@ -279,7 +280,7 @@ do:
279280

280281
Serverless Workflow defines several default functions that **MUST** be supported by all implementations and runtimes:
281282

282-
- [AsyncAPI](#asyncapi)
283+
- [AsyncAPI](#asyncapi-call)
283284
- [gRPC](#grpc-call)
284285
- [HTTP](#http-call)
285286
- [OpenAPI](#openapi-call)
@@ -371,6 +372,7 @@ The [HTTP Call](#http-call) enables workflows to interact with external services
371372
| endpoint | [`endpoint`](#endpoint) | `yes` | An URI or an object that describes the HTTP endpoint to call. |
372373
| headers | `map` | `no` | A name/value mapping of the HTTP headers to use, if any. |
373374
| body | `any` | `no` | The HTTP request body, if any. |
375+
| query | `map[string, any]` | `no` | A name/value mapping of the query parameters to use, if any. |
374376
| output | `string` | `no` | The http call's output format.<br>*Supported values are:*<br>*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*<br>*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*<br>*- `response`, which outputs the [http response](#http-response).*<br>*Defaults to `content`.* |
375377

376378
###### Examples
@@ -528,9 +530,9 @@ Allows workflows to iterate over a collection of items, executing a defined set
528530
| Name | Type | Required | Description|
529531
|:--|:---:|:---:|:---|
530532
| for.each | `string` | `no` | The name of the variable used to store the current item being enumerated.<br>Defaults to `item`. |
531-
| for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. |
533+
| for.in | `string` | `yes` | A [runtime expression](./dsl.md/#runtime-expressions) used to get the collection to enumerate. |
532534
| for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.<br>Defaults to `index`. |
533-
| while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. |
535+
| while | `string` | `no` | A [runtime expression](./dsl.md/#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. |
534536
| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. |
535537

536538
##### Examples
@@ -601,7 +603,6 @@ do:
601603
room: ${ .room.number }
602604
```
603605

604-
605606
#### Listen
606607

607608
Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems.
@@ -1073,7 +1074,7 @@ Defines an external resource.
10731074
| Property | Type | Required | Description |
10741075
|----------|:----:|:--------:|-------------|
10751076
| name | `string` | `no` | The name, if any, of the defined resource. |
1076-
| uri | `string` | `yes` | The URI at which to get the defined resource. |
1077+
| uri | [`uri-template`](#uri-template) | `yes` | The URI at which to get the defined resource. |
10771078
| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when fecthing the resource. |
10781079

10791080
##### Examples
@@ -1208,8 +1209,8 @@ Defines the fundamentals of an 'oauth2' authentication
12081209

12091210
| Property | Type | Required | Description |
12101211
|----------|:----:|:--------:|-------------|
1211-
| authority | `string` | `yes` | The URI that references the OAuth2 authority to use. |
1212-
| grant | `string` | `yes` | The grant type to use.
1212+
| authority | [`uri-template`](#uri-template) | `yes` | The URI that references the OAuth2 authority to use. |
1213+
| grant | `string` | `yes` | The grant type to use. |
12131214
| client.id | `string` | `yes` | The client id to use. |
12141215
| client.secret | `string` | `no` | The client secret to use, if any. |
12151216
| scopes | `string[]` | `no` | The scopes, if any, to request the token for. |
@@ -1346,7 +1347,7 @@ Defines the [Problem Details RFC](https://datatracker.ietf.org/doc/html/rfc7807)
13461347

13471348
| Property | Type | Required | Description |
13481349
|----------|:----:|:--------:|-------------|
1349-
| type | `string` | `yes` | A URI reference that identifies the [`error`](#error) type. <br><u>For cross-compatibility concerns, it is strongly recommended to use [Standard Error Types](#standard-error-types) whenever possible.<u><br><u>Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error).<u> |
1350+
| type | [`uri-template`](#uri-template) | `yes` | A URI reference that identifies the [`error`](#error) type. <br><u>For cross-compatibility concerns, it is strongly recommended to use [Standard Error Types](#standard-error-types) whenever possible.<u><br><u>Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error).<u> |
13501351
| status | `integer` | `yes` | The status code generated by the origin for this occurrence of the [`error`](#error).<br><u>For cross-compatibility concerns, it is strongly recommended to use [HTTP Status Codes](https://datatracker.ietf.org/doc/html/rfc7231#section-6) whenever possible.<u><br><u>Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error).<u> |
13511352
| instance | `string` | `yes` | A [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) used to reference the component the [`error`](#error) originates from.<br><u>Runtimes **MUST** set the property when raising or escalating the [`error`](#error). Otherwise ignore.<u> |
13521353
| title | `string` | `no` | A short, human-readable summary of the [`error`](#error). |
@@ -1355,7 +1356,7 @@ Defines the [Problem Details RFC](https://datatracker.ietf.org/doc/html/rfc7807)
13551356
#### Examples
13561357

13571358
```yaml
1358-
type: https://https://serverlessworkflow.io/spec/1.0.0/errors/communication
1359+
type: https://serverlessworkflow.io/spec/1.0.0/errors/communication
13591360
title: Service Not Available
13601361
status: 503
13611362
```
@@ -1366,14 +1367,14 @@ Standard error types serve the purpose of categorizing errors consistently acros
13661367

13671368
| Type | Status¹ | Description |
13681369
|------|:-------:|-------------|
1369-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/configuration](#) | `400` | Errors resulting from incorrect or invalid configuration settings, such as missing or misconfigured environment variables, incorrect parameter values, or configuration file errors. |
1370-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/validation](#) | `400` | Errors arising from validation processes, such as validation of input data, schema validation failures, or validation constraints not being met. These errors indicate that the provided data or configuration does not adhere to the expected format or requirements specified by the workflow. |
1371-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/expression](#) | `400` | Errors occurring during the evaluation of runtime expressions, such as invalid syntax or unsupported operations. |
1372-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/authentication](#) | `401` | Errors related to authentication failures. |
1373-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/authorization](#) | `403` | Errors related to unauthorized access attempts or insufficient permissions to perform certain actions within the workflow. |
1374-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/timeout](#) | `408` | Errors caused by timeouts during the execution of tasks or during interactions with external services. |
1375-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/communication](#) | `500` | Errors encountered while communicating with external services, including network errors, service unavailable, or invalid responses. |
1376-
| [https://https://serverlessworkflow.io/spec/1.0.0/errors/runtime](#) | `500` | Errors occurring during the runtime execution of a workflow, including unexpected exceptions, errors related to resource allocation, or failures in handling workflow tasks. These errors typically occur during the actual execution of workflow components and may require runtime-specific handling and resolution strategies. |
1370+
| [https://serverlessworkflow.io/spec/1.0.0/errors/configuration](#) | `400` | Errors resulting from incorrect or invalid configuration settings, such as missing or misconfigured environment variables, incorrect parameter values, or configuration file errors. |
1371+
| [https://serverlessworkflow.io/spec/1.0.0/errors/validation](#) | `400` | Errors arising from validation processes, such as validation of input data, schema validation failures, or validation constraints not being met. These errors indicate that the provided data or configuration does not adhere to the expected format or requirements specified by the workflow. |
1372+
| [https://serverlessworkflow.io/spec/1.0.0/errors/expression](#) | `400` | Errors occurring during the evaluation of runtime expressions, such as invalid syntax or unsupported operations. |
1373+
| [https://serverlessworkflow.io/spec/1.0.0/errors/authentication](#) | `401` | Errors related to authentication failures. |
1374+
| [https://serverlessworkflow.io/spec/1.0.0/errors/authorization](#) | `403` | Errors related to unauthorized access attempts or insufficient permissions to perform certain actions within the workflow. |
1375+
| [https://serverlessworkflow.io/spec/1.0.0/errors/timeout](#) | `408` | Errors caused by timeouts during the execution of tasks or during interactions with external services. |
1376+
| [https://serverlessworkflow.io/spec/1.0.0/errors/communication](#) | `500` | Errors encountered while communicating with external services, including network errors, service unavailable, or invalid responses. |
1377+
| [https://serverlessworkflow.io/spec/1.0.0/errors/runtime](#) | `500` | Errors occurring during the runtime execution of a workflow, including unexpected exceptions, errors related to resource allocation, or failures in handling workflow tasks. These errors typically occur during the actual execution of workflow components and may require runtime-specific handling and resolution strategies. |
13771378

13781379
¹ *Default value. The `status code` that best describe the error should always be used.*
13791380

@@ -1685,4 +1686,22 @@ method: get
16851686
uri: https://petstore.swagger.io/v2/pet/1
16861687
headers:
16871688
Content-Type: application/json
1688-
```
1689+
```
1690+
1691+
### URI Template
1692+
1693+
The DSL has limited support for URI template syntax as defined by [RFC 6570](https://datatracker.ietf.org/doc/html/rfc6570). Specifically, only the [Simple String Expansion](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.2) is supported, which allows authors to embed variables in a URI.
1694+
1695+
To substitute a variable within a URI, use the `{}` syntax. The identifier inside the curly braces will be replaced with its value during runtime evaluation. If no value is found for the identifier, an empty string will be used.
1696+
1697+
This has the following limitations compared to runtime expressions:
1698+
1699+
- Only top-level properties can be interpolated within strings, thus identifiers are treated verbatim. This means that `{pet.id}` will be replaced with the value of the `"pet.id"` property, not the value of the `id` property of the `pet` property.
1700+
- The referenced variable must be of type `string`, `number`, `boolean`, or `null`. If the variable is of a different type an error with type `https://https://serverlessworkflow.io/spec/1.0.0/errors/expression` and status `400` will be raised.
1701+
- [Runtime expression arguments](./dsl.md#runtime-expression-arguments) are not available for string substitution.
1702+
1703+
#### Examples
1704+
1705+
```yaml
1706+
uri: https://petstore.swagger.io/v2/pet/{petId}
1707+
```

dsl.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Runtimes **may** optionally support other runtime expression languages, which au
196196

197197
CloudFlows defines [several arguments](#runtime-expression-arguments) that runtimes **must** provide during the evaluation of runtime expressions.
198198

199-
When the evaluation of an expression fails, runtimes **must** raise an error with type `https://https://serverlessworkflow.io/spec/1.0.0/errors/expression` and status `400`.
199+
When the evaluation of an expression fails, runtimes **must** raise an error with type `https://serverlessworkflow.io/spec/1.0.0/errors/expression` and status `400`.
200200

201201
#### Runtime expression arguments
202202

@@ -219,6 +219,28 @@ This argument contains information about the runtime executing the workflow.
219219
| version | `string` | The version of the runtime. This can be an arbitrary string | a incrementing positive integer (`362`), semantic version (`1.4.78`), commit hash (`04cd3be6da98fc35422c8caa821e0aa1ef6b2c02`) or container image label (`v0.7.43-alpine`) |
220220
| metadata | `map` | An object/map of implementation specific key-value pairs. This can be chosen by runtime implementors and usage of this argument signals that a given workflow definition might not be runtime agnostic | A Software as a Service (SaaS) provider might choose to expose information about the tenant the workflow is executed for e.g. `{ "organization": { "id": "org-ff51cff2-fc83-4d70-9af1-8dacdbbce0be", "name": "example-corp" }, "featureFlags": ["fastZip", "arm64"] }`. |
221221

222+
##### Task Descriptor
223+
224+
| Name | Type | Description | Example |
225+
|:-----|:----:|:------------|:--------|
226+
| name | `string` | The task's name. | `getPet` |
227+
| definition | `map` | The tasks definition (specified under the name) as a parsed object | `{ "call": "http", "with": { ... } }` |
228+
| input | `any` | The task's input *BEFORE* the `input.from` expression. For the result of `input.from` expression use the context of the runtime expression (for jq `.`) | - |
229+
| startedAt.iso8601 | `string` | The start time of the task as a ISO 8601 date time string. It uses `T` as the date-time delimiter, either UTC (`Z`) or a time zone offset (`+01:00`). The precision can be either seconds, milliseconds or nanoseconds | `2022-01-01T12:00:00Z`, `2022-01-01T12:00:00.123456Z`, `2022-01-01T12:00:00.123+01:00` |
230+
| startedAt.epochMillis | `integer` | The start time of the task as a integer value of milliseconds since midnight of 1970-01-01 UTC | `1641024000123` (="2022-01-01T08:00:00.123Z") |
231+
| startedAt.epochNanos | `integer` | The start time of the task as a integer value of nanoseconds since midnight of 1970-01-01 UTC | `1641024000123456` (="2022-01-01T08:00:00.123456Z") |
232+
233+
##### Workflow Descriptor
234+
235+
| Name | Type | Description | Example |
236+
|:-----|:----:|:------------|:--------|
237+
| id | `string` | A unique id of the workflow execution. Now specific format is imposed | UUIDv4: `4a5c8422-5868-4e12-8dd9-220810d2b9ee`, ULID: `0000004JFGDSW1H037G7J7SFB9` |
238+
| definition | `map` | The workflow's definition as a parsed object | `{ "document": { ... }, "do": [...] }` |
239+
| input | `any` | The workflow's input *BEFORE* the `input.from` expression. For the result of `input.from` expression use the `$input` argument | - |
240+
| startedAt.iso8601 | `string` | The start time of the execution as a ISO 8601 date time string. It uses `T` as the date-time delimiter, either UTC (`Z`) or a time zone offset (`+01:00`). The precision can be either seconds, milliseconds or nanoseconds | `2022-01-01T12:00:00Z`, `2022-01-01T12:00:00.123456Z`, `2022-01-01T12:00:00.123+01:00` |
241+
| startedAt.epochMillis | `integer` | The start time of the execution as a integer value of milliseconds since midnight of 1970-01-01 UTC | `1641024000123` (="2022-01-01T08:00:00.123Z") |
242+
| startedAt.epochNanos | `integer` | The start time of the execution as a integer value of nanoseconds since midnight of 1970-01-01 UTC | `1641024000123456` (="2022-01-01T08:00:00.123456Z") |
243+
222244
### Fault Tolerance
223245

224246
Serverless Workflow is designed with resilience in mind, acknowledging that errors are an inevitable part of any system. The DSL provides robust mechanisms to identify, describe, and handle errors effectively, ensuring the workflow can recover gracefully from failures.
@@ -231,7 +253,7 @@ Errors in Serverless Workflow are described using the [Problem Details RFC](http
231253

232254
*Example error:*
233255
```yaml
234-
type: https://https://serverlessworkflow.io/spec/1.0.0/errors/communication
256+
type: https://serverlessworkflow.io/spec/1.0.0/errors/communication
235257
title: Service Unavailable
236258
status: 503
237259
detail: The service is currently unavailable. Please try again later.
@@ -274,7 +296,7 @@ Workflows and tasks alike can be configured to timeout after a defined amount of
274296

275297
When a timeout occur, runtimes **must** abruptly interrupt the execution of the workflow/task, and **must** raise an error that, if uncaught, force the workflow/task to transition to the [`faulted` status phase](#status-phases).
276298

277-
A timeout error **must** have its `type` set to `https://https://serverlessworkflow.io/spec/1.0.0/errors/timeout` and **should** have its `status` set to `408`.
299+
A timeout error **must** have its `type` set to `https://serverlessworkflow.io/spec/1.0.0/errors/timeout` and **should** have its `status` set to `408`.
278300

279301
### Interoperability
280302

@@ -286,7 +308,7 @@ Serverless Workflow DSL is designed to seamlessly interact with a variety of ser
286308
- [**AsyncAPI**](dsl-reference.md#asyncapi-call): Facilitates interaction with asynchronous messaging protocols. AsyncAPI is designed for event-driven architectures, allowing workflows to publish and subscribe to events.
287309
- [**OpenAPI**](dsl-reference.md#openapi-call): Enables communication with services that provide OpenAPI specifications, which is useful for defining and consuming RESTful APIs.
288310

289-
Runtimes **must** raise an error with type `https://https://serverlessworkflow.io/spec/1.0.0/errors/communication` if and when a problem occurs during a call.
311+
Runtimes **must** raise an error with type `https://serverlessworkflow.io/spec/1.0.0/errors/communication` if and when a problem occurs during a call.
290312

291313
#### Custom and Non-Standard Interactions
292314

examples/http-query-params.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# yaml-language-server: $schema=https://serverlessworkflow.io/schemas/1.0.0-alpha2/workflow.yaml
2+
document:
3+
dsl: 1.0.0-alpha2
4+
namespace: examples
5+
name: http-query-params
6+
version: 1.0.0-alpha2
7+
input:
8+
schema:
9+
format: json
10+
document:
11+
type: object
12+
required:
13+
- searchQuery
14+
properties:
15+
searchQuery:
16+
type: string
17+
do:
18+
- searchStarWarsCharacters:
19+
call: http
20+
with:
21+
method: get
22+
endpoint: https://swapi.dev/api/people/
23+
query:
24+
search: ${.searchQuery}
25+

schema/workflow.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ $defs:
266266
description: A name/value mapping of the headers, if any, of the HTTP request to perform.
267267
body:
268268
description: The body, if any, of the HTTP request to perform.
269+
query:
270+
type: object
271+
additionalProperties: true
272+
description: A name/value mapping of the query parameters, if any, of the HTTP request to perform.
269273
output:
270274
type: string
271275
enum: [ raw, content, response ]
@@ -730,7 +734,7 @@ $defs:
730734
properties:
731735
authority:
732736
type: string
733-
format: uri
737+
format: uri-template
734738
description: The URI that references the OAuth2 authority to use.
735739
grant:
736740
type: string
@@ -940,14 +944,14 @@ $defs:
940944
externalResource:
941945
oneOf:
942946
- type: string
943-
format: uri
947+
format: uri-template
944948
- title: ExternalResourceURI
945949
type: object
946950
unevaluatedProperties: false
947951
properties:
948952
uri:
949953
type: string
950-
format: uri
954+
format: uri-template
951955
description: The endpoint's URI.
952956
authentication:
953957
$ref: '#/$defs/referenceableAuthenticationPolicy'

0 commit comments

Comments
 (0)