-
Notifications
You must be signed in to change notification settings - Fork 46
refactored to breakout resourceId and resourceExternalId into separate itnerfaces that can be exported #1481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactored to breakout resourceId and resourceExternalId into separate itnerfaces that can be exported #1481
Conversation
1ffafc4
into
ENT-4372-base-authorization-branch
Greptile OverviewGreptile SummaryThis PR refactors the authorization check interfaces to use discriminated union types, breaking out Key changes:
Note: The PR title contains a typo: "itnerfaces" should be "interfaces" Confidence Score: 3/5
Important Files Changed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 1 comment
| ...('resourceExternalId' in options && { | ||
| resource_external_id: options.resourceExternalId, | ||
| }), | ||
| ...(options.resourceTypeSlug && { | ||
| resource_type_slug: options.resourceTypeSlug, | ||
| }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The serialization logic will include both resource_id and resource_external_id/resource_type_slug if an object with all properties is passed at runtime. TypeScript types don't prevent { resourceId: 'x', resourceExternalId: 'y', resourceTypeSlug: 'z' } from being constructed and passed.
Consider using an else-if pattern to ensure mutual exclusivity:
| ...('resourceExternalId' in options && { | |
| resource_external_id: options.resourceExternalId, | |
| }), | |
| ...(options.resourceTypeSlug && { | |
| resource_type_slug: options.resourceTypeSlug, | |
| }), | |
| ...('resourceId' in options | |
| ? { resource_id: options.resourceId } | |
| : { | |
| resource_external_id: options.resourceExternalId, | |
| resource_type_slug: options.resourceTypeSlug, | |
| }), |
Description
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.