defmodule Mv.Accounts do
  @moduledoc """
  AshAuthentication specific domain to handle Authentication for users.

  ## Resources
  - `User` - User accounts with authentication methods (password, OIDC)
  - `Token` - Session tokens for authentication

  ## Public API
  The domain exposes these main actions:
  - User CRUD: `create_user/1`, `list_users/0`, `update_user/2`, `destroy_user/1`
  - Authentication: `create_register_with_rauthy/1`, `read_sign_in_with_rauthy/1`
  """
  use Ash.Domain,
    extensions: [AshAdmin.Domain, AshPhoenix]

  admin do
    show? true
  end

  resources do
    resource Mv.Accounts.User do
      define :create_user, action: :create_user
      define :list_users, action: :read
      define :update_user, action: :update_user
      define :destroy_user, action: :destroy
      define :create_register_with_rauthy, action: :register_with_rauthy
      define :read_sign_in_with_rauthy, action: :sign_in_with_rauthy
    end

    resource Mv.Accounts.Token
  end
end
