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
| 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 | /** Only an empty account can be closed. */ |
| 9 | export class BalanceNotZero extends Domain.Rejection("BalanceNotZero", { balance: Cents }) {} |
| 10 | |
| 11 | export class AccountClosed extends Domain.Event("AccountClosed") {} |
| 12 | |
| 13 | /** Close an empty account. */ |
| 14 | export class CloseAccount extends Domain.Command("CloseAccount", { |
| 15 | target: AccountId, |
| 16 | middleware: [Session], |
| 17 | events: [AccountClosed], |
| 18 | rejects: [NotOpen, NotOwner, BalanceNotZero], |
| 19 | }) {} |