@levinariy.fedorov/youtrack-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.
Files changed (2) hide show
  1. package/dist/write.js +17 -6
  2. package/package.json +1 -1
package/dist/write.js CHANGED
@@ -16,12 +16,23 @@ async function resolveAudience(client, audience) {
16
16
  groups.push({ id: group.id });
17
17
  continue;
18
18
  }
19
- const login = target.toLowerCase() === "me" ? undefined : target;
20
- const user = login
21
- ? await client.get("/api/users", { fields: "id,login", query: login, $top: 1 }).then((list) => list[0])
22
- : await client.get("/api/users/me", { fields: "id" });
23
- if (!user)
24
- throw new YouTrackError(`Пользователя «${target}» нет в YouTrack.`, 404);
19
+ if (target.toLowerCase() === "me") {
20
+ users.push({ id: (await client.get("/api/users/me", { fields: "id" })).id });
21
+ continue;
22
+ }
23
+ // Только точное совпадение логина. Поиск YouTrack нечёткий, и первый
24
+ // попавшийся из выдачи это чужой человек, которому опечатка откроет
25
+ // заметку, писавшуюся не для него.
26
+ const found = await client.get("/api/users", {
27
+ fields: "id,login",
28
+ query: target,
29
+ $top: 50
30
+ });
31
+ const user = found.find((item) => item.login === target);
32
+ if (!user) {
33
+ const near = found.map((item) => item.login).slice(0, 5);
34
+ throw new YouTrackError(`Логина «${target}» в YouTrack нет.${near.length > 0 ? ` Похожие: ${near.join(", ")}.` : ""}`, 404);
35
+ }
25
36
  users.push({ id: user.id });
26
37
  }
27
38
  if (groups.length === 0 && users.length === 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levinariy.fedorov/youtrack-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "MCP-сервер и библиотека для YouTrack: чтение задачи целиком, комментарии, поля и статусы, списание времени.",
6
6
  "keywords": [