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