@taazkareem/clickup-mcp-server 0.8.5 → 0.9.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.
@@ -7,12 +7,20 @@
7
7
  * Handles comment operations for ClickUp tasks, including:
8
8
  * - Retrieving comments for a task
9
9
  * - Creating comments on a task
10
+ *
11
+ * REFACTORED: Now uses composition instead of inheritance.
12
+ * Only depends on TaskServiceCore for base functionality.
10
13
  */
11
- import { TaskServiceAttachments } from './task-attachments.js';
12
14
  /**
13
15
  * Comments functionality for the TaskService
16
+ *
17
+ * This service handles all comment-related operations for ClickUp tasks.
18
+ * It uses composition to access core functionality instead of inheritance.
14
19
  */
15
- export class TaskServiceComments extends TaskServiceAttachments {
20
+ export class TaskServiceComments {
21
+ constructor(core) {
22
+ this.core = core;
23
+ }
16
24
  /**
17
25
  * Get all comments for a task
18
26
  *
@@ -22,7 +30,7 @@ export class TaskServiceComments extends TaskServiceAttachments {
22
30
  * @returns Array of task comments
23
31
  */
24
32
  async getTaskComments(taskId, start, startId) {
25
- this.logOperation('getTaskComments', { taskId, start, startId });
33
+ this.core.logOperation('getTaskComments', { taskId, start, startId });
26
34
  try {
27
35
  // Build query parameters for pagination
28
36
  const queryParams = new URLSearchParams();
@@ -33,11 +41,13 @@ export class TaskServiceComments extends TaskServiceAttachments {
33
41
  queryParams.append('start_id', startId);
34
42
  }
35
43
  const queryString = queryParams.toString() ? `?${queryParams.toString()}` : '';
36
- const response = await this.client.get(`/task/${taskId}/comment${queryString}`);
37
- return response.data.comments || [];
44
+ return await this.core.makeRequest(async () => {
45
+ const response = await this.core.client.get(`/task/${taskId}/comment${queryString}`);
46
+ return response.data.comments || [];
47
+ });
38
48
  }
39
49
  catch (error) {
40
- throw this.handleError(error, 'Failed to get task comments');
50
+ throw this.core.handleError(error, 'Failed to get task comments');
41
51
  }
42
52
  }
43
53
  /**
@@ -50,7 +60,7 @@ export class TaskServiceComments extends TaskServiceAttachments {
50
60
  * @returns The created comment
51
61
  */
52
62
  async createTaskComment(taskId, commentText, notifyAll = false, assignee) {
53
- this.logOperation('createTaskComment', { taskId, commentText, notifyAll, assignee });
63
+ this.core.logOperation('createTaskComment', { taskId, commentText, notifyAll, assignee });
54
64
  try {
55
65
  const payload = {
56
66
  comment_text: commentText,
@@ -60,7 +70,7 @@ export class TaskServiceComments extends TaskServiceAttachments {
60
70
  payload.assignee = assignee;
61
71
  }
62
72
  // Make the request directly without using makeRequest for better error handling
63
- const response = await this.client.post(`/task/${taskId}/comment`, payload);
73
+ const response = await this.core.client.post(`/task/${taskId}/comment`, payload);
64
74
  // Handle different response formats from ClickUp API
65
75
  if (response.data) {
66
76
  if (response.data.comment) {
@@ -98,7 +108,7 @@ export class TaskServiceComments extends TaskServiceAttachments {
98
108
  resolved: false
99
109
  };
100
110
  }
101
- throw this.handleError(error, 'Failed to create task comment');
111
+ throw this.core.handleError(error, 'Failed to create task comment');
102
112
  }
103
113
  }
104
114
  }
@@ -7,12 +7,20 @@
7
7
  * Handles custom fields operations for ClickUp tasks, including:
8
8
  * - Setting custom field values
9
9
  * - Retrieving custom field values
10
+ *
11
+ * REFACTORED: Now uses composition instead of inheritance.
12
+ * Only depends on TaskServiceCore for getTask() and base functionality.
10
13
  */
11
- import { TaskServiceTags } from './task-tags.js';
12
14
  /**
13
15
  * Custom fields functionality for the TaskService
16
+ *
17
+ * This service handles all custom field operations for ClickUp tasks.
18
+ * It uses composition to access core functionality instead of inheritance.
14
19
  */
15
- export class TaskServiceCustomFields extends TaskServiceTags {
20
+ export class TaskServiceCustomFields {
21
+ constructor(core) {
22
+ this.core = core;
23
+ }
16
24
  /**
17
25
  * Set a single custom field value on a task
18
26
  *
@@ -22,16 +30,18 @@ export class TaskServiceCustomFields extends TaskServiceTags {
22
30
  * @returns Success response
23
31
  */
24
32
  async setCustomFieldValue(taskId, fieldId, value) {
25
- this.logOperation('setCustomFieldValue', { taskId, fieldId, value });
33
+ this.core.logOperation('setCustomFieldValue', { taskId, fieldId, value });
26
34
  try {
27
35
  const payload = {
28
36
  value
29
37
  };
30
- await this.client.post(`/task/${taskId}/field/${fieldId}`, payload);
38
+ await this.core.makeRequest(async () => {
39
+ return await this.core.client.post(`/task/${taskId}/field/${fieldId}`, payload);
40
+ });
31
41
  return true;
32
42
  }
33
43
  catch (error) {
34
- throw this.handleError(error, `Failed to set custom field "${fieldId}" value`);
44
+ throw this.core.handleError(error, `Failed to set custom field "${fieldId}" value`);
35
45
  }
36
46
  }
37
47
  /**
@@ -42,7 +52,7 @@ export class TaskServiceCustomFields extends TaskServiceTags {
42
52
  * @returns Success response
43
53
  */
44
54
  async setCustomFieldValues(taskId, customFields) {
45
- this.logOperation('setCustomFieldValues', { taskId, customFields });
55
+ this.core.logOperation('setCustomFieldValues', { taskId, customFields });
46
56
  try {
47
57
  // Execute each update sequentially
48
58
  for (const field of customFields) {
@@ -51,7 +61,7 @@ export class TaskServiceCustomFields extends TaskServiceTags {
51
61
  return true;
52
62
  }
53
63
  catch (error) {
54
- throw this.handleError(error, 'Failed to set custom field values');
64
+ throw this.core.handleError(error, 'Failed to set custom field values');
55
65
  }
56
66
  }
57
67
  /**
@@ -61,14 +71,14 @@ export class TaskServiceCustomFields extends TaskServiceTags {
61
71
  * @returns Record mapping field IDs to their values
62
72
  */
63
73
  async getCustomFieldValues(taskId) {
64
- this.logOperation('getCustomFieldValues', { taskId });
74
+ this.core.logOperation('getCustomFieldValues', { taskId });
65
75
  try {
66
76
  // We need to fetch the full task to get its custom fields
67
- const task = await this.getTask(taskId);
77
+ const task = await this.core.getTask(taskId);
68
78
  return task.custom_fields || {};
69
79
  }
70
80
  catch (error) {
71
- throw this.handleError(error, 'Failed to get custom field values');
81
+ throw this.core.handleError(error, 'Failed to get custom field values');
72
82
  }
73
83
  }
74
84
  /**
@@ -80,18 +90,18 @@ export class TaskServiceCustomFields extends TaskServiceTags {
80
90
  * @throws ClickUpServiceError if the field doesn't exist
81
91
  */
82
92
  async getCustomFieldValue(taskId, fieldId) {
83
- this.logOperation('getCustomFieldValue', { taskId, fieldId });
93
+ this.core.logOperation('getCustomFieldValue', { taskId, fieldId });
84
94
  try {
85
95
  const customFields = await this.getCustomFieldValues(taskId);
86
96
  if (fieldId in customFields) {
87
97
  return customFields[fieldId];
88
98
  }
89
99
  else {
90
- throw this.handleError(new Error(`Custom field "${fieldId}" not found on task`), `Custom field "${fieldId}" not found on task`);
100
+ throw this.core.handleError(new Error(`Custom field "${fieldId}" not found on task`), `Custom field "${fieldId}" not found on task`);
91
101
  }
92
102
  }
93
103
  catch (error) {
94
- throw this.handleError(error, `Failed to get custom field "${fieldId}" value`);
104
+ throw this.core.handleError(error, `Failed to get custom field "${fieldId}" value`);
95
105
  }
96
106
  }
97
107
  }