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
|
| ...('resourceExternalId' in options && { | ||
| resource_external_id: options.resourceExternalId, | ||
| }), | ||
| ...(options.resourceTypeSlug && { | ||
| resource_type_slug: options.resourceTypeSlug, | ||
| }), |
There was a problem hiding this comment.
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.