@chykalophia/clickup-mcp-server 3.2.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 +21 -0
- package/README.md +467 -0
- package/bin/clickup-mcp-server-ai.js +9 -0
- package/bin/clickup-mcp-server-basic.js +9 -0
- package/bin/clickup-mcp-server-efficiency.js +9 -0
- package/bin/clickup-mcp-server-enhanced.js +9 -0
- package/build/app.d.ts +1 -0
- package/build/app.js +2 -0
- package/build/app.js.map +1 -0
- package/build/clickup-client/attachments-enhanced.d.ts +128 -0
- package/build/clickup-client/attachments-enhanced.js +212 -0
- package/build/clickup-client/attachments-enhanced.js.map +1 -0
- package/build/clickup-client/auth.d.ts +254 -0
- package/build/clickup-client/auth.js +105 -0
- package/build/clickup-client/auth.js.map +1 -0
- package/build/clickup-client/chat-enhanced.d.ts +141 -0
- package/build/clickup-client/chat-enhanced.js +196 -0
- package/build/clickup-client/chat-enhanced.js.map +1 -0
- package/build/clickup-client/checklists.d.ts +87 -0
- package/build/clickup-client/checklists.js +63 -0
- package/build/clickup-client/checklists.js.map +1 -0
- package/build/clickup-client/comments-enhanced.d.ts +176 -0
- package/build/clickup-client/comments-enhanced.js +230 -0
- package/build/clickup-client/comments-enhanced.js.map +1 -0
- package/build/clickup-client/comments.d.ts +173 -0
- package/build/clickup-client/comments.js +312 -0
- package/build/clickup-client/comments.js.map +1 -0
- package/build/clickup-client/custom-fields-enhanced.d.ts +286 -0
- package/build/clickup-client/custom-fields-enhanced.js +416 -0
- package/build/clickup-client/custom-fields-enhanced.js.map +1 -0
- package/build/clickup-client/dependencies-enhanced.d.ts +144 -0
- package/build/clickup-client/dependencies-enhanced.js +142 -0
- package/build/clickup-client/dependencies-enhanced.js.map +1 -0
- package/build/clickup-client/docs-enhanced.d.ts +176 -0
- package/build/clickup-client/docs-enhanced.js +374 -0
- package/build/clickup-client/docs-enhanced.js.map +1 -0
- package/build/clickup-client/docs.d.ts +84 -0
- package/build/clickup-client/docs.js +156 -0
- package/build/clickup-client/docs.js.map +1 -0
- package/build/clickup-client/folders.d.ts +62 -0
- package/build/clickup-client/folders.js +53 -0
- package/build/clickup-client/folders.js.map +1 -0
- package/build/clickup-client/goals-enhanced.d.ts +163 -0
- package/build/clickup-client/goals-enhanced.js +309 -0
- package/build/clickup-client/goals-enhanced.js.map +1 -0
- package/build/clickup-client/index.d.ts +16 -0
- package/build/clickup-client/index.js +61 -0
- package/build/clickup-client/index.js.map +1 -0
- package/build/clickup-client/lists.d.ts +105 -0
- package/build/clickup-client/lists.js +108 -0
- package/build/clickup-client/lists.js.map +1 -0
- package/build/clickup-client/secure-client.d.ts +88 -0
- package/build/clickup-client/secure-client.js +275 -0
- package/build/clickup-client/secure-client.js.map +1 -0
- package/build/clickup-client/spaces.d.ts +58 -0
- package/build/clickup-client/spaces.js +28 -0
- package/build/clickup-client/spaces.js.map +1 -0
- package/build/clickup-client/tasks.d.ts +161 -0
- package/build/clickup-client/tasks.js +99 -0
- package/build/clickup-client/tasks.js.map +1 -0
- package/build/clickup-client/time-tracking-enhanced.d.ts +153 -0
- package/build/clickup-client/time-tracking-enhanced.js +292 -0
- package/build/clickup-client/time-tracking-enhanced.js.map +1 -0
- package/build/clickup-client/views-enhanced.d.ts +149 -0
- package/build/clickup-client/views-enhanced.js +210 -0
- package/build/clickup-client/views-enhanced.js.map +1 -0
- package/build/clickup-client/webhooks-enhanced.d.ts +119 -0
- package/build/clickup-client/webhooks-enhanced.js +169 -0
- package/build/clickup-client/webhooks-enhanced.js.map +1 -0
- package/build/controllers/lists.controller.d.ts +1 -0
- package/build/controllers/lists.controller.js +2 -0
- package/build/controllers/lists.controller.js.map +1 -0
- package/build/index-efficiency-simple.d.ts +2 -0
- package/build/index-efficiency-simple.js +379 -0
- package/build/index-efficiency-simple.js.map +1 -0
- package/build/index-enhanced-efficiency.d.ts +2 -0
- package/build/index-enhanced-efficiency.js +275 -0
- package/build/index-enhanced-efficiency.js.map +1 -0
- package/build/index-enhanced.d.ts +2 -0
- package/build/index-enhanced.js +74 -0
- package/build/index-enhanced.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +77 -0
- package/build/index.js.map +1 -0
- package/build/resources/checklist-resources.d.ts +2 -0
- package/build/resources/checklist-resources.js +102 -0
- package/build/resources/checklist-resources.js.map +1 -0
- package/build/resources/comment-resources.d.ts +2 -0
- package/build/resources/comment-resources.js +152 -0
- package/build/resources/comment-resources.js.map +1 -0
- package/build/resources/doc-resources.d.ts +2 -0
- package/build/resources/doc-resources.js +77 -0
- package/build/resources/doc-resources.js.map +1 -0
- package/build/resources/folder-resources.d.ts +2 -0
- package/build/resources/folder-resources.js +160 -0
- package/build/resources/folder-resources.js.map +1 -0
- package/build/resources/list-resources.d.ts +2 -0
- package/build/resources/list-resources.js +104 -0
- package/build/resources/list-resources.js.map +1 -0
- package/build/resources/space-resources.d.ts +2 -0
- package/build/resources/space-resources.js +104 -0
- package/build/resources/space-resources.js.map +1 -0
- package/build/resources/task-resources.d.ts +2 -0
- package/build/resources/task-resources.js +57 -0
- package/build/resources/task-resources.js.map +1 -0
- package/build/routes/lists.routes.d.ts +1 -0
- package/build/routes/lists.routes.js +2 -0
- package/build/routes/lists.routes.js.map +1 -0
- package/build/schemas/attachments-schemas.d.ts +201 -0
- package/build/schemas/attachments-schemas.js +250 -0
- package/build/schemas/attachments-schemas.js.map +1 -0
- package/build/schemas/chat-schemas.d.ts +478 -0
- package/build/schemas/chat-schemas.js +173 -0
- package/build/schemas/chat-schemas.js.map +1 -0
- package/build/schemas/custom-field-schemas.d.ts +1617 -0
- package/build/schemas/custom-field-schemas.js +384 -0
- package/build/schemas/custom-field-schemas.js.map +1 -0
- package/build/schemas/dependencies-schemas.d.ts +274 -0
- package/build/schemas/dependencies-schemas.js +176 -0
- package/build/schemas/dependencies-schemas.js.map +1 -0
- package/build/schemas/document-schemas.d.ts +433 -0
- package/build/schemas/document-schemas.js +168 -0
- package/build/schemas/document-schemas.js.map +1 -0
- package/build/schemas/goals-schemas.d.ts +961 -0
- package/build/schemas/goals-schemas.js +293 -0
- package/build/schemas/goals-schemas.js.map +1 -0
- package/build/schemas/time-tracking-schemas.d.ts +741 -0
- package/build/schemas/time-tracking-schemas.js +234 -0
- package/build/schemas/time-tracking-schemas.js.map +1 -0
- package/build/schemas/views-schemas.d.ts +1168 -0
- package/build/schemas/views-schemas.js +221 -0
- package/build/schemas/views-schemas.js.map +1 -0
- package/build/schemas/webhook-schemas.d.ts +1127 -0
- package/build/schemas/webhook-schemas.js +137 -0
- package/build/schemas/webhook-schemas.js.map +1 -0
- package/build/services/lists.service.d.ts +1 -0
- package/build/services/lists.service.js +2 -0
- package/build/services/lists.service.js.map +1 -0
- package/build/tools/attachments-tools-setup.d.ts +2 -0
- package/build/tools/attachments-tools-setup.js +387 -0
- package/build/tools/attachments-tools-setup.js.map +1 -0
- package/build/tools/chat-tools-enhanced.d.ts +5 -0
- package/build/tools/chat-tools-enhanced.js +396 -0
- package/build/tools/chat-tools-enhanced.js.map +1 -0
- package/build/tools/chat-tools.d.ts +2 -0
- package/build/tools/chat-tools.js +614 -0
- package/build/tools/chat-tools.js.map +1 -0
- package/build/tools/checklist-tools.d.ts +2 -0
- package/build/tools/checklist-tools.js +139 -0
- package/build/tools/checklist-tools.js.map +1 -0
- package/build/tools/comment-tools.d.ts +2 -0
- package/build/tools/comment-tools.js +295 -0
- package/build/tools/comment-tools.js.map +1 -0
- package/build/tools/custom-field-tools.d.ts +2 -0
- package/build/tools/custom-field-tools.js +578 -0
- package/build/tools/custom-field-tools.js.map +1 -0
- package/build/tools/dependencies-tools-setup.d.ts +2 -0
- package/build/tools/dependencies-tools-setup.js +319 -0
- package/build/tools/dependencies-tools-setup.js.map +1 -0
- package/build/tools/doc-tools-enhanced.d.ts +2 -0
- package/build/tools/doc-tools-enhanced.js +417 -0
- package/build/tools/doc-tools-enhanced.js.map +1 -0
- package/build/tools/doc-tools.d.ts +2 -0
- package/build/tools/doc-tools.js +109 -0
- package/build/tools/doc-tools.js.map +1 -0
- package/build/tools/goals-tools.d.ts +2 -0
- package/build/tools/goals-tools.js +422 -0
- package/build/tools/goals-tools.js.map +1 -0
- package/build/tools/helper-tools.d.ts +2 -0
- package/build/tools/helper-tools.js +363 -0
- package/build/tools/helper-tools.js.map +1 -0
- package/build/tools/space-tools.d.ts +2 -0
- package/build/tools/space-tools.js +45 -0
- package/build/tools/space-tools.js.map +1 -0
- package/build/tools/task-tools.d.ts +2 -0
- package/build/tools/task-tools.js +415 -0
- package/build/tools/task-tools.js.map +1 -0
- package/build/tools/time-tracking-tools.d.ts +2 -0
- package/build/tools/time-tracking-tools.js +329 -0
- package/build/tools/time-tracking-tools.js.map +1 -0
- package/build/tools/views-tools-setup.d.ts +2 -0
- package/build/tools/views-tools-setup.js +358 -0
- package/build/tools/views-tools-setup.js.map +1 -0
- package/build/tools/webhook-tools-setup.d.ts +2 -0
- package/build/tools/webhook-tools-setup.js +304 -0
- package/build/tools/webhook-tools-setup.js.map +1 -0
- package/build/tools/webhook-tools.d.ts +4 -0
- package/build/tools/webhook-tools.js +345 -0
- package/build/tools/webhook-tools.js.map +1 -0
- package/build/utils/clickup-comment-formatter.d.ts +124 -0
- package/build/utils/clickup-comment-formatter.js +504 -0
- package/build/utils/clickup-comment-formatter.js.map +1 -0
- package/build/utils/context-aware-suggestions.d.ts +45 -0
- package/build/utils/context-aware-suggestions.js +360 -0
- package/build/utils/context-aware-suggestions.js.map +1 -0
- package/build/utils/error-handling.d.ts +140 -0
- package/build/utils/error-handling.js +392 -0
- package/build/utils/error-handling.js.map +1 -0
- package/build/utils/markdown-styling.d.ts +40 -0
- package/build/utils/markdown-styling.js +344 -0
- package/build/utils/markdown-styling.js.map +1 -0
- package/build/utils/markdown.d.ts +54 -0
- package/build/utils/markdown.js +243 -0
- package/build/utils/markdown.js.map +1 -0
- package/build/utils/security.d.ts +79 -0
- package/build/utils/security.js +303 -0
- package/build/utils/security.js.map +1 -0
- package/build/utils/tool-efficiency.d.ts +59 -0
- package/build/utils/tool-efficiency.js +247 -0
- package/build/utils/tool-efficiency.js.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ClickUpClient } from './index.js';
|
|
2
|
+
export class DependenciesEnhancedClient extends ClickUpClient {
|
|
3
|
+
constructor(apiToken) {
|
|
4
|
+
super({ apiToken });
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Create a new dependency between tasks
|
|
8
|
+
*/
|
|
9
|
+
async createDependency(request) {
|
|
10
|
+
const payload = {
|
|
11
|
+
depends_on: request.depends_on,
|
|
12
|
+
type: request.type,
|
|
13
|
+
link_id: request.link_id
|
|
14
|
+
};
|
|
15
|
+
const response = await this.post(`/task/${request.task_id}/dependency`, payload);
|
|
16
|
+
return response.dependency;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get dependencies for a task
|
|
20
|
+
*/
|
|
21
|
+
async getTaskDependencies(filter) {
|
|
22
|
+
const params = new URLSearchParams();
|
|
23
|
+
if (filter.type)
|
|
24
|
+
params.append('type', filter.type);
|
|
25
|
+
if (filter.status)
|
|
26
|
+
params.append('status', filter.status);
|
|
27
|
+
if (filter.include_resolved)
|
|
28
|
+
params.append('include_resolved', 'true');
|
|
29
|
+
const queryString = params.toString();
|
|
30
|
+
const endpoint = `/task/${filter.task_id}/dependency${queryString ? `?${queryString}` : ''}`;
|
|
31
|
+
const response = await this.get(endpoint);
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Update an existing dependency
|
|
36
|
+
*/
|
|
37
|
+
async updateDependency(request) {
|
|
38
|
+
const updateData = {};
|
|
39
|
+
if (request.type)
|
|
40
|
+
updateData.type = request.type;
|
|
41
|
+
if (request.status)
|
|
42
|
+
updateData.status = request.status;
|
|
43
|
+
const response = await this.put(`/dependency/${request.dependency_id}`, updateData);
|
|
44
|
+
return response.dependency;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Delete a dependency
|
|
48
|
+
*/
|
|
49
|
+
async deleteDependency(dependencyId) {
|
|
50
|
+
await this.delete(`/dependency/${dependencyId}`);
|
|
51
|
+
return { success: true };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get dependency graph for a task
|
|
55
|
+
*/
|
|
56
|
+
async getDependencyGraph(options) {
|
|
57
|
+
const params = new URLSearchParams();
|
|
58
|
+
params.append('depth', options.depth.toString());
|
|
59
|
+
params.append('direction', options.direction);
|
|
60
|
+
if (options.include_resolved)
|
|
61
|
+
params.append('include_resolved', 'true');
|
|
62
|
+
if (options.include_broken)
|
|
63
|
+
params.append('include_broken', 'true');
|
|
64
|
+
const queryString = params.toString();
|
|
65
|
+
const endpoint = `/task/${options.task_id}/dependency/graph?${queryString}`;
|
|
66
|
+
const response = await this.get(endpoint);
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check for dependency conflicts
|
|
71
|
+
*/
|
|
72
|
+
async checkDependencyConflicts(check) {
|
|
73
|
+
const payload = {
|
|
74
|
+
proposed_dependencies: check.proposed_dependencies || []
|
|
75
|
+
};
|
|
76
|
+
const response = await this.post(`/task/${check.task_id}/dependency/conflicts`, payload);
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Perform bulk dependency operations
|
|
81
|
+
*/
|
|
82
|
+
async bulkDependencyOperations(operation) {
|
|
83
|
+
const response = await this.post('/dependency/bulk', operation);
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get all dependencies in a workspace
|
|
88
|
+
*/
|
|
89
|
+
async getWorkspaceDependencies(workspaceId, options) {
|
|
90
|
+
const params = new URLSearchParams();
|
|
91
|
+
if (options?.status)
|
|
92
|
+
params.append('status', options.status);
|
|
93
|
+
if (options?.type)
|
|
94
|
+
params.append('type', options.type);
|
|
95
|
+
if (options?.limit)
|
|
96
|
+
params.append('limit', options.limit.toString());
|
|
97
|
+
if (options?.offset)
|
|
98
|
+
params.append('offset', options.offset.toString());
|
|
99
|
+
const queryString = params.toString();
|
|
100
|
+
const endpoint = `/team/${workspaceId}/dependency${queryString ? `?${queryString}` : ''}`;
|
|
101
|
+
const response = await this.get(endpoint);
|
|
102
|
+
return response;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get dependency statistics for a workspace
|
|
106
|
+
*/
|
|
107
|
+
async getDependencyStats(workspaceId) {
|
|
108
|
+
const response = await this.get(`/team/${workspaceId}/dependency/stats`);
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolve dependency conflicts automatically
|
|
113
|
+
*/
|
|
114
|
+
async resolveDependencyConflicts(taskId, resolution) {
|
|
115
|
+
const response = await this.post(`/task/${taskId}/dependency/resolve`, resolution);
|
|
116
|
+
return response;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get dependency timeline impact
|
|
120
|
+
*/
|
|
121
|
+
async getDependencyTimelineImpact(taskId) {
|
|
122
|
+
const response = await this.get(`/task/${taskId}/dependency/timeline`);
|
|
123
|
+
return response;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Export dependency graph
|
|
127
|
+
*/
|
|
128
|
+
async exportDependencyGraph(taskId, format = 'json') {
|
|
129
|
+
const params = new URLSearchParams();
|
|
130
|
+
params.append('format', format);
|
|
131
|
+
const response = await this.get(`/task/${taskId}/dependency/export?${params.toString()}`);
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Import dependency graph
|
|
136
|
+
*/
|
|
137
|
+
async importDependencyGraph(workspaceId, data) {
|
|
138
|
+
const response = await this.post(`/team/${workspaceId}/dependency/import`, data);
|
|
139
|
+
return response;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=dependencies-enhanced.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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,CAAC,IAAI,CAS7B,SAAS,WAAW,oBAAoB,EAAE,IAAI,CAAC,CAAC;QAEnD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { ClickUpClient } from './index.js';
|
|
2
|
+
export interface Doc {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
date_created: number;
|
|
6
|
+
date_updated: number;
|
|
7
|
+
parent?: {
|
|
8
|
+
id: string;
|
|
9
|
+
type: number;
|
|
10
|
+
};
|
|
11
|
+
public: boolean;
|
|
12
|
+
workspace_id: number;
|
|
13
|
+
creator: number;
|
|
14
|
+
deleted: boolean;
|
|
15
|
+
type: number;
|
|
16
|
+
content?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
sharing?: SharingConfig;
|
|
19
|
+
page_count?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface Page {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
content: string;
|
|
25
|
+
content_format: ContentFormat;
|
|
26
|
+
doc_id: string;
|
|
27
|
+
parent_page_id?: string;
|
|
28
|
+
position: number;
|
|
29
|
+
date_created: number;
|
|
30
|
+
date_updated: number;
|
|
31
|
+
creator: number;
|
|
32
|
+
}
|
|
33
|
+
export type ContentFormat = 'markdown' | 'html' | 'text/md' | 'text/plain' | 'text/html';
|
|
34
|
+
export interface SharingConfig {
|
|
35
|
+
public: boolean;
|
|
36
|
+
public_share_expires_on?: number;
|
|
37
|
+
public_fields?: string[];
|
|
38
|
+
team_sharing?: boolean;
|
|
39
|
+
guest_sharing?: boolean;
|
|
40
|
+
token?: string;
|
|
41
|
+
seo_optimized?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface CreateDocParams {
|
|
44
|
+
workspace_id?: string;
|
|
45
|
+
space_id?: string;
|
|
46
|
+
folder_id?: string;
|
|
47
|
+
name: string;
|
|
48
|
+
content?: string;
|
|
49
|
+
public?: boolean;
|
|
50
|
+
template_id?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface UpdateDocParams {
|
|
53
|
+
name?: string;
|
|
54
|
+
content?: string;
|
|
55
|
+
public?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface CreatePageParams {
|
|
58
|
+
name: string;
|
|
59
|
+
content: string;
|
|
60
|
+
content_format?: ContentFormat;
|
|
61
|
+
parent_page_id?: string;
|
|
62
|
+
position?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface UpdatePageParams {
|
|
65
|
+
name?: string;
|
|
66
|
+
content?: string;
|
|
67
|
+
content_format?: ContentFormat;
|
|
68
|
+
position?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface SharingParams {
|
|
71
|
+
public?: boolean;
|
|
72
|
+
public_share_expires_on?: number;
|
|
73
|
+
public_fields?: string[];
|
|
74
|
+
team_sharing?: boolean;
|
|
75
|
+
guest_sharing?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface CreateFromTemplateParams {
|
|
78
|
+
workspace_id?: string;
|
|
79
|
+
space_id?: string;
|
|
80
|
+
folder_id?: string;
|
|
81
|
+
name: string;
|
|
82
|
+
template_variables?: Record<string, any>;
|
|
83
|
+
}
|
|
84
|
+
export interface GetDocsParams {
|
|
85
|
+
cursor?: string;
|
|
86
|
+
deleted?: boolean;
|
|
87
|
+
archived?: boolean;
|
|
88
|
+
limit?: number;
|
|
89
|
+
}
|
|
90
|
+
export interface SearchDocsParams {
|
|
91
|
+
query: string;
|
|
92
|
+
cursor?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface DocsResponse {
|
|
95
|
+
docs: Doc[];
|
|
96
|
+
next_cursor?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Enhanced Documents Client with full CRUD operations
|
|
100
|
+
* Extends the existing read-only functionality with write operations
|
|
101
|
+
*/
|
|
102
|
+
export declare class EnhancedDocsClient {
|
|
103
|
+
private client;
|
|
104
|
+
private apiToken;
|
|
105
|
+
constructor(client: ClickUpClient);
|
|
106
|
+
private getHeaders;
|
|
107
|
+
/**
|
|
108
|
+
* Get docs from a specific workspace
|
|
109
|
+
*/
|
|
110
|
+
getDocsFromWorkspace(workspaceId: string, params?: GetDocsParams): Promise<DocsResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Get the pages of a doc
|
|
113
|
+
*/
|
|
114
|
+
getDocPages(workspaceId: string, docId: string, contentFormat?: string): Promise<Page[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Search for docs in a workspace
|
|
117
|
+
*/
|
|
118
|
+
searchDocs(workspaceId: string, params: SearchDocsParams): Promise<DocsResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Create a new document
|
|
121
|
+
*/
|
|
122
|
+
createDoc(params: CreateDocParams): Promise<Doc>;
|
|
123
|
+
/**
|
|
124
|
+
* Update an existing document
|
|
125
|
+
*/
|
|
126
|
+
updateDoc(docId: string, params: UpdateDocParams): Promise<Doc>;
|
|
127
|
+
/**
|
|
128
|
+
* Delete a document
|
|
129
|
+
*/
|
|
130
|
+
deleteDoc(docId: string): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Get document details
|
|
133
|
+
*/
|
|
134
|
+
getDoc(docId: string): Promise<Doc>;
|
|
135
|
+
/**
|
|
136
|
+
* Create a new page in a document
|
|
137
|
+
*/
|
|
138
|
+
createPage(docId: string, params: CreatePageParams): Promise<Page>;
|
|
139
|
+
/**
|
|
140
|
+
* Update an existing page
|
|
141
|
+
*/
|
|
142
|
+
updatePage(docId: string, pageId: string, params: UpdatePageParams): Promise<Page>;
|
|
143
|
+
/**
|
|
144
|
+
* Delete a page from a document
|
|
145
|
+
*/
|
|
146
|
+
deletePage(docId: string, pageId: string): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Get page details
|
|
149
|
+
*/
|
|
150
|
+
getPage(docId: string, pageId: string, contentFormat?: ContentFormat): Promise<Page>;
|
|
151
|
+
/**
|
|
152
|
+
* Get document sharing settings
|
|
153
|
+
*/
|
|
154
|
+
getDocSharing(docId: string): Promise<SharingConfig>;
|
|
155
|
+
/**
|
|
156
|
+
* Update document sharing settings
|
|
157
|
+
*/
|
|
158
|
+
updateDocSharing(docId: string, params: SharingParams): Promise<SharingConfig>;
|
|
159
|
+
/**
|
|
160
|
+
* Create document from template
|
|
161
|
+
*/
|
|
162
|
+
createDocFromTemplate(templateId: string, params: CreateFromTemplateParams): Promise<Doc>;
|
|
163
|
+
/**
|
|
164
|
+
* Enhanced error handling with context
|
|
165
|
+
*/
|
|
166
|
+
private handleError;
|
|
167
|
+
/**
|
|
168
|
+
* Validate content format
|
|
169
|
+
*/
|
|
170
|
+
private validateContentFormat;
|
|
171
|
+
/**
|
|
172
|
+
* Sanitize HTML content (basic implementation)
|
|
173
|
+
*/
|
|
174
|
+
private sanitizeHtml;
|
|
175
|
+
}
|
|
176
|
+
export declare const createEnhancedDocsClient: (client: ClickUpClient) => EnhancedDocsClient;
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced Documents Client with full CRUD operations
|
|
4
|
+
* Extends the existing read-only functionality with write operations
|
|
5
|
+
*/
|
|
6
|
+
export class EnhancedDocsClient {
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.apiToken = process.env.CLICKUP_API_TOKEN || '';
|
|
10
|
+
}
|
|
11
|
+
getHeaders() {
|
|
12
|
+
return {
|
|
13
|
+
'Authorization': this.apiToken,
|
|
14
|
+
'Accept': 'application/json',
|
|
15
|
+
'Content-Type': 'application/json'
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// ========================================
|
|
19
|
+
// EXISTING READ OPERATIONS (Enhanced)
|
|
20
|
+
// ========================================
|
|
21
|
+
/**
|
|
22
|
+
* Get docs from a specific workspace
|
|
23
|
+
*/
|
|
24
|
+
async getDocsFromWorkspace(workspaceId, params) {
|
|
25
|
+
try {
|
|
26
|
+
const url = `https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs`;
|
|
27
|
+
const response = await axios.get(url, {
|
|
28
|
+
headers: this.getHeaders(),
|
|
29
|
+
params
|
|
30
|
+
});
|
|
31
|
+
return response.data;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error('Error getting docs from workspace:', error);
|
|
35
|
+
throw this.handleError(error, 'Failed to get docs from workspace');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the pages of a doc
|
|
40
|
+
*/
|
|
41
|
+
async getDocPages(workspaceId, docId, contentFormat = 'text/md') {
|
|
42
|
+
try {
|
|
43
|
+
const url = `https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs/${docId}/pages`;
|
|
44
|
+
const params = {
|
|
45
|
+
max_page_depth: -1,
|
|
46
|
+
content_format: contentFormat
|
|
47
|
+
};
|
|
48
|
+
const response = await axios.get(url, {
|
|
49
|
+
headers: this.getHeaders(),
|
|
50
|
+
params
|
|
51
|
+
});
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error('Error getting doc pages:', error);
|
|
56
|
+
throw this.handleError(error, 'Failed to get doc pages');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Search for docs in a workspace
|
|
61
|
+
*/
|
|
62
|
+
async searchDocs(workspaceId, params) {
|
|
63
|
+
try {
|
|
64
|
+
const url = `https://api.clickup.com/api/v2/team/${workspaceId}/docs/search`;
|
|
65
|
+
const queryParams = {
|
|
66
|
+
doc_name: params.query,
|
|
67
|
+
cursor: params.cursor
|
|
68
|
+
};
|
|
69
|
+
if (params.query.startsWith('space:')) {
|
|
70
|
+
const spaceId = params.query.substring(6);
|
|
71
|
+
queryParams.space_id = spaceId;
|
|
72
|
+
delete queryParams.doc_name;
|
|
73
|
+
}
|
|
74
|
+
const response = await axios.get(url, {
|
|
75
|
+
headers: this.getHeaders(),
|
|
76
|
+
params: queryParams
|
|
77
|
+
});
|
|
78
|
+
return response.data;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error('Error searching docs:', error);
|
|
82
|
+
throw this.handleError(error, 'Failed to search docs');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// ========================================
|
|
86
|
+
// NEW: DOCUMENT CRUD OPERATIONS
|
|
87
|
+
// ========================================
|
|
88
|
+
/**
|
|
89
|
+
* Create a new document
|
|
90
|
+
*/
|
|
91
|
+
async createDoc(params) {
|
|
92
|
+
try {
|
|
93
|
+
let url;
|
|
94
|
+
// Determine the correct endpoint based on parent
|
|
95
|
+
if (params.workspace_id) {
|
|
96
|
+
url = `https://api.clickup.com/api/v3/workspaces/${params.workspace_id}/docs`;
|
|
97
|
+
}
|
|
98
|
+
else if (params.space_id) {
|
|
99
|
+
url = `https://api.clickup.com/api/v3/spaces/${params.space_id}/docs`;
|
|
100
|
+
}
|
|
101
|
+
else if (params.folder_id) {
|
|
102
|
+
url = `https://api.clickup.com/api/v3/folders/${params.folder_id}/docs`;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw new Error('Must specify workspace_id, space_id, or folder_id');
|
|
106
|
+
}
|
|
107
|
+
const requestBody = {
|
|
108
|
+
name: params.name,
|
|
109
|
+
content: params.content || '',
|
|
110
|
+
public: params.public || false
|
|
111
|
+
};
|
|
112
|
+
// Add template_id if provided
|
|
113
|
+
if (params.template_id) {
|
|
114
|
+
requestBody.template_id = params.template_id;
|
|
115
|
+
}
|
|
116
|
+
const response = await axios.post(url, requestBody, {
|
|
117
|
+
headers: this.getHeaders()
|
|
118
|
+
});
|
|
119
|
+
return response.data;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
console.error('Error creating document:', error);
|
|
123
|
+
throw this.handleError(error, 'Failed to create document');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Update an existing document
|
|
128
|
+
*/
|
|
129
|
+
async updateDoc(docId, params) {
|
|
130
|
+
try {
|
|
131
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}`;
|
|
132
|
+
const requestBody = {};
|
|
133
|
+
if (params.name !== undefined)
|
|
134
|
+
requestBody.name = params.name;
|
|
135
|
+
if (params.content !== undefined)
|
|
136
|
+
requestBody.content = params.content;
|
|
137
|
+
if (params.public !== undefined)
|
|
138
|
+
requestBody.public = params.public;
|
|
139
|
+
const response = await axios.put(url, requestBody, {
|
|
140
|
+
headers: this.getHeaders()
|
|
141
|
+
});
|
|
142
|
+
return response.data;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.error('Error updating document:', error);
|
|
146
|
+
throw this.handleError(error, `Failed to update document ${docId}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Delete a document
|
|
151
|
+
*/
|
|
152
|
+
async deleteDoc(docId) {
|
|
153
|
+
try {
|
|
154
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}`;
|
|
155
|
+
await axios.delete(url, {
|
|
156
|
+
headers: this.getHeaders()
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
console.error('Error deleting document:', error);
|
|
161
|
+
throw this.handleError(error, `Failed to delete document ${docId}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get document details
|
|
166
|
+
*/
|
|
167
|
+
async getDoc(docId) {
|
|
168
|
+
try {
|
|
169
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}`;
|
|
170
|
+
const response = await axios.get(url, {
|
|
171
|
+
headers: this.getHeaders()
|
|
172
|
+
});
|
|
173
|
+
return response.data;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
console.error('Error getting document:', error);
|
|
177
|
+
throw this.handleError(error, `Failed to get document ${docId}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// ========================================
|
|
181
|
+
// NEW: PAGE MANAGEMENT OPERATIONS
|
|
182
|
+
// ========================================
|
|
183
|
+
/**
|
|
184
|
+
* Create a new page in a document
|
|
185
|
+
*/
|
|
186
|
+
async createPage(docId, params) {
|
|
187
|
+
try {
|
|
188
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}/pages`;
|
|
189
|
+
const requestBody = {
|
|
190
|
+
name: params.name,
|
|
191
|
+
content: params.content,
|
|
192
|
+
content_format: params.content_format || 'markdown'
|
|
193
|
+
};
|
|
194
|
+
if (params.parent_page_id) {
|
|
195
|
+
requestBody.parent_page_id = params.parent_page_id;
|
|
196
|
+
}
|
|
197
|
+
if (params.position !== undefined) {
|
|
198
|
+
requestBody.position = params.position;
|
|
199
|
+
}
|
|
200
|
+
const response = await axios.post(url, requestBody, {
|
|
201
|
+
headers: this.getHeaders()
|
|
202
|
+
});
|
|
203
|
+
return response.data;
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
console.error('Error creating page:', error);
|
|
207
|
+
throw this.handleError(error, `Failed to create page in document ${docId}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Update an existing page
|
|
212
|
+
*/
|
|
213
|
+
async updatePage(docId, pageId, params) {
|
|
214
|
+
try {
|
|
215
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}/pages/${pageId}`;
|
|
216
|
+
const requestBody = {};
|
|
217
|
+
if (params.name !== undefined)
|
|
218
|
+
requestBody.name = params.name;
|
|
219
|
+
if (params.content !== undefined)
|
|
220
|
+
requestBody.content = params.content;
|
|
221
|
+
if (params.content_format !== undefined)
|
|
222
|
+
requestBody.content_format = params.content_format;
|
|
223
|
+
if (params.position !== undefined)
|
|
224
|
+
requestBody.position = params.position;
|
|
225
|
+
const response = await axios.put(url, requestBody, {
|
|
226
|
+
headers: this.getHeaders()
|
|
227
|
+
});
|
|
228
|
+
return response.data;
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
console.error('Error updating page:', error);
|
|
232
|
+
throw this.handleError(error, `Failed to update page ${pageId} in document ${docId}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Delete a page from a document
|
|
237
|
+
*/
|
|
238
|
+
async deletePage(docId, pageId) {
|
|
239
|
+
try {
|
|
240
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}/pages/${pageId}`;
|
|
241
|
+
await axios.delete(url, {
|
|
242
|
+
headers: this.getHeaders()
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
console.error('Error deleting page:', error);
|
|
247
|
+
throw this.handleError(error, `Failed to delete page ${pageId} from document ${docId}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get page details
|
|
252
|
+
*/
|
|
253
|
+
async getPage(docId, pageId, contentFormat) {
|
|
254
|
+
try {
|
|
255
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}/pages/${pageId}`;
|
|
256
|
+
const params = contentFormat ? { content_format: contentFormat } : {};
|
|
257
|
+
const response = await axios.get(url, {
|
|
258
|
+
headers: this.getHeaders(),
|
|
259
|
+
params
|
|
260
|
+
});
|
|
261
|
+
return response.data;
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
console.error('Error getting page:', error);
|
|
265
|
+
throw this.handleError(error, `Failed to get page ${pageId} from document ${docId}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// ========================================
|
|
269
|
+
// NEW: SHARING MANAGEMENT
|
|
270
|
+
// ========================================
|
|
271
|
+
/**
|
|
272
|
+
* Get document sharing settings
|
|
273
|
+
*/
|
|
274
|
+
async getDocSharing(docId) {
|
|
275
|
+
try {
|
|
276
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}/sharing`;
|
|
277
|
+
const response = await axios.get(url, {
|
|
278
|
+
headers: this.getHeaders()
|
|
279
|
+
});
|
|
280
|
+
return response.data;
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
console.error('Error getting document sharing:', error);
|
|
284
|
+
throw this.handleError(error, `Failed to get sharing settings for document ${docId}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Update document sharing settings
|
|
289
|
+
*/
|
|
290
|
+
async updateDocSharing(docId, params) {
|
|
291
|
+
try {
|
|
292
|
+
const url = `https://api.clickup.com/api/v3/docs/${docId}/sharing`;
|
|
293
|
+
const response = await axios.put(url, params, {
|
|
294
|
+
headers: this.getHeaders()
|
|
295
|
+
});
|
|
296
|
+
return response.data;
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
console.error('Error updating document sharing:', error);
|
|
300
|
+
throw this.handleError(error, `Failed to update sharing settings for document ${docId}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// ========================================
|
|
304
|
+
// NEW: TEMPLATE OPERATIONS
|
|
305
|
+
// ========================================
|
|
306
|
+
/**
|
|
307
|
+
* Create document from template
|
|
308
|
+
*/
|
|
309
|
+
async createDocFromTemplate(templateId, params) {
|
|
310
|
+
try {
|
|
311
|
+
const createParams = {
|
|
312
|
+
...params,
|
|
313
|
+
template_id: templateId
|
|
314
|
+
};
|
|
315
|
+
return await this.createDoc(createParams);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
console.error('Error creating document from template:', error);
|
|
319
|
+
throw this.handleError(error, `Failed to create document from template ${templateId}`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// ========================================
|
|
323
|
+
// UTILITY METHODS
|
|
324
|
+
// ========================================
|
|
325
|
+
/**
|
|
326
|
+
* Enhanced error handling with context
|
|
327
|
+
*/
|
|
328
|
+
handleError(error, context) {
|
|
329
|
+
if (axios.isAxiosError(error)) {
|
|
330
|
+
const status = error.response?.status;
|
|
331
|
+
const message = error.response?.data?.message || error.message;
|
|
332
|
+
switch (status) {
|
|
333
|
+
case 400:
|
|
334
|
+
return new Error(`${context}: Invalid request - ${message}`);
|
|
335
|
+
case 401:
|
|
336
|
+
return new Error(`${context}: Authentication failed - check API token`);
|
|
337
|
+
case 403:
|
|
338
|
+
return new Error(`${context}: Permission denied - insufficient access rights`);
|
|
339
|
+
case 404:
|
|
340
|
+
return new Error(`${context}: Resource not found - ${message}`);
|
|
341
|
+
case 413:
|
|
342
|
+
return new Error(`${context}: Content too large - reduce document size`);
|
|
343
|
+
case 429:
|
|
344
|
+
return new Error(`${context}: Rate limit exceeded - please retry later`);
|
|
345
|
+
case 500:
|
|
346
|
+
return new Error(`${context}: Server error - please try again`);
|
|
347
|
+
default:
|
|
348
|
+
return new Error(`${context}: ${message}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return new Error(`${context}: ${error.message || 'Unknown error'}`);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Validate content format
|
|
355
|
+
*/
|
|
356
|
+
validateContentFormat(format) {
|
|
357
|
+
const validFormats = ['markdown', 'html', 'text/md', 'text/plain', 'text/html'];
|
|
358
|
+
return validFormats.includes(format);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Sanitize HTML content (basic implementation)
|
|
362
|
+
*/
|
|
363
|
+
sanitizeHtml(html) {
|
|
364
|
+
// Basic HTML sanitization - remove script tags and dangerous attributes
|
|
365
|
+
return html
|
|
366
|
+
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '')
|
|
367
|
+
.replace(/on\w+="[^"]*"/gi, '')
|
|
368
|
+
.replace(/javascript:/gi, '');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
export const createEnhancedDocsClient = (client) => {
|
|
372
|
+
return new EnhancedDocsClient(client);
|
|
373
|
+
};
|
|
374
|
+
//# sourceMappingURL=docs-enhanced.js.map
|