Skip to content

feat(workspace-users): exclude removed users by default#138

Merged
scottlovegrove merged 2 commits into
mainfrom
scottl/include-removed-default
May 22, 2026
Merged

feat(workspace-users): exclude removed users by default#138
scottlovegrove merged 2 commits into
mainfrom
scottl/include-removed-default

Conversation

@scottlovegrove
Copy link
Copy Markdown
Collaborator

@scottlovegrove scottlovegrove commented May 22, 2026

Summary

  • getWorkspaceUsers now excludes users with removed: true by default; pass includeRemoved: true to include them.
  • The Twist API endpoint /workspace_users/get (server: workspace_users.py get(id)) calls workspaces.get_users(ws.id) without the model's with_removed arg, so it's hardcoded to with_removed=True and exposes no override param. Filtering therefore happens client-side in the SDK — matching what twist-web (Redux selectors) and twist-cli already do.
  • Applied to both execution paths: the awaited call filters in .then(); the batch path uses a new optional transform?: (data: unknown) => T hook on BatchRequestDescriptor, applied after schema parse in batch-builder.ts. The batch descriptor now also carries z.array(WorkspaceUserSchema), so batch results are validated too.

Prompted by twist-cli#245 review — the default belongs in the SDK so cli/MCP can drop their own filtering.

Test plan

  • getWorkspaceUsers excludes removed users by default (awaited + batch)
  • includeRemoved: true returns all users (awaited + batch)
  • No include_removed/with_removed query param is sent (proves client-side filtering)
  • Full suite green (245 tests), type-check, oxlint, oxfmt clean

🤖 Generated with Claude Code

getWorkspaceUsers now omits removed users unless includeRemoved is true.
The Twist API always returns removed users with no override param, so the
SDK filters client-side in both the awaited and batch paths — the latter
via a new optional transform hook on BatchRequestDescriptor. This lets
consumers (twist-cli, MCP) drop their own client-side filtering.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove self-assigned this May 22, 2026
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

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

This PR cleanly introduces default client-side filtering for removed workspace users across both awaited and batch execution paths, nicely aligning the SDK's behavior with other clients. The implementation is straightforward and effectively addresses the current backend API limitations. A few refinements were noted around leveraging Zod's built-in transform capabilities to simplify the custom hook logic, optimizing performance by filtering out removed users before paying the schema validation cost, and strengthening the test suite through better mock reuse, consistent apiUrl helper usage, and explicit query parameter assertions on batch requests.

Share FeedbackReview Logs

Comment thread src/clients/workspace-users-client.ts Outdated
Comment thread src/clients/workspace-users-client.ts Outdated
Comment thread src/batch-builder.ts Outdated
Comment thread src/clients/workspace-users-client.test.ts Outdated
Comment thread src/clients/workspace-users-client.test.ts Outdated
Comment thread src/clients/workspace-users-client.test.ts Outdated
Replace the custom BatchRequestDescriptor transform hook with
z.array(WorkspaceUserSchema).transform(filterRemoved), shared by both the
awaited and batch paths. Reverts the batch type/builder changes since the
schema now carries the filtering. Also tighten batch tests: reuse shared
mocks, use the apiUrl helper, and assert no include_removed/with_removed
param is serialized.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove merged commit 6e4b93f into main May 22, 2026
4 checks passed
@scottlovegrove scottlovegrove deleted the scottl/include-removed-default branch May 22, 2026 15:11
doist-release-bot Bot added a commit that referenced this pull request May 22, 2026
## [2.8.0](v2.7.1...v2.8.0) (2026-05-22)

### Features

* **workspace-users:** exclude removed users by default ([#138](#138)) ([6e4b93f](6e4b93f)), closes [twist-cli#245](Doist/twist-cli#245)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants