@doist/todoist-sdk 9.0.0 → 9.1.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/cjs/clients/activity-client.js +63 -0
  2. package/dist/cjs/clients/backup-client.js +65 -0
  3. package/dist/cjs/clients/base-client.js +30 -0
  4. package/dist/cjs/clients/comment-client.js +92 -0
  5. package/dist/cjs/clients/email-client.js +43 -0
  6. package/dist/cjs/clients/folder-client.js +80 -0
  7. package/dist/cjs/clients/goals-client.js +145 -0
  8. package/dist/cjs/clients/id-mapping-client.js +39 -0
  9. package/dist/cjs/clients/insights-client.js +88 -0
  10. package/dist/cjs/clients/label-client.js +127 -0
  11. package/dist/cjs/clients/productivity-client.js +27 -0
  12. package/dist/cjs/clients/project-client.js +232 -0
  13. package/dist/cjs/clients/reminder-client.js +198 -0
  14. package/dist/cjs/clients/section-client.js +118 -0
  15. package/dist/cjs/clients/task-client.js +255 -0
  16. package/dist/cjs/clients/template-client.js +89 -0
  17. package/dist/cjs/clients/upload-client.js +102 -0
  18. package/dist/cjs/clients/workspace-client.js +367 -0
  19. package/dist/cjs/consts/endpoints.js +6 -1
  20. package/dist/cjs/test-utils/test-defaults.js +25 -1
  21. package/dist/cjs/todoist-api.js +186 -1537
  22. package/dist/cjs/transport/sync-request.js +75 -0
  23. package/dist/cjs/types/goals/index.js +18 -0
  24. package/dist/cjs/types/goals/requests.js +2 -0
  25. package/dist/cjs/types/goals/types.js +56 -0
  26. package/dist/cjs/types/index.js +1 -0
  27. package/dist/cjs/types/sync/commands/goals.js +2 -0
  28. package/dist/cjs/types/sync/commands/index.js +1 -0
  29. package/dist/cjs/types/sync/resource-types.js +1 -0
  30. package/dist/cjs/types/sync/response.js +12 -10
  31. package/dist/cjs/utils/headers.js +16 -0
  32. package/dist/cjs/utils/request-helpers.js +21 -0
  33. package/dist/cjs/utils/validators.js +48 -46
  34. package/dist/esm/clients/activity-client.js +59 -0
  35. package/dist/esm/clients/backup-client.js +61 -0
  36. package/dist/esm/clients/base-client.js +26 -0
  37. package/dist/esm/clients/comment-client.js +88 -0
  38. package/dist/esm/clients/email-client.js +39 -0
  39. package/dist/esm/clients/folder-client.js +76 -0
  40. package/dist/esm/clients/goals-client.js +141 -0
  41. package/dist/esm/clients/id-mapping-client.js +35 -0
  42. package/dist/esm/clients/insights-client.js +84 -0
  43. package/dist/esm/clients/label-client.js +123 -0
  44. package/dist/esm/clients/productivity-client.js +23 -0
  45. package/dist/esm/clients/project-client.js +228 -0
  46. package/dist/esm/clients/reminder-client.js +194 -0
  47. package/dist/esm/clients/section-client.js +114 -0
  48. package/dist/esm/clients/task-client.js +251 -0
  49. package/dist/esm/clients/template-client.js +85 -0
  50. package/dist/esm/clients/upload-client.js +98 -0
  51. package/dist/esm/clients/workspace-client.js +363 -0
  52. package/dist/esm/consts/endpoints.js +5 -0
  53. package/dist/esm/test-utils/test-defaults.js +24 -0
  54. package/dist/esm/todoist-api.js +189 -1540
  55. package/dist/esm/transport/sync-request.js +72 -0
  56. package/dist/esm/types/goals/index.js +2 -0
  57. package/dist/esm/types/goals/requests.js +1 -0
  58. package/dist/esm/types/goals/types.js +53 -0
  59. package/dist/esm/types/index.js +1 -0
  60. package/dist/esm/types/sync/commands/goals.js +1 -0
  61. package/dist/esm/types/sync/commands/index.js +1 -0
  62. package/dist/esm/types/sync/resource-types.js +1 -0
  63. package/dist/esm/types/sync/response.js +2 -0
  64. package/dist/esm/utils/headers.js +13 -0
  65. package/dist/esm/utils/request-helpers.js +17 -0
  66. package/dist/esm/utils/validators.js +2 -0
  67. package/dist/types/clients/activity-client.d.ts +12 -0
  68. package/dist/types/clients/backup-client.d.ts +14 -0
  69. package/dist/types/clients/base-client.d.ts +21 -0
  70. package/dist/types/clients/comment-client.d.ts +15 -0
  71. package/dist/types/clients/email-client.d.ts +13 -0
  72. package/dist/types/clients/folder-client.d.ts +16 -0
  73. package/dist/types/clients/goals-client.d.ts +20 -0
  74. package/dist/types/clients/id-mapping-client.d.ts +13 -0
  75. package/dist/types/clients/insights-client.d.ts +18 -0
  76. package/dist/types/clients/label-client.d.ts +19 -0
  77. package/dist/types/clients/productivity-client.d.ts +12 -0
  78. package/dist/types/clients/project-client.d.ts +26 -0
  79. package/dist/types/clients/reminder-client.d.ts +25 -0
  80. package/dist/types/clients/section-client.d.ts +18 -0
  81. package/dist/types/clients/task-client.d.ts +25 -0
  82. package/dist/types/clients/template-client.d.ts +17 -0
  83. package/dist/types/clients/upload-client.d.ts +17 -0
  84. package/dist/types/clients/workspace-client.d.ts +43 -0
  85. package/dist/types/consts/endpoints.d.ts +5 -0
  86. package/dist/types/test-utils/test-defaults.d.ts +4 -1
  87. package/dist/types/todoist-api.d.ts +48 -17
  88. package/dist/types/transport/sync-request.d.ts +27 -0
  89. package/dist/types/types/goals/index.d.ts +2 -0
  90. package/dist/types/types/goals/requests.d.ts +33 -0
  91. package/dist/types/types/goals/types.d.ts +51 -0
  92. package/dist/types/types/http.d.ts +7 -0
  93. package/dist/types/types/index.d.ts +1 -0
  94. package/dist/types/types/sync/commands/goals.d.ts +33 -0
  95. package/dist/types/types/sync/commands/index.d.ts +9 -0
  96. package/dist/types/types/sync/resource-types.d.ts +1 -1
  97. package/dist/types/types/sync/resources/view-options.d.ts +6 -6
  98. package/dist/types/types/sync/response.d.ts +29 -4
  99. package/dist/types/types/tasks/requests.d.ts +1 -0
  100. package/dist/types/utils/headers.d.ts +7 -0
  101. package/dist/types/utils/request-helpers.d.ts +13 -0
  102. package/dist/types/utils/validators.d.ts +55 -8
  103. package/package.json +1 -1
