@doist/todoist-api-typescript 6.5.0 → 6.6.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 (144) hide show
  1. package/dist/cjs/todoist-api.js +32 -4
  2. package/dist/cjs/types/index.js +1 -0
  3. package/dist/cjs/types/sync/commands/calendars.js +2 -0
  4. package/dist/cjs/types/sync/commands/filters.js +2 -0
  5. package/dist/cjs/types/sync/commands/folders.js +2 -0
  6. package/dist/cjs/types/sync/commands/index.js +35 -0
  7. package/dist/cjs/types/sync/commands/labels.js +2 -0
  8. package/dist/cjs/types/sync/commands/notes.js +2 -0
  9. package/dist/cjs/types/sync/commands/notifications.js +2 -0
  10. package/dist/cjs/types/sync/commands/others.js +2 -0
  11. package/dist/cjs/types/sync/commands/project-view-options.js +2 -0
  12. package/dist/cjs/types/sync/commands/projects.js +2 -0
  13. package/dist/cjs/types/sync/commands/reminders.js +2 -0
  14. package/dist/cjs/types/sync/commands/sections.js +2 -0
  15. package/dist/cjs/types/sync/commands/shared.js +5 -0
  16. package/dist/cjs/types/sync/commands/sharing.js +2 -0
  17. package/dist/cjs/types/sync/commands/tasks.js +2 -0
  18. package/dist/cjs/types/sync/commands/view-options.js +2 -0
  19. package/dist/cjs/types/sync/commands/workspace-filters.js +2 -0
  20. package/dist/cjs/types/sync/commands/workspace-goals.js +2 -0
  21. package/dist/cjs/types/sync/commands/workspaces.js +2 -0
  22. package/dist/cjs/types/sync/index.js +21 -0
  23. package/dist/cjs/types/sync/request.js +2 -0
  24. package/dist/cjs/types/{sync.js → sync/resource-types.js} +9 -0
  25. package/dist/cjs/types/sync/resources/calendars.js +27 -0
  26. package/dist/cjs/types/sync/resources/collaborators.js +23 -0
  27. package/dist/cjs/types/sync/resources/completed-info.js +30 -0
  28. package/dist/cjs/types/sync/resources/filters.js +16 -0
  29. package/dist/cjs/types/sync/resources/folders.js +14 -0
  30. package/dist/cjs/types/sync/resources/index.js +33 -0
  31. package/dist/cjs/types/sync/resources/live-notifications.js +28 -0
  32. package/dist/cjs/types/sync/resources/notes.js +23 -0
  33. package/dist/cjs/types/sync/resources/reminders.js +34 -0
  34. package/dist/cjs/types/sync/resources/suggestions.js +38 -0
  35. package/dist/cjs/types/sync/resources/tooltips.js +10 -0
  36. package/dist/cjs/types/sync/resources/user-plan-limits.js +24 -0
  37. package/dist/cjs/types/sync/resources/user-settings.js +42 -0
  38. package/dist/cjs/types/sync/resources/user.js +123 -0
  39. package/dist/cjs/types/sync/resources/view-options.js +75 -0
  40. package/dist/cjs/types/sync/resources/workspace-filters.js +21 -0
  41. package/dist/cjs/types/sync/resources/workspace-goals.js +32 -0
  42. package/dist/cjs/types/sync/resources/workspaces.js +49 -0
  43. package/dist/cjs/types/sync/response.js +2 -0
  44. package/dist/cjs/utils/index.js +3 -1
  45. package/dist/cjs/utils/multipart-upload.js +93 -42
  46. package/dist/cjs/utils/sync-helpers.js +22 -0
  47. package/dist/cjs/utils/validators.js +69 -88
  48. package/dist/esm/todoist-api.js +32 -4
  49. package/dist/esm/types/index.js +1 -0
  50. package/dist/esm/types/sync/commands/calendars.js +1 -0
  51. package/dist/esm/types/sync/commands/filters.js +1 -0
  52. package/dist/esm/types/sync/commands/folders.js +1 -0
  53. package/dist/esm/types/sync/commands/index.js +19 -0
  54. package/dist/esm/types/sync/commands/labels.js +1 -0
  55. package/dist/esm/types/sync/commands/notes.js +1 -0
  56. package/dist/esm/types/sync/commands/notifications.js +1 -0
  57. package/dist/esm/types/sync/commands/others.js +1 -0
  58. package/dist/esm/types/sync/commands/project-view-options.js +1 -0
  59. package/dist/esm/types/sync/commands/projects.js +1 -0
  60. package/dist/esm/types/sync/commands/reminders.js +1 -0
  61. package/dist/esm/types/sync/commands/sections.js +1 -0
  62. package/dist/esm/types/sync/commands/shared.js +4 -0
  63. package/dist/esm/types/sync/commands/sharing.js +1 -0
  64. package/dist/esm/types/sync/commands/tasks.js +1 -0
  65. package/dist/esm/types/sync/commands/view-options.js +1 -0
  66. package/dist/esm/types/sync/commands/workspace-filters.js +1 -0
  67. package/dist/esm/types/sync/commands/workspace-goals.js +1 -0
  68. package/dist/esm/types/sync/commands/workspaces.js +1 -0
  69. package/dist/esm/types/sync/index.js +5 -0
  70. package/dist/esm/types/sync/request.js +1 -0
  71. package/dist/esm/types/{sync.js → sync/resource-types.js} +9 -0
  72. package/dist/esm/types/sync/resources/calendars.js +24 -0
  73. package/dist/esm/types/sync/resources/collaborators.js +20 -0
  74. package/dist/esm/types/sync/resources/completed-info.js +27 -0
  75. package/dist/esm/types/sync/resources/filters.js +13 -0
  76. package/dist/esm/types/sync/resources/folders.js +11 -0
  77. package/dist/esm/types/sync/resources/index.js +17 -0
  78. package/dist/esm/types/sync/resources/live-notifications.js +25 -0
  79. package/dist/esm/types/sync/resources/notes.js +20 -0
  80. package/dist/esm/types/sync/resources/reminders.js +31 -0
  81. package/dist/esm/types/sync/resources/suggestions.js +35 -0
  82. package/dist/esm/types/sync/resources/tooltips.js +7 -0
  83. package/dist/esm/types/sync/resources/user-plan-limits.js +21 -0
  84. package/dist/esm/types/sync/resources/user-settings.js +39 -0
  85. package/dist/esm/types/sync/resources/user.js +120 -0
  86. package/dist/esm/types/sync/resources/view-options.js +72 -0
  87. package/dist/esm/types/sync/resources/workspace-filters.js +18 -0
  88. package/dist/esm/types/sync/resources/workspace-goals.js +29 -0
  89. package/dist/esm/types/sync/resources/workspaces.js +46 -0
  90. package/dist/esm/types/sync/response.js +1 -0
  91. package/dist/esm/utils/index.js +1 -0
  92. package/dist/esm/utils/multipart-upload.js +60 -39
  93. package/dist/esm/utils/sync-helpers.js +19 -0
  94. package/dist/esm/utils/validators.js +65 -64
  95. package/dist/types/todoist-api.d.ts +26 -0
  96. package/dist/types/types/index.d.ts +1 -0
  97. package/dist/types/types/requests.d.ts +3 -3
  98. package/dist/types/types/sync/commands/calendars.d.ts +14 -0
  99. package/dist/types/types/sync/commands/filters.d.ts +21 -0
  100. package/dist/types/types/sync/commands/folders.d.ts +18 -0
  101. package/dist/types/types/sync/commands/index.d.ts +172 -0
  102. package/dist/types/types/sync/commands/labels.d.ts +27 -0
  103. package/dist/types/types/sync/commands/notes.d.ts +27 -0
  104. package/dist/types/types/sync/commands/notifications.d.ts +10 -0
  105. package/dist/types/types/sync/commands/others.d.ts +14 -0
  106. package/dist/types/types/sync/commands/project-view-options.d.ts +14 -0
  107. package/dist/types/types/sync/commands/projects.d.ts +88 -0
  108. package/dist/types/types/sync/commands/reminders.d.ts +27 -0
  109. package/dist/types/types/sync/commands/sections.d.ts +31 -0
  110. package/dist/types/types/sync/commands/shared.d.ts +46 -0
  111. package/dist/types/types/sync/commands/sharing.d.ts +16 -0
  112. package/dist/types/types/sync/commands/tasks.d.ts +78 -0
  113. package/dist/types/types/sync/commands/view-options.d.ts +19 -0
  114. package/dist/types/types/sync/commands/workspace-filters.d.ts +22 -0
  115. package/dist/types/types/sync/commands/workspace-goals.d.ts +24 -0
  116. package/dist/types/types/sync/commands/workspaces.d.ts +79 -0
  117. package/dist/types/types/sync/index.d.ts +5 -0
  118. package/dist/types/types/sync/request.d.ts +7 -0
  119. package/dist/types/types/sync/resource-types.d.ts +5 -0
  120. package/dist/types/types/sync/resources/calendars.d.ts +30 -0
  121. package/dist/types/types/sync/resources/collaborators.d.ts +24 -0
  122. package/dist/types/types/sync/resources/completed-info.d.ts +33 -0
  123. package/dist/types/types/sync/resources/filters.d.ts +12 -0
  124. package/dist/types/types/sync/resources/folders.d.ts +10 -0
  125. package/dist/types/types/sync/resources/index.d.ts +17 -0
  126. package/dist/types/types/sync/resources/live-notifications.d.ts +23 -0
  127. package/dist/types/types/sync/resources/notes.d.ts +34 -0
  128. package/dist/types/types/sync/resources/reminders.d.ts +101 -0
  129. package/dist/types/types/sync/resources/suggestions.d.ts +54 -0
  130. package/dist/types/types/sync/resources/tooltips.d.ts +6 -0
  131. package/dist/types/types/sync/resources/user-plan-limits.d.ts +41 -0
  132. package/dist/types/types/sync/resources/user-settings.d.ts +32 -0
  133. package/dist/types/types/sync/resources/user.d.ts +104 -0
  134. package/dist/types/types/sync/resources/view-options.d.ts +94 -0
  135. package/dist/types/types/sync/resources/workspace-filters.d.ts +17 -0
  136. package/dist/types/types/sync/resources/workspace-goals.d.ts +29 -0
  137. package/dist/types/types/sync/resources/workspaces.d.ts +52 -0
  138. package/dist/types/types/sync/response.d.ts +47 -0
  139. package/dist/types/utils/index.d.ts +1 -0
  140. package/dist/types/utils/multipart-upload.d.ts +5 -3
  141. package/dist/types/utils/sync-helpers.d.ts +17 -0
  142. package/dist/types/utils/validators.d.ts +1163 -23
  143. package/package.json +8 -8
  144. package/dist/types/types/sync.d.ts +0 -30
