The best way to control Claude Code, Codex and more from any computer or phone

main
ts 39 lines 1.39 KB
Raw
1 import { Credentials } from "@distilled.cloud/gcp/Credentials";
2 import * as storagetransfer from "@distilled.cloud/gcp/storagetransfer_v1";
3 import * as Effect from "effect/Effect";
4 import * as HttpClient from "effect/http/HttpClient";
5 import * as Layer from "effect/Layer";
6 import * as GCPBindings from "../GCPBindings.ts";
7 import { GetGoogleServiceAccount } from "./GetGoogleServiceAccount.ts";
8 import type { TransferJob } from "./TransferJob.ts";
9
10 /**
11 * HTTP implementation of {@link GetGoogleServiceAccount}.
12 *
13 * @layer
14 * @provides GCP.StorageTransfer.GetGoogleServiceAccount
15 */
16 export const GetGoogleServiceAccountHttp: Layer.Layer<
17 GetGoogleServiceAccount,
18 never,
19 Credentials | HttpClient.HttpClient
20 > = Layer.effect(
21 GetGoogleServiceAccount,
22 Effect.gen(function* () {
23 const bind = yield* GCPBindings.Bind;
24 const run = yield* GCPBindings.withCredentials(storagetransfer.getGoogleServiceAccounts);
25 return Effect.fn(function* (job: TransferJob) {
26 if (!globalThis.__ALCHEMY_RUNTIME__) {
27 yield* bind`GCP.StorageTransfer.GetGoogleServiceAccount(${job})`({
28 iam: [{ role: "roles/storagetransfer.viewer" }],
29 });
30 }
31 const project = yield* job.project;
32 return Effect.fn(`GCP.StorageTransfer.GetGoogleServiceAccount(${job.LogicalId})`)(
33 function* () {
34 return yield* run({ projectId: yield* project });
35 },
36 );
37 });
38 }),
39 );