@@ -1,102 +1,27 @@
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 zod_1 = require("zod");
4
+ const activity_client_1 = require("./clients/activity-client");
5
+ const backup_client_1 = require("./clients/backup-client");
6
+ const comment_client_1 = require("./clients/comment-client");
7
+ const email_client_1 = require("./clients/email-client");
8
+ const folder_client_1 = require("./clients/folder-client");
9
+ const goals_client_1 = require("./clients/goals-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 upload_client_1 = require("./clients/upload-client");
20
+ const workspace_client_1 = require("./clients/workspace-client");
16
21
  const endpoints_1 = require("./consts/endpoints");
17
22
  const http_client_1 = require("./transport/http-client");
18
- const reminders_1 = require("./types/reminders");
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");
23
+ const sync_request_1 = require("./transport/sync-request");
24
24
  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
25
  class TodoistApi {
101
26
  constructor(
102
27
  /**
@@ -114,39 +39,28 @@ class TodoistApi {
114
39
  const opts = options || {};
115
40
  this.syncApiBase = (0, endpoints_1.getSyncBaseUri)(opts.baseUrl);
116
41
  this.customFetch = opts.customFetch;
117
- }
118
- /**
119
- * Makes a request to the Sync API and handles error checking.
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,
42
+ const clientDeps = {
43
+ authToken: this.authToken,
44
+ syncApiBase: this.syncApiBase,
136
45
  customFetch: this.customFetch,
137
- payload: processedRequest,
138
- requestId: requestId,
139
- hasSyncCommands: hasSyncCommands,
140
- });
141
- // Check for sync errors and throw if any are found
142
- if (response.data.syncStatus) {
143
- Object.entries(response.data.syncStatus).forEach(([_, value]) => {
144
- if (value === 'ok')
145
- return;
146
- throw new types_1.TodoistRequestError(value.error, value.httpCode, value.errorExtra);
147
- });
148
- }
149
- return (0, validators_1.parseSyncResponse)(response.data);
46
+ };
47
+ this.taskClient = new task_client_1.TaskClient(clientDeps);
48
+ this.projectClient = new project_client_1.ProjectClient(clientDeps);
49
+ this.sectionClient = new section_client_1.SectionClient(clientDeps);
50
+ this.labelClient = new label_client_1.LabelClient(clientDeps);
51
+ this.commentClient = new comment_client_1.CommentClient(clientDeps);
52
+ this.reminderClient = new reminder_client_1.ReminderClient(clientDeps);
53
+ this.insightsClient = new insights_client_1.InsightsClient(clientDeps);
54
+ this.folderClient = new folder_client_1.FolderClient(clientDeps);
55
+ this.templateClient = new template_client_1.TemplateClient(clientDeps);
56
+ this.uploadClient = new upload_client_1.UploadClient(clientDeps);
57
+ this.backupClient = new backup_client_1.BackupClient(clientDeps);
58
+ this.emailClient = new email_client_1.EmailClient(clientDeps);
59
+ this.idMappingClient = new id_mapping_client_1.IdMappingClient(clientDeps);
60
+ this.activityClient = new activity_client_1.ActivityClient(clientDeps);
61
+ this.productivityClient = new productivity_client_1.ProductivityClient(clientDeps);
62
+ this.workspaceClient = new workspace_client_1.WorkspaceClient(clientDeps);
63
+ this.goalsClient = new goals_client_1.GoalsClient(clientDeps);
150
64
  }
151
65
  /**
152
66
  * Executes a raw Sync API request.
@@ -174,7 +88,11 @@ class TodoistApi {
174
88
  */
175
89
  async sync(syncRequest, requestId) {
176
90
  var _a;
177
- return this.requestSync(syncRequest, requestId, Boolean((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length));
91
+ return (0, sync_request_1.performSyncRequest)({
92
+ authToken: this.authToken,
93
+ syncApiBase: this.syncApiBase,
94
+ customFetch: this.customFetch,
95
+ }, syncRequest, { requestId, hasSyncCommands: Boolean((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length) });
178
96
  }
179
97
  /**
180
98
  * Retrieves information about the authenticated user.
@@ -198,15 +116,7 @@ class TodoistApi {
198
116
  * @returns A promise that resolves to the requested task.
199
117
  */
200
118
  async getTask(id) {
201
- zod_1.z.string().parse(id);
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);
119
+ return this.taskClient.getTask(id);
210
120
  }
211
121
  /**
212
122
  * Retrieves a list of active tasks filtered by specific parameters.
@@ -215,18 +125,7 @@ class TodoistApi {
215
125
  * @returns A promise that resolves to an array of tasks.
216
126
  */
217
127
  async getTasks(args = {}) {
218
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
128
+ return this.taskClient.getTasks(args);
230
129
  }
231
130
  /**
232
131
  * Retrieves tasks filtered by a filter string.
@@ -235,18 +134,7 @@ class TodoistApi {
235
134
  * @returns A promise that resolves to a paginated response of tasks.
236
135
  */
237
136
  async getTasksByFilter(args) {
238
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
137
+ return this.taskClient.getTasksByFilter(args);
250
138
  }
251
139
  /**
252
140
  * Retrieves completed tasks by completion date.
@@ -255,18 +143,7 @@ class TodoistApi {
255
143
  * @returns A promise that resolves to a paginated response of completed tasks.
256
144
  */
257
145
  async getCompletedTasksByCompletionDate(args) {
258
- const { data: { items, nextCursor }, } = await (0, http_client_1.request)({
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
- };
146
+ return this.taskClient.getCompletedTasksByCompletionDate(args);
270
147
  }
271
148
  /**
272
149
  * Retrieves completed tasks by due date.
@@ -275,18 +152,7 @@ class TodoistApi {
275
152
  * @returns A promise that resolves to a paginated response of completed tasks.
276
153
  */
277
154
  async getCompletedTasksByDueDate(args) {
278
- const { data: { items, nextCursor }, } = await (0, http_client_1.request)({
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
- };
155
+ return this.taskClient.getCompletedTasksByDueDate(args);
290
156
  }
291
157
  /**
292
158
  * Searches completed tasks by query string.
@@ -295,18 +161,7 @@ class TodoistApi {
295
161
  * @returns A promise that resolves to a paginated response of completed tasks.
296
162
  */
297
163
  async searchCompletedTasks(args) {
298
- const { data: { items, nextCursor }, } = await (0, http_client_1.request)({
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
- };
164
+ return this.taskClient.searchCompletedTasks(args);
310
165
  }
311
166
  /**
312
167
  * Retrieves all completed tasks with optional filters.
@@ -317,20 +172,7 @@ class TodoistApi {
317
172
  * @returns A promise that resolves to completed tasks with associated project and section data.
318
173
  */
319
174
  async getAllCompletedTasks(args = {}) {
320
- const { since, until } = args, rest = __rest(args, ["since", "until"]);
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
- };
175
+ return this.taskClient.getAllCompletedTasks(args);
334
176
  }
335
177
  /**
336
178
  * Creates a new task with the provided parameters.
@@ -340,18 +182,7 @@ class TodoistApi {
340
182
  * @returns A promise that resolves to the created task.
341
183
  */
342
184
  async addTask(args, requestId) {
343
- // Process content based on isUncompletable flag
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);
185
+ return this.taskClient.addTask(args, requestId);
355
186
  }
356
187
  /**
357
188
  * Quickly adds a task using natural language processing for due dates.
@@ -360,17 +191,7 @@ class TodoistApi {
360
191
  * @returns A promise that resolves to the created task.
361
192
  */
362
193
  async quickAddTask(args) {
363
- // Process text based on isUncompletable flag
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);
194
+ return this.taskClient.quickAddTask(args);
374
195
  }
375
196
  /**
376
197
  * Updates an existing task by its ID with the provided parameters.
@@ -382,25 +203,7 @@ class TodoistApi {
382
203
  * @returns A promise that resolves to the updated task.
383
204
  */
384
205
  async updateTask(id, args, requestId) {
385
- zod_1.z.string().parse(id);
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);
206
+ return this.taskClient.updateTask(id, args, requestId);
404
207
  }
405
208
  /**
406
209
  * Moves existing tasks by their ID to either a different parent/section/project.
@@ -411,28 +214,7 @@ class TodoistApi {
411
214
  * @returns - A promise that resolves to an array of the updated tasks.
412
215
  */
413
216
  async moveTasks(ids, args, requestId) {
414
- var _a;
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);
217
+ return this.taskClient.moveTasks(ids, args, requestId);
436
218
  }
437
219
  /**
438
220
  * Moves a task by its ID to either a different parent/section/project.
@@ -443,17 +225,7 @@ class TodoistApi {
443
225
  * @returns A promise that resolves to the updated task.
444
226
  */
445
227
  async moveTask(id, args, requestId) {
446
- zod_1.z.string().parse(id);
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);
228
+ return this.taskClient.moveTask(id, args, requestId);
457
229
  }
458
230
  /**
459
231
  * Closes (completes) a task by its ID.
@@ -463,16 +235,7 @@ class TodoistApi {
463
235
  * @returns A promise that resolves to `true` if successful.
464
236
  */
465
237
  async closeTask(id, requestId) {
466
- zod_1.z.string().parse(id);
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);
238
+ return this.taskClient.closeTask(id, requestId);
476
239
  }