@@ -1,39 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateTask = validateTask;
4
- exports.validateTaskArray = validateTaskArray;
3
+ exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = exports.validateNote = exports.validateFolderArray = exports.validateFolder = exports.validateCollaboratorStateArray = exports.validateCollaboratorState = exports.validateCollaboratorArray = exports.validateCollaborator = exports.validateFilterArray = exports.validateFilter = exports.validateWorkspaceArray = exports.validateWorkspace = exports.validateJoinWorkspaceResult = exports.validateWorkspacePlanDetails = exports.validateWorkspaceInvitationArray = exports.validateWorkspaceInvitation = exports.validateWorkspaceUser = exports.validateAttachment = exports.validateActivityEventArray = exports.validateActivityEvent = exports.validateCurrentUser = exports.validateProductivityStats = exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateTaskArray = exports.validateTask = void 0;
4
+ exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = void 0;
5
5
  exports.isWorkspaceProject = isWorkspaceProject;
6
6
  exports.isPersonalProject = isPersonalProject;
7
7
  exports.validateProject = validateProject;
8
8
  exports.validateProjectArray = validateProjectArray;
9
- exports.validateSection = validateSection;
10
- exports.validateSectionArray = validateSectionArray;
11
- exports.validateLabel = validateLabel;
12
- exports.validateLabelArray = validateLabelArray;
13
- exports.validateComment = validateComment;
14
- exports.validateCommentArray = validateCommentArray;
15
- exports.validateUser = validateUser;
16
- exports.validateUserArray = validateUserArray;
17
- exports.validateProductivityStats = validateProductivityStats;
18
- exports.validateCurrentUser = validateCurrentUser;
19
- exports.validateActivityEvent = validateActivityEvent;
20
- exports.validateActivityEventArray = validateActivityEventArray;
21
- exports.validateAttachment = validateAttachment;
22
- exports.validateWorkspaceUser = validateWorkspaceUser;
23
9
  exports.validateWorkspaceUserArray = validateWorkspaceUserArray;
