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

main
ts 41 lines 1.45 KB
Raw
1 import { Credentials } from "@distilled.cloud/gcp/Credentials";
2 import * as recommendationengine from "@distilled.cloud/gcp/recommendationengine_v1beta1";
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 type { CatalogsCatalogItem } from "./CatalogsCatalogItem.ts";
8 import { GetCatalogItem, type GetCatalogItemRequest } from "./GetCatalogItem.ts";
9
10 /**
11 * HTTP implementation of {@link GetCatalogItem}.
12 *
13 * @layer
14 * @provides GCP.RecommendationEngine.GetCatalogItem
15 */
16 export const GetCatalogItemHttp: Layer.Layer<
17 GetCatalogItem,
18 never,
19 Credentials | HttpClient.HttpClient
20 > = Layer.effect(
21 GetCatalogItem,
22 Effect.gen(function* () {
23 const bind = yield* GCPBindings.Bind;
24 const run = yield* GCPBindings.withCredentials(
25 recommendationengine.getProjectsLocationsCatalogsCatalogItems,
26 );
27 return Effect.fn(function* (item: CatalogsCatalogItem) {
28 if (!globalThis.__ALCHEMY_RUNTIME__) {
29 yield* bind`GCP.RecommendationEngine.GetCatalogItem(${item})`({
30 iam: [{ role: "roles/automlrecommendations.viewer" }],
31 });
32 }
33 const name = yield* item.name;
34 return Effect.fn(`GCP.RecommendationEngine.GetCatalogItem(${item.LogicalId})`)(function* (
35 _request?: GetCatalogItemRequest,
36 ) {
37 return yield* run({ name: yield* name });
38 });
39 });
40 }),
41 );