-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(stepfunctions): add comment ability for when condition #27010
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing this @msambol. Just a minor nit on how the function looks
protected addChoice(condition: Condition, next: State) { | ||
this.choices.push({ condition, next }); | ||
protected addChoice(condition: Condition, next: State, comment?: string) { | ||
this.choices.push({ condition, next, comment }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this function would be
protected addChoice(choice: ChoiceTransition) {
this.choices.push(choice);
}
but I guess we can't change the function signature now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can do this to help make this function signature stable if we ever add more props to ChoiceTransition
:
interface ChoiceTransition extends ChoiceTransitionOptions {
condition;
next;
}
interface ChoiceTransitionOptions {
comment?;
}
protected addChoice(condition: Condition, next: State, options: ChoiceTransitionOptions) {}
This has 2 benefits:
- using the function would look like
choice.when(sfn.Condition.stringEquals('$.color', 'BLUE'), handleBlueItem, {
comment: 'blue item comment',
});
which imo makes it clear that we're providing a comment.
- if we add an additional prop to
ChoiceTransition
in the future, likedefault
or something, we can easily add it toChoiceTransitionOptions
Pull request has been modified.
@kaizencc I updated per your feedback—thanks! |
/** | ||
* Options for Choice Transition | ||
*/ | ||
export interface IChoiceTransitionOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msambol what was the reason for naming this IChoiceTransitionOptions
? I assume you ran into some linter rule that yelled at you? Want to find out because I don't think it makes sense here, and we should exempt this from that rule if thats the case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaizencc Yep, I got:
aws-cdk-lib: The declaring class is introduced here
aws-cdk-lib: aws-stepfunctions/lib/states/state.ts:503:3 - error JSII3008: The "comment" property of struct "aws-cdk-lib.aws_stepfunctions.ChoiceTransitionOptions" must be "readonly". Rename "aws-cdk-lib.aws_stepfunctions.ChoiceTransitionOptions" to "IChoiceTransitionOptions" if it is meant to be a behavioral interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaizencc From what I'm reading there isn't a way to silence JSII errors? Hmm..
* | ||
* @default No comment | ||
*/ | ||
comment?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this fix the JSII error maybe?
comment?: string; | |
readonly comment?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jogold It did. Good shout, Jonathan. I was following the pattern of state
and condition
but there is no reason this can't be readonly
.
@kaizencc Mind taking another look here? |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Currently you can comment on a `Choice` state. This adds the ability to comment on a when condition. <img width="437" alt="Screenshot 2023-09-05 at 7 47 35 AM" src="https://github.com/aws/aws-cdk/assets/3310356/4cb92427-c16c-4994-9e86-0384c4c2b075"> <img width="473" alt="Screenshot 2023-09-05 at 7 54 29 AM" src="https://github.com/aws/aws-cdk/assets/3310356/4dc1857e-5515-4510-8fde-a5eb8bc93afe"> Closes #27005. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Currently you can comment on a
Choice
state.This adds the ability to comment on a when condition.
Closes #27005.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license