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

main
ts 42 lines 1.52 KB
Raw
1 import * as firebaserules from "@distilled.cloud/gcp/firebaserules_v1";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as GCPBindings from "../GCPBindings.ts";
5 import { GetReleaseExecutable, type GetReleaseExecutableRequest } from "./GetReleaseExecutable.ts";
6 import type { Release } from "./Release.ts";
7
8 /**
9 * HTTP implementation of {@link GetReleaseExecutable}.
10 *
11 * Grants `roles/firebaserules.admin` on the project because it is the
12 * narrowest predefined role containing `firebaserules.releases.getExecutable`, and Firebase
13 * Rules has no resource-level IAM.
14 *
15 * @layer
16 * @provides GCP.FirebaseRules.GetReleaseExecutable
17 */
18 export const GetReleaseExecutableHttp = Layer.effect(
19 GetReleaseExecutable,
20 Effect.gen(function* () {
21 const bind = yield* GCPBindings.Bind;
22 const getExecutableProjectsReleases = yield* GCPBindings.withCredentials(
23 firebaserules.getExecutableProjectsReleases,
24 );
25 return Effect.fn(function* (release: Release) {
26 if (!globalThis.__ALCHEMY_RUNTIME__) {
27 yield* bind`GCP.FirebaseRules.GetReleaseExecutable(${release})`({
28 iam: [{ role: "roles/firebaserules.admin" }],
29 });
30 }
31 const name = yield* release.name;
32 return Effect.fn(`GCP.FirebaseRules.GetReleaseExecutable(${release.LogicalId})`)(function* (
33 request: GetReleaseExecutableRequest = {},
34 ) {
35 return yield* getExecutableProjectsReleases({
36 ...request,
37 name: yield* name,
38 });
39 });
40 });
41 }),
42 );