Fix return types for backend resource deletions
Description
When deleting resources, for example an Organization, the backend client is typed to return Organization, whereas the actual HTTP API returns a DeletedObject, resulting in a type mismatch. This PR:
- updates
DeletedObjectJSONto accept a generic that extendsstring, with a default ofstring- i initially wanted this to extend
ObjectTypebut then that would breakDeletedObject.fromJSON()
- i initially wanted this to extend
- changes the generics passed into
this.request()for the following resource delete methods:-
Allowlist -
Domain -
EmailAddress -
Organization -
PhoneNumber -
RedirectUrl -
SamlConnection- for this one i'm just assuming
ObjectType.SamlAccountis the correct type, as there's noSamlConnection
- for this one i'm just assuming
-
User
-
I'm not sure what the convention would be for handling this DeletedObjectJSON type property so this just seemed like the most straight forward way that wouldn't break anything 😅
Checklist
- [x]
npm testruns as expected. - [x]
npm run buildruns as expected. - [ ] (If applicable) JSDoc comments have been added or updated for any package exports
- [ ] (If applicable) Documentation has been updated
Type of change
- [x] 🐛 Bug fix
- [ ] 🌟 New feature
- [ ] 🔨 Breaking change
- [ ] 📖 Refactoring / dependency upgrade / documentation
- [ ] other:
🦋 Changeset detected
Latest commit: 8716f30362261af54634f679e7891fe03d1c3136
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 9 packages
| Name | Type |
|---|---|
| @clerk/backend | Patch |
| @clerk/astro | Patch |
| @clerk/express | Patch |
| @clerk/fastify | Patch |
| @clerk/nextjs | Patch |
| @clerk/remix | Patch |
| @clerk/clerk-sdk-node | Patch |
| @clerk/tanstack-start | Patch |
| @clerk/testing | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@dimkl no problem, thanks for the response! I've updated to add ObjectType.SamlConnection, added a generic to DeletedObject and made sure to use that instead of DeletedObjectJSON. The generics extend ObjectType instead of string now so they're required, which doesn't break any existing types but I'd imagine could possibly introduce a breaking change to anyone depending on DeletedObject and/or DeletedObjectJSON in application code.
I don't want to be wasting dev time with reviews etc so I'm off the mark here then I'm cool with closing and just opening an issue :)
Hello 👋
We currently close PRs after 60 days of inactivity. It's been 50 days since the last update here. If we missed this PR, please reply here. Otherwise, we'll close this PR in 10 days.
Thanks for being a part of the Clerk community! 🙏