@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 59 lines 1.92 KB
Raw
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 { Note } from "./Note.ts";
5 import type { Occurrence } from "./Occurrence.ts";
6
7 /**
8 * Shared HTTP scaffolding for Container Analysis get bindings.
9 * NOT exported from index.ts.
10 */
11 export const makeNoteHttpBinding = <I extends { name?: string }, A, E>(options: {
12 tag: string;
13 iam: BindingIam;
14 operation: GcpHttpOp<I, A, E>;
15 }) =>
16 Effect.gen(function* () {
17 const bind = yield* GCPBindings.Bind;
18 const run = yield* GCPBindings.withCredentials(options.operation);
19 return Effect.fn(function* (note: Note) {
20 if (!globalThis.__ALCHEMY_RUNTIME__) {
21 yield* bind`${options.tag}(${note})`({
22 iam: [grantFor(options.iam, note.name)],
23 });
24 }
25 const name = yield* note.name;
26 return Effect.fn(`${options.tag}(${note.LogicalId})`)(function* (request?: Omit<I, "name">) {
27 return yield* run({
28 ...(request as I),
29 name: yield* name,
30 } as I);
31 });
32 });
33 });
34
35 export const makeOccurrenceHttpBinding = <I extends { name?: string }, A, E>(options: {
36 tag: string;
37 iam: BindingIam;
38 operation: GcpHttpOp<I, A, E>;
39 }) =>
40 Effect.gen(function* () {
41 const bind = yield* GCPBindings.Bind;
42 const run = yield* GCPBindings.withCredentials(options.operation);
43 return Effect.fn(function* (occurrence: Occurrence) {
44 if (!globalThis.__ALCHEMY_RUNTIME__) {
45 yield* bind`${options.tag}(${occurrence})`({
46 iam: [grantFor(options.iam, occurrence.name)],
47 });
48 }
49 const name = yield* occurrence.name;
50 return Effect.fn(`${options.tag}(${occurrence.LogicalId})`)(function* (
51 request?: Omit<I, "name">,
52 ) {
53 return yield* run({
54 ...(request as I),
55 name: yield* name,
56 } as I);
57 });
58 });
59 });