@taazkareem/clickup-mcp-server 0.4.60 → 0.4.62

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.
@@ -0,0 +1,28 @@
1
+ import { WorkspaceService } from "./workspace.js";
2
+ /**
3
+ * Service responsible for initializing the server state
4
+ * Handles preloading workspace data
5
+ */
6
+ export class InitializationService {
7
+ constructor(config) {
8
+ // Create workspace service
9
+ this.workspaceService = new WorkspaceService(config.apiKey, config.teamId, config.baseUrl);
10
+ }
11
+ /**
12
+ * Preload workspace hierarchy data on server startup
13
+ * This loads the entire workspace tree for faster initial access
14
+ */
15
+ async preloadWorkspaceData() {
16
+ try {
17
+ console.log("Preloading workspace data...");
18
+ const startTime = Date.now();
19
+ // Force refresh to get the latest data
20
+ await this.workspaceService.getWorkspaceHierarchy(true);
21
+ const duration = (Date.now() - startTime) / 1000;
22
+ console.log(`Workspace data preloaded successfully in ${duration.toFixed(2)}s`);
23
+ }
24
+ catch (error) {
25
+ console.error("Failed to preload workspace data:", error);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,188 @@
1
+ /**
2
+ * ClickUp List Service
3
+ *
4
+ * Handles all operations related to lists in ClickUp, including:
5
+ * - Creating lists
6
+ * - Retrieving lists
7
+ * - Updating lists
8
+ * - Deleting lists
9
+ * - Finding lists by name
10
+ */
11
+ import { BaseClickUpService, ErrorCode, ClickUpServiceError } from './base.js';
12
+ export class ListService extends BaseClickUpService {
13
+ constructor(apiKey, teamId, baseUrl, workspaceService) {
14
+ super(apiKey, teamId, baseUrl);
15
+ this.workspaceService = null;
16
+ this.workspaceService = workspaceService || null;
17
+ }
18
+ /**
19
+ * Helper method to handle errors consistently
20
+ * @param error The error that occurred
21
+ * @param message Optional custom error message
22
+ * @returns A ClickUpServiceError
23
+ */
24
+ handleError(error, message) {
25
+ if (error instanceof ClickUpServiceError) {
26
+ return error;
27
+ }
28
+ return new ClickUpServiceError(message || `List service error: ${error.message}`, ErrorCode.UNKNOWN, error);
29
+ }
30
+ /**
31
+ * Create a new list in a space
32
+ * @param spaceId The ID of the space to create the list in
33
+ * @param listData The data for the new list
34
+ * @returns The created list
35
+ */
36
+ async createList(spaceId, listData) {
37
+ this.logOperation('createList', { spaceId, ...listData });
38
+ try {
39
+ return await this.makeRequest(async () => {
40
+ const response = await this.client.post(`/space/${spaceId}/list`, listData);
41
+ return response.data;
42
+ });
43
+ }
44
+ catch (error) {
45
+ throw this.handleError(error, `Failed to create list in space ${spaceId}`);
46
+ }
47
+ }
48
+ /**
49
+ * Create a new list in a folder
50
+ * @param folderId The ID of the folder to create the list in
51
+ * @param listData The data for the new list
52
+ * @returns The created list
53
+ */
54
+ async createListInFolder(folderId, listData) {
55
+ this.logOperation('createListInFolder', { folderId, ...listData });
56
+ try {
57
+ return await this.makeRequest(async () => {
58
+ const response = await this.client.post(`/folder/${folderId}/list`, listData);
59
+ return response.data;
60
+ });
61
+ }
62
+ catch (error) {
63
+ throw this.handleError(error, `Failed to create list in folder ${folderId}`);
64
+ }
65
+ }
66
+ /**
67
+ * Get a list by ID
68
+ * @param listId The ID of the list to retrieve
69
+ * @returns The requested list
70
+ */
71
+ async getList(listId) {
72
+ this.logOperation('getList', { listId });
73
+ try {
74
+ return await this.makeRequest(async () => {
75
+ const response = await this.client.get(`/list/${listId}`);
76
+ return response.data;
77
+ });
78
+ }
79
+ catch (error) {
80
+ throw this.handleError(error, `Failed to get list ${listId}`);
81
+ }
82
+ }
83
+ /**
84
+ * Update an existing list
85
+ * @param listId The ID of the list to update
86
+ * @param updateData The data to update on the list
87
+ * @returns The updated list
88
+ */
89
+ async updateList(listId, updateData) {
90
+ this.logOperation('updateList', { listId, ...updateData });
91
+ try {
92
+ return await this.makeRequest(async () => {
93
+ const response = await this.client.put(`/list/${listId}`, updateData);
94
+ return response.data;
95
+ });
96
+ }
97
+ catch (error) {
98
+ throw this.handleError(error, `Failed to update list ${listId}`);
99
+ }
100
+ }
101
+ /**
102
+ * Delete a list
103
+ * @param listId The ID of the list to delete
104
+ * @returns Success indicator
105
+ */
106
+ async deleteList(listId) {
107
+ this.logOperation('deleteList', { listId });
108
+ try {
109
+ await this.makeRequest(async () => {
110
+ await this.client.delete(`/list/${listId}`);
111
+ });
112
+ return {
113
+ success: true
114
+ };
115
+ }
116
+ catch (error) {
117
+ throw this.handleError(error, `Failed to delete list ${listId}`);
118
+ }
119
+ }
120
+ /**
121
+ * Get all lists in a space
122
+ * @param spaceId The ID of the space to get lists from
123
+ * @returns Array of lists in the space
124
+ */
125
+ async getListsInSpace(spaceId) {
126
+ this.logOperation('getListsInSpace', { spaceId });
127
+ try {
128
+ return await this.makeRequest(async () => {
129
+ const response = await this.client.get(`/space/${spaceId}/list`);
130
+ return response.data.lists;
131
+ });
132
+ }
133
+ catch (error) {
134
+ throw this.handleError(error, `Failed to get lists in space ${spaceId}`);
135
+ }
136
+ }
137
+ /**
138
+ * Get all lists in a folder
139
+ * @param folderId The ID of the folder to get lists from
140
+ * @returns Array of lists in the folder
141
+ */
142
+ async getListsInFolder(folderId) {
143
+ this.logOperation('getListsInFolder', { folderId });
144
+ try {
145
+ return await this.makeRequest(async () => {
146
+ const response = await this.client.get(`/folder/${folderId}/list`);
147
+ return response.data.lists;
148
+ });
149
+ }
150
+ catch (error) {
151
+ throw this.handleError(error, `Failed to get lists in folder ${folderId}`);
152
+ }
153
+ }
154
+ /**
155
+ * Find a list by its name in a space
156
+ * @param spaceId The ID of the space to search in
157
+ * @param listName The name of the list to find
158
+ * @returns The list if found, otherwise null
159
+ */
160
+ async findListByNameInSpace(spaceId, listName) {
161
+ this.logOperation('findListByNameInSpace', { spaceId, listName });
162
+ try {
163
+ const lists = await this.getListsInSpace(spaceId);
164
+ const matchingList = lists.find(list => list.name.toLowerCase() === listName.toLowerCase());
165
+ return matchingList || null;
166
+ }
167
+ catch (error) {
168
+ throw this.handleError(error, `Failed to find list by name in space ${spaceId}`);
169
+ }
170
+ }
171
+ /**
172
+ * Find a list by its name in a folder
173
+ * @param folderId The ID of the folder to search in
174
+ * @param listName The name of the list to find
175
+ * @returns The list if found, otherwise null
176
+ */
177
+ async findListByNameInFolder(folderId, listName) {
178
+ this.logOperation('findListByNameInFolder', { folderId, listName });
179
+ try {
180
+ const lists = await this.getListsInFolder(folderId);
181
+ const matchingList = lists.find(list => list.name.toLowerCase() === listName.toLowerCase());
182
+ return matchingList || null;
183
+ }
184
+ catch (error) {
185
+ throw this.handleError(error, `Failed to find list by name in folder ${folderId}`);
186
+ }
187
+ }
188
+ }