@dyno181cm.nexsoft/zentao_mcp 1.2.1 → 1.2.2
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/README.md +1 -1
- package/build/index.js +1 -1
- package/build/zentaoClient.js +32 -6
- package/package.json +10 -1
package/README.md
CHANGED
package/build/index.js
CHANGED
package/build/zentaoClient.js
CHANGED
|
@@ -13,12 +13,38 @@ export class ZentaoClient {
|
|
|
13
13
|
account = process.env.ZENTAO_ACCOUNT || '';
|
|
14
14
|
password = process.env.ZENTAO_PASSWORD || '';
|
|
15
15
|
baseUrl = process.env.ZENTAO_BASE_URL || '';
|
|
16
|
+
getCache = new Map();
|
|
17
|
+
cacheTtlMs = 2 * 60 * 1000; // 2 minutes TTL
|
|
18
|
+
/**
|
|
19
|
+
* Clears the in-memory cache for GET requests. Helpful for testing.
|
|
20
|
+
*/
|
|
21
|
+
clearCache() {
|
|
22
|
+
this.getCache.clear();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Helper method to perform GET requests with caching.
|
|
26
|
+
*
|
|
27
|
+
* @param url The API endpoint path.
|
|
28
|
+
* @returns The response data.
|
|
29
|
+
*/
|
|
30
|
+
async get(url) {
|
|
31
|
+
const cached = this.getCache.get(url);
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
if (cached && (now - cached.timestamp < this.cacheTtlMs)) {
|
|
34
|
+
return cached.data;
|
|
35
|
+
}
|
|
36
|
+
const res = await this.client.get(url);
|
|
37
|
+
this.getCache.set(url, { data: res.data, timestamp: now });
|
|
38
|
+
return res.data;
|
|
39
|
+
}
|
|
16
40
|
/**
|
|
17
41
|
* Initializes the Axios client with base configurations and registers interceptors
|
|
18
42
|
* to automatically inject token headers and handle token expiration (401 errors).
|
|
43
|
+
*
|
|
44
|
+
* @param customClient Optional custom AxiosInstance for dependency injection/testing.
|
|
19
45
|
*/
|
|
20
|
-
constructor() {
|
|
21
|
-
this.client = axios.create({
|
|
46
|
+
constructor(customClient) {
|
|
47
|
+
this.client = customClient || axios.create({
|
|
22
48
|
baseURL: this.baseUrl,
|
|
23
49
|
headers: {
|
|
24
50
|
'Content-Type': 'application/json',
|
|
@@ -80,23 +106,23 @@ export class ZentaoClient {
|
|
|
80
106
|
}
|
|
81
107
|
/**
|
|
82
108
|
* Retrieves details of a specific task.
|
|
109
|
+
* Checks the cache first, otherwise fetches from API.
|
|
83
110
|
*
|
|
84
111
|
* @param taskId The ID of the task.
|
|
85
112
|
* @returns Resolves with the task details.
|
|
86
113
|
*/
|
|
87
114
|
async getTaskDetails(taskId) {
|
|
88
|
-
|
|
89
|
-
return res.data;
|
|
115
|
+
return this.get(`/tasks/${taskId}`);
|
|
90
116
|
}
|
|
91
117
|
/**
|
|
92
118
|
* Retrieves details of a specific bug.
|
|
119
|
+
* Checks the cache first, otherwise fetches from API.
|
|
93
120
|
*
|
|
94
121
|
* @param bugId The ID of the bug.
|
|
95
122
|
* @returns Resolves with the bug details.
|
|
96
123
|
*/
|
|
97
124
|
async getBugDetails(bugId) {
|
|
98
|
-
|
|
99
|
-
return res.data;
|
|
125
|
+
return this.get(`/bugs/${bugId}`);
|
|
100
126
|
}
|
|
101
127
|
/**
|
|
102
128
|
* Downloads a file from Zentao API and pipes it to a local file path.
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyno181cm.nexsoft/zentao_mcp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Zentao MCP Server",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/dyno-nexsoft/zentao_mcp.git"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/dyno-nexsoft/zentao_mcp/issues"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/dyno-nexsoft/zentao_mcp#readme",
|
|
5
13
|
"main": "build/index.js",
|
|
6
14
|
"bin": {
|
|
7
15
|
"zentao_mcp": "build/index.js"
|
|
@@ -14,6 +22,7 @@
|
|
|
14
22
|
"build": "tsc",
|
|
15
23
|
"start": "node build/index.js",
|
|
16
24
|
"dev": "tsc --watch",
|
|
25
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
17
26
|
"test:api": "tsx tests/testApi.ts"
|
|
18
27
|
},
|
|
19
28
|
"dependencies": {
|