@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 47 lines 1.47 KB
Raw
1 import * as servicedirectory from "@distilled.cloud/gcp/servicedirectory_v1";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as GCPBindings from "../GCPBindings.ts";
5 import { grantFor } from "../HttpBinding.ts";
6 import { Resolve, type ResolveRequest } from "./Resolve.ts";
7 import type { Service } from "./Service.ts";
8
9 /**
10 * HTTP implementation of {@link Resolve}.
11 *
12 * @layer
13 * @provides GCP.ServiceDirectory.Resolve
14 */
15 export const ResolveHttp = Layer.effect(
16 Resolve,
17 Effect.gen(function* () {
18 const bind = yield* GCPBindings.Bind;
19 const resolveProjectsLocationsNamespacesServices = yield* GCPBindings.withCredentials(
20 servicedirectory.resolveProjectsLocationsNamespacesServices,
21 );
22 return Effect.fn(function* <S extends Service>(service: S) {
23 if (!globalThis.__ALCHEMY_RUNTIME__) {
24 yield* bind`GCP.ServiceDirectory.Resolve(${service})`({
25 iam: [
26 grantFor(
27 {
28 role: "roles/servicedirectory.viewer",
29 on: "servicedirectory.service",
30 },
31 service.name,
32 ),
33 ],
34 });
35 }
36 const name = yield* service.name;
37 return Effect.fn(`GCP.ServiceDirectory.Resolve(${service.LogicalId})`)(function* (
38 request?: ResolveRequest,
39 ) {
40 return yield* resolveProjectsLocationsNamespacesServices({
41 ...request,
42 name: yield* name,
43 });
44 });
45 });
46 }),
47 );