Skip to content

[INFRA-395] feat: add Workflows and ProjectTemplates API resources#45

Open
mguptahub wants to merge 2 commits into
mainfrom
infra-395/node-sdk-project-level-apis
Open

[INFRA-395] feat: add Workflows and ProjectTemplates API resources#45
mguptahub wants to merge 2 commits into
mainfrom
infra-395/node-sdk-project-level-apis

Conversation

@mguptahub
Copy link
Copy Markdown

@mguptahub mguptahub commented May 28, 2026

Summary

  • Adds Workflows resource with list, create, update — plus states sub-resource (attach/detach) and transitions sub-resource (list, create, update, del)
  • Adds ProjectTemplates resource with two sub-resources: workItems (work item templates CRUD) and pages (page templates CRUD)
  • Registers both on PlaneClient and exports all classes + types from the package index
  • Adds TypeScript model interfaces: Workflow, WorkflowTransition, WorkItemTemplate, PageTemplate and their Create/Update DTOs
  • Unit tests for both resources (tests/unit/workflows/workflow.test.ts, tests/unit/project-templates.test.ts)
  • README API Resources section updated to include Workflows, ProjectTemplates, Milestones, and AgentRuns

Notes

  • WorkflowTransitions.create returns null (instead of throwing) when the API responds 400 "already exists" — mirrors Python SDK behaviour
  • Workflows are currently project-scoped; workspace-level workflow methods will be added to the same class when the backend ships them

Test plan

  • Set PLANE_API_KEY, PLANE_BASE_URL, TEST_WORKSPACE_SLUG, TEST_PROJECT_ID and run pnpm test tests/unit/workflows/ and pnpm test tests/unit/project-templates.test.ts
  • pnpm check:lint — 0 errors
  • pnpm check:format — all files correctly formatted
  • pnpm build — compiles cleanly

Co-authored-by: Plane AI noreply@plane.so

Summary by CodeRabbit

  • New Features

    • Added Workflows API to manage project workflows, including workflow states and state transitions.
    • Added ProjectTemplates API to manage work item and page templates for projects.
  • Documentation

    • Updated README with newly available API resources.

Review Change Stack

Adds project-level Workflows (with WorkflowStates and WorkflowTransitions
sub-resources) and ProjectTemplates (WorkItem and Page templates) to the
Node SDK, matching INFRA-395 parity with the Python SDK.

- src/api/Workflows/ — list, create, update; states attach/detach; transitions list, create, update, del
- src/api/ProjectTemplates/ — work item templates and page templates CRUD
- src/models/Workflow.ts, ProjectTemplate.ts — TypeScript interfaces and DTOs
- Registered on PlaneClient and exported from index
- Unit tests for both resources
- README API resources section updated

Co-authored-by: Plane AI <noreply@plane.so>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

This PR introduces two new API resource modules—Workflows and ProjectTemplates—to the Plane Node SDK. It defines TypeScript models for both resources, implements CRUD-style API clients with typed methods and sub-resources, integrates them into the PlaneClient, and adds comprehensive end-to-end tests and documentation updates.

Changes

Workflows and ProjectTemplates API Resources

