Skip to content
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

fix(backend,nextjs): Revert { data, errors } return values to v4 format for clerkClient methods and jwt/token helpers #2633

Merged
merged 7 commits into from Jan 19, 2024

Conversation

dimkl
Copy link
Member

@dimkl dimkl commented Jan 18, 2024

Description

Revert changing the { data, errors } return value of the following helpers. Instead those helpers return the values or throw error (same behaviour with v4):

  • import { verifyToken } from '@clerk/backend'
  • import { signJwt, hasValidSignature, decodeJwt, verifyJwt } from '@clerk/backend/jwt'
  • BAPI clerkClient methods eg (clerkClient.users.getUserList(...))

Also fixed the following BAPI methods to return the correct PaginatedResources. This is a breaking change and converts the return value of the following methods from T[] to { data: T[], totalCount: number }:

  • clerkClient.users.getOrganizationMembershipList(...)
  • clerkClient.organization.getOrganizationList(...)
  • clerkClient.organization.getOrganizationInvitationList(...)

Checklist

  • npm test runs as expected.
  • 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

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

This change will make all the BackendAPI methods to either return
the value or throw error instead of returning `{ data, errors }`.

We also (temporarily) added the `totalCount` property when we expect
an array of resources to allow passing the `total_count` of paginated
responses from the response body to the return value.
…elpers

The following helpers were reverted to return their `data` or throw an error.
Internally we will keep the `{ data, errors }` format but added a compatibility
layer to avoid exposing this breaking change:

- `import { verifyToken } from '@clerk/backend'`
- `import { signJwt, hasValidSignature, decodeJwt, verifyJwt } from '@clerk/backend/jwt'`
@dimkl dimkl self-assigned this Jan 18, 2024
Copy link

changeset-bot bot commented Jan 18, 2024

🦋 Changeset detected

Latest commit: fbd13ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@clerk/clerk-sdk-node Patch
@clerk/backend Major
@clerk/nextjs Patch
gatsby-plugin-clerk Patch
@clerk/fastify Patch
@clerk/remix Patch
@clerk/elements 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 dimkl enabled auto-merge January 19, 2024 02:00
@dimkl dimkl added this pull request to the merge queue Jan 19, 2024
Merged via the queue into main with commit 8e5c881 Jan 19, 2024
7 checks passed
@dimkl dimkl deleted the revert-data-errors-format branch January 19, 2024 02:13
@dimkl dimkl restored the revert-data-errors-format branch January 19, 2024 02:23
@dimkl dimkl deleted the revert-data-errors-format branch January 19, 2024 02:23
This was referenced Jan 19, 2024
BRKalow pushed a commit that referenced this pull request Jan 19, 2024
…rmat for clerkClient methods and jwt/token helpers (#2633)

* fix(backend): Make signJwt consistent by returning error instead of throwing

* fix(backend): Revert `{ data, errors }` return value from api client

This change will make all the BackendAPI methods to either return
the value or throw error instead of returning `{ data, errors }`.

We also (temporarily) added the `totalCount` property when we expect
an array of resources to allow passing the `total_count` of paginated
responses from the response body to the return value.

* fix(backend): Revert `{ data, errors }` return value from jwt/token helpers

The following helpers were reverted to return their `data` or throw an error.
Internally we will keep the `{ data, errors }` format but added a compatibility
layer to avoid exposing this breaking change:

- `import { verifyToken } from '@clerk/backend'`
- `import { signJwt, hasValidSignature, decodeJwt, verifyJwt } from '@clerk/backend/jwt'`

* fix(nextjs): Apply changes related to adding legacy return value compat layer

* fix(clerk-sdk-node): Update examples related to backend legacy return value compat layer

* chore(repo): Add changeset

* feat(backend): Paginated responses now return { data, totalCount } instead of an array

---------

Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants