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

main
ts 38 lines 1.2 KB
Raw
1 import * as pubsub from "@distilled.cloud/gcp/pubsub_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 { GetSchema, type GetSchemaRequest } from "./GetSchema.ts";
7 import type { Schema } from "./Schema.ts";
8
9 /**
10 * HTTP implementation of {@link GetSchema}.
11 *
12 * @layer
13 * @provides GCP.PubSub.GetSchema
14 */
15 export const GetSchemaHttp = Layer.effect(
16 GetSchema,
17 Effect.gen(function* () {
18 const bind = yield* GCPBindings.Bind;
19 const getSchema = yield* GCPBindings.withCredentials(pubsub.getProjectsSchemas);
20 return Effect.fn(function* (schema: Schema) {
21 if (!globalThis.__ALCHEMY_RUNTIME__) {
22 yield* bind`GCP.PubSub.GetSchema(${schema})`({
23 iam: [grantFor({ role: "roles/pubsub.viewer", on: "pubsub.schema" }, schema.name)],
24 });
25 }
26 const name = yield* schema.name;
27 return Effect.fn(`GCP.PubSub.GetSchema(${schema.LogicalId})`)(function* (
28 request?: GetSchemaRequest,
29 ) {
30 return yield* getSchema({
31 view: "FULL",
32 ...request,
33 name: yield* name,
34 });
35 });
36 });
37 }),
38 );