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 DynamoDB from "@distilled.cloud/aws/dynamodb"; |
| 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 { regionFromArn } from "../Lambda/BindingHttp.ts"; |
| 7 | import type { Bucket } from "../S3/Bucket.ts"; |
| 8 | import { GrantTables } from "./BindingHttp.ts"; |
| 9 | import { |
| 10 | ExportTableToPointInTime, |
| 11 | type ExportTableToPointInTimeRequest, |
| 12 | } from "./ExportTableToPointInTime.ts"; |
| 13 | import type { Table } from "./Table.ts"; |
| 14 | |
| 15 | export const ExportTableToPointInTimeHttp = Layer.effect( |
| 16 | ExportTableToPointInTime, |
| 17 | Effect.gen(function* () { |
| 18 | const grantTables = yield* GrantTables; |
| 19 | return Effect.fn(function* <T extends Table, B extends Bucket>(table: T, bucket: B) { |
| 20 | const TableArn = yield* table.tableArn; |
| 21 | const S3Bucket = yield* bucket.bucketName; |
| 22 | yield* grantTables( |
| 23 | `AWS.DynamoDB.ExportTableToPointInTime(${table.LogicalId}, ${bucket.LogicalId})`, |
| 24 | () => [ |
| 25 | { |
| 26 | Effect: "Allow", |
| 27 | Action: ["dynamodb:ExportTableToPointInTime"], |
| 28 | Resource: [table.tableArn], |
| 29 | }, |
| 30 | { |
| 31 | Effect: "Allow", |
| 32 | Action: ["s3:AbortMultipartUpload", "s3:PutObject", "s3:PutObjectAcl"], |
| 33 | Resource: [Output.interpolate`${bucket.bucketArn}/*`], |
| 34 | }, |
| 35 | ], |
| 36 | ); |
| 37 | // The export runs in the table's region; the bucket may be elsewhere. |
| 38 | const exportTableToPointInTime = yield* AWSBindings.withCredentials( |
| 39 | DynamoDB.exportTableToPointInTime, |
| 40 | Effect.succeed(Effect.map(TableArn, regionFromArn)), |
| 41 | ); |
| 42 | return Effect.fn( |
| 43 | `AWS.DynamoDB.ExportTableToPointInTime(${table.LogicalId}, ${bucket.LogicalId})`, |
| 44 | )(function* (request?: ExportTableToPointInTimeRequest) { |
| 45 | return yield* exportTableToPointInTime({ |
| 46 | ...request, |
| 47 | TableArn: yield* TableArn, |
| 48 | S3Bucket: yield* S3Bucket, |
| 49 | }); |
| 50 | }); |
| 51 | }); |
| 52 | }), |
| 53 | ); |