@doist/todoist-sdk 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/authentication.js +1 -0
- package/dist/cjs/clients/activity-client.js +63 -0
- package/dist/cjs/clients/app-client.js +347 -0
- package/dist/cjs/clients/backup-client.js +65 -0
- package/dist/cjs/clients/base-client.js +30 -0
- package/dist/cjs/clients/comment-client.js +92 -0
- package/dist/cjs/clients/email-client.js +43 -0
- package/dist/cjs/clients/folder-client.js +80 -0
- package/dist/cjs/clients/id-mapping-client.js +39 -0
- package/dist/cjs/clients/insights-client.js +88 -0
- package/dist/cjs/clients/label-client.js +127 -0
- package/dist/cjs/clients/productivity-client.js +27 -0
- package/dist/cjs/clients/project-client.js +232 -0
- package/dist/cjs/clients/reminder-client.js +198 -0
- package/dist/cjs/clients/section-client.js +118 -0
- package/dist/cjs/clients/task-client.js +255 -0
- package/dist/cjs/clients/template-client.js +89 -0
- package/dist/cjs/clients/ui-extension-client.js +109 -0
- package/dist/cjs/clients/upload-client.js +102 -0
- package/dist/cjs/clients/workspace-client.js +367 -0
- package/dist/cjs/consts/endpoints.js +66 -1
- package/dist/cjs/test-utils/test-defaults.js +77 -1
- package/dist/cjs/todoist-api.js +422 -1537
- package/dist/cjs/transport/http-client.js +1 -0
- package/dist/cjs/transport/sync-request.js +75 -0
- package/dist/cjs/types/apps/index.js +18 -0
- package/dist/cjs/types/apps/requests.js +2 -0
- package/dist/cjs/types/apps/types.js +253 -0
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/types/ui-extensions/index.js +18 -0
- package/dist/cjs/types/ui-extensions/requests.js +2 -0
- package/dist/cjs/types/ui-extensions/types.js +77 -0
- package/dist/cjs/utils/headers.js +16 -0
- package/dist/cjs/utils/request-helpers.js +21 -0
- package/dist/cjs/utils/validators.js +52 -38
- package/dist/esm/authentication.js +1 -0
- package/dist/esm/clients/activity-client.js +59 -0
- package/dist/esm/clients/app-client.js +343 -0
- package/dist/esm/clients/backup-client.js +61 -0
- package/dist/esm/clients/base-client.js +26 -0
- package/dist/esm/clients/comment-client.js +88 -0
- package/dist/esm/clients/email-client.js +39 -0
- package/dist/esm/clients/folder-client.js +76 -0
- package/dist/esm/clients/id-mapping-client.js +35 -0
- package/dist/esm/clients/insights-client.js +84 -0
- package/dist/esm/clients/label-client.js +123 -0
- package/dist/esm/clients/productivity-client.js +23 -0
- package/dist/esm/clients/project-client.js +228 -0
- package/dist/esm/clients/reminder-client.js +194 -0
- package/dist/esm/clients/section-client.js +114 -0
- package/dist/esm/clients/task-client.js +251 -0
- package/dist/esm/clients/template-client.js +85 -0
- package/dist/esm/clients/ui-extension-client.js +105 -0
- package/dist/esm/clients/upload-client.js +98 -0
- package/dist/esm/clients/workspace-client.js +363 -0
- package/dist/esm/consts/endpoints.js +51 -0
- package/dist/esm/test-utils/test-defaults.js +75 -0
- package/dist/esm/todoist-api.js +425 -1540
- package/dist/esm/transport/http-client.js +1 -0
- package/dist/esm/transport/sync-request.js +72 -0
- package/dist/esm/types/apps/index.js +2 -0
- package/dist/esm/types/apps/requests.js +1 -0
- package/dist/esm/types/apps/types.js +248 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/ui-extensions/index.js +2 -0
- package/dist/esm/types/ui-extensions/requests.js +1 -0
- package/dist/esm/types/ui-extensions/types.js +74 -0
- package/dist/esm/utils/headers.js +13 -0
- package/dist/esm/utils/request-helpers.js +17 -0
- package/dist/esm/utils/validators.js +14 -0
- package/dist/types/authentication.d.ts +1 -1
- package/dist/types/clients/activity-client.d.ts +12 -0
- package/dist/types/clients/app-client.d.ts +37 -0
- package/dist/types/clients/backup-client.d.ts +14 -0
- package/dist/types/clients/base-client.d.ts +21 -0
- package/dist/types/clients/comment-client.d.ts +15 -0
- package/dist/types/clients/email-client.d.ts +13 -0
- package/dist/types/clients/folder-client.d.ts +16 -0
- package/dist/types/clients/id-mapping-client.d.ts +13 -0
- package/dist/types/clients/insights-client.d.ts +18 -0
- package/dist/types/clients/label-client.d.ts +19 -0
- package/dist/types/clients/productivity-client.d.ts +12 -0
- package/dist/types/clients/project-client.d.ts +26 -0
- package/dist/types/clients/reminder-client.d.ts +25 -0
- package/dist/types/clients/section-client.d.ts +18 -0
- package/dist/types/clients/task-client.d.ts +25 -0
- package/dist/types/clients/template-client.d.ts +17 -0
- package/dist/types/clients/ui-extension-client.d.ts +18 -0
- package/dist/types/clients/upload-client.d.ts +17 -0
- package/dist/types/clients/workspace-client.d.ts +43 -0
- package/dist/types/consts/endpoints.d.ts +24 -0
- package/dist/types/test-utils/test-defaults.d.ts +16 -1
- package/dist/types/todoist-api.d.ts +238 -17
- package/dist/types/transport/sync-request.d.ts +27 -0
- package/dist/types/types/apps/index.d.ts +2 -0
- package/dist/types/types/apps/requests.d.ts +89 -0
- package/dist/types/types/apps/types.d.ts +414 -0
- package/dist/types/types/http.d.ts +8 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/sync/resources/user.d.ts +2 -2
- package/dist/types/types/sync/response.d.ts +2 -2
- package/dist/types/types/sync/user-preferences.d.ts +1 -1
- package/dist/types/types/ui-extensions/index.d.ts +2 -0
- package/dist/types/types/ui-extensions/requests.d.ts +108 -0
- package/dist/types/types/ui-extensions/types.d.ts +185 -0
- package/dist/types/utils/headers.d.ts +7 -0
- package/dist/types/utils/request-helpers.d.ts +13 -0
- package/dist/types/utils/validators.d.ts +223 -0
- package/package.json +1 -1
package/dist/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,16 +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);
|
|
943
|
+
return this.folderClient.deleteFolder(id, requestId);
|
|
1921
944
|
}
|
|
1922
945
|
// ── Backups ──
|
|
1923
946
|
/**
|
|
@@ -1927,15 +950,7 @@ class TodoistApi {
|
|
|
1927
950
|
* @returns A promise that resolves to an array of backups.
|
|
1928
951
|
*/
|
|
1929
952
|
async getBackups(args = {}) {
|
|
1930
|
-
|
|
1931
|
-
httpMethod: 'GET',
|
|
1932
|
-
baseUri: this.syncApiBase,
|
|
1933
|
-
relativePath: endpoints_1.ENDPOINT_REST_BACKUPS,
|
|
1934
|
-
apiToken: this.authToken,
|
|
1935
|
-
customFetch: this.customFetch,
|
|
1936
|
-
payload: args,
|
|
1937
|
-
});
|
|
1938
|
-
return (0, validators_1.validateBackupArray)(response.data);
|
|
953
|
+
return this.backupClient.getBackups(args);
|
|
1939
954
|
}
|
|
1940
955
|
/**
|
|
1941
956
|
* Downloads a backup file as binary data.
|
|
@@ -1944,40 +959,7 @@ class TodoistApi {
|
|
|
1944
959
|
* @returns A promise that resolves to a response with binary data accessible via arrayBuffer().
|
|
1945
960
|
*/
|
|
1946
961
|
async downloadBackup(args) {
|
|
1947
|
-
|
|
1948
|
-
const fetchOptions = {
|
|
1949
|
-
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
1950
|
-
};
|
|
1951
|
-
if (this.customFetch) {
|
|
1952
|
-
const response = await this.customFetch(url, fetchOptions);
|
|
1953
|
-
if (!response.ok) {
|
|
1954
|
-
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
1955
|
-
}
|
|
1956
|
-
const text = await response.text();
|
|
1957
|
-
const buffer = new TextEncoder().encode(text).buffer;
|
|
1958
|
-
return {
|
|
1959
|
-
ok: response.ok,
|
|
1960
|
-
status: response.status,
|
|
1961
|
-
statusText: response.statusText,
|
|
1962
|
-
headers: response.headers,
|
|
1963
|
-
text: () => Promise.resolve(text),
|
|
1964
|
-
json: () => response.json(),
|
|
1965
|
-
arrayBuffer: () => Promise.resolve(buffer),
|
|
1966
|
-
};
|
|
1967
|
-
}
|
|
1968
|
-
const response = await fetch(url, fetchOptions);
|
|
1969
|
-
if (!response.ok) {
|
|
1970
|
-
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
1971
|
-
}
|
|
1972
|
-
return {
|
|
1973
|
-
ok: response.ok,
|
|
1974
|
-
status: response.status,
|
|
1975
|
-
statusText: response.statusText,
|
|
1976
|
-
headers: headersToRecord(response.headers),
|
|
1977
|
-
text: () => response.text(),
|
|
1978
|
-
json: () => response.json(),
|
|
1979
|
-
arrayBuffer: () => response.arrayBuffer(),
|
|
1980
|
-
};
|
|
962
|
+
return this.backupClient.downloadBackup(args);
|
|
1981
963
|
}
|
|
1982
964
|
// ── Emails ──
|
|
1983
965
|
/**
|
|
@@ -1988,16 +970,7 @@ class TodoistApi {
|
|
|
1988
970
|
* @returns A promise that resolves to the email address.
|
|
1989
971
|
*/
|
|
1990
972
|
async getOrCreateEmailForwarding(args, requestId) {
|
|
1991
|
-
|
|
1992
|
-
httpMethod: 'PUT',
|
|
1993
|
-
baseUri: this.syncApiBase,
|
|
1994
|
-
relativePath: endpoints_1.ENDPOINT_REST_EMAILS,
|
|
1995
|
-
apiToken: this.authToken,
|
|
1996
|
-
customFetch: this.customFetch,
|
|
1997
|
-
payload: args,
|
|
1998
|
-
requestId: requestId,
|
|
1999
|
-
});
|
|
2000
|
-
return data;
|
|
973
|
+
return this.emailClient.getOrCreateEmailForwarding(args, requestId);
|
|
2001
974
|
}
|
|
2002
975
|
/**
|
|
2003
976
|
* Disables email forwarding for an object.
|
|
@@ -2007,19 +980,7 @@ class TodoistApi {
|
|
|
2007
980
|
* @returns A promise that resolves to `true` if successful.
|
|
2008
981
|
*/
|
|
2009
982
|
async disableEmailForwarding(args, requestId) {
|
|
2010
|
-
|
|
2011
|
-
obj_type: args.objType,
|
|
2012
|
-
obj_id: args.objId,
|
|
2013
|
-
});
|
|
2014
|
-
const response = await (0, http_client_1.request)({
|
|
2015
|
-
httpMethod: 'DELETE',
|
|
2016
|
-
baseUri: this.syncApiBase,
|
|
2017
|
-
relativePath: `${endpoints_1.ENDPOINT_REST_EMAILS}?${queryParams.toString()}`,
|
|
2018
|
-
apiToken: this.authToken,
|
|
2019
|
-
customFetch: this.customFetch,
|
|
2020
|
-
requestId: requestId,
|
|
2021
|
-
});
|
|
2022
|
-
return (0, http_client_1.isSuccess)(response);
|
|
983
|
+
return this.emailClient.disableEmailForwarding(args, requestId);
|
|
2023
984
|
}
|
|
2024
985
|
// ── ID Mappings ──
|
|
2025
986
|
/**
|
|
@@ -2029,14 +990,7 @@ class TodoistApi {
|
|
|
2029
990
|
* @returns A promise that resolves to an array of ID mappings.
|
|
2030
991
|
*/
|
|
2031
992
|
async getIdMappings(args) {
|
|
2032
|
-
|
|
2033
|
-
httpMethod: 'GET',
|
|
2034
|
-
baseUri: this.syncApiBase,
|
|
2035
|
-
relativePath: generatePath(endpoints_1.ENDPOINT_REST_ID_MAPPINGS, args.objName, args.objIds.join(',')),
|
|
2036
|
-
apiToken: this.authToken,
|
|
2037
|
-
customFetch: this.customFetch,
|
|
2038
|
-
});
|
|
2039
|
-
return (0, validators_1.validateIdMappingArray)(response.data);
|
|
993
|
+
return this.idMappingClient.getIdMappings(args);
|
|
2040
994
|
}
|
|
2041
995
|
/**
|
|
2042
996
|
* Retrieves moved IDs for objects that have been migrated.
|
|
@@ -2045,15 +999,7 @@ class TodoistApi {
|
|
|
2045
999
|
* @returns A promise that resolves to an array of moved ID pairs.
|
|
2046
1000
|
*/
|
|
2047
1001
|
async getMovedIds(args) {
|
|
2048
|
-
|
|
2049
|
-
httpMethod: 'GET',
|
|
2050
|
-
baseUri: this.syncApiBase,
|
|
2051
|
-
relativePath: generatePath(endpoints_1.ENDPOINT_REST_MOVED_IDS, args.objName),
|
|
2052
|
-
apiToken: this.authToken,
|
|
2053
|
-
customFetch: this.customFetch,
|
|
2054
|
-
payload: args.oldIds ? { oldIds: args.oldIds.join(',') } : undefined,
|
|
2055
|
-
});
|
|
2056
|
-
return (0, validators_1.validateMovedIdArray)(response.data);
|
|
1002
|
+
return this.idMappingClient.getMovedIds(args);
|
|
2057
1003
|
}
|
|
2058
1004
|
// ── Templates ──
|
|
2059
1005
|
/**
|
|
@@ -2063,15 +1009,7 @@ class TodoistApi {
|
|
|
2063
1009
|
* @returns A promise that resolves to the template file content as a string.
|
|
2064
1010
|
*/
|
|
2065
1011
|
async exportTemplateAsFile(args) {
|
|
2066
|
-
|
|
2067
|
-
httpMethod: 'GET',
|
|
2068
|
-
baseUri: this.syncApiBase,
|
|
2069
|
-
relativePath: endpoints_1.ENDPOINT_REST_TEMPLATES_FILE,
|
|
2070
|
-
apiToken: this.authToken,
|
|
2071
|
-
customFetch: this.customFetch,
|
|
2072
|
-
payload: args,
|
|
2073
|
-
});
|
|
2074
|
-
return response.data;
|
|
1012
|
+
return this.templateClient.exportTemplateAsFile(args);
|
|
2075
1013
|
}
|
|
2076
1014
|
/**
|
|
2077
1015
|
* Exports a project as a template URL.
|
|
@@ -2080,15 +1018,7 @@ class TodoistApi {
|
|
|
2080
1018
|
* @returns A promise that resolves to the file name and URL.
|
|
2081
1019
|
*/
|
|
2082
1020
|
async exportTemplateAsUrl(args) {
|
|
2083
|
-
|
|
2084
|
-
httpMethod: 'GET',
|
|
2085
|
-
baseUri: this.syncApiBase,
|
|
2086
|
-
relativePath: endpoints_1.ENDPOINT_REST_TEMPLATES_URL,
|
|
2087
|
-
apiToken: this.authToken,
|
|
2088
|
-
customFetch: this.customFetch,
|
|
2089
|
-
payload: args,
|
|
2090
|
-
});
|
|
2091
|
-
return data;
|
|
1021
|
+
return this.templateClient.exportTemplateAsUrl(args);
|
|
2092
1022
|
}
|
|
2093
1023
|
/**
|
|
2094
1024
|
* Creates a new project from a template file.
|
|
@@ -2098,22 +1028,7 @@ class TodoistApi {
|
|
|
2098
1028
|
* @returns A promise that resolves to the created project data.
|
|
2099
1029
|
*/
|
|
2100
1030
|
async createProjectFromTemplate(args, requestId) {
|
|
2101
|
-
|
|
2102
|
-
const additionalFields = { name };
|
|
2103
|
-
if (workspaceId !== undefined && workspaceId !== null) {
|
|
2104
|
-
additionalFields.workspace_id = workspaceId;
|
|
2105
|
-
}
|
|
2106
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
2107
|
-
baseUrl: this.syncApiBase,
|
|
2108
|
-
authToken: this.authToken,
|
|
2109
|
-
endpoint: endpoints_1.ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE,
|
|
2110
|
-
file,
|
|
2111
|
-
fileName,
|
|
2112
|
-
additionalFields,
|
|
2113
|
-
customFetch: this.customFetch,
|
|
2114
|
-
requestId,
|
|
2115
|
-
});
|
|
2116
|
-
return this.validateTemplateResponse((0, case_conversion_1.camelCaseKeys)(data));
|
|
1031
|
+
return this.templateClient.createProjectFromTemplate(args, requestId);
|
|
2117
1032
|
}
|
|
2118
1033
|
/**
|
|
2119
1034
|
* Imports a template file into an existing project.
|
|
@@ -2123,18 +1038,7 @@ class TodoistApi {
|
|
|
2123
1038
|
* @returns A promise that resolves to the import result.
|
|
2124
1039
|
*/
|
|
2125
1040
|
async importTemplateIntoProject(args, requestId) {
|
|
2126
|
-
|
|
2127
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
2128
|
-
baseUrl: this.syncApiBase,
|
|
2129
|
-
authToken: this.authToken,
|
|
2130
|
-
endpoint: endpoints_1.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE,
|
|
2131
|
-
file,
|
|
2132
|
-
fileName,
|
|
2133
|
-
additionalFields: { project_id: projectId },
|
|
2134
|
-
customFetch: this.customFetch,
|
|
2135
|
-
requestId,
|
|
2136
|
-
});
|
|
2137
|
-
return this.validateTemplateResponse((0, case_conversion_1.camelCaseKeys)(data));
|
|
1041
|
+
return this.templateClient.importTemplateIntoProject(args, requestId);
|
|
2138
1042
|
}
|
|
2139
1043
|
/**
|
|
2140
1044
|
* Imports a template by ID into an existing project.
|
|
@@ -2144,20 +1048,7 @@ class TodoistApi {
|
|
|
2144
1048
|
* @returns A promise that resolves to the import result.
|
|
2145
1049
|
*/
|
|
2146
1050
|
async importTemplateFromId(args, requestId) {
|
|
2147
|
-
|
|
2148
|
-
httpMethod: 'POST',
|
|
2149
|
-
baseUri: this.syncApiBase,
|
|
2150
|
-
relativePath: endpoints_1.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID,
|
|
2151
|
-
apiToken: this.authToken,
|
|
2152
|
-
customFetch: this.customFetch,
|
|
2153
|
-
payload: args,
|
|
2154
|
-
requestId: requestId,
|
|
2155
|
-
});
|
|
2156
|
-
return this.validateTemplateResponse(data);
|
|
2157
|
-
}
|
|
2158
|
-
validateTemplateResponse(data) {
|
|
2159
|
-
var _a, _b, _c, _d;
|
|
2160
|
-
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);
|
|
2161
1052
|
}
|
|
2162
1053
|
/* Workspace methods */
|
|
2163
1054
|
/**
|
|
@@ -2168,16 +1059,7 @@ class TodoistApi {
|
|
|
2168
1059
|
* @returns Array of email addresses with pending invitations.
|
|
2169
1060
|
*/
|
|
2170
1061
|
async getWorkspaceInvitations(args, requestId) {
|
|
2171
|
-
|
|
2172
|
-
httpMethod: 'GET',
|
|
2173
|
-
baseUri: this.syncApiBase,
|
|
2174
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS,
|
|
2175
|
-
apiToken: this.authToken,
|
|
2176
|
-
customFetch: this.customFetch,
|
|
2177
|
-
payload: { workspace_id: args.workspaceId },
|
|
2178
|
-
requestId: requestId,
|
|
2179
|
-
});
|
|
2180
|
-
return response.data;
|
|
1062
|
+
return this.workspaceClient.getWorkspaceInvitations(args, requestId);
|
|
2181
1063
|
}
|
|
2182
1064
|
/**
|
|
2183
1065
|
* Gets all workspace invitations (admin only).
|
|
@@ -2186,20 +1068,7 @@ class TodoistApi {
|
|
|
2186
1068
|
* @returns Array of email addresses with pending invitations.
|
|
2187
1069
|
*/
|
|
2188
1070
|
async getAllWorkspaceInvitations(args = {}, requestId) {
|
|
2189
|
-
|
|
2190
|
-
if (args.workspaceId) {
|
|
2191
|
-
queryParams.workspace_id = args.workspaceId;
|
|
2192
|
-
}
|
|
2193
|
-
const response = await (0, http_client_1.request)({
|
|
2194
|
-
httpMethod: 'GET',
|
|
2195
|
-
baseUri: this.syncApiBase,
|
|
2196
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_ALL,
|
|
2197
|
-
apiToken: this.authToken,
|
|
2198
|
-
customFetch: this.customFetch,
|
|
2199
|
-
payload: queryParams,
|
|
2200
|
-
requestId: requestId,
|
|
2201
|
-
});
|
|
2202
|
-
return (0, validators_1.validateWorkspaceInvitationArray)(response.data);
|
|
1071
|
+
return this.workspaceClient.getAllWorkspaceInvitations(args, requestId);
|
|
2203
1072
|
}
|
|
2204
1073
|
/**
|
|
2205
1074
|
* Deletes a workspace invitation (admin only).
|
|
@@ -2209,19 +1078,7 @@ class TodoistApi {
|
|
|
2209
1078
|
* @returns The deleted invitation.
|
|
2210
1079
|
*/
|
|
2211
1080
|
async deleteWorkspaceInvitation(args, requestId) {
|
|
2212
|
-
|
|
2213
|
-
httpMethod: 'POST',
|
|
2214
|
-
baseUri: this.syncApiBase,
|
|
2215
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
|
|
2216
|
-
apiToken: this.authToken,
|
|
2217
|
-
customFetch: this.customFetch,
|
|
2218
|
-
payload: {
|
|
2219
|
-
workspace_id: args.workspaceId,
|
|
2220
|
-
user_email: args.userEmail,
|
|
2221
|
-
},
|
|
2222
|
-
requestId: requestId,
|
|
2223
|
-
});
|
|
2224
|
-
return (0, validators_1.validateWorkspaceInvitation)(response.data);
|
|
1081
|
+
return this.workspaceClient.deleteWorkspaceInvitation(args, requestId);
|
|
2225
1082
|
}
|
|
2226
1083
|
/**
|
|
2227
1084
|
* Accepts a workspace invitation.
|
|
@@ -2231,15 +1088,7 @@ class TodoistApi {
|
|
|
2231
1088
|
* @returns The accepted invitation.
|
|
2232
1089
|
*/
|
|
2233
1090
|
async acceptWorkspaceInvitation(args, requestId) {
|
|
2234
|
-
|
|
2235
|
-
httpMethod: 'PUT',
|
|
2236
|
-
baseUri: this.syncApiBase,
|
|
2237
|
-
relativePath: (0, endpoints_1.getWorkspaceInvitationAcceptEndpoint)(args.inviteCode),
|
|
2238
|
-
apiToken: this.authToken,
|
|
2239
|
-
customFetch: this.customFetch,
|
|
2240
|
-
requestId: requestId,
|
|
2241
|
-
});
|
|
2242
|
-
return (0, validators_1.validateWorkspaceInvitation)(response.data);
|
|
1091
|
+
return this.workspaceClient.acceptWorkspaceInvitation(args, requestId);
|
|
2243
1092
|
}
|
|
2244
1093
|
/**
|
|
2245
1094
|
* Rejects a workspace invitation.
|
|
@@ -2249,15 +1098,7 @@ class TodoistApi {
|
|
|
2249
1098
|
* @returns The rejected invitation.
|
|
2250
1099
|
*/
|
|
2251
1100
|
async rejectWorkspaceInvitation(args, requestId) {
|
|
2252
|
-
|
|
2253
|
-
httpMethod: 'PUT',
|
|
2254
|
-
baseUri: this.syncApiBase,
|
|
2255
|
-
relativePath: (0, endpoints_1.getWorkspaceInvitationRejectEndpoint)(args.inviteCode),
|
|
2256
|
-
apiToken: this.authToken,
|
|
2257
|
-
customFetch: this.customFetch,
|
|
2258
|
-
requestId: requestId,
|
|
2259
|
-
});
|
|
2260
|
-
return (0, validators_1.validateWorkspaceInvitation)(response.data);
|
|
1101
|
+
return this.workspaceClient.rejectWorkspaceInvitation(args, requestId);
|
|
2261
1102
|
}
|
|
2262
1103
|
/**
|
|
2263
1104
|
* Joins a workspace via invitation link or domain auto-join.
|
|
@@ -2267,19 +1108,7 @@ class TodoistApi {
|
|
|
2267
1108
|
* @returns Workspace user information.
|
|
2268
1109
|
*/
|
|
2269
1110
|
async joinWorkspace(args, requestId) {
|
|
2270
|
-
|
|
2271
|
-
httpMethod: 'POST',
|
|
2272
|
-
baseUri: this.syncApiBase,
|
|
2273
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_JOIN,
|
|
2274
|
-
apiToken: this.authToken,
|
|
2275
|
-
customFetch: this.customFetch,
|
|
2276
|
-
payload: {
|
|
2277
|
-
invite_code: args.inviteCode,
|
|
2278
|
-
workspace_id: args.workspaceId,
|
|
2279
|
-
},
|
|
2280
|
-
requestId: requestId,
|
|
2281
|
-
});
|
|
2282
|
-
return (0, validators_1.validateJoinWorkspaceResult)(response.data);
|
|
1111
|
+
return this.workspaceClient.joinWorkspace(args, requestId);
|
|
2283
1112
|
}
|
|
2284
1113
|
/**
|
|
2285
1114
|
* Uploads or updates a workspace logo.
|
|
@@ -2289,44 +1118,7 @@ class TodoistApi {
|
|
|
2289
1118
|
* @returns Logo information or null if deleted.
|
|
2290
1119
|
*/
|
|
2291
1120
|
async uploadWorkspaceLogo(args, requestId) {
|
|
2292
|
-
|
|
2293
|
-
// Delete logo
|
|
2294
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
2295
|
-
baseUrl: this.syncApiBase,
|
|
2296
|
-
authToken: this.authToken,
|
|
2297
|
-
endpoint: endpoints_1.ENDPOINT_WORKSPACE_LOGO,
|
|
2298
|
-
file: Buffer.alloc(0), // Empty buffer for delete
|
|
2299
|
-
fileName: 'delete',
|
|
2300
|
-
additionalFields: {
|
|
2301
|
-
workspace_id: args.workspaceId,
|
|
2302
|
-
delete: true,
|
|
2303
|
-
},
|
|
2304
|
-
requestId: requestId,
|
|
2305
|
-
customFetch: this.customFetch,
|
|
2306
|
-
});
|
|
2307
|
-
return data;
|
|
2308
|
-
}
|
|
2309
|
-
if (!args.file) {
|
|
2310
|
-
throw new Error('file is required when not deleting logo');
|
|
2311
|
-
}
|
|
2312
|
-
// Validate buffer is not empty if it's a Buffer
|
|
2313
|
-
if (Buffer.isBuffer(args.file) && args.file.length === 0) {
|
|
2314
|
-
throw new Error('Cannot upload empty image file');
|
|
2315
|
-
}
|
|
2316
|
-
const additionalFields = {
|
|
2317
|
-
workspace_id: args.workspaceId,
|
|
2318
|
-
};
|
|
2319
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
2320
|
-
baseUrl: this.syncApiBase,
|
|
2321
|
-
authToken: this.authToken,
|
|
2322
|
-
endpoint: endpoints_1.ENDPOINT_WORKSPACE_LOGO,
|
|
2323
|
-
file: args.file,
|
|
2324
|
-
fileName: args.fileName,
|
|
2325
|
-
additionalFields: additionalFields,
|
|
2326
|
-
requestId: requestId,
|
|
2327
|
-
customFetch: this.customFetch,
|
|
2328
|
-
});
|
|
2329
|
-
return data;
|
|
1121
|
+
return this.workspaceClient.uploadWorkspaceLogo(args, requestId);
|
|
2330
1122
|
}
|
|
2331
1123
|
/**
|
|
2332
1124
|
* Gets workspace plan and billing details.
|
|
@@ -2336,16 +1128,7 @@ class TodoistApi {
|
|
|
2336
1128
|
* @returns Workspace plan details.
|
|
2337
1129
|
*/
|
|
2338
1130
|
async getWorkspacePlanDetails(args, requestId) {
|
|
2339
|
-
|
|
2340
|
-
httpMethod: 'GET',
|
|
2341
|
-
baseUri: this.syncApiBase,
|
|
2342
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_PLAN_DETAILS,
|
|
2343
|
-
apiToken: this.authToken,
|
|
2344
|
-
customFetch: this.customFetch,
|
|
2345
|
-
payload: { workspace_id: args.workspaceId },
|
|
2346
|
-
requestId: requestId,
|
|
2347
|
-
});
|
|
2348
|
-
return (0, validators_1.validateWorkspacePlanDetails)(response.data);
|
|
1131
|
+
return this.workspaceClient.getWorkspacePlanDetails(args, requestId);
|
|
2349
1132
|
}
|
|
2350
1133
|
/**
|
|
2351
1134
|
* Gets workspace users with pagination.
|
|
@@ -2355,30 +1138,7 @@ class TodoistApi {
|
|
|
2355
1138
|
* @returns Paginated list of workspace users.
|
|
2356
1139
|
*/
|
|
2357
1140
|
async getWorkspaceUsers(args = {}, requestId) {
|
|
2358
|
-
|
|
2359
|
-
if (args.workspaceId !== undefined && args.workspaceId !== null) {
|
|
2360
|
-
queryParams.workspace_id = args.workspaceId;
|
|
2361
|
-
}
|
|
2362
|
-
if (args.cursor) {
|
|
2363
|
-
queryParams.cursor = args.cursor;
|
|
2364
|
-
}
|
|
2365
|
-
if (args.limit) {
|
|
2366
|
-
queryParams.limit = args.limit;
|
|
2367
|
-
}
|
|
2368
|
-
const response = await (0, http_client_1.request)({
|
|
2369
|
-
httpMethod: 'GET',
|
|
2370
|
-
baseUri: this.syncApiBase,
|
|
2371
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_USERS,
|
|
2372
|
-
apiToken: this.authToken,
|
|
2373
|
-
customFetch: this.customFetch,
|
|
2374
|
-
payload: queryParams,
|
|
2375
|
-
requestId: requestId,
|
|
2376
|
-
});
|
|
2377
|
-
return {
|
|
2378
|
-
hasMore: response.data.hasMore || false,
|
|
2379
|
-
nextCursor: response.data.nextCursor,
|
|
2380
|
-
workspaceUsers: (0, validators_1.validateWorkspaceUserArray)(response.data.workspaceUsers || []),
|
|
2381
|
-
};
|
|
1141
|
+
return this.workspaceClient.getWorkspaceUsers(args, requestId);
|
|
2382
1142
|
}
|
|
2383
1143
|
/**
|
|
2384
1144
|
* Retrieves all workspaces for the authenticated user.
|
|
@@ -2395,15 +1155,7 @@ class TodoistApi {
|
|
|
2395
1155
|
* ```
|
|
2396
1156
|
*/
|
|
2397
1157
|
async getWorkspaces(requestId) {
|
|
2398
|
-
|
|
2399
|
-
httpMethod: 'GET',
|
|
2400
|
-
baseUri: this.syncApiBase,
|
|
2401
|
-
relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
|
|
2402
|
-
apiToken: this.authToken,
|
|
2403
|
-
customFetch: this.customFetch,
|
|
2404
|
-
requestId: requestId,
|
|
2405
|
-
});
|
|
2406
|
-
return (0, validators_1.validateWorkspaceArray)(response.data);
|
|
1158
|
+
return this.workspaceClient.getWorkspaces(requestId);
|
|
2407
1159
|
}
|
|
2408
1160
|
/**
|
|
2409
1161
|
* Retrieves a workspace by its ID.
|
|
@@ -2413,16 +1165,7 @@ class TodoistApi {
|
|
|
2413
1165
|
* @returns A promise that resolves to the requested workspace.
|
|
2414
1166
|
*/
|
|
2415
1167
|
async getWorkspace(id, requestId) {
|
|
2416
|
-
|
|
2417
|
-
const response = await (0, http_client_1.request)({
|
|
2418
|
-
httpMethod: 'GET',
|
|
2419
|
-
baseUri: this.syncApiBase,
|
|
2420
|
-
relativePath: generatePath(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
|
|
2421
|
-
apiToken: this.authToken,
|
|
2422
|
-
customFetch: this.customFetch,
|
|
2423
|
-
requestId: requestId,
|
|
2424
|
-
});
|
|
2425
|
-
return (0, validators_1.validateWorkspace)(response.data);
|
|
1168
|
+
return this.workspaceClient.getWorkspace(id, requestId);
|
|
2426
1169
|
}
|
|
2427
1170
|
/**
|
|
2428
1171
|
* Creates a new workspace.
|
|
@@ -2432,16 +1175,7 @@ class TodoistApi {
|
|
|
2432
1175
|
* @returns A promise that resolves to the created workspace.
|
|
2433
1176
|
*/
|
|
2434
1177
|
async addWorkspace(args, requestId) {
|
|
2435
|
-
|
|
2436
|
-
httpMethod: 'POST',
|
|
2437
|
-
baseUri: this.syncApiBase,
|
|
2438
|
-
relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
|
|
2439
|
-
apiToken: this.authToken,
|
|
2440
|
-
customFetch: this.customFetch,
|
|
2441
|
-
payload: args,
|
|
2442
|
-
requestId: requestId,
|
|
2443
|
-
});
|
|
2444
|
-
return (0, validators_1.validateWorkspace)(response.data);
|
|
1178
|
+
return this.workspaceClient.addWorkspace(args, requestId);
|
|
2445
1179
|
}
|
|
2446
1180
|
/**
|
|
2447
1181
|
* Updates an existing workspace.
|
|
@@ -2452,17 +1186,7 @@ class TodoistApi {
|
|
|
2452
1186
|
* @returns A promise that resolves to the updated workspace.
|
|
2453
1187
|
*/
|
|
2454
1188
|
async updateWorkspace(id, args, requestId) {
|
|
2455
|
-
|
|
2456
|
-
const response = await (0, http_client_1.request)({
|
|
2457
|
-
httpMethod: 'POST',
|
|
2458
|
-
baseUri: this.syncApiBase,
|
|
2459
|
-
relativePath: generatePath(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
|
|
2460
|
-
apiToken: this.authToken,
|
|
2461
|
-
customFetch: this.customFetch,
|
|
2462
|
-
payload: args,
|
|
2463
|
-
requestId: requestId,
|
|
2464
|
-
});
|
|
2465
|
-
return (0, validators_1.validateWorkspace)(response.data);
|
|
1189
|
+
return this.workspaceClient.updateWorkspace(id, args, requestId);
|
|
2466
1190
|
}
|
|
2467
1191
|
/**
|
|
2468
1192
|
* Deletes a workspace by its ID.
|
|
@@ -2472,16 +1196,7 @@ class TodoistApi {
|
|
|
2472
1196
|
* @returns A promise that resolves to `true` if successful.
|
|
2473
1197
|
*/
|
|
2474
1198
|
async deleteWorkspace(id, requestId) {
|
|
2475
|
-
|
|
2476
|
-
const response = await (0, http_client_1.request)({
|
|
2477
|
-
httpMethod: 'DELETE',
|
|
2478
|
-
baseUri: this.syncApiBase,
|
|
2479
|
-
relativePath: generatePath(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
|
|
2480
|
-
apiToken: this.authToken,
|
|
2481
|
-
customFetch: this.customFetch,
|
|
2482
|
-
requestId: requestId,
|
|
2483
|
-
});
|
|
2484
|
-
return (0, http_client_1.isSuccess)(response);
|
|
1199
|
+
return this.workspaceClient.deleteWorkspace(id, requestId);
|
|
2485
1200
|
}
|
|
2486
1201
|
/**
|
|
2487
1202
|
* Retrieves activity information for workspace members.
|
|
@@ -2491,19 +1206,7 @@ class TodoistApi {
|
|
|
2491
1206
|
* @returns A promise that resolves to workspace members activity data.
|
|
2492
1207
|
*/
|
|
2493
1208
|
async getWorkspaceMembersActivity(args, requestId) {
|
|
2494
|
-
|
|
2495
|
-
const { data } = await (0, http_client_1.request)({
|
|
2496
|
-
httpMethod: 'GET',
|
|
2497
|
-
baseUri: this.syncApiBase,
|
|
2498
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_MEMBERS,
|
|
2499
|
-
apiToken: this.authToken,
|
|
2500
|
-
customFetch: this.customFetch,
|
|
2501
|
-
payload: Object.assign({ workspaceId }, queryParams),
|
|
2502
|
-
requestId: requestId,
|
|
2503
|
-
});
|
|
2504
|
-
return {
|
|
2505
|
-
members: (0, validators_1.validateMemberActivityInfoArray)(data.members),
|
|
2506
|
-
};
|
|
1209
|
+
return this.workspaceClient.getWorkspaceMembersActivity(args, requestId);
|
|
2507
1210
|
}
|
|
2508
1211
|
/**
|
|
2509
1212
|
* Retrieves tasks assigned to a specific user in a workspace.
|
|
@@ -2513,19 +1216,7 @@ class TodoistApi {
|
|
|
2513
1216
|
* @returns A promise that resolves to workspace user tasks.
|
|
2514
1217
|
*/
|
|
2515
1218
|
async getWorkspaceUserTasks(args, requestId) {
|
|
2516
|
-
|
|
2517
|
-
const { data } = await (0, http_client_1.request)({
|
|
2518
|
-
httpMethod: 'GET',
|
|
2519
|
-
baseUri: this.syncApiBase,
|
|
2520
|
-
relativePath: (0, endpoints_1.getWorkspaceUserTasksEndpoint)(workspaceId, userId),
|
|
2521
|
-
apiToken: this.authToken,
|
|
2522
|
-
customFetch: this.customFetch,
|
|
2523
|
-
payload: queryParams,
|
|
2524
|
-
requestId: requestId,
|
|
2525
|
-
});
|
|
2526
|
-
return {
|
|
2527
|
-
tasks: (0, validators_1.validateWorkspaceUserTaskArray)(data.tasks),
|
|
2528
|
-
};
|
|
1219
|
+
return this.workspaceClient.getWorkspaceUserTasks(args, requestId);
|
|
2529
1220
|
}
|
|
2530
1221
|
/**
|
|
2531
1222
|
* Invites users to a workspace by email.
|
|
@@ -2535,17 +1226,7 @@ class TodoistApi {
|
|
|
2535
1226
|
* @returns A promise that resolves to the list of invited emails.
|
|
2536
1227
|
*/
|
|
2537
1228
|
async inviteWorkspaceUsers(args, requestId) {
|
|
2538
|
-
|
|
2539
|
-
const { data } = await (0, http_client_1.request)({
|
|
2540
|
-
httpMethod: 'POST',
|
|
2541
|
-
baseUri: this.syncApiBase,
|
|
2542
|
-
relativePath: (0, endpoints_1.getWorkspaceInviteUsersEndpoint)(workspaceId),
|
|
2543
|
-
apiToken: this.authToken,
|
|
2544
|
-
customFetch: this.customFetch,
|
|
2545
|
-
payload: payload,
|
|
2546
|
-
requestId: requestId,
|
|
2547
|
-
});
|
|
2548
|
-
return data;
|
|
1229
|
+
return this.workspaceClient.inviteWorkspaceUsers(args, requestId);
|
|
2549
1230
|
}
|
|
2550
1231
|
/**
|
|
2551
1232
|
* Updates a workspace user's role.
|
|
@@ -2555,17 +1236,7 @@ class TodoistApi {
|
|
|
2555
1236
|
* @returns A promise that resolves to the updated workspace user view.
|
|
2556
1237
|
*/
|
|
2557
1238
|
async updateWorkspaceUser(args, requestId) {
|
|
2558
|
-
|
|
2559
|
-
const response = await (0, http_client_1.request)({
|
|
2560
|
-
httpMethod: 'POST',
|
|
2561
|
-
baseUri: this.syncApiBase,
|
|
2562
|
-
relativePath: (0, endpoints_1.getWorkspaceUserEndpoint)(workspaceId, userId),
|
|
2563
|
-
apiToken: this.authToken,
|
|
2564
|
-
customFetch: this.customFetch,
|
|
2565
|
-
payload: payload,
|
|
2566
|
-
requestId: requestId,
|
|
2567
|
-
});
|
|
2568
|
-
return (0, validators_1.validateJoinWorkspaceResult)(response.data);
|
|
1239
|
+
return this.workspaceClient.updateWorkspaceUser(args, requestId);
|
|
2569
1240
|
}
|
|
2570
1241
|
/**
|
|
2571
1242
|
* Removes a user from a workspace.
|
|
@@ -2575,16 +1246,7 @@ class TodoistApi {
|
|
|
2575
1246
|
* @returns A promise that resolves to `true` if successful.
|
|
2576
1247
|
*/
|
|
2577
1248
|
async removeWorkspaceUser(args, requestId) {
|
|
2578
|
-
|
|
2579
|
-
const response = await (0, http_client_1.request)({
|
|
2580
|
-
httpMethod: 'DELETE',
|
|
2581
|
-
baseUri: this.syncApiBase,
|
|
2582
|
-
relativePath: (0, endpoints_1.getWorkspaceUserEndpoint)(workspaceId, userId),
|
|
2583
|
-
apiToken: this.authToken,
|
|
2584
|
-
customFetch: this.customFetch,
|
|
2585
|
-
requestId: requestId,
|
|
2586
|
-
});
|
|
2587
|
-
return (0, http_client_1.isSuccess)(response);
|
|
1249
|
+
return this.workspaceClient.removeWorkspaceUser(args, requestId);
|
|
2588
1250
|
}
|
|
2589
1251
|
/**
|
|
2590
1252
|
* Gets active projects in a workspace with pagination.
|
|
@@ -2594,28 +1256,7 @@ class TodoistApi {
|
|
|
2594
1256
|
* @returns Paginated list of active workspace projects.
|
|
2595
1257
|
*/
|
|
2596
1258
|
async getWorkspaceActiveProjects(args, requestId) {
|
|
2597
|
-
|
|
2598
|
-
const queryParams = {};
|
|
2599
|
-
if (args.cursor) {
|
|
2600
|
-
queryParams.cursor = args.cursor;
|
|
2601
|
-
}
|
|
2602
|
-
if (args.limit) {
|
|
2603
|
-
queryParams.limit = args.limit;
|
|
2604
|
-
}
|
|
2605
|
-
const response = await (0, http_client_1.request)({
|
|
2606
|
-
httpMethod: 'GET',
|
|
2607
|
-
baseUri: this.syncApiBase,
|
|
2608
|
-
relativePath: (0, endpoints_1.getWorkspaceActiveProjectsEndpoint)(args.workspaceId),
|
|
2609
|
-
apiToken: this.authToken,
|
|
2610
|
-
customFetch: this.customFetch,
|
|
2611
|
-
payload: queryParams,
|
|
2612
|
-
requestId: requestId,
|
|
2613
|
-
});
|
|
2614
|
-
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
2615
|
-
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => (0, validators_1.validateProject)(project));
|
|
2616
|
-
return Object.assign(Object.assign({}, response.data), {
|
|
2617
|
-
// oxlint-disable-next-line no-unsafe-assignment
|
|
2618
|
-
results: validatedProjects || [] });
|
|
1259
|
+
return this.workspaceClient.getWorkspaceActiveProjects(args, requestId);
|
|
2619
1260
|
}
|
|
2620
1261
|
/**
|
|
2621
1262
|
* Gets archived projects in a workspace with pagination.
|
|
@@ -2625,28 +1266,272 @@ class TodoistApi {
|
|
|
2625
1266
|
* @returns Paginated list of archived workspace projects.
|
|
2626
1267
|
*/
|
|
2627
1268
|
async getWorkspaceArchivedProjects(args, requestId) {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
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);
|
|
2650
1535
|
}
|
|
2651
1536
|
}
|
|
2652
1537
|
exports.TodoistApi = TodoistApi;
|