import { IntegrationExecutionContext, IntegrationExecutionResult, IntegrationJobKey } from './execution'; import { IntegrationInvocationContext, IntegrationInvocationEvent } from './invocation'; /** * Input provided to the state machine starting state. */ export interface IntegrationStateMachineInvocationEvent extends IntegrationInvocationEvent { /** * The `IntegrationJobKey` created at integration invocation start time. This * must be the job key used throughout the execution of the state machine. */ jobKey: IntegrationJobKey; /** * States used by the state machine to manage step execution. * * These values are not necessarily delivered to the * `IntegrationStepExecutionHandler`, but are intended to be used by the state * machine for step execution decisions. */ stepStates: IntegrationStepStartStates; } /** * Input provided to the state machine ending state. */ export interface IntegrationStateMachineEndEvent extends IntegrationInvocationEvent { /** * The `IntegrationJobKey` created at integration invocation start time. This * must be the job key used throughout the execution of the state machine. */ jobKey: IntegrationJobKey; } /** * Input provided to a state machine step. * * Integrations should expect this type to be delivered to each step and may * extend this to include additional properties that will be delivered IF * preceding steps add any additional properties. * * Do not use these events to carry large payloads, only identifiers for looking * up large payloads between steps. There is a limit to what can be transmitted * between states! */ export interface IntegrationStepInvocationEvent extends IntegrationInvocationEvent { /** * The `IntegrationJobKey` created at integration invocation start time. This * must be the job key used throughout the execution of the state machine. */ jobKey: IntegrationJobKey; /** * The id of the integration step to execute. */ stepId: string; /** * The name of the integration step to execute. */ stepName: string; /** * Steps that support iteration will receive state for iterating. */ iterationState?: IntegrationStepIterationState; } /** * Input provided to a state machine step's failure state. */ export interface IntegrationStepFailureEvent extends IntegrationStepInvocationEvent { /** * The error object produced by the step's execution state. */ error: IntegrationStepError; } /** * The result returned from the execution of an integration process step. */ export declare type IntegrationStepExecutionResult = IntegrationExecutionResult | IntegrationStepIterationState; /** * State machine state for a step, used by the state machine itself to manage * execution of the step. */ export interface IntegrationStepState { /** * Indicates the step is disabled and should not be executed by the state * machine. */ disabled: boolean; } /** * The error included in the result of the step's execution state if any error * occurred. */ export interface IntegrationStepError { /** * Indicates the type of the error. * * States.TaskFailed is Step Functions' default, catch-all error. In our case, * it means that the error came from ECS, since ECS does not return a data * structure that the state machine can interpret beyond success or failure. * * logged_error_executing is the name of the error thrown by the execution * state. This is the type of the step execution state error only if the * execution state ran in Lambda, since Lambda returns the error in a data * structure that the state machine can easily interpret and pass to the * failure state. * * Lambda.Unknown is Step Functions' default, catch-all error for Lambda * responses that it cannot interpret. Likely it means that the Lambda timed * out. */ Error: 'States.TaskFailed' | 'logged_error_executing' | 'Lambda.Unknown'; /** * The full body of the error. If the error is returned from ECS, it includes * the configuration of the ECS container and its exit code. If the error is * returned from Lambda, it includes the error message and a basic stack * trace. */ Cause: string; } /** * State maintained by steps that support iteration. This structure is provided * to the `executionHandler` of a step having a config of `iterates: true`. */ export interface IntegrationStepIterationState { /** * The current iteration, zero based. The `executionHandler` may inspect the * `iteration` to see that `0` means it is operating on the the first * invocation, etc. */ iteration: number; /** * When the `executionHandler` determines that iteration is finished, it must * return with `finished: true`. */ finished: boolean; /** * The integration-specific iteration state maintained by the step * `executionHandler`. The first invocation will have `finished: false, state: * {}`. */ state: { [key: string]: any; }; } /** * Contains the starting states for steps of an integration, keyed by the step * `id` property. These states are used by the state machine itself to manage * execution of steps. */ export declare type IntegrationStepStartStates = Record; /** * An extension of `IntegrationInvocationContext` providing the ARN of the Step * Functions state machine to start. */ export interface IntegrationStepFunctionsStartContext extends IntegrationInvocationContext { /** * The ARN of the Step Functions state machine. */ readonly stepFunctionArn: string; readonly getIntegrationStepStartStates: GetIntegrationStepStartStates; } export interface IntegrationStepFunctionsEndContext extends IntegrationInvocationContext { event: IntegrationStateMachineEndEvent; } export interface IntegrationStepInvocationContext extends IntegrationInvocationContext { event: IntegrationStepInvocationEvent; stepConfig: IntegrationStepConfiguration; } export interface IntegrationStepExecutionContext extends IntegrationExecutionContext { event: IntegrationStepInvocationEvent; stepConfig: IntegrationStepConfiguration; } /** * An integration function that serves as the entry point of implementing a step * of the integration. */ export interface IntegrationStepExecutionHandler { (context: IntegrationStepExecutionContext): Promise; } export interface GetIntegrationStepStartStates { (executionContext: IntegrationExecutionContext): IntegrationStepStartStates; } /** * A phase of executing integration steps in the runtime environment of an * integration. Each phase will run in sequence, and all the steps in a phase * are run in parallel. */ export interface IntegrationStepPhase { steps: IntegrationStepConfiguration[]; } /** * Configuration for an integration step. */ export interface IntegrationStepConfiguration { /** * Identifies the step, used in the state machine to reference the step. The * value should be meaninful, but should remain stable. */ id: string; /** * The name of the step for presentation. This can be easily changed to suit * today's preferences. */ name: string; executionHandler: IntegrationStepExecutionHandler; /** * Indicates the `executionHandler` iterates. This must be `true` or the * system will not invoke the exection handler as expected. An * `executionHandler` capable of iterating, in order to actually iterate, must * also return a proper `IntegrationStepExecutionResult.iterationState`. */ iterates?: boolean; }