Skip to content

feat(my-org): invitation roles API types, constants and locales [1/2] - #456

Open
grandmaester wants to merge 2 commits into
feat/my-org-ea-branchfrom
feat/invitation-roles-api-setup
Open

feat(my-org): invitation roles API types, constants and locales [1/2]#456
grandmaester wants to merge 2 commits into
feat/my-org-ea-branchfrom
feat/invitation-roles-api-setup

Conversation

@grandmaester

@grandmaester grandmaester commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Lays the type, constant and locale groundwork for consuming the new GET /my-org/member-invitations/{invitation_id}/roles endpoint, and updates the member management view to pass the invitation's roles down to the details modal.

This is part 1 of 2. It is the base of a stacked pair and is not independently mergeable — see the callout under What.

Why

The invitation details modal currently resolves a pending invitation's role names by fetching the tenant's roles list and intersecting it client-side against the role IDs on the invitation. That approach has two problems:

  • It silently truncates. The bulk fetch was capped at MAX_ROLES_AVAILABLE_FOR_ASSIGNMENT = 100. Any role beyond the first 100 could not be resolved, and the modal rendered the raw role ID instead of the name — with no indication anything was missing.
  • It pays for data it discards. Every details-modal open fetched up to 100 roles to display, typically, one or two.

The API team added a dedicated sub-resource for this (see References). Per AEP review, role metadata is not embedded in the invitation response; the roles are a sub-resource with their own endpoint. This PR renames and reshapes the contracts to match that model so the hook/service work in part 2 can land against stable types.

What

Query keysmemberManagementQueryKeys.roles() becomes invitationRoles(id), keyed per invitation so each invitation's roles cache independently:

invitationRoles: (id: string) =>
  [...memberManagementQueryKeys.all, 'invitation-roles', id] as const,

rolesSearch(term) is untouched — the create/assign-roles modals still use the paginated role search, which is a different concern.

SDK response type — re-exports GetMemberInvitationRolesResponseContent from @auth0/myorganization-js so consumers do not reach into the SDK namespace directly.

Service optionsenableRolesList?: boolean becomes invitationRolesId?: string | null. The old flag only gated whether to bulk-fetch; the new field doubles as the request parameter and the enablement gate (omit it and no request fires).

Hook resultavailableRoles is removed and isFetchingAvailableRoles becomes:

invitationRoles: Role[];
isFetchingInvitationRoles: boolean;

availableRoles had exactly one consumer — the details modal — so it is fully dead once the modal reads roles instead. rolesQuery on MemberManagementServiceResult becomes invitationRolesQuery.

Details modal propsavailableRoles?: Role[] becomes roles?: Role[] plus isLoadingRoles?: boolean. The rename is deliberate: the prop no longer carries "roles you could pick from", it carries "this invitation's roles".

Constant removedMAX_ROLES_AVAILABLE_FOR_ASSIGNMENT is deleted. Nothing needs a bulk cap once roles arrive scoped to the invitation. MAX_ROLES_PER_REQUEST, MAX_ROLES_PER_MEMBER and DEFAULT_ROLES_PAGE_SIZE are unchanged.

Locales — adds member_management.invitation.error.fetch_roles_failed to the typed custom-message interface, en-US.json and ja.json.

fr.json is intentionally not updated. It has no member_management.invitation block at all — 86 of its 153 missing keys are in that namespace — so adding this one key would create an island holding a single string while the rest stayed absent. French users see the raw key here, exactly as they already do for every other invitation string. The locale gap is pre-existing and wider than this feature; it needs a localization pass, not invented copy. Flagging separately.

Important

This PR fails packages/react typecheck on its own (26 errors), by design. It removes type members and a constant whose consumers are updated in part 2. packages/core typechecks clean. Merge part 2 (#457) into this branch first, then this branch into feat/my-org-ea-branch. Do not merge this alone.

Packages

  • packages/core
  • packages/react
  • examples

References

Testing

Verified at this commit:

  • tsc --noEmit -p packages/core — clean
  • packages/core test suite — 26 files, 1090 tests passing
  • packages/react typecheck — 26 errors, all consumers of the members removed here, resolved by part 2 (see callout above)

The one test file touched here is a harness update, not new coverage: organization-member-management.test.tsx renames two required fields on the mocked hook result (availableRolesinvitationRoles, isFetchingAvailableRolesisFetchingInvitationRoles). Those fields are mandatory on UseOrganizationMemberManagementResult, which the view props extend, so the file would not compile without them. All new behavioural coverage is in part 2.

One incidental diff: the OrganizationInvitationTabProps interface header in organization-invitation-table-types.ts is reformatted. That block was not prettier-clean before; prettier --write normalized it while formatting the real change in the same file. No semantic change.

  • This change adds unit test coverage
  • Tested for both SPA and RWA flows, all example apps working
  • All existing and new tests complete without errors

Checklist

  • Breaking change
  • Requires docs update
  • Backward compatible

useOrganizationMemberManagement is publicly exported, so removing availableRoles and renaming isFetchingAvailableRoles changes its return type. This was a deliberate call rather than keeping the old fields as deprecated aliases: availableRoles had a single internal consumer and retaining it would mean keeping the bulk roles fetch alive purely to populate a field nobody reads.

Contributing

Summary by CodeRabbit

  • Bug Fixes

    • Improved invitation details by loading roles specifically for each invitation.
    • Added a dedicated loading state while invitation roles are retrieved.
    • Added a clear error message with a retry prompt when roles cannot be loaded.
  • Localization

    • Added invitation-role loading failure messages in English and Japanese.
  • Improvements

    • Updated invitation management data handling to provide more accurate role information and loading feedback.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d4388cd-abae-4659-8d2a-0cfaefd05d88

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Invitation role queries are now scoped by invitation ID. Member-management service and modal contracts use invitation-specific roles and loading state. English and Japanese error messages cover role-fetch failures, and test mocks use the renamed fields.

Changes

Invitation role query and service contract

Layer / File(s) Summary
Invitation role query contract
packages/core/src/services/my-organization/member-management/member-management-constants.ts, packages/core/src/services/my-organization/member-management/member-management-types.ts, packages/react/src/types/my-organization/member-management/organization-member-management-types.ts, packages/react/src/lib/constants/my-organization/member-management/member-management-constants.ts
The query key now includes the invitation ID. The service exposes an invitation-role response type, invitationRolesId, invitationRolesQuery, invitationRoles, and isFetchingInvitationRoles. The obsolete maximum-role constant is removed.

Invitation role view integration

Layer / File(s) Summary
Invitation role view integration
packages/react/src/types/my-organization/member-management/organization-invitation-table-types.ts, packages/react/src/components/auth0/my-organization/organization-member-management.tsx, packages/core/src/i18n/custom-messages/my-organization/member-management/invitation-tab-types.ts, packages/core/src/i18n/translations/en-US.json, packages/core/src/i18n/translations/ja.json, packages/react/src/components/auth0/my-organization/__tests__/organization-member-management.test.tsx
The invitation modal receives roles and isLoadingRoles. The view passes invitation roles and loading state. Localized role-fetch failure messages are added. Test mocks use the renamed role fields.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: chakrihacker, rax7389

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main invitation roles groundwork, including API types, constants, and locales.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch feat/invitation-roles-api-setup
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/invitation-roles-api-setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

export const memberManagementQueryKeys = {
all: ['member-management'] as const,
invitations: () => [...memberManagementQueryKeys.all, 'invitations'] as const,
roles: () => [...memberManagementQueryKeys.all, 'roles'] as const,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hope this is verified and not used anywhere else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants