From 3e090b7406745fa70a0ca26fb40ed89f250ff84a Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Mon, 18 Mar 2024 11:57:35 +0100 Subject: [PATCH 1/4] [Fix #712] Describe merge behaviour for non object Update specification to make runtimes predicateble when an action produced a non json object and there is not toStateData filter Signed-off-by: Francisco Javier Tirado Sarti --- specification.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification.md b/specification.md index ea4d2ef1..9a0f5441 100644 --- a/specification.md +++ b/specification.md @@ -439,7 +439,7 @@ The second way would be to directly filter only the "veggie like" vegetables wit | fromStateData | Workflow expression that filters state data that can be used by the action | string | no | | useResults | If set to `false`, action data results are not added/merged to state data. In this case 'results' and 'toStateData' should be ignored. Default is `true`. | boolean | no | | results | Workflow expression that filters the actions data results | string | no | -| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified denotes the top-level state data element | string | no | +| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified denotes the top-level state data element. In case it is not specified and the result of the action is not an object, that result should be merged as value of `response` key. If that `response` key already exist in the model, its value will be overwritten. | string | no |
Click to view example definition

From a6390d351fe6e9d0ff6083f5e0618390acbffc27 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Mon, 18 Mar 2024 19:11:43 +0100 Subject: [PATCH 2/4] [Fix #712] Ricardo's comment Signed-off-by: Francisco Javier Tirado Sarti --- specification.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/specification.md b/specification.md index 9a0f5441..0251eb74 100644 --- a/specification.md +++ b/specification.md @@ -565,6 +565,27 @@ into. With this, after our action executes the state data would be: } ``` +To illustrate merge of not json both object, let`s assume that, in previous example, the action definition is at follows + +```json +"actions":[ + { + "name": "fetch_only_pasta", + "functionRef": "breadAndPastaTypesFunction", + "actionDataFilter": { + "results": "${ .pasta[1] ]", + } + } + ] +} +``` +Since there is not `toStateData` and the result is not a json object but an string, the state would be + +```json +{ + "response": "spaghetti" +} +``` In the case action results should not be added/merged to state data, we can set the `useResults` property to `false`. In this case, the `results` and `toStateData` properties should be ignored, and nothing is added/merged to state data. If `useResults` is not specified (or it's value set to `true`), action results, if available, should be added/merged to state data. From 45079dcfb1bf5b1517b186b4be98068b3c0d9b33 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Thu, 4 Apr 2024 17:09:03 +0200 Subject: [PATCH 3/4] [Fix #712] Modifying key name as discussed Signed-off-by: Francisco Javier Tirado Sarti --- specification.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specification.md b/specification.md index 0251eb74..1b4f0f5e 100644 --- a/specification.md +++ b/specification.md @@ -439,7 +439,7 @@ The second way would be to directly filter only the "veggie like" vegetables wit | fromStateData | Workflow expression that filters state data that can be used by the action | string | no | | useResults | If set to `false`, action data results are not added/merged to state data. In this case 'results' and 'toStateData' should be ignored. Default is `true`. | boolean | no | | results | Workflow expression that filters the actions data results | string | no | -| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified denotes the top-level state data element. In case it is not specified and the result of the action is not an object, that result should be merged as value of `response` key. If that `response` key already exist in the model, its value will be overwritten. | string | no | +| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified denotes the top-level state data element. In case it is not specified and the result of the action is not an object, that result should be merged as value of an automatically generated key. That key name will be the result of concatenating the action name with `_output` suffix. | string | no |

Click to view example definition

@@ -579,11 +579,11 @@ To illustrate merge of not json both object, let`s assume that, in previous ex ] } ``` -Since there is not `toStateData` and the result is not a json object but an string, the state would be +Since there is not `toStateData` and the result is not a json object but an string, the model would be ```json { - "response": "spaghetti" + "fetch_only_pasta_output": "spaghetti" } ``` In the case action results should not be added/merged to state data, we can set the `useResults` property to `false`. From 049b4e861865420cde388b777dbec48b8ff134d6 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:34:00 +0200 Subject: [PATCH 4/4] Update specification.md Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Update specification.md Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Update specification.md Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Update specification.md Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Update specification.md Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Update specification.md Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Signed-off-by: Francisco Javier Tirado Sarti --- specification.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/specification.md b/specification.md index 1b4f0f5e..b3e5baee 100644 --- a/specification.md +++ b/specification.md @@ -439,7 +439,7 @@ The second way would be to directly filter only the "veggie like" vegetables wit | fromStateData | Workflow expression that filters state data that can be used by the action | string | no | | useResults | If set to `false`, action data results are not added/merged to state data. In this case 'results' and 'toStateData' should be ignored. Default is `true`. | boolean | no | | results | Workflow expression that filters the actions data results | string | no | -| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified denotes the top-level state data element. In case it is not specified and the result of the action is not an object, that result should be merged as value of an automatically generated key. That key name will be the result of concatenating the action name with `_output` suffix. | string | no | +| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged. If not specified denotes the top-level state data element. In case it is not specified and the result of the action is not an object, that result should be merged as the value of an automatically generated key. That key name will be the result of concatenating the action name with `-output` suffix. | string | no |

Click to view example definition

@@ -565,25 +565,24 @@ into. With this, after our action executes the state data would be: } ``` -To illustrate merge of not json both object, let`s assume that, in previous example, the action definition is at follows +To illustrate the merge of non-JSON for both objects, let's assume that, in the previous example, the action definition is the follows ```json "actions":[ { - "name": "fetch_only_pasta", + "name": "fetch-only-pasta", "functionRef": "breadAndPastaTypesFunction", "actionDataFilter": { "results": "${ .pasta[1] ]", } } ] -} ``` -Since there is not `toStateData` and the result is not a json object but an string, the model would be +Since there is no `toStateData` attribute and the result is not a JSON object but a string, the model would be: ```json { - "fetch_only_pasta_output": "spaghetti" + "fetch-only-pasta-output": "spaghetti" } ``` In the case action results should not be added/merged to state data, we can set the `useResults` property to `false`.