477
240
  /**
478
241
  * Reopens a previously closed (completed) task by its ID.
@@ -482,16 +245,7 @@ class TodoistApi {
482
245
  * @returns A promise that resolves to `true` if successful.
483
246
  */
484
247
  async reopenTask(id, requestId) {
485
- zod_1.z.string().parse(id);
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);
248
+ return this.taskClient.reopenTask(id, requestId);
495
249
  }
496
250
  /**
497
251
  * Deletes a task by its ID.
@@ -501,16 +255,7 @@ class TodoistApi {
501
255
  * @returns A promise that resolves to `true` if successful.
502
256
  */
503
257
  async deleteTask(id, requestId) {
504
- zod_1.z.string().parse(id);
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);
258
+ return this.taskClient.deleteTask(id, requestId);
514
259
  }
515
260
  /**
516
261
  * Retrieves a project by its ID.
@@ -519,15 +264,7 @@ class TodoistApi {
519
264
  * @returns A promise that resolves to the requested project.
520
265
  */
521
266
  async getProject(id) {
522
- zod_1.z.string().parse(id);
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);
267
+ return this.projectClient.getProject(id);
531
268
  }
532
269
  /**
533
270
  * Retrieves all projects with optional filters.
@@ -536,18 +273,7 @@ class TodoistApi {
536
273
  * @returns A promise that resolves to an array of projects.
537
274
  */
538
275
  async getProjects(args = {}) {
539
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
276
+ return this.projectClient.getProjects(args);
551
277
  }
552
278
  /**
553
279
  * Searches projects by name.
@@ -556,18 +282,7 @@ class TodoistApi {
556
282
  * @returns A promise that resolves to a paginated response of projects.
557
283
  */
558
284
  async searchProjects(args) {
559
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
285
+ return this.projectClient.searchProjects(args);
571
286
  }
572
287
  /**
573
288
  * Retrieves all archived projects with optional filters.
@@ -576,18 +291,7 @@ class TodoistApi {
576
291
  * @returns A promise that resolves to an array of archived projects.
577
292
  */
578
293
  async getArchivedProjects(args = {}) {
579
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
294
+ return this.projectClient.getArchivedProjects(args);
591
295
  }
592
296
  /**
593
297
  * Creates a new project with the provided parameters.
@@ -597,16 +301,7 @@ class TodoistApi {
597
301
  * @returns A promise that resolves to the created project.
598
302
  */
599
303
  async addProject(args, requestId) {
600
- const response = await (0, http_client_1.request)({
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);
304
+ return this.projectClient.addProject(args, requestId);
610
305
  }
611
306
  /**
612
307
  * Updates an existing project by its ID with the provided parameters.
@@ -617,17 +312,7 @@ class TodoistApi {
617
312
  * @returns A promise that resolves to the updated project.
618
313
  */
619
314
  async updateProject(id, args, requestId) {
620
- zod_1.z.string().parse(id);
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);
315
+ return this.projectClient.updateProject(id, args, requestId);
631
316
  }
632
317
  /**
633
318
  * Deletes a project by its ID.
@@ -642,16 +327,7 @@ class TodoistApi {
642
327
  * @returns A promise that resolves to `true` if successful.
643
328
  */
644
329
  async deleteProject(id, requestId) {
645
- zod_1.z.string().parse(id);
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);
330
+ return this.projectClient.deleteProject(id, requestId);
655
331
  }
656
332
  /**
657
333
  * Archives a project by its ID.
@@ -661,16 +337,7 @@ class TodoistApi {
661
337
  * @returns A promise that resolves to the updated project.
662
338
  */
663
339
  async archiveProject(id, requestId) {
664
- zod_1.z.string().parse(id);
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);
340
+ return this.projectClient.archiveProject(id, requestId);
674
341
  }
675
342
  /**
676
343
  * Unarchives a project by its ID.
@@ -680,16 +347,7 @@ class TodoistApi {
680
347
  * @returns A promise that resolves to the updated project.
681
348
  */
682
349
  async unarchiveProject(id, requestId) {
683
- zod_1.z.string().parse(id);
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);
350
+ return this.projectClient.unarchiveProject(id, requestId);
693
351
  }
694
352
  /**
695
353
  * Moves a project to a workspace.
@@ -699,16 +357,7 @@ class TodoistApi {
699
357
  * @returns A promise that resolves to the moved project.
700
358
  */
