@doist/todoist-api-typescript 4.0.0-alpha.2 → 4.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,54 +1,291 @@
1
- import { Task, Project, Label, Section, Comment } from './types/entities';
2
- import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse } from './types/requests';
1
+ import { Project, Label, Section, Comment } from './types/entities';
2
+ import type { Task } from './types/entities';
3
+ import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse, type MoveTaskArgs } from './types/requests';
4
+ /**
5
+ * A client for interacting with the Todoist Sync API.
6
+ * This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const api = new TodoistApi('your-api-token');
11
+ *
12
+ * // Get all tasks
13
+ * const tasks = await api.getTasks();
14
+ *
15
+ * // Create a new task
16
+ * const newTask = await api.addTask({
17
+ * content: 'My new task',
18
+ * projectId: '12345'
19
+ * });
20
+ * ```
21
+ *
22
+ */
3
23
  export declare class TodoistApi {
4
- authToken: string;
5
- constructor(authToken: string, baseUrl?: string);
24
+ private authToken;
6
25
  private syncApiBase;
26
+ constructor(
27
+ /**
28
+ * Your Todoist API token.
29
+ */
30
+ authToken: string,
31
+ /**
32
+ * Optional custom API base URL. If not provided, defaults to Todoist's standard API endpoint
33
+ */
34
+ baseUrl?: string);
35
+ /**
36
+ * Retrieves a single active (non-completed) task by its ID.
37
+ *
38
+ * @param id - The unique identifier of the task.
39
+ * @returns A promise that resolves to the requested task.
40
+ */
7
41
  getTask(id: string): Promise<Task>;
42
+ /**
43
+ * Retrieves a list of active tasks filtered by specific parameters.
44
+ *
45
+ * @param args - Filter parameters such as project ID, label ID, or due date.
46
+ * @returns A promise that resolves to an array of tasks.
47
+ */
8
48
  getTasks(args?: GetTasksArgs): Promise<GetTasksResponse>;
49
+ /**
50
+ * Creates a new task with the provided parameters.
51
+ *
52
+ * @param args - Task creation parameters such as content, due date, or priority.
53
+ * @param requestId - Optional unique identifier for idempotency.
54
+ * @returns A promise that resolves to the created task.
55
+ */
9
56
  addTask(args: AddTaskArgs, requestId?: string): Promise<Task>;
57
+ /**
58
+ * Quickly adds a task using natural language processing for due dates.
59
+ *
60
+ * @param args - Quick add task parameters, including content and due date.
61
+ * @returns A promise that resolves to the created task.
62
+ */
10
63
  quickAddTask(args: QuickAddTaskArgs): Promise<Task>;
64
+ /**
65
+ * Updates an existing task by its ID with the provided parameters.
66
+ *
67
+ * @param id - The unique identifier of the task to update.
68
+ * @param args - Update parameters such as content, priority, or due date.
69
+ * @param requestId - Optional unique identifier for idempotency.
70
+ * @returns A promise that resolves to the updated task.
71
+ */
11
72
  updateTask(id: string, args: UpdateTaskArgs, requestId?: string): Promise<Task>;
73
+ /**
74
+ * Moves existing tasks by their ID to either a different parent/section/project.
75
+ *
76
+ * @param ids - The unique identifier of the tasks to be moved.
77
+ * @param args - The paramets that should contain only one of projectId, sectionId, or parentId
78
+ * @param requestId - Optional unique identifier for idempotency.
79
+ * @returns - A promise that resolves to an array of the updated tasks.
80
+ */
81
+ moveTasks(ids: string[], args: MoveTaskArgs, requestId?: string): Promise<Task[]>;
82
+ /**
83
+ * Closes (completes) a task by its ID.
84
+ *
85
+ * @param id - The unique identifier of the task to close.
86
+ * @param requestId - Optional unique identifier for idempotency.
87
+ * @returns A promise that resolves to `true` if successful.
88
+ */
12
89
  closeTask(id: string, requestId?: string): Promise<boolean>;
90
+ /**
91
+ * Reopens a previously closed (completed) task by its ID.
92
+ *
93
+ * @param id - The unique identifier of the task to reopen.
94
+ * @param requestId - Optional unique identifier for idempotency.
95
+ * @returns A promise that resolves to `true` if successful.
96
+ */
13
97
  reopenTask(id: string, requestId?: string): Promise<boolean>;
98
+ /**
99
+ * Deletes a task by its ID.
100
+ *
101
+ * @param id - The unique identifier of the task to delete.
102
+ * @param requestId - Optional unique identifier for idempotency.
103
+ * @returns A promise that resolves to `true` if successful.
104
+ */
14
105
  deleteTask(id: string, requestId?: string): Promise<boolean>;
106
+ /**
107
+ * Retrieves a project by its ID.
108
+ *
109
+ * @param id - The unique identifier of the project.
110
+ * @returns A promise that resolves to the requested project.
111
+ */
15
112
  getProject(id: string): Promise<Project>;
113
+ /**
114
+ * Retrieves all projects with optional filters.
115
+ *
116
+ * @param args - Optional filters for retrieving projects.
117
+ * @returns A promise that resolves to an array of projects.
118
+ */
16
119
  getProjects(args?: GetProjectsArgs): Promise<GetProjectsResponse>;
120
+ /**
121
+ * Creates a new project with the provided parameters.
122
+ *
123
+ * @param args - Project creation parameters such as name or color.
124
+ * @param requestId - Optional unique identifier for idempotency.
125
+ * @returns A promise that resolves to the created project.
126
+ */
17
127
  addProject(args: AddProjectArgs, requestId?: string): Promise<Project>;
128
+ /**
129
+ * Updates an existing project by its ID with the provided parameters.
130
+ *
131
+ * @param id - The unique identifier of the project to update.
132
+ * @param args - Update parameters such as name or color.
133
+ * @param requestId - Optional unique identifier for idempotency.
134
+ * @returns A promise that resolves to the updated project.
135
+ */
18
136
  updateProject(id: string, args: UpdateProjectArgs, requestId?: string): Promise<Project>;
137
+ /**
138
+ * Deletes a project by its ID.
139
+ *
140
+ * @param id - The unique identifier of the project to delete.
141
+ * @param requestId - Optional unique identifier for idempotency.
142
+ * @returns A promise that resolves to `true` if successful.
143
+ */
19
144
  deleteProject(id: string, requestId?: string): Promise<boolean>;
145
+ /**
146
+ * Retrieves a list of collaborators for a specific project.
147
+ *
148
+ * @param projectId - The unique identifier of the project.
149
+ * @param args - Optional parameters to filter collaborators.
150
+ * @returns A promise that resolves to an array of collaborators for the project.
151
+ */
20
152
  getProjectCollaborators(projectId: string, args?: GetProjectCollaboratorsArgs): Promise<GetProjectCollaboratorsResponse>;
153
+ /**
154
+ * Retrieves all sections within a specific project or matching criteria.
155
+ *
156
+ * @param args - Filter parameters such as project ID.
157
+ * @returns A promise that resolves to an array of sections.
158
+ */
21
159
  getSections(args: GetSectionsArgs): Promise<GetSectionsResponse>;
160
+ /**
161
+ * Retrieves a single section by its ID.
162
+ *
163
+ * @param id - The unique identifier of the section.
164
+ * @returns A promise that resolves to the requested section.
165
+ */
22
166
  getSection(id: string): Promise<Section>;
167
+ /**
168
+ * Creates a new section within a project.
169
+ *
170
+ * @param args - Section creation parameters such as name or project ID.
171
+ * @param requestId - Optional unique identifier for idempotency.
172
+ * @returns A promise that resolves to the created section.
173
+ */
23
174
  addSection(args: AddSectionArgs, requestId?: string): Promise<Section>;
175
+ /**
176
+ * Updates a section by its ID with the provided parameters.
177
+ *
178
+ * @param id - The unique identifier of the section to update.
179
+ * @param args - Update parameters such as name or project ID.
180
+ * @param requestId - Optional unique identifier for idempotency.
181
+ * @returns A promise that resolves to the updated section.
182
+ */
24
183
  updateSection(id: string, args: UpdateSectionArgs, requestId?: string): Promise<Section>;
184
+ /**
185
+ * Deletes a section by its ID.
186
+ *
187
+ * @param id - The unique identifier of the section to delete.
188
+ * @param requestId - Optional unique identifier for idempotency.
189
+ * @returns A promise that resolves to `true` if successful.
190
+ */
25
191
  deleteSection(id: string, requestId?: string): Promise<boolean>;
26
192
  /**
27
- * Fetches a personal label
193
+ * Retrieves a label by its ID.
194
+ *
195
+ * @param id - The unique identifier of the label.
196
+ * @returns A promise that resolves to the requested label.
28
197
  */
29
198
  getLabel(id: string): Promise<Label>;
30
199
  /**
31
- * Fetches the personal labels
200
+ * Retrieves all labels.
201
+ *
202
+ * @param args - Optional filter parameters.
203
+ * @returns A promise that resolves to an array of labels.
32
204
  */
33
205
  getLabels(args?: GetLabelsArgs): Promise<GetLabelsResponse>;
34
206
  /**
35
- * Adds a personal label
207
+ * Adds a new label.
208
+ *
209
+ * @param args - Label creation parameters such as name.
210
+ * @param requestId - Optional unique identifier for idempotency.
211
+ * @returns A promise that resolves to the created label.
36
212
  */
37
213
  addLabel(args: AddLabelArgs, requestId?: string): Promise<Label>;
38
214
  /**
39
- * Updates a personal label
215
+ * Updates an existing label by its ID.
216
+ *
217
+ * @param id - The unique identifier of the label to update.
218
+ * @param args - Update parameters such as name or color.
219
+ * @param requestId - Optional unique identifier for idempotency.
220
+ * @returns A promise that resolves to the updated label.
40
221
  */
41
222
  updateLabel(id: string, args: UpdateLabelArgs, requestId?: string): Promise<Label>;
42
223
  /**
43
- * Deletes a personal label
224
+ * Deletes a label by its ID.
225
+ *
226
+ * @param id - The unique identifier of the label to delete.
227
+ * @param requestId - Optional unique identifier for idempotency.
228
+ * @returns A promise that resolves to `true` if successful.
44
229
  */
45
230
  deleteLabel(id: string, requestId?: string): Promise<boolean>;
231
+ /**
232
+ * Retrieves a list of shared labels.
233
+ *
234
+ * @param args - Optional parameters to filter shared labels.
235
+ * @returns A promise that resolves to an array of shared labels.
236
+ */
46
237
  getSharedLabels(args?: GetSharedLabelsArgs): Promise<GetSharedLabelsResponse>;
238
+ /**
239
+ * Renames an existing shared label.
240
+ *
241
+ * @param args - Parameters for renaming the shared label, including the current and new name.
242
+ * @returns A promise that resolves to `true` if successful.
243
+ */
47
244
  renameSharedLabel(args: RenameSharedLabelArgs): Promise<boolean>;
245
+ /**
246
+ * Removes a shared label.
247
+ *
248
+ * @param args - Parameters for removing the shared label.
249
+ * @returns A promise that resolves to `true` if successful.
250
+ */
48
251
  removeSharedLabel(args: RemoveSharedLabelArgs): Promise<boolean>;
252
+ /**
253
+ * Retrieves all comments associated with a task or project.
254
+ *
255
+ * @param args - Parameters for retrieving comments, such as task ID or project ID.
256
+ * @returns A promise that resolves to an array of comments.
257
+ */
49
258
  getComments(args: GetTaskCommentsArgs | GetProjectCommentsArgs): Promise<GetCommentsResponse>;
259
+ /**
260
+ * Retrieves a specific comment by its ID.
261
+ *
262
+ * @param id - The unique identifier of the comment to retrieve.
263
+ * @returns A promise that resolves to the requested comment.
264
+ */
50
265
  getComment(id: string): Promise<Comment>;
266
+ /**
267
+ * Adds a comment to a task or project.
268
+ *
269
+ * @param args - Parameters for creating the comment, such as content and the target task or project ID.
270
+ * @param requestId - Optional unique identifier for idempotency.
271
+ * @returns A promise that resolves to the created comment.
272
+ */
51
273
  addComment(args: AddCommentArgs, requestId?: string): Promise<Comment>;
274
+ /**
275
+ * Updates an existing comment by its ID.
276
+ *
277
+ * @param id - The unique identifier of the comment to update.
278
+ * @param args - Update parameters such as new content.
279
+ * @param requestId - Optional unique identifier for idempotency.
280
+ * @returns A promise that resolves to the updated comment.
281
+ */
52
282
  updateComment(id: string, args: UpdateCommentArgs, requestId?: string): Promise<Comment>;
283
+ /**
284
+ * Deletes a comment by its ID.
285
+ *
286
+ * @param id - The unique identifier of the comment to delete.
287
+ * @param requestId - Optional unique identifier for idempotency.
288
+ * @returns A promise that resolves to `true` if successful.
289
+ */
53
290
  deleteComment(id: string, requestId?: string): Promise<boolean>;
54
291
  }