@doist/todoist-api-typescript 4.0.0-alpha.1 → 4.0.0-alpha.3
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/TodoistApi.d.ts +253 -37
- package/dist/TodoistApi.js +319 -25
- package/dist/authentication.d.ts +78 -4
- package/dist/authentication.js +58 -0
- package/dist/consts/endpoints.d.ts +2 -1
- package/dist/consts/endpoints.js +2 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/restClient.d.ts +1 -1
- package/dist/restClient.js +2 -2
- package/dist/testUtils/asserts.d.ts +0 -1
- package/dist/testUtils/asserts.js +1 -65
- package/dist/testUtils/testDefaults.d.ts +2 -2
- package/dist/types/entities.d.ts +477 -178
- package/dist/types/entities.js +107 -88
- package/dist/types/requests.d.ts +170 -24
- package/dist/types/sync.d.ts +21 -0
- package/dist/types/sync.js +2 -0
- package/dist/utils/colors.d.ts +14 -0
- package/dist/utils/colors.js +14 -0
- package/dist/utils/sanitization.d.ts +29 -0
- package/dist/utils/sanitization.js +29 -0
- package/dist/utils/taskConverters.js +1 -1
- package/dist/utils/validators.d.ts +1 -1
- package/dist/utils/validators.js +7 -7
- package/package.json +10 -10
package/dist/TodoistApi.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,11 +48,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
48
|
};
|
|
38
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
50
|
exports.TodoistApi = void 0;
|
|
40
|
-
var runtypes_1 = require("runtypes");
|
|
41
51
|
var restClient_1 = require("./restClient");
|
|
42
52
|
var taskConverters_1 = require("./utils/taskConverters");
|
|
43
53
|
var endpoints_1 = require("./consts/endpoints");
|
|
44
54
|
var validators_1 = require("./utils/validators");
|
|
55
|
+
var zod_1 = require("zod");
|
|
56
|
+
var uuid_1 = require("uuid");
|
|
57
|
+
var types_1 = require("./types");
|
|
58
|
+
var MAX_COMMAND_COUNT = 100;
|
|
45
59
|
/**
|
|
46
60
|
* Joins path segments using `/` separator.
|
|
47
61
|
* @param segments A list of **valid** path segments.
|
|
@@ -54,18 +68,51 @@ function generatePath() {
|
|
|
54
68
|
}
|
|
55
69
|
return segments.join('/');
|
|
56
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A client for interacting with the Todoist Sync API.
|
|
73
|
+
* This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const api = new TodoistApi('your-api-token');
|
|
78
|
+
*
|
|
79
|
+
* // Get all tasks
|
|
80
|
+
* const tasks = await api.getTasks();
|
|
81
|
+
*
|
|
82
|
+
* // Create a new task
|
|
83
|
+
* const newTask = await api.addTask({
|
|
84
|
+
* content: 'My new task',
|
|
85
|
+
* projectId: '12345'
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
57
90
|
var TodoistApi = /** @class */ (function () {
|
|
58
|
-
function TodoistApi(
|
|
91
|
+
function TodoistApi(
|
|
92
|
+
/**
|
|
93
|
+
* Your Todoist API token.
|
|
94
|
+
*/
|
|
95
|
+
authToken,
|
|
96
|
+
/**
|
|
97
|
+
* Optional custom API base URL. If not provided, defaults to Todoist's standard API endpoint
|
|
98
|
+
*/
|
|
99
|
+
baseUrl) {
|
|
59
100
|
this.authToken = authToken;
|
|
60
101
|
this.syncApiBase = (0, endpoints_1.getSyncBaseUri)(baseUrl);
|
|
61
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Retrieves a single active (non-completed) task by its ID.
|
|
105
|
+
*
|
|
106
|
+
* @param id - The unique identifier of the task.
|
|
107
|
+
* @returns A promise that resolves to the requested task.
|
|
108
|
+
*/
|
|
62
109
|
TodoistApi.prototype.getTask = function (id) {
|
|
63
110
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
111
|
var response;
|
|
65
112
|
return __generator(this, function (_a) {
|
|
66
113
|
switch (_a.label) {
|
|
67
114
|
case 0:
|
|
68
|
-
|
|
115
|
+
zod_1.z.string().parse(id);
|
|
69
116
|
return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id), this.authToken)];
|
|
70
117
|
case 1:
|
|
71
118
|
response = _a.sent();
|
|
@@ -74,6 +121,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
74
121
|
});
|
|
75
122
|
});
|
|
76
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves a list of active tasks filtered by specific parameters.
|
|
126
|
+
*
|
|
127
|
+
* @param args - Filter parameters such as project ID, label ID, or due date.
|
|
128
|
+
* @returns A promise that resolves to an array of tasks.
|
|
129
|
+
*/
|
|
77
130
|
TodoistApi.prototype.getTasks = function (args) {
|
|
78
131
|
if (args === void 0) { args = {}; }
|
|
79
132
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -91,6 +144,13 @@ var TodoistApi = /** @class */ (function () {
|
|
|
91
144
|
});
|
|
92
145
|
});
|
|
93
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Creates a new task with the provided parameters.
|
|
149
|
+
*
|
|
150
|
+
* @param args - Task creation parameters such as content, due date, or priority.
|
|
151
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
152
|
+
* @returns A promise that resolves to the created task.
|
|
153
|
+
*/
|
|
94
154
|
TodoistApi.prototype.addTask = function (args, requestId) {
|
|
95
155
|
return __awaiter(this, void 0, void 0, function () {
|
|
96
156
|
var response;
|
|
@@ -104,6 +164,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
104
164
|
});
|
|
105
165
|
});
|
|
106
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Quickly adds a task using natural language processing for due dates.
|
|
169
|
+
*
|
|
170
|
+
* @param args - Quick add task parameters, including content and due date.
|
|
171
|
+
* @returns A promise that resolves to the created task.
|
|
172
|
+
*/
|
|
107
173
|
TodoistApi.prototype.quickAddTask = function (args) {
|
|
108
174
|
return __awaiter(this, void 0, void 0, function () {
|
|
109
175
|
var response, task;
|
|
@@ -118,13 +184,21 @@ var TodoistApi = /** @class */ (function () {
|
|
|
118
184
|
});
|
|
119
185
|
});
|
|
120
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* Updates an existing task by its ID with the provided parameters.
|
|
189
|
+
*
|
|
190
|
+
* @param id - The unique identifier of the task to update.
|
|
191
|
+
* @param args - Update parameters such as content, priority, or due date.
|
|
192
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
193
|
+
* @returns A promise that resolves to the updated task.
|
|
194
|
+
*/
|
|
121
195
|
TodoistApi.prototype.updateTask = function (id, args, requestId) {
|
|
122
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
123
197
|
var response;
|
|
124
198
|
return __generator(this, function (_a) {
|
|
125
199
|
switch (_a.label) {
|
|
126
200
|
case 0:
|
|
127
|
-
|
|
201
|
+
zod_1.z.string().parse(id);
|
|
128
202
|
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id), this.authToken, args, requestId)];
|
|
129
203
|
case 1:
|
|
130
204
|
response = _a.sent();
|
|
@@ -133,13 +207,73 @@ var TodoistApi = /** @class */ (function () {
|
|
|
133
207
|
});
|
|
134
208
|
});
|
|
135
209
|
};
|
|
210
|
+
/**
|
|
211
|
+
* Moves existing tasks by their ID to either a different parent/section/project.
|
|
212
|
+
*
|
|
213
|
+
* @param ids - The unique identifier of the tasks to be moved.
|
|
214
|
+
* @param args - The paramets that should contain only one of projectId, sectionId, or parentId
|
|
215
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
216
|
+
* @returns - A promise that resolves to an array of the updated tasks.
|
|
217
|
+
*/
|
|
218
|
+
TodoistApi.prototype.moveTasks = function (ids, args, requestId) {
|
|
219
|
+
var _a;
|
|
220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
+
var uuid, commands, syncRequest, response, syncTasks, tasks;
|
|
222
|
+
return __generator(this, function (_b) {
|
|
223
|
+
switch (_b.label) {
|
|
224
|
+
case 0:
|
|
225
|
+
if (ids.length > MAX_COMMAND_COUNT) {
|
|
226
|
+
throw new types_1.TodoistRequestError("Maximum number of items is ".concat(MAX_COMMAND_COUNT), 400);
|
|
227
|
+
}
|
|
228
|
+
uuid = (0, uuid_1.v4)();
|
|
229
|
+
commands = ids.map(function (id) { return ({
|
|
230
|
+
type: 'item_move',
|
|
231
|
+
uuid: uuid,
|
|
232
|
+
args: __assign(__assign(__assign({ id: id }, (args.projectId && { project_id: args.projectId })), (args.sectionId && { section_id: args.sectionId })), (args.parentId && { parent_id: args.parentId })),
|
|
233
|
+
}); });
|
|
234
|
+
syncRequest = {
|
|
235
|
+
commands: commands,
|
|
236
|
+
resource_types: ['items'],
|
|
237
|
+
};
|
|
238
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, endpoints_1.ENDPOINT_SYNC, this.authToken, syncRequest, requestId,
|
|
239
|
+
/*hasSyncCommands: */ true)];
|
|
240
|
+
case 1:
|
|
241
|
+
response = _b.sent();
|
|
242
|
+
if (response.data.sync_status) {
|
|
243
|
+
Object.entries(response.data.sync_status).forEach(function (_a) {
|
|
244
|
+
var _ = _a[0], value = _a[1];
|
|
245
|
+
if (value === 'ok')
|
|
246
|
+
return;
|
|
247
|
+
throw new types_1.TodoistRequestError(value.error, value.http_code, value.error_extra);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (!((_a = response.data.items) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
251
|
+
throw new types_1.TodoistRequestError('Tasks not found', 404);
|
|
252
|
+
}
|
|
253
|
+
syncTasks = response.data.items.filter(function (task) { return ids.includes(task.id); });
|
|
254
|
+
if (!syncTasks.length) {
|
|
255
|
+
throw new types_1.TodoistRequestError('Tasks not found', 404);
|
|
256
|
+
}
|
|
257
|
+
tasks = syncTasks.map(taskConverters_1.getTaskFromQuickAddResponse);
|
|
258
|
+
return [2 /*return*/, (0, validators_1.validateTaskArray)(tasks)];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Closes (completes) a task by its ID.
|
|
265
|
+
*
|
|
266
|
+
* @param id - The unique identifier of the task to close.
|
|
267
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
268
|
+
* @returns A promise that resolves to `true` if successful.
|
|
269
|
+
*/
|
|
136
270
|
TodoistApi.prototype.closeTask = function (id, requestId) {
|
|
137
271
|
return __awaiter(this, void 0, void 0, function () {
|
|
138
272
|
var response;
|
|
139
273
|
return __generator(this, function (_a) {
|
|
140
274
|
switch (_a.label) {
|
|
141
275
|
case 0:
|
|
142
|
-
|
|
276
|
+
zod_1.z.string().parse(id);
|
|
143
277
|
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id, endpoints_1.ENDPOINT_REST_TASK_CLOSE), this.authToken, undefined, requestId)];
|
|
144
278
|
case 1:
|
|
145
279
|
response = _a.sent();
|
|
@@ -148,13 +282,20 @@ var TodoistApi = /** @class */ (function () {
|
|
|
148
282
|
});
|
|
149
283
|
});
|
|
150
284
|
};
|
|
285
|
+
/**
|
|
286
|
+
* Reopens a previously closed (completed) task by its ID.
|
|
287
|
+
*
|
|
288
|
+
* @param id - The unique identifier of the task to reopen.
|
|
289
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
290
|
+
* @returns A promise that resolves to `true` if successful.
|
|
291
|
+
*/
|
|
151
292
|
TodoistApi.prototype.reopenTask = function (id, requestId) {
|
|
152
293
|
return __awaiter(this, void 0, void 0, function () {
|
|
153
294
|
var response;
|
|
154
295
|
return __generator(this, function (_a) {
|
|
155
296
|
switch (_a.label) {
|
|
156
297
|
case 0:
|
|
157
|
-
|
|
298
|
+
zod_1.z.string().parse(id);
|
|
158
299
|
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id, endpoints_1.ENDPOINT_REST_TASK_REOPEN), this.authToken, undefined, requestId)];
|
|
159
300
|
case 1:
|
|
160
301
|
response = _a.sent();
|
|
@@ -163,13 +304,20 @@ var TodoistApi = /** @class */ (function () {
|
|
|
163
304
|
});
|
|
164
305
|
});
|
|
165
306
|
};
|
|
307
|
+
/**
|
|
308
|
+
* Deletes a task by its ID.
|
|
309
|
+
*
|
|
310
|
+
* @param id - The unique identifier of the task to delete.
|
|
311
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
312
|
+
* @returns A promise that resolves to `true` if successful.
|
|
313
|
+
*/
|
|
166
314
|
TodoistApi.prototype.deleteTask = function (id, requestId) {
|
|
167
315
|
return __awaiter(this, void 0, void 0, function () {
|
|
168
316
|
var response;
|
|
169
317
|
return __generator(this, function (_a) {
|
|
170
318
|
switch (_a.label) {
|
|
171
319
|
case 0:
|
|
172
|
-
|
|
320
|
+
zod_1.z.string().parse(id);
|
|
173
321
|
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, id), this.authToken, undefined, requestId)];
|
|
174
322
|
case 1:
|
|
175
323
|
response = _a.sent();
|
|
@@ -178,13 +326,19 @@ var TodoistApi = /** @class */ (function () {
|
|
|
178
326
|
});
|
|
179
327
|
});
|
|
180
328
|
};
|
|
329
|
+
/**
|
|
330
|
+
* Retrieves a project by its ID.
|
|
331
|
+
*
|
|
332
|
+
* @param id - The unique identifier of the project.
|
|
333
|
+
* @returns A promise that resolves to the requested project.
|
|
334
|
+
*/
|
|
181
335
|
TodoistApi.prototype.getProject = function (id) {
|
|
182
336
|
return __awaiter(this, void 0, void 0, function () {
|
|
183
337
|
var response;
|
|
184
338
|
return __generator(this, function (_a) {
|
|
185
339
|
switch (_a.label) {
|
|
186
340
|
case 0:
|
|
187
|
-
|
|
341
|
+
zod_1.z.string().parse(id);
|
|
188
342
|
return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id), this.authToken)];
|
|
189
343
|
case 1:
|
|
190
344
|
response = _a.sent();
|
|
@@ -193,6 +347,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
193
347
|
});
|
|
194
348
|
});
|
|
195
349
|
};
|
|
350
|
+
/**
|
|
351
|
+
* Retrieves all projects with optional filters.
|
|
352
|
+
*
|
|
353
|
+
* @param args - Optional filters for retrieving projects.
|
|
354
|
+
* @returns A promise that resolves to an array of projects.
|
|
355
|
+
*/
|
|
196
356
|
TodoistApi.prototype.getProjects = function (args) {
|
|
197
357
|
if (args === void 0) { args = {}; }
|
|
198
358
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -210,6 +370,13 @@ var TodoistApi = /** @class */ (function () {
|
|
|
210
370
|
});
|
|
211
371
|
});
|
|
212
372
|
};
|
|
373
|
+
/**
|
|
374
|
+
* Creates a new project with the provided parameters.
|
|
375
|
+
*
|
|
376
|
+
* @param args - Project creation parameters such as name or color.
|
|
377
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
378
|
+
* @returns A promise that resolves to the created project.
|
|
379
|
+
*/
|
|
213
380
|
TodoistApi.prototype.addProject = function (args, requestId) {
|
|
214
381
|
return __awaiter(this, void 0, void 0, function () {
|
|
215
382
|
var response;
|
|
@@ -223,13 +390,21 @@ var TodoistApi = /** @class */ (function () {
|
|
|
223
390
|
});
|
|
224
391
|
});
|
|
225
392
|
};
|
|
393
|
+
/**
|
|
394
|
+
* Updates an existing project by its ID with the provided parameters.
|
|
395
|
+
*
|
|
396
|
+
* @param id - The unique identifier of the project to update.
|
|
397
|
+
* @param args - Update parameters such as name or color.
|
|
398
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
399
|
+
* @returns A promise that resolves to the updated project.
|
|
400
|
+
*/
|
|
226
401
|
TodoistApi.prototype.updateProject = function (id, args, requestId) {
|
|
227
402
|
return __awaiter(this, void 0, void 0, function () {
|
|
228
403
|
var response;
|
|
229
404
|
return __generator(this, function (_a) {
|
|
230
405
|
switch (_a.label) {
|
|
231
406
|
case 0:
|
|
232
|
-
|
|
407
|
+
zod_1.z.string().parse(id);
|
|
233
408
|
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id), this.authToken, args, requestId)];
|
|
234
409
|
case 1:
|
|
235
410
|
response = _a.sent();
|
|
@@ -238,13 +413,20 @@ var TodoistApi = /** @class */ (function () {
|
|
|
238
413
|
});
|
|
239
414
|
});
|
|
240
415
|
};
|
|
416
|
+
/**
|
|
417
|
+
* Deletes a project by its ID.
|
|
418
|
+
*
|
|
419
|
+
* @param id - The unique identifier of the project to delete.
|
|
420
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
421
|
+
* @returns A promise that resolves to `true` if successful.
|
|
422
|
+
*/
|
|
241
423
|
TodoistApi.prototype.deleteProject = function (id, requestId) {
|
|
242
424
|
return __awaiter(this, void 0, void 0, function () {
|
|
243
425
|
var response;
|
|
244
426
|
return __generator(this, function (_a) {
|
|
245
427
|
switch (_a.label) {
|
|
246
428
|
case 0:
|
|
247
|
-
|
|
429
|
+
zod_1.z.string().parse(id);
|
|
248
430
|
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id), this.authToken, undefined, requestId)];
|
|
249
431
|
case 1:
|
|
250
432
|
response = _a.sent();
|
|
@@ -253,6 +435,13 @@ var TodoistApi = /** @class */ (function () {
|
|
|
253
435
|
});
|
|
254
436
|
});
|
|
255
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Retrieves a list of collaborators for a specific project.
|
|
440
|
+
*
|
|
441
|
+
* @param projectId - The unique identifier of the project.
|
|
442
|
+
* @param args - Optional parameters to filter collaborators.
|
|
443
|
+
* @returns A promise that resolves to an array of collaborators for the project.
|
|
444
|
+
*/
|
|
256
445
|
TodoistApi.prototype.getProjectCollaborators = function (projectId, args) {
|
|
257
446
|
if (args === void 0) { args = {}; }
|
|
258
447
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -260,7 +449,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
260
449
|
return __generator(this, function (_b) {
|
|
261
450
|
switch (_b.label) {
|
|
262
451
|
case 0:
|
|
263
|
-
|
|
452
|
+
zod_1.z.string().parse(projectId);
|
|
264
453
|
return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, projectId, endpoints_1.ENDPOINT_REST_PROJECT_COLLABORATORS), this.authToken, args)];
|
|
265
454
|
case 1:
|
|
266
455
|
_a = (_b.sent()).data, results = _a.results, nextCursor = _a.nextCursor;
|
|
@@ -272,6 +461,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
272
461
|
});
|
|
273
462
|
});
|
|
274
463
|
};
|
|
464
|
+
/**
|
|
465
|
+
* Retrieves all sections within a specific project or matching criteria.
|
|
466
|
+
*
|
|
467
|
+
* @param args - Filter parameters such as project ID.
|
|
468
|
+
* @returns A promise that resolves to an array of sections.
|
|
469
|
+
*/
|
|
275
470
|
TodoistApi.prototype.getSections = function (args) {
|
|
276
471
|
return __awaiter(this, void 0, void 0, function () {
|
|
277
472
|
var _a, results, nextCursor;
|
|
@@ -288,13 +483,19 @@ var TodoistApi = /** @class */ (function () {
|
|
|
288
483
|
});
|
|
289
484
|
});
|
|
290
485
|
};
|
|
486
|
+
/**
|
|
487
|
+
* Retrieves a single section by its ID.
|
|
488
|
+
*
|
|
489
|
+
* @param id - The unique identifier of the section.
|
|
490
|
+
* @returns A promise that resolves to the requested section.
|
|
491
|
+
*/
|
|
291
492
|
TodoistApi.prototype.getSection = function (id) {
|
|
292
493
|
return __awaiter(this, void 0, void 0, function () {
|
|
293
494
|
var response;
|
|
294
495
|
return __generator(this, function (_a) {
|
|
295
496
|
switch (_a.label) {
|
|
296
497
|
case 0:
|
|
297
|
-
|
|
498
|
+
zod_1.z.string().parse(id);
|
|
298
499
|
return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id), this.authToken)];
|
|
299
500
|
case 1:
|
|
300
501
|
response = _a.sent();
|
|
@@ -303,6 +504,13 @@ var TodoistApi = /** @class */ (function () {
|
|
|
303
504
|
});
|
|
304
505
|
});
|
|
305
506
|
};
|
|
507
|
+
/**
|
|
508
|
+
* Creates a new section within a project.
|
|
509
|
+
*
|
|
510
|
+
* @param args - Section creation parameters such as name or project ID.
|
|
511
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
512
|
+
* @returns A promise that resolves to the created section.
|
|
513
|
+
*/
|
|
306
514
|
TodoistApi.prototype.addSection = function (args, requestId) {
|
|
307
515
|
return __awaiter(this, void 0, void 0, function () {
|
|
308
516
|
var response;
|
|
@@ -316,13 +524,21 @@ var TodoistApi = /** @class */ (function () {
|
|
|
316
524
|
});
|
|
317
525
|
});
|
|
318
526
|
};
|
|
527
|
+
/**
|
|
528
|
+
* Updates a section by its ID with the provided parameters.
|
|
529
|
+
*
|
|
530
|
+
* @param id - The unique identifier of the section to update.
|
|
531
|
+
* @param args - Update parameters such as name or project ID.
|
|
532
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
533
|
+
* @returns A promise that resolves to the updated section.
|
|
534
|
+
*/
|
|
319
535
|
TodoistApi.prototype.updateSection = function (id, args, requestId) {
|
|
320
536
|
return __awaiter(this, void 0, void 0, function () {
|
|
321
537
|
var response;
|
|
322
538
|
return __generator(this, function (_a) {
|
|
323
539
|
switch (_a.label) {
|
|
324
540
|
case 0:
|
|
325
|
-
|
|
541
|
+
zod_1.z.string().parse(id);
|
|
326
542
|
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id), this.authToken, args, requestId)];
|
|
327
543
|
case 1:
|
|
328
544
|
response = _a.sent();
|
|
@@ -331,13 +547,20 @@ var TodoistApi = /** @class */ (function () {
|
|
|
331
547
|
});
|
|
332
548
|
});
|
|
333
549
|
};
|
|
550
|
+
/**
|
|
551
|
+
* Deletes a section by its ID.
|
|
552
|
+
*
|
|
553
|
+
* @param id - The unique identifier of the section to delete.
|
|
554
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
555
|
+
* @returns A promise that resolves to `true` if successful.
|
|
556
|
+
*/
|
|
334
557
|
TodoistApi.prototype.deleteSection = function (id, requestId) {
|
|
335
558
|
return __awaiter(this, void 0, void 0, function () {
|
|
336
559
|
var response;
|
|
337
560
|
return __generator(this, function (_a) {
|
|
338
561
|
switch (_a.label) {
|
|
339
562
|
case 0:
|
|
340
|
-
|
|
563
|
+
zod_1.z.string().parse(id);
|
|
341
564
|
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id), this.authToken, undefined, requestId)];
|
|
342
565
|
case 1:
|
|
343
566
|
response = _a.sent();
|
|
@@ -347,7 +570,10 @@ var TodoistApi = /** @class */ (function () {
|
|
|
347
570
|
});
|
|
348
571
|
};
|
|
349
572
|
/**
|
|
350
|
-
*
|
|
573
|
+
* Retrieves a label by its ID.
|
|
574
|
+
*
|
|
575
|
+
* @param id - The unique identifier of the label.
|
|
576
|
+
* @returns A promise that resolves to the requested label.
|
|
351
577
|
*/
|
|
352
578
|
TodoistApi.prototype.getLabel = function (id) {
|
|
353
579
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -355,7 +581,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
355
581
|
return __generator(this, function (_a) {
|
|
356
582
|
switch (_a.label) {
|
|
357
583
|
case 0:
|
|
358
|
-
|
|
584
|
+
zod_1.z.string().parse(id);
|
|
359
585
|
return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_LABELS, id), this.authToken)];
|
|
360
586
|
case 1:
|
|
361
587
|
response = _a.sent();
|
|
@@ -365,7 +591,10 @@ var TodoistApi = /** @class */ (function () {
|
|
|
365
591
|
});
|
|
366
592
|
};
|
|
367
593
|
/**
|
|
368
|
-
*
|
|
594
|
+
* Retrieves all labels.
|
|
595
|
+
*
|
|
596
|
+
* @param args - Optional filter parameters.
|
|
597
|
+
* @returns A promise that resolves to an array of labels.
|
|
369
598
|
*/
|
|
370
599
|
TodoistApi.prototype.getLabels = function (args) {
|
|
371
600
|
if (args === void 0) { args = {}; }
|
|
@@ -385,7 +614,11 @@ var TodoistApi = /** @class */ (function () {
|
|
|
385
614
|
});
|
|
386
615
|
};
|
|
387
616
|
/**
|
|
388
|
-
* Adds a
|
|
617
|
+
* Adds a new label.
|
|
618
|
+
*
|
|
619
|
+
* @param args - Label creation parameters such as name.
|
|
620
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
621
|
+
* @returns A promise that resolves to the created label.
|
|
389
622
|
*/
|
|
390
623
|
TodoistApi.prototype.addLabel = function (args, requestId) {
|
|
391
624
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -401,7 +634,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
401
634
|
});
|
|
402
635
|
};
|
|
403
636
|
/**
|
|
404
|
-
* Updates
|
|
637
|
+
* Updates an existing label by its ID.
|
|
638
|
+
*
|
|
639
|
+
* @param id - The unique identifier of the label to update.
|
|
640
|
+
* @param args - Update parameters such as name or color.
|
|
641
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
642
|
+
* @returns A promise that resolves to the updated label.
|
|
405
643
|
*/
|
|
406
644
|
TodoistApi.prototype.updateLabel = function (id, args, requestId) {
|
|
407
645
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -409,7 +647,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
409
647
|
return __generator(this, function (_a) {
|
|
410
648
|
switch (_a.label) {
|
|
411
649
|
case 0:
|
|
412
|
-
|
|
650
|
+
zod_1.z.string().parse(id);
|
|
413
651
|
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_LABELS, id), this.authToken, args, requestId)];
|
|
414
652
|
case 1:
|
|
415
653
|
response = _a.sent();
|
|
@@ -419,7 +657,11 @@ var TodoistApi = /** @class */ (function () {
|
|
|
419
657
|
});
|
|
420
658
|
};
|
|
421
659
|
/**
|
|
422
|
-
* Deletes a
|
|
660
|
+
* Deletes a label by its ID.
|
|
661
|
+
*
|
|
662
|
+
* @param id - The unique identifier of the label to delete.
|
|
663
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
664
|
+
* @returns A promise that resolves to `true` if successful.
|
|
423
665
|
*/
|
|
424
666
|
TodoistApi.prototype.deleteLabel = function (id, requestId) {
|
|
425
667
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -427,7 +669,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
427
669
|
return __generator(this, function (_a) {
|
|
428
670
|
switch (_a.label) {
|
|
429
671
|
case 0:
|
|
430
|
-
|
|
672
|
+
zod_1.z.string().parse(id);
|
|
431
673
|
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_LABELS, id), this.authToken, undefined, requestId)];
|
|
432
674
|
case 1:
|
|
433
675
|
response = _a.sent();
|
|
@@ -436,6 +678,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
436
678
|
});
|
|
437
679
|
});
|
|
438
680
|
};
|
|
681
|
+
/**
|
|
682
|
+
* Retrieves a list of shared labels.
|
|
683
|
+
*
|
|
684
|
+
* @param args - Optional parameters to filter shared labels.
|
|
685
|
+
* @returns A promise that resolves to an array of shared labels.
|
|
686
|
+
*/
|
|
439
687
|
TodoistApi.prototype.getSharedLabels = function (args) {
|
|
440
688
|
return __awaiter(this, void 0, void 0, function () {
|
|
441
689
|
var _a, results, nextCursor;
|
|
@@ -449,6 +697,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
449
697
|
});
|
|
450
698
|
});
|
|
451
699
|
};
|
|
700
|
+
/**
|
|
701
|
+
* Renames an existing shared label.
|
|
702
|
+
*
|
|
703
|
+
* @param args - Parameters for renaming the shared label, including the current and new name.
|
|
704
|
+
* @returns A promise that resolves to `true` if successful.
|
|
705
|
+
*/
|
|
452
706
|
TodoistApi.prototype.renameSharedLabel = function (args) {
|
|
453
707
|
return __awaiter(this, void 0, void 0, function () {
|
|
454
708
|
var response;
|
|
@@ -462,6 +716,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
462
716
|
});
|
|
463
717
|
});
|
|
464
718
|
};
|
|
719
|
+
/**
|
|
720
|
+
* Removes a shared label.
|
|
721
|
+
*
|
|
722
|
+
* @param args - Parameters for removing the shared label.
|
|
723
|
+
* @returns A promise that resolves to `true` if successful.
|
|
724
|
+
*/
|
|
465
725
|
TodoistApi.prototype.removeSharedLabel = function (args) {
|
|
466
726
|
return __awaiter(this, void 0, void 0, function () {
|
|
467
727
|
var response;
|
|
@@ -475,6 +735,12 @@ var TodoistApi = /** @class */ (function () {
|
|
|
475
735
|
});
|
|
476
736
|
});
|
|
477
737
|
};
|
|
738
|
+
/**
|
|
739
|
+
* Retrieves all comments associated with a task or project.
|
|
740
|
+
*
|
|
741
|
+
* @param args - Parameters for retrieving comments, such as task ID or project ID.
|
|
742
|
+
* @returns A promise that resolves to an array of comments.
|
|
743
|
+
*/
|
|
478
744
|
TodoistApi.prototype.getComments = function (args) {
|
|
479
745
|
return __awaiter(this, void 0, void 0, function () {
|
|
480
746
|
var _a, results, nextCursor;
|
|
@@ -491,13 +757,19 @@ var TodoistApi = /** @class */ (function () {
|
|
|
491
757
|
});
|
|
492
758
|
});
|
|
493
759
|
};
|
|
760
|
+
/**
|
|
761
|
+
* Retrieves a specific comment by its ID.
|
|
762
|
+
*
|
|
763
|
+
* @param id - The unique identifier of the comment to retrieve.
|
|
764
|
+
* @returns A promise that resolves to the requested comment.
|
|
765
|
+
*/
|
|
494
766
|
TodoistApi.prototype.getComment = function (id) {
|
|
495
767
|
return __awaiter(this, void 0, void 0, function () {
|
|
496
768
|
var response;
|
|
497
769
|
return __generator(this, function (_a) {
|
|
498
770
|
switch (_a.label) {
|
|
499
771
|
case 0:
|
|
500
|
-
|
|
772
|
+
zod_1.z.string().parse(id);
|
|
501
773
|
return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, id), this.authToken)];
|
|
502
774
|
case 1:
|
|
503
775
|
response = _a.sent();
|
|
@@ -506,6 +778,13 @@ var TodoistApi = /** @class */ (function () {
|
|
|
506
778
|
});
|
|
507
779
|
});
|
|
508
780
|
};
|
|
781
|
+
/**
|
|
782
|
+
* Adds a comment to a task or project.
|
|
783
|
+
*
|
|
784
|
+
* @param args - Parameters for creating the comment, such as content and the target task or project ID.
|
|
785
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
786
|
+
* @returns A promise that resolves to the created comment.
|
|
787
|
+
*/
|
|
509
788
|
TodoistApi.prototype.addComment = function (args, requestId) {
|
|
510
789
|
return __awaiter(this, void 0, void 0, function () {
|
|
511
790
|
var response;
|
|
@@ -519,13 +798,21 @@ var TodoistApi = /** @class */ (function () {
|
|
|
519
798
|
});
|
|
520
799
|
});
|
|
521
800
|
};
|
|
801
|
+
/**
|
|
802
|
+
* Updates an existing comment by its ID.
|
|
803
|
+
*
|
|
804
|
+
* @param id - The unique identifier of the comment to update.
|
|
805
|
+
* @param args - Update parameters such as new content.
|
|
806
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
807
|
+
* @returns A promise that resolves to the updated comment.
|
|
808
|
+
*/
|
|
522
809
|
TodoistApi.prototype.updateComment = function (id, args, requestId) {
|
|
523
810
|
return __awaiter(this, void 0, void 0, function () {
|
|
524
811
|
var response;
|
|
525
812
|
return __generator(this, function (_a) {
|
|
526
813
|
switch (_a.label) {
|
|
527
814
|
case 0:
|
|
528
|
-
|
|
815
|
+
zod_1.z.string().parse(id);
|
|
529
816
|
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, id), this.authToken, args, requestId)];
|
|
530
817
|
case 1:
|
|
531
818
|
response = _a.sent();
|
|
@@ -534,13 +821,20 @@ var TodoistApi = /** @class */ (function () {
|
|
|
534
821
|
});
|
|
535
822
|
});
|
|
536
823
|
};
|
|
824
|
+
/**
|
|
825
|
+
* Deletes a comment by its ID.
|
|
826
|
+
*
|
|
827
|
+
* @param id - The unique identifier of the comment to delete.
|
|
828
|
+
* @param requestId - Optional unique identifier for idempotency.
|
|
829
|
+
* @returns A promise that resolves to `true` if successful.
|
|
830
|
+
*/
|
|
537
831
|
TodoistApi.prototype.deleteComment = function (id, requestId) {
|
|
538
832
|
return __awaiter(this, void 0, void 0, function () {
|
|
539
833
|
var response;
|
|
540
834
|
return __generator(this, function (_a) {
|
|
541
835
|
switch (_a.label) {
|
|
542
836
|
case 0:
|
|
543
|
-
|
|
837
|
+
zod_1.z.string().parse(id);
|
|
544
838
|
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, id), this.authToken, undefined, requestId)];
|
|
545
839
|
case 1:
|
|
546
840
|
response = _a.sent();
|