1import type * as amplify from "@distilled.cloud/aws/amplify";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { App } from "./App.ts";
5
6export interface StartJobRequest extends Omit<
7 amplify.StartJobRequest,
8 "appId"
9> {}
10
11/**
12 * Runtime binding for `amplify:StartJob`.
13 *
14 * Bind an {@link App} in the function's init phase to get a callable that
15 * starts a build/deploy job for one of the app's branches — the app id is
16 * injected automatically and `amplify:StartJob` is granted on the app's jobs.
17 * Provide the implementation with `Effect.provide(AWS.Amplify.StartJobHttp)`.
18 *
19 * The canonical use is a webhook Lambda that rebuilds the site when upstream
20 * content changes (a CMS publish, a data refresh, etc.).
21 * ### Starting Jobs
22 * **Example:** Rebuild a Branch on Content Change
23 * ```typescript
24 * // init — bind the operation to the app
25 * const startJob = yield* AWS.Amplify.StartJob(app);
26 *
27 * // runtime — kick off a release of the main branch
28 * const { jobSummary } = yield* startJob({
29 * branchName: "main",
30 * jobType: "RELEASE",
31 * jobReason: "CMS content published",
32 * });
33 * ```
34 *
35 * @binding
36 */
37export interface StartJob extends Binding.Service<
38 StartJob,
39 "AWS.Amplify.StartJob",
40 (
41 app: App,
42 ) => Effect.Effect<
43 (
44 request: StartJobRequest,
45 ) => Effect.Effect<amplify.StartJobResult, amplify.StartJobError>
46 >
47> {}
48
49export const StartJob = Binding.Service<StartJob>("AWS.Amplify.StartJob");