Skip to content

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Sep 12, 2025

Description

https://clerk.com/docs/reference/backend-api/tag/machines/get/machines.query.order_by

Checklist

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

Summary by CodeRabbit

  • New Features

    • machines.list now supports sorting via an optional orderBy parameter (name or created_at, ascending/descending).
    • Added query filtering to machines.list for quick matching by ID or name.
    • Enhanced pagination parameters for machines.list, replacing simple limit/offset with a more flexible pagination request.
  • Chores

    • Updated changeset to document the new sorting, filtering, and pagination capabilities for the machines.list API.

@changeset-bot
Copy link

changeset-bot bot commented Sep 12, 2025

🦋 Changeset detected

Latest commit: 7564c37

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

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-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

@vercel
Copy link

vercel bot commented Sep 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Sep 12, 2025 10:44pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Walkthrough

Adds pagination type integration and sorting/filtering options to machines.list via GetMachineListParams, replacing limit/offset with ClerkPaginationRequest and supporting orderBy (name or created_at with sign) and query. Documents the public API addition in a changeset entry.

Changes

Cohort / File(s) Summary
Backend API pagination and sorting update
packages/backend/src/api/endpoints/MachineApi.ts
Replaces limit/offset with ClerkPaginationRequest. Extends GetMachineListParams to include orderBy: WithSign<'name' | 'created_at'> and query?: string. Updates imports and adds inline docs.
Changeset entry (public API note)
.changeset/gentle-lamps-collect.md
Records public API change: machines.list now accepts optional orderBy in input; provides usage snippet.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant BackendSDK as Backend SDK (machines.list)
  participant ClerkAPI as Clerk API
  participant DB as Store

  Client->>BackendSDK: list({ page/size, orderBy?, query? })
  note right of BackendSDK: orderBy supports +/− sign<br/>for name or created_at
  BackendSDK->>ClerkAPI: GET /machines with pagination, orderBy, query
  ClerkAPI->>DB: Fetch machines with filters/sort
  DB-->>ClerkAPI: Rows
  ClerkAPI-->>BackendSDK: Paged result set
  BackendSDK-->>Client: Machines[], page info
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I sort my carrots by name, then date,
Hop through pages—oh, paginate!
A query sniff, a tidy list,
Ascending dreams, descending twist.
With whiskers twitching, I decree:
Order by joy, then warren ID. 🥕🐇

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/machine-list-params

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Comment @coderabbitai help to get the list of available commands and usage tips.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely and accurately describes the primary change — adding an orderBy field to the machine list parameters in the backend — and matches the edits to MachineApi.ts and the machines.list usage. It is short, specific to the affected API surface, and readable for a teammate scanning PR history. It does not include noise or irrelevant details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 12, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6767

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6767

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6767

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6767

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6767

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6767

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6767

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6767

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6767

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6767

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6767

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6767

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6767

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6767

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6767

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6767

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6767

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6767

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6767

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6767

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6767

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6767

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6767

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6767

commit: 7564c37

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
packages/backend/src/api/endpoints/MachineApi.ts (4)

45-48: Validate WithSign semantics to avoid a silent breaking change.

Does WithSign<'name' | 'created_at'> accept bare 'name' (no sign)? The changeset example uses 'name' without +/−. If WithSign requires +/−, existing calls may break. If unsure, widen the type to accept both.

-  orderBy?: WithSign<'name' | 'created_at'>;
+  // Accept bare field or signed variant to preserve BC
+  orderBy?: WithSign<'name' | 'created_at'> | 'name' | 'created_at';

50-52: Grammar nit in JSDoc.

Use “an ID”.

-   * Returns machines that have a ID or name that matches the given query.
+   * Returns machines that have an ID or name that matches the given query.

43-53: Clarify behavior details in docs.

Consider documenting:

  • Allowed fields explicitly: 'name' | 'created_at'
  • Sort direction examples: '+name', '-created_at'
  • Whether query does partial/contains match and case sensitivity

75-81: Add explicit return type to public list method.

Matches our guidelines and improves API clarity.

