javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Fix return types for backend resource deletions

Open kylekz opened this issue 6 months 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