Skip to content

Commit

Permalink
Fixing the state name and cleanup on readme
Browse files Browse the repository at this point in the history
  • Loading branch information
SankyRed committed Oct 10, 2023
1 parent ba8ef10 commit e7813c1
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 19 deletions.
12 changes: 4 additions & 8 deletions packages/aws-cdk-lib/aws-stepfunctions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ becomes new the new Data object. This behavior can be modified by supplying valu

These properties impact how each individual step interacts with the state machine data:

* `stateName`: the custom state name to each state if required else we used the construct id
* `stateName`: the name of the state in the state machine definition. If not supplied, defaults to the construct id.
* `inputPath`: the part of the data object that gets passed to the step (`itemsPath` for `Map` states)
* `resultSelector`: the part of the step result that should be added to the state machine data
* `resultPath`: where in the state machine data the step result should be inserted
Expand Down Expand Up @@ -250,8 +250,6 @@ An arbitrary JSON object (specified at execution start) is passed from state to
state and transformed during the execution of the workflow. For more
information, see the States Language spec.

You can add custom state names to all states and if not it defaults to construct id.

### Task

A `Task` represents some work that needs to be done. Do not use the `Task` class directly.
Expand Down Expand Up @@ -284,12 +282,11 @@ The `Pass` state also supports passing key-value pairs as input. Values can
be static, or selected from the input with a path.

The following example filters the `greeting` field from the state input
and also injects a field called `otherData`. You can also add custom state name
to Pass state.
and also injects a field called `otherData`.

```ts
const pass = new sfn.Pass(this, 'Filter input and inject data', {
stateName: 'my-pass-state',
stateName: 'my-pass-state', // the custom state name for the Pass state, defaults to 'Filter input and inject data' as the state name
parameters: { // input to the pass state
input: sfn.JsonPath.stringAt('$.input.greeting'),
otherData: 'some-extra-stuff',
Expand All @@ -307,13 +304,12 @@ Learn more about the [Pass state](https://docs.aws.amazon.com/step-functions/lat

A `Wait` state waits for a given number of seconds, or until the current time
hits a particular time. The time to wait may be taken from the execution's JSON
state. You can also add custom state name to Wait state.
state.

```ts
// Wait until it's the time mentioned in the the state object's "triggerTime"
// field.
const wait = new sfn.Wait(this, 'Wait For Trigger Time', {
stateName: 'new-wait-state',
time: sfn.WaitTime.timestampPath('$.triggerTime'),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Choice extends State {
public readonly endStates: INextable[] = [];

constructor(scope: Construct, id: string, props: ChoiceProps = {}) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-stepfunctions/lib/states/fail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Fail extends State {
private readonly causePath?: string;

constructor(scope: Construct, id: string, props: FailProps = {}) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);

this.error = props.error;
this.errorPath = props.errorPath;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-stepfunctions/lib/states/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class Map extends State implements INextable {
private readonly itemsPath?: string;

constructor(scope: Construct, id: string, props: MapProps = {}) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);
this.endStates = [this];
this.maxConcurrency = props.maxConcurrency;
this.itemsPath = props.itemsPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Parallel extends State implements INextable {
private readonly _branches: IChainable[] = [];

constructor(scope: Construct, id: string, props: ParallelProps = {}) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);

this.endStates = [this];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-stepfunctions/lib/states/pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class Pass extends State implements INextable {
private readonly result?: Result;

constructor(scope: Construct, id: string, props: PassProps = {}) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);

this.result = props.result;
this.endStates = [this];
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-stepfunctions/lib/states/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export abstract class State extends Construct implements IChainable {
private readonly incomingStates: State[] = [];

constructor(scope: Construct, id: string, props: StateProps) {
super(scope, props.stateName? props.stateName: id);
super(scope, id);

this.startState = this;

Expand Down Expand Up @@ -228,7 +228,7 @@ export abstract class State extends Construct implements IChainable {
* Tokenized string that evaluates to the state's ID
*/
public get stateId(): string {
return this.prefixes.concat(this.id).join('');
return this.prefixes.concat(this.stateName? this.stateName: this.id).join('');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Succeed extends State {
public readonly endStates: INextable[] = [];

constructor(scope: Construct, id: string, props: SucceedProps = {}) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export abstract class TaskStateBase extends State implements INextable {
private readonly credentials?: Credentials;

constructor(scope: Construct, id: string, props: TaskStateBaseProps) {
super(scope, props.stateName ? props.stateName: id, props);
super(scope, id, props);

this.endStates = [this];
this.timeout = props.timeout;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-stepfunctions/lib/states/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class Task extends State implements INextable {
private readonly taskProps: StepFunctionsTaskConfig;

constructor(scope: Construct, id: string, props: TaskProps) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);

this.timeout = props.timeout;
const taskProps = props.task.bind(this);
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-stepfunctions/lib/states/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Wait extends State implements INextable {
private readonly time: WaitTime;

constructor(scope: Construct, id: string, props: WaitProps) {
super(scope, props.stateName? props.stateName: id, props);
super(scope, id, props);

this.time = props.time;
this.endStates = [this];
Expand Down

0 comments on commit e7813c1

Please sign in to comment.