701
359
  async moveProjectToWorkspace(args, requestId) {
702
- const response = await (0, http_client_1.request)({
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);
360
+ return this.projectClient.moveProjectToWorkspace(args, requestId);
712
361
  }
713
362
  /**
714
363
  * Moves a project to personal.
@@ -718,16 +367,7 @@ class TodoistApi {
718
367
  * @returns A promise that resolves to the moved project.
719
368
  */
720
369
  async moveProjectToPersonal(args, requestId) {
721
- const response = await (0, http_client_1.request)({
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);
370
+ return this.projectClient.moveProjectToPersonal(args, requestId);
731
371
  }
732
372
  /**
733
373
  * Counts the number of archived projects.
@@ -736,15 +376,7 @@ class TodoistApi {
736
376
  * @returns A promise that resolves to the count of archived projects.
737
377
  */
738
378
  async getArchivedProjectsCount(args = {}) {
739
- const { data } = await (0, http_client_1.request)({
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;
379
+ return this.projectClient.getArchivedProjectsCount(args);
748
380
  }
749
381
  /**
750
382
  * Retrieves the role-to-action permission mappings for projects.
@@ -752,14 +384,7 @@ class TodoistApi {
752
384
  * @returns A promise that resolves to the permission mappings.
753
385
  */
754
386
  async getProjectPermissions() {
755
- const { data } = await (0, http_client_1.request)({
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;
387
+ return this.projectClient.getProjectPermissions();
763
388
  }
764
389
  /**
765
390
  * Retrieves full project data including tasks, sections, collaborators, and notes.
@@ -769,23 +394,7 @@ class TodoistApi {
769
394
  * @returns A promise that resolves to the full project data.
770
395
  */
771
396
  async getFullProject(id, args = {}) {
772
- zod_1.z.string().parse(id);
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
- };
397
+ return this.projectClient.getFullProject(id, args);
789
398
  }
790
399
  /**
791
400
  * Joins a workspace project.
@@ -798,25 +407,7 @@ class TodoistApi {
798
407
  * @returns A promise that resolves to the full project data after joining.
799
408
  */
800
409
  async joinProject(id, requestId) {
801
- zod_1.z.string().parse(id);
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
- };
410
+ return this.projectClient.joinProject(id, requestId);
820
411
  }
821
412
  /**
822
413
  * Retrieves a list of collaborators for a specific project.
@@ -826,19 +417,7 @@ class TodoistApi {
826
417
  * @returns A promise that resolves to an array of collaborators for the project.
827
418
  */
828
419
  async getProjectCollaborators(projectId, args = {}) {
829
- zod_1.z.string().parse(projectId);
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
- };
420
+ return this.projectClient.getProjectCollaborators(projectId, args);
842
421
  }
843
422
  // ── Insights ──
844
423
  /**
@@ -849,16 +428,7 @@ class TodoistApi {
849
428
  * @returns A promise that resolves to the project activity stats.
850
429
  */
851
430
  async getProjectActivityStats(projectId, args = {}) {
852
- zod_1.z.string().parse(projectId);
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);
431
+ return this.insightsClient.getProjectActivityStats(projectId, args);
862
432
  }
863
433
  /**
864
434
  * Retrieves the health status of a project.
@@ -867,15 +437,7 @@ class TodoistApi {
867
437
  * @returns A promise that resolves to the project health data.
868
438
  */
869
439
  async getProjectHealth(projectId) {
870
- zod_1.z.string().parse(projectId);
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);
440
+ return this.insightsClient.getProjectHealth(projectId);
879
441
  }
880
442
  /**
881
443
  * Retrieves the health context for a project, including metrics and task details.
@@ -884,15 +446,7 @@ class TodoistApi {
884
446
  * @returns A promise that resolves to the project health context.
885
447
  */
886
448
  async getProjectHealthContext(projectId) {
887
- zod_1.z.string().parse(projectId);
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);
449
+ return this.insightsClient.getProjectHealthContext(projectId);
896
450
  }
897
451
  /**
898
452
  * Retrieves progress information for a project.
@@ -901,15 +455,7 @@ class TodoistApi {
901
455
  * @returns A promise that resolves to the project progress data.
902
456
  */
903
457
  async getProjectProgress(projectId) {
904
- zod_1.z.string().parse(projectId);
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);
458
+ return this.insightsClient.getProjectProgress(projectId);
913
459
  }
914
460
  /**
915
461
  * Retrieves insights for all projects in a workspace.
@@ -919,16 +465,7 @@ class TodoistApi {
919
465
  * @returns A promise that resolves to workspace insights data.
920
466
  */
921
467
  async getWorkspaceInsights(workspaceId, args = {}) {
922
- zod_1.z.string().parse(workspaceId);
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);
468
+ return this.insightsClient.getWorkspaceInsights(workspaceId, args);
932
469
  }
933
470
  /**
934
471
  * Triggers a health analysis for a project.
@@ -938,16 +475,7 @@ class TodoistApi {
938
475
  * @returns A promise that resolves to the updated project health data.
939
476
  */
940
477
  async analyzeProjectHealth(projectId, requestId) {
941
- zod_1.z.string().parse(projectId);
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);
478
+ return this.insightsClient.analyzeProjectHealth(projectId, requestId);
951
479
  }
952
480
  // ── Sections ──
953
481
  /**
@@ -958,18 +486,7 @@ class TodoistApi {
958
486
  * @returns A promise that resolves to an array of sections.
959
487
  */
960
488
  async getSections(args) {
961
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
489
+ return this.sectionClient.getSections(args);
973
490
  }
974
491
  /**
975
492
  * Searches sections by name.
@@ -978,18 +495,7 @@ class TodoistApi {
978
495
  * @returns A promise that resolves to a paginated response of sections.
979
496
  */
980
497
  async searchSections(args) {
981
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
498
+ return this.sectionClient.searchSections(args);
993
499
  }
994
500
  /**
995
501
  * Retrieves a single section by its ID.
@@ -998,15 +504,7 @@ class TodoistApi {
998
504
  * @returns A promise that resolves to the requested section.
999
505
  */
1000
506
  async getSection(id) {
1001
- zod_1.z.string().parse(id);
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);
507
+ return this.sectionClient.getSection(id);
1010
508
  }
1011
509
  /**
1012
510
  * Creates a new section within a project.
@@ -1016,16 +514,7 @@ class TodoistApi {
1016
514
  * @returns A promise that resolves to the created section.
1017
515
  */
1018
516
  async addSection(args, requestId) {
1019
- const response = await (0, http_client_1.request)({
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);
517
+ return this.sectionClient.addSection(args, requestId);
1029
518
  }
1030
519
  /**
1031
520
  * Updates a section by its ID with the provided parameters.
@@ -1036,17 +525,7 @@ class TodoistApi {
1036
525
  * @returns A promise that resolves to the updated section.
1037
526
  */
1038
527
  async updateSection(id, args, requestId) {
1039
- zod_1.z.string().parse(id);
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);
528
+ return this.sectionClient.updateSection(id, args, requestId);
1050
529
  }
1051
530
  /**
1052
531
  * Deletes a section by its ID.
@@ -1056,16 +535,7 @@ class TodoistApi {
1056
535
  * @returns A promise that resolves to `true` if successful.
1057
536
  */
1058
537
  async deleteSection(id, requestId) {
1059
- zod_1.z.string().parse(id);
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);
538
+ return this.sectionClient.deleteSection(id, requestId);
1069
539
  }
1070
540
  /**
1071
541
  * Archives a section by its ID.
@@ -1075,16 +545,7 @@ class TodoistApi {
1075
545
  * @returns A promise that resolves to the updated section.
1076
546
  */
1077
547
  async archiveSection(id, requestId) {
1078
- zod_1.z.string().parse(id);
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);
548
+ return this.sectionClient.archiveSection(id, requestId);
1088
549
  }
1089
550
  /**
1090
551
  * Unarchives a section by its ID.
@@ -1094,16 +555,7 @@ class TodoistApi {
1094
555
  * @returns A promise that resolves to the updated section.
1095
556
  */
1096
557
  async unarchiveSection(id, requestId) {
1097
- zod_1.z.string().parse(id);
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);
558
+ return this.sectionClient.unarchiveSection(id, requestId);
1107
559
  }
1108
560
  /**
1109
561
  * Retrieves a label by its ID.
@@ -1112,15 +564,7 @@ class TodoistApi {
1112
564
  * @returns A promise that resolves to the requested label.
1113
565
  */
1114
566
  async getLabel(id) {
1115
- zod_1.z.string().parse(id);
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);
567
+ return this.labelClient.getLabel(id);
1124
568
  }
1125
569
  /**
1126
570
  * Retrieves all labels.
@@ -1129,18 +573,7 @@ class TodoistApi {
1129
573
  * @returns A promise that resolves to an array of labels.
1130
574
  */
1131
575
  async getLabels(args = {}) {
1132
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
576
+ return this.labelClient.getLabels(args);
1144
577
  }
1145
578
  /**
1146
579
  * Searches labels by name.
@@ -1149,18 +582,7 @@ class TodoistApi {
1149
582
  * @returns A promise that resolves to a paginated response of labels.
1150
583
  */
