clerk/javascript

Unable to Access users Property in Clerk SDK for Node.js v5.0.2

Subham-Maity opened this issue · 1 comments

Preliminary Checks

Reproduction

https://github.com/Subham-Maity/clerk-nestjs-nextjs

Publishable key

sk_test_SIg2ZrL5mEX

Description

Steps to Reproduce:

  1. Install Clerk SDK for Node.js v5.0.2 (npm install @clerk/clerk-sdk-node@5.0.2).
  2. Attempt to access the users property using the following code snippet:
   import clerkClient from '@clerk/clerk-sdk-node';
   const userList = clerkClient.users.getUserList(); // Throws TS2339 error

Expected Behavior:

The users property should be accessible, as it was in previous versions.

Additional Information:

  • I've checked the official documentation and community resources but couldn't find any specific information on this issue.
  • Environment: Node.js v14+
  • Error Message: TS2339: Property 'users' does not exist on type 'typeof import(...)'.

Actual behavior:

import { Injectable } from '@nestjs/common';
import clerkClient from '@clerk/clerk-sdk-node';

@Injectable()
export class AppService {
  async getUsers() {
    return clerkClient.users.getUserList()
  }
}

TS2339: Property 'users' does not exist on type 'typeof import("C:/0 -Testing Purpose/clerk-nestjs-backend/node_modules/.pnpm/@clerk+clerk-sdk-node@5.0.2_react@18.2.0/node_modules/@clerk/clerk-sdk-node/dist/index")'.

I encountered an issue while using the Clerk SDK for Node.js. The users property, which was previously available in version 4.13.14, seems to be missing in the latest version (5.0.2). As a result, I'm unable to retrieve the user list.

Environment

System:
    OS: Windows 11 10.0.22635
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 5.24 GB / 31.91 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.10.4 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.65), ChromiumDev (123.0.2420.10)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @clerk/clerk-sdk-node: ^5.0.2 => 5.0.2
    @nestjs/cli: ^10.0.0 => 10.3.2
    @nestjs/common: ^10.0.0 => 10.3.7
    @nestjs/config: ^3.2.2 => 3.2.2
    @nestjs/core: ^10.0.0 => 10.3.7
    @nestjs/platform-express: ^10.0.0 => 10.3.7
    @nestjs/schematics: ^10.0.0 => 10.1.1
    @nestjs/testing: ^10.0.0 => 10.3.7
    @types/cookie-parser: ^1.4.7 => 1.4.7
    @types/express: ^4.17.17 => 4.17.21
    @types/jest: ^29.5.2 => 29.5.12
    @types/node: ^20.3.1 => 20.12.5
    @types/supertest: ^6.0.0 => 6.0.2
    @typescript-eslint/eslint-plugin: ^6.0.0 => 6.21.0
    @typescript-eslint/parser: ^6.0.0 => 6.21.0
    cookie-parser: ^1.4.6 => 1.4.6
    eslint: ^8.42.0 => 8.57.0
    eslint-config-prettier: ^9.0.0 => 9.1.0
    eslint-plugin-prettier: ^5.0.0 => 5.1.3
    jest: ^29.5.0 => 29.7.0
    prettier: ^3.0.0 => 3.2.5
    reflect-metadata: ^0.2.0 => 0.2.2
    rxjs: ^7.8.1 => 7.8.1
    source-map-support: ^0.5.21 => 0.5.21
    supertest: ^6.3.3 => 6.3.4
    ts-jest: ^29.1.0 => 29.1.2
    ts-loader: ^9.4.3 => 9.5.1
    ts-node: ^10.9.1 => 10.9.2
    tsconfig-paths: ^4.2.0 => 4.2.0
    typescript: ^5.1.3 => 5.4.4

Hi, thanks for the issue!

Please refer to the upgrade guide when updating a major version of our SDKs. Here's the one for the Node SDK: https://clerk.com/docs/upgrade-guides/core-2/node

Under the Deprecation removals & housekeeping section you'll find:

Users.getUserList return signature changed

The response payload of Users.getUserList was changed as part of the core 2 release. Rather than directly returning data, the return signature is now { data, totalCount }. Since backend API responses are paginated, the totalCount property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.

Here's an example of how the response shape would change with this modification:

- const data = await clerkClient.users.getUserList()
+ const { data, totalCount } = await clerkClient.users.getUserList()