package ports import ( "context" "fmt" "galaxy/user/internal/domain/account" "galaxy/user/internal/domain/common" ) // CreateAccountInput stores the atomic account-create state that must commit // together. type CreateAccountInput struct { // Account stores the durable user-account state. Account account.UserAccount } // Validate reports whether CreateAccountInput is structurally complete. func (input CreateAccountInput) Validate() error { if err := input.Account.Validate(); err != nil { return fmt.Errorf("create account input account: %w", err) } return nil } // UserAccountStore persists source-of-truth user-account records and their // exact lookup mappings. type UserAccountStore interface { // Create stores one new account record. Implementations must wrap // ErrConflict when the user id, e-mail, or exact user-name lookup already // exists. Create(ctx context.Context, input CreateAccountInput) error // GetByUserID returns the stored account identified by userID. GetByUserID(ctx context.Context, userID common.UserID) (account.UserAccount, error) // GetByEmail returns the stored account identified by the normalized e-mail // address. GetByEmail(ctx context.Context, email common.Email) (account.UserAccount, error) // GetByUserName returns the stored account identified by the exact stored // user name. GetByUserName(ctx context.Context, userName common.UserName) (account.UserAccount, error) // ExistsByUserID reports whether userID currently identifies a stored // account. ExistsByUserID(ctx context.Context, userID common.UserID) (bool, error) // Update replaces the stored account state for record.UserID. // // Implementations must wrap ErrConflict when the replacement record // attempts to mutate `user_name` or `email`. Update(ctx context.Context, record account.UserAccount) error }