@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 59 lines 2.02 KB
Raw
1 import type * as ivschat from "@distilled.cloud/aws/ivschat";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { Room } from "./Room.ts";
5
6 /**
7 * The `roomIdentifier` is injected by the binding from the bound room;
8 * the caller supplies the target `userId` (accepted as a plain string or a
9 * `Redacted` value) and an optional `reason`.
10 */
11 export interface DisconnectUserRequest extends Omit<
12 ivschat.DisconnectUserRequest,
13 "roomIdentifier"
14 > {}
15
16 /**
17 * Moderate the bound room by disconnecting all WebSocket connections of a
18 * user — the effectful call made from a deployed Lambda or Task. The
19 * `userId` is the one the user's chat token was minted with; disconnection
20 * does not prevent reconnection, so revoke by not minting further tokens.
21 * The call succeeds even when the user has no open connections.
22 *
23 * ### Moderating Users
24 * Provide the `DisconnectUserHttp` implementation layer on the Function
25 * effect, bind the room in the init phase, then call the returned client at
26 * runtime. The binding grants `ivschat:DisconnectUser` on the room and
27 * injects its ARN as the `roomIdentifier` automatically.
28 *
29 * **Example:** Disconnect a user from a Lambda
30 * ```typescript
31 * // init
32 * const room = yield* IVSChat.Room("LiveChat");
33 * const disconnectUser = yield* IVSChat.DisconnectUser(room);
34 *
35 * return {
36 * fetch: Effect.gen(function* () {
37 * // runtime
38 * yield* disconnectUser({ userId: "user-123", reason: "spam" });
39 * return HttpServerResponse.json({ ok: true });
40 * }),
41 * };
42 * // on the Function effect:
43 * // .pipe(Effect.provide(IVSChat.DisconnectUserHttp))
44 * ```
45 *
46 * @binding
47 */
48 export interface DisconnectUser extends Binding.Service<
49 DisconnectUser,
50 "AWS.IVSChat.DisconnectUser",
51 (
52 room: Room,
53 ) => Effect.Effect<
54 (
55 request: DisconnectUserRequest,
56 ) => Effect.Effect<ivschat.DisconnectUserResponse, ivschat.DisconnectUserError>
57 >
58 > {}
59 export const DisconnectUser = Binding.Service<DisconnectUser>("AWS.IVSChat.DisconnectUser");