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 { Actor } from "../Actor.ts"; |
| 3 | import { CustomerId } from "../Customer/Customer.id.ts"; |
| 4 | import { Session } from "../Session.middleware.ts"; |
| 5 | import { AccountId } from "./Account.id.ts"; |
| 6 | import { NotOpen } from "./NotOpen.rejection.ts"; |
| 7 | |
| 8 | /** Only support agents may reassign accounts. */ |
| 9 | export class NotPermitted extends Domain.Rejection("NotPermitted") {} |
| 10 | |
| 11 | export class OwnerChanged extends Domain.Event("OwnerChanged", { |
| 12 | previous: CustomerId, |
| 13 | customerId: CustomerId, |
| 14 | by: Actor, |
| 15 | }) {} |
| 16 | |
| 17 | /** Reassign an account to another customer. */ |
| 18 | export class ChangeOwner extends Domain.Command("ChangeOwner", { |
| 19 | target: AccountId, |
| 20 | middleware: [Session], |
| 21 | input: { customerId: CustomerId }, |
| 22 | events: [OwnerChanged], |
| 23 | rejects: [NotOpen, NotPermitted], |
| 24 | }) {} |