1151
584
  async searchLabels(args) {
1152
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
585
+ return this.labelClient.searchLabels(args);
1164
586
  }
1165
587
  /**
1166
588
  * Adds a new label.
@@ -1170,16 +592,7 @@ class TodoistApi {
1170
592
  * @returns A promise that resolves to the created label.
1171
593
  */
1172
594
  async addLabel(args, requestId) {
1173
- const response = await (0, http_client_1.request)({
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);
595
+ return this.labelClient.addLabel(args, requestId);
1183
596
  }
1184
597
  /**
1185
598
  * Updates an existing label by its ID.
@@ -1190,17 +603,7 @@ class TodoistApi {
1190
603
  * @returns A promise that resolves to the updated label.
1191
604
  */
1192
605
  async updateLabel(id, args, requestId) {
1193
- zod_1.z.string().parse(id);
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);
606
+ return this.labelClient.updateLabel(id, args, requestId);
1204
607
  }
1205
608
  /**
1206
609
  * Deletes a label by its ID.
@@ -1210,16 +613,7 @@ class TodoistApi {
1210
613
  * @returns A promise that resolves to `true` if successful.
1211
614
  */
1212
615
  async deleteLabel(id, requestId) {
1213
- zod_1.z.string().parse(id);
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);
616
+ return this.labelClient.deleteLabel(id, requestId);
1223
617
  }
1224
618
  /**
1225
619
  * Retrieves a list of shared labels.
@@ -1228,15 +622,7 @@ class TodoistApi {
1228
622
  * @returns A promise that resolves to an array of shared labels.
1229
623
  */
1230
624
  async getSharedLabels(args) {
1231
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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 };
625
+ return this.labelClient.getSharedLabels(args);
1240
626
  }
1241
627
  /**
1242
628
  * Renames an existing shared label.
@@ -1245,15 +631,7 @@ class TodoistApi {
1245
631
  * @returns A promise that resolves to `true` if successful.
1246
632
  */
1247
633
  async renameSharedLabel(args) {
1248
- const response = await (0, http_client_1.request)({
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);
634
+ return this.labelClient.renameSharedLabel(args);
1257
635
  }
1258
636
  /**
1259
637
  * Removes a shared label.
@@ -1262,15 +640,7 @@ class TodoistApi {
1262
640
  * @returns A promise that resolves to `true` if successful.
1263
641
  */
1264
642
  async removeSharedLabel(args) {
1265
- const response = await (0, http_client_1.request)({
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);
643
+ return this.labelClient.removeSharedLabel(args);
1274
644
  }
1275
645
  /**
1276
646
  * Retrieves all comments associated with a task or project.
@@ -1279,18 +649,7 @@ class TodoistApi {
1279
649
  * @returns A promise that resolves to an array of comments.
1280
650
  */
1281
651
  async getComments(args) {
1282
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
652
+ return this.commentClient.getComments(args);
1294
653
  }
1295
654
  /**
1296
655
  * Retrieves a specific comment by its ID.
@@ -1299,15 +658,7 @@ class TodoistApi {
1299
658
  * @returns A promise that resolves to the requested comment.
1300
659
  */
1301
660
  async getComment(id) {
1302
- zod_1.z.string().parse(id);
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);
661
+ return this.commentClient.getComment(id);
1311
662
  }
1312
663
  /**
1313
664
  * Adds a comment to a task or project.
@@ -1317,17 +668,7 @@ class TodoistApi {
1317
668
  * @returns A promise that resolves to the created comment.
1318
669
  */
1319
670
  async addComment(args, requestId) {
1320
- const { uidsToNotify } = args, rest = __rest(args, ["uidsToNotify"]);
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);
671
+ return this.commentClient.addComment(args, requestId);
1331
672
  }
1332
673
  /**
1333
674
  * Updates an existing comment by its ID.
@@ -1338,17 +679,7 @@ class TodoistApi {
1338
679
  * @returns A promise that resolves to the updated comment.
1339
680
  */
1340
681
  async updateComment(id, args, requestId) {
1341
- zod_1.z.string().parse(id);
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);
682
+ return this.commentClient.updateComment(id, args, requestId);
1352
683
  }
1353
684
  /**
1354
685
  * Deletes a comment by its ID.
@@ -1358,16 +689,7 @@ class TodoistApi {
1358
689
  * @returns A promise that resolves to `true` if successful.
1359
690
  */
1360
691
  async deleteComment(id, requestId) {
1361
- zod_1.z.string().parse(id);
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);
692
+ return this.commentClient.deleteComment(id, requestId);
1371
693
  }
1372
694
  /**
1373
695
  * Retrieves a paginated list of time-based reminders.
@@ -1376,18 +698,7 @@ class TodoistApi {
1376
698
  * @returns A promise that resolves to a paginated list of reminders.
1377
699
  */
1378
700
  async getReminders(args = {}) {
1379
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
701
+ return this.reminderClient.getReminders(args);
1391
702
  }
1392
703
  /**
1393
704
  * Retrieves a paginated list of location-based reminders.
@@ -1396,18 +707,7 @@ class TodoistApi {
1396
707
  * @returns A promise that resolves to a paginated list of location reminders.
1397
708
  */
1398
709
  async getLocationReminders(args = {}) {
1399
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
710
+ return this.reminderClient.getLocationReminders(args);
1411
711
  }
1412
712
  /**
1413
713
  * Retrieves a time-based reminder by its ID.
@@ -1416,23 +716,7 @@ class TodoistApi {
1416
716
  * @returns A promise that resolves to the requested reminder.
1417
717
  */
1418
718
  async getReminder(id) {
1419
- reminders_1.ReminderIdSchema.parse(id);
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
- }
719
+ return this.reminderClient.getReminder(id);
1436
720
  }
1437
721
  /**
1438
722
  * Retrieves a location reminder by its ID.
@@ -1441,23 +725,7 @@ class TodoistApi {
1441
725
  * @returns A promise that resolves to the requested reminder.
1442
726
  */
1443
727
  async getLocationReminder(id) {
1444
- reminders_1.ReminderIdSchema.parse(id);
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
- }
728
+ return this.reminderClient.getLocationReminder(id);
1461
729
  }
1462
730
  /**
1463
731
  * Creates a time-based reminder for a task.
@@ -1467,16 +735,7 @@ class TodoistApi {
1467
735
  * @returns A promise that resolves to the created reminder.
1468
736
  */
1469
737
  async addReminder(args, requestId) {
1470
- const response = await (0, http_client_1.request)({
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);
738
+ return this.reminderClient.addReminder(args, requestId);
1480
739
  }
1481
740
  /**
1482
741
  * Creates a location reminder for a task.
@@ -1486,16 +745,7 @@ class TodoistApi {
1486
745
  * @returns A promise that resolves to the created reminder.
1487
746
  */
1488
747
  async addLocationReminder(args, requestId) {
1489
- const response = await (0, http_client_1.request)({
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);
748
+ return this.reminderClient.addLocationReminder(args, requestId);
1499
749
  }
1500
750
  /**
1501
751
  * Updates an existing time-based reminder.
@@ -1506,26 +756,7 @@ class TodoistApi {
1506
756
  * @returns A promise that resolves to the updated reminder.
1507
757
  */
1508
758
  async updateReminder(id, args, requestId) {
1509
- reminders_1.ReminderIdSchema.parse(id);
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
- }
759
+ return this.reminderClient.updateReminder(id, args, requestId);
1529
760
  }
1530
761
  /**
1531
762
  * Updates an existing location reminder.
@@ -1536,26 +767,7 @@ class TodoistApi {
1536
767
  * @returns A promise that resolves to the updated reminder.
1537
768
  */
1538
769
  async updateLocationReminder(id, args, requestId) {
1539
- reminders_1.ReminderIdSchema.parse(id);
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
- }
770
+ return this.reminderClient.updateLocationReminder(id, args, requestId);
1559
771
  }
