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
| 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 type { Schema } from "./Schema.ts"; |
| 6 | import { ValidateMessage, type ValidateMessageRequest } from "./ValidateMessage.ts"; |
| 7 | |
| 8 | /** |
| 9 | * HTTP implementation of {@link ValidateMessage}. |
| 10 | * |
| 11 | * @layer |
| 12 | * @provides GCP.PubSub.ValidateMessage |
| 13 | */ |
| 14 | export const ValidateMessageHttp = Layer.effect( |
| 15 | ValidateMessage, |
| 16 | Effect.gen(function* () { |
| 17 | const bind = yield* GCPBindings.Bind; |
| 18 | const validate = yield* GCPBindings.withCredentials(pubsub.validateMessageProjectsSchemas); |
| 19 | return Effect.fn(function* (schema: Schema) { |
| 20 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 21 | yield* bind`GCP.PubSub.ValidateMessage(${schema})`({ |
| 22 | // schemas.validate is checked on the parent project, not the schema. |
| 23 | iam: [{ role: "roles/pubsub.viewer" }], |
| 24 | }); |
| 25 | } |
| 26 | const name = yield* schema.name; |
| 27 | const project = yield* schema.project; |
| 28 | return Effect.fn(`GCP.PubSub.ValidateMessage(${schema.LogicalId})`)(function* ( |
| 29 | request: ValidateMessageRequest, |
| 30 | ) { |
| 31 | return yield* validate({ |
| 32 | parent: `projects/${yield* project}`, |
| 33 | body: { |
| 34 | ...request, |
| 35 | name: yield* name, |
| 36 | }, |
| 37 | }); |
| 38 | }); |
| 39 | }); |
| 40 | }), |
| 41 | ); |