@zzp123/mcp-zentao 1.8.9 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/api/zentaoApi.js +36 -21
- package/dist/types/zentao.d.ts +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.9.0] - 2025-11-06
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **修复 getMyBugs 工具过滤逻辑问题** 🔧
|
|
12
|
+
- 禅道API的 `/bugs` 接口不支持 `assignedTo` 参数进行服务端过滤
|
|
13
|
+
- 改为使用客户端过滤:获取更多数据后在本地筛选分配给当前用户的Bug
|
|
14
|
+
- 修复了使用 `onlyAssignedToMe=true` 时无法正确获取当前用户Bug的问题
|
|
15
|
+
- 现在能够正确识别 `assignedTo` 字段(支持对象和字符串两种格式)
|
|
16
|
+
|
|
17
|
+
### Improved
|
|
18
|
+
- 优化了 `getMyBugs` 的性能:当需要过滤时自动获取100条数据以确保有足够的结果
|
|
19
|
+
- 增加了详细的过滤日志输出,便于调试和追踪
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- 扩展了 `Bug` 类型定义,添加了 `assignedTo`、`openedBy`、`resolvedBy` 等字段
|
|
23
|
+
- 更新了文档,说明了禅道API的限制和客户端过滤的实现方式
|
|
24
|
+
|
|
8
25
|
## [1.8.9] - 2025-11-06
|
|
9
26
|
|
|
10
27
|
### Fixed
|
package/dist/api/zentaoApi.js
CHANGED
|
@@ -125,38 +125,53 @@ export class ZentaoAPI {
|
|
|
125
125
|
// 默认每页20条,最多100条
|
|
126
126
|
const finalLimit = limit ? Math.min(limit, 100) : 20;
|
|
127
127
|
const finalPage = page || 1;
|
|
128
|
+
// 禅道API的/bugs接口不支持assignedTo参数过滤,需要客户端过滤
|
|
129
|
+
// 所以获取更多数据以确保有足够的结果
|
|
130
|
+
const fetchLimit = onlyAssignedToMe ? 100 : finalLimit;
|
|
128
131
|
const params = {
|
|
129
132
|
status: status || 'all',
|
|
130
133
|
product: productId,
|
|
131
|
-
page:
|
|
132
|
-
limit:
|
|
134
|
+
page: 1,
|
|
135
|
+
limit: fetchLimit
|
|
133
136
|
};
|
|
134
|
-
// 只有当明确指定时才过滤 assignedTo
|
|
135
|
-
if (onlyAssignedToMe) {
|
|
136
|
-
params.assignedTo = this.config.username;
|
|
137
|
-
}
|
|
138
137
|
try {
|
|
139
|
-
console.log(`正在获取Bug
|
|
138
|
+
console.log(`正在获取Bug列表,参数:`, params);
|
|
140
139
|
const response = await this.request('GET', '/bugs', params);
|
|
141
140
|
console.log(`Bug列表响应: 获取到 ${response.bugs?.length || 0} 条数据`);
|
|
141
|
+
let bugs = [];
|
|
142
142
|
if (Array.isArray(response)) {
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
page: finalPage,
|
|
146
|
-
total: response.length,
|
|
147
|
-
limit: finalLimit,
|
|
148
|
-
bugs: response
|
|
149
|
-
};
|
|
143
|
+
bugs = response;
|
|
150
144
|
}
|
|
151
145
|
else if (response && typeof response === 'object' && Array.isArray(response.bugs)) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
bugs = response.bugs;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new Error(`获取Bug列表失败: 响应格式不正确 ${JSON.stringify(response)}`);
|
|
150
|
+
}
|
|
151
|
+
// 如果需要过滤分配给当前用户的bug,在客户端进行过滤
|
|
152
|
+
if (onlyAssignedToMe) {
|
|
153
|
+
console.log(`客户端过滤:只保留分配给 ${this.config.username} 的Bug`);
|
|
154
|
+
bugs = bugs.filter(bug => {
|
|
155
|
+
// assignedTo可能是对象或字符串
|
|
156
|
+
if (typeof bug.assignedTo === 'object' && bug.assignedTo !== null) {
|
|
157
|
+
return bug.assignedTo.account === this.config.username;
|
|
158
|
+
}
|
|
159
|
+
else if (typeof bug.assignedTo === 'string') {
|
|
160
|
+
return bug.assignedTo === this.config.username;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
});
|
|
164
|
+
console.log(`过滤后剩余 ${bugs.length} 个Bug`);
|
|
158
165
|
}
|
|
159
|
-
|
|
166
|
+
// 应用分页
|
|
167
|
+
const start = (finalPage - 1) * finalLimit;
|
|
168
|
+
const paginatedBugs = bugs.slice(start, start + finalLimit);
|
|
169
|
+
return {
|
|
170
|
+
page: finalPage,
|
|
171
|
+
total: bugs.length,
|
|
172
|
+
limit: finalLimit,
|
|
173
|
+
bugs: paginatedBugs
|
|
174
|
+
};
|
|
160
175
|
}
|
|
161
176
|
catch (error) {
|
|
162
177
|
if (error instanceof Error && error.message.includes('Need product id')) {
|
package/dist/types/zentao.d.ts
CHANGED
|
@@ -40,6 +40,13 @@ export interface Bug {
|
|
|
40
40
|
days_open?: number;
|
|
41
41
|
aging_status?: string;
|
|
42
42
|
aging_description?: string;
|
|
43
|
+
assignedTo?: any;
|
|
44
|
+
openedBy?: any;
|
|
45
|
+
resolvedBy?: any;
|
|
46
|
+
product?: number;
|
|
47
|
+
module?: number;
|
|
48
|
+
pri?: number;
|
|
49
|
+
type?: string;
|
|
43
50
|
}
|
|
44
51
|
export interface TaskUpdate {
|
|
45
52
|
consumed?: number;
|