@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, 06:00 UTC

main
ts 26 lines 1.16 KB
Raw
1 import * as Domain from "@alchemy.run/domain";
2 import * as Effect from "effect/Effect";
3 import { CurrentActor } from "../CurrentActor.context.ts";
4 import { Forbidden } from "../Forbidden.rejection.ts";
5 import { Session } from "../Session.middleware.ts";
6 import { Account } from "./Account.aggregate.ts";
7 import { OwnerChanged } from "./ChangeOwner.command.ts";
8 import { AccountClosed } from "./CloseAccount.command.ts";
9 import { AccountFrozen } from "./FreezeAccount.command.ts";
10 import { SettlementOnClosedAccount } from "./RecordSettlement.command.ts";
11 import { RefundStranded } from "./RefundTransfer.command.ts";
12
13 /** Operational events for support tooling, passed through unchanged. Agents only. */
14 export class AccountActivity extends Domain.View("AccountActivity", {
15 from: [Account],
16 key: Account,
17 middleware: [Session],
18 rejects: [Forbidden],
19 validate: Effect.fn(function* (request) {
20 const actor = yield* CurrentActor;
21 if (actor._tag !== "Agent") {
22 return yield* new Forbidden({ reason: `${request.mode} of account activity is for agents` });
23 }
24 }),
25 events: [AccountFrozen, AccountClosed, OwnerChanged, RefundStranded, SettlementOnClosedAccount],
26 }) {}