@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 41 lines 1.28 KB
Raw
1 import type { Output } from "alchemy/Output";
2 import * as Effect from "effect/Effect";
3 import * as GCPBindings from "../GCPBindings.ts";
4 import { type BindingIam, type GcpHttpOp } from "../HttpBinding.ts";
5
6 /**
7 * Shared HTTP scaffolding for Oracle Database@Google Cloud bindings.
8 * NOT exported from index.ts.
9 */
10 export const makeOracleNameHttpBinding = <
11 Resource extends {
12 readonly name: Output<string, never>;
13 readonly LogicalId: string;
14 },
15 I extends { name?: string },
16 A,
17 E,
18 >(options: {
19 tag: string;
20 /** Oracle Database@Google Cloud has no resource-level IAM: project grant. */
21 iam: Pick<BindingIam, "role">;
22 operation: GcpHttpOp<I, A, E>;
23 }) =>
24 Effect.gen(function* () {
25 const bind = yield* GCPBindings.Bind;
26 const run = yield* GCPBindings.withCredentials(options.operation);
27 return Effect.fn(function* (resource: Resource) {
28 if (!globalThis.__ALCHEMY_RUNTIME__) {
29 yield* bind`${options.tag}(${resource})`({ iam: [{ role: options.iam.role }] });
30 }
31 const name = yield* resource.name;
32 return Effect.fn(`${options.tag}(${resource.LogicalId})`)(function* (
33 request?: Omit<I, "name">,
34 ) {
35 return yield* run({
36 ...(request as I),
37 name: yield* name,
38 } as I);
39 });
40 });
41 });