| 1 | import * as sdb from "@distilled.cloud/aws/simpledb"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import { registerSimpleDbBinding } from "./Binding.ts"; |
| 5 | import type { Domain } from "./Domain.ts"; |
| 6 | import { Select, type SelectRequest } from "./Select.ts"; |
| 7 | |
| 8 | export const SelectHttp = Layer.effect( |
| 9 | Select, |
| 10 | Effect.gen(function* () { |
| 11 | const select = yield* sdb.select; |
| 12 | |
| 13 | return Effect.fn(function* (domain: Domain) { |
| 14 | const domainName = yield* domain.domainName; |
| 15 | yield* registerSimpleDbBinding("Select", domain); |
| 16 | return Effect.fn(`AWS.SimpleDB.Select(${domain.LogicalId})`)(function* ( |
| 17 | request: SelectRequest, |
| 18 | ) { |
| 19 | const { SelectExpression, ...rest } = request; |
| 20 | const name = yield* domainName; |
| 21 | return yield* select({ |
| 22 | ...rest, |
| 23 | SelectExpression: |
| 24 | typeof SelectExpression === "function" |
| 25 | ? SelectExpression(name) |
| 26 | : SelectExpression, |
| 27 | }); |
| 28 | }); |
| 29 | }); |
| 30 | }), |
| 31 | ); |