@doist/todoist-api-typescript 7.4.0 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/authentication.js +4 -4
  3. package/dist/cjs/consts/endpoints.js +11 -1
  4. package/dist/cjs/test-utils/test-defaults.js +33 -1
  5. package/dist/cjs/todoist-api.js +528 -84
  6. package/dist/cjs/{utils → transport}/fetch-with-retry.js +23 -71
  7. package/dist/cjs/{rest-client.js → transport/http-client.js} +5 -5
  8. package/dist/cjs/transport/http-dispatcher.js +72 -0
  9. package/dist/cjs/types/entities.js +9 -1
  10. package/dist/cjs/types/errors.js +9 -1
  11. package/dist/cjs/types/http.js +3 -1
  12. package/dist/cjs/types/requests.js +3 -0
  13. package/dist/cjs/types/sync/commands/shared.js +2 -8
  14. package/dist/cjs/types/sync/resources/reminders.js +2 -0
  15. package/dist/cjs/utils/multipart-upload.js +1 -1
  16. package/dist/esm/authentication.js +1 -1
  17. package/dist/esm/consts/endpoints.js +9 -0
  18. package/dist/esm/test-utils/test-defaults.js +32 -0
  19. package/dist/esm/todoist-api.js +461 -17
  20. package/dist/esm/{utils → transport}/fetch-with-retry.js +23 -38
  21. package/dist/esm/{rest-client.js → transport/http-client.js} +5 -5
  22. package/dist/esm/transport/http-dispatcher.js +35 -0
  23. package/dist/esm/types/entities.js +8 -0
  24. package/dist/esm/types/errors.js +7 -0
  25. package/dist/esm/types/http.js +3 -1
  26. package/dist/esm/types/requests.js +2 -1
  27. package/dist/esm/types/sync/commands/shared.js +1 -8
  28. package/dist/esm/types/sync/resources/reminders.js +2 -0
  29. package/dist/esm/utils/multipart-upload.js +1 -1
  30. package/dist/types/consts/endpoints.d.ts +9 -0
  31. package/dist/types/test-utils/test-defaults.d.ts +5 -1
  32. package/dist/types/todoist-api.d.ts +144 -3
  33. package/dist/types/{utils → transport}/fetch-with-retry.d.ts +1 -1
  34. package/dist/types/{rest-client.d.ts → transport/http-client.d.ts} +1 -1
  35. package/dist/types/transport/http-dispatcher.d.ts +3 -0
  36. package/dist/types/types/entities.d.ts +4 -0
  37. package/dist/types/types/errors.d.ts +4 -0
  38. package/dist/types/types/requests.d.ts +163 -1
  39. package/dist/types/types/sync/commands/projects.d.ts +2 -2
  40. package/dist/types/types/sync/commands/shared.d.ts +1 -4
  41. package/dist/types/types/sync/resources/reminders.d.ts +4 -0
  42. package/dist/types/utils/validators.d.ts +4 -0
  43. package/package.json +4 -4
@@ -12,7 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.TodoistApi = void 0;
15
- const rest_client_1 = require("./rest-client");
15
+ const entities_1 = require("./types/entities");
16
+ const reminders_1 = require("./types/sync/resources/reminders");
17
+ const requests_1 = require("./types/requests");
18
+ const http_client_1 = require("./transport/http-client");
16
19
  const endpoints_1 = require("./consts/endpoints");
17
20
  const validators_1 = require("./utils/validators");
18
21
  const url_helpers_1 = require("./utils/url-helpers");
@@ -83,6 +86,56 @@ function headersToRecord(headers) {
83
86
  });
84
87
  return result;
85
88
  }
