Skip to content

fix(events): add missing order parameter to listEvents#1524

Merged
nicknisi merged 1 commit intomainfrom
fix/issue-1523
Mar 18, 2026
Merged

fix(events): add missing order parameter to listEvents#1524
nicknisi merged 1 commit intomainfrom
fix/issue-1523

Conversation

@nicknisi
Copy link
Member

Summary

The WorkOS API docs list order as a valid parameter for the List Events endpoint (GET /events), accepting asc or desc. The Node SDK's listEvents method did not expose this parameter, preventing users from sorting events without manually constructing requests. This adds the order field to the ListEventOptions and SerializedListEventOptions interfaces and passes it through the serializer.

What was tested

Automated

  • All 596 unit tests pass (0 failures)
  • New test verifies order: 'desc' is sent as a query parameter
  • Build, lint, and format checks all pass

Manual

SDK-only repo with no browser-testable application. Verification performed via unit tests, build, lint, typecheck, and format checks. Playwright N/A for pure library packages.

Verification

N/A -- this is a pure SDK library change with no UI. Verified through unit tests confirming the order parameter is correctly serialized and sent in the API request query string.

Manual reproduction steps

  1. On main, call workos.events.listEvents({ events: ['connection.activated'], order: 'desc' }) -- TypeScript rejects the order property (not in interface)
  2. On this branch, the same call compiles and sends ?order=desc to the API
  3. Run npm test src/events/events.spec.ts to see the new test pass (6/6)

Issue

Closes #1523

Follow-ups

None

The WorkOS API accepts an `order` param on GET /events but the SDK did not expose it. Add `order?: 'asc' | 'desc'` to ListEventOptions and SerializedListEventOptions, pass it through the serializer, and add a test verifying it is sent in the query string.
@nicknisi nicknisi requested review from a team as code owners March 18, 2026 14:48
@nicknisi nicknisi requested a review from atainter March 18, 2026 14:48
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR adds the missing order parameter ('asc' | 'desc') to the listEvents method by updating the ListEventOptions and SerializedListEventOptions interfaces and threading it through the serializer. The change is minimal, targeted, and fully consistent with how the order parameter is handled across the rest of the SDK (e.g., sso, directory-sync, user-management, fga).

  • Added order?: 'asc' | 'desc' to both ListEventOptions and SerializedListEventOptions in list-events-options.interface.ts, matching the same type used in the shared PaginationOptions interface.
  • Added order: options.order to the serializeListEventOptions function, consistent with all other list serializers in the codebase.
  • Added a focused unit test confirming order: 'desc' is correctly serialized and sent as a query parameter.

Confidence Score: 5/5

  • This PR is safe to merge — it is a small, additive interface and serializer change with no breaking modifications.
  • The change is purely additive (new optional field), follows the established SDK patterns exactly, and is covered by a new unit test. No logic changes, no security concerns, no risk of regression.
  • No files require special attention.

Important Files Changed

Filename Overview
src/events/interfaces/list-events-options.interface.ts Adds `order?: 'asc'
src/events/serializers/list-event-options.serializer.ts Passes options.order through to the serialized output. Pattern matches all other list serializers in the codebase (e.g., sso, directory-sync, user-management).
src/events/events.spec.ts Adds one new test that verifies order: 'desc' is serialized and sent as a query parameter. Follows existing test conventions using fetchOnce/fetchSearchParams.

Sequence Diagram

sequenceDiagram
    participant Caller as SDK Caller
    participant ListEvents as workos.events.listEvents()
    participant Serializer as serializeListEventOptions()
    participant API as WorkOS API (GET /events)

    Caller->>ListEvents: { events: [...], order: 'desc' }
    ListEvents->>Serializer: ListEventOptions
    Serializer-->>ListEvents: { events, order: 'desc', ... }
    ListEvents->>API: GET /events?events=...&order=desc
    API-->>ListEvents: ListResponse<EventResponse>
    ListEvents-->>Caller: ListResponse<Event>
Loading

Last reviewed commit: "fix(events): add mis..."

@nicknisi nicknisi merged commit 2f3dcb4 into main Mar 18, 2026
8 checks passed
@nicknisi nicknisi deleted the fix/issue-1523 branch March 18, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Events listEvents doesn't have order argument

2 participants