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, 06:00 UTC
| 1 | import * as ag from "@distilled.cloud/aws/api-gateway"; |
| 2 | import * as Output from "alchemy/Output"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as Layer from "effect/Layer"; |
| 5 | import * as AWSBindings from "../AWSBindings.ts"; |
| 6 | import { RegisterApiGatewayBinding } from "./BindingHttp.ts"; |
| 7 | import { GetUsagePlanKeys, type GetUsagePlanKeysRequest } from "./GetUsagePlanKeys.ts"; |
| 8 | import type { UsagePlan } from "./UsagePlan.ts"; |
| 9 | |
| 10 | /** |
| 11 | * HTTP implementation of the {@link GetUsagePlanKeys} binding. Grants |
| 12 | * `apigateway:GET` on the plan's `/keys` path and calls the API with the |
| 13 | * host Function's credentials. |
| 14 | */ |
| 15 | export const GetUsagePlanKeysHttp = Layer.effect( |
| 16 | GetUsagePlanKeys, |
| 17 | Effect.gen(function* () { |
| 18 | const registerApiGatewayBinding = yield* RegisterApiGatewayBinding; |
| 19 | const getUsagePlanKeys = yield* AWSBindings.withCredentials(ag.getUsagePlanKeys); |
| 20 | return Effect.fn(function* <P extends UsagePlan>(usagePlan: P) { |
| 21 | const UsagePlanId = yield* usagePlan.id; |
| 22 | yield* registerApiGatewayBinding({ |
| 23 | cap: "AWS.ApiGateway.GetUsagePlanKeys", |
| 24 | target: usagePlan, |
| 25 | verb: "GET", |
| 26 | paths: (region) => [ |
| 27 | Output.interpolate`arn:aws:apigateway:${region}::/usageplans/${usagePlan.id}/keys`, |
| 28 | ], |
| 29 | }); |
| 30 | return Effect.fn(`AWS.ApiGateway.GetUsagePlanKeys(${usagePlan.LogicalId})`)(function* ( |
| 31 | request?: GetUsagePlanKeysRequest, |
| 32 | ) { |
| 33 | return yield* getUsagePlanKeys({ |
| 34 | ...request, |
| 35 | usagePlanId: yield* UsagePlanId, |
| 36 | }); |
| 37 | }); |
| 38 | }); |
| 39 | }), |
| 40 | ); |