Layer / File(s) Summary
Workflow and ProjectTemplate data models
src/models/Workflow.ts, src/models/ProjectTemplate.ts, src/models/index.ts
Workflow, ProjectTemplate, and related payload interfaces (create, update, state attachment, transitions) with required/optional field distinctions and BaseModel extension.
ProjectTemplates API with Pages and WorkItems sub-resources
src/api/ProjectTemplates/Pages.ts, src/api/ProjectTemplates/WorkItems.ts, src/api/ProjectTemplates/index.ts
Pages and WorkItems resource classes expose list/create/update/delete methods with response normalization; ProjectTemplates wires both as public sub-resources.
Workflows API with States and Transitions sub-resources
src/api/Workflows/States.ts, src/api/Workflows/Transitions.ts, src/api/Workflows/index.ts
States provides attach/detach methods; Transitions provides CRUD with null-on-duplicate handling; Workflows wires both as public sub-resources and provides list/create/update.
PlaneClient wiring and public exports
src/client/plane-client.ts, src/index.ts
Workflows and ProjectTemplates properties added to PlaneClient and initialized in constructor; new resources and sub-resources exported from index.
ProjectTemplates CRUD tests
tests/unit/project-templates.test.ts
End-to-end test suite for work item and page templates covering creation, listing, updating, deletion with field and presence assertions.
Workflows lifecycle and transition tests
tests/unit/workflows/workflow.test.ts
Integration test suite covering workflow creation/listing/updating, state attachment/detachment, and full transition CRUD lifecycle.
README API Resources list update
README.md
Adds Workflows and ProjectTemplates to the documented API resources.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 New resources hop into view,
Templates and workflows bloom anew,
States transition with grace so fine,
Your SDK's API doth now align!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The PR title clearly and concisely summarizes the main addition: two new API resources (Workflows and ProjectTemplates) being added to the SDK.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch infra-395/node-sdk-project-level-apis

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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.

❤️ Share

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

@makeplane
Copy link
Copy Markdown

makeplane Bot commented May 28, 2026

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

Copy link
Copy Markdown

@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: 5

🧹 Nitpick comments (1)
src/models/Workflow.ts (1)

1-1: 🏗️ Heavy lift

Rename this new module to kebab-case to match source file conventions.

src/models/Workflow.ts should follow kebab-case naming for src/**/*.ts files to keep module naming consistent across new additions.

As per coding guidelines src/**/*.ts: Use kebab-case for file names.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/Workflow.ts` at line 1, Rename the module file
src/models/Workflow.ts to kebab-case (e.g., src/models/workflow.ts) and update
every import that references "Workflow" (for example imports like import { X }
from "./models/Workflow" or "src/models/Workflow") to the new path
"./models/workflow"; ensure any barrel/index exports or path mappings that
re-export the module are updated as well so the exported symbols (the
types/classes previously coming from Workflow.ts) continue to resolve.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/api/Workflows/Transitions.ts`:
- Around line 41-43: In the create() error path inside Transitions.ts the code
uses JSON.stringify(error.response) which can throw for non-serializable
responses; instead, defensively extract a string to inspect for "already
exists": check typeof error.response === "string" and use it, else if
error.response?.message is a string use that, else fall back to error.message or
an empty string; call .toLowerCase() only after ensuring you have a string and
then test .includes("already exists"); keep the existing HttpError check and
return null when the duplicate is detected.

In `@src/models/ProjectTemplate.ts`:
- Around line 15-25: CreateWorkItemTemplate and UpdateWorkItemTemplate should be
derived from the WorkItemTemplate model instead of duplicating fields: replace
the explicit property lists by defining CreateWorkItemTemplate =
Pick<WorkItemTemplate, 'name' | 'short_description' | 'template_data'> and
UpdateWorkItemTemplate = Partial<CreateWorkItemTemplate> (or
Partial<Pick<WorkItemTemplate, ...>>) so updates are optional; do the same for
CreatePageTemplate/UpdatePageTemplate by deriving from PageTemplate using Pick
for create DTOs and Partial for update DTOs to keep DTOs in sync with model
changes.

In `@src/models/Workflow.ts`:
- Around line 16-28: The CreateWorkflow and UpdateWorkflow DTOs currently
duplicate slices of the core Workflow model; update them to derive from the
canonical Workflow interface using TypeScript utility types (e.g., export type
CreateWorkflow = Pick<Workflow, 'name' | 'description' | 'work_item_type_ids'> &
{ is_active?: boolean } or export type UpdateWorkflow = Partial<Pick<Workflow,
'name' | 'description' | 'work_item_type_ids' | 'is_active'>>), and apply the
same pattern to CreateWorkflowTransition/UpdateWorkflowTransition so changes to
Workflow/WorkflowTransition don't drift; locate the DTOs named CreateWorkflow
and UpdateWorkflow in this file and replace the standalone interfaces with
derived types using Pick/Partial/Required as appropriate.

