The best way to control Claude Code, Codex and more from any computer or phone

main
ts 70 lines 2.51 KB
Raw
1 // @ts-nocheck
2 import * as S3 from "@distilled.cloud/aws/s3";
3 import * as Binding from "alchemy/Binding";
4 import * as Effect from "effect/Effect";
5 import type { Bucket } from "./Bucket.ts";
6
7 export interface CopyObjectRequest extends Omit<S3.CopyObjectRequest, "Bucket"> {}
8
9 /**
10 * Runtime binding for `s3:CopyObject`.
11 *
12 * Bind this operation to the destination bucket to get a callable that copies
13 * objects server-side — no download/re-upload round trip. `CopySource` names
14 * the source as `"source-bucket/key"`. Provide the implementation with
15 * `Effect.provide(AWS.S3.CopyObjectHttp)`. The binding grants reads of current
16 * and specific source versions within the bound bucket. Cross-bucket copies
17 * require a separate read grant on the source bucket.
18 *
19 * ### Copying Objects
20 * **Example:** Copy an Object Within a Bucket
21 * ```typescript
22 * // init — bind the operation to the destination bucket
23 * const copyObject = yield* AWS.S3.CopyObject(bucket);
24 *
25 * // runtime — promote a staged upload to its final key
26 * yield* copyObject({
27 * CopySource: `${bucketName}/incoming/report.pdf`,
28 * Key: "published/report.pdf",
29 * });
30 * ```
31 *
32 * ### Copying a Specific Version
33 * **Example:** Restore an Older Version to a New Key
34 * ```typescript
35 * const sourceKey = "reports/annual report.pdf";
36 * const encodedKey = sourceKey.split("/").map(encodeURIComponent).join("/");
37 * yield* copyObject({
38 * CopySource: `${bucketName}/${encodedKey}?versionId=${encodeURIComponent(versionId)}`,
39 * Key: "restored/annual report.pdf",
40 * });
41 * ```
42 *
43 * The source version remains unchanged. In a versioned destination bucket,
44 * the copy creates a new version and returns its `VersionId`.
45 *
46 * ### Copying Between Buckets
47 * **Example:** Grant reads on a separate source bucket
48 * ```typescript
49 * yield* AWS.S3.GetObject(sourceBucket);
50 * const copyObject = yield* AWS.S3.CopyObject(destinationBucket);
51 * // Provide both AWS.S3.GetObjectHttp and AWS.S3.CopyObjectHttp on the host.
52 * ```
53 *
54 * The source read binding grants current and version-specific reads without
55 * granting writes to the source. Copying tags, ACLs, Object Lock settings, or
56 * KMS-encrypted data requires the corresponding additional permissions.
57 *
58 * @binding
59 */
60 export interface CopyObject extends Binding.Service<
61 CopyObject,
62 "AWS.S3.CopyObject",
63 (
64 bucket: Bucket,
65 ) => Effect.Effect<
66 (request: CopyObjectRequest) => Effect.Effect<S3.CopyObjectOutput, S3.CopyObjectError>
67 >
68 > {}
69
70 export const CopyObject = Binding.Service<CopyObject>("AWS.S3.CopyObject");