Skip to content

feat: add support for role_slug in invitation schema#1567

Merged
gjtorikian merged 4 commits intomainfrom
auth-6215-invite-role-slug
Apr 21, 2026
Merged

feat: add support for role_slug in invitation schema#1567
gjtorikian merged 4 commits intomainfrom
auth-6215-invite-role-slug

Conversation

@stacurry
Copy link
Copy Markdown
Contributor

@stacurry stacurry commented Apr 21, 2026

Description

Adds support for role_slug in invitation API responses and events

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[X] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

docs added in https://github.com/workos/workos/pull/56857

Summary by CodeRabbit

  • New Features
    • Invitations now show role information and acceptance status, so invites surface assigned role and whether they've been accepted.
    • Client-side models and serializers updated to make these fields consistently available across the UI and API responses.
    • Sample invitation data updated to include the new fields for accurate previewing and testing.

@stacurry stacurry requested review from a team as code owners April 21, 2026 16:54
@stacurry stacurry requested a review from marji-workos April 21, 2026 16:54
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 21, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

Added role_slug to invitation fixtures and responses and mapped it to a new roleSlug field on interfaces and deserializers; fixture invitations also include accepted_user_id: null. No other API shapes or logic were changed.

Changes

Cohort / File(s) Summary
Invitation Fixtures
src/user-management/fixtures/invitation.json, src/user-management/fixtures/list-invitations.json
Added role_slug ("admin") to invitation objects and added accepted_user_id: null in fixtures.
Invitation Interfaces
src/user-management/interfaces/invitation.interface.ts
Added `roleSlug: string
Invitation Serializers
src/user-management/serializers/invitation.serializer.ts
Updated deserializeInvitation and deserializeInvitationEvent to map invitation.role_slugroleSlug in returned objects.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for role_slug in the invitation schema, which aligns with all file modifications.
Description check ✅ Passed The description includes both required sections (Description and Documentation), provides clear context about the role_slug addition, and references the related documentation PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch auth-6215-invite-role-slug

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

@stacurry stacurry changed the title add support for role_slug in invitation schema feat: add support for role_slug in invitation schema Apr 21, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR adds role_slug support to invitation API responses and events by updating all four related interfaces (Invitation, InvitationEvent, InvitationResponse, InvitationEventResponse), both deserializers, and both fixtures. It also cleans up the pre-existing missing accepted_user_id field in the fixture files.

Confidence Score: 5/5

Safe to merge — the change is small, additive, and fully consistent across interfaces, serializers, and fixtures.

All four interfaces, both serializers, and both fixtures are updated in lockstep. No breaking changes, no missing mappings, and the fixture cleanup resolves a pre-existing inconsistency. No P0 or P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
src/user-management/interfaces/invitation.interface.ts Added `roleSlug: string
src/user-management/serializers/invitation.serializer.ts Added roleSlug: invitation.role_slug mapping in both deserializeInvitation and deserializeInvitationEvent — correctly wires the new field end-to-end.
src/user-management/fixtures/invitation.json Added role_slug: "admin" and the previously-missing accepted_user_id: null field, bringing the fixture in line with the InvitationResponse interface contract.
src/user-management/fixtures/list-invitations.json Same fixture clean-up as invitation.jsonrole_slug and accepted_user_id both added to the list entry.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["API Response\n(InvitationResponse / InvitationEventResponse)"] -->|"role_slug: string | null"| B["deserializeInvitation\ndeserializeInvitationEvent"]
    B -->|"roleSlug: string | null"| C["Invitation / InvitationEvent\n(client model)"]
    D["Fixtures\ninvitation.json\nlist-invitations.json"] -.->|"role_slug: 'admin'"| A
Loading

Reviews (3): Last reviewed commit: "add description" | Re-trigger Greptile

Comment thread src/user-management/fixtures/invitation.json
Comment thread src/user-management/fixtures/list-invitations.json
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/user-management/interfaces/invitation.interface.ts`:
- Line 12: The new exported interface properties (e.g., roleSlug) were made
required and can break consumers; make each of these properties optional instead
by adding the optional modifier (e.g., change roleSlug: string | null to
roleSlug?: string | null) in the exported interfaces where they were added
(apply the same change to the other three newly-required properties referenced
in the review) so the API remains backward compatible.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3b5d901b-9e3f-4663-a7fa-f5c4fbc9ad21

📥 Commits

Reviewing files that changed from the base of the PR and between c31736d and e4531de.

📒 Files selected for processing (4)
  • src/user-management/fixtures/invitation.json
  • src/user-management/fixtures/list-invitations.json
  • src/user-management/interfaces/invitation.interface.ts
  • src/user-management/serializers/invitation.serializer.ts

Comment thread src/user-management/interfaces/invitation.interface.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/user-management/interfaces/invitation.interface.ts (1)

23-23: ⚠️ Potential issue | 🟠 Major

Make newly added roleSlug / role_slug fields optional to preserve backward compatibility.

Line 23, Line 45, Line 61, and Line 79 currently make additive fields mandatory, which can break consumers that construct these exported types before all producers are updated.

Proposed compatibility-safe diff
 export interface Invitation {
@@
-  roleSlug: string | null;
+  roleSlug?: string | null;
@@
 }

 export interface InvitationEvent {
@@
-  roleSlug: string | null;
+  roleSlug?: string | null;
@@
 }

 export interface InvitationResponse {
@@
-  role_slug: string | null;
+  role_slug?: string | null;
@@
 }

 export interface InvitationEventResponse {
@@
-  role_slug: string | null;
+  role_slug?: string | null;
@@
 }

Also applies to: 45-45, 61-61, 79-79

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/user-management/interfaces/invitation.interface.ts` at line 23, The newly
added fields (roleSlug / role_slug) were made required and must be optional to
avoid breaking consumers; update each occurrence in the invitation interfaces so
the property is optional (e.g., change roleSlug: string | null to roleSlug?:
string | null and likewise role_slug?: string | null) in the related interface
declarations (look for properties named roleSlug and role_slug in
invitation.interface.ts and its exported types) to preserve backward
compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/user-management/interfaces/invitation.interface.ts`:
- Line 23: The newly added fields (roleSlug / role_slug) were made required and
must be optional to avoid breaking consumers; update each occurrence in the
invitation interfaces so the property is optional (e.g., change roleSlug: string
| null to roleSlug?: string | null and likewise role_slug?: string | null) in
the related interface declarations (look for properties named roleSlug and
role_slug in invitation.interface.ts and its exported types) to preserve
backward compatibility.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fdb59ebb-e809-40f1-9600-799f82b795bd

📥 Commits

Reviewing files that changed from the base of the PR and between 688bc3a and a184fe3.

📒 Files selected for processing (1)
  • src/user-management/interfaces/invitation.interface.ts

@gjtorikian gjtorikian merged commit ba29409 into main Apr 21, 2026
9 checks passed
@gjtorikian gjtorikian deleted the auth-6215-invite-role-slug branch April 21, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants