-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathWorkItemProperty.ts
More file actions
172 lines (150 loc) · 4.56 KB
/
WorkItemProperty.ts
File metadata and controls
172 lines (150 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import { BaseModel, LogoProps, PropertyRelationType, PropertyType } from "./common";
export type WorkItemPropertySettings = TextSettings | undefined;
/**
* WorkItemProperty model interfaces
*/
export interface WorkItemProperty extends BaseModel {
name: string;
property_type: PropertyType;
display_name: string;
description?: string;
relation_type: PropertyRelationType | undefined;
options?: Partial<WorkItemPropertyOption>[];
settings?: WorkItemPropertySettings;
logo_props: LogoProps;
sort_order: number;
is_required: boolean;
default_value: any;
is_active: boolean;
is_multi: boolean;
validation_rules: any;
issue_type: string;
workspace: string;
project: string;
}
/**
* CreateWorkItemProperty model interface
* This is the model used to create a new work item property to add validations according to the property type
* as defined above.
*/
// Base interface for creating work item properties (excluding auto-generated fields)
interface BaseCreateWorkItemProperty {
name: string;
display_name: string;
description?: string;
property_type: PropertyType;
settings?: WorkItemPropertySettings;
logo_props?: LogoProps;
sort_order?: number;
is_required: boolean;
default_value?: any;
is_active?: boolean;
relation_type?: PropertyRelationType;
options?: Partial<WorkItemPropertyOption>[];
is_multi?: boolean;
}
// Specific interfaces for each property type with their required fields
interface CreateTextWorkItemProperty extends BaseCreateWorkItemProperty {
property_type: "TEXT";
settings?: TextSettings;
}
interface CreateDecimalWorkItemProperty extends BaseCreateWorkItemProperty {
property_type: "DECIMAL";
}
interface CreateOptionWorkItemProperty extends BaseCreateWorkItemProperty {
property_type: "OPTION";
options?: Partial<WorkItemPropertyOption>[];
is_multi?: boolean;
}
interface CreateBooleanWorkItemProperty extends BaseCreateWorkItemProperty {
property_type: "BOOLEAN";
}
interface CreateDateTimeWorkItemProperty extends BaseCreateWorkItemProperty {
property_type: "DATETIME";
}
interface CreateRelationWorkItemProperty extends BaseCreateWorkItemProperty {
property_type: "RELATION";
relation_type?: PropertyRelationType;
}
export type CreateWorkItemProperty =
| CreateTextWorkItemProperty
| CreateDecimalWorkItemProperty
| CreateOptionWorkItemProperty
| CreateBooleanWorkItemProperty
| CreateDateTimeWorkItemProperty
| CreateRelationWorkItemProperty;
export type UpdateWorkItemProperty = Partial<WorkItemProperty>;
export interface ListWorkItemPropertiesParams {
project?: string;
limit?: number;
offset?: number;
}
export type TextSettings = {
display_format: "single-line" | "multi-line" | "readonly";
};
/**
* WorkItemPropertyOption model interfaces
*/
export interface WorkItemPropertyOption extends BaseModel {
name: string;
description?: string;
property: string;
is_active?: boolean;
sort_order?: number;
parent?: string;
project?: string;
is_default?: boolean;
logo_props?: LogoProps;
}
export type CreateWorkItemPropertyOption = Partial<WorkItemPropertyOption>;
export type UpdateWorkItemPropertyOption = Partial<WorkItemPropertyOption>;
export interface ListWorkItemPropertyOptionsParams {
property?: string;
limit?: number;
offset?: number;
}
/**
* WorkItemPropertyValue model interfaces
*/
export interface WorkItemPropertyValue extends BaseModel {
value: any;
property: string;
issue: string;
workspace: string;
project: string;
}
export type WorkItemPropertyValues = {
property_id: string;
values: any[];
}[];
/**
* UpdateWorkItemPropertyValue model interface
* Request model for creating/updating a work item property value.
*
* The value type depends on the property type:
* - TEXT/URL/EMAIL/FILE: string
* - DATETIME: string (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS)
* - DECIMAL: number (int or float)
* - BOOLEAN: boolean (true/false)
* - OPTION/RELATION (single): string (UUID)
* - OPTION/RELATION (multi, when is_multi=True): list of strings (UUIDs) or single string
*
* For multi-value properties (is_multi=True):
* - Accept either a single UUID string or a list of UUID strings
* - Multiple IssuePropertyValue records are created
* - Response will be a list of values
*
* For single-value properties:
* - Only one value is allowed per work item/property combination
*/
export type UpdateWorkItemPropertyValue = {
value: string | boolean | number | string[];
external_id?: string;
external_source?: string;
};
export interface ListWorkItemPropertyValuesParams {
issue?: string;
property?: string;
limit?: number;
offset?: number;
}