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

feat(clerk-js): Support Paginated response in OrganizationMembership.retrieve & userMemberships in useOrganizationList #1606

Merged
merged 4 commits into from
Aug 17, 2023

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Aug 16, 2023

Type of change

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

Packages affected

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

Description

  • npm test runs as expected.
  • npm run build runs as expected.

This PR

  • marks as deprecated the Clerk.getOrganizationMemberships method
  • updates the signature of User.getOrganizationMemberships method and OrganizationMembership.retrieve

This PR aims to support backwards compatibility at the type level but also at runtime by adding a new supported parameter to OrganizationMembership.retrieve the paginated:true

Examples:

// Works as before and does not accept parameters (now marked as deprecated)
const memberships = await clerk.getOrganizationMemberships()
// ^ this will be of type OrganizationMemberships[]


// Works as before and accepts parameters
const memberships = await user.getOrganizationMemberships()
// ^ this will be of type OrganizationMembershipResource[]


const memberships = await user.getOrganizationMemberships({limit:10, offset:0})
// ^ this will be of type OrganizationMembershipResource[]


const memberships = await user.getOrganizationMemberships({initialPage:1, pageSize:10, paginated: true})
// ^ this will be of type ClerkPaginatedResponse<OrganizationMembershipResource>

// The hooks only accepts the new paginated params `initialPage & pageSize` (internally uses paginated: true)
const {userMemberships} = useOrganizationList({userMemberships:true})

userMemberships.data
// ^ this will always be of type OrganizationMembershipResource[]

@changeset-bot
Copy link

changeset-bot bot commented Aug 16, 2023

🦋 Changeset detected

Latest commit: 5e4f7d2

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

This PR includes changesets to release 13 packages
Name Type
@clerk/clerk-js Patch
@clerk/shared Patch
@clerk/types Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/backend Patch
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/clerk-sdk-node 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

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

@panteliselef panteliselef changed the title Org 141 feat(clerk-js): Support Paginated response in OrganizationMembership.retrieve & userMemberships in useOrganizationList Aug 16, 2023
@desiprisg
Copy link
Contributor

Is useOrganizationSettings public API ?

@panteliselef
Copy link
Member Author

Is useOrganizationSettings public API ?

My bad the description now says useOrganizationList

@panteliselef
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @panteliselef - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 0.28.0-snapshot.5e4f7d2
@clerk/chrome-extension 0.3.27-snapshot.5e4f7d2
@clerk/clerk-js 4.56.0-snapshot.5e4f7d2
eslint-config-custom 0.3.0
@clerk/clerk-expo 0.18.18-snapshot.5e4f7d2
@clerk/fastify 0.6.4-snapshot.5e4f7d2
gatsby-plugin-clerk 4.4.5-snapshot.5e4f7d2
@clerk/localizations 1.25.0-snapshot.5e4f7d2
@clerk/nextjs 4.23.3-snapshot.5e4f7d2
@clerk/clerk-react 4.24.0-snapshot.5e4f7d2
@clerk/remix 2.10.0-snapshot.5e4f7d2
@clerk/clerk-sdk-node 4.12.3-snapshot.5e4f7d2
@clerk/shared 0.22.0-snapshot.5e4f7d2
@clerk/themes 1.7.5
@clerk/types 3.50.0-snapshot.5e4f7d2

Tip: use the snippet copy button below to quickly install the required packages.

# @clerk/backend
npm i @clerk/backend@0.28.0-snapshot.5e4f7d2
# @clerk/chrome-extension
npm i @clerk/chrome-extension@0.3.27-snapshot.5e4f7d2
# @clerk/clerk-js
npm i @clerk/clerk-js@4.56.0-snapshot.5e4f7d2
# eslint-config-custom
npm i eslint-config-custom@0.3.0
# @clerk/clerk-expo
npm i @clerk/clerk-expo@0.18.18-snapshot.5e4f7d2
# @clerk/fastify
npm i @clerk/fastify@0.6.4-snapshot.5e4f7d2
# gatsby-plugin-clerk
npm i gatsby-plugin-clerk@4.4.5-snapshot.5e4f7d2
# @clerk/localizations
npm i @clerk/localizations@1.25.0-snapshot.5e4f7d2
# @clerk/nextjs
npm i @clerk/nextjs@4.23.3-snapshot.5e4f7d2
# @clerk/clerk-react
npm i @clerk/clerk-react@4.24.0-snapshot.5e4f7d2
# @clerk/remix
npm i @clerk/remix@2.10.0-snapshot.5e4f7d2
# @clerk/clerk-sdk-node
npm i @clerk/clerk-sdk-node@4.12.3-snapshot.5e4f7d2
# @clerk/shared
npm i @clerk/shared@0.22.0-snapshot.5e4f7d2
# @clerk/themes
npm i @clerk/themes@1.7.5
# @clerk/types
npm i @clerk/types@3.50.0-snapshot.5e4f7d2

@panteliselef panteliselef merged commit 435d2cf into main Aug 17, 2023
8 checks passed
@panteliselef panteliselef deleted the ORG-141 branch August 17, 2023 06:50
@clerk-cookie clerk-cookie mentioned this pull request Aug 17, 2023
@clerk-cookie
Copy link
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants