sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ Amplify/ GetJob.ts

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

export interface GetJobRequest extends Omit<amplify.GetJobRequest, "appId"> {}

/**
 * Runtime binding for `amplify:GetJob`.
 *
 * Bind an {@link App} in the function's init phase to get a callable that
 * reads a build job — its summary and per-step logs/status — for one of the
 * app's branches. Provide the implementation with
 * `Effect.provide(AWS.Amplify.GetJobHttp)`.
 * ### Observing Jobs
 * **Example:** Poll a Job Until It Settles
 * ```typescript
 * // init — bind the operation to the app
 * const getJob = yield* AWS.Amplify.GetJob(app);
 *
 * // runtime — read the job's current status
 * const { job } = yield* getJob({ branchName: "main", jobId: "42" });
 * if (job.summary.status === "FAILED") {
 *   yield* Effect.log(`build failed: ${job.summary.jobId}`);
 * }
 * ```
 *
 * @binding
 */
export interface GetJob extends Binding.Service<
  GetJob,
  "AWS.Amplify.GetJob",
  (
    app: App,
  ) => Effect.Effect<
    (request: GetJobRequest) => Effect.Effect<amplify.GetJobResult, amplify.GetJobError>
  >
> {}

export const GetJob = Binding.Service<GetJob>("AWS.Amplify.GetJob");