1import type * as S3 from "@distilled.cloud/aws/s3";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../Binding.ts";
4import type { RuntimeContext } from "../RuntimeContext.ts";
5import type { Bucket } from "./Bucket.ts";
6import type { TigrisCredentialsMissing } from "./Errors.ts";
7
8export interface GetObjectRequest extends Omit<S3.GetObjectRequest, "Bucket"> {}
9
10/**
11 * Runtime binding for Tigris `GetObject` over the S3 API.
12 *
13 * Bind this operation to a {@link Bucket} in Service init. Provide
14 * {@link GetObjectHttp}.
15 *
16 *
17 * ### Reading Objects
18 * **Example:** Read an Object and Decode Its Body
19 * ```typescript
20 * const getObject = yield* Fly.GetObject(Data);
21 *
22 * const text = yield* getObject({ Key: "hello.txt" }).pipe(
23 * Effect.flatMap((result) =>
24 * Stream.mkString(Stream.decodeText(result.Body!)),
25 * ),
26 * );
27 * ```
28 *
29 * @binding
30 * @product Bucket
31 */
32export interface GetObject extends Binding.Service<
33 GetObject,
34 "Fly.GetObject",
35 (
36 bucket: Bucket,
37 ) => Effect.Effect<
38 (
39 request: GetObjectRequest,
40 ) => Effect.Effect<
41 S3.GetObjectOutput,
42 S3.GetObjectError | TigrisCredentialsMissing,
43 RuntimeContext
44 >
45 >
46> {}
47
48export const GetObject = Binding.Service<GetObject>("Fly.GetObject");