| 1 | import type * as appflow from "@distilled.cloud/aws/appflow"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Flow } from "./Flow.ts"; |
| 5 | |
| 6 | export interface StartFlowRequest extends Omit< |
| 7 | appflow.StartFlowRequest, |
| 8 | "flowName" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `appflow:StartFlow`. |
| 13 | * |
| 14 | * Bind this operation to a {@link Flow} in the function's init phase to get a |
| 15 | * callable that activates the flow — for on-demand flows this triggers a |
| 16 | * single run and returns its `executionId`; for schedule and event-triggered |
| 17 | * flows it activates the flow. The flow name is injected automatically and |
| 18 | * `appflow:StartFlow` is granted on the flow. Provide the implementation with |
| 19 | * `Effect.provide(AWS.AppFlow.StartFlowHttp)`. |
| 20 | * ### Running Flows |
| 21 | * **Example:** Start an On-Demand Flow Run from a Handler |
| 22 | * ```typescript |
| 23 | * export default MyFunction.make( |
| 24 | * { main: import.meta.url, functionUrl: true }, |
| 25 | * Effect.gen(function* () { |
| 26 | * const flow = yield* AWS.AppFlow.Flow("CopyFlow", { ... }); |
| 27 | * // init — bind the operation to the flow |
| 28 | * const startFlow = yield* AWS.AppFlow.StartFlow(flow); |
| 29 | * |
| 30 | * return { |
| 31 | * fetch: Effect.gen(function* () { |
| 32 | * // runtime — trigger a run |
| 33 | * const run = yield* startFlow(); |
| 34 | * return HttpServerResponse.json({ executionId: run.executionId }); |
| 35 | * }).pipe(Effect.orDie), |
| 36 | * }; |
| 37 | * }).pipe(Effect.provide(AWS.AppFlow.StartFlowHttp)), |
| 38 | * ); |
| 39 | * ``` |
| 40 | * |
| 41 | * @binding |
| 42 | */ |
| 43 | export interface StartFlow extends Binding.Service< |
| 44 | StartFlow, |
| 45 | "AWS.AppFlow.StartFlow", |
| 46 | ( |
| 47 | flow: Flow, |
| 48 | ) => Effect.Effect< |
| 49 | ( |
| 50 | request?: StartFlowRequest, |
| 51 | ) => Effect.Effect<appflow.StartFlowResponse, appflow.StartFlowError> |
| 52 | > |
| 53 | > {} |
| 54 | |
| 55 | export const StartFlow = Binding.Service<StartFlow>("AWS.AppFlow.StartFlow"); |