-  async list(queryParams: GetMachineListParams = {}) {
+  async list(queryParams: GetMachineListParams = {}): Promise<PaginatedResourceResponse<Machine[]>> {
     return this.request<PaginatedResourceResponse<Machine[]>>({
       method: 'GET',
       path: basePath,
       queryParams,
     });
   }
.changeset/gentle-lamps-collect.md (1)

5-14: Align the changeset with the actual API shape and usage.

Document allowed fields and +/− sign; update example accordingly to prevent confusion.

-Added missing `orderBy` field to machines list method
+Add missing `orderBy` field to machines.list input. Supports sorting by `'name'` or `'created_at'`. Prefix with `+` for ASC or `-` for DESC.

 Example:
 
 ```ts
 clerkClient.machines.list({
   ...params,
-  orderBy: 'name'
+  orderBy: '+name' // or '-created_at'
 })

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: Path: .coderabbit.yaml

**Review profile**: CHILL

**Plan**: Pro

**Disabled knowledge base sources:**

- Linear integration is disabled by default for public repositories

> You can enable these sources in your CodeRabbit configuration.

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 526d50506d620f700e3530ef566aad16fb4b4e7c and 7564c37fa8e03677603001d0054bfb5fedc5e6b1.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `.changeset/gentle-lamps-collect.md` (1 hunks)
* `packages/backend/src/api/endpoints/MachineApi.ts` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>📓 Path-based instructions (7)</summary>

<details>
<summary>.changeset/**</summary>


**📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)**

> Automated releases must use Changesets.

Files:
- `.changeset/gentle-lamps-collect.md`

</details>
<details>
<summary>**/*.{js,jsx,ts,tsx}</summary>


**📄 CodeRabbit inference engine (.cursor/rules/development.mdc)**

> `**/*.{js,jsx,ts,tsx}`: All code must pass ESLint checks with the project's configuration
> Follow established naming conventions (PascalCase for components, camelCase for variables)
> Maintain comprehensive JSDoc comments for public APIs
> Use dynamic imports for optional features
> All public APIs must be documented with JSDoc
> Provide meaningful error messages to developers
> Include error recovery suggestions where applicable
> Log errors appropriately for debugging
> Lazy load components and features when possible
> Implement proper caching strategies
> Use efficient data structures and algorithms
> Profile and optimize critical paths
> Validate all inputs and sanitize outputs
> Implement proper logging with different levels

Files:
- `packages/backend/src/api/endpoints/MachineApi.ts`

</details>
<details>
<summary>**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}</summary>


**📄 CodeRabbit inference engine (.cursor/rules/development.mdc)**

> Use Prettier for consistent code formatting

Files:
- `packages/backend/src/api/endpoints/MachineApi.ts`

</details>
<details>
<summary>packages/**/*.{ts,tsx}</summary>


**📄 CodeRabbit inference engine (.cursor/rules/development.mdc)**

> TypeScript is required for all packages

Files:
- `packages/backend/src/api/endpoints/MachineApi.ts`

</details>
<details>
<summary>packages/**/*.{ts,tsx,d.ts}</summary>


**📄 CodeRabbit inference engine (.cursor/rules/development.mdc)**

> Packages should export TypeScript types alongside runtime code

Files:
- `packages/backend/src/api/endpoints/MachineApi.ts`

</details>
<details>
<summary>**/*.{ts,tsx}</summary>


**📄 CodeRabbit inference engine (.cursor/rules/development.mdc)**

> Use proper TypeScript error types
> 
> `**/*.{ts,tsx}`: Always define explicit return types for functions, especially public APIs
> Use proper type annotations for variables and parameters where inference isn't clear
> Avoid `any` type - prefer `unknown` when type is uncertain, then narrow with type guards
> Use `interface` for object shapes that might be extended
> Use `type` for unions, primitives, and computed types
> Prefer `readonly` properties for immutable data structures
> Use `private` for internal implementation details
> Use `protected` for inheritance hierarchies
> Use `public` explicitly for clarity in public APIs
> Prefer `readonly` for properties that shouldn't change after construction
> Prefer composition and interfaces over deep inheritance chains
> Use mixins for shared behavior across unrelated classes
> Implement dependency injection for loose coupling
> Let TypeScript infer when types are obvious
> Use `const assertions` for literal types: `as const`
> Use `satisfies` operator for type checking without widening
> Use mapped types for transforming object types
> Use conditional types for type-level logic
> Leverage template literal types for string manipulation
> Use ES6 imports/exports consistently
> Use default exports sparingly, prefer named exports
> Use type-only imports: `import type { ... } from ...`
> No `any` types without justification
> Proper error handling with typed errors
> Consistent use of `readonly` for immutable data
> Proper generic constraints
> No unused type parameters
> Proper use of utility types instead of manual type construction
> Type-only imports where possible
> Proper tree-shaking friendly exports
> No circular dependencies
> Efficient type computations (avoid deep recursion)

Files:
- `packages/backend/src/api/endpoints/MachineApi.ts`

</details>
<details>
<summary>**/*.{js,ts,tsx,jsx}</summary>


**📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)**

> Support multiple Clerk environment variables (CLERK_*, NEXT_PUBLIC_CLERK_*, etc.) for configuration.

Files:
- `packages/backend/src/api/endpoints/MachineApi.ts`

</details>

</details><details>
<summary>🧬 Code graph analysis (1)</summary>

<details>
<summary>packages/backend/src/api/endpoints/MachineApi.ts (1)</summary><blockquote>

<details>
<summary>packages/types/src/pagination.ts (1)</summary>

* `ClerkPaginationRequest` (4-13)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)</summary>

* GitHub Check: Integration Tests (machine, chrome)
* GitHub Check: Integration Tests (vue, chrome)
* GitHub Check: Integration Tests (billing, chrome)
* GitHub Check: Integration Tests (custom, chrome)
* GitHub Check: Integration Tests (nextjs, chrome, 14)
* GitHub Check: Integration Tests (localhost, chrome)
* GitHub Check: Integration Tests (elements, chrome)
* GitHub Check: Integration Tests (tanstack-react-router, chrome)
* GitHub Check: Integration Tests (tanstack-react-start, chrome)
* GitHub Check: Integration Tests (react-router, chrome)
* GitHub Check: Integration Tests (sessions, chrome)
* GitHub Check: Integration Tests (nextjs, chrome, 15)
* GitHub Check: Integration Tests (ap-flows, chrome)
* GitHub Check: Integration Tests (expo-web, chrome)
* GitHub Check: Integration Tests (astro, chrome)
* GitHub Check: Integration Tests (express, chrome)
* GitHub Check: Integration Tests (nuxt, chrome)
* GitHub Check: Integration Tests (quickstart, chrome)
* GitHub Check: Integration Tests (generic, chrome)
* GitHub Check: Publish with pkg-pr-new
* GitHub Check: Unit Tests (22, **)
* GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
* GitHub Check: Static analysis
* GitHub Check: semgrep-cloud-platform/scan
* GitHub Check: semgrep-cloud-platform/scan

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>packages/backend/src/api/endpoints/MachineApi.ts (3)</summary><blockquote>

`1-1`: **LGTM: type-only import for pagination.**

Consistent with our TS import style and tree-shaking.

---

`9-9`: **No change needed — WithSign is defined locally.**
WithSign is exported at packages/backend/src/api/endpoints/util-types.ts:1, so importing from './util-types' is correct.

---

`75-81`: **No change required — client converts orderBy → order_by.**  
Tests assert the query param 'order_by' is emitted when passing orderBy (packages/backend/src/api/__tests__/SamlConnectionApi.test.ts); endpoints use orderBy in types (e.g. packages/backend/src/api/endpoints/MachineApi.ts). 

> Likely an incorrect or invalid review comment.

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@wobsoriano wobsoriano merged commit 0006c82 into main Sep 13, 2025
42 checks passed
@wobsoriano wobsoriano deleted the rob/machine-list-params branch September 13, 2025 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants