mbonig/state-machine

Update to not use deprecated prop `StateMachineProps#definition`

Closed this issue · 7 comments

When using this dependency for our stepfunctions we are seeing this error:

[WARNING] aws-cdk-lib.aws_stepfunctions.StateMachineProps#definition is deprecated.
  use definitionBody: DefinitionBody.fromChainable()
  This API will be removed in the next major release.

Any chance of updating to not use this deprecated prop?

Thanks!

mbonig commented

Thanks for bringing this up. Please give it a try and let me know if there are any issues.

Thanks for bringing this up. Please give it a try and let me know if there are any issues.

Hey Matt! Thanks for the quick response and update here! For some reason though I am still getting the warnings after updating

For your ref:

"aws-cdk": "^2.99.1",
"aws-cdk-lib": "^2.99.1",
"@matthewbonig/state-machine": "^0.0.29",

Seems like there are 2 warnings for every statemachine we have if that helps somehow!

mbonig commented

Can you share your output of:

cat node_modules/@matthewbonig/state-machine/package.json | grep version
cat node_modules/@matthewbonig/state-machine/lib/StateMachine.js

Can you share your output of:

cat node_modules/@matthewbonig/state-machine/package.json | grep version
cat node_modules/@matthewbonig/state-machine/lib/StateMachine.js

Sure thing :

"standard-version": "^9",
"version": "0.0.29",

and

"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateMachine = void 0;
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
const aws_stepfunctions = require("aws-cdk-lib/aws-stepfunctions");
const aws_stepfunctions_1 = require("aws-cdk-lib/aws-stepfunctions");
const yaml = require("js-yaml");
// eslint-disable-next-line @typescript-eslint/no-require-imports
const merge = require('lodash.merge');
class StateMachine extends aws_stepfunctions.StateMachine {
    constructor(scope, id, props) {
        const mergedDefinition = merge(props.definition, { States: props.overrides });
        let definitionString;
        if (props.aslYaml) {
            definitionString = yaml.dump(mergedDefinition);
        }
        else {
            definitionString = JSON.stringify(mergedDefinition);
        }
        const propsMinusDefinition = {
            ...props,
            definition: undefined,
        };
        super(scope, id, {
            ...propsMinusDefinition,
            definitionBody: aws_stepfunctions_1.DefinitionBody.fromString(definitionString),
        });
    }
}
exports.StateMachine = StateMachine;
_a = JSII_RTTI_SYMBOL_1;
StateMachine[_a] = { fqn: "@matthewbonig/state-machine.StateMachine", version: "0.0.29" };
mbonig commented

Yup, that's the right code. I just didn't test the fix properly... one second.

mbonig commented

Please try again

That's us sorted now! Nice one!