From 077682050db234ef449b991cced075cad74b8e63 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 16:00:21 +0000 Subject: [PATCH 01/51] feat: update schema to have task array Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index d98321f3..6c68dcda 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -72,9 +72,9 @@ properties: description: The workflow's secrets. description: Defines the workflow's reusable components. do: - type: object - minProperties: 1 - additionalProperties: + type: array + minItems: 1 + items: $ref: '#/$defs/task' description: Defines the tasks the workflow must perform timeout: @@ -103,6 +103,9 @@ $defs: task: type: object properties: + name: + type: string + description: The task's name. **SHOULD** be unique within the workflow. input: $ref: '#/$defs/input' description: Configure the task's input. @@ -270,22 +273,22 @@ $defs: oneOf: - properties: concurrently: - type: object - minProperties: 2 - additionalProperties: + type: array + minItems: 2 + items: $ref: '#/$defs/task' - description: A name/definition mapping of the tasks to perform concurrently. + description: A list of the tasks to perform concurrently. compete: type: boolean description: Indicates whether or not the concurrent tasks are racing against each other, with a single possible winner, which sets the composite task's output. required: [ concurrently ] - properties: sequentially: - type: object - minProperties: 2 - additionalProperties: + type: array + minItems: 2 + items: $ref: '#/$defs/task' - description: A name/definition mapping of the tasks to perform sequentially. + description: A list of the tasks to perform sequentially. required: [ sequentially ] description: Configures the task execution strategy to use required: [ execute ] @@ -487,9 +490,9 @@ $defs: type: object properties: switch: - type: object - minProperties: 1 - additionalProperties: + type: array + minItems: 1 + items: type: object properties: when: From e9f6a66dd5bb66f7585bbb998a7b413059dbd505 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 16:00:46 +0000 Subject: [PATCH 02/51] fix: update examples to follow schema Signed-off-by: Matthias Pichler --- examples/accumulate-room-readings.yaml | 6 +++--- examples/bearer-auth.yaml | 2 +- examples/switch-then-string.yaml | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index d7d91eec..6f953eb1 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -4,7 +4,7 @@ document: name: accumulate-room-readings version: 1.0.0-alpha1 do: - consumeReading: + - name: consumeReading listen: to: all: @@ -25,7 +25,7 @@ do: output: from: .data.reading as: readings - logReading: + - name: logReading for: each: reading in: .readings @@ -35,7 +35,7 @@ do: document: uri: http://myorg.io/ordersservices.json operationId: logreading - generateReport: + - name: generateReport call: openapi with: document: diff --git a/examples/bearer-auth.yaml b/examples/bearer-auth.yaml index f4b2227c..ba69d35c 100644 --- a/examples/bearer-auth.yaml +++ b/examples/bearer-auth.yaml @@ -4,7 +4,7 @@ document: name: bearer-auth version: 1.0.0-alpha1 do: - getPetById: + - name: getPetById call: http with: method: get diff --git a/examples/switch-then-string.yaml b/examples/switch-then-string.yaml index 7db53745..3dc3a9d9 100644 --- a/examples/switch-then-string.yaml +++ b/examples/switch-then-string.yaml @@ -4,45 +4,45 @@ document: name: sample-workflow version: '0.1.0' do: - processOrder: + - name: processOrder switch: - case1: + - name: case1 when: .orderType == "electronic" then: processElectronicOrder - case2: + - name: case2 when: .orderType == "physical" then: processPhysicalOrder - default: + - name: default then: handleUnknownOrderType - processElectronicOrder: + - name: processElectronicOrder execute: sequentially: - validatePayment: + - name: validatePayment set: validate: true - fulfillOrder: + - name: fulfillOrder set: status: fulfilled then: exit - processPhysicalOrder: + - name: processPhysicalOrder execute: sequentially: - checkInventory: + - name: checkInventory set: inventory: clear - packItems: + - name: packItems set: items: 1 - scheduleShipping: + - name: scheduleShipping set: address: Elmer St then: exit handleUnknownOrderType: execute: sequentially: - logWarning: + - name: logWarning set: log: warn - notifyAdmin: + - name: notifyAdmin set: message: something's wrong \ No newline at end of file From 12d1c8592674f78681eeb91f1e44d40b0f32e2d2 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 16:04:37 +0000 Subject: [PATCH 03/51] fix: make all tasks array entries Signed-off-by: Matthias Pichler --- examples/switch-then-string.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/switch-then-string.yaml b/examples/switch-then-string.yaml index 3dc3a9d9..7e6de9ee 100644 --- a/examples/switch-then-string.yaml +++ b/examples/switch-then-string.yaml @@ -37,7 +37,7 @@ do: set: address: Elmer St then: exit - handleUnknownOrderType: + - name: handleUnknownOrderType execute: sequentially: - name: logWarning From 96fa290c2d160a75af256924de674bbe86eea630 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 16:10:42 +0000 Subject: [PATCH 04/51] make: all task references arrays Signed-off-by: Matthias Pichler --- examples/accumulate-room-readings.yaml | 10 +++++----- schema/workflow.yaml | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index 6f953eb1..8abcab07 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -30,11 +30,11 @@ do: each: reading in: .readings do: - call: openapi - with: - document: - uri: http://myorg.io/ordersservices.json - operationId: logreading + - call: openapi + with: + document: + uri: http://myorg.io/ordersservices.json + operationId: logreading - name: generateReport call: openapi with: diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 6c68dcda..7240fb0a 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -355,7 +355,10 @@ $defs: type: string description: A runtime expression that represents the condition, if any, that must be met for the iteration to continue. do: - $ref: '#/$defs/task' + type: array + minItems: 1 + items: + $ref: '#/$defs/task' description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets. required: [ for, do ] listenTask: @@ -507,8 +510,11 @@ $defs: type: object properties: try: - $ref: '#/$defs/task' - description: The task to perform. + description: The tasks to perform. + type: array + minItems: 1 + items: + - $ref: '#/$defs/task' catch: type: object properties: @@ -527,8 +533,11 @@ $defs: $ref: '#/$defs/retryPolicy' description: The retry policy to use, if any, when catching errors. do: - $ref: '#/$defs/task' description: The definition of the task to run when catching an error. + type: array + minItems: 1 + items: + $ref: '#/$defs/task' required: [ try, catch ] description: Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones. waitTask: From 616f8f8a709de48b0ad38eb332d12e77e7902141 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 16:13:14 +0000 Subject: [PATCH 05/51] docs: update samples in docs Signed-off-by: Matthias Pichler --- dsl.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dsl.md b/dsl.md index 900c5fb0..28006471 100644 --- a/dsl.md +++ b/dsl.md @@ -236,11 +236,11 @@ Errors are critical for both authors and runtimes as they provide a means to com *Retrying 5 times when an error with 503 is caught:* ```yaml try: - call: http - with: - method: get - endpoint: - uri: https://example-service.com/healthz + - call: http + with: + method: get + endpoint: + uri: https://example-service.com/healthz catch: errors: with: @@ -342,7 +342,7 @@ document: version: '0.1.0' do: - validateEmail: + - name: validateEmail call: https://github.com/myorg/functions/validateEmailAddress@v1 with: emailAddress: ${ .userEmail } @@ -426,7 +426,7 @@ use: body: message: "${ \"Executed task '\($task.reference)'...\" }" do: - get: + - name: get call: http with: method: get From 0cfa468229e330040c1005e48f22d9c333007548 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 16:48:18 +0000 Subject: [PATCH 06/51] docs: update dsl reference Signed-off-by: Matthias Pichler --- dsl-reference.md | 224 +++++++++++++++++++++++-------------------- schema/workflow.yaml | 15 ++- 2 files changed, 130 insertions(+), 109 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 5db2f1da..957aecaf 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -66,7 +66,7 @@ A [workflow](#workflow) serves as a blueprint outlining the series of [tasks](#t | document | [`document`](#document) | `yes` | Documents the defined workflow. | | input | [`input`](#input) | `no` | Configures the workflow's input. | | use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. | -| do | [`map[string, task]`](#task) | `yes` | The [task(s)](#task) that must be performed by the [workflow](#workflow). | +| do | [`task[]`](#task) | `yes` | The [task(s)](#task) that must be performed by the [workflow](#workflow). | | timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. | | output | [`output`](#output) | `no` | Configures the workflow's output. | | schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. | @@ -146,19 +146,19 @@ use: externalLogging: extend: all before: - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executing task '\($task.reference)'...\" }" + - call: http + with: + method: post + uri: https://fake.log.collector.com + body: + message: "${ \"Executing task '\($task.reference)'...\" }" after: - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executed task '\($task.reference)'...\" }" + - call: http + with: + method: post + uri: https://fake.log.collector.com + body: + message: "${ \"Executed task '\($task.reference)'...\" }" functions: getAvailablePets: call: openapi @@ -171,11 +171,11 @@ use: secrets: - my-oauth2-secret do: - getAvailablePets: + - name: getAvailablePets call: getAvailablePets output: from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }" - submitMatchesByMail: + - name: submitMatchesByMail call: http with: method: post @@ -230,6 +230,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su | Name | Type | Required | Description| |:--|:---:|:---:|:---| +| name | `string` | `no` | The name of the task, if any. **SHOULD** be unique within an array. Required if you want to reference the task in [`then`](#flow-directive) | | 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. | | timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. | @@ -255,7 +256,7 @@ document: name: sample-workflow version: '0.1.0' do: - getPetById: + - name: getPetById call: http with: method: get @@ -294,7 +295,7 @@ document: name: sample-workflow version: '0.1.0' do: - greetUser: + - name: greetUser call: asyncapi with: document: https://fake.com/docs/asyncapi.json @@ -331,7 +332,7 @@ document: name: sample-workflow version: '0.1.0' do: - greetUser: + - name: greetUser call: grpc with: proto: file://app/greet.proto @@ -367,7 +368,7 @@ document: name: sample-workflow version: '0.1.0' do: - getPetById: + - name: getPetById call: http with: method: get @@ -397,7 +398,7 @@ document: name: sample-workflow version: '0.1.0' do: - getPets: + - name: getPets call: openapi with: document: https://petstore.swagger.io/v2/swagger.json @@ -414,8 +415,8 @@ do: | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| execute.sequentially | [`map(string, task)`](#task) | `no` | The tasks to perform sequentially.
*Required if `execute.concurrently` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | -| execute.concurrently | [`map(string, task)`](#task) | `no` | The tasks to perform concurrently.
*Required if `execute.sequentially` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | +| execute.sequentially | [`task[]`](#task) | `no` | The tasks to perform sequentially.
*Required if `execute.concurrently` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | +| execute.concurrently | [`task[]`](#task) | `no` | The tasks to perform concurrently.
*Required if `execute.sequentially` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | | execute.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.
*Ignored if `execute.sequentially` has been set. Defaults to `false`.*
*Must **not** be set if the [`tasks`](#task) are executed sequentially.* | ##### Examples @@ -428,10 +429,10 @@ document: name: sample-workflow version: '0.1.0' do: - bookTrip: + - name: bookTrip execute: sequentially: - bookHotel: + - name: bookHotel call: http with: method: post @@ -442,7 +443,7 @@ do: name: Four Seasons city: Antwerp country: Belgium - bookFlight: + - name: bookFlight call: http with: method: post @@ -474,10 +475,10 @@ document: name: sample-workflow version: '0.1.0' do: - raiseAlarm: + - name: raiseAlarm execute: concurrently: - callNurse: + - name: callNurse call: http with: method: put @@ -485,7 +486,7 @@ do: body: patientId: ${ .patient.fullName } room: ${ .room.number } - callDoctor: + - name: callDoctor call: http with: method: put @@ -514,7 +515,7 @@ document: name: sample-workflow version: '0.1.0' do: - placeOrder: + - name: placeOrder emit: event: with: @@ -541,7 +542,7 @@ Allows workflows to iterate over a collection of items, executing a defined set | for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. | | for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.
Defaults to `index`. | | while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. | -| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. | +| do | [`task[]`](#task) | `yes` | The task(s) to perform for each item in the collection. | ##### Examples @@ -559,8 +560,7 @@ do: at: index while: .vet != null do: - checkForFleas: - if: $pet.lastCheckup == null + - name: checkForFleas listen: to: one: @@ -589,7 +589,7 @@ document: name: sample-workflow version: '0.1.0' do: - callDoctor: + - name: callDoctor listen: to: any: @@ -622,28 +622,31 @@ document: name: sample-workflow version: '0.1.0' do: - processTicket: + - name: processTicket switch: - highPriority: + - name: highPriority when: .ticket.priority == "high" then: escalateToManager - mediumPriority: + - name: mediumPriority when: .ticket.priority == "medium" then: assignToSpecialist - lowPriority: + - name: lowPriority when: .ticket.priority == "low" then: resolveTicket - default: + - name: default then: raiseUndefinedPriorityError - raiseUndefinedPriorityError: + - name: raiseUndefinedPriorityError raise: error: type: https://fake.com/errors/tickets/undefined-priority status: 400 title: Undefined Priority - escalateToManager: {...} - assignToSpecialist: {...} - resolveTicket: {...} + - name: escalateToManager + ... + - name: assignToSpecialist + ... + - name: resolveTicket + ... ``` #### Run @@ -669,24 +672,24 @@ document: version: '0.1.0' do: - runContainer: + - name: runContainer run: container: image: fake-image - runScript: + - name: runScript run: script: language: js code: > Some cool multiline script - runShell: + - name: runShell run: shell: command: 'echo "Hello, ${ .user.name }"' - runWorkflow: + - name: runWorkflow run: workflow: reference: another-one:0.1.0 @@ -716,7 +719,7 @@ document: name: sample-workflow version: '0.1.0' do: - runContainer: + - name: runContainer run: container: image: fake-image @@ -744,7 +747,7 @@ document: name: sample-workflow version: '0.1.0' do: - runScript: + - name: runScript run: script: language: js @@ -773,7 +776,7 @@ document: name: sample-workflow version: '0.1.0' do: - runShell: + - name: runShell run: shell: command: 'echo "Hello, ${ .user.name }"' @@ -800,7 +803,7 @@ document: name: sample-workflow version: '0.1.0' do: - runShell: + - name: runShell run: workflow: reference: another-one:0.1.0 @@ -827,7 +830,7 @@ document: name: set version: '0.1.0' do: - initialize: + - name: initialize set: shape: circle size: ${ .configuration.size } @@ -842,7 +845,7 @@ Enables conditional branching within workflows, allowing them to dynamically sel | Name | Type | Required | Description | |:--|:---:|:---:|:---| -| switch | [`map[string, case]`](#switch-case) | `yes` | A name/value map of the cases to switch on | +| switch | [`case[]`](#switch-case) | `yes` | A name/value map of the cases to switch on | ##### Examples @@ -853,34 +856,41 @@ document: name: sample-workflow version: '0.1.0' do: - processOrder: + - name: processOrder switch: - case1: + - name: case1 when: .orderType == "electronic" then: processElectronicOrder - case2: + - name: case2 when: .orderType == "physical" then: processPhysicalOrder - default: + - name: default then: handleUnknownOrderType - processElectronicOrder: + - name: processElectronicOrder execute: sequentially: - validatePayment: {...} - fulfillOrder: {...} + - name: validatePayment + ... + - name: fulfillOrder + ... then: exit - processPhysicalOrder: + - name: processPhysicalOrder execute: sequentially: - checkInventory: {...} - packItems: {...} - scheduleShipping: {...} + - name: checkInventory + ... + - name: packItems + ... + - name: scheduleShipping + ... then: exit - handleUnknownOrderType: + - name: handleUnknownOrderType execute: sequentially: - logWarning: {...} - notifyAdmin: {...} + - name: logWarning + ... + - name: notifyAdmin + ... ``` ##### Switch Case @@ -889,6 +899,7 @@ Defines a switch case, encompassing of a condition for matching and an associate | Name | Type | Required | Description | |:--|:---:|:---:|:---| +| name | `string` | `no` | The name of the case, if any. | | when | `string` | `no` | A runtime expression used to determine whether or not the case matches.
*If not set, the case will be matched by default if no other case match.*
*Note that there can be only one default case, all others **MUST** set a condition.* | then | [`flowDirective`](#flow-directive) | `yes` | The flow directive to execute when the case matches. | @@ -900,7 +911,7 @@ Serves as a mechanism within workflows to handle errors gracefully, potentially | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| try | [`task`](#task) | `yes` | The task to perform. | +| try | [`task[]`](#task) | `yes` | The task(s) to perform. | | catch | [`catch`](#catch) | `yes` | Configures the errors to catch and how to handle them. | ##### Examples @@ -912,12 +923,12 @@ document: name: sample-workflow version: '0.1.0' do: - processOrder: + - name: processOrder try: - call: http - with: - method: get - uri: https:// + - call: http + with: + method: get + uri: https:// catch: errors: with: @@ -947,7 +958,7 @@ Defines the configuration of a catch clause, which a concept used to catch error | when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error | | exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | | retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors | -| do | [`task`](#task) | `no` | The definition of the task to run when catching an error | +| do | [`task[]`](#task) | `no` | The definition of the task(s) to run when catching an error | #### Wait @@ -968,7 +979,7 @@ document: name: sample-workflow version: '0.1.0' do: - delay10Seconds: + - name: delay10Seconds wait: seconds: 10 ``` @@ -979,9 +990,10 @@ Flow Directives are commands within a workflow that dictate its progression. | Directive | Description | | --------- | ----------- | -| `continue` | Instructs the workflow to proceed with the next task in line. This action may conclude the execution of a particular workflow or branch if there are not task defined after the continue one. | -| `exit` | Halts the current branch's execution, potentially terminating the entire workflow if the current task resides within the main branch. | -| `end` | Provides a graceful conclusion to the workflow execution, signaling its completion explicitly. | +| `"continue"` | Instructs the workflow to proceed with the next task in line. This action may conclude the execution of a particular workflow or branch if there are not task defined after the continue one. | +| `"exit"` | Halts the current branch's execution, potentially terminating the entire workflow if the current task resides within the main branch. | +| `"end"` | Provides a graceful conclusion to the workflow execution, signaling its completion explicitly. | +| `string` | Continues the workflow at the task with the specified name | ### External Resource @@ -1035,7 +1047,7 @@ use: sampleBasicFromSecret: basic: usernamePasswordSecret do: - getMessages: + - name: getMessages call: http with: method: get @@ -1070,7 +1082,7 @@ use: username: admin password: 123 do: - getMessages: + - name: getMessages call: http with: method: get @@ -1098,7 +1110,7 @@ document: name: sample-workflow version: '0.1.0' do: - getMessages: + - name: getMessages call: http with: method: get @@ -1143,7 +1155,7 @@ document: name: sample-workflow version: '0.1.0' do: - getMessages: + - name: getMessages call: http with: method: get @@ -1183,8 +1195,8 @@ Extensions enable the execution of tasks prior to those they extend, offering th |----------|:----:|:--------:|-------------| | extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | | when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | -| before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | -| after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | +| before | [`task[]`](#task) | `no` | The task(s) to execute, if any, before the extended task | +| after | [`task[]`](#task) | `no` | The task(s) to execute, if any, after the extended task | #### Examples @@ -1200,21 +1212,21 @@ use: logging: extend: all before: - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executing task '\($task.reference)'...\" }" + - call: http + with: + method: post + uri: https://fake.log.collector.com + body: + message: "${ \"Executing task '\($task.reference)'...\" }" after: - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executed task '\($task.reference)'...\" }" + - call: http + with: + method: post + uri: https://fake.log.collector.com + body: + message: "${ \"Executed task '\($task.reference)'...\" }" do: - get: + - name: get call: http with: method: get @@ -1234,16 +1246,16 @@ use: extend: http when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) before: - set: - statusCode: 200 - headers: - Content-Type: application/json - content: - foo: - bar: baz - then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected + - set: + statusCode: 200 + headers: + Content-Type: application/json + content: + foo: + bar: baz + then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected do: - get: + - name: get call: http with: method: get @@ -1488,7 +1500,7 @@ document: name: sample version: '0.1.0' do: - waitFor60Seconds: + - name: waitFor60Seconds wait: seconds: 60 timeout: diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 7240fb0a..8b9ca303 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -105,7 +105,7 @@ $defs: properties: name: type: string - description: The task's name. **SHOULD** be unique within the workflow. + description: The task's name. **SHOULD** be unique within an array. Required if you want to reference the task in `then`. input: $ref: '#/$defs/input' description: Configure the task's input. @@ -498,6 +498,9 @@ $defs: items: type: object properties: + name: + type: string + description: The case's name. when: type: string description: A runtime expression used to determine whether or not the case matches. @@ -758,11 +761,17 @@ $defs: type: string description: A runtime expression, if any, used to determine whether or not the extension should apply in the specified context. before: - $ref: '#/$defs/task' description: The task to execute before the extended task, if any. + type: array + minItems: 1 + items: + $ref: '#/$defs/task' after: - $ref: '#/$defs/task' description: The task to execute after the extended task, if any. + type: array + minItems: 1 + items: + $ref: '#/$defs/task' required: [ extend ] description: The definition of a an extension. externalResource: From 805addf8331931dfcd0a006237e832de7c2c115b Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Mon, 3 Jun 2024 11:54:03 -0300 Subject: [PATCH 07/51] Fix #878 - Fix URI format in workflow schema for endpoint attribute Signed-off-by: Ricardo Zanini Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 8b9ca303..db77f557 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -680,7 +680,7 @@ $defs: properties: uri: type: string - format: uri + format: uri-template description: The endpoint's URI. authentication: $ref: '#/$defs/authenticationPolicy' From a38d4ce644227601f0b89a870db3bcc2eea7ee0d Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Mon, 3 Jun 2024 11:57:23 -0300 Subject: [PATCH 08/51] Add missing example to verify change Signed-off-by: Ricardo Zanini Signed-off-by: Matthias Pichler --- examples/bearer-auth-uri-format.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/bearer-auth-uri-format.yaml diff --git a/examples/bearer-auth-uri-format.yaml b/examples/bearer-auth-uri-format.yaml new file mode 100644 index 00000000..622aae2d --- /dev/null +++ b/examples/bearer-auth-uri-format.yaml @@ -0,0 +1,15 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: bearer-auth-uri-format + version: 1.0.0-alpha1 +do: + getPetById: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/1 + authentication: + bearer: + token: ${ .token } From 03a8a6f309edbfe339c0596b8580de1bd6f175aa Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 17:55:24 +0000 Subject: [PATCH 09/51] fix: update new example Signed-off-by: Matthias Pichler --- examples/bearer-auth-uri-format.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bearer-auth-uri-format.yaml b/examples/bearer-auth-uri-format.yaml index 622aae2d..547c63e9 100644 --- a/examples/bearer-auth-uri-format.yaml +++ b/examples/bearer-auth-uri-format.yaml @@ -4,7 +4,7 @@ document: name: bearer-auth-uri-format version: 1.0.0-alpha1 do: - getPetById: + - name: getPetById: call: http with: method: get From f7c0a3410be53034dd045300875ed3f6ce4ca2cc Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 17:57:31 +0000 Subject: [PATCH 10/51] fix: remove trailing colon Signed-off-by: Matthias Pichler --- examples/bearer-auth-uri-format.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bearer-auth-uri-format.yaml b/examples/bearer-auth-uri-format.yaml index 547c63e9..fd1a3e45 100644 --- a/examples/bearer-auth-uri-format.yaml +++ b/examples/bearer-auth-uri-format.yaml @@ -4,7 +4,7 @@ document: name: bearer-auth-uri-format version: 1.0.0-alpha1 do: - - name: getPetById: + - name: getPetById call: http with: method: get From de0efa2174bb7b1e1e746feeff2d669e71057097 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:02:28 +0000 Subject: [PATCH 11/51] fix: make extensions an array as well Signed-off-by: Matthias Pichler --- dsl-reference.md | 8 ++++---- examples/mock-service-extension.yaml | 25 +++++++++++++++++++++++++ schema/workflow.yaml | 7 +++++-- 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 examples/mock-service-extension.yaml diff --git a/dsl-reference.md b/dsl-reference.md index 957aecaf..b388dc2a 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -94,7 +94,7 @@ Defines the workflow's reusable components. |:--|:---:|:---:|:---| | authentications | [`map[string, authentication]`](#authentication) | `no` | A name/value mapping of the workflow's reusable authentication policies. | | errors | [`map[string, error]`](#error) | `no` | A name/value mapping of the workflow's reusable errors. | -| extensions | [`map[string, extension]`](#extension) | `no` | A name/value mapping of the workflow's reusable extensions. | +| extensions | [`extension[]`](#extension) | `no` | A list of the workflow's reusable extensions. | | functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. | | retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. | | secrets | `string[]` | `no` | A list containing the workflow's secrets. | @@ -143,7 +143,7 @@ use: petStoreOAuth2: oauth2: my-oauth2-secret extensions: - externalLogging: + - name: externalLogging extend: all before: - call: http @@ -1209,7 +1209,7 @@ document: version: '0.1.0' use: extensions: - logging: + - name: logging extend: all before: - call: http @@ -1242,7 +1242,7 @@ document: version: '0.1.0' use: extensions: - mockService: + - name: mockService extend: http when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) before: diff --git a/examples/mock-service-extension.yaml b/examples/mock-service-extension.yaml new file mode 100644 index 00000000..306d2235 --- /dev/null +++ b/examples/mock-service-extension.yaml @@ -0,0 +1,25 @@ +document: + dsl: '1.0.0-alpha1' + namespace: test + name: sample-workflow + version: '0.1.0' +use: + extensions: + - name: mockService + extend: http + when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) + before: + - set: + statusCode: 200 + headers: + Content-Type: application/json + content: + foo: + bar: baz + then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected +do: + - name: get + call: http + with: + method: get + uri: https://fake.com/sample \ No newline at end of file diff --git a/schema/workflow.yaml b/schema/workflow.yaml index db77f557..83da1928 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -51,8 +51,8 @@ properties: $ref: '#/$defs/error' description: The workflow's reusable errors. extensions: - type: object - additionalProperties: + type: array + items: $ref: '#/$defs/extension' description: The workflow's extensions. functions: @@ -753,6 +753,9 @@ $defs: extension: type: object properties: + name: + type: string + description: The extension's name. extend: type: string enum: [ call, composite, emit, for, listen, raise, run, set, switch, try, wait, all ] From 88bb6e41e7fba5cf28156749066fdb69be3ab1f5 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:04:02 +0000 Subject: [PATCH 12/51] fix: use endpoint instead of uri Signed-off-by: Matthias Pichler --- examples/mock-service-extension.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mock-service-extension.yaml b/examples/mock-service-extension.yaml index 306d2235..a4bf5e70 100644 --- a/examples/mock-service-extension.yaml +++ b/examples/mock-service-extension.yaml @@ -22,4 +22,4 @@ do: call: http with: method: get - uri: https://fake.com/sample \ No newline at end of file + endpoint: https://fake.com/sample \ No newline at end of file From 2864941b38f80e67b1b8c49973bd2a6f40ceec4c Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:05:51 +0000 Subject: [PATCH 13/51] fix: use correct extend Signed-off-by: Matthias Pichler --- examples/mock-service-extension.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mock-service-extension.yaml b/examples/mock-service-extension.yaml index a4bf5e70..1a33205a 100644 --- a/examples/mock-service-extension.yaml +++ b/examples/mock-service-extension.yaml @@ -6,8 +6,8 @@ document: use: extensions: - name: mockService - extend: http - when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) + extend: call + when: ($task.with.endpoint != null and ($task.with.endpoint | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) before: - set: statusCode: 200 From 872edd3299d2964abefeaf0cdf68fa19ebc06fd8 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:07:04 +0000 Subject: [PATCH 14/51] fix: use endpoint object Signed-off-by: Matthias Pichler --- examples/mock-service-extension.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/mock-service-extension.yaml b/examples/mock-service-extension.yaml index 1a33205a..6eb1165f 100644 --- a/examples/mock-service-extension.yaml +++ b/examples/mock-service-extension.yaml @@ -22,4 +22,5 @@ do: call: http with: method: get - endpoint: https://fake.com/sample \ No newline at end of file + endpoint: + uri: https://fake.com/sample \ No newline at end of file From ad8bad832d4caf8c993d00d5aad3b6df73143a33 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:18:48 +0000 Subject: [PATCH 15/51] refactor: only make do an array Signed-off-by: Matthias Pichler --- dsl-reference.md | 70 +++++++++++++------------- examples/accumulate-room-readings.yaml | 10 ++-- examples/mock-service-extension.yaml | 16 +++--- schema/workflow.yaml | 27 +++------- 4 files changed, 54 insertions(+), 69 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index b388dc2a..cc2162d3 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -542,7 +542,7 @@ Allows workflows to iterate over a collection of items, executing a defined set | for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. | | for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.
Defaults to `index`. | | while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. | -| do | [`task[]`](#task) | `yes` | The task(s) to perform for each item in the collection. | +| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. | ##### Examples @@ -560,12 +560,12 @@ do: at: index while: .vet != null do: - - name: checkForFleas - listen: - to: - one: - with: - type: com.fake.petclinic.pets.checkup.completed.v2 + name: checkForFleas + listen: + to: + one: + with: + type: com.fake.petclinic.pets.checkup.completed.v2 output: to: '.pets + [{ "id": $pet.id }]' ``` @@ -911,7 +911,7 @@ Serves as a mechanism within workflows to handle errors gracefully, potentially | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| try | [`task[]`](#task) | `yes` | The task(s) to perform. | +| try | [`task`](#task) | `yes` | The task(s) to perform. | | catch | [`catch`](#catch) | `yes` | Configures the errors to catch and how to handle them. | ##### Examples @@ -925,10 +925,10 @@ document: do: - name: processOrder try: - - call: http - with: - method: get - uri: https:// + call: http + with: + method: get + uri: https:// catch: errors: with: @@ -958,7 +958,7 @@ Defines the configuration of a catch clause, which a concept used to catch error | when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error | | exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | | retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors | -| do | [`task[]`](#task) | `no` | The definition of the task(s) to run when catching an error | +| do | [`task`](#task) | `no` | The definition of the task to run when catching an error | #### Wait @@ -1195,8 +1195,8 @@ Extensions enable the execution of tasks prior to those they extend, offering th |----------|:----:|:--------:|-------------| | extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | | when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | -| before | [`task[]`](#task) | `no` | The task(s) to execute, if any, before the extended task | -| after | [`task[]`](#task) | `no` | The task(s) to execute, if any, after the extended task | +| before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | +| after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | #### Examples @@ -1212,19 +1212,19 @@ use: - name: logging extend: all before: - - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executing task '\($task.reference)'...\" }" + call: http + with: + method: post + uri: https://fake.log.collector.com + body: + message: "${ \"Executing task '\($task.reference)'...\" }" after: - - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executed task '\($task.reference)'...\" }" + call: http + with: + method: post + uri: https://fake.log.collector.com + body: + message: "${ \"Executed task '\($task.reference)'...\" }" do: - name: get call: http @@ -1246,14 +1246,14 @@ use: extend: http when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) before: - - set: - statusCode: 200 - headers: - Content-Type: application/json - content: - foo: - bar: baz - then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected + set: + statusCode: 200 + headers: + Content-Type: application/json + content: + foo: + bar: baz + then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected do: - name: get call: http diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index 8abcab07..6f953eb1 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -30,11 +30,11 @@ do: each: reading in: .readings do: - - call: openapi - with: - document: - uri: http://myorg.io/ordersservices.json - operationId: logreading + call: openapi + with: + document: + uri: http://myorg.io/ordersservices.json + operationId: logreading - name: generateReport call: openapi with: diff --git a/examples/mock-service-extension.yaml b/examples/mock-service-extension.yaml index 6eb1165f..bebded0a 100644 --- a/examples/mock-service-extension.yaml +++ b/examples/mock-service-extension.yaml @@ -9,14 +9,14 @@ use: extend: call when: ($task.with.endpoint != null and ($task.with.endpoint | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) before: - - set: - statusCode: 200 - headers: - Content-Type: application/json - content: - foo: - bar: baz - then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected + set: + statusCode: 200 + headers: + Content-Type: application/json + content: + foo: + bar: baz + then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected do: - name: get call: http diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 83da1928..ba6ee1cb 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -355,10 +355,7 @@ $defs: type: string description: A runtime expression that represents the condition, if any, that must be met for the iteration to continue. do: - type: array - minItems: 1 - items: - $ref: '#/$defs/task' + $ref: '#/$defs/task' description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets. required: [ for, do ] listenTask: @@ -513,11 +510,8 @@ $defs: type: object properties: try: - description: The tasks to perform. - type: array - minItems: 1 - items: - - $ref: '#/$defs/task' + description: The task to perform. + $ref: '#/$defs/task' catch: type: object properties: @@ -537,10 +531,7 @@ $defs: description: The retry policy to use, if any, when catching errors. do: description: The definition of the task to run when catching an error. - type: array - minItems: 1 - items: - $ref: '#/$defs/task' + $ref: '#/$defs/task' required: [ try, catch ] description: Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones. waitTask: @@ -765,16 +756,10 @@ $defs: description: A runtime expression, if any, used to determine whether or not the extension should apply in the specified context. before: description: The task to execute before the extended task, if any. - type: array - minItems: 1 - items: - $ref: '#/$defs/task' + $ref: '#/$defs/task' after: description: The task to execute after the extended task, if any. - type: array - minItems: 1 - items: - $ref: '#/$defs/task' + $ref: '#/$defs/task' required: [ extend ] description: The definition of a an extension. externalResource: From 14c878366722cb4e8bbfacc2a525003c0b0267b3 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 12:55:43 +0000 Subject: [PATCH 16/51] fix: use const for call tasks Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index ba6ee1cb..60faa644 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -136,7 +136,7 @@ $defs: - properties: call: type: string - constant: asyncapi + const: asyncapi with: type: object properties: @@ -167,7 +167,7 @@ $defs: - properties: call: type: string - constant: grpc + const: grpc with: type: object properties: @@ -206,7 +206,7 @@ $defs: - properties: call: type: string - constant: http + const: http with: type: object properties: @@ -231,7 +231,7 @@ $defs: - properties: call: type: string - constant: openapi + const: openapi with: type: object properties: From 226cf99b8d5bb2b13075ce3ae4c946dca768148d Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:02:56 +0000 Subject: [PATCH 17/51] fix: replace ref with $ref Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 60faa644..21c8ba52 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -159,7 +159,7 @@ $defs: type: object description: The payload to call the AsyncAPI operation with, if any. authentication: - ref: '#/$defs/authenticationPolicy' + $ref: '#/$defs/authenticationPolicy' description: The authentication policy, if any, to use when calling the AsyncAPI operation. required: [ document, operationRef ] description: Defines the AsyncAPI call to perform. From 4f21c9d84fcf4e24c1ec71a2a12042a476545e37 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:07:03 +0000 Subject: [PATCH 18/51] fix: allow references to authentications in use Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 21c8ba52..fb8053d7 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -159,8 +159,10 @@ $defs: type: object description: The payload to call the AsyncAPI operation with, if any. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy, if any, to use when calling the AsyncAPI operation. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string required: [ document, operationRef ] description: Defines the AsyncAPI call to perform. required: [ call, with ] @@ -190,8 +192,10 @@ $defs: max: 65535 description: The port number of the GRPC service to call. authentication: - $ref: '#/$defs/authenticationPolicy' description: The endpoint's authentication policy, if any. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string required: [ name, host ] method: type: string @@ -246,8 +250,10 @@ $defs: additionalProperties: true description: A name/value mapping of the parameters of the OpenAPI operation to call. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy, if any, to use when calling the OpenAPI operation. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string output: type: string enum: [ raw, content, response ] @@ -674,8 +680,10 @@ $defs: format: uri-template description: The endpoint's URI. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy to use. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string required: [ uri ] eventConsumptionStrategy: type: object @@ -770,8 +778,10 @@ $defs: format: uri description: The endpoint's URI. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy to use. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string name: type: string description: The external resource's name, if any. From 4b8e57a737dba5bf6b603359074e6852ff21ff9b Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:08:30 +0000 Subject: [PATCH 19/51] fix: add missing type directives to tasks Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index fb8053d7..34c0dc20 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -273,6 +273,7 @@ $defs: description: A name/value mapping of the parameters, if any, to call the function with. required: [ call ] compositeTask: + type: object properties: execute: type: object @@ -300,6 +301,7 @@ $defs: required: [ execute ] description: Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations emitTask: + type: object properties: emit: type: object @@ -341,6 +343,7 @@ $defs: default: continue - type: string forTask: + type: object properties: for: type: object From 039b90187132b749c2dbd0992985b50378bb2f2e Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:33:08 +0000 Subject: [PATCH 20/51] docs: add example of reusable auth Signed-off-by: Matthias Pichler --- examples/use-authentication.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/use-authentication.yaml diff --git a/examples/use-authentication.yaml b/examples/use-authentication.yaml new file mode 100644 index 00000000..c8cd34fe --- /dev/null +++ b/examples/use-authentication.yaml @@ -0,0 +1,18 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: bearer-auth + version: 1.0.0-alpha1 +use: + authentications: + petStoreAuth: + bearer: + token: ${ .token } +do: + getPetById: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + authentication: petStoreAuth From 58bd84aee007b6fc7ca2e84d812322c7d169dd68 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:36:15 +0000 Subject: [PATCH 21/51] docs: add async api example Signed-off-by: Matthias Pichler --- examples/asyncapi.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/asyncapi.yaml diff --git a/examples/asyncapi.yaml b/examples/asyncapi.yaml new file mode 100644 index 00000000..8c02d90d --- /dev/null +++ b/examples/asyncapi.yaml @@ -0,0 +1,20 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: bearer-auth + version: 1.0.0-alpha1 +do: + greetUser: + call: asyncapi + with: + document: + uri: https://fake.com/docs/asyncapi.json + operation: findPetsByStatus + server: staging + message: getPetByStatusQuery + binding: http + payload: + petId: ${ .pet.id } + authentication: + bearer: + token: ${ .token } From 2f3d9153ae594c05a952a592fac61ff252f9fcb7 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:39:54 +0000 Subject: [PATCH 22/51] fix: use operationRef Signed-off-by: Matthias Pichler --- examples/asyncapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/asyncapi.yaml b/examples/asyncapi.yaml index 8c02d90d..9d442d08 100644 --- a/examples/asyncapi.yaml +++ b/examples/asyncapi.yaml @@ -9,7 +9,7 @@ do: with: document: uri: https://fake.com/docs/asyncapi.json - operation: findPetsByStatus + operationRef: findPetsByStatus server: staging message: getPetByStatusQuery binding: http From 35c0e34cf56ac065bac6bfdced5213ab3b57140c Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 19:10:59 +0000 Subject: [PATCH 23/51] fix: update examples to new schema Signed-off-by: Matthias Pichler --- examples/asyncapi.yaml | 2 +- examples/use-authentication.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/asyncapi.yaml b/examples/asyncapi.yaml index 9d442d08..d2a82b36 100644 --- a/examples/asyncapi.yaml +++ b/examples/asyncapi.yaml @@ -4,7 +4,7 @@ document: name: bearer-auth version: 1.0.0-alpha1 do: - greetUser: + - name: greetUser call: asyncapi with: document: diff --git a/examples/use-authentication.yaml b/examples/use-authentication.yaml index c8cd34fe..0b8add97 100644 --- a/examples/use-authentication.yaml +++ b/examples/use-authentication.yaml @@ -9,7 +9,7 @@ use: bearer: token: ${ .token } do: - getPetById: + - name: getPetById call: http with: method: get From 5e05b5394af74383f3f65763442de0d44afe62fc Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:24:10 +0000 Subject: [PATCH 24/51] fix: update use endpoint in examples Signed-off-by: Matthias Pichler --- dsl-reference.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index cc2162d3..90c70e8a 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -146,19 +146,19 @@ use: - name: externalLogging extend: all before: - - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executing task '\($task.reference)'...\" }" + call: http + with: + method: post + endpoint: https://fake.log.collector.com + body: + message: "${ \"Executing task '\($task.reference)'...\" }" after: - - call: http - with: - method: post - uri: https://fake.log.collector.com - body: - message: "${ \"Executed task '\($task.reference)'...\" }" + call: http + with: + method: post + endpoint: https://fake.log.collector.com + body: + message: "${ \"Executed task '\($task.reference)'...\" }" functions: getAvailablePets: call: openapi @@ -260,7 +260,7 @@ do: call: http with: method: get - uri: https://petstore.swagger.io/v2/pet/{petId} + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` Serverless Workflow defines several default functions that **MUST** be supported by all implementations and runtimes: @@ -372,7 +372,7 @@ do: call: http with: method: get - uri: https://petstore.swagger.io/v2/pet/{petId} + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` ##### OpenAPI Call @@ -482,7 +482,7 @@ do: call: http with: method: put - uri: https://fake-hospital.com/api/v3/alert/nurses + endpoint: https://fake-hospital.com/api/v3/alert/nurses body: patientId: ${ .patient.fullName } room: ${ .room.number } @@ -490,7 +490,7 @@ do: call: http with: method: put - uri: https://fake-hospital.com/api/v3/alert/doctor + endpoint: https://fake-hospital.com/api/v3/alert/doctor body: patientId: ${ .patient.fullName } room: ${ .room.number } @@ -928,7 +928,7 @@ do: call: http with: method: get - uri: https:// + endpoint: https:// catch: errors: with: @@ -1215,14 +1215,14 @@ use: call: http with: method: post - uri: https://fake.log.collector.com + endpoint: https://fake.log.collector.com body: message: "${ \"Executing task '\($task.reference)'...\" }" after: call: http with: method: post - uri: https://fake.log.collector.com + endpoint: https://fake.log.collector.com body: message: "${ \"Executed task '\($task.reference)'...\" }" do: @@ -1230,7 +1230,7 @@ do: call: http with: method: get - uri: https://fake.com/sample + endpoint: https://fake.com/sample ``` *Intercept HTTP calls to 'https://mocked.service.com' and mock its response:* @@ -1259,7 +1259,7 @@ do: call: http with: method: get - uri: https://fake.com/sample + endpoint: https://fake.com/sample ``` ### Error From d33b1a0b812e8cade3537d36523e326a9769a1d5 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:28:33 +0000 Subject: [PATCH 25/51] fix: allow to specify endpoint as string as described in dsl Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 34c0dc20..a144fe03 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -218,8 +218,11 @@ $defs: type: string description: The HTTP method of the HTTP request to perform. endpoint: - $ref: '#/$defs/endpoint' description: The HTTP endpoint to send the request to. + oneOf: + - $ref: '#/$defs/endpoint' + - type: string + format: uri headers: type: object description: A name/value mapping of the headers, if any, of the HTTP request to perform. From 7b5b0fcdc88027b9c7417e02af6d645e1048e78a Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 17:51:12 +0000 Subject: [PATCH 26/51] docs: add shorthand endpoint example Signed-off-by: Matthias Pichler --- examples/call-http-shorthand-endpoint.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 examples/call-http-shorthand-endpoint.yaml diff --git a/examples/call-http-shorthand-endpoint.yaml b/examples/call-http-shorthand-endpoint.yaml new file mode 100644 index 00000000..35a8c81d --- /dev/null +++ b/examples/call-http-shorthand-endpoint.yaml @@ -0,0 +1,11 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: call-http-shorthand-endpoint + version: 1.0.0-alpha1 +do: + getPetById: + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/1 \ No newline at end of file From 752c383f7f0021694516415317e37aea279f1e0d Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 19:13:45 +0000 Subject: [PATCH 27/51] fix: use uri-template Signed-off-by: Matthias Pichler --- examples/call-http-shorthand-endpoint.yaml | 2 +- schema/workflow.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/call-http-shorthand-endpoint.yaml b/examples/call-http-shorthand-endpoint.yaml index 35a8c81d..f682ed30 100644 --- a/examples/call-http-shorthand-endpoint.yaml +++ b/examples/call-http-shorthand-endpoint.yaml @@ -8,4 +8,4 @@ do: call: http with: method: get - endpoint: https://petstore.swagger.io/v2/pet/1 \ No newline at end of file + endpoint: https://petstore.swagger.io/v2/pet/{petId} diff --git a/schema/workflow.yaml b/schema/workflow.yaml index a144fe03..9cecadc1 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -222,7 +222,7 @@ $defs: oneOf: - $ref: '#/$defs/endpoint' - type: string - format: uri + format: uri-template headers: type: object description: A name/value mapping of the headers, if any, of the HTTP request to perform. From b2429133b98b0240d9db2f47e041d314f5e1dfed Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 20:05:07 +0000 Subject: [PATCH 28/51] fix: update old example Signed-off-by: Matthias Pichler --- examples/call-http-shorthand-endpoint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/call-http-shorthand-endpoint.yaml b/examples/call-http-shorthand-endpoint.yaml index f682ed30..c198a8b7 100644 --- a/examples/call-http-shorthand-endpoint.yaml +++ b/examples/call-http-shorthand-endpoint.yaml @@ -4,7 +4,7 @@ document: name: call-http-shorthand-endpoint version: 1.0.0-alpha1 do: - getPetById: + - name: getPetById call: http with: method: get From d01ded3b1756c5b3160c94e125cee0d93acddf90 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 09:33:06 +0000 Subject: [PATCH 29/51] docs: update dsl docs Signed-off-by: Matthias Pichler --- dsl-reference.md | 753 +++++++++++++++++++++++------------------------ dsl.md | 28 +- 2 files changed, 385 insertions(+), 396 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 90c70e8a..a78cfaf1 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -66,7 +66,7 @@ A [workflow](#workflow) serves as a blueprint outlining the series of [tasks](#t | document | [`document`](#document) | `yes` | Documents the defined workflow. | | input | [`input`](#input) | `no` | Configures the workflow's input. | | use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. | -| do | [`task[]`](#task) | `yes` | The [task(s)](#task) that must be performed by the [workflow](#workflow). | +| do | [`map[string, task][]`](#task) | `yes` | The [task(s)](#task) that must be performed by the [workflow](#workflow). | | timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. | | output | [`output`](#output) | `no` | Configures the workflow's output. | | schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. | @@ -94,7 +94,7 @@ Defines the workflow's reusable components. |:--|:---:|:---:|:---| | authentications | [`map[string, authentication]`](#authentication) | `no` | A name/value mapping of the workflow's reusable authentication policies. | | errors | [`map[string, error]`](#error) | `no` | A name/value mapping of the workflow's reusable errors. | -| extensions | [`extension[]`](#extension) | `no` | A list of the workflow's reusable extensions. | +| extensions | [`map[string, extension][]`](#extension) | `no` | A list of the workflow's reusable extensions. | | functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. | | retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. | | secrets | `string[]` | `no` | A list containing the workflow's secrets. | @@ -143,22 +143,22 @@ use: petStoreOAuth2: oauth2: my-oauth2-secret extensions: - - name: externalLogging - extend: all - before: - call: http - with: - method: post - endpoint: https://fake.log.collector.com - body: - message: "${ \"Executing task '\($task.reference)'...\" }" - after: - call: http - with: - method: post - endpoint: https://fake.log.collector.com - body: - message: "${ \"Executed task '\($task.reference)'...\" }" + - externalLogging: + extend: all + before: + call: http + with: + method: post + endpoint: https://fake.log.collector.com + body: + message: "${ \"Executing task '\($task.reference)'...\" }" + after: + call: http + with: + method: post + endpoint: https://fake.log.collector.com + body: + message: "${ \"Executed task '\($task.reference)'...\" }" functions: getAvailablePets: call: openapi @@ -169,37 +169,37 @@ use: parameters: status: available secrets: - - my-oauth2-secret + - my-oauth2-secret do: - - name: getAvailablePets - call: getAvailablePets - output: - from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }" - - name: submitMatchesByMail - call: http - with: - method: post - endpoint: - uri: https://fake.smtp.service.com/email/send - authentication: petStoreOAuth2 - body: - from: noreply@fake.petstore.com - to: ${ .order.client.email } - subject: Candidates for Adoption - body: > - Hello ${ .order.client.preferredDisplayName }! - - Following your interest to adopt a dog, here is a list of candidates that you might be interested in: - - ${ .pets | map("-\(.name)") | join("\n") } - - Please do not hesistate to contact us at info@fake.petstore.com if your have questions. - - Hope to hear from you soon! - - ---------------------------------------------------------------------------------------------- - DO NOT REPLY - ---------------------------------------------------------------------------------------------- + - getAvailablePets: + call: getAvailablePets + output: + from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }" + - submitMatchesByMail: + call: http + with: + method: post + endpoint: + uri: https://fake.smtp.service.com/email/send + authentication: petStoreOAuth2 + body: + from: noreply@fake.petstore.com + to: ${ .order.client.email } + subject: Candidates for Adoption + body: > + Hello ${ .order.client.preferredDisplayName }! + + Following your interest to adopt a dog, here is a list of candidates that you might be interested in: + + ${ .pets | map("-\(.name)") | join("\n") } + + Please do not hesistate to contact us at info@fake.petstore.com if your have questions. + + Hope to hear from you soon! + + ---------------------------------------------------------------------------------------------- + DO NOT REPLY + ---------------------------------------------------------------------------------------------- ``` ### Task @@ -256,11 +256,11 @@ document: name: sample-workflow version: '0.1.0' do: - - name: getPetById - call: http - with: - method: get - endpoint: https://petstore.swagger.io/v2/pet/{petId} + - getPetById: + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` Serverless Workflow defines several default functions that **MUST** be supported by all implementations and runtimes: @@ -295,16 +295,16 @@ document: name: sample-workflow version: '0.1.0' do: - - name: greetUser - call: asyncapi - with: - document: https://fake.com/docs/asyncapi.json - operation: findPetsByStatus - server: staging - message: getPetByStatusQuery - binding: http - payload: - petId: ${ .pet.id } + - greetUser: + call: asyncapi + with: + document: https://fake.com/docs/asyncapi.json + operation: findPetsByStatus + server: staging + message: getPetByStatusQuery + binding: http + payload: + petId: ${ .pet.id } ``` ##### gRPC Call @@ -332,17 +332,17 @@ document: name: sample-workflow version: '0.1.0' do: - - name: greetUser - call: grpc - with: - proto: file://app/greet.proto - service: - name: GreeterApi.Greeter - host: localhost - port: 5011 - method: SayHello - arguments: - name: ${ .user.preferredDisplayName } + - greetUser: + call: grpc + with: + proto: file://app/greet.proto + service: + name: GreeterApi.Greeter + host: localhost + port: 5011 + method: SayHello + arguments: + name: ${ .user.preferredDisplayName } ``` ##### HTTP Call @@ -368,11 +368,11 @@ document: name: sample-workflow version: '0.1.0' do: - - name: getPetById - call: http - with: - method: get - endpoint: https://petstore.swagger.io/v2/pet/{petId} + - getPetById: + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` ##### OpenAPI Call @@ -398,13 +398,13 @@ document: name: sample-workflow version: '0.1.0' do: - - name: getPets - call: openapi - with: - document: https://petstore.swagger.io/v2/swagger.json - operation: findPetsByStatus - parameters: - status: available + - getPets: + call: openapi + with: + document: https://petstore.swagger.io/v2/swagger.json + operation: findPetsByStatus + parameters: + status: available ``` #### Composite @@ -429,42 +429,42 @@ document: name: sample-workflow version: '0.1.0' do: - - name: bookTrip - execute: - sequentially: - - name: bookHotel - call: http - with: - method: post - endpoint: - uri: https://fake-booking-agency.com/hotels/book - authentication: fake-booking-agency-oauth2 - body: - name: Four Seasons - city: Antwerp - country: Belgium - - name: bookFlight - call: http - with: - method: post - endpoint: - uri: https://fake-booking-agency.com/flights/book - authentication: fake-booking-agency-oauth2 - body: - departure: - date: '01/01/26' - time: '07:25:00' - from: - airport: BRU - city: Zaventem + - bookTrip: + execute: + sequentially: + - bookHotel: + call: http + with: + method: post + endpoint: + uri: https://fake-booking-agency.com/hotels/book + authentication: fake-booking-agency-oauth2 + body: + name: Four Seasons + city: Antwerp country: Belgium - arrival: - date: '01/01/26' - time: '11:12:00' - to: - airport: LIS - city: Lisbon - country: Portugal + - bookFlight: + call: http + with: + method: post + endpoint: + uri: https://fake-booking-agency.com/flights/book + authentication: fake-booking-agency-oauth2 + body: + departure: + date: '01/01/26' + time: '07:25:00' + from: + airport: BRU + city: Zaventem + country: Belgium + arrival: + date: '01/01/26' + time: '11:12:00' + to: + airport: LIS + city: Lisbon + country: Portugal ``` *Executing tasks concurrently:* @@ -475,25 +475,25 @@ document: name: sample-workflow version: '0.1.0' do: - - name: raiseAlarm - execute: - concurrently: - - name: callNurse - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/nurses - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } - - name: callDoctor - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/doctor - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } + - raiseAlarm: + execute: + concurrently: + - callNurse: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/nurses + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } + - callDoctor: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/doctor + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } ``` #### Emit @@ -515,19 +515,19 @@ document: name: sample-workflow version: '0.1.0' do: - - name: placeOrder - emit: - event: - with: - source: https://petstore.com - type: com.petstore.order.placed.v1 - data: - client: - firstName: Cruella - lastName: de Vil - items: - - breed: dalmatian - quantity: 101 + - placeOrder: + emit: + event: + with: + source: https://petstore.com + type: com.petstore.order.placed.v1 + data: + client: + firstName: Cruella + lastName: de Vil + items: + - breed: dalmatian + quantity: 101 ``` #### For @@ -553,21 +553,20 @@ document: name: sample-workflow version: '0.1.0' do: - checkup: - for: - each: pet - in: .pets - at: index - while: .vet != null - do: - name: checkForFleas - listen: - to: - one: - with: - type: com.fake.petclinic.pets.checkup.completed.v2 - output: - to: '.pets + [{ "id": $pet.id }]' + - checkup: + for: + each: pet + in: .pets + at: index + while: .vet != null + do: + listen: + to: + one: + with: + type: com.fake.petclinic.pets.checkup.completed.v2 + output: + to: '.pets + [{ "id": $pet.id }]' ``` #### Listen @@ -589,18 +588,18 @@ document: name: sample-workflow version: '0.1.0' do: - - name: callDoctor - listen: - to: - any: - - with: - type: com.fake-hospital.vitals.measurements.temperature - data: - temperature: ${ .temperature > 38 } - - with: - type: com.fake-hospital.vitals.measurements.bpm - data: - temperature: ${ .bpm < 60 or .bpm > 100 } + - callDoctor: + listen: + to: + any: + - with: + type: com.fake-hospital.vitals.measurements.temperature + data: + temperature: ${ .temperature > 38 } + - with: + type: com.fake-hospital.vitals.measurements.bpm + data: + temperature: ${ .bpm < 60 or .bpm > 100 } ``` #### Raise @@ -622,31 +621,28 @@ document: name: sample-workflow version: '0.1.0' do: - - name: processTicket - switch: - - name: highPriority - when: .ticket.priority == "high" - then: escalateToManager - - name: mediumPriority - when: .ticket.priority == "medium" - then: assignToSpecialist - - name: lowPriority - when: .ticket.priority == "low" - then: resolveTicket - - name: default - then: raiseUndefinedPriorityError - - name: raiseUndefinedPriorityError - raise: - error: - type: https://fake.com/errors/tickets/undefined-priority - status: 400 - title: Undefined Priority - - name: escalateToManager - ... - - name: assignToSpecialist - ... - - name: resolveTicket - ... + - processTicket: + switch: + - highPriority: + when: .ticket.priority == "high" + then: escalateToManager + - mediumPriority: + when: .ticket.priority == "medium" + then: assignToSpecialist + - lowPriority: + when: .ticket.priority == "low" + then: resolveTicket + - default: + then: raiseUndefinedPriorityError + - raiseUndefinedPriorityError: + raise: + error: + type: https://fake.com/errors/tickets/undefined-priority + status: 400 + title: Undefined Priority + - escalateToManager: {} + - assignToSpecialist: {} + - resolveTicket: {} ``` #### Run @@ -672,28 +668,28 @@ document: version: '0.1.0' do: - - name: runContainer - run: - container: - image: fake-image - - - name: runScript - run: - script: - language: js - code: > - Some cool multiline script - - - name: runShell - run: - shell: - command: 'echo "Hello, ${ .user.name }"' - - - name: runWorkflow - run: - workflow: - reference: another-one:0.1.0 - input: {} + - runContainer: + run: + container: + image: fake-image + + - runScript: + run: + script: + language: js + code: > + Some cool multiline script + + - runShell: + run: + shell: + command: 'echo "Hello, ${ .user.name }"' + + - runWorkflow: + run: + workflow: + reference: another-one:0.1.0 + input: {} ``` ##### Container Process @@ -719,10 +715,10 @@ document: name: sample-workflow version: '0.1.0' do: - - name: runContainer - run: - container: - image: fake-image + - runContainer: + run: + container: + image: fake-image ``` ##### Script Process @@ -747,12 +743,12 @@ document: name: sample-workflow version: '0.1.0' do: - - name: runScript - run: - script: - language: js - code: > - Some cool multiline script + - runScript: + run: + script: + language: js + code: > + Some cool multiline script ``` ##### Shell Process @@ -776,10 +772,10 @@ document: name: sample-workflow version: '0.1.0' do: - - name: runShell - run: - shell: - command: 'echo "Hello, ${ .user.name }"' + - runShell: + run: + shell: + command: 'echo "Hello, ${ .user.name }"' ``` ##### Workflow Process @@ -803,12 +799,12 @@ document: name: sample-workflow version: '0.1.0' do: - - name: runShell - run: - workflow: - reference: another-one:0.1.0 - input: - foo: bar + - runShell: + run: + workflow: + reference: another-one:0.1.0 + input: + foo: bar ``` #### Set @@ -830,11 +826,11 @@ document: name: set version: '0.1.0' do: - - name: initialize - set: - shape: circle - size: ${ .configuration.size } - fill: ${ .configuration.fill } + - initialize: + set: + shape: circle + size: ${ .configuration.size } + fill: ${ .configuration.fill } ``` #### Switch @@ -856,41 +852,34 @@ document: name: sample-workflow version: '0.1.0' do: - - name: processOrder - switch: - - name: case1 - when: .orderType == "electronic" - then: processElectronicOrder - - name: case2 - when: .orderType == "physical" - then: processPhysicalOrder - - name: default - then: handleUnknownOrderType - - name: processElectronicOrder + - processOrder: + switch: + - case1: + when: .orderType == "electronic" + then: processElectronicOrder + - case2: + when: .orderType == "physical" + then: processPhysicalOrder + - default: + then: handleUnknownOrderType + - processElectronicOrder: execute: sequentially: - - name: validatePayment - ... - - name: fulfillOrder - ... + - validatePayment: {} + - fulfillOrder: {} then: exit - - name: processPhysicalOrder - execute: - sequentially: - - name: checkInventory - ... - - name: packItems - ... - - name: scheduleShipping - ... + - processPhysicalOrder: + execute: + sequentially: + - checkInventory: {} + - packItems: {} + - scheduleShipping: {} then: exit - - name: handleUnknownOrderType + - handleUnknownOrderType: execute: sequentially: - - name: logWarning - ... - - name: notifyAdmin - ... + - logWarning: {} + - notifyAdmin: {} ``` ##### Switch Case @@ -923,26 +912,26 @@ document: name: sample-workflow version: '0.1.0' do: - - name: processOrder - try: - call: http - with: - method: get - endpoint: https:// - catch: - errors: + - processOrder: + try: + call: http with: - type: https://serverlessworkflow.io.io/dsl/errors/types/communication - status: 503 - as: error - retry: - delay: - seconds: 3 - backoff: - exponential: {} - limit: - attempt: - count: 5 + method: get + endpoint: https:// + catch: + errors: + with: + type: https://serverlessworkflow.io.io/dsl/errors/types/communication + status: 503 + as: error + retry: + delay: + seconds: 3 + backoff: + exponential: {} + limit: + attempt: + count: 5 ``` ##### Catch @@ -979,9 +968,9 @@ document: name: sample-workflow version: '0.1.0' do: - - name: delay10Seconds - wait: - seconds: 10 + - delay10Seconds: + wait: + seconds: 10 ``` ### Flow Directive @@ -1047,13 +1036,13 @@ use: sampleBasicFromSecret: basic: usernamePasswordSecret do: - - name: getMessages - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: sampleBasicFromSecret + - getMessages: + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: sampleBasicFromSecret ``` #### Basic Authentication @@ -1082,13 +1071,13 @@ use: username: admin password: 123 do: - - name: getMessages - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: sampleBasic + - getMessages: + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: sampleBasic ``` #### Bearer Authentication @@ -1110,15 +1099,15 @@ document: name: sample-workflow version: '0.1.0' do: - - name: getMessages - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: - bearer: - token: ${ .user.token } + - getMessages: + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: + bearer: + token: ${ .user.token } ``` #### Certificate Authentication @@ -1155,21 +1144,21 @@ document: name: sample-workflow version: '0.1.0' do: - - name: getMessages - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: - oauth2: - authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration - grant: client-credentials - client: - id: workflow-runtime - secret: ********** - scopes: [ api ] - audiences: [ runtime ] + - getMessages: + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: + oauth2: + authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration + grant: client-credentials + client: + id: workflow-runtime + secret: ********** + scopes: [ api ] + audiences: [ runtime ] ``` ##### OAUTH2 Token @@ -1209,28 +1198,28 @@ document: version: '0.1.0' use: extensions: - - name: logging - extend: all - before: - call: http - with: - method: post - endpoint: https://fake.log.collector.com - body: - message: "${ \"Executing task '\($task.reference)'...\" }" - after: - call: http - with: - method: post - endpoint: https://fake.log.collector.com - body: - message: "${ \"Executed task '\($task.reference)'...\" }" + - logging: + extend: all + before: + call: http + with: + method: post + endpoint: https://fake.log.collector.com + body: + message: "${ \"Executing task '\($task.reference)'...\" }" + after: + call: http + with: + method: post + endpoint: https://fake.log.collector.com + body: + message: "${ \"Executed task '\($task.reference)'...\" }" do: - - name: get - call: http - with: - method: get - endpoint: https://fake.com/sample + - get: + call: http + with: + method: get + endpoint: https://fake.com/sample ``` *Intercept HTTP calls to 'https://mocked.service.com' and mock its response:* @@ -1242,24 +1231,24 @@ document: version: '0.1.0' use: extensions: - - name: mockService - extend: http - when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) - before: - set: - statusCode: 200 - headers: - Content-Type: application/json - content: - foo: - bar: baz - then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected + - mockService: + extend: http + when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) + before: + set: + statusCode: 200 + headers: + Content-Type: application/json + content: + foo: + bar: baz + then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected do: - - name: get - call: http - with: - method: get - endpoint: https://fake.com/sample + - get: + call: http + with: + method: get + endpoint: https://fake.com/sample ``` ### Error @@ -1500,9 +1489,9 @@ document: name: sample version: '0.1.0' do: - - name: waitFor60Seconds - wait: - seconds: 60 + - waitFor60Seconds: + wait: + seconds: 60 timeout: after: seconds: 30 diff --git a/dsl.md b/dsl.md index 28006471..9be281dc 100644 --- a/dsl.md +++ b/dsl.md @@ -236,11 +236,11 @@ Errors are critical for both authors and runtimes as they provide a means to com *Retrying 5 times when an error with 503 is caught:* ```yaml try: - - call: http - with: - method: get - endpoint: - uri: https://example-service.com/healthz + call: http + with: + method: get + endpoint: + uri: https://example-service.com/healthz catch: errors: with: @@ -342,10 +342,10 @@ document: version: '0.1.0' do: - - name: validateEmail - call: https://github.com/myorg/functions/validateEmailAddress@v1 - with: - emailAddress: ${ .userEmail } + - validateEmail: + call: https://github.com/myorg/functions/validateEmailAddress@v1 + with: + emailAddress: ${ .userEmail } ``` ##### Publishing a Custom Function @@ -426,11 +426,11 @@ use: body: message: "${ \"Executed task '\($task.reference)'...\" }" do: - - name: get - call: http - with: - method: get - uri: https://fake.com/sample + - get: + call: http + with: + method: get + uri: https://fake.com/sample ``` ### External Resources From b8f3e29bbd1d9c45140e484775845e17011e068d Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 09:37:13 +0000 Subject: [PATCH 30/51] chore: update examples Signed-off-by: Matthias Pichler --- examples/accumulate-room-readings.yaml | 64 ++++++++--------- examples/asyncapi.yaml | 28 ++++---- examples/bearer-auth-uri-format.yaml | 18 ++--- examples/bearer-auth.yaml | 18 ++--- examples/call-http-shorthand-endpoint.yaml | 10 +-- examples/mock-service-extension.yaml | 36 +++++----- examples/switch-then-string.yaml | 84 +++++++++++----------- examples/use-authentication.yaml | 14 ++-- 8 files changed, 136 insertions(+), 136 deletions(-) diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index 6f953eb1..fc807c9a 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -4,43 +4,43 @@ document: name: accumulate-room-readings version: 1.0.0-alpha1 do: - - name: consumeReading - listen: - to: - all: - - with: - source: https://my.home.com/sensor - type: my.home.sensors.temperature - correlate: - roomId: - from: .roomid - output: - from: .data.reading - - with: - source: https://my.home.com/sensor - type: my.home.sensors.humidity - correlate: - roomId: - from: .roomid - output: - from: .data.reading + - consumeReading: + listen: + to: + all: + - with: + source: https://my.home.com/sensor + type: my.home.sensors.temperature + correlate: + roomId: + from: .roomid + output: + from: .data.reading + - with: + source: https://my.home.com/sensor + type: my.home.sensors.humidity + correlate: + roomId: + from: .roomid + output: + from: .data.reading as: readings - - name: logReading - for: - each: reading - in: .readings - do: + - logReading: + for: + each: reading + in: .readings + do: + call: openapi + with: + document: + uri: http://myorg.io/ordersservices.json + operationId: logreading + - generateReport: call: openapi with: document: uri: http://myorg.io/ordersservices.json - operationId: logreading - - name: generateReport - call: openapi - with: - document: - uri: http://myorg.io/ordersservices.json - operationId: produceReport + operationId: produceReport timeout: after: hours: 1 \ No newline at end of file diff --git a/examples/asyncapi.yaml b/examples/asyncapi.yaml index d2a82b36..917160c0 100644 --- a/examples/asyncapi.yaml +++ b/examples/asyncapi.yaml @@ -4,17 +4,17 @@ document: name: bearer-auth version: 1.0.0-alpha1 do: - - name: greetUser - call: asyncapi - with: - document: - uri: https://fake.com/docs/asyncapi.json - operationRef: findPetsByStatus - server: staging - message: getPetByStatusQuery - binding: http - payload: - petId: ${ .pet.id } - authentication: - bearer: - token: ${ .token } + - greetUser: + call: asyncapi + with: + document: + uri: https://fake.com/docs/asyncapi.json + operationRef: findPetsByStatus + server: staging + message: getPetByStatusQuery + binding: http + payload: + petId: ${ .pet.id } + authentication: + bearer: + token: ${ .token } diff --git a/examples/bearer-auth-uri-format.yaml b/examples/bearer-auth-uri-format.yaml index fd1a3e45..0d0328e9 100644 --- a/examples/bearer-auth-uri-format.yaml +++ b/examples/bearer-auth-uri-format.yaml @@ -4,12 +4,12 @@ document: name: bearer-auth-uri-format version: 1.0.0-alpha1 do: - - name: getPetById - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/1 - authentication: - bearer: - token: ${ .token } + - getPetById: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/1 + authentication: + bearer: + token: ${ .token } diff --git a/examples/bearer-auth.yaml b/examples/bearer-auth.yaml index ba69d35c..b28e2e07 100644 --- a/examples/bearer-auth.yaml +++ b/examples/bearer-auth.yaml @@ -4,12 +4,12 @@ document: name: bearer-auth version: 1.0.0-alpha1 do: - - name: getPetById - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} - authentication: - bearer: - token: ${ .token } + - getPetById: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + authentication: + bearer: + token: ${ .token } diff --git a/examples/call-http-shorthand-endpoint.yaml b/examples/call-http-shorthand-endpoint.yaml index c198a8b7..0624bef5 100644 --- a/examples/call-http-shorthand-endpoint.yaml +++ b/examples/call-http-shorthand-endpoint.yaml @@ -4,8 +4,8 @@ document: name: call-http-shorthand-endpoint version: 1.0.0-alpha1 do: - - name: getPetById - call: http - with: - method: get - endpoint: https://petstore.swagger.io/v2/pet/{petId} + - getPetById: + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/{petId} diff --git a/examples/mock-service-extension.yaml b/examples/mock-service-extension.yaml index bebded0a..a9d43459 100644 --- a/examples/mock-service-extension.yaml +++ b/examples/mock-service-extension.yaml @@ -5,22 +5,22 @@ document: version: '0.1.0' use: extensions: - - name: mockService - extend: call - when: ($task.with.endpoint != null and ($task.with.endpoint | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) - before: - set: - statusCode: 200 - headers: - Content-Type: application/json - content: - foo: - bar: baz - then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected + - mockService: + extend: call + when: ($task.with.endpoint != null and ($task.with.endpoint | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com"))) + before: + set: + statusCode: 200 + headers: + Content-Type: application/json + content: + foo: + bar: baz + then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected do: - - name: get - call: http - with: - method: get - endpoint: - uri: https://fake.com/sample \ No newline at end of file + - get: + call: http + with: + method: get + endpoint: + uri: https://fake.com/sample \ No newline at end of file diff --git a/examples/switch-then-string.yaml b/examples/switch-then-string.yaml index 7e6de9ee..6de3235e 100644 --- a/examples/switch-then-string.yaml +++ b/examples/switch-then-string.yaml @@ -4,45 +4,45 @@ document: name: sample-workflow version: '0.1.0' do: - - name: processOrder - switch: - - name: case1 - when: .orderType == "electronic" - then: processElectronicOrder - - name: case2 - when: .orderType == "physical" - then: processPhysicalOrder - - name: default - then: handleUnknownOrderType - - name: processElectronicOrder - execute: - sequentially: - - name: validatePayment - set: - validate: true - - name: fulfillOrder - set: - status: fulfilled - then: exit - - name: processPhysicalOrder - execute: - sequentially: - - name: checkInventory - set: - inventory: clear - - name: packItems - set: - items: 1 - - name: scheduleShipping - set: - address: Elmer St - then: exit - - name: handleUnknownOrderType - execute: - sequentially: - - name: logWarning - set: - log: warn - - name: notifyAdmin - set: - message: something's wrong \ No newline at end of file + - processOrder: + switch: + - case1: + when: .orderType == "electronic" + then: processElectronicOrder + - case2: + when: .orderType == "physical" + then: processPhysicalOrder + - default: + then: handleUnknownOrderType + - processElectronicOrder: + execute: + sequentially: + - validatePayment: + set: + validate: true + - fulfillOrder: + set: + status: fulfilled + then: exit + - processPhysicalOrder: + execute: + sequentially: + - checkInventory: + set: + inventory: clear + - packItems: + set: + items: 1 + - scheduleShipping: + set: + address: Elmer St + then: exit + - handleUnknownOrderType: + execute: + sequentially: + - logWarning: + set: + log: warn + - notifyAdmin: + set: + message: something's wrong \ No newline at end of file diff --git a/examples/use-authentication.yaml b/examples/use-authentication.yaml index 0b8add97..a44a47b6 100644 --- a/examples/use-authentication.yaml +++ b/examples/use-authentication.yaml @@ -9,10 +9,10 @@ use: bearer: token: ${ .token } do: - - name: getPetById - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} - authentication: petStoreAuth + - getPetById: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + authentication: petStoreAuth From e695c2f78d63ce13e44166516a56dd2c40daf39b Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 09:41:41 +0000 Subject: [PATCH 31/51] feat: update schema to use named tasks Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 54 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 9cecadc1..39a1445a 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -53,7 +53,11 @@ properties: extensions: type: array items: - $ref: '#/$defs/extension' + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/extension' description: The workflow's extensions. functions: type: object @@ -75,7 +79,11 @@ properties: type: array minItems: 1 items: - $ref: '#/$defs/task' + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' description: Defines the tasks the workflow must perform timeout: $ref: '#/$defs/timeout' @@ -103,9 +111,6 @@ $defs: task: type: object properties: - name: - type: string - description: The task's name. **SHOULD** be unique within an array. Required if you want to reference the task in `then`. input: $ref: '#/$defs/input' description: Configure the task's input. @@ -286,7 +291,11 @@ $defs: type: array minItems: 2 items: - $ref: '#/$defs/task' + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' description: A list of the tasks to perform concurrently. compete: type: boolean @@ -297,7 +306,11 @@ $defs: type: array minItems: 2 items: - $ref: '#/$defs/task' + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' description: A list of the tasks to perform sequentially. required: [ sequentially ] description: Configures the task execution strategy to use @@ -506,16 +519,20 @@ $defs: minItems: 1 items: type: object - properties: - name: - type: string - description: The case's name. - when: - type: string - description: A runtime expression used to determine whether or not the case matches. - then: - $ref: '#/$defs/flowDirective' - description: The flow directive to execute when the case matches. + minProperties: 1 + maxProperties: 1 + additionalProperties: + type: object + properties: + name: + type: string + description: The case's name. + when: + type: string + description: A runtime expression used to determine whether or not the case matches. + then: + $ref: '#/$defs/flowDirective' + description: The flow directive to execute when the case matches. required: [ switch ] description: Enables conditional branching within workflows, allowing them to dynamically select different paths based on specified conditions or criteria tryTask: @@ -758,9 +775,6 @@ $defs: extension: type: object properties: - name: - type: string - description: The extension's name. extend: type: string enum: [ call, composite, emit, for, listen, raise, run, set, switch, try, wait, all ] From d7220a2fb6176c244849c2b250367e70820264d4 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 10:19:04 +0000 Subject: [PATCH 32/51] refactor: make for.do an array as well Signed-off-by: Matthias Pichler --- dsl-reference.md | 15 ++++++++------- examples/accumulate-room-readings.yaml | 11 ++++++----- schema/workflow.yaml | 20 +++++++++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index a78cfaf1..28b3c390 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -560,13 +560,14 @@ do: at: index while: .vet != null do: - listen: - to: - one: - with: - type: com.fake.petclinic.pets.checkup.completed.v2 - output: - to: '.pets + [{ "id": $pet.id }]' + - checkFleas: + listen: + to: + one: + with: + type: com.fake.petclinic.pets.checkup.completed.v2 + output: + to: '.pets + [{ "id": $pet.id }]' ``` #### Listen diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index fc807c9a..c1c45967 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -30,11 +30,12 @@ do: each: reading in: .readings do: - call: openapi - with: - document: - uri: http://myorg.io/ordersservices.json - operationId: logreading + - callLogReading: + call: openapi + with: + document: + uri: http://myorg.io/ordersservices.json + operationId: logreading - generateReport: call: openapi with: diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 39a1445a..75e00aea 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -76,14 +76,7 @@ properties: description: The workflow's secrets. description: Defines the workflow's reusable components. do: - type: array - minItems: 1 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' + $ref: '#/$defs/do' description: Defines the tasks the workflow must perform timeout: $ref: '#/$defs/timeout' @@ -108,6 +101,15 @@ properties: description: Specifies the events that trigger the workflow execution. description: Schedules the workflow $defs: + do: + type: array + minItems: 1 + items: + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' task: type: object properties: @@ -380,7 +382,7 @@ $defs: type: string description: A runtime expression that represents the condition, if any, that must be met for the iteration to continue. do: - $ref: '#/$defs/task' + $ref: '#/$defs/do' description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets. required: [ for, do ] listenTask: From 28742a54133b1783b57b4dfd947fb353dd3b90d4 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 10:27:25 +0000 Subject: [PATCH 33/51] Revert "refactor: make for.do an array as well" This reverts commit 119b7b84ff2ab4fd7b8096ea2139e6b68a695ad7. Signed-off-by: Matthias Pichler --- dsl-reference.md | 15 +++++++-------- examples/accumulate-room-readings.yaml | 11 +++++------ schema/workflow.yaml | 20 +++++++++----------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 28b3c390..a78cfaf1 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -560,14 +560,13 @@ do: at: index while: .vet != null do: - - checkFleas: - listen: - to: - one: - with: - type: com.fake.petclinic.pets.checkup.completed.v2 - output: - to: '.pets + [{ "id": $pet.id }]' + listen: + to: + one: + with: + type: com.fake.petclinic.pets.checkup.completed.v2 + output: + to: '.pets + [{ "id": $pet.id }]' ``` #### Listen diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index c1c45967..fc807c9a 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -30,12 +30,11 @@ do: each: reading in: .readings do: - - callLogReading: - call: openapi - with: - document: - uri: http://myorg.io/ordersservices.json - operationId: logreading + call: openapi + with: + document: + uri: http://myorg.io/ordersservices.json + operationId: logreading - generateReport: call: openapi with: diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 75e00aea..39a1445a 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -76,7 +76,14 @@ properties: description: The workflow's secrets. description: Defines the workflow's reusable components. do: - $ref: '#/$defs/do' + type: array + minItems: 1 + items: + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' description: Defines the tasks the workflow must perform timeout: $ref: '#/$defs/timeout' @@ -101,15 +108,6 @@ properties: description: Specifies the events that trigger the workflow execution. description: Schedules the workflow $defs: - do: - type: array - minItems: 1 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' task: type: object properties: @@ -382,7 +380,7 @@ $defs: type: string description: A runtime expression that represents the condition, if any, that must be met for the iteration to continue. do: - $ref: '#/$defs/do' + $ref: '#/$defs/task' description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets. required: [ for, do ] listenTask: From 5abfe4d571181511eb1a479ff45cb38d7ef3e735 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 10:46:38 +0000 Subject: [PATCH 34/51] test: update ctk Signed-off-by: Matthias Pichler --- ctk/features/call.feature | 88 ++++++++++----------- ctk/features/composite.feature | 50 ++++++------ ctk/features/data-flow.feature | 58 +++++++------- ctk/features/emit.feature | 16 ++-- ctk/features/flow.feature | 42 +++++----- ctk/features/for.feature | 14 ++-- ctk/features/raise.feature | 12 +-- ctk/features/set.feature | 10 +-- ctk/features/switch.feature | 138 ++++++++++++++++----------------- ctk/features/try.feature | 60 +++++++------- 10 files changed, 244 insertions(+), 244 deletions(-) diff --git a/ctk/features/call.feature b/ctk/features/call.feature index 6ebcfbe2..d61e558d 100644 --- a/ctk/features/call.feature +++ b/ctk/features/call.feature @@ -15,14 +15,14 @@ Feature: Call Task namespace: default name: http-call-with-content-output do: - getFirstAvailablePet: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/findByStatus?status={status} - output: - from: .[0] + - getFirstAvailablePet: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/findByStatus?status={status} + output: + from: .[0] """ And given the workflow input is: """yaml @@ -43,13 +43,13 @@ Feature: Call Task namespace: default name: http-call-with-response-output do: - getPetById: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} - output: response + - getPetById: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + output: response """ And given the workflow input is: """yaml @@ -70,16 +70,16 @@ Feature: Call Task namespace: default name: http-call-with-basic-auth do: - getSecuredEndpoint: - call: http - with: - method: get - endpoint: - uri: https://httpbin.org/basic-auth/{username}/{password} - authentication: - basic: - username: ${ .username } - password: ${ .password } + - getSecuredEndpoint: + call: http + with: + method: get + endpoint: + uri: https://httpbin.org/basic-auth/{username}/{password} + authentication: + basic: + username: ${ .username } + password: ${ .password } """ And given the workflow input is: """yaml @@ -99,16 +99,16 @@ Feature: Call Task namespace: default name: openapi-call-with-content-output do: - getPetsByStatus: - call: openapi - with: - document: - uri: https://petstore.swagger.io/v2/swagger.json - operation: findPetsByStatus - parameters: - status: ${ .status } - output: - from: . | length + - getPetsByStatus: + call: openapi + with: + document: + uri: https://petstore.swagger.io/v2/swagger.json + operation: findPetsByStatus + parameters: + status: ${ .status } + output: + from: . | length """ And given the workflow input is: """yaml @@ -127,15 +127,15 @@ Feature: Call Task namespace: default name: openapi-call-with-response-output do: - getPetById: - call: openapi - with: - document: - uri: https://petstore.swagger.io/v2/swagger.json - operation: getPetById - parameters: - petId: ${ .petId } - output: response + - getPetById: + call: openapi + with: + document: + uri: https://petstore.swagger.io/v2/swagger.json + operation: getPetById + parameters: + petId: ${ .petId } + output: response """ And given the workflow input is: """yaml diff --git a/ctk/features/composite.feature b/ctk/features/composite.feature index aad61fc0..e504d28f 100644 --- a/ctk/features/composite.feature +++ b/ctk/features/composite.feature @@ -12,18 +12,18 @@ Feature: Composite Task namespace: default name: composite-sequential do: - setRGB: - execute: - sequentially: - setRed: - set: - colors: ${ .colors + ["red"] } - setGreen: - set: - colors: ${ .colors + ["green"] } - setBlue: - set: - colors: ${ .colors + ["blue"] } + - setRGB: + execute: + sequentially: + - setRed: + set: + colors: ${ .colors + ["red"] } + - setGreen: + set: + colors: ${ .colors + ["green"] } + - setBlue: + set: + colors: ${ .colors + ["blue"] } """ When the workflow is executed Then the workflow should complete with output: @@ -40,19 +40,19 @@ Feature: Composite Task namespace: default name: composite-sequential do: - setRGB: - execute: - concurrently: - setRed: - set: - colors: ${ .colors + ["red"] } - setGreen: - set: - colors: ${ .colors + ["green"] } - setBlue: - set: - colors: ${ .colors + ["blue"] } - compete: true + - setRGB: + execute: + concurrently: + - setRed: + set: + colors: ${ .colors + ["red"] } + - setGreen: + set: + colors: ${ .colors + ["green"] } + - setBlue: + set: + colors: ${ .colors + ["blue"] } + compete: true """ When the workflow is executed Then the workflow should complete diff --git a/ctk/features/data-flow.feature b/ctk/features/data-flow.feature index 7b06f226..350db5ce 100644 --- a/ctk/features/data-flow.feature +++ b/ctk/features/data-flow.feature @@ -12,11 +12,11 @@ Feature: Data Flow namespace: default name: output-filtering do: - setUsername: - input: - from: .user.claims.subject #filters the input of the task, using only the user's subject - set: - playerId: ${ . } + - setUsername: + input: + from: .user.claims.subject #filters the input of the task, using only the user's subject + set: + playerId: ${ . } """ And given the workflow input is: """yaml @@ -39,14 +39,14 @@ Feature: Data Flow namespace: default name: output-filtering do: - getPetById: - call: http - with: - method: get - 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 + - getPetById: + call: http + with: + method: get + 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 """ And given the workflow input is: """yaml @@ -67,22 +67,22 @@ Feature: Data Flow namespace: default name: non-object-output do: - getPetById1: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables - output: - from: .id - getPetById2: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/2 - output: - from: '{ ids: [ $input, .id ] }' + - getPetById1: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables + output: + from: .id + - getPetById2: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/2 + output: + from: '{ ids: [ $input, .id ] }' """ When the workflow is executed Then the workflow should complete with output: diff --git a/ctk/features/emit.feature b/ctk/features/emit.feature index 8954a4c2..559a9202 100644 --- a/ctk/features/emit.feature +++ b/ctk/features/emit.feature @@ -12,14 +12,14 @@ Feature: Emit Task namespace: default name: emit do: - emitUserGreeted: - emit: - event: - with: - source: https://fake-source.com - type: com.fake-source.user.greeted.v1 - data: - greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" } + - emitUserGreeted: + emit: + event: + with: + source: https://fake-source.com + type: com.fake-source.user.greeted.v1 + data: + greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" } """ And given the workflow input is: """yaml diff --git a/ctk/features/flow.feature b/ctk/features/flow.feature index 705a34b3..16917946 100644 --- a/ctk/features/flow.feature +++ b/ctk/features/flow.feature @@ -11,15 +11,15 @@ Feature: Flow Directive namespace: default name: implicit-sequence do: - setRed: - set: - colors: '${ .colors + [ "red" ] }' - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' """ When the workflow is executed Then the workflow should complete with output: @@ -38,18 +38,18 @@ Feature: Flow Directive namespace: default name: explicit-sequence do: - setRed: - set: - colors: '${ .colors + [ "red" ] }' - then: setGreen - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - then: end - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - then: setBlue + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + then: setGreen + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + then: end + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + then: setBlue """ When the workflow is executed Then the workflow should complete with output: diff --git a/ctk/features/for.feature b/ctk/features/for.feature index 43c17e04..00da7946 100644 --- a/ctk/features/for.feature +++ b/ctk/features/for.feature @@ -14,13 +14,13 @@ Feature: For Task namespace: default name: for do: - forEachColor: - for: - each: color - in: '.colors' - do: - set: - processed: '${ { colors: (.processed.colors + [ $color ]), indexes: (.processed.indexes + [ $index ])} }' + - forEachColor: + for: + each: color + in: '.colors' + do: + set: + processed: '${ { colors: (.processed.colors + [ $color ]), indexes: (.processed.indexes + [ $index ])} }' """ And given the workflow input is: """yaml diff --git a/ctk/features/raise.feature b/ctk/features/raise.feature index 58567530..7aafc902 100644 --- a/ctk/features/raise.feature +++ b/ctk/features/raise.feature @@ -11,12 +11,12 @@ Feature: Raise Task namespace: default name: raise-custom-error do: - raiseComplianceError: - raise: - error: - status: 400 - type: https://serverlessworkflow.io/errors/types/compliance - title: Compliance Error + - raiseComplianceError: + raise: + error: + status: 400 + type: https://serverlessworkflow.io/errors/types/compliance + title: Compliance Error """ When the workflow is executed Then the workflow should fault with error: diff --git a/ctk/features/set.feature b/ctk/features/set.feature index 6d748ed9..6f81b4f9 100644 --- a/ctk/features/set.feature +++ b/ctk/features/set.feature @@ -12,11 +12,11 @@ Feature: Set Task namespace: default name: set do: - initialize: - set: - shape: circle - size: ${ .configuration.size } - fill: ${ .configuration.fill } + - initialize: + set: + shape: circle + size: ${ .configuration.size } + fill: ${ .configuration.fill } """ And given the workflow input is: """yaml diff --git a/ctk/features/switch.feature b/ctk/features/switch.feature index 01471cc0..bba64c00 100644 --- a/ctk/features/switch.feature +++ b/ctk/features/switch.feature @@ -11,29 +11,29 @@ Feature: Switch Task namespace: default name: switch-match do: - switchColor: - switch: - red: - when: '.color == "red"' - then: setRed - green: - when: '.color == "green"' - then: setGreen - blue: - when: '.color == "blue"' - then: setBlue - setRed: - set: - colors: '${ .colors + [ "red" ] }' - then: end - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - then: end - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - then: end + - switchColor: + switch: + - red: + when: '.color == "red"' + then: setRed + - green: + when: '.color == "green"' + then: setGreen + - blue: + when: '.color == "blue"' + then: setBlue + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + then: end + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + then: end + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + then: end """ And given the workflow input is: """yaml @@ -55,27 +55,27 @@ Feature: Switch Task namespace: default name: switch-default-implicit do: - switchColor: - switch: - red: - when: '.color == "red"' - then: setRed - green: - when: '.color == "green"' - then: setGreen - blue: - when: '.color == "blue"' - then: setBlue - then: end - setRed: - set: - colors: '${ .colors + [ "red" ] }' - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' + - switchColor: + switch: + - red: + when: '.color == "red"' + then: setRed + - green: + when: '.color == "green"' + then: setGreen + - blue: + when: '.color == "blue"' + then: setBlue + then: end + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' """ And given the workflow input is: """yaml @@ -97,31 +97,31 @@ Feature: Switch Task namespace: default name: switch-default-implicit do: - switchColor: - switch: - red: - when: '.color == "red"' - then: setRed - green: - when: '.color == "green"' - then: setGreen - blue: - when: '.color == "blue"' - then: setBlue - anyOtherColor: - then: setCustomColor - setRed: - set: - colors: '${ .colors + [ "red" ] }' - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - setCustomColor: - set: - colors: '${ .colors + [ $input.color ] }' + - switchColor: + switch: + - red: + when: '.color == "red"' + then: setRed + - green: + when: '.color == "green"' + then: setGreen + - blue: + when: '.color == "blue"' + then: setBlue + - anyOtherColor: + then: setCustomColor + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + - setCustomColor: + set: + colors: '${ .colors + [ $input.color ] }' """ And given the workflow input is: """yaml diff --git a/ctk/features/try.feature b/ctk/features/try.feature index cd5fb272..e668f6b3 100644 --- a/ctk/features/try.feature +++ b/ctk/features/try.feature @@ -15,22 +15,22 @@ Feature: Try Task namespace: default name: try-catch-404 do: - tryGetPet: - try: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} - catch: - errors: + - tryGetPet: + try: + call: http with: - type: https://serverlessworkflow.io/dsl/errors/types/communication - status: 404 - as: err - do: - set: - error: ${ $err } + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} + catch: + errors: + with: + type: https://serverlessworkflow.io/dsl/errors/types/communication + status: 404 + as: err + do: + set: + error: ${ $err } """ And given the workflow input is: """yaml @@ -56,22 +56,22 @@ Feature: Try Task namespace: default name: try-catch-503 do: - tryGetPet: - try: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} - catch: - errors: + - tryGetPet: + try: + call: http with: - type: https://serverlessworkflow.io/dsl/errors/types/communication - status: 503 - as: err - do: - set: - error: ${ $err } + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} + catch: + errors: + with: + type: https://serverlessworkflow.io/dsl/errors/types/communication + status: 503 + as: err + do: + set: + error: ${ $err } """ And given the workflow input is: """yaml From f50bf6c2ef635472e427ee1405e97ffeec64c7a1 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 10:57:04 +0000 Subject: [PATCH 35/51] chore: update examples Signed-off-by: Matthias Pichler --- examples/accumulate-room-readings.yaml | 67 +++++++++++----------- examples/asyncapi.yaml | 27 +++++---- examples/bearer-auth-uri-format.yaml | 17 +++--- examples/bearer-auth.yaml | 17 +++--- examples/call-http-shorthand-endpoint.yaml | 9 ++- examples/do-single.yaml | 10 ++++ examples/mock-service-extension.yaml | 11 ++-- examples/switch-then-string.yaml | 30 +++++----- examples/use-authentication.yaml | 13 ++--- 9 files changed, 102 insertions(+), 99 deletions(-) create mode 100644 examples/do-single.yaml diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index fc807c9a..3b6d38f8 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -4,43 +4,44 @@ document: name: accumulate-room-readings version: 1.0.0-alpha1 do: - - consumeReading: - listen: - to: - all: - - with: - source: https://my.home.com/sensor - type: my.home.sensors.temperature - correlate: - roomId: - from: .roomid - output: - from: .data.reading - - with: - source: https://my.home.com/sensor - type: my.home.sensors.humidity - correlate: - roomId: - from: .roomid - output: - from: .data.reading - as: readings - - logReading: - for: - each: reading - in: .readings - do: + sequentially: + - consumeReading: + listen: + to: + all: + - with: + source: https://my.home.com/sensor + type: my.home.sensors.temperature + correlate: + roomId: + from: .roomid + output: + from: .data.reading + - with: + source: https://my.home.com/sensor + type: my.home.sensors.humidity + correlate: + roomId: + from: .roomid + output: + from: .data.reading + as: readings + - logReading: + for: + each: reading + in: .readings + do: + call: openapi + with: + document: + uri: http://myorg.io/ordersservices.json + operationId: logreading + - generateReport: call: openapi with: document: uri: http://myorg.io/ordersservices.json - operationId: logreading - - generateReport: - call: openapi - with: - document: - uri: http://myorg.io/ordersservices.json - operationId: produceReport + operationId: produceReport timeout: after: hours: 1 \ No newline at end of file diff --git a/examples/asyncapi.yaml b/examples/asyncapi.yaml index 917160c0..ca6ff26d 100644 --- a/examples/asyncapi.yaml +++ b/examples/asyncapi.yaml @@ -4,17 +4,16 @@ document: name: bearer-auth version: 1.0.0-alpha1 do: - - greetUser: - call: asyncapi - with: - document: - uri: https://fake.com/docs/asyncapi.json - operationRef: findPetsByStatus - server: staging - message: getPetByStatusQuery - binding: http - payload: - petId: ${ .pet.id } - authentication: - bearer: - token: ${ .token } + call: asyncapi + with: + document: + uri: https://fake.com/docs/asyncapi.json + operationRef: findPetsByStatus + server: staging + message: getPetByStatusQuery + binding: http + payload: + petId: ${ .pet.id } + authentication: + bearer: + token: ${ .token } diff --git a/examples/bearer-auth-uri-format.yaml b/examples/bearer-auth-uri-format.yaml index 0d0328e9..2a0700ec 100644 --- a/examples/bearer-auth-uri-format.yaml +++ b/examples/bearer-auth-uri-format.yaml @@ -4,12 +4,11 @@ document: name: bearer-auth-uri-format version: 1.0.0-alpha1 do: - - getPetById: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/1 - authentication: - bearer: - token: ${ .token } + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/1 + authentication: + bearer: + token: ${ .token } diff --git a/examples/bearer-auth.yaml b/examples/bearer-auth.yaml index b28e2e07..46e72bf1 100644 --- a/examples/bearer-auth.yaml +++ b/examples/bearer-auth.yaml @@ -4,12 +4,11 @@ document: name: bearer-auth version: 1.0.0-alpha1 do: - - getPetById: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} - authentication: - bearer: - token: ${ .token } + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + authentication: + bearer: + token: ${ .token } diff --git a/examples/call-http-shorthand-endpoint.yaml b/examples/call-http-shorthand-endpoint.yaml index 0624bef5..52b606b2 100644 --- a/examples/call-http-shorthand-endpoint.yaml +++ b/examples/call-http-shorthand-endpoint.yaml @@ -4,8 +4,7 @@ document: name: call-http-shorthand-endpoint version: 1.0.0-alpha1 do: - - getPetById: - call: http - with: - method: get - endpoint: https://petstore.swagger.io/v2/pet/{petId} + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/{petId} diff --git a/examples/do-single.yaml b/examples/do-single.yaml new file mode 100644 index 00000000..52b606b2 --- /dev/null +++ b/examples/do-single.yaml @@ -0,0 +1,10 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: call-http-shorthand-endpoint + version: 1.0.0-alpha1 +do: + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/{petId} diff --git a/examples/mock-service-extension.yaml b/examples/mock-service-extension.yaml index a9d43459..4a6c7724 100644 --- a/examples/mock-service-extension.yaml +++ b/examples/mock-service-extension.yaml @@ -18,9 +18,8 @@ use: bar: baz then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected do: - - get: - call: http - with: - method: get - endpoint: - uri: https://fake.com/sample \ No newline at end of file + call: http + with: + method: get + endpoint: + uri: https://fake.com/sample \ No newline at end of file diff --git a/examples/switch-then-string.yaml b/examples/switch-then-string.yaml index 6de3235e..9518f542 100644 --- a/examples/switch-then-string.yaml +++ b/examples/switch-then-string.yaml @@ -4,18 +4,18 @@ document: name: sample-workflow version: '0.1.0' do: - - processOrder: - switch: - - case1: - when: .orderType == "electronic" - then: processElectronicOrder - - case2: - when: .orderType == "physical" - then: processPhysicalOrder - - default: - then: handleUnknownOrderType - - processElectronicOrder: - execute: + sequentially: + - processOrder: + switch: + - case1: + when: .orderType == "electronic" + then: processElectronicOrder + - case2: + when: .orderType == "physical" + then: processPhysicalOrder + - default: + then: handleUnknownOrderType + - processElectronicOrder: sequentially: - validatePayment: set: @@ -24,8 +24,7 @@ do: set: status: fulfilled then: exit - - processPhysicalOrder: - execute: + - processPhysicalOrder: sequentially: - checkInventory: set: @@ -37,8 +36,7 @@ do: set: address: Elmer St then: exit - - handleUnknownOrderType: - execute: + - handleUnknownOrderType: sequentially: - logWarning: set: diff --git a/examples/use-authentication.yaml b/examples/use-authentication.yaml index a44a47b6..613764df 100644 --- a/examples/use-authentication.yaml +++ b/examples/use-authentication.yaml @@ -9,10 +9,9 @@ use: bearer: token: ${ .token } do: - - getPetById: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} - authentication: petStoreAuth + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + authentication: petStoreAuth From 62b5fde17eb462d31b05715ff60a357d70283c28 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 11:03:00 +0000 Subject: [PATCH 36/51] feat: update schema Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 89 +++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 39a1445a..46b7e202 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -76,14 +76,7 @@ properties: description: The workflow's secrets. description: Defines the workflow's reusable components. do: - type: array - minItems: 1 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' + $ref: '#/$defs/task' description: Defines the tasks the workflow must perform timeout: $ref: '#/$defs/timeout' @@ -125,7 +118,9 @@ $defs: description: The flow directive to be performed upon completion of the task. oneOf: - $ref: '#/$defs/callTask' - - $ref: '#/$defs/compositeTask' + - $ref: '#/$defs/sequentialTask' + - $ref: '#/$defs/concurrentTask' + - $ref: '#/$defs/competingTask' - $ref: '#/$defs/emitTask' - $ref: '#/$defs/forTask' - $ref: '#/$defs/listenTask' @@ -280,42 +275,50 @@ $defs: additionalProperties: true description: A name/value mapping of the parameters, if any, to call the function with. required: [ call ] - compositeTask: + sequentialTask: type: object properties: - execute: - type: object - oneOf: - - properties: - concurrently: - type: array - minItems: 2 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' - description: A list of the tasks to perform concurrently. - compete: - type: boolean - description: Indicates whether or not the concurrent tasks are racing against each other, with a single possible winner, which sets the composite task's output. - required: [ concurrently ] - - properties: - sequentially: - type: array - minItems: 2 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' - description: A list of the tasks to perform sequentially. - required: [ sequentially ] - description: Configures the task execution strategy to use - required: [ execute ] - description: Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations + sequentially: + type: array + minItems: 2 + items: + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' + description: A list of the tasks to perform sequentially. + required: [ sequentially ] + concurrentTask: + type: object + properties: + concurrently: + description: A list of the tasks to perform concurrently. + type: array + minItems: 2 + items: + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' + required: [ concurrently ] + competingTask: + type: object + properties: + compete: + type: array + minItems: 2 + items: + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' + description: | + A list of the tasks to perform concurrently and race against each + other, with a single possible winner, which sets the task's output. + required: [ compete ] emitTask: type: object properties: From ecee0c146c73ab48614a26dbd8e57acb6d52fda2 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 11:08:32 +0000 Subject: [PATCH 37/51] test: update ctk files Signed-off-by: Matthias Pichler --- ctk/features/call.feature | 83 ++++++++++++++++------------------ ctk/features/composite.feature | 45 ++++++++---------- ctk/features/data-flow.feature | 57 ++++++++++++----------- ctk/features/emit.feature | 15 +++--- ctk/features/flow.feature | 44 +++++++++--------- ctk/features/for.feature | 13 +++--- ctk/features/raise.feature | 11 ++--- ctk/features/set.feature | 9 ++-- ctk/features/switch.feature | 51 +++++++++++---------- ctk/features/try.feature | 62 ++++++++++++------------- 10 files changed, 188 insertions(+), 202 deletions(-) diff --git a/ctk/features/call.feature b/ctk/features/call.feature index d61e558d..0db32456 100644 --- a/ctk/features/call.feature +++ b/ctk/features/call.feature @@ -15,14 +15,13 @@ Feature: Call Task namespace: default name: http-call-with-content-output do: - - getFirstAvailablePet: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/findByStatus?status={status} - output: - from: .[0] + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/findByStatus?status={status} + output: + from: .[0] """ And given the workflow input is: """yaml @@ -43,13 +42,12 @@ Feature: Call Task namespace: default name: http-call-with-response-output do: - - getPetById: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} - output: response + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + output: response """ And given the workflow input is: """yaml @@ -70,16 +68,15 @@ Feature: Call Task namespace: default name: http-call-with-basic-auth do: - - getSecuredEndpoint: - call: http - with: - method: get - endpoint: - uri: https://httpbin.org/basic-auth/{username}/{password} - authentication: - basic: - username: ${ .username } - password: ${ .password } + call: http + with: + method: get + endpoint: + uri: https://httpbin.org/basic-auth/{username}/{password} + authentication: + basic: + username: ${ .username } + password: ${ .password } """ And given the workflow input is: """yaml @@ -99,16 +96,15 @@ Feature: Call Task namespace: default name: openapi-call-with-content-output do: - - getPetsByStatus: - call: openapi - with: - document: - uri: https://petstore.swagger.io/v2/swagger.json - operation: findPetsByStatus - parameters: - status: ${ .status } - output: - from: . | length + call: openapi + with: + document: + uri: https://petstore.swagger.io/v2/swagger.json + operation: findPetsByStatus + parameters: + status: ${ .status } + output: + from: . | length """ And given the workflow input is: """yaml @@ -127,15 +123,14 @@ Feature: Call Task namespace: default name: openapi-call-with-response-output do: - - getPetById: - call: openapi - with: - document: - uri: https://petstore.swagger.io/v2/swagger.json - operation: getPetById - parameters: - petId: ${ .petId } - output: response + call: openapi + with: + document: + uri: https://petstore.swagger.io/v2/swagger.json + operation: getPetById + parameters: + petId: ${ .petId } + output: response """ And given the workflow input is: """yaml diff --git a/ctk/features/composite.feature b/ctk/features/composite.feature index e504d28f..05de0c90 100644 --- a/ctk/features/composite.feature +++ b/ctk/features/composite.feature @@ -12,18 +12,16 @@ Feature: Composite Task namespace: default name: composite-sequential do: - - setRGB: - execute: - sequentially: - - setRed: - set: - colors: ${ .colors + ["red"] } - - setGreen: - set: - colors: ${ .colors + ["green"] } - - setBlue: - set: - colors: ${ .colors + ["blue"] } + sequentially: + - setRed: + set: + colors: ${ .colors + ["red"] } + - setGreen: + set: + colors: ${ .colors + ["green"] } + - setBlue: + set: + colors: ${ .colors + ["blue"] } """ When the workflow is executed Then the workflow should complete with output: @@ -40,19 +38,16 @@ Feature: Composite Task namespace: default name: composite-sequential do: - - setRGB: - execute: - concurrently: - - setRed: - set: - colors: ${ .colors + ["red"] } - - setGreen: - set: - colors: ${ .colors + ["green"] } - - setBlue: - set: - colors: ${ .colors + ["blue"] } - compete: true + compete: + - setRed: + set: + colors: ${ .colors + ["red"] } + - setGreen: + set: + colors: ${ .colors + ["green"] } + - setBlue: + set: + colors: ${ .colors + ["blue"] } """ When the workflow is executed Then the workflow should complete diff --git a/ctk/features/data-flow.feature b/ctk/features/data-flow.feature index 350db5ce..a98e1348 100644 --- a/ctk/features/data-flow.feature +++ b/ctk/features/data-flow.feature @@ -12,11 +12,10 @@ Feature: Data Flow namespace: default name: output-filtering do: - - setUsername: - input: - from: .user.claims.subject #filters the input of the task, using only the user's subject - set: - playerId: ${ . } + input: + from: .user.claims.subject #filters the input of the task, using only the user's subject + set: + playerId: ${ . } """ And given the workflow input is: """yaml @@ -39,14 +38,13 @@ Feature: Data Flow namespace: default name: output-filtering do: - - getPetById: - call: http - with: - method: get - 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 + call: http + with: + method: get + 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 """ And given the workflow input is: """yaml @@ -67,22 +65,23 @@ Feature: Data Flow namespace: default name: non-object-output do: - - getPetById1: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables - output: - from: .id - - getPetById2: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/2 - output: - from: '{ ids: [ $input, .id ] }' + sequentially: + - getPetById1: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables + output: + from: .id + - getPetById2: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/2 + output: + from: '{ ids: [ $input, .id ] }' """ When the workflow is executed Then the workflow should complete with output: diff --git a/ctk/features/emit.feature b/ctk/features/emit.feature index 559a9202..4531be46 100644 --- a/ctk/features/emit.feature +++ b/ctk/features/emit.feature @@ -12,14 +12,13 @@ Feature: Emit Task namespace: default name: emit do: - - emitUserGreeted: - emit: - event: - with: - source: https://fake-source.com - type: com.fake-source.user.greeted.v1 - data: - greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" } + emit: + event: + with: + source: https://fake-source.com + type: com.fake-source.user.greeted.v1 + data: + greetings: ${ "Hello \(.user.firstName) \(.user.lastName)!" } """ And given the workflow input is: """yaml diff --git a/ctk/features/flow.feature b/ctk/features/flow.feature index 16917946..900b902a 100644 --- a/ctk/features/flow.feature +++ b/ctk/features/flow.feature @@ -11,15 +11,16 @@ Feature: Flow Directive namespace: default name: implicit-sequence do: - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' + sequentially: + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' """ When the workflow is executed Then the workflow should complete with output: @@ -38,18 +39,19 @@ Feature: Flow Directive namespace: default name: explicit-sequence do: - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - then: setGreen - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - then: end - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - then: setBlue + sequentially: + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + then: setGreen + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + then: end + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + then: setBlue """ When the workflow is executed Then the workflow should complete with output: diff --git a/ctk/features/for.feature b/ctk/features/for.feature index 00da7946..0423622f 100644 --- a/ctk/features/for.feature +++ b/ctk/features/for.feature @@ -14,13 +14,12 @@ Feature: For Task namespace: default name: for do: - - forEachColor: - for: - each: color - in: '.colors' - do: - set: - processed: '${ { colors: (.processed.colors + [ $color ]), indexes: (.processed.indexes + [ $index ])} }' + for: + each: color + in: '.colors' + do: + set: + processed: '${ { colors: (.processed.colors + [ $color ]), indexes: (.processed.indexes + [ $index ])} }' """ And given the workflow input is: """yaml diff --git a/ctk/features/raise.feature b/ctk/features/raise.feature index 7aafc902..e7df2459 100644 --- a/ctk/features/raise.feature +++ b/ctk/features/raise.feature @@ -11,12 +11,11 @@ Feature: Raise Task namespace: default name: raise-custom-error do: - - raiseComplianceError: - raise: - error: - status: 400 - type: https://serverlessworkflow.io/errors/types/compliance - title: Compliance Error + raise: + error: + status: 400 + type: https://serverlessworkflow.io/errors/types/compliance + title: Compliance Error """ When the workflow is executed Then the workflow should fault with error: diff --git a/ctk/features/set.feature b/ctk/features/set.feature index 6f81b4f9..f9cbb64a 100644 --- a/ctk/features/set.feature +++ b/ctk/features/set.feature @@ -12,11 +12,10 @@ Feature: Set Task namespace: default name: set do: - - initialize: - set: - shape: circle - size: ${ .configuration.size } - fill: ${ .configuration.fill } + set: + shape: circle + size: ${ .configuration.size } + fill: ${ .configuration.fill } """ And given the workflow input is: """yaml diff --git a/ctk/features/switch.feature b/ctk/features/switch.feature index bba64c00..57cc4fcf 100644 --- a/ctk/features/switch.feature +++ b/ctk/features/switch.feature @@ -97,31 +97,32 @@ Feature: Switch Task namespace: default name: switch-default-implicit do: - - switchColor: - switch: - - red: - when: '.color == "red"' - then: setRed - - green: - when: '.color == "green"' - then: setGreen - - blue: - when: '.color == "blue"' - then: setBlue - - anyOtherColor: - then: setCustomColor - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - - setCustomColor: - set: - colors: '${ .colors + [ $input.color ] }' + sequentially: + - switchColor: + switch: + - red: + when: '.color == "red"' + then: setRed + - green: + when: '.color == "green"' + then: setGreen + - blue: + when: '.color == "blue"' + then: setBlue + - anyOtherColor: + then: setCustomColor + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + - setCustomColor: + set: + colors: '${ .colors + [ $input.color ] }' """ And given the workflow input is: """yaml diff --git a/ctk/features/try.feature b/ctk/features/try.feature index e668f6b3..893f9ff6 100644 --- a/ctk/features/try.feature +++ b/ctk/features/try.feature @@ -15,22 +15,21 @@ Feature: Try Task namespace: default name: try-catch-404 do: - - tryGetPet: - try: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} - catch: - errors: - with: - type: https://serverlessworkflow.io/dsl/errors/types/communication - status: 404 - as: err - do: - set: - error: ${ $err } + try: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} + catch: + errors: + with: + type: https://serverlessworkflow.io/dsl/errors/types/communication + status: 404 + as: err + do: + set: + error: ${ $err } """ And given the workflow input is: """yaml @@ -56,22 +55,21 @@ Feature: Try Task namespace: default name: try-catch-503 do: - - tryGetPet: - try: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} - catch: - errors: - with: - type: https://serverlessworkflow.io/dsl/errors/types/communication - status: 503 - as: err - do: - set: - error: ${ $err } + try: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/getPetByName/{petName} + catch: + errors: + with: + type: https://serverlessworkflow.io/dsl/errors/types/communication + status: 503 + as: err + do: + set: + error: ${ $err } """ And given the workflow input is: """yaml From 4b369e5e1f127d1bd81a08f651099b6bf5a425cf Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 11:23:03 +0000 Subject: [PATCH 38/51] docs: update dsl Signed-off-by: Matthias Pichler --- dsl-reference.md | 699 ++++++++++++++++++++++++----------------------- dsl.md | 16 +- 2 files changed, 370 insertions(+), 345 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index a78cfaf1..838a3773 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -14,7 +14,9 @@ + [gRPC](#grpc-call) + [HTTP](#http-call) + [OpenAPI](#openapi-call) - - [Composite](#composite) + - [Sequential](#sequential) + - [Concurrent](#concurrent) + - [Compete](#compete) - [Emit](#emit) - [For](#for) - [Listen](#listen) @@ -66,7 +68,7 @@ A [workflow](#workflow) serves as a blueprint outlining the series of [tasks](#t | document | [`document`](#document) | `yes` | Documents the defined workflow. | | input | [`input`](#input) | `no` | Configures the workflow's input. | | use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. | -| do | [`map[string, task][]`](#task) | `yes` | The [task(s)](#task) that must be performed by the [workflow](#workflow). | +| do | [`task`](#task) | `yes` | The [task](#task) that must be performed by the [workflow](#workflow). | | timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. | | output | [`output`](#output) | `no` | Configures the workflow's output. | | schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. | @@ -171,35 +173,36 @@ use: secrets: - my-oauth2-secret do: - - getAvailablePets: - call: getAvailablePets - output: - from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }" - - submitMatchesByMail: - call: http - with: - method: post - endpoint: - uri: https://fake.smtp.service.com/email/send - authentication: petStoreOAuth2 - body: - from: noreply@fake.petstore.com - to: ${ .order.client.email } - subject: Candidates for Adoption - body: > - Hello ${ .order.client.preferredDisplayName }! + sequentially: + - getAvailablePets: + call: getAvailablePets + output: + from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }" + - submitMatchesByMail: + call: http + with: + method: post + endpoint: + uri: https://fake.smtp.service.com/email/send + authentication: petStoreOAuth2 + body: + from: noreply@fake.petstore.com + to: ${ .order.client.email } + subject: Candidates for Adoption + body: > + Hello ${ .order.client.preferredDisplayName }! - Following your interest to adopt a dog, here is a list of candidates that you might be interested in: + Following your interest to adopt a dog, here is a list of candidates that you might be interested in: - ${ .pets | map("-\(.name)") | join("\n") } + ${ .pets | map("-\(.name)") | join("\n") } - Please do not hesistate to contact us at info@fake.petstore.com if your have questions. + Please do not hesistate to contact us at info@fake.petstore.com if your have questions. - Hope to hear from you soon! + Hope to hear from you soon! - ---------------------------------------------------------------------------------------------- - DO NOT REPLY - ---------------------------------------------------------------------------------------------- + ---------------------------------------------------------------------------------------------- + DO NOT REPLY + ---------------------------------------------------------------------------------------------- ``` ### Task @@ -215,7 +218,9 @@ By breaking down the [workflow](#workflow) into manageable [tasks](#task), organ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** supported by all runtimes: - [Call](#call), used to call services and/or functions. -- [Composite](#composite), used to define a minimum of two subtasks to perform. +- [Sequential](#sequential), used to define a minimum of two subtasks to perform sequentially. +- [Concurrent](#concurrent), used to define a minimum of two subtasks to perform concurrently. +- [Compete](#compete), used to define a minimum of two subtasks to perform concurrently, with a single possible winner. - [Emit](#emit), used to emit [events](#event). - [For](#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](#listen), used to listen for an [event](#event) or more. @@ -256,11 +261,10 @@ document: name: sample-workflow version: '0.1.0' do: - - getPetById: - call: http - with: - method: get - endpoint: https://petstore.swagger.io/v2/pet/{petId} + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` Serverless Workflow defines several default functions that **MUST** be supported by all implementations and runtimes: @@ -295,16 +299,15 @@ document: name: sample-workflow version: '0.1.0' do: - - greetUser: - call: asyncapi - with: - document: https://fake.com/docs/asyncapi.json - operation: findPetsByStatus - server: staging - message: getPetByStatusQuery - binding: http - payload: - petId: ${ .pet.id } + call: asyncapi + with: + document: https://fake.com/docs/asyncapi.json + operation: findPetsByStatus + server: staging + message: getPetByStatusQuery + binding: http + payload: + petId: ${ .pet.id } ``` ##### gRPC Call @@ -332,17 +335,16 @@ document: name: sample-workflow version: '0.1.0' do: - - greetUser: - call: grpc - with: - proto: file://app/greet.proto - service: - name: GreeterApi.Greeter - host: localhost - port: 5011 - method: SayHello - arguments: - name: ${ .user.preferredDisplayName } + call: grpc + with: + proto: file://app/greet.proto + service: + name: GreeterApi.Greeter + host: localhost + port: 5011 + method: SayHello + arguments: + name: ${ .user.preferredDisplayName } ``` ##### HTTP Call @@ -368,11 +370,10 @@ document: name: sample-workflow version: '0.1.0' do: - - getPetById: - call: http - with: - method: get - endpoint: https://petstore.swagger.io/v2/pet/{petId} + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` ##### OpenAPI Call @@ -398,30 +399,26 @@ document: name: sample-workflow version: '0.1.0' do: - - getPets: - call: openapi - with: - document: https://petstore.swagger.io/v2/swagger.json - operation: findPetsByStatus - parameters: - status: available + call: openapi + with: + document: https://petstore.swagger.io/v2/swagger.json + operation: findPetsByStatus + parameters: + status: available ``` -#### Composite +#### Sequential - Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. + Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks one after the other to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. ##### Properties | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| execute.sequentially | [`task[]`](#task) | `no` | The tasks to perform sequentially.
*Required if `execute.concurrently` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | -| execute.concurrently | [`task[]`](#task) | `no` | The tasks to perform concurrently.
*Required if `execute.sequentially` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | -| execute.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.
*Ignored if `execute.sequentially` has been set. Defaults to `false`.*
*Must **not** be set if the [`tasks`](#task) are executed sequentially.* | +| sequentially | [`map[string, task][]`](#task) | `yes` | The tasks to perform sequentially.*Must contain **at least** two [`tasks`](#task).* | ##### Examples -*Executing tasks sequentially:* ```yaml document: dsl: '1.0.0-alpha1' @@ -429,45 +426,54 @@ document: name: sample-workflow version: '0.1.0' do: - - bookTrip: - execute: - sequentially: - - bookHotel: - call: http - with: - method: post - endpoint: - uri: https://fake-booking-agency.com/hotels/book - authentication: fake-booking-agency-oauth2 - body: - name: Four Seasons - city: Antwerp - country: Belgium - - bookFlight: - call: http - with: - method: post - endpoint: - uri: https://fake-booking-agency.com/flights/book - authentication: fake-booking-agency-oauth2 - body: - departure: - date: '01/01/26' - time: '07:25:00' - from: - airport: BRU - city: Zaventem - country: Belgium - arrival: - date: '01/01/26' - time: '11:12:00' - to: - airport: LIS - city: Lisbon - country: Portugal + sequentially: + - bookHotel: + call: http + with: + method: post + endpoint: + uri: https://fake-booking-agency.com/hotels/book + authentication: fake-booking-agency-oauth2 + body: + name: Four Seasons + city: Antwerp + country: Belgium + - bookFlight: + call: http + with: + method: post + endpoint: + uri: https://fake-booking-agency.com/flights/book + authentication: fake-booking-agency-oauth2 + body: + departure: + date: '01/01/26' + time: '07:25:00' + from: + airport: BRU + city: Zaventem + country: Belgium + arrival: + date: '01/01/26' + time: '11:12:00' + to: + airport: LIS + city: Lisbon + country: Portugal ``` -*Executing tasks concurrently:* +#### Concurrent + + Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and parallel execution of multiple subtasks to accomplish complex operations and increase performace. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. + +##### Properties + +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| concurrently | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | + +##### Examples + ```yaml document: dsl: '1.0.0-alpha1' @@ -475,25 +481,61 @@ document: name: sample-workflow version: '0.1.0' do: - - raiseAlarm: - execute: - concurrently: - - callNurse: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/nurses - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } - - callDoctor: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/doctor - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } + concurrently: + - callNurse: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/nurses + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } + - callDoctor: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/doctor + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } +``` + +#### Compete + +Races multiple tasks against each other, with a single possible winner, which sets the task's output. This task type is instrumental in handling scenarios where multiple tasks are competing to achieve a common goal, and only one task is needed to succeed. + +##### Properties + +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| compete | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | + +##### Examples + +```yaml +document: + dsl: '1.0.0-alpha1' + namespace: test + name: sample-workflow + version: '0.1.0' +do: + compete: + - callNurse: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/nurses + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } + - callDoctor: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/doctor + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } ``` #### Emit @@ -515,19 +557,18 @@ document: name: sample-workflow version: '0.1.0' do: - - placeOrder: - emit: - event: - with: - source: https://petstore.com - type: com.petstore.order.placed.v1 - data: - client: - firstName: Cruella - lastName: de Vil - items: - - breed: dalmatian - quantity: 101 + emit: + event: + with: + source: https://petstore.com + type: com.petstore.order.placed.v1 + data: + client: + firstName: Cruella + lastName: de Vil + items: + - breed: dalmatian + quantity: 101 ``` #### For @@ -553,20 +594,19 @@ document: name: sample-workflow version: '0.1.0' do: - - checkup: - for: - each: pet - in: .pets - at: index - while: .vet != null - do: - listen: - to: - one: - with: - type: com.fake.petclinic.pets.checkup.completed.v2 - output: - to: '.pets + [{ "id": $pet.id }]' + for: + each: pet + in: .pets + at: index + while: .vet != null + do: + listen: + to: + one: + with: + type: com.fake.petclinic.pets.checkup.completed.v2 + output: + to: '.pets + [{ "id": $pet.id }]' ``` #### Listen @@ -588,18 +628,17 @@ document: name: sample-workflow version: '0.1.0' do: - - callDoctor: - listen: - to: - any: - - with: - type: com.fake-hospital.vitals.measurements.temperature - data: - temperature: ${ .temperature > 38 } - - with: - type: com.fake-hospital.vitals.measurements.bpm - data: - temperature: ${ .bpm < 60 or .bpm > 100 } + listen: + to: + any: + - with: + type: com.fake-hospital.vitals.measurements.temperature + data: + temperature: ${ .temperature > 38 } + - with: + type: com.fake-hospital.vitals.measurements.bpm + data: + temperature: ${ .bpm < 60 or .bpm > 100 } ``` #### Raise @@ -621,28 +660,29 @@ document: name: sample-workflow version: '0.1.0' do: - - processTicket: - switch: - - highPriority: - when: .ticket.priority == "high" - then: escalateToManager - - mediumPriority: - when: .ticket.priority == "medium" - then: assignToSpecialist - - lowPriority: - when: .ticket.priority == "low" - then: resolveTicket - - default: - then: raiseUndefinedPriorityError - - raiseUndefinedPriorityError: - raise: - error: - type: https://fake.com/errors/tickets/undefined-priority - status: 400 - title: Undefined Priority - - escalateToManager: {} - - assignToSpecialist: {} - - resolveTicket: {} + sequentially: + - processTicket: + switch: + - highPriority: + when: .ticket.priority == "high" + then: escalateToManager + - mediumPriority: + when: .ticket.priority == "medium" + then: assignToSpecialist + - lowPriority: + when: .ticket.priority == "low" + then: resolveTicket + - default: + then: raiseUndefinedPriorityError + - raiseUndefinedPriorityError: + raise: + error: + type: https://fake.com/errors/tickets/undefined-priority + status: 400 + title: Undefined Priority + - escalateToManager: {} + - assignToSpecialist: {} + - resolveTicket: {} ``` #### Run @@ -667,29 +707,29 @@ document: name: sample-workflow version: '0.1.0' do: - - - runContainer: - run: - container: - image: fake-image - - - runScript: - run: - script: - language: js - code: > - Some cool multiline script - - - runShell: - run: - shell: - command: 'echo "Hello, ${ .user.name }"' - - - runWorkflow: - run: - workflow: - reference: another-one:0.1.0 - input: {} + sequentially: + - runContainer: + run: + container: + image: fake-image + + - runScript: + run: + script: + language: js + code: > + Some cool multiline script + + - runShell: + run: + shell: + command: 'echo "Hello, ${ .user.name }"' + + - runWorkflow: + run: + workflow: + reference: another-one:0.1.0 + input: {} ``` ##### Container Process @@ -715,10 +755,9 @@ document: name: sample-workflow version: '0.1.0' do: - - runContainer: - run: - container: - image: fake-image + run: + container: + image: fake-image ``` ##### Script Process @@ -743,12 +782,11 @@ document: name: sample-workflow version: '0.1.0' do: - - runScript: - run: - script: - language: js - code: > - Some cool multiline script + run: + script: + language: js + code: > + Some cool multiline script ``` ##### Shell Process @@ -772,10 +810,9 @@ document: name: sample-workflow version: '0.1.0' do: - - runShell: - run: - shell: - command: 'echo "Hello, ${ .user.name }"' + run: + shell: + command: 'echo "Hello, ${ .user.name }"' ``` ##### Workflow Process @@ -799,12 +836,11 @@ document: name: sample-workflow version: '0.1.0' do: - - runShell: - run: - workflow: - reference: another-one:0.1.0 - input: - foo: bar + run: + workflow: + reference: another-one:0.1.0 + input: + foo: bar ``` #### Set @@ -826,11 +862,10 @@ document: name: set version: '0.1.0' do: - - initialize: - set: - shape: circle - size: ${ .configuration.size } - fill: ${ .configuration.fill } + set: + shape: circle + size: ${ .configuration.size } + fill: ${ .configuration.fill } ``` #### Switch @@ -852,34 +887,35 @@ document: name: sample-workflow version: '0.1.0' do: - - processOrder: - switch: - - case1: - when: .orderType == "electronic" - then: processElectronicOrder - - case2: - when: .orderType == "physical" - then: processPhysicalOrder - - default: - then: handleUnknownOrderType - - processElectronicOrder: - execute: - sequentially: - - validatePayment: {} - - fulfillOrder: {} - then: exit - - processPhysicalOrder: + sequentially: + - processOrder: + switch: + - case1: + when: .orderType == "electronic" + then: processElectronicOrder + - case2: + when: .orderType == "physical" + then: processPhysicalOrder + - default: + then: handleUnknownOrderType + - processElectronicOrder: execute: sequentially: - - checkInventory: {} - - packItems: {} - - scheduleShipping: {} - then: exit - - handleUnknownOrderType: - execute: - sequentially: - - logWarning: {} - - notifyAdmin: {} + - validatePayment: {} + - fulfillOrder: {} + then: exit + - processPhysicalOrder: + execute: + sequentially: + - checkInventory: {} + - packItems: {} + - scheduleShipping: {} + then: exit + - handleUnknownOrderType: + execute: + sequentially: + - logWarning: {} + - notifyAdmin: {} ``` ##### Switch Case @@ -912,26 +948,25 @@ document: name: sample-workflow version: '0.1.0' do: - - processOrder: - try: - call: http - with: - method: get - endpoint: https:// - catch: - errors: - with: - type: https://serverlessworkflow.io.io/dsl/errors/types/communication - status: 503 - as: error - retry: - delay: - seconds: 3 - backoff: - exponential: {} - limit: - attempt: - count: 5 + try: + call: http + with: + method: get + endpoint: https:// + catch: + errors: + with: + type: https://serverlessworkflow.io.io/dsl/errors/types/communication + status: 503 + as: error + retry: + delay: + seconds: 3 + backoff: + exponential: {} + limit: + attempt: + count: 5 ``` ##### Catch @@ -968,9 +1003,8 @@ document: name: sample-workflow version: '0.1.0' do: - - delay10Seconds: - wait: - seconds: 10 + wait: + seconds: 10 ``` ### Flow Directive @@ -1036,13 +1070,12 @@ use: sampleBasicFromSecret: basic: usernamePasswordSecret do: - - getMessages: - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: sampleBasicFromSecret + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: sampleBasicFromSecret ``` #### Basic Authentication @@ -1071,13 +1104,12 @@ use: username: admin password: 123 do: - - getMessages: - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: sampleBasic + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: sampleBasic ``` #### Bearer Authentication @@ -1099,15 +1131,14 @@ document: name: sample-workflow version: '0.1.0' do: - - getMessages: - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: - bearer: - token: ${ .user.token } + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: + bearer: + token: ${ .user.token } ``` #### Certificate Authentication @@ -1144,21 +1175,20 @@ document: name: sample-workflow version: '0.1.0' do: - - getMessages: - call: http - with: - method: get - endpoint: - uri: https://secured.fake.com/sample - authentication: - oauth2: - authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration - grant: client-credentials - client: - id: workflow-runtime - secret: ********** - scopes: [ api ] - audiences: [ runtime ] + call: http + with: + method: get + endpoint: + uri: https://secured.fake.com/sample + authentication: + oauth2: + authority: http://keycloak/realms/fake-authority/.well-known/openid-configuration + grant: client-credentials + client: + id: workflow-runtime + secret: ********** + scopes: [ api ] + audiences: [ runtime ] ``` ##### OAUTH2 Token @@ -1215,11 +1245,10 @@ use: body: message: "${ \"Executed task '\($task.reference)'...\" }" do: - - get: - call: http - with: - method: get - endpoint: https://fake.com/sample + call: http + with: + method: get + endpoint: https://fake.com/sample ``` *Intercept HTTP calls to 'https://mocked.service.com' and mock its response:* @@ -1244,11 +1273,10 @@ use: bar: baz then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected do: - - get: - call: http - with: - method: get - endpoint: https://fake.com/sample + call: http + with: + method: get + endpoint: https://fake.com/sample ``` ### Error @@ -1489,9 +1517,8 @@ document: name: sample version: '0.1.0' do: - - waitFor60Seconds: - wait: - seconds: 60 + wait: + seconds: 60 timeout: after: seconds: 30 diff --git a/dsl.md b/dsl.md index 9be281dc..b481d9c5 100644 --- a/dsl.md +++ b/dsl.md @@ -342,10 +342,9 @@ document: version: '0.1.0' do: - - validateEmail: - call: https://github.com/myorg/functions/validateEmailAddress@v1 - with: - emailAddress: ${ .userEmail } + call: https://github.com/myorg/functions/validateEmailAddress@v1 + with: + emailAddress: ${ .userEmail } ``` ##### Publishing a Custom Function @@ -426,11 +425,10 @@ use: body: message: "${ \"Executed task '\($task.reference)'...\" }" do: - - get: - call: http - with: - method: get - uri: https://fake.com/sample + call: http + with: + method: get + uri: https://fake.com/sample ``` ### External Resources From 183b8d3cd4ad1d76f112111f2efa415d0ba9dd05 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 11:26:34 +0000 Subject: [PATCH 39/51] fix: fix indentation of then Signed-off-by: Matthias Pichler --- examples/switch-then-string.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/switch-then-string.yaml b/examples/switch-then-string.yaml index 9518f542..f293b2cd 100644 --- a/examples/switch-then-string.yaml +++ b/examples/switch-then-string.yaml @@ -23,7 +23,7 @@ do: - fulfillOrder: set: status: fulfilled - then: exit + then: exit - processPhysicalOrder: sequentially: - checkInventory: @@ -35,7 +35,7 @@ do: - scheduleShipping: set: address: Elmer St - then: exit + then: exit - handleUnknownOrderType: sequentially: - logWarning: From f76b709051c7899144caeea3eda8739da1a5fbee Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 11:32:26 +0000 Subject: [PATCH 40/51] fix: update extend property Signed-off-by: Matthias Pichler --- dsl-reference.md | 2 +- dsl.md | 4 +++- schema/workflow.yaml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 838a3773..8c0a5b06 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -1212,7 +1212,7 @@ Extensions enable the execution of tasks prior to those they extend, offering th | Property | Type | Required | Description | |----------|:----:|:--------:|-------------| -| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | +| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `sequentially`, `concurrently`, `compete`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | | when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | | before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | | after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | diff --git a/dsl.md b/dsl.md index b481d9c5..68ebad9e 100644 --- a/dsl.md +++ b/dsl.md @@ -101,7 +101,9 @@ Serverless Workflow DSL allows for defining reusable components that can be refe The Serverless Workflow DSL defines several default [task](dsl-reference.md#tasks) types that runtimes **must** implement: - [Call](dsl-reference.md#call), used to call services and/or functions. -- [Composite](dsl-reference.md#composite), used to define a minimum of two subtasks to perform. +- [Sequential](dsl-reference.md#sequential), used to define a minimum of two subtasks to perform sequentially. +- [Concurrent](dsl-reference.md#concurrent), used to define a minimum of two subtasks to perform concurrently. +- [Compete](dsl-reference.md#compete), used to define a minimum of two subtasks to perform concurrently, and to continue with the first one that completes. - [Emit](dsl-reference.md#emit), used to emit [events](dsl-reference.md#event). - [For](dsl-reference.md#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](dsl-reference.md#listen), used to listen for an [event](dsl-reference.md#event) or more. diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 46b7e202..02b67ad4 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -780,7 +780,7 @@ $defs: properties: extend: type: string - enum: [ call, composite, emit, for, listen, raise, run, set, switch, try, wait, all ] + enum: [ call, compete, sequentially, concurrently, emit, for, listen, raise, run, set, switch, try, wait, all ] description: The type of task to extend. when: type: string From acad3d72a9ba3f6ce3e643ac3be131500bf9f6a5 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Tue, 4 Jun 2024 16:01:45 +0000 Subject: [PATCH 41/51] refactor: replace compete with competitively Signed-off-by: Matthias Pichler --- ctk/features/composite.feature | 2 +- dsl-reference.md | 24 ++++++++++++------------ dsl.md | 6 +++--- schema/workflow.yaml | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ctk/features/composite.feature b/ctk/features/composite.feature index 05de0c90..763f4bb1 100644 --- a/ctk/features/composite.feature +++ b/ctk/features/composite.feature @@ -38,7 +38,7 @@ Feature: Composite Task namespace: default name: composite-sequential do: - compete: + competitively: - setRed: set: colors: ${ .colors + ["red"] } diff --git a/dsl-reference.md b/dsl-reference.md index 8c0a5b06..5047825e 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -14,9 +14,9 @@ + [gRPC](#grpc-call) + [HTTP](#http-call) + [OpenAPI](#openapi-call) - - [Sequential](#sequential) - - [Concurrent](#concurrent) - - [Compete](#compete) + - [Sequentially](#sequentially) + - [Concurrently](#concurrently) + - [Competitively](#competitively) - [Emit](#emit) - [For](#for) - [Listen](#listen) @@ -218,9 +218,9 @@ By breaking down the [workflow](#workflow) into manageable [tasks](#task), organ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** supported by all runtimes: - [Call](#call), used to call services and/or functions. -- [Sequential](#sequential), used to define a minimum of two subtasks to perform sequentially. -- [Concurrent](#concurrent), used to define a minimum of two subtasks to perform concurrently. -- [Compete](#compete), used to define a minimum of two subtasks to perform concurrently, with a single possible winner. +- [Sequentially](#sequentially), used to define a minimum of two subtasks to perform sequentially. +- [Concurrently](#concurrently), used to define a minimum of two subtasks to perform concurrently. +- [competitively](#competitively), used to define a minimum of two subtasks to perform concurrently, with a single possible winner. - [Emit](#emit), used to emit [events](#event). - [For](#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](#listen), used to listen for an [event](#event) or more. @@ -407,7 +407,7 @@ do: status: available ``` -#### Sequential +#### Sequentially Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks one after the other to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. @@ -462,7 +462,7 @@ do: country: Portugal ``` -#### Concurrent +#### Concurrently Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and parallel execution of multiple subtasks to accomplish complex operations and increase performace. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. @@ -500,7 +500,7 @@ do: room: ${ .room.number } ``` -#### Compete +#### Competitively Races multiple tasks against each other, with a single possible winner, which sets the task's output. This task type is instrumental in handling scenarios where multiple tasks are competing to achieve a common goal, and only one task is needed to succeed. @@ -508,7 +508,7 @@ Races multiple tasks against each other, with a single possible winner, which se | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| compete | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | +| competitively | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | ##### Examples @@ -519,7 +519,7 @@ document: name: sample-workflow version: '0.1.0' do: - compete: + competitively: - callNurse: call: http with: @@ -1212,7 +1212,7 @@ Extensions enable the execution of tasks prior to those they extend, offering th | Property | Type | Required | Description | |----------|:----:|:--------:|-------------| -| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `sequentially`, `concurrently`, `compete`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | +| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `sequentially`, `concurrently`, `competitively`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | | when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | | before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | | after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | diff --git a/dsl.md b/dsl.md index 68ebad9e..9df97f09 100644 --- a/dsl.md +++ b/dsl.md @@ -101,9 +101,9 @@ Serverless Workflow DSL allows for defining reusable components that can be refe The Serverless Workflow DSL defines several default [task](dsl-reference.md#tasks) types that runtimes **must** implement: - [Call](dsl-reference.md#call), used to call services and/or functions. -- [Sequential](dsl-reference.md#sequential), used to define a minimum of two subtasks to perform sequentially. -- [Concurrent](dsl-reference.md#concurrent), used to define a minimum of two subtasks to perform concurrently. -- [Compete](dsl-reference.md#compete), used to define a minimum of two subtasks to perform concurrently, and to continue with the first one that completes. +- [Sequentially](dsl-reference.md#sequentially), used to define a minimum of two subtasks to perform sequentially. +- [Concurrently](dsl-reference.md#concurrently), used to define a minimum of two subtasks to perform concurrently. +- [Competitively](dsl-reference.md#competitively), used to define a minimum of two subtasks to perform concurrently, and to continue with the first one that completes. - [Emit](dsl-reference.md#emit), used to emit [events](dsl-reference.md#event). - [For](dsl-reference.md#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](dsl-reference.md#listen), used to listen for an [event](dsl-reference.md#event) or more. diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 02b67ad4..6f747404 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -306,7 +306,7 @@ $defs: competingTask: type: object properties: - compete: + competitively: type: array minItems: 2 items: @@ -318,7 +318,7 @@ $defs: description: | A list of the tasks to perform concurrently and race against each other, with a single possible winner, which sets the task's output. - required: [ compete ] + required: [ competitively ] emitTask: type: object properties: @@ -780,7 +780,7 @@ $defs: properties: extend: type: string - enum: [ call, compete, sequentially, concurrently, emit, for, listen, raise, run, set, switch, try, wait, all ] + enum: [ call, competitively, sequentially, concurrently, emit, for, listen, raise, run, set, switch, try, wait, all ] description: The type of task to extend. when: type: string From 03b8b4690b352bb340a938d9500c671c426dd0b0 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 16:26:28 +0000 Subject: [PATCH 42/51] Revert "refactor: replace compete with competitively" This reverts commit 33488a5ee202880b39ce1fe0cfe831e07d548866. Signed-off-by: Matthias Pichler --- ctk/features/composite.feature | 2 +- dsl-reference.md | 24 ++++++++++++------------ dsl.md | 6 +++--- schema/workflow.yaml | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ctk/features/composite.feature b/ctk/features/composite.feature index 763f4bb1..05de0c90 100644 --- a/ctk/features/composite.feature +++ b/ctk/features/composite.feature @@ -38,7 +38,7 @@ Feature: Composite Task namespace: default name: composite-sequential do: - competitively: + compete: - setRed: set: colors: ${ .colors + ["red"] } diff --git a/dsl-reference.md b/dsl-reference.md index 5047825e..8c0a5b06 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -14,9 +14,9 @@ + [gRPC](#grpc-call) + [HTTP](#http-call) + [OpenAPI](#openapi-call) - - [Sequentially](#sequentially) - - [Concurrently](#concurrently) - - [Competitively](#competitively) + - [Sequential](#sequential) + - [Concurrent](#concurrent) + - [Compete](#compete) - [Emit](#emit) - [For](#for) - [Listen](#listen) @@ -218,9 +218,9 @@ By breaking down the [workflow](#workflow) into manageable [tasks](#task), organ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** supported by all runtimes: - [Call](#call), used to call services and/or functions. -- [Sequentially](#sequentially), used to define a minimum of two subtasks to perform sequentially. -- [Concurrently](#concurrently), used to define a minimum of two subtasks to perform concurrently. -- [competitively](#competitively), used to define a minimum of two subtasks to perform concurrently, with a single possible winner. +- [Sequential](#sequential), used to define a minimum of two subtasks to perform sequentially. +- [Concurrent](#concurrent), used to define a minimum of two subtasks to perform concurrently. +- [Compete](#compete), used to define a minimum of two subtasks to perform concurrently, with a single possible winner. - [Emit](#emit), used to emit [events](#event). - [For](#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](#listen), used to listen for an [event](#event) or more. @@ -407,7 +407,7 @@ do: status: available ``` -#### Sequentially +#### Sequential Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks one after the other to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. @@ -462,7 +462,7 @@ do: country: Portugal ``` -#### Concurrently +#### Concurrent Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and parallel execution of multiple subtasks to accomplish complex operations and increase performace. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. @@ -500,7 +500,7 @@ do: room: ${ .room.number } ``` -#### Competitively +#### Compete Races multiple tasks against each other, with a single possible winner, which sets the task's output. This task type is instrumental in handling scenarios where multiple tasks are competing to achieve a common goal, and only one task is needed to succeed. @@ -508,7 +508,7 @@ Races multiple tasks against each other, with a single possible winner, which se | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| competitively | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | +| compete | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | ##### Examples @@ -519,7 +519,7 @@ document: name: sample-workflow version: '0.1.0' do: - competitively: + compete: - callNurse: call: http with: @@ -1212,7 +1212,7 @@ Extensions enable the execution of tasks prior to those they extend, offering th | Property | Type | Required | Description | |----------|:----:|:--------:|-------------| -| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `sequentially`, `concurrently`, `competitively`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | +| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `sequentially`, `concurrently`, `compete`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | | when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | | before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | | after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | diff --git a/dsl.md b/dsl.md index 9df97f09..68ebad9e 100644 --- a/dsl.md +++ b/dsl.md @@ -101,9 +101,9 @@ Serverless Workflow DSL allows for defining reusable components that can be refe The Serverless Workflow DSL defines several default [task](dsl-reference.md#tasks) types that runtimes **must** implement: - [Call](dsl-reference.md#call), used to call services and/or functions. -- [Sequentially](dsl-reference.md#sequentially), used to define a minimum of two subtasks to perform sequentially. -- [Concurrently](dsl-reference.md#concurrently), used to define a minimum of two subtasks to perform concurrently. -- [Competitively](dsl-reference.md#competitively), used to define a minimum of two subtasks to perform concurrently, and to continue with the first one that completes. +- [Sequential](dsl-reference.md#sequential), used to define a minimum of two subtasks to perform sequentially. +- [Concurrent](dsl-reference.md#concurrent), used to define a minimum of two subtasks to perform concurrently. +- [Compete](dsl-reference.md#compete), used to define a minimum of two subtasks to perform concurrently, and to continue with the first one that completes. - [Emit](dsl-reference.md#emit), used to emit [events](dsl-reference.md#event). - [For](dsl-reference.md#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](dsl-reference.md#listen), used to listen for an [event](dsl-reference.md#event) or more. diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 6f747404..02b67ad4 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -306,7 +306,7 @@ $defs: competingTask: type: object properties: - competitively: + compete: type: array minItems: 2 items: @@ -318,7 +318,7 @@ $defs: description: | A list of the tasks to perform concurrently and race against each other, with a single possible winner, which sets the task's output. - required: [ competitively ] + required: [ compete ] emitTask: type: object properties: @@ -780,7 +780,7 @@ $defs: properties: extend: type: string - enum: [ call, competitively, sequentially, concurrently, emit, for, listen, raise, run, set, switch, try, wait, all ] + enum: [ call, compete, sequentially, concurrently, emit, for, listen, raise, run, set, switch, try, wait, all ] description: The type of task to extend. when: type: string From 4da0614a2e7132feaf518306547ec36efc72e0ea Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 16:26:53 +0000 Subject: [PATCH 43/51] Revert "fix: update extend property" This reverts commit 7d9807c9244509ca338d09948281cb1f32c1185a. Signed-off-by: Matthias Pichler --- dsl-reference.md | 2 +- dsl.md | 4 +--- schema/workflow.yaml | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 8c0a5b06..838a3773 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -1212,7 +1212,7 @@ Extensions enable the execution of tasks prior to those they extend, offering th | Property | Type | Required | Description | |----------|:----:|:--------:|-------------| -| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `sequentially`, `concurrently`, `compete`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | +| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | | when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | | before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | | after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | diff --git a/dsl.md b/dsl.md index 68ebad9e..b481d9c5 100644 --- a/dsl.md +++ b/dsl.md @@ -101,9 +101,7 @@ Serverless Workflow DSL allows for defining reusable components that can be refe The Serverless Workflow DSL defines several default [task](dsl-reference.md#tasks) types that runtimes **must** implement: - [Call](dsl-reference.md#call), used to call services and/or functions. -- [Sequential](dsl-reference.md#sequential), used to define a minimum of two subtasks to perform sequentially. -- [Concurrent](dsl-reference.md#concurrent), used to define a minimum of two subtasks to perform concurrently. -- [Compete](dsl-reference.md#compete), used to define a minimum of two subtasks to perform concurrently, and to continue with the first one that completes. +- [Composite](dsl-reference.md#composite), used to define a minimum of two subtasks to perform. - [Emit](dsl-reference.md#emit), used to emit [events](dsl-reference.md#event). - [For](dsl-reference.md#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](dsl-reference.md#listen), used to listen for an [event](dsl-reference.md#event) or more. diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 02b67ad4..46b7e202 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -780,7 +780,7 @@ $defs: properties: extend: type: string - enum: [ call, compete, sequentially, concurrently, emit, for, listen, raise, run, set, switch, try, wait, all ] + enum: [ call, composite, emit, for, listen, raise, run, set, switch, try, wait, all ] description: The type of task to extend. when: type: string From b55e59cfdb058a051778d45cad63a83f61242b7c Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 16:34:51 +0000 Subject: [PATCH 44/51] fix: update examples Signed-off-by: Matthias Pichler --- examples/accumulate-room-readings.yaml | 69 ++++++++++----------- examples/switch-then-string.yaml | 84 ++++++++++++++------------ 2 files changed, 79 insertions(+), 74 deletions(-) diff --git a/examples/accumulate-room-readings.yaml b/examples/accumulate-room-readings.yaml index 3b6d38f8..5b322b07 100644 --- a/examples/accumulate-room-readings.yaml +++ b/examples/accumulate-room-readings.yaml @@ -4,44 +4,45 @@ document: name: accumulate-room-readings version: 1.0.0-alpha1 do: - sequentially: - - consumeReading: - listen: - to: - all: - - with: - source: https://my.home.com/sensor - type: my.home.sensors.temperature - correlate: - roomId: - from: .roomid - output: - from: .data.reading - - with: - source: https://my.home.com/sensor - type: my.home.sensors.humidity - correlate: - roomId: - from: .roomid - output: - from: .data.reading - as: readings - - logReading: - for: - each: reading - in: .readings - do: + execute: + sequentially: + - consumeReading: + listen: + to: + all: + - with: + source: https://my.home.com/sensor + type: my.home.sensors.temperature + correlate: + roomId: + from: .roomid + output: + from: .data.reading + - with: + source: https://my.home.com/sensor + type: my.home.sensors.humidity + correlate: + roomId: + from: .roomid + output: + from: .data.reading + as: readings + - logReading: + for: + each: reading + in: .readings + do: + call: openapi + with: + document: + uri: http://myorg.io/ordersservices.json + operationId: logreading + - generateReport: call: openapi with: document: uri: http://myorg.io/ordersservices.json - operationId: logreading - - generateReport: - call: openapi - with: - document: - uri: http://myorg.io/ordersservices.json - operationId: produceReport + operationId: produceReport timeout: after: hours: 1 \ No newline at end of file diff --git a/examples/switch-then-string.yaml b/examples/switch-then-string.yaml index f293b2cd..99c69ea1 100644 --- a/examples/switch-then-string.yaml +++ b/examples/switch-then-string.yaml @@ -4,43 +4,47 @@ document: name: sample-workflow version: '0.1.0' do: - sequentially: - - processOrder: - switch: - - case1: - when: .orderType == "electronic" - then: processElectronicOrder - - case2: - when: .orderType == "physical" - then: processPhysicalOrder - - default: - then: handleUnknownOrderType - - processElectronicOrder: - sequentially: - - validatePayment: - set: - validate: true - - fulfillOrder: - set: - status: fulfilled - then: exit - - processPhysicalOrder: - sequentially: - - checkInventory: - set: - inventory: clear - - packItems: - set: - items: 1 - - scheduleShipping: - set: - address: Elmer St - then: exit - - handleUnknownOrderType: - sequentially: - - logWarning: - set: - log: warn - - notifyAdmin: - set: - message: something's wrong \ No newline at end of file + execute: + sequentially: + - processOrder: + switch: + - case1: + when: .orderType == "electronic" + then: processElectronicOrder + - case2: + when: .orderType == "physical" + then: processPhysicalOrder + - default: + then: handleUnknownOrderType + - processElectronicOrder: + execute: + sequentially: + - validatePayment: + set: + validate: true + - fulfillOrder: + set: + status: fulfilled + then: exit + - processPhysicalOrder: + execute: + sequentially: + - checkInventory: + set: + inventory: clear + - packItems: + set: + items: 1 + - scheduleShipping: + set: + address: Elmer St + then: exit + - handleUnknownOrderType: + execute: + sequentially: + - logWarning: + set: + log: warn + - notifyAdmin: + set: + message: something's wrong \ No newline at end of file From a406b2170d6fd292186e9d9c85cbea09de701e16 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 16:40:24 +0000 Subject: [PATCH 45/51] fix: update ctk Signed-off-by: Matthias Pichler --- ctk/features/composite.feature | 43 +++++----- ctk/features/data-flow.feature | 35 ++++---- ctk/features/flow.feature | 48 +++++------ ctk/features/switch.feature | 145 +++++++++++++++++---------------- 4 files changed, 141 insertions(+), 130 deletions(-) diff --git a/ctk/features/composite.feature b/ctk/features/composite.feature index 05de0c90..0cc3b799 100644 --- a/ctk/features/composite.feature +++ b/ctk/features/composite.feature @@ -12,16 +12,17 @@ Feature: Composite Task namespace: default name: composite-sequential do: - sequentially: - - setRed: - set: - colors: ${ .colors + ["red"] } - - setGreen: - set: - colors: ${ .colors + ["green"] } - - setBlue: - set: - colors: ${ .colors + ["blue"] } + execute: + sequentially: + - setRed: + set: + colors: ${ .colors + ["red"] } + - setGreen: + set: + colors: ${ .colors + ["green"] } + - setBlue: + set: + colors: ${ .colors + ["blue"] } """ When the workflow is executed Then the workflow should complete with output: @@ -38,16 +39,18 @@ Feature: Composite Task namespace: default name: composite-sequential do: - compete: - - setRed: - set: - colors: ${ .colors + ["red"] } - - setGreen: - set: - colors: ${ .colors + ["green"] } - - setBlue: - set: - colors: ${ .colors + ["blue"] } + execute: + compete: true + concurrently: + - setRed: + set: + colors: ${ .colors + ["red"] } + - setGreen: + set: + colors: ${ .colors + ["green"] } + - setBlue: + set: + colors: ${ .colors + ["blue"] } """ When the workflow is executed Then the workflow should complete diff --git a/ctk/features/data-flow.feature b/ctk/features/data-flow.feature index a98e1348..6c92e081 100644 --- a/ctk/features/data-flow.feature +++ b/ctk/features/data-flow.feature @@ -65,23 +65,24 @@ Feature: Data Flow namespace: default name: non-object-output do: - sequentially: - - getPetById1: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables - output: - from: .id - - getPetById2: - call: http - with: - method: get - endpoint: - uri: https://petstore.swagger.io/v2/pet/2 - output: - from: '{ ids: [ $input, .id ] }' + execute: + sequentially: + - getPetById1: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} #simple interpolation, only possible with top level variables + output: + from: .id + - getPetById2: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/2 + output: + from: '{ ids: [ $input, .id ] }' """ When the workflow is executed Then the workflow should complete with output: diff --git a/ctk/features/flow.feature b/ctk/features/flow.feature index 900b902a..cad4a786 100644 --- a/ctk/features/flow.feature +++ b/ctk/features/flow.feature @@ -11,16 +11,17 @@ Feature: Flow Directive namespace: default name: implicit-sequence do: - sequentially: - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' + execute: + sequentially: + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' """ When the workflow is executed Then the workflow should complete with output: @@ -39,19 +40,20 @@ Feature: Flow Directive namespace: default name: explicit-sequence do: - sequentially: - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - then: setGreen - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - then: end - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - then: setBlue + execute: + sequentially: + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + then: setGreen + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + then: end + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + then: setBlue """ When the workflow is executed Then the workflow should complete with output: diff --git a/ctk/features/switch.feature b/ctk/features/switch.feature index 57cc4fcf..f101bef9 100644 --- a/ctk/features/switch.feature +++ b/ctk/features/switch.feature @@ -11,29 +11,31 @@ Feature: Switch Task namespace: default name: switch-match do: - - switchColor: - switch: - - red: - when: '.color == "red"' - then: setRed - - green: - when: '.color == "green"' - then: setGreen - - blue: - when: '.color == "blue"' - then: setBlue - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - then: end - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - then: end - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - then: end + execute: + sequentially; + - switchColor: + switch: + - red: + when: '.color == "red"' + then: setRed + - green: + when: '.color == "green"' + then: setGreen + - blue: + when: '.color == "blue"' + then: setBlue + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + then: end + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + then: end + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + then: end """ And given the workflow input is: """yaml @@ -55,27 +57,29 @@ Feature: Switch Task namespace: default name: switch-default-implicit do: - - switchColor: - switch: - - red: - when: '.color == "red"' - then: setRed - - green: - when: '.color == "green"' - then: setGreen - - blue: - when: '.color == "blue"' - then: setBlue - then: end - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' + execute: + sequentially: + - switchColor: + switch: + - red: + when: '.color == "red"' + then: setRed + - green: + when: '.color == "green"' + then: setGreen + - blue: + when: '.color == "blue"' + then: setBlue + then: end + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' """ And given the workflow input is: """yaml @@ -97,32 +101,33 @@ Feature: Switch Task namespace: default name: switch-default-implicit do: - sequentially: - - switchColor: - switch: - - red: - when: '.color == "red"' - then: setRed - - green: - when: '.color == "green"' - then: setGreen - - blue: - when: '.color == "blue"' - then: setBlue - - anyOtherColor: - then: setCustomColor - - setRed: - set: - colors: '${ .colors + [ "red" ] }' - - setGreen: - set: - colors: '${ .colors + [ "green" ] }' - - setBlue: - set: - colors: '${ .colors + [ "blue" ] }' - - setCustomColor: - set: - colors: '${ .colors + [ $input.color ] }' + execute: + sequentially: + - switchColor: + switch: + - red: + when: '.color == "red"' + then: setRed + - green: + when: '.color == "green"' + then: setGreen + - blue: + when: '.color == "blue"' + then: setBlue + - anyOtherColor: + then: setCustomColor + - setRed: + set: + colors: '${ .colors + [ "red" ] }' + - setGreen: + set: + colors: '${ .colors + [ "green" ] }' + - setBlue: + set: + colors: '${ .colors + [ "blue" ] }' + - setCustomColor: + set: + colors: '${ .colors + [ $input.color ] }' """ And given the workflow input is: """yaml From 901578a8478da1e5fcc713e592f92b6734d23160 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 16:46:32 +0000 Subject: [PATCH 46/51] Revert "feat: update schema" This reverts commit ab2228cea586f24b02a8fdf0281a94aed2d43bf3. Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 85 ++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 47 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 46b7e202..d83a7b45 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -76,8 +76,8 @@ properties: description: The workflow's secrets. description: Defines the workflow's reusable components. do: + description: Defines the task the workflow must perform $ref: '#/$defs/task' - description: Defines the tasks the workflow must perform timeout: $ref: '#/$defs/timeout' description: The workflow's timeout configuration, if any. @@ -118,9 +118,7 @@ $defs: description: The flow directive to be performed upon completion of the task. oneOf: - $ref: '#/$defs/callTask' - - $ref: '#/$defs/sequentialTask' - - $ref: '#/$defs/concurrentTask' - - $ref: '#/$defs/competingTask' + - $ref: '#/$defs/compositeTask' - $ref: '#/$defs/emitTask' - $ref: '#/$defs/forTask' - $ref: '#/$defs/listenTask' @@ -275,50 +273,43 @@ $defs: additionalProperties: true description: A name/value mapping of the parameters, if any, to call the function with. required: [ call ] - sequentialTask: - type: object + compositeTask: + type: object + required: [ execute ] + description: Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations properties: - sequentially: - type: array - minItems: 2 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' - description: A list of the tasks to perform sequentially. - required: [ sequentially ] - concurrentTask: - type: object - properties: - concurrently: - description: A list of the tasks to perform concurrently. - type: array - minItems: 2 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' - required: [ concurrently ] - competingTask: - type: object - properties: - compete: - type: array - minItems: 2 - items: - type: object - minProperties: 1 - maxProperties: 1 - additionalProperties: - $ref: '#/$defs/task' - description: | - A list of the tasks to perform concurrently and race against each - other, with a single possible winner, which sets the task's output. - required: [ compete ] + execute: + type: object + description: Configures the task execution strategy to use + oneOf: + - required: [ concurrently ] + properties: + concurrently: + description: A list of the tasks to perform concurrently. + type: array + minItems: 2 + items: + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' + compete: + description: Indicates whether or not the concurrent tasks are racing against each other, with a single possible winner, which sets the composite task's output. + type: boolean + default: false + - required: [ sequentially ] + properties: + sequentially: + description: A list of the tasks to perform sequentially. + type: array + minItems: 2 + items: + type: object + minProperties: 1 + maxProperties: 1 + additionalProperties: + $ref: '#/$defs/task' emitTask: type: object properties: From 36761c67f670beb415cee53b245a43f4e25f48b5 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 16:57:41 +0000 Subject: [PATCH 47/51] revert splitting of composite Signed-off-by: Matthias Pichler --- dsl-reference.md | 386 +++++++++++++++++++++-------------------------- 1 file changed, 171 insertions(+), 215 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 838a3773..c9b256f9 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -14,9 +14,7 @@ + [gRPC](#grpc-call) + [HTTP](#http-call) + [OpenAPI](#openapi-call) - - [Sequential](#sequential) - - [Concurrent](#concurrent) - - [Compete](#compete) + - [Composite](#composite) - [Emit](#emit) - [For](#for) - [Listen](#listen) @@ -173,36 +171,37 @@ use: secrets: - my-oauth2-secret do: - sequentially: - - getAvailablePets: - call: getAvailablePets - output: - from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }" - - submitMatchesByMail: - call: http - with: - method: post - endpoint: - uri: https://fake.smtp.service.com/email/send - authentication: petStoreOAuth2 - body: - from: noreply@fake.petstore.com - to: ${ .order.client.email } - subject: Candidates for Adoption - body: > - Hello ${ .order.client.preferredDisplayName }! - - Following your interest to adopt a dog, here is a list of candidates that you might be interested in: - - ${ .pets | map("-\(.name)") | join("\n") } - - Please do not hesistate to contact us at info@fake.petstore.com if your have questions. - - Hope to hear from you soon! - - ---------------------------------------------------------------------------------------------- - DO NOT REPLY - ---------------------------------------------------------------------------------------------- + execute: + sequentially: + - getAvailablePets: + call: getAvailablePets + output: + from: "$input + { availablePets: [.[] | select(.category.name == "dog" and (.tags[] | .breed == $input.order.breed))] }" + - submitMatchesByMail: + call: http + with: + method: post + endpoint: + uri: https://fake.smtp.service.com/email/send + authentication: petStoreOAuth2 + body: + from: noreply@fake.petstore.com + to: ${ .order.client.email } + subject: Candidates for Adoption + body: > + Hello ${ .order.client.preferredDisplayName }! + + Following your interest to adopt a dog, here is a list of candidates that you might be interested in: + + ${ .pets | map("-\(.name)") | join("\n") } + + Please do not hesistate to contact us at info@fake.petstore.com if your have questions. + + Hope to hear from you soon! + + ---------------------------------------------------------------------------------------------- + DO NOT REPLY + ---------------------------------------------------------------------------------------------- ``` ### Task @@ -218,9 +217,7 @@ By breaking down the [workflow](#workflow) into manageable [tasks](#task), organ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** supported by all runtimes: - [Call](#call), used to call services and/or functions. -- [Sequential](#sequential), used to define a minimum of two subtasks to perform sequentially. -- [Concurrent](#concurrent), used to define a minimum of two subtasks to perform concurrently. -- [Compete](#compete), used to define a minimum of two subtasks to perform concurrently, with a single possible winner. +- [Composite](#composite), used to define a minimum of two subtasks to perform. - [Emit](#emit), used to emit [events](#event). - [For](#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](#listen), used to listen for an [event](#event) or more. @@ -407,73 +404,21 @@ do: status: available ``` -#### Sequential - - Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks one after the other to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. - -##### Properties - -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| sequentially | [`map[string, task][]`](#task) | `yes` | The tasks to perform sequentially.*Must contain **at least** two [`tasks`](#task).* | - -##### Examples - -```yaml -document: - dsl: '1.0.0-alpha1' - namespace: test - name: sample-workflow - version: '0.1.0' -do: - sequentially: - - bookHotel: - call: http - with: - method: post - endpoint: - uri: https://fake-booking-agency.com/hotels/book - authentication: fake-booking-agency-oauth2 - body: - name: Four Seasons - city: Antwerp - country: Belgium - - bookFlight: - call: http - with: - method: post - endpoint: - uri: https://fake-booking-agency.com/flights/book - authentication: fake-booking-agency-oauth2 - body: - departure: - date: '01/01/26' - time: '07:25:00' - from: - airport: BRU - city: Zaventem - country: Belgium - arrival: - date: '01/01/26' - time: '11:12:00' - to: - airport: LIS - city: Lisbon - country: Portugal -``` - -#### Concurrent +#### Composite - Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and parallel execution of multiple subtasks to accomplish complex operations and increase performace. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. + Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. ##### Properties | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| concurrently | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | +| execute.sequentially | [`map[string, task][]`](#task) | `no` | The tasks to perform sequentially.
*Required if `execute.concurrently` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | +| execute.concurrently | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently.
*Required if `execute.sequentially` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | +| execute.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.
*Ignored if `execute.sequentially` has been set. Defaults to `false`.*
*Must **not** be set if the [`tasks`](#task) are executed sequentially.* | ##### Examples +*Executing tasks sequentially:* ```yaml document: dsl: '1.0.0-alpha1' @@ -481,37 +426,44 @@ document: name: sample-workflow version: '0.1.0' do: - concurrently: - - callNurse: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/nurses - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } - - callDoctor: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/doctor - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } + execute: + sequentially: + - bookHotel: + call: http + with: + method: post + endpoint: + uri: https://fake-booking-agency.com/hotels/book + authentication: fake-booking-agency-oauth2 + body: + name: Four Seasons + city: Antwerp + country: Belgium + - bookFlight: + call: http + with: + method: post + endpoint: + uri: https://fake-booking-agency.com/flights/book + authentication: fake-booking-agency-oauth2 + body: + departure: + date: '01/01/26' + time: '07:25:00' + from: + airport: BRU + city: Zaventem + country: Belgium + arrival: + date: '01/01/26' + time: '11:12:00' + to: + airport: LIS + city: Lisbon + country: Portugal ``` -#### Compete - -Races multiple tasks against each other, with a single possible winner, which sets the task's output. This task type is instrumental in handling scenarios where multiple tasks are competing to achieve a common goal, and only one task is needed to succeed. - -##### Properties - -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| compete | [`map[string, task][]`](#task) | `yes` | The tasks to perform concurrently. *Must contain **at least** two [`tasks`](#task).* | - -##### Examples - +*Executing tasks concurrently:* ```yaml document: dsl: '1.0.0-alpha1' @@ -519,23 +471,24 @@ document: name: sample-workflow version: '0.1.0' do: - compete: - - callNurse: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/nurses - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } - - callDoctor: - call: http - with: - method: put - endpoint: https://fake-hospital.com/api/v3/alert/doctor - body: - patientId: ${ .patient.fullName } - room: ${ .room.number } + execute: + concurrently: + - callNurse: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/nurses + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } + - callDoctor: + call: http + with: + method: put + endpoint: https://fake-hospital.com/api/v3/alert/doctor + body: + patientId: ${ .patient.fullName } + room: ${ .room.number } ``` #### Emit @@ -660,29 +613,30 @@ document: name: sample-workflow version: '0.1.0' do: - sequentially: - - processTicket: - switch: - - highPriority: - when: .ticket.priority == "high" - then: escalateToManager - - mediumPriority: - when: .ticket.priority == "medium" - then: assignToSpecialist - - lowPriority: - when: .ticket.priority == "low" - then: resolveTicket - - default: - then: raiseUndefinedPriorityError - - raiseUndefinedPriorityError: - raise: - error: - type: https://fake.com/errors/tickets/undefined-priority - status: 400 - title: Undefined Priority - - escalateToManager: {} - - assignToSpecialist: {} - - resolveTicket: {} + execute: + sequentially: + - processTicket: + switch: + - highPriority: + when: .ticket.priority == "high" + then: escalateToManager + - mediumPriority: + when: .ticket.priority == "medium" + then: assignToSpecialist + - lowPriority: + when: .ticket.priority == "low" + then: resolveTicket + - default: + then: raiseUndefinedPriorityError + - raiseUndefinedPriorityError: + raise: + error: + type: https://fake.com/errors/tickets/undefined-priority + status: 400 + title: Undefined Priority + - escalateToManager: {} + - assignToSpecialist: {} + - resolveTicket: {} ``` #### Run @@ -707,29 +661,30 @@ document: name: sample-workflow version: '0.1.0' do: - sequentially: - - runContainer: - run: - container: - image: fake-image - - - runScript: - run: - script: - language: js - code: > - Some cool multiline script - - - runShell: - run: - shell: - command: 'echo "Hello, ${ .user.name }"' - - - runWorkflow: - run: - workflow: - reference: another-one:0.1.0 - input: {} + execute: + sequentially: + - runContainer: + run: + container: + image: fake-image + + - runScript: + run: + script: + language: js + code: > + Some cool multiline script + + - runShell: + run: + shell: + command: 'echo "Hello, ${ .user.name }"' + + - runWorkflow: + run: + workflow: + reference: another-one:0.1.0 + input: {} ``` ##### Container Process @@ -887,35 +842,36 @@ document: name: sample-workflow version: '0.1.0' do: - sequentially: - - processOrder: - switch: - - case1: - when: .orderType == "electronic" - then: processElectronicOrder - - case2: - when: .orderType == "physical" - then: processPhysicalOrder - - default: - then: handleUnknownOrderType - - processElectronicOrder: - execute: - sequentially: - - validatePayment: {} - - fulfillOrder: {} - then: exit - - processPhysicalOrder: - execute: - sequentially: - - checkInventory: {} - - packItems: {} - - scheduleShipping: {} - then: exit - - handleUnknownOrderType: - execute: - sequentially: - - logWarning: {} - - notifyAdmin: {} + execute: + sequentially: + - processOrder: + switch: + - case1: + when: .orderType == "electronic" + then: processElectronicOrder + - case2: + when: .orderType == "physical" + then: processPhysicalOrder + - default: + then: handleUnknownOrderType + - processElectronicOrder: + execute: + sequentially: + - validatePayment: {} + - fulfillOrder: {} + then: exit + - processPhysicalOrder: + execute: + sequentially: + - checkInventory: {} + - packItems: {} + - scheduleShipping: {} + then: exit + - handleUnknownOrderType: + execute: + sequentially: + - logWarning: {} + - notifyAdmin: {} ``` ##### Switch Case From 2c79aa4735eb2c8bdca84dd8afaaafa1c24243e0 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 17:06:22 +0000 Subject: [PATCH 48/51] fix: rename name from task Signed-off-by: Matthias Pichler --- dsl-reference.md | 816 ++++++++++++++++++++++++----------------------- 1 file changed, 410 insertions(+), 406 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index c9b256f9..26a41cec 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -4,50 +4,50 @@ - [Abstract](#abstract) - [Definitions](#definitions) - + [Workflow](#workflow) + - [Workflow](#workflow) - [Document](#document) - [Use](#use) - [Schedule](#schedule) - + [Task](#task) + - [Task](#task) - [Call](#call) - + [AsyncAPI](#asyncapi-call) - + [gRPC](#grpc-call) - + [HTTP](#http-call) - + [OpenAPI](#openapi-call) + - [AsyncAPI](#asyncapi-call) + - [gRPC](#grpc-call) + - [HTTP](#http-call) + - [OpenAPI](#openapi-call) - [Composite](#composite) - [Emit](#emit) - [For](#for) - [Listen](#listen) - [Raise](#raise) - [Run](#run) - + [Container](#container-process) - + [Shell](#shell-process) - + [Script](#script-process) - + [Workflow](#workflow-process) + - [Container](#container-process) + - [Shell](#shell-process) + - [Script](#script-process) + - [Workflow](#workflow-process) - [Switch](#switch) - [Set](#set) - [Try](#try) - [Wait](#wait) - + [Flow Directive](#flow-directive) - + [External Resource](#external-resource) - + [Authentication](#authentication) + - [Flow Directive](#flow-directive) + - [External Resource](#external-resource) + - [Authentication](#authentication) - [Basic](#basic-authentication) - [Bearer](#bearer-authentication) - [Certificate](#certificate-authentication) - [Digest](#digest-authentication) - [OAUTH2](#oauth2-authentication) - + [Extension](#extension) - + [Error](#error) + - [Extension](#extension) + - [Error](#error) - [Standard Error Types](#standard-error-types) - + [Event Consumption Strategy](#event-consumption-strategy) - + [Event Filter](#event-filter) - + [Retry](#retry) - + [Input](#input) - + [Output](#output) - + [Timeout](#timeout) - + [Duration](#duration) - + [HTTP Response](#http-response) - + [HTTP Request](#http-request) + - [Event Consumption Strategy](#event-consumption-strategy) + - [Event Filter](#event-filter) + - [Retry](#retry) + - [Input](#input) + - [Output](#output) + - [Timeout](#timeout) + - [Duration](#duration) + - [HTTP Response](#http-response) + - [HTTP Request](#http-request) ## Abstract @@ -61,63 +61,63 @@ A [workflow](#workflow) serves as a blueprint outlining the series of [tasks](#t #### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| document | [`document`](#document) | `yes` | Documents the defined workflow. | -| input | [`input`](#input) | `no` | Configures the workflow's input. | -| use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. | -| do | [`task`](#task) | `yes` | The [task](#task) that must be performed by the [workflow](#workflow). | -| timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. | -| output | [`output`](#output) | `no` | Configures the workflow's output. | -| schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. | -| evaluate | [`evaluate`](#evaluate) | `no` | Configures runtime expression evaluation. | +| Name | Type | Required | Description | +| :------- | :---------------------: | :------: | :--------------------------------------------------------------------- | +| document | [`document`](#document) | `yes` | Documents the defined workflow. | +| input | [`input`](#input) | `no` | Configures the workflow's input. | +| use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. | +| do | [`task`](#task) | `yes` | The [task](#task) that must be performed by the [workflow](#workflow). | +| timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. | +| output | [`output`](#output) | `no` | Configures the workflow's output. | +| schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. | +| evaluate | [`evaluate`](#evaluate) | `no` | Configures runtime expression evaluation. | #### Document Documents the workflow definition. -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| dsl | `string` | `yes` | The version of the DSL used to define the workflow. | -| namespace | `string` | `yes` | The workflow's namespace.
| -| name | `string` | `yes` | The workflow's name.
| -| version | `string` | `yes` | The workflow's [semantic version] -| title | `string` | `no` | The workflow's title. | -| summary | `string` | `no` | The workflow's Markdown summary. | -| tags | `map[string, string]` | `no` | A key/value mapping of the workflow's tags, if any. | +| Name | Type | Required | Description | +| :-------- | :-------------------: | :------: | :-------------------------------------------------- | +| dsl | `string` | `yes` | The version of the DSL used to define the workflow. | +| namespace | `string` | `yes` | The workflow's namespace.
| +| name | `string` | `yes` | The workflow's name.
| +| version | `string` | `yes` | The workflow's [semantic version] | +| title | `string` | `no` | The workflow's title. | +| summary | `string` | `no` | The workflow's Markdown summary. | +| tags | `map[string, string]` | `no` | A key/value mapping of the workflow's tags, if any. | #### Use Defines the workflow's reusable components. -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| authentications | [`map[string, authentication]`](#authentication) | `no` | A name/value mapping of the workflow's reusable authentication policies. | -| errors | [`map[string, error]`](#error) | `no` | A name/value mapping of the workflow's reusable errors. | -| extensions | [`map[string, extension][]`](#extension) | `no` | A list of the workflow's reusable extensions. | -| functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. | -| retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. | -| secrets | `string[]` | `no` | A list containing the workflow's secrets. | +| Name | Type | Required | Description | +| :-------------- | :----------------------------------------------: | :------: | :----------------------------------------------------------------------- | +| authentications | [`map[string, authentication]`](#authentication) | `no` | A name/value mapping of the workflow's reusable authentication policies. | +| errors | [`map[string, error]`](#error) | `no` | A name/value mapping of the workflow's reusable errors. | +| extensions | [`map[string, extension][]`](#extension) | `no` | A list of the workflow's reusable extensions. | +| functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. | +| retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. | +| secrets | `string[]` | `no` | A list containing the workflow's secrets. | #### Schedule Configures the schedule of a workflow. -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| every | [`duration`](#duration) | `no` | Specifies the duration of the interval at which the workflow should be executed. Unlike `after`, this option will run the workflow regardless of whether the previous run is still in progress.
*Required when no other property has been set.* | -| cron | `string` | `no` | Specifies the schedule using a CRON expression, e.g., '0 0 * * *' for daily at midnight.
*Required when no other property has been set.* | -| after | [`duration`](#duration) | `no` | Specifies a delay duration that the workflow must wait before starting again after it completes. In other words, when this workflow completes, it should run again after the specified amount of time.
*Required when no other property has been set.* | -| on | [`eventConsumptionStrategy`](#event-consumption-strategy) | `no` | Specifies the events that trigger the workflow execution.
*Required when no other property has been set.* | +| Name | Type | Required | Description | +| :---- | :-------------------------------------------------------: | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| every | [`duration`](#duration) | `no` | Specifies the duration of the interval at which the workflow should be executed. Unlike `after`, this option will run the workflow regardless of whether the previous run is still in progress.
_Required when no other property has been set._ | +| cron | `string` | `no` | Specifies the schedule using a CRON expression, e.g., '0 0 \* \* *' for daily at midnight.
*Required when no other property has been set.\* | +| after | [`duration`](#duration) | `no` | Specifies a delay duration that the workflow must wait before starting again after it completes. In other words, when this workflow completes, it should run again after the specified amount of time.
_Required when no other property has been set._ | +| on | [`eventConsumptionStrategy`](#event-consumption-strategy) | `no` | Specifies the events that trigger the workflow execution.
_Required when no other property has been set._ | #### Evaluate Configures a workflow's runtime expression evaluation. -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| language | `string` | `yes` | The language used for writting runtime expressions.
*Defaults to `jq`.* | -| mode | `string` | `yes` | The runtime expression evaluation mode.
*Supported values are:*
- `strict`: requires all expressions to be enclosed within `${ }` for proper identification and evaluation.
- `loose`: evaluates any value provided. If the evaluation fails, it results in a string with the expression as its content.
*Defaults to `strict`.* +| Name | Type | Required | Description | +| :------- | :------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| language | `string` | `yes` | The language used for writting runtime expressions.
_Defaults to `jq`._ | +| mode | `string` | `yes` | The runtime expression evaluation mode.
_Supported values are:_
- `strict`: requires all expressions to be enclosed within `${ }` for proper identification and evaluation.
- `loose`: evaluates any value provided. If the evaluation fails, it results in a string with the expression as its content.
_Defaults to `strict`._ | #### Examples @@ -206,11 +206,11 @@ do: ### Task -A task within a [workflow](#workflow) represents a discrete unit of work that contributes to achieving the overall objectives defined by the [workflow](#workflow). +A task within a [workflow](#workflow) represents a discrete unit of work that contributes to achieving the overall objectives defined by the [workflow](#workflow). -It encapsulates a specific action or set of actions that need to be executed in a predefined order to advance the workflow towards its completion. +It encapsulates a specific action or set of actions that need to be executed in a predefined order to advance the workflow towards its completion. -[Tasks](#task) are designed to be modular and focused, each serving a distinct purpose within the broader context of the [workflow](#workflow). +[Tasks](#task) are designed to be modular and focused, each serving a distinct purpose within the broader context of the [workflow](#workflow). By breaking down the [workflow](#workflow) into manageable [tasks](#task), organizations can effectively coordinate and track progress, enabling efficient collaboration and ensuring that work is completed in a structured and organized manner. @@ -222,21 +222,20 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su - [For](#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](#listen), used to listen for an [event](#event) or more. - [Raise](#raise), used to raise an [error](#error) and potentially fault the [workflow](#workflow). -- [Run](#run), used to run a [container](#container), a [script](#script) or event a [shell](#shell) command. +- [Run](#run), used to run a [container](#container), a [script](#script) or event a [shell](#shell) command. - [Switch](#switch), used to dynamically select and execute one of multiple alternative paths based on specified conditions -- [Set](#set), used to dynamically set or update the [workflow](#workflow)'s data during the its execution. +- [Set](#set), used to dynamically set or update the [workflow](#workflow)'s data during the its execution. - [Try](#try), used to attempt executing a specified [task](#task), and to handle any resulting [errors](#error) gracefully, allowing the [workflow](#workflow) to continue without interruption. - [Wait](#wait), used to pause or wait for a specified duration before proceeding to the next task. #### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| name | `string` | `no` | The name of the task, if any. **SHOULD** be unique within an array. Required if you want to reference the task in [`then`](#flow-directive) | -| 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. | -| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. | -| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.
*If not set, defaults to `continue`.* | +| Name | Type | Required | Description | +| :------ | :--------------------------------: | :------: | :-------------------------------------------------------------------------------- | +| 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. | +| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. | +| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.
_If not set, defaults to `continue`._ | #### Call @@ -244,19 +243,19 @@ Enables the execution of a specified function within a workflow, allowing seamle ##### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| call | `string` | `yes` | The name of the function to call. | -| with | `map` | `no` | A name/value mapping of the parameters to call the function with | +| Name | Type | Required | Description | +| :--- | :------: | :------: | :--------------------------------------------------------------- | +| call | `string` | `yes` | The name of the function to call. | +| with | `map` | `no` | A name/value mapping of the parameters to call the function with | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: call: http with: @@ -277,24 +276,24 @@ The [AsyncAPI Call](#asyncapi-call) enables workflows to interact with external ###### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| document | [`externalResource`](#external-resource) | `yes` | The AsyncAPI document that defines the operation to call. | -| operationRef | `string` | `yes` | A reference to the AsyncAPI operation to call. | -| server | `string` | `no` | A reference to the server to call the specified AsyncAPI operation on.
If not set, default to the first server matching the operation's channel. | -| message | `string` | `no` | The name of the message to use.
If not set, defaults to the first message defined by the operation. | -| binding | `string` | `no` | The name of the binding to use.
If not set, defaults to the first binding defined by the operation | -| payload | `any` | `no` | The operation's payload, as defined by the configured message | -| authentication | `string`
[`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the AsyncAPI operation. | +| Name | Type | Required | Description | +| :------------- | :---------------------------------------------: | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------- | +| document | [`externalResource`](#external-resource) | `yes` | The AsyncAPI document that defines the operation to call. | +| operationRef | `string` | `yes` | A reference to the AsyncAPI operation to call. | +| server | `string` | `no` | A reference to the server to call the specified AsyncAPI operation on.
If not set, default to the first server matching the operation's channel. | +| message | `string` | `no` | The name of the message to use.
If not set, defaults to the first message defined by the operation. | +| binding | `string` | `no` | The name of the binding to use.
If not set, defaults to the first binding defined by the operation | +| payload | `any` | `no` | The operation's payload, as defined by the configured message | +| authentication | `string`
[`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the AsyncAPI operation. | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: call: asyncapi with: @@ -313,24 +312,24 @@ The [gRPC Call](#grpc-call) enables communication with external systems via the ###### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| proto | [`externalResource`](#external-resource) | `yes` | The proto resource that describes the GRPC service to call. | -| service.name | `string` | `yes` | The name of the GRPC service to call. | -| service.host | `string` | `yes` | The hostname of the GRPC service to call. | -| service.port | `integer` | `no` | The port number of the GRPC service to call. | -| service.authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the GRPC service. | -| method | `string` | `yes` | The name of the GRPC service method to call. | -| arguments | `map` | `no` | A name/value mapping of the method call's arguments, if any. | +| Name | Type | Required | Description | +| :--------------------- | :--------------------------------------: | :------: | :--------------------------------------------------------------------------------------------------------- | +| proto | [`externalResource`](#external-resource) | `yes` | The proto resource that describes the GRPC service to call. | +| service.name | `string` | `yes` | The name of the GRPC service to call. | +| service.host | `string` | `yes` | The hostname of the GRPC service to call. | +| service.port | `integer` | `no` | The port number of the GRPC service to call. | +| service.authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the GRPC service. | +| method | `string` | `yes` | The name of the GRPC service method to call. | +| arguments | `map` | `no` | A name/value mapping of the method call's arguments, if any. | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: call: grpc with: @@ -350,22 +349,22 @@ The [HTTP Call](#http-call) enables workflows to interact with external services ###### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| method | `string` | `yes` | The HTTP request method. | -| endpoint | [`endpoint`](#endpoint) | `yes` | An URI or an object that describes the HTTP endpoint to call. | -| headers | `map` | `no` | A name/value mapping of the HTTP headers to use, if any. | -| body | `any` | `no` | The HTTP request body, if any. | -| output | `string` | `no` | The http call's output format.
*Supported values are:*
*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*
*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*
*- `response`, which outputs the [http response](#http-response).*
*Defaults to `content`.* | +| Name | Type | Required | Description | +| :------- | :---------------------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| method | `string` | `yes` | The HTTP request method. | +| endpoint | [`endpoint`](#endpoint) | `yes` | An URI or an object that describes the HTTP endpoint to call. | +| headers | `map` | `no` | A name/value mapping of the HTTP headers to use, if any. | +| body | `any` | `no` | The HTTP request body, if any. | +| output | `string` | `no` | The http call's output format.
_Supported values are:_
_- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any._
_- `content`, which outputs the content of [http response](#http-response), possibly deserialized._
_- `response`, which outputs the [http response](#http-response)._
_Defaults to `content`._ | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: call: http with: @@ -379,22 +378,22 @@ The [OpenAPI Call](#openapi-call) enables workflows to interact with external se ###### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| document | [`externalResource`](#external-resource) | `yes` | The OpenAPI document that defines the operation to call. | -| operationId | `string` | `yes` | The id of the OpenAPI operation to call. | -| arguments | `map` | `no` | A name/value mapping of the parameters, if any, of the OpenAPI operation to call. | -| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the OpenAPI operation. | -| output | `string` | `no` | The OpenAPI call's output format.
*Supported values are:*
*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*
*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*
*- `response`, which outputs the [http response](#http-response).*
*Defaults to `content`.* | +| Name | Type | Required | Description | +| :------------- | :--------------------------------------: | :------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| document | [`externalResource`](#external-resource) | `yes` | The OpenAPI document that defines the operation to call. | +| operationId | `string` | `yes` | The id of the OpenAPI operation to call. | +| arguments | `map` | `no` | A name/value mapping of the parameters, if any, of the OpenAPI operation to call. | +| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the OpenAPI operation. | +| output | `string` | `no` | The OpenAPI call's output format.
_Supported values are:_
_- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any._
_- `content`, which outputs the content of [http response](#http-response), possibly deserialized._
_- `response`, which outputs the [http response](#http-response)._
_Defaults to `content`._ | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: call: openapi with: @@ -406,25 +405,26 @@ do: #### Composite - Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. +Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. ##### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| execute.sequentially | [`map[string, task][]`](#task) | `no` | The tasks to perform sequentially.
*Required if `execute.concurrently` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | -| execute.concurrently | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently.
*Required if `execute.sequentially` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | -| execute.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.
*Ignored if `execute.sequentially` has been set. Defaults to `false`.*
*Must **not** be set if the [`tasks`](#task) are executed sequentially.* | +| Name | Type | Required | Description | +| :------------------- | :----------------------------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| execute.sequentially | [`map[string, task][]`](#task) | `no` | The tasks to perform sequentially.
_Required if `execute.concurrently` has not been set, otherwise ignored._
_If set, must contains **at least** two [`tasks`](#task)._ | +| execute.concurrently | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently.
_Required if `execute.sequentially` has not been set, otherwise ignored._
_If set, must contains **at least** two [`tasks`](#task)._ | +| execute.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.
_Ignored if `execute.sequentially` has been set. Defaults to `false`._
_Must **not** be set if the [`tasks`](#task) are executed sequentially._ | ##### Examples -*Executing tasks sequentially:* +_Executing tasks sequentially:_ + ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: execute: sequentially: @@ -432,7 +432,7 @@ do: call: http with: method: post - endpoint: + endpoint: uri: https://fake-booking-agency.com/hotels/book authentication: fake-booking-agency-oauth2 body: @@ -443,33 +443,34 @@ do: call: http with: method: post - endpoint: + endpoint: uri: https://fake-booking-agency.com/flights/book authentication: fake-booking-agency-oauth2 body: departure: - date: '01/01/26' - time: '07:25:00' + date: "01/01/26" + time: "07:25:00" from: airport: BRU city: Zaventem country: Belgium arrival: - date: '01/01/26' - time: '11:12:00' + date: "01/01/26" + time: "11:12:00" to: airport: LIS city: Lisbon country: Portugal ``` -*Executing tasks concurrently:* +_Executing tasks concurrently:_ + ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: execute: concurrently: @@ -497,18 +498,18 @@ Allows workflows to publish events to event brokers or messaging systems, facili ##### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| emit.event | [`event`](#event) | `yes` | Defines the event to emit. | +| Name | Type | Required | Description | +| :--------- | :---------------: | :------: | :------------------------- | +| emit.event | [`event`](#event) | `yes` | Defines the event to emit. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: emit: event: @@ -520,8 +521,8 @@ do: firstName: Cruella lastName: de Vil items: - - breed: dalmatian - quantity: 101 + - breed: dalmatian + quantity: 101 ``` #### For @@ -530,22 +531,22 @@ Allows workflows to iterate over a collection of items, executing a defined set ##### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| for.each | `string` | `no` | The name of the variable used to store the current item being enumerated.
Defaults to `item`. | -| for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. | -| for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.
Defaults to `index`. | -| while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. | -| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. | +| Name | Type | Required | Description | +| :------- | :-------------: | :------: | :---------------------------------------------------------------------------------------------------------------------------------- | +| for.each | `string` | `no` | The name of the variable used to store the current item being enumerated.
Defaults to `item`. | +| for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. | +| for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.
Defaults to `index`. | +| while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. | +| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: for: each: pet @@ -559,39 +560,39 @@ do: with: type: com.fake.petclinic.pets.checkup.completed.v2 output: - to: '.pets + [{ "id": $pet.id }]' + to: '.pets + [{ "id": $pet.id }]' ``` #### Listen -Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems. +Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems. ##### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| listen.to | [`eventConsumptionStrategy`](#event-consumption-strategy) | `yes` | Configures the event(s) the workflow must listen to. | +| Name | Type | Required | Description | +| :-------- | :-------------------------------------------------------: | :------: | :--------------------------------------------------- | +| listen.to | [`eventConsumptionStrategy`](#event-consumption-strategy) | `yes` | Configures the event(s) the workflow must listen to. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: listen: to: any: - - with: - type: com.fake-hospital.vitals.measurements.temperature - data: - temperature: ${ .temperature > 38 } - - with: - type: com.fake-hospital.vitals.measurements.bpm - data: - temperature: ${ .bpm < 60 or .bpm > 100 } + - with: + type: com.fake-hospital.vitals.measurements.temperature + data: + temperature: ${ .temperature > 38 } + - with: + type: com.fake-hospital.vitals.measurements.bpm + data: + temperature: ${ .bpm < 60 or .bpm > 100 } ``` #### Raise @@ -600,18 +601,18 @@ Intentionally triggers and propagates errors. By employing the "Raise" task, wor ##### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| raise.error | [`error`](#error) | `yes` | Defines the error to raise. | +| Name | Type | Required | Description | +| :---------- | :---------------: | :------: | :-------------------------- | +| raise.error | [`error`](#error) | `yes` | Defines the error to raise. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: execute: sequentially: @@ -645,21 +646,21 @@ Provides the capability to execute external [containers](#container-process), [s ##### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| run.container | [`container`](#container-process) | `no` | The definition of the container to run.
*Required if `script`, `shell` and `workflow` have not been set.* | -| run.script | [`script`](#script-process) | `no` | The definition of the script to run.
*Required if `container`, `shell` and `workflow` have not been set.* | -| run.shell | [`shell`](#shell-process) | `no` | The definition of the shell command to run.
*Required if `container`, `script` and `workflow` have not been set.* | -| run.workflow | [`workflow`](#workflow-process) | `no` | The definition of the workflow to run.
*Required if `container`, `script` and `shell` have not been set.* | +| Name | Type | Required | Description | +| :------------ | :-------------------------------: | :------: | :------------------------------------------------------------------------------------------------------------------- | +| run.container | [`container`](#container-process) | `no` | The definition of the container to run.
_Required if `script`, `shell` and `workflow` have not been set._ | +| run.script | [`script`](#script-process) | `no` | The definition of the script to run.
_Required if `container`, `shell` and `workflow` have not been set._ | +| run.shell | [`shell`](#shell-process) | `no` | The definition of the shell command to run.
_Required if `container`, `script` and `workflow` have not been set._ | +| run.workflow | [`workflow`](#workflow-process) | `no` | The definition of the workflow to run.
_Required if `container`, `script` and `shell` have not been set._ | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: execute: sequentially: @@ -693,22 +694,22 @@ Enables the execution of external processes encapsulated within a containerized ###### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| image | `string` | `yes` | The name of the container image to run | -| command | `string` | `no` | The command, if any, to execute on the container | -| ports | `map` | `no` | The container's port mappings, if any | -| volumes | `map` | `no` | The container's volume mappings, if any | -| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| Name | Type | Required | Description | +| :---------- | :------: | :------: | :--------------------------------------------------------------------------------------------------- | +| image | `string` | `yes` | The name of the container image to run | +| command | `string` | `no` | The command, if any, to execute on the container | +| ports | `map` | `no` | The container's port mappings, if any | +| volumes | `map` | `no` | The container's volume mappings, if any | +| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: run: container: @@ -721,21 +722,21 @@ Enables the execution of custom scripts or code within a workflow, empowering wo ###### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| language | `string` | `yes` | The language of the script to run | -| code | `string` | `no` | The script's code.
*Required if `source` has not been set.* | -| source | [externalResource](#external-resource) | `no` | The script's resource.
*Required if `code` has not been set.* | -| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| Name | Type | Required | Description | +| :---------- | :------------------------------------: | :------: | :--------------------------------------------------------------------------------------------------- | +| language | `string` | `yes` | The language of the script to run | +| code | `string` | `no` | The script's code.
_Required if `source` has not been set._ | +| source | [externalResource](#external-resource) | `no` | The script's resource.
_Required if `code` has not been set._ | +| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: run: script: @@ -750,20 +751,20 @@ Enables the execution of shell commands within a workflow, enabling workflows to ###### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| command | `string` | `yes` | The shell command to run | -| arguments | `map` | `no` | A list of the arguments of the shell command to run | -| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| Name | Type | Required | Description | +| :---------- | :------: | :------: | :--------------------------------------------------------------------------------------------------- | +| command | `string` | `yes` | The shell command to run | +| arguments | `map` | `no` | A list of the arguments of the shell command to run | +| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: run: shell: @@ -776,20 +777,20 @@ Enables the invocation and execution of nested workflows within a parent workflo ###### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| name | `string` | `yes` | The name of the workflow to run | -| version | `string` | `yes` | The version of the workflow to run. Defaults to `latest` | -| input | `any` | `no` | The data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified | +| Name | Type | Required | Description | +| :------ | :------: | :------: | :---------------------------------------------------------------------------------------------------------------------------------------------------- | +| name | `string` | `yes` | The name of the workflow to run | +| version | `string` | `yes` | The version of the workflow to run. Defaults to `latest` | +| input | `any` | `no` | The data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified | ###### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: run: workflow: @@ -804,9 +805,9 @@ A task used to set data. ##### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| set | `object` | `yes` | A name/value mapping of the data to set. | +| Name | Type | Required | Description | +| :--- | :------: | :------: | :--------------------------------------- | +| set | `object` | `yes` | A name/value mapping of the data to set. | ##### Examples @@ -815,7 +816,7 @@ document: dsl: 1.0.0-alpha1 namespace: default name: set - version: '0.1.0' + version: "0.1.0" do: set: shape: circle @@ -829,18 +830,18 @@ Enables conditional branching within workflows, allowing them to dynamically sel ##### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| switch | [`case[]`](#switch-case) | `yes` | A name/value map of the cases to switch on | +| Name | Type | Required | Description | +| :----- | :----------------------: | :------: | :----------------------------------------- | +| switch | [`case[]`](#switch-case) | `yes` | A name/value map of the cases to switch on | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: execute: sequentially: @@ -878,11 +879,11 @@ do: Defines a switch case, encompassing of a condition for matching and an associated action to execute upon a match. -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| name | `string` | `no` | The name of the case, if any. | -| when | `string` | `no` | A runtime expression used to determine whether or not the case matches.
*If not set, the case will be matched by default if no other case match.*
*Note that there can be only one default case, all others **MUST** set a condition.* -| then | [`flowDirective`](#flow-directive) | `yes` | The flow directive to execute when the case matches. | +| Name | Type | Required | Description | +| :--- | :--------------------------------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| name | `string` | `no` | The name of the case, if any. | +| when | `string` | `no` | A runtime expression used to determine whether or not the case matches.
_If not set, the case will be matched by default if no other case match._
_Note that there can be only one default case, all others **MUST** set a condition._ | +| then | [`flowDirective`](#flow-directive) | `yes` | The flow directive to execute when the case matches. | #### Try @@ -890,19 +891,19 @@ Serves as a mechanism within workflows to handle errors gracefully, potentially ##### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| try | [`task`](#task) | `yes` | The task(s) to perform. | -| catch | [`catch`](#catch) | `yes` | Configures the errors to catch and how to handle them. | +| Name | Type | Required | Description | +| :---- | :---------------: | :------: | :----------------------------------------------------- | +| try | [`task`](#task) | `yes` | The task(s) to perform. | +| catch | [`catch`](#catch) | `yes` | Configures the errors to catch and how to handle them. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: try: call: http @@ -931,14 +932,14 @@ Defines the configuration of a catch clause, which a concept used to catch error ###### Properties -| Name | Type | Required | Description | -|:--|:---:|:---:|:---| -| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch | -| as | `string` | `no` | The name of the runtime expression variable to save the error as. Defaults to 'error'. | -| when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error | -| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | -| retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors | -| do | [`task`](#task) | `no` | The definition of the task to run when catching an error | +| Name | Type | Required | Description | +| :--------- | :---------------------: | :------: | :------------------------------------------------------------------------------------- | +| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch | +| as | `string` | `no` | The name of the runtime expression variable to save the error as. Defaults to 'error'. | +| when | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | +| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | +| retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors | +| do | [`task`](#task) | `no` | The definition of the task to run when catching an error | #### Wait @@ -946,18 +947,18 @@ Allows workflows to pause or delay their execution for a specified period of tim ##### Properties -| Name | Type | Required | Description| -|:--|:---:|:---:|:---| -| wait | `string`
[`duration`](#duration) | `yes` | The amount of time to wait.
If a `string`, must be a valid [ISO 8601](#) duration expression. | +| Name | Type | Required | Description | +| :--- | :---------------------------------: | :------: | :----------------------------------------------------------------------------------------------- | +| wait | `string`
[`duration`](#duration) | `yes` | The amount of time to wait.
If a `string`, must be a valid [ISO 8601](#) duration expression. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: wait: seconds: 10 @@ -967,12 +968,12 @@ do: Flow Directives are commands within a workflow that dictate its progression. -| Directive | Description | -| --------- | ----------- | +| Directive | Description | +| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `"continue"` | Instructs the workflow to proceed with the next task in line. This action may conclude the execution of a particular workflow or branch if there are not task defined after the continue one. | -| `"exit"` | Halts the current branch's execution, potentially terminating the entire workflow if the current task resides within the main branch. | -| `"end"` | Provides a graceful conclusion to the workflow execution, signaling its completion explicitly. | -| `string` | Continues the workflow at the task with the specified name | +| `"exit"` | Halts the current branch's execution, potentially terminating the entire workflow if the current task resides within the main branch. | +| `"end"` | Provides a graceful conclusion to the workflow execution, signaling its completion explicitly. | +| `string` | Continues the workflow at the task with the specified name | ### External Resource @@ -980,11 +981,11 @@ Defines an external resource. #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| name | `string` | `no` | The name, if any, of the defined resource. | -| uri | `string` | `yes` | The URI at which to get the defined resource. | -| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when fecthing the resource. | +| Property | Type | Required | Description | +| -------------- | :---------------------------------: | :------: | ------------------------------------------------------------------------------------------------------- | +| name | `string` | `no` | The name, if any, of the defined resource. | +| uri | `string` | `yes` | The URI at which to get the defined resource. | +| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when fecthing the resource. | ##### Examples @@ -1003,22 +1004,22 @@ Defines the mechanism used to authenticate users and workflows attempting to acc #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| basic | [`basicAuthentication`](#basic-authentication) | `no` | The `basic` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| bearer | [`bearerAuthentication`](#bearer-authentication) | `no` | The `bearer` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| certificate | [`certificateAuthentication`](#certificate-authentication) | `no` | The `certificate` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| digest | [`digestAuthentication`](#digest-authentication) | `no` | The `digest` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| oauth2 | [`oauth2`](#oauth2-authentication) | `no` | The `oauth2` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| Property | Type | Required | Description | +| ----------- | :--------------------------------------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------- | +| basic | [`basicAuthentication`](#basic-authentication) | `no` | The `basic` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| bearer | [`bearerAuthentication`](#bearer-authentication) | `no` | The `bearer` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| certificate | [`certificateAuthentication`](#certificate-authentication) | `no` | The `certificate` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| digest | [`digestAuthentication`](#digest-authentication) | `no` | The `digest` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| oauth2 | [`oauth2`](#oauth2-authentication) | `no` | The `oauth2` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" use: secrets: usernamePasswordSecret: {} @@ -1029,7 +1030,7 @@ do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: sampleBasicFromSecret ``` @@ -1040,19 +1041,19 @@ Defines the fundamentals of a 'basic' authentication. ##### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| username | `string` | `yes` | The username to use. | -| password | `string` | `yes` | The password to use. | +| Property | Type | Required | Description | +| -------- | :------: | :------: | -------------------- | +| username | `string` | `yes` | The username to use. | +| password | `string` | `yes` | The password to use. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" use: authentication: sampleBasic: @@ -1063,7 +1064,7 @@ do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: sampleBasic ``` @@ -1074,23 +1075,23 @@ Defines the fundamentals of a 'bearer' authentication ##### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| token | `string` | `yes` | The bearer token to use. | +| Property | Type | Required | Description | +| -------- | :------: | :------: | ------------------------ | +| token | `string` | `yes` | The bearer token to use. | ##### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: bearer: @@ -1099,28 +1100,26 @@ do: #### Certificate Authentication - #### Digest Authentication - #### OAUTH2 Authentication Defines the fundamentals of an 'oauth2' authentication ##### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| authority | `string` | `yes` | The URI that references the OAuth2 authority to use. | -| grant | `string` | `yes` | The grant type to use. -| client.id | `string` | `yes` | The client id to use. | -| client.secret | `string` | `no` | The client secret to use, if any. | -| scopes | `string[]` | `no` | The scopes, if any, to request the token for. | -| audiences | `string[]` | `no` | The audiences, if any, to request the token for. | -| username | `string` | `no` | The username to use. Used only if the grant type is `Password`. | -| password | `string` | `no` | The password to use. Used only if the grant type is `Password`. | -| subject | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the party on behalf of whom the request is being made. | -| actor | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the acting party. | +| Property | Type | Required | Description | +| ------------- | :----------------------------: | :------: | --------------------------------------------------------------------------------------------------------- | +| authority | `string` | `yes` | The URI that references the OAuth2 authority to use. | +| grant | `string` | `yes` | The grant type to use. | +| client.id | `string` | `yes` | The client id to use. | +| client.secret | `string` | `no` | The client secret to use, if any. | +| scopes | `string[]` | `no` | The scopes, if any, to request the token for. | +| audiences | `string[]` | `no` | The audiences, if any, to request the token for. | +| username | `string` | `no` | The username to use. Used only if the grant type is `Password`. | +| password | `string` | `no` | The password to use. Used only if the grant type is `Password`. | +| subject | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the party on behalf of whom the request is being made. | +| actor | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the acting party. | ##### Examples @@ -1134,7 +1133,7 @@ do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: oauth2: @@ -1153,10 +1152,10 @@ Represents the definition of an OAUTH2 token ###### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| token | `string` | `yes` | The security token to use to use. | -| type | `string` | `yes` | The type of security token to use. | +| Property | Type | Required | Description | +| -------- | :------: | :------: | ---------------------------------- | +| token | `string` | `yes` | The security token to use to use. | +| type | `string` | `yes` | The type of security token to use. | ### Extension @@ -1166,16 +1165,17 @@ Extensions enable the execution of tasks prior to those they extend, offering th #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | -| when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | -| before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | -| after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | +| Property | Type | Required | Description | +| -------- | :-------------: | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | +| when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | +| before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | +| after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | #### Examples -*Perform logging before and after any non-extension task is run:* +_Perform logging before and after any non-extension task is run:_ + ```yaml document: dsl: '1.0.0-alpha1' @@ -1207,13 +1207,14 @@ do: endpoint: https://fake.com/sample ``` -*Intercept HTTP calls to 'https://mocked.service.com' and mock its response:* +_Intercept HTTP calls to 'https://mocked.service.com' and mock its response:_ + ```yaml -document: - dsl: '1.0.0-alpha1' +document: + dsl: "1.0.0-alpha1" namespace: test name: sample-workflow - version: '0.1.0' + version: "0.1.0" use: extensions: - mockService: @@ -1241,13 +1242,13 @@ Defines the [Problem Details RFC](https://datatracker.ietf.org/doc/html/rfc7807) #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| type | `string` | `yes` | A URI reference that identifies the [`error`](#error) type.
For cross-compatibility concerns, it is strongly recommended to use [Standard Error Types](#standard-error-types) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | -| status | `integer` | `yes` | The status code generated by the origin for this occurrence of the [`error`](#error).
For cross-compatibility concerns, it is strongly recommended to use [HTTP Status Codes](https://datatracker.ietf.org/doc/html/rfc7231#section-6) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | -| instance | `string` | `yes` | A [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) used to reference the component the [`error`](#error) originates from.
Runtimes **MUST** set the property when raising or escalating the [`error`](#error). Otherwise ignore. | -| title | `string` | `no` | A short, human-readable summary of the [`error`](#error). | -| detail | `string` | `no` | A human-readable explanation specific to this occurrence of the [`error`](#error). | +| Property | Type | Required | Description | +| -------- | :-------: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| type | `string` | `yes` | A URI reference that identifies the [`error`](#error) type.
For cross-compatibility concerns, it is strongly recommended to use [Standard Error Types](#standard-error-types) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | +| status | `integer` | `yes` | The status code generated by the origin for this occurrence of the [`error`](#error).
For cross-compatibility concerns, it is strongly recommended to use [HTTP Status Codes](https://datatracker.ietf.org/doc/html/rfc7231#section-6) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | +| instance | `string` | `yes` | A [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) used to reference the component the [`error`](#error) originates from.
Runtimes **MUST** set the property when raising or escalating the [`error`](#error). Otherwise ignore. | +| title | `string` | `no` | A short, human-readable summary of the [`error`](#error). | +| detail | `string` | `no` | A human-readable explanation specific to this occurrence of the [`error`](#error). | #### Examples @@ -1261,18 +1262,18 @@ status: 503 Standard error types serve the purpose of categorizing errors consistently across different runtimes, facilitating seamless migration from one runtime environment to another. -| Type | Status¹ | Description | -|------|:-------:|-------------| -| [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. | -| [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. | -| [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. | -| [https://https://serverlessworkflow.io/spec/1.0.0/errors/authentication](#) | `401` | Errors related to authentication failures. | -| [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. | -| [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. | -| [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. | -| [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. | +| Type | Status¹ | Description | +| --------------------------------------------------------------------------- | :-----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [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. | +| [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. | +| [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. | +| [https://https://serverlessworkflow.io/spec/1.0.0/errors/authentication](#) | `401` | Errors related to authentication failures. | +| [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. | +| [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. | +| [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. | +| [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. | -¹ *Default value. The `status code` that best describe the error should always be used.* +¹ _Default value. The `status code` that best describe the error should always be used._ ### Event Consumption Strategy @@ -1280,11 +1281,11 @@ Represents the configuration of an event consumption strategy. #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| all | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for all defined events before resuming execution.
*Required if `any` and `one` have not been set.* | -| any | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for any of the defined events before resuming execution.
*Required if `all` and `one` have not been set.* | -| one | [`eventFilter`](#event-filter) | `no` | Configures the workflow to wait for the defined event before resuming execution.
*Required if `all` and `any` have not been set.* | +| Property | Type | Required | Description | +| -------- | :------------------------------: | :------: | -------------------------------------------------------------------------------------------------------------------------------------------- | +| all | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for all defined events before resuming execution.
_Required if `any` and `one` have not been set._ | +| any | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for any of the defined events before resuming execution.
_Required if `all` and `one` have not been set._ | +| one | [`eventFilter`](#event-filter) | `no` | Configures the workflow to wait for the defined event before resuming execution.
_Required if `all` and `any` have not been set._ | ### Event Filter @@ -1292,10 +1293,10 @@ An event filter is a mechanism used to selectively process or handle events base #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| with | `object` | `yes` | A name/value mapping of the attributes filtered events must define. Supports both regular expressions and runtime expressions. | -| correlate | [`map[string, correlation]`](#correlation) | `no` | A name/definition mapping of the correlations to attempt when filtering events. | +| Property | Type | Required | Description | +| --------- | :----------------------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------------ | +| with | `object` | `yes` | A name/value mapping of the attributes filtered events must define. Supports both regular expressions and runtime expressions. | +| correlate | [`map[string, correlation]`](#correlation) | `no` | A name/definition mapping of the correlations to attempt when filtering events. | ### Correlation @@ -1303,10 +1304,10 @@ A correlation is a link between events and data, established by mapping event at #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| from | `string` | `yes` | A runtime expression used to extract the correlation value from the filtered event. | -| expect | `string` | `no` | A constant or a runtime expression, if any, used to determine whether or not the extracted correlation value matches expectations.
If not set, the first extracted value will be used as the correlation's expectation. | +| Property | Type | Required | Description | +| -------- | :------: | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| from | `string` | `yes` | A runtime expression used to extract the correlation value from the filtered event. | +| expect | `string` | `no` | A constant or a runtime expression, if any, used to determine whether or not the extracted correlation value matches expectations.
If not set, the first extracted value will be used as the correlation's expectation. | ### Retry @@ -1314,42 +1315,42 @@ The Retry is a fundamental concept in the Serverless Workflow DSL, used to defin #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| when | `string` | `no` | A a runtime expression used to determine whether or not to retry running the task, in a given context. | -| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to retry running the task, in a given context. | -| limit | [`retry`](#retry-limit) | `no` | The limits, if any, to impose to the retry policy. | -| backoff | [`backoff`](#backoff) | `no` | The backoff strategy to use, if any. | -| jitter | [`jitter`](#jitter) | `no` | The parameters, if any, that control the randomness or variability of the delay between retry attempts. | +| Property | Type | Required | Description | +| ---------- | :---------------------: | :------: | ------------------------------------------------------------------------------------------------------- | +| when | `string` | `no` | A a runtime expression used to determine whether or not to retry running the task, in a given context. | +| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to retry running the task, in a given context. | +| limit | [`retry`](#retry-limit) | `no` | The limits, if any, to impose to the retry policy. | +| backoff | [`backoff`](#backoff) | `no` | The backoff strategy to use, if any. | +| jitter | [`jitter`](#jitter) | `no` | The parameters, if any, that control the randomness or variability of the delay between retry attempts. | #### Retry Limit The definition of a retry policy. -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| attempt.count | `integer` | `no` | The maximum attempts count. | -| attempt.duration | [`duration`](#duration) | `no` | The duration limit, if any, for all retry attempts. | -| duration | [`duration`](#duration) | `no` | The maximum duration, if any, during which to retry a given task. | +| Property | Type | Required | Description | +| ---------------- | :---------------------: | :------: | ----------------------------------------------------------------- | +| attempt.count | `integer` | `no` | The maximum attempts count. | +| attempt.duration | [`duration`](#duration) | `no` | The duration limit, if any, for all retry attempts. | +| duration | [`duration`](#duration) | `no` | The maximum duration, if any, during which to retry a given task. | #### Backoff The definition of a retry backoff strategy. -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| constant | `object` | `no` | The definition of the constant backoff to use, if any.
*Required if `exponential` and `linear` are not set, otherwise ignored.* | -| exponential | `object` | `no` | The definition of the exponential backoff to use, if any.
*Required if `constant` and `linear` are not set, otherwise ignored.* | -| linear | `object` | `no` | The definition of the linear backoff to use, if any.
*Required if `constant` and `exponential` are not set, otherwise ignored.* | +| Property | Type | Required | Description | +| ----------- | :------: | :------: | ---------------------------------------------------------------------------------------------------------------------------------- | +| constant | `object` | `no` | The definition of the constant backoff to use, if any.
_Required if `exponential` and `linear` are not set, otherwise ignored._ | +| exponential | `object` | `no` | The definition of the exponential backoff to use, if any.
_Required if `constant` and `linear` are not set, otherwise ignored._ | +| linear | `object` | `no` | The definition of the linear backoff to use, if any.
_Required if `constant` and `exponential` are not set, otherwise ignored._ | #### Jitter Represents the definition of the parameters that control the randomness or variability of a delay, typically between retry attempts -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| from | [`duration`](#duration) | `yes` | The minimum duration of the jitter range. | -| to | [`duration`](#duration) | `yes` | The maximum duration of the jitter range. | +| Property | Type | Required | Description | +| -------- | :---------------------: | :------: | ----------------------------------------- | +| from | [`duration`](#duration) | `yes` | The minimum duration of the jitter range. | +| to | [`duration`](#duration) | `yes` | The maximum duration of the jitter range. | #### Examples @@ -1367,10 +1368,10 @@ When set, runtimes must validate input data against the defined schema, unless d #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate input data.
*Even though the schema is not required, it is strongly encouraged to document it, whenever feasible.* | -| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task input. | +| Property | Type | Required | Description | +| -------- | :------------------: | :------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate input data.
_Even though the schema is not required, it is strongly encouraged to document it, whenever feasible._ | +| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task input. | #### Examples @@ -1382,7 +1383,7 @@ schema: properties: petId: type: string - required: [ petId ] + required: [petId] from: .order.pet ``` @@ -1396,11 +1397,11 @@ When set, runtimes must validate output data against the defined schema, unless #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate output data.
*Even though the schema is not required, it is strongly encouraged to document it, whenever feasible.* | -| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task output. | -| to | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to update the context, using both output and context data. | +| Property | Type | Required | Description | +| -------- | :------------------: | :------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate output data.
_Even though the schema is not required, it is strongly encouraged to document it, whenever feasible._ | +| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task output. | +| to | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to update the context, using both output and context data. | #### Examples @@ -1412,10 +1413,10 @@ schema: properties: petId: type: string - required: [ petId ] + required: [petId] from: - petId: '${ .pet.id }' -to: '.petList += [ . ]' + petId: "${ .pet.id }" +to: ".petList += [ . ]" ``` ### Schema @@ -1424,15 +1425,16 @@ Describes a data schema. #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| format | `string` | `yes` | The schema format.
*Supported values are:*
*- `json`, which indicates the [JsonSchema](https://json-schema.org/) format.* | -| document | `object` | `no` | The inline schema document.
*Required if `resource` has not been set, otherwise ignored.* | -| resource | [`externalResource`](#external-resource) | `no` | The schema external resource.
*Required if `document` has not been set, otherwise ignored.* | +| Property | Type | Required | Description | +| -------- | :--------------------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------------- | +| format | `string` | `yes` | The schema format.
_Supported values are:_
_- `json`, which indicates the [JsonSchema](https://json-schema.org/) format._ | +| document | `object` | `no` | The inline schema document.
_Required if `resource` has not been set, otherwise ignored._ | +| resource | [`externalResource`](#external-resource) | `no` | The schema external resource.
_Required if `document` has not been set, otherwise ignored._ | #### Examples -*Example of an inline JsonSchema:* +_Example of an inline JsonSchema:_ + ```yaml format: json document: @@ -1444,10 +1446,11 @@ document: type: string lastName: type: string - required: [ id, firstName, lastName ] + required: [id, firstName, lastName] ``` -*Example of a JsonSchema based on an external resource:* +_Example of a JsonSchema based on an external resource:_ + ```yaml format: json resource: @@ -1460,18 +1463,18 @@ Defines a workflow or task timeout. #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| after | [`duration`](#duration) | `yes` | The duration after which the workflow or task times out. | +| Property | Type | Required | Description | +| -------- | :---------------------: | :------: | -------------------------------------------------------- | +| after | [`duration`](#duration) | `yes` | The duration after which the workflow or task times out. | #### Examples ```yaml document: - dsl: '1.0.0-alpha1' + dsl: "1.0.0-alpha1" namespace: default name: sample - version: '0.1.0' + version: "0.1.0" do: wait: seconds: 60 @@ -1486,17 +1489,18 @@ Defines a duration. #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| Days | `integer` | `no` | Number of days, if any. | -| Hours | `integer` | `no` | Number of hours, if any. | -| Minutes | `integer` | `no`| Number of minutes, if any. | -| Seconds | `integer` | `no`| Number of seconds, if any. | -| Milliseconds | `integer` | `no`| Number of milliseconds, if any. | +| Property | Type | Required | Description | +| ------------ | :-------: | :------: | ------------------------------- | +| Days | `integer` | `no` | Number of days, if any. | +| Hours | `integer` | `no` | Number of hours, if any. | +| Minutes | `integer` | `no` | Number of minutes, if any. | +| Seconds | `integer` | `no` | Number of seconds, if any. | +| Milliseconds | `integer` | `no` | Number of milliseconds, if any. | #### Examples -*Example of a duration of 2 hours, 15 minutes and 30 seconds:* +_Example of a duration of 2 hours, 15 minutes and 30 seconds:_ + ```yaml hours: 2 minutes: 15 @@ -1509,12 +1513,12 @@ Describes an HTTP response. #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| request | [`request`](#http-request) | `yes` | The HTTP request associated with the HTTP response. | -| statusCode | `integer` | `yes` | The HTTP response status code. | -| headers | `map[string, string]` | `no` | The HTTP response headers, if any. | -| content | `any` | `no` | The HTTP response content, if any.
*If the request's content type is one of the following, should contain the deserialized response content. Otherwise, should contain the base-64 encoded response content, if any.*| +| Property | Type | Required | Description | +| ---------- | :------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| request | [`request`](#http-request) | `yes` | The HTTP request associated with the HTTP response. | +| statusCode | `integer` | `yes` | The HTTP response status code. | +| headers | `map[string, string]` | `no` | The HTTP response headers, if any. | +| content | `any` | `no` | The HTTP response content, if any.
_If the request's content type is one of the following, should contain the deserialized response content. Otherwise, should contain the base-64 encoded response content, if any._ | #### Examples @@ -1539,11 +1543,11 @@ Describes an HTTP request. #### Properties -| Property | Type | Required | Description | -|----------|:----:|:--------:|-------------| -| method | `string` | `yes` | The request's method. | -| uri | `uri` | `yes` | The request's URI. | -| headers | `map[string, string]` | `no` | The HTTP request headers, if any. | +| Property | Type | Required | Description | +| -------- | :-------------------: | :------: | --------------------------------- | +| method | `string` | `yes` | The request's method. | +| uri | `uri` | `yes` | The request's URI. | +| headers | `map[string, string]` | `no` | The HTTP request headers, if any. | #### Examples @@ -1552,4 +1556,4 @@ method: get uri: https://petstore.swagger.io/v2/pet/1 headers: Content-Type: application/json -``` \ No newline at end of file +``` From e8500899c27d473b2497089da399b829187aecfa Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 17:08:30 +0000 Subject: [PATCH 49/51] fix: move then to right level Signed-off-by: Matthias Pichler --- dsl-reference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 26a41cec..2ebd0610 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -860,14 +860,14 @@ do: sequentially: - validatePayment: {} - fulfillOrder: {} - then: exit + then: exit - processPhysicalOrder: execute: sequentially: - checkInventory: {} - packItems: {} - scheduleShipping: {} - then: exit + then: exit - handleUnknownOrderType: execute: sequentially: From 639f936ba238834f9249513dbc5d49cb77ba74af Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 17:09:34 +0000 Subject: [PATCH 50/51] Revert "fix: rename name from task" This reverts commit 0533865449f5d0b5286ceda1a0deddb81841b934. Signed-off-by: Matthias Pichler --- dsl-reference.md | 816 +++++++++++++++++++++++------------------------ 1 file changed, 406 insertions(+), 410 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 2ebd0610..805f26dc 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -4,50 +4,50 @@ - [Abstract](#abstract) - [Definitions](#definitions) - - [Workflow](#workflow) + + [Workflow](#workflow) - [Document](#document) - [Use](#use) - [Schedule](#schedule) - - [Task](#task) + + [Task](#task) - [Call](#call) - - [AsyncAPI](#asyncapi-call) - - [gRPC](#grpc-call) - - [HTTP](#http-call) - - [OpenAPI](#openapi-call) + + [AsyncAPI](#asyncapi-call) + + [gRPC](#grpc-call) + + [HTTP](#http-call) + + [OpenAPI](#openapi-call) - [Composite](#composite) - [Emit](#emit) - [For](#for) - [Listen](#listen) - [Raise](#raise) - [Run](#run) - - [Container](#container-process) - - [Shell](#shell-process) - - [Script](#script-process) - - [Workflow](#workflow-process) + + [Container](#container-process) + + [Shell](#shell-process) + + [Script](#script-process) + + [Workflow](#workflow-process) - [Switch](#switch) - [Set](#set) - [Try](#try) - [Wait](#wait) - - [Flow Directive](#flow-directive) - - [External Resource](#external-resource) - - [Authentication](#authentication) + + [Flow Directive](#flow-directive) + + [External Resource](#external-resource) + + [Authentication](#authentication) - [Basic](#basic-authentication) - [Bearer](#bearer-authentication) - [Certificate](#certificate-authentication) - [Digest](#digest-authentication) - [OAUTH2](#oauth2-authentication) - - [Extension](#extension) - - [Error](#error) + + [Extension](#extension) + + [Error](#error) - [Standard Error Types](#standard-error-types) - - [Event Consumption Strategy](#event-consumption-strategy) - - [Event Filter](#event-filter) - - [Retry](#retry) - - [Input](#input) - - [Output](#output) - - [Timeout](#timeout) - - [Duration](#duration) - - [HTTP Response](#http-response) - - [HTTP Request](#http-request) + + [Event Consumption Strategy](#event-consumption-strategy) + + [Event Filter](#event-filter) + + [Retry](#retry) + + [Input](#input) + + [Output](#output) + + [Timeout](#timeout) + + [Duration](#duration) + + [HTTP Response](#http-response) + + [HTTP Request](#http-request) ## Abstract @@ -61,63 +61,63 @@ A [workflow](#workflow) serves as a blueprint outlining the series of [tasks](#t #### Properties -| Name | Type | Required | Description | -| :------- | :---------------------: | :------: | :--------------------------------------------------------------------- | -| document | [`document`](#document) | `yes` | Documents the defined workflow. | -| input | [`input`](#input) | `no` | Configures the workflow's input. | -| use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. | -| do | [`task`](#task) | `yes` | The [task](#task) that must be performed by the [workflow](#workflow). | -| timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. | -| output | [`output`](#output) | `no` | Configures the workflow's output. | -| schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. | -| evaluate | [`evaluate`](#evaluate) | `no` | Configures runtime expression evaluation. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| document | [`document`](#document) | `yes` | Documents the defined workflow. | +| input | [`input`](#input) | `no` | Configures the workflow's input. | +| use | [`use`](#use) | `no` | Defines the workflow's reusable components, if any. | +| do | [`task`](#task) | `yes` | The [task](#task) that must be performed by the [workflow](#workflow). | +| timeout | [`timeout`](#timeout) | `no` | The configuration, if any, of the workflow's timeout. | +| output | [`output`](#output) | `no` | Configures the workflow's output. | +| schedule | [`schedule`](#schedule) | `no` | Configures the workflow's schedule, if any. | +| evaluate | [`evaluate`](#evaluate) | `no` | Configures runtime expression evaluation. | #### Document Documents the workflow definition. -| Name | Type | Required | Description | -| :-------- | :-------------------: | :------: | :-------------------------------------------------- | -| dsl | `string` | `yes` | The version of the DSL used to define the workflow. | -| namespace | `string` | `yes` | The workflow's namespace.
| -| name | `string` | `yes` | The workflow's name.
| -| version | `string` | `yes` | The workflow's [semantic version] | -| title | `string` | `no` | The workflow's title. | -| summary | `string` | `no` | The workflow's Markdown summary. | -| tags | `map[string, string]` | `no` | A key/value mapping of the workflow's tags, if any. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| dsl | `string` | `yes` | The version of the DSL used to define the workflow. | +| namespace | `string` | `yes` | The workflow's namespace.
| +| name | `string` | `yes` | The workflow's name.
| +| version | `string` | `yes` | The workflow's [semantic version] +| title | `string` | `no` | The workflow's title. | +| summary | `string` | `no` | The workflow's Markdown summary. | +| tags | `map[string, string]` | `no` | A key/value mapping of the workflow's tags, if any. | #### Use Defines the workflow's reusable components. -| Name | Type | Required | Description | -| :-------------- | :----------------------------------------------: | :------: | :----------------------------------------------------------------------- | -| authentications | [`map[string, authentication]`](#authentication) | `no` | A name/value mapping of the workflow's reusable authentication policies. | -| errors | [`map[string, error]`](#error) | `no` | A name/value mapping of the workflow's reusable errors. | -| extensions | [`map[string, extension][]`](#extension) | `no` | A list of the workflow's reusable extensions. | -| functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. | -| retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. | -| secrets | `string[]` | `no` | A list containing the workflow's secrets. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| authentications | [`map[string, authentication]`](#authentication) | `no` | A name/value mapping of the workflow's reusable authentication policies. | +| errors | [`map[string, error]`](#error) | `no` | A name/value mapping of the workflow's reusable errors. | +| extensions | [`map[string, extension][]`](#extension) | `no` | A list of the workflow's reusable extensions. | +| functions | [`map[string, task]`](#task) | `no` | A name/value mapping of the workflow's reusable tasks. | +| retries | [`map[string, retryPolicy]`](#retry) | `no` | A name/value mapping of the workflow's reusable retry policies. | +| secrets | `string[]` | `no` | A list containing the workflow's secrets. | #### Schedule Configures the schedule of a workflow. -| Name | Type | Required | Description | -| :---- | :-------------------------------------------------------: | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| every | [`duration`](#duration) | `no` | Specifies the duration of the interval at which the workflow should be executed. Unlike `after`, this option will run the workflow regardless of whether the previous run is still in progress.
_Required when no other property has been set._ | -| cron | `string` | `no` | Specifies the schedule using a CRON expression, e.g., '0 0 \* \* *' for daily at midnight.
*Required when no other property has been set.\* | -| after | [`duration`](#duration) | `no` | Specifies a delay duration that the workflow must wait before starting again after it completes. In other words, when this workflow completes, it should run again after the specified amount of time.
_Required when no other property has been set._ | -| on | [`eventConsumptionStrategy`](#event-consumption-strategy) | `no` | Specifies the events that trigger the workflow execution.
_Required when no other property has been set._ | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| every | [`duration`](#duration) | `no` | Specifies the duration of the interval at which the workflow should be executed. Unlike `after`, this option will run the workflow regardless of whether the previous run is still in progress.
*Required when no other property has been set.* | +| cron | `string` | `no` | Specifies the schedule using a CRON expression, e.g., '0 0 * * *' for daily at midnight.
*Required when no other property has been set.* | +| after | [`duration`](#duration) | `no` | Specifies a delay duration that the workflow must wait before starting again after it completes. In other words, when this workflow completes, it should run again after the specified amount of time.
*Required when no other property has been set.* | +| on | [`eventConsumptionStrategy`](#event-consumption-strategy) | `no` | Specifies the events that trigger the workflow execution.
*Required when no other property has been set.* | #### Evaluate Configures a workflow's runtime expression evaluation. -| Name | Type | Required | Description | -| :------- | :------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| language | `string` | `yes` | The language used for writting runtime expressions.
_Defaults to `jq`._ | -| mode | `string` | `yes` | The runtime expression evaluation mode.
_Supported values are:_
- `strict`: requires all expressions to be enclosed within `${ }` for proper identification and evaluation.
- `loose`: evaluates any value provided. If the evaluation fails, it results in a string with the expression as its content.
_Defaults to `strict`._ | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| language | `string` | `yes` | The language used for writting runtime expressions.
*Defaults to `jq`.* | +| mode | `string` | `yes` | The runtime expression evaluation mode.
*Supported values are:*
- `strict`: requires all expressions to be enclosed within `${ }` for proper identification and evaluation.
- `loose`: evaluates any value provided. If the evaluation fails, it results in a string with the expression as its content.
*Defaults to `strict`.* #### Examples @@ -206,11 +206,11 @@ do: ### Task -A task within a [workflow](#workflow) represents a discrete unit of work that contributes to achieving the overall objectives defined by the [workflow](#workflow). +A task within a [workflow](#workflow) represents a discrete unit of work that contributes to achieving the overall objectives defined by the [workflow](#workflow). -It encapsulates a specific action or set of actions that need to be executed in a predefined order to advance the workflow towards its completion. +It encapsulates a specific action or set of actions that need to be executed in a predefined order to advance the workflow towards its completion. -[Tasks](#task) are designed to be modular and focused, each serving a distinct purpose within the broader context of the [workflow](#workflow). +[Tasks](#task) are designed to be modular and focused, each serving a distinct purpose within the broader context of the [workflow](#workflow). By breaking down the [workflow](#workflow) into manageable [tasks](#task), organizations can effectively coordinate and track progress, enabling efficient collaboration and ensuring that work is completed in a structured and organized manner. @@ -222,20 +222,21 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su - [For](#for), used to iterate over a collection of items, and conditionally perform a task for each of them. - [Listen](#listen), used to listen for an [event](#event) or more. - [Raise](#raise), used to raise an [error](#error) and potentially fault the [workflow](#workflow). -- [Run](#run), used to run a [container](#container), a [script](#script) or event a [shell](#shell) command. +- [Run](#run), used to run a [container](#container), a [script](#script) or event a [shell](#shell) command. - [Switch](#switch), used to dynamically select and execute one of multiple alternative paths based on specified conditions -- [Set](#set), used to dynamically set or update the [workflow](#workflow)'s data during the its execution. +- [Set](#set), used to dynamically set or update the [workflow](#workflow)'s data during the its execution. - [Try](#try), used to attempt executing a specified [task](#task), and to handle any resulting [errors](#error) gracefully, allowing the [workflow](#workflow) to continue without interruption. - [Wait](#wait), used to pause or wait for a specified duration before proceeding to the next task. #### Properties -| Name | Type | Required | Description | -| :------ | :--------------------------------: | :------: | :-------------------------------------------------------------------------------- | -| 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. | -| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. | -| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.
_If not set, defaults to `continue`._ | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| name | `string` | `no` | The name of the task, if any. **SHOULD** be unique within an array. Required if you want to reference the task in [`then`](#flow-directive) | +| 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. | +| timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. | +| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.
*If not set, defaults to `continue`.* | #### Call @@ -243,19 +244,19 @@ Enables the execution of a specified function within a workflow, allowing seamle ##### Properties -| Name | Type | Required | Description | -| :--- | :------: | :------: | :--------------------------------------------------------------- | -| call | `string` | `yes` | The name of the function to call. | -| with | `map` | `no` | A name/value mapping of the parameters to call the function with | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| call | `string` | `yes` | The name of the function to call. | +| with | `map` | `no` | A name/value mapping of the parameters to call the function with | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: call: http with: @@ -276,24 +277,24 @@ The [AsyncAPI Call](#asyncapi-call) enables workflows to interact with external ###### Properties -| Name | Type | Required | Description | -| :------------- | :---------------------------------------------: | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------- | -| document | [`externalResource`](#external-resource) | `yes` | The AsyncAPI document that defines the operation to call. | -| operationRef | `string` | `yes` | A reference to the AsyncAPI operation to call. | -| server | `string` | `no` | A reference to the server to call the specified AsyncAPI operation on.
If not set, default to the first server matching the operation's channel. | -| message | `string` | `no` | The name of the message to use.
If not set, defaults to the first message defined by the operation. | -| binding | `string` | `no` | The name of the binding to use.
If not set, defaults to the first binding defined by the operation | -| payload | `any` | `no` | The operation's payload, as defined by the configured message | -| authentication | `string`
[`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the AsyncAPI operation. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| document | [`externalResource`](#external-resource) | `yes` | The AsyncAPI document that defines the operation to call. | +| operationRef | `string` | `yes` | A reference to the AsyncAPI operation to call. | +| server | `string` | `no` | A reference to the server to call the specified AsyncAPI operation on.
If not set, default to the first server matching the operation's channel. | +| message | `string` | `no` | The name of the message to use.
If not set, defaults to the first message defined by the operation. | +| binding | `string` | `no` | The name of the binding to use.
If not set, defaults to the first binding defined by the operation | +| payload | `any` | `no` | The operation's payload, as defined by the configured message | +| authentication | `string`
[`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the AsyncAPI operation. | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: call: asyncapi with: @@ -312,24 +313,24 @@ The [gRPC Call](#grpc-call) enables communication with external systems via the ###### Properties -| Name | Type | Required | Description | -| :--------------------- | :--------------------------------------: | :------: | :--------------------------------------------------------------------------------------------------------- | -| proto | [`externalResource`](#external-resource) | `yes` | The proto resource that describes the GRPC service to call. | -| service.name | `string` | `yes` | The name of the GRPC service to call. | -| service.host | `string` | `yes` | The hostname of the GRPC service to call. | -| service.port | `integer` | `no` | The port number of the GRPC service to call. | -| service.authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the GRPC service. | -| method | `string` | `yes` | The name of the GRPC service method to call. | -| arguments | `map` | `no` | A name/value mapping of the method call's arguments, if any. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| proto | [`externalResource`](#external-resource) | `yes` | The proto resource that describes the GRPC service to call. | +| service.name | `string` | `yes` | The name of the GRPC service to call. | +| service.host | `string` | `yes` | The hostname of the GRPC service to call. | +| service.port | `integer` | `no` | The port number of the GRPC service to call. | +| service.authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the GRPC service. | +| method | `string` | `yes` | The name of the GRPC service method to call. | +| arguments | `map` | `no` | A name/value mapping of the method call's arguments, if any. | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: call: grpc with: @@ -349,22 +350,22 @@ The [HTTP Call](#http-call) enables workflows to interact with external services ###### Properties -| Name | Type | Required | Description | -| :------- | :---------------------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| method | `string` | `yes` | The HTTP request method. | -| endpoint | [`endpoint`](#endpoint) | `yes` | An URI or an object that describes the HTTP endpoint to call. | -| headers | `map` | `no` | A name/value mapping of the HTTP headers to use, if any. | -| body | `any` | `no` | The HTTP request body, if any. | -| output | `string` | `no` | The http call's output format.
_Supported values are:_
_- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any._
_- `content`, which outputs the content of [http response](#http-response), possibly deserialized._
_- `response`, which outputs the [http response](#http-response)._
_Defaults to `content`._ | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| method | `string` | `yes` | The HTTP request method. | +| endpoint | [`endpoint`](#endpoint) | `yes` | An URI or an object that describes the HTTP endpoint to call. | +| headers | `map` | `no` | A name/value mapping of the HTTP headers to use, if any. | +| body | `any` | `no` | The HTTP request body, if any. | +| output | `string` | `no` | The http call's output format.
*Supported values are:*
*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*
*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*
*- `response`, which outputs the [http response](#http-response).*
*Defaults to `content`.* | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: call: http with: @@ -378,22 +379,22 @@ The [OpenAPI Call](#openapi-call) enables workflows to interact with external se ###### Properties -| Name | Type | Required | Description | -| :------------- | :--------------------------------------: | :------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| document | [`externalResource`](#external-resource) | `yes` | The OpenAPI document that defines the operation to call. | -| operationId | `string` | `yes` | The id of the OpenAPI operation to call. | -| arguments | `map` | `no` | A name/value mapping of the parameters, if any, of the OpenAPI operation to call. | -| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the OpenAPI operation. | -| output | `string` | `no` | The OpenAPI call's output format.
_Supported values are:_
_- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any._
_- `content`, which outputs the content of [http response](#http-response), possibly deserialized._
_- `response`, which outputs the [http response](#http-response)._
_Defaults to `content`._ | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| document | [`externalResource`](#external-resource) | `yes` | The OpenAPI document that defines the operation to call. | +| operationId | `string` | `yes` | The id of the OpenAPI operation to call. | +| arguments | `map` | `no` | A name/value mapping of the parameters, if any, of the OpenAPI operation to call. | +| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the OpenAPI operation. | +| output | `string` | `no` | The OpenAPI call's output format.
*Supported values are:*
*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*
*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*
*- `response`, which outputs the [http response](#http-response).*
*Defaults to `content`.* | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: call: openapi with: @@ -405,26 +406,25 @@ do: #### Composite -Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. + Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations. By encapsulating and coordinating various subtasks, this task type facilitates the efficient execution of intricate workflows. ##### Properties -| Name | Type | Required | Description | -| :------------------- | :----------------------------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| execute.sequentially | [`map[string, task][]`](#task) | `no` | The tasks to perform sequentially.
_Required if `execute.concurrently` has not been set, otherwise ignored._
_If set, must contains **at least** two [`tasks`](#task)._ | -| execute.concurrently | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently.
_Required if `execute.sequentially` has not been set, otherwise ignored._
_If set, must contains **at least** two [`tasks`](#task)._ | -| execute.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.
_Ignored if `execute.sequentially` has been set. Defaults to `false`._
_Must **not** be set if the [`tasks`](#task) are executed sequentially._ | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| execute.sequentially | [`map[string, task][]`](#task) | `no` | The tasks to perform sequentially.
*Required if `execute.concurrently` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | +| execute.concurrently | [`map[string, task][]`](#task) | `no` | The tasks to perform concurrently.
*Required if `execute.sequentially` has not been set, otherwise ignored.*
*If set, must contains **at least** two [`tasks`](#task).* | +| execute.compete | `boolean` | `no` | Indicates whether or not the concurrent [`tasks`](#task) are racing against each other, with a single possible winner, which sets the composite task's output.
*Ignored if `execute.sequentially` has been set. Defaults to `false`.*
*Must **not** be set if the [`tasks`](#task) are executed sequentially.* | ##### Examples -_Executing tasks sequentially:_ - +*Executing tasks sequentially:* ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: execute: sequentially: @@ -432,7 +432,7 @@ do: call: http with: method: post - endpoint: + endpoint: uri: https://fake-booking-agency.com/hotels/book authentication: fake-booking-agency-oauth2 body: @@ -443,34 +443,33 @@ do: call: http with: method: post - endpoint: + endpoint: uri: https://fake-booking-agency.com/flights/book authentication: fake-booking-agency-oauth2 body: departure: - date: "01/01/26" - time: "07:25:00" + date: '01/01/26' + time: '07:25:00' from: airport: BRU city: Zaventem country: Belgium arrival: - date: "01/01/26" - time: "11:12:00" + date: '01/01/26' + time: '11:12:00' to: airport: LIS city: Lisbon country: Portugal ``` -_Executing tasks concurrently:_ - +*Executing tasks concurrently:* ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: execute: concurrently: @@ -498,18 +497,18 @@ Allows workflows to publish events to event brokers or messaging systems, facili ##### Properties -| Name | Type | Required | Description | -| :--------- | :---------------: | :------: | :------------------------- | -| emit.event | [`event`](#event) | `yes` | Defines the event to emit. | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| emit.event | [`event`](#event) | `yes` | Defines the event to emit. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: emit: event: @@ -521,8 +520,8 @@ do: firstName: Cruella lastName: de Vil items: - - breed: dalmatian - quantity: 101 + - breed: dalmatian + quantity: 101 ``` #### For @@ -531,22 +530,22 @@ Allows workflows to iterate over a collection of items, executing a defined set ##### Properties -| Name | Type | Required | Description | -| :------- | :-------------: | :------: | :---------------------------------------------------------------------------------------------------------------------------------- | -| for.each | `string` | `no` | The name of the variable used to store the current item being enumerated.
Defaults to `item`. | -| for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. | -| for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.
Defaults to `index`. | -| while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. | -| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| for.each | `string` | `no` | The name of the variable used to store the current item being enumerated.
Defaults to `item`. | +| for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. | +| for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.
Defaults to `index`. | +| while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. | +| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: for: each: pet @@ -560,39 +559,39 @@ do: with: type: com.fake.petclinic.pets.checkup.completed.v2 output: - to: '.pets + [{ "id": $pet.id }]' + to: '.pets + [{ "id": $pet.id }]' ``` #### Listen -Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems. +Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems. ##### Properties -| Name | Type | Required | Description | -| :-------- | :-------------------------------------------------------: | :------: | :--------------------------------------------------- | -| listen.to | [`eventConsumptionStrategy`](#event-consumption-strategy) | `yes` | Configures the event(s) the workflow must listen to. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| listen.to | [`eventConsumptionStrategy`](#event-consumption-strategy) | `yes` | Configures the event(s) the workflow must listen to. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: listen: to: any: - - with: - type: com.fake-hospital.vitals.measurements.temperature - data: - temperature: ${ .temperature > 38 } - - with: - type: com.fake-hospital.vitals.measurements.bpm - data: - temperature: ${ .bpm < 60 or .bpm > 100 } + - with: + type: com.fake-hospital.vitals.measurements.temperature + data: + temperature: ${ .temperature > 38 } + - with: + type: com.fake-hospital.vitals.measurements.bpm + data: + temperature: ${ .bpm < 60 or .bpm > 100 } ``` #### Raise @@ -601,18 +600,18 @@ Intentionally triggers and propagates errors. By employing the "Raise" task, wor ##### Properties -| Name | Type | Required | Description | -| :---------- | :---------------: | :------: | :-------------------------- | -| raise.error | [`error`](#error) | `yes` | Defines the error to raise. | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| raise.error | [`error`](#error) | `yes` | Defines the error to raise. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: execute: sequentially: @@ -646,21 +645,21 @@ Provides the capability to execute external [containers](#container-process), [s ##### Properties -| Name | Type | Required | Description | -| :------------ | :-------------------------------: | :------: | :------------------------------------------------------------------------------------------------------------------- | -| run.container | [`container`](#container-process) | `no` | The definition of the container to run.
_Required if `script`, `shell` and `workflow` have not been set._ | -| run.script | [`script`](#script-process) | `no` | The definition of the script to run.
_Required if `container`, `shell` and `workflow` have not been set._ | -| run.shell | [`shell`](#shell-process) | `no` | The definition of the shell command to run.
_Required if `container`, `script` and `workflow` have not been set._ | -| run.workflow | [`workflow`](#workflow-process) | `no` | The definition of the workflow to run.
_Required if `container`, `script` and `shell` have not been set._ | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| run.container | [`container`](#container-process) | `no` | The definition of the container to run.
*Required if `script`, `shell` and `workflow` have not been set.* | +| run.script | [`script`](#script-process) | `no` | The definition of the script to run.
*Required if `container`, `shell` and `workflow` have not been set.* | +| run.shell | [`shell`](#shell-process) | `no` | The definition of the shell command to run.
*Required if `container`, `script` and `workflow` have not been set.* | +| run.workflow | [`workflow`](#workflow-process) | `no` | The definition of the workflow to run.
*Required if `container`, `script` and `shell` have not been set.* | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: execute: sequentially: @@ -694,22 +693,22 @@ Enables the execution of external processes encapsulated within a containerized ###### Properties -| Name | Type | Required | Description | -| :---------- | :------: | :------: | :--------------------------------------------------------------------------------------------------- | -| image | `string` | `yes` | The name of the container image to run | -| command | `string` | `no` | The command, if any, to execute on the container | -| ports | `map` | `no` | The container's port mappings, if any | -| volumes | `map` | `no` | The container's volume mappings, if any | -| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| image | `string` | `yes` | The name of the container image to run | +| command | `string` | `no` | The command, if any, to execute on the container | +| ports | `map` | `no` | The container's port mappings, if any | +| volumes | `map` | `no` | The container's volume mappings, if any | +| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: run: container: @@ -722,21 +721,21 @@ Enables the execution of custom scripts or code within a workflow, empowering wo ###### Properties -| Name | Type | Required | Description | -| :---------- | :------------------------------------: | :------: | :--------------------------------------------------------------------------------------------------- | -| language | `string` | `yes` | The language of the script to run | -| code | `string` | `no` | The script's code.
_Required if `source` has not been set._ | -| source | [externalResource](#external-resource) | `no` | The script's resource.
_Required if `code` has not been set._ | -| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| language | `string` | `yes` | The language of the script to run | +| code | `string` | `no` | The script's code.
*Required if `source` has not been set.* | +| source | [externalResource](#external-resource) | `no` | The script's resource.
*Required if `code` has not been set.* | +| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: run: script: @@ -751,20 +750,20 @@ Enables the execution of shell commands within a workflow, enabling workflows to ###### Properties -| Name | Type | Required | Description | -| :---------- | :------: | :------: | :--------------------------------------------------------------------------------------------------- | -| command | `string` | `yes` | The shell command to run | -| arguments | `map` | `no` | A list of the arguments of the shell command to run | -| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| command | `string` | `yes` | The shell command to run | +| arguments | `map` | `no` | A list of the arguments of the shell command to run | +| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: run: shell: @@ -777,20 +776,20 @@ Enables the invocation and execution of nested workflows within a parent workflo ###### Properties -| Name | Type | Required | Description | -| :------ | :------: | :------: | :---------------------------------------------------------------------------------------------------------------------------------------------------- | -| name | `string` | `yes` | The name of the workflow to run | -| version | `string` | `yes` | The version of the workflow to run. Defaults to `latest` | -| input | `any` | `no` | The data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| name | `string` | `yes` | The name of the workflow to run | +| version | `string` | `yes` | The version of the workflow to run. Defaults to `latest` | +| input | `any` | `no` | The data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified | ###### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: run: workflow: @@ -805,9 +804,9 @@ A task used to set data. ##### Properties -| Name | Type | Required | Description | -| :--- | :------: | :------: | :--------------------------------------- | -| set | `object` | `yes` | A name/value mapping of the data to set. | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| set | `object` | `yes` | A name/value mapping of the data to set. | ##### Examples @@ -816,7 +815,7 @@ document: dsl: 1.0.0-alpha1 namespace: default name: set - version: "0.1.0" + version: '0.1.0' do: set: shape: circle @@ -830,18 +829,18 @@ Enables conditional branching within workflows, allowing them to dynamically sel ##### Properties -| Name | Type | Required | Description | -| :----- | :----------------------: | :------: | :----------------------------------------- | -| switch | [`case[]`](#switch-case) | `yes` | A name/value map of the cases to switch on | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| switch | [`case[]`](#switch-case) | `yes` | A name/value map of the cases to switch on | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: execute: sequentially: @@ -879,11 +878,11 @@ do: Defines a switch case, encompassing of a condition for matching and an associated action to execute upon a match. -| Name | Type | Required | Description | -| :--- | :--------------------------------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| name | `string` | `no` | The name of the case, if any. | -| when | `string` | `no` | A runtime expression used to determine whether or not the case matches.
_If not set, the case will be matched by default if no other case match._
_Note that there can be only one default case, all others **MUST** set a condition._ | -| then | [`flowDirective`](#flow-directive) | `yes` | The flow directive to execute when the case matches. | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| name | `string` | `no` | The name of the case, if any. | +| when | `string` | `no` | A runtime expression used to determine whether or not the case matches.
*If not set, the case will be matched by default if no other case match.*
*Note that there can be only one default case, all others **MUST** set a condition.* +| then | [`flowDirective`](#flow-directive) | `yes` | The flow directive to execute when the case matches. | #### Try @@ -891,19 +890,19 @@ Serves as a mechanism within workflows to handle errors gracefully, potentially ##### Properties -| Name | Type | Required | Description | -| :---- | :---------------: | :------: | :----------------------------------------------------- | -| try | [`task`](#task) | `yes` | The task(s) to perform. | -| catch | [`catch`](#catch) | `yes` | Configures the errors to catch and how to handle them. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| try | [`task`](#task) | `yes` | The task(s) to perform. | +| catch | [`catch`](#catch) | `yes` | Configures the errors to catch and how to handle them. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: try: call: http @@ -932,14 +931,14 @@ Defines the configuration of a catch clause, which a concept used to catch error ###### Properties -| Name | Type | Required | Description | -| :--------- | :---------------------: | :------: | :------------------------------------------------------------------------------------- | -| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch | -| as | `string` | `no` | The name of the runtime expression variable to save the error as. Defaults to 'error'. | -| when | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | -| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | -| retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors | -| do | [`task`](#task) | `no` | The definition of the task to run when catching an error | +| Name | Type | Required | Description | +|:--|:---:|:---:|:---| +| errors | [`errorFilter`](#retry) | `no` | The definition of the errors to catch | +| as | `string` | `no` | The name of the runtime expression variable to save the error as. Defaults to 'error'. | +| when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error | +| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error | +| retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors | +| do | [`task`](#task) | `no` | The definition of the task to run when catching an error | #### Wait @@ -947,18 +946,18 @@ Allows workflows to pause or delay their execution for a specified period of tim ##### Properties -| Name | Type | Required | Description | -| :--- | :---------------------------------: | :------: | :----------------------------------------------------------------------------------------------- | -| wait | `string`
[`duration`](#duration) | `yes` | The amount of time to wait.
If a `string`, must be a valid [ISO 8601](#) duration expression. | +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| wait | `string`
[`duration`](#duration) | `yes` | The amount of time to wait.
If a `string`, must be a valid [ISO 8601](#) duration expression. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: wait: seconds: 10 @@ -968,12 +967,12 @@ do: Flow Directives are commands within a workflow that dictate its progression. -| Directive | Description | -| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Directive | Description | +| --------- | ----------- | | `"continue"` | Instructs the workflow to proceed with the next task in line. This action may conclude the execution of a particular workflow or branch if there are not task defined after the continue one. | -| `"exit"` | Halts the current branch's execution, potentially terminating the entire workflow if the current task resides within the main branch. | -| `"end"` | Provides a graceful conclusion to the workflow execution, signaling its completion explicitly. | -| `string` | Continues the workflow at the task with the specified name | +| `"exit"` | Halts the current branch's execution, potentially terminating the entire workflow if the current task resides within the main branch. | +| `"end"` | Provides a graceful conclusion to the workflow execution, signaling its completion explicitly. | +| `string` | Continues the workflow at the task with the specified name | ### External Resource @@ -981,11 +980,11 @@ Defines an external resource. #### Properties -| Property | Type | Required | Description | -| -------------- | :---------------------------------: | :------: | ------------------------------------------------------------------------------------------------------- | -| name | `string` | `no` | The name, if any, of the defined resource. | -| uri | `string` | `yes` | The URI at which to get the defined resource. | -| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when fecthing the resource. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| name | `string` | `no` | The name, if any, of the defined resource. | +| uri | `string` | `yes` | The URI at which to get the defined resource. | +| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when fecthing the resource. | ##### Examples @@ -1004,22 +1003,22 @@ Defines the mechanism used to authenticate users and workflows attempting to acc #### Properties -| Property | Type | Required | Description | -| ----------- | :--------------------------------------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------- | -| basic | [`basicAuthentication`](#basic-authentication) | `no` | The `basic` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| bearer | [`bearerAuthentication`](#bearer-authentication) | `no` | The `bearer` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| certificate | [`certificateAuthentication`](#certificate-authentication) | `no` | The `certificate` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| digest | [`digestAuthentication`](#digest-authentication) | `no` | The `digest` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | -| oauth2 | [`oauth2`](#oauth2-authentication) | `no` | The `oauth2` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| basic | [`basicAuthentication`](#basic-authentication) | `no` | The `basic` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| bearer | [`bearerAuthentication`](#bearer-authentication) | `no` | The `bearer` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| certificate | [`certificateAuthentication`](#certificate-authentication) | `no` | The `certificate` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| digest | [`digestAuthentication`](#digest-authentication) | `no` | The `digest` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | +| oauth2 | [`oauth2`](#oauth2-authentication) | `no` | The `oauth2` authentication scheme to use, if any.
Required if no other property has been set, otherwise ignored. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' use: secrets: usernamePasswordSecret: {} @@ -1030,7 +1029,7 @@ do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: sampleBasicFromSecret ``` @@ -1041,19 +1040,19 @@ Defines the fundamentals of a 'basic' authentication. ##### Properties -| Property | Type | Required | Description | -| -------- | :------: | :------: | -------------------- | -| username | `string` | `yes` | The username to use. | -| password | `string` | `yes` | The password to use. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| username | `string` | `yes` | The username to use. | +| password | `string` | `yes` | The password to use. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' use: authentication: sampleBasic: @@ -1064,7 +1063,7 @@ do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: sampleBasic ``` @@ -1075,23 +1074,23 @@ Defines the fundamentals of a 'bearer' authentication ##### Properties -| Property | Type | Required | Description | -| -------- | :------: | :------: | ------------------------ | -| token | `string` | `yes` | The bearer token to use. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| token | `string` | `yes` | The bearer token to use. | ##### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: bearer: @@ -1100,26 +1099,28 @@ do: #### Certificate Authentication + #### Digest Authentication + #### OAUTH2 Authentication Defines the fundamentals of an 'oauth2' authentication ##### Properties -| Property | Type | Required | Description | -| ------------- | :----------------------------: | :------: | --------------------------------------------------------------------------------------------------------- | -| authority | `string` | `yes` | The URI that references the OAuth2 authority to use. | -| grant | `string` | `yes` | The grant type to use. | -| client.id | `string` | `yes` | The client id to use. | -| client.secret | `string` | `no` | The client secret to use, if any. | -| scopes | `string[]` | `no` | The scopes, if any, to request the token for. | -| audiences | `string[]` | `no` | The audiences, if any, to request the token for. | -| username | `string` | `no` | The username to use. Used only if the grant type is `Password`. | -| password | `string` | `no` | The password to use. Used only if the grant type is `Password`. | -| subject | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the party on behalf of whom the request is being made. | -| actor | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the acting party. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| authority | `string` | `yes` | The URI that references the OAuth2 authority to use. | +| grant | `string` | `yes` | The grant type to use. +| client.id | `string` | `yes` | The client id to use. | +| client.secret | `string` | `no` | The client secret to use, if any. | +| scopes | `string[]` | `no` | The scopes, if any, to request the token for. | +| audiences | `string[]` | `no` | The audiences, if any, to request the token for. | +| username | `string` | `no` | The username to use. Used only if the grant type is `Password`. | +| password | `string` | `no` | The password to use. Used only if the grant type is `Password`. | +| subject | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the party on behalf of whom the request is being made. | +| actor | [`oauth2Token`](#oauth2-token) | `no` | The security token that represents the identity of the acting party. | ##### Examples @@ -1133,7 +1134,7 @@ do: call: http with: method: get - endpoint: + endpoint: uri: https://secured.fake.com/sample authentication: oauth2: @@ -1152,10 +1153,10 @@ Represents the definition of an OAUTH2 token ###### Properties -| Property | Type | Required | Description | -| -------- | :------: | :------: | ---------------------------------- | -| token | `string` | `yes` | The security token to use to use. | -| type | `string` | `yes` | The type of security token to use. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| token | `string` | `yes` | The security token to use to use. | +| type | `string` | `yes` | The type of security token to use. | ### Extension @@ -1165,17 +1166,16 @@ Extensions enable the execution of tasks prior to those they extend, offering th #### Properties -| Property | Type | Required | Description | -| -------- | :-------------: | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | -| when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | -| before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | -| after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| extend | `string` | `yes` | The type of task to extend
Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` | +| when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context | +| before | [`task`](#task) | `no` | The task to execute, if any, before the extended task | +| after | [`task`](#task) | `no` | The task to execute, if any, after the extended task | #### Examples -_Perform logging before and after any non-extension task is run:_ - +*Perform logging before and after any non-extension task is run:* ```yaml document: dsl: '1.0.0-alpha1' @@ -1207,14 +1207,13 @@ do: endpoint: https://fake.com/sample ``` -_Intercept HTTP calls to 'https://mocked.service.com' and mock its response:_ - +*Intercept HTTP calls to 'https://mocked.service.com' and mock its response:* ```yaml -document: - dsl: "1.0.0-alpha1" +document: + dsl: '1.0.0-alpha1' namespace: test name: sample-workflow - version: "0.1.0" + version: '0.1.0' use: extensions: - mockService: @@ -1242,13 +1241,13 @@ Defines the [Problem Details RFC](https://datatracker.ietf.org/doc/html/rfc7807) #### Properties -| Property | Type | Required | Description | -| -------- | :-------: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| type | `string` | `yes` | A URI reference that identifies the [`error`](#error) type.
For cross-compatibility concerns, it is strongly recommended to use [Standard Error Types](#standard-error-types) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | -| status | `integer` | `yes` | The status code generated by the origin for this occurrence of the [`error`](#error).
For cross-compatibility concerns, it is strongly recommended to use [HTTP Status Codes](https://datatracker.ietf.org/doc/html/rfc7231#section-6) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | -| instance | `string` | `yes` | A [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) used to reference the component the [`error`](#error) originates from.
Runtimes **MUST** set the property when raising or escalating the [`error`](#error). Otherwise ignore. | -| title | `string` | `no` | A short, human-readable summary of the [`error`](#error). | -| detail | `string` | `no` | A human-readable explanation specific to this occurrence of the [`error`](#error). | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| type | `string` | `yes` | A URI reference that identifies the [`error`](#error) type.
For cross-compatibility concerns, it is strongly recommended to use [Standard Error Types](#standard-error-types) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | +| status | `integer` | `yes` | The status code generated by the origin for this occurrence of the [`error`](#error).
For cross-compatibility concerns, it is strongly recommended to use [HTTP Status Codes](https://datatracker.ietf.org/doc/html/rfc7231#section-6) whenever possible.
Runtimes **MUST** ensure that the property has been set when raising or escalating the [`error`](#error). | +| instance | `string` | `yes` | A [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) used to reference the component the [`error`](#error) originates from.
Runtimes **MUST** set the property when raising or escalating the [`error`](#error). Otherwise ignore. | +| title | `string` | `no` | A short, human-readable summary of the [`error`](#error). | +| detail | `string` | `no` | A human-readable explanation specific to this occurrence of the [`error`](#error). | #### Examples @@ -1262,18 +1261,18 @@ status: 503 Standard error types serve the purpose of categorizing errors consistently across different runtimes, facilitating seamless migration from one runtime environment to another. -| Type | Status¹ | Description | -| --------------------------------------------------------------------------- | :-----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [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. | -| [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. | -| [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. | -| [https://https://serverlessworkflow.io/spec/1.0.0/errors/authentication](#) | `401` | Errors related to authentication failures. | -| [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. | -| [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. | -| [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. | -| [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. | +| Type | Status¹ | Description | +|------|:-------:|-------------| +| [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. | +| [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. | +| [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. | +| [https://https://serverlessworkflow.io/spec/1.0.0/errors/authentication](#) | `401` | Errors related to authentication failures. | +| [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. | +| [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. | +| [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. | +| [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. | -¹ _Default value. The `status code` that best describe the error should always be used._ +¹ *Default value. The `status code` that best describe the error should always be used.* ### Event Consumption Strategy @@ -1281,11 +1280,11 @@ Represents the configuration of an event consumption strategy. #### Properties -| Property | Type | Required | Description | -| -------- | :------------------------------: | :------: | -------------------------------------------------------------------------------------------------------------------------------------------- | -| all | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for all defined events before resuming execution.
_Required if `any` and `one` have not been set._ | -| any | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for any of the defined events before resuming execution.
_Required if `all` and `one` have not been set._ | -| one | [`eventFilter`](#event-filter) | `no` | Configures the workflow to wait for the defined event before resuming execution.
_Required if `all` and `any` have not been set._ | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| all | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for all defined events before resuming execution.
*Required if `any` and `one` have not been set.* | +| any | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for any of the defined events before resuming execution.
*Required if `all` and `one` have not been set.* | +| one | [`eventFilter`](#event-filter) | `no` | Configures the workflow to wait for the defined event before resuming execution.
*Required if `all` and `any` have not been set.* | ### Event Filter @@ -1293,10 +1292,10 @@ An event filter is a mechanism used to selectively process or handle events base #### Properties -| Property | Type | Required | Description | -| --------- | :----------------------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------------ | -| with | `object` | `yes` | A name/value mapping of the attributes filtered events must define. Supports both regular expressions and runtime expressions. | -| correlate | [`map[string, correlation]`](#correlation) | `no` | A name/definition mapping of the correlations to attempt when filtering events. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| with | `object` | `yes` | A name/value mapping of the attributes filtered events must define. Supports both regular expressions and runtime expressions. | +| correlate | [`map[string, correlation]`](#correlation) | `no` | A name/definition mapping of the correlations to attempt when filtering events. | ### Correlation @@ -1304,10 +1303,10 @@ A correlation is a link between events and data, established by mapping event at #### Properties -| Property | Type | Required | Description | -| -------- | :------: | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| from | `string` | `yes` | A runtime expression used to extract the correlation value from the filtered event. | -| expect | `string` | `no` | A constant or a runtime expression, if any, used to determine whether or not the extracted correlation value matches expectations.
If not set, the first extracted value will be used as the correlation's expectation. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| from | `string` | `yes` | A runtime expression used to extract the correlation value from the filtered event. | +| expect | `string` | `no` | A constant or a runtime expression, if any, used to determine whether or not the extracted correlation value matches expectations.
If not set, the first extracted value will be used as the correlation's expectation. | ### Retry @@ -1315,42 +1314,42 @@ The Retry is a fundamental concept in the Serverless Workflow DSL, used to defin #### Properties -| Property | Type | Required | Description | -| ---------- | :---------------------: | :------: | ------------------------------------------------------------------------------------------------------- | -| when | `string` | `no` | A a runtime expression used to determine whether or not to retry running the task, in a given context. | -| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to retry running the task, in a given context. | -| limit | [`retry`](#retry-limit) | `no` | The limits, if any, to impose to the retry policy. | -| backoff | [`backoff`](#backoff) | `no` | The backoff strategy to use, if any. | -| jitter | [`jitter`](#jitter) | `no` | The parameters, if any, that control the randomness or variability of the delay between retry attempts. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| when | `string` | `no` | A a runtime expression used to determine whether or not to retry running the task, in a given context. | +| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to retry running the task, in a given context. | +| limit | [`retry`](#retry-limit) | `no` | The limits, if any, to impose to the retry policy. | +| backoff | [`backoff`](#backoff) | `no` | The backoff strategy to use, if any. | +| jitter | [`jitter`](#jitter) | `no` | The parameters, if any, that control the randomness or variability of the delay between retry attempts. | #### Retry Limit The definition of a retry policy. -| Property | Type | Required | Description | -| ---------------- | :---------------------: | :------: | ----------------------------------------------------------------- | -| attempt.count | `integer` | `no` | The maximum attempts count. | -| attempt.duration | [`duration`](#duration) | `no` | The duration limit, if any, for all retry attempts. | -| duration | [`duration`](#duration) | `no` | The maximum duration, if any, during which to retry a given task. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| attempt.count | `integer` | `no` | The maximum attempts count. | +| attempt.duration | [`duration`](#duration) | `no` | The duration limit, if any, for all retry attempts. | +| duration | [`duration`](#duration) | `no` | The maximum duration, if any, during which to retry a given task. | #### Backoff The definition of a retry backoff strategy. -| Property | Type | Required | Description | -| ----------- | :------: | :------: | ---------------------------------------------------------------------------------------------------------------------------------- | -| constant | `object` | `no` | The definition of the constant backoff to use, if any.
_Required if `exponential` and `linear` are not set, otherwise ignored._ | -| exponential | `object` | `no` | The definition of the exponential backoff to use, if any.
_Required if `constant` and `linear` are not set, otherwise ignored._ | -| linear | `object` | `no` | The definition of the linear backoff to use, if any.
_Required if `constant` and `exponential` are not set, otherwise ignored._ | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| constant | `object` | `no` | The definition of the constant backoff to use, if any.
*Required if `exponential` and `linear` are not set, otherwise ignored.* | +| exponential | `object` | `no` | The definition of the exponential backoff to use, if any.
*Required if `constant` and `linear` are not set, otherwise ignored.* | +| linear | `object` | `no` | The definition of the linear backoff to use, if any.
*Required if `constant` and `exponential` are not set, otherwise ignored.* | #### Jitter Represents the definition of the parameters that control the randomness or variability of a delay, typically between retry attempts -| Property | Type | Required | Description | -| -------- | :---------------------: | :------: | ----------------------------------------- | -| from | [`duration`](#duration) | `yes` | The minimum duration of the jitter range. | -| to | [`duration`](#duration) | `yes` | The maximum duration of the jitter range. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| from | [`duration`](#duration) | `yes` | The minimum duration of the jitter range. | +| to | [`duration`](#duration) | `yes` | The maximum duration of the jitter range. | #### Examples @@ -1368,10 +1367,10 @@ When set, runtimes must validate input data against the defined schema, unless d #### Properties -| Property | Type | Required | Description | -| -------- | :------------------: | :------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate input data.
_Even though the schema is not required, it is strongly encouraged to document it, whenever feasible._ | -| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task input. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate input data.
*Even though the schema is not required, it is strongly encouraged to document it, whenever feasible.* | +| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task input. | #### Examples @@ -1383,7 +1382,7 @@ schema: properties: petId: type: string - required: [petId] + required: [ petId ] from: .order.pet ``` @@ -1397,11 +1396,11 @@ When set, runtimes must validate output data against the defined schema, unless #### Properties -| Property | Type | Required | Description | -| -------- | :------------------: | :------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate output data.
_Even though the schema is not required, it is strongly encouraged to document it, whenever feasible._ | -| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task output. | -| to | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to update the context, using both output and context data. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| schema | [`schema`](#schema) | `no` | The [`schema`](#schema) used to describe and validate output data.
*Even though the schema is not required, it is strongly encouraged to document it, whenever feasible.* | +| from | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to filter and/or mutate the workflow/task output. | +| to | `string`
`object` | `no` | A [runtime expression](#runtime-expressions), if any, used to update the context, using both output and context data. | #### Examples @@ -1413,10 +1412,10 @@ schema: properties: petId: type: string - required: [petId] + required: [ petId ] from: - petId: "${ .pet.id }" -to: ".petList += [ . ]" + petId: '${ .pet.id }' +to: '.petList += [ . ]' ``` ### Schema @@ -1425,16 +1424,15 @@ Describes a data schema. #### Properties -| Property | Type | Required | Description | -| -------- | :--------------------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------------- | -| format | `string` | `yes` | The schema format.
_Supported values are:_
_- `json`, which indicates the [JsonSchema](https://json-schema.org/) format._ | -| document | `object` | `no` | The inline schema document.
_Required if `resource` has not been set, otherwise ignored._ | -| resource | [`externalResource`](#external-resource) | `no` | The schema external resource.
_Required if `document` has not been set, otherwise ignored._ | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| format | `string` | `yes` | The schema format.
*Supported values are:*
*- `json`, which indicates the [JsonSchema](https://json-schema.org/) format.* | +| document | `object` | `no` | The inline schema document.
*Required if `resource` has not been set, otherwise ignored.* | +| resource | [`externalResource`](#external-resource) | `no` | The schema external resource.
*Required if `document` has not been set, otherwise ignored.* | #### Examples -_Example of an inline JsonSchema:_ - +*Example of an inline JsonSchema:* ```yaml format: json document: @@ -1446,11 +1444,10 @@ document: type: string lastName: type: string - required: [id, firstName, lastName] + required: [ id, firstName, lastName ] ``` -_Example of a JsonSchema based on an external resource:_ - +*Example of a JsonSchema based on an external resource:* ```yaml format: json resource: @@ -1463,18 +1460,18 @@ Defines a workflow or task timeout. #### Properties -| Property | Type | Required | Description | -| -------- | :---------------------: | :------: | -------------------------------------------------------- | -| after | [`duration`](#duration) | `yes` | The duration after which the workflow or task times out. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| after | [`duration`](#duration) | `yes` | The duration after which the workflow or task times out. | #### Examples ```yaml document: - dsl: "1.0.0-alpha1" + dsl: '1.0.0-alpha1' namespace: default name: sample - version: "0.1.0" + version: '0.1.0' do: wait: seconds: 60 @@ -1489,18 +1486,17 @@ Defines a duration. #### Properties -| Property | Type | Required | Description | -| ------------ | :-------: | :------: | ------------------------------- | -| Days | `integer` | `no` | Number of days, if any. | -| Hours | `integer` | `no` | Number of hours, if any. | -| Minutes | `integer` | `no` | Number of minutes, if any. | -| Seconds | `integer` | `no` | Number of seconds, if any. | -| Milliseconds | `integer` | `no` | Number of milliseconds, if any. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| Days | `integer` | `no` | Number of days, if any. | +| Hours | `integer` | `no` | Number of hours, if any. | +| Minutes | `integer` | `no`| Number of minutes, if any. | +| Seconds | `integer` | `no`| Number of seconds, if any. | +| Milliseconds | `integer` | `no`| Number of milliseconds, if any. | #### Examples -_Example of a duration of 2 hours, 15 minutes and 30 seconds:_ - +*Example of a duration of 2 hours, 15 minutes and 30 seconds:* ```yaml hours: 2 minutes: 15 @@ -1513,12 +1509,12 @@ Describes an HTTP response. #### Properties -| Property | Type | Required | Description | -| ---------- | :------------------------: | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| request | [`request`](#http-request) | `yes` | The HTTP request associated with the HTTP response. | -| statusCode | `integer` | `yes` | The HTTP response status code. | -| headers | `map[string, string]` | `no` | The HTTP response headers, if any. | -| content | `any` | `no` | The HTTP response content, if any.
_If the request's content type is one of the following, should contain the deserialized response content. Otherwise, should contain the base-64 encoded response content, if any._ | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| request | [`request`](#http-request) | `yes` | The HTTP request associated with the HTTP response. | +| statusCode | `integer` | `yes` | The HTTP response status code. | +| headers | `map[string, string]` | `no` | The HTTP response headers, if any. | +| content | `any` | `no` | The HTTP response content, if any.
*If the request's content type is one of the following, should contain the deserialized response content. Otherwise, should contain the base-64 encoded response content, if any.*| #### Examples @@ -1543,11 +1539,11 @@ Describes an HTTP request. #### Properties -| Property | Type | Required | Description | -| -------- | :-------------------: | :------: | --------------------------------- | -| method | `string` | `yes` | The request's method. | -| uri | `uri` | `yes` | The request's URI. | -| headers | `map[string, string]` | `no` | The HTTP request headers, if any. | +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| method | `string` | `yes` | The request's method. | +| uri | `uri` | `yes` | The request's URI. | +| headers | `map[string, string]` | `no` | The HTTP request headers, if any. | #### Examples @@ -1556,4 +1552,4 @@ method: get uri: https://petstore.swagger.io/v2/pet/1 headers: Content-Type: application/json -``` +``` \ No newline at end of file From dc721a3b2823dba7acd1c27309e407cce26c351e Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Wed, 5 Jun 2024 17:10:52 +0000 Subject: [PATCH 51/51] fix: remove left over name properties Signed-off-by: Matthias Pichler --- dsl-reference.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 805f26dc..5631d019 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -232,7 +232,6 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su | Name | Type | Required | Description| |:--|:---:|:---:|:---| -| name | `string` | `no` | The name of the task, if any. **SHOULD** be unique within an array. Required if you want to reference the task in [`then`](#flow-directive) | | 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. | | timeout | [`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any. | @@ -880,7 +879,6 @@ Defines a switch case, encompassing of a condition for matching and an associate | Name | Type | Required | Description | |:--|:---:|:---:|:---| -| name | `string` | `no` | The name of the case, if any. | | when | `string` | `no` | A runtime expression used to determine whether or not the case matches.
*If not set, the case will be matched by default if no other case match.*
*Note that there can be only one default case, all others **MUST** set a condition.* | then | [`flowDirective`](#flow-directive) | `yes` | The flow directive to execute when the case matches. |