Issue:
feat(users): Add profile level invites

Currently invites are at merchant level only. Invite, accept invite and accept invite from email should change because of this.

Resolution:
<think>
PR Context:
- Title: feat(users): Add profile level invites
- Merged: 2024-09-04T15:22:10Z
- Files changed: 19 files
- Commits: 8 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
- Removed preferred_merchant_id from update user API.
- Invites will work at profile level as well.
- Handle internal users in list APIs
  - Org List for internal users will throw error.
  - Merchant list will list merchants.
  - Profile 
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(users): Add profile level invites (#5793)
Files to modify:


**crates/api_models/src/user.rs**
  Modify existing code

**crates/api_models/src/user_role.rs**
  Add:
    - struct: pub::Entity

**crates/diesel_models/src/schema.rs**
  Modify existing code

**crates/diesel_models/src/schema_v2.rs**
  Modify existing code

**crates/diesel_models/src/user.rs**
  Modify existing code

**crates/diesel_models/src/user_role.rs**
  Modify existing code

**crates/router/src/core/user.rs**
  Modify existing code

**crates/router/src/core/user_role.rs**
  Modify existing code

**crates/router/src/db/user.rs**
  Modify existing code

**crates/router/src/routes/app.rs**
  Modify existing code

**crates/router/src/routes/lock_utils.rs**
  Modify existing code

**crates/router/src/routes/user_role.rs**
  Add:
    - function: pub::accept_invitations_v2
    - function: pub::accept_invitations_pre_auth

**crates/router/src/services/email/types.rs**
  Remove:
    - function: pub::get_merchant_id
    - struct: pub::InviteRegisteredUser
  Add:
    - function: pub::get_entity_type
    - function: pub::get_entity_id
    - struct: pub::Entity

**crates/router/src/types/domain/user.rs**
  Remove:
    - function: pub::get_preferred_merchant_id
    - function: pub::get_preferred_or_active_user_role_from_db

**crates/router/src/types/domain/user/decision_manager.rs**
  Modify existing code

**crates/router/src/utils/user_role.rs**
  Add:
    - function: pub::get_lineage_for_user_id_and_entity_for_accepting_invite

**crates/router_env/src/logger/types.rs**
  Modify existing code