@doist/todoist-sdk 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/authentication.js +1 -0
- package/dist/cjs/clients/activity-client.js +63 -0
- package/dist/cjs/clients/app-client.js +347 -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/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/ui-extension-client.js +109 -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 +66 -1
- package/dist/cjs/test-utils/test-defaults.js +77 -1
- package/dist/cjs/todoist-api.js +422 -1537
- package/dist/cjs/transport/http-client.js +1 -0
- package/dist/cjs/transport/sync-request.js +75 -0
- package/dist/cjs/types/apps/index.js +18 -0
- package/dist/cjs/types/apps/requests.js +2 -0
- package/dist/cjs/types/apps/types.js +253 -0
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/types/ui-extensions/index.js +18 -0
- package/dist/cjs/types/ui-extensions/requests.js +2 -0
- package/dist/cjs/types/ui-extensions/types.js +77 -0
- package/dist/cjs/utils/headers.js +16 -0
- package/dist/cjs/utils/request-helpers.js +21 -0
- package/dist/cjs/utils/validators.js +52 -38
- package/dist/esm/authentication.js +1 -0
- package/dist/esm/clients/activity-client.js +59 -0
- package/dist/esm/clients/app-client.js +343 -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/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/ui-extension-client.js +105 -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 +51 -0
- package/dist/esm/test-utils/test-defaults.js +75 -0
- package/dist/esm/todoist-api.js +425 -1540
- package/dist/esm/transport/http-client.js +1 -0
- package/dist/esm/transport/sync-request.js +72 -0
- package/dist/esm/types/apps/index.js +2 -0
- package/dist/esm/types/apps/requests.js +1 -0
- package/dist/esm/types/apps/types.js +248 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/ui-extensions/index.js +2 -0
- package/dist/esm/types/ui-extensions/requests.js +1 -0
- package/dist/esm/types/ui-extensions/types.js +74 -0
- package/dist/esm/utils/headers.js +13 -0
- package/dist/esm/utils/request-helpers.js +17 -0
- package/dist/esm/utils/validators.js +14 -0
- package/dist/types/authentication.d.ts +1 -1
- package/dist/types/clients/activity-client.d.ts +12 -0
- package/dist/types/clients/app-client.d.ts +37 -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/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/ui-extension-client.d.ts +18 -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 +24 -0
- package/dist/types/test-utils/test-defaults.d.ts +16 -1
- package/dist/types/todoist-api.d.ts +238 -17
- package/dist/types/transport/sync-request.d.ts +27 -0
- package/dist/types/types/apps/index.d.ts +2 -0
- package/dist/types/types/apps/requests.d.ts +89 -0
- package/dist/types/types/apps/types.d.ts +414 -0
- package/dist/types/types/http.d.ts +8 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/sync/resources/user.d.ts +2 -2
- package/dist/types/types/sync/response.d.ts +2 -2
- package/dist/types/types/sync/user-preferences.d.ts +1 -1
- package/dist/types/types/ui-extensions/index.d.ts +2 -0
- package/dist/types/types/ui-extensions/requests.d.ts +108 -0
- package/dist/types/types/ui-extensions/types.d.ts +185 -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 +223 -0
- package/package.json +1 -1
package/dist/esm/todoist-api.js
CHANGED
|
@@ -1,99 +1,25 @@
|
|
|
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 {
|
|
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 { AppClient } from './clients/app-client.js';
|
|
3
|
+
import { BackupClient } from './clients/backup-client.js';
|
|
4
|
+
import { CommentClient } from './clients/comment-client.js';
|
|
5
|
+
import { EmailClient } from './clients/email-client.js';
|
|
6
|
+
import { FolderClient } from './clients/folder-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 { UiExtensionClient } from './clients/ui-extension-client.js';
|
|
17
|
+
import { UploadClient } from './clients/upload-client.js';
|
|
18
|
+
import { WorkspaceClient } from './clients/workspace-client.js';
|
|
19
|
+
import { ENDPOINT_REST_USER, getSyncBaseUri } from './consts/endpoints.js';
|
|
20
|
+
import { request } from './transport/http-client.js';
|
|
21
|
+
import { performSyncRequest } from './transport/sync-request.js';
|
|
22
|
+
import { validateCurrentUser } from './utils/validators.js';
|
|
97
23
|
export class TodoistApi {
|
|
98
24
|
constructor(
|
|
99
25
|
/**
|
|
@@ -111,39 +37,29 @@ export class TodoistApi {
|
|
|
111
37
|
const opts = options || {};
|
|
112
38
|
this.syncApiBase = getSyncBaseUri(opts.baseUrl);
|
|
113
39
|
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,
|
|
40
|
+
const clientDeps = {
|
|
41
|
+
authToken: this.authToken,
|
|
42
|
+
syncApiBase: this.syncApiBase,
|
|
133
43
|
customFetch: this.customFetch,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
44
|
+
};
|
|
45
|
+
this.taskClient = new TaskClient(clientDeps);
|
|
46
|
+
this.projectClient = new ProjectClient(clientDeps);
|
|
47
|
+
this.sectionClient = new SectionClient(clientDeps);
|
|
48
|
+
this.labelClient = new LabelClient(clientDeps);
|
|
49
|
+
this.commentClient = new CommentClient(clientDeps);
|
|
50
|
+
this.reminderClient = new ReminderClient(clientDeps);
|
|
51
|
+
this.insightsClient = new InsightsClient(clientDeps);
|
|
52
|
+
this.folderClient = new FolderClient(clientDeps);
|
|
53
|
+
this.templateClient = new TemplateClient(clientDeps);
|
|
54
|
+
this.uploadClient = new UploadClient(clientDeps);
|
|
55
|
+
this.backupClient = new BackupClient(clientDeps);
|
|
56
|
+
this.emailClient = new EmailClient(clientDeps);
|
|
57
|
+
this.idMappingClient = new IdMappingClient(clientDeps);
|
|
58
|
+
this.activityClient = new ActivityClient(clientDeps);
|
|
59
|
+
this.productivityClient = new ProductivityClient(clientDeps);
|
|
60
|
+
this.workspaceClient = new WorkspaceClient(clientDeps);
|
|
61
|
+
this.appClient = new AppClient(clientDeps);
|
|
62
|
+
this.uiExtensionClient = new UiExtensionClient(clientDeps);
|
|
147
63
|
}
|
|
148
64
|
/**
|
|
149
65
|
* Executes a raw Sync API request.
|
|
@@ -171,7 +87,11 @@ export class TodoistApi {
|
|
|
171
87
|
*/
|
|
172
88
|
async sync(syncRequest, requestId) {
|
|
173
89
|
var _a;
|
|
174
|
-
return
|
|
90
|
+
return performSyncRequest({
|
|
91
|
+
authToken: this.authToken,
|
|
92
|
+
syncApiBase: this.syncApiBase,
|
|
93
|
+
customFetch: this.customFetch,
|
|
94
|
+
}, syncRequest, { requestId, hasSyncCommands: Boolean((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length) });
|
|
175
95
|
}
|
|
176
96
|
/**
|
|
177
97
|
* Retrieves information about the authenticated user.
|
|
@@ -195,15 +115,7 @@ export class TodoistApi {
|
|
|
195
115
|
* @returns A promise that resolves to the requested task.
|
|
196
116
|
*/
|
|
197
117
|
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);
|
|
118
|
+
return this.taskClient.getTask(id);
|
|
207
119
|
}
|
|
208
120
|
/**
|
|
209
121
|
* Retrieves a list of active tasks filtered by specific parameters.
|
|
@@ -212,18 +124,7 @@ export class TodoistApi {
|
|
|
212
124
|
* @returns A promise that resolves to an array of tasks.
|
|
213
125
|
*/
|
|
214
126
|
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
|
-
};
|
|
127
|
+
return this.taskClient.getTasks(args);
|
|
227
128
|
}
|
|
228
129
|
/**
|
|
229
130
|
* Retrieves tasks filtered by a filter string.
|
|
@@ -232,18 +133,7 @@ export class TodoistApi {
|
|
|
232
133
|
* @returns A promise that resolves to a paginated response of tasks.
|
|
233
134
|
*/
|
|
234
135
|
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
|
-
};
|
|
136
|
+
return this.taskClient.getTasksByFilter(args);
|
|
247
137
|
}
|
|
248
138
|
/**
|
|
249
139
|
* Retrieves completed tasks by completion date.
|
|
@@ -252,18 +142,7 @@ export class TodoistApi {
|
|
|
252
142
|
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
253
143
|
*/
|
|
254
144
|
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
|
-
};
|
|
145
|
+
return this.taskClient.getCompletedTasksByCompletionDate(args);
|
|
267
146
|
}
|
|
268
147
|
/**
|
|
269
148
|
* Retrieves completed tasks by due date.
|
|
@@ -272,18 +151,7 @@ export class TodoistApi {
|
|
|
272
151
|
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
273
152
|
*/
|
|
274
153
|
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
|
-
};
|
|
154
|
+
return this.taskClient.getCompletedTasksByDueDate(args);
|
|
287
155
|
}
|
|
288
156
|
/**
|
|
289
157
|
* Searches completed tasks by query string.
|
|
@@ -292,18 +160,7 @@ export class TodoistApi {
|
|
|
292
160
|
* @returns A promise that resolves to a paginated response of completed tasks.
|
|
293
161
|
*/
|
|
294
162
|
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
|
-
};
|
|
163
|
+
return this.taskClient.searchCompletedTasks(args);
|
|
307
164
|
}
|
|
308
165
|
/**
|
|
309
166
|
* Retrieves all completed tasks with optional filters.
|
|
@@ -314,20 +171,7 @@ export class TodoistApi {
|
|
|
314
171
|
* @returns A promise that resolves to completed tasks with associated project and section data.
|
|
315
172
|
*/
|
|
316
173
|
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
|
-
};
|
|
174
|
+
return this.taskClient.getAllCompletedTasks(args);
|
|
331
175
|
}
|
|
332
176
|
/**
|
|
333
177
|
* Creates a new task with the provided parameters.
|
|
@@ -337,18 +181,7 @@ export class TodoistApi {
|
|
|
337
181
|
* @returns A promise that resolves to the created task.
|
|
338
182
|
*/
|
|
339
183
|
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);
|
|
184
|
+
return this.taskClient.addTask(args, requestId);
|
|
352
185
|
}
|
|
353
186
|
/**
|
|
354
187
|
* Quickly adds a task using natural language processing for due dates.
|
|
@@ -357,17 +190,7 @@ export class TodoistApi {
|
|
|
357
190
|
* @returns A promise that resolves to the created task.
|
|
358
191
|
*/
|
|
359
192
|
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);
|
|
193
|
+
return this.taskClient.quickAddTask(args);
|
|
371
194
|
}
|
|
372
195
|
/**
|
|
373
196
|
* Updates an existing task by its ID with the provided parameters.
|
|
@@ -379,25 +202,7 @@ export class TodoistApi {
|
|
|
379
202
|
* @returns A promise that resolves to the updated task.
|
|
380
203
|
*/
|
|
381
204
|
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);
|
|
205
|
+
return this.taskClient.updateTask(id, args, requestId);
|
|
401
206
|
}
|
|
402
207
|
/**
|
|
403
208
|
* Moves existing tasks by their ID to either a different parent/section/project.
|
|
@@ -408,28 +213,7 @@ export class TodoistApi {
|
|
|
408
213
|
* @returns - A promise that resolves to an array of the updated tasks.
|
|
409
214
|
*/
|
|
410
215
|
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);
|
|
216
|
+
return this.taskClient.moveTasks(ids, args, requestId);
|
|
433
217
|
}
|
|
434
218
|
/**
|
|
435
219
|
* Moves a task by its ID to either a different parent/section/project.
|
|
@@ -440,17 +224,7 @@ export class TodoistApi {
|
|
|
440
224
|
* @returns A promise that resolves to the updated task.
|
|
441
225
|
*/
|
|
442
226
|
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);
|
|
227
|
+
return this.taskClient.moveTask(id, args, requestId);
|
|
454
228
|
}
|
|
455
229
|
/**
|
|
456
230
|
* Closes (completes) a task by its ID.
|
|
@@ -460,16 +234,7 @@ export class TodoistApi {
|
|
|
460
234
|
* @returns A promise that resolves to `true` if successful.
|
|
461
235
|
*/
|
|
462
236
|
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);
|
|
237
|
+
return this.taskClient.closeTask(id, requestId);
|
|
473
238
|
}
|
|
474
239
|
/**
|
|
475
240
|
* Reopens a previously closed (completed) task by its ID.
|
|
@@ -479,16 +244,7 @@ export class TodoistApi {
|
|
|
479
244
|
* @returns A promise that resolves to `true` if successful.
|
|
480
245
|
*/
|
|
481
246
|
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);
|
|
247
|
+
return this.taskClient.reopenTask(id, requestId);
|
|
492
248
|
}
|
|
493
249
|
/**
|
|
494
250
|
* Deletes a task by its ID.
|
|
@@ -498,16 +254,7 @@ export class TodoistApi {
|
|
|
498
254
|
* @returns A promise that resolves to `true` if successful.
|
|
499
255
|
*/
|
|
500
256
|
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);
|
|
257
|
+
return this.taskClient.deleteTask(id, requestId);
|
|
511
258
|
}
|
|
512
259
|
/**
|
|
513
260
|
* Retrieves a project by its ID.
|
|
@@ -516,15 +263,7 @@ export class TodoistApi {
|
|
|
516
263
|
* @returns A promise that resolves to the requested project.
|
|
517
264
|
*/
|
|
518
265
|
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);
|
|
266
|
+
return this.projectClient.getProject(id);
|
|
528
267
|
}
|
|
529
268
|
/**
|
|
530
269
|
* Retrieves all projects with optional filters.
|
|
@@ -533,18 +272,7 @@ export class TodoistApi {
|
|
|
533
272
|
* @returns A promise that resolves to an array of projects.
|
|
534
273
|
*/
|
|
535
274
|
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
|
-
};
|
|
275
|
+
return this.projectClient.getProjects(args);
|
|
548
276
|
}
|
|
549
277
|
/**
|
|
550
278
|
* Searches projects by name.
|
|
@@ -553,18 +281,7 @@ export class TodoistApi {
|
|
|
553
281
|
* @returns A promise that resolves to a paginated response of projects.
|
|
554
282
|
*/
|
|
555
283
|
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
|
-
};
|
|
284
|
+
return this.projectClient.searchProjects(args);
|
|
568
285
|
}
|
|
569
286
|
/**
|
|
570
287
|
* Retrieves all archived projects with optional filters.
|
|
@@ -573,18 +290,7 @@ export class TodoistApi {
|
|
|
573
290
|
* @returns A promise that resolves to an array of archived projects.
|
|
574
291
|
*/
|
|
575
292
|
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
|
-
};
|
|
293
|
+
return this.projectClient.getArchivedProjects(args);
|
|
588
294
|
}
|
|
589
295
|
/**
|
|
590
296
|
* Creates a new project with the provided parameters.
|
|
@@ -594,16 +300,7 @@ export class TodoistApi {
|
|
|
594
300
|
* @returns A promise that resolves to the created project.
|
|
595
301
|
*/
|
|
596
302
|
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);
|
|
303
|
+
return this.projectClient.addProject(args, requestId);
|
|
607
304
|
}
|
|
608
305
|
/**
|
|
609
306
|
* Updates an existing project by its ID with the provided parameters.
|
|
@@ -614,17 +311,7 @@ export class TodoistApi {
|
|
|
614
311
|
* @returns A promise that resolves to the updated project.
|
|
615
312
|
*/
|
|
616
313
|
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);
|
|
314
|
+
return this.projectClient.updateProject(id, args, requestId);
|
|
628
315
|
}
|
|
629
316
|
/**
|
|
630
317
|
* Deletes a project by its ID.
|
|
@@ -639,16 +326,7 @@ export class TodoistApi {
|
|
|
639
326
|
* @returns A promise that resolves to `true` if successful.
|
|
640
327
|
*/
|
|
641
328
|
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);
|
|
329
|
+
return this.projectClient.deleteProject(id, requestId);
|
|
652
330
|
}
|
|
653
331
|
/**
|
|
654
332
|
* Archives a project by its ID.
|
|
@@ -658,16 +336,7 @@ export class TodoistApi {
|
|
|
658
336
|
* @returns A promise that resolves to the updated project.
|
|
659
337
|
*/
|
|
660
338
|
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);
|
|
339
|
+
return this.projectClient.archiveProject(id, requestId);
|
|
671
340
|
}
|
|
672
341
|
/**
|
|
673
342
|
* Unarchives a project by its ID.
|
|
@@ -677,16 +346,7 @@ export class TodoistApi {
|
|
|
677
346
|
* @returns A promise that resolves to the updated project.
|
|
678
347
|
*/
|
|
679
348
|
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);
|
|
349
|
+
return this.projectClient.unarchiveProject(id, requestId);
|
|
690
350
|
}
|
|
691
351
|
/**
|
|
692
352
|
* Moves a project to a workspace.
|
|
@@ -696,16 +356,7 @@ export class TodoistApi {
|
|
|
696
356
|
* @returns A promise that resolves to the moved project.
|
|
697
357
|
*/
|
|
698
358
|
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);
|
|
359
|
+
return this.projectClient.moveProjectToWorkspace(args, requestId);
|
|
709
360
|
}
|
|
710
361
|
/**
|
|
711
362
|
* Moves a project to personal.
|
|
@@ -715,16 +366,7 @@ export class TodoistApi {
|
|
|
715
366
|
* @returns A promise that resolves to the moved project.
|
|
716
367
|
*/
|
|
717
368
|
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);
|
|
369
|
+
return this.projectClient.moveProjectToPersonal(args, requestId);
|
|
728
370
|
}
|
|
729
371
|
/**
|
|
730
372
|
* Counts the number of archived projects.
|
|
@@ -733,15 +375,7 @@ export class TodoistApi {
|
|
|
733
375
|
* @returns A promise that resolves to the count of archived projects.
|
|
734
376
|
*/
|
|
735
377
|
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;
|
|
378
|
+
return this.projectClient.getArchivedProjectsCount(args);
|
|
745
379
|
}
|
|
746
380
|
/**
|
|
747
381
|
* Retrieves the role-to-action permission mappings for projects.
|
|
@@ -749,14 +383,7 @@ export class TodoistApi {
|
|
|
749
383
|
* @returns A promise that resolves to the permission mappings.
|
|
750
384
|
*/
|
|
751
385
|
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;
|
|
386
|
+
return this.projectClient.getProjectPermissions();
|
|
760
387
|
}
|
|
761
388
|
/**
|
|
762
389
|
* Retrieves full project data including tasks, sections, collaborators, and notes.
|
|
@@ -766,23 +393,7 @@ export class TodoistApi {
|
|
|
766
393
|
* @returns A promise that resolves to the full project data.
|
|
767
394
|
*/
|
|
768
395
|
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
|
-
};
|
|
396
|
+
return this.projectClient.getFullProject(id, args);
|
|
786
397
|
}
|
|
787
398
|
/**
|
|
788
399
|
* Joins a workspace project.
|
|
@@ -795,25 +406,7 @@ export class TodoistApi {
|
|
|
795
406
|
* @returns A promise that resolves to the full project data after joining.
|
|
796
407
|
*/
|
|
797
408
|
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
|
-
};
|
|
409
|
+
return this.projectClient.joinProject(id, requestId);
|
|
817
410
|
}
|
|
818
411
|
/**
|
|
819
412
|
* Retrieves a list of collaborators for a specific project.
|
|
@@ -823,19 +416,7 @@ export class TodoistApi {
|
|
|
823
416
|
* @returns A promise that resolves to an array of collaborators for the project.
|
|
824
417
|
*/
|
|
825
418
|
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
|
-
};
|
|
419
|
+
return this.projectClient.getProjectCollaborators(projectId, args);
|
|
839
420
|
}
|
|
840
421
|
// ── Insights ──
|
|
841
422
|
/**
|
|
@@ -846,16 +427,7 @@ export class TodoistApi {
|
|
|
846
427
|
* @returns A promise that resolves to the project activity stats.
|
|
847
428
|
*/
|
|
848
429
|
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);
|
|
430
|
+
return this.insightsClient.getProjectActivityStats(projectId, args);
|
|
859
431
|
}
|
|
860
432
|
/**
|
|
861
433
|
* Retrieves the health status of a project.
|
|
@@ -864,15 +436,7 @@ export class TodoistApi {
|
|
|
864
436
|
* @returns A promise that resolves to the project health data.
|
|
865
437
|
*/
|
|
866
438
|
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);
|
|
439
|
+
return this.insightsClient.getProjectHealth(projectId);
|
|
876
440
|
}
|
|
877
441
|
/**
|
|
878
442
|
* Retrieves the health context for a project, including metrics and task details.
|
|
@@ -881,15 +445,7 @@ export class TodoistApi {
|
|
|
881
445
|
* @returns A promise that resolves to the project health context.
|
|
882
446
|
*/
|
|
883
447
|
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);
|
|
448
|
+
return this.insightsClient.getProjectHealthContext(projectId);
|
|
893
449
|
}
|
|
894
450
|
/**
|
|
895
451
|
* Retrieves progress information for a project.
|
|
@@ -898,15 +454,7 @@ export class TodoistApi {
|
|
|
898
454
|
* @returns A promise that resolves to the project progress data.
|
|
899
455
|
*/
|
|
900
456
|
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);
|
|
457
|
+
return this.insightsClient.getProjectProgress(projectId);
|
|
910
458
|
}
|
|
911
459
|
/**
|
|
912
460
|
* Retrieves insights for all projects in a workspace.
|
|
@@ -916,16 +464,7 @@ export class TodoistApi {
|
|
|
916
464
|
* @returns A promise that resolves to workspace insights data.
|
|
917
465
|
*/
|
|
918
466
|
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);
|
|
467
|
+
return this.insightsClient.getWorkspaceInsights(workspaceId, args);
|
|
929
468
|
}
|
|
930
469
|
/**
|
|
931
470
|
* Triggers a health analysis for a project.
|
|
@@ -935,16 +474,7 @@ export class TodoistApi {
|
|
|
935
474
|
* @returns A promise that resolves to the updated project health data.
|
|
936
475
|
*/
|
|
937
476
|
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);
|
|
477
|
+
return this.insightsClient.analyzeProjectHealth(projectId, requestId);
|
|
948
478
|
}
|
|
949
479
|
// ── Sections ──
|
|
950
480
|
/**
|
|
@@ -955,18 +485,7 @@ export class TodoistApi {
|
|
|
955
485
|
* @returns A promise that resolves to an array of sections.
|
|
956
486
|
*/
|
|
957
487
|
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
|
-
};
|
|
488
|
+
return this.sectionClient.getSections(args);
|
|
970
489
|
}
|
|
971
490
|
/**
|
|
972
491
|
* Searches sections by name.
|
|
@@ -975,18 +494,7 @@ export class TodoistApi {
|
|
|
975
494
|
* @returns A promise that resolves to a paginated response of sections.
|
|
976
495
|
*/
|
|
977
496
|
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
|
-
};
|
|
497
|
+
return this.sectionClient.searchSections(args);
|
|
990
498
|
}
|
|
991
499
|
/**
|
|
992
500
|
* Retrieves a single section by its ID.
|
|
@@ -995,15 +503,7 @@ export class TodoistApi {
|
|
|
995
503
|
* @returns A promise that resolves to the requested section.
|
|
996
504
|
*/
|
|
997
505
|
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);
|
|
506
|
+
return this.sectionClient.getSection(id);
|
|
1007
507
|
}
|
|
1008
508
|
/**
|
|
1009
509
|
* Creates a new section within a project.
|
|
@@ -1013,16 +513,7 @@ export class TodoistApi {
|
|
|
1013
513
|
* @returns A promise that resolves to the created section.
|
|
1014
514
|
*/
|
|
1015
515
|
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);
|
|
516
|
+
return this.sectionClient.addSection(args, requestId);
|
|
1026
517
|
}
|
|
1027
518
|
/**
|
|
1028
519
|
* Updates a section by its ID with the provided parameters.
|
|
@@ -1033,17 +524,7 @@ export class TodoistApi {
|
|
|
1033
524
|
* @returns A promise that resolves to the updated section.
|
|
1034
525
|
*/
|
|
1035
526
|
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);
|
|
527
|
+
return this.sectionClient.updateSection(id, args, requestId);
|
|
1047
528
|
}
|
|
1048
529
|
/**
|
|
1049
530
|
* Deletes a section by its ID.
|
|
@@ -1053,16 +534,7 @@ export class TodoistApi {
|
|
|
1053
534
|
* @returns A promise that resolves to `true` if successful.
|
|
1054
535
|
*/
|
|
1055
536
|
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);
|
|
537
|
+
return this.sectionClient.deleteSection(id, requestId);
|
|
1066
538
|
}
|
|
1067
539
|
/**
|
|
1068
540
|
* Archives a section by its ID.
|
|
@@ -1072,16 +544,7 @@ export class TodoistApi {
|
|
|
1072
544
|
* @returns A promise that resolves to the updated section.
|
|
1073
545
|
*/
|
|
1074
546
|
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);
|
|
547
|
+
return this.sectionClient.archiveSection(id, requestId);
|
|
1085
548
|
}
|
|
1086
549
|
/**
|
|
1087
550
|
* Unarchives a section by its ID.
|
|
@@ -1091,16 +554,7 @@ export class TodoistApi {
|
|
|
1091
554
|
* @returns A promise that resolves to the updated section.
|
|
1092
555
|
*/
|
|
1093
556
|
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);
|
|
557
|
+
return this.sectionClient.unarchiveSection(id, requestId);
|
|
1104
558
|
}
|
|
1105
559
|
/**
|
|
1106
560
|
* Retrieves a label by its ID.
|
|
@@ -1109,15 +563,7 @@ export class TodoistApi {
|
|
|
1109
563
|
* @returns A promise that resolves to the requested label.
|
|
1110
564
|
*/
|
|
1111
565
|
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);
|
|
566
|
+
return this.labelClient.getLabel(id);
|
|
1121
567
|
}
|
|
1122
568
|
/**
|
|
1123
569
|
* Retrieves all labels.
|
|
@@ -1126,18 +572,7 @@ export class TodoistApi {
|
|
|
1126
572
|
* @returns A promise that resolves to an array of labels.
|
|
1127
573
|
*/
|
|
1128
574
|
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
|
-
};
|
|
575
|
+
return this.labelClient.getLabels(args);
|
|
1141
576
|
}
|
|
1142
577
|
/**
|
|
1143
578
|
* Searches labels by name.
|
|
@@ -1146,18 +581,7 @@ export class TodoistApi {
|
|
|
1146
581
|
* @returns A promise that resolves to a paginated response of labels.
|
|
1147
582
|
*/
|
|
1148
583
|
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
|
-
};
|
|
584
|
+
return this.labelClient.searchLabels(args);
|
|
1161
585
|
}
|
|
1162
586
|
/**
|
|
1163
587
|
* Adds a new label.
|
|
@@ -1167,16 +591,7 @@ export class TodoistApi {
|
|
|
1167
591
|
* @returns A promise that resolves to the created label.
|
|
1168
592
|
*/
|
|
1169
593
|
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);
|
|
594
|
+
return this.labelClient.addLabel(args, requestId);
|
|
1180
595
|
}
|
|
1181
596
|
/**
|
|
1182
597
|
* Updates an existing label by its ID.
|
|
@@ -1187,17 +602,7 @@ export class TodoistApi {
|
|
|
1187
602
|
* @returns A promise that resolves to the updated label.
|
|
1188
603
|
*/
|
|
1189
604
|
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);
|
|
605
|
+
return this.labelClient.updateLabel(id, args, requestId);
|
|
1201
606
|
}
|
|
1202
607
|
/**
|
|
1203
608
|
* Deletes a label by its ID.
|
|
@@ -1207,16 +612,7 @@ export class TodoistApi {
|
|
|
1207
612
|
* @returns A promise that resolves to `true` if successful.
|
|
1208
613
|
*/
|
|
1209
614
|
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);
|
|
615
|
+
return this.labelClient.deleteLabel(id, requestId);
|
|
1220
616
|
}
|
|
1221
617
|
/**
|
|
1222
618
|
* Retrieves a list of shared labels.
|
|
@@ -1225,15 +621,7 @@ export class TodoistApi {
|
|
|
1225
621
|
* @returns A promise that resolves to an array of shared labels.
|
|
1226
622
|
*/
|
|
1227
623
|
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 };
|
|
624
|
+
return this.labelClient.getSharedLabels(args);
|
|
1237
625
|
}
|
|
1238
626
|
/**
|
|
1239
627
|
* Renames an existing shared label.
|
|
@@ -1242,15 +630,7 @@ export class TodoistApi {
|
|
|
1242
630
|
* @returns A promise that resolves to `true` if successful.
|
|
1243
631
|
*/
|
|
1244
632
|
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);
|
|
633
|
+
return this.labelClient.renameSharedLabel(args);
|
|
1254
634
|
}
|
|
1255
635
|
/**
|
|
1256
636
|
* Removes a shared label.
|
|
@@ -1259,15 +639,7 @@ export class TodoistApi {
|
|
|
1259
639
|
* @returns A promise that resolves to `true` if successful.
|
|
1260
640
|
*/
|
|
1261
641
|
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);
|
|
642
|
+
return this.labelClient.removeSharedLabel(args);
|
|
1271
643
|
}
|
|
1272
644
|
/**
|
|
1273
645
|
* Retrieves all comments associated with a task or project.
|
|
@@ -1276,18 +648,7 @@ export class TodoistApi {
|
|
|
1276
648
|
* @returns A promise that resolves to an array of comments.
|
|
1277
649
|
*/
|
|
1278
650
|
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
|
-
};
|
|
651
|
+
return this.commentClient.getComments(args);
|
|
1291
652
|
}
|
|
1292
653
|
/**
|
|
1293
654
|
* Retrieves a specific comment by its ID.
|
|
@@ -1296,15 +657,7 @@ export class TodoistApi {
|
|
|
1296
657
|
* @returns A promise that resolves to the requested comment.
|
|
1297
658
|
*/
|
|
1298
659
|
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);
|
|
660
|
+
return this.commentClient.getComment(id);
|
|
1308
661
|
}
|
|
1309
662
|
/**
|
|
1310
663
|
* Adds a comment to a task or project.
|
|
@@ -1314,17 +667,7 @@ export class TodoistApi {
|
|
|
1314
667
|
* @returns A promise that resolves to the created comment.
|
|
1315
668
|
*/
|
|
1316
669
|
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);
|
|
670
|
+
return this.commentClient.addComment(args, requestId);
|
|
1328
671
|
}
|
|
1329
672
|
/**
|
|
1330
673
|
* Updates an existing comment by its ID.
|
|
@@ -1335,17 +678,7 @@ export class TodoistApi {
|
|
|
1335
678
|
* @returns A promise that resolves to the updated comment.
|
|
1336
679
|
*/
|
|
1337
680
|
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);
|
|
681
|
+
return this.commentClient.updateComment(id, args, requestId);
|
|
1349
682
|
}
|
|
1350
683
|
/**
|
|
1351
684
|
* Deletes a comment by its ID.
|
|
@@ -1355,16 +688,7 @@ export class TodoistApi {
|
|
|
1355
688
|
* @returns A promise that resolves to `true` if successful.
|
|
1356
689
|
*/
|
|
1357
690
|
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);
|
|
691
|
+
return this.commentClient.deleteComment(id, requestId);
|
|
1368
692
|
}
|
|
1369
693
|
/**
|
|
1370
694
|
* Retrieves a paginated list of time-based reminders.
|
|
@@ -1373,18 +697,7 @@ export class TodoistApi {
|
|
|
1373
697
|
* @returns A promise that resolves to a paginated list of reminders.
|
|
1374
698
|
*/
|
|
1375
699
|
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
|
-
};
|
|
700
|
+
return this.reminderClient.getReminders(args);
|
|
1388
701
|
}
|
|
1389
702
|
/**
|
|
1390
703
|
* Retrieves a paginated list of location-based reminders.
|
|
@@ -1393,18 +706,7 @@ export class TodoistApi {
|
|
|
1393
706
|
* @returns A promise that resolves to a paginated list of location reminders.
|
|
1394
707
|
*/
|
|
1395
708
|
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
|
-
};
|
|
709
|
+
return this.reminderClient.getLocationReminders(args);
|
|
1408
710
|
}
|
|
1409
711
|
/**
|
|
1410
712
|
* Retrieves a time-based reminder by its ID.
|
|
@@ -1413,23 +715,7 @@ export class TodoistApi {
|
|
|
1413
715
|
* @returns A promise that resolves to the requested reminder.
|
|
1414
716
|
*/
|
|
1415
717
|
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
|
-
}
|
|
718
|
+
return this.reminderClient.getReminder(id);
|
|
1433
719
|
}
|
|
1434
720
|
/**
|
|
1435
721
|
* Retrieves a location reminder by its ID.
|
|
@@ -1438,23 +724,7 @@ export class TodoistApi {
|
|
|
1438
724
|
* @returns A promise that resolves to the requested reminder.
|
|
1439
725
|
*/
|
|
1440
726
|
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
|
-
}
|
|
727
|
+
return this.reminderClient.getLocationReminder(id);
|
|
1458
728
|
}
|
|
1459
729
|
/**
|
|
1460
730
|
* Creates a time-based reminder for a task.
|
|
@@ -1464,16 +734,7 @@ export class TodoistApi {
|
|
|
1464
734
|
* @returns A promise that resolves to the created reminder.
|
|
1465
735
|
*/
|
|
1466
736
|
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);
|
|
737
|
+
return this.reminderClient.addReminder(args, requestId);
|
|
1477
738
|
}
|
|
1478
739
|
/**
|
|
1479
740
|
* Creates a location reminder for a task.
|
|
@@ -1483,16 +744,7 @@ export class TodoistApi {
|
|
|
1483
744
|
* @returns A promise that resolves to the created reminder.
|
|
1484
745
|
*/
|
|
1485
746
|
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);
|
|
747
|
+
return this.reminderClient.addLocationReminder(args, requestId);
|
|
1496
748
|
}
|
|
1497
749
|
/**
|
|
1498
750
|
* Updates an existing time-based reminder.
|
|
@@ -1503,26 +755,7 @@ export class TodoistApi {
|
|
|
1503
755
|
* @returns A promise that resolves to the updated reminder.
|
|
1504
756
|
*/
|
|
1505
757
|
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
|
-
}
|
|
758
|
+
return this.reminderClient.updateReminder(id, args, requestId);
|
|
1526
759
|
}
|
|
1527
760
|
/**
|
|
1528
761
|
* Updates an existing location reminder.
|
|
@@ -1533,26 +766,7 @@ export class TodoistApi {
|
|
|
1533
766
|
* @returns A promise that resolves to the updated reminder.
|
|
1534
767
|
*/
|
|
1535
768
|
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
|
-
}
|
|
769
|
+
return this.reminderClient.updateLocationReminder(id, args, requestId);
|
|
1556
770
|
}
|
|
1557
771
|
/**
|
|
1558
772
|
* Deletes a time-based reminder by its ID.
|
|
@@ -1562,24 +776,7 @@ export class TodoistApi {
|
|
|
1562
776
|
* @returns A promise that resolves to `true` if successful.
|
|
1563
777
|
*/
|
|
1564
778
|
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
|
-
}
|
|
779
|
+
return this.reminderClient.deleteReminder(id, requestId);
|
|
1583
780
|
}
|
|
1584
781
|
/**
|
|
1585
782
|
* Deletes a location reminder by its ID.
|
|
@@ -1589,24 +786,7 @@ export class TodoistApi {
|
|
|
1589
786
|
* @returns A promise that resolves to `true` if successful.
|
|
1590
787
|
*/
|
|
1591
788
|
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
|
-
}
|
|
789
|
+
return this.reminderClient.deleteLocationReminder(id, requestId);
|
|
1610
790
|
}
|
|
1611
791
|
/**
|
|
1612
792
|
* Retrieves productivity stats for the authenticated user.
|
|
@@ -1614,14 +794,7 @@ export class TodoistApi {
|
|
|
1614
794
|
* @returns A promise that resolves to the productivity stats.
|
|
1615
795
|
*/
|
|
1616
796
|
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);
|
|
797
|
+
return this.productivityClient.getProductivityStats();
|
|
1625
798
|
}
|
|
1626
799
|
/**
|
|
1627
800
|
* Retrieves activity logs with optional filters.
|
|
@@ -1630,37 +803,7 @@ export class TodoistApi {
|
|
|
1630
803
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1631
804
|
*/
|
|
1632
805
|
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
|
-
};
|
|
806
|
+
return this.activityClient.getActivityLogs(args);
|
|
1664
807
|
}
|
|
1665
808
|
/**
|
|
1666
809
|
* Uploads a file and returns attachment metadata.
|
|
@@ -1700,21 +843,7 @@ export class TodoistApi {
|
|
|
1700
843
|
* ```
|
|
1701
844
|
*/
|
|
1702
845
|
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);
|
|
846
|
+
return this.uploadClient.uploadFile(args, requestId);
|
|
1718
847
|
}
|
|
1719
848
|
/**
|
|
1720
849
|
* Deletes an uploaded file by its URL.
|
|
@@ -1731,16 +860,7 @@ export class TodoistApi {
|
|
|
1731
860
|
* ```
|
|
1732
861
|
*/
|
|
1733
862
|
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);
|
|
863
|
+
return this.uploadClient.deleteUpload(args, requestId);
|
|
1744
864
|
}
|
|
1745
865
|
/**
|
|
1746
866
|
* Fetches the content of a file attachment from a Todoist comment.
|
|
@@ -1767,57 +887,7 @@ export class TodoistApi {
|
|
|
1767
887
|
* ```
|
|
1768
888
|
*/
|
|
1769
889
|
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
|
-
};
|
|
890
|
+
return this.uploadClient.viewAttachment(commentOrUrl);
|
|
1821
891
|
}
|
|
1822
892
|
// ── Folders ──
|
|
1823
893
|
/**
|
|
@@ -1827,18 +897,7 @@ export class TodoistApi {
|
|
|
1827
897
|
* @returns A promise that resolves to a paginated response of folders.
|
|
1828
898
|
*/
|
|
1829
899
|
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
|
-
};
|
|
900
|
+
return this.folderClient.getFolders(args);
|
|
1842
901
|
}
|
|
1843
902
|
/**
|
|
1844
903
|
* Retrieves a single folder by its ID.
|
|
@@ -1847,15 +906,7 @@ export class TodoistApi {
|
|
|
1847
906
|
* @returns A promise that resolves to the requested folder.
|
|
1848
907
|
*/
|
|
1849
908
|
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);
|
|
909
|
+
return this.folderClient.getFolder(id);
|
|
1859
910
|
}
|
|
1860
911
|
/**
|
|
1861
912
|
* Creates a new folder.
|
|
@@ -1865,16 +916,7 @@ export class TodoistApi {
|
|
|
1865
916
|
* @returns A promise that resolves to the created folder.
|
|
1866
917
|
*/
|
|
1867
918
|
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);
|
|
919
|
+
return this.folderClient.addFolder(args, requestId);
|
|
1878
920
|
}
|
|
1879
921
|
/**
|
|
1880
922
|
* Updates an existing folder by its ID.
|
|
@@ -1885,17 +927,7 @@ export class TodoistApi {
|
|
|
1885
927
|
* @returns A promise that resolves to the updated folder.
|
|
1886
928
|
*/
|
|
1887
929
|
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);
|
|
930
|
+
return this.folderClient.updateFolder(id, args, requestId);
|
|
1899
931
|
}
|
|
1900
932
|
/**
|
|
1901
933
|
* Deletes a folder by its ID.
|
|
@@ -1905,16 +937,7 @@ export class TodoistApi {
|
|
|
1905
937
|
* @returns A promise that resolves to `true` if successful.
|
|
1906
938
|
*/
|
|
1907
939
|
async deleteFolder(id, requestId) {
|
|
1908
|
-
|
|
1909
|
-
const response = await request({
|
|
1910
|
-
httpMethod: 'DELETE',
|
|
1911
|
-
baseUri: this.syncApiBase,
|
|
1912
|
-
relativePath: generatePath(ENDPOINT_REST_FOLDERS, id),
|
|
1913
|
-
apiToken: this.authToken,
|
|
1914
|
-
customFetch: this.customFetch,
|
|
1915
|
-
requestId: requestId,
|
|
1916
|
-
});
|
|
1917
|
-
return isSuccess(response);
|
|
940
|
+
return this.folderClient.deleteFolder(id, requestId);
|
|
1918
941
|
}
|
|
1919
942
|
// ── Backups ──
|
|
1920
943
|
/**
|
|
@@ -1924,15 +947,7 @@ export class TodoistApi {
|
|
|
1924
947
|
* @returns A promise that resolves to an array of backups.
|
|
1925
948
|
*/
|
|
1926
949
|
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);
|
|
950
|
+
return this.backupClient.getBackups(args);
|
|
1936
951
|
}
|
|
1937
952
|
/**
|
|
1938
953
|
* Downloads a backup file as binary data.
|
|
@@ -1941,40 +956,7 @@ export class TodoistApi {
|
|
|
1941
956
|
* @returns A promise that resolves to a response with binary data accessible via arrayBuffer().
|
|
1942
957
|
*/
|
|
1943
958
|
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
|
-
};
|
|
959
|
+
return this.backupClient.downloadBackup(args);
|
|
1978
960
|
}
|
|
1979
961
|
// ── Emails ──
|
|
1980
962
|
/**
|
|
@@ -1985,16 +967,7 @@ export class TodoistApi {
|
|
|
1985
967
|
* @returns A promise that resolves to the email address.
|
|
1986
968
|
*/
|
|
1987
969
|
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;
|
|
970
|
+
return this.emailClient.getOrCreateEmailForwarding(args, requestId);
|
|
1998
971
|
}
|
|
1999
972
|
/**
|
|
2000
973
|
* Disables email forwarding for an object.
|
|
@@ -2004,19 +977,7 @@ export class TodoistApi {
|
|
|
2004
977
|
* @returns A promise that resolves to `true` if successful.
|
|
2005
978
|
*/
|
|
2006
979
|
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);
|
|
980
|
+
return this.emailClient.disableEmailForwarding(args, requestId);
|
|
2020
981
|
}
|
|
2021
982
|
// ── ID Mappings ──
|
|
2022
983
|
/**
|
|
@@ -2026,14 +987,7 @@ export class TodoistApi {
|
|
|
2026
987
|
* @returns A promise that resolves to an array of ID mappings.
|
|
2027
988
|
*/
|
|
2028
989
|
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);
|
|
990
|
+
return this.idMappingClient.getIdMappings(args);
|
|
2037
991
|
}
|
|
2038
992
|
/**
|
|
2039
993
|
* Retrieves moved IDs for objects that have been migrated.
|
|
@@ -2042,15 +996,7 @@ export class TodoistApi {
|
|
|
2042
996
|
* @returns A promise that resolves to an array of moved ID pairs.
|
|
2043
997
|
*/
|
|
2044
998
|
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);
|
|
999
|
+
return this.idMappingClient.getMovedIds(args);
|
|
2054
1000
|
}
|
|
2055
1001
|
// ── Templates ──
|
|
2056
1002
|
/**
|
|
@@ -2060,15 +1006,7 @@ export class TodoistApi {
|
|
|
2060
1006
|
* @returns A promise that resolves to the template file content as a string.
|
|
2061
1007
|
*/
|
|
2062
1008
|
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;
|
|
1009
|
+
return this.templateClient.exportTemplateAsFile(args);
|
|
2072
1010
|
}
|
|
2073
1011
|
/**
|
|
2074
1012
|
* Exports a project as a template URL.
|
|
@@ -2077,15 +1015,7 @@ export class TodoistApi {
|
|
|
2077
1015
|
* @returns A promise that resolves to the file name and URL.
|
|
2078
1016
|
*/
|
|
2079
1017
|
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;
|
|
1018
|
+
return this.templateClient.exportTemplateAsUrl(args);
|
|
2089
1019
|
}
|
|
2090
1020
|
/**
|
|
2091
1021
|
* Creates a new project from a template file.
|
|
@@ -2095,22 +1025,7 @@ export class TodoistApi {
|
|
|
2095
1025
|
* @returns A promise that resolves to the created project data.
|
|
2096
1026
|
*/
|
|
2097
1027
|
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));
|
|
1028
|
+
return this.templateClient.createProjectFromTemplate(args, requestId);
|
|
2114
1029
|
}
|
|
2115
1030
|
/**
|
|
2116
1031
|
* Imports a template file into an existing project.
|
|
@@ -2120,18 +1035,7 @@ export class TodoistApi {
|
|
|
2120
1035
|
* @returns A promise that resolves to the import result.
|
|
2121
1036
|
*/
|
|
2122
1037
|
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));
|
|
1038
|
+
return this.templateClient.importTemplateIntoProject(args, requestId);
|
|
2135
1039
|
}
|
|
2136
1040
|
/**
|
|
2137
1041
|
* Imports a template by ID into an existing project.
|
|
@@ -2141,20 +1045,7 @@ export class TodoistApi {
|
|
|
2141
1045
|
* @returns A promise that resolves to the import result.
|
|
2142
1046
|
*/
|
|
2143
1047
|
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 : []) });
|
|
1048
|
+
return this.templateClient.importTemplateFromId(args, requestId);
|
|
2158
1049
|
}
|
|
2159
1050
|
/* Workspace methods */
|
|
2160
1051
|
/**
|
|
@@ -2165,16 +1056,7 @@ export class TodoistApi {
|
|
|
2165
1056
|
* @returns Array of email addresses with pending invitations.
|
|
2166
1057
|
*/
|
|
2167
1058
|
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;
|
|
1059
|
+
return this.workspaceClient.getWorkspaceInvitations(args, requestId);
|
|
2178
1060
|
}
|
|
2179
1061
|
/**
|
|
2180
1062
|
* Gets all workspace invitations (admin only).
|
|
@@ -2183,20 +1065,7 @@ export class TodoistApi {
|
|
|
2183
1065
|
* @returns Array of email addresses with pending invitations.
|
|
2184
1066
|
*/
|
|
2185
1067
|
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);
|
|
1068
|
+
return this.workspaceClient.getAllWorkspaceInvitations(args, requestId);
|
|
2200
1069
|
}
|
|
2201
1070
|
/**
|
|
2202
1071
|
* Deletes a workspace invitation (admin only).
|
|
@@ -2206,19 +1075,7 @@ export class TodoistApi {
|
|
|
2206
1075
|
* @returns The deleted invitation.
|
|
2207
1076
|
*/
|
|
2208
1077
|
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);
|
|
1078
|
+
return this.workspaceClient.deleteWorkspaceInvitation(args, requestId);
|
|
2222
1079
|
}
|
|
2223
1080
|
/**
|
|
2224
1081
|
* Accepts a workspace invitation.
|
|
@@ -2228,15 +1085,7 @@ export class TodoistApi {
|
|
|
2228
1085
|
* @returns The accepted invitation.
|
|
2229
1086
|
*/
|
|
2230
1087
|
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);
|
|
1088
|
+
return this.workspaceClient.acceptWorkspaceInvitation(args, requestId);
|
|
2240
1089
|
}
|
|
2241
1090
|
/**
|
|
2242
1091
|
* Rejects a workspace invitation.
|
|
@@ -2246,15 +1095,7 @@ export class TodoistApi {
|
|
|
2246
1095
|
* @returns The rejected invitation.
|
|
2247
1096
|
*/
|
|
2248
1097
|
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);
|
|
1098
|
+
return this.workspaceClient.rejectWorkspaceInvitation(args, requestId);
|
|
2258
1099
|
}
|
|
2259
1100
|
/**
|
|
2260
1101
|
* Joins a workspace via invitation link or domain auto-join.
|
|
@@ -2264,19 +1105,7 @@ export class TodoistApi {
|
|
|
2264
1105
|
* @returns Workspace user information.
|
|
2265
1106
|
*/
|
|
2266
1107
|
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);
|
|
1108
|
+
return this.workspaceClient.joinWorkspace(args, requestId);
|
|
2280
1109
|
}
|
|
2281
1110
|
/**
|
|
2282
1111
|
* Uploads or updates a workspace logo.
|
|
@@ -2286,44 +1115,7 @@ export class TodoistApi {
|
|
|
2286
1115
|
* @returns Logo information or null if deleted.
|
|
2287
1116
|
*/
|
|
2288
1117
|
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;
|
|
1118
|
+
return this.workspaceClient.uploadWorkspaceLogo(args, requestId);
|
|
2327
1119
|
}
|
|
2328
1120
|
/**
|
|
2329
1121
|
* Gets workspace plan and billing details.
|
|
@@ -2333,16 +1125,7 @@ export class TodoistApi {
|
|
|
2333
1125
|
* @returns Workspace plan details.
|
|
2334
1126
|
*/
|
|
2335
1127
|
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);
|
|
1128
|
+
return this.workspaceClient.getWorkspacePlanDetails(args, requestId);
|
|
2346
1129
|
}
|
|
2347
1130
|
/**
|
|
2348
1131
|
* Gets workspace users with pagination.
|
|
@@ -2352,30 +1135,7 @@ export class TodoistApi {
|
|
|
2352
1135
|
* @returns Paginated list of workspace users.
|
|
2353
1136
|
*/
|
|
2354
1137
|
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
|
-
};
|
|
1138
|
+
return this.workspaceClient.getWorkspaceUsers(args, requestId);
|
|
2379
1139
|
}
|
|
2380
1140
|
/**
|
|
2381
1141
|
* Retrieves all workspaces for the authenticated user.
|
|
@@ -2392,15 +1152,7 @@ export class TodoistApi {
|
|
|
2392
1152
|
* ```
|
|
2393
1153
|
*/
|
|
2394
1154
|
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);
|
|
1155
|
+
return this.workspaceClient.getWorkspaces(requestId);
|
|
2404
1156
|
}
|
|
2405
1157
|
/**
|
|
2406
1158
|
* Retrieves a workspace by its ID.
|
|
@@ -2410,16 +1162,7 @@ export class TodoistApi {
|
|
|
2410
1162
|
* @returns A promise that resolves to the requested workspace.
|
|
2411
1163
|
*/
|
|
2412
1164
|
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);
|
|
1165
|
+
return this.workspaceClient.getWorkspace(id, requestId);
|
|
2423
1166
|
}
|
|
2424
1167
|
/**
|
|
2425
1168
|
* Creates a new workspace.
|
|
@@ -2429,16 +1172,7 @@ export class TodoistApi {
|
|
|
2429
1172
|
* @returns A promise that resolves to the created workspace.
|
|
2430
1173
|
*/
|
|
2431
1174
|
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);
|
|
1175
|
+
return this.workspaceClient.addWorkspace(args, requestId);
|
|
2442
1176
|
}
|
|
2443
1177
|
/**
|
|
2444
1178
|
* Updates an existing workspace.
|
|
@@ -2449,17 +1183,7 @@ export class TodoistApi {
|
|
|
2449
1183
|
* @returns A promise that resolves to the updated workspace.
|
|
2450
1184
|
*/
|
|
2451
1185
|
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);
|
|
1186
|
+
return this.workspaceClient.updateWorkspace(id, args, requestId);
|
|
2463
1187
|
}
|
|
2464
1188
|
/**
|
|
2465
1189
|
* Deletes a workspace by its ID.
|
|
@@ -2469,16 +1193,7 @@ export class TodoistApi {
|
|
|
2469
1193
|
* @returns A promise that resolves to `true` if successful.
|
|
2470
1194
|
*/
|
|
2471
1195
|
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);
|
|
1196
|
+
return this.workspaceClient.deleteWorkspace(id, requestId);
|
|
2482
1197
|
}
|
|
2483
1198
|
/**
|
|
2484
1199
|
* Retrieves activity information for workspace members.
|
|
@@ -2488,19 +1203,7 @@ export class TodoistApi {
|
|
|
2488
1203
|
* @returns A promise that resolves to workspace members activity data.
|
|
2489
1204
|
*/
|
|
2490
1205
|
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
|
-
};
|
|
1206
|
+
return this.workspaceClient.getWorkspaceMembersActivity(args, requestId);
|
|
2504
1207
|
}
|
|
2505
1208
|
/**
|
|
2506
1209
|
* Retrieves tasks assigned to a specific user in a workspace.
|
|
@@ -2510,19 +1213,7 @@ export class TodoistApi {
|
|
|
2510
1213
|
* @returns A promise that resolves to workspace user tasks.
|
|
2511
1214
|
*/
|
|
2512
1215
|
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
|
-
};
|
|
1216
|
+
return this.workspaceClient.getWorkspaceUserTasks(args, requestId);
|
|
2526
1217
|
}
|
|
2527
1218
|
/**
|
|
2528
1219
|
* Invites users to a workspace by email.
|
|
@@ -2532,17 +1223,7 @@ export class TodoistApi {
|
|
|
2532
1223
|
* @returns A promise that resolves to the list of invited emails.
|
|
2533
1224
|
*/
|
|
2534
1225
|
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;
|
|
1226
|
+
return this.workspaceClient.inviteWorkspaceUsers(args, requestId);
|
|
2546
1227
|
}
|
|
2547
1228
|
/**
|
|
2548
1229
|
* Updates a workspace user's role.
|
|
@@ -2552,17 +1233,7 @@ export class TodoistApi {
|
|
|
2552
1233
|
* @returns A promise that resolves to the updated workspace user view.
|
|
2553
1234
|
*/
|
|
2554
1235
|
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);
|
|
1236
|
+
return this.workspaceClient.updateWorkspaceUser(args, requestId);
|
|
2566
1237
|
}
|
|
2567
1238
|
/**
|
|
2568
1239
|
* Removes a user from a workspace.
|
|
@@ -2572,16 +1243,7 @@ export class TodoistApi {
|
|
|
2572
1243
|
* @returns A promise that resolves to `true` if successful.
|
|
2573
1244
|
*/
|
|
2574
1245
|
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);
|
|
1246
|
+
return this.workspaceClient.removeWorkspaceUser(args, requestId);
|
|
2585
1247
|
}
|
|
2586
1248
|
/**
|
|
2587
1249
|
* Gets active projects in a workspace with pagination.
|
|
@@ -2591,28 +1253,7 @@ export class TodoistApi {
|
|
|
2591
1253
|
* @returns Paginated list of active workspace projects.
|
|
2592
1254
|
*/
|
|
2593
1255
|
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 || [] });
|
|
1256
|
+
return this.workspaceClient.getWorkspaceActiveProjects(args, requestId);
|
|
2616
1257
|
}
|
|
2617
1258
|
/**
|
|
2618
1259
|
* Gets archived projects in a workspace with pagination.
|
|
@@ -2622,27 +1263,271 @@ export class TodoistApi {
|
|
|
2622
1263
|
* @returns Paginated list of archived workspace projects.
|
|
2623
1264
|
*/
|
|
2624
1265
|
async getWorkspaceArchivedProjects(args, requestId) {
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
1266
|
+
return this.workspaceClient.getWorkspaceArchivedProjects(args, requestId);
|
|
1267
|
+
}
|
|
1268
|
+
// ---------------------------------------------------------------------------
|
|
1269
|
+
// App management (dev:app_console scope)
|
|
1270
|
+
// ---------------------------------------------------------------------------
|
|
1271
|
+
/**
|
|
1272
|
+
* Lists all developer applications owned by the authenticated user.
|
|
1273
|
+
*
|
|
1274
|
+
* Requires the `dev:app_console` scope.
|
|
1275
|
+
*
|
|
1276
|
+
* @param requestId - Optional request ID for idempotency.
|
|
1277
|
+
* @returns A promise that resolves to the list of apps.
|
|
1278
|
+
*/
|
|
1279
|
+
async getApps(requestId) {
|
|
1280
|
+
return this.appClient.getApps(requestId);
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Retrieves a single developer application by ID.
|
|
1284
|
+
*
|
|
1285
|
+
* Requires the `dev:app_console` scope.
|
|
1286
|
+
*/
|
|
1287
|
+
async getApp(appId, requestId) {
|
|
1288
|
+
return this.appClient.getApp(appId, requestId);
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Creates a new developer application.
|
|
1292
|
+
*
|
|
1293
|
+
* Requires the `dev:app_console` scope.
|
|
1294
|
+
*/
|
|
1295
|
+
async addApp(args, requestId) {
|
|
1296
|
+
return this.appClient.addApp(args, requestId);
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Updates a developer application.
|
|
1300
|
+
*
|
|
1301
|
+
* Requires the `dev:app_console` scope.
|
|
1302
|
+
*/
|
|
1303
|
+
async updateApp(appId, args, requestId) {
|
|
1304
|
+
return this.appClient.updateApp(appId, args, requestId);
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Deletes a developer application.
|
|
1308
|
+
*
|
|
1309
|
+
* Requires the `dev:app_console` scope.
|
|
1310
|
+
*/
|
|
1311
|
+
async deleteApp(appId, requestId) {
|
|
1312
|
+
return this.appClient.deleteApp(appId, requestId);
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Retrieves the OAuth client credentials (client ID and secret) for an app.
|
|
1316
|
+
*
|
|
1317
|
+
* Requires the `dev:app_console` scope.
|
|
1318
|
+
*/
|
|
1319
|
+
async getAppSecrets(appId, requestId) {
|
|
1320
|
+
return this.appClient.getAppSecrets(appId, requestId);
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Rotates the app's OAuth client secret, returning the updated app record.
|
|
1324
|
+
*
|
|
1325
|
+
* Requires the `dev:app_console` scope.
|
|
1326
|
+
*/
|
|
1327
|
+
async resetAppClientSecret(appId, requestId) {
|
|
1328
|
+
return this.appClient.resetAppClientSecret(appId, requestId);
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Revokes every access token issued for the given app.
|
|
1332
|
+
*
|
|
1333
|
+
* Requires the `dev:app_console` scope.
|
|
1334
|
+
*/
|
|
1335
|
+
async revokeAppTokens(appId, requestId) {
|
|
1336
|
+
return this.appClient.revokeAppTokens(appId, requestId);
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Uploads an icon for a developer application. The `size` argument
|
|
1340
|
+
* selects which icon slot to update (defaults to `'medium'`).
|
|
1341
|
+
*
|
|
1342
|
+
* Requires the `dev:app_console` scope.
|
|
1343
|
+
*/
|
|
1344
|
+
async uploadAppIcon(args, requestId) {
|
|
1345
|
+
return this.appClient.uploadAppIcon(args, requestId);
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Gets the currently issued developer test token for an app (null if none exists).
|
|
1349
|
+
*
|
|
1350
|
+
* Requires the `dev:app_console` scope.
|
|
1351
|
+
*/
|
|
1352
|
+
async getAppTestToken(appId, requestId) {
|
|
1353
|
+
return this.appClient.getAppTestToken(appId, requestId);
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Creates (or rotates) a developer test token for an app.
|
|
1357
|
+
*
|
|
1358
|
+
* Requires the `dev:app_console` scope.
|
|
1359
|
+
*/
|
|
1360
|
+
async createAppTestToken(appId, requestId) {
|
|
1361
|
+
return this.appClient.createAppTestToken(appId, requestId);
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Gets the distribution token for an app, which third parties use to install it.
|
|
1365
|
+
*
|
|
1366
|
+
* Requires the `dev:app_console` scope.
|
|
1367
|
+
*/
|
|
1368
|
+
async getAppDistributionToken(appId, requestId) {
|
|
1369
|
+
return this.appClient.getAppDistributionToken(appId, requestId);
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Gets the current webhook verification token for an app.
|
|
1373
|
+
*
|
|
1374
|
+
* Requires the `dev:app_console` scope.
|
|
1375
|
+
*/
|
|
1376
|
+
async getAppVerificationToken(appId, requestId) {
|
|
1377
|
+
return this.appClient.getAppVerificationToken(appId, requestId);
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Resets the webhook verification token for an app, returning the new value.
|
|
1381
|
+
*
|
|
1382
|
+
* Requires the `dev:app_console` scope.
|
|
1383
|
+
*/
|
|
1384
|
+
async resetAppVerificationToken(appId, requestId) {
|
|
1385
|
+
return this.appClient.resetAppVerificationToken(appId, requestId);
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Resolves a public-facing app view from a distribution token. Used during
|
|
1389
|
+
* the installation flow to show prospective installers what the app does
|
|
1390
|
+
* and which scopes it requests.
|
|
1391
|
+
*
|
|
1392
|
+
* Requires the `dev:app_console` scope.
|
|
1393
|
+
*/
|
|
1394
|
+
async getAppByDistributionToken(distributionToken, requestId) {
|
|
1395
|
+
return this.appClient.getAppByDistributionToken(distributionToken, requestId);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Gets the webhook configuration for an app (null if no webhook is configured).
|
|
1399
|
+
*
|
|
1400
|
+
* Requires the `dev:app_console` scope.
|
|
1401
|
+
*/
|
|
1402
|
+
async getAppWebhook(appId, requestId) {
|
|
1403
|
+
return this.appClient.getAppWebhook(appId, requestId);
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Creates or updates an app webhook configuration (upsert).
|
|
1407
|
+
*
|
|
1408
|
+
* Requires the `dev:app_console` scope.
|
|
1409
|
+
*/
|
|
1410
|
+
async updateAppWebhook(args, requestId) {
|
|
1411
|
+
return this.appClient.updateAppWebhook(args, requestId);
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Deletes an app webhook configuration.
|
|
1415
|
+
*
|
|
1416
|
+
* Requires the `dev:app_console` scope.
|
|
1417
|
+
*/
|
|
1418
|
+
async deleteAppWebhook(appId, requestId) {
|
|
1419
|
+
return this.appClient.deleteAppWebhook(appId, requestId);
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Lists all apps installed on the authenticated user's account.
|
|
1423
|
+
*
|
|
1424
|
+
* Requires the `dev:app_console` scope.
|
|
1425
|
+
*/
|
|
1426
|
+
async getAppInstallations(requestId) {
|
|
1427
|
+
return this.appClient.getAppInstallations(requestId);
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Installs an application via its distribution token.
|
|
1431
|
+
*
|
|
1432
|
+
* Requires the `dev:app_console` scope.
|
|
1433
|
+
*/
|
|
1434
|
+
async installApp(args, requestId) {
|
|
1435
|
+
return this.appClient.installApp(args, requestId);
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Retrieves a single app installation by ID.
|
|
1439
|
+
*
|
|
1440
|
+
* Requires the `dev:app_console` scope.
|
|
1441
|
+
*/
|
|
1442
|
+
async getAppInstallation(installationId, requestId) {
|
|
1443
|
+
return this.appClient.getAppInstallation(installationId, requestId);
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Updates an app installation.
|
|
1447
|
+
*
|
|
1448
|
+
* Requires the `dev:app_console` scope.
|
|
1449
|
+
*/
|
|
1450
|
+
async updateAppInstallation(installationId, args, requestId) {
|
|
1451
|
+
return this.appClient.updateAppInstallation(installationId, args, requestId);
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Uninstalls (removes) an app installation.
|
|
1455
|
+
*
|
|
1456
|
+
* Requires the `dev:app_console` scope.
|
|
1457
|
+
*/
|
|
1458
|
+
async uninstallApp(installationId, requestId) {
|
|
1459
|
+
return this.appClient.uninstallApp(installationId, requestId);
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Retrieves a single UI extension by ID.
|
|
1463
|
+
*
|
|
1464
|
+
* Requires the `dev:app_console` scope.
|
|
1465
|
+
*/
|
|
1466
|
+
async getUiExtension(uiExtensionId, requestId) {
|
|
1467
|
+
return this.uiExtensionClient.getUiExtension(uiExtensionId, requestId);
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Lists UI extensions available (installed) in the web client for the current user.
|
|
1471
|
+
*
|
|
1472
|
+
* Requires the `dev:app_console` scope.
|
|
1473
|
+
*/
|
|
1474
|
+
async getInstalledUiExtensions(requestId) {
|
|
1475
|
+
return this.uiExtensionClient.getInstalledUiExtensions(requestId);
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Lists all UI extensions belonging to a given app (integration).
|
|
1479
|
+
*
|
|
1480
|
+
* Requires the `dev:app_console` scope.
|
|
1481
|
+
*/
|
|
1482
|
+
async getUiExtensionsForApp(appId, requestId) {
|
|
1483
|
+
return this.uiExtensionClient.getUiExtensionsForApp(appId, requestId);
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Adds a new UI extension to an app.
|
|
1487
|
+
*
|
|
1488
|
+
* Requires the `dev:app_console` scope.
|
|
1489
|
+
*/
|
|
1490
|
+
async addUiExtension(args, requestId) {
|
|
1491
|
+
return this.uiExtensionClient.addUiExtension(args, requestId);
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Updates an existing UI extension.
|
|
1495
|
+
*
|
|
1496
|
+
* Requires the `dev:app_console` scope.
|
|
1497
|
+
*/
|
|
1498
|
+
async updateUiExtension(uiExtensionId, args, requestId) {
|
|
1499
|
+
return this.uiExtensionClient.updateUiExtension(uiExtensionId, args, requestId);
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Deletes a UI extension.
|
|
1503
|
+
*
|
|
1504
|
+
* Requires the `dev:app_console` scope.
|
|
1505
|
+
*/
|
|
1506
|
+
async deleteUiExtension(uiExtensionId, requestId) {
|
|
1507
|
+
return this.uiExtensionClient.deleteUiExtension(uiExtensionId, requestId);
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Uploads an icon for a UI extension.
|
|
1511
|
+
*
|
|
1512
|
+
* Requires the `dev:app_console` scope.
|
|
1513
|
+
*/
|
|
1514
|
+
async uploadUiExtensionIcon(args, requestId) {
|
|
1515
|
+
return this.uiExtensionClient.uploadUiExtensionIcon(args, requestId);
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Lists all apps the user has authorized (granted a token to).
|
|
1519
|
+
*
|
|
1520
|
+
* Requires the `dev:app_console` scope.
|
|
1521
|
+
*/
|
|
1522
|
+
async getUserAuthorizations(requestId) {
|
|
1523
|
+
return this.appClient.getUserAuthorizations(requestId);
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Revokes a specific user authorization (access token granted to a third-party app).
|
|
1527
|
+
*
|
|
1528
|
+
* Requires the `dev:app_console` scope.
|
|
1529
|
+
*/
|
|
1530
|
+
async revokeUserAuthorization(args, requestId) {
|
|
1531
|
+
return this.appClient.revokeUserAuthorization(args, requestId);
|
|
2647
1532
|
}
|
|
2648
1533
|
}
|