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 aoss from "@distilled.cloud/aws/opensearchserverless"; |
| 2 | import * as Output from "alchemy/Output"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as Layer from "effect/Layer"; |
| 5 | import * as AWSBindings from "../AWSBindings.ts"; |
| 6 | import type { Collection } from "./Collection.ts"; |
| 7 | import { GetCollection } from "./GetCollection.ts"; |
| 8 | |
| 9 | // Bespoke (not the shared scaffolding): BatchGetCollection takes an `ids` |
| 10 | // array rather than a single injected `id`, and the callable unwraps the |
| 11 | // batch response to the bound collection's detail. |
| 12 | export const GetCollectionHttp = Layer.effect( |
| 13 | GetCollection, |
| 14 | Effect.gen(function* () { |
| 15 | const bind = yield* AWSBindings.Bind; |
| 16 | const op = yield* AWSBindings.withCredentials(aoss.batchGetCollection); |
| 17 | |
| 18 | return Effect.fn(function* (collection: Collection) { |
| 19 | const CollectionId = yield* collection.collectionId; |
| 20 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 21 | yield* bind`AWS.OpenSearchServerless.GetCollection(${collection})`({ |
| 22 | policyStatements: [ |
| 23 | { |
| 24 | Effect: "Allow", |
| 25 | Action: ["aoss:BatchGetCollection"], |
| 26 | Resource: [Output.interpolate`${collection.collectionArn}`], |
| 27 | }, |
| 28 | ], |
| 29 | }); |
| 30 | } |
| 31 | return Effect.fn(`AWS.OpenSearchServerless.GetCollection(${collection.LogicalId})`)( |
| 32 | function* () { |
| 33 | const response = yield* op({ ids: [yield* CollectionId] }); |
| 34 | return response.collectionDetails?.[0]; |
| 35 | }, |
| 36 | ); |
| 37 | }); |
| 38 | }), |
| 39 | ); |