javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Fix return types for backend resource deletions

Open kylekz opened this issue 1 year ago • 2 comments

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 DeletedObjectJSON to accept a generic that extends string, with a default of string
    • i initially wanted this to extend ObjectType but then that would break DeletedObject.fromJSON()
  • 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.SamlAccount is the correct type, as there's no SamlConnection
    • 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 test runs as expected.
  • [x] npm run build runs 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:

kylekz avatar Jul 29 '24 06:07 kylekz

🦋 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

changeset-bot[bot] avatar Jul 29 '24 06:07 changeset-bot[bot]

@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 :)

kylekz avatar Aug 08 '24 11:08 kylekz

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! 🙏

clerk-cookie avatar Oct 29 '24 00:10 clerk-cookie