| 1 | import type * as amplify from "@distilled.cloud/aws/amplify"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { App } from "./App.ts"; |
| 5 | |
| 6 | export interface GetJobRequest extends Omit<amplify.GetJobRequest, "appId"> {} |
| 7 | |
| 8 | /** |
| 9 | * Runtime binding for `amplify:GetJob`. |
| 10 | * |
| 11 | * Bind an {@link App} in the function's init phase to get a callable that |
| 12 | * reads a build job — its summary and per-step logs/status — for one of the |
| 13 | * app's branches. Provide the implementation with |
| 14 | * `Effect.provide(AWS.Amplify.GetJobHttp)`. |
| 15 | * ### Observing Jobs |
| 16 | * **Example:** Poll a Job Until It Settles |
| 17 | * ```typescript |
| 18 | * // init — bind the operation to the app |
| 19 | * const getJob = yield* AWS.Amplify.GetJob(app); |
| 20 | * |
| 21 | * // runtime — read the job's current status |
| 22 | * const { job } = yield* getJob({ branchName: "main", jobId: "42" }); |
| 23 | * if (job.summary.status === "FAILED") { |
| 24 | * yield* Effect.log(`build failed: ${job.summary.jobId}`); |
| 25 | * } |
| 26 | * ``` |
| 27 | * |
| 28 | * @binding |
| 29 | */ |
| 30 | export interface GetJob extends Binding.Service< |
| 31 | GetJob, |
| 32 | "AWS.Amplify.GetJob", |
| 33 | ( |
| 34 | app: App, |
| 35 | ) => Effect.Effect< |
| 36 | ( |
| 37 | request: GetJobRequest, |
| 38 | ) => Effect.Effect<amplify.GetJobResult, amplify.GetJobError> |
| 39 | > |
| 40 | > {} |
| 41 | |
| 42 | export const GetJob = Binding.Service<GetJob>("AWS.Amplify.GetJob"); |