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 Effect from "effect/Effect"; |
| 2 | import * as GCPBindings from "../GCPBindings.ts"; |
| 3 | import { grantFor, type BindingIam, type GcpHttpOp } from "../HttpBinding.ts"; |
| 4 | import type { ParametersVersion } from "./ParametersVersion.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Shared HTTP scaffolding for Parameter Manager version bindings. |
| 8 | * NOT exported from index.ts. |
| 9 | */ |
| 10 | export const makeParameterVersionHttpBinding = <I, A, E, Req = void>(options: { |
| 11 | tag: string; |
| 12 | iam: BindingIam; |
| 13 | operation: GcpHttpOp<I, A, E>; |
| 14 | toInput: (versionName: string, request: Req | undefined) => I; |
| 15 | }) => |
| 16 | Effect.gen(function* () { |
| 17 | const bind = yield* GCPBindings.Bind; |
| 18 | const run = yield* GCPBindings.withCredentials(options.operation); |
| 19 | return Effect.fn(function* (version: ParametersVersion) { |
| 20 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 21 | yield* bind`${options.tag}(${version})`({ |
| 22 | iam: [grantFor(options.iam, version.name)], |
| 23 | }); |
| 24 | } |
| 25 | const name = yield* version.name; |
| 26 | return Effect.fn(`${options.tag}(${version.LogicalId})`)(function* (request?: Req) { |
| 27 | return yield* run(options.toInput(yield* name, request)); |
| 28 | }); |
| 29 | }); |
| 30 | }); |