@zzp123/mcp-zentao 1.4.3 → 1.6.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 CHANGED
@@ -5,6 +5,52 @@ 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.6.0] - 2025-11-05
9
+
10
+ ### Changed - 重大更新
11
+ - **迁移到自定义模块接口** `/custom/modules` - 替代原生 `/modules` 接口
12
+ - 接口路径:`GET /custom/modules`(原 `/modules`)
13
+ - 支持字段过滤功能:通过 `fields` 参数指定返回字段
14
+ - 默认返回精简字段:id、name、parent、grade、type
15
+ - 可选字段:id、root、branch、name、parent、path、grade、order、type、owner、collector、short
16
+
17
+ ### Added
18
+ - 新增 `fields` 参数支持,可大幅减少返回数据量(60-80%)
19
+ - 新增 `ModulesResponse` 接口:`{ modules: SimpleModule[], total: number }`
20
+ - 更新 `SimpleModule` 接口,支持更多可选字段
21
+
22
+ ### Technical
23
+ - 返回数据结构变化:从嵌套树形结构改为扁平化数组
24
+ - 通过 `parent` 字段关联父子关系,通过 `path` 字段表示层级路径
25
+ - 移除 `simplifyModule()` 递归处理方法(不再需要)
26
+ - 接口响应包含 `total` 字段,返回模块总数
27
+
28
+ ### Benefits
29
+ - **性能提升**:支持按需获取字段,减少60-80%数据传输量
30
+ - **更灵活**:可根据实际需求指定返回字段
31
+ - **更标准**:返回格式包含 total 统计信息
32
+
33
+ ### Breaking Changes
34
+ - `getModules()` 返回类型从 `SimpleModule[]` 改为 `ModulesResponse`
35
+ - `SimpleModule` 不再包含 `children` 字段(数据已扁平化)
36
+
37
+ ## [1.5.0] - 2025-11-05
38
+
39
+ ### Added
40
+ - **模块数据简化功能** - 新增 `SimpleModule` 接口,简化模块API返回数据
41
+ - `getModules` 接口现在只返回核心字段:id、name、parent、grade、children
42
+ - 移除冗余的字段(type、path、order等),大幅减少数据传输量
43
+ - 保持树形结构,递归简化所有子模块数据
44
+
45
+ ### Changed
46
+ - 优化 `getModules()` 方法,返回类型从 `Module[]` 改为 `SimpleModule[]`
47
+ - 添加 `simplifyModule()` 私有方法,用于递归转换模块数据结构
48
+
49
+ ### Benefits
50
+ - 减少网络传输数据量,提升API响应速度
51
+ - 简化客户端数据处理逻辑
52
+ - 更清晰的数据结构,只包含必要信息
53
+
8
54
  ## [1.4.3] - 2025-11-05
9
55
 
10
56
  ### Fixed
package/README.md CHANGED
@@ -15,10 +15,11 @@ npm install @zzp123/mcp-zentao -g
15
15
 
16
16
  查看完整的版本更新历史,请访问 [CHANGELOG.md](./CHANGELOG.md)
17
17
 
18
- **最新版本**: v1.4.3
19
- - CHANGELOG.md 添加到 npm 包中,用户可直接查看版本历史
20
- - 完整的文档更新和示例代码修正
21
- - 修正包名和API签名
18
+ **最新版本**: v1.6.0
19
+ - 迁移到自定义模块接口 /custom/modules,支持字段过滤
20
+ - 新增 fields 参数,可减少60-80%数据传输量
21
+ - 返回数据扁平化,包含 total 统计信息
22
+ - ⚠️ Breaking Change: getModules 返回类型变更
22
23
 
23
24
  **主要版本**:
24
25
  - v1.4.1 - 修复 uploadImageFromClipboard 返回值问题
@@ -1,4 +1,4 @@
1
- import { AssignFeedbackRequest, Bug, BugStatus, Build, CloseFeedbackRequest, CreateBuildRequest, CreateBugRequest, CreateExecutionRequest, CreateFeedbackRequest, CreatePlanRequest, CreateProductRequest, CreateProgramRequest, CreateProjectRequest, CreateStoryRequest, CreateTaskRequest, CreateTestCaseRequest, CreateTicketRequest, CreateUserRequest, Execution, Feedback, FileUploadResponse, Module, ModuleType, Plan, Product, Program, Project, Release, ResolveBugRequest, Story, Task, TaskStatus, TaskUpdate, TestCase, Ticket, UpdateBuildRequest, UpdateBugRequest, UpdateExecutionRequest, UpdateFeedbackRequest, UpdatePlanRequest, UpdateProductRequest, UpdateProgramRequest, UpdateProjectRequest, UpdateStoryRequest, UpdateTestCaseRequest, UpdateTicketRequest, UpdateUserRequest, UploadFileRequest, UserDetail, ZentaoConfig } from '../types/zentao';
1
+ import { AssignFeedbackRequest, Bug, BugStatus, Build, CloseFeedbackRequest, CreateBuildRequest, CreateBugRequest, CreateExecutionRequest, CreateFeedbackRequest, CreatePlanRequest, CreateProductRequest, CreateProgramRequest, CreateProjectRequest, CreateStoryRequest, CreateTaskRequest, CreateTestCaseRequest, CreateTicketRequest, CreateUserRequest, Execution, Feedback, FileUploadResponse, ModulesResponse, ModuleType, Plan, Product, Program, Project, Release, ResolveBugRequest, Story, Task, TaskStatus, TaskUpdate, TestCase, Ticket, UpdateBuildRequest, UpdateBugRequest, UpdateExecutionRequest, UpdateFeedbackRequest, UpdatePlanRequest, UpdateProductRequest, UpdateProgramRequest, UpdateProjectRequest, UpdateStoryRequest, UpdateTestCaseRequest, UpdateTicketRequest, UpdateUserRequest, UploadFileRequest, UserDetail, ZentaoConfig } from '../types/zentao';
2
2
  export declare class ZentaoAPI {
3
3
  private config;
4
4
  private client;
@@ -148,7 +148,14 @@ export declare class ZentaoAPI {
148
148
  deleteTicket(ticketId: number): Promise<{
149
149
  message: string;
150
150
  }>;
151
- getModules(type: ModuleType, id: number): Promise<Module[]>;
151
+ /**
152
+ * 获取模块列表(使用自定义接口,支持字段过滤)
153
+ * @param type 模块类型:story(需求)、bug、case(用例)、task(任务)、feedback(反馈)、product
154
+ * @param id 对象ID:产品ID或项目ID
155
+ * @param fields 可选,指定返回的字段,多个字段用逗号分隔。默认返回:id,name,parent,grade,type
156
+ * @returns Promise<ModulesResponse> 包含模块列表和总数
157
+ */
158
+ getModules(type: ModuleType, id: number, fields?: string): Promise<ModulesResponse>;
152
159
  uploadFile(uploadRequest: UploadFileRequest): Promise<FileUploadResponse>;
153
160
  downloadFile(fileId: number): Promise<Buffer>;
154
161
  }
@@ -1119,13 +1119,24 @@ export class ZentaoAPI {
1119
1119
  }
1120
1120
  }
