Skip to content

Commit 88c1280

Browse files
[SILO-676] feat: new api clients and tests (#16)
* add clients for project ws features + stickies + initiatives + teamspaces * fix sticky model * add tests for new apis * fix formatting * add initiative state enum * fix: move binary description fields to readonly in sticky * bump version to 0.2.1 --------- Co-authored-by: Surya Prashanth <[email protected]>
1 parent 340363e commit 88c1280

28 files changed

+1244
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ const project = await client.projects.create("workspace-slug", {
7272
- **Workspace**: Workspace-level operations
7373
- **Epics**: Epic management and organization
7474
- **Intake**: Intake form and request management
75+
- **Stickies**: Stickies management
76+
- **Teamspaces**: Teamspace management
77+
- **Initiatives**: Initiative management
78+
- **Features**: Workspace and project features management
7579

7680
## Development
7781

@@ -129,6 +133,8 @@ pnpm test
129133

130134
# Run specific test files
131135
pnpx ts-node tests/page.test.ts
136+
# or
137+
pnpm test page.test.ts
132138
```
133139

134140
## License

env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Plane Node SDK Test Configuration
22
# Copy this file to .env.test and update with your test environment values
33

4+
# API configuration
5+
PLANE_API_KEY=your-plane-api-key
6+
PLANE_BASE_URL=your-plane-base-url
7+
48
# Workspace configuration
59
TEST_WORKSPACE_SLUG=your-workspace-slug
610

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@makeplane/plane-node-sdk",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Node SDK for Plane",
55
"author": "Plane <[email protected]>",
66
"repository": {

src/api/BaseResource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ export abstract class BaseResource {
111111
/**
112112
* DELETE request
113113
*/
114-
protected async httpDelete(endpoint: string): Promise<void> {
114+
protected async httpDelete(endpoint: string, data?: any): Promise<void> {
115115
try {
116116
await axios.delete(this.buildUrl(endpoint), {
117117
headers: this.getHeaders(),
118+
data,
118119
});
119120
} catch (error) {
120121
throw this.handleError(error);

src/api/Initiatives/Epics.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { BaseResource } from "../BaseResource";
2+
import { Configuration } from "../../Configuration";
3+
import { Epic } from "../../models/Epic";
4+
import { PaginatedResponse } from "../../models/common";
5+
import { AddInitiativeEpicsRequest, RemoveInitiativeEpicsRequest } from "../../models/Initiative";
6+
7+
/**
8+
* Initiative Epics API resource
9+
* Handles initiative epic relationships
10+
*/
11+
export class Epics extends BaseResource {
12+
constructor(config: Configuration) {
13+
super(config);
14+
}
15+
16+
/**
17+
* Get epics associated with an initiative
18+
*/
19+
async list(workspaceSlug: string, initiativeId: string, params?: { limit?: number; offset?: number }): Promise<PaginatedResponse<Epic>> {
20+
return this.get<PaginatedResponse<Epic>>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/epics/`, params);
21+
}
22+
23+
/**
24+
* Add epics to an initiative
25+
*/
26+
async add(workspaceSlug: string, initiativeId: string, addEpics: AddInitiativeEpicsRequest): Promise<Epic[]> {
27+
return this.post<Epic[]>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/epics/`, addEpics);
28+
}
29+
30+
/**
31+
* Remove epics from an initiative
32+
*/
33+
async remove(workspaceSlug: string, initiativeId: string, removeEpics: RemoveInitiativeEpicsRequest): Promise<void> {
34+
return this.httpDelete(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/epics/`, removeEpics);
35+
}
36+
}
37+

