| 1 | import * as S3 from "@distilled.cloud/aws/s3"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import type { Bucket } from "./Bucket.ts"; |
| 6 | |
| 7 | export interface DeleteObjectRequest extends Omit< |
| 8 | S3.DeleteObjectRequest, |
| 9 | "Bucket" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for `s3:DeleteObject`. |
| 14 | * |
| 15 | * Bind this operation to a bucket to get a callable that deletes objects — |
| 16 | * the bucket name is injected automatically and `s3:DeleteObject` is granted |
| 17 | * on the bucket. Provide the implementation with |
| 18 | * `Effect.provide(AWS.S3.DeleteObjectHttp)`. |
| 19 | * ### Deleting Objects |
| 20 | * **Example:** Delete an Object |
| 21 | * ```typescript |
| 22 | * // init — bind the operation to the bucket |
| 23 | * const deleteObject = yield* AWS.S3.DeleteObject(bucket); |
| 24 | * |
| 25 | * // runtime — deleting a non-existent key succeeds (S3 delete is idempotent) |
| 26 | * yield* deleteObject({ Key: "jobs/job-123.json" }); |
| 27 | * ``` |
| 28 | * |
| 29 | * @binding |
| 30 | */ |
| 31 | export interface DeleteObject extends Binding.Service< |
| 32 | DeleteObject, |
| 33 | "AWS.S3.DeleteObject", |
| 34 | ( |
| 35 | bucket: Bucket, |
| 36 | ) => Effect.Effect< |
| 37 | ( |
| 38 | request: DeleteObjectRequest, |
| 39 | ) => Effect.Effect<S3.DeleteObjectOutput, S3.DeleteObjectError> |
| 40 | > |
| 41 | > {} |
| 42 | export const DeleteObject = Binding.Service<DeleteObject>( |
| 43 | "AWS.S3.DeleteObject", |
| 44 | ); |