@leeguoo/zentao-mcp 0.3.0 → 0.3.1
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/package.json +1 -1
- package/src/index.js +35 -14
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -50,10 +50,35 @@ function normalizeError(message, payload) {
|
|
|
50
50
|
return { status: 0, msg: message || "error", result: payload ?? [] };
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function
|
|
53
|
+
function normalizeAccountValue(value) {
|
|
54
54
|
return String(value || "").trim().toLowerCase();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
function extractAccounts(value) {
|
|
58
|
+
if (value === undefined || value === null) return [];
|
|
59
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
60
|
+
const normalized = normalizeAccountValue(value);
|
|
61
|
+
return normalized ? [normalized] : [];
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
return value.flatMap((item) => extractAccounts(item));
|
|
65
|
+
}
|
|
66
|
+
if (typeof value === "object") {
|
|
67
|
+
const candidates = [];
|
|
68
|
+
if (value.account) candidates.push(...extractAccounts(value.account));
|
|
69
|
+
if (value.realname) candidates.push(...extractAccounts(value.realname));
|
|
70
|
+
if (value.name) candidates.push(...extractAccounts(value.name));
|
|
71
|
+
if (value.user) candidates.push(...extractAccounts(value.user));
|
|
72
|
+
return candidates.filter(Boolean);
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function matchesAccount(value, matchAccount) {
|
|
78
|
+
const candidates = extractAccounts(value);
|
|
79
|
+
return candidates.includes(matchAccount);
|
|
80
|
+
}
|
|
81
|
+
|
|
57
82
|
class ZentaoClient {
|
|
58
83
|
constructor({ baseUrl, account, password }) {
|
|
59
84
|
this.baseUrl = normalizeBaseUrl(baseUrl);
|
|
@@ -240,7 +265,7 @@ class ZentaoClient {
|
|
|
240
265
|
maxItems,
|
|
241
266
|
includeDetails,
|
|
242
267
|
}) {
|
|
243
|
-
const matchAccount =
|
|
268
|
+
const matchAccount = normalizeAccountValue(account || this.account);
|
|
244
269
|
const targetScope = (scope || "assigned").toLowerCase();
|
|
245
270
|
|
|
246
271
|
const productsResponse = await this.listProducts({ page: 1, limit: 1000 });
|
|
@@ -264,17 +289,13 @@ class ZentaoClient {
|
|
|
264
289
|
});
|
|
265
290
|
|
|
266
291
|
const matches = productBugs.filter((bug) => {
|
|
267
|
-
const assigned =
|
|
268
|
-
const opened =
|
|
269
|
-
const resolved =
|
|
270
|
-
if (targetScope === "assigned") return assigned
|
|
271
|
-
if (targetScope === "opened") return opened
|
|
272
|
-
if (targetScope === "resolved") return resolved
|
|
273
|
-
return
|
|
274
|
-
assigned === matchAccount ||
|
|
275
|
-
opened === matchAccount ||
|
|
276
|
-
resolved === matchAccount
|
|
277
|
-
);
|
|
292
|
+
const assigned = matchesAccount(bug.assignedTo, matchAccount);
|
|
293
|
+
const opened = matchesAccount(bug.openedBy, matchAccount);
|
|
294
|
+
const resolved = matchesAccount(bug.resolvedBy, matchAccount);
|
|
295
|
+
if (targetScope === "assigned") return assigned;
|
|
296
|
+
if (targetScope === "opened") return opened;
|
|
297
|
+
if (targetScope === "resolved") return resolved;
|
|
298
|
+
return assigned || opened || resolved;
|
|
278
299
|
});
|
|
279
300
|
|
|
280
301
|
if (!includeZero && matches.length === 0) continue;
|
|
@@ -337,7 +358,7 @@ function getClient() {
|
|
|
337
358
|
const server = new Server(
|
|
338
359
|
{
|
|
339
360
|
name: "zentao-mcp",
|
|
340
|
-
version: "0.
|
|
361
|
+
version: "0.3.1",
|
|
341
362
|
},
|
|
342
363
|
{
|
|
343
364
|
capabilities: {
|