@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 30 lines 1.4 KB
Raw
1 import * as ECS from "@distilled.cloud/aws/ecs";
2 import { toWireMinutes } from "alchemy/Util/Duration";
3 import * as Effect from "effect/Effect";
4 import * as Layer from "effect/Layer";
5 import { makeEcsClusterHttpBinding } from "./BindingHttp.ts";
6 import { UpdateTaskProtection, type UpdateTaskProtectionRequest } from "./UpdateTaskProtection.ts";
7
8 export const UpdateTaskProtectionHttp = Layer.effect(
9 UpdateTaskProtection,
10 makeEcsClusterHttpBinding({
11 tag: "AWS.ECS.UpdateTaskProtection",
12 // Wrap the distilled operation so the binding accepts a Duration.Input
13 // `expiresIn` and converts it to the wire's whole minutes.
14 //
15 // The operation must be *yielded* (its `Symbol.iterator`/`asEffect`
16 // protocol), never passed to `Effect.map`: an `API.OperationMethod` is a
17 // plain callable that is not `Effect.isEffect`, so `Effect.map` wraps it
18 // into an invalid effect that crashes the fiber at run time with
19 // "Not a valid effect: function ...".
20 operation: Effect.gen(function* () {
21 const op = yield* ECS.updateTaskProtection;
22 return ({ expiresIn, ...request }: UpdateTaskProtectionRequest & { cluster: string }) =>
23 op({ ...request, expiresInMinutes: toWireMinutes(expiresIn) });
24 }),
25 actions: ["ecs:UpdateTaskProtection"],
26 // Authorizes against the task resource:
27 // arn:aws:ecs:{region}:{account}:task/{clusterName}/*
28 resources: ["task"],
29 }),
30 );