├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── .mergify.yml ├── LICENSE ├── cdk-example ├── .gitignore ├── .npmignore ├── README.md ├── bin │ └── cdk-example.ts ├── cdk.json ├── jest.config.js ├── lib │ └── cdk-example-stack.ts ├── package-lock.json ├── package.json ├── src │ └── program.ts ├── test │ └── cdk-example.test.ts └── tsconfig.json ├── examples ├── api-gateway.md ├── arrays.md ├── boolean-evalation.md ├── choice.md ├── closures.md ├── conditional-expression.md ├── datetime-now.md ├── do-while.md ├── enums.md ├── expressions.md ├── for-each.md ├── hello-world.md ├── if.md ├── in-keyword.md ├── input-validation.md ├── kyc.md ├── map.md ├── nested-stepfunctions.md ├── null-coalescing.md ├── optional-property-chain.md ├── pagination.md ├── parallel.md ├── sdk-states.md ├── states.md ├── string-templates.md ├── switch.md ├── throw.md ├── try-catch.md ├── ts-lib-convert.md ├── variable-assignments.md ├── variables.md └── while.md ├── package-lock.json ├── package.json ├── packages ├── asl-lib │ ├── .gitignore │ ├── build │ │ ├── asl-lib-private.d.ts │ │ ├── asl-lib-public.ts │ │ ├── asl-lib.d.ts │ │ └── wrapdts.ts │ ├── package.json │ ├── src │ │ ├── asl-internals.ts │ │ ├── asl.ts │ │ ├── deploy.ts │ │ ├── index.ts │ │ ├── optimized.ts │ │ ├── runtime.ts │ │ ├── sdk.ts │ │ ├── testing.ts │ │ └── types │ │ │ ├── choice.d.ts │ │ │ ├── fail.d.ts │ │ │ ├── index.d.ts │ │ │ ├── map.d.ts │ │ │ ├── parallel.d.ts │ │ │ ├── pass.d.ts │ │ │ ├── state-machine.d.ts │ │ │ ├── state.d.ts │ │ │ ├── succeed.d.ts │ │ │ ├── task.d.ts │ │ │ └── wait.d.ts │ └── tsconfig.json ├── cdk │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── iamfast │ │ ├── asl.js │ │ └── resolve-permissions.ts │ ├── index.ts │ ├── jest.config.js │ ├── package.json │ └── tsconfig.json ├── cli │ ├── .circleci │ │ └── config.yml │ ├── .editorconfig │ ├── .eslintignore │ ├── .eslintrc │ ├── .github │ │ └── dependabot.yml │ ├── .gitignore │ ├── .mocharc.json │ ├── LICENSE │ ├── README.md │ ├── bin │ │ ├── dev │ │ ├── dev.cmd │ │ ├── run │ │ └── run.cmd │ ├── package.json │ ├── src │ │ ├── commands │ │ │ └── compile │ │ │ │ └── index.ts │ │ └── index.ts │ └── tsconfig.json └── convert │ ├── .gitignore │ ├── jest.config.e2e.js │ ├── jest.config.js │ ├── package.json │ ├── src │ ├── ParserError.ts │ ├── __test__ │ │ ├── integration-tests │ │ │ ├── api-gateway.integration.ts │ │ │ ├── arrays.integration.ts │ │ │ ├── boolean-evalation.integration.ts │ │ │ ├── choice.integration.ts │ │ │ ├── closures.integration.ts │ │ │ ├── conditional-expression.integration.ts │ │ │ ├── datetime-now.integration.ts │ │ │ ├── do-while.integration.ts │ │ │ ├── enums.integration.ts │ │ │ ├── expressions.integration.ts │ │ │ ├── for-each.integration.ts │ │ │ ├── hello-world.integration.ts │ │ │ ├── if.integration.ts │ │ │ ├── in-keyword.integration.ts │ │ │ ├── input-validation.integration.ts │ │ │ ├── kyc.integration.ts │ │ │ ├── map.integration.ts │ │ │ ├── nested-stepfunctions.integration.ts │ │ │ ├── null-coalescing.integration.ts │ │ │ ├── optional-property-chain.integration.ts │ │ │ ├── pagination.integration.ts │ │ │ ├── parallel.integration.ts │ │ │ ├── sdk-states.integration.ts │ │ │ ├── states.integration.ts │ │ │ ├── string-templates.integration.ts │ │ │ ├── switch.integration.ts │ │ │ ├── throw.integration.ts │ │ │ ├── try-catch.integration.ts │ │ │ ├── ts-lib-convert.integration.ts │ │ │ ├── variable-assignments.integration.ts │ │ │ ├── variables.integration.ts │ │ │ └── while.integration.ts │ │ ├── output │ │ │ ├── asl │ │ │ │ ├── api-gateway-main.json │ │ │ │ ├── arrays-filterArray.json │ │ │ │ ├── arrays-jsonPathExpressions.json │ │ │ │ ├── arrays-mapArray.json │ │ │ │ ├── arrays-mapArrayNestedPropertyAccess.json │ │ │ │ ├── arrays-mapArraySimple.json │ │ │ │ ├── arrays-serializeArray.json │ │ │ │ ├── boolean-evalation-main.json │ │ │ │ ├── boolean-evalation-numericComparison.json │ │ │ │ ├── choice-choice.json │ │ │ │ ├── choice-choiceWithShorthand.json │ │ │ │ ├── choice-choiceWithSingleStatements.json │ │ │ │ ├── closures-main.json │ │ │ │ ├── conditional-expression-conditional.json │ │ │ │ ├── conditional-expression-conditionalWithLiteral.json │ │ │ │ ├── conditional-expression-conditionalWithinExpression.json │ │ │ │ ├── conditional-expression-conditionalWithinStringFormat.json │ │ │ │ ├── conditional-expression-nestedConditional.json │ │ │ │ ├── datetime-now-dateTimeNow.json │ │ │ │ ├── datetime-now-dateTimeUsingJsonPath.json │ │ │ │ ├── do-while-doWhileWithBreak.json │ │ │ │ ├── do-while-doWhileWithContinue.json │ │ │ │ ├── do-while-doWhileWithEarlyReturn.json │ │ │ │ ├── do-while-simpleDoAlwaysFalse.json │ │ │ │ ├── do-while-simpleDoWhile.json │ │ │ │ ├── enums-compareEnum.json │ │ │ │ ├── enums-compareStringEnum.json │ │ │ │ ├── expressions-booleans.json │ │ │ │ ├── expressions-concatStrings.json │ │ │ │ ├── expressions-numbers.json │ │ │ │ ├── expressions-parameters.json │ │ │ │ ├── for-each-emptyForeach.json │ │ │ │ ├── for-each-foreachEarlyReturn.json │ │ │ │ ├── for-each-foreachWithBreak.json │ │ │ │ ├── for-each-foreachWithContinue.json │ │ │ │ ├── for-each-nestedForeach.json │ │ │ │ ├── for-each-simpleForeach.json │ │ │ │ ├── hello-world-main.json │ │ │ │ ├── if-enclosedVars.json │ │ │ │ ├── if-ifElse.json │ │ │ │ ├── if-justIf.json │ │ │ │ ├── if-nestedIfs.json │ │ │ │ ├── in-keyword-IfStatementWithInKeyword.json │ │ │ │ ├── input-validation-checkArgumentRange.json │ │ │ │ ├── input-validation-checkArgumentType.json │ │ │ │ ├── input-validation-checkArgumentTypeProvideDefault.json │ │ │ │ ├── kyc-main.json │ │ │ │ ├── map-main.json │ │ │ │ ├── nested-stepfunctions-callLambdaNoAwait.json │ │ │ │ ├── nested-stepfunctions-callLambdaWithAwait.json │ │ │ │ ├── nested-stepfunctions-callLambdaWithAwaitUsingTask.json │ │ │ │ ├── nested-stepfunctions-callStateMachineNoAwait.json │ │ │ │ ├── nested-stepfunctions-callStateMachinePassReference.json │ │ │ │ ├── nested-stepfunctions-callStateMachineWithAwait.json │ │ │ │ ├── nested-stepfunctions-childStateMachine.json │ │ │ │ ├── nested-stepfunctions-notAwaitedVoidExpression.json │ │ │ │ ├── null-coalescing-nestedNullCoalescing.json │ │ │ │ ├── null-coalescing-nullCoalescing.json │ │ │ │ ├── null-coalescing-nullCoalescingWithLiteral.json │ │ │ │ ├── null-coalescing-nullCoalescingWithinExpression.json │ │ │ │ ├── null-coalescing-nullCoalescingWithinStringFormat.json │ │ │ │ ├── optional-property-chain-assignOptionalChain.json │ │ │ │ ├── optional-property-chain-returnLongerChain.json │ │ │ │ ├── optional-property-chain-returnOptionalChain.json │ │ │ │ ├── pagination-doSomething.json │ │ │ │ ├── pagination-listUsers.json │ │ │ │ ├── parallel-enclosedVariables.json │ │ │ │ ├── parallel-simple.json │ │ │ │ ├── sdk-states-cloudWatchPutMetricData.json │ │ │ │ ├── sdk-states-countDynamoDBItems.json │ │ │ │ ├── sdk-states-dynamoDBPutItemIfNotExists.json │ │ │ │ ├── states-waitForTaskToken.json │ │ │ │ ├── string-templates-escapedCharacters.json │ │ │ │ ├── string-templates-stringTemplates.json │ │ │ │ ├── switch-createAwsAccount.json │ │ │ │ ├── switch-simpleSwitch.json │ │ │ │ ├── switch-switchCaseFallsThrough.json │ │ │ │ ├── switch-switchCaseFallsThroughToDefault.json │ │ │ │ ├── switch-switchCaseNonEmptyFallThrough.json │ │ │ │ ├── switch-switchDefaultFallsThrough.json │ │ │ │ ├── switch-switchWithBlock.json │ │ │ │ ├── throw-CatchErrors.json │ │ │ │ ├── throw-RetryErrors.json │ │ │ │ ├── throw-throwErrors.json │ │ │ │ ├── throw-tryCatch.json │ │ │ │ ├── try-catch-referenceError.json │ │ │ │ ├── try-catch-simpleMultipleStatements.json │ │ │ │ ├── try-catch-simpleTry.json │ │ │ │ ├── try-catch-tryAroundPassState.json │ │ │ │ ├── try-catch-tryCatchFailState.json │ │ │ │ ├── try-catch-tryCatchFinally.json │ │ │ │ ├── try-catch-tryFinally.json │ │ │ │ ├── ts-lib-convert-convertStringToBoolean.json │ │ │ │ ├── ts-lib-convert-convertStringToNumber.json │ │ │ │ ├── variable-assignments-arrayIndexer.json │ │ │ │ ├── variable-assignments-arrayWithIdentifiers.json │ │ │ │ ├── variable-assignments-assignmentToNull.json │ │ │ │ ├── variable-assignments-assignmentToUndefined.json │ │ │ │ ├── variable-assignments-binaryExpression.json │ │ │ │ ├── variable-assignments-functions.json │ │ │ │ ├── variable-assignments-literals.json │ │ │ │ ├── variable-assignments-typeOfExpressions.json │ │ │ │ ├── variable-assignments-unassignedVariable.json │ │ │ │ ├── variables-main.json │ │ │ │ ├── while-simpleWhile.json │ │ │ │ ├── while-whileWithBreak.json │ │ │ │ ├── while-whileWithContinue.json │ │ │ │ └── while-whileWithEarlyReturn.json │ │ │ ├── iasl │ │ │ │ ├── api-gateway-main.json │ │ │ │ ├── arrays-filterArray.json │ │ │ │ ├── arrays-jsonPathExpressions.json │ │ │ │ ├── arrays-mapArray.json │ │ │ │ ├── arrays-mapArrayNestedPropertyAccess.json │ │ │ │ ├── arrays-mapArraySimple.json │ │ │ │ ├── arrays-serializeArray.json │ │ │ │ ├── boolean-evalation-main.json │ │ │ │ ├── boolean-evalation-numericComparison.json │ │ │ │ ├── choice-choice.json │ │ │ │ ├── choice-choiceWithShorthand.json │ │ │ │ ├── choice-choiceWithSingleStatements.json │ │ │ │ ├── closures-main.json │ │ │ │ ├── conditional-expression-conditional.json │ │ │ │ ├── conditional-expression-conditionalWithLiteral.json │ │ │ │ ├── conditional-expression-conditionalWithinExpression.json │ │ │ │ ├── conditional-expression-conditionalWithinStringFormat.json │ │ │ │ ├── conditional-expression-nestedConditional.json │ │ │ │ ├── datetime-now-dateTimeNow.json │ │ │ │ ├── datetime-now-dateTimeUsingJsonPath.json │ │ │ │ ├── do-while-doWhileWithBreak.json │ │ │ │ ├── do-while-doWhileWithContinue.json │ │ │ │ ├── do-while-doWhileWithEarlyReturn.json │ │ │ │ ├── do-while-simpleDoAlwaysFalse.json │ │ │ │ ├── do-while-simpleDoWhile.json │ │ │ │ ├── enums-compareEnum.json │ │ │ │ ├── enums-compareStringEnum.json │ │ │ │ ├── expressions-booleans.json │ │ │ │ ├── expressions-concatStrings.json │ │ │ │ ├── expressions-numbers.json │ │ │ │ ├── expressions-parameters.json │ │ │ │ ├── for-each-emptyForeach.json │ │ │ │ ├── for-each-foreachEarlyReturn.json │ │ │ │ ├── for-each-foreachWithBreak.json │ │ │ │ ├── for-each-foreachWithContinue.json │ │ │ │ ├── for-each-nestedForeach.json │ │ │ │ ├── for-each-simpleForeach.json │ │ │ │ ├── hello-world-main.json │ │ │ │ ├── if-enclosedVars.json │ │ │ │ ├── if-ifElse.json │ │ │ │ ├── if-justIf.json │ │ │ │ ├── if-nestedIfs.json │ │ │ │ ├── in-keyword-IfStatementWithInKeyword.json │ │ │ │ ├── input-validation-checkArgumentRange.json │ │ │ │ ├── input-validation-checkArgumentType.json │ │ │ │ ├── input-validation-checkArgumentTypeProvideDefault.json │ │ │ │ ├── kyc-main.json │ │ │ │ ├── map-main.json │ │ │ │ ├── nested-stepfunctions-callLambdaNoAwait.json │ │ │ │ ├── nested-stepfunctions-callLambdaWithAwait.json │ │ │ │ ├── nested-stepfunctions-callLambdaWithAwaitUsingTask.json │ │ │ │ ├── nested-stepfunctions-callStateMachineNoAwait.json │ │ │ │ ├── nested-stepfunctions-callStateMachinePassReference.json │ │ │ │ ├── nested-stepfunctions-callStateMachineWithAwait.json │ │ │ │ ├── nested-stepfunctions-childStateMachine.json │ │ │ │ ├── nested-stepfunctions-notAwaitedVoidExpression.json │ │ │ │ ├── null-coalescing-nestedNullCoalescing.json │ │ │ │ ├── null-coalescing-nullCoalescing.json │ │ │ │ ├── null-coalescing-nullCoalescingWithLiteral.json │ │ │ │ ├── null-coalescing-nullCoalescingWithinExpression.json │ │ │ │ ├── null-coalescing-nullCoalescingWithinStringFormat.json │ │ │ │ ├── optional-property-chain-assignOptionalChain.json │ │ │ │ ├── optional-property-chain-returnLongerChain.json │ │ │ │ ├── optional-property-chain-returnOptionalChain.json │ │ │ │ ├── pagination-doSomething.json │ │ │ │ ├── pagination-listUsers.json │ │ │ │ ├── parallel-enclosedVariables.json │ │ │ │ ├── parallel-simple.json │ │ │ │ ├── sdk-states-cloudWatchPutMetricData.json │ │ │ │ ├── sdk-states-countDynamoDBItems.json │ │ │ │ ├── sdk-states-dynamoDBPutItemIfNotExists.json │ │ │ │ ├── states-waitForTaskToken.json │ │ │ │ ├── string-templates-escapedCharacters.json │ │ │ │ ├── string-templates-stringTemplates.json │ │ │ │ ├── switch-createAwsAccount.json │ │ │ │ ├── switch-simpleSwitch.json │ │ │ │ ├── switch-switchCaseFallsThrough.json │ │ │ │ ├── switch-switchCaseFallsThroughToDefault.json │ │ │ │ ├── switch-switchCaseNonEmptyFallThrough.json │ │ │ │ ├── switch-switchDefaultFallsThrough.json │ │ │ │ ├── switch-switchWithBlock.json │ │ │ │ ├── throw-CatchErrors.json │ │ │ │ ├── throw-RetryErrors.json │ │ │ │ ├── throw-throwErrors.json │ │ │ │ ├── throw-tryCatch.json │ │ │ │ ├── try-catch-referenceError.json │ │ │ │ ├── try-catch-simpleMultipleStatements.json │ │ │ │ ├── try-catch-simpleTry.json │ │ │ │ ├── try-catch-tryAroundPassState.json │ │ │ │ ├── try-catch-tryCatchFailState.json │ │ │ │ ├── try-catch-tryCatchFinally.json │ │ │ │ ├── try-catch-tryFinally.json │ │ │ │ ├── ts-lib-convert-convertStringToBoolean.json │ │ │ │ ├── ts-lib-convert-convertStringToNumber.json │ │ │ │ ├── variable-assignments-arrayIndexer.json │ │ │ │ ├── variable-assignments-arrayWithIdentifiers.json │ │ │ │ ├── variable-assignments-assignmentToNull.json │ │ │ │ ├── variable-assignments-assignmentToUndefined.json │ │ │ │ ├── variable-assignments-binaryExpression.json │ │ │ │ ├── variable-assignments-functions.json │ │ │ │ ├── variable-assignments-literals.json │ │ │ │ ├── variable-assignments-typeOfExpressions.json │ │ │ │ ├── variable-assignments-unassignedVariable.json │ │ │ │ ├── variables-main.json │ │ │ │ ├── while-simpleWhile.json │ │ │ │ ├── while-whileWithBreak.json │ │ │ │ ├── while-whileWithContinue.json │ │ │ │ └── while-whileWithEarlyReturn.json │ │ │ └── ts-lib │ │ │ │ ├── api-gateway-main.ts │ │ │ │ ├── arrays-filterArray.ts │ │ │ │ ├── arrays-jsonPathExpressions.ts │ │ │ │ ├── arrays-mapArray.ts │ │ │ │ ├── arrays-mapArrayNestedPropertyAccess.ts │ │ │ │ ├── arrays-mapArraySimple.ts │ │ │ │ ├── arrays-serializeArray.ts │ │ │ │ ├── boolean-evalation-main.ts │ │ │ │ ├── boolean-evalation-numericComparison.ts │ │ │ │ ├── choice-choice.ts │ │ │ │ ├── choice-choiceWithShorthand.ts │ │ │ │ ├── choice-choiceWithSingleStatements.ts │ │ │ │ ├── closures-main.ts │ │ │ │ ├── conditional-expression-conditional.ts │ │ │ │ ├── conditional-expression-conditionalWithLiteral.ts │ │ │ │ ├── conditional-expression-conditionalWithinExpression.ts │ │ │ │ ├── conditional-expression-conditionalWithinStringFormat.ts │ │ │ │ ├── conditional-expression-nestedConditional.ts │ │ │ │ ├── datetime-now-dateTimeNow.ts │ │ │ │ ├── datetime-now-dateTimeUsingJsonPath.ts │ │ │ │ ├── do-while-doWhileWithBreak.ts │ │ │ │ ├── do-while-doWhileWithContinue.ts │ │ │ │ ├── do-while-doWhileWithEarlyReturn.ts │ │ │ │ ├── do-while-simpleDoAlwaysFalse.ts │ │ │ │ ├── do-while-simpleDoWhile.ts │ │ │ │ ├── enums-compareEnum.ts │ │ │ │ ├── enums-compareStringEnum.ts │ │ │ │ ├── expressions-booleans.ts │ │ │ │ ├── expressions-concatStrings.ts │ │ │ │ ├── expressions-numbers.ts │ │ │ │ ├── expressions-parameters.ts │ │ │ │ ├── for-each-emptyForeach.ts │ │ │ │ ├── for-each-foreachEarlyReturn.ts │ │ │ │ ├── for-each-foreachWithBreak.ts │ │ │ │ ├── for-each-foreachWithContinue.ts │ │ │ │ ├── for-each-nestedForeach.ts │ │ │ │ ├── for-each-simpleForeach.ts │ │ │ │ ├── hello-world-main.ts │ │ │ │ ├── if-enclosedVars.ts │ │ │ │ ├── if-ifElse.ts │ │ │ │ ├── if-justIf.ts │ │ │ │ ├── if-nestedIfs.ts │ │ │ │ ├── in-keyword-IfStatementWithInKeyword.ts │ │ │ │ ├── input-validation-checkArgumentRange.ts │ │ │ │ ├── input-validation-checkArgumentType.ts │ │ │ │ ├── input-validation-checkArgumentTypeProvideDefault.ts │ │ │ │ ├── kyc-main.ts │ │ │ │ ├── map-main.ts │ │ │ │ ├── nested-stepfunctions-callLambdaNoAwait.ts │ │ │ │ ├── nested-stepfunctions-callLambdaWithAwait.ts │ │ │ │ ├── nested-stepfunctions-callLambdaWithAwaitUsingTask.ts │ │ │ │ ├── nested-stepfunctions-callStateMachineNoAwait.ts │ │ │ │ ├── nested-stepfunctions-callStateMachinePassReference.ts │ │ │ │ ├── nested-stepfunctions-callStateMachineWithAwait.ts │ │ │ │ ├── nested-stepfunctions-childStateMachine.ts │ │ │ │ ├── nested-stepfunctions-notAwaitedVoidExpression.ts │ │ │ │ ├── null-coalescing-nestedNullCoalescing.ts │ │ │ │ ├── null-coalescing-nullCoalescing.ts │ │ │ │ ├── null-coalescing-nullCoalescingWithLiteral.ts │ │ │ │ ├── null-coalescing-nullCoalescingWithinExpression.ts │ │ │ │ ├── null-coalescing-nullCoalescingWithinStringFormat.ts │ │ │ │ ├── optional-property-chain-assignOptionalChain.ts │ │ │ │ ├── optional-property-chain-returnLongerChain.ts │ │ │ │ ├── optional-property-chain-returnOptionalChain.ts │ │ │ │ ├── pagination-doSomething.ts │ │ │ │ ├── pagination-listUsers.ts │ │ │ │ ├── parallel-enclosedVariables.ts │ │ │ │ ├── parallel-simple.ts │ │ │ │ ├── sdk-states-cloudWatchPutMetricData.ts │ │ │ │ ├── sdk-states-countDynamoDBItems.ts │ │ │ │ ├── sdk-states-dynamoDBPutItemIfNotExists.ts │ │ │ │ ├── states-waitForTaskToken.ts │ │ │ │ ├── string-templates-escapedCharacters.ts │ │ │ │ ├── string-templates-stringTemplates.ts │ │ │ │ ├── switch-createAwsAccount.ts │ │ │ │ ├── switch-simpleSwitch.ts │ │ │ │ ├── switch-switchCaseFallsThrough.ts │ │ │ │ ├── switch-switchCaseFallsThroughToDefault.ts │ │ │ │ ├── switch-switchCaseNonEmptyFallThrough.ts │ │ │ │ ├── switch-switchDefaultFallsThrough.ts │ │ │ │ ├── switch-switchWithBlock.ts │ │ │ │ ├── throw-CatchErrors.ts │ │ │ │ ├── throw-RetryErrors.ts │ │ │ │ ├── throw-throwErrors.ts │ │ │ │ ├── throw-tryCatch.ts │ │ │ │ ├── try-catch-referenceError.ts │ │ │ │ ├── try-catch-simpleMultipleStatements.ts │ │ │ │ ├── try-catch-simpleTry.ts │ │ │ │ ├── try-catch-tryAroundPassState.ts │ │ │ │ ├── try-catch-tryCatchFailState.ts │ │ │ │ ├── try-catch-tryCatchFinally.ts │ │ │ │ ├── try-catch-tryFinally.ts │ │ │ │ ├── ts-lib-convert-convertStringToBoolean.ts │ │ │ │ ├── ts-lib-convert-convertStringToNumber.ts │ │ │ │ ├── variable-assignments-arrayIndexer.ts │ │ │ │ ├── variable-assignments-arrayWithIdentifiers.ts │ │ │ │ ├── variable-assignments-assignmentToNull.ts │ │ │ │ ├── variable-assignments-assignmentToUndefined.ts │ │ │ │ ├── variable-assignments-binaryExpression.ts │ │ │ │ ├── variable-assignments-functions.ts │ │ │ │ ├── variable-assignments-literals.ts │ │ │ │ ├── variable-assignments-typeOfExpressions.ts │ │ │ │ ├── variable-assignments-unassignedVariable.ts │ │ │ │ ├── variables-main.ts │ │ │ │ ├── while-simpleWhile.ts │ │ │ │ ├── while-whileWithBreak.ts │ │ │ │ ├── while-whileWithContinue.ts │ │ │ │ └── while-whileWithEarlyReturn.ts │ │ ├── resources │ │ │ ├── api-gateway.ts │ │ │ ├── arrays.ts │ │ │ ├── boolean-evalation.ts │ │ │ ├── choice.ts │ │ │ ├── closures.ts │ │ │ ├── conditional-expression.ts │ │ │ ├── datetime-now.ts │ │ │ ├── do-while.ts │ │ │ ├── enums.ts │ │ │ ├── expressions.ts │ │ │ ├── for-each.ts │ │ │ ├── hello-world.ts │ │ │ ├── if.ts │ │ │ ├── in-keyword.ts │ │ │ ├── input-validation.ts │ │ │ ├── kyc.ts │ │ │ ├── map.ts │ │ │ ├── nested-stepfunctions.ts │ │ │ ├── null-coalescing.ts │ │ │ ├── optional-property-chain.ts │ │ │ ├── pagination.ts │ │ │ ├── parallel.ts │ │ │ ├── sdk-states.ts │ │ │ ├── states.ts │ │ │ ├── string-templates.ts │ │ │ ├── switch.ts │ │ │ ├── throw.ts │ │ │ ├── try-catch.ts │ │ │ ├── ts-lib-convert.ts │ │ │ ├── ts2asl.out │ │ │ │ ├── closures.asl.json │ │ │ │ ├── closures.iam.json │ │ │ │ ├── hello-world.asl.json │ │ │ │ ├── hello-world.iam.json │ │ │ │ ├── nested-stepfunctions.asl.json │ │ │ │ ├── nested-stepfunctions.iam.json │ │ │ │ ├── parallel.asl.json │ │ │ │ └── parallel.iam.json │ │ │ ├── variable-assignments.ts │ │ │ ├── variables.ts │ │ │ └── while.ts │ │ ├── tests │ │ │ ├── api-gateway.test.ts │ │ │ ├── arrays.test.ts │ │ │ ├── boolean-evalation.test.ts │ │ │ ├── choice.test.ts │ │ │ ├── closures.test.ts │ │ │ ├── conditional-expression.test.ts │ │ │ ├── datetime-now.test.ts │ │ │ ├── do-while.test.ts │ │ │ ├── enums.test.ts │ │ │ ├── expressions.test.ts │ │ │ ├── for-each.test.ts │ │ │ ├── hello-world.test.ts │ │ │ ├── if.test.ts │ │ │ ├── in-keyword.test.ts │ │ │ ├── input-validation.test.ts │ │ │ ├── kyc.test.ts │ │ │ ├── map.test.ts │ │ │ ├── nested-stepfunctions.test.ts │ │ │ ├── null-coalescing.test.ts │ │ │ ├── optional-property-chain.test.ts │ │ │ ├── pagination.test.ts │ │ │ ├── parallel.test.ts │ │ │ ├── sdk-states.test.ts │ │ │ ├── states.test.ts │ │ │ ├── string-templates.test.ts │ │ │ ├── switch.test.ts │ │ │ ├── throw.test.ts │ │ │ ├── try-catch.test.ts │ │ │ ├── ts-lib-convert.test.ts │ │ │ ├── variable-assignments.test.ts │ │ │ ├── variables.test.ts │ │ │ └── while.test.ts │ │ └── utility.ts │ ├── compiler-host │ │ ├── __test__ │ │ │ ├── node.test.ts │ │ │ └── resources │ │ │ │ ├── client-sns.d.ts │ │ │ │ ├── lambda.ts │ │ │ │ └── lib-test.ts │ │ ├── index.ts │ │ ├── node.ts │ │ └── web.ts │ ├── convert-asllib-to-iasl │ │ ├── __test__ │ │ │ ├── binary-expressions.test.ts │ │ │ ├── choice-statement.test.ts │ │ │ ├── ensure-named-properties.test.ts │ │ │ ├── jsonpath.test.ts │ │ │ ├── map-statement.test.ts │ │ │ ├── map.test.ts │ │ │ ├── multiple-assignment-statements.test.ts │ │ │ ├── native-integrations.test.ts │ │ │ ├── parallel-statement.test.ts │ │ │ ├── parameters.test.ts │ │ │ ├── return.test.ts │ │ │ ├── test-convert.ts │ │ │ ├── types.test.ts │ │ │ ├── typescript-if-statement.test.ts │ │ │ ├── typescript-invoke-statement.test.ts │ │ │ ├── typescript-try-statement.test.ts │ │ │ └── typescript-while-statement.test.ts │ │ ├── ast.ts │ │ ├── ensure-named-properties.ts │ │ ├── helper.ts │ │ ├── iaslfactory.ts │ │ ├── index.ts │ │ └── remove-syntax-transformer.ts │ ├── convert-iasl-to-asl │ │ ├── __tests__ │ │ │ ├── asl-map.test.ts │ │ │ ├── binary-expresions.test.ts │ │ │ ├── choice-utility.test.ts │ │ │ ├── early-return.test.ts │ │ │ ├── enclosed-input.test.ts │ │ │ ├── functions.test.ts │ │ │ ├── loops.test.ts │ │ │ ├── parameters.test.ts │ │ │ └── simple-statements.test.ts │ │ ├── asl-writer.ts │ │ ├── aslfactory.binary.ts │ │ ├── aslfactory.choice.ts │ │ ├── aslfactory.fail.ts │ │ ├── aslfactory.foreach.ts │ │ ├── aslfactory.invoke-sm.ts │ │ ├── aslfactory.map.ts │ │ ├── aslfactory.parallel.ts │ │ ├── aslfactory.pass.ts │ │ ├── aslfactory.rhs.ts │ │ ├── aslfactory.succeed.ts │ │ ├── aslfactory.task.ts │ │ ├── aslfactory.try.ts │ │ ├── aslfactory.ts │ │ ├── aslfactory.typeof.ts │ │ ├── aslfactory.while.ts │ │ ├── choice-utility.ts │ │ ├── identifiers.ts │ │ ├── index.ts │ │ ├── jsonpath-filter.ts │ │ ├── parameters.ts │ │ └── scopes.ts │ ├── convert-ts-to-asllib │ │ ├── __tests__ │ │ │ ├── test-transform.ts │ │ │ └── transform.test.ts │ │ ├── index.ts │ │ ├── readme.md │ │ └── transformers │ │ │ ├── __tests__ │ │ │ ├── array-filter-statement.test.ts │ │ │ ├── array-length-statement.test.ts │ │ │ ├── array-map-statement.test.ts │ │ │ ├── call-statement.test.ts │ │ │ ├── console.log.test.ts │ │ │ ├── datetime-stmt.test.ts │ │ │ ├── do-while-statement.test.ts │ │ │ ├── enum-value-transformer.test.ts │ │ │ ├── eval-const.test.ts │ │ │ ├── for-of-statement.test.ts │ │ │ ├── if-statement.test.ts │ │ │ ├── if-throw-statement.test.ts │ │ │ ├── null-coalescing-statement.test.ts │ │ │ ├── promise-all-statement.test.ts │ │ │ ├── remove-unneccesary-expressionts.test.ts │ │ │ ├── resolve-literal-expressions.test.ts │ │ │ ├── string-concat.test.ts │ │ │ ├── string-conversion.test.ts │ │ │ ├── string-template.test.ts │ │ │ ├── switch-statement.test.ts │ │ │ ├── throw-statement.test.ts │ │ │ ├── try-statement.test.ts │ │ │ └── while-statement.test.ts │ │ │ ├── array-filter-statement.ts │ │ │ ├── array-initializer.ts │ │ │ ├── array-length-statement.ts │ │ │ ├── array-map-statement.ts │ │ │ ├── block-utility.ts │ │ │ ├── call-statement.ts │ │ │ ├── datetime-stmt.ts │ │ │ ├── deploy-time-replacements.ts │ │ │ ├── do-while-statement.ts │ │ │ ├── enum-values.ts │ │ │ ├── eval-const.ts │ │ │ ├── for-of-statement.ts │ │ │ ├── if-statement.ts │ │ │ ├── index.ts │ │ │ ├── log-statement.ts │ │ │ ├── node-utility.ts │ │ │ ├── null-coalescing-statement.ts │ │ │ ├── promise-all-statement.ts │ │ │ ├── remove-unneccesary-expressionts.ts │ │ │ ├── resolve-literal-expressions.ts │ │ │ ├── string-conversion.ts │ │ │ ├── string-template.ts │ │ │ ├── switch-statement.ts │ │ │ ├── throw-statement.ts │ │ │ ├── transform-utility.ts │ │ │ ├── try-statement.ts │ │ │ ├── unsupported.ts │ │ │ └── while-statement.ts │ ├── convert │ │ ├── __test__ │ │ │ └── list-function-declaration.test.ts │ │ ├── index.ts │ │ ├── list-function-declarations.ts │ │ └── web.ts │ ├── create-name.ts │ ├── index.ts │ ├── resources │ │ ├── asl-lib.ts │ │ └── client-names.json │ └── util.ts │ └── tsconfig.json ├── readme.md ├── renovate.json ├── test └── cdk-tests │ ├── .gitignore │ ├── .npmignore │ ├── README.md │ ├── bin │ └── cdk-tests.ts │ ├── cdk.json │ ├── jest.config.js │ ├── lib │ ├── cdk-v2-test-stack.ts │ └── local-test-stack.ts │ ├── package.json │ ├── src │ ├── lib │ │ └── lambda.ts │ ├── program.main.json │ ├── program.ts │ └── ts2asl.out │ │ ├── program.asl.json │ │ └── program.iam.json │ ├── tests │ ├── local.integration.ts │ ├── nested-stepfunctions.integration.ts │ └── parallel.integration.ts │ ├── tsconfig.json │ └── utility.ts ├── tools ├── convert-test-generator │ ├── enum-tests.ts │ ├── generate-example.ts │ ├── generate-integration-tests.ts │ ├── generate-unit-tests.ts │ ├── lib │ │ ├── enum-tests.d.ts │ │ ├── enum-tests.js │ │ ├── generate-example.d.ts │ │ ├── generate-example.js │ │ ├── generate-integration-tests.d.ts │ │ ├── generate-integration-tests.js │ │ ├── generate-unit-tests.d.ts │ │ └── generate-unit-tests.js │ ├── package-lock.json │ ├── package.json │ └── tsconfig.json ├── delete-stepfunctions │ ├── delete-all.ts │ ├── package-lock.json │ └── package.json ├── lib-bundler │ └── build │ │ ├── asl-lib.d.ts │ │ └── asl-lib.ts └── sdk-bundler │ ├── bundle-clients.ts │ ├── create-package-json.ts │ ├── npm │ ├── data │ │ ├── aws-sdk-clients.json │ │ ├── client-names.json │ │ └── module-names.json │ └── package.json │ ├── package-lock.json │ ├── package.json │ └── tsconfig.json ├── tsconfig.base.json └── turbo.json /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @stedi/cloud 2 | # Allow bots to modify the files without the need for us to review the PR 3 | .github/workflows/ci.yml 4 | package.json 5 | package-lock.json 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Renovate handles standard updates. This minimal Dependabot config is a security backstop. 2 | version: 2 3 | updates: 4 | - package-ecosystem: npm 5 | directory: / 6 | schedule: 7 | # Security updates ignore this and are opened ad-hoc, but this is still a required option. 8 | interval: daily 9 | # Prevent PRs from opening except for security updates, as per https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/configuring-dependabot-security-updates#overriding-the-default-behavior-with-a-configuration-file 10 | open-pull-requests-limit: 0 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .turbo 3 | packages/asl-lib/build/asl-lib-public.d.ts 4 | packages/asl-lib/build/asl-lib.ts 5 | tools/sdk-bundler/npm/dts/ 6 | tools/sdk-bundler/npm/package-lock.json 7 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | # We have authorized the GitHub application mergify. Read more about it at https://docs.mergify.com/examples/#dependabot. 2 | pull_request_rules: 3 | - name: Auto-approve dependency upgrades 4 | conditions: 5 | - or: 6 | - and: 7 | - author=renovate[bot] 8 | - -label=major-upgrade 9 | - and: 10 | - author=dependabot[bot] 11 | # This regex allows patch and minor version upgrades, but not major upgrades 12 | - title~=bump [^\s]+ from ([\d]+)\..+ to \1\. 13 | actions: 14 | review: 15 | type: APPROVE 16 | message: Automatically approving dependabot 17 | - name: Auto-merge dependency upgrades 18 | conditions: 19 | - or: 20 | - and: 21 | - author=dependabot[bot] 22 | # This regex allows patch and minor version upgrades, but not major upgrades 23 | - title~=bump [^\s]+ from ([\d]+)\..+ to \1\. 24 | - and: 25 | - author=renovate[bot] 26 | - -label=major-upgrade 27 | # Branch protection rules still apply as configured in GitHub 28 | actions: 29 | merge: 30 | method: squash 31 | -------------------------------------------------------------------------------- /cdk-example/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /cdk-example/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | dist -------------------------------------------------------------------------------- /cdk-example/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project 2 | 3 | This is a blank project for CDK development with TypeScript. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | ## Useful commands 8 | 9 | * `npm run build` compile typescript to js 10 | * `npm run watch` watch for changes and compile 11 | * `npm run test` perform the jest unit tests 12 | * `cdk deploy` deploy this stack to your default AWS account/region 13 | * `cdk diff` compare deployed stack with current state 14 | * `cdk synth` emits the synthesized CloudFormation template 15 | -------------------------------------------------------------------------------- /cdk-example/bin/cdk-example.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import 'source-map-support/register'; 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { CdkV2ExampleStack } from '../lib/cdk-example-stack'; 5 | 6 | const app = new cdk.App(); 7 | new CdkV2ExampleStack(app, 'CdkV2ExampleStack', { 8 | /* If you don't specify 'env', this stack will be environment-agnostic. 9 | * Account/Region-dependent features and context lookups will not work, 10 | * but a single synthesized template can be deployed anywhere. */ 11 | 12 | /* Uncomment the next line to specialize this stack for the AWS Account 13 | * and Region that are implied by the current CLI configuration. */ 14 | // env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }, 15 | 16 | /* Uncomment the next line if you know exactly what Account and Region you 17 | * want to deploy the stack to. */ 18 | // env: { account: '123456789012', region: 'us-east-1' }, 19 | 20 | /* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */ 21 | }); -------------------------------------------------------------------------------- /cdk-example/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node --prefer-ts-exts bin/cdk-example.ts", 3 | "watch": { 4 | "include": [ 5 | "**" 6 | ], 7 | "exclude": [ 8 | "README.md", 9 | "cdk*.json", 10 | "**/*.d.ts", 11 | "**/*.js", 12 | "tsconfig.json", 13 | "package*.json", 14 | "yarn.lock", 15 | "node_modules", 16 | "test" 17 | ] 18 | }, 19 | "context": { 20 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, 21 | "@aws-cdk/core:stackRelativeExports": true, 22 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true, 23 | "@aws-cdk/aws-lambda:recognizeVersionProps": true, 24 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, 25 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, 26 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, 27 | "@aws-cdk/core:checkSecretUsage": true, 28 | "@aws-cdk/aws-iam:minimizePolicies": true, 29 | "@aws-cdk/core:target-partitions": [ 30 | "aws", 31 | "aws-cn" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cdk-example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /cdk-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk-example", 3 | "version": "0.1.0", 4 | "bin": { 5 | "cdk-example": "bin/cdk-example.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "engines": { 14 | "npm": ">=8.3.0" 15 | }, 16 | "devDependencies": { 17 | "@types/jest": "28.1.8", 18 | "@types/node": "16.18.57", 19 | "@types/prettier": "2.7.3", 20 | "aws-cdk": "2.93.0", 21 | "jest": "28.1.3", 22 | "ts-jest": "28.0.8", 23 | "ts-node": "10.9.1", 24 | "typescript": "4.7.4" 25 | }, 26 | "dependencies": { 27 | "@ts2asl/asl-lib": "0.1.36", 28 | "@ts2asl/cdk-typescript-statemachine": "0.2.8", 29 | "@ts2asl/convert": "0.1.62", 30 | "aws-cdk-lib": "2.93.0", 31 | "constructs": "10.2.70", 32 | "esbuild": "0.19.4", 33 | "source-map-support": "0.5.21" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cdk-example/src/program.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | 3 | export const main = asl.deploy.asStateMachine(async (input: IInput) => { 4 | if (typeof input.name !== "string") { 5 | input.name = "World"; 6 | } 7 | const rnd = await random(); 8 | return { 9 | greeting: `Hello ${input.name}`, 10 | luckyNumber: rnd 11 | }; 12 | }); 13 | 14 | export const random = asl.deploy.asLambda(async (input: { min?: number; max?: number; } = {}) => { 15 | const min = input.min ?? 0; 16 | const max = input.max ?? 100; 17 | return Math.round(Math.random() * (max - min) + min); 18 | }); 19 | 20 | interface IInput { 21 | name: string; 22 | } 23 | -------------------------------------------------------------------------------- /cdk-example/test/cdk-example.test.ts: -------------------------------------------------------------------------------- 1 | import { main } from "../src/program"; 2 | 3 | describe('when invoking program', () => { 4 | it("returns proper greeting", async () => { 5 | const result = await main({ name: "Fred" }); 6 | expect(result.greeting).toBe("Hello Fred"); 7 | }) 8 | 9 | it("greets world when passed empty document", async () => { 10 | const result = await main({} as any); 11 | expect(result.greeting).toBe("Hello World"); 12 | }) 13 | 14 | it("no lucky number is the same", async () => { 15 | const first = await main({} as any); 16 | const second = await main({} as any); 17 | expect(first.luckyNumber).not.toBe(second.luckyNumber); 18 | }) 19 | }); 20 | -------------------------------------------------------------------------------- /cdk-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "outDir": "./dist", 6 | "lib": [ 7 | "es2018" 8 | ], 9 | "esModuleInterop": true, 10 | "declaration": true, 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "noImplicitThis": true, 15 | "alwaysStrict": true, 16 | "noUnusedLocals": false, 17 | "noUnusedParameters": false, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": false, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "experimentalDecorators": true, 23 | "strictPropertyInitialization": false, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "node_modules", 30 | "cdk.out" 31 | ] 32 | } -------------------------------------------------------------------------------- /examples/api-gateway.md: -------------------------------------------------------------------------------- 1 | 2 | ## main 3 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoKSA9PiB7CiAgY29uc3QgcmVzcG9uc2UgPSBhd2FpdCBhc2wub3B0aW1pemVkLmFwaUdhdGV3YXlJbnZva2UoewogICAgcGFyYW1ldGVyczogewogICAgICBBcGlFbmRwb2ludDogImFhYmJjY2RkZWUuZXhlY3V0ZS1hcGkudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20iLAogICAgICBNZXRob2Q6ICJHRVQiLAogICAgfSwKICB9KTsKCiAgaWYgKHJlc3BvbnNlLlN0YXR1c0NvZGUgPT09IDIwMCkgewogICAgcmV0dXJuICJvayI7CiAgfQoKICByZXR1cm4gIm5vdC1vayI7Cn0pOwo=) 4 | 5 | ``` typescript 6 | export const main = asl.deploy.asStateMachine(async () => { 7 | const response = await asl.optimized.apiGatewayInvoke({ 8 | parameters: { 9 | ApiEndpoint: "aabbccddee.execute-api.us-east-1.amazonaws.com", 10 | Method: "GET", 11 | }, 12 | }); 13 | 14 | if (response.StatusCode === 200) { 15 | return "ok"; 16 | } 17 | 18 | return "not-ok"; 19 | }); 20 | 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/closures.md: -------------------------------------------------------------------------------- 1 | 2 | ## main 3 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoKSA9PiB7CiAgY29uc3QgbnVtYmVycyA9IFswLCAxLCAyLCAzXTsKICBjb25zdCBsZXR0ZXJzID0gWyJhIiwgImIiLCAiYyIsICJkIl07CiAgY29uc3QgZ2xvYmFsID0gInByZWZpeCI7CiAgY29uc3Qgb3V0ZXIgPSB7IG1pZGRsZTogeyBpbm5lcjogMyB9IH07CiAgbnVtYmVycy5tYXAoKG51bWJlcikgPT4gewogICAgbGV0dGVycy5tYXAoKGxldHRlcikgPT4gewogICAgICBjb25zdCBjb21iaW5lZCA9IHsgbnVtYmVyLCBsZXR0ZXIsIGdsb2JhbCwgaW5uZXI6IG91dGVyLm1pZGRsZS5pbm5lciB9OwogICAgICBkb1NvbWV0aGluZyhjb21iaW5lZCk7CiAgICB9KTsKICB9KTsKfSk7Cg==) 4 | 5 | ``` typescript 6 | export const main = asl.deploy.asStateMachine(async () => { 7 | const numbers = [0, 1, 2, 3]; 8 | const letters = ["a", "b", "c", "d"]; 9 | const global = "prefix"; 10 | const outer = { middle: { inner: 3 } }; 11 | numbers.map((number) => { 12 | letters.map((letter) => { 13 | const combined = { number, letter, global, inner: outer.middle.inner }; 14 | doSomething(combined); 15 | }); 16 | }); 17 | }); 18 | 19 | ``` 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/datetime-now.md: -------------------------------------------------------------------------------- 1 | 2 | ## date time now 3 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoKSA9PiB7CiAgcmV0dXJuIGFzbC5qc29uUGF0aCgiJC5TdGF0ZS5TdGFydFRpbWUiKTsKfSk7Cg==) 4 | 5 | ``` typescript 6 | export const main = asl.deploy.asStateMachine(async () => { 7 | return asl.jsonPath("$.State.EnteredTime"); 8 | }); 9 | 10 | ``` 11 | 12 | 13 | ## date time using json path 14 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoKSA9PiB7CiAgcmV0dXJuIG5ldyBEYXRlKCkudG9JU09TdHJpbmcoKTsKfSk7Cg==) 15 | 16 | ``` typescript 17 | export const main = asl.deploy.asStateMachine(async () => { 18 | return new Date().toISOString(); 19 | }); 20 | 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/hello-world.md: -------------------------------------------------------------------------------- 1 | 2 | ## main 3 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoaW5wdXQ6IElJbnB1dCkgPT4gewogIGlmICh0eXBlb2YgaW5wdXQubmFtZSAhPT0gInN0cmluZyIpIHsKICAgIGlucHV0Lm5hbWUgPSAiV29ybGQiOwogIH0KICBjb25zdCBybmQgPSBhd2FpdCByYW5kb20oKTsKICByZXR1cm4gewogICAgZ3JlZXRpbmc6IGBIZWxsbyAke2lucHV0Lm5hbWV9YCwKICAgIGx1Y2t5TnVtYmVyOiBybmQsCiAgfTsKfSk7CgppbnRlcmZhY2UgSUlucHV0IHsKICBuYW1lOiBzdHJpbmc7Cn0K) 4 | 5 | ``` typescript 6 | export const main = asl.deploy.asStateMachine(async (input: IInput) => { 7 | if (typeof input.name !== "string") { 8 | input.name = "World"; 9 | } 10 | const rnd = await random(); 11 | return { 12 | greeting: `Hello ${input.name}`, 13 | luckyNumber: rnd, 14 | }; 15 | }); 16 | 17 | interface IInput { 18 | name: string; 19 | } 20 | 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/in-keyword.md: -------------------------------------------------------------------------------- 1 | 2 | ## if statement with in keyword 3 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoKSA9PiB7CiAgbGV0IHZhbCA9IHsgZ3JlZXRpbmc6ICJoZWxsbyIgfTsKICBpZiAoImdyZWV0aW5nIiBpbiB2YWwgJiYgISgic29tZXRoaW5nRWxzZSIgaW4gdmFsKSkgewogICAgcmV0dXJuICJzdWNjZXNzIjsKICB9CiAgcmV0dXJuICJmYWlsdXJlIjsKfSk7Cg==) 4 | 5 | ``` typescript 6 | export const main = asl.deploy.asStateMachine(async () => { 7 | let val = { greeting: "hello" }; 8 | if ("greeting" in val && !("somethingElse" in val)) { 9 | return "success"; 10 | } 11 | return "failure"; 12 | }); 13 | 14 | ``` 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/parallel.md: -------------------------------------------------------------------------------- 1 | 2 | ## simple 3 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoaW5wdXQ6IHt9KSA9PiB7CiAgcmV0dXJuIGF3YWl0IFByb21pc2UuYWxsKFt3b3JrZXIoKSwgd29ya2VyKCldKTsKfSk7Cg==) 4 | 5 | ``` typescript 6 | export const main = asl.deploy.asStateMachine(async (input: {}) => { 7 | return await Promise.all([worker(), worker()]); 8 | }); 9 | 10 | ``` 11 | 12 | 13 | ## enclosed variables 14 | [Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoaW5wdXQ6IHt9KSA9PiB7CiAgY29uc3QgZW5jbG9zZWRWYXIxID0geyBzb21ldGhpbmc6ICJsZWZ0IiB9OwogIGNvbnN0IGVuY2xvc2VkVmFyMiA9IHsgc29tZXRoaW5nOiAicmlnaHQiIH07CiAgcmV0dXJuIGF3YWl0IFByb21pc2UuYWxsKFt3b3JrZXIoZW5jbG9zZWRWYXIxKSwgd29ya2VyKGVuY2xvc2VkVmFyMildKTsKfSk7Cg==) 15 | 16 | ``` typescript 17 | export const main = asl.deploy.asStateMachine(async (input: {}) => { 18 | const enclosedVar1 = { something: "left" }; 19 | const enclosedVar2 = { something: "right" }; 20 | return await Promise.all([worker(enclosedVar1), worker(enclosedVar2)]); 21 | }); 22 | 23 | ``` 24 | 25 | 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts2asl", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "web.js", 6 | "workspaces": [ 7 | "packages/*", 8 | "test/*" 9 | ], 10 | "author": "", 11 | "license": "ISC", 12 | "engines": { 13 | "npm": ">=8.3.0" 14 | }, 15 | "devDependencies": { 16 | "@types/jest": "28.1.8", 17 | "ts-node": "10.9.1", 18 | "turbo": "1.10.15", 19 | "typescript": "4.7.4" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/asl-lib/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib -------------------------------------------------------------------------------- /packages/asl-lib/build/wrapdts.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync, writeFileSync } from "fs"; 2 | 3 | if (process.argv[2]) { 4 | const inFile = process.argv[2]; 5 | let contents = readFileSync(process.argv[2], "utf-8"); 6 | const outFile = inFile.replace("d.ts", "ts") 7 | contents = `export const libraryDefinitionAsString = \`${contents}\``; 8 | writeFileSync(outFile, contents); 9 | } -------------------------------------------------------------------------------- /packages/asl-lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ts2asl/asl-lib", 3 | "version": "0.1.36", 4 | "description": "", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "scripts": { 8 | "test": "npx jest --passWithNoTests", 9 | "prepublishOnly": "npm run build", 10 | "bundle-dts": "npx dts-bundle --name @ts2asl/asl-lib --main ./lib/index.d.ts --out ../build/asl-lib-public.d.ts && cat build/asl-lib-private.d.ts build/asl-lib-public.d.ts > build/asl-lib.d.ts && ts-node build/wrapdts build/asl-lib.d.ts", 11 | "build": "npx tsc && npm run bundle-dts && cp ./build/asl-lib.ts ../convert/src/resources/", 12 | "package": "ts-node build/wrapdts build/asl-lib-public.d.ts && cp ./build/asl-lib-public.ts ../../../asl-editor-spike/src/ && cp ../../tools/asl-lib-generator/npm/dts/@aws-sdk/* ../../../asl-editor-spike/public/sdk-clients && cp ../../tools/asl-lib-generator/npm/data/client-names.json ../convert/src/resources" 13 | }, 14 | "files": [ 15 | "lib/**/*" 16 | ], 17 | "author": "", 18 | "license": "ISC", 19 | "devDependencies": { 20 | "@types/jest": "28.1.8", 21 | "@types/mocha": "10.0.2", 22 | "jest": "28.1.3", 23 | "ts-jest": "28.0.8", 24 | "typescript": "4.7.4" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/asl-lib/src/asl-internals.ts: -------------------------------------------------------------------------------- 1 | 2 | export const internalWaitSeconds = async (seconds: number): Promise => { 3 | return new Promise((resolve: Function) => { 4 | setTimeout(resolve, seconds * 1000); 5 | }); 6 | } 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/asl-lib/src/deploy.ts: -------------------------------------------------------------------------------- 1 | export namespace deploy { 2 | const explicitlySetParameters: Record = {}; 3 | export const asStateMachine = (fn: T): T => { return fn; } 4 | export const asLambda = (fn: T): T => { return fn; } 5 | export const getParameter = (parameterName: string): string => { 6 | if (explicitlySetParameters[parameterName] !== undefined) { 7 | return explicitlySetParameters[parameterName]; 8 | } 9 | return `[!parameter[${parameterName}]]`; 10 | } 11 | export const setParameter = (parameterName: string, value: string): void => { 12 | explicitlySetParameters[parameterName] = value; 13 | } 14 | export const getLambdaName = (functionName: string | Function): string => { 15 | return `[!lambda[${functionName}]name]`; 16 | } 17 | export const getLambdaArn = (functionName: string | Function): string => { 18 | return `[!lambda[${functionName}]arn]`; 19 | } 20 | export const getStateMachineName = (functionName: string | Function): string => { 21 | return `[!state-machine[${functionName}]name]`; 22 | } 23 | export const getStateMachineArn = (functionName: string | Function): string => { 24 | return `[!state-machine[${functionName}]arn]`; 25 | } 26 | export const evalConst = (identifier: T): T => { 27 | return identifier; 28 | } 29 | } -------------------------------------------------------------------------------- /packages/asl-lib/src/index.ts: -------------------------------------------------------------------------------- 1 | export type ClientConfig = {region: string}; 2 | export * from "./asl"; 3 | export * from "./sdk"; 4 | export * from "./deploy" 5 | export * from "./runtime" 6 | export * from "./optimized" 7 | export * from "./testing" 8 | 9 | export const clientConfig = {} as ClientConfig; 10 | -------------------------------------------------------------------------------- /packages/asl-lib/src/runtime.ts: -------------------------------------------------------------------------------- 1 | import { AslError } from "./asl"; 2 | 3 | class ThrowableAslError extends Error { 4 | name: string; 5 | Cause: string; 6 | Error: string; 7 | constructor(error: string, cause: string) { 8 | super(cause); 9 | this.name = error; 10 | this.Cause = cause; 11 | this.Error = error; 12 | } 13 | } 14 | 15 | export namespace runtime { 16 | export const createError = (error: string, cause: string): AslError & Error & { name: string; } => { 17 | return new ThrowableAslError(error, cause); 18 | }; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /packages/asl-lib/src/sdk.ts: -------------------------------------------------------------------------------- 1 | import { clientConfig } from '.'; 2 | import { CatchConfiguration, RetryConfiguration } from './asl'; 3 | 4 | type ClassType = { 5 | prototype: T; 6 | }; 7 | 8 | type SdkIntegration = { 9 | parameters: T; 10 | name?: string; 11 | catch?: CatchConfiguration; 12 | retry?: RetryConfiguration; 13 | timeoutSeconds?: number; 14 | heartbeatSeconds?: number; 15 | } 16 | 17 | type SdkIntegrationClient = { 18 | [K in keyof T]: T[K] extends (input: infer Input, options: any, cb: (err: any, data?: infer TOutput) => void) => Promise ? (input: SdkIntegration/*, options?: HttpHandlerOptions | undefined*/) => Promise : never; 19 | }; 20 | export const sdk = ( 21 | client: ClassType & {new(config:{}): TClient}, 22 | ): SdkIntegrationClient => { 23 | const sdkClient: any = new client({...clientConfig}); 24 | return new Proxy(sdkClient, { 25 | get: function (target: TClient, name: string) { 26 | return (input: SdkIntegration<{}>, options?: any) => { 27 | const originalFunction = (target as any as Record)[name]; 28 | return originalFunction.apply(sdkClient, [input.parameters, options]); 29 | }; 30 | } 31 | }) as unknown as SdkIntegrationClient; 32 | } 33 | -------------------------------------------------------------------------------- /packages/asl-lib/src/testing.ts: -------------------------------------------------------------------------------- 1 | import { StateMachineContext } from "./asl"; 2 | 3 | export namespace testing { 4 | export const createTestContext = (input: TInput, context: Partial> = {}): StateMachineContext => { 5 | return { 6 | ...context, 7 | stateMachine: { 8 | id: "", 9 | name: "", 10 | ...("stateMachine" in context ? context.stateMachine : {}), 11 | }, 12 | execution: { 13 | id: "", 14 | name: "", 15 | roleArn: "", 16 | startTime: new Date().toISOString(), 17 | ...("execution" in context ? context.stateMachine : {}), 18 | input: input 19 | }, 20 | task: { 21 | name: "", 22 | token: "", 23 | }, 24 | state: { 25 | name: "", 26 | enteredTime: new Date().toISOString(), 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /packages/asl-lib/src/types/choice.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Fail} from "./fail"; 8 | import {Parallel} from "./parallel"; 9 | import {Pass} from "./pass"; 10 | import {Succeed} from "./succeed"; 11 | import {Task} from "./task"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | export interface Choice { 16 | Type: string; 17 | Next?: string; 18 | End?: true; 19 | Comment?: string; 20 | OutputPath?: string | null; 21 | InputPath?: string | null; 22 | Choices: Operator[]; 23 | Default?: string; 24 | } 25 | export interface Operator { 26 | Variable?: string; 27 | Next?: string; 28 | And?: Operator[]; 29 | Or?: Operator[]; 30 | Not?: Operator; 31 | BooleanEquals?: boolean; 32 | NumericEquals?: number; 33 | NumericGreaterThan?: number; 34 | NumericGreaterThanEquals?: number; 35 | NumericLessThan?: number; 36 | NumericLessThanEquals?: number; 37 | StringEquals?: string; 38 | StringGreaterThan?: string; 39 | StringGreaterThanEquals?: string; 40 | StringLessThan?: string; 41 | StringLessThanEquals?: string; 42 | TimestampEquals?: string; 43 | TimestampGreaterThan?: string; 44 | TimestampGreaterThanEquals?: string; 45 | TimestampLessThan?: string; 46 | TimestampLessThanEquals?: string; 47 | [k: string]: any; 48 | } 49 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/fail.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Choice} from "./choice"; 8 | import {Parallel} from "./parallel"; 9 | import {Pass} from "./pass"; 10 | import {Succeed} from "./succeed"; 11 | import {Task} from "./task"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | export interface Fail { 16 | Type: string; 17 | Comment?: string; 18 | OutputPath?: string | null; 19 | InputPath?: string | null; 20 | Cause?: string; 21 | Error?: string; 22 | } 23 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export type { StateMachine } from './state-machine'; 2 | export type { State } from './state'; 3 | export type { Choice } from './choice'; 4 | export type { Fail } from './fail'; 5 | export type { Parallel } from './parallel'; 6 | export type { Pass } from './pass'; 7 | export type { Succeed } from './succeed'; 8 | export type { Task } from './task'; 9 | export type { Wait } from './wait'; 10 | export type { Map } from './map'; 11 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/map.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Choice} from "./choice"; 8 | import {Fail} from "./fail"; 9 | import {Parallel} from "./parallel"; 10 | import {Pass} from "./pass"; 11 | import {Succeed} from "./succeed"; 12 | import {Task} from "./task"; 13 | import {Wait} from "./wait"; 14 | 15 | export interface Map { 16 | Type: string; 17 | Next?: string; 18 | End?: true; 19 | Comment?: string; 20 | OutputPath?: string | null; 21 | InputPath?: string | null; 22 | ResultPath?: string | null; 23 | ItemsPath?: string | null; 24 | MaxConcurrency?: number; 25 | Iterator: StateMachine; 26 | Parameters?: { 27 | [k: string]: any; 28 | }; 29 | Retry?: { 30 | ErrorEquals: string[]; 31 | IntervalSeconds?: number; 32 | MaxAttempts?: number; 33 | BackoffRate?: number; 34 | [k: string]: any; 35 | }[]; 36 | Catch?: { 37 | ErrorEquals: string[]; 38 | Next: string; 39 | [k: string]: any; 40 | }[]; 41 | } 42 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/parallel.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Choice} from "./choice"; 8 | import {Fail} from "./fail"; 9 | import {Pass} from "./pass"; 10 | import {Succeed} from "./succeed"; 11 | import {Task} from "./task"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | export interface Parallel { 16 | Type: string; 17 | Next?: string; 18 | End?: true; 19 | Comment?: string; 20 | OutputPath?: string | null; 21 | InputPath?: string | null; 22 | ResultPath?: string | null; 23 | Branches: StateMachine[]; 24 | Retry?: { 25 | ErrorEquals: string[]; 26 | IntervalSeconds?: number; 27 | MaxAttempts?: number; 28 | BackoffRate?: number; 29 | [k: string]: any; 30 | }[]; 31 | Catch?: { 32 | ErrorEquals: string[]; 33 | Next: string; 34 | [k: string]: any; 35 | }[]; 36 | } 37 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/pass.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Choice} from "./choice"; 8 | import {Fail} from "./fail"; 9 | import {Parallel} from "./parallel"; 10 | import {Succeed} from "./succeed"; 11 | import {Task} from "./task"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | export interface Pass { 16 | Type: string; 17 | Next?: string; 18 | End?: true; 19 | Comment?: string; 20 | OutputPath?: string | null; 21 | InputPath?: string | null; 22 | ResultPath?: string; 23 | Parameters?: { 24 | [k: string]: any; 25 | }; 26 | Result?: any; 27 | } 28 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/state-machine.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {State} from "./state"; 6 | import {Choice} from "./choice"; 7 | import {Fail} from "./fail"; 8 | import {Parallel} from "./parallel"; 9 | import {Pass} from "./pass"; 10 | import {Succeed} from "./succeed"; 11 | import {Task} from "./task"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | /** 16 | * This interface was referenced by `undefined`'s JSON-Schema definition 17 | * via the `patternProperty` "^.{1,128}$". 18 | */ 19 | export interface StateMachine { 20 | Comment?: string; 21 | StartAt: string; 22 | States: { 23 | [k: string]: State; 24 | }; 25 | Version?: string; 26 | TimeoutSeconds?: number; 27 | } 28 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/state.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {Choice} from "./choice"; 7 | import {Fail} from "./fail"; 8 | import {Parallel} from "./parallel"; 9 | import {Pass} from "./pass"; 10 | import {Succeed} from "./succeed"; 11 | import {Task} from "./task"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | export type State = Choice | Fail | Parallel | Pass | Succeed | Task | Wait | Map; 16 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/succeed.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Choice} from "./choice"; 8 | import {Fail} from "./fail"; 9 | import {Parallel} from "./parallel"; 10 | import {Pass} from "./pass"; 11 | import {Task} from "./task"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | export interface Succeed { 16 | Type: string; 17 | Comment?: string; 18 | } 19 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/task.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Choice} from "./choice"; 8 | import {Fail} from "./fail"; 9 | import {Parallel} from "./parallel"; 10 | import {Pass} from "./pass"; 11 | import {Succeed} from "./succeed"; 12 | import {Wait} from "./wait"; 13 | import {Map} from "./map"; 14 | 15 | export interface Task { 16 | Type: string; 17 | Next?: string; 18 | End?: true; 19 | Comment?: string; 20 | OutputPath?: string | null; 21 | InputPath?: string | null; 22 | Resource: 23 | | string 24 | | { 25 | [k: string]: any; 26 | }; 27 | ResultPath?: string | null; 28 | Retry?: { 29 | ErrorEquals: string[]; 30 | IntervalSeconds?: number; 31 | MaxAttempts?: number; 32 | BackoffRate?: number; 33 | [k: string]: any; 34 | }[]; 35 | Catch?: { 36 | ErrorEquals: string[]; 37 | Next: string; 38 | [k: string]: any; 39 | }[]; 40 | TimeoutSeconds?: number; 41 | HeartbeatSeconds?: number; 42 | Parameters?: { 43 | [k: string]: any; 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /packages/asl-lib/src/types/wait.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /** 3 | * This file was automatically generated */ 4 | 5 | import {StateMachine} from "./state-machine"; 6 | import {State} from "./state"; 7 | import {Choice} from "./choice"; 8 | import {Fail} from "./fail"; 9 | import {Parallel} from "./parallel"; 10 | import {Pass} from "./pass"; 11 | import {Succeed} from "./succeed"; 12 | import {Task} from "./task"; 13 | import {Map} from "./map"; 14 | 15 | export interface Wait { 16 | Type: string; 17 | Next?: string; 18 | End?: true; 19 | Comment?: string; 20 | OutputPath?: string | null; 21 | InputPath?: string | null; 22 | Seconds?: number; 23 | Timestamp?: string; 24 | SecondsPath?: string | null; 25 | TimestampPath?: string | null; 26 | } 27 | -------------------------------------------------------------------------------- /packages/asl-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "noImplicitAny": true, 6 | "declaration": true, 7 | "esModuleInterop": true, 8 | "outDir": "./lib", 9 | "strict": true, 10 | "skipLibCheck": true 11 | }, 12 | "include": [ 13 | "src", 14 | "build/asl-lib-private.ts" 15 | ], 16 | "exclude": [ 17 | "lib", 18 | "**/__tests__/*" 19 | ] 20 | } -------------------------------------------------------------------------------- /packages/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | !iamfast/asl.js 4 | *.d.ts 5 | node_modules 6 | lib 7 | 8 | # CDK asset staging directory 9 | .cdk.staging 10 | cdk.out 11 | -------------------------------------------------------------------------------- /packages/cdk/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | iamfast 4 | !lib/iamfast 5 | # CDK asset staging directory 6 | .cdk.staging 7 | cdk.out 8 | -------------------------------------------------------------------------------- /packages/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript Construct Library project 2 | 3 | You should explore the contents of this project. It demonstrates a CDK Construct Library that includes a construct (`Cdk`) 4 | which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic. 5 | 6 | The construct defines an interface (`CdkProps`) to configure the visibility timeout of the queue. 7 | 8 | ## Useful commands 9 | 10 | * `npm run build` compile typescript to js 11 | * `npm run watch` watch for changes and compile 12 | * `npm run test` perform the jest unit tests 13 | -------------------------------------------------------------------------------- /packages/cdk/iamfast/resolve-permissions.ts: -------------------------------------------------------------------------------- 1 | import { Construct } from "constructs/lib/construct"; 2 | import * as cdk from "aws-cdk-lib"; 3 | const { ResolvePermissions } = require("./asl.js"); 4 | 5 | interface PolicyDocument { 6 | Version: "2012-10-17" | string; 7 | Statement: Array<{ 8 | Effect: "Allow" | "Deny" 9 | Action: string | string[]; 10 | Resource: string | string[]; 11 | } & Record> 12 | } 13 | 14 | export const resolvePermissionsIamFast = (parent: Construct, aslDefinitionAsString: string, postProcess : (input: string) => string): PolicyDocument => { 15 | const policyDoc = ResolvePermissions(cdk.Stack.of(parent).account, cdk.Stack.of(parent).region, aslDefinitionAsString) as string; 16 | const postProcessedDoc = postProcess(policyDoc); 17 | return JSON.parse(postProcessedDoc); 18 | } 19 | -------------------------------------------------------------------------------- /packages/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | roots: ['/test'], 3 | testMatch: ['**/*.test.ts'], 4 | transform: { 5 | '^.+\\.tsx?$': 'ts-jest' 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /packages/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ts2asl/cdk-typescript-statemachine", 3 | "version": "0.2.8", 4 | "main": "lib/index.js", 5 | "types": "lib/index.d.ts", 6 | "scripts": { 7 | "build": "tsc", 8 | "watch": "tsc -w" 9 | }, 10 | "devDependencies": { 11 | "@types/jest": "28.1.8", 12 | "@types/node": "18.18.3", 13 | "@types/prettier": "2.7.3", 14 | "aws-cdk-lib": "2.93.0", 15 | "constructs": "10.2.70", 16 | "jest": "28.1.3", 17 | "ts-jest": "28.0.8", 18 | "typescript": "4.7.4" 19 | }, 20 | "peerDependencies": { 21 | "aws-cdk-lib": "^2.31.2", 22 | "constructs": "^10.0.0" 23 | }, 24 | "dependencies": { 25 | "@ts2asl/asl-lib": "^0.1.36", 26 | "@ts2asl/convert": "^0.1.62" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "ES2018", 5 | "module": "commonjs", 6 | "lib": [ 7 | "es2018" 8 | ], 9 | "outDir": "./lib", 10 | "allowJs": true, 11 | "esModuleInterop": true, 12 | "declaration": true, 13 | "strict": true, 14 | "noImplicitAny": true, 15 | "strictNullChecks": true, 16 | "noImplicitThis": true, 17 | "alwaysStrict": true, 18 | "noUnusedLocals": false, 19 | "noUnusedParameters": false, 20 | "noImplicitReturns": true, 21 | "noFallthroughCasesInSwitch": false, 22 | "inlineSourceMap": true, 23 | "inlineSources": true, 24 | "experimentalDecorators": true, 25 | "strictPropertyInitialization": false, 26 | "typeRoots": [ 27 | "./node_modules/@types" 28 | ] 29 | }, 30 | "exclude": [ 31 | "jest.config.js", 32 | "node_modules", 33 | "lib", 34 | "cdk.out" 35 | ] 36 | } -------------------------------------------------------------------------------- /packages/cli/.circleci/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2.1 3 | 4 | orbs: 5 | release-management: salesforce/npm-release-management@4.38.0 6 | 7 | workflows: 8 | version: 2 9 | test-and-release: 10 | jobs: 11 | - release-management/test-package: 12 | matrix: 13 | parameters: 14 | os: 15 | - linux 16 | - windows 17 | node_version: 18 | - latest 19 | - lts 20 | - maintenance 21 | dependabot-automerge: 22 | triggers: 23 | - schedule: 24 | cron: '0 2,5,8,11 * * *' 25 | filters: 26 | branches: 27 | only: 28 | - main 29 | jobs: 30 | - release-management/dependabot-automerge 31 | -------------------------------------------------------------------------------- /packages/cli/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /packages/cli/.eslintignore: -------------------------------------------------------------------------------- 1 | /dist 2 | -------------------------------------------------------------------------------- /packages/cli/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "oclif", 4 | "oclif-typescript" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /packages/cli/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "npm" 4 | versioning-strategy: increase 5 | directory: "/" 6 | schedule: 7 | interval: "monthly" 8 | labels: 9 | - "dependencies" 10 | open-pull-requests-limit: 100 11 | pull-request-branch-name: 12 | separator: "-" 13 | ignore: 14 | - dependency-name: "fs-extra" 15 | - dependency-name: "*" 16 | update-types: ["version-update:semver-major"] 17 | -------------------------------------------------------------------------------- /packages/cli/.gitignore: -------------------------------------------------------------------------------- 1 | *-debug.log 2 | *-error.log 3 | /.nyc_output 4 | /dist 5 | /lib 6 | /package-lock.json 7 | /tmp 8 | /yarn.lock 9 | node_modules 10 | oclif.manifest.json 11 | -------------------------------------------------------------------------------- /packages/cli/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/helpers/init.js", 4 | "ts-node/register" 5 | ], 6 | "watch-extensions": [ 7 | "ts" 8 | ], 9 | "recursive": true, 10 | "reporter": "spec", 11 | "timeout": 60000 12 | } 13 | -------------------------------------------------------------------------------- /packages/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Salesforce 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/cli/bin/dev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const oclif = require('@oclif/core') 4 | 5 | const path = require('path') 6 | const project = path.join(__dirname, '..', 'tsconfig.json') 7 | 8 | // In dev mode -> use ts-node and dev plugins 9 | process.env.NODE_ENV = 'development' 10 | 11 | require('ts-node').register({project}) 12 | 13 | // In dev mode, always show stack traces 14 | oclif.settings.debug = true; 15 | 16 | // Start the CLI 17 | oclif.run().then(oclif.flush).catch(oclif.Errors.handle) 18 | -------------------------------------------------------------------------------- /packages/cli/bin/dev.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | node "%~dp0\dev" %* -------------------------------------------------------------------------------- /packages/cli/bin/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const oclif = require('@oclif/core') 4 | 5 | oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle')) 6 | -------------------------------------------------------------------------------- /packages/cli/bin/run.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | node "%~dp0\run" %* 4 | -------------------------------------------------------------------------------- /packages/cli/src/index.ts: -------------------------------------------------------------------------------- 1 | export {run} from '@oclif/core' 2 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "declaration": true, 5 | "importHelpers": true, 6 | "module": "commonjs", 7 | "outDir": "dist", 8 | "rootDir": "src", 9 | "strict": true, 10 | "skipLibCheck": true, 11 | "target": "es2019" 12 | }, 13 | "include": [ 14 | "src/**/*" 15 | ] 16 | } -------------------------------------------------------------------------------- /packages/convert/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib 3 | ts2asl-convert-* -------------------------------------------------------------------------------- /packages/convert/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ 2 | module.exports = { 3 | preset: 'ts-jest', 4 | passWithNoTests: true, 5 | testMatch: ["**/*.test.ts"], 6 | // setupFiles: ["/test/setupTests.ts"], 7 | }; -------------------------------------------------------------------------------- /packages/convert/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ts2asl/convert", 3 | "version": "0.1.62", 4 | "description": "", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "scripts": { 8 | "test": "npx jest", 9 | "build": "npx tsc", 10 | "prepublishOnly": "npm run build", 11 | "package": "npx esbuild ./src/convert/web.ts --outdir=../../../asl-editor-spike/lib/ --format=esm --bundle --target=chrome58", 12 | "test:e2e": "npx jest --config ./jest.config.e2e.js" 13 | }, 14 | "files": [ 15 | "lib/**/*" 16 | ], 17 | "author": "", 18 | "license": "ISC", 19 | "dependencies": { 20 | "@ts2asl/asl-lib": "^0.1.36", 21 | "typescript": "^4.7.4" 22 | }, 23 | "devDependencies": { 24 | "@aws-sdk/client-dynamodb": "3.425.0", 25 | "@aws-sdk/client-eventbridge": "3.425.0", 26 | "@aws-sdk/client-iam": "3.425.0", 27 | "@aws-sdk/client-organizations": "3.425.0", 28 | "@aws-sdk/client-sfn": "3.425.0", 29 | "@aws-sdk/client-sns": "3.425.0", 30 | "@types/jest": "28.1.8", 31 | "@types/mocha": "10.0.2", 32 | "@types/node": "18.18.3", 33 | "jest": "28.1.3", 34 | "node-fetch": "3.3.2", 35 | "ts-jest": "28.0.8" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/convert/src/ParserError.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | 3 | export class ParserError extends Error { 4 | constructor(message: string, node: ts.Node) { 5 | 6 | let nodeText = "??" 7 | try { 8 | nodeText = node.getText(); 9 | } catch { 10 | 11 | } 12 | 13 | const context = node ? ` 14 | Kind: ${ts.SyntaxKind[node.kind]} 15 | Source: ${nodeText} 16 | ` : `Node: undefined`; 17 | 18 | super(message + "\n" + context) 19 | } 20 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/api-gateway.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { main } = require("../resources/api-gateway"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting api-gateway", () => { 7 | it("will execute main as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("api-gateway", "main"); 9 | const resultFromNode = await main({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/boolean-evalation.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { main, numericComparison } = require("../resources/boolean-evalation"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting boolean-evalation", () => { 7 | it("will execute main as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("boolean-evalation", "main"); 9 | const resultFromNode = await main({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute numericComparison as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("boolean-evalation", "numericComparison"); 14 | const resultFromNode = await numericComparison({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/choice.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { choice, choiceWithSingleStatements, choiceWithShorthand } = require("../resources/choice"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting choice", () => { 7 | it("will execute choice as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("choice", "choice"); 9 | const resultFromNode = await choice({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute choiceWithSingleStatements as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("choice", "choiceWithSingleStatements"); 14 | const resultFromNode = await choiceWithSingleStatements({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | it("will execute choiceWithShorthand as if it were node", async () => { 18 | const resultFromSfn = await convertDeployExecute("choice", "choiceWithShorthand"); 19 | const resultFromNode = await choiceWithShorthand({}, asl.testing.createTestContext({})); 20 | expect(resultFromSfn).toEqual(resultFromNode); 21 | }); 22 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/closures.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { main } = require("../resources/closures"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting closures", () => { 7 | it("will execute main as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("closures", "main"); 9 | const resultFromNode = await main({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/datetime-now.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { dateTimeNow, dateTimeUsingJsonPath } = require("../resources/datetime-now"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting datetime-now", () => { 7 | it("will execute dateTimeNow as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("datetime-now", "dateTimeNow"); 9 | const resultFromNode = await dateTimeNow({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute dateTimeUsingJsonPath as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("datetime-now", "dateTimeUsingJsonPath"); 14 | const resultFromNode = await dateTimeUsingJsonPath({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/enums.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { compareEnum, compareStringEnum } = require("../resources/enums"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting enums", () => { 7 | it("will execute compareEnum as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("enums", "compareEnum"); 9 | const resultFromNode = await compareEnum({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute compareStringEnum as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("enums", "compareStringEnum"); 14 | const resultFromNode = await compareStringEnum({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/hello-world.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { main } = require("../resources/hello-world"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting hello-world", () => { 7 | it("will execute main as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("hello-world", "main"); 9 | const resultFromNode = await main({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/in-keyword.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { IfStatementWithInKeyword } = require("../resources/in-keyword"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting in-keyword", () => { 7 | it("will execute IfStatementWithInKeyword as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("in-keyword", "IfStatementWithInKeyword"); 9 | const resultFromNode = await IfStatementWithInKeyword({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/kyc.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { main } = require("../resources/kyc"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting kyc", () => { 7 | it("will execute main as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("kyc", "main"); 9 | const resultFromNode = await main({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/map.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { main } = require("../resources/map"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting map", () => { 7 | it("will execute main as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("map", "main"); 9 | const resultFromNode = await main({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/pagination.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { listUsers, doSomething } = require("../resources/pagination"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting pagination", () => { 7 | it("will execute listUsers as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("pagination", "listUsers"); 9 | const resultFromNode = await listUsers({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute doSomething as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("pagination", "doSomething"); 14 | const resultFromNode = await doSomething({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/parallel.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { simple, enclosedVariables } = require("../resources/parallel"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting parallel", () => { 7 | it("will execute simple as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("parallel", "simple"); 9 | const resultFromNode = await simple({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute enclosedVariables as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("parallel", "enclosedVariables"); 14 | const resultFromNode = await enclosedVariables({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/states.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { waitForTaskToken } = require("../resources/states"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting states", () => { 7 | it("will execute waitForTaskToken as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("states", "waitForTaskToken"); 9 | const resultFromNode = await waitForTaskToken({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/string-templates.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { stringTemplates, escapedCharacters } = require("../resources/string-templates"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting string-templates", () => { 7 | it("will execute stringTemplates as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("string-templates", "stringTemplates"); 9 | const resultFromNode = await stringTemplates({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute escapedCharacters as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("string-templates", "escapedCharacters"); 14 | const resultFromNode = await escapedCharacters({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/ts-lib-convert.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { convertStringToNumber, convertStringToBoolean } = require("../resources/ts-lib-convert"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting ts-lib-convert", () => { 7 | it("will execute convertStringToNumber as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("ts-lib-convert", "convertStringToNumber"); 9 | const resultFromNode = await convertStringToNumber({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | it("will execute convertStringToBoolean as if it were node", async () => { 13 | const resultFromSfn = await convertDeployExecute("ts-lib-convert", "convertStringToBoolean"); 14 | const resultFromNode = await convertStringToBoolean({}, asl.testing.createTestContext({})); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/integration-tests/variables.integration.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | import { convertDeployExecute } from "../utility"; 3 | const { main } = require("../resources/variables"); 4 | jest.setTimeout(99999999); 5 | 6 | describe("when converting variables", () => { 7 | it("will execute main as if it were node", async () => { 8 | const resultFromSfn = await convertDeployExecute("variables", "main"); 9 | const resultFromNode = await main({}, asl.testing.createTestContext({})); 10 | expect(resultFromSfn).toEqual(resultFromNode); 11 | }); 12 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/api-gateway-main.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign response" 13 | }, 14 | "Assign response": { 15 | "Type": "Task", 16 | "ResultPath": "$.vars.response", 17 | "Resource": "arn:aws:states:::apigateway:invoke", 18 | "Parameters": { 19 | "ApiEndpoint": "aabbccddee.execute-api.us-east-1.amazonaws.com", 20 | "Method": "GET" 21 | }, 22 | "Next": "If (response.StatusCode = ..." 23 | }, 24 | "If (response.StatusCode = ...": { 25 | "Type": "Choice", 26 | "Choices": [ 27 | { 28 | "Variable": "$.vars.response.StatusCode", 29 | "NumericEquals": 200, 30 | "Next": "Return \"ok\"" 31 | } 32 | ], 33 | "Comment": "source: if (response.StatusCode === 200) { return \"ok\" }", 34 | "Default": "Return \"not-ok\"" 35 | }, 36 | "Return \"ok\"": { 37 | "Type": "Pass", 38 | "Result": "ok", 39 | "End": true 40 | }, 41 | "Return \"not-ok\"": { 42 | "Type": "Pass", 43 | "Result": "not-ok", 44 | "End": true 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/conditional-expression-conditionalWithLiteral.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Eval Conditional" 13 | }, 14 | "Eval Conditional": { 15 | "Type": "Choice", 16 | "Choices": [ 17 | { 18 | "Variable": "$", 19 | "IsNull": true, 20 | "Next": "Conditional True" 21 | } 22 | ], 23 | "Default": "Conditional False" 24 | }, 25 | "Conditional True": { 26 | "Type": "Pass", 27 | "Result": "jim", 28 | "ResultPath": "$.tmp.var", 29 | "Next": "Return false ? \"jim\" : \"j ..." 30 | }, 31 | "Conditional False": { 32 | "Type": "Pass", 33 | "Result": "james", 34 | "ResultPath": "$.tmp.var", 35 | "Next": "Return false ? \"jim\" : \"j ..." 36 | }, 37 | "Return false ? \"jim\" : \"j ...": { 38 | "Type": "Pass", 39 | "InputPath": "$.tmp.var", 40 | "End": true 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/datetime-now-dateTimeNow.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Return asl.jsonPath(\"$$.S ..." 13 | }, 14 | "Return asl.jsonPath(\"$$.S ...": { 15 | "Type": "Pass", 16 | "InputPath": "$$.State.EnteredTime", 17 | "End": true 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/datetime-now-dateTimeUsingJsonPath.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Return" 13 | }, 14 | "Return": { 15 | "Type": "Pass", 16 | "InputPath": "$$.State.EnteredTime", 17 | "End": true 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/enums-compareEnum.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign x" 13 | }, 14 | "Assign x": { 15 | "Type": "Pass", 16 | "Result": 0, 17 | "ResultPath": "$.vars.x", 18 | "Comment": "source: x = ExampleEnum.A", 19 | "Next": "If (x === ExampleEnum.A)" 20 | }, 21 | "If (x === ExampleEnum.A)": { 22 | "Type": "Choice", 23 | "Choices": [ 24 | { 25 | "Variable": "$.vars.x", 26 | "NumericEquals": 0, 27 | "Next": "Return \"success\"" 28 | } 29 | ], 30 | "Comment": "source: if (x === ExampleEnum.A) { return \"success\" }", 31 | "Default": "Return \"fail\"" 32 | }, 33 | "Return \"success\"": { 34 | "Type": "Pass", 35 | "Result": "success", 36 | "End": true 37 | }, 38 | "Return \"fail\"": { 39 | "Type": "Pass", 40 | "Result": "fail", 41 | "End": true 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/enums-compareStringEnum.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign x" 13 | }, 14 | "Assign x": { 15 | "Type": "Pass", 16 | "Result": "a", 17 | "ResultPath": "$.vars.x", 18 | "Comment": "source: x = ExampleEnumString.A", 19 | "Next": "If (x === ExampleEnumStri ..." 20 | }, 21 | "If (x === ExampleEnumStri ...": { 22 | "Type": "Choice", 23 | "Choices": [ 24 | { 25 | "Variable": "$.vars.x", 26 | "StringEquals": "a", 27 | "Next": "Return \"success\"" 28 | } 29 | ], 30 | "Comment": "source: if (x === ExampleEnumString.A) { return \"succe ...", 31 | "Default": "Return \"fail\"" 32 | }, 33 | "Return \"success\"": { 34 | "Type": "Pass", 35 | "Result": "success", 36 | "End": true 37 | }, 38 | "Return \"fail\"": { 39 | "Type": "Pass", 40 | "Result": "fail", 41 | "End": true 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/expressions-booleans.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Return { a: true, ..." 13 | }, 14 | "Return { a: true, ...": { 15 | "Type": "Pass", 16 | "Result": { 17 | "a": true, 18 | "b": false, 19 | "c": true, 20 | "d": false, 21 | "e": false, 22 | "f": true 23 | }, 24 | "End": true 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/expressions-concatStrings.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Return" 13 | }, 14 | "Return": { 15 | "Type": "Pass", 16 | "Result": { 17 | "a": "hello world ", 18 | "b": "abc", 19 | "c": "abc", 20 | "d": "n=42;" 21 | }, 22 | "End": true 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/expressions-numbers.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Return { a: 10 + 10, ..." 13 | }, 14 | "Return { a: 10 + 10, ...": { 15 | "Type": "Pass", 16 | "Result": { 17 | "a": 20, 18 | "b": 20, 19 | "c": 20, 20 | "d": 20, 21 | "e": 40 22 | }, 23 | "End": true 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/expressions-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Return" 13 | }, 14 | "Return": { 15 | "Type": "Pass", 16 | "Result": { 17 | "a": "[!parameter[bucketName]]", 18 | "b": "s3:::arn:[!parameter[bucketName]]", 19 | "c": "value -> [!parameter[bucketName]] <- value" 20 | }, 21 | "End": true 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/for-each-emptyForeach.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign numbers" 13 | }, 14 | "Assign numbers": { 15 | "Type": "Pass", 16 | "Result": [ 17 | 0, 18 | 1, 19 | 2, 20 | 3 21 | ], 22 | "ResultPath": "$.vars.numbers", 23 | "Comment": "source: numbers = [0, 1, 2, 3]", 24 | "Next": "Return \"ok\"" 25 | }, 26 | "Return \"ok\"": { 27 | "Type": "Pass", 28 | "Result": "ok", 29 | "End": true 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/nested-stepfunctions-callLambdaNoAwait.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null 10 | }, 11 | "Next": "childLambda({firstName: \" ..." 12 | }, 13 | "childLambda({firstName: \" ...": { 14 | "Type": "Task", 15 | "ResultPath": null, 16 | "Resource": "[!lambda[childLambda]arn]", 17 | "Parameters": { 18 | "firstName": "Santa", 19 | "lastName": "Claus" 20 | }, 21 | "Retry": [ 22 | { 23 | "ErrorEquals": [ 24 | "Lambda.ServiceException", 25 | "Lambda.AWSLambdaException", 26 | "Lambda.SdkClientException" 27 | ], 28 | "IntervalSeconds": 2, 29 | "MaxAttempts": 6, 30 | "BackoffRate": 2 31 | } 32 | ], 33 | "Comment": "source: childLambda({firstName: \"Santa\", lastName: \"Cl ...", 34 | "End": true 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/nested-stepfunctions-callLambdaWithAwait.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign name" 13 | }, 14 | "Assign name": { 15 | "Type": "Task", 16 | "ResultPath": "$.vars.name", 17 | "Resource": "[!lambda[childLambda]arn]", 18 | "Parameters": { 19 | "firstName": "Santa", 20 | "lastName": "Claus" 21 | }, 22 | "Comment": "source: childLambda({firstName: \"Santa\", lastName: \"Cl ...", 23 | "Retry": [ 24 | { 25 | "ErrorEquals": [ 26 | "Lambda.ServiceException", 27 | "Lambda.AWSLambdaException", 28 | "Lambda.SdkClientException" 29 | ], 30 | "IntervalSeconds": 2, 31 | "MaxAttempts": 6, 32 | "BackoffRate": 2 33 | } 34 | ], 35 | "Next": "Return name" 36 | }, 37 | "Return name": { 38 | "Type": "Pass", 39 | "InputPath": "$.vars.name", 40 | "End": true 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/nested-stepfunctions-callStateMachineNoAwait.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "childStateMachine({firstN ..." 13 | }, 14 | "childStateMachine({firstN ...": { 15 | "Type": "Task", 16 | "Resource": "arn:aws:states:::states:startExecution", 17 | "Parameters": { 18 | "StateMachineArn": "[!state-machine[childStateMachine]arn]", 19 | "Input": { 20 | "firstName": "Santa", 21 | "lastName": "Claus", 22 | "AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID.$": "$$.Execution.Id" 23 | } 24 | }, 25 | "Comment": "source: childStateMachine({firstName: \"Santa\", lastNam ...", 26 | "ResultPath": null, 27 | "Retry": [ 28 | { 29 | "ErrorEquals": [ 30 | "Lambda.ServiceException", 31 | "Lambda.AWSLambdaException", 32 | "Lambda.SdkClientException" 33 | ], 34 | "IntervalSeconds": 2, 35 | "MaxAttempts": 6, 36 | "BackoffRate": 2 37 | } 38 | ], 39 | "End": true 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/nested-stepfunctions-childStateMachine.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Evaluate Format('{} {}', ..." 13 | }, 14 | "Evaluate Format('{} {}', ...": { 15 | "Type": "Pass", 16 | "ResultPath": "$.tmp.eval", 17 | "Parameters": { 18 | "value.$": "States.Format('{} {}', $.vars.firstName, $.vars.lastName)" 19 | }, 20 | "Next": "Return" 21 | }, 22 | "Return": { 23 | "Type": "Pass", 24 | "InputPath": "$.tmp.eval.value", 25 | "End": true 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/nested-stepfunctions-notAwaitedVoidExpression.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "childStateMachine({firstN ..." 13 | }, 14 | "childStateMachine({firstN ...": { 15 | "Type": "Task", 16 | "Resource": "arn:aws:states:::states:startExecution", 17 | "Parameters": { 18 | "StateMachineArn": "[!state-machine[childStateMachine]arn]", 19 | "Input": { 20 | "firstName": "Santa", 21 | "lastName": "Claus", 22 | "AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID.$": "$$.Execution.Id" 23 | } 24 | }, 25 | "Comment": "source: childStateMachine({firstName: \"Santa\", lastNam ...", 26 | "ResultPath": null, 27 | "Retry": [ 28 | { 29 | "ErrorEquals": [ 30 | "Lambda.ServiceException", 31 | "Lambda.AWSLambdaException", 32 | "Lambda.SdkClientException" 33 | ], 34 | "IntervalSeconds": 2, 35 | "MaxAttempts": 6, 36 | "BackoffRate": 2 37 | } 38 | ], 39 | "End": true 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/null-coalescing-nullCoalescingWithLiteral.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Eval Conditional" 13 | }, 14 | "Eval Conditional": { 15 | "Type": "Choice", 16 | "Choices": [ 17 | { 18 | "Variable": "$", 19 | "IsNull": true, 20 | "Next": "Conditional True" 21 | } 22 | ], 23 | "Default": "Conditional False" 24 | }, 25 | "Conditional True": { 26 | "Type": "Pass", 27 | "InputPath": "$._null", 28 | "ResultPath": "$.tmp.var", 29 | "Next": "Return" 30 | }, 31 | "Conditional False": { 32 | "Type": "Pass", 33 | "Result": "jim", 34 | "ResultPath": "$.tmp.var", 35 | "Next": "Return" 36 | }, 37 | "Return": { 38 | "Type": "Pass", 39 | "InputPath": "$.tmp.var", 40 | "End": true 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/pagination-doSomething.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Log (input)" 13 | }, 14 | "Log (input)": { 15 | "Type": "Pass", 16 | "InputPath": "$.vars", 17 | "ResultPath": null, 18 | "Comment": "source: console.log(input)", 19 | "End": true 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/sdk-states-cloudWatchPutMetricData.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign value" 13 | }, 14 | "Assign value": { 15 | "Type": "Pass", 16 | "Result": 42, 17 | "ResultPath": "$.vars.value", 18 | "Comment": "source: value = 42", 19 | "Next": "Publish Metric Data" 20 | }, 21 | "Publish Metric Data": { 22 | "Type": "Task", 23 | "ResultPath": null, 24 | "Resource": "arn:aws:states:::aws-sdk:cloudwatch:putMetricData", 25 | "Parameters": { 26 | "MetricData": [ 27 | { 28 | "MetricName": "ExampleMetric", 29 | "Value.$": "$.vars.value" 30 | } 31 | ], 32 | "Namespace": "ExampleNamespace" 33 | }, 34 | "End": true 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/sdk-states-countDynamoDBItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign result" 13 | }, 14 | "Assign result": { 15 | "Type": "Task", 16 | "ResultPath": "$.vars.result", 17 | "Resource": "arn:aws:states:::aws-sdk:dynamodb:query", 18 | "Parameters": { 19 | "TableName": "[!parameter[tableName]]", 20 | "IndexName": "GSI1", 21 | "KeyConditionExpression": "#pk = :val", 22 | "ExpressionAttributeNames": { 23 | "#pk": "gsi1pk" 24 | }, 25 | "ExpressionAttributeValues": { 26 | ":val": { 27 | "S": "test" 28 | } 29 | }, 30 | "Select": "COUNT" 31 | }, 32 | "Next": "Return result.Count" 33 | }, 34 | "Return result.Count": { 35 | "Type": "Pass", 36 | "InputPath": "$.vars.result.Count", 37 | "End": true 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/sdk-states-dynamoDBPutItemIfNotExists.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "DynamoDB putItem" 13 | }, 14 | "Empty Catch": { 15 | "Type": "Pass", 16 | "End": true 17 | }, 18 | "DynamoDB putItem": { 19 | "Type": "Task", 20 | "ResultPath": null, 21 | "Resource": "arn:aws:states:::aws-sdk:dynamodb:putItem", 22 | "Parameters": { 23 | "Item": { 24 | "pk": { 25 | "S": "pk-value" 26 | }, 27 | "sk": { 28 | "S": "sk-value" 29 | }, 30 | "string": { 31 | "S": "value" 32 | }, 33 | "number": { 34 | "N": "42" 35 | } 36 | }, 37 | "ConditionExpression": "attribute_not_exists(pk)", 38 | "TableName": "[!parameter[assignmentsTableName]]" 39 | }, 40 | "Catch": [ 41 | { 42 | "ErrorEquals": [ 43 | "DynamoDb.ConditionalCheckFailedException" 44 | ], 45 | "ResultPath": null, 46 | "Next": "Empty Catch" 47 | } 48 | ], 49 | "End": true 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/states-waitForTaskToken.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign result" 13 | }, 14 | "Assign result": { 15 | "Type": "Task", 16 | "ResultPath": "$.vars.result", 17 | "Resource": "arn:aws:states:::lambda:invoke.waitForTaskToken", 18 | "Parameters": { 19 | "FunctionName": "sendApprovalEmail", 20 | "Payload": { 21 | "taskToken.$": "$$.Task.Token", 22 | "request.$": "$.vars" 23 | } 24 | }, 25 | "End": true 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/string-templates-escapedCharacters.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign variable" 13 | }, 14 | "Assign variable": { 15 | "Type": "Pass", 16 | "Result": "some var", 17 | "ResultPath": "$.vars.variable", 18 | "Comment": "source: variable = \"some var\"", 19 | "Next": "Return { hello: `hell ..." 20 | }, 21 | "Return { hello: `hell ...": { 22 | "Type": "Pass", 23 | "Parameters": { 24 | "hello.$": "States.Format('hello {}', $.vars.variable)", 25 | "singleQuote.$": "States.Format('hello \\' + {}', $.vars.variable)", 26 | "curlyBrace.$": "States.Format('hello \\}\\{\\} + {}', $.vars.variable)", 27 | "backSlash.$": "States.Format('hello \\\\ + {}', $.vars.variable)", 28 | "emoji.$": "States.Format('hello 🙂 + {}', $.vars.variable)" 29 | }, 30 | "End": true 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/string-templates-stringTemplates.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign variable" 13 | }, 14 | "Assign variable": { 15 | "Type": "Pass", 16 | "Result": "some var", 17 | "ResultPath": "$.vars.variable", 18 | "Comment": "source: variable = \"some var\"", 19 | "Next": "Return { hello: `hell ..." 20 | }, 21 | "Return { hello: `hell ...": { 22 | "Type": "Pass", 23 | "Parameters": { 24 | "hello.$": "States.Format('hello {}', $.vars.variable)" 25 | }, 26 | "End": true 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/throw-RetryErrors.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Parallel" 13 | }, 14 | "Parallel": { 15 | "Type": "Parallel", 16 | "Branches": [ 17 | { 18 | "StartAt": "Throw RetryableError", 19 | "States": { 20 | "Throw RetryableError": { 21 | "Type": "Fail", 22 | "Error": "RetryableError", 23 | "Cause": "retry me", 24 | "Comment": "source: throw new RetryableError(\"retry me\")" 25 | } 26 | } 27 | } 28 | ], 29 | "ResultPath": null, 30 | "Retry": [ 31 | { 32 | "ErrorEquals": [ 33 | "RetryableError" 34 | ], 35 | "IntervalSeconds": 3, 36 | "MaxAttempts": 2, 37 | "BackoffRate": 1.5 38 | } 39 | ], 40 | "End": true 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/try-catch-tryAroundPassState.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Return \"this cannot fail\"" 13 | }, 14 | "Return \"this cannot fail\"": { 15 | "Type": "Pass", 16 | "Result": "this cannot fail", 17 | "End": true 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/try-catch-tryCatchFinally.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign result" 13 | }, 14 | "Assign result": { 15 | "Type": "Pass", 16 | "Result": "", 17 | "ResultPath": "$.vars.result", 18 | "Comment": "source: result = \"\"", 19 | "Next": "Assign result_1" 20 | }, 21 | "Assign result_1": { 22 | "Type": "Pass", 23 | "Result": "try", 24 | "ResultPath": "$.vars.result", 25 | "Next": "Assign result_2" 26 | }, 27 | "Assign result_2": { 28 | "Type": "Pass", 29 | "Result": "finally", 30 | "ResultPath": "$.vars.result", 31 | "Next": "Return result" 32 | }, 33 | "Return result": { 34 | "Type": "Pass", 35 | "InputPath": "$.vars.result", 36 | "End": true 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/try-catch-tryFinally.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Parallel" 13 | }, 14 | "Parallel": { 15 | "Type": "Parallel", 16 | "Branches": [ 17 | { 18 | "StartAt": "Return \"succeeded\"", 19 | "States": { 20 | "Return \"succeeded\"": { 21 | "Type": "Pass", 22 | "Result": "succeeded", 23 | "End": true 24 | } 25 | } 26 | } 27 | ], 28 | "ResultPath": null, 29 | "Comment": "source: Promise.all([() => \"succeeded\"])", 30 | "Next": "Return \"finally\"" 31 | }, 32 | "Return \"finally\"": { 33 | "Type": "Pass", 34 | "Result": "finally", 35 | "End": true 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/variable-assignments-arrayIndexer.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign arr" 13 | }, 14 | "Assign arr": { 15 | "Type": "Pass", 16 | "Result": [ 17 | 1, 18 | 2, 19 | 3, 20 | 4, 21 | 5 22 | ], 23 | "ResultPath": "$.vars.arr", 24 | "Comment": "source: arr = [1, 2, 3, 4, 5]", 25 | "Next": "Assign two" 26 | }, 27 | "Assign two": { 28 | "Type": "Pass", 29 | "InputPath": "$.vars.arr[1]", 30 | "ResultPath": "$.vars.two", 31 | "Comment": "source: two = arr[1]", 32 | "Next": "Assign arr[1]" 33 | }, 34 | "Assign arr[1]": { 35 | "Type": "Pass", 36 | "InputPath": "$.vars.arr[3]", 37 | "ResultPath": "$.vars.arr[1]", 38 | "Next": "Assign arr[3]" 39 | }, 40 | "Assign arr[3]": { 41 | "Type": "Pass", 42 | "InputPath": "$.vars.two", 43 | "ResultPath": "$.vars.arr[3]", 44 | "Next": "Return arr" 45 | }, 46 | "Return arr": { 47 | "Type": "Pass", 48 | "InputPath": "$.vars.arr", 49 | "End": true 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/variable-assignments-assignmentToNull.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign _null" 13 | }, 14 | "Assign _null": { 15 | "Type": "Pass", 16 | "InputPath": "$._null", 17 | "ResultPath": "$.vars._null", 18 | "Comment": "source: _null = null", 19 | "Next": "Return \"ok\"" 20 | }, 21 | "Return \"ok\"": { 22 | "Type": "Pass", 23 | "Result": "ok", 24 | "End": true 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/variable-assignments-assignmentToUndefined.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign _undefined" 13 | }, 14 | "Assign _undefined": { 15 | "Type": "Pass", 16 | "InputPath": "$._undefined", 17 | "ResultPath": "$.vars._undefined", 18 | "Comment": "source: _undefined = undefined", 19 | "Next": "Return \"ok\"" 20 | }, 21 | "Return \"ok\"": { 22 | "Type": "Pass", 23 | "Result": "ok", 24 | "End": true 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/asl/variable-assignments-unassignedVariable.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Assign arr" 13 | }, 14 | "Assign arr": { 15 | "Type": "Pass", 16 | "InputPath": "$._undefined", 17 | "ResultPath": "$.vars.arr", 18 | "Comment": "source: arr: []", 19 | "Next": "Assign two" 20 | }, 21 | "Assign two": { 22 | "Type": "Pass", 23 | "InputPath": "$._undefined", 24 | "ResultPath": "$.vars.two", 25 | "Comment": "source: two: string", 26 | "Next": "Return \"ok\"" 27 | }, 28 | "Return \"ok\"": { 29 | "Type": "Pass", 30 | "Result": "ok", 31 | "End": true 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/conditional-expression-conditionalWithLiteral.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return false ? \"jim\" : \"j ...", 5 | "expression": { 6 | "condition": { 7 | "rhs": { 8 | "value": false, 9 | "type": "boolean", 10 | "_syntaxKind": "literal" 11 | }, 12 | "operator": "is-truthy", 13 | "_syntaxKind": "binary-expression" 14 | }, 15 | "whenTrue": { 16 | "value": "jim", 17 | "type": "string", 18 | "_syntaxKind": "literal" 19 | }, 20 | "whenFalse": { 21 | "value": "james", 22 | "type": "string", 23 | "_syntaxKind": "literal" 24 | }, 25 | "_syntaxKind": "conditional-expression" 26 | }, 27 | "_syntaxKind": "return" 28 | } 29 | ], 30 | "_syntaxKind": "statemachine" 31 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/datetime-now-dateTimeNow.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return asl.jsonPath(\"$$.S ...", 5 | "expression": { 6 | "type": "unknown", 7 | "identifier": "$$.State.EnteredTime", 8 | "_syntaxKind": "identifier" 9 | }, 10 | "_syntaxKind": "return" 11 | } 12 | ], 13 | "_syntaxKind": "statemachine" 14 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/datetime-now-dateTimeUsingJsonPath.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return", 5 | "expression": { 6 | "type": "unknown", 7 | "identifier": "$$.State.EnteredTime", 8 | "_syntaxKind": "identifier" 9 | }, 10 | "_syntaxKind": "return" 11 | } 12 | ], 13 | "_syntaxKind": "statemachine" 14 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/expressions-booleans.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return { a: true, ...", 5 | "expression": { 6 | "properties": { 7 | "a": { 8 | "value": true, 9 | "type": "boolean", 10 | "_syntaxKind": "literal" 11 | }, 12 | "b": { 13 | "value": false, 14 | "type": "boolean", 15 | "_syntaxKind": "literal" 16 | }, 17 | "c": { 18 | "value": true, 19 | "type": "boolean", 20 | "_syntaxKind": "literal" 21 | }, 22 | "d": { 23 | "value": false, 24 | "type": "boolean", 25 | "_syntaxKind": "literal" 26 | }, 27 | "e": { 28 | "value": false, 29 | "type": "boolean", 30 | "_syntaxKind": "literal" 31 | }, 32 | "f": { 33 | "value": true, 34 | "type": "boolean", 35 | "_syntaxKind": "literal" 36 | } 37 | }, 38 | "_syntaxKind": "literal-object" 39 | }, 40 | "_syntaxKind": "return" 41 | } 42 | ], 43 | "_syntaxKind": "statemachine" 44 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/expressions-concatStrings.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return", 5 | "expression": { 6 | "properties": { 7 | "a": { 8 | "value": "hello world ", 9 | "type": "string", 10 | "_syntaxKind": "literal" 11 | }, 12 | "b": { 13 | "value": "abc", 14 | "type": "string", 15 | "_syntaxKind": "literal" 16 | }, 17 | "c": { 18 | "value": "abc", 19 | "type": "string", 20 | "_syntaxKind": "literal" 21 | }, 22 | "d": { 23 | "value": "n=42;", 24 | "type": "string", 25 | "_syntaxKind": "literal" 26 | } 27 | }, 28 | "_syntaxKind": "literal-object" 29 | }, 30 | "_syntaxKind": "return" 31 | } 32 | ], 33 | "_syntaxKind": "statemachine" 34 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/expressions-numbers.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return { a: 10 + 10, ...", 5 | "expression": { 6 | "properties": { 7 | "a": { 8 | "value": 20, 9 | "type": "numeric", 10 | "_syntaxKind": "literal" 11 | }, 12 | "b": { 13 | "value": 20, 14 | "type": "numeric", 15 | "_syntaxKind": "literal" 16 | }, 17 | "c": { 18 | "value": 20, 19 | "type": "numeric", 20 | "_syntaxKind": "literal" 21 | }, 22 | "d": { 23 | "value": 20, 24 | "type": "numeric", 25 | "_syntaxKind": "literal" 26 | }, 27 | "e": { 28 | "value": 40, 29 | "type": "numeric", 30 | "_syntaxKind": "literal" 31 | } 32 | }, 33 | "_syntaxKind": "literal-object" 34 | }, 35 | "_syntaxKind": "return" 36 | } 37 | ], 38 | "_syntaxKind": "statemachine" 39 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/expressions-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return", 5 | "expression": { 6 | "properties": { 7 | "a": { 8 | "value": "[!parameter[bucketName]]", 9 | "type": "string", 10 | "_syntaxKind": "literal" 11 | }, 12 | "b": { 13 | "value": "s3:::arn:[!parameter[bucketName]]", 14 | "type": "string", 15 | "_syntaxKind": "literal" 16 | }, 17 | "c": { 18 | "value": "value -> [!parameter[bucketName]] <- value", 19 | "type": "string", 20 | "_syntaxKind": "literal" 21 | } 22 | }, 23 | "_syntaxKind": "literal-object" 24 | }, 25 | "_syntaxKind": "return" 26 | } 27 | ], 28 | "_syntaxKind": "statemachine" 29 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/nested-stepfunctions-callLambdaNoAwait.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "childLambda({firstName: \" ...", 5 | "resource": "[!lambda[childLambda]arn]", 6 | "retry": [ 7 | { 8 | "errorEquals": [ 9 | "Lambda.ServiceException", 10 | "Lambda.AWSLambdaException", 11 | "Lambda.SdkClientException" 12 | ], 13 | "intervalSeconds": 2, 14 | "maxAttempts": 6, 15 | "backoffRate": 2 16 | } 17 | ], 18 | "parameters": { 19 | "properties": { 20 | "firstName": { 21 | "value": "Santa", 22 | "type": "string", 23 | "_syntaxKind": "literal" 24 | }, 25 | "lastName": { 26 | "value": "Claus", 27 | "type": "string", 28 | "_syntaxKind": "literal" 29 | } 30 | }, 31 | "_syntaxKind": "literal-object" 32 | }, 33 | "source": "childLambda({firstName: \"Santa\", lastName: \"Claus\" })", 34 | "_syntaxKind": "asl-task-state" 35 | } 36 | ], 37 | "_syntaxKind": "statemachine" 38 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/nested-stepfunctions-callStateMachineNoAwait.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "childStateMachine({firstN ...", 5 | "stateMachineName": "[!state-machine[childStateMachine]name]", 6 | "stateMachineArn": "[!state-machine[childStateMachine]arn]", 7 | "parameters": { 8 | "properties": { 9 | "firstName": { 10 | "value": "Santa", 11 | "type": "string", 12 | "_syntaxKind": "literal" 13 | }, 14 | "lastName": { 15 | "value": "Claus", 16 | "type": "string", 17 | "_syntaxKind": "literal" 18 | } 19 | }, 20 | "_syntaxKind": "literal-object" 21 | }, 22 | "retry": [ 23 | { 24 | "errorEquals": [ 25 | "Lambda.ServiceException", 26 | "Lambda.AWSLambdaException", 27 | "Lambda.SdkClientException" 28 | ], 29 | "intervalSeconds": 2, 30 | "maxAttempts": 6, 31 | "backoffRate": 2 32 | } 33 | ], 34 | "source": "childStateMachine({firstName: \"Santa\", lastName: \"Claus\" })", 35 | "_syntaxKind": "asl-invoke-state-machine" 36 | } 37 | ], 38 | "_syntaxKind": "statemachine" 39 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/nested-stepfunctions-childStateMachine.json: -------------------------------------------------------------------------------- 1 | { 2 | "inputArgumentName": { 3 | "identifier": "input", 4 | "type": "object", 5 | "_syntaxKind": "identifier" 6 | }, 7 | "statements": [ 8 | { 9 | "stateName": "Return", 10 | "expression": { 11 | "arguments": [ 12 | { 13 | "value": "{} {}", 14 | "type": "string", 15 | "_syntaxKind": "literal" 16 | }, 17 | { 18 | "identifier": "input.firstName", 19 | "type": "string", 20 | "_syntaxKind": "identifier" 21 | }, 22 | { 23 | "identifier": "input.lastName", 24 | "type": "string", 25 | "_syntaxKind": "identifier" 26 | } 27 | ], 28 | "type": "unknown", 29 | "function": "asl.states.format", 30 | "_syntaxKind": "asl-intrinsic-function" 31 | }, 32 | "_syntaxKind": "return" 33 | } 34 | ], 35 | "_syntaxKind": "statemachine" 36 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/nested-stepfunctions-notAwaitedVoidExpression.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "childStateMachine({firstN ...", 5 | "stateMachineName": "[!state-machine[childStateMachine]name]", 6 | "stateMachineArn": "[!state-machine[childStateMachine]arn]", 7 | "parameters": { 8 | "properties": { 9 | "firstName": { 10 | "value": "Santa", 11 | "type": "string", 12 | "_syntaxKind": "literal" 13 | }, 14 | "lastName": { 15 | "value": "Claus", 16 | "type": "string", 17 | "_syntaxKind": "literal" 18 | } 19 | }, 20 | "_syntaxKind": "literal-object" 21 | }, 22 | "retry": [ 23 | { 24 | "errorEquals": [ 25 | "Lambda.ServiceException", 26 | "Lambda.AWSLambdaException", 27 | "Lambda.SdkClientException" 28 | ], 29 | "intervalSeconds": 2, 30 | "maxAttempts": 6, 31 | "backoffRate": 2 32 | } 33 | ], 34 | "source": "childStateMachine({firstName: \"Santa\", lastName: \"Claus\" })", 35 | "_syntaxKind": "asl-invoke-state-machine" 36 | } 37 | ], 38 | "_syntaxKind": "statemachine" 39 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/null-coalescing-nullCoalescingWithLiteral.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Return", 5 | "expression": { 6 | "condition": { 7 | "rhs": { 8 | "value": null, 9 | "type": "null", 10 | "_syntaxKind": "literal" 11 | }, 12 | "operator": "is-truthy", 13 | "_syntaxKind": "binary-expression" 14 | }, 15 | "whenTrue": { 16 | "value": null, 17 | "type": "null", 18 | "_syntaxKind": "literal" 19 | }, 20 | "whenFalse": { 21 | "value": "jim", 22 | "type": "string", 23 | "_syntaxKind": "literal" 24 | }, 25 | "_syntaxKind": "conditional-expression" 26 | }, 27 | "_syntaxKind": "return" 28 | } 29 | ], 30 | "_syntaxKind": "statemachine" 31 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/pagination-doSomething.json: -------------------------------------------------------------------------------- 1 | { 2 | "inputArgumentName": { 3 | "identifier": "input", 4 | "type": "object", 5 | "_syntaxKind": "identifier" 6 | }, 7 | "statements": [ 8 | { 9 | "stateName": "Log (input)", 10 | "parameters": { 11 | "identifier": "input", 12 | "type": "unknown", 13 | "_syntaxKind": "identifier" 14 | }, 15 | "source": "console.log(input)", 16 | "_syntaxKind": "asl-pass-state" 17 | } 18 | ], 19 | "_syntaxKind": "statemachine" 20 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/string-templates-stringTemplates.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Assign variable", 5 | "name": { 6 | "identifier": "variable", 7 | "type": "string", 8 | "_syntaxKind": "identifier" 9 | }, 10 | "source": "variable = \"some var\"", 11 | "expression": { 12 | "value": "some var", 13 | "type": "string", 14 | "_syntaxKind": "literal" 15 | }, 16 | "_syntaxKind": "variable-assignment" 17 | }, 18 | { 19 | "stateName": "Return { hello: `hell ...", 20 | "expression": { 21 | "properties": { 22 | "hello": { 23 | "arguments": [ 24 | { 25 | "value": "hello {}", 26 | "type": "string", 27 | "_syntaxKind": "literal" 28 | }, 29 | { 30 | "identifier": "variable", 31 | "type": "string", 32 | "_syntaxKind": "identifier" 33 | } 34 | ], 35 | "type": "unknown", 36 | "function": "asl.states.format", 37 | "_syntaxKind": "asl-intrinsic-function" 38 | } 39 | }, 40 | "_syntaxKind": "literal-object" 41 | }, 42 | "_syntaxKind": "return" 43 | } 44 | ], 45 | "_syntaxKind": "statemachine" 46 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/throw-RetryErrors.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "branches": [ 5 | { 6 | "statements": [ 7 | { 8 | "stateName": "Throw RetryableError", 9 | "cause": "retry me", 10 | "error": "RetryableError", 11 | "source": "throw new RetryableError(\"retry me\")", 12 | "_syntaxKind": "asl-fail-state" 13 | } 14 | ], 15 | "_syntaxKind": "function" 16 | } 17 | ], 18 | "retry": [ 19 | { 20 | "errorEquals": [ 21 | "RetryableError" 22 | ], 23 | "backoffRate": 1.5, 24 | "intervalSeconds": 3, 25 | "maxAttempts": 2 26 | } 27 | ], 28 | "_syntaxKind": "asl-parallel-state" 29 | } 30 | ], 31 | "_syntaxKind": "statemachine" 32 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/try-catch-tryAroundPassState.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Try Catch", 5 | "try": { 6 | "statements": [ 7 | { 8 | "stateName": "Return \"this cannot fail\"", 9 | "expression": { 10 | "value": "this cannot fail", 11 | "type": "string", 12 | "_syntaxKind": "literal" 13 | }, 14 | "_syntaxKind": "return" 15 | } 16 | ], 17 | "_syntaxKind": "function" 18 | }, 19 | "catch": [ 20 | { 21 | "errorEquals": [ 22 | "States.ALL" 23 | ], 24 | "block": { 25 | "statements": [ 26 | { 27 | "stateName": "Return \"this never happens\"", 28 | "expression": { 29 | "value": "this never happens", 30 | "type": "string", 31 | "_syntaxKind": "literal" 32 | }, 33 | "_syntaxKind": "return" 34 | } 35 | ], 36 | "_syntaxKind": "function" 37 | } 38 | } 39 | ], 40 | "source": "try {\n return \"this cannot fail\";\n } catch {\n return \"this never happens\";\n }", 41 | "_syntaxKind": "try" 42 | } 43 | ], 44 | "_syntaxKind": "statemachine" 45 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/variable-assignments-assignmentToNull.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Assign _null", 5 | "name": { 6 | "identifier": "_null", 7 | "type": "unknown", 8 | "_syntaxKind": "identifier" 9 | }, 10 | "source": "_null = null", 11 | "expression": { 12 | "value": null, 13 | "type": "null", 14 | "_syntaxKind": "literal" 15 | }, 16 | "_syntaxKind": "variable-assignment" 17 | }, 18 | { 19 | "stateName": "Return \"ok\"", 20 | "expression": { 21 | "value": "ok", 22 | "type": "string", 23 | "_syntaxKind": "literal" 24 | }, 25 | "_syntaxKind": "return" 26 | } 27 | ], 28 | "_syntaxKind": "statemachine" 29 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/variable-assignments-assignmentToUndefined.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Assign _undefined", 5 | "name": { 6 | "identifier": "_undefined", 7 | "type": "unknown", 8 | "_syntaxKind": "identifier" 9 | }, 10 | "source": "_undefined = undefined", 11 | "expression": { 12 | "type": "null", 13 | "_syntaxKind": "literal" 14 | }, 15 | "_syntaxKind": "variable-assignment" 16 | }, 17 | { 18 | "stateName": "Return \"ok\"", 19 | "expression": { 20 | "value": "ok", 21 | "type": "string", 22 | "_syntaxKind": "literal" 23 | }, 24 | "_syntaxKind": "return" 25 | } 26 | ], 27 | "_syntaxKind": "statemachine" 28 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/iasl/variable-assignments-unassignedVariable.json: -------------------------------------------------------------------------------- 1 | { 2 | "statements": [ 3 | { 4 | "stateName": "Assign arr", 5 | "name": { 6 | "identifier": "arr", 7 | "type": "object", 8 | "_syntaxKind": "identifier" 9 | }, 10 | "source": "arr: []", 11 | "expression": { 12 | "type": "null", 13 | "_syntaxKind": "literal" 14 | }, 15 | "_syntaxKind": "variable-assignment" 16 | }, 17 | { 18 | "stateName": "Assign two", 19 | "name": { 20 | "identifier": "two", 21 | "type": "string", 22 | "_syntaxKind": "identifier" 23 | }, 24 | "source": "two: string", 25 | "expression": { 26 | "type": "null", 27 | "_syntaxKind": "literal" 28 | }, 29 | "_syntaxKind": "variable-assignment" 30 | }, 31 | { 32 | "stateName": "Return \"ok\"", 33 | "expression": { 34 | "value": "ok", 35 | "type": "string", 36 | "_syntaxKind": "literal" 37 | }, 38 | "_syntaxKind": "return" 39 | } 40 | ], 41 | "_syntaxKind": "statemachine" 42 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/api-gateway-main.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const main = asl.deploy.asStateMachine(async () =>{ 4 | const response = await asl.optimized.apiGatewayInvoke({ 5 | parameters: { 6 | ApiEndpoint: "aabbccddee.execute-api.us-east-1.amazonaws.com", 7 | Method: "GET", 8 | } 9 | }); 10 | asl.typescriptIf({ 11 | name: "If (response.StatusCode = ...", 12 | condition: () => response.StatusCode === 200, 13 | then: async () => { 14 | return "ok"; 15 | }, 16 | comment: "if (response.StatusCode === 200) {\n return \"ok\"\n }" 17 | }) 18 | return "not-ok"; 19 | }); 20 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/conditional-expression-conditional.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const conditional = asl.deploy.asStateMachine(async (args: { name?: string; }) =>{ 5 | const obj = { name: undefined }; 6 | return obj.name ? obj.name : "jim"; 7 | }); 8 | 9 | export const conditionalWithLiteral = asl.deploy.asStateMachine(async () => { 10 | return false ? "jim" : "james"; 11 | }); 12 | 13 | export const conditionalWithinExpression = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 14 | const obj = { name: "jim" }; 15 | return "hello" + obj.name ? obj.name : "world"; 16 | }); 17 | 18 | export const nestedConditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 19 | const obj = { name: "jim" }; 20 | return null ? "doesn't happen" : obj.name ?? "world"; 21 | }); 22 | 23 | export const conditionalWithinStringFormat = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 24 | const obj = { name: "jim" }; 25 | return `hello: ${obj ? obj.name : "jim"}`; 26 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/conditional-expression-conditionalWithLiteral.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const conditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 5 | const obj = { name: undefined }; 6 | return obj.name ? obj.name : "jim"; 7 | }); 8 | 9 | export const conditionalWithLiteral = asl.deploy.asStateMachine(async () =>{ 10 | return false ? "jim" : "james"; 11 | }); 12 | 13 | export const conditionalWithinExpression = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 14 | const obj = { name: "jim" }; 15 | return "hello" + obj.name ? obj.name : "world"; 16 | }); 17 | 18 | export const nestedConditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 19 | const obj = { name: "jim" }; 20 | return null ? "doesn't happen" : obj.name ?? "world"; 21 | }); 22 | 23 | export const conditionalWithinStringFormat = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 24 | const obj = { name: "jim" }; 25 | return `hello: ${obj ? obj.name : "jim"}`; 26 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/conditional-expression-conditionalWithinExpression.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const conditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 5 | const obj = { name: undefined }; 6 | return obj.name ? obj.name : "jim"; 7 | }); 8 | 9 | export const conditionalWithLiteral = asl.deploy.asStateMachine(async () => { 10 | return false ? "jim" : "james"; 11 | }); 12 | 13 | export const conditionalWithinExpression = asl.deploy.asStateMachine(async (args: { name?: string; }) =>{ 14 | const obj = { name: "jim" }; 15 | return asl.states.format("hello{}", obj.name) ? obj.name : "world"; 16 | }); 17 | 18 | export const nestedConditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 19 | const obj = { name: "jim" }; 20 | return null ? "doesn't happen" : obj.name ?? "world"; 21 | }); 22 | 23 | export const conditionalWithinStringFormat = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 24 | const obj = { name: "jim" }; 25 | return `hello: ${obj ? obj.name : "jim"}`; 26 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/conditional-expression-conditionalWithinStringFormat.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const conditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 5 | const obj = { name: undefined }; 6 | return obj.name ? obj.name : "jim"; 7 | }); 8 | 9 | export const conditionalWithLiteral = asl.deploy.asStateMachine(async () => { 10 | return false ? "jim" : "james"; 11 | }); 12 | 13 | export const conditionalWithinExpression = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 14 | const obj = { name: "jim" }; 15 | return "hello" + obj.name ? obj.name : "world"; 16 | }); 17 | 18 | export const nestedConditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 19 | const obj = { name: "jim" }; 20 | return null ? "doesn't happen" : obj.name ?? "world"; 21 | }); 22 | 23 | export const conditionalWithinStringFormat = asl.deploy.asStateMachine(async (args: { name?: string; }) =>{ 24 | const obj = { name: "jim" }; 25 | return asl.states.format("hello: {}", obj ? obj.name : "jim"); 26 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/conditional-expression-nestedConditional.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const conditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 5 | const obj = { name: undefined }; 6 | return obj.name ? obj.name : "jim"; 7 | }); 8 | 9 | export const conditionalWithLiteral = asl.deploy.asStateMachine(async () => { 10 | return false ? "jim" : "james"; 11 | }); 12 | 13 | export const conditionalWithinExpression = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 14 | const obj = { name: "jim" }; 15 | return "hello" + obj.name ? obj.name : "world"; 16 | }); 17 | 18 | export const nestedConditional = asl.deploy.asStateMachine(async (args: { name?: string; }) =>{ 19 | const obj = { name: "jim" }; 20 | return null ? "doesn't happen" : obj.name ? obj.name : "world"; 21 | }); 22 | 23 | export const conditionalWithinStringFormat = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 24 | const obj = { name: "jim" }; 25 | return `hello: ${obj ? obj.name : "jim"}`; 26 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/datetime-now-dateTimeNow.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const dateTimeNow = asl.deploy.asStateMachine(async () =>{ 5 | return asl.jsonPath("$$.State.EnteredTime"); 6 | }); 7 | 8 | export const dateTimeUsingJsonPath = asl.deploy.asStateMachine(async () => { 9 | return new Date().toISOString(); 10 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/datetime-now-dateTimeUsingJsonPath.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const dateTimeNow = asl.deploy.asStateMachine(async () => { 5 | return asl.jsonPath("$$.State.EnteredTime"); 6 | }); 7 | 8 | export const dateTimeUsingJsonPath = asl.deploy.asStateMachine(async () =>{ 9 | return asl.jsonPath("$$.State.EnteredTime"); 10 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/enums-compareEnum.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | enum ExampleEnum { 4 | "A", 5 | "B" 6 | } 7 | 8 | export const compareEnum = asl.deploy.asStateMachine(async () =>{ 9 | const x = 0; 10 | asl.typescriptIf({ 11 | name: "If (x === ExampleEnum.A)", 12 | condition: () => x === 0, 13 | then: async () => { 14 | return "success"; 15 | }, 16 | comment: "if (x === ExampleEnum.A) {\n return \"success\"\n }" 17 | }) 18 | return "fail"; 19 | }); 20 | 21 | enum ExampleEnumString { 22 | "A" = "a", 23 | "B" = "b" 24 | } 25 | 26 | export const compareStringEnum = asl.deploy.asStateMachine(async () => { 27 | const x = ExampleEnumString.A; 28 | if (x === ExampleEnumString.A) { 29 | return "success" 30 | } 31 | return "fail" 32 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/enums-compareStringEnum.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | enum ExampleEnum { 4 | "A", 5 | "B" 6 | } 7 | 8 | export const compareEnum = asl.deploy.asStateMachine(async () => { 9 | const x = ExampleEnum.A; 10 | if (x === ExampleEnum.A) { 11 | return "success" 12 | } 13 | return "fail" 14 | }); 15 | 16 | enum ExampleEnumString { 17 | "A" = "a", 18 | "B" = "b" 19 | } 20 | 21 | export const compareStringEnum = asl.deploy.asStateMachine(async () =>{ 22 | const x = "a"; 23 | asl.typescriptIf({ 24 | name: "If (x === ExampleEnumStri ...", 25 | condition: () => x === "a", 26 | then: async () => { 27 | return "success"; 28 | }, 29 | comment: "if (x === ExampleEnumString.A) {\n return \"success\"\n }" 30 | }) 31 | return "fail"; 32 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/expressions-booleans.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const concatStrings = asl.deploy.asStateMachine(async () => { 4 | return { 5 | a: "hello" + " world ", 6 | b: "a" + "b" + "c", 7 | c: `a${"b"}c`, 8 | d: `n=${42};` 9 | }; 10 | }); 11 | 12 | export const numbers = asl.deploy.asStateMachine(async () => { 13 | return { 14 | a: 10 + 10, 15 | b: 30 - 10, 16 | c: 10 * 2, 17 | d: 40 / 2, 18 | e: 2 * (4 + 4 * 4), 19 | }; 20 | }); 21 | 22 | export const booleans = asl.deploy.asStateMachine(async () =>{ 23 | return { 24 | a: true, 25 | b: false, 26 | c: true, 27 | d: false, 28 | e: false, 29 | f: true, 30 | }; 31 | }); 32 | 33 | export const parameters = asl.deploy.asStateMachine(async () => { 34 | return { 35 | a: asl.deploy.getParameter("bucketName"), 36 | b: "s3:::arn:" + asl.deploy.getParameter("bucketName"), 37 | c: `value -> ${asl.deploy.getParameter("bucketName")} <- value`, 38 | }; 39 | }); 40 | 41 | // not supported yet 42 | // 43 | // export const simpleMath = asl.deploy.asStateMachine(async () => { 44 | // console.log({ 45 | // a: Math.round(3 / 2) * 2, 46 | // b: Math.floor(3 / 2) + 1, 47 | // }); 48 | // }); 49 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/expressions-concatStrings.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const concatStrings = asl.deploy.asStateMachine(async () =>{ 4 | return { 5 | a: "hello world ", 6 | b: "abc", 7 | c: "abc", 8 | d: "n=42;" 9 | }; 10 | }); 11 | 12 | export const numbers = asl.deploy.asStateMachine(async () => { 13 | return { 14 | a: 10 + 10, 15 | b: 30 - 10, 16 | c: 10 * 2, 17 | d: 40 / 2, 18 | e: 2 * (4 + 4 * 4), 19 | }; 20 | }); 21 | 22 | export const booleans = asl.deploy.asStateMachine(async () => { 23 | return { 24 | a: true, 25 | b: false, 26 | c: true || false, 27 | d: true && false, 28 | e: true && (false || false), 29 | f: ((true && false) || false) || true, 30 | }; 31 | }); 32 | 33 | export const parameters = asl.deploy.asStateMachine(async () => { 34 | return { 35 | a: asl.deploy.getParameter("bucketName"), 36 | b: "s3:::arn:" + asl.deploy.getParameter("bucketName"), 37 | c: `value -> ${asl.deploy.getParameter("bucketName")} <- value`, 38 | }; 39 | }); 40 | 41 | // not supported yet 42 | // 43 | // export const simpleMath = asl.deploy.asStateMachine(async () => { 44 | // console.log({ 45 | // a: Math.round(3 / 2) * 2, 46 | // b: Math.floor(3 / 2) + 1, 47 | // }); 48 | // }); 49 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/expressions-numbers.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const concatStrings = asl.deploy.asStateMachine(async () => { 4 | return { 5 | a: "hello" + " world ", 6 | b: "a" + "b" + "c", 7 | c: `a${"b"}c`, 8 | d: `n=${42};` 9 | }; 10 | }); 11 | 12 | export const numbers = asl.deploy.asStateMachine(async () =>{ 13 | return { 14 | a: 20, 15 | b: 20, 16 | c: 20, 17 | d: 20, 18 | e: 40, 19 | }; 20 | }); 21 | 22 | export const booleans = asl.deploy.asStateMachine(async () => { 23 | return { 24 | a: true, 25 | b: false, 26 | c: true || false, 27 | d: true && false, 28 | e: true && (false || false), 29 | f: ((true && false) || false) || true, 30 | }; 31 | }); 32 | 33 | export const parameters = asl.deploy.asStateMachine(async () => { 34 | return { 35 | a: asl.deploy.getParameter("bucketName"), 36 | b: "s3:::arn:" + asl.deploy.getParameter("bucketName"), 37 | c: `value -> ${asl.deploy.getParameter("bucketName")} <- value`, 38 | }; 39 | }); 40 | 41 | // not supported yet 42 | // 43 | // export const simpleMath = asl.deploy.asStateMachine(async () => { 44 | // console.log({ 45 | // a: Math.round(3 / 2) * 2, 46 | // b: Math.floor(3 / 2) + 1, 47 | // }); 48 | // }); 49 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/expressions-parameters.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const concatStrings = asl.deploy.asStateMachine(async () => { 4 | return { 5 | a: "hello" + " world ", 6 | b: "a" + "b" + "c", 7 | c: `a${"b"}c`, 8 | d: `n=${42};` 9 | }; 10 | }); 11 | 12 | export const numbers = asl.deploy.asStateMachine(async () => { 13 | return { 14 | a: 10 + 10, 15 | b: 30 - 10, 16 | c: 10 * 2, 17 | d: 40 / 2, 18 | e: 2 * (4 + 4 * 4), 19 | }; 20 | }); 21 | 22 | export const booleans = asl.deploy.asStateMachine(async () => { 23 | return { 24 | a: true, 25 | b: false, 26 | c: true || false, 27 | d: true && false, 28 | e: true && (false || false), 29 | f: ((true && false) || false) || true, 30 | }; 31 | }); 32 | 33 | export const parameters = asl.deploy.asStateMachine(async () =>{ 34 | return { 35 | a: "[!parameter[bucketName]]", 36 | b: "s3:::arn:[!parameter[bucketName]]", 37 | c: "value -> [!parameter[bucketName]] <- value", 38 | }; 39 | }); 40 | 41 | // not supported yet 42 | // 43 | // export const simpleMath = asl.deploy.asStateMachine(async () => { 44 | // console.log({ 45 | // a: Math.round(3 / 2) * 2, 46 | // b: Math.floor(3 / 2) + 1, 47 | // }); 48 | // }); 49 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/hello-world-main.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const main = asl.deploy.asStateMachine(async (input: IInput) =>{ 4 | asl.typescriptIf({ 5 | name: "If (typeof input.name !== ...", 6 | condition: () => typeof input.name !== "string", 7 | then: async () => { 8 | input.name = "World"; 9 | }, 10 | comment: "if (typeof input.name !== \"string\") {\n input.name = \"World\";\n }" 11 | }) 12 | const rnd = await asl.typescriptInvoke({ 13 | name: "random()", 14 | resource: random, 15 | comment: "random()" 16 | }); 17 | return { 18 | greeting: asl.states.format("Hello {}", input.name), 19 | luckyNumber: rnd 20 | }; 21 | }); 22 | 23 | export const random = asl.deploy.asLambda(async (input: { min?: number; max?: number } = {}) => { 24 | const min = input.min ?? 0; 25 | const max = input.max ?? 100; 26 | return Math.round(Math.random() * (max - min) + min); 27 | }); 28 | 29 | interface IInput { 30 | name: string; 31 | } 32 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/in-keyword-IfStatementWithInKeyword.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const IfStatementWithInKeyword = asl.deploy.asStateMachine(async () =>{ 5 | let val = { greeting: "hello" }; 6 | asl.typescriptIf({ 7 | name: "If (\"greeting\" in val && ...", 8 | condition: () => "greeting" in val && !("somethingElse" in val), 9 | then: async () => { 10 | return "success"; 11 | }, 12 | comment: "if (\"greeting\" in val && !(\"somethingElse\" in val)) {\n return \"success\";\n }" 13 | }) 14 | return "failure"; 15 | ; 16 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/map-main.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | import { DynamoDB } from "@aws-sdk/client-dynamodb" 3 | 4 | export const main = asl.deploy.asStateMachine(async () =>{ 5 | const entries = await asl.typescriptInvoke({ 6 | name: "getEntries()", 7 | resource: getEntries, 8 | comment: "getEntries()" 9 | }); 10 | await asl.map({ 11 | items: entries, 12 | iterator: (entry: string) => asl.sdk(DynamoDB).putItem({ 13 | catch: [ 14 | { 15 | errorEquals: ["DynamoDb.ConditionalCheckFailedException"], 16 | block: () => { 17 | //no op 18 | }, 19 | }, 20 | ], 21 | parameters: { 22 | Item: { 23 | pk: { S: "pk" }, 24 | sk: { S: asl.states.format("sk#{}", entry) }, 25 | status: { S: "available" }, 26 | }, 27 | ConditionExpression: "attribute_not_exists(:sk)", 28 | TableName: "[!parameter[tableName]]", 29 | }, 30 | }), 31 | }); 32 | }); 33 | 34 | export const getEntries = asl.deploy.asLambda(async () => { 35 | return ["1", "2", "3", "4"] 36 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/null-coalescing-nestedNullCoalescing.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const nullCoalescing = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: undefined as string | undefined }; 6 | let result: { a?: string, b?: string; } = {}; 7 | result.a = obj.name ?? "jim"; 8 | 9 | obj.name = "jack"; 10 | result.b = obj.name ?? "jim"; 11 | 12 | return result; 13 | }); 14 | 15 | export const nullCoalescingWithLiteral = asl.deploy.asStateMachine(async () => { 16 | return null ?? "jim"; 17 | }); 18 | 19 | export const nullCoalescingWithinExpression = asl.deploy.asStateMachine(async () => { 20 | const obj = { name: "world" }; 21 | return "hello " + obj.name ?? "you"; 22 | }); 23 | 24 | export const nestedNullCoalescing = asl.deploy.asStateMachine(async () =>{ 25 | const obj = { name: undefined }; 26 | return (null ? null : obj.name) ? null ? null : obj.name : "world"; 27 | }); 28 | 29 | export const nullCoalescingWithinStringFormat = asl.deploy.asStateMachine(async () => { 30 | const obj = { name: undefined as string | undefined }; 31 | 32 | let result: { a?: string, b?: string; } = {}; 33 | result.a = `hello: ${obj.name ?? "jim"}`; 34 | 35 | obj.name = "jack"; 36 | result.b = `hello: ${obj.name ?? "jim"}`; 37 | 38 | return result; 39 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/null-coalescing-nullCoalescing.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const nullCoalescing = asl.deploy.asStateMachine(async () =>{ 5 | const obj = { name: undefined }; 6 | let result: { 7 | a?: string; 8 | b?: string; 9 | } = {}; 10 | result.a = obj.name ? obj.name : "jim"; 11 | obj.name = "jack"; 12 | result.b = obj.name ? obj.name : "jim"; 13 | return result; 14 | }); 15 | 16 | export const nullCoalescingWithLiteral = asl.deploy.asStateMachine(async () => { 17 | return null ?? "jim"; 18 | }); 19 | 20 | export const nullCoalescingWithinExpression = asl.deploy.asStateMachine(async () => { 21 | const obj = { name: "world" }; 22 | return "hello " + obj.name ?? "you"; 23 | }); 24 | 25 | export const nestedNullCoalescing = asl.deploy.asStateMachine(async () => { 26 | const obj = { name: undefined }; 27 | 28 | return null ?? obj.name ?? "world"; 29 | }); 30 | 31 | export const nullCoalescingWithinStringFormat = asl.deploy.asStateMachine(async () => { 32 | const obj = { name: undefined as string | undefined }; 33 | 34 | let result: { a?: string, b?: string; } = {}; 35 | result.a = `hello: ${obj.name ?? "jim"}`; 36 | 37 | obj.name = "jack"; 38 | result.b = `hello: ${obj.name ?? "jim"}`; 39 | 40 | return result; 41 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/null-coalescing-nullCoalescingWithLiteral.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const nullCoalescing = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: undefined as string | undefined }; 6 | let result: { a?: string, b?: string; } = {}; 7 | result.a = obj.name ?? "jim"; 8 | 9 | obj.name = "jack"; 10 | result.b = obj.name ?? "jim"; 11 | 12 | return result; 13 | }); 14 | 15 | export const nullCoalescingWithLiteral = asl.deploy.asStateMachine(async () =>{ 16 | return null ? null : "jim"; 17 | }); 18 | 19 | export const nullCoalescingWithinExpression = asl.deploy.asStateMachine(async () => { 20 | const obj = { name: "world" }; 21 | return "hello " + obj.name ?? "you"; 22 | }); 23 | 24 | export const nestedNullCoalescing = asl.deploy.asStateMachine(async () => { 25 | const obj = { name: undefined }; 26 | 27 | return null ?? obj.name ?? "world"; 28 | }); 29 | 30 | export const nullCoalescingWithinStringFormat = asl.deploy.asStateMachine(async () => { 31 | const obj = { name: undefined as string | undefined }; 32 | 33 | let result: { a?: string, b?: string; } = {}; 34 | result.a = `hello: ${obj.name ?? "jim"}`; 35 | 36 | obj.name = "jack"; 37 | result.b = `hello: ${obj.name ?? "jim"}`; 38 | 39 | return result; 40 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/null-coalescing-nullCoalescingWithinExpression.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const nullCoalescing = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: undefined as string | undefined }; 6 | let result: { a?: string, b?: string; } = {}; 7 | result.a = obj.name ?? "jim"; 8 | 9 | obj.name = "jack"; 10 | result.b = obj.name ?? "jim"; 11 | 12 | return result; 13 | }); 14 | 15 | export const nullCoalescingWithLiteral = asl.deploy.asStateMachine(async () => { 16 | return null ?? "jim"; 17 | }); 18 | 19 | export const nullCoalescingWithinExpression = asl.deploy.asStateMachine(async () =>{ 20 | const obj = { name: "world" }; 21 | return asl.states.format("hello {}", obj.name) ? asl.states.format("hello {}", obj.name) : "you"; 22 | }); 23 | 24 | export const nestedNullCoalescing = asl.deploy.asStateMachine(async () => { 25 | const obj = { name: undefined }; 26 | 27 | return null ?? obj.name ?? "world"; 28 | }); 29 | 30 | export const nullCoalescingWithinStringFormat = asl.deploy.asStateMachine(async () => { 31 | const obj = { name: undefined as string | undefined }; 32 | 33 | let result: { a?: string, b?: string; } = {}; 34 | result.a = `hello: ${obj.name ?? "jim"}`; 35 | 36 | obj.name = "jack"; 37 | result.b = `hello: ${obj.name ?? "jim"}`; 38 | 39 | return result; 40 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/null-coalescing-nullCoalescingWithinStringFormat.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const nullCoalescing = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: undefined as string | undefined }; 6 | let result: { a?: string, b?: string; } = {}; 7 | result.a = obj.name ?? "jim"; 8 | 9 | obj.name = "jack"; 10 | result.b = obj.name ?? "jim"; 11 | 12 | return result; 13 | }); 14 | 15 | export const nullCoalescingWithLiteral = asl.deploy.asStateMachine(async () => { 16 | return null ?? "jim"; 17 | }); 18 | 19 | export const nullCoalescingWithinExpression = asl.deploy.asStateMachine(async () => { 20 | const obj = { name: "world" }; 21 | return "hello " + obj.name ?? "you"; 22 | }); 23 | 24 | export const nestedNullCoalescing = asl.deploy.asStateMachine(async () => { 25 | const obj = { name: undefined }; 26 | 27 | return null ?? obj.name ?? "world"; 28 | }); 29 | 30 | export const nullCoalescingWithinStringFormat = asl.deploy.asStateMachine(async () =>{ 31 | const obj = { name: undefined }; 32 | let result: { 33 | a?: string; 34 | b?: string; 35 | } = {}; 36 | result.a = asl.states.format("hello: {}", obj.name ? obj.name : "jim"); 37 | obj.name = "jack"; 38 | result.b = asl.states.format("hello: {}", obj.name ? obj.name : "jim"); 39 | return result; 40 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/optional-property-chain-assignOptionalChain.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const returnOptionalChain = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: "jim" }; 6 | return obj?.name; 7 | }); 8 | 9 | export const returnLongerChain = asl.deploy.asStateMachine(async () => { 10 | const obj = { inner: { name: "jim" } }; 11 | return obj?.inner?.name; 12 | }); 13 | 14 | export const assignOptionalChain = asl.deploy.asStateMachine(async () =>{ 15 | const obj = { name: "jim" }; 16 | const name = obj?.name; 17 | return name; 18 | }); 19 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/optional-property-chain-returnLongerChain.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const returnOptionalChain = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: "jim" }; 6 | return obj?.name; 7 | }); 8 | 9 | export const returnLongerChain = asl.deploy.asStateMachine(async () =>{ 10 | const obj = { inner: { name: "jim" } }; 11 | return obj?.inner?.name; 12 | }); 13 | 14 | export const assignOptionalChain = asl.deploy.asStateMachine(async () => { 15 | const obj = { name: "jim" }; 16 | const name = obj?.name; 17 | return name; 18 | }); 19 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/optional-property-chain-returnOptionalChain.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const returnOptionalChain = asl.deploy.asStateMachine(async () =>{ 5 | const obj = { name: "jim" }; 6 | return obj?.name; 7 | }); 8 | 9 | export const returnLongerChain = asl.deploy.asStateMachine(async () => { 10 | const obj = { inner: { name: "jim" } }; 11 | return obj?.inner?.name; 12 | }); 13 | 14 | export const assignOptionalChain = asl.deploy.asStateMachine(async () => { 15 | const obj = { name: "jim" }; 16 | const name = obj?.name; 17 | return name; 18 | }); 19 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/pagination-doSomething.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib" 3 | import { IAM } from "@aws-sdk/client-iam"; 4 | 5 | export const listUsers = asl.deploy.asStateMachine(async (input: any) => { 6 | var marker: string | undefined; 7 | do{ 8 | var response = await asl.sdk(IAM).listUsers({ 9 | name: "List Users", 10 | parameters : { 11 | PathPrefix: "/path", 12 | Marker: marker 13 | } 14 | }); 15 | 16 | for(const user of (response.Users || [])) { 17 | //put your logic here 18 | await doSomething(user); 19 | } 20 | marker = response.IsTruncated ? response.Marker : undefined; 21 | }while(marker) 22 | }); 23 | 24 | 25 | export const doSomething = asl.deploy.asStateMachine(async (input: User) =>{ 26 | asl.pass({ 27 | name: "Log (input)", 28 | parameters: () => input, 29 | comment: "console.log(input)" 30 | }); 31 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/parallel-enclosedVariables.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | 3 | export const worker = asl.deploy.asLambda(async (input?: { something: string }) => { 4 | return "received " + input?.something ?? ""; 5 | }); 6 | 7 | export const simple = asl.deploy.asStateMachine(async (input: {}) => { 8 | return await Promise.all([worker(), worker()]); 9 | }); 10 | 11 | export const enclosedVariables = asl.deploy.asStateMachine(async (input: {}) =>{ 12 | const enclosedVar1 = { something: "left" }; 13 | const enclosedVar2 = { something: "right" }; 14 | return await asl.parallel({ 15 | branches: [ 16 | () => { let return_var = asl.typescriptInvoke({ 17 | name: "worker(enclosedVar1)", 18 | resource: worker, 19 | parameters: () => enclosedVar1, 20 | comment: "worker(enclosedVar1)" 21 | }); return return_var; }, 22 | () => { let return_var = asl.typescriptInvoke({ 23 | name: "worker(enclosedVar2)", 24 | resource: worker, 25 | parameters: () => enclosedVar2, 26 | comment: "worker(enclosedVar2)" 27 | }); return return_var; } 28 | ], 29 | comment: "Promise.all([\n worker(enclosedVar1),\n worker(enclosedVar2),\n ])" 30 | }); 31 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/parallel-simple.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | 3 | export const worker = asl.deploy.asLambda(async (input?: { something: string }) => { 4 | return "received " + input?.something ?? ""; 5 | }); 6 | 7 | export const simple = asl.deploy.asStateMachine(async (input: {}) =>{ 8 | return await asl.parallel({ 9 | branches: [ 10 | () => { let return_var = asl.typescriptInvoke({ 11 | name: "worker()", 12 | resource: worker, 13 | comment: "worker()" 14 | }); return return_var; }, 15 | () => { let return_var = asl.typescriptInvoke({ 16 | name: "worker()", 17 | resource: worker, 18 | comment: "worker()" 19 | }); return return_var; } 20 | ], 21 | comment: "Promise.all([worker(), worker()])" 22 | }); 23 | }); 24 | 25 | export const enclosedVariables = asl.deploy.asStateMachine(async (input: {}) => { 26 | const enclosedVar1 = { something: "left" }; 27 | const enclosedVar2 = { something: "right" }; 28 | return await Promise.all([ 29 | worker(enclosedVar1), 30 | worker(enclosedVar2), 31 | ]); 32 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/states-waitForTaskToken.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | 3 | export const waitForTaskToken = asl.deploy.asStateMachine(async (input: {}, context: asl.StateMachineContext<{}>) =>{ 4 | const result: { 5 | action: "approve" | "reject"; 6 | } = await asl.task({ 7 | name: "Human Approval", 8 | resource: "arn:aws:states:::lambda:invoke.waitForTaskToken", 9 | parameters: { 10 | FunctionName: "sendApprovalEmail", 11 | Payload: { 12 | taskToken: context.task.token, 13 | request: input, 14 | }, 15 | }, 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/string-templates-escapedCharacters.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const stringTemplates = asl.deploy.asStateMachine(async () => { 4 | let variable = "some var"; 5 | 6 | return { 7 | hello: `hello ${variable}`, 8 | }; 9 | }); 10 | 11 | export const escapedCharacters = asl.deploy.asStateMachine(async () =>{ 12 | let variable = "some var"; 13 | return { 14 | hello: asl.states.format("hello {}", variable), 15 | singleQuote: asl.states.format("hello \\' + {}", variable), 16 | curlyBrace: asl.states.format("hello \\}\\{\\} + {}", variable), 17 | backSlash: asl.states.format("hello \\\\ + {}", variable), 18 | emoji: asl.states.format("hello \uD83D\uDE42 + {}", variable), 19 | }; 20 | }); 21 | 22 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/string-templates-stringTemplates.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const stringTemplates = asl.deploy.asStateMachine(async () =>{ 4 | let variable = "some var"; 5 | return { 6 | hello: asl.states.format("hello {}", variable), 7 | }; 8 | }); 9 | 10 | export const escapedCharacters = asl.deploy.asStateMachine(async () => { 11 | let variable = "some var"; 12 | 13 | return { 14 | hello: `hello ${variable}`, 15 | singleQuote: `hello ' + ${variable}`, 16 | curlyBrace: `hello }{} + ${variable}`, 17 | backSlash: `hello \\ + ${variable}`, 18 | emoji: `hello 🙂 + ${variable}`, 19 | }; 20 | }); 21 | 22 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/output/ts-lib/variables-main.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib" 3 | import { StateMachineContext } from "@ts2asl/asl-lib"; 4 | 5 | export const main = asl.deploy.asStateMachine(async (input: IInput, context: StateMachineContext) =>{ 6 | asl.typescriptIf({ 7 | name: "If (typeof input.name !== ...", 8 | condition: () => typeof input.name !== "string", 9 | then: async () => { 10 | input.name = "fred"; 11 | }, 12 | comment: "if (typeof input.name !== \"string\") {\n input.name = \"fred\";\n }" 13 | }) 14 | const x = { 15 | name: input.name, 16 | executionId: context.execution.id 17 | }; 18 | const y = { 19 | x, 20 | somethingLiteral: ["one", 2, "three"], 21 | startTime: context.execution.startTime, 22 | func: asl.states.jsonToString(x), 23 | func2: asl.states.jsonToString({ field: 'val' }), 24 | fmt: asl.states.format("hello {}", x), 25 | number: asl.states.stringToJson("123"), 26 | arr: asl.states.array(1, 2, 3, 4, 5, 6), 27 | }; 28 | return y; 29 | }); 30 | 31 | 32 | interface IInput { 33 | name: string; 34 | totalDue: number; 35 | orders: [{ orderId: string, date: Date }]; 36 | } 37 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/api-gateway.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const main = asl.deploy.asStateMachine(async () => { 4 | const response = await asl.optimized.apiGatewayInvoke({ 5 | parameters: { 6 | ApiEndpoint: "aabbccddee.execute-api.us-east-1.amazonaws.com", 7 | Method: "GET", 8 | }}); 9 | 10 | if (response.StatusCode === 200) { 11 | return "ok" 12 | } 13 | 14 | return "not-ok"; 15 | }); 16 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/closures.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const main = asl.deploy.asStateMachine(async () => { 4 | const numbers = [0, 1, 2, 3]; 5 | const letters = ["a", "b", "c", "d"]; 6 | const global = "prefix"; 7 | const outer = { middle: { inner: 3 } } 8 | numbers.map(number => { 9 | letters.map(letter => { 10 | const combined = { number, letter, global, inner: outer.middle.inner }; 11 | doSomething(combined); 12 | }); 13 | }); 14 | }); 15 | 16 | 17 | 18 | export const doSomething = asl.deploy.asLambda(x => { }) -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/conditional-expression.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const conditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 5 | const obj = { name: undefined }; 6 | return obj.name ? obj.name : "jim"; 7 | }); 8 | 9 | export const conditionalWithLiteral = asl.deploy.asStateMachine(async () => { 10 | return false ? "jim" : "james"; 11 | }); 12 | 13 | export const conditionalWithinExpression = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 14 | const obj = { name: "jim" }; 15 | return "hello" + obj.name ? obj.name : "world"; 16 | }); 17 | 18 | export const nestedConditional = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 19 | const obj = { name: "jim" }; 20 | return null ? "doesn't happen" : obj.name ?? "world"; 21 | }); 22 | 23 | export const conditionalWithinStringFormat = asl.deploy.asStateMachine(async (args: { name?: string; }) => { 24 | const obj = { name: "jim" }; 25 | return `hello: ${obj ? obj.name : "jim"}`; 26 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/datetime-now.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const dateTimeNow = asl.deploy.asStateMachine(async () => { 5 | return asl.jsonPath("$$.State.EnteredTime"); 6 | }); 7 | 8 | export const dateTimeUsingJsonPath = asl.deploy.asStateMachine(async () => { 9 | return new Date().toISOString(); 10 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/enums.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | enum ExampleEnum { 4 | "A", 5 | "B" 6 | } 7 | 8 | export const compareEnum = asl.deploy.asStateMachine(async () => { 9 | const x = ExampleEnum.A; 10 | if (x === ExampleEnum.A) { 11 | return "success" 12 | } 13 | return "fail" 14 | }); 15 | 16 | enum ExampleEnumString { 17 | "A" = "a", 18 | "B" = "b" 19 | } 20 | 21 | export const compareStringEnum = asl.deploy.asStateMachine(async () => { 22 | const x = ExampleEnumString.A; 23 | if (x === ExampleEnumString.A) { 24 | return "success" 25 | } 26 | return "fail" 27 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/expressions.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const concatStrings = asl.deploy.asStateMachine(async () => { 4 | return { 5 | a: "hello" + " world ", 6 | b: "a" + "b" + "c", 7 | c: `a${"b"}c`, 8 | d: `n=${42};` 9 | }; 10 | }); 11 | 12 | export const numbers = asl.deploy.asStateMachine(async () => { 13 | return { 14 | a: 10 + 10, 15 | b: 30 - 10, 16 | c: 10 * 2, 17 | d: 40 / 2, 18 | e: 2 * (4 + 4 * 4), 19 | }; 20 | }); 21 | 22 | export const booleans = asl.deploy.asStateMachine(async () => { 23 | return { 24 | a: true, 25 | b: false, 26 | c: true || false, 27 | d: true && false, 28 | e: true && (false || false), 29 | f: ((true && false) || false) || true, 30 | }; 31 | }); 32 | 33 | export const parameters = asl.deploy.asStateMachine(async () => { 34 | return { 35 | a: asl.deploy.getParameter("bucketName"), 36 | b: "s3:::arn:" + asl.deploy.getParameter("bucketName"), 37 | c: `value -> ${asl.deploy.getParameter("bucketName")} <- value`, 38 | }; 39 | }); 40 | 41 | // not supported yet 42 | // 43 | // export const simpleMath = asl.deploy.asStateMachine(async () => { 44 | // console.log({ 45 | // a: Math.round(3 / 2) * 2, 46 | // b: Math.floor(3 / 2) + 1, 47 | // }); 48 | // }); 49 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/hello-world.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const main = asl.deploy.asStateMachine(async (input: IInput) => { 4 | if (typeof input.name !== "string") { 5 | input.name = "World"; 6 | } 7 | const rnd = await random(); 8 | return { 9 | greeting: `Hello ${input.name}`, 10 | luckyNumber: rnd 11 | } 12 | }); 13 | 14 | export const random = asl.deploy.asLambda(async (input: { min?: number; max?: number } = {}) => { 15 | const min = input.min ?? 0; 16 | const max = input.max ?? 100; 17 | return Math.round(Math.random() * (max - min) + min); 18 | }); 19 | 20 | interface IInput { 21 | name: string; 22 | } 23 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/in-keyword.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const IfStatementWithInKeyword = asl.deploy.asStateMachine(async () => { 5 | let val = { greeting: "hello" }; 6 | if ("greeting" in val && !("somethingElse" in val)) { 7 | return "success"; 8 | } 9 | return "failure";; 10 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/input-validation.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | 3 | export const checkArgumentType = asl.deploy.asStateMachine(async (input: Input) => { 4 | if (typeof input.delayInSeconds !== "number") { 5 | throw new ValidationError("delayInSeconds must be a number"); 6 | } 7 | await asl.wait({ seconds: input.delayInSeconds }); 8 | }); 9 | 10 | export const checkArgumentTypeProvideDefault = asl.deploy.asStateMachine(async (input: Input) => { 11 | if (typeof input.delayInSeconds !== "number") { 12 | input.delayInSeconds = 5; 13 | } 14 | await asl.wait({ seconds: input.delayInSeconds }); 15 | return input.delayInSeconds; 16 | }); 17 | 18 | export const checkArgumentRange = asl.deploy.asStateMachine(async (input: Input) => { 19 | if (typeof input.delayInSeconds !== "number") { 20 | input.delayInSeconds = 5; 21 | } 22 | 23 | if (input.delayInSeconds > 10 || input.delayInSeconds < 1) { 24 | throw new ValidationError("delay in seconds must be numeric value no greater than 10 and no smaller than 1"); 25 | } 26 | 27 | await asl.wait({ seconds: input.delayInSeconds }); 28 | return input.delayInSeconds; 29 | }); 30 | 31 | interface Input { 32 | delayInSeconds: number | undefined; 33 | } 34 | 35 | class ValidationError extends Error { 36 | constructor(message: string) { 37 | super(message); 38 | } 39 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/map.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | import { DynamoDB } from "@aws-sdk/client-dynamodb" 3 | 4 | export const main = asl.deploy.asStateMachine(async () => { 5 | const entries = await getEntries(); 6 | await asl.map({ 7 | items: entries, 8 | iterator: (entry: string) => 9 | void asl.sdk(DynamoDB).putItem({ 10 | catch: [ 11 | { 12 | errorEquals: ["DynamoDb.ConditionalCheckFailedException"], 13 | block: () => { 14 | //no op 15 | }, 16 | }, 17 | ], 18 | parameters: { 19 | Item: { 20 | pk: { S: "pk" }, 21 | sk: { S: `sk#${entry}` }, 22 | status: { S: "available" }, 23 | }, 24 | ConditionExpression: "attribute_not_exists(:sk)", 25 | TableName: asl.deploy.getParameter("tableName"), 26 | }, 27 | }), 28 | }); 29 | }); 30 | 31 | export const getEntries = asl.deploy.asLambda(async () => { 32 | return ["1", "2", "3", "4"] 33 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/null-coalescing.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const nullCoalescing = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: undefined as string | undefined }; 6 | let result: { a?: string, b?: string; } = {}; 7 | result.a = obj.name ?? "jim"; 8 | 9 | obj.name = "jack"; 10 | result.b = obj.name ?? "jim"; 11 | 12 | return result; 13 | }); 14 | 15 | export const nullCoalescingWithLiteral = asl.deploy.asStateMachine(async () => { 16 | return null ?? "jim"; 17 | }); 18 | 19 | export const nullCoalescingWithinExpression = asl.deploy.asStateMachine(async () => { 20 | const obj = { name: "world" }; 21 | return "hello " + obj.name ?? "you"; 22 | }); 23 | 24 | export const nestedNullCoalescing = asl.deploy.asStateMachine(async () => { 25 | const obj = { name: undefined }; 26 | 27 | return null ?? obj.name ?? "world"; 28 | }); 29 | 30 | export const nullCoalescingWithinStringFormat = asl.deploy.asStateMachine(async () => { 31 | const obj = { name: undefined as string | undefined }; 32 | 33 | let result: { a?: string, b?: string; } = {}; 34 | result.a = `hello: ${obj.name ?? "jim"}`; 35 | 36 | obj.name = "jack"; 37 | result.b = `hello: ${obj.name ?? "jim"}`; 38 | 39 | return result; 40 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/optional-property-chain.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib"; 3 | 4 | export const returnOptionalChain = asl.deploy.asStateMachine(async () => { 5 | const obj = { name: "jim" }; 6 | return obj?.name; 7 | }); 8 | 9 | export const returnLongerChain = asl.deploy.asStateMachine(async () => { 10 | const obj = { inner: { name: "jim" } }; 11 | return obj?.inner?.name; 12 | }); 13 | 14 | export const assignOptionalChain = asl.deploy.asStateMachine(async () => { 15 | const obj = { name: "jim" }; 16 | const name = obj?.name; 17 | return name; 18 | }); 19 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/pagination.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib" 3 | import { IAM } from "@aws-sdk/client-iam"; 4 | 5 | export const listUsers = asl.deploy.asStateMachine(async (input: any) => { 6 | var marker: string | undefined; 7 | do{ 8 | var response = await asl.sdk(IAM).listUsers({ 9 | name: "List Users", 10 | parameters : { 11 | PathPrefix: "/path", 12 | Marker: marker 13 | } 14 | }); 15 | 16 | for(const user of (response.Users || [])) { 17 | //put your logic here 18 | await doSomething(user); 19 | } 20 | marker = response.IsTruncated ? response.Marker : undefined; 21 | }while(marker) 22 | }); 23 | 24 | 25 | export const doSomething = asl.deploy.asStateMachine(async (input: User) => { 26 | console.log(input); 27 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/parallel.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | 3 | export const worker = asl.deploy.asLambda(async (input?: { something: string }) => { 4 | return "received " + input?.something ?? ""; 5 | }); 6 | 7 | export const simple = asl.deploy.asStateMachine(async (input: {}) => { 8 | return await Promise.all([worker(), worker()]); 9 | }); 10 | 11 | export const enclosedVariables = asl.deploy.asStateMachine(async (input: {}) => { 12 | const enclosedVar1 = { something: "left" }; 13 | const enclosedVar2 = { something: "right" }; 14 | return await Promise.all([ 15 | worker(enclosedVar1), 16 | worker(enclosedVar2), 17 | ]); 18 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/states.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib"; 2 | 3 | export const waitForTaskToken = asl.deploy.asStateMachine(async (input: {}, context: asl.StateMachineContext<{}>) => { 4 | const result: { action: "approve" | "reject" } = await asl.task({ 5 | name: "Human Approval", 6 | resource: "arn:aws:states:::lambda:invoke.waitForTaskToken", 7 | parameters: { 8 | FunctionName: "sendApprovalEmail", // or asl.deploy.getLambdaName(sendApprovalEmail) 9 | Payload: { 10 | taskToken: context.task.token, 11 | request: input, 12 | }, 13 | }, 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/string-templates.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const stringTemplates = asl.deploy.asStateMachine(async () => { 4 | let variable = "some var"; 5 | 6 | return { 7 | hello: `hello ${variable}`, 8 | }; 9 | }); 10 | 11 | export const escapedCharacters = asl.deploy.asStateMachine(async () => { 12 | let variable = "some var"; 13 | 14 | return { 15 | hello: `hello ${variable}`, 16 | singleQuote: `hello ' + ${variable}`, 17 | curlyBrace: `hello }{} + ${variable}`, 18 | backSlash: `hello \\ + ${variable}`, 19 | emoji: `hello 🙂 + ${variable}`, 20 | }; 21 | }); 22 | 23 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/ts-lib-convert.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib" 3 | 4 | export const lambda = asl.deploy.asLambda(() => { return ["succeeded"] }); 5 | 6 | export const convertStringToNumber = asl.deploy.asStateMachine(async () => { 7 | const num = asl.convert.stringToNumber("42"); 8 | if (num === 42) { 9 | const str = asl.convert.numberToString(num); 10 | if (str === "42") { 11 | return "succeeded"; 12 | } 13 | } 14 | throw new Error("failed"); 15 | }); 16 | 17 | export const convertStringToBoolean = asl.deploy.asStateMachine(async () => { 18 | const bool = asl.convert.stringToBoolean("true"); 19 | if (bool === true) { 20 | const str = asl.convert.booleanToString(bool); 21 | if (str === "true") { 22 | return "succeeded"; 23 | } 24 | } 25 | throw new Error("failed"); 26 | }); -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/ts2asl.out/closures.iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "generated using IAMFast (https://github.com/iann0036/iamfast) and @ts2asl/cdk-typescript-statemachine, version: 0.2.7}", 3 | "Version": "2012-10-17", 4 | "Statement": [ 5 | { 6 | "Effect": "Allow", 7 | "Action": "lambda:InvokeFunction", 8 | "Resource": [ 9 | "arn:aws:lambda:${Token[CDK.REF.REPLACED]}:${Token[CDK.REF.REPLACED]}:function:*" 10 | ] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/ts2asl.out/hello-world.iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "generated using IAMFast (https://github.com/iann0036/iamfast) and @ts2asl/cdk-typescript-statemachine, version: 0.2.7}", 3 | "Version": "2012-10-17", 4 | "Statement": [ 5 | { 6 | "Effect": "Allow", 7 | "Action": "lambda:InvokeFunction", 8 | "Resource": [ 9 | "arn:aws:lambda:${Token[CDK.REF.REPLACED]}:${Token[CDK.REF.REPLACED]}:function:*" 10 | ] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/ts2asl.out/nested-stepfunctions.asl.json: -------------------------------------------------------------------------------- 1 | { 2 | "StartAt": "Initialize", 3 | "States": { 4 | "Initialize": { 5 | "Type": "Pass", 6 | "ResultPath": "$", 7 | "Parameters": { 8 | "vars.$": "$$.Execution.Input", 9 | "_undefined": null, 10 | "_null": null 11 | }, 12 | "Next": "Evaluate Format('{} {}', ..." 13 | }, 14 | "Evaluate Format('{} {}', ...": { 15 | "Type": "Pass", 16 | "ResultPath": "$.tmp.eval", 17 | "Parameters": { 18 | "value.$": "States.Format('{} {}', $.vars.firstName, $.vars.lastName)" 19 | }, 20 | "Next": "Return" 21 | }, 22 | "Return": { 23 | "Type": "Pass", 24 | "InputPath": "$.tmp.eval.value", 25 | "End": true 26 | } 27 | }, 28 | "Comment": "ASL Generated using ts2asl version 0.1.61." 29 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/ts2asl.out/nested-stepfunctions.iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "generated using IAMFast (https://github.com/iann0036/iamfast) and @ts2asl/cdk-typescript-statemachine, version: 0.2.7}", 3 | "Version": "2012-10-17", 4 | "Statement": [] 5 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/ts2asl.out/parallel.iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "generated using IAMFast (https://github.com/iann0036/iamfast) and @ts2asl/cdk-typescript-statemachine, version: 0.2.7}", 3 | "Version": "2012-10-17", 4 | "Statement": [ 5 | { 6 | "Effect": "Allow", 7 | "Action": "lambda:InvokeFunction", 8 | "Resource": [ 9 | "arn:aws:lambda:${Token[CDK.REF.REPLACED]}:${Token[CDK.REF.REPLACED]}:function:*" 10 | ] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/variables.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib" 3 | import { StateMachineContext } from "@ts2asl/asl-lib"; 4 | 5 | export const main = asl.deploy.asStateMachine(async (input: IInput, context: StateMachineContext) => { 6 | if (typeof input.name !== "string") { 7 | input.name = "fred"; 8 | } 9 | const x = { 10 | name: input.name, 11 | executionId: context.execution.id 12 | } 13 | const y = { 14 | x, 15 | somethingLiteral: ["one", 2, "three"], 16 | startTime: context.execution.startTime, 17 | func: asl.states.jsonToString(x), 18 | func2: asl.states.jsonToString({field:'val'}), 19 | fmt: asl.states.format("hello {}", x), 20 | number: asl.states.stringToJson("123") as number, 21 | arr: asl.states.array(1, 2, 3, 4, 5, 6), 22 | } 23 | return y; 24 | }); 25 | 26 | 27 | interface IInput { 28 | name: string; 29 | totalDue: number; 30 | orders: [{ orderId: string, date: Date }]; 31 | } 32 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/resources/while.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | 3 | export const simpleWhile = asl.deploy.asStateMachine(async () => { 4 | let counter = "" 5 | while (counter != "aaaaa") { 6 | counter = `${counter}a`; 7 | } 8 | return counter;; //returns "aaaaa" 9 | }); 10 | 11 | export const whileWithBreak = asl.deploy.asStateMachine(async () => { 12 | let counter = "" 13 | while (counter != "aaaaa") { 14 | counter = `${counter}a`; 15 | if (counter == "aa") { 16 | break; 17 | } 18 | } 19 | return counter;; //returns "aa" 20 | }); 21 | 22 | export const whileWithEarlyReturn = asl.deploy.asStateMachine(async () => { 23 | let counter = "" 24 | while (counter != "aaaaa") { 25 | counter = `${counter}a`; 26 | if (counter == "aa") { 27 | return counter; //returns "aa" 28 | } 29 | } 30 | throw new Error("this should not happen"); 31 | }); 32 | 33 | 34 | export const whileWithContinue = asl.deploy.asStateMachine(async () => { 35 | let counter = "" 36 | let result = ""; 37 | while (counter != "aaaaa") { 38 | counter = `${counter}a`; 39 | if (counter == "aa") { 40 | continue; 41 | } 42 | result = `${result}b`; 43 | } 44 | return result; //returns "bbbb" 45 | }); 46 | -------------------------------------------------------------------------------- /packages/convert/src/__test__/tests/states.test.ts: -------------------------------------------------------------------------------- 1 | import { runConvertForTest } from "../utility"; 2 | describe("when converting states", () => { 3 | let converted; 4 | beforeAll(() => { 5 | converted = runConvertForTest("states"); 6 | }); 7 | it("then waitForTaskToken can be converted to asl", async () => { 8 | expect(converted.waitForTaskToken.asl).toMatchInlineSnapshot(` 9 | Object { 10 | "StartAt": "Initialize", 11 | "States": Object { 12 | "Assign result": Object { 13 | "Comment": undefined, 14 | "End": true, 15 | "HeartbeatSeconds": undefined, 16 | "Parameters": Object { 17 | "FunctionName": "sendApprovalEmail", 18 | "Payload": Object { 19 | "request.$": "$.vars", 20 | "taskToken.$": "$$.Task.Token", 21 | }, 22 | }, 23 | "Resource": "arn:aws:states:::lambda:invoke.waitForTaskToken", 24 | "ResultPath": "$.vars.result", 25 | "TimeoutSeconds": undefined, 26 | "Type": "Task", 27 | }, 28 | "Initialize": Object { 29 | "Next": "Assign result", 30 | "Parameters": Object { 31 | "_null": null, 32 | "_undefined": null, 33 | "vars.$": "$$.Execution.Input", 34 | }, 35 | "ResultPath": "$", 36 | "Type": "Pass", 37 | }, 38 | }, 39 | } 40 | `); 41 | }); 42 | }); -------------------------------------------------------------------------------- /packages/convert/src/compiler-host/__test__/resources/lambda.ts: -------------------------------------------------------------------------------- 1 | export const lambdaImplementation = async (input: {num: number, str: string}) => { 2 | return input; 3 | } -------------------------------------------------------------------------------- /packages/convert/src/compiler-host/__test__/resources/lib-test.ts: -------------------------------------------------------------------------------- 1 | import * as asl from '@ts2asl/asl-lib'; 2 | import { SNS } from "@aws-sdk/client-sns"; 3 | import * as SdkSNS from "@aws-sdk/client-sns"; 4 | import { lambdaImplementation } from './lambda'; 5 | const num = asl.deploy.evalConst(23); 6 | const str = asl.deploy.evalConst(""); 7 | const statemachine = asl.deploy.asStateMachine(async (arg: {}) => "hello"); 8 | const lambda = asl.deploy.asLambda(lambdaImplementation); 9 | const statusCode = (await asl.optimized.lambdaInvoke({parameters: {FunctionName:"asdas"}})).StatusCode; 10 | const messageId = (await asl.sdk(SNS).publish({parameters: {} as any})).MessageId!; 11 | const result = (await lambda({ num, str })).num; 12 | const aliasedImport = SdkSNS; -------------------------------------------------------------------------------- /packages/convert/src/compiler-host/index.ts: -------------------------------------------------------------------------------- 1 | import ts from "typescript"; 2 | 3 | export interface ICompilerHost { 4 | sourceFile: ts.SourceFile; 5 | typeChecker: ts.TypeChecker; 6 | program: ts.Program; 7 | } -------------------------------------------------------------------------------- /packages/convert/src/convert-asllib-to-iasl/__test__/ensure-named-properties.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../convert-ts-to-asllib/__tests__/test-transform"; 2 | import { ensureNamedPropertiesTransformer } from "../ensure-named-properties"; 3 | import { removeUnnecessaryExpressionsTransformer } from "../../convert-ts-to-asllib/transformers/remove-unneccesary-expressionts"; 4 | 5 | describe("when converting unnamed properties", () => { 6 | it("statement becomes invoke", () => { 7 | expect( 8 | testTransform(` 9 | const x = {a, b, c, d:e}; 10 | `, ensureNamedPropertiesTransformer) 11 | ).toMatchInlineSnapshot(`"const x = { a: a, b: b, c: c, d: e };"`); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /packages/convert/src/convert-asllib-to-iasl/__test__/parameters.test.ts: -------------------------------------------------------------------------------- 1 | import { testConvertToIntermediaryAst } from "./test-convert"; 2 | 3 | describe("when converting input parameter reference to iasl", () => { 4 | it("then input parameter is identifier", () => { 5 | const code = ` 6 | asl.pass({parameters: input})`; 7 | const result = testConvertToIntermediaryAst(code, "input"); 8 | expect(result).toMatchInlineSnapshot(` 9 | Object { 10 | "_syntaxKind": "statemachine", 11 | "contextArgumentName": undefined, 12 | "inputArgumentName": Object { 13 | "_syntaxKind": "identifier", 14 | "identifier": "input", 15 | "type": "object", 16 | }, 17 | "statements": Array [ 18 | Object { 19 | "_syntaxKind": "asl-pass-state", 20 | "parameters": Object { 21 | "_syntaxKind": "identifier", 22 | "identifier": "input", 23 | "type": "unknown", 24 | }, 25 | }, 26 | ], 27 | } 28 | `); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/convert/src/convert-asllib-to-iasl/__test__/test-convert.ts: -------------------------------------------------------------------------------- 1 | import { convertToIntermediaryAsl } from '..'; 2 | import { createCompilerHostFromSource } from '../../compiler-host/node'; 3 | import { ConverterOptions } from '../../convert'; 4 | 5 | export const testConvertToIntermediaryAst = (source: string, inputArgumentName: string | undefined = undefined, converterOptions: ConverterOptions = { skipCheckCallables: true }) => { 6 | 7 | const host = createCompilerHostFromSource(source); 8 | 9 | return convertToIntermediaryAsl(host.sourceFile, { converterOptions: converterOptions, typeChecker: host.typeChecker, inputArgumentName }); 10 | } 11 | 12 | describe("dummy", () => { 13 | it("test", () => { }) 14 | }) -------------------------------------------------------------------------------- /packages/convert/src/convert-asllib-to-iasl/ensure-named-properties.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import factory = ts.factory; 3 | 4 | export const ensureNamedPropertiesTransformer = (context: ts.TransformationContext) => (rootNode: T) => { 5 | function visit(node: ts.Node): ts.Node { 6 | node = ts.visitEachChild(node, visit, context); 7 | 8 | // {a, b, c} => {a:a, b:b, c:c} 9 | if (ts.isShorthandPropertyAssignment(node)) { 10 | return factory.createPropertyAssignment(node.name, node.name); 11 | } 12 | 13 | return node; 14 | } 15 | return ts.visitNode(rootNode, visit); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/convert/src/convert-asllib-to-iasl/remove-syntax-transformer.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | 3 | export const removeSyntaxTransformer = (context: ts.TransformationContext) => (rootNode: T) => { 4 | function visit(node: ts.Node): ts.Node { 5 | node = ts.visitEachChild(node, visit, context); 6 | 7 | if (ts.isParenthesizedExpression(node) && ts.isIdentifier(node.expression)) { 8 | return node.expression; 9 | } 10 | 11 | // if (ts.isAwaitExpression(node)) { 12 | // return node.expression; 13 | // } 14 | 15 | if (ts.isAsExpression(node)) { 16 | return node.expression; 17 | } 18 | 19 | return node; 20 | } 21 | return ts.visitNode(rootNode, visit); 22 | }; 23 | -------------------------------------------------------------------------------- /packages/convert/src/convert-iasl-to-asl/__tests__/parameters.test.ts: -------------------------------------------------------------------------------- 1 | import { convert } from ".."; 2 | import { testConvertToIntermediaryAst } from "../../convert-asllib-to-iasl/__test__/test-convert"; 3 | 4 | describe("when converting input parameter reference to asl", () => { 5 | it("then input parameter is identifier", () => { 6 | const code = ` 7 | asl.pass({parameters: input})`; 8 | const iasl = testConvertToIntermediaryAst(code, "input"); 9 | const result = convert(iasl, { skipVersionComment: true }); 10 | expect(result).toMatchInlineSnapshot(` 11 | Object { 12 | "StartAt": "Initialize", 13 | "States": Object { 14 | "Initialize": Object { 15 | "Next": "Pass", 16 | "Parameters": Object { 17 | "_null": null, 18 | "_undefined": null, 19 | "vars.$": "$$.Execution.Input", 20 | }, 21 | "ResultPath": "$", 22 | "Type": "Pass", 23 | }, 24 | "Pass": Object { 25 | "Comment": undefined, 26 | "End": true, 27 | "InputPath": "$.vars", 28 | "ResultPath": null, 29 | "Type": "Pass", 30 | }, 31 | }, 32 | } 33 | `); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /packages/convert/src/convert-iasl-to-asl/aslfactory.fail.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib/src/types"; 3 | import { convertBlock } from "."; 4 | import * as iasl from "../convert-asllib-to-iasl/ast"; 5 | import { AslWriter } from "./asl-writer"; 6 | export class AslFailFactory { 7 | static appendIaslFail(expression: iasl.AslFailState, context: AslWriter, nameSuggestion: string | undefined) { 8 | this.appendAsl( 9 | { 10 | Error: expression.error, 11 | Cause: expression.cause, 12 | Comment: expression.source 13 | }, 14 | context, 15 | nameSuggestion ?? "Fail"); 16 | } 17 | 18 | static appendAsl(fail: Omit, context: AslWriter, nameSuggestion: string) { 19 | context.appendNextState( 20 | { 21 | Type: "Fail", 22 | ...fail, 23 | }, nameSuggestion); 24 | } 25 | } -------------------------------------------------------------------------------- /packages/convert/src/convert-iasl-to-asl/aslfactory.succeed.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as asl from "@ts2asl/asl-lib/src/types"; 3 | import * as iasl from "../convert-asllib-to-iasl/ast"; 4 | import { AslWriter } from "./asl-writer"; 5 | 6 | export class AslSucceedFactory { 7 | static appendIaslSucceed(expression: iasl.AslSucceedState, context: AslWriter, nameSuggestion: string | undefined) { 8 | this.appendAsl( 9 | { 10 | Comment: expression.source 11 | }, 12 | context, 13 | nameSuggestion ?? "Succeed"); 14 | } 15 | 16 | static appendAsl(succeed: Omit, context: AslWriter, nameSuggestion: string) { 17 | context.appendNextState( 18 | { 19 | Type: "Succeed", 20 | ...succeed, 21 | }, nameSuggestion); 22 | } 23 | } -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/__tests__/test-transform.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { createCompilerHostFromSource } from '../../compiler-host/node'; 3 | import { createTransformers } from '../transformers'; 4 | 5 | export const testTransform = (source: string, transformers?: ts.TransformerFactory[] | ts.TransformerFactory) => { 6 | 7 | const printer: ts.Printer = ts.createPrinter(); 8 | 9 | 10 | const host = createCompilerHostFromSource(source); 11 | 12 | const transforms = transformers ? Array.isArray(transformers) ? transformers : [transformers] : createTransformers({}, host); 13 | 14 | const result: ts.TransformationResult = ts.transform( 15 | host.sourceFile, transforms 16 | ); 17 | 18 | const transformedSourceFile: ts.SourceFile = result.transformed[0]; 19 | 20 | const resultPrinted = printer.printFile(transformedSourceFile); 21 | 22 | result.dispose(); 23 | 24 | return resultPrinted.trim(); 25 | } 26 | 27 | describe("dummy", () => { 28 | 29 | it("test", () => { } 30 | ) 31 | }) -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/index.ts: -------------------------------------------------------------------------------- 1 | import ts from "typescript"; 2 | import { ICompilerHost } from "../compiler-host"; 3 | import { ConverterOptions } from "../convert"; 4 | 5 | import { createTransformers } from "./transformers"; 6 | 7 | 8 | export const transformBody = (body: ts.ConciseBody, host: ICompilerHost, converterOptions: ConverterOptions = {}) => { 9 | return ts.transform(body, createTransformers(converterOptions, host)).transformed[0]; 10 | } 11 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/readme.md: -------------------------------------------------------------------------------- 1 | lang-support will transform regular typescript AST constructs (if statement, promise.all) and convert these to ASL concepts ASL.Choice, ASL.Parallel 2 | 3 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/array-length-statement.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | import { arrayLengthTransformer } from "../array-length-statement"; 3 | 4 | describe("when converting array length statements", () => { 5 | it("statement becomes json path", () => { 6 | expect( 7 | testTransform("const x = items.length;", arrayLengthTransformer({})) 8 | ).toMatchInlineSnapshot(`"const x = asl.jsonPathLength(items);"`); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/datetime-stmt.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | 3 | describe("when evaluating new Date()", () => { 4 | it("then call gets replaced with jsonPath expression", () => { 5 | const code = ` 6 | const dateTime = new Date().toISOString(); 7 | `; 8 | const result = testTransform(code); 9 | expect(result).toMatchInlineSnapshot(`"const dateTime = asl.jsonPath(\\"$$.State.EnteredTime\\");"`); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/do-while-statement.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | import { doWhileStatementTransformer } from "../do-while-statement"; 3 | 4 | describe("when converting do-while statements", () => { 5 | it("then do-while statement becomes do-while in ASL", () => { 6 | expect( 7 | testTransform( 8 | "do{ console.log(); ASL.Wait({Seconds: 2})} while (code === 'continue');", 9 | doWhileStatementTransformer({}) 10 | ) 11 | ).toMatchInlineSnapshot(` 12 | "asl.typescriptDoWhile({ 13 | name: \\"Do While (code === 'conti ...\\", 14 | condition: () => code === 'continue', 15 | block: async () => { console.log(); ASL.Wait({ Seconds: 2 }); }, 16 | comment: \\"do{ console.log(); ASL.Wait({Seconds: 2})} while (code === 'continue');\\" 17 | })" 18 | `); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/if-throw-statement.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | import { ifStatementTransformer } from "../if-statement"; 3 | import { throwStatementTransformer } from "../throw-statement"; 4 | 5 | describe("when converting if with throw statements", () => { 6 | it("then both get converted", () => { 7 | expect( 8 | testTransform("if (optIn === false) throw new NotOptedInError('oops');", [ 9 | ifStatementTransformer({}), 10 | throwStatementTransformer({}) 11 | ]) 12 | ).toMatchInlineSnapshot(` 13 | "asl.typescriptIf({ 14 | name: \\"If (optIn === false)\\", 15 | condition: () => optIn === false, 16 | then: async () => { asl.fail({ 17 | name: \\"Throw NotOptedInError\\", 18 | error: \\"NotOptedInError\\", 19 | cause: \\"oops\\", 20 | comment: \\"throw new NotOptedInError('oops');\\" 21 | }) }, 22 | comment: \\"if (optIn === false) throw new NotOptedInError('oops');\\" 23 | })" 24 | `); 25 | }); 26 | 27 | // it("then equals is supported on boolean ", () => { 28 | // expect(testTransform("if (optIn === true) console.log();", ifStatementTransformer)).toMatchInlineSnapshot(); 29 | // }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/null-coalescing-statement.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | import { nullCoalescingStatementTransformer } from "../null-coalescing-statement"; 3 | 4 | describe("when converting null coalescing expression", () => { 5 | it("then result is a conditional", () => { 6 | expect( 7 | testTransform(`const x = y ?? z`, nullCoalescingStatementTransformer({})) 8 | ).toMatchInlineSnapshot(`"const x = y ? y : z;"`); 9 | }); 10 | 11 | it("then literals can be used in lhs", () => { 12 | expect( 13 | testTransform( 14 | `const x = false ?? z`, 15 | nullCoalescingStatementTransformer({}) 16 | ) 17 | ).toMatchInlineSnapshot(`"const x = false ? false : z;"`); 18 | }); 19 | 20 | it("then expressions can be nested in lhs", () => { 21 | expect( 22 | testTransform( 23 | `const x = false ?? false ?? false ?? z`, 24 | nullCoalescingStatementTransformer({}) 25 | ) 26 | ).toMatchInlineSnapshot( 27 | `"const x = ((false ? false : false) ? false ? false : false : false) ? (false ? false : false) ? false ? false : false : false : z;"` 28 | ); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/string-conversion.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | import { ifStatementTransformer } from "../if-statement"; 3 | import { stringConversionTransformer } from "../string-conversion"; 4 | import { throwStatementTransformer } from "../throw-statement"; 5 | 6 | describe("when converting string to number", () => { 7 | it("then call gets transformed to stringToJson", () => { 8 | expect( 9 | testTransform("const x = asl.convert.stringToNumber('42');", [ 10 | stringConversionTransformer 11 | ]) 12 | ).toMatchInlineSnapshot(`"const x = asl.states.stringToJson('42');"`); 13 | }); 14 | }); 15 | 16 | describe("when converting string to boolean", () => { 17 | it("then call gets transformed to stringToJson", () => { 18 | expect( 19 | testTransform("const x = asl.convert.stringToBoolean('true');", [ 20 | stringConversionTransformer 21 | ]) 22 | ).toMatchInlineSnapshot(`"const x = asl.states.stringToJson('true');"`); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/try-statement.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | import { tryStatementTransformer } from "../try-statement"; 3 | 4 | describe("when converting try statements", () => { 5 | it("then both get converted", () => { 6 | expect( 7 | testTransform( 8 | "try { console.log('yay!'); } catch { console.log('nay'); }", 9 | tryStatementTransformer({}) 10 | ) 11 | ).toMatchInlineSnapshot(` 12 | "asl.typescriptTry({ 13 | name: \\"Try Catch\\", 14 | try: async () => { console.log('yay!'); }, 15 | catch: [ 16 | { 17 | errorEquals: [ 18 | \\"States.ALL\\" 19 | ], 20 | block: () => { console.log('nay'); } 21 | } 22 | ], 23 | comment: \\"try { console.log('yay!'); } catch { console.log('nay'); }\\" 24 | })" 25 | `); 26 | }); 27 | 28 | // it("then equals is supported on boolean ", () => { 29 | // expect(testTransform("if (optIn === true) console.log();", ifStatementTransformer)).toMatchInlineSnapshot(); 30 | // }); 31 | }); 32 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/__tests__/while-statement.test.ts: -------------------------------------------------------------------------------- 1 | import { testTransform } from "../../__tests__/test-transform"; 2 | import { whileStatementTransformer } from "../while-statement"; 3 | 4 | describe("when converting while statements", () => { 5 | it("then while statement becomes while in ASL", () => { 6 | expect( 7 | testTransform( 8 | "while(code === 'continue') { console.log(); ASL.Wait({Seconds: 2})}", 9 | whileStatementTransformer({}) 10 | ) 11 | ).toMatchInlineSnapshot(` 12 | "asl.typescriptWhile({ 13 | name: \\"While (code === 'continue')\\", 14 | condition: () => code === 'continue', 15 | block: async () => { console.log(); ASL.Wait({ Seconds: 2 }); }, 16 | comment: \\"while(code === 'continue') { console.log(); ASL.Wait({Seconds: 2})}\\" 17 | })" 18 | `); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/array-initializer.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { ConverterOptions } from '../../convert'; 3 | import { isLiteral } from '../../util'; 4 | const factory = ts.factory; 5 | 6 | 7 | export const resolveExpressionsTransformer = (converterOptions: ConverterOptions) => (context: ts.TransformationContext) => (rootNode: T) => { 8 | function visit(node: ts.Node): ts.Node { 9 | node = ts.visitEachChild(node, visit, context); 10 | if (ts.isVariableDeclaration(node) && node.initializer) { 11 | if (ts.isArrayLiteralExpression(node.initializer)) { 12 | if (!isLiteral(node.initializer, true)) { 13 | return factory.createVariableDeclaration(node.name, node.exclamationToken, node.type, 14 | factory.createCallExpression( 15 | factory.createPropertyAccessExpression( 16 | factory.createPropertyAccessExpression( 17 | factory.createIdentifier("asl"), 18 | factory.createIdentifier("states") 19 | ), 20 | factory.createIdentifier("array") 21 | ), 22 | undefined, 23 | node.initializer.elements 24 | ) 25 | ); 26 | } 27 | } 28 | } 29 | return node; 30 | } 31 | return ts.visitNode(rootNode, visit); 32 | }; 33 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/array-length-statement.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { ConverterOptions } from '../../convert'; 3 | const factory = ts.factory; 4 | 5 | export const arrayLengthTransformer = (converterOptions: ConverterOptions) => (context: ts.TransformationContext) => (rootNode: T) => { 6 | function visit(node: ts.Node): ts.Node { 7 | node = ts.visitEachChild(node, visit, context); 8 | 9 | if (ts.isPropertyAccessExpression(node) && node.name.text === "length") { 10 | 11 | node = factory.createCallExpression( 12 | factory.createPropertyAccessExpression( 13 | factory.createIdentifier("asl"), 14 | factory.createIdentifier("jsonPathLength") 15 | ), 16 | undefined, 17 | [node.expression] 18 | ); 19 | 20 | } 21 | return node; 22 | } 23 | return ts.visitNode(rootNode, visit); 24 | }; 25 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/datetime-stmt.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | const factory = ts.factory; 3 | 4 | 5 | export const newDateTransformer = (context: ts.TransformationContext) => (rootNode: T) => { 6 | function visit(node: ts.Node): ts.Node { 7 | node = ts.visitEachChild(node, visit, context); 8 | 9 | if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isNewExpression(node.expression.expression)) { 10 | if (ts.isIdentifier(node.expression.expression.expression) && node.expression.expression.expression.text === "Date") { 11 | if (ts.isIdentifier(node.expression.name) && node.expression.name.text === "toISOString") { 12 | node = factory.createCallExpression( 13 | factory.createPropertyAccessExpression( 14 | factory.createIdentifier("asl"), 15 | factory.createIdentifier("jsonPath") 16 | ), 17 | undefined, 18 | [factory.createStringLiteral("$$.State.EnteredTime")] 19 | ); 20 | } 21 | } 22 | 23 | } 24 | 25 | return node; 26 | } 27 | return ts.visitNode(rootNode, visit); 28 | }; 29 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/enum-values.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { valueToLiteralExpression } from '../../util'; 3 | import factory = ts.factory; 4 | 5 | export const enumValueTransformer = (typeChecker: ts.TypeChecker) => (context: ts.TransformationContext) => (rootNode: T) => { 6 | function visit(node: ts.Node): ts.Node { 7 | node = ts.visitEachChild(node, visit, context); 8 | if (ts.isPropertyAccessExpression(node)) { 9 | 10 | const type = typeChecker.getTypeAtLocation(node); 11 | if (hasFlag(type, ts.TypeFlags.EnumLiteral)) { 12 | const litType = type as ts.LiteralType; 13 | if (litType.value !== undefined) { 14 | return valueToLiteralExpression(litType.value as string | number); 15 | } 16 | } 17 | return node; 18 | } 19 | return node; 20 | } 21 | return ts.visitNode(rootNode, visit); 22 | }; 23 | function hasFlag(type: ts.Type, flag: ts.TypeFlags) { 24 | return (type.flags & flag) === flag; 25 | } -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/log-statement.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { ConverterOptions } from '../../convert'; 3 | import { TransformUtil } from './transform-utility'; 4 | import factory = ts.factory; 5 | 6 | export const consoleLogStatementTransformer = (converterOptions: ConverterOptions) => (context: ts.TransformationContext) => (rootNode: T) => { 7 | function visit(node: ts.Node): ts.Node { 8 | node = ts.visitEachChild(node, visit, context); 9 | if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === "log") { 10 | 11 | const parameters = TransformUtil.createWrappedExpression("parameters", node.arguments[0]); 12 | const comment = TransformUtil.createCommentPropertyAssignment(node); 13 | const name = TransformUtil.createNamePropertyAssignment(converterOptions, node, "Log (%s)", node.arguments[0] ?? ""); 14 | 15 | const assignments: ts.PropertyAssignment[] = [] 16 | for (const assignment of [name, parameters, comment]) { 17 | if (assignment) { 18 | assignments.push(assignment); 19 | } 20 | } 21 | node = TransformUtil.createAslInvoke("pass", assignments) 22 | return node; 23 | } 24 | return node; 25 | } 26 | return ts.visitNode(rootNode, visit); 27 | }; 28 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/null-coalescing-statement.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { ConverterOptions } from '../../convert'; 3 | import factory = ts.factory; 4 | 5 | 6 | export const nullCoalescingStatementTransformer = (converterOptions: ConverterOptions) => (context: ts.TransformationContext) => (rootNode: T) => { 7 | function visit(node: ts.Node): ts.Node { 8 | node = ts.visitEachChild(node, visit, context); 9 | 10 | if (ts.isBinaryExpression(node)) { 11 | if (node.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken) { 12 | return factory.createConditionalExpression( 13 | node.left, 14 | factory.createToken(ts.SyntaxKind.QuestionToken), 15 | node.left, 16 | factory.createToken(ts.SyntaxKind.ColonToken), 17 | node.right 18 | ); 19 | } 20 | } 21 | return node; 22 | } 23 | return ts.visitNode(rootNode, visit); 24 | }; 25 | -------------------------------------------------------------------------------- /packages/convert/src/convert-ts-to-asllib/transformers/unsupported.ts: -------------------------------------------------------------------------------- 1 | import * as ts from 'typescript'; 2 | import { ConverterOptions } from '../../convert'; 3 | import { ParserError } from '../../ParserError'; 4 | 5 | export const unsupportedStatementTransformer = (converterOptions: ConverterOptions) => (context: ts.TransformationContext) => (rootNode: T) => { 6 | function visit(node: ts.Node): ts.Node { 7 | node = ts.visitEachChild(node, visit, context); 8 | if (ts.isForInStatement(node)) throw new ParserError(`for ... in statement is not supported (for ... of statement is supported!)`, node); 9 | if (ts.isForStatement(node)) throw new ParserError(`for statement is not supported (for ... of statement is supported!)`, node); 10 | if (ts.isSpreadAssignment(node)) throw new ParserError(`spread assignment is not support, see: https://github.com/Stedi/ts2asl/issues/36`, node); 11 | if (ts.isObjectBindingPattern(node)) throw new ParserError(`object binding is not support, see: https://github.com/Stedi/ts2asl/issues/37`, node); 12 | 13 | return node; 14 | } 15 | return ts.visitNode(rootNode, visit); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/convert/src/convert/web.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Converter } from "."; 3 | import { createCompilerHostFromSourceForWeb } from "../compiler-host/web" 4 | 5 | export const convert = (typescriptSource: string, diagnostics: boolean, sdkClients: Record = {}): {} => { 6 | const host = createCompilerHostFromSourceForWeb(typescriptSource, sdkClients); 7 | const converter = new Converter(host); 8 | return converter.convert({ sourceCodeInComments: true, includeDiagnostics: diagnostics ? true : undefined, skipCheckCallables: true }); 9 | } -------------------------------------------------------------------------------- /packages/convert/src/index.ts: -------------------------------------------------------------------------------- 1 | export { Converter, ConverterOptions } from "./convert/index"; 2 | export { createCompilerHostFromFile, createCompilerHostFromSource } from "./compiler-host/node" 3 | -------------------------------------------------------------------------------- /packages/convert/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "noImplicitAny": false, 6 | "resolveJsonModule": true, 7 | "esModuleInterop": true, 8 | "outDir": "./lib", 9 | "strict": true, 10 | "skipLibCheck": true, 11 | "declaration": true 12 | }, 13 | "include": [ 14 | "src" 15 | ], 16 | "exclude": [ 17 | "**/__test__/*" 18 | ] 19 | } -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ], 6 | "stabilityDays": 21, 7 | "major": { 8 | "automerge": false, 9 | "dependencyDashboardApproval": true, 10 | "addLabels": [ 11 | "major-upgrade" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/cdk-tests/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /test/cdk-tests/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | dist -------------------------------------------------------------------------------- /test/cdk-tests/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project 2 | 3 | This is a blank project for CDK development with TypeScript. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | ## Useful commands 8 | 9 | * `npm run build` compile typescript to js 10 | * `npm run watch` watch for changes and compile 11 | * `npm run test` perform the jest unit tests 12 | * `cdk deploy` deploy this stack to your default AWS account/region 13 | * `cdk diff` compare deployed stack with current state 14 | * `cdk synth` emits the synthesized CloudFormation template 15 | -------------------------------------------------------------------------------- /test/cdk-tests/bin/cdk-tests.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import 'source-map-support/register'; 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { CdkV2TestStack } from '../lib/cdk-v2-test-stack'; 5 | import { LocalTestStack } from '../lib/local-test-stack'; 6 | 7 | const app = new cdk.App(); 8 | new CdkV2TestStack(app, "parallel"); 9 | new CdkV2TestStack(app, "nested-stepfunctions"); 10 | new CdkV2TestStack(app, "closures"); 11 | new CdkV2TestStack(app, "hello-world"); 12 | new LocalTestStack(app, "program"); -------------------------------------------------------------------------------- /test/cdk-tests/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node --prefer-ts-exts bin/cdk-tests.ts", 3 | "watch": { 4 | "include": [ 5 | "**" 6 | ], 7 | "exclude": [ 8 | "README.md", 9 | "cdk*.json", 10 | "**/*.d.ts", 11 | "**/*.js", 12 | "tsconfig.json", 13 | "package*.json", 14 | "yarn.lock", 15 | "node_modules", 16 | "test" 17 | ] 18 | }, 19 | "context": { 20 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, 21 | "@aws-cdk/core:stackRelativeExports": true, 22 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true, 23 | "@aws-cdk/aws-lambda:recognizeVersionProps": true, 24 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, 25 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, 26 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, 27 | "@aws-cdk/core:checkSecretUsage": true, 28 | "@aws-cdk/aws-iam:minimizePolicies": true, 29 | "@aws-cdk/core:target-partitions": [ 30 | "aws", 31 | "aws-cn" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/cdk-tests/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | roots: ['/tests'], 3 | testMatch: ['**/*.integration.ts'], 4 | transform: { 5 | '^.+\\.tsx?$': 'ts-jest' 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /test/cdk-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk-tests", 3 | "version": "0.1.0", 4 | "bin": { 5 | "-tests": "bin/-tests.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "cdk": "cdk", 11 | "test:e2e": "npx cdk deploy --all --require-approval never && npx jest && npx cdk destroy --all --require-approval never" 12 | }, 13 | "devDependencies": { 14 | "@aws-sdk/client-sfn": "^3.137.0", 15 | "@types/jest": "^27.5.2", 16 | "@types/node": "10.17.27", 17 | "@types/prettier": "2.6.0", 18 | "aws-cdk": "2.93.0", 19 | "jest": "^27.5.1", 20 | "ts-jest": "^27.1.5", 21 | "ts-node": "^10.9.1", 22 | "typescript": "~3.9.7" 23 | }, 24 | "dependencies": { 25 | "@aws-sdk/client-cloudformation": "^3.137.0", 26 | "@aws-sdk/client-lambda": "^3.137.0", 27 | "@ts2asl/asl-lib": "file:../../packages/asl-lib", 28 | "@ts2asl/cdk-typescript-statemachine": "file:../../packages/cdk", 29 | "@ts2asl/convert": "file:../../packages/convert", 30 | "aws-cdk-lib": "^2.93.0", 31 | "constructs": "^10.1.63", 32 | "esbuild": "^0.14.51", 33 | "source-map-support": "^0.5.21" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/cdk-tests/src/lib/lambda.ts: -------------------------------------------------------------------------------- 1 | export const lambdaImplementation = async (input: {num: number, str: string}) => { 2 | return input; 3 | } -------------------------------------------------------------------------------- /test/cdk-tests/src/program.ts: -------------------------------------------------------------------------------- 1 | import * as asl from "@ts2asl/asl-lib" 2 | import { lambdaImplementation } from "./lib/lambda"; 3 | 4 | export const main = asl.deploy.asStateMachine(async () => { 5 | const result = await lambda({num: 42, str: "hello"}) as {num: number};; 6 | const result2 = await lambda({num: 42, str: "hello"}) as {num: number}; 7 | if (result.num === result2.num) { 8 | return "success" 9 | } 10 | return "failed"; 11 | }); 12 | 13 | 14 | export const lambda = asl.deploy.asLambda(lambdaImplementation); -------------------------------------------------------------------------------- /test/cdk-tests/src/ts2asl.out/program.iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "generated using IAMFast (https://github.com/iann0036/iamfast) and @ts2asl/cdk-typescript-statemachine, version: 0.2.7}", 3 | "Version": "2012-10-17", 4 | "Statement": [ 5 | { 6 | "Effect": "Allow", 7 | "Action": "lambda:InvokeFunction", 8 | "Resource": [ 9 | "arn:aws:lambda:${Token[CDK.REF.REPLACED]}:${Token[CDK.REF.REPLACED]}:function:*" 10 | ] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /test/cdk-tests/tests/local.integration.ts: -------------------------------------------------------------------------------- 1 | import { executeStepFunction } from "../utility"; 2 | jest.setTimeout(99999999); 3 | 4 | describe("when converting local program", () => { 5 | it("will return success", async () => { 6 | const resultFromSfn = await executeStepFunction("program", "main"); 7 | expect(resultFromSfn).toEqual("success"); 8 | }); 9 | }); -------------------------------------------------------------------------------- /test/cdk-tests/tests/parallel.integration.ts: -------------------------------------------------------------------------------- 1 | import { executeStepFunction } from "../utility"; 2 | jest.setTimeout(99999999); 3 | 4 | describe("when converting parallel", () => { 5 | it("will execute simple as if it were node", async () => { 6 | const resultFromSfn = await executeStepFunction("parallel", "simple"); 7 | const { simple } = require("../../../packages/convert/src/__test__/resources/parallel"); 8 | const resultFromNode = await simple({}); 9 | expect(resultFromSfn).toEqual(resultFromNode); 10 | }); 11 | it("will execute enclosedVariables as if it were node", async () => { 12 | const resultFromSfn = await executeStepFunction("parallel", "enclosedVariables"); 13 | const { enclosedVariables } = require("../../../packages/convert/src/__test__/resources/parallel"); 14 | const resultFromNode = await enclosedVariables({}); 15 | expect(resultFromSfn).toEqual(resultFromNode); 16 | }); 17 | }); -------------------------------------------------------------------------------- /test/cdk-tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "ES2018", 5 | "module": "commonjs", 6 | "lib": [ 7 | "es2018" 8 | ], 9 | "outDir": "./dist", 10 | "esModuleInterop": true, 11 | "declaration": true, 12 | "strict": true, 13 | "noImplicitAny": true, 14 | "strictNullChecks": true, 15 | "noImplicitThis": true, 16 | "alwaysStrict": true, 17 | "skipLibCheck": true, 18 | "noUnusedLocals": false, 19 | "noUnusedParameters": false, 20 | "noImplicitReturns": true, 21 | "noFallthroughCasesInSwitch": false, 22 | "inlineSourceMap": true, 23 | "inlineSources": true, 24 | "experimentalDecorators": true, 25 | "strictPropertyInitialization": false 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out", 30 | "dist" 31 | ] 32 | } -------------------------------------------------------------------------------- /tools/convert-test-generator/lib/enum-tests.d.ts: -------------------------------------------------------------------------------- 1 | import { FunctionDeclaration } from "@ts2asl/convert/src/convert/list-function-declarations"; 2 | export declare const enumTests: () => TestFixture[]; 3 | interface TestFixture { 4 | path: string; 5 | fixtureName: string; 6 | enumTestCases: () => TestCase[]; 7 | } 8 | export interface TestCase { 9 | fixtureName: string; 10 | testName: string; 11 | decl: FunctionDeclaration; 12 | } 13 | export {}; 14 | -------------------------------------------------------------------------------- /tools/convert-test-generator/lib/generate-example.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /tools/convert-test-generator/lib/generate-integration-tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /tools/convert-test-generator/lib/generate-unit-tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /tools/convert-test-generator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "convert-test-generator", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "scripts": { 8 | "build": "npx tsc", 9 | "regenerate-all": "export REGEN=true && ts-node generate-example.ts && ts-node generate-integration-tests.ts && ts-node generate-unit-tests && cd ../../packages/convert && npx jest", 10 | "generate-all": "export REGEN=false && ts-node generate-example.ts && ts-node generate-integration-tests.ts && ts-node generate-unit-tests" 11 | }, 12 | "files": [ 13 | "lib/**/*" 14 | ], 15 | "author": "", 16 | "license": "ISC", 17 | "dependencies": { 18 | "@types/change-case": "^2.3.1", 19 | "@types/node": "^17.0.45", 20 | "change-case": "^4.1.2", 21 | "minimist": "^1.2.6", 22 | "prettier": "^2.7.1", 23 | "typescript": "^4.7.4" 24 | }, 25 | "devDependencies": { 26 | "@types/prettier": "2.7.3" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tools/convert-test-generator/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "es2018", 5 | "module": "commonjs", 6 | "lib": [ 7 | "es2018", 8 | "es2019" 9 | ], 10 | "allowJs": true, 11 | "noImplicitAny": true, 12 | "declaration": true, 13 | "esModuleInterop": true, 14 | "outDir": "./lib", 15 | "strict": true, 16 | "resolveJsonModule": true, 17 | }, 18 | "include": [ 19 | "**/*.ts" 20 | ], 21 | } -------------------------------------------------------------------------------- /tools/delete-stepfunctions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "delete-stepfunctions", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@aws-sdk/client-sfn": "^3.363.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/sdk-bundler/bundle-clients.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs"; 2 | import * as sdkClients from "./npm/data/aws-sdk-clients.json"; 3 | import * as dtsb from "dts-bundle"; 4 | 5 | const npmModulesRoot = "./npm/node_modules"; 6 | const clientNames: Array = []; 7 | const moduleNames: Array = []; 8 | 9 | if (!fs.existsSync("./npm/dts")) { 10 | fs.mkdirSync("./npm/dts") 11 | } 12 | 13 | for(const module of Object.values(sdkClients)) { 14 | const moduleDir = npmModulesRoot + "/" + module.name ; 15 | console.log(`bundling: ${module.name}`) 16 | const distTypesDir = moduleDir + "/dist-types" 17 | if (!fs.existsSync(distTypesDir)) continue; 18 | const contents = fs.readdirSync(distTypesDir); 19 | const clientFile = contents.filter(file=>/[a-zA-Z0-9]*?Client.d.ts/.test(file)); 20 | if (clientFile.length !== 1) continue; 21 | const clientName = clientFile[0].substring(0, clientFile[0].length -11) 22 | dtsb.bundle({main: distTypesDir + "/" + clientName + ".d.ts", baseDir: "./" , name: module.name, out: "./npm/dts/" + module.name + ".d.ts"}); 23 | clientNames.push(clientName); 24 | moduleNames.push(module.name) 25 | } 26 | 27 | fs.writeFileSync( "./npm/data/client-names.json", JSON.stringify(clientNames.sort(), null, 2)) 28 | fs.writeFileSync( "./npm/data/module-names.json", JSON.stringify(moduleNames.sort(), null, 2)) -------------------------------------------------------------------------------- /tools/sdk-bundler/create-package-json.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs"; 2 | import * as sdkClients from "./npm/data/aws-sdk-clients.json"; 3 | import * as pjson from "./package.json"; 4 | const dependencies: Record = {} 5 | for(const module of Object.values(sdkClients).map(x=>x.name).filter(x=>!!x)) { 6 | dependencies[module] = "*"; 7 | } 8 | 9 | const copy = {...pjson, dependencies, default: undefined }; 10 | delete copy.default; 11 | 12 | fs.writeFileSync( "./npm/package.json", JSON.stringify(copy, null, 2)) -------------------------------------------------------------------------------- /tools/sdk-bundler/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asl-lib-generator", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "scripts": { 8 | "build": "npx tsc", 9 | "download-aws-sdk-clients": "npm search @aws-sdk/client --json --searchlimit 5000 > npm/data/aws-sdk-clients.json && ts-node create-package-json && cd npm && npm install --verbose", 10 | "bundle": "npx ts-node bundle-clients", 11 | "package-client-names": "cp npm/data/client-names.json ../../packages/convert/src/resources", 12 | "package-client-bundles": "rm -rf ../../../asl-editor-spike/public/sdk-clients/* && cp npm/dts/@aws-sdk/* ../../../asl-editor-spike/public/sdk-clients", 13 | "package": "npm run package-client-names && npm run package-client-bundles " 14 | }, 15 | "files": [ 16 | "lib/**/*" 17 | ], 18 | "engines": { 19 | "npm": ">=8.3.0" 20 | }, 21 | "overrides": { 22 | "minimist@<1.2.6": "^1.2.6" 23 | }, 24 | "author": "", 25 | "license": "ISC", 26 | "dependencies": { 27 | "@types/node": "^17.0.45" 28 | }, 29 | "devDependencies": { 30 | "@types/dts-bundle": "0.0.33", 31 | "dts-bundle": "0.7.3" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tools/sdk-bundler/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "target": "es2018", 5 | "module": "commonjs", 6 | "lib": [ 7 | "es2018", 8 | "es2019" 9 | ], 10 | "allowJs": true, 11 | "noImplicitAny": true, 12 | "declaration": true, 13 | "esModuleInterop": true, 14 | "outDir": "./lib", 15 | "strict": true, 16 | "resolveJsonModule": true, 17 | }, 18 | "include": [ 19 | "**/*.ts" 20 | ], 21 | } -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@ts2asl/asl-lib": [ 6 | "packages/asl-lib" 7 | ], 8 | "@ts2asl/convert": [ 9 | "packages/convert" 10 | ], 11 | "@ts2asl/cdk-typescript-statemachine": [ 12 | "packages/cdk" 13 | ], 14 | "cdk-tests": [ 15 | "test/cdk-tests" 16 | ] 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turborepo.org/schema.json", 3 | "baseBranch": "origin/main", 4 | "pipeline": { 5 | "build": { 6 | "dependsOn": ["^build"] 7 | }, 8 | "test": { 9 | "dependsOn": ["build"] 10 | }, 11 | "test:e2e": { 12 | "dependsOn": ["build"] 13 | }, 14 | "package": { 15 | "dependsOn": ["build"] 16 | }, 17 | "dev": { 18 | "cache": false 19 | } 20 | } 21 | } --------------------------------------------------------------------------------