feat: rich filters + pql on work-item list endpoints, add listWorkspace [WEB-7393]#43
feat: rich filters + pql on work-item list endpoints, add listWorkspace [WEB-7393]#43dheeru0198 wants to merge 2 commits into
Conversation
Expose the new external API's structured filtering capability on every work-item list method in the SDK. - ListWorkItemsParams now accepts `filters?: Record<string, unknown>` (the existing `pql?: string` field is unchanged) plus the standard pagination/ordering fields. AdvancedSearchWorkItem also gains `pql`. - New `prepareWorkItemParams` helper JSON-encodes `filters` into the `filters=` query parameter the API expects; everything else passes through unchanged. - New `WorkItems.listWorkspace(workspaceSlug, params)` calling GET /workspaces/<slug>/work-items/ — paginated, total_results, spans every project the caller can view. - `WorkItems.list`, `Cycles.listWorkItemsInCycle`, and `Modules.listWorkItemsInModule` route through the helper. Typed the `params` argument on the latter two (was previously `any`). - Real-API tests for `filters` on `list` and `listWorkspace`. - Bump version to 0.2.12. Backend: makeplane/plane-ee#7376
|
Warning Review limit reached
More reviews will be available in 32 minutes and 13 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
There was a problem hiding this comment.
Pull request overview
Adds SDK support for Plane’s newer work-item list filtering features (structured filters + existing pql) across project, cycle, and module list endpoints, and introduces a new workspace-scoped work-item listing method to match the backend’s new endpoint.
Changes:
- Extend
ListWorkItemsParamsto includefiltersplus cursor/pagination/sorting fields; add optionalpqltoAdvancedSearchWorkItem. - Add
prepareWorkItemParams()to JSON-encodefiltersinto thefilters=query parameter, and route work-item list endpoints through it. - Add
workItems.listWorkspace(...)and update docs/tests + bump package version to0.2.12.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/work-items/work-items.test.ts | Adds real-API tests for structured filters and the new workspace-scoped list endpoint. |
| src/models/WorkItem.ts | Updates list/search parameter types to include filters, pql, and pagination/sorting fields. |
| src/api/WorkItems/index.ts | Adds prepareWorkItemParams, wires it into list endpoints, and introduces listWorkspace. |
| src/api/Modules.ts | Types module work-item listing params as ListWorkItemsParams and routes through the helper. |
| src/api/Cycles.ts | Types cycle work-item listing params as ListWorkItemsParams and routes through the helper. |
| README.md | Documents how to use filters and pql, including workspace-scoped listing. |
| package.json | Bumps SDK version to 0.2.12. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const filtered = await client.workItems.list(workspaceSlug, projectId, { | ||
| filters: { priority: "urgent" }, | ||
| }); | ||
|
|
||
| expect(filtered).toBeDefined(); | ||
| expect(Array.isArray(filtered.results)).toBe(true); | ||
| const ids = filtered.results.map((wi) => wi.id); | ||
| expect(ids).toContain(urgent.id); | ||
| expect(ids).not.toContain(low.id); |
| const unfiltered = await client.workItems.listWorkspace(workspaceSlug); | ||
| expect(unfiltered).toBeDefined(); | ||
| expect(typeof unfiltered.total_results).toBe("number"); | ||
|
|
||
| const filtered = await client.workItems.listWorkspace(workspaceSlug, { | ||
| filters: { priority: "urgent" }, | ||
| }); | ||
| expect(filtered).toBeDefined(); | ||
| expect(filtered.total_results).toBeLessThanOrEqual(unfiltered.total_results); | ||
| expect(filtered.total_results).toBeGreaterThan(0); | ||
| } finally { |
| fields?: string; | ||
| expand?: string; | ||
| /** | ||
| * Plane Query Language expression for structured filtering. |
Address Copilot review: - `list with structured filters` test could be flaky: the just-created urgent item might land on a later page in busy workspaces, breaking `expect(ids).toContain(urgent.id)`. Add `order_by: "-created_at"` and `per_page: 100`, and also assert that every returned item has `priority === "urgent"` — that's the property the test is meant to prove regardless of pagination luck. - `listWorkspace` filters test could pass even when filtering was ignored (it only checked `total_results` bounds). Add the same per-item `priority === "urgent"` assertion plus the same pagination flags. - `pql` docstring in `WorkItem.ts` said "expression for structured filtering", which is misleading — `filters` is structured, `pql` is string-based. Reword.
Summary
Exposes the new external API's structured filtering capability across every work-item list method in the SDK, plus a new
listWorkspacemethod for the workspace-scoped paginated list endpoint added in makeplane/plane-ee#7376.Changes
ListWorkItemsParamsnow acceptsfilters?: Record<string, unknown>(the existingpql?: stringfield is unchanged) plus the standardcursor/per_page/order_by/fields/expandfields.AdvancedSearchWorkItemalso gains an optionalpql?: string.prepareWorkItemParams(params)helper (exported fromWorkItems/index.ts) JSON-encodesfiltersinto the singlefilters=query parameter the API expects; everything else passes through unchanged.WorkItems.listWorkspace(workspaceSlug, params)callingGET /workspaces/<slug>/work-items/. Returns a paginated envelope with fulltotal_results; spans every project in the workspace the caller can view (per-project authorization and conditional grants are honored server-side).WorkItems.list,Cycles.listWorkItemsInCycle, andModules.listWorkItemsInModuleroute through the helper. The latter two hadparams?: anypreviously — now properly typed asListWorkItemsParams.filtersonlistandlistWorkspace(real-API pattern, matches existing test conventions).Backend
Test plan
pnpm install+pnpm build— succeedspnpm check:lint— 0 errors (105 pre-existing warnings unrelated)pnpm check:format— clean (auto-formatted).env.testagainst an env with the plane-ee branch deployed;pnpm test -- --testPathPattern=tests/unit/work-itemsshould pass the newlist_workspace_work_items_with_filterstest plus the structured-filterstest.References
🤖 Generated with Claude Code