1560
772
  /**
1561
773
  * Deletes a time-based reminder by its ID.
@@ -1565,24 +777,7 @@ class TodoistApi {
1565
777
  * @returns A promise that resolves to `true` if successful.
1566
778
  */
1567
779
  async deleteReminder(id, requestId) {
1568
- reminders_1.ReminderIdSchema.parse(id);
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
- }
780
+ return this.reminderClient.deleteReminder(id, requestId);
1586
781
  }
1587
782
  /**
1588
783
  * Deletes a location reminder by its ID.
@@ -1592,24 +787,7 @@ class TodoistApi {
1592
787
  * @returns A promise that resolves to `true` if successful.
1593
788
  */
1594
789
  async deleteLocationReminder(id, requestId) {
1595
- reminders_1.ReminderIdSchema.parse(id);
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
- }
790
+ return this.reminderClient.deleteLocationReminder(id, requestId);
1613
791
  }
1614
792
  /**
1615
793
  * Retrieves productivity stats for the authenticated user.
@@ -1617,14 +795,7 @@ class TodoistApi {
1617
795
  * @returns A promise that resolves to the productivity stats.
1618
796
  */
1619
797
  async getProductivityStats() {
1620
- const response = await (0, http_client_1.request)({
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);
798
+ return this.productivityClient.getProductivityStats();
1628
799
  }
1629
800
  /**
1630
801
  * Retrieves activity logs with optional filters.
@@ -1633,37 +804,7 @@ class TodoistApi {
1633
804
  * @returns A promise that resolves to a paginated response of activity events.
1634
805
  */
1635
806
  async getActivityLogs(args = {}) {
1636
- // Convert Date objects to YYYY-MM-DD strings
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
- };
807
+ return this.activityClient.getActivityLogs(args);
1667
808
  }
1668
809
  /**
1669
810
  * Uploads a file and returns attachment metadata.
@@ -1703,21 +844,7 @@ class TodoistApi {
1703
844
  * ```
1704
845
  */
1705
846
  async uploadFile(args, requestId) {
1706
- const additionalFields = {};
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);
847
+ return this.uploadClient.uploadFile(args, requestId);
1721
848
  }
1722
849
  /**
1723
850
  * Deletes an uploaded file by its URL.
@@ -1734,16 +861,7 @@ class TodoistApi {
1734
861
  * ```
1735
862
  */
1736
863
  async deleteUpload(args, requestId) {
1737
- const response = await (0, http_client_1.request)({
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);
864
+ return this.uploadClient.deleteUpload(args, requestId);
1747
865
  }
1748
866
  /**
1749
867
  * Fetches the content of a file attachment from a Todoist comment.
@@ -1770,57 +888,7 @@ class TodoistApi {
1770
888
  * ```
1771
889
  */
1772
890
  async viewAttachment(commentOrUrl) {
1773
- var _a;
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
- };
891
+ return this.uploadClient.viewAttachment(commentOrUrl);
1824
892
  }
1825
893
  // ── Folders ──
1826
894
  /**
@@ -1830,18 +898,7 @@ class TodoistApi {
1830
898
  * @returns A promise that resolves to a paginated response of folders.
1831
899
  */
1832
900
  async getFolders(args) {
1833
- const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
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
- };
901
+ return this.folderClient.getFolders(args);
1845
902
  }
1846
903
  /**
1847
904
  * Retrieves a single folder by its ID.
@@ -1850,15 +907,7 @@ class TodoistApi {
1850
907
  * @returns A promise that resolves to the requested folder.
1851
908
  */
1852
909
  async getFolder(id) {
1853
- zod_1.z.string().parse(id);
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);
910
+ return this.folderClient.getFolder(id);
1862
911
  }
1863
912
  /**
1864
913
  * Creates a new folder.
@@ -1868,16 +917,7 @@ class TodoistApi {
1868
917
  * @returns A promise that resolves to the created folder.
1869
918
  */
1870
919
  async addFolder(args, requestId) {
1871
- const response = await (0, http_client_1.request)({
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);
920
+ return this.folderClient.addFolder(args, requestId);
1881
921
  }
1882
922
  /**
1883
923
  * Updates an existing folder by its ID.
@@ -1888,17 +928,7 @@ class TodoistApi {
1888
928
  * @returns A promise that resolves to the updated folder.
1889
929
  */
1890
930
  async updateFolder(id, args, requestId) {
1891
- zod_1.z.string().parse(id);
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);
931
+ return this.folderClient.updateFolder(id, args, requestId);
1902
932
  }
1903
933
  /**
1904
934
  * Deletes a folder by its ID.
@@ -1908,16 +938,38 @@ class TodoistApi {
1908
938
  * @returns A promise that resolves to `true` if successful.
1909
939
  */
1910
940
  async deleteFolder(id, requestId) {
1911
- zod_1.z.string().parse(id);
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);
941
+ return this.folderClient.deleteFolder(id, requestId);
942
+ }
943
+ // ── Goals ──
944
+ async getGoals(args) {
945
+ return this.goalsClient.getGoals(args);
946
+ }
947
+ async searchGoals(args) {
948
+ return this.goalsClient.searchGoals(args);
949
+ }
950
+ async getGoal(id) {
951
+ return this.goalsClient.getGoal(id);
952
+ }
953
+ async addGoal(args, requestId) {
954
+ return this.goalsClient.addGoal(args, requestId);
955
+ }
956
+ async updateGoal(id, args, requestId) {
957
+ return this.goalsClient.updateGoal(id, args, requestId);
958
+ }
959
+ async deleteGoal(id, requestId) {
960
+ return this.goalsClient.deleteGoal(id, requestId);
961
+ }
962
+ async completeGoal(id, requestId) {
963
+ return this.goalsClient.completeGoal(id, requestId);
964
+ }
965
+ async uncompleteGoal(id, requestId) {
966
+ return this.goalsClient.uncompleteGoal(id, requestId);
967
+ }
968
+ async linkTaskToGoal(args, requestId) {
969
+ return this.goalsClient.linkTaskToGoal(args, requestId);
970
+ }
971
+ async unlinkTaskFromGoal(args, requestId) {
972
+ return this.goalsClient.unlinkTaskFromGoal(args, requestId);
1921
973
  }
1922
974
  // ── Backups ──
1923
975
  /**
@@ -1927,15 +979,7 @@ class TodoistApi {
1927
979
  * @returns A promise that resolves to an array of backups.
1928
980
  */
1929
981
  async getBackups(args = {}) {
1930
- const response = await (0, http_client_1.request)({
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);
982
+ return this.backupClient.getBackups(args);
1939
983
  }
1940
984
  /**
1941
985
  * Downloads a backup file as binary data.
@@ -1944,40 +988,7 @@ class TodoistApi {
1944
988
  * @returns A promise that resolves to a response with binary data accessible via arrayBuffer().
1945
989
  */
1946
990
  async downloadBackup(args) {
1947
- const url = `${this.syncApiBase}${endpoints_1.ENDPOINT_REST_BACKUPS_DOWNLOAD}?file=${encodeURIComponent(args.file)}`;
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
- };
991
+ return this.backupClient.downloadBackup(args);
1981
992
  }
