@elobdev/zoho-projects-wrapper 0.0.0-stage → 0.1.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/.codex +0 -0
- package/README.md +52 -2
- package/docs/zoho- +0 -0
- package/docs/zoho-projects-api-matrix.md +368 -0
- package/package.json +23 -4
- package/src/client.ts +75 -0
- package/src/errors.ts +34 -0
- package/src/http.ts +166 -0
- package/src/index.ts +19 -0
- package/src/oauth.ts +121 -0
- package/src/query.ts +51 -0
- package/src/resource-base.ts +59 -0
- package/src/resources/custom-fields.ts +27 -0
- package/src/resources/issues.ts +166 -0
- package/src/resources/module-meta.ts +1 -0
- package/src/resources/phases.ts +68 -0
- package/src/resources/portals.ts +46 -0
- package/src/resources/project-groups.ts +24 -0
- package/src/resources/projects.ts +56 -0
- package/src/resources/records.ts +40 -0
- package/src/resources/settings.ts +132 -0
- package/src/resources/tasklists.ts +94 -0
- package/src/resources/tasks.ts +43 -0
- package/src/resources/time-logs.ts +274 -0
- package/src/tools.ts +741 -0
- package/src/types.ts +546 -0
- package/test/helpers.ts +28 -0
- package/test/http.test.ts +49 -0
- package/test/node-shims.d.ts +9 -0
- package/test/oauth.test.ts +72 -0
- package/test/path-alias-hooks.js +10 -0
- package/test/query.test.ts +46 -0
- package/test/register-path-alias.js +3 -0
- package/test/resources.test.ts +504 -0
- package/test/tools.test.ts +30 -0
- package/tsconfig.json +20 -0
package/src/tools.ts
ADDED
|
@@ -0,0 +1,741 @@
|
|
|
1
|
+
import { ZohoProjectsClient } from '@/client.ts';
|
|
2
|
+
|
|
3
|
+
export interface ZohoFunctionTool {
|
|
4
|
+
type: 'function';
|
|
5
|
+
function: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
parameters: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ZohoToolContext {
|
|
13
|
+
client: ZohoProjectsClient;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ToolExecutor = (context: ZohoToolContext, input: Record<string, unknown>) => Promise<unknown>;
|
|
17
|
+
|
|
18
|
+
function functionTool(name: string, description: string, parameters: Record<string, unknown>): ZohoFunctionTool {
|
|
19
|
+
return {
|
|
20
|
+
type: 'function',
|
|
21
|
+
function: {
|
|
22
|
+
name,
|
|
23
|
+
description,
|
|
24
|
+
parameters,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function objectSchema(properties: Record<string, unknown>, required: string[] = []): Record<string, unknown> {
|
|
30
|
+
return {
|
|
31
|
+
type: 'object',
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
properties,
|
|
34
|
+
required,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function idField(description: string): Record<string, unknown> {
|
|
39
|
+
return { anyOf: [{ type: 'integer' }, { type: 'string' }], description };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const commonQuerySchema = { type: 'object', additionalProperties: true };
|
|
43
|
+
const commonBodySchema = { type: 'object', additionalProperties: true };
|
|
44
|
+
|
|
45
|
+
const portalsTool = functionTool(
|
|
46
|
+
'zoho_projects_portals',
|
|
47
|
+
'Use portal-level Zoho Projects operations such as listing portals, backup, trash, restore, and delete.',
|
|
48
|
+
objectSchema({
|
|
49
|
+
action: { type: 'string', enum: ['listPortals', 'getPortalDetails', 'scheduleDataBackup', 'getDataBackupStatus', 'getDataBackupHistory', 'getTrashedRecords', 'moveRecordsToTrash', 'deleteRecords', 'restoreRecordsFromTrash', 'emptyRecycleBin'] },
|
|
50
|
+
portal_id: idField('Portal ID.'),
|
|
51
|
+
export_id: idField('Backup export ID.'),
|
|
52
|
+
module: { type: 'string' },
|
|
53
|
+
record_id: idField('Single record ID.'),
|
|
54
|
+
body: commonBodySchema,
|
|
55
|
+
query: commonQuerySchema,
|
|
56
|
+
}, ['action']),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const projectsTool = functionTool(
|
|
60
|
+
'zoho_projects_projects',
|
|
61
|
+
'Use project-level Zoho Projects operations including CRUD and project comments.',
|
|
62
|
+
objectSchema({
|
|
63
|
+
action: { type: 'string', enum: ['list', 'getById', 'create', 'update', 'deleteById', 'trash', 'listComments', 'getComment', 'addComment', 'updateComment', 'deleteComment', 'markFavouriteCustomView'] },
|
|
64
|
+
portal_id: idField('Portal ID.'),
|
|
65
|
+
project_id: idField('Project ID.'),
|
|
66
|
+
comment_id: idField('Comment ID.'),
|
|
67
|
+
custom_view_id: idField('Custom view ID.'),
|
|
68
|
+
body: commonBodySchema,
|
|
69
|
+
query: commonQuerySchema,
|
|
70
|
+
}, ['action']),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const projectGroupsTool = functionTool(
|
|
74
|
+
'zoho_projects_project_groups',
|
|
75
|
+
'Use project group operations.',
|
|
76
|
+
objectSchema({
|
|
77
|
+
action: { type: 'string', enum: ['list', 'listMine', 'create', 'update', 'deleteById'] },
|
|
78
|
+
portal_id: idField('Portal ID.'),
|
|
79
|
+
group_id: idField('Project group ID.'),
|
|
80
|
+
body: commonBodySchema,
|
|
81
|
+
query: commonQuerySchema,
|
|
82
|
+
}, ['action']),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const phasesTool = functionTool(
|
|
86
|
+
'zoho_projects_phases',
|
|
87
|
+
'Use milestone/phase operations including CRUD, move, comments, and followers.',
|
|
88
|
+
objectSchema({
|
|
89
|
+
action: { type: 'string', enum: ['list', 'listAll', 'getById', 'create', 'update', 'deleteById', 'move', 'statusTimeline', 'listComments', 'getComment', 'addComment', 'updateComment', 'deleteComment', 'getFollowers', 'addFollowers', 'removeFollowers'] },
|
|
90
|
+
portal_id: idField('Portal ID.'),
|
|
91
|
+
project_id: idField('Project ID.'),
|
|
92
|
+
phase_id: idField('Phase ID.'),
|
|
93
|
+
comment_id: idField('Comment ID.'),
|
|
94
|
+
body: commonBodySchema,
|
|
95
|
+
query: commonQuerySchema,
|
|
96
|
+
}, ['action']),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const tasklistsTool = functionTool(
|
|
100
|
+
'zoho_projects_tasklists',
|
|
101
|
+
'Use task list operations including CRUD, comments, followers, and make-as-template.',
|
|
102
|
+
objectSchema({
|
|
103
|
+
action: { type: 'string', enum: ['list', 'listAll', 'getById', 'create', 'createDefault', 'update', 'deleteById', 'makeAsTemplate', 'getComments', 'getComment', 'addComment', 'updateComment', 'deleteComment', 'getFollowers', 'addFollowers', 'removeFollowers'] },
|
|
104
|
+
portal_id: idField('Portal ID.'),
|
|
105
|
+
project_id: idField('Project ID.'),
|
|
106
|
+
tasklist_id: idField('Task list ID.'),
|
|
107
|
+
comment_id: idField('Comment ID.'),
|
|
108
|
+
body: commonBodySchema,
|
|
109
|
+
query: commonQuerySchema,
|
|
110
|
+
}, ['action']),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const tasksTool = functionTool(
|
|
114
|
+
'zoho_projects_tasks',
|
|
115
|
+
'Use task operations including CRUD, lists, status history, and issue associations.',
|
|
116
|
+
objectSchema({
|
|
117
|
+
action: { type: 'string', enum: ['listAll', 'listMyTasks', 'list', 'getById', 'create', 'update', 'deleteById', 'getStatusHistory', 'getAssociatedTasksByIssues'] },
|
|
118
|
+
portal_id: idField('Portal ID.'),
|
|
119
|
+
project_id: idField('Project ID.'),
|
|
120
|
+
task_id: idField('Task ID.'),
|
|
121
|
+
body: commonBodySchema,
|
|
122
|
+
query: commonQuerySchema,
|
|
123
|
+
issue_ids: { type: 'array', items: { anyOf: [{ type: 'integer' }, { type: 'string' }] } },
|
|
124
|
+
}, ['action']),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const issuesTool = functionTool(
|
|
128
|
+
'zoho_projects_issues',
|
|
129
|
+
'Use issue operations including CRUD, comments, attachments, followers, linking, and bulk actions.',
|
|
130
|
+
objectSchema({
|
|
131
|
+
action: { type: 'string', enum: ['listAll', 'list', 'getById', 'create', 'update', 'deleteById', 'listCustomViews', 'move', 'getComments', 'getComment', 'addComment', 'updateComment', 'deleteComment', 'getFollowers', 'addFollowers', 'removeFollowers', 'getLinkedIssues', 'associateTasks', 'bulkAssociateTasks', 'bulkLinkIssues', 'getAttachments', 'addAttachments', 'removeAttachment', 'dissociateTask', 'getStatusTransition', 'addResolution', 'updateResolution', 'getAssociatedTasks', 'getAssociatedTasksByIssues', 'getCommentAttachment'] },
|
|
132
|
+
portal_id: idField('Portal ID.'),
|
|
133
|
+
project_id: idField('Project ID.'),
|
|
134
|
+
issue_id: idField('Issue ID.'),
|
|
135
|
+
comment_id: idField('Comment ID.'),
|
|
136
|
+
task_id: idField('Task ID.'),
|
|
137
|
+
attachment_id: idField('Attachment ID.'),
|
|
138
|
+
body: commonBodySchema,
|
|
139
|
+
query: commonQuerySchema,
|
|
140
|
+
issue_ids: { type: 'array', items: { anyOf: [{ type: 'integer' }, { type: 'string' }] } },
|
|
141
|
+
task_ids: { type: 'array', items: { anyOf: [{ type: 'integer' }, { type: 'string' }] } },
|
|
142
|
+
}, ['action']),
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const recordsTool = functionTool(
|
|
146
|
+
'zoho_projects_records',
|
|
147
|
+
'Use dynamic module record operations such as create, edits, attachment counts, followers, and comments.',
|
|
148
|
+
objectSchema({
|
|
149
|
+
action: { type: 'string', enum: ['createRecord', 'listEntityEdits', 'getEditsByAuditId', 'getAttachmentCount', 'getFollowers', 'addFollower', 'addOrRemoveFollowers', 'removeFollower', 'addComment'] },
|
|
150
|
+
portal_id: idField('Portal ID.'),
|
|
151
|
+
module_name: { type: 'string' },
|
|
152
|
+
entity_id: idField('Entity ID.'),
|
|
153
|
+
edit_id: idField('Edit/Audit ID.'),
|
|
154
|
+
body: commonBodySchema,
|
|
155
|
+
query: commonQuerySchema,
|
|
156
|
+
}, ['action']),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const settingsTool = functionTool(
|
|
160
|
+
'zoho_projects_settings',
|
|
161
|
+
'Use Zoho Projects module metadata and settings operations.',
|
|
162
|
+
objectSchema({
|
|
163
|
+
action: { type: 'string', enum: ['listModules', 'getModule', 'createModule', 'updateModule', 'updateModuleStatus', 'trashModule', 'deleteModule', 'restoreModule', 'getModuleConfiguration', 'activateModule', 'deactivateModule', 'listLayouts', 'getDefaultLayout', 'getLayoutDetails', 'createLayout', 'updateLayout', 'deleteLayout', 'disassociateFieldFromLayout', 'getAssociatedEntitiesOfLayout', 'createOrUpdateSection', 'deleteSection', 'listFields', 'createOrUpdateField', 'deleteField', 'getAssociatedLayouts', 'getOptionsListForField', 'createBulkOptions', 'deleteOrDisassociateBulkOptions', 'updateBulkOptions', 'getModuleIntegrationField', 'getViews'] },
|
|
164
|
+
portal_id: idField('Portal ID.'),
|
|
165
|
+
module: { type: 'string' },
|
|
166
|
+
layout_id: idField('Layout ID.'),
|
|
167
|
+
field_id: idField('Field ID.'),
|
|
168
|
+
service_id: idField('Service ID.'),
|
|
169
|
+
view_id: idField('View ID.'),
|
|
170
|
+
body: commonBodySchema,
|
|
171
|
+
query: commonQuerySchema,
|
|
172
|
+
}, ['action']),
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
const timeLogsTool = functionTool(
|
|
176
|
+
'zoho_projects_time_logs',
|
|
177
|
+
'Use Zoho Projects time log operations, bulk time logs, reports, timers, pins, approvers, and settings.',
|
|
178
|
+
objectSchema({
|
|
179
|
+
action: { type: 'string', enum: ['listPortalTimeLogs', 'listProjectTimeLogs', 'getTimeLogDetail', 'addTimeLog', 'bulkUpdateTimeLogs', 'bulkDeleteTimeLogs', 'getPortalTimeLogReport', 'getProjectTimeLogReport', 'getDefaultApprover', 'listPinnedPortalTimeLogs', 'listPinnedProjectTimeLogs', 'createPinnedPortalTimeLog', 'updatePinnedPortalTimeLog', 'deletePinnedPortalTimeLog', 'createPinnedProjectTimeLog', 'updatePinnedProjectTimeLog', 'deletePinnedProjectTimeLog', 'listRunningTimers', 'getTimerDetailsByLogId', 'startTimer', 'pauseTimer', 'resumeTimer', 'stopTimer', 'deleteTimer', 'getTimeLogSettingsMetaData', 'getTimeLogSettings', 'updateTimeLogSettings', 'listTaskLogs', 'addTaskLog', 'updateTaskLog', 'approveTaskLog', 'deleteTaskLog', 'listBugLogs', 'addBugLog', 'updateBugLog', 'approveBugLog', 'deleteBugLog', 'addGeneralLog', 'updateGeneralLog', 'approveGeneralLog', 'deleteGeneralLog', 'getTimesheetLayoutDetails', 'getAllTimesheetCustomFields'] },
|
|
180
|
+
portal_id: idField('Portal ID.'),
|
|
181
|
+
project_id: idField('Project ID.'),
|
|
182
|
+
task_id: idField('Task ID.'),
|
|
183
|
+
issue_id: idField('Issue/Bug ID.'),
|
|
184
|
+
log_id: idField('Time log ID.'),
|
|
185
|
+
timer_id: idField('Timer ID.'),
|
|
186
|
+
entity_type: { type: 'string', enum: ['task', 'issue'] },
|
|
187
|
+
body: commonBodySchema,
|
|
188
|
+
query: commonQuerySchema,
|
|
189
|
+
}, ['action']),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const requestTool = functionTool(
|
|
193
|
+
'zoho_projects_request',
|
|
194
|
+
'Use the raw Zoho Projects HTTP client for undocumented or experimental endpoints.',
|
|
195
|
+
objectSchema({
|
|
196
|
+
path: { type: 'string', description: 'Path relative to the Zoho Projects API base, or an absolute URL.' },
|
|
197
|
+
method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] },
|
|
198
|
+
query: commonQuerySchema,
|
|
199
|
+
body: commonBodySchema,
|
|
200
|
+
}, ['path', 'method']),
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
export const zohoProjectsTools: ZohoFunctionTool[] = [
|
|
204
|
+
portalsTool,
|
|
205
|
+
projectsTool,
|
|
206
|
+
projectGroupsTool,
|
|
207
|
+
phasesTool,
|
|
208
|
+
tasklistsTool,
|
|
209
|
+
tasksTool,
|
|
210
|
+
issuesTool,
|
|
211
|
+
recordsTool,
|
|
212
|
+
settingsTool,
|
|
213
|
+
timeLogsTool,
|
|
214
|
+
requestTool,
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
function getNumberOrString(value: unknown): string | number | undefined {
|
|
218
|
+
if (typeof value === 'string' || typeof value === 'number') return value;
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function executePortal(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
223
|
+
const portalId = input.portal_id as string | number;
|
|
224
|
+
const query = input.query as any;
|
|
225
|
+
switch (input.action) {
|
|
226
|
+
case 'listPortals':
|
|
227
|
+
return context.client.portals.listPortals();
|
|
228
|
+
case 'getPortalDetails':
|
|
229
|
+
return context.client.portals.getPortalDetails(portalId);
|
|
230
|
+
case 'scheduleDataBackup':
|
|
231
|
+
return context.client.portals.scheduleDataBackup(portalId, String(input.access_code ?? ''));
|
|
232
|
+
case 'getDataBackupStatus':
|
|
233
|
+
return context.client.portals.getDataBackupStatus(portalId, input.export_id as string | number);
|
|
234
|
+
case 'getDataBackupHistory':
|
|
235
|
+
return context.client.portals.getDataBackupHistory(portalId);
|
|
236
|
+
case 'getTrashedRecords':
|
|
237
|
+
return context.client.portals.getTrashedRecords(portalId, query);
|
|
238
|
+
case 'moveRecordsToTrash':
|
|
239
|
+
return context.client.portals.moveRecordsToTrash(portalId, input.body as any);
|
|
240
|
+
case 'deleteRecords':
|
|
241
|
+
return context.client.portals.deleteRecords(portalId, input.body as any);
|
|
242
|
+
case 'restoreRecordsFromTrash':
|
|
243
|
+
return context.client.portals.restoreRecordsFromTrash(portalId, input.body as any);
|
|
244
|
+
case 'emptyRecycleBin':
|
|
245
|
+
return context.client.portals.emptyRecycleBin(portalId);
|
|
246
|
+
default:
|
|
247
|
+
throw new Error(`Unsupported portals action: ${String(input.action)}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function executeProjects(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
252
|
+
const portalId = input.portal_id as string | number;
|
|
253
|
+
const projectId = input.project_id as string | number;
|
|
254
|
+
const query = input.query as any;
|
|
255
|
+
switch (input.action) {
|
|
256
|
+
case 'list':
|
|
257
|
+
return context.client.projects.list(portalId, query);
|
|
258
|
+
case 'getById':
|
|
259
|
+
return context.client.projects.getById(portalId, projectId);
|
|
260
|
+
case 'create':
|
|
261
|
+
return context.client.projects.create(portalId, input.body as any);
|
|
262
|
+
case 'update':
|
|
263
|
+
return context.client.projects.update(portalId, projectId, input.body as any);
|
|
264
|
+
case 'deleteById':
|
|
265
|
+
return context.client.projects.deleteById(portalId, projectId);
|
|
266
|
+
case 'trash':
|
|
267
|
+
return context.client.projects.trash(portalId, projectId);
|
|
268
|
+
case 'listComments':
|
|
269
|
+
return context.client.projects.listComments(portalId, projectId, query);
|
|
270
|
+
case 'getComment':
|
|
271
|
+
return context.client.projects.getComment(portalId, projectId, input.comment_id as string | number);
|
|
272
|
+
case 'addComment':
|
|
273
|
+
return context.client.projects.addComment(portalId, projectId, input.body as any);
|
|
274
|
+
case 'updateComment':
|
|
275
|
+
return context.client.projects.updateComment(portalId, projectId, input.comment_id as string | number, input.body as any);
|
|
276
|
+
case 'deleteComment':
|
|
277
|
+
return context.client.projects.deleteComment(portalId, projectId, input.comment_id as string | number);
|
|
278
|
+
case 'markFavouriteCustomView':
|
|
279
|
+
return context.client.projects.markFavouriteCustomView(portalId, input.custom_view_id as string | number);
|
|
280
|
+
default:
|
|
281
|
+
throw new Error(`Unsupported projects action: ${String(input.action)}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function executeProjectGroups(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
286
|
+
const portalId = input.portal_id as string | number;
|
|
287
|
+
const groupId = input.group_id as string | number;
|
|
288
|
+
const query = input.query as any;
|
|
289
|
+
switch (input.action) {
|
|
290
|
+
case 'list':
|
|
291
|
+
return context.client.projectGroups.list(portalId, query);
|
|
292
|
+
case 'listMine':
|
|
293
|
+
return context.client.projectGroups.listMine(portalId, query);
|
|
294
|
+
case 'create':
|
|
295
|
+
return context.client.projectGroups.create(portalId, input.body as any);
|
|
296
|
+
case 'update':
|
|
297
|
+
return context.client.projectGroups.update(portalId, groupId, input.body as any);
|
|
298
|
+
case 'deleteById':
|
|
299
|
+
return context.client.projectGroups.deleteById(portalId, groupId);
|
|
300
|
+
default:
|
|
301
|
+
throw new Error(`Unsupported project groups action: ${String(input.action)}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async function executePhases(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
306
|
+
const portalId = input.portal_id as string | number;
|
|
307
|
+
const projectId = input.project_id as string | number;
|
|
308
|
+
const phaseId = input.phase_id as string | number;
|
|
309
|
+
const commentId = input.comment_id as string | number;
|
|
310
|
+
const query = input.query as any;
|
|
311
|
+
switch (input.action) {
|
|
312
|
+
case 'list':
|
|
313
|
+
return context.client.phases.list(portalId, projectId, query);
|
|
314
|
+
case 'listAll':
|
|
315
|
+
return context.client.phases.listAll(portalId, query);
|
|
316
|
+
case 'getById':
|
|
317
|
+
return context.client.phases.getById(portalId, projectId, phaseId);
|
|
318
|
+
case 'create':
|
|
319
|
+
return context.client.phases.create(portalId, projectId, input.body as any);
|
|
320
|
+
case 'update':
|
|
321
|
+
return context.client.phases.update(portalId, projectId, phaseId, input.body as any);
|
|
322
|
+
case 'deleteById':
|
|
323
|
+
return context.client.phases.deleteById(portalId, projectId, phaseId);
|
|
324
|
+
case 'move':
|
|
325
|
+
return context.client.phases.move(portalId, projectId, phaseId, input.body as any);
|
|
326
|
+
case 'statusTimeline':
|
|
327
|
+
return context.client.phases.statusTimeline(portalId, projectId, phaseId);
|
|
328
|
+
case 'listComments':
|
|
329
|
+
return context.client.phases.listComments(portalId, projectId, phaseId, query);
|
|
330
|
+
case 'getComment':
|
|
331
|
+
return context.client.phases.getComment(portalId, projectId, phaseId, commentId);
|
|
332
|
+
case 'addComment':
|
|
333
|
+
return context.client.phases.addComment(portalId, projectId, phaseId, input.body as any);
|
|
334
|
+
case 'updateComment':
|
|
335
|
+
return context.client.phases.updateComment(portalId, projectId, phaseId, commentId, input.body as any);
|
|
336
|
+
case 'deleteComment':
|
|
337
|
+
return context.client.phases.deleteComment(portalId, projectId, phaseId, commentId);
|
|
338
|
+
case 'getFollowers':
|
|
339
|
+
return context.client.phases.getFollowers(portalId, projectId, phaseId, query);
|
|
340
|
+
case 'addFollowers':
|
|
341
|
+
return context.client.phases.addFollowers(portalId, projectId, phaseId, input.body as any);
|
|
342
|
+
case 'removeFollowers':
|
|
343
|
+
return context.client.phases.removeFollowers(portalId, projectId, phaseId, input.body as any);
|
|
344
|
+
default:
|
|
345
|
+
throw new Error(`Unsupported phases action: ${String(input.action)}`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async function executeTasklists(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
350
|
+
const portalId = input.portal_id as string | number;
|
|
351
|
+
const projectId = input.project_id as string | number;
|
|
352
|
+
const tasklistId = input.tasklist_id as string | number;
|
|
353
|
+
const commentId = input.comment_id as string | number;
|
|
354
|
+
const query = input.query as any;
|
|
355
|
+
switch (input.action) {
|
|
356
|
+
case 'list':
|
|
357
|
+
return context.client.tasklists.list(portalId, projectId, query);
|
|
358
|
+
case 'listAll':
|
|
359
|
+
return context.client.tasklists.listAll(portalId, query);
|
|
360
|
+
case 'getById':
|
|
361
|
+
return context.client.tasklists.getById(portalId, projectId, tasklistId);
|
|
362
|
+
case 'create':
|
|
363
|
+
return context.client.tasklists.create(portalId, projectId, input.body as any);
|
|
364
|
+
case 'createDefault':
|
|
365
|
+
return context.client.tasklists.createDefault(portalId, projectId, String(input.name ?? 'internal') as any);
|
|
366
|
+
case 'update':
|
|
367
|
+
return context.client.tasklists.update(portalId, projectId, tasklistId, input.body as any);
|
|
368
|
+
case 'deleteById':
|
|
369
|
+
return context.client.tasklists.deleteById(portalId, projectId, tasklistId);
|
|
370
|
+
case 'makeAsTemplate':
|
|
371
|
+
return context.client.tasklists.makeAsTemplate(portalId, projectId, tasklistId);
|
|
372
|
+
case 'getComments':
|
|
373
|
+
return context.client.tasklists.getComments(portalId, projectId, tasklistId, query);
|
|
374
|
+
case 'getComment':
|
|
375
|
+
return context.client.tasklists.getComment(portalId, projectId, tasklistId, commentId);
|
|
376
|
+
case 'addComment':
|
|
377
|
+
return context.client.tasklists.addComment(portalId, projectId, tasklistId, input.body as any);
|
|
378
|
+
case 'updateComment':
|
|
379
|
+
return context.client.tasklists.updateComment(portalId, projectId, tasklistId, commentId, input.body as any);
|
|
380
|
+
case 'deleteComment':
|
|
381
|
+
return context.client.tasklists.deleteComment(portalId, projectId, tasklistId, commentId);
|
|
382
|
+
case 'getFollowers':
|
|
383
|
+
return context.client.tasklists.getFollowers(portalId, projectId, tasklistId, query);
|
|
384
|
+
case 'addFollowers':
|
|
385
|
+
return context.client.tasklists.addFollowers(portalId, projectId, tasklistId, input.body as any);
|
|
386
|
+
case 'removeFollowers':
|
|
387
|
+
return context.client.tasklists.removeFollowers(portalId, projectId, tasklistId, input.body as any);
|
|
388
|
+
default:
|
|
389
|
+
throw new Error(`Unsupported tasklists action: ${String(input.action)}`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
async function executeTasks(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
394
|
+
const portalId = input.portal_id as string | number;
|
|
395
|
+
const projectId = input.project_id as string | number;
|
|
396
|
+
const taskId = input.task_id as string | number;
|
|
397
|
+
const query = input.query as any;
|
|
398
|
+
switch (input.action) {
|
|
399
|
+
case 'listAll':
|
|
400
|
+
return context.client.tasks.listAll(portalId, query);
|
|
401
|
+
case 'listMyTasks':
|
|
402
|
+
return context.client.tasks.listMyTasks(portalId, query);
|
|
403
|
+
case 'list':
|
|
404
|
+
return context.client.tasks.list(portalId, projectId, query);
|
|
405
|
+
case 'getById':
|
|
406
|
+
return context.client.tasks.getById(portalId, projectId, taskId);
|
|
407
|
+
case 'create':
|
|
408
|
+
return context.client.tasks.create(portalId, projectId, input.body as any);
|
|
409
|
+
case 'update':
|
|
410
|
+
return context.client.tasks.update(portalId, projectId, taskId, input.body as any);
|
|
411
|
+
case 'deleteById':
|
|
412
|
+
return context.client.tasks.deleteById(portalId, projectId, taskId);
|
|
413
|
+
case 'getStatusHistory':
|
|
414
|
+
return context.client.tasks.getStatusHistory(portalId, projectId, query);
|
|
415
|
+
case 'getAssociatedTasksByIssues':
|
|
416
|
+
return context.client.tasks.getAssociatedTasksByIssues(portalId, (input.issue_ids ?? []) as Array<string | number>, query);
|
|
417
|
+
default:
|
|
418
|
+
throw new Error(`Unsupported tasks action: ${String(input.action)}`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
async function executeIssues(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
423
|
+
const portalId = input.portal_id as string | number;
|
|
424
|
+
const projectId = input.project_id as string | number;
|
|
425
|
+
const issueId = input.issue_id as string | number;
|
|
426
|
+
const commentId = input.comment_id as string | number;
|
|
427
|
+
const taskId = input.task_id as string | number;
|
|
428
|
+
const attachmentId = input.attachment_id as string | number;
|
|
429
|
+
const query = input.query as any;
|
|
430
|
+
switch (input.action) {
|
|
431
|
+
case 'listAll':
|
|
432
|
+
return context.client.issues.listAll(portalId, query);
|
|
433
|
+
case 'list':
|
|
434
|
+
return context.client.issues.list(portalId, projectId, query);
|
|
435
|
+
case 'getById':
|
|
436
|
+
return context.client.issues.getById(portalId, projectId, issueId);
|
|
437
|
+
case 'create':
|
|
438
|
+
return context.client.issues.create(portalId, projectId, input.body as any);
|
|
439
|
+
case 'update':
|
|
440
|
+
return context.client.issues.update(portalId, projectId, issueId, input.body as any);
|
|
441
|
+
case 'deleteById':
|
|
442
|
+
return context.client.issues.deleteById(portalId, projectId, issueId);
|
|
443
|
+
case 'listCustomViews':
|
|
444
|
+
return context.client.issues.listCustomViews(portalId, projectId);
|
|
445
|
+
case 'move':
|
|
446
|
+
return context.client.issues.move(portalId, projectId, issueId, input.body as any);
|
|
447
|
+
case 'getComments':
|
|
448
|
+
return context.client.issues.getComments(portalId, projectId, issueId, query);
|
|
449
|
+
case 'getComment':
|
|
450
|
+
return context.client.issues.getComment(portalId, projectId, issueId, commentId);
|
|
451
|
+
case 'addComment':
|
|
452
|
+
return context.client.issues.addComment(portalId, projectId, issueId, input.body as any);
|
|
453
|
+
case 'updateComment':
|
|
454
|
+
return context.client.issues.updateComment(portalId, projectId, issueId, commentId, input.body as any);
|
|
455
|
+
case 'deleteComment':
|
|
456
|
+
return context.client.issues.deleteComment(portalId, projectId, issueId, commentId);
|
|
457
|
+
case 'getFollowers':
|
|
458
|
+
return context.client.issues.getFollowers(portalId, projectId, issueId, query);
|
|
459
|
+
case 'addFollowers':
|
|
460
|
+
return context.client.issues.addFollowers(portalId, projectId, issueId, input.body as any);
|
|
461
|
+
case 'removeFollowers':
|
|
462
|
+
return context.client.issues.removeFollowers(portalId, projectId, issueId, input.body as any);
|
|
463
|
+
case 'getLinkedIssues':
|
|
464
|
+
return context.client.issues.getLinkedIssues(portalId, projectId, issueId);
|
|
465
|
+
case 'associateTasks':
|
|
466
|
+
return context.client.issues.associateTasks(portalId, projectId, issueId, input.body as any);
|
|
467
|
+
case 'bulkAssociateTasks':
|
|
468
|
+
return context.client.issues.bulkAssociateTasks(portalId, projectId, input.body as any);
|
|
469
|
+
case 'bulkLinkIssues':
|
|
470
|
+
return context.client.issues.bulkLinkIssues(portalId, projectId, input.body as any);
|
|
471
|
+
case 'getAttachments':
|
|
472
|
+
return context.client.issues.getAttachments(portalId, projectId, issueId);
|
|
473
|
+
case 'addAttachments':
|
|
474
|
+
return context.client.issues.addAttachments(portalId, projectId, issueId, input.body as any);
|
|
475
|
+
case 'removeAttachment':
|
|
476
|
+
return context.client.issues.removeAttachment(portalId, projectId, issueId, attachmentId);
|
|
477
|
+
case 'dissociateTask':
|
|
478
|
+
return context.client.issues.dissociateTask(portalId, projectId, issueId, taskId);
|
|
479
|
+
case 'getStatusTransition':
|
|
480
|
+
return context.client.issues.getStatusTransition(portalId, projectId, issueId);
|
|
481
|
+
case 'addResolution':
|
|
482
|
+
return context.client.issues.addResolution(portalId, projectId, issueId, input.body as any);
|
|
483
|
+
case 'updateResolution':
|
|
484
|
+
return context.client.issues.updateResolution(portalId, projectId, issueId, input.body as any);
|
|
485
|
+
case 'getAssociatedTasks':
|
|
486
|
+
return context.client.issues.getAssociatedTasks(portalId, projectId, issueId, query);
|
|
487
|
+
case 'getAssociatedTasksByIssues':
|
|
488
|
+
return context.client.issues.getAssociatedTasksByIssues(portalId, (input.issue_ids ?? []) as Array<string | number>, query);
|
|
489
|
+
case 'getCommentAttachment':
|
|
490
|
+
return context.client.issues.getCommentAttachment(portalId, projectId, issueId, commentId);
|
|
491
|
+
default:
|
|
492
|
+
throw new Error(`Unsupported issues action: ${String(input.action)}`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
async function executeRecords(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
497
|
+
const portalId = input.portal_id as string | number;
|
|
498
|
+
const moduleName = String(input.module_name ?? '');
|
|
499
|
+
const entityId = input.entity_id as string | number;
|
|
500
|
+
const editId = input.edit_id as string | number;
|
|
501
|
+
const query = input.query as any;
|
|
502
|
+
switch (input.action) {
|
|
503
|
+
case 'createRecord':
|
|
504
|
+
return context.client.records.createRecord(portalId, moduleName, input.body as any);
|
|
505
|
+
case 'listEntityEdits':
|
|
506
|
+
return context.client.records.listEntityEdits(portalId, moduleName, entityId, query);
|
|
507
|
+
case 'getEditsByAuditId':
|
|
508
|
+
return context.client.records.getEditsByAuditId(portalId, moduleName, entityId, editId);
|
|
509
|
+
case 'getAttachmentCount':
|
|
510
|
+
return context.client.records.getAttachmentCount(portalId, moduleName, entityId);
|
|
511
|
+
case 'getFollowers':
|
|
512
|
+
return context.client.records.getFollowers(portalId, moduleName, entityId, query);
|
|
513
|
+
case 'addFollower':
|
|
514
|
+
return context.client.records.addFollower(portalId, moduleName, entityId);
|
|
515
|
+
case 'addOrRemoveFollowers':
|
|
516
|
+
return context.client.records.addOrRemoveFollowers(portalId, moduleName, entityId, input.body as any);
|
|
517
|
+
case 'removeFollower':
|
|
518
|
+
return context.client.records.removeFollower(portalId, moduleName, entityId);
|
|
519
|
+
case 'addComment':
|
|
520
|
+
return context.client.records.addComment(portalId, moduleName, entityId, input.body as any);
|
|
521
|
+
default:
|
|
522
|
+
throw new Error(`Unsupported records action: ${String(input.action)}`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
async function executeSettings(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
527
|
+
const portalId = input.portal_id as string | number;
|
|
528
|
+
const moduleName = String(input.module ?? '');
|
|
529
|
+
const layoutId = input.layout_id as string | number;
|
|
530
|
+
const fieldId = input.field_id as string | number;
|
|
531
|
+
const serviceId = input.service_id as string | number;
|
|
532
|
+
const viewId = input.view_id as string | number;
|
|
533
|
+
const query = input.query as any;
|
|
534
|
+
switch (input.action) {
|
|
535
|
+
case 'listModules':
|
|
536
|
+
return context.client.settings.listModules(portalId, query);
|
|
537
|
+
case 'getModule':
|
|
538
|
+
return context.client.settings.getModule(portalId, moduleName);
|
|
539
|
+
case 'createModule':
|
|
540
|
+
return context.client.settings.createModule(portalId, input.body as any);
|
|
541
|
+
case 'updateModule':
|
|
542
|
+
return context.client.settings.updateModule(portalId, moduleName, input.body as any);
|
|
543
|
+
case 'updateModuleStatus':
|
|
544
|
+
return context.client.settings.updateModuleStatus(portalId, moduleName, input.body as any);
|
|
545
|
+
case 'trashModule':
|
|
546
|
+
return context.client.settings.trashModule(portalId, moduleName, input.body as any);
|
|
547
|
+
case 'deleteModule':
|
|
548
|
+
return context.client.settings.deleteModule(portalId, moduleName);
|
|
549
|
+
case 'restoreModule':
|
|
550
|
+
return context.client.settings.restoreModule(portalId, moduleName, input.body as any);
|
|
551
|
+
case 'getModuleConfiguration':
|
|
552
|
+
return context.client.settings.getModuleConfiguration(portalId, moduleName);
|
|
553
|
+
case 'activateModule':
|
|
554
|
+
return context.client.settings.activateModule(portalId, moduleName);
|
|
555
|
+
case 'deactivateModule':
|
|
556
|
+
return context.client.settings.deactivateModule(portalId, moduleName);
|
|
557
|
+
case 'listLayouts':
|
|
558
|
+
return context.client.settings.listLayouts(portalId, query);
|
|
559
|
+
case 'getDefaultLayout':
|
|
560
|
+
return context.client.settings.getDefaultLayout(portalId, query);
|
|
561
|
+
case 'getLayoutDetails':
|
|
562
|
+
return context.client.settings.getLayoutDetails(portalId, layoutId);
|
|
563
|
+
case 'createLayout':
|
|
564
|
+
return context.client.settings.createLayout(portalId, input.body as any);
|
|
565
|
+
case 'updateLayout':
|
|
566
|
+
return context.client.settings.updateLayout(portalId, layoutId, input.body as any);
|
|
567
|
+
case 'deleteLayout':
|
|
568
|
+
return context.client.settings.deleteLayout(portalId, layoutId);
|
|
569
|
+
case 'disassociateFieldFromLayout':
|
|
570
|
+
return context.client.settings.disassociateFieldFromLayout(portalId, layoutId, fieldId);
|
|
571
|
+
case 'getAssociatedEntitiesOfLayout':
|
|
572
|
+
return context.client.settings.getAssociatedEntitiesOfLayout(portalId, layoutId);
|
|
573
|
+
case 'createOrUpdateSection':
|
|
574
|
+
return context.client.settings.createOrUpdateSection(portalId, layoutId, input.body as any);
|
|
575
|
+
case 'deleteSection':
|
|
576
|
+
return context.client.settings.deleteSection(portalId, layoutId, input.body as any);
|
|
577
|
+
case 'listFields':
|
|
578
|
+
return context.client.settings.listFields(portalId, query);
|
|
579
|
+
case 'createOrUpdateField':
|
|
580
|
+
return context.client.settings.createOrUpdateField(portalId, input.body as any);
|
|
581
|
+
case 'deleteField':
|
|
582
|
+
return context.client.settings.deleteField(portalId, input.body as any);
|
|
583
|
+
case 'getAssociatedLayouts':
|
|
584
|
+
return context.client.settings.getAssociatedLayouts(portalId, fieldId, query);
|
|
585
|
+
case 'getOptionsListForField':
|
|
586
|
+
return context.client.settings.getOptionsListForField(portalId, query);
|
|
587
|
+
case 'createBulkOptions':
|
|
588
|
+
return context.client.settings.createBulkOptions(portalId, input.body as any);
|
|
589
|
+
case 'deleteOrDisassociateBulkOptions':
|
|
590
|
+
return context.client.settings.deleteOrDisassociateBulkOptions(portalId, input.body as any);
|
|
591
|
+
case 'updateBulkOptions':
|
|
592
|
+
return context.client.settings.updateBulkOptions(portalId, input.body as any);
|
|
593
|
+
case 'getModuleIntegrationField':
|
|
594
|
+
return context.client.settings.getModuleIntegrationField(portalId, serviceId, moduleName);
|
|
595
|
+
case 'getViews':
|
|
596
|
+
return context.client.settings.getViews(portalId, viewId);
|
|
597
|
+
default:
|
|
598
|
+
throw new Error(`Unsupported settings action: ${String(input.action)}`);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async function executeTimeLogs(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
603
|
+
const portalId = input.portal_id as string | number;
|
|
604
|
+
const projectId = input.project_id as string | number;
|
|
605
|
+
const taskId = input.task_id as string | number;
|
|
606
|
+
const issueId = input.issue_id as string | number;
|
|
607
|
+
const logId = input.log_id as string | number;
|
|
608
|
+
const timerId = input.timer_id as string | number;
|
|
609
|
+
const entityType = input.entity_type as 'task' | 'issue';
|
|
610
|
+
const query = input.query as any;
|
|
611
|
+
switch (input.action) {
|
|
612
|
+
case 'listPortalTimeLogs':
|
|
613
|
+
return context.client.timeLogs.listPortalTimeLogs(portalId, query);
|
|
614
|
+
case 'listProjectTimeLogs':
|
|
615
|
+
return context.client.timeLogs.listProjectTimeLogs(portalId, projectId, query);
|
|
616
|
+
case 'getTimeLogDetail':
|
|
617
|
+
return context.client.timeLogs.getTimeLogDetail(portalId, projectId, logId, String(input.type ?? 'task') as 'task' | 'issue' | 'general');
|
|
618
|
+
case 'addTimeLog':
|
|
619
|
+
return context.client.timeLogs.addTimeLog(portalId, projectId, input.body as any);
|
|
620
|
+
case 'bulkUpdateTimeLogs':
|
|
621
|
+
return context.client.timeLogs.bulkUpdateTimeLogs(portalId, input.body as any);
|
|
622
|
+
case 'bulkDeleteTimeLogs':
|
|
623
|
+
return context.client.timeLogs.bulkDeleteTimeLogs(portalId, input.body as any);
|
|
624
|
+
case 'getPortalTimeLogReport':
|
|
625
|
+
return context.client.timeLogs.getPortalTimeLogReport(portalId, query);
|
|
626
|
+
case 'getProjectTimeLogReport':
|
|
627
|
+
return context.client.timeLogs.getProjectTimeLogReport(portalId, projectId, query);
|
|
628
|
+
case 'getDefaultApprover':
|
|
629
|
+
return context.client.timeLogs.getDefaultApprover(portalId, projectId);
|
|
630
|
+
case 'listPinnedPortalTimeLogs':
|
|
631
|
+
return context.client.timeLogs.listPinnedPortalTimeLogs(portalId);
|
|
632
|
+
case 'listPinnedProjectTimeLogs':
|
|
633
|
+
return context.client.timeLogs.listPinnedProjectTimeLogs(portalId, projectId);
|
|
634
|
+
case 'createPinnedPortalTimeLog':
|
|
635
|
+
return context.client.timeLogs.createPinnedPortalTimeLog(portalId, input.body as any);
|
|
636
|
+
case 'updatePinnedPortalTimeLog':
|
|
637
|
+
return context.client.timeLogs.updatePinnedPortalTimeLog(portalId, input.body as any);
|
|
638
|
+
case 'deletePinnedPortalTimeLog':
|
|
639
|
+
return context.client.timeLogs.deletePinnedPortalTimeLog(portalId, input.body as any);
|
|
640
|
+
case 'createPinnedProjectTimeLog':
|
|
641
|
+
return context.client.timeLogs.createPinnedProjectTimeLog(portalId, projectId, input.body as any);
|
|
642
|
+
case 'updatePinnedProjectTimeLog':
|
|
643
|
+
return context.client.timeLogs.updatePinnedProjectTimeLog(portalId, projectId, input.body as any);
|
|
644
|
+
case 'deletePinnedProjectTimeLog':
|
|
645
|
+
return context.client.timeLogs.deletePinnedProjectTimeLog(portalId, projectId, input.body as any);
|
|
646
|
+
case 'listRunningTimers':
|
|
647
|
+
return context.client.timeLogs.listRunningTimers(portalId, query);
|
|
648
|
+
case 'getTimerDetailsByLogId':
|
|
649
|
+
return context.client.timeLogs.getTimerDetailsByLogId(portalId, projectId, entityType, logId);
|
|
650
|
+
case 'startTimer':
|
|
651
|
+
return context.client.timeLogs.startTimer(portalId, input.body as any);
|
|
652
|
+
case 'pauseTimer':
|
|
653
|
+
return context.client.timeLogs.pauseTimer(portalId, timerId, input.body as any);
|
|
654
|
+
case 'resumeTimer':
|
|
655
|
+
return context.client.timeLogs.resumeTimer(portalId, timerId, input.body as any);
|
|
656
|
+
case 'stopTimer':
|
|
657
|
+
return context.client.timeLogs.stopTimer(portalId, timerId, input.body as any);
|
|
658
|
+
case 'deleteTimer':
|
|
659
|
+
return context.client.timeLogs.deleteTimer(portalId, timerId);
|
|
660
|
+
case 'getTimeLogSettingsMetaData':
|
|
661
|
+
return context.client.timeLogs.getTimeLogSettingsMetaData(portalId);
|
|
662
|
+
case 'getTimeLogSettings':
|
|
663
|
+
return context.client.timeLogs.getTimeLogSettings(portalId);
|
|
664
|
+
case 'updateTimeLogSettings':
|
|
665
|
+
return context.client.timeLogs.updateTimeLogSettings(portalId, input.body as any);
|
|
666
|
+
case 'listTaskLogs':
|
|
667
|
+
return context.client.timeLogs.listTaskLogs(portalId, projectId, taskId, query);
|
|
668
|
+
case 'addTaskLog':
|
|
669
|
+
return context.client.timeLogs.addTaskLog(portalId, projectId, taskId, input.body as any);
|
|
670
|
+
case 'updateTaskLog':
|
|
671
|
+
return context.client.timeLogs.updateTaskLog(portalId, projectId, taskId, logId, input.body as any);
|
|
672
|
+
case 'approveTaskLog':
|
|
673
|
+
return context.client.timeLogs.approveTaskLog(portalId, projectId, taskId, logId, input.body as any);
|
|
674
|
+
case 'deleteTaskLog':
|
|
675
|
+
return context.client.timeLogs.deleteTaskLog(portalId, projectId, taskId, logId);
|
|
676
|
+
case 'listBugLogs':
|
|
677
|
+
return context.client.timeLogs.listBugLogs(portalId, projectId, issueId, query);
|
|
678
|
+
case 'addBugLog':
|
|
679
|
+
return context.client.timeLogs.addBugLog(portalId, projectId, issueId, input.body as any);
|
|
680
|
+
case 'updateBugLog':
|
|
681
|
+
return context.client.timeLogs.updateBugLog(portalId, projectId, issueId, logId, input.body as any);
|
|
682
|
+
case 'approveBugLog':
|
|
683
|
+
return context.client.timeLogs.approveBugLog(portalId, projectId, issueId, logId, input.body as any);
|
|
684
|
+
case 'deleteBugLog':
|
|
685
|
+
return context.client.timeLogs.deleteBugLog(portalId, projectId, issueId, logId);
|
|
686
|
+
case 'addGeneralLog':
|
|
687
|
+
return context.client.timeLogs.addGeneralLog(portalId, projectId, input.body as any);
|
|
688
|
+
case 'updateGeneralLog':
|
|
689
|
+
return context.client.timeLogs.updateGeneralLog(portalId, projectId, logId, input.body as any);
|
|
690
|
+
case 'approveGeneralLog':
|
|
691
|
+
return context.client.timeLogs.approveGeneralLog(portalId, projectId, logId, input.body as any);
|
|
692
|
+
case 'deleteGeneralLog':
|
|
693
|
+
return context.client.timeLogs.deleteGeneralLog(portalId, projectId, logId);
|
|
694
|
+
case 'getTimesheetLayoutDetails':
|
|
695
|
+
return context.client.timeLogs.getTimesheetLayoutDetails(portalId, projectId);
|
|
696
|
+
case 'getAllTimesheetCustomFields':
|
|
697
|
+
return context.client.timeLogs.getAllTimesheetCustomFields(portalId);
|
|
698
|
+
default:
|
|
699
|
+
throw new Error(`Unsupported time logs action: ${String(input.action)}`);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
async function executeRequest(context: ZohoToolContext, input: Record<string, unknown>): Promise<unknown> {
|
|
704
|
+
const path = input.path as string;
|
|
705
|
+
const method = input.method as 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
706
|
+
return context.client.request(path, {
|
|
707
|
+
method,
|
|
708
|
+
query: input.query as any,
|
|
709
|
+
body: input.body,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const executors: Record<string, ToolExecutor> = {
|
|
714
|
+
zoho_projects_portals: executePortal,
|
|
715
|
+
zoho_projects_projects: executeProjects,
|
|
716
|
+
zoho_projects_project_groups: executeProjectGroups,
|
|
717
|
+
zoho_projects_phases: executePhases,
|
|
718
|
+
zoho_projects_tasklists: executeTasklists,
|
|
719
|
+
zoho_projects_tasks: executeTasks,
|
|
720
|
+
zoho_projects_issues: executeIssues,
|
|
721
|
+
zoho_projects_records: executeRecords,
|
|
722
|
+
zoho_projects_settings: executeSettings,
|
|
723
|
+
zoho_projects_time_logs: executeTimeLogs,
|
|
724
|
+
zoho_projects_request: executeRequest,
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
export function executeZohoProjectsTool(client: ZohoProjectsClient, toolName: string, input: Record<string, unknown> = {}): Promise<unknown> {
|
|
728
|
+
const executor = executors[toolName];
|
|
729
|
+
if (!executor) {
|
|
730
|
+
throw new Error(`Unknown Zoho Projects tool: ${toolName}`);
|
|
731
|
+
}
|
|
732
|
+
return executor({ client }, input);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
export function createZohoProjectsToolContext(client: ZohoProjectsClient): ZohoToolContext {
|
|
736
|
+
return { client };
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export function hasZohoProjectsTool(toolName: string): toolName is keyof typeof executors {
|
|
740
|
+
return toolName in executors;
|
|
741
|
+
}
|