sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ StepFunctions/ StopExecution.ts

import type * as sfn from "@distilled.cloud/aws/sfn";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";
import type { StateMachine } from "./StateMachine.ts";

export interface StopExecutionRequest extends sfn.StopExecutionInput {}

/**
 * Runtime binding for `states:StopExecution`.
 *
 * Bind this operation to a {@link StateMachine} inside a function runtime to
 * cancel that machine's running executions. Not supported by `EXPRESS`
 * workflows.
 * ### Stopping Executions
 * **Example:** Cancel a running execution
 * ```typescript
 * const stopExecution = yield* StepFunctions.StopExecution(machine);
 *
 * yield* stopExecution({
 *   executionArn,
 *   error: "OrderCancelled",
 *   cause: "user requested cancellation",
 * });
 * ```
 *
 * @binding
 */
export interface StopExecution extends Binding.Service<
  StopExecution,
  "AWS.StepFunctions.StopExecution",
  (
    stateMachine: StateMachine,
  ) => Effect.Effect<
    (
      request: StopExecutionRequest,
    ) => Effect.Effect<sfn.StopExecutionOutput, sfn.StopExecutionError>
  >
> {}
export const StopExecution = Binding.Service<StopExecution>("AWS.StepFunctions.StopExecution");