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 { CustomerId } from "./Customer.id.ts"; |
| 3 | import { Username } from "./Username.ts"; |
| 4 | |
| 5 | /** Someone else holds this username. */ |
| 6 | export class UsernameTaken extends Domain.Rejection("UsernameTaken") {} |
| 7 | |
| 8 | export class UsernameClaimed extends Domain.Event("UsernameClaimed", { customerId: CustomerId }) {} |
| 9 | |
| 10 | /** |
| 11 | * Reserve a username for a customer. Sent by `UsernameReservation`; claiming |
| 12 | * a username the customer already holds records nothing. |
| 13 | */ |
| 14 | export class ClaimUsername extends Domain.Command("ClaimUsername", { |
| 15 | target: Username, |
| 16 | input: { customerId: CustomerId }, |
| 17 | events: [UsernameClaimed], |
| 18 | rejects: [UsernameTaken], |
| 19 | }) {} |