{"_id":"@andybalham/state-machine-with-graph-v2","_rev":"1-524a49e14aa20b8b929fdbb7c3f3238f","name":"@andybalham/state-machine-with-graph-v2","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@andybalham/state-machine-with-graph-v2","version":"2.0.0","description":"An extension of the CDK State Machine class that can output the underlying graph as JSON","main":"index.js","types":"index.d.ts","scripts":{"lint":"eslint ./src --ext .ts","lint-and-fix":"eslint ./src --ext .ts --fix","build":"npm run lint && tsc","test":"mocha --require ts-node/register test/**/*.ts","test-coverage":"nyc npm run test"},"repository":{"type":"git","url":"git+https://github.com/andybalham/agb-cdk-state-machine-with-graph.git"},"author":{"name":"Andy Blackledge"},"keywords":["aws","cdk","stepfunctions"],"license":"ISC","bugs":{"url":"https://github.com/andybalham/agb-cdk-state-machine-with-graph/issues"},"homepage":"https://github.com/andybalham/agb-cdk-state-machine-with-graph#readme","devDependencies":{"aws-cdk-lib":"^2.0.0","constructs":"^10.0.0","@istanbuljs/nyc-config-typescript":"^1.0.1","@types/chai":"^4.2.11","@types/mocha":"^8.2.1","@types/node":"^14.14.31","@typescript-eslint/eslint-plugin":"^4.15.2","@typescript-eslint/parser":"^4.15.2","chai":"^4.2.0","eslint":"^7.20.0","eslint-config-airbnb-typescript":"^12.3.1","eslint-config-prettier":"^8.1.0","eslint-config-standard":"^16.0.2","eslint-plugin-import":"^2.20.2","eslint-plugin-jsx-a11y":"^6.4.1","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.3.1","eslint-plugin-promise":"^4.2.1","eslint-plugin-react":"^7.22.0","eslint-plugin-standard":"^5.0.0","mocha":"^8.3.0","nyc":"^15.1.0","prettier":"^2.2.1","source-map-support":"^0.5.19","ts-node":"^9.1.1","typescript":"^4.2.2"},"peerDependencies":{"aws-cdk-lib":"2.x","constructs":"10.x"},"_id":"@andybalham/state-machine-with-graph-v2@2.0.0","_nodeVersion":"14.19.0","_npmVersion":"6.14.16","dist":{"integrity":"sha512-qeSg7adu23gnX85sbP4St8VUn2nsk3lGnhZ77IgnuhPCG+o1OkKKu6XeLLnhYrOMM4Ty/ktWSPVyisK4xmJ7Kg==","shasum":"89b0b3f85be3a03ca81f1dd76c679f884ec92929","tarball":"https://registry.npmjs.org/@andybalham/state-machine-with-graph-v2/-/state-machine-with-graph-v2-2.0.0.tgz","fileCount":10,"unpackedSize":8160,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiPs8AACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpmIQ//YSESRAaE9ieMH/GmQ6EA/X+B9p89DwObpx9bFvQwKmUP7Xtm\r\nF6XniM58Ygt7GcQ2u6Ktb4nSxnZd03gj621aj7Qppo70nnNA8s0KSeHgA0/8\r\nQIgU3i/zv4RK0E0ZHJ05q2fyl87IutFjbPBaEDXzNq8D7NO37+DEoeUxmvKf\r\n+iEI5fo31Fmamp/x4BIG/6cLofCgDzwYihE9n3gkr+JacQcd9ZEf7Wk00nUe\r\nQRuA85jcW/5YtEVda+Ea7iWgOQcGhKpVMq9aQTxO8fuZ3IbUb8mc/T5tgB4j\r\nJjhvu53Vfr4L6Z0dYfojqp3H7NUB3PtbRyoyA4snzJs4YcFj0bym/8b1eP8v\r\nLQG+hWrsqFPuNVy6WFQ+TIcmNoQrZ5dLRBZ69QMNCwYS4fvF/dukfEEHSdAV\r\nAP9paYizQd8JRpH2M3PMGIiWB3DNqQn6kFmhmptV9WTMBaCzr9VpKhaVvVrP\r\n97RDBE/fRMjNOd0nMrJCGMc/N5V4E5/W8TbTlsbBHFRfPudU4zuSYZ7tGKJL\r\nYUox07GViokHtU6GZB5p5w2Gu63QBF4RjcNCHSs/GwblEbnacWj4AtKKoWpF\r\navFo0vVJqr/gKeV45g7aaK6TzykNS0OMITFaVD0oprjLkieHfUiBBw3M7BGJ\r\nO21SYZHJbiq+QTpfwQFZ1cNyCv50u7i+gKk=\r\n=uf70\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD9HW44LGiSwCIonWI+m32URblXTQM89FEEGSBGG6VuowIhAKLm9a6mkDgfJ25sMI7F9F7R+FEGRhERV8H3vy+CGrfC"}]},"_npmUser":{"name":"andybalham","email":"andybalham@hotmail.com"},"directories":{},"maintainers":[{"name":"andybalham","email":"andybalham@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/state-machine-with-graph-v2_2.0.0_1648283391902_0.7871431519230094"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-26T08:29:51.850Z","2.0.0":"2022-03-26T08:29:52.075Z","modified":"2022-04-04T14:04:34.175Z"},"maintainers":[{"name":"andybalham","email":"andybalham@hotmail.com"}],"description":"An extension of the CDK State Machine class that can output the underlying graph as JSON","homepage":"https://github.com/andybalham/agb-cdk-state-machine-with-graph#readme","keywords":["aws","cdk","stepfunctions"],"repository":{"type":"git","url":"git+https://github.com/andybalham/agb-cdk-state-machine-with-graph.git"},"author":{"name":"Andy Blackledge"},"bugs":{"url":"https://github.com/andybalham/agb-cdk-state-machine-with-graph/issues"},"license":"ISC","readme":"# State Machine With Graph\n\nAn extension of the CDK `StateMachine` class that can output the underlying graph as JSON.\n\nTwo versions are supported:\n* The CDK v1 version is [@andybalham/state-machine-with-graph](https://www.npmjs.com/package/@andybalham/state-machine-with-graph) [![Build & test](https://github.com/andybalham/agb-cdk-state-machine-with-graph/actions/workflows/build-test-v1.yml/badge.svg)](https://github.com/andybalham/agb-cdk-state-machine-with-graph/actions/workflows/build-test-v1.yml)\n* The CDK v2 version is [@andybalham/state-machine-with-graph-v2](https://www.npmjs.com/package/@andybalham/state-machine-with-graph-v2) [![Build & test](https://github.com/andybalham/agb-cdk-state-machine-with-graph/actions/workflows/build-test.yml/badge.svg)](https://github.com/andybalham/agb-cdk-state-machine-with-graph/actions/workflows/build-test.yml)\n\n# Usage\n\n`StateMachineWithGraph` can be used in place of the CDK `StateMachine`, the only difference in usage is that a function must be supplied to return the state machine definition. This function is passed a `scope` parameter that must be used to create the states within the definition.\n\nFor example:\n\n```TypeScript\nconst stack = new cdk.Stack();\n\nconst stateMachine = new StateMachineWithGraph(stack, 'Test', {\n  getDefinition: (scope): sfn.IChainable => \n    sfn.Chain.start(new sfn.Pass(scope, 'Pass')),\n});\n\nconsole.log(stateMachine.graphJson);\n```\n\nOutputs:\n\n```JSON\n{\n  \"StartAt\": \"Pass\",\n  \"States\": {\n    \"Pass\": {\n      \"Type\": \"Pass\",\n      \"End\": true\n    }\n  }\n}\n```\n\n# Replacing CDK tokens\n\nIf you want the output to be consistent, e.g. for use in snapshot testing, then you can use the `replaceCdkTokens` property as shown below:\n\n```TypeScript\nconst stateMachine = new StateMachineWithGraph(stack, 'TestWithResources', {\n  replaceCdkTokens: true,\n  getDefinition: (definitionScope): sfn.IChainable => {\n```\n\nWith this set to `true`, the placeholder tokens generated by CDK are replaced with the constant value `CDK_TOKEN`. For example, if the output was being rendered as follows:\n\n```json\n  \"Type\": \"Task\",\n  \"Resource\": \"arn:${Token[AWS.Partition.7]}:states:::lambda:invoke\",\n  \"Parameters\": {\n    \"FunctionName\": \"${Token[TOKEN.245]}\",\n```\n\nThen setting `replaceCdkTokens` to `true` would result in the following:\n\n```json\n  \"Type\": \"Task\",\n  \"Resource\": \"arn:CDK_TOKEN:states:::lambda:invoke\",\n  \"Parameters\": {\n    \"FunctionName\": \"CDK_TOKEN\",\n```\n\n# Troubleshooting\n\nIf you see an error message like the following, check that the `scope` parameter passed to `getDefinition` is being used to create the states in the definition:\n\n```\nError: There is already a Construct with name 'Pass' in Stack [Default]\n```\n","readmeFilename":"readme.md"}