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