24
- exports.validateWorkspaceInvitation = validateWorkspaceInvitation;
25
- exports.validateWorkspaceInvitationArray = validateWorkspaceInvitationArray;
26
- exports.validateWorkspacePlanDetails = validateWorkspacePlanDetails;
27
- exports.validateJoinWorkspaceResult = validateJoinWorkspaceResult;
28
- exports.validateWorkspace = validateWorkspace;
29
- exports.validateWorkspaceArray = validateWorkspaceArray;
30
10
  const entities_1 = require("../types/entities");
31
- function validateTask(input) {
32
- return entities_1.TaskSchema.parse(input);
11
+ const resources_1 = require("../types/sync/resources");
12
+ function createValidator(schema) {
13
+ return (input) => schema.parse(input);
33
14
  }
34
- function validateTaskArray(input) {
35
- return input.map(validateTask);
15
+ function createArrayValidator(validateItem) {
16
+ return (input) => input.map(validateItem);
36
17
  }
18
+ // Entity validators
19
+ exports.validateTask = createValidator(entities_1.TaskSchema);
20
+ exports.validateTaskArray = createArrayValidator(exports.validateTask);
37
21
  /**
38
22
  * Type guard to check if a project is a workspace project.
39
23
  * @param project The project to check
@@ -64,69 +48,66 @@ function validateProject(input) {
64
48
  function validateProjectArray(input) {
65
49
  return input.map(validateProject);
66
50
  }
67
- function validateSection(input) {
68
- return entities_1.SectionSchema.parse(input);
69
- }
70
- function validateSectionArray(input) {
71
- return input.map(validateSection);
72
- }
73
- function validateLabel(input) {
74
- return entities_1.LabelSchema.parse(input);
75
- }
76
- function validateLabelArray(input) {
77
- return input.map(validateLabel);
78
- }
79
- function validateComment(input) {
80
- return entities_1.CommentSchema.parse(input);
81
- }
82
- function validateCommentArray(input) {
83
- return input.map(validateComment);
84
- }
85
- function validateUser(input) {
86
- return entities_1.UserSchema.parse(input);
87
- }
88
- function validateUserArray(input) {
89
- return input.map(validateUser);
90
- }
91
- function validateProductivityStats(input) {
92
- return entities_1.ProductivityStatsSchema.parse(input);
93
- }
94
- function validateCurrentUser(input) {
95
- return entities_1.CurrentUserSchema.parse(input);
96
- }
97
- function validateActivityEvent(input) {
98
- return entities_1.ActivityEventSchema.parse(input);
99
- }
100
- function validateActivityEventArray(input) {
101
- return input.map(validateActivityEvent);
102
- }
103
- function validateAttachment(input) {
104
- return entities_1.AttachmentSchema.parse(input);
105
- }
106
- function validateWorkspaceUser(input) {
107
- return entities_1.WorkspaceUserSchema.parse(input);
108
- }
51
+ exports.validateSection = createValidator(entities_1.SectionSchema);
52
+ exports.validateSectionArray = createArrayValidator(exports.validateSection);
53
+ exports.validateLabel = createValidator(entities_1.LabelSchema);
54
+ exports.validateLabelArray = createArrayValidator(exports.validateLabel);
55
+ exports.validateComment = createValidator(entities_1.CommentSchema);
56
+ exports.validateCommentArray = createArrayValidator(exports.validateComment);
57
+ exports.validateUser = createValidator(entities_1.UserSchema);
58
+ exports.validateUserArray = createArrayValidator(exports.validateUser);
59
+ exports.validateProductivityStats = createValidator(entities_1.ProductivityStatsSchema);
60
+ exports.validateCurrentUser = createValidator(entities_1.CurrentUserSchema);
61
+ exports.validateActivityEvent = createValidator(entities_1.ActivityEventSchema);
62
+ exports.validateActivityEventArray = createArrayValidator(exports.validateActivityEvent);
63
+ exports.validateAttachment = createValidator(entities_1.AttachmentSchema);
64
+ exports.validateWorkspaceUser = createValidator(entities_1.WorkspaceUserSchema);
109
65
  function validateWorkspaceUserArray(input) {
110
66
  if (!Array.isArray(input)) {
111
67
  throw new Error(`Expected array for workspace users, got ${typeof input}`);
112
68
  }
113
- return input.map(validateWorkspaceUser);
114
- }
115
- function validateWorkspaceInvitation(input) {
116
- return entities_1.WorkspaceInvitationSchema.parse(input);
117
- }
118
- function validateWorkspaceInvitationArray(input) {
119
- return input.map(validateWorkspaceInvitation);
120
- }
121
- function validateWorkspacePlanDetails(input) {
122
- return entities_1.WorkspacePlanDetailsSchema.parse(input);
123
- }
124
- function validateJoinWorkspaceResult(input) {
125
- return entities_1.JoinWorkspaceResultSchema.parse(input);
126
- }
127
- function validateWorkspace(input) {
128
- return entities_1.WorkspaceSchema.parse(input);
129
- }
130
- function validateWorkspaceArray(input) {
131
- return input.map(validateWorkspace);
132
- }
69
+ return input.map(exports.validateWorkspaceUser);
70
+ }
71
+ exports.validateWorkspaceInvitation = createValidator(entities_1.WorkspaceInvitationSchema);
72
+ exports.validateWorkspaceInvitationArray = createArrayValidator(exports.validateWorkspaceInvitation);
73
+ exports.validateWorkspacePlanDetails = createValidator(entities_1.WorkspacePlanDetailsSchema);
74
+ exports.validateJoinWorkspaceResult = createValidator(entities_1.JoinWorkspaceResultSchema);
75
+ exports.validateWorkspace = createValidator(entities_1.WorkspaceSchema);
76
+ exports.validateWorkspaceArray = createArrayValidator(exports.validateWorkspace);
77
+ // Sync resource validators
78
+ exports.validateFilter = createValidator(resources_1.FilterSchema);
79
+ exports.validateFilterArray = createArrayValidator(exports.validateFilter);
80
+ exports.validateCollaborator = createValidator(resources_1.CollaboratorSchema);
81
+ exports.validateCollaboratorArray = createArrayValidator(exports.validateCollaborator);
82
+ exports.validateCollaboratorState = createValidator(resources_1.CollaboratorStateSchema);
83
+ exports.validateCollaboratorStateArray = createArrayValidator(exports.validateCollaboratorState);
84
+ exports.validateFolder = createValidator(resources_1.FolderSchema);
85
+ exports.validateFolderArray = createArrayValidator(exports.validateFolder);
86
+ exports.validateNote = createValidator(resources_1.NoteSchema);
87
+ exports.validateNoteArray = createArrayValidator(exports.validateNote);
88
+ exports.validateTooltips = createValidator(resources_1.TooltipsSchema);
89
+ exports.validateWorkspaceFilter = createValidator(resources_1.WorkspaceFilterSchema);
90
+ exports.validateWorkspaceFilterArray = createArrayValidator(exports.validateWorkspaceFilter);
91
+ exports.validateWorkspaceGoal = createValidator(resources_1.WorkspaceGoalSchema);
92
+ exports.validateWorkspaceGoalArray = createArrayValidator(exports.validateWorkspaceGoal);
93
+ exports.validateCalendar = createValidator(resources_1.CalendarSchema);
94
+ exports.validateCalendarArray = createArrayValidator(exports.validateCalendar);
95
+ exports.validateCalendarAccount = createValidator(resources_1.CalendarAccountSchema);
96
+ exports.validateCalendarAccountArray = createArrayValidator(exports.validateCalendarAccount);
97
+ exports.validateReminder = createValidator(resources_1.ReminderSchema);
98
+ exports.validateReminderArray = createArrayValidator(exports.validateReminder);
99
+ exports.validateCompletedInfo = createValidator(resources_1.CompletedInfoSchema);
100
+ exports.validateCompletedInfoArray = createArrayValidator(exports.validateCompletedInfo);
101
+ exports.validateViewOptions = createValidator(resources_1.ViewOptionsSchema);
102
+ exports.validateViewOptionsArray = createArrayValidator(exports.validateViewOptions);
103
+ exports.validateProjectViewOptionsDefaults = createValidator(resources_1.ProjectViewOptionsDefaultsSchema);
104
+ exports.validateProjectViewOptionsDefaultsArray = createArrayValidator(exports.validateProjectViewOptionsDefaults);
105
+ exports.validateUserPlanLimits = createValidator(resources_1.UserPlanLimitsSchema);
106
+ exports.validateLiveNotification = createValidator(resources_1.LiveNotificationSchema);
107
+ exports.validateLiveNotificationArray = createArrayValidator(exports.validateLiveNotification);
108
+ exports.validateSyncWorkspace = createValidator(resources_1.SyncWorkspaceSchema);
109
+ exports.validateSyncWorkspaceArray = createArrayValidator(exports.validateSyncWorkspace);
110
+ exports.validateSyncUser = createValidator(resources_1.SyncUserSchema);
111
+ exports.validateUserSettings = createValidator(resources_1.UserSettingsSchema);
112
+ exports.validateSuggestion = createValidator(resources_1.SuggestionSchema);
113
+ exports.validateSuggestionArray = createArrayValidator(exports.validateSuggestion);
@@ -73,6 +73,34 @@ export class TodoistApi {
73
73
  }
74
74
  return response.data;
75
75
  }
76
+ /**
77
+ * Executes a raw Sync API request.
78
+ *
79
+ * This method provides direct access to the Sync API, allowing you to send
80
+ * strongly-typed commands and request specific resource types.
81
+ *
82
+ * @param request - The sync request payload containing commands and/or resource types.
83
+ * @param requestId - Optional custom identifier for the request.
84
+ * @returns A promise that resolves to the sync response.
85
+ * @throws TodoistRequestError if the sync status contains errors.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import { createCommand } from '@doist/todoist-api-typescript'
90
+ *
91
+ * const response = await api.sync({
92
+ * commands: [
93
+ * createCommand('item_add', { content: 'Buy milk' }),
94
+ * ],
95
+ * resourceTypes: ['items'],
96
+ * syncToken: '*',
97
+ * })
98
+ * ```
99
+ */
100
+ async sync(syncRequest, requestId) {
101
+ var _a;
102
+ return this.requestSync(syncRequest, requestId, Boolean((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length));
103
+ }
76
104
  /**
77
105
  * Retrieves information about the authenticated user.
78
106
  *
@@ -286,11 +314,11 @@ export class TodoistApi {
286
314
  const commands = ids.map((id) => ({
287
315
  type: 'item_move',
288
316
  uuid: uuidv4(),
289
- args: Object.assign(Object.assign(Object.assign({ id }, (args.projectId && { project_id: args.projectId })), (args.sectionId && { section_id: args.sectionId })), (args.parentId && { parent_id: args.parentId })),
317
+ args: Object.assign(Object.assign(Object.assign({ id }, (args.projectId ? { projectId: args.projectId } : {})), (args.sectionId ? { sectionId: args.sectionId } : {})), (args.parentId ? { parentId: args.parentId } : {})),
290
318
  }));
291
319
  const syncRequest = {
292
320
  commands,
293
- resource_types: ['items'],
321
+ resourceTypes: ['items'],
294
322
  };
295
323
  const syncResponse = await this.requestSync(syncRequest, requestId, true);
296
324
  if (!((_a = syncResponse.items) === null || _a === void 0 ? void 0 : _a.length)) {
@@ -1355,8 +1383,8 @@ export class TodoistApi {
1355
1383
  */
1356
1384
  async getWorkspaces(requestId) {
1357
1385
  const syncRequest = {
1358
- sync_token: '*',
1359
- resource_types: ['workspaces'],
1386
+ syncToken: '*',
1387
+ resourceTypes: ['workspaces'],
1360
1388
  };
1361
1389
  const syncResponse = await this.requestSync(syncRequest, requestId, false);
1362
1390
  const workspacesData = syncResponse.workspaces;
@@ -2,3 +2,4 @@ export * from './entities.js';
2
2
  export * from './errors.js';
3
3
  export * from './requests.js';
4
4
  export * from './http.js';
5
+ export * from './sync/index.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ // Re-export all domain types
2
+ export * from './shared.js';
3
+ export * from './tasks.js';
4
+ export * from './projects.js';
5
+ export * from './sections.js';
6
+ export * from './labels.js';
7
+ export * from './filters.js';
8
+ export * from './notes.js';
9
+ export * from './reminders.js';
10
+ export * from './workspaces.js';
11
+ export * from './folders.js';
12
+ export * from './workspace-filters.js';
13
+ export * from './workspace-goals.js';
14
+ export * from './notifications.js';
15
+ export * from './sharing.js';
16
+ export * from './view-options.js';
17
+ export * from './project-view-options.js';
18
+ export * from './calendars.js';
19
+ export * from './others.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Shared types used across multiple Sync API command argument types.
3
+ */
4
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './commands/index.js';
2
+ export * from './resources/index.js';
3
+ export * from './resource-types.js';
4
+ export * from './request.js';
5
+ export * from './response.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -6,6 +6,7 @@ export const SYNC_RESOURCE_TYPES = [
6
6
  'projects',
7
7
  'items',
8
8
  'notes',
9
+ 'project_notes',
9
10
  'sections',
10
11
  'filters',
11
12
  'reminders',
@@ -14,6 +15,7 @@ export const SYNC_RESOURCE_TYPES = [
14
15
  'user',
15
16
  'live_notifications',
16
17
  'collaborators',
18
+ 'collaborator_states',
17
19
  'user_settings',
18
20
  'notification_settings',
19
21
  'user_plan_limits',
@@ -25,4 +27,11 @@ export const SYNC_RESOURCE_TYPES = [
25
27
  'view_options',
26
28
  'project_view_options_defaults',
27
29
  'role_actions',
30
+ 'folders',
31
+ 'workspace_goals',
32
+ 'day_orders',
33
+ 'calendars',
34
+ 'calendar_accounts',
35
+ 'suggestions',
36
+ 'tooltips',
28
37
  ];
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ export const CalendarSchema = z
3
+ .object({
4
+ id: z.string(),
5
+ summary: z.string(),
6
+ color: z.string().nullable(),
7
+ accountId: z.string(),
8
+ isVisible: z.boolean(),
9
+ isTaskCalendar: z.boolean().optional(),
10
+ })
11
+ .passthrough();
12
+ export const CalendarAccountSchema = z
13
+ .object({
14
+ id: z.string(),
15
+ name: z.string(),
16
+ type: z.enum(['google', 'microsoft', 'apple']),
17
+ isDeleted: z.boolean().optional(),
18
+ isEventsEnabled: z.boolean().optional(),
19
+ isTasksEnabled: z.boolean().optional(),
20
+ isAllDayTasksEnabled: z.boolean().optional(),
21
+ pendingOperationUntil: z.string().nullable().optional(),
22
+ calendarsSyncState: z.enum(['synced', 'syncing', 'error']).optional(),
23
+ })
24
+ .passthrough();
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { WorkspaceRoleSchema } from '../../entities.js';
3
+ export const CollaboratorSchema = z
4
+ .object({
5
+ id: z.string(),
6
+ email: z.string(),
7
+ fullName: z.string(),
8
+ timezone: z.string(),
9
+ imageId: z.string().nullable(),
10
+ })
11
+ .passthrough();
12
+ export const CollaboratorStateSchema = z
13
+ .object({
14
+ userId: z.string(),
15
+ projectId: z.string(),
16
+ state: z.enum(['active', 'invited']),
17
+ isDeleted: z.boolean(),
18
+ workspaceRole: WorkspaceRoleSchema.optional(),
19
+ })
20
+ .passthrough();
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ export const CompletedProjectMetadataSchema = z
3
+ .object({
4
+ projectId: z.string(),
5
+ archivedSections: z.number().int(),
6
+ completedItems: z.number().int(),
7
+ })
8
+ .passthrough();
9
+ export const CompletedSectionMetadataSchema = z
10
+ .object({
11
+ sectionId: z.string(),
12
+ id: z.string(),
13
+ completedItems: z.number().int(),
14
+ })
15
+ .passthrough();
16
+ export const CompletedTaskMetadataSchema = z
17
+ .object({
18
+ itemId: z.string(),
19
+ id: z.string().optional(),
20
+ completedItems: z.number().int(),
21
+ })
22
+ .passthrough();
23
+ export const CompletedInfoSchema = z.union([
24
+ CompletedProjectMetadataSchema,
25
+ CompletedSectionMetadataSchema,
26
+ CompletedTaskMetadataSchema,
27
+ ]);
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export const FilterSchema = z
3
+ .object({
4
+ id: z.string(),
5
+ name: z.string(),
6
+ query: z.string(),
7
+ color: z.string(),
8
+ isDeleted: z.boolean(),
9
+ isFavorite: z.boolean(),
10
+ isFrozen: z.boolean(),
11
+ itemOrder: z.number().int(),
12
+ })
13
+ .passthrough();
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ export const FolderSchema = z
3
+ .object({
4
+ id: z.string(),
5
+ name: z.string(),
6
+ workspaceId: z.string(),
7
+ isDeleted: z.boolean(),
8
+ defaultOrder: z.number().int(),
9
+ childOrder: z.number().int(),
10
+ })
11
+ .passthrough();
@@ -0,0 +1,17 @@
1
+ export * from './filters.js';
2
+ export * from './collaborators.js';
3
+ export * from './folders.js';
4
+ export * from './tooltips.js';
5
+ export * from './notes.js';
6
+ export * from './workspace-filters.js';
7
+ export * from './workspace-goals.js';
8
+ export * from './calendars.js';
9
+ export * from './reminders.js';
10
+ export * from './completed-info.js';
11
+ export * from './view-options.js';
12
+ export * from './user-plan-limits.js';
13
+ export * from './live-notifications.js';
14
+ export * from './workspaces.js';
15
+ export * from './user.js';
16
+ export * from './user-settings.js';
17
+ export * from './suggestions.js';
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Live notification resource from the Sync API.
4
+ *
5
+ * Uses a base schema with commonly-present fields plus `.passthrough()` for
6
+ * forward compatibility. The Sync API returns 20+ notification variants;
7
+ * fully typing each is too fragile for a library, so we validate the common
8
+ * shape and preserve all extra fields.
9
+ */
10
+ export const LiveNotificationSchema = z
11
+ .object({
12
+ id: z.string(),
13
+ createdAt: z.string(),
14
+ fromUid: z.string(),
15
+ notificationType: z.string(),
16
+ isUnread: z.boolean(),
17
+ // Commonly present optional fields
18
+ projectId: z.string().optional(),
19
+ invitationId: z.string().optional(),
20
+ itemId: z.string().optional(),
21
+ itemContent: z.string().optional(),
22
+ responsibleUid: z.string().optional(),
23
+ assignedByUid: z.string().optional(),
24
+ })
25
+ .passthrough();
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { AttachmentSchema } from '../../entities.js';
3
+ /**
4
+ * Sync API note (comment) resource.
5
+ * Separate from the REST `CommentSchema` which transforms `itemId` to `taskId`.
6
+ */
7
+ export const NoteSchema = z
8
+ .object({
9
+ id: z.string(),
10
+ itemId: z.string().optional(),
11
+ projectId: z.string().optional(),
12
+ content: z.string(),
13
+ postedAt: z.string(),
14
+ fileAttachment: AttachmentSchema.nullable(),
15
+ postedUid: z.string(),
16
+ uidsToNotify: z.array(z.string()).nullable(),
17
+ reactions: z.record(z.string(), z.array(z.string())).nullable(),
18
+ isDeleted: z.boolean(),
19
+ })
20
+ .passthrough();
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ import { DueDateSchema } from '../../entities.js';
3
+ const ReminderBaseSchema = z.object({
4
+ id: z.string(),
5
+ notifyUid: z.string(),
6
+ itemId: z.string(),
7
+ projectId: z.string().optional(),
8
+ isDeleted: z.boolean(),
9
+ });
10
+ export const LocationReminderSchema = ReminderBaseSchema.extend({
11
+ type: z.literal('location'),
12
+ name: z.string(),
13
+ locLat: z.string(),
14
+ locLong: z.string(),
15
+ locTrigger: z.enum(['on_enter', 'on_leave']),
16
+ radius: z.number().int(),
17
+ }).passthrough();
18
+ export const AbsoluteReminderSchema = ReminderBaseSchema.extend({
19
+ type: z.literal('absolute'),
20
+ due: DueDateSchema,
21
+ }).passthrough();
22
+ export const RelativeReminderSchema = ReminderBaseSchema.extend({
23
+ type: z.literal('relative'),
24
+ minuteOffset: z.number().int(),
25
+ due: DueDateSchema.optional(),
26
+ }).passthrough();
27
+ export const ReminderSchema = z.discriminatedUnion('type', [
28
+ LocationReminderSchema,
29
+ AbsoluteReminderSchema,
30
+ RelativeReminderSchema,
31
+ ]);
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ export const TemplateSuggestionSchema = z
3
+ .object({
4
+ id: z.string(),
5
+ name: z.string(),
6
+ templateType: z.enum(['project', 'setup']),
7
+ })
8
+ .passthrough();
9
+ export const WorkspaceTemplateSuggestionSchema = TemplateSuggestionSchema.extend({
10
+ workspaceId: z.string().nullable(),
11
+ });
12
+ const SyncTemplateSuggestionsSchema = z
13
+ .object({
14
+ type: z.enum(['templates', 'most_used_user_templates']),
15
+ content: z.object({
16
+ templates: z.array(TemplateSuggestionSchema),
17
+ locale: z.string(),
18
+ }),
19
+ isDeleted: z.boolean(),
20
+ })
21
+ .passthrough();
22
+ const SyncWorkspaceTemplateSuggestionsSchema = z
23
+ .object({
24
+ type: z.literal('most_used_workspace_templates'),
25
+ content: z.object({
26
+ templates: z.array(WorkspaceTemplateSuggestionSchema),
27
+ locale: z.string(),
28
+ }),
29
+ isDeleted: z.boolean(),
30
+ })
31
+ .passthrough();
32
+ export const SuggestionSchema = z.union([
33
+ SyncWorkspaceTemplateSuggestionsSchema,
34
+ SyncTemplateSuggestionsSchema,
35
+ ]);
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export const TooltipsSchema = z
3
+ .object({
4
+ seen: z.array(z.string()).optional(),
5
+ scheduled: z.array(z.string()).optional(),
6
+ })
7
+ .passthrough();
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export const PlanLimitsSchema = z
3
+ .object({
4
+ activeProjects: z.number().int().optional(),
5
+ activityLog: z.number().int().optional(),
6
+ collaboratorsPerProject: z.number().int().optional(),
7
+ commentsPerTask: z.number().int().optional(),
8
+ fileUploadsPerComment: z.number().int().optional(),
9
+ filtersPerUser: z.number().int().optional(),
10
+ labelsPerTask: z.number().int().optional(),
11
+ remindersPerUser: z.number().int().optional(),
12
+ sectionsPerProject: z.number().int().optional(),
13
+ tasksPerProject: z.number().int().optional(),
14
+ })
15
+ .passthrough();
16
+ export const UserPlanLimitsSchema = z
17
+ .object({
18
+ current: PlanLimitsSchema,
19
+ next: PlanLimitsSchema.nullable(),
20
+ })
21
+ .passthrough();