1982
993
  // ── Emails ──
1983
994
  /**
@@ -1988,16 +999,7 @@ class TodoistApi {
1988
999
  * @returns A promise that resolves to the email address.
1989
1000
  */
1990
1001
  async getOrCreateEmailForwarding(args, requestId) {
1991
- const { data } = await (0, http_client_1.request)({
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;
1002
+ return this.emailClient.getOrCreateEmailForwarding(args, requestId);
2001
1003
  }
2002
1004
  /**
2003
1005
  * Disables email forwarding for an object.
@@ -2007,19 +1009,7 @@ class TodoistApi {
2007
1009
  * @returns A promise that resolves to `true` if successful.
2008
1010
  */
2009
1011
  async disableEmailForwarding(args, requestId) {
2010
- const queryParams = new URLSearchParams({
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);
1012
+ return this.emailClient.disableEmailForwarding(args, requestId);
2023
1013
  }
2024
1014
  // ── ID Mappings ──
2025
1015
  /**
@@ -2029,14 +1019,7 @@ class TodoistApi {
2029
1019
  * @returns A promise that resolves to an array of ID mappings.
2030
1020
  */
2031
1021
  async getIdMappings(args) {
2032
- const response = await (0, http_client_1.request)({
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);
1022
+ return this.idMappingClient.getIdMappings(args);
2040
1023
  }
2041
1024
  /**
2042
1025
  * Retrieves moved IDs for objects that have been migrated.
@@ -2045,15 +1028,7 @@ class TodoistApi {
2045
1028
  * @returns A promise that resolves to an array of moved ID pairs.
2046
1029
  */
2047
1030
  async getMovedIds(args) {
2048
- const response = await (0, http_client_1.request)({
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);
1031
+ return this.idMappingClient.getMovedIds(args);
2057
1032
  }
2058
1033
  // ── Templates ──
2059
1034
  /**
@@ -2063,15 +1038,7 @@ class TodoistApi {
2063
1038
  * @returns A promise that resolves to the template file content as a string.
2064
1039
  */
2065
1040
  async exportTemplateAsFile(args) {
2066
- const response = await (0, http_client_1.request)({
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;
1041
+ return this.templateClient.exportTemplateAsFile(args);
2075
1042
  }
2076
1043
  /**
2077
1044
  * Exports a project as a template URL.
@@ -2080,15 +1047,7 @@ class TodoistApi {
2080
1047
  * @returns A promise that resolves to the file name and URL.
2081
1048
  */
2082
1049
  async exportTemplateAsUrl(args) {
2083
- const { data } = await (0, http_client_1.request)({
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;
1050
+ return this.templateClient.exportTemplateAsUrl(args);
2092
1051
  }
2093
1052
  /**
2094
1053
  * Creates a new project from a template file.
@@ -2098,22 +1057,7 @@ class TodoistApi {
2098
1057
  * @returns A promise that resolves to the created project data.
2099
1058
  */
2100
1059
  async createProjectFromTemplate(args, requestId) {
2101
- const { file, fileName, name, workspaceId } = args;
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));
1060
+ return this.templateClient.createProjectFromTemplate(args, requestId);
2117
1061
  }
2118
1062
  /**
2119
1063
  * Imports a template file into an existing project.
@@ -2123,18 +1067,7 @@ class TodoistApi {
2123
1067
  * @returns A promise that resolves to the import result.
2124
1068
  */
2125
1069
  async importTemplateIntoProject(args, requestId) {
2126
- const { file, fileName, projectId } = args;
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));
1070
+ return this.templateClient.importTemplateIntoProject(args, requestId);
2138
1071
  }
2139
1072
  /**
2140
1073
  * Imports a template by ID into an existing project.
@@ -2144,20 +1077,7 @@ class TodoistApi {
2144
1077
  * @returns A promise that resolves to the import result.
2145
1078
  */
2146
1079
  async importTemplateFromId(args, requestId) {
2147
- const { data } = await (0, http_client_1.request)({
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 : []) });
1080
+ return this.templateClient.importTemplateFromId(args, requestId);
2161
1081
  }
2162
1082
  /* Workspace methods */
2163
1083
  /**
@@ -2168,16 +1088,7 @@ class TodoistApi {
2168
1088
  * @returns Array of email addresses with pending invitations.
2169
1089
  */
2170
1090
  async getWorkspaceInvitations(args, requestId) {
2171
- const response = await (0, http_client_1.request)({
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;
1091
+ return this.workspaceClient.getWorkspaceInvitations(args, requestId);
2181
1092
  }
2182
1093
  /**
2183
1094
  * Gets all workspace invitations (admin only).
@@ -2186,20 +1097,7 @@ class TodoistApi {
2186
1097
  * @returns Array of email addresses with pending invitations.
2187
1098
  */
2188
1099
  async getAllWorkspaceInvitations(args = {}, requestId) {
2189
- const queryParams = {};
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);
1100
+ return this.workspaceClient.getAllWorkspaceInvitations(args, requestId);
2203
1101
  }
2204
1102
  /**
2205
1103
  * Deletes a workspace invitation (admin only).
@@ -2209,19 +1107,7 @@ class TodoistApi {
2209
1107
  * @returns The deleted invitation.
2210
1108
  */
2211
1109
  async deleteWorkspaceInvitation(args, requestId) {
2212
- const response = await (0, http_client_1.request)({
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);
1110
+ return this.workspaceClient.deleteWorkspaceInvitation(args, requestId);
2225
1111
  }
2226
1112
  /**
2227
1113
  * Accepts a workspace invitation.
@@ -2231,15 +1117,7 @@ class TodoistApi {
2231
1117
  * @returns The accepted invitation.
2232
1118
  */
2233
1119
  async acceptWorkspaceInvitation(args, requestId) {
2234
- const response = await (0, http_client_1.request)({
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);
1120
+ return this.workspaceClient.acceptWorkspaceInvitation(args, requestId);
2243
1121
  }
2244
1122
  /**
2245
1123
  * Rejects a workspace invitation.
@@ -2249,15 +1127,7 @@ class TodoistApi {
2249
1127
  * @returns The rejected invitation.
2250
1128
  */
2251
1129
  async rejectWorkspaceInvitation(args, requestId) {
2252
- const response = await (0, http_client_1.request)({
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);
1130
+ return this.workspaceClient.rejectWorkspaceInvitation(args, requestId);
2261
1131
  }
2262
1132
  /**
2263
1133
  * Joins a workspace via invitation link or domain auto-join.
@@ -2267,19 +1137,7 @@ class TodoistApi {
2267
1137
  * @returns Workspace user information.
2268
1138
  */
2269
1139
  async joinWorkspace(args, requestId) {
2270
- const response = await (0, http_client_1.request)({
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);
1140
+ return this.workspaceClient.joinWorkspace(args, requestId);
2283
1141
  }
2284
1142
  /**
2285
1143
  * Uploads or updates a workspace logo.
@@ -2289,44 +1147,7 @@ class TodoistApi {
2289
1147
  * @returns Logo information or null if deleted.
2290
1148
  */
2291
1149
  async uploadWorkspaceLogo(args, requestId) {
2292
- if (args.delete) {
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;
1150
+ return this.workspaceClient.uploadWorkspaceLogo(args, requestId);
2330
1151
  }
2331
1152
  /**
2332
1153
  * Gets workspace plan and billing details.
@@ -2336,16 +1157,7 @@ class TodoistApi {
2336
1157
  * @returns Workspace plan details.
2337
1158
  */
2338
1159
  async getWorkspacePlanDetails(args, requestId) {
2339
- const response = await (0, http_client_1.request)({
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);
1160
+ return this.workspaceClient.getWorkspacePlanDetails(args, requestId);
2349
1161
  }
2350
1162
  /**
2351
1163
  * Gets workspace users with pagination.
@@ -2355,30 +1167,7 @@ class TodoistApi {
2355
1167
  * @returns Paginated list of workspace users.
2356
1168
  */
2357
1169
  async getWorkspaceUsers(args = {}, requestId) {
2358
- const queryParams = {};
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
- };
1170
+ return this.workspaceClient.getWorkspaceUsers(args, requestId);
2382
1171
  }
2383
1172
  /**
2384
1173
  * Retrieves all workspaces for the authenticated user.
@@ -2395,15 +1184,7 @@ class TodoistApi {
2395
1184
  * ```
2396
1185
  */
2397
1186
  async getWorkspaces(requestId) {
2398
- const response = await (0, http_client_1.request)({
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);
1187
+ return this.workspaceClient.getWorkspaces(requestId);
2407
1188
  }
2408
1189
  /**
2409
1190
  * Retrieves a workspace by its ID.
@@ -2413,16 +1194,7 @@ class TodoistApi {
2413
1194
  * @returns A promise that resolves to the requested workspace.
2414
1195
  */
2415
1196
  async getWorkspace(id, requestId) {
2416
- zod_1.z.string().parse(id);
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);
1197
+ return this.workspaceClient.getWorkspace(id, requestId);
2426
1198
  }
2427
1199
  /**
2428
1200
  * Creates a new workspace.
@@ -2432,16 +1204,7 @@ class TodoistApi {
2432
1204
  * @returns A promise that resolves to the created workspace.
2433
1205
  */
2434
1206
  async addWorkspace(args, requestId) {
2435
- const response = await (0, http_client_1.request)({
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);
1207
+ return this.workspaceClient.addWorkspace(args, requestId);
2445
1208
  }
2446
1209
  /**
2447
1210
  * Updates an existing workspace.
@@ -2452,17 +1215,7 @@ class TodoistApi {
2452
1215
  * @returns A promise that resolves to the updated workspace.
2453
1216
  */
2454
1217
  async updateWorkspace(id, args, requestId) {
2455
- zod_1.z.string().parse(id);
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);
1218
+ return this.workspaceClient.updateWorkspace(id, args, requestId);
2466
1219
  }
2467
1220
  /**
2468
1221
  * Deletes a workspace by its ID.
@@ -2472,16 +1225,7 @@ class TodoistApi {
2472
1225
  * @returns A promise that resolves to `true` if successful.
2473
1226
  */
2474
1227
  async deleteWorkspace(id, requestId) {
2475
- zod_1.z.string().parse(id);
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);
1228
+ return this.workspaceClient.deleteWorkspace(id, requestId);
2485
1229
  }
2486
1230
  /**
2487
1231
  * Retrieves activity information for workspace members.
@@ -2491,19 +1235,7 @@ class TodoistApi {
2491
1235
  * @returns A promise that resolves to workspace members activity data.
2492
1236
  */
2493
1237
  async getWorkspaceMembersActivity(args, requestId) {
2494
- const { workspaceId } = args, queryParams = __rest(args, ["workspaceId"]);
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
- };
1238
+ return this.workspaceClient.getWorkspaceMembersActivity(args, requestId);
2507
1239
  }
2508
1240
  /**
2509
1241
  * Retrieves tasks assigned to a specific user in a workspace.
@@ -2513,19 +1245,7 @@ class TodoistApi {
2513
1245
  * @returns A promise that resolves to workspace user tasks.
2514
1246
  */
2515
1247
  async getWorkspaceUserTasks(args, requestId) {
2516
- const { workspaceId, userId } = args, queryParams = __rest(args, ["workspaceId", "userId"]);
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
- };
1248
+ return this.workspaceClient.getWorkspaceUserTasks(args, requestId);
2529
1249
  }
2530
1250
  /**
2531
1251
  * Invites users to a workspace by email.
@@ -2535,17 +1255,7 @@ class TodoistApi {
2535
1255
  * @returns A promise that resolves to the list of invited emails.
2536
1256
  */
2537
1257
  async inviteWorkspaceUsers(args, requestId) {
2538
- const { workspaceId } = args, payload = __rest(args, ["workspaceId"]);
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;
1258
+ return this.workspaceClient.inviteWorkspaceUsers(args, requestId);
2549
1259
  }
2550
1260
  /**
2551
1261
  * Updates a workspace user's role.
@@ -2555,17 +1265,7 @@ class TodoistApi {
2555
1265
  * @returns A promise that resolves to the updated workspace user view.
2556
1266
  */
2557
1267
  async updateWorkspaceUser(args, requestId) {
2558
- const { workspaceId, userId } = args, payload = __rest(args, ["workspaceId", "userId"]);
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);
1268
+ return this.workspaceClient.updateWorkspaceUser(args, requestId);
2569
1269
  }
2570
1270
  /**
2571
1271
  * Removes a user from a workspace.
@@ -2575,16 +1275,7 @@ class TodoistApi {
2575
1275
  * @returns A promise that resolves to `true` if successful.
2576
1276
  */
2577
1277
  async removeWorkspaceUser(args, requestId) {
2578
- const { workspaceId, userId } = args;
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);
1278
+ return this.workspaceClient.removeWorkspaceUser(args, requestId);
2588
1279
  }
2589
1280
  /**
2590
1281
  * Gets active projects in a workspace with pagination.
@@ -2594,28 +1285,7 @@ class TodoistApi {
2594
1285
  * @returns Paginated list of active workspace projects.
2595
1286
  */
2596
1287
  async getWorkspaceActiveProjects(args, requestId) {
2597
- var _a;
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 || [] });
1288
+ return this.workspaceClient.getWorkspaceActiveProjects(args, requestId);
2619
1289
  }
2620
1290
  /**
2621
1291
  * Gets archived projects in a workspace with pagination.
@@ -2625,28 +1295,7 @@ class TodoistApi {
2625
1295
  * @returns Paginated list of archived workspace projects.
2626
1296
  */
2627
1297
  async getWorkspaceArchivedProjects(args, requestId) {
2628
- var _a;
2629
- const queryParams = {};
2630
- if (args.cursor) {
2631
- queryParams.cursor = args.cursor;
2632
- }
2633
- if (args.limit) {
2634
- queryParams.limit = args.limit;
2635
- }
2636
- const response = await (0, http_client_1.request)({
2637
- httpMethod: 'GET',
2638
- baseUri: this.syncApiBase,
2639
- relativePath: (0, endpoints_1.getWorkspaceArchivedProjectsEndpoint)(args.workspaceId),
2640
- apiToken: this.authToken,
2641
- customFetch: this.customFetch,
2642
- payload: queryParams,
2643
- requestId: requestId,
2644
- });
2645
- // oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
2646
- const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => (0, validators_1.validateProject)(project));
2647
- return Object.assign(Object.assign({}, response.data), {
2648
- // oxlint-disable-next-line no-unsafe-assignment
2649
- results: validatedProjects || [] });
1298
+ return this.workspaceClient.getWorkspaceArchivedProjects(args, requestId);
2650
1299
  }
2651
1300
  }
2652
1301
  exports.TodoistApi = TodoistApi;