src/api/Initiatives/Labels.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { BaseResource } from "../BaseResource";
2+
import { Configuration } from "../../Configuration";
3+
import { InitiativeLabel, CreateInitiativeLabel, UpdateInitiativeLabel, ListInitiativeLabelsParams } from "../../models/InitiativeLabel";
4+
import { PaginatedResponse } from "../../models/common";
5+
import { AddInitiativeLabelsRequest, RemoveInitiativeLabelsRequest } from "../../models/Initiative";
6+
7+
/**
8+
* Initiative Labels API resource
9+
* Handles initiative label relationships
10+
*/
11+
export class Labels extends BaseResource {
12+
constructor(config: Configuration) {
13+
super(config);
14+
}
15+
16+
/**
17+
* Create a new initiative label
18+
*/
19+
async create(workspaceSlug: string, createInitiativeLabel: CreateInitiativeLabel): Promise<InitiativeLabel> {
20+
return this.post<InitiativeLabel>(`/workspaces/${workspaceSlug}/initiatives/labels/`, createInitiativeLabel);
21+
}
22+
23+
/**
24+
* Retrieve an initiative label by ID
25+
*/
26+
async retrieve(workspaceSlug: string, initiativeLabelId: string): Promise<InitiativeLabel> {
27+
return this.get<InitiativeLabel>(`/workspaces/${workspaceSlug}/initiatives/labels/${initiativeLabelId}/`);
28+
}
29+
30+
/**
31+
* Update an initiative label
32+
*/
33+
async update(workspaceSlug: string, initiativeLabelId: string, updateInitiativeLabel: UpdateInitiativeLabel): Promise<InitiativeLabel> {
34+
return this.patch<InitiativeLabel>(`/workspaces/${workspaceSlug}/initiatives/labels/${initiativeLabelId}/`, updateInitiativeLabel);
35+
}
36+
37+
/**
38+
* Delete an initiative label
39+
*/
40+
async delete(workspaceSlug: string, initiativeLabelId: string): Promise<void> {
41+
return this.httpDelete(`/workspaces/${workspaceSlug}/initiatives/labels/${initiativeLabelId}/`);
42+
}
43+
44+
/**
45+
* List initiative labels with optional filtering
46+
*/
47+
async list(workspaceSlug: string, params?: ListInitiativeLabelsParams): Promise<PaginatedResponse<InitiativeLabel>> {
48+
return this.get<PaginatedResponse<InitiativeLabel>>(`/workspaces/${workspaceSlug}/initiatives/labels/`, params);
49+
}
50+
51+
/**
52+
* Add labels to an initiative
53+
*/
54+
async addLabels(workspaceSlug: string, initiativeId: string, addLabels: AddInitiativeLabelsRequest): Promise<InitiativeLabel[]> {
55+
return this.post<InitiativeLabel[]>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/labels/`, addLabels);
56+
}
57+
58+
/**
59+
* Remove labels from an initiative
60+
*/
61+
async removeLabels(workspaceSlug: string, initiativeId: string, removeLabels: RemoveInitiativeLabelsRequest): Promise<void> {
62+
return this.httpDelete(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/labels/`, removeLabels);
63+
}
64+
65+
/**
66+
* Get labels associated with an initiative
67+
*/
68+
async listLabels(workspaceSlug: string, initiativeId: string, params?: { limit?: number; offset?: number }): Promise<PaginatedResponse<InitiativeLabel>> {
69+
return this.get<PaginatedResponse<InitiativeLabel>>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/labels/`, params);
70+
}
71+
72+
}
73+

src/api/Initiatives/Projects.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { BaseResource } from "../BaseResource";
2+
import { Configuration } from "../../Configuration";
3+
import { Project } from "../../models/Project";
4+
import { PaginatedResponse } from "../../models/common";
5+
import { AddInitiativeProjectsRequest, RemoveInitiativeProjectsRequest } from "../../models/Initiative";
6+
7+
/**
8+
* Initiative Projects API resource
9+
* Handles initiative project relationships
10+
*/
11+
export class Projects extends BaseResource {
12+
constructor(config: Configuration) {
13+
super(config);
14+
}
15+
16+
/**
17+
* Get projects associated with an initiative
18+
*/
19+
async list(workspaceSlug: string, initiativeId: string, params?: { limit?: number; offset?: number }): Promise<PaginatedResponse<Project>> {
20+
return this.get<PaginatedResponse<Project>>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/projects/`, params);
21+
}
22+
23+
/**
24+
* Add projects to an initiative
25+
*/
26+
async add(workspaceSlug: string, initiativeId: string, addProjects: AddInitiativeProjectsRequest): Promise<Project[]> {
27+
return this.post<Project[]>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/projects/`, addProjects);
28+
}
29+
30+
/**
31+
* Remove projects from an initiative
32+
*/
33+
async remove(workspaceSlug: string, initiativeId: string, removeProjects: RemoveInitiativeProjectsRequest): Promise<void> {
34+
return this.httpDelete(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/projects/`, removeProjects);
35+
}
36+
}
37+

