| 1 | import * as amp from "@distilled.cloud/aws/amp"; |
| 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 { GetDefaultScraperConfiguration } from "./GetDefaultScraperConfiguration.ts"; |
| 7 | import { decodeDefinition } from "./internal.ts"; |
| 8 | |
| 9 | export const GetDefaultScraperConfigurationHttp = Layer.effect( |
| 10 | GetDefaultScraperConfiguration, |
| 11 | Effect.gen(function* () { |
| 12 | const getDefaultScraperConfiguration = |
| 13 | yield* amp.getDefaultScraperConfiguration; |
| 14 | |
| 15 | return Effect.fn(function* () { |
| 16 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 17 | const host = yield* Binding.Host; |
| 18 | if (isBindingHost(host)) { |
| 19 | yield* host.bind`Allow(${host}, AWS.AMP.GetDefaultScraperConfiguration())`( |
| 20 | { |
| 21 | policyStatements: [ |
| 22 | { |
| 23 | Effect: "Allow", |
| 24 | Action: ["aps:GetDefaultScraperConfiguration"], |
| 25 | Resource: ["*"], |
| 26 | }, |
| 27 | ], |
| 28 | }, |
| 29 | ); |
| 30 | } |
| 31 | } |
| 32 | return Effect.fn("AWS.AMP.GetDefaultScraperConfiguration")(function* () { |
| 33 | const response = yield* getDefaultScraperConfiguration({}); |
| 34 | return yield* decodeDefinition(response.configuration); |
| 35 | }); |
| 36 | }); |
| 37 | }), |
| 38 | ); |