@doist/todoist-sdk 9.0.0 → 9.1.0-next.2
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/dist/cjs/clients/activity-client.js +63 -0
- package/dist/cjs/clients/backup-client.js +65 -0
- package/dist/cjs/clients/base-client.js +30 -0
- package/dist/cjs/clients/comment-client.js +92 -0
- package/dist/cjs/clients/email-client.js +43 -0
- package/dist/cjs/clients/folder-client.js +80 -0
- package/dist/cjs/clients/goals-client.js +145 -0
- package/dist/cjs/clients/id-mapping-client.js +39 -0
- package/dist/cjs/clients/insights-client.js +88 -0
- package/dist/cjs/clients/label-client.js +127 -0
- package/dist/cjs/clients/productivity-client.js +27 -0
- package/dist/cjs/clients/project-client.js +232 -0
- package/dist/cjs/clients/reminder-client.js +198 -0
- package/dist/cjs/clients/section-client.js +118 -0
- package/dist/cjs/clients/task-client.js +255 -0
- package/dist/cjs/clients/template-client.js +89 -0
- package/dist/cjs/clients/upload-client.js +102 -0
- package/dist/cjs/clients/workspace-client.js +367 -0
- package/dist/cjs/consts/endpoints.js +6 -1
- package/dist/cjs/test-utils/test-defaults.js +25 -1
- package/dist/cjs/todoist-api.js +186 -1537
- package/dist/cjs/transport/sync-request.js +75 -0
- package/dist/cjs/types/goals/index.js +18 -0
- package/dist/cjs/types/goals/requests.js +2 -0
- package/dist/cjs/types/goals/types.js +56 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/sync/commands/goals.js +2 -0
- package/dist/cjs/types/sync/commands/index.js +1 -0
- package/dist/cjs/types/sync/resource-types.js +1 -0
- package/dist/cjs/types/sync/response.js +12 -10
- package/dist/cjs/utils/headers.js +16 -0
- package/dist/cjs/utils/request-helpers.js +21 -0
- package/dist/cjs/utils/validators.js +48 -46
- package/dist/esm/clients/activity-client.js +59 -0
- package/dist/esm/clients/backup-client.js +61 -0
- package/dist/esm/clients/base-client.js +26 -0
- package/dist/esm/clients/comment-client.js +88 -0
- package/dist/esm/clients/email-client.js +39 -0
- package/dist/esm/clients/folder-client.js +76 -0
- package/dist/esm/clients/goals-client.js +141 -0
- package/dist/esm/clients/id-mapping-client.js +35 -0
- package/dist/esm/clients/insights-client.js +84 -0
- package/dist/esm/clients/label-client.js +123 -0
- package/dist/esm/clients/productivity-client.js +23 -0
- package/dist/esm/clients/project-client.js +228 -0
- package/dist/esm/clients/reminder-client.js +194 -0
- package/dist/esm/clients/section-client.js +114 -0
- package/dist/esm/clients/task-client.js +251 -0
- package/dist/esm/clients/template-client.js +85 -0
- package/dist/esm/clients/upload-client.js +98 -0
- package/dist/esm/clients/workspace-client.js +363 -0
- package/dist/esm/consts/endpoints.js +5 -0
- package/dist/esm/test-utils/test-defaults.js +24 -0
- package/dist/esm/todoist-api.js +189 -1540
- package/dist/esm/transport/sync-request.js +72 -0
- package/dist/esm/types/goals/index.js +2 -0
- package/dist/esm/types/goals/requests.js +1 -0
- package/dist/esm/types/goals/types.js +53 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/sync/commands/goals.js +1 -0
- package/dist/esm/types/sync/commands/index.js +1 -0
- package/dist/esm/types/sync/resource-types.js +1 -0
- package/dist/esm/types/sync/response.js +2 -0
- package/dist/esm/utils/headers.js +13 -0
- package/dist/esm/utils/request-helpers.js +17 -0
- package/dist/esm/utils/validators.js +2 -0
- package/dist/types/clients/activity-client.d.ts +12 -0
- package/dist/types/clients/backup-client.d.ts +14 -0
- package/dist/types/clients/base-client.d.ts +21 -0
- package/dist/types/clients/comment-client.d.ts +15 -0
- package/dist/types/clients/email-client.d.ts +13 -0
- package/dist/types/clients/folder-client.d.ts +16 -0
- package/dist/types/clients/goals-client.d.ts +20 -0
- package/dist/types/clients/id-mapping-client.d.ts +13 -0
- package/dist/types/clients/insights-client.d.ts +18 -0
- package/dist/types/clients/label-client.d.ts +19 -0
- package/dist/types/clients/productivity-client.d.ts +12 -0
- package/dist/types/clients/project-client.d.ts +26 -0
- package/dist/types/clients/reminder-client.d.ts +25 -0
- package/dist/types/clients/section-client.d.ts +18 -0
- package/dist/types/clients/task-client.d.ts +25 -0
- package/dist/types/clients/template-client.d.ts +17 -0
- package/dist/types/clients/upload-client.d.ts +17 -0
- package/dist/types/clients/workspace-client.d.ts +43 -0
- package/dist/types/consts/endpoints.d.ts +5 -0
- package/dist/types/test-utils/test-defaults.d.ts +4 -1
- package/dist/types/todoist-api.d.ts +48 -17
- package/dist/types/transport/sync-request.d.ts +27 -0
- package/dist/types/types/goals/index.d.ts +2 -0
- package/dist/types/types/goals/requests.d.ts +33 -0
- package/dist/types/types/goals/types.d.ts +51 -0
- package/dist/types/types/http.d.ts +7 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/sync/commands/goals.d.ts +33 -0
- package/dist/types/types/sync/commands/index.d.ts +9 -0
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +29 -4
- package/dist/types/types/tasks/requests.d.ts +1 -0
- package/dist/types/utils/headers.d.ts +7 -0
- package/dist/types/utils/request-helpers.d.ts +13 -0
- package/dist/types/utils/validators.d.ts +55 -8
- package/package.json +1 -1
package/dist/esm/todoist-api.js
CHANGED
|
@@ -1,99 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
23
|
-
import { TodoistArgumentError, TodoistRequestError } from './types/index.js';
|
|
24
|
-
import { DATE_FORMAT_TO_API, TIME_FORMAT_TO_API, DAY_OF_WEEK_TO_API, } from './types/sync/index.js';
|
|
25
|
-
const MAX_COMMAND_COUNT = 100;
|
|
26
|
-
/**
|
|
27
|
-
* Joins path segments using `/` separator.
|
|
28
|
-
* @param segments A list of **valid** path segments.
|
|
29
|
-
* @returns A joined path.
|
|
30
|
-
*/
|
|
31
|
-
function generatePath(...segments) {
|
|
32
|
-
return segments.join('/');
|
|
33
|
-
}
|
|
34
|
-
function spreadIfDefined(value, fn) {
|
|
35
|
-
return value !== undefined ? fn(value) : {};
|
|
36
|
-
}
|
|
37
|
-
function serializeUserUpdateArgs(args) {
|
|
38
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({
|
|
39
|
-
dateFormat: DATE_FORMAT_TO_API[v],
|
|
40
|
-
}))), spreadIfDefined(args.timeFormat, (v) => ({
|
|
41
|
-
timeFormat: TIME_FORMAT_TO_API[v],
|
|
42
|
-
}))), spreadIfDefined(args.startDay, (v) => ({
|
|
43
|
-
startDay: DAY_OF_WEEK_TO_API[v],
|
|
44
|
-
}))), spreadIfDefined(args.nextWeek, (v) => ({
|
|
45
|
-
nextWeek: DAY_OF_WEEK_TO_API[v],
|
|
46
|
-
})));
|
|
47
|
-
}
|
|
48
|
-
function serializeTaskUpdateDateCompleteArgs(args) {
|
|
49
|
-
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({
|
|
50
|
-
resetSubtasks: v ? 1 : 0,
|
|
51
|
-
})));
|
|
52
|
-
}
|
|
53
|
-
function serializeUpdateGoalsArgs(args) {
|
|
54
|
-
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({
|
|
55
|
-
karmaDisabled: v ? 1 : 0,
|
|
56
|
-
})));
|
|
57
|
-
}
|
|
58
|
-
function preprocessSyncCommands(commands) {
|
|
59
|
-
return commands.map((cmd) => {
|
|
60
|
-
if (cmd.type === 'user_update')
|
|
61
|
-
return Object.assign(Object.assign({}, cmd), { args: serializeUserUpdateArgs(cmd.args) });
|
|
62
|
-
if (cmd.type === 'item_update_date_complete')
|
|
63
|
-
return Object.assign(Object.assign({}, cmd), { args: serializeTaskUpdateDateCompleteArgs(cmd.args) });
|
|
64
|
-
if (cmd.type === 'update_goals')
|
|
65
|
-
return Object.assign(Object.assign({}, cmd), { args: serializeUpdateGoalsArgs(cmd.args) });
|
|
66
|
-
return cmd;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* A client for interacting with the Todoist API v1.
|
|
71
|
-
* This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* const api = new TodoistApi('your-api-token');
|
|
76
|
-
*
|
|
77
|
-
* // Get all tasks
|
|
78
|
-
* const tasks = await api.getTasks();
|
|
79
|
-
*
|
|
80
|
-
* // Create a new task
|
|
81
|
-
* const newTask = await api.addTask({
|
|
82
|
-
* content: 'My new task',
|
|
83
|
-
* projectId: '12345'
|
|
84
|
-
* });
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* For more information about the Todoist API v1, see the [official documentation](https://todoist.com/api/v1).
|
|
88
|
-
* If you're migrating from v9, please refer to the [migration guide](https://todoist.com/api/v1/docs#tag/Migrating-from-v9).
|
|
89
|
-
*/
|
|
90
|
-
function headersToRecord(headers) {
|
|
91
|
-
const result = {};
|
|
92
|
-
headers.forEach((value, key) => {
|
|
93
|
-
result[key] = value;
|
|
94
|
-
});
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
1
|
+
import { ActivityClient } from './clients/activity-client.js';
|
|
2
|
+
import { BackupClient } from './clients/backup-client.js';
|
|
3
|
+
import { CommentClient } from './clients/comment-client.js';
|
|
4
|
+
import { EmailClient } from './clients/email-client.js';
|
|
5
|
+
import { FolderClient } from './clients/folder-client.js';
|
|
6
|
+
import { GoalsClient } from './clients/goals-client.js';
|
|
7
|
+
import { IdMappingClient } from './clients/id-mapping-client.js';
|
|
8
|
+
import { InsightsClient } from './clients/insights-client.js';
|
|
9
|
+
import { LabelClient } from './clients/label-client.js';
|
|
10
|
+
import { ProductivityClient } from './clients/productivity-client.js';
|
|
11
|
+
import { ProjectClient } from './clients/project-client.js';
|
|
12
|
+
import { ReminderClient } from './clients/reminder-client.js';
|
|
13
|
+
import { SectionClient } from './clients/section-client.js';
|
|
14
|
+
import { TaskClient } from './clients/task-client.js';
|
|
15
|
+
import { TemplateClient } from './clients/template-client.js';
|
|
16
|
+
import { UploadClient } from './clients/upload-client.js';
|
|
17
|
+
import { WorkspaceClient } from './clients/workspace-client.js';
|
|
18
|
+
import { ENDPOINT_REST_USER, getSyncBaseUri } from './consts/endpoints.js';
|
|
19
|
+
import { request } from './transport/http-client.js';
|
|
20
|
+
import { performSyncRequest } from './transport/sync-request.js';
|
|
21
|
+
import { validateCurrentUser } from './utils/validators.js';
|
|
97
22
|
export class TodoistApi {
|
|
98
23
|
constructor(
|
|
99
24
|
/**
|
|
@@ -111,39 +36,28 @@ export class TodoistApi {
|
|
|
111
36
|
const opts = options || {};
|
|
112
37
|
this.syncApiBase = getSyncBaseUri(opts.baseUrl);
|
|
113
38
|
this.customFetch = opts.customFetch;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
* @param syncRequest - The sync request payload
|
|
119
|
-
* @param requestId - Optional request identifier
|
|
120
|
-
* @param hasSyncCommands - Whether this request contains sync commands (write operations)
|
|
121
|
-
* @returns The sync response data
|
|
122
|
-
* @throws TodoistRequestError if sync status contains errors
|
|
123
|
-
*/
|
|
124
|
-
async requestSync(syncRequest, requestId, hasSyncCommands = false) {
|
|
125
|
-
var _a;
|
|
126
|
-
const processedRequest = ((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length)
|
|
127
|
-
? Object.assign(Object.assign({}, syncRequest), { commands: preprocessSyncCommands(syncRequest.commands) }) : syncRequest;
|
|
128
|
-
const response = await request({
|
|
129
|
-
httpMethod: 'POST',
|
|
130
|
-
baseUri: this.syncApiBase,
|
|
131
|
-
relativePath: ENDPOINT_SYNC,
|
|
132
|
-
apiToken: this.authToken,
|
|
39
|
+
const clientDeps = {
|
|
40
|
+
authToken: this.authToken,
|
|
41
|
+
syncApiBase: this.syncApiBase,
|
|
133
42
|
customFetch: this.customFetch,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
43
|
+
};
|
|
44
|
+
this.taskClient = new TaskClient(clientDeps);
|
|
45
|
+
this.projectClient = new ProjectClient(clientDeps);
|
|
46
|
+
this.sectionClient = new SectionClient(clientDeps);
|
|
47
|
+
this.labelClient = new LabelClient(clientDeps);
|
|
48
|
+
this.commentClient = new CommentClient(clientDeps);
|
|
49
|
+
this.reminderClient = new ReminderClient(clientDeps);
|
|
50
|
+
this.insightsClient = new InsightsClient(clientDeps);
|
|
51
|
+
this.folderClient = new FolderClient(clientDeps);
|
|
52
|
+
this.templateClient = new TemplateClient(clientDeps);
|
|
53
|
+
this.uploadClient = new UploadClient(clientDeps);
|
|
54
|
+
this.backupClient = new BackupClient(clientDeps);
|
|
55
|
+
this.emailClient = new EmailClient(clientDeps);
|
|
56
|
+
this.idMappingClient = new IdMappingClient(clientDeps);
|
|
57
|
+
this.activityClient = new ActivityClient(clientDeps);
|
|
58
|
+
this.productivityClient = new ProductivityClient(clientDeps);
|
|
59
|
+
this.workspaceClient = new WorkspaceClient(clientDeps);
|
|
60
|
+
this.goalsClient = new GoalsClient(clientDeps);
|
|
147
61
|
}
|
|
148
62
|
/**
|
|
149
63
|
* Executes a raw Sync API request.
|
|
@@ -171,7 +85,11 @@ export class TodoistApi {
|
|
|
171
85
|
*/
|
|
172
86
|
async sync(syncRequest, requestId) {
|
|
173
87
|
var _a;
|
|
174
|
-
return
|
|
88
|
+
return performSyncRequest({
|
|
89
|
+
authToken: this.authToken,
|
|
90
|
+
syncApiBase: this.syncApiBase,
|
|
91
|
+
customFetch: this.customFetch,
|
|
92
|
+
}, syncRequest, { requestId, hasSyncCommands: Boolean((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length) });
|
|
175
93
|
}
|
|
176
94
|
/**
|
|
177
95
|
* Retrieves information about the authenticated user.
|
|
@@ -195,15 +113,7 @@ export class TodoistApi {
|
|
|
195
113
|
* @returns A promise that resolves to the requested task.
|
|
196
114
|
*/
|
|
197
115
|
async getTask(id) {
|
|
198
|
-
|
|
199
|
-
const response = await request({
|
|
200
|
-
httpMethod: 'GET',
|
|
201
|
-
baseUri: this.syncApiBase,
|
|
202
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id),
|
|
203
|
-
apiToken: this.authToken,
|
|
204
|
-
customFetch: this.customFetch,
|
|
205
|
-
});
|
|
206
|
-
return validateTask(response.data);
|
|
116
|
+
return this.taskClient.getTask(id);
|
|
207
117
|
}
|
|
208
118
|
/**
|
|
209
119
|
* Retrieves a list of active tasks filtered by specific parameters.
|
|
@@ -212,18 +122,7 @@ export class TodoistApi {
|
|
|
212
122
|
* @returns A promise that resolves to an array of tasks.
|
|
213
123
|
*/
|
|
214
124
|
async getTasks(args = {}) {
|
|
215
|
-
|
|
216
|
-
httpMethod: 'GET',
|
|
217
|
-
baseUri: this.syncApiBase,
|
|
218
|
-
relativePath: ENDPOINT_REST_TASKS,
|
|
219
|
-
apiToken: this.authToken,
|
|
220
|
-
customFetch: this.customFetch,
|
|
221
|
-
payload: args,
|
|
222
|
-
});
|
|
223
|
-
return {
|
|
224
|
-
results: validateTaskArray(results),
|
|
225
|
-
nextCursor,
|
|
226
|
-
};
|
|
125
|
+
return this.taskClient.getTasks(args);
|
|
227
126
|
}
|
|
228
127
|
/**
|
|
229
128
|
* Retrieves tasks filtered by a filter string.
|
|
@@ -232,18 +131,7 @@ export class TodoistApi {
|
|
|
232
131
|
* @returns A promise that resolves to a paginated response of tasks.
|
|
233
132
|
*/
|
|
234
133
|
async getTasksByFilter(args) {
|
|
235
|
-
|
|
236
|
-
httpMethod: 'GET',
|
|
237
|
-
baseUri: this.syncApiBase,
|
|
238
|
-
relativePath: ENDPOINT_REST_TASKS_FILTER,
|
|
239
|
-
apiToken: this.authToken,
|
|
240
|
-
customFetch: this.customFetch,
|
|
241
|
-
payload: args,
|
|
242
|
-
});
|
|
243
|
-
return {
|
|
244
|
-
results: validateTaskArray(results),
|
|
245
|
-
nextCursor,
|
|
246
|
-
};
|
|
134
|
+
return this.taskClient.getTasksByFilter(args);
|
|
247
135
|
}
|
|
248
136
|
/**
|
|
249
137
|
* Retrieves completed tasks by completion date.
|
|
@@ -252,18 +140,7 @@ export class TodoistApi {
|
|
|
252
140
|
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
253
141
|
*/
|
|
254
142
|
async getCompletedTasksByCompletionDate(args) {
|
|
255
|
-
|
|
256
|
-
httpMethod: 'GET',
|
|
257
|
-
baseUri: this.syncApiBase,
|
|
258
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE,
|
|
259
|
-
apiToken: this.authToken,
|
|
260
|
-
customFetch: this.customFetch,
|
|
261
|
-
payload: args,
|
|
262
|
-
});
|
|
263
|
-
return {
|
|
264
|
-
items: validateTaskArray(items),
|
|
265
|
-
nextCursor,
|
|
266
|
-
};
|
|
143
|
+
return this.taskClient.getCompletedTasksByCompletionDate(args);
|
|
267
144
|
}
|
|
268
145
|
/**
|
|
269
146
|
* Retrieves completed tasks by due date.
|
|
@@ -272,18 +149,7 @@ export class TodoistApi {
|
|
|
272
149
|
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
273
150
|
*/
|
|
274
151
|
async getCompletedTasksByDueDate(args) {
|
|
275
|
-
|
|
276
|
-
httpMethod: 'GET',
|
|
277
|
-
baseUri: this.syncApiBase,
|
|
278
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE,
|
|
279
|
-
apiToken: this.authToken,
|
|
280
|
-
customFetch: this.customFetch,
|
|
281
|
-
payload: args,
|
|
282
|
-
});
|
|
283
|
-
return {
|
|
284
|
-
items: validateTaskArray(items),
|
|
285
|
-
nextCursor,
|
|
286
|
-
};
|
|
152
|
+
return this.taskClient.getCompletedTasksByDueDate(args);
|
|
287
153
|
}
|
|
288
154
|
/**
|
|
289
155
|
* Searches completed tasks by query string.
|
|
@@ -292,18 +158,7 @@ export class TodoistApi {
|
|
|
292
158
|
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
293
159
|
*/
|
|
294
160
|
async searchCompletedTasks(args) {
|
|
295
|
-
|
|
296
|
-
httpMethod: 'GET',
|
|
297
|
-
baseUri: this.syncApiBase,
|
|
298
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED_SEARCH,
|
|
299
|
-
apiToken: this.authToken,
|
|
300
|
-
customFetch: this.customFetch,
|
|
301
|
-
payload: args,
|
|
302
|
-
});
|
|
303
|
-
return {
|
|
304
|
-
items: validateTaskArray(items),
|
|
305
|
-
nextCursor,
|
|
306
|
-
};
|
|
161
|
+
return this.taskClient.searchCompletedTasks(args);
|
|
307
162
|
}
|
|
308
163
|
/**
|
|
309
164
|
* Retrieves all completed tasks with optional filters.
|
|
@@ -314,20 +169,7 @@ export class TodoistApi {
|
|
|
314
169
|
* @returns A promise that resolves to completed tasks with associated project and section data.
|
|
315
170
|
*/
|
|
316
171
|
async getAllCompletedTasks(args = {}) {
|
|
317
|
-
|
|
318
|
-
const { data } = await request({
|
|
319
|
-
httpMethod: 'GET',
|
|
320
|
-
baseUri: this.syncApiBase,
|
|
321
|
-
relativePath: ENDPOINT_REST_TASKS_COMPLETED,
|
|
322
|
-
apiToken: this.authToken,
|
|
323
|
-
customFetch: this.customFetch,
|
|
324
|
-
payload: Object.assign(Object.assign(Object.assign({}, rest), (since ? { since: since.toISOString() } : {})), (until ? { until: until.toISOString() } : {})),
|
|
325
|
-
});
|
|
326
|
-
return {
|
|
327
|
-
projects: data.projects,
|
|
328
|
-
sections: data.sections,
|
|
329
|
-
items: validateTaskArray(data.items),
|
|
330
|
-
};
|
|
172
|
+
return this.taskClient.getAllCompletedTasks(args);
|
|
331
173
|
}
|
|
332
174
|
/**
|
|
333
175
|
* Creates a new task with the provided parameters.
|
|
@@ -337,18 +179,7 @@ export class TodoistApi {
|
|
|
337
179
|
* @returns A promise that resolves to the created task.
|
|
338
180
|
*/
|
|
339
181
|
async addTask(args, requestId) {
|
|
340
|
-
|
|
341
|
-
const processedArgs = Object.assign(Object.assign({}, args), { content: processTaskContent(args.content, args.isUncompletable) });
|
|
342
|
-
const response = await request({
|
|
343
|
-
httpMethod: 'POST',
|
|
344
|
-
baseUri: this.syncApiBase,
|
|
345
|
-
relativePath: ENDPOINT_REST_TASKS,
|
|
346
|
-
apiToken: this.authToken,
|
|
347
|
-
customFetch: this.customFetch,
|
|
348
|
-
payload: processedArgs,
|
|
349
|
-
requestId: requestId,
|
|
350
|
-
});
|
|
351
|
-
return validateTask(response.data);
|
|
182
|
+
return this.taskClient.addTask(args, requestId);
|
|
352
183
|
}
|
|
353
184
|
/**
|
|
354
185
|
* Quickly adds a task using natural language processing for due dates.
|
|
@@ -357,17 +188,7 @@ export class TodoistApi {
|
|
|
357
188
|
* @returns A promise that resolves to the created task.
|
|
358
189
|
*/
|
|
359
190
|
async quickAddTask(args) {
|
|
360
|
-
|
|
361
|
-
const processedArgs = Object.assign(Object.assign({}, args), { text: processTaskContent(args.text, args.isUncompletable) });
|
|
362
|
-
const response = await request({
|
|
363
|
-
httpMethod: 'POST',
|
|
364
|
-
baseUri: this.syncApiBase,
|
|
365
|
-
relativePath: ENDPOINT_SYNC_QUICK_ADD,
|
|
366
|
-
apiToken: this.authToken,
|
|
367
|
-
customFetch: this.customFetch,
|
|
368
|
-
payload: processedArgs,
|
|
369
|
-
});
|
|
370
|
-
return validateTask(response.data);
|
|
191
|
+
return this.taskClient.quickAddTask(args);
|
|
371
192
|
}
|
|
372
193
|
/**
|
|
373
194
|
* Updates an existing task by its ID with the provided parameters.
|
|
@@ -379,25 +200,7 @@ export class TodoistApi {
|
|
|
379
200
|
* @returns A promise that resolves to the updated task.
|
|
380
201
|
*/
|
|
381
202
|
async updateTask(id, args, requestId) {
|
|
382
|
-
|
|
383
|
-
// Translate SDK alias for due-date clearing to Todoist's accepted payload value.
|
|
384
|
-
const normalizedArgs = args.dueString === null ? Object.assign(Object.assign({}, args), { dueString: 'no date' }) : args;
|
|
385
|
-
// Process content if both content and isUncompletable are provided
|
|
386
|
-
const processedArgs = normalizedArgs.content && normalizedArgs.isUncompletable !== undefined
|
|
387
|
-
? Object.assign(Object.assign({}, normalizedArgs), { content: processTaskContent(normalizedArgs.content, normalizedArgs.isUncompletable) }) : normalizedArgs;
|
|
388
|
-
// Remap `order` → `childOrder` so snakeCaseKeys() produces `child_order`
|
|
389
|
-
const { order } = processedArgs, argsWithoutOrder = __rest(processedArgs, ["order"]);
|
|
390
|
-
const remappedArgs = order !== undefined ? Object.assign(Object.assign({}, argsWithoutOrder), { childOrder: order }) : argsWithoutOrder;
|
|
391
|
-
const response = await request({
|
|
392
|
-
httpMethod: 'POST',
|
|
393
|
-
baseUri: this.syncApiBase,
|
|
394
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id),
|
|
395
|
-
apiToken: this.authToken,
|
|
396
|
-
customFetch: this.customFetch,
|
|
397
|
-
payload: remappedArgs,
|
|
398
|
-
requestId: requestId,
|
|
399
|
-
});
|
|
400
|
-
return validateTask(response.data);
|
|
203
|
+
return this.taskClient.updateTask(id, args, requestId);
|
|
401
204
|
}
|
|
402
205
|
/**
|
|
403
206
|
* Moves existing tasks by their ID to either a different parent/section/project.
|
|
@@ -408,28 +211,7 @@ export class TodoistApi {
|
|
|
408
211
|
* @returns - A promise that resolves to an array of the updated tasks.
|
|
409
212
|
*/
|
|
410
213
|
async moveTasks(ids, args, requestId) {
|
|
411
|
-
|
|
412
|
-
if (ids.length > MAX_COMMAND_COUNT) {
|
|
413
|
-
throw new TodoistRequestError(`Maximum number of items is ${MAX_COMMAND_COUNT}`, 400);
|
|
414
|
-
}
|
|
415
|
-
const commands = ids.map((id) => ({
|
|
416
|
-
type: 'item_move',
|
|
417
|
-
uuid: uuidv4(),
|
|
418
|
-
args: Object.assign(Object.assign(Object.assign({ id }, spreadIfDefined(args.projectId, (v) => ({ projectId: v }))), spreadIfDefined(args.sectionId, (v) => ({ sectionId: v }))), spreadIfDefined(args.parentId, (v) => ({ parentId: v }))),
|
|
419
|
-
}));
|
|
420
|
-
const syncRequest = {
|
|
421
|
-
commands,
|
|
422
|
-
resourceTypes: ['items'],
|
|
423
|
-
};
|
|
424
|
-
const syncResponse = await this.requestSync(syncRequest, requestId, true);
|
|
425
|
-
if (!((_a = syncResponse.items) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
426
|
-
throw new TodoistRequestError('Tasks not found', 404);
|
|
427
|
-
}
|
|
428
|
-
const syncTasks = syncResponse.items.filter((task) => ids.includes(task.id));
|
|
429
|
-
if (!syncTasks.length) {
|
|
430
|
-
throw new TodoistRequestError('Tasks not found', 404);
|
|
431
|
-
}
|
|
432
|
-
return validateTaskArray(syncTasks);
|
|
214
|
+
return this.taskClient.moveTasks(ids, args, requestId);
|
|
433
215
|
}
|
|
434
216
|
/**
|
|
435
217
|
* Moves a task by its ID to either a different parent/section/project.
|
|
@@ -440,17 +222,7 @@ export class TodoistApi {
|
|
|
440
222
|
* @returns A promise that resolves to the updated task.
|
|
441
223
|
*/
|
|
442
224
|
async moveTask(id, args, requestId) {
|
|
443
|
-
|
|
444
|
-
const response = await request({
|
|
445
|
-
httpMethod: 'POST',
|
|
446
|
-
baseUri: this.syncApiBase,
|
|
447
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id, ENDPOINT_REST_TASK_MOVE),
|
|
448
|
-
apiToken: this.authToken,
|
|
449
|
-
customFetch: this.customFetch,
|
|
450
|
-
payload: Object.assign(Object.assign(Object.assign({}, spreadIfDefined(args.projectId, (v) => ({ project_id: v }))), spreadIfDefined(args.sectionId, (v) => ({ section_id: v }))), spreadIfDefined(args.parentId, (v) => ({ parent_id: v }))),
|
|
451
|
-
requestId: requestId,
|
|
452
|
-
});
|
|
453
|
-
return validateTask(response.data);
|
|
225
|
+
return this.taskClient.moveTask(id, args, requestId);
|
|
454
226
|
}
|
|
455
227
|
/**
|
|
456
228
|
* Closes (completes) a task by its ID.
|
|
@@ -460,16 +232,7 @@ export class TodoistApi {
|
|
|
460
232
|
* @returns A promise that resolves to `true` if successful.
|
|
461
233
|
*/
|
|
462
234
|
async closeTask(id, requestId) {
|
|
463
|
-
|
|
464
|
-
const response = await request({
|
|
465
|
-
httpMethod: 'POST',
|
|
466
|
-
baseUri: this.syncApiBase,
|
|
467
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id, ENDPOINT_REST_TASK_CLOSE),
|
|
468
|
-
apiToken: this.authToken,
|
|
469
|
-
customFetch: this.customFetch,
|
|
470
|
-
requestId: requestId,
|
|
471
|
-
});
|
|
472
|
-
return isSuccess(response);
|
|
235
|
+
return this.taskClient.closeTask(id, requestId);
|
|
473
236
|
}
|
|
474
237
|
/**
|
|
475
238
|
* Reopens a previously closed (completed) task by its ID.
|
|
@@ -479,16 +242,7 @@ export class TodoistApi {
|
|
|
479
242
|
* @returns A promise that resolves to `true` if successful.
|
|
480
243
|
*/
|
|
481
244
|
async reopenTask(id, requestId) {
|
|
482
|
-
|
|
483
|
-
const response = await request({
|
|
484
|
-
httpMethod: 'POST',
|
|
485
|
-
baseUri: this.syncApiBase,
|
|
486
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id, ENDPOINT_REST_TASK_REOPEN),
|
|
487
|
-
apiToken: this.authToken,
|
|
488
|
-
customFetch: this.customFetch,
|
|
489
|
-
requestId: requestId,
|
|
490
|
-
});
|
|
491
|
-
return isSuccess(response);
|
|
245
|
+
return this.taskClient.reopenTask(id, requestId);
|
|
492
246
|
}
|
|
493
247
|
/**
|
|
494
248
|
* Deletes a task by its ID.
|
|
@@ -498,16 +252,7 @@ export class TodoistApi {
|
|
|
498
252
|
* @returns A promise that resolves to `true` if successful.
|
|
499
253
|
*/
|
|
500
254
|
async deleteTask(id, requestId) {
|
|
501
|
-
|
|
502
|
-
const response = await request({
|
|
503
|
-
httpMethod: 'DELETE',
|
|
504
|
-
baseUri: this.syncApiBase,
|
|
505
|
-
relativePath: generatePath(ENDPOINT_REST_TASKS, id),
|
|
506
|
-
apiToken: this.authToken,
|
|
507
|
-
customFetch: this.customFetch,
|
|
508
|
-
requestId: requestId,
|
|
509
|
-
});
|
|
510
|
-
return isSuccess(response);
|
|
255
|
+
return this.taskClient.deleteTask(id, requestId);
|
|
511
256
|
}
|
|
512
257
|
/**
|
|
513
258
|
* Retrieves a project by its ID.
|
|
@@ -516,15 +261,7 @@ export class TodoistApi {
|
|
|
516
261
|
* @returns A promise that resolves to the requested project.
|
|
517
262
|
*/
|
|
518
263
|
async getProject(id) {
|
|
519
|
-
|
|
520
|
-
const response = await request({
|
|
521
|
-
httpMethod: 'GET',
|
|
522
|
-
baseUri: this.syncApiBase,
|
|
523
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id),
|
|
524
|
-
apiToken: this.authToken,
|
|
525
|
-
customFetch: this.customFetch,
|
|
526
|
-
});
|
|
527
|
-
return validateProject(response.data);
|
|
264
|
+
return this.projectClient.getProject(id);
|
|
528
265
|
}
|
|
529
266
|
/**
|
|
530
267
|
* Retrieves all projects with optional filters.
|
|
@@ -533,18 +270,7 @@ export class TodoistApi {
|
|
|
533
270
|
* @returns A promise that resolves to an array of projects.
|
|
534
271
|
*/
|
|
535
272
|
async getProjects(args = {}) {
|
|
536
|
-
|
|
537
|
-
httpMethod: 'GET',
|
|
538
|
-
baseUri: this.syncApiBase,
|
|
539
|
-
relativePath: ENDPOINT_REST_PROJECTS,
|
|
540
|
-
apiToken: this.authToken,
|
|
541
|
-
customFetch: this.customFetch,
|
|
542
|
-
payload: args,
|
|
543
|
-
});
|
|
544
|
-
return {
|
|
545
|
-
results: validateProjectArray(results),
|
|
546
|
-
nextCursor,
|
|
547
|
-
};
|
|
273
|
+
return this.projectClient.getProjects(args);
|
|
548
274
|
}
|
|
549
275
|
/**
|
|
550
276
|
* Searches projects by name.
|
|
@@ -553,18 +279,7 @@ export class TodoistApi {
|
|
|
553
279
|
* @returns A promise that resolves to a paginated response of projects.
|
|
554
280
|
*/
|
|
555
281
|
async searchProjects(args) {
|
|
556
|
-
|
|
557
|
-
httpMethod: 'GET',
|
|
558
|
-
baseUri: this.syncApiBase,
|
|
559
|
-
relativePath: ENDPOINT_REST_PROJECTS_SEARCH,
|
|
560
|
-
apiToken: this.authToken,
|
|
561
|
-
customFetch: this.customFetch,
|
|
562
|
-
payload: args,
|
|
563
|
-
});
|
|
564
|
-
return {
|
|
565
|
-
results: validateProjectArray(results),
|
|
566
|
-
nextCursor,
|
|
567
|
-
};
|
|
282
|
+
return this.projectClient.searchProjects(args);
|
|
568
283
|
}
|
|
569
284
|
/**
|
|
570
285
|
* Retrieves all archived projects with optional filters.
|
|
@@ -573,18 +288,7 @@ export class TodoistApi {
|
|
|
573
288
|
* @returns A promise that resolves to an array of archived projects.
|
|
574
289
|
*/
|
|
575
290
|
async getArchivedProjects(args = {}) {
|
|
576
|
-
|
|
577
|
-
httpMethod: 'GET',
|
|
578
|
-
baseUri: this.syncApiBase,
|
|
579
|
-
relativePath: ENDPOINT_REST_PROJECTS_ARCHIVED,
|
|
580
|
-
apiToken: this.authToken,
|
|
581
|
-
customFetch: this.customFetch,
|
|
582
|
-
payload: args,
|
|
583
|
-
});
|
|
584
|
-
return {
|
|
585
|
-
results: validateProjectArray(results),
|
|
586
|
-
nextCursor,
|
|
587
|
-
};
|
|
291
|
+
return this.projectClient.getArchivedProjects(args);
|
|
588
292
|
}
|
|
589
293
|
/**
|
|
590
294
|
* Creates a new project with the provided parameters.
|
|
@@ -594,16 +298,7 @@ export class TodoistApi {
|
|
|
594
298
|
* @returns A promise that resolves to the created project.
|
|
595
299
|
*/
|
|
596
300
|
async addProject(args, requestId) {
|
|
597
|
-
|
|
598
|
-
httpMethod: 'POST',
|
|
599
|
-
baseUri: this.syncApiBase,
|
|
600
|
-
relativePath: ENDPOINT_REST_PROJECTS,
|
|
601
|
-
apiToken: this.authToken,
|
|
602
|
-
customFetch: this.customFetch,
|
|
603
|
-
payload: args,
|
|
604
|
-
requestId: requestId,
|
|
605
|
-
});
|
|
606
|
-
return validateProject(response.data);
|
|
301
|
+
return this.projectClient.addProject(args, requestId);
|
|
607
302
|
}
|
|
608
303
|
/**
|
|
609
304
|
* Updates an existing project by its ID with the provided parameters.
|
|
@@ -614,17 +309,7 @@ export class TodoistApi {
|
|
|
614
309
|
* @returns A promise that resolves to the updated project.
|
|
615
310
|
*/
|
|
616
311
|
async updateProject(id, args, requestId) {
|
|
617
|
-
|
|
618
|
-
const response = await request({
|
|
619
|
-
httpMethod: 'POST',
|
|
620
|
-
baseUri: this.syncApiBase,
|
|
621
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id),
|
|
622
|
-
apiToken: this.authToken,
|
|
623
|
-
customFetch: this.customFetch,
|
|
624
|
-
payload: args,
|
|
625
|
-
requestId: requestId,
|
|
626
|
-
});
|
|
627
|
-
return validateProject(response.data);
|
|
312
|
+
return this.projectClient.updateProject(id, args, requestId);
|
|
628
313
|
}
|
|
629
314
|
/**
|
|
630
315
|
* Deletes a project by its ID.
|
|
@@ -639,16 +324,7 @@ export class TodoistApi {
|
|
|
639
324
|
* @returns A promise that resolves to `true` if successful.
|
|
640
325
|
*/
|
|
641
326
|
async deleteProject(id, requestId) {
|
|
642
|
-
|
|
643
|
-
const response = await request({
|
|
644
|
-
httpMethod: 'DELETE',
|
|
645
|
-
baseUri: this.syncApiBase,
|
|
646
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id),
|
|
647
|
-
apiToken: this.authToken,
|
|
648
|
-
customFetch: this.customFetch,
|
|
649
|
-
requestId: requestId,
|
|
650
|
-
});
|
|
651
|
-
return isSuccess(response);
|
|
327
|
+
return this.projectClient.deleteProject(id, requestId);
|
|
652
328
|
}
|
|
653
329
|
/**
|
|
654
330
|
* Archives a project by its ID.
|
|
@@ -658,16 +334,7 @@ export class TodoistApi {
|
|
|
658
334
|
* @returns A promise that resolves to the updated project.
|
|
659
335
|
*/
|
|
660
336
|
async archiveProject(id, requestId) {
|
|
661
|
-
|
|
662
|
-
const response = await request({
|
|
663
|
-
httpMethod: 'POST',
|
|
664
|
-
baseUri: this.syncApiBase,
|
|
665
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, PROJECT_ARCHIVE),
|
|
666
|
-
apiToken: this.authToken,
|
|
667
|
-
customFetch: this.customFetch,
|
|
668
|
-
requestId: requestId,
|
|
669
|
-
});
|
|
670
|
-
return validateProject(response.data);
|
|
337
|
+
return this.projectClient.archiveProject(id, requestId);
|
|
671
338
|
}
|
|
672
339
|
/**
|
|
673
340
|
* Unarchives a project by its ID.
|
|
@@ -677,16 +344,7 @@ export class TodoistApi {
|
|
|
677
344
|
* @returns A promise that resolves to the updated project.
|
|
678
345
|
*/
|
|
679
346
|
async unarchiveProject(id, requestId) {
|
|
680
|
-
|
|
681
|
-
const response = await request({
|
|
682
|
-
httpMethod: 'POST',
|
|
683
|
-
baseUri: this.syncApiBase,
|
|
684
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, PROJECT_UNARCHIVE),
|
|
685
|
-
apiToken: this.authToken,
|
|
686
|
-
customFetch: this.customFetch,
|
|
687
|
-
requestId: requestId,
|
|
688
|
-
});
|
|
689
|
-
return validateProject(response.data);
|
|
347
|
+
return this.projectClient.unarchiveProject(id, requestId);
|
|
690
348
|
}
|
|
691
349
|
/**
|
|
692
350
|
* Moves a project to a workspace.
|
|
@@ -696,16 +354,7 @@ export class TodoistApi {
|
|
|
696
354
|
* @returns A promise that resolves to the moved project.
|
|
697
355
|
*/
|
|
698
356
|
async moveProjectToWorkspace(args, requestId) {
|
|
699
|
-
|
|
700
|
-
httpMethod: 'POST',
|
|
701
|
-
baseUri: this.syncApiBase,
|
|
702
|
-
relativePath: ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE,
|
|
703
|
-
apiToken: this.authToken,
|
|
704
|
-
customFetch: this.customFetch,
|
|
705
|
-
payload: args,
|
|
706
|
-
requestId: requestId,
|
|
707
|
-
});
|
|
708
|
-
return validateProject(response.data.project);
|
|
357
|
+
return this.projectClient.moveProjectToWorkspace(args, requestId);
|
|
709
358
|
}
|
|
710
359
|
/**
|
|
711
360
|
* Moves a project to personal.
|
|
@@ -715,16 +364,7 @@ export class TodoistApi {
|
|
|
715
364
|
* @returns A promise that resolves to the moved project.
|
|
716
365
|
*/
|
|
717
366
|
async moveProjectToPersonal(args, requestId) {
|
|
718
|
-
|
|
719
|
-
httpMethod: 'POST',
|
|
720
|
-
baseUri: this.syncApiBase,
|
|
721
|
-
relativePath: ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL,
|
|
722
|
-
apiToken: this.authToken,
|
|
723
|
-
customFetch: this.customFetch,
|
|
724
|
-
payload: args,
|
|
725
|
-
requestId: requestId,
|
|
726
|
-
});
|
|
727
|
-
return validateProject(response.data.project);
|
|
367
|
+
return this.projectClient.moveProjectToPersonal(args, requestId);
|
|
728
368
|
}
|
|
729
369
|
/**
|
|
730
370
|
* Counts the number of archived projects.
|
|
@@ -733,15 +373,7 @@ export class TodoistApi {
|
|
|
733
373
|
* @returns A promise that resolves to the count of archived projects.
|
|
734
374
|
*/
|
|
735
375
|
async getArchivedProjectsCount(args = {}) {
|
|
736
|
-
|
|
737
|
-
httpMethod: 'GET',
|
|
738
|
-
baseUri: this.syncApiBase,
|
|
739
|
-
relativePath: ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT,
|
|
740
|
-
apiToken: this.authToken,
|
|
741
|
-
customFetch: this.customFetch,
|
|
742
|
-
payload: args,
|
|
743
|
-
});
|
|
744
|
-
return data;
|
|
376
|
+
return this.projectClient.getArchivedProjectsCount(args);
|
|
745
377
|
}
|
|
746
378
|
/**
|
|
747
379
|
* Retrieves the role-to-action permission mappings for projects.
|
|
@@ -749,14 +381,7 @@ export class TodoistApi {
|
|
|
749
381
|
* @returns A promise that resolves to the permission mappings.
|
|
750
382
|
*/
|
|
751
383
|
async getProjectPermissions() {
|
|
752
|
-
|
|
753
|
-
httpMethod: 'GET',
|
|
754
|
-
baseUri: this.syncApiBase,
|
|
755
|
-
relativePath: ENDPOINT_REST_PROJECTS_PERMISSIONS,
|
|
756
|
-
apiToken: this.authToken,
|
|
757
|
-
customFetch: this.customFetch,
|
|
758
|
-
});
|
|
759
|
-
return data;
|
|
384
|
+
return this.projectClient.getProjectPermissions();
|
|
760
385
|
}
|
|
761
386
|
/**
|
|
762
387
|
* Retrieves full project data including tasks, sections, collaborators, and notes.
|
|
@@ -766,23 +391,7 @@ export class TodoistApi {
|
|
|
766
391
|
* @returns A promise that resolves to the full project data.
|
|
767
392
|
*/
|
|
768
393
|
async getFullProject(id, args = {}) {
|
|
769
|
-
|
|
770
|
-
const { data } = await request({
|
|
771
|
-
httpMethod: 'GET',
|
|
772
|
-
baseUri: this.syncApiBase,
|
|
773
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, ENDPOINT_REST_PROJECT_FULL),
|
|
774
|
-
apiToken: this.authToken,
|
|
775
|
-
customFetch: this.customFetch,
|
|
776
|
-
payload: args,
|
|
777
|
-
});
|
|
778
|
-
return {
|
|
779
|
-
project: data.project ? validateProject(data.project) : null,
|
|
780
|
-
commentsCount: data.commentsCount,
|
|
781
|
-
tasks: validateTaskArray(data.tasks),
|
|
782
|
-
sections: validateSectionArray(data.sections),
|
|
783
|
-
collaborators: validateUserArray(data.collaborators),
|
|
784
|
-
notes: validateCommentArray(data.notes),
|
|
785
|
-
};
|
|
394
|
+
return this.projectClient.getFullProject(id, args);
|
|
786
395
|
}
|
|
787
396
|
/**
|
|
788
397
|
* Joins a workspace project.
|
|
@@ -795,25 +404,7 @@ export class TodoistApi {
|
|
|
795
404
|
* @returns A promise that resolves to the full project data after joining.
|
|
796
405
|
*/
|
|
797
406
|
async joinProject(id, requestId) {
|
|
798
|
-
|
|
799
|
-
const { data } = await request({
|
|
800
|
-
httpMethod: 'POST',
|
|
801
|
-
baseUri: this.syncApiBase,
|
|
802
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, id, ENDPOINT_REST_PROJECT_JOIN),
|
|
803
|
-
apiToken: this.authToken,
|
|
804
|
-
customFetch: this.customFetch,
|
|
805
|
-
requestId: requestId,
|
|
806
|
-
});
|
|
807
|
-
return {
|
|
808
|
-
project: validateWorkspaceProject(data.project),
|
|
809
|
-
tasks: validateTaskArray(data.tasks),
|
|
810
|
-
sections: validateSectionArray(data.sections),
|
|
811
|
-
comments: validateNoteArray(data.comments),
|
|
812
|
-
collaborators: validateCollaboratorArray(data.collaborators),
|
|
813
|
-
collaboratorStates: validateCollaboratorStateArray(data.collaboratorStates),
|
|
814
|
-
folder: data.folder ? validateFolder(data.folder) : null,
|
|
815
|
-
subprojects: validateWorkspaceProjectArray(data.subprojects),
|
|
816
|
-
};
|
|
407
|
+
return this.projectClient.joinProject(id, requestId);
|
|
817
408
|
}
|
|
818
409
|
/**
|
|
819
410
|
* Retrieves a list of collaborators for a specific project.
|
|
@@ -823,19 +414,7 @@ export class TodoistApi {
|
|
|
823
414
|
* @returns A promise that resolves to an array of collaborators for the project.
|
|
824
415
|
*/
|
|
825
416
|
async getProjectCollaborators(projectId, args = {}) {
|
|
826
|
-
|
|
827
|
-
const { data: { results, nextCursor }, } = await request({
|
|
828
|
-
httpMethod: 'GET',
|
|
829
|
-
baseUri: this.syncApiBase,
|
|
830
|
-
relativePath: generatePath(ENDPOINT_REST_PROJECTS, projectId, ENDPOINT_REST_PROJECT_COLLABORATORS),
|
|
831
|
-
apiToken: this.authToken,
|
|
832
|
-
customFetch: this.customFetch,
|
|
833
|
-
payload: args,
|
|
834
|
-
});
|
|
835
|
-
return {
|
|
836
|
-
results: validateUserArray(results),
|
|
837
|
-
nextCursor,
|
|
838
|
-
};
|
|
417
|
+
return this.projectClient.getProjectCollaborators(projectId, args);
|
|
839
418
|
}
|
|
840
419
|
// ── Insights ──
|
|
841
420
|
/**
|
|
@@ -846,16 +425,7 @@ export class TodoistApi {
|
|
|
846
425
|
* @returns A promise that resolves to the project activity stats.
|
|
847
426
|
*/
|
|
848
427
|
async getProjectActivityStats(projectId, args = {}) {
|
|
849
|
-
|
|
850
|
-
const response = await request({
|
|
851
|
-
httpMethod: 'GET',
|
|
852
|
-
baseUri: this.syncApiBase,
|
|
853
|
-
relativePath: getProjectInsightsActivityStatsEndpoint(projectId),
|
|
854
|
-
apiToken: this.authToken,
|
|
855
|
-
customFetch: this.customFetch,
|
|
856
|
-
payload: Object.assign({ objectType: 'ITEM', eventType: 'COMPLETED' }, args),
|
|
857
|
-
});
|
|
858
|
-
return validateProjectActivityStats(response.data);
|
|
428
|
+
return this.insightsClient.getProjectActivityStats(projectId, args);
|
|
859
429
|
}
|
|
860
430
|
/**
|
|
861
431
|
* Retrieves the health status of a project.
|
|
@@ -864,15 +434,7 @@ export class TodoistApi {
|
|
|
864
434
|
* @returns A promise that resolves to the project health data.
|
|
865
435
|
*/
|
|
866
436
|
async getProjectHealth(projectId) {
|
|
867
|
-
|
|
868
|
-
const response = await request({
|
|
869
|
-
httpMethod: 'GET',
|
|
870
|
-
baseUri: this.syncApiBase,
|
|
871
|
-
relativePath: getProjectInsightsHealthEndpoint(projectId),
|
|
872
|
-
apiToken: this.authToken,
|
|
873
|
-
customFetch: this.customFetch,
|
|
874
|
-
});
|
|
875
|
-
return validateProjectHealth(response.data);
|
|
437
|
+
return this.insightsClient.getProjectHealth(projectId);
|
|
876
438
|
}
|
|
877
439
|
/**
|
|
878
440
|
* Retrieves the health context for a project, including metrics and task details.
|
|
@@ -881,15 +443,7 @@ export class TodoistApi {
|
|
|
881
443
|
* @returns A promise that resolves to the project health context.
|
|
882
444
|
*/
|
|
883
445
|
async getProjectHealthContext(projectId) {
|
|
884
|
-
|
|
885
|
-
const response = await request({
|
|
886
|
-
httpMethod: 'GET',
|
|
887
|
-
baseUri: this.syncApiBase,
|
|
888
|
-
relativePath: getProjectInsightsHealthContextEndpoint(projectId),
|
|
889
|
-
apiToken: this.authToken,
|
|
890
|
-
customFetch: this.customFetch,
|
|
891
|
-
});
|
|
892
|
-
return validateProjectHealthContext(response.data);
|
|
446
|
+
return this.insightsClient.getProjectHealthContext(projectId);
|
|
893
447
|
}
|
|
894
448
|
/**
|
|
895
449
|
* Retrieves progress information for a project.
|
|
@@ -898,15 +452,7 @@ export class TodoistApi {
|
|
|
898
452
|
* @returns A promise that resolves to the project progress data.
|
|
899
453
|
*/
|
|
900
454
|
async getProjectProgress(projectId) {
|
|
901
|
-
|
|
902
|
-
const response = await request({
|
|
903
|
-
httpMethod: 'GET',
|
|
904
|
-
baseUri: this.syncApiBase,
|
|
905
|
-
relativePath: getProjectInsightsProgressEndpoint(projectId),
|
|
906
|
-
apiToken: this.authToken,
|
|
907
|
-
customFetch: this.customFetch,
|
|
908
|
-
});
|
|
909
|
-
return validateProjectProgress(response.data);
|
|
455
|
+
return this.insightsClient.getProjectProgress(projectId);
|
|
910
456
|
}
|
|
911
457
|
/**
|
|
912
458
|
* Retrieves insights for all projects in a workspace.
|
|
@@ -916,16 +462,7 @@ export class TodoistApi {
|
|
|
916
462
|
* @returns A promise that resolves to workspace insights data.
|
|
917
463
|
*/
|
|
918
464
|
async getWorkspaceInsights(workspaceId, args = {}) {
|
|
919
|
-
|
|
920
|
-
const response = await request({
|
|
921
|
-
httpMethod: 'GET',
|
|
922
|
-
baseUri: this.syncApiBase,
|
|
923
|
-
relativePath: getWorkspaceInsightsEndpoint(workspaceId),
|
|
924
|
-
apiToken: this.authToken,
|
|
925
|
-
customFetch: this.customFetch,
|
|
926
|
-
payload: Object.assign(Object.assign({}, args), (args.projectIds ? { projectIds: args.projectIds.join(',') } : {})),
|
|
927
|
-
});
|
|
928
|
-
return validateWorkspaceInsights(response.data);
|
|
465
|
+
return this.insightsClient.getWorkspaceInsights(workspaceId, args);
|
|
929
466
|
}
|
|
930
467
|
/**
|
|
931
468
|
* Triggers a health analysis for a project.
|
|
@@ -935,16 +472,7 @@ export class TodoistApi {
|
|
|
935
472
|
* @returns A promise that resolves to the updated project health data.
|
|
936
473
|
*/
|
|
937
474
|
async analyzeProjectHealth(projectId, requestId) {
|
|
938
|
-
|
|
939
|
-
const response = await request({
|
|
940
|
-
httpMethod: 'POST',
|
|
941
|
-
baseUri: this.syncApiBase,
|
|
942
|
-
relativePath: getProjectInsightsHealthAnalyzeEndpoint(projectId),
|
|
943
|
-
apiToken: this.authToken,
|
|
944
|
-
customFetch: this.customFetch,
|
|
945
|
-
requestId: requestId,
|
|
946
|
-
});
|
|
947
|
-
return validateProjectHealth(response.data);
|
|
475
|
+
return this.insightsClient.analyzeProjectHealth(projectId, requestId);
|
|
948
476
|
}
|
|
949
477
|
// ── Sections ──
|
|
950
478
|
/**
|
|
@@ -955,18 +483,7 @@ export class TodoistApi {
|
|
|
955
483
|
* @returns A promise that resolves to an array of sections.
|
|
956
484
|
*/
|
|
957
485
|
async getSections(args) {
|
|
958
|
-
|
|
959
|
-
httpMethod: 'GET',
|
|
960
|
-
baseUri: this.syncApiBase,
|
|
961
|
-
relativePath: ENDPOINT_REST_SECTIONS,
|
|
962
|
-
apiToken: this.authToken,
|
|
963
|
-
customFetch: this.customFetch,
|
|
964
|
-
payload: args,
|
|
965
|
-
});
|
|
966
|
-
return {
|
|
967
|
-
results: validateSectionArray(results),
|
|
968
|
-
nextCursor,
|
|
969
|
-
};
|
|
486
|
+
return this.sectionClient.getSections(args);
|
|
970
487
|
}
|
|
971
488
|
/**
|
|
972
489
|
* Searches sections by name.
|
|
@@ -975,18 +492,7 @@ export class TodoistApi {
|
|
|
975
492
|
* @returns A promise that resolves to a paginated response of sections.
|
|
976
493
|
*/
|
|
977
494
|
async searchSections(args) {
|
|
978
|
-
|
|
979
|
-
httpMethod: 'GET',
|
|
980
|
-
baseUri: this.syncApiBase,
|
|
981
|
-
relativePath: ENDPOINT_REST_SECTIONS_SEARCH,
|
|
982
|
-
apiToken: this.authToken,
|
|
983
|
-
customFetch: this.customFetch,
|
|
984
|
-
payload: args,
|
|
985
|
-
});
|
|
986
|
-
return {
|
|
987
|
-
results: validateSectionArray(results),
|
|
988
|
-
nextCursor,
|
|
989
|
-
};
|
|
495
|
+
return this.sectionClient.searchSections(args);
|
|
990
496
|
}
|
|
991
497
|
/**
|
|
992
498
|
* Retrieves a single section by its ID.
|
|
@@ -995,15 +501,7 @@ export class TodoistApi {
|
|
|
995
501
|
* @returns A promise that resolves to the requested section.
|
|
996
502
|
*/
|
|
997
503
|
async getSection(id) {
|
|
998
|
-
|
|
999
|
-
const response = await request({
|
|
1000
|
-
httpMethod: 'GET',
|
|
1001
|
-
baseUri: this.syncApiBase,
|
|
1002
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id),
|
|
1003
|
-
apiToken: this.authToken,
|
|
1004
|
-
customFetch: this.customFetch,
|
|
1005
|
-
});
|
|
1006
|
-
return validateSection(response.data);
|
|
504
|
+
return this.sectionClient.getSection(id);
|
|
1007
505
|
}
|
|
1008
506
|
/**
|
|
1009
507
|
* Creates a new section within a project.
|
|
@@ -1013,16 +511,7 @@ export class TodoistApi {
|
|
|
1013
511
|
* @returns A promise that resolves to the created section.
|
|
1014
512
|
*/
|
|
1015
513
|
async addSection(args, requestId) {
|
|
1016
|
-
|
|
1017
|
-
httpMethod: 'POST',
|
|
1018
|
-
baseUri: this.syncApiBase,
|
|
1019
|
-
relativePath: ENDPOINT_REST_SECTIONS,
|
|
1020
|
-
apiToken: this.authToken,
|
|
1021
|
-
customFetch: this.customFetch,
|
|
1022
|
-
payload: args,
|
|
1023
|
-
requestId: requestId,
|
|
1024
|
-
});
|
|
1025
|
-
return validateSection(response.data);
|
|
514
|
+
return this.sectionClient.addSection(args, requestId);
|
|
1026
515
|
}
|
|
1027
516
|
/**
|
|
1028
517
|
* Updates a section by its ID with the provided parameters.
|
|
@@ -1033,17 +522,7 @@ export class TodoistApi {
|
|
|
1033
522
|
* @returns A promise that resolves to the updated section.
|
|
1034
523
|
*/
|
|
1035
524
|
async updateSection(id, args, requestId) {
|
|
1036
|
-
|
|
1037
|
-
const response = await request({
|
|
1038
|
-
httpMethod: 'POST',
|
|
1039
|
-
baseUri: this.syncApiBase,
|
|
1040
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id),
|
|
1041
|
-
apiToken: this.authToken,
|
|
1042
|
-
customFetch: this.customFetch,
|
|
1043
|
-
payload: args,
|
|
1044
|
-
requestId: requestId,
|
|
1045
|
-
});
|
|
1046
|
-
return validateSection(response.data);
|
|
525
|
+
return this.sectionClient.updateSection(id, args, requestId);
|
|
1047
526
|
}
|
|
1048
527
|
/**
|
|
1049
528
|
* Deletes a section by its ID.
|
|
@@ -1053,16 +532,7 @@ export class TodoistApi {
|
|
|
1053
532
|
* @returns A promise that resolves to `true` if successful.
|
|
1054
533
|
*/
|
|
1055
534
|
async deleteSection(id, requestId) {
|
|
1056
|
-
|
|
1057
|
-
const response = await request({
|
|
1058
|
-
httpMethod: 'DELETE',
|
|
1059
|
-
baseUri: this.syncApiBase,
|
|
1060
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id),
|
|
1061
|
-
apiToken: this.authToken,
|
|
1062
|
-
customFetch: this.customFetch,
|
|
1063
|
-
requestId: requestId,
|
|
1064
|
-
});
|
|
1065
|
-
return isSuccess(response);
|
|
535
|
+
return this.sectionClient.deleteSection(id, requestId);
|
|
1066
536
|
}
|
|
1067
537
|
/**
|
|
1068
538
|
* Archives a section by its ID.
|
|
@@ -1072,16 +542,7 @@ export class TodoistApi {
|
|
|
1072
542
|
* @returns A promise that resolves to the updated section.
|
|
1073
543
|
*/
|
|
1074
544
|
async archiveSection(id, requestId) {
|
|
1075
|
-
|
|
1076
|
-
const response = await request({
|
|
1077
|
-
httpMethod: 'POST',
|
|
1078
|
-
baseUri: this.syncApiBase,
|
|
1079
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id, SECTION_ARCHIVE),
|
|
1080
|
-
apiToken: this.authToken,
|
|
1081
|
-
customFetch: this.customFetch,
|
|
1082
|
-
requestId: requestId,
|
|
1083
|
-
});
|
|
1084
|
-
return validateSection(response.data);
|
|
545
|
+
return this.sectionClient.archiveSection(id, requestId);
|
|
1085
546
|
}
|
|
1086
547
|
/**
|
|
1087
548
|
* Unarchives a section by its ID.
|
|
@@ -1091,16 +552,7 @@ export class TodoistApi {
|
|
|
1091
552
|
* @returns A promise that resolves to the updated section.
|
|
1092
553
|
*/
|
|
1093
554
|
async unarchiveSection(id, requestId) {
|
|
1094
|
-
|
|
1095
|
-
const response = await request({
|
|
1096
|
-
httpMethod: 'POST',
|
|
1097
|
-
baseUri: this.syncApiBase,
|
|
1098
|
-
relativePath: generatePath(ENDPOINT_REST_SECTIONS, id, SECTION_UNARCHIVE),
|
|
1099
|
-
apiToken: this.authToken,
|
|
1100
|
-
customFetch: this.customFetch,
|
|
1101
|
-
requestId: requestId,
|
|
1102
|
-
});
|
|
1103
|
-
return validateSection(response.data);
|
|
555
|
+
return this.sectionClient.unarchiveSection(id, requestId);
|
|
1104
556
|
}
|
|
1105
557
|
/**
|
|
1106
558
|
* Retrieves a label by its ID.
|
|
@@ -1109,15 +561,7 @@ export class TodoistApi {
|
|
|
1109
561
|
* @returns A promise that resolves to the requested label.
|
|
1110
562
|
*/
|
|
1111
563
|
async getLabel(id) {
|
|
1112
|
-
|
|
1113
|
-
const response = await request({
|
|
1114
|
-
httpMethod: 'GET',
|
|
1115
|
-
baseUri: this.syncApiBase,
|
|
1116
|
-
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
1117
|
-
apiToken: this.authToken,
|
|
1118
|
-
customFetch: this.customFetch,
|
|
1119
|
-
});
|
|
1120
|
-
return validateLabel(response.data);
|
|
564
|
+
return this.labelClient.getLabel(id);
|
|
1121
565
|
}
|
|
1122
566
|
/**
|
|
1123
567
|
* Retrieves all labels.
|
|
@@ -1126,18 +570,7 @@ export class TodoistApi {
|
|
|
1126
570
|
* @returns A promise that resolves to an array of labels.
|
|
1127
571
|
*/
|
|
1128
572
|
async getLabels(args = {}) {
|
|
1129
|
-
|
|
1130
|
-
httpMethod: 'GET',
|
|
1131
|
-
baseUri: this.syncApiBase,
|
|
1132
|
-
relativePath: ENDPOINT_REST_LABELS,
|
|
1133
|
-
apiToken: this.authToken,
|
|
1134
|
-
customFetch: this.customFetch,
|
|
1135
|
-
payload: args,
|
|
1136
|
-
});
|
|
1137
|
-
return {
|
|
1138
|
-
results: validateLabelArray(results),
|
|
1139
|
-
nextCursor,
|
|
1140
|
-
};
|
|
573
|
+
return this.labelClient.getLabels(args);
|
|
1141
574
|
}
|
|
1142
575
|
/**
|
|
1143
576
|
* Searches labels by name.
|
|
@@ -1146,18 +579,7 @@ export class TodoistApi {
|
|
|
1146
579
|
* @returns A promise that resolves to a paginated response of labels.
|
|
1147
580
|
*/
|
|
1148
581
|
async searchLabels(args) {
|
|
1149
|
-
|
|
1150
|
-
httpMethod: 'GET',
|
|
1151
|
-
baseUri: this.syncApiBase,
|
|
1152
|
-
relativePath: ENDPOINT_REST_LABELS_SEARCH,
|
|
1153
|
-
apiToken: this.authToken,
|
|
1154
|
-
customFetch: this.customFetch,
|
|
1155
|
-
payload: args,
|
|
1156
|
-
});
|
|
1157
|
-
return {
|
|
1158
|
-
results: validateLabelArray(results),
|
|
1159
|
-
nextCursor,
|
|
1160
|
-
};
|
|
582
|
+
return this.labelClient.searchLabels(args);
|
|
1161
583
|
}
|
|
1162
584
|
/**
|
|
1163
585
|
* Adds a new label.
|
|
@@ -1167,16 +589,7 @@ export class TodoistApi {
|
|
|
1167
589
|
* @returns A promise that resolves to the created label.
|
|
1168
590
|
*/
|
|
1169
591
|
async addLabel(args, requestId) {
|
|
1170
|
-
|
|
1171
|
-
httpMethod: 'POST',
|
|
1172
|
-
baseUri: this.syncApiBase,
|
|
1173
|
-
relativePath: ENDPOINT_REST_LABELS,
|
|
1174
|
-
apiToken: this.authToken,
|
|
1175
|
-
customFetch: this.customFetch,
|
|
1176
|
-
payload: args,
|
|
1177
|
-
requestId: requestId,
|
|
1178
|
-
});
|
|
1179
|
-
return validateLabel(response.data);
|
|
592
|
+
return this.labelClient.addLabel(args, requestId);
|
|
1180
593
|
}
|
|
1181
594
|
/**
|
|
1182
595
|
* Updates an existing label by its ID.
|
|
@@ -1187,17 +600,7 @@ export class TodoistApi {
|
|
|
1187
600
|
* @returns A promise that resolves to the updated label.
|
|
1188
601
|
*/
|
|
1189
602
|
async updateLabel(id, args, requestId) {
|
|
1190
|
-
|
|
1191
|
-
const response = await request({
|
|
1192
|
-
httpMethod: 'POST',
|
|
1193
|
-
baseUri: this.syncApiBase,
|
|
1194
|
-
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
1195
|
-
apiToken: this.authToken,
|
|
1196
|
-
customFetch: this.customFetch,
|
|
1197
|
-
payload: args,
|
|
1198
|
-
requestId: requestId,
|
|
1199
|
-
});
|
|
1200
|
-
return validateLabel(response.data);
|
|
603
|
+
return this.labelClient.updateLabel(id, args, requestId);
|
|
1201
604
|
}
|
|
1202
605
|
/**
|
|
1203
606
|
* Deletes a label by its ID.
|
|
@@ -1207,16 +610,7 @@ export class TodoistApi {
|
|
|
1207
610
|
* @returns A promise that resolves to `true` if successful.
|
|
1208
611
|
*/
|
|
1209
612
|
async deleteLabel(id, requestId) {
|
|
1210
|
-
|
|
1211
|
-
const response = await request({
|
|
1212
|
-
httpMethod: 'DELETE',
|
|
1213
|
-
baseUri: this.syncApiBase,
|
|
1214
|
-
relativePath: generatePath(ENDPOINT_REST_LABELS, id),
|
|
1215
|
-
apiToken: this.authToken,
|
|
1216
|
-
customFetch: this.customFetch,
|
|
1217
|
-
requestId: requestId,
|
|
1218
|
-
});
|
|
1219
|
-
return isSuccess(response);
|
|
613
|
+
return this.labelClient.deleteLabel(id, requestId);
|
|
1220
614
|
}
|
|
1221
615
|
/**
|
|
1222
616
|
* Retrieves a list of shared labels.
|
|
@@ -1225,15 +619,7 @@ export class TodoistApi {
|
|
|
1225
619
|
* @returns A promise that resolves to an array of shared labels.
|
|
1226
620
|
*/
|
|
1227
621
|
async getSharedLabels(args) {
|
|
1228
|
-
|
|
1229
|
-
httpMethod: 'GET',
|
|
1230
|
-
baseUri: this.syncApiBase,
|
|
1231
|
-
relativePath: ENDPOINT_REST_LABELS_SHARED,
|
|
1232
|
-
apiToken: this.authToken,
|
|
1233
|
-
customFetch: this.customFetch,
|
|
1234
|
-
payload: args,
|
|
1235
|
-
});
|
|
1236
|
-
return { results, nextCursor };
|
|
622
|
+
return this.labelClient.getSharedLabels(args);
|
|
1237
623
|
}
|
|
1238
624
|
/**
|
|
1239
625
|
* Renames an existing shared label.
|
|
@@ -1242,15 +628,7 @@ export class TodoistApi {
|
|
|
1242
628
|
* @returns A promise that resolves to `true` if successful.
|
|
1243
629
|
*/
|
|
1244
630
|
async renameSharedLabel(args) {
|
|
1245
|
-
|
|
1246
|
-
httpMethod: 'POST',
|
|
1247
|
-
baseUri: this.syncApiBase,
|
|
1248
|
-
relativePath: ENDPOINT_REST_LABELS_SHARED_RENAME,
|
|
1249
|
-
apiToken: this.authToken,
|
|
1250
|
-
customFetch: this.customFetch,
|
|
1251
|
-
payload: args,
|
|
1252
|
-
});
|
|
1253
|
-
return isSuccess(response);
|
|
631
|
+
return this.labelClient.renameSharedLabel(args);
|
|
1254
632
|
}
|
|
1255
633
|
/**
|
|
1256
634
|
* Removes a shared label.
|
|
@@ -1259,15 +637,7 @@ export class TodoistApi {
|
|
|
1259
637
|
* @returns A promise that resolves to `true` if successful.
|
|
1260
638
|
*/
|
|
1261
639
|
async removeSharedLabel(args) {
|
|
1262
|
-
|
|
1263
|
-
httpMethod: 'POST',
|
|
1264
|
-
baseUri: this.syncApiBase,
|
|
1265
|
-
relativePath: ENDPOINT_REST_LABELS_SHARED_REMOVE,
|
|
1266
|
-
apiToken: this.authToken,
|
|
1267
|
-
customFetch: this.customFetch,
|
|
1268
|
-
payload: args,
|
|
1269
|
-
});
|
|
1270
|
-
return isSuccess(response);
|
|
640
|
+
return this.labelClient.removeSharedLabel(args);
|
|
1271
641
|
}
|
|
1272
642
|
/**
|
|
1273
643
|
* Retrieves all comments associated with a task or project.
|
|
@@ -1276,18 +646,7 @@ export class TodoistApi {
|
|
|
1276
646
|
* @returns A promise that resolves to an array of comments.
|
|
1277
647
|
*/
|
|
1278
648
|
async getComments(args) {
|
|
1279
|
-
|
|
1280
|
-
httpMethod: 'GET',
|
|
1281
|
-
baseUri: this.syncApiBase,
|
|
1282
|
-
relativePath: ENDPOINT_REST_COMMENTS,
|
|
1283
|
-
apiToken: this.authToken,
|
|
1284
|
-
customFetch: this.customFetch,
|
|
1285
|
-
payload: args,
|
|
1286
|
-
});
|
|
1287
|
-
return {
|
|
1288
|
-
results: validateCommentArray(results),
|
|
1289
|
-
nextCursor,
|
|
1290
|
-
};
|
|
649
|
+
return this.commentClient.getComments(args);
|
|
1291
650
|
}
|
|
1292
651
|
/**
|
|
1293
652
|
* Retrieves a specific comment by its ID.
|
|
@@ -1296,15 +655,7 @@ export class TodoistApi {
|
|
|
1296
655
|
* @returns A promise that resolves to the requested comment.
|
|
1297
656
|
*/
|
|
1298
657
|
async getComment(id) {
|
|
1299
|
-
|
|
1300
|
-
const response = await request({
|
|
1301
|
-
httpMethod: 'GET',
|
|
1302
|
-
baseUri: this.syncApiBase,
|
|
1303
|
-
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
1304
|
-
apiToken: this.authToken,
|
|
1305
|
-
customFetch: this.customFetch,
|
|
1306
|
-
});
|
|
1307
|
-
return validateComment(response.data);
|
|
658
|
+
return this.commentClient.getComment(id);
|
|
1308
659
|
}
|
|
1309
660
|
/**
|
|
1310
661
|
* Adds a comment to a task or project.
|
|
@@ -1314,17 +665,7 @@ export class TodoistApi {
|
|
|
1314
665
|
* @returns A promise that resolves to the created comment.
|
|
1315
666
|
*/
|
|
1316
667
|
async addComment(args, requestId) {
|
|
1317
|
-
|
|
1318
|
-
const response = await request({
|
|
1319
|
-
httpMethod: 'POST',
|
|
1320
|
-
baseUri: this.syncApiBase,
|
|
1321
|
-
relativePath: ENDPOINT_REST_COMMENTS,
|
|
1322
|
-
apiToken: this.authToken,
|
|
1323
|
-
customFetch: this.customFetch,
|
|
1324
|
-
payload: Object.assign(Object.assign({}, rest), (uidsToNotify ? { uidsToNotify: uidsToNotify.join(',') } : {})),
|
|
1325
|
-
requestId: requestId,
|
|
1326
|
-
});
|
|
1327
|
-
return validateComment(response.data);
|
|
668
|
+
return this.commentClient.addComment(args, requestId);
|
|
1328
669
|
}
|
|
1329
670
|
/**
|
|
1330
671
|
* Updates an existing comment by its ID.
|
|
@@ -1335,17 +676,7 @@ export class TodoistApi {
|
|
|
1335
676
|
* @returns A promise that resolves to the updated comment.
|
|
1336
677
|
*/
|
|
1337
678
|
async updateComment(id, args, requestId) {
|
|
1338
|
-
|
|
1339
|
-
const response = await request({
|
|
1340
|
-
httpMethod: 'POST',
|
|
1341
|
-
baseUri: this.syncApiBase,
|
|
1342
|
-
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
1343
|
-
apiToken: this.authToken,
|
|
1344
|
-
customFetch: this.customFetch,
|
|
1345
|
-
payload: args,
|
|
1346
|
-
requestId: requestId,
|
|
1347
|
-
});
|
|
1348
|
-
return validateComment(response.data);
|
|
679
|
+
return this.commentClient.updateComment(id, args, requestId);
|
|
1349
680
|
}
|
|
1350
681
|
/**
|
|
1351
682
|
* Deletes a comment by its ID.
|
|
@@ -1355,16 +686,7 @@ export class TodoistApi {
|
|
|
1355
686
|
* @returns A promise that resolves to `true` if successful.
|
|
1356
687
|
*/
|
|
1357
688
|
async deleteComment(id, requestId) {
|
|
1358
|
-
|
|
1359
|
-
const response = await request({
|
|
1360
|
-
httpMethod: 'DELETE',
|
|
1361
|
-
baseUri: this.syncApiBase,
|
|
1362
|
-
relativePath: generatePath(ENDPOINT_REST_COMMENTS, id),
|
|
1363
|
-
apiToken: this.authToken,
|
|
1364
|
-
customFetch: this.customFetch,
|
|
1365
|
-
requestId: requestId,
|
|
1366
|
-
});
|
|
1367
|
-
return isSuccess(response);
|
|
689
|
+
return this.commentClient.deleteComment(id, requestId);
|
|
1368
690
|
}
|
|
1369
691
|
/**
|
|
1370
692
|
* Retrieves a paginated list of time-based reminders.
|
|
@@ -1373,18 +695,7 @@ export class TodoistApi {
|
|
|
1373
695
|
* @returns A promise that resolves to a paginated list of reminders.
|
|
1374
696
|
*/
|
|
1375
697
|
async getReminders(args = {}) {
|
|
1376
|
-
|
|
1377
|
-
httpMethod: 'GET',
|
|
1378
|
-
baseUri: this.syncApiBase,
|
|
1379
|
-
relativePath: ENDPOINT_REST_REMINDERS,
|
|
1380
|
-
apiToken: this.authToken,
|
|
1381
|
-
customFetch: this.customFetch,
|
|
1382
|
-
payload: args,
|
|
1383
|
-
});
|
|
1384
|
-
return {
|
|
1385
|
-
results: validateReminderArray(results),
|
|
1386
|
-
nextCursor,
|
|
1387
|
-
};
|
|
698
|
+
return this.reminderClient.getReminders(args);
|
|
1388
699
|
}
|
|
1389
700
|
/**
|
|
1390
701
|
* Retrieves a paginated list of location-based reminders.
|
|
@@ -1393,18 +704,7 @@ export class TodoistApi {
|
|
|
1393
704
|
* @returns A promise that resolves to a paginated list of location reminders.
|
|
1394
705
|
*/
|
|
1395
706
|
async getLocationReminders(args = {}) {
|
|
1396
|
-
|
|
1397
|
-
httpMethod: 'GET',
|
|
1398
|
-
baseUri: this.syncApiBase,
|
|
1399
|
-
relativePath: ENDPOINT_REST_LOCATION_REMINDERS,
|
|
1400
|
-
apiToken: this.authToken,
|
|
1401
|
-
customFetch: this.customFetch,
|
|
1402
|
-
payload: args,
|
|
1403
|
-
});
|
|
1404
|
-
return {
|
|
1405
|
-
results: validateLocationReminderArray(results),
|
|
1406
|
-
nextCursor,
|
|
1407
|
-
};
|
|
707
|
+
return this.reminderClient.getLocationReminders(args);
|
|
1408
708
|
}
|
|
1409
709
|
/**
|
|
1410
710
|
* Retrieves a time-based reminder by its ID.
|
|
@@ -1413,23 +713,7 @@ export class TodoistApi {
|
|
|
1413
713
|
* @returns A promise that resolves to the requested reminder.
|
|
1414
714
|
*/
|
|
1415
715
|
async getReminder(id) {
|
|
1416
|
-
|
|
1417
|
-
try {
|
|
1418
|
-
const response = await request({
|
|
1419
|
-
httpMethod: 'GET',
|
|
1420
|
-
baseUri: this.syncApiBase,
|
|
1421
|
-
relativePath: generatePath(ENDPOINT_REST_REMINDERS, id),
|
|
1422
|
-
apiToken: this.authToken,
|
|
1423
|
-
customFetch: this.customFetch,
|
|
1424
|
-
});
|
|
1425
|
-
return validateReminder(response.data);
|
|
1426
|
-
}
|
|
1427
|
-
catch (error) {
|
|
1428
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1429
|
-
throw error;
|
|
1430
|
-
}
|
|
1431
|
-
throw new TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use getLocationReminder instead.`);
|
|
1432
|
-
}
|
|
716
|
+
return this.reminderClient.getReminder(id);
|
|
1433
717
|
}
|
|
1434
718
|
/**
|
|
1435
719
|
* Retrieves a location reminder by its ID.
|
|
@@ -1438,23 +722,7 @@ export class TodoistApi {
|
|
|
1438
722
|
* @returns A promise that resolves to the requested reminder.
|
|
1439
723
|
*/
|
|
1440
724
|
async getLocationReminder(id) {
|
|
1441
|
-
|
|
1442
|
-
try {
|
|
1443
|
-
const response = await request({
|
|
1444
|
-
httpMethod: 'GET',
|
|
1445
|
-
baseUri: this.syncApiBase,
|
|
1446
|
-
relativePath: generatePath(ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
1447
|
-
apiToken: this.authToken,
|
|
1448
|
-
customFetch: this.customFetch,
|
|
1449
|
-
});
|
|
1450
|
-
return validateReminder(response.data);
|
|
1451
|
-
}
|
|
1452
|
-
catch (error) {
|
|
1453
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1454
|
-
throw error;
|
|
1455
|
-
}
|
|
1456
|
-
throw new TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use getReminder instead.`);
|
|
1457
|
-
}
|
|
725
|
+
return this.reminderClient.getLocationReminder(id);
|
|
1458
726
|
}
|
|
1459
727
|
/**
|
|
1460
728
|
* Creates a time-based reminder for a task.
|
|
@@ -1464,16 +732,7 @@ export class TodoistApi {
|
|
|
1464
732
|
* @returns A promise that resolves to the created reminder.
|
|
1465
733
|
*/
|
|
1466
734
|
async addReminder(args, requestId) {
|
|
1467
|
-
|
|
1468
|
-
httpMethod: 'POST',
|
|
1469
|
-
baseUri: this.syncApiBase,
|
|
1470
|
-
relativePath: ENDPOINT_REST_REMINDERS,
|
|
1471
|
-
apiToken: this.authToken,
|
|
1472
|
-
customFetch: this.customFetch,
|
|
1473
|
-
payload: args,
|
|
1474
|
-
requestId: requestId,
|
|
1475
|
-
});
|
|
1476
|
-
return validateReminder(response.data);
|
|
735
|
+
return this.reminderClient.addReminder(args, requestId);
|
|
1477
736
|
}
|
|
1478
737
|
/**
|
|
1479
738
|
* Creates a location reminder for a task.
|
|
@@ -1483,16 +742,7 @@ export class TodoistApi {
|
|
|
1483
742
|
* @returns A promise that resolves to the created reminder.
|
|
1484
743
|
*/
|
|
1485
744
|
async addLocationReminder(args, requestId) {
|
|
1486
|
-
|
|
1487
|
-
httpMethod: 'POST',
|
|
1488
|
-
baseUri: this.syncApiBase,
|
|
1489
|
-
relativePath: ENDPOINT_REST_LOCATION_REMINDERS,
|
|
1490
|
-
apiToken: this.authToken,
|
|
1491
|
-
customFetch: this.customFetch,
|
|
1492
|
-
payload: Object.assign(Object.assign({}, args), { reminderType: 'location' }),
|
|
1493
|
-
requestId: requestId,
|
|
1494
|
-
});
|
|
1495
|
-
return validateReminder(response.data);
|
|
745
|
+
return this.reminderClient.addLocationReminder(args, requestId);
|
|
1496
746
|
}
|
|
1497
747
|
/**
|
|
1498
748
|
* Updates an existing time-based reminder.
|
|
@@ -1503,26 +753,7 @@ export class TodoistApi {
|
|
|
1503
753
|
* @returns A promise that resolves to the updated reminder.
|
|
1504
754
|
*/
|
|
1505
755
|
async updateReminder(id, args, requestId) {
|
|
1506
|
-
|
|
1507
|
-
const payload = UpdateReminderArgsSchema.parse(args);
|
|
1508
|
-
try {
|
|
1509
|
-
const response = await request({
|
|
1510
|
-
httpMethod: 'POST',
|
|
1511
|
-
baseUri: this.syncApiBase,
|
|
1512
|
-
relativePath: generatePath(ENDPOINT_REST_REMINDERS, id),
|
|
1513
|
-
apiToken: this.authToken,
|
|
1514
|
-
customFetch: this.customFetch,
|
|
1515
|
-
payload,
|
|
1516
|
-
requestId: requestId,
|
|
1517
|
-
});
|
|
1518
|
-
return validateReminder(response.data);
|
|
1519
|
-
}
|
|
1520
|
-
catch (error) {
|
|
1521
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1522
|
-
throw error;
|
|
1523
|
-
}
|
|
1524
|
-
throw new TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use updateLocationReminder instead.`);
|
|
1525
|
-
}
|
|
756
|
+
return this.reminderClient.updateReminder(id, args, requestId);
|
|
1526
757
|
}
|
|
1527
758
|
/**
|
|
1528
759
|
* Updates an existing location reminder.
|
|
@@ -1533,26 +764,7 @@ export class TodoistApi {
|
|
|
1533
764
|
* @returns A promise that resolves to the updated reminder.
|
|
1534
765
|
*/
|
|
1535
766
|
async updateLocationReminder(id, args, requestId) {
|
|
1536
|
-
|
|
1537
|
-
const payload = UpdateLocationReminderArgsSchema.parse(args);
|
|
1538
|
-
try {
|
|
1539
|
-
const response = await request({
|
|
1540
|
-
httpMethod: 'POST',
|
|
1541
|
-
baseUri: this.syncApiBase,
|
|
1542
|
-
relativePath: generatePath(ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
1543
|
-
apiToken: this.authToken,
|
|
1544
|
-
customFetch: this.customFetch,
|
|
1545
|
-
payload,
|
|
1546
|
-
requestId: requestId,
|
|
1547
|
-
});
|
|
1548
|
-
return validateReminder(response.data);
|
|
1549
|
-
}
|
|
1550
|
-
catch (error) {
|
|
1551
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1552
|
-
throw error;
|
|
1553
|
-
}
|
|
1554
|
-
throw new TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use updateReminder instead.`);
|
|
1555
|
-
}
|
|
767
|
+
return this.reminderClient.updateLocationReminder(id, args, requestId);
|
|
1556
768
|
}
|
|
1557
769
|
/**
|
|
1558
770
|
* Deletes a time-based reminder by its ID.
|
|
@@ -1562,24 +774,7 @@ export class TodoistApi {
|
|
|
1562
774
|
* @returns A promise that resolves to `true` if successful.
|
|
1563
775
|
*/
|
|
1564
776
|
async deleteReminder(id, requestId) {
|
|
1565
|
-
|
|
1566
|
-
try {
|
|
1567
|
-
const response = await request({
|
|
1568
|
-
httpMethod: 'DELETE',
|
|
1569
|
-
baseUri: this.syncApiBase,
|
|
1570
|
-
relativePath: generatePath(ENDPOINT_REST_REMINDERS, id),
|
|
1571
|
-
apiToken: this.authToken,
|
|
1572
|
-
customFetch: this.customFetch,
|
|
1573
|
-
requestId: requestId,
|
|
1574
|
-
});
|
|
1575
|
-
return isSuccess(response);
|
|
1576
|
-
}
|
|
1577
|
-
catch (error) {
|
|
1578
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1579
|
-
throw error;
|
|
1580
|
-
}
|
|
1581
|
-
throw new TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use deleteLocationReminder instead.`);
|
|
1582
|
-
}
|
|
777
|
+
return this.reminderClient.deleteReminder(id, requestId);
|
|
1583
778
|
}
|
|
1584
779
|
/**
|
|
1585
780
|
* Deletes a location reminder by its ID.
|
|
@@ -1589,24 +784,7 @@ export class TodoistApi {
|
|
|
1589
784
|
* @returns A promise that resolves to `true` if successful.
|
|
1590
785
|
*/
|
|
1591
786
|
async deleteLocationReminder(id, requestId) {
|
|
1592
|
-
|
|
1593
|
-
try {
|
|
1594
|
-
const response = await request({
|
|
1595
|
-
httpMethod: 'DELETE',
|
|
1596
|
-
baseUri: this.syncApiBase,
|
|
1597
|
-
relativePath: generatePath(ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
1598
|
-
apiToken: this.authToken,
|
|
1599
|
-
customFetch: this.customFetch,
|
|
1600
|
-
requestId: requestId,
|
|
1601
|
-
});
|
|
1602
|
-
return isSuccess(response);
|
|
1603
|
-
}
|
|
1604
|
-
catch (error) {
|
|
1605
|
-
if (!(error instanceof TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
1606
|
-
throw error;
|
|
1607
|
-
}
|
|
1608
|
-
throw new TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use deleteReminder instead.`);
|
|
1609
|
-
}
|
|
787
|
+
return this.reminderClient.deleteLocationReminder(id, requestId);
|
|
1610
788
|
}
|
|
1611
789
|
/**
|
|
1612
790
|
* Retrieves productivity stats for the authenticated user.
|
|
@@ -1614,14 +792,7 @@ export class TodoistApi {
|
|
|
1614
792
|
* @returns A promise that resolves to the productivity stats.
|
|
1615
793
|
*/
|
|
1616
794
|
async getProductivityStats() {
|
|
1617
|
-
|
|
1618
|
-
httpMethod: 'GET',
|
|
1619
|
-
baseUri: this.syncApiBase,
|
|
1620
|
-
relativePath: ENDPOINT_REST_PRODUCTIVITY,
|
|
1621
|
-
apiToken: this.authToken,
|
|
1622
|
-
customFetch: this.customFetch,
|
|
1623
|
-
});
|
|
1624
|
-
return validateProductivityStats(response.data);
|
|
795
|
+
return this.productivityClient.getProductivityStats();
|
|
1625
796
|
}
|
|
1626
797
|
/**
|
|
1627
798
|
* Retrieves activity logs with optional filters.
|
|
@@ -1630,37 +801,7 @@ export class TodoistApi {
|
|
|
1630
801
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1631
802
|
*/
|
|
1632
803
|
async getActivityLogs(args = {}) {
|
|
1633
|
-
|
|
1634
|
-
const dateFrom = args.dateFrom instanceof Date ? formatDateToYYYYMMDD(args.dateFrom) : args.dateFrom;
|
|
1635
|
-
const dateTo = args.dateTo instanceof Date ? formatDateToYYYYMMDD(args.dateTo) : args.dateTo;
|
|
1636
|
-
// Destructure out raw date, filter-type, and removed legacy fields so they don't leak into payload
|
|
1637
|
-
const _a = args, { dateFrom: _dateFrom, dateTo: _dateTo, objectEventTypes, objectType: _objectType, eventType: _eventType, since: _since, until: _until } = _a, rest = __rest(_a, ["dateFrom", "dateTo", "objectEventTypes", "objectType", "eventType", "since", "until"]);
|
|
1638
|
-
// Build normalized objectEventTypes for the API
|
|
1639
|
-
let normalizedObjectEventTypes;
|
|
1640
|
-
if (objectEventTypes !== undefined) {
|
|
1641
|
-
const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
|
|
1642
|
-
normalizedObjectEventTypes = arr.map(normalizeObjectEventTypeForApi);
|
|
1643
|
-
}
|
|
1644
|
-
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
|
|
1645
|
-
? { objectEventTypes: normalizedObjectEventTypes }
|
|
1646
|
-
: {}));
|
|
1647
|
-
const { data: { results, nextCursor }, } = await request({
|
|
1648
|
-
httpMethod: 'GET',
|
|
1649
|
-
baseUri: this.syncApiBase,
|
|
1650
|
-
relativePath: ENDPOINT_REST_ACTIVITIES,
|
|
1651
|
-
apiToken: this.authToken,
|
|
1652
|
-
customFetch: this.customFetch,
|
|
1653
|
-
payload: processedArgs,
|
|
1654
|
-
});
|
|
1655
|
-
// Convert legacy API object types back to modern SDK types
|
|
1656
|
-
const normalizedResults = results.map((event) => {
|
|
1657
|
-
const normalizedType = denormalizeObjectTypeFromApi(event.objectType);
|
|
1658
|
-
return Object.assign(Object.assign({}, event), { objectType: normalizedType || event.objectType });
|
|
1659
|
-
});
|
|
1660
|
-
return {
|
|
1661
|
-
results: validateActivityEventArray(normalizedResults),
|
|
1662
|
-
nextCursor,
|
|
1663
|
-
};
|
|
804
|
+
return this.activityClient.getActivityLogs(args);
|
|
1664
805
|
}
|
|
1665
806
|
/**
|
|
1666
807
|
* Uploads a file and returns attachment metadata.
|
|
@@ -1700,21 +841,7 @@ export class TodoistApi {
|
|
|
1700
841
|
* ```
|
|
1701
842
|
*/
|
|
1702
843
|
async uploadFile(args, requestId) {
|
|
1703
|
-
|
|
1704
|
-
if (args.projectId) {
|
|
1705
|
-
additionalFields.project_id = args.projectId;
|
|
1706
|
-
}
|
|
1707
|
-
const data = await uploadMultipartFile({
|
|
1708
|
-
baseUrl: this.syncApiBase,
|
|
1709
|
-
authToken: this.authToken,
|
|
1710
|
-
endpoint: ENDPOINT_REST_UPLOADS,
|
|
1711
|
-
file: args.file,
|
|
1712
|
-
fileName: args.fileName,
|
|
1713
|
-
additionalFields: additionalFields,
|
|
1714
|
-
requestId: requestId,
|
|
1715
|
-
customFetch: this.customFetch,
|
|
1716
|
-
});
|
|
1717
|
-
return validateAttachment(data);
|
|
844
|
+
return this.uploadClient.uploadFile(args, requestId);
|
|
1718
845
|
}
|
|
1719
846
|
/**
|
|
1720
847
|
* Deletes an uploaded file by its URL.
|
|
@@ -1731,16 +858,7 @@ export class TodoistApi {
|
|
|
1731
858
|
* ```
|
|
1732
859
|
*/
|
|
1733
860
|
async deleteUpload(args, requestId) {
|
|
1734
|
-
|
|
1735
|
-
httpMethod: 'DELETE',
|
|
1736
|
-
baseUri: this.syncApiBase,
|
|
1737
|
-
relativePath: ENDPOINT_REST_UPLOADS,
|
|
1738
|
-
apiToken: this.authToken,
|
|
1739
|
-
customFetch: this.customFetch,
|
|
1740
|
-
payload: args,
|
|
1741
|
-
requestId: requestId,
|
|
1742
|
-
});
|
|
1743
|
-
return isSuccess(response);
|
|
861
|
+
return this.uploadClient.deleteUpload(args, requestId);
|
|
1744
862
|
}
|
|
1745
863
|
/**
|
|
1746
864
|
* Fetches the content of a file attachment from a Todoist comment.
|
|
@@ -1767,57 +885,7 @@ export class TodoistApi {
|
|
|
1767
885
|
* ```
|
|
1768
886
|
*/
|
|
1769
887
|
async viewAttachment(commentOrUrl) {
|
|
1770
|
-
|
|
1771
|
-
let fileUrl;
|
|
1772
|
-
if (typeof commentOrUrl === 'string') {
|
|
1773
|
-
fileUrl = commentOrUrl;
|
|
1774
|
-
}
|
|
1775
|
-
else {
|
|
1776
|
-
if (!((_a = commentOrUrl.fileAttachment) === null || _a === void 0 ? void 0 : _a.fileUrl)) {
|
|
1777
|
-
throw new Error('Comment does not have a file attachment');
|
|
1778
|
-
}
|
|
1779
|
-
fileUrl = commentOrUrl.fileAttachment.fileUrl;
|
|
1780
|
-
}
|
|
1781
|
-
// Validate the URL belongs to Todoist to prevent leaking the auth token
|
|
1782
|
-
const urlHostname = new URL(fileUrl).hostname;
|
|
1783
|
-
if (!urlHostname.endsWith('.todoist.com')) {
|
|
1784
|
-
throw new Error('Attachment URLs must be on a todoist.com domain');
|
|
1785
|
-
}
|
|
1786
|
-
const fetchOptions = {
|
|
1787
|
-
method: 'GET',
|
|
1788
|
-
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
1789
|
-
};
|
|
1790
|
-
if (this.customFetch) {
|
|
1791
|
-
const response = await this.customFetch(fileUrl, fetchOptions);
|
|
1792
|
-
if (!response.ok) {
|
|
1793
|
-
throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
|
|
1794
|
-
}
|
|
1795
|
-
// Convert text to ArrayBuffer for custom fetch implementations that lack arrayBuffer()
|
|
1796
|
-
const text = await response.text();
|
|
1797
|
-
const buffer = new TextEncoder().encode(text).buffer;
|
|
1798
|
-
return {
|
|
1799
|
-
ok: response.ok,
|
|
1800
|
-
status: response.status,
|
|
1801
|
-
statusText: response.statusText,
|
|
1802
|
-
headers: response.headers,
|
|
1803
|
-
text: () => Promise.resolve(text),
|
|
1804
|
-
json: () => response.json(),
|
|
1805
|
-
arrayBuffer: () => Promise.resolve(buffer),
|
|
1806
|
-
};
|
|
1807
|
-
}
|
|
1808
|
-
const response = await fetch(fileUrl, fetchOptions);
|
|
1809
|
-
if (!response.ok) {
|
|
1810
|
-
throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
|
|
1811
|
-
}
|
|
1812
|
-
return {
|
|
1813
|
-
ok: response.ok,
|
|
1814
|
-
status: response.status,
|
|
1815
|
-
statusText: response.statusText,
|
|
1816
|
-
headers: headersToRecord(response.headers),
|
|
1817
|
-
text: () => response.text(),
|
|
1818
|
-
json: () => response.json(),
|
|
1819
|
-
arrayBuffer: () => response.arrayBuffer(),
|
|
1820
|
-
};
|
|
888
|
+
return this.uploadClient.viewAttachment(commentOrUrl);
|
|
1821
889
|
}
|
|
1822
890
|
// ── Folders ──
|
|
1823
891
|
/**
|
|
@@ -1827,18 +895,7 @@ export class TodoistApi {
|
|
|
1827
895
|
* @returns A promise that resolves to a paginated response of folders.
|
|
1828
896
|
*/
|
|
1829
897
|
async getFolders(args) {
|
|
1830
|
-
|
|
1831
|
-
httpMethod: 'GET',
|
|
1832
|
-
baseUri: this.syncApiBase,
|
|
1833
|
-
relativePath: ENDPOINT_REST_FOLDERS,
|
|
1834
|
-
apiToken: this.authToken,
|
|
1835
|
-
customFetch: this.customFetch,
|
|
1836
|
-
payload: args,
|
|
1837
|
-
});
|
|
1838
|
-
return {
|
|
1839
|
-
results: validateFolderArray(results),
|
|
1840
|
-
nextCursor,
|
|
1841
|
-
};
|
|
898
|
+
return this.folderClient.getFolders(args);
|
|
1842
899
|
}
|
|
1843
900
|
/**
|
|
1844
901
|
* Retrieves a single folder by its ID.
|
|
@@ -1847,15 +904,7 @@ export class TodoistApi {
|
|
|
1847
904
|
* @returns A promise that resolves to the requested folder.
|
|
1848
905
|
*/
|
|
1849
906
|
async getFolder(id) {
|
|
1850
|
-
|
|
1851
|
-
const response = await request({
|
|
1852
|
-
httpMethod: 'GET',
|
|
1853
|
-
baseUri: this.syncApiBase,
|
|
1854
|
-
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
1855
|
-
apiToken: this.authToken,
|
|
1856
|
-
customFetch: this.customFetch,
|
|
1857
|
-
});
|
|
1858
|
-
return validateFolder(response.data);
|
|
907
|
+
return this.folderClient.getFolder(id);
|
|
1859
908
|
}
|
|
1860
909
|
/**
|
|
1861
910
|
* Creates a new folder.
|
|
@@ -1865,16 +914,7 @@ export class TodoistApi {
|
|
|
1865
914
|
* @returns A promise that resolves to the created folder.
|
|
1866
915
|
*/
|
|
1867
916
|
async addFolder(args, requestId) {
|
|
1868
|
-
|
|
1869
|
-
httpMethod: 'POST',
|
|
1870
|
-
baseUri: this.syncApiBase,
|
|
1871
|
-
relativePath: ENDPOINT_REST_FOLDERS,
|
|
1872
|
-
apiToken: this.authToken,
|
|
1873
|
-
customFetch: this.customFetch,
|
|
1874
|
-
payload: args,
|
|
1875
|
-
requestId: requestId,
|
|
1876
|
-
});
|
|
1877
|
-
return validateFolder(response.data);
|
|
917
|
+
return this.folderClient.addFolder(args, requestId);
|
|
1878
918
|
}
|
|
1879
919
|
/**
|
|
1880
920
|
* Updates an existing folder by its ID.
|
|
@@ -1885,17 +925,7 @@ export class TodoistApi {
|
|
|
1885
925
|
* @returns A promise that resolves to the updated folder.
|
|
1886
926
|
*/
|
|
1887
927
|
async updateFolder(id, args, requestId) {
|
|
1888
|
-
|
|
1889
|
-
const response = await request({
|
|
1890
|
-
httpMethod: 'POST',
|
|
1891
|
-
baseUri: this.syncApiBase,
|
|
1892
|
-
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
1893
|
-
apiToken: this.authToken,
|
|
1894
|
-
customFetch: this.customFetch,
|
|
1895
|
-
payload: args,
|
|
1896
|
-
requestId: requestId,
|
|
1897
|
-
});
|
|
1898
|
-
return validateFolder(response.data);
|
|
928
|
+
return this.folderClient.updateFolder(id, args, requestId);
|
|
1899
929
|
}
|
|
1900
930
|
/**
|
|
1901
931
|
* Deletes a folder by its ID.
|
|
@@ -1905,16 +935,38 @@ export class TodoistApi {
|
|
|
1905
935
|
* @returns A promise that resolves to `true` if successful.
|
|
1906
936
|
*/
|
|
1907
937
|
async deleteFolder(id, requestId) {
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
938
|
+
return this.folderClient.deleteFolder(id, requestId);
|
|
939
|
+
}
|
|
940
|
+
// ── Goals ──
|
|
941
|
+
async getGoals(args) {
|
|
942
|
+
return this.goalsClient.getGoals(args);
|
|
943
|
+
}
|
|
944
|
+
async searchGoals(args) {
|
|
945
|
+
return this.goalsClient.searchGoals(args);
|
|
946
|
+
}
|
|
947
|
+
async getGoal(id) {
|
|
948
|
+
return this.goalsClient.getGoal(id);
|
|
949
|
+
}
|
|
950
|
+
async addGoal(args, requestId) {
|
|
951
|
+
return this.goalsClient.addGoal(args, requestId);
|
|
952
|
+
}
|
|
953
|
+
async updateGoal(id, args, requestId) {
|
|
954
|
+
return this.goalsClient.updateGoal(id, args, requestId);
|
|
955
|
+
}
|
|
956
|
+
async deleteGoal(id, requestId) {
|
|
957
|
+
return this.goalsClient.deleteGoal(id, requestId);
|
|
958
|
+
}
|
|
959
|
+
async completeGoal(id, requestId) {
|
|
960
|
+
return this.goalsClient.completeGoal(id, requestId);
|
|
961
|
+
}
|
|
962
|
+
async uncompleteGoal(id, requestId) {
|
|
963
|
+
return this.goalsClient.uncompleteGoal(id, requestId);
|
|
964
|
+
}
|
|
965
|
+
async linkTaskToGoal(args, requestId) {
|
|
966
|
+
return this.goalsClient.linkTaskToGoal(args, requestId);
|
|
967
|
+
}
|
|
968
|
+
async unlinkTaskFromGoal(args, requestId) {
|
|
969
|
+
return this.goalsClient.unlinkTaskFromGoal(args, requestId);
|
|
1918
970
|
}
|
|
1919
971
|
// ── Backups ──
|
|
1920
972
|
/**
|
|
@@ -1924,15 +976,7 @@ export class TodoistApi {
|
|
|
1924
976
|
* @returns A promise that resolves to an array of backups.
|
|
1925
977
|
*/
|
|
1926
978
|
async getBackups(args = {}) {
|
|
1927
|
-
|
|
1928
|
-
httpMethod: 'GET',
|
|
1929
|
-
baseUri: this.syncApiBase,
|
|
1930
|
-
relativePath: ENDPOINT_REST_BACKUPS,
|
|
1931
|
-
apiToken: this.authToken,
|
|
1932
|
-
customFetch: this.customFetch,
|
|
1933
|
-
payload: args,
|
|
1934
|
-
});
|
|
1935
|
-
return validateBackupArray(response.data);
|
|
979
|
+
return this.backupClient.getBackups(args);
|
|
1936
980
|
}
|
|
1937
981
|
/**
|
|
1938
982
|
* Downloads a backup file as binary data.
|
|
@@ -1941,40 +985,7 @@ export class TodoistApi {
|
|
|
1941
985
|
* @returns A promise that resolves to a response with binary data accessible via arrayBuffer().
|
|
1942
986
|
*/
|
|
1943
987
|
async downloadBackup(args) {
|
|
1944
|
-
|
|
1945
|
-
const fetchOptions = {
|
|
1946
|
-
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
1947
|
-
};
|
|
1948
|
-
if (this.customFetch) {
|
|
1949
|
-
const response = await this.customFetch(url, fetchOptions);
|
|
1950
|
-
if (!response.ok) {
|
|
1951
|
-
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
1952
|
-
}
|
|
1953
|
-
const text = await response.text();
|
|
1954
|
-
const buffer = new TextEncoder().encode(text).buffer;
|
|
1955
|
-
return {
|
|
1956
|
-
ok: response.ok,
|
|
1957
|
-
status: response.status,
|
|
1958
|
-
statusText: response.statusText,
|
|
1959
|
-
headers: response.headers,
|
|
1960
|
-
text: () => Promise.resolve(text),
|
|
1961
|
-
json: () => response.json(),
|
|
1962
|
-
arrayBuffer: () => Promise.resolve(buffer),
|
|
1963
|
-
};
|
|
1964
|
-
}
|
|
1965
|
-
const response = await fetch(url, fetchOptions);
|
|
1966
|
-
if (!response.ok) {
|
|
1967
|
-
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
1968
|
-
}
|
|
1969
|
-
return {
|
|
1970
|
-
ok: response.ok,
|
|
1971
|
-
status: response.status,
|
|
1972
|
-
statusText: response.statusText,
|
|
1973
|
-
headers: headersToRecord(response.headers),
|
|
1974
|
-
text: () => response.text(),
|
|
1975
|
-
json: () => response.json(),
|
|
1976
|
-
arrayBuffer: () => response.arrayBuffer(),
|
|
1977
|
-
};
|
|
988
|
+
return this.backupClient.downloadBackup(args);
|
|
1978
989
|
}
|
|
1979
990
|
// ── Emails ──
|
|
1980
991
|
/**
|
|
@@ -1985,16 +996,7 @@ export class TodoistApi {
|
|
|
1985
996
|
* @returns A promise that resolves to the email address.
|
|
1986
997
|
*/
|
|
1987
998
|
async getOrCreateEmailForwarding(args, requestId) {
|
|
1988
|
-
|
|
1989
|
-
httpMethod: 'PUT',
|
|
1990
|
-
baseUri: this.syncApiBase,
|
|
1991
|
-
relativePath: ENDPOINT_REST_EMAILS,
|
|
1992
|
-
apiToken: this.authToken,
|
|
1993
|
-
customFetch: this.customFetch,
|
|
1994
|
-
payload: args,
|
|
1995
|
-
requestId: requestId,
|
|
1996
|
-
});
|
|
1997
|
-
return data;
|
|
999
|
+
return this.emailClient.getOrCreateEmailForwarding(args, requestId);
|
|
1998
1000
|
}
|
|
1999
1001
|
/**
|
|
2000
1002
|
* Disables email forwarding for an object.
|
|
@@ -2004,19 +1006,7 @@ export class TodoistApi {
|
|
|
2004
1006
|
* @returns A promise that resolves to `true` if successful.
|
|
2005
1007
|
*/
|
|
2006
1008
|
async disableEmailForwarding(args, requestId) {
|
|
2007
|
-
|
|
2008
|
-
obj_type: args.objType,
|
|
2009
|
-
obj_id: args.objId,
|
|
2010
|
-
});
|
|
2011
|
-
const response = await request({
|
|
2012
|
-
httpMethod: 'DELETE',
|
|
2013
|
-
baseUri: this.syncApiBase,
|
|
2014
|
-
relativePath: `${ENDPOINT_REST_EMAILS}?${queryParams.toString()}`,
|
|
2015
|
-
apiToken: this.authToken,
|
|
2016
|
-
customFetch: this.customFetch,
|
|
2017
|
-
requestId: requestId,
|
|
2018
|
-
});
|
|
2019
|
-
return isSuccess(response);
|
|
1009
|
+
return this.emailClient.disableEmailForwarding(args, requestId);
|
|
2020
1010
|
}
|
|
2021
1011
|
// ── ID Mappings ──
|
|
2022
1012
|
/**
|
|
@@ -2026,14 +1016,7 @@ export class TodoistApi {
|
|
|
2026
1016
|
* @returns A promise that resolves to an array of ID mappings.
|
|
2027
1017
|
*/
|
|
2028
1018
|
async getIdMappings(args) {
|
|
2029
|
-
|
|
2030
|
-
httpMethod: 'GET',
|
|
2031
|
-
baseUri: this.syncApiBase,
|
|
2032
|
-
relativePath: generatePath(ENDPOINT_REST_ID_MAPPINGS, args.objName, args.objIds.join(',')),
|
|
2033
|
-
apiToken: this.authToken,
|
|
2034
|
-
customFetch: this.customFetch,
|
|
2035
|
-
});
|
|
2036
|
-
return validateIdMappingArray(response.data);
|
|
1019
|
+
return this.idMappingClient.getIdMappings(args);
|
|
2037
1020
|
}
|
|
2038
1021
|
/**
|
|
2039
1022
|
* Retrieves moved IDs for objects that have been migrated.
|
|
@@ -2042,15 +1025,7 @@ export class TodoistApi {
|
|
|
2042
1025
|
* @returns A promise that resolves to an array of moved ID pairs.
|
|
2043
1026
|
*/
|
|
2044
1027
|
async getMovedIds(args) {
|
|
2045
|
-
|
|
2046
|
-
httpMethod: 'GET',
|
|
2047
|
-
baseUri: this.syncApiBase,
|
|
2048
|
-
relativePath: generatePath(ENDPOINT_REST_MOVED_IDS, args.objName),
|
|
2049
|
-
apiToken: this.authToken,
|
|
2050
|
-
customFetch: this.customFetch,
|
|
2051
|
-
payload: args.oldIds ? { oldIds: args.oldIds.join(',') } : undefined,
|
|
2052
|
-
});
|
|
2053
|
-
return validateMovedIdArray(response.data);
|
|
1028
|
+
return this.idMappingClient.getMovedIds(args);
|
|
2054
1029
|
}
|
|
2055
1030
|
// ── Templates ──
|
|
2056
1031
|
/**
|
|
@@ -2060,15 +1035,7 @@ export class TodoistApi {
|
|
|
2060
1035
|
* @returns A promise that resolves to the template file content as a string.
|
|
2061
1036
|
*/
|
|
2062
1037
|
async exportTemplateAsFile(args) {
|
|
2063
|
-
|
|
2064
|
-
httpMethod: 'GET',
|
|
2065
|
-
baseUri: this.syncApiBase,
|
|
2066
|
-
relativePath: ENDPOINT_REST_TEMPLATES_FILE,
|
|
2067
|
-
apiToken: this.authToken,
|
|
2068
|
-
customFetch: this.customFetch,
|
|
2069
|
-
payload: args,
|
|
2070
|
-
});
|
|
2071
|
-
return response.data;
|
|
1038
|
+
return this.templateClient.exportTemplateAsFile(args);
|
|
2072
1039
|
}
|
|
2073
1040
|
/**
|
|
2074
1041
|
* Exports a project as a template URL.
|
|
@@ -2077,15 +1044,7 @@ export class TodoistApi {
|
|
|
2077
1044
|
* @returns A promise that resolves to the file name and URL.
|
|
2078
1045
|
*/
|
|
2079
1046
|
async exportTemplateAsUrl(args) {
|
|
2080
|
-
|
|
2081
|
-
httpMethod: 'GET',
|
|
2082
|
-
baseUri: this.syncApiBase,
|
|
2083
|
-
relativePath: ENDPOINT_REST_TEMPLATES_URL,
|
|
2084
|
-
apiToken: this.authToken,
|
|
2085
|
-
customFetch: this.customFetch,
|
|
2086
|
-
payload: args,
|
|
2087
|
-
});
|
|
2088
|
-
return data;
|
|
1047
|
+
return this.templateClient.exportTemplateAsUrl(args);
|
|
2089
1048
|
}
|
|
2090
1049
|
/**
|
|
2091
1050
|
* Creates a new project from a template file.
|
|
@@ -2095,22 +1054,7 @@ export class TodoistApi {
|
|
|
2095
1054
|
* @returns A promise that resolves to the created project data.
|
|
2096
1055
|
*/
|
|
2097
1056
|
async createProjectFromTemplate(args, requestId) {
|
|
2098
|
-
|
|
2099
|
-
const additionalFields = { name };
|
|
2100
|
-
if (workspaceId !== undefined && workspaceId !== null) {
|
|
2101
|
-
additionalFields.workspace_id = workspaceId;
|
|
2102
|
-
}
|
|
2103
|
-
const data = await uploadMultipartFile({
|
|
2104
|
-
baseUrl: this.syncApiBase,
|
|
2105
|
-
authToken: this.authToken,
|
|
2106
|
-
endpoint: ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE,
|
|
2107
|
-
file,
|
|
2108
|
-
fileName,
|
|
2109
|
-
additionalFields,
|
|
2110
|
-
customFetch: this.customFetch,
|
|
2111
|
-
requestId,
|
|
2112
|
-
});
|
|
2113
|
-
return this.validateTemplateResponse(camelCaseKeys(data));
|
|
1057
|
+
return this.templateClient.createProjectFromTemplate(args, requestId);
|
|
2114
1058
|
}
|
|
2115
1059
|
/**
|
|
2116
1060
|
* Imports a template file into an existing project.
|
|
@@ -2120,18 +1064,7 @@ export class TodoistApi {
|
|
|
2120
1064
|
* @returns A promise that resolves to the import result.
|
|
2121
1065
|
*/
|
|
2122
1066
|
async importTemplateIntoProject(args, requestId) {
|
|
2123
|
-
|
|
2124
|
-
const data = await uploadMultipartFile({
|
|
2125
|
-
baseUrl: this.syncApiBase,
|
|
2126
|
-
authToken: this.authToken,
|
|
2127
|
-
endpoint: ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE,
|
|
2128
|
-
file,
|
|
2129
|
-
fileName,
|
|
2130
|
-
additionalFields: { project_id: projectId },
|
|
2131
|
-
customFetch: this.customFetch,
|
|
2132
|
-
requestId,
|
|
2133
|
-
});
|
|
2134
|
-
return this.validateTemplateResponse(camelCaseKeys(data));
|
|
1067
|
+
return this.templateClient.importTemplateIntoProject(args, requestId);
|
|
2135
1068
|
}
|
|
2136
1069
|
/**
|
|
2137
1070
|
* Imports a template by ID into an existing project.
|
|
@@ -2141,20 +1074,7 @@ export class TodoistApi {
|
|
|
2141
1074
|
* @returns A promise that resolves to the import result.
|
|
2142
1075
|
*/
|
|
2143
1076
|
async importTemplateFromId(args, requestId) {
|
|
2144
|
-
|
|
2145
|
-
httpMethod: 'POST',
|
|
2146
|
-
baseUri: this.syncApiBase,
|
|
2147
|
-
relativePath: ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID,
|
|
2148
|
-
apiToken: this.authToken,
|
|
2149
|
-
customFetch: this.customFetch,
|
|
2150
|
-
payload: args,
|
|
2151
|
-
requestId: requestId,
|
|
2152
|
-
});
|
|
2153
|
-
return this.validateTemplateResponse(data);
|
|
2154
|
-
}
|
|
2155
|
-
validateTemplateResponse(data) {
|
|
2156
|
-
var _a, _b, _c, _d;
|
|
2157
|
-
return Object.assign(Object.assign({}, data), { projects: validateProjectArray((_a = data.projects) !== null && _a !== void 0 ? _a : []), sections: validateSectionArray((_b = data.sections) !== null && _b !== void 0 ? _b : []), tasks: validateTaskArray((_c = data.tasks) !== null && _c !== void 0 ? _c : []), comments: validateCommentArray((_d = data.comments) !== null && _d !== void 0 ? _d : []) });
|
|
1077
|
+
return this.templateClient.importTemplateFromId(args, requestId);
|
|
2158
1078
|
}
|
|
2159
1079
|
/* Workspace methods */
|
|
2160
1080
|
/**
|
|
@@ -2165,16 +1085,7 @@ export class TodoistApi {
|
|
|
2165
1085
|
* @returns Array of email addresses with pending invitations.
|
|
2166
1086
|
*/
|
|
2167
1087
|
async getWorkspaceInvitations(args, requestId) {
|
|
2168
|
-
|
|
2169
|
-
httpMethod: 'GET',
|
|
2170
|
-
baseUri: this.syncApiBase,
|
|
2171
|
-
relativePath: ENDPOINT_WORKSPACE_INVITATIONS,
|
|
2172
|
-
apiToken: this.authToken,
|
|
2173
|
-
customFetch: this.customFetch,
|
|
2174
|
-
payload: { workspace_id: args.workspaceId },
|
|
2175
|
-
requestId: requestId,
|
|
2176
|
-
});
|
|
2177
|
-
return response.data;
|
|
1088
|
+
return this.workspaceClient.getWorkspaceInvitations(args, requestId);
|
|
2178
1089
|
}
|
|
2179
1090
|
/**
|
|
2180
1091
|
* Gets all workspace invitations (admin only).
|
|
@@ -2183,20 +1094,7 @@ export class TodoistApi {
|
|
|
2183
1094
|
* @returns Array of email addresses with pending invitations.
|
|
2184
1095
|
*/
|
|
2185
1096
|
async getAllWorkspaceInvitations(args = {}, requestId) {
|
|
2186
|
-
|
|
2187
|
-
if (args.workspaceId) {
|
|
2188
|
-
queryParams.workspace_id = args.workspaceId;
|
|
2189
|
-
}
|
|
2190
|
-
const response = await request({
|
|
2191
|
-
httpMethod: 'GET',
|
|
2192
|
-
baseUri: this.syncApiBase,
|
|
2193
|
-
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_ALL,
|
|
2194
|
-
apiToken: this.authToken,
|
|
2195
|
-
customFetch: this.customFetch,
|
|
2196
|
-
payload: queryParams,
|
|
2197
|
-
requestId: requestId,
|
|
2198
|
-
});
|
|
2199
|
-
return validateWorkspaceInvitationArray(response.data);
|
|
1097
|
+
return this.workspaceClient.getAllWorkspaceInvitations(args, requestId);
|
|
2200
1098
|
}
|
|
2201
1099
|
/**
|
|
2202
1100
|
* Deletes a workspace invitation (admin only).
|
|
@@ -2206,19 +1104,7 @@ export class TodoistApi {
|
|
|
2206
1104
|
* @returns The deleted invitation.
|
|
2207
1105
|
*/
|
|
2208
1106
|
async deleteWorkspaceInvitation(args, requestId) {
|
|
2209
|
-
|
|
2210
|
-
httpMethod: 'POST',
|
|
2211
|
-
baseUri: this.syncApiBase,
|
|
2212
|
-
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
|
|
2213
|
-
apiToken: this.authToken,
|
|
2214
|
-
customFetch: this.customFetch,
|
|
2215
|
-
payload: {
|
|
2216
|
-
workspace_id: args.workspaceId,
|
|
2217
|
-
user_email: args.userEmail,
|
|
2218
|
-
},
|
|
2219
|
-
requestId: requestId,
|
|
2220
|
-
});
|
|
2221
|
-
return validateWorkspaceInvitation(response.data);
|
|
1107
|
+
return this.workspaceClient.deleteWorkspaceInvitation(args, requestId);
|
|
2222
1108
|
}
|
|
2223
1109
|
/**
|
|
2224
1110
|
* Accepts a workspace invitation.
|
|
@@ -2228,15 +1114,7 @@ export class TodoistApi {
|
|
|
2228
1114
|
* @returns The accepted invitation.
|
|
2229
1115
|
*/
|
|
2230
1116
|
async acceptWorkspaceInvitation(args, requestId) {
|
|
2231
|
-
|
|
2232
|
-
httpMethod: 'PUT',
|
|
2233
|
-
baseUri: this.syncApiBase,
|
|
2234
|
-
relativePath: getWorkspaceInvitationAcceptEndpoint(args.inviteCode),
|
|
2235
|
-
apiToken: this.authToken,
|
|
2236
|
-
customFetch: this.customFetch,
|
|
2237
|
-
requestId: requestId,
|
|
2238
|
-
});
|
|
2239
|
-
return validateWorkspaceInvitation(response.data);
|
|
1117
|
+
return this.workspaceClient.acceptWorkspaceInvitation(args, requestId);
|
|
2240
1118
|
}
|
|
2241
1119
|
/**
|
|
2242
1120
|
* Rejects a workspace invitation.
|
|
@@ -2246,15 +1124,7 @@ export class TodoistApi {
|
|
|
2246
1124
|
* @returns The rejected invitation.
|
|
2247
1125
|
*/
|
|
2248
1126
|
async rejectWorkspaceInvitation(args, requestId) {
|
|
2249
|
-
|
|
2250
|
-
httpMethod: 'PUT',
|
|
2251
|
-
baseUri: this.syncApiBase,
|
|
2252
|
-
relativePath: getWorkspaceInvitationRejectEndpoint(args.inviteCode),
|
|
2253
|
-
apiToken: this.authToken,
|
|
2254
|
-
customFetch: this.customFetch,
|
|
2255
|
-
requestId: requestId,
|
|
2256
|
-
});
|
|
2257
|
-
return validateWorkspaceInvitation(response.data);
|
|
1127
|
+
return this.workspaceClient.rejectWorkspaceInvitation(args, requestId);
|
|
2258
1128
|
}
|
|
2259
1129
|
/**
|
|
2260
1130
|
* Joins a workspace via invitation link or domain auto-join.
|
|
@@ -2264,19 +1134,7 @@ export class TodoistApi {
|
|
|
2264
1134
|
* @returns Workspace user information.
|
|
2265
1135
|
*/
|
|
2266
1136
|
async joinWorkspace(args, requestId) {
|
|
2267
|
-
|
|
2268
|
-
httpMethod: 'POST',
|
|
2269
|
-
baseUri: this.syncApiBase,
|
|
2270
|
-
relativePath: ENDPOINT_WORKSPACE_JOIN,
|
|
2271
|
-
apiToken: this.authToken,
|
|
2272
|
-
customFetch: this.customFetch,
|
|
2273
|
-
payload: {
|
|
2274
|
-
invite_code: args.inviteCode,
|
|
2275
|
-
workspace_id: args.workspaceId,
|
|
2276
|
-
},
|
|
2277
|
-
requestId: requestId,
|
|
2278
|
-
});
|
|
2279
|
-
return validateJoinWorkspaceResult(response.data);
|
|
1137
|
+
return this.workspaceClient.joinWorkspace(args, requestId);
|
|
2280
1138
|
}
|
|
2281
1139
|
/**
|
|
2282
1140
|
* Uploads or updates a workspace logo.
|
|
@@ -2286,44 +1144,7 @@ export class TodoistApi {
|
|
|
2286
1144
|
* @returns Logo information or null if deleted.
|
|
2287
1145
|
*/
|
|
2288
1146
|
async uploadWorkspaceLogo(args, requestId) {
|
|
2289
|
-
|
|
2290
|
-
// Delete logo
|
|
2291
|
-
const data = await uploadMultipartFile({
|
|
2292
|
-
baseUrl: this.syncApiBase,
|
|
2293
|
-
authToken: this.authToken,
|
|
2294
|
-
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
2295
|
-
file: Buffer.alloc(0), // Empty buffer for delete
|
|
2296
|
-
fileName: 'delete',
|
|
2297
|
-
additionalFields: {
|
|
2298
|
-
workspace_id: args.workspaceId,
|
|
2299
|
-
delete: true,
|
|
2300
|
-
},
|
|
2301
|
-
requestId: requestId,
|
|
2302
|
-
customFetch: this.customFetch,
|
|
2303
|
-
});
|
|
2304
|
-
return data;
|
|
2305
|
-
}
|
|
2306
|
-
if (!args.file) {
|
|
2307
|
-
throw new Error('file is required when not deleting logo');
|
|
2308
|
-
}
|
|
2309
|
-
// Validate buffer is not empty if it's a Buffer
|
|
2310
|
-
if (Buffer.isBuffer(args.file) && args.file.length === 0) {
|
|
2311
|
-
throw new Error('Cannot upload empty image file');
|
|
2312
|
-
}
|
|
2313
|
-
const additionalFields = {
|
|
2314
|
-
workspace_id: args.workspaceId,
|
|
2315
|
-
};
|
|
2316
|
-
const data = await uploadMultipartFile({
|
|
2317
|
-
baseUrl: this.syncApiBase,
|
|
2318
|
-
authToken: this.authToken,
|
|
2319
|
-
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
2320
|
-
file: args.file,
|
|
2321
|
-
fileName: args.fileName,
|
|
2322
|
-
additionalFields: additionalFields,
|
|
2323
|
-
requestId: requestId,
|
|
2324
|
-
customFetch: this.customFetch,
|
|
2325
|
-
});
|
|
2326
|
-
return data;
|
|
1147
|
+
return this.workspaceClient.uploadWorkspaceLogo(args, requestId);
|
|
2327
1148
|
}
|
|
2328
1149
|
/**
|
|
2329
1150
|
* Gets workspace plan and billing details.
|
|
@@ -2333,16 +1154,7 @@ export class TodoistApi {
|
|
|
2333
1154
|
* @returns Workspace plan details.
|
|
2334
1155
|
*/
|
|
2335
1156
|
async getWorkspacePlanDetails(args, requestId) {
|
|
2336
|
-
|
|
2337
|
-
httpMethod: 'GET',
|
|
2338
|
-
baseUri: this.syncApiBase,
|
|
2339
|
-
relativePath: ENDPOINT_WORKSPACE_PLAN_DETAILS,
|
|
2340
|
-
apiToken: this.authToken,
|
|
2341
|
-
customFetch: this.customFetch,
|
|
2342
|
-
payload: { workspace_id: args.workspaceId },
|
|
2343
|
-
requestId: requestId,
|
|
2344
|
-
});
|
|
2345
|
-
return validateWorkspacePlanDetails(response.data);
|
|
1157
|
+
return this.workspaceClient.getWorkspacePlanDetails(args, requestId);
|
|
2346
1158
|
}
|
|
2347
1159
|
/**
|
|
2348
1160
|
* Gets workspace users with pagination.
|
|
@@ -2352,30 +1164,7 @@ export class TodoistApi {
|
|
|
2352
1164
|
* @returns Paginated list of workspace users.
|
|
2353
1165
|
*/
|
|
2354
1166
|
async getWorkspaceUsers(args = {}, requestId) {
|
|
2355
|
-
|
|
2356
|
-
if (args.workspaceId !== undefined && args.workspaceId !== null) {
|
|
2357
|
-
queryParams.workspace_id = args.workspaceId;
|
|
2358
|
-
}
|
|
2359
|
-
if (args.cursor) {
|
|
2360
|
-
queryParams.cursor = args.cursor;
|
|
2361
|
-
}
|
|
2362
|
-
if (args.limit) {
|
|
2363
|
-
queryParams.limit = args.limit;
|
|
2364
|
-
}
|
|
2365
|
-
const response = await request({
|
|
2366
|
-
httpMethod: 'GET',
|
|
2367
|
-
baseUri: this.syncApiBase,
|
|
2368
|
-
relativePath: ENDPOINT_WORKSPACE_USERS,
|
|
2369
|
-
apiToken: this.authToken,
|
|
2370
|
-
customFetch: this.customFetch,
|
|
2371
|
-
payload: queryParams,
|
|
2372
|
-
requestId: requestId,
|
|
2373
|
-
});
|
|
2374
|
-
return {
|
|
2375
|
-
hasMore: response.data.hasMore || false,
|
|
2376
|
-
nextCursor: response.data.nextCursor,
|
|
2377
|
-
workspaceUsers: validateWorkspaceUserArray(response.data.workspaceUsers || []),
|
|
2378
|
-
};
|
|
1167
|
+
return this.workspaceClient.getWorkspaceUsers(args, requestId);
|
|
2379
1168
|
}
|
|
2380
1169
|
/**
|
|
2381
1170
|
* Retrieves all workspaces for the authenticated user.
|
|
@@ -2392,15 +1181,7 @@ export class TodoistApi {
|
|
|
2392
1181
|
* ```
|
|
2393
1182
|
*/
|
|
2394
1183
|
async getWorkspaces(requestId) {
|
|
2395
|
-
|
|
2396
|
-
httpMethod: 'GET',
|
|
2397
|
-
baseUri: this.syncApiBase,
|
|
2398
|
-
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
2399
|
-
apiToken: this.authToken,
|
|
2400
|
-
customFetch: this.customFetch,
|
|
2401
|
-
requestId: requestId,
|
|
2402
|
-
});
|
|
2403
|
-
return validateWorkspaceArray(response.data);
|
|
1184
|
+
return this.workspaceClient.getWorkspaces(requestId);
|
|
2404
1185
|
}
|
|
2405
1186
|
/**
|
|
2406
1187
|
* Retrieves a workspace by its ID.
|
|
@@ -2410,16 +1191,7 @@ export class TodoistApi {
|
|
|
2410
1191
|
* @returns A promise that resolves to the requested workspace.
|
|
2411
1192
|
*/
|
|
2412
1193
|
async getWorkspace(id, requestId) {
|
|
2413
|
-
|
|
2414
|
-
const response = await request({
|
|
2415
|
-
httpMethod: 'GET',
|
|
2416
|
-
baseUri: this.syncApiBase,
|
|
2417
|
-
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
2418
|
-
apiToken: this.authToken,
|
|
2419
|
-
customFetch: this.customFetch,
|
|
2420
|
-
requestId: requestId,
|
|
2421
|
-
});
|
|
2422
|
-
return validateWorkspace(response.data);
|
|
1194
|
+
return this.workspaceClient.getWorkspace(id, requestId);
|
|
2423
1195
|
}
|
|
2424
1196
|
/**
|
|
2425
1197
|
* Creates a new workspace.
|
|
@@ -2429,16 +1201,7 @@ export class TodoistApi {
|
|
|
2429
1201
|
* @returns A promise that resolves to the created workspace.
|
|
2430
1202
|
*/
|
|
2431
1203
|
async addWorkspace(args, requestId) {
|
|
2432
|
-
|
|
2433
|
-
httpMethod: 'POST',
|
|
2434
|
-
baseUri: this.syncApiBase,
|
|
2435
|
-
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
2436
|
-
apiToken: this.authToken,
|
|
2437
|
-
customFetch: this.customFetch,
|
|
2438
|
-
payload: args,
|
|
2439
|
-
requestId: requestId,
|
|
2440
|
-
});
|
|
2441
|
-
return validateWorkspace(response.data);
|
|
1204
|
+
return this.workspaceClient.addWorkspace(args, requestId);
|
|
2442
1205
|
}
|
|
2443
1206
|
/**
|
|
2444
1207
|
* Updates an existing workspace.
|
|
@@ -2449,17 +1212,7 @@ export class TodoistApi {
|
|
|
2449
1212
|
* @returns A promise that resolves to the updated workspace.
|
|
2450
1213
|
*/
|
|
2451
1214
|
async updateWorkspace(id, args, requestId) {
|
|
2452
|
-
|
|
2453
|
-
const response = await request({
|
|
2454
|
-
httpMethod: 'POST',
|
|
2455
|
-
baseUri: this.syncApiBase,
|
|
2456
|
-
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
2457
|
-
apiToken: this.authToken,
|
|
2458
|
-
customFetch: this.customFetch,
|
|
2459
|
-
payload: args,
|
|
2460
|
-
requestId: requestId,
|
|
2461
|
-
});
|
|
2462
|
-
return validateWorkspace(response.data);
|
|
1215
|
+
return this.workspaceClient.updateWorkspace(id, args, requestId);
|
|
2463
1216
|
}
|
|
2464
1217
|
/**
|
|
2465
1218
|
* Deletes a workspace by its ID.
|
|
@@ -2469,16 +1222,7 @@ export class TodoistApi {
|
|
|
2469
1222
|
* @returns A promise that resolves to `true` if successful.
|
|
2470
1223
|
*/
|
|
2471
1224
|
async deleteWorkspace(id, requestId) {
|
|
2472
|
-
|
|
2473
|
-
const response = await request({
|
|
2474
|
-
httpMethod: 'DELETE',
|
|
2475
|
-
baseUri: this.syncApiBase,
|
|
2476
|
-
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
2477
|
-
apiToken: this.authToken,
|
|
2478
|
-
customFetch: this.customFetch,
|
|
2479
|
-
requestId: requestId,
|
|
2480
|
-
});
|
|
2481
|
-
return isSuccess(response);
|
|
1225
|
+
return this.workspaceClient.deleteWorkspace(id, requestId);
|
|
2482
1226
|
}
|
|
2483
1227
|
/**
|
|
2484
1228
|
* Retrieves activity information for workspace members.
|
|
@@ -2488,19 +1232,7 @@ export class TodoistApi {
|
|
|
2488
1232
|
* @returns A promise that resolves to workspace members activity data.
|
|
2489
1233
|
*/
|
|
2490
1234
|
async getWorkspaceMembersActivity(args, requestId) {
|
|
2491
|
-
|
|
2492
|
-
const { data } = await request({
|
|
2493
|
-
httpMethod: 'GET',
|
|
2494
|
-
baseUri: this.syncApiBase,
|
|
2495
|
-
relativePath: ENDPOINT_WORKSPACE_MEMBERS,
|
|
2496
|
-
apiToken: this.authToken,
|
|
2497
|
-
customFetch: this.customFetch,
|
|
2498
|
-
payload: Object.assign({ workspaceId }, queryParams),
|
|
2499
|
-
requestId: requestId,
|
|
2500
|
-
});
|
|
2501
|
-
return {
|
|
2502
|
-
members: validateMemberActivityInfoArray(data.members),
|
|
2503
|
-
};
|
|
1235
|
+
return this.workspaceClient.getWorkspaceMembersActivity(args, requestId);
|
|
2504
1236
|
}
|
|
2505
1237
|
/**
|
|
2506
1238
|
* Retrieves tasks assigned to a specific user in a workspace.
|
|
@@ -2510,19 +1242,7 @@ export class TodoistApi {
|
|
|
2510
1242
|
* @returns A promise that resolves to workspace user tasks.
|
|
2511
1243
|
*/
|
|
2512
1244
|
async getWorkspaceUserTasks(args, requestId) {
|
|
2513
|
-
|
|
2514
|
-
const { data } = await request({
|
|
2515
|
-
httpMethod: 'GET',
|
|
2516
|
-
baseUri: this.syncApiBase,
|
|
2517
|
-
relativePath: getWorkspaceUserTasksEndpoint(workspaceId, userId),
|
|
2518
|
-
apiToken: this.authToken,
|
|
2519
|
-
customFetch: this.customFetch,
|
|
2520
|
-
payload: queryParams,
|
|
2521
|
-
requestId: requestId,
|
|
2522
|
-
});
|
|
2523
|
-
return {
|
|
2524
|
-
tasks: validateWorkspaceUserTaskArray(data.tasks),
|
|
2525
|
-
};
|
|
1245
|
+
return this.workspaceClient.getWorkspaceUserTasks(args, requestId);
|
|
2526
1246
|
}
|
|
2527
1247
|
/**
|
|
2528
1248
|
* Invites users to a workspace by email.
|
|
@@ -2532,17 +1252,7 @@ export class TodoistApi {
|
|
|
2532
1252
|
* @returns A promise that resolves to the list of invited emails.
|
|
2533
1253
|
*/
|
|
2534
1254
|
async inviteWorkspaceUsers(args, requestId) {
|
|
2535
|
-
|
|
2536
|
-
const { data } = await request({
|
|
2537
|
-
httpMethod: 'POST',
|
|
2538
|
-
baseUri: this.syncApiBase,
|
|
2539
|
-
relativePath: getWorkspaceInviteUsersEndpoint(workspaceId),
|
|
2540
|
-
apiToken: this.authToken,
|
|
2541
|
-
customFetch: this.customFetch,
|
|
2542
|
-
payload: payload,
|
|
2543
|
-
requestId: requestId,
|
|
2544
|
-
});
|
|
2545
|
-
return data;
|
|
1255
|
+
return this.workspaceClient.inviteWorkspaceUsers(args, requestId);
|
|
2546
1256
|
}
|
|
2547
1257
|
/**
|
|
2548
1258
|
* Updates a workspace user's role.
|
|
@@ -2552,17 +1262,7 @@ export class TodoistApi {
|
|
|
2552
1262
|
* @returns A promise that resolves to the updated workspace user view.
|
|
2553
1263
|
*/
|
|
2554
1264
|
async updateWorkspaceUser(args, requestId) {
|
|
2555
|
-
|
|
2556
|
-
const response = await request({
|
|
2557
|
-
httpMethod: 'POST',
|
|
2558
|
-
baseUri: this.syncApiBase,
|
|
2559
|
-
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
2560
|
-
apiToken: this.authToken,
|
|
2561
|
-
customFetch: this.customFetch,
|
|
2562
|
-
payload: payload,
|
|
2563
|
-
requestId: requestId,
|
|
2564
|
-
});
|
|
2565
|
-
return validateJoinWorkspaceResult(response.data);
|
|
1265
|
+
return this.workspaceClient.updateWorkspaceUser(args, requestId);
|
|
2566
1266
|
}
|
|
2567
1267
|
/**
|
|
2568
1268
|
* Removes a user from a workspace.
|
|
@@ -2572,16 +1272,7 @@ export class TodoistApi {
|
|
|
2572
1272
|
* @returns A promise that resolves to `true` if successful.
|
|
2573
1273
|
*/
|
|
2574
1274
|
async removeWorkspaceUser(args, requestId) {
|
|
2575
|
-
|
|
2576
|
-
const response = await request({
|
|
2577
|
-
httpMethod: 'DELETE',
|
|
2578
|
-
baseUri: this.syncApiBase,
|
|
2579
|
-
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
2580
|
-
apiToken: this.authToken,
|
|
2581
|
-
customFetch: this.customFetch,
|
|
2582
|
-
requestId: requestId,
|
|
2583
|
-
});
|
|
2584
|
-
return isSuccess(response);
|
|
1275
|
+
return this.workspaceClient.removeWorkspaceUser(args, requestId);
|
|
2585
1276
|
}
|
|
2586
1277
|
/**
|
|
2587
1278
|
* Gets active projects in a workspace with pagination.
|
|
@@ -2591,28 +1282,7 @@ export class TodoistApi {
|
|
|
2591
1282
|
* @returns Paginated list of active workspace projects.
|
|
2592
1283
|
*/
|
|
2593
1284
|
async getWorkspaceActiveProjects(args, requestId) {
|
|
2594
|
-
|
|
2595
|
-
const queryParams = {};
|
|
2596
|
-
if (args.cursor) {
|
|
2597
|
-
queryParams.cursor = args.cursor;
|
|
2598
|
-
}
|
|
2599
|
-
if (args.limit) {
|
|
2600
|
-
queryParams.limit = args.limit;
|
|
2601
|
-
}
|
|
2602
|
-
const response = await request({
|
|
2603
|
-
httpMethod: 'GET',
|
|
2604
|
-
baseUri: this.syncApiBase,
|
|
2605
|
-
relativePath: getWorkspaceActiveProjectsEndpoint(args.workspaceId),
|
|
2606
|
-
apiToken: this.authToken,
|
|
2607
|
-
customFetch: this.customFetch,
|
|
2608
|
-
payload: queryParams,
|
|
2609
|
-
requestId: requestId,
|
|
2610
|
-
});
|
|
2611
|
-
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
2612
|
-
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
2613
|
-
return Object.assign(Object.assign({}, response.data), {
|
|
2614
|
-
// oxlint-disable-next-line no-unsafe-assignment
|
|
2615
|
-
results: validatedProjects || [] });
|
|
1285
|
+
return this.workspaceClient.getWorkspaceActiveProjects(args, requestId);
|
|
2616
1286
|
}
|
|
2617
1287
|
/**
|
|
2618
1288
|
* Gets archived projects in a workspace with pagination.
|
|
@@ -2622,27 +1292,6 @@ export class TodoistApi {
|
|
|
2622
1292
|
* @returns Paginated list of archived workspace projects.
|
|
2623
1293
|
*/
|
|
2624
1294
|
async getWorkspaceArchivedProjects(args, requestId) {
|
|
2625
|
-
|
|
2626
|
-
const queryParams = {};
|
|
2627
|
-
if (args.cursor) {
|
|
2628
|
-
queryParams.cursor = args.cursor;
|
|
2629
|
-
}
|
|
2630
|
-
if (args.limit) {
|
|
2631
|
-
queryParams.limit = args.limit;
|
|
2632
|
-
}
|
|
2633
|
-
const response = await request({
|
|
2634
|
-
httpMethod: 'GET',
|
|
2635
|
-
baseUri: this.syncApiBase,
|
|
2636
|
-
relativePath: getWorkspaceArchivedProjectsEndpoint(args.workspaceId),
|
|
2637
|
-
apiToken: this.authToken,
|
|
2638
|
-
customFetch: this.customFetch,
|
|
2639
|
-
payload: queryParams,
|
|
2640
|
-
requestId: requestId,
|
|
2641
|
-
});
|
|
2642
|
-
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
2643
|
-
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
2644
|
-
return Object.assign(Object.assign({}, response.data), {
|
|
2645
|
-
// oxlint-disable-next-line no-unsafe-assignment
|
|
2646
|
-
results: validatedProjects || [] });
|
|
1295
|
+
return this.workspaceClient.getWorkspaceArchivedProjects(args, requestId);
|
|
2647
1296
|
}
|
|
2648
1297
|
}
|