@vitalyostanin/youtrack-mcp 0.7.4 → 0.8.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/README-ru.md +7 -1
- package/README.md +7 -1
- package/dist/package.json +1 -1
- package/dist/src/server.js +2 -0
- package/dist/src/tools/users-activity-tools.d.ts +115 -0
- package/dist/src/tools/users-activity-tools.js +84 -0
- package/dist/src/utils/date.d.ts +2 -0
- package/dist/src/utils/date.js +3 -0
- package/dist/src/utils/mappers.d.ts +0 -1
- package/dist/src/utils/mappers.js +0 -1
- package/dist/src/youtrack-client.d.ts +10 -0
- package/dist/src/youtrack-client.js +59 -23
- package/package.json +1 -1
package/README-ru.md
CHANGED
|
@@ -45,6 +45,7 @@ MCP сервер для полноценной интеграции с YouTrack
|
|
|
45
45
|
- [Трудозатраты](#трудозатраты)
|
|
46
46
|
- [Пользователи и проекты](#пользователи-и-проекты)
|
|
47
47
|
- [Статьи](#статьи)
|
|
48
|
+
- [Лента активности](#лента-активности)
|
|
48
49
|
- [Вложения](#вложения)
|
|
49
50
|
|
|
50
51
|
## Требования
|
|
@@ -294,7 +295,6 @@ YOUTRACK_TOKEN = "perm:your-token-here"
|
|
|
294
295
|
| `issue_comment_update` | Обновление существующего комментария. **Использование:** Редактирование текста комментария, изменение режима форматирования, исправление опечаток. Поддерживает Markdown. **Возвращает:** поля комментария - id, text, textPreview, usesMarkdown, author, created, updated, commentUrl | `issueId` — ID или код задачи, `commentId` — ID комментария, опционально `text`, `usesMarkdown`, `muteUpdateNotifications` |
|
|
295
296
|
| `issue_activities` | Получение истории изменений задачи (активности). **Использование:** Просмотр полной истории задачи, отслеживание изменений полей во времени, мониторинг кто и когда что изменил, анализ эволюции задачи, аудит модификаций. **Возвращает:** Элементы активности с временными метками (ISO datetime), авторами, категориями, типами изменений и деталями изменений (добавленные/удалённые значения). Поддерживает фильтрацию по автору, диапазону дат и категориям активности. **Примечание:** Возвращает предопределённые поля - id, timestamp, author (id, login, name), category (id), target (text), добавленные значения, удалённые значения, тип активности. Полезно для понимания жизненного цикла задачи, отслеживания модификаций полей, просмотра истории комментариев и анализа паттернов совместной работы. | `issueId` — код задачи, опционально `author` (логин пользователя), `startDate` (формат YYYY-MM-DD, timestamp или Date), `endDate`, `categories` (через запятую: `CustomFieldCategory` для изменений полей, `CommentsCategory` для комментариев, `AttachmentsCategory` для вложений, `LinksCategory` для связей, `VcsChangeActivityCategory` для VCS изменений, `WorkItemsActivityCategory` для трудозатрат), `limit` (макс 200), `skip` для пагинации |
|
|
296
297
|
| `issue_change_state` | Изменение состояния/статуса задачи через переходы workflow. **Использование:** Перемещение задач через состояния рабочего процесса (например, 'Открыта' → 'В работе'). Автоматически определяет доступные переходы и валидирует запрошенное изменение состояния. Регистронезависимое сопоставление имён состояний. **Возвращает:** информацию о предыдущем состоянии, новом состоянии и использованном переходе | `issueId` — код задачи, `stateName` — имя целевого состояния (например, 'В работе', 'Открыта', 'Исправлена', 'Проверена'). Регистронезависимое |
|
|
297
|
-
| `issue_search_by_user_activity` | Поиск задач по активности пользователей в заданный период. **Использование:** Поиск задач, где пользователи обновляли, были упомянуты, создавали, были назначены или комментировали. Поддерживает два режима фильтрации: `issue_updated` (по умолчанию, быстрый) использует поле issue.updated, `user_activity` (медленный, точный) проверяет фактические даты активности пользователя, включая комментарии, упоминания и историю изменений полей. **Когда использовать точный режим:** когда нужна точная дата участия пользователя (например, когда пользователь был исполнителем, но позже был изменён). **Возвращает:** краткую информацию о задачах (id, idReadable, summary, project, parent, assignee) без description для уменьшения размера ответа. В режиме `user_activity` включает поле `lastActivityDate` с точной датой последней активности пользователя. Результаты отсортированы по времени активности (новые первыми). Поддерживает пагинацию. **Ограничение:** по умолчанию 100 задач, макс 200 | `userLogins[]` — массив логинов пользователей для поиска активности (updater, mentions, reporter, assignee, commenter), опционально `startDate` (формат YYYY-MM-DD или timestamp), `endDate`, `dateFilterMode` (`issue_updated` или `user_activity`), `limit` (по умолчанию 100, макс 200), `skip` для пагинации |
|
|
298
298
|
|
|
299
299
|
### Связи задач
|
|
300
300
|
|
|
@@ -367,6 +367,12 @@ YOUTRACK_TOKEN = "perm:your-token-here"
|
|
|
367
367
|
| `issues_list` | Список задач по фильтрам с поддержкой сортировки. **Использование:** Дашборды, аудит командной загрузки, подготовка батч-операций. Поддерживает фильтрацию по проектам, датам создания/обновления, статусам, типам, исполнителю. **Возвращает:** краткие или полные данные задачи в зависимости от `briefOutput`, а также информацию о сортировке и пагинации. | Фильтры: `projectIds`, `createdAfter/Before`, `updatedAfter/Before`, `statuses`, `assigneeLogin`, `types`; сортировка: `sortField` (`created`/`updated`), `sortDirection` (`asc`/`desc`); пагинация: `limit`, `skip`; формат: `briefOutput` |
|
|
368
368
|
| `issues_count` | Подсчёт задач с теми же фильтрами, что у `issues_list`, с разбивкой по проектам. **Использование:** Быстрая оценка объёмов работ перед загрузкой полного списка, подготовка аналитических отчётов. При запросе одного проекта обращается к `/api/issuesGetter/count`, иначе считает постранично. | Те же фильтры, что и `issues_list`; опциональный `top` ограничивает объём ручной агрегации (при необходимости частичной выборки) |
|
|
369
369
|
|
|
370
|
+
### Лента активности
|
|
371
|
+
|
|
372
|
+
| Tool | Описание | Основные параметры |
|
|
373
|
+
| --- | --- | --- |
|
|
374
|
+
| `users_activity` | Авторо-центричная лента активности на базе `/api/activities`. **Использование:** аудит обновлений коллеги, накопление комментариев/смен состояний по множеству задач, проверка таймлайна выката. Возвращает нормализованные записи с ISO-временем, ссылками на задачи и полями `added`/`removed`. После анализа обязательно повторно запросите затронутые задачи или рабочие элементы, чтобы убедиться в актуальном состоянии. Поддерживаемые категории: `CustomFieldCategory` (изменения полей), `CommentsCategory` (комментарии), `AttachmentsCategory` (файлы), `LinksCategory` (ссылки), `VcsChangeActivityCategory` (VCS изменения), `WorkItemsActivityCategory` (трудозатраты). | `author` *(обязательный)* — логин пользователя (например, `vyt`); `categories` *(обязательный)* — список категорий через запятую из перечня выше; опционально `start` / `end` (ISO-строка, timestamp в мс или `Date`) для ограничения диапазона, `reverse` (boolean) для прямого хронометража, `limit` (по умолчанию 100, макс 200), `skip` (смещение пагинации), `fields` (расширенный перегруз возвращаемых полей). |
|
|
375
|
+
|
|
370
376
|
### Вложения
|
|
371
377
|
|
|
372
378
|
| Tool | Описание | Основные параметры |
|
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ MCP server for comprehensive YouTrack integration with the following capabilitie
|
|
|
48
48
|
- [Users and Projects](#users-and-projects)
|
|
49
49
|
- [Articles](#articles)
|
|
50
50
|
- [Search](#search)
|
|
51
|
+
- [Activity Feed](#activity-feed)
|
|
51
52
|
- [Important Notes](#important-notes)
|
|
52
53
|
- [Destructive Operations](#destructive-operations)
|
|
53
54
|
|
|
@@ -298,7 +299,6 @@ Tools return either `structuredContent` (default) or a text `content` item, depe
|
|
|
298
299
|
| `issue_comment_update` | Update existing comment | `issueId`, `commentId`, optionally `text`, `usesMarkdown`, `muteUpdateNotifications` |
|
|
299
300
|
| `issue_activities` | Get issue change history | `issueId` — issue code, optionally `author` (login), `startDate` (YYYY-MM-DD, timestamp, or Date), `endDate`, `categories` (comma-separated: `CustomFieldCategory` for field changes, `CommentsCategory` for comments, `AttachmentsCategory` for attachments, `LinksCategory` for links, `VcsChangeActivityCategory` for VCS changes, `WorkItemsActivityCategory` for work items), `limit` (max 200), `skip` for pagination. Returns activity items with timestamps (ISO datetime), authors, categories, and change details (added/removed values). Useful for tracking field modifications, reviewing comment history, and analyzing collaboration patterns |
|
|
300
301
|
| `issue_change_state` | Change issue state/status through workflow transitions | `issueId` — issue code, `stateName` — target state name (e.g., 'In Progress', 'Open', 'Fixed', 'Verified'). Case-insensitive. Automatically discovers available transitions and validates requested state change. Returns information about previous state, new state, and transition used. Use for moving issues through workflow states |
|
|
301
|
-
| `issue_search_by_user_activity` | Search issues with user activity | `userLogins[]` — array of user logins, optionally `startDate`, `endDate`, `dateFilterMode` (`issue_updated` fast mode or `user_activity` precise mode), `limit` (default 100, max 200). Finds issues where users updated, mentioned, reported, assigned, or commented. Fast mode filters by issue.updated field; precise mode checks actual user activity dates including comments, mentions, and field changes history (e.g., when user was assignee but later changed). In precise mode, returns `lastActivityDate` field. Sorted by activity time (newest first) |
|
|
302
302
|
| `issue_attachments_list` | Get list of attachments | `issueId` — issue code |
|
|
303
303
|
| `issue_attachment_get` | Get attachment info | `issueId`, `attachmentId` |
|
|
304
304
|
| `issue_attachment_download` | Get download URL for attachment | `issueId`, `attachmentId` — returns signed URL |
|
|
@@ -370,6 +370,12 @@ Tools return either `structuredContent` (default) or a text `content` item, depe
|
|
|
370
370
|
| --- | --- | --- |
|
|
371
371
|
| `articles_search` | Full-text search across YouTrack knowledge base articles by title and content. Returns `webUrl` for direct access | `query` (min 2 chars), `limit` (default 50, max 200), `skip`, optionally `projectId`, `parentArticleId` |
|
|
372
372
|
| `issues_search` | Full-text search across YouTrack issues by summary, description, and comments. If `query` is not provided or empty, all issues will be returned. Supports filtering by projects, assignee, reporter, state, and type | `query` (optional), `limit` (default 50, max 200), `skip`, `countOnly` (optional), `projects` (optional), `assignee` (optional), `reporter` (optional), `state` (optional), `type` (optional) |
|
|
373
|
+
|
|
374
|
+
### Activity Feed
|
|
375
|
+
|
|
376
|
+
| Tool | Description | Main Parameters |
|
|
377
|
+
| --- | --- | --- |
|
|
378
|
+
| `users_activity` | Author-centric activity feed backed by `/api/activities`. **Use for:** auditing a teammate's updates, gathering comment/state changes across many issues, and reviewing deployment timelines. Returns normalized entries with ISO timestamps, optional issue references, and `added`/`removed` payloads. Always follow up by re-fetching the affected issue or work-item to confirm the latest state. Supported categories: `CustomFieldCategory` (field changes), `CommentsCategory` (comments), `AttachmentsCategory` (file events), `LinksCategory` (issue links), `VcsChangeActivityCategory` (VCS changes), `WorkItemsActivityCategory` (work items). | `author` *(required)* — login such as `vyt`; `categories` *(required)* — comma-separated list built from the supported categories above; optional `start` / `end` (ISO string, timestamp in ms, or `Date`) to bound the range, `reverse` (boolean) to switch to chronological order, `limit` (default 100, max 200), `skip` (pagination offset), `fields` (advanced override of response fields). |
|
|
373
379
|
| `issues_list` | List issues across projects with filtering and sorting | Filters: `projectIds`, `createdAfter/Before`, `updatedAfter/Before`, `statuses`, `assigneeLogin`, `types`; Sorting: `sortField`, `sortDirection`; Pagination: `limit`, `skip`; Output mode: `briefOutput` |
|
|
374
380
|
| `issues_count` | Count issues using same filters as `issues_list`, returns per-project breakdown | Same filters as above, optional `top` to cap manual aggregation when many projects are involved |
|
|
375
381
|
|
package/dist/package.json
CHANGED
package/dist/src/server.js
CHANGED
|
@@ -12,6 +12,7 @@ import { registerProjectTools } from "./tools/project-tools.js";
|
|
|
12
12
|
import { registerAttachmentTools } from "./tools/attachment-tools.js";
|
|
13
13
|
import { registerIssueStarTools } from "./tools/issue-star-tools.js";
|
|
14
14
|
import { registerIssueLinkTools } from "./tools/issue-link-tools.js";
|
|
15
|
+
import { usersActivityArgs, usersActivityHandler } from "./tools/users-activity-tools.js";
|
|
15
16
|
import { YoutrackClient } from "./youtrack-client.js";
|
|
16
17
|
import { loadConfig } from "./config.js";
|
|
17
18
|
import { initializeTimezone } from "./utils/date.js";
|
|
@@ -46,6 +47,7 @@ export class YoutrackServer {
|
|
|
46
47
|
registerArticleTools(this.server, this.client);
|
|
47
48
|
// Removed redundant registerArticleSearchTools call (articles_search tool registered manually above)
|
|
48
49
|
registerUserTools(this.server, this.client);
|
|
50
|
+
this.server.tool("users_activity", "Author-centric activity feed backed by /api/activities. Use for: auditing a teammate's updates, gathering comment/state changes across many issues, and reviewing deployment timelines. Always re-fetch affected entities to confirm final state.", usersActivityArgs, async (args) => usersActivityHandler(this.client, args));
|
|
49
51
|
registerProjectTools(this.server, this.client);
|
|
50
52
|
registerAttachmentTools(this.server, this.client);
|
|
51
53
|
registerIssueStarTools(this.server, this.client);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { YoutrackClient } from "../youtrack-client.js";
|
|
3
|
+
export declare const usersActivityArgs: {
|
|
4
|
+
author: z.ZodString;
|
|
5
|
+
start: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodDate]>>;
|
|
6
|
+
end: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodDate]>>;
|
|
7
|
+
categories: z.ZodString;
|
|
8
|
+
reverse: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
skip: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
fields: z.ZodOptional<z.ZodString>;
|
|
12
|
+
};
|
|
13
|
+
export declare const usersActivitySchema: z.ZodObject<{
|
|
14
|
+
author: z.ZodString;
|
|
15
|
+
start: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodDate]>>;
|
|
16
|
+
end: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodDate]>>;
|
|
17
|
+
categories: z.ZodString;
|
|
18
|
+
reverse: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
skip: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
fields: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
author: string;
|
|
24
|
+
skip: number;
|
|
25
|
+
categories: string;
|
|
26
|
+
limit: number;
|
|
27
|
+
reverse?: boolean | undefined;
|
|
28
|
+
fields?: string | undefined;
|
|
29
|
+
start?: string | number | Date | undefined;
|
|
30
|
+
end?: string | number | Date | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
author: string;
|
|
33
|
+
categories: string;
|
|
34
|
+
reverse?: boolean | undefined;
|
|
35
|
+
skip?: number | undefined;
|
|
36
|
+
fields?: string | undefined;
|
|
37
|
+
start?: string | number | Date | undefined;
|
|
38
|
+
end?: string | number | Date | undefined;
|
|
39
|
+
limit?: number | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function usersActivityHandler(client: YoutrackClient, rawInput: unknown): Promise<{
|
|
42
|
+
[x: string]: unknown;
|
|
43
|
+
content: ({
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
text: string;
|
|
46
|
+
type: "text";
|
|
47
|
+
_meta?: {
|
|
48
|
+
[x: string]: unknown;
|
|
49
|
+
} | undefined;
|
|
50
|
+
} | {
|
|
51
|
+
[x: string]: unknown;
|
|
52
|
+
type: "image";
|
|
53
|
+
data: string;
|
|
54
|
+
mimeType: string;
|
|
55
|
+
_meta?: {
|
|
56
|
+
[x: string]: unknown;
|
|
57
|
+
} | undefined;
|
|
58
|
+
} | {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
type: "audio";
|
|
61
|
+
data: string;
|
|
62
|
+
mimeType: string;
|
|
63
|
+
_meta?: {
|
|
64
|
+
[x: string]: unknown;
|
|
65
|
+
} | undefined;
|
|
66
|
+
} | {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
name: string;
|
|
69
|
+
type: "resource_link";
|
|
70
|
+
uri: string;
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
_meta?: {
|
|
73
|
+
[x: string]: unknown;
|
|
74
|
+
} | undefined;
|
|
75
|
+
mimeType?: string | undefined;
|
|
76
|
+
title?: string | undefined;
|
|
77
|
+
icons?: {
|
|
78
|
+
[x: string]: unknown;
|
|
79
|
+
src: string;
|
|
80
|
+
mimeType?: string | undefined;
|
|
81
|
+
sizes?: string[] | undefined;
|
|
82
|
+
}[] | undefined;
|
|
83
|
+
} | {
|
|
84
|
+
[x: string]: unknown;
|
|
85
|
+
type: "resource";
|
|
86
|
+
resource: {
|
|
87
|
+
[x: string]: unknown;
|
|
88
|
+
text: string;
|
|
89
|
+
uri: string;
|
|
90
|
+
_meta?: {
|
|
91
|
+
[x: string]: unknown;
|
|
92
|
+
} | undefined;
|
|
93
|
+
mimeType?: string | undefined;
|
|
94
|
+
} | {
|
|
95
|
+
[x: string]: unknown;
|
|
96
|
+
uri: string;
|
|
97
|
+
blob: string;
|
|
98
|
+
_meta?: {
|
|
99
|
+
[x: string]: unknown;
|
|
100
|
+
} | undefined;
|
|
101
|
+
mimeType?: string | undefined;
|
|
102
|
+
};
|
|
103
|
+
_meta?: {
|
|
104
|
+
[x: string]: unknown;
|
|
105
|
+
} | undefined;
|
|
106
|
+
})[];
|
|
107
|
+
_meta?: {
|
|
108
|
+
[x: string]: unknown;
|
|
109
|
+
} | undefined;
|
|
110
|
+
structuredContent?: {
|
|
111
|
+
[x: string]: unknown;
|
|
112
|
+
} | undefined;
|
|
113
|
+
isError?: boolean | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
//# sourceMappingURL=users-activity-tools.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { parseDateInput, toIsoDateString, unixMsToDate, getCurrentDate } from "../utils/date.js";
|
|
3
|
+
import { mapActivityItems } from "../utils/mappers.js";
|
|
4
|
+
import { toolSuccess, toolError } from "../utils/tool-response.js";
|
|
5
|
+
export const usersActivityArgs = {
|
|
6
|
+
author: z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.describe("Filter by author login (required, e.g., 'vyt'). Matches activities created by this user."),
|
|
10
|
+
start: z
|
|
11
|
+
.union([z.string(), z.number(), z.date()])
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Inclusive start of the interval. Accepts ISO string, unix timestamp (ms), or Date object. Converted to unix ms for /api/activities (default: no lower bound)."),
|
|
14
|
+
end: z
|
|
15
|
+
.union([z.string(), z.number(), z.date()])
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Inclusive end of the interval. Accepts ISO string, unix timestamp (ms), or Date object. Converted to unix ms for /api/activities (default: now)."),
|
|
18
|
+
categories: z
|
|
19
|
+
.string()
|
|
20
|
+
.describe("Comma-separated list of activity categories. Supported values: 'CustomFieldCategory', 'CommentsCategory', 'AttachmentsCategory', 'LinksCategory', 'VcsChangeActivityCategory', 'WorkItemsActivityCategory'."),
|
|
21
|
+
reverse: z
|
|
22
|
+
.boolean()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("When true, return activities in ascending order (oldest first). Default is false (newest first)."),
|
|
25
|
+
limit: z
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.positive()
|
|
29
|
+
.max(200)
|
|
30
|
+
.default(100)
|
|
31
|
+
.describe("Maximum number of activities to return (default 100, max 200)."),
|
|
32
|
+
skip: z
|
|
33
|
+
.number()
|
|
34
|
+
.int()
|
|
35
|
+
.nonnegative()
|
|
36
|
+
.default(0)
|
|
37
|
+
.describe("Number of activities to skip for pagination (default 0)."),
|
|
38
|
+
fields: z
|
|
39
|
+
.string()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Override fields parameter passed to /api/activities (advanced). Defaults to issue idReadable, author, added/removed, category, timestamps."),
|
|
42
|
+
};
|
|
43
|
+
export const usersActivitySchema = z.object(usersActivityArgs);
|
|
44
|
+
export async function usersActivityHandler(client, rawInput) {
|
|
45
|
+
try {
|
|
46
|
+
const input = usersActivitySchema.parse(rawInput);
|
|
47
|
+
const startMs = parseDateInput(input.start ?? unixMsToDate(0));
|
|
48
|
+
const endMs = parseDateInput(input.end ?? getCurrentDate());
|
|
49
|
+
if (startMs > endMs) {
|
|
50
|
+
throw new Error("'start' must be earlier than or equal to 'end'.");
|
|
51
|
+
}
|
|
52
|
+
const activities = await client.listActivities({
|
|
53
|
+
author: input.author,
|
|
54
|
+
categories: input.categories,
|
|
55
|
+
start: startMs,
|
|
56
|
+
end: endMs,
|
|
57
|
+
limit: input.limit,
|
|
58
|
+
skip: input.skip,
|
|
59
|
+
fields: input.fields,
|
|
60
|
+
reverse: input.reverse,
|
|
61
|
+
});
|
|
62
|
+
const mappedActivities = mapActivityItems(activities);
|
|
63
|
+
const payload = {
|
|
64
|
+
activities: mappedActivities,
|
|
65
|
+
filters: {
|
|
66
|
+
author: input.author,
|
|
67
|
+
start: toIsoDateString(input.start ?? unixMsToDate(startMs)),
|
|
68
|
+
end: toIsoDateString(input.end ?? unixMsToDate(endMs)),
|
|
69
|
+
categories: input.categories,
|
|
70
|
+
reverse: input.reverse,
|
|
71
|
+
},
|
|
72
|
+
pagination: {
|
|
73
|
+
returned: mappedActivities.length,
|
|
74
|
+
limit: input.limit,
|
|
75
|
+
skip: input.skip,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
return toolSuccess(payload);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return toolError(error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=users-activity-tools.js.map
|
package/dist/src/utils/date.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateTime } from "luxon";
|
|
1
2
|
export declare function initializeTimezone(timezone: string): void;
|
|
2
3
|
export declare function getTimezone(): string;
|
|
3
4
|
export declare function parseDateInput(value: string | number | Date): number;
|
|
@@ -31,4 +32,5 @@ export declare function filterWorkingDates(dates: Date[], excludeWeekends?: bool
|
|
|
31
32
|
export declare function isSameDay(left: string | number | Date, right: string | number | Date): boolean;
|
|
32
33
|
export declare function getCurrentTimestamp(): number;
|
|
33
34
|
export declare function getCurrentDate(timezone?: string): Date;
|
|
35
|
+
export declare function getCurrentDateTime(timezone?: string): DateTime;
|
|
34
36
|
//# sourceMappingURL=date.d.ts.map
|
package/dist/src/utils/date.js
CHANGED
|
@@ -144,4 +144,7 @@ export function getCurrentTimestamp() {
|
|
|
144
144
|
export function getCurrentDate(timezone = currentTimezone) {
|
|
145
145
|
return DateTime.now().setZone(timezone).toJSDate();
|
|
146
146
|
}
|
|
147
|
+
export function getCurrentDateTime(timezone = currentTimezone) {
|
|
148
|
+
return DateTime.now().setZone(timezone);
|
|
149
|
+
}
|
|
147
150
|
//# sourceMappingURL=date.js.map
|
|
@@ -48,7 +48,6 @@ export declare function mapIssue(issue: YoutrackIssue): MappedYoutrackIssue;
|
|
|
48
48
|
export declare function mapIssueDetails(issue: YoutrackIssueDetails): MappedYoutrackIssueDetails;
|
|
49
49
|
/**
|
|
50
50
|
* Map YoutrackIssue to brief version (without description fields)
|
|
51
|
-
* Used for reducing payload size in issue_search_by_user_activity tool
|
|
52
51
|
*/
|
|
53
52
|
export declare function mapIssueBrief(issue: YoutrackIssue): MappedYoutrackIssue;
|
|
54
53
|
/**
|
|
@@ -50,7 +50,6 @@ export function mapIssueDetails(issue) {
|
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Map YoutrackIssue to brief version (without description fields)
|
|
53
|
-
* Used for reducing payload size in issue_search_by_user_activity tool
|
|
54
53
|
*/
|
|
55
54
|
export function mapIssueBrief(issue) {
|
|
56
55
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -53,6 +53,16 @@ export declare class YoutrackClient {
|
|
|
53
53
|
startDate?: number;
|
|
54
54
|
endDate?: number;
|
|
55
55
|
}): Promise<YoutrackActivityItem[]>;
|
|
56
|
+
listActivities({ author, categories, start, end, limit, skip, fields, reverse, }: {
|
|
57
|
+
author: string;
|
|
58
|
+
categories?: string;
|
|
59
|
+
start?: number;
|
|
60
|
+
end?: number;
|
|
61
|
+
limit?: number;
|
|
62
|
+
skip?: number;
|
|
63
|
+
fields?: string;
|
|
64
|
+
reverse?: boolean;
|
|
65
|
+
}): Promise<YoutrackActivityItem[]>;
|
|
56
66
|
createIssue(input: YoutrackIssueCreateInput): Promise<IssueLookupPayload>;
|
|
57
67
|
updateIssue(input: YoutrackIssueUpdateInput): Promise<IssueLookupPayload>;
|
|
58
68
|
assignIssue(input: YoutrackIssueAssignInput): Promise<IssueLookupPayload>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import FormData from "form-data";
|
|
3
3
|
import fs from "fs";
|
|
4
|
+
import { DateTime } from "luxon";
|
|
4
5
|
import { MutexPool } from "@vitalyostanin/mutex-pool";
|
|
5
|
-
import { calculateTotalMinutes, enumerateDateRange, filterWorkingDays, getDayBounds, groupWorkItemsByDate, isWeekend, minutesToHours, parseDateInput, toIsoDateString, validateDateRange, } from "./utils/date.js";
|
|
6
|
+
import { calculateTotalMinutes, enumerateDateRange, filterWorkingDays, getCurrentDateTime, getCurrentTimestamp, getDayBounds, groupWorkItemsByDate, isWeekend, minutesToHours, parseDateInput, toIsoDateString, validateDateRange, } from "./utils/date.js";
|
|
6
7
|
import { mapAttachment, mapAttachments, mapComment, mapComments, mapIssue, mapIssueBrief, mapIssueDetails, mapWorkItem, mapWorkItems, } from "./utils/mappers.js";
|
|
7
8
|
import { buildIssueQuery } from "./utils/issue-query.js";
|
|
8
9
|
const DEFAULT_PAGE_SIZE = 200;
|
|
@@ -120,13 +121,15 @@ export class YoutrackClient {
|
|
|
120
121
|
Object.prototype.hasOwnProperty.call(params, "skip");
|
|
121
122
|
// First attempt: prefer $top/$skip
|
|
122
123
|
const dollarParams = { ...params };
|
|
123
|
-
if (Object.prototype.hasOwnProperty.call(dollarParams, "top") &&
|
|
124
|
-
(dollarParams)
|
|
125
|
-
|
|
124
|
+
if (Object.prototype.hasOwnProperty.call(dollarParams, "top") &&
|
|
125
|
+
!Object.prototype.hasOwnProperty.call(dollarParams, "$top")) {
|
|
126
|
+
dollarParams.$top = dollarParams.top;
|
|
127
|
+
delete dollarParams.top;
|
|
126
128
|
}
|
|
127
|
-
if (Object.prototype.hasOwnProperty.call(dollarParams, "skip") &&
|
|
128
|
-
(dollarParams)
|
|
129
|
-
|
|
129
|
+
if (Object.prototype.hasOwnProperty.call(dollarParams, "skip") &&
|
|
130
|
+
!Object.prototype.hasOwnProperty.call(dollarParams, "$skip")) {
|
|
131
|
+
dollarParams.$skip = dollarParams.skip;
|
|
132
|
+
delete dollarParams.skip;
|
|
130
133
|
}
|
|
131
134
|
try {
|
|
132
135
|
const res = await this.http.get(url, { params: dollarParams });
|
|
@@ -137,12 +140,12 @@ export class YoutrackClient {
|
|
|
137
140
|
// Retry with plain top/skip
|
|
138
141
|
const plainParams = { ...params };
|
|
139
142
|
if (Object.prototype.hasOwnProperty.call(plainParams, "$top")) {
|
|
140
|
-
|
|
141
|
-
delete
|
|
143
|
+
plainParams.top = plainParams.$top;
|
|
144
|
+
delete plainParams.$top;
|
|
142
145
|
}
|
|
143
146
|
if (Object.prototype.hasOwnProperty.call(plainParams, "$skip")) {
|
|
144
|
-
|
|
145
|
-
delete
|
|
147
|
+
plainParams.skip = plainParams.$skip;
|
|
148
|
+
delete plainParams.$skip;
|
|
146
149
|
}
|
|
147
150
|
const res2 = await this.http.get(url, { params: plainParams });
|
|
148
151
|
return res2.data;
|
|
@@ -608,6 +611,34 @@ export class YoutrackClient {
|
|
|
608
611
|
throw this.normalizeError(error);
|
|
609
612
|
}
|
|
610
613
|
}
|
|
614
|
+
async listActivities({ author, categories, start, end, limit, skip, fields, reverse, }) {
|
|
615
|
+
const params = {
|
|
616
|
+
author,
|
|
617
|
+
fields: fields ??
|
|
618
|
+
"id,timestamp,author(id,login,name),category(id),target(issue(idReadable,summary),text),added(name,id,login),removed(name,id,login),$type",
|
|
619
|
+
};
|
|
620
|
+
if (categories) {
|
|
621
|
+
params.categories = categories;
|
|
622
|
+
}
|
|
623
|
+
if (typeof start === "number") {
|
|
624
|
+
params.start = start;
|
|
625
|
+
}
|
|
626
|
+
if (typeof end === "number") {
|
|
627
|
+
params.end = end;
|
|
628
|
+
}
|
|
629
|
+
params.$top = Math.min(limit ?? DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE);
|
|
630
|
+
params.$skip = skip ?? 0;
|
|
631
|
+
if (reverse !== undefined) {
|
|
632
|
+
params.reverse = reverse;
|
|
633
|
+
}
|
|
634
|
+
try {
|
|
635
|
+
const response = await this.http.get("/api/activities", { params });
|
|
636
|
+
return response.data;
|
|
637
|
+
}
|
|
638
|
+
catch (error) {
|
|
639
|
+
throw this.normalizeError(error);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
611
642
|
async createIssue(input) {
|
|
612
643
|
const projectIdentifier = input.projectId ?? this.defaultProject;
|
|
613
644
|
if (!projectIdentifier) {
|
|
@@ -909,7 +940,7 @@ export class YoutrackClient {
|
|
|
909
940
|
// Add date range filter if provided
|
|
910
941
|
if (input.startDate || input.endDate) {
|
|
911
942
|
const startDateStr = input.startDate ? toIsoDateString(input.startDate) : "1970-01-01";
|
|
912
|
-
const endDateStr = input.endDate ? toIsoDateString(input.endDate) :
|
|
943
|
+
const endDateStr = input.endDate ? toIsoDateString(input.endDate) : getCurrentDateTime().toISO();
|
|
913
944
|
filters.push(`updated: ${startDateStr} .. ${endDateStr}`);
|
|
914
945
|
}
|
|
915
946
|
// Add sorting by updated time descending
|
|
@@ -952,7 +983,7 @@ export class YoutrackClient {
|
|
|
952
983
|
// and to reduce candidate set before precise post-filtering.
|
|
953
984
|
if (input.startDate || input.endDate) {
|
|
954
985
|
const startDateStr = input.startDate ? toIsoDateString(input.startDate) : "1970-01-01";
|
|
955
|
-
const endDateStr = input.endDate ? toIsoDateString(input.endDate) :
|
|
986
|
+
const endDateStr = input.endDate ? toIsoDateString(input.endDate) : getCurrentDateTime().toISO();
|
|
956
987
|
filters.push(`updated: ${startDateStr} .. ${endDateStr}`);
|
|
957
988
|
}
|
|
958
989
|
const sortPart = "sort by: updated desc";
|
|
@@ -1057,7 +1088,10 @@ export class YoutrackClient {
|
|
|
1057
1088
|
const limit = input.limit ?? 100;
|
|
1058
1089
|
const paginatedIssues = issuesWithActivity.slice(skip, skip + limit);
|
|
1059
1090
|
const mapperFn = briefOutput ? mapIssueBrief : mapIssue;
|
|
1060
|
-
const resultIssues = paginatedIssues.map(({ issue, lastActivityDate }) => ({
|
|
1091
|
+
const resultIssues = paginatedIssues.map(({ issue, lastActivityDate }) => ({
|
|
1092
|
+
...mapperFn(issue),
|
|
1093
|
+
lastActivityDate,
|
|
1094
|
+
}));
|
|
1061
1095
|
return {
|
|
1062
1096
|
issues: resultIssues,
|
|
1063
1097
|
userLogins: input.userLogins,
|
|
@@ -1085,8 +1119,8 @@ export class YoutrackClient {
|
|
|
1085
1119
|
* Used in user_activity mode to determine which issues had activity from specified users
|
|
1086
1120
|
*/
|
|
1087
1121
|
filterIssuesByUserActivity(candidateIssues, detailsLight, commentsLight, activitiesResults, input) {
|
|
1088
|
-
const startTimestamp = input.startDate ?
|
|
1089
|
-
const endTimestamp = input.endDate ?
|
|
1122
|
+
const startTimestamp = input.startDate ? parseDateInput(input.startDate) : 0;
|
|
1123
|
+
const endTimestamp = input.endDate ? parseDateInput(input.endDate) : getCurrentTimestamp();
|
|
1090
1124
|
const issuesWithActivity = [];
|
|
1091
1125
|
for (let i = 0; i < candidateIssues.length; i++) {
|
|
1092
1126
|
const issue = candidateIssues[i];
|
|
@@ -1137,7 +1171,7 @@ export class YoutrackClient {
|
|
|
1137
1171
|
}
|
|
1138
1172
|
if (dates.length > 0) {
|
|
1139
1173
|
const lastActivityTimestamp = Math.max(...dates);
|
|
1140
|
-
const lastActivityDate =
|
|
1174
|
+
const lastActivityDate = DateTime.fromMillis(lastActivityTimestamp).toISO() ?? "";
|
|
1141
1175
|
issuesWithActivity.push({
|
|
1142
1176
|
issue,
|
|
1143
1177
|
lastActivityDate,
|
|
@@ -1145,7 +1179,7 @@ export class YoutrackClient {
|
|
|
1145
1179
|
}
|
|
1146
1180
|
}
|
|
1147
1181
|
// Sort by lastActivityDate descending
|
|
1148
|
-
issuesWithActivity.sort((a, b) =>
|
|
1182
|
+
issuesWithActivity.sort((a, b) => (a.lastActivityDate < b.lastActivityDate ? 1 : -1));
|
|
1149
1183
|
return issuesWithActivity;
|
|
1150
1184
|
}
|
|
1151
1185
|
// Helper to perform fallback request without braces in user filters
|
|
@@ -1157,7 +1191,7 @@ export class YoutrackClient {
|
|
|
1157
1191
|
}
|
|
1158
1192
|
if (input.startDate || input.endDate) {
|
|
1159
1193
|
const startDateStr = input.startDate ? toIsoDateString(input.startDate) : "1970-01-01";
|
|
1160
|
-
const endDateStr = input.endDate ? toIsoDateString(input.endDate) :
|
|
1194
|
+
const endDateStr = input.endDate ? toIsoDateString(input.endDate) : getCurrentDateTime().toISO();
|
|
1161
1195
|
fallbackFilters.push(`updated: ${startDateStr} .. ${endDateStr}`);
|
|
1162
1196
|
}
|
|
1163
1197
|
const fallbackQuery = (fallbackFilters.length ? `${fallbackFilters.join(" and ")} ` : "") + sortPart;
|
|
@@ -1788,8 +1822,8 @@ export class YoutrackClient {
|
|
|
1788
1822
|
}
|
|
1789
1823
|
resolveReportBoundary(items, mode) {
|
|
1790
1824
|
if (!items.length) {
|
|
1791
|
-
const todayIso =
|
|
1792
|
-
return todayIso;
|
|
1825
|
+
const todayIso = getCurrentDateTime().toISO();
|
|
1826
|
+
return todayIso ?? "";
|
|
1793
1827
|
}
|
|
1794
1828
|
const timestamps = items.map((item) => item.date);
|
|
1795
1829
|
const target = mode === "min" ? Math.min(...timestamps) : Math.max(...timestamps);
|
|
@@ -2095,7 +2129,7 @@ export class YoutrackClient {
|
|
|
2095
2129
|
const { briefOutput = true, limit = DEFAULT_PAGE_SIZE, skip = 0, sortField, sortDirection, ...filtersInput } = input;
|
|
2096
2130
|
const { query } = await buildIssueQuery(filtersInput, (projectId) => this.getProjectById(projectId));
|
|
2097
2131
|
const fields = briefOutput ? defaultFields.issueSearchBrief : defaultFields.issueSearch;
|
|
2098
|
-
const { field: resolvedField, direction: resolvedDirection, sortParam } = this.resolveSort(sortField, sortDirection);
|
|
2132
|
+
const { field: resolvedField, direction: resolvedDirection, sortParam, } = this.resolveSort(sortField, sortDirection);
|
|
2099
2133
|
const params = {
|
|
2100
2134
|
$top: Math.min(limit, DEFAULT_PAGE_SIZE),
|
|
2101
2135
|
$skip: skip,
|
|
@@ -2104,7 +2138,9 @@ export class YoutrackClient {
|
|
|
2104
2138
|
...(query ? { query } : {}),
|
|
2105
2139
|
};
|
|
2106
2140
|
const data = await this.getWithFlexibleTop("/api/issues", params);
|
|
2107
|
-
const issues = Array.isArray(data)
|
|
2141
|
+
const issues = Array.isArray(data)
|
|
2142
|
+
? data.map((issue) => (briefOutput ? mapIssueBrief(issue) : mapIssue(issue)))
|
|
2143
|
+
: [];
|
|
2108
2144
|
return {
|
|
2109
2145
|
issues,
|
|
2110
2146
|
filters: {
|