src/api/Initiatives/index.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { BaseResource } from "../BaseResource";
2+
import { Configuration } from "../../Configuration";
3+
import { Initiative, CreateInitiative, UpdateInitiative, ListInitiativesParams } from "../../models/Initiative";
4+
import { PaginatedResponse } from "../../models/common";
5+
import { Labels } from "./Labels";
6+
import { Projects } from "./Projects";
7+
import { Epics } from "./Epics";
8+
9+
/**
10+
* Initiatives API resource
11+
* Handles all initiative-related operations
12+
*/
13+
export class Initiatives extends BaseResource {
14+
public labels: Labels;
15+
public projects: Projects;
16+
public epics: Epics;
17+
18+
constructor(config: Configuration) {
19+
super(config);
20+
this.labels = new Labels(config);
21+
this.projects = new Projects(config);
22+
this.epics = new Epics(config);
23+
}
24+
25+
/**
26+
* Create a new initiative
27+
*/
28+
async create(workspaceSlug: string, createInitiative: CreateInitiative): Promise<Initiative> {
29+
return this.post<Initiative>(`/workspaces/${workspaceSlug}/initiatives/`, createInitiative);
30+
}
31+
32+
/**
33+
* Retrieve an initiative by ID
34+
*/
35+
async retrieve(workspaceSlug: string, initiativeId: string): Promise<Initiative> {
36+
return this.get<Initiative>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/`);
37+
}
38+
39+
/**
40+
* Update an initiative
41+
*/
42+
async update(workspaceSlug: string, initiativeId: string, updateInitiative: UpdateInitiative): Promise<Initiative> {
43+
return this.patch<Initiative>(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/`, updateInitiative);
44+
}
45+
46+
/**
47+
* Delete an initiative
48+
*/
49+
async delete(workspaceSlug: string, initiativeId: string): Promise<void> {
50+
return this.httpDelete(`/workspaces/${workspaceSlug}/initiatives/${initiativeId}/`);
51+
}
52+
53+
/**
54+
* List initiatives with optional filtering
55+
*/
56+
async list(workspaceSlug: string, params?: ListInitiativesParams): Promise<PaginatedResponse<Initiative>> {
57+
return this.get<PaginatedResponse<Initiative>>(`/workspaces/${workspaceSlug}/initiatives/`, params);
58+
}
59+
}
60+

src/api/Projects.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Configuration } from "../Configuration";
33
import { Project, CreateProject, UpdateProject, ListProjectsParams } from "../models/Project";
44
import { PaginatedResponse } from "../models/common";
55
import { User } from "../models/User";
6+
import { ProjectFeatures, UpdateProjectFeatures } from "../models/ProjectFeatures";
67

78
/**
89
* Project API resource
@@ -65,4 +66,22 @@ export class Projects extends BaseResource {
6566
async getTotalWorkLogs(workspaceSlug: string, projectId: string): Promise<any> {
6667
return this.get<any>(`/workspaces/${workspaceSlug}/projects/${projectId}/work-logs/total/`);
6768
}
69+
70+
/**
71+
* Retrieve project features
72+
*/
73+
async retrieveFeatures(workspaceSlug: string, projectId: string): Promise<ProjectFeatures> {
74+
return this.get<ProjectFeatures>(`/workspaces/${workspaceSlug}/projects/${projectId}/features/`);
75+
}
76+
77+
/**
78+
* Update project features
79+
*/
80+
async updateFeatures(
81+
workspaceSlug: string,
82+
projectId: string,
83+
updateFeatures: UpdateProjectFeatures
84+
): Promise<ProjectFeatures> {
85+
return this.patch<ProjectFeatures>(`/workspaces/${workspaceSlug}/projects/${projectId}/features/`, updateFeatures);
86+
}
6887
}

src/api/Stickies.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { BaseResource } from "./BaseResource";
2+
import { Configuration } from "../Configuration";
3+
import { PaginatedResponse } from "../models/common";
4+
import { Sticky, CreateSticky, UpdateSticky, ListStickiesParams } from "../models/Sticky";
5+
6+
/**
7+
* Sticky API resource
8+
* Handles all sticky related operations
9+
*/
10+
export class Stickies extends BaseResource {
11+
constructor(config: Configuration) {
12+
super(config);
13+
}
14+
15+
/**
16+
* Create a new sticky
17+
*/
18+
async create(workspaceSlug: string, createSticky: CreateSticky): Promise<Sticky> {
19+
return this.post<Sticky>(`/workspaces/${workspaceSlug}/stickies/`, createSticky);
20+
}
21+
22+
/**
23+
* Retrieve a sticky by ID
24+
*/
25+
async retrieve(workspaceSlug: string, stickyId: string): Promise<Sticky> {
26+
return this.get<Sticky>(`/workspaces/${workspaceSlug}/stickies/${stickyId}/`);
27+
}
28+
29+
/**
30+
* Update a sticky
31+
*/
32+
async update(workspaceSlug: string, stickyId: string, updateSticky: UpdateSticky): Promise<Sticky> {
33+
return this.patch<Sticky>(`/workspaces/${workspaceSlug}/stickies/${stickyId}/`, updateSticky);
34+
}
35+
36+
/**
37+
* Delete a sticky
38+
*/
39+
async delete(workspaceSlug: string, stickyId: string): Promise<void> {
40+
return this.httpDelete(`/workspaces/${workspaceSlug}/stickies/${stickyId}/`);
41+
}
42+
43+
/**
44+
* List stickies with optional filtering
45+
*/
46+
async list(workspaceSlug: string, params?: ListStickiesParams): Promise<PaginatedResponse<Sticky>> {
47+
return this.get<PaginatedResponse<Sticky>>(`/workspaces/${workspaceSlug}/stickies/`, params);
48+
}
49+
}

0 commit comments

Comments
 (0)