@doist/todoist-api-typescript 4.0.0-alpha.1 → 4.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TodoistApi.d.ts +253 -37
- package/dist/TodoistApi.js +319 -25
- package/dist/authentication.d.ts +78 -4
- package/dist/authentication.js +58 -0
- package/dist/consts/endpoints.d.ts +2 -1
- package/dist/consts/endpoints.js +2 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/restClient.d.ts +1 -1
- package/dist/restClient.js +2 -2
- package/dist/testUtils/asserts.d.ts +0 -1
- package/dist/testUtils/asserts.js +1 -65
- package/dist/testUtils/testDefaults.d.ts +2 -2
- package/dist/types/entities.d.ts +477 -178
- package/dist/types/entities.js +107 -88
- package/dist/types/requests.d.ts +170 -24
- package/dist/types/sync.d.ts +21 -0
- package/dist/types/sync.js +2 -0
- package/dist/utils/colors.d.ts +14 -0
- package/dist/utils/colors.js +14 -0
- package/dist/utils/sanitization.d.ts +29 -0
- package/dist/utils/sanitization.js +29 -0
- package/dist/utils/taskConverters.js +1 -1
- package/dist/utils/validators.d.ts +1 -1
- package/dist/utils/validators.js +7 -7
- package/package.json +10 -10
package/dist/TodoistApi.d.ts
CHANGED
|
@@ -1,75 +1,291 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
|
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>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
12
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
|
+
*/
|
|
13
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
|
+
*/
|
|
14
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
|
+
*/
|
|
15
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
|
+
*/
|
|
16
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
|
+
*/
|
|
17
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
|
+
*/
|
|
18
112
|
getProject(id: string): Promise<Project>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
23
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
|
+
*/
|
|
24
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
|
+
*/
|
|
25
144
|
deleteProject(id: string, requestId?: string): Promise<boolean>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
34
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
|
+
*/
|
|
35
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
|
+
*/
|
|
36
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
|
+
*/
|
|
37
191
|
deleteSection(id: string, requestId?: string): Promise<boolean>;
|
|
38
192
|
/**
|
|
39
|
-
*
|
|
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.
|
|
40
197
|
*/
|
|
41
198
|
getLabel(id: string): Promise<Label>;
|
|
42
199
|
/**
|
|
43
|
-
*
|
|
200
|
+
* Retrieves all labels.
|
|
201
|
+
*
|
|
202
|
+
* @param args - Optional filter parameters.
|
|
203
|
+
* @returns A promise that resolves to an array of labels.
|
|
44
204
|
*/
|
|
45
|
-
getLabels(args?: GetLabelsArgs): Promise<
|
|
46
|
-
results: Label[];
|
|
47
|
-
nextCursor: string | null;
|
|
48
|
-
}>;
|
|
205
|
+
getLabels(args?: GetLabelsArgs): Promise<GetLabelsResponse>;
|
|
49
206
|
/**
|
|
50
|
-
* Adds a
|
|
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.
|
|
51
212
|
*/
|
|
52
213
|
addLabel(args: AddLabelArgs, requestId?: string): Promise<Label>;
|
|
53
214
|
/**
|
|
54
|
-
* Updates
|
|
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.
|
|
55
221
|
*/
|
|
56
222
|
updateLabel(id: string, args: UpdateLabelArgs, requestId?: string): Promise<Label>;
|
|
57
223
|
/**
|
|
58
|
-
* Deletes a
|
|
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.
|
|
59
229
|
*/
|
|
60
230
|
deleteLabel(id: string, requestId?: string): Promise<boolean>;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
65
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
|
+
*/
|
|
66
251
|
removeSharedLabel(args: RemoveSharedLabelArgs): Promise<boolean>;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
71
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
|
+
*/
|
|
72
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
|
+
*/
|
|
73
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
|
+
*/
|
|
74
290
|
deleteComment(id: string, requestId?: string): Promise<boolean>;
|
|
75
291
|
}
|