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

main
ts 33 lines 1.05 KB
Raw
1 import * as Effect from "effect/Effect";
2 import * as Layer from "effect/Layer";
3 import type { Bucket } from "./Bucket.ts";
4 import { GetObject, type GetObjectRequest } from "./GetObject.ts";
5 import { GrantOnBucket } from "./ObjectHttp.ts";
6 import { makeObjectMedia } from "./ObjectMedia.ts";
7
8 /**
9 * HTTP implementation of {@link GetObject}.
10 *
11 * @layer
12 * @provides GCP.Storage.GetObject
13 */
14 export const GetObjectHttp = Layer.effect(
15 GetObject,
16 Effect.gen(function* () {
17 const grantOnBucket = yield* GrantOnBucket;
18 const media = yield* makeObjectMedia;
19 return Effect.fn(function* (bucket: Bucket) {
20 yield* grantOnBucket("GCP.Storage.GetObject", bucket, "roles/storage.objectViewer");
21 const bucketName = yield* bucket.bucketName;
22 return Effect.fn(`GCP.Storage.GetObject(${bucket.LogicalId})`)(function* (
23 request: GetObjectRequest,
24 ) {
25 return yield* media.download({
26 bucket: yield* bucketName,
27 object: request.object,
28 generation: request.generation,
29 });
30 });
31 });
32 }),
33 );