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 obs from "@distilled.cloud/aws/observabilityadmin"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as AWSBindings from "../AWSBindings.ts"; |
| 5 | import { GetTelemetryRule } from "./GetTelemetryRule.ts"; |
| 6 | import type { TelemetryRule } from "./TelemetryRule.ts"; |
| 7 | |
| 8 | /** |
| 9 | * HTTP implementation of {@link GetTelemetryRule}: grants |
| 10 | * `observabilityadmin:GetTelemetryRule` on the bound rule's ARN and calls |
| 11 | * the Observability Admin HTTP API with the function's IAM credentials, |
| 12 | * injecting the rule's name as the `RuleIdentifier`. |
| 13 | */ |
| 14 | export const GetTelemetryRuleHttp = Layer.effect( |
| 15 | GetTelemetryRule, |
| 16 | Effect.gen(function* () { |
| 17 | const bind = yield* AWSBindings.Bind; |
| 18 | const getTelemetryRule = yield* AWSBindings.withCredentials(obs.getTelemetryRule); |
| 19 | |
| 20 | return Effect.fn(function* (rule: TelemetryRule) { |
| 21 | const RuleIdentifier = yield* rule.ruleName; |
| 22 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 23 | yield* bind`AWS.ObservabilityAdmin.GetTelemetryRule(${rule})`({ |
| 24 | policyStatements: [ |
| 25 | { |
| 26 | Effect: "Allow", |
| 27 | Action: ["observabilityadmin:GetTelemetryRule"], |
| 28 | Resource: [rule.ruleArn], |
| 29 | }, |
| 30 | ], |
| 31 | }); |
| 32 | } |
| 33 | return Effect.fn(`AWS.ObservabilityAdmin.GetTelemetryRule(${rule.LogicalId})`)(function* () { |
| 34 | return yield* getTelemetryRule({ |
| 35 | RuleIdentifier: yield* RuleIdentifier, |
| 36 | }); |
| 37 | }); |
| 38 | }); |
| 39 | }), |
| 40 | ); |