Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stepfunctions): add support JSONata and variables (#32343)
### Issue #32262 Closes #32262. ### Reason for this change For to use JSONata and variables of Step Function feature on AWS CDK. JSONata is new query language of Step Function, It is simple and powerful language. JSONata and variables is recommend for new state machine. ### Description of changes #### JSONata support Add `jsonPath()` and `jsonata()` factory methods to state constructs. For example, ```ts // For JSONPath sfn.Pass.jsonPath(stack, "JSONPathPass", { outputPath: sfn.JsonPath.stringAt('$foo'), }); // For JSONata sfn.Pass.jsonata(stack, "JSONataPass", { outputs: { count: "{% $states.input.count + 1 %}" }, }); ``` One option would be to simply add JSONata-specific properties to the Props of the existing State construct, but in this case, the JSONata-specific properties will be displayed to the JSONPath user. Conversely, it was thought that the development experience would deteriorate if JSONata users were shown JSONPath-specific properties. As a countermeasure, we decomposed the existing Props into JSONPath-specific properties and created `jsonPath()` and `jsonata()` factory methods to separate type suggestions for JSONPath users and JSONata users. The existing initialization method, the constructor, is backward compatible because it accepts `JSONPath` and `JSONata `properties. However, to use this interface directly is a lot of noise. This noise is a source of confusion for SFn beginners, and I thought it was necessary to solve this problem.  Therefore, we use the factory methods for each query language. ※ The `output` property is used in the image example, but it is actually `outputs`. Check out [this comment](#32343 (comment)) for the reasons for this decision. `jsonPath()` does not have a JSONata-specific property `outputs`.  `jsonata()` does not have JSONPath-specific properties such as `xxxPath`.  #### Variables Add `assign` to state constructs. `assign` can be used from either `JSONata` or `JSONPath`. For example, ```ts sfn.Pass.jsonata(this, 'AssignExamplePass', { assign: { count: "{% $states.input.count + 1 %}" }, }); ``` ### Description of how you validated changes Added unit test. Integration tests are not yet. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information