motionmcp 1.0.1 → 2.0.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/LICENSE +202 -0
- package/README.md +251 -417
- package/dist/handlers/CommentHandler.d.ts +9 -0
- package/dist/handlers/CommentHandler.d.ts.map +1 -0
- package/dist/handlers/CommentHandler.js +66 -0
- package/dist/handlers/CommentHandler.js.map +1 -0
- package/dist/handlers/CustomFieldHandler.d.ts +14 -0
- package/dist/handlers/CustomFieldHandler.d.ts.map +1 -0
- package/dist/handlers/CustomFieldHandler.js +95 -0
- package/dist/handlers/CustomFieldHandler.js.map +1 -0
- package/dist/handlers/HandlerFactory.d.ts +15 -0
- package/dist/handlers/HandlerFactory.d.ts.map +1 -0
- package/dist/handlers/HandlerFactory.js +58 -0
- package/dist/handlers/HandlerFactory.js.map +1 -0
- package/dist/handlers/ProjectHandler.d.ts +10 -0
- package/dist/handlers/ProjectHandler.d.ts.map +1 -0
- package/dist/handlers/ProjectHandler.js +63 -0
- package/dist/handlers/ProjectHandler.js.map +1 -0
- package/dist/handlers/RecurringTaskHandler.d.ts +10 -0
- package/dist/handlers/RecurringTaskHandler.d.ts.map +1 -0
- package/dist/handlers/RecurringTaskHandler.js +68 -0
- package/dist/handlers/RecurringTaskHandler.js.map +1 -0
- package/dist/handlers/ScheduleHandler.d.ts +8 -0
- package/dist/handlers/ScheduleHandler.d.ts.map +1 -0
- package/dist/handlers/ScheduleHandler.js +43 -0
- package/dist/handlers/ScheduleHandler.js.map +1 -0
- package/dist/handlers/SearchHandler.d.ts +10 -0
- package/dist/handlers/SearchHandler.d.ts.map +1 -0
- package/dist/handlers/SearchHandler.js +116 -0
- package/dist/handlers/SearchHandler.js.map +1 -0
- package/dist/handlers/StatusHandler.d.ts +8 -0
- package/dist/handlers/StatusHandler.d.ts.map +1 -0
- package/dist/handlers/StatusHandler.js +22 -0
- package/dist/handlers/StatusHandler.js.map +1 -0
- package/dist/handlers/TaskHandler.d.ts +22 -0
- package/dist/handlers/TaskHandler.d.ts.map +1 -0
- package/dist/handlers/TaskHandler.js +266 -0
- package/dist/handlers/TaskHandler.js.map +1 -0
- package/dist/handlers/UserHandler.d.ts +9 -0
- package/dist/handlers/UserHandler.d.ts.map +1 -0
- package/dist/handlers/UserHandler.js +36 -0
- package/dist/handlers/UserHandler.js.map +1 -0
- package/dist/handlers/WorkspaceHandler.d.ts +10 -0
- package/dist/handlers/WorkspaceHandler.d.ts.map +1 -0
- package/dist/handlers/WorkspaceHandler.js +49 -0
- package/dist/handlers/WorkspaceHandler.js.map +1 -0
- package/dist/handlers/base/BaseHandler.d.ts +16 -0
- package/dist/handlers/base/BaseHandler.d.ts.map +1 -0
- package/dist/handlers/base/BaseHandler.js +31 -0
- package/dist/handlers/base/BaseHandler.js.map +1 -0
- package/dist/handlers/base/HandlerInterface.d.ts +18 -0
- package/dist/handlers/base/HandlerInterface.d.ts.map +1 -0
- package/dist/handlers/base/HandlerInterface.js +3 -0
- package/dist/handlers/base/HandlerInterface.js.map +1 -0
- package/dist/handlers/index.d.ts +14 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +31 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/mcp-server-old.d.ts +29 -0
- package/dist/mcp-server-old.d.ts.map +1 -0
- package/dist/mcp-server-old.js +1304 -0
- package/dist/mcp-server-old.js.map +1 -0
- package/dist/mcp-server.d.ts +15 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +145 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/schemas/motion.d.ts +4971 -0
- package/dist/schemas/motion.d.ts.map +1 -0
- package/dist/schemas/motion.js +328 -0
- package/dist/schemas/motion.js.map +1 -0
- package/dist/services/motionApi.d.ts +186 -0
- package/dist/services/motionApi.d.ts.map +1 -0
- package/dist/services/motionApi.js +1912 -0
- package/dist/services/motionApi.js.map +1 -0
- package/dist/tools/ToolConfigurator.d.ts +19 -0
- package/dist/tools/ToolConfigurator.d.ts.map +1 -0
- package/dist/tools/ToolConfigurator.js +89 -0
- package/dist/tools/ToolConfigurator.js.map +1 -0
- package/dist/tools/ToolDefinitions.d.ts +25 -0
- package/dist/tools/ToolDefinitions.d.ts.map +1 -0
- package/dist/tools/ToolDefinitions.js +502 -0
- package/dist/tools/ToolDefinitions.js.map +1 -0
- package/dist/tools/ToolRegistry.d.ts +16 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/tools/ToolRegistry.js +89 -0
- package/dist/tools/ToolRegistry.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +21 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/mcp-tool-args.d.ts +122 -0
- package/dist/types/mcp-tool-args.d.ts.map +1 -0
- package/dist/types/mcp-tool-args.js +7 -0
- package/dist/types/mcp-tool-args.js.map +1 -0
- package/dist/types/mcp.d.ts +32 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +3 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/motion.d.ts +304 -0
- package/dist/types/motion.d.ts.map +1 -0
- package/dist/types/motion.js +3 -0
- package/dist/types/motion.js.map +1 -0
- package/dist/utils/cache.d.ts +25 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +135 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/constants.d.ts +83 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +151 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/errorHandling.d.ts +50 -0
- package/dist/utils/errorHandling.d.ts.map +1 -0
- package/dist/utils/errorHandling.js +86 -0
- package/dist/utils/errorHandling.js.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +38 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +47 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paginationNew.d.ts +44 -0
- package/dist/utils/paginationNew.d.ts.map +1 -0
- package/dist/utils/paginationNew.js +149 -0
- package/dist/utils/paginationNew.js.map +1 -0
- package/dist/utils/parameterUtils.d.ts +79 -0
- package/dist/utils/parameterUtils.d.ts.map +1 -0
- package/dist/utils/parameterUtils.js +189 -0
- package/dist/utils/parameterUtils.js.map +1 -0
- package/dist/utils/responseFormatters.d.ts +92 -0
- package/dist/utils/responseFormatters.d.ts.map +1 -0
- package/dist/utils/responseFormatters.js +331 -0
- package/dist/utils/responseFormatters.js.map +1 -0
- package/dist/utils/responseWrapper.d.ts +38 -0
- package/dist/utils/responseWrapper.d.ts.map +1 -0
- package/dist/utils/responseWrapper.js +201 -0
- package/dist/utils/responseWrapper.js.map +1 -0
- package/dist/utils/sanitize.d.ts +51 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +137 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/validator.d.ts +37 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +74 -0
- package/dist/utils/validator.js.map +1 -0
- package/dist/utils/workspaceResolver.d.ts +40 -0
- package/dist/utils/workspaceResolver.d.ts.map +1 -0
- package/dist/utils/workspaceResolver.js +207 -0
- package/dist/utils/workspaceResolver.js.map +1 -0
- package/package.json +41 -17
- package/.claude/settings.local.json +0 -15
- package/.env.example +0 -3
- package/sample.png +0 -0
- package/src/index.js +0 -49
- package/src/mcp-server.js +0 -1137
- package/src/routes/motion.js +0 -152
- package/src/services/motionApi.js +0 -1177
- package/src/worker.js +0 -248
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Response Formatting Utilities - MCP response formatting helpers
|
|
4
|
+
*
|
|
5
|
+
* This module provides utilities to format various types of responses
|
|
6
|
+
* consistently across all MCP handlers, reducing duplication and ensuring
|
|
7
|
+
* uniform response structures.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.formatListResponse = formatListResponse;
|
|
11
|
+
exports.formatProjectList = formatProjectList;
|
|
12
|
+
exports.formatTaskList = formatTaskList;
|
|
13
|
+
exports.formatWorkspaceList = formatWorkspaceList;
|
|
14
|
+
exports.formatDetailResponse = formatDetailResponse;
|
|
15
|
+
exports.formatTaskDetail = formatTaskDetail;
|
|
16
|
+
exports.formatSearchResults = formatSearchResults;
|
|
17
|
+
exports.formatCommentList = formatCommentList;
|
|
18
|
+
exports.formatCommentDetail = formatCommentDetail;
|
|
19
|
+
exports.formatCustomFieldList = formatCustomFieldList;
|
|
20
|
+
exports.formatCustomFieldDetail = formatCustomFieldDetail;
|
|
21
|
+
exports.formatCustomFieldSuccess = formatCustomFieldSuccess;
|
|
22
|
+
exports.formatRecurringTaskList = formatRecurringTaskList;
|
|
23
|
+
exports.formatRecurringTaskDetail = formatRecurringTaskDetail;
|
|
24
|
+
exports.formatScheduleList = formatScheduleList;
|
|
25
|
+
exports.formatStatusList = formatStatusList;
|
|
26
|
+
const errorHandling_1 = require("./errorHandling");
|
|
27
|
+
const constants_1 = require("./constants");
|
|
28
|
+
/**
|
|
29
|
+
* Format a list of items for MCP response
|
|
30
|
+
*/
|
|
31
|
+
function formatListResponse(items, title, formatter) {
|
|
32
|
+
if (!Array.isArray(items)) {
|
|
33
|
+
throw new Error('Items must be an array');
|
|
34
|
+
}
|
|
35
|
+
const list = items.map(formatter).join('\n');
|
|
36
|
+
const responseText = `${title}:\n${list}`;
|
|
37
|
+
return (0, errorHandling_1.formatMcpSuccess)(responseText);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Format project list response with workspace context
|
|
41
|
+
*/
|
|
42
|
+
function formatProjectList(projects, workspaceName, workspaceId = null, options = {}) {
|
|
43
|
+
const { includeWorkspaceNote = false, showIds = true } = options;
|
|
44
|
+
const projectFormatter = (project) => {
|
|
45
|
+
if (showIds) {
|
|
46
|
+
// For cross-workspace listings, show workspace info too
|
|
47
|
+
if (workspaceName === 'All Workspaces' && project.workspaceId) {
|
|
48
|
+
return `- ${project.name} (ID: ${project.id}) [Workspace: ${project.workspaceId}]`;
|
|
49
|
+
}
|
|
50
|
+
return `- ${project.name} (ID: ${project.id})`;
|
|
51
|
+
}
|
|
52
|
+
return `- ${project.name}`;
|
|
53
|
+
};
|
|
54
|
+
let responseText = `Found ${projects.length} ${projects.length === 1 ? 'project' : 'projects'} in workspace "${workspaceName}"`;
|
|
55
|
+
if (workspaceId) {
|
|
56
|
+
responseText += ` (ID: ${workspaceId})`;
|
|
57
|
+
}
|
|
58
|
+
if (projects.length > 0) {
|
|
59
|
+
const projectList = projects.map(projectFormatter).join('\n');
|
|
60
|
+
responseText += `:\n${projectList}`;
|
|
61
|
+
}
|
|
62
|
+
if (includeWorkspaceNote && !workspaceId) {
|
|
63
|
+
responseText += `\n\nNote: This shows projects from the default workspace. You can specify a different workspace using the workspaceId or workspaceName parameter, or use motion_workspaces (operation: list) to see all available workspaces.`;
|
|
64
|
+
}
|
|
65
|
+
return (0, errorHandling_1.formatMcpSuccess)(responseText);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Format task list response
|
|
69
|
+
*/
|
|
70
|
+
function formatTaskList(tasks, context = {}) {
|
|
71
|
+
const { workspaceName, projectName, status, limit, allWorkspaces } = context;
|
|
72
|
+
const taskFormatter = (task) => {
|
|
73
|
+
let line = `- ${task.name}`;
|
|
74
|
+
if (task.id)
|
|
75
|
+
line += ` (ID: ${task.id})`;
|
|
76
|
+
if (task.status)
|
|
77
|
+
line += ` [${typeof task.status === 'string' ? task.status : task.status.name}]`;
|
|
78
|
+
if (task.priority)
|
|
79
|
+
line += ` {${task.priority}}`;
|
|
80
|
+
if (task.dueDate) {
|
|
81
|
+
const dueDate = new Date(task.dueDate).toLocaleDateString();
|
|
82
|
+
line += ` (Due: ${dueDate})`;
|
|
83
|
+
}
|
|
84
|
+
return line;
|
|
85
|
+
};
|
|
86
|
+
let title = `Found ${tasks.length} ${tasks.length === 1 ? 'task' : 'tasks'}`;
|
|
87
|
+
if (allWorkspaces) {
|
|
88
|
+
title += ` across all workspaces`;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
if (workspaceName)
|
|
92
|
+
title += ` in workspace "${workspaceName}"`;
|
|
93
|
+
}
|
|
94
|
+
if (projectName)
|
|
95
|
+
title += ` in project "${projectName}"`;
|
|
96
|
+
if (status)
|
|
97
|
+
title += ` with status "${status}"`;
|
|
98
|
+
if (limit)
|
|
99
|
+
title += ` (limit: ${limit})`;
|
|
100
|
+
return formatListResponse(tasks, title, taskFormatter);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Format workspace list response
|
|
104
|
+
*/
|
|
105
|
+
function formatWorkspaceList(workspaces) {
|
|
106
|
+
const workspaceFormatter = (workspace) => {
|
|
107
|
+
let line = `- ${workspace.name} (ID: ${workspace.id})`;
|
|
108
|
+
if (workspace.type)
|
|
109
|
+
line += ` [${workspace.type}]`;
|
|
110
|
+
return line;
|
|
111
|
+
};
|
|
112
|
+
return formatListResponse(workspaces, `Available workspaces (${workspaces.length})`, workspaceFormatter);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Format detailed item response (project, task, etc.)
|
|
116
|
+
*/
|
|
117
|
+
function formatDetailResponse(item, itemType, fields = []) {
|
|
118
|
+
let responseText = `${itemType} Details:\n`;
|
|
119
|
+
fields.forEach(field => {
|
|
120
|
+
const value = item[field];
|
|
121
|
+
const fieldStr = String(field);
|
|
122
|
+
const displayName = fieldStr.charAt(0).toUpperCase() + fieldStr.slice(1);
|
|
123
|
+
const displayValue = value ?? 'N/A';
|
|
124
|
+
responseText += `- ${displayName}: ${displayValue}\n`;
|
|
125
|
+
});
|
|
126
|
+
return (0, errorHandling_1.formatMcpSuccess)(responseText);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Format single task detail response with comprehensive information
|
|
130
|
+
*/
|
|
131
|
+
function formatTaskDetail(task) {
|
|
132
|
+
const details = [
|
|
133
|
+
`Task: ${task.name}`,
|
|
134
|
+
`ID: ${task.id}`,
|
|
135
|
+
task.description ? `Description: ${task.description}` : null,
|
|
136
|
+
`Status: ${typeof task.status === 'string' ? task.status : task.status?.name || 'Unknown'}`,
|
|
137
|
+
`Priority: ${task.priority || 'Not set'}`,
|
|
138
|
+
`Completed: ${task.completed ? 'Yes' : 'No'}`,
|
|
139
|
+
task.dueDate ? `Due Date: ${new Date(task.dueDate).toLocaleString()}` : 'Due Date: Not set',
|
|
140
|
+
task.createdTime ? `Created: ${new Date(task.createdTime).toLocaleString()}` : null,
|
|
141
|
+
task.updatedTime ? `Last Updated: ${new Date(task.updatedTime).toLocaleString()}` : null,
|
|
142
|
+
task.completedTime ? `Completed: ${new Date(task.completedTime).toLocaleString()}` : null,
|
|
143
|
+
`Workspace: ${task.workspace?.name || 'Unknown'} (${task.workspace?.id || 'N/A'})`,
|
|
144
|
+
task.project ? `Project: ${task.project.name} (${task.project.id})` : 'Project: No project assigned',
|
|
145
|
+
task.assignees && task.assignees.length > 0
|
|
146
|
+
? `Assignees: ${task.assignees.map(a => `${a.name} (${a.email})`).join(', ')}`
|
|
147
|
+
: 'Assignees: None',
|
|
148
|
+
task.creator ? `Creator: ${task.creator.name} (${task.creator.email})` : null,
|
|
149
|
+
(task.labels && task.labels.length > 0)
|
|
150
|
+
? `Labels: ${task.labels.map(l => typeof l === 'string' ? l : l.name).join(', ')}`
|
|
151
|
+
: null,
|
|
152
|
+
task.duration ? `Duration: ${typeof task.duration === 'number' ? `${task.duration} minutes` : task.duration}` : null,
|
|
153
|
+
task.deadlineType ? `Deadline Type: ${task.deadlineType}` : null,
|
|
154
|
+
task.scheduledStart ? `Scheduled Start: ${new Date(task.scheduledStart).toLocaleString()}` : null,
|
|
155
|
+
task.scheduledEnd ? `Scheduled End: ${new Date(task.scheduledEnd).toLocaleString()}` : null,
|
|
156
|
+
task.parentRecurringTaskId ? `Recurring Task ID: ${task.parentRecurringTaskId}` : null,
|
|
157
|
+
task.chunks && task.chunks.length > 0
|
|
158
|
+
? `Scheduled Chunks: ${task.chunks.length} time block(s)`
|
|
159
|
+
: null
|
|
160
|
+
].filter(Boolean).join('\n');
|
|
161
|
+
return (0, errorHandling_1.formatMcpSuccess)(details);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Format search results response
|
|
165
|
+
*/
|
|
166
|
+
function formatSearchResults(results, query, options = {}) {
|
|
167
|
+
const { limit, searchScope } = options;
|
|
168
|
+
const resultFormatter = (result) => {
|
|
169
|
+
const type = result.projectId ? "task" : "project";
|
|
170
|
+
return `- [${type}] ${result.name} (ID: ${result.id})`;
|
|
171
|
+
};
|
|
172
|
+
let title = `Search Results for "${query}"`;
|
|
173
|
+
if (limit)
|
|
174
|
+
title += ` (Limit: ${limit})`;
|
|
175
|
+
if (searchScope)
|
|
176
|
+
title += ` (Scope: ${searchScope})`;
|
|
177
|
+
return formatListResponse(results, title, resultFormatter);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Format comments list response
|
|
181
|
+
*/
|
|
182
|
+
function formatCommentList(comments) {
|
|
183
|
+
if (comments.length === 0) {
|
|
184
|
+
return (0, errorHandling_1.formatMcpSuccess)("No comments found.");
|
|
185
|
+
}
|
|
186
|
+
const commentFormatter = (comment) => {
|
|
187
|
+
const location = `Task ${comment.taskId}`;
|
|
188
|
+
const timestamp = comment.createdAt;
|
|
189
|
+
const author = comment.creator.name || comment.creator.email || comment.creator.id;
|
|
190
|
+
// Truncate long comments for display
|
|
191
|
+
const displayContent = comment.content.length > constants_1.LIMITS.COMMENT_DISPLAY_LENGTH
|
|
192
|
+
? comment.content.substring(0, constants_1.LIMITS.COMMENT_DISPLAY_LENGTH) + '...'
|
|
193
|
+
: comment.content;
|
|
194
|
+
// Keep as single line for proper list formatting
|
|
195
|
+
return `- [${comment.id}] ${location} | Author: ${author} | ${timestamp} | "${displayContent}"`;
|
|
196
|
+
};
|
|
197
|
+
return formatListResponse(comments, `Found ${comments.length} comment${comments.length === 1 ? '' : 's'}`, commentFormatter);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Format single comment response
|
|
201
|
+
*/
|
|
202
|
+
function formatCommentDetail(comment) {
|
|
203
|
+
const location = `Task ${comment.taskId}`;
|
|
204
|
+
const timestamp = comment.createdAt;
|
|
205
|
+
const author = comment.creator.name || comment.creator.email || comment.creator.id;
|
|
206
|
+
const details = [
|
|
207
|
+
`Comment created successfully:`,
|
|
208
|
+
`- ID: ${comment.id}`,
|
|
209
|
+
`- Location: ${location}`,
|
|
210
|
+
`- Author: ${author}`,
|
|
211
|
+
`- Created: ${timestamp}`,
|
|
212
|
+
`- Content: "${comment.content}"`
|
|
213
|
+
].join('\n');
|
|
214
|
+
return (0, errorHandling_1.formatMcpSuccess)(details);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Format custom field list response
|
|
218
|
+
*/
|
|
219
|
+
function formatCustomFieldList(fields) {
|
|
220
|
+
if (fields.length === 0) {
|
|
221
|
+
return (0, errorHandling_1.formatMcpSuccess)("No custom fields found.");
|
|
222
|
+
}
|
|
223
|
+
const fieldFormatter = (field) => {
|
|
224
|
+
return `- ID: ${field.id} [Type: ${field.field}]`;
|
|
225
|
+
};
|
|
226
|
+
return formatListResponse(fields, `Found ${fields.length} custom field${fields.length === 1 ? '' : 's'}`, fieldFormatter);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Format single custom field response
|
|
230
|
+
*/
|
|
231
|
+
function formatCustomFieldDetail(field) {
|
|
232
|
+
const details = [
|
|
233
|
+
`Custom field created successfully:`,
|
|
234
|
+
`- ID: ${field.id}`,
|
|
235
|
+
`- Type: ${field.field}`
|
|
236
|
+
].join('\n');
|
|
237
|
+
return (0, errorHandling_1.formatMcpSuccess)(details);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Format success message for custom field operations
|
|
241
|
+
*/
|
|
242
|
+
function formatCustomFieldSuccess(operation, entityType, entityId) {
|
|
243
|
+
let message = `Custom field ${operation} successfully`;
|
|
244
|
+
if (entityType && entityId) {
|
|
245
|
+
message += ` for ${entityType} ${entityId}`;
|
|
246
|
+
}
|
|
247
|
+
return (0, errorHandling_1.formatMcpSuccess)(message);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Format recurring task list response
|
|
251
|
+
*/
|
|
252
|
+
function formatRecurringTaskList(tasks) {
|
|
253
|
+
if (tasks.length === 0) {
|
|
254
|
+
return (0, errorHandling_1.formatMcpSuccess)("No recurring tasks found.");
|
|
255
|
+
}
|
|
256
|
+
const taskFormatter = (task) => {
|
|
257
|
+
const projectName = task.project?.name ?? 'No Project';
|
|
258
|
+
return `- ${task.name} (ID: ${task.id}) [${task.priority}] (Project: ${projectName})`;
|
|
259
|
+
};
|
|
260
|
+
return formatListResponse(tasks, `Found ${tasks.length} recurring task${tasks.length === 1 ? '' : 's'}`, taskFormatter);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Format single recurring task response
|
|
264
|
+
*/
|
|
265
|
+
function formatRecurringTaskDetail(task) {
|
|
266
|
+
const details = [
|
|
267
|
+
`Recurring task created successfully:`,
|
|
268
|
+
`- ID: ${task.id}`,
|
|
269
|
+
`- Name: ${task.name}`,
|
|
270
|
+
`- Priority: ${task.priority}`,
|
|
271
|
+
`- Creator: ${task.creator.name} (${task.creator.email})`,
|
|
272
|
+
`- Workspace: ${task.workspace.name} (${task.workspace.id})`,
|
|
273
|
+
task.project ? `- Project: ${task.project.name} (${task.project.id})` : `- Project: No project assigned`,
|
|
274
|
+
task.assignee ? `- Assignee: ${task.assignee.name} (${task.assignee.email})` : null,
|
|
275
|
+
`- Status: ${typeof task.status === 'string' ? task.status : task.status?.name || 'Unknown'}`,
|
|
276
|
+
(task.labels && task.labels.length > 0) ? `- Labels: ${task.labels.map(l => typeof l === 'string' ? l : l.name).join(', ')}` : null
|
|
277
|
+
].filter(Boolean).join('\n');
|
|
278
|
+
return (0, errorHandling_1.formatMcpSuccess)(details);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Format schedule list response
|
|
282
|
+
*/
|
|
283
|
+
function formatScheduleList(schedules) {
|
|
284
|
+
// Add null safety check for the array itself
|
|
285
|
+
if (!schedules || !Array.isArray(schedules) || schedules.length === 0) {
|
|
286
|
+
return (0, errorHandling_1.formatMcpSuccess)("No schedules found.");
|
|
287
|
+
}
|
|
288
|
+
const scheduleFormatter = (schedule) => {
|
|
289
|
+
// Defensive programming for nested schedule object
|
|
290
|
+
if (!schedule) {
|
|
291
|
+
return '- Invalid schedule entry';
|
|
292
|
+
}
|
|
293
|
+
const name = schedule.name || 'Unnamed';
|
|
294
|
+
const timezone = schedule.timezone || 'Unknown timezone';
|
|
295
|
+
// Count working days if schedule details are available
|
|
296
|
+
let workingDays = '';
|
|
297
|
+
if (schedule.schedule && typeof schedule.schedule === 'object') {
|
|
298
|
+
const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
|
299
|
+
const activeDays = days.filter(day => Array.isArray(schedule.schedule[day]) &&
|
|
300
|
+
schedule.schedule[day].length > 0);
|
|
301
|
+
workingDays = activeDays.length > 0
|
|
302
|
+
? ` | Working days: ${activeDays.length}/7`
|
|
303
|
+
: ' | No working hours defined';
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
workingDays = ' | Schedule details unavailable';
|
|
307
|
+
}
|
|
308
|
+
return `- ${name} (${timezone})${workingDays}`;
|
|
309
|
+
};
|
|
310
|
+
return formatListResponse(schedules, `Found ${schedules.length} schedule${schedules.length === 1 ? '' : 's'}`, scheduleFormatter);
|
|
311
|
+
}
|
|
312
|
+
function formatStatusList(statuses) {
|
|
313
|
+
const statusFormatter = (status) => {
|
|
314
|
+
// Defensive programming for status object
|
|
315
|
+
if (!status) {
|
|
316
|
+
return '- Invalid status entry';
|
|
317
|
+
}
|
|
318
|
+
const name = status.name || 'Unnamed';
|
|
319
|
+
const flags = [];
|
|
320
|
+
if (status.isDefaultStatus) {
|
|
321
|
+
flags.push('Default');
|
|
322
|
+
}
|
|
323
|
+
if (status.isResolvedStatus) {
|
|
324
|
+
flags.push('Resolved');
|
|
325
|
+
}
|
|
326
|
+
const flagsStr = flags.length > 0 ? ` [${flags.join(', ')}]` : '';
|
|
327
|
+
return `- ${name}${flagsStr}`;
|
|
328
|
+
};
|
|
329
|
+
return formatListResponse(statuses, `Found ${statuses.length} status${statuses.length === 1 ? '' : 'es'}`, statusFormatter);
|
|
330
|
+
}
|
|
331
|
+
//# sourceMappingURL=responseFormatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseFormatters.js","sourceRoot":"","sources":["../../src/utils/responseFormatters.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAUH,gDAaC;AAUD,8CAkCC;AAaD,wCA6BC;AAKD,kDAQC;AAKD,oDAgBC;AAKD,4CAgCC;AAgBD,kDAiBC;AAKD,8CAsBC;AAKD,kDAeC;AAKD,sDAUC;AAKD,0DAQC;AAKD,4DAMC;AAKD,0DAWC;AAKD,8DAeC;AAKD,gDAkCC;AAED,4CAuBC;AA7YD,mDAAmD;AAGnD,2CAAqC;AAErC;;GAEG;AACH,SAAgB,kBAAkB,CAChC,KAAU,EACV,KAAa,EACb,SAA8B;IAE9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,GAAG,KAAK,MAAM,IAAI,EAAE,CAAC;I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B,EAAU,EAAE;QACvD,0CAA0C;QAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,wBAAwB,CAAC;QAClC,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,SAAS,CAAC;QACtC,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC;QACD,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC5B,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzB,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAElE,OAAO,KAAK,IAAI,GAAG,QAAQ,EAAE,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO,kBAAkB,CAAC,QAAQ,EAAE,SAAS,QAAQ,CAAC,MAAM,UAAU,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,eAAe,CAAC,CAAC;AAC9H,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Motion API Response Wrapper Utility
|
|
3
|
+
*
|
|
4
|
+
* Handles the inconsistent response patterns across Motion API endpoints:
|
|
5
|
+
* - Some return wrapped responses: { meta: {...}, [resource]: [...] }
|
|
6
|
+
* - Others return direct arrays: [...]
|
|
7
|
+
*
|
|
8
|
+
* This utility provides type-safe unwrapping with proper pagination support.
|
|
9
|
+
*/
|
|
10
|
+
import { MotionPaginationMeta } from '../types/motion';
|
|
11
|
+
/**
|
|
12
|
+
* Standard unwrapped response structure for consistent internal handling
|
|
13
|
+
*/
|
|
14
|
+
export interface UnwrappedResponse<T> {
|
|
15
|
+
data: T[];
|
|
16
|
+
meta?: MotionPaginationMeta;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Unwraps a Motion API response based on the known patterns
|
|
20
|
+
*
|
|
21
|
+
* @param response - The raw API response data
|
|
22
|
+
* @param apiEndpoint - The API endpoint name (e.g., 'tasks', 'projects', 'comments')
|
|
23
|
+
* @returns Standardized unwrapped response with data array and optional meta
|
|
24
|
+
*/
|
|
25
|
+
export declare function unwrapApiResponse<T = unknown>(response: unknown, apiEndpoint: string): UnwrappedResponse<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if an API endpoint supports pagination based on known patterns
|
|
28
|
+
*/
|
|
29
|
+
export declare function supportsPagination(apiEndpoint: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the expected resource key for a wrapped API response
|
|
32
|
+
*/
|
|
33
|
+
export declare function getResourceKey(apiEndpoint: string): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Updates the known pattern for an API endpoint (for runtime discovery)
|
|
36
|
+
*/
|
|
37
|
+
export declare function updateApiPattern(apiEndpoint: string, isWrapped: boolean, resourceKey?: string): void;
|
|
38
|
+
//# sourceMappingURL=responseWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseWrapper.d.ts","sourceRoot":"","sources":["../../src/utils/responseWrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAIvD;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AA6DD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAC3C,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,MAAM,GAClB,iBAAiB,CAAC,CAAC,CAAC,CAiBtB;AAyGD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGtE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,OAAO,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,IAAI,CAYN"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Motion API Response Wrapper Utility
|
|
4
|
+
*
|
|
5
|
+
* Handles the inconsistent response patterns across Motion API endpoints:
|
|
6
|
+
* - Some return wrapped responses: { meta: {...}, [resource]: [...] }
|
|
7
|
+
* - Others return direct arrays: [...]
|
|
8
|
+
*
|
|
9
|
+
* This utility provides type-safe unwrapping with proper pagination support.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.unwrapApiResponse = unwrapApiResponse;
|
|
13
|
+
exports.supportsPagination = supportsPagination;
|
|
14
|
+
exports.getResourceKey = getResourceKey;
|
|
15
|
+
exports.updateApiPattern = updateApiPattern;
|
|
16
|
+
const logger_1 = require("./logger");
|
|
17
|
+
const constants_1 = require("./constants");
|
|
18
|
+
/**
|
|
19
|
+
* Known API response patterns based on current codebase evidence and task documentation
|
|
20
|
+
*/
|
|
21
|
+
const API_RESPONSE_PATTERNS = {
|
|
22
|
+
// Wrapped responses (with meta pagination)
|
|
23
|
+
tasks: {
|
|
24
|
+
isWrapped: true,
|
|
25
|
+
resourceKey: 'tasks',
|
|
26
|
+
apiName: 'Tasks'
|
|
27
|
+
},
|
|
28
|
+
projects: {
|
|
29
|
+
isWrapped: true,
|
|
30
|
+
resourceKey: 'projects',
|
|
31
|
+
apiName: 'Projects'
|
|
32
|
+
},
|
|
33
|
+
comments: {
|
|
34
|
+
isWrapped: true,
|
|
35
|
+
resourceKey: 'comments',
|
|
36
|
+
apiName: 'Comments'
|
|
37
|
+
},
|
|
38
|
+
'recurring-tasks': {
|
|
39
|
+
isWrapped: true,
|
|
40
|
+
resourceKey: 'tasks', // Note: recurring tasks API returns { meta, tasks } not { meta, recurringTasks }
|
|
41
|
+
apiName: 'Recurring Tasks'
|
|
42
|
+
},
|
|
43
|
+
'custom-fields': {
|
|
44
|
+
isWrapped: true,
|
|
45
|
+
resourceKey: 'customFields',
|
|
46
|
+
apiName: 'Custom Fields'
|
|
47
|
+
},
|
|
48
|
+
// Direct array responses (no wrapper)
|
|
49
|
+
schedules: {
|
|
50
|
+
isWrapped: false,
|
|
51
|
+
apiName: 'Schedules'
|
|
52
|
+
},
|
|
53
|
+
statuses: {
|
|
54
|
+
isWrapped: false,
|
|
55
|
+
apiName: 'Statuses'
|
|
56
|
+
},
|
|
57
|
+
workspaces: {
|
|
58
|
+
isWrapped: false,
|
|
59
|
+
apiName: 'Workspaces'
|
|
60
|
+
},
|
|
61
|
+
users: {
|
|
62
|
+
isWrapped: false, // TODO: Verify this - may be wrapped with 'users' key
|
|
63
|
+
apiName: 'Users'
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Unwraps a Motion API response based on the known patterns
|
|
68
|
+
*
|
|
69
|
+
* @param response - The raw API response data
|
|
70
|
+
* @param apiEndpoint - The API endpoint name (e.g., 'tasks', 'projects', 'comments')
|
|
71
|
+
* @returns Standardized unwrapped response with data array and optional meta
|
|
72
|
+
*/
|
|
73
|
+
function unwrapApiResponse(response, apiEndpoint) {
|
|
74
|
+
const config = API_RESPONSE_PATTERNS[apiEndpoint];
|
|
75
|
+
if (!config) {
|
|
76
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.WARN, `Unknown API endpoint pattern: ${apiEndpoint}`, {
|
|
77
|
+
endpoint: apiEndpoint,
|
|
78
|
+
availablePatterns: Object.keys(API_RESPONSE_PATTERNS)
|
|
79
|
+
});
|
|
80
|
+
// Fallback: try to extract array from common patterns
|
|
81
|
+
return fallbackUnwrap(response, apiEndpoint);
|
|
82
|
+
}
|
|
83
|
+
if (config.isWrapped) {
|
|
84
|
+
return unwrapWrappedResponse(response, config);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return unwrapDirectResponse(response, config);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Unwraps a wrapped response: { meta: {...}, [resourceKey]: [...] }
|
|
92
|
+
*/
|
|
93
|
+
function unwrapWrappedResponse(response, config) {
|
|
94
|
+
if (!response || typeof response !== 'object') {
|
|
95
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.WARN, `Expected wrapped response object for ${config.apiName}`, {
|
|
96
|
+
receivedType: typeof response,
|
|
97
|
+
response
|
|
98
|
+
});
|
|
99
|
+
return { data: [] };
|
|
100
|
+
}
|
|
101
|
+
const responseObj = response;
|
|
102
|
+
const resourceKey = config.resourceKey;
|
|
103
|
+
const data = responseObj[resourceKey];
|
|
104
|
+
const meta = responseObj.meta;
|
|
105
|
+
if (!Array.isArray(data)) {
|
|
106
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.WARN, `Expected array for ${resourceKey} in ${config.apiName} response`, {
|
|
107
|
+
resourceKey,
|
|
108
|
+
receivedType: typeof data,
|
|
109
|
+
hasMetaField: !!meta,
|
|
110
|
+
responseKeys: Object.keys(responseObj)
|
|
111
|
+
});
|
|
112
|
+
return { data: [] };
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
data,
|
|
116
|
+
meta: meta && typeof meta === 'object' ? meta : undefined
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Unwraps a direct array response: [...]
|
|
121
|
+
*/
|
|
122
|
+
function unwrapDirectResponse(response, config) {
|
|
123
|
+
if (!Array.isArray(response)) {
|
|
124
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.WARN, `Expected direct array response for ${config.apiName}`, {
|
|
125
|
+
receivedType: typeof response,
|
|
126
|
+
response
|
|
127
|
+
});
|
|
128
|
+
return { data: [] };
|
|
129
|
+
}
|
|
130
|
+
return { data: response };
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Fallback unwrapping logic for unknown endpoints
|
|
134
|
+
* Attempts to handle both wrapped and direct patterns
|
|
135
|
+
*/
|
|
136
|
+
function fallbackUnwrap(response, apiEndpoint) {
|
|
137
|
+
// Case 1: Direct array
|
|
138
|
+
if (Array.isArray(response)) {
|
|
139
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, `Fallback: treating ${apiEndpoint} as direct array`, {
|
|
140
|
+
itemCount: response.length
|
|
141
|
+
});
|
|
142
|
+
return { data: response };
|
|
143
|
+
}
|
|
144
|
+
// Case 2: Wrapped response - try common resource keys
|
|
145
|
+
if (response && typeof response === 'object') {
|
|
146
|
+
const responseObj = response;
|
|
147
|
+
const possibleKeys = ['items', 'tasks', 'projects', 'comments', 'users', 'workspaces', 'schedules', 'statuses', 'customFields'];
|
|
148
|
+
for (const key of possibleKeys) {
|
|
149
|
+
if (Array.isArray(responseObj[key])) {
|
|
150
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, `Fallback: found array at ${key} for ${apiEndpoint}`, {
|
|
151
|
+
key,
|
|
152
|
+
itemCount: responseObj[key].length,
|
|
153
|
+
hasMeta: !!responseObj.meta
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
data: responseObj[key],
|
|
157
|
+
meta: responseObj.meta
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.WARN, `Fallback: no array found in object response for ${apiEndpoint}`, {
|
|
162
|
+
responseKeys: Object.keys(responseObj)
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// Case 3: Unexpected response
|
|
166
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.ERROR, `Fallback: unexpected response format for ${apiEndpoint}`, {
|
|
167
|
+
responseType: typeof response,
|
|
168
|
+
response
|
|
169
|
+
});
|
|
170
|
+
return { data: [] };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Checks if an API endpoint supports pagination based on known patterns
|
|
174
|
+
*/
|
|
175
|
+
function supportsPagination(apiEndpoint) {
|
|
176
|
+
const config = API_RESPONSE_PATTERNS[apiEndpoint];
|
|
177
|
+
return config?.isWrapped || false;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Gets the expected resource key for a wrapped API response
|
|
181
|
+
*/
|
|
182
|
+
function getResourceKey(apiEndpoint) {
|
|
183
|
+
const config = API_RESPONSE_PATTERNS[apiEndpoint];
|
|
184
|
+
return config?.resourceKey;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Updates the known pattern for an API endpoint (for runtime discovery)
|
|
188
|
+
*/
|
|
189
|
+
function updateApiPattern(apiEndpoint, isWrapped, resourceKey) {
|
|
190
|
+
API_RESPONSE_PATTERNS[apiEndpoint] = {
|
|
191
|
+
isWrapped,
|
|
192
|
+
resourceKey,
|
|
193
|
+
apiName: apiEndpoint
|
|
194
|
+
};
|
|
195
|
+
(0, logger_1.mcpLog)(constants_1.LOG_LEVELS.INFO, `Updated API pattern for ${apiEndpoint}`, {
|
|
196
|
+
endpoint: apiEndpoint,
|
|
197
|
+
isWrapped,
|
|
198
|
+
resourceKey
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=responseWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseWrapper.js","sourceRoot":"","sources":["../../src/utils/responseWrapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAgFH,8CAoBC;AA4GD,gDAGC;AAKD,wCAGC;AAKD,4CAgBC;AA7OD,qCAAkC;AAClC,2CAAyC;AAm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2B,WAAW,EAAE,EAAE;QAChE,QAAQ,EAAE,WAAW;QACrB,SAAS;QACT,WAAW;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Sanitization Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides secure sanitization functions for user-provided content
|
|
5
|
+
* to prevent injection attacks and ensure data integrity.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Sanitize user-provided text content for safe storage and transmission
|
|
9
|
+
* Removes dangerous HTML tags, script content, and other potentially harmful input
|
|
10
|
+
*
|
|
11
|
+
* @param input - The user input to sanitize
|
|
12
|
+
* @returns Sanitized string safe for storage/transmission
|
|
13
|
+
*/
|
|
14
|
+
export declare function sanitizeTextContent(input: string | undefined | null): string;
|
|
15
|
+
/**
|
|
16
|
+
* Validate that sanitized content is not empty after sanitization
|
|
17
|
+
*
|
|
18
|
+
* @param original - Original user input
|
|
19
|
+
* @param sanitized - Sanitized version
|
|
20
|
+
* @returns True if content is valid after sanitization
|
|
21
|
+
*/
|
|
22
|
+
export declare function isValidSanitizedContent(original: string | undefined | null, sanitized: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Sanitize and validate comment content
|
|
25
|
+
*
|
|
26
|
+
* @param content - Comment content to sanitize
|
|
27
|
+
* @returns Object with sanitized content and validation result
|
|
28
|
+
*/
|
|
29
|
+
export declare function sanitizeCommentContent(content: string | undefined | null): {
|
|
30
|
+
sanitized: string;
|
|
31
|
+
isValid: boolean;
|
|
32
|
+
error?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Sanitize task/project description content
|
|
36
|
+
* Similar to comment content but allows empty descriptions
|
|
37
|
+
*
|
|
38
|
+
* @param description - Task or project description to sanitize
|
|
39
|
+
* @returns Sanitized description or undefined if empty/invalid
|
|
40
|
+
*/
|
|
41
|
+
export declare function sanitizeDescription(description: string | undefined | null): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Sanitize task/project name content
|
|
44
|
+
* Names are required and must be non-empty after sanitization
|
|
45
|
+
*
|
|
46
|
+
* @param name - Task or project name to sanitize
|
|
47
|
+
* @returns Sanitized name
|
|
48
|
+
* @throws Error if name is empty or contains invalid content
|
|
49
|
+
*/
|
|
50
|
+
export declare function sanitizeName(name: string | undefined | null): string;
|
|
51
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAiC5E;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAQvG;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAwBA;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAgB9F;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAgBpE"}
|