| 1 | import * as appsignals from "@distilled.cloud/aws/application-signals"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import { isBindingHost } from "../Lambda/Function.ts"; |
| 6 | import { GetInstrumentationConfigurationStatus } from "./GetInstrumentationConfigurationStatus.ts"; |
| 7 | import type { InstrumentationConfiguration } from "./InstrumentationConfiguration.ts"; |
| 8 | |
| 9 | /** |
| 10 | * Bespoke implementation (not built on the shared scaffolding): the runtime |
| 11 | * callable injects the bound configuration's full identity — the |
| 12 | * type/service/environment/signal quadruple plus the location hash — |
| 13 | * rather than a single identifier field. |
| 14 | */ |
| 15 | export const GetInstrumentationConfigurationStatusHttp = Layer.effect( |
| 16 | GetInstrumentationConfigurationStatus, |
| 17 | Effect.gen(function* () { |
| 18 | const op = yield* appsignals.getInstrumentationConfigurationStatus; |
| 19 | const tag = "AWS.ApplicationSignals.GetInstrumentationConfigurationStatus"; |
| 20 | |
| 21 | return Effect.fn(function* (configuration: InstrumentationConfiguration) { |
| 22 | const InstrumentationType = yield* configuration.instrumentationType; |
| 23 | const Service = yield* configuration.service; |
| 24 | const Environment = yield* configuration.environment; |
| 25 | const SignalType = yield* configuration.signalType; |
| 26 | const LocationHash = yield* configuration.locationHash; |
| 27 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 28 | const host = yield* Binding.Host; |
| 29 | if (isBindingHost(host)) { |
| 30 | yield* host.bind`Allow(${host}, ${tag}(${configuration}))`({ |
| 31 | policyStatements: [ |
| 32 | { |
| 33 | Effect: "Allow", |
| 34 | Action: [ |
| 35 | "application-signals:GetInstrumentationConfigurationStatus", |
| 36 | ], |
| 37 | // The dynamic-instrumentation actions do not document |
| 38 | // resource-level permission support. |
| 39 | Resource: ["*"], |
| 40 | }, |
| 41 | ], |
| 42 | }); |
| 43 | } |
| 44 | } |
| 45 | return Effect.fn(`${tag}(${configuration.LogicalId})`)(function* ( |
| 46 | request?: Omit< |
| 47 | appsignals.GetInstrumentationConfigurationStatusRequest, |
| 48 | | "InstrumentationType" |
| 49 | | "Service" |
| 50 | | "Environment" |
| 51 | | "SignalType" |
| 52 | | "LocationIdentifier" |
| 53 | >, |
| 54 | ) { |
| 55 | return yield* op({ |
| 56 | ...request, |
| 57 | InstrumentationType: yield* InstrumentationType, |
| 58 | Service: yield* Service, |
| 59 | Environment: yield* Environment, |
| 60 | SignalType: yield* SignalType, |
| 61 | LocationIdentifier: { LocationHash: yield* LocationHash }, |
| 62 | }); |
| 63 | }); |
| 64 | }); |
| 65 | }), |
| 66 | ); |