-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.ts
More file actions
151 lines (137 loc) · 4.38 KB
/
index.ts
File metadata and controls
151 lines (137 loc) · 4.38 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
import { BaseResource } from "../BaseResource";
import { Configuration } from "../../Configuration";
import {
WorkItem,
CreateWorkItem,
UpdateWorkItem,
ListWorkItemsParams,
WorkItemExpandableFieldName,
WorkItemBase,
WorkItemSearch,
AdvancedSearchWorkItem,
AdvancedSearchResult,
} from "../../models/WorkItem";
import { PaginatedResponse } from "../../models/common";
import { Links } from "../Links";
import { Relations } from "./Relations";
import { Attachments } from "./Attachments";
import { Comments } from "./Comments";
import { Activities } from "./Activities";
import { WorkLogs } from "./WorkLogs";
/**
* WorkItems API resource
* Handles all work item (issue) related operations
*/
export class WorkItems extends BaseResource {
public links: Links;
public relations: Relations;
public attachments: Attachments;
public comments: Comments;
public activities: Activities;
public workLogs: WorkLogs;
constructor(config: Configuration) {
super(config);
this.links = new Links(config);
this.relations = new Relations(config);
this.attachments = new Attachments(config);
this.comments = new Comments(config);
this.activities = new Activities(config);
this.workLogs = new WorkLogs(config);
}
/**
* Create a new work item
*/
async create(workspaceSlug: string, projectId: string, createWorkItem: CreateWorkItem): Promise<WorkItem> {
return this.post<WorkItem>(`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/`, createWorkItem);
}
// method overloads
async retrieve(workspaceSlug: string, projectId: string, workItemId: string): Promise<WorkItemBase>;
async retrieve<E extends WorkItemExpandableFieldName>(
workspaceSlug: string,
projectId: string,
workItemId: string,
expand: E[]
): Promise<WorkItem<E>>;
/**
* Retrieve a work item by ID
*/
async retrieve<E extends WorkItemExpandableFieldName>(
workspaceSlug: string,
projectId: string,
workItemId: string,
expand?: E[]
): Promise<WorkItem<E>> {
return this.get<WorkItem<E>>(`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/`, {
expand: expand?.join(","),
});
}
/**
* Update a work item
*/
async update(
workspaceSlug: string,
projectId: string,
workItemId: string,
updateWorkItem: UpdateWorkItem
): Promise<WorkItem> {
return this.patch<WorkItem>(
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/`,
updateWorkItem
);
}
/**
* Delete a work item
*/
async delete(workspaceSlug: string, projectId: string, workItemId: string): Promise<void> {
return this.httpDelete(`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/`);
}
/**
* List work items with optional filtering
*/
async list(
workspaceSlug: string,
projectId: string,
params?: ListWorkItemsParams
): Promise<PaginatedResponse<WorkItem>> {
return this.get<PaginatedResponse<WorkItem>>(
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/`,
params
);
}
// method overloads
async retrieveByIdentifier(workspaceSlug: string, identifier: string): Promise<WorkItemBase>;
async retrieveByIdentifier<E extends WorkItemExpandableFieldName>(
workspaceSlug: string,
identifier: string,
expand: E[]
): Promise<WorkItem<E>>;
// Implementation
async retrieveByIdentifier<E extends WorkItemExpandableFieldName>(
workspaceSlug: string,
identifier: string,
expand?: E[]
): Promise<WorkItem<E> | WorkItemBase> {
return this.get<WorkItem<E>>(`/workspaces/${workspaceSlug}/work-items/${identifier}/`, {
expand: expand?.join(","),
});
}
/**
* Search work items
*/
async search(workspaceSlug: string, query: string, projectId?: string, params?: any): Promise<WorkItemSearch> {
return this.get<WorkItemSearch>(`/workspaces/${workspaceSlug}/work-items/search/`, {
...params,
search: query,
project: projectId,
});
}
/**
* Perform advanced search on work items with filters.
*
* Supports text-based search via `query` and/or structured filters
* using recursive AND/OR groups.
*/
async advancedSearch(workspaceSlug: string, data: AdvancedSearchWorkItem): Promise<AdvancedSearchResult[]> {
return this.post<AdvancedSearchResult[]>(`/workspaces/${workspaceSlug}/work-items/advanced-search/`, data);
}
}