The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Domain from "@alchemy.run/domain"; |
| 2 | import { Cents } from "../Money.ts"; |
| 3 | import { Session } from "../Session.middleware.ts"; |
| 4 | import { AccountId } from "./Account.id.ts"; |
| 5 | import { NotOpen } from "./NotOpen.rejection.ts"; |
| 6 | import { NotOwner } from "./NotOwner.rejection.ts"; |
| 7 | |
| 8 | export class MoneyDeposited extends Domain.Event("MoneyDeposited", { |
| 9 | amount: Cents, |
| 10 | balanceAfter: Cents, |
| 11 | }) {} |
| 12 | |
| 13 | /** Pay money into an account. */ |
| 14 | export class DepositMoney extends Domain.Command("DepositMoney", { |
| 15 | target: AccountId, |
| 16 | middleware: [Session], |
| 17 | input: { amount: Cents }, |
| 18 | events: [MoneyDeposited], |
| 19 | rejects: [NotOpen, NotOwner], |
| 20 | reply: { balance: Cents }, |
| 21 | }) {} |