@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 36 lines 1.3 KB
Raw
1 import * as polly from "@distilled.cloud/aws/polly";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as AWSBindings from "../AWSBindings.ts";
5 import { GetLexicon } from "./GetLexicon.ts";
6 import type { Lexicon } from "./Lexicon.ts";
7
8 // GetLexicon is one of the few Polly actions with resource-level IAM (the
9 // `lexicon` resource type), so the grant is scoped to the lexicon's ARN
10 // rather than `*` — that's why this binding is bespoke instead of a
11 // makePollyHttpBinding thin call.
12 export const GetLexiconHttp = Layer.effect(
13 GetLexicon,
14 Effect.gen(function* () {
15 const bind = yield* AWSBindings.Bind;
16 const getLexicon = yield* AWSBindings.withCredentials(polly.getLexicon);
17
18 return Effect.fn(function* <L extends Lexicon>(lexicon: L) {
19 const Name = yield* lexicon.lexiconName;
20 if (!globalThis.__ALCHEMY_RUNTIME__) {
21 yield* bind`AWS.Polly.GetLexicon(${lexicon})`({
22 policyStatements: [
23 {
24 Effect: "Allow",
25 Action: ["polly:GetLexicon"],
26 Resource: [lexicon.lexiconArn],
27 },
28 ],
29 });
30 }
31 return Effect.fn(`AWS.Polly.GetLexicon(${lexicon.LogicalId})`)(function* () {
32 return yield* getLexicon({ Name: yield* Name });
33 });
34 });
35 }),
36 );