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

main
ts 27 lines 1.05 KB
Raw
1 import * as Domain from "@alchemy.run/domain";
2 import { Actor } from "../Actor.ts";
3 import { Cents } from "../Money.ts";
4 import { TransferId } from "../Transfer/Transfer.id.ts";
5 import { AccountId } from "./Account.id.ts";
6 import { Frozen } from "./Frozen.rejection.ts";
7 import { InsufficientFunds } from "./InsufficientFunds.rejection.ts";
8 import { NotOpen } from "./NotOpen.rejection.ts";
9 import { NotOwner } from "./NotOwner.rejection.ts";
10
11 export class TransferDebited extends Domain.Event("TransferDebited", {
12 transferId: TransferId,
13 amount: Cents,
14 balanceAfter: Cents,
15 }) {}
16
17 /**
18 * Take a transfer's amount out of the source account, if the transfer's
19 * requester may. Sent by `TransferExecution`; who requested the transfer is a
20 * fact recorded on it, so it is input rather than request context.
21 */
22 export class DebitTransfer extends Domain.Command("DebitTransfer", {
23 target: AccountId,
24 input: { transferId: TransferId, amount: Cents, requestedBy: Actor },
25 events: [TransferDebited],
26 rejects: [NotOpen, NotOwner, Frozen, InsufficientFunds],
27 }) {}