In `@tests/unit/project-templates.test.ts`:
- Around line 82-84: The test is using expect(promise).resolves.not.toThrow(),
which is invalid because toThrow applies to functions; replace that assertion on
client.projectTemplates.workItems.del(workspaceSlug, projectId,
workItemTemplate.id!) with a promise-aware matcher such as await
expect(client.projectTemplates.workItems.del(...)).resolves.toBeUndefined() (or
.resolves.toBeDefined() if the API returns a value) to assert the delete
succeeded; make the same change for the identical patterns in
tests/unit/workflows/workflow.test.ts (the assertions around the delete calls at
the referenced locations).

In `@tests/unit/workflows/workflow.test.ts`:
- Around line 102-106: The tests use the invalid Jest matcher
`.resolves.not.toThrow()` for promise-returning calls; update the assertions to
check the resolved value instead (e.g., use `.resolves.toBeUndefined()` for
Promise<void>). Specifically change the assertions for
client.workflows.states.attach(...) (previously at the attach call),
client.workflows.transitions.del(...) (the delete transition call), and
client.workflows.states.detach(...) (the detach call) to assert the promise
resolves to undefined (or another expected resolved value) rather than using
toThrow.

---

Nitpick comments:
In `@src/models/Workflow.ts`:
- Line 1: Rename the module file src/models/Workflow.ts to kebab-case (e.g.,
src/models/workflow.ts) and update every import that references "Workflow" (for
example imports like import { X } from "./models/Workflow" or
"src/models/Workflow") to the new path "./models/workflow"; ensure any
barrel/index exports or path mappings that re-export the module are updated as
well so the exported symbols (the types/classes previously coming from
Workflow.ts) continue to resolve.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 030224fd-dad9-4008-acf5-9407114a12df

📥 Commits

Reviewing files that changed from the base of the PR and between becbd90 and f0b453a.

📒 Files selected for processing (14)
  • README.md
  • src/api/ProjectTemplates/Pages.ts
  • src/api/ProjectTemplates/WorkItems.ts
  • src/api/ProjectTemplates/index.ts
  • src/api/Workflows/States.ts
  • src/api/Workflows/Transitions.ts
  • src/api/Workflows/index.ts
  • src/client/plane-client.ts
  • src/index.ts
  • src/models/ProjectTemplate.ts
  • src/models/Workflow.ts
  • src/models/index.ts
  • tests/unit/project-templates.test.ts
  • tests/unit/workflows/workflow.test.ts

Comment thread src/api/Workflows/Transitions.ts
Comment thread src/models/ProjectTemplate.ts Outdated
Comment thread src/models/Workflow.ts Outdated
Comment thread tests/unit/project-templates.test.ts Outdated
Comment thread tests/unit/workflows/workflow.test.ts Outdated
- Transitions.ts: harden error.response parsing in create() — defensive
  type check instead of JSON.stringify to avoid throw on non-serializable payloads
- Workflow.ts: derive CreateWorkflow/UpdateWorkflow and
  CreateWorkflowTransition/UpdateWorkflowTransition from model interfaces
  via Pick/Partial/Required instead of duplicating fields
- ProjectTemplate.ts: same — derive Create/Update DTOs from
  WorkItemTemplate and PageTemplate via Pick/Partial
- Tests: replace resolves.not.toThrow() with resolves.toBeUndefined()
  for Promise<void> assertions (workflow + project-templates)

Co-authored-by: Plane AI <noreply@plane.so>
@mguptahub mguptahub requested a review from Prashant-Surya May 28, 2026 06:19
@mguptahub mguptahub changed the title feat: add Workflows and ProjectTemplates API resources [INFRA-395] [INFRA-395] feat: add Workflows and ProjectTemplates API resources May 28, 2026
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.

1 participant