@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const SRC_PREFIX = new URL('../src/', import.meta.url);
|
|
2
|
+
|
|
3
|
+
export function resolve(specifier, context, nextResolve) {
|
|
4
|
+
if (specifier.startsWith('@/')) {
|
|
5
|
+
const target = new URL(specifier.slice(2), SRC_PREFIX);
|
|
6
|
+
return nextResolve(target.href, context);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return nextResolve(specifier, context);
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { serializeQuery } from '@/query.ts';
|
|
4
|
+
|
|
5
|
+
test('serializeQuery encodes primitives and nested Zoho filters as JSON strings', () => {
|
|
6
|
+
const query = serializeQuery({
|
|
7
|
+
page: 1,
|
|
8
|
+
per_page: 20,
|
|
9
|
+
sort_by: 'ASC(last_modified_time)',
|
|
10
|
+
filter: {
|
|
11
|
+
criteria: [
|
|
12
|
+
{
|
|
13
|
+
field_name: 'status',
|
|
14
|
+
criteria_condition: 'contains',
|
|
15
|
+
value: [23806000000019001],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
pattern: '1',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const parsed = new URLSearchParams(query);
|
|
23
|
+
assert.equal(parsed.get('page'), '1');
|
|
24
|
+
assert.equal(parsed.get('per_page'), '20');
|
|
25
|
+
assert.equal(parsed.get('sort_by'), 'ASC(last_modified_time)');
|
|
26
|
+
assert.equal(
|
|
27
|
+
parsed.get('filter'),
|
|
28
|
+
JSON.stringify({
|
|
29
|
+
criteria: [
|
|
30
|
+
{
|
|
31
|
+
field_name: 'status',
|
|
32
|
+
criteria_condition: 'contains',
|
|
33
|
+
value: [23806000000019001],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
pattern: '1',
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('serializeQuery skips undefined values', () => {
|
|
42
|
+
const query = serializeQuery({ page: undefined, per_page: 10 });
|
|
43
|
+
const parsed = new URLSearchParams(query);
|
|
44
|
+
assert.equal(parsed.has('page'), false);
|
|
45
|
+
assert.equal(parsed.get('per_page'), '10');
|
|
46
|
+
});
|
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { ZohoProjectsClient } from '@/client.ts';
|
|
4
|
+
import { makeFetchStub, jsonResponse } from './helpers.ts';
|
|
5
|
+
|
|
6
|
+
test('core resource methods build the expected Zoho endpoints', async () => {
|
|
7
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
8
|
+
jsonResponse({ portals: [] }),
|
|
9
|
+
jsonResponse({ portal_details: { id: 1 } }),
|
|
10
|
+
jsonResponse({ projects: [] }),
|
|
11
|
+
jsonResponse({ id: 10 }),
|
|
12
|
+
jsonResponse({ id: 20 }),
|
|
13
|
+
jsonResponse({ id: 30 }),
|
|
14
|
+
jsonResponse({ id: 40 }),
|
|
15
|
+
jsonResponse({ id: 50 }),
|
|
16
|
+
jsonResponse({ id: 60 }),
|
|
17
|
+
jsonResponse({ id: 70 }),
|
|
18
|
+
jsonResponse({ id: 80 }),
|
|
19
|
+
jsonResponse({ id: 90 }),
|
|
20
|
+
jsonResponse({ id: 100 }),
|
|
21
|
+
jsonResponse({ id: 110 }),
|
|
22
|
+
jsonResponse({ id: 120 }),
|
|
23
|
+
jsonResponse({ id: 130 }),
|
|
24
|
+
jsonResponse({ comments: [] }),
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
28
|
+
|
|
29
|
+
await client.portals.listPortals();
|
|
30
|
+
await client.portals.getPortalDetails(11);
|
|
31
|
+
await client.projects.list(11);
|
|
32
|
+
await client.projects.getById(11, 22);
|
|
33
|
+
await client.projects.create(11, { name: 'Project A' });
|
|
34
|
+
await client.projects.update(11, 22, { name: 'Project B' });
|
|
35
|
+
await client.projects.listComments(11, 22, { page: 1, per_page: 10, sort_by: 'DESC(created_time)', view_id: 123, milestone_ids: '1,2' });
|
|
36
|
+
await client.tasklists.createDefault(11, 22, 'internal');
|
|
37
|
+
await client.tasklists.create(11, 22, { name: 'Tasklist' });
|
|
38
|
+
await client.tasks.getById(11, 22, 33);
|
|
39
|
+
await client.tasks.create(11, 22, { name: 'Task A' });
|
|
40
|
+
await client.issues.getComments(11, 22, 44);
|
|
41
|
+
await client.issues.bulkAssociateTasks(11, 22, { issue_ids: ['1'], task_ids: ['2'] });
|
|
42
|
+
await client.customFields.getFields(11, 'tasks', { page: 1, per_page: 10 });
|
|
43
|
+
await client.moduleMeta.getModule(11, 'risk');
|
|
44
|
+
await client.portals.moveRecordsToTrash(11, { module: 'tasks', items: ['1', '2'] });
|
|
45
|
+
await client.portals.restoreRecordsFromTrash(11, [{ module: 'tasks', items: ['1'] }]);
|
|
46
|
+
|
|
47
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal');
|
|
48
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11');
|
|
49
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects');
|
|
50
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22');
|
|
51
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects');
|
|
52
|
+
assert.equal(String(calls[5].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22');
|
|
53
|
+
assert.equal(String(calls[6].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/comments?page=1&per_page=10&sort_by=DESC%28created_time%29&view_id=123&milestone_ids=1%2C2');
|
|
54
|
+
assert.equal(String(calls[7].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/default-tasklists');
|
|
55
|
+
assert.equal(String(calls[8].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists');
|
|
56
|
+
assert.equal(String(calls[9].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasks/33');
|
|
57
|
+
assert.equal(String(calls[10].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasks');
|
|
58
|
+
assert.equal(String(calls[11].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/44/comments');
|
|
59
|
+
assert.equal(String(calls[12].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/bulk-associate-tasks');
|
|
60
|
+
assert.equal(String(calls[13].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/fields?page=1&per_page=10&module=tasks');
|
|
61
|
+
assert.equal(String(calls[14].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/modules/risk');
|
|
62
|
+
assert.equal(String(calls[15].input), 'https://projectsapi.zoho.com/api/v3/portal/11/trash');
|
|
63
|
+
assert.equal(String(calls[16].input), 'https://projectsapi.zoho.com/api/v3/portal/11/bin/restore');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('scheduleDataBackup sends form data', async () => {
|
|
67
|
+
const { fetchStub, calls } = makeFetchStub([jsonResponse({ id: 'backup' })]);
|
|
68
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
69
|
+
|
|
70
|
+
await client.portals.scheduleDataBackup(11, 'secret');
|
|
71
|
+
|
|
72
|
+
assert.equal(calls[0].init?.method, 'POST');
|
|
73
|
+
assert.equal(calls[0].init?.body instanceof FormData, true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('settings, records, phases, and list helpers map to documented endpoints', async () => {
|
|
77
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
78
|
+
jsonResponse({ modules: [] }),
|
|
79
|
+
jsonResponse({ id: 'layout-default' }),
|
|
80
|
+
jsonResponse({ id: 'layout' }),
|
|
81
|
+
jsonResponse({ id: 'created-layout' }),
|
|
82
|
+
jsonResponse({ ok: true }),
|
|
83
|
+
jsonResponse({ fields: [] }),
|
|
84
|
+
jsonResponse({ associated_layouts: [] }),
|
|
85
|
+
jsonResponse({ options: [] }),
|
|
86
|
+
jsonResponse({ id: 'record' }),
|
|
87
|
+
jsonResponse({ edits: [] }),
|
|
88
|
+
jsonResponse({ attachment_count: 3 }),
|
|
89
|
+
jsonResponse({ followers: [] }),
|
|
90
|
+
jsonResponse({ ok: true }),
|
|
91
|
+
jsonResponse({ ok: true }),
|
|
92
|
+
jsonResponse({ ok: true }),
|
|
93
|
+
jsonResponse({ tasklists: [] }),
|
|
94
|
+
jsonResponse({ comments: [] }),
|
|
95
|
+
jsonResponse({ followers: [] }),
|
|
96
|
+
jsonResponse({ ok: true }),
|
|
97
|
+
jsonResponse({ ok: true }),
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
101
|
+
|
|
102
|
+
await client.settings.listModules(11, { page: 1, per_page: 10, filter: { is_customized: true } });
|
|
103
|
+
await client.settings.getDefaultLayout(11, { module: 'Risk' });
|
|
104
|
+
await client.settings.getLayoutDetails(11, 7000);
|
|
105
|
+
await client.settings.createLayout(11, { module: 'Risk', name: 'Layout A' });
|
|
106
|
+
await client.settings.createOrUpdateSection(11, 7000, { module: 'Risk', id: 1, name: 'Section A' });
|
|
107
|
+
await client.settings.listFields(11, { module: 'Risk' });
|
|
108
|
+
await client.settings.getAssociatedLayouts(11, 400, { module: 'Risk' });
|
|
109
|
+
await client.settings.getOptionsListForField(11, { module: 'Risk', field: 400, page: 1, per_page: 10 });
|
|
110
|
+
await client.records.createRecord(11, 'risk', { name: 'Record A' });
|
|
111
|
+
await client.records.listEntityEdits(11, 'risk', 501, { index: 1, range: 50 });
|
|
112
|
+
await client.records.getEditsByAuditId(11, 'risk', 501, 900);
|
|
113
|
+
await client.records.getAttachmentCount(11, 'risk', 501);
|
|
114
|
+
await client.records.getFollowers(11, 'risk', 501, { page: 1, per_page: 10 });
|
|
115
|
+
await client.records.addFollower(11, 'risk', 501);
|
|
116
|
+
await client.records.addOrRemoveFollowers(11, 'risk', 501, { add: [{ zpuid: '1' }], remove: [{ zpuid: '2' }], zpuid: '1' });
|
|
117
|
+
await client.records.removeFollower(11, 'risk', 501);
|
|
118
|
+
await client.phases.list(11, 22, { page: 1, per_page: 10 });
|
|
119
|
+
await client.phases.statusTimeline(11, 22, 33);
|
|
120
|
+
await client.tasks.listMyTasks(11, { page: 1, per_page: 20 });
|
|
121
|
+
await client.tasklists.listAll(11, { page: 1, per_page: 20 });
|
|
122
|
+
|
|
123
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/modules?page=1&per_page=10&filter=%7B%22is_customized%22%3Atrue%7D');
|
|
124
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/layouts/default-layout?module=Risk');
|
|
125
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/layouts/7000');
|
|
126
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/layouts');
|
|
127
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/layouts/7000/sections');
|
|
128
|
+
assert.equal(String(calls[5].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/fields?module=Risk');
|
|
129
|
+
assert.equal(String(calls[6].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/fields/400/associated-layouts?module=Risk');
|
|
130
|
+
assert.equal(String(calls[7].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/options?module=Risk&field=400&page=1&per_page=10');
|
|
131
|
+
assert.equal(String(calls[8].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entities');
|
|
132
|
+
assert.equal(String(calls[9].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entity/501/edits?index=1&range=50');
|
|
133
|
+
assert.equal(String(calls[10].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entity/501/edits/900');
|
|
134
|
+
assert.equal(String(calls[11].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entity/501/attachmentcount');
|
|
135
|
+
assert.equal(String(calls[12].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entity/501/followers?page=1&per_page=10');
|
|
136
|
+
assert.equal(String(calls[13].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entity/501/follow');
|
|
137
|
+
assert.equal(String(calls[14].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entity/501/followers');
|
|
138
|
+
assert.equal(String(calls[15].input), 'https://projectsapi.zoho.com/api/v3/portal/11/module/risk/entity/501/unfollow');
|
|
139
|
+
assert.equal(String(calls[16].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases?page=1&per_page=10');
|
|
140
|
+
assert.equal(String(calls[17].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases/33/status-timeline');
|
|
141
|
+
assert.equal(String(calls[18].input), 'https://projectsapi.zoho.com/api/v3/portal/11/mytasks?page=1&per_page=20');
|
|
142
|
+
assert.equal(String(calls[19].input), 'https://projectsapi.zoho.com/api/v3/portal/11/all-tasklists?page=1&per_page=20');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('tasklist and issue comment/follower helpers map to documented endpoints', async () => {
|
|
146
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
147
|
+
jsonResponse({ comments: [] }),
|
|
148
|
+
jsonResponse({ id: 1 }),
|
|
149
|
+
jsonResponse({ ok: true }),
|
|
150
|
+
jsonResponse({ ok: true }),
|
|
151
|
+
jsonResponse({ followers: [] }),
|
|
152
|
+
jsonResponse({ ok: true }),
|
|
153
|
+
jsonResponse({ ok: true }),
|
|
154
|
+
jsonResponse({ attachments: [] }),
|
|
155
|
+
jsonResponse({ transitions: [] }),
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
159
|
+
|
|
160
|
+
await client.tasklists.getComments(11, 22, 33, { page: 1, per_page: 10, sort_by: 'ASC(last_modified_time)' });
|
|
161
|
+
await client.tasklists.getComment(11, 22, 33, 44);
|
|
162
|
+
await client.tasklists.addComment(11, 22, 33, { content: 'Hello world', attachments: [1] });
|
|
163
|
+
await client.tasklists.deleteComment(11, 22, 33, 44);
|
|
164
|
+
await client.tasklists.getFollowers(11, 22, 33, { page: 1, per_page: 10 });
|
|
165
|
+
await client.tasklists.addFollowers(11, 22, 33, { followers: [1] });
|
|
166
|
+
await client.tasklists.removeFollowers(11, 22, 33, { follower_ids: [1] });
|
|
167
|
+
await client.issues.getAttachments(11, 22, 55);
|
|
168
|
+
await client.issues.getStatusTransition(11, 22, 55);
|
|
169
|
+
|
|
170
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/comments?page=1&per_page=10&sort_by=ASC%28last_modified_time%29');
|
|
171
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/comments/44');
|
|
172
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/comments');
|
|
173
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/comments/44');
|
|
174
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/followers?page=1&per_page=10');
|
|
175
|
+
assert.equal(String(calls[5].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/follow');
|
|
176
|
+
assert.equal(String(calls[6].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/unfollow');
|
|
177
|
+
assert.equal(String(calls[7].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/attachments');
|
|
178
|
+
assert.equal(String(calls[8].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/statustransition');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('new task and issue helpers map to documented endpoints', async () => {
|
|
182
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
183
|
+
jsonResponse({ tasks: [] }),
|
|
184
|
+
jsonResponse({ status_history: [] }),
|
|
185
|
+
jsonResponse({ tasks: [] }),
|
|
186
|
+
jsonResponse({ ok: true }),
|
|
187
|
+
jsonResponse({ id: 1 }),
|
|
188
|
+
jsonResponse({ ok: true }),
|
|
189
|
+
jsonResponse({ followers: [] }),
|
|
190
|
+
jsonResponse({ ok: true }),
|
|
191
|
+
jsonResponse({ ok: true }),
|
|
192
|
+
jsonResponse({ linkedissues: [] }),
|
|
193
|
+
jsonResponse({ ok: true }),
|
|
194
|
+
jsonResponse({ is_already_mapped: true }),
|
|
195
|
+
jsonResponse({ ok: true }),
|
|
196
|
+
jsonResponse({ ok: true }),
|
|
197
|
+
jsonResponse({ ok: true }),
|
|
198
|
+
jsonResponse({ ok: true }),
|
|
199
|
+
jsonResponse({ ok: true }),
|
|
200
|
+
]);
|
|
201
|
+
|
|
202
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
203
|
+
|
|
204
|
+
await client.tasks.listAll(11, { page: 1, per_page: 20 });
|
|
205
|
+
await client.tasks.getStatusHistory(11, 22, { page: 1, per_page: 10, last_modified_time: 123 });
|
|
206
|
+
await client.tasks.getAssociatedTasksByIssues(11, ['1', '2'], { page: 1, per_page: 10 });
|
|
207
|
+
await client.tasklists.makeAsTemplate(11, 22, 33);
|
|
208
|
+
await client.issues.create(11, 22, { name: 'Issue A' });
|
|
209
|
+
await client.issues.deleteById(11, 22, 44);
|
|
210
|
+
await client.issues.getFollowers(11, 22, 55);
|
|
211
|
+
await client.issues.addFollowers(11, 22, 55);
|
|
212
|
+
await client.issues.removeFollowers(11, 22, 55);
|
|
213
|
+
await client.issues.getLinkedIssues(11, 22, 55);
|
|
214
|
+
await client.issues.associateTasks(11, 22, 55, { task_ids: ['9'] });
|
|
215
|
+
await client.issues.bulkLinkIssues(11, 22, { link_type: 'relate', issue_ids: ['1'], linking_issue_ids: ['2'] });
|
|
216
|
+
await client.issues.addAttachments(11, 22, 55, { attachment_ids: ['1'] });
|
|
217
|
+
await client.issues.removeAttachment(11, 22, 55, 66);
|
|
218
|
+
await client.issues.addResolution(11, 22, 55, { resolution: 'done' });
|
|
219
|
+
await client.issues.updateResolution(11, 22, 55, { resolution: 'done' });
|
|
220
|
+
await client.issues.getCommentAttachment(11, 22, 55, 77);
|
|
221
|
+
|
|
222
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/tasks?page=1&per_page=20');
|
|
223
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/taskstatushistory?page=1&per_page=10&last_modified_time=123');
|
|
224
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/issues/associated-tasks?page=1&per_page=10&issue_ids=%5B%221%22%2C%222%22%5D');
|
|
225
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasklists/33/make-as-template');
|
|
226
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues');
|
|
227
|
+
assert.equal(String(calls[5].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/44');
|
|
228
|
+
assert.equal(String(calls[6].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/followers');
|
|
229
|
+
assert.equal(String(calls[7].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/followers');
|
|
230
|
+
assert.equal(String(calls[8].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/followers');
|
|
231
|
+
assert.equal(String(calls[9].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/linkedissues');
|
|
232
|
+
assert.equal(String(calls[10].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/associate-tasks');
|
|
233
|
+
assert.equal(String(calls[11].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/bulk-link-bugs');
|
|
234
|
+
assert.equal(String(calls[12].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/attachments');
|
|
235
|
+
assert.equal(String(calls[13].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/attachments/66');
|
|
236
|
+
assert.equal(String(calls[14].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/resolution');
|
|
237
|
+
assert.equal(String(calls[15].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/resolution');
|
|
238
|
+
assert.equal(String(calls[16].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/55/attachments/comments?comment_id=77');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('time log helpers map to legacy Zoho timesheets endpoints', async () => {
|
|
242
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
243
|
+
jsonResponse({ timelogs: [] }),
|
|
244
|
+
jsonResponse({ timelogs: [] }),
|
|
245
|
+
jsonResponse({ timelogs: [] }),
|
|
246
|
+
jsonResponse({ timelogs: [] }),
|
|
247
|
+
jsonResponse({ timelogs: [] }),
|
|
248
|
+
jsonResponse({ timelogs: [] }),
|
|
249
|
+
jsonResponse({ response: 'ok' }),
|
|
250
|
+
jsonResponse({ timelogs: [] }),
|
|
251
|
+
jsonResponse({ timelogs: [] }),
|
|
252
|
+
jsonResponse({ response: 'ok' }),
|
|
253
|
+
jsonResponse({ response: 'ok' }),
|
|
254
|
+
jsonResponse({ layout_id: '1' }),
|
|
255
|
+
jsonResponse([{ id: '10' }]),
|
|
256
|
+
]);
|
|
257
|
+
|
|
258
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
259
|
+
|
|
260
|
+
await client.timeLogs.listProjectLogs(11, 22, { index: 1, range: 10, users_list: 'all', view_type: 'day', date: '03-25-2021', bill_status: 'All', component_type: 'task' });
|
|
261
|
+
await client.timeLogs.listMyLogs(11, { index: 1, range: 10, users_list: 99, view_type: 'week', date: '03-25-2021', bill_status: 'Billable', component_type: 'general' });
|
|
262
|
+
await client.timeLogs.listTaskLogs(11, 22, 33, { index: 1, range: 10, users_list: 'all', view_type: 'month', date: '03-25-2021', bill_status: 'Non Billable', component_type: 'task' });
|
|
263
|
+
await client.timeLogs.addTaskLog(11, 22, 33, { date: '03-25-2021', owner: 77, bill_status: 'Billable', hours: '02:00', notes: 'Work log', custom_fields: { UDF_CHAR1: 'Hello' } });
|
|
264
|
+
await client.timeLogs.updateTaskLog(11, 22, 33, 44, { date: '03-25-2021', owner: 77, bill_status: 'Billable', hours: '03:00', notes: 'Updated log' });
|
|
265
|
+
await client.timeLogs.approveTaskLog(11, 22, 33, 44, { approval: 'approve' });
|
|
266
|
+
await client.timeLogs.deleteTaskLog(11, 22, 33, 44);
|
|
267
|
+
await client.timeLogs.listBugLogs(11, 22, 55, { index: 1, range: 10, users_list: 'all', view_type: 'custom_date', custom_date: { start_date: '03-01-2021', end_date: '03-31-2021' }, bill_status: 'Billable', component_type: 'bug' });
|
|
268
|
+
await client.timeLogs.addBugLog(11, 22, 55, { date: '03-25-2021', owner: 77, bill_status: 'Non Billable', hours: '01:30', notes: 'Bug work' });
|
|
269
|
+
await client.timeLogs.addGeneralLog(11, 22, { name: 'General Work', date: '03-25-2021', owner: 77, bill_status: 'Billable', hours: '04:00', notes: 'General log' });
|
|
270
|
+
await client.timeLogs.getTimesheetLayoutDetails(11, 22);
|
|
271
|
+
await client.timeLogs.getAllTimesheetCustomFields(11);
|
|
272
|
+
|
|
273
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/logs?index=1&range=10&users_list=all&view_type=day&date=03-25-2021&bill_status=All&component_type=task');
|
|
274
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/logs?index=1&range=10&users_list=99&view_type=week&date=03-25-2021&bill_status=Billable&component_type=general');
|
|
275
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasks/33/logs?index=1&range=10&users_list=all&view_type=month&date=03-25-2021&bill_status=Non+Billable&component_type=task');
|
|
276
|
+
assert.equal(calls[3].init?.method, 'POST');
|
|
277
|
+
assert.equal(calls[3].init?.body instanceof FormData, true);
|
|
278
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasks/33/logs');
|
|
279
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasks/33/logs/44');
|
|
280
|
+
assert.equal(String(calls[5].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasks/33/logs/44/approval');
|
|
281
|
+
assert.equal(String(calls[6].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/tasks/33/logs/44');
|
|
282
|
+
assert.equal(String(calls[7].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/bugs/55/logs?index=1&range=10&users_list=all&view_type=custom_date&custom_date=%7B%22start_date%22%3A%2203-01-2021%22%2C%22end_date%22%3A%2203-31-2021%22%7D&bill_status=Billable&component_type=bug');
|
|
283
|
+
assert.equal(String(calls[8].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/bugs/55/logs');
|
|
284
|
+
assert.equal(String(calls[9].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/logs');
|
|
285
|
+
assert.equal(String(calls[10].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/timesheetlayouts');
|
|
286
|
+
assert.equal(String(calls[11].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timesheetcustomfields');
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('official time log sections map to Zoho API endpoints', async () => {
|
|
290
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
291
|
+
jsonResponse({ timelogs: [] }),
|
|
292
|
+
jsonResponse({ timelogs: [] }),
|
|
293
|
+
jsonResponse({ timelog: {} }),
|
|
294
|
+
jsonResponse({ id: 1 }),
|
|
295
|
+
jsonResponse({ ok: true }),
|
|
296
|
+
jsonResponse({ ok: true }),
|
|
297
|
+
jsonResponse({ report: [] }),
|
|
298
|
+
jsonResponse({ report: [] }),
|
|
299
|
+
jsonResponse({ approver: {} }),
|
|
300
|
+
jsonResponse({ pin: [] }),
|
|
301
|
+
jsonResponse({ pin: [] }),
|
|
302
|
+
jsonResponse({ ok: true }),
|
|
303
|
+
jsonResponse({ timers: [] }),
|
|
304
|
+
jsonResponse({ timer: {} }),
|
|
305
|
+
jsonResponse({ ok: true }),
|
|
306
|
+
jsonResponse({ ok: true }),
|
|
307
|
+
jsonResponse({ ok: true }),
|
|
308
|
+
jsonResponse({ ok: true }),
|
|
309
|
+
jsonResponse({ ok: true }),
|
|
310
|
+
jsonResponse({ ok: true }),
|
|
311
|
+
jsonResponse({ meta: true }),
|
|
312
|
+
jsonResponse({ timelog_settings_response: {} }),
|
|
313
|
+
jsonResponse({ timelog_settings_response: {} }),
|
|
314
|
+
]);
|
|
315
|
+
|
|
316
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
317
|
+
|
|
318
|
+
await client.timeLogs.listPortalTimeLogs(11, { page: 1, per_page: 10, view_type: 'day' });
|
|
319
|
+
await client.timeLogs.listProjectTimeLogs(11, 22, { page: 1, per_page: 10, view_type: 'week' });
|
|
320
|
+
await client.timeLogs.getTimeLogDetail(11, 22, 33, 'task');
|
|
321
|
+
await client.timeLogs.addTimeLog(11, 22, { date: '2024-12-11', type: 'task', bill_status: 'Billable' });
|
|
322
|
+
await client.timeLogs.bulkUpdateTimeLogs(11, { id: 33, date: '2024-12-12', type: 'task', bill_status: 'Billable' });
|
|
323
|
+
await client.timeLogs.bulkDeleteTimeLogs(11, { id: 33, module: 'task' });
|
|
324
|
+
await client.timeLogs.getPortalTimeLogReport(11, { page: 1, per_page: 10, report_type: 'user', view_type: 'day', start_date: '2024-12-11' });
|
|
325
|
+
await client.timeLogs.getProjectTimeLogReport(11, 22, { page: 1, per_page: 10, report_type: 'module', view_type: 'month', start_date: '2024-12-11' });
|
|
326
|
+
await client.timeLogs.getDefaultApprover(11, 22);
|
|
327
|
+
await client.timeLogs.listPinnedPortalTimeLogs(11);
|
|
328
|
+
await client.timeLogs.listPinnedProjectTimeLogs(11, 22);
|
|
329
|
+
await client.timeLogs.createPinnedProjectTimeLog(11, 22, { log_id: 1 });
|
|
330
|
+
await client.timeLogs.listRunningTimers(11, { type: 'all', for_all: 'true' });
|
|
331
|
+
await client.timeLogs.getTimerDetailsByLogId(11, 22, 'task', 33);
|
|
332
|
+
await client.timeLogs.startTimer(11, { type: 'task', log_id: 33, entity_id: 44, notes: 'start' });
|
|
333
|
+
await client.timeLogs.pauseTimer(11, 55, { type: 'task', log_id: 33, entity_id: 44, notes: 'pause' });
|
|
334
|
+
await client.timeLogs.resumeTimer(11, 55, { type: 'task', log_id: 33, entity_id: 44, notes: 'resume' });
|
|
335
|
+
await client.timeLogs.stopTimer(11, 55, { item_id: 1, log_name: 'work', date: '2024-12-11', project_id: 22, type: 'task', hours: '01.00', start_time: '01:00 AM', end_time: '02:00 AM', bill_status: 'Billable', notes: 'stop' });
|
|
336
|
+
await client.timeLogs.deleteTimer(11, 55);
|
|
337
|
+
await client.timeLogs.getTimeLogSettingsMetaData(11);
|
|
338
|
+
await client.timeLogs.getTimeLogSettings(11);
|
|
339
|
+
await client.timeLogs.updateTimeLogSettings(11, { allow_timelog_for: 'everyone' });
|
|
340
|
+
|
|
341
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/logs?page=1&per_page=10&view_type=day');
|
|
342
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/logs?page=1&per_page=10&view_type=week');
|
|
343
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/logs/33?type=task');
|
|
344
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/logs');
|
|
345
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs');
|
|
346
|
+
assert.equal(String(calls[5].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs');
|
|
347
|
+
assert.equal(String(calls[6].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/report?page=1&per_page=10&report_type=user&view_type=day&start_date=2024-12-11');
|
|
348
|
+
assert.equal(String(calls[7].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/timelogs/report?page=1&per_page=10&report_type=module&view_type=month&start_date=2024-12-11');
|
|
349
|
+
assert.equal(String(calls[8].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/timelogs/approver');
|
|
350
|
+
assert.equal(String(calls[9].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/pin');
|
|
351
|
+
assert.equal(String(calls[10].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/timelogs/pin');
|
|
352
|
+
assert.equal(String(calls[11].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/timelogs/pin');
|
|
353
|
+
assert.equal(String(calls[12].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/timers?type=all&for_all=true');
|
|
354
|
+
assert.equal(String(calls[13].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/task/logs/33/timers');
|
|
355
|
+
assert.equal(String(calls[14].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/timers');
|
|
356
|
+
assert.equal(String(calls[15].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/timers/55/pause');
|
|
357
|
+
assert.equal(String(calls[16].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/timers/55/resume');
|
|
358
|
+
assert.equal(String(calls[17].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/timers/55/stop');
|
|
359
|
+
assert.equal(String(calls[18].input), 'https://projectsapi.zoho.com/api/v3/portal/11/timelogs/timers/55');
|
|
360
|
+
assert.equal(String(calls[19].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/timelog/meta-data');
|
|
361
|
+
assert.equal(String(calls[20].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/timelog');
|
|
362
|
+
assert.equal(String(calls[21].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/timelog');
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test('project, phase, and issue comment helpers map to documented endpoints', async () => {
|
|
366
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
367
|
+
jsonResponse({ comments: [] }),
|
|
368
|
+
jsonResponse({ id: 1 }),
|
|
369
|
+
jsonResponse({ ok: true }),
|
|
370
|
+
jsonResponse({ ok: true }),
|
|
371
|
+
jsonResponse({ ok: true }),
|
|
372
|
+
jsonResponse({ comments: [] }),
|
|
373
|
+
jsonResponse({ id: 2 }),
|
|
374
|
+
jsonResponse({ ok: true }),
|
|
375
|
+
jsonResponse({ ok: true }),
|
|
376
|
+
jsonResponse({ ok: true }),
|
|
377
|
+
jsonResponse({ comments: [] }),
|
|
378
|
+
jsonResponse({ id: 3 }),
|
|
379
|
+
jsonResponse({ ok: true }),
|
|
380
|
+
jsonResponse({ ok: true }),
|
|
381
|
+
jsonResponse({ ok: true }),
|
|
382
|
+
]);
|
|
383
|
+
|
|
384
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
385
|
+
|
|
386
|
+
await client.projects.listComments(11, 22, { page: 1, per_page: 10 });
|
|
387
|
+
await client.projects.getComment(11, 22, 33);
|
|
388
|
+
await client.projects.addComment(11, 22, { content: 'Project comment' });
|
|
389
|
+
await client.projects.updateComment(11, 22, 33, { content: 'Updated project comment' });
|
|
390
|
+
await client.projects.deleteComment(11, 22, 33);
|
|
391
|
+
await client.phases.listComments(11, 22, 44, { page: 1, per_page: 10 });
|
|
392
|
+
await client.phases.getComment(11, 22, 44, 55);
|
|
393
|
+
await client.phases.addComment(11, 22, 44, { content: 'Phase comment' });
|
|
394
|
+
await client.phases.updateComment(11, 22, 44, 55, { content: 'Updated phase comment' });
|
|
395
|
+
await client.phases.deleteComment(11, 22, 44, 55);
|
|
396
|
+
await client.issues.getComments(11, 22, 66, { page: 1, per_page: 10 });
|
|
397
|
+
await client.issues.getComment(11, 22, 66, 77);
|
|
398
|
+
await client.issues.addComment(11, 22, 66, { content: 'Issue comment' });
|
|
399
|
+
await client.issues.updateComment(11, 22, 66, 77, { content: 'Updated issue comment' });
|
|
400
|
+
await client.issues.deleteComment(11, 22, 66, 77);
|
|
401
|
+
|
|
402
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/comments?page=1&per_page=10');
|
|
403
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/comments/33');
|
|
404
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/comments');
|
|
405
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/comments/33');
|
|
406
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/comments/33');
|
|
407
|
+
assert.equal(String(calls[5].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases/44/comments?page=1&per_page=10');
|
|
408
|
+
assert.equal(String(calls[6].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases/44/comments/55');
|
|
409
|
+
assert.equal(String(calls[7].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases/44/comments');
|
|
410
|
+
assert.equal(String(calls[8].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases/44/comments/55');
|
|
411
|
+
assert.equal(String(calls[9].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases/44/comments/55');
|
|
412
|
+
assert.equal(String(calls[10].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/66/comments?page=1&per_page=10');
|
|
413
|
+
assert.equal(String(calls[11].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/66/comments/77');
|
|
414
|
+
assert.equal(String(calls[12].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/66/comments');
|
|
415
|
+
assert.equal(String(calls[13].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/66/comments/77');
|
|
416
|
+
assert.equal(String(calls[14].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/66/comments/77');
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
test('project trash, favorite view, phase move, and issue move helpers map to documented endpoints', async () => {
|
|
420
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
421
|
+
jsonResponse({ ok: true }),
|
|
422
|
+
jsonResponse({ ok: true }),
|
|
423
|
+
jsonResponse({ ok: true }),
|
|
424
|
+
jsonResponse({ ok: true }),
|
|
425
|
+
jsonResponse({ ok: true }),
|
|
426
|
+
]);
|
|
427
|
+
|
|
428
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
429
|
+
|
|
430
|
+
await client.projects.trash(11, 22);
|
|
431
|
+
await client.projects.markFavouriteCustomView(11, 33);
|
|
432
|
+
await client.phases.move(11, 22, 44, { to_project: 55 });
|
|
433
|
+
await client.issues.move(11, 22, 66, { to_project: 77 });
|
|
434
|
+
await client.issues.dissociateTask(11, 22, 66, 88);
|
|
435
|
+
|
|
436
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/trash');
|
|
437
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/customview/33/markfavourite');
|
|
438
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/phases/44/move');
|
|
439
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/66/move');
|
|
440
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/66/task/88');
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
test('issue portal list, custom views, and associated tasks helpers map to documented endpoints', async () => {
|
|
444
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
445
|
+
jsonResponse({ issues: [] }),
|
|
446
|
+
jsonResponse({ customviews: [] }),
|
|
447
|
+
jsonResponse({ associated_tasks: [] }),
|
|
448
|
+
jsonResponse({ associated_tasks: [] }),
|
|
449
|
+
]);
|
|
450
|
+
|
|
451
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
452
|
+
|
|
453
|
+
await client.issues.listAll(11, { page: 1, per_page: 20 });
|
|
454
|
+
await client.issues.listCustomViews(11, 22);
|
|
455
|
+
await client.issues.getAssociatedTasks(11, 22, 33, { page: 1, per_page: 10 });
|
|
456
|
+
await client.issues.getAssociatedTasksByIssues(11, ['1', '2'], { page: 1, per_page: 10 });
|
|
457
|
+
|
|
458
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/issues?page=1&per_page=20');
|
|
459
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/customviews');
|
|
460
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/projects/22/issues/33/associated-tasks?page=1&per_page=10');
|
|
461
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/issues/associated-tasks?page=1&per_page=10&issue_ids=%5B%221%22%2C%222%22%5D');
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
test('portal phases and module activation helpers map to documented endpoints', async () => {
|
|
465
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
466
|
+
jsonResponse({ phases: [] }),
|
|
467
|
+
jsonResponse({ ok: true }),
|
|
468
|
+
jsonResponse({ ok: true }),
|
|
469
|
+
]);
|
|
470
|
+
|
|
471
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
472
|
+
|
|
473
|
+
await client.phases.listAll(11, { page: 1, per_page: 20 });
|
|
474
|
+
await client.settings.activateModule(11, 'risk');
|
|
475
|
+
await client.settings.deactivateModule(11, 'risk');
|
|
476
|
+
|
|
477
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/phases?page=1&per_page=20');
|
|
478
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/modules/risk/activate');
|
|
479
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/settings/modules/risk/deactivate');
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
test('project groups helpers map to documented endpoints', async () => {
|
|
483
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
484
|
+
jsonResponse({ 'project-groups': [] }),
|
|
485
|
+
jsonResponse({ 'project-groups': [] }),
|
|
486
|
+
jsonResponse({ id: 1 }),
|
|
487
|
+
jsonResponse({ id: 2 }),
|
|
488
|
+
jsonResponse({ ok: true }),
|
|
489
|
+
]);
|
|
490
|
+
|
|
491
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
492
|
+
|
|
493
|
+
await client.projectGroups.list(11, { page: 1, per_page: 10 });
|
|
494
|
+
await client.projectGroups.listMine(11, { page: 1, per_page: 10 });
|
|
495
|
+
await client.projectGroups.create(11, { name: 'Marketing', type: 'public', prefix: 'MK-01' });
|
|
496
|
+
await client.projectGroups.update(11, 22, { name: 'Marketing 2', type: 'private' });
|
|
497
|
+
await client.projectGroups.deleteById(11, 22);
|
|
498
|
+
|
|
499
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal/11/project-groups?page=1&per_page=10');
|
|
500
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/my-project-groups?page=1&per_page=10');
|
|
501
|
+
assert.equal(String(calls[2].input), 'https://projectsapi.zoho.com/api/v3/portal/11/project-groups');
|
|
502
|
+
assert.equal(String(calls[3].input), 'https://projectsapi.zoho.com/api/v3/portal/11/project-groups/22');
|
|
503
|
+
assert.equal(String(calls[4].input), 'https://projectsapi.zoho.com/api/v3/portal/11/project-groups/22');
|
|
504
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { ZohoProjectsClient } from '@/client.ts';
|
|
4
|
+
import { executeZohoProjectsTool, zohoProjectsTools } from '@/tools.ts';
|
|
5
|
+
import { jsonResponse, makeFetchStub } from './helpers.ts';
|
|
6
|
+
|
|
7
|
+
test('zoho projects tools expose OpenAI-compatible definitions', () => {
|
|
8
|
+
const names = zohoProjectsTools.map((tool) => tool.function.name);
|
|
9
|
+
|
|
10
|
+
assert.ok(names.includes('zoho_projects_portals'));
|
|
11
|
+
assert.ok(names.includes('zoho_projects_projects'));
|
|
12
|
+
assert.ok(names.includes('zoho_projects_tasks'));
|
|
13
|
+
assert.ok(names.includes('zoho_projects_issues'));
|
|
14
|
+
assert.ok(names.includes('zoho_projects_time_logs'));
|
|
15
|
+
assert.ok(names.includes('zoho_projects_request'));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('zoho projects tool dispatcher executes SDK calls', async () => {
|
|
19
|
+
const { fetchStub, calls } = makeFetchStub([
|
|
20
|
+
jsonResponse({ portals: [] }),
|
|
21
|
+
jsonResponse({ timelogs: [] }),
|
|
22
|
+
]);
|
|
23
|
+
const client = new ZohoProjectsClient({ accessToken: 'abc', fetch: fetchStub });
|
|
24
|
+
|
|
25
|
+
await executeZohoProjectsTool(client, 'zoho_projects_portals', { action: 'listPortals' });
|
|
26
|
+
await executeZohoProjectsTool(client, 'zoho_projects_time_logs', { action: 'listPortalTimeLogs', portal_id: 11, query: { page: 1, per_page: 10 } });
|
|
27
|
+
|
|
28
|
+
assert.equal(String(calls[0].input), 'https://projectsapi.zoho.com/api/v3/portal');
|
|
29
|
+
assert.equal(String(calls[1].input), 'https://projectsapi.zoho.com/api/v3/portal/11/logs?page=1&per_page=10');
|
|
30
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@/*": ["./src/*"]
|
|
8
|
+
},
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"allowJs": false,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"verbatimModuleSyntax": true,
|
|
16
|
+
"exactOptionalPropertyTypes": true,
|
|
17
|
+
"useUnknownInCatchVariables": true
|
|
18
|
+
},
|
|
19
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts", "test/**/*.ts", "test/**/*.d.ts"]
|
|
20
|
+
}
|