@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 49 lines 1.93 KB
Raw
1 import * as S3 from "@distilled.cloud/aws/s3";
2 import * as Binding from "alchemy/Binding";
3 import * as Effect from "effect/Effect";
4 import type { Bucket } from "./Bucket.ts";
5
6 export interface HeadObjectRequest extends Omit<S3.HeadObjectRequest, "Bucket"> {}
7
8 /**
9 * Runtime binding for `s3:HeadObject`.
10 *
11 * Bind this operation to a bucket to get a callable that reads an object's
12 * metadata (size, content type, ETag) without downloading the body. Provide
13 * the implementation with `Effect.provide(AWS.S3.HeadObjectHttp)`.
14 *
15 * The HTTP implementation grants `s3:GetObject` for current-object reads and
16 * `s3:GetObjectVersion` because this request also supports `VersionId`. It
17 * additionally grants `s3:ListBucket` so a missing key produces AWS's
18 * documented `404`/`403` distinction instead of always being reported as
19 * `AccessDenied`. See the [HeadObject API](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html)
20 * and [S3 required permissions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html).
21 *
22 * ### Inspecting Objects
23 * **Example:** Check an Object's Metadata
24 * ```typescript
25 * // init — bind the operation to the bucket
26 * const headObject = yield* AWS.S3.HeadObject(bucket);
27 *
28 * // runtime — inspect without transferring the body
29 * const head = yield* headObject({ Key: "uploads/report.pdf" });
30 * const size = head.ContentLength;
31 * const contentType = head.ContentType;
32 * ```
33 *
34 * @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html
35 * @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html
36 *
37 * @binding
38 */
39 export interface HeadObject extends Binding.Service<
40 HeadObject,
41 "AWS.S3.HeadObject",
42 (
43 bucket: Bucket,
44 ) => Effect.Effect<
45 (request: HeadObjectRequest) => Effect.Effect<S3.HeadObjectOutput, S3.HeadObjectError>
46 >
47 > {}
48
49 export const HeadObject = Binding.Service<HeadObject>("AWS.S3.HeadObject");