Skip to content

Commit 0bb3d6f

Browse files
authored
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. ![image](https://github.com/user-attachments/assets/ac7ffade-e601-44c7-a76c-064f3dce5e9e) 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`. ![image](https://github.com/user-attachments/assets/d3ee9ff1-9a7e-4c9d-bb85-ffd9e1b4a7f1) `jsonata()` does not have JSONPath-specific properties such as `xxxPath`. ![image](https://github.com/user-attachments/assets/f466ba1a-9bef-4d4f-944c-cdf544b1965b) #### 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*
1 parent 9ae1d34 commit 0bb3d6f

File tree

180 files changed

+167849
-897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+167849
-897
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/aws-sdk/integ.call-aws-service-jsonata.js.snapshot/AwsSdkJsonataTestDefaultTestDeployAssert03FB1EE5.assets.json

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/aws-sdk/integ.call-aws-service-jsonata.js.snapshot/AwsSdkJsonataTestDefaultTestDeployAssert03FB1EE5.template.json

+320
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/aws-sdk/integ.call-aws-service-jsonata.js.snapshot/asset.44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)