89
+ const ReminderDeliveryServiceSchema = zod_1.z.enum(requests_1.REMINDER_DELIVERY_SERVICES);
90
+ const ReminderIdSchema = zod_1.z.string();
91
+ const ReminderDueDateSchema = entities_1.DueDateSchema.pick({
92
+ date: true,
93
+ string: true,
94
+ timezone: true,
95
+ lang: true,
96
+ isRecurring: true,
97
+ })
98
+ .partial()
99
+ .strict();
100
+ const UpdateRelativeReminderArgsSchema = zod_1.z
101
+ .object({
102
+ reminderType: zod_1.z.literal('relative'),
103
+ minuteOffset: zod_1.z.number().int().optional(),
104
+ notifyUid: zod_1.z.string().optional(),
105
+ service: ReminderDeliveryServiceSchema.optional(),
106
+ isUrgent: zod_1.z.boolean().optional(),
107
+ })
108
+ .strict();
109
+ const UpdateAbsoluteReminderArgsSchema = zod_1.z
110
+ .object({
111
+ reminderType: zod_1.z.literal('absolute'),
112
+ due: ReminderDueDateSchema.optional(),
113
+ notifyUid: zod_1.z.string().optional(),
114
+ service: ReminderDeliveryServiceSchema.optional(),
115
+ isUrgent: zod_1.z.boolean().optional(),
116
+ })
117
+ .strict();
118
+ const UpdateLocationReminderArgsSchema = zod_1.z
119
+ .object({
120
+ notifyUid: zod_1.z.string().optional(),
121
+ name: zod_1.z.string().optional(),
122
+ locLat: zod_1.z.string().optional(),
123
+ locLong: zod_1.z.string().optional(),
124
+ locTrigger: zod_1.z.enum(reminders_1.LOCATION_TRIGGERS).optional(),
125
+ radius: zod_1.z.number().int().optional(),
126
+ })
127
+ .strict()
128
+ .refine((args) => Object.values(args).some((value) => value !== undefined), {
129
+ message: 'At least one reminder field must be provided to updateLocationReminder',
130
+ });
131
+ const UpdateReminderArgsSchema = zod_1.z
132
+ .discriminatedUnion('reminderType', [
133
+ UpdateRelativeReminderArgsSchema,
134
+ UpdateAbsoluteReminderArgsSchema,
135
+ ])
136
+ .refine((args) => Object.entries(args).some(([key, value]) => key !== 'reminderType' && value !== undefined), {
137
+ message: 'At least one reminder field must be provided to updateReminder',
138
+ });
86
139
  class TodoistApi {
87
140
  constructor(
88
141
  /**
@@ -114,7 +167,7 @@ class TodoistApi {
114
167
  var _a;
115
168
  const processedRequest = ((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length)
116
169
  ? Object.assign(Object.assign({}, syncRequest), { commands: preprocessSyncCommands(syncRequest.commands) }) : syncRequest;
117
- const response = await (0, rest_client_1.request)({
170
+ const response = await (0, http_client_1.request)({
118
171
  httpMethod: 'POST',
119
172
  baseUri: this.syncApiBase,
120
173
  relativePath: endpoints_1.ENDPOINT_SYNC,
@@ -168,7 +221,7 @@ class TodoistApi {
168
221
  * @returns A promise that resolves to the current user's information.
169
222
  */
170
223
  async getUser() {
171
- const response = await (0, rest_client_1.request)({
224
+ const response = await (0, http_client_1.request)({
172
225
  httpMethod: 'GET',
173
226
  baseUri: this.syncApiBase,
174
227
  relativePath: endpoints_1.ENDPOINT_REST_USER,
@@ -185,7 +238,7 @@ class TodoistApi {
185
238
  */
186
239
  async getTask(id) {
187
240
  zod_1.z.string().parse(id);
188
- const response = await (0, rest_client_1.request)({
241
+ const response = await (0, http_client_1.request)({
189
242
  httpMethod: 'GET',
190
243
  baseUri: this.syncApiBase,
191
244
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_TASKS, id),
@@ -201,7 +254,7 @@ class TodoistApi {
201
254
  * @returns A promise that resolves to an array of tasks.
202
255
  */
203
256
  async getTasks(args = {}) {
204
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
257
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
205
258
  httpMethod: 'GET',
206
259
  baseUri: this.syncApiBase,
207
260
  relativePath: endpoints_1.ENDPOINT_REST_TASKS,
@@ -221,7 +274,7 @@ class TodoistApi {
221
274
  * @returns A promise that resolves to a paginated response of tasks.
222
275
  */
223
276
  async getTasksByFilter(args) {
224
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
277
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
225
278
  httpMethod: 'GET',
226
279
  baseUri: this.syncApiBase,
227
280
  relativePath: endpoints_1.ENDPOINT_REST_TASKS_FILTER,
@@ -241,7 +294,7 @@ class TodoistApi {
241
294
  * @returns A promise that resolves to a paginated response of completed tasks.
242
295
  */
243
296
  async getCompletedTasksByCompletionDate(args) {
244
- const { data: { items, nextCursor }, } = await (0, rest_client_1.request)({
297
+ const { data: { items, nextCursor }, } = await (0, http_client_1.request)({
245
298
  httpMethod: 'GET',
246
299
  baseUri: this.syncApiBase,
247
300
  relativePath: endpoints_1.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE,
@@ -261,7 +314,7 @@ class TodoistApi {
261
314
  * @returns A promise that resolves to a paginated response of completed tasks.
262
315
  */
263
316
  async getCompletedTasksByDueDate(args) {
264
- const { data: { items, nextCursor }, } = await (0, rest_client_1.request)({
317
+ const { data: { items, nextCursor }, } = await (0, http_client_1.request)({
265
318
  httpMethod: 'GET',
266
319
  baseUri: this.syncApiBase,
267
320
  relativePath: endpoints_1.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE,
@@ -281,7 +334,7 @@ class TodoistApi {
281
334
  * @returns A promise that resolves to a paginated response of completed tasks.
282
335
  */
283
336
  async searchCompletedTasks(args) {
284
- const { data: { items, nextCursor }, } = await (0, rest_client_1.request)({
337
+ const { data: { items, nextCursor }, } = await (0, http_client_1.request)({
285
338
  httpMethod: 'GET',
286
339
  baseUri: this.syncApiBase,
287
340
  relativePath: endpoints_1.ENDPOINT_REST_TASKS_COMPLETED_SEARCH,
@@ -304,7 +357,7 @@ class TodoistApi {
304
357
  async addTask(args, requestId) {
305
358
  // Process content based on isUncompletable flag
306
359
  const processedArgs = Object.assign(Object.assign({}, args), { content: (0, uncompletable_helpers_1.processTaskContent)(args.content, args.isUncompletable) });
307
- const response = await (0, rest_client_1.request)({
360
+ const response = await (0, http_client_1.request)({
308
361
  httpMethod: 'POST',
309
362
  baseUri: this.syncApiBase,
310
363
  relativePath: endpoints_1.ENDPOINT_REST_TASKS,
@@ -324,7 +377,7 @@ class TodoistApi {
324
377
  async quickAddTask(args) {
325
378
  // Process text based on isUncompletable flag
326
379
  const processedArgs = Object.assign(Object.assign({}, args), { text: (0, uncompletable_helpers_1.processTaskContent)(args.text, args.isUncompletable) });
327
- const response = await (0, rest_client_1.request)({
380
+ const response = await (0, http_client_1.request)({
328
381
  httpMethod: 'POST',
329
382
  baseUri: this.syncApiBase,
330
383
  relativePath: endpoints_1.ENDPOINT_SYNC_QUICK_ADD,
@@ -353,7 +406,7 @@ class TodoistApi {
353
406
  // Remap `order` → `childOrder` so snakeCaseKeys() produces `child_order`
354
407
  const { order } = processedArgs, argsWithoutOrder = __rest(processedArgs, ["order"]);
355
408
  const remappedArgs = order !== undefined ? Object.assign(Object.assign({}, argsWithoutOrder), { childOrder: order }) : argsWithoutOrder;
356
- const response = await (0, rest_client_1.request)({
409
+ const response = await (0, http_client_1.request)({
357
410
  httpMethod: 'POST',
358
411
  baseUri: this.syncApiBase,
359
412
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_TASKS, id),
@@ -406,7 +459,7 @@ class TodoistApi {
406
459
  */
407
460
  async moveTask(id, args, requestId) {
408
461
  zod_1.z.string().parse(id);
409
- const response = await (0, rest_client_1.request)({
462
+ const response = await (0, http_client_1.request)({
410
463
  httpMethod: 'POST',
411
464
  baseUri: this.syncApiBase,
412
465
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_TASKS, id, endpoints_1.ENDPOINT_REST_TASK_MOVE),
@@ -426,7 +479,7 @@ class TodoistApi {
426
479
  */
427
480
  async closeTask(id, requestId) {
428
481
  zod_1.z.string().parse(id);
429
- const response = await (0, rest_client_1.request)({
482
+ const response = await (0, http_client_1.request)({
430
483
  httpMethod: 'POST',
431
484
  baseUri: this.syncApiBase,
432
485
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_TASKS, id, endpoints_1.ENDPOINT_REST_TASK_CLOSE),
@@ -434,7 +487,7 @@ class TodoistApi {
434
487
  customFetch: this.customFetch,
435
488
  requestId: requestId,
436
489
  });
437
- return (0, rest_client_1.isSuccess)(response);
490
+ return (0, http_client_1.isSuccess)(response);
438
491
  }
439
492
  /**
440
493
  * Reopens a previously closed (completed) task by its ID.
@@ -445,7 +498,7 @@ class TodoistApi {
445
498
  */
446
499
  async reopenTask(id, requestId) {
447
500
  zod_1.z.string().parse(id);
448
- const response = await (0, rest_client_1.request)({
501
+ const response = await (0, http_client_1.request)({
449
502
  httpMethod: 'POST',
450
503
  baseUri: this.syncApiBase,
451
504
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_TASKS, id, endpoints_1.ENDPOINT_REST_TASK_REOPEN),
@@ -453,7 +506,7 @@ class TodoistApi {
453
506
  customFetch: this.customFetch,
454
507
  requestId: requestId,
455
508
  });
456
- return (0, rest_client_1.isSuccess)(response);
509
+ return (0, http_client_1.isSuccess)(response);
457
510
  }
458
511
  /**
459
512
  * Deletes a task by its ID.
@@ -464,7 +517,7 @@ class TodoistApi {
464
517
  */
465
518
  async deleteTask(id, requestId) {
466
519
  zod_1.z.string().parse(id);
467
- const response = await (0, rest_client_1.request)({
520
+ const response = await (0, http_client_1.request)({
468
521
  httpMethod: 'DELETE',
469
522
  baseUri: this.syncApiBase,
470
523
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_TASKS, id),
@@ -472,7 +525,7 @@ class TodoistApi {
472
525
  customFetch: this.customFetch,
473
526
  requestId: requestId,
474
527
  });
475
- return (0, rest_client_1.isSuccess)(response);
528
+ return (0, http_client_1.isSuccess)(response);
476
529
  }
477
530
  /**
478
531
  * Retrieves a project by its ID.
@@ -482,7 +535,7 @@ class TodoistApi {
482
535
  */
483
536
  async getProject(id) {
484
537
  zod_1.z.string().parse(id);
485
- const response = await (0, rest_client_1.request)({
538
+ const response = await (0, http_client_1.request)({
486
539
  httpMethod: 'GET',
487
540
  baseUri: this.syncApiBase,
488
541
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id),
@@ -498,7 +551,7 @@ class TodoistApi {
498
551
  * @returns A promise that resolves to an array of projects.
499
552
  */
500
553
  async getProjects(args = {}) {
501
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
554
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
502
555
  httpMethod: 'GET',
503
556
  baseUri: this.syncApiBase,
504
557
  relativePath: endpoints_1.ENDPOINT_REST_PROJECTS,
@@ -518,7 +571,7 @@ class TodoistApi {
518
571
  * @returns A promise that resolves to a paginated response of projects.
519
572
  */
520
573
  async searchProjects(args) {
521
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
574
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
522
575
  httpMethod: 'GET',
523
576
  baseUri: this.syncApiBase,
524
577
  relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_SEARCH,
@@ -538,7 +591,7 @@ class TodoistApi {
538
591
  * @returns A promise that resolves to an array of archived projects.
539
592
  */
540
593
  async getArchivedProjects(args = {}) {
541
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
594
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
542
595
  httpMethod: 'GET',
543
596
  baseUri: this.syncApiBase,
544
597
  relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_ARCHIVED,
@@ -559,7 +612,7 @@ class TodoistApi {
559
612
  * @returns A promise that resolves to the created project.
560
613
  */
561
614
  async addProject(args, requestId) {
562
- const response = await (0, rest_client_1.request)({
615
+ const response = await (0, http_client_1.request)({
563
616
  httpMethod: 'POST',
564
617
  baseUri: this.syncApiBase,
565
618
  relativePath: endpoints_1.ENDPOINT_REST_PROJECTS,
@@ -580,7 +633,7 @@ class TodoistApi {
580
633
  */
581
634
  async updateProject(id, args, requestId) {
582
635
  zod_1.z.string().parse(id);
583
- const response = await (0, rest_client_1.request)({
636
+ const response = await (0, http_client_1.request)({
584
637
  httpMethod: 'POST',
585
638
  baseUri: this.syncApiBase,
586
639
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id),
@@ -600,7 +653,7 @@ class TodoistApi {
600
653
  */
601
654
  async deleteProject(id, requestId) {
602
655
  zod_1.z.string().parse(id);
603
- const response = await (0, rest_client_1.request)({
656
+ const response = await (0, http_client_1.request)({
604
657
  httpMethod: 'DELETE',
605
658
  baseUri: this.syncApiBase,
606
659
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id),
@@ -608,7 +661,7 @@ class TodoistApi {
608
661
  customFetch: this.customFetch,
609
662
  requestId: requestId,
610
663
  });
611
- return (0, rest_client_1.isSuccess)(response);
664
+ return (0, http_client_1.isSuccess)(response);
612
665
  }
613
666
  /**
614
667
  * Archives a project by its ID.
@@ -619,7 +672,7 @@ class TodoistApi {
619
672
  */
620
673
  async archiveProject(id, requestId) {
621
674
  zod_1.z.string().parse(id);
622
- const response = await (0, rest_client_1.request)({
675
+ const response = await (0, http_client_1.request)({
623
676
  httpMethod: 'POST',
624
677
  baseUri: this.syncApiBase,
625
678
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_ARCHIVE),
@@ -638,7 +691,7 @@ class TodoistApi {
638
691
  */
639
692
  async unarchiveProject(id, requestId) {
640
693
  zod_1.z.string().parse(id);
641
- const response = await (0, rest_client_1.request)({
694
+ const response = await (0, http_client_1.request)({
642
695
  httpMethod: 'POST',
643
696
  baseUri: this.syncApiBase,
644
697
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_UNARCHIVE),
@@ -656,7 +709,7 @@ class TodoistApi {
656
709
  * @returns A promise that resolves to the moved project.
657
710
  */
658
711
  async moveProjectToWorkspace(args, requestId) {
659
- const response = await (0, rest_client_1.request)({
712
+ const response = await (0, http_client_1.request)({
660
713
  httpMethod: 'POST',
661
714
  baseUri: this.syncApiBase,
662
715
  relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE,
@@ -675,7 +728,7 @@ class TodoistApi {
675
728
  * @returns A promise that resolves to the moved project.
676
729
  */
677
730
  async moveProjectToPersonal(args, requestId) {
678
- const response = await (0, rest_client_1.request)({
731
+ const response = await (0, http_client_1.request)({
679
732
  httpMethod: 'POST',
680
733
  baseUri: this.syncApiBase,
681
734
  relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL,
@@ -686,6 +739,83 @@ class TodoistApi {
686
739
  });
687
740
  return (0, validators_1.validateProject)(response.data.project);
688
741
  }
742
+ /**
743
+ * Counts the number of archived projects.
744
+ *
745
+ * @param args - Optional parameters to filter the count.
746
+ * @returns A promise that resolves to the count of archived projects.
747
+ */
748
+ async getArchivedProjectsCount(args = {}) {
749
+ const { data } = await (0, http_client_1.request)({
750
+ httpMethod: 'GET',
751
+ baseUri: this.syncApiBase,
752
+ relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT,
753
+ apiToken: this.authToken,
754
+ customFetch: this.customFetch,
755
+ payload: args,
756
+ });
757
+ return data;
758
+ }
759
+ /**
760
+ * Retrieves the role-to-action permission mappings for projects.
761
+ *
762
+ * @returns A promise that resolves to the permission mappings.
763
+ */
764
+ async getProjectPermissions() {
765
+ const { data } = await (0, http_client_1.request)({
766
+ httpMethod: 'GET',
767
+ baseUri: this.syncApiBase,
768
+ relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_PERMISSIONS,
769
+ apiToken: this.authToken,
770
+ customFetch: this.customFetch,
771
+ });
772
+ return data;
773
+ }
774
+ /**
775
+ * Retrieves full project data including tasks, sections, collaborators, and notes.
776
+ *
777
+ * @param id - The unique identifier of the project.
778
+ * @param args - Optional parameters.
779
+ * @returns A promise that resolves to the full project data.
780
+ */
781
+ async getFullProject(id, args = {}) {
782
+ zod_1.z.string().parse(id);
783
+ const { data } = await (0, http_client_1.request)({
784
+ httpMethod: 'GET',
785
+ baseUri: this.syncApiBase,
786
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.ENDPOINT_REST_PROJECT_FULL),
787
+ apiToken: this.authToken,
788
+ customFetch: this.customFetch,
789
+ payload: args,
790
+ });
791
+ return {
792
+ project: data.project ? (0, validators_1.validateProject)(data.project) : null,
793
+ commentsCount: data.commentsCount,
794
+ tasks: (0, validators_1.validateTaskArray)(data.tasks),
795
+ sections: (0, validators_1.validateSectionArray)(data.sections),
796
+ collaborators: (0, validators_1.validateUserArray)(data.collaborators),
797
+ notes: (0, validators_1.validateCommentArray)(data.notes),
798
+ };
799
+ }
800
+ /**
801
+ * Joins a shared project by its ID.
802
+ *
803
+ * @param id - The unique identifier of the project to join.
804
+ * @param requestId - Optional custom identifier for the request.
805
+ * @returns A promise that resolves to the joined project.
806
+ */
807
+ async joinProject(id, requestId) {
808
+ zod_1.z.string().parse(id);
809
+ const response = await (0, http_client_1.request)({
810
+ httpMethod: 'POST',
811
+ baseUri: this.syncApiBase,
812
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.ENDPOINT_REST_PROJECT_JOIN),
813
+ apiToken: this.authToken,
814
+ customFetch: this.customFetch,
815
+ requestId: requestId,
816
+ });
817
+ return (0, validators_1.validateProject)(response.data);
818
+ }
689
819
  /**
690
820
  * Retrieves a list of collaborators for a specific project.
691
821
  *
@@ -695,7 +825,7 @@ class TodoistApi {
695
825
  */
696
826
  async getProjectCollaborators(projectId, args = {}) {
697
827
  zod_1.z.string().parse(projectId);
698
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
828
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
699
829
  httpMethod: 'GET',
700
830
  baseUri: this.syncApiBase,
701
831
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, projectId, endpoints_1.ENDPOINT_REST_PROJECT_COLLABORATORS),
@@ -716,7 +846,7 @@ class TodoistApi {
716
846
  * @returns A promise that resolves to an array of sections.
717
847
  */
718
848
  async getSections(args) {
719
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
849
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
720
850
  httpMethod: 'GET',
721
851
  baseUri: this.syncApiBase,
722
852
  relativePath: endpoints_1.ENDPOINT_REST_SECTIONS,
@@ -736,7 +866,7 @@ class TodoistApi {
736
866
  * @returns A promise that resolves to a paginated response of sections.
737
867
  */
738
868
  async searchSections(args) {
739
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
869
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
740
870
  httpMethod: 'GET',
741
871
  baseUri: this.syncApiBase,
742
872
  relativePath: endpoints_1.ENDPOINT_REST_SECTIONS_SEARCH,
@@ -757,7 +887,7 @@ class TodoistApi {
757
887
  */
758
888
  async getSection(id) {
759
889
  zod_1.z.string().parse(id);
760
- const response = await (0, rest_client_1.request)({
890
+ const response = await (0, http_client_1.request)({
761
891
  httpMethod: 'GET',
762
892
  baseUri: this.syncApiBase,
763
893
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id),
@@ -774,7 +904,7 @@ class TodoistApi {
774
904
  * @returns A promise that resolves to the created section.
775
905
  */
776
906
  async addSection(args, requestId) {
777
- const response = await (0, rest_client_1.request)({
907
+ const response = await (0, http_client_1.request)({
778
908
  httpMethod: 'POST',
779
909
  baseUri: this.syncApiBase,
780
910
  relativePath: endpoints_1.ENDPOINT_REST_SECTIONS,
@@ -795,7 +925,7 @@ class TodoistApi {
795
925
  */
796
926
  async updateSection(id, args, requestId) {
797
927
  zod_1.z.string().parse(id);
798
- const response = await (0, rest_client_1.request)({
928
+ const response = await (0, http_client_1.request)({
799
929
  httpMethod: 'POST',
800
930
  baseUri: this.syncApiBase,
801
931
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id),
@@ -815,7 +945,7 @@ class TodoistApi {
815
945
  */
816
946
  async deleteSection(id, requestId) {
817
947
  zod_1.z.string().parse(id);
818
- const response = await (0, rest_client_1.request)({
948
+ const response = await (0, http_client_1.request)({
819
949
  httpMethod: 'DELETE',
820
950
  baseUri: this.syncApiBase,
821
951
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id),
@@ -823,7 +953,45 @@ class TodoistApi {
823
953
  customFetch: this.customFetch,
824
954
  requestId: requestId,
825
955
  });
826
- return (0, rest_client_1.isSuccess)(response);
956
+ return (0, http_client_1.isSuccess)(response);
957
+ }
958
+ /**
959
+ * Archives a section by its ID.
960
+ *
961
+ * @param id - The unique identifier of the section to archive.
962
+ * @param requestId - Optional custom identifier for the request.
963
+ * @returns A promise that resolves to the updated section.
964
+ */
965
+ async archiveSection(id, requestId) {
966
+ zod_1.z.string().parse(id);
967
+ const response = await (0, http_client_1.request)({
968
+ httpMethod: 'POST',
969
+ baseUri: this.syncApiBase,
970
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id, endpoints_1.SECTION_ARCHIVE),
971
+ apiToken: this.authToken,
972
+ customFetch: this.customFetch,
973
+ requestId: requestId,
974
+ });
975
+ return (0, validators_1.validateSection)(response.data);
976
+ }
977
+ /**
978
+ * Unarchives a section by its ID.
979
+ *
980
+ * @param id - The unique identifier of the section to unarchive.
981
+ * @param requestId - Optional custom identifier for the request.
982
+ * @returns A promise that resolves to the updated section.
983
+ */
984
+ async unarchiveSection(id, requestId) {
985
+ zod_1.z.string().parse(id);
986
+ const response = await (0, http_client_1.request)({
987
+ httpMethod: 'POST',
988
+ baseUri: this.syncApiBase,
989
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, id, endpoints_1.SECTION_UNARCHIVE),
990
+ apiToken: this.authToken,
991
+ customFetch: this.customFetch,
992
+ requestId: requestId,
993
+ });
994
+ return (0, validators_1.validateSection)(response.data);
827
995
  }
828
996
  /**
829
997
  * Retrieves a label by its ID.
@@ -833,7 +1001,7 @@ class TodoistApi {
833
1001
  */
834
1002
  async getLabel(id) {
835
1003
  zod_1.z.string().parse(id);
836
- const response = await (0, rest_client_1.request)({
1004
+ const response = await (0, http_client_1.request)({
837
1005
  httpMethod: 'GET',
838
1006
  baseUri: this.syncApiBase,
839
1007
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_LABELS, id),
@@ -849,7 +1017,7 @@ class TodoistApi {
849
1017
  * @returns A promise that resolves to an array of labels.
850
1018
  */
851
1019
  async getLabels(args = {}) {
852
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
1020
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
853
1021
  httpMethod: 'GET',
854
1022
  baseUri: this.syncApiBase,
855
1023
  relativePath: endpoints_1.ENDPOINT_REST_LABELS,
@@ -869,7 +1037,7 @@ class TodoistApi {
869
1037
  * @returns A promise that resolves to a paginated response of labels.
870
1038
  */
871
1039
  async searchLabels(args) {
872
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
1040
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
873
1041
  httpMethod: 'GET',
874
1042
  baseUri: this.syncApiBase,
875
1043
  relativePath: endpoints_1.ENDPOINT_REST_LABELS_SEARCH,
@@ -890,7 +1058,7 @@ class TodoistApi {
890
1058
  * @returns A promise that resolves to the created label.
891
1059
  */
892
1060
  async addLabel(args, requestId) {
893
- const response = await (0, rest_client_1.request)({
1061
+ const response = await (0, http_client_1.request)({
894
1062
  httpMethod: 'POST',
895
1063
  baseUri: this.syncApiBase,
896
1064
  relativePath: endpoints_1.ENDPOINT_REST_LABELS,
@@ -911,7 +1079,7 @@ class TodoistApi {
911
1079
  */
912
1080
  async updateLabel(id, args, requestId) {
913
1081
  zod_1.z.string().parse(id);
914
- const response = await (0, rest_client_1.request)({
1082
+ const response = await (0, http_client_1.request)({
915
1083
  httpMethod: 'POST',
916
1084
  baseUri: this.syncApiBase,
917
1085
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_LABELS, id),
@@ -931,7 +1099,7 @@ class TodoistApi {
931
1099
  */
932
1100
  async deleteLabel(id, requestId) {
933
1101
  zod_1.z.string().parse(id);
934
- const response = await (0, rest_client_1.request)({
1102
+ const response = await (0, http_client_1.request)({
935
1103
  httpMethod: 'DELETE',
936
1104
  baseUri: this.syncApiBase,
937
1105
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_LABELS, id),
@@ -939,7 +1107,7 @@ class TodoistApi {
939
1107
  customFetch: this.customFetch,
940
1108
  requestId: requestId,
941
1109
  });
942
- return (0, rest_client_1.isSuccess)(response);
1110
+ return (0, http_client_1.isSuccess)(response);
943
1111
  }
944
1112
  /**
945
1113
  * Retrieves a list of shared labels.
@@ -948,7 +1116,7 @@ class TodoistApi {
948
1116
  * @returns A promise that resolves to an array of shared labels.
949
1117
  */
950
1118
  async getSharedLabels(args) {
951
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
1119
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
952
1120
  httpMethod: 'GET',
953
1121
  baseUri: this.syncApiBase,
954
1122
  relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED,
@@ -965,7 +1133,7 @@ class TodoistApi {
965
1133
  * @returns A promise that resolves to `true` if successful.
966
1134
  */
967
1135
  async renameSharedLabel(args) {
968
- const response = await (0, rest_client_1.request)({
1136
+ const response = await (0, http_client_1.request)({
969
1137
  httpMethod: 'POST',
970
1138
  baseUri: this.syncApiBase,
971
1139
  relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED_RENAME,
@@ -973,7 +1141,7 @@ class TodoistApi {
973
1141
  customFetch: this.customFetch,
974
1142
  payload: args,
975
1143
  });
976
- return (0, rest_client_1.isSuccess)(response);
1144
+ return (0, http_client_1.isSuccess)(response);
977
1145
  }
978
1146
  /**
979
1147
  * Removes a shared label.
@@ -982,7 +1150,7 @@ class TodoistApi {
982
1150
  * @returns A promise that resolves to `true` if successful.
983
1151
  */
984
1152
  async removeSharedLabel(args) {
985
- const response = await (0, rest_client_1.request)({
1153
+ const response = await (0, http_client_1.request)({
986
1154
  httpMethod: 'POST',
987
1155
  baseUri: this.syncApiBase,
988
1156
  relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED_REMOVE,
@@ -990,7 +1158,7 @@ class TodoistApi {
990
1158
  customFetch: this.customFetch,
991
1159
  payload: args,
992
1160
  });
993
- return (0, rest_client_1.isSuccess)(response);
1161
+ return (0, http_client_1.isSuccess)(response);
994
1162
  }
995
1163
  /**
996
1164
  * Retrieves all comments associated with a task or project.
@@ -999,7 +1167,7 @@ class TodoistApi {
999
1167
  * @returns A promise that resolves to an array of comments.
1000
1168
  */
1001
1169
  async getComments(args) {
1002
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
1170
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
1003
1171
  httpMethod: 'GET',
1004
1172
  baseUri: this.syncApiBase,
1005
1173
  relativePath: endpoints_1.ENDPOINT_REST_COMMENTS,
@@ -1020,7 +1188,7 @@ class TodoistApi {
1020
1188
  */
1021
1189
  async getComment(id) {
1022
1190
  zod_1.z.string().parse(id);
1023
- const response = await (0, rest_client_1.request)({
1191
+ const response = await (0, http_client_1.request)({
1024
1192
  httpMethod: 'GET',
1025
1193
  baseUri: this.syncApiBase,
1026
1194
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, id),
@@ -1037,7 +1205,7 @@ class TodoistApi {
1037
1205
  * @returns A promise that resolves to the created comment.
1038
1206
  */
1039
1207
  async addComment(args, requestId) {
1040
- const response = await (0, rest_client_1.request)({
1208
+ const response = await (0, http_client_1.request)({
1041
1209
  httpMethod: 'POST',
1042
1210
  baseUri: this.syncApiBase,
1043
1211
  relativePath: endpoints_1.ENDPOINT_REST_COMMENTS,
@@ -1058,7 +1226,7 @@ class TodoistApi {
1058
1226
  */
1059
1227
  async updateComment(id, args, requestId) {
1060
1228
  zod_1.z.string().parse(id);
1061
- const response = await (0, rest_client_1.request)({
1229
+ const response = await (0, http_client_1.request)({
1062
1230
  httpMethod: 'POST',
1063
1231
  baseUri: this.syncApiBase,
1064
1232
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, id),
@@ -1078,7 +1246,7 @@ class TodoistApi {
1078
1246
  */
1079
1247
  async deleteComment(id, requestId) {
1080
1248
  zod_1.z.string().parse(id);
1081
- const response = await (0, rest_client_1.request)({
1249
+ const response = await (0, http_client_1.request)({
1082
1250
  httpMethod: 'DELETE',
1083
1251
  baseUri: this.syncApiBase,
1084
1252
  relativePath: generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, id),
@@ -1086,7 +1254,209 @@ class TodoistApi {
1086
1254
  customFetch: this.customFetch,
1087
1255
  requestId: requestId,
1088
1256
  });
1089
- return (0, rest_client_1.isSuccess)(response);
1257
+ return (0, http_client_1.isSuccess)(response);
1258
+ }
1259
+ /**
1260
+ * Retrieves a time-based reminder by its ID.
1261
+ *
1262
+ * @param id - The unique identifier of the reminder to retrieve.
1263
+ * @returns A promise that resolves to the requested reminder.
1264
+ */
1265
+ async getReminder(id) {
1266
+ ReminderIdSchema.parse(id);
1267
+ try {
1268
+ const response = await (0, http_client_1.request)({
1269
+ httpMethod: 'GET',
1270
+ baseUri: this.syncApiBase,
1271
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_REMINDERS, id),
1272
+ apiToken: this.authToken,
1273
+ customFetch: this.customFetch,
1274
+ });
1275
+ return (0, validators_1.validateReminder)(response.data);
1276
+ }
1277
+ catch (error) {
1278
+ if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
1279
+ throw error;
1280
+ }
1281
+ 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.`);
1282
+ }
1283
+ }
1284
+ /**
1285
+ * Retrieves a location reminder by its ID.
1286
+ *
1287
+ * @param id - The unique identifier of the location reminder to retrieve.
1288
+ * @returns A promise that resolves to the requested reminder.
1289
+ */
1290
+ async getLocationReminder(id) {
1291
+ ReminderIdSchema.parse(id);
1292
+ try {
1293
+ const response = await (0, http_client_1.request)({
1294
+ httpMethod: 'GET',
1295
+ baseUri: this.syncApiBase,
1296
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS, id),
1297
+ apiToken: this.authToken,
1298
+ customFetch: this.customFetch,
1299
+ });
1300
+ return (0, validators_1.validateReminder)(response.data);
1301
+ }
1302
+ catch (error) {
1303
+ if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
1304
+ throw error;
1305
+ }
1306
+ 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.`);
1307
+ }
1308
+ }
1309
+ /**
1310
+ * Creates a time-based reminder for a task.
1311
+ *
1312
+ * @param args - Reminder creation parameters for relative or absolute reminders.
1313
+ * @param requestId - Optional custom identifier for the request.
1314
+ * @returns A promise that resolves to the created reminder.
1315
+ */
1316
+ async addReminder(args, requestId) {
1317
+ const response = await (0, http_client_1.request)({
1318
+ httpMethod: 'POST',
1319
+ baseUri: this.syncApiBase,
1320
+ relativePath: endpoints_1.ENDPOINT_REST_REMINDERS,
1321
+ apiToken: this.authToken,
1322
+ customFetch: this.customFetch,
1323
+ payload: args,
1324
+ requestId: requestId,
1325
+ });
1326
+ return (0, validators_1.validateReminder)(response.data);
1327
+ }
1328
+ /**
1329
+ * Creates a location reminder for a task.
1330
+ *
1331
+ * @param args - Location reminder creation parameters.
1332
+ * @param requestId - Optional custom identifier for the request.
1333
+ * @returns A promise that resolves to the created reminder.
1334
+ */
1335
+ async addLocationReminder(args, requestId) {
1336
+ const response = await (0, http_client_1.request)({
1337
+ httpMethod: 'POST',
1338
+ baseUri: this.syncApiBase,
1339
+ relativePath: endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS,
1340
+ apiToken: this.authToken,
1341
+ customFetch: this.customFetch,
1342
+ payload: Object.assign(Object.assign({}, args), { reminderType: 'location' }),
1343
+ requestId: requestId,
1344
+ });
1345
+ return (0, validators_1.validateReminder)(response.data);
1346
+ }
1347
+ /**
1348
+ * Updates an existing time-based reminder.
1349
+ *
1350
+ * @param id - The unique identifier of the reminder to update.
1351
+ * @param args - Reminder update parameters.
1352
+ * @param requestId - Optional custom identifier for the request.
1353
+ * @returns A promise that resolves to the updated reminder.
1354
+ */
1355
+ async updateReminder(id, args, requestId) {
1356
+ ReminderIdSchema.parse(id);
1357
+ const payload = UpdateReminderArgsSchema.parse(args);
1358
+ try {
1359
+ const response = await (0, http_client_1.request)({
1360
+ httpMethod: 'POST',
1361
+ baseUri: this.syncApiBase,
1362
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_REMINDERS, id),
1363
+ apiToken: this.authToken,
1364
+ customFetch: this.customFetch,
1365
+ payload,
1366
+ requestId: requestId,
1367
+ });
1368
+ return (0, validators_1.validateReminder)(response.data);
1369
+ }
1370
+ catch (error) {
1371
+ if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
1372
+ throw error;
1373
+ }
1374
+ 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.`);
1375
+ }
1376
+ }
1377
+ /**
1378
+ * Updates an existing location reminder.
1379
+ *
1380
+ * @param id - The unique identifier of the location reminder to update.
1381
+ * @param args - Location reminder update parameters.
1382
+ * @param requestId - Optional custom identifier for the request.
1383
+ * @returns A promise that resolves to the updated reminder.
1384
+ */
1385
+ async updateLocationReminder(id, args, requestId) {
1386
+ ReminderIdSchema.parse(id);
1387
+ const payload = UpdateLocationReminderArgsSchema.parse(args);
1388
+ try {
1389
+ const response = await (0, http_client_1.request)({
1390
+ httpMethod: 'POST',
1391
+ baseUri: this.syncApiBase,
1392
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS, id),
1393
+ apiToken: this.authToken,
1394
+ customFetch: this.customFetch,
1395
+ payload,
1396
+ requestId: requestId,
1397
+ });
1398
+ return (0, validators_1.validateReminder)(response.data);
1399
+ }
1400
+ catch (error) {
1401
+ if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
1402
+ throw error;
1403
+ }
1404
+ 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.`);
1405
+ }
1406
+ }
1407
+ /**
1408
+ * Deletes a time-based reminder by its ID.
1409
+ *
1410
+ * @param id - The unique identifier of the reminder to delete.
1411
+ * @param requestId - Optional custom identifier for the request.
1412
+ * @returns A promise that resolves to `true` if successful.
1413
+ */
1414
+ async deleteReminder(id, requestId) {
1415
+ ReminderIdSchema.parse(id);
1416
+ try {
1417
+ const response = await (0, http_client_1.request)({
1418
+ httpMethod: 'DELETE',
1419
+ baseUri: this.syncApiBase,
1420
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_REMINDERS, id),
1421
+ apiToken: this.authToken,
1422
+ customFetch: this.customFetch,
1423
+ requestId: requestId,
1424
+ });
1425
+ return (0, http_client_1.isSuccess)(response);
1426
+ }
1427
+ catch (error) {
1428
+ if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
1429
+ throw error;
1430
+ }
1431
+ 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.`);
1432
+ }
1433
+ }
1434
+ /**
1435
+ * Deletes a location reminder by its ID.
1436
+ *
1437
+ * @param id - The unique identifier of the location reminder to delete.
1438
+ * @param requestId - Optional custom identifier for the request.
1439
+ * @returns A promise that resolves to `true` if successful.
1440
+ */
1441
+ async deleteLocationReminder(id, requestId) {
1442
+ ReminderIdSchema.parse(id);
1443
+ try {
1444
+ const response = await (0, http_client_1.request)({
1445
+ httpMethod: 'DELETE',
1446
+ baseUri: this.syncApiBase,
1447
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS, id),
1448
+ apiToken: this.authToken,
1449
+ customFetch: this.customFetch,
1450
+ requestId: requestId,
1451
+ });
1452
+ return (0, http_client_1.isSuccess)(response);
1453
+ }
1454
+ catch (error) {
1455
+ if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
1456
+ throw error;
1457
+ }
1458
+ 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.`);
1459
+ }
1090
1460
  }
1091
1461
  /**
1092
1462
  * Retrieves productivity stats for the authenticated user.
@@ -1094,7 +1464,7 @@ class TodoistApi {
1094
1464
  * @returns A promise that resolves to the productivity stats.
1095
1465
  */
1096
1466
  async getProductivityStats() {
1097
- const response = await (0, rest_client_1.request)({
1467
+ const response = await (0, http_client_1.request)({
1098
1468
  httpMethod: 'GET',
1099
1469
  baseUri: this.syncApiBase,
1100
1470
  relativePath: endpoints_1.ENDPOINT_REST_PRODUCTIVITY,
@@ -1124,7 +1494,7 @@ class TodoistApi {
1124
1494
  const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
1125
1495
  ? { objectEventTypes: normalizedObjectEventTypes }
1126
1496
  : {}));
1127
- const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
1497
+ const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
1128
1498
  httpMethod: 'GET',
1129
1499
  baseUri: this.syncApiBase,
1130
1500
  relativePath: endpoints_1.ENDPOINT_REST_ACTIVITIES,
@@ -1211,7 +1581,7 @@ class TodoistApi {
1211
1581
  * ```
1212
1582
  */
1213
1583
  async deleteUpload(args, requestId) {
1214
- const response = await (0, rest_client_1.request)({
1584
+ const response = await (0, http_client_1.request)({
1215
1585
  httpMethod: 'DELETE',
1216
1586
  baseUri: this.syncApiBase,
1217
1587
  relativePath: endpoints_1.ENDPOINT_REST_UPLOADS,
@@ -1220,7 +1590,7 @@ class TodoistApi {
1220
1590
  payload: args,
1221
1591
  requestId: requestId,
1222
1592
  });
1223
- return (0, rest_client_1.isSuccess)(response);
1593
+ return (0, http_client_1.isSuccess)(response);
1224
1594
  }
1225
1595
  /**
1226
1596
  * Fetches the content of a file attachment from a Todoist comment.
@@ -1308,7 +1678,7 @@ class TodoistApi {
1308
1678
  * @returns Array of email addresses with pending invitations.
1309
1679
  */
1310
1680
  async getWorkspaceInvitations(args, requestId) {
1311
- const response = await (0, rest_client_1.request)({
1681
+ const response = await (0, http_client_1.request)({
1312
1682
  httpMethod: 'GET',
1313
1683
  baseUri: this.syncApiBase,
1314
1684
  relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS,
@@ -1330,7 +1700,7 @@ class TodoistApi {
1330
1700
  if (args.workspaceId) {
1331
1701
  queryParams.workspace_id = args.workspaceId;
1332
1702
  }
1333
- const response = await (0, rest_client_1.request)({
1703
+ const response = await (0, http_client_1.request)({
1334
1704
  httpMethod: 'GET',
1335
1705
  baseUri: this.syncApiBase,
1336
1706
  relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_ALL,
@@ -1349,7 +1719,7 @@ class TodoistApi {
1349
1719
  * @returns The deleted invitation.
1350
1720
  */
1351
1721
  async deleteWorkspaceInvitation(args, requestId) {
1352
- const response = await (0, rest_client_1.request)({
1722
+ const response = await (0, http_client_1.request)({
1353
1723
  httpMethod: 'POST',
1354
1724
  baseUri: this.syncApiBase,
1355
1725
  relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
@@ -1371,7 +1741,7 @@ class TodoistApi {
1371
1741
  * @returns The accepted invitation.
1372
1742
  */
1373
1743
  async acceptWorkspaceInvitation(args, requestId) {
1374
- const response = await (0, rest_client_1.request)({
1744
+ const response = await (0, http_client_1.request)({
1375
1745
  httpMethod: 'PUT',
1376
1746
  baseUri: this.syncApiBase,
1377
1747
  relativePath: (0, endpoints_1.getWorkspaceInvitationAcceptEndpoint)(args.inviteCode),
@@ -1389,7 +1759,7 @@ class TodoistApi {
1389
1759
  * @returns The rejected invitation.
1390
1760
  */
1391
1761
  async rejectWorkspaceInvitation(args, requestId) {
1392
- const response = await (0, rest_client_1.request)({
1762
+ const response = await (0, http_client_1.request)({
1393
1763
  httpMethod: 'PUT',
1394
1764
  baseUri: this.syncApiBase,
1395
1765
  relativePath: (0, endpoints_1.getWorkspaceInvitationRejectEndpoint)(args.inviteCode),
@@ -1407,7 +1777,7 @@ class TodoistApi {
1407
1777
  * @returns Workspace user information.
1408
1778
  */
1409
1779
  async joinWorkspace(args, requestId) {
1410
- const response = await (0, rest_client_1.request)({
1780
+ const response = await (0, http_client_1.request)({
1411
1781
  httpMethod: 'POST',
1412
1782
  baseUri: this.syncApiBase,
1413
1783
  relativePath: endpoints_1.ENDPOINT_WORKSPACE_JOIN,
@@ -1476,7 +1846,7 @@ class TodoistApi {
1476
1846
  * @returns Workspace plan details.
1477
1847
  */
1478
1848
  async getWorkspacePlanDetails(args, requestId) {
1479
- const response = await (0, rest_client_1.request)({
1849
+ const response = await (0, http_client_1.request)({
1480
1850
  httpMethod: 'GET',
1481
1851
  baseUri: this.syncApiBase,
1482
1852
  relativePath: endpoints_1.ENDPOINT_WORKSPACE_PLAN_DETAILS,
@@ -1505,7 +1875,7 @@ class TodoistApi {
1505
1875
  if (args.limit) {
1506
1876
  queryParams.limit = args.limit;
1507
1877
  }
1508
- const response = await (0, rest_client_1.request)({
1878
+ const response = await (0, http_client_1.request)({
1509
1879
  httpMethod: 'GET',
1510
1880
  baseUri: this.syncApiBase,
1511
1881
  relativePath: endpoints_1.ENDPOINT_WORKSPACE_USERS,
@@ -1523,8 +1893,6 @@ class TodoistApi {
1523
1893
  /**
1524
1894
  * Retrieves all workspaces for the authenticated user.
1525
1895
  *
1526
- * Uses the Sync API internally to fetch workspace data.
1527
- *
1528
1896
  * @param requestId - Optional custom identifier for the request.
1529
1897
  * @returns A promise that resolves to an array of workspaces.
1530
1898
  *
@@ -1537,17 +1905,93 @@ class TodoistApi {
1537
1905
  * ```
1538
1906
  */
1539
1907
  async getWorkspaces(requestId) {
1540
- const syncRequest = {
1541
- syncToken: '*',
1542
- resourceTypes: ['workspaces'],
1543
- };
1544
- const syncResponse = await this.requestSync(syncRequest, requestId, false);
1545
- const workspacesData = syncResponse.workspaces;
1546
- if (!workspacesData || typeof workspacesData !== 'object') {
1547
- return [];
1548
- }
1549
- const workspacesArray = Object.values(workspacesData);
1550
- return (0, validators_1.validateWorkspaceArray)(workspacesArray);
1908
+ const response = await (0, http_client_1.request)({
1909
+ httpMethod: 'GET',
1910
+ baseUri: this.syncApiBase,
1911
+ relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
1912
+ apiToken: this.authToken,
1913
+ customFetch: this.customFetch,
1914
+ requestId: requestId,
1915
+ });
1916
+ return (0, validators_1.validateWorkspaceArray)(response.data);
1917
+ }
1918
+ /**
1919
+ * Retrieves a workspace by its ID.
1920
+ *
1921
+ * @param id - The unique identifier of the workspace.
1922
+ * @param requestId - Optional custom identifier for the request.
1923
+ * @returns A promise that resolves to the requested workspace.
1924
+ */
1925
+ async getWorkspace(id, requestId) {
1926
+ zod_1.z.string().parse(id);
1927
+ const response = await (0, http_client_1.request)({
1928
+ httpMethod: 'GET',
1929
+ baseUri: this.syncApiBase,
1930
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
1931
+ apiToken: this.authToken,
1932
+ customFetch: this.customFetch,
1933
+ requestId: requestId,
1934
+ });
1935
+ return (0, validators_1.validateWorkspace)(response.data);
1936
+ }
1937
+ /**
1938
+ * Creates a new workspace.
1939
+ *
1940
+ * @param args - The arguments for creating the workspace.
1941
+ * @param requestId - Optional custom identifier for the request.
1942
+ * @returns A promise that resolves to the created workspace.
1943
+ */
1944
+ async addWorkspace(args, requestId) {
1945
+ const response = await (0, http_client_1.request)({
1946
+ httpMethod: 'POST',
1947
+ baseUri: this.syncApiBase,
1948
+ relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
1949
+ apiToken: this.authToken,
1950
+ customFetch: this.customFetch,
1951
+ payload: args,
1952
+ requestId: requestId,
1953
+ });
1954
+ return (0, validators_1.validateWorkspace)(response.data);
1955
+ }
1956
+ /**
1957
+ * Updates an existing workspace.
1958
+ *
1959
+ * @param id - The unique identifier of the workspace to update.
1960
+ * @param args - The arguments for updating the workspace.
1961
+ * @param requestId - Optional custom identifier for the request.
1962
+ * @returns A promise that resolves to the updated workspace.
1963
+ */
1964
+ async updateWorkspace(id, args, requestId) {
1965
+ zod_1.z.string().parse(id);
1966
+ const response = await (0, http_client_1.request)({
1967
+ httpMethod: 'POST',
1968
+ baseUri: this.syncApiBase,
1969
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
1970
+ apiToken: this.authToken,
1971
+ customFetch: this.customFetch,
1972
+ payload: args,
1973
+ requestId: requestId,
1974
+ });
1975
+ return (0, validators_1.validateWorkspace)(response.data);
1976
+ }
1977
+ /**
1978
+ * Deletes a workspace by its ID.
1979
+ *
1980
+ * @param id - The unique identifier of the workspace to delete.
1981
+ * @param requestId - Optional custom identifier for the request.
1982
+ * @returns A promise that resolves to `true` if successful.
1983
+ */
1984
+ async deleteWorkspace(id, requestId) {
1985
+ zod_1.z.string().parse(id);
1986
+ const response = await (0, http_client_1.request)({
1987
+ httpMethod: 'DELETE',
1988
+ baseUri: this.syncApiBase,
1989
+ relativePath: generatePath(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
1990
+ apiToken: this.authToken,
1991
+ customFetch: this.customFetch,
1992
+ requestId: requestId,
1993
+ });
1994
+ return (0, http_client_1.isSuccess)(response);
1551
1995
  }
1552
1996
  /**
1553
1997
  * Gets active projects in a workspace with pagination.
@@ -1565,7 +2009,7 @@ class TodoistApi {
1565
2009
  if (args.limit) {
1566
2010
  queryParams.limit = args.limit;
1567
2011
  }
1568
- const response = await (0, rest_client_1.request)({
2012
+ const response = await (0, http_client_1.request)({
1569
2013
  httpMethod: 'GET',
1570
2014
  baseUri: this.syncApiBase,
1571
2015
  relativePath: (0, endpoints_1.getWorkspaceActiveProjectsEndpoint)(args.workspaceId),
@@ -1596,7 +2040,7 @@ class TodoistApi {
1596
2040
  if (args.limit) {
1597
2041
  queryParams.limit = args.limit;
1598
2042
  }
1599
- const response = await (0, rest_client_1.request)({
2043
+ const response = await (0, http_client_1.request)({
1600
2044
  httpMethod: 'GET',
1601
2045
  baseUri: this.syncApiBase,
1602
2046
  relativePath: (0, endpoints_1.getWorkspaceArchivedProjectsEndpoint)(args.workspaceId),