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 * as Schema from "effect/Schema"; |
| 3 | import { Session } from "../Session.middleware.ts"; |
| 4 | import { CustomerId } from "./Customer.id.ts"; |
| 5 | import { Username } from "./Username.ts"; |
| 6 | |
| 7 | /** The customer is registered, or a registration is already in progress. */ |
| 8 | export class AlreadyRegistered extends Domain.Rejection("AlreadyRegistered") {} |
| 9 | |
| 10 | /** A customer may only register themselves. */ |
| 11 | export class NotTheCustomer extends Domain.Rejection("NotTheCustomer") {} |
| 12 | |
| 13 | /** Registration waits for `UsernameReservation` to claim the username. */ |
| 14 | export class RegistrationRequested extends Domain.Event("RegistrationRequested", { |
| 15 | name: Schema.String, |
| 16 | username: Username, |
| 17 | }) {} |
| 18 | |
| 19 | /** |
| 20 | * Sign up as a customer under a unique username. The customer is registered |
| 21 | * once the username is claimed; `MainAccountProvisioning` then opens their |
| 22 | * main account. |
| 23 | */ |
| 24 | export class RegisterCustomer extends Domain.Command("RegisterCustomer", { |
| 25 | target: CustomerId, |
| 26 | middleware: [Session], |
| 27 | input: { name: Schema.String, username: Username }, |
| 28 | events: [RegistrationRequested], |
| 29 | rejects: [AlreadyRegistered, NotTheCustomer], |
| 30 | }) {} |