1121
1121
  // 模块相关API
1122
- async getModules(type, id) {
1123
- try {
1124
- console.log(`正在获取模块列表,类型: ${type}, ID: ${id}...`);
1122
+ /**
1123
+ * 获取模块列表(使用自定义接口,支持字段过滤)
1124
+ * @param type 模块类型:story(需求)、bug、case(用例)、task(任务)、feedback(反馈)、product
1125
+ * @param id 对象ID:产品ID或项目ID
1126
+ * @param fields 可选,指定返回的字段,多个字段用逗号分隔。默认返回:id,name,parent,grade,type
1127
+ * @returns Promise<ModulesResponse> 包含模块列表和总数
1128
+ */
1129
+ async getModules(type, id, fields) {
1130
+ try {
1131
+ console.log(`正在获取模块列表,类型: ${type}, ID: ${id}, 字段: ${fields || '默认'}...`);
1125
1132
  const params = { type, id };
1126
- const response = await this.request('GET', '/modules', params);
1127
- console.log('获取模块列表响应:', response);
1128
- return response.modules;
1133
+ if (fields) {
1134
+ params.fields = fields;
1135
+ }
1136
+ // 使用新的自定义接口路径
1137
+ const response = await this.request('GET', '/custom/modules', params);
1138
+ console.log(`获取模块列表成功,共 ${response.total} 个模块`);
1139
+ return response;
1129
1140
  }
1130
1141
  catch (error) {
1131
1142
  console.error('获取模块列表失败:', error);
package/dist/index.js CHANGED
@@ -926,15 +926,16 @@ server.tool("deleteTicket", { ticketId: z.number() }, async ({ ticketId }) => {
926
926
  throw new Error("Please initialize Zentao API first");
927
927
  return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteTicket(ticketId), null, 2) }] };
928
928
  });
929
- // 模块相关工具
929
+ // 模块相关工具(使用自定义接口,支持字段过滤)
930
930
  server.tool("getModules", {
931
931
  type: z.enum(['story', 'task', 'bug', 'case', 'feedback', 'product']),
932
- id: z.number()
933
- }, async ({ type, id }) => {
932
+ id: z.number(),
933
+ fields: z.string().optional()
934
+ }, async ({ type, id, fields }) => {
934
935
  if (!zentaoApi)
935
936
  throw new Error("Please initialize Zentao API first");
936
- const modules = await zentaoApi.getModules(type, id);
937
- return { content: [{ type: "text", text: JSON.stringify(modules, null, 2) }] };
937
+ const response = await zentaoApi.getModules(type, id, fields);
938
+ return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
938
939
  });
939
940
  // 文件相关工具
940
941
  server.tool("uploadFile", {
@@ -626,8 +626,30 @@ export interface Module {
626
626
  owner: string;
627
627
  collector?: string;
628
628
  short?: string;
629
+ deleted?: string;
630
+ from?: number;
631
+ url?: string;
632
+ children?: Module[];
629
633
  }
630
634
  export type ModuleType = 'story' | 'task' | 'bug' | 'case' | 'feedback' | 'product';
635
+ export interface SimpleModule {
636
+ id: string;
637
+ name: string;
638
+ parent: string;
639
+ grade: string;
640
+ type?: string;
641
+ path?: string;
642
+ root?: string;
643
+ branch?: string;
644
+ order?: string;
645
+ owner?: string;
646
+ collector?: string;
647
+ short?: string;
648
+ }
649
+ export interface ModulesResponse {
650
+ modules: SimpleModule[];
651
+ total: number;
652
+ }
631
653
  export interface FileUploadResponse {
632
654
  id: number;
633
655
  url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzp123/mcp-zentao",
3
- "version": "1.4.3",
3
+ "version": "1.6.0",
4
4
  "description": "禅道项目管理系统的高级API集成包,提供任务管理、Bug跟踪等功能的完整封装,专为Cursor IDE设计的MCP扩展",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",