Skip to content

Commit 29b5b10

Browse files
[SILO-723] feat: add support to set options in create option property api (#21)
* feat: add support to set options in create option property api * fix: tests with new project features update api
1 parent 08368f4 commit 29b5b10

File tree

6 files changed

+298
-109
lines changed

6 files changed

+298
-109
lines changed

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.2",
3+
"version": "0.2.3",
44
"description": "Node SDK for Plane",
55
"author": "Plane <[email protected]>",
66
"repository": {

src/api/WorkItemProperties/Values.ts

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { BaseResource } from '../BaseResource';
2-
import { Configuration } from '../../Configuration';
1+
import { BaseResource } from "../BaseResource";
2+
import { Configuration } from "../../Configuration";
33
import {
44
UpdateWorkItemPropertyValue,
55
ListWorkItemPropertyValuesParams,
66
WorkItemPropertyValues,
7-
} from '../../models/WorkItemProperty';
7+
} from "../../models/WorkItemProperty";
88

99
/**
1010
* WorkItemPropertyValues API resource
@@ -22,7 +22,7 @@ export class Values extends BaseResource {
2222
workspaceSlug: string,
2323
projectId: string,
2424
workItemId: string,
25-
propertyId: string,
25+
propertyId: string
2626
): Promise<WorkItemPropertyValues> {
2727
const propertyValues = await this.get<WorkItemPropertyValues>(
2828
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/${propertyId}/values/`
@@ -45,9 +45,16 @@ export class Values extends BaseResource {
4545
);
4646
}
4747

48-
4948
/**
5049
* Create/update a property value
50+
*
51+
* For single-value properties:
52+
* - Acts as an upsert operation (create or update)
53+
* - Returns a single WorkItemPropertyValues
54+
*
55+
* For multi-value properties (is_multi=True):
56+
* - Replaces all existing values with the new ones (sync operation)
57+
* - Returns a list of values
5158
*/
5259
async create(
5360
workspaceSlug: string,
@@ -61,4 +68,47 @@ export class Values extends BaseResource {
6168
updateData
6269
);
6370
}
71+
72+
/**
73+
* Update an existing property value(s) (partial update)
74+
*
75+
* For single-value properties:
76+
* - Updates the existing value
77+
* - Returns a single WorkItemPropertyValues
78+
*
79+
* For multi-value properties (is_multi=True):
80+
* - Replaces all existing values with the new ones (sync operation)
81+
* - Returns a list of values
82+
*
83+
* @throws {HttpError} If the property value does not exist (404)
84+
*/
85+
async update(
86+
workspaceSlug: string,
87+
projectId: string,
88+
workItemId: string,
89+
propertyId: string,
90+
updateData: UpdateWorkItemPropertyValue
91+
): Promise<WorkItemPropertyValues> {
92+
return this.patch<WorkItemPropertyValues>(
93+
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/${propertyId}/values/`,
94+
updateData
95+
);
96+
}
97+
98+
/**
99+
* Delete the property value(s) for a work item
100+
*
101+
* For single-value properties:
102+
* - Deletes the single value
103+
*
104+
* For multi-value properties (is_multi=True):
105+
* - Deletes all values for that property
106+
*
107+
* @throws {HttpError} If the property value does not exist (404)
108+
*/
109+
async delete(workspaceSlug: string, projectId: string, workItemId: string, propertyId: string): Promise<void> {
110+
return this.httpDelete(
111+
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/${propertyId}/values/`
112+
);
113+
}
64114
}

src/models/WorkItemProperty.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export type TextSettings = {
102102
*/
103103
export interface WorkItemPropertyOption extends BaseModel {
104104
name: string;
105+
description?: string;
105106
property: string;
106107
is_active?: boolean;
107108
sort_order?: number;
@@ -137,8 +138,30 @@ export type WorkItemPropertyValues = {
137138
values: any[];
138139
}[];
139140

141+
/**
142+
* UpdateWorkItemPropertyValue model interface
143+
* Request model for creating/updating a work item property value.
144+
*
145+
* The value type depends on the property type:
146+
* - TEXT/URL/EMAIL/FILE: string
147+
* - DATETIME: string (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS)
148+
* - DECIMAL: number (int or float)
149+
* - BOOLEAN: boolean (true/false)
150+
* - OPTION/RELATION (single): string (UUID)
151+
* - OPTION/RELATION (multi, when is_multi=True): list of strings (UUIDs) or single string
152+
*
153+
* For multi-value properties (is_multi=True):
154+
* - Accept either a single UUID string or a list of UUID strings
155+
* - Multiple IssuePropertyValue records are created
156+
* - Response will be a list of values
157+
*
158+
* For single-value properties:
159+
* - Only one value is allowed per work item/property combination
160+
*/
140161
export type UpdateWorkItemPropertyValue = {
141-
values: [{ value: any }];
162+
value: string | boolean | number | string[];
163+
external_id?: string;
164+
external_source?: string;
142165
};
143166

144167
export interface ListWorkItemPropertyValuesParams {

tests/e2e/project.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ describe("End to End Project Test", () => {
2727
name: projectName,
2828
id: projectName.slice(0, 5).toUpperCase(),
2929
});
30+
31+
await client.projects.updateFeatures(e2eConfig.workspaceSlug, project.id, {
32+
cycles: true,
33+
modules: true,
34+
});
3035
});
3136

3237
it("should create and list cycles", async () => {

0 commit comments

Comments
 (0)